l3.h (29796B)
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 L3 definitions internal to the BCM library. 8 */ 9 10 #ifndef _BCM_INT_L3_H 11 #define _BCM_INT_L3_H 12 13 #include <shared/bitop.h> 14 15 #define INVALID_IP_ADDR 0xffffffff 16 17 #define BCM_L3_IP6_MAX_NETLEN 128 18 #define BCM_L3_IP6_MAX_NETLEN_FBER 64 19 #define BCM_L3_IP4_MAX_NETLEN 32 20 21 22 23 #define _BCM_DEFIP_IPMC_EXPECTED_L3IIF_MAX \ 24 (SOC_IS_MONTEREY(unit) ? 0x3FF : \ 25 (SOC_IS_HURRICANE4(unit) ? 0x3FF : (SOC_IS_HELIX5(unit) ? 0xFFF : 0x2FFF))) 26 #define _BCM_DEFIP_IPMC_RP_ID_BASE \ 27 (SOC_IS_MONTEREY(unit) ? 0x400 : \ 28 (SOC_IS_HURRICANE4(unit) ? 0x400 : (SOC_IS_HELIX5(unit) ? 0x1000 : 0x3000))) 29 #define _BCM_DEFIP_IPMC_RP_SET(rp) \ 30 (soc_feature(unit, soc_feature_l3defip_rp_l3iif_resolve) ? (rp) : \ 31 ((rp) | _BCM_DEFIP_IPMC_RP_ID_BASE)) 32 #define _BCM_DEFIP_IPMC_RP_GET(rp) (rp & (~ _BCM_DEFIP_IPMC_RP_ID_BASE)) 33 #define _BCM_DEFIP_IPMC_RP_IS_SET(val) ((val) > _BCM_DEFIP_IPMC_EXPECTED_L3IIF_MAX) 34 35 extern void _bcm_xgs3_nh_ref_cnt_incr(int unit, unsigned idx); 36 extern void _bcm_xgs3_nh_ref_cnt_get(int unit, uint32 idx, int ecmp, 37 uint32 *ref_count); 38 extern int _bcm_xgs3_ecmp_max_grp_size_get(int unit, int ecmp_group_id, 39 int *grp_sz); 40 extern int _bcm_esw_l3_egress_reference_get(int unit, bcm_if_t mpintf, 41 int ecmp, uint32 *ref_count); 42 extern int _bcm_esw_l3_egress_ref_dlb_update(int unit, int index, 43 uint32 * ref_count); 44 extern int bcmi_esw_l3_egress_ref_count_update(int unit, bcm_if_t intf, 45 uint32 flags, int nh_ecmp_id, int incr); 46 extern int _bcm_esw_l3_gport_construct(int unit, bcm_port_t port, 47 bcm_module_t modid, bcm_trunk_t tgid, uint32 flags, bcm_port_t *gport); 48 49 extern void bcmi_esw_l3_dependent_cleanup(int unit); 50 extern int bcmi_l3_init_check(int unit); 51 /* DGLP Calculation defines */ 52 53 /* Shift module value by 7 bits, since port number 54 * occupies least significant 7 bits. 55 */ 56 #define BCM_L3_DGLP_MODULE_SHIFT_BITS 7 57 /* Port number is 7 bits. Maximum port number is 128 */ 58 #define BCM_L3_DGLP_PORT_MASK 0x7f 59 /* Module id is 8 bits. Maximum modid is 255 */ 60 #define BCM_L3_DGLP_MODULE_ID_MASK 0xff 61 62 #define BCM_L3_DGLP_GET(mod, port) \ 63 (((mod & BCM_L3_DGLP_MODULE_ID_MASK) \ 64 << BCM_L3_DGLP_MODULE_SHIFT_BITS) | \ 65 (port & BCM_L3_DGLP_PORT_MASK)) 66 #define BCM_L3_DGLP_PORT_GET(dglp) \ 67 (dglp & BCM_L3_DGLP_PORT_MASK) 68 #define BCM_L3_DGLP_MODULE_ID_GET(dglp) \ 69 ((dglp >> BCM_L3_DGLP_MODULE_SHIFT_BITS) & \ 70 BCM_L3_DGLP_MODULE_ID_MASK) 71 72 73 #ifdef INCLUDE_L3 74 75 extern int _bcm_esw_l3_vrf_stat_get(int unit, int sync_mode,bcm_vrf_t vrf, 76 bcm_l3_vrf_stat_t stat, uint64 *val); 77 #ifdef FB_LPM_DEBUG 78 extern int lpm128_state_verify(int u); 79 #endif 80 81 #define LPM_L3_ADDR 0xffffffff 82 83 #define BCM_L3_NO_IP6_SUPPORT(_unit_, _flags_) \ 84 (((_flags_) & BCM_L3_IP6) ? \ 85 (soc_feature(_unit_, soc_feature_l3_ip6) ? FALSE : TRUE) : FALSE) 86 87 #define BCM_L3_RPE_SET(_flags_) \ 88 (((_flags_) & BCM_L3_RPE) ? TRUE : FALSE) 89 90 91 /* 5674 L3 interface defines */ 92 #define BCM_LYNX_L3_INTF_NUM_HI_SHIFT 9 93 #define BCM_LYNX_L3_INTF_NUM_L0_MASK 0x1ff 94 95 #define BCM_LYNX_LPM_NEXT_PTR_HI_SHIFT 12 96 #define BCM_LYNX_LPM_NEXT_PTR_L0_MASK 0xfff 97 98 #define _BCM_TR_L3_TRUST_DSCP_PTR_BIT_SIZE 6 99 #define _BCM_TD_L3_TRUST_DSCP_PTR_BIT_SIZE 7 100 #define _BCM_FB6_L3_TRUST_DSCP_PTR_BIT_SIZE 9 101 102 /* Generic types. */ 103 #define BCM_L3_CMP_GREATER (1) 104 #define BCM_L3_CMP_EQUAL (0) 105 #define BCM_L3_CMP_LESS (-1) 106 #define BCM_L3_CMP_NOT_EQUAL (2) 107 108 /* ECMP member operations */ 109 #define BCM_L3_ECMP_MEMBER_OP_SET 0 110 #define BCM_L3_ECMP_MEMBER_OP_ADD 1 111 #define BCM_L3_ECMP_MEMBER_OP_DELETE 2 112 #define BCM_L3_ECMP_MEMBER_OP_REPLACE 3 113 114 /* L3 IP options Default Profile */ 115 #define BCM_L3_IP4_OPTIONS_DEF_PROFILE_INDEX 0x00 116 117 /* L3 subsystem Bookkeeping flags */ 118 #define BCM_L3_BK_DISABLE_ADD_TO_ARL (1 << 0) 119 #define BCM_L3_BK_ENABLE_MACDA_OUI_PROFILE (1 << 1) 120 121 #define BCM_L3_INTER_FLAGS_PRE_FILTER (1 << 0) 122 #define BCM_L3_INTER_FLAGS_PRE_FILTER_SRC (1 << 1) 123 /* 124 * Defines L3 interface 125 */ 126 typedef struct _bcm_l3_intf_cfg_s { 127 uint32 l3i_flags; /* create or replace */ 128 bcm_vrf_t l3i_vrf; /* Virtual Router Instance (EZ only) */ 129 int l3i_index; /* interface number */ 130 bcm_mac_t l3i_mac_addr; /* MAC address for this interface */ 131 bcm_vlan_t l3i_vid; /* VLAN ID this interface is for */ 132 bcm_vlan_t l3i_inner_vlan; /* Inner VLAN ID for double tagged packets*/ 133 int l3i_tunnel_idx; /* tunnel index */ 134 int l3i_ttl; /* TTL threshold */ 135 int l3i_mtu; /* MTU */ 136 bcm_if_group_t l3i_group; /* Interface group number */ 137 bcm_l3_intf_qos_t vlan_qos; 138 bcm_l3_intf_qos_t inner_vlan_qos; 139 bcm_l3_intf_qos_t dscp_qos; 140 #ifdef BCM_TRIUMPH3_SUPPORT 141 int l3i_class; /* Classification class ID */ 142 #endif /* BCM_TRIUMPH3_SUPPORT */ 143 #ifdef BCM_TRIDENT2_SUPPORT 144 int l3i_ip4_options_profile_id; /* IP4 Options handling Profile ID */ 145 int l3i_nat_realm_id; /* Interface realm for NAT */ 146 #endif /* BCM_TRIDENT2_SUPPORT */ 147 #if defined(BCM_TRIDENT2_SUPPORT) || defined(BCM_GREYHOUND2_SUPPORT) 148 int l3i_intf_flags; /* L3 intf flags */ 149 #endif /* BCM_TRIDENT2_SUPPORT || BCM_GREYHOUND2_SUPPORT */ 150 #ifdef BCM_RIOT_SUPPORT 151 bcm_gport_t l3i_source_vp; /* svp for routing in 152 VFI domain over HG flow */ 153 #endif 154 #ifdef BCM_TRIDENT3_SUPPORT 155 uint32 flow_handle; /* FLOW handle for flex entries. */ 156 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 157 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex entries */ 158 uint32 num_of_fields; /* number of logical fields. */ 159 #endif /* BCM_TRIDENT3_SUPPORT */ 160 } _bcm_l3_intf_cfg_t; 161 162 /* 163 * Covers all info needed to config L3 table 164 */ 165 typedef struct _bcm_l3_cfg_s { 166 uint32 l3c_flags; /* See <bcm/l3.h> BCM_L3_* */ 167 uint32 l3c_flags2; /* See <bcm/l3.h> BCM_L3_* */ 168 bcm_vrf_t l3c_vrf; /* Virtual Router Instance (EZ only) */ 169 int l3c_hw_index; /* L3 table index */ 170 bcm_ip_t l3c_ip_addr; /* IPv4 address */ 171 bcm_ip_t l3c_src_ip_addr; /* Source IPv4 address (for IPMC) */ 172 bcm_ip_t l3c_ip_mask; /* used by delete by prefix */ 173 bcm_ip6_t l3c_ip6; /* IPv6 address */ 174 bcm_ip6_t l3c_sip6; /* IPv6 Source address (for IPMC) */ 175 bcm_ip6_t l3c_ip6_mask; /* IPv6 delete by prefix */ 176 bcm_vlan_t l3c_vid; /* VLAN ID (for IPMC 5695 only) */ 177 bcm_mac_t l3c_mac_addr; /* MAC address */ 178 bcm_if_t l3c_intf; /* L3 interface number */ 179 bcm_if_t l3c_ing_intf; /* L3 ingress Interface associated with this entry*/ 180 bcm_port_t l3c_port_tgid; /* port/TGID */ 181 bcm_port_t l3c_stack_port; /* Strata stack port if mod not local */ 182 int l3c_modid; /* MODID */ 183 int l3c_tunnel; /* Tunnel */ 184 int l3c_prio; /* Priority */ 185 int l3c_ipmc_ptr; /* 5690 index to IPMC table */ 186 int l3c_lookup_class; /* Classification lookup class id. */ 187 int l3c_ecmp; /* Set this to 1 to indicate ECMP route */ 188 int l3c_ecmp_count; /* ECMP count */ 189 int l3c_rp_id; /* PIM-BIDIR Rendezvous point ID */ 190 int l3c_eh_q_tag_type;/* EH queue tag type */ 191 int l3c_eh_q_tag; /* EH queue tag */ 192 bcm_if_t l3c_encap_id; /* Encapsulation index */ 193 int l3c_flex_ctr_base_id; /* Base flex counter index */ 194 int l3c_flex_ctr_mode; /* Flex counter offset mode */ 195 int l3c_flex_ctr_pool; /* Flex counter pool number */ 196 int l3c_bfd_enable; /* BFD enable */ 197 #define l3c_ipmc_group l3c_ip_addr 198 #ifdef BCM_TRIDENT3_SUPPORT 199 uint32 l3c_flow_handle; /* FLOW handle for flex entries. */ 200 uint32 l3c_flow_option_handle; /* FLOW option handle for flex entries. */ 201 bcm_flow_logical_field_t l3c_logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex entries */ 202 uint32 l3c_num_of_fields; /* number of logical fields. */ 203 #endif /* BCM_TRIDENT3_SUPPORT */ 204 int l3c_ipmc_ptr_l2; /* L3MC_INDEX_FOR_L2_DISTRIBUTION on TTL/RPF check failure */ 205 } _bcm_l3_cfg_t; 206 207 /* 208 * defip entry type used in _bcm_defip_cfg_t 209 */ 210 typedef enum _bcm_defip_entry_type_e { 211 bcmDefipEntryTypeIp = 0, 212 bcmDefipEntryTypeFcoe = 1 213 } _bcm_defip_entry_type; 214 215 /* 216 * All info needed to configure an IP route. 217 */ 218 typedef struct _bcm_defip_cfg_s { 219 uint32 defip_flags; /* See <bcm/l3.h> BCM_L3_* */ 220 uint32 defip_flags2; /* See <bcm/l3.h> BCM_L3_* */ 221 uint32 defip_inter_flags; /* See BCM_L3_INTER_* */ 222 uint32 defip_ipmc_flags; /* MC-ROUTE: See BCM_IPMC_xxx flag definitions. */ 223 bcm_vrf_t defip_vrf; /* Virtual Router Instance (EZ only) */ 224 bcm_ip_t defip_ip_addr; /* IPv4 subnet address */ 225 bcm_ip6_t defip_ip6_addr; /* IPv6 address */ 226 int defip_sub_len; /* Subnet prefix length */ 227 int defip_index; /* DEFIP table index (Strata only) */ 228 bcm_mac_t defip_mac_addr; /* Next hop MAC address (DA) */ 229 bcm_ip_t defip_nexthop_ip; /* Next hop IPv4 address */ 230 bcm_ip6_t defip_nexthop_ip6; /* Next hop IPv6 address */ 231 int defip_tunnel; /* Tunnel */ 232 int defip_prio; /* Priority */ 233 bcm_if_t defip_intf; /* Hardware redirection index. 234 * For Draco, this is an index into 235 * the L3_INTF table. For Tucana, 236 * this is an index into the L3 table. */ 237 bcm_port_t defip_port_tgid; /* destination port */ 238 bcm_port_t defip_stack_port; /* Strata stack port if mod not local */ 239 int defip_modid; /* destination MODID */ 240 bcm_vlan_t defip_vid; /* For BCM5695 per VLAN default route only */ 241 int defip_ecmp; /* Set this to 1 to indicate ECMP route */ 242 int defip_ecmp_count; /* ECMP count */ 243 int defip_ecmp_index; /* ECMP table index (BCM5695 only) */ 244 int defip_l3hw_index; /* DEFIP route's L3 table index */ 245 uint32 defip_tunnel_option; /* Tunnel option value. */ 246 bcm_mpls_label_t defip_mpls_label; /* MPLS label. */ 247 int defip_lookup_class;/* Classification lookup class id. */ 248 _bcm_defip_entry_type defip_entry_type; /* Entry type, IP or FCOE */ 249 int defip_fcoe_d_id; /* D_ID for FCOE entries */ 250 int defip_fcoe_d_id_mask;/* D_ID mask for FCOE entries */ 251 /* Used to indicate if the entry is in paired tcam or in unpaired TCAM */ 252 int defip_flags_high; 253 int defip_alpm_cookie; /* returns lookup result to be reused in 254 * insert or delete for alpm */ 255 bcm_if_t defip_expected_intf; /* MC-ROUTE: Expected L3 Interface used for 256 * multicast RPF check */ 257 int defip_l3a_rp; /* MC-ROUTE: Rendezvous point ID */ 258 int defip_source_port_tgid; /* Expected source port/trunk */ 259 int defip_source_modid; /* Expected source module */ 260 int defip_source_ts; /* Expected source is trunk? */ 261 bcm_multicast_t defip_mc_group; /* MC-ROUTE: L3 Multicast group index */ 262 #ifdef BCM_TRIDENT3_SUPPORT 263 uint32 defip_flow_handle; /* FLOW handle for flex entries. */ 264 uint32 defip_flow_option_handle; /* FLOW option handle for flex entries. */ 265 uint32 defip_num_of_fields; /* number of logical fields. */ 266 bcm_flow_logical_field_t defip_logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex entries */ 267 #endif /* BCM_TRIDENT3_SUPPORT */ 268 int defip_flex_ctr_base_id; /* Base flex counter index */ 269 int defip_flex_ctr_mode; /* Flex counter offset mode */ 270 int defip_flex_ctr_pool; /* Flex counter pool number */ 271 int defip_acl_class_id; /* Pre-filter class id. */ 272 273 #ifdef ALPM_ENABLE 274 /* Used by ALPM */ 275 uint32 user_data[5]; /* Currently used by ALPM */ 276 void *l1_pvt_node; 277 void *pvt_node; 278 void *bkt_node; 279 void *bkt_info; 280 uint32 bkt_kshift; /* carry down ACB pvt_key_len */ 281 282 void *spl_opn; 283 void *spl_npn; 284 void *spl_pn; 285 void *tcam_write; /* carry _alpm_tcam_write_t info for L1 pvt add during L2 bkt split */ 286 uint32 spl_key[5]; 287 int spl_key_len; 288 int default_miss; /* Used for pivot's default_miss in ALPM_TCAM_ZONED */ 289 int fast_delete_all; /* used only in TH3 fast delete_all */ 290 #endif 291 } _bcm_defip_cfg_t; 292 293 /* 294 * Information of DEF_IP binary table (Strata only) 295 */ 296 typedef struct _bcm_strata_defip_s { 297 ip_addr_t defip_ip_addr; 298 ip_addr_t defip_sub_len; 299 int defip_interface; 300 } _bcm_strata_defip_t; 301 302 /* 303 * Node for hashed version of SW L3 table (XGS Switch) 304 */ 305 typedef struct _bcm_l3hash_s { 306 ip_addr_t l3h_ip_addr; 307 ip_addr_t l3h_sip_addr; 308 uint16 l3h_vid; /* for 5695 IPMC only */ 309 uint16 l3h_flags; 310 uint32 l3h_use_count; 311 #define L3H_HOST 1 312 #define L3H_LPM 2 313 #define L3H_INVALID 4 314 } _bcm_l3hash_t; 315 316 /* 317 * Information about the L3 table (XGS Switch) 318 */ 319 typedef struct _bcm_l3_table_s { 320 _bcm_l3hash_t *l3_hash; /* hashed version of SW L3 table */ 321 uint32 l3_min; /* Min index */ 322 uint32 l3_max; /* Total number of L3 table entries */ 323 uint32 l3_count; /* Number of entries currently used */ 324 } _bcm_l3_table_t; 325 326 /* 327 * Definition of linked list of backup routes (XGS Switch) 328 */ 329 typedef struct _bcm_backup_route_s { 330 struct _bcm_backup_route_s *next; 331 uint16 l3_intf; /* L3 interface number */ 332 uint16 l3_index; /* index in L3 table */ 333 ip_addr_t ip_addr; /* IP subnet address */ 334 unsigned subnet_len:6; /* subnet IP prefix len */ 335 unsigned ecmp:1; /* ecmp bit */ 336 unsigned ecmp_count:6; /* # of ECMP routes */ 337 unsigned ecmp_index:11; /* ECMP table index as in BCM5695 */ 338 } _bcm_backup_route_t; 339 340 /* 341 * Information of one LPM table entry (XGS Switch) 342 */ 343 typedef struct _bcm_lpm_entry_s { 344 _bcm_backup_route_t *backup_routes; /* Backup routes (shorter prefix) */ 345 uint16 forward; /* index of forward LPM _block_ */ 346 uint16 parent; /* index of parent LPM _entry_ */ 347 uint16 l3_index; /* L3 table index for this route */ 348 uint16 l3_intf; /* L3 interface num for this route */ 349 ip_addr_t ip_addr; /* subnet IP address */ 350 unsigned subnet_len:6; /* subnet IP prefix len */ 351 unsigned valid:1; /* valid bit */ 352 unsigned final:1; /* stop bit */ 353 unsigned dirty:1; /* needs to be written to h/w tbl */ 354 unsigned ecmp:1; /* ECMP route bit */ 355 unsigned ecmp_count:6; /* # of ECMP routes */ 356 unsigned ecmp_index:11; /* ECMP table index as in BCM5695 */ 357 } _bcm_lpm_entry_t; 358 359 /* 360 * Node for LPM update list 361 */ 362 typedef struct _bcm_update_list_s { 363 struct _bcm_update_list_s *next; 364 uint16 block; 365 uint32 offsets; 366 } _bcm_update_list_t; 367 368 /* 369 * Per VLAN default route (Draco 1.5) 370 */ 371 typedef struct _bcm_per_vlan_def_route_s { 372 struct _bcm_per_vlan_def_route_s *next; 373 bcm_vlan_t vid; 374 uint16 l3_index; 375 } _bcm_per_vlan_def_route_t; 376 377 /* 378 * Informatin about the LPM table (XGS Switch only) 379 */ 380 typedef struct _bcm_l3_defip_table_s { 381 _bcm_lpm_entry_t *l3_lpm; /* SW shadow copy of LPM table */ 382 int def_route_index; /* def route is last in l3_lpm table */ 383 _bcm_per_vlan_def_route_t *pv_def_route; /* Per VLAN def route (5695 only) */ 384 int global_def_route_set; /* VLAN table based global default route */ 385 int lpm_based_def_route_set; /* LPM based def route set */ 386 387 SHR_BITDCL *lpm_blk_used; /* LPM bock usage bit mask */ 388 soc_mem_t lpm_mem; /* name of the DEFIP memory */ 389 soc_mem_t lpmhit_mem; /* name of the DEFIP HIT memory */ 390 int lpm_min; /* min LPM index */ 391 int lpm_max; /* max LPM index */ 392 int lpm_block_max; /* Max number of blocks in LPM table */ 393 int lpm_block_used; /* number of blocks used */ 394 int lpm_entry_used; /* number of entries used */ 395 int ecmp_max_paths; /* maximum number of ECMP paths allowed */ 396 int ecmp_inuse; /* in use, ecmp_max_paths cannot be changed */ 397 398 /* 399 * These linked lists contain the entries need to be 400 * written to HW LPM table after each insertion/deletion 401 */ 402 _bcm_update_list_t *update_head; /* head of linked list */ 403 _bcm_update_list_t *update_tail; /* tail used for inverse the list */ 404 } _bcm_l3_defip_tbl_t; 405 406 /* 407 * define structure for per Group ECMP info 408 */ 409 410 typedef struct _bcm_l3_ecmp_group_info_s { 411 int max_paths; /* Maximum number of ECMP paths per group. */ 412 int alternate_cnt; 413 uint32 ecmp_flags; /* Ecmp group flags */ 414 } _bcm_l3_ecmp_group_info_t; 415 416 /* 417 * define structure for per Group ECMP buffer 418 */ 419 typedef struct _bcm_l3_ecmp_group_buffer_s { 420 int *group_buffer; /* Ecmp group buffer */ 421 int *dlb_group_buffer; /* DLB group buffer */ 422 } _bcm_l3_ecmp_group_buffer_t; 423 424 /* 425 * define structure for user supplied data in DEFIP traverse 426 */ 427 typedef struct _bcm_l3_defip_traverse_s { 428 bcm_l3_route_traverse_cb trav_cb; 429 void *user_data; 430 int trav_start; 431 int trav_end; 432 int trav_index; 433 bcm_l3_route_t *route_info; 434 } _bcm_l3_defip_traverse_t; 435 436 typedef int (*route_trav_cb_fn)(int unit, _bcm_lpm_entry_t *lpm_entry, void *data); 437 438 /* 439 * Software book keeping for L3 related information 440 */ 441 typedef struct _bcm_l3_bookkeeping_s { 442 uint8 l3_initialized; /* Is L3 module init'ed ? */ 443 SHR_BITDCL *l3_intf_used; /* L3 outgoing interface usage bit mask */ 444 SHR_BITDCL *add_to_arl; /* L3 intf is added to ARL bit mask */ 445 int l3_intf_table_size; /* max number of intf supported by chip */ 446 uint16 l3intf_count; /* number of intf created */ 447 SHR_BITDCL *l3_iif_used; /* L3 incoiming interface usage bit mask. */ 448 int l3_iif_table_size;/* max number of ingress interfaces */ 449 uint16 l3iif_count; /* number of ingress interfaces created */ 450 _bcm_strata_defip_t *strata_defip_info; 451 /* SW copy of DEF_IP table (Strata) */ 452 int defip_table_size; /* max DEF_IP table entries for chip */ 453 int defip_count; /* IP routes added, note each route takes 454 more than one entries in LPM table */ 455 int defip_ip6_count; /* IPv6 routes added */ 456 int l3_table_size; /* chip L3 table size */ 457 int l3_ip4_added; /* IPv4 hosts added */ 458 int l3_ip6_added; /* IPv6 hosts added */ 459 int l3_ipmc4_added; /* IPv4 IPMC added */ 460 int l3_ipmc6_added; /* IPv6 IPMC added */ 461 int l3_nh_added; /* Egress Next hops added */ 462 int l3_ecmp_grp_added; /* ECMP groups added */ 463 int ecmp_table_size; /* max ECMP table entries (D1.5 only) */ 464 int nh_table_size; /* max next hop table */ 465 int tunnel_table_size; /* max tunnel table entries */ 466 int dscp_map_size; /* DSCP-map size */ 467 SHR_BITDCL *dscp_map_used; /* DSCP-map usage bit mask */ 468 int num_dscp_maps; /* Number of DSCP maps available */ 469 #ifdef BCM_TRIDENT_SUPPORT 470 int *l3_trunk_nh_store; /* Store for Trunk nextHop */ 471 #endif /* BCM_TRIDENT_SUPPORT */ 472 #ifdef BCM_TRIUMPH2_SUPPORT 473 int l3_max_ecmp_mode; /* ECMP grp scalability control */ 474 #endif /* BCM_TRIUMPH2_SUPPORT */ 475 #ifdef BCM_TRIDENT2_SUPPORT 476 SHR_BITDCL *ip4_options_bitmap; /* IP options usage bitmap*/ 477 uint32 *ip4_profiles_hw_idx; /* IP options usage bitmap*/ 478 #endif /* BCM_TRIDENT2_SUPPORT */ 479 uint32 l3_ip6_max_128b_entries; /* Max allowed 128b V6 entries */ 480 uint32 flags; /* bookkeeping flags for L3 subsystem */ 481 #if defined(BCM_RIOT_SUPPORT) || defined(BCM_MULTI_LEVEL_ECMP_SUPPORT) 482 uint32 l3_ecmp_levels; 483 uint32 l3_ecmp_overlay_entries; 484 uint32 l3_ecmp_rh_overlay_entries; 485 #endif 486 #ifdef BCM_RIOT_SUPPORT 487 uint32 l3_intf_overlay_entries; 488 uint32 l3_nh_overlay_entries; 489 uint32 riot_enable; 490 #endif 491 #if defined (BCM_TOMAHAWK_SUPPORT) || defined (BCM_TRIDENT2PLUS_SUPPORT) 492 uint8 mc_per_trunk_repl_mode; /* per trunk replication mode */ 493 #endif /* BCM_TOMAHAWK_SUPPORT || BCM_TRIDENT2PLUS_SUPPORT */ 494 #ifdef BCM_RIOT_SUPPORT 495 uint32 l3_intf_overlay_alloc_mode; 496 uint32 l3_nh_overlay_alloc_mode; 497 #endif 498 uint32 *l3_nh_multi_count; 499 uint32 l3_nh_reserve_for_ecmp; 500 #ifdef BCM_TRIDENT3_SUPPORT 501 uint32 l3_ecmp_group_first_lkup_mem_size; 502 uint32 l3_ecmp_member_first_lkup_mem_size; 503 #endif 504 } _bcm_l3_bookkeeping_t; 505 506 extern _bcm_l3_bookkeeping_t _bcm_l3_bk_info[BCM_MAX_NUM_UNITS]; 507 508 509 /* 510 * L3 interface table usage bit mask operations 511 */ 512 #define BCM_L3_INTF_USED_GET(_u_, _if_) \ 513 SHR_BITGET((_bcm_l3_bk_info[unit]).l3_intf_used, (_if_)) 514 #define BCM_L3_INTF_USED_SET(_u_, _if_) \ 515 { \ 516 SHR_BITSET((_bcm_l3_bk_info[unit]).l3_intf_used, (_if_)); \ 517 (_bcm_l3_bk_info[unit]).l3intf_count++; \ 518 } 519 #define BCM_L3_INTF_USED_CLR(_u_, _if_) \ 520 { \ 521 SHR_BITCLR((_bcm_l3_bk_info[unit]).l3_intf_used, (_if_)); \ 522 (_bcm_l3_bk_info[unit]).l3intf_count--; \ 523 } 524 #define BCM_L3_IIF_USED_GET(_u_, _if_) \ 525 SHR_BITGET((_bcm_l3_bk_info[unit]).l3_iif_used, (_if_)) 526 #define BCM_L3_IIF_USED_SET(_u_, _if_) \ 527 { \ 528 SHR_BITSET((_bcm_l3_bk_info[unit]).l3_iif_used, (_if_)); \ 529 (_bcm_l3_bk_info[unit]).l3iif_count++; \ 530 } 531 #define BCM_L3_IIF_USED_CLR(_u_, _if_) \ 532 { \ 533 SHR_BITCLR((_bcm_l3_bk_info[unit]).l3_iif_used, (_if_)); \ 534 (_bcm_l3_bk_info[unit]).l3iif_count--; \ 535 } 536 #define BCM_L3_INTF_ARL_GET(_u_, _if_) \ 537 SHR_BITGET((_bcm_l3_bk_info[unit]).add_to_arl, (_if_)) 538 #define BCM_L3_INTF_ARL_SET(_u_, _if_) \ 539 SHR_BITSET((_bcm_l3_bk_info[unit]).add_to_arl, (_if_)) 540 #define BCM_L3_INTF_ARL_CLR(_u_, _if_) \ 541 SHR_BITCLR((_bcm_l3_bk_info[unit]).add_to_arl, (_if_)) 542 543 #define BCM_L3_DSCP_MAP_USED_GET(_u_, _idx_) \ 544 SHR_BITGET((_bcm_l3_bk_info[unit]).dscp_map_used, (_idx_)) 545 #define BCM_L3_DSCP_MAP_USED_SET(_u_, _idx_) \ 546 SHR_BITSET((_bcm_l3_bk_info[unit]).dscp_map_used, (_idx_)) 547 #define BCM_L3_DSCP_MAP_USED_CLR(_u_, _idx_) \ 548 SHR_BITCLR((_bcm_l3_bk_info[unit]).dscp_map_used, (_idx_)) 549 550 /* Get and Set macros for bookkeeping FLAGs */ 551 #define BCM_L3_BK_FLAG_SET(_u_, _flag_) \ 552 ((_bcm_l3_bk_info[unit]).flags) |= (_flag_) 553 554 #define BCM_L3_BK_FLAG_GET(_u_, _flag_) \ 555 (((_bcm_l3_bk_info[unit]).flags) & (_flag_) ? 1 : 0) 556 557 /* L3X ROUTINES TO BE REMOVED FROM PUBLIC API */ 558 extern int bcm_l3_defip_traverse(int unit, bcm_l3_route_traverse_cb trav_fn, 559 uint32 start, uint32 end); 560 561 extern int _bcm_esw_l3_egress_ecmp_get(int unit, bcm_l3_egress_ecmp_t *ecmp, 562 int intf_size, bcm_if_t *intf_array, 563 int *intf_count, int rh_retrieve); 564 extern int _bcm_esw_l3_ecmp_create(int unit, bcm_l3_egress_ecmp_t *ecmp, 565 int intf_count, bcm_if_t *intf_array, int op, 566 int count, bcm_if_t *intf, int primary_count, 567 SHR_BITDCL *dlb_member_bitmap); 568 569 #define _BCM_EGR_IP_TUNNEL_MPLS_DOUBLE_WIDE(_u_, _tnl_type_) \ 570 (((soc_feature((_u_), soc_feature_egr_ip_tnl_mpls_double_wide)) \ 571 || (soc_feature((_u_), soc_feature_th3_style_simple_mpls))) \ 572 && (_tnl_type_ == bcmTunnelTypeMpls)) 573 574 #define _BCM_EGR_IP_TUNNEL_DOUBLE_WIDE_ENTRY(unit, _tnl_type_) \ 575 ((_BCM_EGR_IP_TUNNEL_MPLS_DOUBLE_WIDE(unit, _tnl_type_)) || \ 576 (_BCM_TUNNEL_OUTER_HEADER_IPV6(_tnl_type_))) 577 578 579 #define _BCM_TUNNEL_OUTER_HEADER_IPV6(_tnl_type_) \ 580 ((((_tnl_type_) == bcmTunnelTypeIp4In6) || \ 581 ((_tnl_type_) == bcmTunnelTypeIp6In6) || \ 582 ((_tnl_type_) == bcmTunnelTypeAutoMulticast6) || \ 583 ((_tnl_type_) == bcmTunnelTypeIpAnyIn6) || \ 584 ((_tnl_type_) == bcmTunnelTypeGre4In6) || \ 585 ((_tnl_type_) == bcmTunnelTypeGre6In6) || \ 586 ((_tnl_type_) == bcmTunnelTypeGreAnyIn6) || \ 587 ((_tnl_type_) == bcmTunnelTypePim6SmDr1) || \ 588 ((_tnl_type_) == bcmTunnelTypePim6SmDr2) || \ 589 ((_tnl_type_) == bcmTunnelTypeRoeIn6) || \ 590 ((_tnl_type_) == bcmTunnelTypeWlanWtpToAc6 || \ 591 ((_tnl_type_) == bcmTunnelTypeWlanAcToAc6)) || \ 592 ((_tnl_type_) == bcmTunnelTypeVxlan6)) ? TRUE : FALSE) 593 594 #ifdef BCM_WARM_BOOT_SUPPORT 595 extern int _bcm_l3_cleanup(int unit); 596 #else 597 #define _bcm_l3_cleanup(u) (BCM_E_NONE) 598 #endif /* BCM_WARM_BOOT_SUPPORT */ 599 600 #ifdef BCM_WARM_BOOT_SUPPORT 601 extern int _bcm_esw_l3_sync(int unit); 602 #endif /* BCM_WARM_BOOT_SUPPORT */ 603 604 #ifndef BCM_SW_STATE_DUMP_DISABLE 605 extern void _bcm_l3_sw_dump(int unit); 606 extern void _bcm_tr_ext_lpm_sw_dump(int unit); 607 #endif /* BCM_SW_STATE_DUMP_DISABLE */ 608 609 typedef struct bcmi_l3_egress_multi_info_s { 610 uint32 flags; /* See BCM_L3_EGRESS_MULTI_XXX flag definitions. */ 611 int number_of_elements; /* number of egress objects to allocate. */ 612 } bcmi_l3_egress_multi_info_t; 613 614 #define BCMI_L3_EGRESS_SOURCE_MULTI_ADD 1 615 #define BCMI_L3_EGRESS_SOURCE_SINGLE_ADD 2 616 617 618 #define BCMI_L3_EGRESS_SOURCE_MASK 0xff 619 #define BCMI_L3_EGRESS_SOURCE_SHIFT 24 620 #define BCMI_L3_EGRESS_SOURCE_VAL_MASK 0xffffff 621 622 #define BCMI_L3_EGRESS_SOURCE_SET(type, val) \ 623 ((((type) << BCMI_L3_EGRESS_SOURCE_SHIFT) | val)) 624 625 #define BCMI_L3_EGRESS_SOURCE_GET(val) \ 626 ((((val) >> BCMI_L3_EGRESS_SOURCE_SHIFT) & BCMI_L3_EGRESS_SOURCE_MASK)) 627 628 629 /* 630 * L3 l3table show flags 631 */ 632 #define _BCM_L3_SHOW_INDEX BCM_L3_VXLAN_ONLY 633 634 #if defined(BCM_RIOT_SUPPORT) || defined(BCM_MULTI_LEVEL_ECMP_SUPPORT) 635 636 /* ECMP Single level */ 637 #define BCMI_L3_ECMP_SINGLE_LEVEL 1 638 639 /* Overlay validity checks */ 640 #define BCMI_L3_ECMP_IS_MULTI_LEVEL(_u) \ 641 (((&_bcm_l3_bk_info[unit])->l3_ecmp_levels) > BCMI_L3_ECMP_SINGLE_LEVEL) 642 643 #define BCMI_L3_ECMP_OVERLAY_ENTRIES(_u) \ 644 ((&_bcm_l3_bk_info[_u])->l3_ecmp_overlay_entries) 645 646 #define BCMI_L3_INTF_OVERLAY_ENTRIES(_u) \ 647 ((&_bcm_l3_bk_info[_u])->l3_intf_overlay_entries) 648 649 /* ECMP Macro flow overlay check */ 650 #define BCM_MACROFLOW_IS_OVERLAY(type) \ 651 ((type == bcmSwitchMacroFlowHashOverlayMinOffset) || \ 652 (type == bcmSwitchMacroFlowHashOverlayMaxOffset) || \ 653 (type == bcmSwitchMacroFlowHashOverlayStrideOffset)) 654 655 /* RioT Overlay validity checks */ 656 #define BCMI_RIOT_IS_ENABLED(_u) \ 657 ((&_bcm_l3_bk_info[_u])->riot_enable) 658 659 #define BCMI_L3_NH_OVERLAY_VALID(_u) \ 660 ((BCMI_RIOT_IS_ENABLED(_u)) && \ 661 (((&_bcm_l3_bk_info[_u])->l3_nh_overlay_entries) > 0)) 662 663 #define BCMI_L3_INTF_OVERLAY_VALID(_u) \ 664 ((BCMI_RIOT_IS_ENABLED(_u)) && \ 665 (((&_bcm_l3_bk_info[_u])->l3_intf_overlay_entries) > 0)) 666 667 #define BCMI_L3_INTF_MEM_ALLOC_MODE(_u) \ 668 ((BCMI_RIOT_IS_ENABLED(_u)) && \ 669 ((_bcm_l3_bk_info[_u].l3_intf_overlay_alloc_mode) == 1)) 670 671 #define BCMI_RIOT_VPN_VFI_IS_SET(_u, _vid) \ 672 ((BCMI_RIOT_IS_ENABLED(_u)) && (_BCM_VPN_VFI_IS_SET((_vid)))) 673 674 #define BCMI_RIOT_VPN_VFI_IS_NOT_SET(_u, _vid) \ 675 ((!BCMI_RIOT_IS_ENABLED(_u)) || (!(_BCM_VPN_VFI_IS_SET((_vid))))) 676 677 #define BCMI_GPORT_TYPE_GET(_gport) \ 678 (((_gport) >> _SHR_GPORT_TYPE_SHIFT) & _SHR_GPORT_TYPE_MASK) 679 680 #endif 681 #endif /* INCLUDE_L3 */ 682 683 #endif /* !_BCM_INT_L3_H */