[PATCH 22/23] net/nfp: add device active command for nsp service

Chaoyong He chaoyong.he at corigine.com
Wed Jun 19 11:58:29 CEST 2024


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

In multiple PF case, VFs belong to PFs except PF0
will not able to send traffic when PF0 is not activated.
So PMD add device active command to active the PF0 when
the probing PF is not PF0.

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      | 30 ++++++++++++++++++++++++++++++
 drivers/net/nfp/nfpcore/nfp_nsp.c | 10 ++++++++++
 drivers/net/nfp/nfpcore/nfp_nsp.h |  1 +
 3 files changed, 41 insertions(+)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 1d88f33756..d560bd695f 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1108,6 +1108,29 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
 	return err;
 }
 
+static int
+nfp_net_device_activate(struct nfp_cpp *cpp,
+		struct nfp_multi_pf *multi_pf)
+{
+	int ret;
+	struct nfp_nsp *nsp;
+
+	if (multi_pf->enabled && multi_pf->function_id != 0) {
+		nsp = nfp_nsp_open(cpp);
+		if (nsp == NULL) {
+			PMD_DRV_LOG(ERR, "NFP error when obtaining NSP handle");
+			return -EIO;
+		}
+
+		ret = nfp_nsp_device_activate(nsp);
+		nfp_nsp_close(nsp);
+		if (ret != 0 && ret != -EOPNOTSUPP)
+			return ret;
+	}
+
+	return 0;
+}
+
 #define DEFAULT_FW_PATH       "/lib/firmware/netronome"
 
 static int
@@ -2133,6 +2156,13 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
 		goto eth_table_cleanup;
 	}
 
+	ret = nfp_net_device_activate(cpp, &pf_dev->multi_pf);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to activate the NFP device");
+		ret = -EIO;
+		goto eth_table_cleanup;
+	}
+
 	if (nfp_fw_setup(pci_dev, cpp, nfp_eth_table, hwinfo,
 			dev_info, &pf_dev->multi_pf, pf_dev->devargs.force_reload_fw) != 0) {
 		PMD_INIT_LOG(ERR, "Error when uploading firmware");
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 6a2ba709ab..7dfb472723 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -80,6 +80,7 @@ enum nfp_nsp_cmd {
 	SPCODE_VERSIONS         = 21, /* Report FW versions */
 	SPCODE_READ_SFF_EEPROM  = 22, /* Read module EEPROM */
 	SPCODE_READ_MEDIA       = 23, /* Get the supported/advertised media for a port */
+	SPCODE_DEV_ACTIVATE	= 29, /* Activate hardware for multiple pfs case */
 };
 
 static const struct {
@@ -729,6 +730,15 @@ nfp_nsp_hwinfo_set(struct nfp_nsp *state,
 	return nfp_nsp_command_buf(state, &hwinfo_set);
 }
 
+int
+nfp_nsp_device_activate(struct nfp_nsp *state)
+{
+	if (nfp_nsp_get_abi_ver_minor(state) < 38)
+		return -EOPNOTSUPP;
+
+	return nfp_nsp_command(state, SPCODE_DEV_ACTIVATE);
+}
+
 int
 nfp_nsp_read_media(struct nfp_nsp *state,
 		void *buf,
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h
index 2ce05c2ec9..003cdc5fa3 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.h
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.h
@@ -16,6 +16,7 @@ uint16_t nfp_nsp_get_abi_ver_major(struct nfp_nsp *state);
 uint16_t nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state);
 int nfp_nsp_wait(struct nfp_nsp *state);
 int nfp_nsp_device_soft_reset(struct nfp_nsp *state);
+int nfp_nsp_device_activate(struct nfp_nsp *state);
 int nfp_nsp_load_fw(struct nfp_nsp *state, void *buf, size_t size);
 int nfp_nsp_mac_reinit(struct nfp_nsp *state);
 int nfp_nsp_read_identify(struct nfp_nsp *state, void *buf, size_t size);
-- 
2.39.1



More information about the dev mailing list