|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
40 #ifndef included_ethernet_h
41 #define included_ethernet_h
52 #define ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX (1 << 0)
55 #define ETH_INPUT_FRAME_F_IP4_CKSUM_OK (1 << 1)
63 #ifdef CLIB_HAVE_VEC128
64 static const u16x8 tagged_ethertypes = {
65 (
u16) ETHERNET_TYPE_VLAN,
66 (
u16) ETHERNET_TYPE_DOT1AD,
67 (
u16) ETHERNET_TYPE_VLAN_9100,
68 (
u16) ETHERNET_TYPE_VLAN_9200,
70 (
u16) ETHERNET_TYPE_VLAN_9200,
71 (
u16) ETHERNET_TYPE_VLAN_9200,
72 (
u16) ETHERNET_TYPE_VLAN_9200,
73 (
u16) ETHERNET_TYPE_VLAN_9200
80 #ifdef CLIB_HAVE_VEC128
81 return !u16x8_is_all_zero (tagged_ethertypes == u16x8_splat (
type));
83 if ((
type == ETHERNET_TYPE_VLAN) ||
84 (
type == ETHERNET_TYPE_DOT1AD) ||
85 (
type == ETHERNET_TYPE_VLAN_9100) || (
type == ETHERNET_TYPE_VLAN_9200))
94 #ifdef CLIB_HAVE_VEC128
95 u16x8 r0 = (tagged_ethertypes == u16x8_splat (type0));
96 u16x8 r1 = (tagged_ethertypes == u16x8_splat (type1));
97 return !u16x8_is_all_zero (r0 | r1);
106 #ifdef CLIB_HAVE_VEC128
107 u16x8 r0 = (tagged_ethertypes == u16x8_splat (type0));
108 u16x8 r1 = (tagged_ethertypes == u16x8_splat (type1));
109 u16x8 r2 = (tagged_ethertypes == u16x8_splat (type2));
110 u16x8 r3 = (tagged_ethertypes == u16x8_splat (type3));
111 return !u16x8_is_all_zero (r0 | r1 | r2 | r3);
132 #define ETHERNET_MIN_PACKET_BYTES 64
133 #define ETHERNET_MAX_PACKET_BYTES 9216
152 #define ETHERNET_INTERFACE_FLAGS_STATUS_MASK (0xffff0000)
153 #define ETHERNET_INTERFACE_FLAGS_SET_OPN_MASK (0x0000ffff)
157 #define ETHERNET_INTERFACE_FLAG_STATUS_L3 (1 << 16)
160 #define ETHERNET_INTERFACE_FLAG_DEFAULT_L3 0
163 #define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL 1
166 #define ETHERNET_INTERFACE_FLAG_MTU 2
199 #define ethernet_error(n,c,s) ETHERNET_ERROR_##n,
201 #undef ethernet_error
215 #define SUBINT_CONFIG_MATCH_0_TAG (1<<0)
216 #define SUBINT_CONFIG_MATCH_1_TAG (1<<1)
217 #define SUBINT_CONFIG_MATCH_2_TAG (1<<2)
218 #define SUBINT_CONFIG_MATCH_3_TAG (1<<3)
219 #define SUBINT_CONFIG_VALID (1<<4)
220 #define SUBINT_CONFIG_L2 (1<<5)
221 #define SUBINT_CONFIG_P2P (1<<6)
361 u32 * hw_if_index_return,
428 #define ethernet_buffer_get_vlan_count(b) ( \
429 ((b)->flags & VNET_BUFFER_FLAGS_VLAN_BITS) >> VNET_BUFFER_F_LOG2_VLAN_1_DEEP \
436 #define ethernet_buffer_set_vlan_count(b, v) ( \
437 (b)->flags = ((b)->flags & ~VNET_BUFFER_FLAGS_VLAN_BITS) | \
438 (((v) << VNET_BUFFER_F_LOG2_VLAN_1_DEEP) & VNET_BUFFER_FLAGS_VLAN_BITS) \
442 #define ethernet_buffer_adjust_vlan_count(b, v) ( \
443 ethernet_buffer_set_vlan_count(b, \
444 (word)ethernet_buffer_get_vlan_count(b) + (word)(v)) \
448 #define ethernet_buffer_adjust_vlan_count_by_bytes(b, v) ( \
449 (b)->flags = ((b)->flags & ~VNET_BUFFER_FLAGS_VLAN_BITS) | (( \
450 ((b)->flags & VNET_BUFFER_FLAGS_VLAN_BITS) + \
451 ((v) << (VNET_BUFFER_F_LOG2_VLAN_1_DEEP - 2)) \
452 ) & VNET_BUFFER_FLAGS_VLAN_BITS) \
463 #define ethernet_buffer_header_size(b) ( \
464 ethernet_buffer_get_vlan_count((b)) * sizeof(ethernet_vlan_header_t) + \
465 sizeof(ethernet_header_t) \
482 u8 is_specified,
u32 user_instance);
486 u16 outer_vlan_id,
u32 * sub_sw_if_index);
495 u32 port_sw_if_index0,
517 vlan_table_id = (first_ethertype == ETHERNET_TYPE_DOT1AD) ?
518 (*main_intf)->dot1ad_vlans : (*main_intf)->dot1q_vlans;
520 *vlan_intf = &vlan_table->
vlans[outer_id];
523 *qinq_intf = &qinq_table->
vlans[inner_id];
537 u32 * new_sw_if_index,
u8 * error0,
u32 * is_l2)
545 subint = &qinq_intf->
subint;
546 if ((subint->
flags & match_flags) == match_flags)
551 if ((subint->
flags & match_flags) == match_flags)
556 if ((subint->
flags & match_flags) == match_flags)
561 if ((subint->
flags & match_flags) == match_flags)
566 if ((subint->
flags & match_flags) == match_flags)
570 *new_sw_if_index = ~0;
571 *error0 = ETHERNET_ERROR_UNKNOWN_VLAN;
u32() ethernet_flag_change_function_t(vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)
vlan_intf_t vlans[ETHERNET_N_VLAN]
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
uword unformat_ethernet_type_net_byte_order(unformat_input_t *input, va_list *args)
void ethernet_register_l2_input(vlib_main_t *vm, u32 node_index)
vnet_interface_main_t * im
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
ethernet_type_info_t * type_infos
static u32 eth_identify_subint(vnet_hw_interface_t *hi, 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)
int format_ethernet_address_16bit
u8 next_by_ethertype_register_called
u8 * ethernet_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
build a rewrite string to use for sending packets of type 'link_type' to 'dst_address'
nat44_ei_hairpin_src_next_t next_index
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
void ethernet_sw_interface_set_l2_mode(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
static_always_inline int ethernet_frame_is_tagged(u16 type)
int vnet_create_sub_interface(u32 sw_if_index, u32 id, u32 flags, u16 inner_vlan_id, u16 outer_vlan_id, u32 *sub_sw_if_index)
u8 * format_ethernet_address(u8 *s, va_list *args)
mac_address_t * ethernet_interface_add_del_address(ethernet_main_t *em, u32 hw_if_index, const u8 *address, u8 is_add)
static_always_inline int ethernet_frame_is_any_tagged_x2(u16 type0, u16 type1)
u8 * format_ethernet_header(u8 *s, va_list *args)
static u32 eth_create_valid_subint_match_flags(u32 num_tags)
union ethernet_interface_address ethernet_interface_address_t
void ethernet_input_init(vlib_main_t *vm, ethernet_main_t *em)
vlib_node_registration_t ethernet_input_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_node)
vnet_hw_interface_class_t ethernet_hw_interface_class
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
qinq_intf_t vlans[ETHERNET_N_VLAN]
uword * type_info_by_name
u8 output_feature_arc_index
unformat_function_t * unformat_buffer
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
subint_config_t untagged_subint
u8 * format_mac_address(u8 *s, va_list *args)
subint_config_t inner_any_subint
static ethernet_main_t * vnet_get_ethernet_main(void)
subint_config_t single_tag_subint
ethernet_interface_t * interfaces
format_function_t * format_buffer
next_by_ethertype_t l3_next
uword unformat_ethernet_type_host_byte_order(unformat_input_t *input, va_list *args)
u8 * format_ethernet_vlan_tci(u8 *s, va_list *va)
u32 default_mtu
Default interface MTU.
unformat_function_t * unformat_edit
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address, u8 is_specified, u32 user_instance)
#define static_always_inline
static pg_node_t * pg_get_node(uword node_index)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
manual_print typedef address
subint_config_t default_subint
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
ethernet_address_change_ctx_t * address_change_callbacks
Functions to call when interface hw address changes.
struct _vlib_node_registration vlib_node_registration_t
uword * type_info_by_type
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
u8 * format_ethernet_type(u8 *s, va_list *args)
u32 * sparse_index_by_input_next_index
uword * bm_loopback_instances
int vnet_delete_loopback_interface(u32 sw_if_index)
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)
ethernet_main_t ethernet_main
void ethernet_register_l3_redirect(vlib_main_t *vm, u32 node_index)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define SUBINT_CONFIG_VALID
uword unformat_pg_ethernet_header(unformat_input_t *input, va_list *args)
static ethernet_type_info_t * ethernet_get_type_info(ethernet_main_t *em, ethernet_type_t type)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static_always_inline int ethernet_frame_is_any_tagged_x4(u16 type0, u16 type1, u16 type2, u16 type3)
static ethernet_header_t * ethernet_buffer_get_header(vlib_buffer_t *b)
struct ethernet_main_t_ ethernet_main_t
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
void() ethernet_address_change_function_t(struct ethernet_main_t_ *im, u32 sw_if_index, uword opaque)
ethernet_flag_change_function_t * flag_change
void ethernet_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
vl_api_interface_index_t sw_if_index
ethernet_interface_address_t * secondary_addrs
void ethernet_sw_interface_set_l2_mode_noport(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
ethernet_interface_address_t address
uword unformat_mac_address(unformat_input_t *input, va_list *args)
struct _vnet_hw_interface_class vnet_hw_interface_class_t
vl_api_fib_path_type_t type
void ethernet_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
int vnet_delete_sub_interface(u32 sw_if_index)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
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)
struct ethernet_interface ethernet_interface_t
VLIB buffer representation.
manual_print typedef u8 mac_address[6]
vl_api_wireguard_peer_flags_t flags