66 s =
format (s,
"l2-learn: sw_if_index %d dst %U src %U bd_index %d",
75 #define foreach_l2learn_error \ 76 _(L2LEARN, "L2 learn packets") \ 77 _(MISS, "L2 learn misses") \ 78 _(MAC_MOVE, "L2 mac moves") \ 79 _(MAC_MOVE_VIOLATE, "L2 mac move violations") \ 80 _(LIMIT, "L2 not learned due to limit") \ 81 _(HIT_UPDATE, "L2 learn hit updates") \ 82 _(FILTER_DROP, "L2 filter mac drops") 86 #define _(sym,str) L2LEARN_ERROR_##sym, 93 #define _(sym,string) string, 127 u32 dtime = timestamp - result0->
fields.timestamp;
133 if (result0->
fields.age_not)
141 if ((*count > 2) && (dtime == 1) && (dsn == 0))
144 counter_base[L2LEARN_ERROR_HIT_UPDATE] += 1;
147 else if (result0->
raw == ~0)
150 counter_base[L2LEARN_ERROR_MISS] += 1;
158 counter_base[L2LEARN_ERROR_LIMIT] += 1;
171 result0->
fields.sw_if_index = sw_if_index0;
177 if (result0->
fields.filter)
181 b0->
error = node->
errors[L2LEARN_ERROR_FILTER_DROP];
186 if (result0->
fields.static_mac)
192 b0->
error = node->
errors[L2LEARN_ERROR_MAC_MOVE_VIOLATE];
201 result0->
fields.sw_if_index = sw_if_index0;
202 if (result0->
fields.age_not)
205 result0->
fields.age_not = 0;
208 counter_base[L2LEARN_ERROR_MAC_MOVE] += 1;
212 result0->
fields.timestamp = timestamp;
215 BVT (clib_bihash_kv) kv;
217 kv.value = result0->
raw;
221 cached_key->
raw = ~0;
229 u32 n_left_from, *from, *to_next;
246 cached_result.
raw = ~0;
248 while (n_left_from > 0)
255 while (n_left_from >= 8 && n_left_to_next >= 4)
257 u32 bi0, bi1, bi2, bi3;
259 u32 next0, next1, next2, next3;
260 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
264 u32 bucket0, bucket1, bucket2, bucket3;
288 to_next[0] = bi0 = from[0];
289 to_next[1] = bi1 = from[1];
290 to_next[2] = bi2 = from[2];
291 to_next[3] = bi3 = from[3];
357 L2LEARN_ERROR_L2LEARN, 4);
368 &key0, &key1, &key2, &key3,
369 &bucket0, &bucket1, &bucket2, &bucket3,
370 &result0, &result1, &result2, &result3);
373 b0, sw_if_index0, &key0, &cached_key,
374 &count, &result0, &next0, timestamp);
377 b1, sw_if_index1, &key1, &cached_key,
378 &count, &result1, &next1, timestamp);
381 b2, sw_if_index2, &key2, &cached_key,
382 &count, &result2, &next2, timestamp);
385 b3, sw_if_index3, &key3, &cached_key,
386 &count, &result3, &next3, timestamp);
391 to_next, n_left_to_next,
393 next0, next1, next2, next3);
396 while (n_left_from > 0 && n_left_to_next > 0)
432 L2LEARN_ERROR_L2LEARN, 1);
437 &key0, &bucket0, &result0);
440 b0, sw_if_index0, &key0, &cached_key,
441 &count, &result0, &next0, timestamp);
445 to_next, n_left_to_next,
468 .vector_size =
sizeof (
u32),
501 mp->mac_table = get_mac_table ();
562 .path =
"set interface l2 learn",
563 .short_help =
"set interface l2 learn <interface> [disable]",
vnet_main_t * vnet_get_main(void)
static f64 vlib_time_now(vlib_main_t *vm)
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
struct _vlib_node_registration vlib_node_registration_t
clib_error_t * l2learn_init(vlib_main_t *vm)
unformat_function_t unformat_vnet_sw_interface
vlib_error_t * errors
Vector of errors for this 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...
static_always_inline void l2learn_process(vlib_node_runtime_t *node, l2learn_main_t *msm, u64 *counter_base, vlib_buffer_t *b0, u32 sw_if_index0, l2fib_entry_key_t *key0, l2fib_entry_key_t *cached_key, u32 *count, l2fib_entry_result_t *result0, u32 *next0, u8 timestamp)
Perform learning on one packet based on the mac table lookup result.
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
int clib_bihash_add_del(clib_bihash *h, clib_bihash_kv *add_v, int is_add)
Add or delete a (key,value) pair from a bi-hash table.
#define VLIB_INIT_FUNCTION(x)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
static char * l2learn_error_strings[]
vlib_error_main_t error_main
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define VLIB_CONFIG_FUNCTION(x, n,...)
static_always_inline uword l2learn_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
static u8 * format_l2learn_trace(u8 *s, va_list *args)
#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).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#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 foreach_l2learn_error
static clib_error_t * l2learn_config(vlib_main_t *vm, unformat_input_t *input)
#define VLIB_BUFFER_IS_TRACED
#define clib_memcpy(a, b, c)
struct l2fib_entry_key_t::@178::@180 fields
static clib_error_t * int_learn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface learn enable/disable.
u32 feat_next_node_index[32]
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.
#define VLIB_CLI_COMMAND(x,...)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
struct l2fib_entry_result_t::@186::@188 fields
#define VLIB_NODE_FLAG_TRACE
static uword l2learn_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
l2learn_main_t l2learn_main
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
static_always_inline void l2fib_lookup_4(BVT(clib_bihash)*mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u8 *mac1, u8 *mac2, u8 *mac3, u16 bd_index0, u16 bd_index1, u16 bd_index2, u16 bd_index3, l2fib_entry_key_t *key0, l2fib_entry_key_t *key1, l2fib_entry_key_t *key2, l2fib_entry_key_t *key3, u32 *bucket0, u32 *bucket1, u32 *bucket2, u32 *bucket3, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1, l2fib_entry_result_t *result2, l2fib_entry_result_t *result3)
u16 flags
Copy of main node flags.
static_always_inline void l2fib_lookup_1(BVT(clib_bihash)*mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u16 bd_index0, l2fib_entry_key_t *key0, u32 *bucket0, l2fib_entry_result_t *result0)
Lookup the entry for mac and bd_index in the mac table for 1 packet.
#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 vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static vlib_node_registration_t l2learn_node
(constructor) VLIB_REGISTER_NODE (l2learn_node)
#define L2LEARN_DEFAULT_LIMIT