aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/main.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-06 12:26:28 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:33:42 +0100
commitfd8deb48c7ad63b47c5d7465ceefcadef0316f93 (patch)
tree3e5f319c7c57f526a6e571fd96847563bedf2706 /src/vlib/main.h
parentf553a2cbbb8cca84ebf033335ebd2cd26dc19d69 (diff)
vlib: split vlib_main_t into global and per-thread
Type: refactor Change-Id: I8b273bc3bf16aa360f031f1b2692f766e5fc4613 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/main.h')
-rw-r--r--src/vlib/main.h95
1 files changed, 61 insertions, 34 deletions
diff --git a/src/vlib/main.h b/src/vlib/main.h
index 860192c1aa3..c655560d08c 100644
--- a/src/vlib/main.h
+++ b/src/vlib/main.h
@@ -152,9 +152,6 @@ typedef struct vlib_main_t
/* Error marker to use when exiting main loop. */
clib_error_t *main_loop_error;
- /* Name for e.g. syslog. */
- char *name;
-
/* Start of the heap. */
void *heap_base;
@@ -173,15 +170,9 @@ typedef struct vlib_main_t
/* Node graph main structure. */
vlib_node_main_t node_main;
- /* Command line interface. */
- vlib_cli_main_t cli_main;
-
/* Packet trace buffer. */
vlib_trace_main_t trace_main;
- /* Packet trace capture filter */
- vlib_trace_filter_t trace_filter;
-
/* Error handling. */
vlib_error_main_t error_main;
@@ -194,11 +185,10 @@ typedef struct vlib_main_t
/* Stream index to use for distribution when MC is enabled. */
u32 mc_stream_index;
- vlib_one_time_waiting_process_t *procs_waiting_for_mc_stream_join;
+ /* Hash table to record which init functions have been called. */
+ uword *worker_init_functions_called;
- /* Event logger. */
- elog_main_t elog_main;
- u32 configured_elog_ring_size;
+ vlib_one_time_waiting_process_t *procs_waiting_for_mc_stream_join;
/* Event logger trace flags */
int elog_trace_api_messages;
@@ -219,22 +209,11 @@ typedef struct vlib_main_t
/* Buffer of random data for various uses. */
clib_random_buffer_t random_buffer;
- /* Hash table to record which init functions have been called. */
- uword *init_functions_called;
-
/* thread, cpu and numa_node indices */
u32 thread_index;
u32 cpu_id;
u32 numa_node;
- /* List of init functions to call, setup by constructors */
- _vlib_init_function_list_elt_t *init_function_registrations;
- _vlib_init_function_list_elt_t *worker_init_function_registrations;
- _vlib_init_function_list_elt_t *main_loop_enter_function_registrations;
- _vlib_init_function_list_elt_t *main_loop_exit_function_registrations;
- _vlib_init_function_list_elt_t *api_init_function_registrations;
- vlib_config_function_runtime_t *config_function_registrations;
-
/* control-plane API queue signal pending, length indication */
volatile u32 queue_signal_pending;
volatile u32 api_queue_nonempty;
@@ -251,15 +230,6 @@ typedef struct vlib_main_t
/* debugging */
volatile int parked_at_barrier;
- /* post-mortem callbacks */
- void (**post_mortem_callbacks) (void);
-
- /*
- * Need to call vlib_worker_thread_node_runtime_update before
- * releasing worker thread barrier. Only valid in vlib_global_main.
- */
- int need_vlib_worker_thread_node_runtime_update;
-
/* Dispatch loop time accounting */
u64 loops_this_reporting_interval;
f64 loop_interval_end;
@@ -301,8 +271,53 @@ typedef struct vlib_main_t
#endif
} vlib_main_t;
+typedef struct vlib_global_main_t
+{
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+
+ /* Per-thread Mains */
+ vlib_main_t **vlib_mains;
+
+ /* Name for e.g. syslog. */
+ char *name;
+
+ /* post-mortem callbacks */
+ void (**post_mortem_callbacks) (void);
+
+ /*
+ * Need to call vlib_worker_thread_node_runtime_update before
+ * releasing worker thread barrier.
+ */
+ int need_vlib_worker_thread_node_runtime_update;
+
+ /* Command line interface. */
+ vlib_cli_main_t cli_main;
+
+ /* Node registrations added by constructors */
+ vlib_node_registration_t *node_registrations;
+
+ /* Event logger. */
+ elog_main_t elog_main;
+ u32 configured_elog_ring_size;
+
+ /* Packet trace capture filter */
+ vlib_trace_filter_t trace_filter;
+
+ /* List of init functions to call, setup by constructors */
+ _vlib_init_function_list_elt_t *init_function_registrations;
+ _vlib_init_function_list_elt_t *main_loop_enter_function_registrations;
+ _vlib_init_function_list_elt_t *main_loop_exit_function_registrations;
+ _vlib_init_function_list_elt_t *worker_init_function_registrations;
+ _vlib_init_function_list_elt_t *api_init_function_registrations;
+ vlib_config_function_runtime_t *config_function_registrations;
+
+ /* Hash table to record which init functions have been called. */
+ uword *init_functions_called;
+
+} vlib_global_main_t;
+
/* Global main structure. */
-extern vlib_main_t vlib_global_main;
+extern vlib_global_main_t vlib_global_main;
void vlib_worker_loop (vlib_main_t * vm);
@@ -441,6 +456,18 @@ always_inline void vlib_set_queue_signal_callback
vm->queue_signal_callback = fp;
}
+always_inline void
+vlib_main_init ()
+{
+ vlib_global_main_t *vgm = &vlib_global_main;
+ vlib_main_t *vm;
+
+ vgm->init_functions_called = hash_create (0, /* value bytes */ 0);
+
+ vm = clib_mem_alloc_aligned (sizeof (*vm), CLIB_CACHE_LINE_BYTES);
+ vec_add1 (vgm->vlib_mains, vm);
+}
+
/* Main routine. */
int vlib_main (vlib_main_t * vm, unformat_input_t * input);