[dpdk-dev] [PATCH v6 05/11] bus: introduce hotplug functionality
Gaetan Rivet
gaetan.rivet at 6wind.com
Tue Jun 27 18:11:12 CEST 2017
From: Jan Blunck <jblunck at infradead.org>
Signed-off-by: Jan Blunck <jblunck at infradead.org>
Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
---
lib/librte_eal/common/eal_common_bus.c | 2 ++
lib/librte_eal/common/include/rte_bus.h | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index dde6c83..83d9c07 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -50,6 +50,8 @@ rte_bus_register(struct rte_bus *bus)
/* A bus should mandatorily have the scan implemented */
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 9aa047d..8c2d19c 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -109,6 +109,35 @@ typedef struct rte_device *
const struct rte_device *start);
/**
+ * 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.
+ *
+ * @param da
+ * Device declaration.
+ *
+ * @return
+ * The pointer to a valid rte_device usable by the bus on success.
+ * NULL on error. rte_errno is then set.
+ */
+typedef struct rte_device * (*rte_bus_plug_t)(struct rte_devargs *da);
+
+/**
+ * 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 device plug call.
+ *
+ * @return
+ * 0 on success.
+ * !0 on error. rte_errno is then set.
+ */
+typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
+
+/**
* A structure describing a generic bus.
*/
struct rte_bus {
@@ -117,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 */
};
/**
--
2.1.4
More information about the dev
mailing list