DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/e1000: update UPDATE_VF_STAT to handle rollover
@ 2019-12-11  2:48 David Harton
  2020-01-26  9:41 ` Ye Xiaolong
  2020-01-26 17:25 ` [dpdk-dev] [PATCH v2] " David Harton
  0 siblings, 2 replies; 7+ messages in thread
From: David Harton @ 2019-12-11  2:48 UTC (permalink / raw)
  To: dev, wenzhuo.lu; +Cc: David Harton

Modified UPDATE_VF_STAT to properly handle rollover conditions.

Signed-off-by: David Harton <dharton@cisco.com>
---
 drivers/net/e1000/igb_ethdev.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index a3e30dbe5..825663267 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -261,11 +261,15 @@ static int igb_filter_restore(struct rte_eth_dev *dev);
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
-#define UPDATE_VF_STAT(reg, last, cur)            \
-{                                                 \
-	u32 latest = E1000_READ_REG(hw, reg);     \
-	cur += (latest - last) & UINT_MAX;        \
-	last = latest;                            \
+#define UPDATE_VF_STAT(reg, last, cur)                          \
+{                                                               \
+	u32 latest = E1000_READ_REG(hw, reg);                   \
+	if (latest >= last)                                     \
+		cur += (latest - last);                         \
+	else                                                    \
+		cur += ((latest + ((uint64_t)1 << 32)) - last); \
+	cur &= UINT_MAX;                                        \
+	last = latest;                                          \
 }
 
 #define IGB_FC_PAUSE_TIME 0x0680
-- 
2.19.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-31  8:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11  2:48 [dpdk-dev] [PATCH] net/e1000: update UPDATE_VF_STAT to handle rollover David Harton
2020-01-26  9:41 ` Ye Xiaolong
2020-01-26 17:25 ` [dpdk-dev] [PATCH v2] " David Harton
2020-01-29  7:53   ` Ye Xiaolong
2020-01-29 10:10   ` Ferruh Yigit
2020-01-29 17:56     ` David Harton (dharton)
2020-01-31  8:46     ` Ye Xiaolong

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).