DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jan Blunck <jblunck@infradead.org>
To: dev@dpdk.org
Cc: pablo.de.lara.guarch@intel.com, thomas.monjalon@6wind.com,
	yuanhan.liu@linux.intel.com, john.mcnamara@intel.com,
	maxime.coquelin@redhat.com
Subject: [dpdk-dev] [PATCH v2 1/3] drivers: add name alias registration for rte_driver
Date: Mon, 24 Oct 2016 12:22:21 -0400	[thread overview]
Message-ID: <1477326143-4571-1-git-send-email-jblunck@infradead.org> (raw)
In-Reply-To: <1476956223-30308-1-git-send-email-jblunck@infradead.org>

This adds infrastructure for drivers to allow being requested by an alias
so that a renamed driver can still get loaded by its legacy name.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_eal/common/eal_common_vdev.c  | 8 ++++++++
 lib/librte_eal/common/include/rte_dev.h  | 1 +
 lib/librte_eal/common/include/rte_vdev.h | 5 +++++
 3 files changed, 14 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 8b05f50..0ff2377 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -79,6 +79,14 @@ rte_eal_vdev_init(const char *name, const char *args)
 			return driver->probe(name, args);
 	}
 
+	/* Give new names precedence over aliases. */
+	TAILQ_FOREACH(driver, &vdev_driver_list, next) {
+		if (driver->driver.alias &&
+		    !strncmp(driver->driver.alias, name,
+			    strlen(driver->driver.alias)))
+			return driver->probe(name, args);
+	}
+
 	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
 	return -EINVAL;
 }
diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index b3873bd..8840380 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -149,6 +149,7 @@ void rte_eal_device_remove(struct rte_device *dev);
 struct rte_driver {
 	TAILQ_ENTRY(rte_driver) next;  /**< Next in list. */
 	const char *name;                   /**< Driver name. */
+	const char *alias;              /**< Driver alias. */
 };
 
 /**
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index 97260b2..784e837 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -83,13 +83,18 @@ void rte_eal_vdrv_unregister(struct rte_vdev_driver *driver);
 
 #define RTE_PMD_REGISTER_VDEV(nm, vdrv)\
 RTE_INIT(vdrvinitfn_ ##vdrv);\
+static const char *vdrvinit_ ## nm ## _alias;\
 static void vdrvinitfn_ ##vdrv(void)\
 {\
 	(vdrv).driver.name = RTE_STR(nm);\
+	(vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\
 	rte_eal_vdrv_register(&vdrv);\
 } \
 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
 
+#define RTE_PMD_REGISTER_ALIAS(nm, alias)\
+static const char *vdrvinit_ ## nm ## _alias = RTE_STR(alias)
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.6.6

  parent reply	other threads:[~2016-10-24 16:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20  9:37 [dpdk-dev] [PATCH 1/2] " Jan Blunck
2016-10-20  9:37 ` [dpdk-dev] [PATCH 2/2] drivers: register aliases for renamed VDEV drivers Jan Blunck
2016-10-21  0:15   ` De Lara Guarch, Pablo
2016-10-21 11:22     ` [dpdk-dev] [PATCH] drivers: register aliases for renamed cryptodev drivers Jan Blunck
2016-10-21 18:35       ` De Lara Guarch, Pablo
2016-10-21 18:33   ` [dpdk-dev] [PATCH 2/2] drivers: register aliases for renamed VDEV drivers De Lara Guarch, Pablo
2016-10-21 18:31 ` [dpdk-dev] [PATCH 1/2] drivers: add name alias registration for rte_driver De Lara Guarch, Pablo
2016-10-22 11:24 ` Maxime Coquelin
2016-10-24 16:22 ` Jan Blunck [this message]
2016-10-24 16:22   ` [dpdk-dev] [PATCH v2 2/3] drivers: register aliases for renamed VDEV drivers Jan Blunck
2016-10-24 16:22   ` [dpdk-dev] [PATCH v2 3/3] drivers: register aliases for renamed cryptodev drivers Jan Blunck
2016-10-24 17:41   ` [dpdk-dev] [PATCH v2 1/3] drivers: add name alias registration for rte_driver Yuanhan Liu
2016-10-25 16:17     ` 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=1477326143-4571-1-git-send-email-jblunck@infradead.org \
    --to=jblunck@infradead.org \
    --cc=dev@dpdk.org \
    --cc=john.mcnamara@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=thomas.monjalon@6wind.com \
    --cc=yuanhan.liu@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).