blob: e724f9c6963205708e36505493fc7f410a035fcd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
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
22/**=========================================================================
23
24 \file vos_api.c
25
26 \brief Stub file for all virtual Operating System Services (vOSS) APIs
27
28 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
29
30 Qualcomm Confidential and Proprietary.
31
32 ========================================================================*/
33 /*===========================================================================
34
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 03/29/09 kanand Created module.
48===========================================================================*/
49
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
54#include "aniGlobal.h"
55#include "halTypes.h"
56#include "wlan_qct_sal.h"
57#include "wlan_qct_bal.h"
58#endif
59#include <vos_mq.h>
60#include "vos_sched.h"
61#include <vos_api.h>
62#include "sirTypes.h"
63#include "sirApi.h"
64#include "sirMacProtDef.h"
65#include "sme_Api.h"
66#include "macInitApi.h"
67#include "wlan_qct_sys.h"
68#include "wlan_qct_tl.h"
69#include "wlan_hdd_misc.h"
70#include "i_vos_packet.h"
71#include "vos_nvitem.h"
72#include "wlan_qct_wda.h"
73#include "wlan_hdd_main.h"
74#include <linux/vmalloc.h>
75
76
77#ifdef WLAN_SOFTAP_FEATURE
78#include "sapApi.h"
79#endif
80
81
82
83#ifdef WLAN_BTAMP_FEATURE
84#include "bapApi.h"
85#include "bapInternal.h"
86#include "bap_hdd_main.h"
87#endif //WLAN_BTAMP_FEATURE
88
89
90/*---------------------------------------------------------------------------
91 * Preprocessor Definitions and Constants
92 * ------------------------------------------------------------------------*/
93/* Amount of time to wait for WDA to perform an asynchronous activity.
94 This value should be larger than the timeout used by WDI to wait for
95 a response from WCNSS since in the event that WCNSS is not responding,
96 WDI should handle that timeout */
97#define VOS_WDA_TIMEOUT 15000
98
99/* Approximate amount of time to wait for WDA to stop WDI */
100#define VOS_WDA_STOP_TIMEOUT WDA_STOP_TIMEOUT
101
102/*---------------------------------------------------------------------------
103 * Data definitions
104 * ------------------------------------------------------------------------*/
105static VosContextType gVosContext;
106static pVosContextType gpVosContext;
107
108/*---------------------------------------------------------------------------
109 * Forward declaration
110 * ------------------------------------------------------------------------*/
111v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
112
113#ifndef FEATURE_WLAN_INTEGRATED_SOC
114v_VOID_t vos_sys_start_complete_cback ( v_VOID_t *pUserData );
115#endif
116v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
117
118v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
119 hdd_config_t * pConfig );
120#ifndef FEATURE_WLAN_INTEGRATED_SOC
121VOS_STATUS vos_get_fwbinary( v_VOID_t **ppBinary, v_SIZE_t *pNumBytes );
122#endif
123
124
125/*---------------------------------------------------------------------------
126
127 \brief vos_preOpen() - PreOpen the vOSS Module
128
129 The \a vos_preOpen() function allocates the Vos Context, but do not
130 initialize all the members. This overal initialization will happen
131 at vos_Open().
132 The reason why we need vos_preOpen() is to get a minimum context
133 where to store BAL and SAL relative data, which happens before
134 vos_Open() is called.
135
136 \param pVosContext: A pointer to where to store the VOS Context
137
138
139 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
140 is ready to be used.
141
142 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
143
144 \sa vos_Open()
145
146---------------------------------------------------------------------------*/
147VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
148{
149 if ( pVosContext == NULL)
150 return VOS_STATUS_E_FAILURE;
151
152 /* Allocate the VOS Context */
153 *pVosContext = NULL;
154 gpVosContext = &gVosContext;
155
156 if (NULL == gpVosContext)
157 {
158 /* Critical Error ...Cannot proceed further */
159 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
160 "%s: Failed to allocate VOS Context", __func__);
161 VOS_ASSERT(0);
162 return VOS_STATUS_E_RESOURCES;
163 }
164
165 vos_mem_zero(gpVosContext, sizeof(VosContextType));
166
167 *pVosContext = gpVosContext;
168
169 return VOS_STATUS_SUCCESS;
170
171} /* vos_preOpen()*/
172
173
174/*---------------------------------------------------------------------------
175
176 \brief vos_preClose() - PreClose the vOSS Module
177
178 The \a vos_preClose() function frees the Vos Context.
179
180 \param pVosContext: A pointer to where the VOS Context was stored
181
182
183 \return VOS_STATUS_SUCCESS - Always successful
184
185
186 \sa vos_preClose()
187 \sa vos_close()
188---------------------------------------------------------------------------*/
189VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
190{
191
192 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
193 "%s: De-allocating the VOS Context", __func__);
194
195 if (( pVosContext == NULL) || (*pVosContext == NULL))
196 {
197 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
198 "%s: vOS Context is Null", __func__);
199 return VOS_STATUS_E_FAILURE;
200 }
201
202 if (gpVosContext != *pVosContext)
203 {
204 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
205 "%s: Context mismatch", __func__);
206 return VOS_STATUS_E_FAILURE;
207 }
208
209 *pVosContext = gpVosContext = NULL;
210
211 return VOS_STATUS_SUCCESS;
212
213} /* vos_preClose()*/
214
215/*---------------------------------------------------------------------------
216
217 \brief vos_open() - Open the vOSS Module
218
219 The \a vos_open() function opens the vOSS Scheduler
220 Upon successful initialization:
221
222 - All VOS submodules should have been initialized
223
224 - The VOS scheduler should have opened
225
226 - All the WLAN SW components should have been opened. This includes
227 SYS, MAC, SME, WDA and TL.
228
229
230 \param hddContextSize: Size of the HDD context to allocate.
231
232
233 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
234 is ready to be used.
235
236 VOS_STATUS_E_RESOURCES - System resources (other than memory)
237 are unavailable to initilize the scheduler
238
239
240 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
241
242 \sa vos_preOpen()
243
244---------------------------------------------------------------------------*/
245VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, v_SIZE_t hddContextSize )
246
247{
248 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
249 int iter = 0;
250 tSirRetStatus sirStatus = eSIR_SUCCESS;
251 tMacOpenParameters macOpenParms;
252 WLANTL_ConfigInfoType TLConfig;
253
254 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
255 "%s: Opening VOSS", __func__);
256
257 if (NULL == gpVosContext)
258 {
259 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
260 "%s: Trying to open VOSS without a PreOpen", __func__);
261 VOS_ASSERT(0);
262 return VOS_STATUS_E_FAILURE;
263 }
264
265 /* Initialize the timer module */
266 vos_timer_module_init();
267
268 /* Initialize the probe event */
269 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
270 {
271 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
272 "%s: Unable to init probeEvent", __func__);
273 VOS_ASSERT(0);
274 return VOS_STATUS_E_FAILURE;
275 }
276#ifdef FEATURE_WLAN_INTEGRATED_SOC
277 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
278 {
279 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
280 "%s: Unable to init wdaCompleteEvent", __func__);
281 VOS_ASSERT(0);
282
283 goto err_probe_event;
284 }
285
286 /* Saving the HDD context */
287 /* This is saved in hdd_wlan_start_up before calling vos_open
288 gpVosContext->pHDDContext = pHddContext;*/
289
290 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
291 "%s: HDD context is saved successfully", __func__);
292
293#endif
294
295 /* Initialize the free message queue */
296 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
297 if (! VOS_IS_STATUS_SUCCESS(vStatus))
298 {
299
300 /* Critical Error ... Cannot proceed further */
301 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
302 "%s: Failed to initialize VOS free message queue", __func__);
303 VOS_ASSERT(0);
304#ifndef FEATURE_WLAN_INTEGRATED_SOC
305 goto err_probe_event;
306#else
307 goto err_wda_complete_event;
308#endif
309 }
310
311 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
312 {
313 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
314 &(gpVosContext->aMsgBuffers[iter]);
315 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
316 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
317 }
318#ifndef FEATURE_WLAN_INTEGRATED_SOC
319 /* Initialize here the VOS Packet sub module */
320 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
321 sizeof( vos_pkt_context_t ) );
322
323 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
324 {
325 /* Critical Error ... Cannot proceed further */
326 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
327 "%s: Failed to open VOS Packet Module", __func__);
328 VOS_ASSERT(0);
329 goto err_msg_queue;
330 }
331#endif
332
333 /* Now Open the VOS Scheduler */
334 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
335 sizeof(VosSchedContext));
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 VOS Scheduler", __func__);
342 VOS_ASSERT(0);
343#ifndef FEATURE_WLAN_INTEGRATED_SOC
344 goto err_packet_close;
345#else
346 goto err_msg_queue;
347#endif
348 }
349
350#ifdef FEATURE_WLAN_INTEGRATED_SOC
351 /*
352 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
353 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
354 */
355
356 /*Open the WDA module */
357 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
358 /* UMA is supported in hardware for performing the
359 ** frame translation 802.11 <-> 802.3
360 */
361 macOpenParms.frameTransRequired = 1;
362 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
363 vStatus = WDA_open( gpVosContext, gpVosContext->pHDDContext, &macOpenParms );
364
365 if (!VOS_IS_STATUS_SUCCESS(vStatus))
366 {
367 /* Critical Error ... Cannot proceed further */
368 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
369 "%s: Failed to open WDA module", __func__);
370 VOS_ASSERT(0);
371 goto err_sched_close;
372 }
373
374 /* Initialize here the VOS Packet sub module */
375 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
376 sizeof( vos_pkt_context_t ) );
377
378 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
379 {
380 /* Critical Error ... Cannot proceed further */
381 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
382 "%s: Failed to open VOS Packet Module", __func__);
383 VOS_ASSERT(0);
384 goto err_wda_close;
385 }
386#endif
387
388 /* Open the SYS module */
389 vStatus = sysOpen(gpVosContext);
390
391 if (!VOS_IS_STATUS_SUCCESS(vStatus))
392 {
393 /* Critical Error ... Cannot proceed further */
394 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
395 "%s: Failed to open SYS module", __func__);
396 VOS_ASSERT(0);
397#ifndef FEATURE_WLAN_INTEGRATED_SOC
398 goto err_sched_close;
399#else
400 goto err_packet_close;
401#endif
402 }
403
404
405 /* initialize the NV module */
406 vStatus = vos_nv_open();
407 if (!VOS_IS_STATUS_SUCCESS(vStatus))
408 {
409 // NV module cannot be initialized
410 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
411 "%s: Failed to initialize the NV module", __func__);
412 goto err_sys_close;
413 }
414#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
415 /* Probe the MC thread */
416 sysMcThreadProbe(gpVosContext,
417 &vos_sys_probe_thread_cback,
418 gpVosContext);
419
420 if (vos_wait_single_event(&gpVosContext->ProbeEvent, 0)!= VOS_STATUS_SUCCESS)
421 {
422 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
423 "%s: Failed to probe MC Thread", __func__);
424 VOS_ASSERT(0);
425 goto err_nv_close;
426 }
427
428 /*Now probe the Tx thread */
429 sysTxThreadProbe(gpVosContext,
430 &vos_sys_probe_thread_cback,
431 gpVosContext);
432
433 if (vos_wait_single_event(&gpVosContext->ProbeEvent, 0)!= VOS_STATUS_SUCCESS)
434 {
435 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
436 "%s: Failed to probe TX Thread", __func__);
437 VOS_ASSERT(0);
438 goto err_nv_close;
439 }
440#endif
441
442 /* If we arrive here, both threads dispacthing messages correctly */
443
444 /* Now proceed to open the MAC */
445
446 /* UMA is supported in hardware for performing the
447 frame translation 802.11 <-> 802.3 */
448 macOpenParms.frameTransRequired = 1;
449 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
450 &macOpenParms);
451
452 if (eSIR_SUCCESS != sirStatus)
453 {
454 /* Critical Error ... Cannot proceed further */
455 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
456 "%s: Failed to open MAC", __func__);
457 VOS_ASSERT(0);
458 goto err_nv_close;
459 }
460
461 /* Now proceed to open the SME */
462 vStatus = sme_Open(gpVosContext->pMACContext);
463 if (!VOS_IS_STATUS_SUCCESS(vStatus))
464 {
465 /* Critical Error ... Cannot proceed further */
466 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
467 "%s: Failed to open SME", __func__);
468 VOS_ASSERT(0);
469 goto err_mac_close;
470 }
471
472 /* Now proceed to open TL. Read TL config first */
473 vos_fetch_tl_cfg_parms ( &TLConfig,
474 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
475
476 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
477 if (!VOS_IS_STATUS_SUCCESS(vStatus))
478 {
479 /* Critical Error ... Cannot proceed further */
480 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
481 "%s: Failed to open TL", __func__);
482 VOS_ASSERT(0);
483 goto err_sme_close;
484 }
485
486 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
487 "%s: VOSS successfully Opened", __func__);
488
489 *pVosContext = gpVosContext;
490
491 return VOS_STATUS_SUCCESS;
492
493
494err_sme_close:
495 sme_Close(gpVosContext->pMACContext);
496
497err_mac_close:
498 macClose(gpVosContext->pMACContext);
499
500err_nv_close:
501 vos_nv_close();
502
503err_sys_close:
504 sysClose(gpVosContext);
505
506#ifdef FEATURE_WLAN_INTEGRATED_SOC
507err_packet_close:
508 vos_packet_close( gpVosContext );
509
510err_wda_close:
511 WDA_close(gpVosContext);
512#endif
513
514err_sched_close:
515 vos_sched_close(gpVosContext);
516
517#ifndef FEATURE_WLAN_INTEGRATED_SOC
518err_packet_close:
519 vos_packet_close( gpVosContext );
520#endif
521
522err_msg_queue:
523 vos_mq_deinit(&gpVosContext->freeVosMq);
524
525#ifdef FEATURE_WLAN_INTEGRATED_SOC
526err_wda_complete_event:
527 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
528#endif
529
530err_probe_event:
531 vos_event_destroy(&gpVosContext->ProbeEvent);
532
533 return VOS_STATUS_E_FAILURE;
534
535} /* vos_open() */
536
537#ifdef FEATURE_WLAN_INTEGRATED_SOC
538/*---------------------------------------------------------------------------
539
540 \brief vos_preStart() -
541
542 The \a vos_preStart() function to download CFG.
543 including:
544 - ccmStart
545
546 - WDA: triggers the CFG download
547
548
549 \param pVosContext: The VOS context
550
551
552 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
553 is ready to be used.
554
555 VOS_STATUS_E_RESOURCES - System resources (other than memory)
556 are unavailable to initilize the scheduler
557
558
559 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
560
561 \sa vos_start
562
563---------------------------------------------------------------------------*/
564VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
565{
566 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
567 pVosContextType pVosContext = (pVosContextType)vosContext;
568
569 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
570 "vos prestart");
571
572 VOS_ASSERT(gpVosContext == pVosContext);
573
574 VOS_ASSERT( NULL != pVosContext->pMACContext);
575
576 VOS_ASSERT( NULL != pVosContext->pWDAContext);
577
578 /* call macPreStart */
579 vStatus = macPreStart(gpVosContext->pMACContext);
580 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
581 {
582 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
583 "Failed at macPreStart ");
584 return VOS_STATUS_E_FAILURE;
585 }
586
587 /* call ccmStart */
588 ccmStart(gpVosContext->pMACContext);
589
590 /* Reset wda wait event */
591 vos_event_reset(&gpVosContext->wdaCompleteEvent);
592
593
594 /*call WDA pre start*/
595 vStatus = WDA_preStart(gpVosContext);
596 if (!VOS_IS_STATUS_SUCCESS(vStatus))
597 {
598 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
599 "Failed to WDA prestart");
600 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
601 ccmStop(gpVosContext->pMACContext);
602 VOS_ASSERT(0);
603 return VOS_STATUS_E_FAILURE;
604 }
605
606 /* Need to update time out of complete */
607 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
608 VOS_WDA_TIMEOUT );
609 if ( vStatus != VOS_STATUS_SUCCESS )
610 {
611 if ( vStatus == VOS_STATUS_E_TIMEOUT )
612 {
613 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
614 "%s: Timeout occurred before WDA complete\n", __func__);
615 }
616 else
617 {
618 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
619 "%s: WDA_preStart reporting other error", __func__);
620 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700621 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
622 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 VOS_ASSERT( 0 );
624 return VOS_STATUS_E_FAILURE;
625 }
626
627 return VOS_STATUS_SUCCESS;
628}
629#endif
630
631/*---------------------------------------------------------------------------
632
633 \brief vos_start() - Start the Libra SW Modules
634
635 The \a vos_start() function starts all the components of the Libra SW
636 including:
637 - SAL/BAL, which in turn starts SSC
638
639 - the MAC (HAL and PE)
640
641 - SME
642
643 - TL
644
645 - SYS: triggers the CFG download
646
647
648 \param pVosContext: The VOS context
649
650
651 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
652 is ready to be used.
653
654 VOS_STATUS_E_RESOURCES - System resources (other than memory)
655 are unavailable to initilize the scheduler
656
657
658 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
659
660 \sa vos_preStart()
661 \sa vos_open()
662
663---------------------------------------------------------------------------*/
664VOS_STATUS vos_start( v_CONTEXT_t vosContext )
665{
666 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
667 tSirRetStatus sirStatus = eSIR_SUCCESS;
668 pVosContextType pVosContext = (pVosContextType)vosContext;
669 tHalMacStartParameters halStartParams;
670#ifndef FEATURE_WLAN_INTEGRATED_SOC
671 v_VOID_t *pFwBinary = NULL;
672 v_SIZE_t numFwBytes = 0;
673#endif
674
675 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
676 "%s: Starting Libra SW", __func__);
677
678 /* We support only one instance for now ...*/
679 if (gpVosContext != pVosContext)
680 {
681 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
682 "%s: mismatch in context", __FUNCTION__);
683 return VOS_STATUS_E_FAILURE;
684 }
685
686#ifndef FEATURE_WLAN_INTEGRATED_SOC
687 if (( pVosContext->pBALContext == NULL) || ( pVosContext->pMACContext == NULL)
688 || ( pVosContext->pTLContext == NULL))
689 {
690 if (pVosContext->pBALContext == NULL)
691 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
692 "%s: BAL NULL context", __FUNCTION__);
693 else if (pVosContext->pMACContext == NULL)
694 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
695 "%s: MAC NULL context", __FUNCTION__);
696 else
697 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
698 "%s: TL NULL context", __FUNCTION__);
699
700 return VOS_STATUS_E_FAILURE;
701 }
702#else
703 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
704 || ( pVosContext->pTLContext == NULL))
705 {
706 if (pVosContext->pWDAContext == NULL)
707 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
708 "%s: WDA NULL context", __FUNCTION__);
709 else if (pVosContext->pMACContext == NULL)
710 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
711 "%s: MAC NULL context", __FUNCTION__);
712 else
713 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
714 "%s: TL NULL context", __FUNCTION__);
715
716 return VOS_STATUS_E_FAILURE;
717 }
718
719 /* WDA_Start will be called after NV image download because the
720 NV image data has to be updated at HAL before HAL_Start gets executed*/
721
722 /* Start the NV Image Download */
723
724 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
725
726 vStatus = WDA_NVDownload_Start(pVosContext);
727
728 if ( vStatus != VOS_STATUS_SUCCESS )
729 {
730 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
731 "%s: Failed to start NV Download", __func__);
732 return VOS_STATUS_E_FAILURE;
733 }
734
735 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
736 VOS_WDA_TIMEOUT );
737
738 if ( vStatus != VOS_STATUS_SUCCESS )
739 {
740 if ( vStatus == VOS_STATUS_E_TIMEOUT )
741 {
742 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
743 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
744 }
745 else
746 {
747 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
748 "%s: WDA_NVDownload_start reporting other error", __func__);
749 }
750 VOS_ASSERT(0);
751 goto err_wda_stop;
752 }
753
754 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
755 "%s: WDA_NVDownload_start correctly started", __func__);
756
757 /* Start the WDA */
758 vStatus = WDA_start(pVosContext);
759 if ( vStatus != VOS_STATUS_SUCCESS )
760 {
761 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
762 "%s: Failed to start WDA", __func__);
763 return VOS_STATUS_E_FAILURE;
764 }
765 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
766 "%s: WDA correctly started", __func__);
767
768#endif
769 /* Start the MAC */
770 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
771
772#ifndef FEATURE_WLAN_INTEGRATED_SOC
773 /* Attempt to get the firmware binary through VOS. We need to pass this
774 to the MAC when starting. */
775 vStatus = vos_get_fwbinary(&pFwBinary, &numFwBytes);
776
777 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
778 {
779 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
780 "%s: Failed to get firmware binary", __func__);
781 return VOS_STATUS_E_FAILURE;
782 }
783
784 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
785 "%s: Firmware binary file found", __func__);
786
787
788 //Begining kernel 2.6.31, memory buffer returned by request_firmware API
789 //cannot be overwritten. So need to copy the firmware into a separate buffer
790 //as HAL needs to modify the endianess of FW binary.
791
792 //Kernel may not have ~40 pages of free buffers always, so
793 //Store the pointer to the buffer provided by kernel for now,
794 //When required copy it to local buffer for translation.
795 //This is done in vos_api.c, during firmware download
796 //This would provide common fix for ftm driver issue aswell,
797 //which is not creating the copy of firmware image for endian conversion.
798 halStartParams.FW.cbImage = numFwBytes;
799 halStartParams.FW.pImage = pFwBinary;
800
801 //determine the driverType for the mode of operation
802 halStartParams.driverType = eDRIVER_TYPE_PRODUCTION;
803#endif
804 /* Start the MAC */
805 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
806
807#ifndef FEATURE_WLAN_INTEGRATED_SOC
808 hdd_release_firmware(WLAN_FW_FILE, pVosContext->pHDDContext);
809
810 halStartParams.FW.pImage = NULL;
811 halStartParams.FW.cbImage = 0;
812#endif
813 if (eSIR_SUCCESS != sirStatus)
814 {
815 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
816 "%s: Failed to start MAC", __func__);
817#ifndef FEATURE_WLAN_INTEGRATED_SOC
818 return VOS_STATUS_E_FAILURE;
819#else
820 goto err_wda_stop;
821#endif
822 }
823
824 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
825 "%s: MAC correctly started", __func__);
826
827 /* START SME */
828 vStatus = sme_Start(pVosContext->pMACContext);
829
830 if (!VOS_IS_STATUS_SUCCESS(vStatus))
831 {
832 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
833 "%s: Failed to start SME", __func__);
834 goto err_mac_stop;
835 }
836
837 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
838 "%s: SME correctly started", __func__);
839
840 /** START TL */
841 vStatus = WLANTL_Start(pVosContext);
842 if (!VOS_IS_STATUS_SUCCESS(vStatus))
843 {
844 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
845 "%s: Failed to start TL", __func__);
846 goto err_sme_stop;
847 }
848
849 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
850 "TL correctly started");
851#ifndef FEATURE_WLAN_INTEGRATED_SOC
852 /* START SYS. This will trigger the CFG download */
853 sysMcStart(pVosContext, vos_sys_start_complete_cback, pVosContext);
854
855 if (vos_wait_single_event(&gpVosContext->ProbeEvent, 0)!= VOS_STATUS_SUCCESS)
856 {
857 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
858 "%s: Failed to start SYS module", __func__);
859 goto err_tl_stop;
860 }
861
862
863 /**
864 EVM issue is observed with 1.6Mhz freq for 1.3V RF supply in wlan standalone case.
865 During concurrent operation (e.g. WLAN and WCDMA) this issue is not observed.
866 To workaround, wlan will vote for 3.2Mhz during startup and will vote for 1.6Mhz
867 during exit.
868 Since using 3.2Mhz has a side effect on power (extra 200ua), this is left configurable.
869 If customers do their design right, they should not see the EVM issue and in that case they
870 can decide to keep 1.6Mhz by setting an NV.
871 If NV item is not present, use the default 3.2Mhz
872 vos_stop is also invoked if wlan startup seq fails (after vos_start, where 3.2Mhz is voted.)
873 */
874 {
875 sFreqFor1p3VSupply freq;
876 vStatus = vos_nv_read( NV_TABLE_FREQUENCY_FOR_1_3V_SUPPLY, &freq, NULL,
877 sizeof(freq) );
878 if (VOS_STATUS_SUCCESS != vStatus)
879 freq.freqFor1p3VSupply = VOS_NV_FREQUENCY_FOR_1_3V_SUPPLY_3P2MH;
880
881 if (vos_chipVoteFreqFor1p3VSupply(NULL, NULL, NULL, freq.freqFor1p3VSupply) != VOS_STATUS_SUCCESS)
882 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
883 "%s: Failed to set the freq %d for 1.3V Supply",
884 __func__, freq.freqFor1p3VSupply );
885 }
886
887#endif
888 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
889 "%s: VOSS Start is successful!!", __func__);
890
891 return VOS_STATUS_SUCCESS;
892
893#ifndef FEATURE_WLAN_INTEGRATED_SOC
894err_tl_stop:
895 WLANTL_Stop(pVosContext);
896#endif
897
898err_sme_stop:
899 sme_Stop(pVosContext->pMACContext, TRUE);
900
901err_mac_stop:
902 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
903
904#ifdef FEATURE_WLAN_INTEGRATED_SOC
905err_wda_stop:
906 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
907 WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
908 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
909 VOS_WDA_TIMEOUT );
910 if( vStatus != VOS_STATUS_SUCCESS )
911 {
912 if( vStatus == VOS_STATUS_E_TIMEOUT )
913 {
914 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
915 "%s: Timeout occurred before WDA_stop complete", __func__);
916
917 }
918 else
919 {
920 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
921 "%s: WDA_stop reporting other error", __func__);
922 }
923 VOS_ASSERT( 0 );
924 }
925#endif
926
927 return VOS_STATUS_E_FAILURE;
928
929} /* vos_start() */
930
931
932/* vos_stop function */
933VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
934{
935 VOS_STATUS vosStatus;
936
937#ifdef FEATURE_WLAN_INTEGRATED_SOC
938 /* WDA_Stop is called before the SYS so that the processing of Riva
939 pending responces will not be handled during uninitialization of WLAN driver */
940 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
941
942 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
943
944 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
945 {
946 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
947 "%s: Failed to stop WDA", __func__);
948 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
949 }
950
951 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
952 VOS_WDA_STOP_TIMEOUT );
953
954 if ( vosStatus != VOS_STATUS_SUCCESS )
955 {
956 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
957 {
958 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
959 "%s: Timeout occurred before WDA complete", __func__);
960 }
961 else
962 {
963 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
964 "%s: WDA_stop reporting other error", __func__ );
965 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700966 WDA_stopFailed(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 }
968#endif
969
970 /* SYS STOP will stop SME and MAC */
971 vosStatus = sysStop( vosContext);
972 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
973 {
974 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
975 "%s: Failed to stop SYS", __func__);
976 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
977 }
978
979 vosStatus = WLANTL_Stop( vosContext );
980 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
981 {
982 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
983 "%s: Failed to stop TL", __func__);
984 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
985 }
986
987#ifndef FEATURE_WLAN_INTEGRATED_SOC
988 /**
989 EVM issue is observed with 1.6Mhz freq for 1.3V supply in wlan standalone case.
990 During concurrent operation (e.g. WLAN and WCDMA) this issue is not observed.
991 To workaround, wlan will vote for 3.2Mhz during startup and will vote for 1.6Mhz
992 during exit.
993 vos_stop is also invoked if wlan startup seq fails (after vos_start, where 3.2Mhz is voted.)
994 */
995 if (vos_chipVoteFreqFor1p3VSupply(NULL, NULL, NULL, VOS_NV_FREQUENCY_FOR_1_3V_SUPPLY_1P6MH) != VOS_STATUS_SUCCESS)
996 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
997 "%s: Failed to set the freq to 1.6Mhz for 1.3V Supply", __func__ );
998#endif
999
1000 return VOS_STATUS_SUCCESS;
1001}
1002
1003
1004/* vos_close function */
1005VOS_STATUS vos_close( v_CONTEXT_t vosContext )
1006{
1007 VOS_STATUS vosStatus;
1008
1009#ifdef WLAN_BTAMP_FEATURE
1010 vosStatus = WLANBAP_Close(vosContext);
1011 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1012 {
1013 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1014 "%s: Failed to close BAP", __func__);
1015 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1016 }
1017#endif // WLAN_BTAMP_FEATURE
1018
1019
1020 vosStatus = WLANTL_Close(vosContext);
1021 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1022 {
1023 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1024 "%s: Failed to close TL", __func__);
1025 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1026 }
1027
1028 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1029 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1030 {
1031 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1032 "%s: Failed to close SME", __func__);
1033 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1034 }
1035
1036 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1037 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1038 {
1039 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1040 "%s: Failed to close MAC", __func__);
1041 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1042 }
1043
1044 ((pVosContextType)vosContext)->pMACContext = NULL;
1045
1046 vosStatus = vos_nv_close();
1047 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1048 {
1049 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1050 "%s: Failed to close NV", __func__);
1051 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1052 }
1053
1054
1055 vosStatus = sysClose( vosContext );
1056 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1057 {
1058 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1059 "%s: Failed to close SYS", __func__);
1060 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1061 }
1062
1063#ifdef FEATURE_WLAN_INTEGRATED_SOC
Jeff Johnsone7245742012-09-05 17:12:55 -07001064 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001066 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
1067 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
1068 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
1069 {
1070 hdd_set_ssr_required( VOS_TRUE );
1071 }
1072 else
1073 {
1074 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1075 "%s: Failed to shutdown WDA", __func__ );
1076 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1077 }
1078 }
1079 else
1080 {
1081 vosStatus = WDA_close( vosContext );
1082 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1083 {
1084 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1085 "%s: Failed to close WDA", __func__);
1086 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 }
1089
1090 /* Let DXE return packets in WDA_close and then free them here */
1091 vosStatus = vos_packet_close( vosContext );
1092 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1093 {
1094 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1095 "%s: Failed to close VOSS Packet", __func__);
1096 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1097 }
1098#endif
1099
1100#ifndef FEATURE_WLAN_INTEGRATED_SOC
1101 vosStatus = vos_packet_close( vosContext );
1102 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1103 {
1104 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1105 "%s: Failed to close VOSS Packet", __func__);
1106 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1107 }
1108#endif
1109
1110 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1111
1112#ifdef FEATURE_WLAN_INTEGRATED_SOC
1113 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1114 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1115 {
1116 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1117 "%s: failed to destroy wdaCompleteEvent", __func__);
1118 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1119 }
1120#endif
1121
1122 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1123 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1124 {
1125 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1126 "%s: failed to destroy ProbeEvent", __func__);
1127 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1128 }
1129
1130 return VOS_STATUS_SUCCESS;
1131}
1132
1133
1134/**---------------------------------------------------------------------------
1135
1136 \brief vos_get_context() - get context data area
1137
1138 Each module in the system has a context / data area that is allocated
1139 and maanged by voss. This API allows any user to get a pointer to its
1140 allocated context data area from the VOSS global context.
1141
1142 \param vosContext - the VOSS Global Context.
1143
1144 \param moduleId - the module ID, who's context data are is being retrived.
1145
1146 \return - pointer to the context data area.
1147
1148 - NULL if the context data is not allocated for the module ID
1149 specified
1150
1151 --------------------------------------------------------------------------*/
1152v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1153 v_CONTEXT_t pVosContext )
1154{
1155 v_PVOID_t pModContext = NULL;
1156
1157 if (pVosContext == NULL)
1158 {
1159 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1160 "%s: vos context pointer is null", __FUNCTION__);
1161 return NULL;
1162 }
1163
1164 if (gpVosContext != pVosContext)
1165 {
1166 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1167 "%s: pVosContext != gpVosContext", __FUNCTION__);
1168 return NULL;
1169 }
1170
1171 switch(moduleId)
1172 {
1173 case VOS_MODULE_ID_TL:
1174 {
1175 pModContext = gpVosContext->pTLContext;
1176 break;
1177 }
1178
1179#ifndef FEATURE_WLAN_INTEGRATED_SOC
1180 case VOS_MODULE_ID_BAL:
1181 {
1182 pModContext = gpVosContext->pBALContext;
1183 break;
1184 }
1185
1186 case VOS_MODULE_ID_SAL:
1187 {
1188 pModContext = gpVosContext->pSALContext;
1189 break;
1190 }
1191
1192 case VOS_MODULE_ID_SSC:
1193 {
1194 pModContext = gpVosContext->pSSCContext;
1195 break;
1196 }
1197#endif
1198#ifdef WLAN_BTAMP_FEATURE
1199 case VOS_MODULE_ID_BAP:
1200 {
1201 pModContext = gpVosContext->pBAPContext;
1202 break;
1203 }
1204#endif //WLAN_BTAMP_FEATURE
1205
1206#ifdef WLAN_SOFTAP_FEATURE
1207 case VOS_MODULE_ID_SAP:
1208 {
1209 pModContext = gpVosContext->pSAPContext;
1210 break;
1211 }
1212
1213 case VOS_MODULE_ID_HDD_SOFTAP:
1214 {
1215 pModContext = gpVosContext->pHDDSoftAPContext;
1216 break;
1217 }
1218#endif
1219
1220 case VOS_MODULE_ID_HDD:
1221 {
1222 pModContext = gpVosContext->pHDDContext;
1223 break;
1224 }
1225
1226 case VOS_MODULE_ID_SME:
1227#ifndef FEATURE_WLAN_INTEGRATED_SOC
1228 case VOS_MODULE_ID_HAL:
1229#endif
1230 case VOS_MODULE_ID_PE:
1231 {
1232 /*
1233 ** In all these cases, we just return the MAC Context
1234 */
1235 pModContext = gpVosContext->pMACContext;
1236 break;
1237 }
1238
1239#ifdef FEATURE_WLAN_INTEGRATED_SOC
1240 case VOS_MODULE_ID_WDA:
1241 {
1242 /* For WDA module */
1243 pModContext = gpVosContext->pWDAContext;
1244 break;
1245 }
1246#endif
1247
1248 case VOS_MODULE_ID_VOSS:
1249 {
1250 /* For SYS this is VOS itself*/
1251 pModContext = gpVosContext;
1252 break;
1253 }
1254
1255 default:
1256 {
1257 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1258 "does not have its context maintained by VOSS", __func__, moduleId);
1259 VOS_ASSERT(0);
1260 return NULL;
1261 }
1262 }
1263
1264 if (pModContext == NULL )
1265 {
1266 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1267 "context is Null", __func__, moduleId);
1268 }
1269
1270 return pModContext;
1271
1272} /* vos_get_context()*/
1273
1274
1275/**---------------------------------------------------------------------------
1276
1277 \brief vos_get_global_context() - get VOSS global Context
1278
1279 This API allows any user to get the VOS Global Context pointer from a
1280 module context data area.
1281
1282 \param moduleContext - the input module context pointer
1283
1284 \param moduleId - the module ID who's context pointer is input in
1285 moduleContext.
1286
1287 \return - pointer to the VOSS global context
1288
1289 - NULL if the function is unable to retreive the VOSS context.
1290
1291 --------------------------------------------------------------------------*/
1292v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1293 v_VOID_t *moduleContext )
1294{
1295 if (gpVosContext == NULL)
1296 {
1297 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1298 "%s: global voss context is NULL", __FUNCTION__);
1299 }
1300
1301 return gpVosContext;
1302
1303} /* vos_get_global_context() */
1304
1305
1306v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1307{
1308 if (gpVosContext == NULL)
1309 {
1310 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1311 "%s: global voss context is NULL", __FUNCTION__);
1312 return 1;
1313 }
1314
1315 return gpVosContext->isLogpInProgress;
1316}
1317
1318void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1319{
1320 if (gpVosContext == NULL)
1321 {
1322 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1323 "%s: global voss context is NULL", __FUNCTION__);
1324 return;
1325 }
1326
1327 gpVosContext->isLogpInProgress = value;
1328}
1329
1330v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1331{
1332 if (gpVosContext == NULL)
1333 {
1334 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1335 "%s: global voss context is NULL", __FUNCTION__);
1336 return 0;
1337 }
1338
1339 return gpVosContext->isLoadUnloadInProgress;
1340}
1341
1342void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1343{
1344 if (gpVosContext == NULL)
1345 {
1346 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1347 "%s: global voss context is NULL", __FUNCTION__);
1348 return;
1349 }
1350
1351 gpVosContext->isLoadUnloadInProgress = value;
1352}
1353
1354/**---------------------------------------------------------------------------
1355
1356 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1357
1358 This API allows any user to allocate a user context area within the
1359 VOS Global Context.
1360
1361 \param pVosContext - pointer to the global Vos context
1362
1363 \param moduleId - the module ID who's context area is being allocated.
1364
1365 \param ppModuleContext - pointer to location where the pointer to the
1366 allocated context is returned. Note this
1367 output pointer is valid only if the API
1368 returns VOS_STATUS_SUCCESS
1369
1370 \param size - the size of the context area to be allocated.
1371
1372 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1373 allocated successfully. The pointer to the context area
1374 can be found in *ppModuleContext.
1375 \note This function returns VOS_STATUS_SUCCESS if the
1376 module context was already allocated and the size
1377 allocated matches the size on this call.
1378
1379 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1380 not identify a module that can have a context allocated.
1381
1382 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1383 because a context for this module ID already exists and it is
1384 a *different* size that specified on this call.
1385
1386 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1387 requested context area.
1388
1389 \sa vos_get_context(), vos_free_context()
1390
1391 --------------------------------------------------------------------------*/
1392VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1393 v_VOID_t **ppModuleContext, v_SIZE_t size )
1394{
1395 v_VOID_t ** pGpModContext = NULL;
1396
1397 if ( pVosContext == NULL) {
1398 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1399 "%s: vos context is null", __FUNCTION__);
1400 return VOS_STATUS_E_FAILURE;
1401 }
1402
1403 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1404 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1405 "%s: context mismatch or null param passed", __FUNCTION__);
1406 return VOS_STATUS_E_FAILURE;
1407 }
1408
1409 switch(moduleID)
1410 {
1411 case VOS_MODULE_ID_TL:
1412 {
1413 pGpModContext = &(gpVosContext->pTLContext);
1414 break;
1415 }
1416
1417#ifndef FEATURE_WLAN_INTEGRATED_SOC
1418 case VOS_MODULE_ID_BAL:
1419 {
1420 pGpModContext = &(gpVosContext->pBALContext);
1421 break;
1422 }
1423
1424 case VOS_MODULE_ID_SAL:
1425 {
1426 pGpModContext = &(gpVosContext->pSALContext);
1427 break;
1428 }
1429
1430 case VOS_MODULE_ID_SSC:
1431 {
1432 pGpModContext = &(gpVosContext->pSSCContext);
1433 break;
1434 }
1435#endif
1436#ifdef WLAN_BTAMP_FEATURE
1437 case VOS_MODULE_ID_BAP:
1438 {
1439 pGpModContext = &(gpVosContext->pBAPContext);
1440 break;
1441 }
1442#endif //WLAN_BTAMP_FEATURE
1443
1444#ifdef WLAN_SOFTAP_FEATURE
1445 case VOS_MODULE_ID_SAP:
1446 {
1447 pGpModContext = &(gpVosContext->pSAPContext);
1448 break;
1449 }
1450#endif
1451
1452#ifdef FEATURE_WLAN_INTEGRATED_SOC
1453 case VOS_MODULE_ID_WDA:
1454 {
1455 pGpModContext = &(gpVosContext->pWDAContext);
1456 break;
1457 }
1458#endif
1459 case VOS_MODULE_ID_SME:
1460#ifndef FEATURE_WLAN_INTEGRATED_SOC
1461 case VOS_MODULE_ID_HAL:
1462#endif
1463 case VOS_MODULE_ID_PE:
1464 case VOS_MODULE_ID_HDD:
1465#ifdef WLAN_SOFTAP_FEATURE
1466 case VOS_MODULE_ID_HDD_SOFTAP:
1467#endif
1468 default:
1469 {
1470 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1471 "does not have its context allocated by VOSS", __func__, moduleID);
1472 VOS_ASSERT(0);
1473 return VOS_STATUS_E_INVAL;
1474 }
1475 }
1476
1477 if ( NULL != *pGpModContext)
1478 {
1479 /*
1480 ** Context has already been allocated!
1481 ** Prevent double allocation
1482 */
1483 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1484 "%s: Module ID %i context has already been allocated",
1485 __func__, moduleID);
1486 return VOS_STATUS_E_EXISTS;
1487 }
1488
1489 /*
1490 ** Dynamically allocate the context for module
1491 */
1492
1493 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1494
1495
1496 if ( *ppModuleContext == NULL)
1497 {
1498 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1499 "allocate Context for module ID %i", __func__, moduleID);
1500 VOS_ASSERT(0);
1501 return VOS_STATUS_E_NOMEM;
1502 }
1503
1504 if (moduleID==VOS_MODULE_ID_TL)
1505 {
1506 vos_mem_zero(*ppModuleContext, size);
1507 }
1508
1509 *pGpModContext = *ppModuleContext;
1510
1511 return VOS_STATUS_SUCCESS;
1512
1513} /* vos_alloc_context() */
1514
1515
1516/**---------------------------------------------------------------------------
1517
1518 \brief vos_free_context() - free an allocated a context within the
1519 VOSS global Context
1520
1521 This API allows a user to free the user context area within the
1522 VOS Global Context.
1523
1524 \param pVosContext - pointer to the global Vos context
1525
1526 \param moduleId - the module ID who's context area is being free
1527
1528 \param pModuleContext - pointer to module context area to be free'd.
1529
1530 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1531 free'd. The pointer to the context area is not longer
1532 available.
1533
1534 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1535 valid pointers.
1536
1537 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1538 not identify a module that can have a context free'd.
1539
1540 VOS_STATUS_E_EXISTS - vos could not free the requested
1541 context area because a context for this module ID does not
1542 exist in the global vos context.
1543
1544 \sa vos_get_context()
1545
1546 --------------------------------------------------------------------------*/
1547VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1548 v_VOID_t *pModuleContext )
1549{
1550 v_VOID_t ** pGpModContext = NULL;
1551
1552 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1553 ( pModuleContext == NULL))
1554 {
1555 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1556 "%s: Null params or context mismatch", __func__);
1557 return VOS_STATUS_E_FAILURE;
1558 }
1559
1560
1561 switch(moduleID)
1562 {
1563 case VOS_MODULE_ID_TL:
1564 {
1565 pGpModContext = &(gpVosContext->pTLContext);
1566 break;
1567 }
1568
1569#ifndef FEATURE_WLAN_INTEGRATED_SOC
1570 case VOS_MODULE_ID_BAL:
1571 {
1572 pGpModContext = &(gpVosContext->pBALContext);
1573 break;
1574 }
1575
1576 case VOS_MODULE_ID_SAL:
1577 {
1578 pGpModContext = &(gpVosContext->pSALContext);
1579 break;
1580 }
1581
1582 case VOS_MODULE_ID_SSC:
1583 {
1584 pGpModContext = &(gpVosContext->pSSCContext);
1585 break;
1586 }
1587#endif
1588#ifdef WLAN_BTAMP_FEATURE
1589 case VOS_MODULE_ID_BAP:
1590 {
1591 pGpModContext = &(gpVosContext->pBAPContext);
1592 break;
1593 }
1594#endif //WLAN_BTAMP_FEATURE
1595
1596#ifdef WLAN_SOFTAP_FEATURE
1597 case VOS_MODULE_ID_SAP:
1598 {
1599 pGpModContext = &(gpVosContext->pSAPContext);
1600 break;
1601 }
1602#endif
1603
1604#ifdef FEATURE_WLAN_INTEGRATED_SOC
1605 case VOS_MODULE_ID_WDA:
1606 {
1607 pGpModContext = &(gpVosContext->pWDAContext);
1608 break;
1609 }
1610#endif
1611 case VOS_MODULE_ID_HDD:
1612 case VOS_MODULE_ID_SME:
1613#ifndef FEATURE_WLAN_INTEGRATED_SOC
1614 case VOS_MODULE_ID_HAL:
1615#endif
1616 case VOS_MODULE_ID_PE:
1617#ifdef WLAN_SOFTAP_FEATURE
1618 case VOS_MODULE_ID_HDD_SOFTAP:
1619#endif
1620 default:
1621 {
1622 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1623 "does not have its context allocated by VOSS", __func__, moduleID);
1624 VOS_ASSERT(0);
1625 return VOS_STATUS_E_INVAL;
1626 }
1627 }
1628
1629 if ( NULL == *pGpModContext)
1630 {
1631 /*
1632 ** Context has not been allocated or freed already!
1633 */
1634 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1635 "context has not been allocated or freed already", __func__,moduleID);
1636 return VOS_STATUS_E_FAILURE;
1637 }
1638
1639 if (*pGpModContext != pModuleContext)
1640 {
1641 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1642 "%s: pGpModContext != pModuleContext", __FUNCTION__);
1643 return VOS_STATUS_E_FAILURE;
1644 }
1645
1646 if(pModuleContext != NULL)
1647 kfree(pModuleContext);
1648
1649 *pGpModContext = NULL;
1650
1651 return VOS_STATUS_SUCCESS;
1652
1653} /* vos_free_context() */
1654
1655
1656/**---------------------------------------------------------------------------
1657
1658 \brief vos_mq_post_message() - post a message to a message queue
1659
1660 This API allows messages to be posted to a specific message queue. Messages
1661 can be posted to the following message queues:
1662
1663 <ul>
1664 <li> SME
1665 <li> PE
1666 <li> HAL
1667 <li> TL
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. Memory for this message
1674 buffer is allocated by the caller and free'd by the vOSS after the
1675 message is posted to the message queue. If the consumer of the
1676 message needs anything in this message, it needs to copy the contents
1677 before returning from the message queue 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 --------------------------------------------------------------------------*/
1693VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1694{
1695 pVosMqType pTargetMq = NULL;
1696 pVosMsgWrapper pMsgWrapper = NULL;
1697
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 /// Message Queue ID for messages bound for SME
1709 case VOS_MQ_ID_SME:
1710 {
1711 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1712 break;
1713 }
1714
1715 /// Message Queue ID for messages bound for PE
1716 case VOS_MQ_ID_PE:
1717 {
1718 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1719 break;
1720 }
1721
1722#ifndef FEATURE_WLAN_INTEGRATED_SOC
1723 /// Message Queue ID for messages bound for HAL
1724 case VOS_MQ_ID_HAL:
1725 {
1726 pTargetMq = &(gpVosContext->vosSched.halMcMq);
1727 break;
1728 }
1729#else
1730 /// Message Queue ID for messages bound for WDA
1731 case VOS_MQ_ID_WDA:
1732 {
1733 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1734 break;
1735 }
1736
1737 /// Message Queue ID for messages bound for WDI
1738 case VOS_MQ_ID_WDI:
1739 {
1740 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1741 break;
1742 }
1743#endif
1744
1745 /// Message Queue ID for messages bound for TL
1746 case VOS_MQ_ID_TL:
1747 {
1748 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1749 break;
1750 }
1751
1752 /// Message Queue ID for messages bound for the SYS module
1753 case VOS_MQ_ID_SYS:
1754 {
1755 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1756 break;
1757 }
1758
1759 default:
1760
1761 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1762 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1763 __func__, msgQueueId);
1764
1765 return VOS_STATUS_E_FAILURE;
1766 }
1767
1768 VOS_ASSERT(NULL !=pTargetMq);
1769 if (pTargetMq == NULL)
1770 {
1771 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1772 "%s: pTargetMq == NULL", __FUNCTION__);
1773 return VOS_STATUS_E_FAILURE;
1774 }
1775
1776 /*
1777 ** Try and get a free Msg wrapper
1778 */
1779 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1780
1781 if (NULL == pMsgWrapper)
1782 {
1783 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1784 "%s: VOS Core run out of message wrapper", __func__);
1785
1786 return VOS_STATUS_E_RESOURCES;
1787 }
1788
1789 /*
1790 ** Copy the message now
1791 */
1792 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1793 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1794
1795 vos_mq_put(pTargetMq, pMsgWrapper);
1796
1797 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1798 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1799
1800 return VOS_STATUS_SUCCESS;
1801
1802} /* vos_mq_post_message()*/
1803
1804
1805/**---------------------------------------------------------------------------
1806
1807 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
1808
1809 This API allows messages to be posted to a specific message queue in the
1810 Tx excution flow. Messages for the Tx execution flow can be posted only
1811 to the following queue.
1812
1813 <ul>
1814 <li> TL
1815 <li> SSC/WDI
1816 </ul>
1817
1818 \param msgQueueId - identifies the message queue upon which the message
1819 will be posted.
1820
1821 \param message - a pointer to a message buffer. Body memory for this message
1822 buffer is allocated by the caller and free'd by the vOSS after the
1823 message is dispacthed to the appropriate component. If the consumer
1824 of the message needs to keep anything in the body, it needs to copy
1825 the contents before returning from the message handler.
1826
1827 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1828 to the message queue.
1829
1830 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1831 refer to a valid Message Queue Id.
1832
1833 VOS_STATUS_E_FAULT - message is an invalid pointer.
1834
1835 VOS_STATUS_E_FAILURE - the message queue handler has reported
1836 an unknown failure.
1837
1838 \sa
1839
1840 --------------------------------------------------------------------------*/
1841VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1842{
1843 pVosMqType pTargetMq = NULL;
1844 pVosMsgWrapper pMsgWrapper = NULL;
1845
1846 if ((gpVosContext == NULL) || (pMsg == NULL))
1847 {
1848 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1849 "%s: Null params or global vos context is null", __func__);
1850 VOS_ASSERT(0);
1851 return VOS_STATUS_E_FAILURE;
1852 }
1853
1854 switch (msgQueueId)
1855 {
1856 /// Message Queue ID for messages bound for SME
1857 case VOS_MQ_ID_TL:
1858 {
1859 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
1860 break;
1861 }
1862
1863#ifndef FEATURE_WLAN_INTEGRATED_SOC
1864 /// Message Queue ID for messages bound for SSC
1865 case VOS_MQ_ID_SSC:
1866 {
1867 pTargetMq = &(gpVosContext->vosSched.sscTxMq);
1868 break;
1869 }
1870#else
1871 /// Message Queue ID for messages bound for SSC
1872 case VOS_MQ_ID_WDI:
1873 {
1874 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
1875 break;
1876 }
1877#endif
1878
1879 /// Message Queue ID for messages bound for the SYS module
1880 case VOS_MQ_ID_SYS:
1881 {
1882 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
1883 break;
1884 }
1885
1886 default:
1887
1888 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1889 "Trying to queue msg into unknown Tx Msg queue ID %d",
1890 __func__, msgQueueId);
1891
1892 return VOS_STATUS_E_FAILURE;
1893 }
1894
1895 if (pTargetMq == NULL)
1896 {
1897 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1898 "%s: pTargetMq == NULL", __FUNCTION__);
1899 return VOS_STATUS_E_FAILURE;
1900 }
1901
1902
1903 /*
1904 ** Try and get a free Msg wrapper
1905 */
1906 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1907
1908 if (NULL == pMsgWrapper)
1909 {
1910 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1911 "%s: VOS Core run out of message wrapper", __func__);
1912
1913 return VOS_STATUS_E_RESOURCES;
1914 }
1915
1916 /*
1917 ** Copy the message now
1918 */
1919 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1920 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1921
1922 vos_mq_put(pTargetMq, pMsgWrapper);
1923
1924 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
1925 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
1926
1927 return VOS_STATUS_SUCCESS;
1928
1929} /* vos_tx_mq_serialize()*/
1930
1931#ifdef FEATURE_WLAN_INTEGRATED_SOC
1932/**---------------------------------------------------------------------------
1933
1934 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
1935
1936 This API allows messages to be posted to a specific message queue in the
1937 Tx excution flow. Messages for the Rx execution flow can be posted only
1938 to the following queue.
1939
1940 <ul>
1941 <li> TL
1942 <li> WDI
1943 </ul>
1944
1945 \param msgQueueId - identifies the message queue upon which the message
1946 will be posted.
1947
1948 \param message - a pointer to a message buffer. Body memory for this message
1949 buffer is allocated by the caller and free'd by the vOSS after the
1950 message is dispacthed to the appropriate component. If the consumer
1951 of the message needs to keep anything in the body, it needs to copy
1952 the contents before returning from the message handler.
1953
1954 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1955 to the message queue.
1956
1957 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1958 refer to a valid Message Queue Id.
1959
1960 VOS_STATUS_E_FAULT - message is an invalid pointer.
1961
1962 VOS_STATUS_E_FAILURE - the message queue handler has reported
1963 an unknown failure.
1964
1965 \sa
1966
1967 --------------------------------------------------------------------------*/
1968
1969VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1970{
1971 pVosMqType pTargetMq = NULL;
1972 pVosMsgWrapper pMsgWrapper = NULL;
1973 if ((gpVosContext == NULL) || (pMsg == NULL))
1974 {
1975 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1976 "%s: Null params or global vos context is null", __func__);
1977 VOS_ASSERT(0);
1978 return VOS_STATUS_E_FAILURE;
1979 }
1980
1981 switch (msgQueueId)
1982 {
1983
1984 case VOS_MQ_ID_SYS:
1985 {
1986 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
1987 break;
1988 }
1989
1990 /// Message Queue ID for messages bound for WDI
1991 case VOS_MQ_ID_WDI:
1992 {
1993 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
1994 break;
1995 }
1996
1997 default:
1998
1999 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2000 "Trying to queue msg into unknown Rx Msg queue ID %d",
2001 __func__, msgQueueId);
2002
2003 return VOS_STATUS_E_FAILURE;
2004 }
2005
2006 if (pTargetMq == NULL)
2007 {
2008 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2009 "%s: pTargetMq == NULL", __FUNCTION__);
2010 return VOS_STATUS_E_FAILURE;
2011 }
2012
2013
2014 /*
2015 ** Try and get a free Msg wrapper
2016 */
2017 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2018
2019 if (NULL == pMsgWrapper)
2020 {
2021 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2022 "%s: VOS Core run out of message wrapper", __func__);
2023
2024 return VOS_STATUS_E_RESOURCES;
2025 }
2026
2027 /*
2028 ** Copy the message now
2029 */
2030 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2031 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2032
2033 vos_mq_put(pTargetMq, pMsgWrapper);
2034
2035 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
2036 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
2037
2038 return VOS_STATUS_SUCCESS;
2039
2040} /* vos_rx_mq_serialize()*/
2041
2042#endif
2043v_VOID_t
2044vos_sys_probe_thread_cback
2045(
2046 v_VOID_t *pUserData
2047)
2048{
2049 if (gpVosContext != pUserData)
2050 {
2051 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2052 "%s: gpVosContext != pUserData", __FUNCTION__);
2053 return;
2054 }
2055
2056 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2057 {
2058 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2059 "%s: vos_event_set failed", __FUNCTION__);
2060 return;
2061 }
2062
2063} /* vos_sys_probe_thread_cback() */
2064
2065#ifndef FEATURE_WLAN_INTEGRATED_SOC
2066v_VOID_t vos_sys_start_complete_cback
2067(
2068 v_VOID_t *pUserData
2069)
2070{
2071
2072 if (gpVosContext != pUserData)
2073 {
2074 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2075 "%s: gpVosContext != pUserData", __FUNCTION__);
2076 return;
2077 }
2078
2079 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2080 {
2081 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2082 "%s: vos_event_set failed", __FUNCTION__);
2083 return;
2084 }
2085
2086} /* vos_sys_start_complete_cback() */
2087#else
2088v_VOID_t vos_WDAComplete_cback
2089(
2090 v_VOID_t *pUserData
2091)
2092{
2093
2094 if (gpVosContext != pUserData)
2095 {
2096 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2097 "%s: gpVosContext != pUserData", __FUNCTION__);
2098 return;
2099 }
2100
2101 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
2102 {
2103 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2104 "%s: vos_event_set failed", __FUNCTION__);
2105 return;
2106 }
2107
2108} /* vos_WDAComplete_cback() */
2109#endif
2110
2111v_VOID_t vos_core_return_msg
2112(
2113 v_PVOID_t pVContext,
2114 pVosMsgWrapper pMsgWrapper
2115)
2116{
2117 pVosContextType pVosContext = (pVosContextType) pVContext;
2118
2119 VOS_ASSERT( gpVosContext == pVosContext);
2120
2121 if (gpVosContext != pVosContext)
2122 {
2123 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2124 "%s: gpVosContext != pVosContext", __FUNCTION__);
2125 return;
2126 }
2127
2128 VOS_ASSERT( NULL !=pMsgWrapper );
2129
2130 if (pMsgWrapper == NULL)
2131 {
2132 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2133 "%s: pMsgWrapper == NULL in function", __FUNCTION__);
2134 return;
2135 }
2136
2137 /*
2138 ** Return the message on the free message queue
2139 */
2140 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
2141 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
2142
2143} /* vos_core_return_msg() */
2144
2145
2146/**
2147 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
2148 TL config params from the registry
2149
2150 @param pAdapter : [inout] pointer to TL config block
2151
2152 @return
2153 None
2154
2155*/
2156v_VOID_t
2157vos_fetch_tl_cfg_parms
2158(
2159 WLANTL_ConfigInfoType *pTLConfig,
2160 hdd_config_t * pConfig
2161)
2162{
2163 if (pTLConfig == NULL)
2164 {
2165 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __FUNCTION__);
2166 return;
2167 }
2168
2169 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
2170 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
2171 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
2172 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
2173 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
2174#ifdef WLAN_SOFTAP_FEATURE
2175 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
2176#endif
2177
2178}
2179
2180v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
2181{
2182 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
2183}
2184
2185void vos_abort_mac_scan(void)
2186{
2187 hdd_context_t *pHddCtx = NULL;
2188 v_CONTEXT_t pVosContext = NULL;
2189
2190 /* Get the Global VOSS Context */
2191 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2192 if(!pVosContext) {
2193 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2194 return;
2195 }
2196
2197 /* Get the HDD context */
2198 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2199 if(!pHddCtx) {
2200 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2201 return;
2202 }
2203
2204 hdd_abort_mac_scan(pHddCtx);
2205 return;
2206}
2207
2208/*---------------------------------------------------------------------------
2209
2210 \brief vos_shutdown() - shutdown VOS
2211
2212 - All VOS submodules are closed.
2213
2214 - All the WLAN SW components should have been opened. This includes
2215 SYS, MAC, SME and TL.
2216
2217
2218 \param vosContext: Global vos context
2219
2220
2221 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
2222
2223 VOS_STATUS_E_FAILURE - Failure to close
2224
2225---------------------------------------------------------------------------*/
2226VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2227{
2228 VOS_STATUS vosStatus;
2229
2230#ifdef WLAN_BTAMP_FEATURE
2231 vosStatus = WLANBAP_Close(vosContext);
2232 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2233 {
2234 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2235 "%s: Failed to close BAP", __func__);
2236 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2237 }
2238#endif // WLAN_BTAMP_FEATURE
2239
2240 vosStatus = WLANTL_Close(vosContext);
2241 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2242 {
2243 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2244 "%s: Failed to close TL", __func__);
2245 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2246 }
2247
2248 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2249 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2250 {
2251 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2252 "%s: Failed to close SME", __func__);
2253 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2254 }
2255
2256 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2257 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2258 {
2259 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2260 "%s: Failed to close MAC", __func__);
2261 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2262 }
2263
2264 ((pVosContextType)vosContext)->pMACContext = NULL;
2265
2266 vosStatus = vos_nv_close();
2267 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2268 {
2269 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2270 "%s: Failed to close NV", __func__);
2271 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2272 }
2273
2274 vosStatus = sysClose( vosContext );
2275 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2276 {
2277 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2278 "%s: Failed to close SYS", __func__);
2279 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2280 }
2281
2282 /* Let DXE return packets in WDA_close and then free them here */
2283 vosStatus = vos_packet_close( vosContext );
2284 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2285 {
2286 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2287 "%s: Failed to close VOSS Packet", __func__);
2288 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2289 }
2290
2291 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2292
2293 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2294 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2295 {
2296 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2297 "%s: failed to destroy wdaCompleteEvent", __func__);
2298 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2299 }
2300
2301 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2302 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2303 {
2304 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2305 "%s: failed to destroy ProbeEvent", __func__);
2306 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2307 }
2308
2309 return VOS_STATUS_SUCCESS;
2310}
2311
2312/*---------------------------------------------------------------------------
2313
2314 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2315
2316 - WDA/WDI shutdown
2317
2318 \param vosContext: Global vos context
2319
2320
2321 \return VOS_STATUS_SUCCESS - Operation successfull
2322
2323 VOS_STATUS_E_FAILURE - Failure to close
2324
2325---------------------------------------------------------------------------*/
2326VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2327{
2328 VOS_STATUS vosStatus;
2329 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2330
2331 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2332 {
2333 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2334 "%s: failed to shutdown WDA", __func__);
2335 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2336 }
2337 return vosStatus;
2338}
2339/**
2340 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2341
2342 This function is called when Riva subsystem crashes. There are two
2343 methods (or operations) in WLAN driver to handle Riva crash,
2344 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2345 driver without handshaking with Riva.
2346 2. re-init: Next API
2347 @param
2348 NONE
2349 @return
2350 VOS_STATUS_SUCCESS - Operation completed successfully.
2351 VOS_STATUS_E_FAILURE - Operation failed.
2352
2353*/
2354VOS_STATUS vos_wlanShutdown(void)
2355{
2356 VOS_STATUS vstatus;
2357 vstatus = vos_watchdog_wlan_shutdown();
2358 return vstatus;
2359}
2360/**
2361 @brief vos_wlanReInit() - This API will re-init WLAN driver
2362
2363 This function is called when Riva subsystem reboots. There are two
2364 methods (or operations) in WLAN driver to handle Riva crash,
2365 1. shutdown: Previous API
2366 2. re-init: Called when Riva comes back after the crash. This will
2367 re-initialize WLAN driver. In some cases re-open may be
2368 referred instead of re-init.
2369 @param
2370 NONE
2371 @return
2372 VOS_STATUS_SUCCESS - Operation completed successfully.
2373 VOS_STATUS_E_FAILURE - Operation failed.
2374
2375*/
2376VOS_STATUS vos_wlanReInit(void)
2377{
2378 VOS_STATUS vstatus;
2379 vstatus = vos_watchdog_wlan_re_init();
2380 return vstatus;
2381}
Jeff Johnsone7245742012-09-05 17:12:55 -07002382/**
2383 @brief vos_wlanRestart() - This API will reload WLAN driver.
2384
2385 This function is called if driver detects any fatal state which
2386 can be recovered by a WLAN module reload ( Android framwork initiated ).
2387 Note that this API will not initiate any RIVA subsystem restart.
2388
2389 The function wlan_hdd_restart_driver protects against re-entrant calls.
2390
2391 @param
2392 NONE
2393 @return
2394 VOS_STATUS_SUCCESS - Operation completed successfully.
2395 VOS_STATUS_E_FAILURE - Operation failed.
2396 VOS_STATUS_E_EMPTY - No configured interface
2397 VOS_STATUS_E_ALREADY - Request already in progress
2398
2399
2400*/
2401VOS_STATUS vos_wlanRestart(void)
2402{
2403 VOS_STATUS vstatus;
2404 hdd_context_t *pHddCtx = NULL;
2405 v_CONTEXT_t pVosContext = NULL;
2406
2407 /* Check whether driver load unload is in progress */
2408 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2409 {
2410 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2411 "%s: Driver load/unload is in progress, retry later.", __func__);
2412 return VOS_STATUS_E_AGAIN;
2413 }
2414
2415 /* Get the Global VOSS Context */
2416 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2417 if(!pVosContext) {
2418 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2419 "%s: Global VOS context is Null", __func__);
2420 return VOS_STATUS_E_FAILURE;
2421 }
2422
2423 /* Get the HDD context */
2424 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2425 if(!pHddCtx) {
2426 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2427 "%s: HDD context is Null", __func__);
2428 return VOS_STATUS_E_FAILURE;
2429 }
2430
2431 /* Reload the driver */
2432 vstatus = wlan_hdd_restart_driver(pHddCtx);
2433 return vstatus;
2434}