48 BVT (clib_bihash) mac_table;
63 u32 sw_if_index = va_arg (*args,
u32);
64 if (sw_if_index == ~0)
77 BVT (clib_bihash) * h = &msm->mac_table;
84 for (i = 0; i < h->nbuckets; i++)
90 for (j = 0; j < (1 << b->log2_pages); j++)
94 if (
v->kvp[k].key == ~0ULL &&
v->kvp[k].value == ~0ULL)
97 key.
raw =
v->kvp[k].key;
98 result.
raw =
v->kvp[k].value;
100 if ((bd_index == ~0) || (bd_index == key.
fields.bd_index))
119 BVT (clib_bihash) * h = &msm->mac_table;
125 u64 total_entries = 0;
129 u32 bd_id, bd_index = ~0;
135 else if (
unformat (input,
"verbose"))
137 else if (
unformat (input,
"bd_index %d", &bd_index))
139 else if (
unformat (input,
"bd_id %d", &bd_id))
154 for (i = 0; i < h->nbuckets; i++)
160 for (j = 0; j < (1 << b->log2_pages); j++)
164 if (
v->kvp[k].key == ~0ULL &&
v->kvp[k].value == ~0ULL)
167 if (verbose && first_entry)
171 "%=19s%=7s%=30s%=7s%=8s%=8s%=5s%=16s",
172 "Mac Address",
"BD Idx",
"Interface",
173 "Index",
"static",
"filter",
"bvi",
177 key.
raw =
v->kvp[k].key;
178 result.
raw =
v->kvp[k].value;
181 & ((bd_index >> 31) || (bd_index == key.
fields.bd_index)))
188 i16 delta = now - result.
fields.timestamp;
189 delta += delta < 0 ? 256 : 0;
190 s =
format (s,
"%d", delta);
193 s =
format (s,
"disabled");
196 "%=19U%=7d%=30U%=7d%=8d%=8d%=5d%=16v",
200 msm->vnet_main, result.
fields.sw_if_index,
201 result.
fields.sw_if_index == ~0
202 ? -1 : result.
fields.sw_if_index,
214 if (total_entries == 0)
221 BV (format_bihash), h, 1 );
250 .path =
"show l2fib",
251 .short_help =
"show l2fib [verbose | bd_id <nn> | bd_index <nn> | raw]",
302 .path =
"clear l2fib",
303 .short_help =
"clear l2fib",
316 u32 sw_if_index,
u32 static_mac,
u32 filter_mac,
u32 bvi_mac)
320 __attribute__ ((unused))
u32 bucket_contents;
322 BVT (clib_bihash_kv) kv;
329 result.
fields.sw_if_index = sw_if_index;
330 result.
fields.static_mac = static_mac;
331 result.
fields.filter = filter_mac;
332 result.
fields.bvi = bvi_mac;
335 kv.value = result.
raw;
340 if (result.
fields.static_mac)
363 u32 sw_if_index = ~0;
376 if (!
unformat (input,
"%d", &bd_id))
455 .short_help =
"l2fib add <mac> <bridge-domain-id> filter | <intf> [static | bvi]",
488 else if (
unformat (input,
"count %d", &count))
497 if (is_add == 0 && is_del == 0 && is_check == 0)
499 "noop: pick at least one of (add,del,check)");
505 for (i = 0; i < count; i++)
509 filter_mac, bvi_mac);
510 tmp = clib_net_to_host_u64 (mac);
514 mac = clib_host_to_net_u64 (tmp);
520 BVT (clib_bihash_kv) kv;
525 for (i = 0; i < count; i++)
534 tmp = clib_net_to_host_u64 (mac);
538 mac = clib_host_to_net_u64 (tmp);
544 for (i = 0; i < count; i++)
550 tmp = clib_net_to_host_u64 (mac);
554 mac = clib_host_to_net_u64 (tmp);
600 .path =
"test l2fib",
601 .short_help =
"test l2fib [add|del|check] mac <base-addr> count <nn>",
617 BVT (clib_bihash_kv) kv;
625 result.
raw = kv.value;
628 if (result.
fields.static_mac)
664 if (!
unformat (input,
"%d", &bd_id))
701 .short_help =
"l2fib del <mac> <bridge-domain-id>",
707 BVT (clib_bihash) * get_mac_table (
void)
710 return &mp->mac_table;
717 uword event_type, *event_data = 0;
720 BVT (clib_bihash) * h = &msm->mac_table;
727 f64 start_time, last_run_duration = 0, t;
754 for (i = 0; i < h->nbuckets; i++)
758 if (t > start_time + 10e-6)
764 if (i < (h->nbuckets - 3))
766 b = &h->buckets[i + 3];
768 b = &h->buckets[i + 1];
780 for (j = 0; j < (1 << b->log2_pages); j++)
784 if (
v->kvp[k].key == ~0ULL &&
v->kvp[k].value == ~0ULL)
787 key.
raw =
v->kvp[k].key;
788 result.
raw =
v->kvp[k].value;
790 if (result.
fields.static_mac)
799 delta = (
u8) (start_time / 60) - result.
fields.timestamp;
800 delta += delta < 0 ? 256 : 0;
802 if (delta > bd_config->
mac_age)
804 void *p = &key.
fields.mac;
820 .name =
"l2fib-mac-age-scanner-process",
839 memset (test_mac, 0,
sizeof (test_mac));
struct l2fib_entry_key_t::@189::@191 fields
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.
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
void clib_bihash_free(clib_bihash *h)
Destroy a bounded index extensible hash table.
static f64 vlib_time_now(vlib_main_t *vm)
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.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
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)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_warning(format, args...)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
uword * bd_index_by_bd_id
format_function_t format_vnet_sw_interface_name
#define BIHASH_KVP_PER_PAGE
struct l2fib_entry_result_t::@193::@195 fields
#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)
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
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.
#define VLIB_CLI_COMMAND(x,...)
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.
static uword l2fib_mac_age_scanner_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
template key/value backing page structure
static u64 l2fib_make_key(u8 *mac_address, u16 bd_index)
l2_bridge_domain_t * bd_configs
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
#define VLIB_REGISTER_NODE(x,...)
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...)
#define CLIB_CACHE_LINE_BYTES
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.
vlib_node_registration_t l2fib_mac_age_scanner_process_node
(constructor) VLIB_REGISTER_NODE (l2fib_mac_age_scanner_process_node)