l2gre.h (7548B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 6 * 7 * This file contains L2GRE definitions internal to the BCM library. 8 */ 9 10 11 #ifndef _BCM_INT_L2GRE_H 12 #define _BCM_INT_L2GRE_H 13 14 #include <bcm/types.h> 15 #include <bcm/l2gre.h> 16 #include <bcm_int/esw/vpn.h> 17 18 #if defined(BCM_TRIUMPH3_SUPPORT) 19 20 #define _BCM_MAX_NUM_L2GRE_TUNNEL 2048 21 #define _BCM_L2GRE_VFI_INVALID 0x3FFF 22 23 /* 24 * L2GRE TPID types 25 */ 26 27 #define _BCM_L2GRE_TPID_SVP_BASED 0x0 28 #define _BCM_L2GRE_TPID_VFI_BASED 0x1 29 #define _BCM_L2GRE_TPID_SGLP_BASED 0x2 30 31 /* 32 * L2GRE TUNNEL TERMINATOR MULTICAST STATES 33 */ 34 35 #define _BCM_L2GRE_TUNNEL_TERM_MULTICAST_LEAF 0x1 36 #define _BCM_L2GRE_TUNNEL_TERM_MULTICAST_BUD 0x2 37 38 /* 39 * L2GRE EGR_L3_NEXT_HOP View 40 */ 41 #define _BCM_L2GRE_EGR_NEXT_HOP_L3_VIEW 0x0 42 #define _BCM_L2GRE_EGR_NEXT_HOP_SDTAG_VIEW 0x2 43 #define _BCM_L2GRE_EGR_NEXT_HOP_L3MC_VIEW 0x7 44 45 /* 46 * L2GRE Lookup Key Types 47 */ 48 #define _BCM_TD2_L2GRE_KEY_TYPE_TUNNEL_VPNID_VFI 0x04 49 #define _BCM_L2GRE_KEY_TYPE_TUNNEL 0x06 50 #define _BCM_L2GRE_KEY_TYPE_VPNID_VFI 0x07 51 #define _BCM_TR3_L2GRE_KEY_TYPE_TUNNEL_VPNID_VFI 0x08 52 #define _BCM_TD2_L2GRE_KEY_TYPE_LOOKUP_DIP 0x0D 53 #define _BCM_TR3_L2GRE_KEY_TYPE_LOOKUP_DIP 0x1A 54 55 /* L2GRE Multicast state */ 56 #define _BCM_L2GRE_MULTICAST_NONE 0x0 57 #define _BCM_L2GRE_MULTICAST_BUD 0x1 58 #define _BCM_L2GRE_MULTICAST_LEAF 0x2 59 #define _BCM_L2GRE_MULTICAST_TRANSIT 0x4 60 61 /* L2GRE Tunnel Type */ 62 #define _BCM_L2GRE_TUNNEL_TYPE 0x7 63 64 /* L2GRE EGR_VFI Type */ 65 #define _BCM_TR3_L2GRE_KEY_TYPE_LOOKUP_VFI 0x04 66 #define _BCM_TR3_L2GRE_KEY_TYPE_LOOKUP_VFI_DVP 0x05 67 #define _BCM_TD2_L2GRE_KEY_TYPE_LOOKUP_VFI 0x05 68 #define _BCM_TD2_L2GRE_KEY_TYPE_LOOKUP_VFI_DVP 0x06 69 70 /* L2GRE SVP Type */ 71 #define _BCM_L2GRE_SOURCE_VP_TYPE_INVALID 0x0 72 #define _BCM_L2GRE_SOURCE_VP_TYPE_VFI 0x1 73 #define _BCM_L2GRE_SOURCE_VP_TYPE_VLAN 0x3 74 75 76 /* L2GRE ING_NEXT_HOP Type */ 77 #define _BCM_L2GRE_INGRESS_NEXT_HOP_ENTRY_TYPE 0x2 78 79 /* L2GRE DVP Type */ 80 #define _BCM_L2GRE_DEST_VP_TYPE_ACCESS 0x0 81 #define _BCM_L2GRE_DEST_VP_ATTRIBUTE_TYPE 0x3 82 #define _BCM_L2GRE_DEST_VP_TYPE_NETWORK 0x2 83 84 #define _BCM_L2GRE_INGRESS_DEST_VP_TYPE 0x2 85 #define _BCM_L2GRE_EGRESS_DEST_VP_TYPE 0x3 86 87 88 /* 89 * L2GRE EGR_L3_NEXT_HOP View 90 */ 91 #define _BCM_L2GRE_EGR_NEXT_HOP_L3_VIEW 0x0 92 #define _BCM_L2GRE_EGR_NEXT_HOP_SDTAG_VIEW 0x2 93 #define _BCM_TD2_L2GRE_EGR_NEXT_HOP_L3MC_VIEW 0x7 94 95 /* 96 * L2GRE port state - need to remember where to find the port. 97 * Flags indicate the type of the port and hence the tables where the data is. 98 * The match attributes are the keys for the various hash tables. 99 */ 100 101 #define _BCM_L2GRE_PORT_MATCH_TYPE_NONE (1 << 0) 102 #define _BCM_L2GRE_PORT_MATCH_TYPE_VLAN (1 << 1) 103 #define _BCM_L2GRE_PORT_MATCH_TYPE_INNER_VLAN (1 << 2) 104 #define _BCM_L2GRE_PORT_MATCH_TYPE_VLAN_STACKED (1 << 3) 105 #define _BCM_L2GRE_PORT_MATCH_TYPE_VLAN_PRI (1 << 4) 106 #define _BCM_L2GRE_PORT_MATCH_TYPE_PORT (1 << 5) 107 #define _BCM_L2GRE_PORT_MATCH_TYPE_TRUNK (1 << 6) 108 #define _BCM_L2GRE_PORT_MATCH_TYPE_VPNID (1 << 7) 109 #define _BCM_L2GRE_PORT_MATCH_TYPE_SHARED (1 << 8) 110 111 112 /* L2GRE Multicast state */ 113 #define _BCM_L2GRE_MULTICAST_NONE 0x0 114 #define _BCM_L2GRE_MULTICAST_BUD 0x1 115 #define _BCM_L2GRE_MULTICAST_LEAF 0x2 116 #define _BCM_L2GRE_MULTICAST_TRANSIT 0x4 117 118 typedef struct _bcm_tr3_l2gre_nh_info_s { 119 int entry_type; 120 int dvp_is_network; 121 int sd_tag_action_present; 122 int sd_tag_action_not_present; 123 int dvp; 124 int intf_num; 125 int sd_tag_vlan; 126 int sd_tag_pri; 127 int sd_tag_cfi; 128 int vc_swap_index; 129 int tpid_index; 130 int is_eline; 131 int dvp_network_group_id; 132 } _bcm_tr3_l2gre_nh_info_t; 133 134 typedef struct _bcm_l2gre_match_port_info_s { 135 uint32 flags; 136 uint32 index; /* Index of memory where port info is programmed */ 137 bcm_trunk_t trunk_id; /* Trunk group ID */ 138 bcm_module_t modid; /* Module id */ 139 bcm_port_t port; /* Port */ 140 bcm_vlan_t match_vlan; 141 bcm_vlan_t match_inner_vlan; 142 uint32 match_vpnid; /* VPNID */ 143 uint32 match_tunnel_index; /* Tunnel Index */ 144 int match_count; /* Number of matches from VLAN_XLATE configured */ 145 } _bcm_l2gre_match_port_info_t; 146 147 typedef struct _bcm_l2gre_eline_vp_map_info_s { 148 int vp1; /* Access VP */ 149 int vp2; /* Network VP */ 150 } _bcm_l2gre_eline_vp_map_info_t; 151 152 typedef struct _bcm_l2gre_tunnel_endpoint_s { 153 bcm_ip_t dip; /* Tunnel DIP */ 154 bcm_ip_t sip; /* Tunnel SIP */ 155 uint16 tunnel_state; /* Multicast Reference Count */ 156 } COMPILER_ATTRIBUTE((packed)) _bcm_l2gre_tunnel_endpoint_t; 157 158 /* 159 * Software book keeping for L2GRE related information 160 */ 161 typedef struct _bcm_tr3_l2gre_bookkeeping_s { 162 int initialized; /* Set to TRUE when L2GRE module initialized */ 163 sal_mutex_t l2gre_mutex; /* Protection mutex. */ 164 SHR_BITDCL *l2gre_ip_tnl_bitmap; /* EGR_IP_TUNNEL index bitmap */ 165 _bcm_l2gre_match_port_info_t *match_key; /* Match Key */ 166 _bcm_l2gre_tunnel_endpoint_t *l2gre_tunnel_term; 167 _bcm_l2gre_tunnel_endpoint_t *l2gre_tunnel_init; 168 } _bcm_tr3_l2gre_bookkeeping_t; 169 170 extern _bcm_tr3_l2gre_bookkeeping_t *_bcm_tr3_l2gre_bk_info[BCM_MAX_NUM_UNITS]; 171 extern void _bcm_l2gre_sw_dump(int unit); 172 173 /* Generic memory allocation routine. */ 174 #define BCM_TR3_L2GRE_ALLOC(_ptr_,_size_,_descr_) \ 175 do { \ 176 if ((NULL == (_ptr_))) { \ 177 _ptr_ = sal_alloc((_size_),(_descr_)); \ 178 } \ 179 if((_ptr_) != NULL) { \ 180 sal_memset((_ptr_), 0, (_size_)); \ 181 } \ 182 } while (0) 183 184 #define _BCM_L2GRE_VPN_INVALID 0xffff 185 186 #define BCM_STAT_L2GRE_FLEX_COUNTER_MAX_TABLES 4 187 /* 188 * Do not change - Implementation assumes 189 * _BCM_L2GRE_VPN_TYPE_ELINE == _BCM_L2GRE_VPN_TYPE_ELAN 190 */ 191 #define _BCM_L2GRE_VPN_TYPE_ELINE _BCM_VPN_TYPE_VFI 192 #define _BCM_L2GRE_VPN_TYPE_ELAN _BCM_VPN_TYPE_VFI 193 194 #define _BCM_L2GRE_VPN_SET(_vpn_, _type_, _id_) \ 195 _BCM_VPN_SET(_vpn_, _type_, _id_) 196 197 #define _BCM_L2GRE_VPN_GET(_id_, _type_, _vpn_) \ 198 _BCM_VPN_GET(_id_, _type_, _vpn_) 199 200 extern int _bcm_esw_l2gre_trunk_member_add(int unit, bcm_trunk_t trunk_id, 201 int trunk_member_count, bcm_port_t *trunk_member_array); 202 extern int _bcm_esw_l2gre_trunk_member_delete(int unit, bcm_trunk_t trunk_id, 203 int trunk_member_count, bcm_port_t *trunk_member_array); 204 205 #endif /* BCM_TRIUMPH3_SUPPORT */ 206 207 #if defined(BCM_WARM_BOOT_SUPPORT) && defined(INCLUDE_L3) 208 extern int _bcm_esw_l2gre_sync(int unit); 209 #endif /* BCM_WARM_BOOT_SUPPORT && INCLUDE_L3 */ 210 211 #if defined(INCLUDE_L3) 212 extern int _bcm_esw_l2gre_port_source_vp_lag_set( 213 int unit, bcm_gport_t gport, int vp_lag_vp); 214 extern int _bcm_esw_l2gre_port_source_vp_lag_clear( 215 int unit, bcm_gport_t gport, int vp_lag_vp); 216 extern int _bcm_esw_l2gre_port_source_vp_lag_get( 217 int unit, bcm_gport_t gport, int *vp_lag_vp); 218 #endif /* INCLUDE_L3 */ 219 #endif /* !_BCM_INT_L2GRE_H */ 220