All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gaëtan Rivet" <gaetan.rivet@6wind.com>
To: Andrew Rybchenko <arybchenko@solarflare.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH v1 12/13] ethdev: process declarative eth devargs
Date: Fri, 31 Aug 2018 14:16:46 +0200	[thread overview]
Message-ID: <20180831121646.x46u43rhfyi45rng@bidouze.vm.6wind.com> (raw)
In-Reply-To: <4538a50d-d6fa-bca2-2dc5-5c9ee9a2c24d@solarflare.com>

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 <gaetan.rivet@6wind.com>
> > ---
> >   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

  reply	other threads:[~2018-08-31 12:17 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 13:41 [PATCH v1 00/13] Implement new devargs framework Gaetan Rivet
2018-08-30 13:41 ` [PATCH v1 01/13] bus/pci: implement device iteration and comparison Gaetan Rivet
2018-08-30 13:41 ` [PATCH v1 02/13] bus/pci: add device matching field id Gaetan Rivet
2018-08-30 13:41 ` [PATCH v1 03/13] bus/vdev: implement device iteration Gaetan Rivet
2018-08-30 13:41 ` [PATCH v1 04/13] bus/vdev: add device matching field driver Gaetan Rivet
2018-08-30 13:41 ` [PATCH v1 05/13] ethdev: add private generic device iterator Gaetan Rivet
2018-08-31 10:09   ` Andrew Rybchenko
2018-08-31 10:22     ` Gaëtan Rivet
2018-08-30 13:41 ` [PATCH v1 06/13] ethdev: register ether layer as a class Gaetan Rivet
2018-08-31 10:09   ` Andrew Rybchenko
2018-08-30 13:41 ` [PATCH v1 07/13] ethdev: add device matching field name Gaetan Rivet
2018-08-31 10:10   ` Andrew Rybchenko
2018-08-30 13:41 ` [PATCH v1 08/13] app/testpmd: add show device command Gaetan Rivet
2018-08-30 13:42 ` [PATCH v1 09/13] bus/pci: pre-process declarative PCI devargs Gaetan Rivet
2018-08-30 13:42 ` [PATCH v1 10/13] bus/vdev: pre-process declarative vdev devargs Gaetan Rivet
2018-08-30 13:42 ` [PATCH v1 11/13] bus/pci: process declarative PCI devargs Gaetan Rivet
2018-08-30 16:15   ` Stephen Hemminger
2018-08-30 16:37     ` Gaëtan Rivet
2018-08-30 13:42 ` [PATCH v1 12/13] ethdev: process declarative eth devargs Gaetan Rivet
2018-08-31 10:10   ` Andrew Rybchenko
2018-08-31 12:16     ` Gaëtan Rivet [this message]
2018-08-30 13:42 ` [PATCH v1 13/13] eal: add generic dev parameter Gaetan Rivet
2018-08-30 15:42 ` [PATCH v1 00/13] Implement new devargs framework Stephen Hemminger
2018-09-19 16:03 ` [PATCH v2 " Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 01/13] bus/pci: implement device iteration and comparison Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 02/13] bus/pci: add device matching field id Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 03/13] bus/vdev: implement device iteration Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 04/13] bus/vdev: add device matching field driver Gaetan Rivet
2018-09-20 16:11     ` Thomas Monjalon
2018-09-21 11:53       ` Gaëtan Rivet
2018-09-21 12:55         ` Thomas Monjalon
2018-09-19 16:03   ` [PATCH v2 05/13] ethdev: add private generic device iterator Gaetan Rivet
2018-09-20 10:02     ` Andrew Rybchenko
2018-09-19 16:03   ` [PATCH v2 06/13] ethdev: register ether layer as a class Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 07/13] ethdev: add device matching field name Gaetan Rivet
2018-09-20 16:17     ` Thomas Monjalon
2018-09-21 12:16       ` Gaëtan Rivet
2018-09-21 13:06         ` Thomas Monjalon
2018-09-19 16:03   ` [PATCH v2 08/13] app/testpmd: add show device command Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 09/13] bus/pci: pre-process declarative PCI devargs Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 10/13] bus/vdev: pre-process declarative vdev devargs Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 11/13] bus/pci: process declarative PCI devargs Gaetan Rivet
2018-09-19 16:03   ` [PATCH v2 12/13] ethdev: process declarative eth devargs Gaetan Rivet
2018-09-20 10:11     ` Andrew Rybchenko
2018-09-19 16:03   ` [PATCH v2 13/13] eal: add generic dev parameter Gaetan Rivet
2018-10-03 12:31   ` [PATCH v2 00/13] Implement new devargs framework Thomas Monjalon
2020-02-19  5:43     ` [dpdk-dev] " Pavan Nikhilesh Bhagavatula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180831121646.x46u43rhfyi45rng@bidouze.vm.6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.