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 38007423F2; Mon, 16 Jan 2023 18:38:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88A7842D26; Mon, 16 Jan 2023 18:38:04 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 18A8842D28 for ; Mon, 16 Jan 2023 18:38:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673890681; x=1705426681; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e3jZHM4yJk/8BqAo8Z2/tMLG0wzwKz0BNGq6sSvTkyo=; b=QqXTIMDZdiLfQkoBWTD0lfHGlClnPK5RLpY5QZ+e3CMbEv8efxTB46I2 XfzeDeA0WvJvG8QoZXQBYv6J8k/54jl5ymLHw+mvMFGFEeU6ySsePF9Hx W6ONWoD46ioxxvckOrghoCO8hs8T/1ZKcDRogf2/l6KbyJPr6K9mJhOGm fTPv8JJEOwZAzUViazu9P09DRmnlDykZmglCzCQTHJJ2KIZ3DkNhiaWZP 1cXVpwG8D0O118WPpjT9GwwU6i8J6CcbgQZdGs/gSH7UtWT+dadZdUaBy Reh11SN4B53FZ9vQoGFBfKDjFD9xXixEi94BaonUsOTWQk7IXVP97Ulbx Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="326570408" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="326570408" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 09:38:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="987869189" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="987869189" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2023 09:37:59 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Chengwen Feng , Kevin Laatz Subject: [PATCH v2 5/6] test/dmadev: create separate function for single copy test Date: Mon, 16 Jan 2023 17:37:36 +0000 Message-Id: <20230116173738.562322-6-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116173738.562322-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230116173738.562322-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The copy tests for dmadev had separate blocks in the test function for single copy and burst copies. Separate out the single-copy block to its own function so that it can be re-used if necessary. Signed-off-by: Bruce Richardson --- app/test/test_dmadev.c | 120 ++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 56 deletions(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 4e1dbcaa19..de787c14e2 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -175,77 +175,85 @@ do_multi_copies(int16_t dev_id, uint16_t vchan, } static int -test_enqueue_copies(int16_t dev_id, uint16_t vchan) +test_single_copy(int16_t dev_id, uint16_t vchan) { - enum rte_dma_status_code status; - unsigned int i; + uint16_t i; uint16_t id; + enum rte_dma_status_code status; + struct rte_mbuf *src, *dst; + char *src_data, *dst_data; - /* 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 *); - 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; - for (i = 0; i < COPY_LEN; i++) - src_data[i] = rte_rand() & 0xFF; + id = rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(src), rte_pktmbuf_iova(dst), + COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); + if (id != id_count) + ERR_RETURN("Error with rte_dma_copy, got %u, expected %u\n", + id, id_count); - id = rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(src), rte_pktmbuf_iova(dst), - COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); - if (id != id_count) - ERR_RETURN("Error with rte_dma_copy, got %u, expected %u\n", - id, id_count); + /* give time for copy to finish, then check it was done */ + await_hw(dev_id, vchan); - /* give time for copy to finish, then check it was done */ - await_hw(dev_id, vchan); + for (i = 0; i < COPY_LEN; i++) + if (dst_data[i] != src_data[i]) + ERR_RETURN("Data mismatch at char %u [Got %02x not %02x]\n", i, + dst_data[i], src_data[i]); + + /* now check completion works */ + id = ~id; + if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 1) + ERR_RETURN("Error with rte_dma_completed\n"); + + if (id != id_count) + ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", + id, id_count); + + /* check for completed and id when no job done */ + id = ~id; + if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 0) + ERR_RETURN("Error with rte_dma_completed when no job done\n"); + if (id != id_count) + ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", + id, id_count); + + /* check for completed_status and id when no job done */ + id = ~id; + if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) + ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); + if (id != id_count) + ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", + id, id_count); - for (i = 0; i < COPY_LEN; i++) - if (dst_data[i] != src_data[i]) - ERR_RETURN("Data mismatch at char %u [Got %02x not %02x]\n", i, - dst_data[i], src_data[i]); - - /* now check completion works */ - id = ~id; - if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 1) - ERR_RETURN("Error with rte_dma_completed\n"); - - if (id != id_count) - ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", - id, id_count); - - /* check for completed and id when no job done */ - id = ~id; - if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 0) - ERR_RETURN("Error with rte_dma_completed when no job done\n"); - if (id != id_count) - ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", - id, id_count); - - /* check for completed_status and id when no job done */ - id = ~id; - if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) - ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); - if (id != id_count) - ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", - id, id_count); + rte_pktmbuf_free(src); + rte_pktmbuf_free(dst); - rte_pktmbuf_free(src); - rte_pktmbuf_free(dst); + /* now check completion returns nothing more */ + if (rte_dma_completed(dev_id, 0, 1, NULL, NULL) != 0) + ERR_RETURN("Error with rte_dma_completed in empty check\n"); + + id_count++; - /* now check completion returns nothing more */ - if (rte_dma_completed(dev_id, 0, 1, NULL, NULL) != 0) - ERR_RETURN("Error with rte_dma_completed in empty check\n"); + return 0; +} - id_count++; +static int +test_enqueue_copies(int16_t dev_id, uint16_t vchan) +{ + unsigned int i; - } while (0); + /* test doing a single copy */ + if (test_single_copy(dev_id, vchan) < 0) + return -1; /* test doing a multiple single copies */ do { + uint16_t id; const uint16_t max_ops = 4; struct rte_mbuf *src, *dst; char *src_data, *dst_data; -- 2.37.2