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, Zerun Fu <zerun.fu@corigine.com>,
	chaoyong.he@corigine.com, stable@dpdk.org,
	Long Wu <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH] net/nfp: add PF ID to the firmware load command
Date: Fri,  7 Mar 2025 10:22:35 +0800	[thread overview]
Message-ID: <20250307022235.2003386-1-chaoyong.he@corigine.com> (raw)

From: Zerun Fu <zerun.fu@corigine.com>

In the previous firmware load command logic, the driver doesn't send
the PF ID to the BSP, so the BSP can't process the DMA address correctly,
and this will lead to DMA mapping errors in memory read/write operations
when using multiple PF firmware.

Fix this by sending the PF ID to the BSP for firmware load command.

Fixes: 74fd1a71cec1 ("net/nfp: support loading firmware for card without DDR")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfpcore/nfp6000_pcie.c |  8 ++++++++
 drivers/net/nfp/nfpcore/nfp6000_pcie.h |  2 ++
 drivers/net/nfp/nfpcore/nfp_cpp.h      |  2 ++
 drivers/net/nfp/nfpcore/nfp_cppcore.c  |  6 ++++++
 drivers/net/nfp/nfpcore/nfp_nsp.c      | 14 +++++++++++---
 5 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/nfp/nfpcore/nfp6000_pcie.c
index 4693577f4e..83b7116097 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.c
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.c
@@ -1033,3 +1033,11 @@ nfp_cpp_from_nfp6000_pcie(struct rte_pci_device *pci_dev,
 
 	return cpp;
 }
+
+uint8_t
+nfp_get_pf_id_from_device(void *priv)
+{
+	struct nfp_pcie_user *nfp = priv;
+
+	return nfp->pci_dev->addr.function;
+}
diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.h b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
index 59b58ddd04..0d2e5bae0d 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.h
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
@@ -17,4 +17,6 @@ struct nfp_cpp *nfp_cpp_from_nfp6000_pcie(struct rte_pci_device *pci_dev,
 		const struct nfp_dev_info *dev_info,
 		bool driver_lock_needed);
 
+uint8_t nfp_get_pf_id_from_device(void *priv);
+
 #endif /* __NFP6000_PCIE_H__ */
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h
index 2defc4fa16..13d0c5fb68 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp.h
+++ b/drivers/net/nfp/nfpcore/nfp_cpp.h
@@ -384,4 +384,6 @@ int nfp_cpp_writeq(struct nfp_cpp *cpp, uint32_t cpp_id,
 
 uint32_t nfp_cpp_mu_locality_lsb(struct nfp_cpp *cpp);
 
+uint8_t nfp_get_pf_id_from_cpp(struct nfp_cpp *cpp);
+
 #endif /* __NFP_CPP_H__ */
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index dfc6d4613a..9f6417b7bf 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -1170,3 +1170,9 @@ nfp_cpp_map_area(struct nfp_cpp *cpp,
 err_eio:
 	return NULL;
 }
+
+uint8_t
+nfp_get_pf_id_from_cpp(struct nfp_cpp *cpp)
+{
+	return nfp_get_pf_id_from_device(nfp_cpp_priv(cpp));
+}
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 732fa5802c..43c13baabe 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -24,6 +24,7 @@
 #define   NSP_COMMAND_OPTION    GENMASK_ULL(63, 32)
 #define   NSP_COMMAND_VER_MAJOR GENMASK_ULL(31, 28)
 #define   NSP_COMMAND_CODE      GENMASK_ULL(27, 16)
+#define   NSP_COMMAND_PF_ID     GENMASK_ULL(3, 2)
 #define   NSP_COMMAND_DMA_BUF   RTE_BIT64(1)
 #define   NSP_COMMAND_START     RTE_BIT64(0)
 
@@ -364,6 +365,7 @@ nfp_nsp_command_real(struct nfp_nsp *state,
 {
 	int err;
 	uint64_t reg;
+	uint64_t address;
 	uint32_t nsp_cpp;
 	uint64_t ret_val;
 	uint64_t nsp_base;
@@ -390,12 +392,18 @@ nfp_nsp_command_real(struct nfp_nsp *state,
 		return err;
 	}
 
-	err = nfp_cpp_writeq(cpp, nsp_cpp, nsp_command,
-			FIELD_PREP(NSP_COMMAND_OPTION, arg->option) |
+	address = FIELD_PREP(NSP_COMMAND_OPTION, arg->option) |
 			FIELD_PREP(NSP_COMMAND_VER_MAJOR, state->ver.major) |
 			FIELD_PREP(NSP_COMMAND_CODE, arg->code) |
 			FIELD_PREP(NSP_COMMAND_DMA_BUF, arg->dma) |
-			FIELD_PREP(NSP_COMMAND_START, 1));
+			FIELD_PREP(NSP_COMMAND_START, 1);
+
+	if (arg->code == SPCODE_FW_LOAD) {
+		address |= FIELD_PREP(NSP_COMMAND_PF_ID,
+				nfp_get_pf_id_from_cpp(cpp));
+	}
+
+	err = nfp_cpp_writeq(cpp, nsp_cpp, nsp_command, address);
 	if (err < 0) {
 		PMD_DRV_LOG(ERR, "CPP write command failed. err %d", err);
 		return err;
-- 
2.43.5


                 reply	other threads:[~2025-03-07  2:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250307022235.2003386-1-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 \
    --cc=stable@dpdk.org \
    --cc=zerun.fu@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).