|
FD.io VPP
v21.06-3-gbb25fbf28
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,
300 u32 i, j, hw_if_index;
310 struct feat_struct *feat_entry;
312 static struct feat_struct feat_array[] = {
313 #define _(s,b) { .str = #s, .bit = b, },
319 struct feat_struct *flag_entry;
320 static struct feat_struct flags_array[] = {
321 #define _(b,e,s) { .bit = b, .str = s, },
330 for (hw_if_index = 0; hw_if_index <
vec_len (hw_if_indices); hw_if_index++)
340 if (
type == VIRTIO_IF_TYPE_PCI)
345 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
355 if (
type == VIRTIO_IF_TYPE_TAP)
373 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI))
378 flag_entry = (
struct feat_struct *) &flags_array;
379 while (flag_entry->str)
381 if (vif->
flags & (1ULL << flag_entry->bit))
386 if (
type == VIRTIO_IF_TYPE_PCI)
391 feat_entry = (
struct feat_struct *) &feat_array;
392 while (feat_entry->str)
394 if (vif->
features & (1ULL << feat_entry->bit))
400 feat_entry = (
struct feat_struct *) &feat_array;
401 while (feat_entry->str)
418 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
424 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
430 " avail wrap counter %d, used wrap counter %d",
436 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
439 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
448 " id addr len flags next/id user_addr\n");
450 " ===== ================== ===== ====== ======= ==================\n");
451 for (j = 0; j < vring->
size; j++)
455 vring_packed_desc_t *desc = &vring->
packed_desc[j];
457 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
460 desc->flags, desc->id, desc->addr);
466 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
479 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
485 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
491 " avail wrap counter %d, used wrap counter %d",
497 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
500 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
519 " id addr len flags next/id user_addr\n");
521 " ===== ================== ===== ====== ======== ==================\n");
522 for (j = 0; j < vring->
size; j++)
526 vring_packed_desc_t *desc = &vring->
packed_desc[j];
528 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
531 desc->flags, desc->id, desc->addr);
537 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
551 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
557 " driver_event.flags 0x%x driver_event.off_wrap %d device_event.flags 0x%x device_event.off_wrap %d",
563 " avail wrap counter %d, used wrap counter %d",
570 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
574 if (
type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
583 " id addr len flags next/id user_addr\n");
585 " ===== ================== ===== ====== ======== ==================\n");
586 for (j = 0; j < vring->
size; j++)
590 vring_packed_desc_t *desc = &vring->
packed_desc[j];
592 " %-5d 0x%016lx %-5d 0x%04x %-8d 0x%016lx\n",
595 desc->flags, desc->id, desc->addr);
601 " %-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.
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)
sll srl srl sll sra u16x4 i
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
void virtio_show(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, u32 type)
#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)