64 s =
format (s,
"l2-classify: sw_if_index %d, table %d, offset %x, next %d",
72 #ifndef CLIB_MARCH_VARIANT 77 #define foreach_l2_input_classify_error \ 78 _(MISS, "Classify misses") \ 79 _(HIT, "Classify hits") \ 80 _(CHAIN_HIT, "Classify hits after chain walk") \ 81 _(DROP, "L2 Classify Drops") 85 #define _(sym,str) L2_INPUT_CLASSIFY_ERROR_##sym, 92 #define _(sym,string) string, 151 u32 n_left_from, *from, *to_next;
163 n_next_nodes =
node->n_next_nodes;
167 n_left_from =
frame->n_vectors;
172 while (n_left_from >= 4)
177 u32 sw_if_index0, sw_if_index1;
179 int type_index0, type_index1;
181 u32 table_index0, table_index1;
213 type0 = clib_net_to_host_u16 (h0->
type);
214 type1 = clib_net_to_host_u16 (h1->
type);
216 type_index0 = (type0 == ETHERNET_TYPE_IP4)
218 type_index0 = (type0 == ETHERNET_TYPE_IP6)
221 type_index1 = (type1 == ETHERNET_TYPE_IP4)
223 type_index1 = (type1 == ETHERNET_TYPE_IP6)
228 rt->
l2cm->classify_table_index_by_sw_if_index
229 [type_index0][sw_if_index0];
231 if (table_index0 != ~0)
242 rt->
l2cm->classify_table_index_by_sw_if_index
243 [type_index1][sw_if_index1];
245 if (table_index1 != ~0)
258 while (n_left_from > 0)
278 type0 = clib_net_to_host_u16 (h0->
type);
280 type_index0 = (type0 == ETHERNET_TYPE_IP4)
282 type_index0 = (type0 == ETHERNET_TYPE_IP6)
286 table_index0 = rt->
l2cm->classify_table_index_by_sw_if_index
287 [type_index0][sw_if_index0];
289 if (table_index0 != ~0)
301 next_index =
node->cached_next_index;
303 n_left_from =
frame->n_vectors;
305 while (n_left_from > 0)
312 while (n_left_from > 0 && n_left_to_next > 0)
321 vnet_classify_entry_t *e0;
334 table_index2 =
vnet_buffer (p2)->l2_classify.table_index;
354 table_index0 =
vnet_buffer (b0)->l2_classify.table_index;
369 next0 = (e0->next_index < n_next_nodes) ?
370 e0->next_index : next0;
396 next0 = (e0->next_index < n_next_nodes) ?
397 e0->next_index : next0;
407 b0->
error =
node->errors[L2_INPUT_CLASSIFY_ERROR_DROP];
412 L2INPUT_FEAT_INPUT_CLASSIFY);
415 ~L2INPUT_FEAT_INPUT_CLASSIFY;
418 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
430 to_next, n_left_to_next,
438 L2_INPUT_CLASSIFY_ERROR_MISS, misses);
440 L2_INPUT_CLASSIFY_ERROR_HIT, hits);
442 L2_INPUT_CLASSIFY_ERROR_CHAIN_HIT, chain_hits);
443 return frame->n_vectors;
448 .name =
"l2-input-classify",
449 .vector_size =
sizeof (
u32),
471 #ifndef CLIB_MARCH_VARIANT 490 cm->l2_inp_feat_next);
492 rt->
vcm = cm->vnet_classify_main;
508 rt->
vcm = cm->vnet_classify_main;
520 (
u32) enable_disable);
537 u32 ip6_table_index,
u32 other_table_index)
544 if (ip4_table_index != ~0 &&
546 return VNET_API_ERROR_NO_SUCH_TABLE;
548 if (ip6_table_index != ~0 &&
550 return VNET_API_ERROR_NO_SUCH_TABLE2;
552 if (other_table_index != ~0 &&
554 return VNET_API_ERROR_NO_SUCH_TABLE3;
588 u32 ip4_table_index = ~0;
589 u32 ip6_table_index = ~0;
590 u32 other_table_index = ~0;
598 else if (
unformat (input,
"ip4-table %d", &ip4_table_index))
600 else if (
unformat (input,
"ip6-table %d", &ip6_table_index))
602 else if (
unformat (input,
"other-table %d", &other_table_index))
608 if (sw_if_index == ~0)
612 if (ip4_table_index == ~0 && ip6_table_index == ~0
613 && other_table_index == ~0)
621 ip6_table_index, other_table_index);
648 .path =
"set interface l2 input classify",
650 "set interface l2 input classify intfc <interface-name> [ip4-table <n>]\n" 651 " [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) ...
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
vnet_main_t * vnet_get_main(void)
static f64 vlib_time_now(vlib_main_t *vm)
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
static u32 vnet_l2_feature_next(vlib_buffer_t *b, u32 *next_nodes, u32 feat_bit)
Return the graph node index for the feature corresponding to the next set bit after clearing the curr...
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
#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.
#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)
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
static void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
Initialize the feature next-node indexes of a graph node.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
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
#define VLIB_CLI_COMMAND(x,...)
struct _vnet_classify_main vnet_classify_main_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vnet_classify_main_t vnet_classify_main
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _l2_classify_main l2_input_classify_main_t
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#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.
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)