trunk.h (35609B)
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_TRUNK_H__ 11 #define __BCM_TRUNK_H__ 12 13 #include <bcm/types.h> 14 #include <shared/trunk.h> 15 16 #define BCM_TRUNK_MAX_PORTCNT 256 /* Maximum number of ports in 17 a trunk group */ 18 #define BCM_TRUNK_FABRIC_MAX_PORTCNT 32 /* Maximum number of ports in 19 a fabric trunk group */ 20 #define BCM_TRUNK_UNSPEC_INDEX -1 /* Let software set 21 DLF/MC/IPMC. */ 22 23 /* Port Selection Criteria. */ 24 #define BCM_TRUNK_PSC_SRCMAC 1 /* Source MAC address. */ 25 #define BCM_TRUNK_PSC_DSTMAC 2 /* Destination MAC address. */ 26 #define BCM_TRUNK_PSC_SRCDSTMAC 3 /* Source+dest MAC address. */ 27 #define BCM_TRUNK_PSC_SRCIP 4 /* Source IP address. */ 28 #define BCM_TRUNK_PSC_DSTIP 5 /* Destination IP address. */ 29 #define BCM_TRUNK_PSC_SRCDSTIP 6 /* Source+dest IP address. */ 30 #define BCM_TRUNK_PSC_REDUNDANT 7 /* Redundant (xgs_fabric). */ 31 #define BCM_TRUNK_PSC_PORTINDEX 8 /* Port index. */ 32 #define BCM_TRUNK_PSC_PORTFLOW 9 /* Enhanced hashing. */ 33 #define BCM_TRUNK_PSC_VLANINDEX 10 /* Static port selection 34 based on VLAN ID. */ 35 #define BCM_TRUNK_PSC_DYNAMIC 11 /* Dynamic load balancing 36 normal mode. */ 37 #define BCM_TRUNK_PSC_DYNAMIC_ASSIGNED 12 /* Dynamic load balancing 38 assigned mode. */ 39 #define BCM_TRUNK_PSC_DYNAMIC_OPTIMAL 13 /* Dynamic load balancing 40 optimal mode. */ 41 #define BCM_TRUNK_PSC_ROUND_ROBIN 14 /* Round robin selection of 42 members. */ 43 #define BCM_TRUNK_PSC_DYNAMIC_RESILIENT 15 /* Resilient load balancing 44 mode. */ 45 #define BCM_TRUNK_PSC_RANDOMIZED 16 /* Randomized load balancing 46 mode. */ 47 #define BCM_TRUNK_PSC_SMOOTH_DIVISION 17 /* Use Smooth Division table 48 to choose members. */ 49 #define BCM_TRUNK_PSC_C_LAG 18 /* Use Consistent Lag tables 50 to choose members. */ 51 #define BCM_TRUNK_PSC_WEIGHTED_PROFILE 19 /* Use Weighted profile to 52 choose members. */ 53 54 /* 55 * BCM5675 has additional fields for hashing in trunk mode. 56 * BCM_TRUNK_PSC_EGRESS_VID and BCM_TRUNK_PSC_RANDOM are for software 57 * IPMC trunk resolution. 58 */ 59 #define BCM_TRUNK_PSC_IPMACSA 0x00010 /* Include IP: MAC source 60 address. */ 61 #define BCM_TRUNK_PSC_IPMACDA 0x00020 /* Include IP: MAC dest address. */ 62 #define BCM_TRUNK_PSC_IPTYPE 0x00040 /* Include IP: EtherType. */ 63 #define BCM_TRUNK_PSC_IPVID 0x00080 /* Include IP: VLAN ID. */ 64 #define BCM_TRUNK_PSC_IPSA 0x00100 /* Include IP: source address. */ 65 #define BCM_TRUNK_PSC_IPDA 0x00200 /* Include IP: dest address. */ 66 #define BCM_TRUNK_PSC_L4SS 0x00400 /* Include TCP/UDP source socket. */ 67 #define BCM_TRUNK_PSC_L4DS 0x00800 /* Include TCP/UDP dest socket. */ 68 #define BCM_TRUNK_PSC_MACSA 0x01000 /* Include Non-IP: MAC source 69 address. */ 70 #define BCM_TRUNK_PSC_MACDA 0x02000 /* Include Non-IP: MAC dest 71 address. */ 72 #define BCM_TRUNK_PSC_TYPE 0x04000 /* Include Non-IP: EtherType. */ 73 #define BCM_TRUNK_PSC_VID 0x08000 /* Include Non-IP: VLAN ID. */ 74 #define BCM_TRUNK_PSC_EGRESS_VID 0x10000 /* Include Egress VLAN ID. */ 75 #define BCM_TRUNK_PSC_RANDOM 0x20000 /* Include random number. */ 76 77 #define BCM_TRUNK_PSC_DEFAULT BCM_TRUNK_PSC_SRCDSTMAC 78 79 /* Backward compatibility. */ 80 #define BCM_RTAG_SRCMAC BCM_TRUNK_PSC_SRCMAC 81 #define BCM_RTAG_DSTMAC BCM_TRUNK_PSC_DSTMAC 82 #define BCM_RTAG_SRCDSTMAC BCM_TRUNK_PSC_SRCDSTMAC 83 #define BCM_RTAG_SRCIP BCM_TRUNK_PSC_SRCIP 84 #define BCM_RTAG_DSTIP BCM_TRUNK_PSC_DSTIP 85 #define BCM_RTAG_SRCDSTIP BCM_TRUNK_PSC_SRCDSTIP 86 #define BCM_TRUNK_DEF_RTAG BCM_TRUNK_PSC_DEFAULT 87 88 #define BCM_TRUNK_PSC_NAMES_INITIALIZER \ 89 { \ 90 "unknown", \ 91 "srcmac", \ 92 "destmac", \ 93 "srcdestmac", \ 94 "srcip", \ 95 "destip", \ 96 "srcdestip", \ 97 "redundant", \ 98 "portindex", \ 99 "portflow", \ 100 "invalid" \ 101 } 102 103 /* Trunk group set flags. */ 104 #define BCM_TRUNK_FLAG_FAILOVER_NEXT 0x0001 /* Failover port defaults 105 to the next port in 106 the trunk port list. */ 107 #define BCM_TRUNK_FLAG_FAILOVER_NEXT_LOCAL 0x0002 /* Failover port defaults 108 to the next local port 109 in the trunk port 110 list, if any. */ 111 #define BCM_TRUNK_FLAG_FAILOVER_ALL 0x0004 /* Failover ports default 112 to all other ports in 113 this trunk. */ 114 #define BCM_TRUNK_FLAG_FAILOVER_ALL_LOCAL 0x0008 /* Failover ports default 115 to all other local 116 ports in this trunk. */ 117 #define BCM_TRUNK_FLAG_FAILOVER BCM_TRUNK_FLAG_FAILOVER_NEXT_LOCAL /* Enable trunk failover 118 support (deprecated). */ 119 #define BCM_TRUNK_FLAG_WITH_ID 0x0010 /* Use the trunk ID 120 supplied by user. */ 121 #define BCM_TRUNK_FLAG_IPMC_CLEAVE 0x0020 /* Disable trunk 122 resolution for IPMC 123 packets in hardware. */ 124 #define BCM_TRUNK_FLAG_DYNAMIC_LOAD_DECREASE_RESET 0x0040 /* If set, historical 125 member load is reset 126 to the instantaneous 127 member load if the 128 latter is smaller. */ 129 #define BCM_TRUNK_FLAG_DYNAMIC_EXPECTED_LOAD_DECREASE_RESET 0x0080 /* If set, historical 130 expected member load 131 is reset to the 132 instantaneous expected 133 member load if the 134 latter is smaller. */ 135 #define BCM_TRUNK_FLAG_STACKING_TMD 0x0100 /* If set, Create trunk 136 which refer to 137 TM-domain Stacking 138 port. */ 139 #define BCM_TRUNK_FLAG_VP 0x0200 /* If set, Create a 140 virtual port trunk 141 group. */ 142 #define BCM_TRUNK_FLAG_MEMBER_SORT 0x0400 /* If set, Create a trunk 143 group with sorted 144 members. */ 145 #define BCM_TRUNK_FLAG_LOCAL 0x0800 /* If set, trunk can 146 contain only local 147 members. */ 148 #define BCM_TRUNK_FLAG_DONT_ALLOCATE_PP_PORTS 0x1000 /* If set, trunk will not 149 alocate pp ports by 150 default. */ 151 #define BCM_TRUNK_FLAG_WITH_VPLAG_ID 0x2000 /* If set, use the VPLAG 152 id supplied by the 153 user. */ 154 #define BCM_TRUNK_FLAG_WEIGHTED 0x4000 /* If set, indicates it 155 is a weighted group 156 and only with 157 BCM_TRUNK_FLAG_VP when 158 creating a VP trunk 159 group. The members 160 count value must be in 161 powers-of-2. */ 162 163 /* Trunk member flags. */ 164 #define BCM_TRUNK_MEMBER_INGRESS_DISABLE 0x0001 /* Member will not 165 receive traffic. 166 Receive traffic will 167 be treated as normal 168 port. 169 To drop all receive 170 traffic use: 171 bcm_port_discard_set, */ 172 #define BCM_TRUNK_MEMBER_EGRESS_DISABLE 0x0002 /* Member will not be a 173 part of the 174 distributor members to 175 be hashed. */ 176 #define BCM_TRUNK_MEMBER_EGRESS_DROP 0x0004 /* Member is part of the 177 distributor hash but 178 any traffic hashed to 179 this member will be 180 dropped. */ 181 #define BCM_TRUNK_MEMBER_UNICAST_EGRESS_DISABLE 0x0008 /* Member will not be a 182 part of the unicast 183 distributor members to 184 be hashed. */ 185 #define BCM_TRUNK_MEMBER_IPMC_EGRESS_DISABLE 0x0010 /* Member will not be a 186 part of the IPMC 187 distributor members to 188 be hashed. */ 189 #define BCM_TRUNK_MEMBER_L2MC_EGRESS_DISABLE 0x0020 /* Member will not be a 190 part of the L2MC 191 distributor members to 192 be hashed. */ 193 #define BCM_TRUNK_MEMBER_BCAST_EGRESS_DISABLE 0x0040 /* Member will not be a 194 part of the broadcast 195 distributor members to 196 be hashed. */ 197 #define BCM_TRUNK_MEMBER_DLF_EGRESS_DISABLE 0x0080 /* Member will not be a 198 part of the unknown 199 unicast or unknown 200 multicast distributor 201 members to be hashed. */ 202 #define BCM_TRUNK_MEMBER_MEMBER_DISABLE 0x0100 /* Member will not 203 recieve traffic as 204 result of hashing */ 205 #define BCM_TRUNK_MEMBER_DGM_ALTERNATE 0x0200 /* If set indicating 206 TRUNK member is within 207 alternate path, else 208 within primary path. */ 209 210 /* 211 * Flags for configuring EtherType eligibility for dynamic load 212 * balancing. 213 */ 214 #define BCM_TRUNK_DYNAMIC_ETHERTYPE_ELIGIBLE 0x01 /* If set, the specified 215 EtherTypes are 216 eligible, else 217 ineligible. */ 218 #define BCM_TRUNK_DYNAMIC_ETHERTYPE_INNER 0x02 /* Use packet's inner 219 EtherType. */ 220 #define BCM_TRUNK_DYNAMIC_ETHERTYPE_TRUNK 0x04 /* Configure EtherType 221 eligibility for trunk 222 dynamic load 223 balancing. */ 224 #define BCM_TRUNK_DYNAMIC_ETHERTYPE_FABRIC_TRUNK 0x08 /* Configure EtherType 225 eligibility for HiGig 226 trunk dynamic load 227 balancing. */ 228 #define BCM_TRUNK_DYNAMIC_ETHERTYPE_RESILIENT 0x10 /* If set, configure 229 EtherType eligibility 230 for resilient load 231 balancing, else for 232 dynamic load 233 balancing. */ 234 235 /* Trunk Macro to support stacking trunk. */ 236 #define BCM_TRUNK_STACKING_TID_BIT 16 /* Bit offset which indicate the 237 tid is Stacking trunk. */ 238 #define BCM_TRUNK_STACKING_TID_SET(tid, peer_tmd) tid = peer_tmd | (1 << 16) /* Mark the tid as Stacking 239 trunk. */ 240 #define BCM_TRUNK_STACKING_TID_GET(tid) tid & ~(1 << 16) /* Get the tid from Stacking 241 trunk. */ 242 243 /* Resilient trunk flags. */ 244 #define BCM_TRUNK_RESILIENT_MATCH_HASH_KEY (1 << 0) /* Match on the hash key 245 value */ 246 #define BCM_TRUNK_RESILIENT_MATCH_MEMBER (1 << 1) /* Match on the interface 247 value */ 248 #define BCM_TRUNK_RESILIENT_MATCH_TRUNK_ID (1 << 2) /* Match on the Trunk-Id 249 value */ 250 #define BCM_TRUNK_RESILIENT_DELETE (1 << 3) /* Delete matched entries */ 251 #define BCM_TRUNK_RESILIENT_REPLACE (1 << 4) /* Replace matched 252 entries with 253 replace_entry */ 254 #define BCM_TRUNK_RESILIENT_COUNT (1 << 5) /* Count matched entries 255 in num_entries */ 256 257 /* Trunk profile information structure. */ 258 typedef struct bcm_trunk_psc_profile_info_s { 259 int weight_array[16]; /* Array of weights for members in trunk. */ 260 int weight_array_size; /* actual Number of members in weight array */ 261 uint32 psc_flags; /* BCM_TRUNK_PSC_xxx */ 262 int max_nof_members_in_profile; /* max number of members in a profile */ 263 } bcm_trunk_psc_profile_info_t; 264 265 /* Trunk DGM structure */ 266 typedef struct bcm_trunk_dgm_s { 267 uint32 threshold; /* Indicates the primary path is always selected when 268 primary optimal quality band is above this threshold. */ 269 uint32 cost; /* Indicates the quality band cost of switching over to 270 alternate path. */ 271 uint32 bias; /* Indicates the quality band bias in favor of alternate 272 path. */ 273 } bcm_trunk_dgm_t; 274 275 /* Trunk group attributes structure. */ 276 typedef struct bcm_trunk_info_s { 277 uint32 flags; /* BCM_TRUNK_FLAG_xxx. */ 278 int psc; /* Port selection criteria. */ 279 bcm_trunk_psc_profile_info_t psc_info; /* Port selection criteria information. */ 280 int ipmc_psc; /* Port selection criteria for software 281 IPMC trunk resolution. */ 282 int dlf_index; /* DLF/broadcast port for trunk group. */ 283 int mc_index; /* Multicast port for trunk group. */ 284 int ipmc_index; /* IPMC port for trunk group. */ 285 int dynamic_size; /* Number of flows for dynamic load 286 balancing. Valid values are 512, 1k, 287 doubling up to 32k */ 288 int dynamic_age; /* Inactivity duration, in microseconds. */ 289 int dynamic_load_exponent; /* The exponent used in the 290 exponentially weighted moving average 291 calculation of historical member 292 load. */ 293 int dynamic_expected_load_exponent; /* The exponent used in the 294 exponentially weighted moving average 295 calculation of historical expected 296 member load. */ 297 bcm_trunk_t master_tid; /* Master trunk id. */ 298 bcm_trunk_dgm_t dgm; /* DGM properties */ 299 } bcm_trunk_info_t; 300 301 /* Trunk ID infomation structure. */ 302 typedef struct bcm_trunk_id_info_s { 303 int pool_index; /* pool index of trunk_id */ 304 int group_index; /* group index of trunk_id */ 305 } bcm_trunk_id_info_t; 306 307 #define BCM_TRUNK_MAX_PP_PORTS 32 /* Maximal number of pp ports 308 accosiated with a single trunk */ 309 310 /* Trunk attributes structure. */ 311 typedef struct bcm_trunk_pp_port_allocation_info_s { 312 uint32 core_bitmap; 313 uint32 pp_port_per_core_array[BCM_TRUNK_MAX_PP_PORTS]; /* Array of pp ports per core. */ 314 } bcm_trunk_pp_port_allocation_info_t; 315 316 /* Initialize a trunk chip information structure. */ 317 typedef struct bcm_trunk_chip_info_s { 318 int trunk_group_count; /* Total number of (front panel) trunk groups. */ 319 int trunk_id_min; /* Minimum (front panel) trunk ID number. */ 320 int trunk_id_max; /* Maximum (front panel) trunk ID number. */ 321 int trunk_ports_max; /* Maximum number of ports per (front panel) 322 trunk group. */ 323 int trunk_fabric_id_min; /* Minimum fabric trunk ID number. */ 324 int trunk_fabric_id_max; /* Maximum fabric trunk ID number. */ 325 int trunk_fabric_ports_max; /* Maximum number of ports per fabric trunk 326 group. */ 327 int vp_id_min; /* Minimum virtual port trunk ID number. */ 328 int vp_id_max; /* Maximum virtual port trunk ID number. */ 329 int vp_ports_max; /* Maximum number of virtual ports per virtual 330 port trunk group. */ 331 } bcm_trunk_chip_info_t; 332 333 /* Structure describing a trunk member. */ 334 typedef struct bcm_trunk_member_s { 335 uint32 flags; /* BCM_TRUNK_MEMBER_xxx */ 336 bcm_gport_t gport; /* Trunk member GPORT ID. */ 337 int dynamic_scaling_factor; /* Dynamic load balancing threshold scaling 338 factor. */ 339 int dynamic_load_weight; /* Relative weight of historical load in 340 determining member quality. */ 341 int dynamic_queue_size_weight; /* Relative weight of queue size in 342 determining member quality. */ 343 } bcm_trunk_member_t; 344 345 /* Resilient trunk entry */ 346 typedef struct bcm_trunk_resilient_entry_s { 347 uint64 hash_key; /* Hash key. */ 348 bcm_trunk_t tid; /* Trunk. */ 349 bcm_trunk_member_t *member; /* Trunk member. */ 350 } bcm_trunk_resilient_entry_t; 351 352 /* Define the counting source (type) of trunk DLB counter engine. */ 353 typedef enum bcm_trunk_dlb_stat_e { 354 bcmTrunkDlbStatFailPackets = 0, /* Number of packets that cannot be 355 resolved through the DLB mechanism. 356 Packet forwarding will be based on 357 static trunk resolution when DLB 358 fails. */ 359 bcmTrunkDlbStatPortReassignmentCount = 1, /* Total aggregate port member 360 reassignments counter. */ 361 bcmTrunkDlbStatCount = 2 /* Always last. */ 362 } bcm_trunk_dlb_stat_t; 363 364 /* Actions to take for DLB flow monitored packets. */ 365 #define BCM_TRUNK_DLB_MON_ACTION_NONE 0 /* Do not perform any action. */ 366 #define BCM_TRUNK_DLB_MON_ACTION_TRACE 1 /* Trace DLB monitored 367 packets */ 368 369 /* Per DLB configuration of monitoring parameters. */ 370 typedef struct bcm_trunk_dlb_mon_cfg_s { 371 uint64 sample_rate; /* Rate of sampling DLB monitored packets */ 372 int action; /* Either BCM_TRUNK_DLB_MON_ACTION_NONE or 373 BCM_TRUNK_DLB_MON_TRACE. */ 374 int enable; /* Enable monitoring of DLB associated with the TRUNK 375 group. 1 = Enable monitoring for DLB associated with 376 trunk, 0 = Do not monitor DLB */ 377 } bcm_trunk_dlb_mon_cfg_t; 378 379 /* Initializes the bcm_trunk_info_t structure */ 380 extern void bcm_trunk_info_t_init( 381 bcm_trunk_info_t *trunk_info); 382 383 /* Initializes the bcm_trunk_member_t structure */ 384 extern void bcm_trunk_member_t_init( 385 bcm_trunk_member_t *trunk_member); 386 387 #ifndef BCM_HIDE_DISPATCHABLE 388 389 /* Initialize the trunk module and SoC trunk hardware. */ 390 extern int bcm_trunk_init( 391 int unit); 392 393 /* Shut down (uninitialize) the trunk module. */ 394 extern int bcm_trunk_detach( 395 int unit); 396 397 /* 398 * Create the software data structure for a new trunk, using 399 * caller-specified or next available trunk ID. 400 */ 401 extern int bcm_trunk_create( 402 int unit, 403 uint32 flags, 404 bcm_trunk_t *tid); 405 406 /* Create VPLAG trunk with user provided VPLAG Port Id. */ 407 extern int bcm_trunk_with_vplag_create( 408 int unit, 409 uint32 flags, 410 bcm_trunk_t *tid, 411 bcm_gport_t *vplag_port_id); 412 413 /* Get VPLAG port Id for vitual port trunk group. */ 414 extern int bcm_trunk_vplag_get( 415 int unit, 416 bcm_trunk_t tid, 417 bcm_gport_t *vplag_port_id); 418 419 /* Get a trunk's Port Selection Criteria (PSC). */ 420 extern int bcm_trunk_psc_get( 421 int unit, 422 bcm_trunk_t tid, 423 int *psc); 424 425 /* Set a trunk's Port Selection Criteria (PSC). */ 426 extern int bcm_trunk_psc_set( 427 int unit, 428 bcm_trunk_t tid, 429 int psc); 430 431 /* Gets the underlying SoC device's trunk support limits. */ 432 extern int bcm_trunk_chip_info_get( 433 int unit, 434 bcm_trunk_chip_info_t *ta_info); 435 436 /* 437 * Get the current attributes and member ports for the specified trunk 438 * group. 439 */ 440 extern int bcm_trunk_get( 441 int unit, 442 bcm_trunk_t tid, 443 bcm_trunk_info_t *t_data, 444 int member_max, 445 bcm_trunk_member_t *member_array, 446 int *member_count); 447 448 /* Specify the ports in a trunk group. */ 449 extern int bcm_trunk_set( 450 int unit, 451 bcm_trunk_t tid, 452 bcm_trunk_info_t *trunk_info, 453 int member_count, 454 bcm_trunk_member_t *member_array); 455 456 /* Removes a trunk group. */ 457 extern int bcm_trunk_destroy( 458 int unit, 459 bcm_trunk_t tid); 460 461 /* Expand a port bitmap to include all associated trunk member ports. */ 462 extern int bcm_trunk_bitmap_expand( 463 int unit, 464 bcm_pbmp_t *pbmp_ptr); 465 466 /* Add the specified trunk group to an existing MAC multicast entry. */ 467 extern int bcm_trunk_mcast_join( 468 int unit, 469 bcm_trunk_t tid, 470 bcm_vlan_t vid, 471 bcm_mac_t mac); 472 473 /* 474 * Retrieve the current bitmap of ports for which switching is enabled 475 * from the given trunk. 476 */ 477 extern int bcm_trunk_egress_get( 478 int unit, 479 bcm_trunk_t tid, 480 bcm_pbmp_t *pbmp); 481 482 /* Restricts switching only to specified ports from the given trunk. */ 483 extern int bcm_trunk_egress_set( 484 int unit, 485 bcm_trunk_t tid, 486 bcm_pbmp_t pbmp); 487 488 /* 489 * Retrieve the current state of trunk hashing override for unicast 490 * packets. 491 */ 492 extern int bcm_trunk_override_ucast_get( 493 int unit, 494 bcm_port_t port, 495 bcm_trunk_t tid, 496 int modid, 497 int *enable); 498 499 /* Configure the override mode of trunk hashing for unicast packets. */ 500 extern int bcm_trunk_override_ucast_set( 501 int unit, 502 bcm_port_t port, 503 bcm_trunk_t tid, 504 int modid, 505 int enable); 506 507 /* 508 * Retrieve the current state of trunk hashing override for multicast 509 * packets. 510 */ 511 extern int bcm_trunk_override_mcast_get( 512 int unit, 513 bcm_port_t port, 514 bcm_trunk_t tid, 515 int idx, 516 int *enable); 517 518 /* Configure the overriding of trunk hashing for multicast packets. */ 519 extern int bcm_trunk_override_mcast_set( 520 int unit, 521 bcm_port_t port, 522 bcm_trunk_t tid, 523 int idx, 524 int enable); 525 526 /* Retrieve the current state of trunk hashing override for IPMC packets. */ 527 extern int bcm_trunk_override_ipmc_get( 528 int unit, 529 bcm_port_t port, 530 bcm_trunk_t tid, 531 int idx, 532 int *enable); 533 534 /* Configure the overriding of trunk hashing for IPMC packets. */ 535 extern int bcm_trunk_override_ipmc_set( 536 int unit, 537 bcm_port_t port, 538 bcm_trunk_t tid, 539 int idx, 540 int enable); 541 542 /* 543 * Retrieve the current state of trunk hashing override for broadcast or 544 * unknown unicast packets. 545 */ 546 extern int bcm_trunk_override_vlan_get( 547 int unit, 548 bcm_port_t port, 549 bcm_trunk_t tid, 550 bcm_vlan_t vid, 551 int *enable); 552 553 /* 554 * Configure the overriding of trunk hashing for broadcast or unknown 555 * unicast packets. 556 */ 557 extern int bcm_trunk_override_vlan_set( 558 int unit, 559 bcm_port_t port, 560 bcm_trunk_t tid, 561 bcm_vlan_t vid, 562 int enable); 563 564 /* 565 * Retrieve the current state of trunk hashing override for non-unicast 566 * packets. 567 */ 568 extern int bcm_trunk_override_non_ucast_get( 569 int unit, 570 bcm_trunk_t tid, 571 int *enable); 572 573 /* Configure the override mode of trunk hashing for non-unicast packets. */ 574 extern int bcm_trunk_override_non_ucast_set( 575 int unit, 576 bcm_trunk_t tid, 577 int enable); 578 579 /* Retrieve the current weighted trunk hashing table. */ 580 extern int bcm_trunk_pool_get( 581 int unit, 582 bcm_port_t port, 583 bcm_trunk_t tid, 584 int *size, 585 int weights[BCM_TRUNK_MAX_PORTCNT]); 586 587 /* Configure the weighted trunk hashing table. */ 588 extern int bcm_trunk_pool_set( 589 int unit, 590 bcm_port_t port, 591 bcm_trunk_t tid, 592 int size, 593 const int weights[BCM_TRUNK_MAX_PORTCNT]); 594 595 #endif /* BCM_HIDE_DISPATCHABLE */ 596 597 /* Initialize a trunk chip information structure. */ 598 extern void bcm_trunk_chip_info_t_init( 599 bcm_trunk_chip_info_t *trunk_chip_info); 600 601 #ifndef BCM_HIDE_DISPATCHABLE 602 603 /* 604 * Get the trunk group ID for a given system port, specified by Module ID 605 * and Port number 606 */ 607 extern int bcm_trunk_find( 608 int unit, 609 bcm_module_t modid, 610 bcm_gport_t gport, 611 bcm_trunk_t *tid); 612 613 /* Assign the failover port list for a specific trunk port. */ 614 extern int bcm_trunk_failover_set( 615 int unit, 616 bcm_trunk_t tid, 617 bcm_gport_t failport, 618 int psc, 619 uint32 flags, 620 int count, 621 bcm_gport_t *fail_to_array); 622 623 /* Retrieve the failover port list for a specific trunk port. */ 624 extern int bcm_trunk_failover_get( 625 int unit, 626 bcm_trunk_t tid, 627 bcm_gport_t failport, 628 int *psc, 629 uint32 *flags, 630 int array_size, 631 bcm_gport_t *fail_to_array, 632 int *array_count); 633 634 /* Add a member to a trunk group. */ 635 extern int bcm_trunk_member_add( 636 int unit, 637 bcm_trunk_t tid, 638 bcm_trunk_member_t *member); 639 640 /* Delete a member from a trunk group. */ 641 extern int bcm_trunk_member_delete( 642 int unit, 643 bcm_trunk_t tid, 644 bcm_trunk_member_t *member); 645 646 /* Delete all members from a trunk group. */ 647 extern int bcm_trunk_member_delete_all( 648 int unit, 649 bcm_trunk_t tid); 650 651 #endif /* BCM_HIDE_DISPATCHABLE */ 652 653 /* bcm_trunk_resilient_traverse_cb */ 654 typedef int (*bcm_trunk_resilient_traverse_cb)( 655 int unit, 656 bcm_trunk_resilient_entry_t *entry, 657 void *user_data); 658 659 #ifndef BCM_HIDE_DISPATCHABLE 660 661 /* 662 * Traverse through the resilient trunk table and run callback at each 663 * valid entry. Possible replacement of the matched entries. 664 */ 665 extern int bcm_trunk_resilient_traverse( 666 int unit, 667 uint32 flags, 668 bcm_trunk_resilient_entry_t *match_entry, 669 bcm_trunk_resilient_traverse_cb trav_fn, 670 void *user_data); 671 672 /* Replace Trunk resilient entries matching given criteria. */ 673 extern int bcm_trunk_resilient_replace( 674 int unit, 675 uint32 flags, 676 bcm_trunk_resilient_entry_t *match_entry, 677 int *num_entries, 678 bcm_trunk_resilient_entry_t *replace_entry); 679 680 #endif /* BCM_HIDE_DISPATCHABLE */ 681 682 #define BCM_TRUNK_DYNAMIC_MEMBER_FORCE_DOWN 0 683 #define BCM_TRUNK_DYNAMIC_MEMBER_FORCE_UP 1 684 #define BCM_TRUNK_DYNAMIC_MEMBER_HW 2 685 #define BCM_TRUNK_DYNAMIC_MEMBER_HW_DOWN 3 686 #define BCM_TRUNK_DYNAMIC_MEMBER_HW_UP 4 687 688 #ifndef BCM_HIDE_DISPATCHABLE 689 690 /* Set trunk member dynamic load balancing (DLB) link status. */ 691 extern int bcm_trunk_member_status_set( 692 int unit, 693 bcm_gport_t member, 694 int status); 695 696 /* Get trunk member dynamic load balancing (DLB) link status. */ 697 extern int bcm_trunk_member_status_get( 698 int unit, 699 bcm_gport_t member, 700 int *status); 701 702 /* 703 * Set EtherType eligibility for dynamic load balancing or resilient 704 * hashing. 705 */ 706 extern int bcm_trunk_ethertype_set( 707 int unit, 708 uint32 flags, 709 int ethertype_count, 710 int *ethertype_array); 711 712 /* 713 * Get EtherType eligibility for dynamic load balancing or resilient 714 * hashing. 715 */ 716 extern int bcm_trunk_ethertype_get( 717 int unit, 718 uint32 *flags, 719 int ethertype_max, 720 int *ethertype_array, 721 int *ethertype_count); 722 723 /* Attach already created monitor entry to a trunk or a fabric trunk. */ 724 extern int bcm_trunk_agm_attach( 725 int unit, 726 bcm_trunk_t trunk_id, 727 bcm_switch_agm_id_t agm_id); 728 729 /* Detach a monitor entry from a trunk or a fabric trunk */ 730 extern int bcm_trunk_agm_detach( 731 int unit, 732 bcm_trunk_t trunk_id, 733 bcm_switch_agm_id_t agm_id); 734 735 /* Retrieve a monitor id attached to a (fabric) trunk. */ 736 extern int bcm_trunk_agm_attach_get( 737 int unit, 738 bcm_trunk_t trunk_id, 739 bcm_switch_agm_id_t *agm_id); 740 741 /* 742 * map a system port aggregate (SPA) to its corresponding system physical 743 * port. 744 */ 745 extern int bcm_trunk_spa_to_system_phys_port_map_get( 746 int unit, 747 uint32 flags, 748 uint32 system_port_aggregate, 749 bcm_gport_t *gport); 750 751 /* Add a GPORT ID for the specified trunk. */ 752 extern int bcm_trunk_gport_add( 753 int unit, 754 bcm_trunk_t tid, 755 bcm_gport_t gport); 756 757 /* Get all the GPORT ID for the specified trunk. */ 758 extern int bcm_trunk_gport_get_all( 759 int unit, 760 bcm_trunk_t tid, 761 int gport_size, 762 bcm_gport_t *gport_array, 763 int *count); 764 765 /* Delete the GPORT ID for the specified trunk. */ 766 extern int bcm_trunk_gport_delete( 767 int unit, 768 bcm_trunk_t tid, 769 bcm_gport_t gport); 770 771 /* Delete all the GPORT ID for the specified trunk. */ 772 extern int bcm_trunk_gport_delete_all( 773 int unit, 774 bcm_trunk_t tid); 775 776 extern int bcm_trunk_pp_port_allocation_set( 777 int unit, 778 bcm_trunk_t trunk_id, 779 uint32 flags, 780 bcm_trunk_pp_port_allocation_info_t *allocation_info); 781 782 extern int bcm_trunk_pp_port_allocation_get( 783 int unit, 784 bcm_trunk_t trunk_id, 785 uint32 flags, 786 bcm_trunk_pp_port_allocation_info_t *allocation_info); 787 788 #endif /* BCM_HIDE_DISPATCHABLE */ 789 790 /* bcm_trunk_pp_port_allocation_info_t_init */ 791 extern void bcm_trunk_pp_port_allocation_info_t_init( 792 bcm_trunk_pp_port_allocation_info_t *allocation_info); 793 794 #define BCM_TRUNK_ID_SET(trunk_id, pool, group) _SHR_TRUNK_ID_SET(trunk_id, pool, group) 795 #define BCM_TRUNK_ID_POOL_GET(pool, trunk_id) _SHR_TRUNK_ID_POOL_GET(pool, trunk_id) 796 #define BCM_TRUNK_ID_GROUP_GET(group, trunk_id) _SHR_TRUNK_ID_GROUP_GET(group, trunk_id) 797 #define BCM_TRUNK_ID_IS_VALID(trunk_id) _SHR_TRUNK_ID_IS_VALID(trunk_id) 798 799 #ifndef BCM_HIDE_DISPATCHABLE 800 801 /* Set the DLB statistics based on the trunk Id. */ 802 extern int bcm_trunk_dlb_stat_set( 803 int unit, 804 bcm_trunk_t tid, 805 bcm_trunk_dlb_stat_t type, 806 uint64 value); 807 808 /* Get the DLB statistics based on the trunk Id. */ 809 extern int bcm_trunk_dlb_stat_get( 810 int unit, 811 bcm_trunk_t tid, 812 bcm_trunk_dlb_stat_t type, 813 uint64 *value); 814 815 /* Get the DLB statistics from the trunk Id with sync mode. */ 816 extern int bcm_trunk_dlb_stat_sync_get( 817 int unit, 818 bcm_trunk_t tid, 819 bcm_trunk_dlb_stat_t type, 820 uint64 *value); 821 822 #endif /* BCM_HIDE_DISPATCHABLE */ 823 824 /* Initializes the bcm_trunk_dlb_mon_cfg_t structure */ 825 extern void bcm_trunk_dlb_mon_cfg_t_init( 826 bcm_trunk_dlb_mon_cfg_t *dlb_mon_cfg); 827 828 #ifndef BCM_HIDE_DISPATCHABLE 829 830 /* Set DLB monitoring configurations. */ 831 extern int bcm_trunk_dlb_mon_config_set( 832 int unit, 833 bcm_trunk_t tid, 834 bcm_trunk_dlb_mon_cfg_t *dlb_mon_cfg); 835 836 /* Get DLB monitoring configurations. */ 837 extern int bcm_trunk_dlb_mon_config_get( 838 int unit, 839 bcm_trunk_t tid, 840 bcm_trunk_dlb_mon_cfg_t *dlb_mon_cfg); 841 842 /* Attach stat counter ID to a given trunk ID. */ 843 extern int bcm_trunk_stat_attach( 844 int unit, 845 bcm_trunk_t tid, 846 uint32 stat_counter_id); 847 848 /* Detach stat counter ID to a given trunk ID. */ 849 extern int bcm_trunk_stat_detach( 850 int unit, 851 bcm_trunk_t tid, 852 uint32 stat_counter_id); 853 854 /* Get stat counter ID if associated with given trunk ID. */ 855 extern int bcm_trunk_stat_id_get( 856 int unit, 857 bcm_trunk_t tid, 858 uint32 *stat_counter_id); 859 860 /* Set object for a given trunk ID. */ 861 extern int bcm_trunk_flexctr_object_set( 862 int unit, 863 bcm_trunk_t tid, 864 uint16 value); 865 866 /* Get object for a given trunk ID. */ 867 extern int bcm_trunk_flexctr_object_get( 868 int unit, 869 bcm_trunk_t tid, 870 uint16 *value); 871 872 #endif /* BCM_HIDE_DISPATCHABLE */ 873 874 #endif /* __BCM_TRUNK_H__ */