diff mbox series

[v5,4/4] app: hook in EAL usage help

Message ID 20210405193954.1115838-5-thomas@monjalon.net (mailing list archive)
State New
Delegated to: David Marchand
Headers show
Series improve options help | expand

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon April 5, 2021, 7:39 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>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 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

Jerin Jacob April 6, 2021, 1:32 p.m. UTC | #1
On Tue, Apr 6, 2021 at 1:10 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 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>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
>  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 +++++++

>
> +       rte_set_application_usage_hook(print_usage);

All DPDK APIs, We are having rte_<subsystem><...><verb> kind of API
name convention.
I think, it is better to change to rte_application_usage_hook_set() to
express the hierarchy.
Thomas Monjalon April 6, 2021, 2:05 p.m. UTC | #2
06/04/2021 15:32, Jerin Jacob:
> On Tue, Apr 6, 2021 at 1:10 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > 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.
[...]
> > +       rte_set_application_usage_hook(print_usage);
> 
> All DPDK APIs, We are having rte_<subsystem><...><verb> kind of API
> name convention.
> I think, it is better to change to rte_application_usage_hook_set() to
> express the hierarchy.

The naming of this function is not fantastic.
Without thinking about a better name, we should ask if we want to go
through a deprecation of this function name?
Jerin Jacob April 6, 2021, 2:13 p.m. UTC | #3
On Tue, Apr 6, 2021 at 7:35 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 06/04/2021 15:32, Jerin Jacob:
> > On Tue, Apr 6, 2021 at 1:10 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > >
> > > 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.
> [...]
> > > +       rte_set_application_usage_hook(print_usage);
> >
> > All DPDK APIs, We are having rte_<subsystem><...><verb> kind of API
> > name convention.
> > I think, it is better to change to rte_application_usage_hook_set() to
> > express the hierarchy.
>
> The naming of this function is not fantastic.
> Without thinking about a better name, we should ask if we want to go
> through a deprecation of this function name?

I thought it is a new function introduced by this series. Ignore my
comment as the function is already present in the codebase.


>
>
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 f3954c1c63..4a1d64af89 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("\nUsage: %s [EAL options] -- [testpmd options]\n\n",
 	       progname);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 96d2e0fcec..007ae429a1 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3781,6 +3781,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 a87ccb0f0f..1f9408ebb9 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -764,6 +764,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 f18dc2eef8..73ba227fba 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");