netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sathya Perla <sathya.perla@emulex.com>
To: <netdev@vger.kernel.org>
Subject: [PATCH net-next 3/5] be2net: fix erx->rx_drops_no_frags wrap around
Date: Mon, 22 Aug 2011 16:43:31 +0530	[thread overview]
Message-ID: <1314011613-4519-4-git-send-email-sathya.perla@emulex.com> (raw)
In-Reply-To: <1314011613-4519-1-git-send-email-sathya.perla@emulex.com>

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.

Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
---
 drivers/net/ethernet/emulex/benet/be_main.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 2375c0c..4e588d8 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -378,6 +378,17 @@ static void populate_lancer_stats(struct be_adapter *adapter)
 				pport_stats->rx_drops_too_many_frags_lo;
 }
 
+static void accumulate_16bit_val(u32 *acc, u16 val)
+{
+#define lo(x)			(x & 0xFFFF)
+#define hi(x)			(x & 0xFFFF0000)
+	bool wrapped = val < lo(*acc);
+
+	*acc = hi(*acc) + val;
+	if (wrapped)
+		*acc += 65536;
+}
+
 void be_parse_stats(struct be_adapter *adapter)
 {
 	struct be_erx_stats_v1 *erx = be_erx_stats_from_cmd(adapter);
@@ -394,9 +405,13 @@ void be_parse_stats(struct be_adapter *adapter)
 	}
 
 	/* as erx_v1 is longer than v0, ok to use v1 defn for v0 access */
-	for_all_rx_queues(adapter, rxo, i)
-		rx_stats(rxo)->rx_drops_no_frags =
-			erx->rx_drops_no_fragments[rxo->q.id];
+	for_all_rx_queues(adapter, rxo, i) {
+		/* below erx HW counter can actually wrap around after
+		 * 65535. Driver accumulates a 32-bit value
+		 */
+		accumulate_16bit_val(&rx_stats(rxo)->rx_drops_no_frags,
+				(u16)erx->rx_drops_no_fragments[rxo->q.id]);
+	}
 }
 
 static struct rtnl_link_stats64 *be_get_stats64(struct net_device *netdev,
-- 
1.7.4


  parent reply	other threads:[~2011-08-22 11:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-22 11:13 [PATCH net-next 0/5] be2net: fixes Sathya Perla
2011-08-22 11:13 ` [PATCH net-next 1/5] be2net: Fix race in posting rx buffers Sathya Perla
2011-08-22 11:13 ` [PATCH net-next 2/5] be2net: get rid of memory mapped pci-cfg space address Sathya Perla
2011-08-22 11:13 ` Sathya Perla [this message]
2011-08-22 11:43   ` [PATCH net-next 3/5] be2net: fix erx->rx_drops_no_frags wrap around Eric Dumazet
2011-08-22 11:47     ` Eric Dumazet
2011-08-22 12:15       ` Sathya.Perla
2011-08-22 12:44         ` Eric Dumazet
2011-08-22 17:22           ` Sathya.Perla
2011-08-22 11:13 ` [PATCH net-next 4/5] be2net: increase FW update completion timeout Sathya Perla
2011-08-22 11:13 ` [PATCH net-next 5/5] be2net: remove unused variable Sathya Perla
  -- strict thread matches above, loose matches on Subject: below --
2011-08-23  5:41 [PATCH net-next 0/5] be2net fixes v2 Sathya Perla
2011-08-23  5:41 ` [PATCH net-next 3/5] be2net: fix erx->rx_drops_no_frags wrap around Sathya Perla
2011-08-23  6:41   ` Eric Dumazet
2011-08-23  7:06     ` Sathya.Perla
2011-08-23  7:29       ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314011613-4519-4-git-send-email-sathya.perla@emulex.com \
    --to=sathya.perla@emulex.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).