]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/spdk/dpdk/lib/librte_eal/common/include/rte_bus.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / common / include / rte_bus.h
index b7b5b0848bf07ef67fe8fecb5948a9c1c5102bfc..4faf2d20a0b16fc8cd9c23e3399f61b58ce46301 100644 (file)
@@ -167,6 +167,77 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
  */
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
+/**
+ * Device level DMA map function.
+ * After a successful call, the memory segment will be mapped to the
+ * given device.
+ *
+ * @param dev
+ *     Device pointer.
+ * @param addr
+ *     Virtual address to map.
+ * @param iova
+ *     IOVA address to map.
+ * @param len
+ *     Length of the memory segment being mapped.
+ *
+ * @return
+ *     0 if mapping was successful.
+ *     Negative value and rte_errno is set otherwise.
+ */
+typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr,
+                                 uint64_t iova, size_t len);
+
+/**
+ * Device level DMA unmap function.
+ * After a successful call, the memory segment will no longer be
+ * accessible by the given device.
+ *
+ * @param dev
+ *     Device pointer.
+ * @param addr
+ *     Virtual address to unmap.
+ * @param iova
+ *     IOVA address to unmap.
+ * @param len
+ *     Length of the memory segment being mapped.
+ *
+ * @return
+ *     0 if un-mapping was successful.
+ *     Negative value and rte_errno is set otherwise.
+ */
+typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr,
+                                  uint64_t iova, size_t len);
+
+/**
+ * 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
  */
@@ -209,9 +280,16 @@ struct rte_bus {
        rte_bus_plug_t plug;         /**< Probe single device for drivers */
        rte_bus_unplug_t unplug;     /**< Remove single device from driver */
        rte_bus_parse_t parse;       /**< Parse a device name */
+       rte_dev_dma_map_t dma_map;   /**< DMA map for device in the bus */
+       rte_dev_dma_unmap_t dma_unmap; /**< DMA unmap for device in the 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 */
+
 };
 
 /**