stats: refactor
Type: refactor
Change-Id: Ifd533a095d979dc55bfbe5fac7e0b7510a4d900c
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vlib/counter.c b/src/vlib/counter.c
index 186b48d..ceaf013 100644
--- a/src/vlib/counter.c
+++ b/src/vlib/counter.c
@@ -38,7 +38,7 @@
*/
#include <vlib/vlib.h>
-#include <vlib/stat_weak_inlines.h>
+#include <vlib/stats/stats.h>
void
vlib_clear_simple_counters (vlib_simple_counter_main_t * cm)
@@ -80,7 +80,7 @@
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i, resized = 0;
- void *oldheap = vlib_stats_push_heap (cm->counters);
+ void *oldheap = vlib_stats_set_heap ();
vec_validate (cm->counters, tm->n_vlib_mains - 1);
for (i = 0; i < tm->n_vlib_mains; i++)
@@ -93,12 +93,10 @@
vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES);
}
+ clib_mem_set_heap (oldheap);
/* Avoid the epoch increase when there was no counter vector resize. */
if (resized)
- vlib_stats_pop_heap (cm, oldheap, index,
- 2 /* STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE */);
- else
- clib_mem_set_heap (oldheap);
+ vlib_stats_update_counter (cm, index, STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE);
}
void
@@ -108,7 +106,7 @@
vlib_stats_delete_cm (cm);
- void *oldheap = vlib_stats_push_heap (cm->counters);
+ void *oldheap = vlib_stats_set_heap ();
for (i = 0; i < vec_len (cm->counters); i++)
vec_free (cm->counters[i]);
vec_free (cm->counters);
@@ -120,7 +118,7 @@
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i, resized = 0;
- void *oldheap = vlib_stats_push_heap (cm->counters);
+ void *oldheap = vlib_stats_set_heap ();
vec_validate (cm->counters, tm->n_vlib_mains - 1);
for (i = 0; i < tm->n_vlib_mains; i++)
@@ -133,12 +131,11 @@
vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES);
}
+ clib_mem_set_heap (oldheap);
/* Avoid the epoch increase when there was no counter vector resize. */
if (resized)
- vlib_stats_pop_heap (cm, oldheap, index,
- 3 /*STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED */);
- else
- clib_mem_set_heap (oldheap);
+ vlib_stats_update_counter (cm, index,
+ STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED);
}
int
@@ -147,7 +144,7 @@
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i;
- void *oldheap = vlib_stats_push_heap (cm->counters);
+ void *oldheap = vlib_stats_set_heap ();
/* Possibly once in recorded history */
if (PREDICT_FALSE (vec_len (cm->counters) == 0))
@@ -180,7 +177,7 @@
vlib_stats_delete_cm (cm);
- void *oldheap = vlib_stats_push_heap (cm->counters);
+ void *oldheap = vlib_stats_set_heap ();
for (i = 0; i < vec_len (cm->counters); i++)
vec_free (cm->counters[i]);
vec_free (cm->counters);