aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/mactime/mactime_top.c30
-rw-r--r--src/vpp-api/client/stat_client.c64
-rw-r--r--src/vpp-api/client/stat_client.h15
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_stats.py9
-rw-r--r--src/vpp/stats/stat_segment.c154
-rw-r--r--src/vpp/stats/stat_segment.h10
-rw-r--r--src/vpp/stats/stat_segment_shared.h9
7 files changed, 82 insertions, 209 deletions
diff --git a/src/plugins/mactime/mactime_top.c b/src/plugins/mactime/mactime_top.c
index ee60535e0c2..473cc5b5c0e 100644
--- a/src/plugins/mactime/mactime_top.c
+++ b/src/plugins/mactime/mactime_top.c
@@ -1,7 +1,6 @@
#include <vppinfra/time.h>
#include <vppinfra/hash.h>
#include <vppinfra/pool.h>
-#include <vpp/stats/stat_segment.h>
#include <vpp-api/client/stat_client.h>
#include <vppinfra/vec.h>
#include <mactime/mactime_device.h>
@@ -11,9 +10,9 @@
#include <vnet/api_errno.h>
#include <svm/queue.h>
-/* define message IDs */
-#include <mactime/mactime.api_enum.h>
+#include <vnet/format_fns.h>
#include <mactime/mactime.api_types.h>
+#include <mactime/mactime.api_enum.h>
typedef struct
{
@@ -108,14 +107,18 @@ vl_api_mactime_details_t_handler (vl_api_mactime_details_t * mp)
}
#define vl_print(handle, ...) fformat(handle, __VA_ARGS__)
+#define vl_endianfun /* define message structures */
+#include <mactime/mactime.api.h>
+#undef vl_endianfun
-#define vl_endianfun
+/* instantiate all the print functions we know about */
#define vl_printfun
+#include <mactime/mactime.api.h>
+#undef vl_printfun
+
#define vl_api_version(n,v) static u32 api_version = v;
#include <mactime/mactime.api.h>
#undef vl_api_version
-#undef vl_printfun
-#undef vl_endianfun
static int
connect_to_vpp (char *name)
@@ -137,7 +140,7 @@ connect_to_vpp (char *name)
vec_free (msg_base_lookup_name);
- if (mm->msg_id_base == ~0)
+ if (mm->msg_id_base == (u16) ~ 0)
return -1;
#define _(N,n) \
@@ -183,7 +186,6 @@ scrape_stats_segment (mt_main_t * mm)
{
vlib_counter_t **counters_by_thread;
vlib_counter_t *counters;
- u64 *offset_vector;
mactime_device_t *dev;
stat_segment_access_t sa;
stat_client_main_t *sm = mm->stat_client_main;
@@ -217,8 +219,7 @@ again1:
stat_segment_access_start (&sa, sm);
ep = vec_elt_at_index (sm->directory_vector, mm->ls_result1[0]);
- counters_by_thread = stat_segment_pointer (sm->shared_header, ep->offset);
- offset_vector = stat_segment_pointer (sm->shared_header, ep->offset_vector);
+ counters_by_thread = stat_segment_adjust (sm, ep->data);
for (i = 0; i < vec_len (pool_indices); i++)
{
@@ -230,8 +231,7 @@ again1:
for (j = 0; j < vec_len (counters_by_thread); j++)
{
- counters = stat_segment_pointer (sm->shared_header,
- offset_vector[j]);
+ counters = stat_segment_adjust (sm, counters_by_thread[j]);
mm->allow_counters[index].packets += counters[index].packets;
mm->allow_counters[index].bytes += counters[index].bytes;
}
@@ -252,8 +252,7 @@ again2:
stat_segment_access_start (&sa, sm);
ep = vec_elt_at_index (sm->directory_vector, mm->ls_result2[0]);
- counters_by_thread = stat_segment_pointer (sm->shared_header, ep->offset);
- offset_vector = stat_segment_pointer (sm->shared_header, ep->offset_vector);
+ counters_by_thread = stat_segment_adjust (sm, ep->data);
for (i = 0; i < vec_len (pool_indices); i++)
{
@@ -265,8 +264,7 @@ again2:
for (j = 0; j < vec_len (counters_by_thread); j++)
{
- counters = stat_segment_pointer (sm->shared_header,
- offset_vector[j]);
+ counters = stat_segment_adjust (sm, counters_by_thread[j]);
mm->drop_counters[index].packets += counters[index].packets;
mm->drop_counters[index].bytes += counters[index].bytes;
}
diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c
index 54d6db660ee..56ff387d343 100644
--- a/src/vpp-api/client/stat_client.c
+++ b/src/vpp-api/client/stat_client.c
@@ -85,8 +85,8 @@ static stat_segment_directory_entry_t *
get_stat_vector_r (stat_client_main_t * sm)
{
ASSERT (sm->shared_header);
- return stat_segment_pointer (sm->shared_header,
- sm->shared_header->directory_offset);
+ return stat_segment_adjust (sm,
+ (void *) sm->shared_header->directory_vector);
}
int
@@ -142,7 +142,7 @@ stat_segment_connect_r (const char *socket_name, stat_client_main_t * sm)
sm->memory_size = st.st_size;
sm->shared_header = memaddr;
sm->directory_vector =
- stat_segment_pointer (memaddr, sm->shared_header->directory_offset);
+ stat_segment_adjust (sm, (void *) sm->shared_header->directory_vector);
return 0;
}
@@ -199,7 +199,7 @@ copy_data (stat_segment_directory_entry_t * ep, stat_client_main_t * sm)
int i;
vlib_counter_t **combined_c; /* Combined counter */
counter_t **simple_c; /* Simple counter */
- uint64_t *offset_vector;
+ uint64_t *error_vector;
assert (sm->shared_header);
@@ -212,67 +212,47 @@ copy_data (stat_segment_directory_entry_t * ep, stat_client_main_t * sm)
break;
case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE:
- if (ep->offset == 0)
- return result;
- simple_c = stat_segment_pointer (sm->shared_header, ep->offset);
+ simple_c = stat_segment_adjust (sm, ep->data);
result.simple_counter_vec = vec_dup (simple_c);
- offset_vector =
- stat_segment_pointer (sm->shared_header, ep->offset_vector);
for (i = 0; i < vec_len (simple_c); i++)
{
- counter_t *cb =
- stat_segment_pointer (sm->shared_header, offset_vector[i]);
+ counter_t *cb = stat_segment_adjust (sm, simple_c[i]);
result.simple_counter_vec[i] = vec_dup (cb);
}
break;
case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED:
- if (ep->offset == 0)
- return result;
- combined_c = stat_segment_pointer (sm->shared_header, ep->offset);
+ combined_c = stat_segment_adjust (sm, ep->data);
result.combined_counter_vec = vec_dup (combined_c);
- offset_vector =
- stat_segment_pointer (sm->shared_header, ep->offset_vector);
for (i = 0; i < vec_len (combined_c); i++)
{
- vlib_counter_t *cb =
- stat_segment_pointer (sm->shared_header, offset_vector[i]);
+ vlib_counter_t *cb = stat_segment_adjust (sm, combined_c[i]);
result.combined_counter_vec[i] = vec_dup (cb);
}
break;
case STAT_DIR_TYPE_ERROR_INDEX:
/* Gather errors from all threads into a vector */
- offset_vector = stat_segment_pointer (sm->shared_header,
- sm->shared_header->error_offset);
- vec_validate (result.error_vector, vec_len (offset_vector) - 1);
- for (i = 0; i < vec_len (offset_vector); i++)
+ error_vector =
+ stat_segment_adjust (sm, (void *) sm->shared_header->error_vector);
+ vec_validate (result.error_vector, vec_len (error_vector) - 1);
+ for (i = 0; i < vec_len (error_vector); i++)
{
- counter_t *cb =
- stat_segment_pointer (sm->shared_header, offset_vector[i]);
+ counter_t *cb = stat_segment_adjust (sm, (void *) error_vector[i]);
result.error_vector[i] = cb[ep->index];
}
break;
case STAT_DIR_TYPE_NAME_VECTOR:
- if (ep->offset == 0)
- return result;
- uint8_t **name_vector =
- stat_segment_pointer (sm->shared_header, ep->offset);
- result.name_vector = vec_dup (name_vector);
- offset_vector =
- stat_segment_pointer (sm->shared_header, ep->offset_vector);
- for (i = 0; i < vec_len (name_vector); i++)
- {
- if (offset_vector[i])
- {
- u8 *name =
- stat_segment_pointer (sm->shared_header, offset_vector[i]);
- result.name_vector[i] = vec_dup (name);
- }
- else
- result.name_vector[i] = 0;
- }
+ {
+ uint8_t **name_vector = stat_segment_adjust (sm, ep->data);
+ result.name_vector = vec_dup (name_vector);
+ for (i = 0; i < vec_len (name_vector); i++)
+ {
+ u8 *name = stat_segment_adjust (sm, name_vector[i]);
+ result.name_vector[i] = vec_dup (name);
+ }
+ }
break;
case STAT_DIR_TYPE_EMPTY:
diff --git a/src/vpp-api/client/stat_client.h b/src/vpp-api/client/stat_client.h
index 052d9692c88..9385cd242d5 100644
--- a/src/vpp-api/client/stat_client.h
+++ b/src/vpp-api/client/stat_client.h
@@ -101,6 +101,13 @@ _time_now_nsec (void)
return 1e9 * ts.tv_sec + ts.tv_nsec;
}
+static inline void *
+stat_segment_adjust (stat_client_main_t * sm, void *data)
+{
+ return (void *) ((char *) sm->shared_header +
+ ((char *) data - (char *) sm->shared_header->base));
+}
+
static inline int
stat_segment_access_start (stat_segment_access_t * sa,
stat_client_main_t * sm)
@@ -120,9 +127,10 @@ 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_pointer (sm->shared_header,
- sm->shared_header->directory_offset);
+ sm->directory_vector =
+ (stat_segment_directory_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;
@@ -147,7 +155,6 @@ stat_segment_access_end (stat_segment_access_t * sa, stat_client_main_t * sm)
return true;
}
-
#endif /* included_stat_client_h */
/*
diff --git a/src/vpp-api/python/vpp_papi/vpp_stats.py b/src/vpp-api/python/vpp_papi/vpp_stats.py
index aa3409554d0..1a65c8ebad8 100644
--- a/src/vpp-api/python/vpp_papi/vpp_stats.py
+++ b/src/vpp-api/python/vpp_papi/vpp_stats.py
@@ -25,11 +25,10 @@ typedef struct
{
stat_directory_type_t type;
union {
- uint64_t offset;
uint64_t index;
uint64_t value;
+ uint64_t *data;
};
- uint64_t offset_vector;
char name[128]; // TODO change this to pointer to "somewhere"
} stat_segment_directory_entry_t;
@@ -50,11 +49,11 @@ typedef struct
typedef struct
{
uint64_t version;
+ void *base;
uint64_t epoch;
uint64_t in_progress;
- uint64_t directory_offset;
- uint64_t error_offset;
- uint64_t stats_offset;
+ stat_segment_directory_entry_t *directory_vector;
+ uint64_t **error_vector;
} stat_segment_shared_header_t;
typedef struct
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c
index 8727122cee7..8255b16c010 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -157,7 +157,6 @@ vlib_stats_delete_cm (void *cm_arg)
vlib_simple_counter_main_t *cm = (vlib_simple_counter_main_t *) cm_arg;
stat_segment_main_t *sm = &stat_segment_main;
stat_segment_directory_entry_t *e;
- stat_segment_shared_header_t *shared_header = sm->shared_header;
/* Not all counters have names / hash-table entries */
if (!cm->name && !cm->stat_segment_name)
@@ -174,10 +173,7 @@ vlib_stats_delete_cm (void *cm_arg)
e = &sm->directory_vector[index];
hash_unset (sm->directory_vector_by_name, &e->name);
- u64 *offset_vector = stat_segment_pointer (shared_header, e->offset_vector);
-
void *oldheap = clib_mem_set_heap (sm->heap); /* Enter stats segment */
- vec_free (offset_vector);
clib_mem_set_heap (oldheap); /* Exit stats segment */
memset (e, 0, sizeof (*e));
@@ -226,32 +222,10 @@ vlib_stats_pop_heap (void *cm_arg, void *oldheap, u32 cindex,
}
stat_segment_directory_entry_t *ep = &sm->directory_vector[vector_index];
- ep->offset = stat_segment_offset (shared_header, cm->counters); /* Vector of threads of vectors of counters */
- u64 *offset_vector =
- ep->offset_vector ? stat_segment_pointer (shared_header,
- ep->offset_vector) : 0;
-
- /* Update the 2nd dimension offset vector */
- int i;
- vec_validate (offset_vector, vec_len (cm->counters) - 1);
-
- if (sm->last != offset_vector)
- {
- for (i = 0; i < vec_len (cm->counters); i++)
- offset_vector[i] =
- stat_segment_offset (shared_header, cm->counters[i]);
- }
- else
- offset_vector[cindex] =
- stat_segment_offset (shared_header, cm->counters[cindex]);
-
- ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
- sm->directory_vector[vector_index].offset =
- stat_segment_offset (shared_header, cm->counters);
+ ep->data = cm->counters;
/* Reset the client hash table pointer, since it WILL change! */
- shared_header->directory_offset =
- stat_segment_offset (shared_header, sm->directory_vector);
+ shared_header->directory_vector = sm->directory_vector;
vlib_stat_segment_unlock ();
clib_mem_set_heap (oldheap);
@@ -278,13 +252,11 @@ vlib_stats_register_error_index (void *oldheap, u8 * name, u64 * em_vec,
memcpy (e.name, name, vec_len (name));
e.name[vec_len (name)] = '\0';
e.type = STAT_DIR_TYPE_ERROR_INDEX;
- e.offset = index;
- e.offset_vector = 0;
+ e.index = index;
vector_index = vlib_stats_create_counter (&e, oldheap);
/* Warn clients to refresh any pointers they might be holding */
- shared_header->directory_offset =
- stat_segment_offset (shared_header, sm->directory_vector);
+ shared_header->directory_vector = sm->directory_vector;
}
vlib_stat_segment_unlock ();
@@ -293,45 +265,24 @@ vlib_stats_register_error_index (void *oldheap, u8 * name, u64 * em_vec,
static void
stat_validate_counter_vector (stat_segment_directory_entry_t * ep, u32 max)
{
- stat_segment_main_t *sm = &stat_segment_main;
- stat_segment_shared_header_t *shared_header = sm->shared_header;
- counter_t **counters =
- ep->offset ? stat_segment_pointer (shared_header, ep->offset) : 0;
+ counter_t **counters = ep->data;
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i;
- u64 *offset_vector = 0;
vec_validate_aligned (counters, tm->n_vlib_mains - 1,
CLIB_CACHE_LINE_BYTES);
- ep->offset = stat_segment_offset (shared_header, counters);
-
for (i = 0; i < tm->n_vlib_mains; i++)
- {
- vec_validate_aligned (counters[i], max, CLIB_CACHE_LINE_BYTES);
- vec_add1 (offset_vector,
- stat_segment_offset (shared_header, counters[i]));
- }
+ vec_validate_aligned (counters[i], max, CLIB_CACHE_LINE_BYTES);
- if (ep->offset_vector)
- {
- u64 *p = stat_segment_pointer (sm->shared_header, ep->offset_vector);
- vec_free (p);
- }
- ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
+ ep->data = counters;
}
always_inline void
stat_set_simple_counter (stat_segment_directory_entry_t * ep,
u32 thread_index, u32 index, u64 value)
{
- stat_segment_main_t *sm = &stat_segment_main;
- stat_segment_shared_header_t *shared_header = sm->shared_header;
-
- ASSERT (shared_header);
- counter_t *offset_vector =
- stat_segment_pointer (sm->shared_header, ep->offset_vector);
- counter_t *cb =
- stat_segment_pointer (sm->shared_header, offset_vector[thread_index]);
+ ASSERT (ep->data);
+ counter_t *cb = ep->data;
cb[index] = value;
}
@@ -349,13 +300,10 @@ vlib_stats_pop_heap2 (u64 * error_vector, u32 thread_index, void *oldheap,
/* Reset the client hash table pointer, since it WILL change! */
vec_validate (sm->error_vector, thread_index);
- sm->error_vector[thread_index] =
- stat_segment_offset (shared_header, error_vector);
+ sm->error_vector[thread_index] = error_vector;
- shared_header->error_offset =
- stat_segment_offset (shared_header, sm->error_vector);
- shared_header->directory_offset =
- stat_segment_offset (shared_header, sm->directory_vector);
+ shared_header->error_vector = sm->error_vector;
+ shared_header->directory_vector = sm->directory_vector;
if (lock)
vlib_stat_segment_unlock ();
@@ -402,6 +350,7 @@ vlib_map_stat_segment_init (void)
sm->shared_header = shared_header = memaddr;
shared_header->version = STAT_SEGMENT_VERSION;
+ shared_header->base = memaddr;
sm->stat_segment_lockp = clib_mem_alloc (sizeof (clib_spinlock_t));
clib_spinlock_init (sm->stat_segment_lockp);
@@ -420,9 +369,8 @@ vlib_map_stat_segment_init (void)
sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
foreach_stat_segment_counter_name
#undef _
- /* Save the vector offset in the shared segment, for clients */
- shared_header->directory_offset =
- stat_segment_offset (shared_header, sm->directory_vector);
+ /* Save the vector in the shared segment, for clients */
+ shared_header->directory_vector = sm->directory_vector;
clib_mem_set_heap (oldheap);
@@ -482,7 +430,7 @@ format_stat_dir_entry (u8 * s, va_list * args)
break;
}
- return format (s, format_string, ep->name, type_name, ep->offset);
+ return format (s, format_string, ep->name, type_name, 0);
}
static clib_error_t *
@@ -551,7 +499,6 @@ update_node_counters (stat_segment_main_t * sm)
vlib_main_t **stat_vms = 0;
vlib_node_t ***node_dups = 0;
int i, j;
- stat_segment_shared_header_t *shared_header = sm->shared_header;
static u32 no_max_nodes = 0;
vlib_node_get_nodes (0 /* vm, for barrier sync */ ,
@@ -582,16 +529,11 @@ update_node_counters (stat_segment_main_t * sm)
vec_validate (sm->nodes, l - 1);
stat_segment_directory_entry_t *ep;
ep = &sm->directory_vector[STAT_COUNTER_NODE_NAMES];
- ep->offset = stat_segment_offset (shared_header, sm->nodes);
+ ep->data = sm->nodes;
- int i;
- u64 *offset_vector =
- ep->offset_vector ? stat_segment_pointer (shared_header,
- ep->offset_vector) : 0;
/* Update names dictionary */
- vec_validate (offset_vector, l - 1);
vlib_node_t **nodes = node_dups[0];
-
+ int i;
for (i = 0; i < vec_len (nodes); i++)
{
vlib_node_t *n = nodes[i];
@@ -600,13 +542,7 @@ update_node_counters (stat_segment_main_t * sm)
if (sm->nodes[n->index])
vec_free (sm->nodes[n->index]);
sm->nodes[n->index] = s;
- offset_vector[i] =
- sm->nodes[i] ? stat_segment_offset (shared_header,
- sm->nodes[i]) : 0;
-
}
- ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
-
vlib_stat_segment_unlock ();
clib_mem_set_heap (oldheap);
no_max_nodes = l;
@@ -622,31 +558,19 @@ update_node_counters (stat_segment_main_t * sm)
counter_t *c;
vlib_node_t *n = nodes[i];
- counters =
- stat_segment_pointer (shared_header,
- sm->directory_vector
- [STAT_COUNTER_NODE_CLOCKS].offset);
+ counters = sm->directory_vector[STAT_COUNTER_NODE_CLOCKS].data;
c = counters[j];
c[n->index] = n->stats_total.clocks - n->stats_last_clear.clocks;
- counters =
- stat_segment_pointer (shared_header,
- sm->directory_vector
- [STAT_COUNTER_NODE_VECTORS].offset);
+ counters = sm->directory_vector[STAT_COUNTER_NODE_VECTORS].data;
c = counters[j];
c[n->index] = n->stats_total.vectors - n->stats_last_clear.vectors;
- counters =
- stat_segment_pointer (shared_header,
- sm->directory_vector
- [STAT_COUNTER_NODE_CALLS].offset);
+ counters = sm->directory_vector[STAT_COUNTER_NODE_CALLS].data;
c = counters[j];
c[n->index] = n->stats_total.calls - n->stats_last_clear.calls;
- counters =
- stat_segment_pointer (shared_header,
- sm->directory_vector
- [STAT_COUNTER_NODE_SUSPENDS].offset);
+ counters = sm->directory_vector[STAT_COUNTER_NODE_SUSPENDS].data;
c = counters[j];
c[n->index] =
n->stats_total.suspends - n->stats_last_clear.suspends;
@@ -879,8 +803,7 @@ stat_segment_register_gauge (u8 * name, stat_segment_update_fn update_fn,
vlib_stat_segment_lock ();
vector_index = vlib_stats_create_counter (&e, oldheap);
- shared_header->directory_offset =
- stat_segment_offset (shared_header, sm->directory_vector);
+ shared_header->directory_vector = sm->directory_vector;
vlib_stat_segment_unlock ();
clib_mem_set_heap (oldheap);
@@ -919,8 +842,7 @@ stat_segment_register_state_counter (u8 * name, u32 * index)
vector_index = vlib_stats_create_counter (&e, oldheap);
- shared_header->directory_offset =
- stat_segment_offset (shared_header, sm->directory_vector);
+ shared_header->directory_vector = sm->directory_vector;
vlib_stat_segment_unlock ();
clib_mem_set_heap (oldheap);
@@ -1009,7 +931,6 @@ static clib_error_t *
statseg_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
{
stat_segment_main_t *sm = &stat_segment_main;
- stat_segment_shared_header_t *shared_header = sm->shared_header;
void *oldheap = vlib_stats_push_heap (sm->interfaces);
vlib_stat_segment_lock ();
@@ -1040,32 +961,7 @@ statseg_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
stat_segment_directory_entry_t *ep;
ep = &sm->directory_vector[STAT_COUNTER_INTERFACE_NAMES];
- ep->offset = stat_segment_offset (shared_header, sm->interfaces);
-
- int i;
- u64 *offset_vector =
- ep->offset_vector ? stat_segment_pointer (shared_header,
- ep->offset_vector) : 0;
-
- vec_validate (offset_vector, vec_len (sm->interfaces) - 1);
-
- if (sm->last != sm->interfaces)
- {
- /* the interface vector moved, so need to recalulate the offset array */
- for (i = 0; i < vec_len (sm->interfaces); i++)
- {
- offset_vector[i] =
- sm->interfaces[i] ? stat_segment_offset (shared_header,
- sm->interfaces[i]) : 0;
- }
- }
- else
- {
- offset_vector[sw_if_index] =
- sm->interfaces[sw_if_index] ?
- stat_segment_offset (shared_header, sm->interfaces[sw_if_index]) : 0;
- }
- ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
+ ep->data = sm->interfaces;
vlib_stat_segment_unlock ();
clib_mem_set_heap (oldheap);
diff --git a/src/vpp/stats/stat_segment.h b/src/vpp/stats/stat_segment.h
index 28e9ca3f778..a88067154f7 100644
--- a/src/vpp/stats/stat_segment.h
+++ b/src/vpp/stats/stat_segment.h
@@ -62,16 +62,10 @@ typedef enum
#define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
/* Shared segment memory layout version */
-#define STAT_SEGMENT_VERSION 1
+#define STAT_SEGMENT_VERSION 2
#define STAT_SEGMENT_INDEX_INVALID UINT32_MAX
-static inline uint64_t
-stat_segment_offset (void *start, void *data)
-{
- return (char *) data - (char *) start;
-}
-
typedef void (*stat_segment_update_fn)(stat_segment_directory_entry_t * e, u32 i);
typedef struct {
@@ -88,7 +82,7 @@ typedef struct
/* statistics segment */
uword *directory_vector_by_name;
stat_segment_directory_entry_t *directory_vector;
- u64 *error_vector;
+ volatile u64 **error_vector;
u8 **interfaces;
u8 **nodes;
diff --git a/src/vpp/stats/stat_segment_shared.h b/src/vpp/stats/stat_segment_shared.h
index 982bddd66b6..b09e2b5618f 100644
--- a/src/vpp/stats/stat_segment_shared.h
+++ b/src/vpp/stats/stat_segment_shared.h
@@ -31,11 +31,10 @@ typedef struct
{
stat_directory_type_t type;
union {
- uint64_t offset;
uint64_t index;
uint64_t value;
+ void *data;
};
- uint64_t offset_vector;
char name[128]; // TODO change this to pointer to "somewhere"
} stat_segment_directory_entry_t;
@@ -45,11 +44,11 @@ typedef struct
typedef struct
{
uint64_t version;
+ void *base;
volatile uint64_t epoch;
volatile uint64_t in_progress;
- volatile uint64_t directory_offset;
- volatile uint64_t error_offset;
- volatile uint64_t stats_offset;
+ volatile stat_segment_directory_entry_t *directory_vector;
+ volatile uint64_t **error_vector;
} stat_segment_shared_header_t;
static inline void *