Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * <:copyright-BRCM:2016:DUAL/GPL:standard |
| 4 | * |
| 5 | * Copyright (c) 2016 Broadcom |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * Unless you and Broadcom execute a separate written software license |
| 9 | * agreement governing use of this software, this software is licensed |
| 10 | * to you under the terms of the GNU General Public License version 2 |
| 11 | * (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 12 | * with the following added to such license: |
| 13 | * |
| 14 | * As a special exception, the copyright holders of this software give |
| 15 | * you permission to link this software with independent modules, and |
| 16 | * to copy and distribute the resulting executable under terms of your |
| 17 | * choice, provided that you also meet, for each linked independent |
| 18 | * module, the terms and conditions of the license of that module. |
| 19 | * An independent module is a module which is not derived from this |
| 20 | * software. The special exception does not apply to any modifications |
| 21 | * of the software. |
| 22 | * |
| 23 | * Not withstanding the above, under no circumstances may you combine |
| 24 | * this software in any way with any other Broadcom software provided |
| 25 | * under a license other than the GPL, without Broadcom's express prior |
| 26 | * written consent. |
| 27 | * |
| 28 | * :> |
| 29 | * |
| 30 | *****************************************************************************/ |
| 31 | |
| 32 | /** |
| 33 | * @file tm_queue_fsm.c |
| 34 | * @brief Code to support the BAL tm_queue FSM |
| 35 | * |
| 36 | * |
| 37 | */ |
| 38 | |
| 39 | /*@{*/ |
| 40 | |
| 41 | #include <bcmos_system.h> |
| 42 | #include <tm_queue_fsm.h> |
| 43 | #include <bal_msg.h> |
| 44 | #include <bal_osmsg.h> |
| 45 | #include "bal_worker.h" |
| 46 | #include "bal_mac_util.h" |
| 47 | #include "bal_switch_util.h" |
| 48 | #include "rsc_mgr.h" |
| 49 | |
| 50 | #include <bal_objs.h> |
| 51 | #include <fsm_common.h> |
| 52 | |
| 53 | #ifdef ENABLE_LOG |
| 54 | #include <bcm_dev_log.h> |
| 55 | |
| 56 | /* |
| 57 | * @brief The logging device id for tm queue |
| 58 | */ |
| 59 | static dev_log_id log_id_tm_queue; |
| 60 | #endif |
| 61 | |
| 62 | /* local function declarations */ |
| 63 | |
| 64 | static bcmos_errno tm_queue_free_by_entry(tm_queue_inst *p_entry); |
| 65 | static bcmos_errno tm_queue_fsm_state_err(tm_queue_inst *p_tm_queue_inst, void *msg, tm_queue_fsm_event *p_event); |
| 66 | static void tm_queue_inst_entry_obj_init(tm_queue_inst *p_entry); |
| 67 | |
| 68 | /* |
| 69 | * @brief The Global tm_queue fsm context data structure |
| 70 | */ |
| 71 | static tm_queue_fsm_ctx g_tm_queue_fsm_tm_queue_list_ctx; |
| 72 | |
| 73 | /* |
| 74 | * Macros for tm_queue ctx access |
| 75 | */ |
| 76 | #define TM_QUEUE_FSM_TM_QUEUE_LIST_CTX (g_tm_queue_fsm_tm_queue_list_ctx) |
| 77 | #define TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR (&g_tm_queue_fsm_tm_queue_list_ctx) |
| 78 | |
| 79 | |
| 80 | /* |
| 81 | * @brief The definition of a tm_queue FSM state processing function |
| 82 | */ |
| 83 | typedef bcmos_errno (* tm_queue_fsm_state_processor)(tm_queue_inst *, void *, tm_queue_fsm_event *); |
| 84 | static bcmos_errno bcmbal_tm_queue_create(tm_queue_inst *p_tm_queue_inst, |
| 85 | void *msg, |
| 86 | tm_queue_fsm_event *p_event); |
| 87 | |
| 88 | static bcmos_errno bcmbal_tm_queue_active_destroy (tm_queue_inst *p_tm_queue_inst, |
| 89 | void *msg, |
| 90 | tm_queue_fsm_event *p_event); |
| 91 | static bcmos_errno bcmbal_tm_queue_inactive_destroy(tm_queue_inst *p_tm_queue_inst, |
| 92 | void *msg, |
| 93 | tm_queue_fsm_event *p_event); |
| 94 | |
| 95 | |
| 96 | static tm_queue_fsm_state_processor tm_queue_states[TM_QUEUE_FSM_STATE__NUM_OF][TM_QUEUE_FSM_EVENT_TYPE__NUM_OF] = |
| 97 | { |
| 98 | [TM_QUEUE_FSM_STATE_NULL] = |
| 99 | { |
| 100 | [TM_QUEUE_FSM_EVENT_TYPE_CREATE] = bcmbal_tm_queue_create, |
| 101 | }, |
| 102 | [TM_QUEUE_FSM_STATE_INACTIVE] = |
| 103 | { |
| 104 | [TM_QUEUE_FSM_EVENT_TYPE_DESTROY] = bcmbal_tm_queue_inactive_destroy, |
| 105 | }, |
| 106 | [TM_QUEUE_FSM_STATE_ACTIVE] = |
| 107 | { |
| 108 | [TM_QUEUE_FSM_EVENT_TYPE_DESTROY] = bcmbal_tm_queue_active_destroy, |
| 109 | }, |
| 110 | |
| 111 | }; |
| 112 | |
| 113 | static char *state_name_str[] = |
| 114 | { |
| 115 | "TM_QUEUE_FSM_STATE_NULL", |
| 116 | "TM_QUEUE_FSM_STATE_INACTIVE", |
| 117 | "TM_QUEUE_FSM_STATE_ACTIVE", |
| 118 | "TM_QUEUE_FSM_STATE_IN_USE", |
| 119 | "TM_QUEUE_FSM_STATE_DELETING", |
| 120 | }; |
| 121 | |
| 122 | /* Ensure that the name array size matches the associated enum */ |
| 123 | BAL_STATIC_ASSERT(TM_QUEUE_FSM_STATE__LAST == (sizeof (state_name_str) / sizeof (char *)), tm_queue_fsm_state); |
| 124 | |
| 125 | static char *tm_queue_state_name_get(tm_queue_fsm_state state) |
| 126 | { |
| 127 | if(state < TM_QUEUE_FSM_STATE__LAST) |
| 128 | { |
| 129 | return state_name_str[state]; |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | return "TM_QUEUE_UNKNOWN"; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | static char *event_name_str[] = |
| 138 | { |
| 139 | "TM_QUEUE_FSM_CREATE_EVENT", |
| 140 | "TM_QUEUE_FSM_DESTROY_EVENT", |
| 141 | "FLOW_FSM_UTIL_MSG_EVENT", |
| 142 | }; |
| 143 | |
| 144 | /* Ensure that the name array size matches the associated enum */ |
| 145 | BAL_STATIC_ASSERT(TM_QUEUE_FSM_EVENT_TYPE__LAST == (sizeof (event_name_str) / sizeof (char *)), tm_queue_fsm_event_type); |
| 146 | |
| 147 | static char *tm_queue_event_name_get(tm_queue_fsm_event_type event) |
| 148 | { |
| 149 | if(event < TM_QUEUE_FSM_EVENT_TYPE__LAST) |
| 150 | { |
| 151 | return event_name_str[event]; |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | return "TM_QUEUE_EVT_UNKNOWN"; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | /*****************************************************************************/ |
| 160 | /** |
| 161 | * @brief The Tm queue FSM function which is executed when an error |
| 162 | * is encountered during FSM processing. |
| 163 | * |
| 164 | * @param p_tm_queue_inst Pointer to a tm_queue instance |
| 165 | * @param msg Pointer to a BAL message received from one of |
| 166 | * the BAL apps. |
| 167 | * @param p_event Pointer to a tm_queue event structure |
| 168 | * |
| 169 | * @returns bcmos_errno |
| 170 | *****************************************************************************/ |
| 171 | static bcmos_errno tm_queue_fsm_state_err(tm_queue_inst *p_tm_queue_inst, |
| 172 | void *msg, |
| 173 | tm_queue_fsm_event *p_event) |
| 174 | { |
| 175 | bcmos_errno ret = BCM_ERR_INVALID_OP; |
| 176 | |
| 177 | BCM_LOG(DEBUG, log_id_tm_queue, |
| 178 | "Error encountered processing TM_queue FSM" |
| 179 | " - BAD EVENT ()\n"); |
| 180 | |
| 181 | return ret; |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /*****************************************************************************/ |
| 186 | /** |
| 187 | * @brief A function to initialize the Tm Queue FSM infrastructure. |
| 188 | * |
| 189 | * NOTE: This is called once on startup and NOT for each FSM instance. |
| 190 | * |
| 191 | * @returns bcmos_errno |
| 192 | *****************************************************************************/ |
| 193 | bcmos_errno tm_queue_fsm_init(void) |
| 194 | { |
| 195 | int ii; |
| 196 | tm_queue_inst *new_entry; |
| 197 | bcmos_errno ret = BCM_ERR_OK; |
| 198 | |
| 199 | #ifdef ENABLE_LOG |
| 200 | log_id_tm_queue = bcm_dev_log_id_register("TM_QUEUE", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH); |
| 201 | BUG_ON(log_id_tm_queue == DEV_LOG_INVALID_ID); |
| 202 | #endif |
| 203 | |
| 204 | /* Initialize all of the tm_queue queues */ |
| 205 | TAILQ_INIT(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->free_tm_queue_list); |
| 206 | TAILQ_INIT(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->active_tm_queue_list); |
| 207 | |
| 208 | /* Populate the free list with it's initial set of tm_queues |
| 209 | */ |
| 210 | for(ii=0; ii<TM_QUEUE_ALLOCATION_BLOCK_SIZE; ii++) |
| 211 | { |
| 212 | new_entry = bcmos_calloc(sizeof(tm_queue_inst)); |
| 213 | if(NULL == new_entry) |
| 214 | { |
| 215 | BCM_LOG(FATAL, log_id_tm_queue, "Failed to initialize the tm_queue free list - FATAL\n"); |
| 216 | ret = BCM_ERR_NOMEM; |
| 217 | break; |
| 218 | } |
| 219 | tm_queue_free_by_entry(new_entry); |
| 220 | } |
| 221 | return ret; |
| 222 | } |
| 223 | |
| 224 | /*****************************************************************************/ |
| 225 | /** |
| 226 | * @brief A function to un-initialize the Tm Queue FSM infrastructure. |
| 227 | * |
| 228 | * NOTE: This is called once on shutdown and NOT for each FSM instance. |
| 229 | * |
| 230 | * @returns bcmos_errno |
| 231 | *****************************************************************************/ |
| 232 | bcmos_errno tm_queue_fsm_finish(void) |
| 233 | { |
| 234 | |
| 235 | tm_queue_inst *current_entry, *p_temp_entry; |
| 236 | |
| 237 | /* Free all the entries on the active list */ |
| 238 | TAILQ_FOREACH_SAFE(current_entry, |
| 239 | &TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->active_tm_queue_list, |
| 240 | tm_queue_inst_next, |
| 241 | p_temp_entry) |
| 242 | { |
| 243 | /* Remove it from the active list */ |
| 244 | TAILQ_REMOVE(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->active_tm_queue_list, current_entry, tm_queue_inst_next); |
| 245 | |
| 246 | bcmos_free(current_entry); |
| 247 | |
| 248 | } |
| 249 | |
| 250 | /* Free all the entries on the free list */ |
| 251 | TAILQ_FOREACH_SAFE(current_entry, |
| 252 | &TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->free_tm_queue_list, |
| 253 | tm_queue_inst_next, |
| 254 | p_temp_entry) |
| 255 | { |
| 256 | /* Remove it from the active list */ |
| 257 | TAILQ_REMOVE(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->free_tm_queue_list, current_entry, tm_queue_inst_next); |
| 258 | |
| 259 | bcmos_free(current_entry); |
| 260 | } |
| 261 | |
| 262 | return BCM_ERR_OK; |
| 263 | } |
| 264 | |
| 265 | static void tm_queue_inst_entry_obj_init(tm_queue_inst *p_entry) |
| 266 | { |
| 267 | /* The actual key content is irrelevant for free tm_queues */ |
| 268 | bcmbal_tm_queue_key key = { .id = 0, .sched_id = 0, .sched_dir = BCMBAL_TM_SCHED_DIR_US}; |
| 269 | |
| 270 | /* And add it to the free list */ |
| 271 | p_entry->fsm_state = TM_QUEUE_FSM_STATE_NULL; |
| 272 | |
| 273 | BCMBAL_CFG_INIT(&p_entry->current_tm_queue_info, |
| 274 | tm_queue, |
| 275 | key); |
| 276 | |
| 277 | BCMBAL_OBJ_IN_PROGRESS_SET(&(p_entry->current_tm_queue_info), BCMOS_FALSE); |
| 278 | } |
| 279 | /*****************************************************************************/ |
| 280 | /** |
| 281 | * @brief A function to free a tm_queue instance specified by a the supplied |
| 282 | * entry pointer. |
| 283 | * |
| 284 | * @param p_entry A pointer to the entry to be freed |
| 285 | * |
| 286 | * |
| 287 | * @returns bcmos_errno |
| 288 | *****************************************************************************/ |
| 289 | static bcmos_errno tm_queue_free_by_entry(tm_queue_inst *p_entry) |
| 290 | { |
| 291 | bcmos_errno ret = BCM_ERR_OK; |
| 292 | tm_queue_inst *current_entry; |
| 293 | tm_queue_inst *p_temp_entry; |
| 294 | |
| 295 | /* |
| 296 | * First, check the active list (an active tm_queue can be in the adding or removing state) |
| 297 | */ |
| 298 | TAILQ_FOREACH_SAFE(current_entry, |
| 299 | &TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->active_tm_queue_list, |
| 300 | tm_queue_inst_next, |
| 301 | p_temp_entry) |
| 302 | { |
| 303 | if(current_entry == p_entry) |
| 304 | { |
| 305 | /* Remove it from the active list */ |
| 306 | TAILQ_REMOVE(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->active_tm_queue_list, current_entry, tm_queue_inst_next); |
| 307 | break; |
| 308 | } |
| 309 | } |
| 310 | tm_queue_inst_entry_obj_init(p_entry); |
| 311 | TAILQ_INSERT_TAIL(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->free_tm_queue_list, p_entry, tm_queue_inst_next); |
| 312 | |
| 313 | return ret; |
| 314 | } |
| 315 | |
| 316 | /*****************************************************************************/ |
| 317 | /** |
| 318 | * @brief The Tm queue FSM state processing executive function |
| 319 | * @param p_tm_queue_inst Pointer to a tm_queu instance |
| 320 | * @param p_event Pointer to a tm_Queue event structure |
| 321 | * |
| 322 | * @returns bcmos_errno |
| 323 | *****************************************************************************/ |
| 324 | static bcmos_errno tm_queue_fsm_exec(tm_queue_inst *p_tm_queue_inst, tm_queue_fsm_event *p_event) |
| 325 | { |
| 326 | bcmos_errno ret = BCM_ERR_OK; |
| 327 | tm_queue_fsm_state pre_state; |
| 328 | tm_queue_fsm_state_processor tm_queue_state_processor; |
| 329 | |
| 330 | /* Parameter checks */ |
| 331 | BUG_ON(NULL == p_tm_queue_inst); |
| 332 | BUG_ON(NULL == p_event); |
| 333 | |
| 334 | /* Record the present state for debug printing |
| 335 | */ |
| 336 | pre_state = p_tm_queue_inst->fsm_state; |
| 337 | |
| 338 | /* |
| 339 | * Get the state processing function |
| 340 | */ |
| 341 | tm_queue_state_processor = tm_queue_states[p_tm_queue_inst->fsm_state][p_event->event_type]; |
| 342 | |
| 343 | /* |
| 344 | * If there's a state processing function for this event and state, execute it. |
| 345 | * Otherwise, process a generic error. |
| 346 | */ |
| 347 | if(tm_queue_state_processor) |
| 348 | { |
| 349 | ret = tm_queue_state_processor(p_tm_queue_inst, p_event->msg, p_event); |
| 350 | } |
| 351 | else |
| 352 | { |
| 353 | tm_queue_fsm_state_err(p_tm_queue_inst, p_event->msg, p_event); |
| 354 | } |
| 355 | |
| 356 | if(BCM_ERR_OK != ret) |
| 357 | { |
| 358 | BCM_LOG(ERROR, log_id_tm_queue, "*** Error detected during state processing\n"); |
| 359 | p_tm_queue_inst->fsm_state = pre_state; |
| 360 | } |
| 361 | |
| 362 | BCM_LOG(DEBUG, log_id_tm_queue, "*** Event %s, State: %s --> %s\n\n", |
| 363 | tm_queue_event_name_get(p_event->event_type), |
| 364 | tm_queue_state_name_get(pre_state), |
| 365 | tm_queue_state_name_get(p_tm_queue_inst->fsm_state)); |
| 366 | |
| 367 | return ret; |
| 368 | } |
| 369 | |
| 370 | /*****************************************************************************/ |
| 371 | /** |
| 372 | * @brief A function to retrieve a tm_queue instance of the specified class. |
| 373 | * |
| 374 | * @param key A pointer to the key of the tm_queue being referenced |
| 375 | * @param search_flag A flag specifying the type of tm_queue |
| 376 | * instance to be retrieved |
| 377 | * |
| 378 | * @returns tm_queue_inst_t* A pointer to the found tm_queue instance, |
| 379 | * or NULL if one is not found |
| 380 | *****************************************************************************/ |
| 381 | tm_queue_inst *tm_queue_inst_get(bcmbal_tm_queue_key key, tm_queue_flag search_flag) |
| 382 | { |
| 383 | tm_queue_inst *current_entry = NULL; |
| 384 | |
| 385 | /* |
| 386 | * First, check the active list if the caller has chosen to do so |
| 387 | */ |
| 388 | if(TM_QUEUE_FLAG_ACTIVE & search_flag) |
| 389 | { |
| 390 | TAILQ_FOREACH(current_entry, |
| 391 | &TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->active_tm_queue_list, |
| 392 | tm_queue_inst_next) |
| 393 | { |
| 394 | |
| 395 | if(current_entry->api_req_tm_queue_info.key.id == key.id |
| 396 | && current_entry->api_req_tm_queue_info.key.sched_id == key.sched_id |
| 397 | && current_entry->api_req_tm_queue_info.key.sched_dir == key.sched_dir) |
| 398 | { |
| 399 | BCM_LOG(DEBUG, log_id_tm_queue, "Found active tm_queue\n"); |
| 400 | /* The tm_queue instance pointer is in current_entry */ |
| 401 | break; |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | /* |
| 406 | * Next, check the free list if the caller has chosen to do so |
| 407 | */ |
| 408 | if((TM_QUEUE_FLAG_FREE & search_flag) && (NULL == current_entry)) |
| 409 | { |
| 410 | /* Now check the free list */ |
| 411 | if(!TAILQ_EMPTY(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->free_tm_queue_list)) |
| 412 | { |
| 413 | /* Just grab the first entry */ |
| 414 | current_entry = TAILQ_FIRST(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->free_tm_queue_list); |
| 415 | |
| 416 | /* Remove it from the free list */ |
| 417 | TAILQ_REMOVE(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->free_tm_queue_list, current_entry, tm_queue_inst_next); |
| 418 | |
| 419 | /* And add it to the active list */ |
| 420 | TAILQ_INSERT_TAIL(&TM_QUEUE_FSM_TM_QUEUE_LIST_CTX_PTR->active_tm_queue_list, current_entry, tm_queue_inst_next); |
| 421 | |
| 422 | /* |
| 423 | * Initialize the fsm state |
| 424 | */ |
| 425 | current_entry->fsm_state = TM_QUEUE_FSM_STATE_NULL; |
| 426 | |
| 427 | BCM_LOG(DEBUG, log_id_tm_queue, "Using new tm_queue\n"); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | if((TM_QUEUE_FLAG_ANY & search_flag) && (NULL == current_entry)) |
| 432 | { |
| 433 | /*A tm_queue was not found on either list*/ |
| 434 | |
| 435 | BCM_LOG(DEBUG, log_id_tm_queue, "************** ERROR: no tm_queue found\n"); |
| 436 | } |
| 437 | |
| 438 | return current_entry; |
| 439 | } |
| 440 | |
| 441 | static bcmos_errno bcmbal_tm_queue_validate(bcmbal_tm_queue_cfg *p_tm_queue_cfg) |
| 442 | { |
| 443 | bcmos_errno ret = BCM_ERR_OK; |
| 444 | bcmbal_tm_sched_key tm_sched_key = {.id = p_tm_queue_cfg->key.sched_id, .dir = p_tm_queue_cfg->key.sched_dir}; |
| 445 | tm_sched_inst *p_tm_sched_inst = NULL; |
| 446 | do |
| 447 | { |
| 448 | /*get the tm sched instance*/ |
| 449 | p_tm_sched_inst = tm_sched_inst_get(tm_sched_key, TM_SCHED_FLAG_ACTIVE); |
| 450 | if(NULL == p_tm_sched_inst) |
| 451 | { |
| 452 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR: no related tm_sched found (id = %d dir = %s)\n", |
| 453 | tm_sched_key.id, TM_SCHED_DIR_TO_STR(tm_sched_key.dir)); |
| 454 | ret = BCM_ERR_NOENT; |
| 455 | break; |
| 456 | } |
| 457 | /*check it is not an agg port tm sched - as there are no queues to such node*/ |
| 458 | if(BCMBAL_CFG_PROP_IS_SET(&p_tm_sched_inst->req_tm_sched_info, tm_sched, owner)) |
| 459 | { |
| 460 | if(BCMBAL_TM_SCHED_OWNER_TYPE_AGG_PORT == p_tm_sched_inst->req_tm_sched_info.data.owner.type) |
| 461 | { |
| 462 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR: should not attach queue to node which is owned by agg port (id = %d dir = %s)\n", |
| 463 | tm_sched_key.id, TM_SCHED_DIR_TO_STR(tm_sched_key.dir)); |
| 464 | ret = BCM_ERR_PARM; |
| 465 | break; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | /*sched level should be 'queue'*/ |
| 470 | if(BCMBAL_TM_SCHED_CHILD_TYPE_QUEUE != p_tm_sched_inst->req_tm_sched_info.data.sched_child_type) |
| 471 | { |
| 472 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR: tm sched sched level is invalid (%d), should be BCMBAL_TM_SCHED_CHILD_TYPE_QUEUE\n", |
| 473 | p_tm_sched_inst->req_tm_sched_info.data.sched_child_type); |
| 474 | ret = BCM_ERR_PARM; |
| 475 | break; |
| 476 | } |
| 477 | |
| 478 | /*based on sched type, check priority / weight is set and is valid */ |
| 479 | if(BCMBAL_TM_SCHED_TYPE_SP == p_tm_sched_inst->req_tm_sched_info.data.sched_type) |
| 480 | { |
| 481 | if(!BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, priority)) |
| 482 | { |
| 483 | BCM_LOG(ERROR, log_id_tm_queue, "Queue must be set with a priority, as its scheduler' sched_type is sp\n"); |
| 484 | ret = BCM_ERR_PARM; |
| 485 | break; |
| 486 | } |
| 487 | if(BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, weight)) |
| 488 | { |
| 489 | BCM_LOG(ERROR, log_id_tm_queue, "Queue can not be set with a weight, as its scheduler' sched_type is sp\n"); |
| 490 | ret = BCM_ERR_PARM; |
| 491 | break; |
| 492 | } |
| 493 | if(p_tm_queue_cfg->data.priority >= p_tm_sched_inst->req_tm_sched_info.data.num_priorities) |
| 494 | { |
| 495 | BCM_LOG(ERROR, log_id_tm_queue, "Queue priority (%d) is higher than the allowed at parent scheduler (id = %d dir = %s num of priorities = %d )\n", |
| 496 | p_tm_queue_cfg->data.priority , tm_sched_key.id, TM_SCHED_DIR_TO_STR(tm_sched_key.dir), |
| 497 | p_tm_sched_inst->req_tm_sched_info.data.num_priorities); |
| 498 | |
| 499 | ret = BCM_ERR_PARM; |
| 500 | break; |
| 501 | } |
| 502 | } |
| 503 | else |
| 504 | if(BCMBAL_TM_SCHED_TYPE_WFQ == p_tm_sched_inst->req_tm_sched_info.data.sched_type) |
| 505 | { |
| 506 | if(!BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, weight)) |
| 507 | { |
| 508 | BCM_LOG(ERROR, log_id_tm_queue, "Queue must be set with a weight, as its scheduler' sched_type sched_type is wfq\n"); |
| 509 | ret = BCM_ERR_PARM; |
| 510 | break; |
| 511 | } |
| 512 | if(BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, priority)) |
| 513 | { |
| 514 | BCM_LOG(ERROR, log_id_tm_queue, "Queue can not be set with a priority, as its scheduler' sched_type sched_type is wfq \n"); |
| 515 | ret = BCM_ERR_PARM; |
| 516 | break; |
| 517 | } |
| 518 | } |
| 519 | else |
| 520 | if(BCMBAL_TM_SCHED_TYPE_SP_WFQ == p_tm_sched_inst->req_tm_sched_info.data.sched_type) |
| 521 | { |
| 522 | if(BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, priority) |
| 523 | && BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, weight)) |
| 524 | { |
| 525 | BCM_LOG(ERROR, log_id_tm_queue, "Queue must be set with either weight or priority, not both. as its scheduler' sched_type is sp_wfq\n"); |
| 526 | ret = BCM_ERR_PARM; |
| 527 | break; |
| 528 | } |
| 529 | if(!BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, priority) |
| 530 | && !BCMBAL_CFG_PROP_IS_SET(p_tm_queue_cfg, tm_queue, weight)) |
| 531 | { |
| 532 | BCM_LOG(ERROR, log_id_tm_queue, "Queue must be set with either weight or priority, as its scheduler' sched_type is sp_wfq\n"); |
| 533 | ret = BCM_ERR_PARM; |
| 534 | break; |
| 535 | } |
| 536 | } |
| 537 | }while(0); |
| 538 | return ret; |
| 539 | } |
| 540 | |
| 541 | /*****************************************************************************/ |
| 542 | /** |
| 543 | * @brief A function called by the core worker thread to process an |
| 544 | * tm_queue object message (SET, GET, CLEAR, STATS) received |
| 545 | * from the BAL Public API. |
| 546 | * |
| 547 | * @param msg_payload Pointer to a BAL message received from the |
| 548 | * BAL Public API. |
| 549 | * |
| 550 | * @returns bcmos_errno |
| 551 | *****************************************************************************/ |
| 552 | bcmos_errno process_tm_queue_object(void *msg_payload) |
| 553 | { |
| 554 | bcmos_errno ret = BCM_ERR_OK; |
| 555 | bcmbal_tm_queue_cfg *p_tm_queue_cfg = (bcmbal_tm_queue_cfg *)msg_payload; |
| 556 | tm_queue_inst *p_tm_queue_inst = NULL; |
| 557 | tm_queue_fsm_event fsm_event; |
| 558 | bcmbal_tm_queue_key tm_queue_key; |
| 559 | bcmbal_obj_msg_type oper_type; |
| 560 | bcmbal_tm_sched_key tm_sched_key; |
| 561 | tm_sched_inst *p_tm_sched_inst = NULL; |
| 562 | bcmbal_interface_key intf_key; |
| 563 | bcmbal_tm_sched_owner owner; |
| 564 | |
| 565 | BUG_ON(NULL == msg_payload); |
| 566 | |
| 567 | BCM_LOG(DEBUG, log_id_tm_queue, "Processing a tm queue object\n"); |
| 568 | |
| 569 | tm_queue_key = p_tm_queue_cfg->key; |
| 570 | oper_type = p_tm_queue_cfg->hdr.hdr.type; |
| 571 | |
| 572 | /* |
| 573 | * A message pointer may be passed inside the event structure. |
| 574 | */ |
| 575 | fsm_event.msg = msg_payload; |
| 576 | |
| 577 | /* SET or GET or CLEAR...? */ |
| 578 | switch(oper_type) |
| 579 | { |
| 580 | case(BCMBAL_OBJ_MSG_TYPE_SET): |
| 581 | { |
| 582 | do |
| 583 | { |
| 584 | BCM_LOG(DEBUG, log_id_tm_queue, "Processing a tm queue SET REQ mgmt message\n"); |
| 585 | if(BCMBAL_STATUS_UP != acc_term_status_get()) |
| 586 | { |
| 587 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR - Access-terminal is not UP. No further processing\n"); |
| 588 | ret = BCM_ERR_STATE; |
| 589 | break; |
| 590 | } |
| 591 | |
| 592 | /*Find the specified tm_queue instance is already created */ |
| 593 | p_tm_queue_inst = tm_queue_inst_get(tm_queue_key, TM_QUEUE_FLAG_ACTIVE); |
| 594 | |
| 595 | if(NULL != p_tm_queue_inst) |
| 596 | { |
| 597 | /* This is a fatal error condition */ |
| 598 | BCM_LOG(ERROR, log_id_tm_queue, |
| 599 | "ERROR - tm queue found. Set after create is currently not supported. No further processing\n"); |
| 600 | ret = BCM_ERR_NOT_SUPPORTED; |
| 601 | break; |
| 602 | } |
| 603 | |
| 604 | p_tm_queue_inst = tm_queue_inst_get(tm_queue_key, TM_QUEUE_FLAG_FREE); |
| 605 | if(NULL == p_tm_queue_inst ) |
| 606 | { |
| 607 | /* This is a fatal error condition */ |
| 608 | BCM_LOG(ERROR, log_id_tm_queue, |
| 609 | "ERROR - tm queue not found. No further processing\n"); |
| 610 | ret = BCM_ERR_NOMEM; |
| 611 | break; |
| 612 | } |
| 613 | if(BCM_ERR_OK != (ret = bcmbal_tm_queue_validate(p_tm_queue_cfg))) |
| 614 | { |
| 615 | BCM_LOG(ERROR, log_id_tm_queue, "tm_queue fsm validation Failed (%d)\n", ret); |
| 616 | tm_queue_free_by_entry(p_tm_queue_inst); |
| 617 | break; |
| 618 | } |
| 619 | |
| 620 | |
| 621 | /* Perform the validation check(s) that the utils require */ |
| 622 | if(BCM_ERR_OK != (ret = sw_util_tm_queue_validate(p_tm_queue_cfg))) |
| 623 | { |
| 624 | BCM_LOG(ERROR, log_id_tm_queue, "tm_queue switch validation Failed (%d)\n", ret); |
| 625 | tm_queue_free_by_entry(p_tm_queue_inst); |
| 626 | break; |
| 627 | } |
| 628 | |
| 629 | |
| 630 | |
| 631 | BCM_LOG(DEBUG, log_id_tm_queue, |
| 632 | "Creating a new tm queue\n"); |
| 633 | |
| 634 | }while(0); |
| 635 | |
| 636 | ret = mgmt_msg_send_balapi_rsp(ret, msg_payload, oper_type, log_id_tm_queue); |
| 637 | |
| 638 | if(BCM_ERR_OK != ret ) |
| 639 | { |
| 640 | break; |
| 641 | } |
| 642 | |
| 643 | BCMBAL_CFG_PROP_SET(p_tm_queue_cfg, tm_queue, creation_mode, BCMBAL_TM_CREATION_MODE_MANUAL); |
| 644 | |
| 645 | bcmbal_tm_queue_object_overlay(&p_tm_queue_inst->api_req_tm_queue_info, p_tm_queue_cfg); |
| 646 | |
| 647 | fsm_event.event_type = TM_QUEUE_FSM_EVENT_TYPE_CREATE; |
| 648 | fsm_event.msg = msg_payload; |
| 649 | ret = tm_queue_fsm_exec(p_tm_queue_inst,&fsm_event); |
| 650 | } |
| 651 | break; |
| 652 | |
| 653 | case(BCMBAL_OBJ_MSG_TYPE_GET): |
| 654 | { |
| 655 | BCM_LOG(DEBUG, log_id_tm_queue, "Processing a tm queue GET REQ mgmt message\n"); |
| 656 | if(BCMBAL_STATUS_UP != acc_term_status_get()) |
| 657 | { |
| 658 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR - Access-terminal is not UP. No further processing\n"); |
| 659 | ret = BCM_ERR_STATE; |
| 660 | } |
| 661 | else |
| 662 | { |
| 663 | /* Find the specified tm_queue instance */ |
| 664 | p_tm_queue_inst = tm_queue_inst_get(tm_queue_key, TM_QUEUE_FLAG_ACTIVE); |
| 665 | } |
| 666 | |
| 667 | if(NULL == p_tm_queue_inst) |
| 668 | { |
| 669 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR - Specified tm_queue (%d) not found\n", tm_queue_key.id); |
| 670 | ret = BCM_ERR_NOENT; |
| 671 | |
| 672 | } |
| 673 | else |
| 674 | { |
| 675 | /* We respond to the BAL public API backend with a result. We always |
| 676 | * send a complete msg_payload back to the API, but the data portion |
| 677 | * of the object is only relevant when a GET or GET-STATS has been requested */ |
| 678 | p_tm_queue_inst->api_req_tm_queue_info.hdr.hdr.comm_hdr = ((bcmbal_obj *)msg_payload)->comm_hdr; |
| 679 | *((bcmbal_tm_queue_cfg *)msg_payload) = p_tm_queue_inst->api_req_tm_queue_info; |
| 680 | } |
| 681 | mgmt_msg_send_balapi_rsp(ret, msg_payload, oper_type, log_id_tm_queue); |
| 682 | } |
| 683 | break; |
| 684 | |
| 685 | case(BCMBAL_OBJ_MSG_TYPE_CLEAR): |
| 686 | { |
| 687 | do |
| 688 | { |
| 689 | BCM_LOG(DEBUG, log_id_tm_queue, "Processing a tm queue CLEAR REQ mgmt message\n"); |
| 690 | if(BCMBAL_STATUS_UP != acc_term_status_get()) |
| 691 | { |
| 692 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR - Access-terminal is not UP. No further processing\n"); |
| 693 | ret = BCM_ERR_STATE; |
| 694 | break; |
| 695 | } |
| 696 | /* |
| 697 | * Find the specified tm_queue instance |
| 698 | */ |
| 699 | p_tm_queue_inst = tm_queue_inst_get(tm_queue_key, TM_QUEUE_FLAG_ACTIVE); |
| 700 | |
| 701 | if(NULL == p_tm_queue_inst) |
| 702 | { |
| 703 | BCM_LOG(ERROR, log_id_tm_queue, "Specified tm_queue not found on CLEAR\n"); |
| 704 | ret = BCM_ERR_NOENT; |
| 705 | break; |
| 706 | } |
| 707 | |
| 708 | |
| 709 | if(TM_QUEUE_FSM_STATE_IN_USE == p_tm_queue_inst->fsm_state) |
| 710 | { |
| 711 | BCM_LOG(ERROR, log_id_tm_queue, "Specified tm_queue is in use and can not be removed\n"); |
| 712 | ret = BCM_ERR_PARM; |
| 713 | break; |
| 714 | } |
| 715 | |
| 716 | /*TM_QUEUEs (either auto or manually created) that are associated with a TM_NODE with owner interface |
| 717 | may only be deleted when the associated interface is in the ADMIN-DOWN state*/ |
| 718 | tm_sched_key.id = tm_queue_key.sched_id; |
| 719 | tm_sched_key.dir = tm_queue_key.sched_dir; |
| 720 | |
| 721 | p_tm_sched_inst = tm_sched_inst_get(tm_sched_key, TM_SCHED_FLAG_ACTIVE); |
| 722 | if(NULL == p_tm_sched_inst) |
| 723 | { |
| 724 | BCM_LOG(ERROR, log_id_tm_queue, "ERROR: no related tm_sched found (id = %d dir = %s)\n", |
| 725 | tm_sched_key.id, TM_SCHED_DIR_TO_STR(tm_sched_key.dir)); |
| 726 | ret = BCM_ERR_NOENT; |
| 727 | break; |
| 728 | } |
| 729 | if(BCMBAL_CFG_PROP_IS_SET(&(p_tm_sched_inst->req_tm_sched_info), tm_sched, owner)) |
| 730 | { |
| 731 | owner = p_tm_sched_inst->req_tm_sched_info.data.owner; |
| 732 | switch(owner.type) |
| 733 | { |
| 734 | case BCMBAL_TM_SCHED_OWNER_TYPE_INTERFACE: |
| 735 | { |
| 736 | intf_key.intf_type = owner.u.interface.intf_type; |
| 737 | intf_key.intf_id = owner.u.interface.intf_id; |
| 738 | if(BCMBAL_STATUS_DOWN != bcmbal_interface_status_get(intf_key)) |
| 739 | { |
| 740 | BCM_LOG(ERROR, log_id_tm_queue, "Specified tm_queue is attached to sched that is owned by interface that is not admin down, and can be removed only when the associated interface is in the ADMIN-DOWN state\n"); |
| 741 | ret = BCM_ERR_PARM; |
| 742 | break; |
| 743 | } |
| 744 | } |
| 745 | break; |
| 746 | |
| 747 | default: |
| 748 | break; |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /*generate destroy event*/ |
| 753 | |
| 754 | fsm_event.event_type = TM_QUEUE_FSM_EVENT_TYPE_DESTROY; |
| 755 | fsm_event.msg = msg_payload; |
| 756 | ret = tm_queue_fsm_exec(p_tm_queue_inst,&fsm_event); |
| 757 | |
| 758 | }while(0); |
| 759 | mgmt_msg_send_balapi_rsp(ret, msg_payload, oper_type, log_id_tm_queue); |
| 760 | } |
| 761 | break; |
| 762 | |
| 763 | default: |
| 764 | { |
| 765 | BCM_LOG(ERROR, log_id_tm_queue, "Unsupported operation on tm queue object (%d)\n", oper_type ); |
| 766 | ret = BCM_ERR_NOT_SUPPORTED; |
| 767 | |
| 768 | /* We respond to the BAL public API backend with a result. We always |
| 769 | * send a complete msg_payload back to the API, but the data portion |
| 770 | * of the object is only relevant when a GET or GET-STATS has been requested. |
| 771 | */ |
| 772 | mgmt_msg_send_balapi_rsp(ret, msg_payload, oper_type, log_id_tm_queue); |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | BCM_LOG(DEBUG, log_id_tm_queue, "%s returns\n", __FUNCTION__); |
| 777 | return ret; |
| 778 | |
| 779 | } |
| 780 | |
| 781 | bcmos_errno bcmbal_tm_queue_auto_create(bcmbal_tm_queue_cfg cfg) |
| 782 | { |
| 783 | bcmos_errno ret = BCM_ERR_OK; |
| 784 | tm_queue_inst *p_tm_queue_inst = NULL; |
| 785 | do |
| 786 | { |
| 787 | /*Find a free tm_queue instance */ |
| 788 | p_tm_queue_inst = tm_queue_inst_get(cfg.key, TM_QUEUE_FLAG_FREE); |
| 789 | if(NULL == p_tm_queue_inst) |
| 790 | { |
| 791 | /* This is a fatal error condition*/ |
| 792 | BCM_LOG(ERROR, log_id_tm_queue,"ERROR - tm queue not found. No further processing\n"); |
| 793 | ret = BCM_ERR_NOMEM; |
| 794 | break; |
| 795 | } |
| 796 | p_tm_queue_inst->api_req_tm_queue_info = cfg; |
| 797 | ret = bcmbal_tm_queue_create(p_tm_queue_inst,NULL, NULL); |
| 798 | }while(0); |
| 799 | return ret; |
| 800 | } |
| 801 | |
| 802 | bcmos_errno bcmbal_tm_queue_activate(tm_queue_inst *p_tm_queue_inst) |
| 803 | { |
| 804 | bcmos_errno ret = BCM_ERR_OK; |
| 805 | do |
| 806 | { |
| 807 | |
| 808 | ret = sw_util_tm_queue_set(p_tm_queue_inst); |
| 809 | if(BCM_ERR_OK != ret) |
| 810 | { |
| 811 | BCM_LOG(ERROR, log_id_tm_queue, "queue could not be set by switch\n"); |
| 812 | break; |
| 813 | } |
| 814 | |
| 815 | p_tm_queue_inst->fsm_state = TM_QUEUE_FSM_STATE_ACTIVE; |
| 816 | /* The hardware has properly accepted the object info, so the request object becomes |
| 817 | * the current state. |
| 818 | */ |
| 819 | bcmbal_tm_queue_object_overlay(&p_tm_queue_inst->current_tm_queue_info, |
| 820 | &p_tm_queue_inst->api_req_tm_queue_info); |
| 821 | |
| 822 | }while(0); |
| 823 | return ret; |
| 824 | |
| 825 | } |
| 826 | |
| 827 | bcmos_errno bcmbal_tm_queue_deactivate(tm_queue_inst *p_tm_queue_inst) |
| 828 | { |
| 829 | bcmos_errno ret = BCM_ERR_OK; |
| 830 | |
| 831 | BUG_ON(NULL == p_tm_queue_inst); |
| 832 | |
| 833 | do |
| 834 | { |
| 835 | ret = sw_util_tm_queue_clear(p_tm_queue_inst); |
| 836 | if(BCM_ERR_OK != ret) |
| 837 | { |
| 838 | BCM_LOG(ERROR, log_id_tm_queue, "queue could not be set by switch\n"); |
| 839 | break; |
| 840 | } |
| 841 | p_tm_queue_inst->fsm_state = TM_QUEUE_FSM_STATE_INACTIVE; |
| 842 | }while(0); |
| 843 | return ret; |
| 844 | |
| 845 | } |
| 846 | static bcmos_errno bcmbal_tm_queue_create(tm_queue_inst *p_tm_queue_inst, |
| 847 | void *msg, |
| 848 | tm_queue_fsm_event *p_event) |
| 849 | { |
| 850 | bcmos_errno ret = BCM_ERR_OK; |
| 851 | do |
| 852 | { |
| 853 | p_tm_queue_inst->fsm_state = TM_QUEUE_FSM_STATE_INACTIVE; |
| 854 | |
| 855 | /*referenced tm sched exist for sure as it was already validated*/ |
| 856 | ret = bcmbal_tm_sched_set_queue(p_tm_queue_inst); |
| 857 | if(BCM_ERR_OK != ret) |
| 858 | { |
| 859 | BCM_LOG(ERROR, log_id_tm_queue, "queue could not be attched to node \n"); |
| 860 | break; |
| 861 | } |
| 862 | }while(0); |
| 863 | return ret; |
| 864 | |
| 865 | } |
| 866 | |
| 867 | bcmos_errno bcmbal_tm_queue_set_owner(bcmbal_tm_queue_key key) |
| 868 | { |
| 869 | bcmos_errno ret = BCM_ERR_OK; |
| 870 | tm_queue_inst *p_tm_queue_inst; |
| 871 | do |
| 872 | { |
| 873 | p_tm_queue_inst = tm_queue_inst_get(key,TM_QUEUE_FLAG_ACTIVE); |
| 874 | if(NULL == p_tm_queue_inst) |
| 875 | { |
| 876 | BCM_LOG(ERROR, log_id_tm_queue,"ERROR - tm queue not found. No further processing\n"); |
| 877 | ret = BCM_ERR_NOENT; |
| 878 | break; |
| 879 | } |
| 880 | ret = bcmbal_tm_queue_activate(p_tm_queue_inst); |
| 881 | }while(0); |
| 882 | return ret; |
| 883 | } |
| 884 | |
| 885 | bcmos_errno bcmbal_tm_queue_unset_owner(bcmbal_tm_queue_key key) |
| 886 | { |
| 887 | bcmos_errno ret = BCM_ERR_OK; |
| 888 | tm_queue_inst *p_tm_queue_inst; |
| 889 | do |
| 890 | { |
| 891 | p_tm_queue_inst = tm_queue_inst_get(key,TM_QUEUE_FLAG_ACTIVE); |
| 892 | if(NULL == p_tm_queue_inst) |
| 893 | { |
| 894 | BCM_LOG(ERROR, log_id_tm_queue,"ERROR - tm queue not found. No further processing\n"); |
| 895 | ret = BCM_ERR_NOENT; |
| 896 | break; |
| 897 | } |
| 898 | ret = bcmbal_tm_queue_deactivate(p_tm_queue_inst); |
| 899 | |
| 900 | }while(0); |
| 901 | |
| 902 | return ret; |
| 903 | } |
| 904 | |
| 905 | bcmos_errno bcmbal_tm_queue_use_set(tm_queue_inst *p_tm_queue_inst, bcmos_bool is_in_use) |
| 906 | { |
| 907 | bcmos_errno ret = BCM_ERR_OK; |
| 908 | |
| 909 | BUG_ON(NULL == p_tm_queue_inst); |
| 910 | if(is_in_use) |
| 911 | { |
| 912 | /*queue might already in requested state*/ |
| 913 | p_tm_queue_inst->fsm_state = TM_QUEUE_FSM_STATE_IN_USE; |
| 914 | p_tm_queue_inst->api_req_tm_queue_info.data.ref_count++; |
| 915 | } |
| 916 | else |
| 917 | { |
| 918 | if(p_tm_queue_inst->api_req_tm_queue_info.data.ref_count) |
| 919 | { |
| 920 | p_tm_queue_inst->api_req_tm_queue_info.data.ref_count--; |
| 921 | |
| 922 | if(0 == p_tm_queue_inst->api_req_tm_queue_info.data.ref_count) |
| 923 | { |
| 924 | p_tm_queue_inst->fsm_state = TM_QUEUE_FSM_STATE_ACTIVE; |
| 925 | } |
| 926 | } |
| 927 | else |
| 928 | { |
| 929 | BCM_LOG(ERROR, log_id_tm_queue, "queue (sched.id = %d sched.dir = %s queue.id = %d) could not be unset as no flows assign to it \n", p_tm_queue_inst->api_req_tm_queue_info.key.sched_id, TM_SCHED_DIR_TO_STR(p_tm_queue_inst->api_req_tm_queue_info.key.sched_dir), p_tm_queue_inst->api_req_tm_queue_info.key.id); |
| 930 | ret = BCM_ERR_INTERNAL; |
| 931 | } |
| 932 | } |
| 933 | return ret; |
| 934 | } |
| 935 | |
| 936 | bcmos_errno bcmbal_tm_queue_destroy(tm_queue_inst *p_tm_queue_inst, bcmos_bool remove_from_node) |
| 937 | { |
| 938 | bcmos_errno ret = BCM_ERR_OK; |
| 939 | do |
| 940 | { |
| 941 | p_tm_queue_inst->fsm_state = TM_QUEUE_FSM_STATE_DELETING; |
| 942 | if(remove_from_node) |
| 943 | { |
| 944 | ret = bcmbal_tm_sched_remove_queue(p_tm_queue_inst); |
| 945 | if(BCM_ERR_OK != ret) |
| 946 | { |
| 947 | BCM_LOG(ERROR, log_id_tm_queue, "queue could not be cleaared from its tm sched\n"); |
| 948 | break; |
| 949 | } |
| 950 | } |
| 951 | ret = tm_queue_free_by_entry(p_tm_queue_inst); |
| 952 | }while(0); |
| 953 | return ret; |
| 954 | } |
| 955 | |
| 956 | static bcmos_errno bcmbal_tm_queue_inactive_destroy(tm_queue_inst *p_tm_queue_inst, |
| 957 | void *msg, |
| 958 | tm_queue_fsm_event *p_event) |
| 959 | { |
| 960 | return bcmbal_tm_queue_destroy(p_tm_queue_inst, BCMOS_TRUE); |
| 961 | } |
| 962 | |
| 963 | static bcmos_errno bcmbal_tm_queue_active_destroy(tm_queue_inst *p_tm_queue_inst, |
| 964 | void *msg, |
| 965 | tm_queue_fsm_event *p_event) |
| 966 | { |
| 967 | bcmos_errno ret = BCM_ERR_OK; |
| 968 | do |
| 969 | { |
| 970 | p_tm_queue_inst->fsm_state = TM_QUEUE_FSM_STATE_DELETING; |
| 971 | ret = sw_util_tm_queue_clear(p_tm_queue_inst); |
| 972 | if(BCM_ERR_OK != ret) |
| 973 | { |
| 974 | BCM_LOG(ERROR, log_id_tm_queue, "queue could not be cleaared from the switch\n"); |
| 975 | break; |
| 976 | } |
| 977 | ret = bcmbal_tm_queue_inactive_destroy(p_tm_queue_inst, msg, p_event); |
| 978 | }while(0); |
| 979 | return ret; |
| 980 | } |
| 981 | /*@}*/ |