18 #include <sys/types.h> 21 #include <linux/virtio_net.h> 22 #include <linux/vhost.h> 31 #define foreach_virtio_tx_func_error \ 32 _(NO_FREE_SLOTS, "no free tx slots") \ 33 _(TRUNC_PACKET, "packet > buffer size -- truncated in tx ring") \ 34 _(PENDING_MSGS, "pending msgs in tx ring") \ 35 _(NO_TX_QUEUES, "no tx queues") 39 #define _(f,s) TAP_TX_ERROR_##f, 54 u32 dev_instance = va_arg (*args,
u32);
71 u32 dev_instance = va_arg (*args,
u32);
72 int verbose = va_arg (*args,
int);
75 s =
format (s,
"VIRTIO interface");
87 s =
format (s,
"Unimplemented...");
105 struct vring_used_elem *e = &vring->
used->ring[last & mask];
107 struct vring_desc *d = &vring->
desc[slot];
129 const int hdr_sz =
sizeof (
struct virtio_net_hdr_v1);
130 struct vring_desc *d;
131 d = &vring->
desc[next];
135 memset (hdr, 0, hdr_sz);
145 struct vring_desc *id, *descs = 0;
152 while (b->
flags & VLIB_BUFFER_NEXT_PRESENT)
154 id->flags = VRING_DESC_F_NEXT;
163 d->len =
vec_len (descs) *
sizeof (
struct vring_desc);
164 d->flags = VRING_DESC_F_INDIRECT;
167 vring->
avail->ring[avail & mask] = next;
180 u16 used, next, avail;
192 avail = vring->
avail->idx;
194 while (n_left && used < sz)
199 next = (next + n_added) & mask;
208 vring->
avail->idx = avail;
251 if (node_index == ~0)
294 vif->
flags |= VIRTIO_IF_FLAG_ADMIN_UP;
296 vif->
flags &= ~VIRTIO_IF_FLAG_ADMIN_UP;
u32 per_interface_next_index
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.
u8 runtime_data[0]
Function dependent node-runtime data.
#define foreach_virtio_tx_func_error
#define CLIB_MEMORY_STORE_BARRIER()
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
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)
vnet_device_class_t virtio_device_class
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)
#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)
static uword pointer_to_uword(const void *p)
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.
u16 current_length
Nbytes between current data and the end of this buffer.
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)
#define uword_to_pointer(u, type)
static void virtio_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
static u8 * format_virtio_tx_trace(u8 *s, va_list *args)
#define VIRTIO_RING_FLAG_MASK_INT
#define vec_free(V)
Free vector's memory (no header).
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)
static_always_inline u16 add_buffer_to_slot(vlib_main_t *vm, virtio_vring_t *vring, u32 bi, u16 avail, u16 next, u16 mask)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
void virtio_free_used_desc(vlib_main_t *vm, virtio_vring_t *vring)
u32 next_buffer
Next buffer for this linked-list of buffers.
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
VNET_DEVICE_CLASS(bond_dev_class)
virtio_main_t virtio_main
static vlib_main_t * vlib_get_main(void)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 * format_virtio_device_name(u8 *s, va_list *args)
#define CLIB_CACHE_LINE_BYTES
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_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.
#define VLIB_DEVICE_TX_FUNCTION_MULTIARCH(dev, fn)
static uword virtio_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)