Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipmi: fix statistics counting issues

Bela Lubkin noticed that the statistics for send IPMB and LAN commands
in the IPMI driver could be incremented even if an error occurred. Move
the increments to the proper place to avoid this.

Also add some statistics for retransmissions that failed, and some little
helper functions to neaten up the code a little.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Bela Lubkin <blubkin@vmware.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Corey Minyard and committed by
Linus Torvalds
25176ed6 40112ae7

+51 -22
+51 -22
drivers/char/ipmi/ipmi_msghandler.c
··· 285 285 /* Events that were received with the proper format. */ 286 286 IPMI_STAT_events, 287 287 288 + /* Retransmissions on IPMB that failed. */ 289 + IPMI_STAT_dropped_rexmit_ipmb_commands, 290 + 291 + /* Retransmissions on LAN that failed. */ 292 + IPMI_STAT_dropped_rexmit_lan_commands, 288 293 289 294 /* This *must* remain last, add new values above this. */ 290 295 IPMI_NUM_STATS ··· 450 445 #define ipmi_get_stat(intf, stat) \ 451 446 ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat])) 452 447 448 + static int is_lan_addr(struct ipmi_addr *addr) 449 + { 450 + return addr->addr_type == IPMI_LAN_ADDR_TYPE; 451 + } 452 + 453 + static int is_ipmb_addr(struct ipmi_addr *addr) 454 + { 455 + return addr->addr_type == IPMI_IPMB_ADDR_TYPE; 456 + } 457 + 458 + static int is_ipmb_bcast_addr(struct ipmi_addr *addr) 459 + { 460 + return addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE; 461 + } 453 462 454 463 static void free_recv_msg_list(struct list_head *q) 455 464 { ··· 620 601 return (smi_addr1->lun == smi_addr2->lun); 621 602 } 622 603 623 - if ((addr1->addr_type == IPMI_IPMB_ADDR_TYPE) 624 - || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { 604 + if (is_ipmb_addr(addr1) || is_ipmb_bcast_addr(addr1)) { 625 605 struct ipmi_ipmb_addr *ipmb_addr1 626 606 = (struct ipmi_ipmb_addr *) addr1; 627 607 struct ipmi_ipmb_addr *ipmb_addr2 ··· 630 612 && (ipmb_addr1->lun == ipmb_addr2->lun)); 631 613 } 632 614 633 - if (addr1->addr_type == IPMI_LAN_ADDR_TYPE) { 615 + if (is_lan_addr(addr1)) { 634 616 struct ipmi_lan_addr *lan_addr1 635 617 = (struct ipmi_lan_addr *) addr1; 636 618 struct ipmi_lan_addr *lan_addr2 ··· 662 644 || (addr->channel < 0)) 663 645 return -EINVAL; 664 646 665 - if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 666 - || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { 647 + if (is_ipmb_addr(addr) || is_ipmb_bcast_addr(addr)) { 667 648 if (len < sizeof(struct ipmi_ipmb_addr)) 668 649 return -EINVAL; 669 650 return 0; 670 651 } 671 652 672 - if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { 653 + if (is_lan_addr(addr)) { 673 654 if (len < sizeof(struct ipmi_lan_addr)) 674 655 return -EINVAL; 675 656 return 0; ··· 1520 1503 memcpy(&(smi_msg->data[2]), msg->data, msg->data_len); 1521 1504 smi_msg->data_size = msg->data_len + 2; 1522 1505 ipmi_inc_stat(intf, sent_local_commands); 1523 - } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 1524 - || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { 1506 + } else if (is_ipmb_addr(addr) || is_ipmb_bcast_addr(addr)) { 1525 1507 struct ipmi_ipmb_addr *ipmb_addr; 1526 1508 unsigned char ipmb_seq; 1527 1509 long seqid; ··· 1599 1583 1600 1584 spin_lock_irqsave(&(intf->seq_lock), flags); 1601 1585 1602 - ipmi_inc_stat(intf, sent_ipmb_commands); 1603 - 1604 1586 /* 1605 1587 * Create a sequence number with a 1 second 1606 1588 * timeout and 4 retries. ··· 1619 1605 flags); 1620 1606 goto out_err; 1621 1607 } 1608 + 1609 + ipmi_inc_stat(intf, sent_ipmb_commands); 1622 1610 1623 1611 /* 1624 1612 * Store the sequence number in the message, ··· 1651 1635 */ 1652 1636 spin_unlock_irqrestore(&(intf->seq_lock), flags); 1653 1637 } 1654 - } else if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { 1638 + } else if (is_lan_addr(addr)) { 1655 1639 struct ipmi_lan_addr *lan_addr; 1656 1640 unsigned char ipmb_seq; 1657 1641 long seqid; ··· 1712 1696 1713 1697 spin_lock_irqsave(&(intf->seq_lock), flags); 1714 1698 1715 - ipmi_inc_stat(intf, sent_lan_commands); 1716 - 1717 1699 /* 1718 1700 * Create a sequence number with a 1 second 1719 1701 * timeout and 4 retries. ··· 1732 1718 flags); 1733 1719 goto out_err; 1734 1720 } 1721 + 1722 + ipmi_inc_stat(intf, sent_lan_commands); 1735 1723 1736 1724 /* 1737 1725 * Store the sequence number in the message, ··· 1953 1937 ipmi_get_stat(intf, invalid_events)); 1954 1938 out += sprintf(out, "events: %u\n", 1955 1939 ipmi_get_stat(intf, events)); 1940 + out += sprintf(out, "failed rexmit LAN msgs: %u\n", 1941 + ipmi_get_stat(intf, dropped_rexmit_lan_commands)); 1942 + out += sprintf(out, "failed rexmit IPMB msgs: %u\n", 1943 + ipmi_get_stat(intf, dropped_rexmit_ipmb_commands)); 1956 1944 1957 1945 return (out - ((char *) page)); 1958 1946 } ··· 3750 3730 list_add_tail(&msg->link, timeouts); 3751 3731 if (ent->broadcast) 3752 3732 ipmi_inc_stat(intf, timed_out_ipmb_broadcasts); 3753 - else if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) 3733 + else if (is_lan_addr(&ent->recv_msg->addr)) 3754 3734 ipmi_inc_stat(intf, timed_out_lan_commands); 3755 3735 else 3756 3736 ipmi_inc_stat(intf, timed_out_ipmb_commands); ··· 3764 3744 */ 3765 3745 ent->timeout = MAX_MSG_TIMEOUT; 3766 3746 ent->retries_left--; 3767 - if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) 3768 - ipmi_inc_stat(intf, retransmitted_lan_commands); 3769 - else 3770 - ipmi_inc_stat(intf, retransmitted_ipmb_commands); 3771 - 3772 3747 smi_msg = smi_from_recv_msg(intf, ent->recv_msg, slot, 3773 3748 ent->seqid); 3774 - if (!smi_msg) 3749 + if (!smi_msg) { 3750 + if (is_lan_addr(&ent->recv_msg->addr)) 3751 + ipmi_inc_stat(intf, 3752 + dropped_rexmit_lan_commands); 3753 + else 3754 + ipmi_inc_stat(intf, 3755 + dropped_rexmit_ipmb_commands); 3775 3756 return; 3757 + } 3776 3758 3777 3759 spin_unlock_irqrestore(&intf->seq_lock, *flags); 3778 3760 ··· 3786 3764 * resent. 3787 3765 */ 3788 3766 handlers = intf->handlers; 3789 - if (handlers) 3767 + if (handlers) { 3768 + if (is_lan_addr(&ent->recv_msg->addr)) 3769 + ipmi_inc_stat(intf, 3770 + retransmitted_lan_commands); 3771 + else 3772 + ipmi_inc_stat(intf, 3773 + retransmitted_ipmb_commands); 3774 + 3790 3775 intf->handlers->sender(intf->send_info, 3791 3776 smi_msg, 0); 3792 - else 3777 + } else 3793 3778 ipmi_free_smi_msg(smi_msg); 3794 3779 3795 3780 spin_lock_irqsave(&intf->seq_lock, *flags);