diff mbox series

[v6,09/12] dma/ioat: add support for vchan status function

Message ID 20210927102157.1570116-10-conor.walsh@intel.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series dma: add dmadev driver for ioat devices | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Walsh, Conor Sept. 27, 2021, 10:21 a.m. UTC
Add support for the rte_dmadev_vchan_status API call.

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/dma/ioat/ioat_dmadev.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/drivers/dma/ioat/ioat_dmadev.c b/drivers/dma/ioat/ioat_dmadev.c
index 20ae364318..fe01a3b1db 100644
--- a/drivers/dma/ioat/ioat_dmadev.c
+++ b/drivers/dma/ioat/ioat_dmadev.c
@@ -535,6 +535,26 @@  ioat_stats_reset(struct rte_dma_dev *dev, uint16_t vchan __rte_unused)
 	return 0;
 }
 
+/* Check if the IOAT device is idle. */
+static int
+ioat_vchan_status(const struct rte_dma_dev *dev, uint16_t vchan __rte_unused,
+		enum rte_dma_vchan_status *status)
+{
+	int state = 0;
+	const struct ioat_dmadev *ioat = dev->dev_private;
+	const uint16_t mask = ioat->qcfg.nb_desc - 1;
+	const uint16_t last = __get_last_completed(ioat, &state);
+
+	if (state == IOAT_CHANSTS_HALTED || state == IOAT_CHANSTS_SUSPENDED)
+		*status = RTE_DMA_VCHAN_HALTED_ERROR;
+	else if (last == ((ioat->next_write - 1) & mask))
+		*status = RTE_DMA_VCHAN_IDLE;
+	else
+		*status = RTE_DMA_VCHAN_ACTIVE;
+
+	return 0;
+}
+
 /* Create a DMA device. */
 static int
 ioat_dmadev_create(const char *name, struct rte_pci_device *dev)
@@ -548,6 +568,7 @@  ioat_dmadev_create(const char *name, struct rte_pci_device *dev)
 		.dev_stop = ioat_dev_stop,
 		.stats_get = ioat_stats_get,
 		.stats_reset = ioat_stats_reset,
+		.vchan_status = ioat_vchan_status,
 		.vchan_setup = ioat_vchan_setup,
 	};