All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: "Tan, Jianfeng" <jianfeng.tan@intel.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH] bus/vdev: add custom scan hook
Date: Wed, 06 Dec 2017 10:21:48 +0100	[thread overview]
Message-ID: <3098333.2ghLid1hiy@xps> (raw)
In-Reply-To: <f38a6e5f-f4ea-54f7-79cc-07c29e0bb44f@intel.com>

06/12/2017 03:52, Tan, Jianfeng:
> On 12/1/2017 8:36 AM, Thomas Monjalon wrote:
> > +int
> > +rte_vdev_add_custom_scan(rte_vdev_scan_callback callback, void *user_arg)
> > +{
> > +	struct vdev_custom_scan *custom_scan;
> > +
> > +	rte_spinlock_lock(&vdev_custom_scan_lock);
> > +
> > +	/* check if already registered */
> > +	TAILQ_FOREACH(custom_scan, &vdev_custom_scans, next) {
> > +		if (custom_scan->callback == callback &&
> > +				custom_scan->user_arg == user_arg)
> > +			break;
> > +	}
> > +
> > +	if (custom_scan == NULL) {
> > +		custom_scan = malloc(sizeof(struct vdev_custom_scan));
> > +		if (custom_scan != NULL) {
> > +			custom_scan->callback = callback;
> > +			custom_scan->user_arg = user_arg;
> > +			TAILQ_INSERT_TAIL(&vdev_custom_scans, custom_scan, next);
> > +		}
> > +	}
> > +
> > +	rte_spinlock_unlock(&vdev_custom_scan_lock);
> > +
> > +	return (custom_scan == NULL) ? -ENOMEM : 0;
> > +}
> > +
> > +int
> > +rte_vdev_remove_custom_scan(rte_vdev_scan_callback callback, void *user_arg)
> > +{
> > +	struct vdev_custom_scan *custom_scan, *tmp_scan;
> > +
> > +	rte_spinlock_lock(&vdev_custom_scan_lock);
> > +	TAILQ_FOREACH_SAFE(custom_scan, &vdev_custom_scans, next, tmp_scan) {
> > +		if (custom_scan->callback != callback ||
> > +				(custom_scan->user_arg != (void *)-1 &&
> > +				custom_scan->user_arg != user_arg))
> > +			continue;
> > +		TAILQ_REMOVE(&vdev_custom_scans, custom_scan, next);
> > +		free(custom_scan);
> > +	}
> > +	rte_spinlock_unlock(&vdev_custom_scan_lock);
> > +
> > +	return 0;
> > +}
> > +
> >   static int
> >   vdev_parse(const char *name, void *addr)
> >   {
> > @@ -260,6 +319,22 @@ vdev_scan(void)
> >   {
> >   	struct rte_vdev_device *dev;
> >   	struct rte_devargs *devargs;
> > +	struct vdev_custom_scan *custom_scan;
> > +
> > +	/* call custom scan callbacks if any */
> > +	rte_spinlock_lock(&vdev_custom_scan_lock);
> > +	TAILQ_FOREACH(custom_scan, &vdev_custom_scans, next) {
> > +		if (custom_scan->callback != NULL)
> > +			/*
> > +			 * the callback should update devargs list
> > +			 * by calling rte_eal_devargs_insert() with
> > +			 *     devargs.bus = rte_bus_find_by_name("vdev");
> > +			 *     devargs.type = RTE_DEVTYPE_VIRTUAL;
> > +			 *     devargs.policy = RTE_DEV_WHITELISTED;
> > +			 */
> > +			custom_scan->callback(custom_scan->user_arg);
> > +	}
> > +	rte_spinlock_unlock(&vdev_custom_scan_lock);
> 
> You mentioned that we want to call the hook in the scan(), but it's now 
> in parse()?

No, it is in vdev_scan.
Look carefully the patch, especially after @@.

  reply	other threads:[~2017-12-06  9:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01  0:36 [PATCH] bus/vdev: add custom scan hook Thomas Monjalon
2017-12-01  0:40 ` Thomas Monjalon
2017-12-01  5:48 ` Tan, Jianfeng
2017-12-01  8:42   ` Thomas Monjalon
2017-12-04  8:08     ` Tan, Jianfeng
2017-12-04  9:31       ` Thomas Monjalon
2017-12-05  8:27         ` Tan, Jianfeng
2017-12-05  8:41           ` Thomas Monjalon
2017-12-05 13:56             ` Tan, Jianfeng
2017-12-05 15:21               ` Thomas Monjalon
2017-12-06  2:48                 ` Tan, Jianfeng
2017-12-06  2:52 ` Tan, Jianfeng
2017-12-06  9:21   ` Thomas Monjalon [this message]
2017-12-07  2:30     ` Tan, Jianfeng
2017-12-30 21:21 ` [PATCH v2] " Thomas Monjalon
2018-01-03  1:16   ` Tan, Jianfeng
2018-01-03  8:05     ` Thomas Monjalon
2018-01-08 23:25 ` [PATCH v3] " Thomas Monjalon
2018-01-11 23:47   ` Thomas Monjalon

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=3098333.2ghLid1hiy@xps \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    /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.