From: Ole Troan Date: Fri, 14 Jun 2019 08:26:14 +0000 (+0200) Subject: stats: add version field to stat segment base header X-Git-Tag: v20.01-rc0~409 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=commitdiff_plain;h=b63dbc537c02b1978345744ab34765b2d75011a6 stats: add version field to stat segment base header Add a version in the base header of the stat segment To make support for multiple reader implementations safer. Change-Id: I6816e2a51a98c2df1e621e80d4ef0b4ba4e9f47b Type: feature Signed-off-by: Ole Troan --- diff --git a/MAINTAINERS b/MAINTAINERS index 5cd51f211bd..883ee5bc2ca 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -363,6 +363,12 @@ I: vcl M: Florin Coras F: src/vcl +Statistics Segment +I: stats +M: Ole Troan +F: src/vpp/stats/ +F: src/vpp-api/client/stat_client.[ch] + THE REST I: misc C: Contact vpp-dev Mailing List diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c index 8991806448a..cfe213d938a 100644 --- a/src/vpp-api/client/stat_client.c +++ b/src/vpp-api/client/stat_client.c @@ -509,6 +509,20 @@ stat_segment_index_to_name (uint32_t index) return stat_segment_index_to_name_r (index, sm); } +uint64_t +stat_segment_version_r (stat_client_main_t * sm) +{ + ASSERT (sm->shared_header); + return sm->shared_header->version; +} + +uint64_t +stat_segment_version (void) +{ + stat_client_main_t *sm = &stat_client_main; + return stat_segment_version_r (sm); +} + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vpp-api/client/stat_client.h b/src/vpp-api/client/stat_client.h index 901ec325522..12faddb7bce 100644 --- a/src/vpp-api/client/stat_client.h +++ b/src/vpp-api/client/stat_client.h @@ -78,6 +78,8 @@ double stat_segment_heartbeat (void); char *stat_segment_index_to_name_r (uint32_t index, stat_client_main_t * sm); char *stat_segment_index_to_name (uint32_t index); +uint64_t stat_segment_version (void); +uint64_t stat_segment_version_r (stat_client_main_t * sm); #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 de72249ac6b..590549a17bd 100644 --- a/src/vpp-api/python/vpp_papi/vpp_stats.py +++ b/src/vpp-api/python/vpp_papi/vpp_stats.py @@ -49,6 +49,7 @@ typedef struct typedef struct { + uint64_t version; uint64_t epoch; uint64_t in_progress; uint64_t directory_offset; @@ -82,6 +83,8 @@ double stat_segment_heartbeat_r (stat_client_main_t * sm); int stat_segment_vec_len(void *vec); uint8_t **stat_segment_string_vector(uint8_t **string_vector, char *string); char *stat_segment_index_to_name_r (uint32_t index, stat_client_main_t * sm); +uint64_t stat_segment_version(void); +uint64_t stat_segment_version_r(stat_client_main_t *sm); void free(void *ptr); """) diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c index 61b21babbe3..cef792fc622 100644 --- a/src/vpp/stats/stat_segment.c +++ b/src/vpp/stats/stat_segment.c @@ -272,6 +272,9 @@ vlib_map_stat_segment_init (void) sm->directory_vector_by_name = hash_create_string (0, sizeof (uword)); sm->shared_header = shared_header = memaddr; + + shared_header->version = STAT_SEGMENT_VERSION; + sm->stat_segment_lockp = clib_mem_alloc (sizeof (clib_spinlock_t)); clib_spinlock_init (sm->stat_segment_lockp); diff --git a/src/vpp/stats/stat_segment.h b/src/vpp/stats/stat_segment.h index b9ffedf2169..113eb9a25ad 100644 --- a/src/vpp/stats/stat_segment.h +++ b/src/vpp/stats/stat_segment.h @@ -70,11 +70,15 @@ typedef struct /* Default stat segment 32m */ #define STAT_SEGMENT_DEFAULT_SIZE (32<<20) +/* Shared segment memory layout version */ +#define STAT_SEGMENT_VERSION 1 + /* * Shared header first in the shared memory segment. */ typedef struct { + u64 version; atomic_int_fast64_t epoch; atomic_int_fast64_t in_progress; atomic_int_fast64_t directory_offset;