policer.h (67308B)
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_POLICER_H__ 11 #define __BCM_POLICER_H__ 12 13 #include <bcm/types.h> 14 15 /* Policer Modes. */ 16 typedef enum bcm_policer_mode_e { 17 bcmPolicerModeSrTcm = 0, /* RFC 2697 */ 18 bcmPolicerModeCommitted = 1, 19 bcmPolicerModePeak = 2, 20 bcmPolicerModeTrTcm = 3, /* RFC 2698 */ 21 bcmPolicerModeTrTcmDs = 4, /* RFC 4115, TrTcmModified */ 22 bcmPolicerModeGreen = 5, 23 bcmPolicerModePassThrough = 6, 24 bcmPolicerModeSrTcmModified = 7, 25 bcmPolicerModeCoupledTrTcmDs = 8, 26 bcmPolicerModeCascade = 9, 27 bcmPolicerModeCoupledCascade = 10, 28 bcmPolicerModeSrTcmTsn = 11, /* IEEE 802.1Qci TSN Modified srTCM */ 29 bcmPolicerModeCount = 12 30 } bcm_policer_mode_t; 31 32 /* Modes for creating a group of policers */ 33 typedef enum bcm_policer_group_mode_e { 34 bcmPolicerGroupModeSingle = 0, /* A single policer used for all traffic 35 types */ 36 bcmPolicerGroupModeTrafficType = 1, /* A dedicated policer per traffic type 37 unicast, multicast, broadcast */ 38 bcmPolicerGroupModeDlfAll = 2, /* A pair of policers where the base 39 policer is used for dlf and the other 40 policer is used for all traffic types */ 41 bcmPolicerGroupModeDlfIntPri = 3, /* N+1 policers where the base policer 42 is used for dlf and next N are used 43 per Cos */ 44 bcmPolicerGroupModeTyped = 4, /* A dedicated policer for unknown 45 unicast, known unicast, multicast, 46 broadcast */ 47 bcmPolicerGroupModeTypedAll = 5, /* A dedicated policer for unknown 48 unicast, known unicast, multicast, 49 broadcast and one for all traffic 50 (not already policed) */ 51 bcmPolicerGroupModeTypedIntPri = 6, /* A dedicated policer for unknown 52 unicast, known unicast, multicast, 53 broadcast and N internal priority 54 policers for traffic (not already 55 policed) */ 56 bcmPolicerGroupModeSingleWithControl = 7, /* A single policer used for all traffic 57 types with an additional policer for 58 control traffic */ 59 bcmPolicerGroupModeTrafficTypeWithControl = 8, /* A dedicated policer per traffic type 60 unicast, multicast, broadcast with an 61 additional policer for control 62 traffic */ 63 bcmPolicerGroupModeDlfAllWithControl = 9, /* A pair of policers where the base 64 policer is used for control, the next 65 one for dlf and the other policer is 66 used for all traffic types */ 67 bcmPolicerGroupModeDlfIntPriWithControl = 10, /* N+2 policers where the base policer 68 is used for control, the next one for 69 dlf and next N are used per Cos */ 70 bcmPolicerGroupModeTypedWithControl = 11, /* A dedicated policer for control, 71 unknown unicast, known unicast, 72 multicast, broadcast */ 73 bcmPolicerGroupModeTypedAllWithControl = 12, /* A dedicated policer for control, 74 unknown unicast, known unicast, 75 multicast, broadcast and one for all 76 traffic (not already policed) */ 77 bcmPolicerGroupModeTypedIntPriWithControl = 13, /* A dedicated policer for control, 78 unknown unicast, known unicast, 79 multicast, broadcast and N internal 80 priority policers for traffic (not 81 already policed) */ 82 bcmPolicerGroupModeDot1P = 14, /* A Set of 8 policers based on outer 83 Vlan priority */ 84 bcmPolicerGroupModeIntPri = 15, /* A Set of 16 policers based on 85 internal priority */ 86 bcmPolicerGroupModeIntPriCng = 16, /* A Set of 64 policers based on 87 internal priority and cng */ 88 bcmPolicerGroupModeSvpType = 17, /* A Set of 2 policers based on SVP type */ 89 bcmPolicerGroupModeDscp = 18, /* A Set of 64 policers based on IP DSCP 90 bits */ 91 bcmPolicerGroupModeCascade = 19, /* User specified set of policers(max 92 8), wherein excess bandwidth can 93 overflow from high priority bucket to 94 low priority bucket */ 95 bcmPolicerGroupModeCascadeWithCoupling = 20, /* User specified set of policers(max 96 4), wherein excess bandwidth can 97 overflow from high priority bucket to 98 low priority bucket and from low 99 priority green bucket to high 100 priority yellow bucket */ 101 bcmPolicerGroupModeInnerDot1P = 21, /* A Set of 8 policers based on inner 102 Vlan priority */ 103 bcmPolicerGroupModeEgressSingle = 22, /* A dedicated policer for all egress 104 traffic */ 105 bcmPolicerGroupModeEgressIntPri = 23, /* A dedicated policer for egress 106 traffic for each cos level */ 107 bcmPolicerGroupModeShortIntPri = 24, /* A Set of 8 policers based on internal 108 priority */ 109 bcmPolicerGroupModeIntPriCascade = 25, /* Set of policers(max 8), wherein 110 excess bandwidth can overflow from 111 high priority bucket to low priority 112 bucket, qualified on internal 113 priority */ 114 bcmPolicerGroupModeIntPriCascadeWithCoupling = 26, /* Set of policers(max 4), wherein 115 excess bandwidth can overflow from 116 high priority bucket to low priority 117 bucket and from low priority green 118 bucket to high priority yellow */ 119 bcmPolicerGroupModePreemptable = 27, /* A set of 2 policers based on whether 120 the packet is preemptable or not */ 121 bcmPolicerGroupModeCascadeDroppedPktExclude = 28, /* Set of policers(max 8), wherein 122 excess bandwidth can overflow from 123 high priority bucket to low priority 124 bucket, with dropped packets ignored 125 for metering */ 126 bcmPolicerGroupModeCount = 29 /* Last value. Not to be used */ 127 } bcm_policer_group_mode_t; 128 129 /* Supported policer stats */ 130 typedef enum bcm_policer_stat_e { 131 bcmPolicerStatGreenToGreenPackets = 0, /* Packet count for G-To-G transitions */ 132 bcmPolicerStatGreenToGreenBytes = 1, /* Byte count for G-To-G transitions */ 133 bcmPolicerStatGreenToYellowPackets = 2, /* Packet count for G-To-Y transitions */ 134 bcmPolicerStatGreenToYellowBytes = 3, /* Byte count for G-To-Y transitions */ 135 bcmPolicerStatGreenToRedPackets = 4, /* Packet count for G-To-R transitions */ 136 bcmPolicerStatGreenToRedBytes = 5, /* Byte count for G-To-R transitions */ 137 bcmPolicerStatGreenToDropPackets = 6, /* Packet count for G-To-D transitions */ 138 bcmPolicerStatGreenToDropBytes = 7, /* Byte count for G-To-D transitions */ 139 bcmPolicerStatYellowToGreenPackets = 8, /* Packet count for Y-To-G transitions */ 140 bcmPolicerStatYellowToGreenBytes = 9, /* Byte count for Y-To-G transitions */ 141 bcmPolicerStatYellowToYellowPackets = 10, /* Packet count for Y-To-Y transitions */ 142 bcmPolicerStatYellowToYellowBytes = 11, /* Byte count for Y-To-Y transitions */ 143 bcmPolicerStatYellowToRedPackets = 12, /* Packet count for Y-To-R transitions */ 144 bcmPolicerStatYellowToRedBytes = 13, /* Byte count for Y-To-R transitions */ 145 bcmPolicerStatYellowToDropPackets = 14, /* Packet count for Y-To-D transitions */ 146 bcmPolicerStatYellowToDropBytes = 15, /* Byte count for Y-To-D transitions */ 147 bcmPolicerStatRedToGreenPackets = 16, /* Packet count for R-To-G transitions */ 148 bcmPolicerStatRedToGreenBytes = 17, /* Byte count for R-To-G transitions */ 149 bcmPolicerStatRedToYellowPackets = 18, /* Packet count for R-To-Y transitions */ 150 bcmPolicerStatRedToYellowBytes = 19, /* Byte count for R-To-Y transitions */ 151 bcmPolicerStatRedToRedPackets = 20, /* Packet count for R-To-R transitions */ 152 bcmPolicerStatRedToRedBytes = 21, /* Byte count for R-To-R transitions */ 153 bcmPolicerStatRedToDropPackets = 22, /* Packet count for R-To-D transitions */ 154 bcmPolicerStatRedToDropBytes = 23, /* Byte count for R-To-D transitions */ 155 bcmPolicerStatPackets = 24, /* Packet count for all types of traffic 156 policed */ 157 bcmPolicerStatBytes = 25, /* Byte count for all types of traffic 158 policed */ 159 bcmPolicerStatUnknownUnicastPackets = 26, /* Packet count for policed unknown 160 unicast traffic */ 161 bcmPolicerStatUnknownUnicastBytes = 27, /* Byte count for policed unknown 162 unicast traffic */ 163 bcmPolicerStatUnicastPackets = 28, /* Packet count for policed unicast 164 traffic */ 165 bcmPolicerStatUnicastBytes = 29, /* Byte count for policed unicast 166 traffic */ 167 bcmPolicerStatMulticastPackets = 30, /* Packet count for policed multicast 168 traffic */ 169 bcmPolicerStatMulticastBytes = 31, /* Byte count for policed multicast 170 traffic */ 171 bcmPolicerStatBroadcastPackets = 32, /* Packet count for policed broadcast 172 traffic */ 173 bcmPolicerStatBroadcastBytes = 33, /* Byte count for policed broadcast 174 traffic */ 175 bcmPolicerStatDropPackets = 34, /* Packet count for all types of traffic 176 dropped */ 177 bcmPolicerStatDropBytes = 35, /* Byte count for all types of traffic 178 dropped */ 179 bcmPolicerStatDropUnknownUnicastPackets = 36, /* Packet count for dropped unknown 180 unicast traffic */ 181 bcmPolicerStatDropUnknownUnicastBytes = 37, /* Byte count for dropped unknown 182 unicast traffic */ 183 bcmPolicerStatDropUnicastPackets = 38, /* Packet count for dropped unicast 184 traffic */ 185 bcmPolicerStatDropUnicastBytes = 39, /* Byte count for dropped unicast 186 traffic */ 187 bcmPolicerStatDropMulticastPackets = 40, /* Packet count for dropped multicast 188 traffic */ 189 bcmPolicerStatDropMulticastBytes = 41, /* Byte count for dropped multicast 190 traffic */ 191 bcmPolicerStatDropBroadcastPackets = 42, /* Packet count for dropped broadcast 192 traffic */ 193 bcmPolicerStatDropBroadcastBytes = 43, /* Byte count for dropped broadcast 194 traffic */ 195 bcmPolicerStatGreenPackets = 44, /* Packet count for traffic marked green */ 196 bcmPolicerStatGreenBytes = 45, /* Byte count for traffic marked green */ 197 bcmPolicerStatYellowPackets = 46, /* Packet count for traffic marked 198 yellow */ 199 bcmPolicerStatYellowBytes = 47, /* Byte count for traffic marked yellow */ 200 bcmPolicerStatRedPackets = 48, /* Packet count for traffic marked red */ 201 bcmPolicerStatRedBytes = 49, /* Byte count for traffic marked red */ 202 bcmPolicerStatGlobalInRedColorPackets = 50, /* Global - packet count incoming 203 traffic marked as red */ 204 bcmPolicerStatGlobalInRedColorBytes = 51, /* Global - byte count incoming traffic 205 marked as red */ 206 bcmPolicerStatGlobalInBlackColorPackets = 52, /* Global - packet count incoming 207 traffic marked as black */ 208 bcmPolicerStatGlobalInBlackColorBytes = 53, /* Global - byte count incoming traffic 209 marked as black */ 210 bcmPolicerStatGlobalRejectPackets = 54, /* Global - packet count rejected 211 traffic */ 212 bcmPolicerStatGlobalRejectBytes = 55, /* Global - byte count rejected traffic */ 213 bcmPolicerStatCount = 56 /* Always last */ 214 } bcm_policer_stat_t; 215 216 #define BCM_POLICER_WITH_ID 0x00000001 217 #define BCM_POLICER_REPLACE 0x00000002 218 #define BCM_POLICER_COLOR_BLIND 0x00000004 219 #define BCM_POLICER_DROP_RED 0x00000008 220 #define BCM_POLICER_COLOR_MERGE_MASK 0x00000030 221 #define BCM_POLICER_COLOR_MERGE_AND 0x00000000 222 #define BCM_POLICER_COLOR_MERGE_OR 0x00000010 223 #define BCM_POLICER_COLOR_MERGE_DUAL 0x00000020 224 #define BCM_POLICER_MODE_BYTES 0x00000040 225 #define BCM_POLICER_MODE_PACKETS 0x00000080 226 #define BCM_POLICER_MAX_CKBITS_SEC_VALID 0x00000100 227 #define BCM_POLICER_MAX_PKBITS_SEC_VALID 0x00000200 228 #define BCM_POLICER_MACRO 0x00000400 229 #define BCM_POLICER_EGRESS 0x00000800 /* Allocate policer for 230 egress usage */ 231 #define BCM_POLICER_REGEX 0x00001000 /* Allocate policer for 232 regex usage */ 233 #define BCM_POLICER_REPLACE_SHARED 0x00002000 /* Replace the profile 234 rather than the 235 configuration */ 236 #define BCM_POLICER_MIXED_MICRO_MACRO 0x00004000 /* Micro policer not 237 under the macro 238 envelope */ 239 #define BCM_POLICER_BW_SHARING_GROUP_START 0x00008000 /* Indicates that this 240 policer corresponds to 241 the start of the 242 bandwidth sharing 243 group(cascade chain) */ 244 #define BCM_POLICER_BW_SHARING_GROUP_END 0x00010000 /* Indicates that this 245 policer corresponds to 246 the end of the 247 bandwidth sharing 248 group(cascade chain) */ 249 #define BCM_POLICER_WITH_POOL_ID 0x00020000 /* Indicates that this 250 Policer needs to be 251 created with the given 252 meter pool id */ 253 #define BCM_POLICER_AS_PACKET_COUNTER 0x00040000 /* Indicates that this 254 Policer needs to be 255 created as packet 256 counter */ 257 #define BCM_POLICER_PKT_ADJ_HEADER_TRUNCATE 0x00080000 /* Indicates that this 258 Policer needs to be 259 considerate of header 260 truncate adjustment */ 261 #define BCM_POLICER_APPLY_GLOBAL_POOL_ID 0x00100000 /* Indicates that this 262 Policer needs to be 263 allocated from the 264 given global meter 265 pool id. */ 266 #define BCM_POLICER_LARGE_BUCKET_MODE 0x00200000 /* if set, force policer 267 to use large bucket 268 mode */ 269 270 #define BCM_POLICER_GLOBAL_METER_SHARING_MODE_MIN_MAX 0x00000000 271 #define BCM_POLICER_GLOBAL_METER_SHARING_MODE_MIN 0x00000001 272 #define BCM_POLICER_GLOBAL_METER_SHARING_MODE_MAX 0x00000002 273 274 #define BCM_POLICER_GLOBAL_METER_ENVELOP_MICRO_FLOW 0x1 275 #define BCM_POLICER_GLOBAL_METER_ENVELOP_MACRO_FLOW 0x2 276 277 #define BCM_POLICER_EXPANSION_GROUPS_TC 0x00000001 /* Set the mapping of TC 278 groups for expansion 279 per TC */ 280 #define BCM_POLICER_EXPANSION_GROUPS_FWD 0x00000002 /* Set the mapping of 281 L2-Fwd Type groups for 282 expansion per L2-Fwd 283 Type */ 284 285 typedef struct bcm_policer_config_s { 286 uint32 flags; /* BCM_POLICER_* Flags. */ 287 bcm_policer_mode_t mode; /* Policer mode. */ 288 uint32 ckbits_sec; /* Committed rate (kbits per sec). */ 289 uint32 cbits_sec_lower; /* Committed rate (lower digits; 0~999 290 bits per sec). */ 291 uint32 max_ckbits_sec; /* Maximum Committed rate (kbits per 292 sec), Applicable only for cascade 293 mode. */ 294 uint32 max_cbits_sec_lower; /* Maximum Committed rate (lower digits; 295 0~999 bits per sec). */ 296 uint32 ckbits_burst; /* Committed burst size (kbits). */ 297 uint32 cbits_burst_lower; /* Committed burst size (lower digits; 298 0~999 bits). */ 299 uint32 pkbits_sec; /* Peak rate (kbits per sec). */ 300 uint32 pbits_sec_lower; /* Peak rate (lower digits; 0~999 bits 301 per sec). */ 302 uint32 max_pkbits_sec; /* Maximum Peak rate (kbits per sec), 303 Applicable only for cascade mode. */ 304 uint32 max_pbits_sec_lower; /* Maximum Peak rate (lower digits; 305 0~999 bits per sec). */ 306 uint32 pkbits_burst; /* Peak burst size (kbits). */ 307 uint32 pbits_burst_lower; /* Peak burst size (lower digits; 0~999 308 bits). */ 309 uint32 kbits_current; /* Current size (kbits). */ 310 uint32 bits_current_lower; /* Current size (lower digits; 0~999 311 bits). */ 312 uint32 action_id; /* Index of the global meter action 313 entry */ 314 uint32 sharing_mode; /* Meter sharing mode in case of Macro 315 meter of Envelop */ 316 uint32 entropy_id; /* If set, indicate the configuration 317 group the policer belongs to */ 318 bcm_policer_pool_t pool_id; /* Meter Pool Id of the current policer */ 319 uint32 bucket_width; /* Bucket width in bits of the current 320 policer */ 321 uint32 token_gran; /* Token granularity of the current 322 policer */ 323 uint32 bucket_init_val; /* Initial bucket count of the current 324 policer */ 325 uint32 bucket_rollover_val; /* Rollover bucket count of the current 326 policer */ 327 bcm_core_t core_id; /* Device core on which to allocate the 328 policer */ 329 bcm_policer_t ncoflow_policer_id; /* Next lower priority committed policer 330 ID to overflow to. Applicable in 331 Cascaded policer modes on MEF 10.3+ 332 compliant devices */ 333 bcm_policer_t npoflow_policer_id; /* Next lower priority peak policer ID 334 to overflow to. Applicable in 335 Cascaded and CoupledCascade policer 336 modes on MEF 10.3+ compliant devices */ 337 uint32 actual_ckbits_sec; /* Granularity adjusted Committed rate 338 (kbits per sec). */ 339 uint32 actual_cbits_sec_lower; /* Granularity adjusted Committed rate 340 (lower digits; 0~999 bits per sec). */ 341 uint32 actual_ckbits_burst; /* Granularity adjusted Committed burst 342 size (kbits). */ 343 uint32 actual_cbits_burst_lower; /* Granularity adjusted Committed burst 344 size (lower digits; 0~999 bits). */ 345 uint32 actual_pkbits_sec; /* Granularity adjusted Peak rate (kbits 346 per sec). */ 347 uint32 actual_pbits_sec_lower; /* Granularity adjusted Peak rate (lower 348 digits; 0~999 bits per sec). */ 349 uint32 actual_pkbits_burst; /* Granularity adjusted Peak burst size 350 (kbits). */ 351 uint32 actual_pbits_burst_lower; /* Granularity adjusted Peak burst size 352 (lower digits; 0~999 bits). */ 353 uint32 average_pkt_size; /* Estimated average Ethernet packet 354 size (1 to 16383 Bytes) for more 355 accurate metering. */ 356 int mark_drop_as_black; /* For drop decision (no committed or 357 Excess credits), mark it as black 358 (otherwise, it will be marked as 359 red). */ 360 int color_resolve_profile; /* Input data for the resolved table. */ 361 } bcm_policer_config_t; 362 363 typedef struct bcm_policer_aggregate_group_info_s { 364 bcm_policer_group_mode_t mode; /* Policer mode. */ 365 bcm_core_t core; /* Device core on which to allocate the 366 policer */ 367 uint32 flags; /* BCM_POLICER_* Flags. */ 368 } bcm_policer_aggregate_group_info_t; 369 370 typedef struct bcm_policer_map_s { 371 int count; /* Number of offset mappings */ 372 uint8 *offset_map; /* policer offset for each index */ 373 } bcm_policer_map_t; 374 375 /* Initialize a policer map structure. */ 376 extern void bcm_policer_map_t_init( 377 bcm_policer_map_t *offset_map); 378 379 /* Initialize a policer configuration structure. */ 380 extern void bcm_policer_config_t_init( 381 bcm_policer_config_t *pol_cfg); 382 383 #ifndef BCM_HIDE_DISPATCHABLE 384 385 /* Initialize the policer module. */ 386 extern int bcm_policer_init( 387 int unit); 388 389 /* Create a policer entry. */ 390 extern int bcm_policer_create( 391 int unit, 392 bcm_policer_config_t *pol_cfg, 393 bcm_policer_t *policer_id); 394 395 /* Destroy a policer entry. */ 396 extern int bcm_policer_destroy( 397 int unit, 398 bcm_policer_t policer_id); 399 400 /* Destroy all policer entries. */ 401 extern int bcm_policer_destroy_all( 402 int unit); 403 404 /* Set the config settings for a policer entry. */ 405 extern int bcm_policer_set( 406 int unit, 407 bcm_policer_t policer_id, 408 bcm_policer_config_t *pol_cfg); 409 410 /* Get the config settings for a policer entry. */ 411 extern int bcm_policer_get( 412 int unit, 413 bcm_policer_t policer_id, 414 bcm_policer_config_t *pol_cfg); 415 416 /* Get the current bucket count for a policer entry. */ 417 extern int bcm_policer_packet_counter_get32( 418 int unit, 419 bcm_policer_t policer_id, 420 uint32 *count); 421 422 /* Reset the bucket count to initial value for a policer entry. */ 423 extern int bcm_policer_packet_reset_counter_get32( 424 int unit, 425 bcm_policer_t policer_id, 426 uint32 *count); 427 428 #endif /* BCM_HIDE_DISPATCHABLE */ 429 430 typedef int (*bcm_policer_traverse_cb)( 431 int unit, 432 bcm_policer_t policer_id, 433 bcm_policer_config_t *info, 434 void *user_data); 435 436 #ifndef BCM_HIDE_DISPATCHABLE 437 438 /* 439 * Traverse the existing policers and call the user-supplied callback 440 * function for each one. 441 */ 442 extern int bcm_policer_traverse( 443 int unit, 444 bcm_policer_traverse_cb cb, 445 void *user_data); 446 447 /* 448 * Allocate a block of policer entries. bcm_policer_set must be 449 * called to setup the individual policers. 450 */ 451 extern int bcm_policer_group_create( 452 int unit, 453 bcm_policer_group_mode_t mode, 454 bcm_policer_t *policer_id, 455 int *npolicers); 456 457 /* 458 * Allocate a block of policer entries. bcm_policer_set must be 459 * called to setup the individual policers. 460 */ 461 extern int bcm_policer_aggregate_group_create( 462 int unit, 463 bcm_policer_aggregate_group_info_t *info, 464 bcm_policer_t *policer_id, 465 int *npolicers); 466 467 /* 468 * Allocate a block of policer entries with flexible mapping. 469 * bcm_policer_set must be called to setup the individual policers. 470 */ 471 extern int bcm_policer_group_create_with_map( 472 int unit, 473 bcm_policer_group_mode_t mode, 474 bcm_policer_map_t *offset_map, 475 bcm_policer_t *policer_id, 476 int *num_policers); 477 478 /* Allocate a micro or a macro meter policer. */ 479 extern int bcm_policer_envelop_create( 480 int unit, 481 uint32 flag, 482 bcm_policer_t macro_flow_policer_id, 483 bcm_policer_t *policer_id); 484 485 /* 486 * Allocate a group of micro or a macro meter policer. \ref 487 * bcm_policer_set must be 488 * called to setup the individual policers. 489 */ 490 extern int bcm_policer_envelop_group_create( 491 int unit, 492 uint32 flag, 493 bcm_policer_group_mode_t mode, 494 bcm_policer_t macro_flow_policer_id, 495 bcm_policer_t *policer_id, 496 int *npolicers); 497 498 #endif /* BCM_HIDE_DISPATCHABLE */ 499 500 /* Policer group mode types */ 501 typedef enum bcm_policer_group_mode_type_e { 502 bcmPolicerGroupModeTypeNormal = 0, /* A group of n policers (max 256) which 503 do not share bandwidth amongst each 504 other */ 505 bcmPolicerGroupModeTypeCascade = 1, /* User specified set of n policers (max 506 8), wherein excess bandwidth can 507 overflow from high priority policers 508 (i.e policer with higher index) 509 bucket to low priority policers 510 bucket(policer with next higher index 511 in the group) */ 512 bcmPolicerGroupModeTypeCascadeWithCoupling = 2, /* User specified set of policers (max 513 4), wherein excess bandwidth can 514 overflow from high priority (i.e 515 policer with higher index) policers 516 bucket to low priority bucket and 517 from low priority green bucket to 518 high priority yellow bucket */ 519 bcmPolicerGroupModeTypeCount = 3 /* Always last, Not to be used */ 520 } bcm_policer_group_mode_type_t; 521 522 /* Vlan related policer attributes values */ 523 typedef enum bcm_policer_group_mode_attr_vlan_e { 524 bcmPolicerGroupModeAttrVlanUnTagged = 1, /* UnTagged Vlan */ 525 bcmPolicerGroupModeAttrVlanInnerTag = 2, /* Inner Tagged Vlan */ 526 bcmPolicerGroupModeAttrVlanOuterTag = 3, /* Outer Tagged Vlan */ 527 bcmPolicerGroupModeAttrVlanStackedTag = 4, /* Both Inner and Outer Tagged Vlan */ 528 bcmPolicerGroupModeAttrVlanAll = 5 /* UnTagged,Inner and Outer Tagged Vlan */ 529 } bcm_policer_group_mode_attr_vlan_t; 530 531 /* Packet type related policer attributes values */ 532 typedef enum bcm_policer_group_mode_attr_pkt_type_e { 533 bcmPolicerGroupModeAttrPktTypeAll = 1, /* All Packet Types */ 534 bcmPolicerGroupModeAttrPktTypeUnknown = 2, /* Unknown Packet */ 535 bcmPolicerGroupModeAttrPktTypeControl = 3, /* Control Packet */ 536 bcmPolicerGroupModeAttrPktTypeOAM = 4, /* OAM Packet */ 537 bcmPolicerGroupModeAttrPktTypeBFD = 5, /* BFD Packet */ 538 bcmPolicerGroupModeAttrPktTypeBPDU = 6, /* BPDU Packet */ 539 bcmPolicerGroupModeAttrPktTypeICNM = 7, /* ICNM Packet */ 540 bcmPolicerGroupModeAttrPktType1588 = 8, /* 1588 Packet */ 541 bcmPolicerGroupModeAttrPktTypeKnownL2UC = 9, /* Known L2 Unicast Packet */ 542 bcmPolicerGroupModeAttrPktTypeUnknownL2UC = 10, /* Unknown L2 Unicast Packet */ 543 bcmPolicerGroupModeAttrPktTypeL2BC = 11, /* L2 Broadcast Packet */ 544 bcmPolicerGroupModeAttrPktTypeKnownL2MC = 12, /* Known L2 Multicast Packet */ 545 bcmPolicerGroupModeAttrPktTypeUnknownL2MC = 13, /* Unknown L2 Multicast Packet */ 546 bcmPolicerGroupModeAttrPktTypeKnownL3UC = 14, /* Known L3 Unicast Packet */ 547 bcmPolicerGroupModeAttrPktTypeUnknownL3UC = 15, /* Unknown L3 Unicast Packet */ 548 bcmPolicerGroupModeAttrPktTypeKnownIPMC = 16, /* Known IPMC Packet */ 549 bcmPolicerGroupModeAttrPktTypeUnknownIPMC = 17, /* Unknown IPMC Packet */ 550 bcmPolicerGroupModeAttrPktTypeKnownMplsL2 = 18, /* Known MPLS L2 Packet */ 551 bcmPolicerGroupModeAttrPktTypeKnownMplsL3 = 19, /* Known MPLS L3 Packet */ 552 bcmPolicerGroupModeAttrPktTypeKnownMpls = 20, /* Known MPLS Packet */ 553 bcmPolicerGroupModeAttrPktTypeUnknownMpls = 21, /* Unknown MPLS Packet */ 554 bcmPolicerGroupModeAttrPktTypeKnownMplsMulticast = 22, /* Known MPLS Multicast Packet */ 555 bcmPolicerGroupModeAttrPktTypeKnownMim = 23, /* Known MiM Packet */ 556 bcmPolicerGroupModeAttrPktTypeUnknownMim = 24, /* Unknown MiM Packet */ 557 bcmPolicerGroupModeAttrPktTypeKnownTrill = 25, /* Known TRILL Packet */ 558 bcmPolicerGroupModeAttrPktTypeUnknownTrill = 26, /* Unknown TRILL Packet */ 559 bcmPolicerGroupModeAttrPktTypeKnownNiv = 27, /* Known NIV Packet */ 560 bcmPolicerGroupModeAttrPktTypeUnknownNiv = 28 /* Unknown NIV Packet */ 561 } bcm_policer_group_mode_attr_pkt_type_t; 562 563 /* Policer Group Mode Attribute Selectors */ 564 typedef enum bcm_policer_group_mode_attr_e { 565 bcmPolicerGroupModeAttrUdf = 1, /* UDF selector: Possible values:0 to 566 2^N-1. Value of N may vary depending 567 on device. */ 568 bcmPolicerGroupModeAttrFieldIngressColor = 2, /* Field Ingress Color Selector: 569 Possible 570 Values:bcmColorGreen|Yellow|REd or 571 POLICER_GROUP_MODE_ATTR_ALL_VALUES 572 for all */ 573 bcmPolicerGroupModeAttrIntPri = 3, /* Internal Priority Selector: Possible 574 Values: 0 to 15 or 575 POLICER_GROUP_MODE_ATTR_ALL_VALUES 576 for all */ 577 bcmPolicerGroupModeAttrVlan = 4, /* Vlan Type Selector: Possible Values: 578 bcmPolicerGroupModeVlanAttr */ 579 bcmPolicerGroupModeAttrOuterPri = 5, /* Outer Vlan Priority Selector: 580 Possible Values: 0 to 7 or 581 POLICER_GROUP_MODE_ATTR_ALL_VALUES 582 for all */ 583 bcmPolicerGroupModeAttrInnerPri = 6, /* Inner Vlan Priority Selector: 584 Possible Values: 0 to 7 or 585 POLICER_GROUP_MODE_ATTR_ALL_VALUES 586 for all */ 587 bcmPolicerGroupModeAttrPort = 7, /* Logical Port Selector: Possible 588 Values:<MaxLogicalPort> or 589 POLICER_GROUP_MODE_ATTR_ALL_VALUES 590 for all */ 591 bcmPolicerGroupModeAttrTosDscp = 8, /* Type Of Service Selector(DSCP : 592 Differentiated services Code Point): 593 Possible Values:<6b:TOS Val> or 594 POLICER_GROUP_MODE_ATTR_ALL_VALUES 595 for all */ 596 bcmPolicerGroupModeAttrTosEcn = 9, /* Type Of Service Selector(ECN: 597 Explicit Congestion Notification): 598 Possible Values:<2b:TOS Val> or 599 POLICER_GROUP_MODE_ATTR_ALL_VALUES 600 for all */ 601 bcmPolicerGroupModeAttrPktType = 10, /* Packet Type Selector: Possible 602 Values:<bcmPolicerGroupModeAttrPktType*> */ 603 bcmPolicerGroupModeAttrIngNetworkGroup = 11, /* Ingress Network Group Selector: 604 Possible Values:<Value> or 605 POLICER_GROUP_MODE_ATTR_ALL_VALUES 606 for all */ 607 bcmPolicerGroupModeAttrDrop = 12, /* Drop Selector: Possible Values:<0 or 608 1> */ 609 bcmPolicerGroupModeAttrPacketTypeIp = 13, /* Ip Packet Selector: Possible 610 Values:<0 or 1> */ 611 bcmPolicerGroupModeAttrPreemptable = 14, /* Preemptable Packet Selector: Possible 612 Values:<0 or 1> */ 613 bcmPolicerGroupModeAttrEtherType = 15, /* Ether Type: Possible 614 values:0x0-0xFFFF */ 615 bcmPolicerGroupModeAttrOuterVlanCfi = 16, /* Outer VLAN CFI: Possible Values:<0 or 616 1> */ 617 bcmPolicerGroupModeAttrInnerVlanCfi = 17, /* Inner VLAN CFI: Possible Values:<0 or 618 1> */ 619 bcmPolicerGroupModeAttrLast = 18, /* Last value. Not to be used */ 620 bcmPolicerGroupModeAttrCount = bcmPolicerGroupModeAttrLast /* Last value. Not to be used */ 621 } bcm_policer_group_mode_attr_t; 622 623 /* Unique constants */ 624 #define BCM_POLICER_GROUP_MODE_ATTR_ALL_VALUES 0xFFFFFFFF /* A unique constant for 625 using all attr values */ 626 627 /* packet attribute selector flags values */ 628 #define BCM_POLICER_ATTR_WIDTH_OFFSET 0x1 /* Offset and width fields 629 are valid for this 630 attribute */ 631 632 /* packet attribute selector flags values */ 633 #define BCM_POLICER_ATTR_VALUE_MASK 0x2 /* Mask is valid for this 634 attribute. Flags WIDTH_OFFSET 635 and MASK are mutually 636 exclusive */ 637 638 /* packet attribute selector flags values */ 639 #define BCM_POLICER_ATTR_MULTI 0x4 /* Matching multiple attributes in 640 single selector. The 641 policer_offset is chosen only if 642 all attributes match */ 643 644 /* Policer Group Attribute Selector */ 645 typedef struct bcm_policer_group_mode_attr_selector_s { 646 uint32 flags; /* packet attribute selector flags */ 647 uint32 policer_offset; /* Policer Offset */ 648 bcm_policer_group_mode_attr_t attr; /* Attribute Selector */ 649 uint32 attr_value; /* Attribute Values */ 650 uint32 attr_value_mask; /* Attribute Mask */ 651 int udf_id; /* UDF ID created using bcm_udf_create. 652 Applicable only if Group mode 653 attribute is 654 bcmPolicerGroupModeAttrUdf. */ 655 uint32 offset; /* Offset in bits from the beginning of 656 the packet attribute */ 657 uint32 width; /* Number of bits in packet attribute 658 from offset to be used for policer 659 offset mapping */ 660 uint32 multi_attr_count; /* Number of multiple elements specified 661 in all of the multi_attr_xxx[] array. */ 662 uint32 multi_attr_flags[bcmPolicerGroupModeAttrCount]; /* Attribute flags */ 663 bcm_policer_group_mode_attr_t multi_attr[bcmPolicerGroupModeAttrCount]; /* Attribute Selector */ 664 uint32 multi_attr_value[bcmPolicerGroupModeAttrCount]; /* Attribute Values */ 665 uint32 multi_attr_value_mask[bcmPolicerGroupModeAttrCount]; /* Attribute Mask */ 666 int multi_udf_id[bcmPolicerGroupModeAttrCount]; /* UDF ID created using bcm_udf_create. 667 Applicable only if attribute is 668 bcmPolicerGroupModeAttrUdf. */ 669 uint32 multi_offset[bcmPolicerGroupModeAttrCount]; /* Offset in bits from the beginning of 670 the packet attribute */ 671 uint32 multi_width[bcmPolicerGroupModeAttrCount]; /* Number of bits in packet attribute 672 from offset to be used */ 673 } bcm_policer_group_mode_attr_selector_t; 674 675 /* Initialize a policer group attribute selector structure. */ 676 extern void bcm_policer_group_mode_attr_selector_t_init( 677 bcm_policer_group_mode_attr_selector_t *pol_group_mode_attr_selector); 678 679 #ifndef BCM_HIDE_DISPATCHABLE 680 681 /* Create Customized Policer Group mode for given Policer Attributes */ 682 extern int bcm_policer_group_mode_id_create( 683 int unit, 684 uint32 flags, 685 bcm_policer_group_mode_type_t type, 686 uint32 total_policers, 687 uint32 num_selectors, 688 bcm_policer_group_mode_attr_selector_t *attr_selectors, 689 uint32 *mode_id); 690 691 /* Destroys Customized Group mode */ 692 extern int bcm_policer_group_mode_id_destroy( 693 int unit, 694 uint32 mode_id); 695 696 /* Retrieves Customized Policer Group mode Attributes for given mode_id */ 697 extern int bcm_policer_group_mode_id_get( 698 int unit, 699 uint32 mode_id, 700 uint32 num_selectors, 701 uint32 *flags, 702 bcm_policer_group_mode_type_t *type, 703 uint32 *total_policers, 704 bcm_policer_group_mode_attr_selector_t *attr_selectors, 705 uint32 *actual_num_selectors); 706 707 /* Create a group of policers belonging to group mode specified */ 708 extern int bcm_policer_custom_group_create( 709 int unit, 710 uint32 flags, 711 uint32 mode_id, 712 bcm_policer_t macro_flow_policer_id, 713 bcm_policer_t *policer_id, 714 uint32 *npolicers); 715 716 /* 717 * Get the list of policer members for a given policer group represented 718 * by its base policer id. 719 */ 720 extern int bcm_policer_group_get( 721 int unit, 722 bcm_policer_t base_policer_id, 723 int member_max, 724 bcm_policer_t *member_array, 725 int *member_count); 726 727 /* 728 * Checks if statistics collection is enabled on the specified policer 729 * ID. 730 */ 731 extern int bcm_policer_stat_enable_get( 732 int unit, 733 bcm_policer_t policer_id, 734 int *enable); 735 736 /* Enables statistics collection on the specified policer ID. */ 737 extern int bcm_policer_stat_enable_set( 738 int unit, 739 bcm_policer_t policer_id, 740 int enable); 741 742 /* Gets the specified stat. */ 743 extern int bcm_policer_stat_get( 744 int unit, 745 bcm_policer_t policer_id, 746 bcm_cos_t int_pri, 747 bcm_policer_stat_t stat, 748 uint64 *value); 749 750 /* 32-bit version of stat get API */ 751 extern int bcm_policer_stat_get32( 752 int unit, 753 bcm_policer_t policer_id, 754 bcm_cos_t int_pri, 755 bcm_policer_stat_t stat, 756 uint32 *value); 757 758 /* Sets the specified stat. */ 759 extern int bcm_policer_stat_set( 760 int unit, 761 bcm_policer_t policer_id, 762 bcm_cos_t int_pri, 763 bcm_policer_stat_t stat, 764 uint64 value); 765 766 /* 32-bit version of stat set API */ 767 extern int bcm_policer_stat_set32( 768 int unit, 769 bcm_policer_t policer_id, 770 bcm_cos_t int_pri, 771 bcm_policer_stat_t stat, 772 uint32 value); 773 774 /* Associate action with the policer. */ 775 extern int bcm_policer_action_attach( 776 int unit, 777 bcm_policer_t policer_id, 778 uint32 action_id); 779 780 /* Disassociate action from the policer. */ 781 extern int bcm_policer_action_detach( 782 int unit, 783 bcm_policer_t policer_id, 784 uint32 action_id); 785 786 /* Get the action ID associated with the policer ID. */ 787 extern int bcm_policer_action_attach_get( 788 int unit, 789 bcm_policer_t policer_id, 790 uint32 *action_id); 791 792 #endif /* BCM_HIDE_DISPATCHABLE */ 793 794 /* Global meter policer actions */ 795 typedef enum bcm_policer_action_e { 796 bcmPolicerActionGpDrop = 0, /* Green priority drop */ 797 bcmPolicerActionGpDscpNew = 1, /* Green packet change DSCP value 798 param0: New DSCP value */ 799 bcmPolicerActionGpEcnNew = 2, /* Green packet change ECN value param0: 800 New ECN value */ 801 bcmPolicerActionGpPrioIntNew = 3, /* Green packet internal priority from 802 an argument. param0: New priority */ 803 bcmPolicerActionGpCngNew = 4, /* Green packet change CNG */ 804 bcmPolicerActionGpVlanPrioNew = 5, /* Green packet change vlan priority. 805 param0: New priority */ 806 bcmPolicerActionYpDrop = 6, /* Yellow priority drop */ 807 bcmPolicerActionYpDscpNew = 7, /* Yellow packet change DSCP value 808 param0: New DSCP value */ 809 bcmPolicerActionYpEcnNew = 8, /* Yellow packet change ECN value 810 param0: New ECN value */ 811 bcmPolicerActionYpPrioIntNew = 9, /* Yellow packet internal priority from 812 an argument. param0: New priority */ 813 bcmPolicerActionYpCngNew = 10, /* Yellow packet change CNG */ 814 bcmPolicerActionYpVlanPrioNew = 11, /* Yellow packet change vlan priority. 815 param0: New priority */ 816 bcmPolicerActionRpDrop = 12, /* Red priority drop */ 817 bcmPolicerActionRpDscpNew = 13, /* Red packet change DSCP value param0: 818 New DSCP value */ 819 bcmPolicerActionRpEcnNew = 14, /* Red packet change ECN value param0: 820 New ECN value */ 821 bcmPolicerActionRpPrioIntNew = 15, /* Red packet internal priority from an 822 argument. param0: New priority */ 823 bcmPolicerActionRpCngNew = 16, /* Red packet change CNG */ 824 bcmPolicerActionRpVlanPrioNew = 17, /* Red packet change vlan priority. 825 param0: New priority */ 826 bcmPolicerActionGpIntCongestionNotificationNew = 18, /* Replace the internal congestion 827 notification value of green packet. 828 param0: Internal congestion 829 notification value. */ 830 bcmPolicerActionYpIntCongestionNotificationNew = 19, /* Replace the internal congestion 831 notification value of yellow packet. 832 param0: Internal congestion 833 notification value. */ 834 bcmPolicerActionRpIntCongestionNotificationNew = 20, /* Replace the internal congestion 835 notification value of red packet. 836 param0: Internal congestion 837 notification value. */ 838 bcmPolicerActionCount = 21 /* Last value. Not to be used */ 839 } bcm_policer_action_t; 840 841 #ifndef BCM_HIDE_DISPATCHABLE 842 843 /* Create a new policer action */ 844 extern int bcm_policer_action_create( 845 int unit, 846 uint32 *action_id); 847 848 /* Destroy a policer action */ 849 extern int bcm_policer_action_destroy( 850 int unit, 851 uint32 action_id); 852 853 /* Configure the action for an Action ID . */ 854 extern int bcm_policer_action_add( 855 int unit, 856 uint32 action_id, 857 bcm_policer_action_t action, 858 uint32 param0); 859 860 /* Get the param value for an action in policer action table. */ 861 extern int bcm_policer_action_get( 862 int unit, 863 uint32 action_id, 864 bcm_policer_action_t action, 865 uint32 *param0); 866 867 #endif /* BCM_HIDE_DISPATCHABLE */ 868 869 /* Policer internal color */ 870 typedef enum bcm_policer_color_e { 871 bcmPolicerColorGreen = 0, /* Green color */ 872 bcmPolicerColorInvalid = 1, /* Invalid color */ 873 bcmPolicerColorYellow = 2, /* Yellow color */ 874 bcmPolicerColorRed = 3 /* Red color */ 875 } bcm_policer_color_t; 876 877 /* Policer color decision entry */ 878 typedef struct bcm_policer_color_decision_s { 879 uint32 flags; /* color decision flags */ 880 bcm_policer_color_t policer0_color; /* policer-0 color decision */ 881 uint8 policer0_other_bucket_has_credits; /* if policer0_color is yellow, indicate 882 if green bucket has credits, 883 otherwise if yellow bucket has 884 credits */ 885 bcm_policer_color_t policer1_color; /* policer-1 color decision */ 886 uint8 policer1_other_bucket_has_credits; /* if policer1_color is yellow, indicate 887 if green bucket has credits, 888 otherwise if yellow bucket has 889 credits */ 890 int policer0_mark_drop_as_black; /* if policer0 decision is drop, 891 indicate if it is marked black or 892 red. */ 893 int policer1_mark_drop_as_black; /* if policer1 decision is drop, 894 indicate if it is marked black or 895 red. */ 896 bcm_policer_color_t policer0_update_bucket; /* the policer-0 bucket to update */ 897 bcm_policer_color_t policer1_update_bucket; /* the policer-1 bucket to update */ 898 bcm_color_t policer_color; /* policer color decision */ 899 } bcm_policer_color_decision_t; 900 901 /* Policer color resolution entry */ 902 typedef struct bcm_policer_color_resolution_s { 903 uint32 flags; /* color resolution flags */ 904 uint32 policer_action; /* policer command */ 905 bcm_color_t incoming_color; /* incoming color */ 906 bcm_color_t ethernet_policer_color; /* Ethernet policer color */ 907 bcm_color_t policer_color; /* policer color */ 908 bcm_color_t ingress_color; /* ingress color */ 909 bcm_color_t egress_color; /* egress color */ 910 } bcm_policer_color_resolution_t; 911 912 #ifndef BCM_HIDE_DISPATCHABLE 913 914 /* Set an entry in the Policer Color Decision table */ 915 extern int bcm_policer_color_decision_set( 916 int unit, 917 bcm_policer_color_decision_t *policer_color_decision); 918 919 /* Get an entry from the Policer Color Decision table */ 920 extern int bcm_policer_color_decision_get( 921 int unit, 922 bcm_policer_color_decision_t *policer_color_decision); 923 924 /* Set an entry in the Policer Color Resolution table */ 925 extern int bcm_policer_color_resolution_set( 926 int unit, 927 bcm_policer_color_resolution_t *policer_color_resolution); 928 929 /* Get an entry from the Policer Color Resolution table */ 930 extern int bcm_policer_color_resolution_get( 931 int unit, 932 bcm_policer_color_resolution_t *policer_color_resolution); 933 934 #endif /* BCM_HIDE_DISPATCHABLE */ 935 936 /* Sources of global metering. */ 937 typedef enum bcm_policer_global_meter_source_e { 938 bcmPolicerGlobalMeterSourceFieldStageLookup = 0, /* VFP - Field Stage Lookup */ 939 bcmPolicerGlobalMeterSourceDstMac = 1, /* Destination MAC Address Lookup */ 940 bcmPolicerGlobalMeterSourceSrcMac = 2, /* Source MAC Address Lookup */ 941 bcmPolicerGlobalMeterSourceVlanTranslateFirst = 3, /* VLAN Translation First Lookup */ 942 bcmPolicerGlobalMeterSourceVlanTranslateSecond = 4, /* VLAN Translation Second Lookup */ 943 bcmPolicerGlobalMeterSourceVlan = 5, /* Outer VLAN ID Matched */ 944 bcmPolicerGlobalMeterSourcePort = 6, /* Ingress Port Matched */ 945 bcmPolicerGlobalMeterSourceCount = 7 /* Always last */ 946 } bcm_policer_global_meter_source_t; 947 948 /* bcm policer global meter configuration structure */ 949 typedef struct bcm_policer_global_meter_config_s { 950 uint8 ifg_enable; /* Enable Inter Frame Gap(IFG) for 951 incoming packet length in global 952 metering. The IFG value is configured 953 by switch API 954 bcmSwitchMeterAdjustInterframeGap 955 (per port). 0 = Disable, 1 = Enable. */ 956 bcm_policer_global_meter_source_t source_order[bcmPolicerGlobalMeterSourceCount]; /* Specify global metering sources in 957 the order or precedence. Source at 958 array index 0 has highest precedence. */ 959 uint32 source_order_count; /* Valid index count in source_order 960 array. */ 961 } bcm_policer_global_meter_config_t; 962 963 /* Initialize a policer global meter configuration structure */ 964 extern void bcm_policer_global_meter_config_t_init( 965 bcm_policer_global_meter_config_t *config); 966 967 #ifndef BCM_HIDE_DISPATCHABLE 968 969 /* Set policer global meter configuration. */ 970 extern int bcm_policer_global_meter_config_set( 971 int unit, 972 bcm_policer_global_meter_config_t *config); 973 974 /* Get policer global meter configuration. */ 975 extern int bcm_policer_global_meter_config_get( 976 int unit, 977 bcm_policer_global_meter_config_t *config); 978 979 #endif /* BCM_HIDE_DISPATCHABLE */ 980 981 /* Enum to select the scope of the policer. */ 982 typedef enum bcm_policer_scope_e { 983 bcmPolicerScopeIngressGlobal = 0, 984 bcmPolicerScopeIngress = 1, 985 bcmPolicerScopeEgress = 2 986 } bcm_policer_scope_t; 987 988 /* Forwarding types enum. */ 989 typedef enum bcm_policer_fwd_types_e { 990 bcmPolicerFwdTypeUc = 0, 991 bcmPolicerFwdTypeUnkownUc = 1, 992 bcmPolicerFwdTypeMc = 2, 993 bcmPolicerFwdTypeUnkownMc = 3, 994 bcmPolicerFwdTypeBc = 4, 995 bcmPolicerFwdTypeMax = 5 996 } bcm_policer_fwd_types_t; 997 998 /* 999 * Structure hold the for each forwarding type the offset in the 1000 * expansion group and if to do meter on it or not. 1001 */ 1002 typedef struct bcm_policer_expansion_group_types_config_s { 1003 int offset; /* Offset in expansion group */ 1004 int valid; /* If not valid, packet with this type will be filtered. */ 1005 } bcm_policer_expansion_group_types_config_t; 1006 1007 /* 1008 * Structure holds the policer expansion groups, according the forwarding 1009 * types. 1010 */ 1011 typedef struct bcm_policer_expansion_group_s { 1012 bcm_policer_expansion_group_types_config_t config[bcmPolicerFwdTypeMax]; 1013 int tc_offset[BCM_COS_COUNT]; /* Per TC offset for expansion groups */ 1014 } bcm_policer_expansion_group_t; 1015 1016 #ifndef BCM_HIDE_DISPATCHABLE 1017 1018 /* 1019 * API Defines groups of L2 Fwd-Types and decide if to count them and in 1020 * which offset in the expansion to count them. 1021 */ 1022 extern int bcm_policer_expansion_groups_set( 1023 int unit, 1024 int flags, 1025 bcm_core_t core_id, 1026 bcm_policer_expansion_group_t *expansion_group); 1027 1028 /* API gets the expansion groups of L2 Fwd-Types. */ 1029 extern int bcm_policer_expansion_groups_get( 1030 int unit, 1031 int flags, 1032 bcm_core_t core_id, 1033 bcm_policer_expansion_group_t *expansion_group); 1034 1035 #endif /* BCM_HIDE_DISPATCHABLE */ 1036 1037 /* Structure holds configuration per policer database. */ 1038 typedef struct bcm_policer_database_config_s { 1039 int expansion_enable; /* Allowed to ingress database 0. if enabled, 1040 expansion size, filter and offsets will be made 1041 according API bcm_policer_expansion_groups_set. */ 1042 int is_single_bucket; /* Single or dual bucket mode. */ 1043 int expand_per_tc; /* If set and expansion is enabled, expansion will 1044 be made per TC, else it will be made per L2-Fwd 1045 Type */ 1046 } bcm_policer_database_config_t; 1047 1048 #ifndef BCM_HIDE_DISPATCHABLE 1049 1050 /* 1051 * API create a policer database (sw create). database represent the 1052 * meter processor belong to one of the meter commands.It gets as input 1053 * database handler which gather the key parameters: core, scope, 1054 * database_id 1055 */ 1056 extern int bcm_policer_database_create( 1057 int unit, 1058 int flags, 1059 int policer_database_handle, 1060 bcm_policer_database_config_t *config); 1061 1062 /* API destroy a policer database */ 1063 extern int bcm_policer_database_destroy( 1064 int unit, 1065 int flags, 1066 int policer_database_handle); 1067 1068 #endif /* BCM_HIDE_DISPATCHABLE */ 1069 1070 /* Enum holds the policer control types. */ 1071 typedef enum bcm_policer_control_type_e { 1072 bcmPolicerControlTypeFilterByDpCommand = 0, /* Filter meter pointers according the 1073 dp command. It is a bitmap. */ 1074 bcmPolicerControlTypeDpResolutionByDpCommand = 1, /* select the input for the resolve 1075 table: policer-profile or dp-command. 1076 This type is per ingress/egress only 1077 and not per database. */ 1078 bcmPolicerControlTypeCountBytes = 2, /* Select if to count bytes or packets 1079 in the internal policer stats. 1080 (default=packets). */ 1081 bcmPolicerFairness = 3, /* enable/disable fairness between 1082 multiple flows using the same meter, 1083 by jittering the bucket level. */ 1084 bcmPolicerControlTypeTCSMEnable = 4, /* Enable TC Sensitive metering */ 1085 bcmPolicerControlTypeTCSMUsePPTC = 5 /* Enable using PP TC for determining 1086 the TCSM threshold. If it is not set, 1087 the offset of the expansion group 1088 will be used */ 1089 } bcm_policer_control_type_t; 1090 1091 #ifndef BCM_HIDE_DISPATCHABLE 1092 1093 /* 1094 * API which contain several policer control types that can be 1095 * configured. 1096 */ 1097 extern int bcm_policer_control_set( 1098 int unit, 1099 int flags, 1100 int policer_database_handle, 1101 bcm_policer_control_type_t type, 1102 uint32 arg); 1103 1104 /* API get the value of one of the control types. */ 1105 extern int bcm_policer_control_get( 1106 int unit, 1107 int flags, 1108 int policer_database_handle, 1109 bcm_policer_control_type_t type, 1110 uint32 *arg); 1111 1112 #endif /* BCM_HIDE_DISPATCHABLE */ 1113 1114 /* Enum to select the section in the policer-crps shared memory engines. */ 1115 typedef enum bcm_policer_engine_section_e { 1116 bcmPolicerEngineSectionAll = 0, 1117 bcmPolicerEngineSectionLow = 1, 1118 bcmPolicerEngineSectionHigh = 2 1119 } bcm_policer_engine_section_t; 1120 1121 /* Structure holds the policer memory engine key configuration. */ 1122 typedef struct bcm_policer_engine_s { 1123 int core_id; 1124 int engine_id; /* Same units as the crps engines. valid 1125 engines are the ones that are shared 1126 with crps: 0,1,16,17,18,19,20,21. */ 1127 bcm_policer_engine_section_t section; /* When using dual bucket moode, must 1128 use 'All'. */ 1129 } bcm_policer_engine_t; 1130 1131 /* 1132 * Structure define the database that the engine will attached to and its 1133 * base stat pointer. 1134 */ 1135 typedef struct bcm_policer_database_attach_config_s { 1136 int policer_database_handle; /* Database handle defines the database that 1137 engine belong to. */ 1138 int object_stat_pointer_base; /* Resolution after expansion. */ 1139 } bcm_policer_database_attach_config_t; 1140 1141 #ifndef BCM_HIDE_DISPATCHABLE 1142 1143 /* API attach one engine (or half engine) to a policer database. */ 1144 extern int bcm_policer_engine_database_attach( 1145 int unit, 1146 int flags, 1147 bcm_policer_engine_t *engine, 1148 bcm_policer_database_attach_config_t *config); 1149 1150 /* API gets per engine (or half engine), the database it attached to. */ 1151 extern int bcm_policer_engine_database_get( 1152 int unit, 1153 int flags, 1154 bcm_policer_engine_t *engine, 1155 bcm_policer_database_attach_config_t *config); 1156 1157 /* 1158 * API detach one engine (or half engine) from a policer database. From 1159 * this point, it can be used to crps or other policer database. 1160 */ 1161 extern int bcm_policer_engine_database_detach( 1162 int unit, 1163 int flags, 1164 bcm_policer_engine_t *engine); 1165 1166 /* API enable/disable policer database. */ 1167 extern int bcm_policer_database_enable_set( 1168 int unit, 1169 int flags, 1170 int policer_database_handle, 1171 int enable); 1172 1173 /* API gets if policer database is enabled or disabled. */ 1174 extern int bcm_policer_database_enable_get( 1175 int unit, 1176 int flags, 1177 int policer_database_handle, 1178 int *enable); 1179 1180 #endif /* BCM_HIDE_DISPATCHABLE */ 1181 1182 #define BCM_COLOR_RESOLUTION_EGRESS 0x1 /* Refer to egress meter final 1183 resolve table. (default is 1184 ingress) */ 1185 1186 /* Structure holds the data of each single meter. */ 1187 typedef struct bcm_policer_color_data_s { 1188 bcm_policer_color_t policer_color; /* Meter color decision. */ 1189 int policer_other_bucket_has_credits; /* If policer0_color is yellow, indicate 1190 if green bucket has credits,otherwise 1191 if yellow bucket has credits. */ 1192 } bcm_policer_color_data_t; 1193 1194 /* Structure holds the entire key for the color resolution table. */ 1195 typedef struct bcm_policer_primary_color_resolution_key_s { 1196 bcm_core_t core_id; 1197 int is_ingress; 1198 int action; /* Holds the DP-CMD data or the meter 1199 profile data (depend on 1200 configuration). */ 1201 bcm_policer_color_data_t color_data[3]; /* Color data per meter. For egress, 1202 only 2 are relevant. */ 1203 } bcm_policer_primary_color_resolution_key_t; 1204 1205 /* Holds all the outputs of the resolve table. */ 1206 typedef struct bcm_policer_primary_color_resolution_config_s { 1207 int policer_count[3]; /* Is to count the policer. */ 1208 bcm_color_t policer_color[3]; /* The color which will be marked for 1209 the counter (if counted). */ 1210 bcm_policer_color_t policer_update_bucket[3]; /* The policer bucket to update. */ 1211 bcm_color_t resolved_color; /* The resolved color (or color 1212 decision). */ 1213 } bcm_policer_primary_color_resolution_config_t; 1214 1215 #ifndef BCM_HIDE_DISPATCHABLE 1216 1217 /* 1218 * API configure one entry of the color resolved table (the first/primary 1219 * table). 1220 */ 1221 extern int bcm_policer_primary_color_resolution_set( 1222 int unit, 1223 int flags, 1224 bcm_policer_primary_color_resolution_key_t *key, 1225 bcm_policer_primary_color_resolution_config_t *config); 1226 1227 /* 1228 * API get one entry of the color resolved table (the first/primary 1229 * table). 1230 */ 1231 extern int bcm_policer_primary_color_resolution_get( 1232 int unit, 1233 int flags, 1234 bcm_policer_primary_color_resolution_key_t *key, 1235 bcm_policer_primary_color_resolution_config_t *config); 1236 1237 #endif /* BCM_HIDE_DISPATCHABLE */ 1238 1239 /* init bcm_policer_primary_color_resolution_key_t */ 1240 extern void bcm_policer_primary_color_resolution_key_t_init( 1241 bcm_policer_primary_color_resolution_key_t *policer_primary_color_resolution_key); 1242 1243 /* init bcm_policer_primary_color_resolution_config_t */ 1244 extern void bcm_policer_primary_color_resolution_config_t_init( 1245 bcm_policer_primary_color_resolution_config_t *policer_primary_color_resolution_config); 1246 1247 /* init bcm_policer_engine_t */ 1248 extern void bcm_policer_engine_t_init( 1249 bcm_policer_engine_t *policer_engine); 1250 1251 /* init bcm_policer_database_attach_config_t */ 1252 extern void bcm_policer_database_attach_config_t_init( 1253 bcm_policer_database_attach_config_t *policer_database_attach_config); 1254 1255 /* init bcm_policer_database_config_t */ 1256 extern void bcm_policer_database_config_t_init( 1257 bcm_policer_database_config_t *policer_database_config); 1258 1259 /* init bcm_policer_expansion_group_t */ 1260 extern void bcm_policer_expansion_group_t_init( 1261 bcm_policer_expansion_group_t *policer_expansion_group); 1262 1263 /* init bcm_policer_color_resolution_t */ 1264 extern void bcm_policer_color_resolution_t_init( 1265 bcm_policer_color_resolution_t *policer_color_resolution); 1266 1267 /* Direction of entries allocation in hardware. */ 1268 typedef enum bcm_policer_group_direction_e { 1269 bcmPolicerGroupDirectionVertical = 0, /* Entries allocation within pool */ 1270 bcmPolicerGroupDirectionHorizontal = 1 /* Entries allocation across pool */ 1271 } bcm_policer_group_direction_t; 1272 1273 /* Policer Pool numbers (for bcmFieldHintTypePolicerPoolSel). */ 1274 typedef enum bcm_policer_pool_num_e { 1275 bcmPolicerPool0 = 0, /* Policer pool 0. */ 1276 bcmPolicerPool1 = 1, /* Policer pool 1. */ 1277 bcmPolicerPool2 = 2, /* Policer pool 2. */ 1278 bcmPolicerPool3 = 3, /* Policer pool 3. */ 1279 bcmPolicerPoolCount = 4 /* Always Last. Not a usable value. */ 1280 } bcm_policer_pool_num_t; 1281 1282 #define BCM_POLICER_POOL_NUM_STRINGS \ 1283 { \ 1284 "0", \ 1285 "1", \ 1286 "2", \ 1287 "3" \ 1288 } 1289 1290 /* Macros for policer pool overrride */ 1291 #define BCM_POLICER_CANCEL_NONE (0) /* Do not cancel policer pool 1292 actions */ 1293 #define BCM_POLICER_CANCEL_POOL0 (1 << 0) /* Cancel policer actions from 1294 pool 0 */ 1295 #define BCM_POLICER_CANCEL_POOL1 (1 << 1) /* Cancel policer actions from 1296 pool 1 */ 1297 #define BCM_POLICER_CANCEL_POOL2 (1 << 2) /* Cancel policer actions from 1298 pool 2 */ 1299 #define BCM_POLICER_CANCEL_POOL3 (1 << 3) /* Cancel policer actions from 1300 pool 3 */ 1301 1302 /* Policer group information */ 1303 typedef struct bcm_policer_group_info_s { 1304 bcm_policer_t policer_id; /* Policer Identifier. */ 1305 bcm_policer_group_direction_t direction; /* Direction of allocation of entries */ 1306 uint32 mode_id; /* Policer group mode identifier. */ 1307 bcm_policer_group_mode_t mode; /* Policer group mode. */ 1308 uint32 pool_id; /* Pool number of allocated entries. If 1309 direction is vertical, it represent 1310 pool in which all entries are 1311 allocated. If direction is 1312 horizontal, it is always 0. */ 1313 uint32 base_offset; /* In vertical allocation, it represents 1314 offset of Base policer Index from the 1315 start of pool. In horizontal 1316 direction, it represents offset of 1317 each policers allocated from start of 1318 their respective pool. */ 1319 uint32 num_policers; /* Number of policers allocated in the 1320 group. */ 1321 uint32 num_offset_reserved; /* Number of entries reserved in the 1322 hardware. Direction along with this 1323 value provide information of how 1324 entries are allocated */ 1325 bcm_policer_t macro_policer_id; /* Macro policer of the policer group. */ 1326 } bcm_policer_group_info_t; 1327 1328 /* Initializes bcm_policer_group_info_t struct. */ 1329 extern void bcm_policer_group_info_t_init( 1330 bcm_policer_group_info_t *policer_group_info); 1331 1332 #ifndef BCM_HIDE_DISPATCHABLE 1333 1334 /* 1335 * Create a group of policers belonging to group mode Id. The output 1336 * is policer group information required to build database of entries 1337 * allocations within/across pools. 1338 */ 1339 extern int bcm_policer_custom_group_id_create( 1340 int unit, 1341 uint32 flags, 1342 uint32 mode_id, 1343 bcm_policer_t macro_flow_policer_id, 1344 bcm_policer_group_info_t *policer_group_info); 1345 1346 /* 1347 * Copy a policer group from current hardware location to new location as 1348 * provided. 1349 */ 1350 extern int bcm_policer_custom_group_id_copy( 1351 int unit, 1352 bcm_policer_group_info_t *old_policer_group_info, 1353 bcm_policer_group_info_t *new_policer_group_info); 1354 1355 #endif /* BCM_HIDE_DISPATCHABLE */ 1356 1357 #endif /* __BCM_POLICER_H__ */