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 62DAE606A31F for ; Sat, 5 Dec 2026 21:00:47 +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=k1zcSz9f Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8070D42E7C; Sat, 5 Dec 2026 21:53:40 +0100 (CET) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mails.dpdk.org (Postfix) with ESMTPS id 2777D42E75 for ; Sat, 5 Dec 2026 21:53:39 +0100 (CET) Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-3b41188c8b9so1179789a91.0 for ; Sat, 05 Dec 2026 12:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796504018; x=1797108818; 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=FMT+fCM/pyGbG0yo7tKdzW++aHGwiZlV2eiZef60Yg8=; b=k1zcSz9fn6mB+bSky/s5sIb1xybF/wq5bhEvPSggihxDEX8Dn8qgDS0TqJkAbKHzli Jlhj/W159MUKaaW8iLY7HyR2duenXGr4e6FtFOJyFxnq/mtRWc45BNCFiv0ZxJHD1gDD S51waTRLO3eBIO9Jqxqc1v3vq725nhEzdyuEy8RXY12QV1ZIN0yo/PlYu6P5U0WsjCWS J6ErQ5+Kv9c2yE8rCLxY6aac548PdtpqpRrdy7hO0wrMxtFiC/AdakgtP+H3Tj9Y5c5T awwPvIBv57rELSIPcIIJfZiiYKoTnTE/7EedboTPKZNLu4Q07GVzcXbJwMeyn10VNf0g D72g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796504018; x=1797108818; 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=FMT+fCM/pyGbG0yo7tKdzW++aHGwiZlV2eiZef60Yg8=; b=wpB+vc51YWeapOC4k2+ypbCy64ZluAnzTbvMzD5qAzSimzmM1TLJIVCl7gShhCSbXR WpzhDQ2SCyN/CMrD4yFFcZV7o36aVUWUqJvm+eci/1G5xQ2R0+lD5iiIvieNiqaWcauv B/rvcdBvI20eIhuT5en2A+Jf7BCvndqEVl8QhfRpX8SDCmPNaCZ52ZXcYmKUIbpSS3x7 aGF47ue5lrXkO1aK9HZgUpEq8Br3U80e7Wf4Sa5h93KqRQCZzZUlsJZ3sNFU/+1WohHE IUaEx9pHWB/yvyjgr7p0cGjRxpLA/Jt0PR//zoPF9WFeuajLnL3cKeoUQ5soyb4cowCW rGig== X-Gm-Message-State: AB4q+uFdxsCbI49w2mhcMS5IteTqc/SAkhHqI81b9Ewsz9uk1GpCsQcY 4L7IAxMwWwFn3dHc5YNtQXIlFYBYUN4UGDGghwC/w0aHPIFnyETJXnaiICHdWmNM3z5fCG3YLUZ SdkIjqZE= X-Gm-Gg: AZFdTZf5Z5rHG0Vvd8dNdXeJKHk3Twq2aZ8puNpBpHDxnrfT/nl7DCTVO5b6yO0+trV ZK8kDs6TH6R0zyzBrU5Zt3T3JSd2NeQ9R6L5TttCJha2wK/btwsOUEYxa68xBHq2KGe8z4eIcnh JHKoPf4dOETtxipPhaJZPI6qTPibAckrtWRhJsjF0snu8L0Hme0coEXgXeMxQ3AGiIkzrN97n+F HTe9Vt4E+JMVUs6Ew1JWlRiQAt44wZuBJuWQ6vZg46qaQcsHrIfeLaFcPCUmto3b0yjORHzLFgG jhOzhJz5fay+aOwq5ovbGmxFtwVaAyRWPAXZStP/TJDHvm1PNwRUl6gMT/+kZ/nX/bpcfFEiJ1s a331EyYtB4/3XPAppNZftUAPGElXQfsg6la5BcGHkLPbt5tz4I5lY3cIZzEk9l2JJ0Eg5p3bv7F cjvCXUdX5UunQBYi1oR3YQ1PnzneJVl7hnCedosTLNGoPEpEkIw+CB0bqFjsJfz7MyV8hA32D/e ktrSV5+sYgyQmY3geBCS3yPbxx04OprXKsSj4+VQFbsd0S96czQlSN0qBx5oL3Ly692cmWzypz3 O2zYIWB9/3qTnF5pAorl2IlbElpZGPR9TW3B52k0UZgZQ/DacBQu9NvduOEu50gJSNGM X-Received: by 2002:a17:90b:520e:b0:3ab:a3ee:33ad with SMTP id 98e67ed59e1d1-3b5e064997dmr5418654a91.22.1796504017601; Sat, 05 Dec 2026 12:53:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 12:53:36 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Xingui Yang , Chengwen Feng Subject: [PATCH v5 64/68] net/hns3: use kvargs hex helper for capability mask Date: Sat, 5 Dec 2026 12:50:35 -0800 Message-ID: <20261205205221.1131118-65-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 hns3_parse_dev_caps_mask() does no validation whatsoever: strtoull() is called with neither errno cleared nor the end pointer checked, so "dev_caps_mask=junk" is silently taken as zero and "dev_caps_mask=-1" wraps around to enable every capability. The value is documented as a hexadecimal mask, so use rte_kvargs_handle_hex64(), which reads it as hexadecimal with or without a 0x prefix. The documented form "dev_caps_mask=0xF" is unchanged, and so is a bare "F". Note that hns3_parse_devargs() discards the rte_kvargs_process() return value for every argument it parses, so a malformed mask is now reported but still leaves the default of zero in place rather than failing probe. Propagating those errors is a behaviour change per argument and is left for a separate patch. HNS3_CONVERT_TO_HEXADECIMAL loses its last user here, and HNS3_CONVERT_TO_DECIMAL lost its own earlier in this series, so remove both. Signed-off-by: Stephen Hemminger --- drivers/net/hns3/hns3_common.c | 18 +----------------- drivers/net/hns3/hns3_common.h | 3 --- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c index dd761fcef6..4ba440e57e 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -205,22 +205,6 @@ hns3_get_io_hint_func_name(uint32_t hint) } } -static int -hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) -{ - uint64_t val; - - RTE_SET_USED(key); - - if (value == NULL || extra_args == NULL) - return 0; - - val = strtoull(value, NULL, HNS3_CONVERT_TO_HEXADECIMAL); - *(uint64_t *)extra_args = val; - - return 0; -} - static int hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) { @@ -341,7 +325,7 @@ hns3_parse_devargs(struct rte_eth_dev *dev) (void)rte_kvargs_process(kvlist, HNS3_DEVARG_TX_FUNC_HINT, &hns3_parse_io_hint_func, &tx_func_hint); (void)rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, - &hns3_parse_dev_caps_mask, &dev_caps_mask); + rte_kvargs_handle_hex64, &dev_caps_mask); (void)rte_kvargs_process(kvlist, HNS3_DEVARG_MBX_TIME_LIMIT_MS, &hns3_parse_mbx_time_limit, &mbx_time_limit_ms); if (!hns->is_vf) { diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h index 7b3f96b01a..967cde9e39 100644 --- a/drivers/net/hns3/hns3_common.h +++ b/drivers/net/hns3/hns3_common.h @@ -9,9 +9,6 @@ #include "hns3_ethdev.h" -#define HNS3_CONVERT_TO_DECIMAL 10 -#define HNS3_CONVERT_TO_HEXADECIMAL 16 - enum { HNS3_IO_FUNC_HINT_NONE = 0, HNS3_IO_FUNC_HINT_VEC, -- 2.53.0