summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/client
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/vpp-api/client
parent317cace6185ae134d78a38e1a20249baf751035e (diff)
stats: refactor
Type: refactor Change-Id: Ifd533a095d979dc55bfbe5fac7e0b7510a4d900c Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vpp-api/client')
-rw-r--r--src/vpp-api/client/stat_client.c23
-rw-r--r--src/vpp-api/client/stat_client.h16
2 files changed, 19 insertions, 20 deletions
diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c
index b0c83919f03..a5eafaf5f68 100644
--- a/src/vpp-api/client/stat_client.c
+++ b/src/vpp-api/client/stat_client.c
@@ -29,7 +29,8 @@
#include <vppinfra/vec.h>
#include <vppinfra/lock.h>
#include <stdatomic.h>
-#include <vpp/stats/stat_segment.h>
+#include <vlib/vlib.h>
+#include <vlib/stats/stats.h>
#include <vpp-api/client/stat_client.h>
stat_client_main_t stat_client_main;
@@ -81,8 +82,8 @@ recv_fd (int sock)
return fd;
}
-static stat_segment_directory_entry_t *
-get_stat_vector_r (stat_client_main_t * sm)
+static vlib_stats_entry_t *
+get_stat_vector_r (stat_client_main_t *sm)
{
ASSERT (sm->shared_header);
return stat_segment_adjust (sm,
@@ -172,7 +173,7 @@ double
stat_segment_heartbeat_r (stat_client_main_t * sm)
{
stat_segment_access_t sa;
- stat_segment_directory_entry_t *ep;
+ vlib_stats_entry_t *ep;
/* Has directory been updated? */
if (sm->shared_header->epoch != sm->current_epoch)
@@ -223,7 +224,7 @@ stat_vec_combined_init (vlib_counter_t c)
* threads), otherwise copy out all values.
*/
static stat_segment_data_t
-copy_data (stat_segment_directory_entry_t *ep, u32 index2, char *name,
+copy_data (vlib_stats_entry_t *ep, u32 index2, char *name,
stat_client_main_t *sm)
{
stat_segment_data_t result = { 0 };
@@ -297,7 +298,7 @@ copy_data (stat_segment_directory_entry_t *ep, u32 index2, char *name,
case STAT_DIR_TYPE_SYMLINK:
/* Gather info from all threads into a vector */
{
- stat_segment_directory_entry_t *ep2;
+ vlib_stats_entry_t *ep2;
ep2 = vec_elt_at_index (sm->directory_vector, ep->index1);
return copy_data (ep2, ep->index2, ep->name, sm);
}
@@ -370,7 +371,7 @@ stat_segment_ls_r (uint8_t ** patterns, stat_client_main_t * sm)
if (stat_segment_access_start (&sa, sm))
return 0;
- stat_segment_directory_entry_t *counter_vec = get_stat_vector_r (sm);
+ vlib_stats_entry_t *counter_vec = get_stat_vector_r (sm);
for (j = 0; j < vec_len (counter_vec); j++)
{
for (i = 0; i < vec_len (patterns); i++)
@@ -413,7 +414,7 @@ stat_segment_data_t *
stat_segment_dump_r (uint32_t * stats, stat_client_main_t * sm)
{
int i;
- stat_segment_directory_entry_t *ep;
+ vlib_stats_entry_t *ep;
stat_segment_data_t *res = 0;
stat_segment_access_t sa;
@@ -474,7 +475,7 @@ stat_segment_string_vector (uint8_t ** string_vector, const char *string)
stat_segment_data_t *
stat_segment_dump_entry_r (uint32_t index, stat_client_main_t * sm)
{
- stat_segment_directory_entry_t *ep;
+ vlib_stats_entry_t *ep;
stat_segment_data_t *res = 0;
stat_segment_access_t sa;
@@ -504,9 +505,9 @@ stat_segment_dump_entry (uint32_t index)
char *
stat_segment_index_to_name_r (uint32_t index, stat_client_main_t * sm)
{
- stat_segment_directory_entry_t *ep;
+ vlib_stats_entry_t *ep;
stat_segment_access_t sa;
- stat_segment_directory_entry_t *vec;
+ vlib_stats_entry_t *vec;
/* Has directory been update? */
if (sm->shared_header->epoch != sm->current_epoch)
diff --git a/src/vpp-api/client/stat_client.h b/src/vpp-api/client/stat_client.h
index 730badd1728..26752718d90 100644
--- a/src/vpp-api/client/stat_client.h
+++ b/src/vpp-api/client/stat_client.h
@@ -25,7 +25,7 @@
#include <vlib/counter_types.h>
#include <time.h>
#include <stdbool.h>
-#include <vpp/stats/stat_segment_shared.h>
+#include <vlib/stats/shared.h>
/* Default socket to exchange segment fd */
/* TODO: Get from runtime directory */
@@ -49,8 +49,8 @@ typedef struct
typedef struct
{
uint64_t current_epoch;
- stat_segment_shared_header_t *shared_header;
- stat_segment_directory_entry_t *directory_vector;
+ vlib_stats_shared_header_t *shared_header;
+ vlib_stats_entry_t *directory_vector;
ssize_t memory_size;
uint64_t timeout;
} stat_client_main_t;
@@ -115,7 +115,7 @@ static inline int
stat_segment_access_start (stat_segment_access_t * sa,
stat_client_main_t * sm)
{
- stat_segment_shared_header_t *shared_header = sm->shared_header;
+ vlib_stats_shared_header_t *shared_header = sm->shared_header;
uint64_t max_time;
sa->epoch = shared_header->epoch;
@@ -130,10 +130,8 @@ stat_segment_access_start (stat_segment_access_t * sa,
while (shared_header->in_progress != 0)
;
}
- sm->directory_vector =
- (stat_segment_directory_entry_t *) stat_segment_adjust (sm,
- (void *)
- sm->shared_header->directory_vector);
+ sm->directory_vector = (vlib_stats_entry_t *) stat_segment_adjust (
+ sm, (void *) sm->shared_header->directory_vector);
if (sm->timeout)
return _time_now_nsec () < max_time ? 0 : -1;
return 0;
@@ -164,7 +162,7 @@ stat_segment_set_timeout (uint64_t timeout)
static inline bool
stat_segment_access_end (stat_segment_access_t * sa, stat_client_main_t * sm)
{
- stat_segment_shared_header_t *shared_header = sm->shared_header;
+ vlib_stats_shared_header_t *shared_header = sm->shared_header;
if (shared_header->epoch != sa->epoch || shared_header->in_progress)
return false;