l3.h (9504B)
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 * L3 Internal header 8 */ 9 10 #ifndef _BCM_INT_DPP_L3_H_ 11 #define _BCM_INT_DPP_L3_H_ 12 13 #include <sal/types.h> 14 #include <bcm/types.h> 15 #include <bcm/l3.h> 16 17 #include <soc/dpp/PPD/ppd_api_general.h> 18 #include <soc/dpp/PPC/ppc_api_mymac.h> 19 #include <shared/swstate/sw_state.h> 20 #include <soc/dpp/ARAD/ARAD_PP/arad_pp_vsi.h> 21 #include <soc/dpp/PPD/ppd_api_frwrd_fec.h> 22 23 #define _BCM_PETRA_L3_NOF_ITFS SOC_DPP_CONFIG(unit)->l3.nof_rifs 24 #define _BCM_PETRA_L3_ITF_ID_BASE (0) 25 26 /* Number of entries in the VridMyMacCam table */ 27 #define _BCM_PETRA_L3_VRRP_CAM_MAX_NOF_ENTIRES(_unit) (SOC_PPC_VRRP_CAM_MAX_NOF_ENTRIES(_unit)) 28 29 /* Maximum number of VSIs that can be assigned to a vrrp entry. */ 30 #define _BCM_PETRA_L3_VRRP_MAX_VSI(_unit) SOC_PPC_VRRP_MAX_VSI(_unit) 31 32 #define DPP_DEFAULT_VRF 0 33 #define DPP_VRF_VALID(unit, _vrf) (((_vrf) >= 0) && (_vrf < SOC_DPP_DEFS_GET(unit, nof_vrfs))) 34 35 36 37 /* Multiple mymac enabled modes. 38 * Multiple mymac and VRRP can coexist on the same device, but sometimes the user might want to disable VRRP. 39 * For that reason, the multiple mymac enabled soc_dpp_config can be configured to 2 at device bringup. 40 */ 41 42 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_ENABLED_EXCLUSIVE 2 43 44 #define _BCM_L3_MULTIPLE_MYMAC_ENABLED(_unit) \ 45 (SOC_DPP_CONFIG(_unit)->l3.multiple_mymac_enabled) 46 47 #define _BCM_L3_MULTIPLE_MYMAC_EXCLUSIVE(_unit) \ 48 (SOC_DPP_CONFIG(_unit)->l3.multiple_mymac_enabled == _BCM_PETRA_L3_MULTIPLE_MYMAC_ENABLED_EXCLUSIVE) 49 50 51 /* Multiple mymac modes. 52 * Mode None : No protocol distinction and no use of mac masks. 53 * Mode IPv4 distinct : No use of mac masks, distinction only between IPv4 and other protocols. 54 * Mode Protocol Group Active : Full use of protocol groups for protocol distinction, full use of mac masks. 55 */ 56 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_NONE 0 57 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_IPV4_DISTINCT 1 58 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_PROTOCOL_GROUP_ACTIVE 2 59 60 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE(unit) (SOC_DPP_CONFIG(unit)->l3.multiple_mymac_mode) 61 62 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_PROTOCOL_GROUP_IS_ACTIVE(_unit) \ 63 (_BCM_PETRA_L3_MULTIPLE_MYMAC_MODE(_unit) >= _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_PROTOCOL_GROUP_ACTIVE) 64 65 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_IS_IPV4_DISTINCT(_unit) \ 66 (_BCM_PETRA_L3_MULTIPLE_MYMAC_MODE(_unit) == _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_IPV4_DISTINCT) 67 68 #define _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_IS_NONE(_unit) \ 69 (_BCM_PETRA_L3_MULTIPLE_MYMAC_MODE(_unit) == _BCM_PETRA_L3_MULTIPLE_MYMAC_MODE_NONE) 70 71 72 /* Given a vsi, returns true if it's the vrrp's "configure all VSIs" vsi. */ 73 #define _BCM_PETRA_L3_VRRP_VLAN_IS_ALL_VSI(_vsi) (_vsi == 0) 74 75 /* Given the api's l3 protocol group flags, returns the soc ppc flags. */ 76 #define BCM_PETRA_L3_VRRP_TRANSLATE_API_FLAGS_TO_INTERNAL_PROTOCOL_GROUP_FLAGS(_src, _target) \ 77 (_target) = 0; \ 78 DPP_TRANSLATE_FLAG(_src, BCM_L3_VRRP_IPV4, _target, SOC_PPC_L3_VRRP_PROTOCOL_GROUP_IPV4); \ 79 DPP_TRANSLATE_FLAG(_src, BCM_L3_VRRP_IPV6, _target, SOC_PPC_L3_VRRP_PROTOCOL_GROUP_IPV6); 80 81 /* Given the soc ppc l3 protocol group flags, returns the api flags. */ 82 #define BCM_PETRA_L3_VRRP_TRANSLATE_PROTOCOL_GROUP_INTERNAL_FLAGS_TO_API(_src, _target) \ 83 (_target) = 0; \ 84 DPP_TRANSLATE_FLAG(_src, SOC_PPC_L3_VRRP_PROTOCOL_GROUP_IPV4, _target, BCM_L3_VRRP_IPV4); \ 85 DPP_TRANSLATE_FLAG(_src, SOC_PPC_L3_VRRP_PROTOCOL_GROUP_IPV6, _target, BCM_L3_VRRP_IPV6); 86 87 88 89 90 void Lpm_Cache_Test(int32 masklen, int nof_routes, int flags, int num); 91 92 /* given interface check if it's valid value 93 Note: also for this should work also for uncoded FEC, (i.e. intf 94 */ 95 96 #define _BCM_PETRA_L3_ITF_IS_VALID_FEC(_unit, _l3_itf_) \ 97 ((_l3_itf_) != 0) 98 99 #define L3_ACCESS sw_state_access[unit].dpp.bcm.l3 100 101 /* ECMP Object */ 102 typedef int bcm_ecmp_t; 103 104 /* 105 * This structure contains information about a given unit's l3 state. 106 */ 107 typedef struct bcm_dpp_l3_state_s { 108 int init; 109 int urpf_mode; 110 PARSER_HINT_ARR int *bcm_tunnel_intf_to_eep; /* The associated EEP per interface */ 111 } bcm_dpp_l3_state_t; 112 113 typedef struct bcm_dpp_l3_info_s { 114 int used_intf; 115 int used_vrf; 116 int used_host; 117 int used_route; 118 PARSER_HINT_PTR bcm_dpp_l3_state_t *dpp_l3_state; 119 uint32 vrrp_protocol_set_types[SOC_DPP_DEFS_MAX(VRRP_NOF_PROTOCOL_GROUPS)]; 120 uint32 vrrp_protocol_set_counts[SOC_DPP_DEFS_MAX(VRRP_NOF_PROTOCOL_GROUPS)]; 121 } bcm_dpp_l3_info_t; 122 123 /* Internal structure to handle VRFs routing */ 124 typedef struct _dpp_l3_vrf_route_s { 125 int is_ipv6; /* TRUE indicates ipv6 address */ 126 bcm_vrf_t vrf_id ; /* Virtual router instance. */ 127 bcm_ip_t vrf_subnet; /* IP subnet address (IPv4). */ 128 bcm_ip6_t vrf_ip6_net; /* IP subnet address (IPv6). */ 129 bcm_ip_t vrf_ip_mask; /* IP subnet mask (IPv4). */ 130 bcm_ip6_t vrf_ip6_mask; /* IP subnet mask (IPv6). */ 131 bcm_if_t vrf_intf; /* L3 interface associated with route, (FEC-id) */ 132 uint32 l3a_flags; /* L3 flags */ 133 uint32 l3a_flags2; /* L3 flags2 */ 134 bcm_if_t encap_id; /* Encapsulation index. */ 135 } _dpp_l3_vrf_route_t; 136 137 138 /* L3 module flags for soc layer */ 139 #define _BCM_L3_FLAGS2_RAW_ENTRY (1 << 0) /* insert entry with raw payload */ 140 141 /* Init vrf structure */ 142 143 144 extern bcm_dpp_l3_info_t *_dpp_l3_info[BCM_MAX_NUM_UNITS]; 145 146 147 void 148 __dpp_l3_vrf_route_t_init(_dpp_l3_vrf_route_t *data); 149 150 /* Common functions to handle ipv4 vrf route (UC and MC) */ 151 int 152 _bcm_ppd_frwrd_ipv4_vrf_route_add( 153 int unit, 154 _dpp_l3_vrf_route_t *info 155 ); 156 157 int 158 _bcm_ppd_frwrd_ipv4_vrf_route_get( 159 int unit, 160 _dpp_l3_vrf_route_t *info 161 ); 162 163 int 164 _bcm_ppd_frwrd_ipv4_vrf_route_remove( 165 int unit, 166 _dpp_l3_vrf_route_t *info 167 ); 168 169 /* Common functions to handle ipv6 vrf route (UC and MC) */ 170 int 171 _bcm_ppd_frwrd_ipv6_vrf_route_add( 172 int unit, 173 _dpp_l3_vrf_route_t *info, 174 SOC_PPC_FRWRD_DECISION_INFO *route_info 175 ); 176 177 int 178 _bcm_ppd_frwrd_ipv6_vrf_route_get( 179 int unit, 180 _dpp_l3_vrf_route_t *info 181 ); 182 183 int 184 _bcm_ppd_frwrd_ipv6_vrf_route_remove( 185 int unit, 186 _dpp_l3_vrf_route_t *info 187 ); 188 189 /* Conversions */ 190 int 191 _bcm_l3_sand_ipv6_addr_to_bcm_ipv6_addr( 192 int unit, 193 SOC_SAND_PP_IPV6_ADDRESS *soc_sand_ipv6_addr, 194 bcm_ip6_t *ipv6_addr 195 ); 196 197 int 198 _bcm_l3_bcm_ipv6_addr_to_sand_ipv6_addr( 199 int unit, 200 bcm_ip6_t ipv6_addr, 201 SOC_SAND_PP_IPV6_ADDRESS *soc_sand_ipv6_addr 202 ); 203 204 int 205 _bcm_l3_intf_to_fec( 206 int unit, 207 bcm_if_t intf, 208 SOC_PPC_FEC_ID *fec_index 209 ); 210 211 void 212 _bcm_l3_fec_to_intf( 213 int unit, 214 SOC_PPC_FEC_ID fec_index, 215 bcm_if_t *intf 216 ); 217 218 int 219 _bcm_l3_encap_id_to_eep( 220 int unit, 221 int encap_id, 222 int *eep 223 ); 224 225 int 226 _bcm_ppd_frwrd_fec_entry_get( 227 int unit, 228 int fec_index, 229 bcm_l3_egress_t *egr 230 ); 231 232 int 233 _bcm_ppd_frwrd_fec_urpf_mode_traverse_set( 234 int unit, 235 uint32 uc_rpf_mode 236 ); 237 238 int 239 _bcm_ppd_rif_global_urpf_mode_traverse_set( 240 int unit, 241 uint32 uc_rpf_mode 242 ); 243 244 int 245 _bcm_ppd_frwrd_route_print_info( 246 int unit, 247 bcm_l3_route_t *info 248 ); 249 250 int 251 _bcm_ppd_frwrd_ipv6_route_print_info( 252 int unit, 253 bcm_l3_route_t *info 254 ); 255 256 int 257 _bcm_ppd_frwrd_ipv4_uc_route_print_info( 258 int unit, 259 bcm_l3_route_t *info 260 ); 261 262 int 263 _bcm_ppd_frwrd_ipv4_vrf_uc_route_print_info( 264 int unit, 265 bcm_l3_route_t *info 266 ); 267 268 int 269 _bcm_ppd_frwrd_host_print_info( 270 int unit, 271 bcm_l3_host_t *info 272 ); 273 274 int 275 _bcm_ppd_frwrd_ipv4_host_print_info( 276 int unit, 277 bcm_l3_host_t *info 278 ); 279 280 /* 281 * _bcm_ppd_frwrd_fec_entry_from_hw 282 * Get fec info from HW according to working/protected fec index 283 */ 284 int 285 _bcm_ppd_frwrd_fec_entry_from_hw( 286 int unit, 287 SOC_PPC_FEC_ID fec_ndx, 288 SOC_PPC_FRWRD_FEC_PROTECT_TYPE 289 *protect_type, 290 SOC_PPC_FRWRD_FEC_ENTRY_INFO 291 *working_fec, 292 bcm_failover_t *failover_id 293 ); 294 295 int _bcm_tunnel_intf_ll_eep_set(int unit, bcm_if_t intf, int tunnel_eep, int ll_eep); 296 297 int _bcm_tunnel_intf_eep_set(int unit, bcm_if_t intf, int eep); 298 299 int _bcm_tunnel_intf_eep_get(int unit, bcm_if_t intf, int *eep); 300 301 int _bcm_tunnel_intf_is_tunnel(int unit, bcm_if_t intf, int *tunneled, int *eep, int *vsi, int *ll_eep); 302 303 /* get eedb index from router/tunnel intf */ 304 int _bcm_l3_intf_eep_get(int unit, bcm_if_t intf, uint8 *tunneled, int *eep); 305 306 #ifdef BCM_88660_A0 307 308 int _bcm_l3_vrrp_mac_to_global_mac(int unit, SOC_PPC_VRRP_CAM_INFO *cam_info, uint32 flags, int vrid); 309 310 int _bcm_l3_vrrp_setting_get(int unit, SOC_PPC_VRRP_CAM_INFO *cam_info); 311 312 int _bcm_l3_vrrp_setting_exists(int unit, int profile_index, int vlan); 313 314 int _bcm_l3_vrrp_setting_delete(int unit, int cam_index, SOC_PPC_VRRP_CAM_INFO *cam_info, int vlan); 315 316 int _bcm_l3_vrrp_setting_add(int unit, SOC_PPC_VRRP_CAM_INFO *cam_info, int vlan); 317 318 int 319 _bcm_l3_sand_mac_is_vrrp_mac(SOC_SAND_PP_MAC_ADDRESS *address, uint8 *is_vrrp); 320 321 322 #endif /*BCM_88660_A0*/ 323 324 #endif /* _BCM_INT_DPP_L3_H_ */ 325