[dpdk-dev,v2,02/42] eal: parse "driver" device argument before probing drivers
Checks
Commit Message
From: Jan Blunck <jblunck@infradead.org>
In some cases the virtual device name should be totally different than
the driver being used for the device. Therefore lets parse the devargs for
the "driver" argument before probing drivers in vdev_probe_all_drivers().
Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
lib/librte_eal/common/eal_common_vdev.c | 51 +++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 5 deletions(-)
Comments
On 4/11/2017 4:44 PM, Gaetan Rivet wrote:
> From: Jan Blunck <jblunck@infradead.org>
>
> In some cases the virtual device name should be totally different than
> the driver being used for the device. Therefore lets parse the devargs for
> the "driver" argument before probing drivers in vdev_probe_all_drivers().
Hi Gaetan, Jan,
I have caught this while checking something else.
This patch adds an alternative way for virtual devices to get probed
when device name is not proper.
This probing can be done by having "driver=<driver_name>" in device
argument (not in name).
Do we really need this alternative method, as far as I can see only user
of this is a unit test for bonding?
This method is a little hidden/undocumented and a hack solution, I think
it is better and easier to fix virtual device names in unit test and
remove this, what do you think?
Thanks,
ferruh
>
> Signed-off-by: Jan Blunck <jblunck@infradead.org>
<...>
On 5/10/2017 3:34 AM, Ferruh Yigit wrote:
> On 4/11/2017 4:44 PM, Gaetan Rivet wrote:
>> From: Jan Blunck <jblunck@infradead.org>
>>
>> In some cases the virtual device name should be totally different than
>> the driver being used for the device. Therefore lets parse the devargs for
>> the "driver" argument before probing drivers in vdev_probe_all_drivers().
>
> Hi Gaetan, Jan,
>
> I have caught this while checking something else.
>
> This patch adds an alternative way for virtual devices to get probed
> when device name is not proper.
>
> This probing can be done by having "driver=<driver_name>" in device
> argument (not in name).
>
> Do we really need this alternative method, as far as I can see only user
> of this is a unit test for bonding?
>
> This method is a little hidden/undocumented and a hack solution, I think
> it is better and easier to fix virtual device names in unit test and
> remove this, what do you think?
I am suggesting: http://dpdk.org/dev/patchwork/patch/24196/
>
> Thanks,
> ferruh
>
>>
>> Signed-off-by: Jan Blunck <jblunck@infradead.org>
> <...>
>
@@ -72,12 +72,51 @@ rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
TAILQ_REMOVE(&vdev_driver_list, driver, next);
}
+/*
+ * Parse "driver" devargs without adding a dependency on rte_kvargs.h
+ */
+static char *parse_driver_arg(const char *args)
+{
+ const char *c;
+ char *str;
+
+ if (!args || args[0] == '\0')
+ return NULL;
+
+ c = args;
+
+ do {
+ if (strncmp(c, "driver=", 7) == 0) {
+ c += 7;
+ break;
+ }
+
+ c = strchr(c, ',');
+ if (c)
+ c++;
+ } while (c);
+
+ if (c)
+ str = strdup(c);
+ else
+ str = NULL;
+
+ return str;
+}
+
static int
vdev_probe_all_drivers(struct rte_vdev_device *dev)
{
- const char *name = rte_vdev_device_name(dev);
+ const char *name;
+ char *drv_name;
struct rte_vdev_driver *driver;
- int ret;
+ int ret = 1;
+
+ drv_name = parse_driver_arg(rte_vdev_device_args(dev));
+ name = drv_name ? drv_name : rte_vdev_device_name(dev);
+
+ RTE_LOG(DEBUG, EAL, "Search driver %s to probe device %s\n", name,
+ rte_vdev_device_name(dev));
TAILQ_FOREACH(driver, &vdev_driver_list, next) {
/*
@@ -92,7 +131,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver->probe(dev);
if (ret)
dev->device.driver = NULL;
- return ret;
+ goto out;
}
}
@@ -105,11 +144,13 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver->probe(dev);
if (ret)
dev->device.driver = NULL;
- return ret;
+ break;
}
}
- return 1;
+out:
+ free(drv_name);
+ return ret;
}
static struct rte_vdev_device *