1 /**************************************************************************** 2 **+-----------------------------------------------------------------------+** 3 **| |** 4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |** 5 **| All rights reserved. |** 6 **| |** 7 **| Redistribution and use in source and binary forms, with or without |** 8 **| modification, are permitted provided that the following conditions |** 9 **| are met: |** 10 **| |** 11 **| * Redistributions of source code must retain the above copyright |** 12 **| notice, this list of conditions and the following disclaimer. |** 13 **| * Redistributions in binary form must reproduce the above copyright |** 14 **| notice, this list of conditions and the following disclaimer in |** 15 **| the documentation and/or other materials provided with the |** 16 **| distribution. |** 17 **| * Neither the name Texas Instruments nor the names of its |** 18 **| contributors may be used to endorse or promote products derived |** 19 **| from this software without specific prior written permission. |** 20 **| |** 21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |** 22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |** 23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |** 24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |** 25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |** 26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |** 27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |** 28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |** 29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |** 30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |** 31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |** 32 **| |** 33 **+-----------------------------------------------------------------------+** 34 ****************************************************************************/ 35 36 37 /** \file connInfra.c 38 * \brief Infra connection implementation 39 * 40 * \see connInfra.h 41 */ 42 43 #include "report.h" 44 #include "osTIType.h" 45 #include "osApi.h" 46 #include "conn.h" 47 #include "connInfra.h" 48 #include "fsm.h" 49 #include "siteMgrApi.h" 50 #include "smeSmApi.h" 51 #include "rsnApi.h" 52 #include "DataCtrl_Api.h" 53 #include "paramIn.h" 54 #include "paramOut.h" 55 #include "siteHash.h" 56 #include "smeSm.h" 57 #include "PowerMgr_API.h" 58 #include "measurementMgrApi.h" 59 #include "TrafficMonitorAPI.h" 60 #include "qosMngr_API.h" 61 #include "EvHandler.h" 62 #include "SwitchChannelApi.h" 63 #include "ScanCncnApi.h" 64 #include "currBss.h" 65 #include "EvHandler.h" 66 #include "healthMonitor.h" 67 #include "regulatoryDomainApi.h" 68 #include "SoftGeminiApi.h" 69 70 #ifdef EXC_MODULE_INCLUDED 71 #include "excMngr.h" 72 #include "excTSMngr.h" 73 #endif 74 75 #define DISCONNECT_TIMEOUT 800 76 77 /* Local functions prototypes */ 78 79 static TI_STATUS actionUnexpected(void *pData); 80 81 static TI_STATUS actionNop(void *pData); 82 83 static TI_STATUS Idle_to_ScrWait(void *pData); 84 85 static TI_STATUS Idle_to_Idle(void *pData); 86 87 static TI_STATUS ScrWait_to_idle(void *pData); 88 89 static TI_STATUS ScrWait_to_JoinWait(void *pData); 90 91 static TI_STATUS JoinWait_to_mlmeWait(void *pData); 92 93 static TI_STATUS JoinWait_to_Idle(void *pData); 94 95 static TI_STATUS mlmeWait_to_Idle(void *pData); 96 97 static TI_STATUS mlmeWait_to_rsnWait(void *pData); 98 99 static TI_STATUS rsnWait_to_disassociate(void *pData); 100 101 static TI_STATUS rsnWait_to_configHW(void *pData); 102 103 static TI_STATUS configHW_to_connected(void *pData); 104 105 static TI_STATUS configHW_to_disassociate(void *pData); 106 107 static TI_STATUS connect_to_disassociate(void *pData); 108 109 static TI_STATUS connect_to_ScrWait(void *pData); 110 111 static TI_STATUS disAssocc_to_idle(void *pData); 112 113 114 115 static TI_STATUS stopModules( conn_t *pConn ); 116 117 void InfraConnSM_ScrCB( TI_HANDLE hConn, scr_clientRequestStatus_e requestStatus, 118 scr_pendReason_e pendReason ); 119 120 int conn_MboxFlushFinishCb(TI_HANDLE pData,UINT16 MboxStatus, char *InterrogateParamsBuf); 121 122 /********************************************/ 123 /* Functions Implementations */ 124 /********************************************/ 125 126 127 /*********************************************************************** 128 * conn_infraConfig 129 *********************************************************************** 130 DESCRIPTION: Infra Connection configuration function, called by the conection set param function 131 in the selection phase. Configures the connection state machine to Infra connection mode 132 133 INPUT: hConn - Connection handle. 134 135 OUTPUT: 136 137 RETURN: OK on success, NOK otherwise 138 139 ************************************************************************/ 140 TI_STATUS conn_infraConfig(conn_t *pConn) 141 { 142 fsm_actionCell_t smMatrix[CONN_INFRA_NUM_STATES][CONN_INFRA_NUM_EVENTS] = 143 { 144 /* next state and actions for IDLE state */ 145 { {STATE_CONN_INFRA_SCR_WAIT, Idle_to_ScrWait}, /* "EVENT_CONNECT" */ 146 {STATE_CONN_INFRA_IDLE, actionNop }, /* "EVENT_SCR_SUCC"*/ 147 {STATE_CONN_INFRA_IDLE, actionNop }, /* "EVENT_JOIN_CMD_CMPLT */ 148 {STATE_CONN_INFRA_IDLE, Idle_to_Idle }, /* "EVENT_DISCONNECT" */ 149 {STATE_CONN_INFRA_IDLE, actionUnexpected}, /* "EVENT_MLME_SUCC"*/ 150 {STATE_CONN_INFRA_IDLE, actionUnexpected}, /* "EVENT_RSN_SUCC" */ 151 {STATE_CONN_INFRA_IDLE, actionUnexpected}, /* "EVENT_CONFIG_HW" */ 152 {STATE_CONN_INFRA_IDLE, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */ 153 }, 154 155 /* next state and actions for SCR_WAIT state */ 156 { {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_CONNECT" */ 157 {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, ScrWait_to_JoinWait}, /* "EVENT_SCR_SUCC"*/ 158 {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT */ 159 {STATE_CONN_INFRA_IDLE, ScrWait_to_idle}, /* "EVENT_DISCONNECT" */ 160 {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_MLME_SUCC"*/ 161 {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_RSN_SUCC" */ 162 {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_CONFIG_HW "*/ 163 {STATE_CONN_INFRA_SCR_WAIT, actionNop} /* "EVENT_DISASSOC_FRAME_SENT" */ 164 }, 165 166 /* next state and actions for WAIT_JOIN_CMPLT */ 167 168 { {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_CONNECT" */ 169 {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_SCR_SUCC"*/ 170 {STATE_CONN_INFRA_MLME_WAIT, JoinWait_to_mlmeWait}, /* "EVENT_JOIN_CMD_CMPLT" */ 171 {STATE_CONN_INFRA_IDLE, JoinWait_to_Idle}, /* "EVENT_DISCONNECT" */ 172 {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_MLME_SUCC"*/ 173 {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_RSN_SUCC" */ 174 {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_CONFIG_HW" */ 175 {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */ 176 177 }, 178 179 /* next state and actions for MLME_WAIT state */ 180 { {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_CONNECT" */ 181 {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_SCR_SUCC" */ 182 {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT"*/ 183 {STATE_CONN_INFRA_IDLE, mlmeWait_to_Idle}, /* "EVENT_DISCONNECT" */ 184 {STATE_CONN_INFRA_RSN_WAIT, mlmeWait_to_rsnWait}, /* "EVENT_MLME_SUCC"*/ 185 {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_RSN_SUCC" */ 186 {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_CONFIG_HW" */ 187 {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */ 188 }, 189 190 /* next state and actions for RSN_WAIT state */ 191 { {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_CONNECT" */ 192 {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_SCR_SUCC" */ 193 {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT"*/ 194 {STATE_CONN_INFRA_DISASSOCC, rsnWait_to_disassociate}, /* "EVENT_DISCONNECT" */ 195 {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_MLME_SUCC"*/ 196 {STATE_CONN_INFRA_CONFIG_HW, rsnWait_to_configHW}, /* "EVENT_RSN_SUCC" */ 197 {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_CONFIG_HW" */ 198 {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */ 199 }, 200 201 /* next state and actions for CONFIG_HW state */ 202 { {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_CONNECT" */ 203 {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_SCR_SUCC" */ 204 {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT"*/ 205 {STATE_CONN_INFRA_DISASSOCC, configHW_to_disassociate}, /* "EVENT_DISCONNECT" */ 206 {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_MLME_SUCC"*/ 207 {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_RSN_SUCC" */ 208 {STATE_CONN_INFRA_CONNECTED, configHW_to_connected}, /* "EVENT_CONFIG_HW" */ 209 {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */ 210 }, 211 212 /* next state and actions for CONNECTED state */ 213 { {STATE_CONN_INFRA_SCR_WAIT, connect_to_ScrWait}, /* "EVENT_CONNECT" */ 214 {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_SCR_SUCC"*/ 215 {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT" */ 216 {STATE_CONN_INFRA_DISASSOCC, connect_to_disassociate}, /* "EVENT_DISCONNECT" */ 217 {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_MLME_SUCC"*/ 218 {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_RSN_SUCC" */ 219 {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "STATE_CONN_INFRA_CONFIG_HW" */ 220 {STATE_CONN_INFRA_CONNECTED, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */ 221 }, 222 223 /* next state and actions for STATE_CONN_INFRA_DISASSOCC state */ 224 { {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_CONNECT" */ 225 {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "STATE_CONN_INFRA_SCR_WAIT"*/ 226 {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT" */ 227 {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_DISCONNECT" */ 228 {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_MLME_SUCC"*/ 229 {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_RSN_SUCC" */ 230 {STATE_CONN_INFRA_DISASSOCC, actionNop }, /* "STATE_CONN_INFRA_CONFIG_HW" */ 231 {STATE_CONN_INFRA_IDLE, disAssocc_to_idle} /* "EVENT_DISASSOC_FRAME_SENT" */ 232 } 233 234 }; 235 236 scr_registerClientCB( pConn->hScr, SCR_CID_CONNECT, InfraConnSM_ScrCB, pConn ); 237 238 return fsm_Config(pConn->infra_pFsm, (fsm_Matrix_t)smMatrix, CONN_INFRA_NUM_STATES, CONN_INFRA_NUM_EVENTS, conn_infraSMEvent, pConn->hOs); 239 } 240 241 /*********************************************************************** 242 * conn_infraSMEvent 243 *********************************************************************** 244 DESCRIPTION: Infra Connection SM event processing function, called by the connection API 245 Perform the following: 246 - Print the state movement as a result from the event 247 - Calls the generic state machine event processing function which preform the following: 248 - Calls the correspoding callback function 249 - Move to next state 250 251 INPUT: currentState - Pointer to the connection current state. 252 event - Received event 253 pConn - Connection handle 254 255 OUTPUT: 256 257 RETURN: OK on success, NOK otherwise 258 259 ************************************************************************/ 260 261 #ifdef REPORT_LOG 262 263 static char *stateDesc[CONN_INFRA_NUM_STATES] = 264 { 265 "STATE_INFRA_IDLE", 266 "STATE_INFRA_SCR_WAIT", 267 "STATE_INFRA_WAIT_JOIN_CMPLT", 268 "STATE_INFRA_MLME_WAIT", 269 "STATE_INFRA_RSN_WAIT", 270 "STATE_INFRA_CONFIG_HW", 271 "STATE_INFRA_CONNECTED", 272 "STATE_INFRA_DISASSOCC", 273 }; 274 275 276 static char *eventDesc[CONN_INFRA_NUM_EVENTS] = 277 { 278 "EVENT_INFRA_CONNECT", 279 "EVENT_INFRA_SCR_SUCC", 280 "EVENT_INFRA_JOIN_CMD_CMPLT", 281 "EVENT_INFRA_DISCONNECT", 282 "EVENT_INFRA_MLME_SUCC", 283 "EVENT_INFRA_RSN_SUCC", 284 "EVENT_INFRA_HW_CONFIGURED", 285 "EVENT_INFRA_DISCONN_COMPLETE", 286 }; 287 288 #endif 289 290 TI_STATUS conn_infraSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hConn) 291 { 292 conn_t *pConn = (conn_t *)hConn; 293 TI_STATUS status; 294 UINT8 nextState; 295 296 status = fsm_GetNextState(pConn->infra_pFsm, *currentState, event, &nextState); 297 if (status != OK) 298 { 299 WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, ("State machine error, failed getting next state\n")); 300 return(NOK); 301 } 302 303 WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, 304 ("INFRA: <%s, %s> --> %s\n\n", 305 stateDesc[*currentState], 306 eventDesc[event], 307 stateDesc[nextState])); 308 309 status = fsm_Event(pConn->infra_pFsm, currentState, event, (void *)pConn); 310 311 return status; 312 } 313 314 /************************************************************************************************************/ 315 /* In the following section are listed the callback function used by the Infra connection state machine */ 316 /************************************************************************************************************/ 317 318 /* JOIN, SET_DATA_PORT_NOTIFY, START_MLME */ 319 static TI_STATUS ScrWait_to_JoinWait(void *pData) 320 { 321 TI_STATUS status; 322 conn_t *pConn = (conn_t *)pData; 323 324 /* set Hw available for the duration of the connection */ 325 MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION); 326 327 status = siteMgr_join(((conn_t *)pData)->hSiteMgr ); 328 /* If the Join command was failed we report the SME that connection failure so it could exit connecting state */ 329 if (status != OK) 330 { 331 WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Join command has failed!\n")); 332 } 333 return status; 334 } 335 336 337 static TI_STATUS JoinWait_to_mlmeWait(void *pData) 338 { 339 TI_STATUS status; 340 paramInfo_t param; 341 conn_t *pConn = (conn_t *)pData; 342 343 txData_start(pConn->hTxData); 344 345 param.paramType = REGULATORY_DOMAIN_TX_POWER_AFTER_SELECTION_PARAM; 346 regulatoryDomain_setParam(pConn->hRegulatoryDomain, ¶m); 347 348 param.paramType = RX_DATA_PORT_STATUS_PARAM; 349 param.content.rxDataPortStatus = OPEN_NOTIFY; 350 status = rxData_setParam(pConn->hRxData, ¶m); 351 if (status != OK) 352 return status; 353 354 param.paramType = TX_DATA_PORT_STATUS_PARAM; 355 param.content.txDataPortStatus = OPEN_NOTIFY; 356 status = txData_setParam(pConn->hTxData, ¶m); 357 if (status != OK) 358 return status; 359 360 /* 361 * Set the reassociation flag in the association logic. 362 */ 363 param.paramType = MLME_RE_ASSOC_PARAM; 364 365 if( pConn->connType == CONN_TYPE_ROAM ) 366 param.content.mlmeReAssoc = TRUE; 367 else 368 param.content.mlmeReAssoc = FALSE; 369 370 status = mlme_setParam(pConn->hMlmeSm, ¶m); 371 372 return mlme_start(pConn->hMlmeSm); 373 } 374 375 376 /* STOP_MLME, SET_DATA_PORT_CLOSE, DIS_JOIN */ 377 static TI_STATUS mlmeWait_to_Idle(void *pData) 378 { 379 TI_STATUS status; 380 paramInfo_t param; 381 conn_t *pConn = (conn_t *)pData; 382 383 status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP ); 384 if (status != OK) 385 return status; 386 387 param.paramType = RX_DATA_PORT_STATUS_PARAM; 388 param.content.rxDataPortStatus = CLOSE; 389 rxData_setParam(pConn->hRxData, ¶m); 390 391 392 param.paramType = TX_DATA_PORT_STATUS_PARAM; 393 param.content.txDataPortStatus = CLOSE; 394 txData_setParam(pConn->hTxData, ¶m); 395 396 /* set Hw not available now that the connection process failed */ 397 MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION); 398 399 whalCtrl_FwDisconnect(pConn->hHalCtrl, 400 RX_CONFIG_OPTION_MY_DST_MY_BSS, 401 RX_FILTER_OPTION_FILTER_ALL ); 402 403 #ifdef EXC_MODULE_INCLUDED 404 excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC); 405 #endif 406 407 scr_clientComplete(pConn->hScr, SCR_CID_CONNECT ); 408 409 pConn->scrRequested = FALSE; 410 411 /* 412 * Call the connection lost callback set by the SME or AP_CONN. 413 */ 414 pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode); 415 416 return OK; 417 } 418 419 /* This function is called from the WAIT_FOR_JOIN_CB_CMPLT state (before mlme_start) 420 - all we need to do is call siteMgr_disJoin */ 421 static TI_STATUS JoinWait_to_Idle(void *pData) 422 { 423 conn_t *pConn = (conn_t *)pData; 424 425 whalCtrl_FwDisconnect(pConn->hHalCtrl, 426 RX_CONFIG_OPTION_MY_DST_MY_BSS, 427 RX_FILTER_OPTION_FILTER_ALL ); 428 429 /* set Hw not available now that the connection process failed */ 430 MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION); 431 432 scr_clientComplete( pConn->hScr, SCR_CID_CONNECT ); 433 pConn->scrRequested = FALSE; 434 435 /* 436 * Call the connection lost callback set by the SME or AP_CONN. 437 */ 438 pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode); 439 440 return OK; 441 } 442 443 /* SET_DATA_PORT_EAPOL, START_RSN */ 444 static TI_STATUS mlmeWait_to_rsnWait(void *pData) 445 { 446 TI_STATUS status; 447 paramInfo_t param; 448 conn_t *pConn = (conn_t *)pData; 449 450 param.paramType = RX_DATA_PORT_STATUS_PARAM; 451 param.content.rxDataPortStatus = OPEN_EAPOL; 452 status = rxData_setParam(pConn->hRxData, ¶m); 453 if (status != OK) 454 return status; 455 456 param.paramType = TX_DATA_PORT_STATUS_PARAM; 457 param.content.txDataPortStatus = OPEN_EAPOL; 458 status = txData_setParam(pConn->hTxData, ¶m); 459 if (status != OK) 460 return status; 461 462 /* 463 * Notify that the driver is associated to the supplicant\IP stack. 464 */ 465 EvHandlerSendEvent(pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0); 466 467 return rsn_start(pConn->hRsn); 468 } 469 470 471 472 /* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */ 473 static TI_STATUS rsnWait_to_disassociate(void *pData) 474 { 475 TI_STATUS status; 476 paramInfo_t param; 477 conn_t *pConn = (conn_t *)pData; 478 479 status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys); 480 if (status != OK) 481 return status; 482 483 param.paramType = RX_DATA_PORT_STATUS_PARAM; 484 param.content.rxDataPortStatus = CLOSE; 485 status = rxData_setParam(pConn->hRxData, ¶m); 486 if (status != OK) 487 return status; 488 489 param.paramType = TX_DATA_PORT_STATUS_PARAM; 490 param.content.txDataPortStatus = CLOSE; 491 status = txData_setParam(pConn->hTxData, ¶m); 492 if (status != OK) 493 return status; 494 495 /* Start the disconnect complete time out timer. 496 This should be done BEFORE calling mlme_stop, which invokes Disconect Complete 497 event, which stops the timer. */ 498 os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE); 499 500 status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP ); 501 502 if (status != OK) 503 return status; 504 505 return OK; 506 } 507 508 509 /* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */ 510 static TI_STATUS configHW_to_disassociate(void *pData) 511 { 512 TI_STATUS status; 513 paramInfo_t param; 514 conn_t *pConn = (conn_t *)pData; 515 516 status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys ); 517 if (status != OK) 518 return status; 519 520 param.paramType = RX_DATA_PORT_STATUS_PARAM; 521 param.content.rxDataPortStatus = CLOSE; 522 status = rxData_setParam(pConn->hRxData, ¶m); 523 if (status != OK) 524 return status; 525 526 param.paramType = TX_DATA_PORT_STATUS_PARAM; 527 param.content.txDataPortStatus = CLOSE; 528 status = txData_setParam(pConn->hTxData, ¶m); 529 if (status != OK) 530 return status; 531 532 /* Start the disconnect complete time out timer. 533 This should be done BEFORE calling mlme_stop, which invokes Disconect Complete 534 event, which stops the timer. */ 535 os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE); 536 537 status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP ); 538 if (status != OK) 539 return status; 540 541 param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM; 542 regulatoryDomain_setParam(pConn->hRegulatoryDomain, ¶m); 543 544 /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the 545 supported rates, and stopModules clears all rates. */ 546 stopModules(pConn); 547 548 return OK; 549 } 550 551 static TI_STATUS connect_to_disassociate(void *pData) 552 { 553 TI_STATUS status; 554 paramInfo_t param; 555 conn_t *pConn = (conn_t *)pData; 556 557 status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys); 558 if (status != OK) 559 return status; 560 561 param.paramType = RX_DATA_PORT_STATUS_PARAM; 562 param.content.rxDataPortStatus = CLOSE; 563 status = rxData_setParam(pConn->hRxData, ¶m); 564 if (status != OK) 565 return status; 566 567 param.paramType = TX_DATA_PORT_STATUS_PARAM; 568 param.content.txDataPortStatus = CLOSE; 569 status = txData_setParam(pConn->hTxData, ¶m); 570 if (status != OK) 571 return status; 572 573 param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM; 574 regulatoryDomain_setParam(pConn->hRegulatoryDomain, ¶m); 575 576 /* Start the disconnect complete time out timer. 577 This should be done BEFORE calling mlme_stop, which invokes Disconect Complete 578 event, which stops the timer. */ 579 os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE); 580 581 status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP ); 582 if (status != OK) 583 return status; 584 585 /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the 586 supported rates, and stopModules clears all rates. */ 587 stopModules(pConn); 588 589 return OK; 590 591 } 592 593 594 static TI_STATUS rsnWait_to_configHW(void *pData) 595 { 596 conn_t *pConn=(conn_t *)pData; 597 TI_STATUS status; 598 static UINT8 buf[20]; /* for mailbox interrogate leave the "static" flag !!!*/ 599 paramInfo_t param; 600 601 /* Open the RX to DATA */ 602 param.paramType = RX_DATA_PORT_STATUS_PARAM; 603 param.content.rxDataPortStatus = OPEN; 604 status = rxData_setParam(pConn->hRxData, ¶m); 605 if (status != OK) 606 return status; 607 608 status = ctrlData_start(pConn->hCtrlData); 609 if (status != OK) 610 { 611 WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__)); 612 return status; 613 } 614 615 status = qosMngr_connect(pConn->hQosMngr); 616 if (status != OK) 617 { 618 WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__)); 619 return status; 620 } 621 622 status = measurementMgr_connected(pConn->hMeasurementMgr); 623 if (status != OK) 624 { 625 WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__)); 626 return status; 627 } 628 629 status = TrafficMonitor_Start(pConn->hTrafficMonitor); 630 if (status != OK) 631 { 632 WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__)); 633 return status; 634 } 635 636 healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_CONNECTED); 637 638 switchChannel_start(pConn->hSwitchChannel); 639 640 scanConcentrator_switchToConnected( pConn->hScanCnc ); 641 642 PowerMgr_startPS(pConn->hPwrMngr); 643 644 whalCtrl_InterrogateMbox(pConn->hHalCtrl, (void *)conn_MboxFlushFinishCb,pData,&buf[0]); 645 646 return OK; 647 } 648 649 /* Interrogate command CB to indicates that the Mbox is flushed*/ 650 int conn_MboxFlushFinishCb(TI_HANDLE pData,UINT16 MboxStatus, char *InterrogateParamsBuf) 651 { 652 conn_t *pConn = (conn_t *)pData; 653 return conn_infraSMEvent(&pConn->state, CONN_INFRA_HW_CONFIGURED, pConn); 654 } 655 656 657 static TI_STATUS configHW_to_connected(void *pData) 658 { 659 TI_STATUS status; 660 paramInfo_t param; 661 conn_t *pConn=(conn_t *)pData; 662 663 664 param.paramType = TX_DATA_PORT_STATUS_PARAM; 665 param.content.txDataPortStatus = OPEN; 666 status = txData_setParam(pConn->hTxData, ¶m); 667 if (status != OK) 668 return status; 669 670 #ifdef EXC_MODULE_INCLUDED 671 excMngr_updateIappInformation(pConn->hExcMngr, EXC_ASSOC_OK); 672 #endif 673 674 /* Start keep alive process */ 675 siteMgr_start(pConn->hSiteMgr); 676 677 scr_clientComplete( pConn->hScr, SCR_CID_CONNECT ); 678 pConn->scrRequested = FALSE; 679 680 /* Update current BSS connection type and mode */ 681 currBSS_updateConnectedState(pConn->hCurrBss, TRUE, BSS_INFRASTRUCTURE); 682 683 pConn->pConnStatusCB( pConn->connStatCbObj, STATUS_SUCCESSFUL, 0); 684 685 /* set Hw not available now that the connection process ended successfully */ 686 MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION); 687 688 SoftGemini_SetPSmode(pConn->hSoftGemini); 689 690 WLAN_OS_REPORT(("************ NEW CONNECTION ************\n")); 691 siteMgr_printPrimarySiteDesc(pConn->hSiteMgr); 692 693 return OK; 694 } 695 696 697 static TI_STATUS actionUnexpected(void *pData) 698 { 699 conn_t *pConn = (conn_t *)pData; 700 701 WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, ("State machine error, unexpected Event\n\n")); 702 return OK; 703 } 704 705 static TI_STATUS actionNop(void *pData) 706 { 707 return OK; 708 } 709 710 711 static TI_STATUS Idle_to_ScrWait(void *pData) 712 { 713 scr_clientRequestStatus_e scrReplyStatus; 714 scr_pendReason_e scrPendReason; 715 716 conn_t *pConn = (conn_t *)pData; 717 718 WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, 719 ("Infra Connnect SM: Requesting SCR.\n") ); 720 721 scrReplyStatus = scr_clientRequest( pConn->hScr, SCR_CID_CONNECT, &scrPendReason ); 722 723 pConn->scrRequested = TRUE; 724 725 /* request the SCR as application (either BG or FG) client, and act according to return status */ 726 switch ( scrReplyStatus ) 727 { 728 case SCR_CRS_PEND: 729 /* send a pend event to the SM */ 730 WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, 731 ("Infra Conn: SCR pending with pend reason: %d, stay in wait SCR state.\n", 732 scrPendReason) ); 733 break; 734 735 case SCR_CRS_RUN: 736 /* send an SCR SUCCESS event to the SM */ 737 WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: SCR acquired.\n") ); 738 739 conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn); 740 break; 741 742 default: 743 WLAN_REPORT_ERROR( pConn->hReport, CONN_MODULE_LOG, 744 ("Infra Conn: SCR returned unrecognized status: %d.\n", scrReplyStatus) ); 745 return NOK; 746 } 747 748 return OK; 749 } 750 751 752 753 void InfraConnSM_ScrCB( TI_HANDLE hConn, scr_clientRequestStatus_e requestStatus, 754 scr_pendReason_e pendReason ) 755 { 756 conn_t *pConn = (conn_t *)hConn; 757 758 WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, 759 ("InfraConnSM_ScrCB called by SCR. Status is: %d.\n", requestStatus) ); 760 761 /* act according to the request staus */ 762 switch ( requestStatus ) 763 { 764 case SCR_CRS_RUN: 765 /* send an SCR SUCCESS event to the SM */ 766 WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: SCR acquired.\n") ); 767 768 conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn); 769 break; 770 771 case SCR_CRS_FW_RESET: 772 /* Ignore FW reset, the MLME SM will handle re-try of the conn */ 773 WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: Recovery occured.\n") ); 774 break; 775 776 default: 777 WLAN_REPORT_ERROR( pConn->hReport, CONN_MODULE_LOG, 778 ("Illegal SCR request status:%d, pend reason:%d.\n", 779 requestStatus, pendReason) ); 780 break; 781 } 782 783 return; 784 } 785 786 787 788 static TI_STATUS ScrWait_to_idle(void *pData) 789 { 790 conn_t *pConn = (conn_t *)pData; 791 792 WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, 793 ("Infra Connnect SM: Stop event while in SCR wait, moving to IDLE.\n") ); 794 795 scr_clientComplete( pConn->hScr, SCR_CID_CONNECT ); 796 pConn->scrRequested = FALSE; 797 798 /* 799 * Call the connection lost callback set by the SME or AP_CONN. 800 */ 801 pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode); 802 803 return OK; 804 805 } 806 807 808 static TI_STATUS stopModules( conn_t *pConn ) 809 { 810 811 measurementMgr_disconnected(pConn->hMeasurementMgr); 812 813 rxData_stop(pConn->hRxData); 814 815 ctrlData_stop(pConn->hCtrlData); 816 817 TrafficMonitor_Stop(pConn->hTrafficMonitor); 818 819 switchChannel_stop(pConn->hSwitchChannel); 820 821 healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_DISCONNECTED); 822 823 siteMgr_stop(pConn->hSiteMgr); 824 825 /* stopping power save */ 826 PowerMgr_stopPS(pConn->hPwrMngr); 827 828 scanConcentrator_switchToNotConnected( pConn->hScanCnc ); 829 830 /* Set Current BSS Module to stop triggerring roaming events */ 831 currBSS_updateConnectedState(pConn->hCurrBss, FALSE, BSS_INFRASTRUCTURE); 832 833 SoftGemini_unSetPSmode(pConn->hSoftGemini); 834 835 return OK; 836 } 837 838 839 static TI_STATUS disAssocc_to_idle(void *pData) 840 { 841 conn_t *pConn = (conn_t *)pData; 842 843 /* Stop the disconnect timeout timer. */ 844 os_timerStop(((conn_t *)pData)->hOs, ((conn_t *)pData)->pTimer); 845 846 /* 847 * Tx Data Stop and QoS disconnect must be called only after the disconnect (dissasociate/deauthenticate) 848 * has been sent, or else no TX complete is received! 849 */ 850 txData_stop(pConn->hTxData); 851 qosMngr_disconnect(pConn->hQosMngr); 852 853 #ifdef EXC_MODULE_INCLUDED 854 measurementMgr_disableTsMetrics(pConn->hMeasurementMgr, MAX_NUM_OF_AC); 855 #endif 856 857 /* set Hw not available now that the connection process failed */ 858 MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION); 859 860 whalCtrl_FwDisconnect(pConn->hHalCtrl, 861 RX_CONFIG_OPTION_MY_DST_MY_BSS, 862 RX_FILTER_OPTION_FILTER_ALL); 863 864 #ifdef EXC_MODULE_INCLUDED 865 excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC); 866 #endif 867 868 /* 869 * Call the connection lost callback set by the SME or AP_CONN. 870 */ 871 pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode); 872 873 /* 874 * In case of connection failuer we might get here without freeing the SCR. 875 */ 876 if( pConn->scrRequested == TRUE ){ 877 scr_clientComplete( pConn->hScr, SCR_CID_CONNECT ); 878 pConn->scrRequested = FALSE; 879 } 880 881 882 return OK; 883 884 } 885 886 887 888 static TI_STATUS connect_to_ScrWait(void *pData) 889 { 890 TI_STATUS status; 891 paramInfo_t param; 892 conn_t *pConn = (conn_t *)pData; 893 /* 894 * This function performs roaming by two steps: 895 * First - close the current connection without notify the SME. 896 * Second - start new connection in reassociation mode. 897 */ 898 899 900 status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys); 901 if (status != OK) 902 return status; 903 904 param.paramType = RX_DATA_PORT_STATUS_PARAM; 905 param.content.rxDataPortStatus = CLOSE; 906 status = rxData_setParam(pConn->hRxData, ¶m); 907 if (status != OK) 908 return status; 909 910 param.paramType = TX_DATA_PORT_STATUS_PARAM; 911 param.content.txDataPortStatus = CLOSE; 912 status = txData_setParam(pConn->hTxData, ¶m); 913 if (status != OK) 914 return status; 915 916 status = mlme_stop(pConn->hMlmeSm, DISCONN_TYPE_IMMEDIATE, pConn->disConnReasonToAP); 917 if (status != OK) 918 return status; 919 920 param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM; 921 regulatoryDomain_setParam(pConn->hRegulatoryDomain, ¶m); 922 923 #ifdef EXC_MODULE_INCLUDED 924 excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC); 925 #endif 926 /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the 927 supported rates, and stopModules clears all rates. */ 928 stopModules(pConn); 929 930 /* 931 * Tx Data Stop and QoS disconnect must be called only after the disconnect (dissasociate/deauthenticate) 932 * has been sent. In this case no deauthenticate frame is sent bu still we keep the 933 * order. 934 */ 935 txData_stop(pConn->hTxData); 936 qosMngr_disconnect(pConn->hQosMngr); 937 938 /* 939 * Start new connection. 940 */ 941 Idle_to_ScrWait(pConn); 942 943 return OK; 944 } 945 946 static TI_STATUS Idle_to_Idle(void *pData) 947 { 948 conn_t *pConn = (conn_t *)pData; 949 950 /* 951 * In case we are in IDLE and getting DISCONNECT event, we need to inform 952 * the SME\AP_connection that we are disconnected. 953 * Call the connection lost callback set by the SME or AP_CONN. 954 */ 955 pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode); 956 957 return OK; 958 } 959 960 /*********************************************************************** 961 connInfra_JoinCmpltNotification 962 *********************************************************************** 963 DESCRIPTION: Call back upon receving Join Event Complete. 964 965 INPUT: hSiteMgr - site mgr handle. 966 967 OUTPUT: 968 969 RETURN: 970 ************************************************************************/ 971 TI_STATUS connInfra_JoinCmpltNotification(TI_HANDLE hconn) 972 { 973 conn_t *pConn = (conn_t *)hconn; 974 975 WLAN_REPORT_INFORMATION(pConn->hReport, SITE_MGR_MODULE_LOG, 976 ("siteMgr_JoinCmplt: has been called\n")); 977 978 txData_disableTransmission(pConn->hTxData, NO_DISABLE); 979 980 if (pConn->currentConnType == CONNECTION_INFRA ) { 981 conn_infraSMEvent(&pConn->state, CONN_INFRA_JOIN_CMD_CMPLT, pConn); 982 } 983 984 return OK; 985 } 986