Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 3 | * |
| 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 Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 21 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | /*=========================================================================== |
| 29 | |
| 30 | W L A N S Y S T E M M O D U L E |
| 31 | |
| 32 | |
| 33 | DESCRIPTION |
| 34 | This file contains the system module that implements the 'exectution model' |
| 35 | in the Gen6 host software. |
| 36 | |
| 37 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 38 | ===========================================================================*/ |
| 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 | |
| 52 | when who what, where, why |
| 53 | -------- --- ----------------------------------------------------- |
| 54 | 12/15/08 sho Resolved AMSS compiler errors and warnings when this |
| 55 | is being ported from WM |
| 56 | 07/02/08 lac Added support for eWNI_SME_START_REQ/RSP in init seq |
| 57 | 06/26/08 hba Added implementation of mbReceiveMBMsg() |
| 58 | 06/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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 72 | #include "sme_Api.h" |
| 73 | #include "macInitApi.h" |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 74 | #include "vos_sched.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 75 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 76 | VOS_STATUS WLANFTM_McProcessMsg (v_VOID_t *message); |
| 77 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 78 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 83 | #define FTM_SYS_MSG_COOKIE 0xFACE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 84 | |
| 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 | |
| 92 | VOS_STATUS sys_SendSmeStartReq( v_CONTEXT_t pVosContext ); |
| 93 | |
| 94 | // add this to the sys Context data... ? |
| 95 | typedef struct |
| 96 | { |
| 97 | sysResponseCback mcStartCB; |
| 98 | v_VOID_t * mcStartUserData; |
| 99 | |
| 100 | } sysContextData; |
| 101 | |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 102 | // sysStop 20 Seconds timeout |
| 103 | #define SYS_STOP_TIMEOUT 20000 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 104 | static vos_event_t gStopEvt; |
| 105 | |
| 106 | VOS_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 | |
| 115 | VOS_STATUS sysOpen( v_CONTEXT_t pVosContext ) |
| 116 | { |
| 117 | return( VOS_STATUS_SUCCESS ); |
| 118 | } |
| 119 | |
| 120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 121 | |
| 122 | v_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 | |
| 136 | VOS_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 Khandavalli | 513fdab | 2014-02-17 15:32:39 +0530 | [diff] [blame] | 153 | // Save the user callback and user data |
| 154 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 155 | // finished. |
Arun Kumar Khandavalli | 513fdab | 2014-02-17 15:32:39 +0530 | [diff] [blame] | 156 | sysMsg.callback = sysStopCompleteCb; |
| 157 | sysMsg.bodyptr = (void *) &gStopEvt; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 158 | |
| 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 Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 166 | vosStatus = vos_wait_events( &gStopEvt, 1, SYS_STOP_TIMEOUT, &evtIndex ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 167 | 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 | |
| 176 | VOS_STATUS sysClose( v_CONTEXT_t pVosContext ) |
| 177 | { |
| 178 | return( VOS_STATUS_SUCCESS ); |
| 179 | } |
| 180 | |
| 181 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 182 | |
| 183 | |
| 184 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 185 | |
| 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 | |
| 193 | typedef struct sPolFileVersion |
| 194 | { |
| 195 | unsigned char MajorVersion; |
| 196 | unsigned char MinorVersion; |
| 197 | unsigned char Suffix; |
| 198 | unsigned char Build; |
| 199 | |
| 200 | } tPolFileVersion; |
| 201 | |
| 202 | |
| 203 | typedef struct sPolFileHeader |
| 204 | { |
| 205 | tPolFileVersion FileVersion; |
| 206 | tPolFileVersion HWCapabilities; |
Arun Kumar Khandavalli | d82bcc8 | 2014-02-17 18:52:29 +0530 | [diff] [blame] | 207 | unsigned int FileLength; |
| 208 | unsigned int NumDirectoryEntries; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 209 | |
| 210 | } tPolFileHeader; |
| 211 | |
| 212 | |
| 213 | typedef 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 | |
| 225 | typedef struct sPolFileDirEntry |
| 226 | { |
Arun Kumar Khandavalli | d82bcc8 | 2014-02-17 18:52:29 +0530 | [diff] [blame] | 227 | unsigned int DirEntryType; |
| 228 | unsigned int DirEntryFileOffset; |
| 229 | unsigned int DirEntryLength; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 230 | |
| 231 | } tPolFileDirEntry; |
| 232 | |
| 233 | #if defined(__ANI_COMPILER_PRAGMA_PACK_STACK) |
| 234 | #pragma pack( pop ) |
| 235 | #endif |
| 236 | |
| 237 | |
| 238 | static 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 253 | v_BOOL_t sys_validateStaConfig( void *pImage, unsigned long cbFile, |
| 254 | void **ppStaConfig, v_SIZE_t *pcbStaConfig ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 255 | { |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 317 | |
| 318 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 319 | |
| 320 | VOS_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 Prakash | fb58546 | 2013-12-23 19:07:07 -0800 | [diff] [blame] | 325 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 332 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 345 | /* 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 Johnson | 7184552 | 2013-10-30 12:29:05 -0700 | [diff] [blame] | 348 | " Received SYS_MSG_ID_MC_START message msgType= %d [0x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 349 | pMsg->type, pMsg->type ); |
| 350 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 351 | 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 Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 364 | "%s: Invalid hHal", __func__ ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 365 | } |
| 366 | else |
| 367 | { |
Kiet Lam | a72a232 | 2013-11-15 11:18:11 +0530 | [diff] [blame] | 368 | vosStatus = sme_Stop( hHal, HAL_STOP_TYPE_SYS_DEEP_SLEEP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 369 | 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 Khandavalli | 513fdab | 2014-02-17 15:32:39 +0530 | [diff] [blame] | 374 | ((sysResponseCback)pMsg->callback)((v_VOID_t *)pMsg->bodyptr); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 375 | |
| 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 Singh | 880d712 | 2015-08-26 16:23:04 +0530 | [diff] [blame] | 385 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 386 | if(pMsg->callback) |
| 387 | ((sysThreadProbeCback)pMsg->callback)(current->pid); |
| 388 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 389 | break; |
| 390 | } |
| 391 | |
| 392 | case SYS_MSG_ID_MC_TIMER: |
| 393 | { |
Jeff Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 394 | vos_timer_callback_t timerCB = pMsg->callback; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 395 | |
Jeff Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 396 | if (NULL != timerCB) |
| 397 | { |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 398 | vos_ssr_protect(__func__); |
Jeff Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 399 | timerCB(pMsg->bodyptr); |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 400 | vos_ssr_unprotect(__func__); |
Jeff Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 401 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 402 | break; |
| 403 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 404 | case SYS_MSG_ID_FTM_RSP: |
| 405 | { |
| 406 | WLANFTM_McProcessMsg((v_VOID_t *)pMsg->bodyptr); |
| 407 | break; |
| 408 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 409 | default: |
| 410 | { |
| 411 | VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 7184552 | 2013-10-30 12:29:05 -0700 | [diff] [blame] | 412 | "Unknown message type in sysMcProcessMsg() msgType= %d [0x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 413 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 425 | |
| 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 Johnson | 7184552 | 2013-10-30 12:29:05 -0700 | [diff] [blame] | 432 | "MC message type= %d [0x%08X]", pMsg->type, pMsg->type ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 433 | |
| 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 | |
| 448 | VOS_STATUS sysTxProcessMsg( v_CONTEXT_t pVosContext, vos_msg_t *pMsg ) |
| 449 | { |
| 450 | VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; |
| 451 | |
Manjunathappa Prakash | fb58546 | 2013-12-23 19:07:07 -0800 | [diff] [blame] | 452 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 459 | |
| 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 Singh | 880d712 | 2015-08-26 16:23:04 +0530 | [diff] [blame] | 474 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 475 | if(pMsg->callback) |
| 476 | ((sysThreadProbeCback)pMsg->callback)(current->pid); |
| 477 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 478 | break; |
| 479 | } |
| 480 | |
| 481 | case SYS_MSG_ID_TX_TIMER: |
| 482 | { |
Jeff Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 483 | vos_timer_callback_t timerCB = pMsg->callback; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 484 | |
Jeff Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 485 | if (NULL != timerCB) |
| 486 | { |
| 487 | timerCB(pMsg->bodyptr); |
| 488 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 489 | break; |
| 490 | } |
| 491 | |
| 492 | default: |
| 493 | { |
| 494 | VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 7184552 | 2013-10-30 12:29:05 -0700 | [diff] [blame] | 495 | "Unknown message type in sysTxProcessMsg() msgType= %d [0x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 496 | 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 Johnson | 7184552 | 2013-10-30 12:29:05 -0700 | [diff] [blame] | 508 | " type= %d [0x%08X]", pMsg->type, pMsg->type ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 509 | |
| 510 | vosStatus = VOS_STATUS_E_BADMSG; |
| 511 | } // end else |
| 512 | |
| 513 | return( vosStatus ); |
| 514 | } |
| 515 | |
| 516 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 517 | VOS_STATUS sysRxProcessMsg( v_CONTEXT_t pVosContext, vos_msg_t *pMsg ) |
| 518 | { |
| 519 | VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; |
| 520 | |
Manjunathappa Prakash | fb58546 | 2013-12-23 19:07:07 -0800 | [diff] [blame] | 521 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 528 | |
| 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 Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 541 | vos_timer_callback_t timerCB = pMsg->callback; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 542 | |
Jeff Johnson | 0212798 | 2013-12-09 09:19:48 -0800 | [diff] [blame] | 543 | if (NULL != timerCB) |
| 544 | { |
| 545 | timerCB(pMsg->bodyptr); |
| 546 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 547 | break; |
| 548 | } |
| 549 | |
Abhishek Singh | 880d712 | 2015-08-26 16:23:04 +0530 | [diff] [blame] | 550 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 559 | default: |
| 560 | { |
| 561 | VOS_TRACE( VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 7184552 | 2013-10-30 12:29:05 -0700 | [diff] [blame] | 562 | "Unknown message type in sysRxProcessMsg() msgType= %d [0x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 563 | 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 Johnson | 7184552 | 2013-10-30 12:29:05 -0700 | [diff] [blame] | 575 | " type= %d [0x%08X]", pMsg->type, pMsg->type ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 576 | |
| 577 | vosStatus = VOS_STATUS_E_BADMSG; |
| 578 | } // end else |
| 579 | |
| 580 | return( vosStatus ); |
| 581 | } |
| 582 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 583 | |
| 584 | v_VOID_t sysMcFreeMsg( v_CONTEXT_t pVContext, vos_msg_t* pMsg ) |
| 585 | { |
| 586 | return; |
| 587 | } |
| 588 | |
| 589 | |
| 590 | v_VOID_t sysTxFreeMsg( v_CONTEXT_t pVContext, vos_msg_t* pMsg ) |
| 591 | { |
| 592 | return; |
| 593 | } |
| 594 | |
| 595 | |
| 596 | void |
| 597 | SysProcessMmhMsg |
| 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 Nakkala | 114718f | 2013-03-25 19:19:46 -0700 | [diff] [blame] | 611 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 619 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 636 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 641 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 654 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 659 | 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 Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 725 | vos_mem_free( pMsg->bodyptr); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 726 | } |
| 727 | } |
| 728 | |
| 729 | } /* SysProcessMmhMsg() */ |
| 730 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 731 | /*========================================================================== |
| 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 | |
| 758 | void 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 773 | |
| 774 | |
Sameer Thalappil | 6d69cbd | 2013-06-27 13:07:15 -0700 | [diff] [blame] | 775 | void 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; |
| 781 | vosMessage.bodyptr = NULL; |
| 782 | |
| 783 | vos_mq_post_message(VOS_MQ_ID_SYS, &vosMessage); |
| 784 | |
| 785 | return; |
| 786 | } |
| 787 | |