dmadev: add burst capacity API
authorKevin Laatz <kevin.laatz@intel.com>
Wed, 13 Oct 2021 15:17:26 +0000 (16:17 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 18 Oct 2021 09:17:30 +0000 (11:17 +0200)
Add a burst capacity check API to the dmadev library. This API is useful to
applications which need to how many descriptors can be enqueued in the
current batch. For example, it could be used to determine whether all
segments of a multi-segment packet can be enqueued in the same batch or not
(to avoid half-offload of the packet).

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
drivers/dma/skeleton/skeleton_dmadev.c
lib/dmadev/rte_dmadev.c
lib/dmadev/rte_dmadev.h
lib/dmadev/rte_dmadev_core.h
lib/dmadev/version.map

index dd2f1c9..2952417 100644 (file)
@@ -431,6 +431,15 @@ skeldma_completed_status(void *dev_private,
        return count;
 }
 
+static uint16_t
+skeldma_burst_capacity(const void *dev_private, uint16_t vchan)
+{
+       const struct skeldma_hw *hw = dev_private;
+
+       RTE_SET_USED(vchan);
+       return rte_ring_count(hw->desc_empty);
+}
+
 static const struct rte_dma_dev_ops skeldma_ops = {
        .dev_info_get     = skeldma_info_get,
        .dev_configure    = skeldma_configure,
@@ -469,6 +478,7 @@ skeldma_create(const char *name, struct rte_vdev_device *vdev, int lcore_id)
        dev->fp_obj->submit = skeldma_submit;
        dev->fp_obj->completed = skeldma_completed;
        dev->fp_obj->completed_status = skeldma_completed_status;
+       dev->fp_obj->burst_capacity = skeldma_burst_capacity;
 
        hw = dev->data->dev_private;
        hw->lcore_id = lcore_id;
index 3f9154e..c737cc6 100644 (file)
@@ -830,6 +830,14 @@ dummy_completed_status(__rte_unused void *dev_private,
        return 0;
 }
 
+static uint16_t
+dummy_burst_capacity(__rte_unused const void *dev_private,
+                    __rte_unused uint16_t vchan)
+{
+       RTE_DMA_LOG(ERR, "burst_capacity is not configured or not supported.");
+       return 0;
+}
+
 static void
 dma_fp_object_dummy(struct rte_dma_fp_object *obj)
 {
@@ -840,4 +848,5 @@ dma_fp_object_dummy(struct rte_dma_fp_object *obj)
        obj->submit           = dummy_submit;
        obj->completed        = dummy_completed;
        obj->completed_status = dummy_completed_status;
+       obj->burst_capacity   = dummy_burst_capacity;
 }
index e35aca7..a0824be 100644 (file)
@@ -1076,6 +1076,35 @@ rte_dma_completed_status(int16_t dev_id, uint16_t vchan,
                                        last_idx, status);
 }
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Check remaining capacity in descriptor ring for the current burst.
+ *
+ * @param dev_id
+ *   The identifier of the device.
+ * @param vchan
+ *   The identifier of virtual DMA channel.
+ *
+ * @return
+ *   - Remaining space in the descriptor ring for the current burst.
+ *   - 0 on error
+ */
+__rte_experimental
+static inline uint16_t
+rte_dma_burst_capacity(int16_t dev_id, uint16_t vchan)
+{
+       struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id];
+
+#ifdef RTE_DMADEV_DEBUG
+       if (!rte_dma_is_valid(dev_id))
+               return 0;
+       RTE_FUNC_PTR_OR_ERR_RET(*obbj->burst_capacity, 0);
+#endif
+       return (*obj->burst_capacity)(obj->dev_private, vchan);
+}
+
 #ifdef __cplusplus
 }
 #endif
index 236d9d3..e42d873 100644 (file)
@@ -47,6 +47,9 @@ typedef uint16_t (*rte_dma_completed_status_t)(void *dev_private,
                        uint16_t vchan, const uint16_t nb_cpls,
                        uint16_t *last_idx, enum rte_dma_status_code *status);
 
+/** @internal Used to check the remaining space in descriptor ring. */
+typedef uint16_t (*rte_dma_burst_capacity_t)(const void *dev_private, uint16_t vchan);
+
 /**
  * @internal
  * Fast-path dmadev functions and related data are hold in a flat array.
@@ -69,6 +72,7 @@ struct rte_dma_fp_object {
        rte_dma_submit_t           submit;
        rte_dma_completed_t        completed;
        rte_dma_completed_status_t completed_status;
+       rte_dma_burst_capacity_t   burst_capacity;
 } __rte_aligned(128);
 
 extern struct rte_dma_fp_object *rte_dma_fp_objs;
index 8785e14..4bbfdd5 100644 (file)
@@ -1,6 +1,7 @@
 EXPERIMENTAL {
        global:
 
+       rte_dma_burst_capacity;
        rte_dma_close;
        rte_dma_completed;
        rte_dma_completed_status;