diff options
author | Michael Chan <mchan@broadcom.com> | 2010-01-17 02:30:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-17 22:16:02 -0500 |
commit | a47430583dab67b23161b0e75226781deed50138 (patch) | |
tree | 4d079334ac56ff14aafdacf54c2be7f965163d12 /drivers/net | |
parent | 2c8c1e7297e19bdef3c178c3ea41d898a7716e3e (diff) |
bnx2: Refine statistics code.
Refine the statistics macros by passing in just the name of the
counter field. This makes it a lot easier and cleaner to add
counters saved before the last reset in the next patch.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/bnx2.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index b1c20e5f7de8..47fb5086cf56 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -6542,92 +6542,94 @@ bnx2_close(struct net_device *dev) | |||
6542 | return 0; | 6542 | return 0; |
6543 | } | 6543 | } |
6544 | 6544 | ||
6545 | #define GET_NET_STATS64(ctr) \ | 6545 | #define GET_64BIT_NET_STATS64(ctr) \ |
6546 | (unsigned long) ((unsigned long) (ctr##_hi) << 32) + \ | 6546 | (unsigned long) ((unsigned long) (ctr##_hi) << 32) + \ |
6547 | (unsigned long) (ctr##_lo) | 6547 | (unsigned long) (ctr##_lo) |
6548 | 6548 | ||
6549 | #define GET_NET_STATS32(ctr) \ | 6549 | #define GET_64BIT_NET_STATS32(ctr) \ |
6550 | (ctr##_lo) | 6550 | (ctr##_lo) |
6551 | 6551 | ||
6552 | #if (BITS_PER_LONG == 64) | 6552 | #if (BITS_PER_LONG == 64) |
6553 | #define GET_NET_STATS GET_NET_STATS64 | 6553 | #define GET_64BIT_NET_STATS(ctr) \ |
6554 | GET_64BIT_NET_STATS64(bp->stats_blk->ctr) | ||
6554 | #else | 6555 | #else |
6555 | #define GET_NET_STATS GET_NET_STATS32 | 6556 | #define GET_64BIT_NET_STATS(ctr) \ |
6557 | GET_64BIT_NET_STATS32(bp->stats_blk->ctr) | ||
6556 | #endif | 6558 | #endif |
6557 | 6559 | ||
6560 | #define GET_32BIT_NET_STATS(ctr) \ | ||
6561 | (unsigned long) (bp->stats_blk->ctr) | ||
6562 | |||
6558 | static struct net_device_stats * | 6563 | static struct net_device_stats * |
6559 | bnx2_get_stats(struct net_device *dev) | 6564 | bnx2_get_stats(struct net_device *dev) |
6560 | { | 6565 | { |
6561 | struct bnx2 *bp = netdev_priv(dev); | 6566 | struct bnx2 *bp = netdev_priv(dev); |
6562 | struct statistics_block *stats_blk = bp->stats_blk; | ||
6563 | struct net_device_stats *net_stats = &dev->stats; | 6567 | struct net_device_stats *net_stats = &dev->stats; |
6564 | 6568 | ||
6565 | if (bp->stats_blk == NULL) { | 6569 | if (bp->stats_blk == NULL) { |
6566 | return net_stats; | 6570 | return net_stats; |
6567 | } | 6571 | } |
6568 | net_stats->rx_packets = | 6572 | net_stats->rx_packets = |
6569 | GET_NET_STATS(stats_blk->stat_IfHCInUcastPkts) + | 6573 | GET_64BIT_NET_STATS(stat_IfHCInUcastPkts) + |
6570 | GET_NET_STATS(stats_blk->stat_IfHCInMulticastPkts) + | 6574 | GET_64BIT_NET_STATS(stat_IfHCInMulticastPkts) + |
6571 | GET_NET_STATS(stats_blk->stat_IfHCInBroadcastPkts); | 6575 | GET_64BIT_NET_STATS(stat_IfHCInBroadcastPkts); |
6572 | 6576 | ||
6573 | net_stats->tx_packets = | 6577 | net_stats->tx_packets = |
6574 | GET_NET_STATS(stats_blk->stat_IfHCOutUcastPkts) + | 6578 | GET_64BIT_NET_STATS(stat_IfHCOutUcastPkts) + |
6575 | GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts) + | 6579 | GET_64BIT_NET_STATS(stat_IfHCOutMulticastPkts) + |
6576 | GET_NET_STATS(stats_blk->stat_IfHCOutBroadcastPkts); | 6580 | GET_64BIT_NET_STATS(stat_IfHCOutBroadcastPkts); |
6577 | 6581 | ||
6578 | net_stats->rx_bytes = | 6582 | net_stats->rx_bytes = |
6579 | GET_NET_STATS(stats_blk->stat_IfHCInOctets); | 6583 | GET_64BIT_NET_STATS(stat_IfHCInOctets); |
6580 | 6584 | ||
6581 | net_stats->tx_bytes = | 6585 | net_stats->tx_bytes = |
6582 | GET_NET_STATS(stats_blk->stat_IfHCOutOctets); | 6586 | GET_64BIT_NET_STATS(stat_IfHCOutOctets); |
6583 | 6587 | ||
6584 | net_stats->multicast = | 6588 | net_stats->multicast = |
6585 | GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts); | 6589 | GET_64BIT_NET_STATS(stat_IfHCOutMulticastPkts); |
6586 | 6590 | ||
6587 | net_stats->collisions = | 6591 | net_stats->collisions = |
6588 | (unsigned long) stats_blk->stat_EtherStatsCollisions; | 6592 | GET_32BIT_NET_STATS(stat_EtherStatsCollisions); |
6589 | 6593 | ||
6590 | net_stats->rx_length_errors = | 6594 | net_stats->rx_length_errors = |
6591 | (unsigned long) (stats_blk->stat_EtherStatsUndersizePkts + | 6595 | GET_32BIT_NET_STATS(stat_EtherStatsUndersizePkts) + |
6592 | stats_blk->stat_EtherStatsOverrsizePkts); | 6596 | GET_32BIT_NET_STATS(stat_EtherStatsOverrsizePkts); |
6593 | 6597 | ||
6594 | net_stats->rx_over_errors = | 6598 | net_stats->rx_over_errors = |
6595 | (unsigned long) (stats_blk->stat_IfInFTQDiscards + | 6599 | GET_32BIT_NET_STATS(stat_IfInFTQDiscards) + |
6596 | stats_blk->stat_IfInMBUFDiscards); | 6600 | GET_32BIT_NET_STATS(stat_IfInMBUFDiscards); |
6597 | 6601 | ||
6598 | net_stats->rx_frame_errors = | 6602 | net_stats->rx_frame_errors = |
6599 | (unsigned long) stats_blk->stat_Dot3StatsAlignmentErrors; | 6603 | GET_32BIT_NET_STATS(stat_Dot3StatsAlignmentErrors); |
6600 | 6604 | ||
6601 | net_stats->rx_crc_errors = | 6605 | net_stats->rx_crc_errors = |
6602 | (unsigned long) stats_blk->stat_Dot3StatsFCSErrors; | 6606 | GET_32BIT_NET_STATS(stat_Dot3StatsFCSErrors); |
6603 | 6607 | ||
6604 | net_stats->rx_errors = net_stats->rx_length_errors + | 6608 | net_stats->rx_errors = net_stats->rx_length_errors + |
6605 | net_stats->rx_over_errors + net_stats->rx_frame_errors + | 6609 | net_stats->rx_over_errors + net_stats->rx_frame_errors + |
6606 | net_stats->rx_crc_errors; | 6610 | net_stats->rx_crc_errors; |
6607 | 6611 | ||
6608 | net_stats->tx_aborted_errors = | 6612 | net_stats->tx_aborted_errors = |
6609 | (unsigned long) (stats_blk->stat_Dot3StatsExcessiveCollisions + | 6613 | GET_32BIT_NET_STATS(stat_Dot3StatsExcessiveCollisions) + |
6610 | stats_blk->stat_Dot3StatsLateCollisions); | 6614 | GET_32BIT_NET_STATS(stat_Dot3StatsLateCollisions); |
6611 | 6615 | ||
6612 | if ((CHIP_NUM(bp) == CHIP_NUM_5706) || | 6616 | if ((CHIP_NUM(bp) == CHIP_NUM_5706) || |
6613 | (CHIP_ID(bp) == CHIP_ID_5708_A0)) | 6617 | (CHIP_ID(bp) == CHIP_ID_5708_A0)) |
6614 | net_stats->tx_carrier_errors = 0; | 6618 | net_stats->tx_carrier_errors = 0; |
6615 | else { | 6619 | else { |
6616 | net_stats->tx_carrier_errors = | 6620 | net_stats->tx_carrier_errors = |
6617 | (unsigned long) | 6621 | GET_32BIT_NET_STATS(stat_Dot3StatsCarrierSenseErrors); |
6618 | stats_blk->stat_Dot3StatsCarrierSenseErrors; | ||
6619 | } | 6622 | } |
6620 | 6623 | ||
6621 | net_stats->tx_errors = | 6624 | net_stats->tx_errors = |
6622 | (unsigned long) | 6625 | GET_32BIT_NET_STATS(stat_emac_tx_stat_dot3statsinternalmactransmiterrors) + |
6623 | stats_blk->stat_emac_tx_stat_dot3statsinternalmactransmiterrors | ||
6624 | + | ||
6625 | net_stats->tx_aborted_errors + | 6626 | net_stats->tx_aborted_errors + |
6626 | net_stats->tx_carrier_errors; | 6627 | net_stats->tx_carrier_errors; |
6627 | 6628 | ||
6628 | net_stats->rx_missed_errors = | 6629 | net_stats->rx_missed_errors = |
6629 | (unsigned long) (stats_blk->stat_IfInFTQDiscards + | 6630 | GET_32BIT_NET_STATS(stat_IfInFTQDiscards) + |
6630 | stats_blk->stat_IfInMBUFDiscards + stats_blk->stat_FwRxDrop); | 6631 | GET_32BIT_NET_STATS(stat_IfInMBUFDiscards) + |
6632 | GET_32BIT_NET_STATS(stat_FwRxDrop); | ||
6631 | 6633 | ||
6632 | return net_stats; | 6634 | return net_stats; |
6633 | } | 6635 | } |