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, Peng Zhang <peng.zhang@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>,
	Long Wu <long.wu@corigine.com>
Subject: [PATCH 8/8] net/nfp: simplify the port name for multiple PFs
Date: Mon, 15 Jan 2024 10:54:19 +0800	[thread overview]
Message-ID: <20240115025419.2447759-9-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240115025419.2447759-1-chaoyong.he@corigine.com>

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

For the firmware which does not support multiple PF feature,
there are multiple PFs corresponding to a single PCI BDF address,
so we have to distinguish them by using a '_port*' postfix for
the device name.

For the firmware which supports multiple PFs feature, there is
only one PF corresponding to a PCI BDF address, so actually we
does not need this postfix anymore, and which is in line with
the mainstream.

Add the corresponding logic to simplify the port name for multiple
PFs case, which will make the user happy.

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 | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 22edf11253..31b2302db6 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1451,9 +1451,12 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev,
 	/* Loop through all physical ports on PF */
 	numa_node = rte_socket_id();
 	for (i = 0; i < app_fw_nic->total_phyports; i++) {
-		id = nfp_function_id_get(pf_dev, i);
-		snprintf(port_name, sizeof(port_name), "%s_port%u",
-				pf_dev->pci_dev->device.name, id);
+		if (pf_dev->multi_pf.enabled)
+			snprintf(port_name, sizeof(port_name), "%s",
+					pf_dev->pci_dev->device.name);
+		else
+			snprintf(port_name, sizeof(port_name), "%s_port%u",
+					pf_dev->pci_dev->device.name, i);
 
 		/* Allocate a eth_dev for this phyport */
 		eth_dev = rte_eth_dev_allocate(port_name);
@@ -1473,6 +1476,7 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev,
 		}
 
 		hw = eth_dev->data->dev_private;
+		id = nfp_function_id_get(pf_dev, i);
 
 		/* Add this device to the PF's array of physical ports */
 		app_fw_nic->ports[id] = hw;
@@ -1902,14 +1906,15 @@ nfp_secondary_init_app_fw_nic(struct nfp_pf_dev *pf_dev)
 	}
 
 	for (i = 0; i < total_vnics; i++) {
-		uint32_t id = i;
 		struct rte_eth_dev *eth_dev;
 		char port_name[RTE_ETH_NAME_MAX_LEN];
 
 		if (nfp_check_multi_pf_from_fw(total_vnics))
-			id = function_id;
-		snprintf(port_name, sizeof(port_name), "%s_port%u",
-				pf_dev->pci_dev->device.name, id);
+			snprintf(port_name, sizeof(port_name), "%s",
+					pf_dev->pci_dev->device.name);
+		else
+			snprintf(port_name, sizeof(port_name), "%s_port%u",
+					pf_dev->pci_dev->device.name, i);
 
 		PMD_INIT_LOG(DEBUG, "Secondary attaching to port %s", port_name);
 		eth_dev = rte_eth_dev_attach_secondary(port_name);
-- 
2.39.1


  parent reply	other threads:[~2024-01-15  2:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15  2:54 [PATCH 0/8] optimize the firmware loading process Chaoyong He
2024-01-15  2:54 ` [PATCH 1/8] net/nfp: add the interface for getting the firmware name Chaoyong He
2024-01-15  2:54 ` [PATCH 2/8] net/nfp: speed up the firmware loading process Chaoyong He
2024-01-15  2:54 ` [PATCH 3/8] net/nfp: optimize loading the firmware process Chaoyong He
2024-01-15  2:54 ` [PATCH 4/8] net/nfp: enlarge the range of skipping loading the firmware Chaoyong He
2024-01-15  2:54 ` [PATCH 5/8] net/nfp: add the step of clearing the beat time Chaoyong He
2024-01-15  2:54 ` [PATCH 6/8] net/nfp: add the elf module Chaoyong He
2024-01-15  2:54 ` [PATCH 7/8] net/nfp: reload the firmware only when firmware changed Chaoyong He
2024-01-15  2:54 ` Chaoyong He [this message]
2024-01-22 15:08 ` [PATCH 0/8] optimize the firmware loading process Ferruh Yigit
2024-01-23  1:46   ` Chaoyong He
2024-01-23  9:14     ` Ferruh Yigit
2024-01-23 11:27       ` Chaoyong He
2024-01-23 11:42         ` Ferruh Yigit
2024-01-26  8:25           ` Chaoyong He
2024-01-23 15:18 ` 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=20240115025419.2447759-9-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 \
    /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).