From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 705B946CFC; Mon, 11 Aug 2025 12:54:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EBA5940B98; Mon, 11 Aug 2025 12:54:37 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id B7C4E4013F for ; Mon, 11 Aug 2025 12:54:33 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4c0rx95WvKz14MQ7; Mon, 11 Aug 2025 18:49:33 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 4861518048D; Mon, 11 Aug 2025 18:54:32 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 11 Aug 2025 18:54:31 +0800 From: Chengwen Feng To: CC: , Subject: [PATCH 2/9] app/dma-perf: add global section for config file Date: Mon, 11 Aug 2025 18:54:23 +0800 Message-ID: <20250811105430.55791-3-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250811105430.55791-1-fengchengwen@huawei.com> References: <20250811105430.55791-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemk500009.china.huawei.com (7.202.194.94) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This commit add global section which contains 'eal_args' entry which specifies the EAL arguments for all testcases currently. With this commit, users no longer need to enter EAL arguments on the command line. Signed-off-by: Chengwen Feng --- app/test-dma-perf/config.ini | 15 +++--- app/test-dma-perf/main.c | 89 +++++++++++++++++------------------- app/test-dma-perf/main.h | 8 +++- doc/guides/tools/dmaperf.rst | 26 +++++++---- 4 files changed, 74 insertions(+), 64 deletions(-) diff --git a/app/test-dma-perf/config.ini b/app/test-dma-perf/config.ini index 61e49dbae5..80cbcbb762 100644 --- a/app/test-dma-perf/config.ini +++ b/app/test-dma-perf/config.ini @@ -4,7 +4,11 @@ ; Supported test types are DMA_MEM_COPY and CPU_MEM_COPY. -; Parameters: +; There are two types of configuration sections: global configuration and testcase configuration. +; The global section contains the "eal_args" entry which specifies the EAL arguments for all +; testcases. + +; The testcase configuration contains following parameters: ; "mem_size" denotes the size of the memory footprint in megabytes (MB) for source and destination. ; "buf_size" denotes the memory size of a single operation in bytes (B). ; "dma_ring_size" denotes the dma ring buffer size. It should be must be a power of two, and between @@ -59,6 +63,9 @@ ; 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. +[GLOBAL] +eal_args=--in-memory --file-prefix=test -l 9-12 + [case1] type=DMA_MEM_COPY mem_size=10 @@ -71,7 +78,6 @@ cache_flush=0 test_seconds=2 lcore_dma0=lcore=10,dev=0000:00:04.1,dir=mem2mem lcore_dma1=lcore=11,dev=0000:00:04.2,dir=mem2mem -eal_args=--in-memory --file-prefix=test [case2] type=DMA_MEM_COPY @@ -87,7 +93,6 @@ cache_flush=0 test_seconds=2 lcore_dma0=lcore=10,dev=0000:00:04.1,dir=mem2mem lcore_dma1=lcore=11,dev=0000:00:04.2,dir=mem2mem -eal_args=--in-memory --file-prefix=test [case3] skip=1 @@ -103,7 +108,6 @@ test_seconds=2 lcore_dma0=lcore=10,dev=0000:00:04.1,dir=mem2mem lcore_dma1=lcore=11,dev=0000:00:04.2,dir=dev2mem,raddr=0x200000000,coreid=1,pfid=2,vfid=3 lcore_dma2=lcore=12,dev=0000:00:04.3,dir=mem2dev,raddr=0x300000000,coreid=3,pfid=2,vfid=1 -eal_args=--in-memory --file-prefix=test [case4] type=CPU_MEM_COPY @@ -113,5 +117,4 @@ src_numa_node=0 dst_numa_node=1 cache_flush=0 test_seconds=2 -lcore = 3, 4 -eal_args=--in-memory --no-pci +lcore = 10, 11 diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c index 25a79d1d6c..54a5e573fc 100644 --- a/app/test-dma-perf/main.c +++ b/app/test-dma-perf/main.c @@ -23,9 +23,6 @@ #define CSV_HDR_FMT "Case %u : %s,lcore,DMA,DMA ring size,kick batch size,buffer size(B),number of buffers,memory(MB),average cycle,bandwidth(Gbps),MOps\n" -#define MAX_EAL_PARAM_NB 100 -#define MAX_EAL_PARAM_LEN 1024 - #define DMA_MEM_COPY "DMA_MEM_COPY" #define CPU_MEM_COPY "CPU_MEM_COPY" @@ -45,6 +42,9 @@ enum { #define MAX_TEST_CASES 16 static struct test_configure test_cases[MAX_TEST_CASES]; +#define GLOBAL_SECTION_NAME "GLOBAL" +static struct global_configure global_cfg; + char output_str[MAX_WORKER_NB + 1][MAX_OUTPUT_STR_LEN]; static FILE *fd; @@ -288,6 +288,40 @@ static int populate_dma_dev_config(const char *key, const char *value, void *tes return ret; } +static int +parse_global_config(struct rte_cfgfile *cfgfile) +{ + char *tokens[MAX_EAL_ARGV_NB]; + const char *entry; + int token_nb; + char *args; + int ret; + int i; + + ret = rte_cfgfile_num_sections(cfgfile, GLOBAL_SECTION_NAME, strlen(GLOBAL_SECTION_NAME)); + if (ret != 1) { + printf("Error: GLOBAL section not exist or has multiple!\n"); + return -1; + } + + entry = rte_cfgfile_get_entry(cfgfile, GLOBAL_SECTION_NAME, "eal_args"); + if (entry == NULL) { + printf("Error: GLOBAL section must have 'eal_args' entry!\n"); + return -1; + } + args = strdup(entry); + if (args == NULL) { + printf("Error: dup GLOBAL 'eal_args' failed!\n"); + return -1; + } + token_nb = rte_strsplit(args, strlen(args), tokens, MAX_EAL_ARGV_NB, ' '); + for (i = 0; i < token_nb; i++) + global_cfg.eal_argv[i] = tokens[i]; + global_cfg.eal_argc = i; + + return 0; +} + static uint16_t load_configs(const char *path) { @@ -311,7 +345,10 @@ load_configs(const char *path) exit(1); } - nb_sections = rte_cfgfile_num_sections(cfgfile, NULL, 0); + if (parse_global_config(cfgfile) != 0) + exit(1); + + nb_sections = rte_cfgfile_num_sections(cfgfile, NULL, 0) - 1; if (nb_sections > MAX_TEST_CASES) { printf("Error: The maximum number of cases is %d.\n", MAX_TEST_CASES); exit(1); @@ -479,9 +516,6 @@ load_configs(const char *path) test_case->test_secs = (uint16_t)atoi(rte_cfgfile_get_entry(cfgfile, section_name, "test_seconds")); - test_case->eal_args = rte_cfgfile_get_entry(cfgfile, section_name, "eal_args"); - if (test_case->eal_args != NULL) - test_case->eal_args = strdup(test_case->eal_args); test_case->is_valid = true; } @@ -490,36 +524,6 @@ load_configs(const char *path) return i; } -/* Parse the argument given in the command line of the application */ -static int -append_eal_args(int argc, char **argv, const char *eal_args, char **new_argv) -{ - int i; - char *tokens[MAX_EAL_PARAM_NB]; - char args[MAX_EAL_PARAM_LEN] = {0}; - int token_nb, new_argc = 0; - - for (i = 0; i < argc; i++) { - if ((strcmp(argv[i], CMDLINE_CONFIG_ARG) == 0) || - (strcmp(argv[i], CMDLINE_RESULT_ARG) == 0)) { - i++; - continue; - } - strlcpy(new_argv[new_argc], argv[i], MAX_EAL_PARAM_LEN); - new_argc++; - } - - if (eal_args) { - strlcpy(args, eal_args, MAX_EAL_PARAM_LEN); - token_nb = rte_strsplit(args, strlen(args), - tokens, MAX_EAL_PARAM_NB, ' '); - for (i = 0; i < token_nb; i++) - strlcpy(new_argv[new_argc++], tokens[i], MAX_EAL_PARAM_LEN); - } - - return new_argc; -} - int main(int argc, char *argv[]) { @@ -528,17 +532,9 @@ main(int argc, char *argv[]) uint32_t i, nb_lcores; pid_t cpid, wpid; int wstatus; - char args[MAX_EAL_PARAM_NB][MAX_EAL_PARAM_LEN]; - char *pargs[MAX_EAL_PARAM_NB]; char *cfg_path_ptr = NULL; char *rst_path_ptr = NULL; char rst_path[PATH_MAX]; - int new_argc; - - memset(args, 0, sizeof(args)); - - for (i = 0; i < RTE_DIM(pargs); i++) - pargs[i] = args[i]; for (i = 0; i < (uint32_t)argc; i++) { if (strncmp(argv[i], CMDLINE_CONFIG_ARG, MAX_LONG_OPT_SZ) == 0) @@ -595,8 +591,7 @@ main(int argc, char *argv[]) } else if (cpid == 0) { printf("\nRunning case %u\n\n", i + 1); - new_argc = append_eal_args(argc, argv, test_cases[i].eal_args, pargs); - ret = rte_eal_init(new_argc, pargs); + ret = rte_eal_init(global_cfg.eal_argc, global_cfg.eal_argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h index 59eb648b3d..fa3a8ebf2e 100644 --- a/app/test-dma-perf/main.h +++ b/app/test-dma-perf/main.h @@ -69,10 +69,16 @@ struct test_configure { uint8_t cache_flush; uint32_t nr_buf; uint16_t test_secs; - const char *eal_args; uint8_t scenario_id; }; +#define MAX_EAL_ARGV_NB 100 + +struct global_configure { + char *eal_argv[MAX_EAL_ARGV_NB]; + int eal_argc; +}; + int mem_copy_benchmark(struct test_configure *cfg); #endif /* MAIN_H */ diff --git a/doc/guides/tools/dmaperf.rst b/doc/guides/tools/dmaperf.rst index b7ff41065f..51a9cc8df8 100644 --- a/doc/guides/tools/dmaperf.rst +++ b/doc/guides/tools/dmaperf.rst @@ -27,6 +27,9 @@ along with the application to demonstrate all the parameters. .. code-block:: ini + [GLOBAL] + eal_args=--in-memory --file-prefix=test -l 9-12 + [case1] type=DMA_MEM_COPY mem_size=10 @@ -39,7 +42,6 @@ along with the application to demonstrate all the parameters. test_seconds=2 lcore_dma0=lcore=10,dev=0000:00:04.2,dir=mem2mem lcore_dma0=lcore=11,dev=0000:00:04.3,dir=mem2mem - eal_args=--in-memory --file-prefix=test [case2] type=CPU_MEM_COPY @@ -49,8 +51,7 @@ along with the application to demonstrate all the parameters. dst_numa_node=1 cache_flush=0 test_seconds=2 - lcore = 3, 4 - eal_args=--in-memory --no-pci + lcore = 10, 11 [case3] skip=1 @@ -68,9 +69,10 @@ along with the application to demonstrate all the parameters. lcore_dma0=lcore=10,dev=0000:00:04.1,dir=mem2mem lcore_dma1=lcore=11,dev=0000:00:04.2,dir=dev2mem,raddr=0x200000000,coreid=1,pfid=2,vfid=3 lcore_dma2=lcore=12,dev=0000:00:04.3,dir=mem2dev,raddr=0x200000000,coreid=1,pfid=2,vfid=3 - eal_args=--in-memory --file-prefix=test -The configuration file is divided into multiple sections, each section represents a test case. +The configuration file is divided into two type sections, the first is global configuration +section; the second is testcase sections which contains multiple sections, each section +represents a test case. The four mandatory variables ``mem_size``, ``buf_size``, ``dma_ring_size``, and ``kick_batch`` can vary in each test case. The format for this is ``variable=first,last,increment,ADD|MUL``. @@ -88,8 +90,15 @@ Each case can only have one variable change, and each change will generate a scenario, so each case can have multiple scenarios. -Configuration Parameters -~~~~~~~~~~~~~~~~~~~~~~~~ +Global Configuration Parameters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``eal_args`` + Specifies the EAL arguments for all testcases. + + +Testcase Configuration Parameters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``skip`` To skip a test-case, must be configured as ``1`` @@ -167,9 +176,6 @@ Configuration Parameters ``lcore`` Specifies the lcore for CPU testing. -``eal_args`` - Specifies the EAL arguments. - Running the Application ----------------------- -- 2.17.1