From patchwork Fri Sep 24 10:29:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 99570 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B66A1A0548; Fri, 24 Sep 2021 12:30:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ECC47412F8; Fri, 24 Sep 2021 12:30:04 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id B210E412F8 for ; Fri, 24 Sep 2021 12:30:03 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10116"; a="203541132" X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="203541132" 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:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="436117640" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by orsmga006.jf.intel.com with ESMTP; 24 Sep 2021 03:30:01 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, fengchengwen@huawei.com, jerinj@marvell.com Date: Fri, 24 Sep 2021 11:29:36 +0100 Message-Id: <20210924102942.2878051-4-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 Subject: [dpdk-dev] [PATCH v6 03/13] dmadev: add burst capacity API 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" From: Kevin Laatz Add a burst capacity check API to the dmadev library. This API is useful to applications which need to how many descriptors can be enqueued in the current batch. For example, it could be used to determine whether all segments of a multi-segment packet can be enqueued in the same batch or not (to avoid half-offload of the packet). Signed-off-by: Kevin Laatz Reviewed-by: Conor Walsh --- lib/dmadev/rte_dmadev.h | 31 +++++++++++++++++++++++++++++++ lib/dmadev/rte_dmadev_core.h | 6 ++++-- lib/dmadev/version.map | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index f4c6546d87..bdba19b947 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -1100,6 +1100,37 @@ rte_dma_completed_status(int16_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. + * + * Check remaining capacity in descriptor ring for the current burst. + * + * @param dev_id + * The identifier of the device. + * @param vchan + * The identifier of virtual DMA channel. + * + * @return + * - Remaining space in the descriptor ring for the current burst. + * - 0 on error + */ +__rte_experimental +static inline uint16_t +rte_dma_burst_capacity(int16_t dev_id, uint16_t vchan) +{ + const struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; + +#ifdef RTE_DMADEV_DEBUG + if (!rte_dma_is_valid(dev_id) || !dev->data->dev_started || + vchan >= dev->data->dev_conf.nb_vchans || + nb_cpls == 0 || status == NULL) + return 0; + RTE_FUNC_PTR_OR_ERR_RET(*dev->burst_capacity, 0); +#endif + return (*dev->burst_capacity)(dev, vchan); +} + #ifdef __cplusplus } #endif diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h index 0eec1aa43b..fd6a737d46 100644 --- a/lib/dmadev/rte_dmadev_core.h +++ b/lib/dmadev/rte_dmadev_core.h @@ -58,6 +58,9 @@ 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 the remaining space in descriptor ring. */ +typedef uint16_t (*rte_dma_burst_capacity_t)(const struct rte_dma_dev *dev, uint16_t vchan); + /** @internal Used to dump internal information. */ typedef int (*rte_dma_dump_t)(const struct rte_dma_dev *dev, FILE *f); @@ -124,7 +127,6 @@ struct rte_dma_dev_ops { rte_dma_dump_t dev_dump; rte_dma_vchan_status_t vchan_status; - }; /** @@ -171,7 +173,7 @@ struct rte_dma_dev { rte_dma_submit_t submit; rte_dma_completed_t completed; rte_dma_completed_status_t completed_status; - void *reserved_cl0; + rte_dma_burst_capacity_t burst_capacity; /** Reserve space for future IO functions, while keeping data and * dev_ops pointers on the second cacheline. */ diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index 40ea517016..66420c4ede 100644 --- a/lib/dmadev/version.map +++ b/lib/dmadev/version.map @@ -1,6 +1,7 @@ EXPERIMENTAL { global: + rte_dma_burst_capacity; rte_dma_close; rte_dma_completed; rte_dma_completed_status;