blob: e0f91e2d0b7f7be2aabafd11cd7fb2171982cd7f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam1ed83fc2014-02-19 01:15:45 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**=========================================================================
Jeff Johnson2f5cfec2013-02-22 21:25:10 -080029
Jeff Johnson295189b2012-06-20 16:38:30 -070030 \file vos_api.c
31
32 \brief Stub file for all virtual Operating System Services (vOSS) APIs
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35 /*===========================================================================
36
37 EDIT HISTORY FOR FILE
38
39
40 This section contains comments describing changes made to the module.
41 Notice that changes are listed in reverse chronological order.
42
43
44 $Header:$ $DateTime: $ $Author: $
45
46
47 when who what, where, why
48 -------- --- --------------------------------------------------------
49 03/29/09 kanand Created module.
50===========================================================================*/
51
52/*--------------------------------------------------------------------------
53 Include Files
54 ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <vos_mq.h>
56#include "vos_sched.h"
57#include <vos_api.h>
58#include "sirTypes.h"
59#include "sirApi.h"
60#include "sirMacProtDef.h"
61#include "sme_Api.h"
62#include "macInitApi.h"
63#include "wlan_qct_sys.h"
64#include "wlan_qct_tl.h"
65#include "wlan_hdd_misc.h"
66#include "i_vos_packet.h"
67#include "vos_nvitem.h"
68#include "wlan_qct_wda.h"
69#include "wlan_hdd_main.h"
70#include <linux/vmalloc.h>
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -070071#include "wlan_hdd_cfg80211.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070072
Dino Mycle3f783bc2014-08-08 17:40:22 +053073#include <linux/wcnss_wlan.h>
74
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "sapApi.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070076#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070077
78
79
80#ifdef WLAN_BTAMP_FEATURE
81#include "bapApi.h"
82#include "bapInternal.h"
83#include "bap_hdd_main.h"
84#endif //WLAN_BTAMP_FEATURE
85
86
87/*---------------------------------------------------------------------------
88 * Preprocessor Definitions and Constants
89 * ------------------------------------------------------------------------*/
90/* Amount of time to wait for WDA to perform an asynchronous activity.
91 This value should be larger than the timeout used by WDI to wait for
92 a response from WCNSS since in the event that WCNSS is not responding,
93 WDI should handle that timeout */
94#define VOS_WDA_TIMEOUT 15000
95
96/* Approximate amount of time to wait for WDA to stop WDI */
97#define VOS_WDA_STOP_TIMEOUT WDA_STOP_TIMEOUT
98
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +053099/* Approximate amount of time to wait for WDA to issue a DUMP req */
100#define VOS_WDA_RESP_TIMEOUT WDA_STOP_TIMEOUT
101
Jeff Johnson295189b2012-06-20 16:38:30 -0700102/*---------------------------------------------------------------------------
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
Jeff Johnson295189b2012-06-20 16:38:30 -0700113v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
114
115v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
116 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118
119/*---------------------------------------------------------------------------
120
121 \brief vos_preOpen() - PreOpen the vOSS Module
122
123 The \a vos_preOpen() function allocates the Vos Context, but do not
124 initialize all the members. This overal initialization will happen
125 at vos_Open().
126 The reason why we need vos_preOpen() is to get a minimum context
127 where to store BAL and SAL relative data, which happens before
128 vos_Open() is called.
129
130 \param pVosContext: A pointer to where to store the VOS Context
131
132
133 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
134 is ready to be used.
135
136 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
137
138 \sa vos_Open()
139
140---------------------------------------------------------------------------*/
141VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
142{
143 if ( pVosContext == NULL)
144 return VOS_STATUS_E_FAILURE;
145
146 /* Allocate the VOS Context */
147 *pVosContext = NULL;
148 gpVosContext = &gVosContext;
149
150 if (NULL == gpVosContext)
151 {
152 /* Critical Error ...Cannot proceed further */
153 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
154 "%s: Failed to allocate VOS Context", __func__);
155 VOS_ASSERT(0);
156 return VOS_STATUS_E_RESOURCES;
157 }
158
159 vos_mem_zero(gpVosContext, sizeof(VosContextType));
160
161 *pVosContext = gpVosContext;
162
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700163 /* Initialize the spinlock */
164 vos_trace_spin_lock_init();
165 /* it is the right time to initialize MTRACE structures */
166 #if defined(TRACE_RECORD)
167 vosTraceInit();
168 #endif
169
Jeff Johnson295189b2012-06-20 16:38:30 -0700170 return VOS_STATUS_SUCCESS;
171
172} /* vos_preOpen()*/
173
174
175/*---------------------------------------------------------------------------
176
177 \brief vos_preClose() - PreClose the vOSS Module
178
179 The \a vos_preClose() function frees the Vos Context.
180
181 \param pVosContext: A pointer to where the VOS Context was stored
182
183
184 \return VOS_STATUS_SUCCESS - Always successful
185
186
187 \sa vos_preClose()
188 \sa vos_close()
189---------------------------------------------------------------------------*/
190VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
191{
192
193 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
194 "%s: De-allocating the VOS Context", __func__);
195
196 if (( pVosContext == NULL) || (*pVosContext == NULL))
197 {
198 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
199 "%s: vOS Context is Null", __func__);
200 return VOS_STATUS_E_FAILURE;
201 }
202
203 if (gpVosContext != *pVosContext)
204 {
205 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
206 "%s: Context mismatch", __func__);
207 return VOS_STATUS_E_FAILURE;
208 }
209
210 *pVosContext = gpVosContext = NULL;
211
212 return VOS_STATUS_SUCCESS;
213
214} /* vos_preClose()*/
215
216/*---------------------------------------------------------------------------
217
218 \brief vos_open() - Open the vOSS Module
219
220 The \a vos_open() function opens the vOSS Scheduler
221 Upon successful initialization:
222
223 - All VOS submodules should have been initialized
224
225 - The VOS scheduler should have opened
226
227 - All the WLAN SW components should have been opened. This includes
228 SYS, MAC, SME, WDA and TL.
229
230
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530231 \param devHandle: pointer to the OS specific device handle
Jeff Johnson295189b2012-06-20 16:38:30 -0700232
233
234 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
235 is ready to be used.
236
237 VOS_STATUS_E_RESOURCES - System resources (other than memory)
238 are unavailable to initilize the scheduler
239
240
241 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
242
243 \sa vos_preOpen()
244
245---------------------------------------------------------------------------*/
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530246VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, void *devHandle )
Jeff Johnson295189b2012-06-20 16:38:30 -0700247
248{
249 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
250 int iter = 0;
251 tSirRetStatus sirStatus = eSIR_SUCCESS;
252 tMacOpenParameters macOpenParms;
253 WLANTL_ConfigInfoType TLConfig;
254
255 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
256 "%s: Opening VOSS", __func__);
257
258 if (NULL == gpVosContext)
259 {
260 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
261 "%s: Trying to open VOSS without a PreOpen", __func__);
262 VOS_ASSERT(0);
263 return VOS_STATUS_E_FAILURE;
264 }
265
266 /* Initialize the timer module */
267 vos_timer_module_init();
268
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 /* Initialize the probe event */
271 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
272 {
273 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
274 "%s: Unable to init probeEvent", __func__);
275 VOS_ASSERT(0);
276 return VOS_STATUS_E_FAILURE;
277 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
279 {
280 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
281 "%s: Unable to init wdaCompleteEvent", __func__);
282 VOS_ASSERT(0);
283
284 goto err_probe_event;
285 }
286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 /* Initialize the free message queue */
288 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
289 if (! VOS_IS_STATUS_SUCCESS(vStatus))
290 {
291
292 /* Critical Error ... Cannot proceed further */
293 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
294 "%s: Failed to initialize VOS free message queue", __func__);
295 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 goto err_wda_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 }
298
299 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
300 {
301 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
302 &(gpVosContext->aMsgBuffers[iter]);
303 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
304 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
305 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700306
307 /* Now Open the VOS Scheduler */
308 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
309 sizeof(VosSchedContext));
310
311 if (!VOS_IS_STATUS_SUCCESS(vStatus))
312 {
313 /* Critical Error ... Cannot proceed further */
314 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
315 "%s: Failed to open VOS Scheduler", __func__);
316 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 }
319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 /*
321 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
322 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
323 */
324
325 /*Open the WDA module */
326 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
327 /* UMA is supported in hardware for performing the
328 ** frame translation 802.11 <-> 802.3
329 */
330 macOpenParms.frameTransRequired = 1;
331 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530332 vStatus = WDA_open( gpVosContext, devHandle, &macOpenParms );
Jeff Johnson295189b2012-06-20 16:38:30 -0700333
334 if (!VOS_IS_STATUS_SUCCESS(vStatus))
335 {
336 /* Critical Error ... Cannot proceed further */
337 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
338 "%s: Failed to open WDA module", __func__);
339 VOS_ASSERT(0);
340 goto err_sched_close;
341 }
342
343 /* Initialize here the VOS Packet sub module */
344 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
345 sizeof( vos_pkt_context_t ) );
346
347 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
348 {
349 /* Critical Error ... Cannot proceed further */
350 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
351 "%s: Failed to open VOS Packet Module", __func__);
352 VOS_ASSERT(0);
353 goto err_wda_close;
354 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 /* Open the SYS module */
357 vStatus = sysOpen(gpVosContext);
358
359 if (!VOS_IS_STATUS_SUCCESS(vStatus))
360 {
361 /* Critical Error ... Cannot proceed further */
362 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
363 "%s: Failed to open SYS module", __func__);
364 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 }
367
Amar Singhal0a402232013-10-11 20:57:16 -0700368#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 /* initialize the NV module */
370 vStatus = vos_nv_open();
371 if (!VOS_IS_STATUS_SUCCESS(vStatus))
372 {
373 // NV module cannot be initialized
374 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
375 "%s: Failed to initialize the NV module", __func__);
376 goto err_sys_close;
377 }
Amar Singhal0a402232013-10-11 20:57:16 -0700378#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
380 /* If we arrive here, both threads dispacthing messages correctly */
381
382 /* Now proceed to open the MAC */
383
384 /* UMA is supported in hardware for performing the
385 frame translation 802.11 <-> 802.3 */
386 macOpenParms.frameTransRequired = 1;
387 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
388 &macOpenParms);
389
390 if (eSIR_SUCCESS != sirStatus)
391 {
392 /* Critical Error ... Cannot proceed further */
393 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
394 "%s: Failed to open MAC", __func__);
395 VOS_ASSERT(0);
396 goto err_nv_close;
397 }
398
399 /* Now proceed to open the SME */
400 vStatus = sme_Open(gpVosContext->pMACContext);
401 if (!VOS_IS_STATUS_SUCCESS(vStatus))
402 {
403 /* Critical Error ... Cannot proceed further */
404 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
405 "%s: Failed to open SME", __func__);
406 VOS_ASSERT(0);
407 goto err_mac_close;
408 }
409
410 /* Now proceed to open TL. Read TL config first */
411 vos_fetch_tl_cfg_parms ( &TLConfig,
412 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
413
414 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
415 if (!VOS_IS_STATUS_SUCCESS(vStatus))
416 {
417 /* Critical Error ... Cannot proceed further */
418 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
419 "%s: Failed to open TL", __func__);
420 VOS_ASSERT(0);
421 goto err_sme_close;
422 }
423
424 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
425 "%s: VOSS successfully Opened", __func__);
426
427 *pVosContext = gpVosContext;
428
429 return VOS_STATUS_SUCCESS;
430
431
432err_sme_close:
433 sme_Close(gpVosContext->pMACContext);
434
435err_mac_close:
436 macClose(gpVosContext->pMACContext);
437
438err_nv_close:
Amar Singhal0a402232013-10-11 20:57:16 -0700439
440#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 vos_nv_close();
Amar Singhal0a402232013-10-11 20:57:16 -0700442
443err_sys_close:
444#endif
445
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 sysClose(gpVosContext);
447
Jeff Johnson295189b2012-06-20 16:38:30 -0700448err_packet_close:
449 vos_packet_close( gpVosContext );
450
451err_wda_close:
452 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700453
Amar Singhal0a402232013-10-11 20:57:16 -0700454err_sched_close:
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 vos_sched_close(gpVosContext);
456
Jeff Johnson295189b2012-06-20 16:38:30 -0700457
458err_msg_queue:
459 vos_mq_deinit(&gpVosContext->freeVosMq);
460
Jeff Johnson295189b2012-06-20 16:38:30 -0700461err_wda_complete_event:
462 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700463
464err_probe_event:
465 vos_event_destroy(&gpVosContext->ProbeEvent);
466
467 return VOS_STATUS_E_FAILURE;
468
469} /* vos_open() */
470
Jeff Johnson295189b2012-06-20 16:38:30 -0700471/*---------------------------------------------------------------------------
472
473 \brief vos_preStart() -
474
475 The \a vos_preStart() function to download CFG.
476 including:
477 - ccmStart
478
479 - WDA: triggers the CFG download
480
481
482 \param pVosContext: The VOS context
483
484
485 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
486 is ready to be used.
487
488 VOS_STATUS_E_RESOURCES - System resources (other than memory)
489 are unavailable to initilize the scheduler
490
491
492 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
493
494 \sa vos_start
495
496---------------------------------------------------------------------------*/
497VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
498{
499 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
500 pVosContextType pVosContext = (pVosContextType)vosContext;
501
502 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
503 "vos prestart");
504
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800505 if (gpVosContext != pVosContext)
506 {
507 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
508 "%s: Context mismatch", __func__);
509 VOS_ASSERT(0);
510 return VOS_STATUS_E_INVAL;
511 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700512
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800513 if (pVosContext->pMACContext == NULL)
514 {
515 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
516 "%s: MAC NULL context", __func__);
517 VOS_ASSERT(0);
518 return VOS_STATUS_E_INVAL;
519 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700520
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800521 if (pVosContext->pWDAContext == NULL)
522 {
523 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
524 "%s: WDA NULL context", __func__);
525 VOS_ASSERT(0);
526 return VOS_STATUS_E_INVAL;
527 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
529 /* call macPreStart */
530 vStatus = macPreStart(gpVosContext->pMACContext);
531 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
532 {
533 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
534 "Failed at macPreStart ");
535 return VOS_STATUS_E_FAILURE;
536 }
537
538 /* call ccmStart */
539 ccmStart(gpVosContext->pMACContext);
540
541 /* Reset wda wait event */
542 vos_event_reset(&gpVosContext->wdaCompleteEvent);
543
544
545 /*call WDA pre start*/
546 vStatus = WDA_preStart(gpVosContext);
547 if (!VOS_IS_STATUS_SUCCESS(vStatus))
548 {
549 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
550 "Failed to WDA prestart");
551 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
552 ccmStop(gpVosContext->pMACContext);
553 VOS_ASSERT(0);
554 return VOS_STATUS_E_FAILURE;
555 }
556
557 /* Need to update time out of complete */
558 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
559 VOS_WDA_TIMEOUT );
560 if ( vStatus != VOS_STATUS_SUCCESS )
561 {
562 if ( vStatus == VOS_STATUS_E_TIMEOUT )
563 {
564 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800565 "%s: Timeout occurred before WDA complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 }
567 else
568 {
569 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
570 "%s: WDA_preStart reporting other error", __func__);
571 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700572 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
573 "%s: Test MC thread by posting a probe message to SYS", __func__);
574 wlan_sys_probe();
575
Jeff Johnsone7245742012-09-05 17:12:55 -0700576 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
577 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 VOS_ASSERT( 0 );
579 return VOS_STATUS_E_FAILURE;
580 }
581
582 return VOS_STATUS_SUCCESS;
583}
Jeff Johnson295189b2012-06-20 16:38:30 -0700584
585/*---------------------------------------------------------------------------
586
587 \brief vos_start() - Start the Libra SW Modules
588
589 The \a vos_start() function starts all the components of the Libra SW
590 including:
591 - SAL/BAL, which in turn starts SSC
592
593 - the MAC (HAL and PE)
594
595 - SME
596
597 - TL
598
599 - SYS: triggers the CFG download
600
601
602 \param pVosContext: The VOS context
603
604
605 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
606 is ready to be used.
607
608 VOS_STATUS_E_RESOURCES - System resources (other than memory)
609 are unavailable to initilize the scheduler
610
611
612 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
613
614 \sa vos_preStart()
615 \sa vos_open()
616
617---------------------------------------------------------------------------*/
618VOS_STATUS vos_start( v_CONTEXT_t vosContext )
619{
620 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
621 tSirRetStatus sirStatus = eSIR_SUCCESS;
622 pVosContextType pVosContext = (pVosContextType)vosContext;
623 tHalMacStartParameters halStartParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700624
625 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
626 "%s: Starting Libra SW", __func__);
627
628 /* We support only one instance for now ...*/
629 if (gpVosContext != pVosContext)
630 {
631 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700632 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 return VOS_STATUS_E_FAILURE;
634 }
635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
637 || ( pVosContext->pTLContext == NULL))
638 {
639 if (pVosContext->pWDAContext == NULL)
640 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700641 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 else if (pVosContext->pMACContext == NULL)
643 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700644 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 else
646 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700647 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700648
649 return VOS_STATUS_E_FAILURE;
650 }
651
652 /* WDA_Start will be called after NV image download because the
653 NV image data has to be updated at HAL before HAL_Start gets executed*/
654
655 /* Start the NV Image Download */
656
657 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
658
659 vStatus = WDA_NVDownload_Start(pVosContext);
660
661 if ( vStatus != VOS_STATUS_SUCCESS )
662 {
663 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
664 "%s: Failed to start NV Download", __func__);
665 return VOS_STATUS_E_FAILURE;
666 }
667
668 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
669 VOS_WDA_TIMEOUT );
670
671 if ( vStatus != VOS_STATUS_SUCCESS )
672 {
673 if ( vStatus == VOS_STATUS_E_TIMEOUT )
674 {
675 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
676 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
677 }
678 else
679 {
680 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
681 "%s: WDA_NVDownload_start reporting other error", __func__);
682 }
683 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800684 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700685 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
686 {
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530687 if (isSsrPanicOnFailure())
688 VOS_BUG(0);
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700689 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800690 WDA_setNeedShutdown(vosContext);
691 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 }
693
694 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
695 "%s: WDA_NVDownload_start correctly started", __func__);
696
697 /* Start the WDA */
698 vStatus = WDA_start(pVosContext);
699 if ( vStatus != VOS_STATUS_SUCCESS )
700 {
701 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530702 "%s: Failed to start WDA - WDA_shutdown needed", __func__);
703 if ( vStatus == VOS_STATUS_E_TIMEOUT )
704 {
705 WDA_setNeedShutdown(vosContext);
706 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 return VOS_STATUS_E_FAILURE;
708 }
709 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
710 "%s: WDA correctly started", __func__);
711
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 /* Start the MAC */
713 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
714
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 /* Start the MAC */
716 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
717
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 if (eSIR_SUCCESS != sirStatus)
719 {
720 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
721 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 }
724
725 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
726 "%s: MAC correctly started", __func__);
727
728 /* START SME */
729 vStatus = sme_Start(pVosContext->pMACContext);
730
731 if (!VOS_IS_STATUS_SUCCESS(vStatus))
732 {
733 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
734 "%s: Failed to start SME", __func__);
735 goto err_mac_stop;
736 }
737
738 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
739 "%s: SME correctly started", __func__);
740
741 /** START TL */
742 vStatus = WLANTL_Start(pVosContext);
743 if (!VOS_IS_STATUS_SUCCESS(vStatus))
744 {
745 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
746 "%s: Failed to start TL", __func__);
747 goto err_sme_stop;
748 }
749
750 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
751 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
753 "%s: VOSS Start is successful!!", __func__);
754
755 return VOS_STATUS_SUCCESS;
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757
758err_sme_stop:
Kiet Lama72a2322013-11-15 11:18:11 +0530759 sme_Stop(pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700760
761err_mac_stop:
762 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
763
Jeff Johnson295189b2012-06-20 16:38:30 -0700764err_wda_stop:
765 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800766 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
767 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800769 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
770 "%s: Failed to stop WDA", __func__);
771 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800772 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800773 }
774 else
775 {
776 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
777 VOS_WDA_TIMEOUT );
778 if( vStatus != VOS_STATUS_SUCCESS )
779 {
780 if( vStatus == VOS_STATUS_E_TIMEOUT )
781 {
782 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
783 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700784
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800785 }
786 else
787 {
788 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
789 "%s: WDA_stop reporting other error", __func__);
790 }
791 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800792 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800793 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700795
796 return VOS_STATUS_E_FAILURE;
797
798} /* vos_start() */
799
800
801/* vos_stop function */
802VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
803{
804 VOS_STATUS vosStatus;
805
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 /* WDA_Stop is called before the SYS so that the processing of Riva
807 pending responces will not be handled during uninitialization of WLAN driver */
808 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
809
810 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
811
812 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
813 {
814 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
815 "%s: Failed to stop WDA", __func__);
816 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800817 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -0700819 else
820 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800821 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
822 VOS_WDA_STOP_TIMEOUT );
Jeff Johnson295189b2012-06-20 16:38:30 -0700823
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800824 if ( vosStatus != VOS_STATUS_SUCCESS )
825 {
826 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
827 {
828 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
829 "%s: Timeout occurred before WDA complete", __func__);
830 }
831 else
832 {
833 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
834 "%s: WDA_stop reporting other error", __func__ );
835 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700836 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
837 "%s: Test MC thread by posting a probe message to SYS", __func__);
838 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800839 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800840 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700842
843 /* SYS STOP will stop SME and MAC */
844 vosStatus = sysStop( vosContext);
845 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
846 {
847 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
848 "%s: Failed to stop SYS", __func__);
849 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
850 }
851
852 vosStatus = WLANTL_Stop( vosContext );
853 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
854 {
855 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
856 "%s: Failed to stop TL", __func__);
857 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
858 }
859
Jeff Johnson295189b2012-06-20 16:38:30 -0700860
861 return VOS_STATUS_SUCCESS;
862}
863
864
865/* vos_close function */
866VOS_STATUS vos_close( v_CONTEXT_t vosContext )
867{
868 VOS_STATUS vosStatus;
869
870#ifdef WLAN_BTAMP_FEATURE
871 vosStatus = WLANBAP_Close(vosContext);
872 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
873 {
874 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
875 "%s: Failed to close BAP", __func__);
876 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
877 }
878#endif // WLAN_BTAMP_FEATURE
879
880
881 vosStatus = WLANTL_Close(vosContext);
882 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
883 {
884 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
885 "%s: Failed to close TL", __func__);
886 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
887 }
888
889 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
890 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
891 {
892 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
893 "%s: Failed to close SME", __func__);
894 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
895 }
896
897 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
898 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
899 {
900 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
901 "%s: Failed to close MAC", __func__);
902 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
903 }
904
905 ((pVosContextType)vosContext)->pMACContext = NULL;
906
Amar Singhal0a402232013-10-11 20:57:16 -0700907#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 vosStatus = vos_nv_close();
909 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
910 {
911 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
912 "%s: Failed to close NV", __func__);
913 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
914 }
Amar Singhal0a402232013-10-11 20:57:16 -0700915#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700916
917 vosStatus = sysClose( vosContext );
918 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
919 {
920 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
921 "%s: Failed to close SYS", __func__);
922 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
923 }
924
Jeff Johnsone7245742012-09-05 17:12:55 -0700925 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700927 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
928 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
929 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
930 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -0700931 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -0700932 }
933 else
934 {
935 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
936 "%s: Failed to shutdown WDA", __func__ );
937 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
938 }
939 }
940 else
941 {
942 vosStatus = WDA_close( vosContext );
943 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
944 {
945 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
946 "%s: Failed to close WDA", __func__);
947 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
948 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 }
950
951 /* Let DXE return packets in WDA_close and then free them here */
952 vosStatus = vos_packet_close( vosContext );
953 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
954 {
955 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
956 "%s: Failed to close VOSS Packet", __func__);
957 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
958 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700959
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
961 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
964 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
965 {
966 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
967 "%s: failed to destroy wdaCompleteEvent", __func__);
968 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
969 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700970
971 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
972 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
973 {
974 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
975 "%s: failed to destroy ProbeEvent", __func__);
976 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
977 }
978
979 return VOS_STATUS_SUCCESS;
980}
981
982
983/**---------------------------------------------------------------------------
984
985 \brief vos_get_context() - get context data area
986
987 Each module in the system has a context / data area that is allocated
988 and maanged by voss. This API allows any user to get a pointer to its
989 allocated context data area from the VOSS global context.
990
991 \param vosContext - the VOSS Global Context.
992
993 \param moduleId - the module ID, who's context data are is being retrived.
994
995 \return - pointer to the context data area.
996
997 - NULL if the context data is not allocated for the module ID
998 specified
999
1000 --------------------------------------------------------------------------*/
1001v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1002 v_CONTEXT_t pVosContext )
1003{
1004 v_PVOID_t pModContext = NULL;
1005
1006 if (pVosContext == NULL)
1007 {
1008 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001009 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 return NULL;
1011 }
1012
1013 if (gpVosContext != pVosContext)
1014 {
1015 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001016 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 return NULL;
1018 }
1019
1020 switch(moduleId)
1021 {
1022 case VOS_MODULE_ID_TL:
1023 {
1024 pModContext = gpVosContext->pTLContext;
1025 break;
1026 }
1027
Jeff Johnson295189b2012-06-20 16:38:30 -07001028#ifdef WLAN_BTAMP_FEATURE
1029 case VOS_MODULE_ID_BAP:
1030 {
1031 pModContext = gpVosContext->pBAPContext;
1032 break;
1033 }
1034#endif //WLAN_BTAMP_FEATURE
1035
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 case VOS_MODULE_ID_SAP:
1037 {
1038 pModContext = gpVosContext->pSAPContext;
1039 break;
1040 }
1041
1042 case VOS_MODULE_ID_HDD_SOFTAP:
1043 {
1044 pModContext = gpVosContext->pHDDSoftAPContext;
1045 break;
1046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001047
1048 case VOS_MODULE_ID_HDD:
1049 {
1050 pModContext = gpVosContext->pHDDContext;
1051 break;
1052 }
1053
1054 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301056 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 {
1058 /*
1059 ** In all these cases, we just return the MAC Context
1060 */
1061 pModContext = gpVosContext->pMACContext;
1062 break;
1063 }
1064
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 case VOS_MODULE_ID_WDA:
1066 {
1067 /* For WDA module */
1068 pModContext = gpVosContext->pWDAContext;
1069 break;
1070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001071
1072 case VOS_MODULE_ID_VOSS:
1073 {
1074 /* For SYS this is VOS itself*/
1075 pModContext = gpVosContext;
1076 break;
1077 }
1078
1079 default:
1080 {
1081 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1082 "does not have its context maintained by VOSS", __func__, moduleId);
1083 VOS_ASSERT(0);
1084 return NULL;
1085 }
1086 }
1087
1088 if (pModContext == NULL )
1089 {
1090 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1091 "context is Null", __func__, moduleId);
1092 }
1093
1094 return pModContext;
1095
1096} /* vos_get_context()*/
1097
1098
1099/**---------------------------------------------------------------------------
1100
1101 \brief vos_get_global_context() - get VOSS global Context
1102
1103 This API allows any user to get the VOS Global Context pointer from a
1104 module context data area.
1105
1106 \param moduleContext - the input module context pointer
1107
1108 \param moduleId - the module ID who's context pointer is input in
1109 moduleContext.
1110
1111 \return - pointer to the VOSS global context
1112
1113 - NULL if the function is unable to retreive the VOSS context.
1114
1115 --------------------------------------------------------------------------*/
1116v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1117 v_VOID_t *moduleContext )
1118{
1119 if (gpVosContext == NULL)
1120 {
1121 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001122 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 }
1124
1125 return gpVosContext;
1126
1127} /* vos_get_global_context() */
1128
1129
1130v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1131{
1132 if (gpVosContext == NULL)
1133 {
1134 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001135 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 return 1;
1137 }
1138
1139 return gpVosContext->isLogpInProgress;
1140}
1141
1142void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1143{
1144 if (gpVosContext == NULL)
1145 {
1146 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001147 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 return;
1149 }
1150
1151 gpVosContext->isLogpInProgress = value;
1152}
1153
1154v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1155{
1156 if (gpVosContext == NULL)
1157 {
1158 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001159 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 return 0;
1161 }
1162
1163 return gpVosContext->isLoadUnloadInProgress;
1164}
1165
1166void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1167{
1168 if (gpVosContext == NULL)
1169 {
1170 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001171 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 return;
1173 }
1174
1175 gpVosContext->isLoadUnloadInProgress = value;
1176}
1177
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001178v_U8_t vos_is_reinit_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1179{
1180 if (gpVosContext == NULL)
1181 {
1182 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1183 "%s: global voss context is NULL", __func__);
1184 return 1;
1185 }
1186
1187 return gpVosContext->isReInitInProgress;
1188}
1189
1190void vos_set_reinit_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1191{
1192 if (gpVosContext == NULL)
1193 {
1194 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1195 "%s: global voss context is NULL", __func__);
1196 return;
1197 }
1198
1199 gpVosContext->isReInitInProgress = value;
1200}
1201
1202
Jeff Johnson295189b2012-06-20 16:38:30 -07001203/**---------------------------------------------------------------------------
1204
1205 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1206
1207 This API allows any user to allocate a user context area within the
1208 VOS Global Context.
1209
1210 \param pVosContext - pointer to the global Vos context
1211
1212 \param moduleId - the module ID who's context area is being allocated.
1213
1214 \param ppModuleContext - pointer to location where the pointer to the
1215 allocated context is returned. Note this
1216 output pointer is valid only if the API
1217 returns VOS_STATUS_SUCCESS
1218
1219 \param size - the size of the context area to be allocated.
1220
1221 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1222 allocated successfully. The pointer to the context area
1223 can be found in *ppModuleContext.
1224 \note This function returns VOS_STATUS_SUCCESS if the
1225 module context was already allocated and the size
1226 allocated matches the size on this call.
1227
1228 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1229 not identify a module that can have a context allocated.
1230
1231 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1232 because a context for this module ID already exists and it is
1233 a *different* size that specified on this call.
1234
1235 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1236 requested context area.
1237
1238 \sa vos_get_context(), vos_free_context()
1239
1240 --------------------------------------------------------------------------*/
1241VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1242 v_VOID_t **ppModuleContext, v_SIZE_t size )
1243{
1244 v_VOID_t ** pGpModContext = NULL;
1245
1246 if ( pVosContext == NULL) {
1247 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001248 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 return VOS_STATUS_E_FAILURE;
1250 }
1251
1252 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1253 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001254 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 return VOS_STATUS_E_FAILURE;
1256 }
1257
1258 switch(moduleID)
1259 {
1260 case VOS_MODULE_ID_TL:
1261 {
1262 pGpModContext = &(gpVosContext->pTLContext);
1263 break;
1264 }
1265
Jeff Johnson295189b2012-06-20 16:38:30 -07001266#ifdef WLAN_BTAMP_FEATURE
1267 case VOS_MODULE_ID_BAP:
1268 {
1269 pGpModContext = &(gpVosContext->pBAPContext);
1270 break;
1271 }
1272#endif //WLAN_BTAMP_FEATURE
1273
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 case VOS_MODULE_ID_SAP:
1275 {
1276 pGpModContext = &(gpVosContext->pSAPContext);
1277 break;
1278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001279
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 case VOS_MODULE_ID_WDA:
1281 {
1282 pGpModContext = &(gpVosContext->pWDAContext);
1283 break;
1284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301287 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 default:
1291 {
1292 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1293 "does not have its context allocated by VOSS", __func__, moduleID);
1294 VOS_ASSERT(0);
1295 return VOS_STATUS_E_INVAL;
1296 }
1297 }
1298
1299 if ( NULL != *pGpModContext)
1300 {
1301 /*
1302 ** Context has already been allocated!
1303 ** Prevent double allocation
1304 */
1305 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1306 "%s: Module ID %i context has already been allocated",
1307 __func__, moduleID);
1308 return VOS_STATUS_E_EXISTS;
1309 }
1310
1311 /*
1312 ** Dynamically allocate the context for module
1313 */
1314
1315 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1316
1317
1318 if ( *ppModuleContext == NULL)
1319 {
1320 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1321 "allocate Context for module ID %i", __func__, moduleID);
1322 VOS_ASSERT(0);
1323 return VOS_STATUS_E_NOMEM;
1324 }
1325
1326 if (moduleID==VOS_MODULE_ID_TL)
1327 {
1328 vos_mem_zero(*ppModuleContext, size);
1329 }
1330
1331 *pGpModContext = *ppModuleContext;
1332
1333 return VOS_STATUS_SUCCESS;
1334
1335} /* vos_alloc_context() */
1336
1337
1338/**---------------------------------------------------------------------------
1339
1340 \brief vos_free_context() - free an allocated a context within the
1341 VOSS global Context
1342
1343 This API allows a user to free the user context area within the
1344 VOS Global Context.
1345
1346 \param pVosContext - pointer to the global Vos context
1347
1348 \param moduleId - the module ID who's context area is being free
1349
1350 \param pModuleContext - pointer to module context area to be free'd.
1351
1352 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1353 free'd. The pointer to the context area is not longer
1354 available.
1355
1356 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1357 valid pointers.
1358
1359 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1360 not identify a module that can have a context free'd.
1361
1362 VOS_STATUS_E_EXISTS - vos could not free the requested
1363 context area because a context for this module ID does not
1364 exist in the global vos context.
1365
1366 \sa vos_get_context()
1367
1368 --------------------------------------------------------------------------*/
1369VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1370 v_VOID_t *pModuleContext )
1371{
1372 v_VOID_t ** pGpModContext = NULL;
1373
1374 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1375 ( pModuleContext == NULL))
1376 {
1377 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1378 "%s: Null params or context mismatch", __func__);
1379 return VOS_STATUS_E_FAILURE;
1380 }
1381
1382
1383 switch(moduleID)
1384 {
1385 case VOS_MODULE_ID_TL:
1386 {
1387 pGpModContext = &(gpVosContext->pTLContext);
1388 break;
1389 }
1390
Jeff Johnson295189b2012-06-20 16:38:30 -07001391#ifdef WLAN_BTAMP_FEATURE
1392 case VOS_MODULE_ID_BAP:
1393 {
1394 pGpModContext = &(gpVosContext->pBAPContext);
1395 break;
1396 }
1397#endif //WLAN_BTAMP_FEATURE
1398
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 case VOS_MODULE_ID_SAP:
1400 {
1401 pGpModContext = &(gpVosContext->pSAPContext);
1402 break;
1403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001404
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 case VOS_MODULE_ID_WDA:
1406 {
1407 pGpModContext = &(gpVosContext->pWDAContext);
1408 break;
1409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 case VOS_MODULE_ID_HDD:
1411 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301413 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 default:
1416 {
1417 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1418 "does not have its context allocated by VOSS", __func__, moduleID);
1419 VOS_ASSERT(0);
1420 return VOS_STATUS_E_INVAL;
1421 }
1422 }
1423
1424 if ( NULL == *pGpModContext)
1425 {
1426 /*
1427 ** Context has not been allocated or freed already!
1428 */
1429 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1430 "context has not been allocated or freed already", __func__,moduleID);
1431 return VOS_STATUS_E_FAILURE;
1432 }
1433
1434 if (*pGpModContext != pModuleContext)
1435 {
1436 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001437 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 return VOS_STATUS_E_FAILURE;
1439 }
1440
1441 if(pModuleContext != NULL)
1442 kfree(pModuleContext);
1443
1444 *pGpModContext = NULL;
1445
1446 return VOS_STATUS_SUCCESS;
1447
1448} /* vos_free_context() */
1449
1450
1451/**---------------------------------------------------------------------------
1452
1453 \brief vos_mq_post_message() - post a message to a message queue
1454
1455 This API allows messages to be posted to a specific message queue. Messages
1456 can be posted to the following message queues:
1457
1458 <ul>
1459 <li> SME
1460 <li> PE
1461 <li> HAL
1462 <li> TL
1463 </ul>
1464
1465 \param msgQueueId - identifies the message queue upon which the message
1466 will be posted.
1467
1468 \param message - a pointer to a message buffer. Memory for this message
1469 buffer is allocated by the caller and free'd by the vOSS after the
1470 message is posted to the message queue. If the consumer of the
1471 message needs anything in this message, it needs to copy the contents
1472 before returning from the message queue handler.
1473
1474 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1475 to the message queue.
1476
1477 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1478 refer to a valid Message Queue Id.
1479
1480 VOS_STATUS_E_FAULT - message is an invalid pointer.
1481
1482 VOS_STATUS_E_FAILURE - the message queue handler has reported
1483 an unknown failure.
1484
1485 \sa
1486
1487 --------------------------------------------------------------------------*/
1488VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1489{
1490 pVosMqType pTargetMq = NULL;
1491 pVosMsgWrapper pMsgWrapper = NULL;
1492
1493 if ((gpVosContext == NULL) || (pMsg == NULL))
1494 {
1495 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1496 "%s: Null params or global vos context is null", __func__);
1497 VOS_ASSERT(0);
1498 return VOS_STATUS_E_FAILURE;
1499 }
1500
1501 switch (msgQueueId)
1502 {
1503 /// Message Queue ID for messages bound for SME
1504 case VOS_MQ_ID_SME:
1505 {
1506 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1507 break;
1508 }
1509
1510 /// Message Queue ID for messages bound for PE
1511 case VOS_MQ_ID_PE:
1512 {
1513 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1514 break;
1515 }
1516
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 /// Message Queue ID for messages bound for WDA
1518 case VOS_MQ_ID_WDA:
1519 {
1520 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1521 break;
1522 }
1523
1524 /// Message Queue ID for messages bound for WDI
1525 case VOS_MQ_ID_WDI:
1526 {
1527 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1528 break;
1529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001530
1531 /// Message Queue ID for messages bound for TL
1532 case VOS_MQ_ID_TL:
1533 {
1534 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1535 break;
1536 }
1537
1538 /// Message Queue ID for messages bound for the SYS module
1539 case VOS_MQ_ID_SYS:
1540 {
1541 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1542 break;
1543 }
1544
1545 default:
1546
1547 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1548 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1549 __func__, msgQueueId);
1550
1551 return VOS_STATUS_E_FAILURE;
1552 }
1553
1554 VOS_ASSERT(NULL !=pTargetMq);
1555 if (pTargetMq == NULL)
1556 {
1557 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001558 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 return VOS_STATUS_E_FAILURE;
1560 }
1561
1562 /*
1563 ** Try and get a free Msg wrapper
1564 */
1565 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1566
1567 if (NULL == pMsgWrapper)
1568 {
1569 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1570 "%s: VOS Core run out of message wrapper", __func__);
1571
1572 return VOS_STATUS_E_RESOURCES;
1573 }
1574
1575 /*
1576 ** Copy the message now
1577 */
1578 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1579 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1580
1581 vos_mq_put(pTargetMq, pMsgWrapper);
1582
1583 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1584 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1585
1586 return VOS_STATUS_SUCCESS;
1587
1588} /* vos_mq_post_message()*/
1589
1590
1591/**---------------------------------------------------------------------------
1592
1593 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
1594
1595 This API allows messages to be posted to a specific message queue in the
1596 Tx excution flow. Messages for the Tx execution flow can be posted only
1597 to the following queue.
1598
1599 <ul>
1600 <li> TL
1601 <li> SSC/WDI
1602 </ul>
1603
1604 \param msgQueueId - identifies the message queue upon which the message
1605 will be posted.
1606
1607 \param message - a pointer to a message buffer. Body memory for this message
1608 buffer is allocated by the caller and free'd by the vOSS after the
1609 message is dispacthed to the appropriate component. If the consumer
1610 of the message needs to keep anything in the body, it needs to copy
1611 the contents before returning from the message handler.
1612
1613 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1614 to the message queue.
1615
1616 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1617 refer to a valid Message Queue Id.
1618
1619 VOS_STATUS_E_FAULT - message is an invalid pointer.
1620
1621 VOS_STATUS_E_FAILURE - the message queue handler has reported
1622 an unknown failure.
1623
1624 \sa
1625
1626 --------------------------------------------------------------------------*/
1627VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1628{
1629 pVosMqType pTargetMq = NULL;
1630 pVosMsgWrapper pMsgWrapper = NULL;
1631
1632 if ((gpVosContext == NULL) || (pMsg == NULL))
1633 {
1634 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1635 "%s: Null params or global vos context is null", __func__);
1636 VOS_ASSERT(0);
1637 return VOS_STATUS_E_FAILURE;
1638 }
1639
1640 switch (msgQueueId)
1641 {
1642 /// Message Queue ID for messages bound for SME
1643 case VOS_MQ_ID_TL:
1644 {
1645 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
1646 break;
1647 }
1648
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 /// Message Queue ID for messages bound for SSC
1650 case VOS_MQ_ID_WDI:
1651 {
1652 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
1653 break;
1654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001655
1656 /// Message Queue ID for messages bound for the SYS module
1657 case VOS_MQ_ID_SYS:
1658 {
1659 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
1660 break;
1661 }
1662
1663 default:
1664
1665 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301666 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 __func__, msgQueueId);
1668
1669 return VOS_STATUS_E_FAILURE;
1670 }
1671
1672 if (pTargetMq == NULL)
1673 {
1674 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001675 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 return VOS_STATUS_E_FAILURE;
1677 }
1678
1679
1680 /*
1681 ** Try and get a free Msg wrapper
1682 */
1683 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1684
1685 if (NULL == pMsgWrapper)
1686 {
1687 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1688 "%s: VOS Core run out of message wrapper", __func__);
1689
1690 return VOS_STATUS_E_RESOURCES;
1691 }
1692
1693 /*
1694 ** Copy the message now
1695 */
1696 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1697 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1698
1699 vos_mq_put(pTargetMq, pMsgWrapper);
1700
1701 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
1702 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
1703
1704 return VOS_STATUS_SUCCESS;
1705
1706} /* vos_tx_mq_serialize()*/
1707
Jeff Johnson295189b2012-06-20 16:38:30 -07001708/**---------------------------------------------------------------------------
1709
1710 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
1711
1712 This API allows messages to be posted to a specific message queue in the
1713 Tx excution flow. Messages for the Rx execution flow can be posted only
1714 to the following queue.
1715
1716 <ul>
1717 <li> TL
1718 <li> WDI
1719 </ul>
1720
1721 \param msgQueueId - identifies the message queue upon which the message
1722 will be posted.
1723
1724 \param message - a pointer to a message buffer. Body memory for this message
1725 buffer is allocated by the caller and free'd by the vOSS after the
1726 message is dispacthed to the appropriate component. If the consumer
1727 of the message needs to keep anything in the body, it needs to copy
1728 the contents before returning from the message handler.
1729
1730 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1731 to the message queue.
1732
1733 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1734 refer to a valid Message Queue Id.
1735
1736 VOS_STATUS_E_FAULT - message is an invalid pointer.
1737
1738 VOS_STATUS_E_FAILURE - the message queue handler has reported
1739 an unknown failure.
1740
1741 \sa
1742
1743 --------------------------------------------------------------------------*/
1744
1745VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1746{
1747 pVosMqType pTargetMq = NULL;
1748 pVosMsgWrapper pMsgWrapper = NULL;
1749 if ((gpVosContext == NULL) || (pMsg == NULL))
1750 {
1751 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1752 "%s: Null params or global vos context is null", __func__);
1753 VOS_ASSERT(0);
1754 return VOS_STATUS_E_FAILURE;
1755 }
1756
1757 switch (msgQueueId)
1758 {
1759
1760 case VOS_MQ_ID_SYS:
1761 {
1762 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
1763 break;
1764 }
1765
1766 /// Message Queue ID for messages bound for WDI
1767 case VOS_MQ_ID_WDI:
1768 {
1769 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
1770 break;
1771 }
Katya Nigam664f5032014-05-05 12:24:32 +05301772 case VOS_MQ_ID_TL:
1773 {
1774 pTargetMq = &(gpVosContext->vosSched.tlRxMq);
1775 break;
1776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001777
1778 default:
1779
1780 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301781 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 __func__, msgQueueId);
1783
1784 return VOS_STATUS_E_FAILURE;
1785 }
1786
1787 if (pTargetMq == NULL)
1788 {
1789 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001790 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 return VOS_STATUS_E_FAILURE;
1792 }
1793
1794
1795 /*
1796 ** Try and get a free Msg wrapper
1797 */
1798 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1799
1800 if (NULL == pMsgWrapper)
1801 {
1802 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1803 "%s: VOS Core run out of message wrapper", __func__);
1804
1805 return VOS_STATUS_E_RESOURCES;
1806 }
1807
1808 /*
1809 ** Copy the message now
1810 */
1811 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1812 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1813
1814 vos_mq_put(pTargetMq, pMsgWrapper);
1815
1816 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
1817 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
1818
1819 return VOS_STATUS_SUCCESS;
1820
1821} /* vos_rx_mq_serialize()*/
1822
Jeff Johnson295189b2012-06-20 16:38:30 -07001823v_VOID_t
1824vos_sys_probe_thread_cback
1825(
1826 v_VOID_t *pUserData
1827)
1828{
1829 if (gpVosContext != pUserData)
1830 {
1831 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001832 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 return;
1834 }
1835
1836 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
1837 {
1838 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001839 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 return;
1841 }
1842
1843} /* vos_sys_probe_thread_cback() */
1844
Jeff Johnson295189b2012-06-20 16:38:30 -07001845v_VOID_t vos_WDAComplete_cback
1846(
1847 v_VOID_t *pUserData
1848)
1849{
1850
1851 if (gpVosContext != pUserData)
1852 {
1853 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001854 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 return;
1856 }
1857
1858 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
1859 {
1860 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001861 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 return;
1863 }
1864
1865} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07001866
1867v_VOID_t vos_core_return_msg
1868(
1869 v_PVOID_t pVContext,
1870 pVosMsgWrapper pMsgWrapper
1871)
1872{
1873 pVosContextType pVosContext = (pVosContextType) pVContext;
1874
1875 VOS_ASSERT( gpVosContext == pVosContext);
1876
1877 if (gpVosContext != pVosContext)
1878 {
1879 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001880 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 return;
1882 }
1883
1884 VOS_ASSERT( NULL !=pMsgWrapper );
1885
1886 if (pMsgWrapper == NULL)
1887 {
1888 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001889 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 return;
1891 }
1892
1893 /*
1894 ** Return the message on the free message queue
1895 */
1896 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
1897 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
1898
1899} /* vos_core_return_msg() */
1900
1901
1902/**
1903 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
1904 TL config params from the registry
1905
1906 @param pAdapter : [inout] pointer to TL config block
1907
1908 @return
1909 None
1910
1911*/
1912v_VOID_t
1913vos_fetch_tl_cfg_parms
1914(
1915 WLANTL_ConfigInfoType *pTLConfig,
1916 hdd_config_t * pConfig
1917)
1918{
1919 if (pTLConfig == NULL)
1920 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001921 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 return;
1923 }
1924
1925 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
1926 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
1927 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
1928 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
Dhanashri Atred8c20a32014-01-03 17:20:55 -08001929 pTLConfig->ucReorderAgingTime[0] = pConfig->BkReorderAgingTime;/*WLANTL_AC_BK*/
1930 pTLConfig->ucReorderAgingTime[1] = pConfig->BeReorderAgingTime;/*WLANTL_AC_BE*/
1931 pTLConfig->ucReorderAgingTime[2] = pConfig->ViReorderAgingTime;/*WLANTL_AC_VI*/
1932 pTLConfig->ucReorderAgingTime[3] = pConfig->VoReorderAgingTime;/*WLANTL_AC_VO*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07001935
1936}
1937
1938v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
1939{
1940 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
1941}
1942
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05301943void vos_abort_mac_scan(v_U8_t sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001944{
1945 hdd_context_t *pHddCtx = NULL;
1946 v_CONTEXT_t pVosContext = NULL;
1947
1948 /* Get the Global VOSS Context */
1949 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1950 if(!pVosContext) {
1951 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
1952 return;
1953 }
1954
1955 /* Get the HDD context */
1956 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1957 if(!pHddCtx) {
1958 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
1959 return;
1960 }
1961
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301962 hdd_abort_mac_scan(pHddCtx, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 return;
1964}
Jeff Johnson295189b2012-06-20 16:38:30 -07001965/*---------------------------------------------------------------------------
1966
1967 \brief vos_shutdown() - shutdown VOS
1968
1969 - All VOS submodules are closed.
1970
1971 - All the WLAN SW components should have been opened. This includes
1972 SYS, MAC, SME and TL.
1973
1974
1975 \param vosContext: Global vos context
1976
1977
1978 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
1979
1980 VOS_STATUS_E_FAILURE - Failure to close
1981
1982---------------------------------------------------------------------------*/
1983VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
1984{
1985 VOS_STATUS vosStatus;
1986
1987#ifdef WLAN_BTAMP_FEATURE
1988 vosStatus = WLANBAP_Close(vosContext);
1989 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1990 {
1991 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1992 "%s: Failed to close BAP", __func__);
1993 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1994 }
1995#endif // WLAN_BTAMP_FEATURE
1996
1997 vosStatus = WLANTL_Close(vosContext);
1998 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1999 {
2000 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2001 "%s: Failed to close TL", __func__);
2002 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2003 }
2004
2005 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2006 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2007 {
2008 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2009 "%s: Failed to close SME", __func__);
2010 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2011 }
2012
2013 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2014 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2015 {
2016 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2017 "%s: Failed to close MAC", __func__);
2018 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2019 }
2020
2021 ((pVosContextType)vosContext)->pMACContext = NULL;
2022
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 vosStatus = sysClose( vosContext );
2024 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2025 {
2026 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2027 "%s: Failed to close SYS", __func__);
2028 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2029 }
2030
2031 /* Let DXE return packets in WDA_close and then free them here */
2032 vosStatus = vos_packet_close( vosContext );
2033 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2034 {
2035 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2036 "%s: Failed to close VOSS Packet", __func__);
2037 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2038 }
2039
2040 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2041
2042 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2043 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2044 {
2045 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2046 "%s: failed to destroy wdaCompleteEvent", __func__);
2047 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2048 }
2049
2050 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2051 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2052 {
2053 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2054 "%s: failed to destroy ProbeEvent", __func__);
2055 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2056 }
2057
2058 return VOS_STATUS_SUCCESS;
2059}
2060
2061/*---------------------------------------------------------------------------
2062
2063 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2064
2065 - WDA/WDI shutdown
2066
2067 \param vosContext: Global vos context
2068
2069
2070 \return VOS_STATUS_SUCCESS - Operation successfull
2071
2072 VOS_STATUS_E_FAILURE - Failure to close
2073
2074---------------------------------------------------------------------------*/
2075VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2076{
2077 VOS_STATUS vosStatus;
2078 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2079
2080 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2081 {
2082 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2083 "%s: failed to shutdown WDA", __func__);
2084 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2085 }
2086 return vosStatus;
2087}
2088/**
2089 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2090
2091 This function is called when Riva subsystem crashes. There are two
2092 methods (or operations) in WLAN driver to handle Riva crash,
2093 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2094 driver without handshaking with Riva.
2095 2. re-init: Next API
2096 @param
2097 NONE
2098 @return
2099 VOS_STATUS_SUCCESS - Operation completed successfully.
2100 VOS_STATUS_E_FAILURE - Operation failed.
2101
2102*/
2103VOS_STATUS vos_wlanShutdown(void)
2104{
2105 VOS_STATUS vstatus;
2106 vstatus = vos_watchdog_wlan_shutdown();
2107 return vstatus;
2108}
2109/**
2110 @brief vos_wlanReInit() - This API will re-init WLAN driver
2111
2112 This function is called when Riva subsystem reboots. There are two
2113 methods (or operations) in WLAN driver to handle Riva crash,
2114 1. shutdown: Previous API
2115 2. re-init: Called when Riva comes back after the crash. This will
2116 re-initialize WLAN driver. In some cases re-open may be
2117 referred instead of re-init.
2118 @param
2119 NONE
2120 @return
2121 VOS_STATUS_SUCCESS - Operation completed successfully.
2122 VOS_STATUS_E_FAILURE - Operation failed.
2123
2124*/
2125VOS_STATUS vos_wlanReInit(void)
2126{
2127 VOS_STATUS vstatus;
2128 vstatus = vos_watchdog_wlan_re_init();
2129 return vstatus;
2130}
Jeff Johnsone7245742012-09-05 17:12:55 -07002131/**
2132 @brief vos_wlanRestart() - This API will reload WLAN driver.
2133
2134 This function is called if driver detects any fatal state which
2135 can be recovered by a WLAN module reload ( Android framwork initiated ).
2136 Note that this API will not initiate any RIVA subsystem restart.
2137
2138 The function wlan_hdd_restart_driver protects against re-entrant calls.
2139
2140 @param
2141 NONE
2142 @return
2143 VOS_STATUS_SUCCESS - Operation completed successfully.
2144 VOS_STATUS_E_FAILURE - Operation failed.
2145 VOS_STATUS_E_EMPTY - No configured interface
2146 VOS_STATUS_E_ALREADY - Request already in progress
2147
2148
2149*/
2150VOS_STATUS vos_wlanRestart(void)
2151{
2152 VOS_STATUS vstatus;
2153 hdd_context_t *pHddCtx = NULL;
2154 v_CONTEXT_t pVosContext = NULL;
2155
2156 /* Check whether driver load unload is in progress */
2157 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2158 {
2159 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2160 "%s: Driver load/unload is in progress, retry later.", __func__);
2161 return VOS_STATUS_E_AGAIN;
2162 }
2163
2164 /* Get the Global VOSS Context */
2165 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2166 if(!pVosContext) {
2167 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2168 "%s: Global VOS context is Null", __func__);
2169 return VOS_STATUS_E_FAILURE;
2170 }
2171
2172 /* Get the HDD context */
2173 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2174 if(!pHddCtx) {
2175 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2176 "%s: HDD context is Null", __func__);
2177 return VOS_STATUS_E_FAILURE;
2178 }
2179
2180 /* Reload the driver */
2181 vstatus = wlan_hdd_restart_driver(pHddCtx);
2182 return vstatus;
2183}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302184
2185
2186/**
2187 @brief vos_fwDumpReq()
2188
2189 This function is called to issue dump commands to Firmware
2190
2191 @param
Siddharth Bhal68115602015-01-18 20:44:55 +05302192 cmd - Command No. to execute
2193 arg1 - argument 1 to cmd
2194 arg2 - argument 2 to cmd
2195 arg3 - argument 3 to cmd
2196 arg4 - argument 4 to cmd
2197 async - asynchronous event. Don't wait for completion.
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302198 @return
2199 NONE
2200*/
2201v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
Siddharth Bhal68115602015-01-18 20:44:55 +05302202 tANI_U32 arg3, tANI_U32 arg4, tANI_U8 async)
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302203{
Siddharth Bhal68115602015-01-18 20:44:55 +05302204 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL, 0);
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302205}
Dino Mycle3f783bc2014-08-08 17:40:22 +05302206
2207v_U64_t vos_get_monotonic_boottime(void)
2208{
2209 struct timespec ts;
2210 wcnss_get_monotonic_boottime(&ts);
2211 return (((v_U64_t)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
2212}
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05302213
2214/**---------------------------------------------------------------------------
2215
2216 \brief vos_randomize_n_bytes() - HDD Random Mac Addr Generator
2217
2218 This generates the random mac address for WLAN interface
2219
2220 \param - mac_addr - pointer to Mac address
2221
2222 \return - 0 for success, < 0 for failure
2223
2224 --------------------------------------------------------------------------*/
2225
2226VOS_STATUS vos_randomize_n_bytes(void *start_addr, tANI_U32 n)
2227{
2228
2229 if (start_addr == NULL )
2230 return VOS_STATUS_E_FAILURE;
2231
2232 get_random_bytes( start_addr, n);
2233
2234 return eHAL_STATUS_SUCCESS;
2235}
c_hpothu8adb97b2014-12-08 19:38:20 +05302236
2237/**---------------------------------------------------------------------------
2238
2239 \brief vos_is_wlan_in_badState() - get isFatalError flag from WD Ctx
2240
2241 \param - VOS_MODULE_ID - module id
2242 - moduleContext - module context
2243
2244 \return - isFatalError value if WDCtx is valid otherwise true
2245
2246 --------------------------------------------------------------------------*/
2247v_BOOL_t vos_is_wlan_in_badState(VOS_MODULE_ID moduleId,
2248 v_VOID_t *moduleContext)
2249{
2250 struct _VosWatchdogContext *pVosWDCtx = get_vos_watchdog_ctxt();
2251
2252 if (pVosWDCtx == NULL){
2253 VOS_TRACE(moduleId, VOS_TRACE_LEVEL_ERROR,
2254 "%s: global wd context is null", __func__);
2255
2256 return TRUE;
2257 }
2258 return pVosWDCtx->isFatalError;
2259}