[v2,09/10] dma/ioat: add support for vchan idle function

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Conor Walsh Sept. 3, 2021, 11:17 a.m. UTC
Add support for the rte_dmadev_vchan_idle API call.

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
---
 drivers/dma/ioat/ioat_dmadev.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Kevin Laatz Sept. 7, 2021, 10:12 a.m. UTC | #1
On 03/09/2021 12:17, Conor Walsh wrote:
> Add support for the rte_dmadev_vchan_idle API call.
>
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> ---
>   drivers/dma/ioat/ioat_dmadev.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
>
Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
  

Patch

diff --git a/drivers/dma/ioat/ioat_dmadev.c b/drivers/dma/ioat/ioat_dmadev.c
index 743fb2f558..a09e60b27e 100644
--- a/drivers/dma/ioat/ioat_dmadev.c
+++ b/drivers/dma/ioat/ioat_dmadev.c
@@ -506,6 +506,19 @@  ioat_stats_reset(struct rte_dmadev *dev, uint16_t vchan __rte_unused)
 	return 0;
 }
 
+/* Check if the IOAT device is idle. */
+static int
+ioat_vchan_idle(const struct rte_dmadev *dev, uint16_t vchan __rte_unused)
+{
+	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);
+
+	return (last == ((ioat->next_write - 1) & mask) || state == IOAT_CHANSTS_HALTED
+			|| state == IOAT_CHANSTS_SUSPENDED);
+}
+
 /* Create a DMA device. */
 static int
 ioat_dmadev_create(const char *name, struct rte_pci_device *dev)
@@ -519,6 +532,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_idle = ioat_vchan_idle,
 		.vchan_setup = ioat_vchan_setup,
 	};