Move common functions in EAL
v6 cover Move common functions in EAL
Changes in v6 includes
Adding _setname_ pthread functions when threads are created. Plan to use _getname_ when availabe in both Linux and FreeBSD. Splitting eal.c into 4 files based on the functionality. Simplify eal_pci changes for first series.
Testing:
Linux - Ubuntu x86_64 14.04
Compilation successful (x86_64-native-linuxapp-gcc). "make test" results match baseline code. testpmd utility on I217/I218 Intel chipset.
FreeBSD 10.0 x86_64
Compilation successful (x86_64-native-bsdapp-gcc). helloworld.
Ravi Kerur (6):
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
examples/vhost/main.c | 18 +- examples/vhost_xen/main.c | 18 +- lib/librte_eal/bsdapp/eal/Makefile | 8 +- lib/librte_eal/bsdapp/eal/eal.c | 278 +++--------------- lib/librte_eal/bsdapp/eal/eal_lcore.c | 72 +---- lib/librte_eal/bsdapp/eal/eal_memory.c | 47 ++- lib/librte_eal/bsdapp/eal/eal_pci.c | 72 +---- lib/librte_eal/bsdapp/eal/eal_thread.c | 152 ---------- lib/librte_eal/bsdapp/eal/eal_timer.c | 52 +--- lib/librte_eal/common/eal_common_app_usage.c | 63 ++++ lib/librte_eal/common/eal_common_lcore.c | 107 +++++++ lib/librte_eal/common/eal_common_mem_cfg.c | 217 ++++++++++++++ lib/librte_eal/common/eal_common_memory.c | 38 ++- lib/librte_eal/common/eal_common_pci.c | 72 +++++ lib/librte_eal/common/eal_common_proc_type.c | 58 ++++ lib/librte_eal/common/eal_common_sysfs.c | 163 +++++++++++ lib/librte_eal/common/eal_common_thread.c | 147 +++++++++- lib/librte_eal/common/eal_common_timer.c | 102 +++++++ lib/librte_eal/common/eal_hugepages.h | 1 + lib/librte_eal/common/eal_private.h | 171 ++++++++++- lib/librte_eal/common/eal_thread.h | 5 + lib/librte_eal/common/include/rte_eal.h | 4 + lib/librte_eal/common/include/rte_pci_dev_ids.h | 8 +- lib/librte_eal/linuxapp/eal/Makefile | 9 + lib/librte_eal/linuxapp/eal/eal.c | 306 ++++---------------- lib/librte_eal/linuxapp/eal/eal_interrupts.c | 11 + lib/librte_eal/linuxapp/eal/eal_lcore.c | 66 +---- lib/librte_eal/linuxapp/eal/eal_memory.c | 36 +-- lib/librte_eal/linuxapp/eal/eal_pci.c | 75 +---- lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 22 +- lib/librte_eal/linuxapp/eal/eal_thread.c | 152 +--------- lib/librte_eal/linuxapp/eal/eal_timer.c | 70 ++--- 32 files changed, 1595 insertions(+), 1402 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_app_usage.c create mode 100644 lib/librte_eal/common/eal_common_lcore.c create mode 100644 lib/librte_eal/common/eal_common_mem_cfg.c create mode 100644 lib/librte_eal/common/eal_common_proc_type.c create mode 100644 lib/librte_eal/common/eal_common_sysfs.c create mode 100644 lib/librte_eal/common/eal_common_timer.c
Signature · 1 line
1.9.1
PATCH v6 1/9 Move common functions in eal_thread.c
In reply to a message not in the archiveChanges in v6
Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file. Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD respectively. Plan to use _getname_ in RTE_LOG when available. Use existing rte_get_systid() in RTE_LOG to print thread_id.
Changes in v5
Rebase to latest code.
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.
--- examples/vhost/main.c | 18 ++- examples/vhost_xen/main.c | 18 ++- lib/librte_eal/bsdapp/eal/Makefile | 2 +- lib/librte_eal/bsdapp/eal/eal.c | 7 + lib/librte_eal/bsdapp/eal/eal_thread.c | 152 --------------------- lib/librte_eal/common/eal_common_thread.c | 147 +++++++++++++++++++- lib/librte_eal/common/eal_thread.h | 5 + lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal.c | 10 ++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 11 ++ lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 22 ++- lib/librte_eal/linuxapp/eal/eal_thread.c | 152 +-------------------- lib/librte_eal/linuxapp/eal/eal_timer.c | 15 +- 13 files changed, 250 insertions(+), 311 deletions(-)
examples/vhost/main.c +16 -2
@@ -2891,6 +2891,7 @@ main(int argc, char *argv[])uint8_t portid;uint16_t queue_id;static pthread_t tid; +char thread_name[RTE_THREAD_NAME_LEN ];/* init EAL */ ret =rte_eal_init (argc, argv);
@@ -3017,8 +3018,21 @@ main(int argc, char *argv[])memset (&dev_statistics,0 ,sizeof (dev_statistics));/* Enable stats if the user option is set. */ -if (enable_stats) -pthread_create (&tid,NULL , (void *)print_stats,NULL ); +if (enable_stats) { +snprintf (thread_name,RTE_THREAD_NAME_LEN ,"vhost-stats" ); + + ret =pthread_create (&tid,NULL , (void *)print_stats,NULL ); + +if (ret !=0 ) +rte_exit (EXIT_FAILURE , +"Cannot create print-stats thread\n" ); + + ret =pthread_setname_np (tid, thread_name); + +if (ret !=0 ) +rte_exit (EXIT_FAILURE , +"Cannot set print-stats name\n" ); + }/* Launch all data cores. */ if (zero_copy ==0 ) {
examples/vhost_xen/main.c +17 -1
@@ -1433,6 +1433,7 @@ main(int argc, char *argv[])int ret;uint8_t portid;static pthread_t tid; +char thread_name[RTE_THREAD_NAME_LEN ];/* init EAL */ ret =rte_eal_init (argc, argv);
@@ -1505,9 +1506,24 @@ main(int argc, char *argv[])memset (&dev_statistics,0 ,sizeof (dev_statistics));/* Enable stats if the user option is set. */ -if (enable_stats) +if (enable_stats) { + +snprintf (thread_name,RTE_THREAD_NAME_LEN , +"vhost-xen-stats" ); +pthread_create (&tid,NULL , (void *)print_stats,NULL ); +if (ret !=0 ) +rte_exit (EXIT_FAILURE , +"Cannot create print-stats thread\n" ); + + ret =pthread_setname_np (tid, thread_name); + +if (ret !=0 ) +rte_exit (EXIT_FAILURE , +"Cannot set print-stats name\n" ); + } +/* Launch all data cores. */ RTE_LCORE_FOREACH_SLAVE (lcore_id) {rte_eal_remote_launch (switch_worker, mbuf_pool, lcore_id);
lib/librte_eal/bsdapp/eal/Makefile +1 -1
@@ -87,7 +87,7 @@ 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.c +7 -0
@@ -437,6 +437,7 @@ rte_eal_init(int argc, char **argv)int i, fctret, ret;pthread_t thread_id;static rte_atomic32_t run_once =RTE_ATOMIC32_INIT (0 ); +char thread_name[RTE_THREAD_NAME_LEN ];char cpuset[RTE_CPU_AFFINITY_STR_LEN ];if (!rte_atomic32_test_and_set (&run_once))
@@ -525,6 +526,9 @@ rte_eal_init(int argc, char **argv)RTE_LCORE_FOREACH_SLAVE (i) { +snprintf (thread_name,RTE_THREAD_NAME_LEN , +"lcore-slave-%d" , i); +/* * create communication pipes between master thread * and children
@@ -541,6 +545,9 @@ rte_eal_init(int argc, char **argv) eal_thread_loop, NULL);if (ret !=0 )rte_panic ("Cannot create thread\n" ); + +pthread_set_name_np ( + lcore_config[i].thread_id, (const char *)thread_name); }/*
lib/librte_eal/bsdapp/eal/eal_thread.c +0 -152
163 lines not on this page · raw message
lib/librte_eal/common/eal_common_thread.c +146 -1
170 lines not on this page · raw message
lib/librte_eal/common/eal_thread.h +5 -0
@@ -80,6 +80,11 @@ int eal_cpuset_socket_id(rte_cpuset_t *cpusetp);#define RTE_CPU_AFFINITY_STR_LEN 256/** +* Default buffer size for thread name +*/ +#define RTE_THREAD_NAME_LEN 32 + +/** * Dump the current pthread cpuset. * This function is private to EAL. *
lib/librte_eal/linuxapp/eal/Makefile +2 -0
@@ -93,6 +93,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_thread.c CFLAGS_eal.o := -D_GNU_SOURCE CFLAGS_eal_interrupts.o := -D_GNU_SOURCE +CFLAGS_eal_timer.o := -D_GNU_SOURCE CFLAGS_eal_lcore.o := -D_GNU_SOURCE CFLAGS_eal_thread.o := -D_GNU_SOURCE CFLAGS_eal_log.o := -D_GNU_SOURCE
@@ -101,6 +102,7 @@ CFLAGS_eal_hugepage_info.o := -D_GNU_SOURCE CFLAGS_eal_pci.o := -D_GNU_SOURCE CFLAGS_eal_pci_uio.o := -D_GNU_SOURCE CFLAGS_eal_pci_vfio.o := -D_GNU_SOURCE +CFLAGS_eal_pci_vfio_mp_sync.o := -D_GNU_SOURCE CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE CFLAGS_eal_common_options.o := -D_GNU_SOURCE CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
lib/librte_eal/linuxapp/eal/eal.c +10 -0
@@ -703,6 +703,7 @@ rte_eal_init(int argc, char **argv)pthread_t thread_id;static rte_atomic32_t run_once =RTE_ATOMIC32_INIT (0 );struct shared_driver *solib =NULL ; +char thread_name[RTE_THREAD_NAME_LEN ];const char *logid;char cpuset[RTE_CPU_AFFINITY_STR_LEN ];
@@ -816,6 +817,9 @@ rte_eal_init(int argc, char **argv)RTE_LCORE_FOREACH_SLAVE (i) { +snprintf (thread_name,RTE_THREAD_NAME_LEN , +"lcore-slave-%d" , i); +/* * create communication pipes between master thread * and children
@@ -832,6 +836,12 @@ rte_eal_init(int argc, char **argv) eal_thread_loop, NULL);if (ret !=0 )rte_panic ("Cannot create thread\n" ); + + ret =pthread_setname_np ( + lcore_config[i].thread_id, thread_name); + +if (ret !=0 ) +rte_panic ("Cannot set name for the thread\n" ); }/*
lib/librte_eal/linuxapp/eal/eal_interrupts.c +11 -0
@@ -66,6 +66,7 @@#include "eal_private.h" #include "eal_vfio.h" +#include "eal_thread.h" #define EAL_INTR_EPOLL_WAIT_FOREVER (-1)
@@ -838,6 +839,7 @@ intrte_eal_intr_init (void) {int ret =0 ; +char thread_name[RTE_THREAD_NAME_LEN ];/* init the global interrupt source head */ TAILQ_INIT (&intr_sources);
@@ -849,6 +851,9 @@ rte_eal_intr_init(void)if (pipe (intr_pipe.pipefd) <0 )return -1 ; +snprintf (thread_name,RTE_THREAD_NAME_LEN , +"eal-intr-thread" ); +/* create the host thread to wait/handle the interrupt */ ret =pthread_create (&intr_thread,NULL , eal_intr_thread_main,NULL );
@@ -856,6 +861,12 @@ rte_eal_intr_init(void)RTE_LOG (ERR ,EAL ,"Failed to create thread for interrupt handling\n" ); + ret =pthread_setname_np (intr_thread, thread_name); + +if (ret !=0 ) +RTE_LOG (ERR ,EAL , +"Failed to set thread name for interrupt handling\n" ); +return -ret; }
lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c +20 -2
@@ -34,6 +34,7 @@#include <string.h> #include <fcntl.h> #include <sys/socket.h> +#include <pthread.h> /* sys/un.h with __USE_MISC uses strlen, which is unsafe */ #ifdef __USE_MISC
@@ -54,6 +55,7 @@#include "eal_filesystem.h" #include "eal_pci_init.h" +#include "eal_thread.h" /** * @file
@@ -374,20 +376,36 @@ intpci_vfio_mp_sync_setup (void) {int ret; +char thread_name[RTE_THREAD_NAME_LEN ];if (vfio_mp_sync_socket_setup () <0 ) {RTE_LOG (ERR ,EAL ,"Failed to set up local socket!\n" );return -1 ; } +snprintf (thread_name,RTE_THREAD_NAME_LEN , +"pci-vfio-mp-sync" ); + ret =pthread_create (&socket_thread,NULL , pci_vfio_mp_sync_thread,NULL );if (ret) { -RTE_LOG (ERR ,EAL ,"Failed to create thread for communication with " -"secondary processes!\n" ); +RTE_LOG (ERR ,EAL , +"Failed to create thread for communication with " +"secondary processes!\n" ); +close (mp_socket_fd); +return -1 ; + } + + ret =pthread_setname_np (socket_thread, thread_name); + +if (ret) { +RTE_LOG (ERR ,EAL , +"Failed to set thread name for " +"secondary processes!\n" );close (mp_socket_fd);return -1 ; } +return 0 ; }
lib/librte_eal/linuxapp/eal/eal_thread.c +1 -151
164 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_timer.c +14 -1
@@ -54,6 +54,7 @@#include "eal_private.h" #include "eal_internal_cfg.h" +#include "eal_thread.h" enum timer_source eal_timer_source =EAL_TIMER_HPET ;
@@ -186,6 +187,7 @@ int rte_eal_hpet_init(int make_default) {int fd, ret; +char thread_name[RTE_THREAD_NAME_LEN ];if (internal_config.no_hpet) {RTE_LOG (INFO ,EAL ,"HPET is disabled\n" );
@@ -224,16 +226,27 @@ rte_eal_hpet_init(int make_default) eal_hpet_msb = (eal_hpet->counter_l >>30 ); +snprintf (thread_name,RTE_THREAD_NAME_LEN ,"hpet-msb-inc" ); +/* create a thread that will increment a global variable for * msb (hpet is 32 bits by default under linux) */ ret =pthread_create (&msb_inc_thread_id,NULL , (void *(*)(void *))hpet_msb_inc,NULL ); -if (ret <0 ) { +if (ret !=0 ) {RTE_LOG (ERR ,EAL ,"ERROR: Cannot create HPET timer thread!\n" ); internal_config.no_hpet =1 ;return -1 ; } + ret =pthread_setname_np (msb_inc_thread_id, thread_name); + +if (ret !=0 ) { +RTE_LOG (ERR ,EAL , +"ERROR: Cannot set HPET timer thread name!\n" ); + internal_config.no_hpet =1 ; +return -1 ; + } +if (make_default) eal_timer_source =EAL_TIMER_HPET ;return 0 ;
Signature · 1 line
1.9.1
PATCH v6 2/9 Move common functions in eal.c
In reply to a message not in the archiveChanges in v6
Split eal_common_system.c and eal_common_runtime.c into eal_common_sysfs.ceal_common_mem_cfg.ceal_common_proc_type.ceal_comm_app_usage.c
based on functionality.
Changes in v5
Rebase to latest code.
Changes 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 | 4 + lib/librte_eal/bsdapp/eal/eal.c | 271 +++--------------------- lib/librte_eal/common/eal_common_app_usage.c | 63 ++++++ lib/librte_eal/common/eal_common_mem_cfg.c | 217 ++++++++++++++++++++ lib/librte_eal/common/eal_common_proc_type.c | 58 ++++++ lib/librte_eal/common/eal_common_sysfs.c | 163 +++++++++++++++ lib/librte_eal/common/eal_hugepages.h | 1 + lib/librte_eal/common/eal_private.h | 78 +++++++ lib/librte_eal/common/include/rte_eal.h | 4 + lib/librte_eal/linuxapp/eal/Makefile | 4 + lib/librte_eal/linuxapp/eal/eal.c | 296 ++++----------------------- 11 files changed, 668 insertions(+), 491 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_app_usage.c create mode 100644 lib/librte_eal/common/eal_common_mem_cfg.c create mode 100644 lib/librte_eal/common/eal_common_proc_type.c create mode 100644 lib/librte_eal/common/eal_common_sysfs.c
lib/librte_eal/bsdapp/eal/Makefile +4 -0
@@ -78,6 +78,10 @@ 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_thread.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_sysfs.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_mem_cfg.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_proc_type.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_app_usage.c CFLAGS_eal.o := -D_GNU_SOURCE #CFLAGS_eal_thread.o := -D_GNU_SOURCE
lib/librte_eal/bsdapp/eal/eal.c +33 -238
342 lines not on this page · raw message
lib/librte_eal/common/eal_common_app_usage.c new file +63 -0
63 lines not on this page · raw message
lib/librte_eal/common/eal_common_mem_cfg.c new file +217 -0
217 lines not on this page · raw message
lib/librte_eal/common/eal_common_proc_type.c new file +58 -0
58 lines not on this page · raw message
lib/librte_eal/common/eal_common_sysfs.c new file +163 -0
163 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/common/include/rte_eal.h +4 -0
@@ -51,6 +51,10 @@ extern "C" {#define RTE_MAGIC 19820526/**< Magic number written by the main partition when ready. */ +#define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) + +#define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 10) +/** * The lcore role (used in RTE or not). */
lib/librte_eal/linuxapp/eal/Makefile +4 -0
@@ -90,6 +90,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_thread.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_sysfs.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_mem_cfg.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_proc_type.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_app_usage.c CFLAGS_eal.o := -D_GNU_SOURCE CFLAGS_eal_interrupts.o := -D_GNU_SOURCE
lib/librte_eal/linuxapp/eal/eal.c +43 -253
407 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v6 3/9 Move common functions in eal_lcore.c
In reply to a message not in the archiveChanges in v6
None.
Changes in v5
Rebase to latest code.
Changes 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 | 72 +++++---------------- lib/librte_eal/common/eal_common_lcore.c | 107 +++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 14 ++++ lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal_lcore.c | 66 ++----------------- 6 files changed, 143 insertions(+), 119 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_lcore.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -82,6 +82,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_sysfs.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_mem_cfg.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_proc_type.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_app_usage.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c CFLAGS_eal.o := -D_GNU_SOURCE #CFLAGS_eal_thread.o := -D_GNU_SOURCE
lib/librte_eal/bsdapp/eal/eal_lcore.c +15 -57
89 lines not on this page · raw message
lib/librte_eal/common/eal_common_lcore.c new file +107 -0
107 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +14 -0
@@ -310,4 +310,18 @@ void rte_eal_config_attach(void);*/ void rte_eal_config_reattach (void ); +/** +* This function gets cpu core_id +* +* This function is private to the EAL. +*/ +unsigned eal_cpu_core_id (unsigned lcore_id); + +/** +* This function check if cpu is present +* +* This function is private to the EAL. +*/ +int eal_cpu_detected (unsigned lcore_id); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +2 -0
@@ -94,6 +94,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_sysfs.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_mem_cfg.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_proc_type.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_app_usage.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c CFLAGS_eal.o := -D_GNU_SOURCE CFLAGS_eal_interrupts.o := -D_GNU_SOURCE
@@ -110,6 +111,7 @@ CFLAGS_eal_pci_vfio_mp_sync.o := -D_GNU_SOURCE CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE CFLAGS_eal_common_options.o := -D_GNU_SOURCE CFLAGS_eal_common_thread.o := -D_GNU_SOURCE +CFLAGS_eal_common_lcore.o := -D_GNU_SOURCE # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
lib/librte_eal/linuxapp/eal/eal_lcore.c +4 -62
81 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v6 4/9 Move common functions in eal_timer.c
In reply to a message not in the archiveChanges in v6
Added new line between Copyright and header file inclusion in eal_common_timer.c.
Changes in v5
Rebase to latest code.
Changes 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 | 52 +++------------- lib/librte_eal/common/eal_common_timer.c | 102 +++++++++++++++++++++++++++++++ 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(+), 95 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_timer.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -83,6 +83,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_mem_cfg.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_proc_type.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_app_usage.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_thread.o := -D_GNU_SOURCE
lib/librte_eal/bsdapp/eal/eal_timer.c +8 -44
79 lines not on this page · raw message
lib/librte_eal/common/eal_common_timer.c new file +102 -0
102 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +24 -0
@@ -324,4 +324,28 @@ unsigned eal_cpu_core_id(unsigned lcore_id);*/ int eal_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
@@ -95,6 +95,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_mem_cfg.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_proc_type.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_app_usage.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_interrupts.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 v6 5/9 Move common functions in eal_memory.c
In reply to a message not in the archiveChanges in v6
Removed unnecessary comments in function declaration.
Changes in v5
Rebase to latest code.
Changes 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 | 20 +++++++++++-- lib/librte_eal/linuxapp/eal/eal_memory.c | 36 ++--------------------- 4 files changed, 72 insertions(+), 69 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;
@@ -131,7 +131,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;
@@ -192,35 +201,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
@@ -45,6 +45,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
@@ -69,7 +70,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 ;
@@ -89,7 +90,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 ;
@@ -118,3 +119,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 -2
@@ -334,8 +334,6 @@ 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. */
@@ -348,4 +346,22 @@ 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. +* +* 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 ); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -34
@@ -1030,7 +1030,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;
@@ -1368,7 +1368,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;
@@ -1529,35 +1529,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 v6 6/9 Move common functions in eal_pci.c
In reply to a message not in the archiveChanges in v6
Split changes due to complexity. v6 includes moving rte_eal_pci_probe_one_driver function and its associated utility functions only.
Changes in v5
Rebase to latest code.
Removed RTE_EXEC_ENV_BSDAPP from earlier changes.
Changes 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 | 72 +++++--------------------------- lib/librte_eal/common/eal_common_pci.c | 72 ++++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 39 +++++++++++++----- lib/librte_eal/linuxapp/eal/eal_pci.c | 75 +--------------------------------- 4 files changed, 113 insertions(+), 145 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +11 -61
@@ -111,7 +111,7 @@ static struct rte_tailq_elem rte_uio_tailq = {EAL_REGISTER_TAILQ (rte_uio_tailq)/* 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 "
@@ -274,6 +274,13 @@ pci_uio_map_resource(struct rte_pci_device *dev)return (0 ); } +/* map the PCI resource of a PCI device in virtual memory */ +int +pci_map_device (struct rte_pci_device *dev) +{ +return pci_uio_map_resource (dev); +} +/* 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)
@@ -426,68 +433,11 @@ error: }/* -* If vendor/device ID match, call the devinit() function of the -* driver. +* This function is a no-op in BSD. */ -int -rte_eal_pci_probe_one_driver (struct rte_pci_driver *dr,struct rte_pci_device *dev) +void +pci_config_space_set(struct rte_pci_device *dev __rte_unused) { -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 */
lib/librte_eal/common/eal_common_pci.c +72 -0
78 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +28 -11
@@ -156,17 +156,6 @@ struct rte_pci_driver;struct rte_pci_device ;/** -* Mmap memory for single PCI device -* -* This function is private to EAL. -* -* @return -* 0 on success, negative on error -*/ -int rte_eal_pci_probe_one_driver (struct rte_pci_driver *dr, -struct rte_pci_device *dev); - -/** * Munmap memory for single PCI device * * This function is private to EAL.
@@ -364,4 +353,32 @@ int rte_eal_hugepage_init(void);*/ int rte_eal_hugepage_attach (void ); +/** +* This function unbinds kernel driver for this device +* +* This function is private to the EAL. +*/ +int +pci_unbind_kernel_driver (struct rte_pci_device *dev); + +/** +* This function maps resources for devices +* that use igb_uio on Linux and it's a +* wrapper for pci_uio_map_resource on BSD. +* +* This function is private to the EAL. +*/ +int +pci_map_device (struct rte_pci_device *dev); + +/** +* This function sets PCIe config space for +* high performance. +* It's a NO-OP on BSD. +* +* This function is private to the EAL. +*/ +void +pci_config_space_set (struct rte_pci_device *dev); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/eal_pci.c +2 -73
93 lines not on this page · raw message
Signature · 1 line
1.9.1