summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vpp/stats/stat_segment.c32
-rw-r--r--src/vpp/stats/stat_segment.h7
-rw-r--r--src/vpp/stats/stat_segment_provider.c6
3 files changed, 16 insertions, 29 deletions
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c
index cebd5e32afa..c20ecfc6a5b 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -781,8 +781,7 @@ do_stat_segment_updates (vlib_main_t *vm, stat_segment_main_t *sm)
stat_segment_gauges_pool_t *g;
pool_foreach (g, sm->gauges)
{
- if (g->enabled)
- g->fn (&sm->directory_vector[g->directory_index], g->caller_index);
+ g->fn (&sm->directory_vector[g->directory_index], g->caller_index);
}
/* *INDENT-ON* */
@@ -881,9 +880,9 @@ stat_segment_collector_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
* Add a data provider (via callback) for a given stats entry.
* TODO: Add support for per-provider interval.
*/
-uword
+void
stat_segment_poll_add (u32 vector_index, stat_segment_update_fn update_fn,
- u32 caller_index, u32 interval, u8 enabled)
+ u32 caller_index, u32 interval)
{
stat_segment_main_t *sm = &stat_segment_main;
stat_segment_gauges_pool_t *gauge;
@@ -892,23 +891,8 @@ stat_segment_poll_add (u32 vector_index, stat_segment_update_fn update_fn,
gauge->fn = update_fn;
gauge->caller_index = caller_index;
gauge->directory_index = vector_index;
- gauge->enabled = enabled;
- return pool_elts (sm->gauges) - 1;
-}
-
-/*
- * Enable (or disable) a callback for a stats entry
- */
-void
-stat_segment_poll_state (uword index, u8 enabled)
-{
- stat_segment_main_t *sm = &stat_segment_main;
- stat_segment_gauges_pool_t *gauge = pool_elt_at_index (sm->gauges, index);
-
- ASSERT (gauge);
-
- gauge->enabled = enabled;
+ return;
}
/*
@@ -919,11 +903,17 @@ clib_error_t *
stat_segment_register_gauge (u8 *name, stat_segment_update_fn update_fn,
u32 caller_index)
{
+ stat_segment_main_t *sm = &stat_segment_main;
+ stat_segment_gauges_pool_t *gauge;
+
u32 vector_index = stat_segment_new_entry (name, STAT_DIR_TYPE_SCALAR_INDEX);
if (vector_index == ~0) /* Already registered */
return clib_error_return (0, "%v is already registered", name);
- stat_segment_poll_add (vector_index, update_fn, caller_index, -1, true);
+ pool_get (sm->gauges, gauge);
+ gauge->fn = update_fn;
+ gauge->caller_index = caller_index;
+ gauge->directory_index = vector_index;
return NULL;
}
diff --git a/src/vpp/stats/stat_segment.h b/src/vpp/stats/stat_segment.h
index 42c30071c28..2858003bb73 100644
--- a/src/vpp/stats/stat_segment.h
+++ b/src/vpp/stats/stat_segment.h
@@ -68,7 +68,6 @@ typedef struct {
u32 directory_index;
stat_segment_update_fn fn;
u32 caller_index;
- u8 enabled;
} stat_segment_gauges_pool_t;
typedef struct
@@ -109,10 +108,8 @@ stat_segment_register_state_counter(u8 *name, u32 *index);
clib_error_t *
stat_segment_deregister_state_counter(u32 index);
void stat_segment_set_state_counter (u32 index, u64 value);
-uword stat_segment_poll_add (u32 vector_index,
- stat_segment_update_fn update_fn,
- u32 caller_index, u32 interval, u8 enabled);
-void stat_segment_poll_state (uword index, u8 enabled);
+void stat_segment_poll_add (u32 vector_index, stat_segment_update_fn update_fn,
+ u32 caller_index, u32 interval);
counter_t **stat_validate_counter_vector3 (counter_t **counters, u32 max1,
u32 max2);
diff --git a/src/vpp/stats/stat_segment_provider.c b/src/vpp/stats/stat_segment_provider.c
index f62a74fcab3..30e03be45b9 100644
--- a/src/vpp/stats/stat_segment_provider.c
+++ b/src/vpp/stats/stat_segment_provider.c
@@ -117,7 +117,7 @@ vlib_stats_register_mem_heap (clib_mem_heap_t *heap)
vec_free (s_free);
stat_segment_poll_add (mem_vector_index, stat_provider_mem_usage_update_fn,
- heap_index, 10, true);
+ heap_index, 10);
}
static void
@@ -180,7 +180,7 @@ stat_provider_register_vector_rate (u32 num_workers)
if (i == ~0)
ASSERT (0);
vec_free (s);
- stat_segment_poll_add (i, stat_provider_vector_rate_update_fn, ~0, 10, true);
+ stat_segment_poll_add (i, stat_provider_vector_rate_update_fn, ~0, 10);
s = format (0, "/sys/vector_rate_per_worker%c", 0);
i = stat_segment_new_entry (s, STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE);
@@ -188,7 +188,7 @@ stat_provider_register_vector_rate (u32 num_workers)
ASSERT (0);
vec_free (s);
stat_segment_poll_add (i, stat_provider_vector_rate_per_thread_update_fn, ~0,
- 10, true);
+ 10);
stat_segment_main_t *sm = &stat_segment_main;
vlib_stat_segment_lock ();