From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id E71FF1DB8 for ; Mon, 8 Oct 2018 08:47:25 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 75A37B00060; Mon, 8 Oct 2018 06:47:24 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 8 Oct 2018 07:47:18 +0100 To: Thomas Monjalon , CC: , , References: <20181007222554.4886-1-thomas@monjalon.net> <20181007222554.4886-2-thomas@monjalon.net> From: Andrew Rybchenko Message-ID: Date: Mon, 8 Oct 2018 09:46:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181007222554.4886-2-thomas@monjalon.net> Content-Language: en-GB X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24142.003 X-TM-AS-Result: No-11.317200-8.000000-10 X-TMASE-MatchedRID: 6otD/cJAac0OwH4pD14DsPHkpkyUphL9Ct59Uh3p/NVKda7Cp9A+Rqcw fOzvS1WBB7eCIdFmSljbklCk1l6tjTp3zB6h4uJpyeVujmXuYYWlAfiiC1VA/QZbeEWcL03VFqL 6h0Wt9pivC9GQc0IPU2t0kC9fgmKsJtllgBC70fnN+qWlu2ZxaPiH64jt3FfEkzE2kM4b6Hr7sm UtIcwHJp+anR9/uMyCgDAAef0FoVk25XOhnouJ5SI9MxSOQ6CSXgqwd9ijktCjC1E/zCEIrwrxO vLvFPZPEeHflL4ZdKr9Vaa04yzrEbCq5jSQSB1nnTqdU4w65WkcDDLReGt4PfmUDxpFogQXo8WM kQWv6iWhMIDkR/KfwCIQ5mZ5SqHPXjb1JLMvImnw4RlFm3Pif/fzzNzaVHthLg1ycPQEMVZ9W5w 5MT/d04HuHBVoEA83hp46aR9krZYMBnufYXKMoPVTH7mnvc8iH8FerAT0dJY= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--11.317200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24142.003 X-MDID: 1538981245-nZ6x21tsL7K0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH 1/5] bus/vdev: add iteration filter on name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Oct 2018 06:47:26 -0000 On 10/8/18 1:25 AM, Thomas Monjalon wrote: > A virtual device can be matched with following syntax: > bus=vdev,name=X > > Signed-off-by: Thomas Monjalon > --- > drivers/bus/vdev/vdev_params.c | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c > index da270f2ec..133998c3e 100644 > --- a/drivers/bus/vdev/vdev_params.c > +++ b/drivers/bus/vdev/vdev_params.c > @@ -2,6 +2,8 @@ > * Copyright 2018 Gaƫtan Rivet > */ > > +#include > + > #include > #include > #include > @@ -11,10 +13,12 @@ > #include "vdev_private.h" > > enum vdev_params { > + RTE_VDEV_PARAM_NAME, > RTE_VDEV_PARAM_MAX, > }; > > static const char * const vdev_params_keys[] = { > + [RTE_VDEV_PARAM_NAME] = "name", > [RTE_VDEV_PARAM_MAX] = NULL, > }; > > @@ -22,11 +26,22 @@ static int > vdev_dev_match(const struct rte_device *dev, > const void *_kvlist) > { > + int ret; > const struct rte_kvargs *kvlist = _kvlist; > + char *name; > + > + /* cannot pass const dev->name to rte_kvargs_process() */ > + name = strdup(dev->name); > + if (name == NULL) > + return -ENOMEM; /* interpreted as no match */ It is strange to see -ENOMEM and -1 returned from the same function. rte_dev_cmp_t does not return negative errno. It just says match / no match (greater / smaller than 0 if ordering is possible). So, -ENOMEM is really confusing here. I think just -1 should be used. > + ret = rte_kvargs_process(kvlist, > + vdev_params_keys[RTE_VDEV_PARAM_NAME], > + rte_kvargs_strcmp, name); > + free(name); > + if (ret != 0) > + return -1; > > - (void) kvlist; > - (void) dev; > - return 0; > + return ret; I'm not sure that I understand why 'ret' is returned here instead of 0. Above check guarantees that ret==0. If you change it, it should be a good reason. > } > > void *