Move EAL common function
v4 cover Move EAL common function
Fix v3 PATCH review comments from Thomas. eal_common.c is further split into eal_common_system.c and eal_common_runtime.c files with appropriate functions. eal_externs.h file is removed and _get_ and _set_ APIs are used to access variables.
Functions with same signature in Linux and BSD but different names are kept intact but Linux function name is used as wrapper for BSD.
Added eal_pci.c in v4 PATCH.
New files added follow _common_ naming conventions. Tested against Ubuntu and FreeBSD.
Ravi Kerur (7):
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
Move common functions in eal_pci.c
app/test/test_debug.c | 1 - lib/librte_eal/bsdapp/eal/Makefile | 12 +- lib/librte_eal/bsdapp/eal/eal.c | 269 ++++---------------------- lib/librte_eal/bsdapp/eal/eal_debug.c | 113 ----------- lib/librte_eal/bsdapp/eal/eal_lcore.c | 61 ++---- lib/librte_eal/bsdapp/eal/eal_memory.c | 47 ++--- lib/librte_eal/bsdapp/eal/eal_pci.c | 127 +------------ lib/librte_eal/bsdapp/eal/eal_thread.c | 233 ----------------------- lib/librte_eal/bsdapp/eal/eal_timer.c | 54 +----- lib/librte_eal/common/eal_common_debug.c | 106 +++++++++++ lib/librte_eal/common/eal_common_lcore.c | 95 ++++++++++ lib/librte_eal/common/eal_common_memory.c | 38 +++- lib/librte_eal/common/eal_common_pci.c | 171 ++++++++++++++++- lib/librte_eal/common/eal_common_runtime.c | 201 ++++++++++++++++++++ lib/librte_eal/common/eal_common_system.c | 203 ++++++++++++++++++++ lib/librte_eal/common/eal_common_thread.c | 248 ++++++++++++++++++++++++ lib/librte_eal/common/eal_common_timer.c | 101 ++++++++++ lib/librte_eal/common/eal_hugepages.h | 1 + lib/librte_eal/common/eal_private.h | 205 ++++++++++++++++++++ lib/librte_eal/common/include/rte_debug.h | 7 - lib/librte_eal/linuxapp/eal/Makefile | 12 +- lib/librte_eal/linuxapp/eal/eal.c | 290 +++++------------------------ 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_pci.c | 113 +---------- lib/librte_eal/linuxapp/eal/eal_pci_init.h | 6 - lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 36 +--- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 9 +- lib/librte_eal/linuxapp/eal/eal_thread.c | 233 ----------------------- lib/librte_eal/linuxapp/eal/eal_timer.c | 55 +----- 31 files changed, 1522 insertions(+), 1729 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_debug.c create mode 100644 lib/librte_eal/common/eal_common_lcore.c create mode 100644 lib/librte_eal/common/eal_common_runtime.c create mode 100644 lib/librte_eal/common/eal_common_system.c create mode 100644 lib/librte_eal/common/eal_common_thread.c create mode 100644 lib/librte_eal/common/eal_common_timer.c 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
A message that is not in the archive (sent off-list or not yet received): 1420565170-17365-1-git-send-email-rkerur-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v4 1/7 Move common functions in eal_debug.c
Changes in v4
None
Changes in v3
Changed subject to be more explicit on file name inclusion.
Changes in v2
Remove rte_dump_registers() function since it is not implemented. Fix comment for _rte_exit()
Changes in v1eal_debug.c has no difference between Linux and BSD, move entire file into 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
@@ -136,7 +136,6 @@ static inttest_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
@@ -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
@@ -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
@@ -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
A message that is not in the archive (sent off-list or not yet received): 1420565213-17429-1-git-send-email-rkerur-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v4 2/7 Move common functions in eal_thread.c
Changes in v4
None
Changes in v3
Changed subject to be more explicit on file name inclusion.
Changes in v2
None
Changes in v1eal_thread.c has minor differences between Linux and BSD, move entire file into common directory.
Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences. Rename eal_thread.c to eal_common_thread.cMakefile 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
@@ -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
@@ -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
PATCH v4 3/7 Move common functions in eal.c
In reply to a message not in the archiveChanges in v4
Remove eal_externs.h file, instead use _get_ and _set_ APIS to access those variables.
Split eal_common.c into eal_common_system.c and
and eal_common_runtime.crte_eal prefix functions are moved to _runtime_ and eal prefix functions are moved to _system_ files respectively
Changes in v3
Changed subject to be more explicit on file name inclusion.
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 files added.
Fix checkpatch warnings and errors.
--- lib/librte_eal/bsdapp/eal/Makefile | 2 + lib/librte_eal/bsdapp/eal/eal.c | 269 ++++---------------------- lib/librte_eal/common/eal_common_runtime.c | 201 ++++++++++++++++++++ lib/librte_eal/common/eal_common_system.c | 203 ++++++++++++++++++++ lib/librte_eal/common/eal_hugepages.h | 1 + lib/librte_eal/common/eal_private.h | 78 ++++++++ lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal.c | 290 +++++------------------------ 8 files changed, 563 insertions(+), 483 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_runtime.c create mode 100644 lib/librte_eal/common/eal_common_system.c
lib/librte_eal/bsdapp/eal/Makefile +2 -0
@@ -58,6 +58,8 @@ 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_system.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_runtime.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 +34 -235
348 lines not on this page · raw message
lib/librte_eal/common/eal_common_runtime.c new file +201 -0
201 lines not on this page · raw message
lib/librte_eal/common/eal_common_system.c new file +203 -0
203 lines not on this page · raw message
lib/librte_eal/common/eal_hugepages.h +1 -0
@@ -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 +78 -0
88 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/Makefile +2 -0
@@ -70,6 +70,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_ivshmem.c endif # from common dir +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_system.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_runtime.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 +42 -248
407 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 4/7 Move common functions in eal_lcore.c
In reply to a message not in the archiveChanges in v4
Implement cpu_detected() for BSD.
Have common RTE_LOG for Linux and BSD in rte_eal_cpu_init(). Remove RTE_EXEC_ENV_BSDAPP in common file.
Changes in v3
Changed subject to be more explicit on file name inclusion.
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 | 61 +++++--------------- lib/librte_eal/common/eal_common_lcore.c | 95 ++++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 21 +++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal_lcore.c | 55 +----------------- 6 files changed, 136 insertions(+), 98 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_lcore.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -75,6 +75,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 +15 -46
75 lines not on this page · raw message
lib/librte_eal/common/eal_common_lcore.c new file +95 -0
95 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +21 -0
@@ -281,4 +281,25 @@ 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); + +/** +* This function check if cpu is present +* +* This function is private to the EAL. +*/ +int cpu_detected (unsigned lcore_id); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -87,6 +87,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
PATCH v4 5/7 Move common functions in eal_timer.c
In reply to a message not in the archiveChanges in v4
Removed extern declaration of eal_tsc_resolution_hz, instead provided _set_ API.
Make set_tsc_freq_from_clock as wrapper function for BSD.
Changes in v3
Changed subject to be more explicit on file name inclusion.
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 | 54 +++-------------- lib/librte_eal/common/eal_common_timer.c | 101 +++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 24 ++++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal_timer.c | 55 ++--------------- 6 files changed, 140 insertions(+), 96 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_timer.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -76,6 +76,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 +9 -45
80 lines not on this page · raw message
lib/librte_eal/common/eal_common_timer.c new file +101 -0
101 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +24 -0
@@ -302,4 +302,28 @@ unsigned cpu_core_id(unsigned lcore_id);*/ int cpu_detected (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. +* Is a wrapper function for BSD which will +* internally call set_tsc_freq_from_sysctl. +* +* This function is private to the EAL. +*/ +int set_tsc_freq_from_clock (void ); + +/** +* This function sets TSC frequency +* +* This function is private to the EAL. +*/ +void rte_set_tsc_hz (uint64_t tsc_hz); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -88,6 +88,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 +4 -51
91 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 6/7 Move common functions in eal_memory.c
In reply to a message not in the archiveChanges in v4
Make rte_eal_hugepage_init and rte_eal_hugepage_attach as wrapper functions for BSD.
Changes in v3
Changed subject to be more explicit on file name inclusion.
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 | 47 +++++++++++-------------------- lib/librte_eal/common/eal_common_memory.c | 38 +++++++++++++++++++++++-- lib/librte_eal/common/eal_private.h | 22 +++++++++++++++ lib/librte_eal/linuxapp/eal/eal_memory.c | 36 ++--------------------- 4 files changed, 76 insertions(+), 67 deletions(-)
lib/librte_eal/bsdapp/eal/eal_memory.c +16 -31
@@ -59,7 +59,7 @@ rte_mem_virt2phy(const void *virtaddr)return RTE_BAD_PHYS_ADDR ; } -static int +static inline int rte_eal_contigmem_init (void ) {struct rte_mem_config *mcfg;
@@ -130,7 +130,16 @@ rte_eal_contigmem_init(void)return 0 ; } -static int +/* +* Wrapper function to initialize contigmem. +*/ +int +rte_eal_hugepage_init (void ) +{ +return rte_eal_contigmem_init (); +} + +static inline int rte_eal_contigmem_attach (void ) {const struct hugepage_info *hpi;
@@ -190,35 +199,11 @@ 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 */ +/* +* Wrapper function to attach contigmem. +*/ int -rte_eal_memory_init (void ) +rte_eal_hugepage_attach (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 ; +return rte_eal_contigmem_attach (); }
lib/librte_eal/common/eal_common_memory.c +36 -2
@@ -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 +22 -0
@@ -326,4 +326,26 @@ int set_tsc_freq_from_clock(void);*/ void rte_set_tsc_hz (uint64_t tsc_hz); +/** +* This function prepares physical memory mapping +* i.e. hugepages on Linux and +* contigmem on BSD. +* It is a wrapper function for BSD which will +* internally call contigmem_init. +* +* 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. +* It is a wrapper function for BSD which will +* internally call contigmem_attach. +* +* This function is private to the EAL. +*/ +int rte_eal_hugepage_attach (void ); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -34
@@ -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
PATCH v4 7/7 Move common functions in eal_pci.c
In reply to a message not in the archiveChanges in v4
Move common functions in eal_pci.c to librte_eal/common/ eal_common_pci.c file.
Following functions are moved to eal_common_pci.c file.
void *pci_map_resource(void *requested_addr, const int vfio_fd,
const char *devname, off_t offset, size_t size);
int pci_addr_comparison(struct rte_pci_addr *addr,
struct rte_pci_addr *addr2);
int rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
struct rte_pci_device *dev);Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in common function.
Fix checkpatch warnings and errors.
Changes in v3
N/A
Changes in v2
N/A
Changes in v1
N/A
--- lib/librte_eal/bsdapp/eal/eal_pci.c | 127 +-------------------- lib/librte_eal/common/eal_common_pci.c | 171 ++++++++++++++++++++++++++++- lib/librte_eal/common/eal_private.h | 60 ++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 113 +------------------ lib/librte_eal/linuxapp/eal/eal_pci_init.h | 6 - lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 36 ++---- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 9 +- 7 files changed, 245 insertions(+), 277 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +5 -122
@@ -109,7 +109,7 @@ TAILQ_HEAD(uio_res_list, uio_resource);static struct uio_res_list *uio_res_list =NULL ;/* unbind kernel driver for this device */ -static int +int pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused) { RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented "
@@ -117,45 +117,6 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)return -ENOTSUP ; } -/* map a particular resource from a file */ -static void * -pci_map_resource (void *requested_addr,const char *devname,off_t offset, -size_t size) -{ -int fd; -void *mapaddr; - -/* -* open devname, to mmap it -*/ - fd =open (devname,O_RDWR ); -if (fd <0 ) { -RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , - devname,strerror (errno)); - goto fail; - } - -/* Map the PCI memory resource of device */ - mapaddr =mmap (requested_addr, size,PROT_READ |PROT_WRITE , -MAP_SHARED , fd, offset); -close (fd); -if (mapaddr ==MAP_FAILED || - (requested_addr !=NULL && mapaddr != requested_addr)) { -RTE_LOG (ERR ,EAL ,"%s(): cannot mmap(%s(%d), %p, 0x%lx, 0x%lx):" -" %s (%p)\n" , __func__, devname, fd, requested_addr, - (unsigned long )size, (unsigned long )offset, -strerror (errno), mapaddr); - goto fail; - } - -RTE_LOG (DEBUG ,EAL ," PCI memory mapped at %p\n" , mapaddr); - -return mapaddr; - -fail: -return NULL ; -} -static int pci_uio_map_secondary (struct rte_pci_device *dev) {
@@ -169,7 +130,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)continue ;for (i =0 ; i != uio_res->nb_maps; i++) { -if (pci_map_resource (uio_res->maps[i].addr, +if (pci_map_resource (uio_res->maps[i].addr,INT_MIN , uio_res->path, (off_t )uio_res->maps[i].offset, (size_t)uio_res->maps[i].size)
@@ -187,7 +148,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev) }/* map the PCI resource of a PCI device in virtual memory */ -static int +int pci_uio_map_resource (struct rte_pci_device *dev) {int i, j;
@@ -253,7 +214,8 @@ pci_uio_map_resource(struct rte_pci_device *dev) maps[j].phaddr = dev->mem_resource[i].phys_addr; maps[j].size = dev->mem_resource[i].len;if (maps[j].addr !=NULL || - (mapaddr =pci_map_resource (NULL , devname, (off_t )offset, + (mapaddr =pci_map_resource (NULL ,INT_MIN , devname, + (off_t )offset, (size_t )maps[j].size) ) ==NULL ) {rte_free (uio_res);
@@ -270,20 +232,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)return (0 ); } -/* Compare two PCI device addresses. */ -static int -pci_addr_comparison (struct rte_pci_addr *addr,struct rte_pci_addr *addr2) -{ -uint64_t dev_addr = (addr->domain <<24 ) + (addr->bus <<16 ) + (addr->devid <<8 ) + addr->function; -uint64_t dev_addr2 = (addr2->domain <<24 ) + (addr2->bus <<16 ) + (addr2->devid <<8 ) + addr2->function; - -if (dev_addr > dev_addr2) -return 1 ; -else -return 0 ; -} - -/* Scan one pci sysfs entry, and fill the devices list from it. */ static int pci_scan_one (int dev_pci_fd,struct pci_conf *conf)
@@ -425,71 +373,6 @@ error:return -1 ; } -/* -* If vendor/device ID match, call the devinit() function of the -* driver. -*/ -int -rte_eal_pci_probe_one_driver (struct rte_pci_driver *dr,struct rte_pci_device *dev) -{ -struct rte_pci_id *id_table; -int ret; - -for (id_table = dr->id_table ; id_table->vendor_id !=0 ; id_table++) { - -/* check if device's identifiers match the driver's ones */ -if (id_table->vendor_id != dev->id.vendor_id && - id_table->vendor_id !=PCI_ANY_ID ) -continue ; -if (id_table->device_id != dev->id.device_id && - id_table->device_id !=PCI_ANY_ID ) -continue ; -if (id_table->subsystem_vendor_id != dev->id.subsystem_vendor_id && - id_table->subsystem_vendor_id !=PCI_ANY_ID ) -continue ; -if (id_table->subsystem_device_id != dev->id.subsystem_device_id && - id_table->subsystem_device_id !=PCI_ANY_ID ) -continue ; - -struct rte_pci_addr *loc = &dev->addr; - -RTE_LOG (DEBUG ,EAL ,"PCI device " PCI_PRI_FMT " on NUMA socket %i\n" , - loc->domain, loc->bus, loc->devid, loc->function, - dev->numa_node); - -RTE_LOG (DEBUG ,EAL ," probe driver: %x:%x %s\n" , dev->id.vendor_id, - dev->id.device_id, dr->name); - -/* no initialization when blacklisted, return without error */ -if (dev->devargs !=NULL && - dev->devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { - -RTE_LOG (DEBUG ,EAL ," Device is blacklisted, not initializing\n" ); -return 0 ; - } - -if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { -/* map resources for devices that use igb_uio */ - ret =pci_uio_map_resource (dev); -if (ret !=0 ) -return ret; - }else if (dr->drv_flags &RTE_PCI_DRV_FORCE_UNBIND && -rte_eal_process_type () ==RTE_PROC_PRIMARY ) { -/* unbind current driver */ -if (pci_unbind_kernel_driver (dev) <0 ) -return -1 ; - } - -/* reference driver structure */ - dev->driver = dr; - -/* call the driver devinit() function */ -return dr->devinit (dr, dev); - } -/* return positive value if driver is not found */ -return 1 ; -} -/* Init the PCI EAL subsystem */ int rte_eal_pci_init (void )
lib/librte_eal/common/eal_common_pci.c +165 -6
187 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +60 -0
70 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_pci.c +3 -110
149 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_pci_init.h +0 -6
@@ -65,12 +65,6 @@ extern struct mapped_pci_res_list *pci_res_list;extern void *pci_map_addr;void *pci_find_max_end_va (void ); -void *pci_map_resource (void *requested_addr,int fd,off_t offset, -size_t size); - -/* map IGB_UIO resource prototype */ -int pci_uio_map_resource (struct rte_pci_device *dev); -#ifdef VFIO_PRESENT #define VFIO_MAX_GROUPS 64
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +7 -29
@@ -46,6 +46,7 @@#include "rte_pci_dev_ids.h" #include "eal_filesystem.h" #include "eal_pci_init.h" +#include "eal_private.h" static int pci_parse_sysfs_value (const char *filename,uint64_t *val);
@@ -117,7 +118,7 @@ pci_uio_get_mappings(const char *devname, struct pci_map maps[], int nb_maps)static int pci_uio_map_secondary (struct rte_pci_device *dev) { -int fd, i; +int i;struct mapped_pci_resource *uio_res; TAILQ_FOREACH(uio_res, pci_res_list, next) {
@@ -127,27 +128,15 @@ pci_uio_map_secondary(struct rte_pci_device *dev)continue ;for (i =0 ; i != uio_res->nb_maps; i++) { -/* -* open devname, to mmap it -*/ - fd =open (uio_res->path,O_RDWR ); -if (fd <0 ) { -RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , - uio_res->path,strerror (errno)); -return -1 ; - } - -if (pci_map_resource (uio_res->maps[i].addr, fd, +if (pci_map_resource (uio_res->maps[i].addr,INT_MIN , + uio_res->path, (off_t )uio_res->maps[i].offset, (size_t )uio_res->maps[i].size) != uio_res->maps[i].addr) {RTE_LOG (ERR ,EAL ,"Cannot mmap device resource\n" ); -close (fd);return -1 ; } -/* fd is not needed in slave process, close it */ -close (fd); }return 0 ; }
@@ -344,7 +333,6 @@ pci_uio_map_resource(struct rte_pci_device *dev) maps = uio_res->maps;for (i =0 ; i !=PCI_MAX_RESOURCE ; i++) { -int fd;/* skip empty BAR */ phaddr = dev->mem_resource[i].phys_addr;
@@ -361,16 +349,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)int fail =0 ; offset = j * pagesz; -/* -* open devname, to mmap it -*/ - fd =open (devname,O_RDWR ); -if (fd <0 ) { -RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , - devname,strerror (errno)); -return -1 ; - } -if (maps[j].addr !=NULL ) fail =1 ;else {
@@ -378,7 +356,9 @@ pci_uio_map_resource(struct rte_pci_device *dev)if (pci_map_addr ==NULL ) pci_map_addr =pci_find_max_end_va (); - mapaddr =pci_map_resource (pci_map_addr, fd, (off_t )offset, + mapaddr =pci_map_resource (pci_map_addr, +INT_MIN , devname, + (off_t )offset, (size_t )maps[j].size);if (mapaddr ==MAP_FAILED ) fail =1 ;
@@ -388,10 +368,8 @@ pci_uio_map_resource(struct rte_pci_device *dev)if (fail) {rte_free (uio_res); -close (fd);return -1 ; } -close (fd); maps[j].addr = mapaddr; maps[j].offset = offset;
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +5 -4
@@ -48,6 +48,7 @@#include "eal_filesystem.h" #include "eal_pci_init.h" #include "eal_vfio.h" +#include "eal_private.h" /** * @file
@@ -726,12 +727,12 @@ pci_vfio_map_resource(struct rte_pci_device *dev)if (pci_map_addr ==NULL ) pci_map_addr =pci_find_max_end_va (); - bar_addr =pci_map_resource (pci_map_addr, vfio_dev_fd, reg.offset, - reg.size); + bar_addr =pci_map_resource (pci_map_addr, vfio_dev_fd, +NULL , reg.offset, reg.size); pci_map_addr =RTE_PTR_ADD (bar_addr, (size_t ) reg.size); }else { - bar_addr =pci_map_resource (maps[i].addr, vfio_dev_fd, reg.offset, - reg.size); + bar_addr =pci_map_resource (maps[i].addr, vfio_dev_fd, +NULL , reg.offset, reg.size); } if (bar_addr == MAP_FAILED ||
Signature · 1 line
1.9.1