From: Bruce Richardson <bruce.richardson@intel.com>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 05/10] eal: factorize options sanity check
Date: Tue, 25 Nov 2014 10:42:40 +0000 [thread overview]
Message-ID: <20141125104240.GE5260@bricha3-MOBL3> (raw)
In-Reply-To: <1416692622-28886-6-git-send-email-thomas.monjalon@6wind.com>
On Sat, Nov 22, 2014 at 10:43:37PM +0100, Thomas Monjalon wrote:
> No need to have duplicated check for common options.
>
> Some flags are set for options -c and -m in order to simplify the
> checks.
>
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> lib/librte_eal/bsdapp/eal/eal.c | 54 ++------------------------
> lib/librte_eal/common/eal_common_options.c | 53 ++++++++++++++++++++++++++
> lib/librte_eal/common/eal_options.h | 1 +
> lib/librte_eal/linuxapp/eal/eal.c | 61 ++++--------------------------
> 4 files changed, 66 insertions(+), 103 deletions(-)
>
> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
> index 391ce53..20a9c5f 100644
> --- a/lib/librte_eal/bsdapp/eal/eal.c
> +++ b/lib/librte_eal/bsdapp/eal/eal.c
> @@ -316,7 +316,6 @@ eal_parse_args(int argc, char **argv)
> int opt, ret, i;
> char **argvopt;
> int option_index;
> - int coremask_ok = 0;
> char *prgname = argv[0];
>
> argvopt = argv;
> @@ -339,13 +338,8 @@ eal_parse_args(int argc, char **argv)
> return -1;
> }
> /* common parser handled this option */
> - if (ret == 0) {
> - /* special case, note that the common parser accepted
> - * the coremask option */
> - if (opt == 'c')
> - coremask_ok = 1;
> + if (ret == 0)
> continue;
> - }
>
> switch (opt) {
> default:
> @@ -366,51 +360,11 @@ eal_parse_args(int argc, char **argv)
> }
> }
>
> - /* sanity checks */
> - if (!coremask_ok) {
> - RTE_LOG(ERR, EAL, "coremask not specified\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (internal_config.process_type == RTE_PROC_AUTO){
> + if (internal_config.process_type == RTE_PROC_AUTO)
> internal_config.process_type = eal_proc_type_detect();
> - }
> - if (internal_config.process_type == RTE_PROC_INVALID){
> - RTE_LOG(ERR, EAL, "Invalid process type specified\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (internal_config.process_type == RTE_PROC_PRIMARY &&
> - internal_config.force_nchannel == 0) {
> - RTE_LOG(ERR, EAL, "Number of memory channels (-n) not specified\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (index(internal_config.hugefile_prefix,'%') != NULL){
> - RTE_LOG(ERR, EAL, "Invalid char, '%%', in '"OPT_FILE_PREFIX"' option\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (internal_config.memory > 0 && internal_config.force_sockets == 1) {
> - RTE_LOG(ERR, EAL, "Options -m and --socket-mem cannot be specified "
> - "at the same time\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - /* --no-huge doesn't make sense with either -m or --socket-mem */
> - if (internal_config.no_hugetlbfs &&
> - (internal_config.memory > 0 ||
> - internal_config.force_sockets == 1)) {
> - RTE_LOG(ERR, EAL, "Options -m or --socket-mem cannot be specified "
> - "together with --no-huge!\n");
> - eal_usage(prgname);
> - return -1;
> - }
>
> - if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
> - rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
> - RTE_LOG(ERR, EAL, "Error: blacklist [-b] and whitelist "
> - "[-w] options cannot be used at the same time\n");
> + /* sanity checks */
> + if (eal_check_common_options(&internal_config) != 0) {
> eal_usage(prgname);
> return -1;
> }
> diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
> index ffc615a..630dfe0 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -85,6 +85,9 @@ eal_long_options[] = {
> {0, 0, 0, 0}
> };
>
> +static int lcores_parsed;
> +static int mem_parsed;
> +
> void
> eal_reset_internal_config(struct internal_config *internal_cfg)
> {
> @@ -197,6 +200,7 @@ eal_parse_coremask(const char *coremask)
> return -1;
> /* Update the count of enabled logical cores of the EAL configuration */
> cfg->lcore_count = count;
> + lcores_parsed = 1;
> return 0;
> }
>
> @@ -305,6 +309,7 @@ eal_parse_common_option(int opt, const char *optarg,
> conf->memory = atoi(optarg);
> conf->memory *= 1024ULL;
> conf->memory *= 1024ULL;
> + mem_parsed = 1;
> break;
> /* force number of channels */
> case 'n':
> @@ -394,6 +399,54 @@ eal_parse_common_option(int opt, const char *optarg,
> return 0;
> }
>
> +int
> +eal_check_common_options(struct internal_config *internal_cfg)
> +{
> + struct rte_config *cfg = rte_eal_get_configuration();
> +
> + if (!lcores_parsed) {
> + RTE_LOG(ERR, EAL, "CPU cores must be enabled with option "
> + "-c\n");
> + return -1;
> + }
> +
> + if (internal_cfg->process_type == RTE_PROC_INVALID) {
> + RTE_LOG(ERR, EAL, "Invalid process type specified\n");
> + return -1;
> + }
> + if (internal_cfg->process_type == RTE_PROC_PRIMARY &&
> + internal_cfg->force_nchannel == 0) {
> + RTE_LOG(ERR, EAL, "Number of memory channels (-n) not "
> + "specified\n");
> + return -1;
> + }
> + if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
> + RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
> + "option\n");
> + return -1;
> + }
> + if (mem_parsed && internal_cfg->force_sockets == 1) {
> + RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
> + "be specified at the same time\n");
> + return -1;
> + }
> + if (internal_cfg->no_hugetlbfs &&
> + (mem_parsed || internal_cfg->force_sockets == 1)) {
> + RTE_LOG(ERR, EAL, "Options -m or --"OPT_SOCKET_MEM" cannot "
> + "be specified together with --"OPT_NO_HUGE"\n");
> + return -1;
> + }
> +
> + if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
> + rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
> + RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
> + "cannot be used at the same time\n");
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> void
> eal_common_usage(void)
> {
> diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
> index 7a08507..75351c0 100644
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -83,6 +83,7 @@ extern const struct option eal_long_options[];
>
> int eal_parse_common_option(int opt, const char *argv,
> struct internal_config *conf);
> +int eal_check_common_options(struct internal_config *internal_cfg);
> void eal_common_usage(void);
>
> #endif /* EAL_OPTIONS_H */
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> index bb35669..f5de277 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -507,7 +507,6 @@ eal_parse_args(int argc, char **argv)
> int opt, ret, i;
> char **argvopt;
> int option_index;
> - int coremask_ok = 0;
> char *prgname = argv[0];
> struct shared_driver *solib;
>
> @@ -531,13 +530,8 @@ eal_parse_args(int argc, char **argv)
> return -1;
> }
> /* common parser handled this option */
> - if (ret == 0) {
> - /* special case, note that the common parser accepted
> - * the coremask option */
> - if (opt == 'c')
> - coremask_ok = 1;
> + if (ret == 0)
> continue;
> - }
>
> switch (opt) {
> /* force loading of external driver */
> @@ -622,58 +616,19 @@ eal_parse_args(int argc, char **argv)
> }
> }
>
> - /* sanity checks */
> - if (!coremask_ok) {
> - RTE_LOG(ERR, EAL, "coremask not specified\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (internal_config.process_type == RTE_PROC_AUTO){
> + if (internal_config.process_type == RTE_PROC_AUTO)
> internal_config.process_type = eal_proc_type_detect();
> - }
> - if (internal_config.process_type == RTE_PROC_INVALID){
> - RTE_LOG(ERR, EAL, "Invalid process type specified\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (internal_config.process_type == RTE_PROC_PRIMARY &&
> - internal_config.force_nchannel == 0) {
> - RTE_LOG(ERR, EAL, "Number of memory channels (-n) not specified\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (index(internal_config.hugefile_prefix,'%') != NULL){
> - RTE_LOG(ERR, EAL, "Invalid char, '%%', in '"OPT_FILE_PREFIX"' option\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - if (internal_config.memory > 0 && internal_config.force_sockets == 1) {
> - RTE_LOG(ERR, EAL, "Options -m and --socket-mem cannot be specified "
> - "at the same time\n");
> - eal_usage(prgname);
> - return -1;
> - }
> - /* --no-huge doesn't make sense with either -m or --socket-mem */
> - if (internal_config.no_hugetlbfs &&
> - (internal_config.memory > 0 ||
> - internal_config.force_sockets == 1)) {
> - RTE_LOG(ERR, EAL, "Options -m or --socket-mem cannot be specified "
> - "together with --no-huge!\n");
> +
> + /* sanity checks */
> + if (eal_check_common_options(&internal_config) != 0) {
> eal_usage(prgname);
> return -1;
> }
> +
> /* --xen-dom0 doesn't make sense with --socket-mem */
> if (internal_config.xen_dom0_support && internal_config.force_sockets == 1) {
> - RTE_LOG(ERR, EAL, "Options --socket-mem cannot be specified "
> - "together with --xen_dom0!\n");
> - eal_usage(prgname);
> - return -1;
> - }
> -
> - if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
> - rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
> - RTE_LOG(ERR, EAL, "Error: blacklist [-b] and whitelist "
> - "[-w] options cannot be used at the same time\n");
> + RTE_LOG(ERR, EAL, "Options --"OPT_SOCKET_MEM" cannot be specified "
> + "together with --"OPT_XEN_DOM0"\n");
> eal_usage(prgname);
> return -1;
> }
> --
> 2.1.3
>
next prev parent reply other threads:[~2014-11-25 10:31 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-22 21:43 [dpdk-dev] [PATCH 00/10] eal cleanup and new options Thomas Monjalon
2014-11-22 21:43 ` [dpdk-dev] [PATCH 01/10] eal: move internal headers in source directory Thomas Monjalon
2014-11-25 10:21 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 02/10] eal: factorize common headers Thomas Monjalon
2014-11-25 10:23 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 03/10] eal: fix header guards Thomas Monjalon
2014-11-25 10:28 ` Bruce Richardson
2014-11-25 12:23 ` Thomas Monjalon
2014-11-25 13:37 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 04/10] eal: factorize internal config reset Thomas Monjalon
2014-11-25 10:30 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 05/10] eal: factorize options sanity check Thomas Monjalon
2014-11-25 10:42 ` Bruce Richardson [this message]
2014-11-22 21:43 ` [dpdk-dev] [PATCH 06/10] eal: factorize configuration adjustment Thomas Monjalon
2014-11-25 10:44 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 07/10] eal: add core list input format Thomas Monjalon
2014-11-23 1:35 ` Neil Horman
2014-11-24 11:28 ` Bruce Richardson
2014-11-24 13:19 ` Thomas Monjalon
2014-11-24 13:28 ` Bruce Richardson
2014-11-24 13:37 ` Burakov, Anatoly
2014-11-24 14:01 ` Neil Horman
2014-11-24 14:52 ` Venkatesan, Venky
2014-11-24 16:12 ` Roger Keith Wiles
2014-11-24 17:04 ` Neil Horman
2014-11-24 17:09 ` Roger Keith Wiles
2014-11-24 17:11 ` Burakov, Anatoly
2014-11-24 17:17 ` Neil Horman
2014-11-25 10:45 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 08/10] config: support 128 cores Thomas Monjalon
2014-11-25 10:46 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 09/10] eal: get relative core index Thomas Monjalon
2014-11-25 10:51 ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 10/10] eal: add option --master-lcore Thomas Monjalon
2014-11-25 9:09 ` Simon Kuenzer
2014-11-25 12:45 ` Thomas Monjalon
2014-11-25 13:39 ` Bruce Richardson
2014-11-26 10:34 ` Simon Kuenzer
2014-11-25 14:55 ` [dpdk-dev] [PATCH 00/10] eal cleanup and new options Thomas Monjalon
2014-11-25 15:06 ` Bruce Richardson
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=20141125104240.GE5260@bricha3-MOBL3 \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=thomas.monjalon@6wind.com \
/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).