From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id B15B3160 for ; Mon, 8 Oct 2018 09:47:31 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3519C21FCF; Mon, 8 Oct 2018 03:47:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 08 Oct 2018 03:47:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=DqeIqEhEQFbC6FTVOB4COXrDLDwcvgNUL2y3/8dYV5I=; b=X2+D6v0rmWxL pBgWiZysdSNVrPL11pyg6/r6wGHnWSoDo1bNL7+xqcr124Nh1gP5dGCi8vflElIf LI8bQYZ5A4Yak4ymhiQwXj+N1trbnpFIoFkzr6/xmYuvEd74k+Bu/hz/d2/PGvmr EVtLTrBOTxJ03NCv4rQ4vvHJC2jyxBA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=DqeIqEhEQFbC6FTVOB4COXrDLDwcvgNUL2y3/8dYV 5I=; b=nONtS3v45a+KaaeTebVE856MiMaVXeqfj626bK8VcbXnr93JXTeWolu32 V2bM3hsCO8jZw/4skffaSXxyqJRozPJ5AdCR9xbWc7rqDs7toY/ZLKGUI+JmfrQG pofMcOE1RLgAagvK3tJjpDfZ6kUMQmCirjHykOq+24xbFndYu10FDaV/Y2aupjjS FkaJHfon5ENMzFKy0NflLm75DDSbk8zoXPLiLabLYQMh+tf+wtg3GcnlJGe1NB3S 1UXf8BAoqMx6uWZTfH8ZmT3d30l5CNoOLzzvpIQ9qF9seT7BkqQ3jD2T05vJcEun 2uqEiU21FVHGehzujaWYf53WoZYFg== X-ME-Sender: X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 9C69C102D7; Mon, 8 Oct 2018 03:47:29 -0400 (EDT) From: Thomas Monjalon To: Andrew Rybchenko Cc: dev@dpdk.org, gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com Date: Mon, 08 Oct 2018 09:47:27 +0200 Message-ID: <3036779.UqIVyZ4pAr@xps> In-Reply-To: References: <20181007222554.4886-1-thomas@monjalon.net> <20181007222554.4886-2-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" 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 07:47:32 -0000 08/10/2018 08:46, Andrew Rybchenko: > On 10/8/18 1:25 AM, Thomas Monjalon wrote: > > A virtual device can be matched with following syntax: > > bus=3Dvdev,name=3DX > > > > 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_par= ams.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=EBtan Rivet > > */ > > =20 > > +#include > > + > > #include > > #include > > #include > > @@ -11,10 +13,12 @@ > > #include "vdev_private.h" > > =20 > > enum vdev_params { > > + RTE_VDEV_PARAM_NAME, > > RTE_VDEV_PARAM_MAX, > > }; > > =20 > > static const char * const vdev_params_keys[] =3D { > > + [RTE_VDEV_PARAM_NAME] =3D "name", > > [RTE_VDEV_PARAM_MAX] =3D NULL, > > }; > > =20 > > @@ -22,11 +26,22 @@ static int > > vdev_dev_match(const struct rte_device *dev, > > const void *_kvlist) > > { > > + int ret; > > const struct rte_kvargs *kvlist =3D _kvlist; > > + char *name; > > + > > + /* cannot pass const dev->name to rte_kvargs_process() */ > > + name =3D strdup(dev->name); > > + if (name =3D=3D NULL) > > + return -ENOMEM; /* interpreted as no match */ >=20 > 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. Yes, OK. > > + ret =3D rte_kvargs_process(kvlist, > > + vdev_params_keys[RTE_VDEV_PARAM_NAME], > > + rte_kvargs_strcmp, name); > > + free(name); > > + if (ret !=3D 0) > > + return -1; > > =20 > > - (void) kvlist; > > - (void) dev; > > - return 0; > > + return ret; >=20 > I'm not sure that I understand why 'ret' is returned here > instead of 0. Above check guarantees that ret=3D=3D0. > If you change it, it should be a good reason. Right Thanks for the review!