18 #ifndef included_l2fib_h 19 #define included_l2fib_h 27 #define L2FIB_NUM_BUCKETS (64 * 1024) 28 #define L2FIB_MEMORY_SIZE (512<<20) 31 #define L2FIB_AGE_SCAN_INTERVAL (60.0) 34 #define L2FIB_EVENT_SCAN_DELAY_DEFAULT (0.1) 37 #define L2FIB_EVENT_MAX_MACS_DEFAULT (100) 40 #define L2FIB_EVENT_LEARN_LIMIT_DEFAULT (1000) 46 BVT (clib_bihash) mac_table;
114 #define foreach_l2fib_entry_result_attr \ 115 _(STATIC, 0, "static") \ 116 _(AGE_NOT, 1, "age-not") \ 118 _(FILTER, 3, "filter") \ 119 _(LRN_EVT, 4, "learn-event") \ 120 _(LRN_MOV, 5, "learn-move") 125 #define _(a,v,s) L2FIB_ENTRY_RESULT_FLAG_##a = (1 << v), 157 l2fib_entry_result_is_set_##a (const l2fib_entry_result_t *r) { \ 158 return (r->fields.flags & L2FIB_ENTRY_RESULT_FLAG_##a); \ 164 l2fib_entry_result_set_##a (l2fib_entry_result_t *r) { \ 165 r->fields.flags |= L2FIB_ENTRY_RESULT_FLAG_##a; \ 171 l2fib_entry_result_clear_##a (l2fib_entry_result_t *r) { \ 172 r->fields.flags &= ~L2FIB_ENTRY_RESULT_FLAG_##a; \ 178 l2fib_entry_result_flags_t bits)
185 l2fib_entry_result_flags_t bits)
210 temp_a = key->
words.w0;
211 temp_b = key->
words.w1;
226 #if CLIB_ARCH_IS_LITTLE_ENDIAN 232 temp = (temp & ~0xffff) | (
u64) (bd_index);
239 temp = temp | (((
u64) bd_index) << 48);
270 if (key0->
raw == cached_key->
raw)
273 result0->
raw = cached_result->
raw;
278 BVT (clib_bihash_kv) kv;
283 result0->
raw = kv.value;
286 cached_key->
raw = key0->
raw;
287 cached_result->
raw = result0->
raw;
320 if ((key0->
raw == cached_key->
raw) && (key1->
raw == cached_key->
raw))
323 result0->
raw = cached_result->
raw;
324 result1->
raw = cached_result->
raw;
328 BVT (clib_bihash_kv) kv0, kv1;
342 result0->
raw = kv0.value;
343 result1->
raw = kv1.value;
346 cached_key->
raw = key1->
raw;
347 cached_result->
raw = result1->
raw;
378 if ((key0->
raw == cached_key->
raw) && (key1->
raw == cached_key->
raw) &&
379 (key2->
raw == cached_key->
raw) && (key3->
raw == cached_key->
raw))
382 result0->
raw = cached_result->
raw;
383 result1->
raw = cached_result->
raw;
384 result2->
raw = cached_result->
raw;
385 result3->
raw = cached_result->
raw;
389 BVT (clib_bihash_kv) kv0, kv1, kv2, kv3;
409 result0->
raw = kv0.value;
410 result1->
raw = kv1.value;
411 result2->
raw = kv2.value;
412 result3->
raw = kv3.value;
415 cached_key->
raw = key1->
raw;
416 cached_result->
raw = result1->
raw;
425 u32 sw_if_index, l2fib_entry_result_flags_t flags);
431 (L2FIB_ENTRY_RESULT_FLAG_FILTER |
432 L2FIB_ENTRY_RESULT_FLAG_STATIC));
466 BVT (clib_bihash) * get_mac_table (
void);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
struct l2fib_entry_key_t::@450::@453 words
l2fib_entry_result_flags_t flags
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
enum l2fib_entry_result_flags_t_ l2fib_entry_result_flags_t
#define static_always_inline
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, l2fib_entry_result_t *result0)
Lookup the entry for mac and bd_index in the mac table for 1 packet.
static void l2fib_entry_result_clear_bits(l2fib_entry_result_t *r, l2fib_entry_result_flags_t bits)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void l2fib_flush_all_mac(vlib_main_t *vm)
Flush all non static MACs - flushes all valid BDs.
struct l2fib_entry_result_t_ l2fib_entry_result_t
static_always_inline u8 * l2fib_valid_swif_seq_num(u32 sw_if_index)
u8 * format_l2fib_entry_result_flags(u8 *s, va_list *args)
void l2fib_add_entry(const u8 *mac, u32 bd_index, u32 sw_if_index, l2fib_entry_result_flags_t flags)
Add an entry to the l2fib.
BVT(clib_bihash) *get_mac_table(void)
static_always_inline void l2fib_lookup_4(BVT(clib_bihash) *mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, const u8 *mac0, const u8 *mac1, const u8 *mac2, const 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, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1, l2fib_entry_result_t *result2, l2fib_entry_result_t *result3)
STATIC_ASSERT_SIZEOF(l2fib_entry_key_t, 8)
int clib_bihash_search_inline(clib_bihash *h, clib_bihash_kv *in_out_kv)
Search a bi-hash table.
#define L2FIB_NUM_BUCKETS
static_always_inline void l2fib_lookup_2(BVT(clib_bihash) *mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u8 *mac1, u16 bd_index0, u16 bd_index1, l2fib_entry_key_t *key0, l2fib_entry_key_t *key1, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1)
Lookup the entry for mac and bd_index in the mac table for 2 packets.
struct l2fib_entry_result_t_::@458::@460 fields
l2fib_entry_result_flags_t_
void l2fib_flush_bd_mac(vlib_main_t *vm, u32 bd_index)
Flush all non static MACs in a bridge domain.
#define hash_mix32(a0, b0, c0)
static u64 l2fib_make_key(const u8 *mac_address, u16 bd_index)
void l2fib_clear_table(void)
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
void l2fib_flush_int_mac(vlib_main_t *vm, u32 sw_if_index)
Flush all non static MACs from an interface.
#define foreach_l2fib_entry_result_attr
Flags associated with an L2 Fib Entry.
u32 l2fib_del_entry(const u8 *mac, u32 bd_index, u32 sw_if_index)
Delete an entry from the l2fib.
u8 * format_vnet_sw_if_index_name_with_NA(u8 *s, va_list *args)
Format sw_if_index.
static u32 l2fib_compute_hash_bucket(l2fib_entry_key_t *key)
Compute the hash for the given key and return the corresponding bucket index.
static void l2fib_add_filter_entry(const u8 *mac, u32 bd_index)
static foreach_l2fib_entry_result_attr void l2fib_entry_result_set_bits(l2fib_entry_result_t *r, l2fib_entry_result_flags_t bits)
#define CLIB_MEM_OVERFLOW_LOAD(f, src)
manual_print typedef u8 mac_address[6]
void l2fib_start_ager_scan(vlib_main_t *vm)
Kick off ager to scan MACs to age/delete MAC entries.