DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Long Wu <long.wu@corigine.com>,
	chaoyong.he@corigine.com, stable@dpdk.org
Subject: [PATCH 2/3] net/nfp: fix representor creation failed
Date: Fri,  9 Jun 2023 14:00:59 +0800	[thread overview]
Message-ID: <20230609060100.1306648-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230609060100.1306648-1-chaoyong.he@corigine.com>

From: Long Wu <long.wu@corigine.com>

The former logic does not consider the simultaneous initialization of
several NICs using flower firmware. The reason the initialization
failed was because several NICs use the same name parameter when we
call rte_eth_dev_create().

We use the PCI address to give each NIC a unique name parameter and let
the initializtion succeed.

Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_representor.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 3225a4b84a..5118c9c57c 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -723,6 +723,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower)
 {
 	int i;
 	int ret;
+	struct rte_device *device;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_eth_table *nfp_eth_table;
 	struct nfp_eth_table_port *eth_port;
@@ -746,7 +747,11 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower)
 
 	/* PF vNIC reprs get a random MAC address */
 	rte_eth_random_addr(flower_repr.mac_addr.addr_bytes);
-	sprintf(flower_repr.name, "flower_repr_pf");
+
+	device = &app_fw_flower->pf_hw->pf_dev->pci_dev->device;
+
+	snprintf(flower_repr.name, sizeof(flower_repr.name),
+			"%s_flower_repr_pf", device->name);
 
 	/* Create a eth_dev for this representor */
 	ret = rte_eth_dev_create(eth_dev->device, flower_repr.name,
@@ -767,7 +772,8 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower)
 
 		/* Copy the real mac of the interface to the representor struct */
 		rte_ether_addr_copy(&eth_port->mac_addr, &flower_repr.mac_addr);
-		sprintf(flower_repr.name, "flower_repr_p%d", i);
+		snprintf(flower_repr.name, sizeof(flower_repr.name),
+				"%s_fl_repr_p%d", device->name, i);
 
 		/*
 		 * Create a eth_dev for this representor
@@ -798,7 +804,8 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower)
 
 		/* VF reprs get a random MAC address */
 		rte_eth_random_addr(flower_repr.mac_addr.addr_bytes);
-		sprintf(flower_repr.name, "flower_repr_vf%d", i);
+		snprintf(flower_repr.name, sizeof(flower_repr.name),
+				"%s_fl_repr_vf%d", device->name, i);
 
 		 /* This will also allocate private memory for the device*/
 		ret = rte_eth_dev_create(eth_dev->device, flower_repr.name,
-- 
2.39.1


  parent reply	other threads:[~2023-06-09  6:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09  6:00 [PATCH 0/3] support using several cards in one host Chaoyong He
2023-06-09  6:00 ` [PATCH 1/3] net/nfp: fix control mempool creation failed Chaoyong He
2023-06-09  6:00 ` Chaoyong He [this message]
2023-06-09  6:01 ` [PATCH 3/3] net/nfp: fix flow hash table " Chaoyong He
2023-06-09 13:23 ` [PATCH 0/3] support using several cards in one host Ferruh Yigit

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=20230609060100.1306648-3-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.com \
    --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).