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

Message ID 20240115025419.2447759-9-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series optimize the firmware loading process |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Chaoyong He Jan. 15, 2024, 2:54 a.m. UTC
  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(-)
  

Patch

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);