blob: 354dded74573752aaf4808527ba7b03d582a459b [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
110/*---------------------------------------------------------------------------
111 * Data definitions
112 * ------------------------------------------------------------------------*/
113static VosContextType gVosContext;
114static pVosContextType gpVosContext;
115
116/*---------------------------------------------------------------------------
117 * Forward declaration
118 * ------------------------------------------------------------------------*/
119v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
122
123v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
124 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700125
126
127/*---------------------------------------------------------------------------
128
129 \brief vos_preOpen() - PreOpen the vOSS Module
130
131 The \a vos_preOpen() function allocates the Vos Context, but do not
132 initialize all the members. This overal initialization will happen
133 at vos_Open().
134 The reason why we need vos_preOpen() is to get a minimum context
135 where to store BAL and SAL relative data, which happens before
136 vos_Open() is called.
137
138 \param pVosContext: A pointer to where to store the VOS Context
139
140
141 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
142 is ready to be used.
143
144 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
145
146 \sa vos_Open()
147
148---------------------------------------------------------------------------*/
149VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
150{
151 if ( pVosContext == NULL)
152 return VOS_STATUS_E_FAILURE;
153
154 /* Allocate the VOS Context */
155 *pVosContext = NULL;
156 gpVosContext = &gVosContext;
157
158 if (NULL == gpVosContext)
159 {
160 /* Critical Error ...Cannot proceed further */
161 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
162 "%s: Failed to allocate VOS Context", __func__);
163 VOS_ASSERT(0);
164 return VOS_STATUS_E_RESOURCES;
165 }
166
167 vos_mem_zero(gpVosContext, sizeof(VosContextType));
168
169 *pVosContext = gpVosContext;
170
171 return VOS_STATUS_SUCCESS;
172
173} /* vos_preOpen()*/
174
175
176/*---------------------------------------------------------------------------
177
178 \brief vos_preClose() - PreClose the vOSS Module
179
180 The \a vos_preClose() function frees the Vos Context.
181
182 \param pVosContext: A pointer to where the VOS Context was stored
183
184
185 \return VOS_STATUS_SUCCESS - Always successful
186
187
188 \sa vos_preClose()
189 \sa vos_close()
190---------------------------------------------------------------------------*/
191VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
192{
193
194 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
195 "%s: De-allocating the VOS Context", __func__);
196
197 if (( pVosContext == NULL) || (*pVosContext == NULL))
198 {
199 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
200 "%s: vOS Context is Null", __func__);
201 return VOS_STATUS_E_FAILURE;
202 }
203
204 if (gpVosContext != *pVosContext)
205 {
206 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
207 "%s: Context mismatch", __func__);
208 return VOS_STATUS_E_FAILURE;
209 }
210
211 *pVosContext = gpVosContext = NULL;
212
213 return VOS_STATUS_SUCCESS;
214
215} /* vos_preClose()*/
216
217/*---------------------------------------------------------------------------
218
219 \brief vos_open() - Open the vOSS Module
220
221 The \a vos_open() function opens the vOSS Scheduler
222 Upon successful initialization:
223
224 - All VOS submodules should have been initialized
225
226 - The VOS scheduler should have opened
227
228 - All the WLAN SW components should have been opened. This includes
229 SYS, MAC, SME, WDA and TL.
230
231
232 \param hddContextSize: Size of the HDD context to allocate.
233
234
235 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
236 is ready to be used.
237
238 VOS_STATUS_E_RESOURCES - System resources (other than memory)
239 are unavailable to initilize the scheduler
240
241
242 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
243
244 \sa vos_preOpen()
245
246---------------------------------------------------------------------------*/
247VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, v_SIZE_t hddContextSize )
248
249{
250 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
251 int iter = 0;
252 tSirRetStatus sirStatus = eSIR_SUCCESS;
253 tMacOpenParameters macOpenParms;
254 WLANTL_ConfigInfoType TLConfig;
255
256 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
257 "%s: Opening VOSS", __func__);
258
259 if (NULL == gpVosContext)
260 {
261 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
262 "%s: Trying to open VOSS without a PreOpen", __func__);
263 VOS_ASSERT(0);
264 return VOS_STATUS_E_FAILURE;
265 }
266
267 /* Initialize the timer module */
268 vos_timer_module_init();
269
270 /* Initialize the probe event */
271 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
272 {
273 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
274 "%s: Unable to init probeEvent", __func__);
275 VOS_ASSERT(0);
276 return VOS_STATUS_E_FAILURE;
277 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
279 {
280 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
281 "%s: Unable to init wdaCompleteEvent", __func__);
282 VOS_ASSERT(0);
283
284 goto err_probe_event;
285 }
286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 /* Initialize the free message queue */
288 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
289 if (! VOS_IS_STATUS_SUCCESS(vStatus))
290 {
291
292 /* Critical Error ... Cannot proceed further */
293 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
294 "%s: Failed to initialize VOS free message queue", __func__);
295 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 goto err_wda_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 }
298
299 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
300 {
301 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
302 &(gpVosContext->aMsgBuffers[iter]);
303 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
304 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
305 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700306
307 /* Now Open the VOS Scheduler */
308 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
309 sizeof(VosSchedContext));
310
311 if (!VOS_IS_STATUS_SUCCESS(vStatus))
312 {
313 /* Critical Error ... Cannot proceed further */
314 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
315 "%s: Failed to open VOS Scheduler", __func__);
316 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 }
319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 /*
321 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
322 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
323 */
324
325 /*Open the WDA module */
326 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
327 /* UMA is supported in hardware for performing the
328 ** frame translation 802.11 <-> 802.3
329 */
330 macOpenParms.frameTransRequired = 1;
331 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
332 vStatus = WDA_open( gpVosContext, gpVosContext->pHDDContext, &macOpenParms );
333
334 if (!VOS_IS_STATUS_SUCCESS(vStatus))
335 {
336 /* Critical Error ... Cannot proceed further */
337 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
338 "%s: Failed to open WDA module", __func__);
339 VOS_ASSERT(0);
340 goto err_sched_close;
341 }
342
343 /* Initialize here the VOS Packet sub module */
344 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
345 sizeof( vos_pkt_context_t ) );
346
347 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
348 {
349 /* Critical Error ... Cannot proceed further */
350 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
351 "%s: Failed to open VOS Packet Module", __func__);
352 VOS_ASSERT(0);
353 goto err_wda_close;
354 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 /* Open the SYS module */
357 vStatus = sysOpen(gpVosContext);
358
359 if (!VOS_IS_STATUS_SUCCESS(vStatus))
360 {
361 /* Critical Error ... Cannot proceed further */
362 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
363 "%s: Failed to open SYS module", __func__);
364 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 }
367
368
369 /* initialize the NV module */
370 vStatus = vos_nv_open();
371 if (!VOS_IS_STATUS_SUCCESS(vStatus))
372 {
373 // NV module cannot be initialized
374 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
375 "%s: Failed to initialize the NV module", __func__);
376 goto err_sys_close;
377 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
379 /* If we arrive here, both threads dispacthing messages correctly */
380
381 /* Now proceed to open the MAC */
382
383 /* UMA is supported in hardware for performing the
384 frame translation 802.11 <-> 802.3 */
385 macOpenParms.frameTransRequired = 1;
386 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
387 &macOpenParms);
388
389 if (eSIR_SUCCESS != sirStatus)
390 {
391 /* Critical Error ... Cannot proceed further */
392 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
393 "%s: Failed to open MAC", __func__);
394 VOS_ASSERT(0);
395 goto err_nv_close;
396 }
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700397/* call crda before sme_Open which will read NV and store the default country code */
398 wlan_hdd_get_crda_regd_entry(
399 ((hdd_context_t*)(gpVosContext->pHDDContext))->wiphy,
400 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
Jeff Johnson295189b2012-06-20 16:38:30 -0700401
402 /* Now proceed to open the SME */
403 vStatus = sme_Open(gpVosContext->pMACContext);
404 if (!VOS_IS_STATUS_SUCCESS(vStatus))
405 {
406 /* Critical Error ... Cannot proceed further */
407 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
408 "%s: Failed to open SME", __func__);
409 VOS_ASSERT(0);
410 goto err_mac_close;
411 }
412
413 /* Now proceed to open TL. Read TL config first */
414 vos_fetch_tl_cfg_parms ( &TLConfig,
415 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
416
417 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
418 if (!VOS_IS_STATUS_SUCCESS(vStatus))
419 {
420 /* Critical Error ... Cannot proceed further */
421 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
422 "%s: Failed to open TL", __func__);
423 VOS_ASSERT(0);
424 goto err_sme_close;
425 }
426
427 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
428 "%s: VOSS successfully Opened", __func__);
429
430 *pVosContext = gpVosContext;
431
432 return VOS_STATUS_SUCCESS;
433
434
435err_sme_close:
436 sme_Close(gpVosContext->pMACContext);
437
438err_mac_close:
439 macClose(gpVosContext->pMACContext);
440
441err_nv_close:
442 vos_nv_close();
443
444err_sys_close:
445 sysClose(gpVosContext);
446
Jeff Johnson295189b2012-06-20 16:38:30 -0700447err_packet_close:
448 vos_packet_close( gpVosContext );
449
450err_wda_close:
451 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700452
453err_sched_close:
454 vos_sched_close(gpVosContext);
455
Jeff Johnson295189b2012-06-20 16:38:30 -0700456
457err_msg_queue:
458 vos_mq_deinit(&gpVosContext->freeVosMq);
459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460err_wda_complete_event:
461 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700462
463err_probe_event:
464 vos_event_destroy(&gpVosContext->ProbeEvent);
465
466 return VOS_STATUS_E_FAILURE;
467
468} /* vos_open() */
469
Jeff Johnson295189b2012-06-20 16:38:30 -0700470/*---------------------------------------------------------------------------
471
472 \brief vos_preStart() -
473
474 The \a vos_preStart() function to download CFG.
475 including:
476 - ccmStart
477
478 - WDA: triggers the CFG download
479
480
481 \param pVosContext: The VOS context
482
483
484 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
485 is ready to be used.
486
487 VOS_STATUS_E_RESOURCES - System resources (other than memory)
488 are unavailable to initilize the scheduler
489
490
491 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
492
493 \sa vos_start
494
495---------------------------------------------------------------------------*/
496VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
497{
498 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
499 pVosContextType pVosContext = (pVosContextType)vosContext;
500
501 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
502 "vos prestart");
503
504 VOS_ASSERT(gpVosContext == pVosContext);
505
506 VOS_ASSERT( NULL != pVosContext->pMACContext);
507
508 VOS_ASSERT( NULL != pVosContext->pWDAContext);
509
510 /* call macPreStart */
511 vStatus = macPreStart(gpVosContext->pMACContext);
512 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
513 {
514 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
515 "Failed at macPreStart ");
516 return VOS_STATUS_E_FAILURE;
517 }
518
519 /* call ccmStart */
520 ccmStart(gpVosContext->pMACContext);
521
522 /* Reset wda wait event */
523 vos_event_reset(&gpVosContext->wdaCompleteEvent);
524
525
526 /*call WDA pre start*/
527 vStatus = WDA_preStart(gpVosContext);
528 if (!VOS_IS_STATUS_SUCCESS(vStatus))
529 {
530 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
531 "Failed to WDA prestart");
532 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
533 ccmStop(gpVosContext->pMACContext);
534 VOS_ASSERT(0);
535 return VOS_STATUS_E_FAILURE;
536 }
537
538 /* Need to update time out of complete */
539 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
540 VOS_WDA_TIMEOUT );
541 if ( vStatus != VOS_STATUS_SUCCESS )
542 {
543 if ( vStatus == VOS_STATUS_E_TIMEOUT )
544 {
545 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
546 "%s: Timeout occurred before WDA complete\n", __func__);
547 }
548 else
549 {
550 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
551 "%s: WDA_preStart reporting other error", __func__);
552 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700553 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
554 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 VOS_ASSERT( 0 );
556 return VOS_STATUS_E_FAILURE;
557 }
558
559 return VOS_STATUS_SUCCESS;
560}
Jeff Johnson295189b2012-06-20 16:38:30 -0700561
562/*---------------------------------------------------------------------------
563
564 \brief vos_start() - Start the Libra SW Modules
565
566 The \a vos_start() function starts all the components of the Libra SW
567 including:
568 - SAL/BAL, which in turn starts SSC
569
570 - the MAC (HAL and PE)
571
572 - SME
573
574 - TL
575
576 - SYS: triggers the CFG download
577
578
579 \param pVosContext: The VOS context
580
581
582 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
583 is ready to be used.
584
585 VOS_STATUS_E_RESOURCES - System resources (other than memory)
586 are unavailable to initilize the scheduler
587
588
589 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
590
591 \sa vos_preStart()
592 \sa vos_open()
593
594---------------------------------------------------------------------------*/
595VOS_STATUS vos_start( v_CONTEXT_t vosContext )
596{
597 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
598 tSirRetStatus sirStatus = eSIR_SUCCESS;
599 pVosContextType pVosContext = (pVosContextType)vosContext;
600 tHalMacStartParameters halStartParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700601
602 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
603 "%s: Starting Libra SW", __func__);
604
605 /* We support only one instance for now ...*/
606 if (gpVosContext != pVosContext)
607 {
608 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700609 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 return VOS_STATUS_E_FAILURE;
611 }
612
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
614 || ( pVosContext->pTLContext == NULL))
615 {
616 if (pVosContext->pWDAContext == NULL)
617 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700618 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 else if (pVosContext->pMACContext == NULL)
620 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700621 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 else
623 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700624 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625
626 return VOS_STATUS_E_FAILURE;
627 }
628
629 /* WDA_Start will be called after NV image download because the
630 NV image data has to be updated at HAL before HAL_Start gets executed*/
631
632 /* Start the NV Image Download */
633
634 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
635
636 vStatus = WDA_NVDownload_Start(pVosContext);
637
638 if ( vStatus != VOS_STATUS_SUCCESS )
639 {
640 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
641 "%s: Failed to start NV Download", __func__);
642 return VOS_STATUS_E_FAILURE;
643 }
644
645 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
646 VOS_WDA_TIMEOUT );
647
648 if ( vStatus != VOS_STATUS_SUCCESS )
649 {
650 if ( vStatus == VOS_STATUS_E_TIMEOUT )
651 {
652 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
653 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
654 }
655 else
656 {
657 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
658 "%s: WDA_NVDownload_start reporting other error", __func__);
659 }
660 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800661 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
662 WDA_setNeedShutdown(vosContext);
663 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 }
665
666 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
667 "%s: WDA_NVDownload_start correctly started", __func__);
668
669 /* Start the WDA */
670 vStatus = WDA_start(pVosContext);
671 if ( vStatus != VOS_STATUS_SUCCESS )
672 {
673 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
674 "%s: Failed to start WDA", __func__);
675 return VOS_STATUS_E_FAILURE;
676 }
677 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
678 "%s: WDA correctly started", __func__);
679
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 /* Start the MAC */
681 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
682
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 /* Start the MAC */
684 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 if (eSIR_SUCCESS != sirStatus)
687 {
688 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
689 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 }
692
693 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
694 "%s: MAC correctly started", __func__);
695
696 /* START SME */
697 vStatus = sme_Start(pVosContext->pMACContext);
698
699 if (!VOS_IS_STATUS_SUCCESS(vStatus))
700 {
701 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
702 "%s: Failed to start SME", __func__);
703 goto err_mac_stop;
704 }
705
706 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
707 "%s: SME correctly started", __func__);
708
709 /** START TL */
710 vStatus = WLANTL_Start(pVosContext);
711 if (!VOS_IS_STATUS_SUCCESS(vStatus))
712 {
713 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
714 "%s: Failed to start TL", __func__);
715 goto err_sme_stop;
716 }
717
718 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
719 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
721 "%s: VOSS Start is successful!!", __func__);
722
723 return VOS_STATUS_SUCCESS;
724
Jeff Johnson295189b2012-06-20 16:38:30 -0700725
726err_sme_stop:
727 sme_Stop(pVosContext->pMACContext, TRUE);
728
729err_mac_stop:
730 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
731
Jeff Johnson295189b2012-06-20 16:38:30 -0700732err_wda_stop:
733 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800734 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
735 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800737 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
738 "%s: Failed to stop WDA", __func__);
739 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800740 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800741 }
742 else
743 {
744 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
745 VOS_WDA_TIMEOUT );
746 if( vStatus != VOS_STATUS_SUCCESS )
747 {
748 if( vStatus == VOS_STATUS_E_TIMEOUT )
749 {
750 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
751 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700752
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800753 }
754 else
755 {
756 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
757 "%s: WDA_stop reporting other error", __func__);
758 }
759 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800760 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800761 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700763
764 return VOS_STATUS_E_FAILURE;
765
766} /* vos_start() */
767
768
769/* vos_stop function */
770VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
771{
772 VOS_STATUS vosStatus;
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 /* WDA_Stop is called before the SYS so that the processing of Riva
775 pending responces will not be handled during uninitialization of WLAN driver */
776 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
777
778 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
779
780 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
781 {
782 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
783 "%s: Failed to stop WDA", __func__);
784 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800785 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -0700787 else
788 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800789 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
790 VOS_WDA_STOP_TIMEOUT );
Jeff Johnson295189b2012-06-20 16:38:30 -0700791
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800792 if ( vosStatus != VOS_STATUS_SUCCESS )
793 {
794 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
795 {
796 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
797 "%s: Timeout occurred before WDA complete", __func__);
798 }
799 else
800 {
801 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
802 "%s: WDA_stop reporting other error", __func__ );
803 }
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800804 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800805 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700807
808 /* SYS STOP will stop SME and MAC */
809 vosStatus = sysStop( vosContext);
810 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
811 {
812 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
813 "%s: Failed to stop SYS", __func__);
814 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
815 }
816
817 vosStatus = WLANTL_Stop( vosContext );
818 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
819 {
820 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
821 "%s: Failed to stop TL", __func__);
822 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
823 }
824
Jeff Johnson295189b2012-06-20 16:38:30 -0700825
826 return VOS_STATUS_SUCCESS;
827}
828
829
830/* vos_close function */
831VOS_STATUS vos_close( v_CONTEXT_t vosContext )
832{
833 VOS_STATUS vosStatus;
834
835#ifdef WLAN_BTAMP_FEATURE
836 vosStatus = WLANBAP_Close(vosContext);
837 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
838 {
839 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
840 "%s: Failed to close BAP", __func__);
841 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
842 }
843#endif // WLAN_BTAMP_FEATURE
844
845
846 vosStatus = WLANTL_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 TL", __func__);
851 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
852 }
853
854 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
855 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
856 {
857 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
858 "%s: Failed to close SME", __func__);
859 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
860 }
861
862 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
863 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
864 {
865 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
866 "%s: Failed to close MAC", __func__);
867 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
868 }
869
870 ((pVosContextType)vosContext)->pMACContext = NULL;
871
872 vosStatus = vos_nv_close();
873 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
874 {
875 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
876 "%s: Failed to close NV", __func__);
877 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
878 }
879
880
881 vosStatus = sysClose( vosContext );
882 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
883 {
884 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
885 "%s: Failed to close SYS", __func__);
886 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
887 }
888
Jeff Johnsone7245742012-09-05 17:12:55 -0700889 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700891 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
892 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
893 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
894 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -0700895 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -0700896 }
897 else
898 {
899 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
900 "%s: Failed to shutdown WDA", __func__ );
901 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
902 }
903 }
904 else
905 {
906 vosStatus = WDA_close( vosContext );
907 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
908 {
909 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
910 "%s: Failed to close WDA", __func__);
911 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
912 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 }
914
915 /* Let DXE return packets in WDA_close and then free them here */
916 vosStatus = vos_packet_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 VOSS Packet", __func__);
921 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
922 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700923
Jeff Johnson295189b2012-06-20 16:38:30 -0700924
925 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
926
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
928 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
929 {
930 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
931 "%s: failed to destroy wdaCompleteEvent", __func__);
932 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
933 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700934
935 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
936 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
937 {
938 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
939 "%s: failed to destroy ProbeEvent", __func__);
940 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
941 }
942
943 return VOS_STATUS_SUCCESS;
944}
945
946
947/**---------------------------------------------------------------------------
948
949 \brief vos_get_context() - get context data area
950
951 Each module in the system has a context / data area that is allocated
952 and maanged by voss. This API allows any user to get a pointer to its
953 allocated context data area from the VOSS global context.
954
955 \param vosContext - the VOSS Global Context.
956
957 \param moduleId - the module ID, who's context data are is being retrived.
958
959 \return - pointer to the context data area.
960
961 - NULL if the context data is not allocated for the module ID
962 specified
963
964 --------------------------------------------------------------------------*/
965v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
966 v_CONTEXT_t pVosContext )
967{
968 v_PVOID_t pModContext = NULL;
969
970 if (pVosContext == NULL)
971 {
972 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700973 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 return NULL;
975 }
976
977 if (gpVosContext != pVosContext)
978 {
979 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700980 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 return NULL;
982 }
983
984 switch(moduleId)
985 {
986 case VOS_MODULE_ID_TL:
987 {
988 pModContext = gpVosContext->pTLContext;
989 break;
990 }
991
Jeff Johnson295189b2012-06-20 16:38:30 -0700992#ifdef WLAN_BTAMP_FEATURE
993 case VOS_MODULE_ID_BAP:
994 {
995 pModContext = gpVosContext->pBAPContext;
996 break;
997 }
998#endif //WLAN_BTAMP_FEATURE
999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 case VOS_MODULE_ID_SAP:
1001 {
1002 pModContext = gpVosContext->pSAPContext;
1003 break;
1004 }
1005
1006 case VOS_MODULE_ID_HDD_SOFTAP:
1007 {
1008 pModContext = gpVosContext->pHDDSoftAPContext;
1009 break;
1010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001011
1012 case VOS_MODULE_ID_HDD:
1013 {
1014 pModContext = gpVosContext->pHDDContext;
1015 break;
1016 }
1017
1018 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 case VOS_MODULE_ID_PE:
1020 {
1021 /*
1022 ** In all these cases, we just return the MAC Context
1023 */
1024 pModContext = gpVosContext->pMACContext;
1025 break;
1026 }
1027
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 case VOS_MODULE_ID_WDA:
1029 {
1030 /* For WDA module */
1031 pModContext = gpVosContext->pWDAContext;
1032 break;
1033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001034
1035 case VOS_MODULE_ID_VOSS:
1036 {
1037 /* For SYS this is VOS itself*/
1038 pModContext = gpVosContext;
1039 break;
1040 }
1041
1042 default:
1043 {
1044 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1045 "does not have its context maintained by VOSS", __func__, moduleId);
1046 VOS_ASSERT(0);
1047 return NULL;
1048 }
1049 }
1050
1051 if (pModContext == NULL )
1052 {
1053 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1054 "context is Null", __func__, moduleId);
1055 }
1056
1057 return pModContext;
1058
1059} /* vos_get_context()*/
1060
1061
1062/**---------------------------------------------------------------------------
1063
1064 \brief vos_get_global_context() - get VOSS global Context
1065
1066 This API allows any user to get the VOS Global Context pointer from a
1067 module context data area.
1068
1069 \param moduleContext - the input module context pointer
1070
1071 \param moduleId - the module ID who's context pointer is input in
1072 moduleContext.
1073
1074 \return - pointer to the VOSS global context
1075
1076 - NULL if the function is unable to retreive the VOSS context.
1077
1078 --------------------------------------------------------------------------*/
1079v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1080 v_VOID_t *moduleContext )
1081{
1082 if (gpVosContext == NULL)
1083 {
1084 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001085 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 }
1087
1088 return gpVosContext;
1089
1090} /* vos_get_global_context() */
1091
1092
1093v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1094{
1095 if (gpVosContext == NULL)
1096 {
1097 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001098 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 return 1;
1100 }
1101
1102 return gpVosContext->isLogpInProgress;
1103}
1104
1105void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1106{
1107 if (gpVosContext == NULL)
1108 {
1109 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001110 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 return;
1112 }
1113
1114 gpVosContext->isLogpInProgress = value;
1115}
1116
1117v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1118{
1119 if (gpVosContext == NULL)
1120 {
1121 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001122 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 return 0;
1124 }
1125
1126 return gpVosContext->isLoadUnloadInProgress;
1127}
1128
1129void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1130{
1131 if (gpVosContext == NULL)
1132 {
1133 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001134 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 return;
1136 }
1137
1138 gpVosContext->isLoadUnloadInProgress = value;
1139}
1140
1141/**---------------------------------------------------------------------------
1142
1143 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1144
1145 This API allows any user to allocate a user context area within the
1146 VOS Global Context.
1147
1148 \param pVosContext - pointer to the global Vos context
1149
1150 \param moduleId - the module ID who's context area is being allocated.
1151
1152 \param ppModuleContext - pointer to location where the pointer to the
1153 allocated context is returned. Note this
1154 output pointer is valid only if the API
1155 returns VOS_STATUS_SUCCESS
1156
1157 \param size - the size of the context area to be allocated.
1158
1159 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1160 allocated successfully. The pointer to the context area
1161 can be found in *ppModuleContext.
1162 \note This function returns VOS_STATUS_SUCCESS if the
1163 module context was already allocated and the size
1164 allocated matches the size on this call.
1165
1166 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1167 not identify a module that can have a context allocated.
1168
1169 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1170 because a context for this module ID already exists and it is
1171 a *different* size that specified on this call.
1172
1173 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1174 requested context area.
1175
1176 \sa vos_get_context(), vos_free_context()
1177
1178 --------------------------------------------------------------------------*/
1179VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1180 v_VOID_t **ppModuleContext, v_SIZE_t size )
1181{
1182 v_VOID_t ** pGpModContext = NULL;
1183
1184 if ( pVosContext == NULL) {
1185 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001186 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 return VOS_STATUS_E_FAILURE;
1188 }
1189
1190 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1191 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001192 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 return VOS_STATUS_E_FAILURE;
1194 }
1195
1196 switch(moduleID)
1197 {
1198 case VOS_MODULE_ID_TL:
1199 {
1200 pGpModContext = &(gpVosContext->pTLContext);
1201 break;
1202 }
1203
Jeff Johnson295189b2012-06-20 16:38:30 -07001204#ifdef WLAN_BTAMP_FEATURE
1205 case VOS_MODULE_ID_BAP:
1206 {
1207 pGpModContext = &(gpVosContext->pBAPContext);
1208 break;
1209 }
1210#endif //WLAN_BTAMP_FEATURE
1211
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 case VOS_MODULE_ID_SAP:
1213 {
1214 pGpModContext = &(gpVosContext->pSAPContext);
1215 break;
1216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001217
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 case VOS_MODULE_ID_WDA:
1219 {
1220 pGpModContext = &(gpVosContext->pWDAContext);
1221 break;
1222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 case VOS_MODULE_ID_PE:
1225 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 default:
1228 {
1229 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1230 "does not have its context allocated by VOSS", __func__, moduleID);
1231 VOS_ASSERT(0);
1232 return VOS_STATUS_E_INVAL;
1233 }
1234 }
1235
1236 if ( NULL != *pGpModContext)
1237 {
1238 /*
1239 ** Context has already been allocated!
1240 ** Prevent double allocation
1241 */
1242 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1243 "%s: Module ID %i context has already been allocated",
1244 __func__, moduleID);
1245 return VOS_STATUS_E_EXISTS;
1246 }
1247
1248 /*
1249 ** Dynamically allocate the context for module
1250 */
1251
1252 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1253
1254
1255 if ( *ppModuleContext == NULL)
1256 {
1257 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1258 "allocate Context for module ID %i", __func__, moduleID);
1259 VOS_ASSERT(0);
1260 return VOS_STATUS_E_NOMEM;
1261 }
1262
1263 if (moduleID==VOS_MODULE_ID_TL)
1264 {
1265 vos_mem_zero(*ppModuleContext, size);
1266 }
1267
1268 *pGpModContext = *ppModuleContext;
1269
1270 return VOS_STATUS_SUCCESS;
1271
1272} /* vos_alloc_context() */
1273
1274
1275/**---------------------------------------------------------------------------
1276
1277 \brief vos_free_context() - free an allocated a context within the
1278 VOSS global Context
1279
1280 This API allows a user to free the user context area within the
1281 VOS Global Context.
1282
1283 \param pVosContext - pointer to the global Vos context
1284
1285 \param moduleId - the module ID who's context area is being free
1286
1287 \param pModuleContext - pointer to module context area to be free'd.
1288
1289 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1290 free'd. The pointer to the context area is not longer
1291 available.
1292
1293 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1294 valid pointers.
1295
1296 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1297 not identify a module that can have a context free'd.
1298
1299 VOS_STATUS_E_EXISTS - vos could not free the requested
1300 context area because a context for this module ID does not
1301 exist in the global vos context.
1302
1303 \sa vos_get_context()
1304
1305 --------------------------------------------------------------------------*/
1306VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1307 v_VOID_t *pModuleContext )
1308{
1309 v_VOID_t ** pGpModContext = NULL;
1310
1311 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1312 ( pModuleContext == NULL))
1313 {
1314 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1315 "%s: Null params or context mismatch", __func__);
1316 return VOS_STATUS_E_FAILURE;
1317 }
1318
1319
1320 switch(moduleID)
1321 {
1322 case VOS_MODULE_ID_TL:
1323 {
1324 pGpModContext = &(gpVosContext->pTLContext);
1325 break;
1326 }
1327
Jeff Johnson295189b2012-06-20 16:38:30 -07001328#ifdef WLAN_BTAMP_FEATURE
1329 case VOS_MODULE_ID_BAP:
1330 {
1331 pGpModContext = &(gpVosContext->pBAPContext);
1332 break;
1333 }
1334#endif //WLAN_BTAMP_FEATURE
1335
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 case VOS_MODULE_ID_SAP:
1337 {
1338 pGpModContext = &(gpVosContext->pSAPContext);
1339 break;
1340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001341
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 case VOS_MODULE_ID_WDA:
1343 {
1344 pGpModContext = &(gpVosContext->pWDAContext);
1345 break;
1346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 case VOS_MODULE_ID_HDD:
1348 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 case VOS_MODULE_ID_PE:
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 default:
1352 {
1353 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1354 "does not have its context allocated by VOSS", __func__, moduleID);
1355 VOS_ASSERT(0);
1356 return VOS_STATUS_E_INVAL;
1357 }
1358 }
1359
1360 if ( NULL == *pGpModContext)
1361 {
1362 /*
1363 ** Context has not been allocated or freed already!
1364 */
1365 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1366 "context has not been allocated or freed already", __func__,moduleID);
1367 return VOS_STATUS_E_FAILURE;
1368 }
1369
1370 if (*pGpModContext != pModuleContext)
1371 {
1372 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001373 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 return VOS_STATUS_E_FAILURE;
1375 }
1376
1377 if(pModuleContext != NULL)
1378 kfree(pModuleContext);
1379
1380 *pGpModContext = NULL;
1381
1382 return VOS_STATUS_SUCCESS;
1383
1384} /* vos_free_context() */
1385
1386
1387/**---------------------------------------------------------------------------
1388
1389 \brief vos_mq_post_message() - post a message to a message queue
1390
1391 This API allows messages to be posted to a specific message queue. Messages
1392 can be posted to the following message queues:
1393
1394 <ul>
1395 <li> SME
1396 <li> PE
1397 <li> HAL
1398 <li> TL
1399 </ul>
1400
1401 \param msgQueueId - identifies the message queue upon which the message
1402 will be posted.
1403
1404 \param message - a pointer to a message buffer. Memory for this message
1405 buffer is allocated by the caller and free'd by the vOSS after the
1406 message is posted to the message queue. If the consumer of the
1407 message needs anything in this message, it needs to copy the contents
1408 before returning from the message queue handler.
1409
1410 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1411 to the message queue.
1412
1413 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1414 refer to a valid Message Queue Id.
1415
1416 VOS_STATUS_E_FAULT - message is an invalid pointer.
1417
1418 VOS_STATUS_E_FAILURE - the message queue handler has reported
1419 an unknown failure.
1420
1421 \sa
1422
1423 --------------------------------------------------------------------------*/
1424VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1425{
1426 pVosMqType pTargetMq = NULL;
1427 pVosMsgWrapper pMsgWrapper = NULL;
1428
1429 if ((gpVosContext == NULL) || (pMsg == NULL))
1430 {
1431 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1432 "%s: Null params or global vos context is null", __func__);
1433 VOS_ASSERT(0);
1434 return VOS_STATUS_E_FAILURE;
1435 }
1436
1437 switch (msgQueueId)
1438 {
1439 /// Message Queue ID for messages bound for SME
1440 case VOS_MQ_ID_SME:
1441 {
1442 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1443 break;
1444 }
1445
1446 /// Message Queue ID for messages bound for PE
1447 case VOS_MQ_ID_PE:
1448 {
1449 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1450 break;
1451 }
1452
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 /// Message Queue ID for messages bound for WDA
1454 case VOS_MQ_ID_WDA:
1455 {
1456 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1457 break;
1458 }
1459
1460 /// Message Queue ID for messages bound for WDI
1461 case VOS_MQ_ID_WDI:
1462 {
1463 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1464 break;
1465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001466
1467 /// Message Queue ID for messages bound for TL
1468 case VOS_MQ_ID_TL:
1469 {
1470 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1471 break;
1472 }
1473
1474 /// Message Queue ID for messages bound for the SYS module
1475 case VOS_MQ_ID_SYS:
1476 {
1477 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1478 break;
1479 }
1480
1481 default:
1482
1483 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1484 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1485 __func__, msgQueueId);
1486
1487 return VOS_STATUS_E_FAILURE;
1488 }
1489
1490 VOS_ASSERT(NULL !=pTargetMq);
1491 if (pTargetMq == NULL)
1492 {
1493 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001494 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 return VOS_STATUS_E_FAILURE;
1496 }
1497
1498 /*
1499 ** Try and get a free Msg wrapper
1500 */
1501 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1502
1503 if (NULL == pMsgWrapper)
1504 {
1505 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1506 "%s: VOS Core run out of message wrapper", __func__);
1507
1508 return VOS_STATUS_E_RESOURCES;
1509 }
1510
1511 /*
1512 ** Copy the message now
1513 */
1514 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1515 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1516
1517 vos_mq_put(pTargetMq, pMsgWrapper);
1518
1519 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1520 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1521
1522 return VOS_STATUS_SUCCESS;
1523
1524} /* vos_mq_post_message()*/
1525
1526
1527/**---------------------------------------------------------------------------
1528
1529 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
1530
1531 This API allows messages to be posted to a specific message queue in the
1532 Tx excution flow. Messages for the Tx execution flow can be posted only
1533 to the following queue.
1534
1535 <ul>
1536 <li> TL
1537 <li> SSC/WDI
1538 </ul>
1539
1540 \param msgQueueId - identifies the message queue upon which the message
1541 will be posted.
1542
1543 \param message - a pointer to a message buffer. Body memory for this message
1544 buffer is allocated by the caller and free'd by the vOSS after the
1545 message is dispacthed to the appropriate component. If the consumer
1546 of the message needs to keep anything in the body, it needs to copy
1547 the contents before returning from the message handler.
1548
1549 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1550 to the message queue.
1551
1552 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1553 refer to a valid Message Queue Id.
1554
1555 VOS_STATUS_E_FAULT - message is an invalid pointer.
1556
1557 VOS_STATUS_E_FAILURE - the message queue handler has reported
1558 an unknown failure.
1559
1560 \sa
1561
1562 --------------------------------------------------------------------------*/
1563VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1564{
1565 pVosMqType pTargetMq = NULL;
1566 pVosMsgWrapper pMsgWrapper = NULL;
1567
1568 if ((gpVosContext == NULL) || (pMsg == NULL))
1569 {
1570 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1571 "%s: Null params or global vos context is null", __func__);
1572 VOS_ASSERT(0);
1573 return VOS_STATUS_E_FAILURE;
1574 }
1575
1576 switch (msgQueueId)
1577 {
1578 /// Message Queue ID for messages bound for SME
1579 case VOS_MQ_ID_TL:
1580 {
1581 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
1582 break;
1583 }
1584
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 /// Message Queue ID for messages bound for SSC
1586 case VOS_MQ_ID_WDI:
1587 {
1588 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
1589 break;
1590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001591
1592 /// Message Queue ID for messages bound for the SYS module
1593 case VOS_MQ_ID_SYS:
1594 {
1595 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
1596 break;
1597 }
1598
1599 default:
1600
1601 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301602 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 __func__, msgQueueId);
1604
1605 return VOS_STATUS_E_FAILURE;
1606 }
1607
1608 if (pTargetMq == NULL)
1609 {
1610 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001611 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 return VOS_STATUS_E_FAILURE;
1613 }
1614
1615
1616 /*
1617 ** Try and get a free Msg wrapper
1618 */
1619 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1620
1621 if (NULL == pMsgWrapper)
1622 {
1623 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1624 "%s: VOS Core run out of message wrapper", __func__);
1625
1626 return VOS_STATUS_E_RESOURCES;
1627 }
1628
1629 /*
1630 ** Copy the message now
1631 */
1632 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1633 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1634
1635 vos_mq_put(pTargetMq, pMsgWrapper);
1636
1637 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
1638 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
1639
1640 return VOS_STATUS_SUCCESS;
1641
1642} /* vos_tx_mq_serialize()*/
1643
Jeff Johnson295189b2012-06-20 16:38:30 -07001644/**---------------------------------------------------------------------------
1645
1646 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
1647
1648 This API allows messages to be posted to a specific message queue in the
1649 Tx excution flow. Messages for the Rx execution flow can be posted only
1650 to the following queue.
1651
1652 <ul>
1653 <li> TL
1654 <li> WDI
1655 </ul>
1656
1657 \param msgQueueId - identifies the message queue upon which the message
1658 will be posted.
1659
1660 \param message - a pointer to a message buffer. Body memory for this message
1661 buffer is allocated by the caller and free'd by the vOSS after the
1662 message is dispacthed to the appropriate component. If the consumer
1663 of the message needs to keep anything in the body, it needs to copy
1664 the contents before returning from the message handler.
1665
1666 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1667 to the message queue.
1668
1669 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1670 refer to a valid Message Queue Id.
1671
1672 VOS_STATUS_E_FAULT - message is an invalid pointer.
1673
1674 VOS_STATUS_E_FAILURE - the message queue handler has reported
1675 an unknown failure.
1676
1677 \sa
1678
1679 --------------------------------------------------------------------------*/
1680
1681VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1682{
1683 pVosMqType pTargetMq = NULL;
1684 pVosMsgWrapper pMsgWrapper = NULL;
1685 if ((gpVosContext == NULL) || (pMsg == NULL))
1686 {
1687 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1688 "%s: Null params or global vos context is null", __func__);
1689 VOS_ASSERT(0);
1690 return VOS_STATUS_E_FAILURE;
1691 }
1692
1693 switch (msgQueueId)
1694 {
1695
1696 case VOS_MQ_ID_SYS:
1697 {
1698 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
1699 break;
1700 }
1701
1702 /// Message Queue ID for messages bound for WDI
1703 case VOS_MQ_ID_WDI:
1704 {
1705 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
1706 break;
1707 }
1708
1709 default:
1710
1711 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301712 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 __func__, msgQueueId);
1714
1715 return VOS_STATUS_E_FAILURE;
1716 }
1717
1718 if (pTargetMq == NULL)
1719 {
1720 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001721 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 return VOS_STATUS_E_FAILURE;
1723 }
1724
1725
1726 /*
1727 ** Try and get a free Msg wrapper
1728 */
1729 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1730
1731 if (NULL == pMsgWrapper)
1732 {
1733 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1734 "%s: VOS Core run out of message wrapper", __func__);
1735
1736 return VOS_STATUS_E_RESOURCES;
1737 }
1738
1739 /*
1740 ** Copy the message now
1741 */
1742 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1743 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1744
1745 vos_mq_put(pTargetMq, pMsgWrapper);
1746
1747 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
1748 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
1749
1750 return VOS_STATUS_SUCCESS;
1751
1752} /* vos_rx_mq_serialize()*/
1753
Jeff Johnson295189b2012-06-20 16:38:30 -07001754v_VOID_t
1755vos_sys_probe_thread_cback
1756(
1757 v_VOID_t *pUserData
1758)
1759{
1760 if (gpVosContext != pUserData)
1761 {
1762 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001763 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 return;
1765 }
1766
1767 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
1768 {
1769 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001770 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 return;
1772 }
1773
1774} /* vos_sys_probe_thread_cback() */
1775
Jeff Johnson295189b2012-06-20 16:38:30 -07001776v_VOID_t vos_WDAComplete_cback
1777(
1778 v_VOID_t *pUserData
1779)
1780{
1781
1782 if (gpVosContext != pUserData)
1783 {
1784 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001785 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 return;
1787 }
1788
1789 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
1790 {
1791 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001792 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 return;
1794 }
1795
1796} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07001797
1798v_VOID_t vos_core_return_msg
1799(
1800 v_PVOID_t pVContext,
1801 pVosMsgWrapper pMsgWrapper
1802)
1803{
1804 pVosContextType pVosContext = (pVosContextType) pVContext;
1805
1806 VOS_ASSERT( gpVosContext == pVosContext);
1807
1808 if (gpVosContext != pVosContext)
1809 {
1810 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001811 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 return;
1813 }
1814
1815 VOS_ASSERT( NULL !=pMsgWrapper );
1816
1817 if (pMsgWrapper == NULL)
1818 {
1819 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001820 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 return;
1822 }
1823
1824 /*
1825 ** Return the message on the free message queue
1826 */
1827 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
1828 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
1829
1830} /* vos_core_return_msg() */
1831
1832
1833/**
1834 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
1835 TL config params from the registry
1836
1837 @param pAdapter : [inout] pointer to TL config block
1838
1839 @return
1840 None
1841
1842*/
1843v_VOID_t
1844vos_fetch_tl_cfg_parms
1845(
1846 WLANTL_ConfigInfoType *pTLConfig,
1847 hdd_config_t * pConfig
1848)
1849{
1850 if (pTLConfig == NULL)
1851 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001852 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 return;
1854 }
1855
1856 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
1857 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
1858 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
1859 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
1860 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07001862
1863}
1864
1865v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
1866{
1867 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
1868}
1869
1870void vos_abort_mac_scan(void)
1871{
1872 hdd_context_t *pHddCtx = NULL;
1873 v_CONTEXT_t pVosContext = NULL;
1874
1875 /* Get the Global VOSS Context */
1876 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1877 if(!pVosContext) {
1878 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
1879 return;
1880 }
1881
1882 /* Get the HDD context */
1883 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1884 if(!pHddCtx) {
1885 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
1886 return;
1887 }
1888
1889 hdd_abort_mac_scan(pHddCtx);
1890 return;
1891}
1892
1893/*---------------------------------------------------------------------------
1894
1895 \brief vos_shutdown() - shutdown VOS
1896
1897 - All VOS submodules are closed.
1898
1899 - All the WLAN SW components should have been opened. This includes
1900 SYS, MAC, SME and TL.
1901
1902
1903 \param vosContext: Global vos context
1904
1905
1906 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
1907
1908 VOS_STATUS_E_FAILURE - Failure to close
1909
1910---------------------------------------------------------------------------*/
1911VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
1912{
1913 VOS_STATUS vosStatus;
1914
1915#ifdef WLAN_BTAMP_FEATURE
1916 vosStatus = WLANBAP_Close(vosContext);
1917 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1918 {
1919 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1920 "%s: Failed to close BAP", __func__);
1921 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1922 }
1923#endif // WLAN_BTAMP_FEATURE
1924
1925 vosStatus = WLANTL_Close(vosContext);
1926 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1927 {
1928 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1929 "%s: Failed to close TL", __func__);
1930 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1931 }
1932
1933 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1934 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1935 {
1936 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1937 "%s: Failed to close SME", __func__);
1938 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1939 }
1940
1941 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1942 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1943 {
1944 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1945 "%s: Failed to close MAC", __func__);
1946 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1947 }
1948
1949 ((pVosContextType)vosContext)->pMACContext = NULL;
1950
1951 vosStatus = vos_nv_close();
1952 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1953 {
1954 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1955 "%s: Failed to close NV", __func__);
1956 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1957 }
1958
1959 vosStatus = sysClose( vosContext );
1960 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1961 {
1962 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1963 "%s: Failed to close SYS", __func__);
1964 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1965 }
1966
1967 /* Let DXE return packets in WDA_close and then free them here */
1968 vosStatus = vos_packet_close( vosContext );
1969 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1970 {
1971 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1972 "%s: Failed to close VOSS Packet", __func__);
1973 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1974 }
1975
1976 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1977
1978 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1979 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1980 {
1981 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1982 "%s: failed to destroy wdaCompleteEvent", __func__);
1983 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1984 }
1985
1986 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1987 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1988 {
1989 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1990 "%s: failed to destroy ProbeEvent", __func__);
1991 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1992 }
1993
1994 return VOS_STATUS_SUCCESS;
1995}
1996
1997/*---------------------------------------------------------------------------
1998
1999 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2000
2001 - WDA/WDI shutdown
2002
2003 \param vosContext: Global vos context
2004
2005
2006 \return VOS_STATUS_SUCCESS - Operation successfull
2007
2008 VOS_STATUS_E_FAILURE - Failure to close
2009
2010---------------------------------------------------------------------------*/
2011VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2012{
2013 VOS_STATUS vosStatus;
2014 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2015
2016 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2017 {
2018 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2019 "%s: failed to shutdown WDA", __func__);
2020 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2021 }
2022 return vosStatus;
2023}
2024/**
2025 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2026
2027 This function is called when Riva subsystem crashes. There are two
2028 methods (or operations) in WLAN driver to handle Riva crash,
2029 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2030 driver without handshaking with Riva.
2031 2. re-init: Next API
2032 @param
2033 NONE
2034 @return
2035 VOS_STATUS_SUCCESS - Operation completed successfully.
2036 VOS_STATUS_E_FAILURE - Operation failed.
2037
2038*/
2039VOS_STATUS vos_wlanShutdown(void)
2040{
2041 VOS_STATUS vstatus;
2042 vstatus = vos_watchdog_wlan_shutdown();
2043 return vstatus;
2044}
2045/**
2046 @brief vos_wlanReInit() - This API will re-init WLAN driver
2047
2048 This function is called when Riva subsystem reboots. There are two
2049 methods (or operations) in WLAN driver to handle Riva crash,
2050 1. shutdown: Previous API
2051 2. re-init: Called when Riva comes back after the crash. This will
2052 re-initialize WLAN driver. In some cases re-open may be
2053 referred instead of re-init.
2054 @param
2055 NONE
2056 @return
2057 VOS_STATUS_SUCCESS - Operation completed successfully.
2058 VOS_STATUS_E_FAILURE - Operation failed.
2059
2060*/
2061VOS_STATUS vos_wlanReInit(void)
2062{
2063 VOS_STATUS vstatus;
2064 vstatus = vos_watchdog_wlan_re_init();
2065 return vstatus;
2066}
Jeff Johnsone7245742012-09-05 17:12:55 -07002067/**
2068 @brief vos_wlanRestart() - This API will reload WLAN driver.
2069
2070 This function is called if driver detects any fatal state which
2071 can be recovered by a WLAN module reload ( Android framwork initiated ).
2072 Note that this API will not initiate any RIVA subsystem restart.
2073
2074 The function wlan_hdd_restart_driver protects against re-entrant calls.
2075
2076 @param
2077 NONE
2078 @return
2079 VOS_STATUS_SUCCESS - Operation completed successfully.
2080 VOS_STATUS_E_FAILURE - Operation failed.
2081 VOS_STATUS_E_EMPTY - No configured interface
2082 VOS_STATUS_E_ALREADY - Request already in progress
2083
2084
2085*/
2086VOS_STATUS vos_wlanRestart(void)
2087{
2088 VOS_STATUS vstatus;
2089 hdd_context_t *pHddCtx = NULL;
2090 v_CONTEXT_t pVosContext = NULL;
2091
2092 /* Check whether driver load unload is in progress */
2093 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2094 {
2095 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2096 "%s: Driver load/unload is in progress, retry later.", __func__);
2097 return VOS_STATUS_E_AGAIN;
2098 }
2099
2100 /* Get the Global VOSS Context */
2101 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2102 if(!pVosContext) {
2103 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2104 "%s: Global VOS context is Null", __func__);
2105 return VOS_STATUS_E_FAILURE;
2106 }
2107
2108 /* Get the HDD context */
2109 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2110 if(!pHddCtx) {
2111 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2112 "%s: HDD context is Null", __func__);
2113 return VOS_STATUS_E_FAILURE;
2114 }
2115
2116 /* Reload the driver */
2117 vstatus = wlan_hdd_restart_driver(pHddCtx);
2118 return vstatus;
2119}