36 BVT(clib_bihash) mac_table;
50 u32 sw_if_index = va_arg (*args,
u32);
51 if (sw_if_index == ~0)
63 BVT(clib_bihash) * h = &msm->mac_table;
65 BVT(clib_bihash_value) * v;
70 for (i = 0; i < h->nbuckets; i++)
80 if (v->kvp[k].key == ~0ULL && v->kvp[k].value == ~0ULL)
83 key.
raw = v->kvp[k].key;
84 result.
raw = v->kvp[k].value;
86 if ((bd_index == ~0) || (bd_index == key.
fields.bd_index))
105 BVT(clib_bihash) * h = &msm->mac_table;
107 BVT(clib_bihash_value) * v;
111 u64 total_entries = 0;
115 u32 bd_id, bd_index = ~0;
119 else if (
unformat (input,
"verbose"))
121 else if (
unformat (input,
"bd_index %d", &bd_index))
123 else if (
unformat (input,
"bd_id %d", &bd_id))
138 for (i = 0; i < h->nbuckets; i++)
148 if (v->kvp[k].key == ~0ULL && v->kvp[k].value == ~0ULL)
151 if (verbose && first_entry)
155 "%=19s%=7s%=30s%=7s%=8s%=8s%=5s%=9s%=11s",
156 "Mac Address",
"BD Idx",
"Interface",
157 "Index",
"static",
"filter",
"bvi",
158 "refresh",
"timestamp");
161 key.
raw = v->kvp[k].key;
162 result.
raw = v->kvp[k].value;
165 & ((bd_index >>31) || (bd_index == key.
fields.bd_index)))
168 "%=19U%=7d%=30U%=7d%=8d%=8d%=5d%=9d%=11X",
172 msm->vnet_main, result.
fields.sw_if_index,
173 result.
fields.sw_if_index == ~0
174 ? -1 : result.
fields.sw_if_index,
187 if (total_entries == 0)
200 .path =
"show l2fib",
201 .short_help =
"show l2fib [verbose | bd_id <nn> | bd_index <nn> | raw]",
235 .path =
"clear l2fib",
236 .short_help =
"Clear l2fib mac forwarding entries",
251 __attribute__((unused))
u32 bucket_contents;
253 BVT(clib_bihash_kv) kv;
260 result.
fields.sw_if_index = sw_if_index;
261 result.
fields.static_mac = static_mac;
262 result.
fields.filter = filter_mac;
263 result.
fields.bvi = bvi_mac;
266 kv.value = result.
raw;
271 if (result.
fields.static_mac) {
292 u32 sw_if_index = ~0;
305 if (!
unformat (input,
"%d", &bd_id)) {
331 }
else if (
unformat (input,
"bvi")) {
337 l2fib_add_entry(mac, bd_index, sw_if_index, static_mac, filter_mac, bvi_mac);
345 .short_help =
"Add l2fib mac forwarding entry <mac> <bd-id> filter | <intf> [static | bvi]",
378 else if (
unformat (input,
"count %d", &count))
387 if (is_add == 0 && is_del == 0 && is_check == 0)
394 for (i = 0; i < count; i++)
398 filter_mac, bvi_mac);
399 tmp = clib_net_to_host_u64(mac);
403 mac = clib_host_to_net_u64 (tmp);
409 BVT(clib_bihash_kv) kv;
414 for (i = 0; i < count; i++)
423 tmp = clib_net_to_host_u64(mac);
427 mac = clib_host_to_net_u64 (tmp);
433 for (i = 0; i < count; i++)
439 tmp = clib_net_to_host_u64(mac);
443 mac = clib_host_to_net_u64 (tmp);
451 .path =
"test l2fib",
452 .short_help =
"test l2fib [del] mac <base-addr> count <nn>",
464 BVT(clib_bihash_kv) kv;
472 result.
raw = kv.value;
475 if (result.
fields.static_mac) {
508 if (!
unformat (input,
"%d", &bd_id)) {
533 .short_help =
"Delete l2fib mac forwarding entry <mac> <bd-id>",
538 BVT(clib_bihash) *get_mac_table(
void) {
540 return &mp->mac_table;
557 memset (test_mac, 0,
sizeof(test_mac));
static clib_error_t * l2fib_test_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
sll srl srl sll sra u16x4 i
u8 * format_vnet_sw_if_index_name_with_NA(u8 *s, va_list *args)
u32 l2fib_del_entry(u64 mac, u32 bd_index)
clib_error_t * l2fib_init(vlib_main_t *vm)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define L2FIB_MEMORY_SIZE
unformat_function_t unformat_vnet_sw_interface
int BV() clib_bihash_add_del(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*add_v, int is_add)
static clib_error_t * l2fib_del(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_main_t * vnet_get_main(void)
u8 * format_ethernet_address(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(x)
void BV() clib_bihash_init(BVT(clib_bihash)*h, char *name, u32 nbuckets, uword memory_size)
#define clib_warning(format, args...)
int vlib_main(vlib_main_t *vm, unformat_input_t *input)
uword * bd_index_by_bd_id
int BV() clib_bihash_search(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*search_key, BVT(clib_bihash_kv)*valuep)
format_function_t format_vnet_sw_interface_name
#define BIHASH_KVP_PER_PAGE
always_inline u64 l2fib_make_key(u8 *mac_address, u16 bd_index)
u8 *BV() format_bihash(u8 *s, va_list *args)
#define L2FIB_NUM_BUCKETS
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static clib_error_t * clear_l2fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * show_l2fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct l2fib_entry_key_t::@124::@126 fields
void l2fib_clear_table(uint keep_static)
void l2fib_add_entry(u64 mac, u32 bd_index, u32 sw_if_index, u32 static_mac, u32 filter_mac, u32 bvi_mac)
struct l2fib_entry_result_t::@128::@130 fields
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
void BV() clib_bihash_free(BVT(clib_bihash)*h)
static void *BV() clib_bihash_get_value(BVT(clib_bihash)*h, uword offset)
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
l2learn_main_t l2learn_main
#define clib_error_return(e, args...)
static clib_error_t * l2fib_add(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)