FD.io VPP  v21.06-3-gbb25fbf28
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 */
23 
25 
26 /*
27  * Used only by VPP writers
28  */
29 void
31 {
34  sm->shared_header->in_progress = 1;
35 }
36 
37 void
39 {
41  sm->shared_header->epoch++;
42  sm->shared_header->in_progress = 0;
44 }
45 
46 /*
47  * Change heap to the stats shared memory segment
48  */
49 void *
51 {
53 
54  sm->last = old;
55  ASSERT (sm && sm->shared_header);
56  return clib_mem_set_heap (sm->heap);
57 }
58 
59 static u32
61 {
64  hash_pair_t *hp;
65 
66  /* Must be called in the context of the main heap */
67  ASSERT (clib_mem_get_heap () != sm->heap);
68 
70  if (hp)
71  {
72  index = hp->value[0];
73  }
74 
75  return index;
76 }
77 
78 static void
80 {
82 
83  /* Must be called in the context of the main heap */
84  ASSERT (clib_mem_get_heap () != sm->heap);
85 
86  hash_set (sm->directory_vector_by_name, format (0, "%s%c", name, 0), index);
87 }
88 
89 static u32
91 {
93  u32 next_vector_index = vec_len (sm->directory_vector);
94 
95  ssize_t i;
97  {
99  {
100  next_vector_index = i;
101  break;
102  }
103  }
104 
105  return next_vector_index;
106 }
107 
108 static u32
110 {
112 
113  ASSERT (clib_mem_get_heap () == sm->heap);
114 
116 
117  clib_mem_set_heap (oldheap);
118  create_hash_index ((u8 *) e->name, index);
119  clib_mem_set_heap (sm->heap);
120 
122  sm->directory_vector[index] = *e;
123 
124  return index;
125 }
126 
127 static void
129 {
132 
133  ASSERT (clib_mem_get_heap () == sm->heap);
134 
135  if (index > vec_len (sm->directory_vector))
136  return;
137 
138  e = &sm->directory_vector[index];
139 
140  clib_mem_set_heap (oldheap);
142  clib_mem_set_heap (sm->heap);
143 
144  memset (e, 0, sizeof (*e));
146 }
147 
148 /*
149  * Called from main heap
150  */
151 void
152 vlib_stats_delete_cm (void *cm_arg)
153 {
157 
158  /* Not all counters have names / hash-table entries */
159  if (!cm->name && !cm->stat_segment_name)
160  {
161  return;
162  }
164 
165  /* Lookup hash-table is on the main heap */
166  char *stat_segment_name =
167  cm->stat_segment_name ? cm->stat_segment_name : cm->name;
168  u32 index = lookup_hash_index ((u8 *) stat_segment_name);
169 
170  e = &sm->directory_vector[index];
172 
173  void *oldheap = clib_mem_set_heap (sm->heap); /* Enter stats segment */
174  clib_mem_set_heap (oldheap); /* Exit stats segment */
175 
176  memset (e, 0, sizeof (*e));
178 
180 }
181 
182 void
183 vlib_stats_pop_heap (void *cm_arg, void *oldheap, u32 cindex,
185 {
188  stat_segment_shared_header_t *shared_header = sm->shared_header;
189  char *stat_segment_name;
191 
192  /* Not all counters have names / hash-table entries */
193  if (!cm->name && !cm->stat_segment_name)
194  {
195  clib_mem_set_heap (oldheap);
196  return;
197  }
198 
199  ASSERT (shared_header);
200 
202 
203  /* Lookup hash-table is on the main heap */
204  stat_segment_name =
205  cm->stat_segment_name ? cm->stat_segment_name : cm->name;
206 
207  clib_mem_set_heap (oldheap); /* Exit stats segment */
208  u32 vector_index = lookup_hash_index ((u8 *) stat_segment_name);
209  /* Back to stats segment */
210  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */
211 
212 
213  /* Update the vector */
214  if (vector_index == STAT_SEGMENT_INDEX_INVALID)
215  { /* New */
216  strncpy (e.name, stat_segment_name, 128 - 1);
217  e.type = type;
218  vector_index = vlib_stats_create_counter (&e, oldheap);
219  }
220 
221  stat_segment_directory_entry_t *ep = &sm->directory_vector[vector_index];
222  ep->data = cm->counters;
223 
224  /* Reset the client hash table pointer, since it WILL change! */
225  shared_header->directory_vector = sm->directory_vector;
226 
228  clib_mem_set_heap (oldheap);
229 }
230 
231 u8 *
232 format_vlib_stats_symlink (u8 *s, va_list *args)
233 {
234  char *input = va_arg (*args, char *);
235  char *modified_input = vec_dup (input);
236  int i;
237  u8 *result;
238 
239  for (i = 0; i < strlen (modified_input); i++)
240  if (modified_input[i] == '/')
241  modified_input[i] = '_';
242 
243  result = format (s, "%s", modified_input);
244  vec_free (modified_input);
245  return result;
246 }
247 
248 void
249 vlib_stats_register_symlink (void *oldheap, u8 *name, u32 index1, u32 index2,
250  u8 lock)
251 {
253  stat_segment_shared_header_t *shared_header = sm->shared_header;
255 
256  ASSERT (shared_header);
257 
258  if (lock)
260  clib_mem_set_heap (oldheap); /* Exit stats segment */
261  u32 vector_index = lookup_hash_index (name);
262  /* Back to stats segment */
263  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */
264 
265  if (vector_index == STAT_SEGMENT_INDEX_INVALID)
266  {
267  memcpy (e.name, name, vec_len (name));
268  e.name[vec_len (name)] = '\0';
270  e.index1 = index1;
271  e.index2 = index2;
272  vector_index = vlib_stats_create_counter (&e, oldheap);
273 
274  /* Warn clients to refresh any pointers they might be holding */
275  shared_header->directory_vector = sm->directory_vector;
276  }
277 
278  if (lock)
280 }
281 
282 void
283 vlib_stats_rename_symlink (void *oldheap, u64 index, u8 *new_name)
284 {
287 
288  ASSERT (clib_mem_get_heap () == sm->heap);
289 
290  if (index > vec_len (sm->directory_vector))
291  return;
292 
293  e = &sm->directory_vector[index];
294 
295  clib_mem_set_heap (oldheap);
297  clib_mem_set_heap (sm->heap);
298 
299  strncpy (e->name, (char *) new_name, 128 - 1);
300  clib_mem_set_heap (oldheap);
302  clib_mem_set_heap (sm->heap);
303 }
304 
305 void
306 vlib_stats_register_error_index (void *oldheap, u8 * name, u64 * em_vec,
307  u64 index)
308 {
310  stat_segment_shared_header_t *shared_header = sm->shared_header;
312 
313  ASSERT (shared_header);
314 
316  clib_mem_set_heap (oldheap); /* Exit stats segment */
317  u32 vector_index = lookup_hash_index (name);
318  /* Back to stats segment */
319  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */
320 
321  if (vector_index == STAT_SEGMENT_INDEX_INVALID)
322  {
323  memcpy (e.name, name, vec_len (name));
324  e.name[vec_len (name)] = '\0';
326  e.index = index;
327  vector_index = vlib_stats_create_counter (&e, oldheap);
328 
329  /* Warn clients to refresh any pointers they might be holding */
330  shared_header->directory_vector = sm->directory_vector;
331  }
332 
334 }
335 
336 /*
337  * Creates a two dimensional vector with the maximum valid index specified in
338  * both dimensions as arguments.
339  * Must be called on the stat segment heap.
340  */
341 static void
343  u32 max2)
344 {
345  counter_t **counters = ep->data;
346  int i;
348  for (i = 0; i <= max1; i++)
349  vec_validate_aligned (counters[i], max2, CLIB_CACHE_LINE_BYTES);
350 
351  ep->data = counters;
352 }
353 
354 static void
356 {
358  ASSERT (tm->n_vlib_mains > 0);
360 }
361 
362 void
363 vlib_stats_pop_heap2 (u64 * error_vector, u32 thread_index, void *oldheap,
364  int lock)
365 {
367  stat_segment_shared_header_t *shared_header = sm->shared_header;
368 
369  ASSERT (shared_header);
370 
371  if (lock)
373 
374  /* Reset the client hash table pointer, since it WILL change! */
376  sm->error_vector[thread_index] = error_vector;
377 
378  shared_header->error_vector = sm->error_vector;
379  shared_header->directory_vector = sm->directory_vector;
380 
381  if (lock)
383  clib_mem_set_heap (oldheap);
384 }
385 
386 /*
387  * Create a new entry and add name to directory hash.
388  * Returns ~0 if name exists.
389  * Called from main heap.
390  * The name is either C-string or nul-terminated vector
391  */
392 u32
394 {
396  stat_segment_shared_header_t *shared_header = sm->shared_header;
397  void *oldheap;
399 
400  ASSERT (shared_header);
401 
402  u32 vector_index = lookup_hash_index (name);
403  if (vector_index != STAT_SEGMENT_INDEX_INVALID) /* Already registered */
404  return ~0;
405 
406  memset (&e, 0, sizeof (e));
407  e.type = t;
408  strcpy_s (e.name, sizeof (e.name), (char *) name);
409 
410  oldheap = vlib_stats_push_heap (NULL);
412  vector_index = vlib_stats_create_counter (&e, oldheap);
413 
414  shared_header->directory_vector = sm->directory_vector;
415 
417  clib_mem_set_heap (oldheap);
418 
419  return vector_index;
420 }
421 
422 clib_error_t *
424 {
426  stat_segment_shared_header_t *shared_header;
427  void *oldheap;
428  uword memory_size, sys_page_sz;
429  int mfd;
430  char *mem_name = "stat segment";
431  void *heap, *memaddr;
432 
433  memory_size = sm->memory_size;
434  if (memory_size == 0)
436 
439 
440  mfd = clib_mem_vm_create_fd (sm->log2_page_sz, mem_name);
441 
442  if (mfd == -1)
443  return clib_error_return (0, "stat segment memory fd failure: %U",
445  /* Set size */
446  if ((ftruncate (mfd, memory_size)) == -1)
447  {
448  close (mfd);
449  return clib_error_return (0, "stat segment ftruncate failure");
450  }
451 
452  memaddr = clib_mem_vm_map_shared (0, memory_size, mfd, 0, mem_name);
453 
454  if (memaddr == CLIB_MEM_VM_MAP_FAILED)
455  return clib_error_return (0, "stat segment mmap failure");
456 
457  sys_page_sz = clib_mem_get_page_size ();
458 
459  heap =
460  clib_mem_create_heap (((u8 *) memaddr) + sys_page_sz,
461  memory_size - sys_page_sz, 1 /* locked */, mem_name);
462  sm->heap = heap;
463  sm->memfd = mfd;
464 
466  sm->shared_header = shared_header = memaddr;
467 
468  shared_header->version = STAT_SEGMENT_VERSION;
469  shared_header->base = memaddr;
470 
473 
474  oldheap = clib_mem_set_heap (sm->heap);
475 
476  /* Set up the name to counter-vector hash table */
477  sm->directory_vector = 0;
478 
479  shared_header->epoch = 1;
480 
481  /* Scalar stats and node counters */
483 #define _(E,t,n,p) \
484  strcpy(sm->directory_vector[STAT_COUNTER_##E].name, #p "/" #n); \
485  sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
487 #undef _
488  /* Save the vector in the shared segment, for clients */
489  shared_header->directory_vector = sm->directory_vector;
490 
491  clib_mem_set_heap (oldheap);
492 
494 
495  return 0;
496 }
497 
498 static int
499 name_sort_cmp (void *a1, void *a2)
500 {
503 
504  return strcmp ((char *) n1->name, (char *) n2->name);
505 }
506 
507 static u8 *
508 format_stat_dir_entry (u8 * s, va_list * args)
509 {
511  va_arg (*args, stat_segment_directory_entry_t *);
512  char *type_name;
513  char *format_string;
514 
515  format_string = "%-74s %-10s %10lld";
516 
517  switch (ep->type)
518  {
520  type_name = "ScalarPtr";
521  break;
522 
525  type_name = "CMainPtr";
526  break;
527 
529  type_name = "ErrIndex";
530  break;
531 
533  type_name = "NameVector";
534  break;
535 
536  case STAT_DIR_TYPE_EMPTY:
537  type_name = "empty";
538  break;
539 
541  type_name = "Symlink";
542  break;
543 
544  default:
545  type_name = "illegal!";
546  break;
547  }
548 
549  return format (s, format_string, ep->name, type_name, 0);
550 }
551 
552 static clib_error_t *
554  unformat_input_t * input,
555  vlib_cli_command_t * cmd)
556 {
559  int i;
560 
561  int verbose = 0;
562 
563  if (unformat (input, "verbose"))
564  verbose = 1;
565 
566  /* Lock even as reader, as this command doesn't handle epoch changes */
568  show_data = vec_dup (sm->directory_vector);
570 
572 
573  vlib_cli_output (vm, "%-74s %10s %10s", "Name", "Type", "Value");
574 
575  for (i = 0; i < vec_len (show_data); i++)
576  {
578 
579  if (ep->type == STAT_DIR_TYPE_EMPTY)
580  continue;
581 
583  vec_elt_at_index (show_data, i));
584  }
585 
586  if (verbose)
587  {
588  ASSERT (sm->heap);
590  0 /* verbose */ );
591  }
592 
593  return 0;
594 }
595 
596 /* *INDENT-OFF* */
598 {
599  .path = "show statistics segment",
600  .short_help = "show statistics segment [verbose]",
601  .function = show_stat_segment_command_fn,
602 };
603 /* *INDENT-ON* */
604 
605 /*
606  * Node performance counters:
607  * total_calls [threads][node-index]
608  * total_vectors
609  * total_calls
610  * total suspends
611  */
612 
613 static inline void
615 {
616  vlib_main_t **stat_vms = 0;
617  vlib_node_t ***node_dups = 0;
618  int i, j;
619  static u32 no_max_nodes = 0;
620 
621  vlib_node_get_nodes (0 /* vm, for barrier sync */,
622  (u32) ~0 /* all threads */, 1 /* include stats */,
623  0 /* barrier sync */, &node_dups, &stat_vms);
624 
625  u32 l = vec_len (node_dups[0]);
626  u8 *symlink_name = 0;
627 
628  /*
629  * Extend performance nodes if necessary
630  */
631  if (l > no_max_nodes)
632  {
633  void *oldheap = clib_mem_set_heap (sm->heap);
635 
644 
645  vec_validate (sm->nodes, l - 1);
648  ep->data = sm->nodes;
649 
650  /* Update names dictionary */
651  vlib_node_t **nodes = node_dups[0];
652  int i;
653  for (i = 0; i < vec_len (nodes); i++)
654  {
655  vlib_node_t *n = nodes[i];
656  u8 *s = 0;
657  s = format (s, "%v%c", n->name, 0);
658  if (sm->nodes[n->index])
659  vec_free (sm->nodes[n->index]);
660  sm->nodes[n->index] = s;
661 
662 #define _(E, t, name, p) \
663  vec_reset_length (symlink_name); \
664  symlink_name = format (symlink_name, "/nodes/%U/" #name "%c", \
665  format_vlib_stats_symlink, s, 0); \
666  vlib_stats_register_symlink (oldheap, symlink_name, STAT_COUNTER_##E, \
667  n->index, 0 /* don't lock */);
669 #undef _
670  }
671  vec_free (symlink_name);
673  clib_mem_set_heap (oldheap);
674  no_max_nodes = l;
675  }
676 
677  for (j = 0; j < vec_len (node_dups); j++)
678  {
679  vlib_node_t **nodes = node_dups[j];
680 
681  for (i = 0; i < vec_len (nodes); i++)
682  {
683  counter_t **counters;
684  counter_t *c;
685  vlib_node_t *n = nodes[i];
686 
687  if (j == 0)
688  {
689  if (strncmp ((char *) sm->nodes[n->index], (char *) n->name,
690  strlen ((char *) sm->nodes[n->index])))
691  {
692  u8 *s = 0;
693  u32 vector_index;
694  u8 *symlink_new_name = 0;
695  void *oldheap = clib_mem_set_heap (sm->heap);
697  s = format (s, "%v%c", n->name, 0);
698 #define _(E, t, name, p) \
699  vec_reset_length (symlink_name); \
700  symlink_name = format (symlink_name, "/nodes/%U/" #name "%c", \
701  format_vlib_stats_symlink, sm->nodes[n->index], 0); \
702  clib_mem_set_heap (oldheap); /* Exit stats segment */ \
703  vector_index = lookup_hash_index ((u8 *) symlink_name); \
704  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */ \
705  vec_reset_length (symlink_new_name); \
706  symlink_new_name = format (symlink_new_name, "/nodes/%U/" #name "%c", \
707  format_vlib_stats_symlink, s, 0); \
708  vlib_stats_rename_symlink (oldheap, vector_index, symlink_new_name);
710 #undef _
711  vec_free (symlink_name);
712  vec_free (symlink_new_name);
713  vec_free (sm->nodes[n->index]);
714  sm->nodes[n->index] = s;
716  clib_mem_set_heap (oldheap);
717  }
718  }
719 
721  c = counters[j];
723 
725  c = counters[j];
727 
729  c = counters[j];
731 
733  c = counters[j];
735  }
736  vec_free (node_dups[j]);
737  }
738  vec_free (node_dups);
739  vec_free (stat_vms);
740 }
741 
742 static void
744 {
745  u64 input_packets;
746  f64 dt, now;
747  static int num_worker_threads_set;
748 
749  /*
750  * Set once at the beginning of time.
751  * Can't do this from the init routine, which happens before
752  * start_workers sets up vlib_mains...
753  */
754  if (PREDICT_FALSE (num_worker_threads_set == 0))
755  {
757  ASSERT (tm->n_vlib_mains > 0);
760  tm->n_vlib_mains - 1;
761  num_worker_threads_set = 1;
762  }
763 
764  /*
765  * Compute the aggregate input rate
766  */
767  now = vlib_time_now (vm);
769  input_packets = vnet_get_aggregate_rx_packets ();
771  (f64) (input_packets - sm->last_input_packets) / dt;
773  sm->last_input_packets = input_packets;
776 
777  if (sm->node_counters_enabled)
779 
780  /* *INDENT-OFF* */
782  pool_foreach (g, sm->gauges)
783  {
785  }
786  /* *INDENT-ON* */
787 
788  /* Heartbeat, so clients detect we're still here */
790 }
791 
792 /*
793  * Accept connection on the socket and exchange the fd for the shared
794  * memory segment.
795  */
796 static clib_error_t *
798 {
800  clib_error_t *err;
801  clib_socket_t client = { 0 };
802 
803  err = clib_socket_accept (sm->socket, &client);
804  if (err)
805  {
806  clib_error_report (err);
807  return err;
808  }
809 
810  /* Send the fd across and close */
811  err = clib_socket_sendmsg (&client, 0, 0, &sm->memfd, 1);
812  if (err)
813  clib_error_report (err);
814  clib_socket_close (&client);
815 
816  return 0;
817 }
818 
819 static clib_error_t *
821 {
825 
826  memset (s, 0, sizeof (clib_socket_t));
827  s->config = (char *) sm->socket_name;
830 
831  if ((error = clib_socket_init (s)))
832  return error;
833 
834  clib_file_t template = { 0 };
836  template.file_descriptor = s->fd;
837  template.description = format (0, "stats segment listener %s", s->config);
838  clib_file_add (&file_main, &template);
839 
840  sm->socket = s;
841 
842  return 0;
843 }
844 
845 static clib_error_t *
847 {
848  /*
849  * cleanup the listener socket on exit.
850  */
852  unlink ((char *) sm->socket_name);
853  return 0;
854 }
855 
857 
858 /* Overrides weak reference in vlib:node_cli.c */
859 f64
861 {
863 }
864 
865 static uword
867  vlib_frame_t * f)
868 {
870 
871  while (1)
872  {
875  }
876  return 0; /* or not */
877 }
878 
879 /*
880  * Add a data provider (via callback) for a given stats entry.
881  * TODO: Add support for per-provider interval.
882  */
883 void
885  u32 caller_index, u32 interval)
886 {
889 
890  pool_get (sm->gauges, gauge);
891  gauge->fn = update_fn;
892  gauge->caller_index = caller_index;
893  gauge->directory_index = vector_index;
894 
895  return;
896 }
897 
898 /*
899  * Create an scalar entry with a data provider.
900  * Deprecated, replace with stat_segment_new_entry + stat_segment_pool_add
901  */
902 clib_error_t *
904  u32 caller_index)
905 {
908 
910  if (vector_index == ~0) /* Already registered */
911  return clib_error_return (0, "%v is already registered", name);
912 
913  pool_get (sm->gauges, gauge);
914  gauge->fn = update_fn;
915  gauge->caller_index = caller_index;
916  gauge->directory_index = vector_index;
917 
918  return NULL;
919 }
920 
921 clib_error_t *
923 {
924  ASSERT (vlib_get_thread_index () == 0);
925 
927  if (vector_index == ~0) /* Already registered */
928  return clib_error_return (0, "%v is already registered", name);
929  *index = vector_index;
930  return 0;
931 }
932 
933 clib_error_t *
935 {
937  stat_segment_shared_header_t *shared_header = sm->shared_header;
939  void *oldheap;
940 
941  ASSERT (shared_header);
942 
943  if (index > vec_len (sm->directory_vector))
944  return clib_error_return (0, "%u index does not exist", index);
945 
946  e = &sm->directory_vector[index];
948  return clib_error_return (0, "%u index cannot be deleted", index);
949 
950  oldheap = vlib_stats_push_heap (NULL);
952 
953  vlib_stats_delete_counter (index, oldheap);
954 
956  clib_mem_set_heap (oldheap);
957 
958  return 0;
959 }
960 
961 void
963 {
965 
968 }
969 
970 static clib_error_t *
972 {
974  sm->update_interval = 10.0;
975 
977  {
978  if (unformat (input, "socket-name %s", &sm->socket_name))
979  ;
980  /* DEPRECATE: default (does nothing) */
981  else if (unformat (input, "default"))
982  ;
983  else if (unformat (input, "size %U",
985  ;
986  else if (unformat (input, "page-size %U",
988  ;
989  else if (unformat (input, "per-node-counters on"))
990  sm->node_counters_enabled = 1;
991  else if (unformat (input, "per-node-counters off"))
992  sm->node_counters_enabled = 0;
993  else if (unformat (input, "update-interval %f", &sm->update_interval))
994  ;
995  else
996  return clib_error_return (0, "unknown input `%U'",
997  format_unformat_error, input);
998  }
999 
1000  /*
1001  * NULL-terminate socket name string
1002  * clib_socket_init()->socket_config() use C str*
1003  */
1004  if (vec_len (sm->socket_name))
1006 
1007  return 0;
1008 }
1009 
1011 
1012 static clib_error_t *
1014 {
1017  vnet_sw_interface_t *si_sup =
1019  vnet_hw_interface_t *hi_sup;
1020  u8 *s = 0;
1021  u8 *symlink_name = 0;
1022  u32 vector_index;
1023 
1024  void *oldheap = vlib_stats_push_heap (sm->interfaces);
1026 
1028 
1030  hi_sup = vnet_get_hw_interface (vnm, si_sup->hw_if_index);
1031 
1032  s = format (s, "%v", hi_sup->name);
1034  s = format (s, ".%d", si->sub.id);
1035  s = format (s, "%c", 0);
1036 
1037  if (is_add)
1038  {
1039  sm->interfaces[sw_if_index] = s;
1040 #define _(E, n, p) \
1041  clib_mem_set_heap (oldheap); /* Exit stats segment */ \
1042  vector_index = lookup_hash_index ((u8 *) "/" #p "/" #n); \
1043  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */ \
1044  vec_reset_length (symlink_name); \
1045  symlink_name = format (symlink_name, "/interfaces/%U/" #n "%c", \
1046  format_vlib_stats_symlink, s, 0); \
1047  vlib_stats_register_symlink (oldheap, symlink_name, vector_index, \
1048  sw_if_index, 0 /* don't lock */);
1051 #undef _
1052 
1053  vec_free (symlink_name);
1054  }
1055  else
1056  {
1058  sm->interfaces[sw_if_index] = 0;
1059 #define _(E, n, p) \
1060  vec_reset_length (symlink_name); \
1061  symlink_name = format (symlink_name, "/interfaces/%U/" #n "%c", \
1062  format_vlib_stats_symlink, s, 0); \
1063  clib_mem_set_heap (oldheap); /* Exit stats segment */ \
1064  vector_index = lookup_hash_index ((u8 *) symlink_name); \
1065  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */ \
1066  vlib_stats_delete_counter (vector_index, oldheap);
1069 #undef _
1070 
1071  vec_free (symlink_name);
1072  }
1073 
1076  ep->data = sm->interfaces;
1077 
1079  clib_mem_set_heap (oldheap);
1080 
1081  return 0;
1082 }
1083 
1085 
1087 {
1088 .function = stat_segment_collector_process,
1089 .name = "statseg-collector-process",
1090 .type = VLIB_NODE_TYPE_PROCESS,
1091 };
1092 
1093 static clib_error_t *
1095 {
1097 
1098  /* set default socket file name when statseg config stanza is empty. */
1099  if (!vec_len (sm->socket_name))
1100  sm->socket_name = format (0, "%s/%s%c", vlib_unix_get_runtime_dir (),
1102  return stats_segment_socket_init ();
1103 }
1104 
1106  .runs_after = VLIB_INITS ("unix_input_init"),
1107 };
1108 
1109 /*
1110  * fd.io coding-style-patch-verification: ON
1111  *
1112  * Local Variables:
1113  * eval: (c-set-style "gnu")
1114  * End:
1115  */
stat_segment_register_state_counter
clib_error_t * stat_segment_register_state_counter(u8 *name, u32 *index)
Definition: stat_segment.c:922
vlib.h
vlib_node_stats_t::calls
u64 calls
Definition: node.h:226
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
vlib_node_get_nodes
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:603
show_stat_segment_command_fn
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:553
CLIB_SOCKET_F_IS_SERVER
#define CLIB_SOCKET_F_IS_SERVER
Definition: socket.h:58
stat_segment_main_t::heap
void * heap
Definition: stat_segment.h:95
STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED
@ STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED
Definition: stat_segment_shared.h:24
stat_segment_shared_header_t::base
void * base
Definition: stat_segment_shared.h:53
vlib_stats_push_heap
void * vlib_stats_push_heap(void *old)
Definition: stat_segment.c:50
STAT_COUNTERS
@ STAT_COUNTERS
Definition: stat_segment.h:36
file_main
clib_file_main_t file_main
Definition: main.c:63
foreach_stat_segment_counter_name
#define foreach_stat_segment_counter_name
Definition: stat_segment.h:46
stat_segment_shared_header_t::error_vector
volatile uint64_t ** error_vector
Definition: stat_segment_shared.h:57
stat_segment_gauges_pool_t::directory_index
u32 directory_index
Definition: stat_segment.h:68
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:492
vnet_sw_interface_t::type
vnet_sw_interface_type_t type
Definition: interface.h:870
vnet_sw_interface_t
Definition: interface.h:868
stat_segment_directory_entry_t::data
void * data
Definition: stat_segment_shared.h:42
clib_mem_get_heap
static clib_mem_heap_t * clib_mem_get_heap(void)
Definition: mem.h:359
stat_segment_main_t::memory_size
ssize_t memory_size
Definition: stat_segment.h:91
stat_segment_main_t::shared_header
stat_segment_shared_header_t * shared_header
Definition: stat_segment.h:96
stat_segment_poll_add
void stat_segment_poll_add(u32 vector_index, stat_segment_update_fn update_fn, u32 caller_index, u32 interval)
Definition: stat_segment.c:884
stat_segment_update_fn
void(* stat_segment_update_fn)(stat_segment_directory_entry_t *e, u32 i)
Definition: stat_segment.h:65
f
vlib_frame_t * f
Definition: interface_output.c:1080
vlib_stats_get_next_vector_index
static u32 vlib_stats_get_next_vector_index()
Definition: stat_segment.c:90
name
string name[64]
Definition: fib.api:25
stat_segment_main_t::directory_vector
stat_segment_directory_entry_t * directory_vector
Definition: stat_segment.h:80
stat_segment_gauges_pool_t
Definition: stat_segment.h:67
vlib_node_main_t::time_last_runtime_stats_clear
f64 time_last_runtime_stats_clear
Definition: node.h:730
clib_mem_vm_map_shared
__clib_export void * clib_mem_vm_map_shared(void *base, uword size, int fd, uword offset, char *fmt,...)
Definition: mem.c:59
STAT_COUNTER_INTERFACE_NAMES
@ STAT_COUNTER_INTERFACE_NAMES
Definition: stat_segment.h:34
STAT_DIR_TYPE_NAME_VECTOR
@ STAT_DIR_TYPE_NAME_VECTOR
Definition: stat_segment_shared.h:26
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
format_clib_mem_heap
u8 * format_clib_mem_heap(u8 *s, va_list *va)
Definition: mem_dlmalloc.c:422
stat_segment_main_t::gauges
stat_segment_gauges_pool_t * gauges
Definition: stat_segment.h:76
vlib_cli_command_t::path
char * path
Definition: cli.h:96
clib_file::read_function
clib_file_function_t * read_function
Definition: file.h:67
vlib_stats_register_symlink
void vlib_stats_register_symlink(void *oldheap, u8 *name, u32 index1, u32 index2, u8 lock)
Definition: stat_segment.c:249
STAT_COUNTER_INPUT_RATE
@ STAT_COUNTER_INPUT_RATE
Definition: stat_segment.h:26
vlib_stats_pop_heap2
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap, int lock)
Definition: stat_segment.c:363
hash_get_pair
#define hash_get_pair(h, key)
Definition: hash.h:252
vlib_main_t::node_main
vlib_node_main_t node_main
Definition: main.h:171
STAT_COUNTER_NODE_SUSPENDS
@ STAT_COUNTER_NODE_SUSPENDS
Definition: stat_segment.h:33
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
hash_create_string
#define hash_create_string(elts, value_bytes)
Definition: hash.h:689
vnet_get_sw_interface
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:58
STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE
@ STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE
Definition: stat_segment_shared.h:23
stat_directory_type_t
stat_directory_type_t
Definition: stat_segment_shared.h:19
lookup_hash_index
static u32 lookup_hash_index(u8 *name)
Definition: stat_segment.c:60
stat_segment_directory_entry_t::index1
uint32_t index1
Definition: stat_segment_shared.h:37
stat_segment_shared_header_t::version
uint64_t version
Definition: stat_segment_shared.h:52
stat_segment_main_t::last
void * last
Definition: stat_segment.h:94
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
unformat_input_t
struct _unformat_input_t unformat_input_t
stat_segment_directory_entry_t::index
uint64_t index
Definition: stat_segment_shared.h:40
stat_segment_main_t
Definition: stat_segment.h:73
CLIB_MEM_VM_MAP_FAILED
#define CLIB_MEM_VM_MAP_FAILED
Definition: mem.h:54
vlib_frame_t
Definition: node.h:372
STAT_SEGMENT_SOCKET_FILENAME
#define STAT_SEGMENT_SOCKET_FILENAME
Definition: stat_client.h:33
memory_size
u64 memory_size
Definition: vhost_user.h:124
error
Definition: cJSON.c:88
vlib_node_stats_t::clocks
u64 clocks
Definition: node.h:226
vlib_stat_segment_unlock
void vlib_stat_segment_unlock(void)
Definition: stat_segment.c:38
VLIB_EARLY_CONFIG_FUNCTION
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:220
STAT_DIR_TYPE_EMPTY
@ STAT_DIR_TYPE_EMPTY
Definition: stat_segment_shared.h:27
format_clib_error
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
STAT_SEGMENT_DEFAULT_SIZE
#define STAT_SEGMENT_DEFAULT_SIZE
Definition: stat_segment.h:58
clib_mem_vm_create_fd
__clib_export int clib_mem_vm_create_fd(clib_mem_page_sz_t log2_page_size, char *fmt,...)
Definition: mem.c:263
STAT_COUNTER_NODE_NAMES
@ STAT_COUNTER_NODE_NAMES
Definition: stat_segment.h:35
stats_segment_socket_exit
static clib_error_t * stats_segment_socket_exit(vlib_main_t *vm)
Definition: stat_segment.c:846
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
vnet_sw_interface_t::sw_if_index
u32 sw_if_index
Definition: interface.h:875
vlib_stats_create_counter
static u32 vlib_stats_create_counter(stat_segment_directory_entry_t *e, void *oldheap)
Definition: stat_segment.c:109
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:283
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vlib_stats_pop_heap
void vlib_stats_pop_heap(void *cm_arg, void *oldheap, u32 cindex, stat_directory_type_t type)
Definition: stat_segment.c:183
unformat_memory_size
unformat_function_t unformat_memory_size
Definition: format.h:288
clib_mem_create_heap
clib_mem_heap_t * clib_mem_create_heap(void *base, uword size, int is_locked, char *fmt,...)
Definition: mem_dlmalloc.c:536
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_node_t::index
u32 index
Definition: node.h:269
vnet_sw_interface_t::sub
vnet_sub_interface_t sub
Definition: interface.h:892
stat_segment_gauges_pool_t::caller_index
u32 caller_index
Definition: stat_segment.h:70
vlib_node_stats_t::suspends
u64 suspends
Definition: node.h:226
hash_pair_t::value
uword value[0]
Definition: hash.h:165
stat_segment_register_gauge
clib_error_t * stat_segment_register_gauge(u8 *name, stat_segment_update_fn update_fn, u32 caller_index)
Definition: stat_segment.c:903
vec_dup
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:444
stat_segment_main_t::last_input_packets
u64 last_input_packets
Definition: stat_segment.h:99
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
clib_socket_close
static clib_error_t * clib_socket_close(clib_socket_t *sock)
Definition: socket.h:175
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
clib_file
Definition: file.h:51
STAT_COUNTER_NODE_VECTORS
@ STAT_COUNTER_NODE_VECTORS
Definition: stat_segment.h:31
create_hash_index
static void create_hash_index(u8 *name, u32 index)
Definition: stat_segment.c:79
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
stats_segment_socket_init
static clib_error_t * stats_segment_socket_init(void)
Definition: stat_segment.c:820
vlib_get_thread_index
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:208
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vlib_config_function_runtime_t
Definition: init.h:68
stat_segment_directory_entry_t::value
uint64_t value
Definition: stat_segment_shared.h:41
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
clib_spinlock_lock
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:82
counter_t
uint64_t counter_t
64bit counters
Definition: counter_types.h:22
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
stat_segment_shared_header_t::directory_vector
volatile stat_segment_directory_entry_t * directory_vector
Definition: stat_segment_shared.h:56
stat_provider_register_vector_rate
void stat_provider_register_vector_rate(u32 num_workers)
Definition: stat_segment_provider.c:173
clib_spinlock_s
Definition: lock.h:51
uword
u64 uword
Definition: types.h:112
stat_segment_main_t::memfd
int memfd
Definition: stat_segment.h:97
STAT_COUNTER_LAST_UPDATE
@ STAT_COUNTER_LAST_UPDATE
Definition: stat_segment.h:27
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
vlib_unix_get_runtime_dir
static char * vlib_unix_get_runtime_dir(void)
Definition: unix.h:151
clib_socket_sendmsg
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:151
format_stat_dir_entry
static u8 * format_stat_dir_entry(u8 *s, va_list *args)
Definition: stat_segment.c:508
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
vlib_node_stats_t::vectors
u64 vectors
Definition: node.h:226
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:591
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
show_stat_segment_command
static vlib_cli_command_t show_stat_segment_command
(constructor) VLIB_CLI_COMMAND (show_stat_segment_command)
Definition: stat_segment.c:597
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
stat_segment_directory_entry_t::name
char name[128]
Definition: stat_segment_shared.h:44
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
STAT_COUNTER_NODE_CALLS
@ STAT_COUNTER_NODE_CALLS
Definition: stat_segment.h:32
statseg_init
static clib_error_t * statseg_init(vlib_main_t *vm)
Definition: stat_segment.c:1094
vlib_get_stat_segment_update_rate
f64 vlib_get_stat_segment_update_rate(void)
Definition: stat_segment.c:860
vlib_stat_segment_lock
void vlib_stat_segment_lock(void)
Definition: stat_segment.c:30
vlib_stats_delete_counter
static void vlib_stats_delete_counter(u32 index, void *oldheap)
Definition: stat_segment.c:128
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
interval
u16 interval
Definition: vrrp.api:34
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
strcpy_s
__clib_export errno_t strcpy_s(char *__restrict__ dest, rsize_t dmax, const char *__restrict__ src)
copy src string to dest string
Definition: string.c:272
stat_segment.h
format_vlib_stats_symlink
u8 * format_vlib_stats_symlink(u8 *s, va_list *args)
Definition: stat_segment.c:232
stat_segment_shared_header_t
Definition: stat_segment_shared.h:50
STAT_DIR_TYPE_SYMLINK
@ STAT_DIR_TYPE_SYMLINK
Definition: stat_segment_shared.h:28
stat_segment_main_t::node_counters_enabled
u8 node_counters_enabled
Definition: stat_segment.h:93
stat_segment_collector_process
static uword stat_segment_collector_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: stat_segment.c:866
STAT_COUNTER_NUM_WORKER_THREADS
@ STAT_COUNTER_NUM_WORKER_THREADS
Definition: stat_segment.h:25
stat_validate_counter_vector2
static void stat_validate_counter_vector2(stat_segment_directory_entry_t *ep, u32 max1, u32 max2)
Definition: stat_segment.c:342
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
stat_segment_directory_entry_t
Definition: stat_segment_shared.h:31
index
u32 index
Definition: flow_types.api:221
stat_segment_shared_header_t::in_progress
volatile uint64_t in_progress
Definition: stat_segment_shared.h:55
STAT_COUNTER_LAST_STATS_CLEAR
@ STAT_COUNTER_LAST_STATS_CLEAR
Definition: stat_segment.h:28
STAT_COUNTER_HEARTBEAT
@ STAT_COUNTER_HEARTBEAT
Definition: stat_segment.h:29
u64
unsigned long u64
Definition: types.h:89
VNET_SW_INTERFACE_ADD_DEL_FUNCTION
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(statseg_sw_interface_add_del)
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
stat_segment_main_t::socket
clib_socket_t * socket
Definition: stat_segment.h:89
clib_socket_init
__clib_export clib_error_t * clib_socket_init(clib_socket_t *s)
Definition: socket.c:390
stat_segment_gauges_pool_t::fn
stat_segment_update_fn fn
Definition: stat_segment.h:69
vlib_process_suspend
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:486
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vnet_sub_interface_t::id
u32 id
Definition: interface.h:777
STAT_DIR_TYPE_SCALAR_INDEX
@ STAT_DIR_TYPE_SCALAR_INDEX
Definition: stat_segment_shared.h:22
CLIB_MEM_PAGE_SZ_DEFAULT
@ CLIB_MEM_PAGE_SZ_DEFAULT
Definition: mem.h:60
vlib_thread_main_t
Definition: threads.h:264
stat_segment_main_t::nodes
u8 ** nodes
Definition: stat_segment.h:83
stat_segment_directory_entry_t::index2
uint32_t index2
Definition: stat_segment_shared.h:38
vlib_node_t::stats_total
vlib_node_stats_t stats_total
Definition: node.h:259
CLIB_SOCKET_F_ALLOW_GROUP_WRITE
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
Definition: socket.h:62
stat_segment_deregister_state_counter
clib_error_t * stat_segment_deregister_state_counter(u32 index)
Definition: stat_segment.c:934
STAT_SEGMENT_VERSION
#define STAT_SEGMENT_VERSION
Definition: stat_segment.h:61
si
vnet_sw_interface_t * si
Definition: interface_output.c:398
foreach_simple_interface_counter_name
#define foreach_simple_interface_counter_name
Definition: interface.h:935
clib_mem_get_page_size
static_always_inline uword clib_mem_get_page_size(void)
Definition: mem.h:468
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
clib_spinlock_unlock
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:121
clib_file_add
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
value
u8 value
Definition: qos.api:54
stat_segment_main_t::update_interval
f64 update_interval
Definition: stat_segment.h:86
stat_segment_main_t::directory_vector_by_name
uword * directory_vector_by_name
Definition: stat_segment.h:79
stat_segment_collector
static vlib_node_registration_t stat_segment_collector
(constructor) VLIB_REGISTER_NODE (stat_segment_collector)
Definition: stat_segment.c:1086
now
f64 now
Definition: nat44_ei_out2in.c:710
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
stat_segment_main_t::socket_name
u8 * socket_name
Definition: stat_segment.h:90
vlib_main_t
Definition: main.h:102
foreach_stat_segment_node_counter_name
#define foreach_stat_segment_node_counter_name
Definition: stat_segment.h:40
vlib_node_t::stats_last_clear
vlib_node_stats_t stats_last_clear
Definition: node.h:263
vlib_node_t
Definition: node.h:247
statseg_sw_interface_add_del
static clib_error_t * statseg_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
Definition: stat_segment.c:1013
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
vlib_map_stat_segment_init
clib_error_t * vlib_map_stat_segment_init(void)
Definition: stat_segment.c:423
VLIB_INITS
#define VLIB_INITS(...)
Definition: init.h:352
STAT_SEGMENT_INDEX_INVALID
#define STAT_SEGMENT_INDEX_INVALID
Definition: stat_segment.h:63
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
unix.h
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:399
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vec_terminate_c_string
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
Definition: vec.h:1132
CLIB_SOCKET_F_PASSCRED
#define CLIB_SOCKET_F_PASSCRED
Definition: socket.h:64
unformat_log2_page_size
unformat_function_t unformat_log2_page_size
Definition: format.h:294
stat_segment_main_t::log2_page_sz
clib_mem_page_sz_t log2_page_sz
Definition: stat_segment.h:92
foreach_combined_interface_counter_name
#define foreach_combined_interface_counter_name
Definition: interface.h:946
devices.h
update_node_counters
static void update_node_counters(stat_segment_main_t *sm)
Definition: stat_segment.c:614
vnet_sw_interface_t::hw_if_index
u32 hw_if_index
Definition: interface.h:886
stat_client.h
vnet_hw_interface_t::name
u8 * name
Definition: interface.h:678
do_stat_segment_updates
static void do_stat_segment_updates(vlib_main_t *vm, stat_segment_main_t *sm)
Definition: stat_segment.c:743
mem.h
stat_segment_main_t::interfaces
u8 ** interfaces
Definition: stat_segment.h:82
vlib_stats_rename_symlink
void vlib_stats_rename_symlink(void *oldheap, u64 index, u8 *new_name)
Definition: stat_segment.c:283
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
VLIB_MAIN_LOOP_EXIT_FUNCTION
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
Definition: init.h:177
vnet.h
VNET_SW_INTERFACE_TYPE_HARDWARE
@ VNET_SW_INTERFACE_TYPE_HARDWARE
Definition: interface.h:763
clib_socket_t
struct _socket_t clib_socket_t
vlib_node_runtime_t
Definition: node.h:454
vnet_get_sup_sw_interface
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:81
vlib_cli_command_t
Definition: cli.h:92
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
stat_segment_set_state_counter
void stat_segment_set_state_counter(u32 index, u64 value)
Definition: stat_segment.c:962
vlib_stats_register_mem_heap
void vlib_stats_register_mem_heap(clib_mem_heap_t *heap)
Definition: stat_segment_provider.c:84
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
stat_segment_new_entry
u32 stat_segment_new_entry(u8 *name, stat_directory_type_t t)
Definition: stat_segment.c:393
clib_mem_get_last_error
static_always_inline clib_error_t * clib_mem_get_last_error(void)
Definition: mem.h:553
CLIB_MEM_PAGE_SZ_UNKNOWN
@ CLIB_MEM_PAGE_SZ_UNKNOWN
Definition: mem.h:59
STAT_COUNTER_NODE_CLOCKS
@ STAT_COUNTER_NODE_CLOCKS
Definition: stat_segment.h:30
vnet_get_aggregate_rx_packets
static u64 vnet_get_aggregate_rx_packets(void)
Definition: devices.h:74
statseg_config
static clib_error_t * statseg_config(vlib_main_t *vm, unformat_input_t *input)
Definition: stat_segment.c:971
clib_mem_set_heap
static clib_mem_heap_t * clib_mem_set_heap(clib_mem_heap_t *heap)
Definition: mem.h:365
stat_segment_main_t::error_vector
volatile u64 ** error_vector
Definition: stat_segment.h:81
clib_mem_alloc
static void * clib_mem_alloc(uword size)
Definition: mem.h:253
stat_segment_directory_entry_t::type
stat_directory_type_t type
Definition: stat_segment_shared.h:33
vlib_stats_delete_cm
void vlib_stats_delete_cm(void *cm_arg)
Definition: stat_segment.c:152
STAT_DIR_TYPE_ERROR_INDEX
@ STAT_DIR_TYPE_ERROR_INDEX
Definition: stat_segment_shared.h:25
vlib_stats_register_error_index
void vlib_stats_register_error_index(void *oldheap, u8 *name, u64 *em_vec, u64 index)
Definition: stat_segment.c:306
stat_segment_main_t::stat_segment_lockp
clib_spinlock_t * stat_segment_lockp
Definition: stat_segment.h:88
stat_segment_main
stat_segment_main_t stat_segment_main
Definition: stat_segment.c:24
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vlib_node_t::name
u8 * name
Definition: node.h:253
vec_foreach_index_backwards
#define vec_foreach_index_backwards(var, v)
Iterate over vector indices (reverse).
Definition: vec_bootstrap.h:223
stats_socket_accept_ready
static clib_error_t * stats_socket_accept_ready(clib_file_t *uf)
Definition: stat_segment.c:797
CLIB_SOCKET_F_SEQPACKET
#define CLIB_SOCKET_F_SEQPACKET
Definition: socket.h:63
stat_validate_counter_vector
static void stat_validate_counter_vector(stat_segment_directory_entry_t *ep, u32 max)
Definition: stat_segment.c:355
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
hash_pair_t
Definition: hash.h:159
stat_segment_shared_header_t::epoch
volatile uint64_t epoch
Definition: stat_segment_shared.h:54
clib_socket_accept
__clib_export clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:542
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
name_sort_cmp
static int name_sort_cmp(void *a1, void *a2)
Definition: stat_segment.c:499