<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Vidya Sagar Velumuri <vvelumuri@marvell.com><br>
<b>Sent:</b> Friday, April 19, 2024 2:37 PM<br>
<b>To:</b> fengchengwen@huawei.com <fengchengwen@huawei.com>; kevin.laatz@intel.com <kevin.laatz@intel.com>; bruce.richardson@intel.com <bruce.richardson@intel.com><br>
<b>Cc:</b> Jerin Jacob <jerinj@marvell.com>; Anoob Joseph <anoobj@marvell.com>; Vidya Sagar Velumuri <vvelumuri@marvell.com>; Aakash Sasidharan <asasidharan@marvell.com>; Tejasree Kondoj <ktejasree@marvell.com>; Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>;
 dev@dpdk.org <dev@dpdk.org><br>
<b>Subject:</b> [EXTERNAL] [PATCH v2 2/2] test/dma: add functions to verify zero and one fill</span>
<div> </div>
</div>
<div class="elementToProof" style="font-size: 11pt;">Prioritize security for external emails: Confirm sender and content safety before clicking links or opening attachments<br>
<br>
----------------------------------------------------------------------<br>
Add test cases to verify zero fill and one fill<br>
<br>
Signed-off-by: Vidya Sagar Velumuri <vvelumuri@marvell.com><br>
diff --git a/app/test/test.h b/app/test/test.h<br>
index 15e23d297f..0ca6519f6e 100644<br>
--- a/app/test/test.h<br>
+++ b/app/test/test.h<br>
@@ -27,6 +27,10 @@<br>
 <br>
 #include <rte_test.h><br>
 <br>
+#ifndef ARRAY_SIZE<br>
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))<br>
+#endif<br>
+<br>
 #define TEST_ASSERT RTE_TEST_ASSERT<br>
 <br>
 #define TEST_ASSERT_EQUAL RTE_TEST_ASSERT_EQUAL<br>
diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c<br>
index 7462e90831..ec896a4905 100644<br>
--- a/app/test/test_dmadev.c<br>
+++ b/app/test/test_dmadev.c<br>
@@ -869,42 +869,51 @@ test_completion_handling(int16_t dev_id, uint16_t vchan)<br>
 static int<br>
 test_enqueue_fill(int16_t dev_id, uint16_t vchan)<br>
 {<br>
+       uint64_t pattern[3] = {0x0, 0xfedcba9876543210, 0xffffffffffffffff};<br>
         const unsigned int lengths[] = {8, 64, 1024, 50, 100, 89};<br>
+       unsigned int i, j, k;<br>
         struct rte_mbuf *dst;<br>
         char *dst_data;<br>
-       uint64_t pattern = 0xfedcba9876543210;<br>
-       unsigned int i, j;<br>
 <br>
         dst = rte_pktmbuf_alloc(pool);<br>
         if (dst == NULL)<br>
                 ERR_RETURN("Failed to allocate mbuf\n");<br>
         dst_data = rte_pktmbuf_mtod(dst, char *);<br>
 <br>
-       for (i = 0; i < RTE_DIM(lengths); i++) {<br>
-               /* reset dst_data */<br>
-               memset(dst_data, 0, rte_pktmbuf_data_len(dst));<br>
+       for (k = 0; k < ARRAY_SIZE(pattern); k++) {<br>
+               for (i = 0; i < RTE_DIM(lengths); i++) {<br>
+                       /* reset dst_data */<br>
+                       memset(dst_data, 0, rte_pktmbuf_data_len(dst));<br>
+<br>
+                       /* perform the fill operation */<br>
+                       int id = rte_dma_fill(dev_id, vchan, pattern[k],<br>
+                                       rte_pktmbuf_iova(dst), lengths[i], RTE_DMA_OP_FLAG_SUBMIT);<br>
+                       if (id < 0) {<br>
+                               if (id == -ENOTSUP) {<br>
+                                       rte_pktmbuf_free(dst);<br>
+                                       break;<br>
+                               }<br>
+                               ERR_RETURN("Error with rte_dma_fill\n");<br>
+                       }<br>
+                       await_hw(dev_id, vchan);<br>
 <br>
-               /* perform the fill operation */<br>
-               int id = rte_dma_fill(dev_id, vchan, pattern,<br>
-                               rte_pktmbuf_iova(dst), lengths[i], RTE_DMA_OP_FLAG_SUBMIT);<br>
-               if (id < 0)<br>
-                       ERR_RETURN("Error with rte_dma_fill\n");<br>
-               await_hw(dev_id, vchan);<br>
+                       if (rte_dma_completed(dev_id, vchan, 1, NULL, NULL) != 1)<br>
+                               ERR_RETURN("Error: fill operation failed (length: %u)\n",<br>
+                                          lengths[i]);<br>
+                       /* check the data from the fill operation is correct */<br>
+                       for (j = 0; j < lengths[i]; j++) {<br>
+                               char pat_byte = ((char *)&pattern[k])[j % 8];<br>
 <br>
-               if (rte_dma_completed(dev_id, vchan, 1, NULL, NULL) != 1)<br>
-                       ERR_RETURN("Error: fill operation failed (length: %u)\n", lengths[i]);<br>
-               /* check the data from the fill operation is correct */<br>
-               for (j = 0; j < lengths[i]; j++) {<br>
-                       char pat_byte = ((char *)&pattern)[j % 8];<br>
-                       if (dst_data[j] != pat_byte)<br>
-                               ERR_RETURN("Error with fill operation (lengths = %u): got (%x), not (%x)\n",<br>
-                                               lengths[i], dst_data[j], pat_byte);<br>
+                               if (dst_data[j] != pat_byte)<br>
+                                       ERR_RETURN("Error with fill operation (lengths = %u): got (%x), not (%x)\n",<br>
+                                                       lengths[i], dst_data[j], pat_byte);<br>
+                       }<br>
+                       /* check that the data after the fill operation was not written to */<br>
+                       for (; j < rte_pktmbuf_data_len(dst); j++)<br>
+                               if (dst_data[j] != 0)<br>
+                                       ERR_RETURN("Error, fill operation wrote too far (lengths = %u): got (%x), not (%x)\n",<br>
+                                                       lengths[i], dst_data[j], 0);<br>
                 }<br>
-               /* check that the data after the fill operation was not written to */<br>
-               for (; j < rte_pktmbuf_data_len(dst); j++)<br>
-                       if (dst_data[j] != 0)<br>
-                               ERR_RETURN("Error, fill operation wrote too far (lengths = %u): got (%x), not (%x)\n",<br>
-                                               lengths[i], dst_data[j], 0);<br>
         }<br>
 <br>
         rte_pktmbuf_free(dst);<br>
--<br>
2.25.1</div>
<div class="elementToProof" style="font-size: 11pt;"><br>
</div>
<div class="elementToProof" style="font-size: 11pt; color: rgb(0, 0, 0);">Acked-by: Amit Prakash Shukla <amitprakashs@marvell.com></div>
<div class="elementToProof" style="font-size: 11pt; color: rgb(0, 0, 0);"><br>
</div>
<div class="elementToProof" style="font-size: 11pt; color: rgb(0, 0, 0);">Thanks</div>
<div class="elementToProof" style="font-size: 11pt;"><br>
</div>
</body>
</html>