FD.io VPP  v19.04-6-g6f05f72
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  clib_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  goto error;
420 
421  if (mif == 0 && msg.type != MEMIF_MSG_TYPE_INIT)
422  {
423  memif_socket_close (&sock);
424  err = clib_error_return (0, "unexpected message received");
425  goto error;
426  }
427 
428  memif_log_debug (mif, "Message type %u received", msg.type);
429  /* process the message based on its type */
430  switch (msg.type)
431  {
432  case MEMIF_MSG_TYPE_ACK:
433  break;
434 
436  if ((err = memif_msg_receive_hello (mif, &msg)))
437  goto error;
438  if ((err = memif_init_regions_and_queues (mif)))
439  goto error;
440  memif_msg_enq_init (mif);
441  /* *INDENT-OFF* */
442  vec_foreach_index (i, mif->regions)
443  memif_msg_enq_add_region (mif, i);
444  vec_foreach_index (i, mif->tx_queues)
446  vec_foreach_index (i, mif->rx_queues)
448  /* *INDENT-ON* */
449  memif_msg_enq_connect (mif);
450  break;
451 
452  case MEMIF_MSG_TYPE_INIT:
453  if ((err = memif_msg_receive_init (mifp, &msg, sock, uf->private_data)))
454  goto error;
455  mif = *mifp;
457  uf->description = format (uf->description, "%U ctl",
459  memif_msg_enq_ack (mif);
460  break;
461 
463  if ((err = memif_msg_receive_add_region (mif, &msg, fd)))
464  goto error;
465  memif_msg_enq_ack (mif);
466  break;
467 
469  if ((err = memif_msg_receive_add_ring (mif, &msg, fd)))
470  goto error;
471  memif_msg_enq_ack (mif);
472  break;
473 
475  if ((err = memif_msg_receive_connect (mif, &msg)))
476  goto error;
478  break;
479 
481  if ((err = memif_msg_receive_connected (mif, &msg)))
482  goto error;
483  break;
484 
486  if ((err = memif_msg_receive_disconnect (mif, &msg)))
487  goto error;
488  break;
489 
490  default:
491  err = clib_error_return (0, "unknown message type (0x%x)", msg.type);
492  goto error;
493  }
494 
495  if (clib_fifo_elts (mif->msg_queue))
497  mif->sock->private_data, 1);
498  return 0;
499 
500 error:
501  memif_log_err (mif, "%U", format_clib_error, err);
502  return err;
503 }
504 
505 clib_error_t *
507 {
508  memif_main_t *mm = &memif_main;
509  memif_socket_file_t *msf =
511  uword *p;
512  memif_if_t *mif = 0;
513  clib_socket_t *sock = 0;
514  clib_error_t *err = 0;
515 
517  if (p)
518  {
519  mif = vec_elt_at_index (mm->interfaces, p[0]);
520  sock = mif->sock;
521  }
522  else
523  {
524  /* This is new connection, remove index from pending vector */
525  int i;
527  if (msf->pending_clients[i]->fd == uf->file_descriptor)
528  {
529  sock = msf->pending_clients[i];
530  vec_del1 (msf->pending_clients, i);
531  break;
532  }
533  ASSERT (sock != 0);
534  }
535  err = memif_msg_receive (&mif, sock, uf);
536  if (err)
537  {
538  memif_disconnect (mif, err);
539  clib_error_free (err);
540  }
541  return 0;
542 }
543 
544 clib_error_t *
546 {
547  memif_main_t *mm = &memif_main;
548  clib_error_t *err;
550  err = memif_msg_receive (&mif, mif->sock, uf);
551  if (err)
552  {
553  memif_disconnect (mif, err);
554  clib_error_free (err);
555  }
556  return 0;
557 }
558 
559 static clib_error_t *
561 {
563  clib_fifo_sub2 (mif->msg_queue, e);
565  mif->sock->private_data, 0);
566  return clib_socket_sendmsg (mif->sock, &e->msg, sizeof (memif_msg_t),
567  &e->fd, e->fd > -1 ? 1 : 0);
568 }
569 
570 clib_error_t *
572 {
573  memif_main_t *mm = &memif_main;
574  memif_socket_file_t *msf =
576  uword *p;
577  memif_if_t *mif;
578 
580  if (!p)
581  return 0;
582 
583  mif = vec_elt_at_index (mm->interfaces, p[0]);
584  return memif_conn_fd_write_ready (uf, mif);
585 }
586 
587 clib_error_t *
589 {
590  memif_main_t *mm = &memif_main;
592  return memif_conn_fd_write_ready (uf, mif);
593 }
594 
595 clib_error_t *
597 {
598  memif_main_t *mm = &memif_main;
600  clib_error_t *err;
601 
602  err = clib_error_return (0, "connection fd error");
603  memif_disconnect (mif, err);
604  clib_error_free (err);
605 
606  return 0;
607 }
608 
609 clib_error_t *
611 {
612  memif_main_t *mm = &memif_main;
613  memif_socket_file_t *msf =
615  uword *p;
616 
617 
619  if (p)
620  {
621  memif_if_t *mif;
622  clib_error_t *err;
623  mif = vec_elt_at_index (mm->interfaces, p[0]);
624  err = clib_error_return (0, "connection fd error");
625  memif_disconnect (mif, err);
626  clib_error_free (err);
627  }
628  else
629  {
630  int i;
632  if (msf->pending_clients[i]->fd == uf->file_descriptor)
633  {
634  clib_socket_t *s = msf->pending_clients[i];
635  memif_socket_close (&s);
636  vec_del1 (msf->pending_clients, i);
637  return 0;
638  }
639  }
640 
641  memif_log_warn (0, "Error on unknown file descriptor %d",
642  uf->file_descriptor);
643  memif_file_del (uf);
644  return 0;
645 }
646 
647 
648 clib_error_t *
650 {
651  memif_main_t *mm = &memif_main;
652  memif_socket_file_t *msf =
654  clib_file_t template = { 0 };
655  clib_error_t *err;
656  clib_socket_t *client;
657 
658  client = clib_mem_alloc (sizeof (clib_socket_t));
659  clib_memset (client, 0, sizeof (clib_socket_t));
660  err = clib_socket_accept (msf->sock, client);
661  if (err)
662  goto error;
663 
664  template.read_function = memif_master_conn_fd_read_ready;
665  template.write_function = memif_master_conn_fd_write_ready;
666  template.error_function = memif_master_conn_fd_error;
667  template.file_descriptor = client->fd;
668  template.private_data = uf->private_data;
669  template.description = format (0, "memif in conn on %s", msf->filename);
670 
671  memif_file_add (&client->private_data, &template);
672 
673  err = memif_msg_enq_hello (client);
674  if (err)
675  {
676  clib_socket_close (client);
677  goto error;
678  }
679 
680  vec_add1 (msf->pending_clients, client);
681 
682  return 0;
683 
684 error:
685  memif_log_err (0, "%U", format_clib_error, err);
686  clib_mem_free (client);
687  return err;
688 }
689 
690 /*
691  * fd.io coding-style-patch-verification: ON
692  *
693  * Local Variables:
694  * eval: (c-set-style "gnu")
695  * End:
696  */
#define memif_log_err(dev, f,...)
Definition: private.h:55
memif_if_t * interfaces
Definition: private.h:241
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.
u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
#define hash_set(h, key, value)
Definition: hash.h:255
clib_error_t * memif_master_conn_fd_error(clib_file_t *uf)
Definition: socket.c:610
#define clib_min(x, y)
Definition: clib.h:295
clib_error_t * memif_conn_fd_accept_ready(clib_file_t *uf)
Definition: socket.c:649
u8 * secret
Definition: private.h:170
#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:588
clib_socket_t ** pending_clients
Definition: private.h:87
static uword clib_fifo_elts(void *v)
Definition: fifo.h:66
#define memif_file_del(a)
Definition: private.h:72
static clib_error_t * memif_msg_receive_connected(memif_if_t *mif, memif_msg_t *msg)
Definition: socket.c:387
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:244
memif_log2_ring_size_t log2_ring_size
Definition: private.h:183
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:29
u32 file_descriptor
Definition: file.h:54
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
int i
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
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:450
u8 num_m2s_rings
Definition: private.h:185
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
unsigned char u8
Definition: types.h:56
uint16_t private_hdr_size
Definition: memif.h:106
#define memif_file_del_by_index(a)
Definition: private.h:77
#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:545
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:178
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:560
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:308
u16 buffer_size
Definition: private.h:186
#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:121
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:27
memif_region_offset_t offset
Definition: memif.h:104
#define memif_file_add(a, b)
Definition: private.h:66
#define MEMIF_MAX_LOG2_RING_SIZE
Definition: private.h:30
mhash_t dev_instance_by_id
Definition: private.h:92
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:596
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:249
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:514
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:524
uword dev_instance
Definition: private.h:161
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
struct memif_if_t::@507 cfg
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:804
uword int_clib_file_index
Definition: private.h:130
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:175
u8 len
Definition: ip_types.api:49
clib_error_t * memif_connect(memif_if_t *mif)
Definition: memif.c:186
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:341
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:571
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:134
memif_region_t * regions
Definition: private.h:172
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
struct memif_if_t::@508 run
memif_msg_t msg
Definition: private.h:110
memif_msg_connect_t connect
Definition: memif.h:134
#define MEMIF_VERSION
Definition: memif.h:28
u32 flags
Definition: private.h:157
static void clib_mem_free(void *p)
Definition: mem.h:205
struct _socket_t clib_socket_t
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
Definition: vec.h:919
static void * clib_mem_alloc(uword size)
Definition: mem.h:132
static clib_error_t * memif_msg_receive_add_region(memif_if_t *mif, memif_msg_t *msg, int fd)
Definition: socket.c:300
static void memif_msg_enq_connect(memif_if_t *mif)
Definition: socket.c:160
uword * dev_instance_by_fd
Definition: private.h:95
u8 num_s2m_rings
Definition: private.h:184
uint16_t flags
Definition: memif.h:100
#define MEMIF_MAX_S2M_RING
Definition: private.h:28
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
memif_region_size_t size
Definition: memif.h:95
#define memif_log_warn(dev, f,...)
Definition: private.h:44
memif_region_index_t max_region
Definition: memif.h:77
u64 uword
Definition: types.h:112
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:179
clib_error_t * memif_master_conn_fd_read_ready(clib_file_t *uf)
Definition: socket.c:506
memif_interface_id_t id
Definition: private.h:158
memif_log2_ring_size_t log2_ring_size
Definition: private.h:119
#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
#define memif_log_debug(dev, f,...)
Definition: private.h:33
u8 * remote_disc_string
Definition: private.h:199
uword private_data
Definition: file.h:64
Definition: file.h:51
clib_socket_t * sock
Definition: private.h:167
memif_queue_t * rx_queues
Definition: private.h:174
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
memif_msg_fifo_elt_t * msg_queue
Definition: private.h:169
memif_main_t memif_main
Definition: memif.c:43
memif_region_index_t region
Definition: private.h:120
clib_socket_t * sock
Definition: private.h:86
memif_interface_mode_t mode
Definition: private.h:162
u8 * format_memif_device_name(u8 *s, va_list *args)
Definition: device.c:51
memif_region_size_t region_size
Definition: private.h:103