21 #include <sys/ioctl.h> 31 #define foreach_memif_tx_func_error \ 32 _(NO_FREE_SLOTS, "no free tx slots") \ 33 _(ROLLBACK, "no enough space in tx buffers") 37 #define _(f,s) MEMIF_TX_ERROR_##f, 49 #ifndef CLIB_MARCH_VARIANT 53 u32 dev_instance = va_arg (*args,
u32);
64 static __clib_unused
u8 *
67 u32 dev_instance = va_arg (*args,
u32);
68 int verbose = va_arg (*args,
int);
71 s =
format (s,
"MEMIF interface");
80 static __clib_unused
u8 *
83 s =
format (s,
"Unimplemented...");
89 u16 buffer_offset,
u16 buffer_vec_index)
109 u16 ring_size, mask, slot, free_slots;
114 void *last_region_shm = 0;
118 mask = ring_size - 1;
129 free_slots = ring->
head - ring->
tail;
131 while (n_left && free_slots)
136 u32 bi0, dst_off, src_left, dst_left, bytes_to_copy;
137 u32 saved_ptd_copy_ops_len = _vec_len (ptd->
copy_ops);
138 u32 saved_ptd_buffers_len = _vec_len (ptd->
buffers);
139 u16 saved_slot = slot;
144 d0 = &ring->
desc[slot & mask];
150 mb0 = last_region_shm + d0->
offset;
176 d0 = &ring->
desc[slot & mask];
187 mb0 = last_region_shm + d0->
offset;
192 _vec_len (ptd->
buffers) = saved_ptd_buffers_len;
193 _vec_len (ptd->
copy_ops) = saved_ptd_copy_ops_len;
195 MEMIF_TX_ERROR_ROLLBACK, 1);
200 bytes_to_copy =
clib_min (src_left, dst_left);
204 src_off += bytes_to_copy;
205 dst_off += bytes_to_copy;
206 src_left -= bytes_to_copy;
207 dst_left -= bytes_to_copy;
230 while (n_copy_op >= 8)
272 if (n_left && n_retries--)
304 u16 slot, free_slots, n_free;
306 u16 mask = ring_size - 1;
323 while (n_left && free_slots)
326 u16 slots_in_packet = 1;
340 d0 = &ring->
desc[s0];
357 free_slots += slots_in_packet;
358 slot -= slots_in_packet;
381 if (n_left && n_retries--)
426 if (mif->flags & MEMIF_IF_FLAG_ZERO_COPY)
428 else if (mif->flags & MEMIF_IF_FLAG_IS_SLAVE)
436 static __clib_unused
void 445 if (node_index == ~0)
455 static __clib_unused
void 487 mif->
flags |= MEMIF_IF_FLAG_ADMIN_UP;
489 mif->
flags &= ~MEMIF_IF_FLAG_ADMIN_UP;
503 #ifndef CLIB_MARCH_VARIANT 523 static void __clib_constructor
static __clib_unused u8 * format_memif_device(u8 *s, va_list *args)
static __clib_unused void memif_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static_always_inline uword memif_interface_tx_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, memif_if_t *mif, memif_ring_type_t type, memif_queue_t *mq, memif_per_thread_data_t *ptd)
memif_socket_file_t * socket_files
#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 __clib_unused clib_error_t * memif_interface_rx_mode_change(vnet_main_t *vnm, u32 hw_if_index, u32 qid, vnet_hw_interface_rx_mode mode)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u8 buffer_pool_index
index of buffer pool this buffer belongs.
uint16_t memif_region_index_t
vlib_node_function_t __clib_weak memif_interface_tx_avx512
vlib_main_t ** vlib_mains
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static_always_inline void memif_add_copy_op(memif_per_thread_data_t *ptd, void *data, u32 len, u16 buffer_offset, u16 buffer_vec_index)
static __clib_unused u8 * format_memif_tx_trace(u8 *s, va_list *args)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
uword CLIB_MULTIARCH_FN() memif_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vec_add1_aligned(V, E, A)
Add 1 element to end of vector (alignment specified).
static void __clib_constructor dpdk_interface_tx_multiarch_select(void)
vnet_hw_interface_rx_mode
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define static_always_inline
static __clib_unused void memif_clear_hw_interface_counters(u32 instance)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vnet_device_class_t memif_device_class
u32 per_interface_next_index
memif_region_index_t region
memif_copy_op_t * copy_ops
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vlib_node_registration_t memif_input_node
(constructor) VLIB_REGISTER_NODE (memif_input_node)
u16 current_length
Nbytes between current data and the end of this buffer.
u32 node_index
Node index.
uword( vlib_node_function_t)(struct vlib_main_t *vm, struct vlib_node_runtime_t *node, struct vlib_frame_t *frame)
#define foreach_memif_tx_func_error
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
static __clib_unused clib_error_t * memif_subif_add_del_function(vnet_main_t *vnm, u32 hw_if_index, struct vnet_sw_interface_t *st, int is_add)
struct memif_if_t::@446 run
#define clib_memcpy(a, b, c)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
#define MEMIF_DESC_FLAG_NEXT
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)
#define MEMIF_RING_FLAG_MASK_INT
static __clib_unused clib_error_t * memif_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static vlib_main_t * vlib_get_main(void)
memif_region_offset_t offset
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
memif_log2_ring_size_t log2_ring_size
static __clib_unused char * memif_tx_func_error_strings[]
vlib_node_function_t __clib_weak memif_interface_tx_avx2
memif_per_thread_data_t * per_thread_data
static_always_inline uword memif_interface_tx_zc_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, memif_if_t *mif, memif_queue_t *mq, memif_per_thread_data_t *ptd)
memif_queue_t * rx_queues
#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 void vlib_buffer_free_from_ring_no_next(vlib_main_t *vm, u32 *ring, u32 start, u32 ring_size, u32 n_buffers)
Free buffers from ring without freeing tail buffers.
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.
u8 * format_memif_device_name(u8 *s, va_list *args)
#define CLIB_MULTIARCH_FN(fn)