cosq.h (14000B)
1 /*! \file cosq.h 2 * 3 * COSQ internal management header file. 4 * This file contains the management for COSQ module. 5 */ 6 /* 7 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 8 * 9 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 10 */ 11 12 #ifndef BCMI_LTSW_COSQ_H 13 #define BCMI_LTSW_COSQ_H 14 15 #include <bcm/cosq.h> 16 #include <sal/sal_types.h> 17 18 /* 19 * port map information. 20 */ 21 typedef struct bcmi_ltsw_cosq_port_map_info_s { 22 23 /* Physical port number. */ 24 int phy_port; 25 26 /* Pipe number. */ 27 int pipe; 28 29 /* TM pipe-local port number. */ 30 int local_port; 31 32 /* 33 * TM sparse global port number. 34 * The discrete global port number to index ports within TM. 35 */ 36 int mmu_port; 37 38 /* 39 * TM compact global port number. 40 * The continuous global port number based on TM pipe-local port number and pipe offsets. 41 */ 42 int global_port; 43 44 /* Unicast queue number base. */ 45 int uc_base; 46 47 /* Number of Unicast Queues. */ 48 int num_uc_q; 49 50 /* Multicast queue number base. */ 51 int mc_base; 52 53 /* Number of Multicast Queues. */ 54 int num_mc_q; 55 56 } bcmi_ltsw_cosq_port_map_info_t; 57 58 /* 59 * Device specific TM information. 60 */ 61 typedef struct bcmi_ltsw_cosq_device_info_s { 62 63 /* Maximum packet size in bytes. */ 64 int max_pkt_byte; 65 66 /* Packet header size in bytes. */ 67 int mmu_hdr_byte; 68 69 /* Jumbo packet size in bytes. */ 70 int jumbo_pkt_size; 71 72 /* Default MTU size in bytes. */ 73 int default_mtu_size; 74 75 /* Number of Cells (TM buffer memory size). */ 76 int mmu_total_cell; 77 78 /* Size of single buffer cell in bytes. */ 79 int mmu_cell_size; 80 81 /* Number of supported port-pg instances. */ 82 int num_pg; 83 84 /* Number of supported service pools. */ 85 int num_service_pool; 86 87 /* 88 * Maximum number of unicast and multicast queues supported for 89 * non-cpu ports. 90 */ 91 int num_queue; 92 93 /* 94 * Maximum number of queues supported for the CPU port. 95 * The CPU port supports only multicast queues. 96 */ 97 int num_cpu_queue; 98 99 /* Number of pipes. */ 100 int num_pipe; 101 102 /* Number of itms. */ 103 int num_itm; 104 105 /* Number of schedler profile. */ 106 int num_sched_profile; 107 108 /* Number of internal priority */ 109 int num_int_pri; 110 111 /* Number of internal priority */ 112 int num_rqe_queue; 113 114 /* Number of scheduler node */ 115 int num_sched_node; 116 117 /* Number of uc queue for non-cpu port */ 118 int num_ucq; 119 120 /* Number of mc queue for non-cpu port */ 121 int num_mcq; 122 } bcmi_ltsw_cosq_device_info_t; 123 124 /* 125 * \brief Get port map information. 126 * 127 * \param [in] unit Unit number. 128 * \param [in] lport Logic port number. 129 * \param [out] info ltsw_cosq_port_map_info_t. 130 * 131 * \retval SHE_E_NONE No errors. 132 * \retval !SHR_E_NONE Failure. 133 */ 134 extern int 135 bcmi_ltsw_cosq_port_map_info_get(int unit, bcm_port_t lport, 136 bcmi_ltsw_cosq_port_map_info_t *info); 137 138 /* 139 * \brief Get device specific TM information. 140 * 141 * \param [in] unit Unit number. 142 * \param [out] info bcmi_ltsw_cosq_device_info_t. 143 * 144 * \retval SHR_E_NONE No errors. 145 * \retval !SHR_E_NONE Failure. 146 */ 147 extern int 148 bcmi_ltsw_cosq_device_info_get(int unit, bcmi_ltsw_cosq_device_info_t *info); 149 150 /* 151 * \brief Retrieve number UC&MC queue according to multcast queue mode. 152 * 153 * \param [in] unit Unit number. 154 * \param [out] num_ucq unicast queue number. 155 * \param [out] num_mcq multcast queue number. 156 * 157 * \retval SHR_E_NONE No errors. 158 * \retval !SHR_E_NONE Failure. 159 */ 160 extern int 161 bcmi_ltsw_cosq_num_queue_get(int unit, int *num_ucq, int *num_mcq); 162 163 /* 164 * \brief Resolve GPORT if it is a local port. 165 * 166 * \param [in] unit Unit number. 167 * \param [in] gport GPORT identifier. 168 * \param [out] local_port local port number. 169 * 170 * \retval SHE_E_NONE No errors. 171 * \retval !SHR_E_NONE Failure. 172 */ 173 extern int 174 bcmi_ltsw_cosq_localport_resolve(int unit, bcm_gport_t gport, 175 bcm_port_t *local_port); 176 177 /* 178 * \brief Get port number and queue or scheduler identifier for the specified GPORT . 179 * 180 * \param [in] unit Unit number. 181 * \param [in] gport GPORT identifier 182 * \param [out] port Port number 183 * \param [out] id Queue or scheduler identifier. 184 * 185 * \retval SHR_E_NONE No errors. 186 * \retval !SHR_E_NONE Failure. 187 */ 188 extern int 189 bcmi_ltsw_cosq_gport_port_resolve(int unit, bcm_gport_t gport, 190 bcm_port_t *port, int *id); 191 192 /*! 193 * \brief Validate input parameters of ingress threshold. 194 * 195 * \param [in] unit Unit number. 196 * \param [in] port port ID. 197 * \param [in/out] itm itm. 198 * 199 * \retval SHR_E_NONE No errors. 200 * \retval !SHR_E_NONE Failure. 201 */ 202 extern int 203 bcmi_ltsw_cosq_port_itm_validate(int unit, int port, int *itm); 204 205 /* 206 * \brief Displays COS Queue information maintained by software. 207 * 208 * \param [in] unit Unit number. 209 * 210 * \retval SHE_E_NONE No errors. 211 * \retval !SHR_E_NONE Failure. 212 */ 213 extern void 214 bcmi_ltsw_cosq_sw_dump(int unit); 215 216 /* 217 * \brief COS queue bandwidth control bucket setting. 218 * If port is any form of local port, cosq is the hardware queue index. 219 * 220 * \param [in] unit Unit number. 221 * \param [in] gport Port number or GPORT identifier. 222 * \param [in] cosq COS queue number. 223 * \param [in] min_quantum kbps or packet/second. 224 * \param [in] max_quantum kbps or packet/second. 225 * \param [in] burst_size_auto Enables automatic calculation of burst size. 226 * \param [in] kbits_burst_min Configured size of maximum burst traffic. 227 * \param [in] kbits_burst_max Configured size of maximum burst traffic. 228 * \param [in] flags flags. 229 * 230 * \retval SHE_E_NONE No errors. 231 * \retval !SHR_E_NONE Failure. 232 */ 233 extern int 234 bcmi_ltsw_cosq_bucket_set(int unit, bcm_port_t gport, bcm_cos_queue_t cosq, 235 uint32_t min_quantum, uint32_t max_quantum, bool burst_size_auto, 236 uint32_t kbits_burst_min, uint32_t kbits_burst_max, 237 uint32_t flags); 238 239 /* 240 * \brief Get COS queue bandwidth control bucket setting. 241 * If port is any form of local port, cosq is the hardware queue index. 242 * 243 * \param [in] unit Unit number. 244 * \param [in] gport Port number or GPORT identifier. 245 * \param [in] cosq COS queue number. 246 * \param [out] min_quantum kbps or packet/second. 247 * \param [in] max_quantum kbps or packet/second. 248 * \param [out] burst_size_auto Enables automatic calculation of burst size. 249 * \param [out] kbits_burst_min Configured size of maximum burst traffic. 250 * \param [out] kbits_burst_max Configured size of maximum burst traffic. 251 * \param [out] flags flags. 252 * 253 * \retval SHE_E_NONE No errors. 254 * \retval !SHR_E_NONE Failure. 255 */ 256 extern int 257 bcmi_ltsw_cosq_bucket_get(int unit, bcm_port_t gport, bcm_cos_queue_t cosq, 258 uint32_t *min_quantum, uint32_t *max_quantum, bool burst_size_auto, 259 uint32_t *kbits_burst_min, uint32_t *kbits_burst_max, 260 uint32_t *flags); 261 262 /* 263 * \brief Get number of COSQs configured for this port. 264 * 265 * \param [in] unit Unit number. 266 * \param [in] port Local port. 267 * 268 * \retval Per port cos num. 269 */ 270 extern int 271 bcmi_ltsw_cosq_port_num_cos(int unit, int port); 272 273 /* 274 * \brief Get Function to return the number of child nodes and child node gport 275 * array for scheduler gport. 276 * 277 * \param [in] unit Unit number. 278 * \param [in] sched_gport scheduler gport. 279 * \param [out] num_uc_child number of uc child. 280 * \param [out] uc_queue uc queue array. 281 * \param [out] num_mc_child number of mc child. 282 * \param [out] mc_queue mc queue array. 283 * 284 * \retval Per port cos num. 285 */ 286 extern int 287 bcmi_ltsw_cosq_sched_node_child_get(int unit, bcm_gport_t sched_gport, 288 int *num_uc_child, int *uc_queue, 289 int *num_mc_child, int *mc_queue); 290 291 /* Shaper refresh timer. */ 292 typedef enum bcmi_ltsw_sharper_refresh_time_e { 293 REFRESH_TIME_INVALID = -1, 294 /* Refresh time 3.90625 us. */ 295 REFRESH_TIME_3_90625_US = 0, 296 /* Refresh time 7.8125 us. */ 297 REFRESH_TIME_7_8125_US = 1 298 } bcmi_ltsw_sharper_refresh_time_t; 299 300 /* 301 * \brief Get device-level shaper configuration properties. 302 * 303 * \param [in] unit Unit Number. 304 * \param [out] refresh_time Refresh time. NULL to ignore. 305 * \param [out] itu_mode Itu mode status. NULL to ignore 306 * \param [out] shaper Shaper status. NULL to ignore 307 * 308 * \retval SHR_E_NONE No errors. 309 * \retval !SHR_E_NONE Failure. 310 */ 311 extern int 312 bcmi_ltsw_cosq_shaper_config_get( 313 int unit, 314 bcmi_ltsw_sharper_refresh_time_t *refresh_time, 315 int *itu_mode, 316 int *shaper); 317 318 /* 319 * \brief Clear cosq configuration of port. 320 * 321 * \param [in] unit Unit Number. 322 * \param [in] port Logical port ID. 323 * 324 * \retval SHR_E_NONE No errors. 325 * \retval !SHR_E_NONE Failure. 326 */ 327 extern int 328 bcmi_ltsw_cosq_port_detach(int unit, bcm_port_t port); 329 330 /* 331 * \brief Initialize Cosq for newly added port. 332 * 333 * \param [in] unit Unit Number. 334 * \param [in] port Logical port ID. 335 * 336 * \retval SHR_E_NONE No errors. 337 * \retval !SHR_E_NONE Failure. 338 */ 339 extern int 340 bcmi_ltsw_cosq_port_attach(int unit, bcm_port_t port); 341 342 /* 343 * \brief Enable to use multicast COS from mirroring. 344 * 345 * \param [in] unit Unit Number. 346 * \param [in] enable Enable 347 * 348 * \retval SHR_E_NONE No errors. 349 * \retval !SHR_E_NONE Failure. 350 */ 351 extern int 352 bcmi_ltsw_cosq_mc_cos_mirror_set( 353 int unit, 354 int enable); 355 356 /* 357 * \brief Enable to use multicast COS from mirroring. 358 * 359 * \param [in] unit Unit Number. 360 * \param [out] enable Enable status 361 * 362 * \retval SHR_E_NONE No errors. 363 * \retval !SHR_E_NONE Failure. 364 */ 365 extern int 366 bcmi_ltsw_cosq_mc_cos_mirror_get( 367 int unit, 368 int *enable); 369 370 /* 371 * \brief Set cut-through mode for a specific port 372 * 373 * \param [in] unit Unit Number. 374 * \param [in] port Port Number. 375 * \param [in] enable Enable to use cut-through mode. 376 * 377 * \retval SHR_E_NONE No errors. 378 * \retval !SHR_E_NONE Failure. 379 */ 380 extern int 381 bcmi_ltsw_port_ct_mode_set( 382 int unit, 383 bcm_port_t port, 384 int enable); 385 386 /* 387 * \brief Get cut-through mode for a specific port 388 * 389 * \param [in] unit Unit Number. 390 * \param [in] port Port Number. 391 * \param [out] enable Enable to use cut-through mode. 392 * 393 * \retval SHR_E_NONE No errors. 394 * \retval !SHR_E_NONE Failure. 395 */ 396 extern int 397 bcmi_ltsw_port_ct_mode_get( 398 int unit, 399 bcm_port_t port, 400 int *enable); 401 402 /* 403 * \brief Dump per-port asf configurations to diag Shell. 404 * 405 * \param [in] unit Unit number. 406 * \param [in] port Logical port number. 407 * \param [in] port_speed Port speed in MB/s. 408 * 409 * \retval SHR_E_NONE No errors. 410 * \retval !SHR_E_NONE Failure. 411 */ 412 extern int 413 bcmi_ltsw_port_asf_config_dump( 414 int unit, 415 bcm_port_t port, 416 int port_speed); 417 418 /* 419 * \brief Print per-port traffic forwarding mode in diag Shell. 420 * 421 * \param [in] unit Unit number. 422 * \param [in] port Logical port number. 423 * \param [in] port_speed Port speed in MB/s. 424 * 425 * \retval SHR_E_NONE No errors. 426 * \retval !SHR_E_NONE Failure. 427 */ 428 extern int 429 bcmi_ltsw_port_asf_config_show( 430 int unit, 431 bcm_port_t port, 432 int port_speed); 433 434 /* 435 * \brief Get the ifp cos map profile id from classifier id. 436 * 437 * \param [in] unit Unit number. 438 * \param [in] classifier_id Classifier ID. 439 * \param [out] flag BCM_COSQ_CLASSIFIER_NO_INT_PRI. 440 * \param [out] index ifp cos map profile id. 441 * 442 * \retval SHR_E_NONE No errors. 443 * \retval !SHR_E_NONE Failure. 444 */ 445 extern int 446 bcmi_ltsw_cosq_classifier_field_get( 447 int unit, 448 int classifier_id, 449 int *flag, 450 int *index); 451 452 /* 453 * \brief Set the classifier id for give ifp cos map profile id. 454 * 455 * \param [in] unit Unit number. 456 * \param [in] index ifp cos map profile id. 457 * \param [in] flag BCM_COSQ_CLASSIFIER_NO_INT_PRI. 458 * \param [out] classifier_id Classifier ID. 459 * 460 * \retval SHR_E_NONE No errors. 461 * \retval !SHR_E_NONE Failure. 462 */ 463 extern int 464 bcmi_ltsw_cosq_classifier_field_set( 465 int unit, 466 int index, 467 int flag, 468 int *classifier_id); 469 470 /* 471 * \brief Get the associated rx channel with a given cosq 472 * 473 * \param [in] unit Unit Number. 474 * \param [in] queue_id input queue id 475 * \param [in] chan_id channel index 476 * \param [out] enable enable state 477 * 478 * \retval SHR_E_NONE No errors. 479 * \retval !SHR_E_NONE Failure. 480 */ 481 extern int 482 bcmi_ltsw_rx_queue_channel_get( 483 int unit, 484 bcm_cos_queue_t queue_id, 485 bcm_rx_chan_t chan_id, 486 bool *enable); 487 488 /* 489 * \brief Assign a RX channel to a cosq 490 * 491 * \param [in] unit Unit Number. 492 * \param [in] queue_id input queue id 493 * \param [in] chan_id channel index 494 * \param [in] enable enable state 495 * 496 * \retval SHR_E_NONE No errors. 497 * \retval !SHR_E_NONE Failure. 498 */ 499 extern int 500 bcmi_ltsw_rx_queue_channel_set( 501 int unit, 502 bcm_cos_queue_t queue_id, 503 bcm_rx_chan_t chan_id, 504 bool enable); 505 506 /* 507 * \brief Tests whether the corresponding COS_BMP bit is set or not 508 * 509 * \param [in] unit Unit Number. 510 * \param [in] queue_id input queue id 511 * \param [in] chan_id channel index 512 * 513 * \retval SHR_E_NONE No errors. 514 * \retval !SHR_E_NONE Failure. 515 */ 516 extern int 517 bcmi_ltsw_rx_queue_channel_set_test( 518 int unit, 519 bcm_cos_queue_t queue_id, 520 bcm_rx_chan_t chan_id); 521 522 #endif /* BCMI_LTSW_COSQ_H */