[dpdk-dev,05/13] eal/bus: add support for inserting a device on a bus
Checks
Commit Message
Rather than adding a device to tail, a new device might be added to the
list (pivoted on bus) at a predefined position, for example, adding it
order of addressing.
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
lib/librte_eal/common/eal_common_bus.c | 11 +++++++++++
lib/librte_eal/common/include/rte_bus.h | 18 ++++++++++++++++++
2 files changed, 29 insertions(+)
@@ -58,6 +58,17 @@ rte_eal_bus_add_device(struct rte_bus *bus, struct rte_device *dev)
dev->bus = bus;
}
+void
+rte_eal_bus_insert_device(struct rte_bus *bus, struct rte_device *old_dev,
+ struct rte_device *new_dev)
+{
+ RTE_VERIFY(bus);
+ RTE_VERIFY(old_dev);
+ RTE_VERIFY(new_dev);
+
+ TAILQ_INSERT_BEFORE(old_dev, new_dev, next);
+}
+
/** @internal
* Remove a device from its bus.
*/
@@ -128,6 +128,24 @@ void
rte_eal_bus_add_device(struct rte_bus *bus, struct rte_device *dev);
/** @internal
+ * Rather than adding a device to tail, insert at a predefined location.
+ * This is specifically useful for update device cases, or where addition
+ * of devices in the list needs to be ordered (addressing, for example).
+ *
+ * @param bus
+ * Handle for bus on which device is to be added
+ * @param old_dev
+ * Existing rte_device object before which new device needs to be added
+ * @param new_dev
+ * Object for device to be added before old_dev
+ * @return
+ * void
+ */
+void
+rte_eal_bus_insert_device(struct rte_bus *bus, struct rte_device *old_device,
+ struct rte_device *new_device);
+
+/** @internal
* Remove a device from its bus.
*
* @param dev