X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_vdev.c;h=baf3c5bfa23ff65705dfb4877a4d5ccab7fcbcfc;hb=791aa7f4a44e364367eaf9956a7a295ff524a4f5;hp=0037a6416e3d2a7e1c72bee0c3d532c1d08327e6;hpb=2f6fec53909b90fa653b5d6ace0c4aeb4cce25b7;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 0037a6416e..baf3c5bfa2 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -35,14 +35,17 @@ #include #include #include +#include #include #include +#include #include #include #include #include #include +#include /** Double linked list of virtual device drivers. */ TAILQ_HEAD(vdev_device_list, rte_vdev_device); @@ -52,14 +55,10 @@ static struct vdev_device_list vdev_device_list = struct vdev_driver_list vdev_driver_list = TAILQ_HEAD_INITIALIZER(vdev_driver_list); -static void rte_vdev_bus_register(void); - /* register a driver */ void rte_vdev_register(struct rte_vdev_driver *driver) { - rte_vdev_bus_register(); - TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next); } @@ -338,21 +337,41 @@ vdev_probe(void) return 0; } -static struct rte_bus rte_vdev_bus = { - .scan = vdev_scan, - .probe = vdev_probe, -}; +static struct rte_device * +vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, + const void *data) +{ + struct rte_vdev_device *dev; + bool start_found = !start; -RTE_INIT(rte_vdev_bus_register); + TAILQ_FOREACH(dev, &vdev_device_list, next) { + if (start_found == 0) { + if (&dev->device == start) + start_found = 1; + continue; + } + if (cmp(&dev->device, data) == 0) + return &dev->device; + } + return NULL; +} -static void rte_vdev_bus_register(void) +static int +vdev_unplug(struct rte_device *dev) { - static int registered; + /* + * The virtual bus doesn't support 'unattached' devices so this is + * actually equal to hotplugging removal of it. + */ + return rte_vdev_uninit(dev->name); +} - if (registered) - return; +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 */ + .unplug = vdev_unplug, +}; - registered = 1; - rte_vdev_bus.name = RTE_STR(virtual); - rte_bus_register(&rte_vdev_bus); -} +RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus);