From: Gaetan Rivet Date: Sat, 15 Jul 2017 17:56:35 +0000 (+0200) Subject: bus/vdev: implement plug operation X-Git-Tag: spdx-start~2469 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=925288bee3e74e914338bda14952b10c67467f41;p=dpdk.git bus/vdev: implement plug operation This method must be implemented to allow using a unified, generic API to hotplug devices, including virtual ones. VDEV devices actually exist unattached after performing a scan on the rte_devargs list. As such it makes sense to be able to perform a device hotplug afterward. Finally, missing this generic interface forces the EAL to be dependent on vdev-specific API, which hinders the plan of moving the vdev bus to drivers/bus. Signed-off-by: Gaetan Rivet --- diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index e00dda9aa3..85cf3fc62f 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -318,13 +318,15 @@ vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, return NULL; } +static int +vdev_plug(struct rte_device *dev, const char *args __rte_unused) +{ + return vdev_probe_all_drivers(RTE_DEV_TO_VDEV(dev)); +} + static int vdev_unplug(struct rte_device *dev) { - /* - * The virtual bus doesn't support 'unattached' devices so this is - * actually equal to hotplugging removal of it. - */ return rte_vdev_uninit(dev->name); } @@ -332,7 +334,7 @@ static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, .find_device = vdev_find_device, - /* .plug = NULL, see comment on vdev_unplug */ + .plug = vdev_plug, .unplug = vdev_unplug, .parse = vdev_parse, }; diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index fc24298f23..29f5a52309 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -46,6 +46,13 @@ struct rte_vdev_device { struct rte_device device; /**< Inherit core device */ }; +/** + * @internal + * Helper macro for drivers that need to convert to struct rte_vdev_device. + */ +#define RTE_DEV_TO_VDEV(ptr) \ + container_of(ptr, struct rte_vdev_device, device) + static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {