* [PATCH 1/6] net/nfp: fix check logic for device arguments
[not found] <20240619030655.3216268-1-chaoyong.he@corigine.com>
@ 2024-06-19 3:06 ` Chaoyong He
2024-06-19 3:06 ` [PATCH 4/6] net/nfp: fix disable CPP service Chaoyong He
1 sibling, 0 replies; 2+ messages in thread
From: Chaoyong He @ 2024-06-19 3:06 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, peng.zhang, stable, Chaoyong He
From: Long Wu <long.wu@corigine.com>
There is no check for NFP device argument now, so the users may
not be aware of the wrong device argument and feels confused
with the result in some case.
Add the check logic to fix this problem.
Fixes: b301fd736003 ("net/nfp: add force reload firmware option")
Cc: peng.zhang@corigine.com
Cc: stable@dpdk.org
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 59 +++++++++++++++++++++++++-----------
1 file changed, 41 insertions(+), 18 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 71c4f35c56..ddbbd736db 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -67,46 +67,64 @@ nfp_devarg_handle_int(const char *key,
return 0;
}
-static void
-nfp_devarg_parse_force_reload_fw(struct rte_kvargs *kvlist,
- bool *force_reload_fw)
+static int
+nfp_devarg_parse_bool_para(struct rte_kvargs *kvlist,
+ const char *key_match,
+ bool *value_ret)
{
int ret;
+ uint32_t count;
uint64_t value;
+ count = rte_kvargs_count(kvlist, key_match);
+ if (count == 0)
+ return 0;
- if (rte_kvargs_count(kvlist, NFP_PF_FORCE_RELOAD_FW) != 1)
- return;
+ if (count > 1) {
+ PMD_DRV_LOG(ERR, "Too much bool arguments: %s", key_match);
+ return -EINVAL;
+ }
- ret = rte_kvargs_process(kvlist, NFP_PF_FORCE_RELOAD_FW, &nfp_devarg_handle_int, &value);
+ ret = rte_kvargs_process(kvlist, key_match, &nfp_devarg_handle_int, &value);
if (ret != 0)
- return;
+ return -EINVAL;
- if (value == 1)
- *force_reload_fw = true;
- else if (value == 0)
- *force_reload_fw = false;
- else
+ if (value == 1) {
+ *value_ret = true;
+ } else if (value == 0) {
+ *value_ret = false;
+ } else {
PMD_DRV_LOG(ERR, "The param does not work, the format is %s=0/1",
- NFP_PF_FORCE_RELOAD_FW);
+ key_match);
+ return -EINVAL;
+ }
+
+ return 0;
}
-static void
+static int
nfp_devargs_parse(struct nfp_devargs *nfp_devargs_param,
const struct rte_devargs *devargs)
{
+ int ret;
struct rte_kvargs *kvlist;
if (devargs == NULL)
- return;
+ return 0;
kvlist = rte_kvargs_parse(devargs->args, NULL);
if (kvlist == NULL)
- return;
+ return -EINVAL;
- nfp_devarg_parse_force_reload_fw(kvlist, &nfp_devargs_param->force_reload_fw);
+ ret = nfp_devarg_parse_bool_para(kvlist, NFP_PF_FORCE_RELOAD_FW,
+ &nfp_devargs_param->force_reload_fw);
+ if (ret != 0)
+ goto exit;
+exit:
rte_kvargs_free(kvlist);
+
+ return ret;
}
static void
@@ -1856,7 +1874,12 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
nfp_eth_set_configured(cpp, index, 0);
}
- nfp_devargs_parse(&pf_dev->devargs, pci_dev->device.devargs);
+ ret = nfp_devargs_parse(&pf_dev->devargs, pci_dev->device.devargs);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Error when parsing device args");
+ ret = -EINVAL;
+ goto eth_table_cleanup;
+ }
if (nfp_fw_setup(pci_dev, cpp, nfp_eth_table, hwinfo,
dev_info, &pf_dev->multi_pf, pf_dev->devargs.force_reload_fw) != 0) {
--
2.39.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 4/6] net/nfp: fix disable CPP service
[not found] <20240619030655.3216268-1-chaoyong.he@corigine.com>
2024-06-19 3:06 ` [PATCH 1/6] net/nfp: fix check logic for device arguments Chaoyong He
@ 2024-06-19 3:06 ` Chaoyong He
1 sibling, 0 replies; 2+ messages in thread
From: Chaoyong He @ 2024-06-19 3:06 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, stable, Peng Zhang, Chaoyong He
From: Long Wu <long.wu@corigine.com>
The CPP service is enabled in 'nfp_pf_init()', so it should be disabled
in corresponding free function 'nfp_pf_uninit()'.
Fixes: 600f6d2c7704 ("net/nfp: add service module")
Cc: stable@dpdk.org
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_representor.c | 3 ---
drivers/net/nfp/nfp_cpp_bridge.c | 6 ++++++
drivers/net/nfp/nfp_cpp_bridge.h | 1 +
drivers/net/nfp/nfp_ethdev.c | 1 +
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index f1451fcca2..700957f945 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -457,9 +457,6 @@ nfp_flower_repr_dev_close(struct rte_eth_dev *dev)
/* Stop flower service first */
nfp_flower_service_stop(app_fw_flower, hw_priv);
- /* Disable cpp service */
- nfp_service_disable(&pf_dev->cpp_service_info);
-
/* Now it is safe to free all PF resources */
nfp_uninit_app_fw_flower(hw_priv);
nfp_pf_uninit(hw_priv);
diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c
index 441c0d2843..fc73fa20ab 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.c
+++ b/drivers/net/nfp/nfp_cpp_bridge.c
@@ -45,6 +45,12 @@ nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev)
return 0;
}
+void
+nfp_disable_cpp_service(struct nfp_pf_dev *pf_dev)
+{
+ nfp_service_disable(&pf_dev->cpp_service_info);
+}
+
/*
* Serving a write request to NFP from host programs. The request
* sends the write size and the CPP target. The bridge makes use
diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h
index 406c961dce..93026c10f4 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.h
+++ b/drivers/net/nfp/nfp_cpp_bridge.h
@@ -9,5 +9,6 @@
#include "nfp_net_common.h"
int nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev);
+void nfp_disable_cpp_service(struct nfp_pf_dev *pf_dev);
#endif /* __NFP_CPP_BRIDGE_H__ */
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index ddbbd736db..76bbaf1f50 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -641,6 +641,7 @@ nfp_pf_uninit(struct nfp_net_hw_priv *hw_priv)
{
struct nfp_pf_dev *pf_dev = hw_priv->pf_dev;
+ nfp_disable_cpp_service(pf_dev);
nfp_cpp_area_release_free(pf_dev->mac_stats_area);
nfp_cpp_area_release_free(pf_dev->qc_area);
free(pf_dev->sym_tbl);
--
2.39.1
^ permalink raw reply [flat|nested] 2+ messages in thread