Re: [PATCH v2 5/7] bus: factorize devargs lookup

fengchengwen
2026-03-28T03:33:29Z

On 3/26/2026 6:24 PM, David Marchand wrote:
> 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 <david.marchand@redhat.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> Tested-by: Maxime Leroy <maxime@leroys.fr>
> ---

...

> diff --git a/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c
> index 06a3643290..e6963dc18a 100644
> --- a/drivers/bus/uacce/uacce.c
> +++ b/drivers/bus/uacce/uacce.c
> @@ -70,25 +70,10 @@ extern int uacce_bus_logtype;
> #define UACCE_BUS_DEBUG(fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__)
>
>
> -static struct rte_devargs *
> -uacce_devargs_lookup(const char *dev_name)
> -{
> - char name[RTE_UACCE_DEV_PATH_SIZE] = {0};
> - struct rte_devargs *devargs;
> -
> - snprintf(name, sizeof(name), "%s%s", UACCE_DEV_PREFIX, dev_name);

For uacce, application should pass device with prefix uacce, e.g:
dpdk-testpmd -a uacce:hisi_zip-0,queues=2 --file-prefix=feng -- -i

And the scan device is hisi_zip-0, so in match we should combined which is
above snprintf does.

> - 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);
>

...

>
> return retval;
> diff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c
>
> +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;
> +}
> +

...