[PATCH v4 4/7] drivers/bus: cleanup devargs lookup in scan

David Marchand
2026-04-14T12:39:40Z

Don't hardcode the bus names in the RTE_EAL_DEVARGS_FOREACH() calls.
The bus name is set by code in EAL.
Even if there is nothing broken, let's reuse the name from the bus object.

And remove the now useless macros.

Note: in the ifpga bus case, the lookup loop was using an incorrect macro
(IFPGA_ARG_NAME instead of IFPGA_BUS_NAME), yet it was working fine
as this macro is aligned with the ifpga bus name.
Besides, the raw/ifpga wants to hotplug a device in this bus, so keep
this bus name macro and add a check the bus name is aligned at init time.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Tested-by: Maxime Leroy <maxime@leroys.fr>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
Changes since v1:
- fixed ifpga hotplug in raw/ifpga,

---
drivers/bus/auxiliary/auxiliary_common.c | 2 +-
drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 --
drivers/bus/cdx/cdx.c | 3 +--
drivers/bus/dpaa/dpaa_bus.c | 6 ++----
drivers/bus/fslmc/fslmc_bus.c | 8 +++-----
drivers/bus/ifpga/ifpga_bus.c | 8 ++++++--
drivers/bus/pci/pci_common.c | 2 +-
drivers/bus/platform/platform.c | 2 +-
drivers/bus/uacce/uacce.c | 2 +-
drivers/bus/vdev/vdev.c | 2 +-
drivers/bus/vmbus/vmbus_common.c | 2 +-
11 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index ac766e283e..119533df28 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -30,7 +30,7 @@ auxiliary_devargs_lookup(const char *name)
{
struct rte_devargs *devargs;

- RTE_EAL_DEVARGS_FOREACH(RTE_BUS_AUXILIARY_NAME, devargs) {
+ RTE_EAL_DEVARGS_FOREACH(auxiliary_bus.bus.name, devargs) {
if (strcmp(devargs->name, name) == 0)
return devargs;
}
diff --git a/drivers/bus/auxiliary/bus_auxiliary_driver.h b/drivers/bus/auxiliary/bus_auxiliary_driver.h
index 1dc814151e..8450d56583 100644
--- a/drivers/bus/auxiliary/bus_auxiliary_driver.h
+++ b/drivers/bus/auxiliary/bus_auxiliary_driver.h
@@ -28,8 +28,6 @@
extern "C" {
#endif

-#define RTE_BUS_AUXILIARY_NAME "auxiliary"
-
/* Forward declarations */
struct rte_auxiliary_driver;
struct rte_auxiliary_device;
diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index 729d54337c..b183d98453 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -82,7 +82,6 @@
#include "cdx_logs.h"
#include "private.h"

-#define CDX_BUS_NAME cdx
#define CDX_DEV_PREFIX "cdx-"

/* CDX Bus iterators */
@@ -157,7 +156,7 @@ cdx_devargs_lookup(const char *dev_name)
{
struct rte_devargs *devargs;

- RTE_EAL_DEVARGS_FOREACH("cdx", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(rte_cdx_bus.bus.name, devargs) {
if (strcmp(devargs->name, dev_name) == 0)
return devargs;
}
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 5e0f32bfe8..e3c17d41f7 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -77,8 +77,6 @@ static pthread_key_t dpaa_portal_key;
struct dpaa_portal *dpaa_portals[RTE_MAX_LCORE] = {NULL};
static int dpaa_bus_global_init;

-#define FSL_DPAA_BUS_NAME dpaa_bus
-
RTE_EXPORT_INTERNAL_SYMBOL(per_lcore_dpaa_io)
RTE_DEFINE_PER_LCORE(struct dpaa_portal *, dpaa_io);

@@ -206,7 +204,7 @@ dpaa_devargs_lookup(struct rte_dpaa_device *dev)
struct rte_devargs *devargs;
char dev_name[32];

- RTE_EAL_DEVARGS_FOREACH("dpaa_bus", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(rte_dpaa_bus.bus.name, devargs) {
devargs->bus->parse(devargs->name, &dev_name);
if (strcmp(dev_name, dev->device.name) == 0) {
DPAA_BUS_INFO("**Devargs matched %s", dev_name);
@@ -1003,5 +1001,5 @@ static struct rte_dpaa_bus rte_dpaa_bus = {
.device_count = 0,
};

-RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
+RTE_REGISTER_BUS(dpaa_bus, rte_dpaa_bus.bus);
RTE_LOG_REGISTER_DEFAULT(dpaa_logtype_bus, NOTICE);
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 20b08639b7..bfedc53b55 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -26,7 +26,6 @@
#include <dpaax_iova_table.h>

#define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
-#define FSLMC_BUS_NAME fslmc

struct rte_fslmc_bus rte_fslmc_bus;

@@ -106,7 +105,7 @@ fslmc_devargs_lookup(struct rte_dpaa2_device *dev)
struct rte_devargs *devargs;
char dev_name[32];

- RTE_EAL_DEVARGS_FOREACH("fslmc", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(rte_fslmc_bus.bus.name, devargs) {
devargs->bus->parse(devargs->name, &dev_name);
if (strcmp(dev_name, dev->device.name) == 0) {
DPAA2_BUS_INFO("**Devargs matched %s", dev_name);
@@ -266,8 +265,7 @@ rte_fslmc_parse(const char *name, void *addr)
*/
if (sep_exists) {
/* If either of "fslmc" or "name" are starting part */
- if (!strncmp(name, RTE_STR(FSLMC_BUS_NAME),
- strlen(RTE_STR(FSLMC_BUS_NAME))) ||
+ if (!strncmp(name, rte_fslmc_bus.bus.name, strlen(rte_fslmc_bus.bus.name)) ||
(!strncmp(name, "name", strlen("name")))) {
goto jump_out;
} else {
@@ -708,5 +706,5 @@ struct rte_fslmc_bus rte_fslmc_bus = {
.device_count = {0},
};

-RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
+RTE_REGISTER_BUS(fslmc, rte_fslmc_bus.bus);
RTE_LOG_REGISTER_DEFAULT(dpaa2_logtype_bus, NOTICE);
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index fdce1f6b1f..ca2812a960 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -220,7 +220,7 @@ ifpga_scan(void)
struct rte_afu_device *afu_dev = NULL;

/* for FPGA devices we scan the devargs_list populated via cmdline */
- RTE_EAL_DEVARGS_FOREACH(IFPGA_ARG_NAME, devargs) {
+ RTE_EAL_DEVARGS_FOREACH(rte_ifpga_bus.name, devargs) {
if (devargs->bus != &rte_ifpga_bus)
continue;

@@ -516,5 +516,9 @@ static struct rte_bus rte_ifpga_bus = {
.parse = ifpga_parse,
};

-RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
+RTE_REGISTER_BUS(ifpga, rte_ifpga_bus);
+RTE_INIT(ifpga_bus_init)
+{
+ RTE_VERIFY(strcmp(rte_ifpga_bus.name, RTE_STR(IFPGA_BUS_NAME)) == 0);
+}
RTE_LOG_REGISTER_DEFAULT(ifpga_bus_logtype, NOTICE);
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index bf5df3d94e..1d26fce680 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -85,7 +85,7 @@ pci_devargs_lookup(const struct rte_pci_addr *pci_addr)
struct rte_devargs *devargs;
struct rte_pci_addr addr;

- RTE_EAL_DEVARGS_FOREACH("pci", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(rte_pci_bus.bus.name, devargs) {
devargs->bus->parse(devargs->name, &addr);
if (!rte_pci_addr_cmp(pci_addr, &addr))
return devargs;
diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c
index f6673cf181..18fa73795c 100644
--- a/drivers/bus/platform/platform.c
+++ b/drivers/bus/platform/platform.c
@@ -48,7 +48,7 @@ dev_devargs(const char *dev_name)
{
struct rte_devargs *devargs;

- RTE_EAL_DEVARGS_FOREACH("platform", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(platform_bus.bus.name, devargs) {
if (!strcmp(devargs->name, dev_name))
return devargs;
}
diff --git a/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c
index a471edcad0..06a3643290 100644
--- a/drivers/bus/uacce/uacce.c
+++ b/drivers/bus/uacce/uacce.c
@@ -77,7 +77,7 @@ uacce_devargs_lookup(const char *dev_name)
struct rte_devargs *devargs;

snprintf(name, sizeof(name), "%s%s", UACCE_DEV_PREFIX, dev_name);
- RTE_EAL_DEVARGS_FOREACH("uacce", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(uacce_bus.bus.name, devargs) {
if (strcmp(devargs->name, name) == 0)
return devargs;
}
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index be375f63dc..eb1de0186e 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -526,7 +526,7 @@ vdev_scan(void)
rte_spinlock_unlock(&vdev_custom_scan_lock);

/* for virtual devices we scan the devargs_list populated via cmdline */
- RTE_EAL_DEVARGS_FOREACH("vdev", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(rte_vdev_bus.name, devargs) {

dev = calloc(1, sizeof(*dev));
if (!dev)
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index a787d8b18d..f857244c85 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -271,7 +271,7 @@ vmbus_devargs_lookup(struct rte_vmbus_device *dev)
struct rte_devargs *devargs;
rte_uuid_t addr;

- RTE_EAL_DEVARGS_FOREACH("vmbus", devargs) {
+ RTE_EAL_DEVARGS_FOREACH(rte_vmbus_bus.bus.name, devargs) {
vmbus_parse(devargs->name, &addr);

if (rte_uuid_compare(dev->device_id, addr) == 0)
--
2.53.0