summaryrefslogtreecommitdiffstats
path: root/src/plugins
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/plugins
parent317cace6185ae134d78a38e1a20249baf751035e (diff)
stats: refactor
Type: refactor Change-Id: Ifd533a095d979dc55bfbe5fac7e0b7510a4d900c Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lacp/input.c14
-rw-r--r--src/plugins/lacp/lacp.c26
-rw-r--r--src/plugins/mactime/mactime_top.c2
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.c14
-rw-r--r--src/plugins/nat/pnat/tests/pnat_test_stubs.h6
-rw-r--r--src/plugins/prom/prom.c4
-rw-r--r--src/plugins/unittest/counter_test.c6
7 files changed, 33 insertions, 39 deletions
diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c
index ebca2ad9185..3997af897eb 100644
--- a/src/plugins/lacp/input.c
+++ b/src/plugins/lacp/input.c
@@ -16,7 +16,7 @@
#define _GNU_SOURCE
#include <vnet/bonding/node.h>
#include <lacp/node.h>
-#include <vpp/stats/stat_segment.h>
+#include <vlib/stats/stats.h>
static int
lacp_packet_scan (vlib_main_t * vm, member_if_t * mif)
@@ -213,12 +213,12 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
/* Actually scan the packet */
e = lacp_packet_scan (vm, mif);
bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance);
- stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
- [mif->sw_if_index].actor_state,
- mif->actor.state);
- stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
- [mif->sw_if_index].partner_state,
- mif->partner.state);
+ vlib_stats_set_gauge (
+ bm->stats[bif->sw_if_index][mif->sw_if_index].actor_state,
+ mif->actor.state);
+ vlib_stats_set_gauge (
+ bm->stats[bif->sw_if_index][mif->sw_if_index].partner_state,
+ mif->partner.state);
mif->last_packet_signature_valid = 1;
mif->last_packet_signature = last_packet_signature;
}
diff --git a/src/plugins/lacp/lacp.c b/src/plugins/lacp/lacp.c
index 44a32aa23a9..ad7710266f9 100644
--- a/src/plugins/lacp/lacp.c
+++ b/src/plugins/lacp/lacp.c
@@ -21,7 +21,7 @@
#include <vppinfra/hash.h>
#include <vnet/bonding/node.h>
#include <lacp/node.h>
-#include <vpp/stats/stat_segment.h>
+#include <vlib/stats/stats.h>
lacp_main_t lacp_main;
@@ -173,16 +173,16 @@ lacp_periodic (vlib_main_t * vm)
if (actor_state != mif->actor.state)
{
bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance);
- stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
- [mif->sw_if_index].actor_state,
- mif->actor.state);
+ vlib_stats_set_gauge (
+ bm->stats[bif->sw_if_index][mif->sw_if_index].actor_state,
+ mif->actor.state);
}
if (partner_state != mif->partner.state)
{
bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance);
- stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
- [mif->sw_if_index].partner_state,
- mif->partner.state);
+ vlib_stats_set_gauge (
+ bm->stats[bif->sw_if_index][mif->sw_if_index].partner_state,
+ mif->partner.state);
}
}
/* *INDENT-ON* */
@@ -380,12 +380,12 @@ lacp_init_state_machines (vlib_main_t * vm, member_if_t * mif)
lacp_init_mux_machine (vm, mif);
lacp_init_ptx_machine (vm, mif);
lacp_init_rx_machine (vm, mif);
- stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
- [mif->sw_if_index].actor_state,
- mif->actor.state);
- stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
- [mif->sw_if_index].partner_state,
- mif->partner.state);
+ vlib_stats_set_gauge (
+ bm->stats[bif->sw_if_index][mif->sw_if_index].actor_state,
+ mif->actor.state);
+ vlib_stats_set_gauge (
+ bm->stats[bif->sw_if_index][mif->sw_if_index].partner_state,
+ mif->partner.state);
}
VLIB_INIT_FUNCTION (lacp_periodic_init);
diff --git a/src/plugins/mactime/mactime_top.c b/src/plugins/mactime/mactime_top.c
index ed4c7345721..abcb530608c 100644
--- a/src/plugins/mactime/mactime_top.c
+++ b/src/plugins/mactime/mactime_top.c
@@ -187,7 +187,7 @@ scrape_stats_segment (mt_main_t * mm)
mactime_device_t *dev;
stat_segment_access_t sa;
stat_client_main_t *sm = mm->stat_client_main;
- stat_segment_directory_entry_t *ep;
+ vlib_stats_entry_t *ep;
int need_update2 = 0;
static u32 *pool_indices;
int i, j;
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.c b/src/plugins/nat/nat44-ed/nat44_ed.c
index c29ee54a6c4..b67a247358a 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed.c
@@ -38,7 +38,7 @@
#include <nat/nat44-ed/nat44_ed_affinity.h>
#include <nat/nat44-ed/nat44_ed_inlines.h>
-#include <vpp/stats/stat_segment.h>
+#include <vlib/stats/stats.h>
snat_main_t snat_main;
@@ -2290,8 +2290,8 @@ nat_init (vlib_main_t * vm)
nat_init_simple_counter (sm->total_sessions, "total-sessions",
"/nat44-ed/total-sessions");
- sm->max_cfg_sessions_gauge = stat_segment_new_entry (
- (u8 *) "/nat44-ed/max-cfg-sessions", STAT_DIR_TYPE_SCALAR_INDEX);
+ sm->max_cfg_sessions_gauge =
+ vlib_stats_add_gauge ("/nat44-ed/max-cfg-sessions");
#define _(x) \
nat_init_simple_counter (sm->counters.fastpath.in2out.x, #x, \
@@ -2373,8 +2373,8 @@ nat44_plugin_enable (nat44_config_t c)
c.sessions = 63 * 1024;
sm->max_translations_per_thread = c.sessions;
- stat_segment_set_state_counter (sm->max_cfg_sessions_gauge,
- sm->max_translations_per_thread);
+ vlib_stats_set_gauge (sm->max_cfg_sessions_gauge,
+ sm->max_translations_per_thread);
sm->translation_buckets = nat_calc_bihash_buckets (c.sessions);
vec_add1 (sm->max_translations_per_fib, sm->max_translations_per_thread);
@@ -3145,8 +3145,8 @@ nat44_update_session_limit (u32 session_limit, u32 vrf_id)
return 1;
sm->max_translations_per_thread = nat44_get_max_session_limit ();
- stat_segment_set_state_counter (sm->max_cfg_sessions_gauge,
- sm->max_translations_per_thread);
+ vlib_stats_set_gauge (sm->max_cfg_sessions_gauge,
+ sm->max_translations_per_thread);
sm->translation_buckets =
nat_calc_bihash_buckets (sm->max_translations_per_thread);
diff --git a/src/plugins/nat/pnat/tests/pnat_test_stubs.h b/src/plugins/nat/pnat/tests/pnat_test_stubs.h
index bfe1838ffa4..2dc59ac8586 100644
--- a/src/plugins/nat/pnat/tests/pnat_test_stubs.h
+++ b/src/plugins/nat/pnat/tests/pnat_test_stubs.h
@@ -19,12 +19,6 @@
void os_panic(void) {}
void os_exit(int code) {}
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index) { return 0; }
-#include <vpp/stats/stat_segment.h>
-clib_error_t *stat_segment_register_gauge(u8 *names,
- stat_segment_update_fn update_fn,
- u32 index) {
- return 0;
-};
#include <vnet/feature/feature.h>
vnet_feature_main_t feature_main;
void classify_get_trace_chain(void){};
diff --git a/src/plugins/prom/prom.c b/src/plugins/prom/prom.c
index 3fb3704a9a0..0b03a7adb0b 100644
--- a/src/plugins/prom/prom.c
+++ b/src/plugins/prom/prom.c
@@ -17,7 +17,7 @@
#include <prom/prom.h>
#include <vpp-api/client/stat_client.h>
-#include <vpp/stats/stat_segment.h>
+#include <vlib/stats/stats.h>
#include <ctype.h>
static prom_main_t prom_main;
@@ -388,7 +388,7 @@ static void
prom_stat_segment_client_init (void)
{
stat_client_main_t *scm = &stat_client_main;
- stat_segment_main_t *sm = &stat_segment_main;
+ vlib_stats_segment_t *sm = vlib_stats_get_segment ();
uword size;
size = sm->memory_size ? sm->memory_size : STAT_SEGMENT_DEFAULT_SIZE;
diff --git a/src/plugins/unittest/counter_test.c b/src/plugins/unittest/counter_test.c
index 24b9e1e386e..e7090f0a860 100644
--- a/src/plugins/unittest/counter_test.c
+++ b/src/plugins/unittest/counter_test.c
@@ -19,7 +19,7 @@
#include <vppinfra/error.h>
#include <vlib/counter.h>
-#include <vpp/stats/stat_segment.h>
+#include <vlib/stats/stats.h>
enum
{
@@ -38,7 +38,7 @@ enum
static uint64_t
get_stats_epoch ()
{
- stat_segment_main_t *sm = &stat_segment_main;
+ vlib_stats_segment_t *sm = vlib_stats_get_segment ();
return sm->shared_header->epoch;
}
@@ -49,7 +49,7 @@ get_stats_epoch ()
static int
get_vec_mem_size (void *v, uword data_size)
{
- stat_segment_main_t *sm = &stat_segment_main;
+ vlib_stats_segment_t *sm = vlib_stats_get_segment ();
if (v == 0)
return 0;