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...");
93 #ifndef CLIB_MARCH_VARIANT 108 struct vring_used_elem *e = &vring->
used->ring[last & mask];
124 u16 mask,
int do_gso)
128 struct vring_desc *d;
129 d = &vring->
desc[next];
134 if (do_gso && (b->
flags & VNET_BUFFER_F_GSO))
136 if (b->
flags & VNET_BUFFER_F_IS_IP4)
138 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
140 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
142 hdr->csum_offset = 0x10;
146 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
148 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
150 hdr->csum_offset = 0x10;
177 struct vring_desc *
id =
196 id->flags = VRING_DESC_F_NEXT;
203 while (b->
flags & VLIB_BUFFER_NEXT_PRESENT)
205 id->flags = VRING_DESC_F_NEXT;
221 while (b->
flags & VLIB_BUFFER_NEXT_PRESENT)
223 id->flags = VRING_DESC_F_NEXT;
234 d->len = count *
sizeof (
struct vring_desc);
235 d->flags = VRING_DESC_F_INDIRECT;
238 vring->
avail->ring[avail & mask] = next;
252 u16 used, next, avail;
268 avail = vring->
avail->idx;
270 while (n_left && used < sz)
279 next = (next + n_added) & mask;
288 vring->
avail->idx = avail;
332 if (node_index == ~0)
380 vif->
flags |= VIRTIO_IF_FLAG_ADMIN_UP;
382 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)
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)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
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)
#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
void virtio_free_used_desc(vlib_main_t *vm, virtio_vring_t *vring)
#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.
u8 * format_virtio_device_name(u8 *s, va_list *args)
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)