diff mbox series

[v2,1/6] dmadev: add device idle check for testing use

Message ID 20210901163216.120087-2-bruce.richardson@intel.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series add test suite for DMA drivers | expand

Checks

Context Check Description
ci/iol-testing warning apply patch failure
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson Sept. 1, 2021, 4:32 p.m. UTC
Add in a function to check if a device or vchan has completed all jobs
assigned to it, without gathering in the results. This is primarily for
use in testing, to allow the hardware to be in a known-state prior to
gathering completions.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/dmadev/rte_dmadev.c      | 16 ++++++++++++++++
 lib/dmadev/rte_dmadev.h      | 21 +++++++++++++++++++++
 lib/dmadev/rte_dmadev_core.h |  4 ++++
 lib/dmadev/version.map       |  1 +
 4 files changed, 42 insertions(+)

Comments

fengchengwen Sept. 2, 2021, 12:54 p.m. UTC | #1
When some hardware is faulty, the error code cannot be set, and it just stops working.
In addition, interrupts are generally not enabled. Therefore, for such hardware, the
framework needs to have a mechanism to transmit the status so that applications can
sense the status.

So how about extend vchan_idle to vchan_status, include: idle, running, error-stop ?

On 2021/9/2 0:32, Bruce Richardson wrote:
> Add in a function to check if a device or vchan has completed all jobs
> assigned to it, without gathering in the results. This is primarily for
> use in testing, to allow the hardware to be in a known-state prior to
> gathering completions.
> 

[snip]
Bruce Richardson Sept. 2, 2021, 2:21 p.m. UTC | #2
On Thu, Sep 02, 2021 at 08:54:11PM +0800, fengchengwen wrote:
> When some hardware is faulty, the error code cannot be set, and it just stops working.
> In addition, interrupts are generally not enabled. Therefore, for such hardware, the
> framework needs to have a mechanism to transmit the status so that applications can
> sense the status.
> 
> So how about extend vchan_idle to vchan_status, include: idle, running, error-stop ?
> 

We can look at changing that. By "idle" I originally meant "non-active",
meaning that it's either halted or idle, but I think we can separate out
those two into separate items like you suggest.

/Bruce
diff mbox series

Patch

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 1c946402db..e249411631 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -555,3 +555,19 @@  rte_dmadev_dump(uint16_t dev_id, FILE *f)
 
 	return 0;
 }
+
+int
+rte_dmadev_vchan_idle(uint16_t dev_id, uint16_t vchan)
+{
+	struct rte_dmadev *dev = &rte_dmadevices[dev_id];
+
+	RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
+	if (vchan >= dev->data->dev_conf.nb_vchans) {
+		RTE_DMADEV_LOG(ERR,
+			"Device %u vchan %u out of range\n", dev_id, vchan);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vchan_idle, -ENOTSUP);
+	return (*dev->dev_ops->vchan_idle)(dev, vchan);
+}
diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
index e8f58e9213..350e7defc8 100644
--- a/lib/dmadev/rte_dmadev.h
+++ b/lib/dmadev/rte_dmadev.h
@@ -1028,6 +1028,27 @@  rte_dmadev_completed_status(uint16_t dev_id, uint16_t vchan,
 	return (*dev->completed_status)(dev, vchan, nb_cpls, last_idx, status);
 }
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Determine if all jobs have completed on a device channel.
+ * This function is primarily designed for testing use, as it allows a process to check if
+ * all jobs are completed, without actually gathering completions from those jobs.
+ *
+ * @param dev_id
+ *   The identifier of the device.
+ * @param vchan
+ *   The identifier of virtual DMA channel.
+ * @return
+ *   1 - if all jobs have completed and the device vchan is idle
+ *   0 - if there are still outstanding jobs yet to complete
+ *   < 0 - error code indicating there was a problem calling the API
+ */
+__rte_experimental
+int
+rte_dmadev_vchan_idle(uint16_t dev_id, uint16_t vchan);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h
index e94aa1c457..7ec5a5b572 100644
--- a/lib/dmadev/rte_dmadev_core.h
+++ b/lib/dmadev/rte_dmadev_core.h
@@ -53,6 +53,9 @@  typedef int (*rte_dmadev_stats_reset_t)(struct rte_dmadev *dev, uint16_t vchan);
 typedef int (*rte_dmadev_dump_t)(const struct rte_dmadev *dev, FILE *f);
 /**< @internal Used to dump internal information. */
 
+typedef int (*rte_dmadev_vchan_idle_t)(const struct rte_dmadev *dev, uint16_t vchan);
+/**< @internal Used to check if a virtual channel has finished all jobs. */
+
 typedef int (*rte_dmadev_copy_t)(struct rte_dmadev *dev, uint16_t vchan,
 				 rte_iova_t src, rte_iova_t dst,
 				 uint32_t length, uint64_t flags);
@@ -106,6 +109,7 @@  struct rte_dmadev_ops {
 	rte_dmadev_stats_get_t stats_get;
 	rte_dmadev_stats_reset_t stats_reset;
 	rte_dmadev_dump_t dev_dump;
+	rte_dmadev_vchan_idle_t vchan_idle;
 };
 
 /**
diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
index 80be592713..b7e52fda3d 100644
--- a/lib/dmadev/version.map
+++ b/lib/dmadev/version.map
@@ -18,6 +18,7 @@  EXPERIMENTAL {
 	rte_dmadev_stats_reset;
 	rte_dmadev_stop;
 	rte_dmadev_submit;
+	rte_dmadev_vchan_idle;
 	rte_dmadev_vchan_setup;
 
 	local: *;