diff options
author | Sathya Perla <sathya.perla@emulex.com> | 2011-08-22 15:41:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-08-24 19:19:29 -0400 |
commit | 09c1c68f2239dcd99b76be2c44e84811fba273db (patch) | |
tree | bbbede1f08fb5663a39528deabae91a20cef8969 /drivers/net/ethernet/emulex/benet | |
parent | db3ea7819d035ff01c8260fce364511adfae0eaa (diff) |
be2net: fix erx->rx_drops_no_frags wrap around
The rx_drops_no_frags HW counter for RSS rings is 16bits in HW and can
wraparound often. Maintain a 32-bit accumulator in the driver to prevent
frequent wraparound.
Also, incorporated Eric's feedback to use ACCESS_ONCE() for the accumulator
write.
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/emulex/benet')
-rw-r--r-- | drivers/net/ethernet/emulex/benet/be_main.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 2375c0c3d1b3..fb2eda08a094 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
@@ -378,6 +378,18 @@ static void populate_lancer_stats(struct be_adapter *adapter) | |||
378 | pport_stats->rx_drops_too_many_frags_lo; | 378 | pport_stats->rx_drops_too_many_frags_lo; |
379 | } | 379 | } |
380 | 380 | ||
381 | static void accumulate_16bit_val(u32 *acc, u16 val) | ||
382 | { | ||
383 | #define lo(x) (x & 0xFFFF) | ||
384 | #define hi(x) (x & 0xFFFF0000) | ||
385 | bool wrapped = val < lo(*acc); | ||
386 | u32 newacc = hi(*acc) + val; | ||
387 | |||
388 | if (wrapped) | ||
389 | newacc += 65536; | ||
390 | ACCESS_ONCE(*acc) = newacc; | ||
391 | } | ||
392 | |||
381 | void be_parse_stats(struct be_adapter *adapter) | 393 | void be_parse_stats(struct be_adapter *adapter) |
382 | { | 394 | { |
383 | struct be_erx_stats_v1 *erx = be_erx_stats_from_cmd(adapter); | 395 | struct be_erx_stats_v1 *erx = be_erx_stats_from_cmd(adapter); |
@@ -394,9 +406,13 @@ void be_parse_stats(struct be_adapter *adapter) | |||
394 | } | 406 | } |
395 | 407 | ||
396 | /* as erx_v1 is longer than v0, ok to use v1 defn for v0 access */ | 408 | /* as erx_v1 is longer than v0, ok to use v1 defn for v0 access */ |
397 | for_all_rx_queues(adapter, rxo, i) | 409 | for_all_rx_queues(adapter, rxo, i) { |
398 | rx_stats(rxo)->rx_drops_no_frags = | 410 | /* below erx HW counter can actually wrap around after |
399 | erx->rx_drops_no_fragments[rxo->q.id]; | 411 | * 65535. Driver accumulates a 32-bit value |
412 | */ | ||
413 | accumulate_16bit_val(&rx_stats(rxo)->rx_drops_no_frags, | ||
414 | (u16)erx->rx_drops_no_fragments[rxo->q.id]); | ||
415 | } | ||
400 | } | 416 | } |
401 | 417 | ||
402 | static struct rtnl_link_stats64 *be_get_stats64(struct net_device *netdev, | 418 | static struct rtnl_link_stats64 *be_get_stats64(struct net_device *netdev, |