From: Bruce Richardson <bruce.richardson@intel.com>
To: David Marchand <david.marchand@redhat.com>
Cc: <dev@dpdk.org>, Parav Pandit <parav@nvidia.com>,
Xueming Li <xuemingl@nvidia.com>,
Nipun Gupta <nipun.gupta@amd.com>,
Nikhil Agarwal <nikhil.agarwal@amd.com>,
Hemant Agrawal <hemant.agrawal@nxp.com>,
"Sachin Saxena" <sachin.saxena@nxp.com>,
Chenbo Xia <chenbox@nvidia.com>,
"Tomasz Duszynski" <tduszynski@marvell.com>,
Chengwen Feng <fengchengwen@huawei.com>,
Long Li <longli@microsoft.com>, Wei Hu <weh@microsoft.com>,
Kevin Laatz <kevin.laatz@intel.com>
Subject: Re: [RFC v3 5/7] bus: factorize devargs lookup
Date: Thu, 5 Mar 2026 17:06:11 +0000 [thread overview]
Message-ID: <aam4A98jJsuhgTYG@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20260305164550.2067453-6-david.marchand@redhat.com>
On Thu, Mar 05, 2026 at 05:45:47PM +0100, 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>
> ---
Looks generally good. Couple of minor naming suggestions inline below.
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 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>
> diff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c
> index 0a2311a342..863c7418bb 100644
> --- a/lib/eal/common/eal_common_bus.c
> +++ b/lib/eal/common/eal_common_bus.c
> @@ -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)
> {
> diff --git a/lib/eal/include/bus_driver.h b/lib/eal/include/bus_driver.h
> index 60527b75b6..430906772d 100644
> --- a/lib/eal/include/bus_driver.h
> +++ b/lib/eal/include/bus_driver.h
> @@ -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);
> +
This is a good addition.
> /**
> * 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);
> +
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.]
> /**
> * Helper for Bus registration.
> * The constructor has higher priority than PMD constructors.
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-03-05 17:06 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 11:29 [RFC 1/2] devtools: check packet forwarding in null test David Marchand
2026-02-25 11:29 ` [RFC 2/2] eal: configure initial device probing David Marchand
2026-02-25 12:09 ` Bruce Richardson
2026-02-25 17:53 ` David Marchand
2026-02-26 16:20 ` [RFC v2 0/5] Rework " David Marchand
2026-02-26 16:20 ` [RFC v2 1/5] devtools: check packet forwarding in null test David Marchand
2026-02-26 16:35 ` Bruce Richardson
2026-02-26 16:20 ` [RFC v2 2/5] bus/fslmc: fix bus cleanup David Marchand
2026-02-26 16:20 ` [RFC v2 3/5] drivers/bus: require probe function for NXP drivers David Marchand
2026-02-26 16:24 ` Bruce Richardson
2026-02-26 16:20 ` [RFC v2 4/5] bus: factorize device selection David Marchand
2026-02-26 16:31 ` Bruce Richardson
2026-02-27 14:17 ` David Marchand
2026-02-27 14:33 ` Bruce Richardson
2026-02-26 16:20 ` [RFC v2 5/5] eal: configure initial device probing David Marchand
2026-02-26 16:34 ` Bruce Richardson
2026-02-26 16:50 ` Robin Jarry
2026-02-27 13:43 ` Thomas Monjalon
2026-02-27 13:51 ` Bruce Richardson
2026-02-27 22:10 ` Stephen Hemminger
2026-03-02 9:02 ` Bruce Richardson
2026-03-02 11:08 ` Morten Brørup
2026-03-02 11:13 ` David Marchand
2026-03-05 16:45 ` [RFC v3 0/7] Rework " David Marchand
2026-03-05 16:45 ` [RFC v3 1/7] devtools: check packet forwarding in null test David Marchand
2026-03-05 16:45 ` [RFC v3 2/7] bus/fslmc: fix bus cleanup David Marchand
2026-03-05 16:45 ` [RFC v3 3/7] drivers/bus: require probe function for NXP drivers David Marchand
2026-03-05 16:45 ` [RFC v3 4/7] drivers: cleanup devargs lookup in bus scan David Marchand
2026-03-05 16:56 ` Bruce Richardson
2026-03-05 16:45 ` [RFC v3 5/7] bus: factorize devargs lookup David Marchand
2026-03-05 17:06 ` Bruce Richardson [this message]
2026-03-05 17:10 ` David Marchand
2026-03-05 16:45 ` [RFC v3 6/7] bus: factorize device selection David Marchand
2026-03-05 17:30 ` Bruce Richardson
2026-03-09 9:50 ` David Marchand
2026-03-07 20:59 ` Robin Jarry
2026-03-05 16:45 ` [RFC v3 7/7] eal: configure initial device probing David Marchand
2026-03-05 17:33 ` Bruce Richardson
2026-03-07 21:05 ` Robin Jarry
2026-03-06 8:26 ` [RFC v3 0/7] Rework " David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aam4A98jJsuhgTYG@bricha3-mobl1.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=chenbox@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=hemant.agrawal@nxp.com \
--cc=kevin.laatz@intel.com \
--cc=longli@microsoft.com \
--cc=nikhil.agarwal@amd.com \
--cc=nipun.gupta@amd.com \
--cc=parav@nvidia.com \
--cc=sachin.saxena@nxp.com \
--cc=tduszynski@marvell.com \
--cc=weh@microsoft.com \
--cc=xuemingl@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox