blob: b42b870c673409902547da4782a297b3c0e778ee [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**=========================================================================
Jeff Johnson2f5cfec2013-02-22 21:25:10 -080043
Jeff Johnson295189b2012-06-20 16:38:30 -070044 \file vos_api.c
45
46 \brief Stub file for all virtual Operating System Services (vOSS) APIs
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48 ========================================================================*/
49 /*===========================================================================
50
51 EDIT HISTORY FOR FILE
52
53
54 This section contains comments describing changes made to the module.
55 Notice that changes are listed in reverse chronological order.
56
57
58 $Header:$ $DateTime: $ $Author: $
59
60
61 when who what, where, why
62 -------- --- --------------------------------------------------------
63 03/29/09 kanand Created module.
64===========================================================================*/
65
66/*--------------------------------------------------------------------------
67 Include Files
68 ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include <vos_mq.h>
70#include "vos_sched.h"
71#include <vos_api.h>
72#include "sirTypes.h"
73#include "sirApi.h"
74#include "sirMacProtDef.h"
75#include "sme_Api.h"
76#include "macInitApi.h"
77#include "wlan_qct_sys.h"
78#include "wlan_qct_tl.h"
79#include "wlan_hdd_misc.h"
80#include "i_vos_packet.h"
81#include "vos_nvitem.h"
82#include "wlan_qct_wda.h"
83#include "wlan_hdd_main.h"
84#include <linux/vmalloc.h>
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -070085#include "wlan_hdd_cfg80211.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086
Jeff Johnson295189b2012-06-20 16:38:30 -070087#include "sapApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070088
89
90
91#ifdef WLAN_BTAMP_FEATURE
92#include "bapApi.h"
93#include "bapInternal.h"
94#include "bap_hdd_main.h"
95#endif //WLAN_BTAMP_FEATURE
96
97
98/*---------------------------------------------------------------------------
99 * Preprocessor Definitions and Constants
100 * ------------------------------------------------------------------------*/
101/* Amount of time to wait for WDA to perform an asynchronous activity.
102 This value should be larger than the timeout used by WDI to wait for
103 a response from WCNSS since in the event that WCNSS is not responding,
104 WDI should handle that timeout */
105#define VOS_WDA_TIMEOUT 15000
106
107/* Approximate amount of time to wait for WDA to stop WDI */
108#define VOS_WDA_STOP_TIMEOUT WDA_STOP_TIMEOUT
109
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +0530110/* Approximate amount of time to wait for WDA to issue a DUMP req */
111#define VOS_WDA_RESP_TIMEOUT WDA_STOP_TIMEOUT
112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113/*---------------------------------------------------------------------------
114 * Data definitions
115 * ------------------------------------------------------------------------*/
116static VosContextType gVosContext;
117static pVosContextType gpVosContext;
118
119/*---------------------------------------------------------------------------
120 * Forward declaration
121 * ------------------------------------------------------------------------*/
122v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
123
Jeff Johnson295189b2012-06-20 16:38:30 -0700124v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
125
126v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
127 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700128
129
130/*---------------------------------------------------------------------------
131
132 \brief vos_preOpen() - PreOpen the vOSS Module
133
134 The \a vos_preOpen() function allocates the Vos Context, but do not
135 initialize all the members. This overal initialization will happen
136 at vos_Open().
137 The reason why we need vos_preOpen() is to get a minimum context
138 where to store BAL and SAL relative data, which happens before
139 vos_Open() is called.
140
141 \param pVosContext: A pointer to where to store the VOS Context
142
143
144 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
145 is ready to be used.
146
147 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
148
149 \sa vos_Open()
150
151---------------------------------------------------------------------------*/
152VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
153{
154 if ( pVosContext == NULL)
155 return VOS_STATUS_E_FAILURE;
156
157 /* Allocate the VOS Context */
158 *pVosContext = NULL;
159 gpVosContext = &gVosContext;
160
161 if (NULL == gpVosContext)
162 {
163 /* Critical Error ...Cannot proceed further */
164 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
165 "%s: Failed to allocate VOS Context", __func__);
166 VOS_ASSERT(0);
167 return VOS_STATUS_E_RESOURCES;
168 }
169
170 vos_mem_zero(gpVosContext, sizeof(VosContextType));
171
172 *pVosContext = gpVosContext;
173
174 return VOS_STATUS_SUCCESS;
175
176} /* vos_preOpen()*/
177
178
179/*---------------------------------------------------------------------------
180
181 \brief vos_preClose() - PreClose the vOSS Module
182
183 The \a vos_preClose() function frees the Vos Context.
184
185 \param pVosContext: A pointer to where the VOS Context was stored
186
187
188 \return VOS_STATUS_SUCCESS - Always successful
189
190
191 \sa vos_preClose()
192 \sa vos_close()
193---------------------------------------------------------------------------*/
194VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
195{
196
197 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
198 "%s: De-allocating the VOS Context", __func__);
199
200 if (( pVosContext == NULL) || (*pVosContext == NULL))
201 {
202 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
203 "%s: vOS Context is Null", __func__);
204 return VOS_STATUS_E_FAILURE;
205 }
206
207 if (gpVosContext != *pVosContext)
208 {
209 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
210 "%s: Context mismatch", __func__);
211 return VOS_STATUS_E_FAILURE;
212 }
213
214 *pVosContext = gpVosContext = NULL;
215
216 return VOS_STATUS_SUCCESS;
217
218} /* vos_preClose()*/
219
220/*---------------------------------------------------------------------------
221
222 \brief vos_open() - Open the vOSS Module
223
224 The \a vos_open() function opens the vOSS Scheduler
225 Upon successful initialization:
226
227 - All VOS submodules should have been initialized
228
229 - The VOS scheduler should have opened
230
231 - All the WLAN SW components should have been opened. This includes
232 SYS, MAC, SME, WDA and TL.
233
234
235 \param hddContextSize: Size of the HDD context to allocate.
236
237
238 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
239 is ready to be used.
240
241 VOS_STATUS_E_RESOURCES - System resources (other than memory)
242 are unavailable to initilize the scheduler
243
244
245 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
246
247 \sa vos_preOpen()
248
249---------------------------------------------------------------------------*/
250VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, v_SIZE_t hddContextSize )
251
252{
253 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
254 int iter = 0;
255 tSirRetStatus sirStatus = eSIR_SUCCESS;
256 tMacOpenParameters macOpenParms;
257 WLANTL_ConfigInfoType TLConfig;
258
259 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
260 "%s: Opening VOSS", __func__);
261
262 if (NULL == gpVosContext)
263 {
264 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
265 "%s: Trying to open VOSS without a PreOpen", __func__);
266 VOS_ASSERT(0);
267 return VOS_STATUS_E_FAILURE;
268 }
269
270 /* Initialize the timer module */
271 vos_timer_module_init();
272
273 /* Initialize the probe event */
274 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
275 {
276 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
277 "%s: Unable to init probeEvent", __func__);
278 VOS_ASSERT(0);
279 return VOS_STATUS_E_FAILURE;
280 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
282 {
283 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
284 "%s: Unable to init wdaCompleteEvent", __func__);
285 VOS_ASSERT(0);
286
287 goto err_probe_event;
288 }
289
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 /* Initialize the free message queue */
291 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
292 if (! VOS_IS_STATUS_SUCCESS(vStatus))
293 {
294
295 /* Critical Error ... Cannot proceed further */
296 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
297 "%s: Failed to initialize VOS free message queue", __func__);
298 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 goto err_wda_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 }
301
302 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
303 {
304 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
305 &(gpVosContext->aMsgBuffers[iter]);
306 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
307 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
308 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700309
310 /* Now Open the VOS Scheduler */
311 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
312 sizeof(VosSchedContext));
313
314 if (!VOS_IS_STATUS_SUCCESS(vStatus))
315 {
316 /* Critical Error ... Cannot proceed further */
317 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
318 "%s: Failed to open VOS Scheduler", __func__);
319 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 }
322
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 /*
324 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
325 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
326 */
327
328 /*Open the WDA module */
329 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
330 /* UMA is supported in hardware for performing the
331 ** frame translation 802.11 <-> 802.3
332 */
333 macOpenParms.frameTransRequired = 1;
334 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
335 vStatus = WDA_open( gpVosContext, gpVosContext->pHDDContext, &macOpenParms );
336
337 if (!VOS_IS_STATUS_SUCCESS(vStatus))
338 {
339 /* Critical Error ... Cannot proceed further */
340 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
341 "%s: Failed to open WDA module", __func__);
342 VOS_ASSERT(0);
343 goto err_sched_close;
344 }
345
346 /* Initialize here the VOS Packet sub module */
347 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
348 sizeof( vos_pkt_context_t ) );
349
350 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
351 {
352 /* Critical Error ... Cannot proceed further */
353 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
354 "%s: Failed to open VOS Packet Module", __func__);
355 VOS_ASSERT(0);
356 goto err_wda_close;
357 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700358
359 /* Open the SYS module */
360 vStatus = sysOpen(gpVosContext);
361
362 if (!VOS_IS_STATUS_SUCCESS(vStatus))
363 {
364 /* Critical Error ... Cannot proceed further */
365 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
366 "%s: Failed to open SYS module", __func__);
367 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 }
370
371
372 /* initialize the NV module */
373 vStatus = vos_nv_open();
374 if (!VOS_IS_STATUS_SUCCESS(vStatus))
375 {
376 // NV module cannot be initialized
377 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
378 "%s: Failed to initialize the NV module", __func__);
379 goto err_sys_close;
380 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
382 /* If we arrive here, both threads dispacthing messages correctly */
383
384 /* Now proceed to open the MAC */
385
386 /* UMA is supported in hardware for performing the
387 frame translation 802.11 <-> 802.3 */
388 macOpenParms.frameTransRequired = 1;
389 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
390 &macOpenParms);
391
392 if (eSIR_SUCCESS != sirStatus)
393 {
394 /* Critical Error ... Cannot proceed further */
395 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
396 "%s: Failed to open MAC", __func__);
397 VOS_ASSERT(0);
398 goto err_nv_close;
399 }
400
401 /* Now proceed to open the SME */
402 vStatus = sme_Open(gpVosContext->pMACContext);
403 if (!VOS_IS_STATUS_SUCCESS(vStatus))
404 {
405 /* Critical Error ... Cannot proceed further */
406 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
407 "%s: Failed to open SME", __func__);
408 VOS_ASSERT(0);
409 goto err_mac_close;
410 }
411
412 /* Now proceed to open TL. Read TL config first */
413 vos_fetch_tl_cfg_parms ( &TLConfig,
414 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
415
416 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
417 if (!VOS_IS_STATUS_SUCCESS(vStatus))
418 {
419 /* Critical Error ... Cannot proceed further */
420 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
421 "%s: Failed to open TL", __func__);
422 VOS_ASSERT(0);
423 goto err_sme_close;
424 }
425
426 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
427 "%s: VOSS successfully Opened", __func__);
428
429 *pVosContext = gpVosContext;
430
431 return VOS_STATUS_SUCCESS;
432
433
434err_sme_close:
435 sme_Close(gpVosContext->pMACContext);
436
437err_mac_close:
438 macClose(gpVosContext->pMACContext);
439
440err_nv_close:
441 vos_nv_close();
442
443err_sys_close:
444 sysClose(gpVosContext);
445
Jeff Johnson295189b2012-06-20 16:38:30 -0700446err_packet_close:
447 vos_packet_close( gpVosContext );
448
449err_wda_close:
450 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700451
452err_sched_close:
453 vos_sched_close(gpVosContext);
454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455
456err_msg_queue:
457 vos_mq_deinit(&gpVosContext->freeVosMq);
458
Jeff Johnson295189b2012-06-20 16:38:30 -0700459err_wda_complete_event:
460 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700461
462err_probe_event:
463 vos_event_destroy(&gpVosContext->ProbeEvent);
464
465 return VOS_STATUS_E_FAILURE;
466
467} /* vos_open() */
468
Jeff Johnson295189b2012-06-20 16:38:30 -0700469/*---------------------------------------------------------------------------
470
471 \brief vos_preStart() -
472
473 The \a vos_preStart() function to download CFG.
474 including:
475 - ccmStart
476
477 - WDA: triggers the CFG download
478
479
480 \param pVosContext: The VOS context
481
482
483 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
484 is ready to be used.
485
486 VOS_STATUS_E_RESOURCES - System resources (other than memory)
487 are unavailable to initilize the scheduler
488
489
490 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
491
492 \sa vos_start
493
494---------------------------------------------------------------------------*/
495VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
496{
497 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
498 pVosContextType pVosContext = (pVosContextType)vosContext;
499
500 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
501 "vos prestart");
502
503 VOS_ASSERT(gpVosContext == pVosContext);
504
505 VOS_ASSERT( NULL != pVosContext->pMACContext);
506
507 VOS_ASSERT( NULL != pVosContext->pWDAContext);
508
509 /* call macPreStart */
510 vStatus = macPreStart(gpVosContext->pMACContext);
511 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
512 {
513 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
514 "Failed at macPreStart ");
515 return VOS_STATUS_E_FAILURE;
516 }
517
518 /* call ccmStart */
519 ccmStart(gpVosContext->pMACContext);
520
521 /* Reset wda wait event */
522 vos_event_reset(&gpVosContext->wdaCompleteEvent);
523
524
525 /*call WDA pre start*/
526 vStatus = WDA_preStart(gpVosContext);
527 if (!VOS_IS_STATUS_SUCCESS(vStatus))
528 {
529 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
530 "Failed to WDA prestart");
531 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
532 ccmStop(gpVosContext->pMACContext);
533 VOS_ASSERT(0);
534 return VOS_STATUS_E_FAILURE;
535 }
536
537 /* Need to update time out of complete */
538 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
539 VOS_WDA_TIMEOUT );
540 if ( vStatus != VOS_STATUS_SUCCESS )
541 {
542 if ( vStatus == VOS_STATUS_E_TIMEOUT )
543 {
544 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
545 "%s: Timeout occurred before WDA complete\n", __func__);
546 }
547 else
548 {
549 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
550 "%s: WDA_preStart reporting other error", __func__);
551 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700552 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
553 "%s: Test MC thread by posting a probe message to SYS", __func__);
554 wlan_sys_probe();
555
Jeff Johnsone7245742012-09-05 17:12:55 -0700556 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
557 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 VOS_ASSERT( 0 );
559 return VOS_STATUS_E_FAILURE;
560 }
561
562 return VOS_STATUS_SUCCESS;
563}
Jeff Johnson295189b2012-06-20 16:38:30 -0700564
565/*---------------------------------------------------------------------------
566
567 \brief vos_start() - Start the Libra SW Modules
568
569 The \a vos_start() function starts all the components of the Libra SW
570 including:
571 - SAL/BAL, which in turn starts SSC
572
573 - the MAC (HAL and PE)
574
575 - SME
576
577 - TL
578
579 - SYS: triggers the CFG download
580
581
582 \param pVosContext: The VOS context
583
584
585 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
586 is ready to be used.
587
588 VOS_STATUS_E_RESOURCES - System resources (other than memory)
589 are unavailable to initilize the scheduler
590
591
592 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
593
594 \sa vos_preStart()
595 \sa vos_open()
596
597---------------------------------------------------------------------------*/
598VOS_STATUS vos_start( v_CONTEXT_t vosContext )
599{
600 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
601 tSirRetStatus sirStatus = eSIR_SUCCESS;
602 pVosContextType pVosContext = (pVosContextType)vosContext;
603 tHalMacStartParameters halStartParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700604
605 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
606 "%s: Starting Libra SW", __func__);
607
608 /* We support only one instance for now ...*/
609 if (gpVosContext != pVosContext)
610 {
611 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700612 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 return VOS_STATUS_E_FAILURE;
614 }
615
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
617 || ( pVosContext->pTLContext == NULL))
618 {
619 if (pVosContext->pWDAContext == NULL)
620 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700621 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 else if (pVosContext->pMACContext == NULL)
623 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700624 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 else
626 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700627 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700628
629 return VOS_STATUS_E_FAILURE;
630 }
631
632 /* WDA_Start will be called after NV image download because the
633 NV image data has to be updated at HAL before HAL_Start gets executed*/
634
635 /* Start the NV Image Download */
636
637 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
638
639 vStatus = WDA_NVDownload_Start(pVosContext);
640
641 if ( vStatus != VOS_STATUS_SUCCESS )
642 {
643 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
644 "%s: Failed to start NV Download", __func__);
645 return VOS_STATUS_E_FAILURE;
646 }
647
648 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
649 VOS_WDA_TIMEOUT );
650
651 if ( vStatus != VOS_STATUS_SUCCESS )
652 {
653 if ( vStatus == VOS_STATUS_E_TIMEOUT )
654 {
655 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
656 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
657 }
658 else
659 {
660 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
661 "%s: WDA_NVDownload_start reporting other error", __func__);
662 }
663 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800664 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700665 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
666 {
667 VOS_BUG(0);
668 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800669 WDA_setNeedShutdown(vosContext);
670 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 }
672
673 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
674 "%s: WDA_NVDownload_start correctly started", __func__);
675
676 /* Start the WDA */
677 vStatus = WDA_start(pVosContext);
678 if ( vStatus != VOS_STATUS_SUCCESS )
679 {
680 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
681 "%s: Failed to start WDA", __func__);
682 return VOS_STATUS_E_FAILURE;
683 }
684 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
685 "%s: WDA correctly started", __func__);
686
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 /* Start the MAC */
688 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 /* Start the MAC */
691 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 if (eSIR_SUCCESS != sirStatus)
694 {
695 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
696 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 }
699
700 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
701 "%s: MAC correctly started", __func__);
702
703 /* START SME */
704 vStatus = sme_Start(pVosContext->pMACContext);
705
706 if (!VOS_IS_STATUS_SUCCESS(vStatus))
707 {
708 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
709 "%s: Failed to start SME", __func__);
710 goto err_mac_stop;
711 }
712
713 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
714 "%s: SME correctly started", __func__);
715
716 /** START TL */
717 vStatus = WLANTL_Start(pVosContext);
718 if (!VOS_IS_STATUS_SUCCESS(vStatus))
719 {
720 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
721 "%s: Failed to start TL", __func__);
722 goto err_sme_stop;
723 }
724
725 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
726 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
728 "%s: VOSS Start is successful!!", __func__);
729
730 return VOS_STATUS_SUCCESS;
731
Jeff Johnson295189b2012-06-20 16:38:30 -0700732
733err_sme_stop:
734 sme_Stop(pVosContext->pMACContext, TRUE);
735
736err_mac_stop:
737 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
738
Jeff Johnson295189b2012-06-20 16:38:30 -0700739err_wda_stop:
740 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800741 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
742 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800744 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
745 "%s: Failed to stop WDA", __func__);
746 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800747 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800748 }
749 else
750 {
751 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
752 VOS_WDA_TIMEOUT );
753 if( vStatus != VOS_STATUS_SUCCESS )
754 {
755 if( vStatus == VOS_STATUS_E_TIMEOUT )
756 {
757 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
758 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700759
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800760 }
761 else
762 {
763 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
764 "%s: WDA_stop reporting other error", __func__);
765 }
766 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800767 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800768 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700770
771 return VOS_STATUS_E_FAILURE;
772
773} /* vos_start() */
774
775
776/* vos_stop function */
777VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
778{
779 VOS_STATUS vosStatus;
780
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 /* WDA_Stop is called before the SYS so that the processing of Riva
782 pending responces will not be handled during uninitialization of WLAN driver */
783 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
784
785 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
786
787 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
788 {
789 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
790 "%s: Failed to stop WDA", __func__);
791 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800792 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -0700794 else
795 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800796 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
797 VOS_WDA_STOP_TIMEOUT );
Jeff Johnson295189b2012-06-20 16:38:30 -0700798
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800799 if ( vosStatus != VOS_STATUS_SUCCESS )
800 {
801 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
802 {
803 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
804 "%s: Timeout occurred before WDA complete", __func__);
805 }
806 else
807 {
808 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
809 "%s: WDA_stop reporting other error", __func__ );
810 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700811 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
812 "%s: Test MC thread by posting a probe message to SYS", __func__);
813 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800814 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800815 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700817
818 /* SYS STOP will stop SME and MAC */
819 vosStatus = sysStop( vosContext);
820 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
821 {
822 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
823 "%s: Failed to stop SYS", __func__);
824 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
825 }
826
827 vosStatus = WLANTL_Stop( vosContext );
828 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
829 {
830 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
831 "%s: Failed to stop TL", __func__);
832 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
833 }
834
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
836 return VOS_STATUS_SUCCESS;
837}
838
839
840/* vos_close function */
841VOS_STATUS vos_close( v_CONTEXT_t vosContext )
842{
843 VOS_STATUS vosStatus;
844
845#ifdef WLAN_BTAMP_FEATURE
846 vosStatus = WLANBAP_Close(vosContext);
847 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
848 {
849 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
850 "%s: Failed to close BAP", __func__);
851 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
852 }
853#endif // WLAN_BTAMP_FEATURE
854
855
856 vosStatus = WLANTL_Close(vosContext);
857 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
858 {
859 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
860 "%s: Failed to close TL", __func__);
861 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
862 }
863
864 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
865 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
866 {
867 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
868 "%s: Failed to close SME", __func__);
869 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
870 }
871
872 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
873 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
874 {
875 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
876 "%s: Failed to close MAC", __func__);
877 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
878 }
879
880 ((pVosContextType)vosContext)->pMACContext = NULL;
881
882 vosStatus = vos_nv_close();
883 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
884 {
885 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
886 "%s: Failed to close NV", __func__);
887 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
888 }
889
890
891 vosStatus = sysClose( vosContext );
892 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
893 {
894 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
895 "%s: Failed to close SYS", __func__);
896 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
897 }
898
Jeff Johnsone7245742012-09-05 17:12:55 -0700899 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700901 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
902 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
903 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
904 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -0700905 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -0700906 }
907 else
908 {
909 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
910 "%s: Failed to shutdown WDA", __func__ );
911 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
912 }
913 }
914 else
915 {
916 vosStatus = WDA_close( vosContext );
917 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
918 {
919 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
920 "%s: Failed to close WDA", __func__);
921 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
922 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 }
924
925 /* Let DXE return packets in WDA_close and then free them here */
926 vosStatus = vos_packet_close( vosContext );
927 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
928 {
929 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
930 "%s: Failed to close VOSS Packet", __func__);
931 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
932 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934
935 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
936
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
938 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
939 {
940 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
941 "%s: failed to destroy wdaCompleteEvent", __func__);
942 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
943 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700944
945 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
946 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
947 {
948 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
949 "%s: failed to destroy ProbeEvent", __func__);
950 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
951 }
952
953 return VOS_STATUS_SUCCESS;
954}
955
956
957/**---------------------------------------------------------------------------
958
959 \brief vos_get_context() - get context data area
960
961 Each module in the system has a context / data area that is allocated
962 and maanged by voss. This API allows any user to get a pointer to its
963 allocated context data area from the VOSS global context.
964
965 \param vosContext - the VOSS Global Context.
966
967 \param moduleId - the module ID, who's context data are is being retrived.
968
969 \return - pointer to the context data area.
970
971 - NULL if the context data is not allocated for the module ID
972 specified
973
974 --------------------------------------------------------------------------*/
975v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
976 v_CONTEXT_t pVosContext )
977{
978 v_PVOID_t pModContext = NULL;
979
980 if (pVosContext == NULL)
981 {
982 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700983 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 return NULL;
985 }
986
987 if (gpVosContext != pVosContext)
988 {
989 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700990 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 return NULL;
992 }
993
994 switch(moduleId)
995 {
996 case VOS_MODULE_ID_TL:
997 {
998 pModContext = gpVosContext->pTLContext;
999 break;
1000 }
1001
Jeff Johnson295189b2012-06-20 16:38:30 -07001002#ifdef WLAN_BTAMP_FEATURE
1003 case VOS_MODULE_ID_BAP:
1004 {
1005 pModContext = gpVosContext->pBAPContext;
1006 break;
1007 }
1008#endif //WLAN_BTAMP_FEATURE
1009
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 case VOS_MODULE_ID_SAP:
1011 {
1012 pModContext = gpVosContext->pSAPContext;
1013 break;
1014 }
1015
1016 case VOS_MODULE_ID_HDD_SOFTAP:
1017 {
1018 pModContext = gpVosContext->pHDDSoftAPContext;
1019 break;
1020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001021
1022 case VOS_MODULE_ID_HDD:
1023 {
1024 pModContext = gpVosContext->pHDDContext;
1025 break;
1026 }
1027
1028 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301030 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 {
1032 /*
1033 ** In all these cases, we just return the MAC Context
1034 */
1035 pModContext = gpVosContext->pMACContext;
1036 break;
1037 }
1038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 case VOS_MODULE_ID_WDA:
1040 {
1041 /* For WDA module */
1042 pModContext = gpVosContext->pWDAContext;
1043 break;
1044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001045
1046 case VOS_MODULE_ID_VOSS:
1047 {
1048 /* For SYS this is VOS itself*/
1049 pModContext = gpVosContext;
1050 break;
1051 }
1052
1053 default:
1054 {
1055 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1056 "does not have its context maintained by VOSS", __func__, moduleId);
1057 VOS_ASSERT(0);
1058 return NULL;
1059 }
1060 }
1061
1062 if (pModContext == NULL )
1063 {
1064 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1065 "context is Null", __func__, moduleId);
1066 }
1067
1068 return pModContext;
1069
1070} /* vos_get_context()*/
1071
1072
1073/**---------------------------------------------------------------------------
1074
1075 \brief vos_get_global_context() - get VOSS global Context
1076
1077 This API allows any user to get the VOS Global Context pointer from a
1078 module context data area.
1079
1080 \param moduleContext - the input module context pointer
1081
1082 \param moduleId - the module ID who's context pointer is input in
1083 moduleContext.
1084
1085 \return - pointer to the VOSS global context
1086
1087 - NULL if the function is unable to retreive the VOSS context.
1088
1089 --------------------------------------------------------------------------*/
1090v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1091 v_VOID_t *moduleContext )
1092{
1093 if (gpVosContext == NULL)
1094 {
1095 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001096 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 }
1098
1099 return gpVosContext;
1100
1101} /* vos_get_global_context() */
1102
1103
1104v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1105{
1106 if (gpVosContext == NULL)
1107 {
1108 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001109 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 return 1;
1111 }
1112
1113 return gpVosContext->isLogpInProgress;
1114}
1115
1116void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1117{
1118 if (gpVosContext == NULL)
1119 {
1120 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001121 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 return;
1123 }
1124
1125 gpVosContext->isLogpInProgress = value;
1126}
1127
1128v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1129{
1130 if (gpVosContext == NULL)
1131 {
1132 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001133 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 return 0;
1135 }
1136
1137 return gpVosContext->isLoadUnloadInProgress;
1138}
1139
1140void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1141{
1142 if (gpVosContext == NULL)
1143 {
1144 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001145 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 return;
1147 }
1148
1149 gpVosContext->isLoadUnloadInProgress = value;
1150}
1151
1152/**---------------------------------------------------------------------------
1153
1154 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1155
1156 This API allows any user to allocate a user context area within the
1157 VOS Global Context.
1158
1159 \param pVosContext - pointer to the global Vos context
1160
1161 \param moduleId - the module ID who's context area is being allocated.
1162
1163 \param ppModuleContext - pointer to location where the pointer to the
1164 allocated context is returned. Note this
1165 output pointer is valid only if the API
1166 returns VOS_STATUS_SUCCESS
1167
1168 \param size - the size of the context area to be allocated.
1169
1170 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1171 allocated successfully. The pointer to the context area
1172 can be found in *ppModuleContext.
1173 \note This function returns VOS_STATUS_SUCCESS if the
1174 module context was already allocated and the size
1175 allocated matches the size on this call.
1176
1177 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1178 not identify a module that can have a context allocated.
1179
1180 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1181 because a context for this module ID already exists and it is
1182 a *different* size that specified on this call.
1183
1184 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1185 requested context area.
1186
1187 \sa vos_get_context(), vos_free_context()
1188
1189 --------------------------------------------------------------------------*/
1190VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1191 v_VOID_t **ppModuleContext, v_SIZE_t size )
1192{
1193 v_VOID_t ** pGpModContext = NULL;
1194
1195 if ( pVosContext == NULL) {
1196 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001197 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 return VOS_STATUS_E_FAILURE;
1199 }
1200
1201 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1202 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001203 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 return VOS_STATUS_E_FAILURE;
1205 }
1206
1207 switch(moduleID)
1208 {
1209 case VOS_MODULE_ID_TL:
1210 {
1211 pGpModContext = &(gpVosContext->pTLContext);
1212 break;
1213 }
1214
Jeff Johnson295189b2012-06-20 16:38:30 -07001215#ifdef WLAN_BTAMP_FEATURE
1216 case VOS_MODULE_ID_BAP:
1217 {
1218 pGpModContext = &(gpVosContext->pBAPContext);
1219 break;
1220 }
1221#endif //WLAN_BTAMP_FEATURE
1222
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 case VOS_MODULE_ID_SAP:
1224 {
1225 pGpModContext = &(gpVosContext->pSAPContext);
1226 break;
1227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001228
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 case VOS_MODULE_ID_WDA:
1230 {
1231 pGpModContext = &(gpVosContext->pWDAContext);
1232 break;
1233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301236 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 default:
1240 {
1241 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1242 "does not have its context allocated by VOSS", __func__, moduleID);
1243 VOS_ASSERT(0);
1244 return VOS_STATUS_E_INVAL;
1245 }
1246 }
1247
1248 if ( NULL != *pGpModContext)
1249 {
1250 /*
1251 ** Context has already been allocated!
1252 ** Prevent double allocation
1253 */
1254 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1255 "%s: Module ID %i context has already been allocated",
1256 __func__, moduleID);
1257 return VOS_STATUS_E_EXISTS;
1258 }
1259
1260 /*
1261 ** Dynamically allocate the context for module
1262 */
1263
1264 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1265
1266
1267 if ( *ppModuleContext == NULL)
1268 {
1269 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1270 "allocate Context for module ID %i", __func__, moduleID);
1271 VOS_ASSERT(0);
1272 return VOS_STATUS_E_NOMEM;
1273 }
1274
1275 if (moduleID==VOS_MODULE_ID_TL)
1276 {
1277 vos_mem_zero(*ppModuleContext, size);
1278 }
1279
1280 *pGpModContext = *ppModuleContext;
1281
1282 return VOS_STATUS_SUCCESS;
1283
1284} /* vos_alloc_context() */
1285
1286
1287/**---------------------------------------------------------------------------
1288
1289 \brief vos_free_context() - free an allocated a context within the
1290 VOSS global Context
1291
1292 This API allows a user to free the user context area within the
1293 VOS Global Context.
1294
1295 \param pVosContext - pointer to the global Vos context
1296
1297 \param moduleId - the module ID who's context area is being free
1298
1299 \param pModuleContext - pointer to module context area to be free'd.
1300
1301 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1302 free'd. The pointer to the context area is not longer
1303 available.
1304
1305 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1306 valid pointers.
1307
1308 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1309 not identify a module that can have a context free'd.
1310
1311 VOS_STATUS_E_EXISTS - vos could not free the requested
1312 context area because a context for this module ID does not
1313 exist in the global vos context.
1314
1315 \sa vos_get_context()
1316
1317 --------------------------------------------------------------------------*/
1318VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1319 v_VOID_t *pModuleContext )
1320{
1321 v_VOID_t ** pGpModContext = NULL;
1322
1323 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1324 ( pModuleContext == NULL))
1325 {
1326 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1327 "%s: Null params or context mismatch", __func__);
1328 return VOS_STATUS_E_FAILURE;
1329 }
1330
1331
1332 switch(moduleID)
1333 {
1334 case VOS_MODULE_ID_TL:
1335 {
1336 pGpModContext = &(gpVosContext->pTLContext);
1337 break;
1338 }
1339
Jeff Johnson295189b2012-06-20 16:38:30 -07001340#ifdef WLAN_BTAMP_FEATURE
1341 case VOS_MODULE_ID_BAP:
1342 {
1343 pGpModContext = &(gpVosContext->pBAPContext);
1344 break;
1345 }
1346#endif //WLAN_BTAMP_FEATURE
1347
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 case VOS_MODULE_ID_SAP:
1349 {
1350 pGpModContext = &(gpVosContext->pSAPContext);
1351 break;
1352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001353
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 case VOS_MODULE_ID_WDA:
1355 {
1356 pGpModContext = &(gpVosContext->pWDAContext);
1357 break;
1358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 case VOS_MODULE_ID_HDD:
1360 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301362 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 default:
1365 {
1366 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1367 "does not have its context allocated by VOSS", __func__, moduleID);
1368 VOS_ASSERT(0);
1369 return VOS_STATUS_E_INVAL;
1370 }
1371 }
1372
1373 if ( NULL == *pGpModContext)
1374 {
1375 /*
1376 ** Context has not been allocated or freed already!
1377 */
1378 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1379 "context has not been allocated or freed already", __func__,moduleID);
1380 return VOS_STATUS_E_FAILURE;
1381 }
1382
1383 if (*pGpModContext != pModuleContext)
1384 {
1385 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001386 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 return VOS_STATUS_E_FAILURE;
1388 }
1389
1390 if(pModuleContext != NULL)
1391 kfree(pModuleContext);
1392
1393 *pGpModContext = NULL;
1394
1395 return VOS_STATUS_SUCCESS;
1396
1397} /* vos_free_context() */
1398
1399
1400/**---------------------------------------------------------------------------
1401
1402 \brief vos_mq_post_message() - post a message to a message queue
1403
1404 This API allows messages to be posted to a specific message queue. Messages
1405 can be posted to the following message queues:
1406
1407 <ul>
1408 <li> SME
1409 <li> PE
1410 <li> HAL
1411 <li> TL
1412 </ul>
1413
1414 \param msgQueueId - identifies the message queue upon which the message
1415 will be posted.
1416
1417 \param message - a pointer to a message buffer. Memory for this message
1418 buffer is allocated by the caller and free'd by the vOSS after the
1419 message is posted to the message queue. If the consumer of the
1420 message needs anything in this message, it needs to copy the contents
1421 before returning from the message queue handler.
1422
1423 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1424 to the message queue.
1425
1426 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1427 refer to a valid Message Queue Id.
1428
1429 VOS_STATUS_E_FAULT - message is an invalid pointer.
1430
1431 VOS_STATUS_E_FAILURE - the message queue handler has reported
1432 an unknown failure.
1433
1434 \sa
1435
1436 --------------------------------------------------------------------------*/
1437VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1438{
1439 pVosMqType pTargetMq = NULL;
1440 pVosMsgWrapper pMsgWrapper = NULL;
1441
1442 if ((gpVosContext == NULL) || (pMsg == NULL))
1443 {
1444 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1445 "%s: Null params or global vos context is null", __func__);
1446 VOS_ASSERT(0);
1447 return VOS_STATUS_E_FAILURE;
1448 }
1449
1450 switch (msgQueueId)
1451 {
1452 /// Message Queue ID for messages bound for SME
1453 case VOS_MQ_ID_SME:
1454 {
1455 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1456 break;
1457 }
1458
1459 /// Message Queue ID for messages bound for PE
1460 case VOS_MQ_ID_PE:
1461 {
1462 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1463 break;
1464 }
1465
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 /// Message Queue ID for messages bound for WDA
1467 case VOS_MQ_ID_WDA:
1468 {
1469 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1470 break;
1471 }
1472
1473 /// Message Queue ID for messages bound for WDI
1474 case VOS_MQ_ID_WDI:
1475 {
1476 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1477 break;
1478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001479
1480 /// Message Queue ID for messages bound for TL
1481 case VOS_MQ_ID_TL:
1482 {
1483 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1484 break;
1485 }
1486
1487 /// Message Queue ID for messages bound for the SYS module
1488 case VOS_MQ_ID_SYS:
1489 {
1490 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1491 break;
1492 }
1493
1494 default:
1495
1496 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1497 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1498 __func__, msgQueueId);
1499
1500 return VOS_STATUS_E_FAILURE;
1501 }
1502
1503 VOS_ASSERT(NULL !=pTargetMq);
1504 if (pTargetMq == NULL)
1505 {
1506 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001507 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 return VOS_STATUS_E_FAILURE;
1509 }
1510
1511 /*
1512 ** Try and get a free Msg wrapper
1513 */
1514 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1515
1516 if (NULL == pMsgWrapper)
1517 {
1518 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1519 "%s: VOS Core run out of message wrapper", __func__);
1520
1521 return VOS_STATUS_E_RESOURCES;
1522 }
1523
1524 /*
1525 ** Copy the message now
1526 */
1527 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1528 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1529
1530 vos_mq_put(pTargetMq, pMsgWrapper);
1531
1532 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1533 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1534
1535 return VOS_STATUS_SUCCESS;
1536
1537} /* vos_mq_post_message()*/
1538
1539
1540/**---------------------------------------------------------------------------
1541
1542 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
1543
1544 This API allows messages to be posted to a specific message queue in the
1545 Tx excution flow. Messages for the Tx execution flow can be posted only
1546 to the following queue.
1547
1548 <ul>
1549 <li> TL
1550 <li> SSC/WDI
1551 </ul>
1552
1553 \param msgQueueId - identifies the message queue upon which the message
1554 will be posted.
1555
1556 \param message - a pointer to a message buffer. Body memory for this message
1557 buffer is allocated by the caller and free'd by the vOSS after the
1558 message is dispacthed to the appropriate component. If the consumer
1559 of the message needs to keep anything in the body, it needs to copy
1560 the contents before returning from the message handler.
1561
1562 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1563 to the message queue.
1564
1565 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1566 refer to a valid Message Queue Id.
1567
1568 VOS_STATUS_E_FAULT - message is an invalid pointer.
1569
1570 VOS_STATUS_E_FAILURE - the message queue handler has reported
1571 an unknown failure.
1572
1573 \sa
1574
1575 --------------------------------------------------------------------------*/
1576VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1577{
1578 pVosMqType pTargetMq = NULL;
1579 pVosMsgWrapper pMsgWrapper = NULL;
1580
1581 if ((gpVosContext == NULL) || (pMsg == NULL))
1582 {
1583 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1584 "%s: Null params or global vos context is null", __func__);
1585 VOS_ASSERT(0);
1586 return VOS_STATUS_E_FAILURE;
1587 }
1588
1589 switch (msgQueueId)
1590 {
1591 /// Message Queue ID for messages bound for SME
1592 case VOS_MQ_ID_TL:
1593 {
1594 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
1595 break;
1596 }
1597
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 /// Message Queue ID for messages bound for SSC
1599 case VOS_MQ_ID_WDI:
1600 {
1601 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
1602 break;
1603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001604
1605 /// Message Queue ID for messages bound for the SYS module
1606 case VOS_MQ_ID_SYS:
1607 {
1608 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
1609 break;
1610 }
1611
1612 default:
1613
1614 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301615 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 __func__, msgQueueId);
1617
1618 return VOS_STATUS_E_FAILURE;
1619 }
1620
1621 if (pTargetMq == NULL)
1622 {
1623 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001624 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 return VOS_STATUS_E_FAILURE;
1626 }
1627
1628
1629 /*
1630 ** Try and get a free Msg wrapper
1631 */
1632 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1633
1634 if (NULL == pMsgWrapper)
1635 {
1636 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1637 "%s: VOS Core run out of message wrapper", __func__);
1638
1639 return VOS_STATUS_E_RESOURCES;
1640 }
1641
1642 /*
1643 ** Copy the message now
1644 */
1645 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1646 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1647
1648 vos_mq_put(pTargetMq, pMsgWrapper);
1649
1650 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
1651 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
1652
1653 return VOS_STATUS_SUCCESS;
1654
1655} /* vos_tx_mq_serialize()*/
1656
Jeff Johnson295189b2012-06-20 16:38:30 -07001657/**---------------------------------------------------------------------------
1658
1659 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
1660
1661 This API allows messages to be posted to a specific message queue in the
1662 Tx excution flow. Messages for the Rx execution flow can be posted only
1663 to the following queue.
1664
1665 <ul>
1666 <li> TL
1667 <li> WDI
1668 </ul>
1669
1670 \param msgQueueId - identifies the message queue upon which the message
1671 will be posted.
1672
1673 \param message - a pointer to a message buffer. Body memory for this message
1674 buffer is allocated by the caller and free'd by the vOSS after the
1675 message is dispacthed to the appropriate component. If the consumer
1676 of the message needs to keep anything in the body, it needs to copy
1677 the contents before returning from the message handler.
1678
1679 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1680 to the message queue.
1681
1682 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1683 refer to a valid Message Queue Id.
1684
1685 VOS_STATUS_E_FAULT - message is an invalid pointer.
1686
1687 VOS_STATUS_E_FAILURE - the message queue handler has reported
1688 an unknown failure.
1689
1690 \sa
1691
1692 --------------------------------------------------------------------------*/
1693
1694VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1695{
1696 pVosMqType pTargetMq = NULL;
1697 pVosMsgWrapper pMsgWrapper = NULL;
1698 if ((gpVosContext == NULL) || (pMsg == NULL))
1699 {
1700 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1701 "%s: Null params or global vos context is null", __func__);
1702 VOS_ASSERT(0);
1703 return VOS_STATUS_E_FAILURE;
1704 }
1705
1706 switch (msgQueueId)
1707 {
1708
1709 case VOS_MQ_ID_SYS:
1710 {
1711 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
1712 break;
1713 }
1714
1715 /// Message Queue ID for messages bound for WDI
1716 case VOS_MQ_ID_WDI:
1717 {
1718 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
1719 break;
1720 }
1721
1722 default:
1723
1724 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301725 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 __func__, msgQueueId);
1727
1728 return VOS_STATUS_E_FAILURE;
1729 }
1730
1731 if (pTargetMq == NULL)
1732 {
1733 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001734 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 return VOS_STATUS_E_FAILURE;
1736 }
1737
1738
1739 /*
1740 ** Try and get a free Msg wrapper
1741 */
1742 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1743
1744 if (NULL == pMsgWrapper)
1745 {
1746 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1747 "%s: VOS Core run out of message wrapper", __func__);
1748
1749 return VOS_STATUS_E_RESOURCES;
1750 }
1751
1752 /*
1753 ** Copy the message now
1754 */
1755 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1756 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1757
1758 vos_mq_put(pTargetMq, pMsgWrapper);
1759
1760 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
1761 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
1762
1763 return VOS_STATUS_SUCCESS;
1764
1765} /* vos_rx_mq_serialize()*/
1766
Jeff Johnson295189b2012-06-20 16:38:30 -07001767v_VOID_t
1768vos_sys_probe_thread_cback
1769(
1770 v_VOID_t *pUserData
1771)
1772{
1773 if (gpVosContext != pUserData)
1774 {
1775 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001776 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 return;
1778 }
1779
1780 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
1781 {
1782 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001783 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 return;
1785 }
1786
1787} /* vos_sys_probe_thread_cback() */
1788
Jeff Johnson295189b2012-06-20 16:38:30 -07001789v_VOID_t vos_WDAComplete_cback
1790(
1791 v_VOID_t *pUserData
1792)
1793{
1794
1795 if (gpVosContext != pUserData)
1796 {
1797 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001798 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 return;
1800 }
1801
1802 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
1803 {
1804 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001805 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 return;
1807 }
1808
1809} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07001810
1811v_VOID_t vos_core_return_msg
1812(
1813 v_PVOID_t pVContext,
1814 pVosMsgWrapper pMsgWrapper
1815)
1816{
1817 pVosContextType pVosContext = (pVosContextType) pVContext;
1818
1819 VOS_ASSERT( gpVosContext == pVosContext);
1820
1821 if (gpVosContext != pVosContext)
1822 {
1823 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001824 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 return;
1826 }
1827
1828 VOS_ASSERT( NULL !=pMsgWrapper );
1829
1830 if (pMsgWrapper == NULL)
1831 {
1832 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001833 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 return;
1835 }
1836
1837 /*
1838 ** Return the message on the free message queue
1839 */
1840 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
1841 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
1842
1843} /* vos_core_return_msg() */
1844
1845
1846/**
1847 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
1848 TL config params from the registry
1849
1850 @param pAdapter : [inout] pointer to TL config block
1851
1852 @return
1853 None
1854
1855*/
1856v_VOID_t
1857vos_fetch_tl_cfg_parms
1858(
1859 WLANTL_ConfigInfoType *pTLConfig,
1860 hdd_config_t * pConfig
1861)
1862{
1863 if (pTLConfig == NULL)
1864 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001865 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 return;
1867 }
1868
1869 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
1870 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
1871 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
1872 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
1873 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07001875
1876}
1877
1878v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
1879{
1880 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
1881}
1882
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05301883void vos_abort_mac_scan(v_U8_t sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001884{
1885 hdd_context_t *pHddCtx = NULL;
1886 v_CONTEXT_t pVosContext = NULL;
1887
1888 /* Get the Global VOSS Context */
1889 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1890 if(!pVosContext) {
1891 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
1892 return;
1893 }
1894
1895 /* Get the HDD context */
1896 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1897 if(!pHddCtx) {
1898 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
1899 return;
1900 }
1901
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05301902 hdd_abort_mac_scan(pHddCtx, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 return;
1904}
Jeff Johnson295189b2012-06-20 16:38:30 -07001905/*---------------------------------------------------------------------------
1906
1907 \brief vos_shutdown() - shutdown VOS
1908
1909 - All VOS submodules are closed.
1910
1911 - All the WLAN SW components should have been opened. This includes
1912 SYS, MAC, SME and TL.
1913
1914
1915 \param vosContext: Global vos context
1916
1917
1918 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
1919
1920 VOS_STATUS_E_FAILURE - Failure to close
1921
1922---------------------------------------------------------------------------*/
1923VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
1924{
1925 VOS_STATUS vosStatus;
1926
1927#ifdef WLAN_BTAMP_FEATURE
1928 vosStatus = WLANBAP_Close(vosContext);
1929 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1930 {
1931 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1932 "%s: Failed to close BAP", __func__);
1933 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1934 }
1935#endif // WLAN_BTAMP_FEATURE
1936
1937 vosStatus = WLANTL_Close(vosContext);
1938 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1939 {
1940 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1941 "%s: Failed to close TL", __func__);
1942 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1943 }
1944
1945 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1946 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1947 {
1948 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1949 "%s: Failed to close SME", __func__);
1950 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1951 }
1952
1953 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1954 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1955 {
1956 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1957 "%s: Failed to close MAC", __func__);
1958 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1959 }
1960
1961 ((pVosContextType)vosContext)->pMACContext = NULL;
1962
1963 vosStatus = vos_nv_close();
1964 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1965 {
1966 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1967 "%s: Failed to close NV", __func__);
1968 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1969 }
1970
1971 vosStatus = sysClose( vosContext );
1972 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1973 {
1974 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1975 "%s: Failed to close SYS", __func__);
1976 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1977 }
1978
1979 /* Let DXE return packets in WDA_close and then free them here */
1980 vosStatus = vos_packet_close( vosContext );
1981 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1982 {
1983 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1984 "%s: Failed to close VOSS Packet", __func__);
1985 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1986 }
1987
1988 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1989
1990 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1991 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1992 {
1993 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1994 "%s: failed to destroy wdaCompleteEvent", __func__);
1995 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1996 }
1997
1998 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1999 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2000 {
2001 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2002 "%s: failed to destroy ProbeEvent", __func__);
2003 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2004 }
2005
2006 return VOS_STATUS_SUCCESS;
2007}
2008
2009/*---------------------------------------------------------------------------
2010
2011 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2012
2013 - WDA/WDI shutdown
2014
2015 \param vosContext: Global vos context
2016
2017
2018 \return VOS_STATUS_SUCCESS - Operation successfull
2019
2020 VOS_STATUS_E_FAILURE - Failure to close
2021
2022---------------------------------------------------------------------------*/
2023VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2024{
2025 VOS_STATUS vosStatus;
2026 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2027
2028 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2029 {
2030 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2031 "%s: failed to shutdown WDA", __func__);
2032 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2033 }
2034 return vosStatus;
2035}
2036/**
2037 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2038
2039 This function is called when Riva subsystem crashes. There are two
2040 methods (or operations) in WLAN driver to handle Riva crash,
2041 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2042 driver without handshaking with Riva.
2043 2. re-init: Next API
2044 @param
2045 NONE
2046 @return
2047 VOS_STATUS_SUCCESS - Operation completed successfully.
2048 VOS_STATUS_E_FAILURE - Operation failed.
2049
2050*/
2051VOS_STATUS vos_wlanShutdown(void)
2052{
2053 VOS_STATUS vstatus;
2054 vstatus = vos_watchdog_wlan_shutdown();
2055 return vstatus;
2056}
2057/**
2058 @brief vos_wlanReInit() - This API will re-init WLAN driver
2059
2060 This function is called when Riva subsystem reboots. There are two
2061 methods (or operations) in WLAN driver to handle Riva crash,
2062 1. shutdown: Previous API
2063 2. re-init: Called when Riva comes back after the crash. This will
2064 re-initialize WLAN driver. In some cases re-open may be
2065 referred instead of re-init.
2066 @param
2067 NONE
2068 @return
2069 VOS_STATUS_SUCCESS - Operation completed successfully.
2070 VOS_STATUS_E_FAILURE - Operation failed.
2071
2072*/
2073VOS_STATUS vos_wlanReInit(void)
2074{
2075 VOS_STATUS vstatus;
2076 vstatus = vos_watchdog_wlan_re_init();
2077 return vstatus;
2078}
Jeff Johnsone7245742012-09-05 17:12:55 -07002079/**
2080 @brief vos_wlanRestart() - This API will reload WLAN driver.
2081
2082 This function is called if driver detects any fatal state which
2083 can be recovered by a WLAN module reload ( Android framwork initiated ).
2084 Note that this API will not initiate any RIVA subsystem restart.
2085
2086 The function wlan_hdd_restart_driver protects against re-entrant calls.
2087
2088 @param
2089 NONE
2090 @return
2091 VOS_STATUS_SUCCESS - Operation completed successfully.
2092 VOS_STATUS_E_FAILURE - Operation failed.
2093 VOS_STATUS_E_EMPTY - No configured interface
2094 VOS_STATUS_E_ALREADY - Request already in progress
2095
2096
2097*/
2098VOS_STATUS vos_wlanRestart(void)
2099{
2100 VOS_STATUS vstatus;
2101 hdd_context_t *pHddCtx = NULL;
2102 v_CONTEXT_t pVosContext = NULL;
2103
2104 /* Check whether driver load unload is in progress */
2105 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2106 {
2107 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2108 "%s: Driver load/unload is in progress, retry later.", __func__);
2109 return VOS_STATUS_E_AGAIN;
2110 }
2111
2112 /* Get the Global VOSS Context */
2113 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2114 if(!pVosContext) {
2115 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2116 "%s: Global VOS context is Null", __func__);
2117 return VOS_STATUS_E_FAILURE;
2118 }
2119
2120 /* Get the HDD context */
2121 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2122 if(!pHddCtx) {
2123 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2124 "%s: HDD context is Null", __func__);
2125 return VOS_STATUS_E_FAILURE;
2126 }
2127
2128 /* Reload the driver */
2129 vstatus = wlan_hdd_restart_driver(pHddCtx);
2130 return vstatus;
2131}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302132
2133
2134/**
2135 @brief vos_fwDumpReq()
2136
2137 This function is called to issue dump commands to Firmware
2138
2139 @param
2140 cmd - Command No. to execute
2141 arg1 - argument 1 to cmd
2142 arg2 - argument 2 to cmd
2143 arg3 - argument 3 to cmd
2144 arg4 - argument 4 to cmd
2145 @return
2146 NONE
2147*/
2148v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
2149 tANI_U32 arg3, tANI_U32 arg4)
2150{
2151 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
2152
2153 /* Reset wda wait event */
2154 vos_event_reset(&gpVosContext->wdaCompleteEvent);
2155
2156 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL);
2157
2158 /* Need to update time out of complete */
2159 vStatus = vos_wait_single_event(&gpVosContext->wdaCompleteEvent,
2160 VOS_WDA_RESP_TIMEOUT );
2161
2162 if (vStatus != VOS_STATUS_SUCCESS)
2163 {
2164 if (vStatus == VOS_STATUS_E_TIMEOUT)
2165 {
2166 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2167 "%s: Timeout occurred before WDA HAL DUMP complete\n", __func__);
2168 }
2169 else
2170 {
2171 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2172 "%s: reporting other error", __func__);
2173 }
2174 }
2175
2176 return;
2177
2178}