18 #include <sys/types.h> 29 #define foreach_virtio_tx_func_error \ 30 _(NO_FREE_SLOTS, "no free tx slots") \ 31 _(TRUNC_PACKET, "packet > buffer size -- truncated in tx ring") \ 32 _(PENDING_MSGS, "pending msgs in tx ring") \ 33 _(NO_TX_QUEUES, "no tx queues") 37 #define _(f,s) VIRTIO_TX_ERROR_##f, 49 #ifndef CLIB_MARCH_VARIANT 53 u32 dev_instance = va_arg (*args,
u32);
73 u32 dev_instance = va_arg (*args,
u32);
74 int verbose = va_arg (*args,
int);
77 s =
format (s,
"VIRTIO interface");
89 s =
format (s,
"Unimplemented...");
107 struct vring_used_elem *e = &vring->
used->ring[last & mask];
109 slot = n_buffers = e->id;
111 while (e->id == n_buffers)
118 e = &vring->
used->ring[last & mask];
121 sz, (n_buffers - slot));
122 used -= (n_buffers - slot);
141 u16 mask,
int do_gso)
145 struct vring_desc *d;
146 d = &vring->
desc[next];
151 if (do_gso && (b->
flags & VNET_BUFFER_F_GSO))
153 if (b->
flags & VNET_BUFFER_F_IS_IP4)
155 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
157 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
159 hdr->csum_offset = 0x10;
163 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
165 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
167 hdr->csum_offset = 0x10;
190 u32 indirect_buffer = 0;
196 indirect_desc->
flags |= VLIB_BUFFER_NEXT_PRESENT;
198 bi = indirect_buffer;
200 struct vring_desc *
id =
219 id->flags = VRING_DESC_F_NEXT;
226 while (b->
flags & VLIB_BUFFER_NEXT_PRESENT)
228 id->flags = VRING_DESC_F_NEXT;
244 while (b->
flags & VLIB_BUFFER_NEXT_PRESENT)
246 id->flags = VRING_DESC_F_NEXT;
257 d->len = count *
sizeof (
struct vring_desc);
258 d->flags = VRING_DESC_F_INDIRECT;
261 vring->
avail->ring[avail & mask] = next;
275 u16 used, next, avail;
291 avail = vring->
avail->idx;
293 while (n_left && used < sz)
302 next = (next + n_added) & mask;
311 vring->
avail->idx = avail;
355 if (node_index == ~0)
403 vif->
flags |= VIRTIO_IF_FLAG_ADMIN_UP;
405 vif->
flags &= ~VIRTIO_IF_FLAG_ADMIN_UP;
u32 per_interface_next_index
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static uword vlib_buffer_get_current_pa(vlib_main_t *vm, vlib_buffer_t *b)
vlib_node_registration_t virtio_input_node
(constructor) VLIB_REGISTER_NODE (virtio_input_node)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
#define foreach_virtio_tx_func_error
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define CLIB_MEMORY_STORE_BARRIER()
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u16 current_length
Nbytes between current data and the end of this buffer.
static heap_elt_t * last(heap_header_t *h)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static char * virtio_tx_func_error_strings[]
vnet_hw_interface_rx_mode
struct vring_avail * avail
#define static_always_inline
static_always_inline uword virtio_interface_tx_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, virtio_if_t *vif, int do_gso)
VNET_DEVICE_CLASS_TX_FN() virtio_device_class(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static void virtio_clear_hw_interface_counters(u32 instance)
#define clib_error_return(e, args...)
#define VNET_DEVICE_CLASS_TX_FN(devclass)
static clib_error_t * virtio_interface_rx_mode_change(vnet_main_t *vnm, u32 hw_if_index, u32 qid, vnet_hw_interface_rx_mode mode)
static void vlib_buffer_free_from_ring(vlib_main_t *vm, u32 *ring, u32 start, u32 ring_size, u32 n_buffers)
Free buffers from ring.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 node_index
Node index.
static u8 * format_virtio_device(u8 *s, va_list *args)
static void virtio_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
virtio_vring_t * rxq_vrings
static u8 * format_virtio_tx_trace(u8 *s, va_list *args)
#define VIRTIO_RING_FLAG_MASK_INT
static clib_error_t * virtio_subif_add_del_function(vnet_main_t *vnm, u32 hw_if_index, struct vnet_sw_interface_t *st, int is_add)
static clib_error_t * virtio_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
vl_api_vxlan_gbp_api_tunnel_mode_t mode
#define VIRTIO_FEATURE(X)
VNET_DEVICE_CLASS(bond_dev_class)
static uword pointer_to_uword(const void *p)
virtio_main_t virtio_main
static vlib_main_t * vlib_get_main(void)
static_always_inline u16 add_buffer_to_slot(vlib_main_t *vm, virtio_if_t *vif, virtio_vring_t *vring, u32 bi, u16 avail, u16 next, u16 mask, int do_gso)
static u64 vlib_physmem_get_pa(vlib_main_t *vm, void *mem)
u32 next_buffer
Next buffer for this linked-list of buffers.
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static_always_inline void virtio_free_used_device_desc(vlib_main_t *vm, virtio_vring_t *vring)
u8 * format_virtio_device_name(u8 *s, va_list *args)
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
virtio_vring_t * txq_vrings
static_always_inline void virtio_kick(vlib_main_t *vm, virtio_vring_t *vring, virtio_if_t *vif)