Skip to contentSkip to conversation

fix defects of macro in VF

PATCH Superseded Guinan Sun 3 participants 15 messages May 8, 2020 – May 19, 2020 Network drivers

lore
Share & tools
lore

Guinan Sun

author
#0 lore raw

cover fix defects of macro in VF

The defects of UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result. The issues exist only in ixgbe and e1000 NICs.

Guinan Sun (2):
net/ixgbe: fix defects of macro in VF
net/e1000: fix defects of macro in VF

 drivers/net/e1000/igb_ethdev.c   | 14 +++++++++++---
 drivers/net/ixgbe/ixgbe_ethdev.c | 20 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 net/ixgbe: fix defects of macro in VF

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result.
The patch fixes the defect.

Fixes abf7275bbaa2 ("ixgbe: move to drivers/net/")
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +18 -2
index cf5f1fe70..08a964399 100644
@@ -94,6 +94,10 @@
 #define IXGBE_4_BIT_MASK   RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
 #define IXGBE_8_BIT_WIDTH  CHAR_BIT
 #define IXGBE_8_BIT_MASK   UINT8_MAX
+#define IXGBE_32_BIT_WIDTH (CHAR_BIT * 4)
+#define IXGBE_32_BIT_MASK  RTE_LEN2MASK(IXGBE_32_BIT_WIDTH, uint32_t)
+#define IXGBE_36_BIT_WIDTH (CHAR_BIT * 4 + IXGBE_4_BIT_WIDTH)
+#define IXGBE_36_BIT_MASK  RTE_LEN2MASK(IXGBE_36_BIT_WIDTH, uint64_t)
 
 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
 
@@ -388,7 +392,13 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 #define UPDATE_VF_STAT(reg, last, cur)                          \
 {                                                               \
 	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
-	cur += (latest - last) & UINT_MAX;                      \
+	u64 stat = 0;                                           \
+	if (latest >= last)                                     \
+		stat = latest - last;                           \
+	else                                                    \
+		stat = (u64)((latest +                          \
+			((u64)1 << IXGBE_32_BIT_WIDTH)) - last);\
+	cur += stat & IXGBE_32_BIT_MASK;                        \
 	last = latest;                                          \
 }
 
@@ -397,7 +407,13 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
 	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
 	u64 latest = ((new_msb << 32) | new_lsb);                \
-	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
+	u64 stat = 0;                                            \
+	if (latest >= last)                                      \
+		stat = latest - last;                            \
+	else                                                     \
+		stat = (u64)((latest +                           \
+			((u64)1 << IXGBE_36_BIT_WIDTH)) - last); \
+	cur += stat & IXGBE_36_BIT_MASK;                         \
 	last = latest;                                           \
 }
 
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/2 net/e1000: fix defects of macro in VF

In reply to Guinan Sun

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result.
The patch fixes the defect.

Fixes d15fcf76c8b7 ("e1000: move to drivers/net/")
---
 drivers/net/e1000/igb_ethdev.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/e1000/igb_ethdev.c +11 -3
index 520fba8fa..d6032fd65 100644
@@ -47,6 +47,8 @@
 #define IGB_4_BIT_MASK   RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t)
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
+#define IGB_32_BIT_WIDTH (CHAR_BIT * 4)
+#define IGB_32_BIT_MASK  RTE_LEN2MASK(IGB_32_BIT_WIDTH, uint32_t)
 
 /* Additional timesync values. */
 #define E1000_CYCLECOUNTER_MASK      0xffffffffffffffffULL
@@ -263,9 +265,15 @@ static int igb_filter_restore(struct rte_eth_dev *dev);
  */
 #define UPDATE_VF_STAT(reg, last, cur)            \
 {                                                 \
-	u32 latest = E1000_READ_REG(hw, reg);     \
-	cur += (latest - last) & UINT_MAX;        \
-	last = latest;                            \
+	uint64_t latest = E1000_READ_REG(hw, reg);                 \
+	uint64_t stat = 0;                                         \
+	if (latest >= last)                                        \
+		stat = latest - last;                              \
+	else                                                       \
+		stat = (uint64_t)((latest +                        \
+			((uint64_t)1 << IGB_32_BIT_WIDTH)) - last);\
+	cur += stat & IGB_32_BIT_MASK;                             \
+	last = latest;                                             \
 }
 
 #define IGB_FC_PAUSE_TIME 0x0680
Signature · 1 line
2.17.1
#3 lore raw
In reply to Guinan Sun

Hi,
Please alaign " \" in each line.

Quoted 21 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Friday, May 8, 2020 9:59 AM
To: [email protected]
Cc: Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH 0/2] fix defects of macro in VF

The defects of UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result. The issues exist only in ixgbe and e1000 NICs.

Guinan Sun (2):
net/ixgbe: fix defects of macro in VF
net/e1000: fix defects of macro in VF

 drivers/net/e1000/igb_ethdev.c   | 14 +++++++++++---
 drivers/net/ixgbe/ixgbe_ethdev.c | 20 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 5 deletions(-)

--
2.17.1

#4 lore raw

Hi ZhaoWei

Quoted 9 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Friday, May 8, 2020 10:19 AM
To: Sun, GuinanX <[email protected]>; [email protected]
Cc: Sun, GuinanX <[email protected]>; Guo, Jia <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 0/2] fix defects of macro in VF

Hi,
Please alaign " \" in each line.

It will be modified in V2 patch.
Remark: It can't be aligned in vim tool and email at the same time. It will be aligned in vim tool in v2 patch.

Quoted 24 lines
Quoted 23 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Friday, May 8, 2020 9:59 AM
To: [email protected]
Cc: Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH 0/2] fix defects of macro in VF

The defects of UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result. The issues exist only in ixgbe and e1000 NICs.

Guinan Sun (2):
net/ixgbe: fix defects of macro in VF
net/e1000: fix defects of macro in VF

 drivers/net/e1000/igb_ethdev.c   | 14 +++++++++++---
 drivers/net/ixgbe/ixgbe_ethdev.c | 20 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 5 deletions(-)

--
2.17.1

#5 lore raw
Quoted 18 lines

-----Original Message-----
From: Sun, GuinanX <[email protected]>
Sent: Friday, May 8, 2020 1:07 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: Guo, Jia <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 0/2] fix defects of macro in VF

Hi ZhaoWei

Quoted 7 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Friday, May 8, 2020 10:19 AM
To: Sun, GuinanX <[email protected]>; [email protected]
Cc: Sun, GuinanX <[email protected]>; Guo, Jia <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 0/2] fix defects of macro in VF

Quoted 8 lines
Quoted 2 lines

Hi,
Please alaign " \" in each line.

It will be modified in V2 patch.
Remark: It can't be aligned in vim tool and email at the same time. It will be aligned in vim tool in v2 patch.

Quoted 1 line

Ok.

Quoted 24 lines
Quoted 23 lines
Quoted 22 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Friday, May 8, 2020 9:59 AM
To: [email protected]
Cc: Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH 0/2] fix defects of macro in VF

The defects of UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result. The issues exist only in ixgbe and e1000 NICs.

Guinan Sun (2):
net/ixgbe: fix defects of macro in VF
net/e1000: fix defects of macro in VF

 drivers/net/e1000/igb_ethdev.c   | 14 +++++++++++---
 drivers/net/ixgbe/ixgbe_ethdev.c | 20 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 5 deletions(-)

--
2.17.1

author
#6 lore raw

v2 cover fix defects of macro in VF

In reply to Guinan Sun

The defects of UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result. The issues exist only in ixgbe and e1000 NICs.
---
v2 changes:
* Aligned line-continuation character "\".

Guinan Sun (2):
net/ixgbe: fix defects of macro in VF
net/e1000: fix defects of macro in VF

 drivers/net/e1000/igb_ethdev.c   | 18 +++++++++++++-----
 drivers/net/ixgbe/ixgbe_ethdev.c | 32 ++++++++++++++++++++++++--------
 2 files changed, 37 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v2 1/2 net/ixgbe: fix defects of macro in VF

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result.
The patch fixes the defect.

Fixes abf7275bbaa2 ("ixgbe: move to drivers/net/")

---
v2 changes:
* Aligned line-continuation character "\".

---
 drivers/net/ixgbe/ixgbe_ethdev.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +24 -8
index cf5f1fe70..57368c79c 100644
@@ -94,6 +94,10 @@
 #define IXGBE_4_BIT_MASK   RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
 #define IXGBE_8_BIT_WIDTH  CHAR_BIT
 #define IXGBE_8_BIT_MASK   UINT8_MAX
+#define IXGBE_32_BIT_WIDTH (CHAR_BIT * 4)
+#define IXGBE_32_BIT_MASK  RTE_LEN2MASK(IXGBE_32_BIT_WIDTH, uint32_t)
+#define IXGBE_36_BIT_WIDTH (CHAR_BIT * 4 + IXGBE_4_BIT_WIDTH)
+#define IXGBE_36_BIT_MASK  RTE_LEN2MASK(IXGBE_36_BIT_WIDTH, uint64_t)
 
 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
 
@@ -388,17 +392,29 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 #define UPDATE_VF_STAT(reg, last, cur)                          \
 {                                                               \
 	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
-	cur += (latest - last) & UINT_MAX;                      \
+	u64 stat = 0;                                           \
+	if (latest >= last)                                     \
+		stat = latest - last;                           \
+	else                                                    \
+		stat = (u64)((latest +                          \
+			((u64)1 << IXGBE_32_BIT_WIDTH)) - last);\
+	cur += stat & IXGBE_32_BIT_MASK;                        \
 	last = latest;                                          \
 }
 
-#define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur)                \
-{                                                                \
-	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
-	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
-	u64 latest = ((new_msb << 32) | new_lsb);                \
-	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
-	last = latest;                                           \
+#define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur)               \
+{                                                               \
+	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                  \
+	u64 new_msb = IXGBE_READ_REG(hw, msb);                  \
+	u64 latest = ((new_msb << 32) | new_lsb);               \
+	u64 stat = 0;                                           \
+	if (latest >= last)                                     \
+		stat = latest - last;                           \
+	else                                                    \
+		stat = (u64)((latest +                          \
+			((u64)1 << IXGBE_36_BIT_WIDTH)) - last);\
+	cur += stat & IXGBE_36_BIT_MASK;                        \
+	last = latest;                                          \
 }
 
 #define IXGBE_SET_HWSTRIP(h, q) do {\
Signature · 1 line
2.17.1
author
#8 lore raw

PATCH v2 2/2 net/e1000: fix defects of macro in VF

In reply to Guinan Sun

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result.
The patch fixes the defect.

Fixes d15fcf76c8b7 ("e1000: move to drivers/net/")

---
v2 changes:
* Aligned line-continuation character "\".

---
 drivers/net/e1000/igb_ethdev.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/e1000/igb_ethdev.c +13 -5
index 520fba8fa..4cd4e55c0 100644
@@ -47,6 +47,8 @@
 #define IGB_4_BIT_MASK   RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t)
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
+#define IGB_32_BIT_WIDTH (CHAR_BIT * 4)
+#define IGB_32_BIT_MASK  RTE_LEN2MASK(IGB_32_BIT_WIDTH, uint32_t)
 
 /* Additional timesync values. */
 #define E1000_CYCLECOUNTER_MASK      0xffffffffffffffffULL
@@ -261,11 +263,17 @@ 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)                             \
+{                                                                  \
+	uint64_t latest = E1000_READ_REG(hw, reg);                 \
+	uint64_t stat = 0;                                         \
+	if (latest >= last)                                        \
+		stat = latest - last;                              \
+	else                                                       \
+		stat = (uint64_t)((latest +                        \
+			((uint64_t)1 << IGB_32_BIT_WIDTH)) - last);\
+	cur += stat & IGB_32_BIT_MASK;                             \
+	last = latest;                                             \
 }
 
 #define IGB_FC_PAUSE_TIME 0x0680
Signature · 1 line
2.17.1
#9 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Hi, guinan

Quoted 3 lines · Guinan Sun

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result.
The patch fixes the defect.

There was similar patch before, https://patches.dpdk.org/patch/65131/, if I understand it correctly, you are trying to solve the rollover issue, right? Could you find the Ferruh's comment and check if this is a real issue?

Quoted 2 lines
Fixes d15fcf76c8b7 ("e1000: move to drivers/net/")

This fix commit isn't correct.

Thanks,
Xiaolong

Quoted 52 lines

---
v2 changes:
* Aligned line-continuation character "\".
---
drivers/net/e1000/igb_ethdev.c | 18 +++++++++++++-----

1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/e1000/igb_ethdev.c +13 -5
index 520fba8fa..4cd4e55c0 100644
@@ -47,6 +47,8 @@
 #define IGB_4_BIT_MASK   RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t)
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
+#define IGB_32_BIT_WIDTH (CHAR_BIT * 4)
+#define IGB_32_BIT_MASK  RTE_LEN2MASK(IGB_32_BIT_WIDTH, uint32_t)
 
 /* Additional timesync values. */
 #define E1000_CYCLECOUNTER_MASK      0xffffffffffffffffULL
@@ -261,11 +263,17 @@ 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)                             \
+{                                                                  \
+	uint64_t latest = E1000_READ_REG(hw, reg);                 \
+	uint64_t stat = 0;                                         \
+	if (latest >= last)                                        \
+		stat = latest - last;                              \
+	else                                                       \
+		stat = (uint64_t)((latest +                        \
+			((uint64_t)1 << IGB_32_BIT_WIDTH)) - last);\
+	cur += stat & IGB_32_BIT_MASK;                             \
+	last = latest;                                             \
 }
 
 #define IGB_FC_PAUSE_TIME 0x0680
Signature · 1 line
2.17.1
#10 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Hi, xiaolong

Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ye Xiaolong
Sent: Monday, May 18, 2020 9:25 AM
To: Sun, GuinanX <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Hi, guinan

On 05/08, Guinan Sun wrote:

Quoted 8 lines
Quoted 1 line

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT

exist.

Quoted 2 lines

If latest is less than last, we will get wrong result. The patch fixes the defect.

There was similar patch before, https://patches.dpdk.org/patch/65131/, if I understand it correctly, you are trying to solve the rollover issue, right? Could you find the Ferruh's comment and check if this is a real issue?

this issue has not been fixed by now, we need this patch to fix it. If (latest < last), there will be issue, is that right?

Quoted 64 lines
Quoted 3 lines
Fixes d15fcf76c8b7 ("e1000: move to drivers/net/")

This fix commit isn't correct.

Thanks,
Xiaolong

Quoted 27 lines

---
v2 changes:
* Aligned line-continuation character "\".
---
drivers/net/e1000/igb_ethdev.c | 18 +++++++++++++-----

1 file changed, 13 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/net/e1000/igb_ethdev.c index 520fba8fa..4cd4e55c0 100644

drivers/net/e1000/igb_ethdev.c +2 -0
@@ -47,6 +47,8 @@
 #define IGB_4_BIT_MASK   RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t)
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
+#define IGB_32_BIT_WIDTH (CHAR_BIT * 4) #define IGB_32_BIT_MASK
+RTE_LEN2MASK(IGB_32_BIT_WIDTH, uint32_t)
 
 /* Additional timesync values. */
 #define E1000_CYCLECOUNTER_MASK      0xffffffffffffffffULL

drivers/net/e1000/igb_ethdev.c static int igb_filter_restore(struct rte_eth_dev · line 267

Quoted 10 lines
drivers/net/e1000/igb_ethdev.c +1 -5
@@ -261,11 +263,17 @@ 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)

\

drivers/net/e1000/igb_ethdev.c static int igb_filter_restore(struct rte_eth_dev · line 268

Quoted 1 line
drivers/net/e1000/igb_ethdev.c +1 -0
+{
     \
Quoted 15 lines
drivers/net/e1000/igb_ethdev.c +9 -0
+	uint64_t latest = E1000_READ_REG(hw, reg);                 \
+	uint64_t stat = 0;                                         \
+	if (latest >= last)                                        \
+		stat = latest - last;                              \
+	else                                                       \
+		stat = (uint64_t)((latest +                        \
+			((uint64_t)1 << IGB_32_BIT_WIDTH)) - last);\
+	cur += stat & IGB_32_BIT_MASK;                             \
+	last = latest;                                             \
 }
 

#define IGB_FC_PAUSE_TIME 0x0680
--
2.17.1

#11 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Hi, wei

Quoted 18 lines · Wei

Hi, xiaolong

Quoted 16 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ye Xiaolong
Sent: Monday, May 18, 2020 9:25 AM
To: Sun, GuinanX <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Hi, guinan

Quoted 1 line · Guinan Sun

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT

exist.

Quoted 2 lines

If latest is less than last, we will get wrong result. The patch fixes the defect.

Quoted 6 lines
Quoted 3 lines

There was similar patch before, https://patches.dpdk.org/patch/65131/, if I understand it correctly, you are trying to solve the rollover issue, right? Could you find the Ferruh's comment and check if this is a real issue?

this issue has not been fixed by now, we need this patch to fix it. If (latest < last), there will be issue, is that right?

Actually the rollover case has been covered by original code.

Thanks,
Xiaolong

Quoted 66 lines
Quoted 66 lines
Quoted 5 lines
Fixes d15fcf76c8b7 ("e1000: move to drivers/net/")

This fix commit isn't correct.

Thanks,
Xiaolong

Quoted 27 lines

---
v2 changes:
* Aligned line-continuation character "\".
---
drivers/net/e1000/igb_ethdev.c | 18 +++++++++++++-----

1 file changed, 13 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/net/e1000/igb_ethdev.c index 520fba8fa..4cd4e55c0 100644

drivers/net/e1000/igb_ethdev.c +2 -0
@@ -47,6 +47,8 @@
 #define IGB_4_BIT_MASK   RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t)
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
+#define IGB_32_BIT_WIDTH (CHAR_BIT * 4) #define IGB_32_BIT_MASK
+RTE_LEN2MASK(IGB_32_BIT_WIDTH, uint32_t)
 
 /* Additional timesync values. */
 #define E1000_CYCLECOUNTER_MASK      0xffffffffffffffffULL

drivers/net/e1000/igb_ethdev.c static int igb_filter_restore(struct rte_eth_dev · line 267

Quoted 10 lines
drivers/net/e1000/igb_ethdev.c +1 -5
@@ -261,11 +263,17 @@ 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)

\

drivers/net/e1000/igb_ethdev.c static int igb_filter_restore(struct rte_eth_dev · line 268

Quoted 1 line
drivers/net/e1000/igb_ethdev.c +1 -0
+{
     \
Quoted 15 lines
drivers/net/e1000/igb_ethdev.c +9 -0
+uint64_t latest = E1000_READ_REG(hw, reg);                 \
+uint64_t stat = 0;                                         \
+if (latest >= last)                                        \
+stat = latest - last;                              \
+else                                                       \
+stat = (uint64_t)((latest +                        \
+((uint64_t)1 << IGB_32_BIT_WIDTH)) - last);\
+cur += stat & IGB_32_BIT_MASK;                             \
+last = latest;                                             \
 }
 

#define IGB_FC_PAUSE_TIME 0x0680
--
2.17.1

#12 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Quoted 34 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Tuesday, May 19, 2020 7:39 AM
To: Zhao1, Wei <[email protected]>
Cc: Sun, GuinanX <[email protected]>; [email protected]; [email protected]; Min, JiaqiX <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Hi, wei

Quoted 20 lines · Wei

Hi, xiaolong

Quoted 18 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ye Xiaolong
Sent: Monday, May 18, 2020 9:25 AM
To: Sun, GuinanX <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

Hi, guinan

Quoted 1 line · Guinan Sun

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT

exist.

Quoted 2 lines

If latest is less than last, we will get wrong result. The patch fixes the defect.

There was similar patch before,
https://patches.dpdk.org/patch/65131/, if I understand it correctly, you are

Quoted 7 lines

trying to solve the rollover issue, right?

Quoted 4 lines
Quoted 1 line

Could you find the Ferruh's comment and check if this is a real issue?

this issue has not been fixed by now, we need this patch to fix it. If (latest < last), there will be issue, is that right?

Actually the rollover case has been covered by original code.

Yes, you are right.

Quoted 72 lines

Thanks,
Xiaolong

Quoted 24 lines
Quoted 24 lines
Quoted 5 lines
Fixes d15fcf76c8b7 ("e1000: move to drivers/net/")

This fix commit isn't correct.

Thanks,
Xiaolong

Quoted 13 lines

---
v2 changes:
* Aligned line-continuation character "\".
---
drivers/net/e1000/igb_ethdev.c | 18 +++++++++++++-----

1 file changed, 13 insertions(+), 5 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/net/e1000/igb_ethdev.c line 47

Quoted 6 lines
(quoted diff) +0 -0

b/drivers/net/e1000/igb_ethdev.c index 520fba8fa..4cd4e55c0 100644

drivers/net/e1000/igb_ethdev.c +0 -0
@@ -47,6 +47,8 @@
 #define IGB_4_BIT_MASK   RTE_LEN2MASK(IGB_4_BIT_WIDTH,

uint8_t)

Quoted 36 lines
Quoted 36 lines
Quoted 8 lines
drivers/net/e1000/igb_ethdev.c +2 -0
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
+#define IGB_32_BIT_WIDTH (CHAR_BIT * 4) #define IGB_32_BIT_MASK
+RTE_LEN2MASK(IGB_32_BIT_WIDTH, uint32_t)
 
 /* Additional timesync values. */
 #define E1000_CYCLECOUNTER_MASK      0xffffffffffffffffULL

drivers/net/e1000/igb_ethdev.c static int igb_filter_restore(struct · line 267

Quoted 10 lines
drivers/net/e1000/igb_ethdev.c +1 -5
@@ -261,11 +263,17 @@ 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)

\

drivers/net/e1000/igb_ethdev.c static int igb_filter_restore(struct · line 268

Quoted 1 line
drivers/net/e1000/igb_ethdev.c +1 -0
+{
     \
Quoted 15 lines
drivers/net/e1000/igb_ethdev.c +9 -0
+uint64_t latest = E1000_READ_REG(hw, reg);                 \
+uint64_t stat = 0;                                         \
+if (latest >= last)                                        \
+stat = latest - last;                              \
+else                                                       \
+stat = (uint64_t)((latest +                        \
+((uint64_t)1 << IGB_32_BIT_WIDTH)) - last);\
+cur += stat & IGB_32_BIT_MASK;                             \
+last = latest;                                             \
 }
 

#define IGB_FC_PAUSE_TIME 0x0680
--
2.17.1

#13 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

In reply to Guinan Sun

Hi, jiaqi

Quoted 41 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Friday, May 8, 2020 12:46 PM
To: [email protected]
Cc: Sun, GuinanX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2 2/2] net/e1000: fix defects of macro in VF

The defects in the macros UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist.
If latest is less than last, we will get wrong result. The patch fixes the defect.

Fixes d15fcf76c8b7 ("e1000: move to drivers/net/")

---
v2 changes:
* Aligned line-continuation character "\".

---
 drivers/net/e1000/igb_ethdev.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/e1000/igb_ethdev.c +2 -0
index 520fba8fa..4cd4e55c0 100644
@@ -47,6 +47,8 @@
 #define IGB_4_BIT_MASK   RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t)
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
+#define IGB_32_BIT_WIDTH (CHAR_BIT * 4) #define IGB_32_BIT_MASK
+RTE_LEN2MASK(IGB_32_BIT_WIDTH, uint32_t)
 
 /* Additional timesync values. */
 #define E1000_CYCLECOUNTER_MASK      0xffffffffffffffffULL
@@ -261,11 +263,17 @@ static int igb_filter_restore(struct rte_eth_dev
 *dev);
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */

drivers/net/e1000/igb_ethdev.c static int igb_filter_restore(struct rte_eth_dev · line 271

Quoted 10 lines
drivers/net/e1000/igb_ethdev.c +4 -5
-#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)                             \
+{
    \
+	uint64_t latest = E1000_READ_REG(hw, reg);                 \
+	uint64_t stat = 0;                                         \

Why do use 64 bit for register read?
Igb register only 32 bit width?

Quoted 12 lines
drivers/net/e1000/igb_ethdev.c +7 -0
+	if (latest >= last)                                        \
+		stat = latest - last;                              \
+	else                                                       \
+		stat = (uint64_t)((latest +                        \
+			((uint64_t)1 << IGB_32_BIT_WIDTH)) - last);\
+	cur += stat & IGB_32_BIT_MASK;                             \
+	last = latest;                                             \
 }

#define IGB_FC_PAUSE_TIME 0x0680
--
2.17.1

Reviewed-by on the v2 series
#14 lore raw
In reply to Guinan Sun
Quoted 24 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Friday, May 8, 2020 12:46 PM
To: [email protected]
Cc: Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/2] fix defects of macro in VF

The defects of UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT exist. If latest is less than last, we will get wrong result. The issues exist only in ixgbe and e1000 NICs.
---
v2 changes:
* Aligned line-continuation character "\".

Guinan Sun (2):
net/ixgbe: fix defects of macro in VF
net/e1000: fix defects of macro in VF

 drivers/net/e1000/igb_ethdev.c   | 18 +++++++++++++-----
 drivers/net/ixgbe/ixgbe_ethdev.c | 32 ++++++++++++++++++++++++--------
 2 files changed, 37 insertions(+), 13 deletions(-)

--
2.17.1