代码拉取完成,页面将自动刷新
From 45f9f54fa1a896d8bf579723c8e1bc42c3dff7d2 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Wed, 9 Oct 2024 04:50:28 +0000
Subject: [PATCH] net/sfc: use new kvargs process API
[ upstream commit f33e8c0e4a80c1456987f96c1ce448d65e7d6dfb ]
Add sfc_kvargs_process_opt() function to handle only-key case, and
remove redundancy NULL judgement of value because the rte_kvargs_process
(which invoked in sfc_kvargs_process()) will handle it.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/sfc_efx/sfc_efx.c | 3 ---
drivers/net/sfc/sfc_ethdev.c | 12 ++++++------
drivers/net/sfc/sfc_kvargs.c | 12 +++++++++++-
drivers/net/sfc/sfc_kvargs.h | 2 ++
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
index 2dc5545..f96b5e5 100644
--- a/drivers/common/sfc_efx/sfc_efx.c
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -23,9 +23,6 @@ sfc_efx_kvarg_dev_class_handler(__rte_unused const char *key,
{
enum sfc_efx_dev_class *dev_class = opaque;
- if (class_str == NULL)
- return *dev_class;
-
if (strcmp(class_str, "vdpa") == 0) {
*dev_class = SFC_EFX_DEV_CLASS_VDPA;
} else if (strcmp(class_str, "net") == 0) {
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 6d57b2b..eacd6c2 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -2836,8 +2836,8 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev)
if (encp->enc_rx_es_super_buffer_supported)
avail_caps |= SFC_DP_HW_FW_CAP_RX_ES_SUPER_BUFFER;
- rc = sfc_kvargs_process(sa, SFC_KVARG_RX_DATAPATH,
- sfc_kvarg_string_handler, &rx_name);
+ rc = sfc_kvargs_process_opt(sa, SFC_KVARG_RX_DATAPATH,
+ sfc_kvarg_string_handler, &rx_name);
if (rc != 0)
goto fail_kvarg_rx_datapath;
@@ -2879,8 +2879,8 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev)
sfc_notice(sa, "use %s Rx datapath", sas->dp_rx_name);
- rc = sfc_kvargs_process(sa, SFC_KVARG_TX_DATAPATH,
- sfc_kvarg_string_handler, &tx_name);
+ rc = sfc_kvargs_process_opt(sa, SFC_KVARG_TX_DATAPATH,
+ sfc_kvarg_string_handler, &tx_name);
if (rc != 0)
goto fail_kvarg_tx_datapath;
@@ -3074,8 +3074,8 @@ sfc_parse_switch_mode(struct sfc_adapter *sa, bool has_representors)
sfc_log_init(sa, "entry");
- rc = sfc_kvargs_process(sa, SFC_KVARG_SWITCH_MODE,
- sfc_kvarg_string_handler, &switch_mode);
+ rc = sfc_kvargs_process_opt(sa, SFC_KVARG_SWITCH_MODE,
+ sfc_kvarg_string_handler, &switch_mode);
if (rc != 0)
goto fail_kvargs;
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 783cb43..eb36fa9 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -73,6 +73,16 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
}
+int
+sfc_kvargs_process_opt(struct sfc_adapter *sa, const char *key_match,
+ arg_handler_t handler, void *opaque_arg)
+{
+ if (sa->kvargs == NULL)
+ return 0;
+
+ return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
+}
+
int
sfc_kvarg_bool_handler(__rte_unused const char *key,
const char *value_str, void *opaque)
@@ -104,7 +114,7 @@ sfc_kvarg_long_handler(__rte_unused const char *key,
long value;
char *endptr;
- if (!value_str || !opaque)
+ if (!opaque)
return -EINVAL;
value = strtol(value_str, &endptr, 0);
diff --git a/drivers/net/sfc/sfc_kvargs.h b/drivers/net/sfc/sfc_kvargs.h
index 2226f2b..4dcc61e 100644
--- a/drivers/net/sfc/sfc_kvargs.h
+++ b/drivers/net/sfc/sfc_kvargs.h
@@ -83,6 +83,8 @@ void sfc_kvargs_cleanup(struct sfc_adapter *sa);
int sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
arg_handler_t handler, void *opaque_arg);
+int sfc_kvargs_process_opt(struct sfc_adapter *sa, const char *key_match,
+ arg_handler_t handler, void *opaque_arg);
int sfc_kvarg_bool_handler(const char *key, const char *value_str,
void *opaque);
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。