32 l2_rw_entry_t *e = va_arg (*args, l2_rw_entry_t *);
34 s =
format (s,
"%d - mask:%U value:%U\n",
38 s =
format (s,
" hits:%d skip_bytes:%d",
39 e->hit_count, e->skip_n_vectors *
sizeof(u32x4));
45 l2_rw_config_t *c = va_arg (*args, l2_rw_config_t *);
46 return format(s,
"table-index:%d miss-index:%d",
57 return format (s,
"l2-rw: sw_if_index %d, table %d, entry %d",
67 rw->
configs[sw_if_index].table_index = ~0;
68 rw->
configs[sw_if_index].miss_index = ~0;
71 return &rw->
configs[sw_if_index];
77 u32x4 *d = ((u32x4 *) h) + rwe->skip_n_vectors;
78 switch(rwe->rewrite_n_vectors) {
80 d[4] = (d[4] & ~rwe->mask[4]) | rwe->value[4];
83 d[3] = (d[3] & ~rwe->mask[3]) | rwe->value[3];
86 d[2] = (d[2] & ~rwe->mask[2]) | rwe->value[2];
89 d[1] = (d[1] & ~rwe->mask[1]) | rwe->value[1];
92 d[0] = (d[0] & ~rwe->mask[0]) | rwe->value[0];
98 u64 *d = ((
u64 *) h) + rwe->skip_n_vectors * 2;
99 switch(rwe->rewrite_n_vectors) {
101 d[8] = (d[8] & ~(((
u64*)rwe->mask)[8])) | (((
u64*)rwe->value)[8]);
102 d[9] = (d[9] & ~(((
u64*)rwe->mask)[9])) | (((
u64*)rwe->value)[9]);
105 d[6] = (d[6] & ~(((
u64*)rwe->mask)[6])) | (((
u64*)rwe->value)[6]);
106 d[7] = (d[7] & ~(((
u64*)rwe->mask)[7])) | (((
u64*)rwe->value)[7]);
109 d[4] = (d[4] & ~(((
u64*)rwe->mask)[4])) | (((
u64*)rwe->value)[4]);
110 d[5] = (d[5] & ~(((
u64*)rwe->mask)[5])) | (((
u64*)rwe->value)[5]);
113 d[2] = (d[2] & ~(((
u64*)rwe->mask)[2])) | (((
u64*)rwe->value)[2]);
114 d[3] = (d[3] & ~(((
u64*)rwe->mask)[3])) | (((
u64*)rwe->value)[3]);
117 d[0] = (d[0] & ~(((
u64*)rwe->mask)[0])) | (((
u64*)rwe->value)[0]);
118 d[1] = (d[1] & ~(((
u64*)rwe->mask)[1])) | (((
u64*)rwe->value)[1]);
132 u32 n_left_from, * from, * to_next, next_index;
136 u32 prefetch_size = 0;
142 while (n_left_from > 0)
148 to_next, n_left_to_next);
150 while (n_left_from >= 4 && n_left_to_next >= 2)
152 u32 bi0, next0, sw_if_index0, feature_bitmap0, rwe_index0;
153 u32 bi1, next1, sw_if_index1, feature_bitmap1, rwe_index1;
156 l2_rw_config_t *config0, *config1;
159 vnet_classify_entry_t *e0, *e1;
160 l2_rw_entry_t *rwe0, *rwe1;
212 rwe_index0 = e0?e0->opaque_index:config0->miss_index;
213 rwe_index1 = e1?e1->opaque_index:config1->miss_index;
215 if (rwe_index0 != ~0) {
219 if (rwe_index1 != ~0) {
241 feature_bitmap0 =
vnet_buffer(b0)->l2.feature_bitmap & ~L2INPUT_FEAT_RW;
242 feature_bitmap1 =
vnet_buffer(b1)->l2.feature_bitmap & ~L2INPUT_FEAT_RW;
243 vnet_buffer(b0)->l2.feature_bitmap = feature_bitmap0;
244 vnet_buffer(b1)->l2.feature_bitmap = feature_bitmap1;
251 to_next, n_left_to_next,
252 bi0, bi1, next0, next1);
255 while (n_left_from > 0 && n_left_to_next > 0)
257 u32 bi0, next0, sw_if_index0, feature_bitmap0, rwe_index0;
260 l2_rw_config_t *config0;
263 vnet_classify_entry_t *e0;
289 rwe_index0 = e0?e0->opaque_index:config0->miss_index;
291 if (rwe_index0 != ~0) {
305 feature_bitmap0 =
vnet_buffer(b0)->l2.feature_bitmap & ~L2INPUT_FEAT_RW;
306 vnet_buffer(b0)->l2.feature_bitmap = feature_bitmap0;
311 to_next, n_left_to_next,
325 l2_rw_entry_t *e = 0;
344 e->skip_n_vectors = skip /
sizeof(u32x4);
345 skip -= e->skip_n_vectors *
sizeof(u32x4);
346 e->rewrite_n_vectors = (skip + len - 1) /
sizeof(u32x4) + 1;
348 memset(e->mask, 0, e->rewrite_n_vectors *
sizeof(u32x4));
350 memset(e->value, 0, e->rewrite_n_vectors *
sizeof(u32x4));
356 for (i = 0; i < e->rewrite_n_vectors; i++) {
357 e->value[
i] &= e->mask[
i];
376 if (
unformat (input,
"index %d", &index))
382 else if (
unformat (input,
"skip %d", &skip))
404 .path =
"l2 rewrite entry",
406 "l2 rewrite entry [index <index>] [mask <hex-mask>] [value <hex-value>] [skip <n_bytes>] [del]",
417 c->table_index = table_index;
418 c->miss_index = miss_index;
419 u32 feature_bitmap = (table_index == ~0)?0:L2INPUT_FEAT_RW;
423 if (c->table_index == ~0)
435 u32 table_index = ~0;
436 u32 sw_if_index = ~0;
446 if (
unformat (input,
"table %d", &table_index))
448 else if (
unformat (input,
"miss-index %d", &miss_index))
454 if (sw_if_index == ~0)
465 .path =
"set interface l2 rewrite",
467 "set interface l2 rewrite <interface> [table <table index>] [miss-index <entry-index>]",
482 vlib_cli_output (vm,
"sw_if_index:%d %U\n", i, format_l2_rw_config, &rw->configs[i]);
488 .path =
"show l2 rewrite interfaces",
490 "show l2 rewrite interfaces",
505 vlib_cli_output (vm,
"%U\n", format_l2_rw_entry, e);
511 .path =
"show l2 rewrite entries",
513 "show l2 rewrite entries",
520 u32 mask = L2INPUT_FEAT_RW;
535 !
unformat (input,
"%d", &bridge_domain)) {
551 .path =
"set bridge-domain rewrite",
553 "set bridge-domain rewrite <bridge-domain> [disable]",
578 #define foreach_l2_rw_error \ 579 _(UNKNOWN, "Unknown error") 582 #define _(sym,str) L2_RW_ERROR_##sym, 589 #define _(sym,string) string, 597 .vector_size =
sizeof (
u32),
602 .runtime_data_bytes = 0,
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
sll srl srl sll sra u16x4 i
always_inline uword clib_bitmap_count_set_bits(uword *ai)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static clib_error_t * l2_rw_show_interfaces_cli_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u8 * format_l2_rw_entry(u8 *s, va_list *args)
static clib_error_t * l2_rw_show_entries_cli_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct _vlib_node_registration vlib_node_registration_t
unformat_function_t unformat_vnet_sw_interface
vlib_node_registration_t l2_rw_node
(constructor) VLIB_REGISTER_NODE (l2_rw_node)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
always_inline vlib_main_t * vlib_get_main(void)
static u8 * format_l2_rw_config(u8 *s, va_list *args)
#define foreach_l2_rw_error
vnet_main_t * vnet_get_main(void)
#define static_always_inline
#define pool_foreach(VAR, POOL, BODY)
#define VLIB_INIT_FUNCTION(x)
static char * l2_rw_error_strings[]
int l2_rw_enable_disable(u32 bridge_domain, u8 disable)
always_inline uword pool_elts(void *v)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
#define clib_bitmap_foreach(i, ai, body)
static clib_error_t * l2_rw_set_cli_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_elt_at_index(p, i)
int l2_rw_mod_entry(u32 *index, u8 *mask, u8 *value, u32 len, u32 skip, u8 is_del)
static clib_error_t * l2_rw_entry_cli_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_alloc_aligned(V, N, A)
Allocate space for N more elements (no header, given alignment)
static_always_inline void l2_rw_rewrite(l2_rw_entry_t *rwe, u8 *h)
always_inline uword * clib_bitmap_set(uword *ai, uword i, uword value)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static u8 * format_l2_rw_trace(u8 *s, va_list *args)
static uword l2_rw_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define clib_bitmap_alloc(v, n_bits)
always_inline uword clib_bitmap_get(uword *ai, uword i)
#define CLIB_PREFETCH(addr, size, type)
#define clib_memcpy(a, b, c)
#define pool_is_free_index(P, I)
#define VLIB_CLI_COMMAND(x,...)
struct _vnet_classify_main vnet_classify_main_t
static clib_error_t * l2_rw_init(vlib_main_t *vm)
static clib_error_t * l2_rw_interface_cli_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 feat_next_node_index[32]
vnet_classify_main_t vnet_classify_main
#define VLIB_BUFFER_IS_TRACED
always_inline l2_rw_config_t * l2_rw_get_config(u32 sw_if_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline u32 feat_bitmap_get_next_node_index(u32 *next_nodes, u32 bitmap)
int l2_rw_interface_set_table(u32 sw_if_index, u32 table_index, u32 miss_index)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
always_inline f64 vlib_time_now(vlib_main_t *vm)
#define clib_error_return(e, args...)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
always_inline void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)