patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Peng Zhang <peng.zhang@corigine.com>,
	zerun.fu@corigine.com, stable@dpdk.org,
	Chaoyong He <chaoyong.he@corigine.com>,
	Long Wu <long.wu@corigine.com>
Subject: [PATCH 05/23] net/nfp: fix repeat set the speed configure
Date: Wed, 19 Jun 2024 17:58:12 +0800	[thread overview]
Message-ID: <20240619095830.3479757-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com>

From: Peng Zhang <peng.zhang@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@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@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


  parent reply	other threads:[~2024-06-19  9:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240619095830.3479757-1-chaoyong.he@corigine.com>
2024-06-19  9:58 ` [PATCH 01/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-07-07 18:56   ` Ferruh Yigit
2024-07-08  1:35     ` Chaoyong He
2024-06-19  9:58 ` [PATCH 02/23] net/nfp: disable ctrl VNIC queues Chaoyong He
2024-06-19  9:58 ` [PATCH 03/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-06-19  9:58 ` [PATCH 04/23] net/nfp: fix repeat disable the port Chaoyong He
2024-06-19  9:58 ` Chaoyong He [this message]
2024-06-19  9:58 ` [PATCH 18/23] net/nfp: add check for numbers of VF representor port Chaoyong He

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=20240619095830.3479757-6-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=peng.zhang@corigine.com \
    --cc=stable@dpdk.org \
    --cc=zerun.fu@corigine.com \
    /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).