blob: be54dffb7fbc26d26e9c47057c297cff177e854f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -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 Lam0fb93dd2014-02-19 00:32:59 -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/*===========================================================================
29
30 W L A N S Y S T E M M O D U L E
31
32
33DESCRIPTION
34 This file contains the system module that implements the 'exectution model'
35 in the Gen6 host software.
36
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038===========================================================================*/
39
40/*===========================================================================
41
42 EDIT HISTORY FOR FILE
43
44
45 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
47
48
49 $Header:$ $DateTime: $ $Author: $
50
51
52when who what, where, why
53-------- --- -----------------------------------------------------
5412/15/08 sho Resolved AMSS compiler errors and warnings when this
55 is being ported from WM
5607/02/08 lac Added support for eWNI_SME_START_REQ/RSP in init seq
5706/26/08 hba Added implementation of mbReceiveMBMsg()
5806/26/08 lac Created module.
59
60===========================================================================*/
61
62
63#include <wlan_qct_sys.h>
64#include <vos_api.h>
65
66#include <sirTypes.h> // needed for tSirRetStatus
67#include <sirParams.h> // needed for tSirMbMsg
68#include <sirApi.h> // needed for SIR_... message types
69#include <wniApi.h> // needed for WNI_... message types
70#include "aniGlobal.h"
71#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070072#include "sme_Api.h"
73#include "macInitApi.h"
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +053074#include "vos_sched.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075
Jeff Johnson295189b2012-06-20 16:38:30 -070076VOS_STATUS WLANFTM_McProcessMsg (v_VOID_t *message);
77
Jeff Johnson295189b2012-06-20 16:38:30 -070078
79
80// Cookie for SYS messages. Note that anyone posting a SYS Message has to
81// write the COOKIE in the reserved field of the message. The SYS Module
82// relies on this COOKIE
Jeff Johnson295189b2012-06-20 16:38:30 -070083#define FTM_SYS_MSG_COOKIE 0xFACE
Jeff Johnson295189b2012-06-20 16:38:30 -070084
85#define SYS_MSG_COOKIE ( 0xFACE )
86
87// need to define FIELD_OFFSET for non-WM platforms
88#ifndef FIELD_OFFSET
89#define FIELD_OFFSET(x,y) offsetof(x,y)
90#endif
91
92VOS_STATUS sys_SendSmeStartReq( v_CONTEXT_t pVosContext );
93
94// add this to the sys Context data... ?
95typedef struct
96{
97 sysResponseCback mcStartCB;
98 v_VOID_t * mcStartUserData;
99
100} sysContextData;
101
Vinay Krishna Eranna0fe2e7c2014-04-09 21:32:08 +0530102// sysStop 20 Seconds timeout
103#define SYS_STOP_TIMEOUT 20000
Jeff Johnson295189b2012-06-20 16:38:30 -0700104static vos_event_t gStopEvt;
105
106VOS_STATUS sysBuildMessageHeader( SYS_MSG_ID sysMsgId, vos_msg_t *pMsg )
107{
108 pMsg->type = sysMsgId;
109 pMsg->reserved = SYS_MSG_COOKIE;
110
111 return( VOS_STATUS_SUCCESS );
112}
113
114
115VOS_STATUS sysOpen( v_CONTEXT_t pVosContext )
116{
117 return( VOS_STATUS_SUCCESS );
118}
119
120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
122v_VOID_t sysStopCompleteCb
123(
124 v_VOID_t *pUserData
125)
126{
127 vos_event_t* pStopEvt = (vos_event_t *) pUserData;
128 VOS_STATUS vosStatus;
129/*-------------------------------------------------------------------------*/
130
131 vosStatus = vos_event_set( pStopEvt );
132 VOS_ASSERT( VOS_IS_STATUS_SUCCESS ( vosStatus ) );
133
134} /* vos_sys_stop_complete_cback() */
135
136VOS_STATUS sysStop( v_CONTEXT_t pVosContext )
137{
138 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
139 vos_msg_t sysMsg;
140 v_U8_t evtIndex;
141
142 /* Initialize the stop event */
143 vosStatus = vos_event_init( &gStopEvt );
144
145 if(! VOS_IS_STATUS_SUCCESS( vosStatus ))
146 {
147 return vosStatus;
148 }
149
150 /* post a message to SYS module in MC to stop SME and MAC */
151 sysBuildMessageHeader( SYS_MSG_ID_MC_STOP, &sysMsg );
152
Arun Kumar Khandavalli513fdab2014-02-17 15:32:39 +0530153 // Save the user callback and user data
154
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 // finished.
Arun Kumar Khandavalli513fdab2014-02-17 15:32:39 +0530156 sysMsg.callback = sysStopCompleteCb;
157 sysMsg.bodyptr = (void *) &gStopEvt;
Jeff Johnson295189b2012-06-20 16:38:30 -0700158
159 // post the message..
160 vosStatus = vos_mq_post_message( VOS_MQ_ID_SYS, &sysMsg );
161 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
162 {
163 vosStatus = VOS_STATUS_E_BADMSG;
164 }
165
Vinay Krishna Eranna0fe2e7c2014-04-09 21:32:08 +0530166 vosStatus = vos_wait_events( &gStopEvt, 1, SYS_STOP_TIMEOUT, &evtIndex );
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 VOS_ASSERT( VOS_IS_STATUS_SUCCESS ( vosStatus ) );
168
169 vosStatus = vos_event_destroy( &gStopEvt );
170 VOS_ASSERT( VOS_IS_STATUS_SUCCESS ( vosStatus ) );
171
172 return( vosStatus );
173}
174
175
176VOS_STATUS sysClose( v_CONTEXT_t pVosContext )
177{
178 return( VOS_STATUS_SUCCESS );
179}
180
181
Jeff Johnson295189b2012-06-20 16:38:30 -0700182
183
184
Jeff Johnson295189b2012-06-20 16:38:30 -0700185
186#if defined(__ANI_COMPILER_PRAGMA_PACK_STACK)
187#pragma pack( push )
188#pragma pack( 1 )
189#elif defined(__ANI_COMPILER_PRAGMA_PACK)
190#pragma pack( 1 )
191#endif
192
193typedef struct sPolFileVersion
194{
195 unsigned char MajorVersion;
196 unsigned char MinorVersion;
197 unsigned char Suffix;
198 unsigned char Build;
199
200} tPolFileVersion;
201
202
203typedef struct sPolFileHeader
204{
205 tPolFileVersion FileVersion;
206 tPolFileVersion HWCapabilities;
Arun Kumar Khandavallid82bcc82014-02-17 18:52:29 +0530207 unsigned int FileLength;
208 unsigned int NumDirectoryEntries;
Jeff Johnson295189b2012-06-20 16:38:30 -0700209
210} tPolFileHeader;
211
212
213typedef enum ePolFileDirTypes
214{
215 ePOL_DIR_TYPE_BOOTLOADER = 0,
216 ePOL_DIR_TYPE_STA_FIRMWARE,
217 ePOL_DIR_TYPE_AP_FIRMWARE,
218 ePOL_DIR_TYPE_DIAG_FIRMWARE,
219 ePOL_DIR_TYPE_STA_CONFIG,
220 ePOL_DIR_TYPE_AP_CONFIG
221
222} tPolFileDirTypes;
223
224
225typedef struct sPolFileDirEntry
226{
Arun Kumar Khandavallid82bcc82014-02-17 18:52:29 +0530227 unsigned int DirEntryType;
228 unsigned int DirEntryFileOffset;
229 unsigned int DirEntryLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700230
231} tPolFileDirEntry;
232
233#if defined(__ANI_COMPILER_PRAGMA_PACK_STACK)
234#pragma pack( pop )
235#endif
236
237
238static unsigned short polFileChkSum( unsigned short *FileData, unsigned long NumWords )
239{
240 unsigned long Sum;
241
242 for ( Sum = 0; NumWords > 0; NumWords-- )
243 {
244 Sum += *FileData++;
245 }
246
247 Sum = (Sum >> 16) + (Sum & 0xffff); // add carry
248 Sum += (Sum >> 16); // maybe last unsigned short
249
250 return( (unsigned short)( ~Sum ) );
251}
252
Jeff Johnson295189b2012-06-20 16:38:30 -0700253v_BOOL_t sys_validateStaConfig( void *pImage, unsigned long cbFile,
254 void **ppStaConfig, v_SIZE_t *pcbStaConfig )
Jeff Johnson295189b2012-06-20 16:38:30 -0700255{
256 v_BOOL_t fFound = VOS_FALSE;
257 tPolFileHeader *pFileHeader = NULL;
258 tPolFileDirEntry *pDirEntry = NULL;
259 v_U32_t idx;
260
261 do
262 {
263 // Compute the checksum before bothering to copy...
264 if ( polFileChkSum( ( v_U16_t *)pImage, cbFile / sizeof( v_U16_t ) ) )
265 {
266 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
267 "Failed to validate the checksum for CFG binary" );
268 break;
269 }
270
271 pFileHeader = (tPolFileHeader *)pImage;
272
273 *ppStaConfig = NULL;
274 *pcbStaConfig = 0;
275
276 pDirEntry = ( tPolFileDirEntry* ) ( pFileHeader + 1 );
277
278 for ( idx = 0; idx < pFileHeader->NumDirectoryEntries; ++idx )
279 {
280 if ( ePOL_DIR_TYPE_STA_CONFIG == pDirEntry[ idx ].DirEntryType )
281 {
282 *ppStaConfig = pDirEntry[ idx ].DirEntryFileOffset + ( v_U8_t * )pFileHeader;
283
284 *pcbStaConfig = pDirEntry[ idx ].DirEntryLength;
285
286 break;
287 }
288
289 } // End iteration over the header's entries
290
291 if ( NULL != *ppStaConfig )
292 {
293 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO_LOW,
294 "Found the Station CFG in the CFG binary!!" );
295
296 fFound = VOS_TRUE;
297 }
298 else
299 {
300 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
301 "Failed to find Station CFG in the CFG binary" );
302 }
303
304 } while( 0 );
305
306 VOS_ASSERT( VOS_TRUE == fFound );
307
308 return( fFound );
309}
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312
313
314
315
316
Jeff Johnson295189b2012-06-20 16:38:30 -0700317
318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319
320VOS_STATUS sysMcProcessMsg( v_CONTEXT_t pVosContext, vos_msg_t *pMsg )
321{
322 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
323 v_VOID_t *hHal;
324
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800325 if (NULL == pMsg)
326 {
327 VOS_ASSERT(0);
328 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
329 "%s: NULL pointer to vos_msg_t", __func__);
330 return VOS_STATUS_E_INVAL;
331 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700332
333 // All 'new' SYS messages are identified by a cookie in the reserved
334 // field of the message as well as the message type. This prevents
335 // the possibility of overlap in the message types defined for new
336 // SYS messages with the 'legacy' message types. The legacy messages
337 // will not have this cookie in the reserved field
338 if ( SYS_MSG_COOKIE == pMsg->reserved )
339 {
340 // Process all the new SYS messages..
341 switch( pMsg->type )
342 {
343 case SYS_MSG_ID_MC_START:
344 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 /* Handling for this message is not needed now so adding
346 *debug print and VOS_ASSERT*/
347 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson71845522013-10-30 12:29:05 -0700348 " Received SYS_MSG_ID_MC_START message msgType= %d [0x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 pMsg->type, pMsg->type );
350 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 break;
352 }
353
354 case SYS_MSG_ID_MC_STOP:
355 {
356 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO,
357 "Processing SYS MC STOP" );
358
359 // get the HAL context...
360 hHal = vos_get_context( VOS_MODULE_ID_PE, pVosContext );
361 if (NULL == hHal)
362 {
363 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700364 "%s: Invalid hHal", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 }
366 else
367 {
Kiet Lama72a2322013-11-15 11:18:11 +0530368 vosStatus = sme_Stop( hHal, HAL_STOP_TYPE_SYS_DEEP_SLEEP);
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
370
371 vosStatus = macStop( hHal, HAL_STOP_TYPE_SYS_DEEP_SLEEP );
372 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
373
Arun Kumar Khandavalli513fdab2014-02-17 15:32:39 +0530374 ((sysResponseCback)pMsg->callback)((v_VOID_t *)pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700375
376 vosStatus = VOS_STATUS_SUCCESS;
377 }
378 break;
379 }
380
381 // Process MC thread probe. Just callback to the
382 // function that is in the message.
383 case SYS_MSG_ID_MC_THR_PROBE:
384 {
Abhishek Singh880d7122015-08-26 16:23:04 +0530385#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
386 if(pMsg->callback)
387 ((sysThreadProbeCback)pMsg->callback)(current->pid);
388#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 break;
390 }
391
392 case SYS_MSG_ID_MC_TIMER:
393 {
Jeff Johnson02127982013-12-09 09:19:48 -0800394 vos_timer_callback_t timerCB = pMsg->callback;
Jeff Johnson295189b2012-06-20 16:38:30 -0700395
Jeff Johnson02127982013-12-09 09:19:48 -0800396 if (NULL != timerCB)
397 {
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530398 vos_ssr_protect(__func__);
Jeff Johnson02127982013-12-09 09:19:48 -0800399 timerCB(pMsg->bodyptr);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530400 vos_ssr_unprotect(__func__);
Jeff Johnson02127982013-12-09 09:19:48 -0800401 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700402 break;
403 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 case SYS_MSG_ID_FTM_RSP:
405 {
406 WLANFTM_McProcessMsg((v_VOID_t *)pMsg->bodyptr);
407 break;
408 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 default:
410 {
411 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson71845522013-10-30 12:29:05 -0700412 "Unknown message type in sysMcProcessMsg() msgType= %d [0x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 pMsg->type, pMsg->type );
414 break;
415 }
416
417 } // end switch on message type
418
419 } // end if cookie set
420 else
421 {
422 // Process all 'legacy' messages
423 switch( pMsg->type )
424 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700425
426 default:
427 {
428 VOS_ASSERT( 0 );
429
430 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
431 "Received SYS message cookie with unidentified "
Jeff Johnson71845522013-10-30 12:29:05 -0700432 "MC message type= %d [0x%08X]", pMsg->type, pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -0700433
434 vosStatus = VOS_STATUS_E_BADMSG;
435 if (pMsg->bodyptr)
436 vos_mem_free(pMsg->bodyptr);
437 break;
438 }
439 } // end switch on pMsg->type
440 } // end else
441
442 return( vosStatus );
443}
444
445
446
447
448VOS_STATUS sysTxProcessMsg( v_CONTEXT_t pVosContext, vos_msg_t *pMsg )
449{
450 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
451
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800452 if (NULL == pMsg)
453 {
454 VOS_ASSERT(0);
455 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
456 "%s: NULL pointer to vos_msg_t", __func__);
457 return VOS_STATUS_E_INVAL;
458 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700459
460 // All 'new' SYS messages are identified by a cookie in the reserved
461 // field of the message as well as the message type. This prevents
462 // the possibility of overlap in the message types defined for new
463 // SYS messages with the 'legacy' message types. The legacy messages
464 // will not have this cookie in the reserved field
465 if ( SYS_MSG_COOKIE == pMsg->reserved )
466 {
467 // Process all the new SYS messages..
468 switch( pMsg->type )
469 {
470 // Process TX thread probe. Just callback to the
471 // function that is in the message.
472 case SYS_MSG_ID_TX_THR_PROBE:
473 {
Abhishek Singh880d7122015-08-26 16:23:04 +0530474#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
475 if(pMsg->callback)
476 ((sysThreadProbeCback)pMsg->callback)(current->pid);
477#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 break;
479 }
480
481 case SYS_MSG_ID_TX_TIMER:
482 {
Jeff Johnson02127982013-12-09 09:19:48 -0800483 vos_timer_callback_t timerCB = pMsg->callback;
Jeff Johnson295189b2012-06-20 16:38:30 -0700484
Jeff Johnson02127982013-12-09 09:19:48 -0800485 if (NULL != timerCB)
486 {
487 timerCB(pMsg->bodyptr);
488 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 break;
490 }
491
492 default:
493 {
494 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson71845522013-10-30 12:29:05 -0700495 "Unknown message type in sysTxProcessMsg() msgType= %d [0x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 pMsg->type, pMsg->type );
497 break;
498 }
499
500 } // end switch on message type
501 } // end if cookie set
502 else
503 {
504 VOS_ASSERT( 0 );
505
506 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
507 "Received SYS message cookie with unidentified TX message "
Jeff Johnson71845522013-10-30 12:29:05 -0700508 " type= %d [0x%08X]", pMsg->type, pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -0700509
510 vosStatus = VOS_STATUS_E_BADMSG;
511 } // end else
512
513 return( vosStatus );
514}
515
516
Jeff Johnson295189b2012-06-20 16:38:30 -0700517VOS_STATUS sysRxProcessMsg( v_CONTEXT_t pVosContext, vos_msg_t *pMsg )
518{
519 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
520
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800521 if (NULL == pMsg)
522 {
523 VOS_ASSERT(0);
524 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
525 "%s: NULL pointer to vos_msg_t", __func__);
526 return VOS_STATUS_E_INVAL;
527 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
529 // All 'new' SYS messages are identified by a cookie in the reserved
530 // field of the message as well as the message type. This prevents
531 // the possibility of overlap in the message types defined for new
532 // SYS messages with the 'legacy' message types. The legacy messages
533 // will not have this cookie in the reserved field
534 if ( SYS_MSG_COOKIE == pMsg->reserved )
535 {
536 // Process all the new SYS messages..
537 switch( pMsg->type )
538 {
539 case SYS_MSG_ID_RX_TIMER:
540 {
Jeff Johnson02127982013-12-09 09:19:48 -0800541 vos_timer_callback_t timerCB = pMsg->callback;
Jeff Johnson295189b2012-06-20 16:38:30 -0700542
Jeff Johnson02127982013-12-09 09:19:48 -0800543 if (NULL != timerCB)
544 {
545 timerCB(pMsg->bodyptr);
546 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 break;
548 }
549
Abhishek Singh880d7122015-08-26 16:23:04 +0530550 case SYS_MSG_ID_RX_THR_PROBE:
551 {
552#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
553 if(pMsg->callback)
554 ((sysThreadProbeCback)pMsg->callback)(current->pid);
555#endif
556 break;
557 }
558
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 default:
560 {
561 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson71845522013-10-30 12:29:05 -0700562 "Unknown message type in sysRxProcessMsg() msgType= %d [0x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 pMsg->type, pMsg->type );
564 break;
565 }
566
567 } // end switch on message type
568 } // end if cookie set
569 else
570 {
571 VOS_ASSERT( 0 );
572
573 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
574 "Received SYS message cookie with unidentified RX message "
Jeff Johnson71845522013-10-30 12:29:05 -0700575 " type= %d [0x%08X]", pMsg->type, pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -0700576
577 vosStatus = VOS_STATUS_E_BADMSG;
578 } // end else
579
580 return( vosStatus );
581}
582
Jeff Johnson295189b2012-06-20 16:38:30 -0700583
584v_VOID_t sysMcFreeMsg( v_CONTEXT_t pVContext, vos_msg_t* pMsg )
585{
586 return;
587}
588
589
590v_VOID_t sysTxFreeMsg( v_CONTEXT_t pVContext, vos_msg_t* pMsg )
591{
592 return;
593}
594
595
596void
597SysProcessMmhMsg
598(
599 tpAniSirGlobal pMac,
600 tSirMsgQ* pMsg
601)
602{
603 VOS_MQ_ID targetMQ = VOS_MQ_ID_SYS;
604/*-------------------------------------------------------------------------*/
605 /*
606 ** The body of this pMsg is a tSirMbMsg
607 ** Contrary to Gen4, we cannot free it here!
608 ** It is up to the callee to free it
609 */
610
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700611
612 if (NULL == pMsg)
613 {
614 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
615 "NULL Message Pointer");
616 VOS_ASSERT(0);
617 return;
618 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700619
620
621 switch (pMsg->type)
622 {
623 /*
624 ** Following messages are routed to SYS
625 */
626 case WNI_CFG_DNLD_REQ:
627 case WNI_CFG_DNLD_CNF:
628 case WDA_APP_SETUP_NTF:
629 case WDA_NIC_OPER_NTF:
630 case WDA_RESET_REQ:
631 case eWNI_SME_START_RSP:
632 {
633 /* Forward this message to the SYS module */
634 targetMQ = VOS_MQ_ID_SYS;
635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
637 "Handling for the Message ID %d is removed in SYS\r\n",
638 pMsg->type);
639
640 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 break;
642 }
643
644
645 /*
646 ** Following messages are routed to HAL
647 */
648 case WNI_CFG_DNLD_RSP:
649 case WDA_INIT_START_REQ:
650 {
651 /* Forward this message to the HAL module */
652 targetMQ = VOS_MQ_ID_WDA;
653
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
655 "Handling for the Message ID %d is removed as there is no HAL \r\n",
656 pMsg->type);
657
658 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 break;
660 }
661
662 case eWNI_SME_START_REQ:
663 case WNI_CFG_GET_REQ:
664 case WNI_CFG_SET_REQ:
665 case WNI_CFG_SET_REQ_NO_RSP:
666 case eWNI_SME_SYS_READY_IND:
667 {
668 /* Forward this message to the PE module */
669 targetMQ = VOS_MQ_ID_PE;
670 break;
671 }
672
673
674 case WNI_CFG_GET_RSP:
675 case WNI_CFG_SET_CNF:
676/* case eWNI_SME_DISASSOC_RSP:
677 case eWNI_SME_STA_STAT_RSP:
678 case eWNI_SME_AGGR_STAT_RSP:
679 case eWNI_SME_GLOBAL_STAT_RSP:
680 case eWNI_SME_STAT_SUMM_RSP:
681 case eWNI_PMC_ENTER_BMPS_RSP:
682 case eWNI_PMC_EXIT_BMPS_RSP:
683 case eWNI_PMC_EXIT_BMPS_IND:
684 case eWNI_PMC_ENTER_IMPS_RSP:
685 case eWNI_PMC_EXIT_IMPS_RSP:
686 case eWNI_PMC_ENTER_UAPSD_RSP:
687 case eWNI_PMC_EXIT_UAPSD_RSP:
688 case eWNI_PMC_ENTER_WOWL_RSP:
689 case eWNI_PMC_EXIT_WOWL_RSP:
690 case eWNI_SME_SWITCH_CHL_REQ: */ //Taken care by the check in default case
691 {
692 /* Forward this message to the SME module */
693 targetMQ = VOS_MQ_ID_SME;
694 break;
695 }
696
697 default:
698 {
699
700 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN ) && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
701 {
702 targetMQ = VOS_MQ_ID_SME;
703 break;
704 }
705
706 VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
707 "Message of ID %d is not yet handled by SYS\r\n",
708 pMsg->type);
709
710 VOS_ASSERT(0);
711 }
712
713 }
714
715
716 /*
717 ** Post now the message to the appropriate module for handling
718 */
719 if(VOS_STATUS_SUCCESS != vos_mq_post_message(targetMQ, (vos_msg_t*)pMsg))
720 {
721 //Caller doesn't allocate memory for the pMsg. It allocate memory for bodyptr
722 /* free the mem and return */
723 if(pMsg->bodyptr)
724 {
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530725 vos_mem_free( pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 }
727 }
728
729} /* SysProcessMmhMsg() */
730
Jeff Johnson295189b2012-06-20 16:38:30 -0700731/*==========================================================================
732 FUNCTION WLAN_FTM_SYS_FTM
733
734 DESCRIPTION
735 Called by VOSS to free a given FTM message on the Main thread when there
736 are messages pending in the queue when the whole system is been reset.
737
738 DEPENDENCIES
739 FTM must be initialized before this function can be called.
740
741 PARAMETERS
742
743 IN
744 pvosGCtx: pointer to the global vos context; a handle to FTM's
745 control block can be extracted from its context
746 message: type and content of the message
747
748
749 RETURN VALUE
750 The result code associated with performing the operation
751
752 VOS_STATUS_SUCCESS:
753
754 SIDE EFFECTS
755 NONE
756============================================================================*/
757
758void wlan_sys_ftm(void *pMsgPtr)
759{
760 vos_msg_t vosMessage;
761
762
763
764 vosMessage.reserved = FTM_SYS_MSG_COOKIE;
765 vosMessage.type = SYS_MSG_ID_FTM_RSP;
766 vosMessage.bodyptr = pMsgPtr;
767
768 vos_mq_post_message(VOS_MQ_ID_SYS, &vosMessage);
769
770 return;
771}
772
Jeff Johnson295189b2012-06-20 16:38:30 -0700773
774
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700775void wlan_sys_probe(void)
776{
777 vos_msg_t vosMessage;
778
779 vosMessage.reserved = FTM_SYS_MSG_COOKIE;
780 vosMessage.type = SYS_MSG_ID_MC_THR_PROBE;
Hanumantha Reddy Pothulabbfac7a2015-11-09 11:23:58 +0530781 vosMessage.callback = NULL;
Sameer Thalappil6d69cbd2013-06-27 13:07:15 -0700782 vosMessage.bodyptr = NULL;
783
784 vos_mq_post_message(VOS_MQ_ID_SYS, &vosMessage);
785
786 return;
787}
788