From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9557D45AEA; Wed, 9 Oct 2024 06:49:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5BC0840BA0; Wed, 9 Oct 2024 06:49:38 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 995C44069F for ; Wed, 9 Oct 2024 06:49:34 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4XNgQJ2WPNz20pwk; Wed, 9 Oct 2024 12:48:56 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 9DA1C1A016C; Wed, 9 Oct 2024 12:49:32 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 9 Oct 2024 12:49:32 +0800 From: Chengwen Feng To: , , Andrew Rybchenko CC: , Subject: [PATCH v6 2/4] net/sfc: use new API to parse kvargs Date: Wed, 9 Oct 2024 04:50:28 +0000 Message-ID: <20241009045030.26874-3-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241009045030.26874-1-fengchengwen@huawei.com> References: <20230314124813.39521-1-fengchengwen@huawei.com> <20241009045030.26874-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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 5eeffb065b..458efacba5 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 3480a51642..89444f0b4a 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -2835,8 +2835,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; @@ -2878,8 +2878,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; @@ -3073,8 +3073,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 783cb43ae6..eb36fa98ca 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 2226f2b3d9..4dcc61e973 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.17.1