From: Bruce Richardson <bruce.richardson@intel.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, <techboard@dpdk.org>
Subject: Re: [PATCH] bus/vdev: automatically add eth alias for net drivers
Date: Wed, 19 Oct 2022 14:20:45 +0100 [thread overview]
Message-ID: <Y0/5raKPVsa3Jbhe@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <20221019131118.32394-1-bruce.richardson@intel.com>
On Wed, Oct 19, 2022 at 02:11:18PM +0100, Bruce Richardson wrote:
> For historical reasons, a number of net vdev drivers also add a driver
> alias using the "eth_" prefix. Since this is done on a per-driver basis,
> the use of the alias in inconsistent and is spread across multiple
> files. We can remove the per-driver aliases by just adding the alias
> automatically at the vdev bus level.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> drivers/bus/vdev/vdev.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> index f5b43f1930..bfd7ce60c1 100644
> --- a/drivers/bus/vdev/vdev.c
> +++ b/drivers/bus/vdev/vdev.c
> @@ -54,6 +54,12 @@ static rte_spinlock_t vdev_custom_scan_lock = RTE_SPINLOCK_INITIALIZER;
> void
> rte_vdev_register(struct rte_vdev_driver *driver)
> {
> + /* For net driver vdevs, add an automatic alias using "eth" prefix */
> + if (strncmp(driver->driver.name, "net_", 4) == 0 && driver->driver.alias == NULL) {
> + char *alias = strdup(driver->driver.name);
> + memcpy(alias, "eth_", 4);
> + driver->driver.alias = alias;
> + }
> TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
> }
>
As a self-review comment, I realise this solution has got an issue that it
leaks memory if drivers are constantly being registered or unregistered. I
find it hard to see situations where this can occur, but it is a potential
issue.
A second solution that does not have this problem is to move the aliasing
to EAL, as below:
index fb5d0a293b..37b86914a0 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -226,9 +226,14 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev)
da->name[i] = '\0';
if (bus == NULL) {
bus = rte_bus_find_by_device_name(da->name);
+ if (bus == NULL && strncmp(da->name, "eth_", 4) == 0) {
+ RTE_LOG(INFO, EAL, "failed to parse device \"%s\"...\n", da->name);
+ memcpy(da->name, "net_", 4);
+ RTE_LOG(INFO, EAL, "... trying device \"%s\"\n", da->name);
+ bus = rte_bus_find_by_device_name(da->name);
+ }
if (bus == NULL) {
RTE_LOG(ERR, EAL, "failed to parse device \"%s\"\n",
da->name);
While this doesn't have a memory freeing issue, it's downside is obviously
that we have further abstraction leakage, from the vdev bus for net drivers
all the way to EAL. Again, since the code delta is fairly small, this may
be acceptable, so opinions welcome.
/Bruce
next prev parent reply other threads:[~2022-10-19 13:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 13:34 [PATCH] drivers/net: remove alias for virtual devices Ferruh Yigit
2022-09-21 14:26 ` Thomas Monjalon
2022-09-21 14:43 ` Ferruh Yigit
2022-09-21 14:49 ` Bruce Richardson
2022-10-19 13:13 ` Bruce Richardson
2022-11-06 10:43 ` Andrew Rybchenko
2022-10-19 13:11 ` [PATCH] bus/vdev: automatically add eth alias for net drivers Bruce Richardson
2022-10-19 13:20 ` Bruce Richardson [this message]
2022-10-20 8:23 ` Thomas Monjalon
2022-10-20 8:48 ` Bruce Richardson
2022-10-20 11:51 ` Ferruh Yigit
2022-10-27 7:58 ` David Marchand
2022-10-27 8:35 ` Ferruh Yigit
2023-01-12 11:02 ` Bruce Richardson
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=Y0/5raKPVsa3Jbhe@bricha3-MOBL.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=techboard@dpdk.org \
/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;
as well as URLs for NNTP newsgroup(s).