From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>
Cc: <dev@dpdk.org>, <liuyonglong@huawei.com>
Subject: [PATCH 2/9] app/dma-perf: add global section for config file
Date: Mon, 11 Aug 2025 18:54:23 +0800 [thread overview]
Message-ID: <20250811105430.55791-3-fengchengwen@huawei.com> (raw)
In-Reply-To: <20250811105430.55791-1-fengchengwen@huawei.com>
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 <fengchengwen@huawei.com>
---
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
next prev parent reply other threads:[~2025-08-11 10:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 10:54 [PATCH 0/9] bugfix and refactor of dma-perf Chengwen Feng
2025-08-11 10:54 ` [PATCH 1/9] app/dma-perf: fix use-after-free Chengwen Feng
2025-08-11 10:54 ` Chengwen Feng [this message]
2025-08-11 10:54 ` [PATCH 3/9] app/dma-perf: use argparse lib to parse argument Chengwen Feng
2025-08-11 10:54 ` [PATCH 4/9] app/dma-perf: refactor output csv Chengwen Feng
2025-08-11 10:54 ` [PATCH 5/9] app/dma-perf: support list DMA devices Chengwen Feng
2025-08-11 10:54 ` [PATCH 6/9] app/dma-perf: add more global config Chengwen Feng
2025-08-11 10:54 ` [PATCH 7/9] app/dma-perf: remove invalid or redundant field Chengwen Feng
2025-08-11 10:54 ` [PATCH 8/9] app/dma-perf: refactor load config function Chengwen Feng
2025-08-11 10:54 ` [PATCH 9/9] app/dma-perf: refactor benchmark function Chengwen Feng
2025-08-12 2:06 ` [PATCH 00/10] bugfix and refactor of dma-perf Chengwen Feng
2025-08-12 2:06 ` [PATCH 01/10] app/dma-perf: fix use-after-free Chengwen Feng
2025-08-12 2:07 ` [PATCH 02/10] app/dma-perf: add global section for config file Chengwen Feng
2025-08-12 2:07 ` [PATCH 03/10] app/dma-perf: use argparse lib to parse argument Chengwen Feng
2025-08-12 2:07 ` [PATCH 04/10] app/dma-perf: refactor output csv Chengwen Feng
2025-08-12 2:07 ` [PATCH 05/10] app/dma-perf: support list DMA devices Chengwen Feng
2025-08-12 2:07 ` [PATCH 06/10] app/dma-perf: add more global config Chengwen Feng
2025-08-12 2:07 ` [PATCH 07/10] app/dma-perf: remove invalid or redundant field Chengwen Feng
2025-08-12 2:07 ` [PATCH 08/10] app/dma-perf: refactor load config function Chengwen Feng
2025-08-12 2:07 ` [PATCH 09/10] app/dma-perf: refactor benchmark function Chengwen Feng
2025-08-12 2:07 ` [PATCH 10/10] app/dma-perf: support specific error info Chengwen Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250811105430.55791-3-fengchengwen@huawei.com \
--to=fengchengwen@huawei.com \
--cc=dev@dpdk.org \
--cc=liuyonglong@huawei.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).