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