|
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>
50 virtio_net_hdr_v1_t
hdr;
61 s =
format (s,
"virtio: hw_if_index %d next-index %d vring %u len %u",
63 s =
format (s,
"\n%Uhdr: flags 0x%02x gso_type 0x%02x hdr_len %u "
64 "gso_size %u csum_start %u csum_offset %u num_buffers %u",
66 t->
hdr.flags, t->
hdr.gso_type, t->
hdr.hdr_len, t->
hdr.gso_size,
67 t->
hdr.csum_start, t->
hdr.csum_offset, t->
hdr.num_buffers);
77 u16 ethertype = 0, l2hdr_sz = 0;
80 if (
type == VIRTIO_IF_TYPE_TUN)
82 switch (b0->
data[0] & 0xf0)
85 ethertype = ETHERNET_TYPE_IP4;
88 ethertype = ETHERNET_TYPE_IP6;
96 ethertype = clib_net_to_host_u16 (eh->
type);
104 ethertype = clib_net_to_host_u16 (vlan->
type);
105 l2hdr_sz +=
sizeof (*vlan);
106 if (ethertype == ETHERNET_TYPE_VLAN)
109 ethertype = clib_net_to_host_u16 (vlan->
type);
110 l2hdr_sz +=
sizeof (*vlan);
123 *l4_proto =
ip4->protocol;
124 oflags |= VNET_BUFFER_OFFLOAD_F_IP_CKSUM;
126 (VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_L2_HDR_OFFSET_VALID |
127 VNET_BUFFER_F_L3_HDR_OFFSET_VALID |
128 VNET_BUFFER_F_L4_HDR_OFFSET_VALID);
136 *l4_proto =
ip6->protocol;
137 b0->
flags |= (VNET_BUFFER_F_IS_IP6 |
138 VNET_BUFFER_F_L2_HDR_OFFSET_VALID
139 | VNET_BUFFER_F_L3_HDR_OFFSET_VALID |
140 VNET_BUFFER_F_L4_HDR_OFFSET_VALID);
142 if (*l4_proto == IP_PROTOCOL_TCP)
144 oflags |= VNET_BUFFER_OFFLOAD_F_TCP_CKSUM;
147 (b0)->l4_hdr_offset);
150 else if (*l4_proto == IP_PROTOCOL_UDP)
152 oflags |= VNET_BUFFER_OFFLOAD_F_UDP_CKSUM;
155 (b0)->l4_hdr_offset);
156 *l4_hdr_sz =
sizeof (*udp);
165 u8 l4_proto,
u8 l4_hdr_sz)
172 b0->
flags |= VNET_BUFFER_F_GSO | VNET_BUFFER_F_IS_IP4;
179 b0->
flags |= VNET_BUFFER_F_GSO | VNET_BUFFER_F_IS_IP6;
212 #define increment_last(last, packed, vring) \
215 if (packed && last >= vring->size) \
218 vring->used_wrap_counter ^= 1; \
226 int gso_enabled,
int checksum_offload_enabled,
235 u32 n_rx_packets = 0;
245 if (
type == VIRTIO_IF_TYPE_TUN)
266 while (
n_left && n_left_to_next)
281 u8 l4_proto = 0, l4_hdr_sz = 0;
283 virtio_net_hdr_v1_t *hdr;
289 if (hdr_sz ==
sizeof (virtio_net_hdr_v1_t))
290 num_buffers = hdr->num_buffers;
292 b0->
flags = VLIB_BUFFER_TOTAL_LENGTH_VALID;
296 if (checksum_offload_enabled)
311 while (num_buffers > 1)
325 pb->
flags |= VLIB_BUFFER_NEXT_PRESENT;
338 if (
type == VIRTIO_IF_TYPE_TUN)
340 switch (b0->
data[0] & 0xf0)
386 if (
type == VIRTIO_IF_TYPE_TUN)
388 n_left_to_next, bi0, next0);
480 if (vif->
flags & VIRTIO_IF_FLAG_ADMIN_UP)
482 if (vif->
type == VIRTIO_IF_TYPE_TAP)
485 else if (vif->
type == VIRTIO_IF_TYPE_PCI)
488 else if (vif->
type == VIRTIO_IF_TYPE_TUN)
499 .name =
"virtio-input",
500 .sibling_of =
"device-input",
504 .state = VLIB_NODE_STATE_INTERRUPT,
static_always_inline uword virtio_device_input_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, virtio_if_t *vif, u16 qid, virtio_if_type_t type)
u32 next_buffer
Next buffer for this linked-list of buffers.
static int tcp_header_bytes(tcp_header_t *t)
static char * virtio_input_error_strings[]
gro_flow_table_t * flow_table
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
nat44_ei_hairpin_src_next_t next_index
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static_always_inline int ethernet_frame_is_tagged(u16 type)
struct _tcp_header tcp_header_t
@ VNET_DEVICE_INPUT_NEXT_DROP
vlib_main_t vlib_node_runtime_t * node
static_always_inline void vnet_buffer_offload_flags_set(vlib_buffer_t *b, vnet_buffer_oflags_t oflags)
static_always_inline void virtio_needs_csum(vlib_buffer_t *b0, virtio_net_hdr_v1_t *hdr, u8 *l4_proto, u8 *l4_hdr_sz, virtio_if_type_t type)
u32 per_interface_next_index
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
#define VRING_DESC_F_USED
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
@ VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static u8 * format_virtio_input_trace(u8 *s, va_list *args)
virtio_main_t virtio_main
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
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)
#define VIRTIO_NET_HDR_GSO_TCPV4
static_always_inline void fill_gso_buffer_flags(vlib_buffer_t *b, u32 gso_size, u8 l4_hdr_sz)
virtio_vring_t * txq_vrings
static_always_inline u16 virtio_get_len(virtio_vring_t *vring, const int packed, const int hdr_sz, u16 last, u16 mask)
#define VLIB_NODE_FN(node)
static_always_inline uword virtio_device_input_gso_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, virtio_if_t *vif, virtio_vring_t *vring, virtio_if_type_t type, int gso_enabled, int checksum_offload_enabled, int packed)
#define VRING_DESC_F_AVAIL
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vnet_main_t * vnet_get_main(void)
@ VNET_DEVICE_INPUT_NEXT_IP6_INPUT
@ VNET_DEVICE_INPUT_NEXT_IP4_INPUT
#define static_always_inline
static heap_elt_t * last(heap_header_t *h)
#define VLIB_NODE_FLAG_TRACE_SUPPORTED
@ VNET_INTERFACE_COUNTER_RX
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
struct _vlib_node_registration vlib_node_registration_t
vlib_combined_counter_main_t * combined_sw_if_counters
u16 current_length
Nbytes between current data and the end of this buffer.
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
static_always_inline void vnet_gro_flow_table_schedule_node_on_dispatcher(vlib_main_t *vm, gro_flow_table_t *flow_table)
description fragment has unexpected format
vlib_put_next_frame(vm, node, next_index, 0)
vlib_node_registration_t virtio_input_node
(constructor) VLIB_REGISTER_NODE (virtio_input_node)
#define VIRTIO_NET_HDR_GSO_TCPV6
static_always_inline u16 virtio_n_left_to_process(virtio_vring_t *vring, const int packed)
vring_packed_desc_t * packed_desc
#define increment_last(last, packed, vring)
#define vec_foreach(var, vec)
Vector iterator.
#define VIRTIO_NET_HDR_F_NEEDS_CSUM
static_always_inline vnet_hw_if_rxq_poll_vector_t * vnet_hw_if_get_rxq_poll_vector(vlib_main_t *vm, vlib_node_runtime_t *node)
virtio_vring_t * rxq_vrings
static_always_inline int clib_spinlock_trylock_if_init(clib_spinlock_t *p)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vring_used_elem_t ring[0]
virtio_vring_buffering_t * buffering
static_always_inline void vnet_feature_start_device_input_x1(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)
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)
static int ip4_header_bytes(const ip4_header_t *i)
#define foreach_virtio_input_error
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static __clib_warn_unused_result int vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
static_always_inline void virtio_vring_buffering_schedule_node_on_dispatcher(vlib_main_t *vm, virtio_vring_buffering_t *buffering)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vl_api_fib_path_type_t type
vnet_interface_main_t interface_main
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
static_always_inline u16 virtio_get_slot_id(virtio_vring_t *vring, const int packed, u16 last, u16 mask)
#define VLIB_REGISTER_NODE(x,...)
vl_api_wireguard_peer_flags_t flags