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