17 Star 12 Fork 75

src-openEuler/dpdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0070-net-sfc-use-new-kvargs-process-API.patch 4.00 KB
一键复制 编辑 原始数据 按行查看 历史
huangdengdui 提交于 2024-11-11 18:33 . sync some patchs from upstreaming
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/dpdk.git
git@gitee.com:src-openeuler/dpdk.git
src-openeuler
dpdk
dpdk
master

搜索帮助