blob: 6dd7f8cd7f88998101145dfb2627fbf117d3679b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Hanumanth Reddy Pothulabe7ff0c2018-02-26 18:20:09 +05302 * Copyright (c) 2012-2018 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
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +0530106/* ARP Target IP offset */
107#define VOS_ARP_TARGET_IP_OFFSET 58
108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109/*---------------------------------------------------------------------------
110 * Data definitions
111 * ------------------------------------------------------------------------*/
112static VosContextType gVosContext;
113static pVosContextType gpVosContext;
Sushant Kaushik215778f2015-05-21 14:05:36 +0530114static v_U8_t vos_multicast_logging;
Jeff Johnson295189b2012-06-20 16:38:30 -0700115
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +0530116struct vos_wdi_trace
117{
118 vos_wdi_trace_event_type event;
119 uint16 message;
120 uint64 time;
121};
122
123static struct vos_wdi_trace gvos_wdi_msg_trace[VOS_TRACE_INDEX_MAX];
124uint16 gvos_wdi_msg_trace_index = 0;
125
Jeff Johnson295189b2012-06-20 16:38:30 -0700126/*---------------------------------------------------------------------------
127 * Forward declaration
128 * ------------------------------------------------------------------------*/
129v_VOID_t vos_sys_probe_thread_cback ( v_VOID_t *pUserData );
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131v_VOID_t vos_core_return_msg(v_PVOID_t pVContext, pVosMsgWrapper pMsgWrapper);
132
133v_VOID_t vos_fetch_tl_cfg_parms ( WLANTL_ConfigInfoType *pTLConfig,
134 hdd_config_t * pConfig );
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136
137/*---------------------------------------------------------------------------
138
139 \brief vos_preOpen() - PreOpen the vOSS Module
140
141 The \a vos_preOpen() function allocates the Vos Context, but do not
142 initialize all the members. This overal initialization will happen
143 at vos_Open().
144 The reason why we need vos_preOpen() is to get a minimum context
145 where to store BAL and SAL relative data, which happens before
146 vos_Open() is called.
147
148 \param pVosContext: A pointer to where to store the VOS Context
149
150
151 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
152 is ready to be used.
153
154 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
155
156 \sa vos_Open()
157
158---------------------------------------------------------------------------*/
159VOS_STATUS vos_preOpen ( v_CONTEXT_t *pVosContext )
160{
161 if ( pVosContext == NULL)
162 return VOS_STATUS_E_FAILURE;
163
164 /* Allocate the VOS Context */
165 *pVosContext = NULL;
166 gpVosContext = &gVosContext;
167
168 if (NULL == gpVosContext)
169 {
170 /* Critical Error ...Cannot proceed further */
171 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
172 "%s: Failed to allocate VOS Context", __func__);
173 VOS_ASSERT(0);
174 return VOS_STATUS_E_RESOURCES;
175 }
176
177 vos_mem_zero(gpVosContext, sizeof(VosContextType));
178
179 *pVosContext = gpVosContext;
180
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700181 /* Initialize the spinlock */
182 vos_trace_spin_lock_init();
183 /* it is the right time to initialize MTRACE structures */
184 #if defined(TRACE_RECORD)
185 vosTraceInit();
186 #endif
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530187 vos_register_debugcb_init();
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700188
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 return VOS_STATUS_SUCCESS;
190
191} /* vos_preOpen()*/
192
193
194/*---------------------------------------------------------------------------
195
196 \brief vos_preClose() - PreClose the vOSS Module
197
198 The \a vos_preClose() function frees the Vos Context.
199
200 \param pVosContext: A pointer to where the VOS Context was stored
201
202
203 \return VOS_STATUS_SUCCESS - Always successful
204
205
206 \sa vos_preClose()
207 \sa vos_close()
208---------------------------------------------------------------------------*/
209VOS_STATUS vos_preClose( v_CONTEXT_t *pVosContext )
210{
211
212 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
213 "%s: De-allocating the VOS Context", __func__);
214
215 if (( pVosContext == NULL) || (*pVosContext == NULL))
216 {
217 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
218 "%s: vOS Context is Null", __func__);
219 return VOS_STATUS_E_FAILURE;
220 }
221
222 if (gpVosContext != *pVosContext)
223 {
224 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
225 "%s: Context mismatch", __func__);
226 return VOS_STATUS_E_FAILURE;
227 }
228
229 *pVosContext = gpVosContext = NULL;
230
231 return VOS_STATUS_SUCCESS;
232
233} /* vos_preClose()*/
234
235/*---------------------------------------------------------------------------
236
237 \brief vos_open() - Open the vOSS Module
238
239 The \a vos_open() function opens the vOSS Scheduler
240 Upon successful initialization:
241
242 - All VOS submodules should have been initialized
243
244 - The VOS scheduler should have opened
245
246 - All the WLAN SW components should have been opened. This includes
247 SYS, MAC, SME, WDA and TL.
248
249
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530250 \param devHandle: pointer to the OS specific device handle
Jeff Johnson295189b2012-06-20 16:38:30 -0700251
252
253 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
254 is ready to be used.
255
256 VOS_STATUS_E_RESOURCES - System resources (other than memory)
257 are unavailable to initilize the scheduler
258
259
260 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
261
262 \sa vos_preOpen()
263
264---------------------------------------------------------------------------*/
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530265VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, void *devHandle )
Jeff Johnson295189b2012-06-20 16:38:30 -0700266
267{
268 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
269 int iter = 0;
270 tSirRetStatus sirStatus = eSIR_SUCCESS;
271 tMacOpenParameters macOpenParms;
272 WLANTL_ConfigInfoType TLConfig;
273
274 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
275 "%s: Opening VOSS", __func__);
276
277 if (NULL == gpVosContext)
278 {
279 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
280 "%s: Trying to open VOSS without a PreOpen", __func__);
281 VOS_ASSERT(0);
282 return VOS_STATUS_E_FAILURE;
283 }
284
285 /* Initialize the timer module */
286 vos_timer_module_init();
287
288 /* Initialize the probe event */
289 if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
290 {
291 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
292 "%s: Unable to init probeEvent", __func__);
293 VOS_ASSERT(0);
294 return VOS_STATUS_E_FAILURE;
295 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
297 {
298 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
299 "%s: Unable to init wdaCompleteEvent", __func__);
300 VOS_ASSERT(0);
301
302 goto err_probe_event;
303 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530304 if (vos_event_init( &(gpVosContext->fwLogsComplete) ) != VOS_STATUS_SUCCESS )
305 {
306 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
307 "%s: Unable to init fwLogsComplete", __func__);
308 VOS_ASSERT(0);
309
310 goto err_wda_complete_event;
311 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 /* Initialize the free message queue */
314 vStatus = vos_mq_init(&gpVosContext->freeVosMq);
315 if (! VOS_IS_STATUS_SUCCESS(vStatus))
316 {
317
318 /* Critical Error ... Cannot proceed further */
319 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
320 "%s: Failed to initialize VOS free message queue", __func__);
321 VOS_ASSERT(0);
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530322 goto err_fw_logs_complete_event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 }
324
325 for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
326 {
327 (gpVosContext->aMsgWrappers[iter]).pVosMsg =
328 &(gpVosContext->aMsgBuffers[iter]);
329 INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
330 vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
331 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700332
333 /* Now Open the VOS Scheduler */
334 vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
335 sizeof(VosSchedContext));
336
337 if (!VOS_IS_STATUS_SUCCESS(vStatus))
338 {
339 /* Critical Error ... Cannot proceed further */
340 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
341 "%s: Failed to open VOS Scheduler", __func__);
342 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 goto err_msg_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 }
345
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 /*
347 ** Need to open WDA first because it calls WDI_Init, which calls wpalOpen
348 ** The reason that is needed becasue vos_packet_open need to use PAL APIs
349 */
350
351 /*Open the WDA module */
352 vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
353 /* UMA is supported in hardware for performing the
354 ** frame translation 802.11 <-> 802.3
355 */
356 macOpenParms.frameTransRequired = 1;
357 macOpenParms.driverType = eDRIVER_TYPE_PRODUCTION;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530358 vStatus = WDA_open( gpVosContext, devHandle, &macOpenParms );
Jeff Johnson295189b2012-06-20 16:38:30 -0700359
360 if (!VOS_IS_STATUS_SUCCESS(vStatus))
361 {
362 /* Critical Error ... Cannot proceed further */
363 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
364 "%s: Failed to open WDA module", __func__);
365 VOS_ASSERT(0);
366 goto err_sched_close;
367 }
368
369 /* Initialize here the VOS Packet sub module */
370 vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
371 sizeof( vos_pkt_context_t ) );
372
373 if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
374 {
375 /* Critical Error ... Cannot proceed further */
376 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
377 "%s: Failed to open VOS Packet Module", __func__);
378 VOS_ASSERT(0);
379 goto err_wda_close;
380 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
382 /* Open the SYS module */
383 vStatus = sysOpen(gpVosContext);
384
385 if (!VOS_IS_STATUS_SUCCESS(vStatus))
386 {
387 /* Critical Error ... Cannot proceed further */
388 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
389 "%s: Failed to open SYS module", __func__);
390 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 goto err_packet_close;
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 }
393
Amar Singhal0a402232013-10-11 20:57:16 -0700394#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 /* initialize the NV module */
396 vStatus = vos_nv_open();
397 if (!VOS_IS_STATUS_SUCCESS(vStatus))
398 {
399 // NV module cannot be initialized
400 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
401 "%s: Failed to initialize the NV module", __func__);
402 goto err_sys_close;
403 }
Amar Singhal0a402232013-10-11 20:57:16 -0700404#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700405
406 /* If we arrive here, both threads dispacthing messages correctly */
407
408 /* Now proceed to open the MAC */
409
410 /* UMA is supported in hardware for performing the
411 frame translation 802.11 <-> 802.3 */
412 macOpenParms.frameTransRequired = 1;
413 sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
414 &macOpenParms);
415
416 if (eSIR_SUCCESS != sirStatus)
417 {
418 /* Critical Error ... Cannot proceed further */
419 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
420 "%s: Failed to open MAC", __func__);
421 VOS_ASSERT(0);
422 goto err_nv_close;
423 }
424
425 /* Now proceed to open the SME */
426 vStatus = sme_Open(gpVosContext->pMACContext);
427 if (!VOS_IS_STATUS_SUCCESS(vStatus))
428 {
429 /* Critical Error ... Cannot proceed further */
430 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
431 "%s: Failed to open SME", __func__);
432 VOS_ASSERT(0);
433 goto err_mac_close;
434 }
435
436 /* Now proceed to open TL. Read TL config first */
437 vos_fetch_tl_cfg_parms ( &TLConfig,
438 ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);
439
440 vStatus = WLANTL_Open(gpVosContext, &TLConfig);
441 if (!VOS_IS_STATUS_SUCCESS(vStatus))
442 {
443 /* Critical Error ... Cannot proceed further */
444 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
445 "%s: Failed to open TL", __func__);
446 VOS_ASSERT(0);
447 goto err_sme_close;
448 }
449
Girish Gowlifb0bfd32015-01-13 11:42:11 +0530450 if (gpVosContext->roamDelayStatsEnabled &&
451 !vos_roam_delay_stats_init())
452 {
453 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
454 "%s: Could not init roamDelayStats", __func__);
455 }
456
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
458 "%s: VOSS successfully Opened", __func__);
459
Abhishek Singh8a3e4dc2017-01-02 10:39:18 +0530460 gpVosContext->snoc_high_freq_voting = false;
461 spin_lock_init(&gpVosContext->freq_voting_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 *pVosContext = gpVosContext;
463
464 return VOS_STATUS_SUCCESS;
465
466
467err_sme_close:
468 sme_Close(gpVosContext->pMACContext);
469
470err_mac_close:
471 macClose(gpVosContext->pMACContext);
472
473err_nv_close:
Amar Singhal0a402232013-10-11 20:57:16 -0700474
475#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 vos_nv_close();
Amar Singhal0a402232013-10-11 20:57:16 -0700477
478err_sys_close:
479#endif
480
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 sysClose(gpVosContext);
482
Jeff Johnson295189b2012-06-20 16:38:30 -0700483err_packet_close:
484 vos_packet_close( gpVosContext );
485
486err_wda_close:
487 WDA_close(gpVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488
Amar Singhal0a402232013-10-11 20:57:16 -0700489err_sched_close:
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 vos_sched_close(gpVosContext);
491
Jeff Johnson295189b2012-06-20 16:38:30 -0700492
493err_msg_queue:
494 vos_mq_deinit(&gpVosContext->freeVosMq);
495
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530496err_fw_logs_complete_event:
497 vos_event_destroy( &gpVosContext->fwLogsComplete);
498
Jeff Johnson295189b2012-06-20 16:38:30 -0700499err_wda_complete_event:
500 vos_event_destroy( &gpVosContext->wdaCompleteEvent );
Jeff Johnson295189b2012-06-20 16:38:30 -0700501
502err_probe_event:
503 vos_event_destroy(&gpVosContext->ProbeEvent);
504
505 return VOS_STATUS_E_FAILURE;
506
507} /* vos_open() */
508
Jeff Johnson295189b2012-06-20 16:38:30 -0700509/*---------------------------------------------------------------------------
510
511 \brief vos_preStart() -
512
513 The \a vos_preStart() function to download CFG.
514 including:
515 - ccmStart
516
517 - WDA: triggers the CFG download
518
519
520 \param pVosContext: The VOS context
521
522
523 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
524 is ready to be used.
525
526 VOS_STATUS_E_RESOURCES - System resources (other than memory)
527 are unavailable to initilize the scheduler
528
529
530 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
531
532 \sa vos_start
533
534---------------------------------------------------------------------------*/
535VOS_STATUS vos_preStart( v_CONTEXT_t vosContext )
536{
537 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
538 pVosContextType pVosContext = (pVosContextType)vosContext;
539
540 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
541 "vos prestart");
542
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800543 if (gpVosContext != pVosContext)
544 {
545 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
546 "%s: Context mismatch", __func__);
547 VOS_ASSERT(0);
548 return VOS_STATUS_E_INVAL;
549 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700550
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800551 if (pVosContext->pMACContext == NULL)
552 {
553 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
554 "%s: MAC NULL context", __func__);
555 VOS_ASSERT(0);
556 return VOS_STATUS_E_INVAL;
557 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700558
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800559 if (pVosContext->pWDAContext == NULL)
560 {
561 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
562 "%s: WDA NULL context", __func__);
563 VOS_ASSERT(0);
564 return VOS_STATUS_E_INVAL;
565 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
567 /* call macPreStart */
568 vStatus = macPreStart(gpVosContext->pMACContext);
569 if ( !VOS_IS_STATUS_SUCCESS(vStatus) )
570 {
571 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
572 "Failed at macPreStart ");
573 return VOS_STATUS_E_FAILURE;
574 }
575
576 /* call ccmStart */
577 ccmStart(gpVosContext->pMACContext);
578
579 /* Reset wda wait event */
580 vos_event_reset(&gpVosContext->wdaCompleteEvent);
581
582
583 /*call WDA pre start*/
584 vStatus = WDA_preStart(gpVosContext);
585 if (!VOS_IS_STATUS_SUCCESS(vStatus))
586 {
587 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_FATAL,
588 "Failed to WDA prestart");
589 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
590 ccmStop(gpVosContext->pMACContext);
591 VOS_ASSERT(0);
592 return VOS_STATUS_E_FAILURE;
593 }
594
595 /* Need to update time out of complete */
596 vStatus = vos_wait_single_event( &gpVosContext->wdaCompleteEvent,
597 VOS_WDA_TIMEOUT );
598 if ( vStatus != VOS_STATUS_SUCCESS )
599 {
600 if ( vStatus == VOS_STATUS_E_TIMEOUT )
601 {
602 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800603 "%s: Timeout occurred before WDA complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 }
605 else
606 {
607 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
608 "%s: WDA_preStart reporting other error", __func__);
609 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700610 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
611 "%s: Test MC thread by posting a probe message to SYS", __func__);
612 wlan_sys_probe();
613
Jeff Johnsone7245742012-09-05 17:12:55 -0700614 macStop(gpVosContext->pMACContext, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
615 ccmStop(gpVosContext->pMACContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 VOS_ASSERT( 0 );
617 return VOS_STATUS_E_FAILURE;
618 }
619
620 return VOS_STATUS_SUCCESS;
621}
Jeff Johnson295189b2012-06-20 16:38:30 -0700622
Katya Nigame7b69a82015-04-28 15:24:06 +0530623VOS_STATUS vos_mon_start( v_CONTEXT_t vosContext )
624{
625 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
626 pVosContextType pVosContext = (pVosContextType)vosContext;
627
628 if (pVosContext == NULL)
629 {
630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
631 "%s: mismatch in context",__func__);
632 return VOS_STATUS_E_FAILURE;
633 }
634
635 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pTLContext == NULL))
636 {
637 if (pVosContext->pWDAContext == NULL)
638 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
639 "%s: WDA NULL context", __func__);
640 else
641 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
642 "%s: TL NULL context", __func__);
643
644 return VOS_STATUS_E_FAILURE;
645 }
646
647 /* Reset wda wait event */
648 vos_event_reset(&pVosContext->wdaCompleteEvent);
649
650 /*call WDA pre start*/
651 vStatus = WDA_preStart(pVosContext);
652 if (!VOS_IS_STATUS_SUCCESS(vStatus))
653 {
654 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
655 "Failed to WDA prestart ");
656 VOS_ASSERT(0);
657 return VOS_STATUS_E_FAILURE;
658 }
659
660 /* Need to update time out of complete */
661 vStatus = vos_wait_single_event( &pVosContext->wdaCompleteEvent, 1000);
662 if ( vStatus != VOS_STATUS_SUCCESS )
663 {
664 if ( vStatus == VOS_STATUS_E_TIMEOUT )
665 {
666 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
667 "%s: Timeout occurred before WDA complete",__func__);
668 }
669 else
670 {
671 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
672 "%s: WDA_preStart reporting other error",__func__);
673 }
674 VOS_ASSERT( 0 );
675 return VOS_STATUS_E_FAILURE;
676 }
677
678 vStatus = WDA_NVDownload_Start(pVosContext);
679
680 if ( vStatus != VOS_STATUS_SUCCESS )
681 {
682 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
683 "%s: Failed to start NV Download",__func__);
684 return VOS_STATUS_E_FAILURE;
685 }
686
687 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000 * 30);
688
689 if ( vStatus != VOS_STATUS_SUCCESS )
690 {
691 if ( vStatus == VOS_STATUS_E_TIMEOUT )
692 {
693 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
694 "%s: Timeout occurred before WDA_NVDownload_Start complete",__func__);
695 }
696 else
697 {
698 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
699 "%s: WDA_NVDownload_Start reporting other error",__func__);
700 }
701 VOS_ASSERT(0);
702 return VOS_STATUS_E_FAILURE;
703 }
704
705 vStatus = WDA_start(pVosContext);
706 if (vStatus != VOS_STATUS_SUCCESS)
707 {
708 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
709 "%s: Failed to start WDA",__func__);
710 return VOS_STATUS_E_FAILURE;
711 }
712
713 /** START TL */
714 vStatus = WLANTL_Start(pVosContext);
715 if (!VOS_IS_STATUS_SUCCESS(vStatus))
716 {
717 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
718 "%s: Failed to start TL", __func__);
719 goto err_wda_stop;
720 }
721
722 return VOS_STATUS_SUCCESS;
723
724err_wda_stop:
725 vos_event_reset(&(pVosContext->wdaCompleteEvent));
726 WDA_stop(pVosContext, HAL_STOP_TYPE_RF_KILL);
727 vStatus = vos_wait_single_event(&(pVosContext->wdaCompleteEvent), 1000);
728 if(vStatus != VOS_STATUS_SUCCESS)
729 {
730 if(vStatus == VOS_STATUS_E_TIMEOUT)
731 {
732 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
733 "%s: Timeout occurred before WDA_stop complete",__func__);
734
735 }
736 else
737 {
738 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
739 "%s: WDA_stop reporting other error",__func__);
740 }
741 VOS_ASSERT(0);
742 }
743 return VOS_STATUS_E_FAILURE;
744}
745
746VOS_STATUS vos_mon_stop( v_CONTEXT_t vosContext )
747{
748 VOS_STATUS vosStatus;
749
750 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
751
Bhargav Shah1ae5de02015-07-20 13:32:31 +0530752 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
753 "%s: HAL_STOP is requested", __func__);
754
Katya Nigame7b69a82015-04-28 15:24:06 +0530755 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
756
757 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
758 {
759 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
760 "%s: Failed to stop WDA", __func__);
761 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
762 WDA_setNeedShutdown(vosContext);
763 }
764 else
765 {
766 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
767 VOS_WDA_STOP_TIMEOUT );
768
769 if ( vosStatus != VOS_STATUS_SUCCESS )
770 {
771 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
772 {
773 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
774 "%s: Timeout occurred before WDA complete", __func__);
775 }
776 else
777 {
778 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
779 "%s: WDA_stop reporting other error", __func__ );
780 }
781 WDA_setNeedShutdown(vosContext);
782 }
783 }
784
785 vosStatus = WLANTL_Stop( vosContext );
786 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
787 {
788 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
789 "%s: Failed to stop TL", __func__);
790 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
791 }
792
793 return VOS_STATUS_SUCCESS;
794}
795
Jeff Johnson295189b2012-06-20 16:38:30 -0700796/*---------------------------------------------------------------------------
797
798 \brief vos_start() - Start the Libra SW Modules
799
800 The \a vos_start() function starts all the components of the Libra SW
801 including:
802 - SAL/BAL, which in turn starts SSC
803
804 - the MAC (HAL and PE)
805
806 - SME
807
808 - TL
809
810 - SYS: triggers the CFG download
811
812
813 \param pVosContext: The VOS context
814
815
816 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
817 is ready to be used.
818
819 VOS_STATUS_E_RESOURCES - System resources (other than memory)
820 are unavailable to initilize the scheduler
821
822
823 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
824
825 \sa vos_preStart()
826 \sa vos_open()
827
828---------------------------------------------------------------------------*/
829VOS_STATUS vos_start( v_CONTEXT_t vosContext )
830{
831 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
832 tSirRetStatus sirStatus = eSIR_SUCCESS;
833 pVosContextType pVosContext = (pVosContextType)vosContext;
834 tHalMacStartParameters halStartParams;
Srinivas Dasaric14dac82016-03-01 19:24:55 +0530835 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700836
837 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
838 "%s: Starting Libra SW", __func__);
839
840 /* We support only one instance for now ...*/
841 if (gpVosContext != pVosContext)
842 {
843 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700844 "%s: mismatch in context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 return VOS_STATUS_E_FAILURE;
846 }
847
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 if (( pVosContext->pWDAContext == NULL) || ( pVosContext->pMACContext == NULL)
849 || ( pVosContext->pTLContext == NULL))
850 {
851 if (pVosContext->pWDAContext == NULL)
852 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700853 "%s: WDA NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 else if (pVosContext->pMACContext == NULL)
855 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700856 "%s: MAC NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 else
858 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700859 "%s: TL NULL context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700860
861 return VOS_STATUS_E_FAILURE;
862 }
863
864 /* WDA_Start will be called after NV image download because the
865 NV image data has to be updated at HAL before HAL_Start gets executed*/
866
867 /* Start the NV Image Download */
868
869 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
870
871 vStatus = WDA_NVDownload_Start(pVosContext);
872
873 if ( vStatus != VOS_STATUS_SUCCESS )
874 {
875 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
876 "%s: Failed to start NV Download", __func__);
877 return VOS_STATUS_E_FAILURE;
878 }
879
880 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
881 VOS_WDA_TIMEOUT );
882
883 if ( vStatus != VOS_STATUS_SUCCESS )
884 {
885 if ( vStatus == VOS_STATUS_E_TIMEOUT )
886 {
887 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
888 "%s: Timeout occurred before WDA_NVDownload_start complete", __func__);
889 }
890 else
891 {
892 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
893 "%s: WDA_NVDownload_start reporting other error", __func__);
894 }
895 VOS_ASSERT(0);
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800896 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700897 if (vos_is_logp_in_progress(VOS_MODULE_ID_VOSS, NULL))
898 {
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530899 if (isSsrPanicOnFailure())
900 VOS_BUG(0);
Sameer Thalappilb511beb2013-09-09 17:11:51 -0700901 }
Madan Mohan Koyyalamudiec231f82012-11-28 16:01:28 -0800902 WDA_setNeedShutdown(vosContext);
903 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 }
905
906 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
907 "%s: WDA_NVDownload_start correctly started", __func__);
908
909 /* Start the WDA */
910 vStatus = WDA_start(pVosContext);
911 if ( vStatus != VOS_STATUS_SUCCESS )
912 {
913 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530914 "%s: Failed to start WDA - WDA_shutdown needed %d ",
915 __func__, vStatus);
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530916 if ( vStatus == VOS_STATUS_E_TIMEOUT )
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530917 {
Siddharth Bhalbea38ad2014-10-12 14:10:52 +0530918 WDA_setNeedShutdown(vosContext);
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +0530919 vos_smd_dump_stats();
920 vos_dump_wdi_events();
921 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
922 "%s: Test MC thread by posting a probe message to SYS",
923 __func__);
924 wlan_sys_probe();
Hanumantha Reddy Pothulab5c67c02015-07-14 21:27:50 +0530925 }
926 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 return VOS_STATUS_E_FAILURE;
928 }
929 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
930 "%s: WDA correctly started", __func__);
931
Srinivas Dasaric14dac82016-03-01 19:24:55 +0530932 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
933 if (!pHddCtx)
934 {
935 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
936 "%s: HDD context is null", __func__);
937 goto err_wda_stop;
938 }
939
940 pHddCtx->wifi_turn_on_time_since_boot = vos_get_monotonic_boottime();
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 /* Start the MAC */
943 vos_mem_zero((v_PVOID_t)&halStartParams, sizeof(tHalMacStartParameters));
944
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 /* Start the MAC */
946 sirStatus = macStart(pVosContext->pMACContext,(v_PVOID_t)&halStartParams);
947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 if (eSIR_SUCCESS != sirStatus)
949 {
950 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
951 "%s: Failed to start MAC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 goto err_wda_stop;
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 }
954
955 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
956 "%s: MAC correctly started", __func__);
957
958 /* START SME */
959 vStatus = sme_Start(pVosContext->pMACContext);
960
961 if (!VOS_IS_STATUS_SUCCESS(vStatus))
962 {
963 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
964 "%s: Failed to start SME", __func__);
965 goto err_mac_stop;
966 }
967
968 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
969 "%s: SME correctly started", __func__);
970
971 /** START TL */
972 vStatus = WLANTL_Start(pVosContext);
973 if (!VOS_IS_STATUS_SUCCESS(vStatus))
974 {
975 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
976 "%s: Failed to start TL", __func__);
977 goto err_sme_stop;
978 }
979
980 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
981 "TL correctly started");
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
983 "%s: VOSS Start is successful!!", __func__);
984
985 return VOS_STATUS_SUCCESS;
986
Jeff Johnson295189b2012-06-20 16:38:30 -0700987
988err_sme_stop:
Kiet Lama72a2322013-11-15 11:18:11 +0530989 sme_Stop(pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700990
991err_mac_stop:
992 macStop( pVosContext->pMACContext, HAL_STOP_TYPE_SYS_RESET );
993
Jeff Johnson295189b2012-06-20 16:38:30 -0700994err_wda_stop:
995 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800996 vStatus = WDA_stop( pVosContext, HAL_STOP_TYPE_RF_KILL);
997 if (!VOS_IS_STATUS_SUCCESS(vStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 {
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -0800999 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1000 "%s: Failed to stop WDA", __func__);
1001 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001002 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001003 }
1004 else
1005 {
1006 vStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
1007 VOS_WDA_TIMEOUT );
1008 if( vStatus != VOS_STATUS_SUCCESS )
1009 {
1010 if( vStatus == VOS_STATUS_E_TIMEOUT )
1011 {
1012 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1013 "%s: Timeout occurred before WDA_stop complete", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001014
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001015 }
1016 else
1017 {
1018 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1019 "%s: WDA_stop reporting other error", __func__);
1020 }
1021 VOS_ASSERT( 0 );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001022 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001025
1026 return VOS_STATUS_E_FAILURE;
1027
1028} /* vos_start() */
1029
1030
1031/* vos_stop function */
1032VOS_STATUS vos_stop( v_CONTEXT_t vosContext )
1033{
1034 VOS_STATUS vosStatus;
1035
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 /* WDA_Stop is called before the SYS so that the processing of Riva
1037 pending responces will not be handled during uninitialization of WLAN driver */
1038 vos_event_reset( &(gpVosContext->wdaCompleteEvent) );
1039
1040 vosStatus = WDA_stop( vosContext, HAL_STOP_TYPE_RF_KILL );
1041
1042 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1043 {
1044 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1045 "%s: Failed to stop WDA", __func__);
1046 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001047 WDA_setNeedShutdown(vosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 }
Madan Mohan Koyyalamudia2fc6412012-10-21 12:06:12 -07001049 else
1050 {
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301051 if(wcnss_device_is_shutdown())
1052 {
1053 vosStatus = VOS_STATUS_E_TIMEOUT;
1054 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1055 "%s: Wait for WDA_Stop complete event not needed due to SSR",
1056 __func__);
1057 }
1058 else
1059 {
1060 vosStatus = vos_wait_single_event( &(gpVosContext->wdaCompleteEvent),
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001061 VOS_WDA_STOP_TIMEOUT );
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05301062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001064 if ( vosStatus != VOS_STATUS_SUCCESS )
1065 {
1066 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1067 {
1068 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1069 "%s: Timeout occurred before WDA complete", __func__);
1070 }
1071 else
1072 {
1073 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1074 "%s: WDA_stop reporting other error", __func__ );
1075 }
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -07001076 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1077 "%s: Test MC thread by posting a probe message to SYS", __func__);
1078 wlan_sys_probe();
Madan Mohan Koyyalamudi9d7a27f2012-11-28 15:55:25 -08001079 WDA_setNeedShutdown(vosContext);
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08001080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001082
1083 /* SYS STOP will stop SME and MAC */
1084 vosStatus = sysStop( vosContext);
1085 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1086 {
1087 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1088 "%s: Failed to stop SYS", __func__);
1089 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1090 }
1091
1092 vosStatus = WLANTL_Stop( vosContext );
1093 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1094 {
1095 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1096 "%s: Failed to stop TL", __func__);
1097 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1098 }
1099
Jeff Johnson295189b2012-06-20 16:38:30 -07001100
1101 return VOS_STATUS_SUCCESS;
1102}
1103
1104
1105/* vos_close function */
1106VOS_STATUS vos_close( v_CONTEXT_t vosContext )
1107{
1108 VOS_STATUS vosStatus;
1109
1110#ifdef WLAN_BTAMP_FEATURE
1111 vosStatus = WLANBAP_Close(vosContext);
1112 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1113 {
1114 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1115 "%s: Failed to close BAP", __func__);
1116 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1117 }
1118#endif // WLAN_BTAMP_FEATURE
1119
1120
1121 vosStatus = WLANTL_Close(vosContext);
1122 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1123 {
1124 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1125 "%s: Failed to close TL", __func__);
1126 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1127 }
1128
1129 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
1130 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1131 {
1132 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1133 "%s: Failed to close SME", __func__);
1134 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1135 }
1136
1137 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
1138 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1139 {
1140 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1141 "%s: Failed to close MAC", __func__);
1142 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1143 }
1144
1145 ((pVosContextType)vosContext)->pMACContext = NULL;
1146
Amar Singhal0a402232013-10-11 20:57:16 -07001147#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 vosStatus = vos_nv_close();
1149 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1150 {
1151 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1152 "%s: Failed to close NV", __func__);
1153 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1154 }
Amar Singhal0a402232013-10-11 20:57:16 -07001155#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001156
1157 vosStatus = sysClose( vosContext );
1158 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1159 {
1160 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1161 "%s: Failed to close SYS", __func__);
1162 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1163 }
1164
Jeff Johnsone7245742012-09-05 17:12:55 -07001165 if ( TRUE == WDA_needShutdown(vosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001167 /* if WDA stop failed, call WDA shutdown to cleanup WDA/WDI */
1168 vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
1169 if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
1170 {
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07001171 hdd_set_ssr_required( HDD_SSR_REQUIRED );
Jeff Johnsone7245742012-09-05 17:12:55 -07001172 }
1173 else
1174 {
1175 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1176 "%s: Failed to shutdown WDA", __func__ );
1177 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1178 }
1179 }
1180 else
1181 {
1182 vosStatus = WDA_close( vosContext );
1183 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1184 {
1185 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1186 "%s: Failed to close WDA", __func__);
1187 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 }
1190
1191 /* Let DXE return packets in WDA_close and then free them here */
1192 vosStatus = vos_packet_close( vosContext );
1193 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1194 {
1195 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1196 "%s: Failed to close VOSS Packet", __func__);
1197 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001199
Jeff Johnson295189b2012-06-20 16:38:30 -07001200
1201 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
1202
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301203 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
1204 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1205 {
1206 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1207 "%s: failed to destroy fwLogsComplete", __func__);
1208 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1209 }
1210
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
1212 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1213 {
1214 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1215 "%s: failed to destroy wdaCompleteEvent", __func__);
1216 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001218
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301219
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
1221 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1222 {
1223 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1224 "%s: failed to destroy ProbeEvent", __func__);
1225 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
1226 }
1227
Girish Gowlifb0bfd32015-01-13 11:42:11 +05301228 if (gpVosContext->roamDelayStatsEnabled &&
1229 !vos_roam_delay_stats_deinit())
1230 {
1231 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1232 "%s: Could not deinit roamDelayStats", __func__);
1233 }
1234
Mahesh A Saptasagara67b86d2016-04-26 21:20:41 +05301235 vos_wdthread_flush_timer_work();
1236
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 return VOS_STATUS_SUCCESS;
1238}
1239
1240
1241/**---------------------------------------------------------------------------
1242
1243 \brief vos_get_context() - get context data area
1244
1245 Each module in the system has a context / data area that is allocated
1246 and maanged by voss. This API allows any user to get a pointer to its
1247 allocated context data area from the VOSS global context.
1248
1249 \param vosContext - the VOSS Global Context.
1250
1251 \param moduleId - the module ID, who's context data are is being retrived.
1252
1253 \return - pointer to the context data area.
1254
1255 - NULL if the context data is not allocated for the module ID
1256 specified
1257
1258 --------------------------------------------------------------------------*/
1259v_VOID_t* vos_get_context( VOS_MODULE_ID moduleId,
1260 v_CONTEXT_t pVosContext )
1261{
1262 v_PVOID_t pModContext = NULL;
1263
1264 if (pVosContext == NULL)
1265 {
1266 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001267 "%s: vos context pointer is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 return NULL;
1269 }
1270
1271 if (gpVosContext != pVosContext)
1272 {
1273 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001274 "%s: pVosContext != gpVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 return NULL;
1276 }
1277
1278 switch(moduleId)
1279 {
1280 case VOS_MODULE_ID_TL:
1281 {
1282 pModContext = gpVosContext->pTLContext;
1283 break;
1284 }
1285
Jeff Johnson295189b2012-06-20 16:38:30 -07001286#ifdef WLAN_BTAMP_FEATURE
1287 case VOS_MODULE_ID_BAP:
1288 {
1289 pModContext = gpVosContext->pBAPContext;
1290 break;
1291 }
1292#endif //WLAN_BTAMP_FEATURE
1293
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 case VOS_MODULE_ID_SAP:
1295 {
1296 pModContext = gpVosContext->pSAPContext;
1297 break;
1298 }
1299
1300 case VOS_MODULE_ID_HDD_SOFTAP:
1301 {
1302 pModContext = gpVosContext->pHDDSoftAPContext;
1303 break;
1304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001305
1306 case VOS_MODULE_ID_HDD:
1307 {
1308 pModContext = gpVosContext->pHDDContext;
1309 break;
1310 }
1311
1312 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301314 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 {
1316 /*
1317 ** In all these cases, we just return the MAC Context
1318 */
1319 pModContext = gpVosContext->pMACContext;
1320 break;
1321 }
1322
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 case VOS_MODULE_ID_WDA:
1324 {
1325 /* For WDA module */
1326 pModContext = gpVosContext->pWDAContext;
1327 break;
1328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001329
1330 case VOS_MODULE_ID_VOSS:
1331 {
1332 /* For SYS this is VOS itself*/
1333 pModContext = gpVosContext;
1334 break;
1335 }
1336
1337 default:
1338 {
1339 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1340 "does not have its context maintained by VOSS", __func__, moduleId);
1341 VOS_ASSERT(0);
1342 return NULL;
1343 }
1344 }
1345
1346 if (pModContext == NULL )
1347 {
1348 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1349 "context is Null", __func__, moduleId);
1350 }
1351
1352 return pModContext;
1353
1354} /* vos_get_context()*/
1355
1356
1357/**---------------------------------------------------------------------------
1358
1359 \brief vos_get_global_context() - get VOSS global Context
1360
1361 This API allows any user to get the VOS Global Context pointer from a
1362 module context data area.
1363
1364 \param moduleContext - the input module context pointer
1365
1366 \param moduleId - the module ID who's context pointer is input in
1367 moduleContext.
1368
1369 \return - pointer to the VOSS global context
1370
1371 - NULL if the function is unable to retreive the VOSS context.
1372
1373 --------------------------------------------------------------------------*/
1374v_CONTEXT_t vos_get_global_context( VOS_MODULE_ID moduleId,
1375 v_VOID_t *moduleContext )
1376{
1377 if (gpVosContext == NULL)
1378 {
1379 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001380 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 }
1382
1383 return gpVosContext;
1384
1385} /* vos_get_global_context() */
1386
1387
1388v_U8_t vos_is_logp_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1389{
1390 if (gpVosContext == NULL)
1391 {
1392 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001393 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 return 1;
1395 }
1396
1397 return gpVosContext->isLogpInProgress;
1398}
1399
1400void vos_set_logp_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1401{
1402 if (gpVosContext == NULL)
1403 {
1404 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001405 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 return;
1407 }
1408
1409 gpVosContext->isLogpInProgress = value;
1410}
1411
1412v_U8_t vos_is_load_unload_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1413{
1414 if (gpVosContext == NULL)
1415 {
1416 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001417 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 return 0;
1419 }
1420
1421 return gpVosContext->isLoadUnloadInProgress;
1422}
1423
1424void vos_set_load_unload_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1425{
1426 if (gpVosContext == NULL)
1427 {
1428 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001429 "%s: global voss context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 return;
1431 }
1432
1433 gpVosContext->isLoadUnloadInProgress = value;
1434}
1435
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07001436v_U8_t vos_is_reinit_in_progress(VOS_MODULE_ID moduleId, v_VOID_t *moduleContext)
1437{
1438 if (gpVosContext == NULL)
1439 {
1440 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1441 "%s: global voss context is NULL", __func__);
1442 return 1;
1443 }
1444
1445 return gpVosContext->isReInitInProgress;
1446}
1447
1448void vos_set_reinit_in_progress(VOS_MODULE_ID moduleId, v_U8_t value)
1449{
1450 if (gpVosContext == NULL)
1451 {
1452 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1453 "%s: global voss context is NULL", __func__);
1454 return;
1455 }
1456
1457 gpVosContext->isReInitInProgress = value;
1458}
1459
1460
Jeff Johnson295189b2012-06-20 16:38:30 -07001461/**---------------------------------------------------------------------------
1462
1463 \brief vos_alloc_context() - allocate a context within the VOSS global Context
1464
1465 This API allows any user to allocate a user context area within the
1466 VOS Global Context.
1467
1468 \param pVosContext - pointer to the global Vos context
1469
1470 \param moduleId - the module ID who's context area is being allocated.
1471
1472 \param ppModuleContext - pointer to location where the pointer to the
1473 allocated context is returned. Note this
1474 output pointer is valid only if the API
1475 returns VOS_STATUS_SUCCESS
1476
1477 \param size - the size of the context area to be allocated.
1478
1479 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1480 allocated successfully. The pointer to the context area
1481 can be found in *ppModuleContext.
1482 \note This function returns VOS_STATUS_SUCCESS if the
1483 module context was already allocated and the size
1484 allocated matches the size on this call.
1485
1486 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1487 not identify a module that can have a context allocated.
1488
1489 VOS_STATUS_E_EXISTS - vos could allocate the requested context
1490 because a context for this module ID already exists and it is
1491 a *different* size that specified on this call.
1492
1493 VOS_STATUS_E_NOMEM - vos could not allocate memory for the
1494 requested context area.
1495
1496 \sa vos_get_context(), vos_free_context()
1497
1498 --------------------------------------------------------------------------*/
1499VOS_STATUS vos_alloc_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1500 v_VOID_t **ppModuleContext, v_SIZE_t size )
1501{
1502 v_VOID_t ** pGpModContext = NULL;
1503
1504 if ( pVosContext == NULL) {
1505 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001506 "%s: vos context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 return VOS_STATUS_E_FAILURE;
1508 }
1509
1510 if (( gpVosContext != pVosContext) || ( ppModuleContext == NULL)) {
1511 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001512 "%s: context mismatch or null param passed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 return VOS_STATUS_E_FAILURE;
1514 }
1515
1516 switch(moduleID)
1517 {
1518 case VOS_MODULE_ID_TL:
1519 {
1520 pGpModContext = &(gpVosContext->pTLContext);
1521 break;
1522 }
1523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524#ifdef WLAN_BTAMP_FEATURE
1525 case VOS_MODULE_ID_BAP:
1526 {
1527 pGpModContext = &(gpVosContext->pBAPContext);
1528 break;
1529 }
1530#endif //WLAN_BTAMP_FEATURE
1531
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 case VOS_MODULE_ID_SAP:
1533 {
1534 pGpModContext = &(gpVosContext->pSAPContext);
1535 break;
1536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001537
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 case VOS_MODULE_ID_WDA:
1539 {
1540 pGpModContext = &(gpVosContext->pWDAContext);
1541 break;
1542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301545 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 case VOS_MODULE_ID_HDD:
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 default:
1549 {
1550 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1551 "does not have its context allocated by VOSS", __func__, moduleID);
1552 VOS_ASSERT(0);
1553 return VOS_STATUS_E_INVAL;
1554 }
1555 }
1556
1557 if ( NULL != *pGpModContext)
1558 {
1559 /*
1560 ** Context has already been allocated!
1561 ** Prevent double allocation
1562 */
1563 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1564 "%s: Module ID %i context has already been allocated",
1565 __func__, moduleID);
1566 return VOS_STATUS_E_EXISTS;
1567 }
1568
1569 /*
1570 ** Dynamically allocate the context for module
1571 */
1572
1573 *ppModuleContext = kmalloc(size, GFP_KERNEL);
1574
1575
1576 if ( *ppModuleContext == NULL)
1577 {
1578 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Failed to "
1579 "allocate Context for module ID %i", __func__, moduleID);
1580 VOS_ASSERT(0);
1581 return VOS_STATUS_E_NOMEM;
1582 }
1583
1584 if (moduleID==VOS_MODULE_ID_TL)
1585 {
1586 vos_mem_zero(*ppModuleContext, size);
1587 }
1588
1589 *pGpModContext = *ppModuleContext;
1590
1591 return VOS_STATUS_SUCCESS;
1592
1593} /* vos_alloc_context() */
1594
1595
1596/**---------------------------------------------------------------------------
1597
1598 \brief vos_free_context() - free an allocated a context within the
1599 VOSS global Context
1600
1601 This API allows a user to free the user context area within the
1602 VOS Global Context.
1603
1604 \param pVosContext - pointer to the global Vos context
1605
1606 \param moduleId - the module ID who's context area is being free
1607
1608 \param pModuleContext - pointer to module context area to be free'd.
1609
1610 \return - VOS_STATUS_SUCCESS - the context for the module ID has been
1611 free'd. The pointer to the context area is not longer
1612 available.
1613
1614 VOS_STATUS_E_FAULT - pVosContext or pModuleContext are not
1615 valid pointers.
1616
1617 VOS_STATUS_E_INVAL - the moduleId is not a valid or does
1618 not identify a module that can have a context free'd.
1619
1620 VOS_STATUS_E_EXISTS - vos could not free the requested
1621 context area because a context for this module ID does not
1622 exist in the global vos context.
1623
1624 \sa vos_get_context()
1625
1626 --------------------------------------------------------------------------*/
1627VOS_STATUS vos_free_context( v_VOID_t *pVosContext, VOS_MODULE_ID moduleID,
1628 v_VOID_t *pModuleContext )
1629{
1630 v_VOID_t ** pGpModContext = NULL;
1631
1632 if (( pVosContext == NULL) || ( gpVosContext != pVosContext) ||
1633 ( pModuleContext == NULL))
1634 {
1635 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1636 "%s: Null params or context mismatch", __func__);
1637 return VOS_STATUS_E_FAILURE;
1638 }
1639
1640
1641 switch(moduleID)
1642 {
1643 case VOS_MODULE_ID_TL:
1644 {
1645 pGpModContext = &(gpVosContext->pTLContext);
1646 break;
1647 }
1648
Jeff Johnson295189b2012-06-20 16:38:30 -07001649#ifdef WLAN_BTAMP_FEATURE
1650 case VOS_MODULE_ID_BAP:
1651 {
1652 pGpModContext = &(gpVosContext->pBAPContext);
1653 break;
1654 }
1655#endif //WLAN_BTAMP_FEATURE
1656
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 case VOS_MODULE_ID_SAP:
1658 {
1659 pGpModContext = &(gpVosContext->pSAPContext);
1660 break;
1661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001662
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 case VOS_MODULE_ID_WDA:
1664 {
1665 pGpModContext = &(gpVosContext->pWDAContext);
1666 break;
1667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 case VOS_MODULE_ID_HDD:
1669 case VOS_MODULE_ID_SME:
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 case VOS_MODULE_ID_PE:
Katya Nigam70d68332013-09-16 16:49:45 +05301671 case VOS_MODULE_ID_PMC:
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 case VOS_MODULE_ID_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 default:
1674 {
1675 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: Module ID %i "
1676 "does not have its context allocated by VOSS", __func__, moduleID);
1677 VOS_ASSERT(0);
1678 return VOS_STATUS_E_INVAL;
1679 }
1680 }
1681
1682 if ( NULL == *pGpModContext)
1683 {
1684 /*
1685 ** Context has not been allocated or freed already!
1686 */
1687 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,"%s: Module ID %i "
1688 "context has not been allocated or freed already", __func__,moduleID);
1689 return VOS_STATUS_E_FAILURE;
1690 }
1691
1692 if (*pGpModContext != pModuleContext)
1693 {
1694 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001695 "%s: pGpModContext != pModuleContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 return VOS_STATUS_E_FAILURE;
1697 }
1698
1699 if(pModuleContext != NULL)
1700 kfree(pModuleContext);
1701
1702 *pGpModContext = NULL;
1703
1704 return VOS_STATUS_SUCCESS;
1705
1706} /* vos_free_context() */
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301707
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301708
1709bool vos_is_log_report_in_progress(void)
1710{
1711 return wlan_is_log_report_in_progress();
1712}
1713
1714void vos_reset_log_report_in_progress(void)
1715{
1716 return wlan_reset_log_report_in_progress();
1717}
1718
1719
1720
1721
1722int vos_set_log_completion(uint32 is_fatal,
1723 uint32 indicator,
1724 uint32 reason_code)
1725{
1726 return wlan_set_log_completion(is_fatal,
1727 indicator,reason_code);
1728}
1729
Abhishek Singh837adf22015-10-01 17:37:37 +05301730void vos_get_log_and_reset_completion(uint32 *is_fatal,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301731 uint32 *indicator,
Abhishek Singh837adf22015-10-01 17:37:37 +05301732 uint32 *reason_code,
1733 bool reset)
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301734{
Abhishek Singh837adf22015-10-01 17:37:37 +05301735 wlan_get_log_and_reset_completion(is_fatal, indicator, reason_code, reset);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301736}
1737
1738
1739
1740void vos_send_fatal_event_done(void)
1741{
1742 /*Complete the fwLogsComplete Event*/
1743 VosContextType *vos_context;
1744 uint32_t is_fatal, indicator, reason_code;
1745
1746 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1747 if (!vos_context) {
1748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1749 "%s: vos context is Invalid", __func__);
1750 return;
1751 }
1752 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1753 "%s: vos_event_set for fwLogsComplete", __func__);
1754 if (vos_event_set(&vos_context->fwLogsComplete)!= VOS_STATUS_SUCCESS)
1755 {
1756 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1757 "%s: vos_event_set failed for fwLogsComplete", __func__);
1758 return;
1759 }
1760 /*The below API will reset is_report_in_progress flag*/
Abhishek Singh837adf22015-10-01 17:37:37 +05301761 vos_get_log_and_reset_completion(&is_fatal, &indicator,
1762 &reason_code, true);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301763 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05301764 "is_fatal : %d, indicator: %d, reason_code=%d",
1765 is_fatal, indicator, reason_code);
1766 wlan_report_log_completion(is_fatal, indicator, reason_code);
1767
Abhishek Singh84fc7512015-10-06 14:27:25 +05301768 /* Do ssr after reporting fatal event to recover from
1769 * below conditions
1770 */
Abhishek Singh183e3682015-11-16 16:54:35 +05301771 if ((WLAN_LOG_INDICATOR_HOST_DRIVER == indicator) &&
1772 (WLAN_LOG_REASON_SME_COMMAND_STUCK == reason_code ||
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +05301773 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF == reason_code ||
1774 WLAN_LOG_REASON_SCAN_NOT_ALLOWED == reason_code))
Abhishek Singh183e3682015-11-16 16:54:35 +05301775 {
1776 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1777 "Do SSR for reason_code=%d", reason_code);
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05301778 vos_wlanRestart(VOS_GET_MSG_BUFF_FAILURE);
Abhishek Singh183e3682015-11-16 16:54:35 +05301779 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301780}
1781
Abhishek Singh837adf22015-10-01 17:37:37 +05301782/**
1783 * vos_isFatalEventEnabled()
1784 *
1785 * Return TRUE if Fatal event is enabled is in progress.
1786 *
1787 */
1788v_BOOL_t vos_isFatalEventEnabled(void)
1789{
1790 hdd_context_t *pHddCtx = NULL;
1791 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1792
1793 if(!pVosContext)
1794 {
1795 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
1796 return FALSE;
1797 }
1798
1799 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1800 if(!pHddCtx) {
1801 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1802 "%s: HDD context is Null", __func__);
1803 return FALSE;
1804 }
1805
1806 return pHddCtx->cfg_ini->enableFatalEvent;
1807}
1808
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301809/**---------------------------------------------------------------------------
1810
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301811 \brief __vos_fatal_event_logs_req() - used to send flush command to FW
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301812
1813 This API is wrapper to SME flush API.
1814
1815 \param is_fatal - fatal or non fatal event
1816 indicator - Tyoe of indicator framework/Host/FW
1817 reason_code - reason code for flush logs
1818
1819 \return VOS_STATUS_SUCCESS - if command is sent successfully.
1820 VOS_STATUS_E_FAILURE - if command is not sent successfully.
1821 --------------------------------------------------------------------------*/
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301822VOS_STATUS __vos_fatal_event_logs_req( uint32_t is_fatal,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301823 uint32_t indicator,
1824 uint32_t reason_code,
Abhishek Singh837adf22015-10-01 17:37:37 +05301825 bool wait_required,
1826 bool dump_vos_trace)
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301827{
1828 VOS_STATUS vosStatus;
1829 eHalStatus status;
1830 VosContextType *vos_context;
Abhishek Singh837adf22015-10-01 17:37:37 +05301831 hdd_context_t *pHddCtx = NULL;
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301832
1833 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1834 if (!vos_context)
1835 {
1836 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1837 "%s: vos context is Invalid", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301838 return VOS_STATUS_E_FAILURE;
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301839 }
Abhishek Singh837adf22015-10-01 17:37:37 +05301840 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, vos_context );
1841 if(!pHddCtx) {
1842 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
1843 "%s: HDD context is Null", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301844 return VOS_STATUS_E_FAILURE;
1845 }
1846
1847 if(!pHddCtx->cfg_ini->wlanLoggingEnable)
1848 {
1849 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1850 "%s: Wlan logging not enabled", __func__);
1851 return VOS_STATUS_E_FAILURE;
Abhishek Singh837adf22015-10-01 17:37:37 +05301852 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301853
Hanumanth Reddy Pothulae92bcc12017-05-19 13:56:35 +05301854 if (!pHddCtx->cfg_ini->enableFatalEvent || !pHddCtx->is_fatal_event_log_sup)
Abhishek Singh837adf22015-10-01 17:37:37 +05301855 {
1856 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
1857 "%s: Fatal event not enabled", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301858 return VOS_STATUS_E_FAILURE;
Abhishek Singh837adf22015-10-01 17:37:37 +05301859 }
1860
1861 if (pHddCtx->isLoadUnloadInProgress ||
1862 vos_context->isLogpInProgress)
1863 {
1864 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1865 "%s: un/Load/SSR in progress", __func__);
Manjeet Singh87a6eb72016-06-28 19:23:55 +05301866 return VOS_STATUS_E_FAILURE;
Abhishek Singh837adf22015-10-01 17:37:37 +05301867 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301868
1869 if (vos_is_log_report_in_progress() == true)
1870 {
1871 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1872 "%s: Fatal Event Req already in progress - dropping! type:%d, indicator=%d reason_code=%d",
1873 __func__, is_fatal, indicator, reason_code);
1874 return VOS_STATUS_E_FAILURE;
1875 }
1876
1877 vosStatus = vos_set_log_completion(is_fatal, indicator, reason_code);
1878 if (VOS_STATUS_SUCCESS != vosStatus) {
1879 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1880 "%s: Failed to set log trigger params for fatalEvent", __func__);
1881 return VOS_STATUS_E_FAILURE;
1882 }
Abhishek Singh837adf22015-10-01 17:37:37 +05301883 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301884 "%s: Triggering fatal Event: type:%d, indicator=%d reason_code=%d",
1885 __func__, is_fatal, indicator, reason_code);
1886
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301887 status = vos_event_reset(&gpVosContext->fwLogsComplete);
1888 if(!HAL_STATUS_SUCCESS(status))
1889 {
1890 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1891 FL("fwLogsComplete reset failed:%d"),status);
1892 return VOS_STATUS_E_FAILURE;
1893 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301894 status = sme_fatal_event_logs_req(vos_context->pMACContext,
1895 is_fatal, indicator,
Abhishek Singh837adf22015-10-01 17:37:37 +05301896 reason_code, dump_vos_trace);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301897
Abhishek Singh837adf22015-10-01 17:37:37 +05301898 if (HAL_STATUS_SUCCESS(status) && (wait_required == TRUE))
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301899 {
1900
1901 /* Need to update time out of complete */
1902 vosStatus = vos_wait_single_event(&gpVosContext->fwLogsComplete,
1903 WAIT_TIME_FW_LOGS);
1904 if ( vosStatus != VOS_STATUS_SUCCESS )
1905 {
1906 if ( vosStatus == VOS_STATUS_E_TIMEOUT )
1907 {
1908 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1909 "%s: Timeout occurred before fwLogsComplete", __func__);
1910 }
1911 else
1912 {
1913 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1914 "%s: fwLogsComplete reporting other error", __func__);
1915 }
1916 /*Done indication is not received.So reset the bug report in progress*/
1917 vos_reset_log_report_in_progress();
1918 return VOS_STATUS_E_FAILURE;
1919 }
1920 }
1921 if (HAL_STATUS_SUCCESS( status ))
1922 return VOS_STATUS_SUCCESS;
1923 else
1924 return VOS_STATUS_E_FAILURE;
1925}
1926
Hanumantha Reddy Pothula164bed12015-11-09 09:48:21 +05301927VOS_STATUS vos_fatal_event_logs_req( uint32_t is_fatal,
1928 uint32_t indicator,
1929 uint32_t reason_code,
1930 bool wait_required,
1931 bool dump_vos_trace)
1932{
1933 VOS_STATUS status;
1934
1935 vos_ssr_protect(__func__);
1936 status = __vos_fatal_event_logs_req(is_fatal, indicator, reason_code,
1937 wait_required, dump_vos_trace);
1938 vos_ssr_unprotect(__func__);
1939
1940 return status;
1941}
1942
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301943/**---------------------------------------------------------------------------
1944
1945 \brief vos_process_done_indication() - Process the done indication for fatal event,
1946 FW memory dump
1947
1948 This API processes the done indication and wakeup the logger thread accordingly.
1949
1950 \param type - Type for which done indication is received.
1951
1952
1953 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1954 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1955 a failure.
1956 --------------------------------------------------------------------------*/
1957
1958VOS_STATUS vos_process_done_indication(v_U8_t type, v_U32_t reason_code)
1959{
1960 wlan_process_done_indication(type, reason_code);
1961 return VOS_STATUS_SUCCESS;
1962}
1963
Abhishek Singh837adf22015-10-01 17:37:37 +05301964/**
1965 * vos_flush_host_logs_for_fatal() -flush host logs and send
1966 * fatal event to upper layer.
1967 */
1968void vos_flush_host_logs_for_fatal(void)
1969{
1970 wlan_flush_host_logs_for_fatal();
1971 return;
1972}
1973
1974
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301975/**---------------------------------------------------------------------------
1976
1977 \brief vos_logger_pkt_serialize() - queue a logging vos pkt
1978
1979 This API allows single vos pkt to be queued and later sent to userspace by
1980 logger thread.
1981
1982 \param pPacket - a pointer to a vos pkt to be queued
1983 pkt_type - type of pkt to be queued
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301984
1985 \return VOS_STATUS_SUCCESS - the pkt has been successfully queued.
1986 VOS_STATUS_E_FAILURE - the pkt queue handler has reported
1987 a failure.
1988 --------------------------------------------------------------------------*/
Mihir Sheteccafc0c2015-04-17 16:13:15 +05301989VOS_STATUS vos_logger_pkt_serialize( vos_pkt_t *pPacket, uint32 pkt_type)
Siddharth Bhal7bd19932015-03-03 16:54:36 +05301990{
1991#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
1992 return wlan_queue_logpkt_for_app(pPacket, pkt_type);
1993#else
1994 return vos_pkt_return_packet(pPacket);
1995#endif
1996}
Jeff Johnson295189b2012-06-20 16:38:30 -07001997
Sushant Kaushik33200572015-08-05 16:46:20 +05301998void vos_per_pkt_stats_to_user(void *perPktStat)
1999{
2000#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
2001 wlan_pkt_stats_to_user(perPktStat);
2002#else
2003 return;
2004#endif
2005
2006
2007
2008}
2009
2010void vos_updatePktStatsInfo(void * pktStat)
2011{
2012#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
2013 wlan_fillTxStruct(pktStat);
2014#else
2015 return;
2016#endif
2017
2018}
2019
2020
Jeff Johnson295189b2012-06-20 16:38:30 -07002021/**---------------------------------------------------------------------------
2022
2023 \brief vos_mq_post_message() - post a message to a message queue
2024
2025 This API allows messages to be posted to a specific message queue. Messages
2026 can be posted to the following message queues:
2027
2028 <ul>
2029 <li> SME
2030 <li> PE
2031 <li> HAL
2032 <li> TL
2033 </ul>
2034
2035 \param msgQueueId - identifies the message queue upon which the message
2036 will be posted.
2037
2038 \param message - a pointer to a message buffer. Memory for this message
2039 buffer is allocated by the caller and free'd by the vOSS after the
2040 message is posted to the message queue. If the consumer of the
2041 message needs anything in this message, it needs to copy the contents
2042 before returning from the message queue handler.
2043
2044 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2045 to the message queue.
2046
2047 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2048 refer to a valid Message Queue Id.
2049
2050 VOS_STATUS_E_FAULT - message is an invalid pointer.
2051
2052 VOS_STATUS_E_FAILURE - the message queue handler has reported
2053 an unknown failure.
2054
2055 \sa
2056
2057 --------------------------------------------------------------------------*/
2058VOS_STATUS vos_mq_post_message( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2059{
2060 pVosMqType pTargetMq = NULL;
2061 pVosMsgWrapper pMsgWrapper = NULL;
2062
2063 if ((gpVosContext == NULL) || (pMsg == NULL))
2064 {
2065 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2066 "%s: Null params or global vos context is null", __func__);
2067 VOS_ASSERT(0);
2068 return VOS_STATUS_E_FAILURE;
2069 }
2070
2071 switch (msgQueueId)
2072 {
2073 /// Message Queue ID for messages bound for SME
2074 case VOS_MQ_ID_SME:
2075 {
2076 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
2077 break;
2078 }
2079
2080 /// Message Queue ID for messages bound for PE
2081 case VOS_MQ_ID_PE:
2082 {
2083 pTargetMq = &(gpVosContext->vosSched.peMcMq);
2084 break;
2085 }
2086
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 /// Message Queue ID for messages bound for WDA
2088 case VOS_MQ_ID_WDA:
2089 {
2090 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
2091 break;
2092 }
2093
2094 /// Message Queue ID for messages bound for WDI
2095 case VOS_MQ_ID_WDI:
2096 {
2097 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
2098 break;
2099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002100
2101 /// Message Queue ID for messages bound for TL
2102 case VOS_MQ_ID_TL:
2103 {
2104 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
2105 break;
2106 }
2107
2108 /// Message Queue ID for messages bound for the SYS module
2109 case VOS_MQ_ID_SYS:
2110 {
2111 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
2112 break;
2113 }
2114
2115 default:
2116
2117 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2118 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
2119 __func__, msgQueueId);
2120
2121 return VOS_STATUS_E_FAILURE;
2122 }
2123
2124 VOS_ASSERT(NULL !=pTargetMq);
2125 if (pTargetMq == NULL)
2126 {
2127 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002128 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 return VOS_STATUS_E_FAILURE;
2130 }
2131
2132 /*
2133 ** Try and get a free Msg wrapper
2134 */
2135 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2136
2137 if (NULL == pMsgWrapper)
2138 {
2139 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2140 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302141 if (!gpVosContext->vosWrapperFullReported)
2142 {
2143 gpVosContext->vosWrapperFullReported = 1;
2144 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2145 WLAN_LOG_INDICATOR_HOST_ONLY,
2146 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2147 FALSE, TRUE);
2148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 return VOS_STATUS_E_RESOURCES;
2150 }
2151
2152 /*
2153 ** Copy the message now
2154 */
2155 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2156 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2157
2158 vos_mq_put(pTargetMq, pMsgWrapper);
2159
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302160 set_bit(MC_POST_EVENT, &gpVosContext->vosSched.mcEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
2162
2163 return VOS_STATUS_SUCCESS;
2164
2165} /* vos_mq_post_message()*/
2166
2167
Padma, Santhosh Kumarb036fc72015-11-13 16:22:23 +05302168/**--------------------------------------------------------------------------
2169 \brief vos_mq_post_message_high_pri() - posts a high priority message to
2170 a message queue
2171
2172 This API allows messages to be posted to the head of a specific message
2173 queue. Messages can be posted to the following message queues:
2174
2175 <ul>
2176 <li> SME
2177 <li> PE
2178 <li> HAL
2179 <li> TL
2180 </ul>
2181
2182 \param msgQueueId - identifies the message queue upon which the message
2183 will be posted.
2184
2185 \param message - a pointer to a message buffer. Memory for this message
2186 buffer is allocated by the caller and free'd by the vOSS after the
2187 message is posted to the message queue. If the consumer of the
2188 message needs anything in this message, it needs to copy the contents
2189 before returning from the message queue handler.
2190
2191 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2192 to the message queue.
2193
2194 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2195 refer to a valid Message Queue Id.
2196
2197 VOS_STATUS_E_FAULT - message is an invalid pointer.
2198
2199 VOS_STATUS_E_FAILURE - the message queue handler has reported
2200 an unknown failure.
2201 --------------------------------------------------------------------------*/
2202VOS_STATUS vos_mq_post_message_high_pri(VOS_MQ_ID msgQueueId, vos_msg_t *pMsg)
2203{
2204 pVosMqType pTargetMq = NULL;
2205 pVosMsgWrapper pMsgWrapper = NULL;
2206
2207 if ((gpVosContext == NULL) || (pMsg == NULL))
2208 {
2209 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2210 "%s: Null params or global vos context is null", __func__);
2211 VOS_ASSERT(0);
2212 return VOS_STATUS_E_FAILURE;
2213 }
2214
2215 switch (msgQueueId)
2216 {
2217 /// Message Queue ID for messages bound for SME
2218 case VOS_MQ_ID_SME:
2219 {
2220 pTargetMq = &(gpVosContext->vosSched.smeMcMq);
2221 break;
2222 }
2223
2224 /// Message Queue ID for messages bound for PE
2225 case VOS_MQ_ID_PE:
2226 {
2227 pTargetMq = &(gpVosContext->vosSched.peMcMq);
2228 break;
2229 }
2230
2231 /// Message Queue ID for messages bound for WDA
2232 case VOS_MQ_ID_WDA:
2233 {
2234 pTargetMq = &(gpVosContext->vosSched.wdaMcMq);
2235 break;
2236 }
2237
2238 /// Message Queue ID for messages bound for WDI
2239 case VOS_MQ_ID_WDI:
2240 {
2241 pTargetMq = &(gpVosContext->vosSched.wdiMcMq);
2242 break;
2243 }
2244
2245 /// Message Queue ID for messages bound for TL
2246 case VOS_MQ_ID_TL:
2247 {
2248 pTargetMq = &(gpVosContext->vosSched.tlMcMq);
2249 break;
2250 }
2251
2252 /// Message Queue ID for messages bound for the SYS module
2253 case VOS_MQ_ID_SYS:
2254 {
2255 pTargetMq = &(gpVosContext->vosSched.sysMcMq);
2256 break;
2257 }
2258
2259 default:
2260
2261 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2262 ("%s: Trying to queue msg into unknown MC Msg queue ID %d"),
2263 __func__, msgQueueId);
2264
2265 return VOS_STATUS_E_FAILURE;
2266 }
2267
2268 VOS_ASSERT(NULL !=pTargetMq);
2269 if (pTargetMq == NULL)
2270 {
2271 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2272 "%s: pTargetMq == NULL", __func__);
2273 return VOS_STATUS_E_FAILURE;
2274 }
2275
2276 /*
2277 ** Try and get a free Msg wrapper
2278 */
2279 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2280
2281 if (NULL == pMsgWrapper)
2282 {
2283 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2284 "%s: VOS Core run out of message wrapper", __func__);
2285 if (!gpVosContext->vosWrapperFullReported)
2286 {
2287 gpVosContext->vosWrapperFullReported = 1;
2288 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2289 WLAN_LOG_INDICATOR_HOST_ONLY,
2290 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2291 FALSE, TRUE);
2292 }
2293 return VOS_STATUS_E_RESOURCES;
2294 }
2295
2296 /*
2297 ** Copy the message now
2298 */
2299 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2300 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2301
2302 vos_mq_put_front(pTargetMq, pMsgWrapper);
2303
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302304 set_bit(MC_POST_EVENT, &gpVosContext->vosSched.mcEventFlag);
Padma, Santhosh Kumarb036fc72015-11-13 16:22:23 +05302305 wake_up_interruptible(&gpVosContext->vosSched.mcWaitQueue);
2306
2307 return VOS_STATUS_SUCCESS;
2308
2309} /* vos_mq_post_message_high_pri()*/
2310
2311
2312
Jeff Johnson295189b2012-06-20 16:38:30 -07002313/**---------------------------------------------------------------------------
2314
2315 \brief vos_tx_mq_serialize() - serialize a message to the Tx execution flow
2316
2317 This API allows messages to be posted to a specific message queue in the
2318 Tx excution flow. Messages for the Tx execution flow can be posted only
2319 to the following queue.
2320
2321 <ul>
2322 <li> TL
2323 <li> SSC/WDI
2324 </ul>
2325
2326 \param msgQueueId - identifies the message queue upon which the message
2327 will be posted.
2328
2329 \param message - a pointer to a message buffer. Body memory for this message
2330 buffer is allocated by the caller and free'd by the vOSS after the
2331 message is dispacthed to the appropriate component. If the consumer
2332 of the message needs to keep anything in the body, it needs to copy
2333 the contents before returning from the message handler.
2334
2335 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2336 to the message queue.
2337
2338 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2339 refer to a valid Message Queue Id.
2340
2341 VOS_STATUS_E_FAULT - message is an invalid pointer.
2342
2343 VOS_STATUS_E_FAILURE - the message queue handler has reported
2344 an unknown failure.
2345
2346 \sa
2347
2348 --------------------------------------------------------------------------*/
2349VOS_STATUS vos_tx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2350{
2351 pVosMqType pTargetMq = NULL;
2352 pVosMsgWrapper pMsgWrapper = NULL;
2353
2354 if ((gpVosContext == NULL) || (pMsg == NULL))
2355 {
2356 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2357 "%s: Null params or global vos context is null", __func__);
2358 VOS_ASSERT(0);
2359 return VOS_STATUS_E_FAILURE;
2360 }
2361
2362 switch (msgQueueId)
2363 {
2364 /// Message Queue ID for messages bound for SME
2365 case VOS_MQ_ID_TL:
2366 {
2367 pTargetMq = &(gpVosContext->vosSched.tlTxMq);
2368 break;
2369 }
2370
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 /// Message Queue ID for messages bound for SSC
2372 case VOS_MQ_ID_WDI:
2373 {
2374 pTargetMq = &(gpVosContext->vosSched.wdiTxMq);
2375 break;
2376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002377
2378 /// Message Queue ID for messages bound for the SYS module
2379 case VOS_MQ_ID_SYS:
2380 {
2381 pTargetMq = &(gpVosContext->vosSched.sysTxMq);
2382 break;
2383 }
2384
2385 default:
2386
2387 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302388 "%s: Trying to queue msg into unknown Tx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 __func__, msgQueueId);
2390
2391 return VOS_STATUS_E_FAILURE;
2392 }
2393
2394 if (pTargetMq == NULL)
2395 {
2396 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002397 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 return VOS_STATUS_E_FAILURE;
2399 }
2400
2401
2402 /*
2403 ** Try and get a free Msg wrapper
2404 */
2405 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2406
2407 if (NULL == pMsgWrapper)
2408 {
2409 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2410 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302411 if (!gpVosContext->vosWrapperFullReported)
2412 {
2413 gpVosContext->vosWrapperFullReported = 1;
2414 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2415 WLAN_LOG_INDICATOR_HOST_ONLY,
2416 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2417 FALSE, TRUE);
2418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002419
2420 return VOS_STATUS_E_RESOURCES;
2421 }
2422
2423 /*
2424 ** Copy the message now
2425 */
2426 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2427 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2428
2429 vos_mq_put(pTargetMq, pMsgWrapper);
2430
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302431 set_bit(TX_POST_EVENT, &gpVosContext->vosSched.txEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 wake_up_interruptible(&gpVosContext->vosSched.txWaitQueue);
2433
2434 return VOS_STATUS_SUCCESS;
2435
2436} /* vos_tx_mq_serialize()*/
2437
Jeff Johnson295189b2012-06-20 16:38:30 -07002438/**---------------------------------------------------------------------------
2439
2440 \brief vos_rx_mq_serialize() - serialize a message to the Rx execution flow
2441
2442 This API allows messages to be posted to a specific message queue in the
2443 Tx excution flow. Messages for the Rx execution flow can be posted only
2444 to the following queue.
2445
2446 <ul>
2447 <li> TL
2448 <li> WDI
2449 </ul>
2450
2451 \param msgQueueId - identifies the message queue upon which the message
2452 will be posted.
2453
2454 \param message - a pointer to a message buffer. Body memory for this message
2455 buffer is allocated by the caller and free'd by the vOSS after the
2456 message is dispacthed to the appropriate component. If the consumer
2457 of the message needs to keep anything in the body, it needs to copy
2458 the contents before returning from the message handler.
2459
2460 \return VOS_STATUS_SUCCESS - the message has been successfully posted
2461 to the message queue.
2462
2463 VOS_STATUS_E_INVAL - The value specified by msgQueueId does not
2464 refer to a valid Message Queue Id.
2465
2466 VOS_STATUS_E_FAULT - message is an invalid pointer.
2467
2468 VOS_STATUS_E_FAILURE - the message queue handler has reported
2469 an unknown failure.
2470
2471 \sa
2472
2473 --------------------------------------------------------------------------*/
2474
2475VOS_STATUS vos_rx_mq_serialize( VOS_MQ_ID msgQueueId, vos_msg_t *pMsg )
2476{
2477 pVosMqType pTargetMq = NULL;
2478 pVosMsgWrapper pMsgWrapper = NULL;
2479 if ((gpVosContext == NULL) || (pMsg == NULL))
2480 {
2481 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2482 "%s: Null params or global vos context is null", __func__);
2483 VOS_ASSERT(0);
2484 return VOS_STATUS_E_FAILURE;
2485 }
2486
2487 switch (msgQueueId)
2488 {
2489
2490 case VOS_MQ_ID_SYS:
2491 {
2492 pTargetMq = &(gpVosContext->vosSched.sysRxMq);
2493 break;
2494 }
2495
2496 /// Message Queue ID for messages bound for WDI
2497 case VOS_MQ_ID_WDI:
2498 {
2499 pTargetMq = &(gpVosContext->vosSched.wdiRxMq);
2500 break;
2501 }
Katya Nigam664f5032014-05-05 12:24:32 +05302502 case VOS_MQ_ID_TL:
2503 {
2504 pTargetMq = &(gpVosContext->vosSched.tlRxMq);
2505 break;
2506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002507
2508 default:
2509
2510 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302511 "%s: Trying to queue msg into unknown Rx Msg queue ID %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 __func__, msgQueueId);
2513
2514 return VOS_STATUS_E_FAILURE;
2515 }
2516
2517 if (pTargetMq == NULL)
2518 {
2519 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002520 "%s: pTargetMq == NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 return VOS_STATUS_E_FAILURE;
2522 }
2523
2524
2525 /*
2526 ** Try and get a free Msg wrapper
2527 */
2528 pMsgWrapper = vos_mq_get(&gpVosContext->freeVosMq);
2529
2530 if (NULL == pMsgWrapper)
2531 {
2532 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2533 "%s: VOS Core run out of message wrapper", __func__);
Abhishek Singh837adf22015-10-01 17:37:37 +05302534 if (!gpVosContext->vosWrapperFullReported)
2535 {
2536 gpVosContext->vosWrapperFullReported = 1;
2537 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
2538 WLAN_LOG_INDICATOR_HOST_ONLY,
2539 WLAN_LOG_REASON_VOS_MSG_UNDER_RUN,
2540 FALSE, TRUE);
2541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002542
2543 return VOS_STATUS_E_RESOURCES;
2544 }
2545
2546 /*
2547 ** Copy the message now
2548 */
2549 vos_mem_copy( (v_VOID_t*)pMsgWrapper->pVosMsg,
2550 (v_VOID_t*)pMsg, sizeof(vos_msg_t));
2551
2552 vos_mq_put(pTargetMq, pMsgWrapper);
2553
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302554 set_bit(RX_POST_EVENT, &gpVosContext->vosSched.rxEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 wake_up_interruptible(&gpVosContext->vosSched.rxWaitQueue);
2556
2557 return VOS_STATUS_SUCCESS;
2558
2559} /* vos_rx_mq_serialize()*/
2560
Jeff Johnson295189b2012-06-20 16:38:30 -07002561v_VOID_t
2562vos_sys_probe_thread_cback
2563(
2564 v_VOID_t *pUserData
2565)
2566{
2567 if (gpVosContext != pUserData)
2568 {
2569 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002570 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 return;
2572 }
2573
2574 if (vos_event_set(&gpVosContext->ProbeEvent)!= VOS_STATUS_SUCCESS)
2575 {
2576 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002577 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 return;
2579 }
2580
2581} /* vos_sys_probe_thread_cback() */
2582
Jeff Johnson295189b2012-06-20 16:38:30 -07002583v_VOID_t vos_WDAComplete_cback
2584(
2585 v_VOID_t *pUserData
2586)
2587{
2588
2589 if (gpVosContext != pUserData)
2590 {
2591 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002592 "%s: gpVosContext != pUserData", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 return;
2594 }
2595
2596 if (vos_event_set(&gpVosContext->wdaCompleteEvent)!= VOS_STATUS_SUCCESS)
2597 {
2598 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002599 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 return;
2601 }
2602
2603} /* vos_WDAComplete_cback() */
Jeff Johnson295189b2012-06-20 16:38:30 -07002604
2605v_VOID_t vos_core_return_msg
2606(
2607 v_PVOID_t pVContext,
2608 pVosMsgWrapper pMsgWrapper
2609)
2610{
2611 pVosContextType pVosContext = (pVosContextType) pVContext;
2612
2613 VOS_ASSERT( gpVosContext == pVosContext);
2614
2615 if (gpVosContext != pVosContext)
2616 {
2617 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002618 "%s: gpVosContext != pVosContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 return;
2620 }
2621
2622 VOS_ASSERT( NULL !=pMsgWrapper );
2623
2624 if (pMsgWrapper == NULL)
2625 {
2626 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002627 "%s: pMsgWrapper == NULL in function", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 return;
2629 }
2630
2631 /*
2632 ** Return the message on the free message queue
2633 */
2634 INIT_LIST_HEAD(&pMsgWrapper->msgNode);
2635 vos_mq_put(&pVosContext->freeVosMq, pMsgWrapper);
2636
2637} /* vos_core_return_msg() */
2638
2639
2640/**
2641 @brief vos_fetch_tl_cfg_parms() - this function will attempt to read the
2642 TL config params from the registry
2643
2644 @param pAdapter : [inout] pointer to TL config block
2645
2646 @return
2647 None
2648
2649*/
2650v_VOID_t
2651vos_fetch_tl_cfg_parms
2652(
2653 WLANTL_ConfigInfoType *pTLConfig,
2654 hdd_config_t * pConfig
2655)
2656{
2657 if (pTLConfig == NULL)
2658 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002659 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s NULL ptr passed in!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 return;
2661 }
2662
2663 pTLConfig->ucAcWeights[0] = pConfig->WfqBkWeight;
2664 pTLConfig->ucAcWeights[1] = pConfig->WfqBeWeight;
2665 pTLConfig->ucAcWeights[2] = pConfig->WfqViWeight;
2666 pTLConfig->ucAcWeights[3] = pConfig->WfqVoWeight;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302667 pTLConfig->ucAcWeights[4] = pConfig->WfqVoWeight;
Dhanashri Atred8c20a32014-01-03 17:20:55 -08002668 pTLConfig->ucReorderAgingTime[0] = pConfig->BkReorderAgingTime;/*WLANTL_AC_BK*/
2669 pTLConfig->ucReorderAgingTime[1] = pConfig->BeReorderAgingTime;/*WLANTL_AC_BE*/
2670 pTLConfig->ucReorderAgingTime[2] = pConfig->ViReorderAgingTime;/*WLANTL_AC_VI*/
2671 pTLConfig->ucReorderAgingTime[3] = pConfig->VoReorderAgingTime;/*WLANTL_AC_VO*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 pTLConfig->uDelayedTriggerFrmInt = pConfig->DelayedTriggerFrmInt;
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 pTLConfig->uMinFramesProcThres = pConfig->MinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -07002674
2675}
2676
2677v_BOOL_t vos_is_apps_power_collapse_allowed(void* pHddCtx)
2678{
2679 return hdd_is_apps_power_collapse_allowed((hdd_context_t*) pHddCtx);
2680}
2681
Jeff Johnson295189b2012-06-20 16:38:30 -07002682/*---------------------------------------------------------------------------
2683
2684 \brief vos_shutdown() - shutdown VOS
2685
2686 - All VOS submodules are closed.
2687
2688 - All the WLAN SW components should have been opened. This includes
2689 SYS, MAC, SME and TL.
2690
2691
2692 \param vosContext: Global vos context
2693
2694
2695 \return VOS_STATUS_SUCCESS - Operation successfull & vos is shutdown
2696
2697 VOS_STATUS_E_FAILURE - Failure to close
2698
2699---------------------------------------------------------------------------*/
2700VOS_STATUS vos_shutdown(v_CONTEXT_t vosContext)
2701{
2702 VOS_STATUS vosStatus;
2703
2704#ifdef WLAN_BTAMP_FEATURE
2705 vosStatus = WLANBAP_Close(vosContext);
2706 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2707 {
2708 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2709 "%s: Failed to close BAP", __func__);
2710 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2711 }
2712#endif // WLAN_BTAMP_FEATURE
2713
2714 vosStatus = WLANTL_Close(vosContext);
2715 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2716 {
2717 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2718 "%s: Failed to close TL", __func__);
2719 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2720 }
2721
2722 vosStatus = sme_Close( ((pVosContextType)vosContext)->pMACContext);
2723 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2724 {
2725 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2726 "%s: Failed to close SME", __func__);
2727 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2728 }
2729
2730 vosStatus = macClose( ((pVosContextType)vosContext)->pMACContext);
2731 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2732 {
2733 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2734 "%s: Failed to close MAC", __func__);
2735 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2736 }
2737
2738 ((pVosContextType)vosContext)->pMACContext = NULL;
2739
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 vosStatus = sysClose( vosContext );
2741 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2742 {
2743 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2744 "%s: Failed to close SYS", __func__);
2745 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2746 }
2747
2748 /* Let DXE return packets in WDA_close and then free them here */
2749 vosStatus = vos_packet_close( vosContext );
2750 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2751 {
2752 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2753 "%s: Failed to close VOSS Packet", __func__);
2754 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2755 }
2756
2757 vos_mq_deinit(&((pVosContextType)vosContext)->freeVosMq);
2758
Sachin Ahuja715aafc2015-07-21 23:35:10 +05302759 vosStatus = vos_event_destroy(&gpVosContext->fwLogsComplete);
2760 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2761 {
2762 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2763 "%s: failed to destroy fwLogsComplete", __func__);
2764 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2765 }
2766
2767
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 vosStatus = vos_event_destroy(&gpVosContext->wdaCompleteEvent);
2769 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2770 {
2771 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2772 "%s: failed to destroy wdaCompleteEvent", __func__);
2773 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2774 }
2775
2776 vosStatus = vos_event_destroy(&gpVosContext->ProbeEvent);
2777 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2778 {
2779 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2780 "%s: failed to destroy ProbeEvent", __func__);
2781 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2782 }
2783
2784 return VOS_STATUS_SUCCESS;
2785}
2786
2787/*---------------------------------------------------------------------------
2788
2789 \brief vos_wda_shutdown() - VOS interface to wda shutdown
2790
2791 - WDA/WDI shutdown
2792
2793 \param vosContext: Global vos context
2794
2795
2796 \return VOS_STATUS_SUCCESS - Operation successfull
2797
2798 VOS_STATUS_E_FAILURE - Failure to close
2799
2800---------------------------------------------------------------------------*/
2801VOS_STATUS vos_wda_shutdown(v_CONTEXT_t vosContext)
2802{
2803 VOS_STATUS vosStatus;
2804 vosStatus = WDA_shutdown(vosContext, VOS_FALSE);
2805
2806 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2807 {
2808 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2809 "%s: failed to shutdown WDA", __func__);
2810 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
2811 }
2812 return vosStatus;
2813}
2814/**
2815 @brief vos_wlanShutdown() - This API will shutdown WLAN driver
2816
2817 This function is called when Riva subsystem crashes. There are two
2818 methods (or operations) in WLAN driver to handle Riva crash,
2819 1. shutdown: Called when Riva goes down, this will shutdown WLAN
2820 driver without handshaking with Riva.
2821 2. re-init: Next API
2822 @param
2823 NONE
2824 @return
2825 VOS_STATUS_SUCCESS - Operation completed successfully.
2826 VOS_STATUS_E_FAILURE - Operation failed.
2827
2828*/
2829VOS_STATUS vos_wlanShutdown(void)
2830{
2831 VOS_STATUS vstatus;
2832 vstatus = vos_watchdog_wlan_shutdown();
2833 return vstatus;
2834}
2835/**
2836 @brief vos_wlanReInit() - This API will re-init WLAN driver
2837
2838 This function is called when Riva subsystem reboots. There are two
2839 methods (or operations) in WLAN driver to handle Riva crash,
2840 1. shutdown: Previous API
2841 2. re-init: Called when Riva comes back after the crash. This will
2842 re-initialize WLAN driver. In some cases re-open may be
2843 referred instead of re-init.
2844 @param
2845 NONE
2846 @return
2847 VOS_STATUS_SUCCESS - Operation completed successfully.
2848 VOS_STATUS_E_FAILURE - Operation failed.
2849
2850*/
2851VOS_STATUS vos_wlanReInit(void)
2852{
2853 VOS_STATUS vstatus;
2854 vstatus = vos_watchdog_wlan_re_init();
2855 return vstatus;
2856}
Jeff Johnsone7245742012-09-05 17:12:55 -07002857/**
2858 @brief vos_wlanRestart() - This API will reload WLAN driver.
2859
2860 This function is called if driver detects any fatal state which
2861 can be recovered by a WLAN module reload ( Android framwork initiated ).
2862 Note that this API will not initiate any RIVA subsystem restart.
2863
2864 The function wlan_hdd_restart_driver protects against re-entrant calls.
2865
2866 @param
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05302867 reason: recovery reason
Jeff Johnsone7245742012-09-05 17:12:55 -07002868 @return
2869 VOS_STATUS_SUCCESS - Operation completed successfully.
2870 VOS_STATUS_E_FAILURE - Operation failed.
2871 VOS_STATUS_E_EMPTY - No configured interface
2872 VOS_STATUS_E_ALREADY - Request already in progress
2873
2874
2875*/
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05302876VOS_STATUS vos_wlanRestart(enum vos_hang_reason reason)
Jeff Johnsone7245742012-09-05 17:12:55 -07002877{
2878 VOS_STATUS vstatus;
2879 hdd_context_t *pHddCtx = NULL;
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05302880 VosContextType *pVosContext = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07002881
2882 /* Check whether driver load unload is in progress */
2883 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
2884 {
2885 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2886 "%s: Driver load/unload is in progress, retry later.", __func__);
2887 return VOS_STATUS_E_AGAIN;
2888 }
2889
2890 /* Get the Global VOSS Context */
2891 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2892 if(!pVosContext) {
2893 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2894 "%s: Global VOS context is Null", __func__);
2895 return VOS_STATUS_E_FAILURE;
2896 }
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05302897 pVosContext->recovery_reason = reason;
2898
Jeff Johnsone7245742012-09-05 17:12:55 -07002899 /* Get the HDD context */
2900 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
2901 if(!pHddCtx) {
2902 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2903 "%s: HDD context is Null", __func__);
2904 return VOS_STATUS_E_FAILURE;
2905 }
2906
2907 /* Reload the driver */
2908 vstatus = wlan_hdd_restart_driver(pHddCtx);
2909 return vstatus;
2910}
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302911
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05302912/**
2913 * vos_get_recovery_reason() - get self recovery reason
2914 * @reason: recovery reason
2915 *
2916 * Return: None
2917 */
2918void vos_get_recovery_reason(enum vos_hang_reason *reason)
2919{
2920 VosContextType *pVosContext = NULL;
2921
2922 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2923 if(!pVosContext) {
2924 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2925 "%s: Global VOS context is Null", __func__);
2926 return;
2927 }
2928
2929 *reason = pVosContext->recovery_reason;
2930}
2931
2932/**
2933 * vos_reset_recovery_reason() - reset the reason to unspecified
2934 *
2935 * Return: None
2936 */
2937void vos_reset_recovery_reason(void)
2938{
2939 VosContextType *pVosContext = NULL;
2940
2941 pVosContext = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
2942 if(!pVosContext) {
2943 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
2944 "%s: Global VOS context is Null", __func__);
2945 return;
2946 }
2947
2948 pVosContext->recovery_reason = VOS_REASON_UNSPECIFIED;
2949}
2950
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302951
2952/**
2953 @brief vos_fwDumpReq()
2954
2955 This function is called to issue dump commands to Firmware
2956
2957 @param
Siddharth Bhal68115602015-01-18 20:44:55 +05302958 cmd - Command No. to execute
2959 arg1 - argument 1 to cmd
2960 arg2 - argument 2 to cmd
2961 arg3 - argument 3 to cmd
2962 arg4 - argument 4 to cmd
2963 async - asynchronous event. Don't wait for completion.
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302964 @return
2965 NONE
2966*/
2967v_VOID_t vos_fwDumpReq(tANI_U32 cmd, tANI_U32 arg1, tANI_U32 arg2,
Siddharth Bhal68115602015-01-18 20:44:55 +05302968 tANI_U32 arg3, tANI_U32 arg4, tANI_U8 async)
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302969{
Siddharth Bhalec9581a2015-02-18 14:48:18 +05302970 WDA_HALDumpCmdReq(NULL, cmd, arg1, arg2, arg3, arg4, NULL, async);
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +05302971}
Dino Mycle3f783bc2014-08-08 17:40:22 +05302972
2973v_U64_t vos_get_monotonic_boottime(void)
2974{
2975 struct timespec ts;
2976 wcnss_get_monotonic_boottime(&ts);
2977 return (((v_U64_t)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
2978}
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05302979
2980/**---------------------------------------------------------------------------
2981
2982 \brief vos_randomize_n_bytes() - HDD Random Mac Addr Generator
2983
2984 This generates the random mac address for WLAN interface
2985
2986 \param - mac_addr - pointer to Mac address
2987
2988 \return - 0 for success, < 0 for failure
2989
2990 --------------------------------------------------------------------------*/
2991
2992VOS_STATUS vos_randomize_n_bytes(void *start_addr, tANI_U32 n)
2993{
2994
2995 if (start_addr == NULL )
2996 return VOS_STATUS_E_FAILURE;
2997
2998 get_random_bytes( start_addr, n);
2999
3000 return eHAL_STATUS_SUCCESS;
3001}
c_hpothu8adb97b2014-12-08 19:38:20 +05303002
3003/**---------------------------------------------------------------------------
3004
3005 \brief vos_is_wlan_in_badState() - get isFatalError flag from WD Ctx
3006
3007 \param - VOS_MODULE_ID - module id
3008 - moduleContext - module context
3009
3010 \return - isFatalError value if WDCtx is valid otherwise true
3011
3012 --------------------------------------------------------------------------*/
3013v_BOOL_t vos_is_wlan_in_badState(VOS_MODULE_ID moduleId,
3014 v_VOID_t *moduleContext)
3015{
3016 struct _VosWatchdogContext *pVosWDCtx = get_vos_watchdog_ctxt();
3017
3018 if (pVosWDCtx == NULL){
3019 VOS_TRACE(moduleId, VOS_TRACE_LEVEL_ERROR,
3020 "%s: global wd context is null", __func__);
3021
3022 return TRUE;
3023 }
3024 return pVosWDCtx->isFatalError;
3025}
Girish Gowlia33f0372015-01-19 15:39:04 +05303026
Girish Gowlia33f0372015-01-19 15:39:04 +05303027/**---------------------------------------------------------------------------
3028
Mihir Shetee2ae82a2015-03-16 14:08:49 +05303029 \brief vos_is_fw_logging_enabled() -
3030
3031 API to check if firmware is configured to send logs using DXE channel
3032
3033 \param - None
3034
Mihir Sheted6274602015-04-28 16:13:21 +05303035 \return - 0: firmware logging is not enabled (it may or may not
3036 be supported)
Mihir Shetee2ae82a2015-03-16 14:08:49 +05303037 1: firmware logging is enabled
3038
3039 --------------------------------------------------------------------------*/
3040v_U8_t vos_is_fw_logging_enabled(void)
3041{
3042 return hdd_is_fw_logging_enabled();
3043}
3044
3045/**---------------------------------------------------------------------------
3046
Mihir Shetebe94ebb2015-05-26 12:07:14 +05303047 \brief vos_is_fw_ev_logging_enabled() -
3048
3049 API to check if firmware is configured to send live logs using DXE channel
3050
3051 \param - None
3052
3053 \return - 0: firmware logging is not enabled (it may or may not
3054 be supported)
3055 1: firmware logging is enabled
3056
3057 --------------------------------------------------------------------------*/
3058v_U8_t vos_is_fw_ev_logging_enabled(void)
3059{
3060 return hdd_is_fw_ev_logging_enabled();
3061}
3062
3063/**---------------------------------------------------------------------------
3064
Mihir Sheted6274602015-04-28 16:13:21 +05303065 \brief vos_is_fw_logging_supported() -
3066
3067 API to check if firmware supports to send logs using DXE channel
3068
3069 \param - None
3070
3071 \return - 0: firmware logging is not supported
3072 1: firmware logging is supported
3073
3074 --------------------------------------------------------------------------*/
3075v_U8_t vos_is_fw_logging_supported(void)
3076{
3077 return IS_FRAME_LOGGING_SUPPORTED_BY_FW;
3078}
3079/**---------------------------------------------------------------------------
3080
Girish Gowlia33f0372015-01-19 15:39:04 +05303081 \brief vos_set_roam_delay_stats_enabled() -
3082
3083 API to set value of roamDelayStatsEnabled in vos context
3084
3085 \param - value to be updated
3086
3087 \return - NONE
3088
3089 --------------------------------------------------------------------------*/
3090
3091v_VOID_t vos_set_roam_delay_stats_enabled(v_U8_t value)
3092{
3093 gpVosContext->roamDelayStatsEnabled = value;
3094}
3095
3096
3097/**---------------------------------------------------------------------------
3098
3099 \brief vos_get_roam_delay_stats_enabled() -
3100
3101 API to get value of roamDelayStatsEnabled from vos context
3102
3103 \param - NONE
3104
3105 \return - value of roamDelayStatsEnabled
3106
3107 --------------------------------------------------------------------------*/
3108
3109v_U8_t vos_get_roam_delay_stats_enabled(v_VOID_t)
3110{
3111 return gpVosContext->roamDelayStatsEnabled;
3112}
Katya Nigama6fbf662015-03-17 18:35:47 +05303113
3114v_U32_t vos_get_dxeReplenishRXTimerVal(void)
3115{
3116 hdd_context_t *pHddCtx = NULL;
3117 v_CONTEXT_t pVosContext = NULL;
3118
3119 /* Get the Global VOSS Context */
3120 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3121 if(!pVosContext) {
3122 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
3123 return 0;
3124 }
3125
3126 /* Get the HDD context */
3127 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3128 if(!pHddCtx) {
3129 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
3130 return 0;
3131 }
3132
3133 return pHddCtx->cfg_ini->dxeReplenishRXTimerVal;
3134}
3135
3136v_BOOL_t vos_get_dxeSSREnable(void)
3137{
3138 hdd_context_t *pHddCtx = NULL;
3139 v_CONTEXT_t pVosContext = NULL;
3140
3141 /* Get the Global VOSS Context */
3142 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3143 if(!pVosContext) {
3144 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Global VOS context is Null", __func__);
3145 return FALSE;
3146 }
3147
3148 /* Get the HDD context */
3149 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3150 if(!pHddCtx) {
3151 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is Null", __func__);
3152 return FALSE;
3153 }
3154
3155 return pHddCtx->cfg_ini->dxeSSREnable;
3156}
Anand N Sunkad860e5ea2015-03-30 14:41:51 +05303157
3158v_VOID_t vos_flush_work(struct work_struct *work)
3159{
3160#if defined (WLAN_OPEN_SOURCE)
3161 cancel_work_sync(work);
3162#else
3163 wcnss_flush_work(work);
3164#endif
3165}
3166
3167v_VOID_t vos_flush_delayed_work(struct delayed_work *dwork)
3168{
3169#if defined (WLAN_OPEN_SOURCE)
3170 cancel_delayed_work_sync(dwork);
3171#else
3172 wcnss_flush_delayed_work(dwork);
3173#endif
3174}
3175
Anand N Sunkaddc63c792015-06-03 14:33:24 +05303176v_VOID_t vos_init_work(struct work_struct *work , void *callbackptr)
3177{
3178#if defined (WLAN_OPEN_SOURCE)
3179 INIT_WORK(work,callbackptr);
3180#else
3181 wcnss_init_work(work, callbackptr);
3182#endif
3183}
3184
3185v_VOID_t vos_init_delayed_work(struct delayed_work *dwork , void *callbackptr)
3186{
3187#if defined (WLAN_OPEN_SOURCE)
3188 INIT_DELAYED_WORK(dwork,callbackptr);
3189#else
3190 wcnss_init_delayed_work(dwork, callbackptr);
3191#endif
3192}
3193
Sushant Kaushik215778f2015-05-21 14:05:36 +05303194/**
3195 * vos_set_multicast_logging() - Set mutlicast logging value
3196 * @value: Value of multicast logging
3197 *
3198 * Set the multicast logging value which will indicate
3199 * whether to multicast host and fw messages even
3200 * without any registration by userspace entity
3201 *
3202 * Return: None
3203 */
3204void vos_set_multicast_logging(uint8_t value)
3205{
3206 vos_multicast_logging = value;
3207}
3208
3209/**
3210 * vos_is_multicast_logging() - Get multicast logging value
3211 *
3212 * Get the multicast logging value which will indicate
3213 * whether to multicast host and fw messages even
3214 * without any registration by userspace entity
3215 *
3216 * Return: 0 - Multicast logging disabled, 1 - Multicast logging enabled
3217 */
3218v_U8_t vos_is_multicast_logging(void)
3219{
3220 return vos_multicast_logging;
3221}
3222
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05303223/**
Abhishek Singh30fd58c2015-07-15 14:19:21 +05303224 * vos_isLoadUnloadInProgress()
3225 *
3226 * Return TRUE if load/unload is in progress.
3227 *
3228 */
3229v_BOOL_t vos_isLoadUnloadInProgress(void)
3230{
3231 hdd_context_t *pHddCtx = NULL;
3232 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3233
3234 if(!pVosContext)
3235 {
3236 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3237 return FALSE;
3238 }
3239
3240 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3241 if(!pHddCtx) {
3242 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3243 "%s: HDD context is Null", __func__);
3244 return FALSE;
3245 }
3246
3247 return ( 0 != pHddCtx->isLoadUnloadInProgress);
3248}
3249
3250/**
Hanumantha Reddy Pothula05b0b552015-06-18 14:26:10 +05303251 * vos_isUnloadInProgress()
3252 *
3253 * Return TRUE if unload is in progress.
3254 *
3255 */
3256v_BOOL_t vos_isUnloadInProgress(void)
3257{
3258 hdd_context_t *pHddCtx = NULL;
3259 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3260
3261 if(!pVosContext)
3262 {
3263 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3264 return FALSE;
3265 }
3266
3267 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3268 if(!pHddCtx) {
3269 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3270 "%s: HDD context is Null", __func__);
3271 return FALSE;
3272 }
3273
3274 return (WLAN_HDD_UNLOAD_IN_PROGRESS == pHddCtx->isLoadUnloadInProgress);
3275}
3276
Abhishek Singh880d7122015-08-26 16:23:04 +05303277/**
Sravan Kumar Kairam1871d402016-08-04 13:18:25 +05303278 *vos_get_rx_wow_dump()
3279 *
3280 * Return true/flase to dump RX packet
3281 *
3282 */
3283bool vos_get_rx_wow_dump(void)
3284{
3285 hdd_context_t *pHddCtx = NULL;
3286 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3287
3288 if(!pVosContext)
3289 {
3290 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3291 return FALSE;
3292 }
3293
3294 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3295 if(!pHddCtx) {
3296 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3297 "%s: HDD context is Null", __func__);
3298 return FALSE;
3299 }
3300
3301 return pHddCtx->rx_wow_dump;
3302}
3303
3304/**
3305 *vos_set_rx_wow_dump() - Set RX wow pkt dump
3306 *@value: Value of RX wow pkt dump
3307 *
3308 * Return none.
3309 *
3310 */
3311void vos_set_rx_wow_dump(bool value)
3312{
3313 hdd_context_t *pHddCtx = NULL;
3314 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3315
3316 if(!pVosContext)
3317 {
3318 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3319 return;
3320 }
3321
3322 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3323 if(!pHddCtx) {
3324 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3325 "%s: HDD context is Null", __func__);
3326 return;
3327 }
3328
3329 pHddCtx->rx_wow_dump = value;
3330}
3331
3332/**
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05303333 * vos_set_hdd_bad_sta() - Set bad link peer sta id
3334 * @sta_id: sta id of the bad peer
3335 *
3336 * Return none.
3337 */
3338void vos_set_hdd_bad_sta(uint8_t sta_id)
3339{
3340 hdd_context_t *pHddCtx = NULL;
3341 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3342
3343 if(!pVosContext)
3344 {
3345 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3346 return;
3347 }
3348
3349 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3350 if(!pHddCtx) {
3351 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3352 "%s: HDD context is Null", __func__);
3353 return;
3354 }
3355
3356 pHddCtx->bad_sta[sta_id] = 1;
3357}
3358
3359/**
3360 * vos_reset_hdd_bad_sta() - Reset the bad peer sta_id
3361 * @sta_id: sta id of the peer
3362 *
3363 * Return none.
3364 */
3365void vos_reset_hdd_bad_sta(uint8_t sta_id)
3366{
3367 hdd_context_t *pHddCtx = NULL;
3368 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3369
3370 if(!pVosContext) {
3371 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3372 return;
3373 }
3374
3375 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3376 if(!pHddCtx) {
3377 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3378 "%s: HDD context is Null", __func__);
3379 return;
3380 }
3381
3382 pHddCtx->bad_sta[sta_id] = 0;
3383}
3384
3385/**
Abhishek Singh880d7122015-08-26 16:23:04 +05303386 * vos_probe_threads() - VOS API to post messages
3387 * to all the threads to detect if they are active or not
3388 *
3389 * Return none.
3390 *
3391 */
3392void vos_probe_threads(void)
3393{
3394 vos_msg_t msg;
3395
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303396 msg.callback = vos_wd_reset_thread_stuck_count;
Abhishek Singh880d7122015-08-26 16:23:04 +05303397 /* Post Message to MC Thread */
3398 sysBuildMessageHeader(SYS_MSG_ID_MC_THR_PROBE, &msg);
3399 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SYS, &msg)) {
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303400 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3401 FL("Unable to post SYS_MSG_ID_MC_THR_PROBE message to MC thread"));
Abhishek Singh880d7122015-08-26 16:23:04 +05303402 }
3403
3404 /* Post Message to Tx Thread */
3405 sysBuildMessageHeader(SYS_MSG_ID_TX_THR_PROBE, &msg);
3406 if (VOS_STATUS_SUCCESS != vos_tx_mq_serialize(VOS_MQ_ID_SYS, &msg)) {
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303407 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3408 FL("Unable to post SYS_MSG_ID_TX_THR_PROBE message to TX thread"));
Abhishek Singh880d7122015-08-26 16:23:04 +05303409 }
3410
3411 /* Post Message to Rx Thread */
3412 sysBuildMessageHeader(SYS_MSG_ID_RX_THR_PROBE, &msg);
3413 if (VOS_STATUS_SUCCESS != vos_rx_mq_serialize(VOS_MQ_ID_SYS, &msg)) {
Abhishek Singhe7ea25c2015-11-23 16:23:24 +05303414 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3415 FL("Unable to post SYS_MSG_ID_RX_THR_PROBE message to RX thread"));
Abhishek Singh880d7122015-08-26 16:23:04 +05303416 }
3417}
3418
Sushant Kaushik8e644982015-09-23 12:18:54 +05303419/**
3420 * vos_set_ring_log_level() - Convert HLOS values to driver log levels
3421 * @ring_id: ring_id
3422 * @log_levelvalue: Log level specificed
3423 *
3424 * This function sets the log level of a particular ring
3425 *
3426 * Return: None
3427 */
3428 void vos_set_ring_log_level(v_U32_t ring_id, v_U32_t log_level)
3429{
3430 VosContextType *vos_context;
3431 v_U32_t log_val;
3432
3433 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3434 if (!vos_context) {
3435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3436 "%s: vos context is Invald", __func__);
3437 return;
3438 }
3439
3440 switch (log_level) {
3441 case LOG_LEVEL_NO_COLLECTION:
3442 log_val = WLAN_LOG_LEVEL_OFF;
3443 break;
3444 case LOG_LEVEL_NORMAL_COLLECT:
3445 log_val = WLAN_LOG_LEVEL_NORMAL;
3446 break;
3447 case LOG_LEVEL_ISSUE_REPRO:
3448 log_val = WLAN_LOG_LEVEL_REPRO;
3449 break;
3450 case LOG_LEVEL_ACTIVE:
3451 default:
3452 log_val = WLAN_LOG_LEVEL_ACTIVE;
3453 break;
3454 }
3455
3456 if (ring_id == RING_ID_WAKELOCK) {
3457 vos_context->wakelock_log_level = log_val;
3458 return;
3459 } else if (ring_id == RING_ID_CONNECTIVITY) {
3460 vos_context->connectivity_log_level = log_val;
3461 return;
3462 } else if (ring_id == RING_ID_PER_PACKET_STATS) {
3463 vos_context->packet_stats_log_level = log_val;
Sushant Kaushik33200572015-08-05 16:46:20 +05303464 if (WLAN_LOG_LEVEL_ACTIVE != log_val)
3465 wlan_disable_and_flush_pkt_stats();
3466
Sushant Kaushik8e644982015-09-23 12:18:54 +05303467 return;
3468 }
3469}
3470/**
3471 * vos_get_ring_log_level() - Get the a ring id's log level
3472 * @ring_id: Ring id
3473 *
3474 * Fetch and return the log level corresponding to a ring id
3475 *
3476 * Return: Log level corresponding to the ring ID
3477 */
3478v_U8_t vos_get_ring_log_level(v_U32_t ring_id)
3479{
3480 VosContextType *vos_context;
3481
3482 vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3483 if (!vos_context) {
3484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3485 "%s: vos context is Invald", __func__);
3486 return WLAN_LOG_LEVEL_OFF;
3487 }
3488
3489 if (ring_id == RING_ID_WAKELOCK)
3490 return vos_context->wakelock_log_level;
3491 else if (ring_id == RING_ID_CONNECTIVITY)
3492 return vos_context->connectivity_log_level;
3493 else if (ring_id == RING_ID_PER_PACKET_STATS)
3494 return vos_context->packet_stats_log_level;
3495
3496 return WLAN_LOG_LEVEL_OFF;
3497}
Sushant Kaushik33200572015-08-05 16:46:20 +05303498
3499/* elements are rate, preamable, bw, short_gi */
3500rateidx_to_rate_bw_preamble_sgi rateidx_to_rate_bw_preamble_sgi_table[] =
3501{
3502/*11B CCK Long preamble (0-3)*/
3503{ 10, PREAMBLE_CCK, S_BW20, 0},{ 20, PREAMBLE_CCK, S_BW20, 0},
3504{ 55, PREAMBLE_CCK, S_BW20, 0},{ 110, PREAMBLE_CCK, S_BW20, 0},
3505/*11B CCK Short preamble (4-7)*/
3506{ 10, PREAMBLE_CCK, S_BW20, 0},{ 20, PREAMBLE_CCK, S_BW20, 0},
3507{ 55, PREAMBLE_CCK, S_BW20, 0},{ 110, PREAMBLE_CCK, S_BW20, 0},
3508/*11G/A (8-15)*/
3509{ 60, PREAMBLE_OFDM, S_BW20, 0},{ 90, PREAMBLE_OFDM, S_BW20, 0},
3510{ 120, PREAMBLE_OFDM, S_BW20, 0},{ 180, PREAMBLE_OFDM, S_BW20, 0},
3511{ 240, PREAMBLE_OFDM, S_BW20, 0},{ 360, PREAMBLE_OFDM, S_BW20, 0},
3512{ 480, PREAMBLE_OFDM, S_BW20, 0},{ 540, PREAMBLE_OFDM, S_BW20, 0},
3513/*HT20 LGI MCS 0-7 (16-23)*/
3514{ 65, PREAMBLE_HT, S_BW20, 0},{ 130, PREAMBLE_HT, S_BW20, 0},
3515{ 195, PREAMBLE_HT, S_BW20, 0},{ 260, PREAMBLE_HT, S_BW20, 0},
3516{ 390, PREAMBLE_HT, S_BW20, 0},{ 520, PREAMBLE_HT, S_BW20, 0},
3517{ 585, PREAMBLE_HT, S_BW20, 0},{ 650, PREAMBLE_HT, S_BW20, 0},
3518/*HT20 SGI MCS 0-7 (24-31)*/
3519{ 72, PREAMBLE_HT, S_BW20, 1},{ 144, PREAMBLE_HT, S_BW20, 1},
3520{ 217, PREAMBLE_HT, S_BW20, 1},{ 289, PREAMBLE_HT, S_BW20, 1},
3521{ 433, PREAMBLE_HT, S_BW20, 1},{ 578, PREAMBLE_HT, S_BW20, 1},
3522{ 650, PREAMBLE_HT, S_BW20, 1},{ 722, PREAMBLE_HT, S_BW20, 1},
3523/*HT20 Greenfield MCS 0-7 rates (32-39)*/
3524{ 65, PREAMBLE_HT, S_BW20, 0},{ 130, PREAMBLE_HT, S_BW20, 0},
3525{ 195, PREAMBLE_HT, S_BW20, 0},{ 260, PREAMBLE_HT, S_BW20, 0},
3526{ 390, PREAMBLE_HT, S_BW20, 0},{ 520, PREAMBLE_HT, S_BW20, 0},
3527{ 585, PREAMBLE_HT, S_BW20, 0},{ 650, PREAMBLE_HT, S_BW20, 0},
3528/*HT40 LGI MCS 0-7 (40-47)*/
3529{ 135, PREAMBLE_HT, S_BW40, 0},{ 270, PREAMBLE_HT, S_BW40, 0},
3530{ 405, PREAMBLE_HT, S_BW40, 0},{ 540, PREAMBLE_HT, S_BW40, 0},
3531{ 810, PREAMBLE_HT, S_BW40, 0},{ 1080, PREAMBLE_HT, S_BW40, 0},
3532{ 1215, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3533/*HT40 SGI MCS 0-7 (48-55)*/
3534{ 150, PREAMBLE_HT, S_BW40, 1},{ 300, PREAMBLE_HT, S_BW40, 1},
3535{ 450, PREAMBLE_HT, S_BW40, 1},{ 600, PREAMBLE_HT, S_BW40, 1},
3536{ 900, PREAMBLE_HT, S_BW40, 1},{ 1200, PREAMBLE_HT, S_BW40, 1},
3537{ 1350, PREAMBLE_HT, S_BW40, 1},{ 1500, PREAMBLE_HT, S_BW40, 1},
3538/*HT40 Greenfield MCS 0-7 rates (56-63) 64-65 are dummy*/
3539{ 135, PREAMBLE_HT, S_BW40, 0},{ 270, PREAMBLE_HT, S_BW40, 0},
3540{ 405, PREAMBLE_HT, S_BW40, 0},{ 540, PREAMBLE_HT, S_BW40, 0},
3541{ 810, PREAMBLE_HT, S_BW40, 0},{ 1080, PREAMBLE_HT, S_BW40, 0},
3542{ 1215, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3543/*64-65 are dummy*/
3544{ 1350, PREAMBLE_HT, S_BW40, 0},{ 1350, PREAMBLE_HT, S_BW40, 0},
3545/*VHT20 LGI MCS 0-9 rates (66-75)*/
3546{ 65, PREAMBLE_VHT, S_BW20, 0},{ 130, PREAMBLE_VHT, S_BW20, 0},
3547{ 195, PREAMBLE_VHT, S_BW20, 0},{ 260, PREAMBLE_VHT, S_BW20, 0},
3548{ 390, PREAMBLE_VHT, S_BW20, 0},{ 520, PREAMBLE_VHT, S_BW20, 0},
3549{ 585, PREAMBLE_VHT, S_BW20, 0},{ 650, PREAMBLE_VHT, S_BW20, 0},
3550{ 780, PREAMBLE_VHT, S_BW20, 0},{ 865, PREAMBLE_VHT, S_BW20, 0},
3551/*76-77 are dummy*/
3552{ 865, PREAMBLE_VHT, S_BW20, 0},{ 865, PREAMBLE_VHT, S_BW20, 0},
3553/*VHT20 SGI MCS 0-9 rates (78-87)*/
3554{ 72, PREAMBLE_VHT, S_BW20, 1},{ 144, PREAMBLE_VHT, S_BW20, 1},
3555{ 217, PREAMBLE_VHT, S_BW20, 1},{ 289, PREAMBLE_VHT, S_BW20, 1},
3556{ 433, PREAMBLE_VHT, S_BW20, 1},{ 578, PREAMBLE_VHT, S_BW20, 1},
3557{ 650, PREAMBLE_VHT, S_BW20, 1},{ 722, PREAMBLE_VHT, S_BW20, 1},
3558{ 867, PREAMBLE_VHT, S_BW20, 1},{ 961, PREAMBLE_VHT, S_BW20, 1},
3559/*88-89 are dummy*/
3560{ 961, PREAMBLE_VHT, S_BW20, 1},{ 961, PREAMBLE_VHT, S_BW20, 1},
3561/*VHT40 LGI MCS 0-9 rates (90-101) 98,101 is Dummy*/
3562{ 135, PREAMBLE_VHT, S_BW40, 0},{ 270, PREAMBLE_VHT, S_BW40, 0},
3563{ 405, PREAMBLE_VHT, S_BW40, 0},{ 540, PREAMBLE_VHT, S_BW40, 0},
3564{ 810, PREAMBLE_VHT, S_BW40, 0},{ 1080, PREAMBLE_VHT, S_BW40, 0},
3565{ 1215, PREAMBLE_VHT, S_BW40, 0},{ 1350, PREAMBLE_VHT, S_BW40, 0},
3566{ 1350, PREAMBLE_VHT, S_BW40, 0},{ 1620, PREAMBLE_VHT, S_BW40, 0},
3567{ 1800, PREAMBLE_VHT, S_BW40, 0},{ 1800, PREAMBLE_VHT, S_BW40, 0},
3568/*VHT40 SGI MCS 0-9 rates (102-112) 110, 113 is Dummy*/
3569{ 150, PREAMBLE_VHT, S_BW40, 1},{ 300, PREAMBLE_VHT, S_BW40, 1},
3570{ 450, PREAMBLE_VHT, S_BW40, 1},{ 600, PREAMBLE_VHT, S_BW40, 1},
3571{ 900, PREAMBLE_VHT, S_BW40, 1},{ 1200, PREAMBLE_VHT, S_BW40, 1},
3572{ 1350, PREAMBLE_VHT, S_BW40, 1},{ 1500, PREAMBLE_VHT, S_BW40, 1},
3573{ 1500, PREAMBLE_VHT, S_BW40, 1},{ 1800, PREAMBLE_VHT, S_BW40, 1},
3574{ 2000, PREAMBLE_VHT, S_BW40, 1},{ 2000, PREAMBLE_VHT, S_BW40, 1},
3575/*VHT80 LGI MCS 0-9 rates (114-125) 122, 125 is Dummy*/
3576{ 293, PREAMBLE_VHT, S_BW80, 0},{ 585, PREAMBLE_VHT, S_BW80, 0},
3577{ 878, PREAMBLE_VHT, S_BW80, 0},{ 1170, PREAMBLE_VHT, S_BW80, 0},
3578{ 1755, PREAMBLE_VHT, S_BW80, 0},{ 2340, PREAMBLE_VHT, S_BW80, 0},
3579{ 2633, PREAMBLE_VHT, S_BW80, 0},{ 2925, PREAMBLE_VHT, S_BW80, 0},
3580{ 2925, PREAMBLE_VHT, S_BW80, 0},{ 3510, PREAMBLE_VHT, S_BW80, 0},
3581{ 3900, PREAMBLE_VHT, S_BW80, 0},{ 3900, PREAMBLE_VHT, S_BW80, 0},
3582/*VHT80 SGI MCS 0-9 rates (126-136) 134 is Dummy*/
3583{ 325, PREAMBLE_VHT, S_BW80, 1},{ 650, PREAMBLE_VHT, S_BW80, 1},
3584{ 975, PREAMBLE_VHT, S_BW80, 1},{ 1300, PREAMBLE_VHT, S_BW80, 1},
3585{ 1950, PREAMBLE_VHT, S_BW80, 1},{ 2600, PREAMBLE_VHT, S_BW80, 1},
3586{ 2925, PREAMBLE_VHT, S_BW80, 1},{ 3250, PREAMBLE_VHT, S_BW80, 1},
3587{ 3250, PREAMBLE_VHT, S_BW80, 1},{ 3900, PREAMBLE_VHT, S_BW80, 1},
3588{ 4333, PREAMBLE_VHT, S_BW80, 1},
3589};
3590
3591void get_rate_and_MCS(per_packet_stats *stats, uint32 rateindex)
3592{
3593 rateidx_to_rate_bw_preamble_sgi *ratetbl;
3594
3595 if (STATS_MAX_RATE_INDEX < rateindex)
3596 rateindex = STATS_MAX_RATE_INDEX;
3597 ratetbl= &rateidx_to_rate_bw_preamble_sgi_table[rateindex];
3598 stats->last_transmit_rate = ratetbl->rate/5;
3599 stats->MCS.nss = 0;
3600 if (0 <= rateindex && rateindex <= 7)
3601 stats->MCS.rate = 7 - rateindex;
3602 else if (8 <= rateindex && rateindex <= 15)
3603 {
3604 switch(rateindex)
3605 {
3606 case 8:stats->MCS.rate = 3; break;
3607 case 9:stats->MCS.rate = 7; break;
3608 case 10:stats->MCS.rate = 2; break;
3609 case 11:stats->MCS.rate = 6; break;
3610 case 12:stats->MCS.rate = 1; break;
3611 case 13:stats->MCS.rate = 5; break;
3612 case 14:stats->MCS.rate = 0; break;
3613 case 15:stats->MCS.rate = 4; break;
3614 }
3615 }
3616 else if(16 <= rateindex && rateindex <= 23)
3617 stats->MCS.rate = rateindex - 16;
3618 else if(24 <= rateindex && rateindex <= 31)
3619 stats->MCS.rate = rateindex - 24;
3620 else if(32 <= rateindex && rateindex <= 39)
3621 stats->MCS.rate = rateindex - 32;
3622 else if(40 <= rateindex && rateindex <= 47)
3623 stats->MCS.rate = rateindex - 40;
3624 else if(48 <= rateindex && rateindex <= 55)
3625 stats->MCS.rate = rateindex - 48;
3626 else if(56 <= rateindex && rateindex <= 63)
3627 stats->MCS.rate = rateindex - 56;
3628 else if(66 <= rateindex && rateindex <= 75)
3629 stats->MCS.rate = rateindex - 66;
3630 else if(78 <= rateindex && rateindex <= 87)
3631 stats->MCS.rate = rateindex - 78;
3632 else if(90 <= rateindex && rateindex <= 100)
3633 stats->MCS.rate = rateindex - 90;
3634 else if(78 <= rateindex && rateindex <= 87)
3635 stats->MCS.rate = rateindex - 78;
3636 else if(90 <= rateindex && rateindex <= 97)
3637 stats->MCS.rate = rateindex - 90;
3638 else if(99 <= rateindex && rateindex <= 100)
3639 stats->MCS.rate = rateindex - 91;
3640 else if(102 <= rateindex && rateindex <= 109)
3641 stats->MCS.rate = rateindex - 102;
3642 else if(111 <= rateindex && rateindex <= 112)
3643 stats->MCS.rate = rateindex - 103;
3644 else if(114 <= rateindex && rateindex <= 121)
3645 stats->MCS.rate = rateindex - 114;
3646 else if(123 <= rateindex && rateindex <= 124)
3647 stats->MCS.rate = rateindex - 115;
3648 else if(126 <= rateindex && rateindex <= 133)
3649 stats->MCS.rate = rateindex - 126;
3650 else if(135 <= rateindex && rateindex <= 136)
3651 stats->MCS.rate = rateindex - 127;
3652 else /*Invalid rate index mark it 0*/
3653 stats->MCS.rate = 0;
3654 stats->MCS.preamble = ratetbl->preamble;
3655 stats->MCS.bw = ratetbl->bw;
3656 stats->MCS.short_gi = ratetbl->short_gi;
3657}
3658
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05303659v_U16_t vos_get_rate_from_rateidx(uint32 rateindex)
3660{
3661 v_U16_t rate = 0;
3662
3663 if (rateindex < STATS_MAX_RATE_INDEX)
3664 rate = rateidx_to_rate_bw_preamble_sgi_table[rateindex].rate;
3665
3666 return rate;
3667}
3668
Sushant Kaushik33200572015-08-05 16:46:20 +05303669bool vos_isPktStatsEnabled(void)
3670{
3671 bool value;
3672 value = wlan_isPktStatsEnabled();
3673 return (value);
3674}
Manjeet Singh87a6eb72016-06-28 19:23:55 +05303675
3676bool vos_is_wlan_logging_enabled(void)
3677{
3678 v_CONTEXT_t vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3679 hdd_context_t *hdd_ctx;
3680
3681 if(!vos_ctx)
3682 {
3683 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3684 return false;
3685 }
3686
3687 hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx);
3688
3689 if(!hdd_ctx)
3690 {
3691 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null", __func__);
3692 return false;
3693 }
3694
3695 if (!hdd_ctx->cfg_ini->wlanLoggingEnable)
3696 {
3697 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Logging framework not enabled!", __func__);
3698 return false;
3699 }
3700
3701 return true;
3702}
Rajeev Kumar Sirasanagandla63f85cf2016-06-29 16:52:15 +05303703
3704/**---------------------------------------------------------------------------
3705
3706 \brief vos_is_probe_rsp_offload_enabled -
3707
3708 API to check if probe response offload feature is enabled from ini
3709
3710 \param - None
3711
3712 \return - 0: probe response offload is disabled
3713 1: probe response offload is enabled
3714
3715 --------------------------------------------------------------------------*/
3716v_BOOL_t vos_is_probe_rsp_offload_enabled(void)
3717{
3718 hdd_context_t *pHddCtx = NULL;
3719 v_CONTEXT_t pVosContext = NULL;
3720
3721 /* Get the Global VOSS Context */
3722 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3723 if (!pVosContext) {
3724 hddLog(VOS_TRACE_LEVEL_FATAL,
3725 "%s: Global VOS context is Null", __func__);
3726 return FALSE;
3727 }
3728
3729 /* Get the HDD context */
3730 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD,
3731 pVosContext);
3732 if (!pHddCtx) {
3733 hddLog(VOS_TRACE_LEVEL_FATAL,
3734 "%s: HDD context is Null", __func__);
3735 return FALSE;
3736 }
3737
3738 return pHddCtx->cfg_ini->sap_probe_resp_offload;
3739}
Abhishek Singh8a3e4dc2017-01-02 10:39:18 +05303740
3741
3742/**
3743 * vos_set_snoc_high_freq_voting() - enable/disable high freq voting
3744 * @enable: true if need to be enabled
3745 *
3746 * enable/disable high freq voting
3747 *
3748 * Return: Void
3749 */
3750#ifdef HAVE_WCNSS_SNOC_HIGH_FREQ_VOTING
3751void vos_set_snoc_high_freq_voting(bool enable)
3752{
3753 VosContextType *vos_ctx = NULL;
3754
3755 /* Get the Global VOSS Context */
3756 vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3757
3758 if (!vos_ctx) {
3759 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3760 "%s: vos context is NULL", __func__);
3761 return;
3762 }
3763
3764 spin_lock(&vos_ctx->freq_voting_lock);
3765 if (vos_ctx->snoc_high_freq_voting != enable)
3766 {
3767 vos_ctx->snoc_high_freq_voting = enable;
3768 spin_unlock(&vos_ctx->freq_voting_lock);
3769 wcnss_snoc_vote(enable);
3770 return;
3771 }
3772 spin_unlock(&vos_ctx->freq_voting_lock);
3773}
3774#else
3775void vos_set_snoc_high_freq_voting(bool enable)
3776{
3777 return;
3778}
3779#endif
Arunk Khandavalliaf6c3af2017-01-16 11:44:46 +05303780
3781void vos_smd_dump_stats(void)
3782{
3783 WCTS_Dump_Smd_status();
3784}
3785
3786void vos_log_wdi_event(uint16 msg, vos_wdi_trace_event_type event)
3787{
3788
3789 if (gvos_wdi_msg_trace_index >= VOS_TRACE_INDEX_MAX)
3790 {
3791 gvos_wdi_msg_trace_index = 0;
3792 }
3793
3794 gvos_wdi_msg_trace[gvos_wdi_msg_trace_index].event = event;
3795 gvos_wdi_msg_trace[gvos_wdi_msg_trace_index].time =
3796 vos_get_monotonic_boottime();
3797 gvos_wdi_msg_trace[gvos_wdi_msg_trace_index].message = msg;
3798 gvos_wdi_msg_trace_index++;
3799
3800 return;
3801}
3802
3803void vos_dump_wdi_events(void)
3804{
3805 int i;
3806
3807 for(i = 0; i < VOS_TRACE_INDEX_MAX; i++) {
3808 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3809 "%s:event:%d time:%lld msg:%d ",__func__,
3810 gvos_wdi_msg_trace[i].event,
3811 gvos_wdi_msg_trace[i].time,
3812 gvos_wdi_msg_trace[i].message);
3813 }
3814}
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05303815
3816/**
3817 * vos_check_arp_target_ip() - check if the Target IP is gateway IP
3818 * @pPacket: pointer to vos packet
3819 *
3820 * Return: true if the IP is of gateway or false otherwise
3821 */
3822bool vos_check_arp_target_ip(vos_pkt_t *pPacket)
3823{
3824 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3825 hdd_context_t *pHddCtx = NULL;
3826 struct sk_buff *skb;
3827
3828 if(!pVosContext)
3829 {
3830 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3831 return false;
3832 }
3833
3834 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3835 if(!pHddCtx) {
3836 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3837 "%s: HDD context is Null", __func__);
3838 return false;
3839 }
3840
3841 if (unlikely(NULL == pPacket))
3842 {
3843 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3844 "%s: NULL pointer", __func__);
3845 return false;
3846 }
3847
3848 if ( VOS_STATUS_SUCCESS !=
3849 vos_pkt_get_os_packet(pPacket, (void**)&skb, VOS_FALSE ))
3850 {
3851 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3852 "%s: OS PKT pointer is NULL", __func__);
3853 return false;
3854 }
3855
3856 if (pHddCtx->track_arp_ip ==
3857 (v_U32_t)(*(v_U32_t *)(skb->data + VOS_ARP_TARGET_IP_OFFSET)))
3858 return true;
3859
3860 return false;
3861}
Asodi T,Venkateswara Reddy9826c872017-01-18 19:08:25 +05303862
3863/**
3864 * vos_update_arp_fw_tx_delivered() - update the ARP stats host to FW deliver
3865 * count
3866 *
3867 * Return: None
3868 */
3869void vos_update_arp_fw_tx_delivered(void)
3870{
3871 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3872 hdd_context_t *pHddCtx = NULL;
Hanumanth Reddy Pothulabe7ff0c2018-02-26 18:20:09 +05303873 hdd_adapter_t * pAdapter = NULL;
Asodi T,Venkateswara Reddy9826c872017-01-18 19:08:25 +05303874 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
3875 uint8_t status;
3876
3877 if(!pVosContext) {
3878 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3879 return;
3880 }
3881
3882 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3883 if(!pHddCtx) {
3884 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3885 "%s: HDD context is Null", __func__);
3886 return;
3887 }
3888
3889 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
3890
3891 while (NULL != pAdapterNode && 0 == status)
3892 {
3893 pAdapter = pAdapterNode->pAdapter;
3894 if (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3895 break;
3896
3897 status = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext);
3898 pAdapterNode = pNext;
3899 }
Hanumanth Reddy Pothulabe7ff0c2018-02-26 18:20:09 +05303900 if (pAdapter)
3901 pAdapter->hdd_stats.hddArpStats.tx_host_fw_sent++;
Asodi T,Venkateswara Reddy9826c872017-01-18 19:08:25 +05303902}
3903
3904/**
3905 * vos_update_arp_rx_drop_reorder() - update the RX ARP stats drop due
3906 * reorder logic at host
3907 *
3908 * Return: None
3909 */
3910void vos_update_arp_rx_drop_reorder(void)
3911{
3912 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3913 hdd_context_t *pHddCtx = NULL;
Hanumanth Reddy Pothulabe7ff0c2018-02-26 18:20:09 +05303914 hdd_adapter_t * pAdapter = NULL;
Asodi T,Venkateswara Reddy9826c872017-01-18 19:08:25 +05303915 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
3916 uint8_t status;
3917
3918 if(!pVosContext) {
3919 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
3920 return;
3921 }
3922
3923 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
3924 if(!pHddCtx) {
3925 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
3926 "%s: HDD context is Null", __func__);
3927 return;
3928 }
3929
3930 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
3931
3932 while (NULL != pAdapterNode && 0 == status)
3933 {
3934 pAdapter = pAdapterNode->pAdapter;
3935 if (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3936 break;
3937
3938 status = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext);
3939 pAdapterNode = pNext;
3940 }
3941
Hanumanth Reddy Pothulabe7ff0c2018-02-26 18:20:09 +05303942 if (pAdapter)
3943 pAdapter->hdd_stats.hddArpStats.rx_host_drop_reorder++;
Asodi T,Venkateswara Reddy9826c872017-01-18 19:08:25 +05303944}
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05303945
3946v_BOOL_t vos_check_monitor_state(void)
3947{
3948 hdd_context_t *hdd_ctx;
3949
3950 v_CONTEXT_t vos_ctx = vos_get_global_context(VOS_MODULE_ID_HDD, NULL);
3951 if (!vos_ctx)
3952 return VOS_FALSE;
3953
3954 hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx);
3955 if (!hdd_ctx)
3956 return VOS_FALSE;
3957
3958 return wlan_hdd_check_monitor_state(hdd_ctx);
3959}