l3.h (11427B)
1 /*! \file l3.h 2 * 3 * L3 header file. 4 * This file contains L3 definitions internal to the BCM library. 5 */ 6 /* 7 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 8 * 9 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 10 */ 11 12 13 #ifndef BCMI_LTSW_L3_H 14 #define BCMI_LTSW_L3_H 15 #include <shr/shr_types.h> 16 #include <bcm_int/ltsw/types.h> 17 18 #define BCMI_LTSW_L3_MTU_DEFAULT_SIZE 0x3FFF 19 20 /*! 21 * L3 MTU type. 22 */ 23 typedef enum { 24 /*! L3_UC_MTU. */ 25 L3_MTU_TYPE_UC, 26 27 /*! L3_MC_TYPE encap. */ 28 L3_MTU_TYPE_MC, 29 30 /*! L3_UC_TUNNEL_MTU encap. */ 31 L3_MTU_TYPE_TUNNEL, 32 33 /*! Last mtu type. */ 34 L3_MTU_TYPE_COUNT 35 } l3_mtu_type; 36 37 38 typedef struct bcmi_ltsw_l3_mtu_cfg_s { 39 40 /*! L3 MTU index. */ 41 int index; 42 43 /*! L3 MTU size. */ 44 int mtu; 45 46 /*! L3 MTU type. */ 47 l3_mtu_type type; 48 } bcmi_ltsw_l3_mtu_cfg_t; 49 50 /*! 51 * \brief Application switch control type of L3 for a specific device. 52 */ 53 typedef enum bcmi_ltsw_l3_control_s { 54 55 /*! Non-IP packets w/DA of my router MAC to CPU. */ 56 bcmiL3ControlNonIpL3ErrToCpu = 0, 57 58 /*! DIP not found in L3/LPM tables. */ 59 bcmiL3ControlUnknownL3DestToCpu = 1, 60 61 /*! Invalid IPv6 packets to CPU. */ 62 bcmiL3ControlV6L3ErrToCpu = 2, 63 64 /*! IPv6 unknown dest packets to CPU. */ 65 bcmiL3ControlV6L3DstMissToCpu = 3, 66 67 /*! Drop IPv6 with link local sources. */ 68 bcmiL3ControlV6L3LocalLinkDrop = 4, 69 70 /*! Invalid IPv6 packets to CPU. */ 71 bcmiL3ControlV4L3ErrToCpu = 5, 72 73 /*! IPv6 unknown dest packets to CPU. */ 74 bcmiL3ControlV4L3DstMissToCpu = 6, 75 76 /*! Martian packets to CPU. */ 77 bcmiL3ControlMartianAddrToCpu = 7, 78 79 /*! L3 unicast w/invalid TTL to CPU. */ 80 bcmiL3ControlL3UcTtlErrToCpu = 8, 81 82 /*! Slowpath packets to CPU. */ 83 bcmiL3ControlL3SlowpathToCpu = 9, 84 85 /*! L3 MTU check failure. */ 86 bcmiL3ControlL3MtuFailToCpu = 10, 87 88 /*! Copy L3 Ucast with TTL 1 to CPU. */ 89 bcmiL3ControlL3UcastTtl1ToCpu = 11, 90 91 /*! Enables/Disables source hit bit lookup update in the L3 table */ 92 bcmiL3ControlL3SrcHitEnable = 12, 93 94 /*! Programmable value for user defined extension header 1 & 2. */ 95 bcmiL3ControlFlexIP6ExtHdr = 13, 96 97 /*! Egress programmable value for user defined extension header 1 & 2. */ 98 bcmiL3ControlFlexIP6ExtHdrEgress = 14, 99 100 /*! 101 * Do not drop IPv6. It will override drop control 102 * bcmSwitchV6L3LocalLinkDrop if source and destination are local link. 103 */ 104 bcmiL3ControlV6L3SrcDstLocalLinkDropCancel = 15, 105 106 /*! MC unknown Index Error to CPU. */ 107 bcmiL3ControlMcastUnknownErrToCpu = 16, 108 109 /*! Incoming port not in IPMC entry. */ 110 bcmiL3ControlIpmcPortMissToCpu = 17, 111 112 /*! IPMC pkt has header err or TTL=0. */ 113 bcmiL3ControlIpmcErrorToCpu = 18, 114 115 /*! IPMC packets w/invalid TTL to CPU. */ 116 bcmiL3ControlIpmcTtlErrToCpu = 19, 117 118 /*! IGMP packets with reserved MC address threated as IGMP. */ 119 bcmiL3ControlIgmpReservedMcastEnable = 20, 120 121 /*! MLD packets with reserved MC address threated as MLD. */ 122 bcmiL3ControlMldReservedMcastEnable = 21, 123 124 /*! Stricter checks for MLD packets are enable. */ 125 bcmiL3ControlMldDirectAttachedOnly = 22, 126 127 /*! Threat unknown IPMC as L2 Mcast. */ 128 bcmiL3ControlUnknownIpmcAsMcast = 23, 129 130 /*! Drop unknown IPMC for incomming tunnel. */ 131 bcmiL3ControlTunnelUnknownIpmcDrop = 24, 132 133 /*! Copy L3 Mcast with TTL 1 to CPU. */ 134 bcmiL3ControlIpmcTtl1ToCpu = 25, 135 136 /*! 137 * Allow both L2 and L3 copies of a packet to 138 * go out on a physical port if it happens to be a member of 139 * both the L2 and L3 bitmaps of the replication group. 140 */ 141 bcmiL3ControlIpmcSameVlanPruning = 26, 142 143 /*! Hash Select for Multipath. */ 144 bcmiL3ControlEcmpHashMultipath = 27, 145 146 /*! Hash Control of fields. */ 147 bcmiL3ControlEcmpHashControl = 28, 148 149 /*! Enable/Disable flow based hashing for ECMP. */ 150 bcmiL3ControlEcmpHashUseFlowSelEcmp = 29, 151 152 /*! 153 * To select the most significant bits of the 16-bit ECMP hash value 154 * before the modulo function. 155 */ 156 bcmiL3ControlEcmpHashBitCountSelect = 30, 157 158 /*! Enable unicast packets with IGMP payload. */ 159 bcmiL3ControlIgmpUcastEnable = 31, 160 161 /*! Enable unicast packets with MLD payload. */ 162 bcmiL3ControlMldUcastEnable = 32, 163 164 /*! Check MACDA and IPv4 DIP address match. */ 165 bcmiL3ControlIp4McastL2DestCheck = 33, 166 167 /*! Check MACDA and IPv6 DIP address match. */ 168 bcmiL3ControlIp6McastL2DestCheck = 34, 169 170 /*! Enable forwarding of known IPMC packets to the incoming vlan. */ 171 bcmiL3ControlIpmcSameVlanL3Route = 35, 172 173 /*! Enable/Disable flow based hashing for weighted ECMP. */ 174 bcmiL3ControlFlowSelWeightedEcmp = 36, 175 176 /*! Enables/Disables parsing into WESP payload. */ 177 bcmiL3ControlWESPProtocolEnable = 37, 178 179 /*! WESP protocol number. */ 180 bcmiL3ControlWESPProtocol = 38, 181 182 /*! Random single level ECMP seed. */ 183 bcmiL3ControlECMPRandomSeed = 39, 184 185 /*! Random level1 ECMP seed. */ 186 bcmiL3ControlECMPLevel1RandomSeed = 40, 187 188 /*! Random level2 ECMP seed. */ 189 bcmiL3ControlECMPLevel2RandomSeed = 41, 190 191 /* Enable/Disable flow based hashing for overlay ECMP. */ 192 bcmiL3ControlFlowSelOverlayEcmp = 42, 193 194 /* Enable/Disable flow based hashing for L2 ECMP. */ 195 bcmiL3ControlFlowSelL2Ecmp = 43, 196 197 /* Enable/Disable flow based hashing for overlay L2 ECMP. */ 198 bcmiL3ControlFlowSelOverlayL2Ecmp = 44, 199 200 /* Enable/Disable flow based hashing for resilient ECMP. */ 201 bcmiL3ControlFlowSelRhEcmp = 45, 202 203 /* Enable/Disable flow based hashing for overlay resilient ECMP. */ 204 bcmiL3ControlFlowSelOverlayRhEcmp = 46, 205 206 /* Enable/Disable flow based hashing for overlay weighted ECMP. */ 207 bcmiL3ControlFlowSelOverlayWeightedEcmp = 47, 208 209 /*! Enable/Disable flow based hashing for ECMP DLB. */ 210 bcmiL3ControlFlowSelEcmpDynamic = 48, 211 212 /*! L3 control type count. */ 213 bcmiL3ControlCount 214 215 } bcmi_ltsw_l3_control_t; 216 217 typedef struct bcmi_ltsw_l3_ipv4_options_profile_s { 218 /*! Enable drop. */ 219 bool drop; 220 221 /*! Enable copy to CPU. */ 222 bool copy_to_cpu; 223 } bcmi_ltsw_l3_ipv4_options_profile_t; 224 225 226 #define BCMI_LTSW_L3_PC_ATTR_IPMC_UNTAG (1 << 0) 227 #define BCMI_LTSW_L3_PC_ATTR_IPMC_TTL_DEC (1 << 1) 228 #define BCMI_LTSW_L3_PC_ATTR_IPMC_TTL_CHECK (1 << 2) 229 #define BCMI_LTSW_L3_PC_ATTR_IPMC_SA_REPLACE (1 << 3) 230 #define BCMI_LTSW_L3_PC_ATTR_IPMC_VLAN (1 << 4) 231 232 typedef struct bcmi_ltsw_l3_port_control_s { 233 /*! Enable untag IPMC packets. */ 234 bool ipmc_untag; 235 236 /*! Enable TTL decrement for IPMC packets. */ 237 bool ipmc_ttl_dec; 238 239 /*! Enable ttl check for IPMC packets. */ 240 bool ipmc_ttl_check; 241 242 /*! Enable to replace SA for IPMC packets. */ 243 bool ipmc_sa_replace; 244 245 /*! Untag VID for IPMC packets. */ 246 uint16_t ipmc_vid; 247 248 } bcmi_ltsw_l3_port_control_t; 249 250 /*! 251 * \brief Set mtu value. 252 * 253 * \param [in] unit Unit Number. 254 * \param [in] cfg MTU Information. 255 * 256 * \retval SHR_E_NONE No errors. 257 * \retval !SHR_E_NONE Failure. 258 */ 259 extern int 260 bcmi_ltsw_l3_mtu_set( 261 int unit, 262 bcmi_ltsw_l3_mtu_cfg_t *cfg); 263 264 /*! 265 * \brief Get mtu value. 266 * 267 * \param [in] unit Unit Number. 268 * \param [out] cfg MTU Information. 269 * 270 * \retval SHR_E_NONE No errors. 271 * \retval !SHR_E_NONE Failure. 272 */ 273 extern int 274 bcmi_ltsw_l3_mtu_get( 275 int unit, 276 bcmi_ltsw_l3_mtu_cfg_t *cfg); 277 278 /*! 279 * \brief Delete mtu value. 280 * 281 * \param [in] unit Unit Number. 282 * \param [in] mtu_idx MTU entry index. 283 * 284 * \retval SHR_E_NONE No errors. 285 * \retval !SHR_E_NONE Failure. 286 */ 287 extern int 288 bcmi_ltsw_l3_mtu_delete(int unit, bcmi_ltsw_l3_mtu_cfg_t *cfg); 289 290 /*! 291 * \brief Recover mtu database from LT. 292 * 293 * \param [in] unit Unit Number. 294 * \param [in] mtu_idx MTU entry index. 295 * 296 * \retval SHR_E_NONE No errors. 297 * \retval !SHR_E_NONE Failure. 298 */ 299 extern int 300 bcmi_ltsw_l3_mtu_recover(int unit, int mtu_idx); 301 302 /*! Full ipv4 mask.*/ 303 #define BCMI_LTSW_L3_IP4_FULL_MASK 0xffffffff 304 305 /*! L3_IP_OPTION_CONTROL_PROFILE size per profile. */ 306 #define BCMI_LTSW_L3_IP_OPTION_PROFILE_CHUNK 256 307 308 /*! L3 IP options Default Profile */ 309 #define BCM_L3_IP4_OPTIONS_DEF_PROFILE_INDEX 0x00 310 311 extern int bcmi_ltsw_l3_mask6_apply(bcm_ip6_t mask, bcm_ip6_t addr); 312 313 /*! 314 * \brief Set L3 controlling information. 315 * 316 * \param [in] unit Unit Number. 317 * \param [in] control Switch control. 318 * \param [in] value Type-based controlling value for L3. 319 * 320 * \retval SHR_E_NONE No errors. 321 * \retval !SHR_E_NONE Failure. 322 */ 323 extern int 324 bcmi_ltsw_l3_control_set( 325 int unit, 326 bcmi_ltsw_l3_control_t control, 327 uint32_t value); 328 329 /*! 330 * \brief Get L3 controlling information. 331 * 332 * \param [in] unit Unit Number. 333 * \param [in] control Switch control. 334 * \param [out] value Type-based controlling value for L3. 335 * 336 * \retval SHR_E_NONE No errors. 337 * \retval !SHR_E_NONE Failure. 338 */ 339 extern int 340 bcmi_ltsw_l3_control_get( 341 int unit, 342 bcmi_ltsw_l3_control_t control, 343 uint32_t *value); 344 345 /*! 346 * \brief Set L3 port controlling information. 347 * 348 * \param [in] unit Unit Number. 349 * \param [in] port Port Number. 350 * \param [in] control Control type. 351 * \param [in] info Control infomation. 352 * 353 * \retval SHR_E_NONE No errors. 354 * \retval !SHR_E_NONE Failure. 355 */ 356 extern int 357 bcmi_ltsw_l3_port_control_set( 358 int unit, 359 int port, 360 int control, 361 bcmi_ltsw_l3_port_control_t *info); 362 363 /*! 364 * \brief Get L3 port controlling information. 365 * 366 * \param [in] unit Unit Number. 367 * \param [in] port Port Number. 368 * \param [in] control Control type. 369 * \param [out] info Control infomation. 370 * 371 * \retval SHR_E_NONE No errors. 372 * \retval !SHR_E_NONE Failure. 373 */ 374 extern int 375 bcmi_ltsw_l3_port_control_get( 376 int unit, 377 int port, 378 int control, 379 bcmi_ltsw_l3_port_control_t *info); 380 381 /*! 382 * \brief Set ipv6 reserved multicast address and mask. 383 * 384 * \param [in] unit Unit number. 385 * \param [in] num Number of ipv6 address/mask pairs 386 * \param [in] ip6_addr Ipv6 address. 387 * \param [in] ip6_mask Ipv6 address mask. 388 * 389 * \retval SHR_E_NONE No errors. 390 * \retval !SHR_E_NONE Failure. 391 */ 392 extern int 393 bcmi_ltsw_l3_ipv6_reserved_multicast_addr_multi_set( 394 int unit, 395 int num, 396 bcm_ip6_t *ip6_addr, 397 bcm_ip6_t *ip6_mask); 398 399 /*! 400 * \brief Get ipv6 reserved multicast address and mask. 401 * 402 * \param [in] unit Unit number. 403 * \param [in] num Number of ipv6 address/mask pairs 404 * \param [out] ip6_addr Ipv6 address. 405 * \param [out] ip6_mask Ipv6 address mask. 406 * 407 * \retval SHR_E_NONE No errors. 408 * \retval !SHR_E_NONE Failure. 409 */ 410 extern int 411 bcmi_ltsw_l3_ipv6_reserved_multicast_addr_multi_get( 412 int unit, 413 int num, 414 bcm_ip6_t *ip6_addr, 415 bcm_ip6_t *ip6_mask); 416 417 /*! 418 * \brief Translate Profile ID into hardware table index used by API. 419 * 420 * \param [in] unit Unit Number. 421 * \param [in] profile_id Profile ID. 422 * \param [out] hw_idx Hardware index. 423 * 424 * \retval SHR_E_NONE No errors. 425 * \retval !SHR_E_NONE Failure. 426 */ 427 extern int 428 bcmi_ltsw_l3_ip4_options_profile_id2idx( 429 int unit, 430 int profile_id, 431 int *hw_idx); 432 433 /*! 434 * \brief Translate hardware table index into Profile ID used by API. 435 * 436 * \param [in] unit Unit Number. 437 * \param [in] hw_idx Hardware index. 438 * \param [out] profile_id Profile ID. 439 * 440 * \retval SHR_E_NONE No errors. 441 * \retval !SHR_E_NONE Failure. 442 */ 443 extern int 444 bcm_ltsw_l3_ip4_options_profile_idx2id( 445 int unit, 446 int hw_idx, 447 int *profile_id); 448 449 #endif /* BCMI_LTSW_L3_H */