[PATCH 05/23] net/nfp: fix repeat set the speed configure

Chaoyong He chaoyong.he at corigine.com
Wed Jun 19 11:58:12 CEST 2024


From: Peng Zhang <peng.zhang at corigine.com>

For firmware with multiple PFs, all the PFs share the same
'nfp_eth_table' data structure. So the original logic loop the
ports in 'nfp_eth_table' will cause the speed capability field of
the 'struct nfp_pf_dev' be covered.

Fix this by adding the special logic for firmware with multiple PFs.

Fixes: 3110ab733862 ("net/nfp: support getting speed capability")
Cc: zerun.fu at corigine.com
Cc: stable at dpdk.org

Signed-off-by: Peng Zhang <peng.zhang at corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he at corigine.com>
Reviewed-by: Long Wu <long.wu at corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c | 39 +++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 7479802a52..2c1300350c 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1741,7 +1741,7 @@ nfp_net_speed_capa_get_real(struct nfp_eth_media_buf *media_buf,
 }
 
 static int
-nfp_net_speed_capa_get(struct nfp_pf_dev *pf_dev,
+nfp_net_speed_cap_get_one(struct nfp_pf_dev *pf_dev,
 		uint32_t port_id)
 {
 	int ret;
@@ -1773,6 +1773,27 @@ nfp_net_speed_capa_get(struct nfp_pf_dev *pf_dev,
 	return 0;
 }
 
+static int
+nfp_net_speed_cap_get(struct nfp_pf_dev *pf_dev)
+{
+	int ret;
+	uint32_t i;
+	uint32_t id;
+	uint32_t count;
+
+	count = nfp_net_get_port_num(pf_dev, pf_dev->nfp_eth_table);
+	for (i = 0; i < count; i++) {
+		id = nfp_function_id_get(pf_dev, i);
+		ret = nfp_net_speed_cap_get_one(pf_dev, id);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Failed to get port %d speed capability.", id);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
 /* Force the physical port down to clear the possible DMA error */
 static int
 nfp_net_force_port_down(struct nfp_pf_dev *pf_dev,
@@ -1801,8 +1822,6 @@ static int
 nfp_pf_init(struct rte_pci_device *pci_dev)
 {
 	void *sync;
-	uint32_t i;
-	uint32_t id;
 	int ret = 0;
 	uint64_t addr;
 	uint32_t cpp_id;
@@ -1953,15 +1972,11 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
 	pf_dev->nfp_eth_table = nfp_eth_table;
 	pf_dev->sync = sync;
 
-	/* Get the speed capability */
-	for (i = 0; i < nfp_eth_table->count; i++) {
-		id = nfp_function_id_get(pf_dev, i);
-		ret = nfp_net_speed_capa_get(pf_dev, id);
-		if (ret != 0) {
-			PMD_INIT_LOG(ERR, "Failed to get speed capability.");
-			ret = -EIO;
-			goto sym_tbl_cleanup;
-		}
+	ret = nfp_net_speed_cap_get(pf_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get speed capability.");
+		ret = -EIO;
+		goto sym_tbl_cleanup;
 	}
 
 	/* Configure access to tx/rx vNIC BARs */
-- 
2.39.1



More information about the dev mailing list