app/dma-perf: add SG copy support
PATCH v2 1/1 app/dma-perf: add SG copy support
Add SG copy support.
---
v2:
- patch issue fixed.
--- app/test-dma-perf/benchmark.c | 204 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 17 +++ app/test-dma-perf/main.c | 35 +++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 231 insertions(+), 30 deletions(-)
app/test-dma-perf/benchmark.c +179 -25
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge **src_sges; +struct rte_dma_sge **dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -130,7 +144,7 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -153,6 +167,10 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -166,8 +184,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -177,7 +199,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, ring_size, ptrs_max); ++nb_dmadevs; }
@@ -217,7 +239,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -270,6 +292,61 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge **src_sges = para->src_sges; +struct rte_dma_sge **dst_sges = para->dst_sges; +const uint16_t dev_id = para->dev_id; +const uint32_t nr_buf = para->nr_buf; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +uint16_t nr_cpl; +uint64_t async_cnt =0 ; +uint32_t i; +uint32_t poll_cnt =0 ; +int ret; + + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , src_sges[i], dst_sges[i], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -303,8 +380,9 @@ do_cpu_mem_copy(void *p) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge ***src_sges,struct rte_dma_sge ***dst_sges) {unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets, i;
@@ -366,15 +444,69 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; +uint32_t nr_buf = cfg->nr_buf; +uint8_t j; + + *src_sges =rte_malloc (NULL , nr_buf *sizeof (struct rte_dma_sge **),0 ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i] =rte_malloc (NULL , src_ptrs *sizeof (struct rte_dma_sge ),0 ); +if ((*src_sges)[i] ==NULL ) { +printf ("Error: src_sges malloc failed.\n" ); +return -1 ; + } + } + + *dst_sges =rte_malloc (NULL , nr_buf *sizeof (struct rte_dma_sge **),0 ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + +for (i =0 ; i < nr_buf; i++) { + (*dst_sges)[i] =rte_malloc (NULL , dst_ptrs *sizeof (struct rte_dma_sge ),0 ); +if ((*dst_sges)[i] ==NULL ) { +printf ("Error: dst_sges malloc failed.\n" ); +return -1 ; + } + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; +for (i =0 ; i < nr_buf; i++) { +for (j =0 ; j < src_ptrs; j++) { + (*src_sges)[i][j].addr =rte_pktmbuf_iova ((*srcs)[i]) + + sglen_src * j; + (*src_sges)[i][j].length = sglen_src; + } + (*src_sges)[i][j-1 ].length += buf_size % src_ptrs; + +for (j =0 ; j < dst_ptrs; j++) { + (*dst_sges)[i][j].addr =rte_pktmbuf_iova ((*dsts)[i]) + + sglen_dst * j; + (*dst_sges)[i][j].length = sglen_dst; + } + (*dst_sges)[i][j-1 ].length += buf_size % dst_ptrs; + } + }return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) {uint16_t i;uint32_t offset;unsigned int lcore_id =0 ; +struct rte_dma_sge **src_sges =NULL , **dst_sges =NULL ;struct rte_mbuf **srcs =NULL , **dsts =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;
@@ -389,10 +521,10 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)float bandwidth, bandwidth_total;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -412,7 +544,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -426,10 +558,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + offset * cfg->src_ptrs; + lcores[i]->dst_sges = dst_sges + offset * cfg->dst_ptrs; + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -478,10 +623,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -510,13 +653,24 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +for (i =0 ; i < nr_buf; i++) { +rte_free (src_sges[i]); +rte_free (dst_sges[i]); + } + +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ;/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +17 -0
@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments. ; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.
@@ -50,6 +52,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +31 -4
@@ -93,10 +93,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -325,7 +323,8 @@ load_configs(const char *path)char section_name[CFG_NAME_LEN ];const char *case_type;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;int args_nr, nb_vp;bool is_dma;
@@ -361,12 +360,14 @@ load_configs(const char *path) test_case->test_type =TEST_TYPE_CPU_MEM_COPY ; test_case->test_type_str =CPU_MEM_COPY ; is_dma = false; + }else {printf ("Error: Wrong test case type %s in case%d.\n" , case_type, i +1 ); test_case->is_valid = false;continue ; } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -401,6 +402,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -47,11 +47,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -59,6 +62,6 @@ struct test_configure { uint8_t scenario_id; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
v3 cover app/dma-perf: add SG copy support
Add SG copy support in dma-perf application.
v3:
- Combined patch that does copy validation along with this patch, which means better validation for SG.
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 227 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 17 +++ app/test-dma-perf/main.c | 47 +++++-- app/test-dma-perf/main.h | 5 +- 4 files changed, 261 insertions(+), 35 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/2 app/dma-perf: validate copied memory
Validate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 23 +++++++++++++++++++++-- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-)
app/test-dma-perf/benchmark.c +21 -2
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -306,7 +307,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, struct rte_mbuf ***dsts) {unsigned int buf_size = cfg->buf_size.cur; -unsigned int nr_sockets; +unsigned int nr_sockets, i;uint32_t nr_buf = cfg->nr_buf; nr_sockets =rte_socket_count ();
@@ -360,10 +361,15 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint16_t i;
@@ -381,6 +387,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -454,6 +461,16 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_eal_mp_wait_lcore (); +for (i =0 ; i < cfg->nr_buf; 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -505,4 +522,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -86,20 +86,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)output_csv (true); } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -144,8 +148,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -59,6 +59,6 @@ struct test_configure { uint8_t scenario_id; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.25.1
RE: [EXT] [PATCH v3 1/2] app/dma-perf: validate copied memory
Quoted 63 lines
Validate copied memory to ensure DMA copy did not fail.
Fixes 623dc9364dc ("app/dma-perf: introduce DMA performance test")Signed-off-by Gowrishankar Muthukrishnan <[email protected]>--- app/test-dma-perf/benchmark.c | 23 +++++++++++++++++++++-- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-)app/test-dma- renamed from app/test-dma-perf/benchmark.c +0
-0
perf/benchmark.c
index0601e0d171..9e5b5dc770100644app/test-dma-perf/benchmark.c +2
-1@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h" @@ -306,7 +307,7 @@ setup_memory_env(struct test_configure *cfg,struct rte_mbuf ***srcs, struct rte_mbuf ***dsts) { unsigned int buf_size = cfg->buf_size.cur; -unsigned int nr_sockets; +unsigned int nr_sockets, i;uint32_t nr_buf = cfg->nr_buf;app/test-dma-perf/benchmark.c +6
-1nr_sockets =rte_socket_count ();@@ -360,10 +361,15 @@ setup_memory_env(struct test_configure *cfg,struct rte_mbuf ***srcs, return -1; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma){
app/test-dma-perf/benchmark.c +1
-0uint16_t i;@@ -381,6 +387,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 )app/test-dma-perf/benchmark.c +0
-0goto out;
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, · line 465
Quoted 5 lines
app/test-dma-perf/benchmark.c +1
-0@@ -454,6 +461,16 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_eal_mp_wait_lcore (); +for (i =0 ; i < cfg->nr_buf; i++) {
Here i is uint16_t which will overflow when memsize is set to 10 in the default config.ini, please increase it to 32-bit.
Quoted 82 lines
app/test-dma-perf/benchmark.c +9
-0+ 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; + } + } + mops_total =0 ;app/test-dma-perf/benchmark.c +2
-0bandwidth_total =0 ; avg_cycles_total =0 ;@@ -505,4 +522,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) rte_dma_stop(ldm->dma_ids[i]); } } + +return ret;}
app/test-dma-perf/main.c +7
-3@@ -86,20 +86,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)output_csv (true ); } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; }static void
app/test-dma-perf/main.c +4
-2@@ -144,8 +148,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD )app/test-dma-perf/main.c +0
-0var_entry->cur += var_entry->incr;app/test-dma-perf/main.h +1
-2@@ -59,6 +59,6 @@ struct test_configure { uint8_t scenario_id; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */ --2.25.1
PATCH v3 2/2 app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support.
--- app/test-dma-perf/benchmark.c | 204 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 17 +++ app/test-dma-perf/main.c | 35 +++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 231 insertions(+), 30 deletions(-)
app/test-dma-perf/benchmark.c +179 -25
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge **src_sges; +struct rte_dma_sge **dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -130,7 +144,7 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -153,6 +167,10 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -166,8 +184,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -177,7 +199,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, ring_size, ptrs_max); ++nb_dmadevs; }
@@ -217,7 +239,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -270,6 +292,61 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge **src_sges = para->src_sges; +struct rte_dma_sge **dst_sges = para->dst_sges; +const uint16_t dev_id = para->dev_id; +const uint32_t nr_buf = para->nr_buf; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +uint16_t nr_cpl; +uint64_t async_cnt =0 ; +uint32_t i; +uint32_t poll_cnt =0 ; +int ret; + + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , src_sges[i], dst_sges[i], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -303,8 +380,9 @@ do_cpu_mem_copy(void *p) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge ***src_sges,struct rte_dma_sge ***dst_sges) {unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets, i;
@@ -366,15 +444,69 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; +uint32_t nr_buf = cfg->nr_buf; +uint8_t j; + + *src_sges =rte_malloc (NULL , nr_buf *sizeof (struct rte_dma_sge **),0 ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i] =rte_malloc (NULL , src_ptrs *sizeof (struct rte_dma_sge ),0 ); +if ((*src_sges)[i] ==NULL ) { +printf ("Error: src_sges malloc failed.\n" ); +return -1 ; + } + } + + *dst_sges =rte_malloc (NULL , nr_buf *sizeof (struct rte_dma_sge **),0 ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + +for (i =0 ; i < nr_buf; i++) { + (*dst_sges)[i] =rte_malloc (NULL , dst_ptrs *sizeof (struct rte_dma_sge ),0 ); +if ((*dst_sges)[i] ==NULL ) { +printf ("Error: dst_sges malloc failed.\n" ); +return -1 ; + } + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; +for (i =0 ; i < nr_buf; i++) { +for (j =0 ; j < src_ptrs; j++) { + (*src_sges)[i][j].addr =rte_pktmbuf_iova ((*srcs)[i]) + + sglen_src * j; + (*src_sges)[i][j].length = sglen_src; + } + (*src_sges)[i][j-1 ].length += buf_size % src_ptrs; + +for (j =0 ; j < dst_ptrs; j++) { + (*dst_sges)[i][j].addr =rte_pktmbuf_iova ((*dsts)[i]) + + sglen_dst * j; + (*dst_sges)[i][j].length = sglen_dst; + } + (*dst_sges)[i][j-1 ].length += buf_size % dst_ptrs; + } + }return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) {uint16_t i;uint32_t offset;unsigned int lcore_id =0 ; +struct rte_dma_sge **src_sges =NULL , **dst_sges =NULL ;struct rte_mbuf **srcs =NULL , **dsts =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;
@@ -389,10 +521,10 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)float bandwidth, bandwidth_total;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -412,7 +544,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -426,10 +558,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + offset * cfg->src_ptrs; + lcores[i]->dst_sges = dst_sges + offset * cfg->dst_ptrs; + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -478,10 +623,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -510,13 +653,24 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +for (i =0 ; i < nr_buf; i++) { +rte_free (src_sges[i]); +rte_free (dst_sges[i]); + } + +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ;/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +17 -0
@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments. ; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.
@@ -50,6 +52,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +31 -4
@@ -93,10 +93,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -325,7 +323,8 @@ load_configs(const char *path)char section_name[CFG_NAME_LEN ];const char *case_type;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;int args_nr, nb_vp;bool is_dma;
@@ -361,12 +360,14 @@ load_configs(const char *path) test_case->test_type =TEST_TYPE_CPU_MEM_COPY ; test_case->test_type_str =CPU_MEM_COPY ; is_dma = false; + }else {printf ("Error: Wrong test case type %s in case%d.\n" , case_type, i +1 ); test_case->is_valid = false;continue ; } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -401,6 +402,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -47,11 +47,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -59,6 +62,6 @@ struct test_configure { uint8_t scenario_id; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
Hi,
Sorry for the late reply.
Generally I like your idea. But I might not be able to review in a timely manner, as I'm leaving Intel. If you're in a hurry, you might need to find someone else to help with the review.
Thanks for your work,
Cheng
Quoted 29 lines
-----Original Message-----
From: Gowrishankar Muthukrishnan <[email protected]>
Sent: Thursday, August 10, 2023 9:02 PM
To: [email protected]
Cc: [email protected]; Jiang, Cheng1 <[email protected]>; Laatz, Kevin <[email protected]>; Richardson, Bruce <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>
Subject: [PATCH v3 0/2] app/dma-perf: add SG copy supportAdd SG copy support in dma-perf application.
v3:
- Combined patch that does copy validation along with this patch, which means better validation for SG.Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy supportapp/test-dma-perf/benchmark.c | 227 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 17 +++ app/test-dma-perf/main.c | 47 +++++-- app/test-dma-perf/main.h | 5 +- 4 files changed, 261 insertions(+), 35 deletions(-)--
2.25.1
v4 cover app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support in dma-perf application.
v4:
- improvement in buffer allocation for perf validation.
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 251 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 17 +++ app/test-dma-perf/main.c | 46 ++++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 283 insertions(+), 36 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/2 app/dma-perf: validate copied memory
Validate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 24 ++++++++++++++++++++++-- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 34 insertions(+), 8 deletions(-)
app/test-dma-perf/benchmark.c +22 -2
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -308,6 +309,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -360,13 +362,18 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL ;
@@ -381,6 +388,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -454,6 +462,16 @@ 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -505,4 +523,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -86,20 +86,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)output_csv (true); } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -144,8 +148,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -59,6 +59,6 @@ struct test_configure { uint8_t scenario_id; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.25.1
PATCH v4 2/2 app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support.
--- 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(-)
app/test-dma-perf/benchmark.c +209 -34
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -130,7 +144,7 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -153,6 +167,10 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -166,8 +184,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -177,7 +199,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, ring_size, ptrs_max); ++nb_dmadevs; }
@@ -217,7 +239,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -270,6 +292,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf = nr_buf / src_ptrs; + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -303,8 +384,9 @@ do_cpu_mem_copy(void *p) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;
@@ -367,20 +449,50 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct rte_mbuf **srcs =NULL , **dsts =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -388,12 +500,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf = (nr_buf / nb_workers) * nb_workers; +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf = (nr_buf / cfg->src_ptrs) * cfg->src_ptrs; + nr_buf *= nb_workers; + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -413,7 +536,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -427,10 +550,24 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + offset; + lcores[i]->dst_sges = dst_sges + + ((nr_buf / cfg->src_ptrs * cfg->dst_ptrs) / nb_workers) * i; + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -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 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
@@ -479,10 +649,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -511,13 +679,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +17 -0
@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments. ; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.
@@ -49,6 +51,21 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test +[case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + [case2] type=CPU_MEM_COPY mem_size=10
app/test-dma-perf/main.c +30 -4
@@ -93,10 +93,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -325,7 +323,8 @@ load_configs(const char *path)char section_name[CFG_NAME_LEN ];const char *case_type;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;int args_nr, nb_vp;bool is_dma;
@@ -367,6 +366,7 @@ load_configs(const char *path)continue ; } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -401,6 +401,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -47,11 +47,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -59,6 +62,6 @@ struct test_configure { uint8_t scenario_id; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
Quoted 24 lines
-----Original Message-----
From: Gowrishankar Muthukrishnan <[email protected]>
Sent: Sunday, September 24, 2023 3:02 PM
To: [email protected]
Cc: Anoob Joseph <[email protected]>; Cheng Jiang <[email protected]>; Kevin Laatz <[email protected]>; Bruce Richardson <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>
Subject: [PATCH v4 2/2] app/dma-perf: add SG copy supportAdd SG copy support.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>--- 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>
Quoted 46 lines
app/test-dma-perf/benchmark.c +23
-7@@ -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-Quoted 1 line
src_ptrs+ j],uint8_t*),app/test-dma-perf/benchmark.c +7
-0+ src_sz); + sbuf += src_sz; + } + +for (j =0 ; j < cfg->dst_ptrs; j++) { + memcpy(dbuf, + rte_pktmbuf_mtod(dsts[i * cfg-Quoted 1 line
dst_ptrs+ j],uint8_t*),
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 636
Quoted 5 lines
app/test-dma-perf/benchmark.c +5
-0+ 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).
Quoted 9 lines
(quoted diff) +1
-0+ printf("SG Copy validation fails for buffernumber %d\n",
app/test-dma-perf/benchmark.c +4
-0+ i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
<snip>
v5 cover app/dma-perf: PCI Dev and SG copy support
In reply to Gowrishankar MuthukrishnanImprove dma-perf application to support PCI dev and SG copy, along with additional supports below:
- validate copied memory
- skip tests if not opted.
v5:
- Additional patches included to apply as one series.
Amit Prakash Shukla (2):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 344 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 56 ++++++ app/test-dma-perf/main.c | 136 +++++++++++++- app/test-dma-perf/main.h | 12 +- 4 files changed, 507 insertions(+), 41 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/4 app/dma-perf: add skip support
From: Amit Prakash Shukla <[email protected]>
Add support to skip running a dma-perf test-case.
--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 23 +++++++++++++++++++++++ app/test-dma-perf/main.h | 1 + 3 files changed, 26 insertions(+)
app/test-dma-perf/config.ini +2 -0
@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with the same name as the configuration ; file, with the addition of "_result.csv" at the end. +; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10
app/test-dma-perf/main.c +23 -0
@@ -320,6 +320,7 @@ load_configs(const char *path)const char *case_type;const char *lcore_dma;const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *skip;int args_nr, nb_vp;bool is_dma;
@@ -339,6 +340,13 @@ load_configs(const char *path)for (i =0 ; i < nb_sections; i++) {snprintf (section_name,CFG_NAME_LEN ,"case%d" , i +1 ); test_case = &test_cases[i]; + + skip =rte_cfgfile_get_entry (cfgfile, section_name,"skip" ); +if (skip && (atoi (skip) ==1 )) { + test_case->is_skip = true; +continue ; + } + case_type =rte_cfgfile_get_entry (cfgfile, section_name,"type" );if (case_type ==NULL ) { printf("Error: No case type in case %d, the test will be finished here.\n",
@@ -523,6 +531,21 @@ main(int argc, char *argv[])printf ("Running cases...\n" );for (i =0 ; i < case_nb; i++) { +if (test_cases[i].is_skip) { +printf ("Test case %d configured to be skipped.\n\n" , i +1 ); +snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Skip the test-case %d\n" , + i +1 ); + + fd =fopen (rst_path_ptr,"a" ); +if (!fd) { +printf ("Open output CSV file error.\n" ); +return 0 ; + } +output_csv (true); +fclose (fd); +continue ; + } +if (!test_cases[i].is_valid) {printf ("Invalid test case %d.\n\n" , i +1 );snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Invalid case %d\n" , i +1 );
app/test-dma-perf/main.h +1 -0
@@ -41,6 +41,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
Signature · 1 line
2.25.1
RE: [PATCH v5 1/4] app/dma-perf: add skip support
Quoted 7 lines
Subject: [PATCH v5 1/4] app/dma-perf: add skip support
From: Amit Prakash Shukla <[email protected]>
Add support to skip running a dma-perf test-case.
Signed-off-by Amit Prakash Shukla <[email protected]>
PATCH v5 2/4 app/dma-perf: add PCI device support
In reply to Gowrishankar MuthukrishnanFrom: Amit Prakash Shukla <[email protected]>
Add support to test performance for "device to memory" and "memory to device" data transfer.
--- app/test-dma-perf/benchmark.c | 67 +++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 37 +++++++++++++++++++ app/test-dma-perf/main.c | 67 +++++++++++++++++++++++++++++++++++ app/test-dma-perf/main.h | 6 ++++ 4 files changed, 170 insertions(+), 7 deletions(-)
app/test-dma-perf/benchmark.c +60 -7
@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->dcoreid; + qconf->dst_port.pcie.vfid = cfg->vfid; + qconf->dst_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->scoreid; + qconf->src_port.pcie.vfid = cfg->vfid; + qconf->src_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );
@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;
@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }
@@ -308,6 +344,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -360,6 +397,22 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_mbuf_iova_set (*srcs[i], (rte_iova_t )cfg->raddr); + ((*srcs)[i])->data_off =0 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_mbuf_iova_set (*dsts[i], (rte_iova_t )cfg->raddr); + ((*dsts)[i])->data_off =0 ; + } + } +return 0 ; }
app/test-dma-perf/config.ini +37 -0
@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": +; ================================================================================== +; "direction" denotes the direction of data transfer. It can take 3 values: +; 0 - mem to mem transfer +; 1 - mem to dev transfer +; 2 - dev to mem transfer +; If not specified the default value is 0 (mem to mem transfer). + +; "raddr" remote iova address for "mem to dev" and "dev to mem" transfer. + +; "scoreid" denotes source PCIe core index. +; "dcoreid" denotes destination PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer. + +; =========== End of "mem to dev" and "dev to mem" config parameters. ============== + [case1] type=DMA_MEM_COPY mem_size=10
@@ -52,6 +69,26 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=2 +raddr=0x200000000 +scoreid=0 +dcoreid=0 +pfid=0 +vfid=0 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +67 -0
94 lines not on this page · raw message
app/test-dma-perf/main.h +6 -0
@@ -43,6 +43,7 @@ struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
@@ -58,6 +59,11 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +uint8_t scoreid; +uint8_t dcoreid; +uint8_t pfid; +uint16_t vfid; +uint64_t raddr; };void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
Signature · 1 line
2.25.1
RE: [PATCH v5 2/4] app/dma-perf: add PCI device support
Quoted 8 lines
Subject: [PATCH v5 2/4] app/dma-perf: add PCI device support
From: Amit Prakash Shukla <[email protected]>
Add support to test performance for "device to memory" and "memory to device" data transfer.
Signed-off-by Amit Prakash Shukla <[email protected]>
PATCH v5 3/4 app/dma-perf: validate copied memory
In reply to Gowrishankar MuthukrishnanValidate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 23 +++++++++++++++++++++-- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-)
app/test-dma-perf/benchmark.c +21 -2
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -397,6 +398,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) {for (i =0 ; i < nr_buf; i++) {/* Using mbuf structure to hold remote iova address. */
@@ -416,10 +422,10 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL ;
@@ -434,6 +440,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -507,6 +514,16 @@ 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -558,4 +575,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -87,20 +87,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)output_csv (true); } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -145,8 +149,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -66,6 +66,6 @@ struct test_configure { uint64_t raddr; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.25.1
RE: [PATCH v5 3/4] app/dma-perf: validate copied memory
Quoted 5 lines
Subject: [PATCH v5 3/4] app/dma-perf: validate copied memory
Validate copied memory to ensure DMA copy did not fail.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>
PATCH v5 4/4 app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support.
--- app/test-dma-perf/benchmark.c | 274 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 19 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 292 insertions(+), 40 deletions(-)
app/test-dma-perf/benchmark.c +240 -34
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }
@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -339,8 +420,9 @@ do_cpu_mem_copy(void *p) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;
@@ -419,20 +501,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct rte_mbuf **srcs =NULL , **dsts =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -440,12 +558,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -459,13 +597,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + } + offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -479,10 +627,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -514,13 +675,53 @@ 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_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
@@ -531,10 +732,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -563,13 +762,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +18 -1
@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments. ; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.
@@ -69,6 +71,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=2
@@ -88,7 +105,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +30 -4
@@ -94,10 +94,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -327,7 +325,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;const char *raddr, *scoreid, *dcoreid, *vfid, *pfid;int args_nr, nb_vp;
@@ -442,6 +441,7 @@ load_configs(const char *path) test_case->dcoreid = (uint8_t )atoi (dcoreid); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -476,6 +476,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -49,11 +49,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -66,6 +69,6 @@ struct test_configure { uint64_t raddr; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
Quoted 4 lines
Add SG copy support.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>
v6 cover PCI Dev and SG copy support
In reply to Gowrishankar MuthukrishnanImprove dma-perf application to support PCI dev and SG copy, along with additional supports below:
- validate copied memory
- skip tests if not opted.
v6:
- PCI patch updated.
Amit Prakash Shukla (2):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 383 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 56 +++++ app/test-dma-perf/main.c | 136 +++++++++++- app/test-dma-perf/main.h | 12 +- 4 files changed, 545 insertions(+), 42 deletions(-)
Signature · 1 line
2.25.1
PATCH v6 1/4 app/dma-perf: add skip support
From: Amit Prakash Shukla <[email protected]>
Add support to skip running a dma-perf test-case.
--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 23 +++++++++++++++++++++++ app/test-dma-perf/main.h | 1 + 3 files changed, 26 insertions(+)
app/test-dma-perf/config.ini +2 -0
@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with the same name as the configuration ; file, with the addition of "_result.csv" at the end. +; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10
app/test-dma-perf/main.c +23 -0
@@ -320,6 +320,7 @@ load_configs(const char *path)const char *case_type;const char *lcore_dma;const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *skip;int args_nr, nb_vp;bool is_dma;
@@ -339,6 +340,13 @@ load_configs(const char *path)for (i =0 ; i < nb_sections; i++) {snprintf (section_name,CFG_NAME_LEN ,"case%d" , i +1 ); test_case = &test_cases[i]; + + skip =rte_cfgfile_get_entry (cfgfile, section_name,"skip" ); +if (skip && (atoi (skip) ==1 )) { + test_case->is_skip = true; +continue ; + } + case_type =rte_cfgfile_get_entry (cfgfile, section_name,"type" );if (case_type ==NULL ) { printf("Error: No case type in case %d, the test will be finished here.\n",
@@ -523,6 +531,21 @@ main(int argc, char *argv[])printf ("Running cases...\n" );for (i =0 ; i < case_nb; i++) { +if (test_cases[i].is_skip) { +printf ("Test case %d configured to be skipped.\n\n" , i +1 ); +snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Skip the test-case %d\n" , + i +1 ); + + fd =fopen (rst_path_ptr,"a" ); +if (!fd) { +printf ("Open output CSV file error.\n" ); +return 0 ; + } +output_csv (true); +fclose (fd); +continue ; + } +if (!test_cases[i].is_valid) {printf ("Invalid test case %d.\n\n" , i +1 );snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Invalid case %d\n" , i +1 );
app/test-dma-perf/main.h +1 -0
@@ -41,6 +41,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
Signature · 1 line
2.25.1
PATCH v6 2/4 app/dma-perf: add PCI device support
In reply to Gowrishankar MuthukrishnanFrom: Amit Prakash Shukla <[email protected]>
Add support to test performance for "device to memory" and "memory to device" data transfer.
---
v6:
- fix mbuf IOVA with remote address
---
--- app/test-dma-perf/benchmark.c | 108 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 37 ++++++++++++ app/test-dma-perf/main.c | 67 +++++++++++++++++++++ app/test-dma-perf/main.h | 6 ++ 4 files changed, 209 insertions(+), 9 deletions(-)
app/test-dma-perf/benchmark.c +99 -9
@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->dcoreid; + qconf->dst_port.pcie.vfid = cfg->vfid; + qconf->dst_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->scoreid; + qconf->src_port.pcie.vfid = cfg->vfid; + qconf->src_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );
@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;
@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }
@@ -301,13 +337,22 @@ do_cpu_mem_copy(void *p)return 0 ; } +static void +dummy_free_ext_buf (void *addr,void *opaque) +{ +RTE_SET_USED (addr); +RTE_SET_USED (opaque); +} +static int setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs,struct rte_mbuf ***dsts) { +static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -360,16 +405,47 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || + cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 ); +if (ext_buf_info ==NULL ) { +printf ("Error: ext_buf_info malloc failed.\n" ); +return -1 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*srcs)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*dsts)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } +return 0 ; }void mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ; -struct rte_mbuf **srcs =NULL , **dsts =NULL ; +struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur;
@@ -475,6 +551,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) avg_cycles_total / nb_workers, bandwidth_total, mops_total); out: + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) + m = srcs; +else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) + m = dsts; + +if (m) { +for (i =0 ; i < nr_buf; i++) +rte_pktmbuf_detach_extbuf (m[i]); + +if (m[0 ]->shinfo &&rte_mbuf_ext_refcnt_read (m[0 ]->shinfo) ==0 ) +rte_free (m[0 ]->shinfo); + } +/* free mbufs used in the test */ if (srcs !=NULL )rte_pktmbuf_free_bulk (srcs, nr_buf);
app/test-dma-perf/config.ini +37 -0
@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": +; ================================================================================== +; "direction" denotes the direction of data transfer. It can take 3 values: +; 0 - mem to mem transfer +; 1 - mem to dev transfer +; 2 - dev to mem transfer +; If not specified the default value is 0 (mem to mem transfer). + +; "raddr" remote iova address for "mem to dev" and "dev to mem" transfer. + +; "scoreid" denotes source PCIe core index. +; "dcoreid" denotes destination PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer. + +; =========== End of "mem to dev" and "dev to mem" config parameters. ============== + [case1] type=DMA_MEM_COPY mem_size=10
@@ -52,6 +69,26 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=2 +raddr=0x200000000 +scoreid=0 +dcoreid=0 +pfid=0 +vfid=0 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +67 -0
94 lines not on this page · raw message
app/test-dma-perf/main.h +6 -0
@@ -43,6 +43,7 @@ struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
@@ -58,6 +59,11 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +uint8_t scoreid; +uint8_t dcoreid; +uint8_t pfid; +uint16_t vfid; +uint64_t raddr; };void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
Signature · 1 line
2.25.1
PATCH v6 3/4 app/dma-perf: validate copied memory
In reply to Gowrishankar MuthukrishnanValidate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-)
app/test-dma-perf/benchmark.c +20 -1
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -405,6 +406,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 );
@@ -439,7 +445,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint32_t i;
@@ -457,6 +463,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -530,6 +537,16 @@ 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -595,4 +612,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -87,20 +87,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)output_csv (true); } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -145,8 +149,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -66,6 +66,6 @@ struct test_configure { uint64_t raddr; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.25.1
PATCH v6 4/4 app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support.
--- app/test-dma-perf/benchmark.c | 274 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 19 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 292 insertions(+), 40 deletions(-)
app/test-dma-perf/benchmark.c +240 -34
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }
@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -346,8 +427,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;
@@ -442,20 +524,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -463,12 +581,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -482,13 +620,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + } + offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -502,10 +650,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -537,13 +698,53 @@ 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_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
@@ -554,10 +755,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -600,13 +799,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +18 -1
@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments. ; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.
@@ -69,6 +71,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=2
@@ -88,7 +105,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +30 -4
@@ -94,10 +94,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -327,7 +325,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;const char *raddr, *scoreid, *dcoreid, *vfid, *pfid;int args_nr, nb_vp;
@@ -442,6 +441,7 @@ load_configs(const char *path) test_case->dcoreid = (uint8_t )atoi (dcoreid); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -476,6 +476,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -49,11 +49,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -66,6 +69,6 @@ struct test_configure { uint64_t raddr; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
v7 cover PCI Dev and SG copy support
In reply to Gowrishankar MuthukrishnanImprove dma-perf application to support PCI dev and SG copy, along with additional supports below:
- validate copied memory
- skip tests if not opted.
v7:
- PCI patch updated.
Amit Prakash Shukla (2):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 383 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 56 +++++ app/test-dma-perf/main.c | 136 +++++++++++- app/test-dma-perf/main.h | 12 +- 4 files changed, 545 insertions(+), 42 deletions(-)
Signature · 1 line
2.25.1
PATCH v7 1/4 app/dma-perf: add skip support
From: Amit Prakash Shukla <[email protected]>
Add support to skip running a dma-perf test-case.
--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 23 +++++++++++++++++++++++ app/test-dma-perf/main.h | 1 + 3 files changed, 26 insertions(+)
app/test-dma-perf/config.ini +2 -0
@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with the same name as the configuration ; file, with the addition of "_result.csv" at the end. +; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10
app/test-dma-perf/main.c +23 -0
@@ -320,6 +320,7 @@ load_configs(const char *path)const char *case_type;const char *lcore_dma;const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *skip;int args_nr, nb_vp;bool is_dma;
@@ -339,6 +340,13 @@ load_configs(const char *path)for (i =0 ; i < nb_sections; i++) {snprintf (section_name,CFG_NAME_LEN ,"case%d" , i +1 ); test_case = &test_cases[i]; + + skip =rte_cfgfile_get_entry (cfgfile, section_name,"skip" ); +if (skip && (atoi (skip) ==1 )) { + test_case->is_skip = true; +continue ; + } + case_type =rte_cfgfile_get_entry (cfgfile, section_name,"type" );if (case_type ==NULL ) { printf("Error: No case type in case %d, the test will be finished here.\n",
@@ -523,6 +531,21 @@ main(int argc, char *argv[])printf ("Running cases...\n" );for (i =0 ; i < case_nb; i++) { +if (test_cases[i].is_skip) { +printf ("Test case %d configured to be skipped.\n\n" , i +1 ); +snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Skip the test-case %d\n" , + i +1 ); + + fd =fopen (rst_path_ptr,"a" ); +if (!fd) { +printf ("Open output CSV file error.\n" ); +return 0 ; + } +output_csv (true); +fclose (fd); +continue ; + } +if (!test_cases[i].is_valid) {printf ("Invalid test case %d.\n\n" , i +1 );snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Invalid case %d\n" , i +1 );
app/test-dma-perf/main.h +1 -0
@@ -40,6 +40,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
Signature · 1 line
2.25.1
Re: [PATCH v7 1/4] app/dma-perf: add skip support
Hi Gowrishankar and Amit,
Quoted 59 lines · Gowrishankar Muthukrishnan
From: Amit Prakash Shukla <[email protected]>
Add support to skip running a dma-perf test-case.
Signed-off-by Amit Prakash Shukla <[email protected]>Acked-by Anoob Joseph <[email protected]>--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 23 +++++++++++++++++++++++ app/test-dma-perf/main.h | 1 + 3 files changed, 26 insertions(+)app/test-dma-perf/config.ini +2
-0@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with the same name as the configuration ; file, with the addition of "_result.csv" at the end. +; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10app/test-dma-perf/main.c +12
-0@@ -320,6 +320,7 @@ load_configs(const char *path)const char *case_type;const char *lcore_dma;const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *skip;int args_nr, nb_vp;bool is_dma;@@ -339,6 +340,13 @@ load_configs(const char *path)for (i =0 ; i < nb_sections; i++) {snprintf (section_name,CFG_NAME_LEN ,"case%d" , i +1 ); test_case = &test_cases[i]; + + skip =rte_cfgfile_get_entry (cfgfile, section_name,"skip" ); +if (skip && (atoi (skip) ==1 )) { + test_case->is_skip = true; +continue ; + } + case_type =rte_cfgfile_get_entry (cfgfile, section_name,"type" );if (case_type ==NULL ) { printf("Error: No case type in case %d, the test will be finished here.\n",@@ -523,6 +531,21 @@ main(int argc, char *argv[])printf ("Running cases...\n" );for (i =0 ; i < case_nb; i++) { +if (test_cases[i].is_skip) { +printf ("Test case %d configured to be skipped.\n\n" , i +1 ); +snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Skip the test-case %d\n" , + i +1 );
app/test-dma-perf/main.c main(int argc, char *argv[]) · line 547
Quoted 10 lines
app/test-dma-perf/main.c +10
-0+ + fd =fopen (rst_path_ptr,"a" ); +if (!fd) { +printf ("Open output CSV file error.\n" ); +return 0 ; + } +output_csv (true); +fclose (fd); +continue ; + }
The process is similar to following two cases:
1\ if (!test_cases[i].is_valid)
2\ if (test_cases[i].test_type == TEST_TYPE_NONE)
They just different in error info, suggest abstract one function.
With above fixed,
Thanks
Chengwen
Quoted 17 lines
app/test-dma-perf/main.c +1
-0+if (!test_cases[i].is_valid) {printf ("Invalid test case %d.\n\n" , i +1 );snprintf (output_str[0 ],MAX_OUTPUT_STR_LEN ,"Invalid case %d\n" , i +1 );app/test-dma-perf/main.h +1
-0@@ -40,6 +40,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
RE: [EXT] Re: [PATCH v7 1/4] app/dma-perf: add skip support
Hi Chengwen,
Thanks for the review and feedback. Changes suggested by you are incorporated as part of v8 send by Gowrishankar. In v8, have also removed a redundant check for TEST_TYPE_NONE.
Thanks,
Amit Shukla
Quoted 106 lines
-----Original Message-----
From: fengchengwen <[email protected]>
Sent: Monday, November 20, 2023 8:25 AM
To: Gowrishankar Muthukrishnan <[email protected]>; [email protected]
Cc: Anoob Joseph <[email protected]>; Cheng Jiang <[email protected]>; Kevin Laatz <[email protected]>; Bruce Richardson <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Amit Prakash Shukla <[email protected]>
Subject: [EXT] Re: [PATCH v7 1/4] app/dma-perf: add skip supportExternal Email
----------------------------------------------------------------------
Hi Gowrishankar and Amit,Quoted 18 lines · Gowrishankar Muthukrishnan
From: Amit Prakash Shukla <[email protected]>
Add support to skip running a dma-perf test-case.
Signed-off-by Amit Prakash Shukla <[email protected]>Acked-by Anoob Joseph <[email protected]>--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 23 +++++++++++++++++++++++ app/test-dma-perf/main.h | 1 + 3 files changed, 26 insertions(+)(quoted diff) +0
-0b/app/test-dma-perf/config.ini index
b550f4b23f..4d59234b2a100644app/test-dma-perf/config.ini +0
-0@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with theQuoted 1 line
same name as the configuration ; file, with the addition of "_result.csv" at
the end.
Quoted 21 lines
app/test-dma-perf/config.ini +2
-0+; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10app/test-dma-perf/main.c index renamed from app/test-dma-perf/main.c +0
-0
5f8bab8f45..c74f1d81bd100644app/test-dma-perf/main.c +1
-0@@ -320,6 +320,7 @@ load_configs(const char *path)const char *case_type;const char *lcore_dma;const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *skip;int args_nr, nb_vp;bool is_dma;@@ -339,6 +340,13 @@ load_configs(const char *path)for (i =0 ; i < nb_sections; i++) {app/test-dma-perf/main.c load_configs(const char *path) · line 350
Quoted 10 lines
app/test-dma-perf/main.c +7
-0snprintf (section_name,CFG_NAME_LEN ,"case%d" , i +1 ); test_case = &test_cases[i]; + + skip =rte_cfgfile_get_entry (cfgfile, section_name,"skip" ); +if (skip && (atoi (skip) ==1 )) { + test_case->is_skip = true; +continue ; + } + case_type = rte_cfgfile_get_entry(cfgfile, section_name,"type");
app/test-dma-perf/main.c load_configs(const char *path) · line 352
Quoted 2 lines
app/test-dma-perf/main.c +0
-0if (case_type ==NULL ) { printf("Error: No case type in case %d, the test will befinished
app/test-dma-perf/main.c main(int argc, char *argv[])
Quoted 6 lines
here.\n", @@ -523,6 +531,21 @@
main(int argc, char *argv[])app/test-dma-perf/main.c +2
-0printf ("Running cases...\n" );for (i =0 ; i < case_nb; i++) { +if (test_cases[i].is_skip) { + printf("Test case %d configured to be skipped.\n\n", i+ 1);
app/test-dma-perf/main.c
Quoted 1 line
app/test-dma-perf/main.c +1
-0+ snprintf(output_str[0], MAX_OUTPUT_STR_LEN, "Skipthe test-case %d\n",
app/test-dma-perf/main.c main(int argc, char *argv[]) · line 547
Quoted 11 lines
app/test-dma-perf/main.c +11
-0+ i + 1); + + fd =fopen (rst_path_ptr,"a" ); +if (!fd) { +printf ("Open output CSV file error.\n" ); +return 0 ; + } +output_csv (true); +fclose (fd); +continue ; + }The process is similar to following two cases:
1\ if (!test_cases[i].is_valid)
2\ if (test_cases[i].test_type ==TEST_TYPE_NONE)They just different in error info, suggest abstract one function.
With above fixed,
Acked-by Chengwen Feng <[email protected]>Thanks
Chengwen
<snip>
PATCH v7 2/4 app/dma-perf: add PCI device support
In reply to Gowrishankar MuthukrishnanFrom: Amit Prakash Shukla <[email protected]>
Add support to test performance for "device to memory" and "memory to device" data transfer.
---
v7:
- changed cfg->raddr type to uintptr_t to fix 32 bit compilation.
--- app/test-dma-perf/benchmark.c | 108 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 37 ++++++++++++ app/test-dma-perf/main.c | 67 +++++++++++++++++++++ app/test-dma-perf/main.h | 6 ++ 4 files changed, 209 insertions(+), 9 deletions(-)
app/test-dma-perf/benchmark.c +99 -9
@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->dcoreid; + qconf->dst_port.pcie.vfid = cfg->vfid; + qconf->dst_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->scoreid; + qconf->src_port.pcie.vfid = cfg->vfid; + qconf->src_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );
@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;
@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }
@@ -302,13 +338,22 @@ do_cpu_mem_copy(void *p)return 0 ; } +static void +dummy_free_ext_buf (void *addr,void *opaque) +{ +RTE_SET_USED (addr); +RTE_SET_USED (opaque); +} +static int setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs,struct rte_mbuf ***dsts) { +static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -361,16 +406,47 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || + cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 ); +if (ext_buf_info ==NULL ) { +printf ("Error: ext_buf_info malloc failed.\n" ); +return -1 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*srcs)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*dsts)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } +return 0 ; }void mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ; -struct rte_mbuf **srcs =NULL , **dsts =NULL ; +struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur;
@@ -476,6 +552,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) avg_cycles_total / nb_workers, bandwidth_total, mops_total); out: + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) + m = srcs; +else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) + m = dsts; + +if (m) { +for (i =0 ; i < nr_buf; i++) +rte_pktmbuf_detach_extbuf (m[i]); + +if (m[0 ]->shinfo &&rte_mbuf_ext_refcnt_read (m[0 ]->shinfo) ==0 ) +rte_free (m[0 ]->shinfo); + } +/* free mbufs used in the test */ if (srcs !=NULL )rte_pktmbuf_free_bulk (srcs, nr_buf);
app/test-dma-perf/config.ini +37 -0
@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": +; ================================================================================== +; "direction" denotes the direction of data transfer. It can take 3 values: +; 0 - mem to mem transfer +; 1 - mem to dev transfer +; 2 - dev to mem transfer +; If not specified the default value is 0 (mem to mem transfer). + +; "raddr" remote iova address for "mem to dev" and "dev to mem" transfer. + +; "scoreid" denotes source PCIe core index. +; "dcoreid" denotes destination PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer. + +; =========== End of "mem to dev" and "dev to mem" config parameters. ============== + [case1] type=DMA_MEM_COPY mem_size=10
@@ -52,6 +69,26 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=2 +raddr=0x200000000 +scoreid=0 +dcoreid=0 +pfid=0 +vfid=0 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +67 -0
94 lines not on this page · raw message
app/test-dma-perf/main.h +6 -0
@@ -42,6 +42,7 @@ struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
@@ -57,6 +58,11 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +uint8_t scoreid; +uint8_t dcoreid; +uint8_t pfid; +uint16_t vfid; +uintptr_t raddr; };void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
Signature · 1 line
2.25.1
PATCH v7 3/4 app/dma-perf: validate copied memory
In reply to Gowrishankar MuthukrishnanValidate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-)
app/test-dma-perf/benchmark.c +20 -1
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -406,6 +407,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 );
@@ -440,7 +446,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint32_t i;
@@ -458,6 +464,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -531,6 +538,16 @@ 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -596,4 +613,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -87,20 +87,24 @@ output_header(uint32_t case_id, struct test_configure *case_cfg)output_csv (true); } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -145,8 +149,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -65,6 +65,6 @@ struct test_configure { uintptr_t raddr; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.25.1
PATCH v7 4/4 app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support.
--- app/test-dma-perf/benchmark.c | 274 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 19 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 292 insertions(+), 40 deletions(-)
app/test-dma-perf/benchmark.c +240 -34
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }
@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -347,8 +428,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;
@@ -443,20 +525,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -464,12 +582,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -483,13 +621,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + } + offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -503,10 +651,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -538,13 +699,53 @@ 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_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
@@ -555,10 +756,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -601,13 +800,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +18 -1
@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments. ; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.
@@ -69,6 +71,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=2
@@ -88,7 +105,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +30 -4
@@ -94,10 +94,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -327,7 +325,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;const char *raddr, *scoreid, *dcoreid, *vfid, *pfid;int args_nr, nb_vp;
@@ -442,6 +441,7 @@ load_configs(const char *path) test_case->dcoreid = (uint8_t )atoi (dcoreid); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -476,6 +476,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -48,11 +48,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -65,6 +68,6 @@ struct test_configure { uintptr_t raddr; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
v8 cover PCI Dev and SG copy support
In reply to Gowrishankar MuthukrishnanImprove dma-perf application to support PCI dev and SG copy, along with additional supports below:
- validate copied memory
- skip tests if not opted.
v8:
- updated skip test patch.
Amit Prakash Shukla (2):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 383 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 56 +++++ app/test-dma-perf/main.c | 161 +++++++++++--- app/test-dma-perf/main.h | 12 +- 4 files changed, 551 insertions(+), 61 deletions(-)
Signature · 1 line
2.25.1
PATCH v8 1/4 app/dma-perf: add skip support
From: Amit Prakash Shukla <[email protected]>
Add support to skip running a dma-perf test-case.
---
v8:
- abstracted csv file write error log
--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 48 ++++++++++++++++++++++-------------- app/test-dma-perf/main.h | 1 + 3 files changed, 32 insertions(+), 19 deletions(-)
app/test-dma-perf/config.ini +2 -0
@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with the same name as the configuration ; file, with the addition of "_result.csv" at the end. +; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10
app/test-dma-perf/main.c +29 -19
78 lines not on this page · raw message
app/test-dma-perf/main.h +1 -0
@@ -40,6 +40,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
Signature · 1 line
2.25.1
PATCH v8 2/4 app/dma-perf: add PCI device support
In reply to Gowrishankar MuthukrishnanFrom: Amit Prakash Shukla <[email protected]>
Add support to test performance for "device to memory" and "memory to device" data transfer.
--- app/test-dma-perf/benchmark.c | 108 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 37 ++++++++++++ app/test-dma-perf/main.c | 67 +++++++++++++++++++++ app/test-dma-perf/main.h | 6 ++ 4 files changed, 209 insertions(+), 9 deletions(-)
app/test-dma-perf/benchmark.c +99 -9
@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->dcoreid; + qconf->dst_port.pcie.vfid = cfg->vfid; + qconf->dst_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->scoreid; + qconf->src_port.pcie.vfid = cfg->vfid; + qconf->src_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );
@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;
@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }
@@ -302,13 +338,22 @@ do_cpu_mem_copy(void *p)return 0 ; } +static void +dummy_free_ext_buf (void *addr,void *opaque) +{ +RTE_SET_USED (addr); +RTE_SET_USED (opaque); +} +static int setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs,struct rte_mbuf ***dsts) { +static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -361,16 +406,47 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || + cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 ); +if (ext_buf_info ==NULL ) { +printf ("Error: ext_buf_info malloc failed.\n" ); +return -1 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*srcs)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*dsts)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } +return 0 ; }void mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ; -struct rte_mbuf **srcs =NULL , **dsts =NULL ; +struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur;
@@ -476,6 +552,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) avg_cycles_total / nb_workers, bandwidth_total, mops_total); out: + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) + m = srcs; +else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) + m = dsts; + +if (m) { +for (i =0 ; i < nr_buf; i++) +rte_pktmbuf_detach_extbuf (m[i]); + +if (m[0 ]->shinfo &&rte_mbuf_ext_refcnt_read (m[0 ]->shinfo) ==0 ) +rte_free (m[0 ]->shinfo); + } +/* free mbufs used in the test */ if (srcs !=NULL )rte_pktmbuf_free_bulk (srcs, nr_buf);
app/test-dma-perf/config.ini +37 -0
@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": +; ================================================================================== +; "direction" denotes the direction of data transfer. It can take 3 values: +; 0 - mem to mem transfer +; 1 - mem to dev transfer +; 2 - dev to mem transfer +; If not specified the default value is 0 (mem to mem transfer). + +; "raddr" remote iova address for "mem to dev" and "dev to mem" transfer. + +; "scoreid" denotes source PCIe core index. +; "dcoreid" denotes destination PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer. + +; =========== End of "mem to dev" and "dev to mem" config parameters. ============== + [case1] type=DMA_MEM_COPY mem_size=10
@@ -52,6 +69,26 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=2 +raddr=0x200000000 +scoreid=0 +dcoreid=0 +pfid=0 +vfid=0 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +67 -0
94 lines not on this page · raw message
app/test-dma-perf/main.h +6 -0
@@ -42,6 +42,7 @@ struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
@@ -57,6 +58,11 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +uint8_t scoreid; +uint8_t dcoreid; +uint8_t pfid; +uint16_t vfid; +uintptr_t raddr; };void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
Signature · 1 line
2.25.1
Re: [PATCH v8 2/4] app/dma-perf: add PCI device support
Quoted 14 lines · Gowrishankar Muthukrishnan
From: Amit Prakash Shukla <[email protected]>
Add support to test performance for "device to memory" and "memory to device" data transfer.
Signed-off-by Amit Prakash Shukla <[email protected]>Acked-by Anoob Joseph <[email protected]>--- app/test-dma-perf/benchmark.c | 108 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 37 ++++++++++++ app/test-dma-perf/main.c | 67 +++++++++++++++++++++ app/test-dma-perf/main.h | 6 ++ 4 files changed, 209 insertions(+), 9 deletions(-)
...
Re: [PATCH v8 2/4] app/dma-perf: add PCI device support
In reply to Gowrishankar MuthukrishnanHi Amit,
There are many commit for dma-perf, I've done a re-review and have a few comments, pls see below:
Quoted 194 lines · Gowrishankar Muthukrishnan
From: Amit Prakash Shukla <[email protected]>
Add support to test performance for "device to memory" and "memory to device" data transfer.
Signed-off-by Amit Prakash Shukla <[email protected]>Acked-by Anoob Joseph <[email protected]>--- app/test-dma-perf/benchmark.c | 108 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 37 ++++++++++++ app/test-dma-perf/main.c | 67 +++++++++++++++++++++ app/test-dma-perf/main.h | 6 ++ 4 files changed, 209 insertions(+), 9 deletions(-)app/test-dma-perf/benchmark.c +99
-9@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->dcoreid; + qconf->dst_port.pcie.vfid = cfg->vfid; + qconf->dst_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->scoreid; + qconf->src_port.pcie.vfid = cfg->vfid; + qconf->src_port.pcie.pfid = cfg->pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }@@ -302,13 +338,22 @@ do_cpu_mem_copy(void *p)return 0 ; } +static void +dummy_free_ext_buf (void *addr,void *opaque) +{ +RTE_SET_USED (addr); +RTE_SET_USED (opaque); +} +static int setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs,struct rte_mbuf ***dsts) { +static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||@@ -361,16 +406,47 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || + cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 ); +if (ext_buf_info ==NULL ) { +printf ("Error: ext_buf_info malloc failed.\n" ); +return -1 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*srcs)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*dsts)[i], (void *)cfg->raddr, + (rte_iova_t )cfg->raddr,0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } +return 0 ; }void mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ; -struct rte_mbuf **srcs =NULL , **dsts =NULL ; +struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur;@@ -476,6 +552,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) avg_cycles_total / nb_workers, bandwidth_total, mops_total); out: + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) + m = srcs; +else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) + m = dsts; + +if (m) { +for (i =0 ; i < nr_buf; i++) +rte_pktmbuf_detach_extbuf (m[i]); + +if (m[0 ]->shinfo &&rte_mbuf_ext_refcnt_read (m[0 ]->shinfo) ==0 ) +rte_free (m[0 ]->shinfo); + } +/* free mbufs used in the test */ if (srcs !=NULL )rte_pktmbuf_free_bulk (srcs, nr_buf);app/test-dma-perf/config.ini +0
-0
app/test-dma-perf/config.ini line 46
Quoted 9 lines
app/test-dma-perf/config.ini +6
-0@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": +; ================================================================================== +; "direction" denotes the direction of data transfer. It can take 3 values: +; 0 - mem to mem transfer +; 1 - mem to dev transfer +; 2 - dev to mem transfer
I prefer readable string not number, for examples:
mem2mem
mem2dev
dev2mem
app/test-dma-perf/config.ini line 54
Quoted 8 lines
app/test-dma-perf/config.ini +8
-0+; If not specified the default value is 0 (mem to mem transfer). + +; "raddr" remote iova address for "mem to dev" and "dev to mem" transfer. + +; "scoreid" denotes source PCIe core index. +; "dcoreid" denotes destination PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer.
too many entries, and it all about pcie, the 'struct rte_dma_port_param' future may support other bus.
Suggest the entry is vchan_dev, user could input some thing like
1. vchan_dev=bus=pcie,coreid=1,pfid=0,vfid=1,addr=xxx
add add descriptor, only valid when direction is one of mem2dev or dev2mem
It could use kvargs library to parse the value of entry vchan_dev
Quoted 122 lines
app/test-dma-perf/config.ini +23
-0+ +; =========== End of "mem to dev" and "dev to mem" config parameters. ============== + [case1] type=DMA_MEM_COPY mem_size=10@@ -52,6 +69,26 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=2 +raddr=0x200000000 +scoreid=0 +dcoreid=0 +pfid=0 +vfid=0 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MULapp/test-dma-perf/main.c +57
-0@@ -16,6 +16,7 @@#include <rte_cfgfile.h> #include <rte_string_fns.h> #include <rte_lcore.h> +#include <rte_dmadev.h> #include "main.h" @@ -331,9 +332,11 @@ load_configs(const char *path)struct test_configure *test_case;char section_name[CFG_NAME_LEN ];const char *case_type; +const char *transfer_dir;const char *lcore_dma;const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str;const char *skip; +const char *raddr, *scoreid, *dcoreid, *vfid, *pfid;int args_nr, nb_vp;bool is_dma;@@ -371,6 +374,20 @@ load_configs(const char *path)if (strcmp (case_type,DMA_MEM_COPY ) ==0 ) { test_case->test_type =TEST_TYPE_DMA_MEM_COPY ; test_case->test_type_str =DMA_MEM_COPY ; + + transfer_dir =rte_cfgfile_get_entry (cfgfile, section_name,"direction" ); +if (transfer_dir ==NULL ) { +printf ("Transfer direction not configured." +" Defaulting it to MEM to MEM transfer.\n" ); + test_case->transfer_dir =RTE_DMA_DIR_MEM_TO_MEM ; + }else + test_case->transfer_dir = (uint8_t )atoi (transfer_dir); + +if (test_case->transfer_dir >=RTE_DMA_DIR_DEV_TO_DEV ) { +printf ("Error: Invalid transfer direction configured.\n" ); + test_case->is_valid = false; +continue ; + } is_dma = true; }else if (strcmp (case_type,CPU_MEM_COPY ) ==0 ) { test_case->test_type =TEST_TYPE_CPU_MEM_COPY ;@@ -382,6 +399,56 @@ load_configs(const char *path)continue ; } +if (test_case->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV || + test_case->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { +char *endptr; + + raddr =rte_cfgfile_get_entry (cfgfile, section_name,"raddr" ); +if (raddr ==NULL ) { +printf ("Error: No raddr configured for case%d.\n" , i +1 ); + test_case->is_valid = false; +continue ; + } + test_case->raddr =strtoull (raddr, &endptr,16 ); + + vfid =rte_cfgfile_get_entry (cfgfile, section_name,"vfid" ); +if (vfid ==NULL ) { +printf ("Error: No vfid configured for case%d.\n" , i +1 ); + test_case->is_valid = false; +continue ; + } + test_case->vfid = (uint16_t )atoi (vfid); + + pfid =rte_cfgfile_get_entry (cfgfile, section_name,"pfid" ); +if (pfid ==NULL ) { +printf ("Error: No pfid configured for case%d.\n" , i +1 ); + test_case->is_valid = false; +continue ; + } + test_case->pfid = (uint8_t )atoi (pfid); + + } + +if (test_case->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + scoreid =rte_cfgfile_get_entry (cfgfile, section_name,"scoreid" ); +if (scoreid ==NULL ) { +printf ("Error: No scoreid configured for case%d.\n" , i +1 ); + test_case->is_valid = false; +continue ; + } + test_case->scoreid = (uint8_t )atoi (scoreid); + } +
app/test-dma-perf/main.c load_configs(const char *path) · line 451
Quoted 10 lines
app/test-dma-perf/main.c +10
-0+if (test_case->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + dcoreid =rte_cfgfile_get_entry (cfgfile, section_name,"dcoreid" ); +if (dcoreid ==NULL ) { +printf ("Error: No dcoreid configured for case%d.\n" , i +1 ); + test_case->is_valid = false; +continue ; + } + test_case->dcoreid = (uint8_t )atoi (dcoreid); + } +
suggest add a subfunction to wrap parsing device's config.
Quoted 16 lines
app/test-dma-perf/main.c +0
-0test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,app/test-dma-perf/main.h +1
-0@@ -42,6 +42,7 @@ struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
app/test-dma-perf/main.h struct test_configure { · line 65
Quoted 8 lines
app/test-dma-perf/main.h +5
-0@@ -57,6 +58,11 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +uint8_t scoreid; +uint8_t dcoreid; +uint8_t pfid; +uint16_t vfid; +uintptr_t raddr;
suggest create new struct:
struct test_vchan_dev_config {
struct rte_dma_port_param port;
uintptr_t addr;
};So defined as:
struct test_vchan_dev_config vchan_dev;
Thanks
Quoted 4 lines
app/test-dma-perf/main.h +0
-0};void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
RE: [EXT] Re: [PATCH v8 2/4] app/dma-perf: add PCI device support
Hi Chengwen,
Thanks for the review and feedback. I will send the next version with suggested changes.
Thanks,
Amit Shukla
Quoted 14 lines
-----Original Message-----
From: fengchengwen <[email protected]>
Sent: Wednesday, February 21, 2024 8:56 AM
To: Gowrishankar Muthukrishnan <[email protected]>; [email protected]; Amit Prakash Shukla <[email protected]>
Cc: Anoob Joseph <[email protected]>; Cheng Jiang <[email protected]>; Kevin Laatz <[email protected]>; Bruce Richardson <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Thomas Monjalon <[email protected]>
Subject: [EXT] Re: [PATCH v8 2/4] app/dma-perf: add PCI device supportExternal Email
----------------------------------------------------------------------
<snip>
Quoted 56 lines
app/test-dma-perf/config.ini line 41
Quoted 11 lines
(quoted diff) +0
-0if (srcs != NULL) rte_pktmbuf_free_bulk(srcs, nr_buf); diff --gita/app/test-dma-perf/config.ini b/app/test-dma-perf/config.ini index
4d59234b2a..cddcf93c6e100644app/test-dma-perf/config.ini +1
-0@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and"dev to mem":
app/test-dma-perf/config.ini line 43
Quoted 2 lines
app/test-dma-perf/config.ini +1
-0+;+==================================================================
===app/test-dma-perf/config.ini line 46
Quoted 5 lines
app/test-dma-perf/config.ini +5
-0+============= ; "direction" denotes the direction of data transfer. +It can take 3 values: +; 0 - mem to mem transfer +; 1 - mem to dev transfer +; 2 - dev to mem transferI prefer readable string not number, for examples:
mem2mem
mem2dev
dev2memapp/test-dma-perf/config.ini
Quoted 8 lines
app/test-dma-perf/config.ini +8
-0+; If not specified the default value is 0 (mem to mem transfer). + +; "raddr" remote iova address for "mem to dev" and "dev to mem" transfer. + +; "scoreid" denotes source PCIe core index. +; "dcoreid" denotes destination PCIe core index. +; "pfid" denotes PF-id to be used for data transfer ; "vfid" denotes +VF-id of PF-id to be used for data transfer.too many entries, and it all about pcie, the 'struct
rte_dma_port_param' future may support other bus.Suggest the entry is
vchan_dev, user could input some thing like 1. vchan_dev=bus=pcie,coreid=1,pfid=0,vfid=1,addr=xxx
add add descriptor, only valid when direction is one of mem2dev or
dev2memIt could use kvargs library to parse the value of entry
vchan_devQuoted 10 lines
app/test-dma-perf/config.ini +4
-0+ +; =========== End of "mem to dev" and "dev to mem" config parameters. +============== + [case1] type=DMA_MEM_COPY mem_size=10@@ -52,6 +69,26 @@ lcore_dma=lcore10@0000:00:04.2,lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test
<snip>
Quoted 72 lines
app/test-dma-perf/config.ini
Quoted 3 lines
app/test-dma-perf/config.ini +3
-0+ + if (test_case->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM) { + scoreid = rte_cfgfile_get_entry(cfgfile, section_name,"scoreid");
app/test-dma-perf/config.ini
Quoted 2 lines
app/test-dma-perf/config.ini +2
-0+ if (scoreid == NULL) { + printf("Error: No scoreid configured forcase%d.\n", i + 1);
app/test-dma-perf/config.ini
Quoted 8 lines
app/test-dma-perf/config.ini +8
-0+ test_case->is_valid = false; + continue; + } + test_case->scoreid = (uint8_t)atoi(scoreid); + } + + if (test_case->transfer_dir == RTE_DMA_DIR_MEM_TO_DEV) { + dcoreid = rte_cfgfile_get_entry(cfgfile, section_name,"dcoreid");
app/test-dma-perf/config.ini
Quoted 2 lines
app/test-dma-perf/config.ini +2
-0+ if (dcoreid == NULL) { + printf("Error: No dcoreid configured forcase%d.\n", i + 1);
app/test-dma-perf/config.ini
Quoted 6 lines
app/test-dma-perf/config.ini +6
-0+ test_case->is_valid = false; + continue; + } + test_case->dcoreid = (uint8_t)atoi(dcoreid); + } +suggest add a subfunction to wrap parsing device's config.
Quoted 1 line
test_case->src_numa_node=(int)atoi(rte_cfgfile_get_entry(cfgfile,
Quoted 1 line
section_name, "src_numa_node"));Quoted 1 line
test_case->dst_numa_node=(int)atoi(rte_cfgfile_get_entry(cfgfile,
Quoted 13 lines
app/test-dma-perf/main.h index renamed from app/test-dma-perf/main.h +0
-0
32670151af..8ac3270fba100644app/test-dma-perf/main.h +1
-0@@ -42,6 +42,7 @@ struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;app/test-dma-perf/main.h struct test_configure { · line 65
Quoted 8 lines
app/test-dma-perf/main.h +5
-0@@ -57,6 +58,11 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +uint8_t scoreid; +uint8_t dcoreid; +uint8_t pfid; +uint16_t vfid; +uintptr_t raddr;suggest create new struct:
struct test_vchan_dev_config { struct rte_dma_port_param port; uintptr_t addr; };So defined as:
structtest_vchan_dev_configvchan_dev;Thanks
Quoted 4 lines
app/test-dma-perf/main.h +0
-0};void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
PATCH v8 3/4 app/dma-perf: validate copied memory
In reply to Gowrishankar MuthukrishnanValidate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-)
app/test-dma-perf/benchmark.c +20 -1
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -406,6 +407,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 );
@@ -440,7 +446,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint32_t i;
@@ -458,6 +464,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -531,6 +538,16 @@ 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -596,4 +613,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -100,20 +100,24 @@ open_output_csv(const char *rst_path_ptr)return 0 ; } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -158,8 +162,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -65,6 +65,6 @@ struct test_configure { uintptr_t raddr; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.25.1
Re: [PATCH v8 3/4] app/dma-perf: validate copied memory
Quoted 10 lines · Gowrishankar Muthukrishnan
Validate copied memory to ensure DMA copy did not fail.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>Acked-by Anoob Joseph <[email protected]>--- app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-)
...
PATCH v8 4/4 app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support.
--- app/test-dma-perf/benchmark.c | 274 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 19 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 292 insertions(+), 40 deletions(-)
app/test-dma-perf/benchmark.c +240 -34
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }
@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -347,8 +428,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;
@@ -443,20 +525,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -464,12 +582,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -483,13 +621,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + } + offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -503,10 +651,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -538,13 +699,53 @@ 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_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
@@ -555,10 +756,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -601,13 +800,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +18 -1
@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments. ; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.
@@ -69,6 +71,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=2
@@ -88,7 +105,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +30 -4
@@ -107,10 +107,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -340,7 +338,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;const char *raddr, *scoreid, *dcoreid, *vfid, *pfid;int args_nr, nb_vp;
@@ -455,6 +454,7 @@ load_configs(const char *path) test_case->dcoreid = (uint8_t )atoi (dcoreid); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -489,6 +489,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -48,11 +48,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -65,6 +68,6 @@ struct test_configure { uintptr_t raddr; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
LGTM
Thanks
Quoted 11 lines · Gowrishankar Muthukrishnan
Add SG copy support.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>Acked-by Anoob Joseph <[email protected]>--- app/test-dma-perf/benchmark.c | 274 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 19 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 292 insertions(+), 40 deletions(-)
...
Hi Gowrishankar,
Quoted 443 lines · Gowrishankar Muthukrishnan
Add SG copy support.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>Acked-by Anoob Joseph <[email protected]>--- app/test-dma-perf/benchmark.c | 274 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 19 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 292 insertions(+), 40 deletions(-)app/test-dma-perf/benchmark.c +240
-34@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {@@ -347,8 +428,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int buf_size = cfg->buf_size.cur;@@ -443,20 +525,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = buf_size / src_ptrs; + sglen_dst = buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;@@ -464,12 +582,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;@@ -483,13 +621,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + } + offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;@@ -503,10 +651,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {@@ -538,13 +699,53 @@ 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_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }@@ -555,10 +756,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;@@ -601,13 +800,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);app/test-dma-perf/config.ini +0
-0
app/test-dma-perf/config.ini line 13
Quoted 5 lines
app/test-dma-perf/config.ini +2
-0@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between ; 64 and 4096. +; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments.
The two entry is hard to understand, I prefer src_sge_num/dst_sge_num (better names are also welcome.) and add descript about:
1. only valid when the type is DMA_MEM_COPY
2. enable scatter-gather copy test when both are set.
Thanks.
Quoted 129 lines
app/test-dma-perf/config.ini +16
-1; "kick_batch" denotes the dma operation batch size, and should be greater than 1 normally. ; The format for variables is variable=first,last,increment,ADD|MUL.@@ -69,6 +71,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_ptrs_src=4 +dma_ptrs_dst=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=2@@ -88,7 +105,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MULapp/test-dma-perf/main.c +30
-4@@ -107,10 +107,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);@@ -340,7 +338,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;const char *raddr, *scoreid, *dcoreid, *vfid, *pfid;int args_nr, nb_vp;@@ -455,6 +454,7 @@ load_configs(const char *path) test_case->dcoreid = (uint8_t )atoi (dcoreid); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,@@ -489,6 +489,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_src" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_src" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_ptrs_dst" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_ptrs_dst" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_ptrs_src, dma_ptrs_dst error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {app/test-dma-perf/main.h +4
-1@@ -48,11 +48,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;@@ -65,6 +68,6 @@ struct test_configure { uintptr_t raddr; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Quoted 7 lines
Quoted 7 lines
(quoted diff) +0
-0b/app/test-dma-perf/config.ini index
cddcf93c6e..f460b93414100644app/test-dma-perf/config.ini +0
-0@@ -9,6 +9,8 @@ ; "buf_size" denotes the memory size of a single operation. ; "dma_ring_size" denotes the dma ring buffer size. It should be must
Quoted 9 lines
app/test-dma-perf/config.ini line 13
Quoted 3 lines
be a power of two, and between ; 64 and 4096.
app/test-dma-perf/config.ini +2
-0+; "dma_ptrs_src" denotes number of source segments. +; "dma_ptrs_dst" denotes number of destination segments.The two entry is hard to understand, I prefer src_sge_num/dst_sge_num (better names are also welcome.) and add descript about:
1. only valid when the type isDMA_MEM_COPY2. enable scatter-gather copy test when both are set.
Yes Chengwen, I have named variables dma_src_sge and dma_dst_sge to fit context.
Please check https://patches.dpdk.org/project/dpdk/patch/[email protected]/ .
Thanks,
Gowrishankar
RE: [PATCH v8 0/4] PCI Dev and SG copy support
In reply to Gowrishankar MuthukrishnanHi,
Could this patch series be reviewed ? As of now, patches are rebased without any conflicts.
Thanks,
Gowrishankar
Quoted 38 lines
-----Original Message-----
From: Gowrishankar Muthukrishnan <[email protected]>
Sent: Wednesday, November 22, 2023 4:36 PM
To: [email protected]
Cc: Anoob Joseph <[email protected]>; Cheng Jiang <[email protected]>; Kevin Laatz <[email protected]>; Bruce Richardson <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Amit Prakash Shukla <[email protected]>; Chengwen Feng <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>
Subject: [PATCH v8 0/4] PCI Dev and SG copy supportImprove dma-perf application to support PCI dev and SG copy, along with additional supports below:
- validate copied memory
- skip tests if not opted.v8:
- updated skip test patch.Amit Prakash Shukla (2):
app/dma-perf: add skip support
app/dma-perf: add PCI device supportGowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy supportapp/test-dma-perf/benchmark.c | 383 +++++++++++++++++++++++++++++++--- app/test-dma-perf/config.ini | 56 +++++ app/test-dma-perf/main.c | 161 +++++++++++--- app/test-dma-perf/main.h | 12 +- 4 files changed, 551 insertions(+), 61 deletions(-)--
2.25.1
RE: [PATCH v8 0/4] PCI Dev and SG copy support
Hi,
Could this series be merged as the patches are acked.
Thanks,
Gowrishankar
v9 cover PCI Dev and SG copy support
In reply to Gowrishankar MuthukrishnanImprove dma-perf application to support PCI dev and SG copy, along with additional supports as below:
- validate copied memory
- skip tests if not opted.
v9:
- Review suggestions.
Amit Prakash Shukla (2):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 392 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 58 +++++ app/test-dma-perf/main.c | 171 ++++++++++++--- app/test-dma-perf/main.h | 13 +- 4 files changed, 570 insertions(+), 64 deletions(-)
Signature · 1 line
2.34.1
PATCH v9 1/4 app/dma-perf: add skip support
Add support to skip running a dma-perf test-case.
--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 48 ++++++++++++++++++++++-------------- app/test-dma-perf/main.h | 1 + 3 files changed, 32 insertions(+), 19 deletions(-)
app/test-dma-perf/config.ini +2 -0
@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with the same name as the configuration ; file, with the addition of "_result.csv" at the end. +; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10
app/test-dma-perf/main.c +29 -19
78 lines not on this page · raw message
app/test-dma-perf/main.h +1 -0
@@ -40,6 +40,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
Signature · 1 line
2.34.1
PATCH v9 2/4 app/dma-perf: add PCI device support
In reply to Amit Prakash ShuklaAdd support to test performance for "device to memory" and "memory to device" data transfer.
---
v9:
- PCI config parsing using kvargs.
app/test-dma-perf/benchmark.c | 117 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 33 ++++++++++ app/test-dma-perf/main.c | 77 ++++++++++++++++++++++ app/test-dma-perf/main.h | 7 ++ 4 files changed, 222 insertions(+), 12 deletions(-)
app/test-dma-perf/benchmark.c +105 -12
@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->vchan_dev.port.pcie.coreid; + qconf->dst_port.pcie.vfid = cfg->vchan_dev.port.pcie.vfid; + qconf->dst_port.pcie.pfid = cfg->vchan_dev.port.pcie.pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->vchan_dev.port.pcie.coreid; + qconf->src_port.pcie.vfid = cfg->vchan_dev.port.pcie.vfid; + qconf->src_port.pcie.pfid = cfg->vchan_dev.port.pcie.pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );
@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;
@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }
@@ -302,13 +338,23 @@ do_cpu_mem_copy(void *p)return 0 ; } +static void +dummy_free_ext_buf (void *addr,void *opaque) +{ +RTE_SET_USED (addr); +RTE_SET_USED (opaque); +} +static int setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs,struct rte_mbuf ***dsts) { -unsigned int buf_size = cfg->buf_size.cur; +static struct rte_mbuf_ext_shared_info *ext_buf_info; +unsigned int cur_buf_size = cfg->buf_size.cur; +unsigned int buf_size = cur_buf_size +RTE_PKTMBUF_HEADROOM ;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -321,7 +367,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, nr_buf,0 ,0 , - buf_size +RTE_PKTMBUF_HEADROOM , + buf_size, cfg->src_numa_node);if (src_pool ==NULL ) {PRINT_ERR ("Error with source mempool creation.\n" );
@@ -332,7 +378,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, nr_buf,0 ,0 , - buf_size +RTE_PKTMBUF_HEADROOM , + buf_size, cfg->dst_numa_node);if (dst_pool ==NULL ) {PRINT_ERR ("Error with destination mempool creation.\n" );
@@ -361,16 +407,49 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || + cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 ); +if (ext_buf_info ==NULL ) { +printf ("Error: ext_buf_info malloc failed.\n" ); +return -1 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*srcs)[i], (void *)(cfg->vchan_dev.raddr + + (i * buf_size)), (rte_iova_t)(cfg->vchan_dev.raddr + + (i * buf_size)),0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*dsts)[i], (void *)(cfg->vchan_dev.raddr + + (i * buf_size)), (rte_iova_t)(cfg->vchan_dev.raddr + + (i * buf_size)),0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } +return 0 ; }void mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ; -struct rte_mbuf **srcs =NULL , **dsts =NULL ; +struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur;
@@ -476,6 +555,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) avg_cycles_total / nb_workers, bandwidth_total, mops_total); out: + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) + m = srcs; +else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) + m = dsts; + +if (m) { +for (i =0 ; i < nr_buf; i++) +rte_pktmbuf_detach_extbuf (m[i]); + +if (m[0 ]->shinfo &&rte_mbuf_ext_refcnt_read (m[0 ]->shinfo) ==0 ) +rte_free (m[0 ]->shinfo); + } +/* free mbufs used in the test */ if (srcs !=NULL )rte_pktmbuf_free_bulk (srcs, nr_buf);
app/test-dma-perf/config.ini +33 -0
@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": +; ================================================================================== +; "direction" denotes the direction of data transfer. It can take 3 values: +; mem2mem - mem to mem transfer +; mem2dev - mem to dev transfer +; dev2mem - dev to mem transfer +; If not specified the default value is mem2mem transfer. + +; "vchan_dev comma separated bus related config parameter for mem2dev and dev2mem dma transfer. Ex:" +; vchan_dev=raddr=0x400000,coreid=1,pfid=2,vfid=3 +; "raddr" remote iova address for mem2dev and dev2mem transfer. +; "coreid" denotes PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer. + +; =========== End of "mem2dev" and "dev2mem" config parameters. ============== + [case1] type=DMA_MEM_COPY mem_size=10
@@ -52,6 +69,22 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=dev2mem +vchan_dev=raddr=0x200000000,coreid=1,pfid=2,vfid=3 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +77 -0
110 lines not on this page · raw message
app/test-dma-perf/main.h +7 -0
@@ -38,10 +38,16 @@ struct lcore_dma_map_t {uint16_t cnt; }; +struct test_vchan_dev_config { +struct rte_dma_port_param port; +uintptr_t raddr; +}; +struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
@@ -57,6 +63,7 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +struct test_vchan_dev_config vchan_dev; };void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
Signature · 1 line
2.34.1
PATCH v9 3/4 app/dma-perf: validate copied memory
In reply to Amit Prakash ShuklaFrom: Gowrishankar Muthukrishnan <[email protected]>
Validate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-)
app/test-dma-perf/benchmark.c +20 -1
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -407,6 +408,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 );
@@ -443,7 +449,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint32_t i;
@@ -461,6 +467,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -534,6 +541,16 @@ 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -599,4 +616,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -101,20 +101,24 @@ open_output_csv(const char *rst_path_ptr)return 0 ; } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -159,8 +163,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -66,6 +66,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.34.1
PATCH v9 4/4 app/dma-perf: add SG copy support
In reply to Amit Prakash ShuklaFrom: Gowrishankar Muthukrishnan <[email protected]>
Add SG copy support.
---
v9:
- SG config variables renamed.
app/test-dma-perf/benchmark.c | 278 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 25 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 300 insertions(+), 42 deletions(-)
app/test-dma-perf/benchmark.c +242 -36
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }
@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -347,8 +428,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int cur_buf_size = cfg->buf_size.cur;
@@ -409,8 +491,8 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, }for (i =0 ; i < nr_buf; i++) { - memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); - memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), cur_buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, cur_buf_size); } if (cfg->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM ||
@@ -446,20 +528,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = cur_buf_size / src_ptrs; + sglen_dst = cur_buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (cur_buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (cur_buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -467,12 +585,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -486,13 +624,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + } + offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -506,10 +654,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -541,13 +702,53 @@ 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 && cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +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 if (cfg->is_sg && cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +size_t src_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
@@ -558,10 +759,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -604,13 +803,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +24 -1
@@ -38,6 +38,14 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for SG copy: +; ======================================== +; "dma_src_sge" denotes number of source segments. +; "dma_dst_sge" denotes number of destination segments. +; +; For SG copy, both the parameters need to be configured and they are valid only +; when type is DMA_MEM_COPY. +; ; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": ; ================================================================================== ; "direction" denotes the direction of data transfer. It can take 3 values:
@@ -69,6 +77,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_src_sge=4 +dma_dst_sge=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=dev2mem
@@ -84,7 +107,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +30 -4
@@ -108,10 +108,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -365,7 +363,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;struct rte_kvargs *kvlist;const char *vchan_dev;
@@ -467,6 +466,7 @@ load_configs(const char *path)rte_kvargs_free (kvlist); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -501,6 +501,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_src_sge" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_src_sge" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_dst_sge" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_dst_sge" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_src_sge, dma_dst_sge error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -53,11 +53,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -66,6 +69,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.34.1
v10 cover PCI Dev and SG copy support
In reply to Amit Prakash ShuklaImprove dma-perf application to support PCI dev and SG copy, along with additional supports as below:
- validate copied memory
- skip tests if not opted.
v10:
- Review suggestions.
- v9 sent again.
Amit Prakash Shukla (2):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
Gowrishankar Muthukrishnan (2):
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 392 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 58 +++++ app/test-dma-perf/main.c | 171 ++++++++++++--- app/test-dma-perf/main.h | 13 +- 4 files changed, 570 insertions(+), 64 deletions(-)
Signature · 1 line
2.34.1
PATCH v10 1/4 app/dma-perf: add skip support
Add support to skip running a dma-perf test-case.
--- app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 48 ++++++++++++++++++++++-------------- app/test-dma-perf/main.h | 1 + 3 files changed, 32 insertions(+), 19 deletions(-)
app/test-dma-perf/config.ini +2 -0
@@ -36,6 +36,8 @@ ; If you do not specify a result file, one will be generated with the same name as the configuration ; file, with the addition of "_result.csv" at the end. +; "skip" To skip a test-case set skip to 1. + [case1] type=DMA_MEM_COPY mem_size=10
app/test-dma-perf/main.c +29 -19
78 lines not on this page · raw message
app/test-dma-perf/main.h +1 -0
@@ -40,6 +40,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
Signature · 1 line
2.34.1
PATCH v10 2/4 app/dma-perf: add PCI device support
In reply to Amit Prakash ShuklaAdd support to test performance for "device to memory" and "memory to device" data transfer.
---
v10:
- PCI config parsing using kvargs.
app/test-dma-perf/benchmark.c | 117 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 33 ++++++++++ app/test-dma-perf/main.c | 77 ++++++++++++++++++++++ app/test-dma-perf/main.h | 7 ++ 4 files changed, 222 insertions(+), 12 deletions(-)
app/test-dma-perf/benchmark.c +105 -12
@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->vchan_dev.port.pcie.coreid; + qconf->dst_port.pcie.vfid = cfg->vchan_dev.port.pcie.vfid; + qconf->dst_port.pcie.pfid = cfg->vchan_dev.port.pcie.pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->vchan_dev.port.pcie.coreid; + qconf->src_port.pcie.vfid = cfg->vchan_dev.port.pcie.vfid; + qconf->src_port.pcie.pfid = cfg->vchan_dev.port.pcie.pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );
@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;
@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }
@@ -302,13 +338,23 @@ do_cpu_mem_copy(void *p)return 0 ; } +static void +dummy_free_ext_buf (void *addr,void *opaque) +{ +RTE_SET_USED (addr); +RTE_SET_USED (opaque); +} +static int setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs,struct rte_mbuf ***dsts) { -unsigned int buf_size = cfg->buf_size.cur; +static struct rte_mbuf_ext_shared_info *ext_buf_info; +unsigned int cur_buf_size = cfg->buf_size.cur; +unsigned int buf_size = cur_buf_size +RTE_PKTMBUF_HEADROOM ;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -321,7 +367,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, nr_buf,0 ,0 , - buf_size +RTE_PKTMBUF_HEADROOM , + buf_size, cfg->src_numa_node);if (src_pool ==NULL ) {PRINT_ERR ("Error with source mempool creation.\n" );
@@ -332,7 +378,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, nr_buf,0 ,0 , - buf_size +RTE_PKTMBUF_HEADROOM , + buf_size, cfg->dst_numa_node);if (dst_pool ==NULL ) {PRINT_ERR ("Error with destination mempool creation.\n" );
@@ -361,16 +407,49 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || + cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 ); +if (ext_buf_info ==NULL ) { +printf ("Error: ext_buf_info malloc failed.\n" ); +return -1 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*srcs)[i], (void *)(cfg->vchan_dev.raddr + + (i * buf_size)), (rte_iova_t)(cfg->vchan_dev.raddr + + (i * buf_size)),0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*dsts)[i], (void *)(cfg->vchan_dev.raddr + + (i * buf_size)), (rte_iova_t)(cfg->vchan_dev.raddr + + (i * buf_size)),0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } +return 0 ; }void mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ; -struct rte_mbuf **srcs =NULL , **dsts =NULL ; +struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur;
@@ -476,6 +555,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) avg_cycles_total / nb_workers, bandwidth_total, mops_total); out: + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) + m = srcs; +else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) + m = dsts; + +if (m) { +for (i =0 ; i < nr_buf; i++) +rte_pktmbuf_detach_extbuf (m[i]); + +if (m[0 ]->shinfo &&rte_mbuf_ext_refcnt_read (m[0 ]->shinfo) ==0 ) +rte_free (m[0 ]->shinfo); + } +/* free mbufs used in the test */ if (srcs !=NULL )rte_pktmbuf_free_bulk (srcs, nr_buf);
app/test-dma-perf/config.ini +33 -0
@@ -38,6 +38,23 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": +; ================================================================================== +; "direction" denotes the direction of data transfer. It can take 3 values: +; mem2mem - mem to mem transfer +; mem2dev - mem to dev transfer +; dev2mem - dev to mem transfer +; If not specified the default value is mem2mem transfer. + +; "vchan_dev comma separated bus related config parameter for mem2dev and dev2mem dma transfer. Ex:" +; vchan_dev=raddr=0x400000,coreid=1,pfid=2,vfid=3 +; "raddr" remote iova address for mem2dev and dev2mem transfer. +; "coreid" denotes PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer. + +; =========== End of "mem2dev" and "dev2mem" config parameters. ============== + [case1] type=DMA_MEM_COPY mem_size=10
@@ -52,6 +69,22 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=dev2mem +vchan_dev=raddr=0x200000000,coreid=1,pfid=2,vfid=3 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +77 -0
110 lines not on this page · raw message
app/test-dma-perf/main.h +7 -0
@@ -38,10 +38,16 @@ struct lcore_dma_map_t {uint16_t cnt; }; +struct test_vchan_dev_config { +struct rte_dma_port_param port; +uintptr_t raddr; +}; +struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
@@ -57,6 +63,7 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +struct test_vchan_dev_config vchan_dev; };void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
Signature · 1 line
2.34.1
PATCH v10 3/4 app/dma-perf: validate copied memory
In reply to Amit Prakash ShuklaFrom: Gowrishankar Muthukrishnan <[email protected]>
Validate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-)
app/test-dma-perf/benchmark.c +20 -1
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -407,6 +408,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 );
@@ -443,7 +449,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint32_t i;
@@ -461,6 +467,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -534,6 +541,16 @@ 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; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -599,4 +616,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -101,20 +101,24 @@ open_output_csv(const char *rst_path_ptr)return 0 ; } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -159,8 +163,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -66,6 +66,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.34.1
Re: [PATCH v10 3/4] app/dma-perf: validate copied memory
Hi Gowrishankar,
Quoted 55 lines · Amit Prakash Shukla
From: Gowrishankar Muthukrishnan <[email protected]>
Validate copied memory to ensure DMA copy did not fail.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>Acked-by Anoob Joseph <[email protected]>Acked-by Chengwen Feng <[email protected]>--- app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-)app/test-dma-perf/benchmark.c +8
-1@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h" @@ -407,6 +408,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 );@@ -443,7 +449,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint32_t i;@@ -461,6 +467,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 548
Quoted 8 lines
app/test-dma-perf/benchmark.c +5
-0@@ -534,6 +541,16 @@ 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);
For non-mem2mem DMA, like mem2dev or dev2mem, the device host address may not direct accessable by CPU (if could may need mmap).
So pls restrict it only mem2mem, or drop this commit.
Thanks
Quoted 73 lines
app/test-dma-perf/benchmark.c +7
-0+ ret =-1 ; + goto out; + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;@@ -599,4 +616,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }app/test-dma-perf/main.c +11
-5@@ -101,20 +101,24 @@ open_output_csv(const char *rst_path_ptr)return 0 ; } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void@@ -159,8 +163,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;app/test-dma-perf/main.h +1
-1@@ -66,6 +66,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
RE: [EXT] Re: [PATCH v10 3/4] app/dma-perf: validate copied memory
Hi Fengchengwen,
Quoted 10 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +5
-0+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);
For non-mem2mem DMA, like mem2dev or dev2mem, the device host address may not direct accessable by CPU (if could may need mmap).
This has been checked in 4/4 patch as (cfg->transfer_dir == RTE_DMA_DIR_MEM_TO_MEM). Would you still need it in this patch only ?.
Thanks,
Gowrishankar
Quoted 3 lines
So pls restrict it only mem2mem, or drop this commit.
Thanks
v11 cover PCI Dev and SG copy support
In reply to Amit Prakash ShuklaImprove dma-perf application to support PCI dev and SG copy, along with additional supports as below:
- validate copied memory
- skip tests if not opted.
v11:
- Review suggestions.
Gowrishankar Muthukrishnan (4):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
app/test-dma-perf/benchmark.c | 413 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 56 +++++ app/test-dma-perf/main.c | 178 ++++++++++++--- app/test-dma-perf/main.h | 13 +- 4 files changed, 595 insertions(+), 65 deletions(-)
Signature · 1 line
2.25.1
PATCH v11 1/4 app/dma-perf: add skip support
Add support to skip running a dma-perf test-case.
---
v11:
- config file formatting
app/test-dma-perf/config.ini | 2 ++ app/test-dma-perf/main.c | 48 ++++++++++++++++++++++-------------- app/test-dma-perf/main.h | 1 + 3 files changed, 32 insertions(+), 19 deletions(-)
app/test-dma-perf/config.ini +2 -0
@@ -30,6 +30,8 @@ ; If you have already set the "-l" and "-a" parameters using EAL, ; make sure that the value of "lcore" falls within their range of values. +; "skip" To skip a test-case set skip to 1. + ; To specify a configuration file, use the "--config" flag followed by the path to the file. ; To specify a result file, use the "--result" flag followed by the path to the file.
app/test-dma-perf/main.c +29 -19
78 lines not on this page · raw message
app/test-dma-perf/main.h +1 -0
@@ -40,6 +40,7 @@ struct lcore_dma_map_t {struct test_configure {bool is_valid; +bool is_skip;uint8_t test_type;const char *test_type_str;uint16_t src_numa_node;
Signature · 1 line
2.25.1
PATCH v11 2/4 app/dma-perf: add PCI device support
In reply to Gowrishankar MuthukrishnanAdd support to test performance for "device to memory" and "memory to device" data transfer.
---
v11:
- config file formatting.
app/test-dma-perf/benchmark.c | 119 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 31 +++++++++ app/test-dma-perf/main.c | 77 ++++++++++++++++++++++ app/test-dma-perf/main.h | 7 ++ 4 files changed, 222 insertions(+), 12 deletions(-)
app/test-dma-perf/benchmark.c +107 -12
@@ -127,17 +127,54 @@ cache_flush_buf(__rte_unused struct rte_mbuf **array,#endif } +static int +vchan_data_populate (uint32_t dev_id,struct rte_dma_vchan_conf *qconf, +struct test_configure *cfg) +{ +struct rte_dma_info info; + + qconf->direction = cfg->transfer_dir; + +rte_dma_info_get (dev_id, &info); +if (!(RTE_BIT64 (qconf->direction) & info.dev_capa)) +return -1 ; + + qconf->nb_desc = cfg->ring_size.cur; + +switch (qconf->direction) { +case RTE_DMA_DIR_MEM_TO_DEV : + qconf->dst_port.pcie.vfen =1 ; + qconf->dst_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->dst_port.pcie.coreid = cfg->vchan_dev.port.pcie.coreid; + qconf->dst_port.pcie.vfid = cfg->vchan_dev.port.pcie.vfid; + qconf->dst_port.pcie.pfid = cfg->vchan_dev.port.pcie.pfid; +break ; +case RTE_DMA_DIR_DEV_TO_MEM : + qconf->src_port.pcie.vfen =1 ; + qconf->src_port.port_type =RTE_DMA_PORT_PCIE ; + qconf->src_port.pcie.coreid = cfg->vchan_dev.port.pcie.coreid; + qconf->src_port.pcie.vfid = cfg->vchan_dev.port.pcie.vfid; + qconf->src_port.pcie.pfid = cfg->vchan_dev.port.pcie.pfid; +break ; +case RTE_DMA_DIR_MEM_TO_MEM : +case RTE_DMA_DIR_DEV_TO_DEV : +break ; + } + +return 0 ; +} +/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,uint32_t ring_size) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) {uint16_t vchan =0 ;struct rte_dma_info info;struct rte_dma_conf dev_config = { .nb_vchans =1 }; -struct rte_dma_vchan_conf qconf = { - .direction =RTE_DMA_DIR_MEM_TO_MEM , - .nb_desc = ring_size - }; +struct rte_dma_vchan_conf qconf = {0 }; + +if (vchan_data_populate (dev_id, &qconf, cfg) !=0 ) +rte_exit (EXIT_FAILURE ,"Error with vchan data populate.\n" );if (rte_dma_configure (dev_id, &dev_config) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma configure.\n" );
@@ -159,7 +196,6 @@ configure_dmadev_queue(uint32_t dev_id, uint32_t ring_size)static int config_dmadevs (struct test_configure *cfg) { -uint32_t ring_size = cfg->ring_size.cur;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;uint32_t nb_workers = ldm->cnt;uint32_t i;
@@ -176,7 +212,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, ring_size); +configure_dmadev_queue (dev_id, cfg); ++nb_dmadevs; }
@@ -302,13 +338,23 @@ do_cpu_mem_copy(void *p)return 0 ; } +static void +dummy_free_ext_buf (void *addr,void *opaque) +{ +RTE_SET_USED (addr); +RTE_SET_USED (opaque); +} +static int setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs,struct rte_mbuf ***dsts) { -unsigned int buf_size = cfg->buf_size.cur; +static struct rte_mbuf_ext_shared_info *ext_buf_info; +unsigned int cur_buf_size = cfg->buf_size.cur; +unsigned int buf_size = cur_buf_size +RTE_PKTMBUF_HEADROOM ;unsigned int nr_sockets;uint32_t nr_buf = cfg->nr_buf; +uint32_t i; nr_sockets =rte_socket_count (); if (cfg->src_numa_node >= nr_sockets ||
@@ -321,7 +367,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, nr_buf,0 ,0 , - buf_size +RTE_PKTMBUF_HEADROOM , + buf_size, cfg->src_numa_node);if (src_pool ==NULL ) {PRINT_ERR ("Error with source mempool creation.\n" );
@@ -332,7 +378,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, nr_buf,0 ,0 , - buf_size +RTE_PKTMBUF_HEADROOM , + buf_size, cfg->dst_numa_node);if (dst_pool ==NULL ) {PRINT_ERR ("Error with destination mempool creation.\n" );
@@ -361,16 +407,51 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || + cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 ); +if (ext_buf_info ==NULL ) { +printf ("Error: ext_buf_info malloc failed.\n" ); +return -1 ; + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*srcs)[i], + (void *)(cfg->vchan_dev.raddr + (i * buf_size)), + (rte_iova_t)(cfg->vchan_dev.raddr + (i * buf_size)), +0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } + +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { + ext_buf_info->free_cb = dummy_free_ext_buf; + ext_buf_info->fcb_opaque =NULL ; +for (i =0 ; i < nr_buf; i++) { +/* Using mbuf structure to hold remote iova address. */ +rte_pktmbuf_attach_extbuf ((*dsts)[i], + (void *)(cfg->vchan_dev.raddr + (i * buf_size)), + (rte_iova_t)(cfg->vchan_dev.raddr + (i * buf_size)), +0 , ext_buf_info); +rte_mbuf_ext_refcnt_update (ext_buf_info,1 ); + } + } +return 0 ; }void mem_copy_benchmark (struct test_configure *cfg,bool is_dma) { -uint16_t i; +uint32_t i;uint32_t offset;unsigned int lcore_id =0 ; -struct rte_mbuf **srcs =NULL , **dsts =NULL ; +struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur;
@@ -476,6 +557,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) avg_cycles_total / nb_workers, bandwidth_total, mops_total); out: + +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM ) + m = srcs; +else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) + m = dsts; + +if (m) { +for (i =0 ; i < nr_buf; i++) +rte_pktmbuf_detach_extbuf (m[i]); + +if (m[0 ]->shinfo &&rte_mbuf_ext_refcnt_read (m[0 ]->shinfo) ==0 ) +rte_free (m[0 ]->shinfo); + } +/* free mbufs used in the test */ if (srcs !=NULL )rte_pktmbuf_free_bulk (srcs, nr_buf);
app/test-dma-perf/config.ini +31 -0
@@ -32,6 +32,21 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters for data transfers from "mem to dev" and "dev to mem": +; +; "direction" denotes the direction of data transfer. It can take 3 values: +; mem2mem - mem to mem transfer +; mem2dev - mem to dev transfer +; dev2mem - dev to mem transfer +; If not specified the default value is mem2mem transfer. + +; "vchan_dev" denotes below comma separated bus related parameters for mem2dev and dev2mem dma transfer. +; "raddr" remote iova address for mem2dev and dev2mem transfer. +; "coreid" denotes PCIe core index. +; "pfid" denotes PF-id to be used for data transfer +; "vfid" denotes VF-id of PF-id to be used for data transfer. +; Example: vchan_dev=raddr=0x400000,coreid=1,pfid=2,vfid=3 + ; To specify a configuration file, use the "--config" flag followed by the path to the file. ; To specify a result file, use the "--result" flag followed by the path to the file.
@@ -52,6 +67,22 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +skip=1 +type=DMA_MEM_COPY +direction=dev2mem +vchan_dev=raddr=0x200000000,coreid=1,pfid=2,vfid=3 +mem_size=10 +buf_size=64,4096,2,MUL +dma_ring_size=1024 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +77 -0
110 lines not on this page · raw message
app/test-dma-perf/main.h +7 -0
@@ -38,10 +38,16 @@ struct lcore_dma_map_t {uint16_t cnt; }; +struct test_vchan_dev_config { +struct rte_dma_port_param port; +uintptr_t raddr; +}; +struct test_configure {bool is_valid;bool is_skip;uint8_t test_type; +uint8_t transfer_dir;const char *test_type_str;uint16_t src_numa_node;uint16_t dst_numa_node;
@@ -57,6 +63,7 @@ struct test_configure {uint16_t test_secs;const char *eal_args;uint8_t scenario_id; +struct test_vchan_dev_config vchan_dev; };void mem_copy_benchmark (struct test_configure *cfg,bool is_dma);
Signature · 1 line
2.25.1
PATCH v11 3/4 app/dma-perf: validate copied memory
In reply to Gowrishankar MuthukrishnanValidate copied memory to ensure DMA copy did not fail.
--- app/test-dma-perf/benchmark.c | 23 ++++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 34 insertions(+), 7 deletions(-)
app/test-dma-perf/benchmark.c +22 -1
@@ -12,6 +12,7 @@#include <rte_dmadev.h> #include <rte_malloc.h> #include <rte_lcore.h> +#include <rte_random.h> #include "main.h"
@@ -407,6 +408,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return -1 ; } +for (i =0 ; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } +if (cfg->transfer_dir ==RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_DEV ) { ext_buf_info =rte_malloc (NULL ,sizeof (struct rte_mbuf_ext_shared_info ),0 );
@@ -445,7 +451,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,return 0 ; } -void +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma) {uint32_t i;
@@ -463,6 +469,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +int ret =0 ;if (setup_memory_env (cfg, &srcs, &dsts) <0 ) goto out;
@@ -536,6 +543,18 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_eal_mp_wait_lcore (); +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +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; + } + } + } + mops_total =0 ; bandwidth_total =0 ; avg_cycles_total =0 ;
@@ -601,4 +620,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_dma_stop (ldm->dma_ids[i]); } } + +return ret; }
app/test-dma-perf/main.c +11 -5
@@ -101,20 +101,24 @@ open_output_csv(const char *rst_path_ptr)return 0 ; } -static void +static int run_test_case (struct test_configure *case_cfg) { +int ret =0 ; +switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : -mem_copy_benchmark (case_cfg, true); + ret =mem_copy_benchmark (case_cfg, true);break ;case TEST_TYPE_CPU_MEM_COPY : -mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg, false);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);break ; } + +return ret; } static void
@@ -159,8 +163,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++;printf ("\nRunning scenario %d\n" , case_cfg->scenario_id); -run_test_case (case_cfg); -output_csv (false); +if (run_test_case (case_cfg) <0 ) +printf ("\nTest fails! skipping this scenario.\n" ); +else +output_csv (false);if (var_entry->op ==OP_ADD ) var_entry->cur += var_entry->incr;
app/test-dma-perf/main.h +1 -1
@@ -66,6 +66,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -void mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg,bool is_dma);#endif /* MAIN_H */
Signature · 1 line
2.25.1
PATCH v11 4/4 app/dma-perf: add SG copy support
In reply to Gowrishankar MuthukrishnanAdd SG copy support.
---
v11:
- using struct for SGE config.
app/test-dma-perf/benchmark.c | 283 ++++++++++++++++++++++++++++++---- app/test-dma-perf/config.ini | 25 ++- app/test-dma-perf/main.c | 41 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 317 insertions(+), 37 deletions(-)
app/test-dma-perf/benchmark.c +252 -31
@@ -34,6 +34,13 @@ struct worker_info {uint32_t test_cpl; }; +struct sge_info { +struct rte_dma_sge *srcs; +struct rte_dma_sge *dsts; +uint8_t nb_srcs; +uint8_t nb_dsts; +}; +struct lcore_params {uint8_t scenario_id;unsigned int lcore_id;
@@ -46,6 +53,7 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct sge_info sge;volatile struct worker_info worker_info; };
@@ -86,21 +94,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src sges: %u, dst sges: %u" , + para->sge.nb_srcs, para->sge.nb_dsts); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -167,7 +185,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t sges_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -190,6 +208,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < sges_max) +rte_exit (EXIT_FAILURE ,"Error with unsupported max_sges on device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -202,8 +224,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t nb_sges =0 ;char *dma_name; +if (cfg->is_sg) + nb_sges =RTE_MAX (cfg->nb_src_sges, cfg->nb_dst_sges); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -213,7 +239,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, nb_sges); ++nb_dmadevs; }
@@ -253,7 +279,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -306,6 +332,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->sge.srcs; +struct rte_dma_sge *dst_sges = para->sge.dsts; +const uint8_t nb_src_sges = para->sge.nb_srcs; +const uint8_t nb_dst_sges = para->sge.nb_dsts; +const uint16_t kick_batch = para->kick_batch; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (nb_src_sges, nb_dst_sges); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * nb_src_sges], &dst_sges[j * nb_dst_sges], + nb_src_sges, nb_dst_sges,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -347,8 +432,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int cur_buf_size = cfg->buf_size.cur;
@@ -409,8 +495,8 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, }for (i =0 ; i < nr_buf; i++) { - memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); - memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), cur_buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, cur_buf_size); } if (cfg->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM ||
@@ -448,20 +534,102 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t nb_src_sges = cfg->nb_src_sges; +uint8_t nb_dst_sges = cfg->nb_dst_sges; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = cur_buf_size / nb_src_sges; + sglen_dst = cur_buf_size / nb_dst_sges; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % nb_src_sges)) + (*src_sges)[i].length += (cur_buf_size % nb_src_sges); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % nb_dst_sges)) + (*dst_sges)[i].length += (cur_buf_size % nb_dst_sges); + } + } +return 0 ; } +static uint32_t +align_buffer_count (struct test_configure *cfg,uint32_t *nr_sgsrc,uint32_t *nr_sgdst) +{ +struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +uint16_t nb_workers = ldm->cnt; +uint32_t nr_buf; + + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); + +if (nr_sgsrc ==NULL || nr_sgdst ==NULL ) +return nr_buf; + +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->nb_src_sges * cfg->nb_dst_sges); + nr_buf *= nb_workers; + +if (cfg->nb_dst_sges > cfg->nb_src_sges) { + *nr_sgsrc = (nr_buf / cfg->nb_dst_sges * cfg->nb_src_sges); + *nr_sgdst = nr_buf; + }else { + *nr_sgsrc = nr_buf; + *nr_sgdst = (nr_buf / cfg->nb_src_sges * cfg->nb_dst_sges); + } + } + +return nr_buf; +} + +static lcore_function_t * +get_work_function (struct test_configure *cfg) +{ +lcore_function_t *fn; + +if (cfg->is_dma) { +if (!cfg->is_sg) + fn = do_dma_plain_mem_copy; +else + fn = do_dma_sg_mem_copy; + }else { + fn = do_cpu_mem_copy; + } + +return fn; +} +int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map;unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -469,12 +637,17 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) + nr_buf =align_buffer_count (cfg, &nr_sgsrc, &nr_sgdst); + cfg->nr_buf = nr_buf; + +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -494,7 +667,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -508,10 +681,15 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else -rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); +if (cfg->is_sg) { + lcores[i]->sge.nb_srcs = cfg->nb_src_sges; + lcores[i]->sge.nb_dsts = cfg->nb_dst_sges; + lcores[i]->sge.srcs = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->sge.dsts = dst_sges + (nr_sgdst / nb_workers * i); + } + +rte_eal_remote_launch (get_work_function (cfg), (void *)(lcores[i]), + lcore_id); }while (1 ) {
@@ -543,7 +721,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_eal_mp_wait_lcore (); -if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM && !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 *),
@@ -553,6 +731,44 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) goto out; } } + }else if (cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM && cfg->is_sg) { +size_t src_remsz = buf_size % cfg->nb_src_sges; +size_t dst_remsz = buf_size % cfg->nb_dst_sges; +size_t src_sz = buf_size / cfg->nb_src_sges; +size_t dst_sz = buf_size / cfg->nb_dst_sges; +uint8_t src[buf_size], dst[buf_size]; +uint8_t *sbuf, *dbuf, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->nb_src_sges, cfg->nb_dst_sges)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->nb_src_sges; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->nb_src_sges + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->nb_dst_sges; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->nb_dst_sges + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->nb_src_sges); + ret =-1 ; + goto out; + } + } } mops_total =0 ;
@@ -562,10 +778,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -608,13 +822,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +24 -1
@@ -47,6 +47,14 @@ ; "vfid" denotes VF-id of PF-id to be used for data transfer. ; Example: vchan_dev=raddr=0x400000,coreid=1,pfid=2,vfid=3 +; Parameters for DMA scatter-gather memory copy: +; +; "dma_src_sge" denotes number of source segments. +; "dma_dst_sge" denotes number of destination segments. +; +; For DMA scatter-gather memory copy, the parameters need to be configured +; and they are valid only when type is DMA_MEM_COPY. + ; To specify a configuration file, use the "--config" flag followed by the path to the file. ; To specify a result file, use the "--result" flag followed by the path to the file.
@@ -67,6 +75,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_src_sge=4 +dma_dst_sge=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=dev2mem
@@ -82,7 +105,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +37 -4
66 lines not on this page · raw message
app/test-dma-perf/main.h +4 -1
@@ -53,11 +53,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t nb_src_sges; +uint8_t nb_dst_sges;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -66,6 +69,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.25.1
Re: [v11 0/4] PCI Dev and SG copy support
In reply to Gowrishankar Muthukrishnan29/02/2024 14:48, Gowrishankar Muthukrishnan:
Quoted 5 lines
Improve dma-perf application to support PCI dev and SG copy, along with additional supports as below:
- validate copied memory
- skip tests if not opted.
Quoted 8 lines
v11:
- Review suggestions.Gowrishankar Muthukrishnan (4):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
app/dma-perf: validate copied memory
app/dma-perf: add SG copy support
Waiting for a confirmation that this series is good to go.
Recheck-request: iol-unit-amd64-testing
Re: [v11 0/4] PCI Dev and SG copy support
Hi Thomas and Gowrishankar,
Quoted 9 lines · Thomas Monjalon
29/02/2024 14:48, Gowrishankar Muthukrishnan:
Quoted 8 lines
Improve dma-perf application to support PCI dev and SG copy, along with additional supports as below:
- validate copied memory
- skip tests if not opted.v11:
- Review suggestions.
Quoted 7 lines
Quoted 5 lines
Gowrishankar Muthukrishnan (4):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
app/dma-perf: validate copied memory
app/dma-perf: add SG copy supportWaiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by modify config.ini file.
[1] [PATCH v2] app/dma-perf: support bi-directional transfer
Thanks
Quoted 6 lines
Recheck-request: iol-unit-amd64-testing
.
RE: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
Hi Fengchengwen,
Quoted 5 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by modify config.ini file.
This patch set already exposes all configuration via config.ini. I didn't follow what is missing. For bi-direction, we can better continue discussing on that patch.
Thanks,
Gowrishankar
Quoted 10 lines
[1] [PATCH v2] app/dma-perf: support bi-directional transfer
Thanks
Quoted 6 lines
Recheck-request: iol-unit-amd64-testing
.
Re: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 9 lines
Hi Fengchengwen,
Quoted 5 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by modify config.ini file.
This patch set already exposes all configuration via config.ini. I didn't follow what is missing. For bi-direction, we can better continue discussing on that patch.
Chengwen, please can you confirm whether you require a new version? Which change exactly is missing?
Re: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
Hi Thomas,
Quoted 5 lines · Thomas Monjalon
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 4 lines
Hi Fengchengwen,
Quoted 2 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by modify config.ini file.
This patch set already exposes all configuration via config.ini. I didn't follow what is missing. For bi-direction, we can better continue discussing on that patch.
Chengwen, please can you confirm whether you require a new version? Which change exactly is missing?
This patchset is OK with one sub-test only tackle one DMA direction.
But there is a later patch [1] which will support multiple DMA directions within one sub-test. it will add a entry "xfer_mode", but I think it complicate the test, I prefer we do more in this patchset to support some like bi-direction just by modify config.ini, some like this:
1. extend lcore_dma:
current lcore_dma is: lcore10@0000:00:04.2
extend it support: lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0xXXXX
2. to fix one entry can't hold too many dma device, support entrys: lcore_dma_1, lcore_dma_2 which value is same with lcore_dma.
So for bi-direction, we just define config.ini as:
lcore_dma=lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0xXXXX, lcore10@0000:00:04.2,dir=d2m,coreid=1,pfid=2,vfid=3,raddr=0xXXXX
[1] https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Quoted 1 line
RE: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
Hi Fengchengwen
Quoted 14 lines
Hi Thomas,
Quoted 7 lines · Thomas Monjalon
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 6 lines
Hi Fengchengwen,
Quoted 4 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by
modify config.ini file.
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 9 lines
Quoted 1 line
Quoted 1 line
This patch set already exposes all configuration via config.ini. I didn't follow
what is missing. For bi-direction, we can better continue discussing on that patch.
Quoted 3 lines
Chengwen, please can you confirm whether you require a new version? Which change exactly is missing?
This patchset is OK with one sub-test only tackle one DMA direction.
Thanks for the confirmation.
Quoted 6 lines
But there is a later patch [1] which will support multiple DMA directions within one sub-test.
it will add a entry "xfer_mode", but I think it complicate the test, I prefer we do more in this patchset to support some like bi-direction just by modify config.ini, some like this:
I think we should discuss about that in bi-directional patch series. This series is self-contained and there is no need to add bi-directional as part of this series. As far as this patch set is concerned, all the options are exposed via config.ini. Can you comment if there is anything missing, assuming that we are taking bi-directional support as a separate feature addition.
Thanks,
Gowrishankar
Quoted 22 lines
1. extend
lcore_dma:
currentlcore_dmais: lcore10@0000:00:04.2
extend it support:
lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0xXXXX
2. to fix one entry can't hold too many dma device, support entrys:lcore_dma_1,lcore_dma_2
which value is same withlcore_dma.So for bi-direction, we just define config.ini as:
lcore_dma=lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0x XXXX, lcore10@0000:00:04.2,dir=d2m,coreid=1,pfid=2,vfid=3,raddr=0xXXXX[1] https://urldefense.proofpoint.com/v2/url?u=https-
3A__patches.dpdk.org_project_dpdk_patch_20240229141426.4188428- 2D1-2Damitprakashs- 40marvell.com_&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=EAtr- g7yUFhtOio8r2Rtm13Aqe4WVp_S_gHpcu6KFVo&m=DUaL_AJR1zqM0T2yw3 aV44EObB90uqw5weFzSm- w39citSeGozNdEe4kzicss_KG&s=UTAcoZx5DjSJHyzxyLMxXz1bPqfPXQM7feDx ZdC6Jgk&e=Quoted 1 line
Re: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
Hi Gowrishankar,
Quoted 27 lines · Gowrishankar Muthukrishnan
Hi Fengchengwen
Quoted 14 lines
Hi Thomas,
Quoted 7 lines · Thomas Monjalon
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 6 lines
Hi Fengchengwen,
Quoted 4 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by
modify config.ini file.
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 9 lines
Quoted 1 line
Quoted 1 line
This patch set already exposes all configuration via config.ini. I didn't follow
what is missing. For bi-direction, we can better continue discussing on that patch.
Quoted 3 lines
Chengwen, please can you confirm whether you require a new version? Which change exactly is missing?
This patchset is OK with one sub-test only tackle one DMA direction.
Thanks for the confirmation.
Quoted 7 lines
Quoted 6 lines
But there is a later patch [1] which will support multiple DMA directions within one sub-test.
it will add a entry "xfer_mode", but I think it complicate the test, I prefer we do more in this patchset to support some like bi-direction just by modify config.ini, some like this:I think we should discuss about that in bi-directional patch series. This series is self-contained and there is no need to add bi-directional as part of this series. As far as this patch set is concerned, all the options are exposed via config.ini. Can you comment if there is anything missing, assuming that we are taking bi-directional support as a separate feature addition.
I have identified some improvements to the dma-perf app, and I plan to do it in 24.07, so if you don't mind, I will incorporate your commits (keeping your signed-off-by) and modify to the one that I described above, and then send to community (also with my improvements commits).
Thanks
Quoted 26 lines
Thanks,
GowrishankarQuoted 22 lines
1. extend
lcore_dma:
currentlcore_dmais: lcore10@0000:00:04.2
extend it support:
lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0xXXXX
2. to fix one entry can't hold too many dma device, support entrys:lcore_dma_1,lcore_dma_2
which value is same withlcore_dma.So for bi-direction, we just define config.ini as:
lcore_dma=lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0x XXXX, lcore10@0000:00:04.2,dir=d2m,coreid=1,pfid=2,vfid=3,raddr=0xXXXX[1] https://urldefense.proofpoint.com/v2/url?u=https-
3A__patches.dpdk.org_project_dpdk_patch_20240229141426.4188428- 2D1-2Damitprakashs- 40marvell.com_&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=EAtr- g7yUFhtOio8r2Rtm13Aqe4WVp_S_gHpcu6KFVo&m=DUaL_AJR1zqM0T2yw3 aV44EObB90uqw5weFzSm- w39citSeGozNdEe4kzicss_KG&s=UTAcoZx5DjSJHyzxyLMxXz1bPqfPXQM7feDx ZdC6Jgk&e=Quoted 1 line
RE: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
Hi Fengchengwen
Quoted 38 lines
Hi Gowrishankar,
Quoted 35 lines · Gowrishankar Muthukrishnan
Hi Fengchengwen
Quoted 17 lines
Hi Thomas,
Quoted 8 lines · Thomas Monjalon
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 7 lines
Hi Fengchengwen,
Quoted 5 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by
modify config.ini file.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
This patch set already exposes all configuration via config.ini. I didn't follow
Quoted 8 lines
what is missing. For bi-direction, we can better continue discussing on that patch.
Quoted 3 lines
Chengwen, please can you confirm whether you require a new version? Which change exactly is missing?
This patchset is OK with one sub-test only tackle one DMA direction.
Thanks for the confirmation.
Quoted 6 lines
But there is a later patch [1] which will support multiple DMA directions within one sub-test.
it will add a entry "xfer_mode", but I think it complicate the test, I prefer we do more in this patchset to support some like bi-direction just by modify config.ini, some like this:
Quoted 7 lines
Quoted 1 line
I think we should discuss about that in bi-directional patch series. This series
is self-contained and there is no need to add bi-directional as part of this series. As far as this patch set is concerned, all the options are exposed via config.ini. Can you comment if there is anything missing, assuming that we are taking bi-directional support as a separate feature addition.
I have identified some improvements to the dma-perf app, and I plan to do it
It is unclear at this point what is the issue that you have with the app or this patch set. This series was first submitted on Aug 10 2023. You had acked v8 on Jan 25 2024. After the patches were acked, there were still review comments on variable renames etc, which were all addressed. The patches had been under review for more than 8 months with very slow progress.
Quoted 3 lines
in 24.07, so if you don't mind, I will incorporate your commits (keeping your signed-off-by) and modify to the one that I described above, and then send to community (also with my improvements commits).
I would like to have this series merged first and not pulled into another series. We do have few other features that we would like to add on top. I would assume that you can also add your changes on top. To make contribution easier, isn't it better to accept at least this patch set (as you acked earlier) and then you can continue working on the improvements?
Thanks,
Gowrishankar
Quoted 33 lines
Thanks
Quoted 14 lines
Thanks,
GowrishankarQuoted 10 lines
1. extend
lcore_dma:
currentlcore_dmais: lcore10@0000:00:04.2
extend it support:
lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0xXXXX
2. to fix one entry can't hold too many dma device, support entrys:lcore_dma_1,lcore_dma_2
which value is same withlcore_dma.So for bi-direction, we just define config.ini as:
lcore_dma=lcore10@0000:00:04.2,dir=m2d,coreid=1,pfid=2,vfid=3,raddr=0
Quoted 8 lines
Quoted 8 lines
x XXXX, lcore10@0000:00:04.2,dir=d2m,coreid=1,pfid=2,vfid=3,raddr=0xXXXX
[1] https://urldefense.proofpoint.com/v2/url?u=https-
3A__patches.dpdk.org_project_dpdk_patch_20240229141426.4188428- 2D1-2Damitprakashs- 40marvell.com_&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=EAtr-g7yUFhtOio8r2Rtm13Aqe4WVp_S_gHpcu6KFVo&m=DUaL_AJR1zqM0T2yw3
Quoted 2 lines
Quoted 2 lines
aV44EObB90uqw5weFzSm-
w39citSeGozNdEe4kzicss_KG&s=UTAcoZx5DjSJHyzxyLMxXz1bPqfPXQM7feDx
Quoted 3 lines
Quoted 3 lines
ZdC6Jgk&e=
Quoted 1 line
RE: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
Hi Thomas,
Quoted 63 lines
Hi Fengchengwen
Quoted 38 lines
Hi Gowrishankar,
Quoted 35 lines · Gowrishankar Muthukrishnan
Hi Fengchengwen
Quoted 17 lines
Hi Thomas,
Quoted 8 lines · Thomas Monjalon
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 7 lines
Hi Fengchengwen,
Quoted 5 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by
modify config.ini file.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
This patch set already exposes all configuration via config.ini. I didn't follow
Quoted 8 lines
what is missing. For bi-direction, we can better continue discussing on that patch.
Quoted 3 lines
Chengwen, please can you confirm whether you require a new version? Which change exactly is missing?
This patchset is OK with one sub-test only tackle one DMA direction.
Thanks for the confirmation.
Quoted 6 lines
But there is a later patch [1] which will support multiple DMA directions within one sub-test.
it will add a entry "xfer_mode", but I think it complicate the test, I prefer we do more in this patchset to support some like bi-direction just by modify config.ini, some like this:Quoted 6 lines
Quoted 2 lines
I think we should discuss about that in bi-directional patch series. This series
is self-contained and there is no need to add bi-directional as part of this series. As far as this patch set is concerned, all the options are exposed via config.ini. Can you comment if there is anything missing, assuming that we are taking bi-directional support as a separate
feature addition.
Quoted 3 lines
I have identified some improvements to the dma-perf app, and I plan to do it
It is unclear at this point what is the issue that you have with the app or this patch set. This series was first submitted on Aug 10 2023. You had acked v8 on Jan 25 2024. After the patches were acked, there were still review comments on variable renames etc, which were all addressed. The patches had been under review for more than 8 months with very slow progress.
Quoted 4 lines
in 24.07, so if you don't mind, I will incorporate your commits (keeping your
signed-off-by) and modify to the one that I described above, and then send to community (also with my improvements commits).
Quoted 6 lines
I would like to have this series merged first and not pulled into another series. We do have few other features that we would like to add on top. I would assume that you can also add your changes on top. To make contribution easier, isn't it better to accept at least this patch set (as you acked earlier) and then you can continue working on the improvements?
Can this series be merged ?
Thanks,
Gowrishankar
Quoted 3 lines
Thanks,
Gowrishankar
Re: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
In reply to Gowrishankar Muthukrishnan13/03/2024 09:22, Gowrishankar Muthukrishnan:
Quoted 48 lines
Hi Fengchengwen
Quoted 38 lines
Hi Gowrishankar,
Quoted 35 lines · Gowrishankar Muthukrishnan
Hi Fengchengwen
Quoted 17 lines
Hi Thomas,
Quoted 8 lines · Thomas Monjalon
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 7 lines
Hi Fengchengwen,
Quoted 5 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by
modify config.ini file.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
This patch set already exposes all configuration via config.ini. I didn't follow
Quoted 8 lines
what is missing. For bi-direction, we can better continue discussing on that patch.
Quoted 3 lines
Chengwen, please can you confirm whether you require a new version? Which change exactly is missing?
This patchset is OK with one sub-test only tackle one DMA direction.
Thanks for the confirmation.
Quoted 6 lines
But there is a later patch [1] which will support multiple DMA directions within one sub-test.
it will add a entry "xfer_mode", but I think it complicate the test, I prefer we do more in this patchset to support some like bi-direction just by modify config.ini, some like this:Quoted 7 lines
Quoted 1 line
I think we should discuss about that in bi-directional patch series. This series
is self-contained and there is no need to add bi-directional as part of this series. As far as this patch set is concerned, all the options are exposed via config.ini. Can you comment if there is anything missing, assuming that we are taking bi-directional support as a separate feature addition.
I have identified some improvements to the dma-perf app, and I plan to do it
Quoted 7 lines
It is unclear at this point what is the issue that you have with the app or this patch set. This series was first submitted on Aug 10 2023. You had acked v8 on Jan 25 2024. After the patches were acked, there were still review comments on variable renames etc, which were all addressed. The patches had been under review for more than 8 months with very slow progress.
Quoted 3 lines
in 24.07, so if you don't mind, I will incorporate your commits (keeping your signed-off-by) and modify to the one that I described above, and then send to community (also with my improvements commits).
I would like to have this series merged first and not pulled into another series. We do have few other features that we would like to add on top. I would assume that you can also add your changes on top. To make contribution easier, isn't it better to accept at least this patch set (as you acked earlier) and then you can continue working on the improvements?
OK, one feature at a time.
Let's work on top of this patchset applied.
RE: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
Hi Thomas and Fengchengwen,
Quoted 65 lines
13/03/2024 09:22, Gowrishankar Muthukrishnan:
Quoted 28 lines
Hi Fengchengwen
Quoted 26 lines
Hi Gowrishankar,
Quoted 23 lines · Gowrishankar Muthukrishnan
Hi Fengchengwen
Quoted 21 lines
Hi Thomas,
Quoted 8 lines · Thomas Monjalon
07/03/2024 14:55, Gowrishankar Muthukrishnan:
Quoted 7 lines
Hi Fengchengwen,
Quoted 5 lines
Quoted 1 line
Waiting for a confirmation that this series is good to go.
In the discuss of thread [1], I hope this patchset continue take a step forward (means new version) to support bi-direction test just by
modify config.ini file.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
This patch set already exposes all configuration via config.ini. I didn't follow
what is missing. For bi-direction, we can better continue discussing on that patch.
Quoted 2 lines
Chengwen, please can you confirm whether you require a new
version?
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Quoted 1 line
Which change exactly is missing?
This patchset is OK with one sub-test only tackle one DMA direction.
Thanks for the confirmation.
Quoted 6 lines
But there is a later patch [1] which will support multiple DMA directions within one sub-test.
it will add a entry "xfer_mode", but I think it complicate the test, I prefer we do more in this patchset to support some like bi-direction just by modify config.ini, some like this:Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
I think we should discuss about that in bi-directional patch series. This series
is self-contained and there is no need to add bi-directional as part of this series. As far as this patch set is concerned, all the options are exposed via config.ini. Can you comment if there is anything missing, assuming that we are taking bi-directional support as a
separate feature addition.
Quoted 5 lines
Quoted 3 lines
I have identified some improvements to the dma-perf app, and I plan to do it
It is unclear at this point what is the issue that you have with the app or this
patch set. This series was first submitted on Aug 10 2023. You had acked v8 on Jan 25 2024. After the patches were acked, there were still review comments on variable renames etc, which were all addressed. The patches had been under review for more than 8 months with very slow progress.
Quoted 6 lines
Quoted 5 lines
in 24.07, so if you don't mind, I will incorporate your commits (keeping your
signed-off-by) and modify to the one that I described above, and then send to community (also with my improvements commits).
Quoted 9 lines
Quoted 1 line
I would like to have this series merged first and not pulled into another
series. We do have few other features that we would like to add on top. I would assume that you can also add your changes on top. To make contribution easier, isn't it better to accept at least this patch set (as you acked earlier) and then you can continue working on the improvements?
OK, one feature at a time.
Let's work on top of this patchset applied.
Thank you both for reviewing this series and accepting it in RC3.
Regards,
Gowrishankar
RE: [EXTERNAL] Re: [v11 0/4] PCI Dev and SG copy support
In reply to Thomas MonjalonHi Thomas,
Quoted 9 lines
29/02/2024 14:48, Gowrishankar Muthukrishnan:
Quoted 8 lines
Improve dma-perf application to support PCI dev and SG copy, along with additional supports as below:
- validate copied memory
- skip tests if not opted.v11:
- Review suggestions.
Quoted 8 lines
Quoted 5 lines
Gowrishankar Muthukrishnan (4):
app/dma-perf: add skip support
app/dma-perf: add PCI device support
app/dma-perf: validate copied memory
app/dma-perf: add SG copy supportWaiting for a confirmation that this series is good to go.
Patches are already acked by maintainer and is ready for merge.
Thanks,
Gowrishankar
Quoted 2 lines
Recheck-request: iol-unit-amd64-testing
PATCH v10 4/4 app/dma-perf: add SG copy support
In reply to Amit Prakash ShuklaFrom: Gowrishankar Muthukrishnan <[email protected]>
Add SG copy support.
---
v10:
- SG config variables renamed.
app/test-dma-perf/benchmark.c | 278 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 25 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 300 insertions(+), 42 deletions(-)
app/test-dma-perf/benchmark.c +242 -36
@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;volatile struct worker_info worker_info; };
@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs); +printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);
@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) +rte_exit (EXIT_FAILURE ,"Error, DMA ptrs more than supported by device id %u.\n" , + dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }
@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);
@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }
@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);
@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {
@@ -347,8 +428,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int cur_buf_size = cfg->buf_size.cur;
@@ -409,8 +491,8 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, }for (i =0 ; i < nr_buf; i++) { - memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); - memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), cur_buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, cur_buf_size); } if (cfg->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM ||
@@ -446,20 +528,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = cur_buf_size / src_ptrs; + sglen_dst = cur_buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (cur_buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (cur_buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;
@@ -467,12 +585,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + } + + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;
@@ -486,13 +624,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + } + offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;
@@ -506,10 +654,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + } }while (1 ) {
@@ -541,13 +702,53 @@ 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 && cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +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 if (cfg->is_sg && cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +size_t src_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + } } }
@@ -558,10 +759,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;
@@ -604,13 +803,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);
app/test-dma-perf/config.ini +24 -1
@@ -38,6 +38,14 @@ ; "skip" To skip a test-case set skip to 1. +; Parameters to be configured for SG copy: +; ======================================== +; "dma_src_sge" denotes number of source segments. +; "dma_dst_sge" denotes number of destination segments. +; +; For SG copy, both the parameters need to be configured and they are valid only +; when type is DMA_MEM_COPY. +; ; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": ; ================================================================================== ; "direction" denotes the direction of data transfer. It can take 3 values:
@@ -69,6 +77,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_src_sge=4 +dma_dst_sge=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=dev2mem
@@ -84,7 +107,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MUL
app/test-dma-perf/main.c +30 -4
@@ -108,10 +108,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);
@@ -365,7 +363,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;struct rte_kvargs *kvlist;const char *vchan_dev;
@@ -467,6 +466,7 @@ load_configs(const char *path)rte_kvargs_free (kvlist); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,
@@ -501,6 +501,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_src_sge" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_src_sge" )); + } + + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_dst_sge" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_dst_sge" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) { +printf ("parse dma_src_sge, dma_dst_sge error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false; + } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {
app/test-dma-perf/main.h +4 -1
@@ -53,11 +53,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;
@@ -66,6 +69,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Signature · 1 line
2.34.1
Hi Gowrishankar,
Quoted 22 lines · Amit Prakash Shukla
From: Gowrishankar Muthukrishnan <[email protected]>
Add SG copy support.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>Acked-by Anoob Joseph <[email protected]>Acked-by Chengwen Feng <[email protected]>---
v10:
- SG config variables renamed.app/test-dma-perf/benchmark.c | 278 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 25 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 300 insertions(+), 42 deletions(-)app/test-dma-perf/benchmark.c +0
-0
app/test-dma-perf/benchmark.c struct lcore_params { · line 52
Quoted 7 lines
app/test-dma-perf/benchmark.c +4
-0@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;
1. src/dst_ptrs -> src/dst_nb_sge
2. How about wrap these four fields as a struct?
Quoted 19 lines
app/test-dma-perf/benchmark.c +4
-7volatile struct worker_info worker_info; };@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te }static void -output_result (uint8_t scenario_id,uint32_t lcore_id,char *dma_name,uint16_t ring_size, -uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size,uint32_t nr_buf, -float memory,float bandwidth,float mops,bool is_dma) +output_result (struct test_configure *cfg,struct lcore_params *para, +uint16_t kick_batch,uint64_t ave_cycle,uint32_t buf_size, +uint32_t nr_buf,float memory,float bandwidth,float mops) { -if (is_dma) -printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u.\n" , - lcore_id, dma_name, ring_size, kick_batch); -else +uint16_t ring_size = cfg->ring_size.cur;
app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te · line 107
Quoted 10 lines
app/test-dma-perf/benchmark.c +10
-0+uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { +printf ("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size: %u" , lcore_id, + dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs);
DMA src sges: %u DMA dst sges: %u
I think we should add a column which title maybe misc, some like sg-src[4]-dst[1], and later we may add fill test, then this field could be pattern-0x12345678
And in "[PATCH v10 2/4] app/dma-perf: add PCI device support" commit, if the DMA was worked in non-mem2mem direction, we could add simple descriptor of direction and pcie.info in the above misc column.
Quoted 24 lines
app/test-dma-perf/benchmark.c +5
-2+printf (".\n" ); + }else {printf ("lcore %u\n" , lcore_id); + }printf ("Average Cycles/op: %" PRIu64", Buffer Size: %u B, Buffer Number: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n" , ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz ()/1000000000.0 );printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma)snprintf (output_str[lcore_id],MAX_OUTPUT_STR_LEN ,CSV_LINE_DMA_FMT , scenario_id, lcore_id, dma_name, ring_size, kick_batch, buf_size, nr_buf, memory, ave_cycle, bandwidth, mops);@@ -167,7 +181,7 @@ vchan_data_populate(uint32_t dev_id, struct rte_dma_vchan_conf *qconf,/* Configuration of device. */ static void -configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg) +configure_dmadev_queue (uint32_t dev_id,struct test_configure *cfg,uint8_t ptrs_max) {uint16_t vchan =0 ;struct rte_dma_info info;
app/test-dma-perf/benchmark.c configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg) · line 208
Quoted 5 lines
app/test-dma-perf/benchmark.c +2
-0@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)rte_exit (EXIT_FAILURE ,"Error, no configured queues reported on device id. %u\n" , dev_id); +if (info.max_sges < ptrs_max) + rte_exit(EXIT_FAILURE, "Error, DMA ptrs more than supported by device id %u.\n",
"Error with unsupport max_sges on device id %u.\n"
app/test-dma-perf/benchmark.c config_dmadevs(struct test_configure *cfg) · line 223
Quoted 10 lines
app/test-dma-perf/benchmark.c +3
-0+ dev_id); +if (rte_dma_start (dev_id) !=0 )rte_exit (EXIT_FAILURE ,"Error with dma start.\n" ); }@@ -202,8 +220,12 @@ config_dmadevs(struct test_configure *cfg)uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;
It hard to understand, how about nb_sge?
Quoted 190 lines
app/test-dma-perf/benchmark.c +116
-10char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id, uint64_t *async_cnt, }static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true; + +while (!worker_info->start_flag) + ; + +while (1 ) { + j =0 ; +for (i =0 ; i < nr_buf; i++) { +dma_copy: + ret =rte_dma_copy_sg (dev_id,0 , + &src_sges[i * src_ptrs], &dst_sges[j * dst_ptrs], + src_ptrs, dst_ptrs,0 ); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) +do_dma_submit_and_poll (dev_id, &async_cnt, worker_info); + } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl =rte_dma_completed (dev_id,0 ,MAX_DMA_CPL_NB ,NULL ,NULL ); + async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {@@ -347,8 +428,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, +struct rte_dma_sge **src_sges,struct rte_dma_sge **dst_sges) {static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int cur_buf_size = cfg->buf_size.cur;@@ -409,8 +491,8 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, }for (i =0 ; i < nr_buf; i++) { - memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); - memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), cur_buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, cur_buf_size); } if (cfg->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM ||@@ -446,20 +528,56 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, } } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges =rte_zmalloc (NULL , nr_buf *sizeof (struct rte_dma_sge ), +RTE_CACHE_LINE_SIZE ); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ; + } + + sglen_src = cur_buf_size / src_ptrs; + sglen_dst = cur_buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (cur_buf_size % src_ptrs); + + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (cur_buf_size % dst_ptrs); + } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i; +uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; -uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 );uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;@@ -467,12 +585,32 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs);
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 607
Quoted 10 lines
app/test-dma-perf/benchmark.c +10
-0+ nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs); + nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + }
pls move to a subfunction
Quoted 13 lines
app/test-dma-perf/benchmark.c +4
-1+ + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;@@ -486,13 +624,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)for (i =0 ; i < nb_workers; i++) {
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 635
Quoted 10 lines
app/test-dma-perf/benchmark.c +9
-0lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { +printf ("lcore parameters can not use main core id %d\n" , mcore_id); + goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { +printf ("lcore parameters can not use offline core id %d\n" , lcore_id); + goto out; + }
The above two judgement should in a seperate commit.
Quoted 26 lines
app/test-dma-perf/benchmark.c +9
-4+ offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) {printf ("lcore parameters malloc failure for lcore %d\n" , lcore_id);break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;@@ -506,10 +654,23 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) -rte_eal_remote_launch (do_dma_mem_copy, (void *)(lcores[i]), lcore_id); -else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers * i); + lcores[i]->dst_sges = dst_sges + (nr_sgdst / nb_workers * i); + } +
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 673
Quoted 10 lines
app/test-dma-perf/benchmark.c +9
-0+if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch (do_dma_plain_mem_copy, (void *)(lcores[i]), + lcore_id); +else +rte_eal_remote_launch (do_dma_sg_mem_copy, (void *)(lcores[i]), + lcore_id); + }else {rte_eal_remote_launch (do_cpu_mem_copy, (void *)(lcores[i]), lcore_id); + }
too many judgement for selecting target function, how about wrap it subfunction:lcore_function_t get_work_function(struct test_configure *cfg)
then rte_eal_remote_launch(get_work_function(cfg), (void *)(lcores[i]), lcore_id);
Quoted 51 lines
app/test-dma-perf/benchmark.c +37
-7}while (1 ) {@@ -541,13 +702,53 @@ 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 && cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +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 if (cfg->is_sg && cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ) { +size_t src_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + +for (i =0 ; i < (nr_buf /RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs)); i++) { + sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs + j], uint8_t *); +memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs + j], uint8_t *); +memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + }
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 751
Quoted 10 lines
app/test-dma-perf/benchmark.c +10
-0+ +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { +printf ("SG Copy validation fails for buffer number %d\n" , + i * cfg->src_ptrs); + ret =-1 ; + goto out; + }
Now I doubt the value of verify, this verify can't find the middle round copy failure, because as long as the last round copy is successful, the validation will pass.
And adding validatation in every round copy will impact performance.
Also app/test_dmadev already verify data. so I think we should drop the validation commit.
Quoted 43 lines
app/test-dma-perf/benchmark.c +10
-5} }@@ -558,10 +759,8 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); -output_result (cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg->ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf / nb_workers, memory, - bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth; avg_cycles_total += avg_cycles;@@ -604,13 +803,20 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma)rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);app/test-dma-perf/config.ini +0
-0
app/test-dma-perf/config.ini line 39
Quoted 2 lines
app/test-dma-perf/config.ini +0
-0@@ -38,6 +38,14 @@ ; "skip" To skip a test-case set skip to 1.
Please place hese patchset new add entrys' descriptions above the
"; To specify a configuration file, use the "--config" flag followed by the path to the file."
because original config.ini, fist is parameters descriptor, and then program argment descriptor, and last was example.
app/test-dma-perf/config.ini line 41
Quoted 2 lines
app/test-dma-perf/config.ini +1
-0+; Parameters to be configured for SG copy:
Parameters for DMA scatter-gather memory copy:
app/test-dma-perf/config.ini line 42
Quoted 1 line
app/test-dma-perf/config.ini +1
-0+; ========================================
Please remove this line
app/test-dma-perf/config.ini line 47
Quoted 5 lines
app/test-dma-perf/config.ini +5
-0+; "dma_src_sge" denotes number of source segments. +; "dma_dst_sge" denotes number of destination segments. +; +; For SG copy, both the parameters need to be configured and they are valid only +; when type is DMA_MEM_COPY.
For DMA scatter-gather memory copy, the parameters need to be configured and they are valid only when type is DMA_MEM_COPY.
app/test-dma-perf/config.ini line 50
Quoted 3 lines
app/test-dma-perf/config.ini +1
-0+; ; Parameters to be configured for data transfers from "mem to dev" and "dev to mem": ; ==================================================================================
Please remove this line
As another commit "Re: [PATCH v2] app/dma-perf: support bi-directional transfer"'s review feedback, these descriptor should place after
"
; To use DMA for a test, please specify the "lcore_dma" parameter.
; If you have already set the "-l" and "-a" parameters using EAL,
; make sure that the value of "lcore_dma" falls within their range of the values.
; We have to ensure a 1:1 mapping between the core and DMA device.
"
Quoted 76 lines
app/test-dma-perf/config.ini +16
-1; "direction" denotes the direction of data transfer. It can take 3 values:@@ -69,6 +77,21 @@ lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_src_sge=4 +dma_dst_sge=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=dev2mem@@ -84,7 +107,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MULapp/test-dma-perf/main.c +10
-4@@ -108,10 +108,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);@@ -365,7 +363,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; -const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str; +const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str, + *src_ptrs_str, *dst_ptrs_str;const char *skip;struct rte_kvargs *kvlist;const char *vchan_dev;@@ -467,6 +466,7 @@ load_configs(const char *path)rte_kvargs_free (kvlist); } + test_case->is_dma = is_dma; test_case->src_numa_node = (int )atoi (rte_cfgfile_get_entry (cfgfile, section_name,"src_numa_node" )); test_case->dst_numa_node = (int)atoi(rte_cfgfile_get_entry(cfgfile,@@ -501,6 +501,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_src_sge" ); +if (src_ptrs_str !=NULL ) { + test_case->src_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_src_sge" )); + }
app/test-dma-perf/main.c load_configs(const char *path) · line 519
Quoted 10 lines
app/test-dma-perf/main.c +10
-0+ + dst_ptrs_str =rte_cfgfile_get_entry (cfgfile, section_name, +"dma_dst_sge" ); +if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs = (int )atoi (rte_cfgfile_get_entry (cfgfile, + section_name,"dma_dst_sge" )); + } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) {
Please also check test_case->src_ptrs and test_case->dst_ptrs valid, make sure there are >1 and <=UINT16_MAX
app/test-dma-perf/main.c load_configs(const char *path) · line 527
Quoted 8 lines
app/test-dma-perf/main.c +8
-0+printf ("parse dma_src_sge, dma_dst_sge error in case %d.\n" , + i +1 ); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ) { + test_case->is_sg = true; + }else { + test_case->is_sg = false;
the above could simple by: test_case->is_sg = (src_ptrs_str != NULL && dst_ptrs_str != NULL);
Quoted 33 lines
app/test-dma-perf/main.c +2
-0+ } + kick_batch_str =rte_cfgfile_get_entry (cfgfile, section_name,"kick_batch" ); args_nr =parse_entry (kick_batch_str, &test_case->kick_batch);if (args_nr <0 ) {app/test-dma-perf/main.h +4
-1@@ -53,11 +53,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;@@ -66,6 +69,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Hi Fengcheng,
Quoted 36 lines
-----Original Message-----
From: fengchengwen <[email protected]>
Sent: Wednesday, February 28, 2024 3:02 PM
To: Amit Prakash Shukla <[email protected]>; Cheng Jiang <[email protected]>
Cc: [email protected]; Jerin Jacob <[email protected]>; Anoob Joseph <[email protected]>; Kevin Laatz <[email protected]>; Bruce Richardson <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>
Subject: [EXT] Re: [PATCH v10 4/4] app/dma-perf: add SG copy supportExternal Email
----------------------------------------------------------------------
Hi Gowrishankar,Quoted 18 lines · Amit Prakash Shukla
From: Gowrishankar Muthukrishnan <[email protected]>
Add SG copy support.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>Acked-by Anoob Joseph <[email protected]>Acked-by Chengwen Feng <[email protected]>---
v10:
- SG config variables renamed.app/test-dma-perf/benchmark.c | 278 +++++++++++++++++++++++++++++----- app/test-dma-perf/config.ini | 25 ++- app/test-dma-perf/main.c | 34 ++++- app/test-dma-perf/main.h | 5 +- 4 files changed, 300 insertions(+), 42 deletions(-)
Quoted 14 lines
app/test-dma-perf/benchmark.c struct lcore_params { · line 52
Quoted 12 lines
(quoted diff) +0
-0
b/app/test-dma-perf/benchmark.cindex0047e2f4b8..25ed6fa6d0100644app/test-dma-perf/benchmark.c +4
-0@@ -46,6 +46,10 @@ struct lcore_params {uint16_t test_secs;struct rte_mbuf **srcs;struct rte_mbuf **dsts; +struct rte_dma_sge *src_sges; +struct rte_dma_sge *dst_sges; +uint8_t src_ptrs; +uint8_t dst_ptrs;1. src/dst_ptrs -> src/dst_nb_sge
Ack.
Quoted 1 line
2. How about wrap these four fields as a struct?
Ack.
Quoted 39 lines
app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, · line 89
Quoted 8 lines
app/test-dma-perf/benchmark.c +0
-1volatile struct worker_info worker_info; };@@ -86,21 +90,31 @@ calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te } static void -output_result(uint8_t scenario_id, uint32_t lcore_id, char *dma_name,
uint16_tring_size,app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, · line 90
Quoted 1 line
app/test-dma-perf/benchmark.c +0
-1- uint16_t kick_batch, uint64_t ave_cycle, uint32_t
buf_size,uint32_tnr_buf,app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, · line 91
Quoted 1 line
app/test-dma-perf/benchmark.c +0
-1- float memory, float bandwidth, float mops, bool
is_dma)app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, · line 94
Quoted 2 lines
app/test-dma-perf/benchmark.c +2
-0+output_result(struct test_configure *cfg, struct lcore_params *para, + uint16_t kick_batch, uint64_t ave_cycle, uint32_t
buf_size,app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, · line 95
Quoted 1 line
app/test-dma-perf/benchmark.c +1
-0+ uint32_t nr_buf, float memory, float bandwidth, floatmops)
app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te
Quoted 3 lines
app/test-dma-perf/benchmark.c +0
-2{ -if (is_dma) - printf("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size:%u.\n",
app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te
Quoted 9 lines
app/test-dma-perf/benchmark.c +7
-2- lcore_id, dma_name, ring_size, kick_batch); - else +uint16_t ring_size = cfg->ring_size.cur; +uint8_t scenario_id = cfg->scenario_id; +uint32_t lcore_id = para->lcore_id; +char *dma_name = para->dma_name; + +if (cfg->is_dma) { + printf("lcore %u, DMA %s, DMA Ring Size: %u, Kick Batch Size:%u",
lcore_id,app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te · line 107
Quoted 4 lines
app/test-dma-perf/benchmark.c +4
-0+ dma_name, ring_size, kick_batch); +if (cfg->is_sg) +printf (" DMA src ptrs: %u, dst ptrs: %u" , + para->src_ptrs, para->dst_ptrs);DMA src sges: %u DMA dst sges: %u
Quoted 8 lines
I think we should add a column which title maybe misc, some like sg-src[4]- dst[1], and later we may add fill test, then this field could be pattern-
0x12345678And in "[PATCH v10 2/4] app/dma-perf: add PCI device support" commit, if the DMA was worked in non-mem2mem direction, we could add simple descriptor of direction and pcie.info in the above misc column.
I am sorry, I could not understand complete picture here. Do you mean we reserve a column and use it as per test type.
For plain mem copy, nothing added.
For SG mem copy, instead of showing "DMA src sges: 1, dst sges: 4", print "sg-src[1]-dst[4]". In future, when we add fill test in benchmark, this line instead be "pattern-0x12345678".
Is my understanding correct over here ?
Quoted 34 lines
app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te
Quoted 6 lines
app/test-dma-perf/benchmark.c +3
-0+printf (".\n" ); + } else {printf ("lcore %u\n" , lcore_id); + } printf("Average Cycles/op: %" PRIu64 ", Buffer Size: %u B, BufferNumber: %u, Memory: %.2lf MB, Frequency: %.3lf Ghz.\n",
app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, · line 114
Quoted 1 line
app/test-dma-perf/benchmark.c +0
-0ave_cycle, buf_size, nr_buf, memory,rte_get_timer_hz()/1000000000.0);
app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, uint16_t nb_workers, uint16_t te
Quoted 6 lines
app/test-dma-perf/benchmark.c +1
-1printf ("Average Bandwidth: %.3lf Gbps, MOps: %.3lf\n" , bandwidth, mops); -if (is_dma) +if (cfg->is_dma) snprintf(output_str[lcore_id], MAX_OUTPUT_STR_LEN,
CSV_LINE_DMA_FMT,app/test-dma-perf/benchmark.c calc_result(uint32_t buf_size, uint32_t nr_buf, · line 120
Quoted 1 line
app/test-dma-perf/benchmark.c +0
-0scenario_id, lcore_id, dma_name, ring_size,
kick_batch,buf_size,Quoted 1 line
nr_buf, memory,ave_cycle, bandwidth, mops); @@ -167,7 +181,7 @@
app/test-dma-perf/benchmark.c configure_dmadev_queue(uint32_t dev_id, struct
Quoted 11 lines
vchan_data_populate(uint32_t
dev_id, structrte_dma_vchan_conf*qconf,/* Configuration of device. */
static voidapp/test-dma-perf/benchmark.c +2
-1-configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg) +configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg, +uint8_t ptrs_max) { uint16_t vchan = 0;struct rte_dma_info info;@@ -190,6 +204,10 @@ configure_dmadev_queue(uint32_t dev_id, struct
test_configure*cfg)app/test-dma-perf/benchmark.c configure_dmadev_queue(uint32_t dev_id, struct · line 204
Quoted 1 line
app/test-dma-perf/benchmark.c +0
-0rte_exit(EXIT_FAILURE, "Error, no configured queues reportedon device id. %u\n",
Quoted 8 lines
app/test-dma-perf/benchmark.c configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)
Quoted 4 lines
app/test-dma-perf/benchmark.c +2
-0dev_id); +if (info.max_sges < ptrs_max) + rte_exit(EXIT_FAILURE, "Error, DMA ptrs more than supportedby
app/test-dma-perf/benchmark.c configure_dmadev_queue(uint32_t dev_id, struct · line 209
Quoted 1 line
app/test-dma-perf/benchmark.c +1
-0+device id %u.\n","Error with unsupport
max_sgeson device id %u.\n"
Ack.
Quoted 6 lines
app/test-dma-perf/benchmark.c configure_dmadev_queue(uint32_t dev_id, struct test_configure *cfg)
Quoted 5 lines
app/test-dma-perf/benchmark.c +2
-0+ dev_id); +if (rte_dma_start (dev_id) !=0 ) rte_exit(EXIT_FAILURE, "Error with dma start.\n"); } @@ -202,8
Quoted 7 lines
app/test-dma-perf/benchmark.c config_dmadevs(struct test_configure *cfg) · line 223
Quoted 5 lines
app/test-dma-perf/benchmark.c +2
-0+220,12 @@ config_dmadevs(struct test_configure *cfg) uint32_t i;int dev_id;uint16_t nb_dmadevs =0 ; +uint8_t ptrs_max =0 ;It hard to understand, how about
nb_sge?
Ack. Renamed it to nb_sges.
Quoted 212 lines
app/test-dma-perf/benchmark.c do_dma_submit_and_poll(uint16_t dev_id,
Quoted 19 lines
app/test-dma-perf/benchmark.c +4
-1char *dma_name; +if (cfg->is_sg) + ptrs_max =RTE_MAX (cfg->src_ptrs, cfg->dst_ptrs); +for (i =0 ; i < ldm->cnt; i++) { dma_name = ldm->dma_names[i]; dev_id =rte_dma_get_dev_id_by_name (dma_name);@@ -213,7 +235,7 @@ config_dmadevs(struct test_configure *cfg) } ldm->dma_ids[i] = dev_id; -configure_dmadev_queue (dev_id, cfg); +configure_dmadev_queue (dev_id, cfg, ptrs_max); ++nb_dmadevs; }@@ -253,7 +275,7 @@ do_dma_submit_and_poll(uint16_t dev_id,
uint64_t*async_cnt,Quoted 33 lines
app/test-dma-perf/benchmark.c +22
-1}static inline int -do_dma_mem_copy (void *p) +do_dma_plain_mem_copy (void *p) {struct lcore_params *para = (struct lcore_params *)p;volatile struct worker_info *worker_info = &(para->worker_info);@@ -306,6 +328,65 @@ do_dma_mem_copy(void *p)return 0 ; } +static inline int +do_dma_sg_mem_copy (void *p) +{ +struct lcore_params *para = (struct lcore_params *)p; +volatile struct worker_info *worker_info = &(para->worker_info); +struct rte_dma_sge *src_sges = para->src_sges; +struct rte_dma_sge *dst_sges = para->dst_sges; +const uint16_t kick_batch = para->kick_batch; +const uint8_t src_ptrs = para->src_ptrs; +const uint8_t dst_ptrs = para->dst_ptrs; +const uint16_t dev_id = para->dev_id; +uint32_t nr_buf = para->nr_buf; +uint64_t async_cnt =0 ; +uint32_t poll_cnt =0 ; +uint16_t nr_cpl; +uint32_t i, j; +int ret; + + nr_buf /=RTE_MAX (src_ptrs, dst_ptrs); + worker_info->stop_flag = false; + worker_info->ready_flag = true;app/test-dma-perf/benchmark.c do_dma_mem_copy(void *p) · line 361
Quoted 10 lines
app/test-dma-perf/benchmark.c +10
-0+ + while (!worker_info->start_flag) + ; + + while (1) { + j = 0; + for (i = 0; i < nr_buf; i++) { +dma_copy: + ret = rte_dma_copy_sg(dev_id, 0, + &src_sges[i * src_ptrs], &dst_sges[j *
dst_ptrs],app/test-dma-perf/benchmark.c do_dma_mem_copy(void *p)
Quoted 4 lines
app/test-dma-perf/benchmark.c +4
-0+ src_ptrs, dst_ptrs, 0); +if (unlikely (ret <0 )) { +if (ret == -ENOSPC ) { + do_dma_submit_and_poll(dev_id,
&async_cnt,worker_info);app/test-dma-perf/benchmark.c do_dma_mem_copy(void *p)
Quoted 9 lines
app/test-dma-perf/benchmark.c +9
-0+ goto dma_copy; + }else +error_exit (dev_id); + } + async_cnt++; + j++; + +if ((async_cnt % kick_batch) ==0 ) + do_dma_submit_and_poll(dev_id,
&async_cnt,worker_info);app/test-dma-perf/benchmark.c do_dma_mem_copy(void *p)
Quoted 9 lines
app/test-dma-perf/benchmark.c +9
-0+ } + +if (worker_info->stop_flag) +break ; + } + +rte_dma_submit (dev_id,0 ); +while ((async_cnt >0 ) && (poll_cnt++ <POLL_MAX )) { + nr_cpl = rte_dma_completed(dev_id, 0, MAX_DMA_CPL_NB,NULL, NULL);
Quoted 10 lines
app/test-dma-perf/benchmark.c +6
-0+ async_cnt -= nr_cpl; + } + +return 0 ; +} +static inline int do_cpu_mem_copy (void *p) {app/test-dma-perf/benchmark.c dummy_free_ext_buf(void *addr, void *opaque) · line 433
Quoted 8 lines
app/test-dma-perf/benchmark.c +3
-2@@ -347,8 +428,9 @@ dummy_free_ext_buf(void *addr, void *opaque) }static int -setup_memory_env (struct test_configure *cfg,struct rte_mbuf ***srcs, -struct rte_mbuf ***dsts) +setup_memory_env (struct test_configure *cfg, +struct rte_mbuf ***srcs,struct rte_mbuf ***dsts, + struct rte_dma_sge **src_sges, struct rte_dma_sge**dst_sges)
app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg,
Quoted 4 lines
app/test-dma-perf/benchmark.c +0
-0{static struct rte_mbuf_ext_shared_info *ext_buf_info;unsigned int cur_buf_size = cfg->buf_size.cur;@@ -409,8 +491,8 @@ setup_memory_env(struct test_configure *cfg,struct
rte_mbuf***srcs,app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
Quoted 4 lines
app/test-dma-perf/benchmark.c +0
-1}for (i =0 ; i < nr_buf; i++) { - memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(),
buf_size);app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, · line 494
Quoted 2 lines
app/test-dma-perf/benchmark.c +1
-1- memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(),
cur_buf_size);app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, · line 495
Quoted 1 line
app/test-dma-perf/benchmark.c +1
-0+ memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0,
cur_buf_size);app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg,
Quoted 4 lines
app/test-dma-perf/benchmark.c +0
-0} if (cfg->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM ||@@ -446,20 +528,56 @@ setup_memory_env(struct test_configure *cfg,struct
rte_mbuf***srcs,app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
Quoted 9 lines
app/test-dma-perf/benchmark.c +6
-0} } +if (cfg->is_sg) { +uint8_t src_ptrs = cfg->src_ptrs; +uint8_t dst_ptrs = cfg->dst_ptrs; +uint32_t sglen_src, sglen_dst; + + *src_sges = rte_zmalloc(NULL, nr_buf * sizeof(struct
rte_dma_sge),app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
Quoted 7 lines
app/test-dma-perf/benchmark.c +7
-0+ RTE_CACHE_LINE_SIZE); +if (*src_sges ==NULL ) { +printf ("Error: src_sges array malloc failed.\n" ); +return -1 ; + } + + *dst_sges = rte_zmalloc(NULL, nr_buf * sizeof(struct
rte_dma_sge),Quoted 4 lines
app/test-dma-perf/benchmark.c +4
-0+ RTE_CACHE_LINE_SIZE); +if (*dst_sges ==NULL ) { +printf ("Error: dst_sges array malloc failed.\n" ); +return -1 ;app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
Quoted 10 lines
app/test-dma-perf/benchmark.c +10
-0+ } + + sglen_src = cur_buf_size / src_ptrs; + sglen_dst = cur_buf_size / dst_ptrs; + +for (i =0 ; i < nr_buf; i++) { + (*src_sges)[i].addr =rte_pktmbuf_iova ((*srcs)[i]); + (*src_sges)[i].length = sglen_src; +if (!((i+1 ) % src_ptrs)) + (*src_sges)[i].length += (cur_buf_size %
src_ptrs);app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
Quoted 5 lines
app/test-dma-perf/benchmark.c +5
-0+ + (*dst_sges)[i].addr =rte_pktmbuf_iova ((*dsts)[i]); + (*dst_sges)[i].length = sglen_dst; +if (!((i+1 ) % dst_ptrs)) + (*dst_sges)[i].length += (cur_buf_size %
dst_ptrs);Quoted 11 lines
app/test-dma-perf/benchmark.c +4
-2+ } + } +return 0 ; }int -mem_copy_benchmark (struct test_configure *cfg,bool is_dma) +mem_copy_benchmark (struct test_configure *cfg) { -uint32_t i;app/test-dma-perf/benchmark.c setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs,
Quoted 10 lines
app/test-dma-perf/benchmark.c +3
-1+uint32_t i, j;uint32_t offset;unsigned int lcore_id =0 ;struct rte_mbuf **srcs =NULL , **dsts =NULL , **m =NULL ; +struct rte_dma_sge *src_sges =NULL , *dst_sges =NULL ;struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; +const uint32_t mcore_id =rte_get_main_lcore ();unsigned int buf_size = cfg->buf_size.cur;uint16_t kick_batch = cfg->kick_batch.cur; - uint32_t nr_buf = cfg->nr_buf = (cfg->mem_size.cur * 1024 * 1024) /(
cfg->buf_size.cur* 2);app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure
Quoted 4 lines
app/test-dma-perf/benchmark.c +0
-0uint16_t nb_workers = ldm->cnt;uint16_t test_secs = cfg->test_secs;float memory =0 ;@@ -467,12 +585,32 @@ mem_copy_benchmark(struct test_configure*cfg, bool
is_dma)Quoted 18 lines
app/test-dma-perf/benchmark.c +12
-1uint32_t avg_cycles_total;float mops, mops_total;float bandwidth, bandwidth_total; +uint32_t nr_sgsrc =0 , nr_sgdst =0 ; +uint32_t nr_buf;int ret =0 ; -if (setup_memory_env (cfg, &srcs, &dsts) <0 ) +/* Align number of buffers according to workers count */ + nr_buf = (cfg->mem_size.cur *1024 *1024 ) / (cfg->buf_size.cur *2 ); + nr_buf -= (nr_buf % nb_workers); +if (cfg->is_sg) { + nr_buf /= nb_workers; + nr_buf -= nr_buf % (cfg->src_ptrs * cfg->dst_ptrs); + nr_buf *= nb_workers; + +if (cfg->dst_ptrs > cfg->src_ptrs) { + nr_sgsrc = (nr_buf / cfg->dst_ptrs * cfg->src_ptrs);
Quoted 8 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 607
Quoted 6 lines
app/test-dma-perf/benchmark.c +6
-0+ nr_sgdst = nr_buf; + }else { + nr_sgsrc = nr_buf; + nr_sgdst = (nr_buf / cfg->src_ptrs * cfg->dst_ptrs); + } + }pls move to a subfunction
Ack.
Quoted 25 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure
Quoted 12 lines
app/test-dma-perf/benchmark.c +4
-1+ + cfg->nr_buf = nr_buf; +if (setup_memory_env (cfg, &srcs, &dsts, &src_sges, &dst_sges) <0 ) goto out; -if (is_dma) +if (cfg->is_dma)if (config_dmadevs (cfg) <0 ) goto out;@@ -486,13 +624,23 @@ mem_copy_benchmark(struct test_configure*cfg, bool
is_dma)app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +2
-0for (i =0 ; i < nb_workers; i++) { lcore_id = ldm->lcores[i]; +if (lcore_id == mcore_id) { + printf("lcore parameters can not use main core id%d\n",
mcore_id);app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +5
-0+ goto out; + } + +if (rte_eal_lcore_role (lcore_id) ==ROLE_OFF ) { + printf("lcore parameters can not use offline core id%d\n",
lcore_id);
Quoted 4 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure · line 634
Quoted 2 lines
app/test-dma-perf/benchmark.c +2
-0+ goto out; + }The above two judgement should in a seperate commit.
Sorry, somehow it got mixed from different patch I had in my local repo. It will be in different commit.
Quoted 44 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 6 lines
app/test-dma-perf/benchmark.c +1
-0+ offset = nr_buf / nb_workers * i; lcores[i] =rte_malloc (NULL ,sizeof (struct lcore_params ),0 );if (lcores[i] ==NULL ) { printf("lcore parameters malloc failure for lcore %d\n",
lcore_id);app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure
Quoted 8 lines
app/test-dma-perf/benchmark.c +1
-1break ; } -if (is_dma) { +if (cfg->is_dma) { lcores[i]->dma_name = ldm->dma_names[i]; lcores[i]->dev_id = ldm->dma_ids[i]; lcores[i]->kick_batch = kick_batch;@@ -506,10 +654,23 @@ mem_copy_benchmark(struct test_configure*cfg, bool
is_dma)app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +0
-2lcores[i]->scenario_id = cfg->scenario_id; lcores[i]->lcore_id = lcore_id; -if (is_dma) - rte_eal_remote_launch(do_dma_mem_copy, (void*)(lcores[i]),
lcore_id);app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +4
-1-else +if (cfg->is_sg) { + lcores[i]->src_ptrs = cfg->src_ptrs; + lcores[i]->dst_ptrs = cfg->dst_ptrs; + lcores[i]->src_sges = src_sges + (nr_sgsrc / nb_workers* i);
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure · line 661
Quoted 1 line
app/test-dma-perf/benchmark.c +1
-0+ lcores[i]->dst_sges = dst_sges + (nr_sgdst /
nb_workers* i);app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +5
-0+ } + +if (cfg->is_dma) { +if (!cfg->is_sg) +rte_eal_remote_launch(do_dma_plain_mem_copy, (void *)(lcores[i]),app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 3 lines
app/test-dma-perf/benchmark.c +3
-0+ lcore_id); + else +rte_eal_remote_launch(do_dma_sg_mem_copy, (void *)(lcores[i]),app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 3 lines
app/test-dma-perf/benchmark.c +2
-0+ lcore_id); + }else { rte_eal_remote_launch(do_cpu_mem_copy, (void*)(lcores[i]),
lcore_id);
Quoted 8 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure · line 673
Quoted 1 line
app/test-dma-perf/benchmark.c +1
-0+ }too many judgement for selecting target function, how about wrap it subfunction:
lcore_function_tget_work_function(struct test_configure *cfg)thenrte_eal_remote_launch(get_work_function(cfg), (void *)(lcores[i]), lcore_id);
Ack.
Quoted 66 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure
Quoted 4 lines
app/test-dma-perf/benchmark.c +0
-0}while (1 ) {@@ -541,13 +702,53 @@ mem_copy_benchmark(struct test_configure*cfg, bool
is_dma)app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 8 lines
app/test-dma-perf/benchmark.c +0
-5rte_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);
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 3 lines
app/test-dma-perf/benchmark.c +1
-2- ret =-1 ; - goto out; +if (!cfg->is_sg && cfg->transfer_dir ==RTE_DMA_DIR_MEM_TO_MEM ){
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +5
-0+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);
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 5 lines
app/test-dma-perf/benchmark.c +5
-0+ ret =-1 ; + goto out; + } + } + } else if (cfg->is_sg && cfg->transfer_dir ==
RTE_DMA_DIR_MEM_TO_MEM) {app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 8 lines
app/test-dma-perf/benchmark.c +8
-0+size_t src_remsz = buf_size % cfg->src_ptrs; +size_t dst_remsz = buf_size % cfg->dst_ptrs; +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, *ptr; + + for (i = 0; i < (nr_buf / RTE_MAX(cfg->src_ptrs, cfg->dst_ptrs));i++) {
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 6 lines
app/test-dma-perf/benchmark.c +6
-0+ sbuf = src; + dbuf = dst; + ptr =NULL ; + +for (j =0 ; j < cfg->src_ptrs; j++) { + ptr = rte_pktmbuf_mtod(srcs[i * cfg->src_ptrs+ j],
uint8_t*);app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 9 lines
app/test-dma-perf/benchmark.c +9
-0+memcpy (sbuf, ptr, src_sz); + sbuf += src_sz; + } + +if (src_remsz) +memcpy (sbuf, ptr + src_sz, src_remsz); + +for (j =0 ; j < cfg->dst_ptrs; j++) { + ptr = rte_pktmbuf_mtod(dsts[i * cfg->dst_ptrs+ j],
uint8_t*);app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 9 lines
app/test-dma-perf/benchmark.c +9
-0+memcpy (dbuf, ptr, dst_sz); + dbuf += dst_sz; + } + +if (dst_remsz) +memcpy (dbuf, ptr + dst_sz, dst_remsz); + +if (memcmp (src, dst, buf_size) !=0 ) { + printf("SG Copy validation fails for buffernumber %d\n",
Quoted 9 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma) · line 751
Quoted 4 lines
app/test-dma-perf/benchmark.c +4
-0+ i * cfg->src_ptrs); + ret =-1 ; + goto out; + }Now I doubt the value of verify, this verify can't find the middle round copy failure,
because as long as the last round copy is successful, the validation will pass.
Validation is on entire buffer. If any middle copy is a failure, entire memcmp would have failed. Or do I miss something ?
Quoted 2 lines
And adding validatation in every round copy will impact performance.
This validation is just after worker function is stopped measuring perf. How would this impact performance ?
Quoted 2 lines
Also app/test_dmadev already verify data. so I think we should drop the validation commit.
Even in some corner cases or unknown issues, copy would have failed and taking perf cycles then is meaningless. That is the reason, this validation is added after perf function doing its job.
Quoted 49 lines
app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg,
Quoted 5 lines
app/test-dma-perf/benchmark.c +0
-0} }@@ -558,10 +759,8 @@ mem_copy_benchmark(struct test_configure *cfg,bool
is_dma)app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure *cfg, bool is_dma)
Quoted 7 lines
app/test-dma-perf/benchmark.c +0
-3calc_result (buf_size, nr_buf, nb_workers, test_secs, lcores[i]->worker_info.test_cpl, &memory, &avg_cycles, &bandwidth, &mops); - output_result(cfg->scenario_id, lcores[i]->lcore_id, - lcores[i]->dma_name, cfg- ring_size.cur, kick_batch, - avg_cycles, buf_size, nr_buf /
nb_workers, memory,app/test-dma-perf/benchmark.c mem_copy_benchmark(struct test_configure
Quoted 7 lines
app/test-dma-perf/benchmark.c +2
-1- bandwidth, mops, is_dma); +output_result (cfg, lcores[i], kick_batch, avg_cycles, buf_size, + nr_buf / nb_workers, memory, bandwidth, mops); mops_total += mops; bandwidth_total += bandwidth;app/test-dma-perf/benchmark.c +0
-0avg_cycles_total += avg_cycles;@@ -604,13 +803,20 @@ mem_copy_benchmark(struct test_configure*cfg, bool
is_dma)Quoted 27 lines
app/test-dma-perf/benchmark.c +8
-1rte_mempool_free (dst_pool); dst_pool =NULL ; +/* free sges for mbufs */ +rte_free (src_sges); + src_sges =NULL ; + +rte_free (dst_sges); + dst_sges =NULL ; +/* free the worker parameters */ for (i =0 ; i < nb_workers; i++) {rte_free (lcores[i]); lcores[i] =NULL ; } -if (is_dma) { +if (cfg->is_dma) {for (i =0 ; i < nb_workers; i++) {printf ("Stopping dmadev %d\n" , ldm->dma_ids[i]);rte_dma_stop (ldm->dma_ids[i]);app/test-dma-perf/config.ini +0
-0@@ -38,6 +38,14 @@
Quoted 9 lines
app/test-dma-perf/config.ini line 39
Quoted 1 line
app/test-dma-perf/config.ini +0
-0; "skip" To skip a test-case set skip to 1.Please place hese patchset new add entrys' descriptions above the
"; To specify a configuration file, use the "--config" flag followed by the path to the file."because original config.ini, fist is parameters descriptor, and then program argment descriptor, and last was example.
Ack.
Quoted 5 lines
app/test-dma-perf/config.ini line 41
Quoted 2 lines
app/test-dma-perf/config.ini +1
-0+; Parameters to be configured for SG copy:Parameters for DMA scatter-gather memory copy:
Ack.
Quoted 4 lines
app/test-dma-perf/config.ini line 42
Quoted 1 line
app/test-dma-perf/config.ini +1
-0+; ========================================Please remove this line
Ack.
Quoted 11 lines
app/test-dma-perf/config.ini
Quoted 4 lines
app/test-dma-perf/config.ini +4
-0+; "dma_src_sge" denotes number of source segments. +; "dma_dst_sge" denotes number of destination segments. +; +; For SG copy, both the parameters need to be configured and they are validonly
app/test-dma-perf/config.ini line 47
Quoted 1 line
app/test-dma-perf/config.ini +1
-0+; when type is DMA_MEM_COPY.For DMA scatter-gather memory copy, the parameters need to be configured and they are valid only
when type isDMA_MEM_COPY.
Ack.
Quoted 115 lines
app/test-dma-perf/config.ini line 48
Quoted 2 lines
app/test-dma-perf/config.ini +1
-0+; ; Parameters to be configured for data transfers from "mem to dev" and"dev to mem":
app/test-dma-perf/config.ini line 49
Quoted 1 line
app/test-dma-perf/config.ini +0
-0;===================================================================
===============Please remove this line
As another commit "Re: [PATCH v2] app/dma-perf: support bi-directional transfer"'s review feedback,
these descriptor should place after
"
; To use DMA for a test, please specify the "lcore_dma" parameter.
; If you have already set the "-l" and "-a" parameters using EAL,
; make sure that the value of "lcore_dma" falls within their range of the values. ; We have to ensure a 1:1 mapping between the core and DMA device.
"app/test-dma-perf/config.ini lcore_dma=lcore10@0000:00:04.2,
Quoted 2 lines
app/test-dma-perf/config.ini +0
-0; "direction" denotes the direction of data transfer. It can take 3 values:@@ -69,6 +77,21 @@ lcore_dma=lcore10@0000:00:04.2,lcore11@0000:00:04.3
Quoted 47 lines
app/test-dma-perf/config.ini +16
-1eal_args=--in-memory --file-prefix=test [case2] +type=DMA_MEM_COPY +mem_size=10 +buf_size=64,8192,2,MUL +dma_ring_size=1024 +dma_src_sge=4 +dma_dst_sge=1 +kick_batch=32 +src_numa_node=0 +dst_numa_node=0 +cache_flush=0 +test_seconds=2 +lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 +eal_args=--in-memory --file-prefix=test + +[case3] skip=1 type=DMA_MEM_COPY direction=dev2mem@@ -84,7 +107,7 @@ test_seconds=2 lcore_dma=lcore10@0000:00:04.2, lcore11@0000:00:04.3 eal_args=--in-memory --file-prefix=test -[case3] +[case4] type=CPU_MEM_COPY mem_size=10 buf_size=64,8192,2,MULapp/test-dma-perf/main.c +1
-3@@ -108,10 +108,8 @@ run_test_case(struct test_configure *case_cfg)switch (case_cfg->test_type) {case TEST_TYPE_DMA_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, true); -break ;case TEST_TYPE_CPU_MEM_COPY : - ret =mem_copy_benchmark (case_cfg, false); + ret =mem_copy_benchmark (case_cfg);break ;default :printf ("Unknown test type. %s\n" , case_cfg->test_type_str);app/test-dma-perf/main.c load_configs(const char *path) · line 368
Quoted 4 lines
app/test-dma-perf/main.c +0
-1@@ -365,7 +363,8 @@ load_configs(const char *path)const char *case_type;const char *transfer_dir;const char *lcore_dma; - const char *mem_size_str, *buf_size_str, *ring_size_str,
*kick_batch_str;app/test-dma-perf/main.c load_configs(const char *path) · line 366
Quoted 1 line
app/test-dma-perf/main.c +1
-0+ const char *mem_size_str, *buf_size_str, *ring_size_str,
*kick_batch_str,app/test-dma-perf/main.c load_configs(const char *path) · line 470
Quoted 10 lines
app/test-dma-perf/main.c +2
-0+ *src_ptrs_str, *dst_ptrs_str;const char *skip;struct rte_kvargs *kvlist;const char *vchan_dev;@@ -467,6 +466,7 @@ load_configs(const char *path)rte_kvargs_free (kvlist); } + test_case->is_dma = is_dma; test_case->src_numa_node =(int)atoi(rte_cfgfile_get_entry(cfgfile,
Quoted 1 line
section_name, "src_numa_node"));Quoted 1 line
test_case->dst_numa_node=(int)atoi(rte_cfgfile_get_entry(cfgfile,
app/test-dma-perf/main.c load_configs(const char *path) · line 504
Quoted 5 lines
app/test-dma-perf/main.c +1
-0@@ -501,6 +501,32 @@ load_configs(const char *path) }else if (args_nr ==4 ) nb_vp++; + src_ptrs_str = rte_cfgfile_get_entry(cfgfile,
section_name,app/test-dma-perf/main.c load_configs(const char *path) · line 505
Quoted 1 line
app/test-dma-perf/main.c +1
-0+"dma_src_sge");app/test-dma-perf/main.c load_configs(const char *path) · line 507
Quoted 2 lines
app/test-dma-perf/main.c +2
-0+if (src_ptrs_str !=NULL ) { + test_case->src_ptrs =(int)atoi(rte_cfgfile_get_entry(cfgfile,
app/test-dma-perf/main.c load_configs(const char *path) · line 508
Quoted 1 line
app/test-dma-perf/main.c +1
-0+section_name, "dma_src_sge"));app/test-dma-perf/main.c load_configs(const char *path) · line 511
Quoted 3 lines
app/test-dma-perf/main.c +3
-0+ } + + dst_ptrs_str = rte_cfgfile_get_entry(cfgfile,
section_name,app/test-dma-perf/main.c load_configs(const char *path) · line 512
Quoted 1 line
app/test-dma-perf/main.c +1
-0+"dma_dst_sge");app/test-dma-perf/main.c load_configs(const char *path) · line 514
Quoted 2 lines
app/test-dma-perf/main.c +2
-0+if (dst_ptrs_str !=NULL ) { + test_case->dst_ptrs =(int)atoi(rte_cfgfile_get_entry(cfgfile,
app/test-dma-perf/main.c load_configs(const char *path) · line 515
Quoted 1 line
app/test-dma-perf/main.c +1
-0+
Quoted 8 lines
section_name, "dma_dst_sge"));app/test-dma-perf/main.c load_configs(const char *path) · line 519
Quoted 4 lines
app/test-dma-perf/main.c +4
-0+ } + +if ((src_ptrs_str !=NULL && dst_ptrs_str ==NULL ) || + (src_ptrs_str ==NULL && dst_ptrs_str !=NULL )) {Please also check
test_case->src_ptrsandtest_case->dst_ptrsvalid, make sure there are >1 and <=UINT16_MAX
At present, this is uint8_t. Do we need it more than UINT8_MAX ?
Quoted 8 lines
app/test-dma-perf/main.c load_configs(const char *path) · line 520
Quoted 2 lines
app/test-dma-perf/main.c +1
-0+ printf("parse dma_src_sge, dma_dst_sge errorin case %d.\n",
app/test-dma-perf/main.c load_configs(const char *path)
Quoted 4 lines
app/test-dma-perf/main.c +4
-0+ i + 1); + test_case->is_valid = false; +continue ; + }else if (src_ptrs_str !=NULL && dst_ptrs_str !=NULL ){
Quoted 7 lines
app/test-dma-perf/main.c load_configs(const char *path) · line 527
Quoted 3 lines
app/test-dma-perf/main.c +3
-0+ test_case->is_sg = true; + }else { + test_case->is_sg = false;the above could simple by:
test_case->is_sg= (src_ptrs_str!= NULL &&dst_ptrs_str!= NULL);
Added check for nb_ validation here. Please check in next version of patch.
Quoted 30 lines
app/test-dma-perf/main.c load_configs(const char *path) · line 530
Quoted 3 lines
app/test-dma-perf/main.c +2
-0+ } + kick_batch_str = rte_cfgfile_get_entry(cfgfile,
section_name, "kick_batch");Quoted 26 lines
app/test-dma-perf/main.c +0
-0args_nr =parse_entry (kick_batch_str, &test_case- kick_batch);app/test-dma-perf/main.c +0
-0if (args_nr <0 ) {app/test-dma-perf/main.h +3
-0@@ -53,11 +53,14 @@ struct test_configure {uint16_t dst_numa_node;uint16_t opcode;bool is_dma; +bool is_sg;struct lcore_dma_map_t lcore_dma_map;struct test_configure_entry mem_size;struct test_configure_entry buf_size;struct test_configure_entry ring_size;struct test_configure_entry kick_batch; +uint8_t src_ptrs; +uint8_t dst_ptrs;uint8_t cache_flush;uint32_t nr_buf;uint16_t test_secs;@@ -66,6 +69,6 @@ struct test_configure {struct test_vchan_dev_config vchan_dev; };
Quoted 5 lines
app/test-dma-perf/main.h struct test_configure { · line 74
Quoted 5 lines
app/test-dma-perf/main.h +1
-1-int mem_copy_benchmark (struct test_configure *cfg,bool is_dma); +int mem_copy_benchmark (struct test_configure *cfg);#endif /* MAIN_H */
Thank you for your review. Please confirm if there are any other changes and I hope next version goes through 😊
Regards,
Gowrishankar