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>
int opt, ret, i;
char **argvopt;
int option_index;
- int coremask_ok = 0;
char *prgname = argv[0];
argvopt = 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:
}
}
- /* 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;
}
{0, 0, 0, 0}
};
+static int lcores_parsed;
+static int mem_parsed;
+
void
eal_reset_internal_config(struct internal_config *internal_cfg)
{
return -1;
/* Update the count of enabled logical cores of the EAL configuration */
cfg->lcore_count = count;
+ lcores_parsed = 1;
return 0;
}
conf->memory = atoi(optarg);
conf->memory *= 1024ULL;
conf->memory *= 1024ULL;
+ mem_parsed = 1;
break;
/* force number of channels */
case 'n':
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)
{
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 */
int opt, ret, i;
char **argvopt;
int option_index;
- int coremask_ok = 0;
char *prgname = argv[0];
struct shared_driver *solib;
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 */
}
}
- /* 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;
}