From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1501B606A31F for ; Sat, 5 Dec 2026 20:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=GwEHo73m Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 430D942DCB; Sat, 5 Dec 2026 21:53:22 +0100 (CET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTPS id E5D4540E4B for ; Sat, 5 Dec 2026 21:53:20 +0100 (CET) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2f0621eec70so16323945ad.2 for ; Sat, 05 Dec 2026 12:53:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796503999; x=1797108799; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=btVwyQPyJIWeIq0WVDCybiYZerxBlLizcdFSg4FAjks=; b=GwEHo73mzEPGrH7fpHOEJSigNqaB0wu4tHb5Rui8hOyLGegxiREZBtjcR18Fas+2dX N3j2CnFOWNlum1TvfSI4r6bFbOhyPxR47KdK9aha7FFw0fg1Pmhd8SoRTFHn6FRYs/G5 0KlWecSoJbWbKtaHVU1le+OqSa+7IsOyi+seazcFAhzba+/9cJaj9SnfDA7i4r6///QS vi/MOrBd9WyM7h5LqjM9F5pWGhc/XMdnUTk6/76uu0i/LPUZoccE4S3hRhWh8Cuk+Go7 WDFUmwIS1hBPslIgA+8IDuuJONDtbm1Q3ZeLCMT3Hb4cR/kWjXKV2JZJK4YagYOw287f 8fsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796503999; x=1797108799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=btVwyQPyJIWeIq0WVDCybiYZerxBlLizcdFSg4FAjks=; b=jdFV6EqqcmuOJu6dLZ8C5C1XhXADImrIW2/ri7NK8hltQidp9r8HlzYUljuGsLO5nX FAlX7ow3Dj1JLZkNJT9OZB/Uuaj0yhSz6wt/eYelUJhFC7r1DBEWFxniNBE9S5ySPOc0 dK8HDwDp37SD0EXQiGfontrY0sqUtuTXNS1PDWvo9qFo9HOpwcqwF2ILZqxcI1Q9JuAS 9d7seFNxHUulizMpfUefxFr+DvwxiyMeU60ka1GtLOVcilEGCG11QFmNGkMy89F19Ehx cXI36GHppw7mio2VxXKAgItrMn82Ko6R0SNoWDIsYdc/kXgQU3tfulq4B7eWZ8xgUGW/ +RJQ== X-Gm-Message-State: AB4q+uGk8tzC33nbUZeN+0Ybjmgzb+iRnl+k8gTx8Nk+B61k6Q8rZfcq 41lyLBT+a+xClaebGXuJewNHc2cFdorTUpmmYi3aw1OOSsmE0Hc/TUVl4dY8FPSZvssh0ToZmdV iKK9K X-Gm-Gg: AZFdTZc3EZXEvCrItkramFbFHa4caUbiqvqbfmXjtNikkhwOD2O3ada3zf3bKyZnIX/ M1jpQtArvaC9ZZW4FYe/v6LznIK/6pCB+bEEdjXu0gclCbwvHhx1upsgti5VzeZ/qservnjyl2j YPJJlh9WcPx0d1YEFSY9JEUf3HtaGxyPO+cNnDzH057gGQutnHVpdL2rwuiHMyK8s2bOOOTH0Gi s4wPnXhWoSaZ4BGPYZOohlS8UZ0CU8VAOfyapXAcXyH1qGR2mnny//LR99Yyww8WgW8YJ+n8QkG C3/XNvvmsU9Z8TqyoIjuh6LBybge8bh0wjff59Rk7szvAK83X73VYhtk5XXlaKF5agxdJn++HSE PP02r/TsFgOoLhKs77rALB+/6Y5RpI0RxD22bZgWDoZpj4eVZ3sDUuQMSKzR7t7ThU+UKghnnH0 FUQScZJBciwoOvj++bSmhKZichlDShWdNH/9tCNvIFiu7HplNDUnSj+KCSOGLJ0PDcqzoDvyzRU WbJAGsO7j5fxt9J85FRyyiNVO/yX7TOPrZhdkqUM5XO1rNgScYRrl0PpQ6mWEMw0DvHVi9Z5avO 7u8dH5CXkKp2Lrn9BT6jQk+TOKmTpFRoZZkihcJQVM8hFFL/Wr+rmMdokDunR9BCCtFe X-Received: by 2002:a17:90b:3c41:b0:3b4:1336:4f6b with SMTP id 98e67ed59e1d1-3b5e06662cemr5519411a91.33.1796503999359; Sat, 05 Dec 2026 12:53:19 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b6166c7c72sm2965998a91.3.2026.12.05.12.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 12:53:18 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tirthendu Sarkar Subject: [PATCH v5 47/68] event/dlb2: use kvargs numeric helpers Date: Sat, 5 Dec 2026 12:50:18 -0800 Message-ID: <20261205205221.1131118-48-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261205205221.1131118-1-stephen@networkplumber.org> References: <20260914054912.755403-1-stephen@networkplumber.org> <20261205205221.1131118-1-stephen@networkplumber.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 dlb2_string_to_int() returns -errno on failure, but errno is only meaningful when strtol() actually failed; on a plain parse failure it returns -0, that is success, with an uninitialised result. The end pointer is also only checked after the errno test, so "abc" reaches the range check with a value of zero. All thirteen dlb2 devargs handlers go through this one function, so converting it covers them all. set_numa_node() is replaced by rte_kvargs_handle_socket_id(). It used "> RTE_MAX_NUMA_NODES", which is off by one and accepted a socket id one past the end of the range, so that value is now rejected. The helper also rejects a negative socket id other than -1, which is SOCKET_ID_ANY. The four boolean arguments use rte_kvargs_handle_bool() and their local handlers go away: vector_opts_enable, default_ldb_port_allocation, enable_cq_weight and use_default_hl. Beware that this changes what the first three accept. They only ever tested for a leading 'y' or 'Y', so "=1" meant false, and any typo silently meant false as well. They now take the usual boolean spellings, "=1" means true, and anything else is rejected. The documented "=" form still works; the examples are updated to the more usual "=<0|1>". use_default_hl already treated '0' and 'n' as false and everything else as true, so only the rejection of garbage is new there. Signed-off-by: Stephen Hemminger --- doc/guides/eventdevs/dlb2.rst | 11 ++- drivers/event/dlb2/dlb2.c | 127 ++++------------------------------ 2 files changed, 17 insertions(+), 121 deletions(-) diff --git a/doc/guides/eventdevs/dlb2.rst b/doc/guides/eventdevs/dlb2.rst index 06841ba312..4397851504 100644 --- a/doc/guides/eventdevs/dlb2.rst +++ b/doc/guides/eventdevs/dlb2.rst @@ -380,7 +380,7 @@ follows .. code-block:: console - --allow ea:00.0,vector_opts_enabled= + --allow ea:00.0,vector_opts_enabled=<0|1> Maximum CQ Depth ~~~~~~~~~~~~~~~~ @@ -433,13 +433,12 @@ reduce the likelihood of sequential ports mapping to the same QID(s). Hence, DLB uses an initial allocation of Port IDs to maximize the average distance between an ID and its immediate neighbors. (i.e.the distance from 1 to 0 and to 2, the distance from 2 to 1 and to 3, etc.). -Initial port allocation option can be passed through devarg. If y (or Y) -inial port allocation will be used, otherwise initial port allocation -won't be used. +Initial port allocation option can be passed through devarg. If set, +initial port allocation will be used, otherwise it won't be used. .. code-block:: console - --allow ea:00.0,default_port_allocation= + --allow ea:00.0,default_port_allocation=<0|1> QE Weight ~~~~~~~~~ @@ -459,7 +458,7 @@ Example command to enable QE Weight feature: .. code-block:: console - --allow ea:00.0,enable_cq_weight= + --allow ea:00.0,enable_cq_weight=<0|1> Credit Handling Scenario Improvements ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c index 084875f1c8..b3eceab094 100644 --- a/drivers/event/dlb2/dlb2.c +++ b/drivers/event/dlb2/dlb2.c @@ -288,24 +288,15 @@ dlb2_hw_query_resources(struct dlb2_eventdev *dlb2) return 0; } -#define DLB2_BASE_10 10 - static int dlb2_string_to_int(int *result, const char *str) { - long ret; - char *endptr; + int64_t ret; - if (str == NULL || result == NULL) + if (result == NULL) return -EINVAL; - errno = 0; - ret = strtol(str, &endptr, DLB2_BASE_10); - if (errno) - return -errno; - - /* long int and int may be different width for some architectures */ - if (ret < INT_MIN || ret > INT_MAX || endptr == str) + if (rte_kvargs_to_int(str, INT_MIN, INT_MAX, &ret) < 0) return -EINVAL; *result = ret; @@ -329,22 +320,6 @@ set_producer_coremask(const char *key __rte_unused, return 0; } -static int -set_numa_node(const char *key __rte_unused, const char *value, void *opaque) -{ - int *socket_id = opaque; - int ret; - - ret = dlb2_string_to_int(socket_id, value); - if (ret < 0) - return ret; - - if (*socket_id > RTE_MAX_NUMA_NODES) - return -EINVAL; - return 0; -} - - static int set_max_cq_depth(const char *key __rte_unused, const char *value, @@ -667,84 +642,6 @@ set_default_depth_thresh(const char *key __rte_unused, return 0; } -static int -set_vector_opts_enab(const char *key __rte_unused, - const char *value, - void *opaque) -{ - bool *dlb2_vector_opts_enabled = opaque; - - if (value == NULL || opaque == NULL) { - DLB2_LOG_ERR("NULL pointer"); - return -EINVAL; - } - - if ((*value == 'y') || (*value == 'Y')) - *dlb2_vector_opts_enabled = true; - else - *dlb2_vector_opts_enabled = false; - - return 0; -} - -static int -set_default_ldb_port_allocation(const char *key __rte_unused, - const char *value, - void *opaque) -{ - bool *default_ldb_port_allocation = opaque; - - if (value == NULL || opaque == NULL) { - DLB2_LOG_ERR("NULL pointer"); - return -EINVAL; - } - - if ((*value == 'y') || (*value == 'Y')) - *default_ldb_port_allocation = true; - else - *default_ldb_port_allocation = false; - - return 0; -} - -static int -set_enable_cq_weight(const char *key __rte_unused, - const char *value, - void *opaque) -{ - bool *enable_cq_weight = opaque; - - if (value == NULL || opaque == NULL) { - DLB2_LOG_ERR("NULL pointer"); - return -EINVAL; - } - - if ((*value == 'y') || (*value == 'Y')) - *enable_cq_weight = true; - else - *enable_cq_weight = false; - - return 0; -} - -static int set_hl_override(const char *key __rte_unused, const char *value, - void *opaque) -{ - bool *default_hl = opaque; - - if (value == NULL || opaque == NULL) { - DLB2_LOG_ERR("NULL pointer"); - return -EINVAL; - } - - if ((*value == 'n') || (*value == 'N') || (*value == '0')) - *default_hl = false; - else - *default_hl = true; - - return 0; -} - static int set_hl_entries(const char *key __rte_unused, const char *value, void *opaque) { @@ -5223,7 +5120,7 @@ dlb2_parse_params(const char *params, name); } else { int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG, - set_numa_node, + rte_kvargs_handle_socket_id, &dlb2_args->socket_id); if (ret != 0) { DLB2_LOG_ERR("%s: Error parsing numa node parameter", @@ -5335,9 +5232,9 @@ dlb2_parse_params(const char *params, return ret; } - ret = rte_kvargs_process(kvlist, + ret = rte_kvargs_process_opt(kvlist, DLB2_VECTOR_OPTS_ENAB_ARG, - set_vector_opts_enab, + rte_kvargs_handle_bool, &dlb2_args->vector_opts_enabled); if (ret != 0) { DLB2_LOG_ERR("%s: Error parsing vector opts enabled", @@ -5403,9 +5300,9 @@ dlb2_parse_params(const char *params, return ret; } - ret = rte_kvargs_process(kvlist, + ret = rte_kvargs_process_opt(kvlist, DLB2_DEFAULT_LDB_PORT_ALLOCATION_ARG, - set_default_ldb_port_allocation, + rte_kvargs_handle_bool, &dlb2_args->default_ldb_port_allocation); if (ret != 0) { DLB2_LOG_ERR("%s: Error parsing ldb default port allocation arg", @@ -5414,9 +5311,9 @@ dlb2_parse_params(const char *params, return ret; } - ret = rte_kvargs_process(kvlist, + ret = rte_kvargs_process_opt(kvlist, DLB2_ENABLE_CQ_WEIGHT_ARG, - set_enable_cq_weight, + rte_kvargs_handle_bool, &dlb2_args->enable_cq_weight); if (ret != 0) { DLB2_LOG_ERR("%s: Error parsing enable_cq_weight arg", @@ -5427,8 +5324,8 @@ dlb2_parse_params(const char *params, if (version == DLB2_HW_V2 && dlb2_args->enable_cq_weight) DLB2_LOG_INFO("Ignoring 'enable_cq_weight=y'. Only supported for 2.5 HW onwards"); - ret = rte_kvargs_process(kvlist, DLB2_USE_DEFAULT_HL, - set_hl_override, + ret = rte_kvargs_process_opt(kvlist, DLB2_USE_DEFAULT_HL, + rte_kvargs_handle_bool, &dlb2_args->use_default_hl); if (ret != 0) { DLB2_LOG_ERR("%s: Error parsing hl_override arg", -- 2.53.0