summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/counter.c20
-rw-r--r--src/vlib/counter.h2
-rw-r--r--src/vlib/error.c37
-rw-r--r--src/vlib/main.c24
4 files changed, 82 insertions, 1 deletions
diff --git a/src/vlib/counter.c b/src/vlib/counter.c
index 62f4bd66ddc..29cd004fc3e 100644
--- a/src/vlib/counter.c
+++ b/src/vlib/counter.c
@@ -74,15 +74,32 @@ vlib_clear_combined_counters (vlib_combined_counter_main_t * cm)
}
}
+void *vlib_stats_push_heap (void) __attribute__ ((weak));
+void *
+vlib_stats_push_heap (void)
+{
+ return 0;
+};
+
+void vlib_stats_pop_heap (void *, void *) __attribute__ ((weak));
+void
+vlib_stats_pop_heap (void *notused, void *notused2)
+{
+};
+
+
void
vlib_validate_simple_counter (vlib_simple_counter_main_t * cm, u32 index)
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i;
+ void *oldheap = vlib_stats_push_heap ();
vec_validate (cm->counters, tm->n_vlib_mains - 1);
for (i = 0; i < tm->n_vlib_mains; i++)
vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES);
+
+ vlib_stats_pop_heap (cm, oldheap);
}
void
@@ -90,10 +107,13 @@ vlib_validate_combined_counter (vlib_combined_counter_main_t * cm, u32 index)
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i;
+ void *oldheap = vlib_stats_push_heap ();
vec_validate (cm->counters, tm->n_vlib_mains - 1);
for (i = 0; i < tm->n_vlib_mains; i++)
vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES);
+
+ vlib_stats_pop_heap (cm, oldheap);
}
u32
diff --git a/src/vlib/counter.h b/src/vlib/counter.h
index 60e2055d232..fe5279a5e28 100644
--- a/src/vlib/counter.h
+++ b/src/vlib/counter.h
@@ -63,6 +63,7 @@ typedef struct
serialized incrementally. */
char *name; /**< The counter collection's name. */
+ char *stat_segment_name; /**< Name in stat segment directory */
} vlib_simple_counter_main_t;
/** The number of counters (not the number of per-thread counters) */
@@ -183,6 +184,7 @@ typedef struct
vlib_counter_t *value_at_last_serialize; /**< Counter values as of last serialize. */
u32 last_incremental_serialize_index; /**< Last counter index serialized incrementally. */
char *name; /**< The counter collection's name. */
+ char *stat_segment_name; /**< Name in stat segment directory */
} vlib_combined_counter_main_t;
/** The number of counters (not the number of per-thread counters) */
diff --git a/src/vlib/error.c b/src/vlib/error.c
index dec90bbe440..368118210e6 100644
--- a/src/vlib/error.c
+++ b/src/vlib/error.c
@@ -140,6 +140,19 @@ VLIB_REGISTER_NODE (misc_drop_buffers_node,static) = {
};
/* *INDENT-ON* */
+void vlib_stats_register_error_index (u8 *, u64) __attribute__ ((weak));
+void
+vlib_stats_register_error_index (u8 * notused, u64 notused2)
+{
+};
+
+void vlib_stats_pop_heap2 (void *, u32, void *) __attribute__ ((weak));
+void
+vlib_stats_pop_heap2 (void *notused, u32 notused2, void *notused3)
+{
+};
+
+
/* Reserves given number of error codes for given node. */
void
vlib_register_errors (vlib_main_t * vm,
@@ -148,6 +161,8 @@ vlib_register_errors (vlib_main_t * vm,
vlib_error_main_t *em = &vm->error_main;
vlib_node_t *n = vlib_get_node (vm, node_index);
uword l;
+ void *oldheap;
+ void *vlib_stats_push_heap (void) __attribute__ ((weak));
ASSERT (vlib_get_thread_index () == 0);
@@ -169,9 +184,13 @@ vlib_register_errors (vlib_main_t * vm,
clib_memcpy (vec_elt_at_index (em->error_strings_heap, n->error_heap_index),
error_strings, n_errors * sizeof (error_strings[0]));
+ vec_validate (vm->error_elog_event_types, l - 1);
+
+ /* Switch to the stats segment ... */
+ oldheap = vlib_stats_push_heap ();
+
/* Allocate a counter/elog type for each error. */
vec_validate (em->counters, l - 1);
- vec_validate (vm->error_elog_event_types, l - 1);
/* Zero counters for re-registrations of errors. */
if (n->error_heap_index + n_errors <= vec_len (em->counters_last_clear))
@@ -182,6 +201,22 @@ vlib_register_errors (vlib_main_t * vm,
memset (em->counters + n->error_heap_index,
0, n_errors * sizeof (em->counters[0]));
+ /* Register counter indices in the stat segment directory */
+ {
+ int i;
+ u8 *error_name;
+
+ for (i = 0; i < n_errors; i++)
+ {
+ error_name = format (0, "/err/%s%c", error_strings[i], 0);
+ /* Note: error_name consumed by the following call */
+ vlib_stats_register_error_index (error_name, n->error_heap_index + i);
+ }
+ }
+
+ /* (re)register the em->counters base address, switch back to main heap */
+ vlib_stats_pop_heap2 (em->counters, vm->thread_index, oldheap);
+
{
elog_event_type_t t;
uword i;
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 7da519241bb..e4c4438b5aa 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1717,6 +1717,12 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
goto done;
}
+ if ((error = vlib_call_init_function (vm, map_stat_segment_init)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
/* Register static nodes so that init functions may use them. */
vlib_register_all_static_nodes (vm);
@@ -1736,6 +1742,24 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
goto done;
}
+ if ((error = vlib_call_init_function (vm, vpe_api_init)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
+ if ((error = vlib_call_init_function (vm, vlibmemory_init)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
+ if ((error = vlib_call_init_function (vm, map_api_segment_init)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
/* See unix/main.c; most likely already set up */
if (vm->init_functions_called == 0)
vm->init_functions_called = hash_create (0, /* value bytes */ 0);