|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
18 #include <sys/types.h>
22 #include <linux/if_tun.h>
23 #include <sys/ioctl.h>
24 #include <sys/eventfd.h>
39 #define _IOCTL(fd,a,...) \
40 if (ioctl (fd, a, __VA_ARGS__) < 0) \
42 err = clib_error_return_unix (0, "ioctl(" #a ")"); \
117 vring->
call_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
120 vring->
kick_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
197 vif->
type & (VIRTIO_IF_TYPE_TAP |
253 if (vif->
type == VIRTIO_IF_TYPE_TAP || vif->
type == VIRTIO_IF_TYPE_TUN)
259 .file_descriptor = vring->
call_fd,
301 u32 i, j, hw_if_index;
311 struct feat_struct *feat_entry;
313 static struct feat_struct feat_array[] = {
314 #define _(s,b) { .str = #s, .bit = b, },
320 struct feat_struct *flag_entry;
321 static struct feat_struct flags_array[] = {
322 #define _(b,e,s) { .bit = b, .str = s, },
331 for (hw_if_index = 0; hw_if_index <
vec_len (hw_if_indices); hw_if_index++)
341 if (
type == VIRTIO_IF_TYPE_PCI)
346 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
356 if (
type == VIRTIO_IF_TYPE_TAP)
374 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI))
379 flag_entry = (
struct feat_struct *) &flags_array;
380 while (flag_entry->str)
382 if (vif->
flags & (1ULL << flag_entry->bit))
387 if (
type == VIRTIO_IF_TYPE_PCI)
392 feat_entry = (
struct feat_struct *) &feat_array;
393 while (feat_entry->str)
395 if (vif->
features & (1ULL << feat_entry->bit))
401 feat_entry = (
struct feat_struct *) &feat_array;
402 while (feat_entry->str)
419 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
425 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
431 " avail wrap counter %d, used wrap counter %d",
437 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
440 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
449 " id addr len flags next/id user_addr\n");
451 " ===== ================== ===== ====== ======= ==================\n");
452 for (j = 0; j < vring->
size; j++)
456 vring_packed_desc_t *desc = &vring->
packed_desc[j];
458 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
461 desc->flags, desc->id, desc->addr);
467 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
480 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
486 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
492 " avail wrap counter %d, used wrap counter %d",
498 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
501 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
520 " id addr len flags next/id user_addr\n");
522 " ===== ================== ===== ====== ======== ==================\n");
523 for (j = 0; j < vring->
size; j++)
527 vring_packed_desc_t *desc = &vring->
packed_desc[j];
529 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
532 desc->flags, desc->id, desc->addr);
538 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
552 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
558 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
564 " avail wrap counter %d, used wrap counter %d",
571 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
575 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
584 " id addr len flags next/id user_addr\n");
586 " ===== ================== ===== ====== ======== ==================\n");
587 for (j = 0; j < vring->
size; j++)
591 vring_packed_desc_t *desc = &vring->
packed_desc[j];
593 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
596 desc->flags, desc->id, desc->addr);
602 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
static void clib_spinlock_init(clib_spinlock_t *p)
#define VNET_HW_IF_RXQ_THREAD_ANY
clib_error_t * virtio_vring_free_rx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
clib_file_main_t file_main
gro_flow_table_t * flow_table
static_always_inline u8 * virtio_vring_buffering_format(u8 *s, va_list *args)
clib_error_t * virtio_vring_free_tx(vlib_main_t *vm, virtio_if_t *vif, u32 idx)
#define TX_QUEUE_ACCESS(X)
static void virtio_vring_fill(vlib_main_t *vm, virtio_if_t *vif, virtio_vring_t *vring)
@ foreach_virtio_net_features
int vnet_hw_if_set_rx_queue_mode(vnet_main_t *vnm, u32 queue_index, vnet_hw_if_rx_mode mode)
static_always_inline u8 vnet_hw_if_get_rx_queue_numa_node(vnet_main_t *vnm, u32 queue_index)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void virtio_show(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, virtio_if_type_t type)
u8 * format_ethernet_address(u8 *s, va_list *args)
static clib_error_t * virtio_init(vlib_main_t *vm)
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
static void clib_mem_free(void *p)
#define clib_error_return(e, args...)
@ VNET_HW_IF_RX_MODE_POLLING
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
#define VIRTIO_FEATURE(X)
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
clib_error_t * virtio_vring_init(vlib_main_t *vm, virtio_if_t *vif, u16 idx, u16 sz)
static_always_inline void gro_flow_table_free(gro_flow_table_t *flow_table)
static uword round_pow2(uword x, uword pow2)
virtio_main_t virtio_main
void virtio_set_packet_coalesce(virtio_if_t *vif)
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)
static_always_inline void clib_memset_u32(void *p, u32 val, uword count)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define UNIX_FILE_EVENT_EDGE_TRIGGERED
void device_status(vlib_main_t *vm, virtio_if_t *vif)
virtio_vring_t * txq_vrings
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define vec_foreach_index(var, v)
Iterate over vector indices.
format_function_t format_vnet_hw_if_index_name
static heap_elt_t * last(heap_header_t *h)
void vnet_hw_if_update_runtime_data(vnet_main_t *vnm, u32 hw_if_index)
void virtio_set_net_hdr_size(virtio_if_t *vif)
static void clib_spinlock_free(clib_spinlock_t *p)
#define vlib_log_debug(...)
static_always_inline void vnet_hw_if_rx_queue_set_int_pending(vnet_main_t *vnm, u32 queue_index)
#define VRING_AVAIL_F_NO_INTERRUPT
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static_always_inline void virtio_vring_buffering_free(vlib_main_t *vm, virtio_vring_buffering_t *buffering)
void vnet_hw_if_set_rx_queue_file_index(vnet_main_t *vnm, u32 queue_index, u32 file_index)
vring_desc_event_t * driver_event
#define vec_free(V)
Free vector's memory (no header).
#define virtio_log_debug(vif, f,...)
virtio_vring_t * cxq_vring
format_function_t format_vlib_pci_addr
#define RX_QUEUE_ACCESS(X)
description fragment has unexpected format
#define VLIB_INIT_FUNCTION(x)
vlib_node_registration_t virtio_input_node
(constructor) VLIB_REGISTER_NODE (virtio_input_node)
static clib_error_t * call_read_ready(clib_file_t *uf)
vring_packed_desc_t * packed_desc
#define vec_foreach(var, vec)
Vector iterator.
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
virtio_vring_t * rxq_vrings
format_function_t format_virtio_device_name
static u8 vlib_buffer_pool_get_default_for_numa(vlib_main_t *vm, u32 numa_node)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void virtio_free_buffers(vlib_main_t *vm, virtio_vring_t *vring)
u32 vnet_hw_if_register_rx_queue(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id, u32 thread_index)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
virtio_vring_buffering_t * buffering
uword vlib_pci_get_msix_file_index(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 index)
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)
clib_error_t * virtio_set_packet_buffering(virtio_if_t *vif, u16 buffering_size)
static void * clib_mem_alloc_aligned(uword size, uword align)
static void clib_file_del_by_index(clib_file_main_t *um, uword index)
static_always_inline clib_error_t * virtio_vring_buffering_init(virtio_vring_buffering_t **buffering, u32 node_index, u16 size)
vring_desc_event_t * device_event
void virtio_vring_set_rx_queues(vlib_main_t *vm, virtio_if_t *vif)
static vlib_thread_main_t * vlib_get_thread_main()
static uword is_pow2(uword x)
vl_api_fib_path_type_t type
static_always_inline u8 * gro_flow_table_format(u8 *s, va_list *args)
void vnet_hw_if_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)