From: Jan Blunck Date: Mon, 24 Oct 2016 16:22:21 +0000 (-0400) Subject: eal: add driver name alias X-Git-Tag: spdx-start~5502 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d63eed6b2dcaf65c71d613f1f6dd172b697a1258;p=dpdk.git eal: add driver name alias 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 Reviewed-by: Maxime Coquelin Tested-by: Pablo de Lara Reviewed-by: Yuanhan Liu --- diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 8b05f50e8b..0ff2377dd6 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 b3873bdbce..8840380df1 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 97260b2faa..784e837d10 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