diff mbox series

[v6,03/13] dmadev: add burst capacity API

Message ID 20210924102942.2878051-4-bruce.richardson@intel.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series add test suite for DMA drivers | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson Sept. 24, 2021, 10:29 a.m. UTC
From: Kevin Laatz <kevin.laatz@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.laatz@intel.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
---
 lib/dmadev/rte_dmadev.h      | 31 +++++++++++++++++++++++++++++++
 lib/dmadev/rte_dmadev_core.h |  6 ++++--
 lib/dmadev/version.map       |  1 +
 3 files changed, 36 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
index f4c6546d87..bdba19b947 100644
--- a/lib/dmadev/rte_dmadev.h
+++ b/lib/dmadev/rte_dmadev.h
@@ -1100,6 +1100,37 @@  rte_dma_completed_status(int16_t dev_id, uint16_t vchan,
 	return (*dev->completed_status)(dev, vchan, nb_cpls, 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)
+{
+	const struct rte_dma_dev *dev = &rte_dma_devices[dev_id];
+
+#ifdef RTE_DMADEV_DEBUG
+	if (!rte_dma_is_valid(dev_id) || !dev->data->dev_started ||
+	    vchan >= dev->data->dev_conf.nb_vchans ||
+	    nb_cpls == 0 || status == NULL)
+		return 0;
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->burst_capacity, 0);
+#endif
+	return (*dev->burst_capacity)(dev, vchan);
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h
index 0eec1aa43b..fd6a737d46 100644
--- a/lib/dmadev/rte_dmadev_core.h
+++ b/lib/dmadev/rte_dmadev_core.h
@@ -58,6 +58,9 @@  typedef int (*rte_dma_stats_get_t)(const struct rte_dma_dev *dev,
 /** @internal Used to reset basic statistics. */
 typedef int (*rte_dma_stats_reset_t)(struct rte_dma_dev *dev, uint16_t vchan);
 
+/** @internal Used to check the remaining space in descriptor ring. */
+typedef uint16_t (*rte_dma_burst_capacity_t)(const struct rte_dma_dev *dev, uint16_t vchan);
+
 /** @internal Used to dump internal information. */
 typedef int (*rte_dma_dump_t)(const struct rte_dma_dev *dev, FILE *f);
 
@@ -124,7 +127,6 @@  struct rte_dma_dev_ops {
 
 	rte_dma_dump_t           dev_dump;
 	rte_dma_vchan_status_t   vchan_status;
-
 };
 
 /**
@@ -171,7 +173,7 @@  struct rte_dma_dev {
 	rte_dma_submit_t           submit;
 	rte_dma_completed_t        completed;
 	rte_dma_completed_status_t completed_status;
-	void *reserved_cl0;
+	rte_dma_burst_capacity_t   burst_capacity;
 	/** Reserve space for future IO functions, while keeping data and
 	 * dev_ops pointers on the second cacheline.
 	 */
diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
index 40ea517016..66420c4ede 100644
--- a/lib/dmadev/version.map
+++ b/lib/dmadev/version.map
@@ -1,6 +1,7 @@ 
 EXPERIMENTAL {
 	global:
 
+	rte_dma_burst_capacity;
 	rte_dma_close;
 	rte_dma_completed;
 	rte_dma_completed_status;