net/e1000: update UPDATE_VF_STAT to handle rollover

Message ID 20191211024802.17978-1-dharton@cisco.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers
Series net/e1000: update UPDATE_VF_STAT to handle rollover |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot warning Travis build: failed
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

David Harton Dec. 11, 2019, 2:48 a.m. UTC
  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(-)
  

Comments

Xiaolong Ye Jan. 26, 2020, 9:41 a.m. UTC | #1
On 12/10, David Harton wrote:
>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
>

Could you provide Fixes: tag and cc stable?

Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
  

Patch

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