FD.io VPP  v18.01-8-g0eacf49
Vector Packet Processing
socket.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2016 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #define _GNU_SOURCE
19 #include <stdint.h>
20 #include <net/if.h>
21 #include <sys/types.h>
22 #include <fcntl.h>
23 #include <sys/ioctl.h>
24 #include <sys/socket.h>
25 #include <sys/un.h>
26 #include <sys/uio.h>
27 #include <sys/mman.h>
28 #include <sys/prctl.h>
29 #include <sys/eventfd.h>
30 #include <inttypes.h>
31 #include <limits.h>
32 
33 #include <vlib/vlib.h>
34 #include <vlib/unix/unix.h>
35 #include <vnet/plugin/plugin.h>
36 #include <vnet/ethernet/ethernet.h>
37 #include <vpp/app/version.h>
38 
39 #include <memif/memif.h>
40 #include <memif/private.h>
41 
42 void
44 {
45  memif_file_del_by_index ((*s)->private_data);
46  clib_mem_free (*s);
47  *s = 0;
48 }
49 
50 static u8 *
51 memif_str2vec (uint8_t * str, int len)
52 {
53  u8 *s = 0;
54  int i;
55 
56  if (str[0] == 0)
57  return s;
58 
59  for (i = 0; i < len; i++)
60  {
61  vec_add1 (s, str[i]);
62  if (str[i] == 0)
63  return s;
64  }
65  vec_add1 (s, 0);
66 
67  return s;
68 }
69 
70 static void
72 {
74  clib_fifo_add2 (mif->msg_queue, e);
75 
77  e->fd = -1;
78 }
79 
80 static clib_error_t *
82 {
83  u8 *s;
84  memif_msg_t msg = { 0 };
85  memif_msg_hello_t *h = &msg.hello;
93  s = format (0, "VPP %s%c", VPP_BUILD_VER, 0);
94  strncpy ((char *) h->name, (char *) s, sizeof (h->name) - 1);
95  vec_free (s);
96  return clib_socket_sendmsg (sock, &msg, sizeof (memif_msg_t), 0, 0);
97 }
98 
99 static void
101 {
102  u8 *s;
104  clib_fifo_add2 (mif->msg_queue, e);
105  memif_msg_init_t *i = &e->msg.init;
106 
108  e->fd = -1;
109  i->version = MEMIF_VERSION;
110  i->id = mif->id;
111  i->mode = mif->mode;
112  s = format (0, "VPP %s%c", VPP_BUILD_VER, 0);
113  strncpy ((char *) i->name, (char *) s, sizeof (i->name) - 1);
114  if (mif->secret)
115  strncpy ((char *) i->secret, (char *) mif->secret,
116  sizeof (i->secret) - 1);
117  vec_free (s);
118 }
119 
120 static void
122 {
124  clib_fifo_add2 (mif->msg_queue, e);
126 
128  e->fd = mif->regions[region].fd;
129  ar->index = region;
130  ar->size = mif->regions[region].region_size;
131 }
132 
133 static void
134 memif_msg_enq_add_ring (memif_if_t * mif, u8 index, u8 direction)
135 {
137  clib_fifo_add2 (mif->msg_queue, e);
139  memif_queue_t *mq;
140 
141  ASSERT ((mif->flags & MEMIF_IF_FLAG_IS_SLAVE) != 0);
142 
144 
145  if (direction == MEMIF_RING_M2S)
146  mq = vec_elt_at_index (mif->rx_queues, index);
147  else
148  mq = vec_elt_at_index (mif->tx_queues, index);
149 
150  e->fd = mq->int_fd;
151  ar->index = index;
152  ar->region = mq->region;
153  ar->offset = mq->offset;
154  ar->log2_ring_size = mq->log2_ring_size;
155  ar->flags = (direction == MEMIF_RING_S2M) ? MEMIF_MSG_ADD_RING_FLAG_S2M : 0;
156 }
157 
158 static void
160 {
162  clib_fifo_add2 (mif->msg_queue, e);
164  u8 *s;
165 
167  e->fd = -1;
168  s = format (0, "%U%c", format_memif_device_name, mif->dev_instance, 0);
169  strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name) - 1);
170  vec_free (s);
171 }
172 
173 static void
175 {
177  clib_fifo_add2 (mif->msg_queue, e);
179  u8 *s;
180 
182  e->fd = -1;
183  s = format (0, "%U%c", format_memif_device_name, mif->dev_instance, 0);
184  strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name) - 1);
185  vec_free (s);
186 }
187 
188 clib_error_t *
190 {
191  memif_msg_t msg = { 0 };
194 
195  d->code = err->code;
196  strncpy ((char *) d->string, (char *) err->what, sizeof (d->string) - 1);
197 
198  return clib_socket_sendmsg (mif->sock, &msg, sizeof (memif_msg_t), 0, 0);
199 }
200 
201 static clib_error_t *
203 {
204  memif_msg_hello_t *h = &msg->hello;
205 
206  if (msg->hello.min_version > MEMIF_VERSION ||
208  return clib_error_return (0, "incompatible protocol version");
209 
210  mif->run.num_s2m_rings = clib_min (h->max_s2m_ring + 1,
211  mif->cfg.num_s2m_rings);
212  mif->run.num_m2s_rings = clib_min (h->max_m2s_ring + 1,
213  mif->cfg.num_m2s_rings);
215  mif->cfg.log2_ring_size);
216  mif->run.buffer_size = mif->cfg.buffer_size;
217 
218  mif->remote_name = memif_str2vec (h->name, sizeof (h->name));
219 
220  return 0;
221 }
222 
223 static clib_error_t *
225  clib_socket_t * sock, uword socket_file_index)
226 {
227  memif_main_t *mm = &memif_main;
228  memif_socket_file_t *msf =
229  vec_elt_at_index (mm->socket_files, socket_file_index);
230  memif_msg_init_t *i = &msg->init;
231  memif_if_t *mif, tmp;
232  clib_error_t *err;
233  uword *p;
234 
235  if (i->version != MEMIF_VERSION)
236  {
237  memif_file_del_by_index (sock->private_data);
238  return clib_error_return (0, "unsupported version");
239  }
240 
241  p = mhash_get (&msf->dev_instance_by_id, &i->id);
242 
243  if (!p)
244  {
245  err = clib_error_return (0, "unmatched interface id");
246  goto error;
247  }
248 
249  mif = vec_elt_at_index (mm->interfaces, p[0]);
250 
251  if (mif->flags & MEMIF_IF_FLAG_IS_SLAVE)
252  {
253  err = clib_error_return (0, "cannot connect to slave");
254  goto error;
255  }
256 
257  if (mif->sock)
258  {
259  err = clib_error_return (0, "already connected");
260  goto error;
261  }
262 
263  if (i->mode != mif->mode)
264  {
265  err = clib_error_return (0, "mode mismatch");
266  goto error;
267  }
268 
269  mif->sock = sock;
270  hash_set (msf->dev_instance_by_fd, mif->sock->fd, mif->dev_instance);
271  mif->remote_name = memif_str2vec (i->name, sizeof (i->name));
272  *mifp = mif;
273 
274  if (mif->secret)
275  {
276  u8 *s;
277  int r;
278  s = memif_str2vec (i->secret, sizeof (i->secret));
279  if (s == 0)
280  return clib_error_return (0, "secret required");
281 
282  r = vec_cmp (s, mif->secret);
283  vec_free (s);
284 
285  if (r)
286  return clib_error_return (0, "incorrect secret");
287  }
288 
289  return 0;
290 
291 error:
292  tmp.sock = sock;
293  memif_msg_send_disconnect (&tmp, err);
294  memif_socket_close (&sock);
295  return err;
296 }
297 
298 static clib_error_t *
300 {
302  memif_region_t *mr;
303  if (fd < 0)
304  return clib_error_return (0, "missing memory region fd");
305 
306  if (ar->index != vec_len (mif->regions))
307  return clib_error_return (0, "unexpected region index");
308 
309  if (ar->index > MEMIF_MAX_REGION)
310  return clib_error_return (0, "too many regions");
311 
313  mr = vec_elt_at_index (mif->regions, ar->index);
314  mr->fd = fd;
315  mr->region_size = ar->size;
316 
317  return 0;
318 }
319 
320 static clib_error_t *
322 {
323  memif_msg_add_ring_t *ar = &msg->add_ring;
324  memif_queue_t *mq;
325 
326  if (fd < 0)
327  return clib_error_return (0, "missing ring interrupt fd");
328 
330  {
331  if (ar->index != vec_len (mif->rx_queues))
332  return clib_error_return (0, "unexpected ring index");
333 
334  if (ar->index > MEMIF_MAX_S2M_RING)
335  return clib_error_return (0, "too many rings");
336 
338  mq = vec_elt_at_index (mif->rx_queues, ar->index);
339  mif->run.num_s2m_rings = vec_len (mif->rx_queues);
340  }
341  else
342  {
343  if (ar->index != vec_len (mif->tx_queues))
344  return clib_error_return (0, "unexpected ring index");
345 
346  if (ar->index > MEMIF_MAX_M2S_RING)
347  return clib_error_return (0, "too many rings");
348 
350  mq = vec_elt_at_index (mif->tx_queues, ar->index);
351  mif->run.num_m2s_rings = vec_len (mif->tx_queues);
352  }
353 
354  mq->int_fd = fd;
355  mq->int_clib_file_index = ~0;
356  mq->log2_ring_size = ar->log2_ring_size;
357  mq->region = ar->region;
358  mq->offset = ar->offset;
359 
360  return 0;
361 }
362 
363 static clib_error_t *
365 {
366  clib_error_t *err;
367  memif_msg_connect_t *c = &msg->connect;
368 
369  if ((err = memif_connect (mif)))
370  return err;
371 
372  mif->remote_if_name = memif_str2vec (c->if_name, sizeof (c->if_name));
373 
374  return 0;
375 }
376 
377 static clib_error_t *
379 {
380  clib_error_t *err;
382 
383  if ((err = memif_connect (mif)))
384  return err;
385 
386  mif->remote_if_name = memif_str2vec (c->if_name, sizeof (c->if_name));
387  return 0;
388 }
389 
390 static clib_error_t *
392 {
394 
395  mif->remote_disc_string = memif_str2vec (d->string, sizeof (d->string));
396  return clib_error_return (0, "disconnect received");
397 }
398 
399 static clib_error_t *
401 {
402  memif_msg_t msg = { 0 };
403  clib_error_t *err = 0;
404  int fd = -1;
405  int i;
406  memif_if_t *mif = *mifp;
407 
408  err = clib_socket_recvmsg (sock, &msg, sizeof (memif_msg_t), &fd, 1);
409  if (err)
410  return err;
411 
412  if (mif == 0 && msg.type != MEMIF_MSG_TYPE_INIT)
413  {
414  memif_socket_close (&sock);
415  return clib_error_return (0, "unexpected message received");
416  }
417 
418  DBG ("Message type %u received", msg.type);
419  /* process the message based on its type */
420  switch (msg.type)
421  {
422  case MEMIF_MSG_TYPE_ACK:
423  break;
424 
426  if ((err = memif_msg_receive_hello (mif, &msg)))
427  return err;
428  if ((err = memif_init_regions_and_queues (mif)))
429  return err;
430  memif_msg_enq_init (mif);
431  memif_msg_enq_add_region (mif, 0);
432  vec_foreach_index (i, mif->tx_queues)
434  vec_foreach_index (i, mif->rx_queues)
436  memif_msg_enq_connect (mif);
437  break;
438 
439  case MEMIF_MSG_TYPE_INIT:
440  if ((err = memif_msg_receive_init (mifp, &msg, sock, uf->private_data)))
441  return err;
442  mif = *mifp;
443  memif_msg_enq_ack (mif);
444  break;
445 
447  if ((err = memif_msg_receive_add_region (mif, &msg, fd)))
448  return err;
449  memif_msg_enq_ack (mif);
450  break;
451 
453  if ((err = memif_msg_receive_add_ring (mif, &msg, fd)))
454  return err;
455  memif_msg_enq_ack (mif);
456  break;
457 
459  if ((err = memif_msg_receive_connect (mif, &msg)))
460  return err;
462  break;
463 
465  if ((err = memif_msg_receive_connected (mif, &msg)))
466  return err;
467  break;
468 
470  if ((err = memif_msg_receive_disconnect (mif, &msg)))
471  return err;
472  break;
473 
474  default:
475  err = clib_error_return (0, "unknown message type (0x%x)", msg.type);
476  return err;
477  }
478 
479  if (clib_fifo_elts (mif->msg_queue))
481  mif->sock->private_data, 1);
482  return 0;
483 }
484 
485 clib_error_t *
487 {
488  memif_main_t *mm = &memif_main;
489  memif_socket_file_t *msf =
491  uword *p;
492  memif_if_t *mif = 0;
493  clib_socket_t *sock = 0;
494  clib_error_t *err = 0;
495 
497  if (p)
498  {
499  mif = vec_elt_at_index (mm->interfaces, p[0]);
500  sock = mif->sock;
501  }
502  else
503  {
504  /* This is new connection, remove index from pending vector */
505  int i;
507  if (msf->pending_clients[i]->fd == uf->file_descriptor)
508  {
509  sock = msf->pending_clients[i];
510  vec_del1 (msf->pending_clients, i);
511  break;
512  }
513  ASSERT (sock != 0);
514  }
515  err = memif_msg_receive (&mif, sock, uf);
516  if (err)
517  {
518  memif_disconnect (mif, err);
519  clib_error_free (err);
520  }
521  return 0;
522 }
523 
524 clib_error_t *
526 {
527  memif_main_t *mm = &memif_main;
528  clib_error_t *err;
530  err = memif_msg_receive (&mif, mif->sock, uf);
531  if (err)
532  {
533  memif_disconnect (mif, err);
534  clib_error_free (err);
535  }
536  return 0;
537 }
538 
539 static clib_error_t *
541 {
543  clib_fifo_sub2 (mif->msg_queue, e);
545  mif->sock->private_data, 0);
546  return clib_socket_sendmsg (mif->sock, &e->msg, sizeof (memif_msg_t),
547  &e->fd, e->fd > -1 ? 1 : 0);
548 }
549 
550 clib_error_t *
552 {
553  memif_main_t *mm = &memif_main;
554  memif_socket_file_t *msf =
556  uword *p;
557  memif_if_t *mif;
558 
560  if (!p)
561  return 0;
562 
563  mif = vec_elt_at_index (mm->interfaces, p[0]);
564  return memif_conn_fd_write_ready (uf, mif);
565 }
566 
567 clib_error_t *
569 {
570  memif_main_t *mm = &memif_main;
572  return memif_conn_fd_write_ready (uf, mif);
573 }
574 
575 clib_error_t *
577 {
578  memif_main_t *mm = &memif_main;
580  clib_error_t *err;
581 
582  err = clib_error_return (0, "connection fd error");
583  memif_disconnect (mif, err);
584  clib_error_free (err);
585 
586  return 0;
587 }
588 
589 clib_error_t *
591 {
592  memif_main_t *mm = &memif_main;
593  memif_socket_file_t *msf =
595  uword *p;
596 
597 
599  if (p)
600  {
601  memif_if_t *mif;
602  clib_error_t *err;
603  mif = vec_elt_at_index (mm->interfaces, p[0]);
604  err = clib_error_return (0, "connection fd error");
605  memif_disconnect (mif, err);
606  clib_error_free (err);
607  }
608  else
609  {
610  int i;
612  if (msf->pending_clients[i]->fd == uf->file_descriptor)
613  {
614  clib_socket_t *s = msf->pending_clients[i];
615  memif_socket_close (&s);
616  vec_del1 (msf->pending_clients, i);
617  return 0;
618  }
619  }
620 
621  clib_warning ("Error on unknown file descriptor %d", uf->file_descriptor);
622  memif_file_del (uf);
623  return 0;
624 }
625 
626 
627 clib_error_t *
629 {
630  memif_main_t *mm = &memif_main;
631  memif_socket_file_t *msf =
633  clib_file_t template = { 0 };
634  clib_error_t *err;
635  clib_socket_t *client;
636 
637  client = clib_mem_alloc (sizeof (clib_socket_t));
638  memset (client, 0, sizeof (clib_socket_t));
639  err = clib_socket_accept (msf->sock, client);
640  if (err)
641  goto error;
642 
643  template.read_function = memif_master_conn_fd_read_ready;
644  template.write_function = memif_master_conn_fd_write_ready;
645  template.error_function = memif_master_conn_fd_error;
646  template.file_descriptor = client->fd;
647  template.private_data = uf->private_data;
648 
649  memif_file_add (&client->private_data, &template);
650 
651  err = memif_msg_enq_hello (client);
652  if (err)
653  {
654  clib_socket_close (client);
655  goto error;
656  }
657 
658  vec_add1 (msf->pending_clients, client);
659 
660  return 0;
661 
662 error:
663  clib_error_report (err);
664  clib_mem_free (client);
665  return err;
666 }
667 
668 /*
669  * fd.io coding-style-patch-verification: ON
670  *
671  * Local Variables:
672  * eval: (c-set-style "gnu")
673  * End:
674  */
memif_if_t * interfaces
Definition: private.h:181
memif_version_t max_version
Definition: memif.h:76
memif_interface_mode_t mode
Definition: memif.h:87
static clib_error_t * memif_msg_receive_connect(memif_if_t *mif, memif_msg_t *msg)
Definition: socket.c:364
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
clib_error_t * memif_master_conn_fd_error(clib_file_t *uf)
Definition: socket.c:590
#define clib_min(x, y)
Definition: clib.h:340
clib_error_t * memif_conn_fd_accept_ready(clib_file_t *uf)
Definition: socket.c:628
u8 * secret
Definition: private.h:141
#define clib_fifo_sub2(f, p)
Definition: fifo.h:232
memif_msg_add_region_t add_region
Definition: memif.h:131
clib_error_t * memif_slave_conn_fd_write_ready(clib_file_t *uf)
Definition: socket.c:568
clib_socket_t ** pending_clients
Definition: private.h:69
static uword clib_fifo_elts(void *v)
Definition: fifo.h:66
#define memif_file_del(a)
Definition: private.h:61
static clib_error_t * memif_msg_receive_connected(memif_if_t *mif, memif_msg_t *msg)
Definition: socket.c:378
uint8_t string[96]
Definition: memif.h:121
static clib_error_t * memif_msg_receive_add_ring(memif_if_t *mif, memif_msg_t *msg, int fd)
Definition: socket.c:321
memif_socket_file_t * socket_files
Definition: private.h:184
memif_log2_ring_size_t log2_ring_size
Definition: private.h:154
struct memif_if_t::@366 run
struct memif_if_t::@365 cfg
memif_msg_add_ring_t add_ring
Definition: memif.h:132
#define MEMIF_MSG_ADD_RING_FLAG_S2M
Definition: memif.h:101
#define MEMIF_MAX_REGION
Definition: private.h:28
u32 file_descriptor
Definition: file.h:53
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
memif_region_index_t region
Definition: memif.h:103
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:443
u8 num_m2s_rings
Definition: private.h:156
static uword clib_file_set_data_available_to_write(clib_file_main_t *um, u32 clib_file_index, uword is_available)
Definition: file.h:111
memif_version_t min_version
Definition: memif.h:75
uint8_t secret[24]
Definition: memif.h:88
#define memif_file_del_by_index(a)
Definition: private.h:62
clib_error_t * memif_slave_conn_fd_read_ready(clib_file_t *uf)
Definition: socket.c:525
memif_interface_id_t id
Definition: memif.h:86
void memif_socket_close(clib_socket_t **s)
Definition: socket.c:43
uint8_t name[32]
Definition: memif.h:74
u8 * remote_name
Definition: private.h:149
static clib_error_t * memif_msg_receive(memif_if_t **mifp, clib_socket_t *sock, clib_file_t *uf)
Definition: socket.c:400
static clib_error_t * memif_msg_receive_hello(memif_if_t *mif, memif_msg_t *msg)
Definition: socket.c:202
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:151
static clib_error_t * memif_conn_fd_write_ready(clib_file_t *uf, memif_if_t *mif)
Definition: socket.c:540
memif_ring_index_t max_m2s_ring
Definition: memif.h:78
clib_error_t * memif_init_regions_and_queues(memif_if_t *mif)
Definition: memif.c:266
u16 buffer_size
Definition: private.h:157
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
Definition: error.h:99
clib_file_main_t file_main
Definition: main.c:63
static clib_error_t * clib_socket_recvmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:158
memif_region_offset_t offset
Definition: private.h:99
static void memif_msg_enq_add_region(memif_if_t *mif, u8 region)
Definition: socket.c:121
#define MEMIF_MAX_M2S_RING
Definition: private.h:26
memif_region_offset_t offset
Definition: memif.h:104
#define memif_file_add(a, b)
Definition: private.h:58
#define MEMIF_MAX_LOG2_RING_SIZE
Definition: private.h:29
mhash_t dev_instance_by_id
Definition: private.h:74
static void memif_msg_enq_init(memif_if_t *mif)
Definition: socket.c:100
clib_error_t * memif_slave_conn_fd_error(clib_file_t *uf)
Definition: socket.c:576
static u8 * memif_str2vec(uint8_t *str, int len)
Definition: socket.c:51
memif_msg_init_t init
Definition: memif.h:130
memif_ring_index_t index
Definition: memif.h:102
clib_error_t * memif_msg_send_disconnect(memif_if_t *mif, clib_error_t *err)
Definition: socket.c:189
#define hash_get(h, key)
Definition: hash.h:248
static void memif_msg_enq_connected(memif_if_t *mif)
Definition: socket.c:174
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:459
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:514
uword dev_instance
Definition: private.h:132
static clib_error_t * clib_socket_close(clib_socket_t *sock)
Definition: socket.h:175
memif_msg_disconnect_t disconnect
Definition: memif.h:135
static clib_error_t * memif_msg_receive_disconnect(memif_if_t *mif, memif_msg_t *msg)
Definition: socket.c:391
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:801
uword int_clib_file_index
Definition: private.h:106
memif_msg_hello_t hello
Definition: memif.h:129
static void memif_msg_enq_add_ring(memif_if_t *mif, u8 index, u8 direction)
Definition: socket.c:134
memif_log2_ring_size_t max_log2_ring_size
Definition: memif.h:80
static clib_error_t * memif_msg_receive_init(memif_if_t **mifp, memif_msg_t *msg, clib_socket_t *sock, uword socket_file_index)
Definition: socket.c:224
memif_queue_t * tx_queues
Definition: private.h:146
clib_error_t * memif_connect(memif_if_t *mif)
Definition: memif.c:175
uint8_t if_name[32]
Definition: memif.h:110
uint8_t name[32]
Definition: memif.h:89
svmdb_client_t * c
static void memif_msg_enq_ack(memif_if_t *mif)
Definition: socket.c:71
vec_header_t h
Definition: buffer.c:282
uint8_t if_name[32]
Definition: memif.h:115
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
#define clib_warning(format, args...)
Definition: error.h:59
#define DBG(...)
memif_region_index_t index
Definition: memif.h:94
clib_error_t * memif_master_conn_fd_write_ready(clib_file_t *uf)
Definition: socket.c:551
void memif_disconnect(memif_if_t *mif, clib_error_t *err)
Definition: memif.c:69
memif_log2_ring_size_t log2_ring_size
Definition: memif.h:105
memif_version_t version
Definition: memif.h:85
memif_region_t * regions
Definition: private.h:143
memif_ring_index_t max_s2m_ring
Definition: memif.h:79
#define ASSERT(truth)
static uword * mhash_get(mhash_t *h, const void *key)
Definition: mhash.h:110
memif_msg_t msg
Definition: private.h:89
memif_msg_connect_t connect
Definition: memif.h:133
#define MEMIF_VERSION
Definition: memif.h:28
u32 flags
Definition: private.h:128
static void clib_mem_free(void *p)
Definition: mem.h:179
#define clib_error_report(e)
Definition: error.h:113
struct _socket_t clib_socket_t
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
Definition: vec.h:916
static void * clib_mem_alloc(uword size)
Definition: mem.h:112
static clib_error_t * memif_msg_receive_add_region(memif_if_t *mif, memif_msg_t *msg, int fd)
Definition: socket.c:299
u64 uword
Definition: types.h:112
static void memif_msg_enq_connect(memif_if_t *mif)
Definition: socket.c:159
uword * dev_instance_by_fd
Definition: private.h:77
u8 num_s2m_rings
Definition: private.h:155
uint16_t flags
Definition: memif.h:100
#define MEMIF_MAX_S2M_RING
Definition: private.h:27
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
memif_region_size_t size
Definition: memif.h:95
memif_region_index_t max_region
Definition: memif.h:77
memif_msg_type_t type
Definition: memif.h:126
#define clib_error_free(e)
Definition: error.h:86
u8 * remote_if_name
Definition: private.h:150
clib_error_t * memif_master_conn_fd_read_ready(clib_file_t *uf)
Definition: socket.c:486
memif_interface_id_t id
Definition: private.h:129
memif_log2_ring_size_t log2_ring_size
Definition: private.h:97
#define clib_fifo_add2(f, p)
Definition: fifo.h:200
static clib_error_t * memif_msg_enq_hello(clib_socket_t *sock)
Definition: socket.c:81
memif_msg_connected_t connected
Definition: memif.h:134
u8 * remote_disc_string
Definition: private.h:170
uword private_data
Definition: file.h:60
Definition: file.h:50
clib_socket_t * sock
Definition: private.h:138
memif_queue_t * rx_queues
Definition: private.h:145
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
memif_msg_fifo_elt_t * msg_queue
Definition: private.h:140
memif_main_t memif_main
Definition: memif.c:43
memif_region_index_t region
Definition: private.h:98
clib_socket_t * sock
Definition: private.h:68
memif_interface_mode_t mode
Definition: private.h:133
u8 * format_memif_device_name(u8 *s, va_list *args)
Definition: device.c:52
memif_region_size_t region_size
Definition: private.h:83