From patchwork Tue Jul 6 20:28:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95423 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 8AAAAA0C48; Tue, 6 Jul 2021 22:29:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E7C84133E; Tue, 6 Jul 2021 22:29:12 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 42B374067C for ; Tue, 6 Jul 2021 22:29:10 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470313" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470313" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522056" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:04 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:33 +0100 Message-Id: <20210706202841.661302-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 1/9] dmadev: add missing exports 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" Export the rte_dmadevices array and the allocate and release functions which are needed by PMDs. Signed-off-by: Bruce Richardson --- drivers/meson.build | 1 + lib/dmadev/rte_dmadev.c | 2 ++ lib/dmadev/version.map | 3 +++ 3 files changed, 6 insertions(+) diff --git a/drivers/meson.build b/drivers/meson.build index bc6f4f567..f09a9172c 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -9,6 +9,7 @@ subdirs = [ 'common/mlx5', # depends on bus. 'common/qat', # depends on bus. 'common/sfc_efx', # depends on bus. + 'dma', # depends on bus. 'mempool', # depends on common and bus. 'net', # depends on common, bus, mempool 'raw', # depends on common, bus and net. diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index a94e83984..855f4d272 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -372,6 +372,7 @@ rte_dmadev_find_free_device_index(void) return RTE_DMADEV_MAX_DEVS; } +__rte_experimental struct rte_dmadev * rte_dmadev_pmd_allocate(const char *name, size_t dev_priv_size, int socket_id) { @@ -414,6 +415,7 @@ rte_dmadev_pmd_allocate(const char *name, size_t dev_priv_size, int socket_id) return dev; } +__rte_experimental int rte_dmadev_pmd_release(struct rte_dmadev *dev) { diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index 383b3ca5f..a0a121f3a 100644 --- a/lib/dmadev/version.map +++ b/lib/dmadev/version.map @@ -1,6 +1,8 @@ EXPERIMENTAL { global: + rte_dmadevices; + rte_dmadev_pmd_allocate; rte_dmadev_count; rte_dmadev_get_dev_id; rte_dmadev_socket_id; @@ -19,6 +21,7 @@ EXPERIMENTAL { rte_dmadev_fill_sg; rte_dmadev_fence; rte_dmadev_perform; + rte_dmadev_pmd_release; rte_dmadev_completed; rte_dmadev_completed_fails; rte_dmadev_stats_get; From patchwork Tue Jul 6 20:28:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95422 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 25D7FA0C48; Tue, 6 Jul 2021 22:29:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11EB141333; Tue, 6 Jul 2021 22:29:11 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id A15DA4067C for ; Tue, 6 Jul 2021 22:29:09 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470315" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470315" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522064" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:06 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:34 +0100 Message-Id: <20210706202841.661302-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 2/9] dmadev: change virtual addresses to IOVA 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" For 32-bit builds, iova's are 64-bit still, so to ensure we can still use PA mode on 32-bit we need to convert all enqueue "void *" parameters to rte_iova_t Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.h | 8 ++++---- lib/dmadev/rte_dmadev_core.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index f74fc6adb..1659ceaf2 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -133,8 +133,8 @@ typedef int32_t dma_cookie_t; * dma_scatterlist - can hold scatter DMA operation request */ struct dma_scatterlist { - void *src; - void *dst; + rte_iova_t src; + rte_iova_t dst; uint32_t length; }; @@ -505,7 +505,7 @@ rte_dmadev_queue_info_get(uint16_t dev_id, uint16_t vq_id, */ __rte_experimental static inline dma_cookie_t -rte_dmadev_copy(uint16_t dev_id, uint16_t vq_id, void *src, void *dst, +rte_dmadev_copy(uint16_t dev_id, uint16_t vq_id, rte_iova_t src, rte_iova_t dst, uint32_t length, uint64_t flags) { struct rte_dmadev *dev = &rte_dmadevices[dev_id]; @@ -579,7 +579,7 @@ rte_dmadev_copy_sg(uint16_t dev_id, uint16_t vq_id, __rte_experimental static inline dma_cookie_t rte_dmadev_fill(uint16_t dev_id, uint16_t vq_id, uint64_t pattern, - void *dst, uint32_t length, uint64_t flags) + rte_iova_t dst, uint32_t length, uint64_t flags) { struct rte_dmadev *dev = &rte_dmadevices[dev_id]; return (*dev->fill)(dev, vq_id, pattern, dst, length, flags); diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h index a3afea251..80b56ed83 100644 --- a/lib/dmadev/rte_dmadev_core.h +++ b/lib/dmadev/rte_dmadev_core.h @@ -17,7 +17,7 @@ struct rte_dmadev; typedef dma_cookie_t (*dmadev_copy_t)(struct rte_dmadev *dev, uint16_t vq_id, - void *src, void *dst, + rte_iova_t src, rte_iova_t dst, uint32_t length, uint64_t flags); /**< @internal Function used to enqueue a copy operation. */ @@ -27,7 +27,7 @@ typedef dma_cookie_t (*dmadev_copy_sg_t)(struct rte_dmadev *dev, uint16_t vq_id, /**< @internal Function used to enqueue a scatter list copy operation. */ typedef dma_cookie_t (*dmadev_fill_t)(struct rte_dmadev *dev, uint16_t vq_id, - uint64_t pattern, void *dst, + uint64_t pattern, rte_iova_t dst, uint32_t length, uint64_t flags); /**< @internal Function used to enqueue a fill operation. */ From patchwork Tue Jul 6 20:28:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95424 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 B54FDA0C48; Tue, 6 Jul 2021 22:29:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D79E413C1; Tue, 6 Jul 2021 22:29:13 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id B2B474132E for ; Tue, 6 Jul 2021 22:29:10 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470321" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470321" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522068" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:07 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:35 +0100 Message-Id: <20210706202841.661302-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 3/9] dmadev: add dump 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" a dump() function to print the state of a device to a file (e.g. sterr or stdout) is very useful for debugging drivers. Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.c | 17 +++++++++++++++++ lib/dmadev/rte_dmadev.h | 19 +++++++++++++++++++ lib/dmadev/rte_dmadev_pmd.h | 5 +++++ lib/dmadev/version.map | 1 + 4 files changed, 42 insertions(+) diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 855f4d272..ffd7c5b97 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -345,6 +345,23 @@ rte_dmadev_xstats_reset(uint16_t dev_id, const uint32_t ids[], uint32_t nb_ids) return (*dev->dev_ops->xstats_reset)(dev, ids, nb_ids); } +int +rte_dmadev_dump(uint16_t dev_id, FILE *f) +{ + struct rte_dmadev *dev = &rte_dmadevices[dev_id]; + + RTE_DMADEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + + fprintf(f, "DMA Dev %u, '%s' [%s]\n", dev->dev_id, dev->name, + dev->started ? "started" : "stopped"); + fprintf(f, " Driver: %s\n", dev->driver_name); + fprintf(f, " Socket Id: %d\n", dev->socket_id); + + if (dev->dev_ops->dump != NULL) + return (*dev->dev_ops->dump)(dev, f); + return 0; +} + int rte_dmadev_selftest(uint16_t dev_id) { diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index 1659ceaf2..d64df17bd 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -357,6 +357,25 @@ __rte_experimental int rte_dmadev_close(uint16_t dev_id); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Dump DMA device info. + * + * @param dev_id + * The identifier of the device. + * + * @param f + * The file to write the output to. + * + * @return + * 0 on success. Non-zero otherwise. + */ +__rte_experimental +int +rte_dmadev_dump(uint16_t dev_id, FILE *f); + /** * @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 ef03cf7cd..428ddc943 100644 --- a/lib/dmadev/rte_dmadev_pmd.h +++ b/lib/dmadev/rte_dmadev_pmd.h @@ -99,6 +99,9 @@ typedef int (*dmadev_close_t)(struct rte_dmadev *dev); typedef int (*dmadev_reset_t)(struct rte_dmadev *dev); /**< @internal Function used to reset a configured device. */ +typedef int (*dmadev_dump_t)(struct rte_dmadev *dev, FILE *f); +/**< @internal Function used to dump out the state of a device for debugging. */ + typedef int (*dmadev_queue_setup_t)(struct rte_dmadev *dev, const struct rte_dmadev_queue_conf *conf); /**< @internal Function used to allocate and set up a virt queue. */ @@ -147,6 +150,8 @@ struct rte_dmadev_ops { dmadev_close_t dev_close; /**< Reset device. */ dmadev_reset_t dev_reset; + /**< Dump device info for debugging */ + dmadev_dump_t dump; /**< Allocate and set up a virt queue. */ dmadev_queue_setup_t queue_setup; diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index a0a121f3a..ed051d54f 100644 --- a/lib/dmadev/version.map +++ b/lib/dmadev/version.map @@ -4,6 +4,7 @@ EXPERIMENTAL { rte_dmadevices; rte_dmadev_pmd_allocate; rte_dmadev_count; + rte_dmadev_dump; rte_dmadev_get_dev_id; rte_dmadev_socket_id; rte_dmadev_info_get; From patchwork Tue Jul 6 20:28: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: 95425 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 B6D6EA0C48; Tue, 6 Jul 2021 22:29:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90891413DA; Tue, 6 Jul 2021 22:29:14 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 217BC4133B for ; Tue, 6 Jul 2021 22:29:11 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470327" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470327" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522072" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:09 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:36 +0100 Message-Id: <20210706202841.661302-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 4/9] dmadev: remove xstats functions 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" remove the xstats function calls, as they are not needed for this class as-yet. Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.c | 63 -------------------------- lib/dmadev/rte_dmadev.h | 89 ------------------------------------- lib/dmadev/rte_dmadev_pmd.h | 19 -------- lib/dmadev/version.map | 3 -- 4 files changed, 174 deletions(-) diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index ffd7c5b97..fed168675 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -282,69 +282,6 @@ rte_dmadev_stats_reset(uint16_t dev_id, int vq_id) return (*dev->dev_ops->stats_reset)(dev, vq_id); } -static int -xstats_get_count(uint16_t dev_id) -{ - struct rte_dmadev *dev = &rte_dmadevices[dev_id]; - - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_get_names, -ENOTSUP); - - return (*dev->dev_ops->xstats_get_names)(dev, NULL, 0); -} - -int -rte_dmadev_xstats_names_get(uint16_t dev_id, - struct rte_dmadev_xstats_name *xstats_names, - uint32_t size) -{ - struct rte_dmadev *dev; - int cnt_expected_entries; - - RTE_DMADEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); - - cnt_expected_entries = xstats_get_count(dev_id); - - if (xstats_names == NULL || cnt_expected_entries < 0 || - (int)size < cnt_expected_entries || size == 0) - return cnt_expected_entries; - - dev = &rte_dmadevices[dev_id]; - - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_get_names, -ENOTSUP); - return (*dev->dev_ops->xstats_get_names)(dev, xstats_names, size); -} - -int -rte_dmadev_xstats_get(uint16_t dev_id, const uint32_t ids[], - uint64_t values[], uint32_t n) -{ - struct rte_dmadev *dev; - - RTE_DMADEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); - RTE_FUNC_PTR_OR_ERR_RET(ids, -EINVAL); - RTE_FUNC_PTR_OR_ERR_RET(values, -EINVAL); - - dev = &rte_dmadevices[dev_id]; - - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_get, -ENOTSUP); - - return (*dev->dev_ops->xstats_get)(dev, ids, values, n); -} - -int -rte_dmadev_xstats_reset(uint16_t dev_id, const uint32_t ids[], uint32_t nb_ids) -{ - struct rte_dmadev *dev; - - RTE_DMADEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); - - dev = &rte_dmadevices[dev_id]; - - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_reset, -ENOTSUP); - - return (*dev->dev_ops->xstats_reset)(dev, ids, nb_ids); -} - int rte_dmadev_dump(uint16_t dev_id, FILE *f) { diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index d64df17bd..2bfc0b619 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -824,95 +824,6 @@ __rte_experimental int rte_dmadev_stats_reset(uint16_t dev_id, int vq_id); -/** Maximum name length for extended statistics counters */ -#define RTE_DMA_DEV_XSTATS_NAME_SIZE 64 - -/** - * A name-key lookup element for extended statistics. - * - * This structure is used to map between names and ID numbers - * for extended ethdev statistics. - */ -struct rte_dmadev_xstats_name { - char name[RTE_DMA_DEV_XSTATS_NAME_SIZE]; -}; - -/** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * - * Retrieve names of extended statistics of a DMA device. - * - * @param dev_id - * The identifier of the device. - * @param[out] xstats_names - * Block of memory to insert names into. Must be at least size in capacity. - * If set to NULL, function returns required capacity. - * @param size - * Capacity of xstats_names (number of names). - * @return - * - positive value lower or equal to size: success. The return value - * is the number of entries filled in the stats table. - * - positive value higher than size: error, the given statistics table - * is too small. The return value corresponds to the size that should - * be given to succeed. The entries in the table are not valid and - * shall not be used by the caller. - * - negative value on error. - */ -__rte_experimental -int -rte_dmadev_xstats_names_get(uint16_t dev_id, - struct rte_dmadev_xstats_name *xstats_names, - uint32_t size); - -/** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * - * Retrieve extended statistics of a DMA device. - * - * @param dev_id - * The identifier of the device. - * @param ids - * The id numbers of the stats to get. The ids can be got from the stat - * position in the stat list from rte_dmadev_get_xstats_names(). - * @param[out] values - * The values for each stats request by ID. - * @param n - * The number of stats requested. - * - * @return - * - positive value: number of stat entries filled into the values array. - * - negative value on error. - */ -__rte_experimental -int -rte_dmadev_xstats_get(uint16_t dev_id, const uint32_t ids[], - uint64_t values[], uint32_t n); - -/** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * - * Reset the values of the xstats of the selected component in the device. - * - * @param dev_id - * The identifier of the device. - * @param ids - * Selects specific statistics to be reset. When NULL, all statistics - * will be reset. If non-NULL, must point to array of at least - * *nb_ids* size. - * @param nb_ids - * The number of ids available from the *ids* array. Ignored when ids is NULL. - * - * @return - * - zero: successfully reset the statistics to zero. - * - negative value on error. - */ -__rte_experimental -int -rte_dmadev_xstats_reset(uint16_t dev_id, const uint32_t ids[], uint32_t nb_ids); - /** * @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 428ddc943..d0ec43af6 100644 --- a/lib/dmadev/rte_dmadev_pmd.h +++ b/lib/dmadev/rte_dmadev_pmd.h @@ -120,19 +120,6 @@ typedef int (*dmadev_stats_get_t)(struct rte_dmadev *dev, int vq_id, typedef int (*dmadev_stats_reset_t)(struct rte_dmadev *dev, int vq_id); /**< @internal Function used to reset basic statistics. */ -typedef int (*dmadev_xstats_get_names_t)(const struct rte_dmadev *dev, - struct rte_dmadev_xstats_name *xstats_names, - uint32_t size); -/**< @internal Function used to get names of extended stats. */ - -typedef int (*dmadev_xstats_get_t)(const struct rte_dmadev *dev, - const uint32_t ids[], uint64_t values[], uint32_t n); -/**< @internal Function used to retrieve extended stats. */ - -typedef int (*dmadev_xstats_reset_t)(struct rte_dmadev *dev, - const uint32_t ids[], uint32_t nb_ids); -/**< @internal Function used to reset extended stats. */ - typedef int (*dmadev_selftest_t)(uint16_t dev_id); /**< @internal Function used to start dmadev selftest. */ @@ -164,12 +151,6 @@ struct rte_dmadev_ops { dmadev_stats_get_t stats_get; /**< Reset basic statistics. */ dmadev_stats_reset_t stats_reset; - /**< Get names of extended stats. */ - dmadev_xstats_get_names_t xstats_get_names; - /**< Get extended statistics. */ - dmadev_xstats_get_t xstats_get; - /**< Reset extended statistics values. */ - dmadev_xstats_reset_t xstats_reset; /**< Device selftest function */ dmadev_selftest_t dev_selftest; diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index ed051d54f..a4d6b539a 100644 --- a/lib/dmadev/version.map +++ b/lib/dmadev/version.map @@ -27,9 +27,6 @@ EXPERIMENTAL { rte_dmadev_completed_fails; rte_dmadev_stats_get; rte_dmadev_stats_reset; - rte_dmadev_xstats_names_get; - rte_dmadev_xstats_get; - rte_dmadev_xstats_reset; rte_dmadev_selftest; local: *; From patchwork Tue Jul 6 20:28:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95426 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 85265A0C48; Tue, 6 Jul 2021 22:29:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C7BE413E3; Tue, 6 Jul 2021 22:29:17 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id C994E413C6 for ; Tue, 6 Jul 2021 22:29:13 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470335" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470335" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522077" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:11 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:37 +0100 Message-Id: <20210706202841.661302-6-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 5/9] dmadev: drop cookie typedef 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" Rather than having a special type for the index values used in dmadev, just use regular int types, with appropriate return value notifications. Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.h | 59 ++++++++++++------------------------ lib/dmadev/rte_dmadev_core.h | 12 ++++---- 2 files changed, 26 insertions(+), 45 deletions(-) diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index 2bfc0b619..8cfe14dd2 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -106,29 +106,6 @@ extern "C" { #include #include -/** - * dma_cookie_t - an opaque DMA cookie - * - * If dma_cookie_t is >=0 it's a DMA operation request cookie, <0 it's a error - * code. - * When using cookies, comply with the following rules: - * a) Cookies for each virtual queue are independent. - * b) For a virt queue, the cookie are monotonically incremented, when it reach - * the INT_MAX, it wraps back to zero. - * c) The initial cookie of a virt queue is zero, after the device is stopped or - * reset, the virt queue's cookie needs to be reset to zero. - * Example: - * step-1: start one dmadev - * step-2: enqueue a copy operation, the cookie return is 0 - * step-3: enqueue a copy operation again, the cookie return is 1 - * ... - * step-101: stop the dmadev - * step-102: start the dmadev - * step-103: enqueue a copy operation, the cookie return is 0 - * ... - */ -typedef int32_t dma_cookie_t; - /** * dma_scatterlist - can hold scatter DMA operation request */ @@ -517,13 +494,14 @@ rte_dmadev_queue_info_get(uint16_t dev_id, uint16_t vq_id, * An opaque flags for this operation. * * @return - * dma_cookie_t: please refer to the corresponding definition. + * <0 on error, + * on success, index of enqueued copy job, monotonically increasing between 0..UINT16_MAX * * NOTE: The caller must ensure that the input parameter is valid and the * corresponding device supports the operation. */ __rte_experimental -static inline dma_cookie_t +static inline int rte_dmadev_copy(uint16_t dev_id, uint16_t vq_id, rte_iova_t src, rte_iova_t dst, uint32_t length, uint64_t flags) { @@ -552,13 +530,14 @@ rte_dmadev_copy(uint16_t dev_id, uint16_t vq_id, rte_iova_t src, rte_iova_t dst, * An opaque flags for this operation. * * @return - * dma_cookie_t: please refer to the corresponding definition. + * <0 on error, + * on success, index of enqueued copy job, monotonically increasing between 0..UINT16_MAX * * NOTE: The caller must ensure that the input parameter is valid and the * corresponding device supports the operation. */ __rte_experimental -static inline dma_cookie_t +static inline int rte_dmadev_copy_sg(uint16_t dev_id, uint16_t vq_id, const struct dma_scatterlist *sg, uint32_t sg_len, uint64_t flags) @@ -590,13 +569,14 @@ rte_dmadev_copy_sg(uint16_t dev_id, uint16_t vq_id, * An opaque flags for this operation. * * @return - * dma_cookie_t: please refer to the corresponding definition. + * <0 on error, + * on success, index of enqueued copy job, monotonically increasing between 0..UINT16_MAX * * NOTE: The caller must ensure that the input parameter is valid and the * corresponding device supports the operation. */ __rte_experimental -static inline dma_cookie_t +static inline int rte_dmadev_fill(uint16_t dev_id, uint16_t vq_id, uint64_t pattern, rte_iova_t dst, uint32_t length, uint64_t flags) { @@ -627,13 +607,14 @@ rte_dmadev_fill(uint16_t dev_id, uint16_t vq_id, uint64_t pattern, * An opaque flags for this operation. * * @return - * dma_cookie_t: please refer to the corresponding definition. + * <0 on error, + * on success, index of enqueued copy job, monotonically increasing between 0..UINT16_MAX * * NOTE: The caller must ensure that the input parameter is valid and the * corresponding device supports the operation. */ __rte_experimental -static inline dma_cookie_t +static inline int rte_dmadev_fill_sg(uint16_t dev_id, uint16_t vq_id, uint64_t pattern, const struct dma_scatterlist *sg, uint32_t sg_len, uint64_t flags) @@ -716,8 +697,8 @@ rte_dmadev_perform(uint16_t dev_id, uint16_t vq_id) * The identifier of virt queue. * @param nb_cpls * The maximum number of completed operations that can be processed. - * @param[out] cookie - * The last completed operation's cookie. + * @param[out] last_idx + * The last completed operation's index, as returned when entry was enqueued * @param[out] has_error * Indicates if there are transfer error. * @@ -730,11 +711,11 @@ rte_dmadev_perform(uint16_t dev_id, uint16_t vq_id) __rte_experimental static inline uint16_t rte_dmadev_completed(uint16_t dev_id, uint16_t vq_id, const uint16_t nb_cpls, - dma_cookie_t *cookie, bool *has_error) + uint16_t *last_idx, bool *has_error) { struct rte_dmadev *dev = &rte_dmadevices[dev_id]; has_error = false; - return (*dev->completed)(dev, vq_id, nb_cpls, cookie, has_error); + return (*dev->completed)(dev, vq_id, nb_cpls, last_idx, has_error); } /** @@ -752,8 +733,8 @@ rte_dmadev_completed(uint16_t dev_id, uint16_t vq_id, const uint16_t nb_cpls, * Indicates the size of status array. * @param[out] status * The error code of operations that failed to complete. - * @param[out] cookie - * The last failed completed operation's cookie. + * @param[out] last_idx + * The last failed completed operation's index. * * @return * The number of operations that failed to complete. @@ -765,10 +746,10 @@ __rte_experimental static inline uint16_t rte_dmadev_completed_fails(uint16_t dev_id, uint16_t vq_id, const uint16_t nb_status, uint32_t *status, - dma_cookie_t *cookie) + uint16_t *last_idx) { struct rte_dmadev *dev = &rte_dmadevices[dev_id]; - return (*dev->completed_fails)(dev, vq_id, nb_status, status, cookie); + return (*dev->completed_fails)(dev, vq_id, nb_status, status, last_idx); } struct rte_dmadev_stats { diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h index 80b56ed83..7fbefe8f9 100644 --- a/lib/dmadev/rte_dmadev_core.h +++ b/lib/dmadev/rte_dmadev_core.h @@ -16,22 +16,22 @@ struct rte_dmadev; -typedef dma_cookie_t (*dmadev_copy_t)(struct rte_dmadev *dev, uint16_t vq_id, +typedef int (*dmadev_copy_t)(struct rte_dmadev *dev, uint16_t vq_id, rte_iova_t src, rte_iova_t dst, uint32_t length, uint64_t flags); /**< @internal Function used to enqueue a copy operation. */ -typedef dma_cookie_t (*dmadev_copy_sg_t)(struct rte_dmadev *dev, uint16_t vq_id, +typedef int (*dmadev_copy_sg_t)(struct rte_dmadev *dev, uint16_t vq_id, const struct dma_scatterlist *sg, uint32_t sg_len, uint64_t flags); /**< @internal Function used to enqueue a scatter list copy operation. */ -typedef dma_cookie_t (*dmadev_fill_t)(struct rte_dmadev *dev, uint16_t vq_id, +typedef int (*dmadev_fill_t)(struct rte_dmadev *dev, uint16_t vq_id, uint64_t pattern, rte_iova_t dst, uint32_t length, uint64_t flags); /**< @internal Function used to enqueue a fill operation. */ -typedef dma_cookie_t (*dmadev_fill_sg_t)(struct rte_dmadev *dev, uint16_t vq_id, +typedef int (*dmadev_fill_sg_t)(struct rte_dmadev *dev, uint16_t vq_id, uint64_t pattern, const struct dma_scatterlist *sg, uint32_t sg_len, uint64_t flags); /**< @internal Function used to enqueue a scatter list fill operation. */ @@ -44,12 +44,12 @@ typedef int (*dmadev_perform_t)(struct rte_dmadev *dev, uint16_t vq_id); typedef uint16_t (*dmadev_completed_t)(struct rte_dmadev *dev, uint16_t vq_id, const uint16_t nb_cpls, - dma_cookie_t *cookie, bool *has_error); + uint16_t *last_idx, bool *has_error); /**< @internal Function used to return number of successful completed operations */ typedef uint16_t (*dmadev_completed_fails_t)(struct rte_dmadev *dev, uint16_t vq_id, const uint16_t nb_status, - uint32_t *status, dma_cookie_t *cookie); + uint32_t *status, uint16_t *last_idx); /**< @internal Function used to return number of failed completed operations */ #define RTE_DMADEV_NAME_MAX_LEN 64 /**< Max length of name of DMA PMD */ From patchwork Tue Jul 6 20:28:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95427 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 0B20BA0C48; Tue, 6 Jul 2021 22:29:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C5DD413FE; Tue, 6 Jul 2021 22:29:18 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id E95DD413E3 for ; Tue, 6 Jul 2021 22:29:14 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470343" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470343" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522081" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:13 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:38 +0100 Message-Id: <20210706202841.661302-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 6/9] dmadev: allow NULL parameters to completed ops call 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" Allow the user to skip passing the "out" parameters to the rte_dmadev_completed() API call, by using local replacements in the inline function. This simplifies drivers, and compilers should be able to remove the branches at compile time in many cases. Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index 8cfe14dd2..eb78f3805 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -698,9 +698,11 @@ rte_dmadev_perform(uint16_t dev_id, uint16_t vq_id) * @param nb_cpls * The maximum number of completed operations that can be processed. * @param[out] last_idx - * The last completed operation's index, as returned when entry was enqueued + * The last completed operation's index, as returned when entry was enqueued. + * If not required, NULL can be passed in. * @param[out] has_error * Indicates if there are transfer error. + * If not required, may be passed as NULL. * * @return * The number of operations that successful completed. @@ -714,7 +716,20 @@ rte_dmadev_completed(uint16_t dev_id, uint16_t vq_id, const uint16_t nb_cpls, uint16_t *last_idx, bool *has_error) { struct rte_dmadev *dev = &rte_dmadevices[dev_id]; - has_error = false; + bool err = false; + uint16_t idx; + + /* ensure the pointer values are non-null to simplify drivers. + * In most cases these should be compile time evaluated, since this is an inline function. + * - If NULL is explicitly passed as parameter, then compiler knows the value is NULL + * - If address of local variable is passed as parameter, then compiler can + * know it's non-NULL. + */ + if (has_error == NULL) + has_error = &err; + if (last_idx == NULL) + last_idx = &idx; + return (*dev->completed)(dev, vq_id, nb_cpls, last_idx, has_error); } From patchwork Tue Jul 6 20:28:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95428 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 3BD79A0C48; Tue, 6 Jul 2021 22:29:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F035841421; Tue, 6 Jul 2021 22:29:19 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 87CBC413F8 for ; Tue, 6 Jul 2021 22:29:16 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470353" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470353" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522089" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:14 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:39 +0100 Message-Id: <20210706202841.661302-8-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 7/9] dmadev: stats structure updates 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" Drop the failed enqueue count since that is best tracked by the application so that retries of the same job can be counted as desired by the app developer. Since the "doorbell" function is separate from the actual functions to enqueue descriptors, track a separate stat for jobs which were submitted to hardware, in case the "enqueued" count includes jobs which were not yet "doorbelled". Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index eb78f3805..bdb531a53 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -768,14 +768,10 @@ rte_dmadev_completed_fails(uint16_t dev_id, uint16_t vq_id, } struct rte_dmadev_stats { - uint64_t enqueue_fail_count; - /**< Conut of all operations which failed enqueued */ - uint64_t enqueued_count; - /**< Count of all operations which successful enqueued */ - uint64_t completed_fail_count; - /**< Count of all operations which failed to complete */ - uint64_t completed_count; - /**< Count of all operations which successful complete */ + uint64_t enqueued_count; /**< Count of operations which were successful enqueued */ + uint64_t submitted_count; /**< Count of operations which were submitted to hardware */ + uint64_t completed_fail_count; /**< Count of operations which failed to complete */ + uint64_t completed_count; /**< Count of operations which successful complete */ }; /** From patchwork Tue Jul 6 20:28:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95429 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 1D493A0C48; Tue, 6 Jul 2021 22:29:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4DD5C41426; Tue, 6 Jul 2021 22:29:22 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 489624067C for ; Tue, 6 Jul 2021 22:29:18 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470360" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470360" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522093" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:16 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:40 +0100 Message-Id: <20210706202841.661302-9-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 8/9] drivers: add dma driver category 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" Signed-off-by: Bruce Richardson --- drivers/dma/meson.build | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 drivers/dma/meson.build diff --git a/drivers/dma/meson.build b/drivers/dma/meson.build new file mode 100644 index 000000000..986b28be5 --- /dev/null +++ b/drivers/dma/meson.build @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +if is_windows + subdir_done() +endif + +drivers = [ +] + +std_deps = ['dmadev'] From patchwork Tue Jul 6 20:28:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 95430 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 CCA3EA0C48; Tue, 6 Jul 2021 22:29:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 69AC44140A; Tue, 6 Jul 2021 22:29:23 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 1C8A141424 for ; Tue, 6 Jul 2021 22:29:19 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470365" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470365" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522098" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:17 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:41 +0100 Message-Id: <20210706202841.661302-10-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC UPDATE PATCH 9/9] app/test: add basic dmadev unit test 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 some basic dmadev unit tests for testing drivers and the library itself. Signed-off-by: Bruce Richardson --- app/test/meson.build | 2 + app/test/test_dmadev.c | 320 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 322 insertions(+) create mode 100644 app/test/test_dmadev.c diff --git a/app/test/meson.build b/app/test/meson.build index 0a5f42557..223ca210a 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -36,6 +36,7 @@ test_sources = files( 'test_debug.c', 'test_distributor.c', 'test_distributor_perf.c', + 'test_dmadev.c', 'test_eal_flags.c', 'test_eal_fs.c', 'test_efd.c', @@ -155,6 +156,7 @@ test_deps = [ 'cmdline', 'cryptodev', 'distributor', + 'dmadev', 'efd', 'ethdev', 'eventdev', diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c new file mode 100644 index 000000000..df301b385 --- /dev/null +++ b/app/test/test_dmadev.c @@ -0,0 +1,320 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021 Intel Corporation + */ + +#include + +#include +#include +#include "test.h" + +#define COPY_LEN 1024 + +static struct rte_mempool *pool; +static uint16_t id_count = 0; + +#define PRINT_ERR(...) print_err(__func__, __LINE__, __VA_ARGS__) + +static inline int +__rte_format_printf(3, 4) +print_err(const char *func, int lineno, const char *format, ...) +{ + va_list ap; + int ret; + + ret = fprintf(stderr, "In %s:%d - ", func, lineno); + va_start(ap, format); + ret += vfprintf(stderr, format, ap); + va_end(ap); + + return ret; +} + +static int +do_multi_copies(int dev_id, int split_batches, int split_completions) +{ + struct rte_mbuf *srcs[32], *dsts[32]; + unsigned int i, j; + bool dma_err = false; + + for (i = 0; i < RTE_DIM(srcs); i++) { + char *src_data; + + if (split_batches && i == RTE_DIM(srcs) / 2) + rte_dmadev_perform(dev_id, 0); + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], char *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN; j++) + src_data[j] = rand() & 0xFF; + + if (rte_dmadev_copy(dev_id, 0, srcs[i]->buf_iova + srcs[i]->data_off, + dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) != id_count++) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", i); + return -1; + } + } + rte_dmadev_perform(dev_id, 0); + usleep(100); + + if (split_completions) { + /* gather completions in two halves */ + uint16_t half_len = RTE_DIM(srcs) / 2; + int ret = rte_dmadev_completed(dev_id, 0, half_len, NULL, &dma_err); + if (ret != half_len || dma_err) { + PRINT_ERR("Error with rte_dmadev_completed - first half. ret = %d, expected ret = %u, dma_err = %d\n", + ret, half_len, dma_err); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + ret = rte_dmadev_completed(dev_id, 0, half_len, NULL, &dma_err); + if (ret != half_len || dma_err) { + PRINT_ERR("Error with rte_dmadev_completed - second half. ret = %d, expected ret = %u, dma_err = %d\n", + ret, half_len, dma_err); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + } else { + /* gather all completions in one go */ + if ((j = rte_dmadev_completed(dev_id, 0, RTE_DIM(srcs), NULL, + &dma_err)) != RTE_DIM(srcs) || dma_err) { + PRINT_ERR("Error with rte_dmadev_completed, %u [expected: %zu], dma_err = %d\n", + j, RTE_DIM(srcs), dma_err); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + } + + /* check for empty */ + if (rte_dmadev_completed(dev_id, 0, RTE_DIM(srcs), NULL, &dma_err) != 0 || dma_err) { + PRINT_ERR("Error with rte_dmadev_completed - ops unexpectedly returned\n"); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + + for (i = 0; i < RTE_DIM(srcs); i++) { + char *src_data, *dst_data; + + src_data = rte_pktmbuf_mtod(srcs[i], char *); + dst_data = rte_pktmbuf_mtod(dsts[i], char *); + for (j = 0; j < COPY_LEN; j++) + if (src_data[j] != dst_data[j]) { + PRINT_ERR("Error with copy of packet %u, byte %u\n", i, j); + return -1; + } + rte_pktmbuf_free(srcs[i]); + rte_pktmbuf_free(dsts[i]); + } + return 0; +} + +static int +test_enqueue_copies(int dev_id) +{ + unsigned int i; + uint16_t id; + + /* test doing a single copy */ + do { + struct rte_mbuf *src, *dst; + char *src_data, *dst_data; + + src = rte_pktmbuf_alloc(pool); + dst = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(src, char *); + dst_data = rte_pktmbuf_mtod(dst, char *); + + for (i = 0; i < COPY_LEN; i++) + src_data[i] = rand() & 0xFF; + + id = rte_dmadev_copy(dev_id, 0, src->buf_iova + src->data_off, + dst->buf_iova + dst->data_off, COPY_LEN, 0); + if (id != id_count) { + PRINT_ERR("Error with rte_dmadev_copy, got %u, expected %u\n", + id, id_count); + return -1; + } + if (rte_dmadev_perform(dev_id, 0) < 0) { + PRINT_ERR("Error with rte_dmadev_perform\n"); + return -1; + } + /* give time for copy to finish, then check it was done */ + usleep(10); + + for (i = 0; i < COPY_LEN; i++) { + if (dst_data[i] != src_data[i]) { + PRINT_ERR("Data mismatch at char %u [Got %02x not %02x]\n", i, + dst_data[i], src_data[i]); + rte_dmadev_dump(dev_id, stderr); + return -1; + } + } + + /* now check completion works */ + if (rte_dmadev_completed(dev_id, 0, 1, &id, NULL) != 1) { + PRINT_ERR("Error with rte_dmadev_completed\n"); + return -1; + } + if (id != id_count) { + PRINT_ERR("Error:incorrect job id received, %u [expected %u]\n", id, id_count); + return -1; + } + + rte_pktmbuf_free(src); + rte_pktmbuf_free(dst); + + /* now check completion works */ + if (rte_dmadev_completed(dev_id, 0, 1, NULL, NULL) != 0) { + PRINT_ERR("Error with rte_dmadev_completed in empty check\n"); + return -1; + } + id_count++; + + } while (0); + + /* test doing a multiple single copies */ + do { + const uint16_t max_ops = 4; + struct rte_mbuf *src, *dst; + char *src_data, *dst_data; + + src = rte_pktmbuf_alloc(pool); + dst = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(src, char *); + dst_data = rte_pktmbuf_mtod(dst, char *); + + for (i = 0; i < COPY_LEN; i++) + src_data[i] = rand() & 0xFF; + + /* perform the same copy times */ + for (i = 0; i < max_ops; i++) { + if (rte_dmadev_copy(dev_id, 0, + src->buf_iova + src->data_off, + dst->buf_iova + dst->data_off, + COPY_LEN, 0) != id_count++) { + PRINT_ERR("Error with rte_dmadev_copy\n"); + return -1; + } + rte_dmadev_perform(dev_id, 0); + } + usleep(10); + + if ((i = rte_dmadev_completed(dev_id, 0, max_ops * 2, &id, NULL)) != max_ops) { + PRINT_ERR("Error with rte_dmadev_completed, got %u not %u\n", i, max_ops); + return -1; + } + if (id != id_count - 1) { + PRINT_ERR("Error, incorrect job id returned: got %u not %u\n", id, id_count - 1); + return -1; + } + for (i = 0; i < COPY_LEN; i++) { + if (dst_data[i] != src_data[i]) { + PRINT_ERR("Data mismatch at char %u\n", i); + return -1; + } + } + rte_pktmbuf_free(src); + rte_pktmbuf_free(dst); + } while (0); + + /* test doing multiple copies */ + return do_multi_copies(dev_id, 0, 0) /* enqueue and complete one batch at a time */ + || do_multi_copies(dev_id, 1, 0) /* enqueue 2 batches and then complete both */ + || do_multi_copies(dev_id, 0, 1); /* enqueue 1 batch, then complete in two halves */ +} + +static int +test_dmadev_instance(uint16_t dev_id) +{ +#define TEST_RINGSIZE 512 + struct rte_dmadev_info info; + struct rte_dmadev_conf conf = { .nb_hw_queues = 1}; + struct rte_dmadev_queue_conf qconf = { .nb_desc = TEST_RINGSIZE }; + int i; + + rte_dmadev_info_get(dev_id, &info); + if (info.max_hw_queues < 1) { + PRINT_ERR("Error, no queues reported on device id %u\n", dev_id); + return -1; + } + if (rte_dmadev_configure(dev_id, &conf) != 0) { + PRINT_ERR("Error with rte_rawdev_configure()\n"); + return -1; + } + if (rte_dmadev_queue_setup(dev_id, &qconf) != 0) { + PRINT_ERR("Error with queue configuration\n"); + return -1; + } + rte_dmadev_info_get(dev_id, &info); + if (info.nb_hw_queues != 1) { + PRINT_ERR("Error, no configured queues reported on device id %u\n", dev_id); + return -1; + } + + if (rte_dmadev_start(dev_id) != 0) { + PRINT_ERR("Error with rte_rawdev_start()\n"); + return -1; + } + id_count = 0; + + /* create a mempool for running tests */ + pool = rte_pktmbuf_pool_create("TEST_DMADEV_POOL", + TEST_RINGSIZE * 2, /* n == num elements */ + 32, /* cache size */ + 0, /* priv size */ + 2048, /* data room size */ + info.socket_id); + if (pool == NULL) { + PRINT_ERR("Error with mempool creation\n"); + return -1; + } + + /* run the test cases */ + printf("DMA Dev: %u, Running Copy Tests\n", dev_id); + for (i = 0; i < 768; i++) { + struct rte_dmadev_stats stats; + + if (test_enqueue_copies(dev_id) != 0) { + printf("Error with iteration %d\n", i); + rte_dmadev_dump(dev_id, stdout); + goto err; + } + + rte_dmadev_stats_get(dev_id, 0, &stats); + printf("Ops enqueued: %"PRIu64"\t", stats.enqueued_count); + printf("Ops completed: %"PRIu64"\r", stats.completed_count); + } + printf("\n"); + + rte_mempool_free(pool); + rte_dmadev_stop(dev_id); + + return 0; + +err: + rte_mempool_free(pool); + rte_dmadev_stop(dev_id); + return -1; +} + +static int +test_dmadevs(void) +{ + int i; + + if (rte_dmadev_count() == 0) + return TEST_SKIPPED; + + for (i = 0; i < RTE_DMADEV_MAX_DEVS; i++) + if (rte_dmadevices[i].attached && test_dmadev_instance(i) < 0) + return -1; + return 0; +} + +REGISTER_TEST_COMMAND(dmadev_autotest, test_dmadevs);