[dpdk-dev] [PATCH 1/2] eal: expose device states in rte device

Jeff Guo jia.guo at intel.com
Wed Nov 7 10:41:30 CET 2018


Since the hotplug API and device event API have make public, so in order
to let applications or driver deal with device directly, it would be
helpful if the states of device could be exposed, especially for hotplug
process.

This patch will add some devices states in rte device structure
to recode the device's current status, such as “RTE_DEV_UNUSED”,
“RTE_DEV_ATTACHED” and “RTE_DEV_REMOVED”.

Signed-off-by: Jeff Guo <jia.guo at intel.com>
---
 lib/librte_eal/common/include/rte_dev.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index cd6c187..1bab0dd 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -151,6 +151,18 @@ struct rte_driver {
 #define RTE_DEV_NAME_MAX_LEN 64
 
 /**
+ * Possible states of an rte devcie.
+ */
+enum rte_dev_state {
+	/** Device is unused before being hotplug add. */
+	RTE_DEV_UNUSED = 0,
+	/** Device is attached when allocated in probing. */
+	RTE_DEV_ATTACHED,
+	/** Device is in removed state when plug-out is detected. */
+	RTE_DEV_REMOVED,
+};
+
+/**
  * A structure describing a generic device.
  */
 struct rte_device {
@@ -160,6 +172,7 @@ struct rte_device {
 	const struct rte_bus *bus;    /**< Bus handle assigned on scan */
 	int numa_node;                /**< NUMA node connection */
 	struct rte_devargs *devargs;  /**< Arguments for latest probing */
+	enum rte_dev_state state; /**< Flag indicating the device state */
 };
 
 /**
-- 
2.7.4



More information about the dev mailing list