From patchwork Thu Aug 26 18:32:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 97395 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 4BA32A0C43; Thu, 26 Aug 2021 20:33:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12B9E41238; Thu, 26 Aug 2021 20:33:21 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id F321341238 for ; Thu, 26 Aug 2021 20:33:18 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217847116" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217847116" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 11:33:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685030797" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 11:33:17 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, Chengwen Feng , jerinj@marvell.com, Bruce Richardson Date: Thu, 26 Aug 2021 19:32:55 +0100 Message-Id: <20210826183301.333442-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826183301.333442-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 1/7] app/test: take API tests from skeleton dmadev 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 the API level tests as self-test for the skeleton driver, we can have these tests included directly into the autotest, so that potentially other drivers can use them in future. Signed-off-by: Bruce Richardson --- app/test/meson.build | 1 + app/test/test_dmadev.c | 12 ++++++++-- .../test/test_dmadev_api.c | 24 ++++++++----------- drivers/dma/skeleton/meson.build | 1 - drivers/dma/skeleton/skeleton_dmadev.c | 6 +++++ 5 files changed, 27 insertions(+), 17 deletions(-) rename drivers/dma/skeleton/skeleton_dmadev_test.c => app/test/test_dmadev_api.c (96%) diff --git a/app/test/meson.build b/app/test/meson.build index 881cb4f655..9027eba3a4 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -44,6 +44,7 @@ test_sources = files( 'test_distributor.c', 'test_distributor_perf.c', 'test_dmadev.c', + 'test_dmadev_api.c', 'test_eal_flags.c', 'test_eal_fs.c', 'test_efd.c', diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 90e8faafa5..62fe27b7e8 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -9,15 +9,23 @@ #include "test.h" +/* from test_dmadev_api.c */ +extern int test_dmadev_api(uint16_t dev_id); + static int test_dmadev_selftest_skeleton(void) { const char *pmd = "dma_skeleton"; + int id; int ret; + if (rte_vdev_init(pmd, NULL) < 0) + return TEST_SKIPPED; + id = rte_dmadev_get_dev_id(pmd); + if (id < 0) + return TEST_SKIPPED; printf("\n### Test dmadev infrastructure using skeleton driver\n"); - rte_vdev_init(pmd, NULL); - ret = rte_dmadev_selftest(rte_dmadev_get_dev_id(pmd)); + ret = test_dmadev_api(id); rte_vdev_uninit(pmd); return ret; diff --git a/drivers/dma/skeleton/skeleton_dmadev_test.c b/app/test/test_dmadev_api.c similarity index 96% rename from drivers/dma/skeleton/skeleton_dmadev_test.c rename to app/test/test_dmadev_api.c index be56f07262..8b93628e1c 100644 --- a/drivers/dma/skeleton/skeleton_dmadev_test.c +++ b/app/test/test_dmadev_api.c @@ -2,20 +2,16 @@ * Copyright(c) 2021 HiSilicon Limited. */ +#include #include #include #include #include #include +#include -/* Using relative path as skeleton_dmadev is not part of exported headers */ -#include "skeleton_dmadev.h" - -#define SKELDMA_TEST_DEBUG(fmt, args...) \ - SKELDMA_LOG(DEBUG, fmt, ## args) -#define SKELDMA_TEST_INFO(fmt, args...) \ - SKELDMA_LOG(INFO, fmt, ## args) +extern int test_dmadev_api(uint16_t dev_id); #define SKELDMA_TEST_RUN(test) \ testsuite_run_test(test, #test) @@ -73,10 +69,10 @@ testsuite_run_test(int (*test)(void), const char *name) ret = test(); if (ret < 0) { failed++; - SKELDMA_TEST_INFO("%s Failed", name); + printf("%s Failed\n", name); } else { passed++; - SKELDMA_TEST_DEBUG("%s Passed", name); + printf("%s Passed\n", name); } } @@ -486,11 +482,11 @@ test_dmadev_completed_status(void) } int -test_dma_skeleton(uint16_t dev_id) +test_dmadev_api(uint16_t dev_id) { int ret = testsuite_setup(dev_id); if (ret) { - SKELDMA_TEST_INFO("testsuite setup fail!"); + printf("testsuite setup fail!"); return -1; } @@ -510,9 +506,9 @@ test_dma_skeleton(uint16_t dev_id) testsuite_teardown(); - SKELDMA_TEST_INFO("Total tests : %d\n", total); - SKELDMA_TEST_INFO("Passed : %d\n", passed); - SKELDMA_TEST_INFO("Failed : %d\n", failed); + printf("Total tests : %d\n", total); + printf("Passed : %d\n", passed); + printf("Failed : %d\n", failed); if (failed) return -1; diff --git a/drivers/dma/skeleton/meson.build b/drivers/dma/skeleton/meson.build index 5d47339c6f..27509b1668 100644 --- a/drivers/dma/skeleton/meson.build +++ b/drivers/dma/skeleton/meson.build @@ -4,5 +4,4 @@ deps += ['dmadev', 'kvargs', 'ring', 'bus_vdev'] sources = files( 'skeleton_dmadev.c', - 'skeleton_dmadev_test.c', ) diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index 1707e88173..ad129c578c 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -30,6 +30,12 @@ /* Count of instances */ static uint16_t skeldma_init_once; +int +test_dma_skeleton(uint16_t dev_id __rte_unused) +{ + return 0; +} + static int skeldma_info_get(const struct rte_dmadev *dev, struct rte_dmadev_info *dev_info, uint32_t info_sz) From patchwork Thu Aug 26 18:32:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 97396 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 A0151A0C43; Thu, 26 Aug 2021 20:33:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A2B741241; Thu, 26 Aug 2021 20:33:23 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id A4E3641241 for ; Thu, 26 Aug 2021 20:33:21 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217847125" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217847125" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 11:33:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685030808" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 11:33:19 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, Chengwen Feng , jerinj@marvell.com, Bruce Richardson Date: Thu, 26 Aug 2021 19:32:56 +0100 Message-Id: <20210826183301.333442-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826183301.333442-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 2/7] dmadev: remove selftest support 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" Since the dmadev provides a common API for all devices, there should be no need to drivers to perform their own selftests, but instead should be tested by the common tests in the autotest binary. Signed-off-by: Bruce Richardson --- app/test/test_dmadev.c | 27 ++++------------- drivers/dma/skeleton/skeleton_dmadev.c | 41 +++----------------------- drivers/dma/skeleton/skeleton_dmadev.h | 3 -- lib/dmadev/rte_dmadev.c | 10 ------- lib/dmadev/rte_dmadev.h | 18 ----------- lib/dmadev/rte_dmadev_core.h | 4 --- lib/dmadev/version.map | 1 - 7 files changed, 9 insertions(+), 95 deletions(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 62fe27b7e8..683e024a56 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -13,7 +13,7 @@ extern int test_dmadev_api(uint16_t dev_id); static int -test_dmadev_selftest_skeleton(void) +test_apis(void) { const char *pmd = "dma_skeleton"; int id; @@ -32,30 +32,13 @@ test_dmadev_selftest_skeleton(void) } static int -test_dmadev_selftests(void) +test_dmadev(void) { - const int count = rte_dmadev_count(); - int ret = 0; - int i; - /* basic sanity on dmadev infrastructure */ - if (test_dmadev_selftest_skeleton() < 0) + if (test_apis() < 0) return -1; - /* now run self-test on all dmadevs */ - if (count > 0) - printf("\n### Run selftest on each available dmadev\n"); - for (i = 0; i < RTE_DMADEV_MAX_DEVS; i++) { - if (rte_dmadevices[i].state != RTE_DMADEV_ATTACHED) - continue; - int result = rte_dmadev_selftest(i); - printf("dmadev %u (%s) selftest: %s\n", i, - rte_dmadevices[i].data->dev_name, - result == 0 ? "Passed" : "Failed"); - ret |= result; - } - - return ret; + return 0; } -REGISTER_TEST_COMMAND(dmadev_autotest, test_dmadev_selftests); +REGISTER_TEST_COMMAND(dmadev_autotest, test_dmadev); diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index ad129c578c..85ba4dae54 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -30,12 +30,6 @@ /* Count of instances */ static uint16_t skeldma_init_once; -int -test_dma_skeleton(uint16_t dev_id __rte_unused) -{ - return 0; -} - static int skeldma_info_get(const struct rte_dmadev *dev, struct rte_dmadev_info *dev_info, uint32_t info_sz) @@ -436,7 +430,6 @@ static const struct rte_dmadev_ops skeldma_ops = { .stats_reset = skeldma_stats_reset, .dev_dump = skeldma_dump, - .dev_selftest = test_dma_skeleton, }; static int @@ -510,24 +503,11 @@ skeldma_parse_lcore(const char *key __rte_unused, return 0; } -static int -skeldma_parse_selftest(const char *key __rte_unused, - const char *value, - void *opaque) -{ - int flag = atoi(value); - if (flag == 0 || flag == 1) - *(int *)opaque = flag; - return 0; -} - static void -skeldma_parse_vdev_args(struct rte_vdev_device *vdev, - int *lcore_id, int *selftest) +skeldma_parse_vdev_args(struct rte_vdev_device *vdev, int *lcore_id) { static const char *const args[] = { SKELDMA_ARG_LCORE, - SKELDMA_ARG_SELFTEST, NULL }; @@ -544,11 +524,7 @@ skeldma_parse_vdev_args(struct rte_vdev_device *vdev, (void)rte_kvargs_process(kvlist, SKELDMA_ARG_LCORE, skeldma_parse_lcore, lcore_id); - (void)rte_kvargs_process(kvlist, SKELDMA_ARG_SELFTEST, - skeldma_parse_selftest, selftest); - - SKELDMA_INFO("Parse lcore_id = %d selftest = %d\n", - *lcore_id, *selftest); + SKELDMA_INFO("Parse lcore_id = %d\n", *lcore_id); rte_kvargs_free(kvlist); } @@ -558,7 +534,6 @@ skeldma_probe(struct rte_vdev_device *vdev) { const char *name; int lcore_id = -1; - int selftest = 0; int ret; name = rte_vdev_device_name(vdev); @@ -576,17 +551,10 @@ skeldma_probe(struct rte_vdev_device *vdev) return -EINVAL; } - skeldma_parse_vdev_args(vdev, &lcore_id, &selftest); + skeldma_parse_vdev_args(vdev, &lcore_id); ret = skeldma_create(name, vdev, lcore_id); if (ret >= 0) { - /* In case command line argument for 'selftest' was passed; - * if invalid arguments were passed, execution continues but - * without selftest. - */ - if (selftest) - (void)test_dma_skeleton(ret); - SKELDMA_INFO("Create %s dmadev lcore-id %d\n", name, lcore_id); /* Device instance created; Second instance not possible */ skeldma_init_once = 1; @@ -623,5 +591,4 @@ static struct rte_vdev_driver skeldma_pmd_drv = { RTE_LOG_REGISTER_DEFAULT(skeldma_logtype, INFO); RTE_PMD_REGISTER_VDEV(dma_skeleton, skeldma_pmd_drv); RTE_PMD_REGISTER_PARAM_STRING(dma_skeleton, - SKELDMA_ARG_LCORE "= " - SKELDMA_ARG_SELFTEST "=<0|1> "); + SKELDMA_ARG_LCORE "= "); diff --git a/drivers/dma/skeleton/skeleton_dmadev.h b/drivers/dma/skeleton/skeleton_dmadev.h index e8a310da18..8cdc2bb0c9 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.h +++ b/drivers/dma/skeleton/skeleton_dmadev.h @@ -22,7 +22,6 @@ extern int skeldma_logtype; SKELDMA_LOG(ERR, fmt, ## args) #define SKELDMA_ARG_LCORE "lcore" -#define SKELDMA_ARG_SELFTEST "selftest" struct skeldma_desc { void *src; @@ -71,6 +70,4 @@ struct skeldma_hw { uint64_t completed_count; }; -int test_dma_skeleton(uint16_t dev_id); - #endif /* __SKELETON_DMADEV_H__ */ diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 80be485b78..1c946402db 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -555,13 +555,3 @@ rte_dmadev_dump(uint16_t dev_id, FILE *f) return 0; } - -int -rte_dmadev_selftest(uint16_t dev_id) -{ - struct rte_dmadev *dev = &rte_dmadevices[dev_id]; - - RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL); - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_selftest, -ENOTSUP); - return (*dev->dev_ops->dev_selftest)(dev_id); -} diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index cf9e4bfa0f..e8f58e9213 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -654,24 +654,6 @@ __rte_experimental int rte_dmadev_dump(uint16_t dev_id, FILE *f); -/** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * - * Trigger the dmadev self test. - * - * @param dev_id - * The identifier of the device. - * - * @return - * - 0: selftest successful. - * - -ENOTSUP: if the device doesn't support selftest. - * - other values < 0 on failure. - */ -__rte_experimental -int -rte_dmadev_selftest(uint16_t dev_id); - /** * rte_dma_status_code - DMA transfer result status code defines. */ diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h index aa8e622f85..e94aa1c457 100644 --- a/lib/dmadev/rte_dmadev_core.h +++ b/lib/dmadev/rte_dmadev_core.h @@ -53,9 +53,6 @@ typedef int (*rte_dmadev_stats_reset_t)(struct rte_dmadev *dev, uint16_t vchan); typedef int (*rte_dmadev_dump_t)(const struct rte_dmadev *dev, FILE *f); /**< @internal Used to dump internal information. */ -typedef int (*rte_dmadev_selftest_t)(uint16_t dev_id); -/**< @internal Used to start dmadev selftest. */ - typedef int (*rte_dmadev_copy_t)(struct rte_dmadev *dev, uint16_t vchan, rte_iova_t src, rte_iova_t dst, uint32_t length, uint64_t flags); @@ -109,7 +106,6 @@ struct rte_dmadev_ops { rte_dmadev_stats_get_t stats_get; rte_dmadev_stats_reset_t stats_reset; rte_dmadev_dump_t dev_dump; - rte_dmadev_selftest_t dev_selftest; }; /** diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index 86c5e75321..80be592713 100644 --- a/lib/dmadev/version.map +++ b/lib/dmadev/version.map @@ -13,7 +13,6 @@ EXPERIMENTAL { rte_dmadev_get_dev_id; rte_dmadev_info_get; rte_dmadev_is_valid_dev; - rte_dmadev_selftest; rte_dmadev_start; rte_dmadev_stats_get; rte_dmadev_stats_reset; From patchwork Thu Aug 26 18:32:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 97397 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 7C1E6A0C43; Thu, 26 Aug 2021 20:33:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B647441250; Thu, 26 Aug 2021 20:33:26 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 3550841250 for ; Thu, 26 Aug 2021 20:33:24 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217847139" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217847139" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 11:33:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685030816" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 11:33:22 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, Chengwen Feng , jerinj@marvell.com, Bruce Richardson Date: Thu, 26 Aug 2021 19:32:57 +0100 Message-Id: <20210826183301.333442-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826183301.333442-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 3/7] app/test: add basic dmadev instance tests 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" Run basic sanity tests for configuring, starting and stopping a dmadev instance to help validate drivers. This also provides the framework for future tests for data-path operation. Signed-off-by: Bruce Richardson --- app/test/test_dmadev.c | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) -- 2.30.2 diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 683e024a56..f895556d29 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -12,6 +12,67 @@ /* from test_dmadev_api.c */ extern int test_dmadev_api(uint16_t dev_id); +#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 +test_dmadev_instance(uint16_t dev_id) +{ +#define TEST_RINGSIZE 512 + /* Setup of the dmadev device. 8< */ + struct rte_dmadev_info info; + const struct rte_dmadev_conf conf = { .nb_vchans = 1}; + const struct rte_dmadev_vchan_conf qconf = { + .direction = RTE_DMA_DIR_MEM_TO_MEM, + .nb_desc = TEST_RINGSIZE, + }; + const int vchan = 0; + + printf("\n### Test dmadev instance %u\n", dev_id); + + rte_dmadev_info_get(dev_id, &info); + if (info.max_vchans < 1) { + PRINT_ERR("Error, no channels available on device id %u\n", dev_id); + return -1; + } + if (rte_dmadev_configure(dev_id, &conf) != 0) { + PRINT_ERR("Error with rte_dmadev_configure()\n"); + return -1; + } + if (rte_dmadev_vchan_setup(dev_id, vchan, &qconf) < 0) { + PRINT_ERR("Error with queue configuration\n"); + return -1; + } + /* >8 End of setup of the dmadev device. */ + rte_dmadev_info_get(dev_id, &info); + if (info.nb_vchans != 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; + } + + rte_dmadev_stop(dev_id); + return 0; +} + static int test_apis(void) { @@ -34,10 +95,19 @@ test_apis(void) static int test_dmadev(void) { + int i; + /* basic sanity on dmadev infrastructure */ if (test_apis() < 0) return -1; + if (rte_dmadev_count() == 0) + return TEST_SKIPPED; + + for (i = 0; i < RTE_DMADEV_MAX_DEVS; i++) + if (rte_dmadevices[i].state == RTE_DMADEV_ATTACHED && test_dmadev_instance(i) < 0) + return -1; + return 0; } From patchwork Thu Aug 26 18:32:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 97398 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 0F11AA0C43; Thu, 26 Aug 2021 20:33:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E646641256; Thu, 26 Aug 2021 20:33:28 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id A9D9E41228 for ; Thu, 26 Aug 2021 20:33:26 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217847151" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217847151" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 11:33:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685030822" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 11:33:24 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, Chengwen Feng , jerinj@marvell.com, Bruce Richardson Date: Thu, 26 Aug 2021 19:32:58 +0100 Message-Id: <20210826183301.333442-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826183301.333442-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 4/7] app/test: add basic dmadev copy tests 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 each dmadev instance, perform some basic copy tests to validate that functionality. Signed-off-by: Bruce Richardson --- app/test/test_dmadev.c | 157 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index f895556d29..a9f7d34a94 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -1,11 +1,14 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2021 HiSilicon Limited. */ +#include #include #include #include #include +#include +#include #include "test.h" @@ -14,6 +17,11 @@ extern int test_dmadev_api(uint16_t dev_id); #define PRINT_ERR(...) print_err(__func__, __LINE__, __VA_ARGS__) +#define COPY_LEN 1024 + +static struct rte_mempool *pool; +static uint16_t id_count; + static inline int __rte_format_printf(3, 4) print_err(const char *func, int lineno, const char *format, ...) @@ -29,10 +37,123 @@ print_err(const char *func, int lineno, const char *format, ...) return ret; } +static int +test_enqueue_copies(int dev_id, uint16_t vchan) +{ + 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] = rte_rand() & 0xFF; + + id = rte_dmadev_copy(dev_id, vchan, src->buf_iova + src->data_off, + dst->buf_iova + dst->data_off, COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); + if (id != id_count) { + PRINT_ERR("Error with rte_dmadev_copy, got %u, expected %u\n", + id, id_count); + 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, vchan, 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] = rte_rand() & 0xFF; + + /* perform the same copy times */ + for (i = 0; i < max_ops; i++) { + if (rte_dmadev_copy(dev_id, vchan, + src->buf_iova + src->data_off, + dst->buf_iova + dst->data_off, + COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT) != id_count++) { + PRINT_ERR("Error with rte_dmadev_copy\n"); + return -1; + } + } + usleep(10); + + if ((i = rte_dmadev_completed(dev_id, vchan, 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); + + return 0; +} + static int test_dmadev_instance(uint16_t dev_id) { #define TEST_RINGSIZE 512 + struct rte_dmadev_stats stats; + int i; + /* Setup of the dmadev device. 8< */ struct rte_dmadev_info info; const struct rte_dmadev_conf conf = { .nb_vchans = 1}; @@ -68,9 +189,45 @@ test_dmadev_instance(uint16_t dev_id) 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.device->numa_node); + if (pool == NULL) { + PRINT_ERR("Error with mempool creation\n"); + return -1; + } + + /* run the test cases, use many iterations to ensure UINT16_MAX id wraparound */ + printf("DMA Dev: %u, Running Copy Tests\n", dev_id); + for (i = 0; i < 640; i++) { + + if (test_enqueue_copies(dev_id, vchan) != 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 submitted: %"PRIu64"\t", stats.submitted); + printf("Ops completed: %"PRIu64"\r", stats.completed); + } + 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 From patchwork Thu Aug 26 18:32:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 97399 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 CDC0BA0C43; Thu, 26 Aug 2021 20:33:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11D024125B; Thu, 26 Aug 2021 20:33:31 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 8A43F41259 for ; Thu, 26 Aug 2021 20:33:29 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217847174" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217847174" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 11:33:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685030830" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 11:33:27 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, Chengwen Feng , jerinj@marvell.com, Bruce Richardson Date: Thu, 26 Aug 2021 19:32:59 +0100 Message-Id: <20210826183301.333442-6-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826183301.333442-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 5/7] app/test: add more comprehensive dmadev copy tests 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 unit tests for various combinations of use for dmadev, copying bursts of packets in various formats, e.g. 1. enqueuing two smaller bursts and completing them as one burst 2. enqueuing one burst and gathering completions in smaller bursts 3. using completed_status() function to gather completions rather than just completed() Signed-off-by: Bruce Richardson --- app/test/test_dmadev.c | 123 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index a9f7d34a94..f3ebac2812 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -37,6 +37,120 @@ print_err(const char *func, int lineno, const char *format, ...) return ret; } +/* run a series of copy tests just using some different options for enqueues and completions */ +static int +do_multi_copies(int dev_id, uint16_t vchan, + int split_batches, /* submit 2 x 16 or 1 x 32 burst */ + int split_completions, /* gather 2 x 16 or 1 x 32 completions */ + int use_completed_status) /* use completed or completed_status function */ +{ + struct rte_mbuf *srcs[32], *dsts[32]; + enum rte_dma_status_code sc[32]; + unsigned int i, j; + bool dma_err = false; + + /* Enqueue burst of copies and hit doorbell. 8< */ + for (i = 0; i < RTE_DIM(srcs); i++) { + uint64_t *src_data; + + if (split_batches && i == RTE_DIM(srcs) / 2) + rte_dmadev_submit(dev_id, vchan); + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++) + src_data[j] = rte_rand(); + + if (rte_dmadev_copy(dev_id, vchan, 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_submit(dev_id, vchan); + /* >8 End of enqueue burst of copies and hit doorbell. */ + usleep(20); + + if (split_completions) { + /* gather completions in two halves */ + uint16_t half_len = RTE_DIM(srcs) / 2; + int ret = rte_dmadev_completed(dev_id, vchan, 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, vchan, 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, using either + * completed or completed_status fns + */ + if (!use_completed_status) { + int n = rte_dmadev_completed(dev_id, vchan, RTE_DIM(srcs), NULL, &dma_err); + if (n != RTE_DIM(srcs) || dma_err) { + PRINT_ERR("Error with rte_dmadev_completed, %u [expected: %zu], dma_err = %d\n", + n, RTE_DIM(srcs), dma_err); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + } else { + int n = rte_dmadev_completed_status(dev_id, vchan, RTE_DIM(srcs), NULL, sc); + if (n != RTE_DIM(srcs)) { + PRINT_ERR("Error with rte_dmadev_completed_status, %u [expected: %zu]\n", + n, RTE_DIM(srcs)); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + for (j = 0; j < (uint16_t)n; j++) { + if (sc[j] != RTE_DMA_STATUS_SUCCESSFUL) { + PRINT_ERR("Error with rte_dmadev_completed_status, job %u reports failure [code %u]\n", + j, sc[j]); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + } + } + } + + /* check for empty */ + int ret = use_completed_status ? + rte_dmadev_completed_status(dev_id, vchan, RTE_DIM(srcs), NULL, sc) : + rte_dmadev_completed(dev_id, vchan, RTE_DIM(srcs), NULL, &dma_err); + if (ret != 0) { + PRINT_ERR("Error with completion check - 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, uint16_t vchan) { @@ -144,7 +258,14 @@ test_enqueue_copies(int dev_id, uint16_t vchan) rte_pktmbuf_free(dst); } while (0); - return 0; + /* test doing multiple copies */ + return do_multi_copies(dev_id, vchan, 0, 0, 0) /* enqueue and complete 1 batch at a time */ + /* enqueue 2 batches and then complete both */ + || do_multi_copies(dev_id, vchan, 1, 0, 0) + /* enqueue 1 batch, then complete in two halves */ + || do_multi_copies(dev_id, vchan, 0, 1, 0) + /* test using completed_status in place of regular completed API */ + || do_multi_copies(dev_id, vchan, 0, 0, 1); } static int From patchwork Thu Aug 26 18:33:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 97400 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 72685A0C43; Thu, 26 Aug 2021 20:33:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E95D4124E; Thu, 26 Aug 2021 20:33:34 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id ACBD341249 for ; Thu, 26 Aug 2021 20:33:32 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217847204" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217847204" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 11:33:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685030848" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 11:33:30 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, Chengwen Feng , jerinj@marvell.com, Bruce Richardson Date: Thu, 26 Aug 2021 19:33:00 +0100 Message-Id: <20210826183301.333442-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826183301.333442-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 6/7] app/test: test dmadev instance failure handling 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 a series of tests to inject bad copy operations into a dmadev to test the error handling and reporting capabilities. Various combinations of errors in various positions in a burst are tested, as are errors in bursts with fence flag set, and multiple errors in a single burst. Signed-off-by: Bruce Richardson --- app/test/test_dmadev.c | 395 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 395 insertions(+) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index f3ebac2812..9b34632cbc 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -268,6 +268,387 @@ test_enqueue_copies(int dev_id, uint16_t vchan) || do_multi_copies(dev_id, vchan, 0, 0, 1); } +/* Failure handling test cases - global macros and variables for those tests*/ +#define COMP_BURST_SZ 16 +#define OPT_FENCE(idx) ((fence && idx == 8) ? RTE_DMA_OP_FLAG_FENCE : 0) + +static int +test_failure_in_full_burst(int dev_id, uint16_t vchan, bool fence, + struct rte_mbuf **srcs, struct rte_mbuf **dsts, unsigned int fail_idx) +{ + /* Test single full batch statuses with failures */ + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t invalid_addr_id = 0; + uint16_t idx; + uint16_t count, status_count; + unsigned int j; + bool error = 0; + + for (j = 0; j < COMP_BURST_SZ; j++) { + int id = rte_dmadev_copy(dev_id, vchan, + (j == fail_idx ? 0 : (srcs[j]->buf_iova + srcs[j]->data_off)), + dsts[j]->buf_iova + dsts[j]->data_off, + COPY_LEN, OPT_FENCE(j)); + if (id < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", j); + return -1; + } + if (j == fail_idx) + invalid_addr_id = id; + } + rte_dmadev_submit(dev_id, vchan); + usleep(10); + + count = rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + if (count != fail_idx) { + PRINT_ERR("Error with rte_dmadev_completed for failure test. Got returned %u not %u.\n", + count, fail_idx); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + if (error == false) { + PRINT_ERR("Error, missing expected failed copy, %u. has_error is not set\n", + fail_idx); + return -1; + } + if (idx != invalid_addr_id - 1) { + PRINT_ERR("Error, missing expected failed copy, %u. Got last idx %u, not %u\n", + fail_idx, idx, invalid_addr_id - 1); + return -1; + } + + /* all checks ok, now verify calling completed() again always returns 0 */ + for (j = 0; j < 10; j++) { + if (rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error) != 0 + || error == false || idx != (invalid_addr_id - 1)) { + PRINT_ERR("Error with follow-up completed calls for fail idx %u\n", + fail_idx); + return -1; + } + } + + status_count = rte_dmadev_completed_status(dev_id, vchan, COMP_BURST_SZ, + &idx, status); + /* some HW may stop on error and be restarted after getting error status for single value + * To handle this case, if we get just one error back, wait for more completions and get + * status for rest of the burst + */ + if (status_count == 1) { + usleep(10); + status_count += rte_dmadev_completed_status(dev_id, vchan, COMP_BURST_SZ - 1, + &idx, &status[1]); + } + /* check that at this point we have all status values */ + if (status_count != COMP_BURST_SZ - count) { + PRINT_ERR("Error with completed_status calls for fail idx %u. Got %u not %u\n", + fail_idx, status_count, COMP_BURST_SZ - count); + return -1; + } + /* now verify just one failure followed by multiple successful or skipped entries */ + if (status[0] == RTE_DMA_STATUS_SUCCESSFUL) { + PRINT_ERR("Error with status returned for fail idx %u. First status was not failure\n", + fail_idx); + return -1; + } + for (j = 1; j < status_count; j++) { + /* after a failure in a burst, depending on ordering/fencing, + * operations may be successful or skipped because of previous error. + */ + if (status[j] != RTE_DMA_STATUS_SUCCESSFUL + && status[j] != RTE_DMA_STATUS_NOT_ATTEMPTED) { + PRINT_ERR("Error with status calls for fail idx %u. Status for job %u (of %u) is not successful\n", + fail_idx, count + j, COMP_BURST_SZ); + return -1; + } + } + return 0; +} + +static int +test_individual_status_query_with_failure(int dev_id, uint16_t vchan, bool fence, + struct rte_mbuf **srcs, struct rte_mbuf **dsts, unsigned int fail_idx) +{ + /* Test gathering batch statuses one at a time */ + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t invalid_addr_id = 0; + uint16_t idx; + uint16_t count = 0, status_count = 0; + unsigned int j; + bool error = false; + + for (j = 0; j < COMP_BURST_SZ; j++) { + int id = rte_dmadev_copy(dev_id, vchan, + (j == fail_idx ? 0 : (srcs[j]->buf_iova + srcs[j]->data_off)), + dsts[j]->buf_iova + dsts[j]->data_off, + COPY_LEN, OPT_FENCE(j)); + if (id < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", j); + return -1; + } + if (j == fail_idx) + invalid_addr_id = id; + } + rte_dmadev_submit(dev_id, vchan); + usleep(10); + + /* use regular "completed" until we hit error */ + while (!error) { + uint16_t n = rte_dmadev_completed(dev_id, vchan, 1, &idx, &error); + count += n; + if (n > 1 || count >= COMP_BURST_SZ) { + PRINT_ERR("Error - too many completions got\n"); + return -1; + } + if (n == 0 && !error) { + PRINT_ERR("Error, unexpectedly got zero completions after %u completed\n", + count); + return -1; + } + } + if (idx != invalid_addr_id - 1) { + PRINT_ERR("Error, last successful index not as expected, got %u, expected %u\n", + idx, invalid_addr_id - 1); + return -1; + } + + /* use completed_status until we hit end of burst */ + while (count + status_count < COMP_BURST_SZ) { + uint16_t n = rte_dmadev_completed_status(dev_id, vchan, 1, &idx, + &status[status_count]); + usleep(10); /* allow delay to ensure jobs are completed */ + status_count += n; + if (n != 1) { + PRINT_ERR("Error: unexpected number of completions received, %u, not 1\n", + n); + return -1; + } + } + + /* check for single failure */ + if (status[0] == RTE_DMA_STATUS_SUCCESSFUL) { + PRINT_ERR("Error, unexpected successful DMA transaction\n"); + return -1; + } + for (j = 1; j < status_count; j++) { + if (status[j] != RTE_DMA_STATUS_SUCCESSFUL + && status[j] != RTE_DMA_STATUS_NOT_ATTEMPTED) { + PRINT_ERR("Error, unexpected DMA error reported\n"); + return -1; + } + } + + return 0; +} + +static int +test_single_item_status_query_with_failure(int dev_id, uint16_t vchan, + struct rte_mbuf **srcs, struct rte_mbuf **dsts, unsigned int fail_idx) +{ + /* When error occurs just collect a single error using "completed_status()" + * before going to back to completed() calls + */ + enum rte_dma_status_code status; + uint16_t invalid_addr_id = 0; + uint16_t idx; + uint16_t count, status_count, count2; + unsigned int j; + bool error = 0; + + for (j = 0; j < COMP_BURST_SZ; j++) { + int id = rte_dmadev_copy(dev_id, vchan, + (j == fail_idx ? 0 : (srcs[j]->buf_iova + srcs[j]->data_off)), + dsts[j]->buf_iova + dsts[j]->data_off, + COPY_LEN, 0); + if (id < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", j); + return -1; + } + if (j == fail_idx) + invalid_addr_id = id; + } + rte_dmadev_submit(dev_id, vchan); + usleep(10); + + /* get up to the error point */ + count = rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + if (count != fail_idx) { + PRINT_ERR("Error with rte_dmadev_completed for failure test. Got returned %u not %u.\n", + count, fail_idx); + rte_dmadev_dump(dev_id, stdout); + return -1; + } + if (error == false) { + PRINT_ERR("Error, missing expected failed copy, %u. has_error is not set\n", + fail_idx); + return -1; + } + if (idx != invalid_addr_id - 1) { + PRINT_ERR("Error, missing expected failed copy, %u. Got last idx %u, not %u\n", + fail_idx, idx, invalid_addr_id - 1); + return -1; + } + + /* get the error code */ + status_count = rte_dmadev_completed_status(dev_id, vchan, 1, &idx, &status); + if (status_count != 1) { + PRINT_ERR("Error with completed_status calls for fail idx %u. Got %u not %u\n", + fail_idx, status_count, COMP_BURST_SZ - count); + return -1; + } + if (status == RTE_DMA_STATUS_SUCCESSFUL) { + PRINT_ERR("Error with status returned for fail idx %u. First status was not failure\n", + fail_idx); + return -1; + } + usleep(10); /* delay in case more time needed after error handled to complete other jobs */ + + /* get the rest of the completions without status */ + count2 = rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + if (error == true) { + PRINT_ERR("Error, got further errors post completed_status() call, for failure case %u.\n", + fail_idx); + return -1; + } + if (count + status_count + count2 != COMP_BURST_SZ) { + PRINT_ERR("Error, incorrect number of completions received, got %u not %u\n", + count + status_count + count2, COMP_BURST_SZ); + return -1; + } + + return 0; +} + +static int +test_multi_failure(int dev_id, uint16_t vchan, struct rte_mbuf **srcs, struct rte_mbuf **dsts, + const unsigned int *fail, size_t num_fail) +{ + /* test having multiple errors in one go */ + enum rte_dma_status_code status[COMP_BURST_SZ]; + unsigned int i, j; + uint16_t count, err_count = 0; + bool error = 0; + + /* enqueue and gather completions in one go */ + for (j = 0; j < COMP_BURST_SZ; j++) { + uintptr_t src = srcs[j]->buf_iova + srcs[j]->data_off; + /* set up for failure if the current index is anywhere is the fails array */ + for (i = 0; i < num_fail; i++) + if (j == fail[i]) + src = 0; + + int id = rte_dmadev_copy(dev_id, vchan, + src, dsts[j]->buf_iova + dsts[j]->data_off, + COPY_LEN, 0); + if (id < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", j); + return -1; + } + } + rte_dmadev_submit(dev_id, vchan); + usleep(10); + + count = rte_dmadev_completed_status(dev_id, vchan, COMP_BURST_SZ, NULL, status); + while (count < COMP_BURST_SZ) { + usleep(10); + + uint16_t ret = rte_dmadev_completed_status(dev_id, vchan, COMP_BURST_SZ - count, + NULL, &status[count]); + if (ret == 0) { + PRINT_ERR("Error getting all completions for jobs. Got %u of %u\n", + count, COMP_BURST_SZ); + return -1; + } + count += ret; + } + for (i = 0; i < count; i++) { + if (status[i] != RTE_DMA_STATUS_SUCCESSFUL) + err_count++; + } + if (err_count != num_fail) { + PRINT_ERR("Error: Invalid number of failed completions returned, %u; expected %zu\n", + err_count, num_fail); + return -1; + } + + /* enqueue and gather completions in bursts, but getting errors one at a time */ + for (j = 0; j < COMP_BURST_SZ; j++) { + uintptr_t src = srcs[j]->buf_iova + srcs[j]->data_off; + /* set up for failure if the current index is anywhere is the fails array */ + for (i = 0; i < num_fail; i++) + if (j == fail[i]) + src = 0; + + int id = rte_dmadev_copy(dev_id, vchan, + src, dsts[j]->buf_iova + dsts[j]->data_off, + COPY_LEN, 0); + if (id < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", j); + return -1; + } + } + rte_dmadev_submit(dev_id, vchan); + usleep(10); + + count = 0; + err_count = 0; + while (count + err_count < COMP_BURST_SZ) { + count += rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, NULL, &error); + if (error) { + uint16_t ret = rte_dmadev_completed_status(dev_id, vchan, 1, + NULL, status); + if (ret != 1) { + PRINT_ERR("Error getting error-status for completions\n"); + return -1; + } + err_count += ret; + usleep(10); + } + } + if (err_count != num_fail) { + PRINT_ERR("Error: Incorrect number of failed completions received, got %u not %lu\n", + err_count, num_fail); + return -1; + } + + return 0; +} + +static int +test_completion_status(int dev_id, uint16_t vchan, bool fence) +{ + const unsigned int fail[] = {0, 7, 14, 15}; + struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; + unsigned int i; + + for (i = 0; i < COMP_BURST_SZ; i++) { + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + } + + for (i = 0; i < RTE_DIM(fail); i++) { + if (test_failure_in_full_burst(dev_id, vchan, fence, srcs, dsts, fail[i]) < 0) + return -1; + + if (test_individual_status_query_with_failure(dev_id, vchan, fence, + srcs, dsts, fail[i]) < 0) + return -1; + + /* test is run the same fenced, or unfenced, but no harm in running it twice */ + if (test_single_item_status_query_with_failure(dev_id, vchan, + srcs, dsts, fail[i]) < 0) + return -1; + } + + if (test_multi_failure(dev_id, vchan, srcs, dsts, fail, RTE_DIM(fail)) < 0) + return -1; + + for (i = 0; i < COMP_BURST_SZ; i++) { + rte_pktmbuf_free(srcs[i]); + rte_pktmbuf_free(dsts[i]); + } + return 0; +} + static int test_dmadev_instance(uint16_t dev_id) { @@ -340,6 +721,20 @@ test_dmadev_instance(uint16_t dev_id) } printf("\n"); + /* to test error handling we can provide null pointers for source or dest in copies. This + * requires VA mode in DPDK, since NULL(0) is a valid physical address. + */ + if (rte_eal_iova_mode() == RTE_IOVA_VA) { + printf("DMA Dev: %u, Running Completion Handling Tests\n", dev_id); + if (test_completion_status(dev_id, vchan, false) != 0) /* without fences */ + goto err; + if (test_completion_status(dev_id, vchan, true) != 0) /* with fences */ + goto err; + rte_dmadev_stats_get(dev_id, 0, &stats); + printf("Ops submitted: %"PRIu64"\t", stats.submitted); + printf("Ops completed: %"PRIu64"\n", stats.completed); + } + rte_mempool_free(pool); rte_dmadev_stop(dev_id); From patchwork Thu Aug 26 18:33:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 97401 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 2E58DA0C43; Thu, 26 Aug 2021 20:34:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3C9A41267; Thu, 26 Aug 2021 20:33:37 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 7293241262 for ; Thu, 26 Aug 2021 20:33:35 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217847228" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217847228" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 11:33:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685030872" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 11:33:32 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, Chengwen Feng , jerinj@marvell.com, Bruce Richardson Date: Thu, 26 Aug 2021 19:33:01 +0100 Message-Id: <20210826183301.333442-8-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826183301.333442-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 7/7] app/test: add dmadev fill tests 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 For dma devices which support the fill operation, run unit tests to verify fill behaviour is correct. Signed-off-by: Kevin Laatz Signed-off-by: Bruce Richardson --- app/test/test_dmadev.c | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 9b34632cbc..cc04689adb 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -649,6 +649,62 @@ test_completion_status(int dev_id, uint16_t vchan, bool fence) return 0; } +static int +test_enqueue_fill(int dev_id, uint16_t vchan) +{ + const unsigned int lengths[] = {8, 64, 1024, 50, 100, 89}; + struct rte_mbuf *dst; + char *dst_data; + uint64_t pattern = 0xfedcba9876543210; + unsigned int i, j; + + dst = rte_pktmbuf_alloc(pool); + if (dst == NULL) { + PRINT_ERR("Failed to allocate mbuf\n"); + return -1; + } + dst_data = rte_pktmbuf_mtod(dst, char *); + + for (i = 0; i < RTE_DIM(lengths); i++) { + /* reset dst_data */ + memset(dst_data, 0, rte_pktmbuf_data_len(dst)); + + /* perform the fill operation */ + int id = rte_dmadev_fill(dev_id, vchan, pattern, + rte_pktmbuf_iova(dst), lengths[i], RTE_DMA_OP_FLAG_SUBMIT); + if (id < 0) { + PRINT_ERR("Error with rte_ioat_enqueue_fill\n"); + return -1; + } + usleep(10); + + if (rte_dmadev_completed(dev_id, vchan, 1, NULL, NULL) != 1) { + PRINT_ERR("Error: fill operation failed (length: %u)\n", lengths[i]); + return -1; + } + /* check the data from the fill operation is correct */ + for (j = 0; j < lengths[i]; j++) { + char pat_byte = ((char *)&pattern)[j % 8]; + if (dst_data[j] != pat_byte) { + PRINT_ERR("Error with fill operation (lengths = %u): got (%x), not (%x)\n", + lengths[i], dst_data[j], pat_byte); + return -1; + } + } + /* check that the data after the fill operation was not written to */ + for (; j < rte_pktmbuf_data_len(dst); j++) { + if (dst_data[j] != 0) { + PRINT_ERR("Error, fill operation wrote too far (lengths = %u): got (%x), not (%x)\n", + lengths[i], dst_data[j], 0); + return -1; + } + } + } + + rte_pktmbuf_free(dst); + return 0; +} + static int test_dmadev_instance(uint16_t dev_id) { @@ -735,6 +791,18 @@ test_dmadev_instance(uint16_t dev_id) printf("Ops completed: %"PRIu64"\n", stats.completed); } + if ((info.dev_capa & RTE_DMADEV_CAPA_OPS_FILL) == 0) + printf("DMA Dev: %u, No device fill support - skipping fill tests\n", dev_id); + else { + printf("DMA Dev: %u, Running Fill Tests\n", dev_id); + + if (test_enqueue_fill(dev_id, vchan) != 0) + goto err; + + rte_dmadev_stats_get(dev_id, 0, &stats); + printf("Ops submitted: %"PRIu64"\t", stats.submitted); + printf("Ops completed: %"PRIu64"\n", stats.completed); + } rte_mempool_free(pool); rte_dmadev_stop(dev_id);