FD.io VPP  v21.10.1-2-g0a485f517
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>
36 
38 
39 #define _IOCTL(fd,a,...) \
40  if (ioctl (fd, a, __VA_ARGS__) < 0) \
41  { \
42  err = clib_error_return_unix (0, "ioctl(" #a ")"); \
43  goto error; \
44  }
45 
46 static clib_error_t *
48 {
49  vnet_main_t *vnm = vnet_get_main ();
50  u64 b;
51 
52  CLIB_UNUSED (ssize_t size) = read (uf->file_descriptor, &b, sizeof (b));
54 
55  return 0;
56 }
57 
58 
61 {
62  virtio_vring_t *vring;
63  int i;
64 
65  if (!is_pow2 (sz))
66  return clib_error_return (0, "ring size must be power of 2");
67 
68  if (sz > 32768)
69  return clib_error_return (0, "ring size must be 32768 or lower");
70 
71  if (sz == 0)
72  sz = 256;
73 
74  if (idx % 2)
75  {
79  vring = vec_elt_at_index (vif->txq_vrings, TX_QUEUE_ACCESS (idx));
80  if (thm->n_vlib_mains > vif->num_txqs)
81  clib_spinlock_init (&vring->lockp);
82  }
83  else
84  {
87  vring = vec_elt_at_index (vif->rxq_vrings, RX_QUEUE_ACCESS (idx));
88  }
89  i = sizeof (vring_desc_t) * sz;
92  clib_memset (vring->desc, 0, i);
93 
94  i = sizeof (vring_avail_t) + sz * sizeof (vring->avail->ring[0]);
97  clib_memset (vring->avail, 0, i);
98  // tell kernel that we don't need interrupt
100 
101  i = sizeof (vring_used_t) + sz * sizeof (vring_used_elem_t);
104  clib_memset (vring->used, 0, i);
105 
106  vring->queue_id = idx;
107  ASSERT (vring->buffers == 0);
109 
110  if (idx & 1)
111  {
112  clib_memset_u32 (vring->buffers, ~0, sz);
113  // tx path: suppress the interrupts from kernel
114  vring->call_fd = -1;
115  }
116  else
117  vring->call_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
118 
119  vring->size = sz;
120  vring->kick_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
121  virtio_log_debug (vif, "vring %u size %u call_fd %d kick_fd %d", idx,
122  vring->size, vring->call_fd, vring->kick_fd);
123 
124  return 0;
125 }
126 
127 inline void
129 {
130  u16 used = vring->desc_in_use;
131  u16 last = vring->last_used_idx;
132  u16 mask = vring->size - 1;
133 
134  while (used)
135  {
136  vlib_buffer_free (vm, &vring->buffers[last & mask], 1);
137  last++;
138  used--;
139  }
140 }
141 
142 clib_error_t *
144 {
145  virtio_vring_t *vring =
147 
149  close (vring->kick_fd);
150  close (vring->call_fd);
151  if (vring->used)
152  {
153  virtio_free_buffers (vm, vring);
154  clib_mem_free (vring->used);
155  }
156  if (vring->desc)
157  clib_mem_free (vring->desc);
158  if (vring->avail)
159  clib_mem_free (vring->avail);
160  vec_free (vring->buffers);
161  return 0;
162 }
163 
164 clib_error_t *
166 {
167  virtio_vring_t *vring =
169 
170  close (vring->kick_fd);
171  if (vring->used)
172  {
173  virtio_free_buffers (vm, vring);
174  clib_mem_free (vring->used);
175  }
176  if (vring->desc)
177  clib_mem_free (vring->desc);
178  if (vring->avail)
179  clib_mem_free (vring->avail);
180  vec_free (vring->buffers);
183  clib_spinlock_free (&vring->lockp);
184  return 0;
185 }
186 
187 void
189 {
190  vnet_main_t *vnm = vnet_get_main ();
192  virtio_vring_t *vring;
193  vif->packet_coalesce = 1;
194  vec_foreach (vring, vif->txq_vrings)
195  {
197  vif->type & (VIRTIO_IF_TYPE_TAP |
198  VIRTIO_IF_TYPE_PCI), hw->tx_node_index);
199  }
200 }
201 
202 clib_error_t *
204 {
205  vnet_main_t *vnm = vnet_get_main ();
207  virtio_vring_t *vring;
208  clib_error_t *error = 0;
209  vif->packet_buffering = 1;
210 
211  vec_foreach (vring, vif->txq_vrings)
212  {
213  if ((error =
215  buffering_size)))
216  {
217  break;
218  }
219  }
220 
221  return error;
222 }
223 
224 static void
226 {
227  if (vif->is_packed)
228  virtio_refill_vring_packed (vm, vif, vif->type, vring,
229  vif->virtio_net_hdr_sz,
230  virtio_input_node.index);
231  else
232  virtio_refill_vring_split (vm, vif, vif->type, vring,
233  vif->virtio_net_hdr_sz,
234  virtio_input_node.index);
235 }
236 
237 void
239 {
240  vnet_main_t *vnm = vnet_get_main ();
241  virtio_vring_t *vring;
242  u32 i = 0;
243 
245 
246  vec_foreach (vring, vif->rxq_vrings)
247  {
249  vnm, vif->hw_if_index, RX_QUEUE_ACCESS (vring->queue_id),
253  if (vif->type == VIRTIO_IF_TYPE_TAP || vif->type == VIRTIO_IF_TYPE_TUN)
254  {
255 
256  clib_file_t f = {
257  .read_function = call_read_ready,
259  .file_descriptor = vring->call_fd,
260  .private_data = vring->queue_index,
261  .description = format (0, "%U vring %u", format_virtio_device_name,
262  vif->dev_instance, vring->queue_id),
263  };
264 
267  vring->call_file_index);
268  }
269  else if ((vif->type == VIRTIO_IF_TYPE_PCI) && (vif->support_int_mode) &&
271  {
272  u32 file_index;
273  file_index =
276  file_index);
277  i++;
278  }
282  virtio_vring_fill (vm, vif, vring);
283  }
285 }
286 
287 inline void
289 {
290  if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_MRG_RXBUF) ||
291  vif->features & VIRTIO_FEATURE (VIRTIO_F_VERSION_1))
292  vif->virtio_net_hdr_sz = sizeof (virtio_net_hdr_v1_t);
293  else
294  vif->virtio_net_hdr_sz = sizeof (virtio_net_hdr_t);
295 }
296 
297 inline void
298 virtio_show (vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr,
300 {
301  u32 i, j, hw_if_index;
302  virtio_if_t *vif;
303  vnet_main_t *vnm = &vnet_main;
304  virtio_main_t *mm = &virtio_main;
305  virtio_vring_t *vring;
306  struct feat_struct
307  {
308  u8 bit;
309  char *str;
310  };
311  struct feat_struct *feat_entry;
312 
313  static struct feat_struct feat_array[] = {
314 #define _(s,b) { .str = #s, .bit = b, },
316 #undef _
317  {.str = NULL}
318  };
319 
320  struct feat_struct *flag_entry;
321  static struct feat_struct flags_array[] = {
322 #define _(b,e,s) { .bit = b, .str = s, },
324 #undef _
325  {.str = NULL}
326  };
327 
328  if (!hw_if_indices)
329  return;
330 
331  for (hw_if_index = 0; hw_if_index < vec_len (hw_if_indices); hw_if_index++)
332  {
334  vnet_get_hw_interface (vnm, hw_if_indices[hw_if_index]);
335  vif = pool_elt_at_index (mm->interfaces, hi->dev_instance);
336  if (vif->type != type)
337  continue;
338  vlib_cli_output (vm, "Interface: %U (ifindex %d)",
340  hw_if_indices[hw_if_index], vif->hw_if_index);
341  if (type == VIRTIO_IF_TYPE_PCI)
342  {
343  vlib_cli_output (vm, " PCI Address: %U", format_vlib_pci_addr,
344  &vif->pci_addr);
345  }
346  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
347  {
348  u8 *str = 0;
349  if (vif->host_if_name)
350  vlib_cli_output (vm, " name \"%s\"", vif->host_if_name);
351  if (vif->net_ns)
352  vlib_cli_output (vm, " host-ns \"%s\"", vif->net_ns);
353  if (vif->host_mtu_size)
354  vlib_cli_output (vm, " host-mtu-size \"%d\"",
355  vif->host_mtu_size);
356  if (type == VIRTIO_IF_TYPE_TAP)
357  vlib_cli_output (vm, " host-mac-addr: %U",
359  vlib_cli_output (vm, " host-carrier-up: %u", vif->host_carrier_up);
360 
362  str = format (str, " %d", vif->vhost_fds[i]);
363  vlib_cli_output (vm, " vhost-fds%v", str);
364  vec_free (str);
365  vec_foreach_index (i, vif->tap_fds)
366  str = format (str, " %d", vif->tap_fds[i]);
367  vlib_cli_output (vm, " tap-fds%v", str);
368  vec_free (str);
369  }
370  vlib_cli_output (vm, " gso-enabled %d", vif->gso_enabled);
371  vlib_cli_output (vm, " csum-enabled %d", vif->csum_offload_enabled);
372  vlib_cli_output (vm, " packet-coalesce %d", vif->packet_coalesce);
373  vlib_cli_output (vm, " packet-buffering %d", vif->packet_buffering);
374  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI))
375  vlib_cli_output (vm, " Mac Address: %U", format_ethernet_address,
376  vif->mac_addr);
377  vlib_cli_output (vm, " Device instance: %u", vif->dev_instance);
378  vlib_cli_output (vm, " flags 0x%x", vif->flags);
379  flag_entry = (struct feat_struct *) &flags_array;
380  while (flag_entry->str)
381  {
382  if (vif->flags & (1ULL << flag_entry->bit))
383  vlib_cli_output (vm, " %s (%d)", flag_entry->str,
384  flag_entry->bit);
385  flag_entry++;
386  }
387  if (type == VIRTIO_IF_TYPE_PCI)
388  {
389  device_status (vm, vif);
390  }
391  vlib_cli_output (vm, " features 0x%lx", vif->features);
392  feat_entry = (struct feat_struct *) &feat_array;
393  while (feat_entry->str)
394  {
395  if (vif->features & (1ULL << feat_entry->bit))
396  vlib_cli_output (vm, " %s (%d)", feat_entry->str,
397  feat_entry->bit);
398  feat_entry++;
399  }
400  vlib_cli_output (vm, " remote-features 0x%lx", vif->remote_features);
401  feat_entry = (struct feat_struct *) &feat_array;
402  while (feat_entry->str)
403  {
404  if (vif->remote_features & (1ULL << feat_entry->bit))
405  vlib_cli_output (vm, " %s (%d)", feat_entry->str,
406  feat_entry->bit);
407  feat_entry++;
408  }
409  vlib_cli_output (vm, " Number of RX Virtqueue %u", vif->num_rxqs);
410  vlib_cli_output (vm, " Number of TX Virtqueue %u", vif->num_txqs);
411  if (type == VIRTIO_IF_TYPE_PCI && vif->cxq_vring != NULL &&
412  vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
413  vlib_cli_output (vm, " Number of CTRL Virtqueue 1");
415  {
416  vring = vec_elt_at_index (vif->rxq_vrings, i);
417  vlib_cli_output (vm, " Virtqueue (RX) %d", vring->queue_id);
419  " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
420  vring->size, vring->last_used_idx, vring->desc_next,
421  vring->desc_in_use);
422  if (vif->is_packed)
423  {
425  " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
426  vring->driver_event->flags,
427  vring->driver_event->off_wrap,
428  vring->device_event->flags,
429  vring->device_event->off_wrap);
431  " avail wrap counter %d, used wrap counter %d",
432  vring->avail_wrap_counter,
433  vring->used_wrap_counter);
434  }
435  else
437  " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
438  vring->avail->flags, vring->avail->idx,
439  vring->used->flags, vring->used->idx);
440  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
441  {
442  vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
443  vring->call_fd);
444  }
445  if (show_descr)
446  {
447  vlib_cli_output (vm, "\n descriptor table:\n");
449  " id addr len flags next/id user_addr\n");
451  " ===== ================== ===== ====== ======= ==================\n");
452  for (j = 0; j < vring->size; j++)
453  {
454  if (vif->is_packed)
455  {
456  vring_packed_desc_t *desc = &vring->packed_desc[j];
458  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
459  j, desc->addr,
460  desc->len,
461  desc->flags, desc->id, desc->addr);
462  }
463  else
464  {
465  vring_desc_t *desc = &vring->desc[j];
467  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
468  j, desc->addr,
469  desc->len,
470  desc->flags, desc->next, desc->addr);
471  }
472  }
473  }
474  }
476  {
477  vring = vec_elt_at_index (vif->txq_vrings, i);
478  vlib_cli_output (vm, " Virtqueue (TX) %d", vring->queue_id);
480  " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
481  vring->size, vring->last_used_idx, vring->desc_next,
482  vring->desc_in_use);
483  if (vif->is_packed)
484  {
486  " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
487  vring->driver_event->flags,
488  vring->driver_event->off_wrap,
489  vring->device_event->flags,
490  vring->device_event->off_wrap);
492  " avail wrap counter %d, used wrap counter %d",
493  vring->avail_wrap_counter,
494  vring->used_wrap_counter);
495  }
496  else
498  " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
499  vring->avail->flags, vring->avail->idx,
500  vring->used->flags, vring->used->idx);
501  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
502  {
503  vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
504  vring->call_fd);
505  }
506  if (vring->flow_table)
507  {
509  vring->flow_table);
510  }
511  if (vif->packet_buffering)
512  {
514  vring->buffering);
515  }
516  if (show_descr)
517  {
518  vlib_cli_output (vm, "\n descriptor table:\n");
520  " id addr len flags next/id user_addr\n");
522  " ===== ================== ===== ====== ======== ==================\n");
523  for (j = 0; j < vring->size; j++)
524  {
525  if (vif->is_packed)
526  {
527  vring_packed_desc_t *desc = &vring->packed_desc[j];
529  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
530  j, desc->addr,
531  desc->len,
532  desc->flags, desc->id, desc->addr);
533  }
534  else
535  {
536  vring_desc_t *desc = &vring->desc[j];
538  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
539  j, desc->addr,
540  desc->len,
541  desc->flags, desc->next, desc->addr);
542  }
543  }
544  }
545  }
546  if (type == VIRTIO_IF_TYPE_PCI && vif->cxq_vring != NULL &&
547  vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
548  {
549  vring = vif->cxq_vring;
550  vlib_cli_output (vm, " Virtqueue (CTRL) %d", vring->queue_id);
552  " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
553  vring->size, vring->last_used_idx,
554  vring->desc_next, vring->desc_in_use);
555  if (vif->is_packed)
556  {
558  " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
559  vring->driver_event->flags,
560  vring->driver_event->off_wrap,
561  vring->device_event->flags,
562  vring->device_event->off_wrap);
564  " avail wrap counter %d, used wrap counter %d",
565  vring->avail_wrap_counter,
566  vring->used_wrap_counter);
567  }
568  else
569  {
571  " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
572  vring->avail->flags, vring->avail->idx,
573  vring->used->flags, vring->used->idx);
574  }
575  if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
576  {
577  vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
578  vring->call_fd);
579  }
580  if (show_descr)
581  {
582  vlib_cli_output (vm, "\n descriptor table:\n");
584  " id addr len flags next/id user_addr\n");
586  " ===== ================== ===== ====== ======== ==================\n");
587  for (j = 0; j < vring->size; j++)
588  {
589  if (vif->is_packed)
590  {
591  vring_packed_desc_t *desc = &vring->packed_desc[j];
593  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
594  j, desc->addr,
595  desc->len,
596  desc->flags, desc->id, desc->addr);
597  }
598  else
599  {
600  vring_desc_t *desc = &vring->desc[j];
602  " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
603  j, desc->addr,
604  desc->len,
605  desc->flags, desc->next, desc->addr);
606  }
607  }
608  }
609  }
610 
611  }
612 
613 }
614 
615 static clib_error_t *
617 {
618  virtio_main_t *vim = &virtio_main;
619  clib_error_t *error = 0;
620 
621  vim->log_default = vlib_log_register_class ("virtio", 0);
622  vlib_log_debug (vim->log_default, "initialized");
623 
624  return error;
625 }
626 
628 
629 /*
630  * fd.io coding-style-patch-verification: ON
631  *
632  * Local Variables:
633  * eval: (c-set-style "gnu")
634  * End:
635  */
vlib.h
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
clib_file::file_descriptor
u32 file_descriptor
Definition: file.h:54
pci.h
VNET_HW_IF_RXQ_THREAD_ANY
#define VNET_HW_IF_RXQ_THREAD_ANY
Definition: interface.h:598
vring_used_elem_t
Definition: virtio_std.h:109
virtio_vring_free_rx
clib_error_t * virtio_vring_free_rx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
Definition: virtio.c:143
vlib_buffer_free
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:979
file_main
clib_file_main_t file_main
Definition: main.c:63
virtio_vring_t::flow_table
gro_flow_table_t * flow_table
Definition: virtio.h:110
VIRTIO_MSIX_ENABLED
@ VIRTIO_MSIX_ENABLED
Definition: pci.h:96
virtio_vring_buffering_format
static_always_inline u8 * virtio_vring_buffering_format(u8 *s, va_list *args)
Definition: virtio_buffering.h:226
virtio_vring_t::call_fd
int call_fd
Definition: virtio.h:95
virtio_vring_free_tx
clib_error_t * virtio_vring_free_tx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
Definition: virtio.c:165
TX_QUEUE_ACCESS
#define TX_QUEUE_ACCESS(X)
Definition: virtio.h:39
virtio_vring_fill
static void virtio_vring_fill(vlib_main_t *vm, virtio_if_t *vif, virtio_vring_t *vring)
Definition: virtio.c:225
foreach_virtio_net_features
@ foreach_virtio_net_features
Definition: virtio_std.h:63
virtio_vring_t
Definition: virtio.h:63
vring_used_t::flags
u16 flags
Definition: virtio_std.h:117
virtio.h
foreach_virtio_if_flag
@ foreach_virtio_if_flag
Definition: virtio.h:33
vnet_hw_if_set_rx_queue_mode
int vnet_hw_if_set_rx_queue_mode(vnet_main_t *vnm, u32 queue_index, vnet_hw_if_rx_mode mode)
Definition: rx_queue.c:167
f
vlib_frame_t * f
Definition: interface_output.c:1098
vnet_hw_if_get_rx_queue_numa_node
static_always_inline u8 vnet_hw_if_get_rx_queue_numa_node(vnet_main_t *vnm, u32 queue_index)
Definition: rx_queue_funcs.h:84
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
vring_avail_t::ring
u16 ring[0]
Definition: virtio_std.h:105
virtio_if_t::mac_addr
u8 mac_addr[6]
Definition: virtio.h:171
virtio_if_t::flags
u32 flags
Definition: virtio.h:132
virtio_show
void virtio_show(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, virtio_if_type_t type)
Definition: virtio.c:298
format_ethernet_address
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
virtio_init
static clib_error_t * virtio_init(vlib_main_t *vm)
Definition: virtio.c:616
vlib_log_register_class
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:339
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
virtio_if_t::host_carrier_up
u8 host_carrier_up
Definition: virtio.h:190
virtio_vring_t::kick_fd
int kick_fd
Definition: virtio.h:94
vnet_hw_interface_t::tx_node_index
u32 tx_node_index
Definition: interface.h:653
u16
unsigned short u16
Definition: types.h:57
vring_desc_t::addr
u64 addr
Definition: virtio_std.h:95
clib_file::private_data
u64 private_data
Definition: file.h:64
VNET_HW_IF_RX_MODE_POLLING
@ VNET_HW_IF_RX_MODE_POLLING
Definition: interface.h:56
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
VIRTIO_FEATURE
#define VIRTIO_FEATURE(X)
Definition: virtio_std.h:67
gro_flow_table_init
static_always_inline u32 gro_flow_table_init(gro_flow_table_t **flow_table, u8 is_l2, u32 node_index)
Definition: gro.h:120
virtio_vring_t::queue_id
u16 queue_id
Definition: virtio.h:84
virtio_if_t::packet_coalesce
int packet_coalesce
Definition: virtio.h:156
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
virtio_main_t::log_default
vlib_log_class_t log_default
Definition: virtio.h:218
virtio_vring_t::size
u16 size
Definition: virtio.h:83
virtio_vring_init
clib_error_t * virtio_vring_init(vlib_main_t *vm, virtio_if_t *vif, u16 idx, u16 sz)
Definition: virtio.c:60
ethernet.h
virtio_vring_t::avail
vring_avail_t * avail
Definition: virtio.h:73
error
Definition: cJSON.c:88
virtio_if_t::num_rxqs
u16 num_rxqs
Definition: virtio.h:134
virtio_if_t::host_mac_addr
u8 host_mac_addr[6]
Definition: virtio.h:182
ip6_packet.h
virtio_if_t::vhost_fds
int * vhost_fds
Definition: virtio.h:178
gro_flow_table_free
static_always_inline void gro_flow_table_free(gro_flow_table_t *flow_table)
Definition: gro.h:171
round_pow2
static uword round_pow2(uword x, uword pow2)
Definition: clib.h:279
virtio_if_t::packet_buffering
int packet_buffering
Definition: virtio.h:157
virtio_main
virtio_main_t virtio_main
Definition: virtio.c:37
virtio_set_packet_coalesce
void virtio_set_packet_coalesce(virtio_if_t *vif)
Definition: virtio.c:188
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
virtio_vring_t::buffer_pool_index
u8 buffer_pool_index
Definition: virtio.h:107
virtio_refill_vring_packed
static_always_inline void virtio_refill_vring_packed(vlib_main_t *vm, virtio_if_t *vif, virtio_if_type_t type, virtio_vring_t *vring, const int hdr_sz, u32 node_index)
Definition: virtio_inline.h:96
clib_memset_u32
static_always_inline void clib_memset_u32(void *p, u32 val, uword count)
Definition: string.h:349
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
UNIX_FILE_EVENT_EDGE_TRIGGERED
#define UNIX_FILE_EVENT_EDGE_TRIGGERED
Definition: file.h:58
device_status
void device_status(vlib_main_t *vm, virtio_if_t *vif)
Definition: pci.c:172
virtio_if_t::txq_vrings
virtio_vring_t * txq_vrings
Definition: virtio.h:137
virtio_vring_t::desc_next
u16 desc_next
Definition: virtio.h:87
virtio_vring_t::used
vring_used_t * used
Definition: virtio.h:72
virtio_if_t::pci_addr
pci_addr_t pci_addr
Definition: virtio.h:196
vring_desc_t::flags
u16 flags
Definition: virtio_std.h:97
virtio_if_t::pci_dev_handle
u32 pci_dev_handle
Definition: virtio.h:145
virtio_vring_t::lockp
clib_spinlock_t lockp
Definition: virtio.h:66
vring_desc_t
Definition: virtio_std.h:93
virtio_if_t::net_ns
u8 * net_ns
Definition: virtio.h:180
vring_avail_t::flags
u16 flags
Definition: virtio_std.h:103
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
virtio_vring_t::desc
vring_desc_t * desc
Definition: virtio.h:71
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
virtio_if_type_t
virtio_if_type_t
Definition: virtio.h:50
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
clib_file
Definition: file.h:51
virtio_if_t::features
u64 features
Definition: virtio.h:131
rx_queue_funcs.h
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
virtio_if_t::csum_offload_enabled
int csum_offload_enabled
Definition: virtio.h:139
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
format_vnet_hw_if_index_name
format_function_t format_vnet_hw_if_index_name
Definition: interface_funcs.h:454
last
static heap_elt_t * last(heap_header_t *h)
Definition: heap.c:53
vnet_hw_if_update_runtime_data
void vnet_hw_if_update_runtime_data(vnet_main_t *vnm, u32 hw_if_index)
Definition: runtime.c:58
virtio_if_t::msix_enabled
u32 msix_enabled
Definition: virtio.h:146
virtio_if_t::hw_if_index
u32 hw_if_index
Definition: virtio.h:152
virtio_set_net_hdr_size
void virtio_set_net_hdr_size(virtio_if_t *vif)
Definition: virtio.c:288
clib_spinlock_free
static void clib_spinlock_free(clib_spinlock_t *p)
Definition: lock.h:72
virtio_vring_t::mode
vnet_hw_if_rx_mode mode
Definition: virtio.h:108
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
vring_desc_t::len
u32 len
Definition: virtio_std.h:96
vlib_log_debug
#define vlib_log_debug(...)
Definition: log.h:137
virtio_if_t::host_if_name
u8 * host_if_name
Definition: virtio.h:179
vnet_hw_if_rx_queue_set_int_pending
static_always_inline void vnet_hw_if_rx_queue_set_int_pending(vnet_main_t *vnm, u32 queue_index)
Definition: rx_queue_funcs.h:52
VRING_AVAIL_F_NO_INTERRUPT
#define VRING_AVAIL_F_NO_INTERRUPT
Definition: virtio_std.h:91
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
virtio_vring_buffering_free
static_always_inline void virtio_vring_buffering_free(vlib_main_t *vm, virtio_vring_buffering_t *buffering)
Definition: virtio_buffering.h:86
vnet_hw_if_set_rx_queue_file_index
void vnet_hw_if_set_rx_queue_file_index(vnet_main_t *vnm, u32 queue_index, u32 file_index)
Definition: rx_queue.c:144
virtio_vring_t::queue_index
u32 queue_index
Definition: virtio.h:85
virtio_vring_t::driver_event
vring_desc_event_t * driver_event
Definition: virtio.h:78
virtio_vring_t::last_used_idx
u16 last_used_idx
Definition: virtio.h:88
ip4_packet.h
virtio_main_t
Definition: virtio.h:214
virtio_vring_t::avail_wrap_counter
u16 avail_wrap_counter
Definition: virtio.h:100
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
size
u32 size
Definition: vhost_user.h:125
virtio_if_t::dev_instance
u32 dev_instance
Definition: virtio.h:158
vring_avail_t
Definition: virtio_std.h:101
virtio_log_debug
#define virtio_log_debug(vif, f,...)
Definition: virtio.h:273
virtio_if_t::cxq_vring
virtio_vring_t * cxq_vring
Definition: virtio.h:195
format_vlib_pci_addr
format_function_t format_vlib_pci_addr
Definition: pci.h:326
RX_QUEUE_ACCESS
#define RX_QUEUE_ACCESS(X)
Definition: virtio.h:40
u64
unsigned long u64
Definition: types.h:89
virtio_if_t::num_txqs
u16 num_txqs
Definition: virtio.h:135
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
u32
unsigned int u32
Definition: types.h:88
virtio_if_t::virtio_net_hdr_sz
u16 virtio_net_hdr_sz
Definition: virtio.h:149
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
virtio_input_node
vlib_node_registration_t virtio_input_node
(constructor) VLIB_REGISTER_NODE (virtio_input_node)
Definition: node.c:498
vlib_thread_main_t
Definition: threads.h:243
virtio_if_t::remote_features
u64 remote_features
Definition: virtio.h:160
virtio_if_t::support_int_mode
u8 support_int_mode
Definition: virtio.h:206
call_read_ready
static clib_error_t * call_read_ready(clib_file_t *uf)
Definition: virtio.c:47
virtio_vring_t::packed_desc
vring_packed_desc_t * packed_desc
Definition: virtio.h:77
virtio_if_t::tap_fds
int * tap_fds
Definition: virtio.h:142
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
pci.h
virtio_if_t::type
virtio_if_type_t type
Definition: virtio.h:150
vring_used_t::idx
u16 idx
Definition: virtio_std.h:118
virtio_if_t
Definition: virtio.h:128
clib_file_add
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
virtio_vring_t::call_file_index
u32 call_file_index
Definition: virtio.h:96
virtio_if_t::rxq_vrings
virtio_vring_t * rxq_vrings
Definition: virtio.h:136
virtio_main_t::interfaces
virtio_if_t * interfaces
Definition: virtio.h:220
format_virtio_device_name
format_function_t format_virtio_device_name
Definition: virtio.h:248
vnet_main
vnet_main_t vnet_main
Definition: misc.c:43
vlib_buffer_pool_get_default_for_numa
static u8 vlib_buffer_pool_get_default_for_numa(vlib_main_t *vm, u32 numa_node)
Definition: buffer_funcs.h:189
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
virtio_free_buffers
void virtio_free_buffers(vlib_main_t *vm, virtio_vring_t *vring)
Definition: virtio.c:128
vnet_hw_if_register_rx_queue
u32 vnet_hw_if_register_rx_queue(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id, u32 thread_index)
Definition: rx_queue.c:64
virtio_vring_t::buffers
u32 * buffers
Definition: virtio.h:82
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
unix.h
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
virtio_vring_t::buffering
virtio_vring_buffering_t * buffering
Definition: virtio.h:109
virtio_vring_t::desc_in_use
u16 desc_in_use
Definition: virtio.h:86
vlib_pci_get_msix_file_index
uword vlib_pci_get_msix_file_index(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 index)
Definition: pci.c:917
virtio_refill_vring_split
static_always_inline void virtio_refill_vring_split(vlib_main_t *vm, virtio_if_t *vif, virtio_if_type_t type, virtio_vring_t *vring, const int hdr_sz, u32 node_index)
Definition: virtio_inline.h:31
i
int i
Definition: flowhash_template.h:376
virtio_inline.h
vring_desc_t::next
u16 next
Definition: virtio_std.h:98
virtio_set_packet_buffering
clib_error_t * virtio_set_packet_buffering(virtio_if_t *vif, u16 buffering_size)
Definition: virtio.c:203
clib_mem_alloc_aligned
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:264
clib_file_del_by_index
static void clib_file_del_by_index(clib_file_main_t *um, uword index)
Definition: file.h:119
virtio_vring_buffering_init
static_always_inline clib_error_t * virtio_vring_buffering_init(virtio_vring_buffering_t **buffering, u32 node_index, u16 size)
Definition: virtio_buffering.h:37
clib_error_t::flags
uword flags
Definition: clib_error.h:29
virtio_vring_t::device_event
vring_desc_event_t * device_event
Definition: virtio.h:79
virtio_vring_set_rx_queues
void virtio_vring_set_rx_queues(vlib_main_t *vm, virtio_if_t *vif)
Definition: virtio.c:238
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
is_pow2
static uword is_pow2(uword x)
Definition: clib.h:267
virtio_if_t::is_packed
int is_packed
Definition: virtio.h:211
virtio_vring_t::used_wrap_counter
u16 used_wrap_counter
Definition: virtio.h:101
vring_avail_t::idx
u16 idx
Definition: virtio_std.h:104
virtio_if_t::host_mtu_size
u32 host_mtu_size
Definition: virtio.h:184
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
gro_flow_table_format
static_always_inline u8 * gro_flow_table_format(u8 *s, va_list *args)
Definition: gro.h:255
vnet_hw_if_set_input_node
void vnet_hw_if_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: rx_queue.c:157
virtio_if_t::gso_enabled
int gso_enabled
Definition: virtio.h:138
vring_used_t
Definition: virtio_std.h:115