[RFC,v2] dmadev: offload to free source buffer

Message ID 20230810165314.2238725-1-amitprakashs@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [RFC,v2] dmadev: offload to free source buffer |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Amit Prakash Shukla Aug. 10, 2023, 4:53 p.m. UTC
  This changeset adds support in DMA library to free source DMA buffer by
hardware. On a supported hardware, application can pass on the mempool
information as part of vchan config when the DMA transfer direction is
configured as RTE_DMA_DIR_MEM_TO_DEV.

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
v2:
- Added note related to mempool.

 lib/dmadev/rte_dmadev.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
  

Comments

Morten Brørup Aug. 10, 2023, 6:20 p.m. UTC | #1
> From: Amit Prakash Shukla [mailto:amitprakashs@marvell.com]
> Sent: Thursday, 10 August 2023 18.53
> 
> This changeset adds support in DMA library to free source DMA buffer by
> hardware. On a supported hardware, application can pass on the mempool
> information as part of vchan config when the DMA transfer direction is
> configured as RTE_DMA_DIR_MEM_TO_DEV.
> 
> Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
> ---
> v2:
> - Added note related to mempool.
> 

This seems useful. With the v2 additions,

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  

Patch

diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
index e61d71959e..f4879d9fd8 100644
--- a/lib/dmadev/rte_dmadev.h
+++ b/lib/dmadev/rte_dmadev.h
@@ -278,6 +278,13 @@  int16_t rte_dma_next_dev(int16_t start_dev_id);
 #define RTE_DMA_CAPA_OPS_COPY_SG	RTE_BIT64(33)
 /** Support fill operation. */
 #define RTE_DMA_CAPA_OPS_FILL		RTE_BIT64(34)
+/** Support for source buffer free for mem to dev transfer.
+ *
+ * @note Even though the DMA driver has this capability, it may not support all
+ * mempool drivers. If the mempool is not supported by the DMA driver,
+ * rte_dma_vchan_setup() will fail.
+ **/
+#define RTE_DMA_CAPA_MEM_TO_DEV_SOURCE_BUFFER_FREE	RTE_BIT64(35)
 /**@}*/
 
 /**
@@ -582,6 +589,19 @@  struct rte_dma_vchan_conf {
 	 * @see struct rte_dma_port_param
 	 */
 	struct rte_dma_port_param dst_port;
+	/** mempool from which source buffer is allocated. mempool info is used
+	 * for freeing source buffer by hardware when configured direction is
+	 * RTE_DMA_DIR_MEM_TO_DEV. To free the source buffer by hardware,
+	 * RTE_DMA_OP_FLAG_FREE_SBUF must be set while calling rte_dma_copy and
+	 * rte_dma_copy_sg().
+	 *
+	 * @note If the mempool is not supported by the DMA driver,
+	 * rte_dma_vchan_setup() will fail.
+	 *
+	 * @see RTE_DMA_OP_FLAG_FREE_SBUF
+	 */
+	struct rte_mempool *mem_to_dev_src_buf_pool;
+
 };
 
 /**
@@ -819,6 +839,13 @@  struct rte_dma_sge {
  * capability bit for this, driver should not return error if this flag was set.
  */
 #define RTE_DMA_OP_FLAG_LLC     RTE_BIT64(2)
+/** Mem to dev source buffer free flag.
+ * Used for freeing source DMA buffer by hardware when the transfer direction is
+ * configured as RTE_DMA_DIR_MEM_TO_DEV.
+ *
+ * @see struct rte_dma_vchan_conf::mem_to_dev_src_buf_pool
+ */
+#define RTE_DMA_OP_FLAG_FREE_SBUF	RTE_BIT64(3)
 /**@}*/
 
 /**