FD.io VPP  v18.01.2-1-g9b554f3
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  // clear previous cache data if interface reconncected
355  memset (mq, 0, sizeof (memif_queue_t));
356  mq->int_fd = fd;
357  mq->int_clib_file_index = ~0;
358  mq->log2_ring_size = ar->log2_ring_size;
359  mq->region = ar->region;
360  mq->offset = ar->offset;
361  mq->type =
364 
365  return 0;
366 }
367 
368 static clib_error_t *
370 {
371  clib_error_t *err;
372  memif_msg_connect_t *c = &msg->connect;
373 
374  if ((err = memif_connect (mif)))
375  return err;
376 
377  mif->remote_if_name = memif_str2vec (c->if_name, sizeof (c->if_name));
378 
379  return 0;
380 }
381 
382 static clib_error_t *
384 {
385  clib_error_t *err;
387 
388  if ((err = memif_connect (mif)))
389  return err;
390 
391  mif->remote_if_name = memif_str2vec (c->if_name, sizeof (c->if_name));
392  return 0;
393 }
394 
395 static clib_error_t *
397 {
399 
400  mif->remote_disc_string = memif_str2vec (d->string, sizeof (d->string));
401  return clib_error_return (0, "disconnect received");
402 }
403 
404 static clib_error_t *
406 {
407  memif_msg_t msg = { 0 };
408  clib_error_t *err = 0;
409  int fd = -1;
410  int i;
411  memif_if_t *mif = *mifp;
412 
413  err = clib_socket_recvmsg (sock, &msg, sizeof (memif_msg_t), &fd, 1);
414  if (err)
415  return err;
416 
417  if (mif == 0 && msg.type != MEMIF_MSG_TYPE_INIT)
418  {
419  memif_socket_close (&sock);
420  return clib_error_return (0, "unexpected message received");
421  }
422 
423  DBG ("Message type %u received", msg.type);
424  /* process the message based on its type */
425  switch (msg.type)
426  {
427  case MEMIF_MSG_TYPE_ACK:
428  break;
429 
431  if ((err = memif_msg_receive_hello (mif, &msg)))
432  return err;
433  if ((err = memif_init_regions_and_queues (mif)))
434  return err;
435  memif_msg_enq_init (mif);
436  memif_msg_enq_add_region (mif, 0);
437  vec_foreach_index (i, mif->tx_queues)
439  vec_foreach_index (i, mif->rx_queues)
441  memif_msg_enq_connect (mif);
442  break;
443 
444  case MEMIF_MSG_TYPE_INIT:
445  if ((err = memif_msg_receive_init (mifp, &msg, sock, uf->private_data)))
446  return err;
447  mif = *mifp;
448  memif_msg_enq_ack (mif);
449  break;
450 
452  if ((err = memif_msg_receive_add_region (mif, &msg, fd)))
453  return err;
454  memif_msg_enq_ack (mif);
455  break;
456 
458  if ((err = memif_msg_receive_add_ring (mif, &msg, fd)))
459  return err;
460  memif_msg_enq_ack (mif);
461  break;
462 
464  if ((err = memif_msg_receive_connect (mif, &msg)))
465  return err;
467  break;
468 
470  if ((err = memif_msg_receive_connected (mif, &msg)))
471  return err;
472  break;
473 
475  if ((err = memif_msg_receive_disconnect (mif, &msg)))
476  return err;
477  break;
478 
479  default:
480  err = clib_error_return (0, "unknown message type (0x%x)", msg.type);
481  return err;
482  }
483 
484  if (clib_fifo_elts (mif->msg_queue))
486  mif->sock->private_data, 1);
487  return 0;
488 }
489 
490 clib_error_t *
492 {
493  memif_main_t *mm = &memif_main;
494  memif_socket_file_t *msf =
496  uword *p;
497  memif_if_t *mif = 0;
498  clib_socket_t *sock = 0;
499  clib_error_t *err = 0;
500 
502  if (p)
503  {
504  mif = vec_elt_at_index (mm->interfaces, p[0]);
505  sock = mif->sock;
506  }
507  else
508  {
509  /* This is new connection, remove index from pending vector */
510  int i;
512  if (msf->pending_clients[i]->fd == uf->file_descriptor)
513  {
514  sock = msf->pending_clients[i];
515  vec_del1 (msf->pending_clients, i);
516  break;
517  }
518  ASSERT (sock != 0);
519  }
520  err = memif_msg_receive (&mif, sock, uf);
521  if (err)
522  {
523  memif_disconnect (mif, err);
524  clib_error_free (err);
525  }
526  return 0;
527 }
528 
529 clib_error_t *
531 {
532  memif_main_t *mm = &memif_main;
533  clib_error_t *err;
535  err = memif_msg_receive (&mif, mif->sock, uf);
536  if (err)
537  {
538  memif_disconnect (mif, err);
539  clib_error_free (err);
540  }
541  return 0;
542 }
543 
544 static clib_error_t *
546 {
548  clib_fifo_sub2 (mif->msg_queue, e);
550  mif->sock->private_data, 0);
551  return clib_socket_sendmsg (mif->sock, &e->msg, sizeof (memif_msg_t),
552  &e->fd, e->fd > -1 ? 1 : 0);
553 }
554 
555 clib_error_t *
557 {
558  memif_main_t *mm = &memif_main;
559  memif_socket_file_t *msf =
561  uword *p;
562  memif_if_t *mif;
563 
565  if (!p)
566  return 0;
567 
568  mif = vec_elt_at_index (mm->interfaces, p[0]);
569  return memif_conn_fd_write_ready (uf, mif);
570 }
571 
572 clib_error_t *
574 {
575  memif_main_t *mm = &memif_main;
577  return memif_conn_fd_write_ready (uf, mif);
578 }
579 
580 clib_error_t *
582 {
583  memif_main_t *mm = &memif_main;
585  clib_error_t *err;
586 
587  err = clib_error_return (0, "connection fd error");
588  memif_disconnect (mif, err);
589  clib_error_free (err);
590 
591  return 0;
592 }
593 
594 clib_error_t *
596 {
597  memif_main_t *mm = &memif_main;
598  memif_socket_file_t *msf =
600  uword *p;
601 
602 
604  if (p)
605  {
606  memif_if_t *mif;
607  clib_error_t *err;
608  mif = vec_elt_at_index (mm->interfaces, p[0]);
609  err = clib_error_return (0, "connection fd error");
610  memif_disconnect (mif, err);
611  clib_error_free (err);
612  }
613  else
614  {
615  int i;
617  if (msf->pending_clients[i]->fd == uf->file_descriptor)
618  {
619  clib_socket_t *s = msf->pending_clients[i];
620  memif_socket_close (&s);
621  vec_del1 (msf->pending_clients, i);
622  return 0;
623  }
624  }
625 
626  clib_warning ("Error on unknown file descriptor %d", uf->file_descriptor);
627  memif_file_del (uf);
628  return 0;
629 }
630 
631 
632 clib_error_t *
634 {
635  memif_main_t *mm = &memif_main;
636  memif_socket_file_t *msf =
638  clib_file_t template = { 0 };
639  clib_error_t *err;
640  clib_socket_t *client;
641 
642  client = clib_mem_alloc (sizeof (clib_socket_t));
643  memset (client, 0, sizeof (clib_socket_t));
644  err = clib_socket_accept (msf->sock, client);
645  if (err)
646  goto error;
647 
648  template.read_function = memif_master_conn_fd_read_ready;
649  template.write_function = memif_master_conn_fd_write_ready;
650  template.error_function = memif_master_conn_fd_error;
651  template.file_descriptor = client->fd;
652  template.private_data = uf->private_data;
653 
654  memif_file_add (&client->private_data, &template);
655 
656  err = memif_msg_enq_hello (client);
657  if (err)
658  {
659  clib_socket_close (client);
660  goto error;
661  }
662 
663  vec_add1 (msf->pending_clients, client);
664 
665  return 0;
666 
667 error:
668  clib_error_report (err);
669  clib_mem_free (client);
670  return err;
671 }
672 
673 /*
674  * fd.io coding-style-patch-verification: ON
675  *
676  * Local Variables:
677  * eval: (c-set-style "gnu")
678  * End:
679  */
memif_if_t * interfaces
Definition: private.h:184
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:369
#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:595
#define clib_min(x, y)
Definition: clib.h:340
clib_error_t * memif_conn_fd_accept_ready(clib_file_t *uf)
Definition: socket.c:633
u8 * secret
Definition: private.h:144
#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:573
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:383
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:187
memif_log2_ring_size_t log2_ring_size
Definition: private.h:157
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:159
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:530
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:152
static clib_error_t * memif_msg_receive(memif_if_t **mifp, clib_socket_t *sock, clib_file_t *uf)
Definition: socket.c:405
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:545
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:160
#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:581
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:135
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:396
#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:149
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:556
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_ring_type_t type
Definition: private.h:110
memif_region_t * regions
Definition: private.h:146
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:131
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:158
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:153
clib_error_t * memif_master_conn_fd_read_ready(clib_file_t *uf)
Definition: socket.c:491
memif_interface_id_t id
Definition: private.h:132
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:173
uword private_data
Definition: file.h:60
Definition: file.h:50
clib_socket_t * sock
Definition: private.h:141
memif_queue_t * rx_queues
Definition: private.h:148
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
memif_msg_fifo_elt_t * msg_queue
Definition: private.h:143
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:136
u8 * format_memif_device_name(u8 *s, va_list *args)
Definition: device.c:52
memif_region_size_t region_size
Definition: private.h:83