cosq.c (12557B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: cosq.c 8 * Purpose: Manages common COSQ functions 9 */ 10 11 #include <sal/core/libc.h> 12 13 #include <soc/drv.h> 14 #include <soc/debug.h> 15 16 #include <bcm/port.h> 17 #include <bcm/cosq.h> 18 19 /* 20 * Function: 21 * bcm_cosq_gport_discard_t_init 22 * Purpose: 23 * Initialize the COSQ gport discard struct 24 * Parameters: 25 * discard - Pointer to the struct to be init'ed 26 */ 27 28 void 29 bcm_cosq_gport_discard_t_init(bcm_cosq_gport_discard_t *discard) 30 { 31 if (discard != NULL) { 32 sal_memset(discard, 0, sizeof(*discard)); 33 discard->refresh_time = 8; 34 } 35 } 36 37 /* 38 * Function: 39 * bcm_cosq_congestion_mapping_info_t_init 40 * Purpose: 41 * Initialize the COSQ congestion mapping struct 42 * Parameters: 43 * config - Pointer to the struct to be init'ed 44 */ 45 void 46 bcm_cosq_congestion_mapping_info_t_init(bcm_cosq_congestion_mapping_info_t *config) 47 { 48 if (config != NULL) { 49 sal_memset(config, 0, sizeof(*config)); 50 } 51 } 52 53 /* 54 * Function: 55 * bcm_cosq_classifier_t_init 56 * Purpose: 57 * Initialize the COSQ classifier struct 58 * Parameters: 59 * classifier - Pointer to the struct to be init'ed 60 */ 61 62 void 63 bcm_cosq_classifier_t_init(bcm_cosq_classifier_t *classifier) 64 { 65 if (classifier != NULL) { 66 sal_memset(classifier, 0, sizeof(*classifier)); 67 } 68 } 69 70 /* 71 * Function: 72 * bcm_cosq_congestion_info_t_init 73 * Purpose: 74 * Initialize the COSQ congestion struct 75 * Parameters: 76 * config - Pointer to the struct to be init'ed 77 */ 78 79 void 80 bcm_cosq_congestion_info_t_init(bcm_cosq_congestion_info_t *config) 81 { 82 if (config != NULL) { 83 sal_memset(config, 0, sizeof(*config)); 84 85 /* Setting the default values to -1 since the validation 86 * is done for -1 in all the related APIs. 87 */ 88 config->fabric_modid = -1; 89 config->fabric_port = -1; 90 config->dest_modid = -1; 91 config->dest_port = -1; 92 } 93 } 94 95 /* 96 * Function: 97 * bcm_cosq_bst_profile_t_init 98 * Purpose: 99 * Initialize a CoSQ BST profile structure. 100 * Parameters: 101 * profile - Pointer to the struct to be init'ed 102 */ 103 104 void 105 bcm_cosq_bst_profile_t_init(bcm_cosq_bst_profile_t *profile) 106 { 107 if (profile != NULL) { 108 sal_memset(profile, 0, sizeof(*profile)); 109 } 110 } 111 void 112 bcm_cosq_threshold_t_init(bcm_cosq_threshold_t *threshold) { 113 if (threshold != NULL) { 114 sal_memset(threshold, 0, sizeof(*threshold)); 115 threshold->valid = BCM_COSQ_THRESHOLD_VALID_DP | BCM_COSQ_THRESHOLD_VALID_VALUE; 116 } 117 } 118 119 /* 120 * Function: 121 * bcm_cosq_pfc_class_mapping_t_init 122 * Purpose: 123 * Initialize a PFC class mapping structure. 124 * Parameters: 125 * mapping - Pointer to the struct to be init'ed 126 */ 127 void 128 bcm_cosq_pfc_class_mapping_t_init(bcm_cosq_pfc_class_mapping_t *mapping) 129 { 130 int index = 0; 131 132 if (mapping == NULL) { 133 return; 134 } 135 136 sal_memset(mapping, 0, sizeof(*mapping)); 137 for (index = 0; index < BCM_COSQ_PFC_GPORT_COUNT; index++) { 138 mapping->gport_list[index] = BCM_GPORT_INVALID; 139 } 140 } 141 142 /* 143 * Function: 144 * bcm_cosq_safc_class_mapping_t_init 145 * Purpose: 146 * Initialize a SAFC class mapping structure. 147 * Parameters: 148 * mapping - Pointer to the struct to be init'ed 149 */ 150 void 151 bcm_cosq_safc_class_mapping_t_init(bcm_cosq_safc_class_mapping_t *mapping) 152 { 153 int index = 0; 154 155 if (mapping == NULL) { 156 return; 157 } 158 159 sal_memset(mapping, 0, sizeof(*mapping)); 160 for (index = 0; index < BCM_COSQ_SAFC_GPORT_COUNT; index++) { 161 mapping->gport_list[index] = BCM_GPORT_INVALID; 162 } 163 } 164 165 /* 166 * Function: 167 * bcm_cosq_service_pool_t_init 168 * Purpose: 169 * Initialize a COSQ service pool structure. 170 * Parameters: 171 * service_pool - Pointer to the struct to be init'ed 172 */ 173 174 void 175 bcm_cosq_service_pool_t_init(bcm_cosq_service_pool_t *service_pool) 176 { 177 if (service_pool != NULL) { 178 sal_memset(service_pool, 0, sizeof(*service_pool)); 179 } 180 } 181 182 /* 183 * Function: 184 * bcm_cosq_pfc_deadlock_config_t_init 185 * Purpose: 186 * Initialize a COSq PFC deadlock config structure. 187 * Parameters: 188 * config - Pointer to the struct to be init'ed 189 */ 190 void bcm_cosq_pfc_deadlock_config_t_init( 191 bcm_cosq_pfc_deadlock_config_t *config) 192 { 193 if (config != NULL) { 194 sal_memset(config, 0, sizeof(bcm_cosq_pfc_deadlock_config_t)); 195 } 196 } 197 198 /* 199 * Function: 200 * bcm_cosq_service_pool_t_init 201 * Purpose: 202 * Initialize a COSq PFC deadlock queue config structure. 203 * Parameters: 204 * queue_config - Pointer to the struct to be init'ed 205 */ 206 void bcm_cosq_pfc_deadlock_queue_config_t_init( 207 bcm_cosq_pfc_deadlock_queue_config_t *q_config) 208 { 209 if (q_config != NULL) { 210 sal_memset(q_config, 0, sizeof(bcm_cosq_pfc_deadlock_queue_config_t)); 211 } 212 } 213 214 /* 215 * Function: 216 * bcm_cosq_service_pool_t_init 217 * Purpose: 218 * Initialize a COSq PFC deadlock info structure. 219 * Parameters: 220 * info - Pointer to the struct to be init'ed 221 */ 222 void bcm_cosq_pfc_deadlock_info_t_init( 223 bcm_cosq_pfc_deadlock_info_t *pfc_deadlock_info) 224 { 225 if (pfc_deadlock_info != NULL) { 226 sal_memset(pfc_deadlock_info, 0, sizeof(bcm_cosq_pfc_deadlock_info_t)); 227 } 228 } 229 230 /* 231 * Function: 232 * bcm_cosq_delay_tolerance_preset_attr_t_init 233 * Purpose: 234 * Initialize preset attributes 235 * Parameters: 236 * preset_attr - Pointer to the struct to be init'ed 237 */ 238 void bcm_cosq_delay_tolerance_preset_attr_t_init( 239 bcm_cosq_delay_tolerance_preset_attr_t *preset_attr) 240 { 241 if (preset_attr != NULL) { 242 sal_memset(preset_attr, 0, sizeof(bcm_cosq_delay_tolerance_preset_attr_t)); 243 } 244 } 245 246 /* 247 * Function: 248 * bcm_cosq_tas_profile_t_init 249 * Purpose: 250 * Initialize a COSq TAS profile info structure. 251 * Parameters: 252 * profile - Pointer to the struct to be init'ed 253 */ 254 void bcm_cosq_tas_profile_t_init( 255 bcm_cosq_tas_profile_t *profile) 256 { 257 if (profile != NULL) { 258 sal_memset(profile, 0, sizeof(bcm_cosq_tas_profile_t)); 259 } 260 } 261 262 /* 263 * Function: 264 * bcm_cosq_tas_profile_status_t_init 265 * Purpose: 266 * Initialize a COSq TAS profile status structure. 267 * Parameters: 268 * profile - Pointer to the struct to be init'ed 269 */ 270 void bcm_cosq_tas_profile_status_t_init( 271 bcm_cosq_tas_profile_status_t *profile_status) 272 { 273 if (profile_status != NULL) { 274 sal_memset(profile_status, 0, sizeof(bcm_cosq_tas_profile_status_t)); 275 } 276 } 277 #if defined (INCLUDE_TCB) 278 /* 279 * Function: 280 * bcm_cosq_tcb_config_t_init 281 * Purpose: 282 * Initialize a tcb config info structure. 283 * Parameters: 284 * info - Pointer to the struct to be init'ed 285 */ 286 void bcm_cosq_tcb_config_t_init( 287 bcm_cosq_tcb_config_t *config_info) 288 { 289 if (config_info!= NULL) { 290 sal_memset(config_info, 0, sizeof(bcm_cosq_tcb_config_t)); 291 } 292 } 293 #endif 294 295 #if defined (INCLUDE_TCB) 296 /* 297 * Function: 298 * bcm_cosq_tcb_threshold_profile_t_init 299 * Purpose: 300 * Initialize a tcb config threshold profile structure. 301 * Parameters: 302 * threshold - Pointer to the struct to be init'ed 303 */ 304 void bcm_cosq_tcb_threshold_profile_t_init( 305 bcm_cosq_tcb_threshold_profile_t *threshold) 306 { 307 if (threshold != NULL) { 308 sal_memset(threshold, 0, sizeof(bcm_cosq_tcb_threshold_profile_t)); 309 } 310 } 311 #endif 312 313 /* 314 * Function: 315 * bcm_cosq_object_id_t_init 316 * Purpose: 317 * Initializes the bcm_cosq_object_id_t structure 318 * Parameters: 319 * id - Pointer to the struct to be init'ed 320 */ 321 void 322 bcm_cosq_object_id_t_init(bcm_cosq_object_id_t *id) 323 { 324 if (id != NULL) { 325 sal_memset(id, 0, sizeof(bcm_cosq_object_id_t)); 326 id->port = BCM_GPORT_INVALID; 327 id->cosq = BCM_COS_INVALID; 328 id->buffer = BCM_COSQ_BUFFER_ID_INVALID; 329 } 330 } 331 332 /* 333 * Function: 334 * bcm_cosq_control_data_t_init 335 * Purpose: 336 * Initializes the bcm_cosq_control_data_t structure 337 * Parameters: 338 * id - Pointer to the struct to be init'ed 339 */ 340 void 341 bcm_cosq_control_data_t_init(bcm_cosq_control_data_t *control) 342 { 343 if (control != NULL) { 344 sal_memset(control, 0, sizeof(bcm_cosq_control_data_t)); 345 } 346 } 347 348 /* 349 * Function: 350 * bcm_cosq_mapping_t_init 351 * Purpose: 352 * Initializes the bcm_cosq_mapping_t structure 353 * Parameters: 354 * id - Pointer to the struct to be init'ed 355 */ 356 void 357 bcm_cosq_mapping_t_init(bcm_cosq_mapping_t *control) 358 { 359 if (control != NULL) { 360 sal_memset(control, 0, sizeof(bcm_cosq_mapping_t)); 361 } 362 } 363 364 /* 365 * Function: 366 * bcm_cosq_ingress_drop_control_frame_config_t_init 367 * Purpose: 368 * Initialize a bcm_cosq_ingress_drop_control_frame_config_t structure. 369 * Parameters: 370 * config - Pointer to the struct to be init'ed 371 */ 372 void bcm_cosq_ingress_drop_control_frame_config_t_init( 373 bcm_cosq_ingress_drop_control_frame_config_t *config) 374 { 375 if (config != NULL) { 376 sal_memset(config, 0, sizeof(bcm_cosq_ingress_drop_control_frame_config_t)); 377 } 378 } 379 380 /* 381 * Function: 382 * bcm_cosq_ingress_drop_flex_key_construct_id_t_init 383 * Purpose: 384 * Initialize a bcm_cosq_ingress_drop_flex_key_construct_id_t structure. 385 * Parameters: 386 * config - Pointer to the struct to be init'ed 387 */ 388 void bcm_cosq_ingress_drop_flex_key_construct_id_t_init( 389 bcm_cosq_ingress_drop_flex_key_construct_id_t *config) 390 { 391 if (config != NULL) { 392 sal_memset(config, 0, sizeof(bcm_cosq_ingress_drop_flex_key_construct_id_t)); 393 } 394 } 395 396 /* 397 * Function: 398 * bcm_cosq_ingress_drop_flex_key_construct_t_init 399 * Purpose: 400 * Initialize a bcm_cosq_ingress_drop_flex_key_construct_t structure. 401 * Parameters: 402 * config - Pointer to the struct to be init'ed 403 */ 404 void bcm_cosq_ingress_drop_flex_key_construct_t_init( 405 bcm_cosq_ingress_drop_flex_key_construct_t *config) 406 { 407 if (config != NULL) { 408 sal_memset(config, 0, sizeof(bcm_cosq_ingress_drop_flex_key_construct_t)); 409 config->ether_type_header_size = -1; 410 } 411 } 412 413 /* 414 * Function: 415 * bcm_cosq_ingress_drop_flex_key_t_init 416 * Purpose: 417 * Initialize a bcm_cosq_ingress_drop_flex_key_t structure. 418 * Parameters: 419 * config - Pointer to the struct to be init'ed 420 */ 421 void bcm_cosq_ingress_drop_flex_key_t_init( 422 bcm_cosq_ingress_drop_flex_key_t *config) 423 { 424 if (config != NULL) { 425 sal_memset(config, 0, sizeof(bcm_cosq_ingress_drop_flex_key_t)); 426 } 427 } 428 429 430 /* 431 * Function: 432 * bcm_cosq_ingress_drop_flex_key_entry_t_init 433 * Purpose: 434 * Initialize a bcm_cosq_ingress_drop_flex_key_entry_t structure. 435 * Parameters: 436 * config - Pointer to the struct to be init'ed 437 */ 438 void bcm_cosq_ingress_drop_flex_key_entry_t_init( 439 bcm_cosq_ingress_drop_flex_key_entry_t *config) 440 { 441 if (config != NULL) { 442 sal_memset(config, 0, sizeof(bcm_cosq_ingress_drop_flex_key_entry_t)); 443 } 444 } 445 446 /* 447 * Function: 448 * bcm_cosq_fadt_info_t_init 449 * Purpose: 450 * Initialize a bcm_cosq_fadt_info_t structure. 451 * Parameters: 452 * info - Pointer to the struct to be init'ed 453 */ 454 void bcm_cosq_fadt_info_t_init( 455 bcm_cosq_fadt_info_t* info) 456 { 457 if (info != NULL) { 458 sal_memset(info, 0, sizeof(bcm_cosq_fadt_info_t)); 459 } 460 } 461 462 /* 463 * Function: 464 * bcm_cosq_pfc_class_map_config_t_init 465 * Purpose: 466 * Initialize a bcm_cosq_pfc_class_map_config_t structure. 467 * Parameters: 468 * config - Pointer to the struct to be init'ed 469 */ 470 void bcm_cosq_pfc_class_map_config_t_init( 471 bcm_cosq_pfc_class_map_config_t* config) 472 { 473 if (config != NULL) { 474 sal_memset(config, 0, sizeof(bcm_cosq_pfc_class_map_config_t)); 475 } 476 } 477 478 479 void bcm_cosq_ingress_port_drop_mpls_special_label_config_t_init( bcm_cosq_ingress_port_drop_mpls_special_label_config_t* config) { 480 if (config != NULL) { 481 sal_memset(config, 0, sizeof(bcm_cosq_ingress_port_drop_mpls_special_label_config_t)); 482 } 483 } 484 485 /* 486 * Function: 487 * bcm_cosq_discard_rule_t_init 488 * Purpose: 489 * Initialize the COSQ discard rule struct 490 * Parameters: 491 * rule - Pointer to the struct to be init'ed 492 */ 493 494 void 495 bcm_cosq_discard_rule_t_init(bcm_cosq_discard_rule_t *rule) 496 { 497 if (rule != NULL) { 498 sal_memset(rule, 0, sizeof(*rule)); 499 } 500 } 501 502 /* 503 * Function: 504 * bcm_cosq_gport_level_info_t_init 505 * Purpose: 506 * Initialize cosq gport info structure. 507 * Parameters: 508 * info - Pointer to the struct to be init'ed 509 */ 510 void bcm_cosq_gport_level_info_t_init( 511 bcm_cosq_gport_level_info_t *info) 512 { 513 if (info != NULL) { 514 sal_memset(info, 0, sizeof(bcm_cosq_gport_level_info_t)); 515 } 516 }