blob: eb5b14ba144c80f0a2c5b5e3ecaac50dce14b165 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/*===========================================================================
7 @file vos_sched.c
8 @brief VOS Scheduler Implementation
9
10 Copyright (c) 2011 QUALCOMM Incorporated.
11 All Rights Reserved.
12 Qualcomm Confidential and Proprietary
13===========================================================================*/
14/*===========================================================================
15 EDIT HISTORY FOR FILE
16
17 This section contains comments describing changes made to the module.
18 Notice that changes are listed in reverse chronological order.
19
20 $Header:$ $DateTime: $ $Author: $
21
22 when who what, where, why
23 -------- --- --------------------------------------------------------
24===========================================================================*/
25/*---------------------------------------------------------------------------
26 * Include Files
27 * ------------------------------------------------------------------------*/
28#include <vos_mq.h>
29#include <vos_api.h>
30#include <aniGlobal.h>
31#include <sirTypes.h>
32#include <halTypes.h>
33#include <limApi.h>
34#include <sme_Api.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070035#include <wlan_qct_sys.h>
36#include <wlan_qct_tl.h>
37#include "vos_sched.h"
38#include <wlan_hdd_power.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070039#include "wlan_qct_wda.h"
40#include "wlan_qct_pal_msg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070041#include <linux/spinlock.h>
42#include <linux/kthread.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*---------------------------------------------------------------------------
44 * Preprocessor Definitions and Constants
45 * ------------------------------------------------------------------------*/
46#define VOS_SCHED_THREAD_HEART_BEAT INFINITE
47/*---------------------------------------------------------------------------
48 * Type Declarations
49 * ------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------
51 * Data definitions
52 * ------------------------------------------------------------------------*/
53static pVosSchedContext gpVosSchedContext;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -070054static pVosWatchdogContext gpVosWatchdogContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56/*---------------------------------------------------------------------------
57 * Forward declaration
58 * ------------------------------------------------------------------------*/
Jeff Johnson2f5cfec2013-02-22 21:25:10 -080059static int VosMCThread(void *Arg);
60static int VosWDThread(void *Arg);
61static int VosTXThread(void *Arg);
62static int VosRXThread(void *Arg);
Jeff Johnson295189b2012-06-20 16:38:30 -070063void vos_sched_flush_rx_mqs(pVosSchedContext SchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070064extern v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
65/*---------------------------------------------------------------------------
66 * External Function implementation
67 * ------------------------------------------------------------------------*/
68
69/*---------------------------------------------------------------------------
70 \brief vos_sched_open() - initialize the vOSS Scheduler
71 The \a vos_sched_open() function initializes the vOSS Scheduler
72 Upon successful initialization:
73 - All the message queues are initialized
74 - The Main Controller thread is created and ready to receive and
75 dispatch messages.
76 - The Tx thread is created and ready to receive and dispatch messages
77
78 \param pVosContext - pointer to the global vOSS Context
79 \param pVosSchedContext - pointer to a previously allocated buffer big
80 enough to hold a scheduler context.
81 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
82 is ready to be used.
83 VOS_STATUS_E_RESOURCES - System resources (other than memory)
84 are unavailable to initilize the scheduler
85 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
86 the scheduler
87 VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open
88 function
89 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
90 \sa vos_sched_open()
91 -------------------------------------------------------------------------*/
92VOS_STATUS
93vos_sched_open
94(
95 v_PVOID_t pVosContext,
96 pVosSchedContext pSchedContext,
97 v_SIZE_t SchedCtxSize
98)
99{
100 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
101/*-------------------------------------------------------------------------*/
102 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
103 "%s: Opening the VOSS Scheduler",__func__);
104 // Sanity checks
105 if ((pVosContext == NULL) || (pSchedContext == NULL)) {
106 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
107 "%s: Null params being passed",__func__);
108 return VOS_STATUS_E_FAILURE;
109 }
110 if (sizeof(VosSchedContext) != SchedCtxSize)
111 {
112 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
113 "%s: Incorrect VOS Sched Context size passed",__func__);
114 return VOS_STATUS_E_INVAL;
115 }
116 vos_mem_zero(pSchedContext, sizeof(VosSchedContext));
117 pSchedContext->pVContext = pVosContext;
118 vStatus = vos_sched_init_mqs(pSchedContext);
119 if (!VOS_IS_STATUS_SUCCESS(vStatus))
120 {
121 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
122 "%s: Failed to initialize VOS Scheduler MQs",__func__);
123 return vStatus;
124 }
125 // Initialize the helper events and event queues
126 init_completion(&pSchedContext->McStartEvent);
127 init_completion(&pSchedContext->TxStartEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 init_completion(&pSchedContext->RxStartEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 init_completion(&pSchedContext->McShutdown);
130 init_completion(&pSchedContext->TxShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 init_completion(&pSchedContext->RxShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 init_completion(&pSchedContext->ResumeMcEvent);
133 init_completion(&pSchedContext->ResumeTxEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 init_completion(&pSchedContext->ResumeRxEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136 spin_lock_init(&pSchedContext->McThreadLock);
137 spin_lock_init(&pSchedContext->TxThreadLock);
138 spin_lock_init(&pSchedContext->RxThreadLock);
139
140 init_waitqueue_head(&pSchedContext->mcWaitQueue);
141 pSchedContext->mcEventFlag = 0;
142 init_waitqueue_head(&pSchedContext->txWaitQueue);
143 pSchedContext->txEventFlag= 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700144 init_waitqueue_head(&pSchedContext->rxWaitQueue);
145 pSchedContext->rxEventFlag= 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 /*
Jeff Johnson2f5cfec2013-02-22 21:25:10 -0800147 ** This initialization is critical as the threads will later access the
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 ** global contexts normally,
149 **
150 ** I shall put some memory barrier here after the next piece of code but
151 ** I am keeping it simple for now.
152 */
153 gpVosSchedContext = pSchedContext;
154
155 //Create the VOSS Main Controller thread
156 pSchedContext->McThread = kthread_create(VosMCThread, pSchedContext,
157 "VosMCThread");
158 if (IS_ERR(pSchedContext->McThread))
159 {
160 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
161 "%s: Could not Create VOSS Main Thread Controller",__func__);
162 goto MC_THREAD_START_FAILURE;
163 }
164 wake_up_process(pSchedContext->McThread);
165 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
166 "%s: VOSS Main Controller thread Created",__func__);
167
Jeff Johnson295189b2012-06-20 16:38:30 -0700168 pSchedContext->TxThread = kthread_create(VosTXThread, pSchedContext,
169 "VosTXThread");
170 if (IS_ERR(pSchedContext->TxThread))
171 {
172 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
173 "%s: Could not Create VOSS TX Thread",__func__);
174 goto TX_THREAD_START_FAILURE;
175 }
176 wake_up_process(pSchedContext->TxThread);
177 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain02882402013-11-17 21:55:29 -0800178 ("VOSS TX thread Created"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700179
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 pSchedContext->RxThread = kthread_create(VosRXThread, pSchedContext,
181 "VosRXThread");
182 if (IS_ERR(pSchedContext->RxThread))
183 {
184
185 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
186 "%s: Could not Create VOSS RX Thread",__func__);
187 goto RX_THREAD_START_FAILURE;
188
189 }
190 wake_up_process(pSchedContext->RxThread);
191 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain02882402013-11-17 21:55:29 -0800192 ("VOSS RX thread Created"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700193
194 /*
195 ** Now make sure all threads have started before we exit.
196 ** Each thread should normally ACK back when it starts.
197 */
198 wait_for_completion_interruptible(&pSchedContext->McStartEvent);
199 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
200 "%s: VOSS MC Thread has started",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 wait_for_completion_interruptible(&pSchedContext->TxStartEvent);
202 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
203 "%s: VOSS Tx Thread has started",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 wait_for_completion_interruptible(&pSchedContext->RxStartEvent);
205 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
206 "%s: VOSS Rx Thread has started",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208 /*
209 ** We're good now: Let's get the ball rolling!!!
210 */
211 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
212 "%s: VOSS Scheduler successfully Opened",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 return VOS_STATUS_SUCCESS;
214
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
Jeff Johnson295189b2012-06-20 16:38:30 -0700216RX_THREAD_START_FAILURE:
217 //Try and force the Tx thread controller to exit
218 set_bit(MC_SHUTDOWN_EVENT_MASK, &pSchedContext->txEventFlag);
219 set_bit(MC_POST_EVENT_MASK, &pSchedContext->txEventFlag);
220 wake_up_interruptible(&pSchedContext->txWaitQueue);
221 //Wait for TX to exit
222 wait_for_completion_interruptible(&pSchedContext->TxShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224TX_THREAD_START_FAILURE:
225 //Try and force the Main thread controller to exit
226 set_bit(MC_SHUTDOWN_EVENT_MASK, &pSchedContext->mcEventFlag);
227 set_bit(MC_POST_EVENT_MASK, &pSchedContext->mcEventFlag);
228 wake_up_interruptible(&pSchedContext->mcWaitQueue);
229 //Wait for MC to exit
230 wait_for_completion_interruptible(&pSchedContext->McShutdown);
231
Jeff Johnson295189b2012-06-20 16:38:30 -0700232MC_THREAD_START_FAILURE:
233 //De-initialize all the message queues
234 vos_sched_deinit_mqs(pSchedContext);
235 return VOS_STATUS_E_RESOURCES;
236
237} /* vos_sched_open() */
238
239VOS_STATUS vos_watchdog_open
240(
241 v_PVOID_t pVosContext,
242 pVosWatchdogContext pWdContext,
243 v_SIZE_t wdCtxSize
244)
245{
246/*-------------------------------------------------------------------------*/
247 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
248 "%s: Opening the VOSS Watchdog module",__func__);
249 //Sanity checks
250 if ((pVosContext == NULL) || (pWdContext == NULL)) {
251 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
252 "%s: Null params being passed",__func__);
253 return VOS_STATUS_E_FAILURE;
254 }
255 if (sizeof(VosWatchdogContext) != wdCtxSize)
256 {
257 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
258 "%s: Incorrect VOS Watchdog Context size passed",__func__);
259 return VOS_STATUS_E_INVAL;
260 }
261 vos_mem_zero(pWdContext, sizeof(VosWatchdogContext));
262 pWdContext->pVContext = pVosContext;
263 gpVosWatchdogContext = pWdContext;
264
265 //Initialize the helper events and event queues
266 init_completion(&pWdContext->WdStartEvent);
267 init_completion(&pWdContext->WdShutdown);
268 init_waitqueue_head(&pWdContext->wdWaitQueue);
269 pWdContext->wdEventFlag = 0;
270
271 // Initialize the lock
272 spin_lock_init(&pWdContext->wdLock);
273
274 //Create the Watchdog thread
275 pWdContext->WdThread = kthread_create(VosWDThread, pWdContext,"VosWDThread");
276
277 if (IS_ERR(pWdContext->WdThread))
278 {
279 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
280 "%s: Could not Create Watchdog thread",__func__);
281 return VOS_STATUS_E_RESOURCES;
282 }
283 else
284 {
285 wake_up_process(pWdContext->WdThread);
286 }
287 /*
288 ** Now make sure thread has started before we exit.
289 ** Each thread should normally ACK back when it starts.
290 */
291 wait_for_completion_interruptible(&pWdContext->WdStartEvent);
292 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
293 "%s: VOSS Watchdog Thread has started",__func__);
294 return VOS_STATUS_SUCCESS;
295} /* vos_watchdog_open() */
296/*---------------------------------------------------------------------------
297 \brief VosMcThread() - The VOSS Main Controller thread
298 The \a VosMcThread() is the VOSS main controller thread:
299 \param Arg - pointer to the global vOSS Sched Context
300 \return Thread exit code
301 \sa VosMcThread()
302 -------------------------------------------------------------------------*/
303static int
304VosMCThread
305(
306 void * Arg
307)
308{
309 pVosSchedContext pSchedContext = (pVosSchedContext)Arg;
310 pVosMsgWrapper pMsgWrapper = NULL;
311 tpAniSirGlobal pMacContext = NULL;
312 tSirRetStatus macStatus = eSIR_SUCCESS;
313 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
314 int retWaitStatus = 0;
315 v_BOOL_t shutdown = VOS_FALSE;
316 hdd_context_t *pHddCtx = NULL;
317 v_CONTEXT_t pVosContext = NULL;
318
319 if (Arg == NULL)
320 {
321 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700322 "%s: Bad Args passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 return 0;
324 }
325 set_user_nice(current, -2);
326
Yue Maf49ba872013-08-19 12:04:25 -0700327#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 daemonize("MC_Thread");
Yue Maf49ba872013-08-19 12:04:25 -0700329#endif
330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 /*
332 ** Ack back to the context from which the main controller thread has been
333 ** created.
334 */
335 complete(&pSchedContext->McStartEvent);
336 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
337 "%s: MC Thread %d (%s) starting up",__func__, current->pid, current->comm);
338
339 /* Get the Global VOSS Context */
340 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
341 if(!pVosContext) {
342 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
343 return 0;
344 }
345
346 /* Get the HDD context */
347 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
348 if(!pHddCtx) {
349 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
350 return 0;
351 }
352
353 while(!shutdown)
354 {
355 // This implements the execution model algorithm
356 retWaitStatus = wait_event_interruptible(pSchedContext->mcWaitQueue,
357 test_bit(MC_POST_EVENT_MASK, &pSchedContext->mcEventFlag) ||
358 test_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag));
359
360 if(retWaitStatus == -ERESTARTSYS)
361 {
362 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700363 "%s: wait_event_interruptible returned -ERESTARTSYS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 break;
365 }
366 clear_bit(MC_POST_EVENT_MASK, &pSchedContext->mcEventFlag);
367
368 while(1)
369 {
370 // Check if MC needs to shutdown
371 if(test_bit(MC_SHUTDOWN_EVENT_MASK, &pSchedContext->mcEventFlag))
372 {
373 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
374 "%s: MC thread signaled to shutdown", __func__);
375 shutdown = VOS_TRUE;
376 /* Check for any Suspend Indication */
377 if(test_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag))
378 {
379 clear_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag);
380
381 /* Unblock anyone waiting on suspend */
382 complete(&pHddCtx->mc_sus_event_var);
383 }
384 break;
385 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 /*
387 ** Check the WDI queue
388 ** Service it till the entire queue is empty
389 */
390 if (!vos_is_mq_empty(&pSchedContext->wdiMcMq))
391 {
392 wpt_msg *pWdiMsg;
393 /*
394 ** Service the WDI message queue
395 */
396 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_INFO,
397 ("Servicing the VOS MC WDI Message queue"));
398
399 pMsgWrapper = vos_mq_get(&pSchedContext->wdiMcMq);
Jeff Johnsond13512a2012-07-17 11:42:19 -0700400
401 if (pMsgWrapper == NULL)
402 {
403 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700404 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnsond13512a2012-07-17 11:42:19 -0700405 VOS_ASSERT(0);
406 break;
407 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700408
409 pWdiMsg = (wpt_msg *)pMsgWrapper->pVosMsg->bodyptr;
Jeff Johnsond13512a2012-07-17 11:42:19 -0700410
411 if(pWdiMsg == NULL || pWdiMsg->callback == NULL)
412 {
413 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700414 "%s: WDI Msg or Callback is NULL", __func__);
Jeff Johnsond13512a2012-07-17 11:42:19 -0700415 VOS_ASSERT(0);
416 break;
417 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700418
419 pWdiMsg->callback(pWdiMsg);
420
421 /*
422 ** return message to the Core
423 */
424 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
425
426 continue;
427 }
428
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 // Check the SYS queue first
430 if (!vos_is_mq_empty(&pSchedContext->sysMcMq))
431 {
432 // Service the SYS message queue
433 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
434 "%s: Servicing the VOS SYS MC Message queue",__func__);
435 pMsgWrapper = vos_mq_get(&pSchedContext->sysMcMq);
436 if (pMsgWrapper == NULL)
437 {
438 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700439 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 VOS_ASSERT(0);
441 break;
442 }
443 vStatus = sysMcProcessMsg(pSchedContext->pVContext,
444 pMsgWrapper->pVosMsg);
445 if (!VOS_IS_STATUS_SUCCESS(vStatus))
446 {
447 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
448 "%s: Issue Processing SYS message",__func__);
449 }
450 //return message to the Core
451 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
452 continue;
453 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 // Check the WDA queue
455 if (!vos_is_mq_empty(&pSchedContext->wdaMcMq))
456 {
457 // Service the WDA message queue
458 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
459 "%s: Servicing the VOS WDA MC Message queue",__func__);
460 pMsgWrapper = vos_mq_get(&pSchedContext->wdaMcMq);
461 if (pMsgWrapper == NULL)
462 {
463 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700464 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 VOS_ASSERT(0);
466 break;
467 }
468 vStatus = WDA_McProcessMsg( pSchedContext->pVContext, pMsgWrapper->pVosMsg);
469 if (!VOS_IS_STATUS_SUCCESS(vStatus))
470 {
471 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
472 "%s: Issue Processing WDA message",__func__);
473 }
474 // return message to the Core
475 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
476 continue;
477 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 // Check the PE queue
479 if (!vos_is_mq_empty(&pSchedContext->peMcMq))
480 {
481 // Service the PE message queue
482 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
483 "%s: Servicing the VOS PE MC Message queue",__func__);
484 pMsgWrapper = vos_mq_get(&pSchedContext->peMcMq);
485 if (NULL == pMsgWrapper)
486 {
487 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700488 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 VOS_ASSERT(0);
490 break;
491 }
492
493 /* Need some optimization*/
494 pMacContext = vos_get_context(VOS_MODULE_ID_PE, pSchedContext->pVContext);
495 if (NULL == pMacContext)
496 {
497 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
498 "MAC Context not ready yet");
499 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
500 continue;
501 }
502
503 macStatus = peProcessMessages( pMacContext, (tSirMsgQ*)pMsgWrapper->pVosMsg);
504 if (eSIR_SUCCESS != macStatus)
505 {
506 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
507 "%s: Issue Processing PE message",__func__);
508 }
509 // return message to the Core
510 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
511 continue;
512 }
513 /** Check the SME queue **/
514 if (!vos_is_mq_empty(&pSchedContext->smeMcMq))
515 {
516 /* Service the SME message queue */
517 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
518 "%s: Servicing the VOS SME MC Message queue",__func__);
519 pMsgWrapper = vos_mq_get(&pSchedContext->smeMcMq);
520 if (NULL == pMsgWrapper)
521 {
522 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700523 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 VOS_ASSERT(0);
525 break;
526 }
527
528 /* Need some optimization*/
529 pMacContext = vos_get_context(VOS_MODULE_ID_SME, 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 vStatus = sme_ProcessMsg( (tHalHandle)pMacContext, pMsgWrapper->pVosMsg);
539 if (!VOS_IS_STATUS_SUCCESS(vStatus))
540 {
541 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
542 "%s: Issue Processing SME message",__func__);
543 }
544 // return message to the Core
545 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
546 continue;
547 }
548 /** Check the TL queue **/
549 if (!vos_is_mq_empty(&pSchedContext->tlMcMq))
550 {
551 // Service the TL message queue
552 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
553 ("Servicing the VOS TL MC Message queue"));
554 pMsgWrapper = vos_mq_get(&pSchedContext->tlMcMq);
555 if (pMsgWrapper == NULL)
556 {
557 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700558 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 VOS_ASSERT(0);
560 break;
561 }
562 vStatus = WLANTL_McProcessMsg( pSchedContext->pVContext,
563 pMsgWrapper->pVosMsg);
564 if (!VOS_IS_STATUS_SUCCESS(vStatus))
565 {
566 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
567 "%s: Issue Processing TL message",__func__);
568 }
569 // return message to the Core
570 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
571 continue;
572 }
573 /* Check for any Suspend Indication */
574 if(test_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag))
575 {
576 clear_bit(MC_SUSPEND_EVENT_MASK, &pSchedContext->mcEventFlag);
577 spin_lock(&pSchedContext->McThreadLock);
578
579 /* Mc Thread Suspended */
580 complete(&pHddCtx->mc_sus_event_var);
581
582 INIT_COMPLETION(pSchedContext->ResumeMcEvent);
583 spin_unlock(&pSchedContext->McThreadLock);
584
585 /* Wait foe Resume Indication */
586 wait_for_completion_interruptible(&pSchedContext->ResumeMcEvent);
587 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 break; //All queues are empty now
589 } // while message loop processing
590 } // while TRUE
591 // If we get here the MC thread must exit
592 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700593 "%s: MC Thread exiting!!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 complete_and_exit(&pSchedContext->McShutdown, 0);
595} /* VosMCThread() */
Kiet Lamaa8e15a2014-02-11 23:30:06 -0800596int isWDresetInProgress(void)
Jeff Johnson295189b2012-06-20 16:38:30 -0700597{
598 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
599 "%s: Reset is in Progress...",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 if(gpVosWatchdogContext!=NULL)
601 {
602 return gpVosWatchdogContext->resetInProgress;
603 }
604 else
605 {
Kiet Lamaa8e15a2014-02-11 23:30:06 -0800606 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700608}
609/*---------------------------------------------------------------------------
610 \brief VosWdThread() - The VOSS Watchdog thread
611 The \a VosWdThread() is the Watchdog thread:
612 \param Arg - pointer to the global vOSS Sched Context
613 \return Thread exit code
614 \sa VosMcThread()
615 -------------------------------------------------------------------------*/
616static int
617VosWDThread
618(
619 void * Arg
620)
621{
622 pVosWatchdogContext pWdContext = (pVosWatchdogContext)Arg;
623 int retWaitStatus = 0;
624 v_BOOL_t shutdown = VOS_FALSE;
625 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
626 set_user_nice(current, -3);
627
628 if (Arg == NULL)
629 {
630 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700631 "%s: Bad Args passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 return 0;
633 }
Yue Maf49ba872013-08-19 12:04:25 -0700634
635#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 daemonize("WD_Thread");
Yue Maf49ba872013-08-19 12:04:25 -0700637#endif
638
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 /*
640 ** Ack back to the context from which the Watchdog thread has been
641 ** created.
642 */
643 complete(&pWdContext->WdStartEvent);
644 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
645 "%s: Watchdog Thread %d (%s) starting up",__func__, current->pid, current->comm);
646
647 while(!shutdown)
648 {
649 // This implements the Watchdog execution model algorithm
650 retWaitStatus = wait_event_interruptible(pWdContext->wdWaitQueue,
651 test_bit(WD_POST_EVENT_MASK, &pWdContext->wdEventFlag));
652 if(retWaitStatus == -ERESTARTSYS)
653 {
654 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700655 "%s: wait_event_interruptible returned -ERESTARTSYS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 break;
657 }
658 clear_bit(WD_POST_EVENT_MASK, &pWdContext->wdEventFlag);
659 while(1)
660 {
661 // Check if Watchdog needs to shutdown
662 if(test_bit(WD_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag))
663 {
664 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
665 "%s: Watchdog thread signaled to shutdown", __func__);
666
667 clear_bit(WD_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag);
668 shutdown = VOS_TRUE;
669 break;
670 }
671 /* subsystem restart: shutdown event handler */
672 else if(test_bit(WD_WLAN_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag))
673 {
674 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
675 "%s: Watchdog thread signaled to perform WLAN shutdown",__func__);
676 clear_bit(WD_WLAN_SHUTDOWN_EVENT_MASK, &pWdContext->wdEventFlag);
677
678 //Perform WLAN shutdown
679 if(!pWdContext->resetInProgress)
680 {
681 pWdContext->resetInProgress = true;
682 vosStatus = hdd_wlan_shutdown();
683
684 if (! VOS_IS_STATUS_SUCCESS(vosStatus))
685 {
686 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
687 "%s: Failed to shutdown WLAN",__func__);
688 VOS_ASSERT(0);
689 goto err_reset;
690 }
691 }
692 }
693 /* subsystem restart: re-init event handler */
694 else if(test_bit(WD_WLAN_REINIT_EVENT_MASK, &pWdContext->wdEventFlag))
695 {
696 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
697 "%s: Watchdog thread signaled to perform WLAN re-init",__func__);
698 clear_bit(WD_WLAN_REINIT_EVENT_MASK, &pWdContext->wdEventFlag);
699
700 //Perform WLAN re-init
701 if(!pWdContext->resetInProgress)
702 {
703 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
704 "%s: Trying to do WLAN re-init when it is not shutdown !!",__func__);
705 }
706 vosStatus = hdd_wlan_re_init();
707
708 if (! VOS_IS_STATUS_SUCCESS(vosStatus))
709 {
710 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
711 "%s: Failed to re-init WLAN",__func__);
712 VOS_ASSERT(0);
713 goto err_reset;
714 }
715 pWdContext->resetInProgress = false;
716 }
717 else
718 {
719 //Unnecessary wakeup - Should never happen!!
720 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
721 "%s: Watchdog thread woke up unnecessarily",__func__);
722 }
723 break;
724 } // while message loop processing
725 } // while shutdown
726
727 // If we get here the Watchdog thread must exit
728 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700729 "%s: Watchdog Thread exiting !!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 complete_and_exit(&pWdContext->WdShutdown, 0);
731
732err_reset:
733 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700734 "%s: Watchdog Thread Failed to Reset, Exiting!!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 return 0;
736
737} /* VosMCThread() */
738
739/*---------------------------------------------------------------------------
740 \brief VosTXThread() - The VOSS Main Tx thread
741 The \a VosTxThread() is the VOSS main controller thread:
742 \param Arg - pointer to the global vOSS Sched Context
743
744 \return Thread exit code
745 \sa VosTxThread()
746 -------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700747static int VosTXThread ( void * Arg )
748{
749 pVosSchedContext pSchedContext = (pVosSchedContext)Arg;
750 pVosMsgWrapper pMsgWrapper = NULL;
751 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
752 int retWaitStatus = 0;
753 v_BOOL_t shutdown = VOS_FALSE;
754 hdd_context_t *pHddCtx = NULL;
755 v_CONTEXT_t pVosContext = NULL;
756
757 set_user_nice(current, -1);
Madan Mohan Koyyalamudid68ecce2012-09-18 19:51:41 -0700758
759#ifdef WLAN_FEATURE_11AC_HIGH_TP
Madan Mohan Koyyalamudi893c77f2012-09-18 19:30:48 -0700760 set_wake_up_idle(true);
Madan Mohan Koyyalamudid68ecce2012-09-18 19:51:41 -0700761#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700762
763 if (Arg == NULL)
764 {
765 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700766 "%s Bad Args passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return 0;
768 }
Yue Maf49ba872013-08-19 12:04:25 -0700769
770#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 daemonize("TX_Thread");
Yue Maf49ba872013-08-19 12:04:25 -0700772#endif
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 /*
775 ** Ack back to the context from which the main controller thread has been
776 ** created.
777 */
778 complete(&pSchedContext->TxStartEvent);
779 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
780 "%s: TX Thread %d (%s) starting up!",__func__, current->pid, current->comm);
781
782 /* Get the Global VOSS Context */
783 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
784 if(!pVosContext) {
785 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
786 return 0;
787 }
788
789 /* Get the HDD context */
790 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
791 if(!pHddCtx) {
792 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
793 return 0;
794 }
795
796
797 while(!shutdown)
798 {
799 // This implements the execution model algorithm
800 retWaitStatus = wait_event_interruptible(pSchedContext->txWaitQueue,
801 test_bit(TX_POST_EVENT_MASK, &pSchedContext->txEventFlag) ||
802 test_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag));
803
804
805 if(retWaitStatus == -ERESTARTSYS)
806 {
807 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700808 "%s: wait_event_interruptible returned -ERESTARTSYS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 break;
810 }
811 clear_bit(TX_POST_EVENT_MASK, &pSchedContext->txEventFlag);
812
813 while(1)
814 {
815 if(test_bit(TX_SHUTDOWN_EVENT_MASK, &pSchedContext->txEventFlag))
816 {
817 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
818 "%s: TX thread signaled to shutdown", __func__);
819 shutdown = VOS_TRUE;
820 /* Check for any Suspend Indication */
821 if(test_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag))
822 {
823 clear_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag);
824
825 /* Unblock anyone waiting on suspend */
826 complete(&pHddCtx->tx_sus_event_var);
827 }
828 break;
829 }
830 // Check the SYS queue first
831 if (!vos_is_mq_empty(&pSchedContext->sysTxMq))
832 {
833 // Service the SYS message queue
834 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
835 "%s: Servicing the VOS SYS TX Message queue",__func__);
836 pMsgWrapper = vos_mq_get(&pSchedContext->sysTxMq);
837 if (pMsgWrapper == NULL)
838 {
839 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700840 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 VOS_ASSERT(0);
842 break;
843 }
844 vStatus = sysTxProcessMsg( pSchedContext->pVContext,
845 pMsgWrapper->pVosMsg);
846 if (!VOS_IS_STATUS_SUCCESS(vStatus))
847 {
848 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
849 "%s: Issue Processing TX SYS message",__func__);
850 }
851 // return message to the Core
852 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
853 continue;
854 }
855 // Check now the TL queue
856 if (!vos_is_mq_empty(&pSchedContext->tlTxMq))
857 {
858 // Service the TL message queue
859 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
860 "%s: Servicing the VOS TL TX Message queue",__func__);
861 pMsgWrapper = vos_mq_get(&pSchedContext->tlTxMq);
862 if (pMsgWrapper == NULL)
863 {
864 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700865 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 VOS_ASSERT(0);
867 break;
868 }
869 vStatus = WLANTL_TxProcessMsg( pSchedContext->pVContext,
870 pMsgWrapper->pVosMsg);
871 if (!VOS_IS_STATUS_SUCCESS(vStatus))
872 {
873 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
874 "%s: Issue Processing TX TL message",__func__);
875 }
876 // return message to the Core
877 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
878 continue;
879 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 // Check the WDI queue
881 if (!vos_is_mq_empty(&pSchedContext->wdiTxMq))
882 {
883 wpt_msg *pWdiMsg;
884 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_INFO,
885 "%s: Servicing the VOS TX WDI Message queue",__func__);
886
887 pMsgWrapper = vos_mq_get(&pSchedContext->wdiTxMq);
Jeff Johnsond13512a2012-07-17 11:42:19 -0700888
889 if (pMsgWrapper == NULL)
890 {
891 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700892 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnsond13512a2012-07-17 11:42:19 -0700893 VOS_ASSERT(0);
894 break;
895 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700896
897 pWdiMsg = (wpt_msg *)pMsgWrapper->pVosMsg->bodyptr;
Jeff Johnson295189b2012-06-20 16:38:30 -0700898
Jeff Johnsond13512a2012-07-17 11:42:19 -0700899 if(pWdiMsg == NULL || pWdiMsg->callback == NULL)
900 {
901 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700902 "%s: WDI Msg or Callback is NULL", __func__);
Jeff Johnsond13512a2012-07-17 11:42:19 -0700903 VOS_ASSERT(0);
904 break;
905 }
906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 pWdiMsg->callback(pWdiMsg);
908
909 // return message to the Core
910 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
911
912 continue;
913 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 /* Check for any Suspend Indication */
915 if(test_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag))
916 {
917 clear_bit(TX_SUSPEND_EVENT_MASK, &pSchedContext->txEventFlag);
918 spin_lock(&pSchedContext->TxThreadLock);
919
920 /* Tx Thread Suspended */
921 complete(&pHddCtx->tx_sus_event_var);
922
923 INIT_COMPLETION(pSchedContext->ResumeTxEvent);
924 spin_unlock(&pSchedContext->TxThreadLock);
925
926 /* Wait foe Resume Indication */
927 wait_for_completion_interruptible(&pSchedContext->ResumeTxEvent);
928 }
929
930 break; //All queues are empty now
931 } // while message loop processing
932 } // while TRUE
933 // If we get here the TX thread must exit
934 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700935 "%s: TX Thread exiting!!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 complete_and_exit(&pSchedContext->TxShutdown, 0);
937} /* VosTxThread() */
938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939/*---------------------------------------------------------------------------
940 \brief VosRXThread() - The VOSS Main Rx thread
941 The \a VosRxThread() is the VOSS Rx controller thread:
942 \param Arg - pointer to the global vOSS Sched Context
943
944 \return Thread exit code
945 \sa VosRxThread()
946 -------------------------------------------------------------------------*/
947
948static int VosRXThread ( void * Arg )
949{
950 pVosSchedContext pSchedContext = (pVosSchedContext)Arg;
951 pVosMsgWrapper pMsgWrapper = NULL;
952 int retWaitStatus = 0;
953 v_BOOL_t shutdown = VOS_FALSE;
954 hdd_context_t *pHddCtx = NULL;
955 v_CONTEXT_t pVosContext = NULL;
956 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
957
958 set_user_nice(current, -1);
Madan Mohan Koyyalamudid68ecce2012-09-18 19:51:41 -0700959
960#ifdef WLAN_FEATURE_11AC_HIGH_TP
Madan Mohan Koyyalamudi893c77f2012-09-18 19:30:48 -0700961 set_wake_up_idle(true);
Madan Mohan Koyyalamudid68ecce2012-09-18 19:51:41 -0700962#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700963
964 if (Arg == NULL)
965 {
966 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700967 "%s Bad Args passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 return 0;
969 }
Yue Maf49ba872013-08-19 12:04:25 -0700970
971#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 daemonize("RX_Thread");
Yue Maf49ba872013-08-19 12:04:25 -0700973#endif
974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 /*
976 ** Ack back to the context from which the main controller thread has been
977 ** created.
978 */
979 complete(&pSchedContext->RxStartEvent);
980 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
981 "%s: RX Thread %d (%s) starting up!",__func__, current->pid, current->comm);
982
983 /* Get the Global VOSS Context */
984 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
985 if(!pVosContext) {
986 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
987 return 0;
988 }
989
990 /* Get the HDD context */
991 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
992 if(!pHddCtx) {
993 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
994 return 0;
995 }
996
997 while(!shutdown)
998 {
999 // This implements the execution model algorithm
1000 retWaitStatus = wait_event_interruptible(pSchedContext->rxWaitQueue,
1001 test_bit(RX_POST_EVENT_MASK, &pSchedContext->rxEventFlag) ||
1002 test_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag));
1003
1004
1005 if(retWaitStatus == -ERESTARTSYS)
1006 {
1007 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001008 "%s: wait_event_interruptible returned -ERESTARTSYS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 break;
1010 }
1011 clear_bit(RX_POST_EVENT_MASK, &pSchedContext->rxEventFlag);
1012
1013 while(1)
1014 {
1015 if(test_bit(RX_SHUTDOWN_EVENT_MASK, &pSchedContext->rxEventFlag))
1016 {
1017 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1018 "%s: RX thread signaled to shutdown", __func__);
1019 shutdown = VOS_TRUE;
1020 /* Check for any Suspend Indication */
1021 if(test_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag))
1022 {
1023 clear_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag);
1024
1025 /* Unblock anyone waiting on suspend */
1026 complete(&pHddCtx->rx_sus_event_var);
1027 }
1028 break;
1029 }
1030
1031
1032 // Check the SYS queue first
1033 if (!vos_is_mq_empty(&pSchedContext->sysRxMq))
1034 {
1035 // Service the SYS message queue
1036 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1037 "%s: Servicing the VOS SYS RX Message queue",__func__);
1038 pMsgWrapper = vos_mq_get(&pSchedContext->sysRxMq);
1039 if (pMsgWrapper == NULL)
1040 {
1041 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001042 "%s: pMsgWrapper is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 VOS_ASSERT(0);
1044 break;
1045 }
1046 vStatus = sysRxProcessMsg( pSchedContext->pVContext,
1047 pMsgWrapper->pVosMsg);
1048 if (!VOS_IS_STATUS_SUCCESS(vStatus))
1049 {
1050 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1051 "%s: Issue Processing TX SYS message",__func__);
1052 }
1053 // return message to the Core
1054 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1055 continue;
1056 }
1057
1058 // Check the WDI queue
1059 if (!vos_is_mq_empty(&pSchedContext->wdiRxMq))
1060 {
1061 wpt_msg *pWdiMsg;
1062 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_INFO,
1063 "%s: Servicing the VOS RX WDI Message queue",__func__);
1064
1065 pMsgWrapper = vos_mq_get(&pSchedContext->wdiRxMq);
1066 if ((NULL == pMsgWrapper) || (NULL == pMsgWrapper->pVosMsg))
1067 {
1068 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001069 "%s: wdiRxMq message is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 VOS_ASSERT(0);
1071 // we won't return this wrapper since it is corrupt
1072 }
1073 else
1074 {
1075 pWdiMsg = (wpt_msg *)pMsgWrapper->pVosMsg->bodyptr;
1076 if ((NULL == pWdiMsg) || (NULL == pWdiMsg->callback))
1077 {
1078 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001079 "%s: WDI Msg or callback is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 VOS_ASSERT(0);
1081 }
1082 else
1083 {
1084 // invoke the message handler
1085 pWdiMsg->callback(pWdiMsg);
1086 }
1087
1088 // return message to the Core
1089 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1090 }
1091 continue;
1092 }
1093
1094 /* Check for any Suspend Indication */
1095 if(test_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag))
1096 {
1097 clear_bit(RX_SUSPEND_EVENT_MASK, &pSchedContext->rxEventFlag);
1098 spin_lock(&pSchedContext->RxThreadLock);
1099
1100 /* Rx Thread Suspended */
1101 complete(&pHddCtx->rx_sus_event_var);
1102
Gopichand Nakkala05621412013-06-19 19:37:38 +05301103 INIT_COMPLETION(pSchedContext->ResumeRxEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 spin_unlock(&pSchedContext->RxThreadLock);
1105
1106 /* Wait for Resume Indication */
1107 wait_for_completion_interruptible(&pSchedContext->ResumeRxEvent);
1108 }
1109
1110 break; //All queues are empty now
1111 } // while message loop processing
1112 } // while TRUE
1113 // If we get here the RX thread must exit
1114 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001115 "%s: RX Thread exiting!!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 complete_and_exit(&pSchedContext->RxShutdown, 0);
1117} /* VosRxThread() */
Jeff Johnson295189b2012-06-20 16:38:30 -07001118
Jeff Johnson295189b2012-06-20 16:38:30 -07001119/*---------------------------------------------------------------------------
1120 \brief vos_sched_close() - Close the vOSS Scheduler
1121 The \a vos_sched_closes() function closes the vOSS Scheduler
1122 Upon successful closing:
1123 - All the message queues are flushed
1124 - The Main Controller thread is closed
1125 - The Tx thread is closed
1126
1127 \param pVosContext - pointer to the global vOSS Context
1128 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
1129 is ready to be used.
1130 VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open
1131 function
1132 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
1133 \sa vos_sched_close()
1134---------------------------------------------------------------------------*/
1135VOS_STATUS vos_sched_close ( v_PVOID_t pVosContext )
1136{
1137 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001138 "%s: invoked", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 if (gpVosSchedContext == NULL)
1140 {
1141 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -08001142 "%s: gpVosSchedContext == NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 return VOS_STATUS_E_FAILURE;
1144 }
1145
1146 // shut down MC Thread
1147 set_bit(MC_SHUTDOWN_EVENT_MASK, &gpVosSchedContext->mcEventFlag);
1148 set_bit(MC_POST_EVENT_MASK, &gpVosSchedContext->mcEventFlag);
1149 wake_up_interruptible(&gpVosSchedContext->mcWaitQueue);
1150 //Wait for MC to exit
Mihir Shetede20c472013-11-28 11:02:38 +05301151 wait_for_completion(&gpVosSchedContext->McShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 gpVosSchedContext->McThread = 0;
1153
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 // shut down TX Thread
1155 set_bit(TX_SHUTDOWN_EVENT_MASK, &gpVosSchedContext->txEventFlag);
1156 set_bit(TX_POST_EVENT_MASK, &gpVosSchedContext->txEventFlag);
1157 wake_up_interruptible(&gpVosSchedContext->txWaitQueue);
1158 //Wait for TX to exit
Mihir Shetede20c472013-11-28 11:02:38 +05301159 wait_for_completion(&gpVosSchedContext->TxShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 gpVosSchedContext->TxThread = 0;
1161
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 // shut down RX Thread
1163 set_bit(RX_SHUTDOWN_EVENT_MASK, &gpVosSchedContext->rxEventFlag);
1164 set_bit(RX_POST_EVENT_MASK, &gpVosSchedContext->rxEventFlag);
1165 wake_up_interruptible(&gpVosSchedContext->rxWaitQueue);
1166 //Wait for RX to exit
Mihir Shetede20c472013-11-28 11:02:38 +05301167 wait_for_completion(&gpVosSchedContext->RxShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 gpVosSchedContext->RxThread = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001169
1170 //Clean up message queues of TX and MC thread
1171 vos_sched_flush_mc_mqs(gpVosSchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 vos_sched_flush_tx_mqs(gpVosSchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 vos_sched_flush_rx_mqs(gpVosSchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001174
1175 //Deinit all the queues
1176 vos_sched_deinit_mqs(gpVosSchedContext);
1177
1178 return VOS_STATUS_SUCCESS;
1179} /* vox_sched_close() */
1180
1181VOS_STATUS vos_watchdog_close ( v_PVOID_t pVosContext )
1182{
1183 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001184 "%s: vos_watchdog closing now", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 if (gpVosWatchdogContext == NULL)
1186 {
1187 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -08001188 "%s: gpVosWatchdogContext is NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 return VOS_STATUS_E_FAILURE;
1190 }
1191 set_bit(WD_SHUTDOWN_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag);
1192 set_bit(WD_POST_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag);
1193 wake_up_interruptible(&gpVosWatchdogContext->wdWaitQueue);
1194 //Wait for Watchdog thread to exit
Mihir Shetede20c472013-11-28 11:02:38 +05301195 wait_for_completion(&gpVosWatchdogContext->WdShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 return VOS_STATUS_SUCCESS;
1197} /* vos_watchdog_close() */
1198
1199VOS_STATUS vos_watchdog_chip_reset ( vos_chip_reset_reason_type reason )
1200{
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 return VOS_STATUS_SUCCESS;
1202} /* vos_watchdog_chip_reset() */
1203
1204/*---------------------------------------------------------------------------
1205 \brief vos_sched_init_mqs: Initialize the vOSS Scheduler message queues
1206 The \a vos_sched_init_mqs() function initializes the vOSS Scheduler
1207 message queues.
1208 \param pVosSchedContext - pointer to the Scheduler Context.
1209 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
1210 is ready to be used.
1211 VOS_STATUS_E_RESOURCES - System resources (other than memory)
1212 are unavailable to initilize the scheduler
1213
1214 \sa vos_sched_init_mqs()
1215 -------------------------------------------------------------------------*/
1216VOS_STATUS vos_sched_init_mqs ( pVosSchedContext pSchedContext )
1217{
1218 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
1219 // Now intialize all the message queues
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1221 "%s: Initializing the WDA MC Message queue",__func__);
1222 vStatus = vos_mq_init(&pSchedContext->wdaMcMq);
1223 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1224 {
1225 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1226 "%s: Failed to init WDA MC Message queue",__func__);
1227 VOS_ASSERT(0);
1228 return vStatus;
1229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1231 "%s: Initializing the PE MC Message queue",__func__);
1232 vStatus = vos_mq_init(&pSchedContext->peMcMq);
1233 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1234 {
1235 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1236 "%s: Failed to init PE MC Message queue",__func__);
1237 VOS_ASSERT(0);
1238 return vStatus;
1239 }
1240 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1241 "%s: Initializing the SME MC Message queue", __func__);
1242 vStatus = vos_mq_init(&pSchedContext->smeMcMq);
1243 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1244 {
1245 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1246 "%s: Failed to init SME MC Message queue",__func__);
1247 VOS_ASSERT(0);
1248 return vStatus;
1249 }
1250 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1251 "%s: Initializing the TL MC Message queue",__func__);
1252 vStatus = vos_mq_init(&pSchedContext->tlMcMq);
1253 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1254 {
1255 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1256 "%s: Failed to init TL MC Message queue",__func__);
1257 VOS_ASSERT(0);
1258 return vStatus;
1259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1261 "%s: Initializing the SYS MC Message queue",__func__);
1262 vStatus = vos_mq_init(&pSchedContext->sysMcMq);
1263 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1264 {
1265 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1266 "%s: Failed to init SYS MC Message queue",__func__);
1267 VOS_ASSERT(0);
1268 return vStatus;
1269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1271 "%s: Initializing the WDI MC Message queue",__func__);
1272
1273 vStatus = vos_mq_init(&pSchedContext->wdiMcMq);
1274 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1275 {
1276 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1277 "%s: Failed to init WDI MC Message queue",__func__);
1278 VOS_ASSERT(0);
1279 return vStatus;
1280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001281
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1283 "%s: Initializing the TL Tx Message queue",__func__);
1284 vStatus = vos_mq_init(&pSchedContext->tlTxMq);
1285 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1286 {
1287 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1288 "%s: Failed to init TL TX Message queue",__func__);
1289 VOS_ASSERT(0);
1290 return vStatus;
1291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1293 "%s: Initializing the WDI Tx Message queue",__func__);
1294 vStatus = vos_mq_init(&pSchedContext->wdiTxMq);
1295 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1296 {
1297 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1298 "%s: Failed to init WDI TX Message queue",__func__);
1299 VOS_ASSERT(0);
1300 return vStatus;
1301 }
1302
1303 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1304 "%s: Initializing the WDI Rx Message queue",__func__);
1305
1306 vStatus = vos_mq_init(&pSchedContext->wdiRxMq);
1307 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1308 {
1309 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1310 "%s: Failed to init WDI RX Message queue",__func__);
1311 VOS_ASSERT(0);
1312 return vStatus;
1313 }
1314
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1316 "%s: Initializing the SYS Tx Message queue",__func__);
1317 vStatus = vos_mq_init(&pSchedContext->sysTxMq);
1318 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1319 {
1320 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1321 "%s: Failed to init SYS TX Message queue",__func__);
1322 VOS_ASSERT(0);
1323 return vStatus;
1324 }
1325
1326 vStatus = vos_mq_init(&pSchedContext->sysRxMq);
1327 if (! VOS_IS_STATUS_SUCCESS(vStatus))
1328 {
1329 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1330 "%s: Failed to init SYS RX Message queue",__func__);
1331 VOS_ASSERT(0);
1332 return vStatus;
1333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 return VOS_STATUS_SUCCESS;
1335} /* vos_sched_init_mqs() */
1336
1337/*---------------------------------------------------------------------------
1338 \brief vos_sched_deinit_mqs: Deinitialize the vOSS Scheduler message queues
1339 The \a vos_sched_init_mqs() function deinitializes the vOSS Scheduler
1340 message queues.
1341 \param pVosSchedContext - pointer to the Scheduler Context.
1342 \return None
1343 \sa vos_sched_deinit_mqs()
1344 -------------------------------------------------------------------------*/
1345void vos_sched_deinit_mqs ( pVosSchedContext pSchedContext )
1346{
1347 // Now de-intialize all message queues
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 // MC WDA
1349 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1350 "%s De-Initializing the WDA MC Message queue",__func__);
1351 vos_mq_deinit(&pSchedContext->wdaMcMq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 //MC PE
1353 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1354 "%s De-Initializing the PE MC Message queue",__func__);
1355 vos_mq_deinit(&pSchedContext->peMcMq);
1356 //MC SME
1357 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1358 "%s De-Initializing the SME MC Message queue",__func__);
1359 vos_mq_deinit(&pSchedContext->smeMcMq);
1360 //MC TL
1361 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1362 "%s De-Initializing the TL MC Message queue",__func__);
1363 vos_mq_deinit(&pSchedContext->tlMcMq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 //MC SYS
1365 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1366 "%s De-Initializing the SYS MC Message queue",__func__);
1367 vos_mq_deinit(&pSchedContext->sysMcMq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 // MC WDI
1369 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1370 "%s De-Initializing the WDI MC Message queue",__func__);
1371 vos_mq_deinit(&pSchedContext->wdiMcMq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001372
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 //Tx TL
1374 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1375 "%s De-Initializing the TL Tx Message queue",__func__);
1376 vos_mq_deinit(&pSchedContext->tlTxMq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 //Tx WDI
1378 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1379 "%s: DeInitializing the WDI Tx Message queue",__func__);
1380 vos_mq_deinit(&pSchedContext->wdiTxMq);
1381
1382
1383 //Rx WDI
1384 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1385 "%s: DeInitializing the WDI Rx Message queue",__func__);
1386 vos_mq_deinit(&pSchedContext->wdiRxMq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387
1388 //Tx SYS
1389 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1390 "%s: DeInitializing the SYS Tx Message queue",__func__);
1391 vos_mq_deinit(&pSchedContext->sysTxMq);
1392
1393 //Rx SYS
1394 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
1395 "%s: DeInitializing the SYS Rx Message queue",__func__);
1396 vos_mq_deinit(&pSchedContext->sysRxMq);
1397
Jeff Johnson295189b2012-06-20 16:38:30 -07001398} /* vos_sched_deinit_mqs() */
1399
1400/*-------------------------------------------------------------------------
1401 this helper function flushes all the MC message queues
1402 -------------------------------------------------------------------------*/
1403void vos_sched_flush_mc_mqs ( pVosSchedContext pSchedContext )
1404{
1405 pVosMsgWrapper pMsgWrapper = NULL;
1406 pVosContextType vosCtx;
1407
1408 /*
1409 ** Here each of the MC thread MQ shall be drained and returned to the
1410 ** Core. Before returning a wrapper to the Core, the VOS message shall be
1411 ** freed first
1412 */
1413 VOS_TRACE( VOS_MODULE_ID_VOSS,
1414 VOS_TRACE_LEVEL_INFO,
Arif Hussain02882402013-11-17 21:55:29 -08001415 ("Flushing the MC Thread message queue") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001416
1417 if (NULL == pSchedContext)
1418 {
1419 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001420 "%s: pSchedContext is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 return;
1422 }
1423
1424 vosCtx = (pVosContextType)(pSchedContext->pVContext);
1425 if (NULL == vosCtx)
1426 {
1427 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001428 "%s: vosCtx is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 return;
1430 }
1431
1432 /* Flush the SYS Mq */
1433 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->sysMcMq) ))
1434 {
1435 VOS_TRACE( VOS_MODULE_ID_VOSS,
Leo Chang0f24ca12013-12-17 13:35:00 -08001436 VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 "%s: Freeing MC SYS message type %d ",__func__,
1438 pMsgWrapper->pVosMsg->type );
1439 sysMcFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg);
1440 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 /* Flush the WDA Mq */
1443 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdaMcMq) ))
1444 {
1445 if(pMsgWrapper->pVosMsg != NULL)
1446 {
Leo Chang0f24ca12013-12-17 13:35:00 -08001447 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 "%s: Freeing MC WDA MSG message type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001449 __func__, pMsgWrapper->pVosMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 if (pMsgWrapper->pVosMsg->bodyptr) {
1451 vos_mem_free((v_VOID_t*)pMsgWrapper->pVosMsg->bodyptr);
1452 }
1453
1454 pMsgWrapper->pVosMsg->bodyptr = NULL;
1455 pMsgWrapper->pVosMsg->bodyval = 0;
1456 pMsgWrapper->pVosMsg->type = 0;
1457 }
1458 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1459 }
1460
1461 /* Flush the WDI Mq */
1462 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdiMcMq) ))
1463 {
1464 if(pMsgWrapper->pVosMsg != NULL)
1465 {
Leo Chang0f24ca12013-12-17 13:35:00 -08001466 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 "%s: Freeing MC WDI MSG message type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001468 __func__, pMsgWrapper->pVosMsg->type );
Leo Chang0f24ca12013-12-17 13:35:00 -08001469
1470 /* MSG body pointer is not NULL
1471 * and MSG type is 0
1472 * This MSG is not posted by SMD NOTIFY
1473 * We have to free MSG body */
1474 if ((pMsgWrapper->pVosMsg->bodyptr) && (!pMsgWrapper->pVosMsg->type))
1475 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 vos_mem_free((v_VOID_t*)pMsgWrapper->pVosMsg->bodyptr);
1477 }
Leo Chang0f24ca12013-12-17 13:35:00 -08001478 /* MSG body pointer is not NULL
1479 * and MSG type is not 0
1480 * This MSG is posted by SMD NOTIFY
1481 * We should not free MSG body */
1482 else if ((pMsgWrapper->pVosMsg->bodyptr) && pMsgWrapper->pVosMsg->type)
1483 {
1484 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1485 "%s: SMD NOTIFY MSG, do not free body",
1486 __func__);
1487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 pMsgWrapper->pVosMsg->bodyptr = NULL;
1489 pMsgWrapper->pVosMsg->bodyval = 0;
1490 pMsgWrapper->pVosMsg->type = 0;
1491 }
1492 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1493 }
1494
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 /* Flush the PE Mq */
1496 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->peMcMq) ))
1497 {
1498 VOS_TRACE( VOS_MODULE_ID_VOSS,
Leo Chang0f24ca12013-12-17 13:35:00 -08001499 VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 "%s: Freeing MC PE MSG message type %d",__func__,
1501 pMsgWrapper->pVosMsg->type );
1502 peFreeMsg(vosCtx->pMACContext, (tSirMsgQ*)pMsgWrapper->pVosMsg);
1503 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1504 }
1505 /* Flush the SME Mq */
1506 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->smeMcMq) ))
1507 {
1508 VOS_TRACE( VOS_MODULE_ID_VOSS,
Leo Chang0f24ca12013-12-17 13:35:00 -08001509 VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 "%s: Freeing MC SME MSG message type %d", __func__,
1511 pMsgWrapper->pVosMsg->type );
1512 sme_FreeMsg(vosCtx->pMACContext, pMsgWrapper->pVosMsg);
1513 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1514 }
1515 /* Flush the TL Mq */
1516 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->tlMcMq) ))
1517 {
1518 VOS_TRACE( VOS_MODULE_ID_VOSS,
Leo Chang0f24ca12013-12-17 13:35:00 -08001519 VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 "%s: Freeing MC TL message type %d",__func__,
1521 pMsgWrapper->pVosMsg->type );
1522 WLANTL_McFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg);
1523 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001525} /* vos_sched_flush_mc_mqs() */
1526
1527/*-------------------------------------------------------------------------
1528 This helper function flushes all the TX message queues
1529 ------------------------------------------------------------------------*/
1530void vos_sched_flush_tx_mqs ( pVosSchedContext pSchedContext )
1531{
1532 pVosMsgWrapper pMsgWrapper = NULL;
1533 /*
1534 ** Here each of the TX thread MQ shall be drained and returned to the
1535 ** Core. Before returning a wrapper to the Core, the VOS message shall
1536 ** be freed first
1537 */
1538 VOS_TRACE( VOS_MODULE_ID_VOSS,
1539 VOS_TRACE_LEVEL_INFO,
1540 "%s: Flushing the TX Thread message queue",__func__);
1541
1542 if (NULL == pSchedContext)
1543 {
1544 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001545 "%s: pSchedContext is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 return;
1547 }
1548
1549 /* Flush the SYS Mq */
1550 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->sysTxMq) ))
1551 {
1552 VOS_TRACE( VOS_MODULE_ID_VOSS,
1553 VOS_TRACE_LEVEL_INFO,
1554 "%s: Freeing TX SYS message type %d",__func__,
1555 pMsgWrapper->pVosMsg->type );
1556 sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg);
1557 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1558 }
1559 /* Flush the TL Mq */
1560 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->tlTxMq) ))
1561 {
1562 VOS_TRACE( VOS_MODULE_ID_VOSS,
1563 VOS_TRACE_LEVEL_INFO,
1564 "%s: Freeing TX TL MSG message type %d",__func__,
1565 pMsgWrapper->pVosMsg->type );
1566 WLANTL_TxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg);
1567 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 /* Flush the WDI Mq */
1570 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdiTxMq) ))
1571 {
1572 VOS_TRACE( VOS_MODULE_ID_VOSS,
1573 VOS_TRACE_LEVEL_INFO,
1574 "%s: Freeing TX WDI MSG message type %d",__func__,
1575 pMsgWrapper->pVosMsg->type );
1576 sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg);
1577 vos_core_return_msg(pSchedContext->pVContext, pMsgWrapper);
1578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001579} /* vos_sched_flush_tx_mqs() */
Jeff Johnson295189b2012-06-20 16:38:30 -07001580/*-------------------------------------------------------------------------
1581 This helper function flushes all the RX message queues
1582 ------------------------------------------------------------------------*/
1583void vos_sched_flush_rx_mqs ( pVosSchedContext pSchedContext )
1584{
1585 pVosMsgWrapper pMsgWrapper = NULL;
1586 /*
1587 ** Here each of the RX thread MQ shall be drained and returned to the
1588 ** Core. Before returning a wrapper to the Core, the VOS message shall
1589 ** be freed first
1590 */
1591 VOS_TRACE( VOS_MODULE_ID_VOSS,
1592 VOS_TRACE_LEVEL_INFO,
1593 "%s: Flushing the RX Thread message queue",__func__);
1594
1595 if (NULL == pSchedContext)
1596 {
1597 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001598 "%s: pSchedContext is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 return;
1600 }
1601
1602 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->wdiRxMq) ))
1603 {
1604 VOS_TRACE( VOS_MODULE_ID_VOSS,
1605 VOS_TRACE_LEVEL_INFO,
1606 "%s: Freeing RX WDI MSG message type %d",__func__,
1607 pMsgWrapper->pVosMsg->type );
1608 sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg);
1609 }
1610
1611 while( NULL != (pMsgWrapper = vos_mq_get(&pSchedContext->sysRxMq) ))
1612 {
1613 VOS_TRACE( VOS_MODULE_ID_VOSS,
1614 VOS_TRACE_LEVEL_INFO,
1615 "%s: Freeing RX SYS MSG message type %d",__func__,
1616 pMsgWrapper->pVosMsg->type );
1617 sysTxFreeMsg(pSchedContext->pVContext, pMsgWrapper->pVosMsg);
1618 }
1619
1620}/* vos_sched_flush_rx_mqs() */
Jeff Johnson295189b2012-06-20 16:38:30 -07001621
1622/*-------------------------------------------------------------------------
1623 This helper function helps determine if thread id is of TX thread
1624 ------------------------------------------------------------------------*/
1625int vos_sched_is_tx_thread(int threadID)
1626{
1627 // Make sure that Vos Scheduler context has been initialized
1628 VOS_ASSERT( NULL != gpVosSchedContext);
1629 if (gpVosSchedContext == NULL)
1630 {
1631 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001632 "%s: gpVosSchedContext == NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 return 0;
1634 }
1635 return ((gpVosSchedContext->TxThread) && (threadID == gpVosSchedContext->TxThread->pid));
1636}
Jeff Johnson295189b2012-06-20 16:38:30 -07001637/*-------------------------------------------------------------------------
1638 This helper function helps determine if thread id is of RX thread
1639 ------------------------------------------------------------------------*/
1640int vos_sched_is_rx_thread(int threadID)
1641{
1642 // Make sure that Vos Scheduler context has been initialized
1643 VOS_ASSERT( NULL != gpVosSchedContext);
1644 if (gpVosSchedContext == NULL)
1645 {
1646 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001647 "%s: gpVosSchedContext == NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 return 0;
1649 }
1650 return ((gpVosSchedContext->RxThread) && (threadID == gpVosSchedContext->RxThread->pid));
1651}
Jeff Johnson295189b2012-06-20 16:38:30 -07001652/*-------------------------------------------------------------------------
1653 Helper function to get the scheduler context
1654 ------------------------------------------------------------------------*/
1655pVosSchedContext get_vos_sched_ctxt(void)
1656{
1657 //Make sure that Vos Scheduler context has been initialized
1658 if (gpVosSchedContext == NULL)
1659 {
1660 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001661 "%s: gpVosSchedContext == NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 }
1663 return (gpVosSchedContext);
1664}
1665/*-------------------------------------------------------------------------
1666 Helper function to get the watchdog context
1667 ------------------------------------------------------------------------*/
1668pVosWatchdogContext get_vos_watchdog_ctxt(void)
1669{
1670 //Make sure that Vos Scheduler context has been initialized
1671 if (gpVosWatchdogContext == NULL)
1672 {
1673 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001674 "%s: gpVosWatchdogContext == NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 }
1676 return (gpVosWatchdogContext);
1677}
1678/**
1679 @brief vos_watchdog_wlan_shutdown()
1680
1681 This function is called to shutdown WLAN driver during SSR.
1682 Adapters are disabled, and the watchdog task will be signalled
1683 to shutdown WLAN driver.
1684
1685 @param
1686 NONE
1687 @return
1688 VOS_STATUS_SUCCESS - Operation completed successfully.
1689 VOS_STATUS_E_FAILURE - Operation failed.
1690
1691*/
1692VOS_STATUS vos_watchdog_wlan_shutdown(void)
1693{
1694 v_CONTEXT_t pVosContext = NULL;
1695 hdd_context_t *pHddCtx = NULL;
1696
1697 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001698 "%s: WLAN driver is shutting down ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 if (NULL == gpVosWatchdogContext)
1700 {
1701 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001702 "%s: Watchdog not enabled. LOGP ignored.", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 return VOS_STATUS_E_FAILURE;
1704 }
1705
1706 pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL);
1707 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1708 if (NULL == pHddCtx)
1709 {
1710 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001711 "%s: Invalid HDD Context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 return VOS_STATUS_E_FAILURE;
1713 }
1714
1715 /* Take the lock here */
1716 spin_lock(&gpVosWatchdogContext->wdLock);
1717
1718 /* reuse the existing 'reset in progress' */
1719 if (gpVosWatchdogContext->resetInProgress)
1720 {
1721 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1722 "%s: Shutdown already in Progress. Ignoring signaling Watchdog",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001723 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 /* Release the lock here */
1725 spin_unlock(&gpVosWatchdogContext->wdLock);
1726 return VOS_STATUS_E_FAILURE;
1727 }
1728 /* reuse the existing 'logp in progress', eventhough it is not
1729 * exactly the same */
1730 else if (pHddCtx->isLogpInProgress)
1731 {
1732 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1733 "%s: shutdown/re-init already in Progress. Ignoring signaling Watchdog",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001734 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 /* Release the lock here */
1736 spin_unlock(&gpVosWatchdogContext->wdLock);
1737 return VOS_STATUS_E_FAILURE;
1738 }
1739
1740 /* Set the flags so that all future CMD53 and Wext commands get blocked right away */
1741 vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, TRUE);
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001742 vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 pHddCtx->isLogpInProgress = TRUE;
1744
1745 /* Release the lock here */
1746 spin_unlock(&gpVosWatchdogContext->wdLock);
1747
1748 if (pHddCtx->isLoadUnloadInProgress)
1749 {
1750 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1751 "%s: Load/unload in Progress. Ignoring signaling Watchdog",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001752 __func__);
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07001753 /* wcnss has crashed, and SSR has alredy been started by Kernel driver.
1754 * So disable SSR from WLAN driver */
1755 hdd_set_ssr_required( HDD_SSR_DISABLED );
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 return VOS_STATUS_E_FAILURE;
1757 }
1758 /* Update Riva Reset Statistics */
1759 pHddCtx->hddRivaResetStats++;
1760#ifdef CONFIG_HAS_EARLYSUSPEND
1761 if(VOS_STATUS_SUCCESS != hdd_wlan_reset_initialization())
1762 {
1763 VOS_ASSERT(0);
1764 }
1765#endif
1766
1767 set_bit(WD_WLAN_SHUTDOWN_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag);
1768 set_bit(WD_POST_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag);
1769 wake_up_interruptible(&gpVosWatchdogContext->wdWaitQueue);
1770
1771 return VOS_STATUS_SUCCESS;
1772}
1773
1774/**
1775 @brief vos_watchdog_wlan_re_init()
1776
1777 This function is called to re-initialize WLAN driver, and this is
1778 called when Riva SS reboots.
1779
1780 @param
1781 NONE
1782 @return
1783 VOS_STATUS_SUCCESS - Operation completed successfully.
1784 VOS_STATUS_E_FAILURE - Operation failed.
1785
1786*/
1787VOS_STATUS vos_watchdog_wlan_re_init(void)
1788{
1789 /* watchdog task is still running, it is not closed in shutdown */
1790 set_bit(WD_WLAN_REINIT_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag);
1791 set_bit(WD_POST_EVENT_MASK, &gpVosWatchdogContext->wdEventFlag);
1792 wake_up_interruptible(&gpVosWatchdogContext->wdWaitQueue);
1793
1794 return VOS_STATUS_SUCCESS;
1795}