[dpdk-dev] [PATCH 05/13] eal/bus: add support for inserting a device on a bus

Shreyansh Jain shreyansh.jain at nxp.com
Sun Dec 4 11:11:20 CET 2016


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 at 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(+)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 2473fe4..3be9c77 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -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.
  */
diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index b41105c..d1bd2e8 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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
-- 
2.7.4



More information about the dev mailing list