From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 8745029CB for ; Thu, 13 Jul 2017 12:22:07 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2017 03:22:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,353,1496127600"; d="scan'208";a="1172056620" Received: from gklab-246-072.igk.intel.com (HELO Sent) ([10.217.246.72]) by fmsmga001.fm.intel.com with SMTP; 13 Jul 2017 03:22:03 -0700 Received: by Sent (sSMTP sendmail emulation); Thu, 13 Jul 2017 12:12:15 +0200 From: Kuba Kozak To: dev@dpdk.org Cc: deepak.k.jain@intel.com, bruce.richardson@intel.com, michalx.k.jastrzebski@intel.com, jacekx.piasecki@intel.com, Kuba Kozak Date: Thu, 13 Jul 2017 12:07:48 +0200 Message-Id: <1499940470-31628-2-git-send-email-kubax.kozak@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499940470-31628-1-git-send-email-kubax.kozak@intel.com> References: <1499691101-184293-2-git-send-email-kubax.kozak@intel.com> <1499940470-31628-1-git-send-email-kubax.kozak@intel.com> Subject: [dpdk-dev] [PATCH v5 1/3] eal: add functions parsing EAL arguments 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, 13 Jul 2017 10:22:08 -0000 added function rte_eal_configure which configure Environment Abstraction Layer (EAL) using configuration structure. Signed-off-by: Kuba Kozak Suggested-by: Bruce Richardson --- lib/Makefile | 3 + lib/librte_eal/bsdapp/eal/Makefile | 4 + lib/librte_eal/bsdapp/eal/eal.c | 165 +++++++++++---- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_lcore.c | 7 + lib/librte_eal/common/eal_common_options.c | 106 ++++++++++ lib/librte_eal/common/eal_options.h | 3 + lib/librte_eal/common/include/rte_eal.h | 20 ++ lib/librte_eal/linuxapp/eal/Makefile | 3 + lib/librte_eal/linuxapp/eal/eal.c | 265 ++++++++++++++++-------- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + mk/rte.app.mk | 2 +- 12 files changed, 452 insertions(+), 128 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 1080a95..2c6c380 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -34,6 +34,9 @@ include $(RTE_SDK)/mk/rte.vars.mk DIRS-y += librte_compat DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal +ifeq ($(CONFIG_RTE_LIBRTE_CFGFILE),y) +DEPDIRS-librte_eal := librte_cfgfile +endif DIRS-$(CONFIG_RTE_LIBRTE_RING) += librte_ring DEPDIRS-librte_ring := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += librte_mempool diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index a0f9950..d70eefb 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -50,6 +50,10 @@ EXPORT_MAP := rte_eal_version.map LIBABIVER := 4 +ifeq ($(CONFIG_RTE_LIBRTE_CFGFILE),y) +LDLIBS += -lrte_cfgfile +endif + # specific to bsdapp exec-env SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 05f0c1f..4a0c221 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -73,6 +73,7 @@ #include #include #include +#include #include "eal_private.h" #include "eal_thread.h" @@ -99,6 +100,8 @@ static struct flock wr_lock = { .l_len = sizeof(early_mem_config.memseg), }; +static int run_once_reset_internal_config; + /* Address of global and public configuration */ static struct rte_config rte_config = { .mem_config = &early_mem_config, @@ -347,6 +350,58 @@ eal_log_level_parse(int argc, char **argv) optarg = old_optarg; } +/* Parse single argument */ +static int +eal_parse_option(int opt, char *optarg, int option_index, char *prgname) +{ + int ret; + + /* getopt is not happy, stop right now */ + if (opt == '?') { + eal_usage(prgname); + ret = -1; + goto out; + } + + ret = eal_parse_common_option(opt, optarg, &internal_config); + /* common parser is not happy */ + if (ret < 0) { + eal_usage(prgname); + ret = -1; + goto out; + } + /* common parser handled this option */ + if (ret == 0) + return 0; + + switch (opt) { + case 'h': + eal_usage(prgname); + exit(EXIT_SUCCESS); + break; + + default: + if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { + RTE_LOG(ERR, EAL, "Option %c is not supported " + "on FreeBSD\n", opt); + } else if (opt >= OPT_LONG_MIN_NUM && + opt < OPT_LONG_MAX_NUM) { + RTE_LOG(ERR, EAL, "Option %s is not supported " + "on FreeBSD\n", + eal_long_options[option_index].name); + } else { + RTE_LOG(ERR, EAL, "Option %d is not supported " + "on FreeBSD\n", opt); + } + eal_usage(prgname); + ret = -1; + goto out; + } + return 0; +out: + return ret; +} + /* Parse the argument given in the command line of the application */ static int eal_parse_args(int argc, char **argv) @@ -367,45 +422,9 @@ eal_parse_args(int argc, char **argv) while ((opt = getopt_long(argc, argvopt, eal_short_options, eal_long_options, &option_index)) != EOF) { - /* getopt is not happy, stop right now */ - if (opt == '?') { - eal_usage(prgname); - ret = -1; - goto out; - } - - ret = eal_parse_common_option(opt, optarg, &internal_config); - /* common parser is not happy */ - if (ret < 0) { - eal_usage(prgname); - ret = -1; - goto out; - } - /* common parser handled this option */ - if (ret == 0) - continue; - - switch (opt) { - case 'h': - eal_usage(prgname); - exit(EXIT_SUCCESS); - default: - if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { - RTE_LOG(ERR, EAL, "Option %c is not supported " - "on FreeBSD\n", opt); - } else if (opt >= OPT_LONG_MIN_NUM && - opt < OPT_LONG_MAX_NUM) { - RTE_LOG(ERR, EAL, "Option %s is not supported " - "on FreeBSD\n", - eal_long_options[option_index].name); - } else { - RTE_LOG(ERR, EAL, "Option %d is not supported " - "on FreeBSD\n", opt); - } - eal_usage(prgname); - ret = -1; + ret = eal_parse_option(opt, optarg, option_index, prgname); + if (ret < 0) goto out; - } } if (eal_adjust_config(&internal_config) != 0) { @@ -517,7 +536,10 @@ rte_eal_init(int argc, char **argv) thread_id = pthread_self(); - eal_reset_internal_config(&internal_config); + if (!run_once_reset_internal_config) { + eal_reset_internal_config(&internal_config); + run_once_reset_internal_config = 1; + } /* set log level as early as possible */ eal_log_level_parse(argc, argv); @@ -677,3 +699,68 @@ rte_eal_process_type(void) { return rte_config.process_type; } + +#ifdef RTE_LIBRTE_CFGFILE +int +rte_eal_configure(struct rte_cfgfile *cfg, char *prgname) +{ + int n_entries; + int i; + int opt; + int option_index; + + if (cfg == NULL) { + rte_errno = -EINVAL; + return -1; + } + + n_entries = rte_cfgfile_section_num_entries(cfg, "DPDK"); + + if (n_entries < 1) { + printf("No DPDK section entries in cfgfile object\n"); + return 0; + } + + struct rte_cfgfile_entry entries[n_entries]; + + if (n_entries != + rte_cfgfile_section_entries(cfg, "DPDK", entries, + n_entries)) { + rte_eal_init_alert("Unexpected fault."); + rte_errno = EFAULT; + return -1; + } + + if (!run_once_reset_internal_config) { + eal_reset_internal_config(&internal_config); + run_once_reset_internal_config = 1; + } + + /* set log level as early as possible */ + eal_log_level_cfg(cfg); + + if (rte_eal_cpu_init() < 0) { + rte_eal_init_alert("Cannot detect lcores."); + rte_errno = ENOTSUP; + return -1; + } + + for (i = 0; i < n_entries; i++) { + eal_getopt(entries[i].name, &opt, &option_index); + + if (eal_parse_option(opt, entries[i].value, + option_index, prgname) != 0) { + rte_eal_init_alert("Invalid config file arguments."); + rte_errno = EINVAL; + return -1; + } + } + + if (parse_vdev_devices(cfg) < 0) { + rte_eal_init_alert("Couldn't parse vdevs"); + rte_errno = ENOMEM; + return -1; + } + return 0; +} +#endif diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 381f895..932f990 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -200,6 +200,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_configure; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/common/eal_common_lcore.c index 84fa0cb..d0f4c6f 100644 --- a/lib/librte_eal/common/eal_common_lcore.c +++ b/lib/librte_eal/common/eal_common_lcore.c @@ -53,11 +53,18 @@ int rte_eal_cpu_init(void) { + static int run_once; + static int ret; /* pointer to global configuration */ struct rte_config *config = rte_eal_get_configuration(); unsigned lcore_id; unsigned count = 0; + /* No need to calculate this function again if we know the result */ + if (run_once) + return ret; + run_once = 1; + /* * Parse the maximum set of logical cores, detect the subset of running * ones and enable them by default. diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 075b0ea..aaf0f2c 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -50,6 +50,10 @@ #include #include #include +#ifdef RTE_LIBRTE_CFGFILE +#include +#include +#endif #include "eal_internal_cfg.h" #include "eal_options.h" @@ -1078,3 +1082,105 @@ eal_common_usage(void) " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n" "\n", RTE_MAX_LCORE); } + +#ifdef RTE_LIBRTE_CFGFILE +/* Parse the arguments for --log-level only */ +void +eal_log_level_cfg(struct rte_cfgfile *cfg) +{ + const char *entry; + + entry = rte_cfgfile_get_entry(cfg, "DPDK", OPT_LOG_LEVEL); + if (entry) + eal_parse_common_option(OPT_LOG_LEVEL_NUM, entry, + &internal_config); +} +#endif + +#ifdef RTE_LIBRTE_CFGFILE +static void rte_eal_init_alert(const char *msg) +{ + fprintf(stderr, "EAL: FATAL: %s\n", msg); + RTE_LOG(ERR, EAL, "%s\n", msg); +} + +#define vdev_buff_size 200 +#define sectionname_size 20 +int +parse_vdev_devices(struct rte_cfgfile *cfg) +{ + char sectionname[sectionname_size] = "DPDK.vdev0"; + char buffer[vdev_buff_size]; + int vdev_nb = 0; + int n_entries; + int buf_len; + char *buf_ptr; + int i; + int ret; + + /* ----------- parsing VDEVS */ + for (vdev_nb = 1; rte_cfgfile_has_section(cfg, sectionname); + vdev_nb++) { + n_entries = rte_cfgfile_section_num_entries(cfg, sectionname); + + struct rte_cfgfile_entry entries[n_entries]; + + if (n_entries != rte_cfgfile_section_entries(cfg, sectionname, + entries, n_entries)) { + rte_eal_init_alert("Unexpected fault."); + rte_errno = EFAULT; + return -1; + } + + buffer[0] = '\0'; + buf_ptr = buffer; + buf_len = vdev_buff_size; + for (i = 0; i < n_entries; i++) { + ret = snprintf(buf_ptr, buf_len, "%s%s%s%s", + entries[i].name, + (entries[i].value[0] != '\0') ? + "=" : "", + entries[i].value, + (i < (n_entries - 1)) ? "," : ""); + if (ret >= buf_len) { + printf("parse_vdev_devices(): buffer[] size is " + "to small\n"); + return -1; + } + buf_len -= ret; + buf_ptr += ret; + } + + /* parsing vdev */ + if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED, + buffer) < 0) { + return -1; + } + snprintf(sectionname, sectionname_size, "DPDK.vdev%d", vdev_nb); + } + /* ----------- parsing VDEVS */ + return 0; +} + +void +eal_getopt(const char *str, int *opt, int *option_index) +{ + int i; + + *opt = '?'; + *option_index = 0; + + if (strlen(str) == 1) { + *opt = *str; + return; + } + + for (i = 0; eal_long_options[i].name != NULL; i++) { + if (strcmp(str, eal_long_options[i].name) == 0) { + *opt = eal_long_options[i].val; + *option_index = i; + break; + } + } +} +#endif diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index a881c62..0fce11c 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -96,5 +96,8 @@ 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); int eal_plugins_init(void); +void eal_log_level_cfg(struct rte_cfgfile *cfg); +int parse_vdev_devices(struct rte_cfgfile *cfg); +void eal_getopt(const char *str, int *opt, int *option_index); #endif /* EAL_OPTIONS_H */ diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index 6b7c5ca..a1c78c0 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -46,6 +46,8 @@ #include #include +struct rte_cfgfile; /* forward declaration of struct */ + #ifdef __cplusplus extern "C" { #endif @@ -188,6 +190,24 @@ int rte_eal_iopl_init(void); */ int rte_eal_init(int argc, char **argv); +#ifdef RTE_LIBRTE_CFGFILE +/** + * Initialize the Environment Abstraction Layer (EAL) using + * configuration structure + * + * @param cfg + * pointer to config file structure. + * @param prgname + * pointer to string with execution path + * + * @return + * - On success, return 0 + * - On failure, returns -1. + */ +int +rte_eal_configure(struct rte_cfgfile *cfg, char *prgname); +#endif + /** * Check if a primary process is currently alive * diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 8651e27..7c1c559 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -53,6 +53,9 @@ LDLIBS += -lrt ifeq ($(CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES),y) LDLIBS += -lnuma endif +ifeq ($(CONFIG_RTE_LIBRTE_CFGFILE),y) +LDLIBS += -lrte_cfgfile +endif # specific to linuxapp exec-env SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) := eal.c diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 7c78f2d..f09aeff 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -78,6 +78,9 @@ #include #include #include +#ifdef RTE_LIBRTE_CFGFILE +#include +#endif #include "eal_private.h" #include "eal_thread.h" @@ -101,6 +104,8 @@ static struct rte_mem_config early_mem_config; * duration of the program, as we hold a write lock on it in the primary proc */ static int mem_cfg_fd = -1; +static int run_once_reset_internal_config; + static struct flock wr_lock = { .l_type = F_WRLCK, .l_whence = SEEK_SET, @@ -515,119 +520,135 @@ eal_log_level_parse(int argc, char **argv) optarg = old_optarg; } -/* Parse the argument given in the command line of the application */ +/* Parse single argument */ static int -eal_parse_args(int argc, char **argv) +eal_parse_option(int opt, char *optarg, int option_index, char *prgname) { - int opt, ret; - char **argvopt; - int option_index; - char *prgname = argv[0]; - const int old_optind = optind; - const int old_optopt = optopt; - char * const old_optarg = optarg; + int ret; - argvopt = argv; - optind = 1; + /* getopt is not happy, stop right now */ + if (opt == '?') { + eal_usage(prgname); + ret = -1; + goto out; + } - while ((opt = getopt_long(argc, argvopt, eal_short_options, - eal_long_options, &option_index)) != EOF) { + ret = eal_parse_common_option(opt, optarg, &internal_config); + /* common parser is not happy */ + if (ret < 0) { + eal_usage(prgname); + ret = -1; + goto out; + } + /* common parser handled this option */ + if (ret == 0) + return 0; - /* getopt is not happy, stop right now */ - if (opt == '?') { + switch (opt) { + case 'h': + eal_usage(prgname); + exit(EXIT_SUCCESS); + break; + + /* long options */ + case OPT_XEN_DOM0_NUM: +#ifdef RTE_LIBRTE_XEN_DOM0 + internal_config.xen_dom0_support = 1; + break; +#else + RTE_LOG(ERR, EAL, "Can't support DPDK app " + "running on Dom0, please configure" + " RTE_LIBRTE_XEN_DOM0=y\n"); + ret = -1; + goto out; +#endif + + case OPT_HUGE_DIR_NUM: + internal_config.hugepage_dir = optarg; + break; + + case OPT_FILE_PREFIX_NUM: + internal_config.hugefile_prefix = optarg; + break; + + case OPT_SOCKET_MEM_NUM: + if (eal_parse_socket_mem(optarg) < 0) { + RTE_LOG(ERR, EAL, "invalid parameters for --" + OPT_SOCKET_MEM "\n"); eal_usage(prgname); ret = -1; goto out; } + break; - ret = eal_parse_common_option(opt, optarg, &internal_config); - /* common parser is not happy */ - if (ret < 0) { + case OPT_BASE_VIRTADDR_NUM: + if (eal_parse_base_virtaddr(optarg) < 0) { + RTE_LOG(ERR, EAL, "invalid parameter for --" + OPT_BASE_VIRTADDR "\n"); eal_usage(prgname); ret = -1; goto out; } - /* common parser handled this option */ - if (ret == 0) - continue; + break; - switch (opt) { - case 'h': + case OPT_VFIO_INTR_NUM: + if (eal_parse_vfio_intr(optarg) < 0) { + RTE_LOG(ERR, EAL, "invalid parameters for --" + OPT_VFIO_INTR "\n"); eal_usage(prgname); - exit(EXIT_SUCCESS); - - /* long options */ - case OPT_XEN_DOM0_NUM: -#ifdef RTE_LIBRTE_XEN_DOM0 - internal_config.xen_dom0_support = 1; -#else - RTE_LOG(ERR, EAL, "Can't support DPDK app " - "running on Dom0, please configure" - " RTE_LIBRTE_XEN_DOM0=y\n"); ret = -1; goto out; -#endif - break; + } + break; - case OPT_HUGE_DIR_NUM: - internal_config.hugepage_dir = optarg; - break; + case OPT_CREATE_UIO_DEV_NUM: + internal_config.create_uio_dev = 1; + break; - case OPT_FILE_PREFIX_NUM: - internal_config.hugefile_prefix = optarg; - break; + default: + if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { + RTE_LOG(ERR, EAL, "Option %c is not supported " + "on Linux\n", opt); + } else if (opt >= OPT_LONG_MIN_NUM && + opt < OPT_LONG_MAX_NUM) { + RTE_LOG(ERR, EAL, "Option %s is not supported " + "on Linux\n", + eal_long_options[option_index].name); + } else { + RTE_LOG(ERR, EAL, "Option %d is not supported " + "on Linux\n", opt); + } + eal_usage(prgname); + ret = -1; + goto out; + } - case OPT_SOCKET_MEM_NUM: - if (eal_parse_socket_mem(optarg) < 0) { - RTE_LOG(ERR, EAL, "invalid parameters for --" - OPT_SOCKET_MEM "\n"); - eal_usage(prgname); - ret = -1; - goto out; - } - break; + return 0; +out: + return ret; +} - case OPT_BASE_VIRTADDR_NUM: - if (eal_parse_base_virtaddr(optarg) < 0) { - RTE_LOG(ERR, EAL, "invalid parameter for --" - OPT_BASE_VIRTADDR "\n"); - eal_usage(prgname); - ret = -1; - goto out; - } - break; +/* Parse the argument given in the command line of the application */ +static int +eal_parse_args(int argc, char **argv) +{ + int opt, ret; + char **argvopt; + int option_index; + char *prgname = argv[0]; + const int old_optind = optind; + const int old_optopt = optopt; + char * const old_optarg = optarg; - case OPT_VFIO_INTR_NUM: - if (eal_parse_vfio_intr(optarg) < 0) { - RTE_LOG(ERR, EAL, "invalid parameters for --" - OPT_VFIO_INTR "\n"); - eal_usage(prgname); - ret = -1; - goto out; - } - break; + argvopt = argv; + optind = 1; - case OPT_CREATE_UIO_DEV_NUM: - internal_config.create_uio_dev = 1; - break; + while ((opt = getopt_long(argc, argvopt, eal_short_options, + eal_long_options, &option_index)) != EOF) { - default: - if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { - RTE_LOG(ERR, EAL, "Option %c is not supported " - "on Linux\n", opt); - } else if (opt >= OPT_LONG_MIN_NUM && - opt < OPT_LONG_MAX_NUM) { - RTE_LOG(ERR, EAL, "Option %s is not supported " - "on Linux\n", - eal_long_options[option_index].name); - } else { - RTE_LOG(ERR, EAL, "Option %d is not supported " - "on Linux\n", opt); - } - eal_usage(prgname); - ret = -1; + ret = eal_parse_option(opt, optarg, option_index, prgname); + if (ret < 0) goto out; - } } if (eal_adjust_config(&internal_config) != 0) { @@ -774,7 +795,10 @@ rte_eal_init(int argc, char **argv) thread_id = pthread_self(); - eal_reset_internal_config(&internal_config); + if (!run_once_reset_internal_config) { + eal_reset_internal_config(&internal_config); + run_once_reset_internal_config = 1; + } /* set log level as early as possible */ eal_log_level_parse(argc, argv); @@ -995,3 +1019,68 @@ rte_eal_check_module(const char *module_name) /* Module has been found */ return 1; } + +#ifdef RTE_LIBRTE_CFGFILE +int +rte_eal_configure(struct rte_cfgfile *cfg, char *prgname) +{ + int n_entries; + int i; + int opt; + int option_index; + + if (cfg == NULL) { + rte_errno = -EINVAL; + return -1; + } + + n_entries = rte_cfgfile_section_num_entries(cfg, "DPDK"); + + if (n_entries < 1) { + printf("No DPDK section entries in cfgfile object\n"); + return 0; + } + + struct rte_cfgfile_entry entries[n_entries]; + + if (n_entries != + rte_cfgfile_section_entries(cfg, "DPDK", entries, + n_entries)) { + rte_eal_init_alert("Unexpected fault."); + rte_errno = EFAULT; + return -1; + } + + if (!run_once_reset_internal_config) { + eal_reset_internal_config(&internal_config); + run_once_reset_internal_config = 1; + } + + /* set log level as early as possible */ + eal_log_level_cfg(cfg); + + if (rte_eal_cpu_init() < 0) { + rte_eal_init_alert("Cannot detect lcores."); + rte_errno = ENOTSUP; + return -1; + } + + for (i = 0; i < n_entries; i++) { + eal_getopt(entries[i].name, &opt, &option_index); + + if (eal_parse_option(opt, entries[i].value, + option_index, prgname) != 0) { + rte_eal_init_alert("Invalid config file arguments."); + rte_errno = EINVAL; + return -1; + } + } + + if (parse_vdev_devices(cfg) < 0) { + rte_eal_init_alert("Couldn't parse vdevs"); + rte_errno = ENOMEM; + return -1; + } + return 0; +} +#endif diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 0f9e009..d206fd3 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -205,6 +205,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_configure; } DPDK_17.05; diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 5bb4290..b883d08 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -81,7 +81,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_POWER) += -lrte_power _LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER) += -lrte_timer _LDLIBS-$(CONFIG_RTE_LIBRTE_EFD) += -lrte_efd -_LDLIBS-$(CONFIG_RTE_LIBRTE_CFGFILE) += -lrte_cfgfile _LDLIBS-y += --whole-archive @@ -97,6 +96,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += -lrte_mempool _LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_RING) += -lrte_mempool_ring _LDLIBS-$(CONFIG_RTE_LIBRTE_RING) += -lrte_ring _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lrte_eal +_LDLIBS-$(CONFIG_RTE_LIBRTE_CFGFILE) += -lrte_cfgfile _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder -- 2.7.4