net/nfp: update incorrect MAC stats offset

Message ID 20231010060953.205806-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: update incorrect MAC stats offset |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Chaoyong He Oct. 10, 2023, 6:09 a.m. UTC
  From: James Hershaw <james.hershaw@corigine.com>

The pointer to the beginning of the MAC stats counters for port 1 are
incorrectly set as the pointer to the beginning of the port 0 MAC stats
counters, plus the size of the MAC stats counters multiplied by the port
number.

This patch corrects this by setting the multiplier as the eth_table
index of the port.

Fixes: f26e82397f6d ("net/nfp: implement xstats")
Cc: stable@dpdk.org

Signed-off-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit Oct. 16, 2023, 1:25 p.m. UTC | #1
On 10/10/2023 7:09 AM, Chaoyong He wrote:
> From: James Hershaw <james.hershaw@corigine.com>
> 
> The pointer to the beginning of the MAC stats counters for port 1 are
> incorrectly set as the pointer to the beginning of the port 0 MAC stats
> counters, plus the size of the MAC stats counters multiplied by the port
> number.
> 
> This patch corrects this by setting the multiplier as the eth_table
> index of the port.
> 
> Fixes: f26e82397f6d ("net/nfp: implement xstats")
> Cc: stable@dpdk.org
> 
> Signed-off-by: James Hershaw <james.hershaw@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> 
Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index ebc5538291..0645123c99 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -547,7 +547,8 @@  nfp_net_init(struct rte_eth_dev *eth_dev)
 			return -ENODEV;
 		/* Use port offset in pf ctrl_bar for this ports control bar */
 		hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_PF_CSR_SLICE_SIZE);
-		hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar + (port * NFP_MAC_STATS_SIZE);
+		hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar +
+				(hw->nfp_idx * NFP_MAC_STATS_SIZE);
 	}
 
 	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);