[PATCH v4 2/2] app/dma-perf: add SG copy support

Pavan Nikhilesh Bhagavatula pbhagavatula at marvell.com
Thu Sep 28 23:12:04 CEST 2023


> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn at marvell.com>
> Sent: Sunday, September 24, 2023 3:02 PM
> To: dev at dpdk.org
> Cc: Anoob Joseph <anoobj at marvell.com>; Cheng Jiang
> <cheng1.jiang at intel.com>; Kevin Laatz <kevin.laatz at intel.com>; Bruce
> Richardson <bruce.richardson at intel.com>; Pavan Nikhilesh Bhagavatula
> <pbhagavatula at marvell.com>; Gowrishankar Muthukrishnan
> <gmuthukrishn at marvell.com>
> Subject: [PATCH v4 2/2] app/dma-perf: add SG copy support
> 
> Add SG copy support.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn at marvell.com>
> ---
>  app/test-dma-perf/benchmark.c | 243
> +++++++++++++++++++++++++++++-----
>  app/test-dma-perf/config.ini  |  17 +++
>  app/test-dma-perf/main.c      |  34 ++++-
>  app/test-dma-perf/main.h      |   5 +-
>  4 files changed, 260 insertions(+), 39 deletions(-)
> 

<snip>

> @@ -462,13 +599,46 @@ mem_copy_benchmark(struct test_configure *cfg,
> bool is_dma)
> 
>  	rte_eal_mp_wait_lcore();
> 
> -	for (i = 0; i < (nr_buf / nb_workers) * nb_workers; i++) {
> -		if (memcmp(rte_pktmbuf_mtod(srcs[i], void *),
> -			   rte_pktmbuf_mtod(dsts[i], void *),
> -			   cfg->buf_size.cur) != 0) {
> -			printf("Copy validation fails for buffer number %d\n",
> i);
> -			ret = -1;
> -			goto out;
> +	if (!cfg->is_sg) {
> +		for (i = 0; i < (nr_buf / nb_workers) * nb_workers; i++) {
> +			if (memcmp(rte_pktmbuf_mtod(srcs[i], void *),
> +					rte_pktmbuf_mtod(dsts[i], void *),
> +					cfg->buf_size.cur) != 0) {
> +				printf("Copy validation fails for buffer
> number %d\n", i);
> +				ret = -1;
> +				goto out;
> +			}
> +		}
> +	} else {
> +		size_t src_sz = buf_size / cfg->src_ptrs;
> +		size_t dst_sz = buf_size / cfg->dst_ptrs;
> +		uint8_t src[buf_size], dst[buf_size];
> +		uint8_t *sbuf, *dbuf;
> +
> +		for (i = 0; i < (nr_buf / cfg->src_ptrs); i++) {
> +			sbuf = src;
> +			dbuf = dst;
> +
> +			for (j = 0; j < cfg->src_ptrs; j++) {
> +				memcpy(sbuf,
> +					rte_pktmbuf_mtod(srcs[i * cfg-
> >src_ptrs + j], uint8_t *),
> +					src_sz);
> +				sbuf += src_sz;
> +			}
> +
> +			for (j = 0; j < cfg->dst_ptrs; j++) {
> +				memcpy(dbuf,
> +					rte_pktmbuf_mtod(dsts[i * cfg-
> >dst_ptrs + j], uint8_t *),
> +					dst_sz);
> +				dbuf += dst_sz;
> +			}
> +
> +			if (memcmp(src, dst, buf_size) != 0) {

buf_size should be normalized to actual buffer size sent to the DMA engine, 
i.e., either cfg->src_ptrs * src_sz or cfg->dst_ptrs * dst_sz

Example, with 15 source segments and 15 destination segments and 64B buf_size the actual
buffer size copied by the DMA engine would be 60 bytes (64B / 15 = 4B per segment).

> +				printf("SG Copy validation fails for buffer
> number %d\n",
> +					i * cfg->src_ptrs);
> +				ret = -1;
> +				goto out;
> +			}
>  		}
>  	}
> 

<snip>


More information about the dev mailing list