blob: 7048a05590e0e5ed4d7c881e0280d291c3afac3b [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>
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -070075#include "wlan_hdd_cfg80211.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076
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 }
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700460#ifdef CONFIG_CFG80211
461/* call crda before sme_Open which will read NV and store the default country code */
462 wlan_hdd_get_crda_regd_entry(
463 ((hdd_context_t*)(gpVosContext->pHDDContext))->wiphy,
464 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
465#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700466
467 /* Now proceed to open the SME */
468 vStatus = sme_Open(gpVosContext->pMACContext);
469 if (!VOS_IS_STATUS_SUCCESS(vStatus))
470 {
471 /* Critical Error ... Cannot proceed further */
472 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
473 "%s: Failed to open SME", __func__);
474 VOS_ASSERT(0);
475 goto err_mac_close;
476 }
477
478 /* Now proceed to open TL. Read TL config first */
479 vos_fetch_tl_cfg_parms ( &TLConfig,
480 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
481
482 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
483 if (!VOS_IS_STATUS_SUCCESS(vStatus))
484 {
485 /* Critical Error ... Cannot proceed further */
486 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
487 "%s: Failed to open TL", __func__);
488 VOS_ASSERT(0);
489 goto err_sme_close;
490 }
491
492 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
493 "%s: VOSS successfully Opened", __func__);
494
495 *pVosContext = gpVosContext;
496
497 return VOS_STATUS_SUCCESS;
498
499
500err_sme_close:
501 sme_Close(gpVosContext->pMACContext);
502
503err_mac_close:
504 macClose(gpVosContext->pMACContext);
505
506err_nv_close:
507 vos_nv_close();
508
509err_sys_close:
510 sysClose(gpVosContext);
511
512#ifdef FEATURE_WLAN_INTEGRATED_SOC
513err_packet_close:
514 vos_packet_close( gpVosContext );
515
516err_wda_close:
517 WDA_close(gpVosContext);
518#endif
519
520err_sched_close:
521 vos_sched_close(gpVosContext);
522
523#ifndef FEATURE_WLAN_INTEGRATED_SOC
524err_packet_close:
525 vos_packet_close( gpVosContext );
526#endif
527
528err_msg_queue:
529 vos_mq_deinit(&gpVosContext->freeVosMq);
530
531#ifdef FEATURE_WLAN_INTEGRATED_SOC
532err_wda_complete_event:
533 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
534#endif
535
536err_probe_event:
537 vos_event_destroy(&gpVosContext->ProbeEvent);
538
539 return VOS_STATUS_E_FAILURE;
540
541} /* vos_open() */
542
543#ifdef FEATURE_WLAN_INTEGRATED_SOC
544/*---------------------------------------------------------------------------
545
546 \brief vos_preStart() -
547
548 The \a vos_preStart() function to download CFG.
549 including:
550 - ccmStart
551
552 - WDA: triggers the CFG download
553
554
555 \param pVosContext: The VOS context
556
557
558 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
559 is ready to be used.
560
561 VOS_STATUS_E_RESOURCES - System resources (other than memory)
562 are unavailable to initilize the scheduler
563
564
565 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
566
567 \sa vos_start
568
569---------------------------------------------------------------------------*/
570VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
571{
572 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
573 pVosContextType pVosContext = (pVosContextType)vosContext;
574
575 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
576 "vos prestart");
577
578 VOS_ASSERT(gpVosContext == pVosContext);
579
580 VOS_ASSERT( NULL != pVosContext->pMACContext);
581
582 VOS_ASSERT( NULL != pVosContext->pWDAContext);
583
584 /* call macPreStart */
585 vStatus = macPreStart(gpVosContext->pMACContext);
586 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
587 {
588 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
589 "Failed at macPreStart ");
590 return VOS_STATUS_E_FAILURE;
591 }
592
593 /* call ccmStart */
594 ccmStart(gpVosContext->pMACContext);
595
596 /* Reset wda wait event */
597 vos_event_reset(&gpVosContext->wdaCompleteEvent);
598
599
600 /*call WDA pre start*/
601 vStatus = WDA_preStart(gpVosContext);
602 if (!VOS_IS_STATUS_SUCCESS(vStatus))
603 {
604 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
605 "Failed to WDA prestart");
606 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
607 ccmStop(gpVosContext->pMACContext);
608 VOS_ASSERT(0);
609 return VOS_STATUS_E_FAILURE;
610 }
611
612 /* Need to update time out of complete */
613 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
614 VOS_WDA_TIMEOUT );
615 if ( vStatus != VOS_STATUS_SUCCESS )
616 {
617 if ( vStatus == VOS_STATUS_E_TIMEOUT )
618 {
619 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
620 "%s: Timeout occurred before WDA complete\n", __func__);
621 }
622 else
623 {
624 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
625 "%s: WDA_preStart reporting other error", __func__);
626 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700627 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
628 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 VOS_ASSERT( 0 );
630 return VOS_STATUS_E_FAILURE;
631 }
632
633 return VOS_STATUS_SUCCESS;
634}
635#endif
636
637/*---------------------------------------------------------------------------
638
639 \brief vos_start() - Start the Libra SW Modules
640
641 The \a vos_start() function starts all the components of the Libra SW
642 including:
643 - SAL/BAL, which in turn starts SSC
644
645 - the MAC (HAL and PE)
646
647 - SME
648
649 - TL
650
651 - SYS: triggers the CFG download
652
653
654 \param pVosContext: The VOS context
655
656
657 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
658 is ready to be used.
659
660 VOS_STATUS_E_RESOURCES - System resources (other than memory)
661 are unavailable to initilize the scheduler
662
663
664 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
665
666 \sa vos_preStart()
667 \sa vos_open()
668
669---------------------------------------------------------------------------*/
670VOS_STATUS vos_start( v_CONTEXT_t vosContext )
671{
672 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
673 tSirRetStatus sirStatus = eSIR_SUCCESS;
674 pVosContextType pVosContext = (pVosContextType)vosContext;
675 tHalMacStartParameters halStartParams;
676#ifndef FEATURE_WLAN_INTEGRATED_SOC
677 v_VOID_t *pFwBinary = NULL;
678 v_SIZE_t numFwBytes = 0;
679#endif
680
681 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
682 "%s: Starting Libra SW", __func__);
683
684 /* We support only one instance for now ...*/
685 if (gpVosContext != pVosContext)
686 {
687 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
688 "%s: mismatch in context", __FUNCTION__);
689 return VOS_STATUS_E_FAILURE;
690 }
691
692#ifndef FEATURE_WLAN_INTEGRATED_SOC
693 if (( pVosContext->pBALContext == NULL) || ( pVosContext->pMACContext == NULL)
694 || ( pVosContext->pTLContext == NULL))
695 {
696 if (pVosContext->pBALContext == NULL)
697 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
698 "%s: BAL NULL context", __FUNCTION__);
699 else if (pVosContext->pMACContext == NULL)
700 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
701 "%s: MAC NULL context", __FUNCTION__);
702 else
703 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
704 "%s: TL NULL context", __FUNCTION__);
705
706 return VOS_STATUS_E_FAILURE;
707 }
708#else
709 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
710 || ( pVosContext->pTLContext == NULL))
711 {
712 if (pVosContext->pWDAContext == NULL)
713 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
714 "%s: WDA NULL context", __FUNCTION__);
715 else if (pVosContext->pMACContext == NULL)
716 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
717 "%s: MAC NULL context", __FUNCTION__);
718 else
719 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
720 "%s: TL NULL context", __FUNCTION__);
721
722 return VOS_STATUS_E_FAILURE;
723 }
724
725 /* WDA_Start will be called after NV image download because the
726 NV image data has to be updated at HAL before HAL_Start gets executed*/
727
728 /* Start the NV Image Download */
729
730 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
731
732 vStatus = WDA_NVDownload_Start(pVosContext);
733
734 if ( vStatus != VOS_STATUS_SUCCESS )
735 {
736 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
737 "%s: Failed to start NV Download", __func__);
738 return VOS_STATUS_E_FAILURE;
739 }
740
741 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
742 VOS_WDA_TIMEOUT );
743
744 if ( vStatus != VOS_STATUS_SUCCESS )
745 {
746 if ( vStatus == VOS_STATUS_E_TIMEOUT )
747 {
748 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
749 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
750 }
751 else
752 {
753 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
754 "%s: WDA_NVDownload_start reporting other error", __func__);
755 }
756 VOS_ASSERT(0);
757 goto err_wda_stop;
758 }
759
760 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
761 "%s: WDA_NVDownload_start correctly started", __func__);
762
763 /* Start the WDA */
764 vStatus = WDA_start(pVosContext);
765 if ( vStatus != VOS_STATUS_SUCCESS )
766 {
767 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
768 "%s: Failed to start WDA", __func__);
769 return VOS_STATUS_E_FAILURE;
770 }
771 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
772 "%s: WDA correctly started", __func__);
773
774#endif
775 /* Start the MAC */
776 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
777
778#ifndef FEATURE_WLAN_INTEGRATED_SOC
779 /* Attempt to get the firmware binary through VOS. We need to pass this
780 to the MAC when starting. */
781 vStatus = vos_get_fwbinary(&pFwBinary, &numFwBytes);
782
783 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
784 {
785 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
786 "%s: Failed to get firmware binary", __func__);
787 return VOS_STATUS_E_FAILURE;
788 }
789
790 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
791 "%s: Firmware binary file found", __func__);
792
793
794 //Begining kernel 2.6.31, memory buffer returned by request_firmware API
795 //cannot be overwritten. So need to copy the firmware into a separate buffer
796 //as HAL needs to modify the endianess of FW binary.
797
798 //Kernel may not have ~40 pages of free buffers always, so
799 //Store the pointer to the buffer provided by kernel for now,
800 //When required copy it to local buffer for translation.
801 //This is done in vos_api.c, during firmware download
802 //This would provide common fix for ftm driver issue aswell,
803 //which is not creating the copy of firmware image for endian conversion.
804 halStartParams.FW.cbImage = numFwBytes;
805 halStartParams.FW.pImage = pFwBinary;
806
807 //determine the driverType for the mode of operation
808 halStartParams.driverType = eDRIVER_TYPE_PRODUCTION;
809#endif
810 /* Start the MAC */
811 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
812
813#ifndef FEATURE_WLAN_INTEGRATED_SOC
814 hdd_release_firmware(WLAN_FW_FILE, pVosContext->pHDDContext);
815
816 halStartParams.FW.pImage = NULL;
817 halStartParams.FW.cbImage = 0;
818#endif
819 if (eSIR_SUCCESS != sirStatus)
820 {
821 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
822 "%s: Failed to start MAC", __func__);
823#ifndef FEATURE_WLAN_INTEGRATED_SOC
824 return VOS_STATUS_E_FAILURE;
825#else
826 goto err_wda_stop;
827#endif
828 }
829
830 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
831 "%s: MAC correctly started", __func__);
832
833 /* START SME */
834 vStatus = sme_Start(pVosContext->pMACContext);
835
836 if (!VOS_IS_STATUS_SUCCESS(vStatus))
837 {
838 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
839 "%s: Failed to start SME", __func__);
840 goto err_mac_stop;
841 }
842
843 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
844 "%s: SME correctly started", __func__);
845
846 /** START TL */
847 vStatus = WLANTL_Start(pVosContext);
848 if (!VOS_IS_STATUS_SUCCESS(vStatus))
849 {
850 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
851 "%s: Failed to start TL", __func__);
852 goto err_sme_stop;
853 }
854
855 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
856 "TL correctly started");
857#ifndef FEATURE_WLAN_INTEGRATED_SOC
858 /* START SYS. This will trigger the CFG download */
859 sysMcStart(pVosContext, vos_sys_start_complete_cback, pVosContext);
860
861 if (vos_wait_single_event(&gpVosContext->ProbeEvent, 0)!= VOS_STATUS_SUCCESS)
862 {
863 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
864 "%s: Failed to start SYS module", __func__);
865 goto err_tl_stop;
866 }
867
868
869 /**
870 EVM issue is observed with 1.6Mhz freq for 1.3V RF supply in wlan standalone case.
871 During concurrent operation (e.g. WLAN and WCDMA) this issue is not observed.
872 To workaround, wlan will vote for 3.2Mhz during startup and will vote for 1.6Mhz
873 during exit.
874 Since using 3.2Mhz has a side effect on power (extra 200ua), this is left configurable.
875 If customers do their design right, they should not see the EVM issue and in that case they
876 can decide to keep 1.6Mhz by setting an NV.
877 If NV item is not present, use the default 3.2Mhz
878 vos_stop is also invoked if wlan startup seq fails (after vos_start, where 3.2Mhz is voted.)
879 */
880 {
881 sFreqFor1p3VSupply freq;
882 vStatus = vos_nv_read( NV_TABLE_FREQUENCY_FOR_1_3V_SUPPLY, &freq, NULL,
883 sizeof(freq) );
884 if (VOS_STATUS_SUCCESS != vStatus)
885 freq.freqFor1p3VSupply = VOS_NV_FREQUENCY_FOR_1_3V_SUPPLY_3P2MH;
886
887 if (vos_chipVoteFreqFor1p3VSupply(NULL, NULL, NULL, freq.freqFor1p3VSupply) != VOS_STATUS_SUCCESS)
888 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
889 "%s: Failed to set the freq %d for 1.3V Supply",
890 __func__, freq.freqFor1p3VSupply );
891 }
892
893#endif
894 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
895 "%s: VOSS Start is successful!!", __func__);
896
897 return VOS_STATUS_SUCCESS;
898
899#ifndef FEATURE_WLAN_INTEGRATED_SOC
900err_tl_stop:
901 WLANTL_Stop(pVosContext);
902#endif
903
904err_sme_stop:
905 sme_Stop(pVosContext->pMACContext, TRUE);
906
907err_mac_stop:
908 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
909
910#ifdef FEATURE_WLAN_INTEGRATED_SOC
911err_wda_stop:
912 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
913 WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
914 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
915 VOS_WDA_TIMEOUT );
916 if( vStatus != VOS_STATUS_SUCCESS )
917 {
918 if( vStatus == VOS_STATUS_E_TIMEOUT )
919 {
920 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
921 "%s: Timeout occurred before WDA_stop complete", __func__);
922
923 }
924 else
925 {
926 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
927 "%s: WDA_stop reporting other error", __func__);
928 }
929 VOS_ASSERT( 0 );
930 }
931#endif
932
933 return VOS_STATUS_E_FAILURE;
934
935} /* vos_start() */
936
937
938/* vos_stop function */
939VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
940{
941 VOS_STATUS vosStatus;
942
943#ifdef FEATURE_WLAN_INTEGRATED_SOC
944 /* WDA_Stop is called before the SYS so that the processing of Riva
945 pending responces will not be handled during uninitialization of WLAN driver */
946 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
947
948 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
949
950 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
951 {
952 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
953 "%s: Failed to stop WDA", __func__);
954 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
955 }
956
957 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
958 VOS_WDA_STOP_TIMEOUT );
959
960 if ( vosStatus != VOS_STATUS_SUCCESS )
961 {
962 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
963 {
964 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
965 "%s: Timeout occurred before WDA complete", __func__);
966 }
967 else
968 {
969 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
970 "%s: WDA_stop reporting other error", __func__ );
971 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700972 WDA_stopFailed(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 }
974#endif
975
976 /* SYS STOP will stop SME and MAC */
977 vosStatus = sysStop( vosContext);
978 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
979 {
980 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
981 "%s: Failed to stop SYS", __func__);
982 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
983 }
984
985 vosStatus = WLANTL_Stop( vosContext );
986 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
987 {
988 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
989 "%s: Failed to stop TL", __func__);
990 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
991 }
992
993#ifndef FEATURE_WLAN_INTEGRATED_SOC
994 /**
995 EVM issue is observed with 1.6Mhz freq for 1.3V supply in wlan standalone case.
996 During concurrent operation (e.g. WLAN and WCDMA) this issue is not observed.
997 To workaround, wlan will vote for 3.2Mhz during startup and will vote for 1.6Mhz
998 during exit.
999 vos_stop is also invoked if wlan startup seq fails (after vos_start, where 3.2Mhz is voted.)
1000 */
1001 if (vos_chipVoteFreqFor1p3VSupply(NULL, NULL, NULL, VOS_NV_FREQUENCY_FOR_1_3V_SUPPLY_1P6MH) != VOS_STATUS_SUCCESS)
1002 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1003 "%s: Failed to set the freq to 1.6Mhz for 1.3V Supply", __func__ );
1004#endif
1005
1006 return VOS_STATUS_SUCCESS;
1007}
1008
1009
1010/* vos_close function */
1011VOS_STATUS vos_close( v_CONTEXT_t vosContext )
1012{
1013 VOS_STATUS vosStatus;
1014
1015#ifdef WLAN_BTAMP_FEATURE
1016 vosStatus = WLANBAP_Close(vosContext);
1017 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1018 {
1019 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1020 "%s: Failed to close BAP", __func__);
1021 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1022 }
1023#endif // WLAN_BTAMP_FEATURE
1024
1025
1026 vosStatus = WLANTL_Close(vosContext);
1027 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1028 {
1029 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1030 "%s: Failed to close TL", __func__);
1031 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1032 }
1033
1034 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1035 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1036 {
1037 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1038 "%s: Failed to close SME", __func__);
1039 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1040 }
1041
1042 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1043 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1044 {
1045 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1046 "%s: Failed to close MAC", __func__);
1047 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1048 }
1049
1050 ((pVosContextType)vosContext)->pMACContext = NULL;
1051
1052 vosStatus = vos_nv_close();
1053 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1054 {
1055 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1056 "%s: Failed to close NV", __func__);
1057 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1058 }
1059
1060
1061 vosStatus = sysClose( vosContext );
1062 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1063 {
1064 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1065 "%s: Failed to close SYS", __func__);
1066 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1067 }
1068
1069#ifdef FEATURE_WLAN_INTEGRATED_SOC
Jeff Johnsone7245742012-09-05 17:12:55 -07001070 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001072 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
1073 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
1074 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
1075 {
1076 hdd_set_ssr_required( VOS_TRUE );
1077 }
1078 else
1079 {
1080 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1081 "%s: Failed to shutdown WDA", __func__ );
1082 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1083 }
1084 }
1085 else
1086 {
1087 vosStatus = WDA_close( vosContext );
1088 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1089 {
1090 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1091 "%s: Failed to close WDA", __func__);
1092 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 }
1095
1096 /* Let DXE return packets in WDA_close and then free them here */
1097 vosStatus = vos_packet_close( vosContext );
1098 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1099 {
1100 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1101 "%s: Failed to close VOSS Packet", __func__);
1102 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1103 }
1104#endif
1105
1106#ifndef FEATURE_WLAN_INTEGRATED_SOC
1107 vosStatus = vos_packet_close( vosContext );
1108 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1109 {
1110 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1111 "%s: Failed to close VOSS Packet", __func__);
1112 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1113 }
1114#endif
1115
1116 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1117
1118#ifdef FEATURE_WLAN_INTEGRATED_SOC
1119 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1120 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1121 {
1122 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1123 "%s: failed to destroy wdaCompleteEvent", __func__);
1124 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1125 }
1126#endif
1127
1128 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1129 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1130 {
1131 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1132 "%s: failed to destroy ProbeEvent", __func__);
1133 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1134 }
1135
1136 return VOS_STATUS_SUCCESS;
1137}
1138
1139
1140/**---------------------------------------------------------------------------
1141
1142 \brief vos_get_context() - get context data area
1143
1144 Each module in the system has a context / data area that is allocated
1145 and maanged by voss. This API allows any user to get a pointer to its
1146 allocated context data area from the VOSS global context.
1147
1148 \param vosContext - the VOSS Global Context.
1149
1150 \param moduleId - the module ID, who's context data are is being retrived.
1151
1152 \return - pointer to the context data area.
1153
1154 - NULL if the context data is not allocated for the module ID
1155 specified
1156
1157 --------------------------------------------------------------------------*/
1158v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1159 v_CONTEXT_t pVosContext )
1160{
1161 v_PVOID_t pModContext = NULL;
1162
1163 if (pVosContext == NULL)
1164 {
1165 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1166 "%s: vos context pointer is null", __FUNCTION__);
1167 return NULL;
1168 }
1169
1170 if (gpVosContext != pVosContext)
1171 {
1172 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1173 "%s: pVosContext != gpVosContext", __FUNCTION__);
1174 return NULL;
1175 }
1176
1177 switch(moduleId)
1178 {
1179 case VOS_MODULE_ID_TL:
1180 {
1181 pModContext = gpVosContext->pTLContext;
1182 break;
1183 }
1184
1185#ifndef FEATURE_WLAN_INTEGRATED_SOC
1186 case VOS_MODULE_ID_BAL:
1187 {
1188 pModContext = gpVosContext->pBALContext;
1189 break;
1190 }
1191
1192 case VOS_MODULE_ID_SAL:
1193 {
1194 pModContext = gpVosContext->pSALContext;
1195 break;
1196 }
1197
1198 case VOS_MODULE_ID_SSC:
1199 {
1200 pModContext = gpVosContext->pSSCContext;
1201 break;
1202 }
1203#endif
1204#ifdef WLAN_BTAMP_FEATURE
1205 case VOS_MODULE_ID_BAP:
1206 {
1207 pModContext = gpVosContext->pBAPContext;
1208 break;
1209 }
1210#endif //WLAN_BTAMP_FEATURE
1211
1212#ifdef WLAN_SOFTAP_FEATURE
1213 case VOS_MODULE_ID_SAP:
1214 {
1215 pModContext = gpVosContext->pSAPContext;
1216 break;
1217 }
1218
1219 case VOS_MODULE_ID_HDD_SOFTAP:
1220 {
1221 pModContext = gpVosContext->pHDDSoftAPContext;
1222 break;
1223 }
1224#endif
1225
1226 case VOS_MODULE_ID_HDD:
1227 {
1228 pModContext = gpVosContext->pHDDContext;
1229 break;
1230 }
1231
1232 case VOS_MODULE_ID_SME:
1233#ifndef FEATURE_WLAN_INTEGRATED_SOC
1234 case VOS_MODULE_ID_HAL:
1235#endif
1236 case VOS_MODULE_ID_PE:
1237 {
1238 /*
1239 ** In all these cases, we just return the MAC Context
1240 */
1241 pModContext = gpVosContext->pMACContext;
1242 break;
1243 }
1244
1245#ifdef FEATURE_WLAN_INTEGRATED_SOC
1246 case VOS_MODULE_ID_WDA:
1247 {
1248 /* For WDA module */
1249 pModContext = gpVosContext->pWDAContext;
1250 break;
1251 }
1252#endif
1253
1254 case VOS_MODULE_ID_VOSS:
1255 {
1256 /* For SYS this is VOS itself*/
1257 pModContext = gpVosContext;
1258 break;
1259 }
1260
1261 default:
1262 {
1263 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1264 "does not have its context maintained by VOSS", __func__, moduleId);
1265 VOS_ASSERT(0);
1266 return NULL;
1267 }
1268 }
1269
1270 if (pModContext == NULL )
1271 {
1272 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1273 "context is Null", __func__, moduleId);
1274 }
1275
1276 return pModContext;
1277
1278} /* vos_get_context()*/
1279
1280
1281/**---------------------------------------------------------------------------
1282
1283 \brief vos_get_global_context() - get VOSS global Context
1284
1285 This API allows any user to get the VOS Global Context pointer from a
1286 module context data area.
1287
1288 \param moduleContext - the input module context pointer
1289
1290 \param moduleId - the module ID who's context pointer is input in
1291 moduleContext.
1292
1293 \return - pointer to the VOSS global context
1294
1295 - NULL if the function is unable to retreive the VOSS context.
1296
1297 --------------------------------------------------------------------------*/
1298v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1299 v_VOID_t *moduleContext )
1300{
1301 if (gpVosContext == NULL)
1302 {
1303 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1304 "%s: global voss context is NULL", __FUNCTION__);
1305 }
1306
1307 return gpVosContext;
1308
1309} /* vos_get_global_context() */
1310
1311
1312v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1313{
1314 if (gpVosContext == NULL)
1315 {
1316 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1317 "%s: global voss context is NULL", __FUNCTION__);
1318 return 1;
1319 }
1320
1321 return gpVosContext->isLogpInProgress;
1322}
1323
1324void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1325{
1326 if (gpVosContext == NULL)
1327 {
1328 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1329 "%s: global voss context is NULL", __FUNCTION__);
1330 return;
1331 }
1332
1333 gpVosContext->isLogpInProgress = value;
1334}
1335
1336v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1337{
1338 if (gpVosContext == NULL)
1339 {
1340 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1341 "%s: global voss context is NULL", __FUNCTION__);
1342 return 0;
1343 }
1344
1345 return gpVosContext->isLoadUnloadInProgress;
1346}
1347
1348void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1349{
1350 if (gpVosContext == NULL)
1351 {
1352 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1353 "%s: global voss context is NULL", __FUNCTION__);
1354 return;
1355 }
1356
1357 gpVosContext->isLoadUnloadInProgress = value;
1358}
1359
1360/**---------------------------------------------------------------------------
1361
1362 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1363
1364 This API allows any user to allocate a user context area within the
1365 VOS Global Context.
1366
1367 \param pVosContext - pointer to the global Vos context
1368
1369 \param moduleId - the module ID who's context area is being allocated.
1370
1371 \param ppModuleContext - pointer to location where the pointer to the
1372 allocated context is returned. Note this
1373 output pointer is valid only if the API
1374 returns VOS_STATUS_SUCCESS
1375
1376 \param size - the size of the context area to be allocated.
1377
1378 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1379 allocated successfully. The pointer to the context area
1380 can be found in *ppModuleContext.
1381 \note This function returns VOS_STATUS_SUCCESS if the
1382 module context was already allocated and the size
1383 allocated matches the size on this call.
1384
1385 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1386 not identify a module that can have a context allocated.
1387
1388 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1389 because a context for this module ID already exists and it is
1390 a *different* size that specified on this call.
1391
1392 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1393 requested context area.
1394
1395 \sa vos_get_context(), vos_free_context()
1396
1397 --------------------------------------------------------------------------*/
1398VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1399 v_VOID_t **ppModuleContext, v_SIZE_t size )
1400{
1401 v_VOID_t ** pGpModContext = NULL;
1402
1403 if ( pVosContext == NULL) {
1404 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1405 "%s: vos context is null", __FUNCTION__);
1406 return VOS_STATUS_E_FAILURE;
1407 }
1408
1409 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1410 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1411 "%s: context mismatch or null param passed", __FUNCTION__);
1412 return VOS_STATUS_E_FAILURE;
1413 }
1414
1415 switch(moduleID)
1416 {
1417 case VOS_MODULE_ID_TL:
1418 {
1419 pGpModContext = &(gpVosContext->pTLContext);
1420 break;
1421 }
1422
1423#ifndef FEATURE_WLAN_INTEGRATED_SOC
1424 case VOS_MODULE_ID_BAL:
1425 {
1426 pGpModContext = &(gpVosContext->pBALContext);
1427 break;
1428 }
1429
1430 case VOS_MODULE_ID_SAL:
1431 {
1432 pGpModContext = &(gpVosContext->pSALContext);
1433 break;
1434 }
1435
1436 case VOS_MODULE_ID_SSC:
1437 {
1438 pGpModContext = &(gpVosContext->pSSCContext);
1439 break;
1440 }
1441#endif
1442#ifdef WLAN_BTAMP_FEATURE
1443 case VOS_MODULE_ID_BAP:
1444 {
1445 pGpModContext = &(gpVosContext->pBAPContext);
1446 break;
1447 }
1448#endif //WLAN_BTAMP_FEATURE
1449
1450#ifdef WLAN_SOFTAP_FEATURE
1451 case VOS_MODULE_ID_SAP:
1452 {
1453 pGpModContext = &(gpVosContext->pSAPContext);
1454 break;
1455 }
1456#endif
1457
1458#ifdef FEATURE_WLAN_INTEGRATED_SOC
1459 case VOS_MODULE_ID_WDA:
1460 {
1461 pGpModContext = &(gpVosContext->pWDAContext);
1462 break;
1463 }
1464#endif
1465 case VOS_MODULE_ID_SME:
1466#ifndef FEATURE_WLAN_INTEGRATED_SOC
1467 case VOS_MODULE_ID_HAL:
1468#endif
1469 case VOS_MODULE_ID_PE:
1470 case VOS_MODULE_ID_HDD:
1471#ifdef WLAN_SOFTAP_FEATURE
1472 case VOS_MODULE_ID_HDD_SOFTAP:
1473#endif
1474 default:
1475 {
1476 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1477 "does not have its context allocated by VOSS", __func__, moduleID);
1478 VOS_ASSERT(0);
1479 return VOS_STATUS_E_INVAL;
1480 }
1481 }
1482
1483 if ( NULL != *pGpModContext)
1484 {
1485 /*
1486 ** Context has already been allocated!
1487 ** Prevent double allocation
1488 */
1489 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1490 "%s: Module ID %i context has already been allocated",
1491 __func__, moduleID);
1492 return VOS_STATUS_E_EXISTS;
1493 }
1494
1495 /*
1496 ** Dynamically allocate the context for module
1497 */
1498
1499 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1500
1501
1502 if ( *ppModuleContext == NULL)
1503 {
1504 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1505 "allocate Context for module ID %i", __func__, moduleID);
1506 VOS_ASSERT(0);
1507 return VOS_STATUS_E_NOMEM;
1508 }
1509
1510 if (moduleID==VOS_MODULE_ID_TL)
1511 {
1512 vos_mem_zero(*ppModuleContext, size);
1513 }
1514
1515 *pGpModContext = *ppModuleContext;
1516
1517 return VOS_STATUS_SUCCESS;
1518
1519} /* vos_alloc_context() */
1520
1521
1522/**---------------------------------------------------------------------------
1523
1524 \brief vos_free_context() - free an allocated a context within the
1525 VOSS global Context
1526
1527 This API allows a user to free the user context area within the
1528 VOS Global Context.
1529
1530 \param pVosContext - pointer to the global Vos context
1531
1532 \param moduleId - the module ID who's context area is being free
1533
1534 \param pModuleContext - pointer to module context area to be free'd.
1535
1536 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1537 free'd. The pointer to the context area is not longer
1538 available.
1539
1540 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1541 valid pointers.
1542
1543 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1544 not identify a module that can have a context free'd.
1545
1546 VOS_STATUS_E_EXISTS - vos could not free the requested
1547 context area because a context for this module ID does not
1548 exist in the global vos context.
1549
1550 \sa vos_get_context()
1551
1552 --------------------------------------------------------------------------*/
1553VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1554 v_VOID_t *pModuleContext )
1555{
1556 v_VOID_t ** pGpModContext = NULL;
1557
1558 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1559 ( pModuleContext == NULL))
1560 {
1561 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1562 "%s: Null params or context mismatch", __func__);
1563 return VOS_STATUS_E_FAILURE;
1564 }
1565
1566
1567 switch(moduleID)
1568 {
1569 case VOS_MODULE_ID_TL:
1570 {
1571 pGpModContext = &(gpVosContext->pTLContext);
1572 break;
1573 }
1574
1575#ifndef FEATURE_WLAN_INTEGRATED_SOC
1576 case VOS_MODULE_ID_BAL:
1577 {
1578 pGpModContext = &(gpVosContext->pBALContext);
1579 break;
1580 }
1581
1582 case VOS_MODULE_ID_SAL:
1583 {
1584 pGpModContext = &(gpVosContext->pSALContext);
1585 break;
1586 }
1587
1588 case VOS_MODULE_ID_SSC:
1589 {
1590 pGpModContext = &(gpVosContext->pSSCContext);
1591 break;
1592 }
1593#endif
1594#ifdef WLAN_BTAMP_FEATURE
1595 case VOS_MODULE_ID_BAP:
1596 {
1597 pGpModContext = &(gpVosContext->pBAPContext);
1598 break;
1599 }
1600#endif //WLAN_BTAMP_FEATURE
1601
1602#ifdef WLAN_SOFTAP_FEATURE
1603 case VOS_MODULE_ID_SAP:
1604 {
1605 pGpModContext = &(gpVosContext->pSAPContext);
1606 break;
1607 }
1608#endif
1609
1610#ifdef FEATURE_WLAN_INTEGRATED_SOC
1611 case VOS_MODULE_ID_WDA:
1612 {
1613 pGpModContext = &(gpVosContext->pWDAContext);
1614 break;
1615 }
1616#endif
1617 case VOS_MODULE_ID_HDD:
1618 case VOS_MODULE_ID_SME:
1619#ifndef FEATURE_WLAN_INTEGRATED_SOC
1620 case VOS_MODULE_ID_HAL:
1621#endif
1622 case VOS_MODULE_ID_PE:
1623#ifdef WLAN_SOFTAP_FEATURE
1624 case VOS_MODULE_ID_HDD_SOFTAP:
1625#endif
1626 default:
1627 {
1628 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1629 "does not have its context allocated by VOSS", __func__, moduleID);
1630 VOS_ASSERT(0);
1631 return VOS_STATUS_E_INVAL;
1632 }
1633 }
1634
1635 if ( NULL == *pGpModContext)
1636 {
1637 /*
1638 ** Context has not been allocated or freed already!
1639 */
1640 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1641 "context has not been allocated or freed already", __func__,moduleID);
1642 return VOS_STATUS_E_FAILURE;
1643 }
1644
1645 if (*pGpModContext != pModuleContext)
1646 {
1647 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1648 "%s: pGpModContext != pModuleContext", __FUNCTION__);
1649 return VOS_STATUS_E_FAILURE;
1650 }
1651
1652 if(pModuleContext != NULL)
1653 kfree(pModuleContext);
1654
1655 *pGpModContext = NULL;
1656
1657 return VOS_STATUS_SUCCESS;
1658
1659} /* vos_free_context() */
1660
1661
1662/**---------------------------------------------------------------------------
1663
1664 \brief vos_mq_post_message() - post a message to a message queue
1665
1666 This API allows messages to be posted to a specific message queue. Messages
1667 can be posted to the following message queues:
1668
1669 <ul>
1670 <li> SME
1671 <li> PE
1672 <li> HAL
1673 <li> TL
1674 </ul>
1675
1676 \param msgQueueId - identifies the message queue upon which the message
1677 will be posted.
1678
1679 \param message - a pointer to a message buffer. Memory for this message
1680 buffer is allocated by the caller and free'd by the vOSS after the
1681 message is posted to the message queue. If the consumer of the
1682 message needs anything in this message, it needs to copy the contents
1683 before returning from the message queue handler.
1684
1685 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1686 to the message queue.
1687
1688 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1689 refer to a valid Message Queue Id.
1690
1691 VOS_STATUS_E_FAULT - message is an invalid pointer.
1692
1693 VOS_STATUS_E_FAILURE - the message queue handler has reported
1694 an unknown failure.
1695
1696 \sa
1697
1698 --------------------------------------------------------------------------*/
1699VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1700{
1701 pVosMqType pTargetMq = NULL;
1702 pVosMsgWrapper pMsgWrapper = NULL;
1703
1704 if ((gpVosContext == NULL) || (pMsg == NULL))
1705 {
1706 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1707 "%s: Null params or global vos context is null", __func__);
1708 VOS_ASSERT(0);
1709 return VOS_STATUS_E_FAILURE;
1710 }
1711
1712 switch (msgQueueId)
1713 {
1714 /// Message Queue ID for messages bound for SME
1715 case VOS_MQ_ID_SME:
1716 {
1717 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1718 break;
1719 }
1720
1721 /// Message Queue ID for messages bound for PE
1722 case VOS_MQ_ID_PE:
1723 {
1724 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1725 break;
1726 }
1727
1728#ifndef FEATURE_WLAN_INTEGRATED_SOC
1729 /// Message Queue ID for messages bound for HAL
1730 case VOS_MQ_ID_HAL:
1731 {
1732 pTargetMq = &(gpVosContext->vosSched.halMcMq);
1733 break;
1734 }
1735#else
1736 /// Message Queue ID for messages bound for WDA
1737 case VOS_MQ_ID_WDA:
1738 {
1739 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1740 break;
1741 }
1742
1743 /// Message Queue ID for messages bound for WDI
1744 case VOS_MQ_ID_WDI:
1745 {
1746 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1747 break;
1748 }
1749#endif
1750
1751 /// Message Queue ID for messages bound for TL
1752 case VOS_MQ_ID_TL:
1753 {
1754 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1755 break;
1756 }
1757
1758 /// Message Queue ID for messages bound for the SYS module
1759 case VOS_MQ_ID_SYS:
1760 {
1761 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1762 break;
1763 }
1764
1765 default:
1766
1767 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1768 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1769 __func__, msgQueueId);
1770
1771 return VOS_STATUS_E_FAILURE;
1772 }
1773
1774 VOS_ASSERT(NULL !=pTargetMq);
1775 if (pTargetMq == NULL)
1776 {
1777 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1778 "%s: pTargetMq == NULL", __FUNCTION__);
1779 return VOS_STATUS_E_FAILURE;
1780 }
1781
1782 /*
1783 ** Try and get a free Msg wrapper
1784 */
1785 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1786
1787 if (NULL == pMsgWrapper)
1788 {
1789 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1790 "%s: VOS Core run out of message wrapper", __func__);
1791
1792 return VOS_STATUS_E_RESOURCES;
1793 }
1794
1795 /*
1796 ** Copy the message now
1797 */
1798 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1799 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1800
1801 vos_mq_put(pTargetMq, pMsgWrapper);
1802
1803 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1804 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1805
1806 return VOS_STATUS_SUCCESS;
1807
1808} /* vos_mq_post_message()*/
1809
1810
1811/**---------------------------------------------------------------------------
1812
1813 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
1814
1815 This API allows messages to be posted to a specific message queue in the
1816 Tx excution flow. Messages for the Tx execution flow can be posted only
1817 to the following queue.
1818
1819 <ul>
1820 <li> TL
1821 <li> SSC/WDI
1822 </ul>
1823
1824 \param msgQueueId - identifies the message queue upon which the message
1825 will be posted.
1826
1827 \param message - a pointer to a message buffer. Body memory for this message
1828 buffer is allocated by the caller and free'd by the vOSS after the
1829 message is dispacthed to the appropriate component. If the consumer
1830 of the message needs to keep anything in the body, it needs to copy
1831 the contents before returning from the message handler.
1832
1833 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1834 to the message queue.
1835
1836 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1837 refer to a valid Message Queue Id.
1838
1839 VOS_STATUS_E_FAULT - message is an invalid pointer.
1840
1841 VOS_STATUS_E_FAILURE - the message queue handler has reported
1842 an unknown failure.
1843
1844 \sa
1845
1846 --------------------------------------------------------------------------*/
1847VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1848{
1849 pVosMqType pTargetMq = NULL;
1850 pVosMsgWrapper pMsgWrapper = NULL;
1851
1852 if ((gpVosContext == NULL) || (pMsg == NULL))
1853 {
1854 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1855 "%s: Null params or global vos context is null", __func__);
1856 VOS_ASSERT(0);
1857 return VOS_STATUS_E_FAILURE;
1858 }
1859
1860 switch (msgQueueId)
1861 {
1862 /// Message Queue ID for messages bound for SME
1863 case VOS_MQ_ID_TL:
1864 {
1865 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
1866 break;
1867 }
1868
1869#ifndef FEATURE_WLAN_INTEGRATED_SOC
1870 /// Message Queue ID for messages bound for SSC
1871 case VOS_MQ_ID_SSC:
1872 {
1873 pTargetMq = &(gpVosContext->vosSched.sscTxMq);
1874 break;
1875 }
1876#else
1877 /// Message Queue ID for messages bound for SSC
1878 case VOS_MQ_ID_WDI:
1879 {
1880 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
1881 break;
1882 }
1883#endif
1884
1885 /// Message Queue ID for messages bound for the SYS module
1886 case VOS_MQ_ID_SYS:
1887 {
1888 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
1889 break;
1890 }
1891
1892 default:
1893
1894 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1895 "Trying to queue msg into unknown Tx Msg queue ID %d",
1896 __func__, msgQueueId);
1897
1898 return VOS_STATUS_E_FAILURE;
1899 }
1900
1901 if (pTargetMq == NULL)
1902 {
1903 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1904 "%s: pTargetMq == NULL", __FUNCTION__);
1905 return VOS_STATUS_E_FAILURE;
1906 }
1907
1908
1909 /*
1910 ** Try and get a free Msg wrapper
1911 */
1912 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1913
1914 if (NULL == pMsgWrapper)
1915 {
1916 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1917 "%s: VOS Core run out of message wrapper", __func__);
1918
1919 return VOS_STATUS_E_RESOURCES;
1920 }
1921
1922 /*
1923 ** Copy the message now
1924 */
1925 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1926 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1927
1928 vos_mq_put(pTargetMq, pMsgWrapper);
1929
1930 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
1931 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
1932
1933 return VOS_STATUS_SUCCESS;
1934
1935} /* vos_tx_mq_serialize()*/
1936
1937#ifdef FEATURE_WLAN_INTEGRATED_SOC
1938/**---------------------------------------------------------------------------
1939
1940 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
1941
1942 This API allows messages to be posted to a specific message queue in the
1943 Tx excution flow. Messages for the Rx execution flow can be posted only
1944 to the following queue.
1945
1946 <ul>
1947 <li> TL
1948 <li> WDI
1949 </ul>
1950
1951 \param msgQueueId - identifies the message queue upon which the message
1952 will be posted.
1953
1954 \param message - a pointer to a message buffer. Body memory for this message
1955 buffer is allocated by the caller and free'd by the vOSS after the
1956 message is dispacthed to the appropriate component. If the consumer
1957 of the message needs to keep anything in the body, it needs to copy
1958 the contents before returning from the message handler.
1959
1960 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1961 to the message queue.
1962
1963 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1964 refer to a valid Message Queue Id.
1965
1966 VOS_STATUS_E_FAULT - message is an invalid pointer.
1967
1968 VOS_STATUS_E_FAILURE - the message queue handler has reported
1969 an unknown failure.
1970
1971 \sa
1972
1973 --------------------------------------------------------------------------*/
1974
1975VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1976{
1977 pVosMqType pTargetMq = NULL;
1978 pVosMsgWrapper pMsgWrapper = NULL;
1979 if ((gpVosContext == NULL) || (pMsg == NULL))
1980 {
1981 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1982 "%s: Null params or global vos context is null", __func__);
1983 VOS_ASSERT(0);
1984 return VOS_STATUS_E_FAILURE;
1985 }
1986
1987 switch (msgQueueId)
1988 {
1989
1990 case VOS_MQ_ID_SYS:
1991 {
1992 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
1993 break;
1994 }
1995
1996 /// Message Queue ID for messages bound for WDI
1997 case VOS_MQ_ID_WDI:
1998 {
1999 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
2000 break;
2001 }
2002
2003 default:
2004
2005 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2006 "Trying to queue msg into unknown Rx Msg queue ID %d",
2007 __func__, msgQueueId);
2008
2009 return VOS_STATUS_E_FAILURE;
2010 }
2011
2012 if (pTargetMq == NULL)
2013 {
2014 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2015 "%s: pTargetMq == NULL", __FUNCTION__);
2016 return VOS_STATUS_E_FAILURE;
2017 }
2018
2019
2020 /*
2021 ** Try and get a free Msg wrapper
2022 */
2023 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2024
2025 if (NULL == pMsgWrapper)
2026 {
2027 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2028 "%s: VOS Core run out of message wrapper", __func__);
2029
2030 return VOS_STATUS_E_RESOURCES;
2031 }
2032
2033 /*
2034 ** Copy the message now
2035 */
2036 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2037 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2038
2039 vos_mq_put(pTargetMq, pMsgWrapper);
2040
2041 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
2042 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
2043
2044 return VOS_STATUS_SUCCESS;
2045
2046} /* vos_rx_mq_serialize()*/
2047
2048#endif
2049v_VOID_t
2050vos_sys_probe_thread_cback
2051(
2052 v_VOID_t *pUserData
2053)
2054{
2055 if (gpVosContext != pUserData)
2056 {
2057 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2058 "%s: gpVosContext != pUserData", __FUNCTION__);
2059 return;
2060 }
2061
2062 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2063 {
2064 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2065 "%s: vos_event_set failed", __FUNCTION__);
2066 return;
2067 }
2068
2069} /* vos_sys_probe_thread_cback() */
2070
2071#ifndef FEATURE_WLAN_INTEGRATED_SOC
2072v_VOID_t vos_sys_start_complete_cback
2073(
2074 v_VOID_t *pUserData
2075)
2076{
2077
2078 if (gpVosContext != pUserData)
2079 {
2080 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2081 "%s: gpVosContext != pUserData", __FUNCTION__);
2082 return;
2083 }
2084
2085 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2086 {
2087 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2088 "%s: vos_event_set failed", __FUNCTION__);
2089 return;
2090 }
2091
2092} /* vos_sys_start_complete_cback() */
2093#else
2094v_VOID_t vos_WDAComplete_cback
2095(
2096 v_VOID_t *pUserData
2097)
2098{
2099
2100 if (gpVosContext != pUserData)
2101 {
2102 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2103 "%s: gpVosContext != pUserData", __FUNCTION__);
2104 return;
2105 }
2106
2107 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
2108 {
2109 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2110 "%s: vos_event_set failed", __FUNCTION__);
2111 return;
2112 }
2113
2114} /* vos_WDAComplete_cback() */
2115#endif
2116
2117v_VOID_t vos_core_return_msg
2118(
2119 v_PVOID_t pVContext,
2120 pVosMsgWrapper pMsgWrapper
2121)
2122{
2123 pVosContextType pVosContext = (pVosContextType) pVContext;
2124
2125 VOS_ASSERT( gpVosContext == pVosContext);
2126
2127 if (gpVosContext != pVosContext)
2128 {
2129 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2130 "%s: gpVosContext != pVosContext", __FUNCTION__);
2131 return;
2132 }
2133
2134 VOS_ASSERT( NULL !=pMsgWrapper );
2135
2136 if (pMsgWrapper == NULL)
2137 {
2138 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2139 "%s: pMsgWrapper == NULL in function", __FUNCTION__);
2140 return;
2141 }
2142
2143 /*
2144 ** Return the message on the free message queue
2145 */
2146 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
2147 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
2148
2149} /* vos_core_return_msg() */
2150
2151
2152/**
2153 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
2154 TL config params from the registry
2155
2156 @param pAdapter : [inout] pointer to TL config block
2157
2158 @return
2159 None
2160
2161*/
2162v_VOID_t
2163vos_fetch_tl_cfg_parms
2164(
2165 WLANTL_ConfigInfoType *pTLConfig,
2166 hdd_config_t * pConfig
2167)
2168{
2169 if (pTLConfig == NULL)
2170 {
2171 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __FUNCTION__);
2172 return;
2173 }
2174
2175 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
2176 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
2177 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
2178 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
2179 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
2180#ifdef WLAN_SOFTAP_FEATURE
2181 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
2182#endif
2183
2184}
2185
2186v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
2187{
2188 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
2189}
2190
2191void vos_abort_mac_scan(void)
2192{
2193 hdd_context_t *pHddCtx = NULL;
2194 v_CONTEXT_t pVosContext = NULL;
2195
2196 /* Get the Global VOSS Context */
2197 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2198 if(!pVosContext) {
2199 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2200 return;
2201 }
2202
2203 /* Get the HDD context */
2204 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2205 if(!pHddCtx) {
2206 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2207 return;
2208 }
2209
2210 hdd_abort_mac_scan(pHddCtx);
2211 return;
2212}
2213
2214/*---------------------------------------------------------------------------
2215
2216 \brief vos_shutdown() - shutdown VOS
2217
2218 - All VOS submodules are closed.
2219
2220 - All the WLAN SW components should have been opened. This includes
2221 SYS, MAC, SME and TL.
2222
2223
2224 \param vosContext: Global vos context
2225
2226
2227 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
2228
2229 VOS_STATUS_E_FAILURE - Failure to close
2230
2231---------------------------------------------------------------------------*/
2232VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2233{
2234 VOS_STATUS vosStatus;
2235
2236#ifdef WLAN_BTAMP_FEATURE
2237 vosStatus = WLANBAP_Close(vosContext);
2238 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2239 {
2240 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2241 "%s: Failed to close BAP", __func__);
2242 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2243 }
2244#endif // WLAN_BTAMP_FEATURE
2245
2246 vosStatus = WLANTL_Close(vosContext);
2247 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2248 {
2249 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2250 "%s: Failed to close TL", __func__);
2251 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2252 }
2253
2254 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2255 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2256 {
2257 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2258 "%s: Failed to close SME", __func__);
2259 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2260 }
2261
2262 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2263 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2264 {
2265 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2266 "%s: Failed to close MAC", __func__);
2267 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2268 }
2269
2270 ((pVosContextType)vosContext)->pMACContext = NULL;
2271
2272 vosStatus = vos_nv_close();
2273 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2274 {
2275 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2276 "%s: Failed to close NV", __func__);
2277 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2278 }
2279
2280 vosStatus = sysClose( vosContext );
2281 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2282 {
2283 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2284 "%s: Failed to close SYS", __func__);
2285 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2286 }
2287
2288 /* Let DXE return packets in WDA_close and then free them here */
2289 vosStatus = vos_packet_close( vosContext );
2290 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2291 {
2292 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2293 "%s: Failed to close VOSS Packet", __func__);
2294 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2295 }
2296
2297 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2298
2299 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2300 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2301 {
2302 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2303 "%s: failed to destroy wdaCompleteEvent", __func__);
2304 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2305 }
2306
2307 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2308 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2309 {
2310 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2311 "%s: failed to destroy ProbeEvent", __func__);
2312 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2313 }
2314
2315 return VOS_STATUS_SUCCESS;
2316}
2317
2318/*---------------------------------------------------------------------------
2319
2320 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2321
2322 - WDA/WDI shutdown
2323
2324 \param vosContext: Global vos context
2325
2326
2327 \return VOS_STATUS_SUCCESS - Operation successfull
2328
2329 VOS_STATUS_E_FAILURE - Failure to close
2330
2331---------------------------------------------------------------------------*/
2332VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2333{
2334 VOS_STATUS vosStatus;
2335 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2336
2337 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2338 {
2339 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2340 "%s: failed to shutdown WDA", __func__);
2341 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2342 }
2343 return vosStatus;
2344}
2345/**
2346 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2347
2348 This function is called when Riva subsystem crashes. There are two
2349 methods (or operations) in WLAN driver to handle Riva crash,
2350 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2351 driver without handshaking with Riva.
2352 2. re-init: Next API
2353 @param
2354 NONE
2355 @return
2356 VOS_STATUS_SUCCESS - Operation completed successfully.
2357 VOS_STATUS_E_FAILURE - Operation failed.
2358
2359*/
2360VOS_STATUS vos_wlanShutdown(void)
2361{
2362 VOS_STATUS vstatus;
2363 vstatus = vos_watchdog_wlan_shutdown();
2364 return vstatus;
2365}
2366/**
2367 @brief vos_wlanReInit() - This API will re-init WLAN driver
2368
2369 This function is called when Riva subsystem reboots. There are two
2370 methods (or operations) in WLAN driver to handle Riva crash,
2371 1. shutdown: Previous API
2372 2. re-init: Called when Riva comes back after the crash. This will
2373 re-initialize WLAN driver. In some cases re-open may be
2374 referred instead of re-init.
2375 @param
2376 NONE
2377 @return
2378 VOS_STATUS_SUCCESS - Operation completed successfully.
2379 VOS_STATUS_E_FAILURE - Operation failed.
2380
2381*/
2382VOS_STATUS vos_wlanReInit(void)
2383{
2384 VOS_STATUS vstatus;
2385 vstatus = vos_watchdog_wlan_re_init();
2386 return vstatus;
2387}
Jeff Johnsone7245742012-09-05 17:12:55 -07002388/**
2389 @brief vos_wlanRestart() - This API will reload WLAN driver.
2390
2391 This function is called if driver detects any fatal state which
2392 can be recovered by a WLAN module reload ( Android framwork initiated ).
2393 Note that this API will not initiate any RIVA subsystem restart.
2394
2395 The function wlan_hdd_restart_driver protects against re-entrant calls.
2396
2397 @param
2398 NONE
2399 @return
2400 VOS_STATUS_SUCCESS - Operation completed successfully.
2401 VOS_STATUS_E_FAILURE - Operation failed.
2402 VOS_STATUS_E_EMPTY - No configured interface
2403 VOS_STATUS_E_ALREADY - Request already in progress
2404
2405
2406*/
2407VOS_STATUS vos_wlanRestart(void)
2408{
2409 VOS_STATUS vstatus;
2410 hdd_context_t *pHddCtx = NULL;
2411 v_CONTEXT_t pVosContext = NULL;
2412
2413 /* Check whether driver load unload is in progress */
2414 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2415 {
2416 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2417 "%s: Driver load/unload is in progress, retry later.", __func__);
2418 return VOS_STATUS_E_AGAIN;
2419 }
2420
2421 /* Get the Global VOSS Context */
2422 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2423 if(!pVosContext) {
2424 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2425 "%s: Global VOS context is Null", __func__);
2426 return VOS_STATUS_E_FAILURE;
2427 }
2428
2429 /* Get the HDD context */
2430 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2431 if(!pHddCtx) {
2432 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2433 "%s: HDD context is Null", __func__);
2434 return VOS_STATUS_E_FAILURE;
2435 }
2436
2437 /* Reload the driver */
2438 vstatus = wlan_hdd_restart_driver(pHddCtx);
2439 return vstatus;
2440}