blob: d4d68a8d5455dfee9e0838664f62ad7a40deaf89 [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"
Sushant Kaushik33200572015-08-05 16:46:20 +053072#include "vos_diag_core_log.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070073
Dino Mycle3f783bc2014-08-08 17:40:22 +053074#include <linux/wcnss_wlan.h>
75
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "sapApi.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070077#include "vos_trace.h"
Girish Gowlifb0bfd32015-01-13 11:42:11 +053078#include "vos_utils.h"
Siddharth Bhal7bd19932015-03-03 16:54:36 +053079#include <wlan_logging_sock_svc.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef WLAN_BTAMP_FEATURE
82#include "bapApi.h"
83#include "bapInternal.h"
84#include "bap_hdd_main.h"
85#endif //WLAN_BTAMP_FEATURE
86
87
88/*---------------------------------------------------------------------------
89 * Preprocessor Definitions and Constants
90 * ------------------------------------------------------------------------*/
91/* Amount of time to wait for WDA to perform an asynchronous activity.
92 This value should be larger than the timeout used by WDI to wait for
93 a response from WCNSS since in the event that WCNSS is not responding,
94 WDI should handle that timeout */
95#define VOS_WDA_TIMEOUT 15000
96
97/* Approximate amount of time to wait for WDA to stop WDI */
98#define VOS_WDA_STOP_TIMEOUT WDA_STOP_TIMEOUT
99
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +0530100/* Approximate amount of time to wait for WDA to issue a DUMP req */
101#define VOS_WDA_RESP_TIMEOUT WDA_STOP_TIMEOUT
102
Jeff Johnson295189b2012-06-20 16:38:30 -0700103/*---------------------------------------------------------------------------
104 * Data definitions
105 * ------------------------------------------------------------------------*/
106static VosContextType gVosContext;
107static pVosContextType gpVosContext;
Sushant Kaushik215778f2015-05-21 14:05:36 +0530108static v_U8_t vos_multicast_logging;
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110/*---------------------------------------------------------------------------
111 * Forward declaration
112 * ------------------------------------------------------------------------*/
113v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
114
Jeff Johnson295189b2012-06-20 16:38:30 -0700115v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
116
117v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
118 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700119
120
121/*---------------------------------------------------------------------------
122
123 \brief vos_preOpen() - PreOpen the vOSS Module
124
125 The \a vos_preOpen() function allocates the Vos Context, but do not
126 initialize all the members. This overal initialization will happen
127 at vos_Open().
128 The reason why we need vos_preOpen() is to get a minimum context
129 where to store BAL and SAL relative data, which happens before
130 vos_Open() is called.
131
132 \param pVosContext: A pointer to where to store the VOS Context
133
134
135 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
136 is ready to be used.
137
138 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
139
140 \sa vos_Open()
141
142---------------------------------------------------------------------------*/
143VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
144{
145 if ( pVosContext == NULL)
146 return VOS_STATUS_E_FAILURE;
147
148 /* Allocate the VOS Context */
149 *pVosContext = NULL;
150 gpVosContext = &gVosContext;
151
152 if (NULL == gpVosContext)
153 {
154 /* Critical Error ...Cannot proceed further */
155 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
156 "%s: Failed to allocate VOS Context", __func__);
157 VOS_ASSERT(0);
158 return VOS_STATUS_E_RESOURCES;
159 }
160
161 vos_mem_zero(gpVosContext, sizeof(VosContextType));
162
163 *pVosContext = gpVosContext;
164
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700165 /* Initialize the spinlock */
166 vos_trace_spin_lock_init();
167 /* it is the right time to initialize MTRACE structures */
168 #if defined(TRACE_RECORD)
169 vosTraceInit();
170 #endif
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530171 vos_register_debugcb_init();
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700172
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 return VOS_STATUS_SUCCESS;
174
175} /* vos_preOpen()*/
176
177
178/*---------------------------------------------------------------------------
179
180 \brief vos_preClose() - PreClose the vOSS Module
181
182 The \a vos_preClose() function frees the Vos Context.
183
184 \param pVosContext: A pointer to where the VOS Context was stored
185
186
187 \return VOS_STATUS_SUCCESS - Always successful
188
189
190 \sa vos_preClose()
191 \sa vos_close()
192---------------------------------------------------------------------------*/
193VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
194{
195
196 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
197 "%s: De-allocating the VOS Context", __func__);
198
199 if (( pVosContext == NULL) || (*pVosContext == NULL))
200 {
201 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
202 "%s: vOS Context is Null", __func__);
203 return VOS_STATUS_E_FAILURE;
204 }
205
206 if (gpVosContext != *pVosContext)
207 {
208 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
209 "%s: Context mismatch", __func__);
210 return VOS_STATUS_E_FAILURE;
211 }
212
213 *pVosContext = gpVosContext = NULL;
214
215 return VOS_STATUS_SUCCESS;
216
217} /* vos_preClose()*/
218
219/*---------------------------------------------------------------------------
220
221 \brief vos_open() - Open the vOSS Module
222
223 The \a vos_open() function opens the vOSS Scheduler
224 Upon successful initialization:
225
226 - All VOS submodules should have been initialized
227
228 - The VOS scheduler should have opened
229
230 - All the WLAN SW components should have been opened. This includes
231 SYS, MAC, SME, WDA and TL.
232
233
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530234 \param devHandle: pointer to the OS specific device handle
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
236
237 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
238 is ready to be used.
239
240 VOS_STATUS_E_RESOURCES - System resources (other than memory)
241 are unavailable to initilize the scheduler
242
243
244 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
245
246 \sa vos_preOpen()
247
248---------------------------------------------------------------------------*/
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530249VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, void *devHandle )
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251{
252 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
253 int iter = 0;
254 tSirRetStatus sirStatus = eSIR_SUCCESS;
255 tMacOpenParameters macOpenParms;
256 WLANTL_ConfigInfoType TLConfig;
257
258 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
259 "%s: Opening VOSS", __func__);
260
261 if (NULL == gpVosContext)
262 {
263 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
264 "%s: Trying to open VOSS without a PreOpen", __func__);
265 VOS_ASSERT(0);
266 return VOS_STATUS_E_FAILURE;
267 }
268
269 /* Initialize the timer module */
270 vos_timer_module_init();
271
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700272
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 /* Initialize the probe event */
274 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
275 {
276 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
277 "%s: Unable to init probeEvent", __func__);
278 VOS_ASSERT(0);
279 return VOS_STATUS_E_FAILURE;
280 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
282 {
283 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
284 "%s: Unable to init wdaCompleteEvent", __func__);
285 VOS_ASSERT(0);
286
287 goto err_probe_event;
288 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530289 if (vos_event_init( &(gpVosContext->fwLogsComplete) ) != VOS_STATUS_SUCCESS )
290 {
291 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
292 "%s: Unable to init fwLogsComplete", __func__);
293 VOS_ASSERT(0);
294
295 goto err_wda_complete_event;
296 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700297
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 /* Initialize the free message queue */
299 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
300 if (! VOS_IS_STATUS_SUCCESS(vStatus))
301 {
302
303 /* Critical Error ... Cannot proceed further */
304 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
305 "%s: Failed to initialize VOS free message queue", __func__);
306 VOS_ASSERT(0);
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530307 goto err_fw_logs_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 }
309
310 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
311 {
312 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
313 &(gpVosContext->aMsgBuffers[iter]);
314 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
315 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
316 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700317
318 /* Now Open the VOS Scheduler */
319 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
320 sizeof(VosSchedContext));
321
322 if (!VOS_IS_STATUS_SUCCESS(vStatus))
323 {
324 /* Critical Error ... Cannot proceed further */
325 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
326 "%s: Failed to open VOS Scheduler", __func__);
327 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 /*
332 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
333 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
334 */
335
336 /*Open the WDA module */
337 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
338 /* UMA is supported in hardware for performing the
339 ** frame translation 802.11 <-> 802.3
340 */
341 macOpenParms.frameTransRequired = 1;
342 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530343 vStatus = WDA_open( gpVosContext, devHandle, &macOpenParms );
Jeff Johnson295189b2012-06-20 16:38:30 -0700344
345 if (!VOS_IS_STATUS_SUCCESS(vStatus))
346 {
347 /* Critical Error ... Cannot proceed further */
348 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
349 "%s: Failed to open WDA module", __func__);
350 VOS_ASSERT(0);
351 goto err_sched_close;
352 }
353
354 /* Initialize here the VOS Packet sub module */
355 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
356 sizeof( vos_pkt_context_t ) );
357
358 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
359 {
360 /* Critical Error ... Cannot proceed further */
361 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
362 "%s: Failed to open VOS Packet Module", __func__);
363 VOS_ASSERT(0);
364 goto err_wda_close;
365 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
367 /* Open the SYS module */
368 vStatus = sysOpen(gpVosContext);
369
370 if (!VOS_IS_STATUS_SUCCESS(vStatus))
371 {
372 /* Critical Error ... Cannot proceed further */
373 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
374 "%s: Failed to open SYS module", __func__);
375 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700376 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 }
378
Amar Singhal0a402232013-10-11 20:57:16 -0700379#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 /* initialize the NV module */
381 vStatus = vos_nv_open();
382 if (!VOS_IS_STATUS_SUCCESS(vStatus))
383 {
384 // NV module cannot be initialized
385 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
386 "%s: Failed to initialize the NV module", __func__);
387 goto err_sys_close;
388 }
Amar Singhal0a402232013-10-11 20:57:16 -0700389#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700390
391 /* If we arrive here, both threads dispacthing messages correctly */
392
393 /* Now proceed to open the MAC */
394
395 /* UMA is supported in hardware for performing the
396 frame translation 802.11 <-> 802.3 */
397 macOpenParms.frameTransRequired = 1;
398 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
399 &macOpenParms);
400
401 if (eSIR_SUCCESS != sirStatus)
402 {
403 /* Critical Error ... Cannot proceed further */
404 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
405 "%s: Failed to open MAC", __func__);
406 VOS_ASSERT(0);
407 goto err_nv_close;
408 }
409
410 /* Now proceed to open the SME */
411 vStatus = sme_Open(gpVosContext->pMACContext);
412 if (!VOS_IS_STATUS_SUCCESS(vStatus))
413 {
414 /* Critical Error ... Cannot proceed further */
415 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
416 "%s: Failed to open SME", __func__);
417 VOS_ASSERT(0);
418 goto err_mac_close;
419 }
420
421 /* Now proceed to open TL. Read TL config first */
422 vos_fetch_tl_cfg_parms ( &TLConfig,
423 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
424
425 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
426 if (!VOS_IS_STATUS_SUCCESS(vStatus))
427 {
428 /* Critical Error ... Cannot proceed further */
429 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
430 "%s: Failed to open TL", __func__);
431 VOS_ASSERT(0);
432 goto err_sme_close;
433 }
434
Girish Gowlifb0bfd32015-01-13 11:42:11 +0530435 if (gpVosContext->roamDelayStatsEnabled &&
436 !vos_roam_delay_stats_init())
437 {
438 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
439 "%s: Could not init roamDelayStats", __func__);
440 }
441
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
443 "%s: VOSS successfully Opened", __func__);
444
445 *pVosContext = gpVosContext;
446
447 return VOS_STATUS_SUCCESS;
448
449
450err_sme_close:
451 sme_Close(gpVosContext->pMACContext);
452
453err_mac_close:
454 macClose(gpVosContext->pMACContext);
455
456err_nv_close:
Amar Singhal0a402232013-10-11 20:57:16 -0700457
458#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 vos_nv_close();
Amar Singhal0a402232013-10-11 20:57:16 -0700460
461err_sys_close:
462#endif
463
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 sysClose(gpVosContext);
465
Jeff Johnson295189b2012-06-20 16:38:30 -0700466err_packet_close:
467 vos_packet_close( gpVosContext );
468
469err_wda_close:
470 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700471
Amar Singhal0a402232013-10-11 20:57:16 -0700472err_sched_close:
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 vos_sched_close(gpVosContext);
474
Jeff Johnson295189b2012-06-20 16:38:30 -0700475
476err_msg_queue:
477 vos_mq_deinit(&gpVosContext->freeVosMq);
478
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530479err_fw_logs_complete_event:
480 vos_event_destroy( &gpVosContext->fwLogsComplete);
481
Jeff Johnson295189b2012-06-20 16:38:30 -0700482err_wda_complete_event:
483 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700484
485err_probe_event:
486 vos_event_destroy(&gpVosContext->ProbeEvent);
487
488 return VOS_STATUS_E_FAILURE;
489
490} /* vos_open() */
491
Jeff Johnson295189b2012-06-20 16:38:30 -0700492/*---------------------------------------------------------------------------
493
494 \brief vos_preStart() -
495
496 The \a vos_preStart() function to download CFG.
497 including:
498 - ccmStart
499
500 - WDA: triggers the CFG download
501
502
503 \param pVosContext: The VOS context
504
505
506 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
507 is ready to be used.
508
509 VOS_STATUS_E_RESOURCES - System resources (other than memory)
510 are unavailable to initilize the scheduler
511
512
513 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
514
515 \sa vos_start
516
517---------------------------------------------------------------------------*/
518VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
519{
520 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
521 pVosContextType pVosContext = (pVosContextType)vosContext;
522
523 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
524 "vos prestart");
525
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800526 if (gpVosContext != pVosContext)
527 {
528 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
529 "%s: Context mismatch", __func__);
530 VOS_ASSERT(0);
531 return VOS_STATUS_E_INVAL;
532 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800534 if (pVosContext->pMACContext == NULL)
535 {
536 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
537 "%s: MAC NULL context", __func__);
538 VOS_ASSERT(0);
539 return VOS_STATUS_E_INVAL;
540 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700541
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800542 if (pVosContext->pWDAContext == NULL)
543 {
544 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
545 "%s: WDA NULL context", __func__);
546 VOS_ASSERT(0);
547 return VOS_STATUS_E_INVAL;
548 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700549
550 /* call macPreStart */
551 vStatus = macPreStart(gpVosContext->pMACContext);
552 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
553 {
554 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
555 "Failed at macPreStart ");
556 return VOS_STATUS_E_FAILURE;
557 }
558
559 /* call ccmStart */
560 ccmStart(gpVosContext->pMACContext);
561
562 /* Reset wda wait event */
563 vos_event_reset(&gpVosContext->wdaCompleteEvent);
564
565
566 /*call WDA pre start*/
567 vStatus = WDA_preStart(gpVosContext);
568 if (!VOS_IS_STATUS_SUCCESS(vStatus))
569 {
570 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
571 "Failed to WDA prestart");
572 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
573 ccmStop(gpVosContext->pMACContext);
574 VOS_ASSERT(0);
575 return VOS_STATUS_E_FAILURE;
576 }
577
578 /* Need to update time out of complete */
579 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
580 VOS_WDA_TIMEOUT );
581 if ( vStatus != VOS_STATUS_SUCCESS )
582 {
583 if ( vStatus == VOS_STATUS_E_TIMEOUT )
584 {
585 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800586 "%s: Timeout occurred before WDA complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 }
588 else
589 {
590 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
591 "%s: WDA_preStart reporting other error", __func__);
592 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700593 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
594 "%s: Test MC thread by posting a probe message to SYS", __func__);
595 wlan_sys_probe();
596
Jeff Johnsone7245742012-09-05 17:12:55 -0700597 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
598 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 VOS_ASSERT( 0 );
600 return VOS_STATUS_E_FAILURE;
601 }
602
603 return VOS_STATUS_SUCCESS;
604}
Jeff Johnson295189b2012-06-20 16:38:30 -0700605
Katya Nigame7b69a82015-04-28 15:24:06 +0530606VOS_STATUS vos_mon_start( v_CONTEXT_t vosContext )
607{
608 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
609 pVosContextType pVosContext = (pVosContextType)vosContext;
610
611 if (pVosContext == NULL)
612 {
613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
614 "%s: mismatch in context",__func__);
615 return VOS_STATUS_E_FAILURE;
616 }
617
618 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pTLContext == NULL))
619 {
620 if (pVosContext->pWDAContext == NULL)
621 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
622 "%s: WDA NULL context", __func__);
623 else
624 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
625 "%s: TL NULL context", __func__);
626
627 return VOS_STATUS_E_FAILURE;
628 }
629
630 /* Reset wda wait event */
631 vos_event_reset(&pVosContext->wdaCompleteEvent);
632
633 /*call WDA pre start*/
634 vStatus = WDA_preStart(pVosContext);
635 if (!VOS_IS_STATUS_SUCCESS(vStatus))
636 {
637 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
638 "Failed to WDA prestart ");
639 VOS_ASSERT(0);
640 return VOS_STATUS_E_FAILURE;
641 }
642
643 /* Need to update time out of complete */
644 vStatus = vos_wait_single_event( &pVosContext->wdaCompleteEvent, 1000);
645 if ( vStatus != VOS_STATUS_SUCCESS )
646 {
647 if ( vStatus == VOS_STATUS_E_TIMEOUT )
648 {
649 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
650 "%s: Timeout occurred before WDA complete",__func__);
651 }
652 else
653 {
654 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
655 "%s: WDA_preStart reporting other error",__func__);
656 }
657 VOS_ASSERT( 0 );
658 return VOS_STATUS_E_FAILURE;
659 }
660
661 vStatus = WDA_NVDownload_Start(pVosContext);
662
663 if ( vStatus != VOS_STATUS_SUCCESS )
664 {
665 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
666 "%s: Failed to start NV Download",__func__);
667 return VOS_STATUS_E_FAILURE;
668 }
669
670 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000 * 30);
671
672 if ( vStatus != VOS_STATUS_SUCCESS )
673 {
674 if ( vStatus == VOS_STATUS_E_TIMEOUT )
675 {
676 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
677 "%s: Timeout occurred before WDA_NVDownload_Start complete",__func__);
678 }
679 else
680 {
681 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
682 "%s: WDA_NVDownload_Start reporting other error",__func__);
683 }
684 VOS_ASSERT(0);
685 return VOS_STATUS_E_FAILURE;
686 }
687
688 vStatus = WDA_start(pVosContext);
689 if (vStatus != VOS_STATUS_SUCCESS)
690 {
691 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
692 "%s: Failed to start WDA",__func__);
693 return VOS_STATUS_E_FAILURE;
694 }
695
696 /** START TL */
697 vStatus = WLANTL_Start(pVosContext);
698 if (!VOS_IS_STATUS_SUCCESS(vStatus))
699 {
700 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
701 "%s: Failed to start TL", __func__);
702 goto err_wda_stop;
703 }
704
705 return VOS_STATUS_SUCCESS;
706
707err_wda_stop:
708 vos_event_reset(&(pVosContext->wdaCompleteEvent));
709 WDA_stop(pVosContext, HAL_STOP_TYPE_RF_KILL);
710 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000);
711 if(vStatus != VOS_STATUS_SUCCESS)
712 {
713 if(vStatus == VOS_STATUS_E_TIMEOUT)
714 {
715 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
716 "%s: Timeout occurred before WDA_stop complete",__func__);
717
718 }
719 else
720 {
721 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
722 "%s: WDA_stop reporting other error",__func__);
723 }
724 VOS_ASSERT(0);
725 }
726 return VOS_STATUS_E_FAILURE;
727}
728
729VOS_STATUS vos_mon_stop( v_CONTEXT_t vosContext )
730{
731 VOS_STATUS vosStatus;
732
733 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
734
Bhargav Shah1ae5de02015-07-20 13:32:31 +0530735 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
736 "%s: HAL_STOP is requested", __func__);
737
Katya Nigame7b69a82015-04-28 15:24:06 +0530738 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
739
740 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
741 {
742 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
743 "%s: Failed to stop WDA", __func__);
744 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
745 WDA_setNeedShutdown(vosContext);
746 }
747 else
748 {
749 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
750 VOS_WDA_STOP_TIMEOUT );
751
752 if ( vosStatus != VOS_STATUS_SUCCESS )
753 {
754 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
755 {
756 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
757 "%s: Timeout occurred before WDA complete", __func__);
758 }
759 else
760 {
761 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
762 "%s: WDA_stop reporting other error", __func__ );
763 }
764 WDA_setNeedShutdown(vosContext);
765 }
766 }
767
768 vosStatus = WLANTL_Stop( vosContext );
769 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
770 {
771 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
772 "%s: Failed to stop TL", __func__);
773 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
774 }
775
776 return VOS_STATUS_SUCCESS;
777}
778
Jeff Johnson295189b2012-06-20 16:38:30 -0700779/*---------------------------------------------------------------------------
780
781 \brief vos_start() - Start the Libra SW Modules
782
783 The \a vos_start() function starts all the components of the Libra SW
784 including:
785 - SAL/BAL, which in turn starts SSC
786
787 - the MAC (HAL and PE)
788
789 - SME
790
791 - TL
792
793 - SYS: triggers the CFG download
794
795
796 \param pVosContext: The VOS context
797
798
799 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
800 is ready to be used.
801
802 VOS_STATUS_E_RESOURCES - System resources (other than memory)
803 are unavailable to initilize the scheduler
804
805
806 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
807
808 \sa vos_preStart()
809 \sa vos_open()
810
811---------------------------------------------------------------------------*/
812VOS_STATUS vos_start( v_CONTEXT_t vosContext )
813{
814 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
815 tSirRetStatus sirStatus = eSIR_SUCCESS;
816 pVosContextType pVosContext = (pVosContextType)vosContext;
817 tHalMacStartParameters halStartParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700818
819 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
820 "%s: Starting Libra SW", __func__);
821
822 /* We support only one instance for now ...*/
823 if (gpVosContext != pVosContext)
824 {
825 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700826 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 return VOS_STATUS_E_FAILURE;
828 }
829
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
831 || ( pVosContext->pTLContext == NULL))
832 {
833 if (pVosContext->pWDAContext == NULL)
834 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700835 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 else if (pVosContext->pMACContext == NULL)
837 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700838 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 else
840 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700841 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700842
843 return VOS_STATUS_E_FAILURE;
844 }
845
846 /* WDA_Start will be called after NV image download because the
847 NV image data has to be updated at HAL before HAL_Start gets executed*/
848
849 /* Start the NV Image Download */
850
851 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
852
853 vStatus = WDA_NVDownload_Start(pVosContext);
854
855 if ( vStatus != VOS_STATUS_SUCCESS )
856 {
857 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
858 "%s: Failed to start NV Download", __func__);
859 return VOS_STATUS_E_FAILURE;
860 }
861
862 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
863 VOS_WDA_TIMEOUT );
864
865 if ( vStatus != VOS_STATUS_SUCCESS )
866 {
867 if ( vStatus == VOS_STATUS_E_TIMEOUT )
868 {
869 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
870 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
871 }
872 else
873 {
874 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
875 "%s: WDA_NVDownload_start reporting other error", __func__);
876 }
877 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800878 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700879 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
880 {
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530881 if (isSsrPanicOnFailure())
882 VOS_BUG(0);
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700883 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800884 WDA_setNeedShutdown(vosContext);
885 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 }
887
888 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
889 "%s: WDA_NVDownload_start correctly started", __func__);
890
891 /* Start the WDA */
892 vStatus = WDA_start(pVosContext);
893 if ( vStatus != VOS_STATUS_SUCCESS )
894 {
895 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530896 "%s: Failed to start WDA - WDA_shutdown needed %d ",
897 __func__, vStatus);
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530898 if ( vStatus == VOS_STATUS_E_TIMEOUT )
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530899 {
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530900 WDA_setNeedShutdown(vosContext);
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530901 }
902 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 return VOS_STATUS_E_FAILURE;
904 }
905 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
906 "%s: WDA correctly started", __func__);
907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 /* Start the MAC */
909 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
910
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 /* Start the MAC */
912 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 if (eSIR_SUCCESS != sirStatus)
915 {
916 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
917 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 }
920
921 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
922 "%s: MAC correctly started", __func__);
923
924 /* START SME */
925 vStatus = sme_Start(pVosContext->pMACContext);
926
927 if (!VOS_IS_STATUS_SUCCESS(vStatus))
928 {
929 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
930 "%s: Failed to start SME", __func__);
931 goto err_mac_stop;
932 }
933
934 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
935 "%s: SME correctly started", __func__);
936
937 /** START TL */
938 vStatus = WLANTL_Start(pVosContext);
939 if (!VOS_IS_STATUS_SUCCESS(vStatus))
940 {
941 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
942 "%s: Failed to start TL", __func__);
943 goto err_sme_stop;
944 }
945
946 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
947 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
949 "%s: VOSS Start is successful!!", __func__);
950
951 return VOS_STATUS_SUCCESS;
952
Jeff Johnson295189b2012-06-20 16:38:30 -0700953
954err_sme_stop:
Kiet Lama72a2322013-11-15 11:18:11 +0530955 sme_Stop(pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700956
957err_mac_stop:
958 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
959
Jeff Johnson295189b2012-06-20 16:38:30 -0700960err_wda_stop:
961 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800962 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
963 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800965 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
966 "%s: Failed to stop WDA", __func__);
967 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800968 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800969 }
970 else
971 {
972 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
973 VOS_WDA_TIMEOUT );
974 if( vStatus != VOS_STATUS_SUCCESS )
975 {
976 if( vStatus == VOS_STATUS_E_TIMEOUT )
977 {
978 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
979 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800981 }
982 else
983 {
984 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
985 "%s: WDA_stop reporting other error", __func__);
986 }
987 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800988 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800989 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700991
992 return VOS_STATUS_E_FAILURE;
993
994} /* vos_start() */
995
996
997/* vos_stop function */
998VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
999{
1000 VOS_STATUS vosStatus;
1001
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 /* WDA_Stop is called before the SYS so that the processing of Riva
1003 pending responces will not be handled during uninitialization of WLAN driver */
1004 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
1005
1006 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
1007
1008 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1009 {
1010 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1011 "%s: Failed to stop WDA", __func__);
1012 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001013 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -07001015 else
1016 {
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301017 if(wcnss_device_is_shutdown())
1018 {
1019 vosStatus = VOS_STATUS_E_TIMEOUT;
1020 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1021 "%s: Wait for WDA_Stop complete event not needed due to SSR",
1022 __func__);
1023 }
1024 else
1025 {
1026 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001027 VOS_WDA_STOP_TIMEOUT );
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001029
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001030 if ( vosStatus != VOS_STATUS_SUCCESS )
1031 {
1032 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1033 {
1034 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1035 "%s: Timeout occurred before WDA complete", __func__);
1036 }
1037 else
1038 {
1039 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1040 "%s: WDA_stop reporting other error", __func__ );
1041 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -07001042 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1043 "%s: Test MC thread by posting a probe message to SYS", __func__);
1044 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001045 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001048
1049 /* SYS STOP will stop SME and MAC */
1050 vosStatus = sysStop( vosContext);
1051 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1052 {
1053 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1054 "%s: Failed to stop SYS", __func__);
1055 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1056 }
1057
1058 vosStatus = WLANTL_Stop( vosContext );
1059 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1060 {
1061 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1062 "%s: Failed to stop TL", __func__);
1063 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1064 }
1065
Jeff Johnson295189b2012-06-20 16:38:30 -07001066
1067 return VOS_STATUS_SUCCESS;
1068}
1069
1070
1071/* vos_close function */
1072VOS_STATUS vos_close( v_CONTEXT_t vosContext )
1073{
1074 VOS_STATUS vosStatus;
1075
1076#ifdef WLAN_BTAMP_FEATURE
1077 vosStatus = WLANBAP_Close(vosContext);
1078 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1079 {
1080 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1081 "%s: Failed to close BAP", __func__);
1082 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1083 }
1084#endif // WLAN_BTAMP_FEATURE
1085
1086
1087 vosStatus = WLANTL_Close(vosContext);
1088 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1089 {
1090 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1091 "%s: Failed to close TL", __func__);
1092 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1093 }
1094
1095 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1096 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1097 {
1098 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1099 "%s: Failed to close SME", __func__);
1100 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1101 }
1102
1103 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1104 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1105 {
1106 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1107 "%s: Failed to close MAC", __func__);
1108 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1109 }
1110
1111 ((pVosContextType)vosContext)->pMACContext = NULL;
1112
Amar Singhal0a402232013-10-11 20:57:16 -07001113#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 vosStatus = vos_nv_close();
1115 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1116 {
1117 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1118 "%s: Failed to close NV", __func__);
1119 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1120 }
Amar Singhal0a402232013-10-11 20:57:16 -07001121#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001122
1123 vosStatus = sysClose( vosContext );
1124 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1125 {
1126 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1127 "%s: Failed to close SYS", __func__);
1128 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1129 }
1130
Jeff Johnsone7245742012-09-05 17:12:55 -07001131 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001133 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
1134 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
1135 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
1136 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07001137 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -07001138 }
1139 else
1140 {
1141 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1142 "%s: Failed to shutdown WDA", __func__ );
1143 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1144 }
1145 }
1146 else
1147 {
1148 vosStatus = WDA_close( vosContext );
1149 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1150 {
1151 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1152 "%s: Failed to close WDA", __func__);
1153 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 }
1156
1157 /* Let DXE return packets in WDA_close and then free them here */
1158 vosStatus = vos_packet_close( vosContext );
1159 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1160 {
1161 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1162 "%s: Failed to close VOSS Packet", __func__);
1163 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
Jeff Johnson295189b2012-06-20 16:38:30 -07001166
1167 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1168
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301169 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
1170 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1171 {
1172 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1173 "%s: failed to destroy fwLogsComplete", __func__);
1174 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1175 }
1176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1178 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1179 {
1180 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1181 "%s: failed to destroy wdaCompleteEvent", __func__);
1182 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001184
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301185
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1187 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1188 {
1189 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1190 "%s: failed to destroy ProbeEvent", __func__);
1191 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1192 }
1193
Girish Gowlifb0bfd32015-01-13 11:42:11 +05301194 if (gpVosContext->roamDelayStatsEnabled &&
1195 !vos_roam_delay_stats_deinit())
1196 {
1197 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1198 "%s: Could not deinit roamDelayStats", __func__);
1199 }
1200
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 return VOS_STATUS_SUCCESS;
1202}
1203
1204
1205/**---------------------------------------------------------------------------
1206
1207 \brief vos_get_context() - get context data area
1208
1209 Each module in the system has a context / data area that is allocated
1210 and maanged by voss. This API allows any user to get a pointer to its
1211 allocated context data area from the VOSS global context.
1212
1213 \param vosContext - the VOSS Global Context.
1214
1215 \param moduleId - the module ID, who's context data are is being retrived.
1216
1217 \return - pointer to the context data area.
1218
1219 - NULL if the context data is not allocated for the module ID
1220 specified
1221
1222 --------------------------------------------------------------------------*/
1223v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1224 v_CONTEXT_t pVosContext )
1225{
1226 v_PVOID_t pModContext = NULL;
1227
1228 if (pVosContext == NULL)
1229 {
1230 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001231 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 return NULL;
1233 }
1234
1235 if (gpVosContext != pVosContext)
1236 {
1237 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001238 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 return NULL;
1240 }
1241
1242 switch(moduleId)
1243 {
1244 case VOS_MODULE_ID_TL:
1245 {
1246 pModContext = gpVosContext->pTLContext;
1247 break;
1248 }
1249
Jeff Johnson295189b2012-06-20 16:38:30 -07001250#ifdef WLAN_BTAMP_FEATURE
1251 case VOS_MODULE_ID_BAP:
1252 {
1253 pModContext = gpVosContext->pBAPContext;
1254 break;
1255 }
1256#endif //WLAN_BTAMP_FEATURE
1257
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 case VOS_MODULE_ID_SAP:
1259 {
1260 pModContext = gpVosContext->pSAPContext;
1261 break;
1262 }
1263
1264 case VOS_MODULE_ID_HDD_SOFTAP:
1265 {
1266 pModContext = gpVosContext->pHDDSoftAPContext;
1267 break;
1268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001269
1270 case VOS_MODULE_ID_HDD:
1271 {
1272 pModContext = gpVosContext->pHDDContext;
1273 break;
1274 }
1275
1276 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301278 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 {
1280 /*
1281 ** In all these cases, we just return the MAC Context
1282 */
1283 pModContext = gpVosContext->pMACContext;
1284 break;
1285 }
1286
Jeff Johnson295189b2012-06-20 16:38:30 -07001287 case VOS_MODULE_ID_WDA:
1288 {
1289 /* For WDA module */
1290 pModContext = gpVosContext->pWDAContext;
1291 break;
1292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001293
1294 case VOS_MODULE_ID_VOSS:
1295 {
1296 /* For SYS this is VOS itself*/
1297 pModContext = gpVosContext;
1298 break;
1299 }
1300
1301 default:
1302 {
1303 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1304 "does not have its context maintained by VOSS", __func__, moduleId);
1305 VOS_ASSERT(0);
1306 return NULL;
1307 }
1308 }
1309
1310 if (pModContext == NULL )
1311 {
1312 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1313 "context is Null", __func__, moduleId);
1314 }
1315
1316 return pModContext;
1317
1318} /* vos_get_context()*/
1319
1320
1321/**---------------------------------------------------------------------------
1322
1323 \brief vos_get_global_context() - get VOSS global Context
1324
1325 This API allows any user to get the VOS Global Context pointer from a
1326 module context data area.
1327
1328 \param moduleContext - the input module context pointer
1329
1330 \param moduleId - the module ID who's context pointer is input in
1331 moduleContext.
1332
1333 \return - pointer to the VOSS global context
1334
1335 - NULL if the function is unable to retreive the VOSS context.
1336
1337 --------------------------------------------------------------------------*/
1338v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1339 v_VOID_t *moduleContext )
1340{
1341 if (gpVosContext == NULL)
1342 {
1343 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001344 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 }
1346
1347 return gpVosContext;
1348
1349} /* vos_get_global_context() */
1350
1351
1352v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1353{
1354 if (gpVosContext == NULL)
1355 {
1356 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001357 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 return 1;
1359 }
1360
1361 return gpVosContext->isLogpInProgress;
1362}
1363
1364void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1365{
1366 if (gpVosContext == NULL)
1367 {
1368 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001369 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 return;
1371 }
1372
1373 gpVosContext->isLogpInProgress = value;
1374}
1375
1376v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1377{
1378 if (gpVosContext == NULL)
1379 {
1380 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001381 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 return 0;
1383 }
1384
1385 return gpVosContext->isLoadUnloadInProgress;
1386}
1387
1388void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1389{
1390 if (gpVosContext == NULL)
1391 {
1392 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001393 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 return;
1395 }
1396
1397 gpVosContext->isLoadUnloadInProgress = value;
1398}
1399
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001400v_U8_t vos_is_reinit_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1401{
1402 if (gpVosContext == NULL)
1403 {
1404 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1405 "%s: global voss context is NULL", __func__);
1406 return 1;
1407 }
1408
1409 return gpVosContext->isReInitInProgress;
1410}
1411
1412void vos_set_reinit_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1413{
1414 if (gpVosContext == NULL)
1415 {
1416 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1417 "%s: global voss context is NULL", __func__);
1418 return;
1419 }
1420
1421 gpVosContext->isReInitInProgress = value;
1422}
1423
1424
Jeff Johnson295189b2012-06-20 16:38:30 -07001425/**---------------------------------------------------------------------------
1426
1427 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1428
1429 This API allows any user to allocate a user context area within the
1430 VOS Global Context.
1431
1432 \param pVosContext - pointer to the global Vos context
1433
1434 \param moduleId - the module ID who's context area is being allocated.
1435
1436 \param ppModuleContext - pointer to location where the pointer to the
1437 allocated context is returned. Note this
1438 output pointer is valid only if the API
1439 returns VOS_STATUS_SUCCESS
1440
1441 \param size - the size of the context area to be allocated.
1442
1443 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1444 allocated successfully. The pointer to the context area
1445 can be found in *ppModuleContext.
1446 \note This function returns VOS_STATUS_SUCCESS if the
1447 module context was already allocated and the size
1448 allocated matches the size on this call.
1449
1450 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1451 not identify a module that can have a context allocated.
1452
1453 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1454 because a context for this module ID already exists and it is
1455 a *different* size that specified on this call.
1456
1457 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1458 requested context area.
1459
1460 \sa vos_get_context(), vos_free_context()
1461
1462 --------------------------------------------------------------------------*/
1463VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1464 v_VOID_t **ppModuleContext, v_SIZE_t size )
1465{
1466 v_VOID_t ** pGpModContext = NULL;
1467
1468 if ( pVosContext == NULL) {
1469 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001470 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 return VOS_STATUS_E_FAILURE;
1472 }
1473
1474 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1475 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001476 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 return VOS_STATUS_E_FAILURE;
1478 }
1479
1480 switch(moduleID)
1481 {
1482 case VOS_MODULE_ID_TL:
1483 {
1484 pGpModContext = &(gpVosContext->pTLContext);
1485 break;
1486 }
1487
Jeff Johnson295189b2012-06-20 16:38:30 -07001488#ifdef WLAN_BTAMP_FEATURE
1489 case VOS_MODULE_ID_BAP:
1490 {
1491 pGpModContext = &(gpVosContext->pBAPContext);
1492 break;
1493 }
1494#endif //WLAN_BTAMP_FEATURE
1495
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 case VOS_MODULE_ID_SAP:
1497 {
1498 pGpModContext = &(gpVosContext->pSAPContext);
1499 break;
1500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001501
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 case VOS_MODULE_ID_WDA:
1503 {
1504 pGpModContext = &(gpVosContext->pWDAContext);
1505 break;
1506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301509 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 default:
1513 {
1514 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1515 "does not have its context allocated by VOSS", __func__, moduleID);
1516 VOS_ASSERT(0);
1517 return VOS_STATUS_E_INVAL;
1518 }
1519 }
1520
1521 if ( NULL != *pGpModContext)
1522 {
1523 /*
1524 ** Context has already been allocated!
1525 ** Prevent double allocation
1526 */
1527 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1528 "%s: Module ID %i context has already been allocated",
1529 __func__, moduleID);
1530 return VOS_STATUS_E_EXISTS;
1531 }
1532
1533 /*
1534 ** Dynamically allocate the context for module
1535 */
1536
1537 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1538
1539
1540 if ( *ppModuleContext == NULL)
1541 {
1542 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1543 "allocate Context for module ID %i", __func__, moduleID);
1544 VOS_ASSERT(0);
1545 return VOS_STATUS_E_NOMEM;
1546 }
1547
1548 if (moduleID==VOS_MODULE_ID_TL)
1549 {
1550 vos_mem_zero(*ppModuleContext, size);
1551 }
1552
1553 *pGpModContext = *ppModuleContext;
1554
1555 return VOS_STATUS_SUCCESS;
1556
1557} /* vos_alloc_context() */
1558
1559
1560/**---------------------------------------------------------------------------
1561
1562 \brief vos_free_context() - free an allocated a context within the
1563 VOSS global Context
1564
1565 This API allows a user to free the user context area within the
1566 VOS Global Context.
1567
1568 \param pVosContext - pointer to the global Vos context
1569
1570 \param moduleId - the module ID who's context area is being free
1571
1572 \param pModuleContext - pointer to module context area to be free'd.
1573
1574 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1575 free'd. The pointer to the context area is not longer
1576 available.
1577
1578 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1579 valid pointers.
1580
1581 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1582 not identify a module that can have a context free'd.
1583
1584 VOS_STATUS_E_EXISTS - vos could not free the requested
1585 context area because a context for this module ID does not
1586 exist in the global vos context.
1587
1588 \sa vos_get_context()
1589
1590 --------------------------------------------------------------------------*/
1591VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1592 v_VOID_t *pModuleContext )
1593{
1594 v_VOID_t ** pGpModContext = NULL;
1595
1596 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1597 ( pModuleContext == NULL))
1598 {
1599 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1600 "%s: Null params or context mismatch", __func__);
1601 return VOS_STATUS_E_FAILURE;
1602 }
1603
1604
1605 switch(moduleID)
1606 {
1607 case VOS_MODULE_ID_TL:
1608 {
1609 pGpModContext = &(gpVosContext->pTLContext);
1610 break;
1611 }
1612
Jeff Johnson295189b2012-06-20 16:38:30 -07001613#ifdef WLAN_BTAMP_FEATURE
1614 case VOS_MODULE_ID_BAP:
1615 {
1616 pGpModContext = &(gpVosContext->pBAPContext);
1617 break;
1618 }
1619#endif //WLAN_BTAMP_FEATURE
1620
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 case VOS_MODULE_ID_SAP:
1622 {
1623 pGpModContext = &(gpVosContext->pSAPContext);
1624 break;
1625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001626
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 case VOS_MODULE_ID_WDA:
1628 {
1629 pGpModContext = &(gpVosContext->pWDAContext);
1630 break;
1631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 case VOS_MODULE_ID_HDD:
1633 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301635 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 default:
1638 {
1639 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1640 "does not have its context allocated by VOSS", __func__, moduleID);
1641 VOS_ASSERT(0);
1642 return VOS_STATUS_E_INVAL;
1643 }
1644 }
1645
1646 if ( NULL == *pGpModContext)
1647 {
1648 /*
1649 ** Context has not been allocated or freed already!
1650 */
1651 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1652 "context has not been allocated or freed already", __func__,moduleID);
1653 return VOS_STATUS_E_FAILURE;
1654 }
1655
1656 if (*pGpModContext != pModuleContext)
1657 {
1658 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001659 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 return VOS_STATUS_E_FAILURE;
1661 }
1662
1663 if(pModuleContext != NULL)
1664 kfree(pModuleContext);
1665
1666 *pGpModContext = NULL;
1667
1668 return VOS_STATUS_SUCCESS;
1669
1670} /* vos_free_context() */
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301671
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301672
1673bool vos_is_log_report_in_progress(void)
1674{
1675 return wlan_is_log_report_in_progress();
1676}
1677
1678void vos_reset_log_report_in_progress(void)
1679{
1680 return wlan_reset_log_report_in_progress();
1681}
1682
1683
1684
1685
1686int vos_set_log_completion(uint32 is_fatal,
1687 uint32 indicator,
1688 uint32 reason_code)
1689{
1690 return wlan_set_log_completion(is_fatal,
1691 indicator,reason_code);
1692}
1693
Abhishek Singh837adf22015-10-01 17:37:37 +05301694void vos_get_log_and_reset_completion(uint32 *is_fatal,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301695 uint32 *indicator,
Abhishek Singh837adf22015-10-01 17:37:37 +05301696 uint32 *reason_code,
1697 bool reset)
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301698{
Abhishek Singh837adf22015-10-01 17:37:37 +05301699 wlan_get_log_and_reset_completion(is_fatal, indicator, reason_code, reset);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301700}
1701
1702
1703
1704void vos_send_fatal_event_done(void)
1705{
1706 /*Complete the fwLogsComplete Event*/
1707 VosContextType *vos_context;
1708 uint32_t is_fatal, indicator, reason_code;
1709
1710 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1711 if (!vos_context) {
1712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1713 "%s: vos context is Invalid", __func__);
1714 return;
1715 }
1716 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1717 "%s: vos_event_set for fwLogsComplete", __func__);
1718 if (vos_event_set(&vos_context->fwLogsComplete)!= VOS_STATUS_SUCCESS)
1719 {
1720 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1721 "%s: vos_event_set failed for fwLogsComplete", __func__);
1722 return;
1723 }
1724 /*The below API will reset is_report_in_progress flag*/
Abhishek Singh837adf22015-10-01 17:37:37 +05301725 vos_get_log_and_reset_completion(&is_fatal, &indicator,
1726 &reason_code, true);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301727 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05301728 "is_fatal : %d, indicator: %d, reason_code=%d",
1729 is_fatal, indicator, reason_code);
1730 wlan_report_log_completion(is_fatal, indicator, reason_code);
1731
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301732}
1733
Abhishek Singh837adf22015-10-01 17:37:37 +05301734/**
1735 * vos_isFatalEventEnabled()
1736 *
1737 * Return TRUE if Fatal event is enabled is in progress.
1738 *
1739 */
1740v_BOOL_t vos_isFatalEventEnabled(void)
1741{
1742 hdd_context_t *pHddCtx = NULL;
1743 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1744
1745 if(!pVosContext)
1746 {
1747 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
1748 return FALSE;
1749 }
1750
1751 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1752 if(!pHddCtx) {
1753 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1754 "%s: HDD context is Null", __func__);
1755 return FALSE;
1756 }
1757
1758 return pHddCtx->cfg_ini->enableFatalEvent;
1759}
1760
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301761
1762
1763/**---------------------------------------------------------------------------
1764
1765 \brief vos_fatal_event_logs_req() - used to send flush command to FW
1766
1767 This API is wrapper to SME flush API.
1768
1769 \param is_fatal - fatal or non fatal event
1770 indicator - Tyoe of indicator framework/Host/FW
1771 reason_code - reason code for flush logs
1772
1773 \return VOS_STATUS_SUCCESS - if command is sent successfully.
1774 VOS_STATUS_E_FAILURE - if command is not sent successfully.
1775 --------------------------------------------------------------------------*/
1776VOS_STATUS vos_fatal_event_logs_req( uint32_t is_fatal,
1777 uint32_t indicator,
1778 uint32_t reason_code,
Abhishek Singh837adf22015-10-01 17:37:37 +05301779 bool wait_required,
1780 bool dump_vos_trace)
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301781{
1782 VOS_STATUS vosStatus;
1783 eHalStatus status;
1784 VosContextType *vos_context;
Abhishek Singh837adf22015-10-01 17:37:37 +05301785 hdd_context_t *pHddCtx = NULL;
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301786
1787 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1788 if (!vos_context)
1789 {
1790 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1791 "%s: vos context is Invalid", __func__);
1792 return eHAL_STATUS_FAILURE;
1793 }
Abhishek Singh837adf22015-10-01 17:37:37 +05301794 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, vos_context );
1795 if(!pHddCtx) {
1796 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1797 "%s: HDD context is Null", __func__);
1798 return eHAL_STATUS_FAILURE;
1799 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301800
Abhishek Singh837adf22015-10-01 17:37:37 +05301801 if(!pHddCtx->cfg_ini->enableFatalEvent)
1802 {
1803 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1804 "%s: Fatal event not enabled", __func__);
1805 return eHAL_STATUS_FAILURE;
1806 }
1807
1808 if (pHddCtx->isLoadUnloadInProgress ||
1809 vos_context->isLogpInProgress)
1810 {
1811 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1812 "%s: un/Load/SSR in progress", __func__);
1813 return eHAL_STATUS_FAILURE;
1814 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301815
1816 if (vos_is_log_report_in_progress() == true)
1817 {
1818 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1819 "%s: Fatal Event Req already in progress - dropping! type:%d, indicator=%d reason_code=%d",
1820 __func__, is_fatal, indicator, reason_code);
1821 return VOS_STATUS_E_FAILURE;
1822 }
1823
1824 vosStatus = vos_set_log_completion(is_fatal, indicator, reason_code);
1825 if (VOS_STATUS_SUCCESS != vosStatus) {
1826 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1827 "%s: Failed to set log trigger params for fatalEvent", __func__);
1828 return VOS_STATUS_E_FAILURE;
1829 }
Abhishek Singh837adf22015-10-01 17:37:37 +05301830 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301831 "%s: Triggering fatal Event: type:%d, indicator=%d reason_code=%d",
1832 __func__, is_fatal, indicator, reason_code);
1833
1834 vos_event_reset(&gpVosContext->fwLogsComplete);
1835 status = sme_fatal_event_logs_req(vos_context->pMACContext,
1836 is_fatal, indicator,
Abhishek Singh837adf22015-10-01 17:37:37 +05301837 reason_code, dump_vos_trace);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301838
Abhishek Singh837adf22015-10-01 17:37:37 +05301839 if (HAL_STATUS_SUCCESS(status) && (wait_required == TRUE))
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301840 {
1841
1842 /* Need to update time out of complete */
1843 vosStatus = vos_wait_single_event(&gpVosContext->fwLogsComplete,
1844 WAIT_TIME_FW_LOGS);
1845 if ( vosStatus != VOS_STATUS_SUCCESS )
1846 {
1847 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1848 {
1849 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1850 "%s: Timeout occurred before fwLogsComplete", __func__);
1851 }
1852 else
1853 {
1854 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1855 "%s: fwLogsComplete reporting other error", __func__);
1856 }
1857 /*Done indication is not received.So reset the bug report in progress*/
1858 vos_reset_log_report_in_progress();
1859 return VOS_STATUS_E_FAILURE;
1860 }
1861 }
1862 if (HAL_STATUS_SUCCESS( status ))
1863 return VOS_STATUS_SUCCESS;
1864 else
1865 return VOS_STATUS_E_FAILURE;
1866}
1867
1868/**---------------------------------------------------------------------------
1869
1870 \brief vos_process_done_indication() - Process the done indication for fatal event,
1871 FW memory dump
1872
1873 This API processes the done indication and wakeup the logger thread accordingly.
1874
1875 \param type - Type for which done indication is received.
1876
1877
1878 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1879 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1880 a failure.
1881 --------------------------------------------------------------------------*/
1882
1883VOS_STATUS vos_process_done_indication(v_U8_t type, v_U32_t reason_code)
1884{
1885 wlan_process_done_indication(type, reason_code);
1886 return VOS_STATUS_SUCCESS;
1887}
1888
Abhishek Singh837adf22015-10-01 17:37:37 +05301889/**
1890 * vos_flush_host_logs_for_fatal() -flush host logs and send
1891 * fatal event to upper layer.
1892 */
1893void vos_flush_host_logs_for_fatal(void)
1894{
1895 wlan_flush_host_logs_for_fatal();
1896 return;
1897}
1898
1899
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301900/**---------------------------------------------------------------------------
1901
1902 \brief vos_logger_pkt_serialize() - queue a logging vos pkt
1903
1904 This API allows single vos pkt to be queued and later sent to userspace by
1905 logger thread.
1906
1907 \param pPacket - a pointer to a vos pkt to be queued
1908 pkt_type - type of pkt to be queued
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301909
1910 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1911 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1912 a failure.
1913 --------------------------------------------------------------------------*/
Mihir Sheteccafc0c2015-04-17 16:13:15 +05301914VOS_STATUS vos_logger_pkt_serialize( vos_pkt_t *pPacket, uint32 pkt_type)
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301915{
1916#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1917 return wlan_queue_logpkt_for_app(pPacket, pkt_type);
1918#else
1919 return vos_pkt_return_packet(pPacket);
1920#endif
1921}
Jeff Johnson295189b2012-06-20 16:38:30 -07001922
Sushant Kaushik33200572015-08-05 16:46:20 +05301923void vos_per_pkt_stats_to_user(void *perPktStat)
1924{
1925#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1926 wlan_pkt_stats_to_user(perPktStat);
1927#else
1928 return;
1929#endif
1930
1931
1932
1933}
1934
1935void vos_updatePktStatsInfo(void * pktStat)
1936{
1937#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1938 wlan_fillTxStruct(pktStat);
1939#else
1940 return;
1941#endif
1942
1943}
1944
1945
Jeff Johnson295189b2012-06-20 16:38:30 -07001946/**---------------------------------------------------------------------------
1947
1948 \brief vos_mq_post_message() - post a message to a message queue
1949
1950 This API allows messages to be posted to a specific message queue. Messages
1951 can be posted to the following message queues:
1952
1953 <ul>
1954 <li> SME
1955 <li> PE
1956 <li> HAL
1957 <li> TL
1958 </ul>
1959
1960 \param msgQueueId - identifies the message queue upon which the message
1961 will be posted.
1962
1963 \param message - a pointer to a message buffer. Memory for this message
1964 buffer is allocated by the caller and free'd by the vOSS after the
1965 message is posted to the message queue. If the consumer of the
1966 message needs anything in this message, it needs to copy the contents
1967 before returning from the message queue handler.
1968
1969 \return VOS_STATUS_SUCCESS - the message has been successfully posted
1970 to the message queue.
1971
1972 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
1973 refer to a valid Message Queue Id.
1974
1975 VOS_STATUS_E_FAULT - message is an invalid pointer.
1976
1977 VOS_STATUS_E_FAILURE - the message queue handler has reported
1978 an unknown failure.
1979
1980 \sa
1981
1982 --------------------------------------------------------------------------*/
1983VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
1984{
1985 pVosMqType pTargetMq = NULL;
1986 pVosMsgWrapper pMsgWrapper = NULL;
1987
1988 if ((gpVosContext == NULL) || (pMsg == NULL))
1989 {
1990 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1991 "%s: Null params or global vos context is null", __func__);
1992 VOS_ASSERT(0);
1993 return VOS_STATUS_E_FAILURE;
1994 }
1995
1996 switch (msgQueueId)
1997 {
1998 /// Message Queue ID for messages bound for SME
1999 case VOS_MQ_ID_SME:
2000 {
2001 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
2002 break;
2003 }
2004
2005 /// Message Queue ID for messages bound for PE
2006 case VOS_MQ_ID_PE:
2007 {
2008 pTargetMq = &(gpVosContext->vosSched.peMcMq);
2009 break;
2010 }
2011
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 /// Message Queue ID for messages bound for WDA
2013 case VOS_MQ_ID_WDA:
2014 {
2015 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
2016 break;
2017 }
2018
2019 /// Message Queue ID for messages bound for WDI
2020 case VOS_MQ_ID_WDI:
2021 {
2022 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
2023 break;
2024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002025
2026 /// Message Queue ID for messages bound for TL
2027 case VOS_MQ_ID_TL:
2028 {
2029 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
2030 break;
2031 }
2032
2033 /// Message Queue ID for messages bound for the SYS module
2034 case VOS_MQ_ID_SYS:
2035 {
2036 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
2037 break;
2038 }
2039
2040 default:
2041
2042 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2043 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
2044 __func__, msgQueueId);
2045
2046 return VOS_STATUS_E_FAILURE;
2047 }
2048
2049 VOS_ASSERT(NULL !=pTargetMq);
2050 if (pTargetMq == NULL)
2051 {
2052 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002053 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 return VOS_STATUS_E_FAILURE;
2055 }
2056
2057 /*
2058 ** Try and get a free Msg wrapper
2059 */
2060 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2061
2062 if (NULL == pMsgWrapper)
2063 {
2064 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2065 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302066 if (!gpVosContext->vosWrapperFullReported)
2067 {
2068 gpVosContext->vosWrapperFullReported = 1;
2069 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2070 WLAN_LOG_INDICATOR_HOST_ONLY,
2071 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2072 FALSE, TRUE);
2073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 return VOS_STATUS_E_RESOURCES;
2075 }
2076
2077 /*
2078 ** Copy the message now
2079 */
2080 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2081 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2082
2083 vos_mq_put(pTargetMq, pMsgWrapper);
2084
2085 set_bit(MC_POST_EVENT_MASK, &gpVosContext->vosSched.mcEventFlag);
2086 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
2087
2088 return VOS_STATUS_SUCCESS;
2089
2090} /* vos_mq_post_message()*/
2091
2092
2093/**---------------------------------------------------------------------------
2094
2095 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
2096
2097 This API allows messages to be posted to a specific message queue in the
2098 Tx excution flow. Messages for the Tx execution flow can be posted only
2099 to the following queue.
2100
2101 <ul>
2102 <li> TL
2103 <li> SSC/WDI
2104 </ul>
2105
2106 \param msgQueueId - identifies the message queue upon which the message
2107 will be posted.
2108
2109 \param message - a pointer to a message buffer. Body memory for this message
2110 buffer is allocated by the caller and free'd by the vOSS after the
2111 message is dispacthed to the appropriate component. If the consumer
2112 of the message needs to keep anything in the body, it needs to copy
2113 the contents before returning from the message handler.
2114
2115 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2116 to the message queue.
2117
2118 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2119 refer to a valid Message Queue Id.
2120
2121 VOS_STATUS_E_FAULT - message is an invalid pointer.
2122
2123 VOS_STATUS_E_FAILURE - the message queue handler has reported
2124 an unknown failure.
2125
2126 \sa
2127
2128 --------------------------------------------------------------------------*/
2129VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2130{
2131 pVosMqType pTargetMq = NULL;
2132 pVosMsgWrapper pMsgWrapper = NULL;
2133
2134 if ((gpVosContext == NULL) || (pMsg == NULL))
2135 {
2136 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2137 "%s: Null params or global vos context is null", __func__);
2138 VOS_ASSERT(0);
2139 return VOS_STATUS_E_FAILURE;
2140 }
2141
2142 switch (msgQueueId)
2143 {
2144 /// Message Queue ID for messages bound for SME
2145 case VOS_MQ_ID_TL:
2146 {
2147 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
2148 break;
2149 }
2150
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 /// Message Queue ID for messages bound for SSC
2152 case VOS_MQ_ID_WDI:
2153 {
2154 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
2155 break;
2156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002157
2158 /// Message Queue ID for messages bound for the SYS module
2159 case VOS_MQ_ID_SYS:
2160 {
2161 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
2162 break;
2163 }
2164
2165 default:
2166
2167 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302168 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 __func__, msgQueueId);
2170
2171 return VOS_STATUS_E_FAILURE;
2172 }
2173
2174 if (pTargetMq == NULL)
2175 {
2176 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002177 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 return VOS_STATUS_E_FAILURE;
2179 }
2180
2181
2182 /*
2183 ** Try and get a free Msg wrapper
2184 */
2185 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2186
2187 if (NULL == pMsgWrapper)
2188 {
2189 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2190 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302191 if (!gpVosContext->vosWrapperFullReported)
2192 {
2193 gpVosContext->vosWrapperFullReported = 1;
2194 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2195 WLAN_LOG_INDICATOR_HOST_ONLY,
2196 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2197 FALSE, TRUE);
2198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002199
2200 return VOS_STATUS_E_RESOURCES;
2201 }
2202
2203 /*
2204 ** Copy the message now
2205 */
2206 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2207 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2208
2209 vos_mq_put(pTargetMq, pMsgWrapper);
2210
2211 set_bit(TX_POST_EVENT_MASK, &gpVosContext->vosSched.txEventFlag);
2212 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
2213
2214 return VOS_STATUS_SUCCESS;
2215
2216} /* vos_tx_mq_serialize()*/
2217
Jeff Johnson295189b2012-06-20 16:38:30 -07002218/**---------------------------------------------------------------------------
2219
2220 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
2221
2222 This API allows messages to be posted to a specific message queue in the
2223 Tx excution flow. Messages for the Rx execution flow can be posted only
2224 to the following queue.
2225
2226 <ul>
2227 <li> TL
2228 <li> WDI
2229 </ul>
2230
2231 \param msgQueueId - identifies the message queue upon which the message
2232 will be posted.
2233
2234 \param message - a pointer to a message buffer. Body memory for this message
2235 buffer is allocated by the caller and free'd by the vOSS after the
2236 message is dispacthed to the appropriate component. If the consumer
2237 of the message needs to keep anything in the body, it needs to copy
2238 the contents before returning from the message handler.
2239
2240 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2241 to the message queue.
2242
2243 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2244 refer to a valid Message Queue Id.
2245
2246 VOS_STATUS_E_FAULT - message is an invalid pointer.
2247
2248 VOS_STATUS_E_FAILURE - the message queue handler has reported
2249 an unknown failure.
2250
2251 \sa
2252
2253 --------------------------------------------------------------------------*/
2254
2255VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2256{
2257 pVosMqType pTargetMq = NULL;
2258 pVosMsgWrapper pMsgWrapper = NULL;
2259 if ((gpVosContext == NULL) || (pMsg == NULL))
2260 {
2261 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2262 "%s: Null params or global vos context is null", __func__);
2263 VOS_ASSERT(0);
2264 return VOS_STATUS_E_FAILURE;
2265 }
2266
2267 switch (msgQueueId)
2268 {
2269
2270 case VOS_MQ_ID_SYS:
2271 {
2272 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
2273 break;
2274 }
2275
2276 /// Message Queue ID for messages bound for WDI
2277 case VOS_MQ_ID_WDI:
2278 {
2279 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
2280 break;
2281 }
Katya Nigam664f5032014-05-05 12:24:32 +05302282 case VOS_MQ_ID_TL:
2283 {
2284 pTargetMq = &(gpVosContext->vosSched.tlRxMq);
2285 break;
2286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002287
2288 default:
2289
2290 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302291 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 __func__, msgQueueId);
2293
2294 return VOS_STATUS_E_FAILURE;
2295 }
2296
2297 if (pTargetMq == NULL)
2298 {
2299 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002300 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 return VOS_STATUS_E_FAILURE;
2302 }
2303
2304
2305 /*
2306 ** Try and get a free Msg wrapper
2307 */
2308 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2309
2310 if (NULL == pMsgWrapper)
2311 {
2312 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2313 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302314 if (!gpVosContext->vosWrapperFullReported)
2315 {
2316 gpVosContext->vosWrapperFullReported = 1;
2317 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2318 WLAN_LOG_INDICATOR_HOST_ONLY,
2319 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2320 FALSE, TRUE);
2321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 return VOS_STATUS_E_RESOURCES;
2324 }
2325
2326 /*
2327 ** Copy the message now
2328 */
2329 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2330 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2331
2332 vos_mq_put(pTargetMq, pMsgWrapper);
2333
2334 set_bit(RX_POST_EVENT_MASK, &gpVosContext->vosSched.rxEventFlag);
2335 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
2336
2337 return VOS_STATUS_SUCCESS;
2338
2339} /* vos_rx_mq_serialize()*/
2340
Jeff Johnson295189b2012-06-20 16:38:30 -07002341v_VOID_t
2342vos_sys_probe_thread_cback
2343(
2344 v_VOID_t *pUserData
2345)
2346{
2347 if (gpVosContext != pUserData)
2348 {
2349 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002350 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 return;
2352 }
2353
2354 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2355 {
2356 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002357 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 return;
2359 }
2360
2361} /* vos_sys_probe_thread_cback() */
2362
Jeff Johnson295189b2012-06-20 16:38:30 -07002363v_VOID_t vos_WDAComplete_cback
2364(
2365 v_VOID_t *pUserData
2366)
2367{
2368
2369 if (gpVosContext != pUserData)
2370 {
2371 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002372 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 return;
2374 }
2375
2376 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
2377 {
2378 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002379 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 return;
2381 }
2382
2383} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07002384
2385v_VOID_t vos_core_return_msg
2386(
2387 v_PVOID_t pVContext,
2388 pVosMsgWrapper pMsgWrapper
2389)
2390{
2391 pVosContextType pVosContext = (pVosContextType) pVContext;
2392
2393 VOS_ASSERT( gpVosContext == pVosContext);
2394
2395 if (gpVosContext != pVosContext)
2396 {
2397 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002398 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 return;
2400 }
2401
2402 VOS_ASSERT( NULL !=pMsgWrapper );
2403
2404 if (pMsgWrapper == NULL)
2405 {
2406 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002407 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 return;
2409 }
2410
2411 /*
2412 ** Return the message on the free message queue
2413 */
2414 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
2415 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
2416
2417} /* vos_core_return_msg() */
2418
2419
2420/**
2421 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
2422 TL config params from the registry
2423
2424 @param pAdapter : [inout] pointer to TL config block
2425
2426 @return
2427 None
2428
2429*/
2430v_VOID_t
2431vos_fetch_tl_cfg_parms
2432(
2433 WLANTL_ConfigInfoType *pTLConfig,
2434 hdd_config_t * pConfig
2435)
2436{
2437 if (pTLConfig == NULL)
2438 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002439 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 return;
2441 }
2442
2443 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
2444 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
2445 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
2446 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302447 pTLConfig->ucAcWeights[4] = pConfig->WfqVoWeight;
Dhanashri Atred8c20a32014-01-03 17:20:55 -08002448 pTLConfig->ucReorderAgingTime[0] = pConfig->BkReorderAgingTime;/*WLANTL_AC_BK*/
2449 pTLConfig->ucReorderAgingTime[1] = pConfig->BeReorderAgingTime;/*WLANTL_AC_BE*/
2450 pTLConfig->ucReorderAgingTime[2] = pConfig->ViReorderAgingTime;/*WLANTL_AC_VI*/
2451 pTLConfig->ucReorderAgingTime[3] = pConfig->VoReorderAgingTime;/*WLANTL_AC_VO*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07002454
2455}
2456
2457v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
2458{
2459 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
2460}
2461
Jeff Johnson295189b2012-06-20 16:38:30 -07002462/*---------------------------------------------------------------------------
2463
2464 \brief vos_shutdown() - shutdown VOS
2465
2466 - All VOS submodules are closed.
2467
2468 - All the WLAN SW components should have been opened. This includes
2469 SYS, MAC, SME and TL.
2470
2471
2472 \param vosContext: Global vos context
2473
2474
2475 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
2476
2477 VOS_STATUS_E_FAILURE - Failure to close
2478
2479---------------------------------------------------------------------------*/
2480VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2481{
2482 VOS_STATUS vosStatus;
2483
2484#ifdef WLAN_BTAMP_FEATURE
2485 vosStatus = WLANBAP_Close(vosContext);
2486 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2487 {
2488 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2489 "%s: Failed to close BAP", __func__);
2490 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2491 }
2492#endif // WLAN_BTAMP_FEATURE
2493
2494 vosStatus = WLANTL_Close(vosContext);
2495 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2496 {
2497 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2498 "%s: Failed to close TL", __func__);
2499 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2500 }
2501
2502 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2503 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2504 {
2505 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2506 "%s: Failed to close SME", __func__);
2507 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2508 }
2509
2510 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2511 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2512 {
2513 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2514 "%s: Failed to close MAC", __func__);
2515 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2516 }
2517
2518 ((pVosContextType)vosContext)->pMACContext = NULL;
2519
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 vosStatus = sysClose( vosContext );
2521 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2522 {
2523 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2524 "%s: Failed to close SYS", __func__);
2525 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2526 }
2527
2528 /* Let DXE return packets in WDA_close and then free them here */
2529 vosStatus = vos_packet_close( vosContext );
2530 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2531 {
2532 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2533 "%s: Failed to close VOSS Packet", __func__);
2534 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2535 }
2536
2537 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2538
Sachin Ahuja715aafc2015-07-21 23:35:10 +05302539 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
2540 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2541 {
2542 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2543 "%s: failed to destroy fwLogsComplete", __func__);
2544 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2545 }
2546
2547
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2549 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2550 {
2551 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2552 "%s: failed to destroy wdaCompleteEvent", __func__);
2553 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2554 }
2555
2556 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2557 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2558 {
2559 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2560 "%s: failed to destroy ProbeEvent", __func__);
2561 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2562 }
2563
2564 return VOS_STATUS_SUCCESS;
2565}
2566
2567/*---------------------------------------------------------------------------
2568
2569 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2570
2571 - WDA/WDI shutdown
2572
2573 \param vosContext: Global vos context
2574
2575
2576 \return VOS_STATUS_SUCCESS - Operation successfull
2577
2578 VOS_STATUS_E_FAILURE - Failure to close
2579
2580---------------------------------------------------------------------------*/
2581VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2582{
2583 VOS_STATUS vosStatus;
2584 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2585
2586 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2587 {
2588 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2589 "%s: failed to shutdown WDA", __func__);
2590 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2591 }
2592 return vosStatus;
2593}
2594/**
2595 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2596
2597 This function is called when Riva subsystem crashes. There are two
2598 methods (or operations) in WLAN driver to handle Riva crash,
2599 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2600 driver without handshaking with Riva.
2601 2. re-init: Next API
2602 @param
2603 NONE
2604 @return
2605 VOS_STATUS_SUCCESS - Operation completed successfully.
2606 VOS_STATUS_E_FAILURE - Operation failed.
2607
2608*/
2609VOS_STATUS vos_wlanShutdown(void)
2610{
2611 VOS_STATUS vstatus;
2612 vstatus = vos_watchdog_wlan_shutdown();
2613 return vstatus;
2614}
2615/**
2616 @brief vos_wlanReInit() - This API will re-init WLAN driver
2617
2618 This function is called when Riva subsystem reboots. There are two
2619 methods (or operations) in WLAN driver to handle Riva crash,
2620 1. shutdown: Previous API
2621 2. re-init: Called when Riva comes back after the crash. This will
2622 re-initialize WLAN driver. In some cases re-open may be
2623 referred instead of re-init.
2624 @param
2625 NONE
2626 @return
2627 VOS_STATUS_SUCCESS - Operation completed successfully.
2628 VOS_STATUS_E_FAILURE - Operation failed.
2629
2630*/
2631VOS_STATUS vos_wlanReInit(void)
2632{
2633 VOS_STATUS vstatus;
2634 vstatus = vos_watchdog_wlan_re_init();
2635 return vstatus;
2636}
Jeff Johnsone7245742012-09-05 17:12:55 -07002637/**
2638 @brief vos_wlanRestart() - This API will reload WLAN driver.
2639
2640 This function is called if driver detects any fatal state which
2641 can be recovered by a WLAN module reload ( Android framwork initiated ).
2642 Note that this API will not initiate any RIVA subsystem restart.
2643
2644 The function wlan_hdd_restart_driver protects against re-entrant calls.
2645
2646 @param
2647 NONE
2648 @return
2649 VOS_STATUS_SUCCESS - Operation completed successfully.
2650 VOS_STATUS_E_FAILURE - Operation failed.
2651 VOS_STATUS_E_EMPTY - No configured interface
2652 VOS_STATUS_E_ALREADY - Request already in progress
2653
2654
2655*/
2656VOS_STATUS vos_wlanRestart(void)
2657{
2658 VOS_STATUS vstatus;
2659 hdd_context_t *pHddCtx = NULL;
2660 v_CONTEXT_t pVosContext = NULL;
2661
2662 /* Check whether driver load unload is in progress */
2663 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2664 {
2665 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2666 "%s: Driver load/unload is in progress, retry later.", __func__);
2667 return VOS_STATUS_E_AGAIN;
2668 }
2669
2670 /* Get the Global VOSS Context */
2671 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2672 if(!pVosContext) {
2673 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2674 "%s: Global VOS context is Null", __func__);
2675 return VOS_STATUS_E_FAILURE;
2676 }
2677
2678 /* Get the HDD context */
2679 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2680 if(!pHddCtx) {
2681 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2682 "%s: HDD context is Null", __func__);
2683 return VOS_STATUS_E_FAILURE;
2684 }
2685
2686 /* Reload the driver */
2687 vstatus = wlan_hdd_restart_driver(pHddCtx);
2688 return vstatus;
2689}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302690
2691
2692/**
2693 @brief vos_fwDumpReq()
2694
2695 This function is called to issue dump commands to Firmware
2696
2697 @param
Siddharth Bhal68115602015-01-18 20:44:55 +05302698 cmd - Command No. to execute
2699 arg1 - argument 1 to cmd
2700 arg2 - argument 2 to cmd
2701 arg3 - argument 3 to cmd
2702 arg4 - argument 4 to cmd
2703 async - asynchronous event. Don't wait for completion.
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302704 @return
2705 NONE
2706*/
2707v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
Siddharth Bhal68115602015-01-18 20:44:55 +05302708 tANI_U32 arg3, tANI_U32 arg4, tANI_U8 async)
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302709{
Siddharth Bhalec9581a2015-02-18 14:48:18 +05302710 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL, async);
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302711}
Dino Mycle3f783bc2014-08-08 17:40:22 +05302712
2713v_U64_t vos_get_monotonic_boottime(void)
2714{
2715 struct timespec ts;
2716 wcnss_get_monotonic_boottime(&ts);
2717 return (((v_U64_t)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
2718}
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05302719
2720/**---------------------------------------------------------------------------
2721
2722 \brief vos_randomize_n_bytes() - HDD Random Mac Addr Generator
2723
2724 This generates the random mac address for WLAN interface
2725
2726 \param - mac_addr - pointer to Mac address
2727
2728 \return - 0 for success, < 0 for failure
2729
2730 --------------------------------------------------------------------------*/
2731
2732VOS_STATUS vos_randomize_n_bytes(void *start_addr, tANI_U32 n)
2733{
2734
2735 if (start_addr == NULL )
2736 return VOS_STATUS_E_FAILURE;
2737
2738 get_random_bytes( start_addr, n);
2739
2740 return eHAL_STATUS_SUCCESS;
2741}
c_hpothu8adb97b2014-12-08 19:38:20 +05302742
2743/**---------------------------------------------------------------------------
2744
2745 \brief vos_is_wlan_in_badState() - get isFatalError flag from WD Ctx
2746
2747 \param - VOS_MODULE_ID - module id
2748 - moduleContext - module context
2749
2750 \return - isFatalError value if WDCtx is valid otherwise true
2751
2752 --------------------------------------------------------------------------*/
2753v_BOOL_t vos_is_wlan_in_badState(VOS_MODULE_ID moduleId,
2754 v_VOID_t *moduleContext)
2755{
2756 struct _VosWatchdogContext *pVosWDCtx = get_vos_watchdog_ctxt();
2757
2758 if (pVosWDCtx == NULL){
2759 VOS_TRACE(moduleId, VOS_TRACE_LEVEL_ERROR,
2760 "%s: global wd context is null", __func__);
2761
2762 return TRUE;
2763 }
2764 return pVosWDCtx->isFatalError;
2765}
Girish Gowlia33f0372015-01-19 15:39:04 +05302766
Girish Gowlia33f0372015-01-19 15:39:04 +05302767/**---------------------------------------------------------------------------
2768
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302769 \brief vos_is_fw_logging_enabled() -
2770
2771 API to check if firmware is configured to send logs using DXE channel
2772
2773 \param - None
2774
Mihir Sheted6274602015-04-28 16:13:21 +05302775 \return - 0: firmware logging is not enabled (it may or may not
2776 be supported)
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302777 1: firmware logging is enabled
2778
2779 --------------------------------------------------------------------------*/
2780v_U8_t vos_is_fw_logging_enabled(void)
2781{
2782 return hdd_is_fw_logging_enabled();
2783}
2784
2785/**---------------------------------------------------------------------------
2786
Mihir Shetebe94ebb2015-05-26 12:07:14 +05302787 \brief vos_is_fw_ev_logging_enabled() -
2788
2789 API to check if firmware is configured to send live logs using DXE channel
2790
2791 \param - None
2792
2793 \return - 0: firmware logging is not enabled (it may or may not
2794 be supported)
2795 1: firmware logging is enabled
2796
2797 --------------------------------------------------------------------------*/
2798v_U8_t vos_is_fw_ev_logging_enabled(void)
2799{
2800 return hdd_is_fw_ev_logging_enabled();
2801}
2802
2803/**---------------------------------------------------------------------------
2804
Mihir Sheted6274602015-04-28 16:13:21 +05302805 \brief vos_is_fw_logging_supported() -
2806
2807 API to check if firmware supports to send logs using DXE channel
2808
2809 \param - None
2810
2811 \return - 0: firmware logging is not supported
2812 1: firmware logging is supported
2813
2814 --------------------------------------------------------------------------*/
2815v_U8_t vos_is_fw_logging_supported(void)
2816{
2817 return IS_FRAME_LOGGING_SUPPORTED_BY_FW;
2818}
2819/**---------------------------------------------------------------------------
2820
Girish Gowlia33f0372015-01-19 15:39:04 +05302821 \brief vos_set_roam_delay_stats_enabled() -
2822
2823 API to set value of roamDelayStatsEnabled in vos context
2824
2825 \param - value to be updated
2826
2827 \return - NONE
2828
2829 --------------------------------------------------------------------------*/
2830
2831v_VOID_t vos_set_roam_delay_stats_enabled(v_U8_t value)
2832{
2833 gpVosContext->roamDelayStatsEnabled = value;
2834}
2835
2836
2837/**---------------------------------------------------------------------------
2838
2839 \brief vos_get_roam_delay_stats_enabled() -
2840
2841 API to get value of roamDelayStatsEnabled from vos context
2842
2843 \param - NONE
2844
2845 \return - value of roamDelayStatsEnabled
2846
2847 --------------------------------------------------------------------------*/
2848
2849v_U8_t vos_get_roam_delay_stats_enabled(v_VOID_t)
2850{
2851 return gpVosContext->roamDelayStatsEnabled;
2852}
Katya Nigama6fbf662015-03-17 18:35:47 +05302853
2854v_U32_t vos_get_dxeReplenishRXTimerVal(void)
2855{
2856 hdd_context_t *pHddCtx = NULL;
2857 v_CONTEXT_t pVosContext = NULL;
2858
2859 /* Get the Global VOSS Context */
2860 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2861 if(!pVosContext) {
2862 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2863 return 0;
2864 }
2865
2866 /* Get the HDD context */
2867 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2868 if(!pHddCtx) {
2869 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2870 return 0;
2871 }
2872
2873 return pHddCtx->cfg_ini->dxeReplenishRXTimerVal;
2874}
2875
2876v_BOOL_t vos_get_dxeSSREnable(void)
2877{
2878 hdd_context_t *pHddCtx = NULL;
2879 v_CONTEXT_t pVosContext = NULL;
2880
2881 /* Get the Global VOSS Context */
2882 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2883 if(!pVosContext) {
2884 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
2885 return FALSE;
2886 }
2887
2888 /* Get the HDD context */
2889 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2890 if(!pHddCtx) {
2891 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
2892 return FALSE;
2893 }
2894
2895 return pHddCtx->cfg_ini->dxeSSREnable;
2896}
Anand N Sunkad860e5ea2015-03-30 14:41:51 +05302897
2898v_VOID_t vos_flush_work(struct work_struct *work)
2899{
2900#if defined (WLAN_OPEN_SOURCE)
2901 cancel_work_sync(work);
2902#else
2903 wcnss_flush_work(work);
2904#endif
2905}
2906
2907v_VOID_t vos_flush_delayed_work(struct delayed_work *dwork)
2908{
2909#if defined (WLAN_OPEN_SOURCE)
2910 cancel_delayed_work_sync(dwork);
2911#else
2912 wcnss_flush_delayed_work(dwork);
2913#endif
2914}
2915
Anand N Sunkaddc63c792015-06-03 14:33:24 +05302916v_VOID_t vos_init_work(struct work_struct *work , void *callbackptr)
2917{
2918#if defined (WLAN_OPEN_SOURCE)
2919 INIT_WORK(work,callbackptr);
2920#else
2921 wcnss_init_work(work, callbackptr);
2922#endif
2923}
2924
2925v_VOID_t vos_init_delayed_work(struct delayed_work *dwork , void *callbackptr)
2926{
2927#if defined (WLAN_OPEN_SOURCE)
2928 INIT_DELAYED_WORK(dwork,callbackptr);
2929#else
2930 wcnss_init_delayed_work(dwork, callbackptr);
2931#endif
2932}
2933
Sushant Kaushik215778f2015-05-21 14:05:36 +05302934/**
2935 * vos_set_multicast_logging() - Set mutlicast logging value
2936 * @value: Value of multicast logging
2937 *
2938 * Set the multicast logging value which will indicate
2939 * whether to multicast host and fw messages even
2940 * without any registration by userspace entity
2941 *
2942 * Return: None
2943 */
2944void vos_set_multicast_logging(uint8_t value)
2945{
2946 vos_multicast_logging = value;
2947}
2948
2949/**
2950 * vos_is_multicast_logging() - Get multicast logging value
2951 *
2952 * Get the multicast logging value which will indicate
2953 * whether to multicast host and fw messages even
2954 * without any registration by userspace entity
2955 *
2956 * Return: 0 - Multicast logging disabled, 1 - Multicast logging enabled
2957 */
2958v_U8_t vos_is_multicast_logging(void)
2959{
2960 return vos_multicast_logging;
2961}
2962
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05302963/**
Abhishek Singh30fd58c2015-07-15 14:19:21 +05302964 * vos_isLoadUnloadInProgress()
2965 *
2966 * Return TRUE if load/unload is in progress.
2967 *
2968 */
2969v_BOOL_t vos_isLoadUnloadInProgress(void)
2970{
2971 hdd_context_t *pHddCtx = NULL;
2972 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2973
2974 if(!pVosContext)
2975 {
2976 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
2977 return FALSE;
2978 }
2979
2980 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2981 if(!pHddCtx) {
2982 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2983 "%s: HDD context is Null", __func__);
2984 return FALSE;
2985 }
2986
2987 return ( 0 != pHddCtx->isLoadUnloadInProgress);
2988}
2989
2990/**
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05302991 * vos_isUnloadInProgress()
2992 *
2993 * Return TRUE if unload is in progress.
2994 *
2995 */
2996v_BOOL_t vos_isUnloadInProgress(void)
2997{
2998 hdd_context_t *pHddCtx = NULL;
2999 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3000
3001 if(!pVosContext)
3002 {
3003 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3004 return FALSE;
3005 }
3006
3007 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3008 if(!pHddCtx) {
3009 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3010 "%s: HDD context is Null", __func__);
3011 return FALSE;
3012 }
3013
3014 return (WLAN_HDD_UNLOAD_IN_PROGRESS == pHddCtx->isLoadUnloadInProgress);
3015}
3016
Abhishek Singh880d7122015-08-26 16:23:04 +05303017/**
3018 * vos_probe_threads() - VOS API to post messages
3019 * to all the threads to detect if they are active or not
3020 *
3021 * Return none.
3022 *
3023 */
3024void vos_probe_threads(void)
3025{
3026 vos_msg_t msg;
3027
3028 msg.callback = wlan_logging_reset_thread_stuck_count;
3029 /* Post Message to MC Thread */
3030 sysBuildMessageHeader(SYS_MSG_ID_MC_THR_PROBE, &msg);
3031 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SYS, &msg)) {
3032 pr_err("%s: Unable to post SYS_MSG_ID_MC_THR_PROBE message to MC thread\n",
3033 __func__);
3034 }
3035
3036 /* Post Message to Tx Thread */
3037 sysBuildMessageHeader(SYS_MSG_ID_TX_THR_PROBE, &msg);
3038 if (VOS_STATUS_SUCCESS != vos_tx_mq_serialize(VOS_MQ_ID_SYS, &msg)) {
3039 pr_err("%s: Unable to post SYS_MSG_ID_TX_THR_PROBE message to TX thread\n",
3040 __func__);
3041 }
3042
3043 /* Post Message to Rx Thread */
3044 sysBuildMessageHeader(SYS_MSG_ID_RX_THR_PROBE, &msg);
3045 if (VOS_STATUS_SUCCESS != vos_rx_mq_serialize(VOS_MQ_ID_SYS, &msg)) {
3046 pr_err("%s: Unable to post SYS_MSG_ID_RX_THR_PROBE message to RX thread\n",
3047 __func__);
3048 }
3049}
3050
Sushant Kaushik8e644982015-09-23 12:18:54 +05303051/**
3052 * vos_set_ring_log_level() - Convert HLOS values to driver log levels
3053 * @ring_id: ring_id
3054 * @log_levelvalue: Log level specificed
3055 *
3056 * This function sets the log level of a particular ring
3057 *
3058 * Return: None
3059 */
3060 void vos_set_ring_log_level(v_U32_t ring_id, v_U32_t log_level)
3061{
3062 VosContextType *vos_context;
3063 v_U32_t log_val;
3064
3065 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3066 if (!vos_context) {
3067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3068 "%s: vos context is Invald", __func__);
3069 return;
3070 }
3071
3072 switch (log_level) {
3073 case LOG_LEVEL_NO_COLLECTION:
3074 log_val = WLAN_LOG_LEVEL_OFF;
3075 break;
3076 case LOG_LEVEL_NORMAL_COLLECT:
3077 log_val = WLAN_LOG_LEVEL_NORMAL;
3078 break;
3079 case LOG_LEVEL_ISSUE_REPRO:
3080 log_val = WLAN_LOG_LEVEL_REPRO;
3081 break;
3082 case LOG_LEVEL_ACTIVE:
3083 default:
3084 log_val = WLAN_LOG_LEVEL_ACTIVE;
3085 break;
3086 }
3087
3088 if (ring_id == RING_ID_WAKELOCK) {
3089 vos_context->wakelock_log_level = log_val;
3090 return;
3091 } else if (ring_id == RING_ID_CONNECTIVITY) {
3092 vos_context->connectivity_log_level = log_val;
3093 return;
3094 } else if (ring_id == RING_ID_PER_PACKET_STATS) {
3095 vos_context->packet_stats_log_level = log_val;
Sushant Kaushik33200572015-08-05 16:46:20 +05303096 if (WLAN_LOG_LEVEL_ACTIVE != log_val)
3097 wlan_disable_and_flush_pkt_stats();
3098
Sushant Kaushik8e644982015-09-23 12:18:54 +05303099 return;
3100 }
3101}
3102/**
3103 * vos_get_ring_log_level() - Get the a ring id's log level
3104 * @ring_id: Ring id
3105 *
3106 * Fetch and return the log level corresponding to a ring id
3107 *
3108 * Return: Log level corresponding to the ring ID
3109 */
3110v_U8_t vos_get_ring_log_level(v_U32_t ring_id)
3111{
3112 VosContextType *vos_context;
3113
3114 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3115 if (!vos_context) {
3116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3117 "%s: vos context is Invald", __func__);
3118 return WLAN_LOG_LEVEL_OFF;
3119 }
3120
3121 if (ring_id == RING_ID_WAKELOCK)
3122 return vos_context->wakelock_log_level;
3123 else if (ring_id == RING_ID_CONNECTIVITY)
3124 return vos_context->connectivity_log_level;
3125 else if (ring_id == RING_ID_PER_PACKET_STATS)
3126 return vos_context->packet_stats_log_level;
3127
3128 return WLAN_LOG_LEVEL_OFF;
3129}
Sushant Kaushik33200572015-08-05 16:46:20 +05303130
3131/* elements are rate, preamable, bw, short_gi */
3132rateidx_to_rate_bw_preamble_sgi rateidx_to_rate_bw_preamble_sgi_table[] =
3133{
3134/*11B CCK Long preamble (0-3)*/
3135{ 10, PREAMBLE_CCK, S_BW20, 0},{ 20, PREAMBLE_CCK, S_BW20, 0},
3136{ 55, PREAMBLE_CCK, S_BW20, 0},{ 110, PREAMBLE_CCK, S_BW20, 0},
3137/*11B CCK Short preamble (4-7)*/
3138{ 10, PREAMBLE_CCK, S_BW20, 0},{ 20, PREAMBLE_CCK, S_BW20, 0},
3139{ 55, PREAMBLE_CCK, S_BW20, 0},{ 110, PREAMBLE_CCK, S_BW20, 0},
3140/*11G/A (8-15)*/
3141{ 60, PREAMBLE_OFDM, S_BW20, 0},{ 90, PREAMBLE_OFDM, S_BW20, 0},
3142{ 120, PREAMBLE_OFDM, S_BW20, 0},{ 180, PREAMBLE_OFDM, S_BW20, 0},
3143{ 240, PREAMBLE_OFDM, S_BW20, 0},{ 360, PREAMBLE_OFDM, S_BW20, 0},
3144{ 480, PREAMBLE_OFDM, S_BW20, 0},{ 540, PREAMBLE_OFDM, S_BW20, 0},
3145/*HT20 LGI MCS 0-7 (16-23)*/
3146{ 65, PREAMBLE_HT, S_BW20, 0},{ 130, PREAMBLE_HT, S_BW20, 0},
3147{ 195, PREAMBLE_HT, S_BW20, 0},{ 260, PREAMBLE_HT, S_BW20, 0},
3148{ 390, PREAMBLE_HT, S_BW20, 0},{ 520, PREAMBLE_HT, S_BW20, 0},
3149{ 585, PREAMBLE_HT, S_BW20, 0},{ 650, PREAMBLE_HT, S_BW20, 0},
3150/*HT20 SGI MCS 0-7 (24-31)*/
3151{ 72, PREAMBLE_HT, S_BW20, 1},{ 144, PREAMBLE_HT, S_BW20, 1},
3152{ 217, PREAMBLE_HT, S_BW20, 1},{ 289, PREAMBLE_HT, S_BW20, 1},
3153{ 433, PREAMBLE_HT, S_BW20, 1},{ 578, PREAMBLE_HT, S_BW20, 1},
3154{ 650, PREAMBLE_HT, S_BW20, 1},{ 722, PREAMBLE_HT, S_BW20, 1},
3155/*HT20 Greenfield MCS 0-7 rates (32-39)*/
3156{ 65, PREAMBLE_HT, S_BW20, 0},{ 130, PREAMBLE_HT, S_BW20, 0},
3157{ 195, PREAMBLE_HT, S_BW20, 0},{ 260, PREAMBLE_HT, S_BW20, 0},
3158{ 390, PREAMBLE_HT, S_BW20, 0},{ 520, PREAMBLE_HT, S_BW20, 0},
3159{ 585, PREAMBLE_HT, S_BW20, 0},{ 650, PREAMBLE_HT, S_BW20, 0},
3160/*HT40 LGI MCS 0-7 (40-47)*/
3161{ 135, PREAMBLE_HT, S_BW40, 0},{ 270, PREAMBLE_HT, S_BW40, 0},
3162{ 405, PREAMBLE_HT, S_BW40, 0},{ 540, PREAMBLE_HT, S_BW40, 0},
3163{ 810, PREAMBLE_HT, S_BW40, 0},{ 1080, PREAMBLE_HT, S_BW40, 0},
3164{ 1215, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3165/*HT40 SGI MCS 0-7 (48-55)*/
3166{ 150, PREAMBLE_HT, S_BW40, 1},{ 300, PREAMBLE_HT, S_BW40, 1},
3167{ 450, PREAMBLE_HT, S_BW40, 1},{ 600, PREAMBLE_HT, S_BW40, 1},
3168{ 900, PREAMBLE_HT, S_BW40, 1},{ 1200, PREAMBLE_HT, S_BW40, 1},
3169{ 1350, PREAMBLE_HT, S_BW40, 1},{ 1500, PREAMBLE_HT, S_BW40, 1},
3170/*HT40 Greenfield MCS 0-7 rates (56-63) 64-65 are dummy*/
3171{ 135, PREAMBLE_HT, S_BW40, 0},{ 270, PREAMBLE_HT, S_BW40, 0},
3172{ 405, PREAMBLE_HT, S_BW40, 0},{ 540, PREAMBLE_HT, S_BW40, 0},
3173{ 810, PREAMBLE_HT, S_BW40, 0},{ 1080, PREAMBLE_HT, S_BW40, 0},
3174{ 1215, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3175/*64-65 are dummy*/
3176{ 1350, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3177/*VHT20 LGI MCS 0-9 rates (66-75)*/
3178{ 65, PREAMBLE_VHT, S_BW20, 0},{ 130, PREAMBLE_VHT, S_BW20, 0},
3179{ 195, PREAMBLE_VHT, S_BW20, 0},{ 260, PREAMBLE_VHT, S_BW20, 0},
3180{ 390, PREAMBLE_VHT, S_BW20, 0},{ 520, PREAMBLE_VHT, S_BW20, 0},
3181{ 585, PREAMBLE_VHT, S_BW20, 0},{ 650, PREAMBLE_VHT, S_BW20, 0},
3182{ 780, PREAMBLE_VHT, S_BW20, 0},{ 865, PREAMBLE_VHT, S_BW20, 0},
3183/*76-77 are dummy*/
3184{ 865, PREAMBLE_VHT, S_BW20, 0},{ 865, PREAMBLE_VHT, S_BW20, 0},
3185/*VHT20 SGI MCS 0-9 rates (78-87)*/
3186{ 72, PREAMBLE_VHT, S_BW20, 1},{ 144, PREAMBLE_VHT, S_BW20, 1},
3187{ 217, PREAMBLE_VHT, S_BW20, 1},{ 289, PREAMBLE_VHT, S_BW20, 1},
3188{ 433, PREAMBLE_VHT, S_BW20, 1},{ 578, PREAMBLE_VHT, S_BW20, 1},
3189{ 650, PREAMBLE_VHT, S_BW20, 1},{ 722, PREAMBLE_VHT, S_BW20, 1},
3190{ 867, PREAMBLE_VHT, S_BW20, 1},{ 961, PREAMBLE_VHT, S_BW20, 1},
3191/*88-89 are dummy*/
3192{ 961, PREAMBLE_VHT, S_BW20, 1},{ 961, PREAMBLE_VHT, S_BW20, 1},
3193/*VHT40 LGI MCS 0-9 rates (90-101) 98,101 is Dummy*/
3194{ 135, PREAMBLE_VHT, S_BW40, 0},{ 270, PREAMBLE_VHT, S_BW40, 0},
3195{ 405, PREAMBLE_VHT, S_BW40, 0},{ 540, PREAMBLE_VHT, S_BW40, 0},
3196{ 810, PREAMBLE_VHT, S_BW40, 0},{ 1080, PREAMBLE_VHT, S_BW40, 0},
3197{ 1215, PREAMBLE_VHT, S_BW40, 0},{ 1350, PREAMBLE_VHT, S_BW40, 0},
3198{ 1350, PREAMBLE_VHT, S_BW40, 0},{ 1620, PREAMBLE_VHT, S_BW40, 0},
3199{ 1800, PREAMBLE_VHT, S_BW40, 0},{ 1800, PREAMBLE_VHT, S_BW40, 0},
3200/*VHT40 SGI MCS 0-9 rates (102-112) 110, 113 is Dummy*/
3201{ 150, PREAMBLE_VHT, S_BW40, 1},{ 300, PREAMBLE_VHT, S_BW40, 1},
3202{ 450, PREAMBLE_VHT, S_BW40, 1},{ 600, PREAMBLE_VHT, S_BW40, 1},
3203{ 900, PREAMBLE_VHT, S_BW40, 1},{ 1200, PREAMBLE_VHT, S_BW40, 1},
3204{ 1350, PREAMBLE_VHT, S_BW40, 1},{ 1500, PREAMBLE_VHT, S_BW40, 1},
3205{ 1500, PREAMBLE_VHT, S_BW40, 1},{ 1800, PREAMBLE_VHT, S_BW40, 1},
3206{ 2000, PREAMBLE_VHT, S_BW40, 1},{ 2000, PREAMBLE_VHT, S_BW40, 1},
3207/*VHT80 LGI MCS 0-9 rates (114-125) 122, 125 is Dummy*/
3208{ 293, PREAMBLE_VHT, S_BW80, 0},{ 585, PREAMBLE_VHT, S_BW80, 0},
3209{ 878, PREAMBLE_VHT, S_BW80, 0},{ 1170, PREAMBLE_VHT, S_BW80, 0},
3210{ 1755, PREAMBLE_VHT, S_BW80, 0},{ 2340, PREAMBLE_VHT, S_BW80, 0},
3211{ 2633, PREAMBLE_VHT, S_BW80, 0},{ 2925, PREAMBLE_VHT, S_BW80, 0},
3212{ 2925, PREAMBLE_VHT, S_BW80, 0},{ 3510, PREAMBLE_VHT, S_BW80, 0},
3213{ 3900, PREAMBLE_VHT, S_BW80, 0},{ 3900, PREAMBLE_VHT, S_BW80, 0},
3214/*VHT80 SGI MCS 0-9 rates (126-136) 134 is Dummy*/
3215{ 325, PREAMBLE_VHT, S_BW80, 1},{ 650, PREAMBLE_VHT, S_BW80, 1},
3216{ 975, PREAMBLE_VHT, S_BW80, 1},{ 1300, PREAMBLE_VHT, S_BW80, 1},
3217{ 1950, PREAMBLE_VHT, S_BW80, 1},{ 2600, PREAMBLE_VHT, S_BW80, 1},
3218{ 2925, PREAMBLE_VHT, S_BW80, 1},{ 3250, PREAMBLE_VHT, S_BW80, 1},
3219{ 3250, PREAMBLE_VHT, S_BW80, 1},{ 3900, PREAMBLE_VHT, S_BW80, 1},
3220{ 4333, PREAMBLE_VHT, S_BW80, 1},
3221};
3222
3223void get_rate_and_MCS(per_packet_stats *stats, uint32 rateindex)
3224{
3225 rateidx_to_rate_bw_preamble_sgi *ratetbl;
3226
3227 if (STATS_MAX_RATE_INDEX < rateindex)
3228 rateindex = STATS_MAX_RATE_INDEX;
3229 ratetbl= &rateidx_to_rate_bw_preamble_sgi_table[rateindex];
3230 stats->last_transmit_rate = ratetbl->rate/5;
3231 stats->MCS.nss = 0;
3232 if (0 <= rateindex && rateindex <= 7)
3233 stats->MCS.rate = 7 - rateindex;
3234 else if (8 <= rateindex && rateindex <= 15)
3235 {
3236 switch(rateindex)
3237 {
3238 case 8:stats->MCS.rate = 3; break;
3239 case 9:stats->MCS.rate = 7; break;
3240 case 10:stats->MCS.rate = 2; break;
3241 case 11:stats->MCS.rate = 6; break;
3242 case 12:stats->MCS.rate = 1; break;
3243 case 13:stats->MCS.rate = 5; break;
3244 case 14:stats->MCS.rate = 0; break;
3245 case 15:stats->MCS.rate = 4; break;
3246 }
3247 }
3248 else if(16 <= rateindex && rateindex <= 23)
3249 stats->MCS.rate = rateindex - 16;
3250 else if(24 <= rateindex && rateindex <= 31)
3251 stats->MCS.rate = rateindex - 24;
3252 else if(32 <= rateindex && rateindex <= 39)
3253 stats->MCS.rate = rateindex - 32;
3254 else if(40 <= rateindex && rateindex <= 47)
3255 stats->MCS.rate = rateindex - 40;
3256 else if(48 <= rateindex && rateindex <= 55)
3257 stats->MCS.rate = rateindex - 48;
3258 else if(56 <= rateindex && rateindex <= 63)
3259 stats->MCS.rate = rateindex - 56;
3260 else if(66 <= rateindex && rateindex <= 75)
3261 stats->MCS.rate = rateindex - 66;
3262 else if(78 <= rateindex && rateindex <= 87)
3263 stats->MCS.rate = rateindex - 78;
3264 else if(90 <= rateindex && rateindex <= 100)
3265 stats->MCS.rate = rateindex - 90;
3266 else if(78 <= rateindex && rateindex <= 87)
3267 stats->MCS.rate = rateindex - 78;
3268 else if(90 <= rateindex && rateindex <= 97)
3269 stats->MCS.rate = rateindex - 90;
3270 else if(99 <= rateindex && rateindex <= 100)
3271 stats->MCS.rate = rateindex - 91;
3272 else if(102 <= rateindex && rateindex <= 109)
3273 stats->MCS.rate = rateindex - 102;
3274 else if(111 <= rateindex && rateindex <= 112)
3275 stats->MCS.rate = rateindex - 103;
3276 else if(114 <= rateindex && rateindex <= 121)
3277 stats->MCS.rate = rateindex - 114;
3278 else if(123 <= rateindex && rateindex <= 124)
3279 stats->MCS.rate = rateindex - 115;
3280 else if(126 <= rateindex && rateindex <= 133)
3281 stats->MCS.rate = rateindex - 126;
3282 else if(135 <= rateindex && rateindex <= 136)
3283 stats->MCS.rate = rateindex - 127;
3284 else /*Invalid rate index mark it 0*/
3285 stats->MCS.rate = 0;
3286 stats->MCS.preamble = ratetbl->preamble;
3287 stats->MCS.bw = ratetbl->bw;
3288 stats->MCS.short_gi = ratetbl->short_gi;
3289}
3290
3291bool vos_isPktStatsEnabled(void)
3292{
3293 bool value;
3294 value = wlan_isPktStatsEnabled();
3295 return (value);
3296}