blob: 4326adce4b138fe0e622f947730178f3abc27a4d [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
Katya Nigame7b69a82015-04-28 15:24:06 +0530592VOS_STATUS vos_mon_start( v_CONTEXT_t vosContext )
593{
594 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
595 pVosContextType pVosContext = (pVosContextType)vosContext;
596
597 if (pVosContext == NULL)
598 {
599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
600 "%s: mismatch in context",__func__);
601 return VOS_STATUS_E_FAILURE;
602 }
603
604 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pTLContext == NULL))
605 {
606 if (pVosContext->pWDAContext == NULL)
607 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
608 "%s: WDA NULL context", __func__);
609 else
610 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
611 "%s: TL NULL context", __func__);
612
613 return VOS_STATUS_E_FAILURE;
614 }
615
616 /* Reset wda wait event */
617 vos_event_reset(&pVosContext->wdaCompleteEvent);
618
619 /*call WDA pre start*/
620 vStatus = WDA_preStart(pVosContext);
621 if (!VOS_IS_STATUS_SUCCESS(vStatus))
622 {
623 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
624 "Failed to WDA prestart ");
625 VOS_ASSERT(0);
626 return VOS_STATUS_E_FAILURE;
627 }
628
629 /* Need to update time out of complete */
630 vStatus = vos_wait_single_event( &pVosContext->wdaCompleteEvent, 1000);
631 if ( vStatus != VOS_STATUS_SUCCESS )
632 {
633 if ( vStatus == VOS_STATUS_E_TIMEOUT )
634 {
635 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
636 "%s: Timeout occurred before WDA complete",__func__);
637 }
638 else
639 {
640 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
641 "%s: WDA_preStart reporting other error",__func__);
642 }
643 VOS_ASSERT( 0 );
644 return VOS_STATUS_E_FAILURE;
645 }
646
647 vStatus = WDA_NVDownload_Start(pVosContext);
648
649 if ( vStatus != VOS_STATUS_SUCCESS )
650 {
651 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
652 "%s: Failed to start NV Download",__func__);
653 return VOS_STATUS_E_FAILURE;
654 }
655
656 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000 * 30);
657
658 if ( vStatus != VOS_STATUS_SUCCESS )
659 {
660 if ( vStatus == VOS_STATUS_E_TIMEOUT )
661 {
662 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
663 "%s: Timeout occurred before WDA_NVDownload_Start complete",__func__);
664 }
665 else
666 {
667 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
668 "%s: WDA_NVDownload_Start reporting other error",__func__);
669 }
670 VOS_ASSERT(0);
671 return VOS_STATUS_E_FAILURE;
672 }
673
674 vStatus = WDA_start(pVosContext);
675 if (vStatus != VOS_STATUS_SUCCESS)
676 {
677 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
678 "%s: Failed to start WDA",__func__);
679 return VOS_STATUS_E_FAILURE;
680 }
681
682 /** START TL */
683 vStatus = WLANTL_Start(pVosContext);
684 if (!VOS_IS_STATUS_SUCCESS(vStatus))
685 {
686 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
687 "%s: Failed to start TL", __func__);
688 goto err_wda_stop;
689 }
690
691 return VOS_STATUS_SUCCESS;
692
693err_wda_stop:
694 vos_event_reset(&(pVosContext->wdaCompleteEvent));
695 WDA_stop(pVosContext, HAL_STOP_TYPE_RF_KILL);
696 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000);
697 if(vStatus != VOS_STATUS_SUCCESS)
698 {
699 if(vStatus == VOS_STATUS_E_TIMEOUT)
700 {
701 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
702 "%s: Timeout occurred before WDA_stop complete",__func__);
703
704 }
705 else
706 {
707 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
708 "%s: WDA_stop reporting other error",__func__);
709 }
710 VOS_ASSERT(0);
711 }
712 return VOS_STATUS_E_FAILURE;
713}
714
715VOS_STATUS vos_mon_stop( v_CONTEXT_t vosContext )
716{
717 VOS_STATUS vosStatus;
718
719 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
720
721 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
722
723 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
724 {
725 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
726 "%s: Failed to stop WDA", __func__);
727 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
728 WDA_setNeedShutdown(vosContext);
729 }
730 else
731 {
732 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
733 VOS_WDA_STOP_TIMEOUT );
734
735 if ( vosStatus != VOS_STATUS_SUCCESS )
736 {
737 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
738 {
739 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
740 "%s: Timeout occurred before WDA complete", __func__);
741 }
742 else
743 {
744 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
745 "%s: WDA_stop reporting other error", __func__ );
746 }
747 WDA_setNeedShutdown(vosContext);
748 }
749 }
750
751 vosStatus = WLANTL_Stop( vosContext );
752 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
753 {
754 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
755 "%s: Failed to stop TL", __func__);
756 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
757 }
758
759 return VOS_STATUS_SUCCESS;
760}
761
Jeff Johnson295189b2012-06-20 16:38:30 -0700762/*---------------------------------------------------------------------------
763
764 \brief vos_start() - Start the Libra SW Modules
765
766 The \a vos_start() function starts all the components of the Libra SW
767 including:
768 - SAL/BAL, which in turn starts SSC
769
770 - the MAC (HAL and PE)
771
772 - SME
773
774 - TL
775
776 - SYS: triggers the CFG download
777
778
779 \param pVosContext: The VOS context
780
781
782 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
783 is ready to be used.
784
785 VOS_STATUS_E_RESOURCES - System resources (other than memory)
786 are unavailable to initilize the scheduler
787
788
789 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
790
791 \sa vos_preStart()
792 \sa vos_open()
793
794---------------------------------------------------------------------------*/
795VOS_STATUS vos_start( v_CONTEXT_t vosContext )
796{
797 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
798 tSirRetStatus sirStatus = eSIR_SUCCESS;
799 pVosContextType pVosContext = (pVosContextType)vosContext;
800 tHalMacStartParameters halStartParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700801
802 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
803 "%s: Starting Libra SW", __func__);
804
805 /* We support only one instance for now ...*/
806 if (gpVosContext != pVosContext)
807 {
808 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700809 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 return VOS_STATUS_E_FAILURE;
811 }
812
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
814 || ( pVosContext->pTLContext == NULL))
815 {
816 if (pVosContext->pWDAContext == NULL)
817 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700818 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 else if (pVosContext->pMACContext == NULL)
820 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700821 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 else
823 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700824 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825
826 return VOS_STATUS_E_FAILURE;
827 }
828
829 /* WDA_Start will be called after NV image download because the
830 NV image data has to be updated at HAL before HAL_Start gets executed*/
831
832 /* Start the NV Image Download */
833
834 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
835
836 vStatus = WDA_NVDownload_Start(pVosContext);
837
838 if ( vStatus != VOS_STATUS_SUCCESS )
839 {
840 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
841 "%s: Failed to start NV Download", __func__);
842 return VOS_STATUS_E_FAILURE;
843 }
844
845 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
846 VOS_WDA_TIMEOUT );
847
848 if ( vStatus != VOS_STATUS_SUCCESS )
849 {
850 if ( vStatus == VOS_STATUS_E_TIMEOUT )
851 {
852 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
853 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
854 }
855 else
856 {
857 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
858 "%s: WDA_NVDownload_start reporting other error", __func__);
859 }
860 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800861 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700862 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
863 {
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530864 if (isSsrPanicOnFailure())
865 VOS_BUG(0);
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700866 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800867 WDA_setNeedShutdown(vosContext);
868 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 }
870
871 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
872 "%s: WDA_NVDownload_start correctly started", __func__);
873
874 /* Start the WDA */
875 vStatus = WDA_start(pVosContext);
876 if ( vStatus != VOS_STATUS_SUCCESS )
877 {
878 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530879 "%s: Failed to start WDA - WDA_shutdown needed", __func__);
880 if ( vStatus == VOS_STATUS_E_TIMEOUT )
881 {
882 WDA_setNeedShutdown(vosContext);
883 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 return VOS_STATUS_E_FAILURE;
885 }
886 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
887 "%s: WDA correctly started", __func__);
888
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 /* Start the MAC */
890 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 /* Start the MAC */
893 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
894
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 if (eSIR_SUCCESS != sirStatus)
896 {
897 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
898 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 }
901
902 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
903 "%s: MAC correctly started", __func__);
904
905 /* START SME */
906 vStatus = sme_Start(pVosContext->pMACContext);
907
908 if (!VOS_IS_STATUS_SUCCESS(vStatus))
909 {
910 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
911 "%s: Failed to start SME", __func__);
912 goto err_mac_stop;
913 }
914
915 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
916 "%s: SME correctly started", __func__);
917
918 /** START TL */
919 vStatus = WLANTL_Start(pVosContext);
920 if (!VOS_IS_STATUS_SUCCESS(vStatus))
921 {
922 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
923 "%s: Failed to start TL", __func__);
924 goto err_sme_stop;
925 }
926
927 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
928 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
930 "%s: VOSS Start is successful!!", __func__);
931
932 return VOS_STATUS_SUCCESS;
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934
935err_sme_stop:
Kiet Lama72a2322013-11-15 11:18:11 +0530936 sme_Stop(pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700937
938err_mac_stop:
939 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
940
Jeff Johnson295189b2012-06-20 16:38:30 -0700941err_wda_stop:
942 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800943 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
944 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800946 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
947 "%s: Failed to stop WDA", __func__);
948 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800949 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800950 }
951 else
952 {
953 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
954 VOS_WDA_TIMEOUT );
955 if( vStatus != VOS_STATUS_SUCCESS )
956 {
957 if( vStatus == VOS_STATUS_E_TIMEOUT )
958 {
959 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
960 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700961
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800962 }
963 else
964 {
965 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
966 "%s: WDA_stop reporting other error", __func__);
967 }
968 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800969 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800970 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700972
973 return VOS_STATUS_E_FAILURE;
974
975} /* vos_start() */
976
977
978/* vos_stop function */
979VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
980{
981 VOS_STATUS vosStatus;
982
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 /* WDA_Stop is called before the SYS so that the processing of Riva
984 pending responces will not be handled during uninitialization of WLAN driver */
985 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
986
987 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
988
989 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
990 {
991 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
992 "%s: Failed to stop WDA", __func__);
993 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800994 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -0700996 else
997 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800998 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
999 VOS_WDA_STOP_TIMEOUT );
Jeff Johnson295189b2012-06-20 16:38:30 -07001000
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001001 if ( vosStatus != VOS_STATUS_SUCCESS )
1002 {
1003 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1004 {
1005 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1006 "%s: Timeout occurred before WDA complete", __func__);
1007 }
1008 else
1009 {
1010 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1011 "%s: WDA_stop reporting other error", __func__ );
1012 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -07001013 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1014 "%s: Test MC thread by posting a probe message to SYS", __func__);
1015 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001016 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001019
1020 /* SYS STOP will stop SME and MAC */
1021 vosStatus = sysStop( vosContext);
1022 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1023 {
1024 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1025 "%s: Failed to stop SYS", __func__);
1026 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1027 }
1028
1029 vosStatus = WLANTL_Stop( vosContext );
1030 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1031 {
1032 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1033 "%s: Failed to stop TL", __func__);
1034 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1035 }
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
1038 return VOS_STATUS_SUCCESS;
1039}
1040
1041
1042/* vos_close function */
1043VOS_STATUS vos_close( v_CONTEXT_t vosContext )
1044{
1045 VOS_STATUS vosStatus;
1046
1047#ifdef WLAN_BTAMP_FEATURE
1048 vosStatus = WLANBAP_Close(vosContext);
1049 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1050 {
1051 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1052 "%s: Failed to close BAP", __func__);
1053 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1054 }
1055#endif // WLAN_BTAMP_FEATURE
1056
1057
1058 vosStatus = WLANTL_Close(vosContext);
1059 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1060 {
1061 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1062 "%s: Failed to close TL", __func__);
1063 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1064 }
1065
1066 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1067 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1068 {
1069 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1070 "%s: Failed to close SME", __func__);
1071 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1072 }
1073
1074 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1075 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1076 {
1077 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1078 "%s: Failed to close MAC", __func__);
1079 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1080 }
1081
1082 ((pVosContextType)vosContext)->pMACContext = NULL;
1083
Amar Singhal0a402232013-10-11 20:57:16 -07001084#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 vosStatus = vos_nv_close();
1086 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1087 {
1088 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1089 "%s: Failed to close NV", __func__);
1090 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1091 }
Amar Singhal0a402232013-10-11 20:57:16 -07001092#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
1094 vosStatus = sysClose( vosContext );
1095 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1096 {
1097 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1098 "%s: Failed to close SYS", __func__);
1099 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1100 }
1101
Jeff Johnsone7245742012-09-05 17:12:55 -07001102 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001104 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
1105 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
1106 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
1107 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07001108 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -07001109 }
1110 else
1111 {
1112 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1113 "%s: Failed to shutdown WDA", __func__ );
1114 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1115 }
1116 }
1117 else
1118 {
1119 vosStatus = WDA_close( vosContext );
1120 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1121 {
1122 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1123 "%s: Failed to close WDA", __func__);
1124 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 }
1127
1128 /* Let DXE return packets in WDA_close and then free them here */
1129 vosStatus = vos_packet_close( vosContext );
1130 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1131 {
1132 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1133 "%s: Failed to close VOSS Packet", __func__);
1134 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001136
Jeff Johnson295189b2012-06-20 16:38:30 -07001137
1138 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1139
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1141 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1142 {
1143 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1144 "%s: failed to destroy wdaCompleteEvent", __func__);
1145 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001147
1148 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1149 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1150 {
1151 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1152 "%s: failed to destroy ProbeEvent", __func__);
1153 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1154 }
1155
Girish Gowlifb0bfd32015-01-13 11:42:11 +05301156 if (gpVosContext->roamDelayStatsEnabled &&
1157 !vos_roam_delay_stats_deinit())
1158 {
1159 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1160 "%s: Could not deinit roamDelayStats", __func__);
1161 }
1162
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 return VOS_STATUS_SUCCESS;
1164}
1165
1166
1167/**---------------------------------------------------------------------------
1168
1169 \brief vos_get_context() - get context data area
1170
1171 Each module in the system has a context / data area that is allocated
1172 and maanged by voss. This API allows any user to get a pointer to its
1173 allocated context data area from the VOSS global context.
1174
1175 \param vosContext - the VOSS Global Context.
1176
1177 \param moduleId - the module ID, who's context data are is being retrived.
1178
1179 \return - pointer to the context data area.
1180
1181 - NULL if the context data is not allocated for the module ID
1182 specified
1183
1184 --------------------------------------------------------------------------*/
1185v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1186 v_CONTEXT_t pVosContext )
1187{
1188 v_PVOID_t pModContext = NULL;
1189
1190 if (pVosContext == NULL)
1191 {
1192 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001193 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 return NULL;
1195 }
1196
1197 if (gpVosContext != pVosContext)
1198 {
1199 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001200 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 return NULL;
1202 }
1203
1204 switch(moduleId)
1205 {
1206 case VOS_MODULE_ID_TL:
1207 {
1208 pModContext = gpVosContext->pTLContext;
1209 break;
1210 }
1211
Jeff Johnson295189b2012-06-20 16:38:30 -07001212#ifdef WLAN_BTAMP_FEATURE
1213 case VOS_MODULE_ID_BAP:
1214 {
1215 pModContext = gpVosContext->pBAPContext;
1216 break;
1217 }
1218#endif //WLAN_BTAMP_FEATURE
1219
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 case VOS_MODULE_ID_SAP:
1221 {
1222 pModContext = gpVosContext->pSAPContext;
1223 break;
1224 }
1225
1226 case VOS_MODULE_ID_HDD_SOFTAP:
1227 {
1228 pModContext = gpVosContext->pHDDSoftAPContext;
1229 break;
1230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001231
1232 case VOS_MODULE_ID_HDD:
1233 {
1234 pModContext = gpVosContext->pHDDContext;
1235 break;
1236 }
1237
1238 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301240 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 {
1242 /*
1243 ** In all these cases, we just return the MAC Context
1244 */
1245 pModContext = gpVosContext->pMACContext;
1246 break;
1247 }
1248
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 case VOS_MODULE_ID_WDA:
1250 {
1251 /* For WDA module */
1252 pModContext = gpVosContext->pWDAContext;
1253 break;
1254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001255
1256 case VOS_MODULE_ID_VOSS:
1257 {
1258 /* For SYS this is VOS itself*/
1259 pModContext = gpVosContext;
1260 break;
1261 }
1262
1263 default:
1264 {
1265 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1266 "does not have its context maintained by VOSS", __func__, moduleId);
1267 VOS_ASSERT(0);
1268 return NULL;
1269 }
1270 }
1271
1272 if (pModContext == NULL )
1273 {
1274 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1275 "context is Null", __func__, moduleId);
1276 }
1277
1278 return pModContext;
1279
1280} /* vos_get_context()*/
1281
1282
1283/**---------------------------------------------------------------------------
1284
1285 \brief vos_get_global_context() - get VOSS global Context
1286
1287 This API allows any user to get the VOS Global Context pointer from a
1288 module context data area.
1289
1290 \param moduleContext - the input module context pointer
1291
1292 \param moduleId - the module ID who's context pointer is input in
1293 moduleContext.
1294
1295 \return - pointer to the VOSS global context
1296
1297 - NULL if the function is unable to retreive the VOSS context.
1298
1299 --------------------------------------------------------------------------*/
1300v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1301 v_VOID_t *moduleContext )
1302{
1303 if (gpVosContext == NULL)
1304 {
1305 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001306 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 }
1308
1309 return gpVosContext;
1310
1311} /* vos_get_global_context() */
1312
1313
1314v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1315{
1316 if (gpVosContext == NULL)
1317 {
1318 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001319 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 return 1;
1321 }
1322
1323 return gpVosContext->isLogpInProgress;
1324}
1325
1326void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1327{
1328 if (gpVosContext == NULL)
1329 {
1330 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001331 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 return;
1333 }
1334
1335 gpVosContext->isLogpInProgress = value;
1336}
1337
1338v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1339{
1340 if (gpVosContext == NULL)
1341 {
1342 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001343 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 return 0;
1345 }
1346
1347 return gpVosContext->isLoadUnloadInProgress;
1348}
1349
1350void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
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;
1357 }
1358
1359 gpVosContext->isLoadUnloadInProgress = value;
1360}
1361
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001362v_U8_t vos_is_reinit_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1363{
1364 if (gpVosContext == NULL)
1365 {
1366 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1367 "%s: global voss context is NULL", __func__);
1368 return 1;
1369 }
1370
1371 return gpVosContext->isReInitInProgress;
1372}
1373
1374void vos_set_reinit_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1375{
1376 if (gpVosContext == NULL)
1377 {
1378 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1379 "%s: global voss context is NULL", __func__);
1380 return;
1381 }
1382
1383 gpVosContext->isReInitInProgress = value;
1384}
1385
1386
Jeff Johnson295189b2012-06-20 16:38:30 -07001387/**---------------------------------------------------------------------------
1388
1389 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1390
1391 This API allows any user to allocate a user context area within the
1392 VOS Global Context.
1393
1394 \param pVosContext - pointer to the global Vos context
1395
1396 \param moduleId - the module ID who's context area is being allocated.
1397
1398 \param ppModuleContext - pointer to location where the pointer to the
1399 allocated context is returned. Note this
1400 output pointer is valid only if the API
1401 returns VOS_STATUS_SUCCESS
1402
1403 \param size - the size of the context area to be allocated.
1404
1405 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1406 allocated successfully. The pointer to the context area
1407 can be found in *ppModuleContext.
1408 \note This function returns VOS_STATUS_SUCCESS if the
1409 module context was already allocated and the size
1410 allocated matches the size on this call.
1411
1412 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1413 not identify a module that can have a context allocated.
1414
1415 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1416 because a context for this module ID already exists and it is
1417 a *different* size that specified on this call.
1418
1419 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1420 requested context area.
1421
1422 \sa vos_get_context(), vos_free_context()
1423
1424 --------------------------------------------------------------------------*/
1425VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1426 v_VOID_t **ppModuleContext, v_SIZE_t size )
1427{
1428 v_VOID_t ** pGpModContext = NULL;
1429
1430 if ( pVosContext == NULL) {
1431 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001432 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 return VOS_STATUS_E_FAILURE;
1434 }
1435
1436 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1437 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001438 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 return VOS_STATUS_E_FAILURE;
1440 }
1441
1442 switch(moduleID)
1443 {
1444 case VOS_MODULE_ID_TL:
1445 {
1446 pGpModContext = &(gpVosContext->pTLContext);
1447 break;
1448 }
1449
Jeff Johnson295189b2012-06-20 16:38:30 -07001450#ifdef WLAN_BTAMP_FEATURE
1451 case VOS_MODULE_ID_BAP:
1452 {
1453 pGpModContext = &(gpVosContext->pBAPContext);
1454 break;
1455 }
1456#endif //WLAN_BTAMP_FEATURE
1457
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 case VOS_MODULE_ID_SAP:
1459 {
1460 pGpModContext = &(gpVosContext->pSAPContext);
1461 break;
1462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001463
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 case VOS_MODULE_ID_WDA:
1465 {
1466 pGpModContext = &(gpVosContext->pWDAContext);
1467 break;
1468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301471 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 default:
1475 {
1476 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1477 "does not have its context allocated by VOSS", __func__, moduleID);
1478 VOS_ASSERT(0);
1479 return VOS_STATUS_E_INVAL;
1480 }
1481 }
1482
1483 if ( NULL != *pGpModContext)
1484 {
1485 /*
1486 ** Context has already been allocated!
1487 ** Prevent double allocation
1488 */
1489 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1490 "%s: Module ID %i context has already been allocated",
1491 __func__, moduleID);
1492 return VOS_STATUS_E_EXISTS;
1493 }
1494
1495 /*
1496 ** Dynamically allocate the context for module
1497 */
1498
1499 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1500
1501
1502 if ( *ppModuleContext == NULL)
1503 {
1504 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1505 "allocate Context for module ID %i", __func__, moduleID);
1506 VOS_ASSERT(0);
1507 return VOS_STATUS_E_NOMEM;
1508 }
1509
1510 if (moduleID==VOS_MODULE_ID_TL)
1511 {
1512 vos_mem_zero(*ppModuleContext, size);
1513 }
1514
1515 *pGpModContext = *ppModuleContext;
1516
1517 return VOS_STATUS_SUCCESS;
1518
1519} /* vos_alloc_context() */
1520
1521
1522/**---------------------------------------------------------------------------
1523
1524 \brief vos_free_context() - free an allocated a context within the
1525 VOSS global Context
1526
1527 This API allows a user to free the user context area within the
1528 VOS Global Context.
1529
1530 \param pVosContext - pointer to the global Vos context
1531
1532 \param moduleId - the module ID who's context area is being free
1533
1534 \param pModuleContext - pointer to module context area to be free'd.
1535
1536 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1537 free'd. The pointer to the context area is not longer
1538 available.
1539
1540 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1541 valid pointers.
1542
1543 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1544 not identify a module that can have a context free'd.
1545
1546 VOS_STATUS_E_EXISTS - vos could not free the requested
1547 context area because a context for this module ID does not
1548 exist in the global vos context.
1549
1550 \sa vos_get_context()
1551
1552 --------------------------------------------------------------------------*/
1553VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1554 v_VOID_t *pModuleContext )
1555{
1556 v_VOID_t ** pGpModContext = NULL;
1557
1558 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1559 ( pModuleContext == NULL))
1560 {
1561 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1562 "%s: Null params or context mismatch", __func__);
1563 return VOS_STATUS_E_FAILURE;
1564 }
1565
1566
1567 switch(moduleID)
1568 {
1569 case VOS_MODULE_ID_TL:
1570 {
1571 pGpModContext = &(gpVosContext->pTLContext);
1572 break;
1573 }
1574
Jeff Johnson295189b2012-06-20 16:38:30 -07001575#ifdef WLAN_BTAMP_FEATURE
1576 case VOS_MODULE_ID_BAP:
1577 {
1578 pGpModContext = &(gpVosContext->pBAPContext);
1579 break;
1580 }
1581#endif //WLAN_BTAMP_FEATURE
1582
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 case VOS_MODULE_ID_SAP:
1584 {
1585 pGpModContext = &(gpVosContext->pSAPContext);
1586 break;
1587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001588
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 case VOS_MODULE_ID_WDA:
1590 {
1591 pGpModContext = &(gpVosContext->pWDAContext);
1592 break;
1593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 case VOS_MODULE_ID_HDD:
1595 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301597 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 default:
1600 {
1601 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1602 "does not have its context allocated by VOSS", __func__, moduleID);
1603 VOS_ASSERT(0);
1604 return VOS_STATUS_E_INVAL;
1605 }
1606 }
1607
1608 if ( NULL == *pGpModContext)
1609 {
1610 /*
1611 ** Context has not been allocated or freed already!
1612 */
1613 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1614 "context has not been allocated or freed already", __func__,moduleID);
1615 return VOS_STATUS_E_FAILURE;
1616 }
1617
1618 if (*pGpModContext != pModuleContext)
1619 {
1620 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001621 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 return VOS_STATUS_E_FAILURE;
1623 }
1624
1625 if(pModuleContext != NULL)
1626 kfree(pModuleContext);
1627
1628 *pGpModContext = NULL;
1629
1630 return VOS_STATUS_SUCCESS;
1631
1632} /* vos_free_context() */
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301633
1634/**---------------------------------------------------------------------------
1635
1636 \brief vos_logger_pkt_serialize() - queue a logging vos pkt
1637
1638 This API allows single vos pkt to be queued and later sent to userspace by
1639 logger thread.
1640
1641 \param pPacket - a pointer to a vos pkt to be queued
1642 pkt_type - type of pkt to be queued
1643 LOG_PKT_TYPE_DATA_MGMT - frame log i.e data/mgmt pkts
1644
1645 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1646 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1647 a failure.
1648 --------------------------------------------------------------------------*/
Mihir Sheteccafc0c2015-04-17 16:13:15 +05301649VOS_STATUS vos_logger_pkt_serialize( vos_pkt_t *pPacket, uint32 pkt_type)
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301650{
1651#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1652 return wlan_queue_logpkt_for_app(pPacket, pkt_type);
1653#else
1654 return vos_pkt_return_packet(pPacket);
1655#endif
1656}
Jeff Johnson295189b2012-06-20 16:38:30 -07001657
1658/**---------------------------------------------------------------------------
1659
1660 \brief vos_mq_post_message() - post a message to a message queue
1661
1662 This API allows messages to be posted to a specific message queue. Messages
1663 can be posted to the following message queues:
1664
1665 <ul>
1666 <li> SME
1667 <li> PE
1668 <li> HAL
1669 <li> TL
1670 </ul>
1671
1672 \param msgQueueId - identifies the message queue upon which the message
1673 will be posted.
1674
1675 \param message - a pointer to a message buffer. Memory for this message
1676 buffer is allocated by the caller and free'd by the vOSS after the
1677 message is posted to the message queue. If the consumer of the
1678 message needs anything in this message, it needs to copy the contents
1679 before returning from the message queue handler.
1680
1681 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1682 to the message queue.
1683
1684 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1685 refer to a valid Message Queue Id.
1686
1687 VOS_STATUS_E_FAULT - message is an invalid pointer.
1688
1689 VOS_STATUS_E_FAILURE - the message queue handler has reported
1690 an unknown failure.
1691
1692 \sa
1693
1694 --------------------------------------------------------------------------*/
1695VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1696{
1697 pVosMqType pTargetMq = NULL;
1698 pVosMsgWrapper pMsgWrapper = NULL;
1699
1700 if ((gpVosContext == NULL) || (pMsg == NULL))
1701 {
1702 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1703 "%s: Null params or global vos context is null", __func__);
1704 VOS_ASSERT(0);
1705 return VOS_STATUS_E_FAILURE;
1706 }
1707
1708 switch (msgQueueId)
1709 {
1710 /// Message Queue ID for messages bound for SME
1711 case VOS_MQ_ID_SME:
1712 {
1713 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
1714 break;
1715 }
1716
1717 /// Message Queue ID for messages bound for PE
1718 case VOS_MQ_ID_PE:
1719 {
1720 pTargetMq = &(gpVosContext->vosSched.peMcMq);
1721 break;
1722 }
1723
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 /// Message Queue ID for messages bound for WDA
1725 case VOS_MQ_ID_WDA:
1726 {
1727 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
1728 break;
1729 }
1730
1731 /// Message Queue ID for messages bound for WDI
1732 case VOS_MQ_ID_WDI:
1733 {
1734 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
1735 break;
1736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001737
1738 /// Message Queue ID for messages bound for TL
1739 case VOS_MQ_ID_TL:
1740 {
1741 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
1742 break;
1743 }
1744
1745 /// Message Queue ID for messages bound for the SYS module
1746 case VOS_MQ_ID_SYS:
1747 {
1748 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
1749 break;
1750 }
1751
1752 default:
1753
1754 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1755 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
1756 __func__, msgQueueId);
1757
1758 return VOS_STATUS_E_FAILURE;
1759 }
1760
1761 VOS_ASSERT(NULL !=pTargetMq);
1762 if (pTargetMq == NULL)
1763 {
1764 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001765 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 return VOS_STATUS_E_FAILURE;
1767 }
1768
1769 /*
1770 ** Try and get a free Msg wrapper
1771 */
1772 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1773
1774 if (NULL == pMsgWrapper)
1775 {
1776 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1777 "%s: VOS Core run out of message wrapper", __func__);
1778
1779 return VOS_STATUS_E_RESOURCES;
1780 }
1781
1782 /*
1783 ** Copy the message now
1784 */
1785 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1786 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1787
1788 vos_mq_put(pTargetMq, pMsgWrapper);
1789
1790 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
1791 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
1792
1793 return VOS_STATUS_SUCCESS;
1794
1795} /* vos_mq_post_message()*/
1796
1797
1798/**---------------------------------------------------------------------------
1799
1800 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
1801
1802 This API allows messages to be posted to a specific message queue in the
1803 Tx excution flow. Messages for the Tx execution flow can be posted only
1804 to the following queue.
1805
1806 <ul>
1807 <li> TL
1808 <li> SSC/WDI
1809 </ul>
1810
1811 \param msgQueueId - identifies the message queue upon which the message
1812 will be posted.
1813
1814 \param message - a pointer to a message buffer. Body memory for this message
1815 buffer is allocated by the caller and free'd by the vOSS after the
1816 message is dispacthed to the appropriate component. If the consumer
1817 of the message needs to keep anything in the body, it needs to copy
1818 the contents before returning from the message handler.
1819
1820 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1821 to the message queue.
1822
1823 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1824 refer to a valid Message Queue Id.
1825
1826 VOS_STATUS_E_FAULT - message is an invalid pointer.
1827
1828 VOS_STATUS_E_FAILURE - the message queue handler has reported
1829 an unknown failure.
1830
1831 \sa
1832
1833 --------------------------------------------------------------------------*/
1834VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1835{
1836 pVosMqType pTargetMq = NULL;
1837 pVosMsgWrapper pMsgWrapper = NULL;
1838
1839 if ((gpVosContext == NULL) || (pMsg == NULL))
1840 {
1841 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1842 "%s: Null params or global vos context is null", __func__);
1843 VOS_ASSERT(0);
1844 return VOS_STATUS_E_FAILURE;
1845 }
1846
1847 switch (msgQueueId)
1848 {
1849 /// Message Queue ID for messages bound for SME
1850 case VOS_MQ_ID_TL:
1851 {
1852 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
1853 break;
1854 }
1855
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 /// Message Queue ID for messages bound for SSC
1857 case VOS_MQ_ID_WDI:
1858 {
1859 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
1860 break;
1861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001862
1863 /// Message Queue ID for messages bound for the SYS module
1864 case VOS_MQ_ID_SYS:
1865 {
1866 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
1867 break;
1868 }
1869
1870 default:
1871
1872 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301873 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 __func__, msgQueueId);
1875
1876 return VOS_STATUS_E_FAILURE;
1877 }
1878
1879 if (pTargetMq == NULL)
1880 {
1881 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001882 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 return VOS_STATUS_E_FAILURE;
1884 }
1885
1886
1887 /*
1888 ** Try and get a free Msg wrapper
1889 */
1890 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
1891
1892 if (NULL == pMsgWrapper)
1893 {
1894 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1895 "%s: VOS Core run out of message wrapper", __func__);
1896
1897 return VOS_STATUS_E_RESOURCES;
1898 }
1899
1900 /*
1901 ** Copy the message now
1902 */
1903 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
1904 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
1905
1906 vos_mq_put(pTargetMq, pMsgWrapper);
1907
1908 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
1909 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
1910
1911 return VOS_STATUS_SUCCESS;
1912
1913} /* vos_tx_mq_serialize()*/
1914
Jeff Johnson295189b2012-06-20 16:38:30 -07001915/**---------------------------------------------------------------------------
1916
1917 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
1918
1919 This API allows messages to be posted to a specific message queue in the
1920 Tx excution flow. Messages for the Rx execution flow can be posted only
1921 to the following queue.
1922
1923 <ul>
1924 <li> TL
1925 <li> WDI
1926 </ul>
1927
1928 \param msgQueueId - identifies the message queue upon which the message
1929 will be posted.
1930
1931 \param message - a pointer to a message buffer. Body memory for this message
1932 buffer is allocated by the caller and free'd by the vOSS after the
1933 message is dispacthed to the appropriate component. If the consumer
1934 of the message needs to keep anything in the body, it needs to copy
1935 the contents before returning from the message handler.
1936
1937 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1938 to the message queue.
1939
1940 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1941 refer to a valid Message Queue Id.
1942
1943 VOS_STATUS_E_FAULT - message is an invalid pointer.
1944
1945 VOS_STATUS_E_FAILURE - the message queue handler has reported
1946 an unknown failure.
1947
1948 \sa
1949
1950 --------------------------------------------------------------------------*/
1951
1952VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1953{
1954 pVosMqType pTargetMq = NULL;
1955 pVosMsgWrapper pMsgWrapper = NULL;
1956 if ((gpVosContext == NULL) || (pMsg == NULL))
1957 {
1958 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1959 "%s: Null params or global vos context is null", __func__);
1960 VOS_ASSERT(0);
1961 return VOS_STATUS_E_FAILURE;
1962 }
1963
1964 switch (msgQueueId)
1965 {
1966
1967 case VOS_MQ_ID_SYS:
1968 {
1969 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
1970 break;
1971 }
1972
1973 /// Message Queue ID for messages bound for WDI
1974 case VOS_MQ_ID_WDI:
1975 {
1976 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
1977 break;
1978 }
Katya Nigam664f5032014-05-05 12:24:32 +05301979 case VOS_MQ_ID_TL:
1980 {
1981 pTargetMq = &(gpVosContext->vosSched.tlRxMq);
1982 break;
1983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001984
1985 default:
1986
1987 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301988 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 __func__, msgQueueId);
1990
1991 return VOS_STATUS_E_FAILURE;
1992 }
1993
1994 if (pTargetMq == NULL)
1995 {
1996 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001997 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 return VOS_STATUS_E_FAILURE;
1999 }
2000
2001
2002 /*
2003 ** Try and get a free Msg wrapper
2004 */
2005 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2006
2007 if (NULL == pMsgWrapper)
2008 {
2009 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2010 "%s: VOS Core run out of message wrapper", __func__);
2011
2012 return VOS_STATUS_E_RESOURCES;
2013 }
2014
2015 /*
2016 ** Copy the message now
2017 */
2018 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2019 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2020
2021 vos_mq_put(pTargetMq, pMsgWrapper);
2022
2023 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
2024 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
2025
2026 return VOS_STATUS_SUCCESS;
2027
2028} /* vos_rx_mq_serialize()*/
2029
Jeff Johnson295189b2012-06-20 16:38:30 -07002030v_VOID_t
2031vos_sys_probe_thread_cback
2032(
2033 v_VOID_t *pUserData
2034)
2035{
2036 if (gpVosContext != pUserData)
2037 {
2038 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002039 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 return;
2041 }
2042
2043 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2044 {
2045 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002046 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 return;
2048 }
2049
2050} /* vos_sys_probe_thread_cback() */
2051
Jeff Johnson295189b2012-06-20 16:38:30 -07002052v_VOID_t vos_WDAComplete_cback
2053(
2054 v_VOID_t *pUserData
2055)
2056{
2057
2058 if (gpVosContext != pUserData)
2059 {
2060 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002061 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 return;
2063 }
2064
2065 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
2066 {
2067 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002068 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 return;
2070 }
2071
2072} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07002073
2074v_VOID_t vos_core_return_msg
2075(
2076 v_PVOID_t pVContext,
2077 pVosMsgWrapper pMsgWrapper
2078)
2079{
2080 pVosContextType pVosContext = (pVosContextType) pVContext;
2081
2082 VOS_ASSERT( gpVosContext == pVosContext);
2083
2084 if (gpVosContext != pVosContext)
2085 {
2086 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002087 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 return;
2089 }
2090
2091 VOS_ASSERT( NULL !=pMsgWrapper );
2092
2093 if (pMsgWrapper == NULL)
2094 {
2095 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002096 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 return;
2098 }
2099
2100 /*
2101 ** Return the message on the free message queue
2102 */
2103 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
2104 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
2105
2106} /* vos_core_return_msg() */
2107
2108
2109/**
2110 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
2111 TL config params from the registry
2112
2113 @param pAdapter : [inout] pointer to TL config block
2114
2115 @return
2116 None
2117
2118*/
2119v_VOID_t
2120vos_fetch_tl_cfg_parms
2121(
2122 WLANTL_ConfigInfoType *pTLConfig,
2123 hdd_config_t * pConfig
2124)
2125{
2126 if (pTLConfig == NULL)
2127 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002128 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 return;
2130 }
2131
2132 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
2133 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
2134 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
2135 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302136 pTLConfig->ucAcWeights[4] = pConfig->WfqVoWeight;
Dhanashri Atred8c20a32014-01-03 17:20:55 -08002137 pTLConfig->ucReorderAgingTime[0] = pConfig->BkReorderAgingTime;/*WLANTL_AC_BK*/
2138 pTLConfig->ucReorderAgingTime[1] = pConfig->BeReorderAgingTime;/*WLANTL_AC_BE*/
2139 pTLConfig->ucReorderAgingTime[2] = pConfig->ViReorderAgingTime;/*WLANTL_AC_VI*/
2140 pTLConfig->ucReorderAgingTime[3] = pConfig->VoReorderAgingTime;/*WLANTL_AC_VO*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07002143
2144}
2145
2146v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
2147{
2148 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
2149}
2150
Jeff Johnson295189b2012-06-20 16:38:30 -07002151/*---------------------------------------------------------------------------
2152
2153 \brief vos_shutdown() - shutdown VOS
2154
2155 - All VOS submodules are closed.
2156
2157 - All the WLAN SW components should have been opened. This includes
2158 SYS, MAC, SME and TL.
2159
2160
2161 \param vosContext: Global vos context
2162
2163
2164 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
2165
2166 VOS_STATUS_E_FAILURE - Failure to close
2167
2168---------------------------------------------------------------------------*/
2169VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2170{
2171 VOS_STATUS vosStatus;
2172
2173#ifdef WLAN_BTAMP_FEATURE
2174 vosStatus = WLANBAP_Close(vosContext);
2175 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2176 {
2177 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2178 "%s: Failed to close BAP", __func__);
2179 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2180 }
2181#endif // WLAN_BTAMP_FEATURE
2182
2183 vosStatus = WLANTL_Close(vosContext);
2184 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2185 {
2186 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2187 "%s: Failed to close TL", __func__);
2188 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2189 }
2190
2191 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2192 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2193 {
2194 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2195 "%s: Failed to close SME", __func__);
2196 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2197 }
2198
2199 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2200 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2201 {
2202 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2203 "%s: Failed to close MAC", __func__);
2204 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2205 }
2206
2207 ((pVosContextType)vosContext)->pMACContext = NULL;
2208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 vosStatus = sysClose( vosContext );
2210 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2211 {
2212 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2213 "%s: Failed to close SYS", __func__);
2214 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2215 }
2216
2217 /* Let DXE return packets in WDA_close and then free them here */
2218 vosStatus = vos_packet_close( vosContext );
2219 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2220 {
2221 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2222 "%s: Failed to close VOSS Packet", __func__);
2223 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2224 }
2225
2226 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2227
2228 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2229 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2230 {
2231 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2232 "%s: failed to destroy wdaCompleteEvent", __func__);
2233 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2234 }
2235
2236 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2237 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2238 {
2239 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2240 "%s: failed to destroy ProbeEvent", __func__);
2241 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2242 }
2243
2244 return VOS_STATUS_SUCCESS;
2245}
2246
2247/*---------------------------------------------------------------------------
2248
2249 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2250
2251 - WDA/WDI shutdown
2252
2253 \param vosContext: Global vos context
2254
2255
2256 \return VOS_STATUS_SUCCESS - Operation successfull
2257
2258 VOS_STATUS_E_FAILURE - Failure to close
2259
2260---------------------------------------------------------------------------*/
2261VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2262{
2263 VOS_STATUS vosStatus;
2264 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2265
2266 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2267 {
2268 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2269 "%s: failed to shutdown WDA", __func__);
2270 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2271 }
2272 return vosStatus;
2273}
2274/**
2275 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2276
2277 This function is called when Riva subsystem crashes. There are two
2278 methods (or operations) in WLAN driver to handle Riva crash,
2279 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2280 driver without handshaking with Riva.
2281 2. re-init: Next API
2282 @param
2283 NONE
2284 @return
2285 VOS_STATUS_SUCCESS - Operation completed successfully.
2286 VOS_STATUS_E_FAILURE - Operation failed.
2287
2288*/
2289VOS_STATUS vos_wlanShutdown(void)
2290{
2291 VOS_STATUS vstatus;
2292 vstatus = vos_watchdog_wlan_shutdown();
2293 return vstatus;
2294}
2295/**
2296 @brief vos_wlanReInit() - This API will re-init WLAN driver
2297
2298 This function is called when Riva subsystem reboots. There are two
2299 methods (or operations) in WLAN driver to handle Riva crash,
2300 1. shutdown: Previous API
2301 2. re-init: Called when Riva comes back after the crash. This will
2302 re-initialize WLAN driver. In some cases re-open may be
2303 referred instead of re-init.
2304 @param
2305 NONE
2306 @return
2307 VOS_STATUS_SUCCESS - Operation completed successfully.
2308 VOS_STATUS_E_FAILURE - Operation failed.
2309
2310*/
2311VOS_STATUS vos_wlanReInit(void)
2312{
2313 VOS_STATUS vstatus;
2314 vstatus = vos_watchdog_wlan_re_init();
2315 return vstatus;
2316}
Jeff Johnsone7245742012-09-05 17:12:55 -07002317/**
2318 @brief vos_wlanRestart() - This API will reload WLAN driver.
2319
2320 This function is called if driver detects any fatal state which
2321 can be recovered by a WLAN module reload ( Android framwork initiated ).
2322 Note that this API will not initiate any RIVA subsystem restart.
2323
2324 The function wlan_hdd_restart_driver protects against re-entrant calls.
2325
2326 @param
2327 NONE
2328 @return
2329 VOS_STATUS_SUCCESS - Operation completed successfully.
2330 VOS_STATUS_E_FAILURE - Operation failed.
2331 VOS_STATUS_E_EMPTY - No configured interface
2332 VOS_STATUS_E_ALREADY - Request already in progress
2333
2334
2335*/
2336VOS_STATUS vos_wlanRestart(void)
2337{
2338 VOS_STATUS vstatus;
2339 hdd_context_t *pHddCtx = NULL;
2340 v_CONTEXT_t pVosContext = NULL;
2341
2342 /* Check whether driver load unload is in progress */
2343 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2344 {
2345 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2346 "%s: Driver load/unload is in progress, retry later.", __func__);
2347 return VOS_STATUS_E_AGAIN;
2348 }
2349
2350 /* Get the Global VOSS Context */
2351 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2352 if(!pVosContext) {
2353 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2354 "%s: Global VOS context is Null", __func__);
2355 return VOS_STATUS_E_FAILURE;
2356 }
2357
2358 /* Get the HDD context */
2359 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2360 if(!pHddCtx) {
2361 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2362 "%s: HDD context is Null", __func__);
2363 return VOS_STATUS_E_FAILURE;
2364 }
2365
2366 /* Reload the driver */
2367 vstatus = wlan_hdd_restart_driver(pHddCtx);
2368 return vstatus;
2369}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302370
2371
2372/**
2373 @brief vos_fwDumpReq()
2374
2375 This function is called to issue dump commands to Firmware
2376
2377 @param
Siddharth Bhal68115602015-01-18 20:44:55 +05302378 cmd - Command No. to execute
2379 arg1 - argument 1 to cmd
2380 arg2 - argument 2 to cmd
2381 arg3 - argument 3 to cmd
2382 arg4 - argument 4 to cmd
2383 async - asynchronous event. Don't wait for completion.
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302384 @return
2385 NONE
2386*/
2387v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
Siddharth Bhal68115602015-01-18 20:44:55 +05302388 tANI_U32 arg3, tANI_U32 arg4, tANI_U8 async)
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302389{
Siddharth Bhalec9581a2015-02-18 14:48:18 +05302390 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL, async);
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302391}
Dino Mycle3f783bc2014-08-08 17:40:22 +05302392
2393v_U64_t vos_get_monotonic_boottime(void)
2394{
2395 struct timespec ts;
2396 wcnss_get_monotonic_boottime(&ts);
2397 return (((v_U64_t)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
2398}
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05302399
2400/**---------------------------------------------------------------------------
2401
2402 \brief vos_randomize_n_bytes() - HDD Random Mac Addr Generator
2403
2404 This generates the random mac address for WLAN interface
2405
2406 \param - mac_addr - pointer to Mac address
2407
2408 \return - 0 for success, < 0 for failure
2409
2410 --------------------------------------------------------------------------*/
2411
2412VOS_STATUS vos_randomize_n_bytes(void *start_addr, tANI_U32 n)
2413{
2414
2415 if (start_addr == NULL )
2416 return VOS_STATUS_E_FAILURE;
2417
2418 get_random_bytes( start_addr, n);
2419
2420 return eHAL_STATUS_SUCCESS;
2421}
c_hpothu8adb97b2014-12-08 19:38:20 +05302422
2423/**---------------------------------------------------------------------------
2424
2425 \brief vos_is_wlan_in_badState() - get isFatalError flag from WD Ctx
2426
2427 \param - VOS_MODULE_ID - module id
2428 - moduleContext - module context
2429
2430 \return - isFatalError value if WDCtx is valid otherwise true
2431
2432 --------------------------------------------------------------------------*/
2433v_BOOL_t vos_is_wlan_in_badState(VOS_MODULE_ID moduleId,
2434 v_VOID_t *moduleContext)
2435{
2436 struct _VosWatchdogContext *pVosWDCtx = get_vos_watchdog_ctxt();
2437
2438 if (pVosWDCtx == NULL){
2439 VOS_TRACE(moduleId, VOS_TRACE_LEVEL_ERROR,
2440 "%s: global wd context is null", __func__);
2441
2442 return TRUE;
2443 }
2444 return pVosWDCtx->isFatalError;
2445}
Girish Gowlia33f0372015-01-19 15:39:04 +05302446
Girish Gowlia33f0372015-01-19 15:39:04 +05302447/**---------------------------------------------------------------------------
2448
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302449 \brief vos_is_fw_logging_enabled() -
2450
2451 API to check if firmware is configured to send logs using DXE channel
2452
2453 \param - None
2454
Mihir Sheted6274602015-04-28 16:13:21 +05302455 \return - 0: firmware logging is not enabled (it may or may not
2456 be supported)
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302457 1: firmware logging is enabled
2458
2459 --------------------------------------------------------------------------*/
2460v_U8_t vos_is_fw_logging_enabled(void)
2461{
2462 return hdd_is_fw_logging_enabled();
2463}
2464
2465/**---------------------------------------------------------------------------
2466
Mihir Sheted6274602015-04-28 16:13:21 +05302467 \brief vos_is_fw_logging_supported() -
2468
2469 API to check if firmware supports to send logs using DXE channel
2470
2471 \param - None
2472
2473 \return - 0: firmware logging is not supported
2474 1: firmware logging is supported
2475
2476 --------------------------------------------------------------------------*/
2477v_U8_t vos_is_fw_logging_supported(void)
2478{
2479 return IS_FRAME_LOGGING_SUPPORTED_BY_FW;
2480}
2481/**---------------------------------------------------------------------------
2482
Girish Gowlia33f0372015-01-19 15:39:04 +05302483 \brief vos_set_roam_delay_stats_enabled() -
2484
2485 API to set value of roamDelayStatsEnabled in vos context
2486
2487 \param - value to be updated
2488
2489 \return - NONE
2490
2491 --------------------------------------------------------------------------*/
2492
2493v_VOID_t vos_set_roam_delay_stats_enabled(v_U8_t value)
2494{
2495 gpVosContext->roamDelayStatsEnabled = value;
2496}
2497
2498
2499/**---------------------------------------------------------------------------
2500
2501 \brief vos_get_roam_delay_stats_enabled() -
2502
2503 API to get value of roamDelayStatsEnabled from vos context
2504
2505 \param - NONE
2506
2507 \return - value of roamDelayStatsEnabled
2508
2509 --------------------------------------------------------------------------*/
2510
2511v_U8_t vos_get_roam_delay_stats_enabled(v_VOID_t)
2512{
2513 return gpVosContext->roamDelayStatsEnabled;
2514}
Katya Nigama6fbf662015-03-17 18:35:47 +05302515
2516v_U32_t vos_get_dxeReplenishRXTimerVal(void)
2517{
2518 hdd_context_t *pHddCtx = NULL;
2519 v_CONTEXT_t pVosContext = NULL;
2520
2521 /* Get the Global VOSS Context */
2522 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2523 if(!pVosContext) {
2524 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2525 return 0;
2526 }
2527
2528 /* Get the HDD context */
2529 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2530 if(!pHddCtx) {
2531 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2532 return 0;
2533 }
2534
2535 return pHddCtx->cfg_ini->dxeReplenishRXTimerVal;
2536}
2537
2538v_BOOL_t vos_get_dxeSSREnable(void)
2539{
2540 hdd_context_t *pHddCtx = NULL;
2541 v_CONTEXT_t pVosContext = NULL;
2542
2543 /* Get the Global VOSS Context */
2544 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2545 if(!pVosContext) {
2546 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2547 return FALSE;
2548 }
2549
2550 /* Get the HDD context */
2551 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2552 if(!pHddCtx) {
2553 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2554 return FALSE;
2555 }
2556
2557 return pHddCtx->cfg_ini->dxeSSREnable;
2558}
Anand N Sunkad860e5ea2015-03-30 14:41:51 +05302559
2560v_VOID_t vos_flush_work(struct work_struct *work)
2561{
2562#if defined (WLAN_OPEN_SOURCE)
2563 cancel_work_sync(work);
2564#else
2565 wcnss_flush_work(work);
2566#endif
2567}
2568
2569v_VOID_t vos_flush_delayed_work(struct delayed_work *dwork)
2570{
2571#if defined (WLAN_OPEN_SOURCE)
2572 cancel_delayed_work_sync(dwork);
2573#else
2574 wcnss_flush_delayed_work(dwork);
2575#endif
2576}
2577