l3.h (122958B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_L3_H__ 11 #define __BCM_L3_H__ 12 13 #if defined(INCLUDE_L3) 14 15 #include <bcm/types.h> 16 #include <bcm/stat.h> 17 #include <bcm/qos.h> 18 #include <bcm/mpls.h> 19 20 /* L3 module flags. */ 21 #define BCM_L3_L2ONLY (1U << 0) /* L2 switch only on 22 interface. */ 23 #define BCM_L3_UNTAG (1U << 1) /* Packet goes out untagged. */ 24 #define BCM_L3_S_HIT (1U << 2) /* Source IP address match. */ 25 #define BCM_L3_D_HIT (1U << 3) /* Destination IP address 26 match. */ 27 #define BCM_L3_HIT (BCM_L3_S_HIT | BCM_L3_D_HIT) 28 #define BCM_L3_HIT_CLEAR (1U << 4) /* Clear HIT bit. */ 29 #define BCM_L3_ADD_TO_ARL (1U << 5) /* Add interface address MAC 30 to ARL. */ 31 #define BCM_L3_WITH_ID (1U << 6) /* ID is provided. */ 32 #define BCM_L3_NEGATE (1U << 7) /* Negate a set. */ 33 #define BCM_L3_INGRESS_ONLY BCM_L3_NEGATE /* configure ingress objects 34 only. */ 35 #define BCM_L3_REPLACE (1U << 8) /* Replace existing entry. */ 36 #define BCM_L3_TGID (1U << 9) /* Port belongs to trunk. */ 37 #define BCM_L3_OVERLAY_ENCAP BCM_L3_TGID /* LL encapsulation, used for 38 overlay LL for intra DC 39 routed packets */ 40 #define BCM_L3_RPE (1U << 10) /* Pick up new priority 41 (COS). */ 42 #define BCM_L3_ENCAP_SPACE_OPTIMIZED BCM_L3_RPE /* Optimize encapsulation 43 database resources. */ 44 #define BCM_L3_IPMC (1U << 11) /* Set IPMC for real IPMC 45 entry. */ 46 #define BCM_L3_L2TOCPU (1U << 12) /* Packet to CPU unrouted, 47 XGS12: Set IPMC for UC 48 address. */ 49 #define BCM_L3_NATIVE_ENCAP BCM_L3_L2TOCPU /* Eth encapsulation, used 50 for nativ Ethernet for 51 intra DC routed packets */ 52 #define BCM_L3_DEFIP_CPU (1U << 13) /* Strata: DEFIP CPU bit set. */ 53 #define BCM_L3_DEFIP_LOCAL BCM_L3_DEFIP_CPU /* XGS: Local DEFIP route. */ 54 #define BCM_L3_VIRTUAL_OBJECT (1U << 13) /* FEC/egress-encap (virtual 55 FEC). */ 56 #define BCM_L3_EGRESS_ONLY BCM_L3_VIRTUAL_OBJECT /* Configure Egress objects 57 only. */ 58 #define BCM_L3_MULTIPATH (1U << 14) /* Specify ECMP treatment. */ 59 #define BCM_L3_HOST_LOCAL (1U << 15) /* Packet to local IP stack. */ 60 #define BCM_L3_HOST_AS_ROUTE (1U << 16) /* Use LPM if host table 61 full. */ 62 #define BCM_L3_IP6 (1U << 17) /* IPv6. */ 63 #define BCM_L3_RPF (1U << 18) /* RPF check. */ 64 #define BCM_L3_MC_RPF_EXPLICIT (BCM_L3_RPF | BCM_L3_IPMC) /* Indicates explicit 65 multicast RPF mode */ 66 #define BCM_L3_MC_RPF_SIP_BASE BCM_L3_RPF /* Indicates SIP base 67 multicast RPF mode */ 68 #define BCM_L3_MC_RPF_EXPLICIT_ECMP (BCM_L3_RPF | BCM_L3_MULTIPATH) /* Indicate Explicit 69 multicast ECMP RPF mode */ 70 #define BCM_L3_MC_NO_RPF (BCM_L3_RPF | BCM_L3_L2ONLY) /* Indicates no multicast RPF 71 mode */ 72 #define BCM_L3_SRC_DISCARD (1U << 19) /* Source Match Discard. */ 73 #define BCM_L3_DST_DISCARD (1U << 20) /* Destination match discard. */ 74 #define BCM_L3_SECONDARY (1U << 21) /* Secondary L3 interface 75 (Must NOT be used with 76 L3_CASCADED) */ 77 #define BCM_L3_CASCADED (1U << 21) /* Indicates an L3 egress 78 interface pointed by 79 another L3 egress 80 interface (Must NOT be 81 used with L3_SECONDARY) */ 82 #define BCM_L3_2ND_HIERARCHY BCM_L3_CASCADED /* Indicates that an L3 83 egress/ECMP interface is 84 placed on a 2nd hierarchy 85 level of L3 egresses/ECMPs 86 (Can be replaced by 87 BCM_L3_CASCADED). */ 88 #define BCM_L3_ROUTE_LABEL (1U << 22) /* Indicates that MPLS label 89 in route entry is valid. */ 90 #define BCM_L3_COPY_TO_CPU (1U << 23) /* Send a copy to CPU. */ 91 #define BCM_L3_KEEP_SRCMAC (1U << 24) /* Disable SA replacement for 92 L3UC packets. */ 93 #define BCM_L3_KEEP_DSTMAC (1U << 25) /* Disable DA replacement for 94 L3UC packets. */ 95 #define BCM_L3_KEEP_VLAN (1U << 26) /* Disable VLAN replacement 96 for L3UC packets. */ 97 #define BCM_L3_KEEP_TTL (1U << 27) /* Disable TTL replacement 98 for L3UC packets.When used 99 in conjunction with 100 BCM_L3_ROUTE_LABEL, 101 disable TTL replacement 102 for MPLS flows */ 103 #define BCM_L3_TRILL_ONLY (1U << 28) /* Specific for TRILL Nexthop */ 104 #define BCM_L3_SRC_DST_NAT_REALM_ID (1U << 28) /* To set the nat realm id to 105 both source nat id and 106 destionation nat id. */ 107 #define BCM_L3_L2GRE_ONLY (1U << 29) /* Specific for L2GRE Nexthop */ 108 #define BCM_L3_INTERNAL_ROUTE BCM_L3_L2GRE_ONLY /* Add IP route into the 109 internal LPM table. */ 110 #define BCM_L3_QUEUE_MAP (1U << 30) /* Use queue map to derive 111 queue number */ 112 #define BCM_L3_3RD_HIERARCHY BCM_L3_QUEUE_MAP /* Indicates that an L3 113 egress/ECMP interface is 114 placed on a 3rd hierarchy 115 level of L3 116 egresses/ECMPs. */ 117 #define BCM_L3_DEREFERENCED_NEXTHOP (1U << 30) /* Indicates this is a wider 118 L3 entry. */ 119 #define BCM_L3_ECMP_RH_REPLACE BCM_L3_DEREFERENCED_NEXTHOP /* Replace ECMP member 120 without RH flowset table 121 shuffle. */ 122 #define BCM_L3_VXLAN_ONLY (1U << 31) /* Specific for VXLAN Nexthop */ 123 124 /* L3 module flags2. */ 125 #define BCM_L3_FLAGS2_NIV_ENCAP_LOCAL (1 << 0) /* Apply VNTAG_ACTION on 126 outgoing packet to a 127 HiGig Port. */ 128 #define BCM_L3_FLAGS2_FIELD_ONLY (1 << 1) /* Specific for Field 129 Nexthop. */ 130 #define BCM_L3_FLAGS2_UNDERLAY (1 << 2) /* Create underlay next 131 hop on a virtual port. */ 132 #define BCM_L3_FLAGS2_SRC_DST_MAC_SWAP (1 << 3) /* Swap outgoing packets 133 L2 header SRC/DST MAC 134 fields, for IFP L3 135 egress objects only. */ 136 #define BCM_L3_FLAGS2_EGRESS_WIDE (1 << 4) /* Configure egress wide 137 entry. */ 138 #define BCM_L3_FLAGS2_NO_ECMP_OVERLAP (1 << 5) /* Create next hop on the 139 index without 140 overlapping ECMP 141 indexes */ 142 #define BCM_L3_FLAGS2_SCALE_ROUTE (1 << 6) /* Scale the number of 143 routes. */ 144 #define BCM_L3_FLAGS2_RAW_ENTRY (1 << 7) /* Insert raw data 145 payload */ 146 #define BCM_L3_FLAGS2_SKIP_HIT_CLEAR (1 << 8) /* Skip hit clear when 147 creating a FEC to 148 enhance time 149 performance. */ 150 #define BCM_L3_FLAGS2_ROUTE_NO_MOVE (1 << 9) /* A flag only to be used 151 with BCM_L3_REPLACE 152 flag for avoiding host 153 entries move from the 154 route table to the 155 host table. */ 156 #define BCM_L3_FLAGS2_MPLS_PHP (1 << 10) /* Specific nexthop for 157 MPLS PHP. */ 158 #define BCM_L3_FLOW_ONLY (1 << 11) /* Specific for FLOW 159 Nexthop */ 160 #define BCM_L3_MPLS_GRE_LABEL (1 << 12) /* Specific for MPLS over 161 GRE label */ 162 #define BCM_L3_FLAGS2_XFLOW_MACSEC_ENCRYPT (1 << 13) /* Indicates the next hop 163 entry is for MACsec 164 encrypt */ 165 #define BCM_L3_FLAGS2_XFLOW_MACSEC_DECRYPT (1 << 14) /* Indicates the next hop 166 entry is for MACsec 167 decrypt */ 168 #define BCM_L3_FLAGS2_INGRESS_URPF_MODE (1 << 15) /* Enable fec rpf mode 169 configuration. */ 170 #define BCM_L3_FLAGS2_DECAP_ROE_HEADER (1 << 16) /* Indicates the 171 decapsulation of 172 ROE/ROE Custom Header */ 173 #define BCM_L3_FLAGS2_FCOE_ONLY (1 << 17) /* Specific for FCOE 174 Nexthop. */ 175 #define BCM_L3_FLAGS2_VLAN_TRANSLATION (1 << 18) /* Indicates that 176 bcm_l3_egress_create 177 should allocate ARP+AC 178 entry in EEDB. */ 179 #define BCM_L3_FLAGS2_SRC_MAC (1 << 19) /* Indicates that 180 bcm_l3_egress_create 181 should allocate ARP 182 with the ability to 183 set SA. */ 184 #define BCM_L3_FLAGS2_EGRESS_STAT_ENABLE (1 << 20) /* Indicates statistics 185 enabled. */ 186 #define BCM_L3_FLAGS2_ECMP_RANGE_OVERLAP (1 << 21) /* Indicate that the used 187 FEC ID is overlapping 188 the ECMP IDs range. */ 189 #define BCM_L3_FLAGS2_NON_PROXY_MODE (1 << 22) /* Indicate the 190 encapsulation of HG2 191 PPD-2 Header. */ 192 #define BCM_L3_FLAGS2_MC_GROUP (1 << 23) /* Indicate that the 193 destination is a 194 multicast group. */ 195 #define BCM_L3_FLAGS2_IFA_DST_PORT (1 << 24) /* Indicate that VN_TAG 196 fields need be 197 configured for IFA. */ 198 #define BCM_L3_FLAGS2_VIRTUAL_EGRESS_POINTED (1 << 25) /* Indicate egress object 199 is pointed from EEDB 200 only and not from 201 FWD/ACL Dbs. */ 202 #define BCM_L3_FLAGS2_VLAN_TRANSLATION_TWO_VLAN_TAGS (1 << 26) /* L3 object supports 203 VLAN Translation with 204 up to two VLAN tags. */ 205 #define BCM_L3_FLAGS2_FWD_ONLY (1 << 27) /* Add route to FWD. */ 206 #define BCM_L3_FLAGS2_RPF_ONLY (1 << 28) /* Add route to RPF. */ 207 #define BCM_L3_FLAGS2_NO_PAYLOAD (1 << 29) /* Add route with no 208 payload. */ 209 #define BCM_L3_FLAGS2_SRC_ROUTE (1 << 30) /* Add source route. */ 210 #define BCM_L3_FLAGS2_FAILOVER_UNDERLAY (1U << 31) /* Failover on the 211 underlay next hop. */ 212 213 /* L3 module flags3. */ 214 #define BCM_L3_FLAGS3_INT_ACTION (1 << 0) /* Enable the INT action. */ 215 #define BCM_L3_FLAGS3_DO_NOT_CUT_THROUGH (1 << 1) /* Enable to indicate the 216 packet is not eligible 217 for cut-through. */ 218 #define BCM_L3_FLAGS3_EGRESS_CASCADED (1 << 2) /* Enable to indicate the 219 egress object in 220 cascaded mode. */ 221 #define BCM_L3_FLAGS3_DATA_MODE_FULL (1 << 3) /* Specify data mode of 222 an ALPM route entry as 223 full. */ 224 #define BCM_L3_FLAGS3_DATA_MODE_REDUCED (1 << 4) /* Specify data mode of 225 an ALPM route entry as 226 reduced. */ 227 228 /* L3 module Multicast flags. */ 229 #define BCM_L3_MULTICAST_L2_DEST_PRESERVE (1 << 0) /* L2 multicast dest 230 address replacement 231 disable */ 232 #define BCM_L3_MULTICAST_L2_SRC_PRESERVE (1 << 1) /* L2 multicast source 233 address replacement 234 disable */ 235 #define BCM_L3_MULTICAST_L2_VLAN_PRESERVE (1 << 2) /* L2 multicast outer 236 vlan replacement 237 disable */ 238 #define BCM_L3_MULTICAST_TTL_PRESERVE (1 << 3) /* L3 multicast TTL 239 decrement disable */ 240 #define BCM_L3_MULTICAST_DEST_PRESERVE (1 << 4) /* L3 multicast dest 241 address replacement 242 disable */ 243 #define BCM_L3_MULTICAST_SRC_PRESERVE (1 << 5) /* L3 multicast source 244 address replacement 245 disable */ 246 #define BCM_L3_MULTICAST_VLAN_PRESERVE (1 << 6) /* L3 multicast outer 247 vlan replacement 248 disable */ 249 #define BCM_L3_MULTICAST_L3_DROP (1 << 7) /* L3 multicast L3 drop */ 250 #define BCM_L3_MULTICAST_L2_DROP (1 << 8) /* L3 multicast L2 drop */ 251 252 /* L3 Ingress Interface flags. */ 253 #define BCM_L3_INGRESS_WITH_ID (1 << 0) /* L3 Ingress ID is 254 provided. */ 255 #define BCM_L3_INGRESS_REPLACE (1 << 1) /* Replace existing L3 256 Ingress entry. */ 257 #define BCM_L3_INGRESS_GLOBAL_ROUTE (1 << 2) /* Allow Global Route on 258 L3 Ingress Interface. */ 259 #define BCM_L3_INGRESS_DSCP_TRUST (1 << 3) /* Trust incoming DSCP on 260 L3 Ingress */ 261 #define BCM_L3_INGRESS_URPF_DEFAULT_ROUTE_CHECK (1 << 4) /* Allow URPF Check on 262 Default Routes. */ 263 #define BCM_L3_INGRESS_ROUTE_DISABLE_IP4_UCAST (1 << 5) /* Disable L3 routing on 264 IPv4 UC packets */ 265 #define BCM_L3_INGRESS_ROUTE_DISABLE_IP4_MCAST (1 << 6) /* Disable L3 routing on 266 IPv4 MC packets */ 267 #define BCM_L3_INGRESS_ROUTE_DISABLE_IP6_UCAST (1 << 7) /* Disable L3 routing on 268 IPv6 UC packets */ 269 #define BCM_L3_INGRESS_ROUTE_DISABLE_IP6_MCAST (1 << 8) /* Disable L3 routing on 270 IPv6 MC packets */ 271 #define BCM_L3_INGRESS_ROUTE_DISABLE_MPLS (1 << 9) /* Disable L3 routing on 272 MPLS packets */ 273 #define BCM_L3_INGRESS_IPMC_DO_VLAN_DISABLE (1 << 10) /* Disable using L3 274 interface as part of 275 IPMC forwarding lookup 276 key */ 277 #define BCM_L3_INGRESS_IPV6_ROUTING_HEADER_TYPE_0_DROP (1 << 11) /* Drop Ipv6 Header Type 278 0 packets */ 279 #define BCM_L3_INGRESS_UNKNOWN_SRC_TOCPU (1 << 12) /* Unresolved source for 280 L3 send to CPU */ 281 #define BCM_L3_INGRESS_UNKNOWN_IP4_MCAST_TOCPU (1 << 13) /* Unknown IPMC (IPMC 282 miss) for IPv4 packets 283 sent to CPU */ 284 #define BCM_L3_INGRESS_UNKNOWN_IP6_MCAST_TOCPU (1 << 14) /* Unknown IPMC (IPMC 285 miss) for IPv6 packets 286 sent to CPU */ 287 #define BCM_L3_INGRESS_ICMP_REDIRECT_TOCPU (1 << 15) /* Enables copy to cpu 288 when ICMP redirect 289 packet is needed */ 290 #define BCM_L3_INGRESS_UNKNOWN_IPMC_AS_L2MC (1 << 16) /* Enable L2MC processing 291 of Unknown IPMC (IPMC 292 miss) packets, instead 293 of flooding to vlan */ 294 #define BCM_L3_INGRESS_SRC_DST_NAT_REALM_ID (1 << 17) /* To set the nat id to 295 both source and 296 destination nat id. */ 297 #define BCM_L3_INGRESS_L3_MCAST_L2 (1 << 18) /* Set bridge V4MC 298 forwarding instead of 299 bridge forwarding in 300 case of IPV4 MC with 301 IPMC disable. */ 302 #define BCM_L3_INGRESS_EXT_IPV4_DOUBLE_CAPACITY (1 << 19) /* Enable L3 routing on 303 IPv4 double capacity 304 packets. */ 305 #define BCM_L3_INGRESS_TUNNEL_TERM_ECN_MAP (1 << 20) /* To set the tunnel 306 termination ecn map 307 id. */ 308 #define BCM_L3_INGRESS_MPLS_INTF_NAMESPACE (1 << 21) /* Indicates that if the 309 next layer is MPLS, 310 lookup is in per-I/F 311 context. */ 312 #define BCM_L3_INGRESS_INT (1 << 22) /* INT enable for L3 313 interface. */ 314 #define BCM_L3_INGRESS_IPMC_BRIDGE_FALLBACK (1 << 23) /* Set bridge fallback in 315 case of Unknown IPMC 316 (IPMC miss) packets. */ 317 #define BCM_L3_INGRESS_PIM_BIDIR (1 << 24) /* Classify incoming 318 multicast packets as 319 PIM-BIDIR multicast. 320 Otherwise, incomming 321 multicast packet are 322 classified as PIM-SIM. */ 323 #define BCM_L3_INGRESS_ROUTE_ENABLE_UNKNOWN (1 << 25) /* Enable the routing 324 over an unknown layer, 325 used for tunnel 326 termination where the 327 next layer is yet to 328 be parsed. */ 329 #define BCM_L3_INGRESS_NSH_OVER_L2 (1 << 26) /* Enable NSH over L2 for 330 L3 interface. */ 331 #define BCM_L3_INGRESS_FIELD_COMPRESSION_ENABLE (1 << 27) /* Enable the algorithmic 332 ACL lookup in LPM for 333 Field Compression. */ 334 #define BCM_L3_INGRESS_VIP_ENABLED (1 << 28) /* Indicates that virtual 335 IP routing is enabled 336 on the interface. */ 337 #define BCM_L3_INGRESS_IFA (1 << 29) /* Enable IFA. */ 338 #define BCM_L3_INGRESS_IOAM (1 << 30) /* Enable IOAM. */ 339 #define BCM_L3_INGRESS_IP6_L3_MCAST_L2 (1U << 31) /* Set bridge V6MC 340 forwarding type 341 instead of bridge in 342 case of IPV6 MC with 343 IPMC disable. */ 344 345 /* L3 Interface QOS flags. */ 346 #define BCM_L3_INTF_QOS_OUTER_VLAN_PRI_COPY (1 << 0) /* Copy Outer Vlan .1p 347 from incoming packet 348 .1p. */ 349 #define BCM_L3_INTF_QOS_OUTER_VLAN_PRI_SET (1 << 1) /* Set Outer Vlan .1p 350 from table entry. */ 351 #define BCM_L3_INTF_QOS_OUTER_VLAN_PRI_REMARK (1 << 2) /* Remark Outer Vlan .1p 352 from PHB. */ 353 #define BCM_L3_INTF_QOS_INNER_VLAN_PRI_COPY (1 << 3) /* Copy Inner Vlan .1p 354 from incoming packet 355 .1p. */ 356 #define BCM_L3_INTF_QOS_INNER_VLAN_PRI_SET (1 << 4) /* Set Inner Vlan .1p 357 from table entry. */ 358 #define BCM_L3_INTF_QOS_INNER_VLAN_PRI_REMARK (1 << 5) /* Remark Outer Vlan .1p 359 from PHB. */ 360 #define BCM_L3_INTF_QOS_DSCP_COPY (1 << 6) /* Use existing DSCP */ 361 #define BCM_L3_INTF_QOS_DSCP_SET (1 << 7) /* Set DSCP from table 362 entry. */ 363 #define BCM_L3_INTF_QOS_DSCP_REMARK (1 << 8) /* Remark DSCP from PHB. */ 364 365 /* L3 Egress Interface flags. */ 366 #define BCM_L3_INTF_INNER_VLAN_DO_NOT_MODIFY (1 << 0) /* Do not modify inner 367 VLAN Tag */ 368 #define BCM_L3_INTF_INNER_VLAN_ADD (1 << 1) /* Add Inner VLAN Tag */ 369 #define BCM_L3_INTF_INNER_VLAN_REPLACE (1 << 2) /* Replace Inner VLAN Tag */ 370 #define BCM_L3_INTF_INNER_VLAN_DELETE (1 << 3) /* Delete Inner VLAN Tag */ 371 #define BCM_L3_INTF_UNDERLAY (1 << 4) /* Underlay egress 372 interface */ 373 #define BCM_L3_INTF_IPMC_SAME_INTF_DROP (1 << 5) /* Drop IPMC packets 374 destined to the 375 interface same as the 376 incoming interface. 377 Only applicable with 378 BCM_L3_INTF_IPMC_SAME_INTF_CHECK. */ 379 #define BCM_L3_INTF_TTL_CHECK (1 << 6) /* Enable TTL check */ 380 #define BCM_L3_INTF_PACKET_DO_NOT_MODIFY (1 << 7) /* Do not modify packet. */ 381 #define BCM_L3_INTF_OVERLAY_ENCAP (1 << 9) /* L3 interface used for 382 overlay routing. 383 Relevant for intra DC 384 routed packets */ 385 #define BCM_L3_INTF_NATIVE_ENCAP (1 << 10) /* L3 interface used for 386 native outing. 387 Relevant for intra DC 388 routed packets */ 389 #define BCM_L3_INTF_IPMC_SAME_INTF_CHECK (1 << 11) /* Enable L3 same 390 interface check. The 391 traffic that has the 392 same ingress and 393 egress interface will 394 be either downgraded 395 to L2 switch or 396 dropped. */ 397 #define BCM_L3_INTF_OVERLAY (1 << 12) /* Overlay egress 398 interface */ 399 400 /* Reserved VRF values . */ 401 #define BCM_L3_VRF_INVALID _SHR_L3_VRF_INVALID /* Invalid VRF ID. */ 402 #define BCM_L3_VRF_OVERRIDE _SHR_L3_VRF_OVERRIDE /* Matches before VRF specific 403 entries. */ 404 #define BCM_L3_VRF_GLOBAL _SHR_L3_VRF_GLOBAL /* Matches after VRF specific 405 entries. */ 406 #define BCM_L3_VRF_DEFAULT _SHR_L3_VRF_DEFAULT /* Default VRF ID. */ 407 #define BCM_L3_VRF_ALL _SHR_L3_VRF_ALL /* Represent all VRFs. */ 408 409 /* Backward compatibility. */ 410 #define BCM_L3_TUNNEL_TYPE_IP6_IP4 BCM_L3_TUNNEL_TYPE_6TO4 411 412 /* Invalid L3 Ingress Interface */ 413 #define BCM_L3_INGRESS_INTERFACE_INVALID 4095 /* Invalid L3 Ingress 414 Interface */ 415 416 #define BCM_IP6_BYTE(a, n) (((uint8 *) (a))[n]) 417 418 #define BCM_IP6_HALF(a, n) (((uint16 *) (a))[n]) 419 420 #define BCM_IP6_WORD(a, n) (((uint8 *) (a))[n]) 421 422 #define BCM_IP4_MULTICAST(a) \ 423 (((a) & 0xf0000000) == 0xe0000000) 424 425 #define BCM_IP6_MULTICAST(a) \ 426 ((BCM_IP6_BYTE(a, 0)) == 0xff) 427 428 #define BCM_IP6_ADDR_EQ(a1, a2) \ 429 (sal_memcmp((a1), (a2), BCM_IP6_ADDRLEN) == 0) 430 431 #define BCM_IP6_LOOPBACK(a) \ 432 ((BCM_IP6_WORD((a), 0) | BCM_IP6_WORD((a), 1) | \ 433 BCM_IP6_WORD((a), 2) | BCM_IP6_HALF((a), 6) | \ 434 BCM_IP6_BYTE((a), 14)) == 0 && BCM_IP6_BYTE((a), 15) == 1) 435 436 #define BCM_IP6_V4_MAPPED(a) \ 437 ((BCM_IP6_WORD((a), 0) | BCM_IP6_WORD((a), 1) | \ 438 BCM_IP6_HALF((a), 4)) == 0 && BCM_IP6_HALF((a), 5) == 0xffff) 439 440 #define BCM_IP6_V4_COMPATIBLE(a) \ 441 (BCM_IP6_WORD((a), 0) | BCM_IP6_WORD((a), 1) | BCM_IP6_WORD((a), 2) == 0) 442 443 /* L3 ECMP options. */ 444 #define BCM_L3_ECMP_O_CREATE_WITH_ID (1 << 0) /* Create an Egress ECMP 445 forwarding object with 446 assigned Identifier */ 447 #define BCM_L3_ECMP_O_REPLACE (1 << 1) /* Replace/Update existing 448 Egress ECMP forwarding 449 object. */ 450 451 /* L3 Egress Interface flags. */ 452 #define BCM_L3_ECMP_RESILIENT_MATCH_HASH_KEY (1 << 0) /* Match on the hash key 453 value */ 454 #define BCM_L3_ECMP_RESILIENT_MATCH_INTF (1 << 1) /* Match on the interface 455 value */ 456 #define BCM_L3_ECMP_RESILIENT_MATCH_ECMP (1 << 2) /* Match on the ECMP-Id 457 value */ 458 #define BCM_L3_ECMP_RESILIENT_DELETE (1 << 3) /* Delete matched entries */ 459 #define BCM_L3_ECMP_RESILIENT_REPLACE (1 << 4) /* Replace matched 460 entries with 461 replace_entry */ 462 #define BCM_L3_ECMP_RESILIENT_PCC (1 << 5) /* Add/Replace matched 463 entries with 464 replace_entry in LEM 465 PCC State table */ 466 #define BCM_L3_ECMP_RESILIENT_PCC_EXTERNAL (1 << 6) /* Add/Delete matched 467 entries with 468 replace_entry in KBP 469 PCC table */ 470 #define BCM_L3_ECMP_RESILIENT_COUNT (1 << 7) /* Count matched entries 471 in num_entries */ 472 473 /* L3 Interface QOS setting. */ 474 typedef struct bcm_l3_intf_qos_s { 475 uint32 flags; /* See BCM_L3_INTF_QOS_XXX flag definitions. */ 476 int qos_map_id; /* QOS Map ID. */ 477 uint8 pri; /* Packet .1p. */ 478 uint8 cfi; /* Packet CFI. */ 479 int dscp; /* Packet DSCP. */ 480 } bcm_l3_intf_qos_t; 481 482 /* 483 * L3 Interface Structure. 484 * 485 * Contains information required for manipulating L3 interfaces. 486 */ 487 typedef struct bcm_l3_intf_s { 488 uint32 l3a_flags; /* See BCM_L3_FLAGS_XXX flags 489 definitions. */ 490 uint32 l3a_flags2; /* See BCM_L3_FLAGS2_XXX flags 491 definitions. */ 492 bcm_vrf_t l3a_vrf; /* Virtual router instance. */ 493 bcm_if_t l3a_intf_id; /* Interface ID. */ 494 bcm_mac_t l3a_mac_addr; /* MAC address. */ 495 bcm_vlan_t l3a_vid; /* VLAN ID. */ 496 bcm_vlan_t l3a_inner_vlan; /* Inner vlan for double tagged packets. */ 497 int l3a_tunnel_idx; /* Tunnel (initiator) index. */ 498 int l3a_ttl; /* TTL threshold. */ 499 int l3a_mtu; /* MTU. */ 500 int l3a_mtu_forwarding; /* Forwarding Layer MTU. */ 501 bcm_if_group_t l3a_group; /* Interface group number. */ 502 bcm_l3_intf_qos_t vlan_qos; /* Outer-Vlan QoS Setting. */ 503 bcm_l3_intf_qos_t inner_vlan_qos; /* Inner-Vlan QoS Setting. */ 504 bcm_l3_intf_qos_t dscp_qos; /* DSCP QoS Setting. */ 505 int l3a_intf_class; /* L3 interface class ID */ 506 int l3a_ip4_options_profile_id; /* IP4 Options handling Profile ID */ 507 int l3a_nat_realm_id; /* Realm id of the interface for NAT */ 508 uint16 outer_tpid; /* TPID value */ 509 uint32 l3a_intf_flags; /* See BCM_L3_INTF_XXX flag definitions. */ 510 uint8 native_routing_vlan_tags; /* Set number of VLAN tags expected when 511 interface is used for native routing */ 512 bcm_gport_t l3a_source_vp; /* Source virtual port in overlay 513 domain. SVP is used for deriving port 514 properties in the egress device when 515 packets are sent over HG flow. */ 516 uint32 flow_handle; /* FLOW handle for flex entries. */ 517 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 518 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex 519 entries. */ 520 uint32 num_of_fields; /* number of logical fields. */ 521 bcm_qos_ingress_model_t ingress_qos_model; /* ingress qos and ttl model */ 522 bcm_qos_egress_model_t egress_qos_model; /* egress qos and ttl model */ 523 uint32 stat_id; /* Object statistics ID. */ 524 int stat_pp_profile; /* Statistics profile. */ 525 uint8 l3a_ttl_dec; /* TTL decrement value. */ 526 int opaque_ctrl_id; /* Opqaue control ID for EFP key 527 selection. */ 528 uint32 l3a_mpls_flags; /* BCM_MPLS flag definitions. */ 529 bcm_mpls_label_t l3a_mpls_label; /* MPLS VC label. */ 530 uint8 l3a_mpls_ttl; /* MPLS TTL threshold. */ 531 uint8 l3a_mpls_exp; /* MPLS Exp. */ 532 } bcm_l3_intf_t; 533 534 /* Invalid values for L3 ECMP dynamic load balancing parameters. */ 535 #define BCM_L3_ECMP_DYNAMIC_SCALING_FACTOR_INVALID -1 /* Invalid value for 536 dynamic_scaling_factor. */ 537 #define BCM_L3_ECMP_DYNAMIC_LOAD_WEIGHT_INVALID -1 /* Invalid value for 538 dynamic_load_weight. */ 539 #define BCM_L3_ECMP_DYNAMIC_QUEUE_SIZE_WEIGHT_INVALID -1 /* Invalid value for 540 dynamic_queue_size_weight. */ 541 542 /* L3 Ingress Interface URPF Mode setting. */ 543 typedef enum bcm_l3_ingress_urpf_mode_e { 544 bcmL3IngressUrpfDisable = 0, /* Disable unicast RPF. */ 545 bcmL3IngressUrpfLoose = 1, /* Loose mode Unicast RPF. */ 546 bcmL3IngressUrpfStrict = 2 /* Strict mode Unicast RPF. */ 547 } bcm_l3_ingress_urpf_mode_t; 548 549 /* 550 * L3 Egress Structure. 551 * 552 * Description of an L3 forwarding destination. 553 */ 554 typedef struct bcm_l3_egress_s { 555 uint32 flags; /* Interface flags (BCM_L3_TGID, 556 BCM_L3_L2TOCPU). */ 557 uint32 flags2; /* See BCM_L3_FLAGS2_xxx flag 558 definitions. */ 559 uint32 flags3; /* See BCM_L3_FLAGS3_xxx flag 560 definitions. */ 561 bcm_if_t intf; /* L3 interface (source MAC, tunnel). */ 562 bcm_mac_t mac_addr; /* Next hop forwarding destination mac. */ 563 bcm_vlan_t vlan; /* Next hop vlan id. */ 564 bcm_module_t module; 565 bcm_port_t port; /* Port packet switched to (if 566 !BCM_L3_TGID). */ 567 bcm_trunk_t trunk; /* Trunk packet switched to (if 568 BCM_L3_TGID). */ 569 uint32 mpls_flags; /* BCM_MPLS flag definitions. */ 570 bcm_mpls_label_t mpls_label; /* MPLS label. */ 571 bcm_mpls_egress_action_t mpls_action; /* MPLS action. */ 572 int mpls_qos_map_id; /* MPLS EXP map ID. */ 573 int mpls_ttl; /* MPLS TTL threshold. */ 574 uint8 mpls_pkt_pri; /* MPLS Packet Priority Value. */ 575 uint8 mpls_pkt_cfi; /* MPLS Packet CFI Value. */ 576 uint8 mpls_exp; /* MPLS Exp. */ 577 int qos_map_id; /* General QOS map id */ 578 bcm_if_t encap_id; /* Encapsulation index. */ 579 bcm_failover_t failover_id; /* Failover Object Index. */ 580 bcm_if_t failover_if_id; /* Failover Egress Object index. */ 581 bcm_multicast_t failover_mc_group; /* Failover Multicast Group. */ 582 int dynamic_scaling_factor; /* Scaling factor for dynamic load 583 balancing thresholds. */ 584 int dynamic_load_weight; /* Weight of traffic load in determining 585 a dynamic load balancing member's 586 quality. */ 587 int dynamic_queue_size_weight; /* Weight of queue size in determining a 588 dynamic load balancing member's 589 quality. */ 590 int intf_class; /* L3 interface class ID */ 591 uint32 multicast_flags; /* BCM_L3_MULTICAST flag definitions. */ 592 uint16 oam_global_context_id; /* OAM global context id passed from 593 ingress to egress XGS chip. */ 594 bcm_vntag_t vntag; /* VNTAG. */ 595 bcm_vntag_action_t vntag_action; /* VNTAG action. */ 596 bcm_etag_t etag; /* ETAG. */ 597 bcm_etag_action_t etag_action; /* ETAG action. */ 598 uint32 flow_handle; /* FLOW handle for flex entries. */ 599 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 600 uint32 flow_label_option_handle; /* FLOW option handle for egress label 601 flex entries. */ 602 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex 603 entries. */ 604 uint32 num_of_fields; /* number of logical fields. */ 605 int counting_profile; /* counting profile. If not required, 606 set it to 607 BCM_STAT_LIF_COUNTING_PROFILE_NONE */ 608 int mpls_ecn_map_id; /* IP ECN/INT CN to MPLS EXP map ID. */ 609 bcm_l3_ingress_urpf_mode_t urpf_mode; /* fec rpf mode. */ 610 bcm_multicast_t mc_group; /* Multicast Group. */ 611 bcm_mac_t src_mac_addr; /* Source MAC Address. */ 612 bcm_gport_t hierarchical_gport; /* Hierarchical TM-Flow. */ 613 uint32 stat_id; /* Object statistics ID. */ 614 int stat_pp_profile; /* Statistics profile. */ 615 bcm_gport_t vlan_port_id; /* Pointer to egress vlan translation 616 lif entry in EEDB. */ 617 int replication_id; /* Replication copy ID of multicast 618 Egress object. */ 619 int mtu; /* MTU. */ 620 int nat_realm_id; /* NAT destination realm ID. */ 621 bcm_qos_egress_model_t egress_qos_model; /* egress qos and ttl model */ 622 int egress_opaque_ctrl_id; /* Egress opaque control ID. */ 623 } bcm_l3_egress_t; 624 625 #define BCM_L3_INT_MAX_COSQ_STAT 8 /* Max number of INT COSQ stat. */ 626 627 /* INT COSQ stat types. */ 628 typedef enum bcm_l3_int_cosq_stat_e { 629 bcmL3IntCosqStatNone = 0, /* No stat. */ 630 bcmL3IntCosqStatCurrentBytes = 1, /* Current used buffer in bytes. */ 631 bcmL3IntCosqStatMaxBytes = 2, /* Maximum used buffer in bytes. */ 632 bcmL3IntCosqStatCurrentAvailableBytes = 3, /* Current available buffer in bytes. */ 633 bcmL3IntCosqStatMinAvailableBytes = 4, /* Minimum available buffer in bytes. */ 634 bcmL3IntCosqStatCount = 5 /* Always last. Not a usable value. */ 635 } bcm_l3_int_cosq_stat_t; 636 637 /* 638 * L3 Ingress Structure. 639 * 640 * Description of an L3 Ingress interface. 641 */ 642 typedef struct bcm_l3_ingress_s { 643 uint32 flags; /* Interface flags. */ 644 bcm_vrf_t vrf; /* Virtual router id. */ 645 bcm_l3_ingress_urpf_mode_t urpf_mode; /* URPF mode setting for L3 Ingress 646 Interface. */ 647 int intf_class; /* Classification class ID. */ 648 bcm_vlan_t ipmc_intf_id; /* IPMC L2 distribution Vlan. */ 649 int qos_map_id; /* QoS DSCP priority map. */ 650 int ip4_options_profile_id; /* IP4 Options handling Profile ID */ 651 int nat_realm_id; /* Realm id of the interface for NAT */ 652 int tunnel_term_ecn_map_id; /* Tunnel termination ecn map id */ 653 uint32 intf_class_route_disable; /* routing enablers bit map in rif 654 profile */ 655 int oam_default_profile; /* OAM profile for RIF */ 656 uint32 hash_layers_disable; /* load balancing disable hash layers 657 bit map using the 658 BCM_HASH_LAYER_XXX_DISABLE flags */ 659 int opaque_ctrl_id; /* Opaque control ID. */ 660 bcm_l3_int_cosq_stat_t int_cosq_stat[BCM_L3_INT_MAX_COSQ_STAT]; /* Select INT COSQ stat. */ 661 } bcm_l3_ingress_t; 662 663 /* 664 * L3 Host Structure. 665 * 666 * Contains information required for manipulating L3 host table entries. 667 * 668 * The BCM_L3_IP6 flag in l3a_flags must be set to specify whether the 669 * IPv4 or IPv6 addresses are valid. 670 */ 671 typedef struct bcm_l3_host_s { 672 uint32 l3a_flags; /* See BCM_L3_xxx flag definitions. */ 673 uint32 l3a_flags2; /* See BCM_L3_FLAGS2_xxx flag 674 definitions. */ 675 bcm_vrf_t l3a_vrf; /* Virtual router instance. */ 676 bcm_ip_t l3a_ip_addr; /* Destination host IP address (IPv4). */ 677 bcm_ip6_t l3a_ip6_addr; /* Destination host IP address (IPv6). */ 678 bcm_cos_t l3a_pri; /* New priority in packet. */ 679 bcm_if_t l3a_intf; /* L3 intf associated with this address. */ 680 bcm_if_t l3a_ul_intf; /* Underlay L3 egress object associated 681 with this address. */ 682 bcm_mac_t l3a_nexthop_mac; /* Next hop MAC addr. */ 683 bcm_module_t l3a_modid; /* Module ID packet is switched to. */ 684 bcm_port_t l3a_port_tgid; /* Port/TGID packet is switched to. */ 685 bcm_port_t l3a_stack_port; /* Used if modid not local (Strata 686 Only). */ 687 int l3a_ipmc_ptr; /* Pointer to IPMC table. */ 688 int l3a_lookup_class; /* Classification lookup class ID. */ 689 bcm_if_t encap_id; /* Encapsulation index. */ 690 bcm_if_t native_intf; /* L3 native interface (source MAC). */ 691 uint32 flow_handle; /* FLOW handle for flex entries. */ 692 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 693 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex 694 entries. */ 695 uint32 num_of_fields; /* number of logical fields. */ 696 int l3a_ipmc_ptr_l2; /* Pointer to IPMC table for L2 697 recipients if TTL/RPF check fails. */ 698 uint32 stat_id; /* Object statistics ID. */ 699 int stat_pp_profile; /* Statistics profile. */ 700 int l3a_mtu; /* Multicast packet MTU. */ 701 int l3a_opaque_ctrl_id; /* Opaque control ID. */ 702 } bcm_l3_host_t; 703 704 /* Backward compatibility. */ 705 typedef bcm_l3_host_t bcm_l3_ip_t; 706 707 /* 708 * L3 Key Structure. 709 * 710 * Defines L3 table hash key structure. 711 * 712 * - For unicast addresses, key is DIP address or SIP to update HIT bit 713 * - For multicast addresses, the key is either IPMC group address 714 * (IPMC group address + src IP address), or 715 * (IPMC group address + src IP address + VID) 716 * depending on the chip being used and the (G, S, V) mode enable. 717 * 718 * The BCM_L3_IP6 flag in l3k_flags is set to specify whether the IPv4 or 719 * IPv6 addresses are valid. 720 */ 721 typedef struct bcm_l3_key_s { 722 uint32 l3k_flags; /* Set BCM_L3_IP6 for IPv6, default is IPv4, no 723 other flags are relevant. */ 724 bcm_ip_t l3k_ip_addr; /* Destination IP address (IPv4). */ 725 bcm_ip6_t l3k_ip6_addr; /* Destination IP address (IPv6). */ 726 bcm_ip_t l3k_sip_addr; /* Source IP address (IPv4). */ 727 bcm_ip6_t l3k_sip6_addr; /* Source IP address (IPv6). */ 728 bcm_vlan_t l3k_vid; /* VLAN ID. */ 729 bcm_vrf_t l3k_vrf; /* BCM5660x: Virtual router instance. */ 730 } bcm_l3_key_t; 731 732 /* 733 * L3 Route Structure 734 * 735 * Contains information required for manipulating L3 route table entries. 736 * 737 * The BCM_L3_IP6 flag in l3a_flags must be set to specify whether the 738 * IPv4 or IPv6 addresses are valid. 739 */ 740 typedef struct bcm_l3_route_s { 741 uint32 l3a_flags; /* See BCM_L3_xxx flag definitions. */ 742 uint32 l3a_flags2; /* See BCM_L3_FLAGS2_xxx flag 743 definitions. */ 744 uint32 l3a_flags3; /* See BCM_L3_FLAGS3_xxx flag 745 definitions. */ 746 uint32 l3a_ipmc_flags; /* Used for multicast route entry. See 747 BCM_IPMC_xxx flag definitions. */ 748 bcm_vrf_t l3a_vrf; /* Virtual router instance. */ 749 bcm_ip_t l3a_subnet; /* IP subnet address (IPv4). */ 750 bcm_ip6_t l3a_ip6_net; /* IP subnet address (IPv6). */ 751 bcm_ip_t l3a_ip_mask; /* IP subnet mask (IPv4). */ 752 bcm_ip6_t l3a_ip6_mask; /* IP subnet mask (IPv6). */ 753 bcm_if_t l3a_intf; /* L3 interface associated with route. */ 754 bcm_if_t l3a_ul_intf; /* Underlay L3 egress object associated 755 with this address. */ 756 bcm_ip_t l3a_nexthop_ip; /* Next hop IP address (XGS1/2, IPv4). */ 757 bcm_mac_t l3a_nexthop_mac; /* Next hop MAC address. */ 758 bcm_module_t l3a_modid; /* Module ID. */ 759 bcm_port_t l3a_port_tgid; /* Port or trunk group ID. */ 760 bcm_port_t l3a_stack_port; /* Used if modid is not local (Strata 761 Only). */ 762 bcm_vlan_t l3a_vid; /* BCM5695 only - for per-VLAN def 763 route. */ 764 bcm_cos_t l3a_pri; /* Priority (COS). */ 765 uint32 l3a_tunnel_option; /* Tunnel option value. */ 766 bcm_mpls_label_t l3a_mpls_label; /* MPLS label. */ 767 int l3a_lookup_class; /* Classification class ID. */ 768 bcm_if_t l3a_expected_intf; /* Expected L3 Interface used for 769 multicast RPF check */ 770 int l3a_rp; /* Rendezvous point ID */ 771 bcm_multicast_t l3a_mc_group; /* L3 Multicast group index */ 772 bcm_gport_t l3a_expected_src_gport; /* L3 Multicast group expected source 773 port/trunk */ 774 uint32 flow_handle; /* FLOW handle for flex entries. */ 775 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 776 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex 777 entries. */ 778 uint32 num_of_fields; /* number of logical fields. */ 779 uint32 stat_id; /* Object statistics ID. */ 780 int stat_pp_profile; /* Statistics profile. */ 781 int l3a_mtu; /* Multicast packet MTU. */ 782 int l3a_int_action_profile_id; /* Profile ID for metadata generation 783 and packet updating after metadata 784 insertion. */ 785 int l3a_int_opaque_data_profile_id; /* Profile ID to the opaque data for 786 metadata construction. */ 787 int l3a_opaque_ctrl_id; /* Opaque control ID. */ 788 } bcm_l3_route_t; 789 790 /* 791 * L3 Information Structure. 792 * 793 * Contains information about L3 hardware capacity and utilization. 794 * 795 * Note that in chips that implement the longest prefix match route table 796 * as a trie, one IP route may consume up to 128 table entries in the 797 * worst case. 798 */ 799 typedef struct bcm_l3_info_s { 800 int l3info_max_vrf; /* Maximum number of virtual routers 801 allowed. */ 802 int l3info_used_vrf; /* Number of virtual routers created so far. */ 803 int l3info_max_intf; /* Maximum L3 interfaces the chip supports. */ 804 int l3info_max_intf_group; /* Maximum L3 interface groups the chip 805 supports. */ 806 int l3info_max_host; /* L3 host table size(unit is IPv4 unicast). */ 807 int l3info_max_route; /* L3 route table size (unit is IPv4 route). */ 808 int l3info_max_ecmp_groups; /* Maximum ECMP groups allowed. */ 809 int l3info_max_ecmp; /* Maximum ECMP paths allowed. */ 810 int l3info_used_intf; /* L3 interfaces used. */ 811 int l3info_used_host; /* L3 host entries used. */ 812 int l3info_used_route; /* L3 route entries used. */ 813 int l3info_max_lpm_block; /* Maximum LPM blocks. */ 814 int l3info_used_lpm_block; /* LPM blocks used. */ 815 int l3info_max_l3; /* Superseded by l3info_max_host. */ 816 int l3info_max_defip; /* Superseded by l3info_max_route. */ 817 int l3info_used_l3; /* Superseded by l3info_occupied_host. */ 818 int l3info_used_defip; /* Superseded by l3info_occupied_route. */ 819 int l3info_max_nexthop; /* Maximum NextHops. */ 820 int l3info_used_nexthop; /* NextHops used. */ 821 int l3info_max_tunnel_init; /* Maximum IPV4 tunnels that can be 822 initiated. */ 823 int l3info_used_tunnel_init; /* Number of active IPV4 tunnels initiated. */ 824 int l3info_max_tunnel_term; /* Maximum IPV4 tunnels that can be 825 terminated. */ 826 int l3info_used_tunnel_term; /* Number of active IPV4 tunnels terminated. */ 827 int l3info_used_host_ip4; /* L3 host entries used by IPv4. */ 828 int l3info_used_host_ip6; /* L3 host entries used by IPv6. */ 829 } bcm_l3_info_t; 830 831 /* Renamed bcm_l3_info_t fields. */ 832 #define l3info_occupied_intf l3info_used_intf 833 #define l3info_occupied_host l3info_used_host 834 #define l3info_occupied_route l3info_used_route 835 #define l3info_occupied_l3 l3info_used_l3 836 #define l3info_occupied_defip l3info_used_defip 837 #define bcm_l3_detach bcm_l3_cleanup 838 839 /* L3 DGM structure */ 840 typedef struct bcm_l3_dgm_s { 841 uint32 threshold; /* Indicates the primary path is always selected when 842 primary optimal quality band is above this threshold. */ 843 uint32 cost; /* Indicates the quality band cost of switching over to 844 alternate path. */ 845 uint32 bias; /* Indicates the quality band bias in favor of alternate 846 path. */ 847 } bcm_l3_dgm_t; 848 849 /* L3 ECMP URPF mode setting */ 850 typedef enum bcm_l3_ecmp_urpf_mode_e { 851 bcmL3EcmpUrpfInterfaceDefault = 0, /* Use the L3 interface URPF mode. */ 852 bcmL3EcmpUrpfLoose = 1, /* Use loose ECMP URPF mode. */ 853 bcmL3EcmpUrpfStrictEm = 2 /* Use strict EM ECMP RPF mode. */ 854 } bcm_l3_ecmp_urpf_mode_t; 855 856 /* L3 ECMP tunnel priority - number of priorities. */ 857 typedef enum bcm_l3_ecmp_tunnel_priority_mode_e { 858 bcmL3EcmpTunnelPriorityModeDisable = 0, /* No priorities options. */ 859 bcmL3EcmpTunnelPriorityModeTwoPriorities = 1, /* Two priorities. */ 860 bcmL3EcmpTunnelPriorityModeFourPriorities = 2, /* Four priorities. */ 861 bcmL3EcmpTunnelPriorityModeEightPriorities = 3 /* Eight priorities. */ 862 } bcm_l3_ecmp_tunnel_priority_mode_t; 863 864 /* L3 ECMP tunnel priority. */ 865 typedef struct bcm_l3_tunnel_priority_info_s { 866 bcm_l3_ecmp_tunnel_priority_mode_t mode; /* Tunnel Priority mode. */ 867 int map_profile; /* Tunnel Priority Map profile. */ 868 int index; /* Index to the Tunnel Priority table to 869 update. */ 870 } bcm_l3_tunnel_priority_info_t; 871 872 /* L3 ECMP structure */ 873 typedef struct bcm_l3_egress_ecmp_s { 874 uint32 flags; /* See BCM_L3_xxx flag definitions. */ 875 bcm_if_t ecmp_intf; /* L3 interface ID pointing to egress 876 ecmp object. */ 877 int max_paths; /* Max number of paths in ECMP group. If 878 max_paths <= 0, the default max path 879 which can be set by the API 880 bcm_l3_route_max_ecmp_set will be 881 picked. */ 882 uint32 ecmp_group_flags; /* BCM_L3_ECMP_xxx flags. */ 883 uint32 dynamic_mode; /* Dynamic load balancing mode. See 884 BCM_L3_ECMP_DYNAMIC_MODE_xxx 885 definitions. */ 886 uint32 dynamic_size; /* Number of flows for dynamic load 887 balancing. Valid values are 512, 1k, 888 doubling up to 32k */ 889 uint32 dynamic_age; /* Inactivity duration, in microseconds. */ 890 uint32 dynamic_load_exponent; /* The exponent used in the 891 exponentially weighted moving average 892 calculation of historical member 893 load. */ 894 uint32 dynamic_expected_load_exponent; /* The exponent used in the 895 exponentially weighted moving average 896 calculation of historical expected 897 member load. */ 898 bcm_l3_dgm_t dgm; /* DGM properties */ 899 uint32 stat_id; /* Object statistics ID. */ 900 int stat_pp_profile; /* Statistics profile. */ 901 bcm_l3_ecmp_urpf_mode_t rpf_mode; /* Define RPF mode for the ECMP group. */ 902 bcm_l3_tunnel_priority_info_t tunnel_priority; /* ECMP tunnel priority. */ 903 } bcm_l3_egress_ecmp_t; 904 905 /* L3 ECMP member structure */ 906 typedef struct bcm_l3_ecmp_member_s { 907 uint32 flags; /* Member flag. */ 908 bcm_if_t egress_if; /* L3 interface ID pointing to Egress 909 Forwarding Object. */ 910 bcm_if_t egress_if_2; /* L3 interface ID pointing to Egress 911 Forwarding Object. */ 912 bcm_failover_t failover_id; /* Failover Object Identifier. */ 913 bcm_if_t failover_egress_if; /* Failover Egress L3 Interface ID. */ 914 int status; /* Member status. */ 915 int weight; /* Member weight value. */ 916 } bcm_l3_ecmp_member_t; 917 918 /* Resilient ecmp entry */ 919 typedef struct bcm_l3_egress_ecmp_resilient_entry_s { 920 uint64 hash_key; /* Hash key. */ 921 bcm_l3_egress_ecmp_t ecmp; /* ECMP. */ 922 bcm_if_t intf; /* L3 interface. */ 923 } bcm_l3_egress_ecmp_resilient_entry_t; 924 925 /* Actions to take for DLB flow monitored packets. */ 926 #define BCM_L3_ECMP_DLB_MON_COPY_TO_CPU 1 /* Copy DLB monitored 927 packets to CPU */ 928 #define BCM_L3_ECMP_DLB_MON_MIRROR 2 /* Mirror DLB monitored 929 packets */ 930 #define BCM_L3_ECMP_DLB_MON_COPY_TO_CPU_AND_MIRROR 3 /* Perform Copy to CPU 931 and mirroring of DLB 932 monitored packets */ 933 #define BCM_L3_ECMP_DLB_MON_ACTION_NONE 4 /* Do not perform Copy to 934 CPU or mirroring(take 935 no action) */ 936 #define BCM_L3_ECMP_DLB_MON_TRACE 5 /* Set trace event for 937 DLB monitored packets */ 938 939 /* Per DLB configuration of monitoring parameters. */ 940 typedef struct bcm_l3_ecmp_dlb_mon_cfg_s { 941 uint32 sample_rate; /* Rate of sampling DLB monitored packets */ 942 int action; /* Either BCM_L3_ECMP_DLB_MON_COPY_TO_CPU or 943 BCM_L3_ECMP_DLB_MON_MIRROR or 944 BCM_L3_ECMP_DLB_MON_COPY_TO_CPU_AND_MIRROR or 945 BCM_L3_ECMP_DLB_MON_ACTION_NONE or 946 BCM_L3_ECMP_DLB_MON_TRACE */ 947 int enable; /* Enable monitoring of DLB associated with the ECMP 948 group. 1 = Enable monitoring for DLB associated 949 with ecmp, 0 = Do not monitor DLB */ 950 uint32 sample_rate_64; /* Rate of sampling DLB monitored packets with 64 951 bits */ 952 } bcm_l3_ecmp_dlb_mon_cfg_t; 953 954 /* 955 * L3 ECMP flags. MSB is reserved and used internally for Resilient 956 * Hashing in 56960 957 */ 958 #define BCM_L3_ECMP_DYNAMIC_LOAD_DECREASE_RESET 0x01 /* If set, historical 959 member load is reset 960 to the instantaneous 961 member load if the 962 latter is smaller. */ 963 #define BCM_L3_ECMP_DYNAMIC_EXPECTED_LOAD_DECREASE_RESET 0x02 /* If set, historical 964 expected member load 965 is reset to the 966 instantaneous expected 967 member load if the 968 latter is smaller. */ 969 #define BCM_L3_ECMP_PATH_NO_SORTING 0x04 /* If set, the members of 970 the ECMP group won't 971 be resorted. */ 972 #define BCM_L3_ECMP_OVERLAY 0x08 /* If set, the members of 973 the ECMP group are 974 configured at ECMP 975 Level 1. */ 976 #define BCM_L3_ECMP_UNDERLAY 0x10 /* If set, the members of 977 the ECMP group are 978 configured at ECMP 979 Level 2. */ 980 #define BCM_L3_ECMP_LARGE_TABLE 0x20 /* If selected a large 981 members group table is 982 used for the resilient 983 hashing for better 984 member distribution. */ 985 #define BCM_L3_ECMP_WEIGHTED 0x40 /* If set, indicates it's 986 a weighted ECMP group 987 and members count 988 (intf_count) value 989 must be in powers-of-2 990 and supported values 991 are 256, 512, 1024, 992 2048 and 4096. */ 993 #define BCM_L3_ECMP_EXTENDED 0x80 /* Indicate ECMP extended 994 range (32k to 40k 995 values). */ 996 #define BCM_L3_ECMP_MEMBER_WEIGHTED 0x100 /* If set, indicates it's 997 a weighted ECMP group 998 and each ECMP member 999 should be with a 1000 weight. */ 1001 #define BCM_L3_ECMP_MEMBER_REPLICATION_WEIGHTED BCM_L3_ECMP_WEIGHTED /* Same as 1002 BCM_L3_WEIGHTED and 1003 weighted ECMP is 1004 achieved by member 1005 replication. */ 1006 1007 /* L3 ECMP dynamic load balancing modes. */ 1008 #define BCM_L3_ECMP_DYNAMIC_MODE_DISABLED 0 /* ECMP dynamic load 1009 balancing disabled. */ 1010 #define BCM_L3_ECMP_DYNAMIC_MODE_NORMAL 1 /* ECMP dynamic load 1011 balancing normal mode: 1012 if inactivity duration 1013 lapsed, use optimal 1014 member, else use 1015 assigned member. */ 1016 #define BCM_L3_ECMP_DYNAMIC_MODE_ASSIGNED 2 /* ECMP dynamic load 1017 balancing assigned 1018 mode: always use 1019 assigned member. */ 1020 #define BCM_L3_ECMP_DYNAMIC_MODE_OPTIMAL 3 /* ECMP dynamic load 1021 balancing optimal 1022 mode: always use 1023 optimal member */ 1024 #define BCM_L3_ECMP_DYNAMIC_MODE_RESILIENT 4 /* ECMP resilient load 1025 balancing mode: 1026 minimize reassignment 1027 of flows to members */ 1028 #define BCM_L3_ECMP_DYNAMIC_MODE_RANDOM 5 /* ECMP Randomized load 1029 balancing mode */ 1030 #define BCM_L3_ECMP_DYNAMIC_MODE_ROUND_ROBIN 6 /* ECMP Round Robin load 1031 balancing mode */ 1032 #define BCM_L3_ECMP_DYNAMIC_MODE_DGM 7 /* ECMP dynamic group 1033 multipath mode: if 1034 primary path is good 1035 enough, follow primary 1036 path, else follow 1037 alternate path. */ 1038 #define BCM_L3_ECMP_DYNAMIC_MODE_VIP 8 /* ECMP dynamic group VIP 1039 mode: Virtual IP L4 1040 Load Balancer */ 1041 1042 /* L3 ECMP dynamic load balancing EtherType eligibility flags. */ 1043 #define BCM_L3_ECMP_DYNAMIC_ETHERTYPE_ELIGIBLE 0x01 /* If set, the specified 1044 EtherTypes are 1045 eligible, else 1046 ineligible. */ 1047 #define BCM_L3_ECMP_DYNAMIC_ETHERTYPE_INNER 0x02 /* Use packet's inner 1048 EtherType. */ 1049 #define BCM_L3_ECMP_DYNAMIC_ETHERTYPE_RESILIENT 0x04 /* If set, configure 1050 EtherType eligibility 1051 for resilient load 1052 balancing, else for 1053 dynamic load 1054 balancing. */ 1055 1056 /* L3 ECMP dynamic load balancing link status. */ 1057 #define BCM_L3_ECMP_DYNAMIC_MEMBER_FORCE_DOWN 0 /* Force down the link 1058 status of an ECMP 1059 dynamic load balancing 1060 member. */ 1061 #define BCM_L3_ECMP_DYNAMIC_MEMBER_FORCE_UP 1 /* Force up the link 1062 status of an ECMP 1063 dynamic load balancing 1064 member. */ 1065 #define BCM_L3_ECMP_DYNAMIC_MEMBER_HW 2 /* Let hardware determine 1066 the link status of an 1067 ECMP dynamic load 1068 balancing member. */ 1069 #define BCM_L3_ECMP_DYNAMIC_MEMBER_HW_DOWN 3 /* Hardware indicates 1070 down link status of an 1071 ECMP dynamic load 1072 balancing member. */ 1073 #define BCM_L3_ECMP_DYNAMIC_MEMBER_HW_UP 4 /* Hardware indicates up 1074 link status of an ECMP 1075 dynamic load balancing 1076 member. */ 1077 1078 /* L3 ECMP Member Flags. */ 1079 #define BCM_L3_ECMP_MEMBER_DGM_ALTERNATE 0x00000001 /* If set indicating ECMP 1080 member is within 1081 alternate path, else 1082 within primary path */ 1083 #define BCM_L3_ECMP_MEMBER_FAILOVER_UNDERLAY 0x00000002 /* Failover on the 1084 underlay next hop. */ 1085 1086 /* bcm_l3_host_traverse_cb */ 1087 typedef int (*bcm_l3_host_traverse_cb)( 1088 int unit, 1089 int index, 1090 bcm_l3_host_t *info, 1091 void *user_data); 1092 1093 /* bcm_l3_route_traverse_cb */ 1094 typedef int (*bcm_l3_route_traverse_cb)( 1095 int unit, 1096 int index, 1097 bcm_l3_route_t *info, 1098 void *user_data); 1099 1100 /* bcm_l3_egress_traverse_cb */ 1101 typedef int (*bcm_l3_egress_traverse_cb)( 1102 int unit, 1103 bcm_if_t intf, 1104 bcm_l3_egress_t *info, 1105 void *user_data); 1106 1107 /* bcm_l3_ingress_traverse_cb */ 1108 typedef int (*bcm_l3_ingress_traverse_cb)( 1109 int unit, 1110 bcm_if_t intf_id, 1111 bcm_l3_ingress_t *ing_intf, 1112 void *user_data); 1113 1114 /* bcm_l3_egress_multipath_traverse_cb */ 1115 typedef int (*bcm_l3_egress_multipath_traverse_cb)( 1116 int unit, 1117 bcm_if_t mpintf, 1118 int intf_count, 1119 bcm_if_t *intf_array, 1120 void *user_data); 1121 1122 /* bcm_l3_egress_ecmp_traverse_cb */ 1123 typedef int (*bcm_l3_egress_ecmp_traverse_cb)( 1124 int unit, 1125 bcm_l3_egress_ecmp_t *ecmp, 1126 int intf_count, 1127 bcm_if_t *intf_array, 1128 void *user_data); 1129 1130 /* bcm_l3_ecmp_traverse_cb */ 1131 typedef int (*bcm_l3_ecmp_traverse_cb)( 1132 int unit, 1133 bcm_l3_egress_ecmp_t *ecmp_info, 1134 int ecmp_member_count, 1135 bcm_l3_ecmp_member_t *ecmp_member_array, 1136 void *user_data); 1137 1138 #ifndef BCM_HIDE_DISPATCHABLE 1139 1140 /* Initialize the BCM L3 subsystem. */ 1141 extern int bcm_l3_init( 1142 int unit); 1143 1144 /* De-initialize the BCM L3 subsystem. */ 1145 extern int bcm_l3_cleanup( 1146 int unit); 1147 1148 #endif /* BCM_HIDE_DISPATCHABLE */ 1149 1150 #define bcm_l3_detach bcm_l3_cleanup 1151 1152 #ifndef BCM_HIDE_DISPATCHABLE 1153 1154 /* Enable/disable L3 function without clearing any L3 tables. */ 1155 extern int bcm_l3_enable_set( 1156 int unit, 1157 int enable); 1158 1159 /* Get the status of hardware tables. */ 1160 extern int bcm_l3_info( 1161 int unit, 1162 bcm_l3_info_t *l3info); 1163 1164 #endif /* BCM_HIDE_DISPATCHABLE */ 1165 1166 /* Initialize a bcm_l3_intf_t structure. */ 1167 extern void bcm_l3_intf_t_init( 1168 bcm_l3_intf_t *intf); 1169 1170 /* Initialize a bcm_l3_intf_qos_t structure. */ 1171 extern void bcm_l3_intf_qos_t_init( 1172 bcm_l3_intf_qos_t *intf_qos); 1173 1174 #ifndef BCM_HIDE_DISPATCHABLE 1175 1176 /* Create a new L3 interface. */ 1177 extern int bcm_l3_intf_create( 1178 int unit, 1179 bcm_l3_intf_t *intf); 1180 1181 /* Delete an L3 interface */ 1182 extern int bcm_l3_intf_delete( 1183 int unit, 1184 bcm_l3_intf_t *intf); 1185 1186 /* Delete all L3 interfaces. */ 1187 extern int bcm_l3_intf_delete_all( 1188 int unit); 1189 1190 /* Search for L3 interface by MAC address and VLAN. */ 1191 extern int bcm_l3_intf_find( 1192 int unit, 1193 bcm_l3_intf_t *intf); 1194 1195 /* Search for L3 interface by VLAN only. */ 1196 extern int bcm_l3_intf_find_vlan( 1197 int unit, 1198 bcm_l3_intf_t *intf); 1199 1200 /* Given the L3 interface number, return the interface information. */ 1201 extern int bcm_l3_intf_get( 1202 int unit, 1203 bcm_l3_intf_t *intf); 1204 1205 /* Attach counters entries to the given L3 egress interface. */ 1206 extern int bcm_l3_intf_stat_attach( 1207 int unit, 1208 bcm_if_t intf_id, 1209 uint32 stat_counter_id); 1210 1211 /* Detach counters entries from the given L3 egress interface. */ 1212 extern int bcm_l3_intf_stat_detach( 1213 int unit, 1214 bcm_if_t intf_id); 1215 1216 /* Get stat counter id associated with given L3 egress interface */ 1217 extern int bcm_l3_intf_stat_id_get( 1218 int unit, 1219 bcm_if_t intf_id, 1220 uint32 *stat_counter_id); 1221 1222 #endif /* BCM_HIDE_DISPATCHABLE */ 1223 1224 /* Initialize a bcm_l3_egress_t structure. */ 1225 extern void bcm_l3_egress_t_init( 1226 bcm_l3_egress_t *egr); 1227 1228 #ifndef BCM_HIDE_DISPATCHABLE 1229 1230 /* Create an Egress forwarding object. */ 1231 extern int bcm_l3_egress_create( 1232 int unit, 1233 uint32 flags, 1234 bcm_l3_egress_t *egr, 1235 bcm_if_t *if_id); 1236 1237 /* Destroy an Egress forwarding object. */ 1238 extern int bcm_l3_egress_destroy( 1239 int unit, 1240 bcm_if_t intf); 1241 1242 /* Get an Egress forwarding object. */ 1243 extern int bcm_l3_egress_get( 1244 int unit, 1245 bcm_if_t intf, 1246 bcm_l3_egress_t *egr); 1247 1248 /* Find an interface pointing to an Egress forwarding object. */ 1249 extern int bcm_l3_egress_find( 1250 int unit, 1251 bcm_l3_egress_t *egr, 1252 bcm_if_t *intf); 1253 1254 /* 1255 * Traverse through the egress object table and run callback at each 1256 * valid entry. 1257 */ 1258 extern int bcm_l3_egress_traverse( 1259 int unit, 1260 bcm_l3_egress_traverse_cb trav_fn, 1261 void *user_data); 1262 1263 /* 1264 * Traverse through the egress ARP object table and run callback at each 1265 * valid entry. 1266 */ 1267 extern int bcm_l3_egress_arp_traverse( 1268 int unit, 1269 bcm_l3_egress_traverse_cb trav_fn, 1270 void *user_data); 1271 1272 /* Retrieve valid allocation for a given number of FECs. */ 1273 extern int bcm_l3_egress_allocation_get( 1274 int unit, 1275 uint32 flags, 1276 bcm_l3_egress_t *egr, 1277 uint32 nof_members, 1278 bcm_if_t *if_id); 1279 1280 /* Create a Multipath Egress forwarding object. */ 1281 extern int bcm_l3_egress_multipath_create( 1282 int unit, 1283 uint32 flags, 1284 int intf_count, 1285 bcm_if_t *intf_array, 1286 bcm_if_t *mpintf); 1287 1288 /* Create a Multipath Egress forwarding object with specified path width. */ 1289 extern int bcm_l3_egress_multipath_max_create( 1290 int unit, 1291 uint32 flags, 1292 int max_paths, 1293 int intf_count, 1294 bcm_if_t *intf_array, 1295 bcm_if_t *mpintf); 1296 1297 /* Destroy an Egress Multipath forwarding object. */ 1298 extern int bcm_l3_egress_multipath_destroy( 1299 int unit, 1300 bcm_if_t mpintf); 1301 1302 /* Get an Egress Multipath forwarding object. */ 1303 extern int bcm_l3_egress_multipath_get( 1304 int unit, 1305 bcm_if_t mpintf, 1306 int intf_size, 1307 bcm_if_t *intf_array, 1308 int *intf_count); 1309 1310 /* 1311 * Add an Egress forwarding object to an Egress Multipath forwarding 1312 * object. 1313 */ 1314 extern int bcm_l3_egress_multipath_add( 1315 int unit, 1316 bcm_if_t mpintf, 1317 bcm_if_t intf); 1318 1319 /* 1320 * Delete an Egress forwarding object from an Egress Multipath forwarding 1321 * object. 1322 */ 1323 extern int bcm_l3_egress_multipath_delete( 1324 int unit, 1325 bcm_if_t mpintf, 1326 bcm_if_t intf); 1327 1328 /* Find an interface pointing to an Egress Multipath forwarding object. */ 1329 extern int bcm_l3_egress_multipath_find( 1330 int unit, 1331 int intf_count, 1332 bcm_if_t *intf_array, 1333 bcm_if_t *mpintf); 1334 1335 /* 1336 * Traverse through the multipath egress object table and run callback at 1337 * each valid entry. 1338 */ 1339 extern int bcm_l3_egress_multipath_traverse( 1340 int unit, 1341 bcm_l3_egress_multipath_traverse_cb trav_fn, 1342 void *user_data); 1343 1344 #endif /* BCM_HIDE_DISPATCHABLE */ 1345 1346 /* Initialize L3 Egress ECMP object structure. */ 1347 extern void bcm_l3_egress_ecmp_t_init( 1348 bcm_l3_egress_ecmp_t *ecmp); 1349 1350 /* Initialize L3 Egress ECMP member structure. */ 1351 extern void bcm_l3_ecmp_member_t_init( 1352 bcm_l3_ecmp_member_t *ecmp_member); 1353 1354 #ifndef BCM_HIDE_DISPATCHABLE 1355 1356 /* Create an Egress ECMP forwarding object. */ 1357 extern int bcm_l3_ecmp_create( 1358 int unit, 1359 uint32 options, 1360 bcm_l3_egress_ecmp_t *ecmp_info, 1361 int ecmp_member_count, 1362 bcm_l3_ecmp_member_t *ecmp_member_array); 1363 1364 /* Destroy an Egress ECMP forwarding object. */ 1365 extern int bcm_l3_ecmp_destroy( 1366 int unit, 1367 bcm_if_t ecmp_group_id); 1368 1369 /* Get info about an Egress ECMP forwarding object. */ 1370 extern int bcm_l3_ecmp_get( 1371 int unit, 1372 bcm_l3_egress_ecmp_t *ecmp_info, 1373 int ecmp_member_size, 1374 bcm_l3_ecmp_member_t *ecmp_member_array, 1375 int *ecmp_member_count); 1376 1377 /* Add a member to an Egress ECMP forwarding object. */ 1378 extern int bcm_l3_ecmp_member_add( 1379 int unit, 1380 bcm_if_t ecmp_group_id, 1381 bcm_l3_ecmp_member_t *ecmp_member); 1382 1383 /* Delete a member from an Egress ECMP forwarding object. */ 1384 extern int bcm_l3_ecmp_member_delete( 1385 int unit, 1386 bcm_if_t ecmp_group_id, 1387 bcm_l3_ecmp_member_t *ecmp_member); 1388 1389 /* Delete all members from an Egress ECMP forwarding object. */ 1390 extern int bcm_l3_ecmp_member_delete_all( 1391 int unit, 1392 bcm_if_t ecmp_group_id); 1393 1394 /* Find an Egress ECMP forwarding object. */ 1395 extern int bcm_l3_ecmp_find( 1396 int unit, 1397 int ecmp_member_count, 1398 bcm_l3_ecmp_member_t *ecmp_member_array, 1399 bcm_l3_egress_ecmp_t *ecmp_info); 1400 1401 /* 1402 * Traverse through the valid Egress ECMP forwarding objects and run 1403 * callback. 1404 */ 1405 extern int bcm_l3_ecmp_traverse( 1406 int unit, 1407 bcm_l3_ecmp_traverse_cb trav_fn, 1408 void *user_data); 1409 1410 /* Attach already created monitor entry to a L3 ECMP. */ 1411 extern int bcm_l3_ecmp_agm_attach( 1412 int unit, 1413 bcm_if_t l3_ecmp_id, 1414 bcm_switch_agm_id_t agm_id); 1415 1416 /* Detach a monitor entry from a L3 ECMP group */ 1417 extern int bcm_l3_ecmp_agm_detach( 1418 int unit, 1419 bcm_if_t l3_ecmp_id, 1420 bcm_switch_agm_id_t agm_id); 1421 1422 /* Retrieve a monitor id attached to a L3 ECMP group. */ 1423 extern int bcm_l3_ecmp_agm_attach_get( 1424 int unit, 1425 bcm_if_t l3_ecmp_id, 1426 bcm_switch_agm_id_t *agm_id); 1427 1428 /* Attach counters entries to the given L3 ECMP interface. */ 1429 extern int bcm_l3_ecmp_stat_attach( 1430 int unit, 1431 bcm_if_t intf_id, 1432 uint32 stat_counter_id); 1433 1434 /* Detach counters entries from the given L3 ECMP interface. */ 1435 extern int bcm_l3_ecmp_stat_detach( 1436 int unit, 1437 bcm_if_t intf_id); 1438 1439 /* Get stat counter id associated with given L3 ECMP interface. */ 1440 extern int bcm_l3_ecmp_stat_id_get( 1441 int unit, 1442 bcm_if_t intf_id, 1443 uint32 *stat_counter_id); 1444 1445 /* Set flex counter object value for the given ECMP interface. */ 1446 extern int bcm_l3_ecmp_flexctr_object_set( 1447 int unit, 1448 bcm_if_t intf_id, 1449 uint32 value); 1450 1451 /* Get flex counter object value for the given ECMP interface. */ 1452 extern int bcm_l3_ecmp_flexctr_object_get( 1453 int unit, 1454 bcm_if_t intf_id, 1455 uint32 *value); 1456 1457 /* Create an Egress ECMP forwarding object. */ 1458 extern int bcm_l3_egress_ecmp_create( 1459 int unit, 1460 bcm_l3_egress_ecmp_t *ecmp, 1461 int intf_count, 1462 bcm_if_t *intf_array); 1463 1464 /* Destroy an Egress ECMP forwarding object. */ 1465 extern int bcm_l3_egress_ecmp_destroy( 1466 int unit, 1467 bcm_l3_egress_ecmp_t *ecmp); 1468 1469 /* Get info about an Egress ECMP forwarding object. */ 1470 extern int bcm_l3_egress_ecmp_get( 1471 int unit, 1472 bcm_l3_egress_ecmp_t *ecmp, 1473 int intf_size, 1474 bcm_if_t *intf_array, 1475 int *intf_count); 1476 1477 /* Add an Egress forwarding object to an Egress ECMP forwarding object. */ 1478 extern int bcm_l3_egress_ecmp_add( 1479 int unit, 1480 bcm_l3_egress_ecmp_t *ecmp, 1481 bcm_if_t intf); 1482 1483 /* 1484 * Delete an Egress forwarding object from an Egress ECMP forwarding 1485 * object. 1486 */ 1487 extern int bcm_l3_egress_ecmp_delete( 1488 int unit, 1489 bcm_l3_egress_ecmp_t *ecmp, 1490 bcm_if_t intf); 1491 1492 /* Find an Egress ECMP forwarding object. */ 1493 extern int bcm_l3_egress_ecmp_find( 1494 int unit, 1495 int intf_count, 1496 bcm_if_t *intf_array, 1497 bcm_l3_egress_ecmp_t *ecmp); 1498 1499 /* 1500 * Traverse through the valid Egress ECMP forwarding objects and run 1501 * callback. 1502 */ 1503 extern int bcm_l3_egress_ecmp_traverse( 1504 int unit, 1505 bcm_l3_egress_ecmp_traverse_cb trav_fn, 1506 void *user_data); 1507 1508 /* 1509 * Update an ECMP table that was already allocated, used in cases where 1510 * an ECMP have more than one table. 1511 */ 1512 extern int bcm_l3_egress_ecmp_tunnel_priority_set( 1513 int unit, 1514 bcm_l3_egress_ecmp_t *ecmp, 1515 int intf_count, 1516 bcm_if_t *intf_array); 1517 1518 /* 1519 * Set EtherType eligibility for ECMP dynamic load balancing or resilient 1520 * hashing. 1521 */ 1522 extern int bcm_l3_egress_ecmp_ethertype_set( 1523 int unit, 1524 uint32 flags, 1525 int ethertype_count, 1526 int *ethertype_array); 1527 1528 /* 1529 * Get EtherType eligibility for ECMP dynamic load balancing or resilient 1530 * hashing. 1531 */ 1532 extern int bcm_l3_egress_ecmp_ethertype_get( 1533 int unit, 1534 uint32 *flags, 1535 int ethertype_max, 1536 int *ethertype_array, 1537 int *ethertype_count); 1538 1539 /* 1540 * Set dynamic load balancing (DLB) link status of an Egress forwarding 1541 * object 1542 * belonging to an ECMP group. 1543 */ 1544 extern int bcm_l3_egress_ecmp_member_status_set( 1545 int unit, 1546 bcm_if_t intf, 1547 int status); 1548 1549 /* 1550 * Get dynamic load balancing (DLB) link status of an Egress forwarding 1551 * object 1552 * belonging to an ECMP group. 1553 */ 1554 extern int bcm_l3_egress_ecmp_member_status_get( 1555 int unit, 1556 bcm_if_t intf, 1557 int *status); 1558 1559 #endif /* BCM_HIDE_DISPATCHABLE */ 1560 1561 /* bcm_l3_egress_ecmp_resilient_traverse_cb */ 1562 typedef int (*bcm_l3_egress_ecmp_resilient_traverse_cb)( 1563 int unit, 1564 bcm_l3_egress_ecmp_resilient_entry_t *entry, 1565 void *user_data); 1566 1567 #ifndef BCM_HIDE_DISPATCHABLE 1568 1569 /* 1570 * Traverse through the resilient ecmp table and run callback at each 1571 * valid entry. Possible replacement of the matched entries. 1572 */ 1573 extern int bcm_l3_egress_ecmp_resilient_traverse( 1574 int unit, 1575 uint32 flags, 1576 bcm_l3_egress_ecmp_resilient_entry_t *match_entry, 1577 bcm_l3_egress_ecmp_resilient_traverse_cb trav_fn, 1578 void *user_data); 1579 1580 /* Replace ECMP resilient entries matching given criteria. */ 1581 extern int bcm_l3_egress_ecmp_resilient_replace( 1582 int unit, 1583 uint32 flags, 1584 bcm_l3_egress_ecmp_resilient_entry_t *match_entry, 1585 int *num_entries, 1586 bcm_l3_egress_ecmp_resilient_entry_t *replace_entry); 1587 1588 /* Add ECMP resilient entries matching given criteria. */ 1589 extern int bcm_l3_egress_ecmp_resilient_add( 1590 int unit, 1591 uint32 flags, 1592 bcm_l3_egress_ecmp_resilient_entry_t *entry); 1593 1594 /* Delete ECMP resilient entries matching given criteria. */ 1595 extern int bcm_l3_egress_ecmp_resilient_delete( 1596 int unit, 1597 uint32 flags, 1598 bcm_l3_egress_ecmp_resilient_entry_t *entry); 1599 1600 #endif /* BCM_HIDE_DISPATCHABLE */ 1601 1602 /* Initialize L3 Ingress Interface object structure. */ 1603 extern void bcm_l3_ingress_t_init( 1604 bcm_l3_ingress_t *ing_intf); 1605 1606 #ifndef BCM_HIDE_DISPATCHABLE 1607 1608 /* Create L3 Ingress Interface object. */ 1609 extern int bcm_l3_ingress_create( 1610 int unit, 1611 bcm_l3_ingress_t *ing_intf, 1612 bcm_if_t *intf_id); 1613 1614 /* Destroy L3 Ingress Interface object. */ 1615 extern int bcm_l3_ingress_destroy( 1616 int unit, 1617 bcm_if_t intf_id); 1618 1619 /* Get an Ingress Interface object. */ 1620 extern int bcm_l3_ingress_get( 1621 int unit, 1622 bcm_if_t intf, 1623 bcm_l3_ingress_t *ing_intf); 1624 1625 /* Find an interface pointing to an Ingress Interface object. */ 1626 extern int bcm_l3_ingress_find( 1627 int unit, 1628 bcm_l3_ingress_t *ing_intf, 1629 bcm_if_t *intf_id); 1630 1631 /* 1632 * Goes through ingress interface objects table and runs the user 1633 * callback 1634 * function at each valid ingress object entry passing back the 1635 * information for that object. 1636 */ 1637 extern int bcm_l3_ingress_traverse( 1638 int unit, 1639 bcm_l3_ingress_traverse_cb trav_fn, 1640 void *user_data); 1641 1642 #endif /* BCM_HIDE_DISPATCHABLE */ 1643 1644 /* Initialize a bcm_l3_host_t structure */ 1645 extern void bcm_l3_host_t_init( 1646 bcm_l3_host_t *ip); 1647 1648 #ifndef BCM_HIDE_DISPATCHABLE 1649 1650 /* Look up an L3 host table entry based on IP address. */ 1651 extern int bcm_l3_host_find( 1652 int unit, 1653 bcm_l3_host_t *info); 1654 1655 /* Add an entry into the L3 switching table. */ 1656 extern int bcm_l3_host_add( 1657 int unit, 1658 bcm_l3_host_t *info); 1659 1660 /* Delete an entry from the L3 host table. */ 1661 extern int bcm_l3_host_delete( 1662 int unit, 1663 bcm_l3_host_t *ip_addr); 1664 1665 /* Delete L3 entries based on IP prefix (network). */ 1666 extern int bcm_l3_host_delete_by_network( 1667 int unit, 1668 bcm_l3_route_t *ip_addr); 1669 1670 /* 1671 * Deletes L3 entries that match or do not match a specified L3 interface 1672 * number 1673 */ 1674 extern int bcm_l3_host_delete_by_interface( 1675 int unit, 1676 bcm_l3_host_t *info); 1677 1678 /* Deletes all L3 host table entries. */ 1679 extern int bcm_l3_host_delete_all( 1680 int unit, 1681 bcm_l3_host_t *info); 1682 1683 /* Return list of conflicts in the L3 table. */ 1684 extern int bcm_l3_host_conflict_get( 1685 int unit, 1686 bcm_l3_key_t *ipkey, 1687 bcm_l3_key_t *cf_array, 1688 int cf_max, 1689 int *cf_count); 1690 1691 /* Run L3 table aging */ 1692 extern int bcm_l3_host_age( 1693 int unit, 1694 uint32 flags, 1695 bcm_l3_host_traverse_cb age_cb, 1696 void *user_data); 1697 1698 /* Traverse through the L3 table and run callback at each valid L3 entry. */ 1699 extern int bcm_l3_host_traverse( 1700 int unit, 1701 uint32 flags, 1702 uint32 start, 1703 uint32 end, 1704 bcm_l3_host_traverse_cb cb, 1705 void *user_data); 1706 1707 /* Invalidate L3 entry without clearing so it can be re-validated later. */ 1708 extern int bcm_l3_host_invalidate_entry( 1709 int unit, 1710 bcm_ip_t info); 1711 1712 /* Invalidate L3 entry without clearing so it can be re-validated later. */ 1713 extern int bcm_l3_host_validate_entry( 1714 int unit, 1715 bcm_ip_t info); 1716 1717 #endif /* BCM_HIDE_DISPATCHABLE */ 1718 1719 /* Initialize a bcm_l3_route_t structure. */ 1720 extern void bcm_l3_route_t_init( 1721 bcm_l3_route_t *route); 1722 1723 #ifndef BCM_HIDE_DISPATCHABLE 1724 1725 /* Add an IP route to the L3 route table. */ 1726 extern int bcm_l3_route_add( 1727 int unit, 1728 bcm_l3_route_t *info); 1729 1730 /* Delete an IP route from the DEFIP table. */ 1731 extern int bcm_l3_route_delete( 1732 int unit, 1733 bcm_l3_route_t *info); 1734 1735 /* Delete routes based on matching or non-matching L3 interface number. */ 1736 extern int bcm_l3_route_delete_by_interface( 1737 int unit, 1738 bcm_l3_route_t *info); 1739 1740 /* Delete all routes. */ 1741 extern int bcm_l3_route_delete_all( 1742 int unit, 1743 bcm_l3_route_t *info); 1744 1745 /* Look up a route given the network and netmask. */ 1746 extern int bcm_l3_route_get( 1747 int unit, 1748 bcm_l3_route_t *info); 1749 1750 /* Given a network, return all the paths for this route. */ 1751 extern int bcm_l3_route_multipath_get( 1752 int unit, 1753 bcm_l3_route_t *the_route, 1754 bcm_l3_route_t *path_array, 1755 int max_path, 1756 int *path_count); 1757 1758 /* Age the route table. */ 1759 extern int bcm_l3_route_age( 1760 int unit, 1761 uint32 flags, 1762 bcm_l3_route_traverse_cb age_out, 1763 void *user_data); 1764 1765 /* Traverse through the routing table and run callback at each route. */ 1766 extern int bcm_l3_route_traverse( 1767 int unit, 1768 uint32 flags, 1769 uint32 start, 1770 uint32 end, 1771 bcm_l3_route_traverse_cb trav_fn, 1772 void *user_data); 1773 1774 /* 1775 * Set the maximum ECMP paths allowed for a route (StrataXGS only). 1776 * For optimized Resilient Hashing, maximum ECMP paths is a dummy 1777 * variable. 1778 */ 1779 extern int bcm_l3_route_max_ecmp_set( 1780 int unit, 1781 int max); 1782 1783 /* Get the maximum ECMP paths allowed for a route (StrataXGS only). */ 1784 extern int bcm_l3_route_max_ecmp_get( 1785 int unit, 1786 int *max); 1787 1788 /* Set flex counter object value for the given L3 unicast route. */ 1789 extern int bcm_l3_route_flexctr_object_set( 1790 int unit, 1791 bcm_l3_route_t *info, 1792 uint32 value); 1793 1794 /* Get flex counter object value for the given L3 unicast route. */ 1795 extern int bcm_l3_route_flexctr_object_get( 1796 int unit, 1797 bcm_l3_route_t *info, 1798 uint32 *value); 1799 1800 /* 1801 * Extract list of IPv6 prefixes which are forwarded based on lower 32 1802 * bit of IPv6 address, treated as IPv4 address. 1803 */ 1804 extern int bcm_l3_ip6_prefix_map_get( 1805 int unit, 1806 int map_size, 1807 bcm_ip6_t *ip6_array, 1808 int *ip6_count); 1809 1810 /* 1811 * Add IPv6 prefix to the list of prefixes which are forwarded based on 1812 * lower 32-bit of IPv6 address, treated as IPv4 address. 1813 */ 1814 extern int bcm_l3_ip6_prefix_map_add( 1815 int unit, 1816 bcm_ip6_t ip6_addr); 1817 1818 /* 1819 * Remove IPv6 prefix from the list of prefixes which are forwarded based 1820 * on lower 32-bit of IPv6 address, treated as IPv4 address. 1821 */ 1822 extern int bcm_l3_ip6_prefix_map_delete( 1823 int unit, 1824 bcm_ip6_t ip6_addr); 1825 1826 /* 1827 * Remove all the IPv6 prefixes from the list of prefixes which are 1828 * forwarded based on lower 32-bit of IPv6 address, treated as IPv4 1829 * address. 1830 */ 1831 extern int bcm_l3_ip6_prefix_map_delete_all( 1832 int unit); 1833 1834 #endif /* BCM_HIDE_DISPATCHABLE */ 1835 1836 /* bcm_l3_age_cb */ 1837 typedef void (*bcm_l3_age_cb)( 1838 int unit, 1839 bcm_ip_t ip); 1840 1841 /* Initialize a bcm_l3_key_t_init structure. */ 1842 extern void bcm_l3_key_t_init( 1843 bcm_l3_key_t *key); 1844 1845 /* Initialize a bcm_l3_info_t_init structure. */ 1846 extern void bcm_l3_info_t_init( 1847 bcm_l3_info_t *info); 1848 1849 /* Types of counters per L3 object. */ 1850 typedef enum bcm_l3_stat_e { 1851 bcmL3StatOutPackets = 0, 1852 bcmL3StatOutBytes = 1, 1853 bcmL3StatDropPackets = 2, 1854 bcmL3StatDropBytes = 3, 1855 bcmL3StatInPackets = 4, 1856 bcmL3StatInBytes = 5 1857 } bcm_l3_stat_t; 1858 1859 #ifndef BCM_HIDE_DISPATCHABLE 1860 1861 /* Get L3 route statistics. */ 1862 extern int bcm_l3_route_stat_get( 1863 int unit, 1864 bcm_l3_route_t *route, 1865 bcm_l3_stat_t stat, 1866 uint64 *val); 1867 1868 /* Get L3 route statistics. */ 1869 extern int bcm_l3_route_stat_get32( 1870 int unit, 1871 bcm_l3_route_t *route, 1872 bcm_l3_stat_t stat, 1873 uint32 *val); 1874 1875 /* Set L3 route statistics. */ 1876 extern int bcm_l3_route_stat_set( 1877 int unit, 1878 bcm_l3_route_t *route, 1879 bcm_l3_stat_t stat, 1880 uint64 val); 1881 1882 /* Set L3 route statistics. */ 1883 extern int bcm_l3_route_stat_set32( 1884 int unit, 1885 bcm_l3_route_t *route, 1886 bcm_l3_stat_t stat, 1887 uint32 val); 1888 1889 /* Enable/disable collection of statistics for the indicated L3 route. */ 1890 extern int bcm_l3_route_stat_enable_set( 1891 int unit, 1892 bcm_l3_route_t *route, 1893 int enable); 1894 1895 #endif /* BCM_HIDE_DISPATCHABLE */ 1896 1897 /* Maximum L3 ALPM levels */ 1898 #define BCM_L3_ALPM_LEVELS 3 /* Maximum L3 ALPM levels */ 1899 1900 /* This enum defines L3 ALPM IP types. */ 1901 typedef enum bcm_l3_alpm_ipt_e { 1902 bcmL3AlpmIptV4 = 0, /* L3 ALPM IPv4 type */ 1903 bcmL3AlpmIptV6 = 1, /* L3 ALPM IPv6 type */ 1904 bcmL3AlpmIptCount = 2, /* Total count of L3 ALPM IP types */ 1905 bcmL3AlpmIptAll = 3 /* Represent all L3 ALPM IP types */ 1906 } bcm_l3_alpm_ipt_t; 1907 1908 /* This enum defines L3 ALPM route groups. */ 1909 typedef enum bcm_l3_route_group_e { 1910 bcmL3RouteGroupPrivateV4 = 0, /* L3 IPv4 UC private VRF route group */ 1911 bcmL3RouteGroupGlobalV4 = 1, /* L3 IPv4 UC global low route group */ 1912 bcmL3RouteGroupOverrideV4 = 2, /* L3 IPv4 UC override (global high) route 1913 group */ 1914 bcmL3RouteGroupPrivateV6 = 3, /* L3 IPv6 UC private VRF route group */ 1915 bcmL3RouteGroupGlobalV6 = 4, /* L3 IPv6 UC global low route group */ 1916 bcmL3RouteGroupOverrideV6 = 5, /* L3 IPv6 UC override (global high) route 1917 group */ 1918 bcmL3RouteGroupCounter /* L3 ALPM route group counter. This is not 1919 a group and should always be in the last */ 1920 } bcm_l3_route_group_t; 1921 1922 /* L3 ALPM per-level resource usage information structure. */ 1923 typedef struct bcm_l3_alpm_lvl_usage_s { 1924 int cnt_used; /* used TCAM entry or bucket bank counter. */ 1925 int cnt_total; /* total TCAM entry or bucket bank counter. */ 1926 } bcm_l3_alpm_lvl_usage_t; 1927 1928 /* L3 ALPM route counter and resource usages structure. */ 1929 typedef struct bcm_l3_alpm_resource_s { 1930 int route_cnt; /* installed route number. */ 1931 bcm_l3_alpm_lvl_usage_t lvl_usage[BCM_L3_ALPM_LEVELS]; /* ALPM level usage array. */ 1932 } bcm_l3_alpm_resource_t; 1933 1934 #ifndef BCM_HIDE_DISPATCHABLE 1935 1936 /* 1937 * Get current ALPM route number and resource usage counters for a 1938 * specific route group. 1939 */ 1940 extern int bcm_l3_alpm_resource_get( 1941 int unit, 1942 bcm_l3_route_group_t grp, 1943 bcm_l3_alpm_resource_t *resource); 1944 1945 /* Check ALPM routes sanity and detect hw/sw mismatch. */ 1946 extern int bcm_l3_alpm_sanity_check( 1947 int unit, 1948 int chk_type); 1949 1950 #endif /* BCM_HIDE_DISPATCHABLE */ 1951 1952 /* Return values from ALPM route trace message write callout routine. */ 1953 typedef enum bcm_l3_alpm_trace_e { 1954 BCM_L3_ALPM_TRACE_WRITE_OK = 0, /* ALPM route trace message write 1955 successful. */ 1956 BCM_L3_ALPM_TRACE_WRITE_FAIL = -1 /* ALPM route trace message write 1957 failed. */ 1958 } bcm_l3_alpm_trace_t; 1959 1960 /* Callback function type for applications using ALPM trace facility. */ 1961 typedef bcm_l3_alpm_trace_t (*bcm_l3_alpm_trace_cb_f)( 1962 int unit, 1963 char *trace_msg, 1964 void *user_data); 1965 1966 #ifndef BCM_HIDE_DISPATCHABLE 1967 1968 /* 1969 * Register ALPM trace callback for route insertion, update or delete. 1970 * Only one callback (the most recent) is allowed per unit. 1971 */ 1972 extern int bcm_l3_alpm_trace_cb_register( 1973 int unit, 1974 bcm_l3_alpm_trace_cb_f write_cb, 1975 void *user_data); 1976 1977 /* Unregister ALPM trace callback for route insertion, update or delete. */ 1978 extern int bcm_l3_alpm_trace_cb_unregister( 1979 int unit, 1980 bcm_l3_alpm_trace_cb_f write_cb); 1981 1982 #endif /* BCM_HIDE_DISPATCHABLE */ 1983 1984 /* 1985 * This enum defines ALPM route associated data modes that are maintained 1986 * per L3 VRF. 1987 */ 1988 typedef enum bcm_l3_vrf_route_data_mode_e { 1989 bcmL3VrfRouteDataModeReduced = 0, /* Reduced ALPM route associated data 1990 mode on the L3 VRF */ 1991 bcmL3VrfRouteDataModeFull = 1 /* Full ALPM route associated data mode 1992 on the L3 VRF */ 1993 } bcm_l3_vrf_route_data_mode_t; 1994 1995 #ifndef BCM_HIDE_DISPATCHABLE 1996 1997 /* Get current ALPM route data mode for the selected VRF and IP type. */ 1998 extern int bcm_l3_vrf_route_data_mode_get( 1999 int unit, 2000 bcm_vrf_t vrf, 2001 uint32 flags, 2002 bcm_l3_vrf_route_data_mode_t *mode); 2003 2004 /* Set ALPM route data mode for the selected VRF and IP type. */ 2005 extern int bcm_l3_vrf_route_data_mode_set( 2006 int unit, 2007 bcm_vrf_t vrf, 2008 uint32 flags, 2009 bcm_l3_vrf_route_data_mode_t mode); 2010 2011 #endif /* BCM_HIDE_DISPATCHABLE */ 2012 2013 /* Types of statistics that are maintained per L3 VRF. */ 2014 typedef enum bcm_l3_vrf_stat_e { 2015 bcmL3VrfStatIngressPackets = 0, /* Packets that ingress on the L3 VRF */ 2016 bcmL3VrfStatIngressBytes = 1 /* Bytes that ingress on the L3 VRF */ 2017 } bcm_l3_vrf_stat_t; 2018 2019 #ifndef BCM_HIDE_DISPATCHABLE 2020 2021 /* Enable/disable packet and byte counters for the selected VRF. */ 2022 extern int bcm_l3_vrf_stat_enable_set( 2023 int unit, 2024 bcm_vrf_t vrf, 2025 int enable); 2026 2027 /* Get L3 VRF counter value for specified VRF statistic type. */ 2028 extern int bcm_l3_vrf_stat_get( 2029 int unit, 2030 bcm_vrf_t vrf, 2031 bcm_l3_vrf_stat_t stat, 2032 uint64 *val); 2033 2034 /* 2035 * Force an immediate counter update and retrieve L3 VRF counter value 2036 * for 2037 * specified VRF statistic type. 2038 */ 2039 extern int bcm_l3_vrf_stat_sync_get( 2040 int unit, 2041 bcm_vrf_t vrf, 2042 bcm_l3_vrf_stat_t stat, 2043 uint64 *val); 2044 2045 /* Get L3 VRF counter value for specified VRF statistic type. */ 2046 extern int bcm_l3_vrf_stat_get32( 2047 int unit, 2048 bcm_vrf_t vrf, 2049 bcm_l3_vrf_stat_t stat, 2050 uint32 *val); 2051 2052 /* 2053 * Force an immediate counter update and retrieve L3 VRF counter value 2054 * for 2055 * specified VRF statistic type. 2056 */ 2057 extern int bcm_l3_vrf_stat_sync_get32( 2058 int unit, 2059 bcm_vrf_t vrf, 2060 bcm_l3_vrf_stat_t stat, 2061 uint32 *val); 2062 2063 /* Get stat counter ID associated with given vrf. */ 2064 extern int bcm_l3_vrf_stat_id_get( 2065 int unit, 2066 bcm_vrf_t vrf, 2067 bcm_l3_vrf_stat_t stat, 2068 uint32 *stat_counter_id); 2069 2070 /* Set L3 VRF counter value for specified VRF statistic type. */ 2071 extern int bcm_l3_vrf_stat_set( 2072 int unit, 2073 bcm_vrf_t vrf, 2074 bcm_l3_vrf_stat_t stat, 2075 uint64 val); 2076 2077 /* Set L3 VRF counter value for specified VRF statistic type. */ 2078 extern int bcm_l3_vrf_stat_set32( 2079 int unit, 2080 bcm_vrf_t vrf, 2081 bcm_l3_vrf_stat_t stat, 2082 uint32 val); 2083 2084 /* Get L3 VRF counter value for multiple VRF statistic types. */ 2085 extern int bcm_l3_vrf_stat_multi_get( 2086 int unit, 2087 bcm_vrf_t vrf, 2088 int nstat, 2089 bcm_l3_vrf_stat_t *stat_arr, 2090 uint64 *value_arr); 2091 2092 /* Get L3 VRF counter value for multiple VRF statistic types. */ 2093 extern int bcm_l3_vrf_stat_multi_get32( 2094 int unit, 2095 bcm_vrf_t vrf, 2096 int nstat, 2097 bcm_l3_vrf_stat_t *stat_arr, 2098 uint32 *value_arr); 2099 2100 /* Set L3 VRF counter value for multiple VRF statistic types. */ 2101 extern int bcm_l3_vrf_stat_multi_set( 2102 int unit, 2103 bcm_vrf_t vrf, 2104 int nstat, 2105 bcm_l3_vrf_stat_t *stat_arr, 2106 uint64 *value_arr); 2107 2108 /* Set L3 VRF counter value for multiple VRF statistic types. */ 2109 extern int bcm_l3_vrf_stat_multi_set32( 2110 int unit, 2111 bcm_vrf_t vrf, 2112 int nstat, 2113 bcm_l3_vrf_stat_t *stat_arr, 2114 uint32 *value_arr); 2115 2116 #endif /* BCM_HIDE_DISPATCHABLE */ 2117 2118 #define BCM_L3_SOURCE_BIND_IP6 0x00000001 2119 #define BCM_L3_SOURCE_BIND_REPLACE 0x00000002 2120 #define BCM_L3_SOURCE_BIND_USE_MASK 0x00000004 2121 #define BCM_L3_SOURCE_BIND_PPPoE 0x00000008 2122 2123 /* L3 source binding information structure. */ 2124 typedef struct bcm_l3_source_bind_s { 2125 uint32 flags; /* BCM_L3_SOURCE_BIND_xxx flags. */ 2126 bcm_gport_t port; /* Source module and port, BCM_GPORT_INVALID 2127 to wildcard. */ 2128 bcm_ip_t ip; /* Source IPv4 address. */ 2129 bcm_ip6_t ip6; /* Source IPv6 address. */ 2130 bcm_mac_t mac; /* Source MAC address. */ 2131 bcm_ipfix_rate_id_t rate_id; /* IPFIX rate ID */ 2132 bcm_ip_t ip_mask; /* IP subnet mask (IPv4). */ 2133 bcm_ip6_t ip6_mask; /* IP subnet mask (IPv6). */ 2134 uint32 session_id; /* PPPoE session ID. */ 2135 } bcm_l3_source_bind_t; 2136 2137 /* Initialize a bcm_l3_source_bind_t structure. */ 2138 extern void bcm_l3_source_bind_t_init( 2139 bcm_l3_source_bind_t *info); 2140 2141 #ifndef BCM_HIDE_DISPATCHABLE 2142 2143 /* Enable or disable l3 source binding checks on an ingress port. */ 2144 extern int bcm_l3_source_bind_enable_set( 2145 int unit, 2146 bcm_port_t port, 2147 int enable); 2148 2149 /* 2150 * Retrieve whether l3 source binding checks are performed on an 2151 * ingress port. 2152 */ 2153 extern int bcm_l3_source_bind_enable_get( 2154 int unit, 2155 bcm_port_t port, 2156 int *enable); 2157 2158 /* Add or replace an L3 source binding. */ 2159 extern int bcm_l3_source_bind_add( 2160 int unit, 2161 bcm_l3_source_bind_t *info); 2162 2163 /* Remove an existing L3 source binding. */ 2164 extern int bcm_l3_source_bind_delete( 2165 int unit, 2166 bcm_l3_source_bind_t *info); 2167 2168 /* Remove all existing L3 source bindings. */ 2169 extern int bcm_l3_source_bind_delete_all( 2170 int unit); 2171 2172 /* Retrieve the details of an existing L3 source binding. */ 2173 extern int bcm_l3_source_bind_get( 2174 int unit, 2175 bcm_l3_source_bind_t *info); 2176 2177 #endif /* BCM_HIDE_DISPATCHABLE */ 2178 2179 typedef int (*bcm_l3_source_bind_traverse_cb)( 2180 int unit, 2181 bcm_l3_source_bind_t *info, 2182 void *user_data); 2183 2184 #ifndef BCM_HIDE_DISPATCHABLE 2185 2186 /* 2187 * Traverse through the L3 source bindings and run callback at each 2188 * defined binding. 2189 */ 2190 extern int bcm_l3_source_bind_traverse( 2191 int unit, 2192 bcm_l3_source_bind_traverse_cb cb, 2193 void *user_data); 2194 2195 /* 2196 * Add VRID for the given VSI. Adding a VRID using this API means the 2197 * physical node has become the master for the virtual router 2198 */ 2199 extern int bcm_l3_vrrp_add( 2200 int unit, 2201 bcm_vlan_t vlan, 2202 uint32 vrid); 2203 2204 /* Delete VRID for a particular VLAN/VSI */ 2205 extern int bcm_l3_vrrp_delete( 2206 int unit, 2207 bcm_vlan_t vlan, 2208 uint32 vrid); 2209 2210 /* Delete all the VRIDs for a particular VLAN/VSI */ 2211 extern int bcm_l3_vrrp_delete_all( 2212 int unit, 2213 bcm_vlan_t vlan); 2214 2215 /* 2216 * Get all the VRIDs for which the physical node is master for the 2217 * virtual routers on the given VLAN/VSI 2218 */ 2219 extern int bcm_l3_vrrp_get( 2220 int unit, 2221 bcm_vlan_t vlan, 2222 int alloc_size, 2223 int *vrid_array, 2224 int *count); 2225 2226 /* Attach counters entries to the given VRF. */ 2227 extern int bcm_l3_vrf_stat_attach( 2228 int unit, 2229 bcm_vrf_t vrf, 2230 uint32 stat_counter_id); 2231 2232 /* Detach counters entries to the given VRF. */ 2233 extern int bcm_l3_vrf_stat_detach( 2234 int unit, 2235 bcm_vrf_t vrf); 2236 2237 /* Get L3 VRF counter value for specified VRF statistic type */ 2238 extern int bcm_l3_vrf_stat_counter_get( 2239 int unit, 2240 bcm_vrf_t vrf, 2241 bcm_l3_vrf_stat_t stat, 2242 uint32 num_entries, 2243 uint32 *counter_indexes, 2244 bcm_stat_value_t *counter_values); 2245 2246 /* 2247 * Force an immediate counter update and retrieve L3 VRF counter value 2248 * for 2249 * specified VRF statistic type 2250 */ 2251 extern int bcm_l3_vrf_stat_counter_sync_get( 2252 int unit, 2253 bcm_vrf_t vrf, 2254 bcm_l3_vrf_stat_t stat, 2255 uint32 num_entries, 2256 uint32 *counter_indexes, 2257 bcm_stat_value_t *counter_values); 2258 2259 /* Set L3 VRF counter value for specified VRF statistic type */ 2260 extern int bcm_l3_vrf_stat_counter_set( 2261 int unit, 2262 bcm_vrf_t vrf, 2263 bcm_l3_vrf_stat_t stat, 2264 uint32 num_entries, 2265 uint32 *counter_indexes, 2266 bcm_stat_value_t *counter_values); 2267 2268 /* Attach counters entries to the given L3 Egress interface. */ 2269 extern int bcm_l3_egress_stat_attach( 2270 int unit, 2271 bcm_if_t intf_id, 2272 uint32 stat_counter_id); 2273 2274 /* Detach counters entries to the given L3 Egress interface. */ 2275 extern int bcm_l3_egress_stat_detach( 2276 int unit, 2277 bcm_if_t intf_id); 2278 2279 /* Get the specified counter statistic for a L3 egress interface. */ 2280 extern int bcm_l3_egress_stat_counter_get( 2281 int unit, 2282 bcm_if_t intf_id, 2283 bcm_l3_stat_t stat, 2284 uint32 num_entries, 2285 uint32 *counter_indexes, 2286 bcm_stat_value_t *counter_values); 2287 2288 /* 2289 * Force an immediate counter update and retrieve the specified counter 2290 * statistic for a L3 egress interface. 2291 */ 2292 extern int bcm_l3_egress_stat_counter_sync_get( 2293 int unit, 2294 bcm_if_t intf_id, 2295 bcm_l3_stat_t stat, 2296 uint32 num_entries, 2297 uint32 *counter_indexes, 2298 bcm_stat_value_t *counter_values); 2299 2300 /* Get stat counter ID associated with given L3 Egress interface. */ 2301 extern int bcm_l3_egress_stat_id_get( 2302 int unit, 2303 bcm_if_t intf_id, 2304 bcm_l3_stat_t stat, 2305 uint32 *stat_counter_id); 2306 2307 /* Set the specified counter statistic for a L3 egress interface. */ 2308 extern int bcm_l3_egress_stat_counter_set( 2309 int unit, 2310 bcm_if_t intf_id, 2311 bcm_l3_stat_t stat, 2312 uint32 num_entries, 2313 uint32 *counter_indexes, 2314 bcm_stat_value_t *counter_values); 2315 2316 /* Set flex counter object value for the given egress object. */ 2317 extern int bcm_l3_egress_flexctr_object_set( 2318 int unit, 2319 bcm_if_t intf_id, 2320 uint32 value); 2321 2322 /* Get flex counter object value for the given egress object. */ 2323 extern int bcm_l3_egress_flexctr_object_get( 2324 int unit, 2325 bcm_if_t intf_id, 2326 uint32 *value); 2327 2328 /* Attach counters entries to the given L3 ingress interface. */ 2329 extern int bcm_l3_ingress_stat_attach( 2330 int unit, 2331 bcm_if_t intf_id, 2332 uint32 stat_counter_id); 2333 2334 /* Detach counters entries to the given L3 ingress interface. */ 2335 extern int bcm_l3_ingress_stat_detach( 2336 int unit, 2337 bcm_if_t intf_id); 2338 2339 /* Get counter statistic values for a l3 interface object. */ 2340 extern int bcm_l3_ingress_stat_counter_get( 2341 int unit, 2342 bcm_if_t intf_id, 2343 bcm_l3_stat_t stat, 2344 uint32 num_entries, 2345 uint32 *counter_indexes, 2346 bcm_stat_value_t *counter_values); 2347 2348 /* Get counter statistic values for a l3 interface object. */ 2349 extern int bcm_l3_ingress_stat_counter_sync_get( 2350 int unit, 2351 bcm_if_t intf_id, 2352 bcm_l3_stat_t stat, 2353 uint32 num_entries, 2354 uint32 *counter_indexes, 2355 bcm_stat_value_t *counter_values); 2356 2357 /* Get stat counter ID associated with given L3 ingress interface. */ 2358 extern int bcm_l3_ingress_stat_id_get( 2359 int unit, 2360 bcm_if_t intf_id, 2361 bcm_l3_stat_t stat, 2362 uint32 *stat_counter_id); 2363 2364 /* Set counter statistic values for a l3 interface object. */ 2365 extern int bcm_l3_ingress_stat_counter_set( 2366 int unit, 2367 bcm_if_t intf_id, 2368 bcm_l3_stat_t stat, 2369 uint32 num_entries, 2370 uint32 *counter_indexes, 2371 bcm_stat_value_t *counter_values); 2372 2373 /* Attach counters entries to the given L3 host entry */ 2374 extern int bcm_l3_host_stat_attach( 2375 int unit, 2376 bcm_l3_host_t *info, 2377 uint32 stat_counter_id); 2378 2379 /* Detach counters entries to the given L3 host entry */ 2380 extern int bcm_l3_host_stat_detach( 2381 int unit, 2382 bcm_l3_host_t *info); 2383 2384 /* Get the specified counter statistic for a L3 host entry. */ 2385 extern int bcm_l3_host_stat_counter_get( 2386 int unit, 2387 bcm_l3_host_t *info, 2388 bcm_l3_stat_t stat, 2389 uint32 num_entries, 2390 uint32 *counter_indexes, 2391 bcm_stat_value_t *counter_values); 2392 2393 /* 2394 * Force an immediate counter update and retrieve the specified counter 2395 * statistic for a L3 host entry. 2396 */ 2397 extern int bcm_l3_host_stat_counter_sync_get( 2398 int unit, 2399 bcm_l3_host_t *info, 2400 bcm_l3_stat_t stat, 2401 uint32 num_entries, 2402 uint32 *counter_indexes, 2403 bcm_stat_value_t *counter_values); 2404 2405 /* Set the specified counter statistic for a L3 host entry */ 2406 extern int bcm_l3_host_stat_counter_set( 2407 int unit, 2408 bcm_l3_host_t *info, 2409 bcm_l3_stat_t stat, 2410 uint32 num_entries, 2411 uint32 *counter_indexes, 2412 bcm_stat_value_t *counter_values); 2413 2414 /* Provide stat counter ids associated with given L3 host entry */ 2415 extern int bcm_l3_host_stat_id_get( 2416 int unit, 2417 bcm_l3_host_t *info, 2418 bcm_l3_stat_t stat, 2419 uint32 *stat_counter_id); 2420 2421 #endif /* BCM_HIDE_DISPATCHABLE */ 2422 2423 /* L3 VRRP Flags. */ 2424 #define BCM_L3_VRRP_IPV4 0x00000001 /* VRID for IPV4 */ 2425 #define BCM_L3_VRRP_IPV6 0x00000002 /* VRID for IPV6 */ 2426 #define BCM_L3_VRRP_EXTENDED 0x00000004 /* Indicate extended memory usage for 2427 VRID */ 2428 2429 #ifndef BCM_HIDE_DISPATCHABLE 2430 2431 /* 2432 * Add VRID for the given VSI. VRID can be for IPV4 or for IPV6 (if VRRP 2433 * mode supports IPV6). 2434 * Adding a VRID using this API means the physical node has become the 2435 * master for the virtual router 2436 */ 2437 extern int bcm_l3_vrrp_config_add( 2438 int unit, 2439 uint32 flags, 2440 bcm_vlan_t vlan, 2441 uint32 vrid); 2442 2443 /* Delete VRID for a particular VLAN/VSI, either for IPV4 or for IPV6 */ 2444 extern int bcm_l3_vrrp_config_delete( 2445 int unit, 2446 uint32 flags, 2447 bcm_vlan_t vlan, 2448 uint32 vrid); 2449 2450 /* Delete all the VRIDs for a particular VLAN/VSI */ 2451 extern int bcm_l3_vrrp_config_delete_all( 2452 int unit, 2453 uint32 flags, 2454 bcm_vlan_t vlan); 2455 2456 /* 2457 * Get all the VRIDs for which the physical node is master for the 2458 * virtual routers on the given VLAN/VSI 2459 */ 2460 extern int bcm_l3_vrrp_config_get( 2461 int unit, 2462 uint32 flags, 2463 bcm_vlan_t vlan, 2464 uint32 alloc_size, 2465 uint32 *vrid_array, 2466 uint32 *count); 2467 2468 #endif /* BCM_HIDE_DISPATCHABLE */ 2469 2470 /* L3 Route statistics maintained per route. */ 2471 typedef enum bcm_l3_route_stat_e { 2472 bcmL3RouteInPackets = 0, /* Packets that ingress on the l3 route */ 2473 bcmL3RouteInBytes = 1 /* Bytes that ingress on the l3 route */ 2474 } bcm_l3_route_stat_t; 2475 2476 #ifndef BCM_HIDE_DISPATCHABLE 2477 2478 /* Attach counters entries to the given L3 route index */ 2479 extern int bcm_l3_route_stat_attach( 2480 int unit, 2481 bcm_l3_route_t *info, 2482 uint32 stat_counter_id); 2483 2484 /* Detach counters entries to the given L3 route index. */ 2485 extern int bcm_l3_route_stat_detach( 2486 int unit, 2487 bcm_l3_route_t *info); 2488 2489 /* Get counter statistic values for a l3 route index. */ 2490 extern int bcm_l3_route_stat_counter_get( 2491 int unit, 2492 bcm_l3_route_t *info, 2493 bcm_l3_route_stat_t stat, 2494 uint32 num_entries, 2495 uint32 *counter_indexes, 2496 bcm_stat_value_t *counter_values); 2497 2498 /* 2499 * Force an immediate counter update and retrieve counter statistic 2500 * values for a l3 route index. 2501 */ 2502 extern int bcm_l3_route_stat_counter_sync_get( 2503 int unit, 2504 bcm_l3_route_t *info, 2505 bcm_l3_route_stat_t stat, 2506 uint32 num_entries, 2507 uint32 *counter_indexes, 2508 bcm_stat_value_t *counter_values); 2509 2510 /* Set counter statistic values for a l3 route index */ 2511 extern int bcm_l3_route_stat_counter_set( 2512 int unit, 2513 bcm_l3_route_t *info, 2514 bcm_l3_route_stat_t stat, 2515 uint32 num_entries, 2516 uint32 *counter_indexes, 2517 bcm_stat_value_t *counter_values); 2518 2519 /* Get multiple counter statistic values for multiple l3 route index. */ 2520 extern int bcm_l3_route_stat_multi_get( 2521 int unit, 2522 bcm_l3_route_t *info, 2523 int nstat, 2524 bcm_l3_route_stat_t *stat_arr, 2525 uint64 *value_arr); 2526 2527 /* 2528 * Get 32bit multiple counter statistic values for multiple l3 route 2529 * index. 2530 */ 2531 extern int bcm_l3_route_stat_multi_get32( 2532 int unit, 2533 bcm_l3_route_t *info, 2534 int nstat, 2535 bcm_l3_route_stat_t *stat_arr, 2536 uint32 *value_arr); 2537 2538 /* Set multiple counter statistic values for multiple l3 route index. */ 2539 extern int bcm_l3_route_stat_multi_set( 2540 int unit, 2541 bcm_l3_route_t *info, 2542 int nstat, 2543 bcm_l3_route_stat_t *stat_arr, 2544 uint64 *value_arr); 2545 2546 /* 2547 * Set 32bit multiple counter statistic values for multiple l3 route 2548 * index. 2549 */ 2550 extern int bcm_l3_route_stat_multi_set32( 2551 int unit, 2552 bcm_l3_route_t *info, 2553 int nstat, 2554 bcm_l3_route_stat_t *stat_arr, 2555 uint32 *value_arr); 2556 2557 /* Get stat counter ID associated with given L3 route index. */ 2558 extern int bcm_l3_route_stat_id_get( 2559 int unit, 2560 bcm_l3_route_t *info, 2561 bcm_l3_route_stat_t stat, 2562 uint32 *stat_counter_id); 2563 2564 #endif /* BCM_HIDE_DISPATCHABLE */ 2565 2566 /* L3 IP options Flags. */ 2567 #define BCM_L3_IP4_OPTIONS_WITH_ID 0x00000001 /* With ID option creation */ 2568 #define BCM_L3_IP4_OPTIONS_REPLACE 0x00000002 /* Replace existing entry */ 2569 2570 /* L3 IP options handing actions. */ 2571 typedef enum bcm_l3_ip4_options_action_e { 2572 bcmIntfIPOptionActionNone = 0, /* No action. */ 2573 bcmIntfIPOptionActionCopyToCPU = 1, /* Copy to CPU action. */ 2574 bcmIntfIPOptionActionDrop = 2, /* Drop action. */ 2575 bcmIntfIPOptionActionCopyCPUAndDrop = 3 /* Copy to CPU and Drop action. */ 2576 } bcm_l3_ip4_options_action_t; 2577 2578 #ifndef BCM_HIDE_DISPATCHABLE 2579 2580 /* Create a new L3 IP options handling profile. */ 2581 extern int bcm_l3_ip4_options_profile_create( 2582 int unit, 2583 uint32 flags, 2584 bcm_l3_ip4_options_action_t default_action, 2585 int *ip4_options_profile_id); 2586 2587 /* Delete an L3 IP options Profile */ 2588 extern int bcm_l3_ip4_options_profile_destroy( 2589 int unit, 2590 int ip4_options_profile_id); 2591 2592 /* Set Individual IP options action for a given IP option profile */ 2593 extern int bcm_l3_ip4_options_action_set( 2594 int unit, 2595 int ip4_options_profile_id, 2596 int ip4_option, 2597 bcm_l3_ip4_options_action_t action); 2598 2599 /* Get Individual IP options action for a given IP option profile */ 2600 extern int bcm_l3_ip4_options_action_get( 2601 int unit, 2602 int ip4_options_profile_id, 2603 int ip4_option, 2604 bcm_l3_ip4_options_action_t *action); 2605 2606 /* Find a longest prefix matched route given an IP address. */ 2607 extern int bcm_l3_route_find( 2608 int unit, 2609 bcm_l3_host_t *host, 2610 bcm_l3_route_t *route); 2611 2612 /* Find a longest prefix matched route given the ip and netmask. */ 2613 extern int bcm_l3_subnet_route_find( 2614 int unit, 2615 bcm_l3_route_t *input, 2616 bcm_l3_route_t *route); 2617 2618 #endif /* BCM_HIDE_DISPATCHABLE */ 2619 2620 /* L3 Multiple Egress Object related flags. */ 2621 #define BCM_L3_EGRESS_MULTI_WITH_ID (1 << 0) /* Create multiple egress objects 2622 with id. */ 2623 2624 /* Information to create multiple egress objects. */ 2625 typedef struct bcm_l3_egress_multi_info_s { 2626 uint32 flags; /* See BCM_L3_EGRESS_MULTI_XXX flag definitions. */ 2627 int number_of_elements; /* number of egress objects to allocate. */ 2628 } bcm_l3_egress_multi_info_t; 2629 2630 /* Initialize bcm_l3_egress_multi_info_t structure. */ 2631 extern void bcm_l3_egress_multi_info_t_init( 2632 bcm_l3_egress_multi_info_t *egress_multi_info); 2633 2634 #ifndef BCM_HIDE_DISPATCHABLE 2635 2636 /* Alloc/Create multiple L3 Egress Objects. */ 2637 extern int bcm_l3_egress_multi_alloc( 2638 int unit, 2639 bcm_l3_egress_multi_info_t egress_multi_info, 2640 bcm_if_t *base_egress_id); 2641 2642 /* Deallocates/frees multiple egress objects. */ 2643 extern int bcm_l3_egress_multi_free( 2644 int unit, 2645 bcm_if_t base_egress_id); 2646 2647 /* Set the VPN on a given L3 Egress interface. */ 2648 extern int bcm_l3_intf_vpn_set( 2649 int unit, 2650 bcm_if_t l3_intf_id, 2651 uint32 flags, 2652 bcm_vpn_t vpn); 2653 2654 /* Get the VLAN ID/VPN on a given L3 Egress overlay interface. */ 2655 extern int bcm_l3_intf_vpn_get( 2656 int unit, 2657 bcm_if_t l3_intf_id, 2658 uint32 *flags, 2659 bcm_vpn_t *vpn); 2660 2661 #endif /* BCM_HIDE_DISPATCHABLE */ 2662 2663 /* 2664 * L3 vPBR Structure. Contains information required for manipulating L3 2665 * vPBR table entries 2666 */ 2667 typedef struct bcm_l3_vpbr_entry_s { 2668 uint32 flags; /* See BCM_L3_VPBR_xxx flag definitions. */ 2669 int priority; /* Entry priority. */ 2670 bcm_vrf_t vrf; /* Virtual Router instance. */ 2671 bcm_vrf_t vrf_mask; 2672 bcm_ip_t sip_addr; /* Source IP address (IPv4). */ 2673 bcm_ip_t sip_addr_mask; 2674 bcm_ip_t dip_addr; /* Destination IP address (IPv4). */ 2675 bcm_ip_t dip_addr_mask; 2676 bcm_ip6_t sip6_addr; /* Destination IP address (IPv6). */ 2677 bcm_ip6_t sip6_addr_mask; 2678 bcm_ip6_t dip6_addr; /* Destination IP address (IPv6). */ 2679 bcm_ip6_t dip6_addr_mask; 2680 int dscp; /* DSCP value */ 2681 int dscp_mask; 2682 uint32 src_port; /* TCP/UDP src port. */ 2683 uint32 src_port_mask; 2684 uint32 dst_port; /* TCP/UDP dst port. */ 2685 uint32 dst_port_mask; 2686 bcm_vrf_t new_vrf; /* The new result Virtual Router instance. */ 2687 bcm_if_t l3_intf_id; /* The relevant incoming interface . */ 2688 bcm_if_t l3_intf_id_mask; 2689 uint8 ip_protocol; /* IP protocol field. */ 2690 uint8 ip_protocol_mask; /* IP protocol field mask. */ 2691 } bcm_l3_vpbr_entry_t; 2692 2693 /* Initialize a bcm_l3_vpbr_entry_t structure. */ 2694 extern void bcm_l3_vpbr_entry_t_init( 2695 bcm_l3_vpbr_entry_t *vpbr_info); 2696 2697 /* L3 Flags. */ 2698 #define BCM_L3_VPBR_IP6 0x00000001 /* IPv6 entries */ 2699 2700 /* L3 vPBR Traverse cb type */ 2701 typedef int (*bcm_l3_vpbr_traverse_cb)( 2702 int unit, 2703 bcm_l3_vpbr_entry_t *entry, 2704 void *user_data); 2705 2706 #ifndef BCM_HIDE_DISPATCHABLE 2707 2708 /* 2709 * Traverse all L3 vPBR entries in DNX devices and call a function with 2710 * the data for each entry found. 2711 */ 2712 extern int bcm_l3_vpbr_traverse( 2713 int unit, 2714 uint32 flags, 2715 bcm_l3_vpbr_traverse_cb cb, 2716 void *user_data); 2717 2718 /* Delete an entry from the L3 vPBR table. */ 2719 extern int bcm_l3_vpbr_entry_delete( 2720 int unit, 2721 bcm_l3_vpbr_entry_t *entry); 2722 2723 /* Delete all L3 interfaces. */ 2724 extern int bcm_l3_vpbr_entry_delete_all( 2725 int unit, 2726 bcm_l3_vpbr_entry_t *entry); 2727 2728 /* Look up a L3 vPBR table entry. */ 2729 extern int bcm_l3_vpbr_entry_get( 2730 int unit, 2731 bcm_l3_vpbr_entry_t *entry); 2732 2733 /* Add an entry to the L3 vPBR table. */ 2734 extern int bcm_l3_vpbr_entry_add( 2735 int unit, 2736 bcm_l3_vpbr_entry_t *entry); 2737 2738 /* 2739 * Configure monitoring parameters for a DLB corresponding to a ECMP 2740 * interface 2741 */ 2742 extern int bcm_l3_ecmp_dlb_mon_config_set( 2743 int unit, 2744 bcm_if_t ecmp_intf, 2745 bcm_l3_ecmp_dlb_mon_cfg_t *dlb_mon_cfg); 2746 2747 /* 2748 * Retrieve monitoring parameters for a DLB corresponding to a ECMP 2749 * interface 2750 */ 2751 extern int bcm_l3_ecmp_dlb_mon_config_get( 2752 int unit, 2753 bcm_if_t intf, 2754 bcm_l3_ecmp_dlb_mon_cfg_t *dlb_mon_cfg); 2755 2756 #endif /* BCM_HIDE_DISPATCHABLE */ 2757 2758 /* Initialize bcm_l3_ecmp_dlb_mon_cfg_t structure */ 2759 extern void bcm_l3_ecmp_dlb_mon_cfg_t_init( 2760 bcm_l3_ecmp_dlb_mon_cfg_t *dlb_mon_cfg); 2761 2762 /* L3 ECMP tunnel priority. */ 2763 typedef struct bcm_l3_ecmp_tunnel_priority_map_info_s { 2764 uint32 l3_flags; /* See BCM_L3_xxx flag definitions. */ 2765 int map_profile; /* Tunnel Priority Map profile. */ 2766 int tunnel_priority; /* Tunnel Priority. */ 2767 int index; /* Index to the Tunnel Priority table to update. */ 2768 } bcm_l3_ecmp_tunnel_priority_map_info_t; 2769 2770 #ifndef BCM_HIDE_DISPATCHABLE 2771 2772 /* Creates a new ECMP tunnel priority profile. */ 2773 extern int bcm_l3_ecmp_tunnel_priority_map_create( 2774 int unit, 2775 bcm_l3_ecmp_tunnel_priority_map_info_t *map_info); 2776 2777 /* 2778 * Set a priority index for a set of tunnel priority and a priority 2779 * profile. 2780 */ 2781 extern int bcm_l3_ecmp_tunnel_priority_map_set( 2782 int unit, 2783 bcm_l3_ecmp_tunnel_priority_map_info_t *map_info); 2784 2785 /* 2786 * Get a priority index for a set of tunnel priority and a priority 2787 * profile. 2788 */ 2789 extern int bcm_l3_ecmp_tunnel_priority_map_get( 2790 int unit, 2791 bcm_l3_ecmp_tunnel_priority_map_info_t *map_info); 2792 2793 /* Destroys an ECMP tunnel priority profile. */ 2794 extern int bcm_l3_ecmp_tunnel_priority_map_destroy( 2795 int unit, 2796 bcm_l3_ecmp_tunnel_priority_map_info_t *map_info); 2797 2798 #endif /* BCM_HIDE_DISPATCHABLE */ 2799 2800 /* The attributes that determine DLB port's quality. */ 2801 typedef struct bcm_l3_ecmp_dlb_port_quality_attr_s { 2802 int scaling_factor; /* Scaling factor for dynamic load balancing 2803 thresholds. */ 2804 int load_weight; /* Weight of traffic load in determining port's 2805 quality. */ 2806 int queue_size_weight; /* Weight of total queue size in determining port's 2807 quality. */ 2808 } bcm_l3_ecmp_dlb_port_quality_attr_t; 2809 2810 #ifndef BCM_HIDE_DISPATCHABLE 2811 2812 /* Set ECMP DLB port quality attributes. */ 2813 extern int bcm_l3_ecmp_dlb_port_quality_attr_set( 2814 int unit, 2815 bcm_port_t port, 2816 bcm_l3_ecmp_dlb_port_quality_attr_t *quality_attr); 2817 2818 /* Get ECMP DLB port quality attributes. */ 2819 extern int bcm_l3_ecmp_dlb_port_quality_attr_get( 2820 int unit, 2821 bcm_port_t port, 2822 bcm_l3_ecmp_dlb_port_quality_attr_t *quality_attr); 2823 2824 #endif /* BCM_HIDE_DISPATCHABLE */ 2825 2826 /* Initialize a bcm_l3_ecmp_dlb_port_quality_attr_t structure. */ 2827 extern void bcm_l3_ecmp_dlb_port_quality_attr_t_init( 2828 bcm_l3_ecmp_dlb_port_quality_attr_t *quality_attr); 2829 2830 /* Define the counting source (type) of L3 ECMP DLB counter engine. */ 2831 typedef enum bcm_l3_ecmp_dlb_stat_e { 2832 bcmL3ECMPDlbStatFailPackets = 0, /* Number of packets that cannot be 2833 resolved through the DLB mechanism. */ 2834 bcmL3ECMPDlbStatPortReassignmentCount = 1, /* Total ECMP port member reassignments 2835 counter. */ 2836 bcmL3ECMPDlbStatMemberReassignmentCount = 2, /* Total ECMP member reassignments 2837 counter. */ 2838 bcmL3ECMPDlbStatCount = 3 /* Always last. */ 2839 } bcm_l3_ecmp_dlb_stat_t; 2840 2841 #ifndef BCM_HIDE_DISPATCHABLE 2842 2843 /* Set the DLB statistics based on the ECMP interface. */ 2844 extern int bcm_l3_ecmp_dlb_stat_set( 2845 int unit, 2846 bcm_if_t ecmp_intf, 2847 bcm_l3_ecmp_dlb_stat_t type, 2848 uint64 value); 2849 2850 /* Get the DLB statistics based on the ECMP interface. */ 2851 extern int bcm_l3_ecmp_dlb_stat_get( 2852 int unit, 2853 bcm_if_t ecmp_intf, 2854 bcm_l3_ecmp_dlb_stat_t type, 2855 uint64 *value); 2856 2857 /* Get the DLB statistics based on the ECMP interface in sync mode. */ 2858 extern int bcm_l3_ecmp_dlb_stat_sync_get( 2859 int unit, 2860 bcm_if_t ecmp_intf, 2861 bcm_l3_ecmp_dlb_stat_t type, 2862 uint64 *value); 2863 2864 #endif /* BCM_HIDE_DISPATCHABLE */ 2865 2866 /* L3 AACL options. */ 2867 #define BCM_L3_AACL_OPTIONS_REPLACE (1U << 0) /* Replace existing L3 AACL. */ 2868 2869 /* L3 AACL flags. */ 2870 #define BCM_L3_AACL_FLAGS_IP6 (1U << 0) /* Indicate L3 AACL is for IPv6 2871 packet. */ 2872 #define BCM_L3_AACL_FLAGS_IP_SRC (1U << 1) /* Source IP subnet address 2873 match. */ 2874 2875 /* 2876 * L3 AACL Structure. 2877 * Contains information required for manipulating L3 AACLs. 2878 */ 2879 typedef struct bcm_l3_aacl_s { 2880 uint32 flags; /* See BCM_L3_AACL_FLAGS_xxx flag definitions. */ 2881 bcm_ip_t ip; /* IP subnet address (IPv4). */ 2882 bcm_ip_t ip_mask; /* IP subnet mask (IPv4). */ 2883 bcm_ip6_t ip6; /* IP subnet address (IPv6). */ 2884 bcm_ip6_t ip6_mask; /* IP subnet mask (IPv6). */ 2885 bcm_l4_port_t l4_port; /* L4 port. */ 2886 bcm_l4_port_t l4_port_mask; /* L4 port mask. */ 2887 uint32 class_id; /* Compression class ID. */ 2888 } bcm_l3_aacl_t; 2889 2890 /* Initialize a bcm_l3_aacl_t structure. */ 2891 extern void bcm_l3_aacl_t_init( 2892 bcm_l3_aacl_t *aacl); 2893 2894 #ifndef BCM_HIDE_DISPATCHABLE 2895 2896 /* Adds a L3 AACL to the compression table. */ 2897 extern int bcm_l3_aacl_add( 2898 int unit, 2899 uint32 options, 2900 bcm_l3_aacl_t *aacl); 2901 2902 /* Deletes a L3 AACL from the compression table. */ 2903 extern int bcm_l3_aacl_delete( 2904 int unit, 2905 bcm_l3_aacl_t *aacl); 2906 2907 /* Deletes all AACLs. */ 2908 extern int bcm_l3_aacl_delete_all( 2909 int unit, 2910 bcm_l3_aacl_t *aacl); 2911 2912 /* Finds information from the AACL table. */ 2913 extern int bcm_l3_aacl_find( 2914 int unit, 2915 bcm_l3_aacl_t *aacl); 2916 2917 #endif /* BCM_HIDE_DISPATCHABLE */ 2918 2919 /* bcm_l3_aacl_traverse_cb */ 2920 typedef int (*bcm_l3_aacl_traverse_cb)( 2921 int unit, 2922 bcm_l3_aacl_t *aacl, 2923 void *user_data); 2924 2925 #ifndef BCM_HIDE_DISPATCHABLE 2926 2927 /* Traverse through the AACL table and run callback at each entry. */ 2928 extern int bcm_l3_aacl_traverse( 2929 int unit, 2930 bcm_l3_aacl_traverse_cb trav_fn, 2931 void *user_data); 2932 2933 /* 2934 * Traverse through the AACL table and run callback with matched 2935 * condition. 2936 */ 2937 extern int bcm_l3_aacl_matched_traverse( 2938 int unit, 2939 uint32 flags, 2940 bcm_l3_aacl_traverse_cb trav_fn, 2941 void *user_data); 2942 2943 #endif /* BCM_HIDE_DISPATCHABLE */ 2944 2945 /* 2946 * L3 ECMP group info structure. 2947 * Contains information about L3 ECMP Group that is used mainly for 2 2948 * level ECMP. 2949 */ 2950 typedef struct bcm_l3_ecmp_group_info_s { 2951 int ecmp_levels; /* Number of ECMP levels in use */ 2952 int level1_ecmp_start_index; /* First valid index for Level 1 ECMP group */ 2953 int level1_ecmp_size; /* Max number of Level 1 ECMP groups 2954 possible */ 2955 int level2_ecmp_start_index; /* First valid index for Level 2 ECMP group */ 2956 int level2_ecmp_size; /* Max number of Level 2 ECMP groups 2957 possible */ 2958 } bcm_l3_ecmp_group_info_t; 2959 2960 /* Initialize a bcm_l3_ecmp_group_info_t structure. */ 2961 extern void bcm_l3_ecmp_group_info_t_init( 2962 bcm_l3_ecmp_group_info_t *l3_ecmp_group_info); 2963 2964 #ifndef BCM_HIDE_DISPATCHABLE 2965 2966 /* Obtain ECMP group general information. */ 2967 extern int bcm_l3_ecmp_group_info_get( 2968 int unit, 2969 bcm_l3_ecmp_group_info_t *l3_ecmp_group_info); 2970 2971 #endif /* defined(INCLUDE_L3) */ 2972 2973 #endif /* BCM_HIDE_DISPATCHABLE */ 2974 2975 #endif /* __BCM_L3_H__ */