@@ -514,6 +514,65 @@ test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan)
514514 return 0 ;
515515}
516516
517+ static int
518+ test_single_sva_copy (int16_t dev_id , uint16_t vchan , const char * mem_src ,
519+ char * src , char * dst , uint32_t len )
520+ {
521+ uint16_t i , id ;
522+ int ret ;
523+
524+ for (i = 0 ; i < len ; i ++ )
525+ src [i ] = rte_rand () & 0xFF ;
526+
527+ ret = rte_dma_copy (dev_id , vchan , (rte_iova_t )src , (rte_iova_t )dst ,
528+ len , RTE_DMA_OP_FLAG_SUBMIT );
529+ if (ret != id_count )
530+ ERR_RETURN ("Error with %s rte_dma_copy, got %d expected %u\n" ,
531+ mem_src , ret , id_count );
532+
533+ await_hw (dev_id , vchan );
534+
535+ id = ~id_count ;
536+ if (rte_dma_completed (dev_id , vchan , 1 , & id , NULL ) != 1 )
537+ ERR_RETURN ("Error with %s rte_dma_completed\n" , mem_src );
538+ if (id != id_count )
539+ ERR_RETURN ("Error with %s rte_dma_completed: incorrect job id received, %u [expected %u]\n" ,
540+ mem_src , id , id_count );
541+ id_count ++ ;
542+
543+ for (i = 0 ; i < len ; i ++ )
544+ if (dst [i ] != src [i ])
545+ ERR_RETURN ("Error with %s data mismatch at char %u [Got %02x not %02x]\n" ,
546+ mem_src , i , dst [i ], src [i ]);
547+
548+ return 0 ;
549+ }
550+
551+ static int
552+ test_enqueue_sva_copies (int16_t dev_id , uint16_t vchan )
553+ {
554+ char src [COPY_LEN ], dst [COPY_LEN ];
555+ char * src_data , * dst_data ;
556+ int ret ;
557+
558+ /* test copy between buffer which malloced by libc. */
559+ src_data = malloc (COPY_LEN );
560+ dst_data = malloc (COPY_LEN );
561+ if (src_data == NULL || dst_data == NULL ) {
562+ free (src_data );
563+ free (dst_data );
564+ ERR_RETURN ("Error with malloc copy buffer!\n" );
565+ }
566+ ret = test_single_sva_copy (dev_id , vchan , "libc" , src_data , dst_data , COPY_LEN );
567+ free (src_data );
568+ free (dst_data );
569+ if (ret != 0 )
570+ return ret ;
571+
572+ /* test copy between buffer which belong stack. */
573+ return test_single_sva_copy (dev_id , vchan , "stack" , src , dst , COPY_LEN );
574+ }
575+
517576/* Failure handling test cases - global macros and variables for those tests*/
518577#define COMP_BURST_SZ 16
519578#define OPT_FENCE (idx ) ((fence && idx == 8) ? RTE_DMA_OP_FLAG_FENCE : 0)
@@ -1204,6 +1263,21 @@ test_dmadev_sg_copy_setup(void)
12041263 return ret ;
12051264}
12061265
1266+ static int
1267+ test_dmadev_sva_setup (void )
1268+ {
1269+ int ret = TEST_SUCCESS ;
1270+
1271+ if ((info .dev_capa & RTE_DMA_CAPA_SVA ) == 0 ) {
1272+ RTE_LOG (ERR , USER1 ,
1273+ "DMA Dev %u: device does not support SVA, skipping SVA tests\n" ,
1274+ test_dev_id );
1275+ ret = TEST_SKIPPED ;
1276+ }
1277+
1278+ return ret ;
1279+ }
1280+
12071281static int
12081282test_dmadev_burst_setup (void )
12091283{
@@ -1364,6 +1438,7 @@ test_dmadev_instance(int16_t dev_id)
13641438 enum {
13651439 TEST_COPY = 0 ,
13661440 TEST_COPY_SG ,
1441+ TEST_SVA_COPY ,
13671442 TEST_START ,
13681443 TEST_BURST ,
13691444 TEST_ERR ,
@@ -1376,6 +1451,7 @@ test_dmadev_instance(int16_t dev_id)
13761451 static struct runtest_param param [] = {
13771452 {"copy" , test_enqueue_copies , 640 },
13781453 {"sg_copy" , test_enqueue_sg_copies , 1 },
1454+ {"sva_copy" , test_enqueue_sva_copies , 1 },
13791455 {"stop_start" , test_stop_start , 1 },
13801456 {"burst_capacity" , test_burst_capacity , 1 },
13811457 {"error_handling" , test_completion_handling , 1 },
@@ -1395,6 +1471,9 @@ test_dmadev_instance(int16_t dev_id)
13951471 TEST_CASE_NAMED_WITH_DATA ("sg_copy" ,
13961472 test_dmadev_sg_copy_setup , NULL ,
13971473 runtest , & param [TEST_COPY_SG ]),
1474+ TEST_CASE_NAMED_WITH_DATA ("sva_copy" ,
1475+ test_dmadev_sva_setup , NULL ,
1476+ runtest , & param [TEST_SVA_COPY ]),
13981477 TEST_CASE_NAMED_WITH_DATA ("stop_start" ,
13991478 NULL , NULL ,
14001479 runtest , & param [TEST_START ]),
0 commit comments