aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api')
-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
3 files changed, 37 insertions, 51 deletions
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