New upstream version 18.11-rc1
[deb_dpdk.git] / lib / librte_eal / common / include / rte_bus.h
index b7b5b08..6be4b5c 100644 (file)
@@ -167,6 +167,35 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
  */
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
+/**
+ * Implement a specific hot-unplug handler, which is responsible for
+ * handle the failure when device be hot-unplugged. When the event of
+ * hot-unplug be detected, it could call this function to handle
+ * the hot-unplug failure and avoid app crash.
+ * @param dev
+ *     Pointer of the device structure.
+ *
+ * @return
+ *     0 on success.
+ *     !0 on error.
+ */
+typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev);
+
+/**
+ * Implement a specific sigbus handler, which is responsible for handling
+ * the sigbus error which is either original memory error, or specific memory
+ * error that caused of device be hot-unplugged. When sigbus error be captured,
+ * it could call this function to handle sigbus error.
+ * @param failure_addr
+ *     Pointer of the fault address of the sigbus error.
+ *
+ * @return
+ *     0 for success handle the sigbus for hot-unplug.
+ *     1 for not process it, because it is a generic sigbus error.
+ *     -1 for failed to handle the sigbus for hot-unplug.
+ */
+typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
+
 /**
  * Bus scan policies
  */
@@ -212,6 +241,11 @@ struct rte_bus {
        struct rte_bus_conf conf;    /**< Bus configuration */
        rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */
        rte_dev_iterate_t dev_iterate; /**< Device iterator. */
+       rte_bus_hot_unplug_handler_t hot_unplug_handler;
+                               /**< handle hot-unplug failure on the bus */
+       rte_bus_sigbus_handler_t sigbus_handler;
+                                       /**< handle sigbus error on the bus */
+
 };
 
 /**