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 6FFFAA0548; Fri, 24 Sep 2021 12:30:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E43B341302; Fri, 24 Sep 2021 12:30:01 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 1208A41301 for ; Fri, 24 Sep 2021 12:30:00 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10116"; a="203541128" X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="203541128" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2021 03:30:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="436117610" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by orsmga006.jf.intel.com with ESMTP; 24 Sep 2021 03:29:59 -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: Fri, 24 Sep 2021 11:29:35 +0100 Message-Id: <20210924102942.2878051-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210924102942.2878051-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> <20210924102942.2878051-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 02/13] dma/skeleton: add channel status function 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" In order to avoid timing errors with the unit tests, we need to ensure we have the vchan_status function to report when a channel is idle. Signed-off-by: Bruce Richardson --- drivers/dma/skeleton/skeleton_dmadev.c | 18 +++++++++++++++++- drivers/dma/skeleton/skeleton_dmadev.h | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index 876878bb78..ada9a3be68 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -80,7 +80,7 @@ cpucopy_thread(void *param) hw->zero_req_count = 0; rte_memcpy(desc->dst, desc->src, desc->len); - hw->completed_count++; + __atomic_add_fetch(&hw->completed_count, 1, __ATOMIC_RELEASE); (void)rte_ring_enqueue(hw->desc_completed, (void *)desc); } @@ -258,6 +258,21 @@ skeldma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, return vchan_setup(hw, conf->nb_desc); } +static int +skeldma_vchan_status(const struct rte_dma_dev *dev, + uint16_t vchan, enum rte_dma_vchan_status *status) +{ + struct skeldma_hw *hw = dev->dev_private; + + RTE_SET_USED(vchan); + + *status = RTE_DMA_VCHAN_IDLE; + if (hw->submitted_count != __atomic_load_n(&hw->completed_count, __ATOMIC_ACQUIRE) + || hw->zero_req_count == 0) + *status = RTE_DMA_VCHAN_ACTIVE; + return 0; +} + static int skeldma_stats_get(const struct rte_dma_dev *dev, uint16_t vchan, struct rte_dma_stats *stats, uint32_t stats_sz) @@ -425,6 +440,7 @@ static const struct rte_dma_dev_ops skeldma_ops = { .dev_close = skeldma_close, .vchan_setup = skeldma_vchan_setup, + .vchan_status = skeldma_vchan_status, .stats_get = skeldma_stats_get, .stats_reset = skeldma_stats_reset, diff --git a/drivers/dma/skeleton/skeleton_dmadev.h b/drivers/dma/skeleton/skeleton_dmadev.h index eaa52364bf..91eb5460fc 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.h +++ b/drivers/dma/skeleton/skeleton_dmadev.h @@ -54,7 +54,7 @@ struct skeldma_hw { /* Cache delimiter for cpucopy thread's operation data */ char cache2 __rte_cache_aligned; - uint32_t zero_req_count; + volatile uint32_t zero_req_count; uint64_t completed_count; }; -- 2.30.2