summaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-03-01 15:51:18 +0100
committerDamjan Marion <dmarion@me.com>2022-03-09 13:51:31 +0000
commit8973b07eecbbfe23a5267975f8052a5c6339c756 (patch)
treefe4d3507ff24c18743d3241cd9ab049ee2add062 /src/vlib/buffer.c
parent317cace6185ae134d78a38e1a20249baf751035e (diff)
stats: refactor
Type: refactor Change-Id: Ifd533a095d979dc55bfbe5fac7e0b7510a4d900c Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/buffer.c')
-rw-r--r--src/vlib/buffer.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 7a70a8abdd3..fbded6e8300 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -46,7 +46,7 @@
#include <vppinfra/linux/sysfs.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
-#include <vpp/stats/stat_segment.h>
+#include <vlib/stats/stats.h>
#define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA 16384
#define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV 8192
@@ -63,17 +63,6 @@ STATIC_ASSERT_OFFSET_OF (vlib_buffer_t, template_end, 64);
u16 __vlib_buffer_external_hdr_size = 0;
-static void
-buffer_gauges_update_cached_fn (stat_segment_directory_entry_t * e,
- u32 index);
-
-static void
-buffer_gauges_update_available_fn (stat_segment_directory_entry_t * e,
- u32 index);
-
-static void
-buffer_gauges_update_used_fn (stat_segment_directory_entry_t * e, u32 index);
-
uword
vlib_buffer_length_in_chain_slow_path (vlib_main_t * vm,
vlib_buffer_t * b_first)
@@ -798,37 +787,39 @@ buffer_get_by_index (vlib_buffer_main_t * bm, u32 index)
}
static void
-buffer_gauges_update_used_fn (stat_segment_directory_entry_t * e, u32 index)
+buffer_gauges_collect_used_fn (vlib_stats_collector_data_t *d)
{
vlib_main_t *vm = vlib_get_main ();
- vlib_buffer_pool_t *bp = buffer_get_by_index (vm->buffer_main, index);
+ vlib_buffer_pool_t *bp =
+ buffer_get_by_index (vm->buffer_main, d->private_data);
if (!bp)
return;
- e->value = bp->n_buffers - bp->n_avail - buffer_get_cached (bp);
+ d->entry->value = bp->n_buffers - bp->n_avail - buffer_get_cached (bp);
}
static void
-buffer_gauges_update_available_fn (stat_segment_directory_entry_t * e,
- u32 index)
+buffer_gauges_collect_available_fn (vlib_stats_collector_data_t *d)
{
vlib_main_t *vm = vlib_get_main ();
- vlib_buffer_pool_t *bp = buffer_get_by_index (vm->buffer_main, index);
+ vlib_buffer_pool_t *bp =
+ buffer_get_by_index (vm->buffer_main, d->private_data);
if (!bp)
return;
- e->value = bp->n_avail;
+ d->entry->value = bp->n_avail;
}
static void
-buffer_gauges_update_cached_fn (stat_segment_directory_entry_t * e, u32 index)
+buffer_gauges_collect_cached_fn (vlib_stats_collector_data_t *d)
{
vlib_main_t *vm = vlib_get_main ();
- vlib_buffer_pool_t *bp = buffer_get_by_index (vm->buffer_main, index);
+ vlib_buffer_pool_t *bp =
+ buffer_get_by_index (vm->buffer_main, d->private_data);
if (!bp)
return;
- e->value = buffer_get_cached (bp);
+ d->entry->value = buffer_get_cached (bp);
}
clib_error_t *
@@ -902,23 +893,23 @@ vlib_buffer_main_init (struct vlib_main_t * vm)
vec_foreach (bp, bm->buffer_pools)
{
+ vlib_stats_collector_reg_t reg = { .private_data = bp - bm->buffer_pools };
if (bp->n_buffers == 0)
continue;
- vec_reset_length (name);
- name = format (name, "/buffer-pools/%s/cached%c", bp->name, 0);
- stat_segment_register_gauge (name, buffer_gauges_update_cached_fn,
- bp - bm->buffer_pools);
+ reg.entry_index =
+ vlib_stats_add_gauge ("/buffer-pools/%s/cached", bp->name);
+ reg.collect_fn = buffer_gauges_collect_cached_fn;
+ vlib_stats_register_collector_fn (&reg);
- vec_reset_length (name);
- name = format (name, "/buffer-pools/%s/used%c", bp->name, 0);
- stat_segment_register_gauge (name, buffer_gauges_update_used_fn,
- bp - bm->buffer_pools);
+ reg.entry_index = vlib_stats_add_gauge ("/buffer-pools/%s/used", bp->name);
+ reg.collect_fn = buffer_gauges_collect_used_fn;
+ vlib_stats_register_collector_fn (&reg);
- vec_reset_length (name);
- name = format (name, "/buffer-pools/%s/available%c", bp->name, 0);
- stat_segment_register_gauge (name, buffer_gauges_update_available_fn,
- bp - bm->buffer_pools);
+ reg.entry_index =
+ vlib_stats_add_gauge ("/buffer-pools/%s/available", bp->name);
+ reg.collect_fn = buffer_gauges_collect_available_fn;
+ vlib_stats_register_collector_fn (&reg);
}
done: