From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 06/10] eal: factorize configuration adjustment
Date: Sat, 22 Nov 2014 22:43:38 +0100 [thread overview]
Message-ID: <1416692622-28886-7-git-send-email-thomas.monjalon@6wind.com> (raw)
In-Reply-To: <1416692622-28886-1-git-send-email-thomas.monjalon@6wind.com>
Some adjustments are done after options parsing and are common
to Linux and BSD.
Remove process_type adjustment in rte_config_init() because
it is already done in eal_parse_args().
eal_proc_type_detect() is kept duplicated because it open a
file descriptor which is used later in each eal.c.
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
lib/librte_eal/bsdapp/eal/eal.c | 18 +++++-------------
lib/librte_eal/common/eal_common_options.c | 16 ++++++++++++++++
lib/librte_eal/common/eal_options.h | 2 ++
lib/librte_eal/linuxapp/eal/eal.c | 18 +++++-------------
4 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 20a9c5f..69f3c03 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -224,7 +224,7 @@ rte_eal_config_attach(void)
}
/* Detect if we are a primary or a secondary process */
-static enum rte_proc_type_t
+enum rte_proc_type_t
eal_proc_type_detect(void)
{
enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
@@ -247,9 +247,7 @@ eal_proc_type_detect(void)
static void
rte_config_init(void)
{
- rte_config.process_type = (internal_config.process_type == RTE_PROC_AUTO) ?
- eal_proc_type_detect() : /* for auto, detect the type */
- internal_config.process_type; /* otherwise use what's already set */
+ rte_config.process_type = internal_config.process_type;
switch (rte_config.process_type){
case RTE_PROC_PRIMARY:
@@ -313,7 +311,7 @@ eal_get_hugepage_mem_size(void)
static int
eal_parse_args(int argc, char **argv)
{
- int opt, ret, i;
+ int opt, ret;
char **argvopt;
int option_index;
char *prgname = argv[0];
@@ -360,8 +358,8 @@ eal_parse_args(int argc, char **argv)
}
}
- if (internal_config.process_type == RTE_PROC_AUTO)
- internal_config.process_type = eal_proc_type_detect();
+ if (eal_adjust_config(&internal_config) != 0)
+ return -1;
/* sanity checks */
if (eal_check_common_options(&internal_config) != 0) {
@@ -371,12 +369,6 @@ eal_parse_args(int argc, char **argv)
if (optind >= 0)
argv[optind-1] = prgname;
-
- /* if no memory amounts were requested, this will result in 0 and
- * will be overriden later, right after eal_hugepage_info_init() */
- for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
- internal_config.memory += internal_config.socket_mem[i];
-
ret = optind-1;
optind = 0; /* reset getopt lib */
return ret;
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 630dfe0..63710b0 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -400,6 +400,22 @@ eal_parse_common_option(int opt, const char *optarg,
}
int
+eal_adjust_config(struct internal_config *internal_cfg)
+{
+ int i;
+
+ if (internal_config.process_type == RTE_PROC_AUTO)
+ internal_config.process_type = eal_proc_type_detect();
+
+ /* if no memory amounts were requested, this will result in 0 and
+ * will be overridden later, right after eal_hugepage_info_init() */
+ for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
+ internal_cfg->memory += internal_cfg->socket_mem[i];
+
+ return 0;
+}
+
+int
eal_check_common_options(struct internal_config *internal_cfg)
{
struct rte_config *cfg = rte_eal_get_configuration();
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index 75351c0..f58965c 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -83,7 +83,9 @@ extern const struct option eal_long_options[];
int eal_parse_common_option(int opt, const char *argv,
struct internal_config *conf);
+int eal_adjust_config(struct internal_config *internal_cfg);
int eal_check_common_options(struct internal_config *internal_cfg);
void eal_common_usage(void);
+enum rte_proc_type_t eal_proc_type_detect(void);
#endif /* EAL_OPTIONS_H */
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index f5de277..5e5a7a0 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -284,7 +284,7 @@ rte_eal_config_reattach(void)
}
/* Detect if we are a primary or a secondary process */
-static enum rte_proc_type_t
+enum rte_proc_type_t
eal_proc_type_detect(void)
{
enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
@@ -307,9 +307,7 @@ eal_proc_type_detect(void)
static void
rte_config_init(void)
{
- rte_config.process_type = (internal_config.process_type == RTE_PROC_AUTO) ?
- eal_proc_type_detect() : /* for auto, detect the type */
- internal_config.process_type; /* otherwise use what's already set */
+ rte_config.process_type = internal_config.process_type;
switch (rte_config.process_type){
case RTE_PROC_PRIMARY:
@@ -504,7 +502,7 @@ eal_get_hugepage_mem_size(void)
static int
eal_parse_args(int argc, char **argv)
{
- int opt, ret, i;
+ int opt, ret;
char **argvopt;
int option_index;
char *prgname = argv[0];
@@ -616,8 +614,8 @@ eal_parse_args(int argc, char **argv)
}
}
- if (internal_config.process_type == RTE_PROC_AUTO)
- internal_config.process_type = eal_proc_type_detect();
+ if (eal_adjust_config(&internal_config) != 0)
+ return -1;
/* sanity checks */
if (eal_check_common_options(&internal_config) != 0) {
@@ -635,12 +633,6 @@ eal_parse_args(int argc, char **argv)
if (optind >= 0)
argv[optind-1] = prgname;
-
- /* if no memory amounts were requested, this will result in 0 and
- * will be overriden later, right after eal_hugepage_info_init() */
- for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
- internal_config.memory += internal_config.socket_mem[i];
-
ret = optind-1;
optind = 0; /* reset getopt lib */
return ret;
--
2.1.3
next prev parent reply other threads:[~2014-11-22 21:33 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
2014-11-22 21:43 ` Thomas Monjalon [this message]
2014-11-25 10:44 ` [dpdk-dev] [PATCH 06/10] eal: factorize configuration adjustment 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=1416692622-28886-7-git-send-email-thomas.monjalon@6wind.com \
--to=thomas.monjalon@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).