aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-26 13:45:37 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:33:42 +0100
commitf553a2cbbb8cca84ebf033335ebd2cd26dc19d69 (patch)
tree3705c2c0121769dff96a122cef13886d5f0e5205 /src/vlib
parent6ffb7c61899eb782416cbd2f117042a583f189f7 (diff)
vlib: introduce vlib_get_elog_main()
Type: improvement Change-Id: I73383eb15186021cd6527d112da8443a0082f129 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/cli.c16
-rw-r--r--src/vlib/error_funcs.h2
-rw-r--r--src/vlib/global_funcs.h7
-rw-r--r--src/vlib/log.c5
-rw-r--r--src/vlib/main.c21
-rw-r--r--src/vlib/node.c3
-rw-r--r--src/vlib/threads.c6
-rw-r--r--src/vlib/threads.h6
-rw-r--r--src/vlib/unix/main.c4
9 files changed, 38 insertions, 32 deletions
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index 85ec6cbc43c..3215a3264f5 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -575,8 +575,8 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
{
u32 c;
} *ed;
- ed = ELOG_DATA (&vm->elog_main, e);
- ed->c = elog_string (&vm->elog_main, "%v", c->path);
+ ed = ELOG_DATA (vlib_get_elog_main (), e);
+ ed->c = elog_string (vlib_get_elog_main (), "%v", c->path);
}
if (!c->is_mp_safe)
@@ -607,17 +607,17 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
{
u32 c, err;
} *ed;
- ed = ELOG_DATA (&vm->elog_main, e);
- ed->c = elog_string (&vm->elog_main, "%v", c->path);
+ ed = ELOG_DATA (vlib_get_elog_main (), e);
+ ed->c = elog_string (vlib_get_elog_main (), "%v", c->path);
if (c_error)
{
vec_add1 (c_error->what, 0);
- ed->err =
- elog_string (&vm->elog_main, (char *) c_error->what);
+ ed->err = elog_string (vlib_get_elog_main (),
+ (char *) c_error->what);
_vec_len (c_error->what) -= 1;
}
else
- ed->err = elog_string (&vm->elog_main, "OK");
+ ed->err = elog_string (vlib_get_elog_main (), "OK");
}
if (c_error)
@@ -1547,7 +1547,7 @@ event_logger_trace_command_fn (vlib_main_t * vm,
*/
if (dispatch || circuit)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = &vlib_global_main.elog_main;
em->n_total_events_disable_limit =
em->n_total_events + vec_len (em->event_ring);
diff --git a/src/vlib/error_funcs.h b/src/vlib/error_funcs.h
index ab281ba2ef8..4fea1ce6dc0 100644
--- a/src/vlib/error_funcs.h
+++ b/src/vlib/error_funcs.h
@@ -47,7 +47,7 @@ vlib_error_elog_count (vlib_main_t * vm, uword counter, uword increment)
{
if (VLIB_ELOG_MAIN_LOOP > 0 && increment > 0)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = vlib_get_elog_main ();
elog (em, vec_elt_at_index (vm->error_elog_event_types, counter),
increment);
}
diff --git a/src/vlib/global_funcs.h b/src/vlib/global_funcs.h
index b1d636f7ce4..63f8115a181 100644
--- a/src/vlib/global_funcs.h
+++ b/src/vlib/global_funcs.h
@@ -52,6 +52,13 @@ vlib_get_thread_main ()
return &vlib_thread_main;
}
+always_inline elog_main_t *
+vlib_get_elog_main ()
+{
+ vlib_main_t *vm = vlib_get_first_main ();
+ return &vm->elog_main;
+}
+
#endif /* included_vlib_global_funcs_h_ */
/*
diff --git a/src/vlib/log.c b/src/vlib/log.c
index ed14d9ecdc6..fc67a1f8903 100644
--- a/src/vlib/log.c
+++ b/src/vlib/log.c
@@ -249,9 +249,10 @@ vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...)
u32 string_index;
} *ed;
/* *INDENT-ON* */
- ed = ELOG_DATA (&vm->elog_main, ee);
+ ed = ELOG_DATA (&vlib_global_main.elog_main, ee);
ed->log_level = level;
- ed->string_index = elog_string (&vm->elog_main, "%v", e->string);
+ ed->string_index =
+ elog_string (&vlib_global_main.elog_main, "%v", e->string);
}
lm->next = (lm->next + 1) % lm->size;
diff --git a/src/vlib/main.c b/src/vlib/main.c
index fc6fadb625e..62da7b9ff0a 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -694,7 +694,7 @@ static clib_error_t *
vlib_cli_elog_clear (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- elog_reset_buffer (&vm->elog_main);
+ elog_reset_buffer (&vlib_global_main.elog_main);
return 0;
}
@@ -711,7 +711,7 @@ static clib_error_t *
elog_save_buffer (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = &vlib_global_main.elog_main;
char *file, *chroot_file;
clib_error_t *error = 0;
@@ -765,7 +765,7 @@ static clib_error_t *
elog_stop (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = &vlib_global_main.elog_main;
em->n_total_events_disable_limit = em->n_total_events;
@@ -785,7 +785,7 @@ static clib_error_t *
elog_restart (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = &vlib_global_main.elog_main;
em->n_total_events_disable_limit = ~0;
@@ -805,11 +805,11 @@ static clib_error_t *
elog_resize_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = &vlib_global_main.elog_main;
u32 tmp;
/* Stop the parade */
- elog_reset_buffer (&vm->elog_main);
+ elog_reset_buffer (em);
if (unformat (input, "%d", &tmp))
{
@@ -836,7 +836,7 @@ VLIB_CLI_COMMAND (elog_resize_cli, static) = {
static void
elog_show_buffer_internal (vlib_main_t * vm, u32 n_events_to_show)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = &vlib_global_main.elog_main;
elog_event_t *e, *es;
f64 dt;
@@ -902,7 +902,7 @@ vlib_elog_main_loop_event (vlib_main_t * vm,
u64 time, u32 n_vectors, u32 is_return)
{
vlib_main_t *evm = &vlib_global_main;
- elog_main_t *em = &evm->elog_main;
+ elog_main_t *em = vlib_get_elog_main ();
int enabled = evm->elog_trace_graph_dispatch |
evm->elog_trace_graph_circuit;
@@ -1819,8 +1819,7 @@ vlib_add_del_post_mortem_callback (void *cb, int is_add)
static void
elog_post_mortem_dump (void)
{
- vlib_main_t *vm = &vlib_global_main;
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = vlib_get_elog_main ();
u8 *filename;
clib_error_t *error;
@@ -1933,7 +1932,7 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
if (vm->configured_elog_ring_size &&
vm->configured_elog_ring_size != vm->elog_main.event_ring_size)
elog_resize (&vm->elog_main, vm->configured_elog_ring_size);
- vl_api_set_elog_main (&vm->elog_main);
+ vl_api_set_elog_main (vlib_get_elog_main ());
(void) vl_api_set_elog_trace_api_messages (1);
/* Default name. */
diff --git a/src/vlib/node.c b/src/vlib/node.c
index 3c96d9d2a04..9de4c690c3f 100644
--- a/src/vlib/node.c
+++ b/src/vlib/node.c
@@ -68,7 +68,8 @@ node_set_elog_name (vlib_main_t * vm, uword node_index)
vec_free (t->format);
t->format = (char *) format (0, "%v-return: %%d%c", n->name, 0);
- n->name_elog_string = elog_string (&vm->elog_main, "%v%c", n->name, 0);
+ n->name_elog_string =
+ elog_string (&vlib_global_main.elog_main, "%v%c", n->name, 0);
}
void
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 939f9107556..cf82e1802d6 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -686,7 +686,7 @@ start_workers (vlib_main_t * vm)
/* Set up the main thread */
vec_add2_aligned (vlib_worker_threads, w, 1, CLIB_CACHE_LINE_BYTES);
w->elog_track.name = "main thread";
- elog_track_register (&vm->elog_main, &w->elog_track);
+ elog_track_register (vlib_get_elog_main (), &w->elog_track);
if (vec_len (tm->thread_prefix))
{
@@ -770,7 +770,7 @@ start_workers (vlib_main_t * vm)
w->elog_track.name =
(char *) format (0, "%s %d", tr->name, k + 1);
vec_add1 (w->elog_track.name, 0);
- elog_track_register (&vm->elog_main, &w->elog_track);
+ elog_track_register (vlib_get_elog_main (), &w->elog_track);
if (tr->no_data_structure_clone)
continue;
@@ -944,7 +944,7 @@ start_workers (vlib_main_t * vm)
(char *) format (0, "%s %d", tr->name, j + 1);
w->registration = tr;
vec_add1 (w->elog_track.name, 0);
- elog_track_register (&vm->elog_main, &w->elog_track);
+ elog_track_register (vlib_get_elog_main (), &w->elog_track);
}
}
}
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index eb31edc2706..b514ba415ec 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -425,8 +425,7 @@ vlib_worker_thread_barrier_check (void)
u32 thread_index;
} __clib_packed *ed;
- ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e,
- w->elog_track);
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track);
ed->thread_index = thread_index;
}
@@ -503,8 +502,7 @@ vlib_worker_thread_barrier_check (void)
u32 duration;
} __clib_packed *ed;
- ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e,
- w->elog_track);
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track);
ed->thread_index = thread_index;
ed->duration = (int) (1000000.0 * t);
}
diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c
index f73f9ca325f..a0a13f3affa 100644
--- a/src/vlib/unix/main.c
+++ b/src/vlib/unix/main.c
@@ -708,8 +708,8 @@ vlib_unix_main (int argc, char *argv[])
/* Turn on the event logger at the first possible moment */
vm->configured_elog_ring_size = 128 << 10;
- elog_init (&vm->elog_main, vm->configured_elog_ring_size);
- elog_enable_disable (&vm->elog_main, 1);
+ elog_init (vlib_get_elog_main (), vm->configured_elog_ring_size);
+ elog_enable_disable (vlib_get_elog_main (), 1);
unformat_init_command_line (&input, (char **) vm->argv);
if ((e = vlib_plugin_config (vm, &input)))