l2.h (65574B)
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_L2_H__ 11 #define __BCM_L2_H__ 12 13 #include <bcm/types.h> 14 15 /* 16 * Flags for device-independent L2 address. 17 * 18 * Special note on insert/delete/lookup-specific flags: 19 * 20 * BCM_L2_NATIVE 21 * BCM_L2_MOVE 22 * BCM_L2_FROM_NATIVE 23 * BCM_L2_TO_NATIVE 24 * BCM_L2_MOVE_PORT 25 * BCM_L2_LOCAL_CPU 26 * 27 * On a move, two calls occur: delete and insert. The from native/to 28 * native calls are set the same for both of these operations. On an age, 29 * the move bit is not set and only one delete operation occurs. 30 * 31 * Suggested application operation: 32 * 33 * Insert: If native is set, send insert op to all units. 34 * Age: If native is set, send delete operation to all units. 35 * Move: Ignore delete indication and wait for insert operation. 36 * Treat insert like above. 37 * 38 * That is, ignore move-delete operations; only forward other 39 * operations if native. 40 * 41 * The BCM_L2_LOCAL_CPU flag indicates the entry is for the local CPU on 42 * the device. This is valid for _add operations only. Note that 43 * BCM_L2_LOCAL_CPU is related to the L2_NATIVE value. L2_NATIVE is valid 44 * on reads, L2_LOCAL_CPU is valid on move or write. 45 */ 46 #define BCM_L2_COS_SRC_PRI 0x00000001 /* Source COS has priority 47 over destination COS. */ 48 #define BCM_L2_DISCARD_SRC 0x00000002 49 #define BCM_L2_DISCARD_DST 0x00000004 50 #define BCM_L2_COPY_TO_CPU 0x00000008 51 #define BCM_L2_L3LOOKUP 0x00000010 52 #define BCM_L2_STATIC 0x00000020 53 #define BCM_L2_HIT 0x00000040 54 #define BCM_L2_TRUNK_MEMBER 0x00000080 55 #define BCM_L2_MCAST 0x00000100 56 #define BCM_L2_REPLACE_DYNAMIC 0x00000200 57 #define BCM_L2_SRC_HIT 0x00000400 58 #define BCM_L2_DES_HIT 0x00000800 59 #define BCM_L2_REMOTE_TRUNK 0x00001000 60 #define BCM_L2_MIRROR 0x00002000 61 #define BCM_L2_SETPRI 0x00004000 62 #define BCM_L2_REMOTE_LOOKUP 0x00008000 63 #define BCM_L2_NATIVE 0x00010000 64 #define BCM_L2_MOVE 0x00020000 65 #define BCM_L2_FROM_NATIVE 0x00040000 66 #define BCM_L2_TO_NATIVE 0x00080000 67 #define BCM_L2_MOVE_PORT 0x00100000 68 #define BCM_L2_LOCAL_CPU 0x00200000 /* Entry is for the local CPU 69 on the device. */ 70 #define BCM_L2_USE_FABRIC_DISTRIBUTION 0x00400000 /* Use specified fabric 71 distribution class. */ 72 #define BCM_L2_PENDING 0x00800000 73 #define BCM_L2_LEARN_LIMIT_EXEMPT 0x01000000 74 #define BCM_L2_LEARN_LIMIT 0x02000000 75 #define BCM_L2_ENTRY_OVERFLOW 0x04000000 76 #define BCM_L2_LEARN_LIMIT_EXEMPT_LOCAL 0x08000000 /* Only system wide MAC limit 77 counter will be 78 incremented. */ 79 #define BCM_L2_SET_ENCAP_VALID 0x10000000 /* DNX only: indication that 80 encap_id_valid needs to 81 set even when encap_id is 82 not valid. */ 83 #define BCM_L2_SET_ENCAP_INVALID 0x20000000 /* DNX only: encap_id is 84 added to MAC table as is, 85 however valid bit is 86 cleared. */ 87 #define BCM_L2_SR_SAN_DEST 0x40000000 /* Seamless Redundancy: the 88 destination is a SAN */ 89 #define BCM_L2_ADD_OVERRIDE_PENDING 0x80000000 /* Override pending entry 90 while the same hash bucket 91 is full. */ 92 93 /* These are in bit order. */ 94 #define BCM_L2_FLAGS_STR \ 95 { \ 96 "SrcCOS", \ 97 "SrcDisc", \ 98 "DestDisc", \ 99 "CopyCPU", \ 100 "L3Lkup", \ 101 "Static", \ 102 "Hit", \ 103 "Trunk", \ 104 "Mcast", \ 105 "RplDyn", \ 106 "SrcHit", \ 107 "DestHit", \ 108 "RTrunk", \ 109 "Mirror", \ 110 "SetPri", \ 111 "RemoteLookup", \ 112 "Native", \ 113 "Move", \ 114 "FrNative", \ 115 "ToNative", \ 116 "MovePort", \ 117 "LclCPU", \ 118 "UseFabricDistribution", \ 119 "Pending", \ 120 "LearnLimitExempt", \ 121 "LearnLimit" \ 122 } 123 124 /* bcm_l2_flags_str */ 125 extern char *bcm_l2_flags_str[]; 126 127 /* bcm_l2_flags_count */ 128 extern int bcm_l2_flags_count; 129 130 /* Flags2 for device-independent L2 address. */ 131 #define BCM_L2_FLAGS2_ROE_NHI 0x00000001 /* The destination of the l2 132 address is ROE/ROE Custom 133 Next Hop Index. */ 134 #define BCM_L2_FLAGS2_L3_MULTICAST 0x00000002 /* The destination of the l2 135 address is ROE/ROE Custom 136 IPMC Index. */ 137 #define BCM_L2_FLAGS2_BMACT_LEARN 0x00000004 /* Mac-in-Mac: BVID entries 138 will be added to dedicated 139 MiM learn table (instead 140 of BMACT FWD). */ 141 #define BCM_L2_FLAGS2_ADD_NO_CALLBACKS 0x00000008 /* The l2 FIFO events will 142 not be generated if this 143 flag is set. */ 144 #define BCM_L2_FLAGS2_ADD_VPN_TYPE 0x00000010 /* Add VPN type l2 entry. */ 145 #define BCM_L2_FLAGS2_HIT_GET 0x00000020 /* Signal bcm_l2_addr_get to 146 return the hit status of 147 the MAC entry. */ 148 #define BCM_L2_FLAGS2_AGE_GET 0x00000040 /* Signal bcm_l2_addr_get to 149 return the age of the MAC 150 entry. */ 151 #define BCM_L2_FLAGS2_MESH 0x00000080 /* The L2 address is mesh bit 152 set. */ 153 154 #define BCM_L2_AUTH_NONE 0 155 #define BCM_L2_AUTH_STATIC_ACCEPT 4 156 #define BCM_L2_AUTH_STATIC_REJECT 5 157 #define BCM_L2_AUTH_SA_NUM 6 158 #define BCM_L2_AUTH_SA_MATCH 7 159 160 #define BCM_L2_VID_MASK_ALL 0x0fff 161 #define BCM_L2_SRCPORT_MASK_ALL 0x3f 162 163 #define BCM_L2_CALLBACK_DELETE 0 164 #define BCM_L2_CALLBACK_ADD 1 165 #define BCM_L2_CALLBACK_REPORT 2 166 #define BCM_L2_CALLBACK_LEARN_EVENT 3 167 #define BCM_L2_CALLBACK_AGE_EVENT 4 168 #define BCM_L2_CALLBACK_MOVE_EVENT 5 169 #define BCM_L2_CALLBACK_REFRESH_EVENT 6 170 171 #define BCM_L2_ADDR_DIST_LEARN_EVENT 0x00000001 /* learning events */ 172 #define BCM_L2_ADDR_DIST_STATION_MOVE_EVENT 0x00000002 /* station movement event */ 173 #define BCM_L2_ADDR_DIST_AGED_OUT_EVENT 0x00000004 /* aged out events */ 174 #define BCM_L2_ADDR_DIST_SET_LEARN_DISTRIBUTER 0x00000008 /* Send events to the 175 learning distributer */ 176 #define BCM_L2_ADDR_DIST_SET_SHADOW_DISTRIBUTER 0x00000010 /* Send events to the 177 shadow distributer */ 178 #define BCM_L2_ADDR_DIST_REFRESH_EVENT 0x00000020 /* Age refresh event */ 179 #define BCM_L2_ADDR_DIST_SET_NO_DISTRIBUTER 0x00000040 /* Do not send events to 180 any distributer */ 181 #define BCM_L2_ADDR_DIST_SET_CPU_DMA_DISTRIBUTER 0x00000080 /* Send events to the DMA 182 that copies them to 183 the CPU's memory */ 184 #define BCM_L2_ADDR_DIST_ACK_EVENT 0x00000100 /* acknowledge events */ 185 #define BCM_L2_ADDR_DIST_UPDATE_WITHOUT_ADD_EVENT 0x00000200 /* Update payload or age 186 state or fail in case 187 the entry doesn't 188 exist */ 189 #define BCM_L2_ADDR_DIST_GPORT 0x00000400 /* Set distibution events 190 per LIF */ 191 192 #define BCM_L2_LEARN_MSG_DEST_MULTICAST 0x00000001 /* The destination of the 193 learning message is 194 Multicast group 195 'dest_group' in use, if 196 not present then the 197 destination is uc and 198 'dest_port' in use 199 dst_mac_addr , 200 src_mac_addr, ether_type, 201 vlan_prio, vlan. */ 202 #define BCM_L2_LEARN_MSG_ETH_ENCAP 0x00000002 /* Learn message are 203 encapsulated with 204 Etherenet header. Use the 205 specified Ethernet 206 parameters */ 207 #define BCM_L2_LEARN_MSG_LEARNING 0x00000004 /* The specified 208 configuration are for 209 message generated to 210 learning */ 211 #define BCM_L2_LEARN_MSG_SHADOW 0x00000008 /* The specified 212 configuration are for 213 message generated to 214 manage a shadow of the ARL */ 215 216 /* Device-independent L2 address structure. */ 217 typedef struct bcm_l2_addr_s { 218 uint32 flags; /* BCM_L2_xxx flags. */ 219 uint32 flags2; /* BCM_L2_FLAGS2_xxx flags. */ 220 uint32 station_flags; /* BCM_L2_STATION_xxx flags. */ 221 bcm_mac_t mac; /* 802.3 MAC address. */ 222 bcm_vlan_t vid; /* VLAN identifier. */ 223 int port; /* Zero-based port number. */ 224 int modid; /* XGS: modid. */ 225 bcm_trunk_t tgid; /* Trunk group ID. */ 226 bcm_cos_t cos_dst; /* COS based on dst addr. */ 227 bcm_cos_t cos_src; /* COS based on src addr. */ 228 bcm_multicast_t l2mc_group; /* XGS: index in L2MC table */ 229 bcm_if_t egress_if; /* XGS: index in Next Hop Tables. Used 230 it with BCM_L2_FLAGS2_ROE_NHI flag */ 231 bcm_multicast_t l3mc_group; /* XGS: index in L3_IPMC table. Use it 232 with BCM_L2_FLAGS2_L3_MULTICAST. */ 233 bcm_pbmp_t block_bitmap; /* XGS: blocked egress bitmap. */ 234 int auth; /* Used if auth enabled on port. */ 235 int group; /* Group number for FP. */ 236 bcm_fabric_distribution_t distribution_class; /* Fabric Distribution Class. */ 237 int encap_id; /* out logical interface */ 238 int age_state; /* Age state of the entry */ 239 uint32 flow_handle; /* FLOW handle for flex entries. */ 240 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 241 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex 242 entries. */ 243 uint32 num_of_fields; /* number of logical fields. */ 244 bcm_pbmp_t sa_source_filter_pbmp; /* Source port filter bitmap for this SA */ 245 bcm_tsn_flowset_t tsn_flowset; /* Time-Sensitive Networking: associated 246 flow set */ 247 bcm_tsn_sr_flowset_t sr_flowset; /* Seamless Redundancy: associated flow 248 set */ 249 bcm_policer_t policer_id; /* Base policer to be used */ 250 bcm_tsn_pri_map_t taf_gate_primap; /* TAF (Time Aware Filtering) gate 251 priority mapping */ 252 uint32 stat_id; /* Object statistics ID */ 253 int stat_pp_profile; /* Statistics profile */ 254 uint16 gbp_src_id; /* GBP Source ID */ 255 int opaque_ctrl_id; /* Opaque control ID. */ 256 } bcm_l2_addr_t; 257 258 /* Flags for device-independent L2 egress. */ 259 #define BCM_L2_EGRESS_WITH_ID 0x00000001 /* Use the specified 260 Encap ID while 261 creating. */ 262 #define BCM_L2_EGRESS_REPLACE 0x00000002 /* Replace config of 263 existing egress 264 object. */ 265 #define BCM_L2_EGRESS_DEST_MAC_REPLACE 0x00000004 /* Replace dest MAC. */ 266 #define BCM_L2_EGRESS_DEST_MAC_PREFIX5_REPLACE 0x00000008 /* Replace only 5 prefix 267 bytes of dest MAC. */ 268 #define BCM_L2_EGRESS_SRC_MAC_REPLACE 0x00000010 /* Replace source MAC. */ 269 #define BCM_L2_EGRESS_OUTER_VLAN_REPLACE 0x00000020 /* Replace outer vlan. */ 270 #define BCM_L2_EGRESS_OUTER_PRIO_REPLACE 0x00000040 /* Replace outer tag 271 priority. */ 272 #define BCM_L2_EGRESS_INNER_VLAN_REPLACE 0x00000080 /* Replace inner vlan. */ 273 #define BCM_L2_EGRESS_INNER_PRIO_REPLACE 0x00000100 /* Replace inner tag 274 priority. */ 275 #define BCM_L2_EGRESS_ETHERTYPE_REPLACE 0x00000200 /* Replace EtherType */ 276 #define BCM_L2_EGRESS_DEST_PORT 0x00000400 /* Associate l2 egress 277 entry with a 278 particular dest port */ 279 #define BCM_L2_EGRESS_OUTER_VLAN_ADD 0x00000800 /* add outer vlan, if set 280 then new vlan-tag is 281 added according to 282 outer_tpid,outer_prio,outer_vlan, 283 attributes */ 284 #define BCM_L2_EGRESS_VLAN_QOS_MAP_REPLACE 0x00001000 /* Replace VLAN PCP-DEI 285 QOS settings */ 286 #define BCM_L2_EGRESS_WIDE 0x00002000 /* Set wide entry in 287 egress */ 288 #define BCM_L2_EGRESS_RECYCLE_HEADER 0x00004000 /* Recycle header */ 289 #define BCM_L2_EGRESS_DEST_ENCAP_ID 0x00008000 /* Set destination 290 encap_id */ 291 292 /* L2 Egress recycle Apps. */ 293 typedef enum bcm_l2_egress_recycle_app_e { 294 bcmL2EgressRecycleAppDropAndContinue = 0, 295 bcmL2EgressRecycleAppExtendedTerm = 1, 296 bcmL2EgressRecycleAppExtendedEncap = 2, 297 bcmL2EgressRecycleAppReflector = 3, 298 bcmL2EgressRecycleAppRedirectVrf = 4, 299 bcmL2EgressRecycleAppCount = 5 300 } bcm_l2_egress_recycle_app_t; 301 302 /* Device-independent L2 egress structure. */ 303 typedef struct bcm_l2_egress_s { 304 uint32 flags; /* BCM_L2_EGRESS_XXX flags. */ 305 bcm_mac_t dest_mac; /* Destination MAC address to replace 306 with. */ 307 bcm_mac_t src_mac; /* Source MAC address to replace with. */ 308 bcm_vlan_t outer_vlan; /* outer vlan tag to replace with. */ 309 bcm_vlan_t inner_vlan; /* inner vlan tag to replace with. */ 310 bcm_ethertype_t ethertype; /* EtherType to replace with. */ 311 bcm_gport_t dest_port; /* Destination gport to associate this 312 l2 egress entry with */ 313 bcm_if_t encap_id; /* Encapsulation index */ 314 uint16 outer_tpid; /* outer vlan tag TPID */ 315 uint8 outer_prio; /* outer vlan tag User Priority */ 316 uint16 inner_tpid; /* inner vlan tag TPID */ 317 bcm_if_t l3_intf; /* L3 interface (tunnel). Used only in 318 Native Routing overlay protocols. */ 319 int vlan_qos_map_id; /* VLAN PCP-DEI QoS settings. Used only 320 in Native Routing overlay protocols. */ 321 int mpls_extended_label_value; /* An extended label placed on top of a 322 an egress encapsulation. */ 323 bcm_gport_t vlan_port_id; /* vlan gport identifier */ 324 int recycle_header_extension_length; /* Specify in bytes the size of 325 extension header after recycle header */ 326 int additional_egress_termination_size; /* Specify in bytes the size of egress 327 additional termination */ 328 bcm_l2_egress_recycle_app_t recycle_app; /* Indicates the recycle app */ 329 bcm_if_t dest_encap_id; /* Destination encapsulation index */ 330 bcm_vrf_t vrf; /* Virtual router instance */ 331 } bcm_l2_egress_t; 332 333 /* Flags for device-independent L2 cache address. */ 334 #define BCM_L2_CACHE_CPU 0x00000001 /* Packet is copied to CPU. */ 335 #define BCM_L2_CACHE_DISCARD 0x00000002 /* Packet is not switched. */ 336 #define BCM_L2_CACHE_MIRROR 0x00000004 /* Packet is mirrored. */ 337 #define BCM_L2_CACHE_L3 0x00000008 /* Packet is to be L3 routed. */ 338 #define BCM_L2_CACHE_BPDU 0x00000010 /* Packet is BPDU. */ 339 #define BCM_L2_CACHE_SETPRI 0x00000020 /* Internal prio from prio field. */ 340 #define BCM_L2_CACHE_TRUNK 0x00000040 /* Destination is a trunk. */ 341 #define BCM_L2_CACHE_REMOTE_LOOKUP 0x00000080 /* Remote L2 lookup requested. */ 342 #define BCM_L2_CACHE_LEARN_DISABLE 0x00000100 /* Packet source address is not 343 learned for this destination 344 address. */ 345 #define BCM_L2_CACHE_TUNNEL 0x00000200 /* Tunnel termination address. */ 346 #define BCM_L2_CACHE_DESTPORTS 0x00000400 /* Packet is forwarded by 347 multiport L2 address. */ 348 #define BCM_L2_CACHE_SUBTYPE 0x00000800 /* Slow protocol subtype to 349 match. */ 350 #define BCM_L2_CACHE_LOOKUP 0x00001000 /* L2 lookup requested. */ 351 #define BCM_L2_CACHE_MULTICAST 0x00002000 /* Destination is (flood) 352 multicast group. */ 353 #define BCM_L2_CACHE_PROTO_PKT 0x00004000 /* Packet is protocol packets. */ 354 355 /* Device-independent L2 cache address structure. */ 356 typedef struct bcm_l2_cache_addr_s { 357 uint32 flags; /* BCM_L2_CACHE_xxx flags. */ 358 uint32 station_flags; /* BCM_L2_STATION_xxx flags. */ 359 bcm_mac_t mac; /* Destination MAC address to match. */ 360 bcm_mac_t mac_mask; /* MAC address mask. */ 361 bcm_vlan_t vlan; /* VLAN to match. */ 362 bcm_vlan_t vlan_mask; /* VLAN mask. */ 363 bcm_port_t src_port; /* Ingress port to match (BCM5660x). */ 364 bcm_port_t src_port_mask; /* Ingress port mask (must be 0 if not 365 BCM5660x). */ 366 bcm_module_t dest_modid; /* Switch destination module ID. */ 367 bcm_port_t dest_port; /* Switch destination port. */ 368 bcm_trunk_t dest_trunk; /* Switch destination trunk ID. */ 369 int prio; /* Internal priority, use -1 to not set. */ 370 bcm_pbmp_t dest_ports; /* Destination ports for Multiport L2 371 address forwarding. */ 372 int lookup_class; /* Classification class ID. */ 373 uint8 subtype; /* Slow protocol subtype to match. */ 374 bcm_if_t encap_id; /* Encapsulation index. */ 375 bcm_multicast_t group; /* Flood domain for L2CP. */ 376 bcm_ethertype_t ethertype; /* EtherType to match. */ 377 bcm_ethertype_t ethertype_mask; /* Mask. */ 378 } bcm_l2_cache_addr_t; 379 380 /* Flags for L2 learn limit. */ 381 #define BCM_L2_LEARN_LIMIT_SYSTEM 0x00000001 /* Limit is system wide. */ 382 #define BCM_L2_LEARN_LIMIT_VLAN 0x00000002 /* Limit is on per VLAN 383 basis. */ 384 #define BCM_L2_LEARN_LIMIT_PORT 0x00000004 /* Limit is on per port 385 basis. */ 386 #define BCM_L2_LEARN_LIMIT_TRUNK 0x00000008 /* Limit is on per trunk 387 basis. */ 388 #define BCM_L2_LEARN_LIMIT_ACTION_DROP 0x00000010 /* Drop if over limit. */ 389 #define BCM_L2_LEARN_LIMIT_ACTION_CPU 0x00000020 /* Send to CPU if over 390 limit. */ 391 #define BCM_L2_LEARN_LIMIT_ACTION_PREFER 0x00000040 /* Use system drop/CPU if 392 over both system limit 393 and non-system limit, 394 used by system wide 395 setting only. */ 396 #define BCM_L2_LEARN_LIMIT_TUNNEL 0x00000080 /* Limit is on per tunnel 397 basis. */ 398 399 /* L2 learn limit structure. */ 400 typedef struct bcm_l2_learn_limit_s { 401 uint32 flags; /* BCM_L2_LEARN_LIMIT_xxx actions and 402 qualifiers. */ 403 bcm_vlan_t vlan; /* VLAN identifier. */ 404 bcm_port_t port; /* Port number. */ 405 bcm_trunk_t trunk; /* Trunk identifier. */ 406 bcm_tunnel_id_t tunnel_id; /* Tunnel identifier. */ 407 int limit; /* Maximum number of learned entries, -1 for 408 unlimited. */ 409 } bcm_l2_learn_limit_t; 410 411 /* L2 learn message distribution info. */ 412 typedef struct bcm_l2_learn_msgs_config_s { 413 uint32 flags; /* BCM_L2_LEARN_MSG_XXX flags. */ 414 bcm_gport_t dest_port; /* Destination port. */ 415 bcm_multicast_t dest_group; /* Destination group. */ 416 bcm_vlan_t vlan; /* L2: vlan identifier. set to invalid for 417 untagged Ethernet */ 418 uint16 tpid; /* L2: vlan TPID. */ 419 uint16 vlan_prio; /* L2: vlan priority. */ 420 uint16 ether_type; /* L2: type in Ethernet II frame or 802.1Q tag. */ 421 bcm_mac_t src_mac_addr; /* L2: source MAC address. */ 422 bcm_mac_t dst_mac_addr; /* L2: destination MAC address. */ 423 uint8 priority; /* L2: traffic class, Range: 0..7 */ 424 uint8 color; /* L2: drop precedence, Range: 0..3 */ 425 } bcm_l2_learn_msgs_config_t; 426 427 /* Learning events distibution. */ 428 typedef struct bcm_l2_addr_distribute_s { 429 uint32 flags; /* BCM_L2_ADDR_DIST_XXX flags. */ 430 bcm_vlan_t vid; /* VLAN or VPN identifier. */ 431 bcm_gport_t gport; /* GPORT identifier. */ 432 } bcm_l2_addr_distribute_t; 433 434 /* L2 control information. */ 435 typedef struct bcm_l2_gport_control_info_s { 436 uint32 flags; /* BCM_L2_GPORT_CONTROL_XXX flags. */ 437 bcm_gport_t gport; /* GPORT identifier. */ 438 int aging_cycles; /* number of aging meta-cycles. */ 439 int entropy_id; /* aging profile ID. */ 440 } bcm_l2_gport_control_info_t; 441 442 #ifndef BCM_HIDE_DISPATCHABLE 443 444 /* Initialize the BCM L2 subsystem. */ 445 extern int bcm_l2_init( 446 int unit); 447 448 /* Clear the BCM L2 subsystem. */ 449 extern int bcm_l2_clear( 450 int unit); 451 452 /* Finalize the BCM L2 subsystem. */ 453 extern int bcm_l2_detach( 454 int unit); 455 456 #endif /* BCM_HIDE_DISPATCHABLE */ 457 458 /* 459 * Initialize an L2 address structure to a specified MAC address and VLAN 460 * ID. 461 */ 462 extern void bcm_l2_addr_t_init( 463 bcm_l2_addr_t *l2addr, 464 const bcm_mac_t mac_addr, 465 bcm_vlan_t vid); 466 467 #define bcm_l2_addr_init bcm_l2_addr_t_init 468 469 #ifndef BCM_HIDE_DISPATCHABLE 470 471 /* Add an L2 address entry to the specified device. */ 472 extern int bcm_l2_addr_add( 473 int unit, 474 bcm_l2_addr_t *l2addr); 475 476 #endif /* BCM_HIDE_DISPATCHABLE */ 477 478 #define BCM_L2_DELETE_STATIC 0x00000001 479 #define BCM_L2_DELETE_PENDING 0x00000002 480 #define BCM_L2_DELETE_NO_CALLBACKS 0x00000004 481 #define BCM_L2_DELETE_REMOTE_TRUNK 0x00000008 482 483 #ifndef BCM_HIDE_DISPATCHABLE 484 485 /* Delete an L2 address entry from the specified device. */ 486 extern int bcm_l2_addr_delete( 487 int unit, 488 bcm_mac_t mac, 489 bcm_vlan_t vid); 490 491 /* Delete L2 entries associated with a destination module/port. */ 492 extern int bcm_l2_addr_delete_by_port( 493 int unit, 494 bcm_module_t mod, 495 bcm_port_t port, 496 uint32 flags); 497 498 /* Delete L2 entries associated with a MAC address. */ 499 extern int bcm_l2_addr_delete_by_mac( 500 int unit, 501 bcm_mac_t mac, 502 uint32 flags); 503 504 /* Delete L2 entries associated with a VLAN. */ 505 extern int bcm_l2_addr_delete_by_vlan( 506 int unit, 507 bcm_vlan_t vid, 508 uint32 flags); 509 510 /* Delete L2 entries associated with a trunk. */ 511 extern int bcm_l2_addr_delete_by_trunk( 512 int unit, 513 bcm_trunk_t tid, 514 uint32 flags); 515 516 /* 517 * Delete L2 entries associated with a MAC address and a destination 518 * module/port. 519 */ 520 extern int bcm_l2_addr_delete_by_mac_port( 521 int unit, 522 bcm_mac_t mac, 523 bcm_module_t mod, 524 bcm_port_t port, 525 uint32 flags); 526 527 /* 528 * Delete L2 entries associated with a VLAN and a destination 529 * module/port. 530 */ 531 extern int bcm_l2_addr_delete_by_vlan_port( 532 int unit, 533 bcm_vlan_t vid, 534 bcm_module_t mod, 535 bcm_port_t port, 536 uint32 flags); 537 538 /* 539 * Delete L2 entries associated with a VLAN and a destination 540 * module/port. 541 */ 542 extern int bcm_l2_addr_delete_by_vlan_trunk( 543 int unit, 544 bcm_vlan_t vid, 545 bcm_trunk_t tid, 546 uint32 flags); 547 548 /* Check if an L2 entry is present in the L2 table. */ 549 extern int bcm_l2_addr_get( 550 int unit, 551 bcm_mac_t mac_addr, 552 bcm_vlan_t vid, 553 bcm_l2_addr_t *l2addr); 554 555 #endif /* BCM_HIDE_DISPATCHABLE */ 556 557 /* Dump a hardware-independent L2 address. */ 558 extern void bcm_l2_addr_dump( 559 bcm_l2_addr_t *l2e); 560 561 #ifndef BCM_HIDE_DISPATCHABLE 562 563 /* Dump the key portion of a hardware-independent L2 address. */ 564 extern int bcm_l2_key_dump( 565 int unit, 566 char *pfx, 567 bcm_l2_addr_t *entry, 568 char *sfx); 569 570 #endif /* BCM_HIDE_DISPATCHABLE */ 571 572 /* 573 * Callback function used for receiving notification about insertions 574 * into and deletions from the L2 table dynamically as they occur. Valid 575 * operations are: delete, add, and report. A report with l2addr=NULL 576 * indicates a scan completion of the L2 table. 577 */ 578 typedef void (*bcm_l2_addr_callback_t)( 579 int unit, 580 bcm_l2_addr_t *l2addr, 581 int operation, 582 void *userdata); 583 584 #ifndef BCM_HIDE_DISPATCHABLE 585 586 /* Register/Unregister a callback routine for BCM L2 subsystem. */ 587 extern int bcm_l2_addr_register( 588 int unit, 589 bcm_l2_addr_callback_t callback, 590 void *userdata); 591 592 /* Register/Unregister a callback routine for BCM L2 subsystem. */ 593 extern int bcm_l2_addr_unregister( 594 int unit, 595 bcm_l2_addr_callback_t callback, 596 void *userdata); 597 598 /* Set/Get the age timer. */ 599 extern int bcm_l2_age_timer_set( 600 int unit, 601 int age_seconds); 602 603 /* Set/Get the age timer. */ 604 extern int bcm_l2_age_timer_get( 605 int unit, 606 int *age_seconds); 607 608 /* Set/Get the age timer. */ 609 extern int bcm_l2_age_timer_meta_cycle_set( 610 int unit, 611 int meta_cycle_time); 612 613 /* Set/Get the age timer. */ 614 extern int bcm_l2_age_timer_meta_cycle_get( 615 int unit, 616 int *meta_cycle_time); 617 618 #endif /* BCM_HIDE_DISPATCHABLE */ 619 620 /* Initialize an L2 learn message structure. */ 621 extern void bcm_l2_learn_msgs_config_t_init( 622 bcm_l2_learn_msgs_config_t *learn_msg_config); 623 624 #ifndef BCM_HIDE_DISPATCHABLE 625 626 /* 627 * Set device to distribute learning message to other devices in system 628 * and/or 629 * monitoring CPU. 630 */ 631 extern int bcm_l2_learn_msgs_config_set( 632 int unit, 633 bcm_l2_learn_msgs_config_t *learn_msg_config); 634 635 /* 636 * Get device configuration for distribution of learning messages to 637 * other 638 * devices in system and/or monitoring CPU. 639 */ 640 extern int bcm_l2_learn_msgs_config_get( 641 int unit, 642 bcm_l2_learn_msgs_config_t *learn_msg_config); 643 644 #endif /* BCM_HIDE_DISPATCHABLE */ 645 646 /* Initialize an L2 learn distribution structure. */ 647 extern void bcm_l2_addr_distribute_t_init( 648 bcm_l2_addr_distribute_t *distribution); 649 650 #ifndef BCM_HIDE_DISPATCHABLE 651 652 /* 653 * Per VSI set which events (learn, station move (transplant), aged-out) 654 * to inform CPU about. 655 */ 656 extern int bcm_l2_addr_msg_distribute_set( 657 int unit, 658 bcm_l2_addr_distribute_t *distribution); 659 660 /* 661 * Per VSI, get which events (learn, station move (transplant), aged-out) 662 * to inform CPU about. 663 */ 664 extern int bcm_l2_addr_msg_distribute_get( 665 int unit, 666 bcm_l2_addr_distribute_t *distribution); 667 668 #endif /* BCM_HIDE_DISPATCHABLE */ 669 670 /* Initialize an L2 control information structure. */ 671 extern void bcm_l2_gport_control_info_t_init( 672 bcm_l2_gport_control_info_t *control_info); 673 674 #ifndef BCM_HIDE_DISPATCHABLE 675 676 /* 677 * Per LIF set l2 control infomration(aging profile ID, number of aging 678 * meta-cycles). 679 */ 680 extern int bcm_l2_gport_control_info_set( 681 int unit, 682 bcm_l2_gport_control_info_t *control_info); 683 684 /* 685 * Per LIF get l2 control infomration(aging profile ID, number of aging 686 * meta-cycles). 687 */ 688 extern int bcm_l2_gport_control_info_get( 689 int unit, 690 bcm_l2_gport_control_info_t *control_info); 691 692 /* Temporarily stop/restore L2 table from changing. */ 693 extern int bcm_l2_addr_freeze( 694 int unit); 695 696 /* Temporarily stop/restore L2 table from changing. */ 697 extern int bcm_l2_addr_thaw( 698 int unit); 699 700 /* 701 * Given an L2 address entry, return existing addresses which could 702 * conflict. 703 */ 704 extern int bcm_l2_conflict_get( 705 int unit, 706 bcm_l2_addr_t *addr, 707 bcm_l2_addr_t *cf_array, 708 int cf_max, 709 int *cf_count); 710 711 /* Determine if the given port is "native" from the point of view of L2. */ 712 extern int bcm_l2_port_native( 713 int unit, 714 int modid, 715 int port); 716 717 /* Initialize the L2 cache. */ 718 extern int bcm_l2_cache_init( 719 int unit); 720 721 #endif /* BCM_HIDE_DISPATCHABLE */ 722 723 /* Initialize an L2 cache address structure. */ 724 extern void bcm_l2_cache_addr_t_init( 725 bcm_l2_cache_addr_t *addr); 726 727 #ifndef BCM_HIDE_DISPATCHABLE 728 729 /* Get number of L2 cache entries. */ 730 extern int bcm_l2_cache_size_get( 731 int unit, 732 int *size); 733 734 /* Set an L2 cache entry. */ 735 extern int bcm_l2_cache_set( 736 int unit, 737 int index, 738 bcm_l2_cache_addr_t *addr, 739 int *index_used); 740 741 /* Get an L2 cache entry. */ 742 extern int bcm_l2_cache_get( 743 int unit, 744 int index, 745 bcm_l2_cache_addr_t *addr); 746 747 /* Clear an L2 cache entry. */ 748 extern int bcm_l2_cache_delete( 749 int unit, 750 int index); 751 752 /* Clear all L2 cache entries. */ 753 extern int bcm_l2_cache_delete_all( 754 int unit); 755 756 #endif /* BCM_HIDE_DISPATCHABLE */ 757 758 /* Initialize the l2 egress structure */ 759 extern void bcm_l2_egress_t_init( 760 bcm_l2_egress_t *egr); 761 762 #ifndef BCM_HIDE_DISPATCHABLE 763 764 /* Create an l2 egress entry. */ 765 extern int bcm_l2_egress_create( 766 int unit, 767 bcm_l2_egress_t *egr); 768 769 /* Destroy an l2 egress entry. */ 770 extern int bcm_l2_egress_destroy( 771 int unit, 772 bcm_if_t encap_id); 773 774 /* Get the config of an l2 egress entry with specified encap_id. */ 775 extern int bcm_l2_egress_get( 776 int unit, 777 bcm_if_t encap_id, 778 bcm_l2_egress_t *egr); 779 780 /* Find the encap_id with a given egress config */ 781 extern int bcm_l2_egress_find( 782 int unit, 783 bcm_l2_egress_t *egr, 784 bcm_if_t *encap_id); 785 786 #endif /* BCM_HIDE_DISPATCHABLE */ 787 788 /* l2 egress traverse callback */ 789 typedef int (*bcm_l2_egress_traverse_cb)( 790 int unit, 791 bcm_l2_egress_t *egr, 792 void *user_data); 793 794 #ifndef BCM_HIDE_DISPATCHABLE 795 796 /* 797 * Iterates over all l2 egress entries and executes user callback 798 * function for each valid entry. 799 */ 800 extern int bcm_l2_egress_traverse( 801 int unit, 802 bcm_l2_egress_traverse_cb trav_fn, 803 void *user_data); 804 805 /* Add a destination L2 address to trigger tunnel processing. */ 806 extern int bcm_l2_tunnel_add( 807 int unit, 808 bcm_mac_t mac, 809 bcm_vlan_t vlan); 810 811 /* Clear a destination L2 address used to trigger tunnel processing. */ 812 extern int bcm_l2_tunnel_delete( 813 int unit, 814 bcm_mac_t mac, 815 bcm_vlan_t vlan); 816 817 /* Clear all destination L2 addresses used to trigger tunnel processing. */ 818 extern int bcm_l2_tunnel_delete_all( 819 int unit); 820 821 #endif /* BCM_HIDE_DISPATCHABLE */ 822 823 /* Initialize an L2 learn limit structure. */ 824 extern void bcm_l2_learn_limit_t_init( 825 bcm_l2_learn_limit_t *limit); 826 827 #ifndef BCM_HIDE_DISPATCHABLE 828 829 /* Enable/Disable BCM L2 learn limit subsystem. */ 830 extern int bcm_l2_learn_limit_enable( 831 int unit); 832 833 /* Enable/Disable BCM L2 learn limit subsystem. */ 834 extern int bcm_l2_learn_limit_disable( 835 int unit); 836 837 /* Set/Get L2 addresses learn limit. */ 838 extern int bcm_l2_learn_limit_set( 839 int unit, 840 bcm_l2_learn_limit_t *limit); 841 842 /* Set/Get L2 addresses learn limit. */ 843 extern int bcm_l2_learn_limit_get( 844 int unit, 845 bcm_l2_learn_limit_t *limit); 846 847 #endif /* BCM_HIDE_DISPATCHABLE */ 848 849 #define BCM_L2_LEARN_CLASS_MOVE 0x01 850 851 #ifndef BCM_HIDE_DISPATCHABLE 852 853 /* Set/Get attributes for the specified L2 learning class. */ 854 extern int bcm_l2_learn_class_set( 855 int unit, 856 int lclass, 857 int lclass_prio, 858 uint32 flags); 859 860 /* Set/Get attributes for the specified L2 learning class. */ 861 extern int bcm_l2_learn_class_get( 862 int unit, 863 int lclass, 864 int *lclass_prio, 865 uint32 *flags); 866 867 /* Set/Get L2 learning class for the specified port. */ 868 extern int bcm_l2_learn_port_class_set( 869 int unit, 870 bcm_gport_t port, 871 int lclass); 872 873 #endif /* BCM_HIDE_DISPATCHABLE */ 874 875 /* L2 Statistics. */ 876 typedef enum bcm_l2_stat_e { 877 bcmL2StatSourcePackets = 0, 878 bcmL2StatSourceBytes = 1, 879 bcmL2StatDestPackets = 2, 880 bcmL2StatDestBytes = 3, 881 bcmL2StatDropPackets = 4, 882 bcmL2StatDropBytes = 5 883 } bcm_l2_stat_t; 884 885 #define BCM_STAT_CHECK_L2_STAT(type) do { if ( ((type) < bcmL2StatSourcePackets) || ((type) > bcmL2StatDropBytes) ) { return (BCM_E_BADID); } } while (0) 886 887 #ifndef BCM_HIDE_DISPATCHABLE 888 889 /* Get the specified L2 statistic from the chip. */ 890 extern int bcm_l2_stat_get( 891 int unit, 892 bcm_l2_addr_t *l2_addr, 893 bcm_l2_stat_t stat, 894 uint64 *val); 895 896 /* Get the specified L2 statistic from the chip. */ 897 extern int bcm_l2_stat_get32( 898 int unit, 899 bcm_l2_addr_t *l2_addr, 900 bcm_l2_stat_t stat, 901 uint32 *val); 902 903 /* Set the specified L2 statistic to the indicated value. */ 904 extern int bcm_l2_stat_set( 905 int unit, 906 bcm_l2_addr_t *l2_addr, 907 bcm_l2_stat_t stat, 908 uint64 val); 909 910 /* Set the specified L2 statistic to the indicated value. */ 911 extern int bcm_l2_stat_set32( 912 int unit, 913 bcm_l2_addr_t *l2_addr, 914 bcm_l2_stat_t stat, 915 uint32 val); 916 917 /* Enable/disable collection of statistics on the indicated L2 entry. */ 918 extern int bcm_l2_stat_enable_set( 919 int unit, 920 bcm_l2_addr_t *l2_addr, 921 int enable); 922 923 /* Set/Get L2 learning class for the specified port. */ 924 extern int bcm_l2_learn_port_class_get( 925 int unit, 926 bcm_gport_t port, 927 int *lclass); 928 929 #endif /* BCM_HIDE_DISPATCHABLE */ 930 931 /* L2 Learned Statistic Type. */ 932 typedef enum bcm_l2_learn_stat_type_e { 933 bcmL2LearnStatL2TableLearned = 0, /* The counter of L2_ENTRY learned. */ 934 bcmL2LearnStatOverflowPoolLearned = 1, /* The counter of 128_OVERFLOW_ENTRY 935 learned. */ 936 bcmL2LearnStatHashCollisions = 2, /* The counter of L2_ENTRY hash 937 collision. */ 938 bcmL2LearnStatCount = 3 /* Must be last. */ 939 } bcm_l2_learn_stat_type_t; 940 941 /* L2 Learned Statistic info. */ 942 typedef struct bcm_l2_learn_stat_s { 943 bcm_l2_learn_stat_type_t type; /* L2 learned statistic type. */ 944 uint32 value; /* 32-bit data value for L2 learned 945 statistic. */ 946 } bcm_l2_learn_stat_t; 947 948 /* Initialize an L2 learned statistic structure. */ 949 extern void bcm_l2_learn_stat_t_init( 950 bcm_l2_learn_stat_t *learn_stat); 951 952 #ifndef BCM_HIDE_DISPATCHABLE 953 954 /* Set or clear the specified L2 hash counter to the indicated value. */ 955 extern int bcm_l2_learn_stat_set( 956 int unit, 957 bcm_l2_learn_stat_t *learn_stat); 958 959 /* Get the statistic of the specified L2 hash counter from chip. */ 960 extern int bcm_l2_learn_stat_get( 961 int unit, 962 bcm_l2_learn_stat_t *learn_stat); 963 964 #endif /* BCM_HIDE_DISPATCHABLE */ 965 966 /* bcm_l2_traverse_cb */ 967 typedef int (*bcm_l2_traverse_cb)( 968 int unit, 969 bcm_l2_addr_t *info, 970 void *user_data); 971 972 #ifndef BCM_HIDE_DISPATCHABLE 973 974 /* 975 * Iterates over all entries in the L2 table and executes user callback 976 * function for each entry. 977 */ 978 extern int bcm_l2_traverse( 979 int unit, 980 bcm_l2_traverse_cb trav_fn, 981 void *user_data); 982 983 /* 984 * Iterates over entries in the L2 table and executes user callback 985 * function for each entry matching both given addr and mask. 986 */ 987 extern int bcm_l2_match_masked_traverse( 988 int unit, 989 uint32 flags, 990 bcm_l2_addr_t *match_addr, 991 bcm_l2_addr_t *mask_addr, 992 bcm_l2_traverse_cb trav_fn, 993 void *user_data); 994 995 #endif /* BCM_HIDE_DISPATCHABLE */ 996 997 /* Flags for l2_replace API */ 998 #define BCM_L2_REPLACE_MATCH_STATIC 0x00000001 /* Replace L2 static 999 entries. */ 1000 #define BCM_L2_REPLACE_MATCH_MAC 0x00000002 /* Replace all L2 entries 1001 matching given MAC 1002 address */ 1003 #define BCM_L2_REPLACE_MATCH_VLAN 0x00000004 /* Replace all L2 entries 1004 matching given VLAN id */ 1005 #define BCM_L2_REPLACE_MATCH_DEST 0x00000008 /* Replace all L2 entries 1006 matching given modid 1007 port/tgid */ 1008 #define BCM_L2_REPLACE_VPN_TYPE 0x00000010 /* Replace all VPN type 1009 L2 entry */ 1010 #define BCM_L2_REPLACE_VLAN_AND_VPN_TYPE 0x00000020 /* Replace all VLAN and 1011 VPN type L2 entry */ 1012 #define BCM_L2_REPLACE_DELETE 0x00000100 /* L2 replace will 1013 perform delete 1014 operation instead of 1015 replace on matching 1016 entries */ 1017 #define BCM_L2_REPLACE_NEW_TRUNK 0x00000200 /* New destination is a 1018 trunk group */ 1019 #define BCM_L2_REPLACE_PENDING 0x00000400 /* Replace L2 pending 1020 entries. */ 1021 #define BCM_L2_REPLACE_NO_CALLBACKS 0x00000800 /* Replace L2 entries 1022 without callbacks. */ 1023 #define BCM_L2_REPLACE_LEARN_LIMIT 0x00001000 /* Force ALL entries 1024 including static to be 1025 counted for learn 1026 limit */ 1027 #define BCM_L2_REPLACE_IGNORE_PENDING 0x00002000 /* Force the L2 replace 1028 process to ignore the 1029 pending status check. */ 1030 #define BCM_L2_REPLACE_PROTECTION_RING 0x00004000 /* Replace L2 protection 1031 ring. */ 1032 #define BCM_L2_REPLACE_MIGRATE_PORT 0x00008000 /* Replace L2 port. */ 1033 #define BCM_L2_REPLACE_IGNORE_DISCARD_SRC 0x00010000 /* Match L2 entries with 1034 given Discard on 1035 source. */ 1036 #define BCM_L2_REPLACE_IGNORE_DES_HIT 0x00020000 /* Match L2 entries 1037 ignoring hit-bit 1038 indication. */ 1039 #define BCM_L2_REPLACE_DES_HIT_CLEAR 0x00040000 /* When set then reset 1040 DES Hit-bit state. */ 1041 #define BCM_L2_REPLACE_DISCARD_SRC_SET 0x00080000 /* When set then set 1042 Discard on source */ 1043 #define BCM_L2_REPLACE_DISCARD_SRC_CLEAR 0x00100000 /* When set then reset 1044 Discard on source */ 1045 #define BCM_L2_REPLACE_SRC_HIT_CLEAR 0x00200000 /* When set then reset 1046 SRC Hit-bit state. */ 1047 #define BCM_L2_REPLACE_REMOTE_TRUNK 0x00400000 /* L2 replace will be 1048 performed on remote 1049 trunk entries. */ 1050 #define BCM_L2_REPLACE_AGE 0x01000000 /* L2 replace will 1051 perform age operation 1052 instead of replace on 1053 matching entries */ 1054 #define BCM_L2_REPLACE_MATCH_UC 0x02000000 /* L2 replace will be 1055 performed on Unicast 1056 entries */ 1057 #define BCM_L2_REPLACE_MATCH_MC 0x04000000 /* L2 replace will be 1058 performed on Multicast 1059 entries */ 1060 #define BCM_L2_REPLACE_DYNAMIC_SET 0x08000000 /* L2 replace changes the 1061 MACT entries to be 1062 dynamic */ 1063 #define BCM_L2_REPLACE_DYNAMIC_CLEAR 0x10000000 /* L2 replace changes the 1064 MACT entries to be 1065 static */ 1066 #define BCM_L2_REPLACE_MATCH_AGE 0x20000000 /* L2 replace will be 1067 performed on L2 1068 entries of a given age 1069 state */ 1070 #define BCM_L2_REPLACE_MATCH_CLASS_ID 0x40000000 /* L2 replace will be 1071 performed on L2 1072 entries of a given 1073 class id */ 1074 #define BCM_L2_REPLACE_MATCH_GROUP 0x40000000 /* L2 replace L2 entries 1075 with a given group */ 1076 #define BCM_L2_REPLACE_MATCH_INT_PRI 0x80000000 /* L2 replace will be 1077 performed on L2 1078 entries of a given 1079 internal priority */ 1080 1081 #ifndef BCM_HIDE_DISPATCHABLE 1082 1083 /* Replace destination (or delete) multiple L2 entries. */ 1084 extern int bcm_l2_replace( 1085 int unit, 1086 uint32 flags, 1087 bcm_l2_addr_t *match_addr, 1088 bcm_module_t new_module, 1089 bcm_port_t new_port, 1090 bcm_trunk_t new_trunk); 1091 1092 /* 1093 * Replace destination (or delete) multiple L2 entries matching the given 1094 * address and mask. Only bits that are 1 (turned on) in the mask will be 1095 * checked when checking the match. 1096 */ 1097 extern int bcm_l2_replace_match( 1098 int unit, 1099 uint32 flags, 1100 bcm_l2_addr_t *match_addr, 1101 bcm_l2_addr_t *mask_addr, 1102 bcm_l2_addr_t *replace_addr, 1103 bcm_l2_addr_t *replace_mask_addr); 1104 1105 #endif /* BCM_HIDE_DISPATCHABLE */ 1106 1107 /* L2 Forwarding Domain Type. */ 1108 typedef enum bcm_l2_forward_domain_type_e { 1109 bcmL2ForwardDomainVlan = 0, /* VLAN. */ 1110 bcmL2ForwardDomainVpn = 1, /* VFI. */ 1111 bcmL2ForwardDomainVlanClassId = 2, /* Use VLAN class ID from VLAN table as 1112 forward field. */ 1113 bcmL2ForwardDomainCount = 3 /* Must be last. */ 1114 } bcm_l2_forward_domain_type_t; 1115 1116 /* L2 Station address info. */ 1117 typedef struct bcm_l2_station_s { 1118 uint32 flags; /* BCM_L2_STATION_xxx flags. */ 1119 int priority; /* Entry priority. */ 1120 bcm_mac_t dst_mac; /* Destination MAC address to match. */ 1121 bcm_mac_t dst_mac_mask; /* Destination MAC address mask value. */ 1122 bcm_vlan_t vlan; /* VLAN to match. */ 1123 bcm_vlan_t vlan_mask; /* VLAN mask value. */ 1124 bcm_port_t src_port; /* Ingress port to match. */ 1125 bcm_port_t src_port_mask; /* Ingress port mask value. */ 1126 bcm_tsn_pri_map_t taf_gate_primap; /* TAF (Time Aware Filtering) gate 1127 priority mapping */ 1128 bcm_l2_forward_domain_type_t forward_domain_type; /* L2 forwarding domain type. */ 1129 uint8 forward_domain_type_mask; /* L2 forwarding domain type mask. */ 1130 bcm_vlan_t inner_vlan; /* Inner VLAN to match. */ 1131 bcm_vlan_t inner_vlan_mask; /* Inner VLAN mask value. */ 1132 bcm_vlan_t vfi; /* Port default virtual forwarding 1133 instance to match. */ 1134 bcm_vlan_t vfi_mask; /* Port default virtual forwarding 1135 instance mask. */ 1136 bcm_vlan_t forwarding_domain; /* Forwarding domain for the packet with 1137 matched VLAN. */ 1138 } bcm_l2_station_t; 1139 1140 /* bcm_l2_station_traverse_cb */ 1141 typedef int (*bcm_l2_station_traverse_cb)( 1142 int unit, 1143 bcm_l2_station_t *l2_station_addr, 1144 void *user_data); 1145 1146 #ifndef BCM_HIDE_DISPATCHABLE 1147 1148 /* 1149 * Iterates over all entries in the L2 station table and executes user 1150 * callback function for each entry. 1151 */ 1152 extern int bcm_l2_station_traverse( 1153 int unit, 1154 bcm_l2_station_traverse_cb trav_fn, 1155 void *user_data); 1156 1157 #endif /* BCM_HIDE_DISPATCHABLE */ 1158 1159 /* Flags for bcm_l2_station_add/get APIs. */ 1160 #define BCM_L2_STATION_WITH_ID (1 << 0) /* Use the specified Station ID. */ 1161 #define BCM_L2_STATION_REPLACE (1 << 1) /* Replace an existing L2 Station 1162 table entry. */ 1163 #define BCM_L2_STATION_IPV4 (1 << 2) /* Subject packets matching this 1164 entry to L3 processing. */ 1165 #define BCM_L2_STATION_IPV6 (1 << 3) /* Subject packets matching this 1166 entry to L3 processing. */ 1167 #define BCM_L2_STATION_ARP_RARP (1 << 4) /* Subject packets matching this 1168 entry to ARP/RARP processing. */ 1169 #define BCM_L2_STATION_MPLS (1 << 5) /* Subject packets matching this 1170 entry to MPLS processing. */ 1171 #define BCM_L2_STATION_MIM (1 << 6) /* Subject packets matching this 1172 entry to MiM processing. */ 1173 #define BCM_L2_STATION_TRILL (1 << 7) /* Subject packets matching this 1174 entry to Trill processing. */ 1175 #define BCM_L2_STATION_FCOE (1 << 8) /* Subject packets matching this 1176 entry to FCoE processing. */ 1177 #define BCM_L2_STATION_OAM (1 << 9) /* Subject packets matching this 1178 entry to OAM processing. */ 1179 #define BCM_L2_STATION_COPY_TO_CPU (1 << 10) /* Copy packet to CPU. */ 1180 #define BCM_L2_STATION_OLP (1 << 11) /* Subject packets matching this 1181 entry to OAM-OLP header 1182 processing. */ 1183 #define BCM_L2_STATION_XGS_MAC (1 << 12) /* Add this MAC address as source 1184 MAC in the OLP header for 1185 packets sent to OLP. */ 1186 #define BCM_L2_STATION_IPV4_MCAST (1 << 13) /* Subject packets matching this 1187 entry to IPV4 mcast 1188 processing. */ 1189 #define BCM_L2_STATION_IPV6_MCAST (1 << 14) /* Subject packets matching this 1190 entry to IPV6 mcast 1191 processing. */ 1192 #define BCM_L2_STATION_UNDERLAY (1 << 15) /* When RIOT is enabled, this 1193 flag must be set for creating 1194 tunnel mac addresses to 1195 distinguish them from routing 1196 mac addresses */ 1197 #define BCM_L2_STATION_DISCARD (1 << 16) /* Discard packets matching this 1198 entry */ 1199 #define BCM_L2_STATION_EXTENDED (1 << 17) /* Indicate extended memory usage */ 1200 #define BCM_L2_STATION_NSH_OVER_L2 (1 << 18) /* Allow NSH over L2 termination */ 1201 1202 /* Initialize L2 Station structure */ 1203 extern void bcm_l2_station_t_init( 1204 bcm_l2_station_t *addr); 1205 1206 #ifndef BCM_HIDE_DISPATCHABLE 1207 1208 /* Add an entry to L2 Station table */ 1209 extern int bcm_l2_station_add( 1210 int unit, 1211 int *station_id, 1212 bcm_l2_station_t *station); 1213 1214 /* Delete an entry from L2 Station Table */ 1215 extern int bcm_l2_station_delete( 1216 int unit, 1217 int station_id); 1218 1219 /* Clear L2 station table */ 1220 extern int bcm_l2_station_delete_all( 1221 int unit); 1222 1223 /* Get L2 station entry details from Station Table. */ 1224 extern int bcm_l2_station_get( 1225 int unit, 1226 int station_id, 1227 bcm_l2_station_t *station); 1228 1229 /* Get size of L2 Station Table */ 1230 extern int bcm_l2_station_size_get( 1231 int unit, 1232 int *size); 1233 1234 #endif /* BCM_HIDE_DISPATCHABLE */ 1235 1236 /* L2 ring structure. */ 1237 typedef struct bcm_l2_ring_s { 1238 uint32 flags; /* flags */ 1239 bcm_vlan_vector_t vlan_vector; /* List of Vlans. */ 1240 bcm_gport_t port0; /* VLAN gport */ 1241 bcm_gport_t port1; /* VLAN gport */ 1242 bcm_vpn_vector_t vpn_vector; /* List of VPN IDs. */ 1243 bcm_vlan_t vlan; /* Base Vlan id. */ 1244 bcm_vlan_t vlan_mask; /* Vlan Mask. */ 1245 bcm_vpn_t vpn; /* Base VPN id. */ 1246 bcm_vpn_t vpn_mask; /* VPN Mask. */ 1247 } bcm_l2_ring_t; 1248 1249 /* Initialize an empty L2 ring failover structure. */ 1250 extern void bcm_l2_ring_t_init( 1251 bcm_l2_ring_t *l2_ring); 1252 1253 #ifndef BCM_HIDE_DISPATCHABLE 1254 1255 /* Invoke accelerated L2 ring failover mechanism */ 1256 extern int bcm_l2_ring_replace( 1257 int unit, 1258 bcm_l2_ring_t *l2_ring); 1259 1260 #endif /* BCM_HIDE_DISPATCHABLE */ 1261 1262 /* Device-independent L2 SA authentication structure. */ 1263 typedef struct bcm_l2_auth_addr_s { 1264 uint32 flags; /* BCM_L2_AUTH_XXX flags. */ 1265 bcm_mac_t sa_mac; /* SA MAC address to match. */ 1266 bcm_vlan_t vlan; /* VLAN to match. */ 1267 bcm_port_t src_port; /* ingress port to match. */ 1268 } bcm_l2_auth_addr_t; 1269 1270 /* The callback function called for each valid entry in l2-auth. */ 1271 typedef int (*bcm_l2_auth_traverse_cb)( 1272 int unit, 1273 bcm_l2_auth_addr_t *info, 1274 void *userdata); 1275 1276 #define BCM_L2_AUTH_CHECK_IN_PORT 0x00000001 /* check packet with sa_mac 1277 received on the expected 1278 src_port. */ 1279 #define BCM_L2_AUTH_CHECK_VLAN 0x00000002 /* check packet with sa_mac 1280 received on the expected 1281 vlan */ 1282 #define BCM_L2_AUTH_PERMIT_TAGGED_ONLY 0x00000004 /* permit only tagged packets */ 1283 1284 /* 1285 * Initialize an L2 SA authentication structure to a specified MAC 1286 * address and VLAN ID. 1287 */ 1288 extern void bcm_l2_auth_addr_t_init( 1289 bcm_l2_auth_addr_t *addr); 1290 1291 #ifndef BCM_HIDE_DISPATCHABLE 1292 1293 /* Add an L2 authentication entry. */ 1294 extern int bcm_l2_auth_add( 1295 int unit, 1296 bcm_l2_auth_addr_t *addr); 1297 1298 /* Get an L2 authentication entry. */ 1299 extern int bcm_l2_auth_get( 1300 int unit, 1301 bcm_l2_auth_addr_t *addr); 1302 1303 /* Delete an L2 authentication entry. */ 1304 extern int bcm_l2_auth_delete( 1305 int unit, 1306 bcm_l2_auth_addr_t *addr); 1307 1308 /* Clear all L2 authentication entries. */ 1309 extern int bcm_l2_auth_delete_all( 1310 int unit); 1311 1312 /* 1313 * Iterates over all l2 authentication entriesand executes user call back 1314 * function for each valid entry. 1315 */ 1316 extern int bcm_l2_auth_traverse( 1317 int unit, 1318 bcm_l2_auth_traverse_cb trav_fn, 1319 void *user_data); 1320 1321 /* 1322 * Iterates over matching entries in the L2 table and executes user 1323 * callback function for each matching entry 1324 */ 1325 extern int bcm_l2_matched_traverse( 1326 int unit, 1327 uint32 flags, 1328 bcm_l2_addr_t *match_addr, 1329 bcm_l2_traverse_cb trav_fn, 1330 void *user_data); 1331 1332 #endif /* BCM_HIDE_DISPATCHABLE */ 1333 1334 /* Flags for bcm_l2_traverse_match API. */ 1335 #define BCM_L2_TRAVERSE_MATCH_STATIC (1 << 0) /* Match L2 static 1336 entries only, if it 1337 and 1338 L2_TRAVERSE_MATCH_DYNAMIC 1339 not present match 1340 static entries 1341 together with all 1342 other entries */ 1343 #define BCM_L2_TRAVERSE_MATCH_MAC (1 << 1) /* Match L2 entries with 1344 given MAC address */ 1345 #define BCM_L2_TRAVERSE_MATCH_VLAN (1 << 2) /* Match L2 entries with 1346 given VLAN ID */ 1347 #define BCM_L2_TRAVERSE_MATCH_DEST (1 << 3) /* Match L2 entries with 1348 given modid port/tgid */ 1349 #define BCM_L2_TRAVERSE_IGNORE_DISCARD_SRC (1 << 4) /* match entries ignoring 1350 destination SA-discard 1351 indication */ 1352 #define BCM_L2_TRAVERSE_IGNORE_DES_HIT (1 << 5) /* match entries ignoring 1353 destination hit-bit 1354 indication */ 1355 #define BCM_L2_TRAVERSE_IGNORE_SRC_HIT (1 << 6) /* match entries ignoring 1356 source hit-bit 1357 indication */ 1358 #define BCM_L2_TRAVERSE_MATCH_NATIVE (1 << 7) /* Match entries with 1359 given local address 1360 indication */ 1361 #define BCM_L2_TRAVERSE_MATCH_DYNAMIC (1 << 8) /* Match L2 non-static 1362 entries only, if it 1363 and 1364 L2_TRAVERSE_MATCH_STATIC 1365 not present match 1366 dynamic entries 1367 together with all 1368 other entries */ 1369 #define BCM_L2_TRAVERSE_MATCH_IVL (1 << 9) /* Traverse l2 entries 1370 that have an IVL 1371 format. */ 1372 #define BCM_L2_TRAVERSE_MATCH_GROUP (1 << 10) /* Match L2 entries with 1373 a given group. */ 1374 #define BCM_L2_TRAVERSE_MATCH_MESH (1 << 11) /* Match L2 entries with 1375 mesh bit set. */ 1376 #define BCM_L2_TRAVERSE_IGNORE_PENDING (1 << 12) /* non-blocking traverse. */ 1377 1378 /* BCM_L2_MAC_PORT_* flags. */ 1379 #define BCM_L2_MAC_PORT_WITH_ID 0x00000001 /* create mac port with specified ID */ 1380 #define BCM_L2_MAC_PORT_REPLACE 0x00000002 /* Replace existing mac port */ 1381 1382 /* MAC port type. */ 1383 typedef struct bcm_l2_mac_port_s { 1384 uint32 flags; /* BCM_L2_MAC_PORT_xxx. */ 1385 bcm_mac_t mac; /* MAC address to match. */ 1386 bcm_gport_t port; /* Physical port / trunk */ 1387 bcm_gport_t mac_port_id; /* MAC GPORT ID. */ 1388 } bcm_l2_mac_port_t; 1389 1390 /* Initialize the MAC port structure. */ 1391 extern void bcm_l2_mac_port_t_init( 1392 bcm_l2_mac_port_t *mac_port); 1393 1394 #ifndef BCM_HIDE_DISPATCHABLE 1395 1396 /* Create MAC port */ 1397 extern int bcm_l2_mac_port_create( 1398 int unit, 1399 bcm_l2_mac_port_t *mac_port); 1400 1401 /* Destroy MAC port. */ 1402 extern int bcm_l2_mac_port_destroy( 1403 int unit, 1404 bcm_gport_t mac_port_id); 1405 1406 /* Destroy all MAC ports. */ 1407 extern int bcm_l2_mac_port_destroy_all( 1408 int unit); 1409 1410 /* Get MAC Port information */ 1411 extern int bcm_l2_mac_port_get( 1412 int unit, 1413 bcm_l2_mac_port_t *mac_port); 1414 1415 #endif /* BCM_HIDE_DISPATCHABLE */ 1416 1417 /* MAC port traverse function prototype. */ 1418 typedef int (*bcm_l2_mac_port_traverse_cb)( 1419 int unit, 1420 bcm_l2_mac_port_t *mac_port, 1421 void *user_data); 1422 1423 #ifndef BCM_HIDE_DISPATCHABLE 1424 1425 /* Traverse MAC ports */ 1426 extern int bcm_l2_mac_port_traverse( 1427 int unit, 1428 bcm_l2_mac_port_traverse_cb cb, 1429 void *user_data); 1430 1431 #endif /* BCM_HIDE_DISPATCHABLE */ 1432 1433 /* Struct to get gport forward info */ 1434 typedef struct bcm_l2_gport_forward_info_s { 1435 int phy_gport; 1436 int encap_id; 1437 } bcm_l2_gport_forward_info_t; 1438 1439 /* Initialize bcm_l2_gport_forward_info_t struct */ 1440 extern void bcm_l2_gport_forward_info_t_init( 1441 bcm_l2_gport_forward_info_t *forward_info); 1442 1443 #ifndef BCM_HIDE_DISPATCHABLE 1444 1445 /* Get the forwarding information for the given gport. */ 1446 extern int bcm_l2_gport_forward_info_get( 1447 int unit, 1448 int gport_id, 1449 bcm_l2_gport_forward_info_t *forward_info); 1450 1451 /* Purge L2 Entries for the specific set of (port,vlan) pairs. */ 1452 extern int bcm_l2_addr_delete_by_vlan_gport_multi( 1453 int unit, 1454 uint32 flags, 1455 int num_pairs, 1456 bcm_vlan_t *vlan, 1457 bcm_gport_t *gport); 1458 1459 /* Add mutli L2 address entry to the specified device. */ 1460 extern int bcm_l2_addr_multi_add( 1461 int unit, 1462 bcm_l2_addr_t *l2addr, 1463 int count); 1464 1465 /* Delete multi L2 address entry from the specified device. */ 1466 extern int bcm_l2_addr_multi_delete( 1467 int unit, 1468 bcm_l2_addr_t *l2addr, 1469 int count); 1470 1471 #endif /* BCM_HIDE_DISPATCHABLE */ 1472 1473 /* Max number of MACs in the structure below. */ 1474 #define BCM_RX_TRAP_L2CP_NOF_ENTRIES 64 1475 1476 /* Set of MACS for L2CP traps profile build. */ 1477 typedef struct bcm_l2cp_profile_info_s { 1478 int nof_entries; 1479 bcm_mac_t mac_add[BCM_RX_TRAP_L2CP_NOF_ENTRIES]; 1480 } bcm_l2cp_profile_info_t; 1481 1482 #ifndef BCM_HIDE_DISPATCHABLE 1483 1484 /* creates and writes down to HW the bitmap profile for L2CP traps. */ 1485 extern int bcm_l2_cache_profile_set( 1486 int unit, 1487 int trap_type, 1488 uint32 profile_idx, 1489 uint32 flags, 1490 bcm_l2cp_profile_info_t *l2cp_profile_info); 1491 1492 /* reads from HW the bitmap profile for L2CP traps. */ 1493 extern int bcm_l2_cache_profile_get( 1494 int unit, 1495 int trap_type, 1496 uint32 profile_idx, 1497 uint32 flags, 1498 bcm_l2cp_profile_info_t *l2cp_profile_info); 1499 1500 /* 1501 * links the given VPN to required profile index (from 0 to 3) for L2CP 1502 * traps. 1503 */ 1504 extern int bcm_l2_cache_vpn_to_profile_map_set( 1505 int unit, 1506 uint32 vsi, 1507 uint32 profile_idx); 1508 1509 /* for the given VPN returns profile index (from 0 to 3) for L2CP traps. */ 1510 extern int bcm_l2_cache_vpn_to_profile_map_get( 1511 int unit, 1512 uint32 vsi, 1513 uint32 *profile_idx); 1514 1515 /* 1516 * Retrieve a MAC entry according to mac, vid (used as VSI) and modid. 1517 * When modid != 0 it should hold a VLAN ID for IVL entries. 1518 */ 1519 extern int bcm_l2_addr_by_struct_get( 1520 int unit, 1521 bcm_l2_addr_t *l2addr); 1522 1523 /* 1524 * Delete a MAC entry according to mac, vid (used as VSI) and modid. When 1525 * modid != 0 it should hold a VLAN ID for IVL entries. 1526 */ 1527 extern int bcm_l2_addr_by_struct_delete( 1528 int unit, 1529 bcm_l2_addr_t *l2addr); 1530 1531 #endif /* BCM_HIDE_DISPATCHABLE */ 1532 1533 #if defined(INCLUDE_L3) 1534 /* Requires BROADCOM_PREMIUM license */ 1535 #define BCM_L2_CHANGE_FIELDS_DVP (1 << 0) /* DVP key paramter is 1536 valid. */ 1537 #define BCM_L2_CHANGE_FIELDS_REPLACE (1 << 1) /* Replace L2 Change 1538 Fields entry for given 1539 key fields. */ 1540 #define BCM_L2_CHANGE_FIELDS_VLAN_ADD (1 << 2) /* Add payload VLAN tag. */ 1541 #define BCM_L2_CHANGE_FIELDS_VLAN_DELETE (1 << 3) /* Delete payload vlan. */ 1542 #define BCM_L2_CHANGE_FIELDS_VLAN_REPLACE (1 << 4) /* Replace payload vlan 1543 tag. */ 1544 #define BCM_L2_CHANGE_FIELDS_VLAN_PRI_TPID_REPLACE (1 << 5) /* Replace payload vlan, 1545 priority and tpid. */ 1546 #define BCM_L2_CHANGE_FIELDS_VLAN_TPID_REPLACE (1 << 6) /* Replace payload vlan 1547 and tpid. */ 1548 #define BCM_L2_CHANGE_FIELDS_VLAN_PRI_REPLACE (1 << 7) /* Replace payload vlan 1549 and priority. */ 1550 #define BCM_L2_CHANGE_FIELDS_PRI_REPLACE (1 << 8) /* Replace payload 1551 priority only. */ 1552 #define BCM_L2_CHANGE_FIELDS_TPID_REPLACE (1 << 9) /* Replace payload tpid 1553 only. */ 1554 #endif 1555 1556 #if defined(INCLUDE_L3) 1557 /* Requires BROADCOM_PREMIUM license */ 1558 typedef struct bcm_l2_change_fields_s { 1559 uint32 flags; 1560 bcm_mac_t macda; 1561 bcm_mac_t macsa; 1562 uint8 pri; 1563 uint8 cfi; 1564 uint16 tpid; 1565 uint16 vlan; 1566 uint32 change_l2_fields_class_id; 1567 bcm_gport_t dvp; 1568 } bcm_l2_change_fields_t; 1569 #endif 1570 1571 /* Requires BROADCOM_PREMIUM license */ 1572 #if defined(INCLUDE_L3) 1573 typedef int (*bcm_l2_change_fields_traverse_cb)( 1574 int unit, 1575 bcm_l2_change_fields_t *l2_fields_info, 1576 void *user_data); 1577 #endif 1578 1579 #if defined(INCLUDE_L3) 1580 /* Requires BROADCOM_PREMIUM license */ 1581 extern void bcm_l2_change_fields_t_init( 1582 bcm_l2_change_fields_t *l2_fields_info); 1583 #endif 1584 1585 #ifndef BCM_HIDE_DISPATCHABLE 1586 1587 #if defined(INCLUDE_L3) 1588 /* Requires BROADCOM_PREMIUM license */ 1589 extern int bcm_l2_change_fields_add( 1590 int unit, 1591 bcm_l2_change_fields_t *l2_fields_info); 1592 #endif 1593 1594 #if defined(INCLUDE_L3) 1595 /* Requires BROADCOM_PREMIUM license */ 1596 extern int bcm_l2_change_fields_delete( 1597 int unit, 1598 bcm_l2_change_fields_t *l2_fields_info); 1599 #endif 1600 1601 #if defined(INCLUDE_L3) 1602 /* Requires BROADCOM_PREMIUM license */ 1603 extern int bcm_l2_change_fields_get( 1604 int unit, 1605 bcm_l2_change_fields_t *l2_fields_info); 1606 #endif 1607 1608 #if defined(INCLUDE_L3) 1609 /* Requires BROADCOM_PREMIUM license */ 1610 extern int bcm_l2_change_fields_traverse( 1611 int unit, 1612 bcm_l2_change_fields_traverse_cb cb, 1613 void *user_data); 1614 #endif 1615 1616 #endif /* BCM_HIDE_DISPATCHABLE */ 1617 1618 #endif /* __BCM_L2_H__ */