FD.io VPP  v18.04-17-g3a0d853
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  ar->private_hdr_size = 0;
157 }
158 
159 static void
161 {
163  clib_fifo_add2 (mif->msg_queue, e);
165  u8 *s;
166 
168  e->fd = -1;
169  s = format (0, "%U%c", format_memif_device_name, mif->dev_instance, 0);
170  strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name) - 1);
171  vec_free (s);
172 }
173 
174 static void
176 {
178  clib_fifo_add2 (mif->msg_queue, e);
180  u8 *s;
181 
183  e->fd = -1;
184  s = format (0, "%U%c", format_memif_device_name, mif->dev_instance, 0);
185  strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name) - 1);
186  vec_free (s);
187 }
188 
189 clib_error_t *
191 {
192  memif_msg_t msg = { 0 };
195 
196  d->code = err->code;
197  strncpy ((char *) d->string, (char *) err->what, sizeof (d->string) - 1);
198 
199  return clib_socket_sendmsg (mif->sock, &msg, sizeof (memif_msg_t), 0, 0);
200 }
201 
202 static clib_error_t *
204 {
205  memif_msg_hello_t *h = &msg->hello;
206 
207  if (msg->hello.min_version > MEMIF_VERSION ||
209  return clib_error_return (0, "incompatible protocol version");
210 
211  mif->run.num_s2m_rings = clib_min (h->max_s2m_ring + 1,
212  mif->cfg.num_s2m_rings);
213  mif->run.num_m2s_rings = clib_min (h->max_m2s_ring + 1,
214  mif->cfg.num_m2s_rings);
216  mif->cfg.log2_ring_size);
217  mif->run.buffer_size = mif->cfg.buffer_size;
218 
219  mif->remote_name = memif_str2vec (h->name, sizeof (h->name));
220 
221  return 0;
222 }
223 
224 static clib_error_t *
226  clib_socket_t * sock, uword socket_file_index)
227 {
228  memif_main_t *mm = &memif_main;
229  memif_socket_file_t *msf =
230  vec_elt_at_index (mm->socket_files, socket_file_index);
231  memif_msg_init_t *i = &msg->init;
232  memif_if_t *mif, tmp;
233  clib_error_t *err;
234  uword *p;
235 
236  if (i->version != MEMIF_VERSION)
237  {
238  memif_file_del_by_index (sock->private_data);
239  return clib_error_return (0, "unsupported version");
240  }
241 
242  p = mhash_get (&msf->dev_instance_by_id, &i->id);
243 
244  if (!p)
245  {
246  err = clib_error_return (0, "unmatched interface id");
247  goto error;
248  }
249 
250  mif = vec_elt_at_index (mm->interfaces, p[0]);
251 
252  if (mif->flags & MEMIF_IF_FLAG_IS_SLAVE)
253  {
254  err = clib_error_return (0, "cannot connect to slave");
255  goto error;
256  }
257 
258  if (mif->sock)
259  {
260  err = clib_error_return (0, "already connected");
261  goto error;
262  }
263 
264  if (i->mode != mif->mode)
265  {
266  err = clib_error_return (0, "mode mismatch");
267  goto error;
268  }
269 
270  mif->sock = sock;
271  hash_set (msf->dev_instance_by_fd, mif->sock->fd, mif->dev_instance);
272  mif->remote_name = memif_str2vec (i->name, sizeof (i->name));
273  *mifp = mif;
274 
275  if (mif->secret)
276  {
277  u8 *s;
278  int r;
279  s = memif_str2vec (i->secret, sizeof (i->secret));
280  if (s == 0)
281  return clib_error_return (0, "secret required");
282 
283  r = vec_cmp (s, mif->secret);
284  vec_free (s);
285 
286  if (r)
287  return clib_error_return (0, "incorrect secret");
288  }
289 
290  return 0;
291 
292 error:
293  tmp.sock = sock;
294  memif_msg_send_disconnect (&tmp, err);
295  memif_socket_close (&sock);
296  return err;
297 }
298 
299 static clib_error_t *
301 {
303  memif_region_t *mr;
304  if (fd < 0)
305  return clib_error_return (0, "missing memory region fd");
306 
307  if (ar->index != vec_len (mif->regions))
308  return clib_error_return (0, "unexpected region index");
309 
310  if (ar->index > MEMIF_MAX_REGION)
311  return clib_error_return (0, "too many regions");
312 
314  mr = vec_elt_at_index (mif->regions, ar->index);
315  mr->fd = fd;
316  mr->region_size = ar->size;
317 
318  return 0;
319 }
320 
321 static clib_error_t *
323 {
324  memif_msg_add_ring_t *ar = &msg->add_ring;
325  memif_queue_t *mq;
326 
327  if (fd < 0)
328  return clib_error_return (0, "missing ring interrupt fd");
329 
330  if (ar->private_hdr_size != 0)
331  return clib_error_return (0, "private headers not supported");
332 
334  {
335  if (ar->index != vec_len (mif->rx_queues))
336  return clib_error_return (0, "unexpected ring index");
337 
338  if (ar->index > MEMIF_MAX_S2M_RING)
339  return clib_error_return (0, "too many rings");
340 
342  mq = vec_elt_at_index (mif->rx_queues, ar->index);
343  mif->run.num_s2m_rings = vec_len (mif->rx_queues);
344  }
345  else
346  {
347  if (ar->index != vec_len (mif->tx_queues))
348  return clib_error_return (0, "unexpected ring index");
349 
350  if (ar->index > MEMIF_MAX_M2S_RING)
351  return clib_error_return (0, "too many rings");
352 
354  mq = vec_elt_at_index (mif->tx_queues, ar->index);
355  mif->run.num_m2s_rings = vec_len (mif->tx_queues);
356  }
357 
358  // clear previous cache data if interface reconncected
359  memset (mq, 0, sizeof (memif_queue_t));
360  mq->int_fd = fd;
361  mq->int_clib_file_index = ~0;
362  mq->log2_ring_size = ar->log2_ring_size;
363  mq->region = ar->region;
364  mq->offset = ar->offset;
365  mq->type =
368 
369  return 0;
370 }
371 
372 static clib_error_t *
374 {
375  clib_error_t *err;
376  memif_msg_connect_t *c = &msg->connect;
377 
378  if ((err = memif_connect (mif)))
379  return err;
380 
381  mif->remote_if_name = memif_str2vec (c->if_name, sizeof (c->if_name));
382 
383  return 0;
384 }
385 
386 static clib_error_t *
388 {
389  clib_error_t *err;
391 
392  if ((err = memif_connect (mif)))
393  return err;
394 
395  mif->remote_if_name = memif_str2vec (c->if_name, sizeof (c->if_name));
396  return 0;
397 }
398 
399 static clib_error_t *
401 {
403 
404  mif->remote_disc_string = memif_str2vec (d->string, sizeof (d->string));
405  return clib_error_return (0, "disconnect received");
406 }
407 
408 static clib_error_t *
410 {
411  memif_msg_t msg = { 0 };
412  clib_error_t *err = 0;
413  int fd = -1;
414  int i;
415  memif_if_t *mif = *mifp;
416 
417  err = clib_socket_recvmsg (sock, &msg, sizeof (memif_msg_t), &fd, 1);
418  if (err)
419  return err;
420 
421  if (mif == 0 && msg.type != MEMIF_MSG_TYPE_INIT)
422  {
423  memif_socket_close (&sock);
424  return clib_error_return (0, "unexpected message received");
425  }
426 
427  DBG ("Message type %u received", msg.type);
428  /* process the message based on its type */
429  switch (msg.type)
430  {
431  case MEMIF_MSG_TYPE_ACK:
432  break;
433 
435  if ((err = memif_msg_receive_hello (mif, &msg)))
436  return err;
437  if ((err = memif_init_regions_and_queues (mif)))
438  return err;
439  memif_msg_enq_init (mif);
440  /* *INDENT-OFF* */
441  vec_foreach_index (i, mif->regions)
442  memif_msg_enq_add_region (mif, i);
443  vec_foreach_index (i, mif->tx_queues)
445  vec_foreach_index (i, mif->rx_queues)
447  /* *INDENT-ON* */
448  memif_msg_enq_connect (mif);
449  break;
450 
451  case MEMIF_MSG_TYPE_INIT:
452  if ((err = memif_msg_receive_init (mifp, &msg, sock, uf->private_data)))
453  return err;
454  mif = *mifp;
456  uf->description = format (uf->description, "%U ctl",
458  memif_msg_enq_ack (mif);
459  break;
460 
462  if ((err = memif_msg_receive_add_region (mif, &msg, fd)))
463  return err;
464  memif_msg_enq_ack (mif);
465  break;
466 
468  if ((err = memif_msg_receive_add_ring (mif, &msg, fd)))
469  return err;
470  memif_msg_enq_ack (mif);
471  break;
472 
474  if ((err = memif_msg_receive_connect (mif, &msg)))
475  return err;
477  break;
478 
480  if ((err = memif_msg_receive_connected (mif, &msg)))
481  return err;
482  break;
483 
485  if ((err = memif_msg_receive_disconnect (mif, &msg)))
486  return err;
487  break;
488 
489  default:
490  err = clib_error_return (0, "unknown message type (0x%x)", msg.type);
491  return err;
492  }
493 
494  if (clib_fifo_elts (mif->msg_queue))
496  mif->sock->private_data, 1);
497  return 0;
498 }
499 
500 clib_error_t *
502 {
503  memif_main_t *mm = &memif_main;
504  memif_socket_file_t *msf =
506  uword *p;
507  memif_if_t *mif = 0;
508  clib_socket_t *sock = 0;
509  clib_error_t *err = 0;
510 
512  if (p)
513  {
514  mif = vec_elt_at_index (mm->interfaces, p[0]);
515  sock = mif->sock;
516  }
517  else
518  {
519  /* This is new connection, remove index from pending vector */
520  int i;
522  if (msf->pending_clients[i]->fd == uf->file_descriptor)
523  {
524  sock = msf->pending_clients[i];
525  vec_del1 (msf->pending_clients, i);
526  break;
527  }
528  ASSERT (sock != 0);
529  }
530  err = memif_msg_receive (&mif, sock, uf);
531  if (err)
532  {
533  memif_disconnect (mif, err);
534  clib_error_free (err);
535  }
536  return 0;
537 }
538 
539 clib_error_t *
541 {
542  memif_main_t *mm = &memif_main;
543  clib_error_t *err;
545  err = memif_msg_receive (&mif, mif->sock, uf);
546  if (err)
547  {
548  memif_disconnect (mif, err);
549  clib_error_free (err);
550  }
551  return 0;
552 }
553 
554 static clib_error_t *
556 {
558  clib_fifo_sub2 (mif->msg_queue, e);
560  mif->sock->private_data, 0);
561  return clib_socket_sendmsg (mif->sock, &e->msg, sizeof (memif_msg_t),
562  &e->fd, e->fd > -1 ? 1 : 0);
563 }
564 
565 clib_error_t *
567 {
568  memif_main_t *mm = &memif_main;
569  memif_socket_file_t *msf =
571  uword *p;
572  memif_if_t *mif;
573 
575  if (!p)
576  return 0;
577 
578  mif = vec_elt_at_index (mm->interfaces, p[0]);
579  return memif_conn_fd_write_ready (uf, mif);
580 }
581 
582 clib_error_t *
584 {
585  memif_main_t *mm = &memif_main;
587  return memif_conn_fd_write_ready (uf, mif);
588 }
589 
590 clib_error_t *
592 {
593  memif_main_t *mm = &memif_main;
595  clib_error_t *err;
596 
597  err = clib_error_return (0, "connection fd error");
598  memif_disconnect (mif, err);
599  clib_error_free (err);
600 
601  return 0;
602 }
603 
604 clib_error_t *
606 {
607  memif_main_t *mm = &memif_main;
608  memif_socket_file_t *msf =
610  uword *p;
611 
612 
614  if (p)
615  {
616  memif_if_t *mif;
617  clib_error_t *err;
618  mif = vec_elt_at_index (mm->interfaces, p[0]);
619  err = clib_error_return (0, "connection fd error");
620  memif_disconnect (mif, err);
621  clib_error_free (err);
622  }
623  else
624  {
625  int i;
627  if (msf->pending_clients[i]->fd == uf->file_descriptor)
628  {
629  clib_socket_t *s = msf->pending_clients[i];
630  memif_socket_close (&s);
631  vec_del1 (msf->pending_clients, i);
632  return 0;
633  }
634  }
635 
636  clib_warning ("Error on unknown file descriptor %d", uf->file_descriptor);
637  memif_file_del (uf);
638  return 0;
639 }
640 
641 
642 clib_error_t *
644 {
645  memif_main_t *mm = &memif_main;
646  memif_socket_file_t *msf =
648  clib_file_t template = { 0 };
649  clib_error_t *err;
650  clib_socket_t *client;
651 
652  client = clib_mem_alloc (sizeof (clib_socket_t));
653  memset (client, 0, sizeof (clib_socket_t));
654  err = clib_socket_accept (msf->sock, client);
655  if (err)
656  goto error;
657 
658  template.read_function = memif_master_conn_fd_read_ready;
659  template.write_function = memif_master_conn_fd_write_ready;
660  template.error_function = memif_master_conn_fd_error;
661  template.file_descriptor = client->fd;
662  template.private_data = uf->private_data;
663  template.description = format (0, "memif in conn on %s", msf->filename);
664 
665  memif_file_add (&client->private_data, &template);
666 
667  err = memif_msg_enq_hello (client);
668  if (err)
669  {
670  clib_socket_close (client);
671  goto error;
672  }
673 
674  vec_add1 (msf->pending_clients, client);
675 
676  return 0;
677 
678 error:
679  clib_error_report (err);
680  clib_mem_free (client);
681  return err;
682 }
683 
684 /*
685  * fd.io coding-style-patch-verification: ON
686  *
687  * Local Variables:
688  * eval: (c-set-style "gnu")
689  * End:
690  */
memif_if_t * interfaces
Definition: private.h:221
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:373
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
Definition: hash.h:254
clib_error_t * memif_master_conn_fd_error(clib_file_t *uf)
Definition: socket.c:605
#define clib_min(x, y)
Definition: clib.h:340
clib_error_t * memif_conn_fd_accept_ready(clib_file_t *uf)
Definition: socket.c:643
u8 * secret
Definition: private.h:151
#define clib_fifo_sub2(f, p)
Definition: fifo.h:232
memif_msg_add_region_t add_region
Definition: memif.h:132
clib_error_t * memif_slave_conn_fd_write_ready(clib_file_t *uf)
Definition: socket.c:583
clib_socket_t ** pending_clients
Definition: private.h:70
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:387
struct memif_if_t::@424 run
uint8_t string[96]
Definition: memif.h:122
static clib_error_t * memif_msg_receive_add_ring(memif_if_t *mif, memif_msg_t *msg, int fd)
Definition: socket.c:322
memif_socket_file_t * socket_files
Definition: private.h:224
memif_log2_ring_size_t log2_ring_size
Definition: private.h:164
memif_msg_add_ring_t add_ring
Definition: memif.h:133
#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:54
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:520
int i
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:445
u8 num_m2s_rings
Definition: private.h:166
static uword clib_file_set_data_available_to_write(clib_file_main_t *um, u32 clib_file_index, uword is_available)
Definition: file.h:137
memif_version_t min_version
Definition: memif.h:75
uint8_t secret[24]
Definition: memif.h:88
uint16_t private_hdr_size
Definition: memif.h:106
#define memif_file_del_by_index(a)
Definition: private.h:62
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
clib_error_t * memif_slave_conn_fd_read_ready(clib_file_t *uf)
Definition: socket.c:540
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:159
static clib_error_t * memif_msg_receive(memif_if_t **mifp, clib_socket_t *sock, clib_file_t *uf)
Definition: socket.c:409
static clib_error_t * memif_msg_receive_hello(memif_if_t *mif, memif_msg_t *msg)
Definition: socket.c:203
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:555
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:281
u16 buffer_size
Definition: private.h:167
#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:103
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:75
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:591
static u8 * memif_str2vec(uint8_t *str, int len)
Definition: socket.c:51
memif_msg_init_t init
Definition: memif.h:131
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:190
u8 * description
Definition: file.h:70
#define hash_get(h, key)
Definition: hash.h:248
static void memif_msg_enq_connected(memif_if_t *mif)
Definition: socket.c:175
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:461
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:514
uword dev_instance
Definition: private.h:142
static clib_error_t * clib_socket_close(clib_socket_t *sock)
Definition: socket.h:175
memif_msg_disconnect_t disconnect
Definition: memif.h:136
static clib_error_t * memif_msg_receive_disconnect(memif_if_t *mif, memif_msg_t *msg)
Definition: socket.c:400
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:803
uword int_clib_file_index
Definition: private.h:111
memif_msg_hello_t hello
Definition: memif.h:130
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:225
memif_queue_t * tx_queues
Definition: private.h:156
clib_error_t * memif_connect(memif_if_t *mif)
Definition: memif.c:181
uint8_t if_name[32]
Definition: memif.h:111
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
uint8_t if_name[32]
Definition: memif.h:116
#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:566
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:115
memif_region_t * regions
Definition: private.h:153
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:93
memif_msg_connect_t connect
Definition: memif.h:134
#define MEMIF_VERSION
Definition: memif.h:28
u32 flags
Definition: private.h:138
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:918
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:300
u64 uword
Definition: types.h:112
static void memif_msg_enq_connect(memif_if_t *mif)
Definition: socket.c:160
uword * dev_instance_by_fd
Definition: private.h:78
u8 num_s2m_rings
Definition: private.h:165
struct memif_if_t::@423 cfg
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:127
#define clib_error_free(e)
Definition: error.h:86
u8 * remote_if_name
Definition: private.h:160
clib_error_t * memif_master_conn_fd_read_ready(clib_file_t *uf)
Definition: socket.c:501
memif_interface_id_t id
Definition: private.h:139
memif_log2_ring_size_t log2_ring_size
Definition: private.h:101
#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:135
u8 * remote_disc_string
Definition: private.h:180
uword private_data
Definition: file.h:64
Definition: file.h:51
clib_socket_t * sock
Definition: private.h:148
memif_queue_t * rx_queues
Definition: private.h:155
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
memif_msg_fifo_elt_t * msg_queue
Definition: private.h:150
memif_main_t memif_main
Definition: memif.c:43
memif_region_index_t region
Definition: private.h:102
clib_socket_t * sock
Definition: private.h:69
memif_interface_mode_t mode
Definition: private.h:143
u8 * format_memif_device_name(u8 *s, va_list *args)
Definition: device.c:51
memif_region_size_t region_size
Definition: private.h:86