40 #ifndef included_ethernet_h 41 #define included_ethernet_h 49 {
return (((
u64) a[0] << (
u64) (5*8))
50 | ((
u64) a[1] << (
u64) (4*8))
51 | ((
u64) a[2] << (
u64) (3*8))
52 | ((
u64) a[3] << (
u64) (2*8))
53 | ((
u64) a[4] << (
u64) (1*8))
54 | ((
u64) a[5] << (
u64) (0*8))); }
58 return (a & (1ULL<<(5*8))) != 0;
74 #define ETHERNET_MIN_PACKET_BYTES 64 75 #define ETHERNET_MAX_PACKET_BYTES 9216 81 #define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL (1 << 0) 82 #define ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC(flags) \ 83 (((flags) & ~ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) == 0) 86 #define ETHERNET_INTERFACE_FLAG_MTU (1 << 1) 87 #define ETHERNET_INTERFACE_FLAG_CONFIG_MTU(flags) \ 88 ((flags) & ETHERNET_INTERFACE_FLAG_MTU) 116 #define ethernet_error(n,c,s) ETHERNET_ERROR_##n, 118 #undef ethernet_error 131 #define SUBINT_CONFIG_MATCH_0_TAG (1<<0) 132 #define SUBINT_CONFIG_MATCH_1_TAG (1<<1) 133 #define SUBINT_CONFIG_MATCH_2_TAG (1<<2) 134 #define SUBINT_CONFIG_MATCH_3_TAG (1<<3) 135 #define SUBINT_CONFIG_VALID (1<<4) 136 #define SUBINT_CONFIG_L2 (1<<5) 243 u32 * hw_if_index_return,
308 +
vnet_buffer (b)->ethernet.start_of_ethernet_header);
315 #define ethernet_buffer_get_vlan_count(b) ( \ 316 ((b)->flags & ETH_BUFFER_VLAN_BITS) >> LOG2_ETH_BUFFER_VLAN_1_DEEP \ 323 #define ethernet_buffer_set_vlan_count(b, v) ( \ 324 (b)->flags = ((b)->flags & ~ETH_BUFFER_VLAN_BITS) | \ 325 (((v) << LOG2_ETH_BUFFER_VLAN_1_DEEP) & ETH_BUFFER_VLAN_BITS) \ 329 #define ethernet_buffer_adjust_vlan_count(b, v) ( \ 330 ethernet_buffer_set_vlan_count(b, \ 331 (word)ethernet_buffer_get_vlan_count(b) + (word)(v)) \ 335 #define ethernet_buffer_adjust_vlan_count_by_bytes(b, v) ( \ 336 (b)->flags = ((b)->flags & ~ETH_BUFFER_VLAN_BITS) | (( \ 337 ((b)->flags & ETH_BUFFER_VLAN_BITS) + \ 338 ((v) << (LOG2_ETH_BUFFER_VLAN_1_DEEP - 2)) \ 339 ) & ETH_BUFFER_VLAN_BITS) \ 350 #define ethernet_buffer_header_size(b) ( \ 351 ethernet_buffer_get_vlan_count((b)) * sizeof(ethernet_vlan_header_t) + \ 352 sizeof(ethernet_header_t) \ 370 u32 sw_if_index,
u32 fib_index,
389 u32 port_sw_if_index0,
412 vlan_table_id = (first_ethertype == ETHERNET_TYPE_DOT1AD) ?
413 (*main_intf)->dot1ad_vlans :
414 (*main_intf)->dot1q_vlans;
416 *vlan_intf = &vlan_table->
vlans[outer_id];
419 *qinq_intf = &qinq_table->
vlans[inner_id];
434 u32 * new_sw_if_index,
444 subint = &qinq_intf->
subint;
445 if ((subint->
flags & match_flags) == match_flags)
goto matched;
449 if ((subint->
flags & match_flags) == match_flags)
goto matched;
453 if ((subint->
flags & match_flags) == match_flags)
goto matched;
457 if ((subint->
flags & match_flags) == match_flags)
goto matched;
461 if ((subint->
flags & match_flags) == match_flags)
goto matched;
464 *new_sw_if_index = ~0;
465 *error0 = ETHERNET_ERROR_UNKNOWN_VLAN;
478 return (*((
u32 *)(mac1+0)) == *((
u32 *)(mac2+0)) &&
479 *((
u32 *)(mac1+2)) == *((
u32 *)(mac2+2)));
497 void * data_callback,
502 uword data,
int is_add);
always_inline u32 eth_mac_equal(u8 *mac1, u8 *mac2)
uword unformat_ethernet_type_net_byte_order(unformat_input_t *input, va_list *args)
always_inline ethernet_type_info_t * ethernet_get_type_info(ethernet_main_t *em, ethernet_type_t type)
always_inline pg_node_t * pg_get_node(uword node_index)
uword unformat_pg_ethernet_header(unformat_input_t *input, va_list *args)
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
always_inline void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
int vnet_arp_set_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, u32 fib_index, void *a_arg, int is_static)
struct _vlib_node_registration vlib_node_registration_t
int vnet_add_del_ip4_arp_change_event(vnet_main_t *vnm, void *data_callback, u32 pid, void *address_arg, uword node_index, uword type_opaque, uword data, int is_add)
subint_config_t inner_any_subint
vlib_node_registration_t ethernet_input_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_node)
always_inline ethernet_main_t * vnet_get_ethernet_main(void)
void ethernet_register_l3_redirect(vlib_main_t *vm, u32 node_index)
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address)
ethernet_main_t ethernet_main
u8 * format_ethernet_address(u8 *s, va_list *args)
subint_config_t default_subint
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void ethernet_sw_interface_set_l2_mode_noport(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
int format_ethernet_address_16bit
ethernet_flag_change_function_t * flag_change
always_inline ethernet_header_t * ethernet_buffer_get_header(vlib_buffer_t *b)
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
subint_config_t single_tag_subint
u32 * sparse_index_by_input_next_index
format_function_t * format_buffer
vnet_hw_interface_class_t ethernet_hw_interface_class
u8 next_by_ethertype_register_called
subint_config_t untagged_subint
u8 * format_ethernet_type(u8 *s, va_list *args)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define SUBINT_CONFIG_VALID
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
void vnet_register_ip4_arp_resolution_event(vnet_main_t *vnm, void *address_arg, uword node_index, uword type_opaque, uword data)
qinq_intf_t vlans[ETHERNET_N_VLAN]
int vnet_delete_loopback_interface(u32 sw_if_index)
void ethernet_register_l2_input(vlib_main_t *vm, u32 node_index)
unformat_function_t * unformat_buffer
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
always_inline 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)
unformat_function_t * unformat_edit
u32 vnet_arp_glean_add(u32 fib_index, void *next_hop_arg)
static int ethernet_mac_address_is_multicast_u64(u64 a)
always_inline u64 ethernet_mac_address_u64(u8 *a)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
u8 * format_ethernet_header(u8 *s, va_list *args)
u32( ethernet_flag_change_function_t)(vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
vlan_intf_t vlans[ETHERNET_N_VLAN]
void ethernet_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
uword * type_info_by_type
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
void ethernet_sw_interface_set_l2_mode(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
uword unformat_ethernet_type_host_byte_order(unformat_input_t *input, va_list *args)
struct _vnet_hw_interface_class vnet_hw_interface_class_t
struct ethernet_interface ethernet_interface_t
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
always_inline 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)
int vnet_proxy_arp_fib_reset(u32 fib_id)
next_by_ethertype_t l3_next
always_inline u32 eth_create_valid_subint_match_flags(u32 num_tags)
ethernet_interface_t * interfaces
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
ethernet_type_info_t * type_infos
int vnet_arp_unset_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, u32 fib_index, void *a_arg)