Commit a4743058 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

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: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2c8c1e72
...@@ -6542,92 +6542,94 @@ bnx2_close(struct net_device *dev) ...@@ -6542,92 +6542,94 @@ bnx2_close(struct net_device *dev)
return 0; return 0;
} }
#define GET_NET_STATS64(ctr) \ #define GET_64BIT_NET_STATS64(ctr) \
(unsigned long) ((unsigned long) (ctr##_hi) << 32) + \ (unsigned long) ((unsigned long) (ctr##_hi) << 32) + \
(unsigned long) (ctr##_lo) (unsigned long) (ctr##_lo)
#define GET_NET_STATS32(ctr) \ #define GET_64BIT_NET_STATS32(ctr) \
(ctr##_lo) (ctr##_lo)
#if (BITS_PER_LONG == 64) #if (BITS_PER_LONG == 64)
#define GET_NET_STATS GET_NET_STATS64 #define GET_64BIT_NET_STATS(ctr) \
GET_64BIT_NET_STATS64(bp->stats_blk->ctr)
#else #else
#define GET_NET_STATS GET_NET_STATS32 #define GET_64BIT_NET_STATS(ctr) \
GET_64BIT_NET_STATS32(bp->stats_blk->ctr)
#endif #endif
#define GET_32BIT_NET_STATS(ctr) \
(unsigned long) (bp->stats_blk->ctr)
static struct net_device_stats * static struct net_device_stats *
bnx2_get_stats(struct net_device *dev) bnx2_get_stats(struct net_device *dev)
{ {
struct bnx2 *bp = netdev_priv(dev); struct bnx2 *bp = netdev_priv(dev);
struct statistics_block *stats_blk = bp->stats_blk;
struct net_device_stats *net_stats = &dev->stats; struct net_device_stats *net_stats = &dev->stats;
if (bp->stats_blk == NULL) { if (bp->stats_blk == NULL) {
return net_stats; return net_stats;
} }
net_stats->rx_packets = net_stats->rx_packets =
GET_NET_STATS(stats_blk->stat_IfHCInUcastPkts) + GET_64BIT_NET_STATS(stat_IfHCInUcastPkts) +
GET_NET_STATS(stats_blk->stat_IfHCInMulticastPkts) + GET_64BIT_NET_STATS(stat_IfHCInMulticastPkts) +
GET_NET_STATS(stats_blk->stat_IfHCInBroadcastPkts); GET_64BIT_NET_STATS(stat_IfHCInBroadcastPkts);
net_stats->tx_packets = net_stats->tx_packets =
GET_NET_STATS(stats_blk->stat_IfHCOutUcastPkts) + GET_64BIT_NET_STATS(stat_IfHCOutUcastPkts) +
GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts) + GET_64BIT_NET_STATS(stat_IfHCOutMulticastPkts) +
GET_NET_STATS(stats_blk->stat_IfHCOutBroadcastPkts); GET_64BIT_NET_STATS(stat_IfHCOutBroadcastPkts);
net_stats->rx_bytes = net_stats->rx_bytes =
GET_NET_STATS(stats_blk->stat_IfHCInOctets); GET_64BIT_NET_STATS(stat_IfHCInOctets);
net_stats->tx_bytes = net_stats->tx_bytes =
GET_NET_STATS(stats_blk->stat_IfHCOutOctets); GET_64BIT_NET_STATS(stat_IfHCOutOctets);
net_stats->multicast = net_stats->multicast =
GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts); GET_64BIT_NET_STATS(stat_IfHCOutMulticastPkts);
net_stats->collisions = net_stats->collisions =
(unsigned long) stats_blk->stat_EtherStatsCollisions; GET_32BIT_NET_STATS(stat_EtherStatsCollisions);
net_stats->rx_length_errors = net_stats->rx_length_errors =
(unsigned long) (stats_blk->stat_EtherStatsUndersizePkts + GET_32BIT_NET_STATS(stat_EtherStatsUndersizePkts) +
stats_blk->stat_EtherStatsOverrsizePkts); GET_32BIT_NET_STATS(stat_EtherStatsOverrsizePkts);
net_stats->rx_over_errors = net_stats->rx_over_errors =
(unsigned long) (stats_blk->stat_IfInFTQDiscards + GET_32BIT_NET_STATS(stat_IfInFTQDiscards) +
stats_blk->stat_IfInMBUFDiscards); GET_32BIT_NET_STATS(stat_IfInMBUFDiscards);
net_stats->rx_frame_errors = net_stats->rx_frame_errors =
(unsigned long) stats_blk->stat_Dot3StatsAlignmentErrors; GET_32BIT_NET_STATS(stat_Dot3StatsAlignmentErrors);
net_stats->rx_crc_errors = net_stats->rx_crc_errors =
(unsigned long) stats_blk->stat_Dot3StatsFCSErrors; GET_32BIT_NET_STATS(stat_Dot3StatsFCSErrors);
net_stats->rx_errors = net_stats->rx_length_errors + net_stats->rx_errors = net_stats->rx_length_errors +
net_stats->rx_over_errors + net_stats->rx_frame_errors + net_stats->rx_over_errors + net_stats->rx_frame_errors +
net_stats->rx_crc_errors; net_stats->rx_crc_errors;
net_stats->tx_aborted_errors = net_stats->tx_aborted_errors =
(unsigned long) (stats_blk->stat_Dot3StatsExcessiveCollisions + GET_32BIT_NET_STATS(stat_Dot3StatsExcessiveCollisions) +
stats_blk->stat_Dot3StatsLateCollisions); GET_32BIT_NET_STATS(stat_Dot3StatsLateCollisions);
if ((CHIP_NUM(bp) == CHIP_NUM_5706) || if ((CHIP_NUM(bp) == CHIP_NUM_5706) ||
(CHIP_ID(bp) == CHIP_ID_5708_A0)) (CHIP_ID(bp) == CHIP_ID_5708_A0))
net_stats->tx_carrier_errors = 0; net_stats->tx_carrier_errors = 0;
else { else {
net_stats->tx_carrier_errors = net_stats->tx_carrier_errors =
(unsigned long) GET_32BIT_NET_STATS(stat_Dot3StatsCarrierSenseErrors);
stats_blk->stat_Dot3StatsCarrierSenseErrors;
} }
net_stats->tx_errors = net_stats->tx_errors =
(unsigned long) GET_32BIT_NET_STATS(stat_emac_tx_stat_dot3statsinternalmactransmiterrors) +
stats_blk->stat_emac_tx_stat_dot3statsinternalmactransmiterrors
+
net_stats->tx_aborted_errors + net_stats->tx_aborted_errors +
net_stats->tx_carrier_errors; net_stats->tx_carrier_errors;
net_stats->rx_missed_errors = net_stats->rx_missed_errors =
(unsigned long) (stats_blk->stat_IfInFTQDiscards + GET_32BIT_NET_STATS(stat_IfInFTQDiscards) +
stats_blk->stat_IfInMBUFDiscards + stats_blk->stat_FwRxDrop); GET_32BIT_NET_STATS(stat_IfInMBUFDiscards) +
GET_32BIT_NET_STATS(stat_FwRxDrop);
return net_stats; return net_stats;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment