FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
l2_fib.h File Reference
+ Include dependency graph for l2_fib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  l2fib_main_t
 
struct  l2fib_entry_key_t
 
struct  l2fib_seq_num_t
 
struct  l2fib_entry_result_t
 

Macros

#define L2FIB_NUM_BUCKETS   (64 * 1024)
 
#define L2FIB_MEMORY_SIZE   (512<<20)
 
#define L2FIB_AGE_SCAN_INTERVAL   (60.0)
 
#define L2FIB_EVENT_SCAN_DELAY_DEFAULT   (0.1)
 
#define L2FIB_EVENT_MAX_MACS_DEFAULT   (100)
 
#define L2FIB_EVENT_LEARN_LIMIT_DEFAULT   (1000)
 

Enumerations

enum  l2_mac_event_action_t { MAC_EVENT_ACTION_ADD = 0, MAC_EVENT_ACTION_DELETE = 1, MAC_EVENT_ACTION_MOVE = 2 }
 

Functions

 STATIC_ASSERT_SIZEOF (l2fib_entry_key_t, 8)
 
 STATIC_ASSERT_SIZEOF (l2fib_entry_result_t, 8)
 
static u32 l2fib_compute_hash_bucket (l2fib_entry_key_t *key)
 Compute the hash for the given key and return the corresponding bucket index. More...
 
static u64 l2fib_make_key (u8 *mac_address, u16 bd_index)
 make address sanitizer skip this: The 6-Bytes mac-address is cast into an 8-Bytes u64, with 2 additional Bytes. More...
 
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. More...
 
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, u32 *bucket0, u32 *bucket1, 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. More...
 
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)
 
void l2fib_clear_table (void)
 
void l2fib_add_entry (u8 *mac, u32 bd_index, u32 sw_if_index, u8 static_mac, u8 drop_mac, u8 bvi_mac)
 Add an entry to the l2fib. More...
 
static void l2fib_add_fwd_entry (u8 *mac, u32 bd_index, u32 sw_if_index, u8 static_mac, u8 bvi_mac)
 
static void l2fib_add_filter_entry (u8 *mac, u32 bd_index)
 
u32 l2fib_del_entry (u8 *mac, u32 bd_index)
 Delete an entry from the l2fib. More...
 
void l2fib_start_ager_scan (vlib_main_t *vm)
 Kick off ager to scan MACs to age/delete MAC entries. More...
 
void l2fib_flush_int_mac (vlib_main_t *vm, u32 sw_if_index)
 Flush all non static MACs from an interface. More...
 
void l2fib_flush_bd_mac (vlib_main_t *vm, u32 bd_index)
 Flush all non static MACs in a bridge domain. More...
 
void l2fib_flush_all_mac (vlib_main_t *vm)
 Flush all non static MACs - flushes all valid BDs. More...
 
void l2fib_table_dump (u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
 
u8format_vnet_sw_if_index_name_with_NA (u8 *s, va_list *args)
 Format sw_if_index. More...
 
static_always_inline u8l2fib_swif_seq_num (u32 sw_if_index)
 
static_always_inline u8l2fib_valid_swif_seq_num (u32 sw_if_index)
 
 BVT (clib_bihash)*get_mac_table(void)
 

Variables

l2fib_main_t l2fib_main
 

Macro Definition Documentation

#define L2FIB_AGE_SCAN_INTERVAL   (60.0)

Definition at line 31 of file l2_fib.h.

#define L2FIB_EVENT_LEARN_LIMIT_DEFAULT   (1000)

Definition at line 40 of file l2_fib.h.

#define L2FIB_EVENT_MAX_MACS_DEFAULT   (100)

Definition at line 37 of file l2_fib.h.

#define L2FIB_EVENT_SCAN_DELAY_DEFAULT   (0.1)

Definition at line 34 of file l2_fib.h.

#define L2FIB_MEMORY_SIZE   (512<<20)

Definition at line 28 of file l2_fib.h.

#define L2FIB_NUM_BUCKETS   (64 * 1024)

Definition at line 27 of file l2_fib.h.

Enumeration Type Documentation

Enumerator
MAC_EVENT_ACTION_ADD 
MAC_EVENT_ACTION_DELETE 
MAC_EVENT_ACTION_MOVE 

Definition at line 134 of file l2_fib.h.

Function Documentation

BVT ( clib_bihash  )

Definition at line 931 of file l2_fib.c.

+ Here is the caller graph for this function:

u8* format_vnet_sw_if_index_name_with_NA ( u8 s,
va_list *  args 
)

Format sw_if_index.

If the value is ~0, use the text "N/A"

Definition at line 70 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void l2fib_add_entry ( u8 mac,
u32  bd_index,
u32  sw_if_index,
u8  static_mac,
u8  filter_mac,
u8  bvi_mac 
)

Add an entry to the l2fib.

If the entry already exists then overwrite it

Definition at line 356 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void l2fib_add_filter_entry ( u8 mac,
u32  bd_index 
)
inlinestatic

Definition at line 400 of file l2_fib.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void l2fib_add_fwd_entry ( u8 mac,
u32  bd_index,
u32  sw_if_index,
u8  static_mac,
u8  bvi_mac 
)
inlinestatic

Definition at line 393 of file l2_fib.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void l2fib_clear_table ( void  )

Definition at line 298 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 l2fib_compute_hash_bucket ( l2fib_entry_key_t key)
inlinestatic

Compute the hash for the given key and return the corresponding bucket index.

Definition at line 146 of file l2_fib.h.

u32 l2fib_del_entry ( u8 mac,
u32  bd_index 
)

Delete an entry from the l2fib.

Return 0 if the entry was deleted, or 1 if it was not found

Definition at line 671 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void l2fib_flush_all_mac ( vlib_main_t vm)

Flush all non static MACs - flushes all valid BDs.

Definition at line 789 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void l2fib_flush_bd_mac ( vlib_main_t vm,
u32  bd_index 
)

Flush all non static MACs in a bridge domain.

Definition at line 778 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void l2fib_flush_int_mac ( vlib_main_t vm,
u32  sw_if_index 
)

Flush all non static MACs from an interface.

Definition at line 768 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Cached_key and cached_result are used as a one-entry cache. The function reads and updates them as needed.

mac0 and bd_index0 are the keys. The entry is written to result0. If the entry was not found, result0 is set to ~0.

key0 and bucket0 return with the computed key and hash bucket, convenient if the entry needs to be updated afterward. If the cached_result was used, bucket0 is set to ~0.

Definition at line 209 of file l2_fib.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
u32 bucket0,
u32 bucket1,
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.

The lookups for the two packets are interleaved.

Cached_key and cached_result are used as a one-entry cache. The function reads and updates them as needed.

mac0 and bd_index0 are the keys. The entry is written to result0. If the entry was not found, result0 is set to ~0. The same holds for mac1/bd_index1/result1.

Definition at line 255 of file l2_fib.h.

+ Here is the call graph for this function:

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 
)

Definition at line 308 of file l2_fib.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u64 l2fib_make_key ( u8 mac_address,
u16  bd_index 
)
inlinestatic

make address sanitizer skip this: The 6-Bytes mac-address is cast into an 8-Bytes u64, with 2 additional Bytes.

l2fib_make_key() does read those two Bytes but does not use them.

Definition at line 166 of file l2_fib.h.

+ Here is the caller graph for this function:

void l2fib_start_ager_scan ( vlib_main_t vm)

Kick off ager to scan MACs to age/delete MAC entries.

Definition at line 745 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline u8* l2fib_swif_seq_num ( u32  sw_if_index)

Definition at line 422 of file l2_fib.h.

+ Here is the caller graph for this function:

void l2fib_table_dump ( u32  bd_index,
l2fib_entry_key_t **  l2fe_key,
l2fib_entry_result_t **  l2fe_res 
)

Definition at line 86 of file l2_fib.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline u8* l2fib_valid_swif_seq_num ( u32  sw_if_index)

Definition at line 429 of file l2_fib.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

STATIC_ASSERT_SIZEOF ( l2fib_entry_key_t  ,
 
)
STATIC_ASSERT_SIZEOF ( l2fib_entry_result_t  ,
 
)

Variable Documentation

l2fib_main_t l2fib_main

Definition at line 55 of file l2_fib.c.