From: Kevin Laatz <kevin.la...@intel.com>

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.la...@intel.com>
---
 lib/dmadev/rte_dmadev.c      | 11 +++++++++++
 lib/dmadev/rte_dmadev.h      | 19 +++++++++++++++++++
 lib/dmadev/rte_dmadev_core.h |  5 +++++
 lib/dmadev/version.map       |  1 +
 4 files changed, 36 insertions(+)

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index ab45928efb..6494871f05 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -573,6 +573,17 @@ dmadev_dump_capability(FILE *f, uint64_t dev_capa)
        fprintf(f, "\n");
 }
 
+int
+rte_dmadev_burst_capacity(uint16_t dev_id, uint16_t vchan)
+{
+       const struct rte_dmadev *dev = &rte_dmadevices[dev_id];
+
+       RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
+
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->burst_capacity, -ENOTSUP);
+       return (*dev->dev_ops->burst_capacity)(dev, vchan);
+}
+
 int
 rte_dmadev_dump(uint16_t dev_id, FILE *f)
 {
diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
index 39d73872c8..8b84914810 100644
--- a/lib/dmadev/rte_dmadev.h
+++ b/lib/dmadev/rte_dmadev.h
@@ -673,6 +673,25 @@ __rte_experimental
 int
 rte_dmadev_vchan_status(uint16_t dev_id, uint16_t vchan, enum 
rte_dmadev_vchan_status *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 on success.
+ *   - -ENOTSUP: if not supported by the device.
+ */
+__rte_experimental
+int
+rte_dmadev_burst_capacity(uint16_t dev_id, uint16_t vchan);
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h
index 3c9d698044..2756936798 100644
--- a/lib/dmadev/rte_dmadev_core.h
+++ b/lib/dmadev/rte_dmadev_core.h
@@ -52,6 +52,10 @@ typedef int (*rte_dmadev_stats_get_t)(const struct 
rte_dmadev *dev,
 typedef int (*rte_dmadev_stats_reset_t)(struct rte_dmadev *dev, uint16_t 
vchan);
 /**< @internal Used to reset basic statistics. */
 
+typedef uint16_t (*rte_dmadev_burst_capacity_t)(const struct rte_dmadev *dev,
+                       uint16_t vchan);
+/** < @internal Used to check the remaining space in descriptor ring. */
+
 typedef int (*rte_dmadev_dump_t)(const struct rte_dmadev *dev, FILE *f);
 /**< @internal Used to dump internal information. */
 
@@ -114,6 +118,7 @@ struct rte_dmadev_ops {
        rte_dmadev_stats_get_t      stats_get;
        rte_dmadev_stats_reset_t    stats_reset;
 
+       rte_dmadev_burst_capacity_t burst_capacity;
        rte_dmadev_vchan_status_t   vchan_status;
 
        rte_dmadev_dump_t           dev_dump;
diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
index 10eeb0f7a3..56cb279e8f 100644
--- a/lib/dmadev/version.map
+++ b/lib/dmadev/version.map
@@ -1,6 +1,7 @@
 EXPERIMENTAL {
        global:
 
+       rte_dmadev_burst_capacity;
        rte_dmadev_close;
        rte_dmadev_completed;
        rte_dmadev_completed_status;
-- 
2.30.2

Reply via email to