[dpdk-dev] [PATCH v3 4/4] eal: simplify parameters of hotplug functions
Andrew Rybchenko
arybchenko at solarflare.com
Mon Oct 1 13:26:48 CEST 2018
On 9/28/18 7:21 PM, Thomas Monjalon wrote:
> 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 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.
>
> Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
Minor memory leak below, when fixed:
Reviewed-by: Andrew Rybchenko <arybchenko at solarflare.com>
<...>
> diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
> index a9be58edf..b40e4c0d0 100644
> --- a/lib/librte_eal/common/eal_common_dev.c
> +++ b/lib/librte_eal/common/eal_common_dev.c
> @@ -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)
> + 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.
> +}
<...>
More information about the dev
mailing list