DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>
Cc: <dev@dpdk.org>
Subject: [PATCH] test: support SVA copy for dmadev test
Date: Thu, 18 Sep 2025 12:15:34 +0800	[thread overview]
Message-ID: <20250918041534.38227-1-fengchengwen@huawei.com> (raw)

This commit supports SVA copy for dmadev test.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_dmadev.c | 79 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c
index 9cbb9a6552..dd4ace49ae 100644
--- a/app/test/test_dmadev.c
+++ b/app/test/test_dmadev.c
@@ -514,6 +514,65 @@ test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
 	return 0;
 }
 
+static int
+test_single_sva_copy(int16_t dev_id, uint16_t vchan, const char *mem_src,
+		     char *src, char *dst, uint32_t len)
+{
+	uint16_t i, id;
+	int ret;
+
+	for (i = 0; i < len; i++)
+		src[i] = rte_rand() & 0xFF;
+
+	ret = rte_dma_copy(dev_id, vchan, (rte_iova_t)src, (rte_iova_t)dst,
+			len, RTE_DMA_OP_FLAG_SUBMIT);
+	if (ret != id_count)
+		ERR_RETURN("Error with %s rte_dma_copy, got %d expected %u\n",
+			mem_src, ret, id_count);
+
+	await_hw(dev_id, vchan);
+
+	id = ~id;
+	if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 1)
+		ERR_RETURN("Error with %s rte_dma_completed\n", mem_src);
+	if (id != id_count)
+		ERR_RETURN("Error with %s rte_dma_completed: incorrect job id received, %u [expected %u]\n",
+			mem_src, id, id_count);
+	id_count++;
+
+	for (i = 0; i < len; i++)
+		if (dst[i] != src[i])
+			ERR_RETURN("Error with %s data mismatch at char %u [Got %02x not %02x]\n",
+				mem_src, i, dst[i], src[i]);
+
+	return 0;
+}
+
+static int
+test_enqueue_sva_copies(int16_t dev_id, uint16_t vchan)
+{
+	char *src_data = NULL, *dst_data = NULL;
+	char src[COPY_LEN], dst[COPY_LEN];
+	int ret;
+
+	/* test copy between buffer which malloced by libc. */
+	src_data = malloc(COPY_LEN);
+	dst_data = malloc(COPY_LEN);
+	if (src_data == NULL || dst_data == NULL) {
+		free(src_data);
+		free(dst_data);
+		ERR_RETURN("Error with malloc copy buffer!\n");
+	}
+	ret = test_single_sva_copy(dev_id, vchan, "libc", src_data, dst_data, COPY_LEN);
+	free(src_data);
+	free(dst_data);
+	if (ret != 0)
+		return ret;
+
+	/* test copy between buffer which belong stack. */
+	return test_single_sva_copy(dev_id, vchan, "stack", src, dst, COPY_LEN);
+}
+
 /* 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)
@@ -1063,6 +1122,21 @@ test_dmadev_sg_copy_setup(void)
 	return ret;
 }
 
+static int
+test_dmadev_sva_setup(void)
+{
+	int ret = TEST_SUCCESS;
+
+	if ((info.dev_capa & RTE_DMA_CAPA_SVA) == 0) {
+		RTE_LOG(ERR, USER1,
+			"DMA Dev %u: device does not support SVA, skipping SVA tests\n",
+			test_dev_id);
+		ret = TEST_SKIPPED;
+	}
+
+	return ret;
+}
+
 static int
 test_dmadev_burst_setup(void)
 {
@@ -1205,6 +1279,7 @@ test_dmadev_instance(int16_t dev_id)
 	enum {
 		  TEST_COPY = 0,
 		  TEST_COPY_SG,
+		  TEST_SVA_COPY,
 		  TEST_START,
 		  TEST_BURST,
 		  TEST_ERR,
@@ -1216,6 +1291,7 @@ test_dmadev_instance(int16_t dev_id)
 	static struct runtest_param param[] = {
 		{"copy", test_enqueue_copies, 640},
 		{"sg_copy", test_enqueue_sg_copies, 1},
+		{"sva_copy", test_enqueue_sva_copies, 1},
 		{"stop_start", test_stop_start, 1},
 		{"burst_capacity", test_burst_capacity, 1},
 		{"error_handling", test_completion_handling, 1},
@@ -1234,6 +1310,9 @@ test_dmadev_instance(int16_t dev_id)
 			TEST_CASE_NAMED_WITH_DATA("sg_copy",
 				test_dmadev_sg_copy_setup, NULL,
 				runtest, &param[TEST_COPY_SG]),
+			TEST_CASE_NAMED_WITH_DATA("sva_copy",
+				test_dmadev_sva_setup, NULL,
+				runtest, &param[TEST_SVA_COPY]),
 			TEST_CASE_NAMED_WITH_DATA("stop_start",
 				NULL, NULL,
 				runtest, &param[TEST_START]),
-- 
2.17.1


             reply	other threads:[~2025-09-18  4:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  4:15 Chengwen Feng [this message]
2025-09-18  8:20 ` [PATCH v2] " Chengwen Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250918041534.38227-1-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).