FD.io VPP  v21.01.1
Vector Packet Processing
virtio.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2017 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 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <fcntl.h>
21 #include <net/if.h>
22 #include <linux/if_tun.h>
23 #include <sys/ioctl.h>
24 #include <sys/eventfd.h>
25 
26 #include <vlib/vlib.h>
27 #include <vlib/pci/pci.h>
28 #include <vlib/unix/unix.h>
29 #include <vnet/ethernet/ethernet.h>
30 #include <vnet/ip/ip4_packet.h>
31 #include <vnet/ip/ip6_packet.h>
34 
36 
37 #define _IOCTL(fd,a,...) \
38  if (ioctl (fd, a, __VA_ARGS__) < 0) \
39  { \
40  err = clib_error_return_unix (0, "ioctl(" #a ")"); \
41  goto error; \
42  }
43 
44 static clib_error_t *
46 {
48  vnet_main_t *vnm = vnet_get_main ();
49  u16 qid = uf->private_data & 0xFFFF;
50  virtio_if_t *vif =
51  vec_elt_at_index (nm->interfaces, uf->private_data >> 16);
52  u64 b;
53 
54  CLIB_UNUSED (ssize_t size) = read (uf->file_descriptor, &b, sizeof (b));
55  if ((qid & 1) == 0)
57  RX_QUEUE_ACCESS (qid));
58 
59  return 0;
60 }
61 
62 
65 {
66  virtio_vring_t *vring;
67  clib_file_t t = { 0 };
68  int i;
69 
70  if (!is_pow2 (sz))
71  return clib_error_return (0, "ring size must be power of 2");
72 
73  if (sz > 32768)
74  return clib_error_return (0, "ring size must be 32768 or lower");
75 
76  if (sz == 0)
77  sz = 256;
78 
79  if (idx % 2)
80  {
84  vring = vec_elt_at_index (vif->txq_vrings, TX_QUEUE_ACCESS (idx));
85  if (thm->n_vlib_mains > vif->num_txqs)
86  clib_spinlock_init (&vring->lockp);
87  }
88  else
89  {
92  vring = vec_elt_at_index (vif->rxq_vrings, RX_QUEUE_ACCESS (idx));
93  }
94  i = sizeof (vring_desc_t) * sz;
97  clib_memset (vring->desc, 0, i);
98 
99  i = sizeof (vring_avail_t) + sz * sizeof (vring->avail->ring[0]);
102  clib_memset (vring->avail, 0, i);
103  // tell kernel that we don't need interrupt
105 
106  i = sizeof (vring_used_t) + sz * sizeof (vring_used_elem_t);
109  clib_memset (vring->used, 0, i);
110 
111  vring->queue_id = idx;
112  ASSERT (vring->buffers == 0);
114 
115  if (idx & 1)
116  {
117  clib_memset_u32 (vring->buffers, ~0, sz);
118  }
119 
120  vring->size = sz;
121  vring->call_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
122  vring->kick_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
123  virtio_log_debug (vif, "vring %u size %u call_fd %d kick_fd %d", idx,
124  vring->size, vring->call_fd, vring->kick_fd);
125 
127  t.file_descriptor = vring->call_fd;
128  t.private_data = vif->dev_instance << 16 | idx;
129  t.description = format (0, "%U vring %u", format_virtio_device_name,
130  vif->dev_instance, idx);
131  vring->call_file_index = clib_file_add (&file_main, &t);
132 
133  return 0;
134 }
135 
136 inline void
138 {
139  u16 used = vring->desc_in_use;
140  u16 last = vring->last_used_idx;
141  u16 mask = vring->size - 1;
142 
143  while (used)
144  {
145  vlib_buffer_free (vm, &vring->buffers[last & mask], 1);
146  last++;
147  used--;
148  }
149 }
150 
151 clib_error_t *
153 {
154  virtio_vring_t *vring =
156 
158  close (vring->kick_fd);
159  close (vring->call_fd);
160  if (vring->used)
161  {
162  virtio_free_buffers (vm, vring);
163  clib_mem_free (vring->used);
164  }
165  if (vring->desc)
166  clib_mem_free (vring->desc);
167  if (vring->avail)
168  clib_mem_free (vring->avail);
169  vec_free (vring->buffers);
170  return 0;
171 }
172 
173 clib_error_t *
175 {
176  virtio_vring_t *vring =
178 
180  close (vring->kick_fd);
181  close (vring->call_fd);
182  if (vring->used)
183  {
184  virtio_free_buffers (vm, vring);
185  clib_mem_free (vring->used);
186  }
187  if (vring->desc)
188  clib_mem_free (vring->desc);
189  if (vring->avail)
190  clib_mem_free (vring->avail);
191  vec_free (vring->buffers);
194  clib_spinlock_free (&vring->lockp);
195  return 0;
196 }
197 
198 void
200 {
201  vnet_main_t *vnm = vnet_get_main ();
203  virtio_vring_t *vring;
204  vif->packet_coalesce = 1;
205  vec_foreach (vring, vif->txq_vrings)
206  {
208  vif->type & (VIRTIO_IF_TYPE_TAP |
209  VIRTIO_IF_TYPE_PCI), hw->tx_node_index);
210  }
211 }
212 
213 clib_error_t *
215 {
216  vnet_main_t *vnm = vnet_get_main ();
218  virtio_vring_t *vring;
219  clib_error_t *error = 0;
220  vif->packet_buffering = 1;
221 
222  vec_foreach (vring, vif->txq_vrings)
223  {
224  if ((error =
226  buffering_size)))
227  {
228  break;
229  }
230  }
231 
232  return error;
233 }
234 
235 void
237 {
238  vnet_main_t *vnm = vnet_get_main ();
239  u32 thread_index;
240  virtio_vring_t *vring =
242  thread_index =
244  RX_QUEUE_ACCESS (idx));
245  vring->buffer_pool_index =
247  vlib_mains
248  [thread_index]->numa_node);
249 }
250 
251 inline void
253 {
254  if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_MRG_RXBUF) ||
255  vif->features & VIRTIO_FEATURE (VIRTIO_F_VERSION_1))
256  vif->virtio_net_hdr_sz = sizeof (virtio_net_hdr_v1_t);
257  else
258  vif->virtio_net_hdr_sz = sizeof (virtio_net_hdr_t);
259 }
260 
261 inline void
262 virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type)
263 {
264  u32 i, j, hw_if_index;
265  virtio_if_t *vif;
266  vnet_main_t *vnm = &vnet_main;
267  virtio_main_t *mm = &virtio_main;
268  virtio_vring_t *vring;
269  struct feat_struct
270  {
271  u8 bit;
272  char *str;
273  };
274  struct feat_struct *feat_entry;
275 
276  static struct feat_struct feat_array[] = {
277 #define _(s,b) { .str = #s, .bit = b, },
279 #undef _
280  {.str = NULL}
281  };
282 
283  struct feat_struct *flag_entry;
284  static struct feat_struct flags_array[] = {
285 #define _(b,e,s) { .bit = b, .str = s, },
287 #undef _
288  {.str = NULL}
289  };
290 
291  if (!hw_if_indices)
292  return;
293 
294  for (hw_if_index = 0; hw_if_index < vec_len (hw_if_indices); hw_if_index++)
295  {
297  vnet_get_hw_interface (vnm, hw_if_indices[hw_if_index]);
298  vif = pool_elt_at_index (mm->interfaces, hi->dev_instance);
299  if (vif->type != type)
300  continue;
301  vlib_cli_output (vm, "Interface: %U (ifindex %d)",
303  hw_if_indices[hw_if_index], vif->hw_if_index);
304  if (type == VIRTIO_IF_TYPE_PCI)
305  {
306  vlib_cli_output (vm, " PCI Address: %U", format_vlib_pci_addr,
307  &vif->pci_addr);
308  }
309  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
310  {
311  u8 *str = 0;
312  if (vif->host_if_name)
313  vlib_cli_output (vm, " name \"%s\"", vif->host_if_name);
314  if (vif->net_ns)
315  vlib_cli_output (vm, " host-ns \"%s\"", vif->net_ns);
316  if (vif->host_mtu_size)
317  vlib_cli_output (vm, " host-mtu-size \"%d\"",
318  vif->host_mtu_size);
319  if (type == VIRTIO_IF_TYPE_TAP)
320  vlib_cli_output (vm, " host-mac-addr: %U",
322  vlib_cli_output (vm, " host-carrier-up: %u", vif->host_carrier_up);
323 
324  vec_foreach_index (i, vif->vhost_fds)
325  str = format (str, " %d", vif->vhost_fds[i]);
326  vlib_cli_output (vm, " vhost-fds%v", str);
327  vec_free (str);
328  vec_foreach_index (i, vif->tap_fds)
329  str = format (str, " %d", vif->tap_fds[i]);
330  vlib_cli_output (vm, " tap-fds%v", str);
331  vec_free (str);
332  }
333  vlib_cli_output (vm, " gso-enabled %d", vif->gso_enabled);
334  vlib_cli_output (vm, " csum-enabled %d", vif->csum_offload_enabled);
335  vlib_cli_output (vm, " packet-coalesce %d", vif->packet_coalesce);
336  vlib_cli_output (vm, " packet-buffering %d", vif->packet_buffering);
337  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI))
338  vlib_cli_output (vm, " Mac Address: %U", format_ethernet_address,
339  vif->mac_addr);
340  vlib_cli_output (vm, " Device instance: %u", vif->dev_instance);
341  vlib_cli_output (vm, " flags 0x%x", vif->flags);
342  flag_entry = (struct feat_struct *) &flags_array;
343  while (flag_entry->str)
344  {
345  if (vif->flags & (1ULL << flag_entry->bit))
346  vlib_cli_output (vm, " %s (%d)", flag_entry->str,
347  flag_entry->bit);
348  flag_entry++;
349  }
350  if (type == VIRTIO_IF_TYPE_PCI)
351  {
352  device_status (vm, vif);
353  }
354  vlib_cli_output (vm, " features 0x%lx", vif->features);
355  feat_entry = (struct feat_struct *) &feat_array;
356  while (feat_entry->str)
357  {
358  if (vif->features & (1ULL << feat_entry->bit))
359  vlib_cli_output (vm, " %s (%d)", feat_entry->str,
360  feat_entry->bit);
361  feat_entry++;
362  }
363  vlib_cli_output (vm, " remote-features 0x%lx", vif->remote_features);
364  feat_entry = (struct feat_struct *) &feat_array;
365  while (feat_entry->str)
366  {
367  if (vif->remote_features & (1ULL << feat_entry->bit))
368  vlib_cli_output (vm, " %s (%d)", feat_entry->str,
369  feat_entry->bit);
370  feat_entry++;
371  }
372  vlib_cli_output (vm, " Number of RX Virtqueue %u", vif->num_rxqs);
373  vlib_cli_output (vm, " Number of TX Virtqueue %u", vif->num_txqs);
374  if (vif->cxq_vring != NULL
375  && vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
376  vlib_cli_output (vm, " Number of CTRL Virtqueue 1");
377  vec_foreach_index (i, vif->rxq_vrings)
378  {
379  vring = vec_elt_at_index (vif->rxq_vrings, i);
380  vlib_cli_output (vm, " Virtqueue (RX) %d", vring->queue_id);
381  vlib_cli_output (vm,
382  " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
383  vring->size, vring->last_used_idx, vring->desc_next,
384  vring->desc_in_use);
385  if (vif->is_packed)
386  {
387  vlib_cli_output (vm,
388  " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
389  vring->driver_event->flags,
390  vring->driver_event->off_wrap,
391  vring->device_event->flags,
392  vring->device_event->off_wrap);
393  vlib_cli_output (vm,
394  " avail wrap counter %d, used wrap counter %d",
395  vring->avail_wrap_counter,
396  vring->used_wrap_counter);
397  }
398  else
399  vlib_cli_output (vm,
400  " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
401  vring->avail->flags, vring->avail->idx,
402  vring->used->flags, vring->used->idx);
403  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
404  {
405  vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
406  vring->call_fd);
407  }
408  if (show_descr)
409  {
410  vlib_cli_output (vm, "\n descriptor table:\n");
411  vlib_cli_output (vm,
412  " id addr len flags next/id user_addr\n");
413  vlib_cli_output (vm,
414  " ===== ================== ===== ====== ======= ==================\n");
415  for (j = 0; j < vring->size; j++)
416  {
417  if (vif->is_packed)
418  {
419  vring_packed_desc_t *desc = &vring->packed_desc[j];
420  vlib_cli_output (vm,
421  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
422  j, desc->addr,
423  desc->len,
424  desc->flags, desc->id, desc->addr);
425  }
426  else
427  {
428  vring_desc_t *desc = &vring->desc[j];
429  vlib_cli_output (vm,
430  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
431  j, desc->addr,
432  desc->len,
433  desc->flags, desc->next, desc->addr);
434  }
435  }
436  }
437  }
438  vec_foreach_index (i, vif->txq_vrings)
439  {
440  vring = vec_elt_at_index (vif->txq_vrings, i);
441  vlib_cli_output (vm, " Virtqueue (TX) %d", vring->queue_id);
442  vlib_cli_output (vm,
443  " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
444  vring->size, vring->last_used_idx, vring->desc_next,
445  vring->desc_in_use);
446  if (vif->is_packed)
447  {
448  vlib_cli_output (vm,
449  " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
450  vring->driver_event->flags,
451  vring->driver_event->off_wrap,
452  vring->device_event->flags,
453  vring->device_event->off_wrap);
454  vlib_cli_output (vm,
455  " avail wrap counter %d, used wrap counter %d",
456  vring->avail_wrap_counter,
457  vring->used_wrap_counter);
458  }
459  else
460  vlib_cli_output (vm,
461  " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
462  vring->avail->flags, vring->avail->idx,
463  vring->used->flags, vring->used->idx);
464  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
465  {
466  vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
467  vring->call_fd);
468  }
469  if (vring->flow_table)
470  {
472  vring->flow_table);
473  }
474  if (vif->packet_buffering)
475  {
477  vring->buffering);
478  }
479  if (show_descr)
480  {
481  vlib_cli_output (vm, "\n descriptor table:\n");
482  vlib_cli_output (vm,
483  " id addr len flags next/id user_addr\n");
484  vlib_cli_output (vm,
485  " ===== ================== ===== ====== ======== ==================\n");
486  for (j = 0; j < vring->size; j++)
487  {
488  if (vif->is_packed)
489  {
490  vring_packed_desc_t *desc = &vring->packed_desc[j];
491  vlib_cli_output (vm,
492  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
493  j, desc->addr,
494  desc->len,
495  desc->flags, desc->id, desc->addr);
496  }
497  else
498  {
499  vring_desc_t *desc = &vring->desc[j];
500  vlib_cli_output (vm,
501  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
502  j, desc->addr,
503  desc->len,
504  desc->flags, desc->next, desc->addr);
505  }
506  }
507  }
508  }
509  if (vif->cxq_vring != NULL
510  && vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
511  {
512  vring = vif->cxq_vring;
513  vlib_cli_output (vm, " Virtqueue (CTRL) %d", vring->queue_id);
514  vlib_cli_output (vm,
515  " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
516  vring->size, vring->last_used_idx,
517  vring->desc_next, vring->desc_in_use);
518  if (vif->is_packed)
519  {
520  vlib_cli_output (vm,
521  " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
522  vring->driver_event->flags,
523  vring->driver_event->off_wrap,
524  vring->device_event->flags,
525  vring->device_event->off_wrap);
526  vlib_cli_output (vm,
527  " avail wrap counter %d, used wrap counter %d",
528  vring->avail_wrap_counter,
529  vring->used_wrap_counter);
530  }
531  else
532  {
533  vlib_cli_output (vm,
534  " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
535  vring->avail->flags, vring->avail->idx,
536  vring->used->flags, vring->used->idx);
537  }
538  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
539  {
540  vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
541  vring->call_fd);
542  }
543  if (show_descr)
544  {
545  vlib_cli_output (vm, "\n descriptor table:\n");
546  vlib_cli_output (vm,
547  " id addr len flags next/id user_addr\n");
548  vlib_cli_output (vm,
549  " ===== ================== ===== ====== ======== ==================\n");
550  for (j = 0; j < vring->size; j++)
551  {
552  if (vif->is_packed)
553  {
554  vring_packed_desc_t *desc = &vring->packed_desc[j];
555  vlib_cli_output (vm,
556  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
557  j, desc->addr,
558  desc->len,
559  desc->flags, desc->id, desc->addr);
560  }
561  else
562  {
563  vring_desc_t *desc = &vring->desc[j];
564  vlib_cli_output (vm,
565  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
566  j, desc->addr,
567  desc->len,
568  desc->flags, desc->next, desc->addr);
569  }
570  }
571  }
572  }
573 
574  }
575 
576 }
577 
578 static clib_error_t *
580 {
581  virtio_main_t *vim = &virtio_main;
582  clib_error_t *error = 0;
583 
584  vim->log_default = vlib_log_register_class ("virtio", 0);
585  vlib_log_debug (vim->log_default, "initialized");
586 
587  return error;
588 }
589 
591 
592 /*
593  * fd.io coding-style-patch-verification: ON
594  *
595  * Local Variables:
596  * eval: (c-set-style "gnu")
597  * End:
598  */
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:338
gro_flow_table_t * flow_table
Definition: virtio.h:109
#define vec_foreach_index(var, v)
Iterate over vector indices.
vring_desc_event_t * device_event
Definition: virtio.h:79
format_function_t format_vnet_hw_if_index_name
void virtio_set_net_hdr_size(virtio_if_t *vif)
Definition: virtio.c:252
virtio_if_t * interfaces
Definition: virtio.h:219
#define CLIB_UNUSED(x)
Definition: clib.h:87
void virtio_show(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, u32 type)
Definition: virtio.c:262
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:937
u8 host_carrier_up
Definition: virtio.h:189
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static_always_inline u8 * gro_flow_table_format(u8 *s, va_list *args)
Definition: gro.h:255
unsigned long u64
Definition: types.h:89
int gso_enabled
Definition: virtio.h:137
u32 host_mtu_size
Definition: virtio.h:183
u32 dev_instance
Definition: virtio.h:157
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
int kick_fd
Definition: virtio.h:93
u64 private_data
Definition: file.h:64
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 file_descriptor
Definition: file.h:54
static heap_elt_t * last(heap_header_t *h)
Definition: heap.c:53
void virtio_vring_set_numa_node(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
Definition: virtio.c:236
vlib_main_t * vm
Definition: in2out_ed.c:1580
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:520
u16 mask
Definition: flow_types.api:52
int call_fd
Definition: virtio.h:94
vlib_main_t ** vlib_mains
Definition: buffer.c:332
unsigned char u8
Definition: types.h:56
clib_error_t * virtio_vring_free_tx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
Definition: virtio.c:174
#define VIRTIO_FEATURE(X)
Definition: virtio_std.h:69
vring_desc_t * desc
Definition: virtio.h:71
clib_file_function_t * read_function
Definition: file.h:67
static void clib_spinlock_free(clib_spinlock_t *p)
Definition: lock.h:72
#define VRING_AVAIL_F_NO_INTERRUPT
Definition: virtio_std.h:85
u64 features
Definition: virtio.h:130
u32 hw_if_index
Definition: virtio.h:151
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
static clib_error_t * virtio_init(vlib_main_t *vm)
Definition: virtio.c:579
#define TX_QUEUE_ACCESS(X)
Definition: virtio.h:39
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
void device_status(vlib_main_t *vm, virtio_if_t *vif)
Definition: pci.c:170
static_always_inline void vnet_device_input_set_interrupt_pending(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
Definition: devices.h:127
description fragment has unexpected format
Definition: map.api:433
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
clib_spinlock_t lockp
Definition: virtio.h:66
#define clib_error_return(e, args...)
Definition: error.h:99
clib_file_main_t file_main
Definition: main.c:63
const cJSON *const b
Definition: cJSON.h:255
unsigned int u32
Definition: types.h:88
#define vlib_log_debug(...)
Definition: log.h:136
u16 queue_id
Definition: virtio.h:84
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
u16 num_txqs
Definition: virtio.h:134
vl_api_fib_path_type_t type
Definition: fib_types.api:123
Definition: cJSON.c:84
u8 * description
Definition: file.h:70
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:546
int * vhost_fds
Definition: virtio.h:177
static_always_inline uword vnet_get_device_input_thread_index(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
Definition: devices.h:118
vring_avail_t * avail
Definition: virtio.h:73
vring_desc_event_t * driver_event
Definition: virtio.h:78
unsigned short u16
Definition: types.h:57
u32 size
Definition: vhost_user.h:106
pci_addr_t pci_addr
Definition: virtio.h:195
vnet_main_t vnet_main
Definition: misc.c:43
u8 buffer_pool_index
Definition: virtio.h:106
#define virtio_log_debug(vif, f,...)
Definition: virtio.h:272
int packet_coalesce
Definition: virtio.h:155
vring_used_t * used
Definition: virtio.h:72
u16 desc_next
Definition: virtio.h:86
u16 virtio_net_hdr_sz
Definition: virtio.h:148
u16 num_rxqs
Definition: virtio.h:133
virtio_vring_t * rxq_vrings
Definition: virtio.h:135
format_function_t format_virtio_device_name
Definition: virtio.h:247
u16 last_used_idx
Definition: virtio.h:87
void virtio_free_buffers(vlib_main_t *vm, virtio_vring_t *vring)
Definition: virtio.c:137
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
static_always_inline void gro_flow_table_free(gro_flow_table_t *flow_table)
Definition: gro.h:171
static_always_inline u32 gro_flow_table_init(gro_flow_table_t **flow_table, u8 is_l2, u32 node_index)
Definition: gro.h:120
u32 call_file_index
Definition: virtio.h:95
u8 * net_ns
Definition: virtio.h:179
u8 mac_addr[6]
Definition: virtio.h:170
u32 flags
Definition: virtio.h:131
vlib_log_class_t log_default
Definition: virtio.h:217
static uword round_pow2(uword x, uword pow2)
Definition: clib.h:265
virtio_if_type_t type
Definition: virtio.h:149
clib_error_t * virtio_set_packet_buffering(virtio_if_t *vif, u16 buffering_size)
Definition: virtio.c:214
vring_packed_desc_t * packed_desc
Definition: virtio.h:77
#define ASSERT(truth)
u16 avail_wrap_counter
Definition: virtio.h:99
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:696
u64 remote_features
Definition: virtio.h:159
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
static void clib_file_del_by_index(clib_file_main_t *um, uword index)
Definition: file.h:119
clib_error_t * virtio_vring_init(vlib_main_t *vm, virtio_if_t *vif, u16 idx, u16 sz)
Definition: virtio.c:64
u8 host_mac_addr[6]
Definition: virtio.h:181
static void clib_mem_free(void *p)
Definition: mem.h:311
void virtio_set_packet_coalesce(virtio_if_t *vif)
Definition: virtio.c:199
virtio_main_t virtio_main
Definition: virtio.c:35
vl_api_ip4_address_t hi
Definition: arp.api:37
static uword is_pow2(uword x)
Definition: clib.h:253
u16 ring[0]
Definition: virtio_std.h:99
virtio_vring_buffering_t * buffering
Definition: virtio.h:108
u16 used_wrap_counter
Definition: virtio.h:100
#define RX_QUEUE_ACCESS(X)
Definition: virtio.h:40
int csum_offload_enabled
Definition: virtio.h:138
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int packet_buffering
Definition: virtio.h:156
u32 * buffers
Definition: virtio.h:82
static_always_inline clib_error_t * virtio_vring_buffering_init(virtio_vring_buffering_t **buffering, u32 node_index, u16 size)
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:261
virtio_vring_t * cxq_vring
Definition: virtio.h:194
clib_error_t * virtio_vring_free_rx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
Definition: virtio.c:152
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
static_always_inline u8 * virtio_vring_buffering_format(u8 *s, va_list *args)
int is_packed
Definition: virtio.h:210
#define vec_foreach(var, vec)
Vector iterator.
Definition: file.h:51
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
static u8 vlib_buffer_pool_get_default_for_numa(vlib_main_t *vm, u32 numa_node)
Definition: buffer_funcs.h:199
int * tap_fds
Definition: virtio.h:141
format_function_t format_vlib_pci_addr
Definition: pci.h:326
u16 desc_in_use
Definition: virtio.h:85
virtio_vring_t * txq_vrings
Definition: virtio.h:136
static clib_error_t * call_read_ready(clib_file_t *uf)
Definition: virtio.c:45
static_always_inline void virtio_vring_buffering_free(vlib_main_t *vm, virtio_vring_buffering_t *buffering)
u8 * host_if_name
Definition: virtio.h:178
static_always_inline void clib_memset_u32(void *p, u32 val, uword count)
Definition: string.h:332