[v5,4/4] app: hook in EAL usage help
Checks
Commit Message
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
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.
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?
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.
>
>
This patch appears stuck in limbo.
Some comments.
On Mon, 5 Apr 2021 21:39:54 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:
> 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)
Why does the hook now need to be a non-static function. Should be possible for the
hook to still just be:
static void
usage(const char *progname);
Fits the principle of change as little as possible.
On Mon, 5 Apr 2021 21:39:54 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:
> From: Thomas Monjalon <thomas@monjalon.net>
> To: dev@dpdk.org
> Cc: david.marchand@redhat.com, Wisam Jaddo <wisamm@nvidia.com>, Bruce Richardson <bruce.richardson@intel.com>, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>, 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>, Xiaoyun Li <xiaoyun.li@intel.com>, Ori Kam <orika@nvidia.com>, Bernard Iremonger <bernard.iremonger@intel.com>
> Subject: [dpdk-dev] [PATCH v5 4/4] app: hook in EAL usage help
> Date: Mon, 5 Apr 2021 21:39:54 +0200
> Sender: "dev" <dev-bounces@dpdk.org>
> X-Mailer: git-send-email 2.31.1
>
> 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>
The patch makes sense, but no longer applies.
It needs to be rebased.
@@ -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);
@@ -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) {
@@ -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");
@@ -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;
@@ -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);
@@ -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;
}
}
@@ -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");
@@ -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);
@@ -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;
}
}
@@ -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");
@@ -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");
@@ -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");
@@ -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);
@@ -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",
@@ -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);
@@ -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");
@@ -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");