FD.io VPP  v16.06
Vector Packet Processing
memory_shared.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * memclnt_shared.c - API message handling, common code for both clients
4  * and the vlib process itself.
5  *
6  *
7  * Copyright (c) 2009 Cisco and/or its affiliates.
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at:
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *------------------------------------------------------------------
20  */
21 
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stddef.h>
25 #include <string.h>
26 #include <unistd.h>
27 #include <signal.h>
28 #include <vppinfra/format.h>
29 #include <vppinfra/byte_order.h>
30 #include <vppinfra/error.h>
31 #include <vlib/vlib.h>
32 #include <vlib/unix/unix.h>
33 #include <vlibmemory/api.h>
35 
37 
38 #define vl_typedefs
40 #undef vl_typedefs
41 
42 static inline void *vl_msg_api_alloc_internal(int nbytes, int pool)
43 {
44  int i;
45  msgbuf_t *rv;
46  ring_alloc_t *ap;
48  void *oldheap;
50  api_main_t *am = &api_main;
51 
52  shmem_hdr = am->shmem_hdr;
53 
54  if (shmem_hdr == 0) {
55  clib_warning ("shared memory header NULL");
56  return 0;
57  }
58 
59  /* account for the msgbuf_t header*/
60  nbytes += sizeof(msgbuf_t);
61 
62  if (shmem_hdr->vl_rings == 0) {
63  clib_warning ("vl_rings NULL");
64  return 0;
65  }
66 
67  if (shmem_hdr->client_rings == 0) {
68  clib_warning ("client_rings NULL");
69  return 0;
70  }
71 
72  ap = pool ? shmem_hdr->vl_rings : shmem_hdr->client_rings;
73  for (i = 0; i < vec_len (ap); i++) {
74  /* Too big? */
75  if (nbytes > ap[i].size) {
76  continue;
77  }
78 
79  q = ap[i].rp;
80  if (pool == 0) {
81  pthread_mutex_lock(&q->mutex);
82  }
83  rv = (msgbuf_t *) (&q->data[0] + q->head*q->elsize);
84  /*
85  * Is this item still in use?
86  */
87  if (rv->q) {
88  /* yes, loser; try next larger pool */
89  ap[i].misses++;
90  if (pool == 0)
91  pthread_mutex_unlock(&q->mutex);
92  continue;
93  }
94  /* OK, we have a winner */
95  ap[i].hits++;
96  /*
97  * Remember the source queue, although we
98  * don't need to know the queue to free the item.
99  */
100  rv->q = q;
101  q->head++;
102  if (q->head == q->maxsize)
103  q->head = 0;
104 
105  if (pool == 0)
106  pthread_mutex_unlock(&q->mutex);
107  goto out;
108  }
109 
110  /*
111  * Request too big, or head element of all size-compatible rings
112  * still in use. Fall back to shared-memory malloc.
113  */
114  am->ring_misses++;
115 
116  pthread_mutex_lock (&am->vlib_rp->mutex);
117  oldheap = svm_push_data_heap (am->vlib_rp);
118  rv = clib_mem_alloc(nbytes);
119  rv->q = 0;
120  svm_pop_heap (oldheap);
121  pthread_mutex_unlock (&am->vlib_rp->mutex);
122 
123  out:
124  rv->data_len = htonl(nbytes - sizeof(msgbuf_t));
125  return(rv->data);
126 }
127 
128 void *vl_msg_api_alloc (int nbytes)
129 {
130  int pool;
131  api_main_t *am = &api_main;
133 
134  /*
135  * Clients use pool-0, vlib proc uses pool 1
136  */
137  pool = (am->our_pid == shmem_hdr->vl_pid);
138  return vl_msg_api_alloc_internal (nbytes, pool);
139 }
140 
142 {
143  return vl_msg_api_alloc_internal (nbytes, 0);
144 }
145 
146 void vl_msg_api_free(void *a)
147 {
148  msgbuf_t *rv;
149  void *oldheap;
150  api_main_t *am = &api_main;
151 
152  rv = (msgbuf_t *)(((u8 *)a) - offsetof(msgbuf_t, data));
153 
154  /*
155  * Here's the beauty of the scheme. Only one proc/thread has
156  * control of a given message buffer. To free a buffer, we just clear the
157  * queue field, and leave. No locks, no hits, no errors...
158  */
159  if (rv->q) {
160  rv->q = 0;
161  return;
162  }
163 
164  pthread_mutex_lock (&am->vlib_rp->mutex);
165  oldheap = svm_push_data_heap (am->vlib_rp);
166  clib_mem_free (rv);
167  svm_pop_heap (oldheap);
168  pthread_mutex_unlock (&am->vlib_rp->mutex);
169 }
170 
171 static void vl_msg_api_free_nolock (void *a)
172 {
173  msgbuf_t *rv;
174  void *oldheap;
175  api_main_t *am = &api_main;
176 
177  rv = (msgbuf_t *)(((u8 *)a) - offsetof(msgbuf_t, data));
178  /*
179  * Here's the beauty of the scheme. Only one proc/thread has
180  * control of a given message buffer. To free a buffer, we just clear the
181  * queue field, and leave. No locks, no hits, no errors...
182  */
183  if (rv->q) {
184  rv->q = 0;
185  return;
186  }
187 
188  oldheap = svm_push_data_heap (am->vlib_rp);
189  clib_mem_free (rv);
190  svm_pop_heap (oldheap);
191 }
192 
193 void vl_set_memory_root_path (char *name)
194 {
195  api_main_t *am = &api_main;
196 
197  am->root_path = name;
198 }
199 
200 void vl_set_memory_uid (int uid)
201 {
202  api_main_t *am = &api_main;
203 
204  am->api_uid = uid;
205 }
206 
207 void vl_set_memory_gid (int gid)
208 {
209  api_main_t *am = &api_main;
210 
211  am->api_gid = gid;
212 }
213 
214 int vl_map_shmem (char *region_name, int is_vlib)
215 {
216  svm_map_region_args_t _a, *a = &_a;
217  svm_region_t *vlib_rp, *root_rp;
218  void *oldheap;
220  api_main_t *am = &api_main;
221  int i;
222  struct timespec ts, tsrem;
223 
224  if (is_vlib == 0)
226 
227  memset (a, 0, sizeof (*a));
228 
229  a->name = region_name;
230  a->size = 16<<20;
231  a->flags = SVM_FLAGS_MHEAP;
232  a->uid = am->api_uid;
233  a->gid = am->api_gid;
234 
235  vlib_rp = svm_region_find_or_create (a);
236 
237  if (vlib_rp == 0)
238  return (-2);
239 
240  pthread_mutex_lock (&vlib_rp->mutex);
241  /* Has someone else set up the shared-memory variable table? */
242  if (vlib_rp->user_ctx) {
243  am->shmem_hdr = (void *) vlib_rp->user_ctx;
244  am->our_pid = getpid();
245  if (is_vlib) {
247  uword old_msg;
248  /*
249  * application restart. Reset cached pids, API message
250  * rings, list of clients; otherwise, various things
251  * fail. (e.g. queue non-empty notification)
252  */
253 
254  /* ghosts keep the region from disappearing properly */
257  q = am->shmem_hdr->vl_input_queue;
258  am->shmem_hdr->vl_pid = getpid();
259  q->consumer_pid = am->shmem_hdr->vl_pid;
260  /* Drain the input queue, freeing msgs */
261  for (i = 0; i < 10; i++) {
262  if (pthread_mutex_trylock (&q->mutex) == 0) {
263  pthread_mutex_unlock (&q->mutex);
264  goto mutex_ok;
265  }
266  ts.tv_sec = 0;
267  ts.tv_nsec = 10000*1000; /* 10 ms */
268  while (nanosleep(&ts, &tsrem) < 0)
269  ts = tsrem;
270  }
271  /* Mutex buggered, "fix" it */
272  memset (&q->mutex, 0, sizeof (q->mutex));
273  clib_warning ("forcibly release main input queue mutex");
274 
275  mutex_ok:
276  am->vlib_rp = vlib_rp;
277  while (unix_shared_memory_queue_sub (q,
278  (u8 *)&old_msg,
279  1 /* nowait */)
280  != -2 /* queue underflow */) {
281  vl_msg_api_free_nolock ((void *)old_msg);
283  }
284  pthread_mutex_unlock (&vlib_rp->mutex);
285  root_rp = svm_get_root_rp();
286  ASSERT(root_rp);
287  /* Clean up the root region client list */
288  pthread_mutex_lock (&root_rp->mutex);
290  pthread_mutex_unlock (&root_rp->mutex);
291  }
292  pthread_mutex_unlock (&vlib_rp->mutex);
293  am->vlib_rp = vlib_rp;
294  vec_add1(am->mapped_shmem_regions, vlib_rp);
295  return 0;
296  }
297  /* Clients simply have to wait... */
298  if (!is_vlib) {
299  pthread_mutex_unlock (&vlib_rp->mutex);
300 
301  /* Wait up to 100 seconds... */
302  for (i = 0; i < 10000; i++) {
303  ts.tv_sec = 0;
304  ts.tv_nsec = 10000*1000; /* 10 ms */
305  while (nanosleep(&ts, &tsrem) < 0)
306  ts = tsrem;
307  if (vlib_rp->user_ctx)
308  goto ready;
309  }
310  /* Clean up and leave... */
311  svm_region_unmap (vlib_rp);
312  clib_warning ("region init fail");
313  return (-2);
314 
315  ready:
316  am->shmem_hdr = (void *)vlib_rp->user_ctx;
317  am->our_pid = getpid();
318  am->vlib_rp = vlib_rp;
319  vec_add1(am->mapped_shmem_regions, vlib_rp);
320  return 0;
321  }
322 
323  /* Nope, it's our problem... */
324 
325  oldheap = svm_push_data_heap (vlib_rp);
326 
327  vec_validate(shmem_hdr, 0);
328  shmem_hdr->version = VL_SHM_VERSION;
329 
330  /* vlib main input queue */
331  shmem_hdr->vl_input_queue =
332  unix_shared_memory_queue_init (1024, sizeof (uword), getpid(),
333  am->vlib_signal);
334 
335  /* Set up the msg ring allocator */
336 #define _(sz,n) \
337  do { \
338  ring_alloc_t _rp; \
339  _rp.rp = unix_shared_memory_queue_init ((n), (sz), 0, 0); \
340  _rp.size = (sz); \
341  _rp.nitems = n; \
342  _rp.hits = 0; \
343  _rp.misses = 0; \
344  vec_add1(shmem_hdr->vl_rings, _rp); \
345  } while (0);
346 
348 #undef _
349 
350 #define _(sz,n) \
351  do { \
352  ring_alloc_t _rp; \
353  _rp.rp = unix_shared_memory_queue_init ((n), (sz), 0, 0); \
354  _rp.size = (sz); \
355  _rp.nitems = n; \
356  _rp.hits = 0; \
357  _rp.misses = 0; \
358  vec_add1(shmem_hdr->client_rings, _rp); \
359  } while (0);
360 
362 #undef _
363 
364  am->shmem_hdr = shmem_hdr;
365  am->vlib_rp = vlib_rp;
366  am->our_pid = getpid();
367  if (is_vlib)
368  am->shmem_hdr->vl_pid = am->our_pid;
369 
370  svm_pop_heap (oldheap);
371 
372  /*
373  * After absolutely everything that a client might see is set up,
374  * declare the shmem region valid
375  */
376  vlib_rp->user_ctx = shmem_hdr;
377 
378  pthread_mutex_unlock (&vlib_rp->mutex);
379  vec_add1(am->mapped_shmem_regions, vlib_rp);
380  return 0;
381 }
382 
384 {
385  api_main_t *am = &api_main;
386 
388 }
389 
390 void vl_unmap_shmem (void)
391 {
392  svm_region_t *rp;
393  int i;
394  api_main_t *am = &api_main;
395 
396  if (! svm_get_root_rp())
397  return;
398 
399  for (i = 0; i < vec_len(am->mapped_shmem_regions); i++) {
400  rp = am->mapped_shmem_regions[i];
401  svm_region_unmap (rp);
402  }
403 
405  am->shmem_hdr = 0;
406 
407  svm_region_exit ();
408  /* $$$ more careful cleanup, valgrind run... */
409  vec_free (am->msg_handlers);
412 }
413 
415 {
416  api_main_t *am = &api_main;
417  uword *trace = (uword *)elem;
418 
419  if (am->tx_trace && am->tx_trace->enabled)
420  vl_msg_api_trace(am, am->tx_trace, (void *)trace[0]);
421 
422  (void)unix_shared_memory_queue_add(q, elem, 0 /* nowait */);
423 }
424 
426 {
427  api_main_t *am = &api_main;
428  uword *trace = (uword *)elem;
429 
430  if (am->tx_trace && am->tx_trace->enabled)
431  vl_msg_api_trace(am, am->tx_trace, (void *)trace[0]);
432 
434 }
435 
438 {
439  api_main_t *am = &api_main;
440  int rv;
441 
442  am->my_client_index = mp->index;
444  mp->handle;
445 
446  rv = ntohl(mp->response);
447 
448  if (rv < 0)
449  clib_warning ("WARNING: API mismatch detected");
450 }
451 
453  __attribute__((weak));
454 
456 {
457  int i;
458 
459  for (i = 0; i < ARRAY_LEN(mp->api_versions); i++)
460  mp->api_versions[i] = 0;
461 }
462 
463 int vl_client_connect (char *name, int ctx_quota, int input_queue_size)
464 {
465  svm_region_t *svm;
468  unix_shared_memory_queue_t *vl_input_queue;
470  int rv=0;
471  void *oldheap;
472  api_main_t *am = &api_main;
473 
474  if (am->my_registration) {
475  clib_warning ("client %s already connected...", name);
476  return -1;
477  }
478 
479  if (am->vlib_rp == 0) {
480  clib_warning ("am->vlib_rp NULL");
481  return -1;
482  }
483 
484  svm = am->vlib_rp;
485  shmem_hdr = am->shmem_hdr;
486 
487  if (shmem_hdr == 0 || shmem_hdr->vl_input_queue == 0) {
488  clib_warning ("shmem_hdr / input queue NULL");
489  return -1;
490  }
491 
492  pthread_mutex_lock (&svm->mutex);
493  oldheap = svm_push_data_heap(svm);
494  vl_input_queue =
495  unix_shared_memory_queue_init (input_queue_size, sizeof(uword),
496  getpid(), 0);
497  pthread_mutex_unlock(&svm->mutex);
498  svm_pop_heap (oldheap);
499 
500  am->my_client_index = ~0;
501  am->my_registration = 0;
502  am->vl_input_queue = vl_input_queue;
503 
505  memset(mp, 0, sizeof (*mp));
506  mp->_vl_msg_id = ntohs(VL_API_MEMCLNT_CREATE);
507  mp->ctx_quota = ctx_quota;
508  mp->input_queue = (uword)vl_input_queue;
509  strncpy ((char *) mp->name, name, sizeof(mp->name)-1);
510 
512 
513  vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *)&mp);
514 
515  while (1) {
516  int qstatus;
517  struct timespec ts, tsrem;
518  int i;
519 
520  /* Wait up to 10 seconds */
521  for (i = 0; i < 1000; i++) {
522  qstatus = unix_shared_memory_queue_sub (vl_input_queue, (u8 *)&rp,
523  1 /* nowait */);
524  if (qstatus == 0)
525  goto read_one_msg;
526  ts.tv_sec = 0;
527  ts.tv_nsec = 10000*1000; /* 10 ms */
528  while (nanosleep(&ts, &tsrem) < 0)
529  ts = tsrem;
530  }
531  /* Timeout... */
532  clib_warning ("memclnt_create_reply timeout");
533  return -1;
534 
535  read_one_msg:
536  if (ntohs(rp->_vl_msg_id) != VL_API_MEMCLNT_CREATE_REPLY) {
537  clib_warning ("unexpected reply: id %d", ntohs(rp->_vl_msg_id));
538  continue;
539  }
540  rv = clib_net_to_host_u32(rp->response);
541 
542  vl_msg_api_handler((void *)rp);
543  break;
544  }
545  return (rv);
546 }
547 
550 {
551  void *oldheap;
552  api_main_t *am = &api_main;
553 
554  pthread_mutex_lock (&am->vlib_rp->mutex);
555  oldheap = svm_push_data_heap(am->vlib_rp);
557  pthread_mutex_unlock (&am->vlib_rp->mutex);
558  svm_pop_heap (oldheap);
559 
560  am->my_client_index = ~0;
561  am->my_registration = 0;
562  am->vl_input_queue = 0;
563 }
564 
566 {
569  unix_shared_memory_queue_t *vl_input_queue;
571  time_t begin;
572  api_main_t *am = &api_main;
573 
574  ASSERT(am->vlib_rp);
575  shmem_hdr = am->shmem_hdr;
576  ASSERT(shmem_hdr && shmem_hdr->vl_input_queue);
577 
578  vl_input_queue = am->vl_input_queue;
579 
581  memset(mp, 0, sizeof (*mp));
582  mp->_vl_msg_id = ntohs(VL_API_MEMCLNT_DELETE);
583  mp->index = am->my_client_index;
584  mp->handle = (uword) am->my_registration;
585 
586  vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *)&mp);
587 
588  /*
589  * Have to be careful here, in case the client is disconnecting
590  * because e.g. the vlib process died, or is unresponsive.
591  */
592 
593  begin = time (0);
594  while (1) {
595  time_t now;
596 
597  now = time (0);
598 
599  if (now >= (begin + 2)) {
600  clib_warning ("peer unresponsive, give up");
601  am->my_client_index = ~0;
602  am->my_registration = 0;
603  am->shmem_hdr = 0;
604  break;
605  }
606  if (unix_shared_memory_queue_sub (vl_input_queue, (u8 *)&rp, 1) < 0)
607  continue;
608 
609  /* drain the queue */
610  if (ntohs(rp->_vl_msg_id) != VL_API_MEMCLNT_DELETE_REPLY) {
611  vl_msg_api_handler ((void *)rp);
612  continue;
613  }
614  vl_msg_api_handler((void *)rp);
615  break;
616  }
617 }
618 
619 static inline vl_api_registration_t
621 {
622  vl_api_registration_t **regpp;
623  vl_api_registration_t *regp;
624  api_main_t *am = &api_main;
625  u32 index;
626 
627  index = vl_msg_api_handle_get_index (handle);
629  != vl_msg_api_handle_get_epoch (handle)) {
631  return 0;
632  }
633 
634  regpp = am->vl_clients + index;
635 
636  if (pool_is_free(am->vl_clients, regpp)) {
638  return 0;
639  }
640  regp = *regpp;
641  return (regp);
642 }
643 
645 {
647 }
648 
650 {
651  vl_api_registration_t *regp;
652 
654  if (!regp)
655  return 0;
656  return (regp->vl_input_queue);
657 }
658 
659 #define foreach_api_client_msg \
660 _(MEMCLNT_CREATE_REPLY, memclnt_create_reply) \
661 _(MEMCLNT_DELETE_REPLY, memclnt_delete_reply)
662 
663 int vl_client_api_map (char *region_name)
664 {
665  int rv;
666 
667  if ((rv = vl_map_shmem (region_name, 0 /* is_vlib */)) < 0) {
668  return rv;
669  }
670 
671 #define _(N,n) \
672  vl_msg_api_set_handlers(VL_API_##N, 0 /* name */, \
673  vl_api_##n##_t_handler, \
674  0/* cleanup */, 0/* endian */, 0/* print */, \
675  sizeof(vl_api_##n##_t), 1);
677 #undef _
678  return 0;
679 }
680 
682 {
683  vl_unmap_shmem();
684 }
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:394
static void * vl_msg_api_alloc_internal(int nbytes, int pool)
Definition: memory_shared.c:42
void vl_client_api_unmap(void)
svm_region_t * svm_get_root_rp(void)
Definition: svm.c:53
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
int vl_client_api_map(char *region_name)
static void svm_pop_heap(void *oldheap)
Definition: svm.h:179
a
Definition: bitmap.h:393
vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: memory_vlib.c:1046
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
#define foreach_clnt_aring_size
Definition: api.h:59
u32 application_restarts
Definition: api.h:82
void vl_set_memory_uid(int uid)
always_inline void clib_mem_free(void *p)
Definition: mem.h:149
unix_shared_memory_queue_t * vl_input_queue
Definition: api.h:71
int my_client_index
Definition: api.h:148
void unix_shared_memory_queue_free(unix_shared_memory_queue_t *q)
void vl_unmap_shmem(void)
int vl_client_connect(char *name, int ctx_quota, int input_queue_size)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:480
int api_uid
Definition: api.h:139
ring_alloc_t * client_rings
Definition: api.h:79
u8 data[0]
Definition: api.h:93
#define pool_is_free(P, E)
Definition: pool.h:189
static vl_api_registration_t * vl_api_client_index_to_registration_internal(u32 handle)
void * vl_msg_api_alloc(int nbytes)
int api_gid
Definition: api.h:138
void vl_set_memory_root_path(char *name)
unix_shared_memory_queue_t * vl_input_queue
Definition: api.h:142
#define SVM_FLAGS_MHEAP
Definition: svm.h:32
api_main_t api_main
Definition: api.h:162
int our_pid
Definition: api.h:122
vl_api_registration_t * my_registration
Definition: api.h:154
u32 ring_misses
Definition: api.h:116
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:172
vl_api_registration_t ** vl_clients
Definition: api.h:126
void * svm_region_find_or_create(svm_map_region_args_t *a)
Definition: svm.c:692
volatile void * user_ctx
Definition: svm.h:51
char * name
Definition: svm.h:71
int vl_map_shmem(char *region_name, int is_vlib)
svm_region_t * vlib_rp
Definition: api.h:123
int unix_shared_memory_queue_add_nolock(unix_shared_memory_queue_t *q, u8 *elem)
#define clib_warning(format, args...)
Definition: error.h:59
struct vl_shmem_hdr_ * shmem_hdr
Definition: api.h:125
vl_shmem_hdr_t * shmem_hdr
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
volatile int vl_pid
Definition: api.h:68
void vl_register_mapped_shmem_region(svm_region_t *rp)
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
void(** msg_print_handlers)(void *, void *)
Definition: api.h:111
void vl_msg_api_send_shmem_nolock(unix_shared_memory_queue_t *q, u8 *elem)
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
void svm_region_exit()
Definition: svm.c:918
static u32 vl_msg_api_handle_get_index(u32 index)
Definition: api.h:105
u8 enabled
Definition: api.h:78
int unix_shared_memory_queue_sub(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
ring_alloc_t * vl_rings
Definition: api.h:76
always_inline void * clib_mem_alloc(uword size)
Definition: mem.h:109
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:298
unix_shared_memory_queue_t * vl_input_queue
Definition: api.h:51
unix_shared_memory_queue_t * q
Definition: api.h:91
void vl_msg_api_trace(api_main_t *am, vl_api_trace_t *tp, void *msg)
Definition: api_shared.c:72
void vl_set_memory_gid(int gid)
static void vl_msg_api_free_nolock(void *a)
void vl_msg_api_free(void *a)
#define ARRAY_LEN(x)
Definition: clib.h:59
#define VL_SHM_VERSION
Definition: api.h:96
struct msgbuf_ msgbuf_t
#define foreach_vl_aring_size
Definition: api.h:54
int version
Definition: api.h:65
vl_api_trace_t * tx_trace
Definition: api.h:119
#define ASSERT(truth)
#define VL_API_EPOCH_MASK
Definition: api.h:98
unsigned int u32
Definition: types.h:88
void svm_region_init_chroot(char *root_path)
Definition: svm.c:682
static void vl_api_memclnt_create_reply_t_handler(vl_api_memclnt_create_reply_t *mp)
u32 data_len
Definition: api.h:92
Definition: api.h:90
unix_shared_memory_queue_t * unix_shared_memory_queue_init(int nels, int elsize, int consumer_pid, int signal_when_queue_non_empty)
u32 size
Definition: vhost-user.h:74
u32 misses
Definition: api.h:46
u32 restart_reclaims
Definition: api.h:85
i32 vlib_signal
Definition: api.h:156
u64 uword
Definition: types.h:112
char * root_path
Definition: api.h:159
#define foreach_api_client_msg
void(** msg_endian_handlers)(void *)
Definition: api.h:110
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
void vl_msg_api_handler(void *the_msg)
Definition: api_shared.c:458
void svm_region_unmap(void *rp_arg)
Definition: svm.c:802
void svm_client_scan_this_region_nolock(svm_region_t *rp)
Definition: svm.c:963
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void vl_api_memclnt_delete_reply_t_handler(vl_api_memclnt_delete_reply_t *mp)
void vl_client_add_api_signatures(vl_api_memclnt_create_t *mp)
unix_shared_memory_queue_t * rp
Definition: api.h:42
void vl_msg_api_increment_missing_client_counter(void)
Definition: api_shared.c:46
void(** msg_handlers)(void *)
Definition: api.h:107
void * vl_msg_api_alloc_as_if_client(int nbytes)
static u32 vl_msg_api_handle_get_epoch(u32 index)
Definition: api.h:101
svm_region_t ** mapped_shmem_regions
Definition: api.h:124
u32 hits
Definition: api.h:45
void vl_client_disconnect(void)
pthread_mutex_t mutex
Definition: svm.h:41
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static svm_region_t * root_rp
Definition: svm.c:46