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 42E76606A322 for ; Sat, 5 Dec 2026 06:32:19 +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=taWurTXn Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C9AF42D3F; Sat, 5 Dec 2026 07:26:44 +0100 (CET) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by mails.dpdk.org (Postfix) with ESMTPS id 07EF7427D3 for ; Sat, 5 Dec 2026 07:26:38 +0100 (CET) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-ce12ecc2af9so383638a12.1 for ; Fri, 04 Dec 2026 22:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796451996; x=1797056796; 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=2d5I6RfGs4ozcuWRP0apnYYyVJP+5TNX2DKnH1VeMbU=; b=taWurTXnrdm1lFq66AIa8C81W1EZvkIkmjPL9VjwJr8wZ9RZXTWFCklvfzyf1YvOb6 P/fyk9PRt8sPzl9iT+E2KXRnaS7+LfvxMtIW/X1tG54lP8ZVMJ/YSWDKQvu4yh04OofT FPRIOhjQh1lYpnYlVv1Sq8QStZsHgwO3nku+kCPWqOIUtTWEXLynnt48Y1ZMRrsoWlGT LWGGQhB3rZvn2aaLDhife8ut4heZbcK4VyM5AZNbwYYDs5U28ACFhmuy9gVbiaiWjlPF 8OkfCIVg/rkuSC1JTFQzfgrs1AxbHcxQwVa0+i6tbjfghMinkAVCl+aJCUPd4ShoZECD rTIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796451996; x=1797056796; 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=2d5I6RfGs4ozcuWRP0apnYYyVJP+5TNX2DKnH1VeMbU=; b=YpX+YUbPwUI3Uz6T+wAI05Bx02hyiWTQh/pbCwRnySmy4J4xr1IPqp68ZqdkJEDZX9 yExoJZKAWpMWNxACXlv7g/npA/OysVx2XqETdnLaFqvP00N31Fea/5bLWfTzt0tGYeg5 g5Gl6bsl0uh/A5BVjoKZXMNJpmzi5+JNA7oOvZpPiAXT4B5Obh+cHB56Hb1ovlPlUIhq niJISD9PTW2S1/4kVGyeYK0b90AKJ67/81R0il16ijM/jmHel9j8pCgrzzRyIIYFNtP3 UQtFNjhWV7oc5ojfs5/G4WGkG6sd5wztD9Ki5xEaPLvlJupByNcCe23Wef3D48HgNP3g EvOg== X-Gm-Message-State: AB4q+uFokjZqKLWXxxvevsu4YNjVbJAgywwBq+hAOR7MLCo2e5gpSvk1 Dsp5ZBtA7rB1J4yPD26FByW8oThVUkYGUIF5dGYm288wR4xzGlUcWTcb0Be/jp/wRuX4fS0saSu 6W9zT/8M= X-Gm-Gg: AZFdTZcsrXfvyKSMmknSabSSpljtcIRonjwjXA4uX2iWPWXGOHeqSBf/ZwfZZCUMmZA fe55RKAgJyhJsxWogj7bs1vtqr9iE/tnnhK7oapx4hvsPuXITm62X9cI6oy+dfgcKy6mPKqI3Z5 RoEFSRJ24aAAzqcZ5o0OBxA5BfH8iYuFVNZ0A/1kl3lDbEp4IykVgUOKVZhGLZddlhZNORPk9SD +OXREwx5kjgwwUq+yHC6pK/4H+SIUpSYkbpb/7ZgKlBo9iyKrt+MNsGNsKq0ObTVDOOCK6HwbHd q32B//PE/l604H94u8UU5wf3U02D4Php05i4eBBZyQjLZ4glo3u81ZKoL87cG5IyXiOHZwlsqxz 8JdYoM67RmgCcwI550405jPPjoVieLoS7JNCLD++hys60SxhKiW19NXBwd+zB4cBz9u1emiWNT6 pQSlR5dZi8ovboxZoIpNTNgXMx+yfG2AgAqBcZW7WdJwKTd7x6EmSIh79yZowqZNhsULoryhN4+ DWpvNiBlspn2jhIHZMF4EW84TupYiWtb+wwjzcJQWOZjDRXGNrgIas9TCtSWNHIxl3Hp/ETfdLe 5DtW5Ouugmp67W1rJNi9Y2rHZ4tyjo+w6EOOCZfulhTlvup75+ov4IN7kEivIahGjvJ+ X-Received: by 2002:a17:90b:1a81:b0:3a0:cca0:4a8c with SMTP id 98e67ed59e1d1-3b5e0619681mr2439256a91.7.1796451996496; Fri, 04 Dec 2026 22:26:36 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b6168d3e2fsm1162797a91.2.2026.12.04.22.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:26:35 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH v4 52/68] net/mlx4: use kvargs numeric helpers Date: Fri, 4 Dec 2026 22:20:29 -0800 Message-ID: <20261205062551.19553-53-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261205062551.19553-1-stephen@networkplumber.org> References: <20260914054912.755403-1-stephen@networkplumber.org> <20261205062551.19553-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 mlx4_arg_parse() checks errno without clearing it first, so a stale value left by earlier code rejects a valid argument, while a malformed value such as "abc" sets no errno at all and is silently taken as zero. The end pointer is never checked, so "1junk" is accepted. Base 0 was used, so a leading zero silently selected octal. The PCI_SLOT_NAME parser is left alone: it reads sysfs rather than a device argument. mr_ext_memseg_en is a boolean, so make the mlx4_conf field bool and parse it with rte_kvargs_handle_bool(). mlx4_arg_parse() serves several keys through a cast function pointer, so the boolean gets a call of its own and the generic loop skips it. The one bit field it is later copied into stays as it is. Signed-off-by: Stephen Hemminger --- drivers/net/mlx4/mlx4.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index c5015bc03c..c3794cd798 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -70,7 +70,7 @@ struct mlx4_conf { uint32_t present; /**< Bit-field for existing ports. */ uint32_t enabled; /**< Bit-field for user-enabled ports. */ } ports; - int mr_ext_memseg_en; + bool mr_ext_memseg_en; /** Whether memseg should be extended for MR creation. */ }; @@ -532,12 +532,10 @@ mlx4_ibv_device_to_pci_addr(const struct ibv_device *device, static int mlx4_arg_parse(const char *key, const char *val, struct mlx4_conf *conf) { - unsigned long tmp; + uint64_t tmp; - errno = 0; - tmp = strtoul(val, NULL, 0); - if (errno) { - rte_errno = errno; + if (rte_kvargs_to_uint(val, 0, UINT32_MAX, &tmp) < 0) { + rte_errno = EINVAL; WARN("%s: \"%s\" is not a valid integer", key, val); return -rte_errno; } @@ -545,18 +543,16 @@ mlx4_arg_parse(const char *key, const char *val, struct mlx4_conf *conf) uint32_t ports = rte_log2_u32(conf->ports.present + 1); if (tmp >= ports) { - ERROR("port index %lu outside range [0,%" PRIu32 ")", - tmp, ports); + ERROR("port index %u outside range [0,%u)", + (unsigned int)tmp, ports); return -EINVAL; } if (!(conf->ports.present & (1 << tmp))) { rte_errno = EINVAL; - ERROR("invalid port index %lu", tmp); + ERROR("invalid port index %u", (unsigned int)tmp); return -rte_errno; } conf->ports.enabled |= 1 << tmp; - } else if (strcmp(MLX4_MR_EXT_MEMSEG_EN_KVARG, key) == 0) { - conf->mr_ext_memseg_en = !!tmp; } else { rte_errno = EINVAL; WARN("%s: unknown parameter", key); @@ -590,8 +586,21 @@ mlx4_args(struct rte_devargs *devargs, struct mlx4_conf *conf) ERROR("failed to parse kvargs"); return -rte_errno; } + /* + * mr_ext_memseg_en is a boolean and has a handler of its own; the + * loop below covers the arguments which mlx4_arg_parse() handles. + */ + ret = rte_kvargs_process_opt(kvlist, MLX4_MR_EXT_MEMSEG_EN_KVARG, + rte_kvargs_handle_bool, + &conf->mr_ext_memseg_en); + if (ret != 0) + goto free_kvlist; + /* Process parameters. */ for (i = 0; pmd_mlx4_init_params[i]; ++i) { + if (strcmp(pmd_mlx4_init_params[i], + MLX4_MR_EXT_MEMSEG_EN_KVARG) == 0) + continue; arg_count = rte_kvargs_count(kvlist, pmd_mlx4_init_params[i]); while (arg_count-- > 0) { ret = rte_kvargs_process(kvlist, @@ -783,7 +792,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) struct rte_eth_dev *prev_dev = NULL; struct mlx4_conf conf = { .ports.present = 0, - .mr_ext_memseg_en = 1, + .mr_ext_memseg_en = true, }; unsigned int vf; int i; -- 2.53.0