[dpdk-dev] [PATCH v7 14/15] dev: use new hotplug API in attach / detach
Thomas Monjalon
thomas at monjalon.net
Thu Jun 29 23:05:00 CEST 2017
29/06/2017 20:22, Jan Blunck:
> Using the new generic API allows attach and detach to be backwards
> compatible while decoupling from the concrete bus implementations.
>
> Signed-off-by: Jan Blunck <jblunck at infradead.org>
> ---
> int rte_eal_dev_attach(const char *name, const char *devargs)
> {
> - struct rte_pci_addr addr;
> + int ret;
>
> if (name == NULL || devargs == NULL) {
> RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n");
> return -EINVAL;
> }
>
> - if (eal_parse_pci_DomBDF(name, &addr) == 0) {
> - if (rte_pci_probe_one(&addr) < 0)
> - goto err;
> + ret = rte_eal_hotplug_add("PCI", name, devargs);
> + if (ret && ret != -EINVAL)
> + return ret;
>
> - } else {
> - if (rte_vdev_init(name, devargs))
> - goto err;
> - }
> + /*
> + * If we haven't found a bus device the user meant to "hotplug" a
> + * virtual device instead.
> + */
> + ret = rte_vdev_init(name, devargs);
> + if (ret)
> + RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
> + name);
> + return ret;
> +}
I really don't like this function.
It is not really decoupled from the buses (cf "PCI" and rte_vdev_init).
However I think it is acceptable if it is explictly deprecated
and kept only for the legacy rte_eth_dev_attach() function.
More information about the dev
mailing list