From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 380A9A0C47; Wed, 1 Sep 2021 18:32:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A9F04116F; Wed, 1 Sep 2021 18:32:41 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 0BA694116F for ; Wed, 1 Sep 2021 18:32:39 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10094"; a="198359900" X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="198359900" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2021 09:32:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="645812868" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by orsmga005.jf.intel.com with ESMTP; 01 Sep 2021 09:32:38 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, fengchengwen@huawei.com, jerinj@marvell.com, Bruce Richardson Date: Wed, 1 Sep 2021 17:32:14 +0100 Message-Id: <20210901163216.120087-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210901163216.120087-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> <20210901163216.120087-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 4/6] 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 | 142 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 2 deletions(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 261f45db71..7a808a9cba 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -39,6 +39,20 @@ print_err(const char *func, int lineno, const char *format, ...) return ret; } +static inline int +check_stats(struct rte_dmadev_stats *stats, bool check_errors) +{ + if (stats->completed != stats->submitted) { + PRINT_ERR("Error, not all submitted jobs are reported as completed\n"); + return -1; + } + if (check_errors && stats->errors != 0) { + PRINT_ERR("Errors reported during copy processing, aborting tests\n"); + return -1; + } + return 0; +} + static inline void await_hw(int dev_id, uint16_t vchan) { @@ -57,6 +71,120 @@ await_hw(int dev_id, uint16_t vchan) } } +/* 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 */ + 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); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + + 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); + + await_hw(dev_id, vchan); + + 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) { @@ -164,7 +292,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 @@ -216,6 +351,8 @@ test_dmadev_instance(uint16_t dev_id) stats.completed, stats.submitted, stats.errors); return -1; } + + rte_dmadev_stats_reset(dev_id, vchan); id_count = 0; /* create a mempool for running tests */ @@ -246,7 +383,8 @@ test_dmadev_instance(uint16_t dev_id) printf("Errors: %"PRIu64"\r", stats.errors); } printf("\n"); - + if (check_stats(&stats, true) < 0) + goto err; rte_mempool_free(pool); rte_dmadev_stop(dev_id); -- 2.30.2