DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] fix defects of macro in VF
@ 2020-05-07  6:16 Guinan Sun
  2020-05-07  6:16 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: " Guinan Sun
  2020-05-07  6:16 ` [dpdk-dev] [PATCH 2/2] net/e1000: " Guinan Sun
  0 siblings, 2 replies; 4+ messages in thread
From: Guinan Sun @ 2020-05-07  6:16 UTC (permalink / raw)
  To: dev; +Cc: 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.

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


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

* [dpdk-dev] [PATCH 1/2] net/ixgbe: fix defects of macro in VF
  2020-05-07  6:16 [dpdk-dev] [PATCH 0/2] fix defects of macro in VF Guinan Sun
@ 2020-05-07  6:16 ` Guinan Sun
  2020-05-07  6:16 ` [dpdk-dev] [PATCH 2/2] net/e1000: " Guinan Sun
  1 sibling, 0 replies; 4+ messages in thread
From: Guinan Sun @ 2020-05-07  6:16 UTC (permalink / raw)
  To: dev; +Cc: Guinan Sun, stable

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/")
Cc: stable@dpdk.org

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index cf5f1fe70..08a964399 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -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;                                           \
 }
 
-- 
2.17.1


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

* [dpdk-dev] [PATCH 2/2] net/e1000: fix defects of macro in VF
  2020-05-07  6:16 [dpdk-dev] [PATCH 0/2] fix defects of macro in VF Guinan Sun
  2020-05-07  6:16 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: " Guinan Sun
@ 2020-05-07  6:16 ` Guinan Sun
  1 sibling, 0 replies; 4+ messages in thread
From: Guinan Sun @ 2020-05-07  6:16 UTC (permalink / raw)
  To: dev; +Cc: Guinan Sun, stable

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/")
Cc: stable@dpdk.org

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
 drivers/net/e1000/igb_ethdev.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 520fba8fa..d6032fd65 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -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
-- 
2.17.1


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

* [dpdk-dev] [PATCH 1/2] net/ixgbe: fix defects of macro in VF
  2020-05-08  1:59 [dpdk-dev] [PATCH 0/2] " Guinan Sun
@ 2020-05-08  1:59 ` Guinan Sun
  0 siblings, 0 replies; 4+ messages in thread
From: Guinan Sun @ 2020-05-08  1:59 UTC (permalink / raw)
  To: dev; +Cc: Guinan Sun, stable

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/")
Cc: stable@dpdk.org

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index cf5f1fe70..08a964399 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -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;                                           \
 }
 
-- 
2.17.1


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

end of thread, other threads:[~2020-05-08  2:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07  6:16 [dpdk-dev] [PATCH 0/2] fix defects of macro in VF Guinan Sun
2020-05-07  6:16 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: " Guinan Sun
2020-05-07  6:16 ` [dpdk-dev] [PATCH 2/2] net/e1000: " Guinan Sun
2020-05-08  1:59 [dpdk-dev] [PATCH 0/2] " Guinan Sun
2020-05-08  1:59 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: " Guinan Sun

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