18 #include <sys/types.h> 22 #include <linux/if_tun.h> 23 #include <sys/ioctl.h> 24 #include <sys/eventfd.h> 37 #define _IOCTL(fd,a,...) \ 38 if (ioctl (fd, a, __VA_ARGS__) < 0) \ 40 err = clib_error_return_unix (0, "ioctl(" #a ")"); \ 121 vring->
call_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
122 vring->
kick_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
208 vif->
type & (VIRTIO_IF_TYPE_TAP |
248 [thread_index]->numa_node);
264 u32 i, j, hw_if_index;
274 struct feat_struct *feat_entry;
276 static struct feat_struct feat_array[] = {
277 #define _(s,b) { .str = #s, .bit = b, }, 283 struct feat_struct *flag_entry;
284 static struct feat_struct flags_array[] = {
285 #define _(b,e,s) { .bit = b, .str = s, }, 294 for (hw_if_index = 0; hw_if_index <
vec_len (hw_if_indices); hw_if_index++)
299 if (vif->
type != type)
304 if (type == VIRTIO_IF_TYPE_PCI)
309 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
319 if (type == VIRTIO_IF_TYPE_TAP)
337 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI))
342 flag_entry = (
struct feat_struct *) &flags_array;
343 while (flag_entry->str)
345 if (vif->
flags & (1ULL << flag_entry->bit))
350 if (type == VIRTIO_IF_TYPE_PCI)
355 feat_entry = (
struct feat_struct *) &feat_array;
356 while (feat_entry->str)
358 if (vif->
features & (1ULL << feat_entry->bit))
364 feat_entry = (
struct feat_struct *) &feat_array;
365 while (feat_entry->str)
382 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
388 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
394 " avail wrap counter %d, used wrap counter %d",
400 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
403 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
412 " id addr len flags next/id user_addr\n");
414 " ===== ================== ===== ====== ======= ==================\n");
415 for (j = 0; j < vring->
size; j++)
419 vring_packed_desc_t *desc = &vring->
packed_desc[j];
421 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
424 desc->flags, desc->id, desc->addr);
430 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
443 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
449 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
455 " avail wrap counter %d, used wrap counter %d",
461 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
464 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
483 " id addr len flags next/id user_addr\n");
485 " ===== ================== ===== ====== ======== ==================\n");
486 for (j = 0; j < vring->
size; j++)
490 vring_packed_desc_t *desc = &vring->
packed_desc[j];
492 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
495 desc->flags, desc->id, desc->addr);
501 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
515 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
521 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
527 " avail wrap counter %d, used wrap counter %d",
534 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
538 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
547 " id addr len flags next/id user_addr\n");
549 " ===== ================== ===== ====== ======== ==================\n");
550 for (j = 0; j < vring->
size; j++)
554 vring_packed_desc_t *desc = &vring->
packed_desc[j];
556 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
559 desc->flags, desc->id, desc->addr);
565 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
gro_flow_table_t * flow_table
#define vec_foreach_index(var, v)
Iterate over vector indices.
vring_desc_event_t * device_event
format_function_t format_vnet_hw_if_index_name
void virtio_set_net_hdr_size(virtio_if_t *vif)
void virtio_show(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, u32 type)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
vnet_main_t * vnet_get_main(void)
static_always_inline u8 * gro_flow_table_format(u8 *s, va_list *args)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static heap_elt_t * last(heap_header_t *h)
void virtio_vring_set_numa_node(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
vlib_main_t ** vlib_mains
clib_error_t * virtio_vring_free_tx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
#define VIRTIO_FEATURE(X)
clib_file_function_t * read_function
static void clib_spinlock_free(clib_spinlock_t *p)
#define VRING_AVAIL_F_NO_INTERRUPT
u8 * format_ethernet_address(u8 *s, va_list *args)
static clib_error_t * virtio_init(vlib_main_t *vm)
#define TX_QUEUE_ACCESS(X)
#define VLIB_INIT_FUNCTION(x)
void device_status(vlib_main_t *vm, virtio_if_t *vif)
static_always_inline void vnet_device_input_set_interrupt_pending(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
description fragment has unexpected format
#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...)
clib_file_main_t file_main
#define vlib_log_debug(...)
static void clib_spinlock_init(clib_spinlock_t *p)
vl_api_fib_path_type_t type
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline uword vnet_get_device_input_thread_index(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
vring_desc_event_t * driver_event
#define virtio_log_debug(vif, f,...)
virtio_vring_t * rxq_vrings
format_function_t format_virtio_device_name
void virtio_free_buffers(vlib_main_t *vm, virtio_vring_t *vring)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
static_always_inline void gro_flow_table_free(gro_flow_table_t *flow_table)
static_always_inline u32 gro_flow_table_init(gro_flow_table_t **flow_table, u8 is_l2, u32 node_index)
vlib_log_class_t log_default
static uword round_pow2(uword x, uword pow2)
clib_error_t * virtio_set_packet_buffering(virtio_if_t *vif, u16 buffering_size)
vring_packed_desc_t * packed_desc
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
static void clib_file_del_by_index(clib_file_main_t *um, uword index)
clib_error_t * virtio_vring_init(vlib_main_t *vm, virtio_if_t *vif, u16 idx, u16 sz)
static void clib_mem_free(void *p)
void virtio_set_packet_coalesce(virtio_if_t *vif)
virtio_main_t virtio_main
static uword is_pow2(uword x)
virtio_vring_buffering_t * buffering
#define RX_QUEUE_ACCESS(X)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
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)
virtio_vring_t * cxq_vring
clib_error_t * virtio_vring_free_rx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
static vlib_thread_main_t * vlib_get_thread_main()
static_always_inline u8 * virtio_vring_buffering_format(u8 *s, va_list *args)
#define vec_foreach(var, vec)
Vector iterator.
#define CLIB_CACHE_LINE_BYTES
static u8 vlib_buffer_pool_get_default_for_numa(vlib_main_t *vm, u32 numa_node)
format_function_t format_vlib_pci_addr
virtio_vring_t * txq_vrings
static clib_error_t * call_read_ready(clib_file_t *uf)
static_always_inline void virtio_vring_buffering_free(vlib_main_t *vm, virtio_vring_buffering_t *buffering)
static_always_inline void clib_memset_u32(void *p, u32 val, uword count)