[dpdk-dev] [PATCH v7 02/13] dma/skeleton: add channel status function

Bruce Richardson bruce.richardson at intel.com
Wed Oct 13 17:17:25 CEST 2021


In order to avoid timing errors with the unit tests, we need to ensure
we have the vchan_status function to report when a channel is idle.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 drivers/dma/skeleton/skeleton_dmadev.c | 18 +++++++++++++++++-
 drivers/dma/skeleton/skeleton_dmadev.h |  2 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
index 22a73c6178..dd2f1c9b57 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -79,7 +79,7 @@ cpucopy_thread(void *param)
 
 		hw->zero_req_count = 0;
 		rte_memcpy(desc->dst, desc->src, desc->len);
-		hw->completed_count++;
+		__atomic_add_fetch(&hw->completed_count, 1, __ATOMIC_RELEASE);
 		(void)rte_ring_enqueue(hw->desc_completed, (void *)desc);
 	}
 
@@ -257,6 +257,21 @@ skeldma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 	return vchan_setup(hw, conf->nb_desc);
 }
 
+static int
+skeldma_vchan_status(const struct rte_dma_dev *dev,
+		uint16_t vchan, enum rte_dma_vchan_status *status)
+{
+	struct skeldma_hw *hw = dev->data->dev_private;
+
+	RTE_SET_USED(vchan);
+
+	*status = RTE_DMA_VCHAN_IDLE;
+	if (hw->submitted_count != __atomic_load_n(&hw->completed_count, __ATOMIC_ACQUIRE)
+			|| hw->zero_req_count == 0)
+		*status = RTE_DMA_VCHAN_ACTIVE;
+	return 0;
+}
+
 static int
 skeldma_stats_get(const struct rte_dma_dev *dev, uint16_t vchan,
 		  struct rte_dma_stats *stats, uint32_t stats_sz)
@@ -424,6 +439,7 @@ static const struct rte_dma_dev_ops skeldma_ops = {
 	.dev_close        = skeldma_close,
 
 	.vchan_setup      = skeldma_vchan_setup,
+	.vchan_status     = skeldma_vchan_status,
 
 	.stats_get        = skeldma_stats_get,
 	.stats_reset      = skeldma_stats_reset,
diff --git a/drivers/dma/skeleton/skeleton_dmadev.h b/drivers/dma/skeleton/skeleton_dmadev.h
index eaa52364bf..91eb5460fc 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.h
+++ b/drivers/dma/skeleton/skeleton_dmadev.h
@@ -54,7 +54,7 @@ struct skeldma_hw {
 
 	/* Cache delimiter for cpucopy thread's operation data */
 	char cache2 __rte_cache_aligned;
-	uint32_t zero_req_count;
+	volatile uint32_t zero_req_count;
 	uint64_t completed_count;
 };
 
-- 
2.30.2



More information about the dev mailing list