* [PATCH] test: support SVA copy for dmadev test
@ 2025-09-18 4:15 Chengwen Feng
2025-09-18 8:20 ` [PATCH v2] " Chengwen Feng
0 siblings, 1 reply; 2+ messages in thread
From: Chengwen Feng @ 2025-09-18 4:15 UTC (permalink / raw)
To: thomas; +Cc: dev
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, ¶m[TEST_COPY_SG]),
+ TEST_CASE_NAMED_WITH_DATA("sva_copy",
+ test_dmadev_sva_setup, NULL,
+ runtest, ¶m[TEST_SVA_COPY]),
TEST_CASE_NAMED_WITH_DATA("stop_start",
NULL, NULL,
runtest, ¶m[TEST_START]),
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2] test: support SVA copy for dmadev test
2025-09-18 4:15 [PATCH] test: support SVA copy for dmadev test Chengwen Feng
@ 2025-09-18 8:20 ` Chengwen Feng
0 siblings, 0 replies; 2+ messages in thread
From: Chengwen Feng @ 2025-09-18 8:20 UTC (permalink / raw)
To: thomas; +Cc: dev
This commit supports SVA copy for dmadev test.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
v2: fix CI error (use uninitialized value)
---
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..6dffba0259 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_count;
+ 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[COPY_LEN], dst[COPY_LEN];
+ char *src_data, *dst_data;
+ 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, ¶m[TEST_COPY_SG]),
+ TEST_CASE_NAMED_WITH_DATA("sva_copy",
+ test_dmadev_sva_setup, NULL,
+ runtest, ¶m[TEST_SVA_COPY]),
TEST_CASE_NAMED_WITH_DATA("stop_start",
NULL, NULL,
runtest, ¶m[TEST_START]),
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-18 8:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18 4:15 [PATCH] test: support SVA copy for dmadev test Chengwen Feng
2025-09-18 8:20 ` [PATCH v2] " Chengwen Feng
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).