Signed-off-by: Jan Blunck <jblu...@infradead.org> --- lib/librte_eal/common/eal_common_devargs.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 92c77c30e..205fabb95 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -137,6 +137,14 @@ rte_eal_devargs_parse(const char *dev, struct rte_devargs *da) return 0; } +static const struct rte_bus_conf BUS_CONF_WHITELIST = { + .scan_mode = RTE_BUS_SCAN_WHITELIST, +}; + +static const struct rte_bus_conf BUS_CONF_BLACKLIST = { + .scan_mode = RTE_BUS_SCAN_BLACKLIST, +}; + /* store a whitelist parameter for later parsing */ int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) @@ -144,6 +152,7 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) struct rte_devargs *devargs = NULL; struct rte_bus *bus = NULL; const char *dev = devargs_str; + int ret; /* use calloc instead of rte_zmalloc as it's called early at init */ devargs = calloc(1, sizeof(*devargs)); @@ -154,18 +163,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) goto fail; devargs->type = devtype; bus = devargs->bus; - if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) { - if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { - bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST; - } else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) { - fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n"); - goto fail; - } - } else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) { - if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { - bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST; - } else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) { - fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n"); + if (devtype != RTE_DEVTYPE_VIRTUAL) { + ret = rte_bus_configure(bus, + devtype == RTE_DEVTYPE_WHITELISTED_PCI ? + &BUS_CONF_WHITELIST : &BUS_CONF_BLACKLIST); + if (ret != 0) { + RTE_LOG(ERR, EAL, + "Bus [%s] scan_mode conflicts with devtype: " + "%s\n", bus->name, devargs_str); goto fail; } } -- 2.13.2