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 7C2F7606A322 for ; Sat, 5 Dec 2026 06:28:46 +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=AYnqtXLe Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8075410F2; Sat, 5 Dec 2026 07:26:16 +0100 (CET) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTPS id 34DA540EE7 for ; Sat, 5 Dec 2026 07:26:12 +0100 (CET) Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-3b487f44ee0so1130872a91.0 for ; Fri, 04 Dec 2026 22:26:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796451971; x=1797056771; 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=CqAPMSgYqr+0a0IqrflyYXAid6FyYUU1vEtsBi5ICsQ=; b=AYnqtXLerbaoHEkkqHDzbNNsZROjgeeCu4P/+wX7lhM6M2j+hUQR5GQOBx5LehZ+ak xA9HcLtigGH5L5l7/yyARtAKqXv2skU7a5NGZ+KgflIWB7E1a5PN9Zr2eAGcJWs4c4b8 3UfZsKXpLaD0t7hUVU6iAGa+p7/AbdnWOOkprIa3bYv2/CweO9DIDZHdN6McZBV3BuGs jFNfq/qyLYuHJDIlqi2iVLfjSowQiXsw1AHpoIBEglaZNkCQAtcjpq5z9AUVuBtMpjBR RTkpapSK5eosJXRc5BAAPg0jxvZsXcm8hDqLCeAufYHYuYctYMyL6Tb4HC49OKGtxaWg Kp2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796451971; x=1797056771; 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=CqAPMSgYqr+0a0IqrflyYXAid6FyYUU1vEtsBi5ICsQ=; b=XGlhz3G6ibJ2BEi8iPhNRKk9PvJd8WDAi14zATjUBvEpjL5Ev5cUwXKNrJ8fTBTcTi ru8NMGrZnV6Cx/WiRye6Q20PDEDwu39kU7qzrqgqBgk95XFTB9+DmpbQeWMn39oiapAV G+vDPwq42bjR9zZXLsbGXeke4z/3s0KDfb3nLaZWiQW14xhxx06PWXtyE3/JJrmNH7QP HPFnXCzDXagEQ19ihvZhtgIaHRaTA01HNLI6GUikcVzvKYUYFD5rCztMDtp5FLSL5GYi QaL8T2GZJg6GxkUf2iO0gHi0HPWbuce24+lUAS7pTAe8pwI5ajc+0+FcsmeJslW6sNbZ 0vlw== X-Gm-Message-State: AB4q+uGvbILql0J653XZ7e9aHsCCjbgtL7aYSV/+umqEJYfAhd5qZ1Gq BV4KXqzOS+fGfoehBHc+YAsUBchrK1n8/kSC0FOuyBaa24hdDRnTfxl9TicoifZpHyEfigl7Zes 6DFQ3 X-Gm-Gg: AZFdTZdUBvJ284SDR7DrrzVAv4V5l7xSPkIqeEGV8O/gsY9pgCMKE7ycT1FO32rkXPM f2EbDbhr9zrqjD2W98lCYzLdcG4Kma1J2N/cSrDUv9nsG7krMi9OOS8sZP+fng54UiQ+yH00IGv /N9Vn8K9z7V8ahJ8ECdnr9bpjdht1EuSXKmMkxOIWvqrgJAaLKCfcel95so4Y8sq4EcU8OGgA6R Q0OU5tkRKNOaEXXVMSnLL5eIDfLSO0D26+f2J4bT9S0ySE5qKhU0IJM1bA/hQbBxaRZ2ns/rEER EHu2vi8ow7o8nArcaoVy2UwHEcU1T277Hnr1bnTOD2Lu7Eb8FKXWKlNlzfhG3lYOHT/y9rC2RDE ztDuxhjhUwGBpGhdw+PDTt+qLLTvDGfq5E7sUD9lV6MZ0aJSx9x6SpP70Ucj/9E4SjWFXuo3/tI lxbhq3z0jolssEI42yWcxOMzm3uOlEuGpm42ECMVYTGAcBJxXIO0Vi1wO4m/5pE4JNJM/a0ZQQS XngO2tE3DJURjiJQ6LT+DSkX5va8UAV/VZGq7TyyCr4/YfSqa4fjODTRPaabqU0wpqWOvPfmWIG 6usKWUIzBim0Ump56XRVPVn8PNSEEqPowgY5aOsYDoCHNjHWHGXi0oKewNcSlD3vvUwadg== X-Received: by 2002:a17:90a:d884:b0:3b3:b632:7f1b with SMTP id 98e67ed59e1d1-3b5e0653c7amr4096874a91.12.1796451970588; Fri, 04 Dec 2026 22:26:10 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:26:10 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v4 21/68] net/af_packet: use kvargs numeric helpers Date: Fri, 4 Dec 2026 22:19:58 -0800 Message-ID: <20261205062551.19553-22-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 The open coded parse_uint() is correct, but the same checks are now available from kvargs. Use them, and express the lower bound as part of the range rather than as a separate test after each call. qdisc_bypass and ignore_outgoing are booleans, so parse them with rte_kvargs_handle_bool() into a bool. A bare "qdisc_bypass" with no value now enables it, which the manual pair loop here supports without any further change. Note that both parameters of rte_pmd_init_internals() stay an unsigned int: the address of each is passed to setsockopt(), which expects a four byte int. Signed-off-by: Stephen Hemminger --- drivers/net/af_packet/rte_eth_af_packet.c | 81 ++++++----------------- 1 file changed, 20 insertions(+), 61 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index fbaea57615..1c2da2d6da 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -70,7 +69,7 @@ struct __rte_cache_aligned pkt_rx_queue { uint8_t vlan_strip; uint8_t timestamp_offloading; uint8_t scatter_enabled; - uint8_t ignore_outgoing; + bool ignore_outgoing; volatile unsigned long rx_pkts; volatile unsigned long rx_bytes; @@ -204,7 +203,7 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) break; /* skip outgoing frames if ignore_outgoing is set */ - if (pkt_q->ignore_outgoing != 0) { + if (pkt_q->ignore_outgoing) { sll = (struct sockaddr_ll *)((uint8_t *)ppd + TPACKET_ALIGN(sizeof(*ppd))); if (sll->sll_pkttype == PACKET_OUTGOING) @@ -1209,36 +1208,17 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, /* Parse an unsigned integer device argument. */ static int parse_uint(const char *key, const char *value, - unsigned int *out, unsigned long limit) + unsigned int *out, unsigned long min, unsigned long max) { - unsigned long val; - char *endptr; + uint64_t val; - if (value == NULL) { - PMD_LOG(ERR, "no value for argument \"%s\"", key); - return -1; - } - - /* Skip leading whitespace so a leading sign can be detected. */ - while (isspace((unsigned char)*value)) - value++; - - /* strtoul() silently accepts and negates a leading '-'. */ - if (*value == '\0' || *value == '-') { - PMD_LOG(ERR, "invalid value \"%s\" for argument \"%s\"", - value, key); - return -1; - } - - errno = 0; - val = strtoul(value, &endptr, 10); - if (errno != 0 || *endptr != '\0' || val > limit) { + if (rte_kvargs_to_uint(value, min, max, &val) < 0) { PMD_LOG(ERR, "invalid value \"%s\" for argument \"%s\"", - value, key); + value == NULL ? "" : value, key); return -1; } - *out = (unsigned int)val; + *out = val; return 0; } @@ -1257,9 +1237,9 @@ rte_eth_from_packet(struct rte_vdev_device *dev, unsigned int framesize = DFLT_FRAME_SIZE; unsigned int framecount = DFLT_FRAME_COUNT; unsigned int qpairs = 1; - unsigned int qdisc_bypass = 1; + bool qdisc_bypass = true; const char *fanout_mode = NULL; - unsigned int ignore_outgoing = 0; + bool ignore_outgoing = false; /* do some parameter checking */ if (*sockfd < 0) @@ -1273,52 +1253,31 @@ rte_eth_from_packet(struct rte_vdev_device *dev, for (k_idx = 0; k_idx < kvlist->count; k_idx++) { pair = &kvlist->pairs[k_idx]; if (strstr(pair->key, ETH_AF_PACKET_NUM_Q_ARG) != NULL) { - if (parse_uint(pair->key, pair->value, - &qpairs, RTE_MAX_QUEUES_PER_PORT) < 0) - return -1; - if (qpairs < 1) { - PMD_LOG(ERR, - "%s: invalid qpairs value", - name); + if (parse_uint(pair->key, pair->value, &qpairs, + 1, RTE_MAX_QUEUES_PER_PORT) < 0) return -1; - } continue; } if (strstr(pair->key, ETH_AF_PACKET_BLOCKSIZE_ARG) != NULL) { - if (parse_uint(pair->key, pair->value, &blocksize, UINT_MAX) < 0) - return -1; - if (!blocksize) { - PMD_LOG(ERR, - "%s: invalid blocksize value", - name); + if (parse_uint(pair->key, pair->value, &blocksize, + 1, UINT_MAX) < 0) return -1; - } continue; } if (strstr(pair->key, ETH_AF_PACKET_FRAMESIZE_ARG) != NULL) { - if (parse_uint(pair->key, pair->value, &framesize, UINT_MAX) < 0) - return -1; - if (!framesize) { - PMD_LOG(ERR, - "%s: invalid framesize value", - name); + if (parse_uint(pair->key, pair->value, &framesize, + 1, UINT_MAX) < 0) return -1; - } continue; } if (strstr(pair->key, ETH_AF_PACKET_FRAMECOUNT_ARG) != NULL) { - if (parse_uint(pair->key, pair->value, &framecount, UINT_MAX) < 0) + if (parse_uint(pair->key, pair->value, &framecount, + 1, UINT_MAX) < 0) return -1; - if (!framecount) { - PMD_LOG(ERR, - "%s: invalid framecount value", - name); - return -1; - } continue; } if (strstr(pair->key, ETH_AF_PACKET_QDISC_BYPASS_ARG) != NULL) { - if (parse_uint(pair->key, pair->value, &qdisc_bypass, 1) < 0) + if (rte_kvargs_handle_bool(pair->key, pair->value, &qdisc_bypass) < 0) return -1; continue; } @@ -1327,7 +1286,7 @@ rte_eth_from_packet(struct rte_vdev_device *dev, continue; } if (strstr(pair->key, ETH_AF_PACKET_IGNORE_OUTGOING_ARG) != NULL) { - if (parse_uint(pair->key, pair->value, &ignore_outgoing, 1) < 0) + if (rte_kvargs_handle_bool(pair->key, pair->value, &ignore_outgoing) < 0) return -1; continue; } @@ -1357,7 +1316,7 @@ rte_eth_from_packet(struct rte_vdev_device *dev, PMD_LOG(DEBUG, "%s:\tfanout mode %s", name, fanout_mode); else PMD_LOG(DEBUG, "%s:\tfanout mode %s", name, "default PACKET_FANOUT_HASH"); - PMD_LOG(DEBUG, "%s:\tignore outgoing %u", name, ignore_outgoing); + PMD_LOG(DEBUG, "%s:\tignore outgoing %d", name, ignore_outgoing); if (rte_pmd_init_internals(dev, *sockfd, qpairs, blocksize, blockcount, -- 2.53.0