DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] drivers: add name alias registration for rte_driver
@ 2016-10-20  9:37 Jan Blunck
  2016-10-20  9:37 ` [dpdk-dev] [PATCH 2/2] drivers: register aliases for renamed VDEV drivers Jan Blunck
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Jan Blunck @ 2016-10-20  9:37 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch, thomas.monjalon, yuanhan.liu, john.mcnamara

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>
---
 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..ee5060e 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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-10-25 16:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-20  9:37 [dpdk-dev] [PATCH 1/2] drivers: add name alias registration for rte_driver 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 ` [dpdk-dev] [PATCH v2 1/3] " Jan Blunck
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

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).