From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 57D18A0C55; Wed, 13 Oct 2021 17:18:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A66AB411EC; Wed, 13 Oct 2021 17:18:03 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 53C1740E64 for ; Wed, 13 Oct 2021 17:18:00 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10136"; a="290944040" X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="290944040" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 08:17:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="441682026" Received: from silpixa00399126.ir.intel.com ([10.237.223.151]) by orsmga006.jf.intel.com with ESMTP; 13 Oct 2021 08:17:47 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, fengchengwen@huawei.com, jerinj@marvell.com, Bruce Richardson Date: Wed, 13 Oct 2021 16:17:24 +0100 Message-Id: <20211013151736.762378-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211013151736.762378-1-bruce.richardson@intel.com> References: <20210924102942.2878051-1-bruce.richardson@intel.com> <20211013151736.762378-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 01/13] dmadev: add channel status check for testing use X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Reviewed-by: Conor Walsh Reviewed-by: Kevin Laatz --- lib/dmadev/rte_dmadev.c | 17 +++++++++++++++++ lib/dmadev/rte_dmadev.h | 34 ++++++++++++++++++++++++++++++++++ lib/dmadev/rte_dmadev_pmd.h | 5 +++++ lib/dmadev/version.map | 1 + 4 files changed, 57 insertions(+) diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 7099bbb28d..3f9154e619 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -679,6 +679,23 @@ rte_dma_stats_reset(int16_t dev_id, uint16_t vchan) return (*dev->dev_ops->stats_reset)(dev, vchan); } +int +rte_dma_vchan_status(int16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status) +{ + struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; + + if (!rte_dma_is_valid(dev_id)) + return -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); +} + static const char * dma_capability_name(uint64_t capability) { diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index e46c001404..e35aca7d1c 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -645,6 +645,40 @@ 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 + * @see rte_dma_vchan_status + */ +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(int16_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_pmd.h b/lib/dmadev/rte_dmadev_pmd.h index 23b07a4e1c..b97b5bf10b 100644 --- a/lib/dmadev/rte_dmadev_pmd.h +++ b/lib/dmadev/rte_dmadev_pmd.h @@ -54,6 +54,10 @@ typedef int (*rte_dma_stats_get_t)(const struct rte_dma_dev *dev, /** @internal Used to reset basic statistics. */ typedef int (*rte_dma_stats_reset_t)(struct rte_dma_dev *dev, uint16_t vchan); +/** @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 dump internal information. */ typedef int (*rte_dma_dump_t)(const struct rte_dma_dev *dev, FILE *f); @@ -74,6 +78,7 @@ struct rte_dma_dev_ops { rte_dma_stats_get_t stats_get; rte_dma_stats_reset_t stats_reset; + rte_dma_vchan_status_t vchan_status; rte_dma_dump_t dev_dump; }; diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index e17207b212..8785e14648 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