42 s =
format (s,
"l2-classify: sw_if_index %d, table %d, offset %x, next %d",
51 #define foreach_l2_classify_error \ 52 _(MISS, "Classify misses") \ 53 _(HIT, "Classify hits") \ 54 _(CHAIN_HIT, "Classify hits after chain walk") \ 55 _(DROP, "L2 Classify Drops") 58 #define _(sym,str) L2_CLASSIFY_ERROR_##sym, 65 #define _(sym,string) string, 75 u32 n_left_from, * from, * to_next;
93 while (n_left_from > 2)
98 u32 sw_if_index0, sw_if_index1;
100 int type_index0, type_index1;
102 u32 table_index0, table_index1;
134 type0 = clib_net_to_host_u16 (h0->
type);
135 type1 = clib_net_to_host_u16 (h1->
type);
137 type_index0 = (type0 == ETHERNET_TYPE_IP4)
139 type_index0 = (type0 == ETHERNET_TYPE_IP6)
142 type_index1 = (type1 == ETHERNET_TYPE_IP4)
144 type_index1 = (type1 == ETHERNET_TYPE_IP6)
150 [type_index0][sw_if_index0];
152 if (table_index0 != ~0)
164 [type_index1][sw_if_index1];
166 if (table_index1 != ~0)
179 while (n_left_from > 0)
199 type0 = clib_net_to_host_u16 (h0->
type);
201 type_index0 = (type0 == ETHERNET_TYPE_IP4)
203 type_index0 = (type0 == ETHERNET_TYPE_IP6)
208 [type_index0][sw_if_index0];
210 if (table_index0 != ~0)
226 while (n_left_from > 0)
231 to_next, n_left_to_next);
234 while (n_left_from > 0 && n_left_to_next > 0)
243 vnet_classify_entry_t * e0;
256 table_index2 =
vnet_buffer(p2)->l2_classify.table_index;
276 table_index0 =
vnet_buffer(b0)->l2_classify.table_index;
293 e0->next_index:next0;
319 e0->next_index:next0;
335 feature_bitmap =
vnet_buffer(b0)->l2.feature_bitmap
336 & ~L2INPUT_FEAT_CLASSIFY;
339 vnet_buffer(b0)->l2.feature_bitmap = feature_bitmap;
359 to_next, n_left_to_next,
367 L2_CLASSIFY_ERROR_MISS,
370 L2_CLASSIFY_ERROR_HIT,
373 L2_CLASSIFY_ERROR_CHAIN_HIT,
380 .name =
"l2-classify",
381 .vector_size =
sizeof (
u32),
445 u32 other_table_index)
452 if (ip4_table_index != ~0 &&
454 return VNET_API_ERROR_NO_SUCH_TABLE;
456 if (ip6_table_index != ~0 &&
458 return VNET_API_ERROR_NO_SUCH_TABLE2;
460 if (other_table_index != ~0 &&
462 return VNET_API_ERROR_NO_SUCH_TABLE3;
477 [sw_if_index] = ip4_table_index;
480 [sw_if_index] = ip6_table_index;
483 [sw_if_index] = other_table_index;
494 u32 sw_if_index = ~0;
495 u32 ip4_table_index = ~0;
496 u32 ip6_table_index = ~0;
497 u32 other_table_index = ~0;
505 else if (
unformat (input,
"ip4-table %d", &ip4_table_index))
507 else if (
unformat (input,
"ip6-table %d", &ip6_table_index))
509 else if (
unformat (input,
"other-table %d", &other_table_index))
515 if (sw_if_index == ~0)
519 if (ip4_table_index == ~0 && ip6_table_index == ~0
520 && other_table_index == ~0)
528 ip6_table_index, other_table_index);
545 .path =
"set interface l2 classify",
547 "set interface l2 classify intfc <int> [ip4-table <n>]\n" 548 " [ip6-table <n>] [other-table <n>]",
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)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
#define foreach_l2_classify_error
struct _vlib_node_registration vlib_node_registration_t
unformat_function_t unformat_vnet_sw_interface
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)
u32 * classify_table_index_by_sw_if_index[L2_CLASSIFY_N_TABLES]
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
vnet_classify_main_t * vnet_classify_main
static char * l2_classify_error_strings[]
void vnet_l2_classify_enable_disable(u32 sw_if_index, int enable_disable)
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
l2_classify_main_t l2_classify_main
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
#define pool_elt_at_index(p, i)
int vnet_l2_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
static clib_error_t * int_l2_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
always_inline void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#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,...)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
u32 feat_next_node_index[32]
#define CLIB_PREFETCH(addr, size, type)
static u8 * format_l2_classify_trace(u8 *s, va_list *args)
vnet_classify_main_t * vcm
vlib_node_registration_t l2_classify_node
(constructor) VLIB_REGISTER_NODE (l2_classify_node)
clib_error_t * l2_classify_init(vlib_main_t *vm)
#define pool_is_free_index(P, I)
#define VLIB_CLI_COMMAND(x,...)
struct _vnet_classify_main vnet_classify_main_t
#define VLIB_NODE_FLAG_TRACE
vnet_classify_main_t vnet_classify_main
#define VLIB_BUFFER_IS_TRACED
static uword l2_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
always_inline void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
always_inline u32 feat_bitmap_get_next_node_index(u32 *next_nodes, u32 bitmap)
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...)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
uword runtime_data[(128-1 *sizeof(vlib_node_function_t *)-1 *sizeof(vlib_error_t *)-11 *sizeof(u32)-5 *sizeof(u16))/sizeof(uword)]
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)
l2_classify_main_t * l2cm