ecgm.h (19665B)
1 /** \file include/bcm_int/dnx/cosq/egress/ecgm.h 2 * 3 * 4 * Egress congestion (ECGM) 5 * internal API implementation 6 * functions and types. 7 * 8 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 9 * 10 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 11 */ 12 13 #ifndef _DNX_COSQ_EGRESS_CONGESTION_H_INCLUDED_ 14 /** { */ 15 #define _DNX_COSQ_EGRESS_CONGESTION_H_INCLUDED_ 16 17 #include <shared/shrextend/shrextend_error.h> 18 #include <bcm_int/dnx/cosq/cosq.h> 19 #include <sal/types.h> 20 #include <bcm/cosq.h> /* (legacy) for bcm_cosq_egress_multicast_config_t */ 21 #include <soc/dnx/dbal/auto_generated/dbal_defines_fields.h> 22 23 #ifndef BCM_DNX_SUPPORT 24 #error "This file is for use by DNX (JR2) family only!" 25 #endif 26 27 typedef enum 28 { 29 ECGM_LONG_PACKETS_FIFO = 0, 30 ECGM_LCD_FIFO = 1, 31 ECGM_TDM_AND_SHORT_PACKETS = 2 32 } dnx_ecgm_delete_fifo_type_e; 33 34 /** 35 * ECGM resources Typedefs 36 * 37 * { 38 * note that these types are used in two APIs: 39 * for ecgm templates - used as port profile and interface profile fields. 40 * for several dbal accessing functions - used as table parameters. 41 * any change to these types should consider these internal APIs. 42 * 43 * \see algo_ecgm.h 44 * egress_congestion_dbal.h 45 */ 46 47 /* values for FADT (fair adaptive dynamic thresholds) scheme. */ 48 typedef struct 49 { 50 uint32 min; 51 uint32 max; 52 int alpha; 53 } dnx_ecgm_fadt_threshold_t; 54 55 /* unicast flow control thresholds for packet descriptors and data buffers */ 56 typedef struct 57 { 58 dnx_ecgm_fadt_threshold_t db_fc; 59 dnx_ecgm_fadt_threshold_t pd_fc; 60 } dnx_ecgm_uc_fc_thresholds_t; 61 62 /* unicast flow control and drop thresholds */ 63 typedef struct 64 { 65 dnx_ecgm_uc_fc_thresholds_t flow_control; 66 uint32 pd_drop; 67 uint32 db_drop; 68 } dnx_ecgm_uc_thresholds_t; 69 70 /* multicast drop thresholds for packet descriptors and data buffers */ 71 typedef struct 72 { 73 dnx_ecgm_fadt_threshold_t pd_drop; 74 uint32 db_drop; 75 } dnx_ecgm_mc_drop_thresholds_t; 76 77 /* multicast queue resources */ 78 typedef struct 79 { 80 /* 81 * amount of reserved packet descriptors 82 */ 83 uint32 reserved_pds; 84 85 /* 86 * mapped PD service pool 87 */ 88 uint32 pd_sp; 89 90 /* 91 * drop thresholds per DP 92 */ 93 dnx_ecgm_mc_drop_thresholds_t drop_thresholds[DNX_COSQ_NOF_DP]; 94 } dnx_ecgm_mc_queue_resources_t; 95 96 typedef struct 97 { 98 uint32 total_pd; 99 uint32 uc_pd; 100 uint32 mc_pd; 101 uint32 total_db; 102 uint32 uc_db; 103 uint32 mc_db; 104 } ecgm_core_global_resources_statistics_t; 105 106 typedef struct 107 { 108 uint32 pd; 109 uint32 db; 110 uint32 reserved_pd; 111 uint32 reserved_db; 112 } ecgm_service_pool_resources_statistics_t; 113 114 /** 115 * } 116 */ 117 118 /** 119 * ECGM internal API 120 */ 121 122 /* ECGM_MULTICAST_QUEUE_MAP_TO_SP */ 123 124 /** 125 * \brief - enable dynamic memory access to all tables under ecgm block 126 * 127 * \param [in] unit - unit number 128 * \param [in] enable - enable/disable 1/0 129 * 130 * \return 131 * shr_error_e 132 * 133 * \remark 134 * * None 135 * \see 136 * * None 137 */ 138 shr_error_e dnx_ecgm_dbal_dynamic_memory_access_set( 139 int unit, 140 int enable); 141 142 /** 143 * \brief - Gets enable dynamic memory access for ecgm block 144 * 145 * \param [in] unit - unit number 146 * \param [in] enable - enable/disable 1/0 147 * 148 * \return 149 * shr_error_e 150 * 151 * \remark 152 * * None 153 * \see 154 * * None 155 */ 156 shr_error_e dnx_ecgm_dbal_dynamic_memory_access_get( 157 int unit, 158 uint32 *enable); 159 160 /** 161 * \brief 162 * Init function for ECGM resources. 163 * initializes port profile and interface profile templates 164 * and set HW registers to requiered default values. 165 * 166 * \param [in] unit - device unit number 167 * 168 * \return 169 * shr_error_e 170 * 171 * \remarks 172 * * None 173 * 174 * \see 175 * * None 176 */ 177 shr_error_e dnx_ecgm_init( 178 int unit); 179 180 /** 181 * \brief 182 * Deinit function for ECGM resources. 183 * releases allocated resources. 184 * 185 * \param [in] unit - device unit number 186 * 187 * \return 188 * shr_error_e 189 * 190 * \remarks 191 * * None 192 * 193 * \see 194 * * None 195 */ 196 shr_error_e dnx_ecgm_deinit( 197 int unit); 198 199 /** 200 * \brief - callback function for port add sequence. 201 * allocates empty resource-profiles for the new port. 202 * 203 * \param [in] unit - device unit number 204 * 205 * \return 206 * shr_error_e 207 * 208 * \see 209 * port_dyn.c 210 */ 211 shr_error_e dnx_ecgm_port_add( 212 int unit); 213 214 /** 215 * \brief - callback function for port add sequence. 216 * frees ecgm resources consumed by the port. 217 * 218 * \param [in] unit - device unit number 219 * 220 * \return 221 * shr_error_e 222 * 223 * \see 224 * port_dyn.c 225 */ 226 shr_error_e dnx_ecgm_port_remove( 227 int unit); 228 229 /** 230 * \brief - Map a multicast queue to a PD service pool. 231 * 232 * \param [in] unit - device unit number 233 * \param [in] gport - multicast queue gport 234 * \param [in] queue_offset - offset from base Q-pair (priority). 235 * \param [in] pd_service_pool - packet descriptors service pool id (0/1) to map the queue to. 236 * 237 * \return 238 * shr_error_e 239 * 240 * \remarks 241 * * None 242 * \see 243 * * None 244 */ 245 shr_error_e dnx_ecgm_map_mc_queue_to_pd_sp_set( 246 int unit, 247 bcm_gport_t gport, 248 bcm_cos_queue_t queue_offset, 249 int pd_service_pool); 250 251 /** 252 * \brief - Map a multicast queue to a PD service pool. 253 * 254 * \param [in] unit - device unit number 255 * \param [in] gport - multicast queue gport 256 * \param [in] queue_offset - offset from base Q-pair (priority). 257 * \param [out] pd_service_pool - mapped packet descriptors service pool id (0/1). 258 * 259 * \return 260 * shr_error_e 261 * 262 * \remarks 263 * * None 264 * \see 265 * * None 266 */ 267 shr_error_e dnx_ecgm_map_mc_queue_to_pd_sp_get( 268 int unit, 269 bcm_gport_t gport, 270 bcm_cos_queue_t queue_offset, 271 int *pd_service_pool); 272 273 /** 274 * \brief - Mapping multicast COS params on device level. 275 * per system TC and system DP: 276 * 1. Multicast TC (config->priority). 277 * 2. Data buffers service pool (config->unscheduled_sp). 278 * 3. Eligibility to use resources (config->unscheduled_se). 279 * 280 * \param [in] unit - device unit number. 281 * \param [in] system_tc - traffic class (0-7). 282 * \param [in] system_dp - drop precedence (0-3). 283 * \param [in] config - bcm_cosq_egress_multicast_config_t 284 * relevant fields in the struct are: 285 * priority, unscheduled_sp and unscheduled_se. 286 * \return 287 * shr_error_e 288 * 289 * \remarks 290 * generally, db sp #0 (bcmCosqEgressMulticastServicePool0) 291 * is considered high priority, and #1 (bcmCosqEgressMulticastServicePool1) 292 * is considered low priority. this can be configured either way, 293 * but should be consistent through all sp configurations. 294 * 295 * mapping an MC-TC to a new SP can only be done if reserved DB for the chosen MC-TC is 0 (for both cores). 296 * 297 * mapping all multicast COS params cannot be done when the device traffic is enabled, 298 * unless the SOC property "allow modifications during traffic" is enabled. 299 * 300 * \see 301 * * None 302 */ 303 shr_error_e dnx_ecgm_core_multicast_config_set( 304 int unit, 305 bcm_cos_t system_tc, 306 bcm_color_t system_dp, 307 bcm_cosq_egress_multicast_config_t * config); 308 309 /** 310 * \brief - Get multicast COS params mapped to system TC and system DP. 311 * see more info about mapping in the set function above. 312 * 313 * \param [in] unit - device unit number. 314 * \param [in] system_tc - traffic class (0-7). 315 * \param [in] system_dp - drop precedence (0-3). 316 * \param [in] config - bcm_cosq_egress_multicast_config_t. 317 * 318 * \return 319 * shr_error_e 320 */ 321 shr_error_e dnx_ecgm_core_multicast_config_get( 322 int unit, 323 bcm_cos_t system_tc, 324 bcm_color_t system_dp, 325 bcm_cosq_egress_multicast_config_t * config); 326 327 /** 328 * \brief - set ecgm thresholds. 329 * 330 * \param [in] unit - device unit number 331 * \param [in] gport - may be of type: CORE, INTERFACE, MCAST_EGRESS_QUEUE, UCAST_EGRESS_QUEUE or 0. 332 * if gport == 0 - will indicate CORE, and threshold will be set for all cores. 333 * \param [in] cosq - valid values are: -1 or 0-7 (when represents traffic class) 334 * must be consistent with flags and types indicated by threshold struct. 335 * \param [in] threshold - a struct containing information about the requierd threshold. 336 * the ONLY relevant fields from the struct are: 337 * flags - indicate the type of threshold action. 338 * dp - drop precedence (0-3), only for relevant some multicast queue thresholds. 339 * when used - flag must be set with BCM_COSQ_THRESHOLD_PER_DP. 340 * type - the threshold resource type. 341 * priority - BCM_COSQ_HIGH_PRIORITY / BCM_COSQ_LOW_PRIORITY 342 * relevant only for interface thresholds. 343 * MUST be indicated if gport is interface. 344 * value - indicates the threshold value to be set. 345 * \return 346 * shr_error_e 347 * 348 * \remarks 349 * NOTE that threshold struct contains a 'tc' field - but this will NOT be used. 350 * instead - the given cosq is used to indicate the chosen queue/tc. 351 * \see 352 */ 353 shr_error_e dnx_ecgm_gport_threshold_set( 354 int unit, 355 bcm_gport_t gport, 356 bcm_cos_queue_t cosq, 357 bcm_cosq_threshold_t * threshold); 358 359 /** 360 * \brief - get ecgm thresholds. 361 * 362 * \param [in] unit - device unit number 363 * \param [in] gport - may be of type: CORE, INTERFACE, MCAST_EGRESS_QUEUE, UCAST_EGRESS_QUEUE or 0. 364 * if gport == 0 - will indicate CORE, and threshold will be given from core id = 0. 365 * \param [in] cosq - valid values are: -1 or 0-7 (when represents traffic class) 366 * must be consistent with flags and types indicated by threshold struct. 367 * \param [out] threshold - a struct containing information about the requierd threshold. 368 * the ONLY relevant fields from the struct are: 369 * flags - indicate the type of threshold action. 370 * dp - drop precedence (0-3), only for relevant some multicast queue thresholds. 371 * when used - flag must be set with BCM_COSQ_THRESHOLD_PER_DP. 372 * type - the threshold resource type. 373 * priority - BCM_COSQ_HIGH_PRIORITY / BCM_COSQ_LOW_PRIORITY 374 * relevant only for interface thresholds. 375 * MUST be indicated if gport is interface. 376 * value - will be set with the corresponding threshold value. 377 * \return 378 * shr_error_e 379 * 380 * \remarks 381 * NOTE that threshold struct contains a 'tc' field - but this will NOT be used. 382 * instead - the given cosq is used to indicate the chosen queue/tc. 383 * \see 384 */ 385 shr_error_e dnx_ecgm_gport_threshold_get( 386 int unit, 387 bcm_gport_t gport, 388 bcm_cos_queue_t cosq, 389 bcm_cosq_threshold_t * threshold); 390 391 /** 392 * \brief - Get the current values of the ECGM resources per core. 393 * 394 * \param [in] unit - chip unit id 395 * \param [in] core_id - core id 396 * \param [out] core_res_cur - Current values of the following resources: 397 * Total PDs, UC PDs, MC PDs, Total DBs, UC DBs, MC DBs. 398 * 399 * \return 400 * shr_error_e 401 * 402 * \see 403 * * None 404 */ 405 shr_error_e dnx_ecgm_dbal_core_global_resources_statistics_current_get( 406 uint32 unit, 407 uint32 core_id, 408 ecgm_core_global_resources_statistics_t * core_res_cur); 409 410 /** 411 * \brief - Get the current values of the ECGM resources per InterFace. 412 * 413 * \param [in] unit - chip unit id 414 * \param [in] core_id - core id 415 * \param [in] is_mc - UC = 0, MC = 1 416 * \param [in] ecgm_priority - Interface priority 417 * \param [in] egq_if - Interface number 418 * \param [out] pd - Current value of allocated Packet Descriptors. 419 * \param [out] db - Current value of allocated Data Buffers. 420 * 421 * \return 422 * shr_error_e 423 * 424 * \see 425 * * None 426 */ 427 shr_error_e dnx_ecgm_dbal_interface_resources_statistics_current_get( 428 uint32 unit, 429 uint32 core_id, 430 uint32 is_mc, 431 dbal_enum_value_field_ecgm_priority_e ecgm_priority, 432 uint32 egq_if, 433 uint32 *pd, 434 uint32 *db); 435 436 /** 437 * \brief - Get the current values of the ECGM resources per Port. 438 * 439 * \param [in] unit - chip unit id 440 * \param [in] core_id - core id 441 * \param [in] is_mc - UC = 0, MC = 1 442 * \param [in] otm_port - Port number. 443 * \param [out] pd - Current value of allocated Packet Descriptors. 444 * \param [out] db - Current value of allocated Data Buffers. 445 * 446 * \return 447 * shr_error_e 448 * 449 * \see 450 * * None 451 */ 452 shr_error_e dnx_ecgm_dbal_port_resources_statistics_current_get( 453 uint32 unit, 454 uint32 core_id, 455 uint32 is_mc, 456 uint32 otm_port, 457 uint32 *pd, 458 uint32 *db); 459 460 /** 461 * \brief - Get the current values of the ECGM resources per Queue. 462 * 463 * \param [in] unit - chip unit id 464 * \param [in] core_id - core id 465 * \param [in] is_mc - UC = 0, MC = 1 466 * \param [in] queue_pair - Queue Pair number 467 * \param [out] pd - Current value of allocated Packet Descriptors. 468 * \param [out] db - Current value of allocated Data Buffers. 469 * 470 * \return 471 * shr_error_e 472 * 473 * \see 474 * * None 475 */ 476 shr_error_e dnx_ecgm_dbal_queue_resources_statistics_current_get( 477 uint32 unit, 478 uint32 core_id, 479 uint32 is_mc, 480 uint32 queue_pair, 481 uint32 *pd, 482 uint32 *db); 483 484 /** 485 * \brief - Get the current values of the ECGM resources per Service Pool. 486 * 487 * \param [in] unit - chip unit id 488 * \param [in] core_id - core id 489 * \param [in] sp_id - Service Pool number 490 * \param [out] sp_resource - Current values of the following resources: 491 * PDs, DBs, reserved PDs, resreved DBs. 492 * 493 * \return 494 * shr_error_e 495 * 496 * \see 497 * * None 498 */ 499 shr_error_e dnx_ecgm_dbal_service_pool_resources_statistics_current_get( 500 uint32 unit, 501 uint32 core_id, 502 uint32 sp_id, 503 ecgm_service_pool_resources_statistics_t * sp_resource); 504 505 /** 506 * \brief - Get the current values of the ECGM resources per Service Pool per Traffic Class. 507 * 508 * \param [in] unit - chip unit id 509 * \param [in] core_id - core id 510 * \param [in] sp_id - Service Pool number 511 * \param [in] tc - Traffic Class 512 * \param [out] pd - Current value of allocated Packet Descriptors. 513 * \param [out] db - Current value of allocated Data Buffers. 514 * 515 * \return 516 * shr_error_e 517 * 518 * \see 519 * * None 520 */ 521 shr_error_e dnx_ecgm_dbal_service_pool_tc_resources_statistics_current_get( 522 uint32 unit, 523 uint32 core_id, 524 uint32 sp_id, 525 uint32 tc, 526 uint32 *pd, 527 uint32 *db); 528 529 /** 530 * \brief - Get the maximum number of allocated ECGM resources that have been reached per core since the last CPU read. 531 * 532 * \param [in] unit - chip unit id 533 * \param [in] core_id - core id 534 * \param [out] core_resource - Maximum values of the following resources: 535 * Total PDs, UC PDs, MC PDs, Total DBs, UC DBs, MC DBs. 536 * 537 * \return 538 * shr_error_e 539 * 540 * \see 541 * * None 542 */ 543 shr_error_e dnx_ecgm_dbal_core_global_resources_statistics_max_get( 544 uint32 unit, 545 uint32 core_id, 546 ecgm_core_global_resources_statistics_t * core_resource); 547 548 /** 549 * \brief - Get the maximum number of allocated ECGM resources that have been reached per InterFace since the last CPU read. 550 * 551 * \param [in] unit - chip unit id 552 * \param [in] core_id - core id 553 * \param [in] is_mc - UC = 0, MC = 1 554 * \param [in] ecgm_priority - Interface priority 555 * \param [in] egq_if - Interface number 556 * \param [out] pd - Maximum number of allocated Packet Descriptors that have been reached since the last CPU read. 557 * \param [out] db - Maximum number of allocated Data Buffers that have been reached since the last CPU read. 558 * 559 * \return 560 * shr_error_e 561 * 562 * \see 563 * * None 564 */ 565 shr_error_e dnx_ecgm_dbal_interface_resources_statistics_max_get( 566 uint32 unit, 567 uint32 core_id, 568 uint32 is_mc, 569 dbal_enum_value_field_ecgm_priority_e ecgm_priority, 570 uint32 egq_if, 571 uint32 *pd, 572 uint32 *db); 573 574 /** 575 * \brief - Get the maximum number of allocated ECGM resources that have been reached per Port since the last CPU read. 576 * 577 * \param [in] unit - chip unit id 578 * \param [in] core_id - core id 579 * \param [in] is_mc - UC = 0, MC = 1 580 * \param [in] otm_port - Port number 581 * \param [in] pd - Maximum number of allocated Packet Descriptors that have been reached since the last CPU read. 582 * \param [in] db - Maximum number of allocated Data Buffers that have been reached since the last CPU read. 583 * 584 * \return 585 * shr_error_e 586 * 587 * \see 588 * * None 589 */ 590 shr_error_e dnx_ecgm_dbal_port_resources_statistics_max_get( 591 uint32 unit, 592 uint32 core_id, 593 uint32 is_mc, 594 uint32 otm_port, 595 uint32 *pd, 596 uint32 *db); 597 598 /** 599 * \brief - Get the maximum number of allocated ECGM resources that have been reached per Queue since the last CPU read. 600 * 601 * \param [in] unit - chip unit id 602 * \param [in] core_id - core id 603 * \param [in] is_mc - UC = 0, MC = 1 604 * \param [in] queue_pair - Queue Pair number 605 * \param [out] pd - Maximum number of allocated Packet Descriptors that have been reached since the last CPU read. 606 * \param [out] db - Maximum number of allocated Data Buffers that have been reached since the last CPU read. 607 * 608 * \return 609 * shr_error_e 610 * 611 * \see 612 * * None 613 */ 614 shr_error_e dnx_ecgm_dbal_queue_resources_statistics_max_get( 615 uint32 unit, 616 uint32 core_id, 617 uint32 is_mc, 618 uint32 queue_pair, 619 uint32 *pd, 620 uint32 *db); 621 622 /** 623 * \brief - Get the maximum number of allocated ECGM resources that have been reached per Service Pool since the last CPU read. 624 * 625 * \param [in] unit - chip unit id 626 * \param [in] core_id - core id 627 * \param [in] sp_id - Service Pool number 628 * \param [out] sp_resource - Maximum number of allocated resources that have been reached since the last CPU read: 629 * PDs, DBs. (Note that the members "reserved PDs" and "reserved DBs" do not change). 630 * 631 * \return 632 * shr_error_e 633 * 634 * \see 635 * * None 636 */ 637 shr_error_e dnx_ecgm_dbal_service_pool_resources_statistics_max_get( 638 uint32 unit, 639 uint32 core_id, 640 uint32 sp_id, 641 ecgm_service_pool_resources_statistics_t * sp_resource); 642 643 /** 644 * \brief - Get the maximum number of allocated ECGM resources that have been reached per Service Pool per Traffic Class since the last CPU read. 645 * 646 * \param [in] unit - chip unit id 647 * \param [in] core_id - core id 648 * \param [in] sp_id - Service Pool number 649 * \param [in] tc - Traffic Class 650 * \param [out] pd - Maximum number of allocated Packet Descriptors that have been reached since the last CPU read. 651 * \param [out] db - Maximum number of allocated Data Buffers that have been reached since the last CPU read. 652 * 653 * \return 654 * shr_error_e 655 * 656 * \see 657 * * None 658 */ 659 shr_error_e dnx_ecgm_dbal_service_pool_tc_resources_statistics_max_get( 660 uint32 unit, 661 uint32 core_id, 662 uint32 sp_id, 663 uint32 tc, 664 uint32 *pd, 665 uint32 *db); 666 667 /** 668 * \brief - Clears the maximum number of allocated ECGM resources that have been reached since the last CPU read. 669 * 670 * \param [in] unit - chip unit id 671 * 672 * \return 673 * shr_error_e 674 * 675 * \see 676 * * None 677 */ 678 shr_error_e dnx_ecgm_dbal_resources_statistics_max_clear( 679 int unit); 680 681 /** 682 * \brief - Set the ECGM tacking control bit. 683 * 684 * \param [in] unit - chip unit id 685 * \param [in] core_id - core id 686 * \param [in] is_tracking - set the tacking: 1 = on, 0 = off. 687 * \return 688 * shr_error_e 689 * 690 * \see 691 * * None 692 */ 693 shr_error_e dnx_ecgm_dbal_disable_max_statistics_tracking_set( 694 uint32 unit, 695 uint32 core_id, 696 uint32 is_tracking); 697 698 /** 699 * \brief - Get a disable indication bit for a queue pair number. 700 * 701 * \param [in] unit - chip unit id 702 * \param [in] core_id - core id 703 * \param [in] queue_pair - queue pair id 0-511 704 * \param [out] is_queue_disabled - the queue-pair is disabled when the bit is on 705 * 706 * \return 707 * shr_error_e 708 * 709 * \remarks 710 * * None 711 * \see 712 * * None 713 */ 714 shr_error_e dnx_ecgm_dbal_queue_disable_get( 715 uint32 unit, 716 uint32 core_id, 717 uint32 queue_pair, 718 uint32 *is_queue_disabled); 719 720 /** } */ 721 722 #endif /** _DNX_COSQ_EGRESS_CONGESTION_H_INCLUDED_ */