From patchwork Fri Sep 24 15:57:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 99636 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A6564A0548; Fri, 24 Sep 2021 17:58:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF2174132D; Fri, 24 Sep 2021 17:58:09 +0200 (CEST) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mails.dpdk.org (Postfix) with ESMTP id 14DAA4126F for ; Fri, 24 Sep 2021 17:58:07 +0200 (CEST) Received: by mail-wr1-f44.google.com with SMTP id t8so28971976wrq.4 for ; Fri, 24 Sep 2021 08:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zQqg3Lch3k/T4Zg+81jBH2E9oSejDv44UTZphrmjjbM=; b=UsNxEMTgpGdbuHr2Bg2OXerNAVQ9A+8eM01zIxN+Tb8UKcaqnfP4KM9NAUTUtd5ELB rRXbLetkaY6Vx4ZPbZLnYnMZA2aVvqLxb48AaCTgaQKLwTjQCpwTxeR4Xye513teLhBH 7HRWtqZkpNUBgEuMY8rTul12MWLXqyn5+M6/dUjRm+UmzZVsVLdInr00KCjQjbX3muM3 RhncneqohIIWcWeL2BTtSgd7fopvxcOs58q7veMylern0/PyNP3sb6+n64NYcyiXgoTZ Q6sSoeAe1wZlFS8z/SEjeQk/0azN0BLDtLJtbgiZ3wDt8OxXZZfKsI8WrImwEja1LIvG bJFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zQqg3Lch3k/T4Zg+81jBH2E9oSejDv44UTZphrmjjbM=; b=bZhHr+Rw0jaZLtF/dWeRN3AA5FtU9XXkyCKBuzcypwoYBjzKhXwv8kWBxU8WYpc+yT YOBctReqruDNnsOyEfFY1QCPL6Gy9ZvQoK0BdFllMasD9xX7vdZZ76+hWK1nZGAlBOvB 5igFdZOvUNJDYQaqI0S9lx+QmWZmqcRVu+sOrfk6oSftxCBKJBu5P6IGPNghpJSC0ou4 gcCfyCI0P8F1R+EPl379HiMbC0v13gxQtMD3TySgjd9H3wWtBWzudTNsnk8afdaUjqml p9/RASIUwf7cKC/wY5piQMJq42wnKXIu1F3tTkrvDwHTUXx6Z/yFGqN2zE0DyyZKql9h P0HA== X-Gm-Message-State: AOAM533KehHeKTisR90dfuZlp4J5anuZScmDVY2b+mUBM6mPquar0kHz LfpcQBMm48TulgI9W+s12eLf+T1lVfr1/g== X-Google-Smtp-Source: ABdhPJxk+9nO7ADo+Z2l+Jv7Ah/3WHVWOTpv2MCAhYLHlLTdwjJBLqPZ43fTtkPHc729PQ7HVw77Ug== X-Received: by 2002:adf:f890:: with SMTP id u16mr12155421wrp.388.1632499086817; Fri, 24 Sep 2021 08:58:06 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id a75sm9280829wmd.4.2021.09.24.08.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:58:06 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Fri, 24 Sep 2021 17:57:36 +0200 Message-Id: <20210924155740.20510-2-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210924155740.20510-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/5] kvargs: promote delimited parsing as stable 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 Sender: "dev" This function is used by EAL to parse key/value strings separated with specified delimiters. It was introduced in 2018 by commit 5d6af85ab00c ("kvargs: introduce a more flexible parsing function"), and can be promoted as stable. Signed-off-by: Olivier Matz --- lib/kvargs/rte_kvargs.h | 1 - lib/kvargs/version.map | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h index 12a8f90435..c30891c668 100644 --- a/lib/kvargs/rte_kvargs.h +++ b/lib/kvargs/rte_kvargs.h @@ -98,7 +98,6 @@ struct rte_kvargs *rte_kvargs_parse(const char *args, * - A pointer to an allocated rte_kvargs structure on success * - NULL on error */ -__rte_experimental struct rte_kvargs *rte_kvargs_parse_delim(const char *args, const char *const valid_keys[], const char *valid_ends); diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map index a07166b4d2..75b13fcb78 100644 --- a/lib/kvargs/version.map +++ b/lib/kvargs/version.map @@ -4,6 +4,7 @@ DPDK_22 { rte_kvargs_count; rte_kvargs_free; rte_kvargs_parse; + rte_kvargs_parse_delim; rte_kvargs_process; local: *; @@ -12,7 +13,6 @@ DPDK_22 { EXPERIMENTAL { global: - rte_kvargs_parse_delim; rte_kvargs_strcmp; # added in 21.05 From patchwork Fri Sep 24 15:57:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 99637 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EFD5BA0548; Fri, 24 Sep 2021 17:58:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1EB141336; Fri, 24 Sep 2021 17:58:10 +0200 (CEST) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mails.dpdk.org (Postfix) with ESMTP id EB24A4126F for ; Fri, 24 Sep 2021 17:58:07 +0200 (CEST) Received: by mail-wr1-f44.google.com with SMTP id w17so28817847wrv.10 for ; Fri, 24 Sep 2021 08:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sIhq580+8vSbeKd1EAFqX6ngK8O9IRg3IZMhWwG/8pA=; b=ADRfuN/bo/FegCPvl7fOd9JdayJELLRxvf2O9fAEJDbsLcGHF1He8Isn/SuZM02P+F tG597wVG7UcZCMGJstderAa6Ne/Wy6xdRmWycWnVUg50VT1T1eJ4RiVPa44kzmKKKnGL ZkuDTytw45bO8ZKu1zchXHNNmfigAF2Z0R3+me1iNJoaGr9k5+nA1TO+Uhcoeb+w9Mdw IMIaK1hS+fXoEwttTwZ79rFrkreb9QTUbyBYE5WlSqQI93uoj5UR7Ia22dEdceeTH0Ob M9QmEqfagsqNf+bD/R7mUGC9FD8Ux+lchica+ODAvDAexoyQtUKfJLfJ8vrnHCQonlD5 D5oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sIhq580+8vSbeKd1EAFqX6ngK8O9IRg3IZMhWwG/8pA=; b=l55K8+Q9B9pBrN7BxcdMI3IeJM0XvykD68Qt48ce2R16xX735tW7fw6fOkX1wCupSY W3rfV0EGArpvUXlzJT2HPMbjF31oToLs4gRPjlUeoFcNHdLbOmteP5CsJofxpyQhQKno Y8NlqAUA6QUtKB/u5XIjN5IxioeBINoRpYz+4UbQGZFtRcCa/4V1CV/7QihycqNdZGcY NRZF88/p0BzjDHY0RP7/CLhVtonMCEwHwLaeLBSIXqsYXcU6zIv2W6tUL4Acpi2sneZL WrNbagbWZO0pSkBJ5zt4iBViShf4ZDOCtqecesyHgROgczh+A4OncZAkynNND8vn3UTq tLbg== X-Gm-Message-State: AOAM530Ed0hUsVam2LV4PN4tzD3bdBJrwmLGUZsZtc5knZe7InO50i2V 1Iw8BF2yHYUsNvjZUFoy10Wk/MPt260nuA== X-Google-Smtp-Source: ABdhPJxe3OaKLi10PxO3w6kK29aRVdWo5ZnkIi8HkEWTSR7hTiAb1uPKF/d+brIS8tsYoT2pPqMa1g== X-Received: by 2002:a05:6000:1b8d:: with SMTP id r13mr12825525wru.230.1632499087762; Fri, 24 Sep 2021 08:58:07 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id a75sm9280829wmd.4.2021.09.24.08.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:58:07 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Fri, 24 Sep 2021 17:57:37 +0200 Message-Id: <20210924155740.20510-3-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210924155740.20510-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/5] kvargs: promote get from key as stable 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 Sender: "dev" The function rte_kvargs_get() is used by eal and pci bus driver since its introduction in commit 3ab385063cb9 ("kvargs: add get by key") and commit d2a66ad79480 ("bus: add device arguments name parsing"), in dpdk 21.05. Let's promote it as stable. Signed-off-by: Olivier Matz --- lib/kvargs/rte_kvargs.h | 1 - lib/kvargs/version.map | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h index c30891c668..328f0d3cc6 100644 --- a/lib/kvargs/rte_kvargs.h +++ b/lib/kvargs/rte_kvargs.h @@ -130,7 +130,6 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); * NULL if no key matches the input, * a value associated with a matching key otherwise. */ -__rte_experimental const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key); /** diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map index 75b13fcb78..236f35c02b 100644 --- a/lib/kvargs/version.map +++ b/lib/kvargs/version.map @@ -3,6 +3,7 @@ DPDK_22 { rte_kvargs_count; rte_kvargs_free; + rte_kvargs_get; rte_kvargs_parse; rte_kvargs_parse_delim; rte_kvargs_process; @@ -15,6 +16,4 @@ EXPERIMENTAL { rte_kvargs_strcmp; - # added in 21.05 - rte_kvargs_get; }; From patchwork Fri Sep 24 15:57:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 99638 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 043DBA0548; Fri, 24 Sep 2021 17:58:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3E1541340; Fri, 24 Sep 2021 17:58:11 +0200 (CEST) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mails.dpdk.org (Postfix) with ESMTP id C726B41329 for ; Fri, 24 Sep 2021 17:58:08 +0200 (CEST) Received: by mail-wr1-f51.google.com with SMTP id t8so28972228wrq.4 for ; Fri, 24 Sep 2021 08:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mG4OZqEBoW7KZ2M7s7ssYRmQvKyO3lGkA6SRDKo6ft0=; b=fbxWlUKYeU6HA49+hQobP0J2hcUV3xOaHQoYOjJRMo8Emfi8UsxjuwaFcl6DCsRD/+ 8aeH86hyELUwQiJUZK5mBgaq0ywXsbYJGDl2nTWO71v5hqnNtdkwNjF0GsXrl+X9qb7o TYRFplWeHXz/N83auuKHa7lFTJTf9K/1xqvM8STl0uB1zz1r9m1Xeb7ZBDQqpxd4ye7P ySxyHYLIe3dGh+casZ8kaNCn90HWcBsV3h2end0GNBPj9wop166LCgRpi8rl6VTbRXJ+ 0m9rtzowZj01D3JqHjOwsbiFv4G4wO5IRI9CJ0xLJY9VZCdnFCm36xWbNNCd2UmegbSY 52XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mG4OZqEBoW7KZ2M7s7ssYRmQvKyO3lGkA6SRDKo6ft0=; b=KcW/6vi0LwJmgMqvofvAf4Yx3nEnfBW3jw7NSsu2EU24IGHCqxburkNOzqXUTuVnLa tLZuQ5+FM3BYGv2KpJtLc/15fSnP9/NYVv6hCi2ZznYmT3laygjIUui0z/ueNaqWvwuZ w6nCzMhKWOsdaDZgbC/bWOT296hkpE94TDcQ+jyp8GL8pJ5mUOIuiUQ1F0egKbkFU4c8 7WloGQnz6dmS4FYCCovdMj3cRYMC5ouyQwxrkbNpZ66q82V8q1p1Bd2WJzocbjmCnCTx tPV127KSuw0uQYcKlAhdKj4ZA20+WPuQdudVUHXsWZCuWdEmyrn97H3uw0souN0sQ7ZP MVTg== X-Gm-Message-State: AOAM533B3dwDLgdEDNhs88wVcjV1Y1GVhmNn9DmEcVNcfGeH3KCVZaqt hDJd0QC6/R9zaS3qnJ5esLbrpCMkzQBPmA== X-Google-Smtp-Source: ABdhPJzNLJf62OA7W33G7X7uAlyiUcor+i7TQyUVCsSYsHVUjKLK6W88a7kn+xzGeVQjq/3sFn6RCQ== X-Received: by 2002:adf:f4c6:: with SMTP id h6mr1720823wrp.397.1632499088530; Fri, 24 Sep 2021 08:58:08 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id a75sm9280829wmd.4.2021.09.24.08.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:58:08 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Fri, 24 Sep 2021 17:57:38 +0200 Message-Id: <20210924155740.20510-4-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210924155740.20510-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/5] kvargs: new function to get from key and value 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 Sender: "dev" A quite common scenario with kvargs is to lookup for a = in a kvlist. For instance, check if name=foo is present in name=toto,name=foo,name=bar. This is currently done in drivers/bus with rte_kvargs_process() + the rte_kvargs_strcmp() handler. This approach is not straightforward, and can be replaced by this new function. Signed-off-by: Olivier Matz --- drivers/bus/auxiliary/auxiliary_params.c | 9 ++++---- drivers/bus/vdev/vdev_params.c | 13 ++--------- lib/kvargs/rte_kvargs.c | 23 +++++++++++++++---- lib/kvargs/rte_kvargs.h | 29 +++++++++++++++++++++++- lib/kvargs/version.map | 2 ++ 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/drivers/bus/auxiliary/auxiliary_params.c b/drivers/bus/auxiliary/auxiliary_params.c index cd3fa56cb4..a9c7853ed1 100644 --- a/drivers/bus/auxiliary/auxiliary_params.c +++ b/drivers/bus/auxiliary/auxiliary_params.c @@ -25,13 +25,12 @@ auxiliary_dev_match(const struct rte_device *dev, const void *_kvlist) { const struct rte_kvargs *kvlist = _kvlist; - int ret; + const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME]; - ret = rte_kvargs_process(kvlist, - auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME], - rte_kvargs_strcmp, (void *)(uintptr_t)dev->name); + if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL) + return -1; - return ret != 0 ? -1 : 0; + return 0; } void * diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index 6f74704d1c..37d95395e7 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -26,19 +26,10 @@ static int vdev_dev_match(const struct rte_device *dev, const void *_kvlist) { - int ret; const struct rte_kvargs *kvlist = _kvlist; - char *name; + const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME]; - /* cannot pass const dev->name to rte_kvargs_process() */ - name = strdup(dev->name); - if (name == NULL) - return -1; - ret = rte_kvargs_process(kvlist, - vdev_params_keys[RTE_VDEV_PARAM_NAME], - rte_kvargs_strcmp, name); - free(name); - if (ret != 0) + if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL) return -1; return 0; diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c index 38e9d5c1ca..20abb23183 100644 --- a/lib/kvargs/rte_kvargs.c +++ b/lib/kvargs/rte_kvargs.c @@ -204,21 +204,34 @@ rte_kvargs_free(struct rte_kvargs *kvlist) free(kvlist); } -/* Lookup a value in an rte_kvargs list by its key. */ +/* Lookup a value in an rte_kvargs list by its key and value. */ const char * -rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key) +rte_kvargs_get_with_value(const struct rte_kvargs *kvlist, const char *key, + const char *value) { unsigned int i; - if (kvlist == NULL || key == NULL) + if (kvlist == NULL) return NULL; for (i = 0; i < kvlist->count; ++i) { - if (strcmp(kvlist->pairs[i].key, key) == 0) - return kvlist->pairs[i].value; + if (key != NULL && strcmp(kvlist->pairs[i].key, key) != 0) + continue; + if (value != NULL && strcmp(kvlist->pairs[i].value, value) != 0) + continue; + return kvlist->pairs[i].value; } return NULL; } +/* Lookup a value in an rte_kvargs list by its key. */ +const char * +rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key) +{ + if (kvlist == NULL || key == NULL) + return NULL; + return rte_kvargs_get_with_value(kvlist, key, NULL); +} + /* * Parse the arguments "key=value,key=value,..." string and return * an allocated structure that contains a key/value list. Also diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h index 328f0d3cc6..e40df1bd2a 100644 --- a/lib/kvargs/rte_kvargs.h +++ b/lib/kvargs/rte_kvargs.h @@ -116,7 +116,7 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); /** * Get the value associated with a given key. * - * If multiple key matches, the value of the first one is returned. + * If multiple keys match, the value of the first one is returned. * * The memory returned is allocated as part of the rte_kvargs structure, * it must never be modified. @@ -132,6 +132,33 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); */ const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get the value associated with a given key and value. + * + * Find the first entry in the kvlist whose key and value match the + * ones passed as argument. + * + * The memory returned is allocated as part of the rte_kvargs structure, + * it must never be modified. + * + * @param kvlist + * A list of rte_kvargs pair of 'key=value'. + * @param key + * The matching key. If NULL, any key will match. + * @param value + * The matching value. If NULL, any value will match. + * + * @return + * NULL if no key matches the input, + * a value associated with a matching key otherwise. + */ +__rte_experimental +const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist, + const char *key, const char *value); + /** * Call a handler function for each key/value matching the key * diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map index 236f35c02b..82879b7140 100644 --- a/lib/kvargs/version.map +++ b/lib/kvargs/version.map @@ -16,4 +16,6 @@ EXPERIMENTAL { rte_kvargs_strcmp; + # added in 21.11 + rte_kvargs_get_with_value; }; From patchwork Fri Sep 24 15:57:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 99639 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B5736A0548; Fri, 24 Sep 2021 17:58:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8239F41356; Fri, 24 Sep 2021 17:58:13 +0200 (CEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mails.dpdk.org (Postfix) with ESMTP id 75ACE4132B for ; Fri, 24 Sep 2021 17:58:09 +0200 (CEST) Received: by mail-wr1-f49.google.com with SMTP id r23so3567281wra.6 for ; Fri, 24 Sep 2021 08:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H9CfQdlzO2MAaTjpsalAe97t1CMRfElsAxkb3P1z/BU=; b=WfokmZFBPlTo9NYwGLE8xzCH8FAFomjEHjVlg7P5JQZb2NmZTd7IRQX/JDCcsUAasf 5QsCnU5t3VslodmmiXypiN49ymp+0NyhbgmVwIfewL9M9O89m/LXIaByKfnONhgbtMw8 oidebeCeX9TpaIr1DtPV0xyNL8v7IwnBXGdt7SS/N3WP5L2VGV9zQqFE4LDj/yaQKTHA WTgwxMQ8MgU9Gvikw9Ho3PXLdU5WPzYk0vCJ3if3XRlItf/cTTMalnLkxOHdBLOAaVTl 8VXHZKt57+XqfF4WG+NFPqYX027juwTrP5bzgaOH0q3xZroQrmZxwU4x6oVV9Dn94TNM gjHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H9CfQdlzO2MAaTjpsalAe97t1CMRfElsAxkb3P1z/BU=; b=6TpOkbUSKnmYmP7iExSNiGmNBispJv/gRUArcAxgCavWLX73UDTR9gWbL/lm5FQjDK cgheioZ9w+sp5xyUE/aWjNa9gDiJSNHGvsiFkPUKUmKXNKJG1Sh55cb2oEueHzdEpk05 gLop8r9wteOvDMQUzXuUA5HHS0aGWuh59ZmFVQs+IlDHG25LA8v92p1Pg8eDp6hYEnrj g4QtBuKpehgNsYo8ajNRJ+R5t9VgHZCcGpMWqQ4xw3dPPMJ7M1eXyGG8d+K+7XD7omWk Fb5H403x8fFDKfoWjUO845s9wftwVH7opNNepb706SM7CNnLZMYrIEwncgGFpeCzh+tc dIfg== X-Gm-Message-State: AOAM531aTJ5/8UemD24allSKw/JcR7ZF90V7lyngo3zYEL99Rg50YxZK v08yv8gvy23rhbGJY/UrajthjSLUHYyH4g== X-Google-Smtp-Source: ABdhPJxzz88VB3QT4pD1mnktNFgrrLkDiKKbWjMnDOPjaXdyOJGHMQxMZl2bewuiNMlBnhcrJu2liw== X-Received: by 2002:a05:600c:499a:: with SMTP id h26mr2814526wmp.164.1632499089301; Fri, 24 Sep 2021 08:58:09 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id a75sm9280829wmd.4.2021.09.24.08.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:58:08 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Fri, 24 Sep 2021 17:57:39 +0200 Message-Id: <20210924155740.20510-5-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210924155740.20510-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 4/5] kvargs: remove experimental function to compare string 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 Sender: "dev" The function was designed to be used as a handler for rte_kvargs_process() to compare the value string in a kvlist. For readability, its usages in DPDK have been replaced by rte_kvargs_get_with_value() in previous commit. Remove this function, as it is not used anymore. Signed-off-by: Olivier Matz --- lib/kvargs/rte_kvargs.c | 9 --------- lib/kvargs/rte_kvargs.h | 26 -------------------------- 2 files changed, 35 deletions(-) diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c index 20abb23183..11f624ef14 100644 --- a/lib/kvargs/rte_kvargs.c +++ b/lib/kvargs/rte_kvargs.c @@ -283,12 +283,3 @@ rte_kvargs_parse_delim(const char *args, const char * const valid_keys[], free(copy); return kvlist; } - -int -rte_kvargs_strcmp(const char *key __rte_unused, - const char *value, void *opaque) -{ - const char *str = opaque; - - return -abs(strcmp(str, value)); -} diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h index e40df1bd2a..3c1754c3d9 100644 --- a/lib/kvargs/rte_kvargs.h +++ b/lib/kvargs/rte_kvargs.h @@ -197,32 +197,6 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist, unsigned rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match); -/** - * Generic kvarg handler for string comparison. - * - * This function can be used for a generic string comparison processing - * on a list of kvargs. - * - * @param key - * kvarg pair key. - * - * @param value - * kvarg pair value. - * - * @param opaque - * Opaque pointer to a string. - * - * @return - * 0 if the strings match. - * !0 otherwise or on error. - * - * Unlike strcmp, comparison ordering is not kept. - * In order for rte_kvargs_process to stop processing on match error, - * a negative value is returned even if strcmp had returned a positive one. - */ -__rte_experimental -int rte_kvargs_strcmp(const char *key, const char *value, void *opaque); - #ifdef __cplusplus } #endif From patchwork Fri Sep 24 15:57:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 99640 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1358FA0548; Fri, 24 Sep 2021 17:58:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95E844135D; Fri, 24 Sep 2021 17:58:14 +0200 (CEST) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by mails.dpdk.org (Postfix) with ESMTP id 4247641332 for ; Fri, 24 Sep 2021 17:58:10 +0200 (CEST) Received: by mail-wr1-f54.google.com with SMTP id t28so15509282wra.7 for ; Fri, 24 Sep 2021 08:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nf3KdNb6gA+ZuvmDV+TD2jtcEHZSaknKNTRdxkOv9tQ=; b=Q6ysYMnCwb7LhRzepMIlWcEaEnPE4g2h+67nkgp1z1EHY6oh4bgBermEiNrA7/zJ1l kJaa34Gky/nFuspw+M1U0da794EO60JAggoQ4P21MCOZdTZClbvrcPAQFvpoPN60DdqN 3/CqTz/kdlpgZOmw0t1/ef/kgMJw7Tzi6ePcVK81BO2CZpMwkYRNg9LFyvzBm0pG1Zfy 8j7ha1r41bk/0K5FLclylBbdan6ev1YQZt7KN1Gc+IKHWoa5KDxh1F9OOc3bAsbhxgqr pWxu2MeWaAwMeZUIHK/i7DWhbr0ibJrKrz0Z9Hh5dH3ab/cgFnwCDMu8s+LikfoLt0rX jntw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nf3KdNb6gA+ZuvmDV+TD2jtcEHZSaknKNTRdxkOv9tQ=; b=Oc9K2vqbrzfvahc04xQdZMmxX9SVVnuR9pGbmg3IeMdWR769vZzQeriCsf66lteX3G Hdn2ZsYlL51ZdmevqjfYvOoFRoZ2HNX7RUcAamrPxp86NN4h8fyWCMAwjy1V2fZxApK6 ITFT/FD+zK9OkKIPFdZW3yv1fpPAeNntHX8dtb7W75JCSVGEUIgK6z5YlKQg2zAYRIEU xuwrGGiY6dNdiIlE7YpeDpNzyMt0+BAIMTbo7p2x4v+X/sirjC3NUC5DHJI8OaPJzowe PSUGOE6TAhmpjO1+sLF8y3iKsa+weLzRs0ep7kYJ5bBM6fKE0Ej3SaulYqmn6YII+LWs L0vQ== X-Gm-Message-State: AOAM532PgYy1JnDXbyeL/iTMnrbCTNE/YUwWtwdw5qEl/j9/GbMdGf/S g1ke+7tFl2C7yv9P4jqb10phBCjI3OQf6A== X-Google-Smtp-Source: ABdhPJzG+SaUoTynwNZfcsjmaYvGXchUZToaCC3U1lFsi7e/QV9ATG3qz2yi70s5MjJk14NT78rs7w== X-Received: by 2002:a05:600c:4f95:: with SMTP id n21mr2919590wmq.22.1632499090062; Fri, 24 Sep 2021 08:58:10 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id a75sm9280829wmd.4.2021.09.24.08.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:58:09 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Fri, 24 Sep 2021 17:57:40 +0200 Message-Id: <20210924155740.20510-6-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210924155740.20510-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/5] kvargs: fix comments style 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 Sender: "dev" A '*' is missing at 2 places, add them. Fixes: e1a00536c8ed ("kvargs: add a new library to parse key/value arguments") Fixes: 3ab385063cb9 ("kvargs: add get by key") Signed-off-by: Olivier Matz --- lib/kvargs/rte_kvargs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h index 3c1754c3d9..359a9f5b09 100644 --- a/lib/kvargs/rte_kvargs.h +++ b/lib/kvargs/rte_kvargs.h @@ -125,7 +125,7 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); * A list of rte_kvargs pair of 'key=value'. * @param key * The matching key. - + * * @return * NULL if no key matches the input, * a value associated with a matching key otherwise. @@ -190,7 +190,7 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist, * The rte_kvargs structure * @param key_match * The key that should match, or NULL to count all associations - + * * @return * The number of entries */