[PATCH] bus/vdev: automatically add eth alias for net drivers

Bruce Richardson bruce.richardson at intel.com
Wed Oct 19 15:11:18 CEST 2022


For historical reasons, a number of net vdev drivers also add a driver
alias using the "eth_" prefix. Since this is done on a per-driver basis,
the use of the alias in inconsistent and is spread across multiple
files. We can remove the per-driver aliases by just adding the alias
automatically at the vdev bus level.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 drivers/bus/vdev/vdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index f5b43f1930..bfd7ce60c1 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -54,6 +54,12 @@ static rte_spinlock_t vdev_custom_scan_lock = RTE_SPINLOCK_INITIALIZER;
 void
 rte_vdev_register(struct rte_vdev_driver *driver)
 {
+	/* For net driver vdevs, add an automatic alias using "eth" prefix */
+	if (strncmp(driver->driver.name, "net_", 4) == 0 && driver->driver.alias == NULL) {
+		char *alias = strdup(driver->driver.name);
+		memcpy(alias, "eth_", 4);
+		driver->driver.alias = alias;
+	}
 	TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
 }
 
-- 
2.34.1



More information about the dev mailing list