* [PATCH] net/nfp: add PF ID to the firmware load command
@ 2025-03-07 2:22 Chaoyong He
0 siblings, 0 replies; only message in thread
From: Chaoyong He @ 2025-03-07 2:22 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Zerun Fu, chaoyong.he, stable, Long Wu, Peng Zhang
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-03-07 2:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-07 2:22 [PATCH] net/nfp: add PF ID to the firmware load command Chaoyong He
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).