From: Jan Blunck Date: Fri, 30 Jun 2017 18:19:38 +0000 (+0200) Subject: bus: introduce device plug/unplug X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7c8810f43f6eb2620115847aff8f8b86b28fa4ca;p=dpdk.git bus: introduce device plug/unplug This allows the buses to plug and probe specific devices. This is meant to be a building block for hotplug support. Signed-off-by: Jan Blunck --- diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index bf2b138a6e..87b0c6e6fa 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -51,6 +51,8 @@ rte_bus_register(struct rte_bus *bus) RTE_VERIFY(bus->scan); RTE_VERIFY(bus->probe); RTE_VERIFY(bus->find_device); + /* Buses supporting driver plug also require unplug. */ + RTE_VERIFY(!bus->plug || bus->unplug); TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name); diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 509292d134..2f1c911f7e 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -107,6 +107,36 @@ typedef struct rte_device * (*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data); +/** + * Implementation specific probe function which is responsible for linking + * devices on that bus with applicable drivers. + * + * @param dev + * Device pointer that was returned by a previous call to find_device. + * + * @param devargs + * Device declaration. + * + * @return + * 0 on success. + * !0 on error. + */ +typedef int (*rte_bus_plug_t)(struct rte_device *dev, + const char *devargs); + +/** + * Implementation specific remove function which is responsible for unlinking + * devices on that bus from assigned driver. + * + * @param dev + * Device pointer that was returned by a previous call to find_device. + * + * @return + * 0 on success. + * !0 on error. + */ +typedef int (*rte_bus_unplug_t)(struct rte_device *dev); + /** * A structure describing a generic bus. */ @@ -116,6 +146,8 @@ struct rte_bus { rte_bus_scan_t scan; /**< Scan for devices attached to bus */ rte_bus_probe_t probe; /**< Probe devices on bus */ rte_bus_find_device_t find_device; /**< Find a device on the bus */ + rte_bus_plug_t plug; /**< Probe single device for drivers */ + rte_bus_unplug_t unplug; /**< Remove single device from driver */ }; /**