diff mbox series

[v5,1/9] dmadev: add channel status check for testing use

Message ID 20210917135429.90562-2-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
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. 17, 2021, 1:54 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>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
---
 lib/dmadev/rte_dmadev.c      | 15 +++++++++++++++
 lib/dmadev/rte_dmadev.h      | 33 +++++++++++++++++++++++++++++++++
 lib/dmadev/rte_dmadev_core.h |  6 ++++++
 lib/dmadev/version.map       |  1 +
 4 files changed, 55 insertions(+)

--
2.30.2

Comments

Fengchengwen Sept. 22, 2021, 8:25 a.m. UTC | #1
On 2021/9/17 21:54, 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.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> Reviewed-by: Conor Walsh <conor.walsh@intel.com>
> Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
> ---
>  lib/dmadev/rte_dmadev.c      | 15 +++++++++++++++
>  lib/dmadev/rte_dmadev.h      | 33 +++++++++++++++++++++++++++++++++
>  lib/dmadev/rte_dmadev_core.h |  6 ++++++
>  lib/dmadev/version.map       |  1 +
>  4 files changed, 55 insertions(+)
> 
> diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
> index 544937acf8..859958fff8 100644
> --- a/lib/dmadev/rte_dmadev.c
> +++ b/lib/dmadev/rte_dmadev.c
> @@ -716,3 +716,18 @@ rte_dma_dump(int16_t dev_id, FILE *f)
> 
>  	return 0;
>  }
> +
> +int
> +rte_dma_vchan_status(uint16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status)

uint16_t dev_id -> int16_t

> +{
> +	struct rte_dma_dev *dev = &rte_dma_devices[dev_id];
> +
> +	RTE_DMA_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
> +	if (vchan >= dev->data->dev_conf.nb_vchans) {
> +		RTE_DMA_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_status, -ENOTSUP);
> +	return (*dev->dev_ops->vchan_status)(dev, vchan, status);
> +}
> diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
> index be54f2cb9d..86c4a38f83 100644
> --- a/lib/dmadev/rte_dmadev.h
> +++ b/lib/dmadev/rte_dmadev.h
> @@ -660,6 +660,39 @@ int rte_dma_stats_get(int16_t dev_id, uint16_t vchan,
>  __rte_experimental
>  int rte_dma_stats_reset(int16_t dev_id, uint16_t vchan);
> 
> +/**
> + * device vchannel status
> + *
> + * Enum with the options for the channel status, either idle, active or halted due to error

please add @see

> + */
> +enum rte_dma_vchan_status {
> +	RTE_DMA_VCHAN_IDLE,          /**< not processing, awaiting ops */
> +	RTE_DMA_VCHAN_ACTIVE,        /**< currently processing jobs */
> +	RTE_DMA_VCHAN_HALTED_ERROR,  /**< not processing due to error, cannot accept new ops */
> +};
> +
> +/**
> + * @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.
> + * @param[out] status
> + *   The vchan status
> + * @return
> + *   0 - call completed successfully
> + *   < 0 - error code indicating there was a problem calling the API
> + */
> +__rte_experimental
> +int
> +rte_dma_vchan_status(uint16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status);
> +
>  /**
>   * @warning
>   * @b EXPERIMENTAL: this API may change without prior notice.
> diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h
> index edb3286cbb..0eec1aa43b 100644
> --- a/lib/dmadev/rte_dmadev_core.h
> +++ b/lib/dmadev/rte_dmadev_core.h
> @@ -46,6 +46,10 @@ typedef int (*rte_dma_vchan_setup_t)(struct rte_dma_dev *dev, uint16_t vchan,
>  				const struct rte_dma_vchan_conf *conf,
>  				uint32_t conf_sz);
> 
> +/** @internal Used to check if a virtual channel has finished all jobs. */
> +typedef int (*rte_dma_vchan_status_t)(const struct rte_dma_dev *dev, uint16_t vchan,
> +		enum rte_dma_vchan_status *status);
> +
>  /** @internal Used to retrieve basic statistics. */
>  typedef int (*rte_dma_stats_get_t)(const struct rte_dma_dev *dev,
>  			uint16_t vchan, struct rte_dma_stats *stats,
> @@ -119,6 +123,8 @@ struct rte_dma_dev_ops {
>  	rte_dma_stats_reset_t    stats_reset;
> 
>  	rte_dma_dump_t           dev_dump;
> +	rte_dma_vchan_status_t   vchan_status;
> +
>  };
> 
>  /**
> diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
> index c780463bb2..40ea517016 100644
> --- a/lib/dmadev/version.map
> +++ b/lib/dmadev/version.map
> @@ -20,6 +20,7 @@ EXPERIMENTAL {
>  	rte_dma_stop;
>  	rte_dma_submit;
>  	rte_dma_vchan_setup;
> +	rte_dma_vchan_status;
> 
>  	local: *;
>  };
> --
> 2.30.2
> 
> .
>
Bruce Richardson Sept. 22, 2021, 8:31 a.m. UTC | #2
On Wed, Sep 22, 2021 at 04:25:15PM +0800, fengchengwen wrote:
> On 2021/9/17 21:54, 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.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > Reviewed-by: Conor Walsh <conor.walsh@intel.com>
> > Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
> > ---
> >  lib/dmadev/rte_dmadev.c      | 15 +++++++++++++++
> >  lib/dmadev/rte_dmadev.h      | 33 +++++++++++++++++++++++++++++++++
> >  lib/dmadev/rte_dmadev_core.h |  6 ++++++
> >  lib/dmadev/version.map       |  1 +
> >  4 files changed, 55 insertions(+)
> > 
> > diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
> > index 544937acf8..859958fff8 100644
> > --- a/lib/dmadev/rte_dmadev.c
> > +++ b/lib/dmadev/rte_dmadev.c
> > @@ -716,3 +716,18 @@ rte_dma_dump(int16_t dev_id, FILE *f)
> > 
> >  	return 0;
> >  }
> > +
> > +int
> > +rte_dma_vchan_status(uint16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status)
> 
> uint16_t dev_id -> int16_t
> 
> > +{
> > +	struct rte_dma_dev *dev = &rte_dma_devices[dev_id];
> > +
> > +	RTE_DMA_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
> > +	if (vchan >= dev->data->dev_conf.nb_vchans) {
> > +		RTE_DMA_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_status, -ENOTSUP);
> > +	return (*dev->dev_ops->vchan_status)(dev, vchan, status);
> > +}
> > diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
> > index be54f2cb9d..86c4a38f83 100644
> > --- a/lib/dmadev/rte_dmadev.h
> > +++ b/lib/dmadev/rte_dmadev.h
> > @@ -660,6 +660,39 @@ int rte_dma_stats_get(int16_t dev_id, uint16_t vchan,
> >  __rte_experimental
> >  int rte_dma_stats_reset(int16_t dev_id, uint16_t vchan);
> > 
> > +/**
> > + * device vchannel status
> > + *
> > + * Enum with the options for the channel status, either idle, active or halted due to error
> 
> please add @see
> 
Will do in next revision.

Thanks for feedback.
/Bruce
diff mbox series

Patch

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 544937acf8..859958fff8 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -716,3 +716,18 @@  rte_dma_dump(int16_t dev_id, FILE *f)

 	return 0;
 }
+
+int
+rte_dma_vchan_status(uint16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status)
+{
+	struct rte_dma_dev *dev = &rte_dma_devices[dev_id];
+
+	RTE_DMA_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
+	if (vchan >= dev->data->dev_conf.nb_vchans) {
+		RTE_DMA_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_status, -ENOTSUP);
+	return (*dev->dev_ops->vchan_status)(dev, vchan, status);
+}
diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
index be54f2cb9d..86c4a38f83 100644
--- a/lib/dmadev/rte_dmadev.h
+++ b/lib/dmadev/rte_dmadev.h
@@ -660,6 +660,39 @@  int rte_dma_stats_get(int16_t dev_id, uint16_t vchan,
 __rte_experimental
 int rte_dma_stats_reset(int16_t dev_id, uint16_t vchan);

+/**
+ * device vchannel status
+ *
+ * Enum with the options for the channel status, either idle, active or halted due to error
+ */
+enum rte_dma_vchan_status {
+	RTE_DMA_VCHAN_IDLE,          /**< not processing, awaiting ops */
+	RTE_DMA_VCHAN_ACTIVE,        /**< currently processing jobs */
+	RTE_DMA_VCHAN_HALTED_ERROR,  /**< not processing due to error, cannot accept new ops */
+};
+
+/**
+ * @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.
+ * @param[out] status
+ *   The vchan status
+ * @return
+ *   0 - call completed successfully
+ *   < 0 - error code indicating there was a problem calling the API
+ */
+__rte_experimental
+int
+rte_dma_vchan_status(uint16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status);
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h
index edb3286cbb..0eec1aa43b 100644
--- a/lib/dmadev/rte_dmadev_core.h
+++ b/lib/dmadev/rte_dmadev_core.h
@@ -46,6 +46,10 @@  typedef int (*rte_dma_vchan_setup_t)(struct rte_dma_dev *dev, uint16_t vchan,
 				const struct rte_dma_vchan_conf *conf,
 				uint32_t conf_sz);

+/** @internal Used to check if a virtual channel has finished all jobs. */
+typedef int (*rte_dma_vchan_status_t)(const struct rte_dma_dev *dev, uint16_t vchan,
+		enum rte_dma_vchan_status *status);
+
 /** @internal Used to retrieve basic statistics. */
 typedef int (*rte_dma_stats_get_t)(const struct rte_dma_dev *dev,
 			uint16_t vchan, struct rte_dma_stats *stats,
@@ -119,6 +123,8 @@  struct rte_dma_dev_ops {
 	rte_dma_stats_reset_t    stats_reset;

 	rte_dma_dump_t           dev_dump;
+	rte_dma_vchan_status_t   vchan_status;
+
 };

 /**
diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
index c780463bb2..40ea517016 100644
--- a/lib/dmadev/version.map
+++ b/lib/dmadev/version.map
@@ -20,6 +20,7 @@  EXPERIMENTAL {
 	rte_dma_stop;
 	rte_dma_submit;
 	rte_dma_vchan_setup;
+	rte_dma_vchan_status;

 	local: *;
 };