FD.io VPP  v19.01.2-3-gf61a1a8
Vector Packet Processing
stat_segment.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vppinfra/mem.h>
17 #include <vlib/vlib.h>
18 #include <vlib/unix/unix.h>
19 #include "stat_segment.h"
20 #include <vnet/vnet.h>
21 #include <vnet/devices/devices.h> /* vnet_get_aggregate_rx_packets */
22 #undef HAVE_MEMFD_CREATE
23 #include <vppinfra/linux/syscall.h>
26 
27 /*
28  * Used only by VPP writers
29  */
30 void
32 {
35  sm->shared_header->in_progress = 1;
36 }
37 
38 void
40 {
42  sm->shared_header->epoch++;
43  sm->shared_header->in_progress = 0;
45 }
46 
47 /*
48  * Change heap to the stats shared memory segment
49  */
50 void *
52 {
54 
55  ASSERT (sm && sm->shared_header);
56  return clib_mem_set_heap (sm->heap);
57 }
58 
59 /* Name to vector index hash */
60 static u32
61 lookup_or_create_hash_index (void *oldheap, char *name, u32 next_vector_index)
62 {
64  u32 index;
65  hash_pair_t *hp;
66 
67  hp = hash_get_pair (sm->directory_vector_by_name, name);
68  if (!hp)
69  {
70  hash_set (sm->directory_vector_by_name, name, next_vector_index);
71  index = next_vector_index;
72  }
73  else
74  {
75  index = hp->value[0];
76  }
77 
78  return index;
79 }
80 
81 void
82 vlib_stats_pop_heap (void *cm_arg, void *oldheap, stat_directory_type_t type)
83 {
86  stat_segment_shared_header_t *shared_header = sm->shared_header;
87  char *stat_segment_name;
89 
90  /* Not all counters have names / hash-table entries */
91  if (!cm->name && !cm->stat_segment_name)
92  {
93  clib_mem_set_heap (oldheap);
94  return;
95  }
96 
97  ASSERT (shared_header);
98 
100 
101  /* Lookup hash-table is on the main heap */
102  stat_segment_name =
103  cm->stat_segment_name ? cm->stat_segment_name : cm->name;
104  u32 next_vector_index = vec_len (sm->directory_vector);
105  clib_mem_set_heap (oldheap); /* Exit stats segment */
106  u32 vector_index = lookup_or_create_hash_index (oldheap, stat_segment_name,
107  next_vector_index);
108  /* Back to stats segment */
109  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */
110 
111 
112  /* Update the vector */
113  if (vector_index == next_vector_index)
114  { /* New */
115  strncpy (e.name, stat_segment_name, 128 - 1);
116  e.type = type;
117  vec_add1 (sm->directory_vector, e);
118  }
119 
120  stat_segment_directory_entry_t *ep = &sm->directory_vector[vector_index];
121  ep->offset = stat_segment_offset (shared_header, cm->counters); /* Vector of threads of vectors of counters */
122  u64 *offset_vector =
123  ep->offset_vector ? stat_segment_pointer (shared_header,
124  ep->offset_vector) : 0;
125 
126  /* Update the 2nd dimension offset vector */
127  int i;
128  vec_validate (offset_vector, vec_len (cm->counters) - 1);
129  for (i = 0; i < vec_len (cm->counters); i++)
130  offset_vector[i] = stat_segment_offset (shared_header, cm->counters[i]);
131  ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
132  sm->directory_vector[vector_index].offset =
133  stat_segment_offset (shared_header, cm->counters);
134 
135  /* Reset the client hash table pointer, since it WILL change! */
136  shared_header->directory_offset =
137  stat_segment_offset (shared_header, sm->directory_vector);
138 
140  clib_mem_set_heap (oldheap);
141 }
142 
143 void
145 {
147  stat_segment_shared_header_t *shared_header = sm->shared_header;
149  hash_pair_t *hp;
150 
151  ASSERT (shared_header);
152 
154 
155  memcpy (e.name, name, vec_len (name));
156  e.name[vec_len (name)] = '\0';
158  e.offset = index;
159  e.offset_vector = 0;
160  vec_add1 (sm->directory_vector, e);
161 
162  /* Warn clients to refresh any pointers they might be holding */
163  shared_header->directory_offset =
164  stat_segment_offset (shared_header, sm->directory_vector);
165 
167 }
168 
169 static void
171 {
173  stat_segment_shared_header_t *shared_header = sm->shared_header;
174  counter_t **counters = 0;
176  int i;
177  u64 *offset_vector = 0;
178 
179  vec_validate_aligned (counters, tm->n_vlib_mains - 1,
181  for (i = 0; i < tm->n_vlib_mains; i++)
182  {
183  vec_validate_aligned (counters[i], max, CLIB_CACHE_LINE_BYTES);
184  vec_add1 (offset_vector,
185  stat_segment_offset (shared_header, counters[i]));
186  }
187  ep->offset = stat_segment_offset (shared_header, counters);
188  ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
189 }
190 
191 void
192 vlib_stats_pop_heap2 (u64 * error_vector, u32 thread_index, void *oldheap)
193 {
195  stat_segment_shared_header_t *shared_header = sm->shared_header;
196 
197  ASSERT (shared_header);
198 
200 
201  /* Reset the client hash table pointer, since it WILL change! */
202  shared_header->error_offset =
203  stat_segment_offset (shared_header, error_vector);
204  shared_header->directory_offset =
205  stat_segment_offset (shared_header, sm->directory_vector);
206 
208  clib_mem_set_heap (oldheap);
209 }
210 
211 clib_error_t *
213 {
215  stat_segment_shared_header_t *shared_header;
217 
218  f64 *scalar_data;
219  u8 *name;
220  void *oldheap;
221  u32 *lock;
222  int rv;
223  ssize_t memory_size;
224 
225 
226  int mfd;
227  char *mem_name = "stat_segment_test";
228  void *memaddr;
229 
230  memory_size = sm->memory_size;
231  if (memory_size == 0)
232  memory_size = STAT_SEGMENT_DEFAULT_SIZE;
233 
234  /* Create shared memory segment */
235  if ((mfd = memfd_create (mem_name, 0)) < 0)
236  return clib_error_return (0, "stat segment memfd_create failure");
237 
238  /* Set size */
239  if ((ftruncate (mfd, memory_size)) == -1)
240  return clib_error_return (0, "stat segment ftruncate failure");
241 
242  if ((memaddr =
243  mmap (NULL, memory_size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd,
244  0)) == MAP_FAILED)
245  return clib_error_return (0, "stat segment mmap failure");
246 
247  void *heap;
248 #if USE_DLMALLOC == 0
249  heap = mheap_alloc_with_flags (((u8 *) memaddr) + getpagesize (),
250  memory_size - getpagesize (),
253 #else
254  heap =
255  create_mspace_with_base (((u8 *) memaddr) + getpagesize (),
256  memory_size - getpagesize (), 1 /* locked */ );
257  mspace_disable_expand (heap);
258 #endif
259 
260  sm->heap = heap;
261  sm->memfd = mfd;
262 
264  sm->shared_header = shared_header = memaddr;
267 
268  oldheap = clib_mem_set_heap (sm->heap);
269 
270  /* Set up the name to counter-vector hash table */
271  sm->directory_vector = 0;
272 
273  shared_header->epoch = 1;
274 
275  /* Scalar stats and node counters */
277 #define _(E,t,n,p) \
278  strcpy(sm->directory_vector[STAT_COUNTER_##E].name, "/sys" #p "/" #n); \
279  sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
281 #undef _
282  /* Save the vector offset in the shared segment, for clients */
283  shared_header->directory_offset =
284  stat_segment_offset (shared_header, sm->directory_vector);
285 
286  clib_mem_set_heap (oldheap);
287 
288  return 0;
289 }
290 
291 static int
292 name_sort_cmp (void *a1, void *a2)
293 {
296 
297  return strcmp ((char *) n1->name, (char *) n2->name);
298 }
299 
300 static u8 *
301 format_stat_dir_entry (u8 * s, va_list * args)
302 {
304  va_arg (*args, stat_segment_directory_entry_t *);
305  char *type_name;
306  char *format_string;
307 
308  format_string = "%-74s %-10s %10lld";
309 
310  switch (ep->type)
311  {
313  type_name = "ScalarPtr";
314  break;
315 
318  type_name = "CMainPtr";
319  break;
320 
322  type_name = "ErrIndex";
323  break;
324 
325  default:
326  type_name = "illegal!";
327  break;
328  }
329 
330  return format (s, format_string, ep->name, type_name, ep->offset);
331 }
332 
333 static clib_error_t *
335  unformat_input_t * input,
336  vlib_cli_command_t * cmd)
337 {
339  counter_t *counter;
340  hash_pair_t *p;
341  stat_segment_directory_entry_t *show_data, *this;
342  int i, j;
343 
344  int verbose = 0;
345  u8 *s;
346 
347  if (unformat (input, "verbose"))
348  verbose = 1;
349 
350  /* Lock even as reader, as this command doesn't handle epoch changes */
352  show_data = vec_dup (sm->directory_vector);
354 
356 
357  vlib_cli_output (vm, "%-74s %10s %10s", "Name", "Type", "Value");
358 
359  for (i = 0; i < vec_len (show_data); i++)
360  {
361  vlib_cli_output (vm, "%-100U", format_stat_dir_entry,
362  vec_elt_at_index (show_data, i));
363  }
364 
365  if (verbose)
366  {
367  ASSERT (sm->heap);
368  vlib_cli_output (vm, "%U", format_mheap, sm->heap, 0 /* verbose */ );
369  }
370 
371  return 0;
372 }
373 
374 /* *INDENT-OFF* */
375 VLIB_CLI_COMMAND (show_stat_segment_command, static) =
376 {
377  .path = "show statistics segment",
378  .short_help = "show statistics segment [verbose]",
379  .function = show_stat_segment_command_fn,
380 };
381 /* *INDENT-ON* */
382 
383 /*
384  * Node performance counters:
385  * total_calls [threads][node-index]
386  * total_vectors
387  * total_calls
388  * total suspends
389  */
390 
391 static inline void
393 {
394  vlib_main_t *vm = vlib_mains[0];
395  vlib_main_t **stat_vms = 0;
396  vlib_node_t ***node_dups = 0;
397  int i, j;
398  stat_segment_shared_header_t *shared_header = sm->shared_header;
399  static u32 no_max_nodes = 0;
400 
401  vlib_node_get_nodes (0 /* vm, for barrier sync */ ,
402  (u32) ~ 0 /* all threads */ ,
403  1 /* include stats */ ,
404  0 /* barrier sync */ ,
405  &node_dups, &stat_vms);
406 
407  u32 l = vec_len (node_dups[0]);
408 
409  /*
410  * Extend performance nodes if necessary
411  */
412  if (l > no_max_nodes)
413  {
414  void *oldheap = clib_mem_set_heap (sm->heap);
416 
425 
427  clib_mem_set_heap (oldheap);
428  no_max_nodes = l;
429  }
430 
431  for (j = 0; j < vec_len (node_dups); j++)
432  {
433  vlib_node_t **nodes = node_dups[j];
434  u32 l = vec_len (nodes);
435 
436  for (i = 0; i < vec_len (nodes); i++)
437  {
438  counter_t **counters;
439  counter_t *c;
440  vlib_node_t *n = nodes[i];
441 
442  counters =
443  stat_segment_pointer (shared_header,
444  sm->directory_vector
446  c = counters[j];
448 
449  counters =
450  stat_segment_pointer (shared_header,
451  sm->directory_vector
453  c = counters[j];
455 
456  counters =
457  stat_segment_pointer (shared_header,
458  sm->directory_vector
460  c = counters[j];
461  c[n->index] = n->stats_total.calls - n->stats_last_clear.calls;
462 
463  counters =
464  stat_segment_pointer (shared_header,
465  sm->directory_vector
467  c = counters[j];
468  c[n->index] =
470  }
471  }
472 }
473 
474 static void
476 {
477  vlib_main_t *vm = vlib_mains[0];
478  f64 vector_rate;
479  u64 input_packets, last_input_packets;
480  f64 dt, now;
481  vlib_main_t *this_vlib_main;
482  int i, start;
483 
484  /*
485  * Compute the average vector rate across all workers
486  */
487  vector_rate = 0.0;
488 
489  start = vec_len (vlib_mains) > 1 ? 1 : 0;
490 
491  for (i = start; i < vec_len (vlib_mains); i++)
492  {
493  this_vlib_main = vlib_mains[i];
494  vector_rate += vlib_last_vector_length_per_node (this_vlib_main);
495  }
496  vector_rate /= (f64) (i - start);
497 
499  vector_rate / ((f64) (vec_len (vlib_mains) - start));
500 
501  /*
502  * Compute the aggregate input rate
503  */
504  now = vlib_time_now (vm);
506  input_packets = vnet_get_aggregate_rx_packets ();
508  (f64) (input_packets - sm->last_input_packets) / dt;
510  sm->last_input_packets = input_packets;
513 
514  if (sm->node_counters_enabled)
516 
517  /* Heartbeat, so clients detect we're still here */
519 }
520 
521 /*
522  * Accept connection on the socket and exchange the fd for the shared
523  * memory segment.
524  */
525 static clib_error_t *
527 {
529  clib_error_t *err;
530  clib_socket_t client = { 0 };
531 
532  err = clib_socket_accept (sm->socket, &client);
533  if (err)
534  {
535  clib_error_report (err);
536  return err;
537  }
538 
539  /* Send the fd across and close */
540  err = clib_socket_sendmsg (&client, 0, 0, &sm->memfd, 1);
541  if (err)
542  clib_error_report (err);
543  clib_socket_close (&client);
544 
545  return 0;
546 }
547 
548 static void
550 {
552  clib_error_t *error;
554 
555  memset (s, 0, sizeof (clib_socket_t));
556  s->config = (char *) sm->socket_name;
559 
560  if ((error = clib_socket_init (s)))
561  {
562  clib_error_report (error);
563  return;
564  }
565 
566  clib_file_t template = { 0 };
568  template.file_descriptor = s->fd;
569  template.description = format (0, "stats segment listener %s", s->config);
570  clib_file_add (&file_main, &template);
571 
572  sm->socket = s;
573 }
574 
575 static clib_error_t *
577 {
578  /*
579  * cleanup the listener socket on exit.
580  */
582  unlink ((char *) sm->socket_name);
583  return 0;
584 }
585 
587 
588 static uword
590  vlib_frame_t * f)
591 {
593 
594  /* Wait for Godot... */
595  f64 sleep_duration = 10;
596 
597  while (1)
598  {
600  vlib_process_suspend (vm, sleep_duration);
601  }
602  return 0; /* or not */
603 }
604 
605 static clib_error_t *
607 {
609  clib_error_t *error;
610 
611  /* dependent on unix_input_init */
612  if ((error = vlib_call_init_function (vm, unix_input_init)))
613  return error;
614 
615  if (sm->socket_name)
617 
618  return 0;
619 }
620 
621 static clib_error_t *
623 {
625 
626  /* set default socket file name when statseg config stanza is empty. */
628 
630  {
631  if (unformat (input, "socket-name %s", &sm->socket_name))
632  ;
633  else if (unformat (input, "default"))
635  else
636  if (unformat
637  (input, "size %U", unformat_memory_size, &sm->memory_size))
638  ;
639  else if (unformat (input, "per-node-counters on"))
640  sm->node_counters_enabled = 1;
641  else if (unformat (input, "per-node-counters off"))
642  sm->node_counters_enabled = 0;
643  else
644  return clib_error_return (0, "unknown input `%U'",
645  format_unformat_error, input);
646  }
647  return 0;
648 }
649 
652 
653 /* *INDENT-OFF* */
655 {
657 .name = "statseg-collector-process",
658 .type = VLIB_NODE_TYPE_PROCESS,
659 };
660 
661 /* *INDENT-ON* */
662 
663 /*
664  * fd.io coding-style-patch-verification: ON
665  *
666  * Local Variables:
667  * eval: (c-set-style "gnu")
668  * End:
669  */
static clib_error_t * statseg_config(vlib_main_t *vm, unformat_input_t *input)
Definition: stat_segment.c:622
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
void vlib_stats_pop_heap(void *cm_arg, void *oldheap, stat_directory_type_t type)
Definition: stat_segment.c:82
Definition: stat_segment.h:49
#define hash_set(h, key, value)
Definition: hash.h:255
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:89
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:74
static clib_error_t * unix_input_init(vlib_main_t *vm)
Definition: input.c:406
void vlib_stats_register_error_index(u8 *name, u64 *em_vec, u64 index)
Definition: stat_segment.c:144
static u64 vnet_get_aggregate_rx_packets(void)
Definition: devices.h:98
stat_segment_shared_header_t * shared_header
Definition: stat_segment.h:99
static clib_error_t * stats_socket_accept_ready(clib_file_t *uf)
Definition: stat_segment.c:526
stat_segment_main_t stat_segment_main
Definition: stat_segment.c:25
stat_segment_directory_entry_t * directory_vector
Definition: stat_segment.h:92
unsigned long u64
Definition: types.h:89
#define NULL
Definition: clib.h:58
u32 index
Definition: node.h:304
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:232
static uint64_t stat_segment_offset(void *start, void *data)
Definition: stat_segment.h:77
static void stat_validate_counter_vector(stat_segment_directory_entry_t *ep, u32 max)
Definition: stat_segment.c:170
static int memfd_create(const char *name, unsigned int flags)
Definition: syscall.h:50
#define STAT_SEGMENT_DEFAULT_SIZE
Definition: stat_segment.h:62
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:525
int i
clib_error_t * clib_socket_init(clib_socket_t *s)
Definition: socket.c:384
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
#define foreach_stat_segment_counter_name
Definition: stat_segment.h:38
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:450
#define MHEAP_FLAG_THREAD_SAFE
vlib_main_t ** vlib_mains
Definition: buffer.c:310
unsigned char u8
Definition: types.h:56
atomic_int_fast64_t in_progress
Definition: stat_segment.h:70
clib_file_function_t * read_function
Definition: file.h:67
double f64
Definition: types.h:142
uword value[0]
Definition: hash.h:165
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
Definition: main.h:323
#define CLIB_SOCKET_F_IS_SERVER
Definition: socket.h:58
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
Definition: node_funcs.h:452
DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, int locked)
vlib_node_stats_t stats_last_clear
Definition: node.h:298
uint64_t value
Definition: stat_segment.h:55
static void do_stat_segment_updates(stat_segment_main_t *sm)
Definition: stat_segment.c:475
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
void vlib_node_get_nodes(vlib_main_t *vm, u32 max_threads, int include_stats, int barrier_sync, vlib_node_t ****node_dupsp, vlib_main_t ***stat_vmsp)
Get list of nodes.
Definition: node.c:569
#define MHEAP_FLAG_DISABLE_VM
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:151
uint64_t counter_t
64bit counters
Definition: counter_types.h:22
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
Definition: error.h:99
clib_file_main_t file_main
Definition: main.c:63
#define hash_get_pair(h, key)
Definition: hash.h:252
unsigned int u32
Definition: types.h:88
static clib_error_t * statseg_init(vlib_main_t *vm)
Definition: stat_segment.c:606
A collection of simple counters.
Definition: counter.h:57
#define vlib_call_init_function(vm, x)
Definition: init.h:260
void * vlib_stats_push_heap(void)
Definition: stat_segment.c:51
#define hash_create_string(elts, value_bytes)
Definition: hash.h:690
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:57
char * name
The counter collection&#39;s name.
Definition: counter.h:64
u8 * format_mheap(u8 *s, va_list *va)
Definition: mem_dlmalloc.c:354
vlib_node_stats_t stats_total
Definition: node.h:294
static void * stat_segment_pointer(void *start, uint64_t offset)
Definition: stat_segment.h:83
static void stats_segment_socket_init(void)
Definition: stat_segment.c:549
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:524
f64 time_last_runtime_stats_clear
Definition: node.h:784
static clib_error_t * clib_socket_close(clib_socket_t *sock)
Definition: socket.h:175
static u8 * format_stat_dir_entry(u8 *s, va_list *args)
Definition: stat_segment.c:301
void vlib_stat_segment_unlock(void)
Definition: stat_segment.c:39
uint64_t offset
Definition: stat_segment.h:53
DLMALLOC_EXPORT void mspace_disable_expand(mspace msp)
struct _unformat_input_t unformat_input_t
u64 memory_size
Definition: vhost_user.h:115
static clib_error_t * stats_segment_socket_exit(vlib_main_t *vm)
Definition: stat_segment.c:576
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:375
u8 name[64]
Definition: memclnt.api:152
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:216
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
svmdb_client_t * c
static u32 lookup_or_create_hash_index(void *oldheap, char *name, u32 next_vector_index)
Definition: stat_segment.c:61
vlib_main_t * vm
Definition: buffer.c:301
#define STAT_SEGMENT_SOCKET_FILE
Definition: stat_client.h:34
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
Definition: init.h:168
stat_directory_type_t
Definition: stat_client.h:24
static void * clib_mem_set_heap(void *heap)
Definition: mem.h:261
static vlib_node_registration_t stat_segment_collector
(constructor) VLIB_REGISTER_NODE (stat_segment_collector)
Definition: stat_segment.c:654
void vlib_stat_segment_lock(void)
Definition: stat_segment.c:31
uint64_t offset_vector
Definition: stat_segment.h:57
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
Definition: mheap.c:885
char name[128]
Definition: stat_segment.h:58
#define ASSERT(truth)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
#define clib_error_report(e)
Definition: error.h:113
struct _socket_t clib_socket_t
atomic_int_fast64_t epoch
Definition: stat_segment.h:69
static void * clib_mem_alloc(uword size)
Definition: mem.h:132
#define CLIB_SOCKET_F_SEQPACKET
Definition: socket.h:63
static uword stat_segment_collector_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: stat_segment.c:589
uword * directory_vector_by_name
Definition: stat_segment.h:91
char * stat_segment_name
Name in stat segment directory.
Definition: counter.h:65
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_main_t node_main
Definition: main.h:129
#define CLIB_SOCKET_F_PASSCRED
Definition: socket.h:64
u64 uword
Definition: types.h:112
static void update_node_counters(stat_segment_main_t *sm)
Definition: stat_segment.c:392
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:984
static int name_sort_cmp(void *a1, void *a2)
Definition: stat_segment.c:292
static clib_error_t * show_stat_segment_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: stat_segment.c:334
unformat_function_t unformat_memory_size
Definition: format.h:295
clib_socket_t * socket
Definition: stat_segment.h:94
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
counter_t ** counters
Per-thread u64 non-atomic counters.
Definition: counter.h:59
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
Definition: file.h:51
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
Definition: socket.h:62
clib_error_t * vlib_map_stat_segment_init(void)
Definition: stat_segment.c:212
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:725
atomic_int_fast64_t error_offset
Definition: stat_segment.h:72
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap)
Definition: stat_segment.c:192
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
clib_spinlock_t * stat_segment_lockp
Definition: stat_segment.h:93
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
atomic_int_fast64_t directory_offset
Definition: stat_segment.h:71
stat_directory_type_t type
Definition: stat_segment.h:51