[PATCH 8/8] net/nfp: simplify the port name for multiple PFs

Chaoyong He chaoyong.he at corigine.com
Mon Jan 15 03:54:19 CET 2024


From: Peng Zhang <peng.zhang at 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 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 | 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



More information about the dev mailing list