[dpdk-dev] [PATCH 4/7] Move EAL common functions
Inline On Mon, Jan 5, 2015 at 12:38 PM, Thomas Monjalon wrote: > 2015-01-05 10:56, Ravi Kerur: > > On Mon, Jan 5, 2015 at 7:59 AM, Thomas Monjalon < > thomas.monjalon at 6wind.com> > > wrote: > > > 2014-12-25 10:33, Ravi Kerur: > > > > Move common functions in eal.c to librte_eal/common directory. > > > [...] > > > > lib/librte_eal/common/eal_common.c| 328 > ++ > > > > lib/librte_eal/common/eal_externs.h | 42 + > > > > > > I don't agree with these new files. > > > We must try to keep a semantic organization. The file > eal_common_options.c > > > would be better for option-related functions. > > > Maybe that the split between system config, runtime config and internal > > > config > > > must be reworked. > > > > > > By the way, it would be nice to avoid extern variables. > > > > I have taken care of your comments and will generate v4 patch. > > Please do not forget v4 word and changelog when sending patches. > Check http://dpdk.org/dev#send > > > Currently I have moved common functions in eal.c into > > "eal_common_system_options.c" file. Are you suggesting that we further > > divide "eal_common_options.c" and "eal_common_system_options.c(new file > > added)" into 3 separate files i.e. > > > > eal_common_system_options.c > > eal_common_runtime_options.c > > eal_common_internal_options.c > > You are already doing big changes. So let's iterate with existing files and > avoid creating new ones. > eal_common_options.c must be kept. But if some code is not really related > to > runtime options, we could consider adding a new file eal_common_config.c, > not > sure about this one. > > -- > i have divided eal_common.c (new file which was added in v1 PATCH) into eal_common_system.c and eal_common_runtime.c and have moved appropriate functions into it. If file names are not appropriate or changes are not worth doing the split, I will merge them back into eal_common_config.c. Thanks. > Thomas >
[dpdk-dev] [PATCH 4/7] Move EAL common functions
2015-01-05 10:56, Ravi Kerur: > On Mon, Jan 5, 2015 at 7:59 AM, Thomas Monjalon > wrote: > > 2014-12-25 10:33, Ravi Kerur: > > > Move common functions in eal.c to librte_eal/common directory. > > [...] > > > lib/librte_eal/common/eal_common.c| 328 > > > ++ > > > lib/librte_eal/common/eal_externs.h | 42 + > > > > I don't agree with these new files. > > We must try to keep a semantic organization. The file eal_common_options.c > > would be better for option-related functions. > > Maybe that the split between system config, runtime config and internal > > config > > must be reworked. > > > > By the way, it would be nice to avoid extern variables. > > I have taken care of your comments and will generate v4 patch. Please do not forget v4 word and changelog when sending patches. Check http://dpdk.org/dev#send > Currently I have moved common functions in eal.c into > "eal_common_system_options.c" file. Are you suggesting that we further > divide "eal_common_options.c" and "eal_common_system_options.c(new file > added)" into 3 separate files i.e. > > eal_common_system_options.c > eal_common_runtime_options.c > eal_common_internal_options.c You are already doing big changes. So let's iterate with existing files and avoid creating new ones. eal_common_options.c must be kept. But if some code is not really related to runtime options, we could consider adding a new file eal_common_config.c, not sure about this one. -- Thomas
[dpdk-dev] [PATCH 4/7] Move EAL common functions
2014-12-25 10:33, Ravi Kerur: > Move common functions in eal.c to librte_eal/common directory. [...] > lib/librte_eal/common/eal_common.c| 328 > ++ > lib/librte_eal/common/eal_externs.h | 42 + I don't agree with these new files. We must try to keep a semantic organization. The file eal_common_options.c would be better for option-related functions. Maybe that the split between system config, runtime config and internal config must be reworked. By the way, it would be nice to avoid extern variables. -- Thomas
[dpdk-dev] [PATCH 4/7] Move EAL common functions
Inline On Mon, Jan 5, 2015 at 7:59 AM, Thomas Monjalon wrote: > 2014-12-25 10:33, Ravi Kerur: > > Move common functions in eal.c to librte_eal/common directory. > [...] > > lib/librte_eal/common/eal_common.c| 328 > ++ > > lib/librte_eal/common/eal_externs.h | 42 + > > I don't agree with these new files. > We must try to keep a semantic organization. The file eal_common_options.c > would be better for option-related functions. > Maybe that the split between system config, runtime config and internal > config > must be reworked. > > By the way, it would be nice to avoid extern variables. > I have taken care of your comments and will generate v4 patch. Currently I have moved common functions in eal.c into "eal_common_system_options.c" file. Are you suggesting that we further divide "eal_common_options.c" and "eal_common_system_options.c(new file added)" into 3 separate files i.e. eal_common_system_options.c eal_common_runtime_options.c eal_common_internal_options.c Thanks. > > -- > Thomas >
[dpdk-dev] [PATCH 4/7] Move EAL common functions
Thanks Thomas for the reviews, do you want me to send "v4" version of this patch series or start a different patch series? Thanks, Ravi On Mon, Jan 5, 2015 at 7:59 AM, Thomas Monjalon wrote: > 2014-12-25 10:33, Ravi Kerur: > > Move common functions in eal.c to librte_eal/common directory. > [...] > > lib/librte_eal/common/eal_common.c| 328 > ++ > > lib/librte_eal/common/eal_externs.h | 42 + > > I don't agree with these new files. > We must try to keep a semantic organization. The file eal_common_options.c > would be better for option-related functions. > Maybe that the split between system config, runtime config and internal > config > must be reworked. > > By the way, it would be nice to avoid extern variables. > > -- > Thomas >
[dpdk-dev] [PATCH 4/7] Move EAL common functions
On Thu, Dec 25, 2014 at 11:17:41AM -0800, Ravi Kerur wrote: > Inline > > On Thu, Dec 25, 2014 at 9:44 AM, Neil Horman wrote: > > > On Thu, Dec 25, 2014 at 10:33:14AM -0500, Ravi Kerur wrote: > > > Move common functions in eal.c to librte_eal/common directory. > > > Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in > > > common functions. > > > Makefile changes to reflect new file. > > > Fix checkpatch warnings and errors. > > > > > > Signed-off-by: Ravi Kerur > > > --- > > > lib/librte_eal/bsdapp/eal/Makefile| 1 + > > > lib/librte_eal/bsdapp/eal/eal.c | 233 +--- > > > lib/librte_eal/common/eal_common.c| 328 > > ++ > > > lib/librte_eal/common/eal_externs.h | 42 + > > > lib/librte_eal/common/eal_hugepages.h | 1 + > > > lib/librte_eal/common/eal_private.h | 47 + > > > lib/librte_eal/linuxapp/eal/Makefile | 1 + > > > lib/librte_eal/linuxapp/eal/eal.c | 246 ++--- > > > 8 files changed, 439 insertions(+), 460 deletions(-) > > > create mode 100644 lib/librte_eal/common/eal_common.c > > > create mode 100644 lib/librte_eal/common/eal_externs.h > > > > > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile > > b/lib/librte_eal/bsdapp/eal/Makefile > > > index 92dd9a6..050d70b 100644 > > > --- a/lib/librte_eal/bsdapp/eal/Makefile > > > +++ b/lib/librte_eal/bsdapp/eal/Makefile > > > @@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += > > eal_interrupts.c > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c > > > > > > # from common dir > > > +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common.c > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_memzone.c > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_log.c > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_launch.c > > > diff --git a/lib/librte_eal/bsdapp/eal/eal.c > > b/lib/librte_eal/bsdapp/eal/eal.c > > > index 69f3c03..f925da7 100644 > > > --- a/lib/librte_eal/bsdapp/eal/eal.c > > > +++ b/lib/librte_eal/bsdapp/eal/eal.c > > > @@ -80,30 +80,10 @@ > > > #include "eal_filesystem.h" > > > #include "eal_hugepages.h" > > > #include "eal_options.h" > > > +#include "eal_externs.h" > > > > > > #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) > > > > > > -/* Allow the application to print its usage message too if set */ > > > -static rte_usage_hook_t rte_application_usage_hook = NULL; > > > -/* early configuration structure, when memory config is not mmapped */ > > > -static struct rte_mem_config early_mem_config; > > > - > > > -/* define fd variable here, because file needs to be kept open for the > > > - * duration of the program, as we hold a write lock on it in the > > primary proc */ > > > -static int mem_cfg_fd = -1; > > > - > > > -static struct flock wr_lock = { > > > - .l_type = F_WRLCK, > > > - .l_whence = SEEK_SET, > > > - .l_start = offsetof(struct rte_mem_config, memseg), > > > - .l_len = sizeof(early_mem_config.memseg), > > > -}; > > > - > > > -/* Address of global and public configuration */ > > > -static struct rte_config rte_config = { > > > - .mem_config = _mem_config, > > > -}; > > > - > > > /* internal configuration (per-core) */ > > > struct lcore_config lcore_config[RTE_MAX_LCORE]; > > > > > > @@ -113,93 +93,14 @@ struct internal_config internal_config; > > > /* used by rte_rdtsc() */ > > > int rte_cycles_vmware_tsc_map; > > > > > > -/* Return a pointer to the configuration structure */ > > > -struct rte_config * > > > -rte_eal_get_configuration(void) > > > +inline void * > > > +rte_eal_get_mem_cfg_addr(void) > > > { > > > - return _config; > > > -} > > > - > > > -/* parse a sysfs (or other) file containing one integer value */ > > > -int > > > -eal_parse_sysfs_value(const char *filename, unsigned long *val) > > > -{ > > > - FILE *f; > > > - char buf[BUFSIZ]; > > > - char *end = NULL; > > > - > > > - if ((f = fopen(filename, "r")) == NULL) { > > > - RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n", > > > - __func__, filename); > > > - return -1; > > > - } > > > - > > > - if (fgets(buf, sizeof(buf), f) == NULL) { > > > - RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", > > > - __func__, filename); > > > - fclose(f); > > > - return -1; > > > - } > > > - *val = strtoul(buf, , 0); > > > - if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) { > > > - RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n", > > > - __func__, filename); > > > - fclose(f); > > > - return -1; > > > - } > > > - fclose(f); > > > - return 0; > > > -} > > > - > > > - > > > -/* create memory configuration in shared/mmap memory. Take out > > > - * a write lock on the memsegs, so we can auto-detect
[dpdk-dev] [PATCH 4/7] Move EAL common functions
On Fri, Dec 26, 2014 at 6:42 AM, Neil Horman wrote: > On Thu, Dec 25, 2014 at 11:17:41AM -0800, Ravi Kerur wrote: > > Inline > > > > On Thu, Dec 25, 2014 at 9:44 AM, Neil Horman > wrote: > > > > > On Thu, Dec 25, 2014 at 10:33:14AM -0500, Ravi Kerur wrote: > > > > Move common functions in eal.c to librte_eal/common directory. > > > > Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in > > > > common functions. > > > > Makefile changes to reflect new file. > > > > Fix checkpatch warnings and errors. > > > > > > > > Signed-off-by: Ravi Kerur > > > > --- > > > > lib/librte_eal/bsdapp/eal/Makefile| 1 + > > > > lib/librte_eal/bsdapp/eal/eal.c | 233 +--- > > > > lib/librte_eal/common/eal_common.c| 328 > > > ++ > > > > lib/librte_eal/common/eal_externs.h | 42 + > > > > lib/librte_eal/common/eal_hugepages.h | 1 + > > > > lib/librte_eal/common/eal_private.h | 47 + > > > > lib/librte_eal/linuxapp/eal/Makefile | 1 + > > > > lib/librte_eal/linuxapp/eal/eal.c | 246 > ++--- > > > > 8 files changed, 439 insertions(+), 460 deletions(-) > > > > create mode 100644 lib/librte_eal/common/eal_common.c > > > > create mode 100644 lib/librte_eal/common/eal_externs.h > > > > > > > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile > > > b/lib/librte_eal/bsdapp/eal/Makefile > > > > index 92dd9a6..050d70b 100644 > > > > --- a/lib/librte_eal/bsdapp/eal/Makefile > > > > +++ b/lib/librte_eal/bsdapp/eal/Makefile > > > > @@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += > > > eal_interrupts.c > > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c > > > > > > > > # from common dir > > > > +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common.c > > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_memzone.c > > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_log.c > > > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_launch.c > > > > diff --git a/lib/librte_eal/bsdapp/eal/eal.c > > > b/lib/librte_eal/bsdapp/eal/eal.c > > > > index 69f3c03..f925da7 100644 > > > > --- a/lib/librte_eal/bsdapp/eal/eal.c > > > > +++ b/lib/librte_eal/bsdapp/eal/eal.c > > > > @@ -80,30 +80,10 @@ > > > > #include "eal_filesystem.h" > > > > #include "eal_hugepages.h" > > > > #include "eal_options.h" > > > > +#include "eal_externs.h" > > > > > > > > #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) > > > > > > > > -/* Allow the application to print its usage message too if set */ > > > > -static rte_usage_hook_t rte_application_usage_hook = NULL; > > > > -/* early configuration structure, when memory config is not mmapped > */ > > > > -static struct rte_mem_config early_mem_config; > > > > - > > > > -/* define fd variable here, because file needs to be kept open for > the > > > > - * duration of the program, as we hold a write lock on it in the > > > primary proc */ > > > > -static int mem_cfg_fd = -1; > > > > - > > > > -static struct flock wr_lock = { > > > > - .l_type = F_WRLCK, > > > > - .l_whence = SEEK_SET, > > > > - .l_start = offsetof(struct rte_mem_config, memseg), > > > > - .l_len = sizeof(early_mem_config.memseg), > > > > -}; > > > > - > > > > -/* Address of global and public configuration */ > > > > -static struct rte_config rte_config = { > > > > - .mem_config = _mem_config, > > > > -}; > > > > - > > > > /* internal configuration (per-core) */ > > > > struct lcore_config lcore_config[RTE_MAX_LCORE]; > > > > > > > > @@ -113,93 +93,14 @@ struct internal_config internal_config; > > > > /* used by rte_rdtsc() */ > > > > int rte_cycles_vmware_tsc_map; > > > > > > > > -/* Return a pointer to the configuration structure */ > > > > -struct rte_config * > > > > -rte_eal_get_configuration(void) > > > > +inline void * > > > > +rte_eal_get_mem_cfg_addr(void) > > > > { > > > > - return _config; > > > > -} > > > > - > > > > -/* parse a sysfs (or other) file containing one integer value */ > > > > -int > > > > -eal_parse_sysfs_value(const char *filename, unsigned long *val) > > > > -{ > > > > - FILE *f; > > > > - char buf[BUFSIZ]; > > > > - char *end = NULL; > > > > - > > > > - if ((f = fopen(filename, "r")) == NULL) { > > > > - RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n", > > > > - __func__, filename); > > > > - return -1; > > > > - } > > > > - > > > > - if (fgets(buf, sizeof(buf), f) == NULL) { > > > > - RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", > > > > - __func__, filename); > > > > - fclose(f); > > > > - return -1; > > > > - } > > > > - *val = strtoul(buf, , 0); > > > > - if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) { > > > > - RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value > %s\n", > > > > -
[dpdk-dev] [PATCH 4/7] Move EAL common functions
On Thu, Dec 25, 2014 at 10:33:14AM -0500, Ravi Kerur wrote: > Move common functions in eal.c to librte_eal/common directory. > Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in > common functions. > Makefile changes to reflect new file. > Fix checkpatch warnings and errors. > > Signed-off-by: Ravi Kerur > --- > lib/librte_eal/bsdapp/eal/Makefile| 1 + > lib/librte_eal/bsdapp/eal/eal.c | 233 +--- > lib/librte_eal/common/eal_common.c| 328 > ++ > lib/librte_eal/common/eal_externs.h | 42 + > lib/librte_eal/common/eal_hugepages.h | 1 + > lib/librte_eal/common/eal_private.h | 47 + > lib/librte_eal/linuxapp/eal/Makefile | 1 + > lib/librte_eal/linuxapp/eal/eal.c | 246 ++--- > 8 files changed, 439 insertions(+), 460 deletions(-) > create mode 100644 lib/librte_eal/common/eal_common.c > create mode 100644 lib/librte_eal/common/eal_externs.h > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile > b/lib/librte_eal/bsdapp/eal/Makefile > index 92dd9a6..050d70b 100644 > --- a/lib/librte_eal/bsdapp/eal/Makefile > +++ b/lib/librte_eal/bsdapp/eal/Makefile > @@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c > > # from common dir > +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common.c > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_memzone.c > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_log.c > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_launch.c > diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c > index 69f3c03..f925da7 100644 > --- a/lib/librte_eal/bsdapp/eal/eal.c > +++ b/lib/librte_eal/bsdapp/eal/eal.c > @@ -80,30 +80,10 @@ > #include "eal_filesystem.h" > #include "eal_hugepages.h" > #include "eal_options.h" > +#include "eal_externs.h" > > #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) > > -/* Allow the application to print its usage message too if set */ > -static rte_usage_hook_t rte_application_usage_hook = NULL; > -/* early configuration structure, when memory config is not mmapped */ > -static struct rte_mem_config early_mem_config; > - > -/* define fd variable here, because file needs to be kept open for the > - * duration of the program, as we hold a write lock on it in the primary > proc */ > -static int mem_cfg_fd = -1; > - > -static struct flock wr_lock = { > - .l_type = F_WRLCK, > - .l_whence = SEEK_SET, > - .l_start = offsetof(struct rte_mem_config, memseg), > - .l_len = sizeof(early_mem_config.memseg), > -}; > - > -/* Address of global and public configuration */ > -static struct rte_config rte_config = { > - .mem_config = _mem_config, > -}; > - > /* internal configuration (per-core) */ > struct lcore_config lcore_config[RTE_MAX_LCORE]; > > @@ -113,93 +93,14 @@ struct internal_config internal_config; > /* used by rte_rdtsc() */ > int rte_cycles_vmware_tsc_map; > > -/* Return a pointer to the configuration structure */ > -struct rte_config * > -rte_eal_get_configuration(void) > +inline void * > +rte_eal_get_mem_cfg_addr(void) > { > - return _config; > -} > - > -/* parse a sysfs (or other) file containing one integer value */ > -int > -eal_parse_sysfs_value(const char *filename, unsigned long *val) > -{ > - FILE *f; > - char buf[BUFSIZ]; > - char *end = NULL; > - > - if ((f = fopen(filename, "r")) == NULL) { > - RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n", > - __func__, filename); > - return -1; > - } > - > - if (fgets(buf, sizeof(buf), f) == NULL) { > - RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", > - __func__, filename); > - fclose(f); > - return -1; > - } > - *val = strtoul(buf, , 0); > - if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) { > - RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n", > - __func__, filename); > - fclose(f); > - return -1; > - } > - fclose(f); > - return 0; > -} > - > - > -/* create memory configuration in shared/mmap memory. Take out > - * a write lock on the memsegs, so we can auto-detect primary/secondary. > - * This means we never close the file while running (auto-close on exit). > - * We also don't lock the whole file, so that in future we can use read-locks > - * on other parts, e.g. memzones, to detect if there are running secondary > - * processes. */ > -static void > -rte_eal_config_create(void) > -{ > - void *rte_mem_cfg_addr; > - int retval; > - > - const char *pathname = eal_runtime_config_path(); > - > - if (internal_config.no_shconf) > - return; > - > - if (mem_cfg_fd < 0){ > - mem_cfg_fd = open(pathname, O_RDWR |
[dpdk-dev] [PATCH 4/7] Move EAL common functions
Inline On Thu, Dec 25, 2014 at 9:44 AM, Neil Horman wrote: > On Thu, Dec 25, 2014 at 10:33:14AM -0500, Ravi Kerur wrote: > > Move common functions in eal.c to librte_eal/common directory. > > Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in > > common functions. > > Makefile changes to reflect new file. > > Fix checkpatch warnings and errors. > > > > Signed-off-by: Ravi Kerur > > --- > > lib/librte_eal/bsdapp/eal/Makefile| 1 + > > lib/librte_eal/bsdapp/eal/eal.c | 233 +--- > > lib/librte_eal/common/eal_common.c| 328 > ++ > > lib/librte_eal/common/eal_externs.h | 42 + > > lib/librte_eal/common/eal_hugepages.h | 1 + > > lib/librte_eal/common/eal_private.h | 47 + > > lib/librte_eal/linuxapp/eal/Makefile | 1 + > > lib/librte_eal/linuxapp/eal/eal.c | 246 ++--- > > 8 files changed, 439 insertions(+), 460 deletions(-) > > create mode 100644 lib/librte_eal/common/eal_common.c > > create mode 100644 lib/librte_eal/common/eal_externs.h > > > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile > b/lib/librte_eal/bsdapp/eal/Makefile > > index 92dd9a6..050d70b 100644 > > --- a/lib/librte_eal/bsdapp/eal/Makefile > > +++ b/lib/librte_eal/bsdapp/eal/Makefile > > @@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += > eal_interrupts.c > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c > > > > # from common dir > > +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common.c > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_memzone.c > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_log.c > > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_launch.c > > diff --git a/lib/librte_eal/bsdapp/eal/eal.c > b/lib/librte_eal/bsdapp/eal/eal.c > > index 69f3c03..f925da7 100644 > > --- a/lib/librte_eal/bsdapp/eal/eal.c > > +++ b/lib/librte_eal/bsdapp/eal/eal.c > > @@ -80,30 +80,10 @@ > > #include "eal_filesystem.h" > > #include "eal_hugepages.h" > > #include "eal_options.h" > > +#include "eal_externs.h" > > > > #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) > > > > -/* Allow the application to print its usage message too if set */ > > -static rte_usage_hook_t rte_application_usage_hook = NULL; > > -/* early configuration structure, when memory config is not mmapped */ > > -static struct rte_mem_config early_mem_config; > > - > > -/* define fd variable here, because file needs to be kept open for the > > - * duration of the program, as we hold a write lock on it in the > primary proc */ > > -static int mem_cfg_fd = -1; > > - > > -static struct flock wr_lock = { > > - .l_type = F_WRLCK, > > - .l_whence = SEEK_SET, > > - .l_start = offsetof(struct rte_mem_config, memseg), > > - .l_len = sizeof(early_mem_config.memseg), > > -}; > > - > > -/* Address of global and public configuration */ > > -static struct rte_config rte_config = { > > - .mem_config = _mem_config, > > -}; > > - > > /* internal configuration (per-core) */ > > struct lcore_config lcore_config[RTE_MAX_LCORE]; > > > > @@ -113,93 +93,14 @@ struct internal_config internal_config; > > /* used by rte_rdtsc() */ > > int rte_cycles_vmware_tsc_map; > > > > -/* Return a pointer to the configuration structure */ > > -struct rte_config * > > -rte_eal_get_configuration(void) > > +inline void * > > +rte_eal_get_mem_cfg_addr(void) > > { > > - return _config; > > -} > > - > > -/* parse a sysfs (or other) file containing one integer value */ > > -int > > -eal_parse_sysfs_value(const char *filename, unsigned long *val) > > -{ > > - FILE *f; > > - char buf[BUFSIZ]; > > - char *end = NULL; > > - > > - if ((f = fopen(filename, "r")) == NULL) { > > - RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n", > > - __func__, filename); > > - return -1; > > - } > > - > > - if (fgets(buf, sizeof(buf), f) == NULL) { > > - RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", > > - __func__, filename); > > - fclose(f); > > - return -1; > > - } > > - *val = strtoul(buf, , 0); > > - if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) { > > - RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n", > > - __func__, filename); > > - fclose(f); > > - return -1; > > - } > > - fclose(f); > > - return 0; > > -} > > - > > - > > -/* create memory configuration in shared/mmap memory. Take out > > - * a write lock on the memsegs, so we can auto-detect primary/secondary. > > - * This means we never close the file while running (auto-close on > exit). > > - * We also don't lock the whole file, so that in future we can use > read-locks > > - * on other parts, e.g. memzones, to detect if there are running > secondary > > - * processes. */ > > -static void > >
[dpdk-dev] [PATCH 4/7] Move EAL common functions
Move common functions in eal.c to librte_eal/common directory. Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in common functions. Makefile changes to reflect new file. Fix checkpatch warnings and errors. Signed-off-by: Ravi Kerur --- lib/librte_eal/bsdapp/eal/Makefile| 1 + lib/librte_eal/bsdapp/eal/eal.c | 233 +--- lib/librte_eal/common/eal_common.c| 328 ++ lib/librte_eal/common/eal_externs.h | 42 + lib/librte_eal/common/eal_hugepages.h | 1 + lib/librte_eal/common/eal_private.h | 47 + lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal.c | 246 ++--- 8 files changed, 439 insertions(+), 460 deletions(-) create mode 100644 lib/librte_eal/common/eal_common.c create mode 100644 lib/librte_eal/common/eal_externs.h diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 92dd9a6..050d70b 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c # from common dir +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_launch.c diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 69f3c03..f925da7 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -80,30 +80,10 @@ #include "eal_filesystem.h" #include "eal_hugepages.h" #include "eal_options.h" +#include "eal_externs.h" #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) -/* Allow the application to print its usage message too if set */ -static rte_usage_hook_trte_application_usage_hook = NULL; -/* early configuration structure, when memory config is not mmapped */ -static struct rte_mem_config early_mem_config; - -/* define fd variable here, because file needs to be kept open for the - * duration of the program, as we hold a write lock on it in the primary proc */ -static int mem_cfg_fd = -1; - -static struct flock wr_lock = { - .l_type = F_WRLCK, - .l_whence = SEEK_SET, - .l_start = offsetof(struct rte_mem_config, memseg), - .l_len = sizeof(early_mem_config.memseg), -}; - -/* Address of global and public configuration */ -static struct rte_config rte_config = { - .mem_config = _mem_config, -}; - /* internal configuration (per-core) */ struct lcore_config lcore_config[RTE_MAX_LCORE]; @@ -113,93 +93,14 @@ struct internal_config internal_config; /* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; -/* Return a pointer to the configuration structure */ -struct rte_config * -rte_eal_get_configuration(void) +inline void * +rte_eal_get_mem_cfg_addr(void) { - return _config; -} - -/* parse a sysfs (or other) file containing one integer value */ -int -eal_parse_sysfs_value(const char *filename, unsigned long *val) -{ - FILE *f; - char buf[BUFSIZ]; - char *end = NULL; - - if ((f = fopen(filename, "r")) == NULL) { - RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n", - __func__, filename); - return -1; - } - - if (fgets(buf, sizeof(buf), f) == NULL) { - RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", - __func__, filename); - fclose(f); - return -1; - } - *val = strtoul(buf, , 0); - if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) { - RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n", - __func__, filename); - fclose(f); - return -1; - } - fclose(f); - return 0; -} - - -/* create memory configuration in shared/mmap memory. Take out - * a write lock on the memsegs, so we can auto-detect primary/secondary. - * This means we never close the file while running (auto-close on exit). - * We also don't lock the whole file, so that in future we can use read-locks - * on other parts, e.g. memzones, to detect if there are running secondary - * processes. */ -static void -rte_eal_config_create(void) -{ - void *rte_mem_cfg_addr; - int retval; - - const char *pathname = eal_runtime_config_path(); - - if (internal_config.no_shconf) - return; - - if (mem_cfg_fd < 0){ - mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660); - if (mem_cfg_fd < 0) - rte_panic("Cannot open '%s' for rte_mem_config\n", pathname); - } - - retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config)); - if (retval < 0){ -