From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 411F24CB3 for ; Fri, 31 Aug 2018 14:17:04 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id r1-v6so1074021wmh.0 for ; Fri, 31 Aug 2018 05:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Zl7CoQ4Kt0l7sIMGhnbaleZOsEUpaP3WyEu14PgdYhY=; b=NTEFAVHcMKZgQJ2Y7PHUFwbST6J7LJBphRW7cbR+DxjafL9eYktq9hmmr2IMy8zHIM fU82wXv2pav8GmuLl5ldGLENdTVUyt/6VsSBpa4OKHzUcd/Io5I4gwTnxyQaq9hadR9X XrGmd7beYSHLcD6iN0PGjArE12hrIqyZV2aEoFx3dzR8C3PPVy3SKMo+E4cheIzuYxUc 8VM5B7Y5/p33O9dgzvNjVGTk1wGlCFLa/k9lNFYKPu4NKbaoMAtH/o6RAPPO6FXy6hjd RGw44O0vqyIS6AO+aNNAQYPIzaev5zpQu11DqKhKkZpUNajzaXkbgI4OQz5xCWOmuNna LrAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=Zl7CoQ4Kt0l7sIMGhnbaleZOsEUpaP3WyEu14PgdYhY=; b=dxdsNdjaqh1BeY0aLVTW0j/a5lZdAe1kHfHDwnT7mBRcHGHbVs9W+1CPNiLpAZoq3n IKd/2lw8GTrh72d91NVPNIJ1UMXaMooBbYOne0iyG4/C9Qckk7YHC7ebQstOZ2dTatO4 Vyuq67+EFYBw2im+mZCLI8E+tmKAmLXYhd3HHxPeUiWRYd6GiAWTqdneyiNGgsdBb5QD mEZTuW/F9H4BVdQAlAhNpI0Igc74wrp6Q4DwVlOhDEE1dMvlFm70bUftAUOJaJxXCv8B CAN1I6JvIduoX3KD/ilxbFjvfba2uXB+IBeyGl4CvGlPeq1Fs+3/d/l3hSQ6j3RKtUnM wnNw== X-Gm-Message-State: APzg51BcT90sbyT0ZjNuDgSUKIz3jvZL/7f6T1DHX36Jf7HbUhf//kO/ WriJtYbr/NnF+p9aUpUPwsxF7A== X-Google-Smtp-Source: ANB0VdbzAI/AQRXElTMkMCYE7Isubxe6oH3ICkTomtxPQgF3/CYEu+yYz65DScRj4EUReP1cFkgqbg== X-Received: by 2002:a1c:8145:: with SMTP id c66-v6mr4791857wmd.139.1535717823762; Fri, 31 Aug 2018 05:17:03 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id u40-v6sm18725120wrc.43.2018.08.31.05.17.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 05:17:02 -0700 (PDT) Date: Fri, 31 Aug 2018 14:16:46 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Andrew Rybchenko Cc: dev@dpdk.org Message-ID: <20180831121646.x46u43rhfyi45rng@bidouze.vm.6wind.com> References: <712878880719df833be5c45f866fae04ba5379aa.1535633784.git.gaetan.rivet@6wind.com> <4538a50d-d6fa-bca2-2dc5-5c9ee9a2c24d@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4538a50d-d6fa-bca2-2dc5-5c9ee9a2c24d@solarflare.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v1 12/13] ethdev: process declarative eth devargs 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: Fri, 31 Aug 2018 12:17:04 -0000 On Fri, Aug 31, 2018 at 01:10:48PM +0300, Andrew Rybchenko wrote: > On 08/30/2018 04:42 PM, Gaetan Rivet wrote: > > Process the class-specific arguments in a devargs. > > This processing takes the form of setting the proper eth_dev fields when > > relevant. > > > > Signed-off-by: Gaetan Rivet > > --- > > lib/librte_ethdev/eth_private.h | 5 +++ > > lib/librte_ethdev/rte_class_eth.c | 62 +++++++++++++++++++++++++++++++ > > lib/librte_ethdev/rte_ethdev.c | 7 ++++ > > 3 files changed, 74 insertions(+) > > > > diff --git a/lib/librte_ethdev/eth_private.h b/lib/librte_ethdev/eth_private.h > > index 0f5c6d5c4..c0c065165 100644 > > --- a/lib/librte_ethdev/eth_private.h > > +++ b/lib/librte_ethdev/eth_private.h > > @@ -19,6 +19,11 @@ struct rte_eth_dev * > > eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, > > const void *data); > > +/* Generic rte_eth_dev parameters processor. */ > > +int > > +rte_eth_dev_args_parse(struct rte_eth_dev *eth_dev, > > + struct rte_devargs *da); > > + > > #ifdef __cplusplus > > } > > #endif > > diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c > > index d8d8e8845..18fdef605 100644 > > --- a/lib/librte_ethdev/rte_class_eth.c > > +++ b/lib/librte_ethdev/rte_class_eth.c > > <...> > > > @@ -79,6 +93,54 @@ eth_dev_iterate(const void *start, > > return edev; > > } > > +static int > > +eth_dev_set_name(struct rte_eth_dev *edev, > > + const char *value) > > +{ > > + snprintf(edev->data->name, > > + sizeof(edev->data->name), > > + "%s", value); > > strlcpy()? Ok. > Shouldn't we return error if name does fit in name buffer? Good idea. > > > + return 0; > > +} > > + > > +static int > > +ethdev_args_process(const char *key, > > + const char *value, > > + void *_edev) > > +{ > > + static eth_dev_set_t eth_dev_set[] = { > > + [RTE_ETH_PARAMS_NAME] = eth_dev_set_name, > > + [RTE_ETH_PARAMS_MAX] = NULL, > > + }; > > + struct rte_eth_dev *edev = _edev; > > + int param; > > + > > + param = ethdev_param_id(key); > > + if (eth_dev_set[param]) > > + return eth_dev_set[param](edev, value); > > + return 0; > > +} > > + > > +int > > +rte_eth_dev_args_parse(struct rte_eth_dev *edev, > > + struct rte_devargs *devargs) > > +{ > > + struct rte_kvargs *kvargs = NULL; > > + > > + if (devargs == NULL || devargs->cls_str == NULL) > > + return 0; > > + > > + kvargs = rte_kvargs_parse_delim(devargs->cls_str, eth_params_keys, "/"); > > + if (kvargs == NULL) { > > + RTE_LOG(ERR, EAL, "cannot parse argument list\n"); > > + return -EINVAL; > > + } > > + if (rte_kvargs_process(kvargs, NULL, ethdev_args_process, edev)) > > Shouldn't we free kvargs here as well? > Indeed, silly mistake. Thanks > > + return -1; > > + rte_kvargs_free(kvargs); > > + return 0; > > +} > > + > > struct rte_class rte_class_eth = { > > .dev_iterate = eth_dev_iterate, > > }; > > <...> -- Gaëtan Rivet 6WIND