37 BVT (clib_bihash) mac_table;
52 u32 sw_if_index = va_arg (*args,
u32);
53 if (sw_if_index == ~0)
66 BVT (clib_bihash) * h = &msm->mac_table;
73 for (i = 0; i < h->nbuckets; i++)
79 for (j = 0; j < (1 << b->log2_pages); j++)
83 if (v->kvp[k].key == ~0ULL && v->kvp[k].value == ~0ULL)
86 key.
raw = v->kvp[k].key;
87 result.
raw = v->kvp[k].value;
89 if ((bd_index == ~0) || (bd_index == key.
fields.bd_index))
107 BVT (clib_bihash) * h = &msm->mac_table;
113 u64 total_entries = 0;
117 u32 bd_id, bd_index = ~0;
121 else if (
unformat (input,
"verbose"))
123 else if (
unformat (input,
"bd_index %d", &bd_index))
125 else if (
unformat (input,
"bd_id %d", &bd_id))
140 for (i = 0; i < h->nbuckets; i++)
146 for (j = 0; j < (1 << b->log2_pages); j++)
150 if (v->kvp[k].key == ~0ULL && v->kvp[k].value == ~0ULL)
153 if (verbose && first_entry)
157 "%=19s%=7s%=30s%=7s%=8s%=8s%=5s%=9s%=11s",
158 "Mac Address",
"BD Idx",
"Interface",
159 "Index",
"static",
"filter",
"bvi",
160 "refresh",
"timestamp");
163 key.
raw = v->kvp[k].key;
164 result.
raw = v->kvp[k].value;
167 & ((bd_index >> 31) || (bd_index == key.
fields.bd_index)))
170 "%=19U%=7d%=30U%=7d%=8d%=8d%=5d%=9d%=11X",
174 msm->vnet_main, result.
fields.sw_if_index,
175 result.
fields.sw_if_index == ~0
176 ? -1 : result.
fields.sw_if_index,
189 if (total_entries == 0)
196 BV (format_bihash), h, 1 );
203 .path =
"show l2fib",
204 .short_help =
"show l2fib [verbose | bd_id <nn> | bd_index <nn> | raw]",
244 .path =
"clear l2fib",
245 .short_help =
"Clear l2fib mac forwarding entries",
258 u32 sw_if_index,
u32 static_mac,
u32 filter_mac,
u32 bvi_mac)
262 __attribute__ ((unused))
u32 bucket_contents;
264 BVT (clib_bihash_kv) kv;
271 result.
fields.sw_if_index = sw_if_index;
272 result.
fields.static_mac = static_mac;
273 result.
fields.filter = filter_mac;
274 result.
fields.bvi = bvi_mac;
277 kv.value = result.
raw;
282 if (result.
fields.static_mac)
305 u32 sw_if_index = ~0;
318 if (!
unformat (input,
"%d", &bd_id))
370 .short_help =
"Add l2fib mac forwarding entry <mac> <bd-id> filter | <intf> [static | bvi]",
403 else if (
unformat (input,
"count %d", &count))
412 if (is_add == 0 && is_del == 0 && is_check == 0)
414 "noop: pick at least one of (add,del,check)");
420 for (i = 0; i < count; i++)
424 filter_mac, bvi_mac);
425 tmp = clib_net_to_host_u64 (mac);
429 mac = clib_host_to_net_u64 (tmp);
435 BVT (clib_bihash_kv) kv;
440 for (i = 0; i < count; i++)
449 tmp = clib_net_to_host_u64 (mac);
453 mac = clib_host_to_net_u64 (tmp);
459 for (i = 0; i < count; i++)
465 tmp = clib_net_to_host_u64 (mac);
469 mac = clib_host_to_net_u64 (tmp);
478 .path =
"test l2fib",
479 .short_help =
"test l2fib [del] mac <base-addr> count <nn>",
495 BVT (clib_bihash_kv) kv;
503 result.
raw = kv.value;
506 if (result.
fields.static_mac)
542 if (!
unformat (input,
"%d", &bd_id))
571 .short_help =
"Delete l2fib mac forwarding entry <mac> <bd-id>",
577 BVT (clib_bihash) * get_mac_table (
void)
580 return &mp->mac_table;
598 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)
Format sw_if_index.
void clib_bihash_free(clib_bihash *h)
Destroy a bounded index extensible hash table.
struct l2fib_entry_result_t::@159::@161 fields
u32 l2fib_del_entry(u64 mac, u32 bd_index)
Delete an entry from the l2fib.
clib_error_t * l2fib_init(vlib_main_t *vm)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define L2FIB_MEMORY_SIZE
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * l2fib_del(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Delete an entry from the L2FIB.
vnet_main_t * vnet_get_main(void)
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 clib_warning(format, args...)
int vlib_main(vlib_main_t *vm, unformat_input_t *input)
uword * bd_index_by_bd_id
format_function_t format_vnet_sw_interface_name
#define BIHASH_KVP_PER_PAGE
#define L2FIB_NUM_BUCKETS
void clib_bihash_init(clib_bihash *h, char *name, u32 nbuckets, uword memory_size)
initialize a bounded index extensible hash table
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)
Clear all entries in L2FIB.
static clib_error_t * show_l2fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Display the contents of the l2fib.
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)
Add an entry to the l2fib.
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
int clib_bihash_search(clib_bihash *h, clib_bihash_kv *search_v, clib_bihash_kv *return_v)
Search a bi-hash table.
template key/value backing page structure
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
static u64 l2fib_make_key(u8 *mac_address, u16 bd_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
static void * clib_bihash_get_value(clib_bihash *h, uword offset)
Get pointer to value page given its clib mheap offset.
#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)
Add an entry to the L2FIB.
struct l2fib_entry_key_t::@155::@157 fields