48 #define foreach_ethernet_input_next \ 49 _ (PUNT, "error-punt") \ 50 _ (DROP, "error-drop") \ 55 #define _(s,n) ETHERNET_INPUT_NEXT_##s, 94 u16 * outer_id,
u16 * inner_id,
u32 * match_flags)
106 b0->
flags |= VNET_BUFFER_F_L2_HDR_OFFSET_VALID;
110 *type = clib_net_to_host_u16 (e0->
type);
121 *type = clib_net_to_host_u16 (e0[0]);
146 *outer_id = tag & 0xfff;
150 *type = clib_net_to_host_u16 (h0->
type);
155 if (*type == ETHERNET_TYPE_VLAN)
164 *inner_id = tag & 0xfff;
166 *type = clib_net_to_host_u16 (h0->
type);
170 if (*type == ETHERNET_TYPE_VLAN)
193 u32 * new_sw_if_index,
u8 * error0,
u32 * is_l2)
198 main_intf, vlan_intf, qinq_intf,
199 new_sw_if_index, error0, is_l2);
216 *error0 = ETHERNET_ERROR_L3_MAC_MISMATCH;
222 *error0 = (*new_sw_if_index) != ~0 ? (*error0) : ETHERNET_ERROR_DOWN;
235 *next0 = ETHERNET_INPUT_NEXT_DROP;
249 else if (type0 == ETHERNET_TYPE_IP4)
253 else if (type0 == ETHERNET_TYPE_IP6)
257 else if (type0 == ETHERNET_TYPE_MPLS)
283 *next0 = ETHERNET_INPUT_NEXT_LLC;
292 const __m128i ethertype_mask = _mm_set_epi16 (ETHERNET_TYPE_VLAN,
293 ETHERNET_TYPE_DOT1AD,
294 ETHERNET_TYPE_VLAN_9100,
295 ETHERNET_TYPE_VLAN_9200,
298 ETHERNET_TYPE_DOT1AD,
299 ETHERNET_TYPE_VLAN_9100,
300 ETHERNET_TYPE_VLAN_9200);
303 _mm_set_epi16 (type0, type0, type0, type0, type1, type1, type1, type1);
304 r = _mm_cmpeq_epi16 (ethertype_mask, r);
305 return !_mm_test_all_zeros (r, r);
320 u32 n_left_from, next_index, *from, *to_next;
321 u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
323 u32 cached_sw_if_index = ~0;
324 u32 cached_is_l2 = 0;
344 stats_n_packets = stats_n_bytes = 0;
346 while (n_left_from > 0)
352 while (n_left_from >= 4 && n_left_to_next >= 2)
356 u8 next0, next1, error0, error1;
357 u16 type0, orig_type0, type1, orig_type1;
358 u16 outer_id0, inner_id0, outer_id1, inner_id1;
359 u32 match_flags0, match_flags1;
360 u32 old_sw_if_index0, new_sw_if_index0, len0, old_sw_if_index1,
361 new_sw_if_index1, len1;
395 error0 = error1 = ETHERNET_ERROR_NONE;
397 type0 = clib_net_to_host_u16 (e0->
type);
399 type1 = clib_net_to_host_u16 (e1->
type);
407 u32 sw_if_index0, sw_if_index1;
411 is_l20 = cached_is_l2;
420 cached_sw_if_index = sw_if_index0;
433 b0->
flags |= VNET_BUFFER_F_L2_HDR_OFFSET_VALID |
434 VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
435 b1->
flags |= VNET_BUFFER_F_L2_HDR_OFFSET_VALID |
436 VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
450 error0 = ETHERNET_ERROR_L3_MAC_MISMATCH;
454 error1 = ETHERNET_ERROR_L3_MAC_MISMATCH;
470 &orig_type0, &outer_id0, &inner_id0, &match_flags0);
475 &orig_type1, &outer_id1, &inner_id1, &match_flags1);
487 &main_intf0, &vlan_intf0, &qinq_intf0);
496 &main_intf1, &vlan_intf1, &qinq_intf1);
503 qinq_intf0, &new_sw_if_index0, &error0, &is_l20);
510 qinq_intf1, &new_sw_if_index1, &error1, &is_l21);
515 ETHERNET_ERROR_NONE ? old_sw_if_index0 : new_sw_if_index0;
518 ETHERNET_ERROR_NONE ? old_sw_if_index1 : new_sw_if_index1;
521 if (((new_sw_if_index0 != ~0)
522 && (new_sw_if_index0 != old_sw_if_index0))
523 || ((new_sw_if_index1 != ~0)
524 && (new_sw_if_index1 != old_sw_if_index1)))
532 stats_n_packets += 2;
533 stats_n_bytes += len0 + len1;
536 (!(new_sw_if_index0 == stats_sw_if_index
537 && new_sw_if_index1 == stats_sw_if_index)))
539 stats_n_packets -= 2;
540 stats_n_bytes -= len0 + len1;
542 if (new_sw_if_index0 != old_sw_if_index0
543 && new_sw_if_index0 != ~0)
545 interface_main.combined_sw_if_counters
551 if (new_sw_if_index1 != old_sw_if_index1
552 && new_sw_if_index1 != ~0)
554 interface_main.combined_sw_if_counters
561 if (new_sw_if_index0 == new_sw_if_index1)
563 if (stats_n_packets > 0)
570 stats_n_packets, stats_n_bytes);
571 stats_n_packets = stats_n_bytes = 0;
573 stats_sw_if_index = new_sw_if_index0;
589 b0->
flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
590 b1->
flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
598 n_left_to_next, bi0, bi1, next0,
602 while (n_left_from > 0 && n_left_to_next > 0)
607 u16 type0, orig_type0;
608 u16 outer_id0, inner_id0;
610 u32 old_sw_if_index0, new_sw_if_index0, len0;
637 error0 = ETHERNET_ERROR_NONE;
639 type0 = clib_net_to_host_u16 (e0->
type);
650 is_l20 = cached_is_l2;
654 cached_sw_if_index = sw_if_index0;
664 b0->
flags |= VNET_BUFFER_F_L2_HDR_OFFSET_VALID |
665 VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
677 error0 = ETHERNET_ERROR_L3_MAC_MISMATCH;
689 &orig_type0, &outer_id0, &inner_id0, &match_flags0);
700 &main_intf0, &vlan_intf0, &qinq_intf0);
707 qinq_intf0, &new_sw_if_index0, &error0, &is_l20);
712 ETHERNET_ERROR_NONE ? old_sw_if_index0 : new_sw_if_index0;
723 if ((new_sw_if_index0 != ~0)
724 && (new_sw_if_index0 != old_sw_if_index0))
730 stats_n_packets += 1;
731 stats_n_bytes += len0;
737 stats_n_packets -= 1;
738 stats_n_bytes -= len0;
740 if (new_sw_if_index0 != ~0)
744 thread_index, new_sw_if_index0, 1, len0);
745 if (stats_n_packets > 0)
751 stats_sw_if_index, stats_n_packets, stats_n_bytes);
752 stats_n_packets = stats_n_bytes = 0;
754 stats_sw_if_index = new_sw_if_index0;
765 b0->
flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
772 to_next, n_left_to_next,
780 if (stats_n_packets > 0)
785 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
852 u32 p2pe_sw_if_index =
854 if (p2pe_sw_if_index == ~0)
1115 u32 sw_if_index,
u32 is_create)
1120 u32 unsupported = 0;
1164 #define ethernet_error(n,c,s) s, 1166 #undef ethernet_error 1172 .name =
"ethernet-input",
1174 .vector_size =
sizeof (
u32),
1179 #define _(s,n) [ETHERNET_INPUT_NEXT_##s] = n, 1196 .name =
"ethernet-input-type",
1198 .vector_size =
sizeof (
u32),
1201 #define _(s,n) [ETHERNET_INPUT_NEXT_##s] = n, 1215 .name =
"ethernet-input-not-l2",
1217 .vector_size =
sizeof (
u32),
1220 #define _(s,n) [ETHERNET_INPUT_NEXT_##s] = n, 1257 ETHERNET_INPUT_NEXT_DROP);
1259 ETHERNET_INPUT_NEXT_PUNT);
1281 u32 ethertype,
u32 next_index)
1309 if (ethertype == ETHERNET_TYPE_IP4)
1313 else if (ethertype == ETHERNET_TYPE_IP6)
1317 else if (ethertype == ETHERNET_TYPE_MPLS)
1330 __attribute__ ((unused))
vlan_table_t *invalid_vlan_table;
1331 __attribute__ ((unused))
qinq_table_t *invalid_qinq_table;
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static_always_inline void identify_subint(vnet_hw_interface_t *hi, vlib_buffer_t *b0, u32 match_flags, main_intf_t *main_intf, vlan_intf_t *vlan_intf, qinq_intf_t *qinq_intf, u32 *new_sw_if_index, u8 *error0, u32 *is_l2)
static_always_inline uword ethernet_input_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, ethernet_input_variant_t variant)
sll srl srl sll sra u16x4 i
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
u8 runtime_data[0]
Function dependent node-runtime data.
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
vnet_interface_main_t interface_main
vnet_p2p_sub_interface_t p2p
int vnet_hw_interface_rx_redirect_to_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
void ethernet_register_l2_input(vlib_main_t *vm, u32 node_index)
#define SUBINT_CONFIG_MATCH_0_TAG
#define ethernet_buffer_header_size(b)
Determine the size of the Ethernet headers of the current frame in the buffer.
static subint_config_t * ethernet_sw_interface_get_config(vnet_main_t *vnm, u32 sw_if_index, u32 *flags, u32 *unsupported)
struct _vlib_node_registration vlib_node_registration_t
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
subint_config_t inner_any_subint
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static clib_error_t * ethernet_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_create)
vlib_node_registration_t ethernet_input_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_node)
ethernet_main_t ethernet_main
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define static_always_inline
#define VLIB_INIT_FUNCTION(x)
static uword ethernet_address_cast(u8 *a)
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
vlib_combined_counter_main_t * combined_sw_if_counters
#define sparse_vec_validate(v, i)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
subint_config_t default_subint
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
#define vlib_call_init_function(vm, x)
static char * ethernet_error_strings[]
static_always_inline int ethernet_frame_is_any_tagged(u16 type0, u16 type1)
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
static clib_error_t * ethernet_input_init(vlib_main_t *vm)
subint_config_t single_tag_subint
u32 * sparse_index_by_input_next_index
static ethernet_type_info_t * ethernet_get_type_info(ethernet_main_t *em, ethernet_type_t type)
clib_error_t * ethernet_sw_interface_up_down(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static uword ethernet_input_not_l2(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static vlib_node_registration_t ethernet_input_type_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_type_node)
struct vnet_sub_interface_t::@180::@181::@183 flags
#define ethernet_buffer_set_vlan_count(b, v)
Sets the number of VLAN headers in the current Ethernet frame in the buffer.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
#define SUBINT_CONFIG_MATCH_3_TAG
vlib_error_t error
Error code for buffers to be enqueued to error handler.
vnet_hw_interface_class_t ethernet_hw_interface_class
u8 next_by_ethertype_register_called
subint_config_t untagged_subint
u32 p2p_ethernet_lookup(u32 parent_if_index, u8 *client_mac)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define SUBINT_CONFIG_VALID
struct vnet_sub_interface_t::@180 eth
qinq_intf_t vlans[ETHERNET_N_VLAN]
static_always_inline uword vlib_get_thread_index(void)
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(ethernet_sw_interface_add_del)
#define CLIB_PREFETCH(addr, size, type)
static uword ethernet_input_type(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
#define SUBINT_CONFIG_MATCH_1_TAG
static_always_inline void parse_header(ethernet_input_variant_t variant, vlib_buffer_t *b0, u16 *type, u16 *orig_type, u16 *outer_id, u16 *inner_id, u32 *match_flags)
static void eth_vlan_table_lookups(ethernet_main_t *em, vnet_main_t *vnm, u32 port_sw_if_index0, u16 first_ethertype, u16 outer_id, u16 inner_id, vnet_hw_interface_t **hi, main_intf_t **main_intf, vlan_intf_t **vlan_intf, qinq_intf_t **qinq_intf)
static uword sparse_vec_index(void *v, uword sparse_index)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static u32 eth_identify_subint(vnet_hw_interface_t *hi, vlib_buffer_t *b0, u32 match_flags, main_intf_t *main_intf, vlan_intf_t *vlan_intf, qinq_intf_t *qinq_intf, u32 *new_sw_if_index, u8 *error0, u32 *is_l2)
u8 * format_ethernet_header(u8 *s, va_list *args)
void ethernet_register_l3_redirect(vlib_main_t *vm, u32 node_index)
void ethernet_sw_interface_set_l2_mode_noport(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
static_always_inline int ethernet_frame_is_tagged(u16 type)
static_always_inline void determine_next_node(ethernet_main_t *em, ethernet_input_variant_t variant, u32 is_l20, u32 type0, vlib_buffer_t *b0, u8 *error0, u8 *next0)
void ethernet_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
#define clib_error_report(e)
static u8 * format_ethernet_input_trace(u8 *s, va_list *va)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define VLIB_NODE_FLAG_TRACE
vlan_intf_t vlans[ETHERNET_N_VLAN]
#define SUBINT_CONFIG_MATCH_2_TAG
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
#define vec_elt(v, i)
Get vector value at index i.
static vlib_node_registration_t ethernet_input_not_l2_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_not_l2_node)
#define foreach_ethernet_input_next
void vlib_trace_frame_buffers_only(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, uword n_buffers, uword next_buffer_stride, uword n_buffer_data_bytes_in_trace)
#define SUBINT_CONFIG_P2P
void l2bvi_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(ethernet_sw_interface_up_down)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static clib_error_t * ethernet_init(vlib_main_t *vm)
void ethernet_sw_interface_set_l2_mode(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
static uword ethernet_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define VLIB_REGISTER_NODE(x,...)
p2p_ethernet_main_t p2p_main
vnet_sw_interface_type_t type
static u32 eth_mac_equal(u8 *mac1, u8 *mac2)
u16 flags
Copy of main node flags.
next_by_ethertype_t l3_next
subint_config_t * p2p_subif_pool
#define CLIB_CACHE_LINE_BYTES
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
VLIB_NODE_FUNCTION_MULTIARCH(ethernet_input_not_l2_node, ethernet_input_not_l2)
static void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)
#define SPARSE_VEC_INVALID_INDEX