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 <gaetan.rivet@6wind.com>
This commit is contained in:
Gaetan Rivet 2017-07-15 19:56:35 +02:00 committed by Thomas Monjalon
parent 501d4a65c8
commit 925288bee3
2 changed files with 14 additions and 5 deletions

View File

@ -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,
};

View File

@ -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)
{