DPDK patches and discussions
 help / color / mirror / Atom feed
From: Guinan Sun <guinanx.sun@intel.com>
To: dev@dpdk.org
Cc: Guinan Sun <guinanx.sun@intel.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH 1/2] net/ixgbe: fix defects of macro in VF
Date: Fri,  8 May 2020 01:59:12 +0000	[thread overview]
Message-ID: <20200508015913.48764-2-guinanx.sun@intel.com> (raw)
In-Reply-To: <20200508015913.48764-1-guinanx.sun@intel.com>

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


  reply	other threads:[~2020-05-08  2:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08  1:59 [dpdk-dev] [PATCH 0/2] " Guinan Sun
2020-05-08  1:59 ` Guinan Sun [this message]
2020-05-08  1:59 ` [dpdk-dev] [PATCH 2/2] net/e1000: " Guinan Sun
2020-05-08  2:18 ` [dpdk-dev] [PATCH 0/2] " Zhao1, Wei
2020-05-08  5:07   ` Sun, GuinanX
2020-05-08  5:41     ` Zhao1, Wei
2020-05-08  4:46 ` [dpdk-dev] [PATCH v2 " Guinan Sun
2020-05-08  4:46   ` [dpdk-dev] [PATCH v2 1/2] net/ixgbe: " Guinan Sun
2020-05-08  4:46   ` [dpdk-dev] [PATCH v2 2/2] net/e1000: " Guinan Sun
2020-05-18  1:24     ` [dpdk-dev] [dpdk-stable] " Ye Xiaolong
2020-05-18  6:48       ` Zhao1, Wei
2020-05-18 23:39         ` Ye Xiaolong
2020-05-19  1:01           ` Zhao1, Wei
2020-05-18  7:21     ` [dpdk-dev] " Zhao1, Wei
2020-05-08  5:05   ` [dpdk-dev] [PATCH v2 0/2] " Zhao1, Wei
  -- strict thread matches above, loose matches on Subject: below --
2020-05-07  6:16 [dpdk-dev] [PATCH " Guinan Sun
2020-05-07  6:16 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: " Guinan Sun

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=20200508015913.48764-2-guinanx.sun@intel.com \
    --to=guinanx.sun@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.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).