From patchwork Wed Sep 29 21:39: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: 100033 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 8B773A0032; Wed, 29 Sep 2021 23:40:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB2A7410F7; Wed, 29 Sep 2021 23:40:06 +0200 (CEST) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mails.dpdk.org (Postfix) with ESMTP id 76B2A410EC for ; Wed, 29 Sep 2021 23:40:04 +0200 (CEST) Received: by mail-wm1-f43.google.com with SMTP id o19so2955791wms.1 for ; Wed, 29 Sep 2021 14:40:04 -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=pL58UCVX14VYolIRZgb+9n8Gc+JrPjWD73F8fEloVtM=; b=cFae/Gkwfrb8xyHVjjG4PoSeYLfk4AW97OJKdNOTbU02bhiHJW5Jxnf0fze8+6Fjqj TV4k4hjXYgi5uEHUDAHNd/kDMNFPrQWMl3GG68pDoB/Uy1hyDB5aNY5GQ0rLphvGwhZZ 5F38/m1GiFoFMThCSj5YyjFqjiJgu5URDHQjWTd/IC+7dCJcBfL9ceOMQ0ej2sXsv45t 252P5G27ZBlci/3kU5UxaHsS1Lkog5QEc3/5pEiwmicJg9DRDU49UGyaPrRSkiN/KIRp U94f6L8ejbp+jWk5N5lpqZqRq889jzZfJLRN0a6TFZyy5OzD9Odnq4UvQjzIf2RqUU8n 7ysA== 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=pL58UCVX14VYolIRZgb+9n8Gc+JrPjWD73F8fEloVtM=; b=qwel04andmHuS28lyRv4tzpHyJMuP5M4xflALLyn1K+YuUl4fMSr5Jip+OKK1b9dc/ F/HLrsoTzcRY45762saHD2vr6VnNXSp1dFqXQfYFLM7i0XRolijjyELeetU1HIJQKXg5 f07sv+J6sn0uKa1hYZbM8P7xf/FMXbgDWsaBfv+hD6Amie1YbPWmQekDvkvd07TcPjdK 5KRwtIybjYpXE96yNr6l01KKKEpLDVH8tq+hd9usqbZ3rTGAz778DB7uG2e6SiIu0PRv CXV/tn6liAAaTyscJ6WcTO6m40z+PmSNtfw4L6alZX/Ks5cx1CL4hRTqXQQOw8dpMag8 hdBA== X-Gm-Message-State: AOAM531QH8au3SKS1nUXhbIF5NL345mHxYvey6M45vPW6bfG7NPXY5WY mSU8zHYu/AaSd6br6ZrtA+YH4A28zlaT2Q== X-Google-Smtp-Source: ABdhPJwk+IbyqCssQVUVuqMrew7MccxduNE6pNGpKaljPIQw2X/9E/HnBh7ViSeNsv4Clz3U4JgXZA== X-Received: by 2002:a05:600c:41d6:: with SMTP id t22mr2171616wmh.59.1632951604241; Wed, 29 Sep 2021 14:40:04 -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 o19sm1079743wrg.60.2021.09.29.14.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 14:40:03 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Wed, 29 Sep 2021 23:39:39 +0200 Message-Id: <20210929213943.17817-2-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929213943.17817-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> <20210929213943.17817-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Reviewed-by: Xueming Li --- 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 Wed Sep 29 21:39: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: 100034 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 E5B00A0032; Wed, 29 Sep 2021 23:40:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47CC6410FF; Wed, 29 Sep 2021 23:40:10 +0200 (CEST) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mails.dpdk.org (Postfix) with ESMTP id 45412410EC for ; Wed, 29 Sep 2021 23:40:05 +0200 (CEST) Received: by mail-wm1-f50.google.com with SMTP id v127so2918622wme.5 for ; Wed, 29 Sep 2021 14:40:05 -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=ynmeEw6WF4qftXwSGhn/FtdlHGBVqZLYwcIbEpAixKA=; b=QeSUqoqmR0EBbIDJd2M5Av9Z+SybqsuGD1Dk0joyZ4HSCqLgYKbc6qdIfaC2+DZgzx zr+npR4R+8qTHG4RwVyYxbP8cBGqiuQqPd+HYUczDtKRWjkYG3s3+EGVg66Uby52YJ+t LBb29/MHc5MXHWl5RfxAe90W9nVCfLIIYgOqte0kuOVOc6+kZzSLHyH+PTrnalWPkPYC 5p3C+8Xroca2TplM7E9aw0QMYg4Oe6SDtruH1skU5flk2kln9BMn1kpCNfCjCqPa51lI 8TOp62gNPBzTepgEjkpGfteuA032NltJiCE7/oQqHdOutfkGGjMBL1gI+cnAAip8JGyi xiKA== 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=ynmeEw6WF4qftXwSGhn/FtdlHGBVqZLYwcIbEpAixKA=; b=YeldTASoCGOpAh1wiGLQgBr9t3jrrI5EshttFYnCmhGhxa1fJF5+NXWo5xKfR2G3Pp csebLAH6vbMB4a3970T8AWW4dS8Om2daabN3qupXq1+JCUkjqWhQcK8GfBlJiXTaU798 IAkift4WRui/DygX8CAEHVpaGEBCyZD5hbGOlB/E+/WgDJXc42usTrLA73ikULV1Cwt8 VjIFD3xIK8tGsJan3AEQlMfw5ds93zagRcv0nKm4gafPsLO1C4kD/G3iF6nD42IoOVBc G7QwnNY1DoLxJVU8mMEW4ytebjkuzLQTvOt98I5B2zsZmUbkdhqGpXe0jmdOaptrJdka jAfA== X-Gm-Message-State: AOAM533oiEeiKIu4JGwczzDi2W3q6lpDZC+ElICmGWL/r5FCwa1oVI6f +iq7CdwNtD+R+SdfGGTJ+37BVknotUeC2g== X-Google-Smtp-Source: ABdhPJxBjTA4mA7VbNsxaGfm6MZZUQ5SqW3l+tugirnz5CFKdA/9h3+XMrkVSR8PC6SQkR/dyJ4aNA== X-Received: by 2002:a1c:4e0d:: with SMTP id g13mr12501732wmh.42.1632951605017; Wed, 29 Sep 2021 14:40:05 -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 o19sm1079743wrg.60.2021.09.29.14.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 14:40:04 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Wed, 29 Sep 2021 23:39:40 +0200 Message-Id: <20210929213943.17817-3-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929213943.17817-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> <20210929213943.17817-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Reviewed-by: Xueming Li --- 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 Wed Sep 29 21:39:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 100035 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 9A854A0032; Wed, 29 Sep 2021 23:40:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51EDD410F0; Wed, 29 Sep 2021 23:40:11 +0200 (CEST) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mails.dpdk.org (Postfix) with ESMTP id 12021410F2 for ; Wed, 29 Sep 2021 23:40:06 +0200 (CEST) Received: by mail-wm1-f41.google.com with SMTP id j27so2966627wms.0 for ; Wed, 29 Sep 2021 14:40:06 -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=qXKA7hBgJPdrYfOCcAdOOtanDoOf3WmmEVZubd/adjY=; b=G2olN1tIGofVXNBs9A5spKEmj0BD/HWI9aesJhhe8KesxiHm6SCXppriIQuYfWSd1x mGWjMYUIYuPvP31pkUmHXIPuIMqZlyaHmSzh63uOIobUDe2rfZ5lr4hCuQiUdilkLh0j 9OF0vpBKfEo+Qjza+ZyNQGdoZtr8N4MKsG2whFtFpOG48miRiOaGNNDPzpHEGy1Z1xEe OSBQ44O66gWmtXpiMaMlFSe0SURkMxB5sJMjSg1boW/fE1nveUM6Qls+5VQTB0Z5JqSf e0Tgr1J52v9twR43eVTrWSAwEwbdfc57JJ9QYs3RjQCk86nxfQHVdkoAFJA46xXFthMP xLjg== 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=qXKA7hBgJPdrYfOCcAdOOtanDoOf3WmmEVZubd/adjY=; b=q0yZCO+zGQBF4F2fUZkZmLF3vSBWFVxKZOAt8+aglKOGTASNYYDC0Z4glFbJLwrvrL B3KK7aCDvdQxDnUdi85Gedk3I2YHClKFHBVuYkFp9/Z3aE8Qicvqn+aMD1RacFPg2HE2 0dqFYkv0Hdj4KUGgR9XKVCcWRmhFw7tbm+dA7QjZklcH/oGNlQzZg5be+xCWaxLGoE7u Yw9R4tmxOdzWvtR64N1FXB73f2iC5JQqa6A0f4BRx7YUwVWUhANH9zVUAh7y8/pgIIFO 4yiDm4uy//izWCC7/zauLeSiEoZg7NKcgTkkNwCB46qe7eqE+SonWvcVQC5Xn/Ov/aYv adxw== X-Gm-Message-State: AOAM530WczJNdyjdVyrfcDPPu2E26w58XEQftB70DDRkX9xQefmU/++z 8lauCccyCg4OCz6eEPQK/bHUMSeSdAuSEQ== X-Google-Smtp-Source: ABdhPJzcEIpVOyzt2Qo/MUiEK44oLnmly2DVfSIhLESwcmzoE6zqSGGPdNJR8WvWqigm04DNlmGR4A== X-Received: by 2002:a05:600c:4fc7:: with SMTP id o7mr12839356wmq.91.1632951605793; Wed, 29 Sep 2021 14:40:05 -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 o19sm1079743wrg.60.2021.09.29.14.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 14:40:05 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Wed, 29 Sep 2021 23:39:41 +0200 Message-Id: <20210929213943.17817-4-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929213943.17817-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> <20210929213943.17817-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Reviewed-by: Xueming Li --- 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 Wed Sep 29 21:39:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 100036 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 37DD7A0032; Wed, 29 Sep 2021 23:40:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 533804111F; Wed, 29 Sep 2021 23:40:12 +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 AFACC410F2 for ; Wed, 29 Sep 2021 23:40:06 +0200 (CEST) Received: by mail-wr1-f51.google.com with SMTP id d6so6509189wrc.11 for ; Wed, 29 Sep 2021 14:40:06 -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=yh0oVJn13XE2wUoqp8T0trW+xdSBLudc5er4oxGWPjc=; b=G3jHG5Ukqm7JN6JomANp6DcIWN6Ka8KX2G7bVNwl7sxv4Lz11lHUFo4Ya4zchHRID2 5qd75HtrLurrnq7TeX6XjjSngWt1yi9M+FRTT3qYqwkcpPXYOR//34KbF1AS+YuU1fqQ 1/9ZLNgl7Ohskb71ZcbeAoiIusU0s/wqg1jcnChNnKUPEKZj/rWSVwyuztj0yWO7zZMR OTei8qcCVjflEzHG2QmZmJIiKlOzkaUfp9n/VqigVz8lyNffGafC242UG3dkbbY80Ev5 B6udnSUyQpmHPDVh4e8vnF2m/Zg3xzLF4g9UZvr+h17Gw/1iPvt2maSv+kuBwVzFLAhN n2IA== 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=yh0oVJn13XE2wUoqp8T0trW+xdSBLudc5er4oxGWPjc=; b=mMBAgSaRW7Vu98tLkkrWGNfQMP953uY5kscy2E8qckk5iG/volJjoC/AyGUATOy9sB g2zozlX4D4L0+ZxrAHJq8JAHk5aoisBbgNCiCv8QCQ5U9hJx9I1I4iwHOR3Ab8h4PqRe lhkbf7wn4eYFaGIeiHv0Q0zc701mk+z2blqPXhrSLMlugtsPN+y+DlcLFlda+jAbpSng hhiAtJaKjPbuJBYnvst65C+/TuBlncmUFgWx8YAND2S3f9j2b8ggCa8XHEdoC0sT/06k vuS3QVgCzC1H6QtI4jzCwHWeD6d1pmnYFcDuys2qaNrkcdtnuL/BgfDI0V+qxUHV9G+U 6fwg== X-Gm-Message-State: AOAM531FG0zeR9p3Pt1HYXE6MHlsOAli3FZUi3UciHU7KYl2LU8rrp0J eO9j9nPye7jsnNhK+FtcvXJkOLe8w6w0Uw== X-Google-Smtp-Source: ABdhPJyLMUgXjjxs9eFjVbqJ+jXKyjSOeIOL3utf71ORfuNW05kgZrmdMzBebpP2QJdvrclVxZzqvQ== X-Received: by 2002:a05:6000:2c6:: with SMTP id o6mr2504655wry.292.1632951606494; Wed, 29 Sep 2021 14:40: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 o19sm1079743wrg.60.2021.09.29.14.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 14:40:06 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Wed, 29 Sep 2021 23:39:42 +0200 Message-Id: <20210929213943.17817-5-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929213943.17817-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> <20210929213943.17817-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Reviewed-by: Xueming Li --- lib/kvargs/rte_kvargs.c | 9 --------- lib/kvargs/rte_kvargs.h | 26 -------------------------- lib/kvargs/version.map | 2 -- 3 files changed, 37 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 diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map index 82879b7140..0d42cd58a8 100644 --- a/lib/kvargs/version.map +++ b/lib/kvargs/version.map @@ -14,8 +14,6 @@ DPDK_22 { EXPERIMENTAL { global: - rte_kvargs_strcmp; - # added in 21.11 rte_kvargs_get_with_value; }; From patchwork Wed Sep 29 21:39:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 100037 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 059EAA0032; Wed, 29 Sep 2021 23:40:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 698E041130; Wed, 29 Sep 2021 23:40:13 +0200 (CEST) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mails.dpdk.org (Postfix) with ESMTP id 676D3410FC for ; Wed, 29 Sep 2021 23:40:07 +0200 (CEST) Received: by mail-wm1-f52.google.com with SMTP id v127so2918709wme.5 for ; Wed, 29 Sep 2021 14:40: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=BqF7NtSTNeZc5HC3yFCpzQJJQAgZ8QxOvlnm5nM1FJk=; b=AbjXJk6hj7RgcEOsVP7DljnHO35JddINURoSnPffJvyfqFl2WDlBYdP2pbZAGzXZrr M/qtIXeahyySIMGmnYA0jX/1RHzzDWZSP+O4nsq+d04O5I18aC0akfga1NVWtDDGM9hy XTOww1DYCa1wPsOhWLlE9DT5QdO4Rl3jM0ok5njAqFY2DKbUcSoo2Hm6uWBAkF+96BCA XqbPSZOGNpUMo+p/KfGoSo3F7aN2l5NcjOQ0AS38XQ0HHemh5DBoiKEbDvFQywYkCjeP QmPpyYdlBMunVMfOjFsNX1RfiN9ucF/sup/lW5FRWUuBDtQy6MuxW1boY8i6/Mb62jmu eg5w== 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=BqF7NtSTNeZc5HC3yFCpzQJJQAgZ8QxOvlnm5nM1FJk=; b=UkkrbJrWkn/qE13sP+dP65kTh3Ezhsk+5QYnM+Ths8H/HZTE5aC5zqzyxooHff+ZmQ wuO9wdeDM2cwQumPKosqcmBHkARiH+ZOQznUj0T/B0zyV6L7MYch6ZiRPElfvCmaWyeR nK3tDc9bdkzV+gh1znH6WRJiy3GOuUq7V1cui72qWwgdbhDwb+0j3QgeD8swx3gzhd2V xocwTkC97PkCk3nHEUY5zQu1fKO1QP+hVotogklgDB+vxXIt6tcuhkdtA+uhLPAuyyUB FL8ijcoGiC6vs85ZveKehya049jApLXy3vL5NbfXdeLnRFlCNHLEM1sHaXNNmrxw2sr3 zuxg== X-Gm-Message-State: AOAM5329KAXvCjSlIFrtxZ4oTzjb+NVGmEP82Idti0HxBwzFKiNb136Z 9PhB9hBs6NhbZhzqRCLbUEcSpwNCqQFi5g== X-Google-Smtp-Source: ABdhPJx1qofPUXs4OtM15M88E5xmxO92HEJpDSyyrpwIXfymlbSXRDk2rk9BmlszGut2k64ywpu2Dw== X-Received: by 2002:a05:600c:2d45:: with SMTP id a5mr2159414wmg.39.1632951607185; Wed, 29 Sep 2021 14:40: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 o19sm1079743wrg.60.2021.09.29.14.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 14:40:06 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , Xueming Li , Gaetan Rivet , Ray Kinsella Date: Wed, 29 Sep 2021 23:39:43 +0200 Message-Id: <20210929213943.17817-6-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929213943.17817-1-olivier.matz@6wind.com> References: <20210924155740.20510-1-olivier.matz@6wind.com> <20210929213943.17817-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Reviewed-by: Xueming Li --- 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 */