FD.io VPP  v21.10.1-2-g0a485f517
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_entry_result_t_
 

Macros

#define L2FIB_NUM_BUCKETS   (256 * 1024)
 
#define L2FIB_MEMORY_SIZE   (128<<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)
 
#define foreach_l2fib_entry_result_attr
 Flags associated with an L2 Fib Entry. More...
 

Typedefs

typedef u16 l2fib_seq_num_t
 A combined representation of the sequence number associated with the interface and the BD. More...
 
typedef enum l2fib_entry_result_flags_t_ l2fib_entry_result_flags_t
 
typedef struct l2fib_entry_result_t_ l2fib_entry_result_t
 

Enumerations

enum  l2fib_entry_result_flags_t_ { L2FIB_ENTRY_RESULT_FLAG_NONE = 0, foreach_l2fib_entry_result_attr }
 
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_always_inline l2fib_seq_num_t l2_fib_mk_seq_num (u8 bd_sn, u8 if_sn)
 
static_always_inline l2fib_seq_num_t l2_fib_update_seq_num (l2fib_seq_num_t sn, u8 if_sn)
 
void l2_fib_extract_seq_num (l2fib_seq_num_t sn, u8 *bd_sn, u8 *if_sn)
 
u8format_l2_fib_seq_num (u8 *s, va_list *a)
 
 STATIC_ASSERT_SIZEOF (l2fib_entry_result_flags_t, 1)
 
u8format_l2fib_entry_result_flags (u8 *s, va_list *args)
 
 STATIC_ASSERT_SIZEOF (l2fib_entry_result_t, 8)
 
static foreach_l2fib_entry_result_attr void l2fib_entry_result_set_bits (l2fib_entry_result_t *r, l2fib_entry_result_flags_t bits)
 
static void l2fib_entry_result_clear_bits (l2fib_entry_result_t *r, l2fib_entry_result_flags_t bits)
 
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 (const u8 *mac_address, u16 bd_index)
 
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. 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, 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, 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)
 
void l2fib_clear_table (void)
 
void l2fib_table_init (void)
 
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. More...
 
static void l2fib_add_filter_entry (const u8 *mac, u32 bd_index)
 
u32 l2fib_del_entry (const u8 *mac, u32 bd_index, u32 sw_if_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...
 
 BVT (clib_bihash) *get_mac_table(void)
 The table of adjacencies indexed by the rewrite string. More...
 

Variables

l2fib_main_t l2fib_main
 

Macro Definition Documentation

◆ foreach_l2fib_entry_result_attr

#define foreach_l2fib_entry_result_attr
Value:
_(STATIC, 0, "static") \
_(AGE_NOT, 1, "age-not") \
_(BVI, 2, "bvi") \
_(FILTER, 3, "filter") \
_(LRN_EVT, 4, "learn-event") \
_(LRN_MOV, 5, "learn-move")

Flags associated with an L2 Fib Entry.

  • static mac, no MAC move
  • not subject to age
  • mac is for a bridged virtual interface
  • drop packets to/from this mac
  • MAC learned to be sent in L2 MAC event -MAC learned is a MAC move

Definition at line 137 of file l2_fib.h.

◆ L2FIB_AGE_SCAN_INTERVAL

#define L2FIB_AGE_SCAN_INTERVAL   (60.0)

Definition at line 31 of file l2_fib.h.

◆ L2FIB_EVENT_LEARN_LIMIT_DEFAULT

#define L2FIB_EVENT_LEARN_LIMIT_DEFAULT   (1000)

Definition at line 40 of file l2_fib.h.

◆ L2FIB_EVENT_MAX_MACS_DEFAULT

#define L2FIB_EVENT_MAX_MACS_DEFAULT   (100)

Definition at line 37 of file l2_fib.h.

◆ L2FIB_EVENT_SCAN_DELAY_DEFAULT

#define L2FIB_EVENT_SCAN_DELAY_DEFAULT   (0.1)

Definition at line 34 of file l2_fib.h.

◆ L2FIB_MEMORY_SIZE

#define L2FIB_MEMORY_SIZE   (128<<20)

Definition at line 28 of file l2_fib.h.

◆ L2FIB_NUM_BUCKETS

#define L2FIB_NUM_BUCKETS   (256 * 1024)

Definition at line 27 of file l2_fib.h.

Typedef Documentation

◆ l2fib_entry_result_flags_t

◆ l2fib_entry_result_t

◆ l2fib_seq_num_t

A combined representation of the sequence number associated with the interface and the BD.

The BD is in higher bits, the interface in the lower bits, but the order is not important.

It's convenient to represent this as an union of two u8s, but then in the DP one is forced to do short writes, followed by long reads, which is a sure thing for a stall

Definition at line 107 of file l2_fib.h.

Enumeration Type Documentation

◆ l2_mac_event_action_t

Enumerator
MAC_EVENT_ACTION_ADD 
MAC_EVENT_ACTION_DELETE 
MAC_EVENT_ACTION_MOVE 

Definition at line 214 of file l2_fib.h.

◆ l2fib_entry_result_flags_t_

Enumerator
L2FIB_ENTRY_RESULT_FLAG_NONE 
foreach_l2fib_entry_result_attr 

Definition at line 145 of file l2_fib.h.

Function Documentation

◆ BVT()

BVT ( clib_bihash  )

The table of adjacencies indexed by the rewrite string.

Definition at line 1065 of file l2_fib.c.

+ Here is the caller graph for this function:

◆ format_l2_fib_seq_num()

u8* format_l2_fib_seq_num ( u8 s,
va_list *  a 
)

Definition at line 153 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_l2fib_entry_result_flags()

u8* format_l2fib_entry_result_flags ( u8 s,
va_list *  args 
)

Definition at line 53 of file l2_fib.c.

+ Here is the caller graph for this function:

◆ format_vnet_sw_if_index_name_with_NA()

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 86 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2_fib_extract_seq_num()

void l2_fib_extract_seq_num ( l2fib_seq_num_t  sn,
u8 bd_sn,
u8 if_sn 
)

Definition at line 146 of file l2_fib.c.

+ Here is the caller graph for this function:

◆ l2_fib_mk_seq_num()

static_always_inline l2fib_seq_num_t l2_fib_mk_seq_num ( u8  bd_sn,
u8  if_sn 
)

Definition at line 110 of file l2_fib.h.

+ Here is the caller graph for this function:

◆ l2_fib_update_seq_num()

static_always_inline l2fib_seq_num_t l2_fib_update_seq_num ( l2fib_seq_num_t  sn,
u8  if_sn 
)

Definition at line 116 of file l2_fib.h.

+ Here is the caller graph for this function:

◆ l2fib_add_entry()

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.

If the entry already exists then overwrite it

Definition at line 441 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_add_filter_entry()

static void l2fib_add_filter_entry ( const u8 mac,
u32  bd_index 
)
inlinestatic

Definition at line 453 of file l2_fib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_clear_table()

void l2fib_clear_table ( void  )

Definition at line 379 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_compute_hash_bucket()

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 226 of file l2_fib.h.

◆ l2fib_del_entry()

u32 l2fib_del_entry ( const u8 mac,
u32  bd_index,
u32  sw_if_index 
)

Delete an entry from the l2fib.

Return 0 if the entry was deleted, or 1 it was not found or if sw_if_index is non-zero and does not match that in the entry.

Definition at line 742 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_entry_result_clear_bits()

static void l2fib_entry_result_clear_bits ( l2fib_entry_result_t r,
l2fib_entry_result_flags_t  bits 
)
inlinestatic

Definition at line 207 of file l2_fib.h.

+ Here is the caller graph for this function:

◆ l2fib_entry_result_set_bits()

static foreach_l2fib_entry_result_attr void l2fib_entry_result_set_bits ( l2fib_entry_result_t r,
l2fib_entry_result_flags_t  bits 
)
inlinestatic

Definition at line 200 of file l2_fib.h.

+ Here is the caller graph for this function:

◆ l2fib_flush_all_mac()

void l2fib_flush_all_mac ( vlib_main_t vm)

Flush all non static MACs - flushes all valid BDs.

Definition at line 922 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_flush_bd_mac()

void l2fib_flush_bd_mac ( vlib_main_t vm,
u32  bd_index 
)

Flush all non static MACs in a bridge domain.

Definition at line 911 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_flush_int_mac()

void l2fib_flush_int_mac ( vlib_main_t vm,
u32  sw_if_index 
)

Flush all non static MACs from an interface.

Definition at line 901 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_lookup_1()

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.

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 return with the computed key, convenient if the entry needs, to be updated afterward.

Definition at line 283 of file l2_fib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_lookup_2()

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.

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 327 of file l2_fib.h.

+ Here is the call graph for this function:

◆ l2fib_lookup_4()

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 
)

Definition at line 375 of file l2_fib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_make_key()

static u64 l2fib_make_key ( const u8 mac_address,
u16  bd_index 
)
inlinestatic

Definition at line 241 of file l2_fib.h.

+ Here is the caller graph for this function:

◆ l2fib_start_ager_scan()

void l2fib_start_ager_scan ( vlib_main_t vm)

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

Definition at line 878 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_table_dump()

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

Definition at line 129 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_table_init()

void l2fib_table_init ( void  )

Definition at line 365 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ STATIC_ASSERT_SIZEOF() [1/3]

STATIC_ASSERT_SIZEOF ( l2fib_entry_key_t  ,
 
)

◆ STATIC_ASSERT_SIZEOF() [2/3]

STATIC_ASSERT_SIZEOF ( l2fib_entry_result_flags_t  ,
 
)

◆ STATIC_ASSERT_SIZEOF() [3/3]

STATIC_ASSERT_SIZEOF ( l2fib_entry_result_t  ,
 
)

Variable Documentation

◆ l2fib_main

l2fib_main_t l2fib_main

Definition at line 50 of file l2_fib.c.