X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fethernet%2Fethernet.h;h=2e5209c44232262335af168dd3a586e039aac07a;hb=cbe25aab3be72154f2c706c39eeba6a77f34450f;hp=ceaadd26c1cdbb1301a745a7d871e17f65c49551;hpb=ddf6e08d2e3fc1614430e26dea632fbc79df2906;p=vpp.git diff --git a/src/vnet/ethernet/ethernet.h b/src/vnet/ethernet/ethernet.h index ceaadd26c1c..2e5209c4423 100644 --- a/src/vnet/ethernet/ethernet.h +++ b/src/vnet/ethernet/ethernet.h @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -59,40 +60,6 @@ typedef struct u32 hw_if_index; } ethernet_input_frame_t; -always_inline u64 -ethernet_mac_address_u64 (const u8 * a) -{ - return (((u64) a[0] << (u64) (5 * 8)) - | ((u64) a[1] << (u64) (4 * 8)) - | ((u64) a[2] << (u64) (3 * 8)) - | ((u64) a[3] << (u64) (2 * 8)) - | ((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, @@ -187,6 +154,9 @@ typedef struct ethernet_interface /* Ethernet (MAC) address for this interface. */ u8 address[6]; + + /* Secondary MAC addresses for this interface */ + mac_address_t *secondary_addrs; } ethernet_interface_t; extern vnet_hw_interface_class_t ethernet_hw_interface_class; @@ -287,7 +257,18 @@ typedef struct u32 input_next_mpls; } next_by_ethertype_t; +struct ethernet_main_t_; + +typedef void (ethernet_address_change_function_t) + (struct ethernet_main_t_ * im, u32 sw_if_index, uword opaque); + typedef struct +{ + ethernet_address_change_function_t *function; + uword function_opaque; +} ethernet_address_change_ctx_t; + +typedef struct ethernet_main_t_ { vlib_main_t *vlib_main; @@ -330,6 +311,10 @@ typedef struct /* Allocated loopback instances */ uword *bm_loopback_instances; + + /** Functions to call when interface hw address changes. */ + ethernet_address_change_ctx_t *address_change_callbacks; + } ethernet_main_t; extern ethernet_main_t ethernet_main; @@ -343,11 +328,15 @@ ethernet_get_type_info (ethernet_main_t * em, ethernet_type_t type) ethernet_interface_t *ethernet_get_interface (ethernet_main_t * em, u32 hw_if_index); +mac_address_t *ethernet_interface_add_del_address (ethernet_main_t * em, + u32 hw_if_index, + const u8 * address, + u8 is_add); clib_error_t *ethernet_register_interface (vnet_main_t * vnm, u32 dev_class_index, u32 dev_instance, - u8 * address, + const u8 * address, u32 * hw_if_index_return, ethernet_flag_change_function_t flag_change); @@ -471,6 +460,9 @@ clib_error_t *next_by_ethertype_register (next_by_ethertype_t * l3_next, int vnet_create_loopback_interface (u32 * sw_if_indexp, u8 * mac_address, u8 is_specified, u32 user_instance); int vnet_delete_loopback_interface (u32 sw_if_index); +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); int vnet_delete_sub_interface (u32 sw_if_index); // Perform ethernet subinterface classification table lookups given @@ -565,58 +557,20 @@ matched: return 1; } -// Compare two ethernet macs. Return 1 if they are the same, 0 if different -always_inline u32 -eth_mac_equal (const u8 * mac1, const u8 * mac2) -{ - return (*((u32 *) (mac1 + 0)) == *((u32 *) (mac2 + 0)) && - *((u32 *) (mac1 + 2)) == *((u32 *) (mac2 + 2))); -} - - always_inline ethernet_main_t * vnet_get_ethernet_main (void) { return ðernet_main; } -void vnet_register_ip4_arp_resolution_event (vnet_main_t * vnm, - void *address_arg, - uword node_index, - uword type_opaque, uword data); - - -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); - -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); - -void arp_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai); - void ethernet_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai); u8 *ethernet_build_rewrite (vnet_main_t * vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address); -const u8 *ethernet_ip4_mcast_dst_addr (void); -const u8 *ethernet_ip6_mcast_dst_addr (void); +void ethernet_input_init (vlib_main_t * vm, ethernet_main_t * em); 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 */ /*