Skip to contentSkip to conversation

improve dmadev tests

PATCH In review Tejasree Kondoj 3 participants 5 messages Jun 22 – Jun 24

lore
Share & tools
lore
#0 lore raw

v2 cover improve dmadev tests

Extend dmadev tests for SG wrap-around and zero/one fill coverage.

v2:
- Fixed checkpatch warnings.

Tejasree Kondoj (2):
test/dma: update the sg test to verify wrap around case test/dma: add functions to verify zero and one fill

 app/test/test.h            |   4 ++
 app/test/test_dmadev.c     | 102 ++++++++++++++++++++++---------------
 app/test/test_dmadev_api.c |   1 -
 app/test/test_dmadev_api.h |   2 +
 4 files changed, 68 insertions(+), 41 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/2 test/dma: update the sg test to verify wrap around case

Run the sg test in a loop to verify wrap around case.
Total number commands submitted to be more than the number descriptors allocated to verify the scenario.

---
 app/test/test_dmadev.c     | 45 ++++++++++++++++++++++++--------------
 app/test/test_dmadev_api.c |  1 -
 app/test/test_dmadev_api.h |  2 ++
 3 files changed, 31 insertions(+), 17 deletions(-)
app/test/test_dmadev.c +29 -16
index 5488a1af33..b30f2214e5 100644
@@ -393,36 +393,28 @@ test_stop_start(int16_t dev_id, uint16_t vchan)
 }
 
 static int
-test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
+test_enqueue_sg(int16_t dev_id, uint16_t vchan, unsigned int n_sge, unsigned int test_len)
 {
-	unsigned int src_len, dst_len, n_sge, len, i, j, k;
 	char orig_src[COPY_LEN], orig_dst[COPY_LEN];
-	struct rte_dma_info info = { 0 };
+	unsigned int src_len, dst_len, i, j, k;
 	enum rte_dma_status_code status;
 	uint16_t id, n_src, n_dst;
 
-	if (rte_dma_info_get(dev_id, &info) < 0)
-		ERR_RETURN("Failed to get dev info");
-
-	if (info.max_sges < 2)
-		ERR_RETURN("Test needs minimum 2 SG pointers");
-
-	n_sge = info.max_sges;
-
 	for (n_src = 1; n_src <= n_sge; n_src++) {
 		for (n_dst = 1; n_dst <= n_sge; n_dst++) {
 			/* Normalize SG buffer lengths */
-			len = COPY_LEN;
-			len -= (len % (n_src * n_dst));
-			dst_len = len / n_dst;
-			src_len = len / n_src;
-
 			struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge);
 			struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge);
 			struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge);
 			struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge);
 			char **src_data = alloca(sizeof(char *) * n_sge);
 			char **dst_data = alloca(sizeof(char *) * n_sge);
+			unsigned int len = test_len - (test_len % (n_src * n_dst));
+
+			dst_len = len / n_dst;
+			src_len = len / n_src;
+			if (dst_len == 0 || src_len == 0)
+				continue;
 
 			for (i = 0 ; i < len; i++)
 				orig_src[i] = rte_rand() & 0xFF;
@@ -514,6 +506,27 @@ test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
 	return 0;
 }
 
+static int
+test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
+{
+	struct rte_dma_info info = { 0 };
+	unsigned int n_sge, len;
+	int loop_count = 0;
+
+	if (rte_dma_info_get(dev_id, &info) < 0)
+		ERR_RETURN("Failed to get dev info");
+
+	n_sge = RTE_MIN(info.max_sges, TEST_SG_MAX);
+	len = COPY_LEN;
+
+	do {
+		test_enqueue_sg(dev_id, vchan, n_sge, len);
+		loop_count++;
+	} while (loop_count * n_sge * n_sge < TEST_RINGSIZE * 3);
+
+	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)
app/test/test_dmadev_api.c +0 -1
index 1ba053696b..4bb8f9e820 100644
@@ -16,7 +16,6 @@ extern int test_dma_api(uint16_t dev_id);
 
 #define TEST_MEMCPY_SIZE	1024
 #define TEST_WAIT_US_VAL	50000
-#define TEST_SG_MAX		64
 
 static int16_t test_dev_id;
 static int16_t invalid_dev_id;
app/test/test_dmadev_api.h +2 -0
index 33fbc5bd41..a03f7acd4f 100644
@@ -2,4 +2,6 @@
  * Copyright(c) 2021 HiSilicon Limited
  */
 
+#define TEST_SG_MAX		64
+
 int test_dma_api(uint16_t dev_id);
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 1/2] test/dma: update the sg test to verify wrap around case

Quoted 66 lines · Tejasree Kondoj

Run the sg test in a loop to verify wrap around case.
Total number commands submitted to be more than the number descriptors allocated to verify the scenario.

---
 app/test/test_dmadev.c     | 45 ++++++++++++++++++++++++--------------
 app/test/test_dmadev_api.c |  1 -
 app/test/test_dmadev_api.h |  2 ++
 3 files changed, 31 insertions(+), 17 deletions(-)
app/test/test_dmadev.c +9 -16
index 5488a1af33..b30f2214e5 100644
@@ -393,36 +393,28 @@ test_stop_start(int16_t dev_id, uint16_t vchan)
 }
 
 static int
-test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
+test_enqueue_sg(int16_t dev_id, uint16_t vchan, unsigned int n_sge, unsigned int test_len)
 {
-	unsigned int src_len, dst_len, n_sge, len, i, j, k;
 	char orig_src[COPY_LEN], orig_dst[COPY_LEN];
-	struct rte_dma_info info = { 0 };
+	unsigned int src_len, dst_len, i, j, k;
 	enum rte_dma_status_code status;
 	uint16_t id, n_src, n_dst;
 
-	if (rte_dma_info_get(dev_id, &info) < 0)
-		ERR_RETURN("Failed to get dev info");
-
-	if (info.max_sges < 2)
-		ERR_RETURN("Test needs minimum 2 SG pointers");
-
-	n_sge = info.max_sges;
-
 	for (n_src = 1; n_src <= n_sge; n_src++) {
 		for (n_dst = 1; n_dst <= n_sge; n_dst++) {
 			/* Normalize SG buffer lengths */
-			len = COPY_LEN;
-			len -= (len % (n_src * n_dst));
-			dst_len = len / n_dst;
-			src_len = len / n_src;
-
 			struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge);
 			struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge);
 			struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge);
 			struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge);
 			char **src_data = alloca(sizeof(char *) * n_sge);
 			char **dst_data = alloca(sizeof(char *) * n_sge);
+			unsigned int len = test_len - (test_len % (n_src * n_dst));
+
+			dst_len = len / n_dst;
+			src_len = len / n_src;
+			if (dst_len == 0 || src_len == 0)
+				continue;
 
 			for (i = 0 ; i < len; i++)
 				orig_src[i] = rte_rand() & 0xFF;
@@ -514,6 +506,27 @@ test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
 	return 0;
 }
 
+static int

app/test/test_dmadev.c test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan) · line 519

Quoted 10 lines
app/test/test_dmadev.c +10 -0
+test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
+{
+	struct rte_dma_info info = { 0 };
+	unsigned int n_sge, len;
+	int loop_count = 0;
+
+	if (rte_dma_info_get(dev_id, &info) < 0)
+		ERR_RETURN("Failed to get dev info");
+
+	n_sge = RTE_MIN(info.max_sges, TEST_SG_MAX);

test_enqueue_sg() has protection:
+ if (dst_len == 0 || src_len == 0)
+ continue;

So no need RTE_MIN, just info.max_sges, in this way we will test the device's capability.

app/test/test_dmadev.c test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan) · line 523

Quoted 4 lines
app/test/test_dmadev.c +4 -0
+	len = COPY_LEN;
+
+	do {
+		test_enqueue_sg(dev_id, vchan, n_sge, len);

We need check the retcode of test_enqueue_sg, else this case will return OK even the copy failed.

Quoted 26 lines
app/test/test_dmadev.c +6 -0
+		loop_count++;
+	} while (loop_count * n_sge * n_sge < TEST_RINGSIZE * 3);
+
+	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)
app/test/test_dmadev_api.c +0 -1
index 1ba053696b..4bb8f9e820 100644
@@ -16,7 +16,6 @@ extern int test_dma_api(uint16_t dev_id);
 
 #define TEST_MEMCPY_SIZE	1024
 #define TEST_WAIT_US_VAL	50000
-#define TEST_SG_MAX		64
 
 static int16_t test_dev_id;
 static int16_t invalid_dev_id;
app/test/test_dmadev_api.h +0 -0
index 33fbc5bd41..a03f7acd4f 100644

app/test/test_dmadev_api.h line 5

Quoted 4 lines
app/test/test_dmadev_api.h +1 -0
@@ -2,4 +2,6 @@
  * Copyright(c) 2021 HiSilicon Limited
  */
 
+#define TEST_SG_MAX		64

No need public this macro.

Quoted 2 lines
app/test/test_dmadev_api.h +1 -0
+
 int test_dma_api(uint16_t dev_id);
#3 lore raw

PATCH v2 2/2 test/dma: add functions to verify zero and one fill

In reply to Tejasree Kondoj

Add test cases to verify zero fill and one fill

---
 app/test/test.h        |  4 +++
 app/test/test_dmadev.c | 57 ++++++++++++++++++++++++------------------
 2 files changed, 37 insertions(+), 24 deletions(-)
app/test/test.h +4 -0
index b29233bb32..d313300056 100644
@@ -34,6 +34,10 @@
 
 #include <rte_test.h>
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
 #define TEST_ASSERT RTE_TEST_ASSERT
 
 #define TEST_ASSERT_EQUAL RTE_TEST_ASSERT_EQUAL
app/test/test_dmadev.c +33 -24

75 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v2 2/2] test/dma: add functions to verify zero and one fill

Quoted 9 lines · Tejasree Kondoj

Add test cases to verify zero fill and one fill

---
 app/test/test.h        |  4 +++
 app/test/test_dmadev.c | 57 ++++++++++++++++++++++++------------------
 2 files changed, 37 insertions(+), 24 deletions(-)

Feedback on v1 of this patch is still relevant, please check my comments there.
Additional comments inline below here too.

Thanks,
/Bruce

app/test/test.h line 38

Quoted 10 lines
app/test/test.h +2 -0
index b29233bb32..d313300056 100644
@@ -34,6 +34,10 @@
 
 #include <rte_test.h>
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

This is the same as RTE_DIM.

Quoted 10 lines
app/test/test.h +2 -0
+#endif
+
 #define TEST_ASSERT RTE_TEST_ASSERT
 
 #define TEST_ASSERT_EQUAL RTE_TEST_ASSERT_EQUAL
app/test/test_dmadev.c +0 -0
index b30f2214e5..d4299e501d 100644

app/test/test_dmadev.c test_completion_handling(int16_t dev_id, uint16_t vchan) · line 934

Quoted 4 lines
app/test/test_dmadev.c +1 -0
@@ -931,42 +931,51 @@ test_completion_handling(int16_t dev_id, uint16_t vchan)
 static int
 test_enqueue_fill(int16_t dev_id, uint16_t vchan)
 {
+	uint64_t pattern[3] = {0x0, 0xfedcba9876543210, 0xffffffffffffffff};

You don't need to hard-code the 3, since you always compute the size. Copy what is done with "lengths" below.

Quoted 74 lines
app/test/test_dmadev.c +32 -24
 	const unsigned int lengths[] = {8, 64, 1024, 50, 100, 89};
+	unsigned int i, j, k;
 	struct rte_mbuf *dst;
 	char *dst_data;
-	uint64_t pattern = 0xfedcba9876543210;
-	unsigned int i, j;
 
 	dst = rte_pktmbuf_alloc(pool);
 	if (dst == NULL)
 		ERR_RETURN("Failed to allocate mbuf\n");
 	dst_data = rte_pktmbuf_mtod(dst, char *);
 
-	for (i = 0; i < RTE_DIM(lengths); i++) {
-		/* reset dst_data */
-		memset(dst_data, 0, rte_pktmbuf_data_len(dst));
+	for (k = 0; k < ARRAY_SIZE(pattern); k++) {
+		for (i = 0; i < RTE_DIM(lengths); i++) {
+			/* reset dst_data */
+			memset(dst_data, 0, rte_pktmbuf_data_len(dst));
+
+			/* perform the fill operation */
+			int id = rte_dma_fill(dev_id, vchan, pattern[k],
+					rte_pktmbuf_iova(dst), lengths[i], RTE_DMA_OP_FLAG_SUBMIT);
+			if (id < 0) {
+				if (id == -ENOTSUP) {
+					rte_pktmbuf_free(dst);
+					return 0;
+				}
+				ERR_RETURN("Error with rte_dma_fill\n");
+			}
+			await_hw(dev_id, vchan);
 
-		/* perform the fill operation */
-		int id = rte_dma_fill(dev_id, vchan, pattern,
-				rte_pktmbuf_iova(dst), lengths[i], RTE_DMA_OP_FLAG_SUBMIT);
-		if (id < 0)
-			ERR_RETURN("Error with rte_dma_fill\n");
-		await_hw(dev_id, vchan);
+			if (rte_dma_completed(dev_id, vchan, 1, NULL, NULL) != 1)
+				ERR_RETURN("Error: fill operation failed (length: %u)\n",
+					   lengths[i]);
+			/* check the data from the fill operation is correct */
+			for (j = 0; j < lengths[i]; j++) {
+				char pat_byte = ((char *)&pattern[k])[j % 8];
 
-		if (rte_dma_completed(dev_id, vchan, 1, NULL, NULL) != 1)
-			ERR_RETURN("Error: fill operation failed (length: %u)\n", lengths[i]);
-		/* check the data from the fill operation is correct */
-		for (j = 0; j < lengths[i]; j++) {
-			char pat_byte = ((char *)&pattern)[j % 8];
-			if (dst_data[j] != pat_byte)
-				ERR_RETURN("Error with fill operation (lengths = %u): got (%x), not (%x)\n",
-						lengths[i], dst_data[j], pat_byte);
+				if (dst_data[j] != pat_byte)
+					ERR_RETURN("Error with fill operation (lengths = %u): got (%x), not (%x)\n",
+							lengths[i], dst_data[j], pat_byte);
+			}
+			/* check that the data after the fill operation was not written to */
+			for (; j < rte_pktmbuf_data_len(dst); j++)
+				if (dst_data[j] != 0)
+					ERR_RETURN("Error, fill operation wrote too far (lengths = %u): got (%x), not (%x)\n",
+							lengths[i], dst_data[j], 0);
 		}
-		/* check that the data after the fill operation was not written to */
-		for (; j < rte_pktmbuf_data_len(dst); j++)
-			if (dst_data[j] != 0)
-				ERR_RETURN("Error, fill operation wrote too far (lengths = %u): got (%x), not (%x)\n",
-						lengths[i], dst_data[j], 0);
 	}
 
 	rte_pktmbuf_free(dst);
Signature · 1 line
2.34.1