diff mbox series

[09/11] app: hook in EAL usage help

Message ID 20210309233116.1934666-10-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers show
Series improve options help | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon March 9, 2021, 11:31 p.m. UTC
Use rte_set_application_usage_hook() in the test applications,
so the full help including EAL options can be printed in one go
with the EAL option -h or --help.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/pdump/main.c                                 | 2 ++
 app/proc-info/main.c                             | 2 ++
 app/test-acl/main.c                              | 2 ++
 app/test-bbdev/main.c                            | 3 ++-
 app/test-compress-perf/comp_perf_options.h       | 2 ++
 app/test-compress-perf/comp_perf_options_parse.c | 8 ++++----
 app/test-compress-perf/main.c                    | 3 ++-
 app/test-crypto-perf/cperf_options.h             | 2 ++
 app/test-crypto-perf/cperf_options_parsing.c     | 8 ++++----
 app/test-crypto-perf/main.c                      | 3 ++-
 app/test-fib/main.c                              | 8 ++++++++
 app/test-flow-perf/main.c                        | 4 +++-
 app/test-pmd/parameters.c                        | 4 ++--
 app/test-pmd/testpmd.c                           | 2 ++
 app/test-pmd/testpmd.h                           | 1 +
 app/test-regex/main.c                            | 3 ++-
 app/test-sad/main.c                              | 7 +++++++
 17 files changed, 49 insertions(+), 15 deletions(-)

Comments

Wisam Monther March 10, 2021, 9:25 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, March 10, 2021 1:31 AM
> To: dev@dpdk.org
> Cc: david.marchand@redhat.com; Reshma Pattan
> <reshma.pattan@intel.com>; Maryam Tahhan
> <maryam.tahhan@intel.com>; Konstantin Ananyev
> <konstantin.ananyev@intel.com>; Nicolas Chautru
> <nicolas.chautru@intel.com>; Declan Doherty <declan.doherty@intel.com>;
> Ciara Power <ciara.power@intel.com>; Vladimir Medvedkin
> <vladimir.medvedkin@intel.com>; Wisam Monther <wisamm@nvidia.com>;
> Xiaoyun Li <xiaoyun.li@intel.com>; Ori Kam <orika@nvidia.com>; Bernard
> Iremonger <bernard.iremonger@intel.com>
> Subject: [PATCH 09/11] app: hook in EAL usage help
> 
> Use rte_set_application_usage_hook() in the test applications, so the full
> help including EAL options can be printed in one go with the EAL option -h or -
> -help.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Acked-by: Wisam Jaddo <wisamm@nvidia.com>

BRs,
Wisam Jaddo
diff mbox series

Patch

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 63bbe65cd8..8641017f48 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -974,6 +974,8 @@  main(int argc, char **argv)
 	char mp_flag[] = "--proc-type=secondary";
 	char *argp[argc + 2];
 
+	rte_set_application_usage_hook(pdump_usage);
+
 	/* catch ctrl-c so we can print on exit */
 	signal(SIGINT, signal_handler);
 
diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index b9587f7ded..e7d86bfa9d 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1361,6 +1361,8 @@  main(int argc, char **argv)
 	char *argp[argc + 4];
 	uint16_t nb_ports;
 
+	rte_set_application_usage_hook(proc_info_usage);
+
 	/* preparse app arguments */
 	ret = proc_info_preparse_args(argc, argv);
 	if (ret < 0) {
diff --git a/app/test-acl/main.c b/app/test-acl/main.c
index 2cb2fe2579..9f95cb0fbf 100644
--- a/app/test-acl/main.c
+++ b/app/test-acl/main.c
@@ -1080,6 +1080,8 @@  main(int argc, char **argv)
 	int ret;
 	uint32_t lcore;
 
+	rte_set_application_usage_hook(print_usage);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		rte_panic("Cannot init EAL\n");
diff --git a/app/test-bbdev/main.c b/app/test-bbdev/main.c
index ff65173fdb..5960ec18b2 100644
--- a/app/test-bbdev/main.c
+++ b/app/test-bbdev/main.c
@@ -340,7 +340,8 @@  main(int argc, char **argv)
 {
 	int ret;
 
-	/* Init EAL */
+	rte_set_application_usage_hook(print_usage);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		return 1;
diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h
index 0b777521c5..7dd785fba1 100644
--- a/app/test-compress-perf/comp_perf_options.h
+++ b/app/test-compress-perf/comp_perf_options.h
@@ -73,6 +73,8 @@  struct comp_test_data {
 	uint32_t cyclecount_delay;
 };
 
+void comp_perf_usage(const char *progname);
+
 int
 comp_perf_options_parse(struct comp_test_data *test_data, int argc,
 			char **argv);
diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c
index 019eddb7bd..39d7fd8c69 100644
--- a/app/test-compress-perf/comp_perf_options_parse.c
+++ b/app/test-compress-perf/comp_perf_options_parse.c
@@ -38,8 +38,8 @@  struct name_id_map {
 	uint32_t id;
 };
 
-static void
-usage(char *progname)
+void
+comp_perf_usage(const char *progname)
 {
 	printf("%s [EAL options] --\n"
 		" --ptest throughput / verify / pmd-cyclecount\n"
@@ -619,7 +619,7 @@  comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv)
 	while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) {
 		switch (opt) {
 		case 'h':
-			usage(argv[0]);
+			comp_perf_usage(argv[0]);
 			exit(EXIT_SUCCESS);
 			break;
 		/* long options */
@@ -631,7 +631,7 @@  comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv)
 			break;
 
 		default:
-			usage(argv[0]);
+			comp_perf_usage(argv[0]);
 			return -EINVAL;
 		}
 	}
diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index cc9951a9b1..dcd347528e 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -323,7 +323,8 @@  main(int argc, char **argv)
 	uint8_t cdev_id;
 	uint32_t lcore_id;
 
-	/* Initialise DPDK EAL */
+	rte_set_application_usage_hook(comp_perf_usage);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n");
diff --git a/app/test-crypto-perf/cperf_options.h b/app/test-crypto-perf/cperf_options.h
index 9664a4b343..5f4a780614 100644
--- a/app/test-crypto-perf/cperf_options.h
+++ b/app/test-crypto-perf/cperf_options.h
@@ -153,6 +153,8 @@  struct cperf_options {
 	uint8_t imix_distribution_count;
 };
 
+void cperf_usage(const char *progname);
+
 void
 cperf_options_default(struct cperf_options *options);
 
diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index 40b6dfb648..3777bc7509 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -19,8 +19,8 @@  struct name_id_map {
 	uint32_t id;
 };
 
-static void
-usage(char *progname)
+void
+cperf_usage(const char *progname)
 {
 	printf("%s [EAL options] --\n"
 		" --silent: disable options dump\n"
@@ -982,7 +982,7 @@  cperf_options_parse(struct cperf_options *options, int argc, char **argv)
 	while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) {
 		switch (opt) {
 		case 'h':
-			usage(argv[0]);
+			cperf_usage(argv[0]);
 			exit(EXIT_SUCCESS);
 			break;
 		/* long options */
@@ -994,7 +994,7 @@  cperf_options_parse(struct cperf_options *options, int argc, char **argv)
 			break;
 
 		default:
-			usage(argv[0]);
+			cperf_usage(argv[0]);
 			return -EINVAL;
 		}
 	}
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 49af812d8b..497c4c5226 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -519,7 +519,8 @@  main(int argc, char **argv)
 	int ret;
 	uint32_t lcore_id;
 
-	/* Initialise DPDK EAL */
+	rte_set_application_usage_hook(cperf_usage);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n");
diff --git a/app/test-fib/main.c b/app/test-fib/main.c
index b0a97b0d7e..420fe17c39 100644
--- a/app/test-fib/main.c
+++ b/app/test-fib/main.c
@@ -648,6 +648,12 @@  print_usage(void)
 		config.prgname);
 }
 
+static void
+usage_hook(const char *prgname __rte_unused)
+{
+	print_usage();
+}
+
 static int
 check_config(void)
 {
@@ -1209,6 +1215,8 @@  main(int argc, char **argv)
 	FILE *fl = NULL;
 	uint8_t depth_lim;
 
+	rte_set_application_usage_hook(usage_hook);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		rte_panic("Cannot init EAL\n");
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 0aef767350..949a5e3e11 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -115,7 +115,7 @@  static struct multi_cores_pool mc_pool = {
 };
 
 static void
-usage(char *progname)
+usage(const char *progname)
 {
 	printf("\nusage: %s\n", progname);
 	printf("\nControl configurations:\n");
@@ -1849,6 +1849,8 @@  main(int argc, char **argv)
 	uint16_t port;
 	struct rte_flow_error error;
 
+	rte_set_application_usage_hook(usage);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "EAL init failed\n");
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 55ecea6338..7f41021d4d 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -46,8 +46,8 @@ 
 
 #include "testpmd.h"
 
-static void
-usage(char* progname)
+void
+usage(const char *progname)
 {
 	printf("usage: %s [EAL options] -- "
 #ifdef RTE_LIB_CMDLINE
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1a57324b1b..1a60830037 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3771,6 +3771,8 @@  main(int argc, char** argv)
 		rte_exit(EXIT_FAILURE, "Cannot register log type");
 	rte_log_set_level(testpmd_logtype, RTE_LOG_DEBUG);
 
+	rte_set_application_usage_hook(usage);
+
 	diag = rte_eal_init(argc, argv);
 	if (diag < 0)
 		rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n",
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index ce83f31f0d..37348246f8 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -763,6 +763,7 @@  inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)
 unsigned int parse_item_list(char* str, const char* item_name,
 			unsigned int max_items,
 			unsigned int *parsed_items, int check_unique_values);
+void usage(const char *progname);
 void launch_args_parse(int argc, char** argv);
 void cmdline_read_from_file(const char *filename);
 void prompt(void);
diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 7bb87bb1b8..ba09b20126 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -616,7 +616,8 @@  main(int argc, char **argv)
 	uint32_t i;
 	struct qps_per_lcore *qps_per_lcore;
 
-	/* Init EAL. */
+	rte_set_application_usage_hook(usage);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "EAL init failed\n");
diff --git a/app/test-sad/main.c b/app/test-sad/main.c
index 1024757add..14a8263f8c 100644
--- a/app/test-sad/main.c
+++ b/app/test-sad/main.c
@@ -149,7 +149,12 @@  print_usage(void)
 		"[-p <parallel lookup on all available cores>]\n"
 		"[-c <init sad supporting read/write concurrency>]\n",
 		config.prgname);
+}
 
+static void
+usage_hook(const char *prgname __rte_unused)
+{
+	print_usage();
 }
 
 static int
@@ -620,6 +625,8 @@  main(int argc, char **argv)
 	struct rte_ipsec_sad_conf conf = {0};
 	unsigned int lcore_id;
 
+	rte_set_application_usage_hook(usage_hook);
+
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		rte_panic("Cannot init EAL\n");