1 /* 2 * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include <scheduler_api.h> 20 #include <scheduler_core.h> 21 #include <qdf_atomic.h> 22 23 QDF_STATUS scheduler_disable(void) 24 { 25 struct scheduler_ctx *sched_ctx; 26 27 sched_debug("Disabling Scheduler"); 28 29 sched_ctx = scheduler_get_context(); 30 QDF_BUG(sched_ctx); 31 if (!sched_ctx) 32 return QDF_STATUS_E_INVAL; 33 34 /* send shutdown signal to scheduler thread */ 35 qdf_atomic_set_bit(MC_SHUTDOWN_EVENT_MASK, &sched_ctx->sch_event_flag); 36 qdf_atomic_set_bit(MC_POST_EVENT_MASK, &sched_ctx->sch_event_flag); 37 qdf_wake_up_interruptible(&sched_ctx->sch_wait_queue); 38 39 /* wait for scheduler thread to shutdown */ 40 qdf_wait_single_event(&sched_ctx->sch_shutdown, 0); 41 sched_ctx->sch_thread = NULL; 42 43 /* flush any unprocessed scheduler messages */ 44 scheduler_queues_flush(sched_ctx); 45 46 return QDF_STATUS_SUCCESS; 47 } 48 49 static inline void scheduler_watchdog_notify(struct scheduler_ctx *sched) 50 { 51 char symbol[QDF_SYMBOL_LEN]; 52 53 if (sched->watchdog_callback) 54 qdf_sprint_symbol(symbol, sched->watchdog_callback); 55 56 sched_err("WLAN_BUG_RCA: Callback %s (type 0x%x) exceeded its allotted time of %ds", 57 sched->watchdog_callback ? symbol : "<null>", 58 sched->watchdog_msg_type, SCHEDULER_WATCHDOG_TIMEOUT / 1000); 59 } 60 61 #ifdef CONFIG_SLUB_DEBUG_ON 62 static void scheduler_watchdog_timeout(void *arg) 63 { 64 struct scheduler_ctx *sched = arg; 65 66 scheduler_watchdog_notify(sched); 67 if (sched->sch_thread) 68 qdf_print_thread_trace(sched->sch_thread); 69 70 /* avoid crashing during shutdown */ 71 if (qdf_atomic_test_bit(MC_SHUTDOWN_EVENT_MASK, &sched->sch_event_flag)) 72 return; 73 74 QDF_DEBUG_PANIC("Going down for Scheduler Watchdog Bite!"); 75 } 76 #else 77 static void scheduler_watchdog_timeout(void *arg) 78 { 79 scheduler_watchdog_notify((struct scheduler_ctx *)arg); 80 } 81 #endif 82 83 QDF_STATUS scheduler_enable(void) 84 { 85 struct scheduler_ctx *sched_ctx; 86 87 sched_debug("Enabling Scheduler"); 88 89 sched_ctx = scheduler_get_context(); 90 QDF_BUG(sched_ctx); 91 if (!sched_ctx) 92 return QDF_STATUS_E_INVAL; 93 94 qdf_atomic_clear_bit(MC_SHUTDOWN_EVENT_MASK, 95 &sched_ctx->sch_event_flag); 96 qdf_atomic_clear_bit(MC_POST_EVENT_MASK, 97 &sched_ctx->sch_event_flag); 98 99 /* create the scheduler thread */ 100 sched_ctx->sch_thread = qdf_create_thread(scheduler_thread, sched_ctx, 101 "scheduler_thread"); 102 if (!sched_ctx->sch_thread) { 103 sched_err("Failed to create scheduler thread"); 104 return QDF_STATUS_E_RESOURCES; 105 } 106 107 sched_debug("Scheduler thread created"); 108 109 /* wait for the scheduler thread to startup */ 110 qdf_wake_up_process(sched_ctx->sch_thread); 111 qdf_wait_single_event(&sched_ctx->sch_start_event, 0); 112 113 sched_debug("Scheduler thread started"); 114 115 return QDF_STATUS_SUCCESS; 116 } 117 118 QDF_STATUS scheduler_init(void) 119 { 120 QDF_STATUS status; 121 struct scheduler_ctx *sched_ctx; 122 123 sched_debug("Initializing Scheduler"); 124 125 status = scheduler_create_ctx(); 126 if (QDF_IS_STATUS_ERROR(status)) { 127 sched_err("Failed to create context; status:%d", status); 128 return status; 129 } 130 131 sched_ctx = scheduler_get_context(); 132 QDF_BUG(sched_ctx); 133 if (!sched_ctx) { 134 status = QDF_STATUS_E_FAILURE; 135 goto ctx_destroy; 136 } 137 138 status = scheduler_queues_init(sched_ctx); 139 if (QDF_IS_STATUS_ERROR(status)) { 140 sched_err("Failed to init queues; status:%d", status); 141 goto ctx_destroy; 142 } 143 144 status = qdf_event_create(&sched_ctx->sch_start_event); 145 if (QDF_IS_STATUS_ERROR(status)) { 146 sched_err("Failed to create start event; status:%d", status); 147 goto queues_deinit; 148 } 149 150 status = qdf_event_create(&sched_ctx->sch_shutdown); 151 if (QDF_IS_STATUS_ERROR(status)) { 152 sched_err("Failed to create shutdown event; status:%d", status); 153 goto start_event_destroy; 154 } 155 156 status = qdf_event_create(&sched_ctx->resume_sch_event); 157 if (QDF_IS_STATUS_ERROR(status)) { 158 sched_err("Failed to create resume event; status:%d", status); 159 goto shutdown_event_destroy; 160 } 161 162 qdf_spinlock_create(&sched_ctx->sch_thread_lock); 163 qdf_init_waitqueue_head(&sched_ctx->sch_wait_queue); 164 sched_ctx->sch_event_flag = 0; 165 qdf_timer_init(NULL, 166 &sched_ctx->watchdog_timer, 167 &scheduler_watchdog_timeout, 168 sched_ctx, 169 QDF_TIMER_TYPE_SW); 170 171 qdf_register_mc_timer_callback(scheduler_mc_timer_callback); 172 173 return QDF_STATUS_SUCCESS; 174 175 shutdown_event_destroy: 176 qdf_event_destroy(&sched_ctx->sch_shutdown); 177 178 start_event_destroy: 179 qdf_event_destroy(&sched_ctx->sch_start_event); 180 181 queues_deinit: 182 scheduler_queues_deinit(sched_ctx); 183 184 ctx_destroy: 185 scheduler_destroy_ctx(); 186 187 return status; 188 } 189 190 QDF_STATUS scheduler_deinit(void) 191 { 192 QDF_STATUS status; 193 struct scheduler_ctx *sched_ctx; 194 195 sched_debug("Deinitializing Scheduler"); 196 197 sched_ctx = scheduler_get_context(); 198 QDF_BUG(sched_ctx); 199 if (!sched_ctx) 200 return QDF_STATUS_E_INVAL; 201 202 qdf_timer_free(&sched_ctx->watchdog_timer); 203 qdf_spinlock_destroy(&sched_ctx->sch_thread_lock); 204 qdf_event_destroy(&sched_ctx->resume_sch_event); 205 qdf_event_destroy(&sched_ctx->sch_shutdown); 206 qdf_event_destroy(&sched_ctx->sch_start_event); 207 208 status = scheduler_queues_deinit(sched_ctx); 209 if (QDF_IS_STATUS_ERROR(status)) 210 sched_err("Failed to deinit queues; status:%d", status); 211 212 status = scheduler_destroy_ctx(); 213 if (QDF_IS_STATUS_ERROR(status)) 214 sched_err("Failed to destroy context; status:%d", status); 215 216 return QDF_STATUS_SUCCESS; 217 } 218 219 QDF_STATUS scheduler_post_msg_by_priority(uint32_t qid, 220 struct scheduler_msg *msg, 221 bool is_high_priority) 222 { 223 uint8_t qidx; 224 struct scheduler_mq_type *target_mq; 225 struct scheduler_msg *queue_msg; 226 struct scheduler_ctx *sched_ctx; 227 uint16_t src_id; 228 uint16_t dest_id; 229 uint16_t que_id; 230 231 QDF_BUG(msg); 232 if (!msg) 233 return QDF_STATUS_E_INVAL; 234 235 sched_ctx = scheduler_get_context(); 236 QDF_BUG(sched_ctx); 237 if (!sched_ctx) 238 return QDF_STATUS_E_INVAL; 239 240 if (!sched_ctx->sch_thread) { 241 sched_err("Cannot post message; scheduler thread is stopped"); 242 return QDF_STATUS_E_FAILURE; 243 } 244 245 if (msg->reserved != 0 && msg->reserved != SYS_MSG_COOKIE) { 246 QDF_DEBUG_PANIC("Scheduler messages must be initialized"); 247 return QDF_STATUS_E_FAILURE; 248 } 249 250 dest_id = scheduler_get_dest_id(qid); 251 src_id = scheduler_get_src_id(qid); 252 que_id = scheduler_get_que_id(qid); 253 254 if (que_id >= QDF_MODULE_ID_MAX || src_id >= QDF_MODULE_ID_MAX || 255 dest_id >= QDF_MODULE_ID_MAX) { 256 sched_err("Src_id/Dest_id invalid, cannot post message"); 257 return QDF_STATUS_E_FAILURE; 258 } 259 /* Target_If is a special message queue in phase 3 convergence beacause 260 * its used by both legacy WMA and as well as new UMAC components which 261 * directly populate callback handlers in message body. 262 * 1) WMA legacy messages should not have callback 263 * 2) New target_if message needs to have valid callback 264 * Clear callback handler for legacy WMA messages such that in case 265 * if someone is sending legacy WMA message from stack which has 266 * uninitialized callback then its handled properly. Also change 267 * legacy WMA message queue id to target_if queue such that its always 268 * handled in right order. 269 */ 270 if (QDF_MODULE_ID_WMA == que_id) { 271 msg->callback = NULL; 272 /* change legacy WMA message id to new target_if mq id */ 273 que_id = QDF_MODULE_ID_TARGET_IF; 274 } 275 qdf_mtrace(src_id, dest_id, msg->type, 0xFF, 0); 276 277 qidx = sched_ctx->queue_ctx.scheduler_msg_qid_to_qidx[que_id]; 278 if (qidx >= SCHEDULER_NUMBER_OF_MSG_QUEUE) { 279 sched_err("Scheduler is deinitialized ignore msg"); 280 return QDF_STATUS_E_FAILURE; 281 } 282 283 if (!sched_ctx->queue_ctx.scheduler_msg_process_fn[qidx]) { 284 QDF_DEBUG_PANIC("callback not registered for qid[%d]", que_id); 285 return QDF_STATUS_E_FAILURE; 286 } 287 288 target_mq = &(sched_ctx->queue_ctx.sch_msg_q[qidx]); 289 290 queue_msg = scheduler_core_msg_dup(msg); 291 if (!queue_msg) 292 return QDF_STATUS_E_NOMEM; 293 294 if (is_high_priority) 295 scheduler_mq_put_front(target_mq, queue_msg); 296 else 297 scheduler_mq_put(target_mq, queue_msg); 298 299 qdf_atomic_set_bit(MC_POST_EVENT_MASK, &sched_ctx->sch_event_flag); 300 qdf_wake_up_interruptible(&sched_ctx->sch_wait_queue); 301 302 return QDF_STATUS_SUCCESS; 303 } 304 305 QDF_STATUS scheduler_register_module(QDF_MODULE_ID qid, 306 scheduler_msg_process_fn_t callback) 307 { 308 struct scheduler_mq_ctx *ctx; 309 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 310 311 sched_enter(); 312 313 QDF_BUG(sched_ctx); 314 if (!sched_ctx) 315 return QDF_STATUS_E_FAILURE; 316 317 if (sched_ctx->sch_last_qidx >= SCHEDULER_NUMBER_OF_MSG_QUEUE) { 318 sched_err("Already registered max %d no of message queues", 319 SCHEDULER_NUMBER_OF_MSG_QUEUE); 320 return QDF_STATUS_E_FAILURE; 321 } 322 323 ctx = &sched_ctx->queue_ctx; 324 ctx->scheduler_msg_qid_to_qidx[qid] = sched_ctx->sch_last_qidx; 325 ctx->sch_msg_q[sched_ctx->sch_last_qidx].qid = qid; 326 ctx->scheduler_msg_process_fn[sched_ctx->sch_last_qidx] = callback; 327 sched_ctx->sch_last_qidx++; 328 329 sched_exit(); 330 331 return QDF_STATUS_SUCCESS; 332 } 333 334 QDF_STATUS scheduler_deregister_module(QDF_MODULE_ID qid) 335 { 336 struct scheduler_mq_ctx *ctx; 337 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 338 uint8_t qidx; 339 340 sched_enter(); 341 342 QDF_BUG(sched_ctx); 343 if (!sched_ctx) 344 return QDF_STATUS_E_FAILURE; 345 346 ctx = &sched_ctx->queue_ctx; 347 qidx = ctx->scheduler_msg_qid_to_qidx[qid]; 348 ctx->scheduler_msg_process_fn[qidx] = NULL; 349 sched_ctx->sch_last_qidx--; 350 ctx->scheduler_msg_qid_to_qidx[qidx] = SCHEDULER_NUMBER_OF_MSG_QUEUE; 351 352 sched_exit(); 353 354 return QDF_STATUS_SUCCESS; 355 } 356 357 void scheduler_resume(void) 358 { 359 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 360 361 if (sched_ctx) 362 qdf_event_set(&sched_ctx->resume_sch_event); 363 } 364 365 void scheduler_register_hdd_suspend_callback(hdd_suspend_callback callback) 366 { 367 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 368 369 if (sched_ctx) 370 sched_ctx->hdd_callback = callback; 371 } 372 void scheduler_wake_up_controller_thread(void) 373 { 374 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 375 376 if (sched_ctx) 377 qdf_wake_up_interruptible(&sched_ctx->sch_wait_queue); 378 } 379 void scheduler_set_event_mask(uint32_t event_mask) 380 { 381 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 382 383 if (sched_ctx) 384 qdf_atomic_set_bit(event_mask, &sched_ctx->sch_event_flag); 385 } 386 387 void scheduler_clear_event_mask(uint32_t event_mask) 388 { 389 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 390 391 if (sched_ctx) 392 qdf_atomic_clear_bit(event_mask, &sched_ctx->sch_event_flag); 393 } 394 395 QDF_STATUS scheduler_target_if_mq_handler(struct scheduler_msg *msg) 396 { 397 QDF_STATUS status; 398 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 399 QDF_STATUS (*target_if_msg_handler)(struct scheduler_msg *); 400 401 QDF_BUG(msg); 402 if (!msg) 403 return QDF_STATUS_E_FAILURE; 404 405 QDF_BUG(sched_ctx); 406 if (!sched_ctx) 407 return QDF_STATUS_E_FAILURE; 408 409 target_if_msg_handler = msg->callback; 410 411 /* Target_If is a special message queue in phase 3 convergence beacause 412 * its used by both legacy WMA and as well as new UMAC components. New 413 * UMAC components directly pass their message handlers as callback in 414 * message body. 415 * 1) All Legacy WMA messages do not contain message callback so invoke 416 * registered legacy WMA handler. Scheduler message posting APIs 417 * makes sure legacy WMA messages do not have callbacks. 418 * 2) For new messages which have valid callbacks invoke their callbacks 419 * directly. 420 */ 421 if (!target_if_msg_handler) 422 status = sched_ctx->legacy_wma_handler(msg); 423 else 424 status = target_if_msg_handler(msg); 425 426 return status; 427 } 428 429 QDF_STATUS scheduler_os_if_mq_handler(struct scheduler_msg *msg) 430 { 431 QDF_STATUS (*os_if_msg_handler)(struct scheduler_msg *); 432 433 QDF_BUG(msg); 434 if (!msg) 435 return QDF_STATUS_E_FAILURE; 436 437 os_if_msg_handler = msg->callback; 438 439 QDF_BUG(os_if_msg_handler); 440 if (!os_if_msg_handler) 441 return QDF_STATUS_E_FAILURE; 442 443 os_if_msg_handler(msg); 444 445 return QDF_STATUS_SUCCESS; 446 } 447 448 QDF_STATUS scheduler_timer_q_mq_handler(struct scheduler_msg *msg) 449 { 450 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 451 qdf_mc_timer_callback_t timer_callback; 452 453 QDF_BUG(msg); 454 if (!msg) 455 return QDF_STATUS_E_FAILURE; 456 457 QDF_BUG(sched_ctx); 458 if (!sched_ctx) 459 return QDF_STATUS_E_FAILURE; 460 461 /* legacy sys message handler? */ 462 if (msg->reserved != SYS_MSG_COOKIE || msg->type != SYS_MSG_ID_MC_TIMER) 463 return sched_ctx->legacy_sys_handler(msg); 464 465 timer_callback = msg->callback; 466 QDF_BUG(timer_callback); 467 if (!timer_callback) 468 return QDF_STATUS_E_FAILURE; 469 470 timer_callback(msg->bodyptr); 471 472 return QDF_STATUS_SUCCESS; 473 } 474 475 QDF_STATUS scheduler_scan_mq_handler(struct scheduler_msg *msg) 476 { 477 QDF_STATUS (*scan_q_msg_handler)(struct scheduler_msg *); 478 479 QDF_BUG(msg); 480 if (!msg) 481 return QDF_STATUS_E_FAILURE; 482 483 scan_q_msg_handler = msg->callback; 484 485 QDF_BUG(scan_q_msg_handler); 486 if (!scan_q_msg_handler) 487 return QDF_STATUS_E_FAILURE; 488 489 scan_q_msg_handler(msg); 490 491 return QDF_STATUS_SUCCESS; 492 } 493 494 QDF_STATUS scheduler_register_wma_legacy_handler(scheduler_msg_process_fn_t 495 wma_callback) 496 { 497 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 498 499 QDF_BUG(sched_ctx); 500 if (!sched_ctx) 501 return QDF_STATUS_E_FAILURE; 502 503 sched_ctx->legacy_wma_handler = wma_callback; 504 505 return QDF_STATUS_SUCCESS; 506 } 507 508 QDF_STATUS scheduler_register_sys_legacy_handler(scheduler_msg_process_fn_t 509 sys_callback) 510 { 511 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 512 513 QDF_BUG(sched_ctx); 514 if (!sched_ctx) 515 return QDF_STATUS_E_FAILURE; 516 517 sched_ctx->legacy_sys_handler = sys_callback; 518 519 return QDF_STATUS_SUCCESS; 520 } 521 522 QDF_STATUS scheduler_deregister_wma_legacy_handler(void) 523 { 524 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 525 526 QDF_BUG(sched_ctx); 527 if (!sched_ctx) 528 return QDF_STATUS_E_FAILURE; 529 530 sched_ctx->legacy_wma_handler = NULL; 531 532 return QDF_STATUS_SUCCESS; 533 } 534 535 QDF_STATUS scheduler_deregister_sys_legacy_handler(void) 536 { 537 struct scheduler_ctx *sched_ctx = scheduler_get_context(); 538 539 QDF_BUG(sched_ctx); 540 if (!sched_ctx) 541 return QDF_STATUS_E_FAILURE; 542 543 sched_ctx->legacy_sys_handler = NULL; 544 545 return QDF_STATUS_SUCCESS; 546 } 547 548 static QDF_STATUS scheduler_msg_flush_noop(struct scheduler_msg *msg) 549 { 550 return QDF_STATUS_SUCCESS; 551 } 552 553 void scheduler_mc_timer_callback(unsigned long data) 554 { 555 qdf_mc_timer_t *timer = (qdf_mc_timer_t *)data; 556 struct scheduler_msg msg = {0}; 557 QDF_STATUS status; 558 559 qdf_mc_timer_callback_t callback = NULL; 560 void *user_data = NULL; 561 QDF_TIMER_TYPE type = QDF_TIMER_TYPE_SW; 562 563 QDF_BUG(timer); 564 if (!timer) 565 return; 566 567 qdf_spin_lock_irqsave(&timer->platform_info.spinlock); 568 569 switch (timer->state) { 570 case QDF_TIMER_STATE_STARTING: 571 /* we are in this state because someone just started the timer, 572 * MC timer got started and expired, but the time content have 573 * not been updated this is a rare race condition! 574 */ 575 timer->state = QDF_TIMER_STATE_STOPPED; 576 status = QDF_STATUS_E_ALREADY; 577 break; 578 579 case QDF_TIMER_STATE_STOPPED: 580 status = QDF_STATUS_E_ALREADY; 581 break; 582 583 case QDF_TIMER_STATE_UNUSED: 584 status = QDF_STATUS_E_EXISTS; 585 break; 586 587 case QDF_TIMER_STATE_RUNNING: 588 /* need to go to stop state here because the call-back function 589 * may restart timer (to emulate periodic timer) 590 */ 591 timer->state = QDF_TIMER_STATE_STOPPED; 592 /* copy the relevant timer information to local variables; 593 * once we exits from this critical section, the timer content 594 * may be modified by other tasks 595 */ 596 callback = timer->callback; 597 user_data = timer->user_data; 598 type = timer->type; 599 status = QDF_STATUS_SUCCESS; 600 break; 601 602 default: 603 QDF_ASSERT(0); 604 status = QDF_STATUS_E_FAULT; 605 break; 606 } 607 608 qdf_spin_unlock_irqrestore(&timer->platform_info.spinlock); 609 610 if (QDF_IS_STATUS_ERROR(status)) { 611 sched_debug("MC timer fired but is not running; skip callback"); 612 return; 613 } 614 615 qdf_try_allowing_sleep(type); 616 617 QDF_BUG(callback); 618 if (!callback) 619 return; 620 621 /* serialize to scheduler controller thread */ 622 msg.type = SYS_MSG_ID_MC_TIMER; 623 msg.reserved = SYS_MSG_COOKIE; 624 msg.callback = callback; 625 msg.bodyptr = user_data; 626 msg.bodyval = 0; 627 628 /* bodyptr points to user data, do not free it during msg flush */ 629 msg.flush_callback = scheduler_msg_flush_noop; 630 631 status = scheduler_post_message(QDF_MODULE_ID_SCHEDULER, 632 QDF_MODULE_ID_SCHEDULER, 633 QDF_MODULE_ID_SYS, &msg); 634 if (QDF_IS_STATUS_ERROR(status)) 635 sched_err("Could not enqueue timer to timer queue"); 636 } 637 638 QDF_STATUS scheduler_get_queue_size(QDF_MODULE_ID qid, uint32_t *size) 639 { 640 uint8_t qidx; 641 struct scheduler_mq_type *target_mq; 642 struct scheduler_ctx *sched_ctx; 643 644 sched_ctx = scheduler_get_context(); 645 if (!sched_ctx) 646 return QDF_STATUS_E_INVAL; 647 648 /* WMA also uses the target_if queue, so replace the QID */ 649 if (QDF_MODULE_ID_WMA == qid) 650 qid = QDF_MODULE_ID_TARGET_IF; 651 652 qidx = sched_ctx->queue_ctx.scheduler_msg_qid_to_qidx[qid]; 653 if (qidx >= SCHEDULER_NUMBER_OF_MSG_QUEUE) { 654 sched_err("Scheduler is deinitialized"); 655 return QDF_STATUS_E_FAILURE; 656 } 657 658 target_mq = &(sched_ctx->queue_ctx.sch_msg_q[qidx]); 659 660 *size = qdf_list_size(&target_mq->mq_list); 661 662 return QDF_STATUS_SUCCESS; 663 } 664