blob: 1e24ce1b56f2c8402f350817316720e55b233982 [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;
107
108/*---------------------------------------------------------------------------
109 * Forward declaration
110 * ------------------------------------------------------------------------*/
111v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
114
115v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
116 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118
119/*---------------------------------------------------------------------------
120
121 \brief vos_preOpen() - PreOpen the vOSS Module
122
123 The \a vos_preOpen() function allocates the Vos Context, but do not
124 initialize all the members. This overal initialization will happen
125 at vos_Open().
126 The reason why we need vos_preOpen() is to get a minimum context
127 where to store BAL and SAL relative data, which happens before
128 vos_Open() is called.
129
130 \param pVosContext: A pointer to where to store the VOS Context
131
132
133 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
134 is ready to be used.
135
136 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
137
138 \sa vos_Open()
139
140---------------------------------------------------------------------------*/
141VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
142{
143 if ( pVosContext == NULL)
144 return VOS_STATUS_E_FAILURE;
145
146 /* Allocate the VOS Context */
147 *pVosContext = NULL;
148 gpVosContext = &gVosContext;
149
150 if (NULL == gpVosContext)
151 {
152 /* Critical Error ...Cannot proceed further */
153 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
154 "%s: Failed to allocate VOS Context", __func__);
155 VOS_ASSERT(0);
156 return VOS_STATUS_E_RESOURCES;
157 }
158
159 vos_mem_zero(gpVosContext, sizeof(VosContextType));
160
161 *pVosContext = gpVosContext;
162
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700163 /* Initialize the spinlock */
164 vos_trace_spin_lock_init();
165 /* it is the right time to initialize MTRACE structures */
166 #if defined(TRACE_RECORD)
167 vosTraceInit();
168 #endif
169
Jeff Johnson295189b2012-06-20 16:38:30 -0700170 return VOS_STATUS_SUCCESS;
171
172} /* vos_preOpen()*/
173
174
175/*---------------------------------------------------------------------------
176
177 \brief vos_preClose() - PreClose the vOSS Module
178
179 The \a vos_preClose() function frees the Vos Context.
180
181 \param pVosContext: A pointer to where the VOS Context was stored
182
183
184 \return VOS_STATUS_SUCCESS - Always successful
185
186
187 \sa vos_preClose()
188 \sa vos_close()
189---------------------------------------------------------------------------*/
190VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
191{
192
193 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
194 "%s: De-allocating the VOS Context", __func__);
195
196 if (( pVosContext == NULL) || (*pVosContext == NULL))
197 {
198 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
199 "%s: vOS Context is Null", __func__);
200 return VOS_STATUS_E_FAILURE;
201 }
202
203 if (gpVosContext != *pVosContext)
204 {
205 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
206 "%s: Context mismatch", __func__);
207 return VOS_STATUS_E_FAILURE;
208 }
209
210 *pVosContext = gpVosContext = NULL;
211
212 return VOS_STATUS_SUCCESS;
213
214} /* vos_preClose()*/
215
216/*---------------------------------------------------------------------------
217
218 \brief vos_open() - Open the vOSS Module
219
220 The \a vos_open() function opens the vOSS Scheduler
221 Upon successful initialization:
222
223 - All VOS submodules should have been initialized
224
225 - The VOS scheduler should have opened
226
227 - All the WLAN SW components should have been opened. This includes
228 SYS, MAC, SME, WDA and TL.
229
230
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530231 \param devHandle: pointer to the OS specific device handle
Jeff Johnson295189b2012-06-20 16:38:30 -0700232
233
234 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
235 is ready to be used.
236
237 VOS_STATUS_E_RESOURCES - System resources (other than memory)
238 are unavailable to initilize the scheduler
239
240
241 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
242
243 \sa vos_preOpen()
244
245---------------------------------------------------------------------------*/
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530246VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, void *devHandle )
Jeff Johnson295189b2012-06-20 16:38:30 -0700247
248{
249 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
250 int iter = 0;
251 tSirRetStatus sirStatus = eSIR_SUCCESS;
252 tMacOpenParameters macOpenParms;
253 WLANTL_ConfigInfoType TLConfig;
254
255 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
256 "%s: Opening VOSS", __func__);
257
258 if (NULL == gpVosContext)
259 {
260 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
261 "%s: Trying to open VOSS without a PreOpen", __func__);
262 VOS_ASSERT(0);
263 return VOS_STATUS_E_FAILURE;
264 }
265
266 /* Initialize the timer module */
267 vos_timer_module_init();
268
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 /* Initialize the probe event */
271 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
272 {
273 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
274 "%s: Unable to init probeEvent", __func__);
275 VOS_ASSERT(0);
276 return VOS_STATUS_E_FAILURE;
277 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
279 {
280 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
281 "%s: Unable to init wdaCompleteEvent", __func__);
282 VOS_ASSERT(0);
283
284 goto err_probe_event;
285 }
286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 /* Initialize the free message queue */
288 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
289 if (! VOS_IS_STATUS_SUCCESS(vStatus))
290 {
291
292 /* Critical Error ... Cannot proceed further */
293 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
294 "%s: Failed to initialize VOS free message queue", __func__);
295 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 goto err_wda_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 }
298
299 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
300 {
301 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
302 &(gpVosContext->aMsgBuffers[iter]);
303 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
304 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
305 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700306
307 /* Now Open the VOS Scheduler */
308 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
309 sizeof(VosSchedContext));
310
311 if (!VOS_IS_STATUS_SUCCESS(vStatus))
312 {
313 /* Critical Error ... Cannot proceed further */
314 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
315 "%s: Failed to open VOS Scheduler", __func__);
316 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 }
319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 /*
321 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
322 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
323 */
324
325 /*Open the WDA module */
326 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
327 /* UMA is supported in hardware for performing the
328 ** frame translation 802.11 <-> 802.3
329 */
330 macOpenParms.frameTransRequired = 1;
331 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530332 vStatus = WDA_open( gpVosContext, devHandle, &macOpenParms );
Jeff Johnson295189b2012-06-20 16:38:30 -0700333
334 if (!VOS_IS_STATUS_SUCCESS(vStatus))
335 {
336 /* Critical Error ... Cannot proceed further */
337 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
338 "%s: Failed to open WDA module", __func__);
339 VOS_ASSERT(0);
340 goto err_sched_close;
341 }
342
343 /* Initialize here the VOS Packet sub module */
344 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
345 sizeof( vos_pkt_context_t ) );
346
347 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
348 {
349 /* Critical Error ... Cannot proceed further */
350 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
351 "%s: Failed to open VOS Packet Module", __func__);
352 VOS_ASSERT(0);
353 goto err_wda_close;
354 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 /* Open the SYS module */
357 vStatus = sysOpen(gpVosContext);
358
359 if (!VOS_IS_STATUS_SUCCESS(vStatus))
360 {
361 /* Critical Error ... Cannot proceed further */
362 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
363 "%s: Failed to open SYS module", __func__);
364 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 }
367
Amar Singhal0a402232013-10-11 20:57:16 -0700368#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 /* initialize the NV module */
370 vStatus = vos_nv_open();
371 if (!VOS_IS_STATUS_SUCCESS(vStatus))
372 {
373 // NV module cannot be initialized
374 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
375 "%s: Failed to initialize the NV module", __func__);
376 goto err_sys_close;
377 }
Amar Singhal0a402232013-10-11 20:57:16 -0700378#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
380 /* If we arrive here, both threads dispacthing messages correctly */
381
382 /* Now proceed to open the MAC */
383
384 /* UMA is supported in hardware for performing the
385 frame translation 802.11 <-> 802.3 */
386 macOpenParms.frameTransRequired = 1;
387 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
388 &macOpenParms);
389
390 if (eSIR_SUCCESS != sirStatus)
391 {
392 /* Critical Error ... Cannot proceed further */
393 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
394 "%s: Failed to open MAC", __func__);
395 VOS_ASSERT(0);
396 goto err_nv_close;
397 }
398
399 /* Now proceed to open the SME */
400 vStatus = sme_Open(gpVosContext->pMACContext);
401 if (!VOS_IS_STATUS_SUCCESS(vStatus))
402 {
403 /* Critical Error ... Cannot proceed further */
404 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
405 "%s: Failed to open SME", __func__);
406 VOS_ASSERT(0);
407 goto err_mac_close;
408 }
409
410 /* Now proceed to open TL. Read TL config first */
411 vos_fetch_tl_cfg_parms ( &TLConfig,
412 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
413
414 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
415 if (!VOS_IS_STATUS_SUCCESS(vStatus))
416 {
417 /* Critical Error ... Cannot proceed further */
418 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
419 "%s: Failed to open TL", __func__);
420 VOS_ASSERT(0);
421 goto err_sme_close;
422 }
423
Girish Gowlifb0bfd32015-01-13 11:42:11 +0530424 if (gpVosContext->roamDelayStatsEnabled &&
425 !vos_roam_delay_stats_init())
426 {
427 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
428 "%s: Could not init roamDelayStats", __func__);
429 }
430
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
432 "%s: VOSS successfully Opened", __func__);
433
434 *pVosContext = gpVosContext;
435
436 return VOS_STATUS_SUCCESS;
437
438
439err_sme_close:
440 sme_Close(gpVosContext->pMACContext);
441
442err_mac_close:
443 macClose(gpVosContext->pMACContext);
444
445err_nv_close:
Amar Singhal0a402232013-10-11 20:57:16 -0700446
447#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 vos_nv_close();
Amar Singhal0a402232013-10-11 20:57:16 -0700449
450err_sys_close:
451#endif
452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 sysClose(gpVosContext);
454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455err_packet_close:
456 vos_packet_close( gpVosContext );
457
458err_wda_close:
459 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460
Amar Singhal0a402232013-10-11 20:57:16 -0700461err_sched_close:
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 vos_sched_close(gpVosContext);
463
Jeff Johnson295189b2012-06-20 16:38:30 -0700464
465err_msg_queue:
466 vos_mq_deinit(&gpVosContext->freeVosMq);
467
Jeff Johnson295189b2012-06-20 16:38:30 -0700468err_wda_complete_event:
469 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700470
471err_probe_event:
472 vos_event_destroy(&gpVosContext->ProbeEvent);
473
474 return VOS_STATUS_E_FAILURE;
475
476} /* vos_open() */
477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478/*---------------------------------------------------------------------------
479
480 \brief vos_preStart() -
481
482 The \a vos_preStart() function to download CFG.
483 including:
484 - ccmStart
485
486 - WDA: triggers the CFG download
487
488
489 \param pVosContext: The VOS context
490
491
492 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
493 is ready to be used.
494
495 VOS_STATUS_E_RESOURCES - System resources (other than memory)
496 are unavailable to initilize the scheduler
497
498
499 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
500
501 \sa vos_start
502
503---------------------------------------------------------------------------*/
504VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
505{
506 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
507 pVosContextType pVosContext = (pVosContextType)vosContext;
508
509 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
510 "vos prestart");
511
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800512 if (gpVosContext != pVosContext)
513 {
514 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
515 "%s: Context mismatch", __func__);
516 VOS_ASSERT(0);
517 return VOS_STATUS_E_INVAL;
518 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700519
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800520 if (pVosContext->pMACContext == NULL)
521 {
522 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
523 "%s: MAC NULL context", __func__);
524 VOS_ASSERT(0);
525 return VOS_STATUS_E_INVAL;
526 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700527
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800528 if (pVosContext->pWDAContext == NULL)
529 {
530 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
531 "%s: WDA NULL context", __func__);
532 VOS_ASSERT(0);
533 return VOS_STATUS_E_INVAL;
534 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700535
536 /* call macPreStart */
537 vStatus = macPreStart(gpVosContext->pMACContext);
538 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
539 {
540 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
541 "Failed at macPreStart ");
542 return VOS_STATUS_E_FAILURE;
543 }
544
545 /* call ccmStart */
546 ccmStart(gpVosContext->pMACContext);
547
548 /* Reset wda wait event */
549 vos_event_reset(&gpVosContext->wdaCompleteEvent);
550
551
552 /*call WDA pre start*/
553 vStatus = WDA_preStart(gpVosContext);
554 if (!VOS_IS_STATUS_SUCCESS(vStatus))
555 {
556 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
557 "Failed to WDA prestart");
558 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
559 ccmStop(gpVosContext->pMACContext);
560 VOS_ASSERT(0);
561 return VOS_STATUS_E_FAILURE;
562 }
563
564 /* Need to update time out of complete */
565 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
566 VOS_WDA_TIMEOUT );
567 if ( vStatus != VOS_STATUS_SUCCESS )
568 {
569 if ( vStatus == VOS_STATUS_E_TIMEOUT )
570 {
571 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800572 "%s: Timeout occurred before WDA complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 }
574 else
575 {
576 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
577 "%s: WDA_preStart reporting other error", __func__);
578 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700579 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
580 "%s: Test MC thread by posting a probe message to SYS", __func__);
581 wlan_sys_probe();
582
Jeff Johnsone7245742012-09-05 17:12:55 -0700583 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
584 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 VOS_ASSERT( 0 );
586 return VOS_STATUS_E_FAILURE;
587 }
588
589 return VOS_STATUS_SUCCESS;
590}
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592/*---------------------------------------------------------------------------
593
594 \brief vos_start() - Start the Libra SW Modules
595
596 The \a vos_start() function starts all the components of the Libra SW
597 including:
598 - SAL/BAL, which in turn starts SSC
599
600 - the MAC (HAL and PE)
601
602 - SME
603
604 - TL
605
606 - SYS: triggers the CFG download
607
608
609 \param pVosContext: The VOS context
610
611
612 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
613 is ready to be used.
614
615 VOS_STATUS_E_RESOURCES - System resources (other than memory)
616 are unavailable to initilize the scheduler
617
618
619 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
620
621 \sa vos_preStart()
622 \sa vos_open()
623
624---------------------------------------------------------------------------*/
625VOS_STATUS vos_start( v_CONTEXT_t vosContext )
626{
627 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
628 tSirRetStatus sirStatus = eSIR_SUCCESS;
629 pVosContextType pVosContext = (pVosContextType)vosContext;
630 tHalMacStartParameters halStartParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700631
632 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
633 "%s: Starting Libra SW", __func__);
634
635 /* We support only one instance for now ...*/
636 if (gpVosContext != pVosContext)
637 {
638 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700639 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 return VOS_STATUS_E_FAILURE;
641 }
642
Jeff Johnson295189b2012-06-20 16:38:30 -0700643 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
644 || ( pVosContext->pTLContext == NULL))
645 {
646 if (pVosContext->pWDAContext == NULL)
647 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700648 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 else if (pVosContext->pMACContext == NULL)
650 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700651 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 else
653 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700654 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700655
656 return VOS_STATUS_E_FAILURE;
657 }
658
659 /* WDA_Start will be called after NV image download because the
660 NV image data has to be updated at HAL before HAL_Start gets executed*/
661
662 /* Start the NV Image Download */
663
664 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
665
666 vStatus = WDA_NVDownload_Start(pVosContext);
667
668 if ( vStatus != VOS_STATUS_SUCCESS )
669 {
670 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
671 "%s: Failed to start NV Download", __func__);
672 return VOS_STATUS_E_FAILURE;
673 }
674
675 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
676 VOS_WDA_TIMEOUT );
677
678 if ( vStatus != VOS_STATUS_SUCCESS )
679 {
680 if ( vStatus == VOS_STATUS_E_TIMEOUT )
681 {
682 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
683 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
684 }
685 else
686 {
687 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
688 "%s: WDA_NVDownload_start reporting other error", __func__);
689 }
690 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800691 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700692 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
693 {
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530694 if (isSsrPanicOnFailure())
695 VOS_BUG(0);
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700696 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800697 WDA_setNeedShutdown(vosContext);
698 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 }
700
701 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
702 "%s: WDA_NVDownload_start correctly started", __func__);
703
704 /* Start the WDA */
705 vStatus = WDA_start(pVosContext);
706 if ( vStatus != VOS_STATUS_SUCCESS )
707 {
708 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530709 "%s: Failed to start WDA - WDA_shutdown needed", __func__);
710 if ( vStatus == VOS_STATUS_E_TIMEOUT )
711 {
712 WDA_setNeedShutdown(vosContext);
713 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 return VOS_STATUS_E_FAILURE;
715 }
716 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
717 "%s: WDA correctly started", __func__);
718
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 /* Start the MAC */
720 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
721
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 /* Start the MAC */
723 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
724
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 if (eSIR_SUCCESS != sirStatus)
726 {
727 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
728 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 }
731
732 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
733 "%s: MAC correctly started", __func__);
734
735 /* START SME */
736 vStatus = sme_Start(pVosContext->pMACContext);
737
738 if (!VOS_IS_STATUS_SUCCESS(vStatus))
739 {
740 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
741 "%s: Failed to start SME", __func__);
742 goto err_mac_stop;
743 }
744
745 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
746 "%s: SME correctly started", __func__);
747
748 /** START TL */
749 vStatus = WLANTL_Start(pVosContext);
750 if (!VOS_IS_STATUS_SUCCESS(vStatus))
751 {
752 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
753 "%s: Failed to start TL", __func__);
754 goto err_sme_stop;
755 }
756
757 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
758 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
760 "%s: VOSS Start is successful!!", __func__);
761
762 return VOS_STATUS_SUCCESS;
763
Jeff Johnson295189b2012-06-20 16:38:30 -0700764
765err_sme_stop:
Kiet Lama72a2322013-11-15 11:18:11 +0530766 sme_Stop(pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767
768err_mac_stop:
769 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
770
Jeff Johnson295189b2012-06-20 16:38:30 -0700771err_wda_stop:
772 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800773 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
774 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800776 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
777 "%s: Failed to stop WDA", __func__);
778 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800779 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800780 }
781 else
782 {
783 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
784 VOS_WDA_TIMEOUT );
785 if( vStatus != VOS_STATUS_SUCCESS )
786 {
787 if( vStatus == VOS_STATUS_E_TIMEOUT )
788 {
789 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
790 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800792 }
793 else
794 {
795 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
796 "%s: WDA_stop reporting other error", __func__);
797 }
798 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800799 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800800 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700802
803 return VOS_STATUS_E_FAILURE;
804
805} /* vos_start() */
806
807
808/* vos_stop function */
809VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
810{
811 VOS_STATUS vosStatus;
812
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 /* WDA_Stop is called before the SYS so that the processing of Riva
814 pending responces will not be handled during uninitialization of WLAN driver */
815 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
816
817 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
818
819 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
820 {
821 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
822 "%s: Failed to stop WDA", __func__);
823 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800824 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -0700826 else
827 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800828 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
829 VOS_WDA_STOP_TIMEOUT );
Jeff Johnson295189b2012-06-20 16:38:30 -0700830
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800831 if ( vosStatus != VOS_STATUS_SUCCESS )
832 {
833 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
834 {
835 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
836 "%s: Timeout occurred before WDA complete", __func__);
837 }
838 else
839 {
840 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
841 "%s: WDA_stop reporting other error", __func__ );
842 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700843 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
844 "%s: Test MC thread by posting a probe message to SYS", __func__);
845 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800846 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800847 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700849
850 /* SYS STOP will stop SME and MAC */
851 vosStatus = sysStop( vosContext);
852 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
853 {
854 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
855 "%s: Failed to stop SYS", __func__);
856 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
857 }
858
859 vosStatus = WLANTL_Stop( vosContext );
860 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
861 {
862 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
863 "%s: Failed to stop TL", __func__);
864 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
865 }
866
Jeff Johnson295189b2012-06-20 16:38:30 -0700867
868 return VOS_STATUS_SUCCESS;
869}
870
871
872/* vos_close function */
873VOS_STATUS vos_close( v_CONTEXT_t vosContext )
874{
875 VOS_STATUS vosStatus;
876
877#ifdef WLAN_BTAMP_FEATURE
878 vosStatus = WLANBAP_Close(vosContext);
879 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
880 {
881 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
882 "%s: Failed to close BAP", __func__);
883 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
884 }
885#endif // WLAN_BTAMP_FEATURE
886
887
888 vosStatus = WLANTL_Close(vosContext);
889 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
890 {
891 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
892 "%s: Failed to close TL", __func__);
893 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
894 }
895
896 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
897 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
898 {
899 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
900 "%s: Failed to close SME", __func__);
901 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
902 }
903
904 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
905 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
906 {
907 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
908 "%s: Failed to close MAC", __func__);
909 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
910 }
911
912 ((pVosContextType)vosContext)->pMACContext = NULL;
913
Amar Singhal0a402232013-10-11 20:57:16 -0700914#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 vosStatus = vos_nv_close();
916 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
917 {
918 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
919 "%s: Failed to close NV", __func__);
920 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
921 }
Amar Singhal0a402232013-10-11 20:57:16 -0700922#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700923
924 vosStatus = sysClose( vosContext );
925 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
926 {
927 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
928 "%s: Failed to close SYS", __func__);
929 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
930 }
931
Jeff Johnsone7245742012-09-05 17:12:55 -0700932 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700934 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
935 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
936 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
937 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -0700938 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -0700939 }
940 else
941 {
942 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
943 "%s: Failed to shutdown WDA", __func__ );
944 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
945 }
946 }
947 else
948 {
949 vosStatus = WDA_close( vosContext );
950 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
951 {
952 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
953 "%s: Failed to close WDA", __func__);
954 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
955 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 }
957
958 /* Let DXE return packets in WDA_close and then free them here */
959 vosStatus = vos_packet_close( vosContext );
960 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
961 {
962 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
963 "%s: Failed to close VOSS Packet", __func__);
964 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
965 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967
968 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
971 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
972 {
973 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
974 "%s: failed to destroy wdaCompleteEvent", __func__);
975 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
976 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700977
978 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
979 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
980 {
981 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
982 "%s: failed to destroy ProbeEvent", __func__);
983 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
984 }
985
Girish Gowlifb0bfd32015-01-13 11:42:11 +0530986 if (gpVosContext->roamDelayStatsEnabled &&
987 !vos_roam_delay_stats_deinit())
988 {
989 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
990 "%s: Could not deinit roamDelayStats", __func__);
991 }
992
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 return VOS_STATUS_SUCCESS;
994}
995
996
997/**---------------------------------------------------------------------------
998
999 \brief vos_get_context() - get context data area
1000
1001 Each module in the system has a context / data area that is allocated
1002 and maanged by voss. This API allows any user to get a pointer to its
1003 allocated context data area from the VOSS global context.
1004
1005 \param vosContext - the VOSS Global Context.
1006
1007 \param moduleId - the module ID, who's context data are is being retrived.
1008
1009 \return - pointer to the context data area.
1010
1011 - NULL if the context data is not allocated for the module ID
1012 specified
1013
1014 --------------------------------------------------------------------------*/
1015v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1016 v_CONTEXT_t pVosContext )
1017{
1018 v_PVOID_t pModContext = NULL;
1019
1020 if (pVosContext == NULL)
1021 {
1022 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001023 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 return NULL;
1025 }
1026
1027 if (gpVosContext != pVosContext)
1028 {
1029 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001030 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 return NULL;
1032 }
1033
1034 switch(moduleId)
1035 {
1036 case VOS_MODULE_ID_TL:
1037 {
1038 pModContext = gpVosContext->pTLContext;
1039 break;
1040 }
1041
Jeff Johnson295189b2012-06-20 16:38:30 -07001042#ifdef WLAN_BTAMP_FEATURE
1043 case VOS_MODULE_ID_BAP:
1044 {
1045 pModContext = gpVosContext->pBAPContext;
1046 break;
1047 }
1048#endif //WLAN_BTAMP_FEATURE
1049
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 case VOS_MODULE_ID_SAP:
1051 {
1052 pModContext = gpVosContext->pSAPContext;
1053 break;
1054 }
1055
1056 case VOS_MODULE_ID_HDD_SOFTAP:
1057 {
1058 pModContext = gpVosContext->pHDDSoftAPContext;
1059 break;
1060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001061
1062 case VOS_MODULE_ID_HDD:
1063 {
1064 pModContext = gpVosContext->pHDDContext;
1065 break;
1066 }
1067
1068 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301070 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 {
1072 /*
1073 ** In all these cases, we just return the MAC Context
1074 */
1075 pModContext = gpVosContext->pMACContext;
1076 break;
1077 }
1078
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 case VOS_MODULE_ID_WDA:
1080 {
1081 /* For WDA module */
1082 pModContext = gpVosContext->pWDAContext;
1083 break;
1084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001085
1086 case VOS_MODULE_ID_VOSS:
1087 {
1088 /* For SYS this is VOS itself*/
1089 pModContext = gpVosContext;
1090 break;
1091 }
1092
1093 default:
1094 {
1095 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1096 "does not have its context maintained by VOSS", __func__, moduleId);
1097 VOS_ASSERT(0);
1098 return NULL;
1099 }
1100 }
1101
1102 if (pModContext == NULL )
1103 {
1104 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1105 "context is Null", __func__, moduleId);
1106 }
1107
1108 return pModContext;
1109
1110} /* vos_get_context()*/
1111
1112
1113/**---------------------------------------------------------------------------
1114
1115 \brief vos_get_global_context() - get VOSS global Context
1116
1117 This API allows any user to get the VOS Global Context pointer from a
1118 module context data area.
1119
1120 \param moduleContext - the input module context pointer
1121
1122 \param moduleId - the module ID who's context pointer is input in
1123 moduleContext.
1124
1125 \return - pointer to the VOSS global context
1126
1127 - NULL if the function is unable to retreive the VOSS context.
1128
1129 --------------------------------------------------------------------------*/
1130v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1131 v_VOID_t *moduleContext )
1132{
1133 if (gpVosContext == NULL)
1134 {
1135 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001136 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 }
1138
1139 return gpVosContext;
1140
1141} /* vos_get_global_context() */
1142
1143
1144v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1145{
1146 if (gpVosContext == NULL)
1147 {
1148 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001149 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 return 1;
1151 }
1152
1153 return gpVosContext->isLogpInProgress;
1154}
1155
1156void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1157{
1158 if (gpVosContext == NULL)
1159 {
1160 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001161 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 return;
1163 }
1164
1165 gpVosContext->isLogpInProgress = value;
1166}
1167
1168v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1169{
1170 if (gpVosContext == NULL)
1171 {
1172 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001173 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 return 0;
1175 }
1176
1177 return gpVosContext->isLoadUnloadInProgress;
1178}
1179
1180void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1181{
1182 if (gpVosContext == NULL)
1183 {
1184 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001185 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 return;
1187 }
1188
1189 gpVosContext->isLoadUnloadInProgress = value;
1190}
1191
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001192v_U8_t vos_is_reinit_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1193{
1194 if (gpVosContext == NULL)
1195 {
1196 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1197 "%s: global voss context is NULL", __func__);
1198 return 1;
1199 }
1200
1201 return gpVosContext->isReInitInProgress;
1202}
1203
1204void vos_set_reinit_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1205{
1206 if (gpVosContext == NULL)
1207 {
1208 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1209 "%s: global voss context is NULL", __func__);
1210 return;
1211 }
1212
1213 gpVosContext->isReInitInProgress = value;
1214}
1215
1216
Jeff Johnson295189b2012-06-20 16:38:30 -07001217/**---------------------------------------------------------------------------
1218
1219 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1220
1221 This API allows any user to allocate a user context area within the
1222 VOS Global Context.
1223
1224 \param pVosContext - pointer to the global Vos context
1225
1226 \param moduleId - the module ID who's context area is being allocated.
1227
1228 \param ppModuleContext - pointer to location where the pointer to the
1229 allocated context is returned. Note this
1230 output pointer is valid only if the API
1231 returns VOS_STATUS_SUCCESS
1232
1233 \param size - the size of the context area to be allocated.
1234
1235 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1236 allocated successfully. The pointer to the context area
1237 can be found in *ppModuleContext.
1238 \note This function returns VOS_STATUS_SUCCESS if the
1239 module context was already allocated and the size
1240 allocated matches the size on this call.
1241
1242 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1243 not identify a module that can have a context allocated.
1244
1245 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1246 because a context for this module ID already exists and it is
1247 a *different* size that specified on this call.
1248
1249 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1250 requested context area.
1251
1252 \sa vos_get_context(), vos_free_context()
1253
1254 --------------------------------------------------------------------------*/
1255VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1256 v_VOID_t **ppModuleContext, v_SIZE_t size )
1257{
1258 v_VOID_t ** pGpModContext = NULL;
1259
1260 if ( pVosContext == NULL) {
1261 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001262 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 return VOS_STATUS_E_FAILURE;
1264 }
1265
1266 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1267 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001268 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 return VOS_STATUS_E_FAILURE;
1270 }
1271
1272 switch(moduleID)
1273 {
1274 case VOS_MODULE_ID_TL:
1275 {
1276 pGpModContext = &(gpVosContext->pTLContext);
1277 break;
1278 }
1279
Jeff Johnson295189b2012-06-20 16:38:30 -07001280#ifdef WLAN_BTAMP_FEATURE
1281 case VOS_MODULE_ID_BAP:
1282 {
1283 pGpModContext = &(gpVosContext->pBAPContext);
1284 break;
1285 }
1286#endif //WLAN_BTAMP_FEATURE
1287
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 case VOS_MODULE_ID_SAP:
1289 {
1290 pGpModContext = &(gpVosContext->pSAPContext);
1291 break;
1292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001293
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 case VOS_MODULE_ID_WDA:
1295 {
1296 pGpModContext = &(gpVosContext->pWDAContext);
1297 break;
1298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301301 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 default:
1305 {
1306 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1307 "does not have its context allocated by VOSS", __func__, moduleID);
1308 VOS_ASSERT(0);
1309 return VOS_STATUS_E_INVAL;
1310 }
1311 }
1312
1313 if ( NULL != *pGpModContext)
1314 {
1315 /*
1316 ** Context has already been allocated!
1317 ** Prevent double allocation
1318 */
1319 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1320 "%s: Module ID %i context has already been allocated",
1321 __func__, moduleID);
1322 return VOS_STATUS_E_EXISTS;
1323 }
1324
1325 /*
1326 ** Dynamically allocate the context for module
1327 */
1328
1329 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1330
1331
1332 if ( *ppModuleContext == NULL)
1333 {
1334 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1335 "allocate Context for module ID %i", __func__, moduleID);
1336 VOS_ASSERT(0);
1337 return VOS_STATUS_E_NOMEM;
1338 }
1339
1340 if (moduleID==VOS_MODULE_ID_TL)
1341 {
1342 vos_mem_zero(*ppModuleContext, size);
1343 }
1344
1345 *pGpModContext = *ppModuleContext;
1346
1347 return VOS_STATUS_SUCCESS;
1348
1349} /* vos_alloc_context() */
1350
1351
1352/**---------------------------------------------------------------------------
1353
1354 \brief vos_free_context() - free an allocated a context within the
1355 VOSS global Context
1356
1357 This API allows a user to free the user context area within the
1358 VOS Global Context.
1359
1360 \param pVosContext - pointer to the global Vos context
1361
1362 \param moduleId - the module ID who's context area is being free
1363
1364 \param pModuleContext - pointer to module context area to be free'd.
1365
1366 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1367 free'd. The pointer to the context area is not longer
1368 available.
1369
1370 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1371 valid pointers.
1372
1373 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1374 not identify a module that can have a context free'd.
1375
1376 VOS_STATUS_E_EXISTS - vos could not free the requested
1377 context area because a context for this module ID does not
1378 exist in the global vos context.
1379
1380 \sa vos_get_context()
1381
1382 --------------------------------------------------------------------------*/
1383VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1384 v_VOID_t *pModuleContext )
1385{
1386 v_VOID_t ** pGpModContext = NULL;
1387
1388 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1389 ( pModuleContext == NULL))
1390 {
1391 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1392 "%s: Null params or context mismatch", __func__);
1393 return VOS_STATUS_E_FAILURE;
1394 }
1395
1396
1397 switch(moduleID)
1398 {
1399 case VOS_MODULE_ID_TL:
1400 {
1401 pGpModContext = &(gpVosContext->pTLContext);
1402 break;
1403 }
1404
Jeff Johnson295189b2012-06-20 16:38:30 -07001405#ifdef WLAN_BTAMP_FEATURE
1406 case VOS_MODULE_ID_BAP:
1407 {
1408 pGpModContext = &(gpVosContext->pBAPContext);
1409 break;
1410 }
1411#endif //WLAN_BTAMP_FEATURE
1412
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 case VOS_MODULE_ID_SAP:
1414 {
1415 pGpModContext = &(gpVosContext->pSAPContext);
1416 break;
1417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001418
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 case VOS_MODULE_ID_WDA:
1420 {
1421 pGpModContext = &(gpVosContext->pWDAContext);
1422 break;
1423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 case VOS_MODULE_ID_HDD:
1425 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301427 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 default:
1430 {
1431 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1432 "does not have its context allocated by VOSS", __func__, moduleID);
1433 VOS_ASSERT(0);
1434 return VOS_STATUS_E_INVAL;
1435 }
1436 }
1437
1438 if ( NULL == *pGpModContext)
1439 {
1440 /*
1441 ** Context has not been allocated or freed already!
1442 */
1443 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1444 "context has not been allocated or freed already", __func__,moduleID);
1445 return VOS_STATUS_E_FAILURE;
1446 }
1447
1448 if (*pGpModContext != pModuleContext)
1449 {
1450 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001451 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 return VOS_STATUS_E_FAILURE;
1453 }
1454
1455 if(pModuleContext != NULL)
1456 kfree(pModuleContext);
1457
1458 *pGpModContext = NULL;
1459
1460 return VOS_STATUS_SUCCESS;
1461
1462} /* vos_free_context() */
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301463
1464/**---------------------------------------------------------------------------
1465
1466 \brief vos_logger_pkt_serialize() - queue a logging vos pkt
1467
1468 This API allows single vos pkt to be queued and later sent to userspace by
1469 logger thread.
1470
1471 \param pPacket - a pointer to a vos pkt to be queued
1472 pkt_type - type of pkt to be queued
1473 LOG_PKT_TYPE_DATA_MGMT - frame log i.e data/mgmt pkts
1474
1475 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1476 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1477 a failure.
1478 --------------------------------------------------------------------------*/
Mihir Sheteccafc0c2015-04-17 16:13:15 +05301479VOS_STATUS vos_logger_pkt_serialize( vos_pkt_t *pPacket, uint32 pkt_type)
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301480{
1481#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1482 return wlan_queue_logpkt_for_app(pPacket, pkt_type);
1483#else
1484 return vos_pkt_return_packet(pPacket);
1485#endif
1486}
Jeff Johnson295189b2012-06-20 16:38:30 -07001487
1488/**---------------------------------------------------------------------------
1489
1490 \brief vos_mq_post_message() - post a message to a message queue
1491
1492 This API allows messages to be posted to a specific message queue. Messages
1493 can be posted to the following message queues:
1494
1495 <ul>
1496 <li> SME
1497 <li> PE
1498 <li> HAL
1499 <li> TL
1500 </ul>
1501
1502 \param msgQueueId - identifies the message queue upon which the message
1503 will be posted.
1504
1505 \param message - a pointer to a message buffer. Memory for this message
1506 buffer is allocated by the caller and free'd by the vOSS after the
1507 message is posted to the message queue. If the consumer of the
1508 message needs anything in this message, it needs to copy the contents
1509 before returning from the message queue handler.
1510
1511 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1512 to the message queue.
1513
1514 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1515 refer to a valid Message Queue Id.
1516
1517 VOS_STATUS_E_FAULT - message is an invalid pointer.
1518
1519 VOS_STATUS_E_FAILURE - the message queue handler has reported
1520 an unknown failure.
1521
1522 \sa
1523
1524 --------------------------------------------------------------------------*/
1525VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1526{
1527 pVosMqType pTargetMq = NULL;
1528 pVosMsgWrapper pMsgWrapper = NULL;
1529
1530 if ((gpVosContext == NULL) || (pMsg == NULL))
1531 {
1532 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1533 "%s: Null params or global vos context is null", __func__);
1534 VOS_ASSERT(0);
1535 return VOS_STATUS_E_FAILURE;
1536 }
1537
1538 switch (msgQueueId)
1539 {
1540 /// Message Queue ID for messages bound for SME
1541 case VOS_MQ_ID_SME:
1542 {
1543 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1544 break;
1545 }
1546
1547 /// Message Queue ID for messages bound for PE
1548 case VOS_MQ_ID_PE:
1549 {
1550 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1551 break;
1552 }
1553
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 /// Message Queue ID for messages bound for WDA
1555 case VOS_MQ_ID_WDA:
1556 {
1557 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1558 break;
1559 }
1560
1561 /// Message Queue ID for messages bound for WDI
1562 case VOS_MQ_ID_WDI:
1563 {
1564 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1565 break;
1566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001567
1568 /// Message Queue ID for messages bound for TL
1569 case VOS_MQ_ID_TL:
1570 {
1571 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1572 break;
1573 }
1574
1575 /// Message Queue ID for messages bound for the SYS module
1576 case VOS_MQ_ID_SYS:
1577 {
1578 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1579 break;
1580 }
1581
1582 default:
1583
1584 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1585 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1586 __func__, msgQueueId);
1587
1588 return VOS_STATUS_E_FAILURE;
1589 }
1590
1591 VOS_ASSERT(NULL !=pTargetMq);
1592 if (pTargetMq == NULL)
1593 {
1594 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001595 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 return VOS_STATUS_E_FAILURE;
1597 }
1598
1599 /*
1600 ** Try and get a free Msg wrapper
1601 */
1602 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1603
1604 if (NULL == pMsgWrapper)
1605 {
1606 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1607 "%s: VOS Core run out of message wrapper", __func__);
1608
1609 return VOS_STATUS_E_RESOURCES;
1610 }
1611
1612 /*
1613 ** Copy the message now
1614 */
1615 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1616 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1617
1618 vos_mq_put(pTargetMq, pMsgWrapper);
1619
1620 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1621 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1622
1623 return VOS_STATUS_SUCCESS;
1624
1625} /* vos_mq_post_message()*/
1626
1627
1628/**---------------------------------------------------------------------------
1629
1630 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
1631
1632 This API allows messages to be posted to a specific message queue in the
1633 Tx excution flow. Messages for the Tx execution flow can be posted only
1634 to the following queue.
1635
1636 <ul>
1637 <li> TL
1638 <li> SSC/WDI
1639 </ul>
1640
1641 \param msgQueueId - identifies the message queue upon which the message
1642 will be posted.
1643
1644 \param message - a pointer to a message buffer. Body memory for this message
1645 buffer is allocated by the caller and free'd by the vOSS after the
1646 message is dispacthed to the appropriate component. If the consumer
1647 of the message needs to keep anything in the body, it needs to copy
1648 the contents before returning from the message handler.
1649
1650 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1651 to the message queue.
1652
1653 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1654 refer to a valid Message Queue Id.
1655
1656 VOS_STATUS_E_FAULT - message is an invalid pointer.
1657
1658 VOS_STATUS_E_FAILURE - the message queue handler has reported
1659 an unknown failure.
1660
1661 \sa
1662
1663 --------------------------------------------------------------------------*/
1664VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1665{
1666 pVosMqType pTargetMq = NULL;
1667 pVosMsgWrapper pMsgWrapper = NULL;
1668
1669 if ((gpVosContext == NULL) || (pMsg == NULL))
1670 {
1671 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1672 "%s: Null params or global vos context is null", __func__);
1673 VOS_ASSERT(0);
1674 return VOS_STATUS_E_FAILURE;
1675 }
1676
1677 switch (msgQueueId)
1678 {
1679 /// Message Queue ID for messages bound for SME
1680 case VOS_MQ_ID_TL:
1681 {
1682 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
1683 break;
1684 }
1685
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 /// Message Queue ID for messages bound for SSC
1687 case VOS_MQ_ID_WDI:
1688 {
1689 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
1690 break;
1691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001692
1693 /// Message Queue ID for messages bound for the SYS module
1694 case VOS_MQ_ID_SYS:
1695 {
1696 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
1697 break;
1698 }
1699
1700 default:
1701
1702 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301703 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 __func__, msgQueueId);
1705
1706 return VOS_STATUS_E_FAILURE;
1707 }
1708
1709 if (pTargetMq == NULL)
1710 {
1711 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001712 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 return VOS_STATUS_E_FAILURE;
1714 }
1715
1716
1717 /*
1718 ** Try and get a free Msg wrapper
1719 */
1720 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1721
1722 if (NULL == pMsgWrapper)
1723 {
1724 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1725 "%s: VOS Core run out of message wrapper", __func__);
1726
1727 return VOS_STATUS_E_RESOURCES;
1728 }
1729
1730 /*
1731 ** Copy the message now
1732 */
1733 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1734 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1735
1736 vos_mq_put(pTargetMq, pMsgWrapper);
1737
1738 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
1739 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
1740
1741 return VOS_STATUS_SUCCESS;
1742
1743} /* vos_tx_mq_serialize()*/
1744
Jeff Johnson295189b2012-06-20 16:38:30 -07001745/**---------------------------------------------------------------------------
1746
1747 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
1748
1749 This API allows messages to be posted to a specific message queue in the
1750 Tx excution flow. Messages for the Rx execution flow can be posted only
1751 to the following queue.
1752
1753 <ul>
1754 <li> TL
1755 <li> WDI
1756 </ul>
1757
1758 \param msgQueueId - identifies the message queue upon which the message
1759 will be posted.
1760
1761 \param message - a pointer to a message buffer. Body memory for this message
1762 buffer is allocated by the caller and free'd by the vOSS after the
1763 message is dispacthed to the appropriate component. If the consumer
1764 of the message needs to keep anything in the body, it needs to copy
1765 the contents before returning from the message handler.
1766
1767 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1768 to the message queue.
1769
1770 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1771 refer to a valid Message Queue Id.
1772
1773 VOS_STATUS_E_FAULT - message is an invalid pointer.
1774
1775 VOS_STATUS_E_FAILURE - the message queue handler has reported
1776 an unknown failure.
1777
1778 \sa
1779
1780 --------------------------------------------------------------------------*/
1781
1782VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1783{
1784 pVosMqType pTargetMq = NULL;
1785 pVosMsgWrapper pMsgWrapper = NULL;
1786 if ((gpVosContext == NULL) || (pMsg == NULL))
1787 {
1788 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1789 "%s: Null params or global vos context is null", __func__);
1790 VOS_ASSERT(0);
1791 return VOS_STATUS_E_FAILURE;
1792 }
1793
1794 switch (msgQueueId)
1795 {
1796
1797 case VOS_MQ_ID_SYS:
1798 {
1799 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
1800 break;
1801 }
1802
1803 /// Message Queue ID for messages bound for WDI
1804 case VOS_MQ_ID_WDI:
1805 {
1806 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
1807 break;
1808 }
Katya Nigam664f5032014-05-05 12:24:32 +05301809 case VOS_MQ_ID_TL:
1810 {
1811 pTargetMq = &(gpVosContext->vosSched.tlRxMq);
1812 break;
1813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001814
1815 default:
1816
1817 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301818 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 __func__, msgQueueId);
1820
1821 return VOS_STATUS_E_FAILURE;
1822 }
1823
1824 if (pTargetMq == NULL)
1825 {
1826 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001827 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 return VOS_STATUS_E_FAILURE;
1829 }
1830
1831
1832 /*
1833 ** Try and get a free Msg wrapper
1834 */
1835 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1836
1837 if (NULL == pMsgWrapper)
1838 {
1839 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1840 "%s: VOS Core run out of message wrapper", __func__);
1841
1842 return VOS_STATUS_E_RESOURCES;
1843 }
1844
1845 /*
1846 ** Copy the message now
1847 */
1848 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1849 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1850
1851 vos_mq_put(pTargetMq, pMsgWrapper);
1852
1853 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
1854 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
1855
1856 return VOS_STATUS_SUCCESS;
1857
1858} /* vos_rx_mq_serialize()*/
1859
Jeff Johnson295189b2012-06-20 16:38:30 -07001860v_VOID_t
1861vos_sys_probe_thread_cback
1862(
1863 v_VOID_t *pUserData
1864)
1865{
1866 if (gpVosContext != pUserData)
1867 {
1868 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001869 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 return;
1871 }
1872
1873 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
1874 {
1875 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001876 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 return;
1878 }
1879
1880} /* vos_sys_probe_thread_cback() */
1881
Jeff Johnson295189b2012-06-20 16:38:30 -07001882v_VOID_t vos_WDAComplete_cback
1883(
1884 v_VOID_t *pUserData
1885)
1886{
1887
1888 if (gpVosContext != pUserData)
1889 {
1890 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001891 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 return;
1893 }
1894
1895 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
1896 {
1897 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001898 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 return;
1900 }
1901
1902} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
1904v_VOID_t vos_core_return_msg
1905(
1906 v_PVOID_t pVContext,
1907 pVosMsgWrapper pMsgWrapper
1908)
1909{
1910 pVosContextType pVosContext = (pVosContextType) pVContext;
1911
1912 VOS_ASSERT( gpVosContext == pVosContext);
1913
1914 if (gpVosContext != pVosContext)
1915 {
1916 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001917 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 return;
1919 }
1920
1921 VOS_ASSERT( NULL !=pMsgWrapper );
1922
1923 if (pMsgWrapper == NULL)
1924 {
1925 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001926 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 return;
1928 }
1929
1930 /*
1931 ** Return the message on the free message queue
1932 */
1933 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
1934 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
1935
1936} /* vos_core_return_msg() */
1937
1938
1939/**
1940 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
1941 TL config params from the registry
1942
1943 @param pAdapter : [inout] pointer to TL config block
1944
1945 @return
1946 None
1947
1948*/
1949v_VOID_t
1950vos_fetch_tl_cfg_parms
1951(
1952 WLANTL_ConfigInfoType *pTLConfig,
1953 hdd_config_t * pConfig
1954)
1955{
1956 if (pTLConfig == NULL)
1957 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001958 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 return;
1960 }
1961
1962 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
1963 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
1964 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
1965 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301966 pTLConfig->ucAcWeights[4] = pConfig->WfqVoWeight;
Dhanashri Atred8c20a32014-01-03 17:20:55 -08001967 pTLConfig->ucReorderAgingTime[0] = pConfig->BkReorderAgingTime;/*WLANTL_AC_BK*/
1968 pTLConfig->ucReorderAgingTime[1] = pConfig->BeReorderAgingTime;/*WLANTL_AC_BE*/
1969 pTLConfig->ucReorderAgingTime[2] = pConfig->ViReorderAgingTime;/*WLANTL_AC_VI*/
1970 pTLConfig->ucReorderAgingTime[3] = pConfig->VoReorderAgingTime;/*WLANTL_AC_VO*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07001973
1974}
1975
1976v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
1977{
1978 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
1979}
1980
Jeff Johnson295189b2012-06-20 16:38:30 -07001981/*---------------------------------------------------------------------------
1982
1983 \brief vos_shutdown() - shutdown VOS
1984
1985 - All VOS submodules are closed.
1986
1987 - All the WLAN SW components should have been opened. This includes
1988 SYS, MAC, SME and TL.
1989
1990
1991 \param vosContext: Global vos context
1992
1993
1994 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
1995
1996 VOS_STATUS_E_FAILURE - Failure to close
1997
1998---------------------------------------------------------------------------*/
1999VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2000{
2001 VOS_STATUS vosStatus;
2002
2003#ifdef WLAN_BTAMP_FEATURE
2004 vosStatus = WLANBAP_Close(vosContext);
2005 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2006 {
2007 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2008 "%s: Failed to close BAP", __func__);
2009 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2010 }
2011#endif // WLAN_BTAMP_FEATURE
2012
2013 vosStatus = WLANTL_Close(vosContext);
2014 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2015 {
2016 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2017 "%s: Failed to close TL", __func__);
2018 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2019 }
2020
2021 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2022 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2023 {
2024 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2025 "%s: Failed to close SME", __func__);
2026 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2027 }
2028
2029 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2030 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2031 {
2032 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2033 "%s: Failed to close MAC", __func__);
2034 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2035 }
2036
2037 ((pVosContextType)vosContext)->pMACContext = NULL;
2038
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 vosStatus = sysClose( vosContext );
2040 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2041 {
2042 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2043 "%s: Failed to close SYS", __func__);
2044 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2045 }
2046
2047 /* Let DXE return packets in WDA_close and then free them here */
2048 vosStatus = vos_packet_close( vosContext );
2049 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2050 {
2051 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2052 "%s: Failed to close VOSS Packet", __func__);
2053 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2054 }
2055
2056 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2057
2058 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2059 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2060 {
2061 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2062 "%s: failed to destroy wdaCompleteEvent", __func__);
2063 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2064 }
2065
2066 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2067 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2068 {
2069 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2070 "%s: failed to destroy ProbeEvent", __func__);
2071 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2072 }
2073
2074 return VOS_STATUS_SUCCESS;
2075}
2076
2077/*---------------------------------------------------------------------------
2078
2079 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2080
2081 - WDA/WDI shutdown
2082
2083 \param vosContext: Global vos context
2084
2085
2086 \return VOS_STATUS_SUCCESS - Operation successfull
2087
2088 VOS_STATUS_E_FAILURE - Failure to close
2089
2090---------------------------------------------------------------------------*/
2091VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2092{
2093 VOS_STATUS vosStatus;
2094 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2095
2096 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2097 {
2098 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2099 "%s: failed to shutdown WDA", __func__);
2100 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2101 }
2102 return vosStatus;
2103}
2104/**
2105 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2106
2107 This function is called when Riva subsystem crashes. There are two
2108 methods (or operations) in WLAN driver to handle Riva crash,
2109 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2110 driver without handshaking with Riva.
2111 2. re-init: Next API
2112 @param
2113 NONE
2114 @return
2115 VOS_STATUS_SUCCESS - Operation completed successfully.
2116 VOS_STATUS_E_FAILURE - Operation failed.
2117
2118*/
2119VOS_STATUS vos_wlanShutdown(void)
2120{
2121 VOS_STATUS vstatus;
2122 vstatus = vos_watchdog_wlan_shutdown();
2123 return vstatus;
2124}
2125/**
2126 @brief vos_wlanReInit() - This API will re-init WLAN driver
2127
2128 This function is called when Riva subsystem reboots. There are two
2129 methods (or operations) in WLAN driver to handle Riva crash,
2130 1. shutdown: Previous API
2131 2. re-init: Called when Riva comes back after the crash. This will
2132 re-initialize WLAN driver. In some cases re-open may be
2133 referred instead of re-init.
2134 @param
2135 NONE
2136 @return
2137 VOS_STATUS_SUCCESS - Operation completed successfully.
2138 VOS_STATUS_E_FAILURE - Operation failed.
2139
2140*/
2141VOS_STATUS vos_wlanReInit(void)
2142{
2143 VOS_STATUS vstatus;
2144 vstatus = vos_watchdog_wlan_re_init();
2145 return vstatus;
2146}
Jeff Johnsone7245742012-09-05 17:12:55 -07002147/**
2148 @brief vos_wlanRestart() - This API will reload WLAN driver.
2149
2150 This function is called if driver detects any fatal state which
2151 can be recovered by a WLAN module reload ( Android framwork initiated ).
2152 Note that this API will not initiate any RIVA subsystem restart.
2153
2154 The function wlan_hdd_restart_driver protects against re-entrant calls.
2155
2156 @param
2157 NONE
2158 @return
2159 VOS_STATUS_SUCCESS - Operation completed successfully.
2160 VOS_STATUS_E_FAILURE - Operation failed.
2161 VOS_STATUS_E_EMPTY - No configured interface
2162 VOS_STATUS_E_ALREADY - Request already in progress
2163
2164
2165*/
2166VOS_STATUS vos_wlanRestart(void)
2167{
2168 VOS_STATUS vstatus;
2169 hdd_context_t *pHddCtx = NULL;
2170 v_CONTEXT_t pVosContext = NULL;
2171
2172 /* Check whether driver load unload is in progress */
2173 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2174 {
2175 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2176 "%s: Driver load/unload is in progress, retry later.", __func__);
2177 return VOS_STATUS_E_AGAIN;
2178 }
2179
2180 /* Get the Global VOSS Context */
2181 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2182 if(!pVosContext) {
2183 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2184 "%s: Global VOS context is Null", __func__);
2185 return VOS_STATUS_E_FAILURE;
2186 }
2187
2188 /* Get the HDD context */
2189 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2190 if(!pHddCtx) {
2191 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2192 "%s: HDD context is Null", __func__);
2193 return VOS_STATUS_E_FAILURE;
2194 }
2195
2196 /* Reload the driver */
2197 vstatus = wlan_hdd_restart_driver(pHddCtx);
2198 return vstatus;
2199}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302200
2201
2202/**
2203 @brief vos_fwDumpReq()
2204
2205 This function is called to issue dump commands to Firmware
2206
2207 @param
Siddharth Bhal68115602015-01-18 20:44:55 +05302208 cmd - Command No. to execute
2209 arg1 - argument 1 to cmd
2210 arg2 - argument 2 to cmd
2211 arg3 - argument 3 to cmd
2212 arg4 - argument 4 to cmd
2213 async - asynchronous event. Don't wait for completion.
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302214 @return
2215 NONE
2216*/
2217v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
Siddharth Bhal68115602015-01-18 20:44:55 +05302218 tANI_U32 arg3, tANI_U32 arg4, tANI_U8 async)
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302219{
Siddharth Bhalec9581a2015-02-18 14:48:18 +05302220 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL, async);
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302221}
Dino Mycle3f783bc2014-08-08 17:40:22 +05302222
2223v_U64_t vos_get_monotonic_boottime(void)
2224{
2225 struct timespec ts;
2226 wcnss_get_monotonic_boottime(&ts);
2227 return (((v_U64_t)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
2228}
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05302229
2230/**---------------------------------------------------------------------------
2231
2232 \brief vos_randomize_n_bytes() - HDD Random Mac Addr Generator
2233
2234 This generates the random mac address for WLAN interface
2235
2236 \param - mac_addr - pointer to Mac address
2237
2238 \return - 0 for success, < 0 for failure
2239
2240 --------------------------------------------------------------------------*/
2241
2242VOS_STATUS vos_randomize_n_bytes(void *start_addr, tANI_U32 n)
2243{
2244
2245 if (start_addr == NULL )
2246 return VOS_STATUS_E_FAILURE;
2247
2248 get_random_bytes( start_addr, n);
2249
2250 return eHAL_STATUS_SUCCESS;
2251}
c_hpothu8adb97b2014-12-08 19:38:20 +05302252
2253/**---------------------------------------------------------------------------
2254
2255 \brief vos_is_wlan_in_badState() - get isFatalError flag from WD Ctx
2256
2257 \param - VOS_MODULE_ID - module id
2258 - moduleContext - module context
2259
2260 \return - isFatalError value if WDCtx is valid otherwise true
2261
2262 --------------------------------------------------------------------------*/
2263v_BOOL_t vos_is_wlan_in_badState(VOS_MODULE_ID moduleId,
2264 v_VOID_t *moduleContext)
2265{
2266 struct _VosWatchdogContext *pVosWDCtx = get_vos_watchdog_ctxt();
2267
2268 if (pVosWDCtx == NULL){
2269 VOS_TRACE(moduleId, VOS_TRACE_LEVEL_ERROR,
2270 "%s: global wd context is null", __func__);
2271
2272 return TRUE;
2273 }
2274 return pVosWDCtx->isFatalError;
2275}
Girish Gowlia33f0372015-01-19 15:39:04 +05302276
Girish Gowlia33f0372015-01-19 15:39:04 +05302277/**---------------------------------------------------------------------------
2278
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302279 \brief vos_is_fw_logging_enabled() -
2280
2281 API to check if firmware is configured to send logs using DXE channel
2282
2283 \param - None
2284
Mihir Sheted6274602015-04-28 16:13:21 +05302285 \return - 0: firmware logging is not enabled (it may or may not
2286 be supported)
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302287 1: firmware logging is enabled
2288
2289 --------------------------------------------------------------------------*/
2290v_U8_t vos_is_fw_logging_enabled(void)
2291{
2292 return hdd_is_fw_logging_enabled();
2293}
2294
2295/**---------------------------------------------------------------------------
2296
Mihir Sheted6274602015-04-28 16:13:21 +05302297 \brief vos_is_fw_logging_supported() -
2298
2299 API to check if firmware supports to send logs using DXE channel
2300
2301 \param - None
2302
2303 \return - 0: firmware logging is not supported
2304 1: firmware logging is supported
2305
2306 --------------------------------------------------------------------------*/
2307v_U8_t vos_is_fw_logging_supported(void)
2308{
2309 return IS_FRAME_LOGGING_SUPPORTED_BY_FW;
2310}
2311/**---------------------------------------------------------------------------
2312
Girish Gowlia33f0372015-01-19 15:39:04 +05302313 \brief vos_set_roam_delay_stats_enabled() -
2314
2315 API to set value of roamDelayStatsEnabled in vos context
2316
2317 \param - value to be updated
2318
2319 \return - NONE
2320
2321 --------------------------------------------------------------------------*/
2322
2323v_VOID_t vos_set_roam_delay_stats_enabled(v_U8_t value)
2324{
2325 gpVosContext->roamDelayStatsEnabled = value;
2326}
2327
2328
2329/**---------------------------------------------------------------------------
2330
2331 \brief vos_get_roam_delay_stats_enabled() -
2332
2333 API to get value of roamDelayStatsEnabled from vos context
2334
2335 \param - NONE
2336
2337 \return - value of roamDelayStatsEnabled
2338
2339 --------------------------------------------------------------------------*/
2340
2341v_U8_t vos_get_roam_delay_stats_enabled(v_VOID_t)
2342{
2343 return gpVosContext->roamDelayStatsEnabled;
2344}
Katya Nigama6fbf662015-03-17 18:35:47 +05302345
2346v_U32_t vos_get_dxeReplenishRXTimerVal(void)
2347{
2348 hdd_context_t *pHddCtx = NULL;
2349 v_CONTEXT_t pVosContext = NULL;
2350
2351 /* Get the Global VOSS Context */
2352 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2353 if(!pVosContext) {
2354 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2355 return 0;
2356 }
2357
2358 /* Get the HDD context */
2359 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2360 if(!pHddCtx) {
2361 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2362 return 0;
2363 }
2364
2365 return pHddCtx->cfg_ini->dxeReplenishRXTimerVal;
2366}
2367
2368v_BOOL_t vos_get_dxeSSREnable(void)
2369{
2370 hdd_context_t *pHddCtx = NULL;
2371 v_CONTEXT_t pVosContext = NULL;
2372
2373 /* Get the Global VOSS Context */
2374 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2375 if(!pVosContext) {
2376 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2377 return FALSE;
2378 }
2379
2380 /* Get the HDD context */
2381 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2382 if(!pHddCtx) {
2383 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2384 return FALSE;
2385 }
2386
2387 return pHddCtx->cfg_ini->dxeSSREnable;
2388}
Anand N Sunkad860e5ea2015-03-30 14:41:51 +05302389
2390v_VOID_t vos_flush_work(struct work_struct *work)
2391{
2392#if defined (WLAN_OPEN_SOURCE)
2393 cancel_work_sync(work);
2394#else
2395 wcnss_flush_work(work);
2396#endif
2397}
2398
2399v_VOID_t vos_flush_delayed_work(struct delayed_work *dwork)
2400{
2401#if defined (WLAN_OPEN_SOURCE)
2402 cancel_delayed_work_sync(dwork);
2403#else
2404 wcnss_flush_delayed_work(dwork);
2405#endif
2406}
2407