aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/mactime
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/plugins/mactime
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/plugins/mactime')
-rw-r--r--src/plugins/mactime/mactime_top.c30
1 files changed, 14 insertions, 16 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;
}