PageRenderTime 59ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/core/sme/conn/connInfra.c

http://github.com/CyanogenMod/cm-kernel
C | 985 lines | 575 code | 229 blank | 181 comment | 67 complexity | ef5821243bff42d878dca8b18a6aaffd MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  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. /** \file connInfra.c
  36. * \brief Infra connection implementation
  37. *
  38. * \see connInfra.h
  39. */
  40. #include "report.h"
  41. #include "osTIType.h"
  42. #include "osApi.h"
  43. #include "conn.h"
  44. #include "connInfra.h"
  45. #include "fsm.h"
  46. #include "siteMgrApi.h"
  47. #include "smeSmApi.h"
  48. #include "rsnApi.h"
  49. #include "DataCtrl_Api.h"
  50. #include "paramIn.h"
  51. #include "paramOut.h"
  52. #include "siteHash.h"
  53. #include "smeSm.h"
  54. #include "PowerMgr_API.h"
  55. #include "measurementMgrApi.h"
  56. #include "TrafficMonitorAPI.h"
  57. #include "qosMngr_API.h"
  58. #include "EvHandler.h"
  59. #include "SwitchChannelApi.h"
  60. #include "ScanCncnApi.h"
  61. #include "currBss.h"
  62. #include "EvHandler.h"
  63. #include "healthMonitor.h"
  64. #include "regulatoryDomainApi.h"
  65. #include "SoftGeminiApi.h"
  66. #ifdef EXC_MODULE_INCLUDED
  67. #include "excMngr.h"
  68. #include "excTSMngr.h"
  69. #endif
  70. #define DISCONNECT_TIMEOUT 800
  71. /* Local functions prototypes */
  72. static TI_STATUS actionUnexpected(void *pData);
  73. static TI_STATUS actionNop(void *pData);
  74. static TI_STATUS Idle_to_ScrWait(void *pData);
  75. static TI_STATUS Idle_to_Idle(void *pData);
  76. static TI_STATUS ScrWait_to_idle(void *pData);
  77. static TI_STATUS ScrWait_to_JoinWait(void *pData);
  78. static TI_STATUS JoinWait_to_mlmeWait(void *pData);
  79. static TI_STATUS JoinWait_to_Idle(void *pData);
  80. static TI_STATUS mlmeWait_to_Idle(void *pData);
  81. static TI_STATUS mlmeWait_to_rsnWait(void *pData);
  82. static TI_STATUS rsnWait_to_disassociate(void *pData);
  83. static TI_STATUS rsnWait_to_configHW(void *pData);
  84. static TI_STATUS configHW_to_connected(void *pData);
  85. static TI_STATUS configHW_to_disassociate(void *pData);
  86. static TI_STATUS connect_to_disassociate(void *pData);
  87. static TI_STATUS connect_to_ScrWait(void *pData);
  88. static TI_STATUS disAssocc_to_idle(void *pData);
  89. static TI_STATUS stopModules( conn_t *pConn );
  90. void InfraConnSM_ScrCB( TI_HANDLE hConn, scr_clientRequestStatus_e requestStatus,
  91. scr_pendReason_e pendReason );
  92. int conn_MboxFlushFinishCb(TI_HANDLE pData,UINT16 MboxStatus, char *InterrogateParamsBuf);
  93. /********************************************/
  94. /* Functions Implementations */
  95. /********************************************/
  96. /***********************************************************************
  97. * conn_infraConfig
  98. ***********************************************************************
  99. DESCRIPTION: Infra Connection configuration function, called by the conection set param function
  100. in the selection phase. Configures the connection state machine to Infra connection mode
  101. INPUT: hConn - Connection handle.
  102. OUTPUT:
  103. RETURN: OK on success, NOK otherwise
  104. ************************************************************************/
  105. TI_STATUS conn_infraConfig(conn_t *pConn)
  106. {
  107. fsm_actionCell_t smMatrix[CONN_INFRA_NUM_STATES][CONN_INFRA_NUM_EVENTS] =
  108. {
  109. /* next state and actions for IDLE state */
  110. { {STATE_CONN_INFRA_SCR_WAIT, Idle_to_ScrWait}, /* "EVENT_CONNECT" */
  111. {STATE_CONN_INFRA_IDLE, actionNop }, /* "EVENT_SCR_SUCC"*/
  112. {STATE_CONN_INFRA_IDLE, actionNop }, /* "EVENT_JOIN_CMD_CMPLT */
  113. {STATE_CONN_INFRA_IDLE, Idle_to_Idle }, /* "EVENT_DISCONNECT" */
  114. {STATE_CONN_INFRA_IDLE, actionUnexpected}, /* "EVENT_MLME_SUCC"*/
  115. {STATE_CONN_INFRA_IDLE, actionUnexpected}, /* "EVENT_RSN_SUCC" */
  116. {STATE_CONN_INFRA_IDLE, actionUnexpected}, /* "EVENT_CONFIG_HW" */
  117. {STATE_CONN_INFRA_IDLE, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */
  118. },
  119. /* next state and actions for SCR_WAIT state */
  120. { {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_CONNECT" */
  121. {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, ScrWait_to_JoinWait}, /* "EVENT_SCR_SUCC"*/
  122. {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT */
  123. {STATE_CONN_INFRA_IDLE, ScrWait_to_idle}, /* "EVENT_DISCONNECT" */
  124. {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_MLME_SUCC"*/
  125. {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_RSN_SUCC" */
  126. {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected}, /* "EVENT_CONFIG_HW "*/
  127. {STATE_CONN_INFRA_SCR_WAIT, actionNop} /* "EVENT_DISASSOC_FRAME_SENT" */
  128. },
  129. /* next state and actions for WAIT_JOIN_CMPLT */
  130. { {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_CONNECT" */
  131. {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_SCR_SUCC"*/
  132. {STATE_CONN_INFRA_MLME_WAIT, JoinWait_to_mlmeWait}, /* "EVENT_JOIN_CMD_CMPLT" */
  133. {STATE_CONN_INFRA_IDLE, JoinWait_to_Idle}, /* "EVENT_DISCONNECT" */
  134. {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_MLME_SUCC"*/
  135. {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_RSN_SUCC" */
  136. {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}, /* "EVENT_CONFIG_HW" */
  137. {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */
  138. },
  139. /* next state and actions for MLME_WAIT state */
  140. { {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_CONNECT" */
  141. {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_SCR_SUCC" */
  142. {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT"*/
  143. {STATE_CONN_INFRA_IDLE, mlmeWait_to_Idle}, /* "EVENT_DISCONNECT" */
  144. {STATE_CONN_INFRA_RSN_WAIT, mlmeWait_to_rsnWait}, /* "EVENT_MLME_SUCC"*/
  145. {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_RSN_SUCC" */
  146. {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}, /* "EVENT_CONFIG_HW" */
  147. {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */
  148. },
  149. /* next state and actions for RSN_WAIT state */
  150. { {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_CONNECT" */
  151. {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_SCR_SUCC" */
  152. {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT"*/
  153. {STATE_CONN_INFRA_DISASSOCC, rsnWait_to_disassociate}, /* "EVENT_DISCONNECT" */
  154. {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_MLME_SUCC"*/
  155. {STATE_CONN_INFRA_CONFIG_HW, rsnWait_to_configHW}, /* "EVENT_RSN_SUCC" */
  156. {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected}, /* "EVENT_CONFIG_HW" */
  157. {STATE_CONN_INFRA_RSN_WAIT, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */
  158. },
  159. /* next state and actions for CONFIG_HW state */
  160. { {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_CONNECT" */
  161. {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_SCR_SUCC" */
  162. {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT"*/
  163. {STATE_CONN_INFRA_DISASSOCC, configHW_to_disassociate}, /* "EVENT_DISCONNECT" */
  164. {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_MLME_SUCC"*/
  165. {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}, /* "EVENT_RSN_SUCC" */
  166. {STATE_CONN_INFRA_CONNECTED, configHW_to_connected}, /* "EVENT_CONFIG_HW" */
  167. {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */
  168. },
  169. /* next state and actions for CONNECTED state */
  170. { {STATE_CONN_INFRA_SCR_WAIT, connect_to_ScrWait}, /* "EVENT_CONNECT" */
  171. {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_SCR_SUCC"*/
  172. {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT" */
  173. {STATE_CONN_INFRA_DISASSOCC, connect_to_disassociate}, /* "EVENT_DISCONNECT" */
  174. {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_MLME_SUCC"*/
  175. {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "EVENT_RSN_SUCC" */
  176. {STATE_CONN_INFRA_CONNECTED, actionUnexpected}, /* "STATE_CONN_INFRA_CONFIG_HW" */
  177. {STATE_CONN_INFRA_CONNECTED, actionUnexpected} /* "EVENT_DISASSOC_FRAME_SENT" */
  178. },
  179. /* next state and actions for STATE_CONN_INFRA_DISASSOCC state */
  180. { {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_CONNECT" */
  181. {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "STATE_CONN_INFRA_SCR_WAIT"*/
  182. {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_JOIN_CMD_CMPLT" */
  183. {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_DISCONNECT" */
  184. {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_MLME_SUCC"*/
  185. {STATE_CONN_INFRA_DISASSOCC, actionUnexpected}, /* "EVENT_RSN_SUCC" */
  186. {STATE_CONN_INFRA_DISASSOCC, actionNop }, /* "STATE_CONN_INFRA_CONFIG_HW" */
  187. {STATE_CONN_INFRA_IDLE, disAssocc_to_idle} /* "EVENT_DISASSOC_FRAME_SENT" */
  188. }
  189. };
  190. scr_registerClientCB( pConn->hScr, SCR_CID_CONNECT, InfraConnSM_ScrCB, pConn );
  191. return fsm_Config(pConn->infra_pFsm, (fsm_Matrix_t)smMatrix, CONN_INFRA_NUM_STATES, CONN_INFRA_NUM_EVENTS, conn_infraSMEvent, pConn->hOs);
  192. }
  193. /***********************************************************************
  194. * conn_infraSMEvent
  195. ***********************************************************************
  196. DESCRIPTION: Infra Connection SM event processing function, called by the connection API
  197. Perform the following:
  198. - Print the state movement as a result from the event
  199. - Calls the generic state machine event processing function which preform the following:
  200. - Calls the correspoding callback function
  201. - Move to next state
  202. INPUT: currentState - Pointer to the connection current state.
  203. event - Received event
  204. pConn - Connection handle
  205. OUTPUT:
  206. RETURN: OK on success, NOK otherwise
  207. ************************************************************************/
  208. #ifdef REPORT_LOG
  209. static char *stateDesc[CONN_INFRA_NUM_STATES] =
  210. {
  211. "STATE_INFRA_IDLE",
  212. "STATE_INFRA_SCR_WAIT",
  213. "STATE_INFRA_WAIT_JOIN_CMPLT",
  214. "STATE_INFRA_MLME_WAIT",
  215. "STATE_INFRA_RSN_WAIT",
  216. "STATE_INFRA_CONFIG_HW",
  217. "STATE_INFRA_CONNECTED",
  218. "STATE_INFRA_DISASSOCC",
  219. };
  220. static char *eventDesc[CONN_INFRA_NUM_EVENTS] =
  221. {
  222. "EVENT_INFRA_CONNECT",
  223. "EVENT_INFRA_SCR_SUCC",
  224. "EVENT_INFRA_JOIN_CMD_CMPLT",
  225. "EVENT_INFRA_DISCONNECT",
  226. "EVENT_INFRA_MLME_SUCC",
  227. "EVENT_INFRA_RSN_SUCC",
  228. "EVENT_INFRA_HW_CONFIGURED",
  229. "EVENT_INFRA_DISCONN_COMPLETE",
  230. };
  231. #endif
  232. TI_STATUS conn_infraSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hConn)
  233. {
  234. conn_t *pConn = (conn_t *)hConn;
  235. TI_STATUS status;
  236. UINT8 nextState;
  237. status = fsm_GetNextState(pConn->infra_pFsm, *currentState, event, &nextState);
  238. if (status != OK)
  239. {
  240. WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, ("State machine error, failed getting next state\n"));
  241. return(NOK);
  242. }
  243. WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG,
  244. ("INFRA: <%s, %s> --> %s\n\n",
  245. stateDesc[*currentState],
  246. eventDesc[event],
  247. stateDesc[nextState]));
  248. status = fsm_Event(pConn->infra_pFsm, currentState, event, (void *)pConn);
  249. return status;
  250. }
  251. /************************************************************************************************************/
  252. /* In the following section are listed the callback function used by the Infra connection state machine */
  253. /************************************************************************************************************/
  254. /* JOIN, SET_DATA_PORT_NOTIFY, START_MLME */
  255. static TI_STATUS ScrWait_to_JoinWait(void *pData)
  256. {
  257. TI_STATUS status;
  258. conn_t *pConn = (conn_t *)pData;
  259. /* set Hw available for the duration of the connection */
  260. MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
  261. status = siteMgr_join(((conn_t *)pData)->hSiteMgr );
  262. /* If the Join command was failed we report the SME that connection failure so it could exit connecting state */
  263. if (status != OK)
  264. {
  265. WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Join command has failed!\n"));
  266. }
  267. return status;
  268. }
  269. static TI_STATUS JoinWait_to_mlmeWait(void *pData)
  270. {
  271. TI_STATUS status;
  272. paramInfo_t param;
  273. conn_t *pConn = (conn_t *)pData;
  274. txData_start(pConn->hTxData);
  275. param.paramType = REGULATORY_DOMAIN_TX_POWER_AFTER_SELECTION_PARAM;
  276. regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
  277. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  278. param.content.rxDataPortStatus = OPEN_NOTIFY;
  279. status = rxData_setParam(pConn->hRxData, &param);
  280. if (status != OK)
  281. return status;
  282. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  283. param.content.txDataPortStatus = OPEN_NOTIFY;
  284. status = txData_setParam(pConn->hTxData, &param);
  285. if (status != OK)
  286. return status;
  287. /*
  288. * Set the reassociation flag in the association logic.
  289. */
  290. param.paramType = MLME_RE_ASSOC_PARAM;
  291. if( pConn->connType == CONN_TYPE_ROAM )
  292. param.content.mlmeReAssoc = TRUE;
  293. else
  294. param.content.mlmeReAssoc = FALSE;
  295. status = mlme_setParam(pConn->hMlmeSm, &param);
  296. return mlme_start(pConn->hMlmeSm);
  297. }
  298. /* STOP_MLME, SET_DATA_PORT_CLOSE, DIS_JOIN */
  299. static TI_STATUS mlmeWait_to_Idle(void *pData)
  300. {
  301. TI_STATUS status;
  302. paramInfo_t param;
  303. conn_t *pConn = (conn_t *)pData;
  304. status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
  305. if (status != OK)
  306. return status;
  307. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  308. param.content.rxDataPortStatus = CLOSE;
  309. rxData_setParam(pConn->hRxData, &param);
  310. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  311. param.content.txDataPortStatus = CLOSE;
  312. txData_setParam(pConn->hTxData, &param);
  313. /* set Hw not available now that the connection process failed */
  314. MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
  315. whalCtrl_FwDisconnect(pConn->hHalCtrl,
  316. RX_CONFIG_OPTION_MY_DST_MY_BSS,
  317. RX_FILTER_OPTION_FILTER_ALL );
  318. #ifdef EXC_MODULE_INCLUDED
  319. excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC);
  320. #endif
  321. scr_clientComplete(pConn->hScr, SCR_CID_CONNECT );
  322. pConn->scrRequested = FALSE;
  323. /*
  324. * Call the connection lost callback set by the SME or AP_CONN.
  325. */
  326. pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
  327. return OK;
  328. }
  329. /* This function is called from the WAIT_FOR_JOIN_CB_CMPLT state (before mlme_start)
  330. - all we need to do is call siteMgr_disJoin */
  331. static TI_STATUS JoinWait_to_Idle(void *pData)
  332. {
  333. conn_t *pConn = (conn_t *)pData;
  334. whalCtrl_FwDisconnect(pConn->hHalCtrl,
  335. RX_CONFIG_OPTION_MY_DST_MY_BSS,
  336. RX_FILTER_OPTION_FILTER_ALL );
  337. /* set Hw not available now that the connection process failed */
  338. MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
  339. scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
  340. pConn->scrRequested = FALSE;
  341. /*
  342. * Call the connection lost callback set by the SME or AP_CONN.
  343. */
  344. pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
  345. return OK;
  346. }
  347. /* SET_DATA_PORT_EAPOL, START_RSN */
  348. static TI_STATUS mlmeWait_to_rsnWait(void *pData)
  349. {
  350. TI_STATUS status;
  351. paramInfo_t param;
  352. conn_t *pConn = (conn_t *)pData;
  353. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  354. param.content.rxDataPortStatus = OPEN_EAPOL;
  355. status = rxData_setParam(pConn->hRxData, &param);
  356. if (status != OK)
  357. return status;
  358. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  359. param.content.txDataPortStatus = OPEN_EAPOL;
  360. status = txData_setParam(pConn->hTxData, &param);
  361. if (status != OK)
  362. return status;
  363. /*
  364. * Notify that the driver is associated to the supplicant\IP stack.
  365. */
  366. EvHandlerSendEvent(pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);
  367. return rsn_start(pConn->hRsn);
  368. }
  369. /* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */
  370. static TI_STATUS rsnWait_to_disassociate(void *pData)
  371. {
  372. TI_STATUS status;
  373. paramInfo_t param;
  374. conn_t *pConn = (conn_t *)pData;
  375. status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
  376. if (status != OK)
  377. return status;
  378. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  379. param.content.rxDataPortStatus = CLOSE;
  380. status = rxData_setParam(pConn->hRxData, &param);
  381. if (status != OK)
  382. return status;
  383. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  384. param.content.txDataPortStatus = CLOSE;
  385. status = txData_setParam(pConn->hTxData, &param);
  386. if (status != OK)
  387. return status;
  388. /* Start the disconnect complete time out timer.
  389. This should be done BEFORE calling mlme_stop, which invokes Disconect Complete
  390. event, which stops the timer. */
  391. os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE);
  392. status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
  393. if (status != OK)
  394. return status;
  395. return OK;
  396. }
  397. /* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */
  398. static TI_STATUS configHW_to_disassociate(void *pData)
  399. {
  400. TI_STATUS status;
  401. paramInfo_t param;
  402. conn_t *pConn = (conn_t *)pData;
  403. status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys );
  404. if (status != OK)
  405. return status;
  406. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  407. param.content.rxDataPortStatus = CLOSE;
  408. status = rxData_setParam(pConn->hRxData, &param);
  409. if (status != OK)
  410. return status;
  411. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  412. param.content.txDataPortStatus = CLOSE;
  413. status = txData_setParam(pConn->hTxData, &param);
  414. if (status != OK)
  415. return status;
  416. /* Start the disconnect complete time out timer.
  417. This should be done BEFORE calling mlme_stop, which invokes Disconect Complete
  418. event, which stops the timer. */
  419. os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE);
  420. status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
  421. if (status != OK)
  422. return status;
  423. param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
  424. regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
  425. /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
  426. supported rates, and stopModules clears all rates. */
  427. stopModules(pConn);
  428. return OK;
  429. }
  430. static TI_STATUS connect_to_disassociate(void *pData)
  431. {
  432. TI_STATUS status;
  433. paramInfo_t param;
  434. conn_t *pConn = (conn_t *)pData;
  435. status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
  436. if (status != OK)
  437. return status;
  438. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  439. param.content.rxDataPortStatus = CLOSE;
  440. status = rxData_setParam(pConn->hRxData, &param);
  441. if (status != OK)
  442. return status;
  443. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  444. param.content.txDataPortStatus = CLOSE;
  445. status = txData_setParam(pConn->hTxData, &param);
  446. if (status != OK)
  447. return status;
  448. param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
  449. regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
  450. /* Start the disconnect complete time out timer.
  451. This should be done BEFORE calling mlme_stop, which invokes Disconect Complete
  452. event, which stops the timer. */
  453. os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE);
  454. status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
  455. if (status != OK)
  456. return status;
  457. /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
  458. supported rates, and stopModules clears all rates. */
  459. stopModules(pConn);
  460. return OK;
  461. }
  462. static TI_STATUS rsnWait_to_configHW(void *pData)
  463. {
  464. conn_t *pConn=(conn_t *)pData;
  465. TI_STATUS status;
  466. static UINT8 buf[20]; /* for mailbox interrogate leave the "static" flag !!!*/
  467. paramInfo_t param;
  468. /* Open the RX to DATA */
  469. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  470. param.content.rxDataPortStatus = OPEN;
  471. status = rxData_setParam(pConn->hRxData, &param);
  472. if (status != OK)
  473. return status;
  474. status = ctrlData_start(pConn->hCtrlData);
  475. if (status != OK)
  476. {
  477. WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
  478. return status;
  479. }
  480. status = qosMngr_connect(pConn->hQosMngr);
  481. if (status != OK)
  482. {
  483. WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
  484. return status;
  485. }
  486. status = measurementMgr_connected(pConn->hMeasurementMgr);
  487. if (status != OK)
  488. {
  489. WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
  490. return status;
  491. }
  492. status = TrafficMonitor_Start(pConn->hTrafficMonitor);
  493. if (status != OK)
  494. {
  495. WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
  496. return status;
  497. }
  498. healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_CONNECTED);
  499. switchChannel_start(pConn->hSwitchChannel);
  500. scanConcentrator_switchToConnected( pConn->hScanCnc );
  501. PowerMgr_startPS(pConn->hPwrMngr);
  502. whalCtrl_InterrogateMbox(pConn->hHalCtrl, (void *)conn_MboxFlushFinishCb,pData,&buf[0]);
  503. return OK;
  504. }
  505. /* Interrogate command CB to indicates that the Mbox is flushed*/
  506. int conn_MboxFlushFinishCb(TI_HANDLE pData,UINT16 MboxStatus, char *InterrogateParamsBuf)
  507. {
  508. conn_t *pConn = (conn_t *)pData;
  509. return conn_infraSMEvent(&pConn->state, CONN_INFRA_HW_CONFIGURED, pConn);
  510. }
  511. static TI_STATUS configHW_to_connected(void *pData)
  512. {
  513. TI_STATUS status;
  514. paramInfo_t param;
  515. conn_t *pConn=(conn_t *)pData;
  516. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  517. param.content.txDataPortStatus = OPEN;
  518. status = txData_setParam(pConn->hTxData, &param);
  519. if (status != OK)
  520. return status;
  521. #ifdef EXC_MODULE_INCLUDED
  522. excMngr_updateIappInformation(pConn->hExcMngr, EXC_ASSOC_OK);
  523. #endif
  524. /* Start keep alive process */
  525. siteMgr_start(pConn->hSiteMgr);
  526. scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
  527. pConn->scrRequested = FALSE;
  528. /* Update current BSS connection type and mode */
  529. currBSS_updateConnectedState(pConn->hCurrBss, TRUE, BSS_INFRASTRUCTURE);
  530. pConn->pConnStatusCB( pConn->connStatCbObj, STATUS_SUCCESSFUL, 0);
  531. /* set Hw not available now that the connection process ended successfully */
  532. MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
  533. SoftGemini_SetPSmode(pConn->hSoftGemini);
  534. WLAN_OS_REPORT(("************ NEW CONNECTION ************\n"));
  535. siteMgr_printPrimarySiteDesc(pConn->hSiteMgr);
  536. return OK;
  537. }
  538. static TI_STATUS actionUnexpected(void *pData)
  539. {
  540. conn_t *pConn = (conn_t *)pData;
  541. WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, ("State machine error, unexpected Event\n\n"));
  542. return OK;
  543. }
  544. static TI_STATUS actionNop(void *pData)
  545. {
  546. return OK;
  547. }
  548. static TI_STATUS Idle_to_ScrWait(void *pData)
  549. {
  550. scr_clientRequestStatus_e scrReplyStatus;
  551. scr_pendReason_e scrPendReason;
  552. conn_t *pConn = (conn_t *)pData;
  553. WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG,
  554. ("Infra Connnect SM: Requesting SCR.\n") );
  555. scrReplyStatus = scr_clientRequest( pConn->hScr, SCR_CID_CONNECT, &scrPendReason );
  556. pConn->scrRequested = TRUE;
  557. /* request the SCR as application (either BG or FG) client, and act according to return status */
  558. switch ( scrReplyStatus )
  559. {
  560. case SCR_CRS_PEND:
  561. /* send a pend event to the SM */
  562. WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG,
  563. ("Infra Conn: SCR pending with pend reason: %d, stay in wait SCR state.\n",
  564. scrPendReason) );
  565. break;
  566. case SCR_CRS_RUN:
  567. /* send an SCR SUCCESS event to the SM */
  568. WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: SCR acquired.\n") );
  569. conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn);
  570. break;
  571. default:
  572. WLAN_REPORT_ERROR( pConn->hReport, CONN_MODULE_LOG,
  573. ("Infra Conn: SCR returned unrecognized status: %d.\n", scrReplyStatus) );
  574. return NOK;
  575. }
  576. return OK;
  577. }
  578. void InfraConnSM_ScrCB( TI_HANDLE hConn, scr_clientRequestStatus_e requestStatus,
  579. scr_pendReason_e pendReason )
  580. {
  581. conn_t *pConn = (conn_t *)hConn;
  582. WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG,
  583. ("InfraConnSM_ScrCB called by SCR. Status is: %d.\n", requestStatus) );
  584. /* act according to the request staus */
  585. switch ( requestStatus )
  586. {
  587. case SCR_CRS_RUN:
  588. /* send an SCR SUCCESS event to the SM */
  589. WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: SCR acquired.\n") );
  590. conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn);
  591. break;
  592. case SCR_CRS_FW_RESET:
  593. /* Ignore FW reset, the MLME SM will handle re-try of the conn */
  594. WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: Recovery occured.\n") );
  595. break;
  596. default:
  597. WLAN_REPORT_ERROR( pConn->hReport, CONN_MODULE_LOG,
  598. ("Illegal SCR request status:%d, pend reason:%d.\n",
  599. requestStatus, pendReason) );
  600. break;
  601. }
  602. return;
  603. }
  604. static TI_STATUS ScrWait_to_idle(void *pData)
  605. {
  606. conn_t *pConn = (conn_t *)pData;
  607. WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG,
  608. ("Infra Connnect SM: Stop event while in SCR wait, moving to IDLE.\n") );
  609. scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
  610. pConn->scrRequested = FALSE;
  611. /*
  612. * Call the connection lost callback set by the SME or AP_CONN.
  613. */
  614. pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
  615. return OK;
  616. }
  617. static TI_STATUS stopModules( conn_t *pConn )
  618. {
  619. measurementMgr_disconnected(pConn->hMeasurementMgr);
  620. rxData_stop(pConn->hRxData);
  621. ctrlData_stop(pConn->hCtrlData);
  622. TrafficMonitor_Stop(pConn->hTrafficMonitor);
  623. switchChannel_stop(pConn->hSwitchChannel);
  624. healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_DISCONNECTED);
  625. siteMgr_stop(pConn->hSiteMgr);
  626. /* stopping power save */
  627. PowerMgr_stopPS(pConn->hPwrMngr);
  628. scanConcentrator_switchToNotConnected( pConn->hScanCnc );
  629. /* Set Current BSS Module to stop triggerring roaming events */
  630. currBSS_updateConnectedState(pConn->hCurrBss, FALSE, BSS_INFRASTRUCTURE);
  631. SoftGemini_unSetPSmode(pConn->hSoftGemini);
  632. return OK;
  633. }
  634. static TI_STATUS disAssocc_to_idle(void *pData)
  635. {
  636. conn_t *pConn = (conn_t *)pData;
  637. /* Stop the disconnect timeout timer. */
  638. os_timerStop(((conn_t *)pData)->hOs, ((conn_t *)pData)->pTimer);
  639. /*
  640. * Tx Data Stop and QoS disconnect must be called only after the disconnect (dissasociate/deauthenticate)
  641. * has been sent, or else no TX complete is received!
  642. */
  643. txData_stop(pConn->hTxData);
  644. qosMngr_disconnect(pConn->hQosMngr);
  645. #ifdef EXC_MODULE_INCLUDED
  646. measurementMgr_disableTsMetrics(pConn->hMeasurementMgr, MAX_NUM_OF_AC);
  647. #endif
  648. /* set Hw not available now that the connection process failed */
  649. MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
  650. whalCtrl_FwDisconnect(pConn->hHalCtrl,
  651. RX_CONFIG_OPTION_MY_DST_MY_BSS,
  652. RX_FILTER_OPTION_FILTER_ALL);
  653. #ifdef EXC_MODULE_INCLUDED
  654. excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC);
  655. #endif
  656. /*
  657. * Call the connection lost callback set by the SME or AP_CONN.
  658. */
  659. pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
  660. /*
  661. * In case of connection failuer we might get here without freeing the SCR.
  662. */
  663. if( pConn->scrRequested == TRUE ){
  664. scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
  665. pConn->scrRequested = FALSE;
  666. }
  667. return OK;
  668. }
  669. static TI_STATUS connect_to_ScrWait(void *pData)
  670. {
  671. TI_STATUS status;
  672. paramInfo_t param;
  673. conn_t *pConn = (conn_t *)pData;
  674. /*
  675. * This function performs roaming by two steps:
  676. * First - close the current connection without notify the SME.
  677. * Second - start new connection in reassociation mode.
  678. */
  679. status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
  680. if (status != OK)
  681. return status;
  682. param.paramType = RX_DATA_PORT_STATUS_PARAM;
  683. param.content.rxDataPortStatus = CLOSE;
  684. status = rxData_setParam(pConn->hRxData, &param);
  685. if (status != OK)
  686. return status;
  687. param.paramType = TX_DATA_PORT_STATUS_PARAM;
  688. param.content.txDataPortStatus = CLOSE;
  689. status = txData_setParam(pConn->hTxData, &param);
  690. if (status != OK)
  691. return status;
  692. status = mlme_stop(pConn->hMlmeSm, DISCONN_TYPE_IMMEDIATE, pConn->disConnReasonToAP);
  693. if (status != OK)
  694. return status;
  695. param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
  696. regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
  697. #ifdef EXC_MODULE_INCLUDED
  698. excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC);
  699. #endif
  700. /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
  701. supported rates, and stopModules clears all rates. */
  702. stopModules(pConn);
  703. /*
  704. * Tx Data Stop and QoS disconnect must be called only after the disconnect (dissasociate/deauthenticate)
  705. * has been sent. In this case no deauthenticate frame is sent bu still we keep the
  706. * order.
  707. */
  708. txData_stop(pConn->hTxData);
  709. qosMngr_disconnect(pConn->hQosMngr);
  710. /*
  711. * Start new connection.
  712. */
  713. Idle_to_ScrWait(pConn);
  714. return OK;
  715. }
  716. static TI_STATUS Idle_to_Idle(void *pData)
  717. {
  718. conn_t *pConn = (conn_t *)pData;
  719. /*
  720. * In case we are in IDLE and getting DISCONNECT event, we need to inform
  721. * the SME\AP_connection that we are disconnected.
  722. * Call the connection lost callback set by the SME or AP_CONN.
  723. */
  724. pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
  725. return OK;
  726. }
  727. /***********************************************************************
  728. connInfra_JoinCmpltNotification
  729. ***********************************************************************
  730. DESCRIPTION: Call back upon receving Join Event Complete.
  731. INPUT: hSiteMgr - site mgr handle.
  732. OUTPUT:
  733. RETURN:
  734. ************************************************************************/
  735. TI_STATUS connInfra_JoinCmpltNotification(TI_HANDLE hconn)
  736. {
  737. conn_t *pConn = (conn_t *)hconn;
  738. WLAN_REPORT_INFORMATION(pConn->hReport, SITE_MGR_MODULE_LOG,
  739. ("siteMgr_JoinCmplt: has been called\n"));
  740. txData_disableTransmission(pConn->hTxData, NO_DISABLE);
  741. if (pConn->currentConnType == CONNECTION_INFRA ) {
  742. conn_infraSMEvent(&pConn->state, CONN_INFRA_JOIN_CMD_CMPLT, pConn);
  743. }
  744. return OK;
  745. }