[dpdk-dev] [PATCH v1 2/8] bus: introduce opaque control framework

Gaetan Rivet gaetan.rivet at 6wind.com
Thu Oct 12 10:18:24 CEST 2017


New configuration elements are added to the buses. They make the ABI
unstable and will continue to do so.

This new control scheme allows to add new bus operators without
breaking the ABI and by only expanding the API.

This helps having more stability in core EAL subsystems, while allowing
flexibility for future evolutions.

Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
---
 lib/librte_eal/common/eal_common_bus.c  |  9 +++++++
 lib/librte_eal/common/include/rte_bus.h | 46 +++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 3c66a02..65d7229 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -42,6 +42,13 @@
 struct rte_bus_list rte_bus_list =
 	TAILQ_HEAD_INITIALIZER(rte_bus_list);
 
+static rte_bus_ctrl_t
+rte_bus_default_ctrl(enum rte_bus_ctrl_op op __rte_unused,
+		     enum rte_bus_ctrl_item item __rte_unused)
+{
+	return NULL;
+}
+
 void
 rte_bus_register(struct rte_bus *bus)
 {
@@ -53,6 +60,8 @@ rte_bus_register(struct rte_bus *bus)
 	RTE_VERIFY(bus->find_device);
 	/* Buses supporting driver plug also require unplug. */
 	RTE_VERIFY(!bus->plug || bus->unplug);
+	if (bus->ctrl == NULL)
+		bus->ctrl = &rte_bus_default_ctrl;
 
 	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 331d954..bd3c28e 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -183,6 +183,51 @@ struct rte_bus_conf {
 	enum rte_bus_probe_mode probe_mode; /**< Probe policy. */
 };
 
+/**
+ * Bus configuration items.
+ */
+enum rte_bus_ctrl_item {
+	RTE_BUS_CTRL_PROBE_MODE = 0,
+	RTE_BUS_CTRL_ITEM_MAX,
+};
+
+/**
+ * Bus configuration operations.
+ */
+enum rte_bus_ctrl_op {
+	RTE_BUS_CTRL_GET = 0,
+	RTE_BUS_CTRL_SET,
+	RTE_BUS_CTRL_RESET,
+	RTE_BUS_CTRL_OP_MAX,
+};
+
+/**
+ * Operator for a particular rte_bus configuration item.
+ *
+ * @param arg
+ *    Operation parameter.
+ *
+ * @return
+ *	0 on success
+ *	!0 otherwise
+ */
+typedef int (*rte_bus_ctrl_t)(void *arg);
+
+/**
+ * Accessor to bus configuration operators.
+ *
+ * @param op
+ *	Operation type.
+ *
+ * @param item
+ *	Operation element.
+ *
+ * @return
+ *	Operator function on success.
+ *	NULL if this item is not supported.
+ */
+typedef rte_bus_ctrl_t (*rte_bus_ctrl_get_t)(enum rte_bus_ctrl_op op,
+					     enum rte_bus_ctrl_item item);
 
 /**
  * Get common iommu class of the all the devices on the bus. The bus may
@@ -211,6 +256,7 @@ struct rte_bus {
 	rte_bus_parse_t parse;       /**< Parse a device name */
 	struct rte_bus_conf conf;    /**< Bus configuration */
 	rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */
+	rte_bus_ctrl_get_t ctrl;     /**< Get control operators */
 };
 
 /**
-- 
2.1.4



More information about the dev mailing list