On 3/23/26 10:53 AM, David Marchand wrote: > 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.) > 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(-) > > diff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c > index 2ca0af7914..27a31bbefa 100644 > --- a/lib/eal/common/eal_common_bus.c > +++ b/lib/eal/common/eal_common_bus.c > @@ -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. > */ > diff --git a/lib/eal/common/eal_common_devargs.c > b/lib/eal/common/eal_common_devargs.c > index c523429d67..8083bdebc2 100644 > --- a/lib/eal/common/eal_common_devargs.c > +++ b/lib/eal/common/eal_common_devargs.c > @@ -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; > diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h > index e032dd10c9..12db04dce2 100644 > --- a/lib/eal/common/eal_private.h > +++ b/lib/eal/common/eal_private.h > @@ -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. > diff --git a/lib/eal/include/bus_driver.h b/lib/eal/include/bus_driver.h > index e67e052404..9045d64816 100644 > --- a/lib/eal/include/bus_driver.h > +++ b/lib/eal/include/bus_driver.h > @@ -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;

