Commit 6e53391c authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: fix netdev_stats_update

Problem initially reproted and fixed by Eric Dumazet <eric.dumazet@gmail.com>

netdev_stats_update() resets netdev->stats and then accumulates stats from
various rings. This is wrong as stats readers can sometimes catch zero values.
Use temporary variables instead for accumulating per-ring values.
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c6af9c40
...@@ -428,33 +428,38 @@ void netdev_stats_update(struct be_adapter *adapter) ...@@ -428,33 +428,38 @@ void netdev_stats_update(struct be_adapter *adapter)
struct net_device_stats *dev_stats = &adapter->netdev->stats; struct net_device_stats *dev_stats = &adapter->netdev->stats;
struct be_rx_obj *rxo; struct be_rx_obj *rxo;
struct be_tx_obj *txo; struct be_tx_obj *txo;
unsigned long pkts = 0, bytes = 0, mcast = 0, drops = 0;
int i; int i;
memset(dev_stats, 0, sizeof(*dev_stats));
for_all_rx_queues(adapter, rxo, i) { for_all_rx_queues(adapter, rxo, i) {
dev_stats->rx_packets += rx_stats(rxo)->rx_pkts; pkts += rx_stats(rxo)->rx_pkts;
dev_stats->rx_bytes += rx_stats(rxo)->rx_bytes; bytes += rx_stats(rxo)->rx_bytes;
dev_stats->multicast += rx_stats(rxo)->rx_mcast_pkts; mcast += rx_stats(rxo)->rx_mcast_pkts;
/* no space in linux buffers: best possible approximation */ /* no space in linux buffers: best possible approximation */
if (adapter->generation == BE_GEN3) { if (adapter->generation == BE_GEN3) {
if (!(lancer_chip(adapter))) { if (!(lancer_chip(adapter))) {
struct be_erx_stats_v1 *erx_stats = struct be_erx_stats_v1 *erx =
be_erx_stats_from_cmd(adapter); be_erx_stats_from_cmd(adapter);
dev_stats->rx_dropped += drops += erx->rx_drops_no_fragments[rxo->q.id];
erx_stats->rx_drops_no_fragments[rxo->q.id];
} }
} else { } else {
struct be_erx_stats_v0 *erx_stats = struct be_erx_stats_v0 *erx =
be_erx_stats_from_cmd(adapter); be_erx_stats_from_cmd(adapter);
dev_stats->rx_dropped += drops += erx->rx_drops_no_fragments[rxo->q.id];
erx_stats->rx_drops_no_fragments[rxo->q.id];
} }
} }
dev_stats->rx_packets = pkts;
dev_stats->rx_bytes = bytes;
dev_stats->multicast = mcast;
dev_stats->rx_dropped = drops;
pkts = bytes = 0;
for_all_tx_queues(adapter, txo, i) { for_all_tx_queues(adapter, txo, i) {
dev_stats->tx_packets += tx_stats(txo)->be_tx_pkts; pkts += tx_stats(txo)->be_tx_pkts;
dev_stats->tx_bytes += tx_stats(txo)->be_tx_bytes; bytes += tx_stats(txo)->be_tx_bytes;
} }
dev_stats->tx_packets = pkts;
dev_stats->tx_bytes = bytes;
/* bad pkts received */ /* bad pkts received */
dev_stats->rx_errors = drvs->rx_crc_errors + dev_stats->rx_errors = drvs->rx_crc_errors +
......
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