From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v1 3/8] option: add usage string
Date: Thu, 20 Dec 2018 18:06:42 +0100 [thread overview]
Message-ID: <1f284decd3c8d5398d6d0fb5ef7cc024562dc219.1545325395.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1545325395.git.gaetan.rivet@6wind.com>
Add a usage string field in rte_option, allowing to display
help to the user and describe which options are currently available.
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_options.c | 1 +
lib/librte_eal/common/eal_private.h | 7 +++++++
lib/librte_eal/common/include/rte_option.h | 1 +
lib/librte_eal/common/rte_option.c | 17 +++++++++++++++++
lib/librte_telemetry/rte_telemetry.c | 1 +
5 files changed, 27 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 6e3a83b98..e096ac896 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -1494,4 +1494,5 @@ eal_common_usage(void)
" --"OPT_NO_HPET" Disable HPET\n"
" --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
"\n", RTE_MAX_LCORE);
+ rte_option_usage();
}
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 442c6dc48..50ab58385 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -370,4 +370,11 @@ rte_option_parse(const char *opt);
void
rte_option_init(void);
+/**
+ * Iterate through the registered options and show the associated
+ * usage string.
+ */
+void
+rte_option_usage(void);
+
#endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h
index 8957b970c..bbcc6cec9 100644
--- a/lib/librte_eal/common/include/rte_option.h
+++ b/lib/librte_eal/common/include/rte_option.h
@@ -35,6 +35,7 @@ typedef int (*rte_option_cb)(void);
struct rte_option {
TAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */
char *opt_str; /**< The option name. */
+ const char *usage; /**< Option summary string. */
rte_option_cb cb; /**< Function called when option is used. */
int enabled; /**< Set when the option is used. */
};
diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c
index 9e233f7d2..2ed74873b 100644
--- a/lib/librte_eal/common/rte_option.c
+++ b/lib/librte_eal/common/rte_option.c
@@ -61,3 +61,20 @@ rte_option_init(void)
option->cb();
}
}
+
+void
+rte_option_usage(void)
+{
+ struct rte_option *option;
+ int opt_count = 0;
+
+ TAILQ_FOREACH(option, &rte_option_list, next)
+ opt_count += 1;
+ if (opt_count == 0)
+ return;
+
+ printf("EAL dynamic options:\n");
+ TAILQ_FOREACH(option, &rte_option_list, next)
+ printf(" --%-*s %s\n", 17, option->opt_str, option->usage);
+ printf("\n");
+}
diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c
index 3080bb715..0ba6626c1 100644
--- a/lib/librte_telemetry/rte_telemetry.c
+++ b/lib/librte_telemetry/rte_telemetry.c
@@ -1799,6 +1799,7 @@ int telemetry_log_level;
static struct rte_option option = {
.opt_str = "telemetry",
+ .usage = "Enable telemetry backend",
.cb = &rte_telemetry_init,
.enabled = 0
};
--
2.19.1
next prev parent reply other threads:[~2018-12-20 17:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-20 17:06 [dpdk-dev] [PATCH v1 0/8] Clean up rte_option Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 1/8] option: use bare option string as name Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 2/8] option: do not use static iterator Gaetan Rivet
2018-12-20 17:06 ` Gaetan Rivet [this message]
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 4/8] option: rename name field Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 5/8] option: check against common option on register Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 6/8] option: fix log level of error in register Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 7/8] option: improve library documentation Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 8/8] option: return an error when register fail Gaetan Rivet
2019-01-15 1:23 ` [dpdk-dev] [PATCH v1 0/8] Clean up rte_option Thomas Monjalon
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=1f284decd3c8d5398d6d0fb5ef7cc024562dc219.1545325395.git.gaetan.rivet@6wind.com \
--to=gaetan.rivet@6wind.com \
--cc=dev@dpdk.org \
/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).