X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fethernet%2Fethernet.h;h=ece7aa582177c76083a6c73c3783729fa2823025;hb=88076749e663e35925c2212eb79e2ec4ce023772;hp=dcc656a7dbb81428cd6f7efeb61f3e12b5945895;hpb=b3b2de71ceea0cc7ce18f89cc8180ed4a42e355d;p=vpp.git diff --git a/src/vnet/ethernet/ethernet.h b/src/vnet/ethernet/ethernet.h index dcc656a7dbb..ece7aa58217 100644 --- a/src/vnet/ethernet/ethernet.h +++ b/src/vnet/ethernet/ethernet.h @@ -46,7 +46,7 @@ #include always_inline u64 -ethernet_mac_address_u64 (u8 * a) +ethernet_mac_address_u64 (const u8 * a) { return (((u64) a[0] << (u64) (5 * 8)) | ((u64) a[1] << (u64) (4 * 8)) @@ -55,30 +55,49 @@ ethernet_mac_address_u64 (u8 * a) | ((u64) a[4] << (u64) (1 * 8)) | ((u64) a[5] << (u64) (0 * 8))); } +always_inline void +ethernet_mac_address_from_u64 (u64 u, u8 * a) +{ + i8 ii; + + for (ii = 5; ii >= 0; ii--) + { + a[ii] = u & 0xFF; + u = u >> 8; + } +} + static inline int ethernet_mac_address_is_multicast_u64 (u64 a) { return (a & (1ULL << (5 * 8))) != 0; } +static inline int +ethernet_mac_address_is_zero (const u8 * mac) +{ + return ((*((u32 *) mac) == 0) && (*((u16 *) (mac + 4)) == 0)); +} + +#ifdef CLIB_HAVE_VEC128 +static const u16x8 tagged_ethertypes = { + (u16) ETHERNET_TYPE_VLAN, + (u16) ETHERNET_TYPE_DOT1AD, + (u16) ETHERNET_TYPE_VLAN_9100, + (u16) ETHERNET_TYPE_VLAN_9200, + /* duplicate last one to fill register */ + (u16) ETHERNET_TYPE_VLAN_9200, + (u16) ETHERNET_TYPE_VLAN_9200, + (u16) ETHERNET_TYPE_VLAN_9200, + (u16) ETHERNET_TYPE_VLAN_9200 +}; +#endif + static_always_inline int ethernet_frame_is_tagged (u16 type) { -#if __SSE4_2__ - const __m128i ethertype_mask = _mm_set_epi16 (ETHERNET_TYPE_VLAN, - ETHERNET_TYPE_DOT1AD, - ETHERNET_TYPE_VLAN_9100, - ETHERNET_TYPE_VLAN_9200, - /* duplicate last one to - fill register */ - ETHERNET_TYPE_VLAN_9200, - ETHERNET_TYPE_VLAN_9200, - ETHERNET_TYPE_VLAN_9200, - ETHERNET_TYPE_VLAN_9200); - - __m128i r = _mm_set1_epi16 (type); - r = _mm_cmpeq_epi16 (ethertype_mask, r); - return !_mm_test_all_zeros (r, r); +#ifdef CLIB_HAVE_VEC128 + return !u16x8_is_all_zero (tagged_ethertypes == u16x8_splat (type)); #else if ((type == ETHERNET_TYPE_VLAN) || (type == ETHERNET_TYPE_DOT1AD) || @@ -88,6 +107,33 @@ ethernet_frame_is_tagged (u16 type) return 0; } +static_always_inline int +ethernet_frame_is_any_tagged_x2 (u16 type0, u16 type1) +{ +#ifdef CLIB_HAVE_VEC128 + u16x8 r0 = (tagged_ethertypes == u16x8_splat (type0)); + u16x8 r1 = (tagged_ethertypes == u16x8_splat (type1)); + return !u16x8_is_all_zero (r0 | r1); +#else + return ethernet_frame_is_tagged (type0) || ethernet_frame_is_tagged (type1); +#endif +} + +static_always_inline int +ethernet_frame_is_any_tagged_x4 (u16 type0, u16 type1, u16 type2, u16 type3) +{ +#ifdef CLIB_HAVE_VEC128 + u16x8 r0 = (tagged_ethertypes == u16x8_splat (type0)); + u16x8 r1 = (tagged_ethertypes == u16x8_splat (type1)); + u16x8 r2 = (tagged_ethertypes == u16x8_splat (type2)); + u16x8 r3 = (tagged_ethertypes == u16x8_splat (type3)); + return !u16x8_is_all_zero (r0 | r1 | r2 | r3); +#else + return ethernet_frame_is_tagged (type0) || ethernet_frame_is_tagged (type1) + || ethernet_frame_is_tagged (type2) || ethernet_frame_is_tagged (type3); +#endif +} + /* Max. sized ethernet/vlan header for parsing. */ typedef struct { @@ -169,6 +215,7 @@ typedef struct #define SUBINT_CONFIG_MATCH_3_TAG (1<<3) #define SUBINT_CONFIG_VALID (1<<4) #define SUBINT_CONFIG_L2 (1<<5) +#define SUBINT_CONFIG_P2P (1<<6) } subint_config_t; @@ -270,7 +317,7 @@ typedef struct uword *bm_loopback_instances; } ethernet_main_t; -ethernet_main_t ethernet_main; +extern ethernet_main_t ethernet_main; always_inline ethernet_type_info_t * ethernet_get_type_info (ethernet_main_t * em, ethernet_type_t type) @@ -304,6 +351,7 @@ void ethernet_register_l2_input (vlib_main_t * vm, u32 node_index); void ethernet_register_l3_redirect (vlib_main_t * vm, u32 node_index); /* Formats ethernet address X:X:X:X:X:X */ +u8 *format_mac_address (u8 * s, va_list * args); u8 *format_ethernet_address (u8 * s, va_list * args); u8 *format_ethernet_type (u8 * s, va_list * args); u8 *format_ethernet_vlan_tci (u8 * s, va_list * va); @@ -312,6 +360,7 @@ u8 *format_ethernet_header_with_length (u8 * s, va_list * args); /* Parse ethernet address in either X:X:X:X:X:X unix or X.X.X cisco format. */ uword unformat_ethernet_address (unformat_input_t * input, va_list * args); +uword unformat_mac_address (unformat_input_t * input, va_list * args); /* Parse ethernet type as 0xXXXX or type name from ethernet/types.def. In either host or network byte order. */ @@ -344,8 +393,7 @@ ethernet_setup_node (vlib_main_t * vm, u32 node_index) always_inline ethernet_header_t * ethernet_buffer_get_header (vlib_buffer_t * b) { - return (void *) - (b->data + vnet_buffer (b)->ethernet.start_of_ethernet_header); + return (void *) (b->data + vnet_buffer (b)->l2_hdr_offset); } /** Returns the number of VLAN headers in the current Ethernet frame in the @@ -353,7 +401,7 @@ ethernet_buffer_get_header (vlib_buffer_t * b) * the number of headers is not known. */ #define ethernet_buffer_get_vlan_count(b) ( \ - ((b)->flags & ETH_BUFFER_VLAN_BITS) >> LOG2_ETH_BUFFER_VLAN_1_DEEP \ + ((b)->flags & VNET_BUFFER_FLAGS_VLAN_BITS) >> VNET_BUFFER_F_LOG2_VLAN_1_DEEP \ ) /** Sets the number of VLAN headers in the current Ethernet frame in the @@ -361,8 +409,8 @@ ethernet_buffer_get_header (vlib_buffer_t * b) * the number of headers is not known. */ #define ethernet_buffer_set_vlan_count(b, v) ( \ - (b)->flags = ((b)->flags & ~ETH_BUFFER_VLAN_BITS) | \ - (((v) << LOG2_ETH_BUFFER_VLAN_1_DEEP) & ETH_BUFFER_VLAN_BITS) \ + (b)->flags = ((b)->flags & ~VNET_BUFFER_FLAGS_VLAN_BITS) | \ + (((v) << VNET_BUFFER_F_LOG2_VLAN_1_DEEP) & VNET_BUFFER_FLAGS_VLAN_BITS) \ ) /** Adjusts the vlan count by the delta in 'v' */ @@ -373,10 +421,10 @@ ethernet_buffer_get_header (vlib_buffer_t * b) /** Adjusts the vlan count by the header size byte delta in 'v' */ #define ethernet_buffer_adjust_vlan_count_by_bytes(b, v) ( \ - (b)->flags = ((b)->flags & ~ETH_BUFFER_VLAN_BITS) | (( \ - ((b)->flags & ETH_BUFFER_VLAN_BITS) + \ - ((v) << (LOG2_ETH_BUFFER_VLAN_1_DEEP - 2)) \ - ) & ETH_BUFFER_VLAN_BITS) \ + (b)->flags = ((b)->flags & ~VNET_BUFFER_FLAGS_VLAN_BITS) | (( \ + ((b)->flags & VNET_BUFFER_FLAGS_VLAN_BITS) + \ + ((v) << (VNET_BUFFER_F_LOG2_VLAN_1_DEEP - 2)) \ + ) & VNET_BUFFER_FLAGS_VLAN_BITS) \ ) /** @@ -401,17 +449,6 @@ void ethernet_sw_interface_set_l2_mode_noport (vnet_main_t * vnm, void ethernet_set_rx_redirect (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 enable); -int -vnet_arp_set_ip4_over_ethernet (vnet_main_t * vnm, - u32 sw_if_index, void *a_arg, - int is_static, int is_no_fib_entry); - -int -vnet_arp_unset_ip4_over_ethernet (vnet_main_t * vnm, - u32 sw_if_index, void *a_arg); - -int vnet_proxy_arp_fib_reset (u32 fib_id); - clib_error_t *next_by_ethertype_init (next_by_ethertype_t * l3_next); clib_error_t *next_by_ethertype_register (next_by_ethertype_t * l3_next, u32 ethertype, u32 next_index); @@ -492,13 +529,13 @@ eth_identify_subint (vnet_hw_interface_t * hi, if ((subint->flags & match_flags) == match_flags) goto matched; - // check for untagged interface - subint = &main_intf->untagged_subint; + // check for default interface + subint = &main_intf->default_subint; if ((subint->flags & match_flags) == match_flags) goto matched; - // check for default interface - subint = &main_intf->default_subint; + // check for untagged interface + subint = &main_intf->untagged_subint; if ((subint->flags & match_flags) == match_flags) goto matched; @@ -516,7 +553,7 @@ matched: // Compare two ethernet macs. Return 1 if they are the same, 0 if different always_inline u32 -eth_mac_equal (u8 * mac1, u8 * mac2) +eth_mac_equal (const u8 * mac1, const u8 * mac2) { return (*((u32 *) (mac1 + 0)) == *((u32 *) (mac2 + 0)) && *((u32 *) (mac1 + 2)) == *((u32 *) (mac2 + 2))); @@ -543,6 +580,8 @@ int vnet_add_del_ip4_arp_change_event (vnet_main_t * vnm, uword type_opaque, uword data, int is_add); +void wc_arp_set_publisher_node (uword inode_index, uword event_type); + void ethernet_arp_change_mac (u32 sw_if_index); void ethernet_ndp_change_mac (u32 sw_if_index); @@ -557,6 +596,13 @@ const u8 *ethernet_ip6_mcast_dst_addr (void); extern vlib_node_registration_t ethernet_input_node; +typedef struct +{ + u32 sw_if_index; + u32 ip4; + u8 mac[6]; +} wc_arp_report_t; + #endif /* included_ethernet_h */ /*