devtools: check packet forwarding in null test
Subsystems (2)
RFC 1/2 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
RFC 2/2 eal: configure initial device probing
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 to disable device probing, allowing to select per bus.
Note: the current implementation does not take combinations of the new option with -a/-b.
--- app/test/test.c | 1 + app/test/test_eal_flags.c | 31 ++++++++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 7 ++++ lib/eal/common/eal_common_bus.c | 50 ++++++++++++++++++++--- lib/eal/common/eal_common_options.c | 14 +++++++ lib/eal/common/eal_internal_cfg.h | 2 + lib/eal/common/eal_option_list.h | 1 + lib/eal/common/eal_private.h | 13 ++++++ lib/eal/freebsd/eal.c | 3 +- lib/eal/linux/eal.c | 3 +- lib/eal/windows/eal.c | 2 +- 12 files changed, 118 insertions(+), 11 deletions(-)
app/test/test.c +1 -0
@@ -72,6 +72,7 @@ do_recursive_call(void) { "test_main_lcore_flag", no_action }, { "test_invalid_n_flag", no_action }, { "test_no_hpet_flag", no_action }, + { "test_no_probe_flag", no_action }, { "test_allow_flag", no_action }, { "test_invalid_b_flag", no_action }, { "test_invalid_vdev_flag", no_action },
app/test/test_eal_flags.c +31 -0
@@ -46,6 +46,13 @@ test_no_huge_flag(void)return TEST_SKIPPED ; } +static int +test_no_probe_flag (void ) +{ +printf ("no_probe_flag not supported on Windows, skipping test\n" ); +return TEST_SKIPPED ; +} +static int test_allow_flag (void ) {
@@ -302,6 +309,29 @@ get_number_of_sockets(void) }#endif /* RTE_EXEC_ENV_LINUX */ +static int +test_no_probe_flag (void ) +{ +const char *prefix =file_prefix_arg (); +if (prefix ==NULL ) +return -1 ; + +const char *wlvalid[][4 ] = { + {prgname, prefix, mp_flag,"--no-probe" }, + {prgname, prefix, mp_flag,"--no-probe=pci" }, + }; + +for (unsigned int i =0 ; i <RTE_DIM (wlvalid); i++) { +if (launch_proc (wlvalid[i]) !=0 ) { +printf ("Error (line %d) - process did not run with valid no probe parameter\n" , + __LINE__); +return -1 ; + } + } + +return 0 ; +} +/* * Test that the app doesn't run with invalid allow option. * Final tests ensures it does run with valid options as sanity check (one
@@ -1678,6 +1708,7 @@ REGISTER_FAST_TEST(eal_flags_main_opt_autotest, NOHUGE_SKIP, ASAN_SKIP, test_maiREGISTER_FAST_TEST (eal_flags_n_opt_autotest,NOHUGE_SKIP ,ASAN_SKIP , test_invalid_n_flag);REGISTER_FAST_TEST (eal_flags_hpet_autotest,NOHUGE_SKIP ,ASAN_SKIP , test_no_hpet_flag);REGISTER_FAST_TEST (eal_flags_no_huge_autotest,NOHUGE_SKIP ,ASAN_SKIP , test_no_huge_flag); +REGISTER_FAST_TEST (eal_flags_no_probe_autotest,NOHUGE_SKIP ,ASAN_SKIP , test_no_probe_flag);REGISTER_FAST_TEST (eal_flags_a_opt_autotest,NOHUGE_SKIP ,ASAN_SKIP , test_allow_flag);REGISTER_FAST_TEST (eal_flags_b_opt_autotest,NOHUGE_SKIP ,ASAN_SKIP , test_invalid_b_flag);REGISTER_FAST_TEST (eal_flags_vdev_opt_autotest,NOHUGE_SKIP ,ASAN_SKIP , test_invalid_vdev_flag);
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 --no-probe=pci --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 +7 -0
@@ -136,6 +136,13 @@ Device-related options Disable PCI bus. +* ``--no-probe[=bus list]`` + + Disable device probing as part of EAL init. Disabling affects either all buses + when no value is passed, or the list of buses. This is especially useful when + the DPDK application relies on resources hotplug and has no idea of which + device will be used at the time rte_eal_init() is called. + Multiprocessing-related options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/eal/common/eal_common_bus.c +45 -5
73 lines not on this page · raw message
lib/eal/common/eal_common_options.c +14 -0
@@ -518,6 +518,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_probe =NULL ; +#ifdef RTE_LIBEAL_USE_HPET internal_cfg->no_hpet =0 ;#else
@@ -2206,6 +2208,17 @@ eal_parse_args(void) }#endif +if (args.no_probe !=NULL ) { +if (args.no_probe == (void *)1 ) + int_cfg->no_probe =strdup ("all" ); +else + int_cfg->no_probe =strdup (args.no_probe); +if (int_cfg->no_probe ==NULL ) { +EAL_LOG (ERR ,"failed to allocate memory for no probe parameter" ); +return -1 ; + } + } +/* simple flag settings * Only set these to 1, as we don't want to set them to 0 in case * other options above have already set them.
@@ -2336,6 +2349,7 @@ eal_cleanup_config(struct internal_config *internal_cfg) {free (internal_cfg->hugefile_prefix);free (internal_cfg->hugepage_dir); +free (internal_cfg->no_probe);free (internal_cfg->user_mbuf_pool_ops_name);return 0 ;
lib/eal/common/eal_internal_cfg.h +2 -0
@@ -57,6 +57,8 @@ struct internal_config {volatile unsigned force_nrank;/**< force number of ranks */ volatile unsigned no_hugetlbfs;/**< true to disable hugetlbfs */ struct hugepage_file_discipline hugepage_file; +char *no_probe; +/**< a list of (or all) buses to exclude when probing devices at init */ volatile unsigned no_pci;/**< true to disable PCI */ volatile unsigned no_hpet;/**< true to disable HPET */ volatile unsigned vmware_tsc_map;/**< true to use VMware TSC mapping
lib/eal/common/eal_option_list.h +1 -0
@@ -51,6 +51,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) +OPT_STR_ARG("--no-probe", NULL, "Disable device probing at init (for all or some buses)", no_probe) 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)
lib/eal/common/eal_private.h +13 -0
@@ -469,6 +469,19 @@ int rte_eal_memory_detach(void);*/ struct rte_bus *rte_bus_find_by_device_name (const char *str); +/** +* Call all buses probe() function except those present in the +* excluded string. +* +* @param excluded +* A list of bus to exclude separated by ,. A "all" string +* is a special case that results in skipping all buses. +* @return +* 0 on success; +* (<0) on failure. +*/ +int eal_bus_probe (const char *excluded); +/** * For each device on the buses, call the driver-specific function for * device cleanup.
lib/eal/freebsd/eal.c +1 -2
@@ -717,8 +717,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -/* Probe all the buses and devices/drivers on them */ -if (rte_bus_probe ()) { +if (eal_bus_probe (internal_conf->no_probe) <0 ) {rte_eal_init_alert ("Cannot probe devices" ); rte_errno =ENOTSUP ; goto err_out;
lib/eal/linux/eal.c +1 -2
@@ -890,8 +890,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -/* Probe all the buses and devices/drivers on them */ -if (rte_bus_probe ()) { +if (eal_bus_probe (internal_conf->no_probe) <0 ) {rte_eal_init_alert ("Cannot probe devices" ); rte_errno =ENOTSUP ; goto err_out;
lib/eal/windows/eal.c +1 -1
@@ -398,7 +398,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (rte_bus_probe ()) { +if (eal_bus_probe (internal_conf->no_probe) <0 ) {rte_eal_init_alert ("Cannot probe devices" ); rte_errno =ENOTSUP ; goto err_out;
Signature · 1 line
2.53.0
Re: [RFC 2/2] eal: configure initial device probing
Quoted 12 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.
Quoted 7 lines
Add an EAL option to disable device probing, allowing to select per bus.
Note: the current implementation does not take combinations of the new option with -a/-b.
Signed-off-by David Marchand <[email protected]>---
Wondering about this problem and fix options. Rather than a new flag for no-probe, would an alternative flag to switch the default mode from block-listing to allow-listing work?
Right now, by default, EAL probes all buses and tries to take all non-blocklisted devices. We could add a flag to switch that so that we allow-list by default, which I think should have the same effect as this if no -a flags are passed. We already have support for managing -a and -b flag interactions, which should make interacting with the new flag easier.
WDYT?
/Bruce
Re: [RFC 2/2] eal: configure initial device probing
Quoted 25 lines · Bruce Richardson
Quoted 12 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.Quoted 7 lines
Add an EAL option to disable device probing, allowing to select per bus.
Note: the current implementation does not take combinations of the new option with -a/-b.
Signed-off-by David Marchand <[email protected]>---
Wondering about this problem and fix options. Rather than a new flag for no-probe, would an alternative flag to switch the default mode from block-listing to allow-listing work?
Quoted 5 lines
Right now, by default, EAL probes all buses and tries to take all non-blocklisted devices. We could add a flag to switch that so that we allow-list by default, which I think should have the same effect as this if no -a flags are passed. We already have support for managing -a and -b flag interactions, which should make interacting with the new flag easier.
I like the idea. The devil is in the details though and I'll have to look carefully at all bus probe() functions.
I'll try to implement as a RFC v2.
Signature · 1 line
David Marchand
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 · 35 lines
David Marchand Changes since RFC v1: - reviewed bus probe() and cleaned up NXP drivers, - changed approach following Bruce comment, David Marchand (5): devtools: check packet forwarding in null test bus/fslmc: fix bus cleanup drivers/bus: require probe function for NXP drivers bus: factorize device selection eal: configure initial device probing app/test/test_eal_flags.c | 9 +++++++ devtools/test-null.sh | 10 +++++-- doc/guides/linux_gsg/eal_args.include.rst | 6 +++++ drivers/bus/auxiliary/auxiliary_common.c | 15 +---------- drivers/bus/cdx/cdx.c | 21 +-------------- drivers/bus/dpaa/dpaa_bus.c | 26 ++++++------------ drivers/bus/fslmc/fslmc_bus.c | 29 ++++++-------------- drivers/bus/fslmc/fslmc_vfio.c | 22 +++++----------- drivers/bus/pci/pci_common.c | 15 +---------- drivers/bus/platform/platform.c | 28 ++------------------ drivers/bus/uacce/uacce.c | 22 +--------------- drivers/bus/vmbus/vmbus_common.c | 21 +-------------- drivers/dma/idxd/idxd_bus.c | 32 +++++++++-------------- lib/eal/common/eal_common_bus.c | 31 ++++++++++++++++++++++ lib/eal/common/eal_common_options.c | 3 +++ lib/eal/common/eal_option_list.h | 1 + lib/eal/common/eal_private.h | 6 +++++ lib/eal/include/bus_driver.h | 7 +++++ 18 files changed, 112 insertions(+), 192 deletions(-) -- 2.53.0
RFC v2 1/5 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
Quoted 7 lines · David Marchand
Add some simple checks that testpmd was indeed polling two ports, and some packets got through it.
Signed-off-by David Marchand <[email protected]>--- devtools/test-null.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
RFC v2 2/5 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 earlier.
Since the device contains a reference to the driver that probed it, simply call this driver remove op.
--- drivers/bus/fslmc/fslmc_vfio.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +6 -16
@@ -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,21 +1411,11 @@ 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) { + ret = drv->remove (dev); +if (ret) +DPAA2_BUS_ERR ("Unable to remove" ); }break ;default :
Signature · 1 line
2.53.0
RFC v2 3/5 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: [RFC v2 3/5] drivers/bus: require probe function for NXP drivers
Quoted 8 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]>--- drivers/bus/dpaa/dpaa_bus.c | 6 +++--- drivers/bus/fslmc/fslmc_bus.c | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-)
RFC v2 4/5 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.
--- drivers/bus/auxiliary/auxiliary_common.c | 15 +---------- drivers/bus/cdx/cdx.c | 21 +--------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++------------ drivers/bus/fslmc/fslmc_bus.c | 22 ++++++---------- drivers/bus/pci/pci_common.c | 15 +---------- drivers/bus/platform/platform.c | 28 ++------------------- drivers/bus/uacce/uacce.c | 22 +--------------- drivers/bus/vmbus/vmbus_common.c | 21 +--------------- drivers/dma/idxd/idxd_bus.c | 32 +++++++++--------------- lib/eal/common/eal_common_bus.c | 18 +++++++++++++ lib/eal/include/bus_driver.h | 7 ++++++ 11 files changed, 58 insertions(+), 167 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +1 -14
@@ -399,20 +399,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); - -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; +return rte_bus_is_ignored_device (&auxiliary_bus.bus,auxiliary_devargs_lookup (name)); } static enum rte_iova_mode
drivers/bus/cdx/cdx.c +1 -20
@@ -164,25 +164,6 @@ cdx_devargs_lookup(const char *dev_name)return NULL ; } -static bool -cdx_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =cdx_devargs_lookup (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
@@ -282,7 +263,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,cdx_devargs_lookup (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->device.devargs))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
@@ -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,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.devargs)) {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/pci_common.c +1 -14
@@ -721,20 +721,7 @@ 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); - -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; +return rte_bus_is_ignored_device (&rte_pci_bus.bus,pci_devargs_lookup (pci_addr)); }enum rte_iova_mode
drivers/bus/platform/platform.c +2 -26
@@ -56,30 +56,6 @@ dev_devargs(const char *dev_name)return NULL ; } -static bool -dev_allowed (const char *dev_name) -{ -struct rte_devargs *devargs; - - devargs =dev_devargs (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) {
@@ -173,7 +149,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_devargs (dev_name)))continue ;if (!dev_is_bound_vfio_platform (dev_name))
@@ -497,7 +473,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->devargs))return -EPERM ;if (!dev_is_bound_vfio_platform (dev->name))
drivers/bus/uacce/uacce.c +1 -21
@@ -84,26 +84,6 @@ uacce_devargs_lookup(const char *dev_name)return NULL ; } -static bool -uacce_ignore_device (const char *dev_name) -{ -struct rte_devargs *devargs =uacce_devargs_lookup (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.
@@ -310,7 +290,7 @@ uacce_scan(void)continue ; } -if (uacce_ignore_device (e->d_name)) +if (rte_bus_is_ignored_device (&uacce_bus.bus,uacce_devargs_lookup (e->d_name)))continue ;if (uacce_scan_one (e->d_name) <0 )
drivers/bus/vmbus/vmbus_common.c +1 -20
@@ -168,25 +168,6 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)return 1 ; } -static bool -vmbus_ignore_device (struct rte_vmbus_device *dev) -{ -struct rte_devargs *devargs =vmbus_devargs_lookup (dev); - -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
@@ -205,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,vmbus_devargs_lookup ((dev))))continue ;if (vmbus_probe_all_drivers (dev) <0 ) {
drivers/dma/idxd/idxd_bus.c +12 -20
@@ -6,6 +6,7 @@#include <fcntl.h> #include <unistd.h> #include <sys/mman.h> +#include <stdbool.h> #include <libgen.h> #include <bus_driver.h>
@@ -247,40 +248,32 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return 0 ; } -static int search_devargs (const char *name) +static const struct rte_devargs *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 devargs; } -return 0 ; +return NULL ; } -static int +static bool is_for_this_process_use (struct rte_dsa_device *dev,const char *name) {char prefix[256 ]; -int retval =0 ;size_t prefixlen; prefixlen =rte_basename (rte_eal_get_runtime_dir (), prefix,sizeof (prefix));if (prefixlen >=sizeof (prefix) ||strcmp (prefix,"." ) ==0 ) -return retval; - -if (strncmp (name,"dpdk_" ,5 ) ==0 ) - retval =1 ; -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 =search_devargs (dev->device.name); -else - retval = !search_devargs (dev->device.name); +return false; + +if (strncmp (name,"dpdk_" ,5 ) ==0 || + (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' )) { +return !rte_bus_is_ignored_device (&dsa_bus.bus,search_devargs (dev->device.name)); } -return retval; +return false; } static int
@@ -295,8 +288,7 @@ dsa_probe(void) read_wq_string(dev, "name", name, sizeof(name)) < 0)continue ; -if (strncmp (type,"user" ,4 ) ==0 && -is_for_this_process_use (dev, name)) { +if (strncmp (type,"user" ,4 ) ==0 &&is_for_this_process_use (dev, name)) { dev->device.driver = &dsa_bus.driver;idxd_probe_dsa (dev);continue ;
lib/eal/common/eal_common_bus.c +18 -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>
@@ -226,6 +227,23 @@ 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 struct rte_devargs *devargs) +{ +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 +7 -0
@@ -302,6 +302,13 @@ RTE_INIT_PRIO(businitfn_ ##nm, BUS) \__rte_internal void rte_bus_unregister(struct rte_bus *bus); +/** +* Indicate if a device referenced by some devargs should be skipped during +* probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const struct rte_devargs *devargs); + #ifdef __cplusplus }#endif
Signature · 1 line
2.53.0
Re: [RFC v2 4/5] bus: factorize device selection
Quoted 20 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]>--- drivers/bus/auxiliary/auxiliary_common.c | 15 +---------- drivers/bus/cdx/cdx.c | 21 +--------------- drivers/bus/dpaa/dpaa_bus.c | 24 ++++++------------ drivers/bus/fslmc/fslmc_bus.c | 22 ++++++---------- drivers/bus/pci/pci_common.c | 15 +---------- drivers/bus/platform/platform.c | 28 ++------------------- drivers/bus/uacce/uacce.c | 22 +--------------- drivers/bus/vmbus/vmbus_common.c | 21 +--------------- drivers/dma/idxd/idxd_bus.c | 32 +++++++++--------------- lib/eal/common/eal_common_bus.c | 18 +++++++++++++ lib/eal/include/bus_driver.h | 7 ++++++ 11 files changed, 58 insertions(+), 167 deletions(-)
<snip>
Quoted 23 lines
lib/eal/common/eal_common_bus.c +8
-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> @@ -226,6 +227,23 @@ 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 struct rte_devargs *devargs) +{ +switch (bus->conf.scan_mode) { +case RTE_BUS_SCAN_ALLOWLIST : +if (devargs && devargs->policy ==RTE_DEV_ALLOWED )
lib/eal/common/eal_common_bus.c rte_bus_find_by_device_name(const char *str) · line 246
Quoted 10 lines
lib/eal/common/eal_common_bus.c +10
-0+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; +}
I think this could do with more comments. Am I right in thinking that devargs is NULL on input if the device in question is not referenced by any devargs passed to the app? This seems a little obscure form of input parameter, so I definitely think it needs documenting.
Is there any way the search for the device name that returns the devargs null/non-null pointer can be similarly generalized?
Quoted 24 lines
lib/eal/common/eal_common_bus.c +0
-0/* * Get iommu class of devices on the bus. lib/eal/include/bus_driver.h +7
-0@@ -302,6 +302,13 @@ RTE_INIT_PRIO(businitfn_ ##nm, BUS) \__rte_internal void rte_bus_unregister(struct rte_bus *bus); +/** +* Indicate if a device referenced by some devargs should be skipped during +* probing of a bus. +*/ +__rte_internal +bool rte_bus_is_ignored_device(const struct rte_bus *bus, const struct rte_devargs *devargs); + #ifdef __cplusplus }#endif Signature · 1 line
2.53.0
Re: [RFC v2 4/5] bus: factorize device selection
Quoted 14 lines · Bruce Richardson
Quoted 14 lines
lib/eal/common/eal_common_bus.c +14
-0+RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_is_ignored_device) +bool +rte_bus_is_ignored_device (const struct rte_bus *bus,const struct rte_devargs *devargs) +{ +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 ;
Quoted 8 lines
lib/eal/common/eal_common_bus.c rte_bus_find_by_device_name(const char *str) · line 246
Quoted 3 lines
lib/eal/common/eal_common_bus.c +3
-0+ } +return true; +}I think this could do with more comments. Am I right in thinking that devargs is NULL on input if the device in question is not referenced by any devargs passed to the app? This seems a little obscure form of input parameter, so I definitely think it needs documenting.
Yes the handling of a NULL devargs is implicit, I can add a comment.
Quoted 2 lines
Is there any way the search for the device name that returns the devargs null/non-null pointer can be similarly generalized?
I also wondered about that and it would be better, but I stopped quickly when I looked at the bus specific devargs_lookup functions, preparing the v2.
For example with the pci bus, names for pci devices can take various forms, so the pci bus uses its device specific representation for identifying the devargs.
rte_pci_device_name(&dev->addr,
dev->name, sizeof(dev->name));
devargs = pci_devargs_lookup(&dev->addr);And:
RTE_EAL_DEVARGS_FOREACH("pci", devargs) {
devargs->bus->parse(devargs->name, &addr);
if (!rte_pci_addr_cmp(pci_addr, &addr))
return devargs;
}I suspect vmbus is the same, with this uuid stuff.
And others bus need investigation too.
I could try to normalize the devargs names for this lookup.. ?
Signature · 1 line
David Marchand
Re: [RFC v2 4/5] bus: factorize device selection
Quoted 49 lines · David Marchand
Quoted 14 lines · Bruce Richardson
Quoted 14 lines
lib/eal/common/eal_common_bus.c +14
-0+RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_is_ignored_device) +bool +rte_bus_is_ignored_device (const struct rte_bus *bus,const struct rte_devargs *devargs) +{ +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 ;Quoted 8 lines
lib/eal/common/eal_common_bus.c rte_bus_find_by_device_name(const char *str) · line 246
Quoted 3 lines
lib/eal/common/eal_common_bus.c +3
-0+ } +return true; +}I think this could do with more comments. Am I right in thinking that devargs is NULL on input if the device in question is not referenced by any devargs passed to the app? This seems a little obscure form of input parameter, so I definitely think it needs documenting.
Yes the handling of a NULL devargs is implicit, I can add a comment.
Quoted 2 lines
Is there any way the search for the device name that returns the devargs null/non-null pointer can be similarly generalized?
I also wondered about that and it would be better, but I stopped quickly when I looked at the bus specific
devargs_lookupfunctions, preparing the v2.For example with the pci bus, names for pci devices can take various forms, so the pci bus uses its device specific representation for identifying the devargs.
rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name)); devargs = pci_devargs_lookup(&dev->addr);And:
RTE_EAL_DEVARGS_FOREACH("pci", devargs) { devargs->bus->parse(devargs->name, &addr); if (!rte_pci_addr_cmp(pci_addr, &addr)) return devargs; }
Quoted 5 lines
I suspect vmbus is the same, with this uuid stuff.
And others bus need investigation too.
I could try to normalize the devargs names for this lookup.. ?
That's a nice to have, IMHO. I think if the NULL/non-NULL is properly commented it's good enough for this set. You can probably note the cleanup as a TODO in the code as a further reminder.
/Bruce
RFC v2 5/5 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.
---
Changes since RFC v1:
- changed approach following Bruce suggestion,
--- app/test/test_eal_flags.c | 9 ++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 6 ++++++ lib/eal/common/eal_common_bus.c | 25 +++++++++++++++++------ lib/eal/common/eal_common_options.c | 3 +++ lib/eal/common/eal_option_list.h | 1 + lib/eal/common/eal_private.h | 6 ++++++ 7 files changed, 45 insertions(+), 7 deletions(-)
app/test/test_eal_flags.c +9 -0
@@ -1030,6 +1030,10 @@ test_misc_flags(void)const char *const argv28[] = {prgname, prefix, mp_flag, eal_debug_logs,"--log-color=invalid" }; +/* Try running with --allow-explicitly */ +const char *const argv29[] = {prgname, prefix, mp_flag, eal_debug_logs, +"--allow-explicitly" }; +/* run all tests also applicable to FreeBSD first */ if (launch_proc (argv0) ==0 ) {
@@ -1176,6 +1180,11 @@ test_misc_flags(void) __LINE__); goto fail; } +if (launch_proc (argv29) !=0 ) { +printf ("Error (line %d) - process did not run ok with --allow-explicitly parameter\n" , + __LINE__); + goto fail; + }rmdir (hugepath_dir3);rmdir (hugepath_dir2);
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 --allow-explicitly --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 +6 -0
@@ -101,6 +101,12 @@ Lcore-related options Device-related options ~~~~~~~~~~~~~~~~~~~~~~ +* ``--allow-explicitly`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b``/``--vdev`` + options are passed. + However, when an application relies on hotplug, it may want to plug each device explicitly. + * ``-b, --block <[domain:]bus:devid.func>`` Skip probing a PCI device to prevent EAL from using it.
lib/eal/common/eal_common_bus.c +19 -6
@@ -15,6 +15,8 @@#include <eal_export.h> #include "eal_private.h" +static bool allow_explicitly; +static struct rte_bus_list rte_bus_list =TAILQ_HEAD_INITIALIZER (rte_bus_list);
@@ -98,6 +100,12 @@ rte_bus_probe(void)return 0 ; } +void +eal_bus_set_allow_explicitly (void ) +{ + allow_explicitly = true; +} +/* Clean up all devices of all buses */ int eal_bus_cleanup (void )
@@ -231,16 +239,21 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_is_ignored_device)bool rte_bus_is_ignored_device (const struct rte_bus *bus,const struct rte_devargs *devargs) { -switch (bus->conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : +enum rte_bus_scan_mode scan_mode = bus->conf.scan_mode; + +if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (allow_explicitly) + 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 +3 -0
@@ -1972,6 +1972,9 @@ eal_parse_args(void) } } +if (args.allow_explicitly) +eal_bus_set_allow_explicitly (); +/* 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_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("--allow-explicitly", NULL, "Change EAL device probing to consider only allowed devices", allow_explicitly) 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)
lib/eal/common/eal_private.h +6 -0
@@ -469,6 +469,12 @@ int rte_eal_memory_detach(void);*/ struct rte_bus *rte_bus_find_by_device_name (const char *str); +/** +* Change behavior of rte_bus_probe() from a block-listing approach +* to an allow-listing approach. +*/ +void eal_bus_set_allow_explicitly (void ); +/** * For each device on the buses, call the driver-specific function for * device cleanup.
Signature · 1 line
2.53.0
Re: [RFC v2 5/5] eal: configure initial device probing
Quoted 12 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.
Quoted 7 lines
Add an EAL option so that we can change the default behavior from block-listing to allow-listing.
Signed-off-by David Marchand <[email protected]>---
Changes since RFC v1:
- changed approach following Bruce suggestion,
Re: [RFC v2 5/5] eal: configure initial device probing
In reply to David MarchandDavid Marchand, Feb 26, 2026 at 17:20:
Quoted 12 lines
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.
Quoted 7 lines
Add an EAL option so that we can change the default behavior from block-listing to allow-listing.
Signed-off-by David Marchand <[email protected]>---
Changes since RFC v1:
- changed approach following Bruce suggestion,
Hey David,
thanks for the patch. The idea looks much nicer than some magic PCI bus value that disables auto probing.
I have a few cosmetic remarks below:
Quoted 16 lines
--- app/test/test_eal_flags.c | 9 ++++++++ devtools/test-null.sh | 2 +- doc/guides/linux_gsg/eal_args.include.rst | 6 ++++++ lib/eal/common/eal_common_bus.c | 25 +++++++++++++++++------ lib/eal/common/eal_common_options.c | 3 +++ lib/eal/common/eal_option_list.h | 1 + lib/eal/common/eal_private.h | 6 ++++++ 7 files changed, 45 insertions(+), 7 deletions(-)app/test/test_eal_flags.c +0
-0
app/test/test_eal_flags.c test_misc_flags(void) · line 1035
Quoted 6 lines
app/test/test_eal_flags.c +3
-0@@ -1030,6 +1030,10 @@ test_misc_flags(void)const char *const argv28[] = {prgname, prefix, mp_flag, eal_debug_logs,"--log-color=invalid" }; +/* Try running with --allow-explicitly */ +const char *const argv29[] = {prgname, prefix, mp_flag, eal_debug_logs, +"--allow-explicitly" };
I am not convinced by the option name. What do you think of:
--no-autoprobe
That would match the Linux sriov_drivers_autoprobe sysfs.
Quoted 34 lines
app/test/test_eal_flags.c +6
-0+/* run all tests also applicable to FreeBSD first */ if (launch_proc (argv0) ==0 ) {@@ -1176,6 +1180,11 @@ test_misc_flags(void) __LINE__); goto fail; } +if (launch_proc (argv29) !=0 ) { +printf ("Error (line %d) - process did not run ok with --allow-explicitly parameter\n" , + __LINE__); + goto fail; + }rmdir (hugepath_dir3);rmdir (hugepath_dir2);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 --allow-explicitly --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 +0
-0
doc/guides/linux_gsg/eal_args.include.rst Lcore-related options · line 108
Quoted 8 lines
doc/guides/linux_gsg/eal_args.include.rst +5
-0@@ -101,6 +101,12 @@ Lcore-related options Device-related options ~~~~~~~~~~~~~~~~~~~~~~ +* ``--allow-explicitly`` + + By default, EAL probes all devices on every available bus, unless some ``-a``/``-b``/``--vdev`` + options are passed. + However, when an application relies on hotplug, it may want to plug each device explicitly.
Can you reword this to make it explicit what the flag does? E.g.:
Disable automatic probing of non-blocked devices.
Quoted 77 lines
doc/guides/linux_gsg/eal_args.include.rst +1
-0+ * ``-b, --block <[domain:]bus:devid.func>`` Skip probing a PCI device to prevent EAL from using it.lib/eal/common/eal_common_bus.c +19
-6@@ -15,6 +15,8 @@#include <eal_export.h> #include "eal_private.h" +static bool allow_explicitly; +static struct rte_bus_list rte_bus_list =TAILQ_HEAD_INITIALIZER (rte_bus_list);@@ -98,6 +100,12 @@ rte_bus_probe(void)return 0 ; } +void +eal_bus_set_allow_explicitly (void ) +{ + allow_explicitly = true; +} +/* Clean up all devices of all buses */ int eal_bus_cleanup (void )@@ -231,16 +239,21 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_is_ignored_device)bool rte_bus_is_ignored_device (const struct rte_bus *bus,const struct rte_devargs *devargs) { -switch (bus->conf.scan_mode) { -case RTE_BUS_SCAN_ALLOWLIST : +enum rte_bus_scan_mode scan_mode = bus->conf.scan_mode; + +if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { +if (allow_explicitly) + 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 +3
-0@@ -1972,6 +1972,9 @@ eal_parse_args(void) } } +if (args.allow_explicitly) +eal_bus_set_allow_explicitly (); +/* 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_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 ("--allow-explicitly" ,NULL ,"Change EAL device probing to consider only allowed devices" , allow_explicitly)
Depending on what option name we settle on, could you add a short flag too? E.g.:
BOOL_ARG("--no-autoprobe", "-N", "Disable automatic probing of non-blocked devices", no_autoprobe)
Or:
BOOL_ARG("--no-autoprobe", "-P", "Disable automatic probing of non-blocked devices", no_autoprobe)
Quoted 20 lines
lib/eal/common/eal_option_list.h +0
-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)lib/eal/common/eal_private.h +6
-0@@ -469,6 +469,12 @@ int rte_eal_memory_detach(void);*/ struct rte_bus *rte_bus_find_by_device_name (const char *str); +/** +* Change behavior of rte_bus_probe() from a block-listing approach +* to an allow-listing approach. +*/ +void eal_bus_set_allow_explicitly (void ); +/** * For each device on the buses, call the driver-specific function for * device cleanup.
Re: [RFC v2 5/5] eal: configure initial device probing
26/02/2026 17:50, Robin Jarry:
Quoted 15 lines
David Marchand, Feb 26, 2026 at 17:20:
Quoted 14 lines
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.
[...]
Quoted 8 lines
app/test/test_eal_flags.c test_misc_flags(void) · line 1035
Quoted 2 lines
app/test/test_eal_flags.c +2
-0+const char *const argv29[] = {prgname, prefix, mp_flag, eal_debug_logs, +"--allow-explicitly" };I am not convinced by the option name. What do you think of:
--no-autoprobe
That would match the Linux
sriov_drivers_autoprobesysfs.
The name --no-autoprobe is better indeed.
The exact effect of this option is to disable initial probing of devices on all buses (except vdev).
Another name could be --no-initial-probing
I think we should add the opposite option as well
to allow changing the default mode later.
For such an option, --autoprobe looks better than --initial-probing.
Other opinions?
[...]
Quoted 8 lines
Depending on what option name we settle on, could you add a short flag too? E.g.:
BOOL_ARG("--no-autoprobe", "-N", "Disable automatic probing of non-blocked devices", no_autoprobe)Or:
BOOL_ARG("--no-autoprobe", "-P", "Disable automatic probing of non-blocked devices", no_autoprobe)
I don't see the benefit of a short flag.
It makes reading commands less obvious.
Re: [RFC v2 5/5] eal: configure initial device probing
Quoted 43 lines · Thomas Monjalon
26/02/2026 17:50, Robin Jarry:
Quoted 15 lines
David Marchand, Feb 26, 2026 at 17:20:
Quoted 14 lines
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.
[...]
Quoted 8 lines
app/test/test_eal_flags.c test_misc_flags(void) · line 1035
Quoted 2 lines
app/test/test_eal_flags.c +2
-0+const char *const argv29[] = {prgname, prefix, mp_flag, eal_debug_logs, +"--allow-explicitly" };I am not convinced by the option name. What do you think of:
--no-autoprobe
That would match the Linux
sriov_drivers_autoprobesysfs.The name --no-autoprobe is better indeed.
The exact effect of this option is to disable initial probing of devices on all buses (except vdev).
Another name could be --no-initial-probingI think we should add the opposite option as well
to allow changing the default mode later.
For such an option, --autoprobe looks better than --initial-probing.Other opinions?
[...]
Quoted 3 lines
Depending on what option name we settle on, could you add a short flag too? E.g.:
Quoted 9 lines
Quoted 5 lines
BOOL_ARG("--no-autoprobe", "-N", "Disable automatic probing of non-blocked devices", no_autoprobe)Or:
BOOL_ARG("--no-autoprobe", "-P", "Disable automatic probing of non-blocked devices", no_autoprobe)I don't see the benefit of a short flag.
It makes reading commands less obvious.
I actually would prefer to have a short option available, and I'd really like that short option to be "-A" since it serves as the perfect addition to the "-a" flag to specify devices to probe.
Based on that, I would look for long options which allow "-A" as the short version for example:
--allowlisted-devs-only
/Bruce
Re: [RFC v2 5/5] eal: configure initial device probing
Quoted 57 lines · On Fri, 27 Feb 2026 13:51:48 +0000 Bruce Richardson…
Quoted 43 lines · Thomas Monjalon
26/02/2026 17:50, Robin Jarry:
Quoted 15 lines
David Marchand, Feb 26, 2026 at 17:20:
Quoted 14 lines
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.
[...]
Quoted 8 lines
app/test/test_eal_flags.c test_misc_flags(void) · line 1035
Quoted 2 lines
app/test/test_eal_flags.c +2
-0+const char *const argv29[] = {prgname, prefix, mp_flag, eal_debug_logs, +"--allow-explicitly" };I am not convinced by the option name. What do you think of:
--no-autoprobe
That would match the Linux
sriov_drivers_autoprobesysfs.The name --no-autoprobe is better indeed.
The exact effect of this option is to disable initial probing of devices on all buses (except vdev).
Another name could be --no-initial-probingI think we should add the opposite option as well
to allow changing the default mode later.
For such an option, --autoprobe looks better than --initial-probing.Other opinions?
[...]
Quoted 3 lines
Depending on what option name we settle on, could you add a short flag too? E.g.:
Quoted 9 lines
Quoted 5 lines
BOOL_ARG("--no-autoprobe", "-N", "Disable automatic probing of non-blocked devices", no_autoprobe)Or:
BOOL_ARG("--no-autoprobe", "-P", "Disable automatic probing of non-blocked devices", no_autoprobe)I don't see the benefit of a short flag.
It makes reading commands less obvious.I actually would prefer to have a short option available, and I'd really like that short option to be "-A" since it serves as the perfect addition to the "-a" flag to specify devices to probe.
Quoted 6 lines
Based on that, I would look for long options which allow "-A" as the short version for example:
--allowlisted-devs-only
/Bruce
Also if -b or --block-list become a no op with --no-autoprobe. So it should be a warning?
Re: [RFC v2 5/5] eal: configure initial device probing
Quoted 60 lines · Stephen Hemminger
Quoted 57 lines · On Fri, 27 Feb 2026 13:51:48 +0000 Bruce Richardson…
Quoted 43 lines · Thomas Monjalon
26/02/2026 17:50, Robin Jarry:
Quoted 15 lines
David Marchand, Feb 26, 2026 at 17:20:
Quoted 14 lines
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.
[...]
Quoted 8 lines
app/test/test_eal_flags.c test_misc_flags(void) · line 1035
Quoted 2 lines
app/test/test_eal_flags.c +2
-0+const char *const argv29[] = {prgname, prefix, mp_flag, eal_debug_logs, +"--allow-explicitly" };I am not convinced by the option name. What do you think of:
--no-autoprobe
That would match the Linux
sriov_drivers_autoprobesysfs.The name --no-autoprobe is better indeed.
The exact effect of this option is to disable initial probing of devices on all buses (except vdev).
Another name could be --no-initial-probingI think we should add the opposite option as well
to allow changing the default mode later.
For such an option, --autoprobe looks better than --initial-probing.Other opinions?
[...]
Quoted 3 lines
Depending on what option name we settle on, could you add a short flag too? E.g.:
Quoted 9 lines
Quoted 5 lines
BOOL_ARG("--no-autoprobe", "-N", "Disable automatic probing of non-blocked devices", no_autoprobe)Or:
BOOL_ARG("--no-autoprobe", "-P", "Disable automatic probing of non-blocked devices", no_autoprobe)I don't see the benefit of a short flag.
It makes reading commands less obvious.I actually would prefer to have a short option available, and I'd really like that short option to be "-A" since it serves as the perfect addition to the "-a" flag to specify devices to probe.
Quoted 8 lines
Quoted 6 lines
Based on that, I would look for long options which allow "-A" as the short version for example:
--allowlisted-devs-only
/Bruce
Also if -b or --block-list become a no op with --no-autoprobe. So it should be a warning?
Yes, I think a warning about ignored parameter would be appropriate.
/Bruce
RE: [RFC v2 5/5] eal: configure initial device probing
Quoted 85 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 2 March 2026 10.02Quoted 7 lines · Stephen Hemminger
Quoted 4 lines · On Fri, 27 Feb 2026 13:51:48 +0000 Bruce Richardson…
Quoted 3 lines · Thomas Monjalon
26/02/2026 17:50, Robin Jarry:
Quoted 2 lines
David Marchand, Feb 26, 2026 at 17:20:
Quoted 1 line
Some applications use port hotplug as their primary way for
using DPDK
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
resources.
Having a systematic device probing is a problem when not allavailable
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
resources will be used by the application, as such
applications won't set
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
an explicit allow list at startup.
This is the case for OVS on systems with multiple mlx5
devices:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
one device can be used by the kernel while the other(s) are
used by DPDK.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
In such a setup, the kernel used device may get reconfigured
in
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
unexpected ways and trigger issues like the one described by
Kevin
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
not so long ago in bugzilla 1873.
Add an EAL option so that we can change the default behavior
from
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
block-listing to allow-listing.
[...]
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ const char * const argv29[] = {prgname, prefix, mp_flag,
eal_debug_logs,Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
app/test/test_eal_flags.c test_misc_flags(void) · line 1035
Quoted 1 line
app/test/test_eal_flags.c +1
-0+ "--allow-explicitly" };I am not convinced by the option name. What do you think of:
--no-autoprobe
That would match the Linux
sriov_drivers_autoprobesysfs.The name --no-autoprobe is better indeed.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
The exact effect of this option is to disable initial probing of devices on all buses (except vdev).
Another name could be --no-initial-probingI think we should add the opposite option as well to allow changing the default mode later.
For such an option, --autoprobe looks better than --initial-probing.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Other opinions?
[...]
Quoted 1 line
Depending on what option name we settle on, could you add a
short flag
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
too? E.g.:
BOOL_ARG("--no-autoprobe", "-N", "Disable automatic probing of
non-blocked devices",
no_autoprobe)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Or:
BOOL_ARG("--no-autoprobe", "-P", "Disable automatic probing of
non-blocked devices",
no_autoprobe)Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
I don't see the benefit of a short flag.
It makes reading commands less obvious.I actually would prefer to have a short option available, and I'd
really
Quoted 1 line
Quoted 1 line
like that short option to be "-A" since it serves as the perfect
addition
Quoted 3 lines
Quoted 3 lines
to the "-a" flag to specify devices to probe.
Based on that, I would look for long options which allow "-A" as
the short
Quoted 4 lines
Quoted 4 lines
version for example:
--allowlisted-devs-only
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
/Bruce
Also if -b or --block-list become a no op with --no-autoprobe. So it
should be a warning?
Yes, I think a warning about ignored parameter would be appropriate.
/Bruce
I haven't been following this discussion, so I might me completely off here.
IIUC, this option is used for specifying which devices to probe. (And as a side effect disables auto-probing of all devices.)
When naming it, please take a fresh view.
Imagine you are defining this option and an auto-probe option.
The discussion assumes the user is familiar with auto-probe, and expects auto-probe. Don't design based on that.
-Morten
Re: [RFC v2 5/5] eal: configure initial device probing
In reply to Bruce RichardsonQuoted 7 lines · Bruce Richardson
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Or:
BOOL_ARG("--no-autoprobe", "-P", "Disable automatic probing of non-blocked devices", no_autoprobe)I don't see the benefit of a short flag.
It makes reading commands less obvious.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
I actually would prefer to have a short option available, and I'd really like that short option to be "-A" since it serves as the perfect addition to the "-a" flag to specify devices to probe.
Based on that, I would look for long options which allow "-A" as the short version for example:
--allowlisted-devs-only
--allow-only?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
/Bruce
Also if -b or --block-list become a no op with --no-autoprobe. So it should be a warning?
Yes, I think a warning about ignored parameter would be appropriate.
Thomas had the same comment when we talked about the series. However, I would reject the combination rather than warn.
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 · 58 lines
David Marchand 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 | 22 ++---- 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 | 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 | 37 ++++++++++ 31 files changed, 288 insertions(+), 364 deletions(-) -- 2.53.0
RFC 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
RFC 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 | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +6 -16
@@ -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,21 +1411,11 @@ 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) { + ret = drv->remove (dev); +if (ret) +DPAA2_BUS_ERR ("Unable to remove" ); }break ;default :
Signature · 1 line
2.53.0
RFC 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
@@ -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
RFC v3 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 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
@@ -76,7 +76,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: [RFC v3 4/7] drivers: cleanup devargs lookup in bus scan
Quoted 11 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]>
RFC 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.
--- 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
@@ -69,25 +69,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 :
@@ -256,7 +241,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 devargs, or NULL if none found. +*/ +__rte_internal +struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *name); +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors.
Signature · 1 line
2.53.0
Re: [RFC v3 5/7] bus: factorize devargs lookup
Quoted 11 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]>---
Looks generally good. Couple of minor naming suggestions inline below.
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(-)
<snip>
Quoted 51 lines
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 +5
-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. +*
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 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); +
This is a good addition.
Quoted 20 lines
lib/eal/include/bus_driver.h +6
-0/** * 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
lib/eal/include/bus_driver.h struct rte_bus { · line 314
Quoted 10 lines
lib/eal/include/bus_driver.h +10
-0+* to be unregistered. +* @param dev_name +* A device name. +* +* @return +* Pointer to the devargs, or NULL if none found. +*/ +__rte_internal +struct rte_devargs *rte_bus_find_devargs(const struct rte_bus *bus, const char *name); +
The doxygen says the parameter is dev_name, while the prototype only uses name. I'd prefer this to be "dev_name". [I nearly one if the function itself should have an extra "_" and be "find_dev_args", as it's finding the args for a particular device, rather than finding the "devargs" for the bus itself.]
Quoted 6 lines
lib/eal/include/bus_driver.h +0
-0/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors. Signature · 1 line
2.53.0
Re: [RFC v3 5/7] bus: factorize devargs lookup
Quoted 129 lines · Bruce Richardson
Quoted 11 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]>---
Looks generally good. Couple of minor naming suggestions inline below.
Acked-by Bruce Richardson <[email protected]>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(-)<snip>
Quoted 51 lines
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 +5
-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. +* 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 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); +This is a good addition.
Quoted 28 lines
lib/eal/include/bus_driver.h +14
-0/** * 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 devargs, or NULL if none found. +*/ +__rte_internal
Quoted 8 lines
lib/eal/include/bus_driver.h struct rte_bus { · line 314
Quoted 2 lines
lib/eal/include/bus_driver.h +2
-0+struct rte_devargs *rte_bus_find_devargs (const struct rte_bus *bus,const char *name); +The doxygen says the parameter is
dev_name, while the prototype only uses name. I'd prefer this to be "dev_name". [I nearly one if the function itself should have an extra "_" and be "find_dev_args", as it's finding the args for a particular device, rather than finding the "devargs" for the bus itself.]
Good catch.
Err well, on doxygen / prototype misalignment.. documentation generation should fail if it is not aligned.
Strange I did not see this.
Ah.. it is a driver header, so we probably don't generate any doc for this.
Signature · 1 line
David Marchand
RFC 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 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
@@ -69,26 +69,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.
@@ -295,7 +275,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 *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: [RFC v3 6/7] bus: factorize device selection
Quoted 7 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]>---
I was going to suggest that we avoid having a per-bus scan mode, but then I realised after looking that the final patch in this series that that won't work for vdev bus which can't use auto-probing.
Quoted 4 lines
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,
<snip>
Re: [RFC v3 6/7] bus: factorize device selection
Hello Bruce,
Quoted 7 lines · Bruce Richardson
Quoted 5 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.
Quoted 8 lines
Quoted 2 lines
Signed-off-by David Marchand <[email protected]>---
Acked-by Bruce Richardson <[email protected]>I was going to suggest that we avoid having a per-bus scan mode, but then I realised after looking that the final patch in this series that that won't work for vdev bus which can't use auto-probing.
I also think we don't need the per-bus mode.
I don't understand why it was added in the first place.
The vdev bus does not consider the bus scan mode, so the current behavior would not be broken if we removed it.
From a user pov (even before this series), -a/-b are mutually exclusive and --vdev lives in parallel.
I'll see if it is as easy as I think and I have a try for the non RFC series for 26.07.
Signature · 1 line
David Marchand
Re: [RFC v3 6/7] bus: factorize device selection
In reply to David MarchandDavid Marchand, Mar 05, 2026 at 17:45:
Quoted 10 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.Signed-off-by David Marchand <[email protected]>---
Changes since RFC v2:
- changed API to query about a device name and hide the devargs meaning in the common code,
Nice cleanup.
RFC 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
@@ -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: [RFC v3 7/7] eal: configure initial device probing
Quoted 32 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]>---
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,
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(-)
While I really like "-A" as a logical shortcut, I am a little concerned it doesn't seem a shortcut for "--no-auto-probing". However, I don't have a better suggestion so.
Re: [RFC v3 7/7] eal: configure initial device probing
In reply to David MarchandDavid Marchand, Mar 05, 2026 at 17:45:
Quoted 29 lines
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]>---
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),
Quoted 4 lines
Changes since RFC v1:
- changed approach following Bruce suggestion,---
Hey David,
thanks, LGTM.
Re: [RFC v3 0/7] Rework device probing
In reply to David MarchandQuoted 54 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 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 drivers
drivers: cleanup devargs lookup in bus 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 | 69 ++++++++----------- drivers/bus/fslmc/fslmc_vfio.c | 22 ++---- 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 +++----------
Quoted 8 lines
drivers/dma/idxd/idxd_bus.c | 18 +---- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 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 | 37 ++++++++++ 31 files changed, 288 insertions(+), 364 deletions(-)
Recheck-request: github-robot
Signature · 1 line
David Marchand