FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
vlib_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * vlib_api.c VLIB API implementation
4  *
5  * Copyright (c) 2009 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <fcntl.h>
21 #include <pthread.h>
22 #include <vppinfra/vec.h>
23 #include <vppinfra/hash.h>
24 #include <vppinfra/pool.h>
25 #include <vppinfra/format.h>
26 #include <vppinfra/byte_order.h>
27 #include <vppinfra/elog.h>
28 #include <vlib/vlib.h>
29 #include <vlib/unix/unix.h>
30 #include <vlibapi/api.h>
31 #include <vlibmemory/api.h>
32 
33 /**
34  * @file
35  * @brief Binary API messaging via shared memory
36  * Low-level, primary provisioning interface
37  */
38 /*? %%clicmd:group_label Binary API CLI %% ?*/
39 /*? %%syscfg:group_label Binary API configuration %% ?*/
40 
41 #define TRACE_VLIB_MEMORY_QUEUE 0
42 
43 #include <vlibmemory/vl_memory_msg_enum.h> /* enumerate all vlib messages */
44 
45 #define vl_typedefs /* define message structures */
47 #undef vl_typedefs
48 
49 /* instantiate all the print functions we know about */
50 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
51 #define vl_printfun
53 #undef vl_printfun
54 
55 static inline void *
57  void *handle)
58 {
59  vl_print (handle, "vl_api_trace_plugin_msg_ids: %s first %u last %u\n",
60  a->plugin_name,
61  clib_host_to_net_u16 (a->first_msg_id),
62  clib_host_to_net_u16 (a->last_msg_id));
63  return handle;
64 }
65 
66 /* instantiate all the endian swap functions we know about */
67 #define vl_endianfun
69 #undef vl_endianfun
70 
71 static void
73 {
76  uword *p;
79  u8 name[64];
80  u16 first_msg_id = ~0;
81  int rv = -7; /* VNET_API_ERROR_INVALID_VALUE */
82 
84  if (!regp)
85  return;
86 
87  if (am->msg_range_by_name == 0)
88  goto out;
89  strncpy ((char *) name, (char *) mp->name, ARRAY_LEN (name));
90  name[ARRAY_LEN (name) - 1] = '\0';
91  p = hash_get_mem (am->msg_range_by_name, name);
92  if (p == 0)
93  goto out;
94 
95  rp = vec_elt_at_index (am->msg_ranges, p[0]);
96  first_msg_id = rp->first_msg_id;
97  rv = 0;
98 
99 out:
100  rmp = vl_msg_api_alloc (sizeof (*rmp));
101  rmp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID_REPLY);
102  rmp->context = mp->context;
103  rmp->retval = ntohl (rv);
104  rmp->first_msg_id = ntohs (first_msg_id);
105  vl_api_send_msg (regp, (u8 *) rmp);
106 }
107 
108 void
110 {
114  u32 nmsg = vec_len (am->api_version_list);
115  int msg_size = sizeof (*rmp) + sizeof (rmp->api_versions[0]) * nmsg;
116  int i;
117 
119  if (!reg)
120  return;
121 
122  rmp = vl_msg_api_alloc (msg_size);
123  clib_memset (rmp, 0, msg_size);
124  rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY);
125 
126  /* fill in the message */
127  rmp->context = mp->context;
128  rmp->count = htonl (nmsg);
129 
130  for (i = 0; i < nmsg; ++i)
131  {
132  api_version_t *vl = &am->api_version_list[i];
133  rmp->api_versions[i].major = htonl (vl->major);
134  rmp->api_versions[i].minor = htonl (vl->minor);
135  rmp->api_versions[i].patch = htonl (vl->patch);
136  strncpy ((char *) rmp->api_versions[i].name, vl->name,
137  ARRAY_LEN (rmp->api_versions[i].name));
138  rmp->api_versions[i].name[ARRAY_LEN (rmp->api_versions[i].name) - 1] =
139  '\0';
140  }
141 
142  vl_api_send_msg (reg, (u8 *) rmp);
143 }
144 
145 #define foreach_vlib_api_msg \
146 _(GET_FIRST_MSG_ID, get_first_msg_id) \
147 _(API_VERSIONS, api_versions)
148 
149 /*
150  * vl_api_init
151  */
152 static int
154 {
156  vl_msg_api_msg_config_t *c = &cfg;
157 
158  clib_memset (c, 0, sizeof (*c));
159 
160 #define _(N,n) do { \
161  c->id = VL_API_##N; \
162  c->name = #n; \
163  c->handler = vl_api_##n##_t_handler; \
164  c->cleanup = vl_noop_handler; \
165  c->endian = vl_api_##n##_t_endian; \
166  c->print = vl_api_##n##_t_print; \
167  c->size = sizeof(vl_api_##n##_t); \
168  c->traced = 1; /* trace, so these msgs print */ \
169  c->replay = 0; /* don't replay client create/delete msgs */ \
170  c->message_bounce = 0; /* don't bounce this message */ \
171  vl_msg_api_config(c);} while (0);
172 
174 #undef _
175 
176  return 0;
177 }
178 
180 
181 /*
182  * Callback to send ourselves a plugin numbering-space trace msg
183  */
184 static void
185 send_one_plugin_msg_ids_msg (u8 * name, u16 first_msg_id, u16 last_msg_id)
186 {
189  vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr;
190  svm_queue_t *q;
191 
192  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
193  clib_memset (mp, 0, sizeof (*mp));
194 
195  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_TRACE_PLUGIN_MSG_IDS);
196  strncpy ((char *) mp->plugin_name, (char *) name,
197  sizeof (mp->plugin_name) - 1);
198  mp->first_msg_id = clib_host_to_net_u16 (first_msg_id);
199  mp->last_msg_id = clib_host_to_net_u16 (last_msg_id);
200 
201  q = shmem_hdr->vl_input_queue;
202 
203  vl_msg_api_send_shmem (q, (u8 *) & mp);
204 }
205 
206 void
208 {
209  u8 *serialized_message_table;
211  u8 *chroot_file;
212  int fd, rv;
213 
214  /*
215  * Snapshoot the api message table.
216  */
217  if (strstr ((char *) am->save_msg_table_filename, "..")
218  || index ((char *) am->save_msg_table_filename, '/'))
219  {
220  clib_warning ("illegal save-message-table filename '%s'",
221  am->save_msg_table_filename);
222  return;
223  }
224 
225  chroot_file = format (0, "/tmp/%s%c", am->save_msg_table_filename, 0);
226 
227  fd = creat ((char *) chroot_file, 0644);
228 
229  if (fd < 0)
230  {
231  clib_unix_warning ("creat");
232  return;
233  }
234 
235  serialized_message_table = vl_api_serialize_message_table (am, 0);
236 
237  rv = write (fd, serialized_message_table,
238  vec_len (serialized_message_table));
239 
240  if (rv != vec_len (serialized_message_table))
241  clib_unix_warning ("write");
242 
243  rv = close (fd);
244  if (rv < 0)
245  clib_unix_warning ("close");
246 
247  vec_free (chroot_file);
248  vec_free (serialized_message_table);
249 }
250 
251 clib_error_t *vat_builtin_main_init (vlib_main_t * vm) __attribute__ ((weak));
252 clib_error_t *
254 {
255  return 0;
256 }
257 
258 static uword
260  vlib_frame_t * f)
261 {
263  int private_segment_rotor = 0, i, rv;
265  vl_shmem_hdr_t *shm;
266  svm_queue_t *q;
267  clib_error_t *e;
269  f64 dead_client_scan_time;
270  f64 sleep_time, start_time;
271  f64 vector_rate;
273  uword event_type;
274  uword *event_data = 0;
275  f64 now;
276 
277  if ((error = vl_sock_api_init (vm)))
278  {
280  clib_warning ("socksvr_api_init failed, quitting...");
281  return 0;
282  }
283 
284  if ((rv = vlib_api_init ()) < 0)
285  {
286  clib_warning ("vlib_api_init returned %d, quitting...", rv);
287  return 0;
288  }
289 
290  shm = am->shmem_hdr;
291  q = shm->vl_input_queue;
292 
294  1 /* call_once */, 1 /* is_global */);
295  if (e)
296  clib_error_report (e);
297 
299  if (e)
300  clib_error_report (e);
301 
302  sleep_time = 10.0;
303  dead_client_scan_time = vlib_time_now (vm) + 10.0;
304 
305  /*
306  * Send plugin message range messages for each plugin we loaded
307  */
308  for (i = 0; i < vec_len (am->msg_ranges); i++)
309  {
310  vl_api_msg_range_t *rp = am->msg_ranges + i;
312  rp->last_msg_id);
313  }
314 
315  /*
316  * Save the api message table snapshot, if configured
317  */
318  if (am->save_msg_table_filename)
320 
321  /* $$$ pay attention to frame size, control CPU usage */
322  while (1)
323  {
324  /*
325  * There's a reason for checking the queue before
326  * sleeping. If the vlib application crashes, it's entirely
327  * possible for a client to enqueue a connect request
328  * during the process restart interval.
329  *
330  * Unless some force of physics causes the new incarnation
331  * of the application to process the request, the client will
332  * sit and wait for Godot...
333  */
334  vector_rate = (f64) vlib_last_vectors_per_main_loop (vm);
335  start_time = vlib_time_now (vm);
336  while (1)
337  {
340  {
341  vm->api_queue_nonempty = 0;
342  VL_MEM_API_LOG_Q_LEN ("q-underflow: len %d", 0);
343  sleep_time = 20.0;
344  break;
345  }
346 
347  /* Allow no more than 10us without a pause */
348  if (vlib_time_now (vm) > start_time + 10e-6)
349  {
350  int index = SLEEP_400_US;
351  if (vector_rate > 40.0)
352  sleep_time = 400e-6;
353  else if (vector_rate > 20.0)
354  {
355  index = SLEEP_200_US;
356  sleep_time = 200e-6;
357  }
358  else if (vector_rate >= 1.0)
359  {
360  index = SLEEP_100_US;
361  sleep_time = 100e-6;
362  }
363  else
364  {
365  index = SLEEP_10_US;
366  sleep_time = 10e-6;
367  }
369  break;
370  }
371  }
372 
373  /*
374  * see if we have any private api shared-memory segments
375  * If so, push required context variables, and process
376  * a message.
377  */
378  if (PREDICT_FALSE (vec_len (am->vlib_private_rps)))
379  {
380  if (private_segment_rotor >= vec_len (am->vlib_private_rps))
381  private_segment_rotor = 0;
382  vl_mem_api_handle_msg_private (vm, node, private_segment_rotor++);
383  }
384 
386  vec_reset_length (event_data);
387  event_type = vlib_process_get_events (vm, &event_data);
388  now = vlib_time_now (vm);
389 
390  switch (event_type)
391  {
392  case QUEUE_SIGNAL_EVENT:
394  VL_MEM_API_LOG_Q_LEN ("q-awake: len %d", q->cursize);
395 
396  break;
397  case SOCKET_READ_EVENT:
398  for (i = 0; i < vec_len (event_data); i++)
399  {
400  vl_api_registration_t *regp;
401 
402  a = pool_elt_at_index (socket_main.process_args, event_data[i]);
403  regp = vl_socket_get_registration (a->reg_index);
404  if (regp)
405  {
406  vl_socket_process_api_msg (regp, (i8 *) a->data);
408  event_data[i]);
409  }
410  vec_free (a->data);
412  }
413  break;
414 
415  /* Timeout... */
416  case -1:
417  break;
418 
419  default:
420  clib_warning ("unknown event type %d", event_type);
421  break;
422  }
423 
424  if (now > dead_client_scan_time)
425  {
427  dead_client_scan_time = vlib_time_now (vm) + 10.0;
428  }
429  }
430 
431  return 0;
432 }
433 /* *INDENT-OFF* */
435 {
436  .function = vl_api_clnt_process,
437  .type = VLIB_NODE_TYPE_PROCESS,
438  .name = "api-rx-from-ring",
439  .state = VLIB_NODE_STATE_DISABLED,
440  .process_log2_n_stack_bytes = 18,
441 };
442 /* *INDENT-ON* */
443 
444 void
446 {
448  (enable
449  ? VLIB_NODE_STATE_POLLING
450  : VLIB_NODE_STATE_DISABLED));
451 }
452 
453 static uword
456 {
457  uword n_packets = frame->n_vectors;
459  u32 *from;
460  static u8 *long_msg;
461 
462  vec_validate (long_msg, 4095);
463  n_left_from = frame->n_vectors;
465 
466  while (n_left_from > 0)
467  {
468  u32 bi0;
469  vlib_buffer_t *b0;
470  void *msg;
471  uword msg_len;
472 
473  bi0 = from[0];
474  b0 = vlib_get_buffer (vm, bi0);
475  from += 1;
476  n_left_from -= 1;
477 
478  msg = b0->data + b0->current_data;
479  msg_len = b0->current_length;
480  if (b0->flags & VLIB_BUFFER_NEXT_PRESENT)
481  {
482  ASSERT (long_msg != 0);
483  _vec_len (long_msg) = 0;
484  vec_add (long_msg, msg, msg_len);
485  while (b0->flags & VLIB_BUFFER_NEXT_PRESENT)
486  {
487  b0 = vlib_get_buffer (vm, b0->next_buffer);
488  msg = b0->data + b0->current_data;
489  msg_len = b0->current_length;
490  vec_add (long_msg, msg, msg_len);
491  }
492  msg = long_msg;
493  }
495  }
496 
497  /* Free what we've been given. */
499 
500  return n_packets;
501 }
502 
503 /* *INDENT-OFF* */
505  .function = api_rx_from_node,
506  .type = VLIB_NODE_TYPE_INTERNAL,
507  .vector_size = 4,
508  .name = "api-rx-from-node",
509 };
510 /* *INDENT-ON* */
511 
512 static void
514 {
515  vl_api_rpc_call_reply_t *rmp;
516  int (*fp) (void *);
517  i32 rv = 0;
519 
520  if (mp->function == 0)
521  {
522  rv = -1;
523  clib_warning ("rpc NULL function pointer");
524  }
525 
526  else
527  {
528  if (mp->need_barrier_sync)
530 
531  fp = uword_to_pointer (mp->function, int (*)(void *));
532  rv = fp (mp->data);
533 
534  if (mp->need_barrier_sync)
536  }
537 
538  if (mp->send_reply)
539  {
541  if (q)
542  {
543  rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
544  rmp->_vl_msg_id = ntohs (VL_API_RPC_CALL_REPLY);
545  rmp->context = mp->context;
546  rmp->retval = rv;
547  vl_msg_api_send_shmem (q, (u8 *) & rmp);
548  }
549  }
550  if (mp->multicast)
551  {
552  clib_warning ("multicast not yet implemented...");
553  }
554 }
555 
556 static void
557 vl_api_rpc_call_reply_t_handler (vl_api_rpc_call_reply_t * mp)
558 {
559  clib_warning ("unimplemented");
560 }
561 
562 void
564 {
565  vlib_main_t *vm_global = vlib_get_first_main ();
566 
567  ASSERT (vm != vm_global);
568 
573 }
574 
575 always_inline void
576 vl_api_rpc_call_main_thread_inline (void *fp, u8 * data, u32 data_length,
577  u8 force_rpc)
578 {
579  vl_api_rpc_call_t *mp;
580  vlib_main_t *vm_global = vlib_get_first_main ();
582 
583  /* Main thread and not a forced RPC: call the function directly */
584  if ((force_rpc == 0) && (vlib_get_thread_index () == 0))
585  {
586  void (*call_fp) (void *);
587 
589 
590  call_fp = fp;
591  call_fp (data);
592 
594  return;
595  }
596 
597  /* Otherwise, actually do an RPC */
598  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp) + data_length);
599 
600  clib_memset (mp, 0, sizeof (*mp));
601  clib_memcpy_fast (mp->data, data, data_length);
602  mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
603  mp->function = pointer_to_uword (fp);
604  mp->need_barrier_sync = 1;
605 
606  /* Add to the pending vector. Thread 0 requires locking. */
607  if (vm == vm_global)
610  if (vm == vm_global)
612 }
613 
614 /*
615  * Check if called from worker threads.
616  * If so, make rpc call of fp through shmem.
617  * Otherwise, call fp directly
618  */
619 void
620 vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
621 {
622  vl_api_rpc_call_main_thread_inline (fp, data, data_length, /*force_rpc */
623  0);
624 }
625 
626 /*
627  * Always make rpc call of fp through shmem, useful for calling from threads
628  * not setup as worker threads, such as DPDK callback thread
629  */
630 void
631 vl_api_force_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
632 {
633  vl_api_rpc_call_main_thread_inline (fp, data, data_length, /*force_rpc */
634  1);
635 }
636 
637 static void
639 {
641  vl_api_msg_range_t *rp;
642  uword *p;
643 
644  /* Noop (except for tracing) during normal operation */
645  if (am->replay_in_progress == 0)
646  return;
647 
648  p = hash_get_mem (am->msg_range_by_name, mp->plugin_name);
649  if (p == 0)
650  {
651  clib_warning ("WARNING: traced plugin '%s' not in current image",
652  mp->plugin_name);
653  return;
654  }
655 
656  rp = vec_elt_at_index (am->msg_ranges, p[0]);
657  if (rp->first_msg_id != clib_net_to_host_u16 (mp->first_msg_id))
658  {
659  clib_warning ("WARNING: traced plugin '%s' first message id %d not %d",
660  mp->plugin_name, clib_net_to_host_u16 (mp->first_msg_id),
661  rp->first_msg_id);
662  }
663 
664  if (rp->last_msg_id != clib_net_to_host_u16 (mp->last_msg_id))
665  {
666  clib_warning ("WARNING: traced plugin '%s' last message id %d not %d",
667  mp->plugin_name, clib_net_to_host_u16 (mp->last_msg_id),
668  rp->last_msg_id);
669  }
670 }
671 
672 #define foreach_rpc_api_msg \
673 _(RPC_CALL,rpc_call) \
674 _(RPC_CALL_REPLY,rpc_call_reply)
675 
676 #define foreach_plugin_trace_msg \
677 _(TRACE_PLUGIN_MSG_IDS,trace_plugin_msg_ids)
678 
679 /*
680  * Set the rpc callback at our earliest possible convenience.
681  * This avoids ordering issues between thread_init() -> start_workers and
682  * an init function which we could define here. If we ever intend to use
683  * vlib all by itself, we can't create a link-time dependency on
684  * an init function here and a typical "call foo_init first"
685  * guitar lick.
686  */
687 
688 extern void *rpc_call_main_thread_cb_fn;
689 
690 static clib_error_t *
692 {
694 #define _(N,n) \
695  vl_msg_api_set_handlers(VL_API_##N, #n, \
696  vl_api_##n##_t_handler, \
697  vl_noop_handler, \
698  vl_noop_handler, \
699  vl_api_##n##_t_print, \
700  sizeof(vl_api_##n##_t), 0 /* do not trace */);
702 #undef _
703 
704 #define _(N,n) \
705  vl_msg_api_set_handlers(VL_API_##N, #n, \
706  vl_api_##n##_t_handler, \
707  vl_noop_handler, \
708  vl_noop_handler, \
709  vl_api_##n##_t_print, \
710  sizeof(vl_api_##n##_t), 1 /* do trace */);
712 #undef _
713 
714  /* No reason to halt the parade to create a trace record... */
715  am->is_mp_safe[VL_API_TRACE_PLUGIN_MSG_IDS] = 1;
717  return 0;
718 }
719 
721 
722 /*
723  * fd.io coding-style-patch-verification: ON
724  *
725  * Local Variables:
726  * eval: (c-set-style "gnu")
727  * End:
728  */
vlib_api_init
static int vlib_api_init(void)
Definition: vlib_api.c:153
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
vlib.h
vlib_buffer_t::next_buffer
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:149
socket_main_t::process_args
vl_socket_args_for_process_t * process_args
Definition: socket_api.h:59
vlib_buffer_free
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:982
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
api.h
vlib_worker_thread_barrier_release
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1386
vec_add
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:688
vl_socket_process_api_msg
void vl_socket_process_api_msg(vl_api_registration_t *rp, i8 *input_v)
Definition: socket_api.c:197
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vlib_global_main_t
Definition: main.h:274
api_rx_from_node_node
static vlib_node_registration_t api_rx_from_node_node
(constructor) VLIB_REGISTER_NODE (api_rx_from_node_node)
Definition: vlib_api.c:504
vl_api_api_versions_reply_t::api_versions
vl_api_module_version_t api_versions[count]
Definition: memclnt.api:131
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
vl_api_rpc_call_t::multicast
u8 multicast
Definition: memclnt.api:92
vl_api_msg_range_t::name
u8 * name
name of the plugin
Definition: api_common.h:116
vl_api_send_pending_rpc_requests
void vl_api_send_pending_rpc_requests(vlib_main_t *vm)
Definition: vlib_api.c:563
elog.h
clib_spinlock_lock_if_init
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:106
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vl_mem_api_handle_msg_private
int vl_mem_api_handle_msg_private(vlib_main_t *vm, vlib_node_runtime_t *node, u32 reg_index)
Definition: memory_api.c:756
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
vl_api_save_msg_table
void vl_api_save_msg_table(void)
Definition: vlib_api.c:207
f
vlib_frame_t * f
Definition: interface_output.c:1080
pointer_to_uword
static uword pointer_to_uword(const void *p)
Definition: types.h:131
vl_api_rpc_call_main_thread
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:620
vlib_node_set_state
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:175
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
name
string name[64]
Definition: fib.api:25
VL_MEM_API_LOG_Q_LEN
#define VL_MEM_API_LOG_Q_LEN(fmt, qlen)
Definition: memory_api.h:70
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
vlib_main_t::pending_rpc_lock
clib_spinlock_t pending_rpc_lock
Definition: main.h:262
vl_api_api_versions_t::context
u32 context
Definition: memclnt.api:125
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
foreach_plugin_trace_msg
#define foreach_plugin_trace_msg
Definition: vlib_api.c:676
vl_api_rpc_call_t::data
u8 data[data_len]
Definition: memclnt.api:96
svm_queue_t
struct _svm_queue svm_queue_t
vl_api_trace_plugin_msg_ids_t
Definition: memclnt.api:140
vec_append
#define vec_append(v1, v2)
Append v2 after v1.
Definition: vec.h:911
vl_msg_api_msg_config_t
Message configuration definition.
Definition: api_common.h:122
u16
unsigned short u16
Definition: types.h:57
am
app_main_t * am
Definition: application.c:489
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
byte_order.h
vl_api_msg_range_t::last_msg_id
u16 last_msg_id
last assigned message ID
Definition: api_common.h:118
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
vlib_frame_t
Definition: node.h:372
vl_api_get_first_msg_id_t::client_index
u32 client_index
Definition: memclnt.api:103
vl_api_rpc_call_t_handler
static void vl_api_rpc_call_t_handler(vl_api_rpc_call_t *mp)
Definition: vlib_api.c:513
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
vl_api_force_rpc_call_main_thread
void vl_api_force_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:631
vlib_main_t::queue_signal_pending
volatile u32 queue_signal_pending
Definition: main.h:218
vat_builtin_main_init
clib_error_t * vat_builtin_main_init(vlib_main_t *vm)
Definition: vlib_api.c:253
vl_shmem_hdr_
Definition: memory_shared.h:76
vlib_get_global_main
static vlib_global_main_t * vlib_get_global_main(void)
Definition: global_funcs.h:50
vl_msg_api_alloc_as_if_client
void * vl_msg_api_alloc_as_if_client(int nbytes)
Definition: memory_shared.c:236
clib_unix_warning
#define clib_unix_warning(format, args...)
Definition: error.h:68
error
Definition: cJSON.c:88
i32
signed int i32
Definition: types.h:77
vl_api_trace_plugin_msg_ids_t::last_msg_id
u16 last_msg_id
Definition: memclnt.api:146
vl_api_rpc_call_t::context
u32 context
Definition: memclnt.api:90
vl_api_api_versions_t_handler
void vl_api_api_versions_t_handler(vl_api_api_versions_t *mp)
Definition: vlib_api.c:109
vlib_process_get_events
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
Definition: node_funcs.h:583
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
socket_main
socket_main_t socket_main
Definition: socket_api.c:48
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vl_api_client_index_to_input_queue
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
Definition: memory_api.c:794
foreach_vlib_api_msg
#define foreach_vlib_api_msg
Definition: vlib_api.c:145
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vl_api_clnt_node
vlib_node_registration_t vl_api_clnt_node
(constructor) VLIB_REGISTER_NODE (vl_api_clnt_node)
Definition: vlib_api.c:434
vlib_last_vectors_per_main_loop
static u32 vlib_last_vectors_per_main_loop(vlib_main_t *vm)
Definition: main.h:427
vl_api_trace_plugin_msg_ids_t::plugin_name
string plugin_name[128]
Definition: memclnt.api:144
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
vl_msg_api_handler_no_trace_no_free
void vl_msg_api_handler_no_trace_no_free(void *the_msg)
Definition: api_shared.c:725
vl_mem_api_handle_rpc
int vl_mem_api_handle_rpc(vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: memory_api.c:712
vl_mem_api_handle_msg_main
int vl_mem_api_handle_msg_main(vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: memory_api.c:704
vlib_worker_thread_barrier_sync
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:194
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vl_api_get_first_msg_id_reply_t::retval
i32 retval
Definition: memclnt.api:110
vlib_get_thread_index
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:208
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
vl_api_get_first_msg_id_t::name
string name[64]
Definition: memclnt.api:105
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
vl_api_rpc_call_t::client_index
u32 client_index
Definition: memclnt.api:89
vl_api_rpc_call_main_thread_inline
static void vl_api_rpc_call_main_thread_inline(void *fp, u8 *data, u32 data_length, u8 force_rpc)
Definition: vlib_api.c:576
vlib_global_main_t::api_init_function_registrations
_vlib_init_function_list_elt_t * api_init_function_registrations
Definition: main.h:311
vlib_call_init_exit_functions
clib_error_t * vlib_call_init_exit_functions(vlib_main_t *vm, _vlib_init_function_list_elt_t **headp, int call_once, int is_global)
Definition: init.c:373
vl_shmem_hdr_::vl_input_queue
svm_queue_t * vl_input_queue
Definition: memory_shared.h:84
uword
u64 uword
Definition: types.h:112
vl_api_rpc_call_reply_t_handler
static void vl_api_rpc_call_reply_t_handler(vl_api_rpc_call_reply_t *mp)
Definition: vlib_api.c:557
vector_rate_histogram
u64 vector_rate_histogram[SLEEP_N_BUCKETS]
Definition: vlib_api.c:179
pool.h
Fixed length block allocator. Pools are built from clib vectors and bitmaps. Use pools when repeatedl...
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
SOCKET_READ_EVENT
@ SOCKET_READ_EVENT
Definition: api.h:134
api_rx_from_node
static uword api_rx_from_node(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: vlib_api.c:454
vl_api_serialize_message_table
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
Definition: api_shared.c:204
vl_mem_api_enable_disable
void vl_mem_api_enable_disable(vlib_main_t *vm, int enable)
Definition: vlib_api.c:445
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
foreach_rpc_api_msg
#define foreach_rpc_api_msg
Definition: vlib_api.c:672
format.h
vlib_main_t::pending_rpc_requests
uword * pending_rpc_requests
Definition: main.h:260
vlib_main_t::api_queue_nonempty
volatile u32 api_queue_nonempty
Definition: main.h:219
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vl_api_trace_plugin_msg_ids_t::first_msg_id
u16 first_msg_id
Definition: memclnt.api:145
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
vl_sock_api_init
clib_error_t * vl_sock_api_init(vlib_main_t *vm)
Definition: socket_api.c:774
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
data
u8 data[128]
Definition: ipsec_types.api:92
vl_api_rpc_call_t::send_reply
u8 send_reply
Definition: memclnt.api:94
vl_api_rpc_call_t::function
u64 function
Definition: memclnt.api:91
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
api_version_t
Definition: api_common.h:219
vl_api_get_first_msg_id_t::context
u32 context
Definition: memclnt.api:104
index
u32 index
Definition: flow_types.api:221
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
vl_socket_args_for_process_t
Definition: socket_api.h:30
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
u64
unsigned long u64
Definition: types.h:89
i8
signed char i8
Definition: types.h:45
vl_api_get_first_msg_id_reply_t::first_msg_id
u16 first_msg_id
Definition: memclnt.api:111
vlib_process_wait_for_event_or_clock
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:755
vl_api_get_first_msg_id_reply_t
Definition: memclnt.api:108
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
QUEUE_SIGNAL_EVENT
@ QUEUE_SIGNAL_EVENT
Definition: api.h:133
vl_mem_api_dead_client_scan
void vl_mem_api_dead_client_scan(api_main_t *am, vl_shmem_hdr_t *shm, f64 now)
Definition: memory_api.c:576
vl_api_api_versions_reply_t
Definition: memclnt.api:127
vl_api_msg_range_t
Message range (belonging to a plugin)
Definition: api_common.h:114
u32
unsigned int u32
Definition: types.h:88
vl_api_get_first_msg_id_t
Definition: memclnt.api:102
vlib_get_first_main
static vlib_main_t * vlib_get_first_main(void)
Definition: global_funcs.h:44
vl_api_api_versions_t::client_index
u32 client_index
Definition: memclnt.api:124
vl_api_clnt_process
static uword vl_api_clnt_process(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Definition: vlib_api.c:259
vl_api_get_first_msg_id_reply_t::context
u32 context
Definition: memclnt.api:109
vl_socket_get_registration
static vl_api_registration_t * vl_socket_get_registration(u32 reg_index)
Definition: socket_api.h:68
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
vl_api_msg_range_t::first_msg_id
u16 first_msg_id
first assigned message ID
Definition: api_common.h:117
vl_api_api_versions_t
Definition: memclnt.api:123
vl
u32 vl(void *p)
GDB callable function: vl - Return vector length of vector.
Definition: gdb_funcs.c:35
vec.h
now
f64 now
Definition: nat44_ei_out2in.c:710
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vl_api_rpc_call_t
Definition: memclnt.api:88
SLEEP_N_BUCKETS
@ SLEEP_N_BUCKETS
Definition: api.h:148
hash.h
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:544
unix.h
vl_msg_api_send_shmem
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
Definition: memory_shared.c:753
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(rpc_api_hookup)
rpc_call_main_thread_cb_fn
void * rpc_call_main_thread_cb_fn
Definition: threads.c:1634
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
uword_to_pointer
#define uword_to_pointer(u, type)
Definition: types.h:136
vl_print
#define vl_print(handle,...)
Definition: vlib_api.c:50
send_one_plugin_msg_ids_msg
static void send_one_plugin_msg_ids_msg(u8 *name, u16 first_msg_id, u16 last_msg_id)
Definition: vlib_api.c:185
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
rv
int __clib_unused rv
Definition: application.c:491
vl_api_api_versions_reply_t::count
u32 count
Definition: memclnt.api:130
vl_memory_api_h.h
vl_api_rpc_call_t::need_barrier_sync
u8 need_barrier_sync
Definition: memclnt.api:93
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
vl_api_api_versions_reply_t::context
u32 context
Definition: memclnt.api:128
vl_api_trace_plugin_msg_ids_t_print
static void * vl_api_trace_plugin_msg_ids_t_print(vl_api_trace_plugin_msg_ids_t *a, void *handle)
Definition: vlib_api.c:56
vlib_node_runtime_t
Definition: node.h:454
clib_spinlock_unlock_if_init
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:129
rpc_api_hookup
static clib_error_t * rpc_api_hookup(vlib_main_t *vm)
Definition: vlib_api.c:691
from
from
Definition: nat44_ei_hairpinning.c:415
vl_memory_msg_enum.h
vl_api_get_first_msg_id_t_handler
static void vl_api_get_first_msg_id_t_handler(vl_api_get_first_msg_id_t *mp)
Definition: vlib_api.c:72
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
vl_api_trace_plugin_msg_ids_t_handler
static void vl_api_trace_plugin_msg_ids_t_handler(vl_api_trace_plugin_msg_ids_t *mp)
Definition: vlib_api.c:638
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169