DPDK patches and discussions
 help / color / mirror / Atom feed
From: Conor Walsh <conor.walsh@intel.com>
To: bruce.richardson@intel.com, fengchengwen@huawei.com,
	jerinj@marvell.com, kevin.laatz@intel.com
Cc: dev@dpdk.org, Conor Walsh <conor.walsh@intel.com>
Subject: [dpdk-dev] [PATCH v7 05/12] dma/ioat: add start and stop functions
Date: Thu, 14 Oct 2021 09:48:55 +0000	[thread overview]
Message-ID: <20211014094902.489159-6-conor.walsh@intel.com> (raw)
In-Reply-To: <20211014094902.489159-1-conor.walsh@intel.com>

Add start, stop and recover functions for IOAT devices.

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
---
 doc/guides/dmadevs/ioat.rst    |  3 ++
 drivers/dma/ioat/ioat_dmadev.c | 92 ++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/doc/guides/dmadevs/ioat.rst b/doc/guides/dmadevs/ioat.rst
index af69556241..df159f9957 100644
--- a/doc/guides/dmadevs/ioat.rst
+++ b/doc/guides/dmadevs/ioat.rst
@@ -82,3 +82,6 @@ IOAT configuration requirements:
 * Only one ``vchan`` is supported per device.
 * Silent mode is not supported.
 * The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory.
+
+Once configured, the device can then be made ready for use by calling the
+``rte_dma_start()`` API.
diff --git a/drivers/dma/ioat/ioat_dmadev.c b/drivers/dma/ioat/ioat_dmadev.c
index ada57c5814..cf28f4a7e6 100644
--- a/drivers/dma/ioat/ioat_dmadev.c
+++ b/drivers/dma/ioat/ioat_dmadev.c
@@ -78,6 +78,96 @@ ioat_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan __rte_unused,
 	return 0;
 }
 
+/* Recover IOAT device. */
+static inline int
+__ioat_recover(struct ioat_dmadev *ioat)
+{
+	uint32_t chanerr, retry = 0;
+	uint16_t mask = ioat->qcfg.nb_desc - 1;
+
+	/* Clear any channel errors. Reading and writing to chanerr does this. */
+	chanerr = ioat->regs->chanerr;
+	ioat->regs->chanerr = chanerr;
+
+	/* Reset Channel. */
+	ioat->regs->chancmd = IOAT_CHANCMD_RESET;
+
+	/* Write new chain address to trigger state change. */
+	ioat->regs->chainaddr = ioat->desc_ring[(ioat->next_read - 1) & mask].next;
+	/* Ensure channel control and status addr are correct. */
+	ioat->regs->chanctrl = IOAT_CHANCTRL_ANY_ERR_ABORT_EN |
+			IOAT_CHANCTRL_ERR_COMPLETION_EN;
+	ioat->regs->chancmp = ioat->status_addr;
+
+	/* Allow HW time to move to the ARMED state. */
+	do {
+		rte_pause();
+		retry++;
+	} while (ioat->regs->chansts != IOAT_CHANSTS_ARMED && retry < 200);
+
+	/* Exit as failure if device is still HALTED. */
+	if (ioat->regs->chansts != IOAT_CHANSTS_ARMED)
+		return -1;
+
+	/* Store next write as offset as recover will move HW and SW ring out of sync. */
+	ioat->offset = ioat->next_read;
+
+	/* Prime status register with previous address. */
+	ioat->status = ioat->desc_ring[(ioat->next_read - 2) & mask].next;
+
+	return 0;
+}
+
+/* Start a configured device. */
+static int
+ioat_dev_start(struct rte_dma_dev *dev)
+{
+	struct ioat_dmadev *ioat = dev->fp_obj->dev_private;
+
+	if (ioat->qcfg.nb_desc == 0 || ioat->desc_ring == NULL)
+		return -EBUSY;
+
+	/* Inform hardware of where the descriptor ring is. */
+	ioat->regs->chainaddr = ioat->ring_addr;
+	/* Inform hardware of where to write the status/completions. */
+	ioat->regs->chancmp = ioat->status_addr;
+
+	/* Prime the status register to be set to the last element. */
+	ioat->status = ioat->ring_addr + ((ioat->qcfg.nb_desc - 1) * DESC_SZ);
+
+	printf("IOAT.status: %s [0x%"PRIx64"]\n",
+			chansts_readable[ioat->status & IOAT_CHANSTS_STATUS],
+			ioat->status);
+
+	if ((ioat->regs->chansts & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_HALTED) {
+		IOAT_PMD_WARN("Device HALTED on start, attempting to recover\n");
+		if (__ioat_recover(ioat) != 0) {
+			IOAT_PMD_ERR("Device couldn't be recovered");
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+/* Stop a configured device. */
+static int
+ioat_dev_stop(struct rte_dma_dev *dev)
+{
+	struct ioat_dmadev *ioat = dev->fp_obj->dev_private;
+	uint32_t retry = 0;
+
+	ioat->regs->chancmd = IOAT_CHANCMD_SUSPEND;
+
+	do {
+		rte_pause();
+		retry++;
+	} while ((ioat->regs->chansts & IOAT_CHANSTS_STATUS) != IOAT_CHANSTS_SUSPENDED
+			&& retry < 200);
+
+	return ((ioat->regs->chansts & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_SUSPENDED) ? 0 : -1;
+}
+
 /* Get device information of a device. */
 static int
 ioat_dev_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_t size)
@@ -193,6 +283,8 @@ ioat_dmadev_create(const char *name, struct rte_pci_device *dev)
 		.dev_configure = ioat_dev_configure,
 		.dev_dump = ioat_dev_dump,
 		.dev_info_get = ioat_dev_info_get,
+		.dev_start = ioat_dev_start,
+		.dev_stop = ioat_dev_stop,
 		.vchan_setup = ioat_vchan_setup,
 	};
 
-- 
2.25.1


  parent reply	other threads:[~2021-10-14  9:49 UTC|newest]

Thread overview: 132+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 17:25 [dpdk-dev] [PATCH 0/8] dma: add dmadev driver for ioat devices Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 1/8] dma/ioat: add device probe and removal functions Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 2/8] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 3/8] dma/ioat: add datapath structures Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 4/8] dma/ioat: add configuration functions Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 5/8] dma/ioat: add start and stop functions Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 6/8] dma/ioat: add data path job submission functions Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 7/8] dma/ioat: add data path completion functions Conor Walsh
2021-08-27 17:25 ` [dpdk-dev] [PATCH 8/8] dma/ioat: add statistics Conor Walsh
2021-09-03 11:17 ` [dpdk-dev] [PATCH v2 00/10] dma: add dmadev driver for ioat devices Conor Walsh
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 01/10] dma/ioat: add device probe and removal functions Conor Walsh
2021-09-07 10:10     ` Kevin Laatz
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 02/10] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-09-07 10:11     ` Kevin Laatz
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 03/10] dma/ioat: add datapath structures Conor Walsh
2021-09-07 10:11     ` Kevin Laatz
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 04/10] dma/ioat: add configuration functions Conor Walsh
2021-09-07 10:11     ` Kevin Laatz
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 05/10] dma/ioat: add start and stop functions Conor Walsh
2021-09-07 10:11     ` Kevin Laatz
2021-09-07 10:35       ` Walsh, Conor
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 06/10] dma/ioat: add data path job submission functions Conor Walsh
2021-09-07 10:12     ` Kevin Laatz
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 07/10] dma/ioat: add data path completion functions Conor Walsh
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 08/10] dma/ioat: add statistics Conor Walsh
2021-09-07 10:12     ` Kevin Laatz
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 09/10] dma/ioat: add support for vchan idle function Conor Walsh
2021-09-07 10:12     ` Kevin Laatz
2021-09-03 11:17   ` [dpdk-dev] [PATCH v2 10/10] devbind: move ioat device ID for ICX to dmadev category Conor Walsh
2021-09-07 10:10     ` Kevin Laatz
2021-09-08 10:39   ` [dpdk-dev] [PATCH v3 00/11] dma: add dmadev driver for ioat devices Conor Walsh
2021-09-08 10:39     ` [dpdk-dev] [PATCH v3 01/11] dma/ioat: add device probe and removal functions Conor Walsh
2021-09-08 10:39     ` [dpdk-dev] [PATCH v3 02/11] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-09-08 10:39     ` [dpdk-dev] [PATCH v3 03/11] dma/ioat: add datapath structures Conor Walsh
2021-09-08 10:39     ` [dpdk-dev] [PATCH v3 04/11] dma/ioat: add configuration functions Conor Walsh
2021-09-08 10:39     ` [dpdk-dev] [PATCH v3 05/11] dma/ioat: add start and stop functions Conor Walsh
2021-09-08 10:39     ` [dpdk-dev] [PATCH v3 06/11] dma/ioat: add data path job submission functions Conor Walsh
2021-09-08 10:40     ` [dpdk-dev] [PATCH v3 07/11] dma/ioat: add data path completion functions Conor Walsh
2021-09-08 10:40     ` [dpdk-dev] [PATCH v3 08/11] dma/ioat: add statistics Conor Walsh
2021-09-08 10:40     ` [dpdk-dev] [PATCH v3 09/11] dma/ioat: add support for vchan status function Conor Walsh
2021-09-08 10:40     ` [dpdk-dev] [PATCH v3 10/11] dma/ioat: add burst capacity function Conor Walsh
2021-09-08 10:40     ` [dpdk-dev] [PATCH v3 11/11] devbind: move ioat device ID for ICX to dmadev category Conor Walsh
2021-09-17 15:42 ` [dpdk-dev] [PATCH v4 00/11] dma: add dmadev driver for ioat devices Conor Walsh
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 01/11] dma/ioat: add device probe and removal functions Conor Walsh
2021-09-20 11:15     ` Bruce Richardson
2021-09-21 16:24       ` Conor Walsh
2021-09-22  3:59     ` fengchengwen
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 02/11] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-09-20 13:31     ` Bruce Richardson
2021-09-21 16:25       ` Conor Walsh
2021-09-22  8:04     ` fengchengwen
2021-09-22 16:40       ` Conor Walsh
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 03/11] dma/ioat: add datapath structures Conor Walsh
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 04/11] dma/ioat: add configuration functions Conor Walsh
2021-09-22  8:08     ` fengchengwen
2021-09-22 16:41       ` Conor Walsh
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 05/11] dma/ioat: add start and stop functions Conor Walsh
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 06/11] dma/ioat: add data path job submission functions Conor Walsh
2021-09-20 13:36     ` Bruce Richardson
2021-09-21 16:25       ` Conor Walsh
2021-09-22  8:18     ` fengchengwen
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 07/11] dma/ioat: add data path completion functions Conor Walsh
2021-09-20 13:39     ` Bruce Richardson
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 08/11] dma/ioat: add statistics Conor Walsh
2021-09-20 13:48     ` Bruce Richardson
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 09/11] dma/ioat: add support for vchan status function Conor Walsh
2021-09-20 13:49     ` Bruce Richardson
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 10/11] dma/ioat: add burst capacity function Conor Walsh
2021-09-20 13:49     ` Bruce Richardson
2021-09-17 15:42   ` [dpdk-dev] [PATCH v4 11/11] devbind: move ioat device ID for ICX to dmadev category Conor Walsh
2021-09-20 13:53     ` Bruce Richardson
2021-09-21 16:26       ` Conor Walsh
2021-09-24 14:33 ` [dpdk-dev] [PATCH v5 00/12] dma: add dmadev driver for ioat devices Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 01/12] dma/ioat: add device probe and removal functions Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 02/12] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 03/12] dma/ioat: add datapath structures Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 04/12] dma/ioat: add configuration functions Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 05/12] dma/ioat: add start and stop functions Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 06/12] dma/ioat: add data path job submission functions Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 07/12] dma/ioat: add data path completion functions Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 08/12] dma/ioat: add statistics Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 09/12] dma/ioat: add support for vchan status function Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 10/12] dma/ioat: add burst capacity function Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 11/12] devbind: move ioat device IDs to dmadev category Conor Walsh
2021-09-24 14:33   ` [dpdk-dev] [PATCH v5 12/12] raw/ioat: deprecate ioat rawdev driver Conor Walsh
2021-09-24 16:21     ` Kevin Laatz
2021-09-24 16:56     ` Bruce Richardson
2021-09-27  9:36       ` Walsh, Conor
2021-09-27 10:21 ` [dpdk-dev] [PATCH v6 00/12] dma: add dmadev driver for ioat devices Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 01/12] dma/ioat: add device probe and removal functions Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 02/12] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 03/12] dma/ioat: add datapath structures Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 04/12] dma/ioat: add configuration functions Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 05/12] dma/ioat: add start and stop functions Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 06/12] dma/ioat: add data path job submission functions Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 07/12] dma/ioat: add data path completion functions Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 08/12] dma/ioat: add statistics Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 09/12] dma/ioat: add support for vchan status function Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 10/12] dma/ioat: add burst capacity function Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 11/12] devbind: move ioat device IDs to dmadev category Conor Walsh
2021-09-27 10:21   ` [dpdk-dev] [PATCH v6 12/12] raw/ioat: deprecate ioat rawdev driver Conor Walsh
2021-10-14  9:48 ` [dpdk-dev] [PATCH v7 00/12] dma: add dmadev driver for ioat devices Conor Walsh
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 01/12] dma/ioat: add device probe and removal functions Conor Walsh
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 02/12] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 03/12] dma/ioat: add datapath structures Conor Walsh
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 04/12] dma/ioat: add configuration functions Conor Walsh
2021-10-14  9:48   ` Conor Walsh [this message]
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 06/12] dma/ioat: add data path job submission functions Conor Walsh
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 07/12] dma/ioat: add data path completion functions Conor Walsh
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 08/12] dma/ioat: add statistics Conor Walsh
2021-10-14  9:48   ` [dpdk-dev] [PATCH v7 09/12] dma/ioat: add support for vchan status function Conor Walsh
2021-10-14  9:49   ` [dpdk-dev] [PATCH v7 10/12] dma/ioat: add burst capacity function Conor Walsh
2021-10-14  9:49   ` [dpdk-dev] [PATCH v7 11/12] devbind: move ioat device IDs to dmadev category Conor Walsh
2021-10-14  9:49   ` [dpdk-dev] [PATCH v7 12/12] raw/ioat: deprecate ioat rawdev driver Conor Walsh
2021-10-18  7:54     ` Thomas Monjalon
2021-10-18 12:38 ` [dpdk-dev] [PATCH v8 00/12] dma: add dmadev driver for ioat devices Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 01/12] dma/ioat: add device probe and removal functions Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 02/12] dma/ioat: create dmadev instances on PCI probe Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 03/12] dma/ioat: add datapath structures Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 04/12] dma/ioat: add configuration functions Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 05/12] dma/ioat: add start and stop functions Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 06/12] dma/ioat: add data path job submission functions Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 07/12] dma/ioat: add data path completion functions Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 08/12] dma/ioat: add statistics Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 09/12] dma/ioat: add support for vchan status function Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 10/12] dma/ioat: add burst capacity function Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 11/12] devbind: move ioat device IDs to dmadev category Conor Walsh
2021-10-18 12:38   ` [dpdk-dev] [PATCH v8 12/12] raw/ioat: deprecate ioat rawdev driver Conor Walsh
2021-10-19 11:28   ` [dpdk-dev] [PATCH v8 00/12] dma: add dmadev driver for ioat devices Walsh, Conor
2021-10-19 14:23     ` Walsh, Conor
2021-10-20 16:35       ` Walsh, Conor
2021-10-22 19:25   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211014094902.489159-6-conor.walsh@intel.com \
    --to=conor.walsh@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=jerinj@marvell.com \
    --cc=kevin.laatz@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).