Skip to content

Commit 2bcb9c9

Browse files
zerun-fushemminger
authored andcommitted
net/nfp: add PF ID to the firmware load command
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: 74fd1a7 ("net/nfp: support loading firmware for card without DDR") Cc: [email protected] Signed-off-by: Zerun Fu <[email protected]> Reviewed-by: Chaoyong He <[email protected]> Reviewed-by: Long Wu <[email protected]> Reviewed-by: Peng Zhang <[email protected]>
1 parent 2364700 commit 2bcb9c9

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

drivers/net/nfp/nfpcore/nfp6000_pcie.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,3 +1033,11 @@ nfp_cpp_from_nfp6000_pcie(struct rte_pci_device *pci_dev,
10331033

10341034
return cpp;
10351035
}
1036+
1037+
uint8_t
1038+
nfp_get_pf_id_from_device(void *priv)
1039+
{
1040+
struct nfp_pcie_user *nfp = priv;
1041+
1042+
return nfp->pci_dev->addr.function;
1043+
}

drivers/net/nfp/nfpcore/nfp6000_pcie.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ struct nfp_cpp *nfp_cpp_from_nfp6000_pcie(struct rte_pci_device *pci_dev,
1717
const struct nfp_dev_info *dev_info,
1818
bool driver_lock_needed);
1919

20+
uint8_t nfp_get_pf_id_from_device(void *priv);
21+
2022
#endif /* __NFP6000_PCIE_H__ */

drivers/net/nfp/nfpcore/nfp_cpp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,6 @@ int nfp_cpp_writeq(struct nfp_cpp *cpp, uint32_t cpp_id,
384384

385385
uint32_t nfp_cpp_mu_locality_lsb(struct nfp_cpp *cpp);
386386

387+
uint8_t nfp_get_pf_id_from_cpp(struct nfp_cpp *cpp);
388+
387389
#endif /* __NFP_CPP_H__ */

drivers/net/nfp/nfpcore/nfp_cppcore.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,3 +1170,9 @@ nfp_cpp_map_area(struct nfp_cpp *cpp,
11701170
err_eio:
11711171
return NULL;
11721172
}
1173+
1174+
uint8_t
1175+
nfp_get_pf_id_from_cpp(struct nfp_cpp *cpp)
1176+
{
1177+
return nfp_get_pf_id_from_device(nfp_cpp_priv(cpp));
1178+
}

drivers/net/nfp/nfpcore/nfp_nsp.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define NSP_COMMAND_OPTION GENMASK_ULL(63, 32)
2525
#define NSP_COMMAND_VER_MAJOR GENMASK_ULL(31, 28)
2626
#define NSP_COMMAND_CODE GENMASK_ULL(27, 16)
27+
#define NSP_COMMAND_PF_ID GENMASK_ULL(3, 2)
2728
#define NSP_COMMAND_DMA_BUF RTE_BIT64(1)
2829
#define NSP_COMMAND_START RTE_BIT64(0)
2930

@@ -364,6 +365,7 @@ nfp_nsp_command_real(struct nfp_nsp *state,
364365
{
365366
int err;
366367
uint64_t reg;
368+
uint64_t address;
367369
uint32_t nsp_cpp;
368370
uint64_t ret_val;
369371
uint64_t nsp_base;
@@ -390,12 +392,18 @@ nfp_nsp_command_real(struct nfp_nsp *state,
390392
return err;
391393
}
392394

393-
err = nfp_cpp_writeq(cpp, nsp_cpp, nsp_command,
394-
FIELD_PREP(NSP_COMMAND_OPTION, arg->option) |
395+
address = FIELD_PREP(NSP_COMMAND_OPTION, arg->option) |
395396
FIELD_PREP(NSP_COMMAND_VER_MAJOR, state->ver.major) |
396397
FIELD_PREP(NSP_COMMAND_CODE, arg->code) |
397398
FIELD_PREP(NSP_COMMAND_DMA_BUF, arg->dma) |
398-
FIELD_PREP(NSP_COMMAND_START, 1));
399+
FIELD_PREP(NSP_COMMAND_START, 1);
400+
401+
if (arg->code == SPCODE_FW_LOAD) {
402+
address |= FIELD_PREP(NSP_COMMAND_PF_ID,
403+
nfp_get_pf_id_from_cpp(cpp));
404+
}
405+
406+
err = nfp_cpp_writeq(cpp, nsp_cpp, nsp_command, address);
399407
if (err < 0) {
400408
PMD_DRV_LOG(ERR, "CPP write command failed. err %d", err);
401409
return err;

0 commit comments

Comments
 (0)