eal: add driver name alias
authorJan Blunck <jblunck@infradead.org>
Mon, 24 Oct 2016 16:22:21 +0000 (12:22 -0400)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 25 Oct 2016 16:49:18 +0000 (18:49 +0200)
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>
Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lib/librte_eal/common/eal_common_vdev.c
lib/librte_eal/common/include/rte_dev.h
lib/librte_eal/common/include/rte_vdev.h

index 8b05f50..0ff2377 100644 (file)
@@ -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;
 }
index b3873bd..8840380 100644 (file)
@@ -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. */
 };
 
 /**
index 97260b2..784e837 100644 (file)
@@ -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