blob: 814c113e01133bd9a4e368874fd9b7264946d872 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh8a3e4dc2017-01-02 10:39:18 +05302 * Copyright (c) 2012-2017 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
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +053086#include "wlan_qct_wdi_cts.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070087
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
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +0530103/* Trace index for WDI Read/Write */
104#define VOS_TRACE_INDEX_MAX 256
105
Jeff Johnson295189b2012-06-20 16:38:30 -0700106/*---------------------------------------------------------------------------
107 * Data definitions
108 * ------------------------------------------------------------------------*/
109static VosContextType gVosContext;
110static pVosContextType gpVosContext;
Sushant Kaushik215778f2015-05-21 14:05:36 +0530111static v_U8_t vos_multicast_logging;
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +0530113struct vos_wdi_trace
114{
115 vos_wdi_trace_event_type event;
116 uint16 message;
117 uint64 time;
118};
119
120static struct vos_wdi_trace gvos_wdi_msg_trace[VOS_TRACE_INDEX_MAX];
121uint16 gvos_wdi_msg_trace_index = 0;
122
Jeff Johnson295189b2012-06-20 16:38:30 -0700123/*---------------------------------------------------------------------------
124 * Forward declaration
125 * ------------------------------------------------------------------------*/
126v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
127
Jeff Johnson295189b2012-06-20 16:38:30 -0700128v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
129
130v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
131 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700132
133
134/*---------------------------------------------------------------------------
135
136 \brief vos_preOpen() - PreOpen the vOSS Module
137
138 The \a vos_preOpen() function allocates the Vos Context, but do not
139 initialize all the members. This overal initialization will happen
140 at vos_Open().
141 The reason why we need vos_preOpen() is to get a minimum context
142 where to store BAL and SAL relative data, which happens before
143 vos_Open() is called.
144
145 \param pVosContext: A pointer to where to store the VOS Context
146
147
148 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
149 is ready to be used.
150
151 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
152
153 \sa vos_Open()
154
155---------------------------------------------------------------------------*/
156VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
157{
158 if ( pVosContext == NULL)
159 return VOS_STATUS_E_FAILURE;
160
161 /* Allocate the VOS Context */
162 *pVosContext = NULL;
163 gpVosContext = &gVosContext;
164
165 if (NULL == gpVosContext)
166 {
167 /* Critical Error ...Cannot proceed further */
168 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
169 "%s: Failed to allocate VOS Context", __func__);
170 VOS_ASSERT(0);
171 return VOS_STATUS_E_RESOURCES;
172 }
173
174 vos_mem_zero(gpVosContext, sizeof(VosContextType));
175
176 *pVosContext = gpVosContext;
177
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700178 /* Initialize the spinlock */
179 vos_trace_spin_lock_init();
180 /* it is the right time to initialize MTRACE structures */
181 #if defined(TRACE_RECORD)
182 vosTraceInit();
183 #endif
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530184 vos_register_debugcb_init();
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700185
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 return VOS_STATUS_SUCCESS;
187
188} /* vos_preOpen()*/
189
190
191/*---------------------------------------------------------------------------
192
193 \brief vos_preClose() - PreClose the vOSS Module
194
195 The \a vos_preClose() function frees the Vos Context.
196
197 \param pVosContext: A pointer to where the VOS Context was stored
198
199
200 \return VOS_STATUS_SUCCESS - Always successful
201
202
203 \sa vos_preClose()
204 \sa vos_close()
205---------------------------------------------------------------------------*/
206VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
207{
208
209 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
210 "%s: De-allocating the VOS Context", __func__);
211
212 if (( pVosContext == NULL) || (*pVosContext == NULL))
213 {
214 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
215 "%s: vOS Context is Null", __func__);
216 return VOS_STATUS_E_FAILURE;
217 }
218
219 if (gpVosContext != *pVosContext)
220 {
221 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
222 "%s: Context mismatch", __func__);
223 return VOS_STATUS_E_FAILURE;
224 }
225
226 *pVosContext = gpVosContext = NULL;
227
228 return VOS_STATUS_SUCCESS;
229
230} /* vos_preClose()*/
231
232/*---------------------------------------------------------------------------
233
234 \brief vos_open() - Open the vOSS Module
235
236 The \a vos_open() function opens the vOSS Scheduler
237 Upon successful initialization:
238
239 - All VOS submodules should have been initialized
240
241 - The VOS scheduler should have opened
242
243 - All the WLAN SW components should have been opened. This includes
244 SYS, MAC, SME, WDA and TL.
245
246
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530247 \param devHandle: pointer to the OS specific device handle
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
249
250 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
251 is ready to be used.
252
253 VOS_STATUS_E_RESOURCES - System resources (other than memory)
254 are unavailable to initilize the scheduler
255
256
257 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
258
259 \sa vos_preOpen()
260
261---------------------------------------------------------------------------*/
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530262VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, void *devHandle )
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
264{
265 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
266 int iter = 0;
267 tSirRetStatus sirStatus = eSIR_SUCCESS;
268 tMacOpenParameters macOpenParms;
269 WLANTL_ConfigInfoType TLConfig;
270
271 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
272 "%s: Opening VOSS", __func__);
273
274 if (NULL == gpVosContext)
275 {
276 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
277 "%s: Trying to open VOSS without a PreOpen", __func__);
278 VOS_ASSERT(0);
279 return VOS_STATUS_E_FAILURE;
280 }
281
282 /* Initialize the timer module */
283 vos_timer_module_init();
284
285 /* Initialize the probe event */
286 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
287 {
288 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
289 "%s: Unable to init probeEvent", __func__);
290 VOS_ASSERT(0);
291 return VOS_STATUS_E_FAILURE;
292 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
294 {
295 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
296 "%s: Unable to init wdaCompleteEvent", __func__);
297 VOS_ASSERT(0);
298
299 goto err_probe_event;
300 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530301 if (vos_event_init( &(gpVosContext->fwLogsComplete) ) != VOS_STATUS_SUCCESS )
302 {
303 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
304 "%s: Unable to init fwLogsComplete", __func__);
305 VOS_ASSERT(0);
306
307 goto err_wda_complete_event;
308 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700309
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 /* Initialize the free message queue */
311 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
312 if (! VOS_IS_STATUS_SUCCESS(vStatus))
313 {
314
315 /* Critical Error ... Cannot proceed further */
316 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
317 "%s: Failed to initialize VOS free message queue", __func__);
318 VOS_ASSERT(0);
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530319 goto err_fw_logs_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 }
321
322 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
323 {
324 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
325 &(gpVosContext->aMsgBuffers[iter]);
326 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
327 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
328 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700329
330 /* Now Open the VOS Scheduler */
331 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
332 sizeof(VosSchedContext));
333
334 if (!VOS_IS_STATUS_SUCCESS(vStatus))
335 {
336 /* Critical Error ... Cannot proceed further */
337 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
338 "%s: Failed to open VOS Scheduler", __func__);
339 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 }
342
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 /*
344 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
345 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
346 */
347
348 /*Open the WDA module */
349 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
350 /* UMA is supported in hardware for performing the
351 ** frame translation 802.11 <-> 802.3
352 */
353 macOpenParms.frameTransRequired = 1;
354 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530355 vStatus = WDA_open( gpVosContext, devHandle, &macOpenParms );
Jeff Johnson295189b2012-06-20 16:38:30 -0700356
357 if (!VOS_IS_STATUS_SUCCESS(vStatus))
358 {
359 /* Critical Error ... Cannot proceed further */
360 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
361 "%s: Failed to open WDA module", __func__);
362 VOS_ASSERT(0);
363 goto err_sched_close;
364 }
365
366 /* Initialize here the VOS Packet sub module */
367 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
368 sizeof( vos_pkt_context_t ) );
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 VOS Packet Module", __func__);
375 VOS_ASSERT(0);
376 goto err_wda_close;
377 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
379 /* Open the SYS module */
380 vStatus = sysOpen(gpVosContext);
381
382 if (!VOS_IS_STATUS_SUCCESS(vStatus))
383 {
384 /* Critical Error ... Cannot proceed further */
385 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
386 "%s: Failed to open SYS module", __func__);
387 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 }
390
Amar Singhal0a402232013-10-11 20:57:16 -0700391#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 /* initialize the NV module */
393 vStatus = vos_nv_open();
394 if (!VOS_IS_STATUS_SUCCESS(vStatus))
395 {
396 // NV module cannot be initialized
397 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
398 "%s: Failed to initialize the NV module", __func__);
399 goto err_sys_close;
400 }
Amar Singhal0a402232013-10-11 20:57:16 -0700401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700402
403 /* If we arrive here, both threads dispacthing messages correctly */
404
405 /* Now proceed to open the MAC */
406
407 /* UMA is supported in hardware for performing the
408 frame translation 802.11 <-> 802.3 */
409 macOpenParms.frameTransRequired = 1;
410 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
411 &macOpenParms);
412
413 if (eSIR_SUCCESS != sirStatus)
414 {
415 /* Critical Error ... Cannot proceed further */
416 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
417 "%s: Failed to open MAC", __func__);
418 VOS_ASSERT(0);
419 goto err_nv_close;
420 }
421
422 /* Now proceed to open the SME */
423 vStatus = sme_Open(gpVosContext->pMACContext);
424 if (!VOS_IS_STATUS_SUCCESS(vStatus))
425 {
426 /* Critical Error ... Cannot proceed further */
427 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
428 "%s: Failed to open SME", __func__);
429 VOS_ASSERT(0);
430 goto err_mac_close;
431 }
432
433 /* Now proceed to open TL. Read TL config first */
434 vos_fetch_tl_cfg_parms ( &TLConfig,
435 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
436
437 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
438 if (!VOS_IS_STATUS_SUCCESS(vStatus))
439 {
440 /* Critical Error ... Cannot proceed further */
441 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
442 "%s: Failed to open TL", __func__);
443 VOS_ASSERT(0);
444 goto err_sme_close;
445 }
446
Girish Gowlifb0bfd32015-01-13 11:42:11 +0530447 if (gpVosContext->roamDelayStatsEnabled &&
448 !vos_roam_delay_stats_init())
449 {
450 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
451 "%s: Could not init roamDelayStats", __func__);
452 }
453
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
455 "%s: VOSS successfully Opened", __func__);
456
Abhishek Singh8a3e4dc2017-01-02 10:39:18 +0530457 gpVosContext->snoc_high_freq_voting = false;
458 spin_lock_init(&gpVosContext->freq_voting_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 *pVosContext = gpVosContext;
460
461 return VOS_STATUS_SUCCESS;
462
463
464err_sme_close:
465 sme_Close(gpVosContext->pMACContext);
466
467err_mac_close:
468 macClose(gpVosContext->pMACContext);
469
470err_nv_close:
Amar Singhal0a402232013-10-11 20:57:16 -0700471
472#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 vos_nv_close();
Amar Singhal0a402232013-10-11 20:57:16 -0700474
475err_sys_close:
476#endif
477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 sysClose(gpVosContext);
479
Jeff Johnson295189b2012-06-20 16:38:30 -0700480err_packet_close:
481 vos_packet_close( gpVosContext );
482
483err_wda_close:
484 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700485
Amar Singhal0a402232013-10-11 20:57:16 -0700486err_sched_close:
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 vos_sched_close(gpVosContext);
488
Jeff Johnson295189b2012-06-20 16:38:30 -0700489
490err_msg_queue:
491 vos_mq_deinit(&gpVosContext->freeVosMq);
492
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530493err_fw_logs_complete_event:
494 vos_event_destroy( &gpVosContext->fwLogsComplete);
495
Jeff Johnson295189b2012-06-20 16:38:30 -0700496err_wda_complete_event:
497 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
499err_probe_event:
500 vos_event_destroy(&gpVosContext->ProbeEvent);
501
502 return VOS_STATUS_E_FAILURE;
503
504} /* vos_open() */
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506/*---------------------------------------------------------------------------
507
508 \brief vos_preStart() -
509
510 The \a vos_preStart() function to download CFG.
511 including:
512 - ccmStart
513
514 - WDA: triggers the CFG download
515
516
517 \param pVosContext: The VOS context
518
519
520 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
521 is ready to be used.
522
523 VOS_STATUS_E_RESOURCES - System resources (other than memory)
524 are unavailable to initilize the scheduler
525
526
527 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
528
529 \sa vos_start
530
531---------------------------------------------------------------------------*/
532VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
533{
534 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
535 pVosContextType pVosContext = (pVosContextType)vosContext;
536
537 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
538 "vos prestart");
539
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800540 if (gpVosContext != pVosContext)
541 {
542 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
543 "%s: Context mismatch", __func__);
544 VOS_ASSERT(0);
545 return VOS_STATUS_E_INVAL;
546 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800548 if (pVosContext->pMACContext == NULL)
549 {
550 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
551 "%s: MAC NULL context", __func__);
552 VOS_ASSERT(0);
553 return VOS_STATUS_E_INVAL;
554 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800556 if (pVosContext->pWDAContext == NULL)
557 {
558 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
559 "%s: WDA NULL context", __func__);
560 VOS_ASSERT(0);
561 return VOS_STATUS_E_INVAL;
562 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700563
564 /* call macPreStart */
565 vStatus = macPreStart(gpVosContext->pMACContext);
566 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
567 {
568 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
569 "Failed at macPreStart ");
570 return VOS_STATUS_E_FAILURE;
571 }
572
573 /* call ccmStart */
574 ccmStart(gpVosContext->pMACContext);
575
576 /* Reset wda wait event */
577 vos_event_reset(&gpVosContext->wdaCompleteEvent);
578
579
580 /*call WDA pre start*/
581 vStatus = WDA_preStart(gpVosContext);
582 if (!VOS_IS_STATUS_SUCCESS(vStatus))
583 {
584 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
585 "Failed to WDA prestart");
586 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
587 ccmStop(gpVosContext->pMACContext);
588 VOS_ASSERT(0);
589 return VOS_STATUS_E_FAILURE;
590 }
591
592 /* Need to update time out of complete */
593 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
594 VOS_WDA_TIMEOUT );
595 if ( vStatus != VOS_STATUS_SUCCESS )
596 {
597 if ( vStatus == VOS_STATUS_E_TIMEOUT )
598 {
599 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800600 "%s: Timeout occurred before WDA complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 }
602 else
603 {
604 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
605 "%s: WDA_preStart reporting other error", __func__);
606 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700607 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
608 "%s: Test MC thread by posting a probe message to SYS", __func__);
609 wlan_sys_probe();
610
Jeff Johnsone7245742012-09-05 17:12:55 -0700611 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
612 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 VOS_ASSERT( 0 );
614 return VOS_STATUS_E_FAILURE;
615 }
616
617 return VOS_STATUS_SUCCESS;
618}
Jeff Johnson295189b2012-06-20 16:38:30 -0700619
Katya Nigame7b69a82015-04-28 15:24:06 +0530620VOS_STATUS vos_mon_start( v_CONTEXT_t vosContext )
621{
622 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
623 pVosContextType pVosContext = (pVosContextType)vosContext;
624
625 if (pVosContext == NULL)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: mismatch in context",__func__);
629 return VOS_STATUS_E_FAILURE;
630 }
631
632 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pTLContext == NULL))
633 {
634 if (pVosContext->pWDAContext == NULL)
635 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
636 "%s: WDA NULL context", __func__);
637 else
638 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
639 "%s: TL NULL context", __func__);
640
641 return VOS_STATUS_E_FAILURE;
642 }
643
644 /* Reset wda wait event */
645 vos_event_reset(&pVosContext->wdaCompleteEvent);
646
647 /*call WDA pre start*/
648 vStatus = WDA_preStart(pVosContext);
649 if (!VOS_IS_STATUS_SUCCESS(vStatus))
650 {
651 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
652 "Failed to WDA prestart ");
653 VOS_ASSERT(0);
654 return VOS_STATUS_E_FAILURE;
655 }
656
657 /* Need to update time out of complete */
658 vStatus = vos_wait_single_event( &pVosContext->wdaCompleteEvent, 1000);
659 if ( vStatus != VOS_STATUS_SUCCESS )
660 {
661 if ( vStatus == VOS_STATUS_E_TIMEOUT )
662 {
663 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
664 "%s: Timeout occurred before WDA complete",__func__);
665 }
666 else
667 {
668 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
669 "%s: WDA_preStart reporting other error",__func__);
670 }
671 VOS_ASSERT( 0 );
672 return VOS_STATUS_E_FAILURE;
673 }
674
675 vStatus = WDA_NVDownload_Start(pVosContext);
676
677 if ( vStatus != VOS_STATUS_SUCCESS )
678 {
679 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
680 "%s: Failed to start NV Download",__func__);
681 return VOS_STATUS_E_FAILURE;
682 }
683
684 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000 * 30);
685
686 if ( vStatus != VOS_STATUS_SUCCESS )
687 {
688 if ( vStatus == VOS_STATUS_E_TIMEOUT )
689 {
690 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
691 "%s: Timeout occurred before WDA_NVDownload_Start complete",__func__);
692 }
693 else
694 {
695 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
696 "%s: WDA_NVDownload_Start reporting other error",__func__);
697 }
698 VOS_ASSERT(0);
699 return VOS_STATUS_E_FAILURE;
700 }
701
702 vStatus = WDA_start(pVosContext);
703 if (vStatus != VOS_STATUS_SUCCESS)
704 {
705 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
706 "%s: Failed to start WDA",__func__);
707 return VOS_STATUS_E_FAILURE;
708 }
709
710 /** START TL */
711 vStatus = WLANTL_Start(pVosContext);
712 if (!VOS_IS_STATUS_SUCCESS(vStatus))
713 {
714 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
715 "%s: Failed to start TL", __func__);
716 goto err_wda_stop;
717 }
718
719 return VOS_STATUS_SUCCESS;
720
721err_wda_stop:
722 vos_event_reset(&(pVosContext->wdaCompleteEvent));
723 WDA_stop(pVosContext, HAL_STOP_TYPE_RF_KILL);
724 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000);
725 if(vStatus != VOS_STATUS_SUCCESS)
726 {
727 if(vStatus == VOS_STATUS_E_TIMEOUT)
728 {
729 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
730 "%s: Timeout occurred before WDA_stop complete",__func__);
731
732 }
733 else
734 {
735 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
736 "%s: WDA_stop reporting other error",__func__);
737 }
738 VOS_ASSERT(0);
739 }
740 return VOS_STATUS_E_FAILURE;
741}
742
743VOS_STATUS vos_mon_stop( v_CONTEXT_t vosContext )
744{
745 VOS_STATUS vosStatus;
746
747 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
748
Bhargav Shah1ae5de02015-07-20 13:32:31 +0530749 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
750 "%s: HAL_STOP is requested", __func__);
751
Katya Nigame7b69a82015-04-28 15:24:06 +0530752 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
753
754 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
755 {
756 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
757 "%s: Failed to stop WDA", __func__);
758 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
759 WDA_setNeedShutdown(vosContext);
760 }
761 else
762 {
763 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
764 VOS_WDA_STOP_TIMEOUT );
765
766 if ( vosStatus != VOS_STATUS_SUCCESS )
767 {
768 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
769 {
770 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
771 "%s: Timeout occurred before WDA complete", __func__);
772 }
773 else
774 {
775 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
776 "%s: WDA_stop reporting other error", __func__ );
777 }
778 WDA_setNeedShutdown(vosContext);
779 }
780 }
781
782 vosStatus = WLANTL_Stop( vosContext );
783 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
784 {
785 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
786 "%s: Failed to stop TL", __func__);
787 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
788 }
789
790 return VOS_STATUS_SUCCESS;
791}
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793/*---------------------------------------------------------------------------
794
795 \brief vos_start() - Start the Libra SW Modules
796
797 The \a vos_start() function starts all the components of the Libra SW
798 including:
799 - SAL/BAL, which in turn starts SSC
800
801 - the MAC (HAL and PE)
802
803 - SME
804
805 - TL
806
807 - SYS: triggers the CFG download
808
809
810 \param pVosContext: The VOS context
811
812
813 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
814 is ready to be used.
815
816 VOS_STATUS_E_RESOURCES - System resources (other than memory)
817 are unavailable to initilize the scheduler
818
819
820 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
821
822 \sa vos_preStart()
823 \sa vos_open()
824
825---------------------------------------------------------------------------*/
826VOS_STATUS vos_start( v_CONTEXT_t vosContext )
827{
828 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
829 tSirRetStatus sirStatus = eSIR_SUCCESS;
830 pVosContextType pVosContext = (pVosContextType)vosContext;
831 tHalMacStartParameters halStartParams;
Srinivas Dasaric14dac82016-03-01 19:24:55 +0530832 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700833
834 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
835 "%s: Starting Libra SW", __func__);
836
837 /* We support only one instance for now ...*/
838 if (gpVosContext != pVosContext)
839 {
840 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700841 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 return VOS_STATUS_E_FAILURE;
843 }
844
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
846 || ( pVosContext->pTLContext == NULL))
847 {
848 if (pVosContext->pWDAContext == NULL)
849 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700850 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 else if (pVosContext->pMACContext == NULL)
852 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700853 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 else
855 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700856 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700857
858 return VOS_STATUS_E_FAILURE;
859 }
860
861 /* WDA_Start will be called after NV image download because the
862 NV image data has to be updated at HAL before HAL_Start gets executed*/
863
864 /* Start the NV Image Download */
865
866 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
867
868 vStatus = WDA_NVDownload_Start(pVosContext);
869
870 if ( vStatus != VOS_STATUS_SUCCESS )
871 {
872 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
873 "%s: Failed to start NV Download", __func__);
874 return VOS_STATUS_E_FAILURE;
875 }
876
877 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
878 VOS_WDA_TIMEOUT );
879
880 if ( vStatus != VOS_STATUS_SUCCESS )
881 {
882 if ( vStatus == VOS_STATUS_E_TIMEOUT )
883 {
884 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
885 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
886 }
887 else
888 {
889 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
890 "%s: WDA_NVDownload_start reporting other error", __func__);
891 }
892 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800893 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700894 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
895 {
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530896 if (isSsrPanicOnFailure())
897 VOS_BUG(0);
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700898 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800899 WDA_setNeedShutdown(vosContext);
900 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 }
902
903 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
904 "%s: WDA_NVDownload_start correctly started", __func__);
905
906 /* Start the WDA */
907 vStatus = WDA_start(pVosContext);
908 if ( vStatus != VOS_STATUS_SUCCESS )
909 {
910 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530911 "%s: Failed to start WDA - WDA_shutdown needed %d ",
912 __func__, vStatus);
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530913 if ( vStatus == VOS_STATUS_E_TIMEOUT )
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530914 {
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530915 WDA_setNeedShutdown(vosContext);
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +0530916 vos_smd_dump_stats();
917 vos_dump_wdi_events();
918 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
919 "%s: Test MC thread by posting a probe message to SYS",
920 __func__);
921 wlan_sys_probe();
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530922 }
923 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 return VOS_STATUS_E_FAILURE;
925 }
926 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
927 "%s: WDA correctly started", __func__);
928
Srinivas Dasaric14dac82016-03-01 19:24:55 +0530929 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
930 if (!pHddCtx)
931 {
932 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
933 "%s: HDD context is null", __func__);
934 goto err_wda_stop;
935 }
936
937 pHddCtx->wifi_turn_on_time_since_boot = vos_get_monotonic_boottime();
938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 /* Start the MAC */
940 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 /* Start the MAC */
943 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
944
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 if (eSIR_SUCCESS != sirStatus)
946 {
947 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
948 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700950 }
951
952 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
953 "%s: MAC correctly started", __func__);
954
955 /* START SME */
956 vStatus = sme_Start(pVosContext->pMACContext);
957
958 if (!VOS_IS_STATUS_SUCCESS(vStatus))
959 {
960 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
961 "%s: Failed to start SME", __func__);
962 goto err_mac_stop;
963 }
964
965 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
966 "%s: SME correctly started", __func__);
967
968 /** START TL */
969 vStatus = WLANTL_Start(pVosContext);
970 if (!VOS_IS_STATUS_SUCCESS(vStatus))
971 {
972 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
973 "%s: Failed to start TL", __func__);
974 goto err_sme_stop;
975 }
976
977 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
978 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
980 "%s: VOSS Start is successful!!", __func__);
981
982 return VOS_STATUS_SUCCESS;
983
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985err_sme_stop:
Kiet Lama72a2322013-11-15 11:18:11 +0530986 sme_Stop(pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700987
988err_mac_stop:
989 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
990
Jeff Johnson295189b2012-06-20 16:38:30 -0700991err_wda_stop:
992 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800993 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
994 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800996 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
997 "%s: Failed to stop WDA", __func__);
998 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -0800999 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001000 }
1001 else
1002 {
1003 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
1004 VOS_WDA_TIMEOUT );
1005 if( vStatus != VOS_STATUS_SUCCESS )
1006 {
1007 if( vStatus == VOS_STATUS_E_TIMEOUT )
1008 {
1009 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1010 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001011
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001012 }
1013 else
1014 {
1015 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1016 "%s: WDA_stop reporting other error", __func__);
1017 }
1018 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001019 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001022
1023 return VOS_STATUS_E_FAILURE;
1024
1025} /* vos_start() */
1026
1027
1028/* vos_stop function */
1029VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
1030{
1031 VOS_STATUS vosStatus;
1032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 /* WDA_Stop is called before the SYS so that the processing of Riva
1034 pending responces will not be handled during uninitialization of WLAN driver */
1035 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
1036
1037 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
1038
1039 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1040 {
1041 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1042 "%s: Failed to stop WDA", __func__);
1043 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001044 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -07001046 else
1047 {
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301048 if(wcnss_device_is_shutdown())
1049 {
1050 vosStatus = VOS_STATUS_E_TIMEOUT;
1051 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1052 "%s: Wait for WDA_Stop complete event not needed due to SSR",
1053 __func__);
1054 }
1055 else
1056 {
1057 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001058 VOS_WDA_STOP_TIMEOUT );
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001060
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001061 if ( vosStatus != VOS_STATUS_SUCCESS )
1062 {
1063 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1064 {
1065 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1066 "%s: Timeout occurred before WDA complete", __func__);
1067 }
1068 else
1069 {
1070 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1071 "%s: WDA_stop reporting other error", __func__ );
1072 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -07001073 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1074 "%s: Test MC thread by posting a probe message to SYS", __func__);
1075 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001076 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001079
1080 /* SYS STOP will stop SME and MAC */
1081 vosStatus = sysStop( vosContext);
1082 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1083 {
1084 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1085 "%s: Failed to stop SYS", __func__);
1086 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1087 }
1088
1089 vosStatus = WLANTL_Stop( vosContext );
1090 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1091 {
1092 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1093 "%s: Failed to stop TL", __func__);
1094 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1095 }
1096
Jeff Johnson295189b2012-06-20 16:38:30 -07001097
1098 return VOS_STATUS_SUCCESS;
1099}
1100
1101
1102/* vos_close function */
1103VOS_STATUS vos_close( v_CONTEXT_t vosContext )
1104{
1105 VOS_STATUS vosStatus;
1106
1107#ifdef WLAN_BTAMP_FEATURE
1108 vosStatus = WLANBAP_Close(vosContext);
1109 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1110 {
1111 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1112 "%s: Failed to close BAP", __func__);
1113 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1114 }
1115#endif // WLAN_BTAMP_FEATURE
1116
1117
1118 vosStatus = WLANTL_Close(vosContext);
1119 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1120 {
1121 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1122 "%s: Failed to close TL", __func__);
1123 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1124 }
1125
1126 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1127 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1128 {
1129 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1130 "%s: Failed to close SME", __func__);
1131 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1132 }
1133
1134 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1135 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1136 {
1137 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1138 "%s: Failed to close MAC", __func__);
1139 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1140 }
1141
1142 ((pVosContextType)vosContext)->pMACContext = NULL;
1143
Amar Singhal0a402232013-10-11 20:57:16 -07001144#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 vosStatus = vos_nv_close();
1146 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1147 {
1148 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1149 "%s: Failed to close NV", __func__);
1150 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1151 }
Amar Singhal0a402232013-10-11 20:57:16 -07001152#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001153
1154 vosStatus = sysClose( vosContext );
1155 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1156 {
1157 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1158 "%s: Failed to close SYS", __func__);
1159 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1160 }
1161
Jeff Johnsone7245742012-09-05 17:12:55 -07001162 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001164 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
1165 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
1166 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
1167 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07001168 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -07001169 }
1170 else
1171 {
1172 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1173 "%s: Failed to shutdown WDA", __func__ );
1174 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1175 }
1176 }
1177 else
1178 {
1179 vosStatus = WDA_close( vosContext );
1180 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1181 {
1182 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1183 "%s: Failed to close WDA", __func__);
1184 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 }
1187
1188 /* Let DXE return packets in WDA_close and then free them here */
1189 vosStatus = vos_packet_close( vosContext );
1190 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1191 {
1192 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1193 "%s: Failed to close VOSS Packet", __func__);
1194 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001196
Jeff Johnson295189b2012-06-20 16:38:30 -07001197
1198 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1199
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301200 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
1201 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1202 {
1203 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1204 "%s: failed to destroy fwLogsComplete", __func__);
1205 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1206 }
1207
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1209 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1210 {
1211 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1212 "%s: failed to destroy wdaCompleteEvent", __func__);
1213 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001215
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301216
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1218 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1219 {
1220 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1221 "%s: failed to destroy ProbeEvent", __func__);
1222 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1223 }
1224
Girish Gowlifb0bfd32015-01-13 11:42:11 +05301225 if (gpVosContext->roamDelayStatsEnabled &&
1226 !vos_roam_delay_stats_deinit())
1227 {
1228 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1229 "%s: Could not deinit roamDelayStats", __func__);
1230 }
1231
Mahesh A Saptasagara67b86d2016-04-26 21:20:41 +05301232 vos_wdthread_flush_timer_work();
1233
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 return VOS_STATUS_SUCCESS;
1235}
1236
1237
1238/**---------------------------------------------------------------------------
1239
1240 \brief vos_get_context() - get context data area
1241
1242 Each module in the system has a context / data area that is allocated
1243 and maanged by voss. This API allows any user to get a pointer to its
1244 allocated context data area from the VOSS global context.
1245
1246 \param vosContext - the VOSS Global Context.
1247
1248 \param moduleId - the module ID, who's context data are is being retrived.
1249
1250 \return - pointer to the context data area.
1251
1252 - NULL if the context data is not allocated for the module ID
1253 specified
1254
1255 --------------------------------------------------------------------------*/
1256v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1257 v_CONTEXT_t pVosContext )
1258{
1259 v_PVOID_t pModContext = NULL;
1260
1261 if (pVosContext == NULL)
1262 {
1263 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001264 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 return NULL;
1266 }
1267
1268 if (gpVosContext != pVosContext)
1269 {
1270 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001271 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 return NULL;
1273 }
1274
1275 switch(moduleId)
1276 {
1277 case VOS_MODULE_ID_TL:
1278 {
1279 pModContext = gpVosContext->pTLContext;
1280 break;
1281 }
1282
Jeff Johnson295189b2012-06-20 16:38:30 -07001283#ifdef WLAN_BTAMP_FEATURE
1284 case VOS_MODULE_ID_BAP:
1285 {
1286 pModContext = gpVosContext->pBAPContext;
1287 break;
1288 }
1289#endif //WLAN_BTAMP_FEATURE
1290
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 case VOS_MODULE_ID_SAP:
1292 {
1293 pModContext = gpVosContext->pSAPContext;
1294 break;
1295 }
1296
1297 case VOS_MODULE_ID_HDD_SOFTAP:
1298 {
1299 pModContext = gpVosContext->pHDDSoftAPContext;
1300 break;
1301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001302
1303 case VOS_MODULE_ID_HDD:
1304 {
1305 pModContext = gpVosContext->pHDDContext;
1306 break;
1307 }
1308
1309 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301311 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 {
1313 /*
1314 ** In all these cases, we just return the MAC Context
1315 */
1316 pModContext = gpVosContext->pMACContext;
1317 break;
1318 }
1319
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 case VOS_MODULE_ID_WDA:
1321 {
1322 /* For WDA module */
1323 pModContext = gpVosContext->pWDAContext;
1324 break;
1325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001326
1327 case VOS_MODULE_ID_VOSS:
1328 {
1329 /* For SYS this is VOS itself*/
1330 pModContext = gpVosContext;
1331 break;
1332 }
1333
1334 default:
1335 {
1336 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1337 "does not have its context maintained by VOSS", __func__, moduleId);
1338 VOS_ASSERT(0);
1339 return NULL;
1340 }
1341 }
1342
1343 if (pModContext == NULL )
1344 {
1345 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1346 "context is Null", __func__, moduleId);
1347 }
1348
1349 return pModContext;
1350
1351} /* vos_get_context()*/
1352
1353
1354/**---------------------------------------------------------------------------
1355
1356 \brief vos_get_global_context() - get VOSS global Context
1357
1358 This API allows any user to get the VOS Global Context pointer from a
1359 module context data area.
1360
1361 \param moduleContext - the input module context pointer
1362
1363 \param moduleId - the module ID who's context pointer is input in
1364 moduleContext.
1365
1366 \return - pointer to the VOSS global context
1367
1368 - NULL if the function is unable to retreive the VOSS context.
1369
1370 --------------------------------------------------------------------------*/
1371v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1372 v_VOID_t *moduleContext )
1373{
1374 if (gpVosContext == NULL)
1375 {
1376 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001377 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 }
1379
1380 return gpVosContext;
1381
1382} /* vos_get_global_context() */
1383
1384
1385v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1386{
1387 if (gpVosContext == NULL)
1388 {
1389 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001390 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 return 1;
1392 }
1393
1394 return gpVosContext->isLogpInProgress;
1395}
1396
1397void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1398{
1399 if (gpVosContext == NULL)
1400 {
1401 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001402 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 return;
1404 }
1405
1406 gpVosContext->isLogpInProgress = value;
1407}
1408
1409v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1410{
1411 if (gpVosContext == NULL)
1412 {
1413 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001414 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 return 0;
1416 }
1417
1418 return gpVosContext->isLoadUnloadInProgress;
1419}
1420
1421void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1422{
1423 if (gpVosContext == NULL)
1424 {
1425 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001426 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 return;
1428 }
1429
1430 gpVosContext->isLoadUnloadInProgress = value;
1431}
1432
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001433v_U8_t vos_is_reinit_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1434{
1435 if (gpVosContext == NULL)
1436 {
1437 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1438 "%s: global voss context is NULL", __func__);
1439 return 1;
1440 }
1441
1442 return gpVosContext->isReInitInProgress;
1443}
1444
1445void vos_set_reinit_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1446{
1447 if (gpVosContext == NULL)
1448 {
1449 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1450 "%s: global voss context is NULL", __func__);
1451 return;
1452 }
1453
1454 gpVosContext->isReInitInProgress = value;
1455}
1456
1457
Jeff Johnson295189b2012-06-20 16:38:30 -07001458/**---------------------------------------------------------------------------
1459
1460 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1461
1462 This API allows any user to allocate a user context area within the
1463 VOS Global Context.
1464
1465 \param pVosContext - pointer to the global Vos context
1466
1467 \param moduleId - the module ID who's context area is being allocated.
1468
1469 \param ppModuleContext - pointer to location where the pointer to the
1470 allocated context is returned. Note this
1471 output pointer is valid only if the API
1472 returns VOS_STATUS_SUCCESS
1473
1474 \param size - the size of the context area to be allocated.
1475
1476 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1477 allocated successfully. The pointer to the context area
1478 can be found in *ppModuleContext.
1479 \note This function returns VOS_STATUS_SUCCESS if the
1480 module context was already allocated and the size
1481 allocated matches the size on this call.
1482
1483 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1484 not identify a module that can have a context allocated.
1485
1486 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1487 because a context for this module ID already exists and it is
1488 a *different* size that specified on this call.
1489
1490 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1491 requested context area.
1492
1493 \sa vos_get_context(), vos_free_context()
1494
1495 --------------------------------------------------------------------------*/
1496VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1497 v_VOID_t **ppModuleContext, v_SIZE_t size )
1498{
1499 v_VOID_t ** pGpModContext = NULL;
1500
1501 if ( pVosContext == NULL) {
1502 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001503 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 return VOS_STATUS_E_FAILURE;
1505 }
1506
1507 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1508 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001509 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 return VOS_STATUS_E_FAILURE;
1511 }
1512
1513 switch(moduleID)
1514 {
1515 case VOS_MODULE_ID_TL:
1516 {
1517 pGpModContext = &(gpVosContext->pTLContext);
1518 break;
1519 }
1520
Jeff Johnson295189b2012-06-20 16:38:30 -07001521#ifdef WLAN_BTAMP_FEATURE
1522 case VOS_MODULE_ID_BAP:
1523 {
1524 pGpModContext = &(gpVosContext->pBAPContext);
1525 break;
1526 }
1527#endif //WLAN_BTAMP_FEATURE
1528
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 case VOS_MODULE_ID_SAP:
1530 {
1531 pGpModContext = &(gpVosContext->pSAPContext);
1532 break;
1533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001534
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 case VOS_MODULE_ID_WDA:
1536 {
1537 pGpModContext = &(gpVosContext->pWDAContext);
1538 break;
1539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301542 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 default:
1546 {
1547 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1548 "does not have its context allocated by VOSS", __func__, moduleID);
1549 VOS_ASSERT(0);
1550 return VOS_STATUS_E_INVAL;
1551 }
1552 }
1553
1554 if ( NULL != *pGpModContext)
1555 {
1556 /*
1557 ** Context has already been allocated!
1558 ** Prevent double allocation
1559 */
1560 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1561 "%s: Module ID %i context has already been allocated",
1562 __func__, moduleID);
1563 return VOS_STATUS_E_EXISTS;
1564 }
1565
1566 /*
1567 ** Dynamically allocate the context for module
1568 */
1569
1570 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1571
1572
1573 if ( *ppModuleContext == NULL)
1574 {
1575 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1576 "allocate Context for module ID %i", __func__, moduleID);
1577 VOS_ASSERT(0);
1578 return VOS_STATUS_E_NOMEM;
1579 }
1580
1581 if (moduleID==VOS_MODULE_ID_TL)
1582 {
1583 vos_mem_zero(*ppModuleContext, size);
1584 }
1585
1586 *pGpModContext = *ppModuleContext;
1587
1588 return VOS_STATUS_SUCCESS;
1589
1590} /* vos_alloc_context() */
1591
1592
1593/**---------------------------------------------------------------------------
1594
1595 \brief vos_free_context() - free an allocated a context within the
1596 VOSS global Context
1597
1598 This API allows a user to free the user context area within the
1599 VOS Global Context.
1600
1601 \param pVosContext - pointer to the global Vos context
1602
1603 \param moduleId - the module ID who's context area is being free
1604
1605 \param pModuleContext - pointer to module context area to be free'd.
1606
1607 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1608 free'd. The pointer to the context area is not longer
1609 available.
1610
1611 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1612 valid pointers.
1613
1614 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1615 not identify a module that can have a context free'd.
1616
1617 VOS_STATUS_E_EXISTS - vos could not free the requested
1618 context area because a context for this module ID does not
1619 exist in the global vos context.
1620
1621 \sa vos_get_context()
1622
1623 --------------------------------------------------------------------------*/
1624VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1625 v_VOID_t *pModuleContext )
1626{
1627 v_VOID_t ** pGpModContext = NULL;
1628
1629 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1630 ( pModuleContext == NULL))
1631 {
1632 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1633 "%s: Null params or context mismatch", __func__);
1634 return VOS_STATUS_E_FAILURE;
1635 }
1636
1637
1638 switch(moduleID)
1639 {
1640 case VOS_MODULE_ID_TL:
1641 {
1642 pGpModContext = &(gpVosContext->pTLContext);
1643 break;
1644 }
1645
Jeff Johnson295189b2012-06-20 16:38:30 -07001646#ifdef WLAN_BTAMP_FEATURE
1647 case VOS_MODULE_ID_BAP:
1648 {
1649 pGpModContext = &(gpVosContext->pBAPContext);
1650 break;
1651 }
1652#endif //WLAN_BTAMP_FEATURE
1653
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 case VOS_MODULE_ID_SAP:
1655 {
1656 pGpModContext = &(gpVosContext->pSAPContext);
1657 break;
1658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001659
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 case VOS_MODULE_ID_WDA:
1661 {
1662 pGpModContext = &(gpVosContext->pWDAContext);
1663 break;
1664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 case VOS_MODULE_ID_HDD:
1666 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301668 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 default:
1671 {
1672 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1673 "does not have its context allocated by VOSS", __func__, moduleID);
1674 VOS_ASSERT(0);
1675 return VOS_STATUS_E_INVAL;
1676 }
1677 }
1678
1679 if ( NULL == *pGpModContext)
1680 {
1681 /*
1682 ** Context has not been allocated or freed already!
1683 */
1684 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1685 "context has not been allocated or freed already", __func__,moduleID);
1686 return VOS_STATUS_E_FAILURE;
1687 }
1688
1689 if (*pGpModContext != pModuleContext)
1690 {
1691 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001692 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 return VOS_STATUS_E_FAILURE;
1694 }
1695
1696 if(pModuleContext != NULL)
1697 kfree(pModuleContext);
1698
1699 *pGpModContext = NULL;
1700
1701 return VOS_STATUS_SUCCESS;
1702
1703} /* vos_free_context() */
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301704
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301705
1706bool vos_is_log_report_in_progress(void)
1707{
1708 return wlan_is_log_report_in_progress();
1709}
1710
1711void vos_reset_log_report_in_progress(void)
1712{
1713 return wlan_reset_log_report_in_progress();
1714}
1715
1716
1717
1718
1719int vos_set_log_completion(uint32 is_fatal,
1720 uint32 indicator,
1721 uint32 reason_code)
1722{
1723 return wlan_set_log_completion(is_fatal,
1724 indicator,reason_code);
1725}
1726
Abhishek Singh837adf22015-10-01 17:37:37 +05301727void vos_get_log_and_reset_completion(uint32 *is_fatal,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301728 uint32 *indicator,
Abhishek Singh837adf22015-10-01 17:37:37 +05301729 uint32 *reason_code,
1730 bool reset)
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301731{
Abhishek Singh837adf22015-10-01 17:37:37 +05301732 wlan_get_log_and_reset_completion(is_fatal, indicator, reason_code, reset);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301733}
1734
1735
1736
1737void vos_send_fatal_event_done(void)
1738{
1739 /*Complete the fwLogsComplete Event*/
1740 VosContextType *vos_context;
1741 uint32_t is_fatal, indicator, reason_code;
1742
1743 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1744 if (!vos_context) {
1745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1746 "%s: vos context is Invalid", __func__);
1747 return;
1748 }
1749 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1750 "%s: vos_event_set for fwLogsComplete", __func__);
1751 if (vos_event_set(&vos_context->fwLogsComplete)!= VOS_STATUS_SUCCESS)
1752 {
1753 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1754 "%s: vos_event_set failed for fwLogsComplete", __func__);
1755 return;
1756 }
1757 /*The below API will reset is_report_in_progress flag*/
Abhishek Singh837adf22015-10-01 17:37:37 +05301758 vos_get_log_and_reset_completion(&is_fatal, &indicator,
1759 &reason_code, true);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301760 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05301761 "is_fatal : %d, indicator: %d, reason_code=%d",
1762 is_fatal, indicator, reason_code);
1763 wlan_report_log_completion(is_fatal, indicator, reason_code);
1764
Abhishek Singh84fc7512015-10-06 14:27:25 +05301765 /* Do ssr after reporting fatal event to recover from
1766 * below conditions
1767 */
Abhishek Singh183e3682015-11-16 16:54:35 +05301768 if ((WLAN_LOG_INDICATOR_HOST_DRIVER == indicator) &&
1769 (WLAN_LOG_REASON_SME_COMMAND_STUCK == reason_code ||
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +05301770 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF == reason_code ||
1771 WLAN_LOG_REASON_SCAN_NOT_ALLOWED == reason_code))
Abhishek Singh183e3682015-11-16 16:54:35 +05301772 {
1773 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1774 "Do SSR for reason_code=%d", reason_code);
Abhishek Singh84fc7512015-10-06 14:27:25 +05301775 vos_wlanRestart();
Abhishek Singh183e3682015-11-16 16:54:35 +05301776 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301777}
1778
Abhishek Singh837adf22015-10-01 17:37:37 +05301779/**
1780 * vos_isFatalEventEnabled()
1781 *
1782 * Return TRUE if Fatal event is enabled is in progress.
1783 *
1784 */
1785v_BOOL_t vos_isFatalEventEnabled(void)
1786{
1787 hdd_context_t *pHddCtx = NULL;
1788 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1789
1790 if(!pVosContext)
1791 {
1792 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
1793 return FALSE;
1794 }
1795
1796 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1797 if(!pHddCtx) {
1798 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1799 "%s: HDD context is Null", __func__);
1800 return FALSE;
1801 }
1802
1803 return pHddCtx->cfg_ini->enableFatalEvent;
1804}
1805
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301806/**---------------------------------------------------------------------------
1807
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301808 \brief __vos_fatal_event_logs_req() - used to send flush command to FW
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301809
1810 This API is wrapper to SME flush API.
1811
1812 \param is_fatal - fatal or non fatal event
1813 indicator - Tyoe of indicator framework/Host/FW
1814 reason_code - reason code for flush logs
1815
1816 \return VOS_STATUS_SUCCESS - if command is sent successfully.
1817 VOS_STATUS_E_FAILURE - if command is not sent successfully.
1818 --------------------------------------------------------------------------*/
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301819VOS_STATUS __vos_fatal_event_logs_req( uint32_t is_fatal,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301820 uint32_t indicator,
1821 uint32_t reason_code,
Abhishek Singh837adf22015-10-01 17:37:37 +05301822 bool wait_required,
1823 bool dump_vos_trace)
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301824{
1825 VOS_STATUS vosStatus;
1826 eHalStatus status;
1827 VosContextType *vos_context;
Abhishek Singh837adf22015-10-01 17:37:37 +05301828 hdd_context_t *pHddCtx = NULL;
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301829
1830 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1831 if (!vos_context)
1832 {
1833 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1834 "%s: vos context is Invalid", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301835 return VOS_STATUS_E_FAILURE;
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301836 }
Abhishek Singh837adf22015-10-01 17:37:37 +05301837 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, vos_context );
1838 if(!pHddCtx) {
1839 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1840 "%s: HDD context is Null", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301841 return VOS_STATUS_E_FAILURE;
1842 }
1843
1844 if(!pHddCtx->cfg_ini->wlanLoggingEnable)
1845 {
1846 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1847 "%s: Wlan logging not enabled", __func__);
1848 return VOS_STATUS_E_FAILURE;
Abhishek Singh837adf22015-10-01 17:37:37 +05301849 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301850
Abhishek Singh837adf22015-10-01 17:37:37 +05301851 if(!pHddCtx->cfg_ini->enableFatalEvent)
1852 {
1853 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1854 "%s: Fatal event not enabled", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301855 return VOS_STATUS_E_FAILURE;
Abhishek Singh837adf22015-10-01 17:37:37 +05301856 }
1857
1858 if (pHddCtx->isLoadUnloadInProgress ||
1859 vos_context->isLogpInProgress)
1860 {
1861 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1862 "%s: un/Load/SSR in progress", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301863 return VOS_STATUS_E_FAILURE;
Abhishek Singh837adf22015-10-01 17:37:37 +05301864 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301865
1866 if (vos_is_log_report_in_progress() == true)
1867 {
1868 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1869 "%s: Fatal Event Req already in progress - dropping! type:%d, indicator=%d reason_code=%d",
1870 __func__, is_fatal, indicator, reason_code);
1871 return VOS_STATUS_E_FAILURE;
1872 }
1873
1874 vosStatus = vos_set_log_completion(is_fatal, indicator, reason_code);
1875 if (VOS_STATUS_SUCCESS != vosStatus) {
1876 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1877 "%s: Failed to set log trigger params for fatalEvent", __func__);
1878 return VOS_STATUS_E_FAILURE;
1879 }
Abhishek Singh837adf22015-10-01 17:37:37 +05301880 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301881 "%s: Triggering fatal Event: type:%d, indicator=%d reason_code=%d",
1882 __func__, is_fatal, indicator, reason_code);
1883
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301884 status = vos_event_reset(&gpVosContext->fwLogsComplete);
1885 if(!HAL_STATUS_SUCCESS(status))
1886 {
1887 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1888 FL("fwLogsComplete reset failed:%d"),status);
1889 return VOS_STATUS_E_FAILURE;
1890 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301891 status = sme_fatal_event_logs_req(vos_context->pMACContext,
1892 is_fatal, indicator,
Abhishek Singh837adf22015-10-01 17:37:37 +05301893 reason_code, dump_vos_trace);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301894
Abhishek Singh837adf22015-10-01 17:37:37 +05301895 if (HAL_STATUS_SUCCESS(status) && (wait_required == TRUE))
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301896 {
1897
1898 /* Need to update time out of complete */
1899 vosStatus = vos_wait_single_event(&gpVosContext->fwLogsComplete,
1900 WAIT_TIME_FW_LOGS);
1901 if ( vosStatus != VOS_STATUS_SUCCESS )
1902 {
1903 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1904 {
1905 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1906 "%s: Timeout occurred before fwLogsComplete", __func__);
1907 }
1908 else
1909 {
1910 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1911 "%s: fwLogsComplete reporting other error", __func__);
1912 }
1913 /*Done indication is not received.So reset the bug report in progress*/
1914 vos_reset_log_report_in_progress();
1915 return VOS_STATUS_E_FAILURE;
1916 }
1917 }
1918 if (HAL_STATUS_SUCCESS( status ))
1919 return VOS_STATUS_SUCCESS;
1920 else
1921 return VOS_STATUS_E_FAILURE;
1922}
1923
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301924VOS_STATUS vos_fatal_event_logs_req( uint32_t is_fatal,
1925 uint32_t indicator,
1926 uint32_t reason_code,
1927 bool wait_required,
1928 bool dump_vos_trace)
1929{
1930 VOS_STATUS status;
1931
1932 vos_ssr_protect(__func__);
1933 status = __vos_fatal_event_logs_req(is_fatal, indicator, reason_code,
1934 wait_required, dump_vos_trace);
1935 vos_ssr_unprotect(__func__);
1936
1937 return status;
1938}
1939
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301940/**---------------------------------------------------------------------------
1941
1942 \brief vos_process_done_indication() - Process the done indication for fatal event,
1943 FW memory dump
1944
1945 This API processes the done indication and wakeup the logger thread accordingly.
1946
1947 \param type - Type for which done indication is received.
1948
1949
1950 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1951 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1952 a failure.
1953 --------------------------------------------------------------------------*/
1954
1955VOS_STATUS vos_process_done_indication(v_U8_t type, v_U32_t reason_code)
1956{
1957 wlan_process_done_indication(type, reason_code);
1958 return VOS_STATUS_SUCCESS;
1959}
1960
Abhishek Singh837adf22015-10-01 17:37:37 +05301961/**
1962 * vos_flush_host_logs_for_fatal() -flush host logs and send
1963 * fatal event to upper layer.
1964 */
1965void vos_flush_host_logs_for_fatal(void)
1966{
1967 wlan_flush_host_logs_for_fatal();
1968 return;
1969}
1970
1971
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301972/**---------------------------------------------------------------------------
1973
1974 \brief vos_logger_pkt_serialize() - queue a logging vos pkt
1975
1976 This API allows single vos pkt to be queued and later sent to userspace by
1977 logger thread.
1978
1979 \param pPacket - a pointer to a vos pkt to be queued
1980 pkt_type - type of pkt to be queued
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301981
1982 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1983 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1984 a failure.
1985 --------------------------------------------------------------------------*/
Mihir Sheteccafc0c2015-04-17 16:13:15 +05301986VOS_STATUS vos_logger_pkt_serialize( vos_pkt_t *pPacket, uint32 pkt_type)
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301987{
1988#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1989 return wlan_queue_logpkt_for_app(pPacket, pkt_type);
1990#else
1991 return vos_pkt_return_packet(pPacket);
1992#endif
1993}
Jeff Johnson295189b2012-06-20 16:38:30 -07001994
Sushant Kaushik33200572015-08-05 16:46:20 +05301995void vos_per_pkt_stats_to_user(void *perPktStat)
1996{
1997#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1998 wlan_pkt_stats_to_user(perPktStat);
1999#else
2000 return;
2001#endif
2002
2003
2004
2005}
2006
2007void vos_updatePktStatsInfo(void * pktStat)
2008{
2009#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
2010 wlan_fillTxStruct(pktStat);
2011#else
2012 return;
2013#endif
2014
2015}
2016
2017
Jeff Johnson295189b2012-06-20 16:38:30 -07002018/**---------------------------------------------------------------------------
2019
2020 \brief vos_mq_post_message() - post a message to a message queue
2021
2022 This API allows messages to be posted to a specific message queue. Messages
2023 can be posted to the following message queues:
2024
2025 <ul>
2026 <li> SME
2027 <li> PE
2028 <li> HAL
2029 <li> TL
2030 </ul>
2031
2032 \param msgQueueId - identifies the message queue upon which the message
2033 will be posted.
2034
2035 \param message - a pointer to a message buffer. Memory for this message
2036 buffer is allocated by the caller and free'd by the vOSS after the
2037 message is posted to the message queue. If the consumer of the
2038 message needs anything in this message, it needs to copy the contents
2039 before returning from the message queue handler.
2040
2041 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2042 to the message queue.
2043
2044 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2045 refer to a valid Message Queue Id.
2046
2047 VOS_STATUS_E_FAULT - message is an invalid pointer.
2048
2049 VOS_STATUS_E_FAILURE - the message queue handler has reported
2050 an unknown failure.
2051
2052 \sa
2053
2054 --------------------------------------------------------------------------*/
2055VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2056{
2057 pVosMqType pTargetMq = NULL;
2058 pVosMsgWrapper pMsgWrapper = NULL;
2059
2060 if ((gpVosContext == NULL) || (pMsg == NULL))
2061 {
2062 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2063 "%s: Null params or global vos context is null", __func__);
2064 VOS_ASSERT(0);
2065 return VOS_STATUS_E_FAILURE;
2066 }
2067
2068 switch (msgQueueId)
2069 {
2070 /// Message Queue ID for messages bound for SME
2071 case VOS_MQ_ID_SME:
2072 {
2073 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
2074 break;
2075 }
2076
2077 /// Message Queue ID for messages bound for PE
2078 case VOS_MQ_ID_PE:
2079 {
2080 pTargetMq = &(gpVosContext->vosSched.peMcMq);
2081 break;
2082 }
2083
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 /// Message Queue ID for messages bound for WDA
2085 case VOS_MQ_ID_WDA:
2086 {
2087 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
2088 break;
2089 }
2090
2091 /// Message Queue ID for messages bound for WDI
2092 case VOS_MQ_ID_WDI:
2093 {
2094 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
2095 break;
2096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002097
2098 /// Message Queue ID for messages bound for TL
2099 case VOS_MQ_ID_TL:
2100 {
2101 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
2102 break;
2103 }
2104
2105 /// Message Queue ID for messages bound for the SYS module
2106 case VOS_MQ_ID_SYS:
2107 {
2108 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
2109 break;
2110 }
2111
2112 default:
2113
2114 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2115 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
2116 __func__, msgQueueId);
2117
2118 return VOS_STATUS_E_FAILURE;
2119 }
2120
2121 VOS_ASSERT(NULL !=pTargetMq);
2122 if (pTargetMq == NULL)
2123 {
2124 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002125 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 return VOS_STATUS_E_FAILURE;
2127 }
2128
2129 /*
2130 ** Try and get a free Msg wrapper
2131 */
2132 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2133
2134 if (NULL == pMsgWrapper)
2135 {
2136 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2137 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302138 if (!gpVosContext->vosWrapperFullReported)
2139 {
2140 gpVosContext->vosWrapperFullReported = 1;
2141 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2142 WLAN_LOG_INDICATOR_HOST_ONLY,
2143 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2144 FALSE, TRUE);
2145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 return VOS_STATUS_E_RESOURCES;
2147 }
2148
2149 /*
2150 ** Copy the message now
2151 */
2152 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2153 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2154
2155 vos_mq_put(pTargetMq, pMsgWrapper);
2156
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302157 set_bit(MC_POST_EVENT, &gpVosContext->vosSched.mcEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
2159
2160 return VOS_STATUS_SUCCESS;
2161
2162} /* vos_mq_post_message()*/
2163
2164
Padma, Santhosh Kumarb036fc72015-11-13 16:22:23 +05302165/**--------------------------------------------------------------------------
2166 \brief vos_mq_post_message_high_pri() - posts a high priority message to
2167 a message queue
2168
2169 This API allows messages to be posted to the head of a specific message
2170 queue. Messages can be posted to the following message queues:
2171
2172 <ul>
2173 <li> SME
2174 <li> PE
2175 <li> HAL
2176 <li> TL
2177 </ul>
2178
2179 \param msgQueueId - identifies the message queue upon which the message
2180 will be posted.
2181
2182 \param message - a pointer to a message buffer. Memory for this message
2183 buffer is allocated by the caller and free'd by the vOSS after the
2184 message is posted to the message queue. If the consumer of the
2185 message needs anything in this message, it needs to copy the contents
2186 before returning from the message queue handler.
2187
2188 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2189 to the message queue.
2190
2191 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2192 refer to a valid Message Queue Id.
2193
2194 VOS_STATUS_E_FAULT - message is an invalid pointer.
2195
2196 VOS_STATUS_E_FAILURE - the message queue handler has reported
2197 an unknown failure.
2198 --------------------------------------------------------------------------*/
2199VOS_STATUS vos_mq_post_message_high_pri(VOS_MQ_ID msgQueueId, vos_msg_t *pMsg)
2200{
2201 pVosMqType pTargetMq = NULL;
2202 pVosMsgWrapper pMsgWrapper = NULL;
2203
2204 if ((gpVosContext == NULL) || (pMsg == NULL))
2205 {
2206 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2207 "%s: Null params or global vos context is null", __func__);
2208 VOS_ASSERT(0);
2209 return VOS_STATUS_E_FAILURE;
2210 }
2211
2212 switch (msgQueueId)
2213 {
2214 /// Message Queue ID for messages bound for SME
2215 case VOS_MQ_ID_SME:
2216 {
2217 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
2218 break;
2219 }
2220
2221 /// Message Queue ID for messages bound for PE
2222 case VOS_MQ_ID_PE:
2223 {
2224 pTargetMq = &(gpVosContext->vosSched.peMcMq);
2225 break;
2226 }
2227
2228 /// Message Queue ID for messages bound for WDA
2229 case VOS_MQ_ID_WDA:
2230 {
2231 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
2232 break;
2233 }
2234
2235 /// Message Queue ID for messages bound for WDI
2236 case VOS_MQ_ID_WDI:
2237 {
2238 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
2239 break;
2240 }
2241
2242 /// Message Queue ID for messages bound for TL
2243 case VOS_MQ_ID_TL:
2244 {
2245 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
2246 break;
2247 }
2248
2249 /// Message Queue ID for messages bound for the SYS module
2250 case VOS_MQ_ID_SYS:
2251 {
2252 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
2253 break;
2254 }
2255
2256 default:
2257
2258 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2259 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
2260 __func__, msgQueueId);
2261
2262 return VOS_STATUS_E_FAILURE;
2263 }
2264
2265 VOS_ASSERT(NULL !=pTargetMq);
2266 if (pTargetMq == NULL)
2267 {
2268 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2269 "%s: pTargetMq == NULL", __func__);
2270 return VOS_STATUS_E_FAILURE;
2271 }
2272
2273 /*
2274 ** Try and get a free Msg wrapper
2275 */
2276 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2277
2278 if (NULL == pMsgWrapper)
2279 {
2280 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2281 "%s: VOS Core run out of message wrapper", __func__);
2282 if (!gpVosContext->vosWrapperFullReported)
2283 {
2284 gpVosContext->vosWrapperFullReported = 1;
2285 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2286 WLAN_LOG_INDICATOR_HOST_ONLY,
2287 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2288 FALSE, TRUE);
2289 }
2290 return VOS_STATUS_E_RESOURCES;
2291 }
2292
2293 /*
2294 ** Copy the message now
2295 */
2296 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2297 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2298
2299 vos_mq_put_front(pTargetMq, pMsgWrapper);
2300
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302301 set_bit(MC_POST_EVENT, &gpVosContext->vosSched.mcEventFlag);
Padma, Santhosh Kumarb036fc72015-11-13 16:22:23 +05302302 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
2303
2304 return VOS_STATUS_SUCCESS;
2305
2306} /* vos_mq_post_message_high_pri()*/
2307
2308
2309
Jeff Johnson295189b2012-06-20 16:38:30 -07002310/**---------------------------------------------------------------------------
2311
2312 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
2313
2314 This API allows messages to be posted to a specific message queue in the
2315 Tx excution flow. Messages for the Tx execution flow can be posted only
2316 to the following queue.
2317
2318 <ul>
2319 <li> TL
2320 <li> SSC/WDI
2321 </ul>
2322
2323 \param msgQueueId - identifies the message queue upon which the message
2324 will be posted.
2325
2326 \param message - a pointer to a message buffer. Body memory for this message
2327 buffer is allocated by the caller and free'd by the vOSS after the
2328 message is dispacthed to the appropriate component. If the consumer
2329 of the message needs to keep anything in the body, it needs to copy
2330 the contents before returning from the message handler.
2331
2332 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2333 to the message queue.
2334
2335 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2336 refer to a valid Message Queue Id.
2337
2338 VOS_STATUS_E_FAULT - message is an invalid pointer.
2339
2340 VOS_STATUS_E_FAILURE - the message queue handler has reported
2341 an unknown failure.
2342
2343 \sa
2344
2345 --------------------------------------------------------------------------*/
2346VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2347{
2348 pVosMqType pTargetMq = NULL;
2349 pVosMsgWrapper pMsgWrapper = NULL;
2350
2351 if ((gpVosContext == NULL) || (pMsg == NULL))
2352 {
2353 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2354 "%s: Null params or global vos context is null", __func__);
2355 VOS_ASSERT(0);
2356 return VOS_STATUS_E_FAILURE;
2357 }
2358
2359 switch (msgQueueId)
2360 {
2361 /// Message Queue ID for messages bound for SME
2362 case VOS_MQ_ID_TL:
2363 {
2364 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
2365 break;
2366 }
2367
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 /// Message Queue ID for messages bound for SSC
2369 case VOS_MQ_ID_WDI:
2370 {
2371 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
2372 break;
2373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002374
2375 /// Message Queue ID for messages bound for the SYS module
2376 case VOS_MQ_ID_SYS:
2377 {
2378 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
2379 break;
2380 }
2381
2382 default:
2383
2384 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302385 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 __func__, msgQueueId);
2387
2388 return VOS_STATUS_E_FAILURE;
2389 }
2390
2391 if (pTargetMq == NULL)
2392 {
2393 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002394 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 return VOS_STATUS_E_FAILURE;
2396 }
2397
2398
2399 /*
2400 ** Try and get a free Msg wrapper
2401 */
2402 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2403
2404 if (NULL == pMsgWrapper)
2405 {
2406 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2407 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302408 if (!gpVosContext->vosWrapperFullReported)
2409 {
2410 gpVosContext->vosWrapperFullReported = 1;
2411 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2412 WLAN_LOG_INDICATOR_HOST_ONLY,
2413 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2414 FALSE, TRUE);
2415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002416
2417 return VOS_STATUS_E_RESOURCES;
2418 }
2419
2420 /*
2421 ** Copy the message now
2422 */
2423 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2424 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2425
2426 vos_mq_put(pTargetMq, pMsgWrapper);
2427
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302428 set_bit(TX_POST_EVENT, &gpVosContext->vosSched.txEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
2430
2431 return VOS_STATUS_SUCCESS;
2432
2433} /* vos_tx_mq_serialize()*/
2434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435/**---------------------------------------------------------------------------
2436
2437 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
2438
2439 This API allows messages to be posted to a specific message queue in the
2440 Tx excution flow. Messages for the Rx execution flow can be posted only
2441 to the following queue.
2442
2443 <ul>
2444 <li> TL
2445 <li> WDI
2446 </ul>
2447
2448 \param msgQueueId - identifies the message queue upon which the message
2449 will be posted.
2450
2451 \param message - a pointer to a message buffer. Body memory for this message
2452 buffer is allocated by the caller and free'd by the vOSS after the
2453 message is dispacthed to the appropriate component. If the consumer
2454 of the message needs to keep anything in the body, it needs to copy
2455 the contents before returning from the message handler.
2456
2457 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2458 to the message queue.
2459
2460 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2461 refer to a valid Message Queue Id.
2462
2463 VOS_STATUS_E_FAULT - message is an invalid pointer.
2464
2465 VOS_STATUS_E_FAILURE - the message queue handler has reported
2466 an unknown failure.
2467
2468 \sa
2469
2470 --------------------------------------------------------------------------*/
2471
2472VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2473{
2474 pVosMqType pTargetMq = NULL;
2475 pVosMsgWrapper pMsgWrapper = NULL;
2476 if ((gpVosContext == NULL) || (pMsg == NULL))
2477 {
2478 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2479 "%s: Null params or global vos context is null", __func__);
2480 VOS_ASSERT(0);
2481 return VOS_STATUS_E_FAILURE;
2482 }
2483
2484 switch (msgQueueId)
2485 {
2486
2487 case VOS_MQ_ID_SYS:
2488 {
2489 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
2490 break;
2491 }
2492
2493 /// Message Queue ID for messages bound for WDI
2494 case VOS_MQ_ID_WDI:
2495 {
2496 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
2497 break;
2498 }
Katya Nigam664f5032014-05-05 12:24:32 +05302499 case VOS_MQ_ID_TL:
2500 {
2501 pTargetMq = &(gpVosContext->vosSched.tlRxMq);
2502 break;
2503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002504
2505 default:
2506
2507 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302508 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 __func__, msgQueueId);
2510
2511 return VOS_STATUS_E_FAILURE;
2512 }
2513
2514 if (pTargetMq == NULL)
2515 {
2516 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002517 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 return VOS_STATUS_E_FAILURE;
2519 }
2520
2521
2522 /*
2523 ** Try and get a free Msg wrapper
2524 */
2525 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2526
2527 if (NULL == pMsgWrapper)
2528 {
2529 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2530 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302531 if (!gpVosContext->vosWrapperFullReported)
2532 {
2533 gpVosContext->vosWrapperFullReported = 1;
2534 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2535 WLAN_LOG_INDICATOR_HOST_ONLY,
2536 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2537 FALSE, TRUE);
2538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002539
2540 return VOS_STATUS_E_RESOURCES;
2541 }
2542
2543 /*
2544 ** Copy the message now
2545 */
2546 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2547 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2548
2549 vos_mq_put(pTargetMq, pMsgWrapper);
2550
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302551 set_bit(RX_POST_EVENT, &gpVosContext->vosSched.rxEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
2553
2554 return VOS_STATUS_SUCCESS;
2555
2556} /* vos_rx_mq_serialize()*/
2557
Jeff Johnson295189b2012-06-20 16:38:30 -07002558v_VOID_t
2559vos_sys_probe_thread_cback
2560(
2561 v_VOID_t *pUserData
2562)
2563{
2564 if (gpVosContext != pUserData)
2565 {
2566 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002567 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 return;
2569 }
2570
2571 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2572 {
2573 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002574 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 return;
2576 }
2577
2578} /* vos_sys_probe_thread_cback() */
2579
Jeff Johnson295189b2012-06-20 16:38:30 -07002580v_VOID_t vos_WDAComplete_cback
2581(
2582 v_VOID_t *pUserData
2583)
2584{
2585
2586 if (gpVosContext != pUserData)
2587 {
2588 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002589 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 return;
2591 }
2592
2593 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
2594 {
2595 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002596 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 return;
2598 }
2599
2600} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07002601
2602v_VOID_t vos_core_return_msg
2603(
2604 v_PVOID_t pVContext,
2605 pVosMsgWrapper pMsgWrapper
2606)
2607{
2608 pVosContextType pVosContext = (pVosContextType) pVContext;
2609
2610 VOS_ASSERT( gpVosContext == pVosContext);
2611
2612 if (gpVosContext != pVosContext)
2613 {
2614 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002615 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 return;
2617 }
2618
2619 VOS_ASSERT( NULL !=pMsgWrapper );
2620
2621 if (pMsgWrapper == NULL)
2622 {
2623 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002624 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 return;
2626 }
2627
2628 /*
2629 ** Return the message on the free message queue
2630 */
2631 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
2632 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
2633
2634} /* vos_core_return_msg() */
2635
2636
2637/**
2638 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
2639 TL config params from the registry
2640
2641 @param pAdapter : [inout] pointer to TL config block
2642
2643 @return
2644 None
2645
2646*/
2647v_VOID_t
2648vos_fetch_tl_cfg_parms
2649(
2650 WLANTL_ConfigInfoType *pTLConfig,
2651 hdd_config_t * pConfig
2652)
2653{
2654 if (pTLConfig == NULL)
2655 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002656 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 return;
2658 }
2659
2660 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
2661 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
2662 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
2663 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302664 pTLConfig->ucAcWeights[4] = pConfig->WfqVoWeight;
Dhanashri Atred8c20a32014-01-03 17:20:55 -08002665 pTLConfig->ucReorderAgingTime[0] = pConfig->BkReorderAgingTime;/*WLANTL_AC_BK*/
2666 pTLConfig->ucReorderAgingTime[1] = pConfig->BeReorderAgingTime;/*WLANTL_AC_BE*/
2667 pTLConfig->ucReorderAgingTime[2] = pConfig->ViReorderAgingTime;/*WLANTL_AC_VI*/
2668 pTLConfig->ucReorderAgingTime[3] = pConfig->VoReorderAgingTime;/*WLANTL_AC_VO*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07002671
2672}
2673
2674v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
2675{
2676 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
2677}
2678
Jeff Johnson295189b2012-06-20 16:38:30 -07002679/*---------------------------------------------------------------------------
2680
2681 \brief vos_shutdown() - shutdown VOS
2682
2683 - All VOS submodules are closed.
2684
2685 - All the WLAN SW components should have been opened. This includes
2686 SYS, MAC, SME and TL.
2687
2688
2689 \param vosContext: Global vos context
2690
2691
2692 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
2693
2694 VOS_STATUS_E_FAILURE - Failure to close
2695
2696---------------------------------------------------------------------------*/
2697VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2698{
2699 VOS_STATUS vosStatus;
2700
2701#ifdef WLAN_BTAMP_FEATURE
2702 vosStatus = WLANBAP_Close(vosContext);
2703 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2704 {
2705 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2706 "%s: Failed to close BAP", __func__);
2707 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2708 }
2709#endif // WLAN_BTAMP_FEATURE
2710
2711 vosStatus = WLANTL_Close(vosContext);
2712 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2713 {
2714 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2715 "%s: Failed to close TL", __func__);
2716 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2717 }
2718
2719 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2720 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2721 {
2722 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2723 "%s: Failed to close SME", __func__);
2724 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2725 }
2726
2727 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2728 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2729 {
2730 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2731 "%s: Failed to close MAC", __func__);
2732 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2733 }
2734
2735 ((pVosContextType)vosContext)->pMACContext = NULL;
2736
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 vosStatus = sysClose( vosContext );
2738 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2739 {
2740 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2741 "%s: Failed to close SYS", __func__);
2742 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2743 }
2744
2745 /* Let DXE return packets in WDA_close and then free them here */
2746 vosStatus = vos_packet_close( vosContext );
2747 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2748 {
2749 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2750 "%s: Failed to close VOSS Packet", __func__);
2751 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2752 }
2753
2754 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2755
Sachin Ahuja715aafc2015-07-21 23:35:10 +05302756 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
2757 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2758 {
2759 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2760 "%s: failed to destroy fwLogsComplete", __func__);
2761 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2762 }
2763
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2766 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2767 {
2768 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2769 "%s: failed to destroy wdaCompleteEvent", __func__);
2770 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2771 }
2772
2773 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2774 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2775 {
2776 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2777 "%s: failed to destroy ProbeEvent", __func__);
2778 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2779 }
2780
2781 return VOS_STATUS_SUCCESS;
2782}
2783
2784/*---------------------------------------------------------------------------
2785
2786 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2787
2788 - WDA/WDI shutdown
2789
2790 \param vosContext: Global vos context
2791
2792
2793 \return VOS_STATUS_SUCCESS - Operation successfull
2794
2795 VOS_STATUS_E_FAILURE - Failure to close
2796
2797---------------------------------------------------------------------------*/
2798VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2799{
2800 VOS_STATUS vosStatus;
2801 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2802
2803 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2804 {
2805 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2806 "%s: failed to shutdown WDA", __func__);
2807 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2808 }
2809 return vosStatus;
2810}
2811/**
2812 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2813
2814 This function is called when Riva subsystem crashes. There are two
2815 methods (or operations) in WLAN driver to handle Riva crash,
2816 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2817 driver without handshaking with Riva.
2818 2. re-init: Next API
2819 @param
2820 NONE
2821 @return
2822 VOS_STATUS_SUCCESS - Operation completed successfully.
2823 VOS_STATUS_E_FAILURE - Operation failed.
2824
2825*/
2826VOS_STATUS vos_wlanShutdown(void)
2827{
2828 VOS_STATUS vstatus;
2829 vstatus = vos_watchdog_wlan_shutdown();
2830 return vstatus;
2831}
2832/**
2833 @brief vos_wlanReInit() - This API will re-init WLAN driver
2834
2835 This function is called when Riva subsystem reboots. There are two
2836 methods (or operations) in WLAN driver to handle Riva crash,
2837 1. shutdown: Previous API
2838 2. re-init: Called when Riva comes back after the crash. This will
2839 re-initialize WLAN driver. In some cases re-open may be
2840 referred instead of re-init.
2841 @param
2842 NONE
2843 @return
2844 VOS_STATUS_SUCCESS - Operation completed successfully.
2845 VOS_STATUS_E_FAILURE - Operation failed.
2846
2847*/
2848VOS_STATUS vos_wlanReInit(void)
2849{
2850 VOS_STATUS vstatus;
2851 vstatus = vos_watchdog_wlan_re_init();
2852 return vstatus;
2853}
Jeff Johnsone7245742012-09-05 17:12:55 -07002854/**
2855 @brief vos_wlanRestart() - This API will reload WLAN driver.
2856
2857 This function is called if driver detects any fatal state which
2858 can be recovered by a WLAN module reload ( Android framwork initiated ).
2859 Note that this API will not initiate any RIVA subsystem restart.
2860
2861 The function wlan_hdd_restart_driver protects against re-entrant calls.
2862
2863 @param
2864 NONE
2865 @return
2866 VOS_STATUS_SUCCESS - Operation completed successfully.
2867 VOS_STATUS_E_FAILURE - Operation failed.
2868 VOS_STATUS_E_EMPTY - No configured interface
2869 VOS_STATUS_E_ALREADY - Request already in progress
2870
2871
2872*/
2873VOS_STATUS vos_wlanRestart(void)
2874{
2875 VOS_STATUS vstatus;
2876 hdd_context_t *pHddCtx = NULL;
2877 v_CONTEXT_t pVosContext = NULL;
2878
2879 /* Check whether driver load unload is in progress */
2880 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2881 {
2882 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2883 "%s: Driver load/unload is in progress, retry later.", __func__);
2884 return VOS_STATUS_E_AGAIN;
2885 }
2886
2887 /* Get the Global VOSS Context */
2888 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2889 if(!pVosContext) {
2890 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2891 "%s: Global VOS context is Null", __func__);
2892 return VOS_STATUS_E_FAILURE;
2893 }
2894
2895 /* Get the HDD context */
2896 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2897 if(!pHddCtx) {
2898 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2899 "%s: HDD context is Null", __func__);
2900 return VOS_STATUS_E_FAILURE;
2901 }
2902
2903 /* Reload the driver */
2904 vstatus = wlan_hdd_restart_driver(pHddCtx);
2905 return vstatus;
2906}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302907
2908
2909/**
2910 @brief vos_fwDumpReq()
2911
2912 This function is called to issue dump commands to Firmware
2913
2914 @param
Siddharth Bhal68115602015-01-18 20:44:55 +05302915 cmd - Command No. to execute
2916 arg1 - argument 1 to cmd
2917 arg2 - argument 2 to cmd
2918 arg3 - argument 3 to cmd
2919 arg4 - argument 4 to cmd
2920 async - asynchronous event. Don't wait for completion.
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302921 @return
2922 NONE
2923*/
2924v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
Siddharth Bhal68115602015-01-18 20:44:55 +05302925 tANI_U32 arg3, tANI_U32 arg4, tANI_U8 async)
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302926{
Siddharth Bhalec9581a2015-02-18 14:48:18 +05302927 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL, async);
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302928}
Dino Mycle3f783bc2014-08-08 17:40:22 +05302929
2930v_U64_t vos_get_monotonic_boottime(void)
2931{
2932 struct timespec ts;
2933 wcnss_get_monotonic_boottime(&ts);
2934 return (((v_U64_t)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
2935}
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05302936
2937/**---------------------------------------------------------------------------
2938
2939 \brief vos_randomize_n_bytes() - HDD Random Mac Addr Generator
2940
2941 This generates the random mac address for WLAN interface
2942
2943 \param - mac_addr - pointer to Mac address
2944
2945 \return - 0 for success, < 0 for failure
2946
2947 --------------------------------------------------------------------------*/
2948
2949VOS_STATUS vos_randomize_n_bytes(void *start_addr, tANI_U32 n)
2950{
2951
2952 if (start_addr == NULL )
2953 return VOS_STATUS_E_FAILURE;
2954
2955 get_random_bytes( start_addr, n);
2956
2957 return eHAL_STATUS_SUCCESS;
2958}
c_hpothu8adb97b2014-12-08 19:38:20 +05302959
2960/**---------------------------------------------------------------------------
2961
2962 \brief vos_is_wlan_in_badState() - get isFatalError flag from WD Ctx
2963
2964 \param - VOS_MODULE_ID - module id
2965 - moduleContext - module context
2966
2967 \return - isFatalError value if WDCtx is valid otherwise true
2968
2969 --------------------------------------------------------------------------*/
2970v_BOOL_t vos_is_wlan_in_badState(VOS_MODULE_ID moduleId,
2971 v_VOID_t *moduleContext)
2972{
2973 struct _VosWatchdogContext *pVosWDCtx = get_vos_watchdog_ctxt();
2974
2975 if (pVosWDCtx == NULL){
2976 VOS_TRACE(moduleId, VOS_TRACE_LEVEL_ERROR,
2977 "%s: global wd context is null", __func__);
2978
2979 return TRUE;
2980 }
2981 return pVosWDCtx->isFatalError;
2982}
Girish Gowlia33f0372015-01-19 15:39:04 +05302983
Girish Gowlia33f0372015-01-19 15:39:04 +05302984/**---------------------------------------------------------------------------
2985
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302986 \brief vos_is_fw_logging_enabled() -
2987
2988 API to check if firmware is configured to send logs using DXE channel
2989
2990 \param - None
2991
Mihir Sheted6274602015-04-28 16:13:21 +05302992 \return - 0: firmware logging is not enabled (it may or may not
2993 be supported)
Mihir Shetee2ae82a2015-03-16 14:08:49 +05302994 1: firmware logging is enabled
2995
2996 --------------------------------------------------------------------------*/
2997v_U8_t vos_is_fw_logging_enabled(void)
2998{
2999 return hdd_is_fw_logging_enabled();
3000}
3001
3002/**---------------------------------------------------------------------------
3003
Mihir Shetebe94ebb2015-05-26 12:07:14 +05303004 \brief vos_is_fw_ev_logging_enabled() -
3005
3006 API to check if firmware is configured to send live logs using DXE channel
3007
3008 \param - None
3009
3010 \return - 0: firmware logging is not enabled (it may or may not
3011 be supported)
3012 1: firmware logging is enabled
3013
3014 --------------------------------------------------------------------------*/
3015v_U8_t vos_is_fw_ev_logging_enabled(void)
3016{
3017 return hdd_is_fw_ev_logging_enabled();
3018}
3019
3020/**---------------------------------------------------------------------------
3021
Mihir Sheted6274602015-04-28 16:13:21 +05303022 \brief vos_is_fw_logging_supported() -
3023
3024 API to check if firmware supports to send logs using DXE channel
3025
3026 \param - None
3027
3028 \return - 0: firmware logging is not supported
3029 1: firmware logging is supported
3030
3031 --------------------------------------------------------------------------*/
3032v_U8_t vos_is_fw_logging_supported(void)
3033{
3034 return IS_FRAME_LOGGING_SUPPORTED_BY_FW;
3035}
3036/**---------------------------------------------------------------------------
3037
Girish Gowlia33f0372015-01-19 15:39:04 +05303038 \brief vos_set_roam_delay_stats_enabled() -
3039
3040 API to set value of roamDelayStatsEnabled in vos context
3041
3042 \param - value to be updated
3043
3044 \return - NONE
3045
3046 --------------------------------------------------------------------------*/
3047
3048v_VOID_t vos_set_roam_delay_stats_enabled(v_U8_t value)
3049{
3050 gpVosContext->roamDelayStatsEnabled = value;
3051}
3052
3053
3054/**---------------------------------------------------------------------------
3055
3056 \brief vos_get_roam_delay_stats_enabled() -
3057
3058 API to get value of roamDelayStatsEnabled from vos context
3059
3060 \param - NONE
3061
3062 \return - value of roamDelayStatsEnabled
3063
3064 --------------------------------------------------------------------------*/
3065
3066v_U8_t vos_get_roam_delay_stats_enabled(v_VOID_t)
3067{
3068 return gpVosContext->roamDelayStatsEnabled;
3069}
Katya Nigama6fbf662015-03-17 18:35:47 +05303070
3071v_U32_t vos_get_dxeReplenishRXTimerVal(void)
3072{
3073 hdd_context_t *pHddCtx = NULL;
3074 v_CONTEXT_t pVosContext = NULL;
3075
3076 /* Get the Global VOSS Context */
3077 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3078 if(!pVosContext) {
3079 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
3080 return 0;
3081 }
3082
3083 /* Get the HDD context */
3084 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3085 if(!pHddCtx) {
3086 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
3087 return 0;
3088 }
3089
3090 return pHddCtx->cfg_ini->dxeReplenishRXTimerVal;
3091}
3092
3093v_BOOL_t vos_get_dxeSSREnable(void)
3094{
3095 hdd_context_t *pHddCtx = NULL;
3096 v_CONTEXT_t pVosContext = NULL;
3097
3098 /* Get the Global VOSS Context */
3099 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3100 if(!pVosContext) {
3101 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
3102 return FALSE;
3103 }
3104
3105 /* Get the HDD context */
3106 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3107 if(!pHddCtx) {
3108 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
3109 return FALSE;
3110 }
3111
3112 return pHddCtx->cfg_ini->dxeSSREnable;
3113}
Anand N Sunkad860e5ea2015-03-30 14:41:51 +05303114
3115v_VOID_t vos_flush_work(struct work_struct *work)
3116{
3117#if defined (WLAN_OPEN_SOURCE)
3118 cancel_work_sync(work);
3119#else
3120 wcnss_flush_work(work);
3121#endif
3122}
3123
3124v_VOID_t vos_flush_delayed_work(struct delayed_work *dwork)
3125{
3126#if defined (WLAN_OPEN_SOURCE)
3127 cancel_delayed_work_sync(dwork);
3128#else
3129 wcnss_flush_delayed_work(dwork);
3130#endif
3131}
3132
Anand N Sunkaddc63c792015-06-03 14:33:24 +05303133v_VOID_t vos_init_work(struct work_struct *work , void *callbackptr)
3134{
3135#if defined (WLAN_OPEN_SOURCE)
3136 INIT_WORK(work,callbackptr);
3137#else
3138 wcnss_init_work(work, callbackptr);
3139#endif
3140}
3141
3142v_VOID_t vos_init_delayed_work(struct delayed_work *dwork , void *callbackptr)
3143{
3144#if defined (WLAN_OPEN_SOURCE)
3145 INIT_DELAYED_WORK(dwork,callbackptr);
3146#else
3147 wcnss_init_delayed_work(dwork, callbackptr);
3148#endif
3149}
3150
Sushant Kaushik215778f2015-05-21 14:05:36 +05303151/**
3152 * vos_set_multicast_logging() - Set mutlicast logging value
3153 * @value: Value of multicast logging
3154 *
3155 * Set the multicast logging value which will indicate
3156 * whether to multicast host and fw messages even
3157 * without any registration by userspace entity
3158 *
3159 * Return: None
3160 */
3161void vos_set_multicast_logging(uint8_t value)
3162{
3163 vos_multicast_logging = value;
3164}
3165
3166/**
3167 * vos_is_multicast_logging() - Get multicast logging value
3168 *
3169 * Get the multicast logging value which will indicate
3170 * whether to multicast host and fw messages even
3171 * without any registration by userspace entity
3172 *
3173 * Return: 0 - Multicast logging disabled, 1 - Multicast logging enabled
3174 */
3175v_U8_t vos_is_multicast_logging(void)
3176{
3177 return vos_multicast_logging;
3178}
3179
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05303180/**
Abhishek Singh30fd58c2015-07-15 14:19:21 +05303181 * vos_isLoadUnloadInProgress()
3182 *
3183 * Return TRUE if load/unload is in progress.
3184 *
3185 */
3186v_BOOL_t vos_isLoadUnloadInProgress(void)
3187{
3188 hdd_context_t *pHddCtx = NULL;
3189 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3190
3191 if(!pVosContext)
3192 {
3193 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3194 return FALSE;
3195 }
3196
3197 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3198 if(!pHddCtx) {
3199 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3200 "%s: HDD context is Null", __func__);
3201 return FALSE;
3202 }
3203
3204 return ( 0 != pHddCtx->isLoadUnloadInProgress);
3205}
3206
3207/**
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05303208 * vos_isUnloadInProgress()
3209 *
3210 * Return TRUE if unload is in progress.
3211 *
3212 */
3213v_BOOL_t vos_isUnloadInProgress(void)
3214{
3215 hdd_context_t *pHddCtx = NULL;
3216 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3217
3218 if(!pVosContext)
3219 {
3220 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3221 return FALSE;
3222 }
3223
3224 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3225 if(!pHddCtx) {
3226 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3227 "%s: HDD context is Null", __func__);
3228 return FALSE;
3229 }
3230
3231 return (WLAN_HDD_UNLOAD_IN_PROGRESS == pHddCtx->isLoadUnloadInProgress);
3232}
3233
Abhishek Singh880d7122015-08-26 16:23:04 +05303234/**
Sravan Kumar Kairam1871d402016-08-04 13:18:25 +05303235 *vos_get_rx_wow_dump()
3236 *
3237 * Return true/flase to dump RX packet
3238 *
3239 */
3240bool vos_get_rx_wow_dump(void)
3241{
3242 hdd_context_t *pHddCtx = NULL;
3243 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3244
3245 if(!pVosContext)
3246 {
3247 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3248 return FALSE;
3249 }
3250
3251 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3252 if(!pHddCtx) {
3253 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3254 "%s: HDD context is Null", __func__);
3255 return FALSE;
3256 }
3257
3258 return pHddCtx->rx_wow_dump;
3259}
3260
3261/**
3262 *vos_set_rx_wow_dump() - Set RX wow pkt dump
3263 *@value: Value of RX wow pkt dump
3264 *
3265 * Return none.
3266 *
3267 */
3268void vos_set_rx_wow_dump(bool value)
3269{
3270 hdd_context_t *pHddCtx = NULL;
3271 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3272
3273 if(!pVosContext)
3274 {
3275 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3276 return;
3277 }
3278
3279 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3280 if(!pHddCtx) {
3281 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3282 "%s: HDD context is Null", __func__);
3283 return;
3284 }
3285
3286 pHddCtx->rx_wow_dump = value;
3287}
3288
3289/**
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05303290 * vos_set_hdd_bad_sta() - Set bad link peer sta id
3291 * @sta_id: sta id of the bad peer
3292 *
3293 * Return none.
3294 */
3295void vos_set_hdd_bad_sta(uint8_t sta_id)
3296{
3297 hdd_context_t *pHddCtx = NULL;
3298 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3299
3300 if(!pVosContext)
3301 {
3302 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3303 return;
3304 }
3305
3306 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3307 if(!pHddCtx) {
3308 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3309 "%s: HDD context is Null", __func__);
3310 return;
3311 }
3312
3313 pHddCtx->bad_sta[sta_id] = 1;
3314}
3315
3316/**
3317 * vos_reset_hdd_bad_sta() - Reset the bad peer sta_id
3318 * @sta_id: sta id of the peer
3319 *
3320 * Return none.
3321 */
3322void vos_reset_hdd_bad_sta(uint8_t sta_id)
3323{
3324 hdd_context_t *pHddCtx = NULL;
3325 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3326
3327 if(!pVosContext) {
3328 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3329 return;
3330 }
3331
3332 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3333 if(!pHddCtx) {
3334 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3335 "%s: HDD context is Null", __func__);
3336 return;
3337 }
3338
3339 pHddCtx->bad_sta[sta_id] = 0;
3340}
3341
3342/**
Abhishek Singh880d7122015-08-26 16:23:04 +05303343 * vos_probe_threads() - VOS API to post messages
3344 * to all the threads to detect if they are active or not
3345 *
3346 * Return none.
3347 *
3348 */
3349void vos_probe_threads(void)
3350{
3351 vos_msg_t msg;
3352
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303353 msg.callback = vos_wd_reset_thread_stuck_count;
Abhishek Singh880d7122015-08-26 16:23:04 +05303354 /* Post Message to MC Thread */
3355 sysBuildMessageHeader(SYS_MSG_ID_MC_THR_PROBE, &msg);
3356 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SYS, &msg)) {
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303357 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3358 FL("Unable to post SYS_MSG_ID_MC_THR_PROBE message to MC thread"));
Abhishek Singh880d7122015-08-26 16:23:04 +05303359 }
3360
3361 /* Post Message to Tx Thread */
3362 sysBuildMessageHeader(SYS_MSG_ID_TX_THR_PROBE, &msg);
3363 if (VOS_STATUS_SUCCESS != vos_tx_mq_serialize(VOS_MQ_ID_SYS, &msg)) {
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303364 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3365 FL("Unable to post SYS_MSG_ID_TX_THR_PROBE message to TX thread"));
Abhishek Singh880d7122015-08-26 16:23:04 +05303366 }
3367
3368 /* Post Message to Rx Thread */
3369 sysBuildMessageHeader(SYS_MSG_ID_RX_THR_PROBE, &msg);
3370 if (VOS_STATUS_SUCCESS != vos_rx_mq_serialize(VOS_MQ_ID_SYS, &msg)) {
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303371 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3372 FL("Unable to post SYS_MSG_ID_RX_THR_PROBE message to RX thread"));
Abhishek Singh880d7122015-08-26 16:23:04 +05303373 }
3374}
3375
Sushant Kaushik8e644982015-09-23 12:18:54 +05303376/**
3377 * vos_set_ring_log_level() - Convert HLOS values to driver log levels
3378 * @ring_id: ring_id
3379 * @log_levelvalue: Log level specificed
3380 *
3381 * This function sets the log level of a particular ring
3382 *
3383 * Return: None
3384 */
3385 void vos_set_ring_log_level(v_U32_t ring_id, v_U32_t log_level)
3386{
3387 VosContextType *vos_context;
3388 v_U32_t log_val;
3389
3390 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3391 if (!vos_context) {
3392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3393 "%s: vos context is Invald", __func__);
3394 return;
3395 }
3396
3397 switch (log_level) {
3398 case LOG_LEVEL_NO_COLLECTION:
3399 log_val = WLAN_LOG_LEVEL_OFF;
3400 break;
3401 case LOG_LEVEL_NORMAL_COLLECT:
3402 log_val = WLAN_LOG_LEVEL_NORMAL;
3403 break;
3404 case LOG_LEVEL_ISSUE_REPRO:
3405 log_val = WLAN_LOG_LEVEL_REPRO;
3406 break;
3407 case LOG_LEVEL_ACTIVE:
3408 default:
3409 log_val = WLAN_LOG_LEVEL_ACTIVE;
3410 break;
3411 }
3412
3413 if (ring_id == RING_ID_WAKELOCK) {
3414 vos_context->wakelock_log_level = log_val;
3415 return;
3416 } else if (ring_id == RING_ID_CONNECTIVITY) {
3417 vos_context->connectivity_log_level = log_val;
3418 return;
3419 } else if (ring_id == RING_ID_PER_PACKET_STATS) {
3420 vos_context->packet_stats_log_level = log_val;
Sushant Kaushik33200572015-08-05 16:46:20 +05303421 if (WLAN_LOG_LEVEL_ACTIVE != log_val)
3422 wlan_disable_and_flush_pkt_stats();
3423
Sushant Kaushik8e644982015-09-23 12:18:54 +05303424 return;
3425 }
3426}
3427/**
3428 * vos_get_ring_log_level() - Get the a ring id's log level
3429 * @ring_id: Ring id
3430 *
3431 * Fetch and return the log level corresponding to a ring id
3432 *
3433 * Return: Log level corresponding to the ring ID
3434 */
3435v_U8_t vos_get_ring_log_level(v_U32_t ring_id)
3436{
3437 VosContextType *vos_context;
3438
3439 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3440 if (!vos_context) {
3441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3442 "%s: vos context is Invald", __func__);
3443 return WLAN_LOG_LEVEL_OFF;
3444 }
3445
3446 if (ring_id == RING_ID_WAKELOCK)
3447 return vos_context->wakelock_log_level;
3448 else if (ring_id == RING_ID_CONNECTIVITY)
3449 return vos_context->connectivity_log_level;
3450 else if (ring_id == RING_ID_PER_PACKET_STATS)
3451 return vos_context->packet_stats_log_level;
3452
3453 return WLAN_LOG_LEVEL_OFF;
3454}
Sushant Kaushik33200572015-08-05 16:46:20 +05303455
3456/* elements are rate, preamable, bw, short_gi */
3457rateidx_to_rate_bw_preamble_sgi rateidx_to_rate_bw_preamble_sgi_table[] =
3458{
3459/*11B CCK Long preamble (0-3)*/
3460{ 10, PREAMBLE_CCK, S_BW20, 0},{ 20, PREAMBLE_CCK, S_BW20, 0},
3461{ 55, PREAMBLE_CCK, S_BW20, 0},{ 110, PREAMBLE_CCK, S_BW20, 0},
3462/*11B CCK Short preamble (4-7)*/
3463{ 10, PREAMBLE_CCK, S_BW20, 0},{ 20, PREAMBLE_CCK, S_BW20, 0},
3464{ 55, PREAMBLE_CCK, S_BW20, 0},{ 110, PREAMBLE_CCK, S_BW20, 0},
3465/*11G/A (8-15)*/
3466{ 60, PREAMBLE_OFDM, S_BW20, 0},{ 90, PREAMBLE_OFDM, S_BW20, 0},
3467{ 120, PREAMBLE_OFDM, S_BW20, 0},{ 180, PREAMBLE_OFDM, S_BW20, 0},
3468{ 240, PREAMBLE_OFDM, S_BW20, 0},{ 360, PREAMBLE_OFDM, S_BW20, 0},
3469{ 480, PREAMBLE_OFDM, S_BW20, 0},{ 540, PREAMBLE_OFDM, S_BW20, 0},
3470/*HT20 LGI MCS 0-7 (16-23)*/
3471{ 65, PREAMBLE_HT, S_BW20, 0},{ 130, PREAMBLE_HT, S_BW20, 0},
3472{ 195, PREAMBLE_HT, S_BW20, 0},{ 260, PREAMBLE_HT, S_BW20, 0},
3473{ 390, PREAMBLE_HT, S_BW20, 0},{ 520, PREAMBLE_HT, S_BW20, 0},
3474{ 585, PREAMBLE_HT, S_BW20, 0},{ 650, PREAMBLE_HT, S_BW20, 0},
3475/*HT20 SGI MCS 0-7 (24-31)*/
3476{ 72, PREAMBLE_HT, S_BW20, 1},{ 144, PREAMBLE_HT, S_BW20, 1},
3477{ 217, PREAMBLE_HT, S_BW20, 1},{ 289, PREAMBLE_HT, S_BW20, 1},
3478{ 433, PREAMBLE_HT, S_BW20, 1},{ 578, PREAMBLE_HT, S_BW20, 1},
3479{ 650, PREAMBLE_HT, S_BW20, 1},{ 722, PREAMBLE_HT, S_BW20, 1},
3480/*HT20 Greenfield MCS 0-7 rates (32-39)*/
3481{ 65, PREAMBLE_HT, S_BW20, 0},{ 130, PREAMBLE_HT, S_BW20, 0},
3482{ 195, PREAMBLE_HT, S_BW20, 0},{ 260, PREAMBLE_HT, S_BW20, 0},
3483{ 390, PREAMBLE_HT, S_BW20, 0},{ 520, PREAMBLE_HT, S_BW20, 0},
3484{ 585, PREAMBLE_HT, S_BW20, 0},{ 650, PREAMBLE_HT, S_BW20, 0},
3485/*HT40 LGI MCS 0-7 (40-47)*/
3486{ 135, PREAMBLE_HT, S_BW40, 0},{ 270, PREAMBLE_HT, S_BW40, 0},
3487{ 405, PREAMBLE_HT, S_BW40, 0},{ 540, PREAMBLE_HT, S_BW40, 0},
3488{ 810, PREAMBLE_HT, S_BW40, 0},{ 1080, PREAMBLE_HT, S_BW40, 0},
3489{ 1215, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3490/*HT40 SGI MCS 0-7 (48-55)*/
3491{ 150, PREAMBLE_HT, S_BW40, 1},{ 300, PREAMBLE_HT, S_BW40, 1},
3492{ 450, PREAMBLE_HT, S_BW40, 1},{ 600, PREAMBLE_HT, S_BW40, 1},
3493{ 900, PREAMBLE_HT, S_BW40, 1},{ 1200, PREAMBLE_HT, S_BW40, 1},
3494{ 1350, PREAMBLE_HT, S_BW40, 1},{ 1500, PREAMBLE_HT, S_BW40, 1},
3495/*HT40 Greenfield MCS 0-7 rates (56-63) 64-65 are dummy*/
3496{ 135, PREAMBLE_HT, S_BW40, 0},{ 270, PREAMBLE_HT, S_BW40, 0},
3497{ 405, PREAMBLE_HT, S_BW40, 0},{ 540, PREAMBLE_HT, S_BW40, 0},
3498{ 810, PREAMBLE_HT, S_BW40, 0},{ 1080, PREAMBLE_HT, S_BW40, 0},
3499{ 1215, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3500/*64-65 are dummy*/
3501{ 1350, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3502/*VHT20 LGI MCS 0-9 rates (66-75)*/
3503{ 65, PREAMBLE_VHT, S_BW20, 0},{ 130, PREAMBLE_VHT, S_BW20, 0},
3504{ 195, PREAMBLE_VHT, S_BW20, 0},{ 260, PREAMBLE_VHT, S_BW20, 0},
3505{ 390, PREAMBLE_VHT, S_BW20, 0},{ 520, PREAMBLE_VHT, S_BW20, 0},
3506{ 585, PREAMBLE_VHT, S_BW20, 0},{ 650, PREAMBLE_VHT, S_BW20, 0},
3507{ 780, PREAMBLE_VHT, S_BW20, 0},{ 865, PREAMBLE_VHT, S_BW20, 0},
3508/*76-77 are dummy*/
3509{ 865, PREAMBLE_VHT, S_BW20, 0},{ 865, PREAMBLE_VHT, S_BW20, 0},
3510/*VHT20 SGI MCS 0-9 rates (78-87)*/
3511{ 72, PREAMBLE_VHT, S_BW20, 1},{ 144, PREAMBLE_VHT, S_BW20, 1},
3512{ 217, PREAMBLE_VHT, S_BW20, 1},{ 289, PREAMBLE_VHT, S_BW20, 1},
3513{ 433, PREAMBLE_VHT, S_BW20, 1},{ 578, PREAMBLE_VHT, S_BW20, 1},
3514{ 650, PREAMBLE_VHT, S_BW20, 1},{ 722, PREAMBLE_VHT, S_BW20, 1},
3515{ 867, PREAMBLE_VHT, S_BW20, 1},{ 961, PREAMBLE_VHT, S_BW20, 1},
3516/*88-89 are dummy*/
3517{ 961, PREAMBLE_VHT, S_BW20, 1},{ 961, PREAMBLE_VHT, S_BW20, 1},
3518/*VHT40 LGI MCS 0-9 rates (90-101) 98,101 is Dummy*/
3519{ 135, PREAMBLE_VHT, S_BW40, 0},{ 270, PREAMBLE_VHT, S_BW40, 0},
3520{ 405, PREAMBLE_VHT, S_BW40, 0},{ 540, PREAMBLE_VHT, S_BW40, 0},
3521{ 810, PREAMBLE_VHT, S_BW40, 0},{ 1080, PREAMBLE_VHT, S_BW40, 0},
3522{ 1215, PREAMBLE_VHT, S_BW40, 0},{ 1350, PREAMBLE_VHT, S_BW40, 0},
3523{ 1350, PREAMBLE_VHT, S_BW40, 0},{ 1620, PREAMBLE_VHT, S_BW40, 0},
3524{ 1800, PREAMBLE_VHT, S_BW40, 0},{ 1800, PREAMBLE_VHT, S_BW40, 0},
3525/*VHT40 SGI MCS 0-9 rates (102-112) 110, 113 is Dummy*/
3526{ 150, PREAMBLE_VHT, S_BW40, 1},{ 300, PREAMBLE_VHT, S_BW40, 1},
3527{ 450, PREAMBLE_VHT, S_BW40, 1},{ 600, PREAMBLE_VHT, S_BW40, 1},
3528{ 900, PREAMBLE_VHT, S_BW40, 1},{ 1200, PREAMBLE_VHT, S_BW40, 1},
3529{ 1350, PREAMBLE_VHT, S_BW40, 1},{ 1500, PREAMBLE_VHT, S_BW40, 1},
3530{ 1500, PREAMBLE_VHT, S_BW40, 1},{ 1800, PREAMBLE_VHT, S_BW40, 1},
3531{ 2000, PREAMBLE_VHT, S_BW40, 1},{ 2000, PREAMBLE_VHT, S_BW40, 1},
3532/*VHT80 LGI MCS 0-9 rates (114-125) 122, 125 is Dummy*/
3533{ 293, PREAMBLE_VHT, S_BW80, 0},{ 585, PREAMBLE_VHT, S_BW80, 0},
3534{ 878, PREAMBLE_VHT, S_BW80, 0},{ 1170, PREAMBLE_VHT, S_BW80, 0},
3535{ 1755, PREAMBLE_VHT, S_BW80, 0},{ 2340, PREAMBLE_VHT, S_BW80, 0},
3536{ 2633, PREAMBLE_VHT, S_BW80, 0},{ 2925, PREAMBLE_VHT, S_BW80, 0},
3537{ 2925, PREAMBLE_VHT, S_BW80, 0},{ 3510, PREAMBLE_VHT, S_BW80, 0},
3538{ 3900, PREAMBLE_VHT, S_BW80, 0},{ 3900, PREAMBLE_VHT, S_BW80, 0},
3539/*VHT80 SGI MCS 0-9 rates (126-136) 134 is Dummy*/
3540{ 325, PREAMBLE_VHT, S_BW80, 1},{ 650, PREAMBLE_VHT, S_BW80, 1},
3541{ 975, PREAMBLE_VHT, S_BW80, 1},{ 1300, PREAMBLE_VHT, S_BW80, 1},
3542{ 1950, PREAMBLE_VHT, S_BW80, 1},{ 2600, PREAMBLE_VHT, S_BW80, 1},
3543{ 2925, PREAMBLE_VHT, S_BW80, 1},{ 3250, PREAMBLE_VHT, S_BW80, 1},
3544{ 3250, PREAMBLE_VHT, S_BW80, 1},{ 3900, PREAMBLE_VHT, S_BW80, 1},
3545{ 4333, PREAMBLE_VHT, S_BW80, 1},
3546};
3547
3548void get_rate_and_MCS(per_packet_stats *stats, uint32 rateindex)
3549{
3550 rateidx_to_rate_bw_preamble_sgi *ratetbl;
3551
3552 if (STATS_MAX_RATE_INDEX < rateindex)
3553 rateindex = STATS_MAX_RATE_INDEX;
3554 ratetbl= &rateidx_to_rate_bw_preamble_sgi_table[rateindex];
3555 stats->last_transmit_rate = ratetbl->rate/5;
3556 stats->MCS.nss = 0;
3557 if (0 <= rateindex && rateindex <= 7)
3558 stats->MCS.rate = 7 - rateindex;
3559 else if (8 <= rateindex && rateindex <= 15)
3560 {
3561 switch(rateindex)
3562 {
3563 case 8:stats->MCS.rate = 3; break;
3564 case 9:stats->MCS.rate = 7; break;
3565 case 10:stats->MCS.rate = 2; break;
3566 case 11:stats->MCS.rate = 6; break;
3567 case 12:stats->MCS.rate = 1; break;
3568 case 13:stats->MCS.rate = 5; break;
3569 case 14:stats->MCS.rate = 0; break;
3570 case 15:stats->MCS.rate = 4; break;
3571 }
3572 }
3573 else if(16 <= rateindex && rateindex <= 23)
3574 stats->MCS.rate = rateindex - 16;
3575 else if(24 <= rateindex && rateindex <= 31)
3576 stats->MCS.rate = rateindex - 24;
3577 else if(32 <= rateindex && rateindex <= 39)
3578 stats->MCS.rate = rateindex - 32;
3579 else if(40 <= rateindex && rateindex <= 47)
3580 stats->MCS.rate = rateindex - 40;
3581 else if(48 <= rateindex && rateindex <= 55)
3582 stats->MCS.rate = rateindex - 48;
3583 else if(56 <= rateindex && rateindex <= 63)
3584 stats->MCS.rate = rateindex - 56;
3585 else if(66 <= rateindex && rateindex <= 75)
3586 stats->MCS.rate = rateindex - 66;
3587 else if(78 <= rateindex && rateindex <= 87)
3588 stats->MCS.rate = rateindex - 78;
3589 else if(90 <= rateindex && rateindex <= 100)
3590 stats->MCS.rate = rateindex - 90;
3591 else if(78 <= rateindex && rateindex <= 87)
3592 stats->MCS.rate = rateindex - 78;
3593 else if(90 <= rateindex && rateindex <= 97)
3594 stats->MCS.rate = rateindex - 90;
3595 else if(99 <= rateindex && rateindex <= 100)
3596 stats->MCS.rate = rateindex - 91;
3597 else if(102 <= rateindex && rateindex <= 109)
3598 stats->MCS.rate = rateindex - 102;
3599 else if(111 <= rateindex && rateindex <= 112)
3600 stats->MCS.rate = rateindex - 103;
3601 else if(114 <= rateindex && rateindex <= 121)
3602 stats->MCS.rate = rateindex - 114;
3603 else if(123 <= rateindex && rateindex <= 124)
3604 stats->MCS.rate = rateindex - 115;
3605 else if(126 <= rateindex && rateindex <= 133)
3606 stats->MCS.rate = rateindex - 126;
3607 else if(135 <= rateindex && rateindex <= 136)
3608 stats->MCS.rate = rateindex - 127;
3609 else /*Invalid rate index mark it 0*/
3610 stats->MCS.rate = 0;
3611 stats->MCS.preamble = ratetbl->preamble;
3612 stats->MCS.bw = ratetbl->bw;
3613 stats->MCS.short_gi = ratetbl->short_gi;
3614}
3615
3616bool vos_isPktStatsEnabled(void)
3617{
3618 bool value;
3619 value = wlan_isPktStatsEnabled();
3620 return (value);
3621}
Manjeet Singh87a6eb72016-06-28 19:23:55 +05303622
3623bool vos_is_wlan_logging_enabled(void)
3624{
3625 v_CONTEXT_t vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3626 hdd_context_t *hdd_ctx;
3627
3628 if(!vos_ctx)
3629 {
3630 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3631 return false;
3632 }
3633
3634 hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx);
3635
3636 if(!hdd_ctx)
3637 {
3638 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null", __func__);
3639 return false;
3640 }
3641
3642 if (!hdd_ctx->cfg_ini->wlanLoggingEnable)
3643 {
3644 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Logging framework not enabled!", __func__);
3645 return false;
3646 }
3647
3648 return true;
3649}
Rajeev Kumar Sirasanagandla63f85cf2016-06-29 16:52:15 +05303650
3651/**---------------------------------------------------------------------------
3652
3653 \brief vos_is_probe_rsp_offload_enabled -
3654
3655 API to check if probe response offload feature is enabled from ini
3656
3657 \param - None
3658
3659 \return - 0: probe response offload is disabled
3660 1: probe response offload is enabled
3661
3662 --------------------------------------------------------------------------*/
3663v_BOOL_t vos_is_probe_rsp_offload_enabled(void)
3664{
3665 hdd_context_t *pHddCtx = NULL;
3666 v_CONTEXT_t pVosContext = NULL;
3667
3668 /* Get the Global VOSS Context */
3669 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3670 if (!pVosContext) {
3671 hddLog(VOS_TRACE_LEVEL_FATAL,
3672 "%s: Global VOS context is Null", __func__);
3673 return FALSE;
3674 }
3675
3676 /* Get the HDD context */
3677 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD,
3678 pVosContext);
3679 if (!pHddCtx) {
3680 hddLog(VOS_TRACE_LEVEL_FATAL,
3681 "%s: HDD context is Null", __func__);
3682 return FALSE;
3683 }
3684
3685 return pHddCtx->cfg_ini->sap_probe_resp_offload;
3686}
Abhishek Singh8a3e4dc2017-01-02 10:39:18 +05303687
3688
3689/**
3690 * vos_set_snoc_high_freq_voting() - enable/disable high freq voting
3691 * @enable: true if need to be enabled
3692 *
3693 * enable/disable high freq voting
3694 *
3695 * Return: Void
3696 */
3697#ifdef HAVE_WCNSS_SNOC_HIGH_FREQ_VOTING
3698void vos_set_snoc_high_freq_voting(bool enable)
3699{
3700 VosContextType *vos_ctx = NULL;
3701
3702 /* Get the Global VOSS Context */
3703 vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3704
3705 if (!vos_ctx) {
3706 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3707 "%s: vos context is NULL", __func__);
3708 return;
3709 }
3710
3711 spin_lock(&vos_ctx->freq_voting_lock);
3712 if (vos_ctx->snoc_high_freq_voting != enable)
3713 {
3714 vos_ctx->snoc_high_freq_voting = enable;
3715 spin_unlock(&vos_ctx->freq_voting_lock);
3716 wcnss_snoc_vote(enable);
3717 return;
3718 }
3719 spin_unlock(&vos_ctx->freq_voting_lock);
3720}
3721#else
3722void vos_set_snoc_high_freq_voting(bool enable)
3723{
3724 return;
3725}
3726#endif
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +05303727
3728void vos_smd_dump_stats(void)
3729{
3730 WCTS_Dump_Smd_status();
3731}
3732
3733void vos_log_wdi_event(uint16 msg, vos_wdi_trace_event_type event)
3734{
3735
3736 if (gvos_wdi_msg_trace_index >= VOS_TRACE_INDEX_MAX)
3737 {
3738 gvos_wdi_msg_trace_index = 0;
3739 }
3740
3741 gvos_wdi_msg_trace[gvos_wdi_msg_trace_index].event = event;
3742 gvos_wdi_msg_trace[gvos_wdi_msg_trace_index].time =
3743 vos_get_monotonic_boottime();
3744 gvos_wdi_msg_trace[gvos_wdi_msg_trace_index].message = msg;
3745 gvos_wdi_msg_trace_index++;
3746
3747 return;
3748}
3749
3750void vos_dump_wdi_events(void)
3751{
3752 int i;
3753
3754 for(i = 0; i < VOS_TRACE_INDEX_MAX; i++) {
3755 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3756 "%s:event:%d time:%lld msg:%d ",__func__,
3757 gvos_wdi_msg_trace[i].event,
3758 gvos_wdi_msg_trace[i].time,
3759 gvos_wdi_msg_trace[i].message);
3760 }
3761}