Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | 1ed83fc | 2014-02-19 01:15:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 1ed83fc | 2014-02-19 01:15:45 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | /*=========================================================================== |
| 29 | @file vos_sched.c |
| 30 | @brief VOS Scheduler Implementation |
| 31 | |
| 32 | Copyright (c) 2011 QUALCOMM Incorporated. |
| 33 | All Rights Reserved. |
| 34 | Qualcomm Confidential and Proprietary |
| 35 | ===========================================================================*/ |
| 36 | /*=========================================================================== |
| 37 | EDIT HISTORY FOR FILE |
| 38 | |
| 39 | This section contains comments describing changes made to the module. |
| 40 | Notice that changes are listed in reverse chronological order. |
| 41 | |
| 42 | $Header:$ $DateTime: $ $Author: $ |
| 43 | |
| 44 | when who what, where, why |
| 45 | -------- --- -------------------------------------------------------- |
| 46 | ===========================================================================*/ |
| 47 | /*--------------------------------------------------------------------------- |
| 48 | * Include Files |
| 49 | * ------------------------------------------------------------------------*/ |
| 50 | #include <vos_mq.h> |
| 51 | #include <vos_api.h> |
| 52 | #include <aniGlobal.h> |
| 53 | #include <sirTypes.h> |
| 54 | #include <halTypes.h> |
| 55 | #include <limApi.h> |
| 56 | #include <sme_Api.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 57 | #include <wlan_qct_sys.h> |
| 58 | #include <wlan_qct_tl.h> |
| 59 | #include "vos_sched.h" |
| 60 | #include <wlan_hdd_power.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 61 | #include "wlan_qct_wda.h" |
| 62 | #include "wlan_qct_pal_msg.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 63 | #include <linux/spinlock.h> |
| 64 | #include <linux/kthread.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 65 | /*--------------------------------------------------------------------------- |
| 66 | * Preprocessor Definitions and Constants |
| 67 | * ------------------------------------------------------------------------*/ |
| 68 | #define VOS_SCHED_THREAD_HEART_BEAT INFINITE |
Mahesh A Saptasagar | 96395ab | 2014-04-08 12:48:39 +0530 | [diff] [blame] | 69 | /* Milli seconds to delay SSR thread when an Entry point is Active */ |
| 70 | #define SSR_WAIT_SLEEP_TIME 100 |
| 71 | /* MAX iteration count to wait for Entry point to exit before |
| 72 | * we proceed with SSR in WD Thread |
| 73 | */ |
| 74 | #define MAX_SSR_WAIT_ITERATIONS 20 |
| 75 | |
| 76 | static atomic_t ssr_protect_entry_count; |
| 77 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 78 | /*--------------------------------------------------------------------------- |
| 79 | * Type Declarations |
| 80 | * ------------------------------------------------------------------------*/ |
| 81 | /*--------------------------------------------------------------------------- |
| 82 | * Data definitions |
| 83 | * ------------------------------------------------------------------------*/ |
| 84 | static pVosSchedContext gpVosSchedContext; |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 85 | static pVosWatchdogContext gpVosWatchdogContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 86 | |
| 87 | /*--------------------------------------------------------------------------- |
| 88 | * Forward declaration |
| 89 | * ------------------------------------------------------------------------*/ |
Jeff Johnson | 2f5cfec | 2013-02-22 21:25:10 -0800 | [diff] [blame] | 90 | static int VosMCThread(void *Arg); |
| 91 | static int VosWDThread(void *Arg); |
| 92 | static int VosTXThread(void *Arg); |
| 93 | static int VosRXThread(void *Arg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 94 | void vos_sched_flush_rx_mqs(pVosSchedContext SchedContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 95 | extern v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper); |
| 96 | /*--------------------------------------------------------------------------- |
| 97 | * External Function implementation |
| 98 | * ------------------------------------------------------------------------*/ |
| 99 | |
| 100 | /*--------------------------------------------------------------------------- |
| 101 | \brief vos_sched_open() - initialize the vOSS Scheduler |
| 102 | The \a vos_sched_open() function initializes the vOSS Scheduler |
| 103 | Upon successful initialization: |
| 104 | - All the message queues are initialized |
| 105 | - The Main Controller thread is created and ready to receive and |
| 106 | dispatch messages. |
| 107 | - The Tx thread is created and ready to receive and dispatch messages |
| 108 | |
| 109 | \param pVosContext - pointer to the global vOSS Context |
| 110 | \param pVosSchedContext - pointer to a previously allocated buffer big |
| 111 | enough to hold a scheduler context. |
| 112 | \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and |
| 113 | is ready to be used. |
| 114 | VOS_STATUS_E_RESOURCES - System resources (other than memory) |
| 115 | are unavailable to initilize the scheduler |
| 116 | VOS_STATUS_E_NOMEM - insufficient memory exists to initialize |
| 117 | the scheduler |
| 118 | VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open |
| 119 | function |
| 120 | VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/ |
| 121 | \sa vos_sched_open() |
| 122 | -------------------------------------------------------------------------*/ |
| 123 | VOS_STATUS |
| 124 | vos_sched_open |
| 125 | ( |
| 126 | v_PVOID_t pVosContext, |
| 127 | pVosSchedContext pSchedContext, |
| 128 | v_SIZE_t SchedCtxSize |
| 129 | ) |
| 130 | { |
| 131 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 132 | /*-------------------------------------------------------------------------*/ |
| 133 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 134 | "%s: Opening the VOSS Scheduler",__func__); |
| 135 | // Sanity checks |
| 136 | if ((pVosContext == NULL) || (pSchedContext == NULL)) { |
| 137 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 138 | "%s: Null params being passed",__func__); |
| 139 | return VOS_STATUS_E_FAILURE; |
| 140 | } |
| 141 | if (sizeof(VosSchedContext) != SchedCtxSize) |
| 142 | { |
| 143 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 144 | "%s: Incorrect VOS Sched Context size passed",__func__); |
| 145 | return VOS_STATUS_E_INVAL; |
| 146 | } |
| 147 | vos_mem_zero(pSchedContext, sizeof(VosSchedContext)); |
| 148 | pSchedContext->pVContext = pVosContext; |
| 149 | vStatus = vos_sched_init_mqs(pSchedContext); |
| 150 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 151 | { |
| 152 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 153 | "%s: Failed to initialize VOS Scheduler MQs",__func__); |
| 154 | return vStatus; |
| 155 | } |
| 156 | // Initialize the helper events and event queues |
| 157 | init_completion(&pSchedContext->McStartEvent); |
| 158 | init_completion(&pSchedContext->TxStartEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 159 | init_completion(&pSchedContext->RxStartEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 160 | init_completion(&pSchedContext->McShutdown); |
| 161 | init_completion(&pSchedContext->TxShutdown); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 162 | init_completion(&pSchedContext->RxShutdown); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 163 | init_completion(&pSchedContext->ResumeMcEvent); |
| 164 | init_completion(&pSchedContext->ResumeTxEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 165 | init_completion(&pSchedContext->ResumeRxEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 166 | |
| 167 | spin_lock_init(&pSchedContext->McThreadLock); |
| 168 | spin_lock_init(&pSchedContext->TxThreadLock); |
| 169 | spin_lock_init(&pSchedContext->RxThreadLock); |
| 170 | |
| 171 | init_waitqueue_head(&pSchedContext->mcWaitQueue); |
| 172 | pSchedContext->mcEventFlag = 0; |
| 173 | init_waitqueue_head(&pSchedContext->txWaitQueue); |
| 174 | pSchedContext->txEventFlag= 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 175 | init_waitqueue_head(&pSchedContext->rxWaitQueue); |
| 176 | pSchedContext->rxEventFlag= 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 177 | /* |
Jeff Johnson | 2f5cfec | 2013-02-22 21:25:10 -0800 | [diff] [blame] | 178 | ** This initialization is critical as the threads will later access the |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 179 | ** global contexts normally, |
| 180 | ** |
| 181 | ** I shall put some memory barrier here after the next piece of code but |
| 182 | ** I am keeping it simple for now. |
| 183 | */ |
| 184 | gpVosSchedContext = pSchedContext; |
| 185 | |
| 186 | //Create the VOSS Main Controller thread |
| 187 | pSchedContext->McThread = kthread_create(VosMCThread, pSchedContext, |
| 188 | "VosMCThread"); |
| 189 | if (IS_ERR(pSchedContext->McThread)) |
| 190 | { |
| 191 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 192 | "%s: Could not Create VOSS Main Thread Controller",__func__); |
| 193 | goto MC_THREAD_START_FAILURE; |
| 194 | } |
| 195 | wake_up_process(pSchedContext->McThread); |
| 196 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 197 | "%s: VOSS Main Controller thread Created",__func__); |
| 198 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 199 | pSchedContext->TxThread = kthread_create(VosTXThread, pSchedContext, |
| 200 | "VosTXThread"); |
| 201 | if (IS_ERR(pSchedContext->TxThread)) |
| 202 | { |
| 203 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 204 | "%s: Could not Create VOSS TX Thread",__func__); |
| 205 | goto TX_THREAD_START_FAILURE; |
| 206 | } |
| 207 | wake_up_process(pSchedContext->TxThread); |
| 208 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 209 | ("VOSS TX thread Created")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 210 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 211 | pSchedContext->RxThread = kthread_create(VosRXThread, pSchedContext, |
| 212 | "VosRXThread"); |
| 213 | if (IS_ERR(pSchedContext->RxThread)) |
| 214 | { |
| 215 | |
| 216 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 217 | "%s: Could not Create VOSS RX Thread",__func__); |
| 218 | goto RX_THREAD_START_FAILURE; |
| 219 | |
| 220 | } |
| 221 | wake_up_process(pSchedContext->RxThread); |
| 222 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 223 | ("VOSS RX thread Created")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 224 | |
| 225 | /* |
| 226 | ** Now make sure all threads have started before we exit. |
| 227 | ** Each thread should normally ACK back when it starts. |
| 228 | */ |
| 229 | wait_for_completion_interruptible(&pSchedContext->McStartEvent); |
| 230 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 231 | "%s: VOSS MC Thread has started",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 232 | wait_for_completion_interruptible(&pSchedContext->TxStartEvent); |
| 233 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 234 | "%s: VOSS Tx Thread has started",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 235 | wait_for_completion_interruptible(&pSchedContext->RxStartEvent); |
| 236 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 237 | "%s: VOSS Rx Thread has started",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 238 | |
| 239 | /* |
| 240 | ** We're good now: Let's get the ball rolling!!! |
| 241 | */ |
| 242 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 243 | "%s: VOSS Scheduler successfully Opened",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 244 | return VOS_STATUS_SUCCESS; |
| 245 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 246 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 247 | RX_THREAD_START_FAILURE: |
| 248 | //Try and force the Tx thread controller to exit |
| 249 | set_bit(MC_SHUTDOWN_EVENT_MASK, &pSchedContext->txEventFlag); |
| 250 | set_bit(MC_POST_EVENT_MASK, &pSchedContext->txEventFlag); |
| 251 | wake_up_interruptible(&pSchedContext->txWaitQueue); |
| 252 | //Wait for TX to exit |
| 253 | wait_for_completion_interruptible(&pSchedContext->TxShutdown); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 254 | |
| 255 | TX_THREAD_START_FAILURE: |
| 256 | //Try and force the Main thread controller to exit |
| 257 | set_bit(MC_SHUTDOWN_EVENT_MASK, &pSchedContext->mcEventFlag); |
| 258 | set_bit(MC_POST_EVENT_MASK, &pSchedContext->mcEventFlag); |
| 259 | wake_up_interruptible(&pSchedContext->mcWaitQueue); |
| 260 | //Wait for MC to exit |
| 261 | wait_for_completion_interruptible(&pSchedContext->McShutdown); |
| 262 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | MC_THREAD_START_FAILURE: |
| 264 | //De-initialize all the message queues |
| 265 | vos_sched_deinit_mqs(pSchedContext); |
| 266 | return VOS_STATUS_E_RESOURCES; |
| 267 | |
| 268 | } /* vos_sched_open() */ |
| 269 | |
| 270 | VOS_STATUS vos_watchdog_open |
| 271 | ( |
| 272 | v_PVOID_t pVosContext, |
| 273 | pVosWatchdogContext pWdContext, |
| 274 | v_SIZE_t wdCtxSize |
| 275 | ) |
| 276 | { |
| 277 | /*-------------------------------------------------------------------------*/ |
| 278 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 279 | "%s: Opening the VOSS Watchdog module",__func__); |
| 280 | //Sanity checks |
| 281 | if ((pVosContext == NULL) || (pWdContext == NULL)) { |
| 282 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 283 | "%s: Null params being passed",__func__); |
| 284 | return VOS_STATUS_E_FAILURE; |
| 285 | } |
| 286 | if (sizeof(VosWatchdogContext) != wdCtxSize) |
| 287 | { |
| 288 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 289 | "%s: Incorrect VOS Watchdog Context size passed",__func__); |
| 290 | return VOS_STATUS_E_INVAL; |
| 291 | } |
| 292 | vos_mem_zero(pWdContext, sizeof(VosWatchdogContext)); |
| 293 | pWdContext->pVContext = pVosContext; |
| 294 | gpVosWatchdogContext = pWdContext; |
| 295 | |
| 296 | //Initialize the helper events and event queues |
| 297 | init_completion(&pWdContext->WdStartEvent); |
| 298 | init_completion(&pWdContext->WdShutdown); |
| 299 | init_waitqueue_head(&pWdContext->wdWaitQueue); |
| 300 | pWdContext->wdEventFlag = 0; |
| 301 | |
| 302 | // Initialize the lock |
| 303 | spin_lock_init(&pWdContext->wdLock); |
| 304 | |
| 305 | //Create the Watchdog thread |
| 306 | pWdContext->WdThread = kthread_create(VosWDThread, pWdContext,"VosWDThread"); |
| 307 | |
| 308 | if (IS_ERR(pWdContext->WdThread)) |
| 309 | { |
| 310 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 311 | "%s: Could not Create Watchdog thread",__func__); |
| 312 | return VOS_STATUS_E_RESOURCES; |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | wake_up_process(pWdContext->WdThread); |
| 317 | } |
| 318 | /* |
| 319 | ** Now make sure thread has started before we exit. |
| 320 | ** Each thread should normally ACK back when it starts. |
| 321 | */ |
| 322 | wait_for_completion_interruptible(&pWdContext->WdStartEvent); |
| 323 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 324 | "%s: VOSS Watchdog Thread has started",__func__); |
| 325 | return VOS_STATUS_SUCCESS; |
| 326 | } /* vos_watchdog_open() */ |
| 327 | /*--------------------------------------------------------------------------- |
| 328 | \brief VosMcThread() - The VOSS Main Controller thread |
| 329 | The \a VosMcThread() is the VOSS main controller thread: |
| 330 | \param Arg - pointer to the global vOSS Sched Context |
| 331 | \return Thread exit code |
| 332 | \sa VosMcThread() |
| 333 | -------------------------------------------------------------------------*/ |
| 334 | static int |
| 335 | VosMCThread |
| 336 | ( |
| 337 | void * Arg |
| 338 | ) |
| 339 | { |
| 340 | pVosSchedContext pSchedContext = (pVosSchedContext)Arg; |
| 341 | pVosMsgWrapper pMsgWrapper = NULL; |
| 342 | tpAniSirGlobal pMacContext = NULL; |
| 343 | tSirRetStatus macStatus = eSIR_SUCCESS; |
| 344 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 345 | int retWaitStatus = 0; |
| 346 | v_BOOL_t shutdown = VOS_FALSE; |
| 347 | hdd_context_t *pHddCtx = NULL; |
| 348 | v_CONTEXT_t pVosContext = NULL; |
| 349 | |
| 350 | if (Arg == NULL) |
| 351 | { |
| 352 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 353 | "%s: Bad Args passed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 354 | return 0; |
| 355 | } |
| 356 | set_user_nice(current, -2); |
| 357 | |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 358 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 359 | daemonize("MC_Thread"); |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 360 | #endif |
| 361 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 362 | /* |
| 363 | ** Ack back to the context from which the main controller thread has been |
| 364 | ** created. |
| 365 | */ |
| 366 | complete(&pSchedContext->McStartEvent); |
| 367 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 368 | "%s: MC Thread %d (%s) starting up",__func__, current->pid, current->comm); |
| 369 | |
| 370 | /* Get the Global VOSS Context */ |
| 371 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 372 | if(!pVosContext) { |
| 373 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | /* Get the HDD context */ |
| 378 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 379 | if(!pHddCtx) { |
| 380 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | while(!shutdown) |
| 385 | { |
| 386 | // This implements the execution model algorithm |
| 387 | retWaitStatus = wait_event_interruptible(pSchedContext->mcWaitQueue, |
| 388 | test_bit(MC_POST_EVENT_MASK, &pSchedContext->mcEventFlag) || |
| 389 | test_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag)); |
| 390 | |
| 391 | if(retWaitStatus == -ERESTARTSYS) |
| 392 | { |
| 393 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 394 | "%s: wait_event_interruptible returned -ERESTARTSYS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 395 | break; |
| 396 | } |
| 397 | clear_bit(MC_POST_EVENT_MASK, &pSchedContext->mcEventFlag); |
| 398 | |
| 399 | while(1) |
| 400 | { |
| 401 | // Check if MC needs to shutdown |
| 402 | if(test_bit(MC_SHUTDOWN_EVENT_MASK, &pSchedContext->mcEventFlag)) |
| 403 | { |
| 404 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 405 | "%s: MC thread signaled to shutdown", __func__); |
| 406 | shutdown = VOS_TRUE; |
| 407 | /* Check for any Suspend Indication */ |
| 408 | if(test_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag)) |
| 409 | { |
| 410 | clear_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag); |
| 411 | |
| 412 | /* Unblock anyone waiting on suspend */ |
| 413 | complete(&pHddCtx->mc_sus_event_var); |
| 414 | } |
| 415 | break; |
| 416 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 417 | /* |
| 418 | ** Check the WDI queue |
| 419 | ** Service it till the entire queue is empty |
| 420 | */ |
| 421 | if (!vos_is_mq_empty(&pSchedContext->wdiMcMq)) |
| 422 | { |
| 423 | wpt_msg *pWdiMsg; |
| 424 | /* |
| 425 | ** Service the WDI message queue |
| 426 | */ |
| 427 | VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_INFO, |
| 428 | ("Servicing the VOS MC WDI Message queue")); |
| 429 | |
| 430 | pMsgWrapper = vos_mq_get(&pSchedContext->wdiMcMq); |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 431 | |
| 432 | if (pMsgWrapper == NULL) |
| 433 | { |
| 434 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 435 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 436 | VOS_ASSERT(0); |
| 437 | break; |
| 438 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 439 | |
| 440 | pWdiMsg = (wpt_msg *)pMsgWrapper->pVosMsg->bodyptr; |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 441 | |
| 442 | if(pWdiMsg == NULL || pWdiMsg->callback == NULL) |
| 443 | { |
| 444 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 445 | "%s: WDI Msg or Callback is NULL", __func__); |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 446 | VOS_ASSERT(0); |
| 447 | break; |
| 448 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 449 | |
| 450 | pWdiMsg->callback(pWdiMsg); |
| 451 | |
| 452 | /* |
| 453 | ** return message to the Core |
| 454 | */ |
| 455 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 456 | |
| 457 | continue; |
| 458 | } |
| 459 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 460 | // Check the SYS queue first |
| 461 | if (!vos_is_mq_empty(&pSchedContext->sysMcMq)) |
| 462 | { |
| 463 | // Service the SYS message queue |
| 464 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 465 | "%s: Servicing the VOS SYS MC Message queue",__func__); |
| 466 | pMsgWrapper = vos_mq_get(&pSchedContext->sysMcMq); |
| 467 | if (pMsgWrapper == NULL) |
| 468 | { |
| 469 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 470 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 471 | VOS_ASSERT(0); |
| 472 | break; |
| 473 | } |
| 474 | vStatus = sysMcProcessMsg(pSchedContext->pVContext, |
| 475 | pMsgWrapper->pVosMsg); |
| 476 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 477 | { |
| 478 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 479 | "%s: Issue Processing SYS message",__func__); |
| 480 | } |
| 481 | //return message to the Core |
| 482 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 483 | continue; |
| 484 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 485 | // Check the WDA queue |
| 486 | if (!vos_is_mq_empty(&pSchedContext->wdaMcMq)) |
| 487 | { |
| 488 | // Service the WDA message queue |
| 489 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 490 | "%s: Servicing the VOS WDA MC Message queue",__func__); |
| 491 | pMsgWrapper = vos_mq_get(&pSchedContext->wdaMcMq); |
| 492 | if (pMsgWrapper == NULL) |
| 493 | { |
| 494 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 495 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 496 | VOS_ASSERT(0); |
| 497 | break; |
| 498 | } |
| 499 | vStatus = WDA_McProcessMsg( pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 500 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 501 | { |
| 502 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 503 | "%s: Issue Processing WDA message",__func__); |
| 504 | } |
| 505 | // return message to the Core |
| 506 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 507 | continue; |
| 508 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 509 | // Check the PE queue |
| 510 | if (!vos_is_mq_empty(&pSchedContext->peMcMq)) |
| 511 | { |
| 512 | // Service the PE message queue |
| 513 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 514 | "%s: Servicing the VOS PE MC Message queue",__func__); |
| 515 | pMsgWrapper = vos_mq_get(&pSchedContext->peMcMq); |
| 516 | if (NULL == pMsgWrapper) |
| 517 | { |
| 518 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 519 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 520 | VOS_ASSERT(0); |
| 521 | break; |
| 522 | } |
| 523 | |
| 524 | /* Need some optimization*/ |
| 525 | pMacContext = vos_get_context(VOS_MODULE_ID_PE, pSchedContext->pVContext); |
| 526 | if (NULL == pMacContext) |
| 527 | { |
| 528 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 529 | "MAC Context not ready yet"); |
| 530 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 531 | continue; |
| 532 | } |
| 533 | |
| 534 | macStatus = peProcessMessages( pMacContext, (tSirMsgQ*)pMsgWrapper->pVosMsg); |
| 535 | if (eSIR_SUCCESS != macStatus) |
| 536 | { |
| 537 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 538 | "%s: Issue Processing PE message",__func__); |
| 539 | } |
| 540 | // return message to the Core |
| 541 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 542 | continue; |
| 543 | } |
| 544 | /** Check the SME queue **/ |
| 545 | if (!vos_is_mq_empty(&pSchedContext->smeMcMq)) |
| 546 | { |
| 547 | /* Service the SME message queue */ |
| 548 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 549 | "%s: Servicing the VOS SME MC Message queue",__func__); |
| 550 | pMsgWrapper = vos_mq_get(&pSchedContext->smeMcMq); |
| 551 | if (NULL == pMsgWrapper) |
| 552 | { |
| 553 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 554 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 555 | VOS_ASSERT(0); |
| 556 | break; |
| 557 | } |
| 558 | |
| 559 | /* Need some optimization*/ |
| 560 | pMacContext = vos_get_context(VOS_MODULE_ID_SME, pSchedContext->pVContext); |
| 561 | if (NULL == pMacContext) |
| 562 | { |
| 563 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 564 | "MAC Context not ready yet"); |
| 565 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 566 | continue; |
| 567 | } |
| 568 | |
| 569 | vStatus = sme_ProcessMsg( (tHalHandle)pMacContext, pMsgWrapper->pVosMsg); |
| 570 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 571 | { |
| 572 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 573 | "%s: Issue Processing SME message",__func__); |
| 574 | } |
| 575 | // return message to the Core |
| 576 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 577 | continue; |
| 578 | } |
| 579 | /** Check the TL queue **/ |
| 580 | if (!vos_is_mq_empty(&pSchedContext->tlMcMq)) |
| 581 | { |
| 582 | // Service the TL message queue |
| 583 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 584 | ("Servicing the VOS TL MC Message queue")); |
| 585 | pMsgWrapper = vos_mq_get(&pSchedContext->tlMcMq); |
| 586 | if (pMsgWrapper == NULL) |
| 587 | { |
| 588 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 589 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 590 | VOS_ASSERT(0); |
| 591 | break; |
| 592 | } |
| 593 | vStatus = WLANTL_McProcessMsg( pSchedContext->pVContext, |
| 594 | pMsgWrapper->pVosMsg); |
| 595 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 596 | { |
| 597 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 598 | "%s: Issue Processing TL message",__func__); |
| 599 | } |
| 600 | // return message to the Core |
| 601 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 602 | continue; |
| 603 | } |
| 604 | /* Check for any Suspend Indication */ |
| 605 | if(test_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag)) |
| 606 | { |
| 607 | clear_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag); |
| 608 | spin_lock(&pSchedContext->McThreadLock); |
| 609 | |
| 610 | /* Mc Thread Suspended */ |
| 611 | complete(&pHddCtx->mc_sus_event_var); |
| 612 | |
| 613 | INIT_COMPLETION(pSchedContext->ResumeMcEvent); |
| 614 | spin_unlock(&pSchedContext->McThreadLock); |
| 615 | |
| 616 | /* Wait foe Resume Indication */ |
| 617 | wait_for_completion_interruptible(&pSchedContext->ResumeMcEvent); |
| 618 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 619 | break; //All queues are empty now |
| 620 | } // while message loop processing |
| 621 | } // while TRUE |
| 622 | // If we get here the MC thread must exit |
| 623 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 624 | "%s: MC Thread exiting!!!!", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 625 | complete_and_exit(&pSchedContext->McShutdown, 0); |
| 626 | } /* VosMCThread() */ |
Wilson Yang | 68349dd | 2014-02-06 17:30:38 -0800 | [diff] [blame] | 627 | |
| 628 | v_BOOL_t isWDresetInProgress(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 629 | { |
| 630 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 631 | "%s: Reset is in Progress...",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 632 | if(gpVosWatchdogContext!=NULL) |
| 633 | { |
| 634 | return gpVosWatchdogContext->resetInProgress; |
| 635 | } |
| 636 | else |
| 637 | { |
Wilson Yang | 68349dd | 2014-02-06 17:30:38 -0800 | [diff] [blame] | 638 | return FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 639 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 640 | } |
| 641 | /*--------------------------------------------------------------------------- |
| 642 | \brief VosWdThread() - The VOSS Watchdog thread |
| 643 | The \a VosWdThread() is the Watchdog thread: |
| 644 | \param Arg - pointer to the global vOSS Sched Context |
| 645 | \return Thread exit code |
| 646 | \sa VosMcThread() |
| 647 | -------------------------------------------------------------------------*/ |
| 648 | static int |
| 649 | VosWDThread |
| 650 | ( |
| 651 | void * Arg |
| 652 | ) |
| 653 | { |
| 654 | pVosWatchdogContext pWdContext = (pVosWatchdogContext)Arg; |
| 655 | int retWaitStatus = 0; |
| 656 | v_BOOL_t shutdown = VOS_FALSE; |
Mahesh A Saptasagar | 96395ab | 2014-04-08 12:48:39 +0530 | [diff] [blame] | 657 | int count = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 658 | VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 659 | hdd_context_t *pHddCtx = NULL; |
| 660 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 661 | set_user_nice(current, -3); |
| 662 | |
| 663 | if (Arg == NULL) |
| 664 | { |
| 665 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 666 | "%s: Bad Args passed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 667 | return 0; |
| 668 | } |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 669 | |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 670 | /* Get the Global VOSS Context */ |
| 671 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 672 | |
| 673 | if(!pVosContext) |
| 674 | { |
| 675 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 676 | return 0; |
| 677 | } |
| 678 | |
| 679 | /* Get the HDD context */ |
| 680 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 681 | |
| 682 | if(!pHddCtx) |
| 683 | { |
| 684 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 685 | return 0; |
| 686 | } |
| 687 | |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 688 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 689 | daemonize("WD_Thread"); |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 690 | #endif |
| 691 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 692 | /* |
| 693 | ** Ack back to the context from which the Watchdog thread has been |
| 694 | ** created. |
| 695 | */ |
| 696 | complete(&pWdContext->WdStartEvent); |
| 697 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 698 | "%s: Watchdog Thread %d (%s) starting up",__func__, current->pid, current->comm); |
| 699 | |
| 700 | while(!shutdown) |
| 701 | { |
| 702 | // This implements the Watchdog execution model algorithm |
| 703 | retWaitStatus = wait_event_interruptible(pWdContext->wdWaitQueue, |
| 704 | test_bit(WD_POST_EVENT_MASK, &pWdContext->wdEventFlag)); |
| 705 | if(retWaitStatus == -ERESTARTSYS) |
| 706 | { |
| 707 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 708 | "%s: wait_event_interruptible returned -ERESTARTSYS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 709 | break; |
| 710 | } |
| 711 | clear_bit(WD_POST_EVENT_MASK, &pWdContext->wdEventFlag); |
| 712 | while(1) |
| 713 | { |
Mahesh A Saptasagar | 96395ab | 2014-04-08 12:48:39 +0530 | [diff] [blame] | 714 | /* Check for any Active Entry Points |
| 715 | * If active, delay SSR until no entry point is active or |
| 716 | * delay until count is decremented to ZERO |
| 717 | */ |
| 718 | count = MAX_SSR_WAIT_ITERATIONS; |
| 719 | while (count) |
| 720 | { |
| 721 | if (!atomic_read(&ssr_protect_entry_count)) |
| 722 | { |
| 723 | /* no external threads are executing */ |
| 724 | break; |
| 725 | } |
| 726 | /* at least one external thread is executing */ |
| 727 | if (--count) |
| 728 | { |
| 729 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 730 | "%s: Waiting for active entry points to exit", __func__); |
| 731 | msleep(SSR_WAIT_SLEEP_TIME); |
| 732 | } |
| 733 | } |
| 734 | /* at least one external thread is executing */ |
| 735 | if (!count) |
| 736 | { |
| 737 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 738 | "%s: Continuing SSR when %d Entry points are still active", |
| 739 | __func__, atomic_read(&ssr_protect_entry_count)); |
| 740 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 741 | // Check if Watchdog needs to shutdown |
| 742 | if(test_bit(WD_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag)) |
| 743 | { |
| 744 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 745 | "%s: Watchdog thread signaled to shutdown", __func__); |
| 746 | |
| 747 | clear_bit(WD_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag); |
| 748 | shutdown = VOS_TRUE; |
| 749 | break; |
| 750 | } |
| 751 | /* subsystem restart: shutdown event handler */ |
| 752 | else if(test_bit(WD_WLAN_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag)) |
| 753 | { |
| 754 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 755 | "%s: Watchdog thread signaled to perform WLAN shutdown",__func__); |
| 756 | clear_bit(WD_WLAN_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag); |
| 757 | |
| 758 | //Perform WLAN shutdown |
| 759 | if(!pWdContext->resetInProgress) |
| 760 | { |
| 761 | pWdContext->resetInProgress = true; |
| 762 | vosStatus = hdd_wlan_shutdown(); |
| 763 | |
| 764 | if (! VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 765 | { |
| 766 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 767 | "%s: Failed to shutdown WLAN",__func__); |
| 768 | VOS_ASSERT(0); |
| 769 | goto err_reset; |
| 770 | } |
| 771 | } |
| 772 | } |
| 773 | /* subsystem restart: re-init event handler */ |
| 774 | else if(test_bit(WD_WLAN_REINIT_EVENT_MASK, &pWdContext->wdEventFlag)) |
| 775 | { |
| 776 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 777 | "%s: Watchdog thread signaled to perform WLAN re-init",__func__); |
| 778 | clear_bit(WD_WLAN_REINIT_EVENT_MASK, &pWdContext->wdEventFlag); |
| 779 | |
| 780 | //Perform WLAN re-init |
| 781 | if(!pWdContext->resetInProgress) |
| 782 | { |
| 783 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 784 | "%s: Trying to do WLAN re-init when it is not shutdown !!",__func__); |
| 785 | } |
| 786 | vosStatus = hdd_wlan_re_init(); |
| 787 | |
| 788 | if (! VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 789 | { |
| 790 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 791 | "%s: Failed to re-init WLAN",__func__); |
| 792 | VOS_ASSERT(0); |
| 793 | goto err_reset; |
| 794 | } |
| 795 | pWdContext->resetInProgress = false; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 796 | complete(&pHddCtx->ssr_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 797 | } |
| 798 | else |
| 799 | { |
| 800 | //Unnecessary wakeup - Should never happen!! |
| 801 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 802 | "%s: Watchdog thread woke up unnecessarily",__func__); |
| 803 | } |
| 804 | break; |
| 805 | } // while message loop processing |
| 806 | } // while shutdown |
| 807 | |
| 808 | // If we get here the Watchdog thread must exit |
| 809 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 810 | "%s: Watchdog Thread exiting !!!!", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 811 | complete_and_exit(&pWdContext->WdShutdown, 0); |
| 812 | |
| 813 | err_reset: |
| 814 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 815 | "%s: Watchdog Thread Failed to Reset, Exiting!!!!", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 816 | return 0; |
| 817 | |
| 818 | } /* VosMCThread() */ |
| 819 | |
| 820 | /*--------------------------------------------------------------------------- |
| 821 | \brief VosTXThread() - The VOSS Main Tx thread |
| 822 | The \a VosTxThread() is the VOSS main controller thread: |
| 823 | \param Arg - pointer to the global vOSS Sched Context |
| 824 | |
| 825 | \return Thread exit code |
| 826 | \sa VosTxThread() |
| 827 | -------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 828 | static int VosTXThread ( void * Arg ) |
| 829 | { |
| 830 | pVosSchedContext pSchedContext = (pVosSchedContext)Arg; |
| 831 | pVosMsgWrapper pMsgWrapper = NULL; |
| 832 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 833 | int retWaitStatus = 0; |
| 834 | v_BOOL_t shutdown = VOS_FALSE; |
| 835 | hdd_context_t *pHddCtx = NULL; |
| 836 | v_CONTEXT_t pVosContext = NULL; |
| 837 | |
| 838 | set_user_nice(current, -1); |
Madan Mohan Koyyalamudi | d68ecce | 2012-09-18 19:51:41 -0700 | [diff] [blame] | 839 | |
| 840 | #ifdef WLAN_FEATURE_11AC_HIGH_TP |
Madan Mohan Koyyalamudi | 893c77f | 2012-09-18 19:30:48 -0700 | [diff] [blame] | 841 | set_wake_up_idle(true); |
Madan Mohan Koyyalamudi | d68ecce | 2012-09-18 19:51:41 -0700 | [diff] [blame] | 842 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 843 | |
| 844 | if (Arg == NULL) |
| 845 | { |
| 846 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 847 | "%s Bad Args passed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 848 | return 0; |
| 849 | } |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 850 | |
| 851 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 852 | daemonize("TX_Thread"); |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 853 | #endif |
| 854 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 855 | /* |
| 856 | ** Ack back to the context from which the main controller thread has been |
| 857 | ** created. |
| 858 | */ |
| 859 | complete(&pSchedContext->TxStartEvent); |
| 860 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 861 | "%s: TX Thread %d (%s) starting up!",__func__, current->pid, current->comm); |
| 862 | |
| 863 | /* Get the Global VOSS Context */ |
| 864 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 865 | if(!pVosContext) { |
| 866 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 867 | return 0; |
| 868 | } |
| 869 | |
| 870 | /* Get the HDD context */ |
| 871 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 872 | if(!pHddCtx) { |
| 873 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | |
| 878 | while(!shutdown) |
| 879 | { |
| 880 | // This implements the execution model algorithm |
| 881 | retWaitStatus = wait_event_interruptible(pSchedContext->txWaitQueue, |
| 882 | test_bit(TX_POST_EVENT_MASK, &pSchedContext->txEventFlag) || |
| 883 | test_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag)); |
| 884 | |
| 885 | |
| 886 | if(retWaitStatus == -ERESTARTSYS) |
| 887 | { |
| 888 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 889 | "%s: wait_event_interruptible returned -ERESTARTSYS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 890 | break; |
| 891 | } |
| 892 | clear_bit(TX_POST_EVENT_MASK, &pSchedContext->txEventFlag); |
| 893 | |
| 894 | while(1) |
| 895 | { |
| 896 | if(test_bit(TX_SHUTDOWN_EVENT_MASK, &pSchedContext->txEventFlag)) |
| 897 | { |
| 898 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 899 | "%s: TX thread signaled to shutdown", __func__); |
| 900 | shutdown = VOS_TRUE; |
| 901 | /* Check for any Suspend Indication */ |
| 902 | if(test_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag)) |
| 903 | { |
| 904 | clear_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag); |
| 905 | |
| 906 | /* Unblock anyone waiting on suspend */ |
| 907 | complete(&pHddCtx->tx_sus_event_var); |
| 908 | } |
| 909 | break; |
| 910 | } |
| 911 | // Check the SYS queue first |
| 912 | if (!vos_is_mq_empty(&pSchedContext->sysTxMq)) |
| 913 | { |
| 914 | // Service the SYS message queue |
| 915 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 916 | "%s: Servicing the VOS SYS TX Message queue",__func__); |
| 917 | pMsgWrapper = vos_mq_get(&pSchedContext->sysTxMq); |
| 918 | if (pMsgWrapper == NULL) |
| 919 | { |
| 920 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 921 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 922 | VOS_ASSERT(0); |
| 923 | break; |
| 924 | } |
| 925 | vStatus = sysTxProcessMsg( pSchedContext->pVContext, |
| 926 | pMsgWrapper->pVosMsg); |
| 927 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 928 | { |
| 929 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 930 | "%s: Issue Processing TX SYS message",__func__); |
| 931 | } |
| 932 | // return message to the Core |
| 933 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 934 | continue; |
| 935 | } |
| 936 | // Check now the TL queue |
| 937 | if (!vos_is_mq_empty(&pSchedContext->tlTxMq)) |
| 938 | { |
| 939 | // Service the TL message queue |
| 940 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 941 | "%s: Servicing the VOS TL TX Message queue",__func__); |
| 942 | pMsgWrapper = vos_mq_get(&pSchedContext->tlTxMq); |
| 943 | if (pMsgWrapper == NULL) |
| 944 | { |
| 945 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 946 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 947 | VOS_ASSERT(0); |
| 948 | break; |
| 949 | } |
| 950 | vStatus = WLANTL_TxProcessMsg( pSchedContext->pVContext, |
| 951 | pMsgWrapper->pVosMsg); |
| 952 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 953 | { |
| 954 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 955 | "%s: Issue Processing TX TL message",__func__); |
| 956 | } |
| 957 | // return message to the Core |
| 958 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 959 | continue; |
| 960 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 961 | // Check the WDI queue |
| 962 | if (!vos_is_mq_empty(&pSchedContext->wdiTxMq)) |
| 963 | { |
| 964 | wpt_msg *pWdiMsg; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 965 | pMsgWrapper = vos_mq_get(&pSchedContext->wdiTxMq); |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 966 | |
| 967 | if (pMsgWrapper == NULL) |
| 968 | { |
| 969 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 970 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 971 | VOS_ASSERT(0); |
| 972 | break; |
| 973 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 974 | |
| 975 | pWdiMsg = (wpt_msg *)pMsgWrapper->pVosMsg->bodyptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 976 | |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 977 | if(pWdiMsg == NULL || pWdiMsg->callback == NULL) |
| 978 | { |
| 979 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 980 | "%s: WDI Msg or Callback is NULL", __func__); |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 981 | VOS_ASSERT(0); |
| 982 | break; |
| 983 | } |
| 984 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 985 | pWdiMsg->callback(pWdiMsg); |
| 986 | |
| 987 | // return message to the Core |
| 988 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 989 | |
| 990 | continue; |
| 991 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 992 | /* Check for any Suspend Indication */ |
| 993 | if(test_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag)) |
| 994 | { |
| 995 | clear_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag); |
| 996 | spin_lock(&pSchedContext->TxThreadLock); |
| 997 | |
| 998 | /* Tx Thread Suspended */ |
| 999 | complete(&pHddCtx->tx_sus_event_var); |
| 1000 | |
| 1001 | INIT_COMPLETION(pSchedContext->ResumeTxEvent); |
| 1002 | spin_unlock(&pSchedContext->TxThreadLock); |
| 1003 | |
| 1004 | /* Wait foe Resume Indication */ |
| 1005 | wait_for_completion_interruptible(&pSchedContext->ResumeTxEvent); |
| 1006 | } |
| 1007 | |
| 1008 | break; //All queues are empty now |
| 1009 | } // while message loop processing |
| 1010 | } // while TRUE |
| 1011 | // If we get here the TX thread must exit |
| 1012 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1013 | "%s: TX Thread exiting!!!!", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1014 | complete_and_exit(&pSchedContext->TxShutdown, 0); |
| 1015 | } /* VosTxThread() */ |
| 1016 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1017 | /*--------------------------------------------------------------------------- |
| 1018 | \brief VosRXThread() - The VOSS Main Rx thread |
| 1019 | The \a VosRxThread() is the VOSS Rx controller thread: |
| 1020 | \param Arg - pointer to the global vOSS Sched Context |
| 1021 | |
| 1022 | \return Thread exit code |
| 1023 | \sa VosRxThread() |
| 1024 | -------------------------------------------------------------------------*/ |
| 1025 | |
| 1026 | static int VosRXThread ( void * Arg ) |
| 1027 | { |
| 1028 | pVosSchedContext pSchedContext = (pVosSchedContext)Arg; |
| 1029 | pVosMsgWrapper pMsgWrapper = NULL; |
| 1030 | int retWaitStatus = 0; |
| 1031 | v_BOOL_t shutdown = VOS_FALSE; |
| 1032 | hdd_context_t *pHddCtx = NULL; |
| 1033 | v_CONTEXT_t pVosContext = NULL; |
| 1034 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 1035 | |
| 1036 | set_user_nice(current, -1); |
Madan Mohan Koyyalamudi | d68ecce | 2012-09-18 19:51:41 -0700 | [diff] [blame] | 1037 | |
| 1038 | #ifdef WLAN_FEATURE_11AC_HIGH_TP |
Madan Mohan Koyyalamudi | 893c77f | 2012-09-18 19:30:48 -0700 | [diff] [blame] | 1039 | set_wake_up_idle(true); |
Madan Mohan Koyyalamudi | d68ecce | 2012-09-18 19:51:41 -0700 | [diff] [blame] | 1040 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1041 | |
| 1042 | if (Arg == NULL) |
| 1043 | { |
| 1044 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1045 | "%s Bad Args passed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1046 | return 0; |
| 1047 | } |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 1048 | |
| 1049 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1050 | daemonize("RX_Thread"); |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 1051 | #endif |
| 1052 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1053 | /* |
| 1054 | ** Ack back to the context from which the main controller thread has been |
| 1055 | ** created. |
| 1056 | */ |
| 1057 | complete(&pSchedContext->RxStartEvent); |
| 1058 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 1059 | "%s: RX Thread %d (%s) starting up!",__func__, current->pid, current->comm); |
| 1060 | |
| 1061 | /* Get the Global VOSS Context */ |
| 1062 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 1063 | if(!pVosContext) { |
| 1064 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | /* Get the HDD context */ |
| 1069 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 1070 | if(!pHddCtx) { |
| 1071 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 1072 | return 0; |
| 1073 | } |
| 1074 | |
| 1075 | while(!shutdown) |
| 1076 | { |
| 1077 | // This implements the execution model algorithm |
| 1078 | retWaitStatus = wait_event_interruptible(pSchedContext->rxWaitQueue, |
| 1079 | test_bit(RX_POST_EVENT_MASK, &pSchedContext->rxEventFlag) || |
| 1080 | test_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag)); |
| 1081 | |
| 1082 | |
| 1083 | if(retWaitStatus == -ERESTARTSYS) |
| 1084 | { |
| 1085 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1086 | "%s: wait_event_interruptible returned -ERESTARTSYS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1087 | break; |
| 1088 | } |
| 1089 | clear_bit(RX_POST_EVENT_MASK, &pSchedContext->rxEventFlag); |
| 1090 | |
| 1091 | while(1) |
| 1092 | { |
| 1093 | if(test_bit(RX_SHUTDOWN_EVENT_MASK, &pSchedContext->rxEventFlag)) |
| 1094 | { |
| 1095 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 1096 | "%s: RX thread signaled to shutdown", __func__); |
| 1097 | shutdown = VOS_TRUE; |
| 1098 | /* Check for any Suspend Indication */ |
| 1099 | if(test_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag)) |
| 1100 | { |
| 1101 | clear_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag); |
| 1102 | |
| 1103 | /* Unblock anyone waiting on suspend */ |
| 1104 | complete(&pHddCtx->rx_sus_event_var); |
| 1105 | } |
| 1106 | break; |
| 1107 | } |
| 1108 | |
| 1109 | |
| 1110 | // Check the SYS queue first |
| 1111 | if (!vos_is_mq_empty(&pSchedContext->sysRxMq)) |
| 1112 | { |
| 1113 | // Service the SYS message queue |
| 1114 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 1115 | "%s: Servicing the VOS SYS RX Message queue",__func__); |
| 1116 | pMsgWrapper = vos_mq_get(&pSchedContext->sysRxMq); |
| 1117 | if (pMsgWrapper == NULL) |
| 1118 | { |
| 1119 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1120 | "%s: pMsgWrapper is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1121 | VOS_ASSERT(0); |
| 1122 | break; |
| 1123 | } |
| 1124 | vStatus = sysRxProcessMsg( pSchedContext->pVContext, |
| 1125 | pMsgWrapper->pVosMsg); |
| 1126 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1127 | { |
| 1128 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1129 | "%s: Issue Processing TX SYS message",__func__); |
| 1130 | } |
| 1131 | // return message to the Core |
| 1132 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1133 | continue; |
| 1134 | } |
| 1135 | |
Katya Nigam | 664f503 | 2014-05-05 12:24:32 +0530 | [diff] [blame^] | 1136 | // Check now the TL queue |
| 1137 | if (!vos_is_mq_empty(&pSchedContext->tlRxMq)) |
| 1138 | { |
| 1139 | // Service the TL message queue |
| 1140 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 1141 | "%s: Servicing the VOS TL RX Message queue",__func__); |
| 1142 | pMsgWrapper = vos_mq_get(&pSchedContext->tlRxMq); |
| 1143 | if (pMsgWrapper == NULL) |
| 1144 | { |
| 1145 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1146 | "%s: pMsgWrapper is NULL", __func__); |
| 1147 | VOS_ASSERT(0); |
| 1148 | break; |
| 1149 | } |
| 1150 | vStatus = WLANTL_RxProcessMsg( pSchedContext->pVContext, |
| 1151 | pMsgWrapper->pVosMsg); |
| 1152 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1153 | { |
| 1154 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1155 | "%s: Issue Processing RX TL message",__func__); |
| 1156 | } |
| 1157 | // return message to the Core |
| 1158 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1159 | continue; |
| 1160 | } |
| 1161 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1162 | // Check the WDI queue |
| 1163 | if (!vos_is_mq_empty(&pSchedContext->wdiRxMq)) |
| 1164 | { |
| 1165 | wpt_msg *pWdiMsg; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1166 | pMsgWrapper = vos_mq_get(&pSchedContext->wdiRxMq); |
| 1167 | if ((NULL == pMsgWrapper) || (NULL == pMsgWrapper->pVosMsg)) |
| 1168 | { |
| 1169 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1170 | "%s: wdiRxMq message is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1171 | VOS_ASSERT(0); |
| 1172 | // we won't return this wrapper since it is corrupt |
| 1173 | } |
| 1174 | else |
| 1175 | { |
| 1176 | pWdiMsg = (wpt_msg *)pMsgWrapper->pVosMsg->bodyptr; |
| 1177 | if ((NULL == pWdiMsg) || (NULL == pWdiMsg->callback)) |
| 1178 | { |
| 1179 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1180 | "%s: WDI Msg or callback is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1181 | VOS_ASSERT(0); |
| 1182 | } |
| 1183 | else |
| 1184 | { |
| 1185 | // invoke the message handler |
| 1186 | pWdiMsg->callback(pWdiMsg); |
| 1187 | } |
| 1188 | |
| 1189 | // return message to the Core |
| 1190 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1191 | } |
| 1192 | continue; |
| 1193 | } |
| 1194 | |
| 1195 | /* Check for any Suspend Indication */ |
| 1196 | if(test_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag)) |
| 1197 | { |
| 1198 | clear_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag); |
| 1199 | spin_lock(&pSchedContext->RxThreadLock); |
| 1200 | |
| 1201 | /* Rx Thread Suspended */ |
| 1202 | complete(&pHddCtx->rx_sus_event_var); |
| 1203 | |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 1204 | INIT_COMPLETION(pSchedContext->ResumeRxEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1205 | spin_unlock(&pSchedContext->RxThreadLock); |
| 1206 | |
| 1207 | /* Wait for Resume Indication */ |
| 1208 | wait_for_completion_interruptible(&pSchedContext->ResumeRxEvent); |
| 1209 | } |
| 1210 | |
| 1211 | break; //All queues are empty now |
| 1212 | } // while message loop processing |
| 1213 | } // while TRUE |
| 1214 | // If we get here the RX thread must exit |
| 1215 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1216 | "%s: RX Thread exiting!!!!", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1217 | complete_and_exit(&pSchedContext->RxShutdown, 0); |
| 1218 | } /* VosRxThread() */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1219 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1220 | /*--------------------------------------------------------------------------- |
| 1221 | \brief vos_sched_close() - Close the vOSS Scheduler |
| 1222 | The \a vos_sched_closes() function closes the vOSS Scheduler |
| 1223 | Upon successful closing: |
| 1224 | - All the message queues are flushed |
| 1225 | - The Main Controller thread is closed |
| 1226 | - The Tx thread is closed |
| 1227 | |
| 1228 | \param pVosContext - pointer to the global vOSS Context |
| 1229 | \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and |
| 1230 | is ready to be used. |
| 1231 | VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open |
| 1232 | function |
| 1233 | VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/ |
| 1234 | \sa vos_sched_close() |
| 1235 | ---------------------------------------------------------------------------*/ |
| 1236 | VOS_STATUS vos_sched_close ( v_PVOID_t pVosContext ) |
| 1237 | { |
| 1238 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1239 | "%s: invoked", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1240 | if (gpVosSchedContext == NULL) |
| 1241 | { |
| 1242 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 1243 | "%s: gpVosSchedContext == NULL",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1244 | return VOS_STATUS_E_FAILURE; |
| 1245 | } |
| 1246 | |
| 1247 | // shut down MC Thread |
| 1248 | set_bit(MC_SHUTDOWN_EVENT_MASK, &gpVosSchedContext->mcEventFlag); |
| 1249 | set_bit(MC_POST_EVENT_MASK, &gpVosSchedContext->mcEventFlag); |
| 1250 | wake_up_interruptible(&gpVosSchedContext->mcWaitQueue); |
| 1251 | //Wait for MC to exit |
Mihir Shete | de20c47 | 2013-11-28 11:02:38 +0530 | [diff] [blame] | 1252 | wait_for_completion(&gpVosSchedContext->McShutdown); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1253 | gpVosSchedContext->McThread = 0; |
| 1254 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1255 | // shut down TX Thread |
| 1256 | set_bit(TX_SHUTDOWN_EVENT_MASK, &gpVosSchedContext->txEventFlag); |
| 1257 | set_bit(TX_POST_EVENT_MASK, &gpVosSchedContext->txEventFlag); |
| 1258 | wake_up_interruptible(&gpVosSchedContext->txWaitQueue); |
| 1259 | //Wait for TX to exit |
Mihir Shete | de20c47 | 2013-11-28 11:02:38 +0530 | [diff] [blame] | 1260 | wait_for_completion(&gpVosSchedContext->TxShutdown); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1261 | gpVosSchedContext->TxThread = 0; |
| 1262 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1263 | // shut down RX Thread |
| 1264 | set_bit(RX_SHUTDOWN_EVENT_MASK, &gpVosSchedContext->rxEventFlag); |
| 1265 | set_bit(RX_POST_EVENT_MASK, &gpVosSchedContext->rxEventFlag); |
| 1266 | wake_up_interruptible(&gpVosSchedContext->rxWaitQueue); |
| 1267 | //Wait for RX to exit |
Mihir Shete | de20c47 | 2013-11-28 11:02:38 +0530 | [diff] [blame] | 1268 | wait_for_completion(&gpVosSchedContext->RxShutdown); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1269 | gpVosSchedContext->RxThread = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1270 | |
| 1271 | //Clean up message queues of TX and MC thread |
| 1272 | vos_sched_flush_mc_mqs(gpVosSchedContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1273 | vos_sched_flush_tx_mqs(gpVosSchedContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1274 | vos_sched_flush_rx_mqs(gpVosSchedContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1275 | |
| 1276 | //Deinit all the queues |
| 1277 | vos_sched_deinit_mqs(gpVosSchedContext); |
| 1278 | |
| 1279 | return VOS_STATUS_SUCCESS; |
| 1280 | } /* vox_sched_close() */ |
| 1281 | |
| 1282 | VOS_STATUS vos_watchdog_close ( v_PVOID_t pVosContext ) |
| 1283 | { |
| 1284 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1285 | "%s: vos_watchdog closing now", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1286 | if (gpVosWatchdogContext == NULL) |
| 1287 | { |
| 1288 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 1289 | "%s: gpVosWatchdogContext is NULL",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1290 | return VOS_STATUS_E_FAILURE; |
| 1291 | } |
| 1292 | set_bit(WD_SHUTDOWN_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag); |
| 1293 | set_bit(WD_POST_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag); |
| 1294 | wake_up_interruptible(&gpVosWatchdogContext->wdWaitQueue); |
| 1295 | //Wait for Watchdog thread to exit |
Mihir Shete | de20c47 | 2013-11-28 11:02:38 +0530 | [diff] [blame] | 1296 | wait_for_completion(&gpVosWatchdogContext->WdShutdown); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1297 | return VOS_STATUS_SUCCESS; |
| 1298 | } /* vos_watchdog_close() */ |
| 1299 | |
| 1300 | VOS_STATUS vos_watchdog_chip_reset ( vos_chip_reset_reason_type reason ) |
| 1301 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1302 | return VOS_STATUS_SUCCESS; |
| 1303 | } /* vos_watchdog_chip_reset() */ |
| 1304 | |
| 1305 | /*--------------------------------------------------------------------------- |
| 1306 | \brief vos_sched_init_mqs: Initialize the vOSS Scheduler message queues |
| 1307 | The \a vos_sched_init_mqs() function initializes the vOSS Scheduler |
| 1308 | message queues. |
| 1309 | \param pVosSchedContext - pointer to the Scheduler Context. |
| 1310 | \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and |
| 1311 | is ready to be used. |
| 1312 | VOS_STATUS_E_RESOURCES - System resources (other than memory) |
| 1313 | are unavailable to initilize the scheduler |
| 1314 | |
| 1315 | \sa vos_sched_init_mqs() |
| 1316 | -------------------------------------------------------------------------*/ |
| 1317 | VOS_STATUS vos_sched_init_mqs ( pVosSchedContext pSchedContext ) |
| 1318 | { |
| 1319 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 1320 | // Now intialize all the message queues |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1321 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1322 | "%s: Initializing the WDA MC Message queue",__func__); |
| 1323 | vStatus = vos_mq_init(&pSchedContext->wdaMcMq); |
| 1324 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1325 | { |
| 1326 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1327 | "%s: Failed to init WDA MC Message queue",__func__); |
| 1328 | VOS_ASSERT(0); |
| 1329 | return vStatus; |
| 1330 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1331 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1332 | "%s: Initializing the PE MC Message queue",__func__); |
| 1333 | vStatus = vos_mq_init(&pSchedContext->peMcMq); |
| 1334 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1335 | { |
| 1336 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1337 | "%s: Failed to init PE MC Message queue",__func__); |
| 1338 | VOS_ASSERT(0); |
| 1339 | return vStatus; |
| 1340 | } |
| 1341 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1342 | "%s: Initializing the SME MC Message queue", __func__); |
| 1343 | vStatus = vos_mq_init(&pSchedContext->smeMcMq); |
| 1344 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1345 | { |
| 1346 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1347 | "%s: Failed to init SME MC Message queue",__func__); |
| 1348 | VOS_ASSERT(0); |
| 1349 | return vStatus; |
| 1350 | } |
| 1351 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1352 | "%s: Initializing the TL MC Message queue",__func__); |
| 1353 | vStatus = vos_mq_init(&pSchedContext->tlMcMq); |
| 1354 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1355 | { |
| 1356 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1357 | "%s: Failed to init TL MC Message queue",__func__); |
| 1358 | VOS_ASSERT(0); |
| 1359 | return vStatus; |
| 1360 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1361 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1362 | "%s: Initializing the SYS MC Message queue",__func__); |
| 1363 | vStatus = vos_mq_init(&pSchedContext->sysMcMq); |
| 1364 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1365 | { |
| 1366 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1367 | "%s: Failed to init SYS MC Message queue",__func__); |
| 1368 | VOS_ASSERT(0); |
| 1369 | return vStatus; |
| 1370 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1371 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1372 | "%s: Initializing the WDI MC Message queue",__func__); |
| 1373 | |
| 1374 | vStatus = vos_mq_init(&pSchedContext->wdiMcMq); |
| 1375 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1376 | { |
| 1377 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1378 | "%s: Failed to init WDI MC Message queue",__func__); |
| 1379 | VOS_ASSERT(0); |
| 1380 | return vStatus; |
| 1381 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1382 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1383 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1384 | "%s: Initializing the TL Tx Message queue",__func__); |
| 1385 | vStatus = vos_mq_init(&pSchedContext->tlTxMq); |
| 1386 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1387 | { |
| 1388 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1389 | "%s: Failed to init TL TX Message queue",__func__); |
| 1390 | VOS_ASSERT(0); |
| 1391 | return vStatus; |
| 1392 | } |
Katya Nigam | 664f503 | 2014-05-05 12:24:32 +0530 | [diff] [blame^] | 1393 | |
| 1394 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1395 | "%s: Initializing the TL Rx Message queue",__func__); |
| 1396 | vStatus = vos_mq_init(&pSchedContext->tlRxMq); |
| 1397 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1398 | { |
| 1399 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1400 | "%s: Failed to init TL RX Message queue",__func__); |
| 1401 | VOS_ASSERT(0); |
| 1402 | return vStatus; |
| 1403 | } |
| 1404 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1405 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1406 | "%s: Initializing the WDI Tx Message queue",__func__); |
| 1407 | vStatus = vos_mq_init(&pSchedContext->wdiTxMq); |
| 1408 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1409 | { |
| 1410 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1411 | "%s: Failed to init WDI TX Message queue",__func__); |
| 1412 | VOS_ASSERT(0); |
| 1413 | return vStatus; |
| 1414 | } |
| 1415 | |
| 1416 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1417 | "%s: Initializing the WDI Rx Message queue",__func__); |
| 1418 | |
| 1419 | vStatus = vos_mq_init(&pSchedContext->wdiRxMq); |
| 1420 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1421 | { |
| 1422 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1423 | "%s: Failed to init WDI RX Message queue",__func__); |
| 1424 | VOS_ASSERT(0); |
| 1425 | return vStatus; |
| 1426 | } |
| 1427 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1428 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1429 | "%s: Initializing the SYS Tx Message queue",__func__); |
| 1430 | vStatus = vos_mq_init(&pSchedContext->sysTxMq); |
| 1431 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1432 | { |
| 1433 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1434 | "%s: Failed to init SYS TX Message queue",__func__); |
| 1435 | VOS_ASSERT(0); |
| 1436 | return vStatus; |
| 1437 | } |
| 1438 | |
| 1439 | vStatus = vos_mq_init(&pSchedContext->sysRxMq); |
| 1440 | if (! VOS_IS_STATUS_SUCCESS(vStatus)) |
| 1441 | { |
| 1442 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1443 | "%s: Failed to init SYS RX Message queue",__func__); |
| 1444 | VOS_ASSERT(0); |
| 1445 | return vStatus; |
| 1446 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1447 | return VOS_STATUS_SUCCESS; |
| 1448 | } /* vos_sched_init_mqs() */ |
| 1449 | |
| 1450 | /*--------------------------------------------------------------------------- |
| 1451 | \brief vos_sched_deinit_mqs: Deinitialize the vOSS Scheduler message queues |
| 1452 | The \a vos_sched_init_mqs() function deinitializes the vOSS Scheduler |
| 1453 | message queues. |
| 1454 | \param pVosSchedContext - pointer to the Scheduler Context. |
| 1455 | \return None |
| 1456 | \sa vos_sched_deinit_mqs() |
| 1457 | -------------------------------------------------------------------------*/ |
| 1458 | void vos_sched_deinit_mqs ( pVosSchedContext pSchedContext ) |
| 1459 | { |
| 1460 | // Now de-intialize all message queues |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1461 | // MC WDA |
| 1462 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1463 | "%s De-Initializing the WDA MC Message queue",__func__); |
| 1464 | vos_mq_deinit(&pSchedContext->wdaMcMq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1465 | //MC PE |
| 1466 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1467 | "%s De-Initializing the PE MC Message queue",__func__); |
| 1468 | vos_mq_deinit(&pSchedContext->peMcMq); |
| 1469 | //MC SME |
| 1470 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1471 | "%s De-Initializing the SME MC Message queue",__func__); |
| 1472 | vos_mq_deinit(&pSchedContext->smeMcMq); |
| 1473 | //MC TL |
| 1474 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1475 | "%s De-Initializing the TL MC Message queue",__func__); |
| 1476 | vos_mq_deinit(&pSchedContext->tlMcMq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1477 | //MC SYS |
| 1478 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1479 | "%s De-Initializing the SYS MC Message queue",__func__); |
| 1480 | vos_mq_deinit(&pSchedContext->sysMcMq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1481 | // MC WDI |
| 1482 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1483 | "%s De-Initializing the WDI MC Message queue",__func__); |
| 1484 | vos_mq_deinit(&pSchedContext->wdiMcMq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1485 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1486 | //Tx TL |
| 1487 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1488 | "%s De-Initializing the TL Tx Message queue",__func__); |
| 1489 | vos_mq_deinit(&pSchedContext->tlTxMq); |
Katya Nigam | 664f503 | 2014-05-05 12:24:32 +0530 | [diff] [blame^] | 1490 | |
| 1491 | //Rx TL |
| 1492 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1493 | "%s De-Initializing the TL Rx Message queue",__func__); |
| 1494 | vos_mq_deinit(&pSchedContext->tlRxMq); |
| 1495 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1496 | //Tx WDI |
| 1497 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1498 | "%s: DeInitializing the WDI Tx Message queue",__func__); |
| 1499 | vos_mq_deinit(&pSchedContext->wdiTxMq); |
| 1500 | |
| 1501 | |
| 1502 | //Rx WDI |
| 1503 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1504 | "%s: DeInitializing the WDI Rx Message queue",__func__); |
| 1505 | vos_mq_deinit(&pSchedContext->wdiRxMq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1506 | |
| 1507 | //Tx SYS |
| 1508 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1509 | "%s: DeInitializing the SYS Tx Message queue",__func__); |
| 1510 | vos_mq_deinit(&pSchedContext->sysTxMq); |
| 1511 | |
| 1512 | //Rx SYS |
| 1513 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1514 | "%s: DeInitializing the SYS Rx Message queue",__func__); |
| 1515 | vos_mq_deinit(&pSchedContext->sysRxMq); |
| 1516 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1517 | } /* vos_sched_deinit_mqs() */ |
| 1518 | |
| 1519 | /*------------------------------------------------------------------------- |
| 1520 | this helper function flushes all the MC message queues |
| 1521 | -------------------------------------------------------------------------*/ |
| 1522 | void vos_sched_flush_mc_mqs ( pVosSchedContext pSchedContext ) |
| 1523 | { |
| 1524 | pVosMsgWrapper pMsgWrapper = NULL; |
| 1525 | pVosContextType vosCtx; |
| 1526 | |
| 1527 | /* |
| 1528 | ** Here each of the MC thread MQ shall be drained and returned to the |
| 1529 | ** Core. Before returning a wrapper to the Core, the VOS message shall be |
| 1530 | ** freed first |
| 1531 | */ |
| 1532 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1533 | VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 1534 | ("Flushing the MC Thread message queue") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1535 | |
| 1536 | if (NULL == pSchedContext) |
| 1537 | { |
| 1538 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1539 | "%s: pSchedContext is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1540 | return; |
| 1541 | } |
| 1542 | |
| 1543 | vosCtx = (pVosContextType)(pSchedContext->pVContext); |
| 1544 | if (NULL == vosCtx) |
| 1545 | { |
| 1546 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1547 | "%s: vosCtx is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1548 | return; |
| 1549 | } |
| 1550 | |
| 1551 | /* Flush the SYS Mq */ |
| 1552 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->sysMcMq) )) |
| 1553 | { |
| 1554 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1555 | VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1556 | "%s: Freeing MC SYS message type %d ",__func__, |
| 1557 | pMsgWrapper->pVosMsg->type ); |
| 1558 | sysMcFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1559 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1560 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1561 | /* Flush the WDA Mq */ |
| 1562 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdaMcMq) )) |
| 1563 | { |
| 1564 | if(pMsgWrapper->pVosMsg != NULL) |
| 1565 | { |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1566 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1567 | "%s: Freeing MC WDA MSG message type %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1568 | __func__, pMsgWrapper->pVosMsg->type ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1569 | if (pMsgWrapper->pVosMsg->bodyptr) { |
| 1570 | vos_mem_free((v_VOID_t*)pMsgWrapper->pVosMsg->bodyptr); |
| 1571 | } |
| 1572 | |
| 1573 | pMsgWrapper->pVosMsg->bodyptr = NULL; |
| 1574 | pMsgWrapper->pVosMsg->bodyval = 0; |
| 1575 | pMsgWrapper->pVosMsg->type = 0; |
| 1576 | } |
| 1577 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1578 | } |
| 1579 | |
| 1580 | /* Flush the WDI Mq */ |
| 1581 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdiMcMq) )) |
| 1582 | { |
| 1583 | if(pMsgWrapper->pVosMsg != NULL) |
| 1584 | { |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1585 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1586 | "%s: Freeing MC WDI MSG message type %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1587 | __func__, pMsgWrapper->pVosMsg->type ); |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1588 | |
| 1589 | /* MSG body pointer is not NULL |
| 1590 | * and MSG type is 0 |
| 1591 | * This MSG is not posted by SMD NOTIFY |
| 1592 | * We have to free MSG body */ |
| 1593 | if ((pMsgWrapper->pVosMsg->bodyptr) && (!pMsgWrapper->pVosMsg->type)) |
| 1594 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1595 | vos_mem_free((v_VOID_t*)pMsgWrapper->pVosMsg->bodyptr); |
| 1596 | } |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1597 | /* MSG body pointer is not NULL |
| 1598 | * and MSG type is not 0 |
| 1599 | * This MSG is posted by SMD NOTIFY |
| 1600 | * We should not free MSG body */ |
| 1601 | else if ((pMsgWrapper->pVosMsg->bodyptr) && pMsgWrapper->pVosMsg->type) |
| 1602 | { |
| 1603 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1604 | "%s: SMD NOTIFY MSG, do not free body", |
| 1605 | __func__); |
| 1606 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1607 | pMsgWrapper->pVosMsg->bodyptr = NULL; |
| 1608 | pMsgWrapper->pVosMsg->bodyval = 0; |
| 1609 | pMsgWrapper->pVosMsg->type = 0; |
| 1610 | } |
| 1611 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1612 | } |
| 1613 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1614 | /* Flush the PE Mq */ |
| 1615 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->peMcMq) )) |
| 1616 | { |
| 1617 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1618 | VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1619 | "%s: Freeing MC PE MSG message type %d",__func__, |
| 1620 | pMsgWrapper->pVosMsg->type ); |
| 1621 | peFreeMsg(vosCtx->pMACContext, (tSirMsgQ*)pMsgWrapper->pVosMsg); |
| 1622 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1623 | } |
| 1624 | /* Flush the SME Mq */ |
| 1625 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->smeMcMq) )) |
| 1626 | { |
| 1627 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1628 | VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1629 | "%s: Freeing MC SME MSG message type %d", __func__, |
| 1630 | pMsgWrapper->pVosMsg->type ); |
| 1631 | sme_FreeMsg(vosCtx->pMACContext, pMsgWrapper->pVosMsg); |
| 1632 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1633 | } |
| 1634 | /* Flush the TL Mq */ |
| 1635 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->tlMcMq) )) |
| 1636 | { |
| 1637 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
Leo Chang | 0f24ca1 | 2013-12-17 13:35:00 -0800 | [diff] [blame] | 1638 | VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1639 | "%s: Freeing MC TL message type %d",__func__, |
| 1640 | pMsgWrapper->pVosMsg->type ); |
| 1641 | WLANTL_McFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1642 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1643 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1644 | } /* vos_sched_flush_mc_mqs() */ |
| 1645 | |
| 1646 | /*------------------------------------------------------------------------- |
| 1647 | This helper function flushes all the TX message queues |
| 1648 | ------------------------------------------------------------------------*/ |
| 1649 | void vos_sched_flush_tx_mqs ( pVosSchedContext pSchedContext ) |
| 1650 | { |
| 1651 | pVosMsgWrapper pMsgWrapper = NULL; |
| 1652 | /* |
| 1653 | ** Here each of the TX thread MQ shall be drained and returned to the |
| 1654 | ** Core. Before returning a wrapper to the Core, the VOS message shall |
| 1655 | ** be freed first |
| 1656 | */ |
| 1657 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1658 | VOS_TRACE_LEVEL_INFO, |
| 1659 | "%s: Flushing the TX Thread message queue",__func__); |
| 1660 | |
| 1661 | if (NULL == pSchedContext) |
| 1662 | { |
| 1663 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1664 | "%s: pSchedContext is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1665 | return; |
| 1666 | } |
| 1667 | |
| 1668 | /* Flush the SYS Mq */ |
| 1669 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->sysTxMq) )) |
| 1670 | { |
| 1671 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1672 | VOS_TRACE_LEVEL_INFO, |
| 1673 | "%s: Freeing TX SYS message type %d",__func__, |
| 1674 | pMsgWrapper->pVosMsg->type ); |
| 1675 | sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1676 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1677 | } |
| 1678 | /* Flush the TL Mq */ |
| 1679 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->tlTxMq) )) |
| 1680 | { |
| 1681 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1682 | VOS_TRACE_LEVEL_INFO, |
| 1683 | "%s: Freeing TX TL MSG message type %d",__func__, |
| 1684 | pMsgWrapper->pVosMsg->type ); |
| 1685 | WLANTL_TxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1686 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1687 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1688 | /* Flush the WDI Mq */ |
| 1689 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdiTxMq) )) |
| 1690 | { |
| 1691 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1692 | VOS_TRACE_LEVEL_INFO, |
| 1693 | "%s: Freeing TX WDI MSG message type %d",__func__, |
| 1694 | pMsgWrapper->pVosMsg->type ); |
| 1695 | sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1696 | vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper); |
| 1697 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1698 | } /* vos_sched_flush_tx_mqs() */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1699 | /*------------------------------------------------------------------------- |
| 1700 | This helper function flushes all the RX message queues |
| 1701 | ------------------------------------------------------------------------*/ |
| 1702 | void vos_sched_flush_rx_mqs ( pVosSchedContext pSchedContext ) |
| 1703 | { |
| 1704 | pVosMsgWrapper pMsgWrapper = NULL; |
| 1705 | /* |
| 1706 | ** Here each of the RX thread MQ shall be drained and returned to the |
| 1707 | ** Core. Before returning a wrapper to the Core, the VOS message shall |
| 1708 | ** be freed first |
| 1709 | */ |
| 1710 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1711 | VOS_TRACE_LEVEL_INFO, |
| 1712 | "%s: Flushing the RX Thread message queue",__func__); |
| 1713 | |
| 1714 | if (NULL == pSchedContext) |
| 1715 | { |
| 1716 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1717 | "%s: pSchedContext is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1718 | return; |
| 1719 | } |
| 1720 | |
| 1721 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdiRxMq) )) |
| 1722 | { |
| 1723 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1724 | VOS_TRACE_LEVEL_INFO, |
| 1725 | "%s: Freeing RX WDI MSG message type %d",__func__, |
| 1726 | pMsgWrapper->pVosMsg->type ); |
| 1727 | sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1728 | } |
| 1729 | |
Katya Nigam | 664f503 | 2014-05-05 12:24:32 +0530 | [diff] [blame^] | 1730 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->tlRxMq) )) |
| 1731 | { |
| 1732 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1733 | VOS_TRACE_LEVEL_INFO, |
| 1734 | "%s: Freeing RX TL MSG message type %d",__func__, |
| 1735 | pMsgWrapper->pVosMsg->type ); |
| 1736 | sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1737 | } |
| 1738 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1739 | while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->sysRxMq) )) |
| 1740 | { |
| 1741 | VOS_TRACE( VOS_MODULE_ID_VOSS, |
| 1742 | VOS_TRACE_LEVEL_INFO, |
| 1743 | "%s: Freeing RX SYS MSG message type %d",__func__, |
| 1744 | pMsgWrapper->pVosMsg->type ); |
| 1745 | sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg); |
| 1746 | } |
| 1747 | |
| 1748 | }/* vos_sched_flush_rx_mqs() */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1749 | |
| 1750 | /*------------------------------------------------------------------------- |
| 1751 | This helper function helps determine if thread id is of TX thread |
| 1752 | ------------------------------------------------------------------------*/ |
| 1753 | int vos_sched_is_tx_thread(int threadID) |
| 1754 | { |
| 1755 | // Make sure that Vos Scheduler context has been initialized |
| 1756 | VOS_ASSERT( NULL != gpVosSchedContext); |
| 1757 | if (gpVosSchedContext == NULL) |
| 1758 | { |
| 1759 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1760 | "%s: gpVosSchedContext == NULL",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1761 | return 0; |
| 1762 | } |
| 1763 | return ((gpVosSchedContext->TxThread) && (threadID == gpVosSchedContext->TxThread->pid)); |
| 1764 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1765 | /*------------------------------------------------------------------------- |
| 1766 | This helper function helps determine if thread id is of RX thread |
| 1767 | ------------------------------------------------------------------------*/ |
| 1768 | int vos_sched_is_rx_thread(int threadID) |
| 1769 | { |
| 1770 | // Make sure that Vos Scheduler context has been initialized |
| 1771 | VOS_ASSERT( NULL != gpVosSchedContext); |
| 1772 | if (gpVosSchedContext == NULL) |
| 1773 | { |
| 1774 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1775 | "%s: gpVosSchedContext == NULL",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1776 | return 0; |
| 1777 | } |
| 1778 | return ((gpVosSchedContext->RxThread) && (threadID == gpVosSchedContext->RxThread->pid)); |
| 1779 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1780 | /*------------------------------------------------------------------------- |
| 1781 | Helper function to get the scheduler context |
| 1782 | ------------------------------------------------------------------------*/ |
| 1783 | pVosSchedContext get_vos_sched_ctxt(void) |
| 1784 | { |
| 1785 | //Make sure that Vos Scheduler context has been initialized |
| 1786 | if (gpVosSchedContext == NULL) |
| 1787 | { |
| 1788 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1789 | "%s: gpVosSchedContext == NULL",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1790 | } |
| 1791 | return (gpVosSchedContext); |
| 1792 | } |
| 1793 | /*------------------------------------------------------------------------- |
| 1794 | Helper function to get the watchdog context |
| 1795 | ------------------------------------------------------------------------*/ |
| 1796 | pVosWatchdogContext get_vos_watchdog_ctxt(void) |
| 1797 | { |
| 1798 | //Make sure that Vos Scheduler context has been initialized |
| 1799 | if (gpVosWatchdogContext == NULL) |
| 1800 | { |
| 1801 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1802 | "%s: gpVosWatchdogContext == NULL",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1803 | } |
| 1804 | return (gpVosWatchdogContext); |
| 1805 | } |
| 1806 | /** |
| 1807 | @brief vos_watchdog_wlan_shutdown() |
| 1808 | |
| 1809 | This function is called to shutdown WLAN driver during SSR. |
| 1810 | Adapters are disabled, and the watchdog task will be signalled |
| 1811 | to shutdown WLAN driver. |
| 1812 | |
| 1813 | @param |
| 1814 | NONE |
| 1815 | @return |
| 1816 | VOS_STATUS_SUCCESS - Operation completed successfully. |
| 1817 | VOS_STATUS_E_FAILURE - Operation failed. |
| 1818 | |
| 1819 | */ |
| 1820 | VOS_STATUS vos_watchdog_wlan_shutdown(void) |
| 1821 | { |
| 1822 | v_CONTEXT_t pVosContext = NULL; |
| 1823 | hdd_context_t *pHddCtx = NULL; |
| 1824 | |
| 1825 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1826 | "%s: WLAN driver is shutting down ", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1827 | if (NULL == gpVosWatchdogContext) |
| 1828 | { |
| 1829 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1830 | "%s: Watchdog not enabled. LOGP ignored.", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1831 | return VOS_STATUS_E_FAILURE; |
| 1832 | } |
| 1833 | |
| 1834 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 1835 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 1836 | if (NULL == pHddCtx) |
| 1837 | { |
| 1838 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1839 | "%s: Invalid HDD Context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1840 | return VOS_STATUS_E_FAILURE; |
| 1841 | } |
| 1842 | |
| 1843 | /* Take the lock here */ |
| 1844 | spin_lock(&gpVosWatchdogContext->wdLock); |
| 1845 | |
| 1846 | /* reuse the existing 'reset in progress' */ |
| 1847 | if (gpVosWatchdogContext->resetInProgress) |
| 1848 | { |
| 1849 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 1850 | "%s: Shutdown already in Progress. Ignoring signaling Watchdog", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1851 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1852 | /* Release the lock here */ |
| 1853 | spin_unlock(&gpVosWatchdogContext->wdLock); |
| 1854 | return VOS_STATUS_E_FAILURE; |
| 1855 | } |
| 1856 | /* reuse the existing 'logp in progress', eventhough it is not |
| 1857 | * exactly the same */ |
| 1858 | else if (pHddCtx->isLogpInProgress) |
| 1859 | { |
| 1860 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 1861 | "%s: shutdown/re-init already in Progress. Ignoring signaling Watchdog", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1862 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1863 | /* Release the lock here */ |
| 1864 | spin_unlock(&gpVosWatchdogContext->wdLock); |
| 1865 | return VOS_STATUS_E_FAILURE; |
| 1866 | } |
| 1867 | |
| 1868 | /* Set the flags so that all future CMD53 and Wext commands get blocked right away */ |
| 1869 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
Sameer Thalappil | 9ab2fe5 | 2013-10-22 12:50:24 -0700 | [diff] [blame] | 1870 | vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1871 | pHddCtx->isLogpInProgress = TRUE; |
| 1872 | |
| 1873 | /* Release the lock here */ |
| 1874 | spin_unlock(&gpVosWatchdogContext->wdLock); |
| 1875 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 1876 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1877 | { |
| 1878 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 1879 | "%s: Load/unload in Progress. Ignoring signaling Watchdog", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1880 | __func__); |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 1881 | /* wcnss has crashed, and SSR has alredy been started by Kernel driver. |
| 1882 | * So disable SSR from WLAN driver */ |
| 1883 | hdd_set_ssr_required( HDD_SSR_DISABLED ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1884 | return VOS_STATUS_E_FAILURE; |
| 1885 | } |
| 1886 | /* Update Riva Reset Statistics */ |
| 1887 | pHddCtx->hddRivaResetStats++; |
| 1888 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 1889 | if(VOS_STATUS_SUCCESS != hdd_wlan_reset_initialization()) |
| 1890 | { |
| 1891 | VOS_ASSERT(0); |
| 1892 | } |
| 1893 | #endif |
| 1894 | |
| 1895 | set_bit(WD_WLAN_SHUTDOWN_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag); |
| 1896 | set_bit(WD_POST_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag); |
| 1897 | wake_up_interruptible(&gpVosWatchdogContext->wdWaitQueue); |
| 1898 | |
| 1899 | return VOS_STATUS_SUCCESS; |
| 1900 | } |
| 1901 | |
| 1902 | /** |
| 1903 | @brief vos_watchdog_wlan_re_init() |
| 1904 | |
| 1905 | This function is called to re-initialize WLAN driver, and this is |
| 1906 | called when Riva SS reboots. |
| 1907 | |
| 1908 | @param |
| 1909 | NONE |
| 1910 | @return |
| 1911 | VOS_STATUS_SUCCESS - Operation completed successfully. |
| 1912 | VOS_STATUS_E_FAILURE - Operation failed. |
| 1913 | |
| 1914 | */ |
| 1915 | VOS_STATUS vos_watchdog_wlan_re_init(void) |
| 1916 | { |
| 1917 | /* watchdog task is still running, it is not closed in shutdown */ |
| 1918 | set_bit(WD_WLAN_REINIT_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag); |
| 1919 | set_bit(WD_POST_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag); |
| 1920 | wake_up_interruptible(&gpVosWatchdogContext->wdWaitQueue); |
| 1921 | |
| 1922 | return VOS_STATUS_SUCCESS; |
| 1923 | } |
Mahesh A Saptasagar | 96395ab | 2014-04-08 12:48:39 +0530 | [diff] [blame] | 1924 | |
| 1925 | /** |
| 1926 | @brief vos_ssr_protect() |
| 1927 | |
| 1928 | This function is called to keep track of active driver entry points |
| 1929 | |
| 1930 | @param |
| 1931 | caller_func - Name of calling function. |
| 1932 | @return |
| 1933 | void |
| 1934 | */ |
| 1935 | void vos_ssr_protect(const char *caller_func) |
| 1936 | { |
| 1937 | int count; |
| 1938 | count = atomic_inc_return(&ssr_protect_entry_count); |
| 1939 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1940 | "%s: ENTRY ACTIVE %d", caller_func, count); |
| 1941 | } |
| 1942 | |
| 1943 | /** |
| 1944 | @brief vos_ssr_unprotect() |
| 1945 | |
| 1946 | @param |
| 1947 | caller_func - Name of calling function. |
| 1948 | @return |
| 1949 | void |
| 1950 | */ |
| 1951 | void vos_ssr_unprotect(const char *caller_func) |
| 1952 | { |
| 1953 | int count; |
| 1954 | count = atomic_dec_return(&ssr_protect_entry_count); |
| 1955 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1956 | "%s: ENTRY INACTIVE %d", caller_func, count); |
| 1957 | } |