[PATCH 04/23] net/nfp: fix repeat disable the port
Chaoyong He
chaoyong.he at corigine.com
Wed Jun 19 11:58:11 CEST 2024
From: Peng Zhang <peng.zhang at corigine.com>
For firmware with multiple PFs, all the PFs share
the same 'nfp_eth_table' data structure. So the original
logic loop the ports in 'nfp_eth_table' will make other
PFs suddently down, which will cause problem.
Fix this by adding the special logic for firmware with
multiple PFs.
Fixes: 3b00109d2b65 ("net/nfp: add PF ID used to format symbols")
Cc: stable at dpdk.org
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 | 35 ++++++++++++++++++++++++++------
drivers/net/nfp/nfp_net_common.c | 10 +++++++++
drivers/net/nfp/nfp_net_common.h | 2 ++
3 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 181798e8e3..7479802a52 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1773,6 +1773,30 @@ nfp_net_speed_capa_get(struct nfp_pf_dev *pf_dev,
return 0;
}
+/* Force the physical port down to clear the possible DMA error */
+static int
+nfp_net_force_port_down(struct nfp_pf_dev *pf_dev,
+ struct nfp_eth_table *nfp_eth_table,
+ struct nfp_cpp *cpp)
+{
+ int ret;
+ uint32_t i;
+ uint32_t id;
+ uint32_t index;
+ uint32_t count;
+
+ count = nfp_net_get_port_num(pf_dev, nfp_eth_table);
+ for (i = 0; i < count; i++) {
+ id = nfp_function_id_get(pf_dev, i);
+ index = nfp_eth_table->ports[id].index;
+ ret = nfp_eth_set_configured(cpp, index, 0);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
static int
nfp_pf_init(struct rte_pci_device *pci_dev)
{
@@ -1781,7 +1805,6 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
uint32_t id;
int ret = 0;
uint64_t addr;
- uint32_t index;
uint32_t cpp_id;
uint8_t function_id;
struct nfp_cpp *cpp;
@@ -1875,11 +1898,11 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
pf_dev->multi_pf.enabled = nfp_check_multi_pf_from_nsp(pci_dev, cpp);
pf_dev->multi_pf.function_id = function_id;
- /* Force the physical port down to clear the possible DMA error */
- for (i = 0; i < nfp_eth_table->count; i++) {
- id = nfp_function_id_get(pf_dev, i);
- index = nfp_eth_table->ports[id].index;
- nfp_eth_set_configured(cpp, index, 0);
+ ret = nfp_net_force_port_down(pf_dev, nfp_eth_table, cpp);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to force port down");
+ ret = -EIO;
+ goto eth_table_cleanup;
}
ret = nfp_devargs_parse(&pf_dev->devargs, pci_dev->device.devargs);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 107306a4e3..d8b7045c3a 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -2554,3 +2554,13 @@ nfp_net_fec_set(struct rte_eth_dev *dev,
return nfp_eth_set_fec(hw_priv->pf_dev->cpp, eth_port->index, fec);
}
+
+uint32_t
+nfp_net_get_port_num(struct nfp_pf_dev *pf_dev,
+ struct nfp_eth_table *nfp_eth_table)
+{
+ if (pf_dev->multi_pf.enabled)
+ return 1;
+ else
+ return nfp_eth_table->count;
+}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 2feeb6f5bd..4016652cf9 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -326,6 +326,8 @@ void nfp_net_get_fw_version(struct nfp_cpp *cpp,
uint32_t *fw_version);
int nfp_net_txrwb_alloc(struct rte_eth_dev *eth_dev);
void nfp_net_txrwb_free(struct rte_eth_dev *eth_dev);
+uint32_t nfp_net_get_port_num(struct nfp_pf_dev *pf_dev,
+ struct nfp_eth_table *nfp_eth_table);
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
((struct nfp_app_fw_nic *)app_fw_priv)
--
2.39.1
More information about the dev
mailing list