From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 8F63C1BD0F for ; Thu, 20 Dec 2018 18:07:18 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id q18so2524437wrx.9 for ; Thu, 20 Dec 2018 09:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TGnxPXPdq0yaEqE6pmJxxStUY2QI/1SenqJI0IH2H3c=; b=HK71wVZdaQ3ZjC/EWq0X2W+XHxTc3C70JEQCm67Xf5f9z0Zm9HnIIk8DXmP0et9OFn IzNCBjELveEcqAwuyMiQKYEmE0jY2/uBMhASgiQacZ9mFTANkmARF6GWGaIOaKz6SOfI nGaA61AEk3WViVhO9b8HrxzOctTS4uca9ett72qslctYR2GKM4UMsj//+0qy/io/eIW2 F2wM4oeSi7rofmSXuXXUFfu3nWFTt0OxdYRUIt4zbC9odJJtWCgsHphQcThXKvqcykdQ tXEuZDgaL0RnlXF/c2vymsyxOLAMY/R/zJLr/BtbLMW0XEjpkn26Qy14SynbHvS54UrW rD2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TGnxPXPdq0yaEqE6pmJxxStUY2QI/1SenqJI0IH2H3c=; b=Ral5pr//cTY6Hy6KqdoP2Y0byY6San83hleGf9L41nge0EoH+JNI7yftBHkg+3fdVB UK4jY86XoAkYP7kUMtzkxSdxAvOjlMhpgdte710MdagInJdPrvsLLQY5nQwQYa9beuty RBxjIdOI+WrkjFr3OGjjQh7URDutlvo8rjlLG5xHWAOfZ3n1/rboP6+FWNP86FEE/zV6 0ytXDK0WUFYPYAHbwudae+4xhUw24FJLUGH72TqMTrFJvDN4hNCjYUKVSN6tFDMQt6cR nMO1JuGuu9ml1rtajtyKrYmRrKfQAbB2moYMhrNSNyEoaMw6il7QjB9voGMHPe52paHK Q7Gg== X-Gm-Message-State: AA+aEWbEh0HdPR9VcNcgkLsYbarIxppG0TqjoBztlS0mZY9i5shhmjrU IBFSChTFigCtJDyGFJTcR8A2djarcOQ= X-Google-Smtp-Source: AFSGD/XIFSyjfae1DjEpn1nHyWfThMei2aEEIcVoU7bih2Q0pebDv8Hg59d12mHzdvnt5R28b3um+w== X-Received: by 2002:adf:c7cc:: with SMTP id y12mr24290538wrg.52.1545325637739; Thu, 20 Dec 2018 09:07:17 -0800 (PST) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id n5sm11951688wrr.94.2018.12.20.09.07.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:16 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:42 +0100 Message-Id: <1f284decd3c8d5398d6d0fb5ef7cc024562dc219.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 3/8] option: add usage string X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2018 17:07:18 -0000 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 --- 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