48 BVT (clib_bihash) * mac_table;
54 u32 feat_next_node_index[32];
78 s =
format (s,
"l2-fwd: sw_if_index %d dst %U src %U bd_index %d",
85 #ifndef CLIB_MARCH_VARIANT 93 #define foreach_l2fwd_error \ 94 _(L2FWD, "L2 forward packets") \ 95 _(FLOOD, "L2 forward misses") \ 96 _(HIT, "L2 forward hits") \ 97 _(BVI_BAD_MAC, "BVI L3 MAC mismatch") \ 98 _(BVI_ETHERTYPE, "BVI packet with unhandled ethertype") \ 99 _(FILTER_DROP, "Filter Mac Drop") \ 100 _(REFLECT_DROP, "Reflection Drop") \ 101 _(STALE_DROP, "Stale entry Drop") 105 #define _(sym,str) L2FWD_ERROR_##sym, 112 #define _(sym,string) string, 134 int try_flood = result0->
raw == ~0;
139 flood_error = L2FWD_ERROR_FLOOD;
145 em->
counters[node_counter_base_index + L2FWD_ERROR_HIT] += 1;
150 int l2fib_seq_num_valid = 1;
153 if (!l2fib_entry_result_is_set_AGE_NOT (result0))
160 l2fib_seq_num_valid =
166 flood_error = L2FWD_ERROR_STALE_DROP;
172 b0->
error = node->
errors[L2FWD_ERROR_REFLECT_DROP];
176 else if (
PREDICT_FALSE (l2fib_entry_result_is_set_FILTER (result0)))
182 else if (
PREDICT_FALSE (l2fib_entry_result_is_set_BVI (result0)))
189 &msm->l3_next, next0);
200 b0->
error = node->
errors[L2FWD_ERROR_BVI_ETHERTYPE];
215 (L2INPUT_FEAT_UU_FLOOD | L2INPUT_FEAT_UU_FWD))
246 cached_result.
raw = ~0;
256 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
260 u32 bucket0, bucket1, bucket2, bucket3;
288 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
296 if (b[1]->
flags & VLIB_BUFFER_IS_TRACED)
304 if (b[2]->
flags & VLIB_BUFFER_IS_TRACED)
312 if (b[3]->
flags & VLIB_BUFFER_IS_TRACED)
323 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
346 l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
347 l2fwd_process (vm, node, msm, em, b[1], sw_if_index1, &result1,
349 l2fwd_process (vm, node, msm, em, b[2], sw_if_index2, &result2,
351 l2fwd_process (vm, node, msm, em, b[3], sw_if_index3, &result3,
384 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
389 l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
413 .vector_size =
sizeof (
u32),
430 #ifndef CLIB_MARCH_VARIANT 444 mp->feat_next_node_index);
447 mp->mac_table = get_mac_table ();
525 .path =
"set interface l2 forward",
526 .short_help =
"set interface l2 forward <interface> [disable]",
#define TO_BVI_ERR_BAD_MAC
vnet_main_t * vnet_get_main(void)
#define TO_BVI_ERR_ETHERTYPE
clib_error_t * l2fwd_init(vlib_main_t *vm)
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
static vlib_node_registration_t l2fwd_node
(constructor) VLIB_REGISTER_NODE (l2fwd_node)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static u32 vnet_l2_feature_next(vlib_buffer_t *b, u32 *next_nodes, u32 feat_bit)
Return the graph node index for the feature corresponding to the next set bit after clearing the curr...
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(x)
struct l2fib_entry_result_t_::@243::@245 fields
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
static clib_error_t * int_fwd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface forward enable/disable.
vlib_error_main_t error_main
void l2fwd_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
Add the L3 input node for this ethertype to the next nodes structure.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static char * l2fwd_error_strings[]
static u8 * format_l2fwd_trace(u8 *s, va_list *args)
static_always_inline void l2fwd_process(vlib_main_t *vm, vlib_node_runtime_t *node, l2fwd_main_t *msm, vlib_error_main_t *em, vlib_buffer_t *b0, u32 sw_if_index0, l2fib_entry_result_t *result0, u16 *next0)
Forward one packet based on the mac table lookup result.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static_always_inline uword l2fwd_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
#define VLIB_REGISTER_NODE(x,...)
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
static void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
Initialize the feature next-node indexes of a graph node.
#define clib_memcpy(a, b, c)
#define VLIB_CLI_COMMAND(x,...)
#define foreach_l2fwd_error
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
struct _vlib_node_registration vlib_node_registration_t
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by 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, u32 *bucket0, l2fib_entry_result_t *result0)
Lookup the entry for mac and bd_index in the mac table for 1 packet.
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
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, 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)
#define CLIB_CACHE_LINE_BYTES
static_always_inline u32 l2_to_bvi(vlib_main_t *vlib_main, vnet_main_t *vnet_main, vlib_buffer_t *b0, u32 bvi_sw_if_index, next_by_ethertype_t *l3_next, u16 *next0)
Send a packet from L2 processing to L3 via the BVI interface.