Skip to contentSkip to conversation

Move EAL common functions

PATCH Superseded Ravi Kerur 3 participants 11 messages Dec 30, 2014 – Jan 6, 2015 4 messages not in the archive

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Ravi Kerur

author
#0 lore raw

v3 cover Move EAL common functions

Changes in v3
Make subject line explicit on file names.
Commit log includes function names moved to common directory.

Changes in v2
Fix patch review comments from Neil.

Changes in v1
Common functions in linuxapp and bsdapp are moved into librte_eal/common directory.
New files added follow _common_ naming conventions.

Following checkpatch warnings are treated as false-positive.
WARNING: quoted string split across lines

Tested against ubuntu and FreeBSD.

Ravi Kerur (6):
Move common functions in eal_debug.c
Move common functions in eal_thread.c
Move common functions in eal.c
Move common functions in eal_lcore.c
Move common functions in eal_timer.c
Move common functions in eal_memory.c

 app/test/test_debug.c                     |   1 -
 lib/librte_eal/bsdapp/eal/Makefile        |  11 +-
 lib/librte_eal/bsdapp/eal/eal.c           | 233 +--------------------
 lib/librte_eal/bsdapp/eal/eal_debug.c     | 113 -----------
 lib/librte_eal/bsdapp/eal/eal_lcore.c     |  62 ++----
 lib/librte_eal/bsdapp/eal/eal_memory.c    |  40 +---
 lib/librte_eal/bsdapp/eal/eal_thread.c    | 233 ---------------------
 lib/librte_eal/bsdapp/eal/eal_timer.c     |  50 +----
 lib/librte_eal/common/eal_common.c        | 326 ++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_common_debug.c  | 106 ++++++++++
 lib/librte_eal/common/eal_common_lcore.c  | 106 ++++++++++
 lib/librte_eal/common/eal_common_memory.c |  38 +++-
 lib/librte_eal/common/eal_common_thread.c | 248 +++++++++++++++++++++++
 lib/librte_eal/common/eal_common_timer.c  |  95 +++++++++
 lib/librte_eal/common/eal_externs.h       |  45 +++++
 lib/librte_eal/common/eal_hugepages.h     |   1 +
 lib/librte_eal/common/eal_private.h       | 112 ++++++++++
 lib/librte_eal/common/include/rte_debug.h |   7 -
 lib/librte_eal/linuxapp/eal/Makefile      |  11 +-
 lib/librte_eal/linuxapp/eal/eal.c         | 246 +---------------------
 lib/librte_eal/linuxapp/eal/eal_debug.c   | 113 -----------
 lib/librte_eal/linuxapp/eal/eal_lcore.c   |  55 +----
 lib/librte_eal/linuxapp/eal/eal_memory.c  |  36 +---
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 233 ---------------------
 lib/librte_eal/linuxapp/eal/eal_timer.c   |  54 +----
 25 files changed, 1134 insertions(+), 1441 deletions(-)
 delete mode 100644 lib/librte_eal/bsdapp/eal/eal_debug.c
 delete mode 100644 lib/librte_eal/bsdapp/eal/eal_thread.c
 create mode 100644 lib/librte_eal/common/eal_common.c
 create mode 100644 lib/librte_eal/common/eal_common_debug.c
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c
 create mode 100644 lib/librte_eal/common/eal_common_thread.c
 create mode 100644 lib/librte_eal/common/eal_common_timer.c
 create mode 100644 lib/librte_eal/common/eal_externs.h
 delete mode 100644 lib/librte_eal/linuxapp/eal/eal_debug.c
 delete mode 100644 lib/librte_eal/linuxapp/eal/eal_thread.c
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v3 1/6 Move common functions in eal_debug.c

In reply to a message not in the archive

Changes in v3
Changed subject line to explicitly include file name

Changes in v2
Remove rte_dump_registers() function since it is not implemented. Fix comment for _rte_exit()

Changes in v1
eal_debug.c has no difference between Linux and BSD, move entire file to common directory.
Rename eal_debug.c to eal_common_debug.c Makefile changes to reflect file move and name change. Fix checkpatch warnings.

---
 app/test/test_debug.c                     |   1 -
 lib/librte_eal/bsdapp/eal/Makefile        |   2 +-
 lib/librte_eal/bsdapp/eal/eal_debug.c     | 113 ------------------------------
 lib/librte_eal/common/eal_common_debug.c  | 106 ++++++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_debug.h |   7 --
 lib/librte_eal/linuxapp/eal/Makefile      |   2 +-
 lib/librte_eal/linuxapp/eal/eal_debug.c   | 113 ------------------------------
 7 files changed, 108 insertions(+), 236 deletions(-)
 delete mode 100644 lib/librte_eal/bsdapp/eal/eal_debug.c
 create mode 100644 lib/librte_eal/common/eal_common_debug.c
 delete mode 100644 lib/librte_eal/linuxapp/eal/eal_debug.c
app/test/test_debug.c +0 -1
index 7c3ee92..01d4b76 100644
@@ -136,7 +136,6 @@ static int
 test_debug(void)
 {
 	rte_dump_stack();
-	rte_dump_registers();
 	if (test_panic() < 0)
 		return -1;
 	if (test_exit() < 0)
lib/librte_eal/bsdapp/eal/Makefile +1 -1
index d434882..9b83e11 100644
@@ -53,7 +53,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c
-SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_timer.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c
@@ -73,6 +72,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_debug.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_thread.o := -D_GNU_SOURCE
lib/librte_eal/bsdapp/eal/eal_debug.c deleted +0 -113

113 lines not on this page · raw message

lib/librte_eal/common/eal_common_debug.c new file +106 -0

106 lines not on this page · raw message

lib/librte_eal/common/include/rte_debug.h +0 -7
index 82ee3b3..3fb0307 100644
@@ -53,13 +53,6 @@ extern "C" {
 void rte_dump_stack(void);
 
 /**
- * Dump the registers of the calling core to the console.
- *
- * Note: Not implemented in a userapp environment; use gdb instead.
- */
-void rte_dump_registers(void);
-
-/**
  * Provide notification of a critical non-recoverable error and terminate
  * execution abnormally.
  *
lib/librte_eal/linuxapp/eal/Makefile +1 -1
index 72ecf3a..87b9bfc 100644
@@ -62,7 +62,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_uio.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_vfio.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_vfio_mp_sync.c
-SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_timer.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_interrupts.c
@@ -85,6 +84,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_options.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_debug.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
 CFLAGS_eal_thread.o := -D_GNU_SOURCE
lib/librte_eal/linuxapp/eal/eal_debug.c deleted +0 -113

113 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#4 lore raw

PATCH v3 2/6 Move common functions in eal_thread.c

In reply to a message not in the archive

Changes in v3
Changed subject line to explicitly include file name

Changes in v2
None

Changes in v1
eal_thread.c has minor differences between Linux and BSD, move entire file to common directory.
Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences. Rename eal_thread.c to eal_common_thread.c
Makefile changes to reflect file move and name change. Fix checkpatch warnings.

---
 lib/librte_eal/bsdapp/eal/Makefile        |   6 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c    | 233 ----------------------------
 lib/librte_eal/common/eal_common_thread.c | 248 ++++++++++++++++++++++++++++++
 lib/librte_eal/linuxapp/eal/Makefile      |   6 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 233 ----------------------------
 5 files changed, 254 insertions(+), 472 deletions(-)
 delete mode 100644 lib/librte_eal/bsdapp/eal/eal_thread.c
 create mode 100644 lib/librte_eal/common/eal_common_thread.c
 delete mode 100644 lib/librte_eal/linuxapp/eal/eal_thread.c
lib/librte_eal/bsdapp/eal/Makefile +3 -3
index 9b83e11..92dd9a6 100644
@@ -50,7 +50,6 @@ CFLAGS += $(WERROR_FLAGS) -O3
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) := eal.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_hugepage_info.c
-SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c
@@ -73,16 +72,17 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_debug.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
-#CFLAGS_eal_thread.o := -D_GNU_SOURCE
+#CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
 CFLAGS_eal_log.o := -D_GNU_SOURCE
 CFLAGS_eal_common_log.o := -D_GNU_SOURCE
 
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
-CFLAGS_eal_thread.o += -Wno-return-type
+CFLAGS_eal_common_thread.o += -Wno-return-type
 CFLAGS_eal_hpet.o += -Wno-return-type
 endif
 
lib/librte_eal/bsdapp/eal/eal_thread.c deleted +0 -233

233 lines not on this page · raw message

lib/librte_eal/common/eal_common_thread.c new file +248 -0

248 lines not on this page · raw message

lib/librte_eal/linuxapp/eal/Makefile +3 -3
index 87b9bfc..9252333 100644
@@ -56,7 +56,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_memory.c
 ifeq ($(CONFIG_RTE_LIBRTE_XEN_DOM0),y)
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_xen_memory.c
 endif
-SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_uio.c
@@ -85,9 +84,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_options.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_debug.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_thread.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
-CFLAGS_eal_thread.o := -D_GNU_SOURCE
+CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
 CFLAGS_eal_log.o := -D_GNU_SOURCE
 CFLAGS_eal_common_log.o := -D_GNU_SOURCE
 CFLAGS_eal_hugepage_info.o := -D_GNU_SOURCE
@@ -98,7 +98,7 @@ CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
-CFLAGS_eal_thread.o += -Wno-return-type
+CFLAGS_eal_common_thread.o += -Wno-return-type
 endif
 
 INC := rte_interrupts.h rte_kni_common.h rte_dom0_common.h
lib/librte_eal/linuxapp/eal/eal_thread.c deleted +0 -233

233 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#5 lore raw

PATCH v3 3/6 Move common functions in eal.c

In reply to a message not in the archive

Changes in v3
Changed subject line to explicitly include file name Commit log includes function names moved to common directory.

Changes in v2
In function rte_eal_config_create remove #ifdef _BSDAPP_ and initialize mem_cfg_addr unconditionally.

Changes in v1
Move common functions in eal.c to librte_eal/common/eal_common.c.

Following functions are moved to eal_common.c file.

struct rte_config *rte_eal_get_configuration(void);
int eal_parse_sysfs_value(const char *filename, unsigned long *val); static void rte_eal_config_create(void);
enum rte_proc_type_t eal_proc_type_detect(void);
void rte_eal_config_init(void);
rte_usage_hook_t rte_set_application_usage_hook(rte_usage_hook_t usage_func); inline size_t eal_get_hugepage_mem_size(void);
void eal_check_mem_on_local_socket(void);
int sync_func(__attribute__((unused)) void *arg);
inline void rte_eal_mcfg_complete(void);
int rte_eal_has_hugepages(void);
enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
enum rte_proc_type_t rte_eal_process_type(void);

Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

---
 lib/librte_eal/bsdapp/eal/Makefile    |   1 +
 lib/librte_eal/bsdapp/eal/eal.c       | 233 +-----------------------
 lib/librte_eal/common/eal_common.c    | 326 ++++++++++++++++++++++++++++++++++
 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, 437 insertions(+), 460 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common.c
 create mode 100644 lib/librte_eal/common/eal_externs.h
lib/librte_eal/bsdapp/eal/Makefile +1 -0
index 92dd9a6..050d70b 100644
@@ -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
lib/librte_eal/bsdapp/eal/eal.c +9 -224

281 lines not on this page · raw message

lib/librte_eal/common/eal_common.c new file +326 -0

326 lines not on this page · raw message

lib/librte_eal/common/eal_externs.h new file +42 -0

42 lines not on this page · raw message

lib/librte_eal/common/eal_hugepages.h +1 -0
index 38edac0..0b4d7a2 100644
@@ -63,5 +63,6 @@ struct hugepage_file {
  * for the EAL to use
  */
 int eal_hugepage_info_init(void);
+inline size_t eal_get_hugepage_mem_size(void);
 
 #endif /* EAL_HUGEPAGES_H */
lib/librte_eal/common/eal_private.h +47 -0

51 lines not on this page · raw message

lib/librte_eal/linuxapp/eal/Makefile +1 -0
index 9252333..60cc448 100644
@@ -70,6 +70,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_ivshmem.c
 endif
 
 # from common dir
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_memzone.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_launch.c
lib/librte_eal/linuxapp/eal/eal.c +10 -236

318 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#6 lore raw

PATCH v3 4/6 Move common functions in eal_lcore.c

In reply to a message not in the archive

Changes in v3
Changed subject line to explicitly include file name Commit log includes function names moved to common directory.

Changes in v2
None

Changes in v1
Move common function in eal_lcore.c to librte_eal/common/ eal_common_lcore.c file.

Following function is moved to eal_common_lcore.c file

int rte_eal_cpu_init(void);

Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in common function.
Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

---
 lib/librte_eal/bsdapp/eal/Makefile       |   1 +
 lib/librte_eal/bsdapp/eal/eal_lcore.c    |  62 ++++--------------
 lib/librte_eal/common/eal_common_lcore.c | 106 +++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_private.h      |  32 ++++++++++
 lib/librte_eal/linuxapp/eal/Makefile     |   1 +
 lib/librte_eal/linuxapp/eal/eal_lcore.c  |  55 +---------------
 6 files changed, 155 insertions(+), 102 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
index 050d70b..560b7a3 100644
@@ -74,6 +74,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
lib/librte_eal/bsdapp/eal/eal_lcore.c +12 -50

72 lines not on this page · raw message

lib/librte_eal/common/eal_common_lcore.c new file +106 -0

106 lines not on this page · raw message

lib/librte_eal/common/eal_private.h +32 -0
index b1d68bc..9fe91b3 100644
@@ -250,4 +250,36 @@ void rte_eal_config_attach(void);
  */
 void rte_eal_config_reattach(void);
 
+/**
+ * This function gets cpu socket_id
+ *
+ * This function is private to the EAL.
+ */
+unsigned cpu_socket_id(unsigned lcore_id);
+
+/**
+ * This function gets cpu core_id
+ *
+ * This function is private to the EAL.
+ */
+unsigned cpu_core_id(unsigned lcore_id);
+
+#ifdef RTE_EXEC_ENV_BSDAPP
+/**
+ * This function gets no. of cpus
+ *
+ * This function is private to the EAL.
+ */
+int get_ncpus(void);
+
+#else /* RTE_EXEC_ENV_BSDAPP */
+/**
+ * This function check if cpu is present
+ *
+ * This function is private to the EAL.
+ */
+int cpu_detected(unsigned lcore_id);
+
+#endif /* RTE_EXEC_ENV_BSDAPP */
+
 #endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +1 -0
index 60cc448..ff185fd 100644
@@ -86,6 +86,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_options.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_thread.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
 CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
lib/librte_eal/linuxapp/eal/eal_lcore.c +3 -52

76 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#7 lore raw

PATCH v3 5/6 Move common functions in eal_timer.c

In reply to a message not in the archive

Changes in v3
Changed subject line to explicitly include file name Commit log includes function names moved to common directory.

Changes in v2
Use common function name set_tsc_freq_from_sysctl for BSD and Linux. Update comments about its actuality in function declaration.

Changes in v1
Move common functions in eal_timer.c to librte_eal/common/ eal_common_timer.c file.

Following functions are moved to eal_common_timer.c file

void rte_delay_us(unsigned us);
uint64_t rte_get_tsc_hz(void);
static void set_tsc_freq_fallback(void);
void set_tsc_freq(void);

Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

---
 lib/librte_eal/bsdapp/eal/Makefile       |  1 +
 lib/librte_eal/bsdapp/eal/eal_timer.c    | 50 +----------------
 lib/librte_eal/common/eal_common_timer.c | 95 ++++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_externs.h      |  3 +
 lib/librte_eal/common/eal_private.h      | 15 +++++
 lib/librte_eal/linuxapp/eal/Makefile     |  1 +
 lib/librte_eal/linuxapp/eal/eal_timer.c  | 54 +-----------------
 7 files changed, 120 insertions(+), 99 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_timer.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
index 560b7a3..fb1faa3 100644
@@ -75,6 +75,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_timer.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
lib/librte_eal/bsdapp/eal/eal_timer.c +2 -48

68 lines not on this page · raw message

lib/librte_eal/common/eal_common_timer.c new file +95 -0

95 lines not on this page · raw message

lib/librte_eal/common/eal_externs.h +3 -0
index b19bea6..124ab65 100644
@@ -39,4 +39,7 @@ extern struct rte_config rte_config;
 extern int mem_cfg_fd;
 extern rte_usage_hook_t	rte_application_usage_hook;
 
+/* Extern declarations defined in eal_common_timer.c */
+extern uint64_t eal_tsc_resolution_hz;
+
 #endif
lib/librte_eal/common/eal_private.h +15 -0
index 9fe91b3..98a08f0 100644
@@ -264,6 +264,21 @@ unsigned cpu_socket_id(unsigned lcore_id);
  */
 unsigned cpu_core_id(unsigned lcore_id);
 
+/**
+ * This function measures TSC frequency
+ *
+ * This function is private to the EAL.
+ */
+void set_tsc_freq(void);
+
+/**
+ * This function sets TSC frequency from sysctl
+ * for BSD and from clock for Linux.
+ *
+ * This function is private to the EAL.
+ */
+int set_tsc_freq_from_sysctl(void);
+
 #ifdef RTE_EXEC_ENV_BSDAPP
 /**
  * This function gets no. of cpus
lib/librte_eal/linuxapp/eal/Makefile +1 -0
index ff185fd..2404423 100644
@@ -87,6 +87,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_options.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_timer.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
 CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
lib/librte_eal/linuxapp/eal/eal_timer.c +3 -51

81 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#10 lore raw

PATCH v3 6/6 Move common functions in eal_memory.c

In reply to a message not in the archive

Changes in v3
Changed subject line to explicitly include file name Commit log includes function names moved to common directory.

Changes in v2
Use common function names rte_eal_hugepage_init and rte_eal_hugepage_attach for BSD and Linux.
Update comments about its actuality in function declaration.

Changes in v1
Move common functions in eal_memory.c to librte_eal/common/ eal_common_memory.c file.

Following functions are moved to eal_common_memory.c file

static int rte_eal_memdevice_init(void);
int rte_eal_memory_init(void);

Fix checkpatch warnings and errors.

---
 lib/librte_eal/bsdapp/eal/eal_memory.c    | 40 ++++---------------------------
 lib/librte_eal/common/eal_common_memory.c | 38 +++++++++++++++++++++++++++--
 lib/librte_eal/common/eal_private.h       | 18 ++++++++++++++
 lib/librte_eal/linuxapp/eal/eal_memory.c  | 36 ++--------------------------
 4 files changed, 60 insertions(+), 72 deletions(-)
lib/librte_eal/bsdapp/eal/eal_memory.c +4 -36
index 65ee87d..0b62d6d 100644
@@ -59,8 +59,8 @@ rte_mem_virt2phy(const void *virtaddr)
 	return RTE_BAD_PHYS_ADDR;
 }
 
-static int
-rte_eal_contigmem_init(void)
+int
+rte_eal_hugepage_init(void)
 {
 	struct rte_mem_config *mcfg;
 	uint64_t total_mem = 0;
@@ -130,8 +130,8 @@ rte_eal_contigmem_init(void)
 	return 0;
 }
 
-static int
-rte_eal_contigmem_attach(void)
+int
+rte_eal_hugepage_attach(void)
 {
 	const struct hugepage_info *hpi;
 	int fd_hugepage_info, fd_hugepage = -1;
@@ -190,35 +190,3 @@ error:
 	return -1;
 }
 
-
-static int
-rte_eal_memdevice_init(void)
-{
-	struct rte_config *config;
-
-	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
-		return 0;
-
-	config = rte_eal_get_configuration();
-	config->mem_config->nchannel = internal_config.force_nchannel;
-	config->mem_config->nrank = internal_config.force_nrank;
-
-	return 0;
-}
-
-/* init memory subsystem */
-int
-rte_eal_memory_init(void)
-{
-	RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
-	const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
-			rte_eal_contigmem_init() :
-			rte_eal_contigmem_attach();
-	if (retval < 0)
-		return -1;
-
-	if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() < 0)
-		return -1;
-
-	return 0;
-}
lib/librte_eal/common/eal_common_memory.c +36 -2
index 77830f8..cb27930 100644
@@ -46,6 +46,7 @@
 #include <rte_log.h>
 
 #include "eal_private.h"
+#include "eal_internal_cfg.h"
 
 /*
  * Return a pointer to a read-only table of struct rte_physmem_desc
@@ -70,7 +71,7 @@ rte_eal_get_physmem_size(void)
 	/* get pointer to global configuration */
 	mcfg = rte_eal_get_configuration()->mem_config;
 
-	for (i=0; i<RTE_MAX_MEMSEG; i++) {
+	for (i = 0; i < RTE_MAX_MEMSEG; i++) {
 		if (mcfg->memseg[i].addr == NULL)
 			break;
 
@@ -90,7 +91,7 @@ rte_dump_physmem_layout(FILE *f)
 	/* get pointer to global configuration */
 	mcfg = rte_eal_get_configuration()->mem_config;
 
-	for (i=0; i<RTE_MAX_MEMSEG; i++) {
+	for (i = 0; i < RTE_MAX_MEMSEG; i++) {
 		if (mcfg->memseg[i].addr == NULL)
 			break;
 
@@ -119,3 +120,36 @@ unsigned rte_memory_get_nrank(void)
 {
 	return rte_eal_get_configuration()->mem_config->nrank;
 }
+
+static int
+rte_eal_memdevice_init(void)
+{
+	struct rte_config *config;
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return 0;
+
+	config = rte_eal_get_configuration();
+	config->mem_config->nchannel = internal_config.force_nchannel;
+	config->mem_config->nrank = internal_config.force_nrank;
+
+	return 0;
+}
+
+/* init memory subsystem */
+int
+rte_eal_memory_init(void)
+{
+	RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
+	const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
+			rte_eal_hugepage_init() :
+			rte_eal_hugepage_attach();
+
+	if (retval < 0)
+		return -1;
+
+	if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() < 0)
+		return -1;
+
+	return 0;
+}
lib/librte_eal/common/eal_private.h +18 -0
index 98a08f0..82a724d 100644
@@ -279,6 +279,24 @@ void set_tsc_freq(void);
  */
 int set_tsc_freq_from_sysctl(void);
 
+/**
+ * This function prepares physical memory mapping
+ * i.e. hugepages on Linux and
+ *      contigmem on BSD.
+ *
+ * This function is private to the EAL.
+ */
+int rte_eal_hugepage_init(void);
+
+/**
+ * This function creates memory mapping in secondary
+ * i.e. hugepages on Linux and
+ *      contigmem on BSD.
+ *
+ * This function is private to the EAL.
+ */
+int rte_eal_hugepage_attach(void);
+
 #ifdef RTE_EXEC_ENV_BSDAPP
 /**
  * This function gets no. of cpus
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -34
index bae2507..f4d91df 100644
@@ -1031,7 +1031,7 @@ calc_num_pages_per_socket(uint64_t * memory,
  *  6. unmap the first mapping
  *  7. fill memsegs in configuration with contiguous zones
  */
-static int
+int
 rte_eal_hugepage_init(void)
 {
 	struct rte_mem_config *mcfg;
@@ -1369,7 +1369,7 @@ getFileSize(int fd)
  * configuration and finds the hugepages which form that segment, mapping them
  * in order to form a contiguous block in the virtual memory space
  */
-static int
+int
 rte_eal_hugepage_attach(void)
 {
 	const struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
@@ -1530,35 +1530,3 @@ error:
 	return -1;
 }
 
-static int
-rte_eal_memdevice_init(void)
-{
-	struct rte_config *config;
-
-	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
-		return 0;
-
-	config = rte_eal_get_configuration();
-	config->mem_config->nchannel = internal_config.force_nchannel;
-	config->mem_config->nrank = internal_config.force_nrank;
-
-	return 0;
-}
-
-
-/* init memory subsystem */
-int
-rte_eal_memory_init(void)
-{
-	RTE_LOG(INFO, EAL, "Setting up memory...\n");
-	const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
-			rte_eal_hugepage_init() :
-			rte_eal_hugepage_attach();
-	if (retval < 0)
-		return -1;
-
-	if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() < 0)
-		return -1;
-
-	return 0;
-}
Signature · 1 line
1.9.1
Acked-by
#14 lore raw
In reply to a message not in the archive
Quoted 53 lines · Ravi Kerur

Changes in v3
Make subject line explicit on file names.
Commit log includes function names moved to common directory.

Changes in v2
Fix patch review comments from Neil.

Changes in v1
Common functions in linuxapp and bsdapp are moved into librte_eal/common directory.
New files added follow _common_ naming conventions.

Following checkpatch warnings are treated as false-positive.
WARNING: quoted string split across lines

Tested against ubuntu and FreeBSD.

Ravi Kerur (6):
Move common functions in eal_debug.c
Move common functions in eal_thread.c
Move common functions in eal.c
Move common functions in eal_lcore.c
Move common functions in eal_timer.c
Move common functions in eal_memory.c

 app/test/test_debug.c                     |   1 -
 lib/librte_eal/bsdapp/eal/Makefile        |  11 +-
 lib/librte_eal/bsdapp/eal/eal.c           | 233 +--------------------
 lib/librte_eal/bsdapp/eal/eal_debug.c     | 113 -----------
 lib/librte_eal/bsdapp/eal/eal_lcore.c     |  62 ++----
 lib/librte_eal/bsdapp/eal/eal_memory.c    |  40 +---
 lib/librte_eal/bsdapp/eal/eal_thread.c    | 233 ---------------------
 lib/librte_eal/bsdapp/eal/eal_timer.c     |  50 +----
 lib/librte_eal/common/eal_common.c        | 326 ++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_common_debug.c  | 106 ++++++++++
 lib/librte_eal/common/eal_common_lcore.c  | 106 ++++++++++
 lib/librte_eal/common/eal_common_memory.c |  38 +++-
 lib/librte_eal/common/eal_common_thread.c | 248 +++++++++++++++++++++++
 lib/librte_eal/common/eal_common_timer.c  |  95 +++++++++
 lib/librte_eal/common/eal_externs.h       |  45 +++++
 lib/librte_eal/common/eal_hugepages.h     |   1 +
 lib/librte_eal/common/eal_private.h       | 112 ++++++++++
 lib/librte_eal/common/include/rte_debug.h |   7 -
 lib/librte_eal/linuxapp/eal/Makefile      |  11 +-
 lib/librte_eal/linuxapp/eal/eal.c         | 246 +---------------------
 lib/librte_eal/linuxapp/eal/eal_debug.c   | 113 -----------
 lib/librte_eal/linuxapp/eal/eal_lcore.c   |  55 +----
 lib/librte_eal/linuxapp/eal/eal_memory.c  |  36 +---
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 233 ---------------------
 lib/librte_eal/linuxapp/eal/eal_timer.c   |  54 +----
 25 files changed, 1134 insertions(+), 1441 deletions(-)
 delete mode 100644 lib/librte_eal/bsdapp/eal/eal_debug.c
 delete mode 100644 lib/librte_eal/bsdapp/eal/eal_thread.c
Quoted 13 lines
 create mode 100644 lib/librte_eal/common/eal_common.c
 create mode 100644 lib/librte_eal/common/eal_common_debug.c
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c
 create mode 100644 lib/librte_eal/common/eal_common_thread.c
 create mode 100644 lib/librte_eal/common/eal_common_timer.c
 create mode 100644 lib/librte_eal/common/eal_externs.h
 delete mode 100644 lib/librte_eal/linuxapp/eal/eal_debug.c
 delete mode 100644 lib/librte_eal/linuxapp/eal/eal_thread.c
Signature · 1 line
1.9.1

Thanks
For the series

#9 lore raw

Re: [PATCH v3 5/6] Move common functions in eal_timer.c

In reply to a message not in the archive

2014-12-30 11:37, Ravi Kerur:

Quoted 1 line

Use common function name set_tsc_freq_from_sysctl for BSD and Linux.

[...]

Quoted 7 lines
lib/librte_eal/common/eal_private.h +7 -0
+/**
+ * This function sets TSC frequency from sysctl
+ * for BSD and from clock for Linux.
+ *
+ * This function is private to the EAL.
+ */
+int set_tsc_freq_from_sysctl(void);

[...]

lib/librte_eal/linuxapp/eal/eal_timer.c check_tsc_flags(void) · line 261

Quoted 4 lines
lib/librte_eal/linuxapp/eal/eal_timer.c +2 -2
-static int
-set_tsc_freq_from_clock(void)
+int
+set_tsc_freq_from_sysctl(void)

NACK
It doesn't seem reasonnable to call a function set_tsc_freq_from_sysctl() if it doesn't use sysctl.

Signature · 1 line
Thomas
#12 lore raw

Re: [PATCH v3 6/6] Move common functions in eal_memory.c

In reply to a message not in the archive

2014-12-30 11:37, Ravi Kerur:

Quoted 2 lines

Use common function names rte_eal_hugepage_init and rte_eal_hugepage_attach for BSD and Linux.

I'd like to be sure that using hugepage wording instead of contigmem is not too weird for BSD people.
Do not forget that we have a kernel module called contigmem. Here, an ifdef or a wrapper seems appropriate to keep right wording.

Signature · 1 line
Thomas
author
#13 lore raw

Re: [PATCH v3 6/6] Move common functions in eal_memory.c

I have added wrapper function for BSD.

Quoted 12 lines · Thomas Monjalon

2014-12-30 11:37, Ravi Kerur:

Quoted 2 lines

Use common function names rte_eal_hugepage_init and rte_eal_hugepage_attach for BSD and Linux.

I'd like to be sure that using hugepage wording instead of contigmem is not too weird for BSD people.
Do not forget that we have a kernel module called contigmem. Here, an ifdef or a wrapper seems appropriate to keep right wording.

--
Thomas