blob: 21484dbe22548f6fc1cffa0099f587d9ccc34f6c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam1ed83fc2014-02-19 01:15:45 -08003 *
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"
Girish Gowlifb0bfd32015-01-13 11:42:11 +053077#include "vos_utils.h"
Siddharth Bhal7bd19932015-03-03 16:54:36 +053078#include <wlan_logging_sock_svc.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070079
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;
Sushant Kaushik215778f2015-05-21 14:05:36 +0530107static v_U8_t vos_multicast_logging;
Jeff Johnson295189b2012-06-20 16:38:30 -0700108
109/*---------------------------------------------------------------------------
110 * Forward declaration
111 * ------------------------------------------------------------------------*/
112v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
113
Jeff Johnson295189b2012-06-20 16:38:30 -0700114v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
115
116v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
117 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119
120/*---------------------------------------------------------------------------
121
122 \brief vos_preOpen() - PreOpen the vOSS Module
123
124 The \a vos_preOpen() function allocates the Vos Context, but do not
125 initialize all the members. This overal initialization will happen
126 at vos_Open().
127 The reason why we need vos_preOpen() is to get a minimum context
128 where to store BAL and SAL relative data, which happens before
129 vos_Open() is called.
130
131 \param pVosContext: A pointer to where to store the VOS Context
132
133
134 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
135 is ready to be used.
136
137 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
138
139 \sa vos_Open()
140
141---------------------------------------------------------------------------*/
142VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
143{
144 if ( pVosContext == NULL)
145 return VOS_STATUS_E_FAILURE;
146
147 /* Allocate the VOS Context */
148 *pVosContext = NULL;
149 gpVosContext = &gVosContext;
150
151 if (NULL == gpVosContext)
152 {
153 /* Critical Error ...Cannot proceed further */
154 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
155 "%s: Failed to allocate VOS Context", __func__);
156 VOS_ASSERT(0);
157 return VOS_STATUS_E_RESOURCES;
158 }
159
160 vos_mem_zero(gpVosContext, sizeof(VosContextType));
161
162 *pVosContext = gpVosContext;
163
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700164 /* Initialize the spinlock */
165 vos_trace_spin_lock_init();
166 /* it is the right time to initialize MTRACE structures */
167 #if defined(TRACE_RECORD)
168 vosTraceInit();
169 #endif
170
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 return VOS_STATUS_SUCCESS;
172
173} /* vos_preOpen()*/
174
175
176/*---------------------------------------------------------------------------
177
178 \brief vos_preClose() - PreClose the vOSS Module
179
180 The \a vos_preClose() function frees the Vos Context.
181
182 \param pVosContext: A pointer to where the VOS Context was stored
183
184
185 \return VOS_STATUS_SUCCESS - Always successful
186
187
188 \sa vos_preClose()
189 \sa vos_close()
190---------------------------------------------------------------------------*/
191VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
192{
193
194 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
195 "%s: De-allocating the VOS Context", __func__);
196
197 if (( pVosContext == NULL) || (*pVosContext == NULL))
198 {
199 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
200 "%s: vOS Context is Null", __func__);
201 return VOS_STATUS_E_FAILURE;
202 }
203
204 if (gpVosContext != *pVosContext)
205 {
206 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
207 "%s: Context mismatch", __func__);
208 return VOS_STATUS_E_FAILURE;
209 }
210
211 *pVosContext = gpVosContext = NULL;
212
213 return VOS_STATUS_SUCCESS;
214
215} /* vos_preClose()*/
216
217/*---------------------------------------------------------------------------
218
219 \brief vos_open() - Open the vOSS Module
220
221 The \a vos_open() function opens the vOSS Scheduler
222 Upon successful initialization:
223
224 - All VOS submodules should have been initialized
225
226 - The VOS scheduler should have opened
227
228 - All the WLAN SW components should have been opened. This includes
229 SYS, MAC, SME, WDA and TL.
230
231
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530232 \param devHandle: pointer to the OS specific device handle
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
234
235 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
236 is ready to be used.
237
238 VOS_STATUS_E_RESOURCES - System resources (other than memory)
239 are unavailable to initilize the scheduler
240
241
242 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
243
244 \sa vos_preOpen()
245
246---------------------------------------------------------------------------*/
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530247VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, void *devHandle )
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
249{
250 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
251 int iter = 0;
252 tSirRetStatus sirStatus = eSIR_SUCCESS;
253 tMacOpenParameters macOpenParms;
254 WLANTL_ConfigInfoType TLConfig;
255
256 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
257 "%s: Opening VOSS", __func__);
258
259 if (NULL == gpVosContext)
260 {
261 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
262 "%s: Trying to open VOSS without a PreOpen", __func__);
263 VOS_ASSERT(0);
264 return VOS_STATUS_E_FAILURE;
265 }
266
267 /* Initialize the timer module */
268 vos_timer_module_init();
269
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700270
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 /* Initialize the probe event */
272 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
273 {
274 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
275 "%s: Unable to init probeEvent", __func__);
276 VOS_ASSERT(0);
277 return VOS_STATUS_E_FAILURE;
278 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
280 {
281 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
282 "%s: Unable to init wdaCompleteEvent", __func__);
283 VOS_ASSERT(0);
284
285 goto err_probe_event;
286 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530287 if (vos_event_init( &(gpVosContext->fwLogsComplete) ) != VOS_STATUS_SUCCESS )
288 {
289 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
290 "%s: Unable to init fwLogsComplete", __func__);
291 VOS_ASSERT(0);
292
293 goto err_wda_complete_event;
294 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700295
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 /* Initialize the free message queue */
297 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
298 if (! VOS_IS_STATUS_SUCCESS(vStatus))
299 {
300
301 /* Critical Error ... Cannot proceed further */
302 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
303 "%s: Failed to initialize VOS free message queue", __func__);
304 VOS_ASSERT(0);
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530305 goto err_fw_logs_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 }
307
308 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
309 {
310 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
311 &(gpVosContext->aMsgBuffers[iter]);
312 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
313 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
314 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700315
316 /* Now Open the VOS Scheduler */
317 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
318 sizeof(VosSchedContext));
319
320 if (!VOS_IS_STATUS_SUCCESS(vStatus))
321 {
322 /* Critical Error ... Cannot proceed further */
323 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
324 "%s: Failed to open VOS Scheduler", __func__);
325 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 }
328
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 /*
330 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
331 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
332 */
333
334 /*Open the WDA module */
335 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
336 /* UMA is supported in hardware for performing the
337 ** frame translation 802.11 <-> 802.3
338 */
339 macOpenParms.frameTransRequired = 1;
340 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530341 vStatus = WDA_open( gpVosContext, devHandle, &macOpenParms );
Jeff Johnson295189b2012-06-20 16:38:30 -0700342
343 if (!VOS_IS_STATUS_SUCCESS(vStatus))
344 {
345 /* Critical Error ... Cannot proceed further */
346 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
347 "%s: Failed to open WDA module", __func__);
348 VOS_ASSERT(0);
349 goto err_sched_close;
350 }
351
352 /* Initialize here the VOS Packet sub module */
353 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
354 sizeof( vos_pkt_context_t ) );
355
356 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
357 {
358 /* Critical Error ... Cannot proceed further */
359 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
360 "%s: Failed to open VOS Packet Module", __func__);
361 VOS_ASSERT(0);
362 goto err_wda_close;
363 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700364
365 /* Open the SYS module */
366 vStatus = sysOpen(gpVosContext);
367
368 if (!VOS_IS_STATUS_SUCCESS(vStatus))
369 {
370 /* Critical Error ... Cannot proceed further */
371 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
372 "%s: Failed to open SYS module", __func__);
373 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 }
376
Amar Singhal0a402232013-10-11 20:57:16 -0700377#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 /* initialize the NV module */
379 vStatus = vos_nv_open();
380 if (!VOS_IS_STATUS_SUCCESS(vStatus))
381 {
382 // NV module cannot be initialized
383 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
384 "%s: Failed to initialize the NV module", __func__);
385 goto err_sys_close;
386 }
Amar Singhal0a402232013-10-11 20:57:16 -0700387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
389 /* If we arrive here, both threads dispacthing messages correctly */
390
391 /* Now proceed to open the MAC */
392
393 /* UMA is supported in hardware for performing the
394 frame translation 802.11 <-> 802.3 */
395 macOpenParms.frameTransRequired = 1;
396 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
397 &macOpenParms);
398
399 if (eSIR_SUCCESS != sirStatus)
400 {
401 /* Critical Error ... Cannot proceed further */
402 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
403 "%s: Failed to open MAC", __func__);
404 VOS_ASSERT(0);
405 goto err_nv_close;
406 }
407
408 /* Now proceed to open the SME */
409 vStatus = sme_Open(gpVosContext->pMACContext);
410 if (!VOS_IS_STATUS_SUCCESS(vStatus))
411 {
412 /* Critical Error ... Cannot proceed further */
413 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
414 "%s: Failed to open SME", __func__);
415 VOS_ASSERT(0);
416 goto err_mac_close;
417 }
418
419 /* Now proceed to open TL. Read TL config first */
420 vos_fetch_tl_cfg_parms ( &TLConfig,
421 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
422
423 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
424 if (!VOS_IS_STATUS_SUCCESS(vStatus))
425 {
426 /* Critical Error ... Cannot proceed further */
427 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
428 "%s: Failed to open TL", __func__);
429 VOS_ASSERT(0);
430 goto err_sme_close;
431 }
432
Girish Gowlifb0bfd32015-01-13 11:42:11 +0530433 if (gpVosContext->roamDelayStatsEnabled &&
434 !vos_roam_delay_stats_init())
435 {
436 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
437 "%s: Could not init roamDelayStats", __func__);
438 }
439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
441 "%s: VOSS successfully Opened", __func__);
442
443 *pVosContext = gpVosContext;
444
445 return VOS_STATUS_SUCCESS;
446
447
448err_sme_close:
449 sme_Close(gpVosContext->pMACContext);
450
451err_mac_close:
452 macClose(gpVosContext->pMACContext);
453
454err_nv_close:
Amar Singhal0a402232013-10-11 20:57:16 -0700455
456#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 vos_nv_close();
Amar Singhal0a402232013-10-11 20:57:16 -0700458
459err_sys_close:
460#endif
461
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 sysClose(gpVosContext);
463
Jeff Johnson295189b2012-06-20 16:38:30 -0700464err_packet_close:
465 vos_packet_close( gpVosContext );
466
467err_wda_close:
468 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700469
Amar Singhal0a402232013-10-11 20:57:16 -0700470err_sched_close:
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 vos_sched_close(gpVosContext);
472
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474err_msg_queue:
475 vos_mq_deinit(&gpVosContext->freeVosMq);
476
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530477err_fw_logs_complete_event:
478 vos_event_destroy( &gpVosContext->fwLogsComplete);
479
Jeff Johnson295189b2012-06-20 16:38:30 -0700480err_wda_complete_event:
481 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700482
483err_probe_event:
484 vos_event_destroy(&gpVosContext->ProbeEvent);
485
486 return VOS_STATUS_E_FAILURE;
487
488} /* vos_open() */
489
Jeff Johnson295189b2012-06-20 16:38:30 -0700490/*---------------------------------------------------------------------------
491
492 \brief vos_preStart() -
493
494 The \a vos_preStart() function to download CFG.
495 including:
496 - ccmStart
497
498 - WDA: triggers the CFG download
499
500
501 \param pVosContext: The VOS context
502
503
504 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
505 is ready to be used.
506
507 VOS_STATUS_E_RESOURCES - System resources (other than memory)
508 are unavailable to initilize the scheduler
509
510
511 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
512
513 \sa vos_start
514
515---------------------------------------------------------------------------*/
516VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
517{
518 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
519 pVosContextType pVosContext = (pVosContextType)vosContext;
520
521 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
522 "vos prestart");
523
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800524 if (gpVosContext != pVosContext)
525 {
526 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
527 "%s: Context mismatch", __func__);
528 VOS_ASSERT(0);
529 return VOS_STATUS_E_INVAL;
530 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700531
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800532 if (pVosContext->pMACContext == NULL)
533 {
534 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
535 "%s: MAC NULL context", __func__);
536 VOS_ASSERT(0);
537 return VOS_STATUS_E_INVAL;
538 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700539
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800540 if (pVosContext->pWDAContext == NULL)
541 {
542 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
543 "%s: WDA NULL context", __func__);
544 VOS_ASSERT(0);
545 return VOS_STATUS_E_INVAL;
546 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
548 /* call macPreStart */
549 vStatus = macPreStart(gpVosContext->pMACContext);
550 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
551 {
552 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
553 "Failed at macPreStart ");
554 return VOS_STATUS_E_FAILURE;
555 }
556
557 /* call ccmStart */
558 ccmStart(gpVosContext->pMACContext);
559
560 /* Reset wda wait event */
561 vos_event_reset(&gpVosContext->wdaCompleteEvent);
562
563
564 /*call WDA pre start*/
565 vStatus = WDA_preStart(gpVosContext);
566 if (!VOS_IS_STATUS_SUCCESS(vStatus))
567 {
568 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
569 "Failed to WDA prestart");
570 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
571 ccmStop(gpVosContext->pMACContext);
572 VOS_ASSERT(0);
573 return VOS_STATUS_E_FAILURE;
574 }
575
576 /* Need to update time out of complete */
577 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
578 VOS_WDA_TIMEOUT );
579 if ( vStatus != VOS_STATUS_SUCCESS )
580 {
581 if ( vStatus == VOS_STATUS_E_TIMEOUT )
582 {
583 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800584 "%s: Timeout occurred before WDA complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 }
586 else
587 {
588 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
589 "%s: WDA_preStart reporting other error", __func__);
590 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700591 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
592 "%s: Test MC thread by posting a probe message to SYS", __func__);
593 wlan_sys_probe();
594
Jeff Johnsone7245742012-09-05 17:12:55 -0700595 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
596 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 VOS_ASSERT( 0 );
598 return VOS_STATUS_E_FAILURE;
599 }
600
601 return VOS_STATUS_SUCCESS;
602}
Jeff Johnson295189b2012-06-20 16:38:30 -0700603
Katya Nigame7b69a82015-04-28 15:24:06 +0530604VOS_STATUS vos_mon_start( v_CONTEXT_t vosContext )
605{
606 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
607 pVosContextType pVosContext = (pVosContextType)vosContext;
608
609 if (pVosContext == NULL)
610 {
611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
612 "%s: mismatch in context",__func__);
613 return VOS_STATUS_E_FAILURE;
614 }
615
616 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pTLContext == NULL))
617 {
618 if (pVosContext->pWDAContext == NULL)
619 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
620 "%s: WDA NULL context", __func__);
621 else
622 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
623 "%s: TL NULL context", __func__);
624
625 return VOS_STATUS_E_FAILURE;
626 }
627
628 /* Reset wda wait event */
629 vos_event_reset(&pVosContext->wdaCompleteEvent);
630
631 /*call WDA pre start*/
632 vStatus = WDA_preStart(pVosContext);
633 if (!VOS_IS_STATUS_SUCCESS(vStatus))
634 {
635 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
636 "Failed to WDA prestart ");
637 VOS_ASSERT(0);
638 return VOS_STATUS_E_FAILURE;
639 }
640
641 /* Need to update time out of complete */
642 vStatus = vos_wait_single_event( &pVosContext->wdaCompleteEvent, 1000);
643 if ( vStatus != VOS_STATUS_SUCCESS )
644 {
645 if ( vStatus == VOS_STATUS_E_TIMEOUT )
646 {
647 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
648 "%s: Timeout occurred before WDA complete",__func__);
649 }
650 else
651 {
652 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
653 "%s: WDA_preStart reporting other error",__func__);
654 }
655 VOS_ASSERT( 0 );
656 return VOS_STATUS_E_FAILURE;
657 }
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(&(pVosContext->wdaCompleteEvent), 1000 * 30);
669
670 if ( vStatus != VOS_STATUS_SUCCESS )
671 {
672 if ( vStatus == VOS_STATUS_E_TIMEOUT )
673 {
674 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
675 "%s: Timeout occurred before WDA_NVDownload_Start complete",__func__);
676 }
677 else
678 {
679 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
680 "%s: WDA_NVDownload_Start reporting other error",__func__);
681 }
682 VOS_ASSERT(0);
683 return VOS_STATUS_E_FAILURE;
684 }
685
686 vStatus = WDA_start(pVosContext);
687 if (vStatus != VOS_STATUS_SUCCESS)
688 {
689 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
690 "%s: Failed to start WDA",__func__);
691 return VOS_STATUS_E_FAILURE;
692 }
693
694 /** START TL */
695 vStatus = WLANTL_Start(pVosContext);
696 if (!VOS_IS_STATUS_SUCCESS(vStatus))
697 {
698 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
699 "%s: Failed to start TL", __func__);
700 goto err_wda_stop;
701 }
702
703 return VOS_STATUS_SUCCESS;
704
705err_wda_stop:
706 vos_event_reset(&(pVosContext->wdaCompleteEvent));
707 WDA_stop(pVosContext, HAL_STOP_TYPE_RF_KILL);
708 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000);
709 if(vStatus != VOS_STATUS_SUCCESS)
710 {
711 if(vStatus == VOS_STATUS_E_TIMEOUT)
712 {
713 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
714 "%s: Timeout occurred before WDA_stop complete",__func__);
715
716 }
717 else
718 {
719 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
720 "%s: WDA_stop reporting other error",__func__);
721 }
722 VOS_ASSERT(0);
723 }
724 return VOS_STATUS_E_FAILURE;
725}
726
727VOS_STATUS vos_mon_stop( v_CONTEXT_t vosContext )
728{
729 VOS_STATUS vosStatus;
730
731 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
732
Bhargav Shah1ae5de02015-07-20 13:32:31 +0530733 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
734 "%s: HAL_STOP is requested", __func__);
735
Katya Nigame7b69a82015-04-28 15:24:06 +0530736 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
737
738 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
739 {
740 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
741 "%s: Failed to stop WDA", __func__);
742 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
743 WDA_setNeedShutdown(vosContext);
744 }
745 else
746 {
747 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
748 VOS_WDA_STOP_TIMEOUT );
749
750 if ( vosStatus != VOS_STATUS_SUCCESS )
751 {
752 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
753 {
754 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
755 "%s: Timeout occurred before WDA complete", __func__);
756 }
757 else
758 {
759 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
760 "%s: WDA_stop reporting other error", __func__ );
761 }
762 WDA_setNeedShutdown(vosContext);
763 }
764 }
765
766 vosStatus = WLANTL_Stop( vosContext );
767 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
768 {
769 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
770 "%s: Failed to stop TL", __func__);
771 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
772 }
773
774 return VOS_STATUS_SUCCESS;
775}
776
Jeff Johnson295189b2012-06-20 16:38:30 -0700777/*---------------------------------------------------------------------------
778
779 \brief vos_start() - Start the Libra SW Modules
780
781 The \a vos_start() function starts all the components of the Libra SW
782 including:
783 - SAL/BAL, which in turn starts SSC
784
785 - the MAC (HAL and PE)
786
787 - SME
788
789 - TL
790
791 - SYS: triggers the CFG download
792
793
794 \param pVosContext: The VOS context
795
796
797 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
798 is ready to be used.
799
800 VOS_STATUS_E_RESOURCES - System resources (other than memory)
801 are unavailable to initilize the scheduler
802
803
804 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
805
806 \sa vos_preStart()
807 \sa vos_open()
808
809---------------------------------------------------------------------------*/
810VOS_STATUS vos_start( v_CONTEXT_t vosContext )
811{
812 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
813 tSirRetStatus sirStatus = eSIR_SUCCESS;
814 pVosContextType pVosContext = (pVosContextType)vosContext;
815 tHalMacStartParameters halStartParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700816
817 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
818 "%s: Starting Libra SW", __func__);
819
820 /* We support only one instance for now ...*/
821 if (gpVosContext != pVosContext)
822 {
823 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700824 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 return VOS_STATUS_E_FAILURE;
826 }
827
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
829 || ( pVosContext->pTLContext == NULL))
830 {
831 if (pVosContext->pWDAContext == NULL)
832 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700833 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 else if (pVosContext->pMACContext == NULL)
835 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700836 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 else
838 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700839 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700840
841 return VOS_STATUS_E_FAILURE;
842 }
843
844 /* WDA_Start will be called after NV image download because the
845 NV image data has to be updated at HAL before HAL_Start gets executed*/
846
847 /* Start the NV Image Download */
848
849 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
850
851 vStatus = WDA_NVDownload_Start(pVosContext);
852
853 if ( vStatus != VOS_STATUS_SUCCESS )
854 {
855 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
856 "%s: Failed to start NV Download", __func__);
857 return VOS_STATUS_E_FAILURE;
858 }
859
860 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
861 VOS_WDA_TIMEOUT );
862
863 if ( vStatus != VOS_STATUS_SUCCESS )
864 {
865 if ( vStatus == VOS_STATUS_E_TIMEOUT )
866 {
867 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
868 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
869 }
870 else
871 {
872 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
873 "%s: WDA_NVDownload_start reporting other error", __func__);
874 }
875 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800876 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700877 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
878 {
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530879 if (isSsrPanicOnFailure())
880 VOS_BUG(0);
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700881 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800882 WDA_setNeedShutdown(vosContext);
883 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 }
885
886 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
887 "%s: WDA_NVDownload_start correctly started", __func__);
888
889 /* Start the WDA */
890 vStatus = WDA_start(pVosContext);
891 if ( vStatus != VOS_STATUS_SUCCESS )
892 {
893 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530894 "%s: Failed to start WDA - WDA_shutdown needed %d ",
895 __func__, vStatus);
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530896 if ( vStatus == VOS_STATUS_E_TIMEOUT )
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530897 {
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530898 WDA_setNeedShutdown(vosContext);
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530899 }
900 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 return VOS_STATUS_E_FAILURE;
902 }
903 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
904 "%s: WDA correctly started", __func__);
905
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 /* Start the MAC */
907 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
908
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 /* Start the MAC */
910 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 if (eSIR_SUCCESS != sirStatus)
913 {
914 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
915 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 }
918
919 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
920 "%s: MAC correctly started", __func__);
921
922 /* START SME */
923 vStatus = sme_Start(pVosContext->pMACContext);
924
925 if (!VOS_IS_STATUS_SUCCESS(vStatus))
926 {
927 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
928 "%s: Failed to start SME", __func__);
929 goto err_mac_stop;
930 }
931
932 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
933 "%s: SME correctly started", __func__);
934
935 /** START TL */
936 vStatus = WLANTL_Start(pVosContext);
937 if (!VOS_IS_STATUS_SUCCESS(vStatus))
938 {
939 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
940 "%s: Failed to start TL", __func__);
941 goto err_sme_stop;
942 }
943
944 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
945 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
947 "%s: VOSS Start is successful!!", __func__);
948
949 return VOS_STATUS_SUCCESS;
950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951
952err_sme_stop:
Kiet Lama72a2322013-11-15 11:18:11 +0530953 sme_Stop(pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700954
955err_mac_stop:
956 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
957
Jeff Johnson295189b2012-06-20 16:38:30 -0700958err_wda_stop:
959 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800960 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
961 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800963 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
964 "%s: Failed to stop WDA", __func__);
965 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800966 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800967 }
968 else
969 {
970 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
971 VOS_WDA_TIMEOUT );
972 if( vStatus != VOS_STATUS_SUCCESS )
973 {
974 if( vStatus == VOS_STATUS_E_TIMEOUT )
975 {
976 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
977 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800979 }
980 else
981 {
982 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
983 "%s: WDA_stop reporting other error", __func__);
984 }
985 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800986 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800987 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700989
990 return VOS_STATUS_E_FAILURE;
991
992} /* vos_start() */
993
994
995/* vos_stop function */
996VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
997{
998 VOS_STATUS vosStatus;
999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 /* WDA_Stop is called before the SYS so that the processing of Riva
1001 pending responces will not be handled during uninitialization of WLAN driver */
1002 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
1003
1004 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
1005
1006 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1007 {
1008 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1009 "%s: Failed to stop WDA", __func__);
1010 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001011 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -07001013 else
1014 {
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301015 if(wcnss_device_is_shutdown())
1016 {
1017 vosStatus = VOS_STATUS_E_TIMEOUT;
1018 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1019 "%s: Wait for WDA_Stop complete event not needed due to SSR",
1020 __func__);
1021 }
1022 else
1023 {
1024 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001025 VOS_WDA_STOP_TIMEOUT );
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001027
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001028 if ( vosStatus != VOS_STATUS_SUCCESS )
1029 {
1030 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1031 {
1032 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1033 "%s: Timeout occurred before WDA complete", __func__);
1034 }
1035 else
1036 {
1037 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1038 "%s: WDA_stop reporting other error", __func__ );
1039 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -07001040 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1041 "%s: Test MC thread by posting a probe message to SYS", __func__);
1042 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001043 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
1047 /* SYS STOP will stop SME and MAC */
1048 vosStatus = sysStop( vosContext);
1049 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1050 {
1051 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1052 "%s: Failed to stop SYS", __func__);
1053 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1054 }
1055
1056 vosStatus = WLANTL_Stop( vosContext );
1057 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1058 {
1059 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1060 "%s: Failed to stop TL", __func__);
1061 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1062 }
1063
Jeff Johnson295189b2012-06-20 16:38:30 -07001064
1065 return VOS_STATUS_SUCCESS;
1066}
1067
1068
1069/* vos_close function */
1070VOS_STATUS vos_close( v_CONTEXT_t vosContext )
1071{
1072 VOS_STATUS vosStatus;
1073
1074#ifdef WLAN_BTAMP_FEATURE
1075 vosStatus = WLANBAP_Close(vosContext);
1076 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1077 {
1078 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1079 "%s: Failed to close BAP", __func__);
1080 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1081 }
1082#endif // WLAN_BTAMP_FEATURE
1083
1084
1085 vosStatus = WLANTL_Close(vosContext);
1086 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1087 {
1088 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1089 "%s: Failed to close TL", __func__);
1090 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1091 }
1092
1093 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1094 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1095 {
1096 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1097 "%s: Failed to close SME", __func__);
1098 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1099 }
1100
1101 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1102 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1103 {
1104 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1105 "%s: Failed to close MAC", __func__);
1106 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1107 }
1108
1109 ((pVosContextType)vosContext)->pMACContext = NULL;
1110
Amar Singhal0a402232013-10-11 20:57:16 -07001111#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 vosStatus = vos_nv_close();
1113 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1114 {
1115 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1116 "%s: Failed to close NV", __func__);
1117 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1118 }
Amar Singhal0a402232013-10-11 20:57:16 -07001119#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001120
1121 vosStatus = sysClose( vosContext );
1122 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1123 {
1124 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1125 "%s: Failed to close SYS", __func__);
1126 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1127 }
1128
Jeff Johnsone7245742012-09-05 17:12:55 -07001129 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001131 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
1132 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
1133 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
1134 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07001135 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -07001136 }
1137 else
1138 {
1139 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1140 "%s: Failed to shutdown WDA", __func__ );
1141 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1142 }
1143 }
1144 else
1145 {
1146 vosStatus = WDA_close( vosContext );
1147 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1148 {
1149 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1150 "%s: Failed to close WDA", __func__);
1151 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 }
1154
1155 /* Let DXE return packets in WDA_close and then free them here */
1156 vosStatus = vos_packet_close( vosContext );
1157 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1158 {
1159 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1160 "%s: Failed to close VOSS Packet", __func__);
1161 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001163
Jeff Johnson295189b2012-06-20 16:38:30 -07001164
1165 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1166
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301167 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
1168 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1169 {
1170 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1171 "%s: failed to destroy fwLogsComplete", __func__);
1172 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1173 }
1174
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1176 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1177 {
1178 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1179 "%s: failed to destroy wdaCompleteEvent", __func__);
1180 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001182
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301183
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1185 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1186 {
1187 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1188 "%s: failed to destroy ProbeEvent", __func__);
1189 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1190 }
1191
Girish Gowlifb0bfd32015-01-13 11:42:11 +05301192 if (gpVosContext->roamDelayStatsEnabled &&
1193 !vos_roam_delay_stats_deinit())
1194 {
1195 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1196 "%s: Could not deinit roamDelayStats", __func__);
1197 }
1198
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 return VOS_STATUS_SUCCESS;
1200}
1201
1202
1203/**---------------------------------------------------------------------------
1204
1205 \brief vos_get_context() - get context data area
1206
1207 Each module in the system has a context / data area that is allocated
1208 and maanged by voss. This API allows any user to get a pointer to its
1209 allocated context data area from the VOSS global context.
1210
1211 \param vosContext - the VOSS Global Context.
1212
1213 \param moduleId - the module ID, who's context data are is being retrived.
1214
1215 \return - pointer to the context data area.
1216
1217 - NULL if the context data is not allocated for the module ID
1218 specified
1219
1220 --------------------------------------------------------------------------*/
1221v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1222 v_CONTEXT_t pVosContext )
1223{
1224 v_PVOID_t pModContext = NULL;
1225
1226 if (pVosContext == NULL)
1227 {
1228 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001229 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 return NULL;
1231 }
1232
1233 if (gpVosContext != pVosContext)
1234 {
1235 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001236 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 return NULL;
1238 }
1239
1240 switch(moduleId)
1241 {
1242 case VOS_MODULE_ID_TL:
1243 {
1244 pModContext = gpVosContext->pTLContext;
1245 break;
1246 }
1247
Jeff Johnson295189b2012-06-20 16:38:30 -07001248#ifdef WLAN_BTAMP_FEATURE
1249 case VOS_MODULE_ID_BAP:
1250 {
1251 pModContext = gpVosContext->pBAPContext;
1252 break;
1253 }
1254#endif //WLAN_BTAMP_FEATURE
1255
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 case VOS_MODULE_ID_SAP:
1257 {
1258 pModContext = gpVosContext->pSAPContext;
1259 break;
1260 }
1261
1262 case VOS_MODULE_ID_HDD_SOFTAP:
1263 {
1264 pModContext = gpVosContext->pHDDSoftAPContext;
1265 break;
1266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001267
1268 case VOS_MODULE_ID_HDD:
1269 {
1270 pModContext = gpVosContext->pHDDContext;
1271 break;
1272 }
1273
1274 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301276 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 {
1278 /*
1279 ** In all these cases, we just return the MAC Context
1280 */
1281 pModContext = gpVosContext->pMACContext;
1282 break;
1283 }
1284
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 case VOS_MODULE_ID_WDA:
1286 {
1287 /* For WDA module */
1288 pModContext = gpVosContext->pWDAContext;
1289 break;
1290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001291
1292 case VOS_MODULE_ID_VOSS:
1293 {
1294 /* For SYS this is VOS itself*/
1295 pModContext = gpVosContext;
1296 break;
1297 }
1298
1299 default:
1300 {
1301 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1302 "does not have its context maintained by VOSS", __func__, moduleId);
1303 VOS_ASSERT(0);
1304 return NULL;
1305 }
1306 }
1307
1308 if (pModContext == NULL )
1309 {
1310 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1311 "context is Null", __func__, moduleId);
1312 }
1313
1314 return pModContext;
1315
1316} /* vos_get_context()*/
1317
1318
1319/**---------------------------------------------------------------------------
1320
1321 \brief vos_get_global_context() - get VOSS global Context
1322
1323 This API allows any user to get the VOS Global Context pointer from a
1324 module context data area.
1325
1326 \param moduleContext - the input module context pointer
1327
1328 \param moduleId - the module ID who's context pointer is input in
1329 moduleContext.
1330
1331 \return - pointer to the VOSS global context
1332
1333 - NULL if the function is unable to retreive the VOSS context.
1334
1335 --------------------------------------------------------------------------*/
1336v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1337 v_VOID_t *moduleContext )
1338{
1339 if (gpVosContext == NULL)
1340 {
1341 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001342 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 }
1344
1345 return gpVosContext;
1346
1347} /* vos_get_global_context() */
1348
1349
1350v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1351{
1352 if (gpVosContext == NULL)
1353 {
1354 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001355 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 return 1;
1357 }
1358
1359 return gpVosContext->isLogpInProgress;
1360}
1361
1362void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1363{
1364 if (gpVosContext == NULL)
1365 {
1366 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001367 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 return;
1369 }
1370
1371 gpVosContext->isLogpInProgress = value;
1372}
1373
1374v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1375{
1376 if (gpVosContext == NULL)
1377 {
1378 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001379 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 return 0;
1381 }
1382
1383 return gpVosContext->isLoadUnloadInProgress;
1384}
1385
1386void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1387{
1388 if (gpVosContext == NULL)
1389 {
1390 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001391 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 return;
1393 }
1394
1395 gpVosContext->isLoadUnloadInProgress = value;
1396}
1397
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001398v_U8_t vos_is_reinit_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1399{
1400 if (gpVosContext == NULL)
1401 {
1402 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1403 "%s: global voss context is NULL", __func__);
1404 return 1;
1405 }
1406
1407 return gpVosContext->isReInitInProgress;
1408}
1409
1410void vos_set_reinit_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1411{
1412 if (gpVosContext == NULL)
1413 {
1414 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1415 "%s: global voss context is NULL", __func__);
1416 return;
1417 }
1418
1419 gpVosContext->isReInitInProgress = value;
1420}
1421
1422
Jeff Johnson295189b2012-06-20 16:38:30 -07001423/**---------------------------------------------------------------------------
1424
1425 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1426
1427 This API allows any user to allocate a user context area within the
1428 VOS Global Context.
1429
1430 \param pVosContext - pointer to the global Vos context
1431
1432 \param moduleId - the module ID who's context area is being allocated.
1433
1434 \param ppModuleContext - pointer to location where the pointer to the
1435 allocated context is returned. Note this
1436 output pointer is valid only if the API
1437 returns VOS_STATUS_SUCCESS
1438
1439 \param size - the size of the context area to be allocated.
1440
1441 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1442 allocated successfully. The pointer to the context area
1443 can be found in *ppModuleContext.
1444 \note This function returns VOS_STATUS_SUCCESS if the
1445 module context was already allocated and the size
1446 allocated matches the size on this call.
1447
1448 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1449 not identify a module that can have a context allocated.
1450
1451 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1452 because a context for this module ID already exists and it is
1453 a *different* size that specified on this call.
1454
1455 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1456 requested context area.
1457
1458 \sa vos_get_context(), vos_free_context()
1459
1460 --------------------------------------------------------------------------*/
1461VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1462 v_VOID_t **ppModuleContext, v_SIZE_t size )
1463{
1464 v_VOID_t ** pGpModContext = NULL;
1465
1466 if ( pVosContext == NULL) {
1467 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001468 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 return VOS_STATUS_E_FAILURE;
1470 }
1471
1472 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1473 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001474 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 return VOS_STATUS_E_FAILURE;
1476 }
1477
1478 switch(moduleID)
1479 {
1480 case VOS_MODULE_ID_TL:
1481 {
1482 pGpModContext = &(gpVosContext->pTLContext);
1483 break;
1484 }
1485
Jeff Johnson295189b2012-06-20 16:38:30 -07001486#ifdef WLAN_BTAMP_FEATURE
1487 case VOS_MODULE_ID_BAP:
1488 {
1489 pGpModContext = &(gpVosContext->pBAPContext);
1490 break;
1491 }
1492#endif //WLAN_BTAMP_FEATURE
1493
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 case VOS_MODULE_ID_SAP:
1495 {
1496 pGpModContext = &(gpVosContext->pSAPContext);
1497 break;
1498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001499
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 case VOS_MODULE_ID_WDA:
1501 {
1502 pGpModContext = &(gpVosContext->pWDAContext);
1503 break;
1504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301507 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 default:
1511 {
1512 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1513 "does not have its context allocated by VOSS", __func__, moduleID);
1514 VOS_ASSERT(0);
1515 return VOS_STATUS_E_INVAL;
1516 }
1517 }
1518
1519 if ( NULL != *pGpModContext)
1520 {
1521 /*
1522 ** Context has already been allocated!
1523 ** Prevent double allocation
1524 */
1525 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1526 "%s: Module ID %i context has already been allocated",
1527 __func__, moduleID);
1528 return VOS_STATUS_E_EXISTS;
1529 }
1530
1531 /*
1532 ** Dynamically allocate the context for module
1533 */
1534
1535 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1536
1537
1538 if ( *ppModuleContext == NULL)
1539 {
1540 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1541 "allocate Context for module ID %i", __func__, moduleID);
1542 VOS_ASSERT(0);
1543 return VOS_STATUS_E_NOMEM;
1544 }
1545
1546 if (moduleID==VOS_MODULE_ID_TL)
1547 {
1548 vos_mem_zero(*ppModuleContext, size);
1549 }
1550
1551 *pGpModContext = *ppModuleContext;
1552
1553 return VOS_STATUS_SUCCESS;
1554
1555} /* vos_alloc_context() */
1556
1557
1558/**---------------------------------------------------------------------------
1559
1560 \brief vos_free_context() - free an allocated a context within the
1561 VOSS global Context
1562
1563 This API allows a user to free the user context area within the
1564 VOS Global Context.
1565
1566 \param pVosContext - pointer to the global Vos context
1567
1568 \param moduleId - the module ID who's context area is being free
1569
1570 \param pModuleContext - pointer to module context area to be free'd.
1571
1572 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1573 free'd. The pointer to the context area is not longer
1574 available.
1575
1576 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1577 valid pointers.
1578
1579 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1580 not identify a module that can have a context free'd.
1581
1582 VOS_STATUS_E_EXISTS - vos could not free the requested
1583 context area because a context for this module ID does not
1584 exist in the global vos context.
1585
1586 \sa vos_get_context()
1587
1588 --------------------------------------------------------------------------*/
1589VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1590 v_VOID_t *pModuleContext )
1591{
1592 v_VOID_t ** pGpModContext = NULL;
1593
1594 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1595 ( pModuleContext == NULL))
1596 {
1597 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1598 "%s: Null params or context mismatch", __func__);
1599 return VOS_STATUS_E_FAILURE;
1600 }
1601
1602
1603 switch(moduleID)
1604 {
1605 case VOS_MODULE_ID_TL:
1606 {
1607 pGpModContext = &(gpVosContext->pTLContext);
1608 break;
1609 }
1610
Jeff Johnson295189b2012-06-20 16:38:30 -07001611#ifdef WLAN_BTAMP_FEATURE
1612 case VOS_MODULE_ID_BAP:
1613 {
1614 pGpModContext = &(gpVosContext->pBAPContext);
1615 break;
1616 }
1617#endif //WLAN_BTAMP_FEATURE
1618
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 case VOS_MODULE_ID_SAP:
1620 {
1621 pGpModContext = &(gpVosContext->pSAPContext);
1622 break;
1623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001624
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 case VOS_MODULE_ID_WDA:
1626 {
1627 pGpModContext = &(gpVosContext->pWDAContext);
1628 break;
1629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 case VOS_MODULE_ID_HDD:
1631 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301633 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 default:
1636 {
1637 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1638 "does not have its context allocated by VOSS", __func__, moduleID);
1639 VOS_ASSERT(0);
1640 return VOS_STATUS_E_INVAL;
1641 }
1642 }
1643
1644 if ( NULL == *pGpModContext)
1645 {
1646 /*
1647 ** Context has not been allocated or freed already!
1648 */
1649 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1650 "context has not been allocated or freed already", __func__,moduleID);
1651 return VOS_STATUS_E_FAILURE;
1652 }
1653
1654 if (*pGpModContext != pModuleContext)
1655 {
1656 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001657 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 return VOS_STATUS_E_FAILURE;
1659 }
1660
1661 if(pModuleContext != NULL)
1662 kfree(pModuleContext);
1663
1664 *pGpModContext = NULL;
1665
1666 return VOS_STATUS_SUCCESS;
1667
1668} /* vos_free_context() */
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301669
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301670
1671bool vos_is_log_report_in_progress(void)
1672{
1673 return wlan_is_log_report_in_progress();
1674}
1675
1676void vos_reset_log_report_in_progress(void)
1677{
1678 return wlan_reset_log_report_in_progress();
1679}
1680
1681
1682
1683
1684int vos_set_log_completion(uint32 is_fatal,
1685 uint32 indicator,
1686 uint32 reason_code)
1687{
1688 return wlan_set_log_completion(is_fatal,
1689 indicator,reason_code);
1690}
1691
1692void vos_get_log_completion(uint32 *is_fatal,
1693 uint32 *indicator,
1694 uint32 *reason_code)
1695{
1696 wlan_get_log_completion(is_fatal, indicator, reason_code);
1697}
1698
1699
1700
1701void vos_send_fatal_event_done(void)
1702{
1703 /*Complete the fwLogsComplete Event*/
1704 VosContextType *vos_context;
1705 uint32_t is_fatal, indicator, reason_code;
1706
1707 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1708 if (!vos_context) {
1709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1710 "%s: vos context is Invalid", __func__);
1711 return;
1712 }
1713 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1714 "%s: vos_event_set for fwLogsComplete", __func__);
1715 if (vos_event_set(&vos_context->fwLogsComplete)!= VOS_STATUS_SUCCESS)
1716 {
1717 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1718 "%s: vos_event_set failed for fwLogsComplete", __func__);
1719 return;
1720 }
1721 /*The below API will reset is_report_in_progress flag*/
1722 vos_get_log_completion(&is_fatal, &indicator, &reason_code);
1723 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1724 "%s: is_fatal : %d, indicator: %d, reason_code=%d",
1725 __func__, is_fatal, indicator, reason_code);
1726}
1727
1728
1729
1730/**---------------------------------------------------------------------------
1731
1732 \brief vos_fatal_event_logs_req() - used to send flush command to FW
1733
1734 This API is wrapper to SME flush API.
1735
1736 \param is_fatal - fatal or non fatal event
1737 indicator - Tyoe of indicator framework/Host/FW
1738 reason_code - reason code for flush logs
1739
1740 \return VOS_STATUS_SUCCESS - if command is sent successfully.
1741 VOS_STATUS_E_FAILURE - if command is not sent successfully.
1742 --------------------------------------------------------------------------*/
1743VOS_STATUS vos_fatal_event_logs_req( uint32_t is_fatal,
1744 uint32_t indicator,
1745 uint32_t reason_code,
1746 bool waitRequired)
1747{
1748 VOS_STATUS vosStatus;
1749 eHalStatus status;
1750 VosContextType *vos_context;
1751
1752 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1753 if (!vos_context)
1754 {
1755 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1756 "%s: vos context is Invalid", __func__);
1757 return eHAL_STATUS_FAILURE;
1758 }
1759
1760
1761 if (vos_is_log_report_in_progress() == true)
1762 {
1763 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1764 "%s: Fatal Event Req already in progress - dropping! type:%d, indicator=%d reason_code=%d",
1765 __func__, is_fatal, indicator, reason_code);
1766 return VOS_STATUS_E_FAILURE;
1767 }
1768
1769 vosStatus = vos_set_log_completion(is_fatal, indicator, reason_code);
1770 if (VOS_STATUS_SUCCESS != vosStatus) {
1771 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1772 "%s: Failed to set log trigger params for fatalEvent", __func__);
1773 return VOS_STATUS_E_FAILURE;
1774 }
1775 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1776 "%s: Triggering fatal Event: type:%d, indicator=%d reason_code=%d",
1777 __func__, is_fatal, indicator, reason_code);
1778
1779 vos_event_reset(&gpVosContext->fwLogsComplete);
1780 status = sme_fatal_event_logs_req(vos_context->pMACContext,
1781 is_fatal, indicator,
1782 reason_code);
1783
1784 if (HAL_STATUS_SUCCESS(status) && (waitRequired == TRUE))
1785 {
1786
1787 /* Need to update time out of complete */
1788 vosStatus = vos_wait_single_event(&gpVosContext->fwLogsComplete,
1789 WAIT_TIME_FW_LOGS);
1790 if ( vosStatus != VOS_STATUS_SUCCESS )
1791 {
1792 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1793 {
1794 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1795 "%s: Timeout occurred before fwLogsComplete", __func__);
1796 }
1797 else
1798 {
1799 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1800 "%s: fwLogsComplete reporting other error", __func__);
1801 }
1802 /*Done indication is not received.So reset the bug report in progress*/
1803 vos_reset_log_report_in_progress();
1804 return VOS_STATUS_E_FAILURE;
1805 }
1806 }
1807 if (HAL_STATUS_SUCCESS( status ))
1808 return VOS_STATUS_SUCCESS;
1809 else
1810 return VOS_STATUS_E_FAILURE;
1811}
1812
1813/**---------------------------------------------------------------------------
1814
1815 \brief vos_process_done_indication() - Process the done indication for fatal event,
1816 FW memory dump
1817
1818 This API processes the done indication and wakeup the logger thread accordingly.
1819
1820 \param type - Type for which done indication is received.
1821
1822
1823 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1824 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1825 a failure.
1826 --------------------------------------------------------------------------*/
1827
1828VOS_STATUS vos_process_done_indication(v_U8_t type, v_U32_t reason_code)
1829{
1830 wlan_process_done_indication(type, reason_code);
1831 return VOS_STATUS_SUCCESS;
1832}
1833
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301834/**---------------------------------------------------------------------------
1835
1836 \brief vos_logger_pkt_serialize() - queue a logging vos pkt
1837
1838 This API allows single vos pkt to be queued and later sent to userspace by
1839 logger thread.
1840
1841 \param pPacket - a pointer to a vos pkt to be queued
1842 pkt_type - type of pkt to be queued
1843 LOG_PKT_TYPE_DATA_MGMT - frame log i.e data/mgmt pkts
1844
1845 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1846 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1847 a failure.
1848 --------------------------------------------------------------------------*/
Mihir Sheteccafc0c2015-04-17 16:13:15 +05301849VOS_STATUS vos_logger_pkt_serialize( vos_pkt_t *pPacket, uint32 pkt_type)
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301850{
1851#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1852 return wlan_queue_logpkt_for_app(pPacket, pkt_type);
1853#else
1854 return vos_pkt_return_packet(pPacket);
1855#endif
1856}
Jeff Johnson295189b2012-06-20 16:38:30 -07001857
1858/**---------------------------------------------------------------------------
1859
1860 \brief vos_mq_post_message() - post a message to a message queue
1861
1862 This API allows messages to be posted to a specific message queue. Messages
1863 can be posted to the following message queues:
1864
1865 <ul>
1866 <li> SME
1867 <li> PE
1868 <li> HAL
1869 <li> TL
1870 </ul>
1871
1872 \param msgQueueId - identifies the message queue upon which the message
1873 will be posted.
1874
1875 \param message - a pointer to a message buffer. Memory for this message
1876 buffer is allocated by the caller and free'd by the vOSS after the
1877 message is posted to the message queue. If the consumer of the
1878 message needs anything in this message, it needs to copy the contents
1879 before returning from the message queue handler.
1880
1881 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1882 to the message queue.
1883
1884 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1885 refer to a valid Message Queue Id.
1886
1887 VOS_STATUS_E_FAULT - message is an invalid pointer.
1888
1889 VOS_STATUS_E_FAILURE - the message queue handler has reported
1890 an unknown failure.
1891
1892 \sa
1893
1894 --------------------------------------------------------------------------*/
1895VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1896{
1897 pVosMqType pTargetMq = NULL;
1898 pVosMsgWrapper pMsgWrapper = NULL;
1899
1900 if ((gpVosContext == NULL) || (pMsg == NULL))
1901 {
1902 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1903 "%s: Null params or global vos context is null", __func__);
1904 VOS_ASSERT(0);
1905 return VOS_STATUS_E_FAILURE;
1906 }
1907
1908 switch (msgQueueId)
1909 {
1910 /// Message Queue ID for messages bound for SME
1911 case VOS_MQ_ID_SME:
1912 {
1913 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1914 break;
1915 }
1916
1917 /// Message Queue ID for messages bound for PE
1918 case VOS_MQ_ID_PE:
1919 {
1920 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1921 break;
1922 }
1923
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 /// Message Queue ID for messages bound for WDA
1925 case VOS_MQ_ID_WDA:
1926 {
1927 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1928 break;
1929 }
1930
1931 /// Message Queue ID for messages bound for WDI
1932 case VOS_MQ_ID_WDI:
1933 {
1934 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1935 break;
1936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001937
1938 /// Message Queue ID for messages bound for TL
1939 case VOS_MQ_ID_TL:
1940 {
1941 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1942 break;
1943 }
1944
1945 /// Message Queue ID for messages bound for the SYS module
1946 case VOS_MQ_ID_SYS:
1947 {
1948 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1949 break;
1950 }
1951
1952 default:
1953
1954 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1955 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1956 __func__, msgQueueId);
1957
1958 return VOS_STATUS_E_FAILURE;
1959 }
1960
1961 VOS_ASSERT(NULL !=pTargetMq);
1962 if (pTargetMq == NULL)
1963 {
1964 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001965 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 return VOS_STATUS_E_FAILURE;
1967 }
1968
1969 /*
1970 ** Try and get a free Msg wrapper
1971 */
1972 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1973
1974 if (NULL == pMsgWrapper)
1975 {
1976 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1977 "%s: VOS Core run out of message wrapper", __func__);
1978
1979 return VOS_STATUS_E_RESOURCES;
1980 }
1981
1982 /*
1983 ** Copy the message now
1984 */
1985 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1986 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1987
1988 vos_mq_put(pTargetMq, pMsgWrapper);
1989
1990 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1991 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1992
1993 return VOS_STATUS_SUCCESS;
1994
1995} /* vos_mq_post_message()*/
1996
1997
1998/**---------------------------------------------------------------------------
1999
2000 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
2001
2002 This API allows messages to be posted to a specific message queue in the
2003 Tx excution flow. Messages for the Tx execution flow can be posted only
2004 to the following queue.
2005
2006 <ul>
2007 <li> TL
2008 <li> SSC/WDI
2009 </ul>
2010
2011 \param msgQueueId - identifies the message queue upon which the message
2012 will be posted.
2013
2014 \param message - a pointer to a message buffer. Body memory for this message
2015 buffer is allocated by the caller and free'd by the vOSS after the
2016 message is dispacthed to the appropriate component. If the consumer
2017 of the message needs to keep anything in the body, it needs to copy
2018 the contents before returning from the message handler.
2019
2020 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2021 to the message queue.
2022
2023 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2024 refer to a valid Message Queue Id.
2025
2026 VOS_STATUS_E_FAULT - message is an invalid pointer.
2027
2028 VOS_STATUS_E_FAILURE - the message queue handler has reported
2029 an unknown failure.
2030
2031 \sa
2032
2033 --------------------------------------------------------------------------*/
2034VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2035{
2036 pVosMqType pTargetMq = NULL;
2037 pVosMsgWrapper pMsgWrapper = NULL;
2038
2039 if ((gpVosContext == NULL) || (pMsg == NULL))
2040 {
2041 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2042 "%s: Null params or global vos context is null", __func__);
2043 VOS_ASSERT(0);
2044 return VOS_STATUS_E_FAILURE;
2045 }
2046
2047 switch (msgQueueId)
2048 {
2049 /// Message Queue ID for messages bound for SME
2050 case VOS_MQ_ID_TL:
2051 {
2052 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
2053 break;
2054 }
2055
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 /// Message Queue ID for messages bound for SSC
2057 case VOS_MQ_ID_WDI:
2058 {
2059 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
2060 break;
2061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002062
2063 /// Message Queue ID for messages bound for the SYS module
2064 case VOS_MQ_ID_SYS:
2065 {
2066 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
2067 break;
2068 }
2069
2070 default:
2071
2072 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302073 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 __func__, msgQueueId);
2075
2076 return VOS_STATUS_E_FAILURE;
2077 }
2078
2079 if (pTargetMq == NULL)
2080 {
2081 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002082 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 return VOS_STATUS_E_FAILURE;
2084 }
2085
2086
2087 /*
2088 ** Try and get a free Msg wrapper
2089 */
2090 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2091
2092 if (NULL == pMsgWrapper)
2093 {
2094 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2095 "%s: VOS Core run out of message wrapper", __func__);
2096
2097 return VOS_STATUS_E_RESOURCES;
2098 }
2099
2100 /*
2101 ** Copy the message now
2102 */
2103 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2104 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2105
2106 vos_mq_put(pTargetMq, pMsgWrapper);
2107
2108 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
2109 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
2110
2111 return VOS_STATUS_SUCCESS;
2112
2113} /* vos_tx_mq_serialize()*/
2114
Jeff Johnson295189b2012-06-20 16:38:30 -07002115/**---------------------------------------------------------------------------
2116
2117 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
2118
2119 This API allows messages to be posted to a specific message queue in the
2120 Tx excution flow. Messages for the Rx execution flow can be posted only
2121 to the following queue.
2122
2123 <ul>
2124 <li> TL
2125 <li> WDI
2126 </ul>
2127
2128 \param msgQueueId - identifies the message queue upon which the message
2129 will be posted.
2130
2131 \param message - a pointer to a message buffer. Body memory for this message
2132 buffer is allocated by the caller and free'd by the vOSS after the
2133 message is dispacthed to the appropriate component. If the consumer
2134 of the message needs to keep anything in the body, it needs to copy
2135 the contents before returning from the message handler.
2136
2137 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2138 to the message queue.
2139
2140 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2141 refer to a valid Message Queue Id.
2142
2143 VOS_STATUS_E_FAULT - message is an invalid pointer.
2144
2145 VOS_STATUS_E_FAILURE - the message queue handler has reported
2146 an unknown failure.
2147
2148 \sa
2149
2150 --------------------------------------------------------------------------*/
2151
2152VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2153{
2154 pVosMqType pTargetMq = NULL;
2155 pVosMsgWrapper pMsgWrapper = NULL;
2156 if ((gpVosContext == NULL) || (pMsg == NULL))
2157 {
2158 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2159 "%s: Null params or global vos context is null", __func__);
2160 VOS_ASSERT(0);
2161 return VOS_STATUS_E_FAILURE;
2162 }
2163
2164 switch (msgQueueId)
2165 {
2166
2167 case VOS_MQ_ID_SYS:
2168 {
2169 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
2170 break;
2171 }
2172
2173 /// Message Queue ID for messages bound for WDI
2174 case VOS_MQ_ID_WDI:
2175 {
2176 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
2177 break;
2178 }
Katya Nigam664f5032014-05-05 12:24:32 +05302179 case VOS_MQ_ID_TL:
2180 {
2181 pTargetMq = &(gpVosContext->vosSched.tlRxMq);
2182 break;
2183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002184
2185 default:
2186
2187 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302188 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 __func__, msgQueueId);
2190
2191 return VOS_STATUS_E_FAILURE;
2192 }
2193
2194 if (pTargetMq == NULL)
2195 {
2196 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002197 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 return VOS_STATUS_E_FAILURE;
2199 }
2200
2201
2202 /*
2203 ** Try and get a free Msg wrapper
2204 */
2205 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2206
2207 if (NULL == pMsgWrapper)
2208 {
2209 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2210 "%s: VOS Core run out of message wrapper", __func__);
2211
2212 return VOS_STATUS_E_RESOURCES;
2213 }
2214
2215 /*
2216 ** Copy the message now
2217 */
2218 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2219 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2220
2221 vos_mq_put(pTargetMq, pMsgWrapper);
2222
2223 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
2224 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
2225
2226 return VOS_STATUS_SUCCESS;
2227
2228} /* vos_rx_mq_serialize()*/
2229
Jeff Johnson295189b2012-06-20 16:38:30 -07002230v_VOID_t
2231vos_sys_probe_thread_cback
2232(
2233 v_VOID_t *pUserData
2234)
2235{
2236 if (gpVosContext != pUserData)
2237 {
2238 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002239 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 return;
2241 }
2242
2243 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2244 {
2245 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002246 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 return;
2248 }
2249
2250} /* vos_sys_probe_thread_cback() */
2251
Jeff Johnson295189b2012-06-20 16:38:30 -07002252v_VOID_t vos_WDAComplete_cback
2253(
2254 v_VOID_t *pUserData
2255)
2256{
2257
2258 if (gpVosContext != pUserData)
2259 {
2260 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002261 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 return;
2263 }
2264
2265 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
2266 {
2267 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002268 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 return;
2270 }
2271
2272} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
2274v_VOID_t vos_core_return_msg
2275(
2276 v_PVOID_t pVContext,
2277 pVosMsgWrapper pMsgWrapper
2278)
2279{
2280 pVosContextType pVosContext = (pVosContextType) pVContext;
2281
2282 VOS_ASSERT( gpVosContext == pVosContext);
2283
2284 if (gpVosContext != pVosContext)
2285 {
2286 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002287 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 return;
2289 }
2290
2291 VOS_ASSERT( NULL !=pMsgWrapper );
2292
2293 if (pMsgWrapper == NULL)
2294 {
2295 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002296 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 return;
2298 }
2299
2300 /*
2301 ** Return the message on the free message queue
2302 */
2303 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
2304 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
2305
2306} /* vos_core_return_msg() */
2307
2308
2309/**
2310 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
2311 TL config params from the registry
2312
2313 @param pAdapter : [inout] pointer to TL config block
2314
2315 @return
2316 None
2317
2318*/
2319v_VOID_t
2320vos_fetch_tl_cfg_parms
2321(
2322 WLANTL_ConfigInfoType *pTLConfig,
2323 hdd_config_t * pConfig
2324)
2325{
2326 if (pTLConfig == NULL)
2327 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002328 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 return;
2330 }
2331
2332 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
2333 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
2334 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
2335 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302336 pTLConfig->ucAcWeights[4] = pConfig->WfqVoWeight;
Dhanashri Atred8c20a32014-01-03 17:20:55 -08002337 pTLConfig->ucReorderAgingTime[0] = pConfig->BkReorderAgingTime;/*WLANTL_AC_BK*/
2338 pTLConfig->ucReorderAgingTime[1] = pConfig->BeReorderAgingTime;/*WLANTL_AC_BE*/
2339 pTLConfig->ucReorderAgingTime[2] = pConfig->ViReorderAgingTime;/*WLANTL_AC_VI*/
2340 pTLConfig->ucReorderAgingTime[3] = pConfig->VoReorderAgingTime;/*WLANTL_AC_VO*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07002343
2344}
2345
2346v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
2347{
2348 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
2349}
2350
Jeff Johnson295189b2012-06-20 16:38:30 -07002351/*---------------------------------------------------------------------------
2352
2353 \brief vos_shutdown() - shutdown VOS
2354
2355 - All VOS submodules are closed.
2356
2357 - All the WLAN SW components should have been opened. This includes
2358 SYS, MAC, SME and TL.
2359
2360
2361 \param vosContext: Global vos context
2362
2363
2364 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
2365
2366 VOS_STATUS_E_FAILURE - Failure to close
2367
2368---------------------------------------------------------------------------*/
2369VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2370{
2371 VOS_STATUS vosStatus;
2372
2373#ifdef WLAN_BTAMP_FEATURE
2374 vosStatus = WLANBAP_Close(vosContext);
2375 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2376 {
2377 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2378 "%s: Failed to close BAP", __func__);
2379 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2380 }
2381#endif // WLAN_BTAMP_FEATURE
2382
2383 vosStatus = WLANTL_Close(vosContext);
2384 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2385 {
2386 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2387 "%s: Failed to close TL", __func__);
2388 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2389 }
2390
2391 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2392 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2393 {
2394 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2395 "%s: Failed to close SME", __func__);
2396 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2397 }
2398
2399 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2400 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2401 {
2402 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2403 "%s: Failed to close MAC", __func__);
2404 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2405 }
2406
2407 ((pVosContextType)vosContext)->pMACContext = NULL;
2408
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 vosStatus = sysClose( vosContext );
2410 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2411 {
2412 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2413 "%s: Failed to close SYS", __func__);
2414 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2415 }
2416
2417 /* Let DXE return packets in WDA_close and then free them here */
2418 vosStatus = vos_packet_close( vosContext );
2419 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2420 {
2421 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2422 "%s: Failed to close VOSS Packet", __func__);
2423 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2424 }
2425
2426 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2427
Sachin Ahuja715aafc2015-07-21 23:35:10 +05302428 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
2429 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2430 {
2431 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2432 "%s: failed to destroy fwLogsComplete", __func__);
2433 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2434 }
2435
2436
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2438 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2439 {
2440 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2441 "%s: failed to destroy wdaCompleteEvent", __func__);
2442 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2443 }
2444
2445 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2446 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2447 {
2448 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2449 "%s: failed to destroy ProbeEvent", __func__);
2450 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2451 }
2452
2453 return VOS_STATUS_SUCCESS;
2454}
2455
2456/*---------------------------------------------------------------------------
2457
2458 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2459
2460 - WDA/WDI shutdown
2461
2462 \param vosContext: Global vos context
2463
2464
2465 \return VOS_STATUS_SUCCESS - Operation successfull
2466
2467 VOS_STATUS_E_FAILURE - Failure to close
2468
2469---------------------------------------------------------------------------*/
2470VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2471{
2472 VOS_STATUS vosStatus;
2473 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2474
2475 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2476 {
2477 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2478 "%s: failed to shutdown WDA", __func__);
2479 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2480 }
2481 return vosStatus;
2482}
2483/**
2484 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2485
2486 This function is called when Riva subsystem crashes. There are two
2487 methods (or operations) in WLAN driver to handle Riva crash,
2488 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2489 driver without handshaking with Riva.
2490 2. re-init: Next API
2491 @param
2492 NONE
2493 @return
2494 VOS_STATUS_SUCCESS - Operation completed successfully.
2495 VOS_STATUS_E_FAILURE - Operation failed.
2496
2497*/
2498VOS_STATUS vos_wlanShutdown(void)
2499{
2500 VOS_STATUS vstatus;
2501 vstatus = vos_watchdog_wlan_shutdown();
2502 return vstatus;
2503}
2504/**
2505 @brief vos_wlanReInit() - This API will re-init WLAN driver
2506
2507 This function is called when Riva subsystem reboots. There are two
2508 methods (or operations) in WLAN driver to handle Riva crash,
2509 1. shutdown: Previous API
2510 2. re-init: Called when Riva comes back after the crash. This will
2511 re-initialize WLAN driver. In some cases re-open may be
2512 referred instead of re-init.
2513 @param
2514 NONE
2515 @return
2516 VOS_STATUS_SUCCESS - Operation completed successfully.
2517 VOS_STATUS_E_FAILURE - Operation failed.
2518
2519*/
2520VOS_STATUS vos_wlanReInit(void)
2521{
2522 VOS_STATUS vstatus;
2523 vstatus = vos_watchdog_wlan_re_init();
2524 return vstatus;
2525}
Jeff Johnsone7245742012-09-05 17:12:55 -07002526/**
2527 @brief vos_wlanRestart() - This API will reload WLAN driver.
2528
2529 This function is called if driver detects any fatal state which
2530 can be recovered by a WLAN module reload ( Android framwork initiated ).
2531 Note that this API will not initiate any RIVA subsystem restart.
2532
2533 The function wlan_hdd_restart_driver protects against re-entrant calls.
2534
2535 @param
2536 NONE
2537 @return
2538 VOS_STATUS_SUCCESS - Operation completed successfully.
2539 VOS_STATUS_E_FAILURE - Operation failed.
2540 VOS_STATUS_E_EMPTY - No configured interface
2541 VOS_STATUS_E_ALREADY - Request already in progress
2542
2543
2544*/
2545VOS_STATUS vos_wlanRestart(void)
2546{
2547 VOS_STATUS vstatus;
2548 hdd_context_t *pHddCtx = NULL;
2549 v_CONTEXT_t pVosContext = NULL;
2550
2551 /* Check whether driver load unload is in progress */
2552 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2553 {
2554 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2555 "%s: Driver load/unload is in progress, retry later.", __func__);
2556 return VOS_STATUS_E_AGAIN;
2557 }
2558
2559 /* Get the Global VOSS Context */
2560 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2561 if(!pVosContext) {
2562 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2563 "%s: Global VOS context is Null", __func__);
2564 return VOS_STATUS_E_FAILURE;
2565 }
2566
2567 /* Get the HDD context */
2568 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2569 if(!pHddCtx) {
2570 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2571 "%s: HDD context is Null", __func__);
2572 return VOS_STATUS_E_FAILURE;
2573 }
2574
2575 /* Reload the driver */
2576 vstatus = wlan_hdd_restart_driver(pHddCtx);
2577 return vstatus;
2578}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302579
2580
2581/**
2582 @brief vos_fwDumpReq()
2583
2584 This function is called to issue dump commands to Firmware
2585
2586 @param
Siddharth Bhal68115602015-01-18 20:44:55 +05302587 cmd - Command No. to execute
2588 arg1 - argument 1 to cmd
2589 arg2 - argument 2 to cmd
2590 arg3 - argument 3 to cmd
2591 arg4 - argument 4 to cmd
2592 async - asynchronous event. Don't wait for completion.
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302593 @return
2594 NONE
2595*/
2596v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
Siddharth Bhal68115602015-01-18 20:44:55 +05302597 tANI_U32 arg3, tANI_U32 arg4, tANI_U8 async)
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302598{
Siddharth Bhalec9581a2015-02-18 14:48:18 +05302599 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL, async);
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302600}
Dino Mycle3f783bc2014-08-08 17:40:22 +05302601
2602v_U64_t vos_get_monotonic_boottime(void)
2603{
2604 struct timespec ts;
2605 wcnss_get_monotonic_boottime(&ts);
2606 return (((v_U64_t)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
2607}
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05302608
2609/**---------------------------------------------------------------------------
2610
2611 \brief vos_randomize_n_bytes() - HDD Random Mac Addr Generator
2612
2613 This generates the random mac address for WLAN interface
2614
2615 \param - mac_addr - pointer to Mac address
2616
2617 \return - 0 for success, < 0 for failure
2618
2619 --------------------------------------------------------------------------*/
2620
2621VOS_STATUS vos_randomize_n_bytes(void *start_addr, tANI_U32 n)
2622{
2623
2624 if (start_addr == NULL )
2625 return VOS_STATUS_E_FAILURE;
2626
2627 get_random_bytes( start_addr, n);
2628
2629 return eHAL_STATUS_SUCCESS;
2630}
c_hpothu8adb97b2014-12-08 19:38:20 +05302631
2632/**---------------------------------------------------------------------------
2633
2634 \brief vos_is_wlan_in_badState() - get isFatalError flag from WD Ctx
2635
2636 \param - VOS_MODULE_ID - module id
2637 - moduleContext - module context
2638
2639 \return - isFatalError value if WDCtx is valid otherwise true
2640
2641 --------------------------------------------------------------------------*/
2642v_BOOL_t vos_is_wlan_in_badState(VOS_MODULE_ID moduleId,
2643 v_VOID_t *moduleContext)
2644{
2645 struct _VosWatchdogContext *pVosWDCtx = get_vos_watchdog_ctxt();
2646
2647 if (pVosWDCtx == NULL){
2648 VOS_TRACE(moduleId, VOS_TRACE_LEVEL_ERROR,
2649 "%s: global wd context is null", __func__);
2650
2651 return TRUE;
2652 }
2653 return pVosWDCtx->isFatalError;
2654}
Girish Gowlia33f0372015-01-19 15:39:04 +05302655
Girish Gowlia33f0372015-01-19 15:39:04 +05302656/**---------------------------------------------------------------------------
2657
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302658 \brief vos_is_fw_logging_enabled() -
2659
2660 API to check if firmware is configured to send logs using DXE channel
2661
2662 \param - None
2663
Mihir Sheted6274602015-04-28 16:13:21 +05302664 \return - 0: firmware logging is not enabled (it may or may not
2665 be supported)
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302666 1: firmware logging is enabled
2667
2668 --------------------------------------------------------------------------*/
2669v_U8_t vos_is_fw_logging_enabled(void)
2670{
2671 return hdd_is_fw_logging_enabled();
2672}
2673
2674/**---------------------------------------------------------------------------
2675
Mihir Shetebe94ebb2015-05-26 12:07:14 +05302676 \brief vos_is_fw_ev_logging_enabled() -
2677
2678 API to check if firmware is configured to send live logs using DXE channel
2679
2680 \param - None
2681
2682 \return - 0: firmware logging is not enabled (it may or may not
2683 be supported)
2684 1: firmware logging is enabled
2685
2686 --------------------------------------------------------------------------*/
2687v_U8_t vos_is_fw_ev_logging_enabled(void)
2688{
2689 return hdd_is_fw_ev_logging_enabled();
2690}
2691
2692/**---------------------------------------------------------------------------
2693
Mihir Sheted6274602015-04-28 16:13:21 +05302694 \brief vos_is_fw_logging_supported() -
2695
2696 API to check if firmware supports to send logs using DXE channel
2697
2698 \param - None
2699
2700 \return - 0: firmware logging is not supported
2701 1: firmware logging is supported
2702
2703 --------------------------------------------------------------------------*/
2704v_U8_t vos_is_fw_logging_supported(void)
2705{
2706 return IS_FRAME_LOGGING_SUPPORTED_BY_FW;
2707}
2708/**---------------------------------------------------------------------------
2709
Girish Gowlia33f0372015-01-19 15:39:04 +05302710 \brief vos_set_roam_delay_stats_enabled() -
2711
2712 API to set value of roamDelayStatsEnabled in vos context
2713
2714 \param - value to be updated
2715
2716 \return - NONE
2717
2718 --------------------------------------------------------------------------*/
2719
2720v_VOID_t vos_set_roam_delay_stats_enabled(v_U8_t value)
2721{
2722 gpVosContext->roamDelayStatsEnabled = value;
2723}
2724
2725
2726/**---------------------------------------------------------------------------
2727
2728 \brief vos_get_roam_delay_stats_enabled() -
2729
2730 API to get value of roamDelayStatsEnabled from vos context
2731
2732 \param - NONE
2733
2734 \return - value of roamDelayStatsEnabled
2735
2736 --------------------------------------------------------------------------*/
2737
2738v_U8_t vos_get_roam_delay_stats_enabled(v_VOID_t)
2739{
2740 return gpVosContext->roamDelayStatsEnabled;
2741}
Katya Nigama6fbf662015-03-17 18:35:47 +05302742
2743v_U32_t vos_get_dxeReplenishRXTimerVal(void)
2744{
2745 hdd_context_t *pHddCtx = NULL;
2746 v_CONTEXT_t pVosContext = NULL;
2747
2748 /* Get the Global VOSS Context */
2749 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2750 if(!pVosContext) {
2751 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2752 return 0;
2753 }
2754
2755 /* Get the HDD context */
2756 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2757 if(!pHddCtx) {
2758 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2759 return 0;
2760 }
2761
2762 return pHddCtx->cfg_ini->dxeReplenishRXTimerVal;
2763}
2764
2765v_BOOL_t vos_get_dxeSSREnable(void)
2766{
2767 hdd_context_t *pHddCtx = NULL;
2768 v_CONTEXT_t pVosContext = NULL;
2769
2770 /* Get the Global VOSS Context */
2771 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2772 if(!pVosContext) {
2773 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2774 return FALSE;
2775 }
2776
2777 /* Get the HDD context */
2778 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2779 if(!pHddCtx) {
2780 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2781 return FALSE;
2782 }
2783
2784 return pHddCtx->cfg_ini->dxeSSREnable;
2785}
Anand N Sunkad860e5ea2015-03-30 14:41:51 +05302786
2787v_VOID_t vos_flush_work(struct work_struct *work)
2788{
2789#if defined (WLAN_OPEN_SOURCE)
2790 cancel_work_sync(work);
2791#else
2792 wcnss_flush_work(work);
2793#endif
2794}
2795
2796v_VOID_t vos_flush_delayed_work(struct delayed_work *dwork)
2797{
2798#if defined (WLAN_OPEN_SOURCE)
2799 cancel_delayed_work_sync(dwork);
2800#else
2801 wcnss_flush_delayed_work(dwork);
2802#endif
2803}
2804
Anand N Sunkaddc63c792015-06-03 14:33:24 +05302805v_VOID_t vos_init_work(struct work_struct *work , void *callbackptr)
2806{
2807#if defined (WLAN_OPEN_SOURCE)
2808 INIT_WORK(work,callbackptr);
2809#else
2810 wcnss_init_work(work, callbackptr);
2811#endif
2812}
2813
2814v_VOID_t vos_init_delayed_work(struct delayed_work *dwork , void *callbackptr)
2815{
2816#if defined (WLAN_OPEN_SOURCE)
2817 INIT_DELAYED_WORK(dwork,callbackptr);
2818#else
2819 wcnss_init_delayed_work(dwork, callbackptr);
2820#endif
2821}
2822
Sushant Kaushik215778f2015-05-21 14:05:36 +05302823/**
2824 * vos_set_multicast_logging() - Set mutlicast logging value
2825 * @value: Value of multicast logging
2826 *
2827 * Set the multicast logging value which will indicate
2828 * whether to multicast host and fw messages even
2829 * without any registration by userspace entity
2830 *
2831 * Return: None
2832 */
2833void vos_set_multicast_logging(uint8_t value)
2834{
2835 vos_multicast_logging = value;
2836}
2837
2838/**
2839 * vos_is_multicast_logging() - Get multicast logging value
2840 *
2841 * Get the multicast logging value which will indicate
2842 * whether to multicast host and fw messages even
2843 * without any registration by userspace entity
2844 *
2845 * Return: 0 - Multicast logging disabled, 1 - Multicast logging enabled
2846 */
2847v_U8_t vos_is_multicast_logging(void)
2848{
2849 return vos_multicast_logging;
2850}
2851
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05302852/**
Abhishek Singh30fd58c2015-07-15 14:19:21 +05302853 * vos_isLoadUnloadInProgress()
2854 *
2855 * Return TRUE if load/unload is in progress.
2856 *
2857 */
2858v_BOOL_t vos_isLoadUnloadInProgress(void)
2859{
2860 hdd_context_t *pHddCtx = NULL;
2861 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2862
2863 if(!pVosContext)
2864 {
2865 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
2866 return FALSE;
2867 }
2868
2869 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2870 if(!pHddCtx) {
2871 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2872 "%s: HDD context is Null", __func__);
2873 return FALSE;
2874 }
2875
2876 return ( 0 != pHddCtx->isLoadUnloadInProgress);
2877}
2878
2879/**
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05302880 * vos_isUnloadInProgress()
2881 *
2882 * Return TRUE if unload is in progress.
2883 *
2884 */
2885v_BOOL_t vos_isUnloadInProgress(void)
2886{
2887 hdd_context_t *pHddCtx = NULL;
2888 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2889
2890 if(!pVosContext)
2891 {
2892 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
2893 return FALSE;
2894 }
2895
2896 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2897 if(!pHddCtx) {
2898 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2899 "%s: HDD context is Null", __func__);
2900 return FALSE;
2901 }
2902
2903 return (WLAN_HDD_UNLOAD_IN_PROGRESS == pHddCtx->isLoadUnloadInProgress);
2904}
2905