Rework device probing
Subsystems (2)
cover Rework device probing
Applications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
Signature · 64 lines
David Marchand Changes since RFC v3: - removed per bus scan mode, Changes since RFC v2: - went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5), - updated device selection helper accordingly and changed API to be device name based, - renamed option, added check on -b presence, updated doc in the last patch, Changes since RFC v1: - reviewed bus probe() and cleaned up NXP drivers, - changed approach following Bruce comment, David Marchand (8): devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup drivers/bus: require probe function for NXP drivers drivers: cleanup devargs lookup in bus scan bus: factorize devargs lookup bus: factorize device selection bus: remove per bus scan mode eal: configure initial device probing app/test/test_eal_flags.c | 63 +++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 13 ++++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +--------- drivers/bus/dpaa/dpaa_bus.c | 71 +++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 69 ++++++++----------- drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/bus_ifpga_driver.h | 2 - drivers/bus/ifpga/ifpga_bus.c | 4 +- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++---------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +----------- drivers/bus/uacce/uacce.c | 39 +---------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 - drivers/bus/vmbus/vmbus_common.c | 45 +++---------- drivers/dma/idxd/idxd_bus.c | 18 +---- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- lib/eal/common/eal_common_bus.c | 62 +++++++++++++++++ lib/eal/common/eal_common_devargs.c | 8 +-- lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/common/eal_private.h | 31 +++++++++ lib/eal/include/bus_driver.h | 55 ++++++++++----- 33 files changed, 338 insertions(+), 388 deletions(-) -- 2.53.0
PATCH 1/8 devtools: check packet forwarding in null test
Add some simple checks that testpmd was indeed polling two ports, and some packets got through it.
--- devtools/test-null.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
devtools/test-null.sh +7 -1
@@ -26,8 +26,14 @@ else libs= fi +logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ - --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia + --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile + +# we expect two ports and some traffic is received and transmitted +grep -q 'io packet forwarding - ports=2 -' $build/test-null.log +grep 'RX-packets: ' $logfile | tail -1 | grep -q 'RX-packets:[[:space:]]*[^0[:space:]]' +grep 'TX-packets: ' $logfile | tail -1 | grep -q 'TX-packets:[[:space:]]*[^0[:space:]]'
Signature · 1 line
2.53.0
PATCH 2/8 bus/fslmc: fix bus cleanup
In reply to David MarchandThe close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +4 -17
@@ -1393,7 +1393,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, {struct rte_dpaa2_object *object =NULL ;struct rte_dpaa2_driver *drv; -int ret, probe_all; +int ret;switch (dev->dev_type) {case DPAA2_IO :
@@ -1411,22 +1411,9 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - probe_all = rte_fslmc_bus.bus.conf.scan_mode != -RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { -if (drv->drv_type != dev->dev_type) -continue ; -if (rte_dev_is_probed (&dev->device)) -continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy == -RTE_DEV_ALLOWED )) { - ret = drv->remove (dev); -if (ret) -DPAA2_BUS_ERR ("Unable to remove" ); - } - } + drv = dev->driver; +if (drv && drv->remove && drv->remove (dev)) +DPAA2_BUS_ERR ("Unable to remove" );break ;default :break ;
Signature · 1 line
2.53.0
Re: [PATCH 2/8] bus/fslmc: fix bus cleanup
Quoted 42 lines · David Marchand
The close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
Fixes 274fd921ff7f ("bus/fslmc: support close operation")Signed-off-by David Marchand <[email protected]>--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)drivers/bus/fslmc/fslmc_vfio.c +1
-9@@ -1393,7 +1393,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, {struct rte_dpaa2_object *object =NULL ;struct rte_dpaa2_driver *drv; -int ret, probe_all; +int ret;switch (dev->dev_type) {case DPAA2_IO :@@ -1411,22 +1411,9 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - probe_all = rte_fslmc_bus.bus.conf.scan_mode != -RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { -if (drv->drv_type != dev->dev_type) -continue ; -if (rte_dev_is_probed (&dev->device)) -continue ; - if (probe_all ||
drivers/bus/fslmc/fslmc_vfio.c fslmc_close_iodevices(struct rte_dpaa2_device *dev, · line 1415
Quoted 10 lines
drivers/bus/fslmc/fslmc_vfio.c +2
-8- (dev->device.devargs && - dev->device.devargs->policy == - RTE_DEV_ALLOWED)) { - ret = drv->remove (dev); -if (ret) -DPAA2_BUS_ERR ("Unable to remove" ); - } - } + drv = dev->driver; +if (drv && drv->remove && drv->remove (dev))
Not new but dpaa2_qdma_remove doesn't return an error which seems like a bug, but it has it's own log and it's just a log here anyway, so not critical.
Quoted 4 lines
drivers/bus/fslmc/fslmc_vfio.c +1
-0+DPAA2_BUS_ERR ("Unable to remove" );break ;default :break ;
Re: [PATCH 2/8] bus/fslmc: fix bus cleanup
Quoted 50 lines · Kevin Traynor
Quoted 48 lines · David Marchand
The close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
Fixes 274fd921ff7f ("bus/fslmc: support close operation")Signed-off-by David Marchand <[email protected]>--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)drivers/bus/fslmc/fslmc_vfio.c +1
-15@@ -1393,7 +1393,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, {struct rte_dpaa2_object *object =NULL ;struct rte_dpaa2_driver *drv; -int ret, probe_all; +int ret;switch (dev->dev_type) {case DPAA2_IO :@@ -1411,22 +1411,9 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - probe_all = rte_fslmc_bus.bus.conf.scan_mode != -RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { -if (drv->drv_type != dev->dev_type) -continue ; -if (rte_dev_is_probed (&dev->device)) -continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy == -RTE_DEV_ALLOWED )) { - ret = drv->remove (dev); -if (ret) -DPAA2_BUS_ERR ("Unable to remove" );
Quoted 10 lines
drivers/bus/fslmc/fslmc_vfio.c fslmc_close_iodevices(struct rte_dpaa2_device *dev, · line 1415
Quoted 4 lines
drivers/bus/fslmc/fslmc_vfio.c +2
-2- } - } + drv = dev->driver; +if (drv && drv->remove && drv->remove (dev))Not new but
dpaa2_qdma_removedoesn't return an error which seems like a bug, but it has it's own log and it's just a log here anyway, so not critical.Quoted 1 line
drivers/bus/fslmc/fslmc_vfio.c +1
-0+DPAA2_BUS_ERR ("Unable to remove" );
Indeed, the dma/dpaa2 driver does not report errors.
And there is probably more to fix in the fslmc bus, as I see that the bus .unplug() does not check the driver .remove() return value either.
I did not dig deeper in this bus for now as I was focusing on the devargs evaluation.
Could you open a bugzilla for tracking this issue?
Thanks.
Signature · 1 line
David Marchand
Re: [PATCH 2/8] bus/fslmc: fix bus cleanup
Quoted 62 lines · David Marchand
Quoted 50 lines · Kevin Traynor
Quoted 48 lines · David Marchand
The close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
Fixes 274fd921ff7f ("bus/fslmc: support close operation")Signed-off-by David Marchand <[email protected]>--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)drivers/bus/fslmc/fslmc_vfio.c +1
-15@@ -1393,7 +1393,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, {struct rte_dpaa2_object *object =NULL ;struct rte_dpaa2_driver *drv; -int ret, probe_all; +int ret;switch (dev->dev_type) {case DPAA2_IO :@@ -1411,22 +1411,9 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - probe_all = rte_fslmc_bus.bus.conf.scan_mode != -RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { -if (drv->drv_type != dev->dev_type) -continue ; -if (rte_dev_is_probed (&dev->device)) -continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy == -RTE_DEV_ALLOWED )) { - ret = drv->remove (dev); -if (ret) -DPAA2_BUS_ERR ("Unable to remove" );Quoted 10 lines
drivers/bus/fslmc/fslmc_vfio.c fslmc_close_iodevices(struct rte_dpaa2_device *dev, · line 1415
Quoted 4 lines
drivers/bus/fslmc/fslmc_vfio.c +2
-2- } - } + drv = dev->driver; +if (drv && drv->remove && drv->remove (dev))Not new but
dpaa2_qdma_removedoesn't return an error which seems like a bug, but it has it's own log and it's just a log here anyway, so not critical.Quoted 1 line
drivers/bus/fslmc/fslmc_vfio.c +1
-0+DPAA2_BUS_ERR ("Unable to remove" );
Quoted 9 lines
Indeed, the dma/dpaa2 driver does not report errors.
And there is probably more to fix in the fslmc bus, as I see that the bus .unplug() does not check the driver .remove() return value either.I did not dig deeper in this bus for now as I was focusing on the devargs evaluation.
Could you open a bugzilla for tracking this issue?
Sure, I will do that
Quoted 3 lines
Thanks.
Re: [PATCH 2/8] bus/fslmc: fix bus cleanup
In reply to David MarchandRe: [PATCH 2/8] bus/fslmc: fix bus cleanup
In reply to David MarchandPATCH 3/8 drivers/bus: require probe function for NXP drivers
In reply to David MarchandRather than silently ignore an invalid driver, enforce every registered driver has a probe callback.
--- drivers/bus/dpaa/dpaa_bus.c | 6 +++--- drivers/bus/fslmc/fslmc_bus.c | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -3
@@ -614,6 +614,7 @@ void rte_dpaa_driver_register(struct rte_dpaa_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );BUS_INIT_FUNC_TRACE ();
@@ -808,9 +809,8 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (!drv->probe || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED )) +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED )continue ; if (probe_all ||
drivers/bus/fslmc/fslmc_bus.c +1 -6
@@ -465,9 +465,6 @@ rte_fslmc_probe(void)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
@@ -534,6 +531,7 @@ void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );TAILQ_INSERT_TAIL (&rte_fslmc_bus.driver_list, driver, next); }
@@ -601,9 +599,6 @@ fslmc_bus_plug(struct rte_device *rte_dev)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
Signature · 1 line
2.53.0
Re: [PATCH 3/8] drivers/bus: require probe function for NXP drivers
Quoted 57 lines · David Marchand
Rather than silently ignore an invalid driver, enforce every registered driver has a probe callback.
Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>--- drivers/bus/dpaa/dpaa_bus.c | 6 +++--- drivers/bus/fslmc/fslmc_bus.c | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-)drivers/bus/dpaa/dpaa_bus.c +3
-3@@ -614,6 +614,7 @@ void rte_dpaa_driver_register(struct rte_dpaa_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );BUS_INIT_FUNC_TRACE ();@@ -808,9 +809,8 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (!drv->probe || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED )) +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED )continue ; if (probe_all ||drivers/bus/fslmc/fslmc_bus.c +1
-3@@ -465,9 +465,6 @@ rte_fslmc_probe(void)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;@@ -534,6 +531,7 @@ void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );TAILQ_INSERT_TAIL (&rte_fslmc_bus.driver_list, driver, next); }
drivers/bus/fslmc/fslmc_bus.c fslmc_bus_plug(struct rte_device *rte_dev) · line 604
Quoted 9 lines
drivers/bus/fslmc/fslmc_bus.c +0
-3@@ -601,9 +599,6 @@ fslmc_bus_plug(struct rte_device *rte_dev)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
Re: [PATCH 3/8] drivers/bus: require probe function for NXP drivers
In reply to David MarchandQuoted 5 lines · David Marchand
Rather than silently ignore an invalid driver, enforce every registered driver has a probe callback.
Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>
Quoted 1 line
PATCH 4/8 drivers: cleanup devargs lookup in bus scan
In reply to David MarchandDon'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 call 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.
--- 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/bus_ifpga_driver.h | 2 -- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- 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 +- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 13 files changed, 15 insertions(+), 24 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +1 -1
@@ -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; }
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -2
@@ -28,8 +28,6 @@extern "C" {#endif -#define RTE_BUS_AUXILIARY_NAME "auxiliary" -/* Forward declarations */ struct rte_auxiliary_driver ;struct rte_auxiliary_device ;
drivers/bus/cdx/cdx.c +1 -2
@@ -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; }
drivers/bus/dpaa/dpaa_bus.c +2 -4
@@ -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 );
drivers/bus/fslmc/fslmc_bus.c +3 -5
@@ -26,7 +26,6 @@#include <dpaax_iova_table.h> #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups" -#define FSLMC_BUS_NAME fslmcstruct 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 {
@@ -704,5 +702,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 );
drivers/bus/ifpga/bus_ifpga_driver.h +0 -2
@@ -21,8 +21,6 @@extern "C" {#endif /* __cplusplus */ -#define IFPGA_BUS_NAME ifpga -/* Forward declarations */ struct rte_afu_device ;struct rte_afu_driver ;
drivers/bus/ifpga/ifpga_bus.c +2 -2
@@ -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,5 @@ 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_LOG_REGISTER_DEFAULT (ifpga_bus_logtype,NOTICE );
drivers/bus/pci/pci_common.c +1 -1
@@ -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;
drivers/bus/platform/platform.c +1 -1
@@ -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; }
drivers/bus/uacce/uacce.c +1 -1
@@ -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; }
drivers/bus/vdev/vdev.c +1 -1
@@ -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)
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -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 )
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
@@ -1823,7 +1823,7 @@ ifpga_cfg_probe(struct rte_vdev_device *vdev)snprintf (dev_name,RTE_RAWDEV_NAME_MAX_LEN ,"%d|%s" , args.port, args.bdf); - ret =rte_eal_hotplug_add (RTE_STR (IFPGA_BUS_NAME ), + ret =rte_eal_hotplug_add (vdev->device.devargs->bus->name, dev_name, vdev->device.devargs->args);if (ret) {rte_free (ifpga_dev->vdev_name[i]);
Signature · 1 line
2.53.0
Re: [PATCH 4/8] drivers: cleanup devargs lookup in bus scan
Quoted 136 lines · David Marchand
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 call was using an incorrect macro (
IFPGA_ARG_NAMEinstead ofIFPGA_BUS_NAME), yet it was working fine as this macro is aligned with the ifpga bus name.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>--- 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/bus_ifpga_driver.h | 2 -- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- 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 +- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 13 files changed, 15 insertions(+), 24 deletions(-)drivers/bus/auxiliary/auxiliary_common.c +1
-1@@ -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; }drivers/bus/auxiliary/bus_auxiliary_driver.h +0
-2@@ -28,8 +28,6 @@extern "C" {#endif -#define RTE_BUS_AUXILIARY_NAME "auxiliary" -/* Forward declarations */ struct rte_auxiliary_driver ;struct rte_auxiliary_device ;drivers/bus/cdx/cdx.c +1
-2@@ -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; }drivers/bus/dpaa/dpaa_bus.c +2
-4@@ -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 );drivers/bus/fslmc/fslmc_bus.c +2
-4@@ -26,7 +26,6 @@#include <dpaax_iova_table.h> #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups" -#define FSLMC_BUS_NAME fslmcstruct 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 {
drivers/bus/fslmc/fslmc_bus.c struct rte_fslmc_bus rte_fslmc_bus = { · line 706
Quoted 6 lines
drivers/bus/fslmc/fslmc_bus.c +1
-1@@ -704,5 +702,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 );
Re: [PATCH 4/8] drivers: cleanup devargs lookup in bus scan
In reply to David MarchandQuoted 12 lines · David Marchand
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 call was using an incorrect macro (
IFPGA_ARG_NAMEinstead ofIFPGA_BUS_NAME), yet it was working fine as this macro is aligned with the ifpga bus name.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>
Quoted 16 lines
--- 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/bus_ifpga_driver.h | 2 -- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- 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 +- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 13 files changed, 15 insertions(+), 24 deletions(-)
Re: [PATCH 4/8] drivers: cleanup devargs lookup in bus scan
In reply to David MarchandQuoted 4 lines · On Mon, 23 Mar 2026 11:52:58 +0100 David Marchand <[email protected]>…
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.
Quoted 8 lines
And remove the now useless macros.
Note: in the ifpga bus case, the call was using an incorrect macro (
IFPGA_ARG_NAMEinstead ofIFPGA_BUS_NAME), yet it was working fine as this macro is aligned with the ifpga bus name.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>
AI review feedback:
Patch 4/8: drivers: cleanup devargs lookup in bus scan
Error: In drivers/raw/ifpga/ifpga_rawdev.c, the change from RTE_STR(IFPGA_BUS_NAME) to vdev->device.devargs->bus->name passes the wrong bus name to rte_eal_hotplug_add(). The vdev is a vdev device (registered via --vdev ifpga_rawdev_cfg,...), so vdev->device.devargs->bus is the vdev bus, and its name is "vdev". The old code correctly passed "ifpga" to hotplug the device onto the ifpga bus. The new code would attempt to add the device to the vdev bus instead.
Suggested fix: use rte_ifpga_bus.name (the ifpga bus object) or a local string "ifpga" rather than deriving it from the vdev's devargs.
PATCH 5/8 bus: factorize devargs lookup
In reply to David MarchandEach bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.
---
Changes since RFC v3:
- fixed doxygen,
--- drivers/bus/auxiliary/auxiliary_common.c | 16 ++------- drivers/bus/cdx/cdx.c | 14 +------- drivers/bus/dpaa/dpaa_bus.c | 41 +++++++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 34 ++++++++++---------- drivers/bus/pci/pci_common.c | 38 +++++++++++----------- drivers/bus/platform/platform.c | 17 ++-------- drivers/bus/uacce/uacce.c | 19 ++--------- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 -- drivers/bus/vmbus/vmbus_common.c | 30 ++++++++--------- drivers/dma/idxd/idxd_bus.c | 14 ++------ lib/eal/common/eal_common_bus.c | 20 ++++++++++++ lib/eal/include/bus_driver.h | 31 ++++++++++++++++++ 13 files changed, 132 insertions(+), 147 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +2 -14
@@ -25,18 +25,6 @@#include "private.h" -static struct rte_devargs * -auxiliary_devargs_lookup (const char *name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(auxiliary_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } -return NULL ; -} -#ifndef AUXILIARY_OS_SUPPORTED /* * Test whether the auxiliary device exist.
@@ -68,7 +56,7 @@ auxiliary_scan(void)void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev) { - aux_dev->device.devargs =auxiliary_devargs_lookup (aux_dev->name); + aux_dev->device.devargs =rte_bus_find_devargs (&auxiliary_bus.bus, aux_dev->name); }/*
@@ -399,7 +387,7 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,bool auxiliary_is_ignored_device (const char *name) { -struct rte_devargs *devargs =auxiliary_devargs_lookup (name); +struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name);switch (auxiliary_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/cdx/cdx.c +1 -13
@@ -151,22 +151,10 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static struct rte_devargs * -cdx_devargs_lookup (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(rte_cdx_bus.bus.name, devargs) { -if (strcmp (devargs->name, dev_name) ==0 ) -return devargs; - } -return NULL ; -} -static bool cdx_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =cdx_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name);switch (rte_cdx_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/dpaa/dpaa_bus.c +22 -19
77 lines not on this page · raw message
drivers/bus/fslmc/fslmc_bus.c +17 -17
@@ -99,22 +99,6 @@ insert_in_device_list(struct rte_dpaa2_device *newdev)TAILQ_INSERT_TAIL (&rte_fslmc_bus.device_list, newdev, next); } -static struct rte_devargs * -fslmc_devargs_lookup (struct rte_dpaa2_device *dev) -{ -struct rte_devargs *devargs; -char dev_name[32 ]; - - 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); -return devargs; - } - } -return NULL ; -} -static void dump_device_list (void ) {
@@ -216,7 +200,10 @@ scan_one_fslmc_device(char *dev_name) ret = -ENOMEM ; goto cleanup; } - dev->device.devargs =fslmc_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus.bus, dev_name); +if (dev->device.devargs !=NULL ) +DPAA2_BUS_INFO ("**Devargs matched %s" , dev_name); +/* Update the device found into the device_count table */ rte_fslmc_bus.device_count[dev->dev_type]++;
@@ -308,6 +295,18 @@ rte_fslmc_parse(const char *name, void *addr)return ret; } +static int +fslmc_devname_compare (const char *name1,const char *name2) +{ +char devname1[32 ], devname2[32 ]; + +if (rte_fslmc_parse (name1, devname1) !=0 || +rte_fslmc_parse (name2, devname2) !=0 ) +return 1 ; + +return strncmp (devname1, devname2,sizeof (devname1)); +} +static int rte_fslmc_scan (void ) {
@@ -691,6 +690,7 @@ struct rte_fslmc_bus rte_fslmc_bus = { .probe = rte_fslmc_probe, .cleanup = rte_fslmc_close, .parse = rte_fslmc_parse, + .devname_compare = fslmc_devname_compare, .find_device = rte_fslmc_find_device, .get_iommu_class = rte_dpaa2_get_iommu_class, .plug = fslmc_bus_plug,
drivers/bus/pci/pci_common.c +19 -19
@@ -79,32 +79,15 @@ pci_asprintf(char **buffer, const char *format, ...) }#endif /* RTE_EXEC_ENV_WINDOWS */ -static struct rte_devargs * -pci_devargs_lookup (const struct rte_pci_addr *pci_addr) -{ -struct rte_devargs *devargs; -struct rte_pci_addr addr; - - 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; - } -return NULL ; -} - void pci_common_set(struct rte_pci_device *dev) { - struct rte_devargs *devargs; - /* Each device has its internal, canonical name set. */ rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name)); dev->device.name = dev->name; - devargs = pci_devargs_lookup(&dev->addr); - dev->device.devargs = devargs; + dev->device.devargs = rte_bus_find_devargs(&rte_pci_bus.bus, dev->name); if (dev->bus_info != NULL || asprintf(&dev->bus_info, "vendor_id=%"PRIx16", device_id=%"PRIx16,
@@ -503,6 +486,18 @@ pci_parse(const char *name, void *addr)return parse == false; } +static int +pci_devname_compare (const char *name1,const char *name2) +{ +struct rte_pci_addr addr1, addr2; + +if (rte_pci_addr_parse (name1, &addr1) !=0 || +rte_pci_addr_parse (name2, &addr2) !=0 ) +return 1 ; + +return rte_pci_addr_cmp (&addr1, &addr2); +} +/* register a driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_pci_register) void
@@ -721,7 +716,11 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) { -struct rte_devargs *devargs =pci_devargs_lookup (pci_addr); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_pci_device_name (pci_addr, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name);switch (rte_pci_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -946,6 +945,7 @@ struct rte_pci_bus rte_pci_bus = { .plug = pci_plug, .unplug = pci_unplug, .parse = pci_parse, + .devname_compare = pci_devname_compare, .devargs_parse = rte_pci_devargs_parse, .dma_map = pci_dma_map, .dma_unmap = pci_dma_unmap,
drivers/bus/platform/platform.c +2 -15
@@ -43,25 +43,12 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static struct rte_devargs * -dev_devargs (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(platform_bus.bus.name, devargs) { -if (!strcmp (devargs->name, dev_name)) -return devargs; - } - -return NULL ; -} -static bool dev_allowed (const char *dev_name) {struct rte_devargs *devargs; - devargs =dev_devargs (dev_name); + devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name);if (devargs ==NULL )return true;
@@ -93,7 +80,7 @@ dev_add(const char *dev_name)rte_strscpy (pdev->name, dev_name,sizeof (pdev->name)); pdev->device.name = pdev->name; - pdev->device.devargs =dev_devargs (dev_name); + pdev->device.devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); pdev->device.bus = &platform_bus.bus;snprintf (path,sizeof (path),PLATFORM_BUS_DEVICES_PATH "/%s/numa_node" , dev_name); pdev->device.numa_node =eal_parse_sysfs_value (path, &val) ?rte_socket_id () : val;
drivers/bus/uacce/uacce.c +2 -17
@@ -70,25 +70,10 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static struct rte_devargs * -uacce_devargs_lookup (const char *dev_name) -{ -char name[RTE_UACCE_DEV_PATH_SIZE ] = {0 }; -struct rte_devargs *devargs; - -snprintf (name,sizeof (name),"%s%s" ,UACCE_DEV_PREFIX , dev_name); - RTE_EAL_DEVARGS_FOREACH(uacce_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } - -return NULL ; -} -static bool uacce_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =uacce_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);switch (uacce_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -257,7 +242,7 @@ uacce_scan_one(const char *dev_name) dev->device.bus = &uacce_bus.bus; dev->device.name = dev->name; - dev->device.devargs =uacce_devargs_lookup (dev_name); + dev->device.devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);snprintf (dev->name,sizeof (dev->name),"%s" , dev_name);snprintf (dev->dev_root,sizeof (dev->dev_root),"%s/%s" ,UACCE_BUS_CLASS_PATH , dev_name);
drivers/bus/vmbus/linux/vmbus_bus.c +1 -1
@@ -333,7 +333,7 @@ vmbus_scan_one(const char *name) dev->monitor_id =UINT8_MAX ; } - dev->device.devargs =vmbus_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, dev_name); dev->device.numa_node =SOCKET_ID_ANY ;if (vmbus_use_numa (dev)) {
drivers/bus/vmbus/private.h +0 -3
@@ -98,9 +98,6 @@ struct vmbus_channel {#define VMBUS_MAX_CHANNELS 64 -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev); -int vmbus_chan_create (const struct rte_vmbus_device *device,uint16_t relid,uint16_t subid,uint8_t monitor_id,struct vmbus_channel **new_chan);
drivers/bus/vmbus/vmbus_common.c +13 -17
@@ -171,7 +171,11 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)static bool vmbus_ignore_device (struct rte_vmbus_device *dev) { -struct rte_devargs *devargs =vmbus_devargs_lookup (dev); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_uuid_unparse (dev->device_id, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name);switch (rte_vmbus_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -260,25 +264,16 @@ vmbus_parse(const char *name, void *addr)return ret; } -/* -* scan for matching device args on command line -* example: -* -a 'vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20' -*/ -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev) +static int +vmbus_devname_compare (const char *name1,const char *name2) { -struct rte_devargs *devargs; -rte_uuid_t addr; - - RTE_EAL_DEVARGS_FOREACH(rte_vmbus_bus.bus.name, devargs) { -vmbus_parse (devargs->name, &addr); +rte_uuid_t guid1, guid2; -if (rte_uuid_compare (dev->device_id, addr) ==0 ) -return devargs; - } -return NULL ; +if (vmbus_parse (name1, &guid1) !=0 || +vmbus_parse (name2, &guid2) !=0 ) +return 1 ; +return rte_uuid_compare (guid1, guid2); }/* register vmbus driver */
@@ -349,6 +344,7 @@ struct rte_vmbus_bus rte_vmbus_bus = { .cleanup = rte_vmbus_cleanup, .find_device = vmbus_find_device, .parse = vmbus_parse, + .devname_compare = vmbus_devname_compare, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.driver_list),
drivers/dma/idxd/idxd_bus.c +2 -12
@@ -247,16 +247,6 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return 0 ; } -static int search_devargs (const char *name) -{ -struct rte_devargs *devargs; - RTE_EAL_DEVARGS_FOREACH(dsa_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return 1 ; - } -return 0 ; -} -static int is_for_this_process_use (struct rte_dsa_device *dev,const char *name) {
@@ -275,9 +265,9 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) {if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ;else - retval = !search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; }return retval;
lib/eal/common/eal_common_bus.c +20 -0
@@ -8,6 +8,7 @@#include <bus_driver.h> #include <rte_debug.h> +#include <rte_devargs.h> #include <rte_string_fns.h> #include <rte_errno.h>
@@ -205,6 +206,25 @@ rte_bus_find_by_name(const char *busname)return rte_bus_find (NULL , cmp_bus_name, (const void *)busname); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_find_devargs) +struct rte_devargs * +rte_bus_find_devargs (const struct rte_bus *bus,const char *name) +{ +rte_bus_devname_compare_t cmp = bus->devname_compare; +struct rte_devargs *devargs; + +if (cmp ==NULL ) + cmp = strcmp; + + RTE_EAL_DEVARGS_FOREACH(rte_bus_name(bus), devargs) { +if (cmp (name, devargs->name) !=0 ) +continue ; +return devargs; + } + +return NULL ; +} +static int bus_can_parse (const struct rte_bus *bus,const void *_name) {
lib/eal/include/bus_driver.h +31 -0
@@ -118,6 +118,21 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);*/ typedef int (*rte_bus_parse_t )(const char *name,void *addr); +/** +* Bus specific device name comparison function. +* Bus can normalize the names of devices using an internal representation. +* This helper makes it possible to check whether two names refer to the same device. +* +* @param[in] name1 +* device information location address, +* @param[in] name2 +* device information location address, +* +* @return +* true or false +*/ +typedef int (*rte_bus_devname_compare_t )(const char *name1,const char *name2); +/** * Parse bus part of the device arguments. *
@@ -258,6 +273,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +rte_bus_devname_compare_t devname_compare;/**< Compare two device names */ rte_bus_devargs_parse_t devargs_parse;/**< Parse bus devargs */ rte_dev_dma_map_t dma_map;/**< DMA map for device in the bus */ rte_dev_dma_unmap_t dma_unmap;/**< DMA unmap for device in the bus */
@@ -281,6 +297,21 @@ struct rte_bus {__rte_internal void rte_bus_register(struct rte_bus *bus); +/** +* Find the devargs associated to a device. +* +* @param bus +* A pointer to a rte_bus structure describing the bus +* to be unregistered. +* @param dev_name +* A device name. +* +* @return +* Pointer to the device devargs, or NULL if none found. +*/ +__rte_internal +struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
Re: [PATCH 5/8] bus: factorize devargs lookup
Quoted 15 lines · David Marchand
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>---
Changes since RFC v3:
- fixed doxygen,
Quoted 15 lines
--- drivers/bus/auxiliary/auxiliary_common.c | 16 ++------- drivers/bus/cdx/cdx.c | 14 +------- drivers/bus/dpaa/dpaa_bus.c | 41 +++++++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 34 ++++++++++---------- drivers/bus/pci/pci_common.c | 38 +++++++++++----------- drivers/bus/platform/platform.c | 17 ++-------- drivers/bus/uacce/uacce.c | 19 ++--------- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 -- drivers/bus/vmbus/vmbus_common.c | 30 ++++++++--------- drivers/dma/idxd/idxd_bus.c | 14 ++------ lib/eal/common/eal_common_bus.c | 20 ++++++++++++ lib/eal/include/bus_driver.h | 31 ++++++++++++++++++ 13 files changed, 132 insertions(+), 147 deletions(-)
Re: [PATCH 5/8] bus: factorize devargs lookup
In reply to David MarchandQuoted 9 lines · On Mon, 23 Mar 2026 11:52:59 +0100 David Marchand <[email protected]>…
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.
Quoted 7 lines
Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>---
Changes since RFC v3:
- fixed doxygen,---
More AI review:
Patch 5/8: bus: factorize devargs lookup
Warning: The Doxygen for rte_bus_find_devargs() in bus_driver.h describes the bus parameter as "A pointer to a rte_bus structure describing the bus to be unregistered" -- this is copy-pasted from rte_bus_unregister. Should say something like "the bus to search for devargs on."
Warning: The Doxygen for rte_bus_devname_compare_t has two issues: the @return says "true or false" but the function follows strcmp semantics (0 for match, non-zero for no match), and the @param descriptions both say "device information location address" when they should say "device name string."
PATCH 6/8 bus: factorize device selection
In reply to David MarchandAll buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.
---
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,
--- drivers/bus/auxiliary/auxiliary_common.c | 19 ---------------- drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 ----- drivers/bus/cdx/cdx.c | 21 +----------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++-------------- drivers/bus/fslmc/fslmc_bus.c | 22 ++++++------------- drivers/bus/pci/bsd/pci.c | 5 ++++- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 23 ------------------- drivers/bus/pci/private.h | 11 ---------- drivers/bus/pci/windows/pci.c | 4 +++- drivers/bus/platform/platform.c | 28 ++---------------------- drivers/bus/uacce/uacce.c | 22 +------------------ drivers/bus/vmbus/vmbus_common.c | 25 +-------------------- drivers/dma/idxd/idxd_bus.c | 8 ++----- lib/eal/common/eal_common_bus.c | 19 ++++++++++++++++ lib/eal/include/bus_driver.h | 6 +++++ 17 files changed, 55 insertions(+), 192 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -19
@@ -384,25 +384,6 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,return aux_dev->driver->dma_unmap (aux_dev, addr, iova, len); } -bool -auxiliary_is_ignored_device (const char *name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name); - -switch (auxiliary_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -static enum rte_iova_mode auxiliary_get_iommu_class (void ) {
drivers/bus/auxiliary/linux/auxiliary.c +1 -1
@@ -110,7 +110,7 @@ auxiliary_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (auxiliary_is_ignored_device (e->d_name)) +if (rte_bus_is_ignored_device (&auxiliary_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/auxiliary/private.h +0 -6
@@ -53,12 +53,6 @@ int auxiliary_scan(void);*/ void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev); -/* -* Validate whether a device with given auxiliary device should be ignored -* or not. -*/ -bool auxiliary_is_ignored_device (const char *name); -/* * Add an auxiliary device to the auxiliary bus (append to auxiliary device * list). This function also updates the bus references of the auxiliary
drivers/bus/cdx/cdx.c +1 -20
@@ -151,25 +151,6 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static bool -cdx_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name); - -switch (rte_cdx_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan one cdx sysfs entry, and fill the devices list from it. * It checks if the CDX device is bound to vfio-cdx driver. In case
@@ -269,7 +250,7 @@ cdx_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (cdx_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&rte_cdx_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/dpaa/dpaa_bus.c +7 -17
@@ -717,7 +717,6 @@ rte_dpaa_bus_probe(void)struct rte_dpaa_driver *drv;FILE *svr_file =NULL ;uint32_t svr_ver; -int probe_all = rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ;static int process_once;char *penv;
@@ -725,9 +724,6 @@ rte_dpaa_bus_probe(void)if (!rte_dpaa_bus.detected)return 0 ; -if (rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ) - probe_all = true; - svr_file =fopen (DPAA_SOC_ID_FILE ,"r" );if (svr_file) {if (fscanf (svr_file,"svr:%x" , &svr_ver) >0 )
@@ -809,21 +805,15 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) +if (rte_bus_is_ignored_device (&rte_dpaa_bus.bus, dev->name))continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA_BUS_ERR ("unable to probe:%s" , - dev->name); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA_BUS_ERR ("unable to probe: %s" , dev->name); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/fslmc/fslmc_bus.c +7 -15
@@ -407,7 +407,6 @@ static intrte_fslmc_probe (void) {int ret =0 ; -int probe_all;struct rte_dpaa2_device *dev;struct rte_dpaa2_driver *drv;
@@ -454,8 +453,6 @@ rte_fslmc_probe(void)return 0 ; } - probe_all = rte_fslmc_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { ret =rte_fslmc_match (drv, dev);
@@ -465,23 +462,18 @@ rte_fslmc_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +if (rte_bus_is_ignored_device (&rte_fslmc_bus.bus, dev->device.name)) {DPAA2_BUS_LOG (DEBUG ,"%s Blocked, skipping" , dev->device.name);continue ; } -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA2_BUS_ERR ("Unable to probe" ); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/pci/bsd/pci.c +4 -1
@@ -370,12 +370,15 @@ rte_pci_scan(void) }for (i =0 ; i < conf_io.num_matches; i++) { +char name[RTE_DEV_NAME_MAX_LEN ]; + pci_addr.domain = matches[i].pc_sel.pc_domain; pci_addr.bus = matches[i].pc_sel.pc_bus; pci_addr.devid = matches[i].pc_sel.pc_dev; pci_addr.function = matches[i].pc_sel.pc_func; +rte_pci_device_name (&pci_addr, name,sizeof (name)); -if (rte_pci_ignore_device (&pci_addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name))continue ;if (pci_scan_one (fd, &matches[i]) <0 )
drivers/bus/pci/linux/pci.c +1 -1
@@ -458,7 +458,7 @@ rte_pci_scan(void)if (parse_pci_addr_format (e->d_name,sizeof (e->d_name), &addr) !=0 )continue ; -if (rte_pci_ignore_device (&addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/pci/pci_common.c +0 -23
@@ -713,29 +713,6 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)return -1 ; } -bool -rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_pci_device_name (pci_addr, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name); - -switch (rte_pci_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -enum rte_iova_mode rte_pci_get_iommu_class (void ) {
drivers/bus/pci/private.h +0 -11
@@ -82,17 +82,6 @@ pci_common_set(struct rte_pci_device *dev);void pci_free (struct rte_pci_device_internal *pdev); -/** -* Validate whether a device with given PCI address should be ignored or not. -* -* @param pci_addr -* PCI address of device to be validated -* @return -* true: if device is to be ignored, -* false: if device is to be scanned, -*/ -bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr); -/** * Add a PCI device to the PCI Bus (append to PCI Device list). This function * also updates the bus references of the PCI Device (and the generic device
drivers/bus/pci/windows/pci.c +3 -1
@@ -373,6 +373,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)struct rte_pci_device *dev =NULL ;int ret =-1 ;char pci_device_info[REGSTR_VAL_MAX_HCID_LEN ]; +char name[RTE_DEV_NAME_MAX_LEN ];struct rte_pci_addr addr;struct rte_pci_id pci_id;
@@ -380,7 +381,8 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)if (ret !=0 ) goto end; -if (rte_pci_ignore_device (&addr)) { +rte_pci_device_name (&addr, name,sizeof (name)); +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name)) {/* * We won't add this device, but we want to continue * looking for supported devices
drivers/bus/platform/platform.c +2 -26
@@ -43,30 +43,6 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static bool -dev_allowed (const char *dev_name) -{ -struct rte_devargs *devargs; - - devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); -if (devargs ==NULL ) -return true; - -switch (platform_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs->policy ==RTE_DEV_ALLOWED ) -return true; -break ; -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs->policy ==RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -static int dev_add (const char *dev_name) {
@@ -160,7 +136,7 @@ platform_bus_scan(void)if (dev_name[0 ] =='.' )continue ; -if (!dev_allowed (dev_name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev_name))continue ;if (!dev_is_bound_vfio_platform (dev_name))
@@ -484,7 +460,7 @@ platform_bus_plug(struct rte_device *dev) {struct rte_platform_device *pdev; -if (!dev_allowed (dev->name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev->name))return -EPERM ;if (!dev_is_bound_vfio_platform (dev->name))
drivers/bus/uacce/uacce.c +1 -21
@@ -70,26 +70,6 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static bool -uacce_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name); - -switch (uacce_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -/* * Returns the number of bytes read (removed last newline) on success. * Otherwise negative value is returned.
@@ -296,7 +276,7 @@ uacce_scan(void)continue ; } -if (uacce_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&uacce_bus.bus, e->d_name))continue ;if (uacce_scan_one (e->d_name) <0 )
drivers/bus/vmbus/vmbus_common.c +1 -24
@@ -168,29 +168,6 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)return 1 ; } -static bool -vmbus_ignore_device (struct rte_vmbus_device *dev) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_uuid_unparse (dev->device_id, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name); - -switch (rte_vmbus_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan the vmbus, and call the devinit() function for * all registered drivers that have a matching entry in its id_table
@@ -209,7 +186,7 @@ rte_vmbus_probe(void)rte_uuid_unparse (dev->device_id, ubuf,sizeof (ubuf)); -if (vmbus_ignore_device (dev)) +if (rte_bus_is_ignored_device (&rte_vmbus_bus.bus, ubuf))continue ;if (vmbus_probe_all_drivers (dev) <0 ) {
drivers/dma/idxd/idxd_bus.c +2 -6
@@ -263,12 +263,8 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' ) retval =1 ; -if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) { -if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ; -else - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; - } +if (retval && !rte_bus_is_ignored_device (&dsa_bus.bus, dev->device.name)) + retval =1 ;return retval; }
lib/eal/common/eal_common_bus.c +19 -0
@@ -246,6 +246,25 @@ rte_bus_find_by_device_name(const char *str)return rte_bus_find (NULL , bus_can_parse, name); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_is_ignored_device) +bool +rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) +{ +struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); + +switch (bus->conf.scan_mode) { +case RTE_BUS_SCAN_ALLOWLIST : +if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) +return false; +break ; +case RTE_BUS_SCAN_UNDEFINED : +case RTE_BUS_SCAN_BLOCKLIST : +if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) +return false; +break ; + } +return true; +}/* * Get iommu class of devices on the bus.
lib/eal/include/bus_driver.h +6 -0
@@ -312,6 +312,12 @@ void rte_bus_register(struct rte_bus *bus);__rte_internal struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** +* Indicate if a device should be skipped during probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
Re: [PATCH 6/8] bus: factorize device selection
Quoted 489 lines · David Marchand
All buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Reviewed-by Robin Jarry <[email protected]>---
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,--- drivers/bus/auxiliary/auxiliary_common.c | 19 ---------------- drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 ----- drivers/bus/cdx/cdx.c | 21 +----------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++-------------- drivers/bus/fslmc/fslmc_bus.c | 22 ++++++------------- drivers/bus/pci/bsd/pci.c | 5 ++++- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 23 ------------------- drivers/bus/pci/private.h | 11 ---------- drivers/bus/pci/windows/pci.c | 4 +++- drivers/bus/platform/platform.c | 28 ++---------------------- drivers/bus/uacce/uacce.c | 22 +------------------ drivers/bus/vmbus/vmbus_common.c | 25 +-------------------- drivers/dma/idxd/idxd_bus.c | 8 ++----- lib/eal/common/eal_common_bus.c | 19 ++++++++++++++++ lib/eal/include/bus_driver.h | 6 +++++ 17 files changed, 55 insertions(+), 192 deletions(-)drivers/bus/auxiliary/auxiliary_common.c +0
-19@@ -384,25 +384,6 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,return aux_dev->driver->dma_unmap (aux_dev, addr, iova, len); } -bool -auxiliary_is_ignored_device (const char *name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name); - -switch (auxiliary_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -static enum rte_iova_mode auxiliary_get_iommu_class (void ) {drivers/bus/auxiliary/linux/auxiliary.c +1
-1@@ -110,7 +110,7 @@ auxiliary_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (auxiliary_is_ignored_device (e->d_name)) +if (rte_bus_is_ignored_device (&auxiliary_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",drivers/bus/auxiliary/private.h +0
-6@@ -53,12 +53,6 @@ int auxiliary_scan(void);*/ void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev); -/* -* Validate whether a device with given auxiliary device should be ignored -* or not. -*/ -bool auxiliary_is_ignored_device (const char *name); -/* * Add an auxiliary device to the auxiliary bus (append to auxiliary device * list). This function also updates the bus references of the auxiliary drivers/bus/cdx/cdx.c +1
-20@@ -151,25 +151,6 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static bool -cdx_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name); - -switch (rte_cdx_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan one cdx sysfs entry, and fill the devices list from it. * It checks if the CDX device is bound to vfio-cdx driver. In case @@ -269,7 +250,7 @@ cdx_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (cdx_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&rte_cdx_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",drivers/bus/dpaa/dpaa_bus.c +7
-17@@ -717,7 +717,6 @@ rte_dpaa_bus_probe(void)struct rte_dpaa_driver *drv;FILE *svr_file =NULL ;uint32_t svr_ver; -int probe_all = rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ;static int process_once;char *penv;@@ -725,9 +724,6 @@ rte_dpaa_bus_probe(void)if (!rte_dpaa_bus.detected)return 0 ; -if (rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ) - probe_all = true; - svr_file =fopen (DPAA_SOC_ID_FILE ,"r" );if (svr_file) {if (fscanf (svr_file,"svr:%x" , &svr_ver) >0 )@@ -809,21 +805,15 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) +if (rte_bus_is_ignored_device (&rte_dpaa_bus.bus, dev->name))continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA_BUS_ERR ("unable to probe:%s" , - dev->name); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA_BUS_ERR ("unable to probe: %s" , dev->name); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }drivers/bus/fslmc/fslmc_bus.c +7
-15@@ -407,7 +407,6 @@ static intrte_fslmc_probe (void) {int ret =0 ; -int probe_all;struct rte_dpaa2_device *dev;struct rte_dpaa2_driver *drv;@@ -454,8 +453,6 @@ rte_fslmc_probe(void)return 0 ; } - probe_all = rte_fslmc_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { ret =rte_fslmc_match (drv, dev);@@ -465,23 +462,18 @@ rte_fslmc_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +if (rte_bus_is_ignored_device (&rte_fslmc_bus.bus, dev->device.name)) {DPAA2_BUS_LOG (DEBUG ,"%s Blocked, skipping" , dev->device.name);continue ; } -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA2_BUS_ERR ("Unable to probe" ); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }drivers/bus/pci/bsd/pci.c +4
-1@@ -370,12 +370,15 @@ rte_pci_scan(void) }for (i =0 ; i < conf_io.num_matches; i++) { +char name[RTE_DEV_NAME_MAX_LEN ]; + pci_addr.domain = matches[i].pc_sel.pc_domain; pci_addr.bus = matches[i].pc_sel.pc_bus; pci_addr.devid = matches[i].pc_sel.pc_dev; pci_addr.function = matches[i].pc_sel.pc_func; +rte_pci_device_name (&pci_addr, name,sizeof (name)); -if (rte_pci_ignore_device (&pci_addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name))continue ;if (pci_scan_one (fd, &matches[i]) <0 )drivers/bus/pci/linux/pci.c +1
-1@@ -458,7 +458,7 @@ rte_pci_scan(void)if (parse_pci_addr_format (e->d_name,sizeof (e->d_name), &addr) !=0 )continue ; -if (rte_pci_ignore_device (&addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",drivers/bus/pci/pci_common.c +0
-23@@ -713,29 +713,6 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)return -1 ; } -bool -rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_pci_device_name (pci_addr, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name); - -switch (rte_pci_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -enum rte_iova_mode rte_pci_get_iommu_class (void ) {drivers/bus/pci/private.h +0
-11@@ -82,17 +82,6 @@ pci_common_set(struct rte_pci_device *dev);void pci_free (struct rte_pci_device_internal *pdev); -/** -* Validate whether a device with given PCI address should be ignored or not. -* -* @param pci_addr -* PCI address of device to be validated -* @return -* true: if device is to be ignored, -* false: if device is to be scanned, -*/ -bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr); -/** * Add a PCI device to the PCI Bus (append to PCI Device list). This function * also updates the bus references of the PCI Device (and the generic device drivers/bus/pci/windows/pci.c +3
-1@@ -373,6 +373,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)struct rte_pci_device *dev =NULL ;int ret =-1 ;char pci_device_info[REGSTR_VAL_MAX_HCID_LEN ]; +char name[RTE_DEV_NAME_MAX_LEN ];struct rte_pci_addr addr;struct rte_pci_id pci_id;@@ -380,7 +381,8 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)if (ret !=0 ) goto end; -if (rte_pci_ignore_device (&addr)) { +rte_pci_device_name (&addr, name,sizeof (name)); +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name)) {/* * We won't add this device, but we want to continue * looking for supported devices drivers/bus/platform/platform.c +2
-26@@ -43,30 +43,6 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static bool -dev_allowed (const char *dev_name) -{ -struct rte_devargs *devargs; - - devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); -if (devargs ==NULL ) -return true; - -switch (platform_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs->policy ==RTE_DEV_ALLOWED ) -return true; -break ; -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs->policy ==RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -static int dev_add (const char *dev_name) {@@ -160,7 +136,7 @@ platform_bus_scan(void)if (dev_name[0 ] =='.' )continue ; -if (!dev_allowed (dev_name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev_name))continue ;if (!dev_is_bound_vfio_platform (dev_name))@@ -484,7 +460,7 @@ platform_bus_plug(struct rte_device *dev) {struct rte_platform_device *pdev; -if (!dev_allowed (dev->name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev->name))return -EPERM ;if (!dev_is_bound_vfio_platform (dev->name))drivers/bus/uacce/uacce.c +1
-21@@ -70,26 +70,6 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static bool -uacce_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name); - -switch (uacce_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -/* * Returns the number of bytes read (removed last newline) on success. * Otherwise negative value is returned. @@ -296,7 +276,7 @@ uacce_scan(void)continue ; } -if (uacce_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&uacce_bus.bus, e->d_name))continue ;if (uacce_scan_one (e->d_name) <0 )drivers/bus/vmbus/vmbus_common.c +1
-24@@ -168,29 +168,6 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)return 1 ; } -static bool -vmbus_ignore_device (struct rte_vmbus_device *dev) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_uuid_unparse (dev->device_id, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name); - -switch (rte_vmbus_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan the vmbus, and call the devinit() function for * all registered drivers that have a matching entry in its id_table @@ -209,7 +186,7 @@ rte_vmbus_probe(void)rte_uuid_unparse (dev->device_id, ubuf,sizeof (ubuf)); -if (vmbus_ignore_device (dev)) +if (rte_bus_is_ignored_device (&rte_vmbus_bus.bus, ubuf))continue ;if (vmbus_probe_all_drivers (dev) <0 ) {drivers/dma/idxd/idxd_bus.c +0
-0@@ -263,12 +263,8 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' )
drivers/dma/idxd/idxd_bus.c is_for_this_process_use(struct rte_dsa_device *dev, const char *name) · line 267
Quoted 10 lines
drivers/dma/idxd/idxd_bus.c +2
-6retval =1 ; -if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) { -if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ; -else - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; - } +if (retval && !rte_bus_is_ignored_device (&dsa_bus.bus, dev->device.name)) + retval =1 ;
hmm, should this be
if (retval && rte_bus_is_ignored_device(&dsa_bus.bus, dev->device.name))
retval = 0;
Quoted 50 lines
drivers/dma/idxd/idxd_bus.c +0
-0return retval; }lib/eal/common/eal_common_bus.c +19
-0@@ -246,6 +246,25 @@ rte_bus_find_by_device_name(const char *str)return rte_bus_find (NULL , bus_can_parse, name); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_is_ignored_device) +bool +rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) +{ +struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); + +switch (bus->conf.scan_mode) { +case RTE_BUS_SCAN_ALLOWLIST : +if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) +return false; +break ; +case RTE_BUS_SCAN_UNDEFINED : +case RTE_BUS_SCAN_BLOCKLIST : +if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) +return false; +break ; + } +return true; +}/* * Get iommu class of devices on the bus. lib/eal/include/bus_driver.h +6
-0@@ -312,6 +312,12 @@ void rte_bus_register(struct rte_bus *bus);__rte_internal struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** +* Indicate if a device should be skipped during probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Re: [PATCH 6/8] bus: factorize device selection
Quoted 19 lines · Kevin Traynor
Quoted 6 lines
drivers/dma/idxd/idxd_bus.c +0
-0@@ -263,12 +263,8 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' )drivers/dma/idxd/idxd_bus.c is_for_this_process_use(struct rte_dsa_device *dev, const char *name) · line 267
Quoted 10 lines
drivers/dma/idxd/idxd_bus.c +2
-6retval =1 ; -if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) { -if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ; -else - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; - } +if (retval && !rte_bus_is_ignored_device (&dsa_bus.bus, dev->device.name)) + retval =1 ;hmm, should this be
Quoted 6 lines
if (retval &&
rte_bus_is_ignored_device(&dsa_bus.bus, dev->device.name))retval = 0;Quoted 3 lines
drivers/dma/idxd/idxd_bus.c +0
-0return retval; }
Indeed, something is wrong with my change.
I will go with a if (retval) retval = !rte_bus_is_ignored_device(&dsa_bus.bus, dev->device.name);
Signature · 1 line
David Marchand
Re: [PATCH 6/8] bus: factorize device selection
In reply to David MarchandQuoted 5 lines · On Mon, 23 Mar 2026 11:53:00 +0100 David Marchand <[email protected]>…
All buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.
Quoted 7 lines
Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Reviewed-by Robin Jarry <[email protected]>---
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,
AI review found some issues in this one:
**Error**: In drivers/dma/idxd/idxd_bus.c, the refactored is_for_this_process_use has a logic error. The old code could set retval to 0 when a device was blocked:
```c
/* Old - retval could be set to 0 */
if (dsa_bus.bus.conf.scan_mode == RTE_BUS_SCAN_ALLOWLIST)
retval = rte_bus_find_devargs(...) != NULL;
else
retval = rte_bus_find_devargs(...) == NULL;
```The new code only ever sets retval = 1, never clearing it:
```c
/* New - retval is never set to 0 */
if (retval && !rte_bus_is_ignored_device(&dsa_bus.bus, dev->device.name))
retval = 1;
```If a device should be ignored (blocked or not on the allow list), rte_bus_is_ignored_device returns true, the condition is false, and retval stays 1 from the earlier name-matching check. Blocked devices will incorrectly pass through.
Suggested fix:
```c
if (retval)
retval = !rte_bus_is_ignored_device(&dsa_bus.bus, dev->device.name);
```PATCH 7/8 bus: remove per bus scan mode
In reply to David MarchandFollowing the refactoring of device selection, it becomes more apparent that there is no need for a per bus scan mode.
-a / -b options are mutually exclusive.
--vdev option works in parallel of allow/block list scan mode.
Remove this (internal) notion.
--- lib/eal/common/eal_common_bus.c | 20 ++++++++++++++++++- lib/eal/common/eal_common_devargs.c | 8 +++----- lib/eal/common/eal_private.h | 31 +++++++++++++++++++++++++++++ lib/eal/include/bus_driver.h | 18 ----------------- 4 files changed, 53 insertions(+), 24 deletions(-)
lib/eal/common/eal_common_bus.c +19 -1
@@ -18,6 +18,8 @@static struct rte_bus_list rte_bus_list =TAILQ_HEAD_INITIALIZER (rte_bus_list); +static enum rte_bus_scan_mode bus_scan_mode; +RTE_EXPORT_SYMBOL (rte_bus_name) const char *rte_bus_name (const struct rte_bus *bus)
@@ -252,7 +254,7 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name) {struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); -switch (bus->conf.scan_mode) { +switch (rte_bus_scan_mode_get ()) {case RTE_BUS_SCAN_ALLOWLIST :if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false;
@@ -266,6 +268,22 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name)return true; } +enum rte_bus_scan_mode +rte_bus_scan_mode_get (void ) +{ +return bus_scan_mode; +} + +int +rte_bus_scan_mode_set (enum rte_bus_scan_mode scan_mode) +{ +if (bus_scan_mode !=RTE_BUS_SCAN_UNDEFINED ) +return -EINVAL ; + + bus_scan_mode = scan_mode; +return 0 ; +} +/* * Get iommu class of devices on the bus. */
lib/eal/common/eal_common_devargs.c +3 -5
@@ -330,7 +330,6 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) { struct rte_devargs *devargs = NULL; -struct rte_bus *bus =NULL ;const char *dev = devargs_str;/* use calloc instead of rte_zmalloc as it's called early at init */
@@ -341,14 +340,13 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)if (rte_devargs_parse (devargs, dev)) goto fail; devargs->type = devtype; - bus = devargs->bus;if (devargs->type ==RTE_DEVTYPE_BLOCKED ) devargs->policy =RTE_DEV_BLOCKED ; -if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (rte_bus_scan_mode_get () ==RTE_BUS_SCAN_UNDEFINED ) {if (devargs->policy ==RTE_DEV_ALLOWED ) - bus->conf.scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +rte_bus_scan_mode_set (RTE_BUS_SCAN_ALLOWLIST );else if (devargs->policy ==RTE_DEV_BLOCKED ) - bus->conf.scan_mode =RTE_BUS_SCAN_BLOCKLIST ; +rte_bus_scan_mode_set (RTE_BUS_SCAN_BLOCKLIST ); }TAILQ_INSERT_TAIL (&devargs_list, devargs, next);return 0 ;
lib/eal/common/eal_private.h +31 -0
@@ -469,6 +469,37 @@ int rte_eal_memory_detach(void);*/ struct rte_bus *rte_bus_find_by_device_name (const char *str); +/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_ALLOWLIST , +RTE_BUS_SCAN_BLOCKLIST , +}; + +/** +* Retrieve the current bus scanning mode. +* +* @return +* The current bus scanning mode. +*/ +enum rte_bus_scan_mode rte_bus_scan_mode_get (void ); + +/** +* Change the bus scanning mode. +* Changing the mode can only be done once from undefined to allow list or to block list. +* No change from allow to block (or vice versa) is allowed. +* +* @param scan_mode +* The scanning mode to apply. +* +* @return +* 0 on successful change. +* < 0 on failure. +*/ +int rte_bus_scan_mode_set (enum rte_bus_scan_mode scan_mode); +/** * For each device on the buses, call the driver-specific function for * device cleanup.
lib/eal/include/bus_driver.h +0 -18
@@ -232,23 +232,6 @@ typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);*/ typedef int (*rte_bus_cleanup_t )(void ); -/** -* Bus scan policies -*/ -enum rte_bus_scan_mode { -RTE_BUS_SCAN_UNDEFINED , -RTE_BUS_SCAN_ALLOWLIST , -RTE_BUS_SCAN_BLOCKLIST , -}; - -/** -* A structure used to configure bus operations. -*/ -struct rte_bus_conf { -enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ -}; - -/** * Get common iommu class of the all the devices on the bus. The bus may * check that those devices are attached to iommu driver.
@@ -277,7 +260,6 @@ struct rte_bus {rte_bus_devargs_parse_t devargs_parse;/**< Parse bus devargs */ rte_dev_dma_map_t dma_map;/**< DMA map for device in the bus */ rte_dev_dma_unmap_t dma_unmap;/**< DMA unmap for device in the bus */ -struct rte_bus_conf conf;/**< Bus configuration */ rte_bus_get_iommu_class_t get_iommu_class;/**< Get iommu class */ rte_dev_iterate_t dev_iterate;/**< Device iterator. */ rte_bus_hot_unplug_handler_t hot_unplug_handler;
Signature · 1 line
2.53.0
Re: [PATCH 7/8] bus: remove per bus scan mode
Quoted 5 lines · David Marchand
Following the refactoring of device selection, it becomes more apparent that there is no need for a per bus scan mode.
-a / -b options are mutually exclusive.
--vdev option works in parallel of allow/block list scan mode.
-a/-b are mutually exclusive but does it mean "-a 0000:01:00.0" stops default probe for all devices on other buses ? Is it a change in behavior ?
(I could probably test but I guess you thought about this case given the nature of patch.)
Quoted 163 lines
Remove this (internal) notion.
Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_bus.c | 20 ++++++++++++++++++- lib/eal/common/eal_common_devargs.c | 8 +++----- lib/eal/common/eal_private.h | 31 +++++++++++++++++++++++++++++ lib/eal/include/bus_driver.h | 18 ----------------- 4 files changed, 53 insertions(+), 24 deletions(-)lib/eal/common/eal_common_bus.c +19
-1@@ -18,6 +18,8 @@static struct rte_bus_list rte_bus_list =TAILQ_HEAD_INITIALIZER (rte_bus_list); +static enum rte_bus_scan_mode bus_scan_mode; +RTE_EXPORT_SYMBOL (rte_bus_name) const char *rte_bus_name (const struct rte_bus *bus)@@ -252,7 +254,7 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name) {struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); -switch (bus->conf.scan_mode) { +switch (rte_bus_scan_mode_get ()) {case RTE_BUS_SCAN_ALLOWLIST :if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false;@@ -266,6 +268,22 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name)return true; } +enum rte_bus_scan_mode +rte_bus_scan_mode_get (void ) +{ +return bus_scan_mode; +} + +int +rte_bus_scan_mode_set (enum rte_bus_scan_mode scan_mode) +{ +if (bus_scan_mode !=RTE_BUS_SCAN_UNDEFINED ) +return -EINVAL ; + + bus_scan_mode = scan_mode; +return 0 ; +} +/* * Get iommu class of devices on the bus. */ lib/eal/common/eal_common_devargs.c +3
-5@@ -330,7 +330,6 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) { struct rte_devargs *devargs = NULL; -struct rte_bus *bus =NULL ;const char *dev = devargs_str;/* use calloc instead of rte_zmalloc as it's called early at init */ @@ -341,14 +340,13 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)if (rte_devargs_parse (devargs, dev)) goto fail; devargs->type = devtype; - bus = devargs->bus;if (devargs->type ==RTE_DEVTYPE_BLOCKED ) devargs->policy =RTE_DEV_BLOCKED ; -if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (rte_bus_scan_mode_get () ==RTE_BUS_SCAN_UNDEFINED ) {if (devargs->policy ==RTE_DEV_ALLOWED ) - bus->conf.scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +rte_bus_scan_mode_set (RTE_BUS_SCAN_ALLOWLIST );else if (devargs->policy ==RTE_DEV_BLOCKED ) - bus->conf.scan_mode =RTE_BUS_SCAN_BLOCKLIST ; +rte_bus_scan_mode_set (RTE_BUS_SCAN_BLOCKLIST ); }TAILQ_INSERT_TAIL (&devargs_list, devargs, next);return 0 ;lib/eal/common/eal_private.h +31
-0@@ -469,6 +469,37 @@ int rte_eal_memory_detach(void);*/ struct rte_bus *rte_bus_find_by_device_name (const char *str); +/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_ALLOWLIST , +RTE_BUS_SCAN_BLOCKLIST , +}; + +/** +* Retrieve the current bus scanning mode. +* +* @return +* The current bus scanning mode. +*/ +enum rte_bus_scan_mode rte_bus_scan_mode_get (void ); + +/** +* Change the bus scanning mode. +* Changing the mode can only be done once from undefined to allow list or to block list. +* No change from allow to block (or vice versa) is allowed. +* +* @param scan_mode +* The scanning mode to apply. +* +* @return +* 0 on successful change. +* < 0 on failure. +*/ +int rte_bus_scan_mode_set (enum rte_bus_scan_mode scan_mode); +/** * For each device on the buses, call the driver-specific function for * device cleanup. lib/eal/include/bus_driver.h +0
-18@@ -232,23 +232,6 @@ typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);*/ typedef int (*rte_bus_cleanup_t )(void ); -/** -* Bus scan policies -*/ -enum rte_bus_scan_mode { -RTE_BUS_SCAN_UNDEFINED , -RTE_BUS_SCAN_ALLOWLIST , -RTE_BUS_SCAN_BLOCKLIST , -}; - -/** -* A structure used to configure bus operations. -*/ -struct rte_bus_conf { -enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ -}; - -/** * Get common iommu class of the all the devices on the bus. The bus may * check that those devices are attached to iommu driver. @@ -277,7 +260,6 @@ struct rte_bus {rte_bus_devargs_parse_t devargs_parse;/**< Parse bus devargs */ rte_dev_dma_map_t dma_map;/**< DMA map for device in the bus */ rte_dev_dma_unmap_t dma_unmap;/**< DMA unmap for device in the bus */ -struct rte_bus_conf conf;/**< Bus configuration */ rte_bus_get_iommu_class_t get_iommu_class;/**< Get iommu class */ rte_dev_iterate_t dev_iterate;/**< Device iterator. */ rte_bus_hot_unplug_handler_t hot_unplug_handler;
Re: [PATCH 7/8] bus: remove per bus scan mode
Quoted 10 lines · Kevin Traynor
Quoted 5 lines · David Marchand
Following the refactoring of device selection, it becomes more apparent that there is no need for a per bus scan mode.
-a / -b options are mutually exclusive.
--vdev option works in parallel of allow/block list scan mode.-a/-b are mutually exclusive but does it mean "-a 0000:01:00.0" stops default probe for all devices on other buses ? Is it a change in behavior ?
Given that -a/-b are not mutually exclusive, i suppose we can say the current behavior is designed to be global and there should not be independence between buses, which is in keeping with what is done in this patch.
Quoted 167 lines
(I could probably test but I guess you thought about this case given the nature of patch.)
Quoted 163 lines
Remove this (internal) notion.
Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_bus.c | 20 ++++++++++++++++++- lib/eal/common/eal_common_devargs.c | 8 +++----- lib/eal/common/eal_private.h | 31 +++++++++++++++++++++++++++++ lib/eal/include/bus_driver.h | 18 ----------------- 4 files changed, 53 insertions(+), 24 deletions(-)lib/eal/common/eal_common_bus.c +19
-1@@ -18,6 +18,8 @@static struct rte_bus_list rte_bus_list =TAILQ_HEAD_INITIALIZER (rte_bus_list); +static enum rte_bus_scan_mode bus_scan_mode; +RTE_EXPORT_SYMBOL (rte_bus_name) const char *rte_bus_name (const struct rte_bus *bus)@@ -252,7 +254,7 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name) {struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); -switch (bus->conf.scan_mode) { +switch (rte_bus_scan_mode_get ()) {case RTE_BUS_SCAN_ALLOWLIST :if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false;@@ -266,6 +268,22 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name)return true; } +enum rte_bus_scan_mode +rte_bus_scan_mode_get (void ) +{ +return bus_scan_mode; +} + +int +rte_bus_scan_mode_set (enum rte_bus_scan_mode scan_mode) +{ +if (bus_scan_mode !=RTE_BUS_SCAN_UNDEFINED ) +return -EINVAL ; + + bus_scan_mode = scan_mode; +return 0 ; +} +/* * Get iommu class of devices on the bus. */ lib/eal/common/eal_common_devargs.c +3
-5@@ -330,7 +330,6 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) { struct rte_devargs *devargs = NULL; -struct rte_bus *bus =NULL ;const char *dev = devargs_str;/* use calloc instead of rte_zmalloc as it's called early at init */ @@ -341,14 +340,13 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)if (rte_devargs_parse (devargs, dev)) goto fail; devargs->type = devtype; - bus = devargs->bus;if (devargs->type ==RTE_DEVTYPE_BLOCKED ) devargs->policy =RTE_DEV_BLOCKED ; -if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (rte_bus_scan_mode_get () ==RTE_BUS_SCAN_UNDEFINED ) {if (devargs->policy ==RTE_DEV_ALLOWED ) - bus->conf.scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +rte_bus_scan_mode_set (RTE_BUS_SCAN_ALLOWLIST );else if (devargs->policy ==RTE_DEV_BLOCKED ) - bus->conf.scan_mode =RTE_BUS_SCAN_BLOCKLIST ; +rte_bus_scan_mode_set (RTE_BUS_SCAN_BLOCKLIST ); }TAILQ_INSERT_TAIL (&devargs_list, devargs, next);return 0 ;lib/eal/common/eal_private.h +31
-0@@ -469,6 +469,37 @@ int rte_eal_memory_detach(void);*/ struct rte_bus *rte_bus_find_by_device_name (const char *str); +/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_ALLOWLIST , +RTE_BUS_SCAN_BLOCKLIST , +}; + +/** +* Retrieve the current bus scanning mode. +* +* @return +* The current bus scanning mode. +*/ +enum rte_bus_scan_mode rte_bus_scan_mode_get (void ); + +/** +* Change the bus scanning mode. +* Changing the mode can only be done once from undefined to allow list or to block list. +* No change from allow to block (or vice versa) is allowed. +* +* @param scan_mode +* The scanning mode to apply. +* +* @return +* 0 on successful change. +* < 0 on failure. +*/ +int rte_bus_scan_mode_set (enum rte_bus_scan_mode scan_mode); +/** * For each device on the buses, call the driver-specific function for * device cleanup. lib/eal/include/bus_driver.h +0
-18@@ -232,23 +232,6 @@ typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);*/ typedef int (*rte_bus_cleanup_t )(void ); -/** -* Bus scan policies -*/ -enum rte_bus_scan_mode { -RTE_BUS_SCAN_UNDEFINED , -RTE_BUS_SCAN_ALLOWLIST , -RTE_BUS_SCAN_BLOCKLIST , -}; - -/** -* A structure used to configure bus operations. -*/ -struct rte_bus_conf { -enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ -}; - -/** * Get common iommu class of the all the devices on the bus. The bus may * check that those devices are attached to iommu driver. @@ -277,7 +260,6 @@ struct rte_bus {rte_bus_devargs_parse_t devargs_parse;/**< Parse bus devargs */ rte_dev_dma_map_t dma_map;/**< DMA map for device in the bus */ rte_dev_dma_unmap_t dma_unmap;/**< DMA unmap for device in the bus */ -struct rte_bus_conf conf;/**< Bus configuration */ rte_bus_get_iommu_class_t get_iommu_class;/**< Get iommu class */ rte_dev_iterate_t dev_iterate;/**< Device iterator. */ rte_bus_hot_unplug_handler_t hot_unplug_handler;
Re: [PATCH 7/8] bus: remove per bus scan mode
In reply to Kevin TraynorQuoted 8 lines · Kevin Traynor
Quoted 5 lines · David Marchand
Following the refactoring of device selection, it becomes more apparent that there is no need for a per bus scan mode.
-a / -b options are mutually exclusive.
--vdev option works in parallel of allow/block list scan mode.
Quoted 5 lines
-a/-b are mutually exclusive but does it mean "-a 0000:01:00.0" stops default probe for all devices on other buses ? Is it a change in behavior ?
(I could probably test but I guess you thought about this case given the nature of patch.)
Hum, yeah, it is a change in behavior, I was too focused on the next patch (where the new mode can't be used with -b option).
This patch was an attempt at simplifying.
Since there is a risk some user may have relied on this combination (iow some user setting -a busA:XXX yet relying on block mode for other buses), I'll just drop it and return to how it was in RFC v3.
Signature · 1 line
David Marchand
PATCH 8/8 eal: configure initial device probing
In reply to David MarchandSome applications use port hotplug as their primary way for using DPDK resources.
Having a systematic device probing is a problem when not all available resources will be used by the application, as such applications won't set an explicit allow list at startup.
This is the case for OVS on systems with multiple mlx5 devices:
one device can be used by the kernel while the other(s) are used by DPDK. In such a setup, the kernel used device may get reconfigured in unexpected ways and trigger issues like the one described by Kevin not so long ago in bugzilla 1873.
Add an EAL option so that we can change the default behavior from block-listing to allow-listing which can be summed up as disabling automatic probing.
In case some applications want to require automatic probing, add the opposite option.
---
Changes since RFC v2:
- added -A short option alias as it seems intuitive to use with -a,
- renamed option to --no-auto-probing (half Robin and half Thomas suggestions),
- made -A and -b conflicting options,
- added opposite option in case an application wants an explicit behavior,
- updated unit tests accordingly,
- updated documentation (namely some detail on --vdev),
Changes since RFC v1:
- changed approach following Bruce suggestion,
--- app/test/test_eal_flags.c | 63 +++++++++++++++++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 13 +++++ lib/eal/common/eal_common_bus.c | 17 +++--- lib/eal/common/eal_common_options.c | 10 ++++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + 7 files changed, 101 insertions(+), 7 deletions(-)
app/test/test_eal_flags.c +63 -0
@@ -119,6 +119,8 @@ test_misc_flags(void)#define no_hpet "--no-hpet"#define no_huge "--no-huge"#define no_shconf "--no-shconf" +#define auto_probing "--auto-probing" +#define no_auto_probing "--no-auto-probing"#define allow "--allow"#define vdev "--vdev"#define no_pci "--no-pci"
@@ -338,6 +340,14 @@ test_allow_flag(void) allow,"09:0B.3,type=test" , allow, "08:00.1,type=normal", }; +const char *wlval4[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing }; +const char *wlval5[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing, allow,"00FF:09:0B.3" }; +const char *wlval6[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing }; +const char *wlval7[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing, allow,"00FF:09:0B.3" };for (i =0 ; i <RTE_DIM (wlinval); i++) {if (launch_proc (wlinval[i]) ==0 ) {
@@ -360,6 +370,26 @@ test_allow_flag(void) __LINE__);return -1 ; } +if (launch_proc (wlval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing + allow\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval6) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval7) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing + allow\n" , + __LINE__); +return -1 ; + }return 0 ; }
@@ -383,6 +413,11 @@ test_invalid_b_flag(void) {prgname, prefix, mp_flag, eal_debug_logs, "-b", "error0:0:0.1"}, {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0.1.2"}, }; +const char *blinval_probing[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , auto_probing}; +const char *blinval_probing_inval[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , no_auto_probing}; +/* Test with valid blocklist option */ const char *blval[] = {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"FF:09:0B.3" };
@@ -396,6 +431,16 @@ test_invalid_b_flag(void)return -1 ; } } +if (launch_proc (blinval_probing) !=0 ) { +printf ("Error (line %d) - process did not run ok with blocklist and auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (blinval_probing_inval) ==0 ) { +printf ("Error (line %d) - process did run ok with blocklist and no-auto-probing\n" , + __LINE__); +return -1 ; + }if (launch_proc (blval) !=0 ) {printf ("Error (line %d) - process did not run ok with valid blocklist value\n" , __LINE__);
@@ -434,6 +479,12 @@ test_invalid_vdev_flag(void)const char *vdevval3[] = {prgname, prefix, no_huge, eal_debug_logs, bus_debug_logs, no_pci, vdev,"net_ring0,nodeaction=r1:0:CREATE" }; +const char *vdevval4[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, no_auto_probing, vdev,"net_ring0" }; + +const char *vdevval5[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, auto_probing, vdev,"net_ring0" }; +if (launch_proc (vdevinval) ==0 ) {printf ("Error (line %d) - process did run ok with invalid vdev parameter\n" , __LINE__);
@@ -457,6 +508,18 @@ test_invalid_vdev_flag(void) __LINE__); return -1; } + +if (launch_proc (vdevval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and no-auto-probing\n" , + __LINE__); +return -1 ; + } + +if (launch_proc (vdevval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and auto-probing\n" , + __LINE__); +return -1 ; + }return 0 ;#else return TEST_SKIPPED ;
devtools/test-null.sh +1 -1
@@ -30,7 +30,7 @@ logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ - $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ + $libs -A --vdev net_null1 --vdev net_null2 $eal_options -- \ --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile # we expect two ports and some traffic is received and transmitted
doc/guides/linux_gsg/eal_args.include.rst +13 -0
@@ -101,6 +101,19 @@ Lcore-related options Device-related options ~~~~~~~~~~~~~~~~~~~~~~ +* ``-A, --no-auto-probing`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b`` + options are passed. + Disable automatic probing of non-blocked devices. + +.. Note:: + Block list cannot be used when auto probing is disabled. + + On the other hand, disabling auto probing does not affect the VDEV bus. + The VDEV bus is not concerned by automatic probing and requires explicit + ``-a`` or ``--vdev``. + * ``-b, --block <[domain:]bus:devid.func>`` Skip probing a PCI device to prevent EAL from using it.
lib/eal/common/eal_common_bus.c +11 -6
@@ -252,18 +252,23 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_is_ignored_device)bool rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) { +const struct internal_config *internal_conf =eal_get_internal_configuration ();struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); +enum rte_bus_scan_mode scan_mode =rte_bus_scan_mode_get (); -switch (rte_bus_scan_mode_get ()) { -case RTE_BUS_SCAN_ALLOWLIST : +if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (internal_conf->no_auto_probing !=0 ) + scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +else + scan_mode =RTE_BUS_SCAN_BLOCKLIST ; + } + +if (scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) {if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : + }else {if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED )return false; -break ; }return true; }
lib/eal/common/eal_common_options.c +10 -0
@@ -233,10 +233,15 @@ eal_collate_args(int argc, char **argv)EAL_LOG (ERR ,"Options allow (-a) and block (-b) can't be used at the same time" );return -1 ; } +if (args.no_auto_probing && !TAILQ_EMPTY (&args.block)) { +EAL_LOG (ERR ,"Options no-auto-probing and block (-b) can't be used at the same time" ); +return -1 ; + }/* for non-list args, we can just check for zero/null values using macro */ if (CONFLICTING_OPTIONS(args, coremask, lcores) || CONFLICTING_OPTIONS(args, service_coremask, service_corelist) || + CONFLICTING_OPTIONS(args, no_auto_probing, auto_probing) || CONFLICTING_OPTIONS(args, no_telemetry, telemetry) || CONFLICTING_OPTIONS(args, memory_size, numa_mem) || CONFLICTING_OPTIONS(args, no_huge, numa_mem) ||
@@ -518,6 +523,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg)memset (internal_cfg->vfio_vf_token,0 ,sizeof (internal_cfg->vfio_vf_token)); + internal_cfg->no_auto_probing =0 ; +#ifdef RTE_LIBEAL_USE_HPET internal_cfg->no_hpet =0 ;#else
@@ -1972,6 +1979,9 @@ eal_parse_args(void) } } +if (args.no_auto_probing) + int_cfg->no_auto_probing =1 ; +/* device -a/-b/-vdev options*/ TAILQ_FOREACH (arg, &args.allow, next) if (eal_option_device_add(RTE_DEVTYPE_ALLOWED, arg->arg) < 0)
lib/eal/common/eal_internal_cfg.h +1 -0
@@ -104,6 +104,7 @@ struct internal_config {struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */ +unsigned int no_auto_probing;/**< true to switch from block-listing to allow-listing */ };void eal_reset_internal_config (struct internal_config *internal_cfg);
lib/eal/common/eal_option_list.h +2 -0
@@ -32,6 +32,7 @@* Format of each entry: long name, short name, help string, struct member name. */ /* (Alphabetical) List of common options first */ +BOOL_ARG("--auto-probing", NULL, "Let EAL probe all available devices unless some -a/-b option is set.", auto_probing) LIST_ARG("--allow", "-a", "Add device to allow-list, causing DPDK to only use specified devices", allow) STR_ARG("--base-virtaddr", NULL, "Base virtual address to reserve memory", base_virtaddr)LIST_ARG ("--block" ,"-b" ,"Add device to block-list, preventing DPDK from using the device" , block)
@@ -51,6 +52,7 @@ STR_ARG("--mbuf-pool-ops-name", NULL, "User defined mbuf default pool ops name", STR_ARG("--memory-channels", "-n", "Number of memory channels per socket", memory_channels) STR_ARG("--memory-ranks", "-r", "Force number of memory ranks (don't detect)", memory_ranks) STR_ARG("--memory-size", "-m", "Total size of memory to allocate initially", memory_size) +BOOL_ARG("--no-auto-probing", "-A", "Do not probe any devices unless some -a option is set", no_auto_probing) BOOL_ARG("--no-hpet", NULL, "Disable HPET timer", no_hpet) BOOL_ARG("--no-huge", NULL, "Disable hugetlbfs support", no_huge)BOOL_ARG ("--no-pci" ,NULL ,"Disable all PCI devices" , no_pci)
Signature · 1 line
2.53.0
Re: [PATCH 8/8] eal: configure initial device probing
Quoted 18 lines · David Marchand
Some applications use port hotplug as their primary way for using DPDK resources.
Having a systematic device probing is a problem when not all available resources will be used by the application, as such applications won't set an explicit allow list at startup.This is the case for OVS on systems with multiple mlx5 devices:
one device can be used by the kernel while the other(s) are used by DPDK. In such a setup, the kernel used device may get reconfigured in unexpected ways and trigger issues like the one described by Kevin not so long ago in bugzilla 1873.Add an EAL option so that we can change the default behavior from block-listing to allow-listing which can be summed up as disabling automatic probing.
In case some applications want to require automatic probing, add the opposite option.
Quoted 6 lines
Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Reviewed-by Robin Jarry <[email protected]>---
Changes since RFC v2:
- added -A short option alias as it seems intuitive to use with -a,
nit: I think I would have said '-B' as it's not allowing anything and it's equivalent of adding a -b for all devices, but let's not bike shed on it :-)
Quoted 10 lines
- renamed option to --no-auto-probing (half Robin and half Thomas suggestions),
- made -A and -b conflicting options,
- added opposite option in case an application wants an explicit behavior,
- updated unit tests accordingly,
- updated documentation (namely some detail on --vdev),Changes since RFC v1:
- changed approach following Bruce suggestion,
Quoted 10 lines
--- app/test/test_eal_flags.c | 63 +++++++++++++++++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 13 +++++ lib/eal/common/eal_common_bus.c | 17 +++--- lib/eal/common/eal_common_options.c | 10 ++++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + 7 files changed, 101 insertions(+), 7 deletions(-)
LGTM
Quoted 4 lines · David Marchand
Applications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
Series-
Hi David,
Quoted 4 lines · David Marchand
Applications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
On my side, the whole series works fine with Grout on NXP CPUs.
I can add DPDK ports, send/receive traffic, delete ports, recreate them, etc.
Quoted 65 lines
--
David MarchandChanges since RFC v3:
- removed per bus scan mode,Changes since RFC v2:
- went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5),
- updated device selection helper accordingly and
changed API to be device name based,
- renamed option, added check on -b presence, updated doc in the last patch,Changes since RFC v1:
- reviewed busprobe()and cleaned up NXP drivers,
- changed approach following Bruce comment,David Marchand (8):
devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup
drivers/bus: require probe function for NXP drivers
drivers: cleanup devargs lookup in bus scan
bus: factorize devargs lookup
bus: factorize device selection
bus: remove per bus scan mode
eal: configure initial device probingapp/test/test_eal_flags.c | 63 +++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 13 ++++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +--------- drivers/bus/dpaa/dpaa_bus.c | 71 +++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 69 ++++++++----------- drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/bus_ifpga_driver.h | 2 - drivers/bus/ifpga/ifpga_bus.c | 4 +- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++---------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +----------- drivers/bus/uacce/uacce.c | 39 +---------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 - drivers/bus/vmbus/vmbus_common.c | 45 +++---------- drivers/dma/idxd/idxd_bus.c | 18 +---- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- lib/eal/common/eal_common_bus.c | 62 +++++++++++++++++ lib/eal/common/eal_common_devargs.c | 8 +-- lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/common/eal_private.h | 31 +++++++++ lib/eal/include/bus_driver.h | 55 ++++++++++----- 33 files changed, 338 insertions(+), 388 deletions(-)
Quoted 3 lines
--
2.53.0
Best regards,
Maxime Leroy
v2 cover Rework device probing
In reply to David MarchandApplications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
Signature · 65 lines
David Marchand Changes since v1: - restored per bus scan mode, - fixed logic in device selection for dma/idxd, - fixed raw/ifpga hotplug on ifpga bus, - fixed some doxygen, Changes since RFC v3: - removed per bus scan mode, Changes since RFC v2: - went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5), - updated device selection helper accordingly and changed API to be device name based, - renamed option, added check on -b presence, updated doc in the last patch, Changes since RFC v1: - reviewed bus probe() and cleaned up NXP drivers, - changed approach following Bruce comment, David Marchand (7): devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup drivers/bus: require probe function for NXP drivers drivers: cleanup devargs lookup in bus scan bus: factorize devargs lookup bus: factorize device selection eal: configure initial device probing app/test/test_eal_flags.c | 63 +++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 13 ++++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +--------- drivers/bus/dpaa/dpaa_bus.c | 71 +++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 69 ++++++++----------- drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/ifpga_bus.c | 8 ++- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++---------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +----------- drivers/bus/uacce/uacce.c | 39 +---------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 - drivers/bus/vmbus/vmbus_common.c | 45 +++---------- drivers/dma/idxd/idxd_bus.c | 18 +---- lib/eal/common/eal_common_bus.c | 44 ++++++++++++ lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/include/bus_driver.h | 38 +++++++++++ 29 files changed, 290 insertions(+), 362 deletions(-) -- 2.53.0
PATCH v2 1/7 devtools: check packet forwarding in null test
Add some simple checks that testpmd was indeed polling two ports, and some packets got through it.
--- devtools/test-null.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
devtools/test-null.sh +7 -1
@@ -26,8 +26,14 @@ else libs= fi +logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ - --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia + --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile + +# we expect two ports and some traffic is received and transmitted +grep -q 'io packet forwarding - ports=2 -' $build/test-null.log +grep 'RX-packets: ' $logfile | tail -1 | grep -q 'RX-packets:[[:space:]]*[^0[:space:]]' +grep 'TX-packets: ' $logfile | tail -1 | grep -q 'TX-packets:[[:space:]]*[^0[:space:]]'
Signature · 1 line
2.53.0
PATCH v2 2/7 bus/fslmc: fix bus cleanup
In reply to David MarchandThe close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +4 -17
@@ -1393,7 +1393,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, {struct rte_dpaa2_object *object =NULL ;struct rte_dpaa2_driver *drv; -int ret, probe_all; +int ret;switch (dev->dev_type) {case DPAA2_IO :
@@ -1411,22 +1411,9 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - probe_all = rte_fslmc_bus.bus.conf.scan_mode != -RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { -if (drv->drv_type != dev->dev_type) -continue ; -if (rte_dev_is_probed (&dev->device)) -continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy == -RTE_DEV_ALLOWED )) { - ret = drv->remove (dev); -if (ret) -DPAA2_BUS_ERR ("Unable to remove" ); - } - } + drv = dev->driver; +if (drv && drv->remove && drv->remove (dev)) +DPAA2_BUS_ERR ("Unable to remove" );break ;default :break ;
Signature · 1 line
2.53.0
Re: [PATCH v2 2/7] bus/fslmc: fix bus cleanup
Quoted 12 lines · David Marchand
The close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
Fixes 274fd921ff7f ("bus/fslmc: support close operation")
Quoted 6 lines
Signed-off-by David Marchand <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
PATCH v2 3/7 drivers/bus: require probe function for NXP drivers
In reply to David MarchandRather than silently ignore an invalid driver, enforce every registered driver has a probe callback.
--- drivers/bus/dpaa/dpaa_bus.c | 6 +++--- drivers/bus/fslmc/fslmc_bus.c | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -3
@@ -614,6 +614,7 @@ void rte_dpaa_driver_register(struct rte_dpaa_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );BUS_INIT_FUNC_TRACE ();
@@ -808,9 +809,8 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (!drv->probe || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED )) +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED )continue ; if (probe_all ||
drivers/bus/fslmc/fslmc_bus.c +1 -6
@@ -465,9 +465,6 @@ rte_fslmc_probe(void)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
@@ -534,6 +531,7 @@ void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );TAILQ_INSERT_TAIL (&rte_fslmc_bus.driver_list, driver, next); }
@@ -601,9 +599,6 @@ fslmc_bus_plug(struct rte_device *rte_dev)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
Signature · 1 line
2.53.0
PATCH v2 4/7 drivers: cleanup devargs lookup in bus scan
In reply to David MarchandDon'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.
---
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(-)
drivers/bus/auxiliary/auxiliary_common.c +1 -1
@@ -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; }
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -2
@@ -28,8 +28,6 @@extern "C" {#endif -#define RTE_BUS_AUXILIARY_NAME "auxiliary" -/* Forward declarations */ struct rte_auxiliary_driver ;struct rte_auxiliary_device ;
drivers/bus/cdx/cdx.c +1 -2
@@ -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; }
drivers/bus/dpaa/dpaa_bus.c +2 -4
@@ -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 );
drivers/bus/fslmc/fslmc_bus.c +3 -5
@@ -26,7 +26,6 @@#include <dpaax_iova_table.h> #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups" -#define FSLMC_BUS_NAME fslmcstruct 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 {
@@ -704,5 +702,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 );
drivers/bus/ifpga/ifpga_bus.c +6 -2
@@ -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 );
drivers/bus/pci/pci_common.c +1 -1
@@ -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;
drivers/bus/platform/platform.c +1 -1
@@ -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; }
drivers/bus/uacce/uacce.c +1 -1
@@ -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; }
drivers/bus/vdev/vdev.c +1 -1
@@ -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)
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -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 )
Signature · 1 line
2.53.0
Re: [PATCH v2 4/7] drivers: cleanup devargs lookup in bus scan
For uacce part,
Quoted 20 lines · David Marchand
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_NAMEinstead ofIFPGA_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 <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Hemant Agrawal <[email protected]>Acked-by Kevin Traynor <[email protected]>Tested-by Maxime Leroy <[email protected]>---
Changes since v1:
- fixed ifpga hotplug in raw/ifpga,
PATCH v2 5/7 bus: factorize devargs lookup
In reply to David MarchandEach bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.
---
Changes since v1:
- fixed copy/paste descriptions in doxygen,
Changes since RFC v3:
- fixed doxygen,
--- drivers/bus/auxiliary/auxiliary_common.c | 16 ++------- drivers/bus/cdx/cdx.c | 14 +------- drivers/bus/dpaa/dpaa_bus.c | 41 +++++++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 34 ++++++++++---------- drivers/bus/pci/pci_common.c | 38 +++++++++++----------- drivers/bus/platform/platform.c | 17 ++-------- drivers/bus/uacce/uacce.c | 19 ++--------- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 -- drivers/bus/vmbus/vmbus_common.c | 30 ++++++++--------- drivers/dma/idxd/idxd_bus.c | 14 ++------ lib/eal/common/eal_common_bus.c | 20 ++++++++++++ lib/eal/include/bus_driver.h | 32 ++++++++++++++++++ 13 files changed, 133 insertions(+), 147 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +2 -14
@@ -25,18 +25,6 @@#include "private.h" -static struct rte_devargs * -auxiliary_devargs_lookup (const char *name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(auxiliary_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } -return NULL ; -} -#ifndef AUXILIARY_OS_SUPPORTED /* * Test whether the auxiliary device exist.
@@ -68,7 +56,7 @@ auxiliary_scan(void)void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev) { - aux_dev->device.devargs =auxiliary_devargs_lookup (aux_dev->name); + aux_dev->device.devargs =rte_bus_find_devargs (&auxiliary_bus.bus, aux_dev->name); }/*
@@ -399,7 +387,7 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,bool auxiliary_is_ignored_device (const char *name) { -struct rte_devargs *devargs =auxiliary_devargs_lookup (name); +struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name);switch (auxiliary_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/cdx/cdx.c +1 -13
@@ -151,22 +151,10 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static struct rte_devargs * -cdx_devargs_lookup (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(rte_cdx_bus.bus.name, devargs) { -if (strcmp (devargs->name, dev_name) ==0 ) -return devargs; - } -return NULL ; -} -static bool cdx_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =cdx_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name);switch (rte_cdx_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/dpaa/dpaa_bus.c +22 -19
77 lines not on this page · raw message
drivers/bus/fslmc/fslmc_bus.c +17 -17
@@ -99,22 +99,6 @@ insert_in_device_list(struct rte_dpaa2_device *newdev)TAILQ_INSERT_TAIL (&rte_fslmc_bus.device_list, newdev, next); } -static struct rte_devargs * -fslmc_devargs_lookup (struct rte_dpaa2_device *dev) -{ -struct rte_devargs *devargs; -char dev_name[32 ]; - - 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); -return devargs; - } - } -return NULL ; -} -static void dump_device_list (void ) {
@@ -216,7 +200,10 @@ scan_one_fslmc_device(char *dev_name) ret = -ENOMEM ; goto cleanup; } - dev->device.devargs =fslmc_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus.bus, dev_name); +if (dev->device.devargs !=NULL ) +DPAA2_BUS_INFO ("**Devargs matched %s" , dev_name); +/* Update the device found into the device_count table */ rte_fslmc_bus.device_count[dev->dev_type]++;
@@ -308,6 +295,18 @@ rte_fslmc_parse(const char *name, void *addr)return ret; } +static int +fslmc_devname_compare (const char *name1,const char *name2) +{ +char devname1[32 ], devname2[32 ]; + +if (rte_fslmc_parse (name1, devname1) !=0 || +rte_fslmc_parse (name2, devname2) !=0 ) +return 1 ; + +return strncmp (devname1, devname2,sizeof (devname1)); +} +static int rte_fslmc_scan (void ) {
@@ -691,6 +690,7 @@ struct rte_fslmc_bus rte_fslmc_bus = { .probe = rte_fslmc_probe, .cleanup = rte_fslmc_close, .parse = rte_fslmc_parse, + .devname_compare = fslmc_devname_compare, .find_device = rte_fslmc_find_device, .get_iommu_class = rte_dpaa2_get_iommu_class, .plug = fslmc_bus_plug,
drivers/bus/pci/pci_common.c +19 -19
@@ -79,32 +79,15 @@ pci_asprintf(char **buffer, const char *format, ...) }#endif /* RTE_EXEC_ENV_WINDOWS */ -static struct rte_devargs * -pci_devargs_lookup (const struct rte_pci_addr *pci_addr) -{ -struct rte_devargs *devargs; -struct rte_pci_addr addr; - - 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; - } -return NULL ; -} - void pci_common_set(struct rte_pci_device *dev) { - struct rte_devargs *devargs; - /* Each device has its internal, canonical name set. */ rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name)); dev->device.name = dev->name; - devargs = pci_devargs_lookup(&dev->addr); - dev->device.devargs = devargs; + dev->device.devargs = rte_bus_find_devargs(&rte_pci_bus.bus, dev->name); if (dev->bus_info != NULL || asprintf(&dev->bus_info, "vendor_id=%"PRIx16", device_id=%"PRIx16,
@@ -503,6 +486,18 @@ pci_parse(const char *name, void *addr)return parse == false; } +static int +pci_devname_compare (const char *name1,const char *name2) +{ +struct rte_pci_addr addr1, addr2; + +if (rte_pci_addr_parse (name1, &addr1) !=0 || +rte_pci_addr_parse (name2, &addr2) !=0 ) +return 1 ; + +return rte_pci_addr_cmp (&addr1, &addr2); +} +/* register a driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_pci_register) void
@@ -721,7 +716,11 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) { -struct rte_devargs *devargs =pci_devargs_lookup (pci_addr); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_pci_device_name (pci_addr, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name);switch (rte_pci_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -946,6 +945,7 @@ struct rte_pci_bus rte_pci_bus = { .plug = pci_plug, .unplug = pci_unplug, .parse = pci_parse, + .devname_compare = pci_devname_compare, .devargs_parse = rte_pci_devargs_parse, .dma_map = pci_dma_map, .dma_unmap = pci_dma_unmap,
drivers/bus/platform/platform.c +2 -15
@@ -43,25 +43,12 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static struct rte_devargs * -dev_devargs (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(platform_bus.bus.name, devargs) { -if (!strcmp (devargs->name, dev_name)) -return devargs; - } - -return NULL ; -} -static bool dev_allowed (const char *dev_name) {struct rte_devargs *devargs; - devargs =dev_devargs (dev_name); + devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name);if (devargs ==NULL )return true;
@@ -93,7 +80,7 @@ dev_add(const char *dev_name)rte_strscpy (pdev->name, dev_name,sizeof (pdev->name)); pdev->device.name = pdev->name; - pdev->device.devargs =dev_devargs (dev_name); + pdev->device.devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); pdev->device.bus = &platform_bus.bus;snprintf (path,sizeof (path),PLATFORM_BUS_DEVICES_PATH "/%s/numa_node" , dev_name); pdev->device.numa_node =eal_parse_sysfs_value (path, &val) ?rte_socket_id () : val;
drivers/bus/uacce/uacce.c +2 -17
@@ -70,25 +70,10 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static struct rte_devargs * -uacce_devargs_lookup (const char *dev_name) -{ -char name[RTE_UACCE_DEV_PATH_SIZE ] = {0 }; -struct rte_devargs *devargs; - -snprintf (name,sizeof (name),"%s%s" ,UACCE_DEV_PREFIX , dev_name); - RTE_EAL_DEVARGS_FOREACH(uacce_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } - -return NULL ; -} -static bool uacce_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =uacce_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);switch (uacce_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -257,7 +242,7 @@ uacce_scan_one(const char *dev_name) dev->device.bus = &uacce_bus.bus; dev->device.name = dev->name; - dev->device.devargs =uacce_devargs_lookup (dev_name); + dev->device.devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);snprintf (dev->name,sizeof (dev->name),"%s" , dev_name);snprintf (dev->dev_root,sizeof (dev->dev_root),"%s/%s" ,UACCE_BUS_CLASS_PATH , dev_name);
drivers/bus/vmbus/linux/vmbus_bus.c +1 -1
@@ -333,7 +333,7 @@ vmbus_scan_one(const char *name) dev->monitor_id =UINT8_MAX ; } - dev->device.devargs =vmbus_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, dev_name); dev->device.numa_node =SOCKET_ID_ANY ;if (vmbus_use_numa (dev)) {
drivers/bus/vmbus/private.h +0 -3
@@ -98,9 +98,6 @@ struct vmbus_channel {#define VMBUS_MAX_CHANNELS 64 -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev); -int vmbus_chan_create (const struct rte_vmbus_device *device,uint16_t relid,uint16_t subid,uint8_t monitor_id,struct vmbus_channel **new_chan);
drivers/bus/vmbus/vmbus_common.c +13 -17
@@ -171,7 +171,11 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)static bool vmbus_ignore_device (struct rte_vmbus_device *dev) { -struct rte_devargs *devargs =vmbus_devargs_lookup (dev); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_uuid_unparse (dev->device_id, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name);switch (rte_vmbus_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -260,25 +264,16 @@ vmbus_parse(const char *name, void *addr)return ret; } -/* -* scan for matching device args on command line -* example: -* -a 'vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20' -*/ -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev) +static int +vmbus_devname_compare (const char *name1,const char *name2) { -struct rte_devargs *devargs; -rte_uuid_t addr; - - RTE_EAL_DEVARGS_FOREACH(rte_vmbus_bus.bus.name, devargs) { -vmbus_parse (devargs->name, &addr); +rte_uuid_t guid1, guid2; -if (rte_uuid_compare (dev->device_id, addr) ==0 ) -return devargs; - } -return NULL ; +if (vmbus_parse (name1, &guid1) !=0 || +vmbus_parse (name2, &guid2) !=0 ) +return 1 ; +return rte_uuid_compare (guid1, guid2); }/* register vmbus driver */
@@ -349,6 +344,7 @@ struct rte_vmbus_bus rte_vmbus_bus = { .cleanup = rte_vmbus_cleanup, .find_device = vmbus_find_device, .parse = vmbus_parse, + .devname_compare = vmbus_devname_compare, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.driver_list),
drivers/dma/idxd/idxd_bus.c +2 -12
@@ -247,16 +247,6 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return 0 ; } -static int search_devargs (const char *name) -{ -struct rte_devargs *devargs; - RTE_EAL_DEVARGS_FOREACH(dsa_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return 1 ; - } -return 0 ; -} -static int is_for_this_process_use (struct rte_dsa_device *dev,const char *name) {
@@ -275,9 +265,9 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) {if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ;else - retval = !search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; }return retval;
lib/eal/common/eal_common_bus.c +20 -0
@@ -8,6 +8,7 @@#include <bus_driver.h> #include <rte_debug.h> +#include <rte_devargs.h> #include <rte_string_fns.h> #include <rte_errno.h>
@@ -205,6 +206,25 @@ rte_bus_find_by_name(const char *busname)return rte_bus_find (NULL , cmp_bus_name, (const void *)busname); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_find_devargs) +struct rte_devargs * +rte_bus_find_devargs (const struct rte_bus *bus,const char *name) +{ +rte_bus_devname_compare_t cmp = bus->devname_compare; +struct rte_devargs *devargs; + +if (cmp ==NULL ) + cmp = strcmp; + + RTE_EAL_DEVARGS_FOREACH(rte_bus_name(bus), devargs) { +if (cmp (name, devargs->name) !=0 ) +continue ; +return devargs; + } + +return NULL ; +} +static int bus_can_parse (const struct rte_bus *bus,const void *_name) {
lib/eal/include/bus_driver.h +32 -0
@@ -118,6 +118,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);*/ typedef int (*rte_bus_parse_t )(const char *name,void *addr); +/** +* Bus specific device name comparison function. +* Bus can normalize the names of devices using an internal representation. +* This helper makes it possible to check whether two names refer to the same device. +* +* @param[in] name1 +* device name +* @param[in] name2 +* device name +* +* @return +* 0 if the two names refer to the same device. +* !0 otherwise. +*/ +typedef int (*rte_bus_devname_compare_t )(const char *name1,const char *name2); +/** * Parse bus part of the device arguments. *
@@ -258,6 +274,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +rte_bus_devname_compare_t devname_compare;/**< Compare two device names */ rte_bus_devargs_parse_t devargs_parse;/**< Parse bus devargs */ rte_dev_dma_map_t dma_map;/**< DMA map for device in the bus */ rte_dev_dma_unmap_t dma_unmap;/**< DMA unmap for device in the bus */
@@ -281,6 +298,21 @@ struct rte_bus {__rte_internal void rte_bus_register(struct rte_bus *bus); +/** +* Find the devargs associated to a device. +* +* @param bus +* A pointer to a rte_bus structure describing the bus +* to search for devargs on. +* @param dev_name +* A device name. +* +* @return +* Pointer to the device devargs, or NULL if none found. +*/ +__rte_internal +struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
Re: [PATCH v2 5/7] bus: factorize devargs lookup
Quoted 20 lines · David Marchand
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>---
Changes since v1:
- fixed copy/paste descriptions in doxygen,Changes since RFC v3:
- fixed doxygen,
Quoted 15 lines
--- drivers/bus/auxiliary/auxiliary_common.c | 16 ++------- drivers/bus/cdx/cdx.c | 14 +------- drivers/bus/dpaa/dpaa_bus.c | 41 +++++++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 34 ++++++++++---------- drivers/bus/pci/pci_common.c | 38 +++++++++++----------- drivers/bus/platform/platform.c | 17 ++-------- drivers/bus/uacce/uacce.c | 19 ++--------- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 -- drivers/bus/vmbus/vmbus_common.c | 30 ++++++++--------- drivers/dma/idxd/idxd_bus.c | 14 ++------ lib/eal/common/eal_common_bus.c | 20 ++++++++++++ lib/eal/include/bus_driver.h | 32 ++++++++++++++++++ 13 files changed, 133 insertions(+), 147 deletions(-)
Re: [PATCH v2 5/7] bus: factorize devargs lookup
In reply to David MarchandQuoted 14 lines · David Marchand
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>---
...
Quoted 5 lines
drivers/bus/uacce/uacce.c +0
-0
drivers/bus/uacce/uacce.c extern int uacce_bus_logtype; · line 79
Quoted 10 lines
drivers/bus/uacce/uacce.c +0
-7@@ -70,25 +70,10 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static struct rte_devargs * -uacce_devargs_lookup (const char *dev_name) -{ -char name[RTE_UACCE_DEV_PATH_SIZE ] = {0 }; -struct rte_devargs *devargs; - -snprintf (name,sizeof (name),"%s%s" ,UACCE_DEV_PREFIX , dev_name);
For uacce, application should pass device with prefix uacce, e.g:
dpdk-testpmd -a uacce:hisi_zip-0,queues=2 --file-prefix=feng -- -i
And the scan device is hisi_zip-0, so in match we should combined which is above snprintf does.
Quoted 14 lines
drivers/bus/uacce/uacce.c +1
-9- RTE_EAL_DEVARGS_FOREACH(uacce_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } - -return NULL ; -} -static bool uacce_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =uacce_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);
...
Quoted 23 lines
drivers/bus/uacce/uacce.c +0
-0return retval;lib/eal/common/eal_common_bus.c +19
-0+RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_find_devargs) +struct rte_devargs * +rte_bus_find_devargs (const struct rte_bus *bus,const char *name) +{ +rte_bus_devname_compare_t cmp = bus->devname_compare; +struct rte_devargs *devargs; + +if (cmp ==NULL ) + cmp = strcmp; + + RTE_EAL_DEVARGS_FOREACH(rte_bus_name(bus), devargs) { +if (cmp (name, devargs->name) !=0 ) +continue ; +return devargs; + } + +return NULL ; +} +
...
Re: [PATCH v2 5/7] bus: factorize devargs lookup
Hello,
Quoted 19 lines · fengchengwen
Quoted 5 lines
drivers/bus/uacce/uacce.c +0
-0drivers/bus/uacce/uacce.c extern int uacce_bus_logtype; · line 79
Quoted 10 lines
drivers/bus/uacce/uacce.c +0
-7@@ -70,25 +70,10 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static struct rte_devargs * -uacce_devargs_lookup (const char *dev_name) -{ -char name[RTE_UACCE_DEV_PATH_SIZE ] = {0 }; -struct rte_devargs *devargs; - -snprintf (name,sizeof (name),"%s%s" ,UACCE_DEV_PREFIX , dev_name);For uacce, application should pass device with prefix uacce, e.g:
dpdk-testpmd -a uacce:hisi_zip-0,queues=2 --file-prefix=feng -- -i
Quoted 2 lines
And the scan device is hisi_zip-0, so in match we should combined which is above snprintf does.
Erm, strange that I did not see this during my tests, but I think you are right. It means the matching is broken in rte_bus_find_devargs().
I'll respin (I need to, anyway, as there was some fslmc change that got merged late in v26.03).
Quoted 9 lines
Quoted 9 lines
drivers/bus/uacce/uacce.c +0
-8- RTE_EAL_DEVARGS_FOREACH(uacce_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } - -return NULL ; -} -
Signature · 1 line
David Marchand
PATCH v2 6/7 bus: factorize device selection
In reply to David MarchandAll buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.
---
Changes since v1:
- fixed device selection in dma/idxd,
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,
--- drivers/bus/auxiliary/auxiliary_common.c | 19 ---------------- drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 ----- drivers/bus/cdx/cdx.c | 21 +----------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++-------------- drivers/bus/fslmc/fslmc_bus.c | 22 ++++++------------- drivers/bus/pci/bsd/pci.c | 5 ++++- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 23 ------------------- drivers/bus/pci/private.h | 11 ---------- drivers/bus/pci/windows/pci.c | 4 +++- drivers/bus/platform/platform.c | 28 ++---------------------- drivers/bus/uacce/uacce.c | 22 +------------------ drivers/bus/vmbus/vmbus_common.c | 25 +-------------------- drivers/dma/idxd/idxd_bus.c | 8 ++----- lib/eal/common/eal_common_bus.c | 19 ++++++++++++++++ lib/eal/include/bus_driver.h | 6 +++++ 17 files changed, 55 insertions(+), 192 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -19
@@ -384,25 +384,6 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,return aux_dev->driver->dma_unmap (aux_dev, addr, iova, len); } -bool -auxiliary_is_ignored_device (const char *name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name); - -switch (auxiliary_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -static enum rte_iova_mode auxiliary_get_iommu_class (void ) {
drivers/bus/auxiliary/linux/auxiliary.c +1 -1
@@ -110,7 +110,7 @@ auxiliary_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (auxiliary_is_ignored_device (e->d_name)) +if (rte_bus_is_ignored_device (&auxiliary_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/auxiliary/private.h +0 -6
@@ -53,12 +53,6 @@ int auxiliary_scan(void);*/ void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev); -/* -* Validate whether a device with given auxiliary device should be ignored -* or not. -*/ -bool auxiliary_is_ignored_device (const char *name); -/* * Add an auxiliary device to the auxiliary bus (append to auxiliary device * list). This function also updates the bus references of the auxiliary
drivers/bus/cdx/cdx.c +1 -20
@@ -151,25 +151,6 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static bool -cdx_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name); - -switch (rte_cdx_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan one cdx sysfs entry, and fill the devices list from it. * It checks if the CDX device is bound to vfio-cdx driver. In case
@@ -269,7 +250,7 @@ cdx_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (cdx_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&rte_cdx_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/dpaa/dpaa_bus.c +7 -17
@@ -717,7 +717,6 @@ rte_dpaa_bus_probe(void)struct rte_dpaa_driver *drv;FILE *svr_file =NULL ;uint32_t svr_ver; -int probe_all = rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ;static int process_once;char *penv;
@@ -725,9 +724,6 @@ rte_dpaa_bus_probe(void)if (!rte_dpaa_bus.detected)return 0 ; -if (rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ) - probe_all = true; - svr_file =fopen (DPAA_SOC_ID_FILE ,"r" );if (svr_file) {if (fscanf (svr_file,"svr:%x" , &svr_ver) >0 )
@@ -809,21 +805,15 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) +if (rte_bus_is_ignored_device (&rte_dpaa_bus.bus, dev->name))continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA_BUS_ERR ("unable to probe:%s" , - dev->name); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA_BUS_ERR ("unable to probe: %s" , dev->name); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/fslmc/fslmc_bus.c +7 -15
@@ -407,7 +407,6 @@ static intrte_fslmc_probe (void) {int ret =0 ; -int probe_all;struct rte_dpaa2_device *dev;struct rte_dpaa2_driver *drv;
@@ -454,8 +453,6 @@ rte_fslmc_probe(void)return 0 ; } - probe_all = rte_fslmc_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { ret =rte_fslmc_match (drv, dev);
@@ -465,23 +462,18 @@ rte_fslmc_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +if (rte_bus_is_ignored_device (&rte_fslmc_bus.bus, dev->device.name)) {DPAA2_BUS_LOG (DEBUG ,"%s Blocked, skipping" , dev->device.name);continue ; } -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA2_BUS_ERR ("Unable to probe" ); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/pci/bsd/pci.c +4 -1
@@ -370,12 +370,15 @@ rte_pci_scan(void) }for (i =0 ; i < conf_io.num_matches; i++) { +char name[RTE_DEV_NAME_MAX_LEN ]; + pci_addr.domain = matches[i].pc_sel.pc_domain; pci_addr.bus = matches[i].pc_sel.pc_bus; pci_addr.devid = matches[i].pc_sel.pc_dev; pci_addr.function = matches[i].pc_sel.pc_func; +rte_pci_device_name (&pci_addr, name,sizeof (name)); -if (rte_pci_ignore_device (&pci_addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name))continue ;if (pci_scan_one (fd, &matches[i]) <0 )
drivers/bus/pci/linux/pci.c +1 -1
@@ -458,7 +458,7 @@ rte_pci_scan(void)if (parse_pci_addr_format (e->d_name,sizeof (e->d_name), &addr) !=0 )continue ; -if (rte_pci_ignore_device (&addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/pci/pci_common.c +0 -23
@@ -713,29 +713,6 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)return -1 ; } -bool -rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_pci_device_name (pci_addr, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name); - -switch (rte_pci_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -enum rte_iova_mode rte_pci_get_iommu_class (void ) {
drivers/bus/pci/private.h +0 -11
@@ -82,17 +82,6 @@ pci_common_set(struct rte_pci_device *dev);void pci_free (struct rte_pci_device_internal *pdev); -/** -* Validate whether a device with given PCI address should be ignored or not. -* -* @param pci_addr -* PCI address of device to be validated -* @return -* true: if device is to be ignored, -* false: if device is to be scanned, -*/ -bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr); -/** * Add a PCI device to the PCI Bus (append to PCI Device list). This function * also updates the bus references of the PCI Device (and the generic device
drivers/bus/pci/windows/pci.c +3 -1
@@ -373,6 +373,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)struct rte_pci_device *dev =NULL ;int ret =-1 ;char pci_device_info[REGSTR_VAL_MAX_HCID_LEN ]; +char name[RTE_DEV_NAME_MAX_LEN ];struct rte_pci_addr addr;struct rte_pci_id pci_id;
@@ -380,7 +381,8 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)if (ret !=0 ) goto end; -if (rte_pci_ignore_device (&addr)) { +rte_pci_device_name (&addr, name,sizeof (name)); +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name)) {/* * We won't add this device, but we want to continue * looking for supported devices
drivers/bus/platform/platform.c +2 -26
@@ -43,30 +43,6 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static bool -dev_allowed (const char *dev_name) -{ -struct rte_devargs *devargs; - - devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); -if (devargs ==NULL ) -return true; - -switch (platform_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs->policy ==RTE_DEV_ALLOWED ) -return true; -break ; -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs->policy ==RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -static int dev_add (const char *dev_name) {
@@ -160,7 +136,7 @@ platform_bus_scan(void)if (dev_name[0 ] =='.' )continue ; -if (!dev_allowed (dev_name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev_name))continue ;if (!dev_is_bound_vfio_platform (dev_name))
@@ -484,7 +460,7 @@ platform_bus_plug(struct rte_device *dev) {struct rte_platform_device *pdev; -if (!dev_allowed (dev->name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev->name))return -EPERM ;if (!dev_is_bound_vfio_platform (dev->name))
drivers/bus/uacce/uacce.c +1 -21
@@ -70,26 +70,6 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static bool -uacce_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name); - -switch (uacce_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -/* * Returns the number of bytes read (removed last newline) on success. * Otherwise negative value is returned.
@@ -296,7 +276,7 @@ uacce_scan(void)continue ; } -if (uacce_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&uacce_bus.bus, e->d_name))continue ;if (uacce_scan_one (e->d_name) <0 )
drivers/bus/vmbus/vmbus_common.c +1 -24
@@ -168,29 +168,6 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)return 1 ; } -static bool -vmbus_ignore_device (struct rte_vmbus_device *dev) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_uuid_unparse (dev->device_id, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name); - -switch (rte_vmbus_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan the vmbus, and call the devinit() function for * all registered drivers that have a matching entry in its id_table
@@ -209,7 +186,7 @@ rte_vmbus_probe(void)rte_uuid_unparse (dev->device_id, ubuf,sizeof (ubuf)); -if (vmbus_ignore_device (dev)) +if (rte_bus_is_ignored_device (&rte_vmbus_bus.bus, ubuf))continue ;if (vmbus_probe_all_drivers (dev) <0 ) {
drivers/dma/idxd/idxd_bus.c +2 -6
@@ -263,12 +263,8 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' ) retval =1 ; -if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) { -if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ; -else - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; - } +if (retval) + retval = !rte_bus_is_ignored_device (&dsa_bus.bus, dev->device.name);return retval; }
lib/eal/common/eal_common_bus.c +19 -0
@@ -246,6 +246,25 @@ rte_bus_find_by_device_name(const char *str)return rte_bus_find (NULL , bus_can_parse, name); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_is_ignored_device) +bool +rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) +{ +struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); + +switch (bus->conf.scan_mode) { +case RTE_BUS_SCAN_ALLOWLIST : +if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) +return false; +break ; +case RTE_BUS_SCAN_UNDEFINED : +case RTE_BUS_SCAN_BLOCKLIST : +if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) +return false; +break ; + } +return true; +}/* * Get iommu class of devices on the bus.
lib/eal/include/bus_driver.h +6 -0
@@ -313,6 +313,12 @@ void rte_bus_register(struct rte_bus *bus);__rte_internal struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** +* Indicate if a device should be skipped during probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
Re: [PATCH v2 6/7] bus: factorize device selection
Quoted 29 lines · David Marchand
All buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Reviewed-by Robin Jarry <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>---
Changes since v1:
- fixed device selection in dma/idxd,Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,--- drivers/bus/auxiliary/auxiliary_common.c | 19 ---------------- drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 ----- drivers/bus/cdx/cdx.c | 21 +----------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++-------------- drivers/bus/fslmc/fslmc_bus.c | 22 ++++++------------- drivers/bus/pci/bsd/pci.c | 5 ++++- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 23 ------------------- drivers/bus/pci/private.h | 11 ----------
Quoted 8 lines
drivers/bus/pci/windows/pci.c | 4 +++- drivers/bus/platform/platform.c | 28 ++---------------------- drivers/bus/uacce/uacce.c | 22 +------------------ drivers/bus/vmbus/vmbus_common.c | 25 +-------------------- drivers/dma/idxd/idxd_bus.c | 8 ++----- lib/eal/common/eal_common_bus.c | 19 ++++++++++++++++ lib/eal/include/bus_driver.h | 6 +++++ 17 files changed, 55 insertions(+), 192 deletions(-)
Re: [PATCH v2 6/7] bus: factorize device selection
In reply to David MarchandFor uacce part,
Quoted 10 lines · David Marchand
All buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Reviewed-by Robin Jarry <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>
PATCH v2 7/7 eal: configure initial device probing
In reply to David MarchandSome applications use port hotplug as their primary way for using DPDK resources.
Having a systematic device probing is a problem when not all available resources will be used by the application, as such applications won't set an explicit allow list at startup.
This is the case for OVS on systems with multiple mlx5 devices:
one device can be used by the kernel while the other(s) are used by DPDK. In such a setup, the kernel used device may get reconfigured in unexpected ways and trigger issues like the one described by Kevin not so long ago in bugzilla 1873.
Add an EAL option so that we can change the default behavior from block-listing to allow-listing which can be summed up as disabling automatic probing.
In case some applications want to require automatic probing, add the opposite option.
---
Changes since RFC v2:
- added -A short option alias as it seems intuitive to use with -a,
- renamed option to --no-auto-probing (half Robin and half Thomas suggestions),
- made -A and -b conflicting options,
- added opposite option in case an application wants an explicit behavior,
- updated unit tests accordingly,
- updated documentation (namely some detail on --vdev),
Changes since RFC v1:
- changed approach following Bruce suggestion,
--- app/test/test_eal_flags.c | 63 +++++++++++++++++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 13 +++++ lib/eal/common/eal_common_bus.c | 17 +++--- lib/eal/common/eal_common_options.c | 10 ++++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + 7 files changed, 101 insertions(+), 7 deletions(-)
app/test/test_eal_flags.c +63 -0
@@ -119,6 +119,8 @@ test_misc_flags(void)#define no_hpet "--no-hpet"#define no_huge "--no-huge"#define no_shconf "--no-shconf" +#define auto_probing "--auto-probing" +#define no_auto_probing "--no-auto-probing"#define allow "--allow"#define vdev "--vdev"#define no_pci "--no-pci"
@@ -338,6 +340,14 @@ test_allow_flag(void) allow,"09:0B.3,type=test" , allow, "08:00.1,type=normal", }; +const char *wlval4[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing }; +const char *wlval5[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing, allow,"00FF:09:0B.3" }; +const char *wlval6[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing }; +const char *wlval7[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing, allow,"00FF:09:0B.3" };for (i =0 ; i <RTE_DIM (wlinval); i++) {if (launch_proc (wlinval[i]) ==0 ) {
@@ -360,6 +370,26 @@ test_allow_flag(void) __LINE__);return -1 ; } +if (launch_proc (wlval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing + allow\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval6) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval7) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing + allow\n" , + __LINE__); +return -1 ; + }return 0 ; }
@@ -383,6 +413,11 @@ test_invalid_b_flag(void) {prgname, prefix, mp_flag, eal_debug_logs, "-b", "error0:0:0.1"}, {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0.1.2"}, }; +const char *blinval_probing[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , auto_probing}; +const char *blinval_probing_inval[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , no_auto_probing}; +/* Test with valid blocklist option */ const char *blval[] = {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"FF:09:0B.3" };
@@ -396,6 +431,16 @@ test_invalid_b_flag(void)return -1 ; } } +if (launch_proc (blinval_probing) !=0 ) { +printf ("Error (line %d) - process did not run ok with blocklist and auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (blinval_probing_inval) ==0 ) { +printf ("Error (line %d) - process did run ok with blocklist and no-auto-probing\n" , + __LINE__); +return -1 ; + }if (launch_proc (blval) !=0 ) {printf ("Error (line %d) - process did not run ok with valid blocklist value\n" , __LINE__);
@@ -434,6 +479,12 @@ test_invalid_vdev_flag(void)const char *vdevval3[] = {prgname, prefix, no_huge, eal_debug_logs, bus_debug_logs, no_pci, vdev,"net_ring0,nodeaction=r1:0:CREATE" }; +const char *vdevval4[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, no_auto_probing, vdev,"net_ring0" }; + +const char *vdevval5[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, auto_probing, vdev,"net_ring0" }; +if (launch_proc (vdevinval) ==0 ) {printf ("Error (line %d) - process did run ok with invalid vdev parameter\n" , __LINE__);
@@ -457,6 +508,18 @@ test_invalid_vdev_flag(void) __LINE__); return -1; } + +if (launch_proc (vdevval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and no-auto-probing\n" , + __LINE__); +return -1 ; + } + +if (launch_proc (vdevval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and auto-probing\n" , + __LINE__); +return -1 ; + }return 0 ;#else return TEST_SKIPPED ;
devtools/test-null.sh +1 -1
@@ -30,7 +30,7 @@ logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ - $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ + $libs -A --vdev net_null1 --vdev net_null2 $eal_options -- \ --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile # we expect two ports and some traffic is received and transmitted
doc/guides/linux_gsg/eal_args.include.rst +13 -0
@@ -101,6 +101,19 @@ Lcore-related options Device-related options ~~~~~~~~~~~~~~~~~~~~~~ +* ``-A, --no-auto-probing`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b`` + options are passed. + Disable automatic probing of non-blocked devices. + +.. Note:: + Block list cannot be used when auto probing is disabled. + + On the other hand, disabling auto probing does not affect the VDEV bus. + The VDEV bus is not concerned by automatic probing and requires explicit + ``-a`` or ``--vdev``. + * ``-b, --block <[domain:]bus:devid.func>`` Skip probing a PCI device to prevent EAL from using it.
lib/eal/common/eal_common_bus.c +11 -6
@@ -250,18 +250,23 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_is_ignored_device)bool rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) { +const struct internal_config *internal_conf =eal_get_internal_configuration ();struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); +enum rte_bus_scan_mode scan_mode = bus->conf.scan_mode; -switch (bus->conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : +if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (internal_conf->no_auto_probing !=0 ) + scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +else + scan_mode =RTE_BUS_SCAN_BLOCKLIST ; + } + +if (scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) {if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : + }else {if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED )return false; -break ; }return true; }
lib/eal/common/eal_common_options.c +10 -0
@@ -233,10 +233,15 @@ eal_collate_args(int argc, char **argv)EAL_LOG (ERR ,"Options allow (-a) and block (-b) can't be used at the same time" );return -1 ; } +if (args.no_auto_probing && !TAILQ_EMPTY (&args.block)) { +EAL_LOG (ERR ,"Options no-auto-probing and block (-b) can't be used at the same time" ); +return -1 ; + }/* for non-list args, we can just check for zero/null values using macro */ if (CONFLICTING_OPTIONS(args, coremask, lcores) || CONFLICTING_OPTIONS(args, service_coremask, service_corelist) || + CONFLICTING_OPTIONS(args, no_auto_probing, auto_probing) || CONFLICTING_OPTIONS(args, no_telemetry, telemetry) || CONFLICTING_OPTIONS(args, memory_size, numa_mem) || CONFLICTING_OPTIONS(args, no_huge, numa_mem) ||
@@ -518,6 +523,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg)memset (internal_cfg->vfio_vf_token,0 ,sizeof (internal_cfg->vfio_vf_token)); + internal_cfg->no_auto_probing =0 ; +#ifdef RTE_LIBEAL_USE_HPET internal_cfg->no_hpet =0 ;#else
@@ -1972,6 +1979,9 @@ eal_parse_args(void) } } +if (args.no_auto_probing) + int_cfg->no_auto_probing =1 ; +/* device -a/-b/-vdev options*/ TAILQ_FOREACH (arg, &args.allow, next) if (eal_option_device_add(RTE_DEVTYPE_ALLOWED, arg->arg) < 0)
lib/eal/common/eal_internal_cfg.h +1 -0
@@ -104,6 +104,7 @@ struct internal_config {struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */ +unsigned int no_auto_probing;/**< true to switch from block-listing to allow-listing */ };void eal_reset_internal_config (struct internal_config *internal_cfg);
lib/eal/common/eal_option_list.h +2 -0
@@ -32,6 +32,7 @@* Format of each entry: long name, short name, help string, struct member name. */ /* (Alphabetical) List of common options first */ +BOOL_ARG("--auto-probing", NULL, "Let EAL probe all available devices unless some -a/-b option is set.", auto_probing) LIST_ARG("--allow", "-a", "Add device to allow-list, causing DPDK to only use specified devices", allow) STR_ARG("--base-virtaddr", NULL, "Base virtual address to reserve memory", base_virtaddr)LIST_ARG ("--block" ,"-b" ,"Add device to block-list, preventing DPDK from using the device" , block)
@@ -51,6 +52,7 @@ STR_ARG("--mbuf-pool-ops-name", NULL, "User defined mbuf default pool ops name", STR_ARG("--memory-channels", "-n", "Number of memory channels per socket", memory_channels) STR_ARG("--memory-ranks", "-r", "Force number of memory ranks (don't detect)", memory_ranks) STR_ARG("--memory-size", "-m", "Total size of memory to allocate initially", memory_size) +BOOL_ARG("--no-auto-probing", "-A", "Do not probe any devices unless some -a option is set", no_auto_probing) BOOL_ARG("--no-hpet", NULL, "Disable HPET timer", no_hpet) BOOL_ARG("--no-huge", NULL, "Disable hugetlbfs support", no_huge)BOOL_ARG ("--no-pci" ,NULL ,"Disable all PCI devices" , no_pci)
Signature · 1 line
2.53.0
Re: [PATCH v2 7/7] eal: configure initial device probing
Quoted 290 lines · David Marchand
Some applications use port hotplug as their primary way for using DPDK resources.
Having a systematic device probing is a problem when not all available resources will be used by the application, as such applications won't set an explicit allow list at startup.This is the case for OVS on systems with multiple mlx5 devices:
one device can be used by the kernel while the other(s) are used by DPDK. In such a setup, the kernel used device may get reconfigured in unexpected ways and trigger issues like the one described by Kevin not so long ago in bugzilla 1873.Add an EAL option so that we can change the default behavior from block-listing to allow-listing which can be summed up as disabling automatic probing.
In case some applications want to require automatic probing, add the opposite option.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Reviewed-by Robin Jarry <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>Acked-by Kevin Traynor <[email protected]>---
Changes since RFC v2:
- added -A short option alias as it seems intuitive to use with -a,
- renamed option to --no-auto-probing (half Robin and half Thomas suggestions),
- made -A and -b conflicting options,
- added opposite option in case an application wants an explicit behavior,
- updated unit tests accordingly,
- updated documentation (namely some detail on --vdev),Changes since RFC v1:
- changed approach following Bruce suggestion,--- app/test/test_eal_flags.c | 63 +++++++++++++++++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 13 +++++ lib/eal/common/eal_common_bus.c | 17 +++--- lib/eal/common/eal_common_options.c | 10 ++++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + 7 files changed, 101 insertions(+), 7 deletions(-)app/test/test_eal_flags.c +63
-0@@ -119,6 +119,8 @@ test_misc_flags(void)#define no_hpet "--no-hpet"#define no_huge "--no-huge"#define no_shconf "--no-shconf" +#define auto_probing "--auto-probing" +#define no_auto_probing "--no-auto-probing"#define allow "--allow"#define vdev "--vdev"#define no_pci "--no-pci"@@ -338,6 +340,14 @@ test_allow_flag(void) allow,"09:0B.3,type=test" , allow, "08:00.1,type=normal", }; +const char *wlval4[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing }; +const char *wlval5[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing, allow,"00FF:09:0B.3" }; +const char *wlval6[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing }; +const char *wlval7[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing, allow,"00FF:09:0B.3" };for (i =0 ; i <RTE_DIM (wlinval); i++) {if (launch_proc (wlinval[i]) ==0 ) {@@ -360,6 +370,26 @@ test_allow_flag(void) __LINE__);return -1 ; } +if (launch_proc (wlval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing + allow\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval6) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval7) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing + allow\n" , + __LINE__); +return -1 ; + }return 0 ; }@@ -383,6 +413,11 @@ test_invalid_b_flag(void) {prgname, prefix, mp_flag, eal_debug_logs, "-b", "error0:0:0.1"}, {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0.1.2"}, }; +const char *blinval_probing[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , auto_probing}; +const char *blinval_probing_inval[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , no_auto_probing}; +/* Test with valid blocklist option */ const char *blval[] = {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"FF:09:0B.3" };@@ -396,6 +431,16 @@ test_invalid_b_flag(void)return -1 ; } } +if (launch_proc (blinval_probing) !=0 ) { +printf ("Error (line %d) - process did not run ok with blocklist and auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (blinval_probing_inval) ==0 ) { +printf ("Error (line %d) - process did run ok with blocklist and no-auto-probing\n" , + __LINE__); +return -1 ; + }if (launch_proc (blval) !=0 ) {printf ("Error (line %d) - process did not run ok with valid blocklist value\n" , __LINE__);@@ -434,6 +479,12 @@ test_invalid_vdev_flag(void)const char *vdevval3[] = {prgname, prefix, no_huge, eal_debug_logs, bus_debug_logs, no_pci, vdev,"net_ring0,nodeaction=r1:0:CREATE" }; +const char *vdevval4[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, no_auto_probing, vdev,"net_ring0" }; + +const char *vdevval5[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, auto_probing, vdev,"net_ring0" }; +if (launch_proc (vdevinval) ==0 ) {printf ("Error (line %d) - process did run ok with invalid vdev parameter\n" , __LINE__);@@ -457,6 +508,18 @@ test_invalid_vdev_flag(void) __LINE__); return -1; } + +if (launch_proc (vdevval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and no-auto-probing\n" , + __LINE__); +return -1 ; + } + +if (launch_proc (vdevval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and auto-probing\n" , + __LINE__); +return -1 ; + }return 0 ;#else return TEST_SKIPPED ;devtools/test-null.sh +1
-1@@ -30,7 +30,7 @@ logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ - $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ + $libs -A --vdev net_null1 --vdev net_null2 $eal_options -- \ --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile # we expect two ports and some traffic is received and transmitteddoc/guides/linux_gsg/eal_args.include.rst +13
-0@@ -101,6 +101,19 @@ Lcore-related options Device-related options ~~~~~~~~~~~~~~~~~~~~~~ +* ``-A, --no-auto-probing`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b`` + options are passed. + Disable automatic probing of non-blocked devices. + +.. Note:: + Block list cannot be used when auto probing is disabled. + + On the other hand, disabling auto probing does not affect the VDEV bus. + The VDEV bus is not concerned by automatic probing and requires explicit + ``-a`` or ``--vdev``. + * ``-b, --block <[domain:]bus:devid.func>`` Skip probing a PCI device to prevent EAL from using it.lib/eal/common/eal_common_bus.c +11
-6@@ -250,18 +250,23 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_is_ignored_device)bool rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) { +const struct internal_config *internal_conf =eal_get_internal_configuration ();struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); +enum rte_bus_scan_mode scan_mode = bus->conf.scan_mode; -switch (bus->conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : +if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (internal_conf->no_auto_probing !=0 ) + scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +else + scan_mode =RTE_BUS_SCAN_BLOCKLIST ; + } + +if (scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) {if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : + }else {if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED )return false; -break ; }return true; }lib/eal/common/eal_common_options.c +10
-0@@ -233,10 +233,15 @@ eal_collate_args(int argc, char **argv)EAL_LOG (ERR ,"Options allow (-a) and block (-b) can't be used at the same time" );return -1 ; } +if (args.no_auto_probing && !TAILQ_EMPTY (&args.block)) { +EAL_LOG (ERR ,"Options no-auto-probing and block (-b) can't be used at the same time" ); +return -1 ; + }/* for non-list args, we can just check for zero/null values using macro */ if (CONFLICTING_OPTIONS(args, coremask, lcores) || CONFLICTING_OPTIONS(args, service_coremask, service_corelist) || + CONFLICTING_OPTIONS(args, no_auto_probing, auto_probing) || CONFLICTING_OPTIONS(args, no_telemetry, telemetry) || CONFLICTING_OPTIONS(args, memory_size, numa_mem) || CONFLICTING_OPTIONS(args, no_huge, numa_mem) ||@@ -518,6 +523,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg)memset (internal_cfg->vfio_vf_token,0 ,sizeof (internal_cfg->vfio_vf_token)); + internal_cfg->no_auto_probing =0 ; +#ifdef RTE_LIBEAL_USE_HPET internal_cfg->no_hpet =0 ;#else @@ -1972,6 +1979,9 @@ eal_parse_args(void) } } +if (args.no_auto_probing) + int_cfg->no_auto_probing =1 ; +/* device -a/-b/-vdev options*/ TAILQ_FOREACH (arg, &args.allow, next) if (eal_option_device_add(RTE_DEVTYPE_ALLOWED, arg->arg) < 0)lib/eal/common/eal_internal_cfg.h +1
-0@@ -104,6 +104,7 @@ struct internal_config {struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */ +unsigned int no_auto_probing;/**< true to switch from block-listing to allow-listing */ };void eal_reset_internal_config (struct internal_config *internal_cfg);lib/eal/common/eal_option_list.h +0
-0
lib/eal/common/eal_option_list.h line 35
Quoted 4 lines
lib/eal/common/eal_option_list.h +1
-0@@ -32,6 +32,7 @@* Format of each entry: long name, short name, help string, struct member name. */ /* (Alphabetical) List of common options first */ +BOOL_ARG ("--auto-probing" ,NULL ,"Let EAL probe all available devices unless some -a/-b option is set." , auto_probing)
This commit only check auto_probing and no_auto_probing conflict,
I think it no need add this arg because auto-probing is default behavir when -a/-b not exist.
Quoted 11 lines
lib/eal/common/eal_option_list.h +1
-0LIST_ARG("--allow", "-a", "Add device to allow-list, causing DPDK to only use specified devices", allow) STR_ARG("--base-virtaddr", NULL, "Base virtual address to reserve memory", base_virtaddr)LIST_ARG ("--block" ,"-b" ,"Add device to block-list, preventing DPDK from using the device" , block)@@ -51,6 +52,7 @@ STR_ARG("--mbuf-pool-ops-name", NULL, "User defined mbuf default pool ops name", STR_ARG("--memory-channels", "-n", "Number of memory channels per socket", memory_channels) STR_ARG("--memory-ranks", "-r", "Force number of memory ranks (don't detect)", memory_ranks) STR_ARG("--memory-size", "-m", "Total size of memory to allocate initially", memory_size) +BOOL_ARG("--no-auto-probing", "-A", "Do not probe any devices unless some -a option is set", no_auto_probing) BOOL_ARG("--no-hpet", NULL, "Disable HPET timer", no_hpet) BOOL_ARG("--no-huge", NULL, "Disable hugetlbfs support", no_huge)BOOL_ARG ("--no-pci" ,NULL ,"Disable all PCI devices" , no_pci)
Re: [PATCH v2 7/7] eal: configure initial device probing
Quoted 11 lines · fengchengwen
Quoted 11 lines
lib/eal/common/eal_internal_cfg.h +1
-0@@ -104,6 +104,7 @@ struct internal_config {struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */ +unsigned int no_auto_probing;/**< true to switch from block-listing to allow-listing */ };
Quoted 13 lines
lib/eal/common/eal_option_list.h line 35
Quoted 10 lines
lib/eal/common/eal_internal_cfg.h +0
-0void eal_reset_internal_config (struct internal_config *internal_cfg);lib/eal/common/eal_option_list.h +1
-0@@ -32,6 +32,7 @@* Format of each entry: long name, short name, help string, struct member name. */ /* (Alphabetical) List of common options first */ +BOOL_ARG ("--auto-probing" ,NULL ,"Let EAL probe all available devices unless some -a/-b option is set." , auto_probing)This commit only check
auto_probingandno_auto_probingconflict,
I think it no need add this arg because auto-probing is default behavir when -a/-b not exist.
Introducing the --auto-probing was an ask from Thomas, so that applications can start requesting an explicit behavior, rather than just rely on the *current* default behavior.
Signature · 1 line
David Marchand
v3 cover Rework device probing
In reply to David MarchandApplications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
Signature · 70 lines
David Marchand Changes since v2: - rebased for late 26.03 fslmc bus changes, - fixed devargs lookup, - added debug logs, Changes since v1: - restored per bus scan mode, - fixed logic in device selection for dma/idxd, - fixed raw/ifpga hotplug on ifpga bus, - fixed some doxygen, Changes since RFC v3: - removed per bus scan mode, Changes since RFC v2: - went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5), - updated device selection helper accordingly and changed API to be device name based, - renamed option, added check on -b presence, updated doc in the last patch, Changes since RFC v1: - reviewed bus probe() and cleaned up NXP drivers, - changed approach following Bruce comment, David Marchand (7): devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup drivers/bus: require probe function for NXP drivers drivers/bus: cleanup devargs lookup in scan bus: factorize devargs lookup bus: factorize device selection eal: configure initial device probing app/test/test_eal_flags.c | 63 ++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 13 ++++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +-------- drivers/bus/dpaa/dpaa_bus.c | 71 ++++++++---------- drivers/bus/fslmc/fslmc_bus.c | 75 ++++++++------------ drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/ifpga_bus.c | 8 ++- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++--------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +---------- drivers/bus/uacce/uacce.c | 39 +--------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 - drivers/bus/vmbus/vmbus_common.c | 45 +++--------- drivers/dma/idxd/idxd_bus.c | 18 +---- lib/eal/common/eal_common_bus.c | 54 ++++++++++++++ lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/include/bus_driver.h | 38 ++++++++++ 29 files changed, 301 insertions(+), 367 deletions(-) -- 2.53.0
PATCH v3 1/7 devtools: check packet forwarding in null test
Add some simple checks that testpmd was indeed polling two ports, and some packets got through it.
--- devtools/test-null.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
devtools/test-null.sh +7 -1
@@ -26,8 +26,14 @@ else libs= fi +logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ - --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia + --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile + +# we expect two ports and some traffic is received and transmitted +grep -q 'io packet forwarding - ports=2 -' $build/test-null.log +grep 'RX-packets: ' $logfile | tail -1 | grep -q 'RX-packets:[[:space:]]*[^0[:space:]]' +grep 'TX-packets: ' $logfile | tail -1 | grep -q 'TX-packets:[[:space:]]*[^0[:space:]]'
Signature · 1 line
2.53.0
PATCH v3 2/7 bus/fslmc: fix bus cleanup
In reply to David MarchandThe close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +4 -17
@@ -1393,7 +1393,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, {struct rte_dpaa2_object *object =NULL ;struct rte_dpaa2_driver *drv; -int ret, probe_all; +int ret;switch (dev->dev_type) {case DPAA2_IO :
@@ -1411,22 +1411,9 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - probe_all = rte_fslmc_bus.bus.conf.scan_mode != -RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { -if (drv->drv_type != dev->dev_type) -continue ; -if (rte_dev_is_probed (&dev->device)) -continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy == -RTE_DEV_ALLOWED )) { - ret = drv->remove (dev); -if (ret) -DPAA2_BUS_ERR ("Unable to remove" ); - } - } + drv = dev->driver; +if (drv && drv->remove && drv->remove (dev)) +DPAA2_BUS_ERR ("Unable to remove" );break ;default :break ;
Signature · 1 line
2.53.0
PATCH v3 3/7 drivers/bus: require probe function for NXP drivers
In reply to David MarchandRather than silently ignore an invalid driver, enforce every registered driver has a probe callback.
--- drivers/bus/dpaa/dpaa_bus.c | 6 +++--- drivers/bus/fslmc/fslmc_bus.c | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -3
@@ -614,6 +614,7 @@ void rte_dpaa_driver_register(struct rte_dpaa_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );BUS_INIT_FUNC_TRACE ();
@@ -808,9 +809,8 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (!drv->probe || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED )) +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED )continue ; if (probe_all ||
drivers/bus/fslmc/fslmc_bus.c +1 -6
@@ -469,9 +469,6 @@ rte_fslmc_probe(void)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
@@ -538,6 +535,7 @@ void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );TAILQ_INSERT_TAIL (&rte_fslmc_bus.driver_list, driver, next); }
@@ -605,9 +603,6 @@ fslmc_bus_plug(struct rte_device *rte_dev)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
Signature · 1 line
2.53.0
PATCH v3 4/7 drivers/bus: cleanup devargs lookup in scan
In reply to David MarchandDon'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.
---
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(-)
drivers/bus/auxiliary/auxiliary_common.c +1 -1
@@ -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; }
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -2
@@ -28,8 +28,6 @@extern "C" {#endif -#define RTE_BUS_AUXILIARY_NAME "auxiliary" -/* Forward declarations */ struct rte_auxiliary_driver ;struct rte_auxiliary_device ;
drivers/bus/cdx/cdx.c +1 -2
@@ -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; }
drivers/bus/dpaa/dpaa_bus.c +2 -4
@@ -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 );
drivers/bus/fslmc/fslmc_bus.c +3 -5
@@ -26,7 +26,6 @@#include <dpaax_iova_table.h> #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups" -#define FSLMC_BUS_NAME fslmcstruct 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 );
drivers/bus/ifpga/ifpga_bus.c +6 -2
@@ -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 );
drivers/bus/pci/pci_common.c +1 -1
@@ -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;
drivers/bus/platform/platform.c +1 -1
@@ -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; }
drivers/bus/uacce/uacce.c +1 -1
@@ -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; }
drivers/bus/vdev/vdev.c +1 -1
@@ -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)
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -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 )
Signature · 1 line
2.53.0
PATCH v3 5/7 bus: factorize devargs lookup
In reply to David MarchandEach bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.
---
Changes since v2:
- rebased on 26.03 fslmc changes,
- fixed devargs lookup for uacce bus (and buses != pci, fslmc),
- added a debug log,
Changes since v1:
- fixed copy/paste descriptions in doxygen,
Changes since RFC v3:
- fixed doxygen,
--- drivers/bus/auxiliary/auxiliary_common.c | 16 ++------- drivers/bus/cdx/cdx.c | 14 +------- drivers/bus/dpaa/dpaa_bus.c | 41 +++++++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 37 +++++++++++---------- drivers/bus/pci/pci_common.c | 38 +++++++++++----------- drivers/bus/platform/platform.c | 17 ++-------- drivers/bus/uacce/uacce.c | 19 ++--------- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 -- drivers/bus/vmbus/vmbus_common.c | 30 ++++++++--------- drivers/dma/idxd/idxd_bus.c | 14 ++------ lib/eal/common/eal_common_bus.c | 28 ++++++++++++++++ lib/eal/include/bus_driver.h | 32 ++++++++++++++++++ 13 files changed, 142 insertions(+), 149 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +2 -14
@@ -25,18 +25,6 @@#include "private.h" -static struct rte_devargs * -auxiliary_devargs_lookup (const char *name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(auxiliary_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } -return NULL ; -} -#ifndef AUXILIARY_OS_SUPPORTED /* * Test whether the auxiliary device exist.
@@ -68,7 +56,7 @@ auxiliary_scan(void)void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev) { - aux_dev->device.devargs =auxiliary_devargs_lookup (aux_dev->name); + aux_dev->device.devargs =rte_bus_find_devargs (&auxiliary_bus.bus, aux_dev->name); }/*
@@ -399,7 +387,7 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,bool auxiliary_is_ignored_device (const char *name) { -struct rte_devargs *devargs =auxiliary_devargs_lookup (name); +struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name);switch (auxiliary_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/cdx/cdx.c +1 -13
@@ -151,22 +151,10 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static struct rte_devargs * -cdx_devargs_lookup (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(rte_cdx_bus.bus.name, devargs) { -if (strcmp (devargs->name, dev_name) ==0 ) -return devargs; - } -return NULL ; -} -static bool cdx_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =cdx_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name);switch (rte_cdx_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/dpaa/dpaa_bus.c +22 -19
77 lines not on this page · raw message
drivers/bus/fslmc/fslmc_bus.c +18 -19
@@ -99,22 +99,6 @@ insert_in_device_list(struct rte_dpaa2_device *newdev)TAILQ_INSERT_TAIL (&rte_fslmc_bus.device_list, newdev, next); } -static struct rte_devargs * -fslmc_devargs_lookup (struct rte_dpaa2_device *dev) -{ -struct rte_devargs *devargs; -char dev_name[32 ]; - - 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); -return devargs; - } - } -return NULL ; -} -static void dump_device_list (void ) {
@@ -216,7 +200,7 @@ scan_one_fslmc_device(char *dev_name) ret = -ENOMEM ; goto cleanup; } - dev->device.devargs =fslmc_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus.bus, dev_name);/* Update the device found into the device_count table */ rte_fslmc_bus.device_count[dev->dev_type]++;
@@ -308,6 +292,18 @@ rte_fslmc_parse(const char *name, void *addr)return ret; } +static int +fslmc_devname_compare (const char *name1,const char *name2) +{ +char devname1[32 ], devname2[32 ]; + +if (rte_fslmc_parse (name1, devname1) !=0 || +rte_fslmc_parse (name2, devname2) !=0 ) +return 1 ; + +return strncmp (devname1, devname2,sizeof (devname1)); +} +static int rte_fslmc_scan (void ) {
@@ -323,8 +319,10 @@ rte_fslmc_scan(void)struct rte_dpaa2_device *dev;DPAA2_BUS_DEBUG ("Fslmc bus already scanned. Not rescanning" ); -TAILQ_FOREACH (dev, &rte_fslmc_bus.device_list, next) - dev->device.devargs = fslmc_devargs_lookup(dev); + TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { + dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus.bus, + dev->device.name); + }return 0 ; } process_once =1 ;
@@ -695,6 +693,7 @@ struct rte_fslmc_bus rte_fslmc_bus = { .probe = rte_fslmc_probe, .cleanup = rte_fslmc_close, .parse = rte_fslmc_parse, + .devname_compare = fslmc_devname_compare, .find_device = rte_fslmc_find_device, .get_iommu_class = rte_dpaa2_get_iommu_class, .plug = fslmc_bus_plug,
drivers/bus/pci/pci_common.c +19 -19
@@ -79,32 +79,15 @@ pci_asprintf(char **buffer, const char *format, ...) }#endif /* RTE_EXEC_ENV_WINDOWS */ -static struct rte_devargs * -pci_devargs_lookup (const struct rte_pci_addr *pci_addr) -{ -struct rte_devargs *devargs; -struct rte_pci_addr addr; - - 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; - } -return NULL ; -} - void pci_common_set(struct rte_pci_device *dev) { - struct rte_devargs *devargs; - /* Each device has its internal, canonical name set. */ rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name)); dev->device.name = dev->name; - devargs = pci_devargs_lookup(&dev->addr); - dev->device.devargs = devargs; + dev->device.devargs = rte_bus_find_devargs(&rte_pci_bus.bus, dev->name); if (dev->bus_info != NULL || asprintf(&dev->bus_info, "vendor_id=%"PRIx16", device_id=%"PRIx16,
@@ -503,6 +486,18 @@ pci_parse(const char *name, void *addr)return parse == false; } +static int +pci_devname_compare (const char *name1,const char *name2) +{ +struct rte_pci_addr addr1, addr2; + +if (rte_pci_addr_parse (name1, &addr1) !=0 || +rte_pci_addr_parse (name2, &addr2) !=0 ) +return 1 ; + +return rte_pci_addr_cmp (&addr1, &addr2); +} +/* register a driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_pci_register) void
@@ -721,7 +716,11 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) { -struct rte_devargs *devargs =pci_devargs_lookup (pci_addr); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_pci_device_name (pci_addr, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name);switch (rte_pci_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -946,6 +945,7 @@ struct rte_pci_bus rte_pci_bus = { .plug = pci_plug, .unplug = pci_unplug, .parse = pci_parse, + .devname_compare = pci_devname_compare, .devargs_parse = rte_pci_devargs_parse, .dma_map = pci_dma_map, .dma_unmap = pci_dma_unmap,
drivers/bus/platform/platform.c +2 -15
@@ -43,25 +43,12 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static struct rte_devargs * -dev_devargs (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(platform_bus.bus.name, devargs) { -if (!strcmp (devargs->name, dev_name)) -return devargs; - } - -return NULL ; -} -static bool dev_allowed (const char *dev_name) {struct rte_devargs *devargs; - devargs =dev_devargs (dev_name); + devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name);if (devargs ==NULL )return true;
@@ -93,7 +80,7 @@ dev_add(const char *dev_name)rte_strscpy (pdev->name, dev_name,sizeof (pdev->name)); pdev->device.name = pdev->name; - pdev->device.devargs =dev_devargs (dev_name); + pdev->device.devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); pdev->device.bus = &platform_bus.bus;snprintf (path,sizeof (path),PLATFORM_BUS_DEVICES_PATH "/%s/numa_node" , dev_name); pdev->device.numa_node =eal_parse_sysfs_value (path, &val) ?rte_socket_id () : val;
drivers/bus/uacce/uacce.c +2 -17
@@ -70,25 +70,10 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static struct rte_devargs * -uacce_devargs_lookup (const char *dev_name) -{ -char name[RTE_UACCE_DEV_PATH_SIZE ] = {0 }; -struct rte_devargs *devargs; - -snprintf (name,sizeof (name),"%s%s" ,UACCE_DEV_PREFIX , dev_name); - RTE_EAL_DEVARGS_FOREACH(uacce_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } - -return NULL ; -} -static bool uacce_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =uacce_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);switch (uacce_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -257,7 +242,7 @@ uacce_scan_one(const char *dev_name) dev->device.bus = &uacce_bus.bus; dev->device.name = dev->name; - dev->device.devargs =uacce_devargs_lookup (dev_name); + dev->device.devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);snprintf (dev->name,sizeof (dev->name),"%s" , dev_name);snprintf (dev->dev_root,sizeof (dev->dev_root),"%s/%s" ,UACCE_BUS_CLASS_PATH , dev_name);
drivers/bus/vmbus/linux/vmbus_bus.c +1 -1
@@ -333,7 +333,7 @@ vmbus_scan_one(const char *name) dev->monitor_id =UINT8_MAX ; } - dev->device.devargs =vmbus_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, dev_name); dev->device.numa_node =SOCKET_ID_ANY ;if (vmbus_use_numa (dev)) {
drivers/bus/vmbus/private.h +0 -3
@@ -98,9 +98,6 @@ struct vmbus_channel {#define VMBUS_MAX_CHANNELS 64 -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev); -int vmbus_chan_create (const struct rte_vmbus_device *device,uint16_t relid,uint16_t subid,uint8_t monitor_id,struct vmbus_channel **new_chan);
drivers/bus/vmbus/vmbus_common.c +13 -17
@@ -171,7 +171,11 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)static bool vmbus_ignore_device (struct rte_vmbus_device *dev) { -struct rte_devargs *devargs =vmbus_devargs_lookup (dev); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_uuid_unparse (dev->device_id, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name);switch (rte_vmbus_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -260,25 +264,16 @@ vmbus_parse(const char *name, void *addr)return ret; } -/* -* scan for matching device args on command line -* example: -* -a 'vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20' -*/ -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev) +static int +vmbus_devname_compare (const char *name1,const char *name2) { -struct rte_devargs *devargs; -rte_uuid_t addr; - - RTE_EAL_DEVARGS_FOREACH(rte_vmbus_bus.bus.name, devargs) { -vmbus_parse (devargs->name, &addr); +rte_uuid_t guid1, guid2; -if (rte_uuid_compare (dev->device_id, addr) ==0 ) -return devargs; - } -return NULL ; +if (vmbus_parse (name1, &guid1) !=0 || +vmbus_parse (name2, &guid2) !=0 ) +return 1 ; +return rte_uuid_compare (guid1, guid2); }/* register vmbus driver */
@@ -349,6 +344,7 @@ struct rte_vmbus_bus rte_vmbus_bus = { .cleanup = rte_vmbus_cleanup, .find_device = vmbus_find_device, .parse = vmbus_parse, + .devname_compare = vmbus_devname_compare, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.driver_list),
drivers/dma/idxd/idxd_bus.c +2 -12
@@ -247,16 +247,6 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return 0 ; } -static int search_devargs (const char *name) -{ -struct rte_devargs *devargs; - RTE_EAL_DEVARGS_FOREACH(dsa_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return 1 ; - } -return 0 ; -} -static int is_for_this_process_use (struct rte_dsa_device *dev,const char *name) {
@@ -275,9 +265,9 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) {if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ;else - retval = !search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; }return retval;
lib/eal/common/eal_common_bus.c +28 -0
@@ -8,6 +8,7 @@#include <bus_driver.h> #include <rte_debug.h> +#include <rte_devargs.h> #include <rte_string_fns.h> #include <rte_errno.h>
@@ -205,6 +206,33 @@ rte_bus_find_by_name(const char *busname)return rte_bus_find (NULL , cmp_bus_name, (const void *)busname); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_find_devargs) +struct rte_devargs * +rte_bus_find_devargs (const struct rte_bus *bus,const char *name) +{ +rte_bus_devname_compare_t cmp = bus->devname_compare; +const char *bus_name =rte_bus_name (bus); +struct rte_devargs *devargs; + +if (cmp ==NULL ) + cmp = strcmp; + + RTE_EAL_DEVARGS_FOREACH(bus_name, devargs) { +const char *devargs_name = devargs->name; + +/* The name in the devargs is usually prefixed with <bus>: */ +if (strncmp (devargs_name, bus_name,strlen (bus_name)) ==0 ) + devargs_name +=strlen (bus_name) +1 ; +if (cmp (name, devargs_name) !=0 ) +continue ; +EAL_LOG (DEBUG ,"found devargs for %s:%s" , bus_name, name); +return devargs; + } + +EAL_LOG (DEBUG ,"no devargs for %s:%s" , bus_name, name); +return NULL ; +} +static int bus_can_parse (const struct rte_bus *bus,const void *_name) {
lib/eal/include/bus_driver.h +32 -0
@@ -118,6 +118,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);*/ typedef int (*rte_bus_parse_t )(const char *name,void *addr); +/** +* Bus specific device name comparison function. +* Bus can normalize the names of devices using an internal representation. +* This helper makes it possible to check whether two names refer to the same device. +* +* @param[in] name1 +* device name +* @param[in] name2 +* device name +* +* @return +* 0 if the two names refer to the same device. +* !0 otherwise. +*/ +typedef int (*rte_bus_devname_compare_t )(const char *name1,const char *name2); +/** * Parse bus part of the device arguments. *
@@ -258,6 +274,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +rte_bus_devname_compare_t devname_compare;/**< Compare two device names */ rte_bus_devargs_parse_t devargs_parse;/**< Parse bus devargs */ rte_dev_dma_map_t dma_map;/**< DMA map for device in the bus */ rte_dev_dma_unmap_t dma_unmap;/**< DMA unmap for device in the bus */
@@ -281,6 +298,21 @@ struct rte_bus {__rte_internal void rte_bus_register(struct rte_bus *bus); +/** +* Find the devargs associated to a device. +* +* @param bus +* A pointer to a rte_bus structure describing the bus +* to search for devargs on. +* @param dev_name +* A device name. +* +* @return +* Pointer to the device devargs, or NULL if none found. +*/ +__rte_internal +struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
Re: [PATCH v3 5/7] bus: factorize devargs lookup
For uacce part:
Quoted 14 lines · David Marchand
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>Acked-by Kevin Traynor <[email protected]>
Re: [PATCH v3 5/7] bus: factorize devargs lookup
In reply to David Marchand07/04/2026 13:52, David Marchand:
Quoted 8 lines
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.
I agree with introducing a new bus helper.
[...]
lib/eal/common/eal_common_bus.c rte_bus_find_by_name(const char *busname) · line 223
Quoted 1 line
lib/eal/common/eal_common_bus.c +1
-0+/* The name in the devargs is usually prefixed with <bus>: */
Is it usually prefixed or always prefixed?
lib/eal/common/eal_common_bus.c rte_bus_find_by_name(const char *busname) · line 225
Quoted 2 lines
lib/eal/common/eal_common_bus.c +2
-0+if (strncmp (devargs_name, bus_name,strlen (bus_name)) ==0 ) + devargs_name +=strlen (bus_name) +1 ;
If I understand well, if it is prefixed with bus name, it is assumed that a colon character will follow.
[...]
Quoted 5 lines
lib/eal/include/bus_driver.h +5
-0+/** +* Bus specific device name comparison function. +* Bus can normalize the names of devices using an internal representation. +* This helper makes it possible to check whether two names refer to the same device. +*
lib/eal/include/bus_driver.h typedef int (*rte_bus_unplug_t)(struct rte_device *dev); · line 135
Quoted 10 lines
lib/eal/include/bus_driver.h +10
-0+* @param[in] name1 +* device name +* @param[in] name2 +* device name +* +* @return +* 0 if the two names refer to the same device. +* !0 otherwise. +*/ +typedef int (*rte_bus_devname_compare_t )(const char *name1,const char *name2);
The helper compares internal representation of the device, not the names. The function should be rte_bus_dev_compare_t.
Re: [PATCH v3 5/7] bus: factorize devargs lookup
13/04/2026 21:18, Thomas Monjalon:
Quoted 17 lines
07/04/2026 13:52, David Marchand:
Quoted 8 lines
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.I agree with introducing a new bus helper.
[...]
lib/eal/common/eal_common_bus.c rte_bus_find_by_name(const char *busname) · line 223
Quoted 1 line
lib/eal/common/eal_common_bus.c +1
-0+/* The name in the devargs is usually prefixed with <bus>: */ Is it usually prefixed or always prefixed?
Quoted 5 lines
lib/eal/common/eal_common_bus.c rte_bus_find_by_name(const char *busname) · line 225
Quoted 2 lines
lib/eal/common/eal_common_bus.c +2
-0+if (strncmp (devargs_name, bus_name,strlen (bus_name)) ==0 ) + devargs_name +=strlen (bus_name) +1 ;If I understand well, if it is prefixed with bus name, it is assumed that a colon character will follow.
In the function rte_bus_find_devargs(), there is this comment:
+ /* The name in the devargs is usually prefixed with : */
+ if (strncmp(devargs_name, bus_name, strlen(bus_name)) == 0)
+ devargs_name += strlen(bus_name) + 1;
I think you mean "prefixed with <bus>:".
Quoted 19 lines
[...]
Quoted 5 lines
lib/eal/include/bus_driver.h +5
-0+/** +* Bus specific device name comparison function. +* Bus can normalize the names of devices using an internal representation. +* This helper makes it possible to check whether two names refer to the same device. +* lib/eal/include/bus_driver.h typedef int (*rte_bus_unplug_t)(struct rte_device *dev); · line 135
Quoted 10 lines
lib/eal/include/bus_driver.h +10
-0+* @param[in] name1 +* device name +* @param[in] name2 +* device name +* +* @return +* 0 if the two names refer to the same device. +* !0 otherwise. +*/ +typedef int (*rte_bus_devname_compare_t )(const char *name1,const char *name2);The helper compares internal representation of the device, not the names. The function should be
rte_bus_dev_compare_t.
Re: [PATCH v3 5/7] bus: factorize devargs lookup
13/04/2026 21:48, Thomas Monjalon:
Quoted 8 lines
13/04/2026 21:18, Thomas Monjalon:
In the functionrte_bus_find_devargs(), there is this comment:lib/eal/common/eal_common_bus.c +3
-0+/* The name in the devargs is usually prefixed with : */ +if (strncmp (devargs_name, bus_name,strlen (bus_name)) ==0 ) + devargs_name +=strlen (bus_name) +1 ;I think you mean "prefixed with <bus>:".
Actually this is what you wrote but my mail software hides it because of a bug. You can ignore this comment.
Re: [PATCH v3 5/7] bus: factorize devargs lookup
In reply to Thomas MonjalonQuoted 10 lines · Thomas Monjalon
07/04/2026 13:52, David Marchand:
Quoted 8 lines
Each bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.
Quoted 6 lines
I agree with introducing a new bus helper.
[...]
Quoted 1 line
+ /* The name in the devargs is usually prefixed with <bus>: */
Is it usually prefixed or always prefixed?
"usually", for legacy reasons (like PCI address are understood as is, or with pci: prefix).
Signature · 1 line
David Marchand
PATCH v3 6/7 bus: factorize device selection
In reply to David MarchandAll buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.
---
Changes since v2:
- added a debug log in the helper,
Changes since v1:
- fixed device selection in dma/idxd,
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,
--- drivers/bus/auxiliary/auxiliary_common.c | 19 ---------------- drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 ----- drivers/bus/cdx/cdx.c | 21 +----------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++-------------- drivers/bus/fslmc/fslmc_bus.c | 25 ++++++--------------- drivers/bus/pci/bsd/pci.c | 5 ++++- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 23 ------------------- drivers/bus/pci/private.h | 11 ---------- drivers/bus/pci/windows/pci.c | 4 +++- drivers/bus/platform/platform.c | 28 ++---------------------- drivers/bus/uacce/uacce.c | 22 +------------------ drivers/bus/vmbus/vmbus_common.c | 25 +-------------------- drivers/dma/idxd/idxd_bus.c | 8 ++----- lib/eal/common/eal_common_bus.c | 21 ++++++++++++++++++ lib/eal/include/bus_driver.h | 6 +++++ 17 files changed, 57 insertions(+), 195 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -19
@@ -384,25 +384,6 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,return aux_dev->driver->dma_unmap (aux_dev, addr, iova, len); } -bool -auxiliary_is_ignored_device (const char *name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name); - -switch (auxiliary_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -static enum rte_iova_mode auxiliary_get_iommu_class (void ) {
drivers/bus/auxiliary/linux/auxiliary.c +1 -1
@@ -110,7 +110,7 @@ auxiliary_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (auxiliary_is_ignored_device (e->d_name)) +if (rte_bus_is_ignored_device (&auxiliary_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/auxiliary/private.h +0 -6
@@ -53,12 +53,6 @@ int auxiliary_scan(void);*/ void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev); -/* -* Validate whether a device with given auxiliary device should be ignored -* or not. -*/ -bool auxiliary_is_ignored_device (const char *name); -/* * Add an auxiliary device to the auxiliary bus (append to auxiliary device * list). This function also updates the bus references of the auxiliary
drivers/bus/cdx/cdx.c +1 -20
@@ -151,25 +151,6 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static bool -cdx_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name); - -switch (rte_cdx_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan one cdx sysfs entry, and fill the devices list from it. * It checks if the CDX device is bound to vfio-cdx driver. In case
@@ -269,7 +250,7 @@ cdx_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (cdx_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&rte_cdx_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/dpaa/dpaa_bus.c +7 -17
@@ -717,7 +717,6 @@ rte_dpaa_bus_probe(void)struct rte_dpaa_driver *drv;FILE *svr_file =NULL ;uint32_t svr_ver; -int probe_all = rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ;static int process_once;char *penv;
@@ -725,9 +724,6 @@ rte_dpaa_bus_probe(void)if (!rte_dpaa_bus.detected)return 0 ; -if (rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ) - probe_all = true; - svr_file =fopen (DPAA_SOC_ID_FILE ,"r" );if (svr_file) {if (fscanf (svr_file,"svr:%x" , &svr_ver) >0 )
@@ -809,21 +805,15 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) +if (rte_bus_is_ignored_device (&rte_dpaa_bus.bus, dev->name))continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA_BUS_ERR ("unable to probe:%s" , - dev->name); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA_BUS_ERR ("unable to probe: %s" , dev->name); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/fslmc/fslmc_bus.c +7 -18
@@ -410,7 +410,6 @@ static intrte_fslmc_probe (void) {int ret =0 ; -int probe_all;struct rte_dpaa2_device *dev;struct rte_dpaa2_driver *drv;
@@ -457,8 +456,6 @@ rte_fslmc_probe(void)return 0 ; } - probe_all = rte_fslmc_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { ret =rte_fslmc_match (drv, dev);
@@ -468,23 +465,15 @@ rte_fslmc_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { -DPAA2_BUS_LOG (DEBUG ,"%s Blocked, skipping" , - dev->device.name); +if (rte_bus_is_ignored_device (&rte_fslmc_bus.bus, dev->device.name))continue ; - } -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA2_BUS_ERR ("Unable to probe" ); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/pci/bsd/pci.c +4 -1
@@ -370,12 +370,15 @@ rte_pci_scan(void) }for (i =0 ; i < conf_io.num_matches; i++) { +char name[RTE_DEV_NAME_MAX_LEN ]; + pci_addr.domain = matches[i].pc_sel.pc_domain; pci_addr.bus = matches[i].pc_sel.pc_bus; pci_addr.devid = matches[i].pc_sel.pc_dev; pci_addr.function = matches[i].pc_sel.pc_func; +rte_pci_device_name (&pci_addr, name,sizeof (name)); -if (rte_pci_ignore_device (&pci_addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name))continue ;if (pci_scan_one (fd, &matches[i]) <0 )
drivers/bus/pci/linux/pci.c +1 -1
@@ -458,7 +458,7 @@ rte_pci_scan(void)if (parse_pci_addr_format (e->d_name,sizeof (e->d_name), &addr) !=0 )continue ; -if (rte_pci_ignore_device (&addr)) +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/pci/pci_common.c +0 -23
@@ -713,29 +713,6 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)return -1 ; } -bool -rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_pci_device_name (pci_addr, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name); - -switch (rte_pci_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -enum rte_iova_mode rte_pci_get_iommu_class (void ) {
drivers/bus/pci/private.h +0 -11
@@ -82,17 +82,6 @@ pci_common_set(struct rte_pci_device *dev);void pci_free (struct rte_pci_device_internal *pdev); -/** -* Validate whether a device with given PCI address should be ignored or not. -* -* @param pci_addr -* PCI address of device to be validated -* @return -* true: if device is to be ignored, -* false: if device is to be scanned, -*/ -bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr); -/** * Add a PCI device to the PCI Bus (append to PCI Device list). This function * also updates the bus references of the PCI Device (and the generic device
drivers/bus/pci/windows/pci.c +3 -1
@@ -373,6 +373,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)struct rte_pci_device *dev =NULL ;int ret =-1 ;char pci_device_info[REGSTR_VAL_MAX_HCID_LEN ]; +char name[RTE_DEV_NAME_MAX_LEN ];struct rte_pci_addr addr;struct rte_pci_id pci_id;
@@ -380,7 +381,8 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)if (ret !=0 ) goto end; -if (rte_pci_ignore_device (&addr)) { +rte_pci_device_name (&addr, name,sizeof (name)); +if (rte_bus_is_ignored_device (&rte_pci_bus.bus, name)) {/* * We won't add this device, but we want to continue * looking for supported devices
drivers/bus/platform/platform.c +2 -26
@@ -43,30 +43,6 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static bool -dev_allowed (const char *dev_name) -{ -struct rte_devargs *devargs; - - devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); -if (devargs ==NULL ) -return true; - -switch (platform_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs->policy ==RTE_DEV_ALLOWED ) -return true; -break ; -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs->policy ==RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -static int dev_add (const char *dev_name) {
@@ -160,7 +136,7 @@ platform_bus_scan(void)if (dev_name[0 ] =='.' )continue ; -if (!dev_allowed (dev_name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev_name))continue ;if (!dev_is_bound_vfio_platform (dev_name))
@@ -484,7 +460,7 @@ platform_bus_plug(struct rte_device *dev) {struct rte_platform_device *pdev; -if (!dev_allowed (dev->name)) +if (rte_bus_is_ignored_device (&platform_bus.bus, dev->name))return -EPERM ;if (!dev_is_bound_vfio_platform (dev->name))
drivers/bus/uacce/uacce.c +1 -21
@@ -70,26 +70,6 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static bool -uacce_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name); - -switch (uacce_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -/* * Returns the number of bytes read (removed last newline) on success. * Otherwise negative value is returned.
@@ -296,7 +276,7 @@ uacce_scan(void)continue ; } -if (uacce_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&uacce_bus.bus, e->d_name))continue ;if (uacce_scan_one (e->d_name) <0 )
drivers/bus/vmbus/vmbus_common.c +1 -24
@@ -168,29 +168,6 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)return 1 ; } -static bool -vmbus_ignore_device (struct rte_vmbus_device *dev) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_uuid_unparse (dev->device_id, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name); - -switch (rte_vmbus_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan the vmbus, and call the devinit() function for * all registered drivers that have a matching entry in its id_table
@@ -209,7 +186,7 @@ rte_vmbus_probe(void)rte_uuid_unparse (dev->device_id, ubuf,sizeof (ubuf)); -if (vmbus_ignore_device (dev)) +if (rte_bus_is_ignored_device (&rte_vmbus_bus.bus, ubuf))continue ;if (vmbus_probe_all_drivers (dev) <0 ) {
drivers/dma/idxd/idxd_bus.c +2 -6
@@ -263,12 +263,8 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' ) retval =1 ; -if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) { -if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ; -else - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; - } +if (retval) + retval = !rte_bus_is_ignored_device (&dsa_bus.bus, dev->device.name);return retval; }
lib/eal/common/eal_common_bus.c +21 -0
@@ -254,6 +254,27 @@ rte_bus_find_by_device_name(const char *str)return rte_bus_find (NULL , bus_can_parse, name); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_is_ignored_device) +bool +rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) +{ +struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); + +switch (bus->conf.scan_mode) { +case RTE_BUS_SCAN_ALLOWLIST : +if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) +return false; +break ; +case RTE_BUS_SCAN_UNDEFINED : +case RTE_BUS_SCAN_BLOCKLIST : +if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) +return false; +break ; + } + +EAL_LOG (DEBUG ,"device %s:%s is ignored" ,rte_bus_name (bus), dev_name); +return true; +}/* * Get iommu class of devices on the bus.
lib/eal/include/bus_driver.h +6 -0
@@ -313,6 +313,12 @@ void rte_bus_register(struct rte_bus *bus);__rte_internal struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** +* Indicate if a device should be skipped during probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
Re: [PATCH v3 6/7] bus: factorize device selection
07/04/2026 13:52, David Marchand:
Quoted 4 lines
All buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.
[...]
lib/eal/include/bus_driver.h void rte_bus_register(struct rte_bus *bus); · line 320
Quoted 5 lines
lib/eal/include/bus_driver.h +5
-0+/** +* Indicate if a device should be skipped during probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name);
Name suggestion:rte_bus_device_is_ignored looks easier to read
Actually it is ignored only when probing the bus. What about rte_bus_device_is_ignored_on_probing? Too long?
Re: [PATCH v3 6/7] bus: factorize device selection
Quoted 16 lines · Thomas Monjalon
07/04/2026 13:52, David Marchand:
Quoted 4 lines
All buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.[...]
lib/eal/include/bus_driver.h void rte_bus_register(struct rte_bus *bus); · line 320
Quoted 5 lines
lib/eal/include/bus_driver.h +5
-0+/** +* Indicate if a device should be skipped during probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name);Name suggestion:
rte_bus_device_is_ignoredlooks easier to read
Quoted 3 lines
Actually it is ignored only when probing the bus. What about
rte_bus_device_is_ignored_on_probing? Too long?
"rte_bus_ignore_dev_on_probe"?
PATCH v3 7/7 eal: configure initial device probing
In reply to David MarchandSome applications use port hotplug as their primary way for using DPDK resources.
Having a systematic device probing is a problem when not all available resources will be used by the application, as such applications won't set an explicit allow list at startup.
This is the case for OVS on systems with multiple mlx5 devices:
one device can be used by the kernel while the other(s) are used by DPDK. In such a setup, the kernel used device may get reconfigured in unexpected ways and trigger issues like the one described by Kevin not so long ago in bugzilla 1873.
Add an EAL option so that we can change the default behavior from block-listing to allow-listing which can be summed up as disabling automatic probing.
In case some applications want to require automatic probing, add the opposite option.
---
Changes since RFC v2:
- added -A short option alias as it seems intuitive to use with -a,
- renamed option to --no-auto-probing (half Robin and half Thomas suggestions),
- made -A and -b conflicting options,
- added opposite option in case an application wants an explicit behavior,
- updated unit tests accordingly,
- updated documentation (namely some detail on --vdev),
Changes since RFC v1:
- changed approach following Bruce suggestion,
--- app/test/test_eal_flags.c | 63 +++++++++++++++++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 13 +++++ lib/eal/common/eal_common_bus.c | 17 +++--- lib/eal/common/eal_common_options.c | 10 ++++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + 7 files changed, 101 insertions(+), 7 deletions(-)
app/test/test_eal_flags.c +63 -0
@@ -119,6 +119,8 @@ test_misc_flags(void)#define no_hpet "--no-hpet"#define no_huge "--no-huge"#define no_shconf "--no-shconf" +#define auto_probing "--auto-probing" +#define no_auto_probing "--no-auto-probing"#define allow "--allow"#define vdev "--vdev"#define no_pci "--no-pci"
@@ -338,6 +340,14 @@ test_allow_flag(void) allow,"09:0B.3,type=test" , allow, "08:00.1,type=normal", }; +const char *wlval4[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing }; +const char *wlval5[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing, allow,"00FF:09:0B.3" }; +const char *wlval6[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing }; +const char *wlval7[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing, allow,"00FF:09:0B.3" };for (i =0 ; i <RTE_DIM (wlinval); i++) {if (launch_proc (wlinval[i]) ==0 ) {
@@ -360,6 +370,26 @@ test_allow_flag(void) __LINE__);return -1 ; } +if (launch_proc (wlval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing + allow\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval6) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval7) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing + allow\n" , + __LINE__); +return -1 ; + }return 0 ; }
@@ -383,6 +413,11 @@ test_invalid_b_flag(void) {prgname, prefix, mp_flag, eal_debug_logs, "-b", "error0:0:0.1"}, {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0.1.2"}, }; +const char *blinval_probing[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , auto_probing}; +const char *blinval_probing_inval[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , no_auto_probing}; +/* Test with valid blocklist option */ const char *blval[] = {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"FF:09:0B.3" };
@@ -396,6 +431,16 @@ test_invalid_b_flag(void)return -1 ; } } +if (launch_proc (blinval_probing) !=0 ) { +printf ("Error (line %d) - process did not run ok with blocklist and auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (blinval_probing_inval) ==0 ) { +printf ("Error (line %d) - process did run ok with blocklist and no-auto-probing\n" , + __LINE__); +return -1 ; + }if (launch_proc (blval) !=0 ) {printf ("Error (line %d) - process did not run ok with valid blocklist value\n" , __LINE__);
@@ -434,6 +479,12 @@ test_invalid_vdev_flag(void)const char *vdevval3[] = {prgname, prefix, no_huge, eal_debug_logs, bus_debug_logs, no_pci, vdev,"net_ring0,nodeaction=r1:0:CREATE" }; +const char *vdevval4[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, no_auto_probing, vdev,"net_ring0" }; + +const char *vdevval5[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, auto_probing, vdev,"net_ring0" }; +if (launch_proc (vdevinval) ==0 ) {printf ("Error (line %d) - process did run ok with invalid vdev parameter\n" , __LINE__);
@@ -457,6 +508,18 @@ test_invalid_vdev_flag(void) __LINE__); return -1; } + +if (launch_proc (vdevval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and no-auto-probing\n" , + __LINE__); +return -1 ; + } + +if (launch_proc (vdevval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and auto-probing\n" , + __LINE__); +return -1 ; + }return 0 ;#else return TEST_SKIPPED ;
devtools/test-null.sh +1 -1
@@ -30,7 +30,7 @@ logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ - $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ + $libs -A --vdev net_null1 --vdev net_null2 $eal_options -- \ --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile # we expect two ports and some traffic is received and transmitted
doc/guides/linux_gsg/eal_args.include.rst +13 -0
@@ -101,6 +101,19 @@ Lcore-related options Device-related options ~~~~~~~~~~~~~~~~~~~~~~ +* ``-A, --no-auto-probing`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b`` + options are passed. + Disable automatic probing of non-blocked devices. + +.. Note:: + Block list cannot be used when auto probing is disabled. + + On the other hand, disabling auto probing does not affect the VDEV bus. + The VDEV bus is not concerned by automatic probing and requires explicit + ``-a`` or ``--vdev``. + * ``-b, --block <[domain:]bus:devid.func>`` Skip probing a PCI device to prevent EAL from using it.
lib/eal/common/eal_common_bus.c +11 -6
@@ -258,18 +258,23 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_is_ignored_device)bool rte_bus_is_ignored_device (const struct rte_bus *bus,const char *dev_name) { +const struct internal_config *internal_conf =eal_get_internal_configuration ();struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); +enum rte_bus_scan_mode scan_mode = bus->conf.scan_mode; -switch (bus->conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : +if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (internal_conf->no_auto_probing !=0 ) + scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +else + scan_mode =RTE_BUS_SCAN_BLOCKLIST ; + } + +if (scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) {if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : + }else {if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED )return false; -break ; }EAL_LOG (DEBUG ,"device %s:%s is ignored" ,rte_bus_name (bus), dev_name);
lib/eal/common/eal_common_options.c +10 -0
@@ -233,10 +233,15 @@ eal_collate_args(int argc, char **argv)EAL_LOG (ERR ,"Options allow (-a) and block (-b) can't be used at the same time" );return -1 ; } +if (args.no_auto_probing && !TAILQ_EMPTY (&args.block)) { +EAL_LOG (ERR ,"Options no-auto-probing and block (-b) can't be used at the same time" ); +return -1 ; + }/* for non-list args, we can just check for zero/null values using macro */ if (CONFLICTING_OPTIONS(args, coremask, lcores) || CONFLICTING_OPTIONS(args, service_coremask, service_corelist) || + CONFLICTING_OPTIONS(args, no_auto_probing, auto_probing) || CONFLICTING_OPTIONS(args, no_telemetry, telemetry) || CONFLICTING_OPTIONS(args, memory_size, numa_mem) || CONFLICTING_OPTIONS(args, no_huge, numa_mem) ||
@@ -518,6 +523,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg)memset (internal_cfg->vfio_vf_token,0 ,sizeof (internal_cfg->vfio_vf_token)); + internal_cfg->no_auto_probing =0 ; +#ifdef RTE_LIBEAL_USE_HPET internal_cfg->no_hpet =0 ;#else
@@ -1972,6 +1979,9 @@ eal_parse_args(void) } } +if (args.no_auto_probing) + int_cfg->no_auto_probing =1 ; +/* device -a/-b/-vdev options*/ TAILQ_FOREACH (arg, &args.allow, next) if (eal_option_device_add(RTE_DEVTYPE_ALLOWED, arg->arg) < 0)
lib/eal/common/eal_internal_cfg.h +1 -0
@@ -104,6 +104,7 @@ struct internal_config {struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */ +unsigned int no_auto_probing;/**< true to switch from block-listing to allow-listing */ };void eal_reset_internal_config (struct internal_config *internal_cfg);
lib/eal/common/eal_option_list.h +2 -0
@@ -32,6 +32,7 @@* Format of each entry: long name, short name, help string, struct member name. */ /* (Alphabetical) List of common options first */ +BOOL_ARG("--auto-probing", NULL, "Let EAL probe all available devices unless some -a/-b option is set.", auto_probing) LIST_ARG("--allow", "-a", "Add device to allow-list, causing DPDK to only use specified devices", allow) STR_ARG("--base-virtaddr", NULL, "Base virtual address to reserve memory", base_virtaddr)LIST_ARG ("--block" ,"-b" ,"Add device to block-list, preventing DPDK from using the device" , block)
@@ -51,6 +52,7 @@ STR_ARG("--mbuf-pool-ops-name", NULL, "User defined mbuf default pool ops name", STR_ARG("--memory-channels", "-n", "Number of memory channels per socket", memory_channels) STR_ARG("--memory-ranks", "-r", "Force number of memory ranks (don't detect)", memory_ranks) STR_ARG("--memory-size", "-m", "Total size of memory to allocate initially", memory_size) +BOOL_ARG("--no-auto-probing", "-A", "Do not probe any devices unless some -a option is set", no_auto_probing) BOOL_ARG("--no-hpet", NULL, "Disable HPET timer", no_hpet) BOOL_ARG("--no-huge", NULL, "Disable hugetlbfs support", no_huge)BOOL_ARG ("--no-pci" ,NULL ,"Disable all PCI devices" , no_pci)
Signature · 1 line
2.53.0
Re: [PATCH v3 7/7] eal: configure initial device probing
Quoted 24 lines · David Marchand
Some applications use port hotplug as their primary way for using DPDK resources.
Having a systematic device probing is a problem when not all available resources will be used by the application, as such applications won't set an explicit allow list at startup.This is the case for OVS on systems with multiple mlx5 devices:
one device can be used by the kernel while the other(s) are used by DPDK. In such a setup, the kernel used device may get reconfigured in unexpected ways and trigger issues like the one described by Kevin not so long ago in bugzilla 1873.Add an EAL option so that we can change the default behavior from block-listing to allow-listing which can be summed up as disabling automatic probing.
In case some applications want to require automatic probing, add the opposite option.Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>Reviewed-by Robin Jarry <[email protected]>Acked-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>Acked-by Kevin Traynor <[email protected]>
Re: [PATCH v3 7/7] eal: configure initial device probing
In reply to David Marchand07/04/2026 13:52, David Marchand:
doc/guides/linux_gsg/eal_args.include.rst Lcore-related options · line 110
Quoted 7 lines
doc/guides/linux_gsg/eal_args.include.rst +7
-0+* ``-A, --no-auto-probing`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b`` + options are passed. + Disable automatic probing of non-blocked devices. + +.. Note::
Usually we write such RST directive in lowercase: note
Quoted 1 line
+ Block list cannot be used when auto probing is disabled.
It would be good to mention the option -b here.
doc/guides/linux_gsg/eal_args.include.rst Lcore-related options · line 114
Quoted 3 lines
doc/guides/linux_gsg/eal_args.include.rst +3
-0+ + On the other hand, disabling auto probing does not affect the VDEV bus. + The VDEV bus is not concerned by automatic probing and requires explicit
Repetition of "VDEV bus" may be simplified in one sentence.
Quoted 1 line
+ ``-a`` or ``--vdev``.
We could add at the end "to be created".
There is no mention in this doc of the other option to force auto-probing?
Hello,
Quoted 6 lines · David Marchand
Applications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
Quoted 7 lines
--
David MarchandChanges since v2:
- rebased for late 26.03 fslmc bus changes,
- fixed devargs lookup,
- added debug logs,
Special heads up:
- Maxime, I had to rebase on top of 26.03 changes for the devargs refresh on hotplug, I kept your tested-by tag,
- Chengwen, thanks for the reviews, I updated patch 5 for the issue on devargs lookup you noticed,
Signature · 1 line
David Marchand
Quoted 5 lines · On Tue, 7 Apr 2026 13:52:03 +0200 David Marchand <[email protected]>…
Applications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
AI spotted one minor nit.
Patch 1/7 (devtools: check packet forwarding in null test) - clean. Minor style nit: the first grep uses $build/test-null.log while the next two use $logfile — they're the same path but inconsistent.
Is there a workaround until this patch is added, if I don't want rte_eal_init() to probe any devices, but I want my application to probe devices later by calling rte_bus_scan() followed by rte_bus_probe()?
It's not something we really need, so if you don't know it off the top of your head, don't spend time trying to figure it out.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 82 lines
-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Tuesday, 7 April 2026 13.52
To: [email protected]
Subject: [PATCH v3 0/7] Rework device probingApplications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.--
David MarchandChanges since v2:
- rebased for late 26.03 fslmc bus changes,
- fixed devargs lookup,
- added debug logs,Changes since v1:
- restored per bus scan mode,
- fixed logic in device selection for dma/idxd,
- fixed raw/ifpga hotplug on ifpga bus,
- fixed some doxygen,Changes since RFC v3:
- removed per bus scan mode,Changes since RFC v2:
- went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5),
- updated device selection helper accordingly and
changed API to be device name based,
- renamed option, added check on -b presence, updated doc in the last patch,Changes since RFC v1:
- reviewed busprobe()and cleaned up NXP drivers,
- changed approach following Bruce comment,David Marchand (7):
devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup
drivers/bus: require probe function for NXP driversdrivers/bus: cleanup devargs lookup in scan
bus: factorize devargs lookup
bus: factorize device selection
eal: configure initial device probingapp/test/test_eal_flags.c | 63 ++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 13 ++++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +-------- drivers/bus/dpaa/dpaa_bus.c | 71 ++++++++---------- drivers/bus/fslmc/fslmc_bus.c | 75 ++++++++------------ drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/ifpga_bus.c | 8 ++- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++--------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +---------- drivers/bus/uacce/uacce.c | 39 +--------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 - drivers/bus/vmbus/vmbus_common.c | 45 +++--------- drivers/dma/idxd/idxd_bus.c | 18 +---- lib/eal/common/eal_common_bus.c | 54 ++++++++++++++ lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/include/bus_driver.h | 38 ++++++++++ 29 files changed, 301 insertions(+), 367 deletions(-)--
2.53.0
Quoted 4 lines · Morten Brørup
Is there a workaround until this patch is added, if I don't want
rte_eal_init()to probe any devices, but I want my application to probe devices later by callingrte_bus_scan()followed byrte_bus_probe()?It's not something we really need, so if you don't know it off the top of your head, don't spend time trying to figure it out.
The workaround we have used is '-a 0000:00:00.0' Only allowing a dummy device, hence other devices are hotplugged as needed.
Quoted 87 lines
Venlig hilsen / Kind regards,
-Morten BrørupQuoted 82 lines
-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Tuesday, 7 April 2026 13.52
To: [email protected]
Subject: [PATCH v3 0/7] Rework device probingApplications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.--
David MarchandChanges since v2:
- rebased for late 26.03 fslmc bus changes,
- fixed devargs lookup,
- added debug logs,Changes since v1:
- restored per bus scan mode,
- fixed logic in device selection for dma/idxd,
- fixed raw/ifpga hotplug on ifpga bus,
- fixed some doxygen,Changes since RFC v3:
- removed per bus scan mode,Changes since RFC v2:
- went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5),
- updated device selection helper accordingly and
changed API to be device name based,
- renamed option, added check on -b presence, updated doc in the last patch,Changes since RFC v1:
- reviewed busprobe()and cleaned up NXP drivers,
- changed approach following Bruce comment,David Marchand (7):
devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup
drivers/bus: require probe function for NXP driversdrivers/bus: cleanup devargs lookup in scan
bus: factorize devargs lookup
bus: factorize device selection
eal: configure initial device probingapp/test/test_eal_flags.c | 63 ++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 13 ++++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +-------- drivers/bus/dpaa/dpaa_bus.c | 71 ++++++++---------- drivers/bus/fslmc/fslmc_bus.c | 75 ++++++++------------ drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/ifpga_bus.c | 8 ++- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++--------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +---------- drivers/bus/uacce/uacce.c | 39 +--------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 - drivers/bus/vmbus/vmbus_common.c | 45 +++--------- drivers/dma/idxd/idxd_bus.c | 18 +---- lib/eal/common/eal_common_bus.c | 54 ++++++++++++++ lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/include/bus_driver.h | 38 ++++++++++ 29 files changed, 301 insertions(+), 367 deletions(-)--
2.53.0
Quoted 7 lines · On Fri, 10 Apr 2026 16:34:56 +0200 Morten Brørup <[email protected]>…
Is there a workaround until this patch is added, if I don't want
rte_eal_init()to probe any devices, but I want my application to probe devices later by callingrte_bus_scan()followed byrte_bus_probe()?It's not something we really need, so if you don't know it off the top of your head, don't spend time trying to figure it out.
Venlig hilsen / Kind regards,
-Morten Brørup
We do need it because of the problems with vdev_netvsc. The issue is that vdev_netvsc tries to setup failsafe on all netvsc devices it sees, and it determines which ones are used by OS based on somewhat fragile OS probes with netlink.
I would recommend getting rid of vdev_netvsc, or make the the auto scanning there something that has to be forced by devargs. But that really is up to the netvsc maintainers.
Quoted 14 lines
Quoted 1 line · On Fri, 10 Apr 2026 16:34:56 +0200 Morten Brørup <[email protected]>…
Is there a workaround until this patch is added, if I don't want
rte_eal_init()toprobe any devices, but I want my application to probe devices later by calling
rte_bus_scan()followed byrte_bus_probe()?Quoted 2 lines
It's not something we really need, so if you don't know it off the top of your
head, don't spend time trying to figure it out.
Quoted 4 lines
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 8 lines
We do need it because of the problems with
vdev_netvsc.
The issue is thatvdev_netvsctries to setup failsafe on all netvsc devices it sees, and it determines which ones are used by OS based on somewhat fragile OS probes with netlink.I would recommend getting rid of
vdev_netvsc, or make the the auto scanning there something that has to be forced by devargs.
But that really is up to the netvsc maintainers.
Hi Morten,
Can you use --vdev=net_vdev_netvsc,ignore=1? The ignore devarg is already supported by the vdev_netvsc PMD — when set, the probe function skips all netvsc interface discovery and returns early.
Long
Quoted 10 lines · On Fri, 10 Apr 2026 21:13:36 +0000 Long Li <[email protected]> wrote:
Quoted 9 lines
We do need it because of the problems with
vdev_netvsc.
The issue is thatvdev_netvsctries to setup failsafe on all netvsc devices it sees, and it determines which ones are used by OS based on somewhat fragile OS probes with netlink.I would recommend getting rid of
vdev_netvsc, or make the the auto scanning there something that has to be forced by devargs.
But that really is up to the netvsc maintainers.
Quoted 5 lines
Hi Morten,
Can you use --vdev=net_vdev_netvsc,ignore=1? The ignore devarg is already supported by the
vdev_netvscPMD — when set, the probe function skips all netvsc interface discovery and returns early.Long
The issue is the CI runs on github (Azure) and therefore vdev_netvsc triggers. Too much of a nuisance to change every test. The vdev_netvsc hack should be opt-in not opt-out
Quoted 32 lines
From: Long Li [mailto:[email protected]]
Sent: Friday, 10 April 2026 23.14Quoted 4 lines
Quoted 1 line · On Fri, 10 Apr 2026 16:34:56 +0200 Morten Brørup <[email protected]>…
Is there a workaround until this patch is added, if I don't want
rte_eal_init()toQuoted 1 line
probe any devices, but I want my application to probe devices later
by calling
Quoted 3 lines
rte_bus_scan()followed byrte_bus_probe()?Quoted 2 lines
It's not something we really need, so if you don't know it off the
top of your
Quoted 8 lines
head, don't spend time trying to figure it out.
Quoted 4 lines
Venlig hilsen / Kind regards,
-Morten BrørupWe do need it because of the problems with
vdev_netvsc. The issue is thatvdev_netvsctries to setup failsafe on all netvscdevices it sees,
Quoted 1 line
and it determines which ones are used by OS based on somewhat fragile
OS
Quoted 3 lines
probes with netlink.
I would recommend getting rid of
vdev_netvsc, or make the the autoscanning
Quoted 2 lines
there something that has to be forced by devargs.
But that really is up to the netvsc maintainers.
Quoted 7 lines
Hi Morten,
Can you use --vdev=net_vdev_netvsc,ignore=1? The ignore devarg is already supported by the
vdev_netvscPMD — when set, the probe function skips all netvsc interface discovery and returns early.Long
Thanks for the suggestion, Long.
I'm not looking for a netvsc solution, I'm looking for a general solution to not probe any drivers at EAL initialization, but at a later stage, controlled by the application.
-Morten
Quoted 4 lines · Morten Brørup
Is there a workaround until this patch is added, if I don't want
rte_eal_init()to probe any devices, but I want my application to probe devices later by callingrte_bus_scan()followed byrte_bus_probe()?It's not something we really need, so if you don't know it off the top of your head, don't spend time trying to figure it out.
Well, starting from the well known -a pci:0000:00:00.0 trick, I wrote an incomplete workaround implemented for OVS.
https://patchwork.ozlabs.org/project/openvswitch/patch/[email protected]/
Incomplete, because some buses make life harder with some additional parsing restraints (bus/dpaa is the first one that comes to mind) or requiring a driver handling the device exists (bus/platform which has *no* in-tree driver, though this is a different story..).
+ if (!args_contains(&args, "-a") && !args_contains(&args, "-b")
+ && !smap_get_bool(ovs_other_config, "dpdk-probe-at-init", false)) {
+#ifdef RTE_BUS_AUXILIARY
+ svec_add(&args, "-a");
+ svec_add(&args, "auxiliary:");
+#endif
+#ifdef RTE_BUS_CDX
+ svec_add(&args, "-a");
+ svec_add(&args, "cdx:cdx-");
+#endif
+#ifdef RTE_BUS_FSLMC
+ svec_add(&args, "-a");
+ svec_add(&args, "fslmc:dpni.65535");
+#endif
+#ifdef RTE_BUS_PCI
+ svec_add(&args, "-a");
+ svec_add(&args, "pci:0000:00:00.0");
+#endif
+#ifdef RTE_BUS_UACCE
+ svec_add(&args, "-a");
+ svec_add(&args, "uacce:");
+#endif
+#ifdef RTE_BUS_VMBUS
+ svec_add(&args, "-a");
+ svec_add(&args, "vmbus:00000000-0000-0000-0000-000000000000");
+#endif
+ }
+
Signature · 1 line
David Marchand
Quoted 6 lines · David Marchand
Quoted 4 lines · Morten Brørup
Is there a workaround until this patch is added, if I don't want
rte_eal_init()to probe any devices, but I want my application to probe devices later by callingrte_bus_scan()followed byrte_bus_probe()?It's not something we really need, so if you don't know it off the top of your head, don't spend time trying to figure it out.
Some (untested) other idea... write some "plugin" loaded last (via -d), that would list all buses, then unregister all of them (or a part of the list, for buses known to be a problem..).
IOVA discovery would end up as DC, so probably fine (and we have an option to force it if needed).
Then after call to rte_eal_init, the application would get a hold of this list, re-register buses... ?
I think it could work, but clearly hacky...
Signature · 1 line
David Marchand
Quoted 18 lines
From: David Marchand [mailto:[email protected]]
Sent: Saturday, 11 April 2026 12.11Quoted 2 lines · Morten Brørup
Is there a workaround until this patch is added, if I don't want
rte_eal_init()to probe any devices, but I want my application to probe devices later by callingrte_bus_scan()followed byrte_bus_probe()?Quoted 2 lines
It's not something we really need, so if you don't know it off the
top of your head, don't spend time trying to figure it out.
Well, starting from the well known -a pci:0000:00:00.0 trick, I wrote an incomplete workaround implemented for OVS.
https://patchwork.ozlabs.org/project/openvswitch/patch/20260226172429.2
[email protected]/
Quoted 4 lines
Incomplete, because some buses make life harder with some additional parsing restraints (bus/dpaa is the first one that comes to mind) or requiring a driver handling the device exists (bus/platform which has *no* in-tree driver, though this is a different story..).
Thanks for all the input, David.
In my case it's only PCI bus devices, so I found a relatively simple workaround instead of using the "-a" trick.
I start by not binding the devices to the vfio-pci kernel driver.
Then I call rte_eal_init(); and the devices are not detected by the EAL at this point. Then I bind the devices to the vfio-pci kernel driver.
And finally I call rte_bus_scan() and rte_bus_probe(); then the devices are detected at this point.
Note: I have to pass "--iova-mode pa" to EAL init.
Otherwise EAL init chooses VA mode, causing my drivers to not load, with the following message:
"PCI_BUS: Expecting 'PA' IOVA mode but current mode is 'VA', not initializing"
For anyone following the thread...
During experimentation, I observed that if the devices were bound to the vfio-pci kernel driver, and "-a ..." was passed to rte_eal_init() it did - as expected - not load the drivers. However, when calling rte_bus_scan() and rte_bus_probe() afterwards, the drivers were also not auto-detected at this point.
I guess the "-a ..." parameter is sticky, which makes sense.
Anyway, looking forward to the --no-auto-probing EAL option. :-)
Quoted 36 lines · Morten Brørup
Quoted 18 lines
From: David Marchand [mailto:[email protected]]
Sent: Saturday, 11 April 2026 12.11Quoted 2 lines · Morten Brørup
Is there a workaround until this patch is added, if I don't want
rte_eal_init()to probe any devices, but I want my application to probe devices later by callingrte_bus_scan()followed byrte_bus_probe()?Quoted 2 lines
It's not something we really need, so if you don't know it off the
top of your head, don't spend time trying to figure it out.
Well, starting from the well known -a pci:0000:00:00.0 trick, I wrote an incomplete workaround implemented for OVS.
https://patchwork.ozlabs.org/project/openvswitch/patch/20260226172429.2
[email protected]/Quoted 4 lines
Incomplete, because some buses make life harder with some additional parsing restraints (bus/dpaa is the first one that comes to mind) or requiring a driver handling the device exists (bus/platform which has *no* in-tree driver, though this is a different story..).
Thanks for all the input, David.
In my case it's only PCI bus devices, so I found a relatively simple workaround instead of using the "-a" trick.
I start by not binding the devices to the vfio-pci kernel driver.
Then I callrte_eal_init(); and the devices are not detected by the EAL at this point. Then I bind the devices to the vfio-pci kernel driver.
And finally I callrte_bus_scan()andrte_bus_probe(); then the devices are detected at this point.Note: I have to pass "--iova-mode pa" to EAL init.
Otherwise EAL init chooses VA mode, causing my drivers to not load, with the following message:
"PCI_BUS: Expecting 'PA' IOVA mode but current mode is 'VA', not initializing"
Quoted 6 lines
For anyone following the thread...
During experimentation, I observed that if the devices were bound to the vfio-pci kernel driver, and "-a ..." was passed to
rte_eal_init()it did - as expected - not load the drivers. However, when callingrte_bus_scan()andrte_bus_probe()afterwards, the drivers were also not auto-detected at this point.
I guess the "-a ..." parameter is sticky, which makes sense.
Yes. The assumption is that, if you don't want to auto-probe, you want to instead add the devices individually, device by device.
/Bruce
v4 cover Rework device probing
In reply to David MarchandApplications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.
Signature · 76 lines
David Marchand Changes since v3: - renamed some internal API, - updated documentation, - added a release notes entry, Changes since v2: - rebased for late 26.03 fslmc bus changes, - fixed devargs lookup, - added debug logs, Changes since v1: - restored per bus scan mode, - fixed logic in device selection for dma/idxd, - fixed raw/ifpga hotplug on ifpga bus, - fixed some doxygen, Changes since RFC v3: - removed per bus scan mode, Changes since RFC v2: - went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5), - updated device selection helper accordingly and changed API to be device name based, - renamed option, added check on -b presence, updated doc in the last patch, Changes since RFC v1: - reviewed bus probe() and cleaned up NXP drivers, - changed approach following Bruce comment, David Marchand (7): devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup drivers/bus: require probe function for NXP drivers drivers/bus: cleanup devargs lookup in scan bus: factorize devargs lookup bus: factorize device selection eal: configure initial device probing app/test/test_eal_flags.c | 63 ++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 18 +++++ doc/guides/rel_notes/release_26_07.rst | 8 +++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +-------- drivers/bus/dpaa/dpaa_bus.c | 71 ++++++++---------- drivers/bus/fslmc/fslmc_bus.c | 75 ++++++++------------ drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/ifpga_bus.c | 8 ++- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++--------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +---------- drivers/bus/uacce/uacce.c | 39 +--------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 - drivers/bus/vmbus/vmbus_common.c | 45 +++--------- drivers/dma/idxd/idxd_bus.c | 18 +---- lib/eal/common/eal_common_bus.c | 54 ++++++++++++++ lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/include/bus_driver.h | 38 ++++++++++ 30 files changed, 314 insertions(+), 367 deletions(-) -- 2.53.0
PATCH v4 1/7 devtools: check packet forwarding in null test
Add some simple checks that testpmd was indeed polling two ports, and some packets got through it.
--- devtools/test-null.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
devtools/test-null.sh +7 -1
@@ -26,8 +26,14 @@ else libs= fi +logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ - --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia + --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile + +# we expect two ports and some traffic is received and transmitted +grep -q 'io packet forwarding - ports=2 -' $logfile +grep 'RX-packets: ' $logfile | tail -1 | grep -q 'RX-packets:[[:space:]]*[^0[:space:]]' +grep 'TX-packets: ' $logfile | tail -1 | grep -q 'TX-packets:[[:space:]]*[^0[:space:]]'
Signature · 1 line
2.53.0
PATCH v4 2/7 bus/fslmc: fix bus cleanup
In reply to David MarchandThe close operation was never closing probed devices.
Taking a step back, reevaluating the devargs makes no sense during the close step, as a probed device must have passed the allow/block list evaluation initially.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
--- drivers/bus/fslmc/fslmc_vfio.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +4 -17
@@ -1393,7 +1393,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, {struct rte_dpaa2_object *object =NULL ;struct rte_dpaa2_driver *drv; -int ret, probe_all; +int ret;switch (dev->dev_type) {case DPAA2_IO :
@@ -1411,22 +1411,9 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - probe_all = rte_fslmc_bus.bus.conf.scan_mode != -RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { -if (drv->drv_type != dev->dev_type) -continue ; -if (rte_dev_is_probed (&dev->device)) -continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy == -RTE_DEV_ALLOWED )) { - ret = drv->remove (dev); -if (ret) -DPAA2_BUS_ERR ("Unable to remove" ); - } - } + drv = dev->driver; +if (drv && drv->remove && drv->remove (dev)) +DPAA2_BUS_ERR ("Unable to remove" );break ;default :break ;
Signature · 1 line
2.53.0
PATCH v4 3/7 drivers/bus: require probe function for NXP drivers
In reply to David MarchandRather than silently ignore an invalid driver, enforce every registered driver has a probe callback.
--- drivers/bus/dpaa/dpaa_bus.c | 6 +++--- drivers/bus/fslmc/fslmc_bus.c | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -3
@@ -614,6 +614,7 @@ void rte_dpaa_driver_register(struct rte_dpaa_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );BUS_INIT_FUNC_TRACE ();
@@ -808,9 +809,8 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (!drv->probe || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED )) +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED )continue ; if (probe_all ||
drivers/bus/fslmc/fslmc_bus.c +1 -6
@@ -469,9 +469,6 @@ rte_fslmc_probe(void)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
@@ -538,6 +535,7 @@ void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver) {RTE_VERIFY (driver); +RTE_VERIFY (driver->probe !=NULL );TAILQ_INSERT_TAIL (&rte_fslmc_bus.driver_list, driver, next); }
@@ -605,9 +603,6 @@ fslmc_bus_plug(struct rte_device *rte_dev)if (ret)continue ; -if (!drv->probe) -continue ; -if (rte_dev_is_probed (&dev->device))continue ;
Signature · 1 line
2.53.0
PATCH v4 4/7 drivers/bus: cleanup devargs lookup in scan
In reply to David MarchandDon'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.
---
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(-)
drivers/bus/auxiliary/auxiliary_common.c +1 -1
@@ -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; }
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -2
@@ -28,8 +28,6 @@extern "C" {#endif -#define RTE_BUS_AUXILIARY_NAME "auxiliary" -/* Forward declarations */ struct rte_auxiliary_driver ;struct rte_auxiliary_device ;
drivers/bus/cdx/cdx.c +1 -2
@@ -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; }
drivers/bus/dpaa/dpaa_bus.c +2 -4
@@ -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 );
drivers/bus/fslmc/fslmc_bus.c +3 -5
@@ -26,7 +26,6 @@#include <dpaax_iova_table.h> #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups" -#define FSLMC_BUS_NAME fslmcstruct 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 );
drivers/bus/ifpga/ifpga_bus.c +6 -2
@@ -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 );
drivers/bus/pci/pci_common.c +1 -1
@@ -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;
drivers/bus/platform/platform.c +1 -1
@@ -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; }
drivers/bus/uacce/uacce.c +1 -1
@@ -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; }
drivers/bus/vdev/vdev.c +1 -1
@@ -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)
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -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 )
Signature · 1 line
2.53.0
PATCH v4 5/7 bus: factorize devargs lookup
In reply to David MarchandEach bus reimplements some similar devargs lookup code.
The differences are in how some bus (PCI, VMBUS etc...) normalizes the device names. We can't use the .parse existing handler from outside the bus code itself, as the size of the bus specific device location address is unknown.
Introduce a bus specific helper to compare two device names and hide this ugly detail.
---
Changes since v3:
- renamed rte_bus_devname_compare_t as rte_bus_dev_compare_t,
- renamed .devname_compare as .dev_compare,
Changes since v2:
- rebased on 26.03 fslmc changes,
- fixed devargs lookup for uacce bus (and buses != pci, fslmc),
- added a debug log,
Changes since v1:
- fixed copy/paste descriptions in doxygen,
Changes since RFC v3:
- fixed doxygen,
--- drivers/bus/auxiliary/auxiliary_common.c | 16 ++------- drivers/bus/cdx/cdx.c | 14 +------- drivers/bus/dpaa/dpaa_bus.c | 41 +++++++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 37 +++++++++++---------- drivers/bus/pci/pci_common.c | 38 +++++++++++----------- drivers/bus/platform/platform.c | 17 ++-------- drivers/bus/uacce/uacce.c | 19 ++--------- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 -- drivers/bus/vmbus/vmbus_common.c | 30 ++++++++--------- drivers/dma/idxd/idxd_bus.c | 14 ++------ lib/eal/common/eal_common_bus.c | 28 ++++++++++++++++ lib/eal/include/bus_driver.h | 32 ++++++++++++++++++ 13 files changed, 142 insertions(+), 149 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +2 -14
@@ -25,18 +25,6 @@#include "private.h" -static struct rte_devargs * -auxiliary_devargs_lookup (const char *name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(auxiliary_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } -return NULL ; -} -#ifndef AUXILIARY_OS_SUPPORTED /* * Test whether the auxiliary device exist.
@@ -68,7 +56,7 @@ auxiliary_scan(void)void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev) { - aux_dev->device.devargs =auxiliary_devargs_lookup (aux_dev->name); + aux_dev->device.devargs =rte_bus_find_devargs (&auxiliary_bus.bus, aux_dev->name); }/*
@@ -399,7 +387,7 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,bool auxiliary_is_ignored_device (const char *name) { -struct rte_devargs *devargs =auxiliary_devargs_lookup (name); +struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name);switch (auxiliary_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/cdx/cdx.c +1 -13
@@ -151,22 +151,10 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static struct rte_devargs * -cdx_devargs_lookup (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(rte_cdx_bus.bus.name, devargs) { -if (strcmp (devargs->name, dev_name) ==0 ) -return devargs; - } -return NULL ; -} -static bool cdx_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =cdx_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name);switch (rte_cdx_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
drivers/bus/dpaa/dpaa_bus.c +22 -19
77 lines not on this page · raw message
drivers/bus/fslmc/fslmc_bus.c +18 -19
@@ -99,22 +99,6 @@ insert_in_device_list(struct rte_dpaa2_device *newdev)TAILQ_INSERT_TAIL (&rte_fslmc_bus.device_list, newdev, next); } -static struct rte_devargs * -fslmc_devargs_lookup (struct rte_dpaa2_device *dev) -{ -struct rte_devargs *devargs; -char dev_name[32 ]; - - 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); -return devargs; - } - } -return NULL ; -} -static void dump_device_list (void ) {
@@ -216,7 +200,7 @@ scan_one_fslmc_device(char *dev_name) ret = -ENOMEM ; goto cleanup; } - dev->device.devargs =fslmc_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus.bus, dev_name);/* Update the device found into the device_count table */ rte_fslmc_bus.device_count[dev->dev_type]++;
@@ -308,6 +292,18 @@ rte_fslmc_parse(const char *name, void *addr)return ret; } +static int +fslmc_dev_compare (const char *name1,const char *name2) +{ +char devname1[32 ], devname2[32 ]; + +if (rte_fslmc_parse (name1, devname1) !=0 || +rte_fslmc_parse (name2, devname2) !=0 ) +return 1 ; + +return strncmp (devname1, devname2,sizeof (devname1)); +} +static int rte_fslmc_scan (void ) {
@@ -323,8 +319,10 @@ rte_fslmc_scan(void)struct rte_dpaa2_device *dev;DPAA2_BUS_DEBUG ("Fslmc bus already scanned. Not rescanning" ); -TAILQ_FOREACH (dev, &rte_fslmc_bus.device_list, next) - dev->device.devargs = fslmc_devargs_lookup(dev); + TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { + dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus.bus, + dev->device.name); + }return 0 ; } process_once =1 ;
@@ -695,6 +693,7 @@ struct rte_fslmc_bus rte_fslmc_bus = { .probe = rte_fslmc_probe, .cleanup = rte_fslmc_close, .parse = rte_fslmc_parse, + .dev_compare = fslmc_dev_compare, .find_device = rte_fslmc_find_device, .get_iommu_class = rte_dpaa2_get_iommu_class, .plug = fslmc_bus_plug,
drivers/bus/pci/pci_common.c +19 -19
@@ -79,32 +79,15 @@ pci_asprintf(char **buffer, const char *format, ...) }#endif /* RTE_EXEC_ENV_WINDOWS */ -static struct rte_devargs * -pci_devargs_lookup (const struct rte_pci_addr *pci_addr) -{ -struct rte_devargs *devargs; -struct rte_pci_addr addr; - - 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; - } -return NULL ; -} - void pci_common_set(struct rte_pci_device *dev) { - struct rte_devargs *devargs; - /* Each device has its internal, canonical name set. */ rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name)); dev->device.name = dev->name; - devargs = pci_devargs_lookup(&dev->addr); - dev->device.devargs = devargs; + dev->device.devargs = rte_bus_find_devargs(&rte_pci_bus.bus, dev->name); if (dev->bus_info != NULL || asprintf(&dev->bus_info, "vendor_id=%"PRIx16", device_id=%"PRIx16,
@@ -503,6 +486,18 @@ pci_parse(const char *name, void *addr)return parse == false; } +static int +pci_dev_compare (const char *name1,const char *name2) +{ +struct rte_pci_addr addr1, addr2; + +if (rte_pci_addr_parse (name1, &addr1) !=0 || +rte_pci_addr_parse (name2, &addr2) !=0 ) +return 1 ; + +return rte_pci_addr_cmp (&addr1, &addr2); +} +/* register a driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_pci_register) void
@@ -721,7 +716,11 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) { -struct rte_devargs *devargs =pci_devargs_lookup (pci_addr); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_pci_device_name (pci_addr, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name);switch (rte_pci_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -946,6 +945,7 @@ struct rte_pci_bus rte_pci_bus = { .plug = pci_plug, .unplug = pci_unplug, .parse = pci_parse, + .dev_compare = pci_dev_compare, .devargs_parse = rte_pci_devargs_parse, .dma_map = pci_dma_map, .dma_unmap = pci_dma_unmap,
drivers/bus/platform/platform.c +2 -15
@@ -43,25 +43,12 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static struct rte_devargs * -dev_devargs (const char *dev_name) -{ -struct rte_devargs *devargs; - - RTE_EAL_DEVARGS_FOREACH(platform_bus.bus.name, devargs) { -if (!strcmp (devargs->name, dev_name)) -return devargs; - } - -return NULL ; -} -static bool dev_allowed (const char *dev_name) {struct rte_devargs *devargs; - devargs =dev_devargs (dev_name); + devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name);if (devargs ==NULL )return true;
@@ -93,7 +80,7 @@ dev_add(const char *dev_name)rte_strscpy (pdev->name, dev_name,sizeof (pdev->name)); pdev->device.name = pdev->name; - pdev->device.devargs =dev_devargs (dev_name); + pdev->device.devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); pdev->device.bus = &platform_bus.bus;snprintf (path,sizeof (path),PLATFORM_BUS_DEVICES_PATH "/%s/numa_node" , dev_name); pdev->device.numa_node =eal_parse_sysfs_value (path, &val) ?rte_socket_id () : val;
drivers/bus/uacce/uacce.c +2 -17
@@ -70,25 +70,10 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static struct rte_devargs * -uacce_devargs_lookup (const char *dev_name) -{ -char name[RTE_UACCE_DEV_PATH_SIZE ] = {0 }; -struct rte_devargs *devargs; - -snprintf (name,sizeof (name),"%s%s" ,UACCE_DEV_PREFIX , dev_name); - RTE_EAL_DEVARGS_FOREACH(uacce_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return devargs; - } - -return NULL ; -} -static bool uacce_ignore_device (const char *dev_name) { -struct rte_devargs *devargs =uacce_devargs_lookup (dev_name); +struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);switch (uacce_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -257,7 +242,7 @@ uacce_scan_one(const char *dev_name) dev->device.bus = &uacce_bus.bus; dev->device.name = dev->name; - dev->device.devargs =uacce_devargs_lookup (dev_name); + dev->device.devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);snprintf (dev->name,sizeof (dev->name),"%s" , dev_name);snprintf (dev->dev_root,sizeof (dev->dev_root),"%s/%s" ,UACCE_BUS_CLASS_PATH , dev_name);
drivers/bus/vmbus/linux/vmbus_bus.c +1 -1
@@ -333,7 +333,7 @@ vmbus_scan_one(const char *name) dev->monitor_id =UINT8_MAX ; } - dev->device.devargs =vmbus_devargs_lookup (dev); + dev->device.devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, dev_name); dev->device.numa_node =SOCKET_ID_ANY ;if (vmbus_use_numa (dev)) {
drivers/bus/vmbus/private.h +0 -3
@@ -98,9 +98,6 @@ struct vmbus_channel {#define VMBUS_MAX_CHANNELS 64 -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev); -int vmbus_chan_create (const struct rte_vmbus_device *device,uint16_t relid,uint16_t subid,uint8_t monitor_id,struct vmbus_channel **new_chan);
drivers/bus/vmbus/vmbus_common.c +13 -17
@@ -171,7 +171,11 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)static bool vmbus_ignore_device (struct rte_vmbus_device *dev) { -struct rte_devargs *devargs =vmbus_devargs_lookup (dev); +char name[RTE_DEV_NAME_MAX_LEN ]; +struct rte_devargs *devargs; + +rte_uuid_unparse (dev->device_id, name,sizeof (name)); + devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name);switch (rte_vmbus_bus.bus.conf.scan_mode) {case RTE_BUS_SCAN_ALLOWLIST :
@@ -260,25 +264,16 @@ vmbus_parse(const char *name, void *addr)return ret; } -/* -* scan for matching device args on command line -* example: -* -a 'vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20' -*/ -struct rte_devargs * -vmbus_devargs_lookup (struct rte_vmbus_device *dev) +static int +vmbus_dev_compare (const char *name1,const char *name2) { -struct rte_devargs *devargs; -rte_uuid_t addr; - - RTE_EAL_DEVARGS_FOREACH(rte_vmbus_bus.bus.name, devargs) { -vmbus_parse (devargs->name, &addr); +rte_uuid_t guid1, guid2; -if (rte_uuid_compare (dev->device_id, addr) ==0 ) -return devargs; - } -return NULL ; +if (vmbus_parse (name1, &guid1) !=0 || +vmbus_parse (name2, &guid2) !=0 ) +return 1 ; +return rte_uuid_compare (guid1, guid2); }/* register vmbus driver */
@@ -349,6 +344,7 @@ struct rte_vmbus_bus rte_vmbus_bus = { .cleanup = rte_vmbus_cleanup, .find_device = vmbus_find_device, .parse = vmbus_parse, + .dev_compare = vmbus_dev_compare, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.driver_list),
drivers/dma/idxd/idxd_bus.c +2 -12
@@ -247,16 +247,6 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return 0 ; } -static int search_devargs (const char *name) -{ -struct rte_devargs *devargs; - RTE_EAL_DEVARGS_FOREACH(dsa_bus.bus.name, devargs) { -if (strcmp (devargs->name, name) ==0 ) -return 1 ; - } -return 0 ; -} -static int is_for_this_process_use (struct rte_dsa_device *dev,const char *name) {
@@ -275,9 +265,9 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) {if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ;else - retval = !search_devargs (dev->device.name); + retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; }return retval;
lib/eal/common/eal_common_bus.c +28 -0
@@ -8,6 +8,7 @@#include <bus_driver.h> #include <rte_debug.h> +#include <rte_devargs.h> #include <rte_string_fns.h> #include <rte_errno.h>
@@ -205,6 +206,33 @@ rte_bus_find_by_name(const char *busname)return rte_bus_find (NULL , cmp_bus_name, (const void *)busname); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_find_devargs) +struct rte_devargs * +rte_bus_find_devargs (const struct rte_bus *bus,const char *name) +{ +rte_bus_dev_compare_t cmp = bus->dev_compare; +const char *bus_name =rte_bus_name (bus); +struct rte_devargs *devargs; + +if (cmp ==NULL ) + cmp = strcmp; + + RTE_EAL_DEVARGS_FOREACH(bus_name, devargs) { +const char *devargs_name = devargs->name; + +/* The name in the devargs is usually prefixed with <bus>: */ +if (strncmp (devargs_name, bus_name,strlen (bus_name)) ==0 ) + devargs_name +=strlen (bus_name) +1 ; +if (cmp (name, devargs_name) !=0 ) +continue ; +EAL_LOG (DEBUG ,"found devargs for %s:%s" , bus_name, name); +return devargs; + } + +EAL_LOG (DEBUG ,"no devargs for %s:%s" , bus_name, name); +return NULL ; +} +static int bus_can_parse (const struct rte_bus *bus,const void *_name) {
lib/eal/include/bus_driver.h +32 -0
@@ -118,6 +118,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);*/ typedef int (*rte_bus_parse_t )(const char *name,void *addr); +/** +* Bus specific device name comparison function. +* Bus can normalize the names of devices using an internal representation. +* This helper makes it possible to check whether two names refer to the same device. +* +* @param[in] name1 +* device name +* @param[in] name2 +* device name +* +* @return +* 0 if the two names refer to the same device. +* !0 otherwise. +*/ +typedef int (*rte_bus_dev_compare_t )(const char *name1,const char *name2); +/** * Parse bus part of the device arguments. *
@@ -258,6 +274,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +rte_bus_dev_compare_t dev_compare;/**< Compare two device names */ rte_bus_devargs_parse_t devargs_parse;/**< Parse bus devargs */ rte_dev_dma_map_t dma_map;/**< DMA map for device in the bus */ rte_dev_dma_unmap_t dma_unmap;/**< DMA unmap for device in the bus */
@@ -281,6 +298,21 @@ struct rte_bus {__rte_internal void rte_bus_register(struct rte_bus *bus); +/** +* Find the devargs associated to a device. +* +* @param bus +* A pointer to a rte_bus structure describing the bus +* to search for devargs on. +* @param dev_name +* A device name. +* +* @return +* Pointer to the device devargs, or NULL if none found. +*/ +__rte_internal +struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
PATCH v4 6/7 bus: factorize device selection
In reply to David MarchandAll buses (thankfully) implement the same logic when it comes to selecting the devices to probe based on -a/-b options.
As we want to adjust how devices are selected, provide a common helper in EAL and use it in the buses.
---
Changes since v3:
- renamed rte_bus_is_ignored_device as rte_bus_device_is_ignored,
Changes since v2:
- added a debug log in the helper,
Changes since v1:
- fixed device selection in dma/idxd,
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,
--- drivers/bus/auxiliary/auxiliary_common.c | 19 ---------------- drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 ----- drivers/bus/cdx/cdx.c | 21 +----------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++-------------- drivers/bus/fslmc/fslmc_bus.c | 25 ++++++--------------- drivers/bus/pci/bsd/pci.c | 5 ++++- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 23 ------------------- drivers/bus/pci/private.h | 11 ---------- drivers/bus/pci/windows/pci.c | 4 +++- drivers/bus/platform/platform.c | 28 ++---------------------- drivers/bus/uacce/uacce.c | 22 +------------------ drivers/bus/vmbus/vmbus_common.c | 25 +-------------------- drivers/dma/idxd/idxd_bus.c | 8 ++----- lib/eal/common/eal_common_bus.c | 21 ++++++++++++++++++ lib/eal/include/bus_driver.h | 6 +++++ 17 files changed, 57 insertions(+), 195 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -19
@@ -384,25 +384,6 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,return aux_dev->driver->dma_unmap (aux_dev, addr, iova, len); } -bool -auxiliary_is_ignored_device (const char *name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&auxiliary_bus.bus, name); - -switch (auxiliary_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -static enum rte_iova_mode auxiliary_get_iommu_class (void ) {
drivers/bus/auxiliary/linux/auxiliary.c +1 -1
@@ -110,7 +110,7 @@ auxiliary_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (auxiliary_is_ignored_device (e->d_name)) +if (rte_bus_device_is_ignored (&auxiliary_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/auxiliary/private.h +0 -6
@@ -53,12 +53,6 @@ int auxiliary_scan(void);*/ void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev); -/* -* Validate whether a device with given auxiliary device should be ignored -* or not. -*/ -bool auxiliary_is_ignored_device (const char *name); -/* * Add an auxiliary device to the auxiliary bus (append to auxiliary device * list). This function also updates the bus references of the auxiliary
drivers/bus/cdx/cdx.c +1 -20
@@ -151,25 +151,6 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev)cdx_vfio_unmap_resource (dev); } -static bool -cdx_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&rte_cdx_bus.bus, dev_name); - -switch (rte_cdx_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan one cdx sysfs entry, and fill the devices list from it. * It checks if the CDX device is bound to vfio-cdx driver. In case
@@ -269,7 +250,7 @@ cdx_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (cdx_ignore_device (e->d_name)) +if (rte_bus_device_is_ignored (&rte_cdx_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/dpaa/dpaa_bus.c +7 -17
@@ -717,7 +717,6 @@ rte_dpaa_bus_probe(void)struct rte_dpaa_driver *drv;FILE *svr_file =NULL ;uint32_t svr_ver; -int probe_all = rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ;static int process_once;char *penv;
@@ -725,9 +724,6 @@ rte_dpaa_bus_probe(void)if (!rte_dpaa_bus.detected)return 0 ; -if (rte_dpaa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ) - probe_all = true; - svr_file =fopen (DPAA_SOC_ID_FILE ,"r" );if (svr_file) {if (fscanf (svr_file,"svr:%x" , &svr_ver) >0 )
@@ -809,21 +805,15 @@ rte_dpaa_bus_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) +if (rte_bus_device_is_ignored (&rte_dpaa_bus.bus, dev->name))continue ; -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA_BUS_ERR ("unable to probe:%s" , - dev->name); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA_BUS_ERR ("unable to probe: %s" , dev->name); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/fslmc/fslmc_bus.c +7 -18
@@ -410,7 +410,6 @@ static intrte_fslmc_probe (void) {int ret =0 ; -int probe_all;struct rte_dpaa2_device *dev;struct rte_dpaa2_driver *drv;
@@ -457,8 +456,6 @@ rte_fslmc_probe(void)return 0 ; } - probe_all = rte_fslmc_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_ALLOWLIST ; - TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { ret =rte_fslmc_match (drv, dev);
@@ -468,23 +465,15 @@ rte_fslmc_probe(void)if (rte_dev_is_probed (&dev->device))continue ; -if (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { -DPAA2_BUS_LOG (DEBUG ,"%s Blocked, skipping" , - dev->device.name); +if (rte_bus_device_is_ignored (&rte_fslmc_bus.bus, dev->device.name))continue ; - } -if (probe_all || - (dev->device.devargs && - dev->device.devargs->policy ==RTE_DEV_ALLOWED )) { - ret = drv->probe (drv, dev); -if (ret) { -DPAA2_BUS_ERR ("Unable to probe" ); - }else { - dev->driver = drv; - dev->device.driver = &drv->driver; - } + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; }break ; }
drivers/bus/pci/bsd/pci.c +4 -1
@@ -370,12 +370,15 @@ rte_pci_scan(void) }for (i =0 ; i < conf_io.num_matches; i++) { +char name[RTE_DEV_NAME_MAX_LEN ]; + pci_addr.domain = matches[i].pc_sel.pc_domain; pci_addr.bus = matches[i].pc_sel.pc_bus; pci_addr.devid = matches[i].pc_sel.pc_dev; pci_addr.function = matches[i].pc_sel.pc_func; +rte_pci_device_name (&pci_addr, name,sizeof (name)); -if (rte_pci_ignore_device (&pci_addr)) +if (rte_bus_device_is_ignored (&rte_pci_bus.bus, name))continue ;if (pci_scan_one (fd, &matches[i]) <0 )
drivers/bus/pci/linux/pci.c +1 -1
@@ -458,7 +458,7 @@ rte_pci_scan(void)if (parse_pci_addr_format (e->d_name,sizeof (e->d_name), &addr) !=0 )continue ; -if (rte_pci_ignore_device (&addr)) +if (rte_bus_device_is_ignored (&rte_pci_bus.bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/pci/pci_common.c +0 -23
@@ -713,29 +713,6 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)return -1 ; } -bool -rte_pci_ignore_device (const struct rte_pci_addr *pci_addr) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_pci_device_name (pci_addr, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_pci_bus.bus, name); - -switch (rte_pci_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -enum rte_iova_mode rte_pci_get_iommu_class (void ) {
drivers/bus/pci/private.h +0 -11
@@ -82,17 +82,6 @@ pci_common_set(struct rte_pci_device *dev);void pci_free (struct rte_pci_device_internal *pdev); -/** -* Validate whether a device with given PCI address should be ignored or not. -* -* @param pci_addr -* PCI address of device to be validated -* @return -* true: if device is to be ignored, -* false: if device is to be scanned, -*/ -bool rte_pci_ignore_device (const struct rte_pci_addr *pci_addr); -/** * Add a PCI device to the PCI Bus (append to PCI Device list). This function * also updates the bus references of the PCI Device (and the generic device
drivers/bus/pci/windows/pci.c +3 -1
@@ -373,6 +373,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)struct rte_pci_device *dev =NULL ;int ret =-1 ;char pci_device_info[REGSTR_VAL_MAX_HCID_LEN ]; +char name[RTE_DEV_NAME_MAX_LEN ];struct rte_pci_addr addr;struct rte_pci_id pci_id;
@@ -380,7 +381,8 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)if (ret !=0 ) goto end; -if (rte_pci_ignore_device (&addr)) { +rte_pci_device_name (&addr, name,sizeof (name)); +if (rte_bus_device_is_ignored (&rte_pci_bus.bus, name)) {/* * We won't add this device, but we want to continue * looking for supported devices
drivers/bus/platform/platform.c +2 -26
@@ -43,30 +43,6 @@ rte_platform_unregister(struct rte_platform_driver *pdrv)TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); } -static bool -dev_allowed (const char *dev_name) -{ -struct rte_devargs *devargs; - - devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); -if (devargs ==NULL ) -return true; - -switch (platform_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs->policy ==RTE_DEV_ALLOWED ) -return true; -break ; -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs->policy ==RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -static int dev_add (const char *dev_name) {
@@ -160,7 +136,7 @@ platform_bus_scan(void)if (dev_name[0 ] =='.' )continue ; -if (!dev_allowed (dev_name)) +if (rte_bus_device_is_ignored (&platform_bus.bus, dev_name))continue ;if (!dev_is_bound_vfio_platform (dev_name))
@@ -484,7 +460,7 @@ platform_bus_plug(struct rte_device *dev) {struct rte_platform_device *pdev; -if (!dev_allowed (dev->name)) +if (rte_bus_device_is_ignored (&platform_bus.bus, dev->name))return -EPERM ;if (!dev_is_bound_vfio_platform (dev->name))
drivers/bus/uacce/uacce.c +1 -21
@@ -70,26 +70,6 @@ extern int uacce_bus_logtype;#define UACCE_BUS_DEBUG (fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__) -static bool -uacce_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name); - -switch (uacce_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } - -return true; -} -/* * Returns the number of bytes read (removed last newline) on success. * Otherwise negative value is returned.
@@ -296,7 +276,7 @@ uacce_scan(void)continue ; } -if (uacce_ignore_device (e->d_name)) +if (rte_bus_device_is_ignored (&uacce_bus.bus, e->d_name))continue ;if (uacce_scan_one (e->d_name) <0 )
drivers/bus/vmbus/vmbus_common.c +1 -24
@@ -168,29 +168,6 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)return 1 ; } -static bool -vmbus_ignore_device (struct rte_vmbus_device *dev) -{ -char name[RTE_DEV_NAME_MAX_LEN ]; -struct rte_devargs *devargs; - -rte_uuid_unparse (dev->device_id, name,sizeof (name)); - devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, name); - -switch (rte_vmbus_bus.bus.conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : -if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) -return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : -if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) -return false; -break ; - } -return true; -} -/* * Scan the vmbus, and call the devinit() function for * all registered drivers that have a matching entry in its id_table
@@ -209,7 +186,7 @@ rte_vmbus_probe(void)rte_uuid_unparse (dev->device_id, ubuf,sizeof (ubuf)); -if (vmbus_ignore_device (dev)) +if (rte_bus_device_is_ignored (&rte_vmbus_bus.bus, ubuf))continue ;if (vmbus_probe_all_drivers (dev) <0 ) {
drivers/dma/idxd/idxd_bus.c +2 -6
@@ -263,12 +263,8 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' ) retval =1 ; -if (retval && dsa_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_UNDEFINED ) { -if (dsa_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) !=NULL ; -else - retval =rte_bus_find_devargs (&dsa_bus.bus, dev->device.name) ==NULL ; - } +if (retval) + retval = !rte_bus_device_is_ignored (&dsa_bus.bus, dev->device.name);return retval; }
lib/eal/common/eal_common_bus.c +21 -0
@@ -254,6 +254,27 @@ rte_bus_find_by_device_name(const char *str)return rte_bus_find (NULL , bus_can_parse, name); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_device_is_ignored) +bool +rte_bus_device_is_ignored (const struct rte_bus *bus,const char *dev_name) +{ +struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); + +switch (bus->conf.scan_mode) { +case RTE_BUS_SCAN_ALLOWLIST : +if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) +return false; +break ; +case RTE_BUS_SCAN_UNDEFINED : +case RTE_BUS_SCAN_BLOCKLIST : +if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) +return false; +break ; + } + +EAL_LOG (DEBUG ,"device %s:%s is ignored" ,rte_bus_name (bus), dev_name); +return true; +}/* * Get iommu class of devices on the bus.
lib/eal/include/bus_driver.h +6 -0
@@ -313,6 +313,12 @@ void rte_bus_register(struct rte_bus *bus);__rte_internal struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *dev_name); +/** +* Indicate if a device should be skipped during probing of a bus. +*/ +__rte_internal +bool rte_bus_device_is_ignored(const struct rte_bus *bus, const char *dev_name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
PATCH v4 7/7 eal: configure initial device probing
In reply to David MarchandSome applications use port hotplug as their primary way for using DPDK resources.
Having a systematic device probing is a problem when not all available resources will be used by the application, as such applications won't set an explicit allow list at startup.
This is the case for OVS on systems with multiple mlx5 devices:
one device can be used by the kernel while the other(s) are used by DPDK. In such a setup, the kernel used device may get reconfigured in unexpected ways and trigger issues like the one described by Kevin not so long ago in bugzilla 1873.
Add an EAL option so that we can change the default behavior from block-listing to allow-listing which can be summed up as disabling automatic probing.
In case some applications want to require automatic probing, add the opposite option.
---
Changes since v3:
- updated documentation,
- added a release notes entry,
Changes since RFC v2:
- added -A short option alias as it seems intuitive to use with -a,
- renamed option to --no-auto-probing (half Robin and half Thomas suggestions),
- made -A and -b conflicting options,
- added opposite option in case an application wants an explicit behavior,
- updated unit tests accordingly,
- updated documentation (namely some detail on --vdev),
Changes since RFC v1:
- changed approach following Bruce suggestion,
--- app/test/test_eal_flags.c | 63 +++++++++++++++++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 18 +++++++ doc/guides/rel_notes/release_26_07.rst | 8 +++ lib/eal/common/eal_common_bus.c | 17 +++--- lib/eal/common/eal_common_options.c | 10 ++++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + 8 files changed, 114 insertions(+), 7 deletions(-)
app/test/test_eal_flags.c +63 -0
@@ -119,6 +119,8 @@ test_misc_flags(void)#define no_hpet "--no-hpet"#define no_huge "--no-huge"#define no_shconf "--no-shconf" +#define auto_probing "--auto-probing" +#define no_auto_probing "--no-auto-probing"#define allow "--allow"#define vdev "--vdev"#define no_pci "--no-pci"
@@ -338,6 +340,14 @@ test_allow_flag(void) allow,"09:0B.3,type=test" , allow, "08:00.1,type=normal", }; +const char *wlval4[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing }; +const char *wlval5[] = {prgname, prefix, mp_flag, eal_debug_logs, + no_auto_probing, allow,"00FF:09:0B.3" }; +const char *wlval6[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing }; +const char *wlval7[] = {prgname, prefix, mp_flag, eal_debug_logs, + auto_probing, allow,"00FF:09:0B.3" };for (i =0 ; i <RTE_DIM (wlinval); i++) {if (launch_proc (wlinval[i]) ==0 ) {
@@ -360,6 +370,26 @@ test_allow_flag(void) __LINE__);return -1 ; } +if (launch_proc (wlval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with no-auto-probing + allow\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval6) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (wlval7) !=0 ) { +printf ("Error (line %d) - process did not run ok with auto-probing + allow\n" , + __LINE__); +return -1 ; + }return 0 ; }
@@ -383,6 +413,11 @@ test_invalid_b_flag(void) {prgname, prefix, mp_flag, eal_debug_logs, "-b", "error0:0:0.1"}, {prgname, prefix, mp_flag, eal_debug_logs, "-b", "0:0:0.1.2"}, }; +const char *blinval_probing[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , auto_probing}; +const char *blinval_probing_inval[] = + {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"0:0.0" , no_auto_probing}; +/* Test with valid blocklist option */ const char *blval[] = {prgname, prefix, mp_flag, eal_debug_logs,"-b" ,"FF:09:0B.3" };
@@ -396,6 +431,16 @@ test_invalid_b_flag(void)return -1 ; } } +if (launch_proc (blinval_probing) !=0 ) { +printf ("Error (line %d) - process did not run ok with blocklist and auto-probing\n" , + __LINE__); +return -1 ; + } +if (launch_proc (blinval_probing_inval) ==0 ) { +printf ("Error (line %d) - process did run ok with blocklist and no-auto-probing\n" , + __LINE__); +return -1 ; + }if (launch_proc (blval) !=0 ) {printf ("Error (line %d) - process did not run ok with valid blocklist value\n" , __LINE__);
@@ -434,6 +479,12 @@ test_invalid_vdev_flag(void)const char *vdevval3[] = {prgname, prefix, no_huge, eal_debug_logs, bus_debug_logs, no_pci, vdev,"net_ring0,nodeaction=r1:0:CREATE" }; +const char *vdevval4[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, no_auto_probing, vdev,"net_ring0" }; + +const char *vdevval5[] = {prgname, prefix, no_huge, eal_debug_logs, + bus_debug_logs, auto_probing, vdev,"net_ring0" }; +if (launch_proc (vdevinval) ==0 ) {printf ("Error (line %d) - process did run ok with invalid vdev parameter\n" , __LINE__);
@@ -457,6 +508,18 @@ test_invalid_vdev_flag(void) __LINE__); return -1; } + +if (launch_proc (vdevval4) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and no-auto-probing\n" , + __LINE__); +return -1 ; + } + +if (launch_proc (vdevval5) !=0 ) { +printf ("Error (line %d) - process did not run ok with valid vdev value and auto-probing\n" , + __LINE__); +return -1 ; + }return 0 ;#else return TEST_SKIPPED ;
devtools/test-null.sh +1 -1
@@ -30,7 +30,7 @@ logfile=$build/test-null.log (sleep 1 && echo stop) | # testpmd only needs 20M, make it x2 (default number of cores) for NUMA systems $testpmd -l $corelist --no-huge -m 40 \ - $libs -a 0:0.0 --vdev net_null1 --vdev net_null2 $eal_options -- \ + $libs -A --vdev net_null1 --vdev net_null2 $eal_options -- \ --no-mlockall --total-num-mbufs=2048 $testpmd_options -ia | tee $logfile # we expect two ports and some traffic is received and transmitted
doc/guides/linux_gsg/eal_args.include.rst +18 -0
@@ -101,6 +101,24 @@ Lcore-related options Device-related options ~~~~~~~~~~~~~~~~~~~~~~ +* ``-A, --no-auto-probing`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b`` + options are passed. + Disable automatic probing of non-blocked devices. + +.. note:: + Block list (see ``-b`` option below) cannot be used when auto probing is disabled. + + On the other hand, disabling auto probing does not affect the VDEV bus, + because this bus is not concerned by automatic probing + and requires explicit ``-a`` or ``--vdev``. + +* ``--auto-probing`` + + Let EAL probe all available devices unless some ``-a``/``-b`` option is set. + This is the default behavior. + * ``-b, --block <[domain:]bus:devid.func>`` Skip probing a PCI device to prevent EAL from using it.
doc/guides/rel_notes/release_26_07.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added option to disable auto probing.** + + Added EAL options affecting the initial bus probing. + + * ``-A`` or ``--no-auto-probing`` disable the initial bus probing: no device is probed during + ``rte_eal_init`` and the application is responsible for probing each device, + * ``--auto-probing`` enables the initial bus probing, which is the current default behavior. + Removed Items -------------
lib/eal/common/eal_common_bus.c +11 -6
@@ -258,18 +258,23 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_device_is_ignored)bool rte_bus_device_is_ignored (const struct rte_bus *bus,const char *dev_name) { +const struct internal_config *internal_conf =eal_get_internal_configuration ();struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name); +enum rte_bus_scan_mode scan_mode = bus->conf.scan_mode; -switch (bus->conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : +if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (internal_conf->no_auto_probing !=0 ) + scan_mode =RTE_BUS_SCAN_ALLOWLIST ; +else + scan_mode =RTE_BUS_SCAN_BLOCKLIST ; + } + +if (scan_mode ==RTE_BUS_SCAN_ALLOWLIST ) {if (devargs && devargs->policy ==RTE_DEV_ALLOWED )return false; -break ; -case RTE_BUS_SCAN_UNDEFINED : -case RTE_BUS_SCAN_BLOCKLIST : + }else {if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED )return false; -break ; }EAL_LOG (DEBUG ,"device %s:%s is ignored" ,rte_bus_name (bus), dev_name);
lib/eal/common/eal_common_options.c +10 -0
@@ -233,10 +233,15 @@ eal_collate_args(int argc, char **argv)EAL_LOG (ERR ,"Options allow (-a) and block (-b) can't be used at the same time" );return -1 ; } +if (args.no_auto_probing && !TAILQ_EMPTY (&args.block)) { +EAL_LOG (ERR ,"Options no-auto-probing and block (-b) can't be used at the same time" ); +return -1 ; + }/* for non-list args, we can just check for zero/null values using macro */ if (CONFLICTING_OPTIONS(args, coremask, lcores) || CONFLICTING_OPTIONS(args, service_coremask, service_corelist) || + CONFLICTING_OPTIONS(args, no_auto_probing, auto_probing) || CONFLICTING_OPTIONS(args, no_telemetry, telemetry) || CONFLICTING_OPTIONS(args, memory_size, numa_mem) || CONFLICTING_OPTIONS(args, no_huge, numa_mem) ||
@@ -518,6 +523,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg)memset (internal_cfg->vfio_vf_token,0 ,sizeof (internal_cfg->vfio_vf_token)); + internal_cfg->no_auto_probing =0 ; +#ifdef RTE_LIBEAL_USE_HPET internal_cfg->no_hpet =0 ;#else
@@ -1972,6 +1979,9 @@ eal_parse_args(void) } } +if (args.no_auto_probing) + int_cfg->no_auto_probing =1 ; +/* device -a/-b/-vdev options*/ TAILQ_FOREACH (arg, &args.allow, next) if (eal_option_device_add(RTE_DEVTYPE_ALLOWED, arg->arg) < 0)
lib/eal/common/eal_internal_cfg.h +1 -0
@@ -104,6 +104,7 @@ struct internal_config {struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */ +unsigned int no_auto_probing;/**< true to switch from block-listing to allow-listing */ };void eal_reset_internal_config (struct internal_config *internal_cfg);
lib/eal/common/eal_option_list.h +2 -0
@@ -32,6 +32,7 @@* Format of each entry: long name, short name, help string, struct member name. */ /* (Alphabetical) List of common options first */ +BOOL_ARG("--auto-probing", NULL, "Let EAL probe all available devices unless some -a/-b option is set.", auto_probing) LIST_ARG("--allow", "-a", "Add device to allow-list, causing DPDK to only use specified devices", allow) STR_ARG("--base-virtaddr", NULL, "Base virtual address to reserve memory", base_virtaddr)LIST_ARG ("--block" ,"-b" ,"Add device to block-list, preventing DPDK from using the device" , block)
@@ -51,6 +52,7 @@ STR_ARG("--mbuf-pool-ops-name", NULL, "User defined mbuf default pool ops name", STR_ARG("--memory-channels", "-n", "Number of memory channels per socket", memory_channels) STR_ARG("--memory-ranks", "-r", "Force number of memory ranks (don't detect)", memory_ranks) STR_ARG("--memory-size", "-m", "Total size of memory to allocate initially", memory_size) +BOOL_ARG("--no-auto-probing", "-A", "Do not probe any devices unless some -a option is set", no_auto_probing) BOOL_ARG("--no-hpet", NULL, "Disable HPET timer", no_hpet) BOOL_ARG("--no-huge", NULL, "Disable hugetlbfs support", no_huge)BOOL_ARG ("--no-pci" ,NULL ,"Disable all PCI devices" , no_pci)
Signature · 1 line
2.53.0
Re: [PATCH v4 7/7] eal: configure initial device probing
14/04/2026 14:38, David Marchand:
Quoted 2 lines
+.. note::
+ Block list (see ``-b`` option below) cannot be used when auto probing is disabled.
A blank line is missing after the note:: directive.
With this change,
Quoted 72 lines · David Marchand
Applications relying on device hotplug don't work well with the default probing of all available resources.
This series proposes to change this behavior via a new EAL option.--
David MarchandChanges since v3:
- renamed some internal API,
- updated documentation,
- added a release notes entry,Changes since v2:
- rebased for late 26.03 fslmc bus changes,
- fixed devargs lookup,
- added debug logs,Changes since v1:
- restored per bus scan mode,
- fixed logic in device selection for dma/idxd,
- fixed raw/ifpga hotplug on ifpga bus,
- fixed some doxygen,Changes since RFC v3:
- removed per bus scan mode,Changes since RFC v2:
- went one step further and reworked devargs lookup in buses following Bruce comment (see patch 4 which is cosmetic, and patch 5),
- updated device selection helper accordingly and
changed API to be device name based,
- renamed option, added check on -b presence, updated doc in the last patch,Changes since RFC v1:
- reviewed busprobe()and cleaned up NXP drivers,
- changed approach following Bruce comment,David Marchand (7):
devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup
drivers/bus: require probe function for NXP driversdrivers/bus: cleanup devargs lookup in scan
bus: factorize devargs lookup
bus: factorize device selection
eal: configure initial device probingapp/test/test_eal_flags.c | 63 ++++++++++++++++ devtools/test-null.sh | 10 ++- doc/guides/linux_gsg/eal_args.include.rst | 18 +++++ doc/guides/rel_notes/release_26_07.rst | 8 +++ drivers/bus/auxiliary/auxiliary_common.c | 33 +-------- drivers/bus/auxiliary/bus_auxiliary_driver.h | 2 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 6 -- drivers/bus/cdx/cdx.c | 34 +-------- drivers/bus/dpaa/dpaa_bus.c | 71 ++++++++---------- drivers/bus/fslmc/fslmc_bus.c | 75 ++++++++------------ drivers/bus/fslmc/fslmc_vfio.c | 21 ++---- drivers/bus/ifpga/ifpga_bus.c | 8 ++- drivers/bus/pci/bsd/pci.c | 5 +- drivers/bus/pci/linux/pci.c | 2 +- drivers/bus/pci/pci_common.c | 51 ++++--------- drivers/bus/pci/private.h | 11 --- drivers/bus/pci/windows/pci.c | 4 +- drivers/bus/platform/platform.c | 43 +---------- drivers/bus/uacce/uacce.c | 39 +--------- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 2 +- drivers/bus/vmbus/private.h | 3 -
Quoted 8 lines
drivers/bus/vmbus/vmbus_common.c | 45 +++--------- drivers/dma/idxd/idxd_bus.c | 18 +---- lib/eal/common/eal_common_bus.c | 54 ++++++++++++++ lib/eal/common/eal_common_options.c | 10 +++ lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_option_list.h | 2 + lib/eal/include/bus_driver.h | 38 ++++++++++ 30 files changed, 314 insertions(+), 367 deletions(-)
Series applied, thanks for all the reviews!
Signature · 1 line
David Marchand