From: Zerun Fu <zerun...@corigine.com> Fix multiple PFs check from NSP problem in the logic of PF initialization.
Fixes: 8ad2cc8fec37 ("net/nfp: add flag for multiple PFs support") Cc: peng.zh...@corigine.com Cc: sta...@dpdk.org Signed-off-by: Zerun Fu <zerun...@corigine.com> Reviewed-by: Chaoyong He <chaoyong...@corigine.com> Reviewed-by: Long Wu <long...@corigine.com> Reviewed-by: Peng Zhang <peng.zh...@corigine.com> --- drivers/net/nfp/nfp_ethdev.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index f54483822f..aad044a0f7 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -1749,24 +1749,25 @@ nfp_check_multi_pf_from_fw(uint32_t total_vnics) return false; } -static inline bool +static inline int nfp_check_multi_pf_from_nsp(struct rte_pci_device *pci_dev, - struct nfp_cpp *cpp) + struct nfp_cpp *cpp, + bool *flag) { - bool flag; struct nfp_nsp *nsp; nsp = nfp_nsp_open(cpp); if (nsp == NULL) { PMD_DRV_LOG(ERR, "NFP error when obtaining NSP handle."); - return false; + return -EIO; } - flag = (nfp_nsp_get_abi_ver_major(nsp) > 0) && + *flag = (nfp_nsp_get_abi_ver_major(nsp) > 0) && (pci_dev->id.device_id == PCI_DEVICE_ID_NFP3800_PF_NIC); nfp_nsp_close(nsp); - return flag; + + return 0; } static int @@ -2432,8 +2433,13 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto eth_table_cleanup; } + ret = nfp_check_multi_pf_from_nsp(pci_dev, cpp, &pf_dev->multi_pf.enabled); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Failed to check multi pf from NSP."); + goto eth_table_cleanup; + } + pf_dev->nfp_eth_table = nfp_eth_table; - pf_dev->multi_pf.enabled = nfp_check_multi_pf_from_nsp(pci_dev, cpp); pf_dev->multi_pf.function_id = function_id; pf_dev->total_phyports = nfp_net_get_phyports_from_nsp(pf_dev); -- 2.43.5