From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5471CC433EF for ; Wed, 13 Oct 2021 15:19:02 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id E6F8060F21 for ; Wed, 13 Oct 2021 15:19:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6F8060F21 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dpdk.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 658044122C; Wed, 13 Oct 2021 17:18:15 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id C31EC411F5 for ; Wed, 13 Oct 2021 17:18:12 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10136"; a="290944110" X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="290944110" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 08:18:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="441682172" Received: from silpixa00399126.ir.intel.com ([10.237.223.151]) by orsmga006.jf.intel.com with ESMTP; 13 Oct 2021 08:18:09 -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, 13 Oct 2021 16:17:32 +0100 Message-Id: <20211013151736.762378-10-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211013151736.762378-1-bruce.richardson@intel.com> References: <20210924102942.2878051-1-bruce.richardson@intel.com> <20211013151736.762378-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 09/13] 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 Reviewed-by: Kevin Laatz Reviewed-by: Conor Walsh --- app/test/test_dmadev.c | 101 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index b0fba1d84e..98b20f75ef 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -82,6 +82,98 @@ await_hw(int16_t 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(int16_t 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_dma_submit(dev_id, vchan); + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + if (srcs[i] == NULL || dsts[i] == NULL) + ERR_RETURN("Error allocating buffers\n"); + + 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_dma_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++) + ERR_RETURN("Error with rte_dma_copy for buffer %u\n", i); + } + rte_dma_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_dma_completed(dev_id, vchan, half_len, NULL, &dma_err); + if (ret != half_len || dma_err) + ERR_RETURN("Error with rte_dma_completed - first half. ret = %d, expected ret = %u, dma_err = %d\n", + ret, half_len, dma_err); + + ret = rte_dma_completed(dev_id, vchan, half_len, NULL, &dma_err); + if (ret != half_len || dma_err) + ERR_RETURN("Error with rte_dma_completed - second half. ret = %d, expected ret = %u, dma_err = %d\n", + ret, half_len, dma_err); + } else { + /* gather all completions in one go, using either + * completed or completed_status fns + */ + if (!use_completed_status) { + int n = rte_dma_completed(dev_id, vchan, RTE_DIM(srcs), NULL, &dma_err); + if (n != RTE_DIM(srcs) || dma_err) + ERR_RETURN("Error with rte_dma_completed, %u [expected: %zu], dma_err = %d\n", + n, RTE_DIM(srcs), dma_err); + } else { + int n = rte_dma_completed_status(dev_id, vchan, RTE_DIM(srcs), NULL, sc); + if (n != RTE_DIM(srcs)) + ERR_RETURN("Error with rte_dma_completed_status, %u [expected: %zu]\n", + n, RTE_DIM(srcs)); + + for (j = 0; j < (uint16_t)n; j++) + if (sc[j] != RTE_DMA_STATUS_SUCCESSFUL) + ERR_RETURN("Error with rte_dma_completed_status, job %u reports failure [code %u]\n", + j, sc[j]); + } + } + + /* check for empty */ + int ret = use_completed_status ? + rte_dma_completed_status(dev_id, vchan, RTE_DIM(srcs), NULL, sc) : + rte_dma_completed(dev_id, vchan, RTE_DIM(srcs), NULL, &dma_err); + if (ret != 0) + ERR_RETURN("Error with completion check - ops unexpectedly returned\n"); + + 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]) + ERR_RETURN("Error with copy of packet %u, byte %u\n", i, j); + + rte_pktmbuf_free(srcs[i]); + rte_pktmbuf_free(dsts[i]); + } + return 0; +} + static int test_enqueue_copies(int16_t dev_id, uint16_t vchan) { @@ -176,7 +268,14 @@ test_enqueue_copies(int16_t 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 -- 2.30.2