eal: simplify parameters of hotplug functions
Subsystems (2)
RFC 1/1 eal: simplify parameters of hotplug functions
All informations about a device to probe can be grouped in a common string, which is what we usually call devargs. That's why the bus name and device name can be removed from rte_eal_hotplug_add().
When removing a device, we already know its rte_device handle which can be directly passed as parameter of rte_eal_hotplug_remove(). If the rte_device is not known, it can be retrieved from the devargs, thanks to RTE_DEV_FOREACH().
---
This patch contains only the change in the API as RFC.
This idea was presented at Dublin during the "hotplug talk".
--- lib/librte_eal/common/include/rte_dev.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
lib/librte_eal/common/include/rte_dev.h +5 -14
@@ -194,18 +194,12 @@ int rte_eal_dev_detach(struct rte_device *dev);* * Hotplug add a given device to a specific bus. * -* @param busname -* The bus name the device is added to. -* @param devname -* The device name. Based on this device name, eal will identify a driver -* capable of handling it and pass it to the driver probing function. * @param devargs -* Device arguments to be passed to the driver. +* Device arguments including bus, class and driver properties * @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs); +int __rte_experimental rte_eal_hotplug_add(const char *devargs);/** * @warning
@@ -213,15 +207,12 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn* * Hotplug remove a given device from a specific bus. * -* @param busname -* The bus name the device is removed from. -* @param devname -* The device name being removed. +* @param dev +* Data structure of the device to remove * @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_remove(const char *busname, -const char *devname); +int __rte_experimental rte_eal_hotplug_remove(struct rte_device *dev);/** * Device comparison function.
Signature · 1 line
2.18.0
v2 cover eal: simplify devargs and hotplug functions
This is a follow-up of an idea presented at Dublin during the "hotplug talk".
Instead of changing the existing hotplug functions, as in the RFC, some new experimental functions are added.
The old functions lose their experimental status in order to provide a non-experimental replacement for deprecated attach/detach functions.
It has been discussed briefly in the technical board meeting today.
Thomas Monjalon (4):
devargs: remove deprecated functions
devargs: simplify parameters of removal function
eal: remove experimental flag of hotplug functions
eal: simplify parameters of hotplug functions
drivers/bus/ifpga/ifpga_bus.c | 5 +- drivers/bus/vdev/vdev.c | 8 +- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 85 +++++++++++++-------- lib/librte_eal/common/eal_common_devargs.c | 38 +-------- lib/librte_eal/common/include/rte_dev.h | 35 +++++++-- lib/librte_eal/common/include/rte_devargs.h | 81 +------------------- lib/librte_eal/rte_eal_version.map | 10 +-- 9 files changed, 96 insertions(+), 172 deletions(-)
Signature · 1 line
2.19.0
PATCH v2 1/4 devargs: remove deprecated functions
rte_eal_parse_devargs_str() does not support parsing the bus name at the start of devargs. So it has been renamed and deprecated.
rte_eal_devargs_add(), rte_eal_devargs_type_count() and rte_eal_devargs_dump() were declared deprecated and had their implementation body renamed.
All these functions were deprecated in release 18.05.
---
The library version is not updated because it should be done in earlier patch https://patches.dpdk.org/patch/43903/
--- lib/librte_eal/common/eal_common_devargs.c | 30 --------- lib/librte_eal/common/include/rte_devargs.h | 71 --------------------- lib/librte_eal/rte_eal_version.map | 4 -- 3 files changed, 105 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +0 -30
@@ -31,36 +31,6 @@ TAILQ_HEAD(rte_devargs_list, rte_devargs);struct rte_devargs_list devargs_list =TAILQ_HEAD_INITIALIZER (devargs_list); -int -rte_eal_parse_devargs_str (const char *devargs_str, -char **drvname,char **drvargs) -{ -char *sep; - -if ((devargs_str) ==NULL || (drvname) ==NULL || (drvargs ==NULL )) -return -1 ; - - *drvname =strdup (devargs_str); -if (*drvname ==NULL ) -return -1 ; - -/* set the first ',' to '\0' to split name and arguments */ - sep =strchr (*drvname,',' ); -if (sep !=NULL ) { - sep[0 ] ='\0' ; - *drvargs =strdup (sep +1 ); - }else { - *drvargs =strdup ("" ); - } - -if (*drvargs ==NULL ) { -free (*drvname); - *drvname =NULL ; -return -1 ; - } -return 0 ; -} -static size_t devargs_layer_count (const char *s) {
lib/librte_eal/common/include/rte_devargs.h +0 -71
95 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +0 -4
@@ -19,9 +19,6 @@ DPDK_2.0 { rte_dump_tailq; rte_eal_alarm_cancel; rte_eal_alarm_set; - rte_eal_devargs_add; - rte_eal_devargs_dump; - rte_eal_devargs_type_count; rte_eal_get_configuration; rte_eal_get_lcore_state; rte_eal_get_physmem_size;
@@ -32,7 +29,6 @@ DPDK_2.0 { rte_eal_lcore_role; rte_eal_mp_remote_launch; rte_eal_mp_wait_lcore; - rte_eal_parse_devargs_str; rte_eal_process_type; rte_eal_remote_launch; rte_eal_tailq_lookup;
Signature · 1 line
2.19.0
PATCH v2 2/4 devargs: simplify parameters of removal function
In reply to Thomas MonjalonThe function rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.
--- drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 8 ++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 5 files changed, 12 insertions(+), 23 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +1 -4
@@ -363,7 +363,6 @@ static int ifpga_unplug(struct rte_device *dev) {struct rte_afu_device *afu_dev =NULL ; -struct rte_devargs *devargs =NULL ;int ret;if (dev ==NULL )
@@ -373,15 +372,13 @@ ifpga_unplug(struct rte_device *dev)if (!afu_dev)return -ENOENT ; - devargs = dev->devargs; - ret =ifpga_remove_driver (afu_dev);if (ret)return ret;TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->devargs);free (afu_dev);return 0 ;
drivers/bus/vdev/vdev.c +2 -6
@@ -248,7 +248,6 @@ int rte_vdev_init(const char *name, const char *args) { struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock);
@@ -259,9 +258,8 @@ rte_vdev_init(const char *name, const char *args)if (ret >0 )VDEV_LOG (ERR ,"no driver found for %s" , name);/* If fails, remove it from vdev list */ - devargs = dev->device.devargs;TAILQ_REMOVE (&vdev_device_list, dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); } }
@@ -289,7 +287,6 @@ int rte_vdev_uninit(const char *name) {struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;if (name ==NULL )
@@ -308,8 +305,7 @@ rte_vdev_uninit(const char *name) goto unlock;TAILQ_REMOVE (&vdev_device_list, dev, next); - devargs = dev->device.devargs; -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); unlock:
lib/librte_eal/common/eal_common_dev.c +2 -2
@@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn 0 ; err_devarg: -if (rte_devargs_remove (busname, devname)) { +if (rte_devargs_remove (da)) {free (da->args);free (da); }
@@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)if (ret)RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , dev->name); -rte_devargs_remove (busname, devname); +rte_devargs_remove (dev->devargs);return ret; }
lib/librte_eal/common/eal_common_devargs.c +4 -4
@@ -266,7 +266,7 @@ rte_devargs_insert(struct rte_devargs *da) {int ret; - ret =rte_devargs_remove (da->bus->name, da->name); + ret =rte_devargs_remove (da);if (ret <0 )return ret;TAILQ_INSERT_TAIL (&devargs_list, da, next);
@@ -312,14 +312,14 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) } int __rte_experimental -rte_devargs_remove (const char *busname,const char *devname) +rte_devargs_remove (struct rte_devargs *devargs) {struct rte_devargs *d;void *tmp; TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { -if (strcmp (d->bus->name, busname) ==0 && -strcmp (d->name, devname) ==0 ) { +if (strcmp (d->bus->name, devargs->bus->name) ==0 && +strcmp (d->name, devargs->name) ==0 ) {TAILQ_REMOVE (&devargs_list, d, next);free (d->args);free (d);
lib/librte_eal/common/include/rte_devargs.h +3 -7
@@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* Its resources are freed. * If the devargs cannot be found, nothing happens. * -* @param busname -* bus name of the devargs to remove. -* -* @param devname -* device name of the devargs to remove. +* @param devargs +* The instance or a copy of devargs to remove. * * @return * 0 on success.
@@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* >0 if the devargs was not within the user device list. */ __rte_experimental -int rte_devargs_remove(const char *busname, -const char *devname); +int rte_devargs_remove(struct rte_devargs *devargs);/** * Count the number of user devices of a specified type
Signature · 1 line
2.19.0
Re: [PATCH v2 2/4] devargs: simplify parameters of removal function
Quoted 102 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, September 27, 2018 12:48 AM
To: [email protected]
Cc: [email protected]; Ophir Munk <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 2/4] devargs: simplify parameters of removal functionThe function
rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name. It is simpler and may allow a different devargs matching in future.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 8 ++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 5 files changed, 12 insertions(+), 23 deletions(-)drivers/bus/ifpga/ifpga_bus.c +1
-4@@ -363,7 +363,6 @@ static int ifpga_unplug(struct rte_device *dev) {struct rte_afu_device *afu_dev =NULL ; -struct rte_devargs *devargs =NULL ;int ret;if (dev ==NULL )@@ -373,15 +372,13 @@ ifpga_unplug(struct rte_device *dev)if (!afu_dev)return -ENOENT ; - devargs = dev->devargs; - ret =ifpga_remove_driver (afu_dev);if (ret)return ret;TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->devargs);free (afu_dev);return 0 ;drivers/bus/vdev/vdev.c index renamed from drivers/bus/vdev/vdev.c +0
-0
69dee89a8..390c2ce70100644drivers/bus/vdev/vdev.c +1
-3@@ -248,7 +248,6 @@ int rte_vdev_init(const char *name, const char *args) { struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock);@@ -259,9 +258,8 @@ rte_vdev_init(const char *name, const char *args)if (ret >0 )VDEV_LOG (ERR ,"no driver found for %s" , name);/* If fails, remove it from vdev list */ - devargs = dev->device.devargs;TAILQ_REMOVE (&vdev_device_list, dev, next); -rte_devargs_remove (devargs->bus->name, devargs- >name); +rte_devargs_remove (dev->device.devargs);free (dev);drivers/bus/vdev/vdev.c +1
-3} }@@ -289,7 +287,6 @@ int rte_vdev_uninit(const char *name) {struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;if (name ==NULL )@@ -308,8 +305,7 @@ rte_vdev_uninit(const char *name) goto unlock;TAILQ_REMOVE (&vdev_device_list, dev, next); - devargs = dev->device.devargs; -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); unlock:lib/librte_eal/common/eal_common_dev.c +0
-0@@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(constchar *busname, const char *devn
lib/librte_eal/common/eal_common_dev.c int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn · line 189
Quoted 5 lines
lib/librte_eal/common/eal_common_dev.c +1
-1return 0 ; err_devarg: -if (rte_devargs_remove (busname, devname)) { +if (rte_devargs_remove (da)) {
Can you please explain why calling with 'da' parameter (which may have different internal fields of busname and devname than the explicit busname and devname parameters) - is correct?
lib/librte_eal/common/eal_common_dev.c rte_eal_hotplug_remove(const char *busname, · line 232
Quoted 11 lines
lib/librte_eal/common/eal_common_dev.c +1
-1free (da->args);free (da); }@@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname) if (ret) RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", dev->name); -rte_devargs_remove (busname ,devname ); +rte_devargs_remove (dev->devargs);
Can you please explain why calling with 'dev->devargs' parameter (which may have different internal fields of busname and devname than the explicit busname and devname parameters) - is correct?
Quoted 66 lines
lib/librte_eal/common/eal_common_dev.c +0
-0return ret;}
lib/librte_eal/common/eal_common_devargs.c +1
-1@@ -266,7 +266,7 @@ rte_devargs_insert(struct rte_devargs *da) {int ret; - ret =rte_devargs_remove (da->bus->name, da->name); + ret =rte_devargs_remove (da);if (ret <0 )return ret; TAILQ_INSERT_TAIL(&devargs_list, da, next); @@ -312,14 +312,14 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) }int
__rte_experimentallib/librte_eal/common/eal_common_devargs.c +3
-3-rte_devargs_remove(const char *busname, const char *devname) +rte_devargs_remove(struct rte_devargs *devargs) {struct rte_devargs *d;void *tmp; TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { -if (strcmp (d->bus->name, busname) ==0 && -strcmp (d->name, devname) ==0 ) { +if (strcmp (d->bus->name, devargs->bus->name) ==0 && +strcmp (d->name, devargs->name) ==0 ) {TAILQ_REMOVE (&devargs_list, d, next);free (d->args);free (d);lib/librte_eal/common/include/rte_devargs.h +2
-5@@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str); * Its resources are freed. * If the devargs cannot be found, nothing happens. * - * @param busname - * bus name of the devargs to remove. - * - * @param devname - * device name of the devargs to remove. + * @param devargs + * The instance or a copy of devargs to remove. * * @return* 0 on success.
lib/librte_eal/common/include/rte_devargs.h +1
-2@@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype,const char *devargs_str); * >0 if the devargs was not within the user device list. */ __rte_experimental -int rte_devargs_remove(const char *busname, -const char *devname); +int rte_devargs_remove(struct rte_devargs *devargs);/** * Count the number of user devices of a specified type
--
2.19.0
Re: [PATCH v2 2/4] devargs: simplify parameters of removal function
Hi,
27/09/2018 10:24, Ophir Munk:
Quoted 5 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 4 lines
The function
rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name. It is simpler and may allow a different devargs matching in future.
[...]
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/eal_common_dev.c +0
-0@@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(constchar *busname, const char *devn
return 0;
Quoted 7 lines
lib/librte_eal/common/eal_common_dev.c int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn · line 189
Quoted 3 lines
err_devarg:lib/librte_eal/common/eal_common_dev.c +1
-1-if (rte_devargs_remove (busname, devname)) { +if (rte_devargs_remove (da)) {Can you please explain why calling with 'da' parameter (which may have different internal fields of busname and devname than the explicit busname and devname parameters) - is correct?
Before devargs is parsed and inserted in the global list, devargs values are NULL, so nothing is found (as before this patch). rte_devargs_remove(da) will have no effect and will return 1, so the devargs will be freed by code in the if block.
When devargs is inserted in the list, it will have the values of busname and devname, so it is the same as before this patch.
However, there may be an issue dereferencing devargs->bus->name when devargs is not parsed. I must add this code in rte_devargs_remove:
if (devargs->bus == NULL)
return 1;[...]
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/common/eal_common_dev.c +0
-0@@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname) if (ret) RTE_LOG(ERR, EAL, "Driver cannot detach the device
Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c rte_eal_hotplug_remove(const char *busname, const char *devname) · line 230
Quoted 4 lines
lib/librte_eal/common/eal_common_dev.c +1
-1(%s)\n", dev->name); -rte_devargs_remove (busname, devname); +rte_devargs_remove (dev->devargs);Can you please explain why calling with '
dev->devargs' parameter (which may have different internal fields of busname and devname than the explicit busname and devname parameters) - is correct?
The device is found by checking the busname and devname. I don't see how the devargs values may be different.
PATCH v2 3/4 eal: remove experimental flag of hotplug functions
In reply to Thomas MonjalonThese functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 13 +++---------- lib/librte_eal/rte_eal_version.map | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-)
lib/librte_eal/common/eal_common_dev.c +4 -3
@@ -127,8 +127,9 @@ int rte_eal_dev_detach(struct rte_device *dev)return ret; } -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs) +int +rte_eal_hotplug_add (const char *busname,const char *devname, +const char *devargs) {struct rte_bus *bus;struct rte_device *dev;
@@ -193,7 +194,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn ret; } -int __rte_experimental +int rte_eal_hotplug_remove (const char *busname,const char *devname) {struct rte_bus *bus;
lib/librte_eal/common/include/rte_dev.h +3 -10
@@ -189,9 +189,6 @@ __rte_deprecatedint rte_eal_dev_detach (struct rte_device *dev);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug add a given device to a specific bus. * * @param busname
@@ -204,13 +201,10 @@ int rte_eal_dev_detach(struct rte_device *dev);* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs); +int rte_eal_hotplug_add (const char *busname,const char *devname, +const char *devargs);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug remove a given device from a specific bus. * * @param busname
@@ -220,8 +214,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_remove(const char *busname, -const char *devname); +int rte_eal_hotplug_remove (const char *busname,const char *devname);/** * Device comparison function.
lib/librte_eal/rte_eal_version.map +2 -2
@@ -261,6 +261,8 @@ DPDK_18.08 { DPDK_18.11 { global: + rte_eal_hotplug_add; + rte_eal_hotplug_remove; rte_strscpy; } DPDK_18.08;
@@ -288,8 +290,6 @@ EXPERIMENTAL { rte_devargs_remove; rte_devargs_type_count; rte_eal_cleanup; - rte_eal_hotplug_add; - rte_eal_hotplug_remove; rte_fbarray_attach; rte_fbarray_destroy; rte_fbarray_detach;
Signature · 1 line
2.19.0
PATCH v2 4/4 eal: simplify parameters of hotplug functions
In reply to Thomas MonjalonAll information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed from rte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.
When removing a device, we already know its rte_device handle which can be directly passed as parameter of rte_eal_hotplug_remove(). If the rte_device is not known, it can be retrieved with the devargs, by iterating in the device list (future RTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.
--- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 76 ++++++++++++++++--------- lib/librte_eal/common/include/rte_dev.h | 30 +++++++++- lib/librte_eal/rte_eal_version.map | 2 + 5 files changed, 80 insertions(+), 34 deletions(-)
drivers/net/failsafe/failsafe_eal.c +1 -2
@@ -144,8 +144,7 @@ fs_bus_uninit(struct rte_eth_dev *dev)int ret =0 ; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { - sdev_ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + sdev_ret =rte_dev_remove (sdev->dev);if (sdev_ret) {ERROR ("Failed to remove requested device %s (err: %d)" , sdev->dev->name, sdev_ret);
drivers/net/failsafe/failsafe_ether.c +1 -2
@@ -265,8 +265,7 @@ fs_dev_remove(struct sub_device *sdev) sdev->state =DEV_PROBED ;/* fallthrough */ case DEV_PROBED : - ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + ret =rte_dev_remove (sdev->dev);if (ret) {ERROR ("Bus detach failed for sub_device %u" ,SUB_ID (sdev));
lib/librte_eal/common/eal_common_dev.c +48 -28
133 lines not on this page · raw message
lib/librte_eal/common/include/rte_dev.h +28 -2
@@ -196,13 +196,26 @@ int rte_eal_dev_detach(struct rte_device *dev);* @param devname * The device name. Based on this device name, eal will identify a driver * capable of handling it and pass it to the driver probing function. -* @param devargs +* @param drvargs * Device arguments to be passed to the driver. * @return * 0 on success, negative on error. */ int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs); +const char *drvargs); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Add matching devices. +* +* @param devargs +* Device arguments including bus, class and driver properties. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_probe(const char *devargs);/** * Hotplug remove a given device from a specific bus.
@@ -216,6 +229,19 @@ int rte_eal_hotplug_add(const char *busname, const char *devname,*/ int rte_eal_hotplug_remove (const char *busname,const char *devname); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Remove one device. +* +* @param dev +* Data structure of the device to remove. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_remove(struct rte_device *dev); +/** * Device comparison function. *
lib/librte_eal/rte_eal_version.map +2 -0
@@ -281,6 +281,8 @@ EXPERIMENTAL { rte_dev_event_monitor_stop; rte_dev_iterator_init; rte_dev_iterator_next; + rte_dev_probe; + rte_dev_remove; rte_devargs_add; rte_devargs_dump; rte_devargs_insert;
Signature · 1 line
2.19.0
v3 cover eal: simplify devargs and hotplug functions
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
Instead of changing the existing hotplug functions, as in the RFC, some new experimental functions are added.
The old functions lose their experimental status in order to provide a non-experimental replacement for deprecated attach/detach functions.
It has been discussed briefly in the technical board meeting this week.
Change in v3:
- fix null dereferencing in error path (patch 2)
Thomas Monjalon (4):
devargs: remove deprecated functions
devargs: simplify parameters of removal function
eal: remove experimental flag of hotplug functions
eal: simplify parameters of hotplug functions
drivers/bus/ifpga/ifpga_bus.c | 5 +- drivers/bus/vdev/vdev.c | 8 +- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 85 +++++++++++++-------- lib/librte_eal/common/eal_common_devargs.c | 41 ++-------- lib/librte_eal/common/include/rte_dev.h | 35 +++++++-- lib/librte_eal/common/include/rte_devargs.h | 81 +------------------- lib/librte_eal/rte_eal_version.map | 10 +-- 9 files changed, 99 insertions(+), 172 deletions(-)
Signature · 1 line
2.19.0
PATCH v3 1/4 devargs: remove deprecated functions
rte_eal_parse_devargs_str() does not support parsing the bus name at the start of devargs. So it has been renamed and deprecated.
rte_eal_devargs_add(), rte_eal_devargs_type_count() and rte_eal_devargs_dump() were declared deprecated and had their implementation body renamed.
All these functions were deprecated in release 18.05.
---
The library version is not updated because it should be done in earlier patch https://patches.dpdk.org/patch/43903/
--- lib/librte_eal/common/eal_common_devargs.c | 30 --------- lib/librte_eal/common/include/rte_devargs.h | 71 --------------------- lib/librte_eal/rte_eal_version.map | 4 -- 3 files changed, 105 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +0 -30
@@ -31,36 +31,6 @@ TAILQ_HEAD(rte_devargs_list, rte_devargs);struct rte_devargs_list devargs_list =TAILQ_HEAD_INITIALIZER (devargs_list); -int -rte_eal_parse_devargs_str (const char *devargs_str, -char **drvname,char **drvargs) -{ -char *sep; - -if ((devargs_str) ==NULL || (drvname) ==NULL || (drvargs ==NULL )) -return -1 ; - - *drvname =strdup (devargs_str); -if (*drvname ==NULL ) -return -1 ; - -/* set the first ',' to '\0' to split name and arguments */ - sep =strchr (*drvname,',' ); -if (sep !=NULL ) { - sep[0 ] ='\0' ; - *drvargs =strdup (sep +1 ); - }else { - *drvargs =strdup ("" ); - } - -if (*drvargs ==NULL ) { -free (*drvname); - *drvname =NULL ; -return -1 ; - } -return 0 ; -} -static size_t devargs_layer_count (const char *s) {
lib/librte_eal/common/include/rte_devargs.h +0 -71
95 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +0 -4
@@ -19,9 +19,6 @@ DPDK_2.0 { rte_dump_tailq; rte_eal_alarm_cancel; rte_eal_alarm_set; - rte_eal_devargs_add; - rte_eal_devargs_dump; - rte_eal_devargs_type_count; rte_eal_get_configuration; rte_eal_get_lcore_state; rte_eal_get_physmem_size;
@@ -32,7 +29,6 @@ DPDK_2.0 { rte_eal_lcore_role; rte_eal_mp_remote_launch; rte_eal_mp_wait_lcore; - rte_eal_parse_devargs_str; rte_eal_process_type; rte_eal_remote_launch; rte_eal_tailq_lookup;
Signature · 1 line
2.19.0
Re: [PATCH v3 1/4] devargs: remove deprecated functions
Quoted 10 lines · Thomas Monjalon
rte_eal_parse_devargs_str()does not support parsing the bus name at the start of devargs. So it has been renamed and deprecated.
rte_eal_devargs_add(),rte_eal_devargs_type_count()andrte_eal_devargs_dump()were declared deprecated and had their implementation body renamed.All these functions were deprecated in release 18.05.
Signed-off-by Thomas Monjalon <[email protected]>
I would say that it is more fair to say that changes related to rte_eal_devargs_add(), rte_eal_devargs_type_count() and rte_eal_devargs_dump() fixes b65ecf19 since the changeset simply removes these functions. May be the ideal solution is to add changeset which adds these deprecated functions and simply calls replacement and remove in the next changeset. But it is too many efforts for nothing, so good to go as is.
Should it be mentioned in release notes (API removal)?
Re: [PATCH v3 1/4] devargs: remove deprecated functions
01/10/2018 13:24, Andrew Rybchenko:
Quoted 14 lines · Thomas Monjalon
Quoted 10 lines
rte_eal_parse_devargs_str()does not support parsing the bus name at the start of devargs. So it has been renamed and deprecated.
rte_eal_devargs_add(),rte_eal_devargs_type_count()andrte_eal_devargs_dump()were declared deprecated and had their implementation body renamed.All these functions were deprecated in release 18.05.
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Quoted 7 lines
I would say that it is more fair to say that changes related to
rte_eal_devargs_add(),rte_eal_devargs_type_count()andrte_eal_devargs_dump()fixesb65ecf19since the changeset simply removes these functions. May be the ideal solution is to add changeset which adds these deprecated functions and simply calls replacement and remove in the next changeset. But it is too many efforts for nothing, so good to go as is.
Yes, not worth the effort.
Quoted 1 line
Should it be mentioned in release notes (API removal)?
Yes, you're right, will add a note in v4.
Thanks
PATCH v3 2/4 devargs: simplify parameters of removal function
In reply to Thomas MonjalonThe function rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.
--- drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 11 +++++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 5 files changed, 15 insertions(+), 23 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +1 -4
@@ -361,7 +361,6 @@ static int ifpga_unplug(struct rte_device *dev) {struct rte_afu_device *afu_dev =NULL ; -struct rte_devargs *devargs =NULL ;int ret;if (dev ==NULL )
@@ -371,15 +370,13 @@ ifpga_unplug(struct rte_device *dev)if (!afu_dev)return -ENOENT ; - devargs = dev->devargs; - ret =ifpga_remove_driver (afu_dev);if (ret)return ret;TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->devargs);free (afu_dev);return 0 ;
drivers/bus/vdev/vdev.c +2 -6
@@ -248,7 +248,6 @@ int rte_vdev_init(const char *name, const char *args) { struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock);
@@ -259,9 +258,8 @@ rte_vdev_init(const char *name, const char *args)if (ret >0 )VDEV_LOG (ERR ,"no driver found for %s" , name);/* If fails, remove it from vdev list */ - devargs = dev->device.devargs;TAILQ_REMOVE (&vdev_device_list, dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); } }
@@ -289,7 +287,6 @@ int rte_vdev_uninit(const char *name) {struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;if (name ==NULL )
@@ -308,8 +305,7 @@ rte_vdev_uninit(const char *name) goto unlock;TAILQ_REMOVE (&vdev_device_list, dev, next); - devargs = dev->device.devargs; -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); unlock:
lib/librte_eal/common/eal_common_dev.c +2 -2
@@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn 0 ; err_devarg: -if (rte_devargs_remove (busname, devname)) { +if (rte_devargs_remove (da)) {free (da->args);free (da); }
@@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)if (ret)RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , dev->name); -rte_devargs_remove (busname, devname); +rte_devargs_remove (dev->devargs);return ret; }
lib/librte_eal/common/eal_common_devargs.c +7 -4
@@ -266,7 +266,7 @@ rte_devargs_insert(struct rte_devargs *da) {int ret; - ret =rte_devargs_remove (da->bus->name, da->name); + ret =rte_devargs_remove (da);if (ret <0 )return ret;TAILQ_INSERT_TAIL (&devargs_list, da, next);
@@ -312,14 +312,17 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) } int __rte_experimental -rte_devargs_remove (const char *busname,const char *devname) +rte_devargs_remove (struct rte_devargs *devargs) {struct rte_devargs *d;void *tmp; +if (devargs->bus ==NULL ) +return -1 ; + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { -if (strcmp (d->bus->name, busname) ==0 && -strcmp (d->name, devname) ==0 ) { +if (strcmp (d->bus->name, devargs->bus->name) ==0 && +strcmp (d->name, devargs->name) ==0 ) {TAILQ_REMOVE (&devargs_list, d, next);free (d->args);free (d);
lib/librte_eal/common/include/rte_devargs.h +3 -7
@@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* Its resources are freed. * If the devargs cannot be found, nothing happens. * -* @param busname -* bus name of the devargs to remove. -* -* @param devname -* device name of the devargs to remove. +* @param devargs +* The instance or a copy of devargs to remove. * * @return * 0 on success.
@@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* >0 if the devargs was not within the user device list. */ __rte_experimental -int rte_devargs_remove(const char *busname, -const char *devname); +int rte_devargs_remove(struct rte_devargs *devargs);/** * Count the number of user devices of a specified type
Signature · 1 line
2.19.0
Re: [PATCH v3 2/4] devargs: simplify parameters of removal function
Quoted 7 lines · Thomas Monjalon
The function
rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.Signed-off-by Thomas Monjalon <[email protected]>
What about release notes? It is API change, yes, experimental, but still.
Re: [PATCH v3 2/4] devargs: simplify parameters of removal function
01/10/2018 13:25, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The function
rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.
Quoted 5 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>What about release notes? It is API change, yes, experimental, but still.
Yes, you're right.
Will fix in v4, thanks.
PATCH v3 3/4 eal: remove experimental flag of hotplug functions
In reply to Thomas MonjalonThese functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 11 ++--------- lib/librte_eal/rte_eal_version.map | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-)
lib/librte_eal/common/eal_common_dev.c +4 -3
@@ -127,8 +127,9 @@ int rte_eal_dev_detach(struct rte_device *dev)return ret; } -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs) +int +rte_eal_hotplug_add (const char *busname,const char *devname, +const char *devargs) {struct rte_bus *bus;struct rte_device *dev;
@@ -193,7 +194,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn ret; } -int __rte_experimental +int rte_eal_hotplug_remove (const char *busname,const char *devname) {struct rte_bus *bus;
lib/librte_eal/common/include/rte_dev.h +2 -9
@@ -189,9 +189,6 @@ __rte_deprecatedint rte_eal_dev_detach (struct rte_device *dev);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug add a given device to a specific bus. * * @param busname
@@ -204,13 +201,10 @@ int rte_eal_dev_detach(struct rte_device *dev);* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, +int rte_eal_hotplug_add (const char *busname,const char *devname,const char *devargs);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug remove a given device from a specific bus. * * @param busname
@@ -220,8 +214,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_remove(const char *busname, -const char *devname); +int rte_eal_hotplug_remove (const char *busname,const char *devname);/** * Device comparison function.
lib/librte_eal/rte_eal_version.map +2 -2
@@ -261,6 +261,8 @@ DPDK_18.08 { DPDK_18.11 { global: + rte_eal_hotplug_add; + rte_eal_hotplug_remove; rte_strscpy; } DPDK_18.08;
@@ -288,8 +290,6 @@ EXPERIMENTAL { rte_devargs_remove; rte_devargs_type_count; rte_eal_cleanup; - rte_eal_hotplug_add; - rte_eal_hotplug_remove; rte_fbarray_attach; rte_fbarray_destroy; rte_fbarray_detach;
Signature · 1 line
2.19.0
Re: [PATCH v3 3/4] eal: remove experimental flag of hotplug functions
Quoted 7 lines · Thomas Monjalon
These functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
Signed-off-by Thomas Monjalon <[email protected]>
Should it be mentioned in release notes?
Re: [PATCH v3 3/4] eal: remove experimental flag of hotplug functions
01/10/2018 13:26, Andrew Rybchenko:
Quoted 12 lines · Thomas Monjalon
Quoted 7 lines
These functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>Should it be mentioned in release notes?
There is no dedicated section for functions becoming "stable". I am afraid it may become too much administrative if we want to note all functions moving from experimental.
Re: [PATCH v3 3/4] eal: remove experimental flag of hotplug functions
In reply to Thomas MonjalonQuoted 11 lines · Thomas Monjalon
These functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 11 ++--------- lib/librte_eal/rte_eal_version.map | 4 ++--
Can remove "-DALLOW_EXPERIMENTAL_API" (or "allow_experimental_apis = true" for meson) from drivers/raw/ifpga_rawdev when these APIs are not experimental anymore. For reference: https://patches.dpdk.org/patch/45836/
It is easy to know when to add "-DALLOW_EXPERIMENTAL_API" but it is hard to know when to remove one, some helper should be good there.
Re: [PATCH v3 3/4] eal: remove experimental flag of hotplug functions
02/10/2018 12:28, Ferruh Yigit:
Quoted 13 lines · Thomas Monjalon
Quoted 11 lines
These functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 11 ++--------- lib/librte_eal/rte_eal_version.map | 4 ++--
Quoted 3 lines
Can remove "-DALLOW_EXPERIMENTAL_API" (or "
allow_experimental_apis= true" for meson) fromdrivers/raw/ifpga_rawdevwhen these APIs are not experimental anymore. For reference: https://patches.dpdk.org/patch/45836/
Yes we could remove this flag in this patch.
But the next series would add it again:
https://patches.dpdk.org/patch/45601/
So I think it is not worth for now.
Quoted 2 lines
It is easy to know when to add "-DALLOW_EXPERIMENTAL_API" but it is hard to know when to remove one, some helper should be good there.
Yes, we should try to clean up those flags regularly after each -rc1 release. But we don't have any tooling for that.
PATCH v3 4/4 eal: simplify parameters of hotplug functions
In reply to Thomas MonjalonAll information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed from rte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.
When removing a device, we already know its rte_device handle which can be directly passed as parameter of rte_eal_hotplug_remove(). If the rte_device is not known, it can be retrieved with the devargs, by iterating in the device list (future RTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.
--- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 76 ++++++++++++++++--------- lib/librte_eal/common/include/rte_dev.h | 30 +++++++++- lib/librte_eal/rte_eal_version.map | 2 + 5 files changed, 80 insertions(+), 34 deletions(-)
drivers/net/failsafe/failsafe_eal.c +1 -2
@@ -144,8 +144,7 @@ fs_bus_uninit(struct rte_eth_dev *dev)int ret =0 ; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { - sdev_ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + sdev_ret =rte_dev_remove (sdev->dev);if (sdev_ret) {ERROR ("Failed to remove requested device %s (err: %d)" , sdev->dev->name, sdev_ret);
drivers/net/failsafe/failsafe_ether.c +1 -2
@@ -265,8 +265,7 @@ fs_dev_remove(struct sub_device *sdev) sdev->state =DEV_PROBED ;/* fallthrough */ case DEV_PROBED : - ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + ret =rte_dev_remove (sdev->dev);if (ret) {ERROR ("Bus detach failed for sub_device %u" ,SUB_ID (sdev));
lib/librte_eal/common/eal_common_dev.c +48 -28
133 lines not on this page · raw message
lib/librte_eal/common/include/rte_dev.h +28 -2
@@ -196,13 +196,26 @@ int rte_eal_dev_detach(struct rte_device *dev);* @param devname * The device name. Based on this device name, eal will identify a driver * capable of handling it and pass it to the driver probing function. -* @param devargs +* @param drvargs * Device arguments to be passed to the driver. * @return * 0 on success, negative on error. */ int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs); +const char *drvargs); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Add matching devices. +* +* @param devargs +* Device arguments including bus, class and driver properties. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_probe(const char *devargs);/** * Hotplug remove a given device from a specific bus.
@@ -216,6 +229,19 @@ int rte_eal_hotplug_add(const char *busname, const char *devname,*/ int rte_eal_hotplug_remove (const char *busname,const char *devname); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Remove one device. +* +* @param dev +* Data structure of the device to remove. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_remove(struct rte_device *dev); +/** * Device comparison function. *
lib/librte_eal/rte_eal_version.map +2 -0
@@ -281,6 +281,8 @@ EXPERIMENTAL { rte_dev_event_monitor_stop; rte_dev_iterator_init; rte_dev_iterator_next; + rte_dev_probe; + rte_dev_remove; rte_devargs_add; rte_devargs_dump; rte_devargs_insert;
Signature · 1 line
2.19.0
Quoted 19 lines · Thomas Monjalon
All information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed fromrte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.When removing a device, we already know its
rte_devicehandle which can be directly passed as parameter ofrte_eal_hotplug_remove(). If therte_deviceis not known, it can be retrieved with the devargs, by iterating in the device list (futureRTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>
Minor memory leak below, when fixed:
<...>
Quoted 14 lines
lib/librte_eal/common/eal_common_dev.c +5
-1@@ -129,46 +129,57 @@ int rte_eal_dev_detach(struct rte_device *dev)int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs) +const char *drvargs) +{ +char *devargs =NULL ; +int size, length =-1 ; +
lib/librte_eal/common/eal_common_dev.c int rte_eal_dev_detach(struct rte_device *dev) · line 146
Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +10
-0+do {/* 2 iterations: first is to know string length */ + size = length +1 ; + length =snprintf (devargs, size,"%s:%s,%s" , busname, devname, drvargs); +if (length >= size) + devargs =malloc (length +1 ); +if (devargs ==NULL ) +return -ENOMEM ; + }while (size ==0 ); + +return rte_dev_probe (devargs);
I think we should free devargs after the call.
Quoted 1 line
lib/librte_eal/common/eal_common_dev.c +1
-0+}
<...>
01/10/2018 13:26, Andrew Rybchenko:
Quoted 46 lines · Thomas Monjalon
Quoted 19 lines
All information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed fromrte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.When removing a device, we already know its
rte_devicehandle which can be directly passed as parameter ofrte_eal_hotplug_remove(). If therte_deviceis not known, it can be retrieved with the devargs, by iterating in the device list (futureRTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>Minor memory leak below, when fixed:
Reviewed-by Andrew Rybchenko <[email protected]><...>
Quoted 18 lines
lib/librte_eal/common/eal_common_dev.c +9
-1@@ -129,46 +129,57 @@ int rte_eal_dev_detach(struct rte_device *dev)int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs) +const char *drvargs) +{ +char *devargs =NULL ; +int size, length =-1 ; + + do { /* 2 iterations: first is to know string length */ + size = length + 1; + length = snprintf(devargs, size, "%s:%s,%s", busname, devname, drvargs); + if (length >= size)
Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c int rte_eal_dev_detach(struct rte_device *dev) · line 146
Quoted 6 lines
lib/librte_eal/common/eal_common_dev.c +6
-0+ devargs =malloc (length +1 ); +if (devargs ==NULL ) +return -ENOMEM ; + }while (size ==0 ); + +return rte_dev_probe (devargs);I think we should free devargs after the call.
Good catch!
Will fix in v4, thank you.
v4 cover eal: simplify devargs and hotplug functions
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
Instead of changing the existing hotplug functions, as in the RFC, some new experimental functions are added.
The old functions lose their experimental status in order to provide a non-experimental replacement for deprecated attach/detach functions.
It has been discussed briefly in the latest technical board meeting.
Changes in v4 - after Andrew's review:
- add API changes in release notes (patches 1 & 2)
- fix memory leak in rte_eal_hotplug_add (patch 4)
Change in v3:
- fix null dereferencing in error path (patch 2)
Thomas Monjalon (4):
devargs: remove deprecated functions
devargs: simplify parameters of removal function
eal: remove experimental flag of hotplug functions
eal: simplify parameters of hotplug functions
doc/guides/rel_notes/release_18_11.rst | 8 ++ drivers/bus/ifpga/ifpga_bus.c | 5 +- drivers/bus/vdev/vdev.c | 8 +- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 89 +++++++++++++-------- lib/librte_eal/common/eal_common_devargs.c | 41 ++-------- lib/librte_eal/common/include/rte_dev.h | 35 ++++++-- lib/librte_eal/common/include/rte_devargs.h | 81 +------------------ lib/librte_eal/rte_eal_version.map | 10 +-- 10 files changed, 111 insertions(+), 172 deletions(-)
Signature · 1 line
2.19.0
PATCH v4 1/4 devargs: remove deprecated functions
rte_eal_parse_devargs_str() does not support parsing the bus name at the start of devargs. So it was renamed and deprecated.
rte_eal_devargs_add(), rte_eal_devargs_type_count() and rte_eal_devargs_dump() were declared deprecated and had their implementation body renamed.
All these functions were deprecated in release 18.05.
---
The library version is not updated because it should be done in earlier patch https://patches.dpdk.org/patch/43903/
--- doc/guides/rel_notes/release_18_11.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 30 --------- lib/librte_eal/common/include/rte_devargs.h | 71 --------------------- lib/librte_eal/rte_eal_version.map | 4 -- 4 files changed, 5 insertions(+), 105 deletions(-)
doc/guides/rel_notes/release_18_11.rst +5 -0
@@ -102,6 +102,11 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* eal: The following devargs functions, which were deprecated in 18.05, + are removed in 18.11: + ``rte_eal_parse_devargs_str()``, ``rte_eal_devargs_add()``, + ``rte_eal_devargs_type_count()``, and ``rte_eal_devargs_dump()``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``.
lib/librte_eal/common/eal_common_devargs.c +0 -30
@@ -31,36 +31,6 @@ TAILQ_HEAD(rte_devargs_list, rte_devargs);struct rte_devargs_list devargs_list =TAILQ_HEAD_INITIALIZER (devargs_list); -int -rte_eal_parse_devargs_str (const char *devargs_str, -char **drvname,char **drvargs) -{ -char *sep; - -if ((devargs_str) ==NULL || (drvname) ==NULL || (drvargs ==NULL )) -return -1 ; - - *drvname =strdup (devargs_str); -if (*drvname ==NULL ) -return -1 ; - -/* set the first ',' to '\0' to split name and arguments */ - sep =strchr (*drvname,',' ); -if (sep !=NULL ) { - sep[0 ] ='\0' ; - *drvargs =strdup (sep +1 ); - }else { - *drvargs =strdup ("" ); - } - -if (*drvargs ==NULL ) { -free (*drvname); - *drvname =NULL ; -return -1 ; - } -return 0 ; -} -static size_t devargs_layer_count (const char *s) {
lib/librte_eal/common/include/rte_devargs.h +0 -71
95 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +0 -4
@@ -19,9 +19,6 @@ DPDK_2.0 { rte_dump_tailq; rte_eal_alarm_cancel; rte_eal_alarm_set; - rte_eal_devargs_add; - rte_eal_devargs_dump; - rte_eal_devargs_type_count; rte_eal_get_configuration; rte_eal_get_lcore_state; rte_eal_get_physmem_size;
@@ -32,7 +29,6 @@ DPDK_2.0 { rte_eal_lcore_role; rte_eal_mp_remote_launch; rte_eal_mp_wait_lcore; - rte_eal_parse_devargs_str; rte_eal_process_type; rte_eal_remote_launch; rte_eal_tailq_lookup;
Signature · 1 line
2.19.0
PATCH v4 2/4 devargs: simplify parameters of removal function
In reply to Thomas MonjalonThe function rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.
--- doc/guides/rel_notes/release_18_11.rst | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 11 +++++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 6 files changed, 18 insertions(+), 23 deletions(-)
doc/guides/rel_notes/release_18_11.rst +3 -0
@@ -107,6 +107,9 @@ API Changes ``rte_eal_parse_devargs_str()``, ``rte_eal_devargs_add()``, ``rte_eal_devargs_type_count()``, and ``rte_eal_devargs_dump()``. +* eal: The parameters of the function ``rte_devargs_remove()`` have changed + from bus and device names to ``struct rte_devargs``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``.
drivers/bus/ifpga/ifpga_bus.c +1 -4
@@ -361,7 +361,6 @@ static int ifpga_unplug(struct rte_device *dev) {struct rte_afu_device *afu_dev =NULL ; -struct rte_devargs *devargs =NULL ;int ret;if (dev ==NULL )
@@ -371,15 +370,13 @@ ifpga_unplug(struct rte_device *dev)if (!afu_dev)return -ENOENT ; - devargs = dev->devargs; - ret =ifpga_remove_driver (afu_dev);if (ret)return ret;TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->devargs);free (afu_dev);return 0 ;
drivers/bus/vdev/vdev.c +2 -6
@@ -248,7 +248,6 @@ int rte_vdev_init(const char *name, const char *args) { struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock);
@@ -259,9 +258,8 @@ rte_vdev_init(const char *name, const char *args)if (ret >0 )VDEV_LOG (ERR ,"no driver found for %s" , name);/* If fails, remove it from vdev list */ - devargs = dev->device.devargs;TAILQ_REMOVE (&vdev_device_list, dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); } }
@@ -289,7 +287,6 @@ int rte_vdev_uninit(const char *name) {struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;if (name ==NULL )
@@ -308,8 +305,7 @@ rte_vdev_uninit(const char *name) goto unlock;TAILQ_REMOVE (&vdev_device_list, dev, next); - devargs = dev->device.devargs; -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); unlock:
lib/librte_eal/common/eal_common_dev.c +2 -2
@@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn 0 ; err_devarg: -if (rte_devargs_remove (busname, devname)) { +if (rte_devargs_remove (da)) {free (da->args);free (da); }
@@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)if (ret)RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , dev->name); -rte_devargs_remove (busname, devname); +rte_devargs_remove (dev->devargs);return ret; }
lib/librte_eal/common/eal_common_devargs.c +7 -4
@@ -266,7 +266,7 @@ rte_devargs_insert(struct rte_devargs *da) {int ret; - ret =rte_devargs_remove (da->bus->name, da->name); + ret =rte_devargs_remove (da);if (ret <0 )return ret;TAILQ_INSERT_TAIL (&devargs_list, da, next);
@@ -312,14 +312,17 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) } int __rte_experimental -rte_devargs_remove (const char *busname,const char *devname) +rte_devargs_remove (struct rte_devargs *devargs) {struct rte_devargs *d;void *tmp; +if (devargs->bus ==NULL ) +return -1 ; + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { -if (strcmp (d->bus->name, busname) ==0 && -strcmp (d->name, devname) ==0 ) { +if (strcmp (d->bus->name, devargs->bus->name) ==0 && +strcmp (d->name, devargs->name) ==0 ) {TAILQ_REMOVE (&devargs_list, d, next);free (d->args);free (d);
lib/librte_eal/common/include/rte_devargs.h +3 -7
@@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* Its resources are freed. * If the devargs cannot be found, nothing happens. * -* @param busname -* bus name of the devargs to remove. -* -* @param devname -* device name of the devargs to remove. +* @param devargs +* The instance or a copy of devargs to remove. * * @return * 0 on success.
@@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* >0 if the devargs was not within the user device list. */ __rte_experimental -int rte_devargs_remove(const char *busname, -const char *devname); +int rte_devargs_remove(struct rte_devargs *devargs);/** * Count the number of user devices of a specified type
Signature · 1 line
2.19.0
PATCH v4 3/4 eal: remove experimental flag of hotplug functions
In reply to Thomas MonjalonThese functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 11 ++--------- lib/librte_eal/rte_eal_version.map | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-)
lib/librte_eal/common/eal_common_dev.c +4 -3
@@ -127,8 +127,9 @@ int rte_eal_dev_detach(struct rte_device *dev)return ret; } -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs) +int +rte_eal_hotplug_add (const char *busname,const char *devname, +const char *devargs) {struct rte_bus *bus;struct rte_device *dev;
@@ -193,7 +194,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn ret; } -int __rte_experimental +int rte_eal_hotplug_remove (const char *busname,const char *devname) {struct rte_bus *bus;
lib/librte_eal/common/include/rte_dev.h +2 -9
@@ -189,9 +189,6 @@ __rte_deprecatedint rte_eal_dev_detach (struct rte_device *dev);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug add a given device to a specific bus. * * @param busname
@@ -204,13 +201,10 @@ int rte_eal_dev_detach(struct rte_device *dev);* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, +int rte_eal_hotplug_add (const char *busname,const char *devname,const char *devargs);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug remove a given device from a specific bus. * * @param busname
@@ -220,8 +214,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_remove(const char *busname, -const char *devname); +int rte_eal_hotplug_remove (const char *busname,const char *devname);/** * Device comparison function.
lib/librte_eal/rte_eal_version.map +2 -2
@@ -261,6 +261,8 @@ DPDK_18.08 { DPDK_18.11 { global: + rte_eal_hotplug_add; + rte_eal_hotplug_remove; rte_strscpy; } DPDK_18.08;
@@ -288,8 +290,6 @@ EXPERIMENTAL { rte_devargs_remove; rte_devargs_type_count; rte_eal_cleanup; - rte_eal_hotplug_add; - rte_eal_hotplug_remove; rte_fbarray_attach; rte_fbarray_destroy; rte_fbarray_detach;
Signature · 1 line
2.19.0
PATCH v4 4/4 eal: simplify parameters of hotplug functions
In reply to Thomas MonjalonAll information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed from rte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.
When removing a device, we already know its rte_device handle which can be directly passed as parameter of rte_eal_hotplug_remove(). If the rte_device is not known, it can be retrieved with the devargs, by iterating in the device list (future RTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.
--- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 80 ++++++++++++++++--------- lib/librte_eal/common/include/rte_dev.h | 30 +++++++++- lib/librte_eal/rte_eal_version.map | 2 + 5 files changed, 84 insertions(+), 34 deletions(-)
drivers/net/failsafe/failsafe_eal.c +1 -2
@@ -144,8 +144,7 @@ fs_bus_uninit(struct rte_eth_dev *dev)int ret =0 ; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { - sdev_ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + sdev_ret =rte_dev_remove (sdev->dev);if (sdev_ret) {ERROR ("Failed to remove requested device %s (err: %d)" , sdev->dev->name, sdev_ret);
drivers/net/failsafe/failsafe_ether.c +1 -2
@@ -282,8 +282,7 @@ fs_dev_remove(struct sub_device *sdev) sdev->state =DEV_PROBED ;/* fallthrough */ case DEV_PROBED : - ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + ret =rte_dev_remove (sdev->dev);if (ret) {ERROR ("Bus detach failed for sub_device %u" ,SUB_ID (sdev));
lib/librte_eal/common/eal_common_dev.c +52 -28
137 lines not on this page · raw message
lib/librte_eal/common/include/rte_dev.h +28 -2
@@ -196,13 +196,26 @@ int rte_eal_dev_detach(struct rte_device *dev);* @param devname * The device name. Based on this device name, eal will identify a driver * capable of handling it and pass it to the driver probing function. -* @param devargs +* @param drvargs * Device arguments to be passed to the driver. * @return * 0 on success, negative on error. */ int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs); +const char *drvargs); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Add matching devices. +* +* @param devargs +* Device arguments including bus, class and driver properties. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_probe(const char *devargs);/** * Hotplug remove a given device from a specific bus.
@@ -216,6 +229,19 @@ int rte_eal_hotplug_add(const char *busname, const char *devname,*/ int rte_eal_hotplug_remove (const char *busname,const char *devname); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Remove one device. +* +* @param dev +* Data structure of the device to remove. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_remove(struct rte_device *dev); +/** * Device comparison function. *
lib/librte_eal/rte_eal_version.map +2 -0
@@ -281,6 +281,8 @@ EXPERIMENTAL { rte_dev_event_monitor_stop; rte_dev_iterator_init; rte_dev_iterator_next; + rte_dev_probe; + rte_dev_remove; rte_devargs_add; rte_devargs_dump; rte_devargs_insert;
Signature · 1 line
2.19.0
v5 cover eal: simplify devargs and hotplug functions
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
Instead of changing the existing hotplug functions, as in the RFC, some new experimental functions are added.
The old functions lose their experimental status in order to provide a non-experimental replacement for deprecated attach/detach functions.
It has been discussed briefly in the latest technical board meeting.
Changes in v5:
- rte_devargs_remove is fixed in case of null devargs (patch 2)
- a pointer to the bus is added in rte_device (patch 3)
- rte_dev_remove is fixed in case of no devargs (patch 5)
Changes in v4 - after Andrew's review:
- add API changes in release notes (patches 1 & 2)
- fix memory leak in rte_eal_hotplug_add (patch 4)
Change in v3:
- fix null dereferencing in error path (patch 2)
Thomas Monjalon (5):
devargs: remove deprecated functions
devargs: simplify parameters of removal function
eal: add bus pointer in device structure
eal: remove experimental flag of hotplug functions
eal: simplify parameters of hotplug functions
doc/guides/rel_notes/release_18_11.rst | 10 +++ drivers/bus/dpaa/dpaa_bus.c | 2 + drivers/bus/fslmc/fslmc_bus.c | 2 + drivers/bus/ifpga/ifpga_bus.c | 6 +- drivers/bus/pci/bsd/pci.c | 2 + drivers/bus/pci/linux/pci.c | 1 + drivers/bus/pci/private.h | 2 + drivers/bus/vdev/vdev.c | 9 +-- drivers/bus/vmbus/linux/vmbus_bus.c | 1 + drivers/bus/vmbus/private.h | 3 + drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 89 +++++++++++++-------- lib/librte_eal/common/eal_common_devargs.c | 41 ++-------- lib/librte_eal/common/include/rte_dev.h | 36 +++++++-- lib/librte_eal/common/include/rte_devargs.h | 81 +------------------ lib/librte_eal/rte_eal_version.map | 10 +-- 17 files changed, 128 insertions(+), 173 deletions(-)
Signature · 1 line
2.19.0
PATCH v5 1/5 devargs: remove deprecated functions
rte_eal_parse_devargs_str() does not support parsing the bus name at the start of devargs. So it was renamed and deprecated.
rte_eal_devargs_add(), rte_eal_devargs_type_count() and rte_eal_devargs_dump() were declared deprecated and had their implementation body renamed.
All these functions were deprecated in release 18.05.
---
The library version is not updated because it should be done in earlier patch https://patches.dpdk.org/patch/43903/
--- doc/guides/rel_notes/release_18_11.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 30 --------- lib/librte_eal/common/include/rte_devargs.h | 71 --------------------- lib/librte_eal/rte_eal_version.map | 4 -- 4 files changed, 5 insertions(+), 105 deletions(-)
doc/guides/rel_notes/release_18_11.rst +5 -0
@@ -118,6 +118,11 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* eal: The following devargs functions, which were deprecated in 18.05, + were removed in 18.11: + ``rte_eal_parse_devargs_str()``, ``rte_eal_devargs_add()``, + ``rte_eal_devargs_type_count()``, and ``rte_eal_devargs_dump()``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``.
lib/librte_eal/common/eal_common_devargs.c +0 -30
@@ -28,36 +28,6 @@ TAILQ_HEAD(rte_devargs_list, rte_devargs);struct rte_devargs_list devargs_list =TAILQ_HEAD_INITIALIZER (devargs_list); -int -rte_eal_parse_devargs_str (const char *devargs_str, -char **drvname,char **drvargs) -{ -char *sep; - -if ((devargs_str) ==NULL || (drvname) ==NULL || (drvargs ==NULL )) -return -1 ; - - *drvname =strdup (devargs_str); -if (*drvname ==NULL ) -return -1 ; - -/* set the first ',' to '\0' to split name and arguments */ - sep =strchr (*drvname,',' ); -if (sep !=NULL ) { - sep[0 ] ='\0' ; - *drvargs =strdup (sep +1 ); - }else { - *drvargs =strdup ("" ); - } - -if (*drvargs ==NULL ) { -free (*drvname); - *drvname =NULL ; -return -1 ; - } -return 0 ; -} -static size_t devargs_layer_count (const char *s) {
lib/librte_eal/common/include/rte_devargs.h +0 -71
95 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +0 -4
@@ -19,9 +19,6 @@ DPDK_2.0 { rte_dump_tailq; rte_eal_alarm_cancel; rte_eal_alarm_set; - rte_eal_devargs_add; - rte_eal_devargs_dump; - rte_eal_devargs_type_count; rte_eal_get_configuration; rte_eal_get_lcore_state; rte_eal_get_physmem_size;
@@ -32,7 +29,6 @@ DPDK_2.0 { rte_eal_lcore_role; rte_eal_mp_remote_launch; rte_eal_mp_wait_lcore; - rte_eal_parse_devargs_str; rte_eal_process_type; rte_eal_remote_launch; rte_eal_tailq_lookup;
Signature · 1 line
2.19.0
Re: [PATCH v5 1/5] devargs: remove deprecated functions
Hi Thomas,
Quoted 11 lines · Thomas Monjalon
rte_eal_parse_devargs_str()does not support parsing the bus name at the start of devargs. So it was renamed and deprecated.
rte_eal_devargs_add(),rte_eal_devargs_type_count()andrte_eal_devargs_dump()were declared deprecated and had their implementation body renamed.All these functions were deprecated in release 18.05.
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Quoted 10 lines
---
The library version is not updated because it should be done in earlier patch https://patches.dpdk.org/patch/43903/--- doc/guides/rel_notes/release_18_11.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 30 --------- lib/librte_eal/common/include/rte_devargs.h | 71 --------------------- lib/librte_eal/rte_eal_version.map | 4 -- 4 files changed, 5 insertions(+), 105 deletions(-)
Signature · 2 lines
Gaëtan Rivet 6WIND
PATCH v5 2/5 devargs: simplify parameters of removal function
In reply to Thomas MonjalonThe function rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.
--- doc/guides/rel_notes/release_18_11.rst | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 11 +++++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 6 files changed, 18 insertions(+), 23 deletions(-)
doc/guides/rel_notes/release_18_11.rst +3 -0
@@ -123,6 +123,9 @@ API Changes ``rte_eal_parse_devargs_str()``, ``rte_eal_devargs_add()``, ``rte_eal_devargs_type_count()``, and ``rte_eal_devargs_dump()``. +* eal: The parameters of the function ``rte_devargs_remove()`` have changed + from bus and device names to ``struct rte_devargs``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``.
drivers/bus/ifpga/ifpga_bus.c +1 -4
@@ -361,7 +361,6 @@ static int ifpga_unplug(struct rte_device *dev) {struct rte_afu_device *afu_dev =NULL ; -struct rte_devargs *devargs =NULL ;int ret;if (dev ==NULL )
@@ -371,15 +370,13 @@ ifpga_unplug(struct rte_device *dev)if (!afu_dev)return -ENOENT ; - devargs = dev->devargs; - ret =ifpga_remove_driver (afu_dev);if (ret)return ret;TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->devargs);free (afu_dev);return 0 ;
drivers/bus/vdev/vdev.c +2 -6
@@ -249,7 +249,6 @@ int rte_vdev_init(const char *name, const char *args) { struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock);
@@ -260,9 +259,8 @@ rte_vdev_init(const char *name, const char *args)if (ret >0 )VDEV_LOG (ERR ,"no driver found for %s" , name);/* If fails, remove it from vdev list */ - devargs = dev->device.devargs;TAILQ_REMOVE (&vdev_device_list, dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); } }
@@ -290,7 +288,6 @@ int rte_vdev_uninit(const char *name) {struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;if (name ==NULL )
@@ -309,8 +306,7 @@ rte_vdev_uninit(const char *name) goto unlock;TAILQ_REMOVE (&vdev_device_list, dev, next); - devargs = dev->device.devargs; -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); unlock:
lib/librte_eal/common/eal_common_dev.c +2 -2
@@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn 0 ; err_devarg: -if (rte_devargs_remove (busname, devname)) { +if (rte_devargs_remove (da) !=0 ) {free (da->args);free (da); }
@@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)if (ret)RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , dev->name); -rte_devargs_remove (busname, devname); +rte_devargs_remove (dev->devargs);return ret; }
lib/librte_eal/common/eal_common_devargs.c +7 -4
@@ -263,7 +263,7 @@ rte_devargs_insert(struct rte_devargs *da) {int ret; - ret =rte_devargs_remove (da->bus->name, da->name); + ret =rte_devargs_remove (da);if (ret <0 )return ret;TAILQ_INSERT_TAIL (&devargs_list, da, next);
@@ -309,14 +309,17 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) } int __rte_experimental -rte_devargs_remove (const char *busname,const char *devname) +rte_devargs_remove (struct rte_devargs *devargs) {struct rte_devargs *d;void *tmp; +if (devargs ==NULL || devargs->bus ==NULL ) +return -1 ; + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { -if (strcmp (d->bus->name, busname) ==0 && -strcmp (d->name, devname) ==0 ) { +if (strcmp (d->bus->name, devargs->bus->name) ==0 && +strcmp (d->name, devargs->name) ==0 ) {TAILQ_REMOVE (&devargs_list, d, next);free (d->args);free (d);
lib/librte_eal/common/include/rte_devargs.h +3 -7
@@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* Its resources are freed. * If the devargs cannot be found, nothing happens. * -* @param busname -* bus name of the devargs to remove. -* -* @param devname -* device name of the devargs to remove. +* @param devargs +* The instance or a copy of devargs to remove. * * @return * 0 on success.
@@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* >0 if the devargs was not within the user device list. */ __rte_experimental -int rte_devargs_remove(const char *busname, -const char *devname); +int rte_devargs_remove(struct rte_devargs *devargs);/** * Count the number of user devices of a specified type
Signature · 1 line
2.19.0
Re: [PATCH v5 2/5] devargs: simplify parameters of removal function
Quoted 8 lines · Thomas Monjalon
The function
rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Quoted 9 lines
--- doc/guides/rel_notes/release_18_11.rst | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 11 +++++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 6 files changed, 18 insertions(+), 23 deletions(-)
Signature · 2 lines
Gaëtan Rivet 6WIND
PATCH v5 3/5 eal: add bus pointer in device structure
In reply to Thomas MonjalonWhen a device is added with a devargs (hotplug or whitelist), the bus pointer can be retrieved via its devargs. But there is no such devargs.bus in case of standard scan.
A pointer to the rte_bus handle is added to rte_device. When a device is allocated (during a scan), the pointer to its bus is assigned.
It will make possible to remove a rte_device,
using the function pointer from its bus.
The function rte_bus_find_by_device() becomes useless, and may be removed later.
--- doc/guides/rel_notes/release_18_11.rst | 2 ++ drivers/bus/dpaa/dpaa_bus.c | 2 ++ drivers/bus/fslmc/fslmc_bus.c | 2 ++ drivers/bus/ifpga/ifpga_bus.c | 1 + drivers/bus/pci/bsd/pci.c | 2 ++ drivers/bus/pci/linux/pci.c | 1 + drivers/bus/pci/private.h | 2 ++ drivers/bus/vdev/vdev.c | 1 + drivers/bus/vmbus/linux/vmbus_bus.c | 1 + drivers/bus/vmbus/private.h | 3 +++ lib/librte_eal/common/include/rte_dev.h | 1 + 11 files changed, 18 insertions(+)
doc/guides/rel_notes/release_18_11.rst +2 -0
@@ -164,6 +164,8 @@ ABI Changes ``rte_config`` structure on account of improving DPDK usability when using either ``--legacy-mem`` or ``--single-file-segments`` flags. +* eal: The structure ``rte_device`` got a new field to reference a ``rte_bus``. + Removed Items -------------
drivers/bus/dpaa/dpaa_bus.c +2 -0
@@ -165,6 +165,8 @@ dpaa_create_device_list(void) goto cleanup; } + dev->device.bus = &rte_dpaa_bus.bus; + cfg = &dpaa_netcfg->port_cfg[i]; fman_intf = cfg->fman_if;
drivers/bus/fslmc/fslmc_bus.c +2 -0
@@ -161,6 +161,8 @@ scan_one_fslmc_device(char *dev_name)return -ENOMEM ; } + dev->device.bus = &rte_fslmc_bus.bus; +/* Parse the device name and ID */ t_ptr =strtok (dup_dev_name,"." );if (!t_ptr) {
drivers/bus/ifpga/ifpga_bus.c +1 -0
@@ -142,6 +142,7 @@ ifpga_scan_one(struct rte_rawdev *rawdev,if (!afu_dev) goto end; + afu_dev->device.bus = &rte_ifpga_bus; afu_dev->device.devargs = devargs; afu_dev->device.numa_node =SOCKET_ID_ANY ; afu_dev->device.name = devargs->name;
drivers/bus/pci/bsd/pci.c +2 -0
@@ -223,6 +223,8 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) }memset (dev,0 ,sizeof (*dev)); + dev->device.bus = &rte_pci_bus.bus; + dev->addr.domain = conf->pc_sel.pc_domain; dev->addr.bus = conf->pc_sel.pc_bus; dev->addr.devid = conf->pc_sel.pc_dev;
drivers/bus/pci/linux/pci.c +1 -0
@@ -228,6 +228,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)return -1 ;memset (dev,0 ,sizeof (*dev)); + dev->device.bus = &rte_pci_bus.bus; dev->addr = *addr;/* get vendor id */
drivers/bus/pci/private.h +2 -0
@@ -15,6 +15,8 @@ extern struct rte_pci_bus rte_pci_bus;struct rte_pci_driver ;struct rte_pci_device ; +extern struct rte_pci_bus rte_pci_bus; +/** * Probe the PCI bus *
drivers/bus/vdev/vdev.c +1 -0
@@ -456,6 +456,7 @@ vdev_scan(void)continue ; } + dev->device.bus = &rte_vdev_bus; dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; dev->device.name = devargs->name;
drivers/bus/vmbus/linux/vmbus_bus.c +1 -0
@@ -229,6 +229,7 @@ vmbus_scan_one(const char *name)if (dev ==NULL )return -1 ; + dev->device.bus = &rte_vmbus_bus.bus; dev->device.name =strdup (name);if (!dev->device.name) goto error;
drivers/bus/vmbus/private.h +3 -0
@@ -10,11 +10,14 @@#include <sys/uio.h> #include <rte_log.h> #include <rte_vmbus_reg.h> +#include <rte_bus_vmbus.h> #ifndef PAGE_SIZE #define PAGE_SIZE 4096#endif +extern struct rte_vmbus_bus rte_vmbus_bus; +extern int vmbus_logtype_bus; #define VMBUS_LOG(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, vmbus_logtype_bus, "%s(): " fmt "\n", \
lib/librte_eal/common/include/rte_dev.h +1 -0
@@ -157,6 +157,7 @@ struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ const struct rte_driver *driver;/**< Associated driver */ +const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */ };
Signature · 1 line
2.19.0
Re: [PATCH v5 3/5] eal: add bus pointer in device structure
Quoted 8 lines · Thomas Monjalon
When a device is added with a devargs (hotplug or whitelist), the bus pointer can be retrieved via its devargs. But there is no such devargs.bus in case of standard scan.
A pointer to the
rte_bushandle is added torte_device. When a device is allocated (during a scan), the pointer to its bus is assigned.
Quoted 7 lines
It will make possible to remove a
rte_device,
using the function pointer from its bus.The function
rte_bus_find_by_device()becomes useless, and may be removed later.Signed-off-by Thomas Monjalon <[email protected]>
I agree with this change, but I think this can break ABI of buses defining their structure by composition with rte_device (e.g. PCI bus). Have you checked ABI?
Personally I don't care, I prefer a clean framework to a littered lib.
Signature · 2 lines
Gaëtan Rivet 6WIND
Re: [PATCH v5 3/5] eal: add bus pointer in device structure
04/10/2018 11:31, Gaëtan Rivet:
Quoted 12 lines · Thomas Monjalon
Quoted 11 lines
When a device is added with a devargs (hotplug or whitelist), the bus pointer can be retrieved via its devargs. But there is no such devargs.bus in case of standard scan.
A pointer to the
rte_bushandle is added torte_device. When a device is allocated (during a scan), the pointer to its bus is assigned.It will make possible to remove a
rte_device,
using the function pointer from its bus.
Quoted 8 lines
Quoted 4 lines
The function
rte_bus_find_by_device()becomes useless, and may be removed later.Signed-off-by Thomas Monjalon <[email protected]>I agree with this change, but I think this can break ABI of buses defining their structure by composition with
rte_device(e.g. PCI bus). Have you checked ABI?
Yes I forgot it changes the size of the bus structures. I can spin a v6 with a bump of ABI version of the bus drivers, and an additional note in release notes.
Quoted 3 lines
Personally I don't care, I prefer a clean framework to a littered lib.
Acked-by Gaetan Rivet <[email protected]>
Adding bus drivers maintainers to get more opinions.
PATCH v5 4/5 eal: remove experimental flag of hotplug functions
In reply to Thomas MonjalonThese functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 11 ++--------- lib/librte_eal/rte_eal_version.map | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-)
lib/librte_eal/common/eal_common_dev.c +4 -3
@@ -127,8 +127,9 @@ int rte_eal_dev_detach(struct rte_device *dev)return ret; } -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs) +int +rte_eal_hotplug_add (const char *busname,const char *devname, +const char *devargs) {struct rte_bus *bus;struct rte_device *dev;
@@ -193,7 +194,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn ret; } -int __rte_experimental +int rte_eal_hotplug_remove (const char *busname,const char *devname) {struct rte_bus *bus;
lib/librte_eal/common/include/rte_dev.h +2 -9
@@ -190,9 +190,6 @@ __rte_deprecatedint rte_eal_dev_detach (struct rte_device *dev);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug add a given device to a specific bus. * * @param busname
@@ -205,13 +202,10 @@ int rte_eal_dev_detach(struct rte_device *dev);* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, +int rte_eal_hotplug_add (const char *busname,const char *devname,const char *devargs);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug remove a given device from a specific bus. * * @param busname
@@ -221,8 +215,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_remove(const char *busname, -const char *devname); +int rte_eal_hotplug_remove (const char *busname,const char *devname);/** * Device comparison function.
lib/librte_eal/rte_eal_version.map +2 -2
@@ -261,6 +261,8 @@ DPDK_18.08 { DPDK_18.11 { global: + rte_eal_hotplug_add; + rte_eal_hotplug_remove; rte_strscpy; } DPDK_18.08;
@@ -288,8 +290,6 @@ EXPERIMENTAL { rte_devargs_remove; rte_devargs_type_count; rte_eal_cleanup; - rte_eal_hotplug_add; - rte_eal_hotplug_remove; rte_fbarray_attach; rte_fbarray_destroy; rte_fbarray_detach;
Signature · 1 line
2.19.0
Re: [PATCH v5 4/5] eal: remove experimental flag of hotplug functions
Quoted 8 lines · Thomas Monjalon
These functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Quoted 6 lines
--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 11 ++--------- lib/librte_eal/rte_eal_version.map | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-)
Signature · 2 lines
Gaëtan Rivet 6WIND
PATCH v5 5/5 eal: simplify parameters of hotplug functions
In reply to Thomas MonjalonAll information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed from rte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.
When removing a device, we already know its rte_device handle which can be directly passed as parameter of rte_eal_hotplug_remove(). If the rte_device is not known, it can be retrieved with the devargs, by iterating in the device list (future RTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.
--- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 80 ++++++++++++++++--------- lib/librte_eal/common/include/rte_dev.h | 30 +++++++++- lib/librte_eal/rte_eal_version.map | 2 + 5 files changed, 83 insertions(+), 35 deletions(-)
drivers/net/failsafe/failsafe_eal.c +1 -2
@@ -144,8 +144,7 @@ fs_bus_uninit(struct rte_eth_dev *dev)int ret =0 ; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { - sdev_ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + sdev_ret =rte_dev_remove (sdev->dev);if (sdev_ret) {ERROR ("Failed to remove requested device %s (err: %d)" , sdev->dev->name, sdev_ret);
drivers/net/failsafe/failsafe_ether.c +1 -2
@@ -282,8 +282,7 @@ fs_dev_remove(struct sub_device *sdev) sdev->state =DEV_PROBED ;/* fallthrough */ case DEV_PROBED : - ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + ret =rte_dev_remove (sdev->dev);if (ret) {ERROR ("Bus detach failed for sub_device %u" ,SUB_ID (sdev));
lib/librte_eal/common/eal_common_dev.c +51 -29
137 lines not on this page · raw message
lib/librte_eal/common/include/rte_dev.h +28 -2
@@ -197,13 +197,26 @@ int rte_eal_dev_detach(struct rte_device *dev);* @param devname * The device name. Based on this device name, eal will identify a driver * capable of handling it and pass it to the driver probing function. -* @param devargs +* @param drvargs * Device arguments to be passed to the driver. * @return * 0 on success, negative on error. */ int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs); +const char *drvargs); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Add matching devices. +* +* @param devargs +* Device arguments including bus, class and driver properties. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_probe(const char *devargs);/** * Hotplug remove a given device from a specific bus.
@@ -217,6 +230,19 @@ int rte_eal_hotplug_add(const char *busname, const char *devname,*/ int rte_eal_hotplug_remove (const char *busname,const char *devname); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Remove one device. +* +* @param dev +* Data structure of the device to remove. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_remove(struct rte_device *dev); +/** * Device comparison function. *
lib/librte_eal/rte_eal_version.map +2 -0
@@ -281,6 +281,8 @@ EXPERIMENTAL { rte_dev_event_monitor_stop; rte_dev_iterator_init; rte_dev_iterator_next; + rte_dev_probe; + rte_dev_remove; rte_devargs_add; rte_devargs_dump; rte_devargs_insert;
Signature · 1 line
2.19.0
I much prefer this API,
I have one remark inline however.
Quoted 19 lines · Thomas Monjalon
All information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed fromrte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.When removing a device, we already know its
rte_devicehandle which can be directly passed as parameter ofrte_eal_hotplug_remove(). If therte_deviceis not known, it can be retrieved with the devargs, by iterating in the device list (futureRTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.
Quoted 2 lines
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
With the following remark being taken care of,
Quoted 8 lines
--- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 80 ++++++++++++++++--------- lib/librte_eal/common/include/rte_dev.h | 30 +++++++++- lib/librte_eal/rte_eal_version.map | 2 + 5 files changed, 83 insertions(+), 35 deletions(-)
<snip>
Quoted 21 lines
lib/librte_eal/common/eal_common_dev.c +3
-7@@ -129,46 +129,61 @@ int rte_eal_dev_detach(struct rte_device *dev)int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs) +const char *drvargs) { -struct rte_bus *bus; -struct rte_device *dev; -struct rte_devargs *da;int ret; +char *devargs =NULL ; +int size, length =-1 ; - bus =rte_bus_find_by_name (busname); -if (bus ==NULL ) { -RTE_LOG (ERR ,EAL ,"Cannot find bus (%s)\n" , busname);
lib/librte_eal/common/eal_common_dev.c int rte_eal_dev_detach(struct rte_device *dev) · line 145
Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +8
-2-return -ENOENT ; - } +do {/* 2 iterations: first is to know string length */ + size = length +1 ; + length =snprintf (devargs, size,"%s:%s,%s" , busname, devname, drvargs); +if (length >= size) + devargs =malloc (length +1 ); +if (devargs ==NULL ) +return -ENOMEM ; + }while (size ==0 );
I don't see a good reason for writing it this way.
You use an additional state (size) and complicate something that is pretty straightforward. To make sure no error was written here, I had to do step-by-step careful reading, this should not be required by clean code.
You should remove this loop, which then allow removing size, and forces using simple code-flow.
Quoted 54 lines
lib/librte_eal/common/eal_common_dev.c +23
-10-if (bus->plug ==NULL ) { -RTE_LOG (ERR ,EAL ,"Function plug not supported by bus (%s)\n" , - bus->name); -return -ENOTSUP ; - } + ret =rte_dev_probe (devargs); + +free (devargs); +return ret; +} + +int __rte_experimental +rte_dev_probe (const char *devargs) +{ +struct rte_device *dev; +struct rte_devargs *da; +int ret; da =calloc (1 ,sizeof (*da));if (da ==NULL )return -ENOMEM ; - ret =rte_devargs_parsef (da,"%s:%s,%s" , - busname, devname, devargs); + ret =rte_devargs_parse (da, devargs);if (ret) goto err_devarg; +if (da->bus->plug ==NULL ) { +RTE_LOG (ERR ,EAL ,"Function plug not supported by bus (%s)\n" , + da->bus->name); + ret = -ENOTSUP ; + goto err_devarg; + } + ret =rte_devargs_insert (da);if (ret) goto err_devarg; - ret = bus->scan (); + ret = da->bus->scan ();if (ret) goto err_devarg; - dev = bus->find_device (NULL , cmp_dev_name, devname); + dev = da->bus->find_device (NULL , cmp_dev_name, da->name);if (dev ==NULL ) {RTE_LOG (ERR ,EAL ,"Cannot find device (%s)\n" , - devname); + da->name); ret = -ENODEV ; goto err_devarg; }
<snip>
Signature · 2 lines
Gaëtan Rivet 6WIND
04/10/2018 11:44, Gaëtan Rivet:
Quoted 37 lines · Thomas Monjalon
Quoted 19 lines
lib/librte_eal/common/eal_common_dev.c +3
-7@@ -129,46 +129,61 @@ int rte_eal_dev_detach(struct rte_device *dev)int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs) +const char *drvargs) { -struct rte_bus *bus; -struct rte_device *dev; -struct rte_devargs *da;int ret; +char *devargs =NULL ; +int size, length =-1 ; - bus =rte_bus_find_by_name (busname); -if (bus ==NULL ) { -RTE_LOG (ERR ,EAL ,"Cannot find bus (%s)\n" , busname);lib/librte_eal/common/eal_common_dev.c int rte_eal_dev_detach(struct rte_device *dev) · line 145
Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +8
-2-return -ENOENT ; - } +do {/* 2 iterations: first is to know string length */ + size = length +1 ; + length =snprintf (devargs, size,"%s:%s,%s" , busname, devname, drvargs); +if (length >= size) + devargs =malloc (length +1 ); +if (devargs ==NULL ) +return -ENOMEM ; + }while (size ==0 );I don't see a good reason for writing it this way.
You use an additional state (size) and complicate something that is pretty straightforward. To make sure no error was written here, I had to do step-by-step careful reading, this should not be required by clean code.
Quoted 2 lines
You should remove this loop, which then allow removing size, and forces using simple code-flow.
The only reason for this loop is to avoid duplicating the snprintf format in two calls.
It could be replaced by this:
length = snprintf(devargs, 0, "%s:%s,%s", busname, devname, drvargs); if (length < 0) return -EINVAL; devargs = malloc(length + 1); if (devargs == NULL) return -ENOMEM; snprintf(devargs, length + 1, "%s:%s,%s", busname, devname, drvargs);
Any preference?
Quoted 54 lines · Thomas Monjalon
04/10/2018 11:44, Gaëtan Rivet:
Quoted 37 lines · Thomas Monjalon
Quoted 19 lines
lib/librte_eal/common/eal_common_dev.c +3
-7@@ -129,46 +129,61 @@ int rte_eal_dev_detach(struct rte_device *dev)int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs) +const char *drvargs) { -struct rte_bus *bus; -struct rte_device *dev; -struct rte_devargs *da;int ret; +char *devargs =NULL ; +int size, length =-1 ; - bus =rte_bus_find_by_name (busname); -if (bus ==NULL ) { -RTE_LOG (ERR ,EAL ,"Cannot find bus (%s)\n" , busname);lib/librte_eal/common/eal_common_dev.c int rte_eal_dev_detach(struct rte_device *dev) · line 145
Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +8
-2-return -ENOENT ; - } +do {/* 2 iterations: first is to know string length */ + size = length +1 ; + length =snprintf (devargs, size,"%s:%s,%s" , busname, devname, drvargs); +if (length >= size) + devargs =malloc (length +1 ); +if (devargs ==NULL ) +return -ENOMEM ; + }while (size ==0 );I don't see a good reason for writing it this way.
You use an additional state (size) and complicate something that is pretty straightforward. To make sure no error was written here, I had to do step-by-step careful reading, this should not be required by clean code.Quoted 2 lines
You should remove this loop, which then allow removing size, and forces using simple code-flow.
The only reason for this loop is to avoid duplicating the snprintf format in two calls.
It could be replaced by this:
length = snprintf(devargs, 0, "%s:%s,%s", busname, devname, drvargs); if (length < 0) return -EINVAL; devargs = malloc(length + 1); if (devargs == NULL) return -ENOMEM; snprintf(devargs, length + 1, "%s:%s,%s", busname, devname, drvargs);
Quoted 3 lines
Any preference?
Yes, the second is cleaner IMO.
Signature · 2 lines
Gaëtan Rivet 6WIND
v6 cover eal: simplify devargs and hotplug functions
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
Instead of changing the existing hotplug functions, as in the RFC, some new experimental functions are added.
The old functions lose their experimental status in order to provide a non-experimental replacement for deprecated attach/detach functions.
It has been discussed briefly in the latest technical board meeting.
Changes in v6 - after Gaetan's review:
- bump ABI version of all buses (because of rte_device change)
- unroll snprintf loop in rte_eal_hotplug_add
Changes in v5:
- rte_devargs_remove is fixed in case of null devargs (patch 2)
- a pointer to the bus is added in rte_device (patch 3)
- rte_dev_remove is fixed in case of no devargs (patch 5)
Changes in v4 - after Andrew's review:
- add API changes in release notes (patches 1 & 2)
- fix memory leak in rte_eal_hotplug_add (patch 4)
Change in v3:
- fix null dereferencing in error path (patch 2)
Thomas Monjalon (5):
devargs: remove deprecated functions
devargs: simplify parameters of removal function
eal: add bus pointer in device structure
eal: remove experimental flag of hotplug functions
eal: simplify parameters of hotplug functions
doc/guides/rel_notes/release_18_11.rst | 23 ++++-- drivers/bus/dpaa/Makefile | 2 +- drivers/bus/dpaa/dpaa_bus.c | 2 + drivers/bus/dpaa/meson.build | 2 + drivers/bus/fslmc/Makefile | 2 +- drivers/bus/fslmc/fslmc_bus.c | 2 + drivers/bus/fslmc/meson.build | 2 + drivers/bus/ifpga/Makefile | 2 +- drivers/bus/ifpga/ifpga_bus.c | 6 +- drivers/bus/ifpga/meson.build | 2 + drivers/bus/pci/Makefile | 2 +- drivers/bus/pci/bsd/pci.c | 2 + drivers/bus/pci/linux/pci.c | 1 + drivers/bus/pci/meson.build | 2 + drivers/bus/pci/private.h | 2 + drivers/bus/vdev/Makefile | 2 +- drivers/bus/vdev/meson.build | 2 + drivers/bus/vdev/vdev.c | 9 +-- drivers/bus/vmbus/Makefile | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 1 + drivers/bus/vmbus/meson.build | 2 + drivers/bus/vmbus/private.h | 3 + drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 90 +++++++++++++-------- lib/librte_eal/common/eal_common_devargs.c | 41 ++-------- lib/librte_eal/common/include/rte_dev.h | 36 +++++++-- lib/librte_eal/common/include/rte_devargs.h | 81 +------------------ lib/librte_eal/rte_eal_version.map | 10 +-- 29 files changed, 155 insertions(+), 184 deletions(-)
Signature · 1 line
2.19.0
PATCH v6 1/5 devargs: remove deprecated functions
rte_eal_parse_devargs_str() does not support parsing the bus name at the start of devargs. So it was renamed and deprecated.
rte_eal_devargs_add(), rte_eal_devargs_type_count() and rte_eal_devargs_dump() were declared deprecated and had their implementation body renamed.
All these functions were deprecated in release 18.05.
---
The library version is not updated because it should be done in earlier patch https://patches.dpdk.org/patch/43903/
--- doc/guides/rel_notes/release_18_11.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 30 --------- lib/librte_eal/common/include/rte_devargs.h | 71 --------------------- lib/librte_eal/rte_eal_version.map | 4 -- 4 files changed, 5 insertions(+), 105 deletions(-)
doc/guides/rel_notes/release_18_11.rst +5 -0
@@ -118,6 +118,11 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* eal: The following devargs functions, which were deprecated in 18.05, + were removed in 18.11: + ``rte_eal_parse_devargs_str()``, ``rte_eal_devargs_add()``, + ``rte_eal_devargs_type_count()``, and ``rte_eal_devargs_dump()``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``.
lib/librte_eal/common/eal_common_devargs.c +0 -30
@@ -28,36 +28,6 @@ TAILQ_HEAD(rte_devargs_list, rte_devargs);struct rte_devargs_list devargs_list =TAILQ_HEAD_INITIALIZER (devargs_list); -int -rte_eal_parse_devargs_str (const char *devargs_str, -char **drvname,char **drvargs) -{ -char *sep; - -if ((devargs_str) ==NULL || (drvname) ==NULL || (drvargs ==NULL )) -return -1 ; - - *drvname =strdup (devargs_str); -if (*drvname ==NULL ) -return -1 ; - -/* set the first ',' to '\0' to split name and arguments */ - sep =strchr (*drvname,',' ); -if (sep !=NULL ) { - sep[0 ] ='\0' ; - *drvargs =strdup (sep +1 ); - }else { - *drvargs =strdup ("" ); - } - -if (*drvargs ==NULL ) { -free (*drvname); - *drvname =NULL ; -return -1 ; - } -return 0 ; -} -static size_t devargs_layer_count (const char *s) {
lib/librte_eal/common/include/rte_devargs.h +0 -71
95 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +0 -4
@@ -19,9 +19,6 @@ DPDK_2.0 { rte_dump_tailq; rte_eal_alarm_cancel; rte_eal_alarm_set; - rte_eal_devargs_add; - rte_eal_devargs_dump; - rte_eal_devargs_type_count; rte_eal_get_configuration; rte_eal_get_lcore_state; rte_eal_get_physmem_size;
@@ -32,7 +29,6 @@ DPDK_2.0 { rte_eal_lcore_role; rte_eal_mp_remote_launch; rte_eal_mp_wait_lcore; - rte_eal_parse_devargs_str; rte_eal_process_type; rte_eal_remote_launch; rte_eal_tailq_lookup;
Signature · 1 line
2.19.0
PATCH v6 2/5 devargs: simplify parameters of removal function
In reply to Thomas MonjalonThe function rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument.
The matching is still using string comparison of bus name and device name.
It is simpler and may allow a different devargs matching in future.
--- doc/guides/rel_notes/release_18_11.rst | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 11 +++++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 6 files changed, 18 insertions(+), 23 deletions(-)
doc/guides/rel_notes/release_18_11.rst +3 -0
@@ -123,6 +123,9 @@ API Changes ``rte_eal_parse_devargs_str()``, ``rte_eal_devargs_add()``, ``rte_eal_devargs_type_count()``, and ``rte_eal_devargs_dump()``. +* eal: The parameters of the function ``rte_devargs_remove()`` have changed + from bus and device names to ``struct rte_devargs``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``.
drivers/bus/ifpga/ifpga_bus.c +1 -4
@@ -361,7 +361,6 @@ static int ifpga_unplug(struct rte_device *dev) {struct rte_afu_device *afu_dev =NULL ; -struct rte_devargs *devargs =NULL ;int ret;if (dev ==NULL )
@@ -371,15 +370,13 @@ ifpga_unplug(struct rte_device *dev)if (!afu_dev)return -ENOENT ; - devargs = dev->devargs; - ret =ifpga_remove_driver (afu_dev);if (ret)return ret;TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->devargs);free (afu_dev);return 0 ;
drivers/bus/vdev/vdev.c +2 -6
@@ -249,7 +249,6 @@ int rte_vdev_init(const char *name, const char *args) { struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock);
@@ -260,9 +259,8 @@ rte_vdev_init(const char *name, const char *args)if (ret >0 )VDEV_LOG (ERR ,"no driver found for %s" , name);/* If fails, remove it from vdev list */ - devargs = dev->device.devargs;TAILQ_REMOVE (&vdev_device_list, dev, next); -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); } }
@@ -290,7 +288,6 @@ int rte_vdev_uninit(const char *name) {struct rte_vdev_device *dev; -struct rte_devargs *devargs;int ret;if (name ==NULL )
@@ -309,8 +306,7 @@ rte_vdev_uninit(const char *name) goto unlock;TAILQ_REMOVE (&vdev_device_list, dev, next); - devargs = dev->device.devargs; -rte_devargs_remove (devargs->bus->name, devargs->name); +rte_devargs_remove (dev->device.devargs);free (dev); unlock:
lib/librte_eal/common/eal_common_dev.c +2 -2
@@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn 0 ; err_devarg: -if (rte_devargs_remove (busname, devname)) { +if (rte_devargs_remove (da) !=0 ) {free (da->args);free (da); }
@@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)if (ret)RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , dev->name); -rte_devargs_remove (busname, devname); +rte_devargs_remove (dev->devargs);return ret; }
lib/librte_eal/common/eal_common_devargs.c +7 -4
@@ -263,7 +263,7 @@ rte_devargs_insert(struct rte_devargs *da) {int ret; - ret =rte_devargs_remove (da->bus->name, da->name); + ret =rte_devargs_remove (da);if (ret <0 )return ret;TAILQ_INSERT_TAIL (&devargs_list, da, next);
@@ -309,14 +309,17 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) } int __rte_experimental -rte_devargs_remove (const char *busname,const char *devname) +rte_devargs_remove (struct rte_devargs *devargs) {struct rte_devargs *d;void *tmp; +if (devargs ==NULL || devargs->bus ==NULL ) +return -1 ; + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { -if (strcmp (d->bus->name, busname) ==0 && -strcmp (d->name, devname) ==0 ) { +if (strcmp (d->bus->name, devargs->bus->name) ==0 && +strcmp (d->name, devargs->name) ==0 ) {TAILQ_REMOVE (&devargs_list, d, next);free (d->args);free (d);
lib/librte_eal/common/include/rte_devargs.h +3 -7
@@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* Its resources are freed. * If the devargs cannot be found, nothing happens. * -* @param busname -* bus name of the devargs to remove. -* -* @param devname -* device name of the devargs to remove. +* @param devargs +* The instance or a copy of devargs to remove. * * @return * 0 on success.
@@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);* >0 if the devargs was not within the user device list. */ __rte_experimental -int rte_devargs_remove(const char *busname, -const char *devname); +int rte_devargs_remove(struct rte_devargs *devargs);/** * Count the number of user devices of a specified type
Signature · 1 line
2.19.0
PATCH v6 3/5 eal: add bus pointer in device structure
In reply to Thomas MonjalonWhen a device is added with a devargs (hotplug or whitelist), the bus pointer can be retrieved via its devargs. But there is no such devargs.bus in case of standard scan.
A pointer to the rte_bus handle is added to rte_device. When a device is allocated (during a scan), the pointer to its bus is assigned.
It will make possible to remove a rte_device,
using the function pointer from its bus.
The function rte_bus_find_by_device() becomes useless, and may be removed later.
--- doc/guides/rel_notes/release_18_11.rst | 15 ++++++++++----- drivers/bus/dpaa/Makefile | 2 +- drivers/bus/dpaa/dpaa_bus.c | 2 ++ drivers/bus/dpaa/meson.build | 2 ++ drivers/bus/fslmc/Makefile | 2 +- drivers/bus/fslmc/fslmc_bus.c | 2 ++ drivers/bus/fslmc/meson.build | 2 ++ drivers/bus/ifpga/Makefile | 2 +- drivers/bus/ifpga/ifpga_bus.c | 1 + drivers/bus/ifpga/meson.build | 2 ++ drivers/bus/pci/Makefile | 2 +- drivers/bus/pci/bsd/pci.c | 2 ++ drivers/bus/pci/linux/pci.c | 1 + drivers/bus/pci/meson.build | 2 ++ drivers/bus/pci/private.h | 2 ++ drivers/bus/vdev/Makefile | 2 +- drivers/bus/vdev/meson.build | 2 ++ drivers/bus/vdev/vdev.c | 1 + drivers/bus/vmbus/Makefile | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 1 + drivers/bus/vmbus/meson.build | 2 ++ drivers/bus/vmbus/private.h | 3 +++ lib/librte_eal/common/include/rte_dev.h | 1 + 23 files changed, 44 insertions(+), 11 deletions(-)
doc/guides/rel_notes/release_18_11.rst +10 -5
@@ -164,6 +164,10 @@ ABI Changes ``rte_config`` structure on account of improving DPDK usability when using either ``--legacy-mem`` or ``--single-file-segments`` flags. +* eal: The structure ``rte_device`` got a new field to reference a ``rte_bus``. + It is changing the size of the ``struct rte_device`` and the inherited + device structures of all buses. + Removed Items -------------
@@ -199,11 +203,12 @@ The libraries prepended with a plus sign were incremented in this version. librte_bbdev.so.1 librte_bitratestats.so.2 librte_bpf.so.1 - librte_bus_dpaa.so.1 - librte_bus_fslmc.so.1 - librte_bus_pci.so.1 - librte_bus_vdev.so.1 - + librte_bus_vmbus.so.1 + + librte_bus_dpaa.so.2 + + librte_bus_fslmc.so.2 + + librte_bus_ifpga.so.2 + + librte_bus_pci.so.2 + + librte_bus_vdev.so.2 + + librte_bus_vmbus.so.2 librte_cfgfile.so.2 librte_cmdline.so.2 librte_common_octeontx.so.1
drivers/bus/dpaa/Makefile +1 -1
@@ -24,7 +24,7 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include # versioning export map EXPORT_MAP := rte_bus_dpaa_version.map -LIBABIVER := 1 +LIBABIVER := 2 # all source are stored in SRCS-y #
drivers/bus/dpaa/dpaa_bus.c +2 -0
@@ -165,6 +165,8 @@ dpaa_create_device_list(void) goto cleanup; } + dev->device.bus = &rte_dpaa_bus.bus; + cfg = &dpaa_netcfg->port_cfg[i]; fman_intf = cfg->fman_if;
drivers/bus/dpaa/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018 NXP +version = 2 + if host_machine.system() != 'linux' build = false endif
drivers/bus/fslmc/Makefile +1 -1
@@ -24,7 +24,7 @@ LDLIBS += -lrte_ethdev EXPORT_MAP := rte_bus_fslmc_version.map # library version -LIBABIVER := 1 +LIBABIVER := 2 SRCS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += \ qbman/qbman_portal.c \
drivers/bus/fslmc/fslmc_bus.c +2 -0
@@ -161,6 +161,8 @@ scan_one_fslmc_device(char *dev_name)return -ENOMEM ; } + dev->device.bus = &rte_fslmc_bus.bus; +/* Parse the device name and ID */ t_ptr =strtok (dup_dev_name,"." );if (!t_ptr) {
drivers/bus/fslmc/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018 NXP +version = 2 + if host_machine.system() != 'linux' build = false endif
drivers/bus/ifpga/Makefile +1 -1
@@ -19,7 +19,7 @@ LDLIBS += -lrte_kvargs EXPORT_MAP := rte_bus_ifpga_version.map # library version -LIBABIVER := 1 +LIBABIVER := 2 SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c
drivers/bus/ifpga/ifpga_bus.c +1 -0
@@ -142,6 +142,7 @@ ifpga_scan_one(struct rte_rawdev *rawdev,if (!afu_dev) goto end; + afu_dev->device.bus = &rte_ifpga_bus; afu_dev->device.devargs = devargs; afu_dev->device.numa_node =SOCKET_ID_ANY ; afu_dev->device.name = devargs->name;
drivers/bus/ifpga/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 Intel Corporation +version = 2 + deps += ['pci', 'kvargs', 'rawdev'] install_headers('rte_bus_ifpga.h') sources = files('ifpga_common.c', 'ifpga_bus.c')
drivers/bus/pci/Makefile +1 -1
@@ -4,7 +4,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_bus_pci.a -LIBABIVER := 1 +LIBABIVER := 2 EXPORT_MAP := rte_bus_pci_version.map CFLAGS := -I$(SRCDIR) $(CFLAGS)
drivers/bus/pci/bsd/pci.c +2 -0
@@ -223,6 +223,8 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) }memset (dev,0 ,sizeof (*dev)); + dev->device.bus = &rte_pci_bus.bus; + dev->addr.domain = conf->pc_sel.pc_domain; dev->addr.bus = conf->pc_sel.pc_bus; dev->addr.devid = conf->pc_sel.pc_dev;
drivers/bus/pci/linux/pci.c +1 -0
@@ -228,6 +228,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)return -1 ;memset (dev,0 ,sizeof (*dev)); + dev->device.bus = &rte_pci_bus.bus; dev->addr = *addr;/* get vendor id */
drivers/bus/pci/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +version = 2 + deps += ['pci'] install_headers('rte_bus_pci.h') sources = files('pci_common.c',
drivers/bus/pci/private.h +2 -0
@@ -15,6 +15,8 @@ extern struct rte_pci_bus rte_pci_bus;struct rte_pci_driver ;struct rte_pci_device ; +extern struct rte_pci_bus rte_pci_bus; +/** * Probe the PCI bus *
drivers/bus/vdev/Makefile +1 -1
@@ -16,7 +16,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API EXPORT_MAP := rte_bus_vdev_version.map # library version -LIBABIVER := 1 +LIBABIVER := 2 SRCS-y += vdev.c SRCS-y += vdev_params.c
drivers/bus/vdev/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +version = 2 + sources = files('vdev.c', 'vdev_params.c') install_headers('rte_bus_vdev.h')
drivers/bus/vdev/vdev.c +1 -0
@@ -456,6 +456,7 @@ vdev_scan(void)continue ; } + dev->device.bus = &rte_vdev_bus; dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; dev->device.name = devargs->name;
drivers/bus/vmbus/Makefile +1 -1
@@ -3,7 +3,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_bus_vmbus.a -LIBABIVER := 1 +LIBABIVER := 2 EXPORT_MAP := rte_bus_vmbus_version.map CFLAGS += -I$(SRCDIR)
drivers/bus/vmbus/linux/vmbus_bus.c +1 -0
@@ -229,6 +229,7 @@ vmbus_scan_one(const char *name)if (dev ==NULL )return -1 ; + dev->device.bus = &rte_vmbus_bus.bus; dev->device.name =strdup (name);if (!dev->device.name) goto error;
drivers/bus/vmbus/meson.build +2 -0
@@ -1,5 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause +version = 2 + allow_experimental_apis = true install_headers('rte_bus_vmbus.h','rte_vmbus_reg.h')
drivers/bus/vmbus/private.h +3 -0
@@ -10,11 +10,14 @@#include <sys/uio.h> #include <rte_log.h> #include <rte_vmbus_reg.h> +#include <rte_bus_vmbus.h> #ifndef PAGE_SIZE #define PAGE_SIZE 4096#endif +extern struct rte_vmbus_bus rte_vmbus_bus; +extern int vmbus_logtype_bus; #define VMBUS_LOG(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, vmbus_logtype_bus, "%s(): " fmt "\n", \
lib/librte_eal/common/include/rte_dev.h +1 -0
@@ -157,6 +157,7 @@ struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ const struct rte_driver *driver;/**< Associated driver */ +const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */ };
Signature · 1 line
2.19.0
PATCH v6 4/5 eal: remove experimental flag of hotplug functions
In reply to Thomas MonjalonThese functions are quite old and are the only available replacement for the deprecated attach/detach functions.
Note: some new functions may (again) replace these hotplug functions, in future, with better parameters.
--- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 11 ++--------- lib/librte_eal/rte_eal_version.map | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-)
lib/librte_eal/common/eal_common_dev.c +4 -3
@@ -127,8 +127,9 @@ int rte_eal_dev_detach(struct rte_device *dev)return ret; } -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs) +int +rte_eal_hotplug_add (const char *busname,const char *devname, +const char *devargs) {struct rte_bus *bus;struct rte_device *dev;
@@ -193,7 +194,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devnreturn ret; } -int __rte_experimental +int rte_eal_hotplug_remove (const char *busname,const char *devname) {struct rte_bus *bus;
lib/librte_eal/common/include/rte_dev.h +2 -9
@@ -190,9 +190,6 @@ __rte_deprecatedint rte_eal_dev_detach (struct rte_device *dev);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug add a given device to a specific bus. * * @param busname
@@ -205,13 +202,10 @@ int rte_eal_dev_detach(struct rte_device *dev);* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, +int rte_eal_hotplug_add (const char *busname,const char *devname,const char *devargs);/** -* @warning -* @b EXPERIMENTAL: this API may change without prior notice -* * Hotplug remove a given device from a specific bus. * * @param busname
@@ -221,8 +215,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn* @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_remove(const char *busname, -const char *devname); +int rte_eal_hotplug_remove (const char *busname,const char *devname);/** * Device comparison function.
lib/librte_eal/rte_eal_version.map +2 -2
@@ -261,6 +261,8 @@ DPDK_18.08 { DPDK_18.11 { global: + rte_eal_hotplug_add; + rte_eal_hotplug_remove; rte_strscpy; } DPDK_18.08;
@@ -288,8 +290,6 @@ EXPERIMENTAL { rte_devargs_remove; rte_devargs_type_count; rte_eal_cleanup; - rte_eal_hotplug_add; - rte_eal_hotplug_remove; rte_fbarray_attach; rte_fbarray_destroy; rte_fbarray_detach;
Signature · 1 line
2.19.0
PATCH v6 5/5 eal: simplify parameters of hotplug functions
In reply to Thomas MonjalonAll information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function.
And the syntax could evolve to be more complex and support matching multiple devices in one string.
That's why the bus name and device name should be removed from rte_eal_hotplug_add().
Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later.
When removing a device, we already know its rte_device handle which can be directly passed as parameter of rte_eal_hotplug_remove(). If the rte_device is not known, it can be retrieved with the devargs, by iterating in the device list (future RTE_DEV_FOREACH()). Similarly to the probing case, a new function is added
and used in the old one, which may be deprecated later.
The new function is used in failsafe, because the replacement is easy.
--- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 81 ++++++++++++++++--------- lib/librte_eal/common/include/rte_dev.h | 30 ++++++++- lib/librte_eal/rte_eal_version.map | 2 + 5 files changed, 84 insertions(+), 35 deletions(-)
drivers/net/failsafe/failsafe_eal.c +1 -2
@@ -144,8 +144,7 @@ fs_bus_uninit(struct rte_eth_dev *dev)int ret =0 ; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { - sdev_ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + sdev_ret =rte_dev_remove (sdev->dev);if (sdev_ret) {ERROR ("Failed to remove requested device %s (err: %d)" , sdev->dev->name, sdev_ret);
drivers/net/failsafe/failsafe_ether.c +1 -2
@@ -282,8 +282,7 @@ fs_dev_remove(struct sub_device *sdev) sdev->state =DEV_PROBED ;/* fallthrough */ case DEV_PROBED : - ret =rte_eal_hotplug_remove (sdev->bus->name, - sdev->dev->name); + ret =rte_dev_remove (sdev->dev);if (ret) {ERROR ("Bus detach failed for sub_device %u" ,SUB_ID (sdev));
lib/librte_eal/common/eal_common_dev.c +52 -29
138 lines not on this page · raw message
lib/librte_eal/common/include/rte_dev.h +28 -2
@@ -197,13 +197,26 @@ int rte_eal_dev_detach(struct rte_device *dev);* @param devname * The device name. Based on this device name, eal will identify a driver * capable of handling it and pass it to the driver probing function. -* @param devargs +* @param drvargs * Device arguments to be passed to the driver. * @return * 0 on success, negative on error. */ int rte_eal_hotplug_add (const char *busname,const char *devname, -const char *devargs); +const char *drvargs); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Add matching devices. +* +* @param devargs +* Device arguments including bus, class and driver properties. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_probe(const char *devargs);/** * Hotplug remove a given device from a specific bus.
@@ -217,6 +230,19 @@ int rte_eal_hotplug_add(const char *busname, const char *devname,*/ int rte_eal_hotplug_remove (const char *busname,const char *devname); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Remove one device. +* +* @param dev +* Data structure of the device to remove. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental rte_dev_remove(struct rte_device *dev); +/** * Device comparison function. *
lib/librte_eal/rte_eal_version.map +2 -0
@@ -281,6 +281,8 @@ EXPERIMENTAL { rte_dev_event_monitor_stop; rte_dev_iterator_init; rte_dev_iterator_next; + rte_dev_probe; + rte_dev_remove; rte_devargs_add; rte_devargs_dump; rte_devargs_insert;
Signature · 1 line
2.19.0
Re: [PATCH v6 0/5] eal: simplify devargs and hotplug functions
In reply to Thomas MonjalonQuoted 57 lines · On Sun, 7 Oct 2018 11:32:39 +0200 Thomas Monjalon <[email protected]> wrote:
This is a follow-up of an idea presented at Dublin during the "hotplug talk".
Instead of changing the existing hotplug functions, as in the RFC, some new experimental functions are added.
The old functions lose their experimental status in order to provide a non-experimental replacement for deprecated attach/detach functions.It has been discussed briefly in the latest technical board meeting.
Changes in v6 - after Gaetan's review:
- bump ABI version of all buses (because ofrte_devicechange)
- unroll snprintf loop inrte_eal_hotplug_addChanges in v5:
-rte_devargs_removeis fixed in case of null devargs (patch 2)
- a pointer to the bus is added inrte_device(patch 3)
-rte_dev_removeis fixed in case of no devargs (patch 5)Changes in v4 - after Andrew's review:
- add API changes in release notes (patches 1 & 2)
- fix memory leak inrte_eal_hotplug_add(patch 4)Change in v3:
- fix null dereferencing in error path (patch 2)Thomas Monjalon (5):
devargs: remove deprecated functions
devargs: simplify parameters of removal function
eal: add bus pointer in device structure
eal: remove experimental flag of hotplug functions
eal: simplify parameters of hotplug functionsdoc/guides/rel_notes/release_18_11.rst | 23 ++++-- drivers/bus/dpaa/Makefile | 2 +- drivers/bus/dpaa/dpaa_bus.c | 2 + drivers/bus/dpaa/meson.build | 2 + drivers/bus/fslmc/Makefile | 2 +- drivers/bus/fslmc/fslmc_bus.c | 2 + drivers/bus/fslmc/meson.build | 2 + drivers/bus/ifpga/Makefile | 2 +- drivers/bus/ifpga/ifpga_bus.c | 6 +- drivers/bus/ifpga/meson.build | 2 + drivers/bus/pci/Makefile | 2 +- drivers/bus/pci/bsd/pci.c | 2 + drivers/bus/pci/linux/pci.c | 1 + drivers/bus/pci/meson.build | 2 + drivers/bus/pci/private.h | 2 + drivers/bus/vdev/Makefile | 2 +- drivers/bus/vdev/meson.build | 2 + drivers/bus/vdev/vdev.c | 9 +-- drivers/bus/vmbus/Makefile | 2 +- drivers/bus/vmbus/linux/vmbus_bus.c | 1 + drivers/bus/vmbus/meson.build | 2 + drivers/bus/vmbus/private.h | 3 +
Quoted 9 lines
drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 90 +++++++++++++-------- lib/librte_eal/common/eal_common_devargs.c | 41 ++-------- lib/librte_eal/common/include/rte_dev.h | 36 +++++++-- lib/librte_eal/common/include/rte_devargs.h | 81 +------------------ lib/librte_eal/rte_eal_version.map | 10 +-- 29 files changed, 155 insertions(+), 184 deletions(-)
I like these changes.
I noticed there is only minimal places that devargs appear in the documentation. The relationship between whitelist and devargs is not obvious for new users.
The one place is in the documentation of the documentation! So you want to pull rte_eth_dev_attach from documentation.rst.
Thomas Monjalon
AppliedRe: [PATCH v6 0/5] eal: simplify devargs and hotplug functions
08/10/2018 23:45, Stephen Hemminger:
Quoted 38 lines
Quoted 28 lines · On Sun, 7 Oct 2018 11:32:39 +0200 Thomas Monjalon <[email protected]> wrote:
This is a follow-up of an idea presented at Dublin during the "hotplug talk".
Instead of changing the existing hotplug functions, as in the RFC, some new experimental functions are added.
The old functions lose their experimental status in order to provide a non-experimental replacement for deprecated attach/detach functions.It has been discussed briefly in the latest technical board meeting.
Changes in v6 - after Gaetan's review:
- bump ABI version of all buses (because ofrte_devicechange)
- unroll snprintf loop inrte_eal_hotplug_addChanges in v5:
-rte_devargs_removeis fixed in case of null devargs (patch 2)
- a pointer to the bus is added inrte_device(patch 3)
-rte_dev_removeis fixed in case of no devargs (patch 5)Changes in v4 - after Andrew's review:
- add API changes in release notes (patches 1 & 2)
- fix memory leak inrte_eal_hotplug_add(patch 4)Change in v3:
- fix null dereferencing in error path (patch 2)Quoted 6 lines
Thomas Monjalon (5):
devargs: remove deprecated functions
devargs: simplify parameters of removal function
eal: add bus pointer in device structure
eal: remove experimental flag of hotplug functions
eal: simplify parameters of hotplug functions
Quoted 3 lines
I like these changes.
Reviewed-by Stephen Hemminger <[email protected]>
Applied