39 s =
format (s,
"SAMPLE: sw_if_index %d, next index %d\n",
41 s =
format (s,
" new src %U -> new dst %U",
50 #define foreach_sample_error \ 51 _(SWAPPED, "Mac swap packets processed") 55 #define _(sym,str) SAMPLE_ERROR_##sym, 62 #define _(sym,string) string, 82 #define foreach_mac_address_offset \ 93 u32 n_left_from, *from, *to_next;
98 n_left_from =
frame->n_vectors;
101 while (n_left_from > 0)
107 while (n_left_from >= 4 && n_left_to_next >= 2)
111 u32 sw_if_index0, sw_if_index1;
132 to_next[0] = bi0 = from[0];
133 to_next[1] = bi1 = from[1];
149 #define _(a) tmp0[a] = en0->src_address[a]; 152 #define _(a) en0->src_address[a] = en0->dst_address[a]; 155 #define _(a) en0->dst_address[a] = tmp0[a]; 159 #define _(a) tmp1[a] = en1->src_address[a]; 162 #define _(a) en1->src_address[a] = en1->dst_address[a]; 165 #define _(a) en1->dst_address[a] = tmp1[a]; 180 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
192 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
207 to_next, n_left_to_next,
208 bi0, bi1, next0, next1);
211 while (n_left_from > 0 && n_left_to_next > 0)
238 #define _(a) tmp0[a] = en0->src_address[a]; 241 #define _(a) en0->src_address[a] = en0->dst_address[a]; 244 #define _(a) en0->dst_address[a] = tmp0[a]; 254 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
269 to_next, n_left_to_next,
277 SAMPLE_ERROR_SWAPPED, pkts_swapped);
278 return frame->n_vectors;
290 u32 n_left_from, *from, *to_next;
292 u32 pkts_swapped = 0;
294 u8x16 swapmac = { 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 12, 13, 14, 15 };
297 n_left_from =
frame->n_vectors;
300 while (n_left_from > 0)
305 while (n_left_from >= 4 && n_left_to_next >= 2)
309 u32 sw_if_index0, sw_if_index1;
310 u8x16 src_dst0, src_dst1;
330 to_next[0] = bi0 = from[0];
331 to_next[1] = bi1 = from[1];
346 src_dst0 = ((u8x16 *) en0)[0];
347 src_dst1 = ((u8x16 *) en1)[0];
350 ((u8x16 *) en0)[0] = src_dst0;
351 ((u8x16 *) en1)[0] = src_dst1;
364 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
376 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
391 to_next, n_left_to_next,
392 bi0, bi1, next0, next1);
395 while (n_left_from > 0 && n_left_to_next > 0)
420 src_dst0 = ((u8x16 *) en0)[0];
422 ((u8x16 *) en0)[0] = src_dst0;
430 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
445 to_next, n_left_to_next,
453 SAMPLE_ERROR_SWAPPED, pkts_swapped);
454 return frame->n_vectors;
472 #define u8x16_shuffle __builtin_shuffle 479 u32 n_left_from, *from;
480 u32 pkts_swapped = 0;
482 u8x16 swapmac = { 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 12, 13, 14, 15 };
485 u16 *next __attribute__ ((unused));
488 n_left_from =
frame->n_vectors;
500 while (n_left_from >= 4)
502 u8x16 src_dst0, src_dst1, src_dst2, src_dst3;
551 while (n_left_from > 0)
571 SAMPLE_ERROR_SWAPPED, pkts_swapped);
578 for (i = 0; i <
frame->n_vectors; i++)
580 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
598 return frame->n_vectors;
614 #define u8x16_shuffle __builtin_shuffle 616 static u8x16 swapmac =
617 { 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 12, 13, 14, 15 };
648 #define STAGE_INLINE inline __attribute__((__always_inline__)) 650 #define stage0 generic_stage0 657 dispatch_pipeline (vm, node,
frame);
660 SAMPLE_ERROR_SWAPPED,
frame->n_vectors);
666 for (i = 0; i <
frame->n_vectors; i++)
668 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
686 return frame->n_vectors;
694 .vector_size =
sizeof (
u32),
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 u8 * format_sample_trace(u8 *s, va_list *args)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define clib_memcpy_fast(a, b, c)
#define VLIB_NODE_FN(node)
#define foreach_sample_error
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_node_registration_t sample_node
(constructor) VLIB_REGISTER_NODE (sample_node)
vl_api_fib_path_type_t type
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#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 void stage1(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b)
#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).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
sll srl srl sll sra u16x4 i
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vlib_main_t vlib_node_runtime_t * node
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
static_always_inline u8x16 u8x16_shuffle(u8x16 v, u8x16 m)
static u32 last_stage(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b)
#define foreach_mac_address_offset
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u8 * format_mac_address(u8 *s, va_list *args)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u16 flags
Copy of main node flags.
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static char * sample_error_strings[]