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