From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 383C1A0524 for ; Thu, 4 Feb 2021 12:31:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0618024074C; Thu, 4 Feb 2021 12:31:21 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 314FB24072D for ; Thu, 4 Feb 2021 12:31:19 +0100 (CET) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l7cqz-00058m-Jh; Thu, 04 Feb 2021 11:31:17 +0000 From: Christian Ehrhardt To: Igor Ryzhov Cc: Qi Zhang , dpdk stable Date: Thu, 4 Feb 2021 12:28:01 +0100 Message-Id: <20210204112954.2488123-26-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204112954.2488123-1-christian.ehrhardt@canonical.com> References: <20210204112954.2488123-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/i40e: fix stats counters' has been queued to stable release 19.11.7 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/06/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/cb93e1ff837b77c8aeb7de5a985877f0856080b9 Thanks. Christian Ehrhardt --- >From cb93e1ff837b77c8aeb7de5a985877f0856080b9 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Tue, 17 Nov 2020 11:56:39 +0300 Subject: [PATCH] net/i40e: fix stats counters [ upstream commit d8d652ec7266d9ea4c8763d4a71a2c7853b9c23b ] When low and high registers are read separately, this opens the door to a race condition: - low register is read - NIC updates the registers - high register is read Because of this, we may end up with an incorrect counter value. Let's read the registers in one shot, as it is done in Linux kernel since the introduction of the i40e driver. Fixes: 4861cde46116 ("i40e: new poll mode driver") Signed-off-by: Igor Ryzhov Acked-by: Qi Zhang --- drivers/net/i40e/base/i40e_osdep.h | 10 ++++++++++ drivers/net/i40e/i40e_ethdev.c | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h index 64b15e1b61..ebd6872400 100644 --- a/drivers/net/i40e/base/i40e_osdep.h +++ b/drivers/net/i40e/base/i40e_osdep.h @@ -133,6 +133,14 @@ static inline uint32_t i40e_read_addr(volatile void *addr) return rte_le_to_cpu_32(I40E_PCI_REG(addr)); } +#define I40E_PCI_REG64(reg) rte_read64(reg) +#define I40E_PCI_REG64_ADDR(a, reg) \ + ((volatile uint64_t *)((char *)(a)->hw_addr + (reg))) +static inline uint64_t i40e_read64_addr(volatile void *addr) +{ + return rte_le_to_cpu_64(I40E_PCI_REG64(addr)); +} + #define I40E_PCI_REG_WRITE(reg, value) \ rte_write32((rte_cpu_to_le_32(value)), reg) #define I40E_PCI_REG_WRITE_RELAXED(reg, value) \ @@ -145,6 +153,8 @@ static inline uint32_t i40e_read_addr(volatile void *addr) #define I40E_WRITE_REG(hw, reg, value) \ I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((hw), (reg)), (value)) +#define I40E_READ_REG64(hw, reg) i40e_read64_addr(I40E_PCI_REG64_ADDR((hw), (reg))) + #define rd32(a, reg) i40e_read_addr(I40E_PCI_REG_ADDR((a), (reg))) #define wr32(a, reg, value) \ I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((a), (reg)), (value)) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index ec9b16608c..e7a7e38bc9 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6620,9 +6620,13 @@ i40e_stat_update_48(struct i40e_hw *hw, { uint64_t new_data; - new_data = (uint64_t)I40E_READ_REG(hw, loreg); - new_data |= ((uint64_t)(I40E_READ_REG(hw, hireg) & - I40E_16_BIT_MASK)) << I40E_32_BIT_WIDTH; + if (hw->device_id == I40E_DEV_ID_QEMU) { + new_data = (uint64_t)I40E_READ_REG(hw, loreg); + new_data |= ((uint64_t)(I40E_READ_REG(hw, hireg) & + I40E_16_BIT_MASK)) << I40E_32_BIT_WIDTH; + } else { + new_data = I40E_READ_REG64(hw, loreg); + } if (!offset_loaded) *offset = new_data; -- 2.30.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-04 12:04:29.233112447 +0100 +++ 0026-net-i40e-fix-stats-counters.patch 2021-02-04 12:04:27.902789605 +0100 @@ -1 +1 @@ -From d8d652ec7266d9ea4c8763d4a71a2c7853b9c23b Mon Sep 17 00:00:00 2001 +From cb93e1ff837b77c8aeb7de5a985877f0856080b9 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d8d652ec7266d9ea4c8763d4a71a2c7853b9c23b ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -27 +28 @@ -index 9b5033024f..c9287ff255 100644 +index 64b15e1b61..ebd6872400 100644 @@ -45 +46 @@ -@@ -150,6 +158,8 @@ static inline uint32_t i40e_read_addr(volatile void *addr) +@@ -145,6 +153,8 @@ static inline uint32_t i40e_read_addr(volatile void *addr) @@ -55 +56 @@ -index 2cb18ecc03..7f9bba4052 100644 +index ec9b16608c..e7a7e38bc9 100644