ipq.h (15877B)
1 /** \file include/bcm_int/dnx/cosq/ingress/ipq.h 2 * 3 * Internal DNX IPQ 4 */ 5 /* 6 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 7 * 8 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 9 */ 10 11 #ifndef _DNX_IPQ_INCLUDED__ 12 #define _DNX_IPQ_INCLUDED__ 13 14 #ifndef BCM_DNX_SUPPORT 15 #error "This file is for use by DNX (JR2) family only!" 16 #endif 17 18 #include <bcm/cosq.h> 19 #include <shared/shrextend/shrextend_error.h> 20 #include <bcm_int/dnx/algo/template_mngr/template_manager_types.h> 21 #include <bcm_int/dnx/algo/swstate/auto_generated/types/dnx_ipq_alloc_mngr_types.h> 22 23 /* 24 * Defines: 25 * { 26 */ 27 28 /* Number of queues in the device */ 29 #define DNX_IPQ_NOF_QUEUES(unit) (dnx_data_ipq.queues.nof_queues_get(unit)) 30 31 /* Number of queues in a region */ 32 #define DNX_IPQ_NOF_QUEUES_IN_REGION(unit) (dnx_data_ipq.regions.nof_queues_get(unit)) 33 34 /* Minimum size of queue bundle */ 35 #define DNX_IPQ_MIN_BUNDLE_SIZE(unit) (dnx_data_ipq.queues.min_bundle_size_get(unit)) 36 37 /* Number of regions the queues are devided into */ 38 #define DNX_IPQ_NOF_REGIONS(unit) (DNX_IPQ_NOF_QUEUES(unit) / DNX_IPQ_NOF_QUEUES_IN_REGION(unit)) 39 40 /* Size of FMQ bundle is simple scheduling mode */ 41 #define DNX_IPQ_FMQ_BUNDLE_SIZE(unit) (dnx_data_ipq.queues.fmq_bundle_size_get(unit)) 42 43 #define DNX_COSQ_IPQ_QUEUE_TO_QUAD_GET(qid) ((qid) / dnx_data_ipq.queues.min_bundle_size_get(unit)) 44 #define DNX_COSQ_IPQ_QUAD_TO_QUEUE_GET(quad) ((quad) * dnx_data_ipq.queues.min_bundle_size_get(unit)) 45 /* 46 * } 47 */ 48 49 /* 50 * Exposing internal declarations - 51 * the following 2 functions are required in shell command "tm ingress queue mapping" implementation. 52 * see sh_dnx_tm_queue_mapping_cmd() 53 * for information about these functions, see declaration in ipq_dbal.h 54 */ 55 extern shr_error_e dnx_cosq_ipq_dbal_system_port_to_voq_base_get( 56 int unit, 57 int core, 58 uint32 system_port, 59 uint32 *base_voq, 60 uint32 *is_valid); 61 62 extern shr_error_e dnx_cosq_ipq_dbal_queue_quartet_to_sys_port_map_get( 63 int unit, 64 int core, 65 uint32 queue_quartet, 66 uint32 *system_port); 67 68 /* 69 * Functions prototypes 70 * { 71 */ 72 73 /** 74 * \brief 75 * Initialize dnx ipq module. 76 * 77 * \param [in] unit - 78 * The unit number. 79 * \return 80 * \retval Zero if no error was detected 81 * \retval Negative if error was detected. See \ref shr_error_e 82 * \remark 83 * * None 84 * \see 85 * * None 86 */ 87 shr_error_e dnx_cosq_ipq_init( 88 int unit); 89 90 /** 91 * \brief 92 * Allocate queue bundles through resource manager. 93 * 94 * \param [in] unit - 95 * Relevant unit. 96 * \param [in] core - 97 * Device core id. 98 * \param [in] flags - 99 * Request to allocate specific queue (using DNX_ALGO_RES_ALLOCATE_WITH_ID), 100 * or any queue from region range (no flags needed). 101 * \param [in] queue_type - 102 * Type of queue. See \ref dnx_ipq_queue_type_e. 103 * \param [in] num_cos - 104 * Number of COS to allocate for the queue. 105 * Should be 4 or 8. 106 * \param [in,out] base_queue - 107 * The base queue that was allocated, or the base queue to allocate if using 108 * WITH_ID flag. 109 * \retval See \ref shr_error_e 110 * \remark 111 * The function allocates queue. 112 * If WITH_ID flag is used then it will allocate the queue specify in 113 * 'base_queue' param. 114 * If WITH_ID flag is not used then it will allocate some free queue bundle 115 * matching queue_type. 116 * Note that when trying to allocate multicast queue in simple scheduling mode, 117 * only FMQ 0 can be allocated. 118 * \see 119 * dnx_algo_res_allocate 120 */ 121 shr_error_e dnx_cosq_ipq_queue_allocate( 122 int unit, 123 int core, 124 uint32 flags, 125 dnx_ipq_queue_type_e queue_type, 126 int num_cos, 127 int *base_queue); 128 129 /** 130 * \brief 131 * Deallocate queue bundles through resource manager. 132 * 133 * \param [in] unit - 134 * Relevant unit. 135 * \param [in] core - 136 * Device core id. 137 * \param [in] base_queue - 138 * The base queue to deallocate. 139 * \retval See \ref shr_error_e. 140 * \remark 141 * For FMQ simple scheduling mode, deallocation is done through 142 * sw_state and not through alloc manager. 143 * \see 144 * dnx_algo_res_free 145 */ 146 shr_error_e dnx_cosq_ipq_queue_deallocate( 147 int unit, 148 int core, 149 int base_queue); 150 151 /** 152 * \brief 153 * Check if queue is allocated in resource manager. 154 * 155 * \param [in] unit - Relevant unit. 156 * \param [in] core - Device core id. 157 * \param [in] base_voq - The base queue to check. 158 * \param [out] is_allocated - indication from resource manager whether the queue is allocated. 159 * 160 * \retval See \ref shr_error_e. 161 * \remark 162 * \see 163 * dnx_algo_res_free 164 */ 165 shr_error_e dnx_cosq_ipq_queue_is_allocated( 166 int unit, 167 int core, 168 uint32 base_voq, 169 int *is_allocated); 170 /** 171 * \brief 172 * Queue to system port mapping. 173 * Returns system port for a given queue. 174 * 175 * \param [in] unit - 176 * Relevant unit. 177 * \param [in] core - 178 * Device core. 179 * \param [in] queue - 180 * The queue. 181 * \param [out] sysport - 182 * The system port. 183 * \retval See \ref shr_error_e. 184 * \remark 185 * None. 186 * \see 187 * None. 188 */ 189 shr_error_e dnx_ipq_queue_sysport_map_get( 190 int unit, 191 int core, 192 int queue, 193 uint32 *sysport); 194 /** 195 * \brief 196 * Get base queue num_cos (number of queues in a bundle) 197 * 198 * \param [in] unit - 199 * Relevant unit. 200 * \param [in] core - core id 201 * \param [in] base_queue_id - queue if of base queue 202 * \param [out] num_cos - number of queues in the bundle 203 * \retval See \ref shr_error_e. 204 * \remark 205 * None. 206 * \see 207 * None. 208 */ 209 shr_error_e dnx_ipq_queue_num_cos_get( 210 int unit, 211 int core, 212 int base_queue_id, 213 int *num_cos); 214 215 /** 216 * \brief 217 * Get base queue num_cos (number of queues in a bundle) 218 * 219 * \param [in] unit - 220 * Relevant unit. 221 * \param [in] queue_id - queue id 222 * \param [out] is_multicast - is the queue multicast 223 * \retval See \ref shr_error_e. 224 * \remark 225 * None. 226 * \see 227 * None. 228 */ 229 shr_error_e dnx_ipq_queue_is_multicast( 230 int unit, 231 int queue_id, 232 int *is_multicast); 233 234 /** 235 * \brief 236 * Function to return the cosq gport from the queue_id num and 237 * the core. 238 * 239 * \param [in] unit - 240 * Relevant unit. 241 * \param [in] core - core 242 * \param [in] queue_id - queue id 243 * \param [out] queue_gport - the queue_id gport 244 * \retval See \ref shr_error_e. 245 * \remark 246 * None. 247 * \see 248 * None. 249 */ 250 shr_error_e dnx_ipq_queue_gport_get( 251 int unit, 252 int core, 253 int queue_id, 254 bcm_gport_t * queue_gport); 255 256 /** 257 * \brief 258 * Function to get the Fabric Multicast Queue upper range within the total queues range. 259 * Both cores are configured symmetrically, so this configuration applies to both cores. 260 * 261 * \param [in] unit - 262 * Relevant unit. 263 * \param [out] queue_id - queue id which is used as the upper limit for FMQ range. 264 * \retval See \ref shr_error_e. 265 * \remark 266 * None. 267 * \see 268 * None. 269 */ 270 shr_error_e dnx_cosq_ipq_fabric_multicast_queue_range_get( 271 int unit, 272 int *queue_id); 273 274 /** 275 * \brief 276 * Function to get the Fabric Multicast Queue upper range within the total queues range. 277 * Both cores are configured symmetrically, so this configuration applies to both cores. 278 * 279 * \param [in] unit - 280 * Relevant unit. 281 * \param [in] queue_id - queue id to be used as the upper limit for FMQ range. 282 * \retval See \ref shr_error_e. 283 * \remark 284 * None. 285 * \see 286 * None. 287 */ 288 shr_error_e dnx_cosq_ipq_fabric_multicast_queue_range_set( 289 int unit, 290 int queue_id); 291 292 /** 293 * \brief - This is a callback function, registered to the alloc manager to be called 294 * whenever a new region is allocated. At that time, we need to set the 295 * region to be interdigitated or not. 296 * 297 * \param [in] unit - Relevant unit. 298 * \param [in] queue_region - queue region index. 299 * \param [in] is_non_contiguous - is region interdigitated. 300 * 301 * \retval See \ref shr_error_e. 302 * \remark 303 * None. 304 * \see 305 * None. 306 */ 307 shr_error_e dnx_cosq_ipq_region_config_set( 308 int unit, 309 int queue_region, 310 int is_non_contiguous); 311 312 /** 313 * \brief 314 * Create a new instance of queue quartet bitmap resource manager. 315 * 316 * \param [in] unit - Relevant unit. 317 * \param [in] module_id - Module ID. 318 * \param [in] res_tag_bitmap - Resource tag bitmap. 319 * \param [in] create_data - Pointed memory contains setup parameters required for the 320 * creation of the resource. See \ref dnx_algo_res_create_data_t 321 * \param [in] extra_arguments - Not used. 322 * \param [in] nof_elements - Number of elements of the resource tag bitmap. Specified in the relevant sw state xml file. 323 * \param [in] alloc_flags - SW state allocation flags. 324 * This flags value is determend by the variable type (dnx data for example) of the additional variables specified in the xml 325 * 326 * \retval Zero if no error was detected 327 * \retval Negative if error was detected. See \ref shr_error_e 328 * \remark 329 * The function creates 1 long bitmap in size of (nof_queue_quartets), 330 * then it tags a group of region_size bits with the same tag. 331 * \see 332 * dnx_algo_res_create 333 * sw_state_res_tag_bitmap_create 334 * sw_state_res_tag_bitmap_tag_set 335 */ 336 shr_error_e dnx_cosq_ipq_alloc_mngr_queue_qrtt_bitmap_create( 337 int unit, 338 uint32 module_id, 339 resource_tag_bitmap_t * res_tag_bitmap, 340 dnx_algo_res_create_data_t * create_data, 341 void *extra_arguments, 342 uint32 nof_elements, 343 uint32 alloc_flags); 344 345 /** 346 * \brief 347 * Free bits in queue quartet bitmap. 348 * 349 * \param [in] unit - Relevant unit. 350 * \param [in] module_id - Module ID. 351 * \param [in] res_tag_bitmap - Resource tag bitmap. 352 * \param [in] element - Element to free. 353 * 354 * \retval See \ref shr_error_e 355 * \remark 356 * Can free more than 1 bit, according to how many bits was allocated. Number 357 * of bits allocated is derived from num_cos in sw_state. 358 * \see 359 * resource_tag_bitmap_free 360 * dnx_algo_ipq_bitmap_allocate 361 */ 362 shr_error_e dnx_cosq_ipq_alloc_mngr_queue_qrtt_bitmap_free( 363 int unit, 364 uint32 module_id, 365 resource_tag_bitmap_t res_tag_bitmap, 366 int element); 367 368 /** 369 * \brief 370 * Allocate bit(s) in queue quartet bitmap. 371 * Each bit represent a queues bundle. 372 * 373 * \param [in] unit - Relevant unit. 374 * \param [in] module_id - Module ID. 375 * \param [in] res_tag_bitmap - Resource tag bitmap. 376 * \param [in] flags - 377 * Special treatment: 378 * 0 (None) - allocate some free element. 379 * DNX_ALGO_RES_ALLOCATE_WITH_ID - allocate specific element 380 * (see also 'element' param info). 381 * \param [in] alloc_info - 382 * Pointer to dnx_ipq_alloc_info_t that holds information 383 * about how many bits to allocate. 384 * See \ref dnx_ipq_alloc_info_t 385 * \param [in,out] element - 386 * Holds the allocated element id (serves as output in no flags were used). 387 * If WITH_ID flag was used this param serves as input and holds the 388 * element id number to allocate. 389 * If more than 1 bit allocated, element will hold the first allocated bit. 390 * 391 * \retval Zero if no error was detected 392 * \retval Negative if error was detected. See \ref shr_error_e 393 * \remark 394 * \see 395 * dnx_algo_res_allocate 396 * sw_state_res_tag_bitmap_alloc_tag 397 * dnx_algo_ipq_bitmap_create 398 */ 399 shr_error_e dnx_cosq_ipq_alloc_mngr_queue_qrtt_bitmap_allocate( 400 int unit, 401 uint32 module_id, 402 resource_tag_bitmap_t res_tag_bitmap, 403 uint32 flags, 404 void *alloc_info, 405 int *element); 406 407 /** 408 * \brief - set mapping from TC to MC prioroity. 409 * 410 * \param [in] unit - Relevant unit. 411 * \param [in] cosq - TC. 412 * \param [in] mc_prio - multicast priority (BCM_COSQ_HIGH_PRIORITY / BCM_COSQ_LOW_PRIORITY). 413 * 414 * \retval See \ref shr_error_e. 415 * \remark 416 * None. 417 * \see 418 * None. 419 */ 420 shr_error_e dnx_cosq_ipq_tc_to_multicast_prio_map_set( 421 int unit, 422 bcm_cos_queue_t cosq, 423 int mc_prio); 424 425 /** 426 * \brief - get mapping from TC to MC prioroity. 427 * 428 * \param [in] unit - Relevant unit. 429 * \param [in] cosq - TC. 430 * \param [out] mc_prio - multicast priority (BCM_COSQ_HIGH_PRIORITY / BCM_COSQ_LOW_PRIORITY). 431 * 432 * \retval See \ref shr_error_e. 433 * \remark 434 * None. 435 * \see 436 * None. 437 */ 438 shr_error_e dnx_cosq_ipq_tc_to_multicast_prio_map_get( 439 int unit, 440 bcm_cos_queue_t cosq, 441 int *mc_prio); 442 /** 443 * \brief - 444 * Connect ingress VOQ to egress VOQ connector on the ingress side. 445 * 446 * \param [in] unit - Unit-ID 447 * \param [in] gport_connect - VOQ to VOQ connector parameters 448 449 * \return 450 * See shr_error_e 451 * \remark 452 * * None 453 * \see 454 * * None 455 */ 456 shr_error_e dnx_cosq_ipq_gport_connection_set( 457 int unit, 458 bcm_cosq_gport_connection_t * gport_connect); 459 460 /** 461 * \brief - 462 * Get connected ingress VOQ to egress VOQ connector on the ingress side. 463 * 464 * \param [in] unit - Unit-ID 465 * \param [in,out] gport_connect - VOQ to VOQ connector parameters: 466 * gport_connect->voq is used only as input to get base_queue and ingress core 467 * gport_connect->voq_connector is used as input to get egress core, and as output to retrieve the VOQ connector. 468 * \return 469 * \remark 470 * * None 471 * \see 472 * * None 473 */ 474 shr_error_e dnx_cosq_ipq_gport_connection_get( 475 int unit, 476 bcm_cosq_gport_connection_t * gport_connect); 477 478 /** 479 * \brief - 480 * Allocate Unicast Gport bundle 481 * 482 * \param [in] unit - Unit-ID 483 * \param [in] config - queue bundle attributes to set 484 * \param [in,out] gport - output for the allocated base queue gport. in case flag BCM_COSQ_GPORT_WITH_ID is used, this will be used as input. 485 * 486 * \return 487 * \remark 488 * * None 489 * \see 490 * * None 491 */ 492 int dnx_cosq_ipq_ucast_gport_add( 493 int unit, 494 bcm_cosq_ingress_queue_bundle_gport_config_t * config, 495 bcm_gport_t * gport); 496 497 /** 498 * \brief - 499 * Allocate Multicast Gport bundle 500 * 501 * \param [in] unit - Unit-ID 502 * \param [in] config - queue bundle attributes to set 503 * \param [in,out] gport - output for the allocated base queue gport. in case flag BCM_COSQ_GPORT_WITH_ID is used, this will be used as input. 504 * 505 * \return 506 * \remark 507 * * None 508 * \see 509 * * None 510 */ 511 shr_error_e dnx_cosq_ipq_mcast_gport_add( 512 int unit, 513 bcm_cosq_ingress_queue_bundle_gport_config_t * config, 514 bcm_gport_t * gport); 515 516 /** 517 * \brief - 518 * Delete Unicast queue 519 * 520 * \param [in] unit - Unit-ID 521 * \param [in] gport - base queue gport 522 * 523 * \return 524 * \remark 525 * * None 526 * \see 527 * * None 528 */ 529 shr_error_e dnx_cosq_ipq_ucast_gport_delete( 530 int unit, 531 bcm_gport_t gport); 532 533 /** 534 * \brief - 535 * Delete Multicast queue 536 * 537 * \param [in] unit - Unit-ID 538 * \param [in] gport - base queue gport 539 * 540 * \return 541 * \remark 542 * * None 543 * \see 544 * * None 545 */ 546 shr_error_e dnx_cosq_ipq_mcast_gport_delete( 547 int unit, 548 bcm_gport_t gport); 549 550 /** 551 * \brief - 552 * Get Unicast queue information from queue gport 553 * 554 * \param [in] unit - Unit-ID 555 * \param [in] gport - base queue gport 556 * \param [out] physical_port - destination gport (if applicable) 557 * \param [out] num_cos_levels - number of queues in the bundle 558 * \param [out] flags -bmc_gport_add flags used to create this gport 559 * 560 * \return 561 * \remark 562 * * None 563 * \see 564 * * None 565 */ 566 shr_error_e dnx_cosq_ipq_ucast_gport_get( 567 int unit, 568 bcm_gport_t gport, 569 bcm_gport_t * physical_port, 570 int *num_cos_levels, 571 uint32 *flags); 572 573 /** 574 * \brief - 575 * Get Multicast queue information from queue gport 576 * 577 * \param [in] unit - Unit-ID 578 * \param [in] gport - base queue gport 579 * \param [out] physical_port - destination gport (if applicable) 580 * \param [out] num_cos_levels - number of queues in the bundle 581 * \param [out] flags -bmc_gport_add flags used to create this gport 582 * 583 * \return 584 * \remark 585 * * None 586 * \see 587 * * None 588 */ 589 shr_error_e dnx_cosq_ipq_mcast_gport_get( 590 int unit, 591 bcm_gport_t gport, 592 bcm_gport_t * physical_port, 593 int *num_cos_levels, 594 uint32 *flags); 595 596 /* 597 * } 598 */ 599 600 #endif/*_DNX_IPQ_INCLUDED__*/