From: Jan Blunck <jblu...@infradead.org> Signed-off-by: Jan Blunck <jblu...@infradead.org> Signed-off-by: Gaetan Rivet <gaetan.ri...@6wind.com> --- lib/librte_eal/common/eal_common_bus.c | 3 +++ lib/librte_eal/common/include/rte_bus.h | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 632a6e7..4063897 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -51,6 +51,9 @@ rte_bus_register(struct rte_bus *bus) RTE_VERIFY(bus->scan); RTE_VERIFY(bus->probe); + /* Buses supporting hotplug 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 b56018f..3c59fc2 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -88,6 +88,24 @@ typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_match_t match, const void *data); /** + * Implementation specific probe function which is responsible for linking + * devices on that bus with applicable drivers. + * The plugged device might already have been used previously by the bus, + * in which case some buses might prefer to detect and re-use the relevant + * information pertaining to this device. + */ +typedef int (*rte_bus_plug_t)(struct rte_devargs *da); + +/** + * Implementation specific remove function which is responsible for unlinking + * devices on that bus from assigned driver. + * Some buses will expect the same device to be plugged-back in eventually. + * The decision to release the associated meta-data (full-fledged bus-specific + * device representation) is left to the discretion of the bus. + */ +typedef int (*rte_bus_unplug_t)(struct rte_devargs *da); + +/** * A structure describing a generic bus. */ struct rte_bus { @@ -96,6 +114,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 device on bus */ + rte_bus_plug_t plug; /**< Probe single device for drivers */ + rte_bus_unplug_t unplug; /**< Remove single device from driver */ }; /** -- 2.1.4