summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/client/stat_client.h
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2020-07-21 08:46:08 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-08-13 07:28:13 +0000
commit7d29e320fb2855a1ddb7a6af09078b8ed636de01 (patch)
tree52f71f8ab88c29a0b8cb8c0cea27fe7d45a95143 /src/vpp-api/client/stat_client.h
parentff40d8f1b2f4efcf05f21934b423dce8aba8b652 (diff)
stats: remove offsets on vpp side
Represent pointers directly in shared memory and require clients to adjust for shared memory segment being mapped at different base address. Deprecated: stat_segment_pointer() / stat_segment_offset() Added: stat_segment_adjust() Bumped the stat segment version to 2. Type: refactor Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I33e756187b8903b45dcd353e6c1a101b7a4acb79
Diffstat (limited to 'src/vpp-api/client/stat_client.h')
-rw-r--r--src/vpp-api/client/stat_client.h15
1 files changed, 11 insertions, 4 deletions
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 */
/*