misc: move part of vpe apis to vlibmemory
[vpp.git] / src / vlibmemory / memclnt_api.c
1 /*
2  *------------------------------------------------------------------
3  * memclnt_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 */
46 #include <vlibmemory/vl_memory_api_h.h>
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
52 #include <vlibmemory/vl_memory_api_h.h>
53 #undef vl_printfun
54
55 static inline void *
56 vl_api_trace_plugin_msg_ids_t_print (vl_api_trace_plugin_msg_ids_t *a,
57                                      void *handle)
58 {
59   vl_print (handle, "vl_api_trace_plugin_msg_ids: %s first %u last %u\n",
60             a->plugin_name, clib_host_to_net_u16 (a->first_msg_id),
61             clib_host_to_net_u16 (a->last_msg_id));
62   return handle;
63 }
64
65 /* instantiate all the endian swap functions we know about */
66 #define vl_endianfun
67 #include <vlibmemory/vl_memory_api_h.h>
68 #undef vl_endianfun
69
70 static void
71 vl_api_get_first_msg_id_t_handler (vl_api_get_first_msg_id_t *mp)
72 {
73   vl_api_get_first_msg_id_reply_t *rmp;
74   vl_api_registration_t *regp;
75   uword *p;
76   api_main_t *am = vlibapi_get_main ();
77   vl_api_msg_range_t *rp;
78   u8 name[64];
79   u16 first_msg_id = ~0;
80   int rv = -7; /* VNET_API_ERROR_INVALID_VALUE */
81
82   regp = vl_api_client_index_to_registration (mp->client_index);
83   if (!regp)
84     return;
85
86   if (am->msg_range_by_name == 0)
87     goto out;
88   strncpy ((char *) name, (char *) mp->name, ARRAY_LEN (name));
89   name[ARRAY_LEN (name) - 1] = '\0';
90   p = hash_get_mem (am->msg_range_by_name, name);
91   if (p == 0)
92     goto out;
93
94   rp = vec_elt_at_index (am->msg_ranges, p[0]);
95   first_msg_id = rp->first_msg_id;
96   rv = 0;
97
98 out:
99   rmp = vl_msg_api_alloc (sizeof (*rmp));
100   rmp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID_REPLY);
101   rmp->context = mp->context;
102   rmp->retval = ntohl (rv);
103   rmp->first_msg_id = ntohs (first_msg_id);
104   vl_api_send_msg (regp, (u8 *) rmp);
105 }
106
107 void
108 vl_api_api_versions_t_handler (vl_api_api_versions_t *mp)
109 {
110   api_main_t *am = vlibapi_get_main ();
111   vl_api_api_versions_reply_t *rmp;
112   vl_api_registration_t *reg;
113   u32 nmsg = vec_len (am->api_version_list);
114   int msg_size = sizeof (*rmp) + sizeof (rmp->api_versions[0]) * nmsg;
115   int i;
116
117   reg = vl_api_client_index_to_registration (mp->client_index);
118   if (!reg)
119     return;
120
121   rmp = vl_msg_api_alloc (msg_size);
122   clib_memset (rmp, 0, msg_size);
123   rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY);
124
125   /* fill in the message */
126   rmp->context = mp->context;
127   rmp->count = htonl (nmsg);
128
129   for (i = 0; i < nmsg; ++i)
130     {
131       api_version_t *vl = &am->api_version_list[i];
132       rmp->api_versions[i].major = htonl (vl->major);
133       rmp->api_versions[i].minor = htonl (vl->minor);
134       rmp->api_versions[i].patch = htonl (vl->patch);
135       strncpy ((char *) rmp->api_versions[i].name, vl->name,
136                ARRAY_LEN (rmp->api_versions[i].name));
137       rmp->api_versions[i].name[ARRAY_LEN (rmp->api_versions[i].name) - 1] =
138         '\0';
139     }
140
141   vl_api_send_msg (reg, (u8 *) rmp);
142 }
143
144 #define foreach_vlib_api_msg                                                  \
145   _ (GET_FIRST_MSG_ID, get_first_msg_id)                                      \
146   _ (API_VERSIONS, api_versions)
147
148 /*
149  * vl_api_init
150  */
151 static int
152 vlib_api_init (void)
153 {
154   vl_msg_api_msg_config_t cfg;
155   vl_msg_api_msg_config_t *c = &cfg;
156
157   clib_memset (c, 0, sizeof (*c));
158
159 #define _(N, n)                                                               \
160   do                                                                          \
161     {                                                                         \
162       c->id = VL_API_##N;                                                     \
163       c->name = #n;                                                           \
164       c->handler = vl_api_##n##_t_handler;                                    \
165       c->cleanup = vl_noop_handler;                                           \
166       c->endian = vl_api_##n##_t_endian;                                      \
167       c->print = vl_api_##n##_t_print;                                        \
168       c->size = sizeof (vl_api_##n##_t);                                      \
169       c->traced = 1;         /* trace, so these msgs print */                 \
170       c->replay = 0;         /* don't replay client create/delete msgs */     \
171       c->message_bounce = 0; /* don't bounce this message */                  \
172       vl_msg_api_config (c);                                                  \
173     }                                                                         \
174   while (0);
175
176   foreach_vlib_api_msg;
177 #undef _
178
179   return 0;
180 }
181
182 u64 vector_rate_histogram[SLEEP_N_BUCKETS];
183
184 /*
185  * Callback to send ourselves a plugin numbering-space trace msg
186  */
187 static void
188 send_one_plugin_msg_ids_msg (u8 *name, u16 first_msg_id, u16 last_msg_id)
189 {
190   vl_api_trace_plugin_msg_ids_t *mp;
191   api_main_t *am = vlibapi_get_main ();
192   vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr;
193   svm_queue_t *q;
194
195   mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
196   clib_memset (mp, 0, sizeof (*mp));
197
198   mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_TRACE_PLUGIN_MSG_IDS);
199   strncpy ((char *) mp->plugin_name, (char *) name,
200            sizeof (mp->plugin_name) - 1);
201   mp->first_msg_id = clib_host_to_net_u16 (first_msg_id);
202   mp->last_msg_id = clib_host_to_net_u16 (last_msg_id);
203
204   q = shmem_hdr->vl_input_queue;
205
206   vl_msg_api_send_shmem (q, (u8 *) &mp);
207 }
208
209 void
210 vl_api_save_msg_table (void)
211 {
212   u8 *serialized_message_table;
213   api_main_t *am = vlibapi_get_main ();
214   u8 *chroot_file;
215   int fd, rv;
216
217   /*
218    * Snapshoot the api message table.
219    */
220   if (strstr ((char *) am->save_msg_table_filename, "..") ||
221       index ((char *) am->save_msg_table_filename, '/'))
222     {
223       clib_warning ("illegal save-message-table filename '%s'",
224                     am->save_msg_table_filename);
225       return;
226     }
227
228   chroot_file = format (0, "/tmp/%s%c", am->save_msg_table_filename, 0);
229
230   fd = creat ((char *) chroot_file, 0644);
231
232   if (fd < 0)
233     {
234       clib_unix_warning ("creat");
235       return;
236     }
237
238   serialized_message_table = vl_api_serialize_message_table (am, 0);
239
240   rv =
241     write (fd, serialized_message_table, vec_len (serialized_message_table));
242
243   if (rv != vec_len (serialized_message_table))
244     clib_unix_warning ("write");
245
246   rv = close (fd);
247   if (rv < 0)
248     clib_unix_warning ("close");
249
250   vec_free (chroot_file);
251   vec_free (serialized_message_table);
252 }
253
254 clib_error_t *vat_builtin_main_init (vlib_main_t *vm) __attribute__ ((weak));
255 clib_error_t *
256 vat_builtin_main_init (vlib_main_t *vm)
257 {
258   return 0;
259 }
260
261 static uword
262 vl_api_clnt_process (vlib_main_t *vm, vlib_node_runtime_t *node,
263                      vlib_frame_t *f)
264 {
265   vlib_global_main_t *vgm = vlib_get_global_main ();
266   int private_segment_rotor = 0, i, rv;
267   vl_socket_args_for_process_t *a;
268   vl_shmem_hdr_t *shm;
269   svm_queue_t *q;
270   clib_error_t *e;
271   api_main_t *am = vlibapi_get_main ();
272   f64 dead_client_scan_time;
273   f64 sleep_time, start_time;
274   f64 vector_rate;
275   clib_error_t *error;
276   uword event_type;
277   uword *event_data = 0;
278   f64 now;
279
280   if ((error = vl_sock_api_init (vm)))
281     {
282       clib_error_report (error);
283       clib_warning ("socksvr_api_init failed, quitting...");
284       return 0;
285     }
286
287   if ((rv = vlib_api_init ()) < 0)
288     {
289       clib_warning ("vlib_api_init returned %d, quitting...", rv);
290       return 0;
291     }
292
293   shm = am->shmem_hdr;
294   q = shm->vl_input_queue;
295
296   e = vlib_call_init_exit_functions (vm, &vgm->api_init_function_registrations,
297                                      1 /* call_once */, 1 /* is_global */);
298   if (e)
299     clib_error_report (e);
300
301   e = vat_builtin_main_init (vm);
302   if (e)
303     clib_error_report (e);
304
305   sleep_time = 10.0;
306   dead_client_scan_time = vlib_time_now (vm) + 10.0;
307
308   /*
309    * Send plugin message range messages for each plugin we loaded
310    */
311   for (i = 0; i < vec_len (am->msg_ranges); i++)
312     {
313       vl_api_msg_range_t *rp = am->msg_ranges + i;
314       send_one_plugin_msg_ids_msg (rp->name, rp->first_msg_id,
315                                    rp->last_msg_id);
316     }
317
318   /*
319    * Save the api message table snapshot, if configured
320    */
321   if (am->save_msg_table_filename)
322     vl_api_save_msg_table ();
323
324   /* $$$ pay attention to frame size, control CPU usage */
325   while (1)
326     {
327       /*
328        * There's a reason for checking the queue before
329        * sleeping. If the vlib application crashes, it's entirely
330        * possible for a client to enqueue a connect request
331        * during the process restart interval.
332        *
333        * Unless some force of physics causes the new incarnation
334        * of the application to process the request, the client will
335        * sit and wait for Godot...
336        */
337       vector_rate = (f64) vlib_last_vectors_per_main_loop (vm);
338       start_time = vlib_time_now (vm);
339       while (1)
340         {
341           if (vl_mem_api_handle_rpc (vm, node) ||
342               vl_mem_api_handle_msg_main (vm, node))
343             {
344               vm->api_queue_nonempty = 0;
345               VL_MEM_API_LOG_Q_LEN ("q-underflow: len %d", 0);
346               sleep_time = 20.0;
347               break;
348             }
349
350           /* Allow no more than 10us without a pause */
351           if (vlib_time_now (vm) > start_time + 10e-6)
352             {
353               int index = SLEEP_400_US;
354               if (vector_rate > 40.0)
355                 sleep_time = 400e-6;
356               else if (vector_rate > 20.0)
357                 {
358                   index = SLEEP_200_US;
359                   sleep_time = 200e-6;
360                 }
361               else if (vector_rate >= 1.0)
362                 {
363                   index = SLEEP_100_US;
364                   sleep_time = 100e-6;
365                 }
366               else
367                 {
368                   index = SLEEP_10_US;
369                   sleep_time = 10e-6;
370                 }
371               vector_rate_histogram[index] += 1;
372               break;
373             }
374         }
375
376       /*
377        * see if we have any private api shared-memory segments
378        * If so, push required context variables, and process
379        * a message.
380        */
381       if (PREDICT_FALSE (vec_len (am->vlib_private_rps)))
382         {
383           if (private_segment_rotor >= vec_len (am->vlib_private_rps))
384             private_segment_rotor = 0;
385           vl_mem_api_handle_msg_private (vm, node, private_segment_rotor++);
386         }
387
388       vlib_process_wait_for_event_or_clock (vm, sleep_time);
389       vec_reset_length (event_data);
390       event_type = vlib_process_get_events (vm, &event_data);
391       now = vlib_time_now (vm);
392
393       switch (event_type)
394         {
395         case QUEUE_SIGNAL_EVENT:
396           vm->queue_signal_pending = 0;
397           VL_MEM_API_LOG_Q_LEN ("q-awake: len %d", q->cursize);
398
399           break;
400         case SOCKET_READ_EVENT:
401           for (i = 0; i < vec_len (event_data); i++)
402             {
403               vl_api_registration_t *regp;
404
405               a = pool_elt_at_index (socket_main.process_args, event_data[i]);
406               regp = vl_socket_get_registration (a->reg_index);
407               if (regp)
408                 {
409                   vl_socket_process_api_msg (regp, (i8 *) a->data);
410                   a = pool_elt_at_index (socket_main.process_args,
411                                          event_data[i]);
412                 }
413               vec_free (a->data);
414               pool_put (socket_main.process_args, a);
415             }
416           break;
417
418           /* Timeout... */
419         case -1:
420           break;
421
422         default:
423           clib_warning ("unknown event type %d", event_type);
424           break;
425         }
426
427       if (now > dead_client_scan_time)
428         {
429           vl_mem_api_dead_client_scan (am, shm, now);
430           dead_client_scan_time = vlib_time_now (vm) + 10.0;
431         }
432     }
433
434   return 0;
435 }
436
437 VLIB_REGISTER_NODE (vl_api_clnt_node) = {
438   .function = vl_api_clnt_process,
439   .type = VLIB_NODE_TYPE_PROCESS,
440   .name = "api-rx-from-ring",
441   .state = VLIB_NODE_STATE_DISABLED,
442   .process_log2_n_stack_bytes = 18,
443 };
444
445 void
446 vl_mem_api_enable_disable (vlib_main_t *vm, int enable)
447 {
448   vlib_node_set_state (
449     vm, vl_api_clnt_node.index,
450     (enable ? VLIB_NODE_STATE_POLLING : VLIB_NODE_STATE_DISABLED));
451 }
452
453 static uword
454 api_rx_from_node (vlib_main_t *vm, vlib_node_runtime_t *node,
455                   vlib_frame_t *frame)
456 {
457   uword n_packets = frame->n_vectors;
458   uword n_left_from;
459   u32 *from;
460   static u8 *long_msg;
461
462   vec_validate (long_msg, 4095);
463   n_left_from = frame->n_vectors;
464   from = vlib_frame_vector_args (frame);
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         }
494       vl_msg_api_handler_no_trace_no_free (msg);
495     }
496
497   /* Free what we've been given. */
498   vlib_buffer_free (vm, vlib_frame_vector_args (frame), n_packets);
499
500   return n_packets;
501 }
502
503 VLIB_REGISTER_NODE (api_rx_from_node_node, static) = {
504   .function = api_rx_from_node,
505   .type = VLIB_NODE_TYPE_INTERNAL,
506   .vector_size = 4,
507   .name = "api-rx-from-node",
508 };
509
510 static void
511 vl_api_rpc_call_t_handler (vl_api_rpc_call_t *mp)
512 {
513   vl_api_rpc_call_reply_t *rmp;
514   int (*fp) (void *);
515   i32 rv = 0;
516   vlib_main_t *vm = vlib_get_main ();
517
518   if (mp->function == 0)
519     {
520       rv = -1;
521       clib_warning ("rpc NULL function pointer");
522     }
523
524   else
525     {
526       if (mp->need_barrier_sync)
527         vlib_worker_thread_barrier_sync (vm);
528
529       fp = uword_to_pointer (mp->function, int (*) (void *));
530       rv = fp (mp->data);
531
532       if (mp->need_barrier_sync)
533         vlib_worker_thread_barrier_release (vm);
534     }
535
536   if (mp->send_reply)
537     {
538       svm_queue_t *q = vl_api_client_index_to_input_queue (mp->client_index);
539       if (q)
540         {
541           rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
542           rmp->_vl_msg_id = ntohs (VL_API_RPC_CALL_REPLY);
543           rmp->context = mp->context;
544           rmp->retval = rv;
545           vl_msg_api_send_shmem (q, (u8 *) &rmp);
546         }
547     }
548   if (mp->multicast)
549     {
550       clib_warning ("multicast not yet implemented...");
551     }
552 }
553
554 static void
555 vl_api_rpc_call_reply_t_handler (vl_api_rpc_call_reply_t *mp)
556 {
557   clib_warning ("unimplemented");
558 }
559
560 void
561 vl_api_send_pending_rpc_requests (vlib_main_t *vm)
562 {
563   vlib_main_t *vm_global = vlib_get_first_main ();
564
565   ASSERT (vm != vm_global);
566
567   clib_spinlock_lock_if_init (&vm_global->pending_rpc_lock);
568   vec_append (vm_global->pending_rpc_requests, vm->pending_rpc_requests);
569   vec_reset_length (vm->pending_rpc_requests);
570   clib_spinlock_unlock_if_init (&vm_global->pending_rpc_lock);
571 }
572
573 always_inline void
574 vl_api_rpc_call_main_thread_inline (void *fp, u8 *data, u32 data_length,
575                                     u8 force_rpc)
576 {
577   vl_api_rpc_call_t *mp;
578   vlib_main_t *vm_global = vlib_get_first_main ();
579   vlib_main_t *vm = vlib_get_main ();
580
581   /* Main thread and not a forced RPC: call the function directly */
582   if ((force_rpc == 0) && (vlib_get_thread_index () == 0))
583     {
584       void (*call_fp) (void *);
585
586       vlib_worker_thread_barrier_sync (vm);
587
588       call_fp = fp;
589       call_fp (data);
590
591       vlib_worker_thread_barrier_release (vm);
592       return;
593     }
594
595   /* Otherwise, actually do an RPC */
596   mp = vl_msg_api_alloc_as_if_client (sizeof (*mp) + data_length);
597
598   clib_memset (mp, 0, sizeof (*mp));
599   clib_memcpy_fast (mp->data, data, data_length);
600   mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
601   mp->function = pointer_to_uword (fp);
602   mp->need_barrier_sync = 1;
603
604   /* Add to the pending vector. Thread 0 requires locking. */
605   if (vm == vm_global)
606     clib_spinlock_lock_if_init (&vm_global->pending_rpc_lock);
607   vec_add1 (vm->pending_rpc_requests, (uword) mp);
608   if (vm == vm_global)
609     clib_spinlock_unlock_if_init (&vm_global->pending_rpc_lock);
610 }
611
612 /*
613  * Check if called from worker threads.
614  * If so, make rpc call of fp through shmem.
615  * Otherwise, call fp directly
616  */
617 void
618 vl_api_rpc_call_main_thread (void *fp, u8 *data, u32 data_length)
619 {
620   vl_api_rpc_call_main_thread_inline (fp, data, data_length, /*force_rpc */
621                                       0);
622 }
623
624 /*
625  * Always make rpc call of fp through shmem, useful for calling from threads
626  * not setup as worker threads, such as DPDK callback thread
627  */
628 void
629 vl_api_force_rpc_call_main_thread (void *fp, u8 *data, u32 data_length)
630 {
631   vl_api_rpc_call_main_thread_inline (fp, data, data_length, /*force_rpc */
632                                       1);
633 }
634
635 static void
636 vl_api_trace_plugin_msg_ids_t_handler (vl_api_trace_plugin_msg_ids_t *mp)
637 {
638   api_main_t *am = vlibapi_get_main ();
639   vl_api_msg_range_t *rp;
640   uword *p;
641
642   /* Noop (except for tracing) during normal operation */
643   if (am->replay_in_progress == 0)
644     return;
645
646   p = hash_get_mem (am->msg_range_by_name, mp->plugin_name);
647   if (p == 0)
648     {
649       clib_warning ("WARNING: traced plugin '%s' not in current image",
650                     mp->plugin_name);
651       return;
652     }
653
654   rp = vec_elt_at_index (am->msg_ranges, p[0]);
655   if (rp->first_msg_id != clib_net_to_host_u16 (mp->first_msg_id))
656     {
657       clib_warning ("WARNING: traced plugin '%s' first message id %d not %d",
658                     mp->plugin_name, clib_net_to_host_u16 (mp->first_msg_id),
659                     rp->first_msg_id);
660     }
661
662   if (rp->last_msg_id != clib_net_to_host_u16 (mp->last_msg_id))
663     {
664       clib_warning ("WARNING: traced plugin '%s' last message id %d not %d",
665                     mp->plugin_name, clib_net_to_host_u16 (mp->last_msg_id),
666                     rp->last_msg_id);
667     }
668 }
669
670 #define foreach_rpc_api_msg                                                   \
671   _ (RPC_CALL, rpc_call)                                                      \
672   _ (RPC_CALL_REPLY, rpc_call_reply)
673
674 #define foreach_plugin_trace_msg _ (TRACE_PLUGIN_MSG_IDS, trace_plugin_msg_ids)
675
676 /*
677  * Set the rpc callback at our earliest possible convenience.
678  * This avoids ordering issues between thread_init() -> start_workers and
679  * an init function which we could define here. If we ever intend to use
680  * vlib all by itself, we can't create a link-time dependency on
681  * an init function here and a typical "call foo_init first"
682  * guitar lick.
683  */
684
685 extern void *rpc_call_main_thread_cb_fn;
686
687 static clib_error_t *
688 rpc_api_hookup (vlib_main_t *vm)
689 {
690   api_main_t *am = vlibapi_get_main ();
691 #define _(N, n)                                                               \
692   vl_msg_api_set_handlers (                                                   \
693     VL_API_##N, #n, vl_api_##n##_t_handler, vl_noop_handler, vl_noop_handler, \
694     vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 0 /* do not trace */);
695   foreach_rpc_api_msg;
696 #undef _
697
698 #define _(N, n)                                                               \
699   vl_msg_api_set_handlers (                                                   \
700     VL_API_##N, #n, vl_api_##n##_t_handler, vl_noop_handler, vl_noop_handler, \
701     vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 1 /* do trace */);
702   foreach_plugin_trace_msg;
703 #undef _
704
705   /* No reason to halt the parade to create a trace record... */
706   am->is_mp_safe[VL_API_TRACE_PLUGIN_MSG_IDS] = 1;
707   rpc_call_main_thread_cb_fn = vl_api_rpc_call_main_thread;
708   return 0;
709 }
710
711 VLIB_API_INIT_FUNCTION (rpc_api_hookup);
712
713 /*
714  * fd.io coding-style-patch-verification: ON
715  *
716  * Local Variables:
717  * eval: (c-set-style "gnu")
718  * End:
719  */