PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/core/sme/smeSm/smeSm.c

http://github.com/CyanogenMod/cm-kernel
C | 1223 lines | 695 code | 249 blank | 279 comment | 67 complexity | 0d3eb5d68f3c340de47236ef6794f312 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 smeSm.c
  36. * \brief SME SM implementation
  37. *
  38. * \see smeSm.h
  39. */
  40. #include "osTIType.h"
  41. #include "osApi.h"
  42. #include "paramOut.h"
  43. #include "paramIn.h"
  44. #include "srcApi.h"
  45. #include "report.h"
  46. #include "connApi.h"
  47. #include "siteMgrApi.h"
  48. #include "smeSmApi.h"
  49. #include "utils.h"
  50. #include "fsm.h"
  51. #include "smeSm.h"
  52. #include "smeApi.h"
  53. #include "DataCtrl_Api.h"
  54. #include "regulatoryDomainApi.h"
  55. #include "TrafficMonitorAPI.h"
  56. #include "PowerMgr_API.h"
  57. #include "EvHandler.h"
  58. #include "TI_IPC_Api.h"
  59. #include "ScanCncnApi.h"
  60. #ifdef EXC_MODULE_INCLUDED
  61. #include "DataCtrl_Api.h"
  62. #endif
  63. #include "apConn.h"
  64. /* State Machine Functions */
  65. static TI_STATUS idle_to_interScan(void *pData);
  66. static TI_STATUS interScan_to_scanning(void *pData);
  67. static TI_STATUS interScan_to_idle(void *pData);
  68. static TI_STATUS scan_to_idle(void *pData);
  69. static TI_STATUS scan_to_scan(void *pData);
  70. static TI_STATUS scan_to_select(void *pData);
  71. static TI_STATUS scan_to_interScan(void *pData);
  72. static TI_STATUS select_to_InterScan(void *pData);
  73. static TI_STATUS select_to_connect(void *pData);
  74. static TI_STATUS connecting_To_Disconnecting(void *pData);
  75. static TI_STATUS connecting_to_connected(void *pData);
  76. static TI_STATUS connecting_to_selecting(void *pData);
  77. static TI_STATUS connected_to_interScan(void *pData);
  78. static TI_STATUS connected_To_disconnecting(void *pData);
  79. static TI_STATUS disconnecting_to_interScan(void *pData);
  80. /* Local functions prototypes */
  81. static TI_STATUS actionUnexpected(void *pData);
  82. static TI_STATUS actionNop(void *pData);
  83. static TI_STATUS smeCallScan(void *pData);
  84. static TI_STATUS chooseScanBand(smeSm_t* pSmeSm, radioBand_e *band);
  85. static TI_STATUS smeSm_changeBandParams(TI_HANDLE hSmeSm, radioBand_e radioBand);
  86. static TI_STATUS smeSm_startInterScanTimeout(TI_HANDLE hSmeSm);
  87. static TI_STATUS smeSm_stopInterScanTimeout(TI_HANDLE hSmeSm);
  88. static void smeSm_sendDisassociateEvent(smeSm_t* pSmeSm);
  89. /****************************************************/
  90. /* Interface Functions Implementations */
  91. /****************************************************/
  92. /***********************************************************************
  93. * smeSm_smCreate
  94. ***********************************************************************
  95. DESCRIPTION: State machine creation function, called by the SME SM API. Allocates the state machine
  96. INPUT: hOs - OS handle.
  97. OUTPUT:
  98. RETURN: State machine pointer on success, NULL otherwise
  99. ************************************************************************/
  100. fsm_stateMachine_t *smeSm_smCreate(TI_HANDLE hOs)
  101. {
  102. TI_STATUS status;
  103. fsm_stateMachine_t *pFsm;
  104. status = fsm_Create(hOs, &pFsm, SME_SM_NUM_STATES, SME_SM_NUM_EVENTS);
  105. if (status != OK)
  106. return NULL;
  107. return pFsm;
  108. }
  109. /***********************************************************************
  110. * smeSm_smConfig
  111. ***********************************************************************
  112. DESCRIPTION: State machine configuration function, called by the SME SM API. Configures the state machine
  113. INPUT: pSmeSm - SME SM handle.
  114. OUTPUT:
  115. RETURN: OK on success, NOK otherwise
  116. ************************************************************************/
  117. TI_STATUS smeSm_smConfig(smeSm_t *pSmeSm)
  118. {
  119. paramInfo_t param;
  120. fsm_actionCell_t smMatrix[SME_SM_NUM_STATES][SME_SM_NUM_EVENTS] =
  121. {
  122. /* next state and actions for IDLE state */
  123. {
  124. {SME_SM_STATE_INTER_SCAN, idle_to_interScan}, /* "EVENT_START", */
  125. {SME_SM_STATE_IDLE, actionUnexpected}, /* "EVENT_STOP", */
  126. {SME_SM_STATE_IDLE, actionUnexpected}, /* "EVENT_SCAN_COMPLETE", */
  127. {SME_SM_STATE_IDLE, actionUnexpected}, /* "EVENT_SELECT_SUCCESS", */
  128. {SME_SM_STATE_IDLE, actionUnexpected}, /* "EVENT_SELECT_FAILURE", */
  129. {SME_SM_STATE_IDLE, actionUnexpected}, /* "EVENT_CONN_SUCCESS", */
  130. {SME_SM_STATE_IDLE, actionUnexpected}, /* "EVENT_CONN_FAILURE", */
  131. {SME_SM_STATE_IDLE, actionNop}, /* "EVENT_RESELECT", */
  132. {SME_SM_STATE_IDLE, actionNop}, /* "EVENT_DISCONNECT"*/
  133. },
  134. /* next state and actions for SCANNING state */
  135. {
  136. {SME_SM_STATE_SCANNING, actionUnexpected}, /* "EVENT_START", */
  137. {SME_SM_STATE_IDLE, scan_to_idle}, /* "EVENT_STOP", */
  138. {SME_SM_STATE_SELECTING, scan_to_select}, /* "EVENT_SCAN_COMPLETE", */
  139. {SME_SM_STATE_SCANNING, actionUnexpected}, /* "EVENT_SELECT_SUCCESS", */
  140. {SME_SM_STATE_SCANNING, actionUnexpected}, /* "EVENT_SELECT_FAILURE", */
  141. {SME_SM_STATE_SCANNING, actionUnexpected}, /* "EVENT_CONN_SUCCESS", */
  142. {SME_SM_STATE_SCANNING, actionUnexpected}, /* "EVENT_CONN_FAILURE", */
  143. {SME_SM_STATE_SCANNING, scan_to_scan}, /* "EVENT_RESELECT",*/
  144. {SME_SM_STATE_INTER_SCAN, scan_to_interScan}, /* "EVENT_DISCONNECT"*/
  145. },
  146. /* next state and actions for SELECTING state */
  147. {
  148. {SME_SM_STATE_SELECTING, actionUnexpected}, /* "EVENT_START", */
  149. {SME_SM_STATE_SELECTING, actionUnexpected}, /* "EVENT_STOP", */
  150. {SME_SM_STATE_SELECTING, actionUnexpected}, /* "EVENT_SCAN_COMPLETE", */
  151. {SME_SM_STATE_CONNECTING, select_to_connect}, /* "EVENT_SELECT_SUCCESS", */
  152. {SME_SM_STATE_INTER_SCAN, select_to_InterScan}, /* "EVENT_SELECT_FAILURE", */
  153. {SME_SM_STATE_SELECTING, actionUnexpected}, /* "EVENT_CONN_SUCCESS", */
  154. {SME_SM_STATE_SELECTING, actionUnexpected}, /* "EVENT_CONN_FAILURE", */
  155. {SME_SM_STATE_SELECTING, actionUnexpected}, /* "EVENT_RESELECT", */
  156. {SME_SM_STATE_SELECTING, actionUnexpected}, /* "EVENT_DISCONNECT",*/
  157. },
  158. /* next state and actions for CONNECTING state */
  159. {
  160. {SME_SM_STATE_SCANNING, actionUnexpected}, /* "EVENT_START", */
  161. {SME_SM_STATE_DISCONNECTING, connecting_To_Disconnecting}, /* "EVENT_STOP", */
  162. {SME_SM_STATE_CONNECTING, actionUnexpected}, /* "EVENT_SCAN_COMPLETE", */
  163. {SME_SM_STATE_CONNECTING, actionUnexpected}, /* "EVENT_SELECT_SUCCESS", */
  164. {SME_SM_STATE_CONNECTING, actionUnexpected}, /* "EVENT_SELECT_FAILURE", */
  165. {SME_SM_STATE_CONNECTED, connecting_to_connected}, /* "EVENT_CONN_SUCCESS", */
  166. {SME_SM_STATE_SELECTING, connecting_to_selecting}, /* "EVENT_CONN_FAILURE", */
  167. {SME_SM_STATE_DISCONNECTING, connecting_To_Disconnecting}, /* "EVENT_RESELECT", */
  168. {SME_SM_STATE_DISCONNECTING, connecting_To_Disconnecting}, /* "EVENT_DISCONNECT", */
  169. },
  170. /* next state and actions for CONNECTED state */
  171. {
  172. {SME_SM_STATE_SCANNING, actionUnexpected}, /* "EVENT_START", */
  173. {SME_SM_STATE_DISCONNECTING, connected_To_disconnecting}, /* "EVENT_STOP", */
  174. {SME_SM_STATE_CONNECTED, actionUnexpected}, /* "EVENT_SCAN_COMPLETE", */
  175. {SME_SM_STATE_CONNECTED, actionUnexpected}, /* "EVENT_SELECT_SUCCESS", */
  176. {SME_SM_STATE_CONNECTED, actionUnexpected}, /* "EVENT_SELECT_FAILURE", */
  177. {SME_SM_STATE_CONNECTED, actionUnexpected}, /* "EVENT_CONN_SUCCESS", */
  178. {SME_SM_STATE_INTER_SCAN, connected_to_interScan}, /* "EVENT_CONN_FAILURE", */
  179. {SME_SM_STATE_DISCONNECTING, connected_To_disconnecting}, /* "EVENT_RESELECT", */
  180. {SME_SM_STATE_DISCONNECTING ,connected_To_disconnecting}, /* "EVENT_DISCONNECT",*/
  181. },
  182. /* next state and actions for DISCONNECTING state */
  183. {
  184. {SME_SM_STATE_DISCONNECTING, actionNop}, /* "EVENT_START", */
  185. {SME_SM_STATE_DISCONNECTING, actionNop}, /* "EVENT_STOP", */
  186. {SME_SM_STATE_DISCONNECTING, actionUnexpected}, /* "EVENT_SCAN_COMPLETE", */
  187. {SME_SM_STATE_DISCONNECTING, actionUnexpected}, /* "EVENT_SELECT_SUCCESS", */
  188. {SME_SM_STATE_DISCONNECTING, actionUnexpected}, /* "EVENT_SELECT_FAILURE", */
  189. {SME_SM_STATE_DISCONNECTING, actionUnexpected}, /* "EVENT_CONN_SUCCESS", */
  190. {SME_SM_STATE_INTER_SCAN, disconnecting_to_interScan}, /* "EVENT_CONN_FAILURE", */
  191. {SME_SM_STATE_DISCONNECTING, actionNop}, /* "EVENT_RESELECT", */
  192. {SME_SM_STATE_DISCONNECTING, actionNop}, /* "EVENT_DISCONNECT",*/
  193. },
  194. /* next state and actions for STATE_INTER_SCAN_TIMEOUT state */
  195. {
  196. {SME_SM_STATE_INTER_SCAN, actionUnexpected}, /* "EVENT_START", */
  197. {SME_SM_STATE_IDLE, interScan_to_idle}, /* "EVENT_STOP", */
  198. {SME_SM_STATE_INTER_SCAN, actionUnexpected}, /* "EVENT_SCAN_COMPLETE", */
  199. {SME_SM_STATE_INTER_SCAN, actionUnexpected}, /* "EVENT_SELECT_SUCCESS", */
  200. {SME_SM_STATE_INTER_SCAN, actionUnexpected}, /* "EVENT_SELECT_FAILURE", */
  201. {SME_SM_STATE_INTER_SCAN, actionUnexpected}, /* "EVENT_CONN_SUCCESS", */
  202. {SME_SM_STATE_INTER_SCAN, actionUnexpected}, /* "EVENT_CONN_FAILURE", */
  203. {SME_SM_STATE_SCANNING, interScan_to_scanning}, /* "EVENT_RESELECT", */
  204. {SME_SM_STATE_INTER_SCAN, actionNop}, /* "EVENT_DISCONNECT",*/
  205. },
  206. };
  207. pSmeSm->dualBandReScanFlag = FALSE;
  208. pSmeSm->reScanFlag = FALSE;
  209. pSmeSm->radioOn = FALSE;
  210. pSmeSm->immediateShutdownRequired = FALSE;
  211. /* if desired SSID is junk SSID, don't connect (until new SSID is set) */
  212. param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
  213. siteMgr_getParam( pSmeSm->hSiteMgr, &param );
  214. if ( utils_isJunkSSID( &(param.content.siteMgrDesiredSSID) ) )
  215. {
  216. pSmeSm->connectEnabled = FALSE;
  217. }
  218. else
  219. {
  220. pSmeSm->connectEnabled = TRUE;
  221. }
  222. /* First event should indicate to the upper layer that STA is disassociated. */
  223. pSmeSm->DisAssoc.mgmtStatus = STATUS_UNSPECIFIED;
  224. pSmeSm->DisAssoc.uStatusCode = 0;
  225. smeSm_sendDisassociateEvent(pSmeSm);
  226. #ifdef TI_DBG
  227. /* clear statistics */
  228. smeSm_resetStats( (TI_HANDLE)pSmeSm );
  229. #endif
  230. return fsm_Config(pSmeSm->pFsm, (fsm_Matrix_t)smMatrix, SME_SM_NUM_STATES, SME_SM_NUM_EVENTS, smeSm_SMEvent, pSmeSm->hOs);
  231. }
  232. /***********************************************************************
  233. * smeSm_smUnLoad
  234. ***********************************************************************
  235. DESCRIPTION: State machine unload function, called by the SME SM API. Unloads the state machine
  236. INPUT: hOs - OS handle.
  237. pFsm - Pointer to the state machine
  238. OUTPUT:
  239. RETURN: State machine pointer on success, NULL otherwise
  240. ************************************************************************/
  241. TI_STATUS smeSm_smUnLoad(TI_HANDLE hOs, fsm_stateMachine_t *pFsm)
  242. {
  243. fsm_Unload(hOs, pFsm);
  244. return OK;
  245. }
  246. /***********************************************************************
  247. * smeSm_SMEvent
  248. ***********************************************************************
  249. DESCRIPTION: SME SM event processing function, called by the SME SM API
  250. Perform the following:
  251. - Print the state movement as a result from the event
  252. - Calls the generic state machine event processing function which preform the following:
  253. - Calls the corresponding callback function
  254. - Move to next state
  255. INPUT: currentState - Pointer to the connection current state.
  256. event - Received event
  257. pSmeSm - SME SM handle
  258. OUTPUT:
  259. RETURN: OK on success, NOK otherwise
  260. ************************************************************************/
  261. #ifdef REPORT_LOG
  262. static char *stateDesc[SME_SM_NUM_STATES] =
  263. {
  264. "STATE_IDLE",
  265. "STATE_SCANNING",
  266. "STATE_SELECTING",
  267. "STATE_CONNECTING",
  268. "STATE_CONNECTED",
  269. "STATE_DISCONNECTING",
  270. "STATE_INTER_SCAN",
  271. };
  272. static char *eventDesc[SME_SM_NUM_EVENTS] =
  273. {
  274. "EVENT_START",
  275. "EVENT_STOP",
  276. "EVENT_SCAN_COMPLETE",
  277. "EVENT_SELECT_SUCCESS",
  278. "EVENT_SELECT_FAILURE",
  279. "EVENT_CONN_SUCCESS",
  280. "EVENT_CONN_FAILURE",
  281. "EVENT_RESELECT",
  282. "EVENT_DISCONNECT",
  283. };
  284. #endif
  285. TI_STATUS smeSm_SMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hSmeSm)
  286. {
  287. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  288. TI_STATUS status;
  289. UINT8 nextState;
  290. status = fsm_GetNextState(pSmeSm->pFsm, *currentState, event, &nextState);
  291. if (status != OK)
  292. {
  293. WLAN_REPORT_SM(pSmeSm->hReport, SME_SM_MODULE_LOG, ("State machine error, failed getting next state\n"));
  294. return(NOK);
  295. }
  296. WLAN_REPORT_SM(pSmeSm->hReport, SME_SM_MODULE_LOG,
  297. ("<%s, %s> --> %s\n\n",
  298. stateDesc[*currentState],
  299. eventDesc[event],
  300. stateDesc[nextState]));
  301. status = fsm_Event(pSmeSm->pFsm, currentState, event, (void *)pSmeSm);
  302. return status;
  303. }
  304. /************************************************************************************************************/
  305. /* In the following section are listed the callback function used by the SME state machine */
  306. /************************************************************************************************************/
  307. /* START_SCAN */
  308. TI_STATUS sme_startScan(void *pData)
  309. {
  310. paramInfo_t param;
  311. smeSm_t *pSmeSm = (smeSm_t *)pData;
  312. /*
  313. * Support Dual Mode Operation
  314. */
  315. radioBand_e band;
  316. /*
  317. * If scan is disabled then send self scan complete event, skipping the scan procedure.
  318. */
  319. if (pSmeSm->scanEnabled != SCAN_ENABLED)
  320. {
  321. if (pSmeSm->scanEnabled == SKIP_NEXT_SCAN)
  322. {
  323. pSmeSm->scanEnabled = SCAN_ENABLED;
  324. }
  325. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE , pSmeSm);
  326. }
  327. /* if performing a dual band rescan now */
  328. if ( TRUE == pSmeSm->dualBandReScanFlag )
  329. {
  330. /* mark that no more scans are needed */
  331. pSmeSm->dualBandReScanFlag = FALSE;
  332. chooseScanBand(pSmeSm, &band);
  333. smeSm_changeBandParams(pSmeSm, band);
  334. }
  335. else
  336. {
  337. param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
  338. siteMgr_getParam(pSmeSm->hSiteMgr, &param);
  339. if(param.content.siteMgrDot11Mode == DOT11_DUAL_MODE)
  340. {
  341. pSmeSm->dualBandReScanFlag = TRUE;
  342. chooseScanBand(pSmeSm, &band);
  343. smeSm_changeBandParams(pSmeSm, band);
  344. }
  345. }
  346. return smeCallScan(pData);
  347. }
  348. /* RESTART_SCAN when exiting from IDLE state*/
  349. static TI_STATUS idle_to_interScan(void *pData)
  350. {
  351. smeSm_t *pSmeSm = (smeSm_t *)pData;
  352. pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
  353. /* Set the SCR group to inter SCAN */
  354. scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
  355. /*
  356. * If the connection is enabled then initiate "reselect" event that moves the
  357. * SM into scan state.
  358. */
  359. if( pSmeSm->connectEnabled ){
  360. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT , pSmeSm);
  361. }
  362. /* connectEnabled is FALSE, need to stay at this state until it will be changed. */
  363. return OK;
  364. }
  365. TI_STATUS interScan_to_scanning(void *pData)
  366. {
  367. smeSm_t *pSmeSm = (smeSm_t *)pData;
  368. pSmeSm->bSendDisAssocEvent = FALSE;
  369. smeSm_stopInterScanTimeout(pSmeSm);
  370. /* Set SCR to "first connection" */
  371. scr_setGroup( pSmeSm->hScr, SCR_GID_CONNECT );
  372. #ifdef TI_DBG
  373. /* update statistics - count scan attempts for connection */
  374. pSmeSm->smeStats.currentNumberOfScanAttempts++;
  375. #endif
  376. return (sme_startScan(pData));
  377. }
  378. static TI_STATUS disconnecting_to_interScan(void *pData)
  379. {
  380. smeSm_t *pSmeSm = (smeSm_t *)pData;
  381. pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
  382. scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
  383. siteMgr_disSelectSite(pSmeSm->hSiteMgr);
  384. /*
  385. * Notify that the driver is disassociated to the supplicant\IP stack.
  386. */
  387. smeSm_sendDisassociateEvent(pSmeSm);
  388. if (!pSmeSm->scanEnabled)
  389. {
  390. pSmeSm->connectEnabled = FALSE;
  391. }
  392. /* Radio ON and connection is enabled go to scanning */
  393. if( pSmeSm->radioOn )
  394. {
  395. if( pSmeSm->connectEnabled )
  396. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT , pSmeSm);
  397. else {
  398. /* Radio is on but connection is disabled, stay at interScan state
  399. without starting the interscan timer. */
  400. /* SCR is set to enable only APP scan */
  401. return OK;
  402. }
  403. }
  404. else{
  405. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP , pSmeSm);
  406. }
  407. }
  408. static TI_STATUS connected_to_interScan(void *pData)
  409. {
  410. smeSm_t *pSmeSm = (smeSm_t *)pData;
  411. pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
  412. siteMgr_disSelectSite(pSmeSm->hSiteMgr);
  413. scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
  414. /*
  415. * Notify that the driver is associated to the supplicant\IP stack.
  416. */
  417. smeSm_sendDisassociateEvent(pSmeSm);
  418. if (!pSmeSm->scanEnabled)
  419. {
  420. pSmeSm->connectEnabled = FALSE;
  421. }
  422. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT , pSmeSm);
  423. }
  424. static TI_STATUS select_to_InterScan(void *pData)
  425. {
  426. smeSm_t *pSmeSm = (smeSm_t *)pData;
  427. siteMgr_disSelectSite(pSmeSm->hSiteMgr);
  428. /* SCR is set to enable only APP scan */
  429. scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
  430. if (pSmeSm->connectEnabled)
  431. {
  432. smeSm_startInterScanTimeout(pSmeSm);
  433. }
  434. if ((pSmeSm->bSendDisAssocEvent == TRUE) || (pSmeSm->scanEnabled == FALSE))
  435. {
  436. /*
  437. * Notify that the driver is disassociated to the supplicant\IP stack.
  438. */
  439. smeSm_sendDisassociateEvent(pSmeSm);
  440. }
  441. return OK;
  442. }
  443. static TI_STATUS scan_to_interScan(void *pData)
  444. {
  445. smeSm_t *pSmeSm = (smeSm_t *)pData;
  446. /* SCR is set to enable only APP scan */
  447. scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
  448. pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
  449. if (pSmeSm->connectEnabled)
  450. {
  451. smeSm_startInterScanTimeout(pSmeSm);
  452. }
  453. return OK;
  454. }
  455. /* STOP_SCAN, START_SCAN */
  456. static TI_STATUS scan_to_scan(void *pData)
  457. {
  458. smeSm_t *pSmeSm = (smeSm_t *)pData;
  459. WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG, ("Setting reScanFlag to ON\n"));
  460. pSmeSm->reScanFlag = TRUE;
  461. scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
  462. return OK;
  463. }
  464. /* CANCEL INTER_SCAN TIMEOUT*/
  465. static TI_STATUS interScan_to_idle(void *pData)
  466. {
  467. smeSm_t *pSmeSm = (smeSm_t *)pData;
  468. smeSm_stopInterScanTimeout(pSmeSm);
  469. /* Change shutdown status flag to indicate SME is in IDLE state */
  470. pSmeSm->shutDownStatus |= DRIVER_SHUTDOWN_SME_STOPPED;
  471. /* Set SCR state to "Idle" */
  472. scr_setGroup( pSmeSm->hScr, SCR_GID_IDLE );
  473. return OK;
  474. }
  475. /* Stop current scanning and go to idle */
  476. static TI_STATUS scan_to_idle(void *pData)
  477. {
  478. smeSm_t *pSmeSm = (smeSm_t *)pData;
  479. /* stopping the current active scan process */
  480. scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
  481. /* Change shutdown status flag to indicate SME is in IDLE state */
  482. pSmeSm->shutDownStatus |= DRIVER_SHUTDOWN_SME_STOPPED;
  483. /* Set the SCR group to "idle" */
  484. scr_setGroup( pSmeSm->hScr, SCR_GID_IDLE );
  485. return OK;
  486. }
  487. /* SELECT */
  488. static TI_STATUS scan_to_select(void *pData)
  489. {
  490. smeSm_t *pSmeSm = (smeSm_t *)pData;
  491. if (!pSmeSm->connectEnabled)
  492. {
  493. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_FAILURE, pSmeSm);
  494. }
  495. siteMgr_resetAttemptsNumberParameter(pSmeSm->hSiteMgr);
  496. return siteMgr_selectSite(pSmeSm->hSiteMgr);
  497. }
  498. /* START_TX, CONNECT */
  499. static TI_STATUS select_to_connect(void *pData)
  500. {
  501. smeSm_t *pSmeSm = (smeSm_t *)pData;
  502. paramInfo_t param;
  503. /* From this moment forward we will send DisAssociation event even if the connection failed */
  504. pSmeSm->bSendDisAssocEvent = TRUE;
  505. /* if we are about o start an IBSS, the conn SM will wait for few seconds before sending connection
  506. failure indication, so that the SME will rescan for IBSSes with the same SSID. To enable application
  507. scan during this period, in this case ONLY we change here the SCR group ID to inter scan */
  508. param.paramType = CONN_TYPE_PARAM;
  509. conn_getParam(pSmeSm->hConn, &param);
  510. if (CONNECTION_SELF == param.content.connType)
  511. {
  512. /* Set SCR group to inter-scan */
  513. scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
  514. }
  515. /* Configure QoS manager not to renegotiate TSPECs as this is first time connection */
  516. return conn_start(pSmeSm->hConn, CONN_TYPE_FIRST_CONN, smeSm_reportConnStatus, pSmeSm, FALSE, FALSE);
  517. }
  518. /* Stop the connecting and go to disconnecting */
  519. static TI_STATUS connecting_To_Disconnecting(void *pData)
  520. {
  521. smeSm_t *pSmeSm = (smeSm_t *)pData;
  522. conn_stop(pSmeSm->hConn, DISCONN_TYPE_DEAUTH, STATUS_UNSPECIFIED,
  523. TRUE, smeSm_reportConnStatus, pSmeSm);
  524. return OK;
  525. }
  526. /* Stop the connection and go to disconnecting */
  527. static TI_STATUS connected_To_disconnecting(void *pData)
  528. {
  529. TI_STATUS status;
  530. paramInfo_t param;
  531. smeSm_t *pSmeSm = (smeSm_t *)pData;
  532. scr_setGroup( pSmeSm->hScr, SCR_GID_CONNECT );
  533. param.paramType = SITE_MGR_CURRENT_BSS_TYPE_PARAM;
  534. siteMgr_getParam(pSmeSm->hSiteMgr, &param);
  535. if(param.content.siteMgrDesiredBSSType == BSS_INFRASTRUCTURE)
  536. {
  537. /* Call the AP connection to perform disconnect - If immidiateShutdownRequired is TRUE, no need to send DISASSOC frame */
  538. status = apConn_stop(pSmeSm->hApConn, TRUE, pSmeSm->immediateShutdownRequired);
  539. }
  540. else
  541. {
  542. /* In IBSS disconnect is done directly with the connection SM */
  543. status = conn_stop(pSmeSm->hConn, DISCONN_TYPE_DEAUTH, STATUS_UNSPECIFIED,
  544. TRUE, smeSm_reportConnStatus,pSmeSm);
  545. if (status != OK)
  546. {
  547. WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
  548. return status;
  549. }
  550. }
  551. return OK;
  552. }
  553. /* RESET_ATTEMPTS_NUMBER, START_SITE_AGING, START_DATA_ALGO */
  554. /* CONNECTING -> CONNECTED due to event CONN_SUCC */
  555. static TI_STATUS connecting_to_connected(void *pData)
  556. {
  557. TI_STATUS status;
  558. paramInfo_t param;
  559. smeSm_t *pSmeSm = (smeSm_t *)pData;
  560. /* Reset the DisAssociation reason since the SME saves that last reason, and if a new connection was made and than aborted by
  561. unspecified reason - no one will clear this value */
  562. pSmeSm->DisAssoc.mgmtStatus = STATUS_UNSPECIFIED;
  563. pSmeSm->DisAssoc.uStatusCode = 0;
  564. status = siteMgr_resetPrevPrimarySiteRssi(pSmeSm->hSiteMgr);
  565. if (status != OK)
  566. {
  567. WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
  568. return status;
  569. }
  570. status = siteMgr_resetPrimarySiteAttemptsNumber(pSmeSm->hSiteMgr);
  571. if (status != OK)
  572. {
  573. WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
  574. return status;
  575. }
  576. status = siteMgr_resetEventStatisticsHistory(pSmeSm->hSiteMgr);
  577. if (status != OK)
  578. {
  579. WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
  580. return status;
  581. }
  582. param.paramType = SITE_MGR_CURRENT_BSS_TYPE_PARAM;
  583. siteMgr_getParam(pSmeSm->hSiteMgr, &param);
  584. if (param.content.siteMgrDesiredBSSType == BSS_INFRASTRUCTURE)
  585. {
  586. /* Start the AP connection */
  587. apConn_start(pSmeSm->hApConn, siteMgr_isThereValidSSID(pSmeSm->hSiteMgr));
  588. }
  589. /* Set SCR group to connected */
  590. scr_setGroup( pSmeSm->hScr, SCR_GID_CONNECTED );
  591. #ifdef TI_DBG
  592. /* update statistics - scan attempts for connection histogran */
  593. if ( SCAN_ATTAMEPTS_HISTOGRAM_SIZE < pSmeSm->smeStats.currentNumberOfScanAttempts )
  594. {
  595. pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ SCAN_ATTAMEPTS_HISTOGRAM_SIZE - 1 ]++;
  596. }
  597. else
  598. {
  599. pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ pSmeSm->smeStats.currentNumberOfScanAttempts - 1 ]++;
  600. }
  601. pSmeSm->smeStats.currentNumberOfScanAttempts = 0;
  602. #endif
  603. return OK;
  604. }
  605. /* STOP_RX, STOP_TX, UPDATE_PRIMARY_SITE_FAIL_STATUS, */
  606. static TI_STATUS connecting_to_selecting(void *pData)
  607. {
  608. TI_STATUS status;
  609. paramInfo_t param;
  610. smeSm_t *pSmeSm = (smeSm_t *)pData;
  611. conn_stop(pSmeSm->hConn, DISCONN_TYPE_IMMEDIATE, STATUS_UNSPECIFIED,
  612. TRUE, smeSm_reportConnStatus,pSmeSm);
  613. /* Remove primary site */
  614. status = siteMgr_updatePrimarySiteFailStatus(pSmeSm->hSiteMgr, TRUE);
  615. if (status != OK)
  616. {
  617. WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
  618. return status;
  619. }
  620. status = siteMgr_disSelectSite(pSmeSm->hSiteMgr);
  621. if (status != OK)
  622. {
  623. WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
  624. return status;
  625. }
  626. /* If we are in IBSS mode we don't try to select another site */
  627. param.paramType = SITE_MGR_DESIRED_BSS_TYPE_PARAM;
  628. siteMgr_getParam(pSmeSm->hSiteMgr, &param);
  629. if(param.content.siteMgrDesiredBSSType == BSS_INDEPENDENT)
  630. return smeSm_reportSelectStatus(pSmeSm, (mgmtStatus_e)SELECT_STATUS_FAILURE);
  631. else
  632. return siteMgr_selectSite(pSmeSm->hSiteMgr);
  633. }
  634. static TI_STATUS chooseScanBand(smeSm_t* pSmeSm, radioBand_e *band)
  635. {
  636. paramInfo_t param;
  637. param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
  638. siteMgr_getParam( pSmeSm->hSiteMgr, &param );
  639. /* if working in dual band, select band according to dualBandReScanFlag */
  640. if ( param.content.siteMgrDot11Mode == DOT11_DUAL_MODE )
  641. {
  642. *band = ( TRUE == pSmeSm->dualBandReScanFlag ? RADIO_BAND_5_0_GHZ : RADIO_BAND_2_4_GHZ);
  643. }
  644. /* if not working in dual band, return site manager current band */
  645. else
  646. {
  647. param.paramType = SITE_MGR_RADIO_BAND_PARAM;
  648. siteMgr_getParam(pSmeSm->hSiteMgr, &param);
  649. *band = pSmeSm->currBand = param.content.siteMgrRadioBand;
  650. }
  651. return OK;
  652. }
  653. static TI_STATUS smeCallScan(void *pData)
  654. {
  655. smeSm_t *pSmeSm = (smeSm_t *)pData;
  656. paramInfo_t param;
  657. scan_Params_t* pScanParams = &(pSmeSm->scanParams);
  658. sme_scan_Params_t *pSmeScanParams;
  659. scan_normalChannelEntry_t *pChanEntry;
  660. int chan, k;
  661. /*
  662. * Check in which band we are in and prepare the scan command.
  663. */
  664. pScanParams->scanType = SCAN_TYPE_NORMAL_ACTIVE;
  665. pScanParams->Tid = 0;
  666. param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
  667. siteMgr_getParam( pSmeSm->hSiteMgr, &param );
  668. if ( DOT11_A_MODE == param.content.siteMgrDot11OperationalMode )
  669. {
  670. pScanParams->band = RADIO_BAND_5_0_GHZ;
  671. pSmeScanParams = &(pSmeSm->scanParamsA);
  672. }
  673. else
  674. {
  675. pScanParams->band = RADIO_BAND_2_4_GHZ;
  676. pSmeScanParams = &(pSmeSm->scanParamsBG);
  677. }
  678. pScanParams->probeRequestRate = pSmeScanParams->probeRequestRate;
  679. pScanParams->numOfChannels = pSmeScanParams->numOfChannels;
  680. pScanParams->probeReqNumber = pSmeScanParams->probeReqNumber;
  681. WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
  682. ("Global Scan Params: Rate=0x%x, Prob#=%d, Channels#=%d\n",
  683. pScanParams->probeRequestRate, pScanParams->probeReqNumber,
  684. pScanParams->numOfChannels));
  685. for( chan=0; chan < pScanParams->numOfChannels; chan++ )
  686. {
  687. pChanEntry = &(pScanParams->channelEntry[chan].normalChannelEntry);
  688. /* Fill channel ID */
  689. pChanEntry->channel = pSmeScanParams->channelsList[chan];
  690. /* Set broadcast BSSID */
  691. for ( k = 0; k < 6; k++ ) pChanEntry->bssId.addr[ k ] = 0xff;
  692. /* Set min & max dwell time */
  693. pChanEntry->minChannelDwellTime = pSmeScanParams->minDwellTime;
  694. pChanEntry->maxChannelDwellTime = pSmeScanParams->maxDwellTime;
  695. /* Set up early termination params. */
  696. pChanEntry->earlyTerminationEvent = SCAN_DEFAULT_EARLY_TERMINATION_EVENT;
  697. pChanEntry->ETMaxNumOfAPframes = SCAN_DEFAULT_EARLY_TERMINATION_NUM_OF_FRAMES;
  698. /* Set desired tx power */
  699. pChanEntry->txPowerDbm = pSmeScanParams->txPowerDbm;
  700. WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
  701. ("Chan %d: CH=%d , DwellTime Min=%d Max=%d, ET=%d, TxPowr=%d, \n",
  702. chan,
  703. pScanParams->channelEntry[chan].normalChannelEntry.channel,
  704. pScanParams->channelEntry[chan].normalChannelEntry.minChannelDwellTime,
  705. pScanParams->channelEntry[chan].normalChannelEntry.maxChannelDwellTime,
  706. pScanParams->channelEntry[chan].normalChannelEntry.earlyTerminationEvent,
  707. pScanParams->channelEntry[chan].normalChannelEntry.txPowerDbm));
  708. } /* Channel list setting */
  709. /*
  710. * Set the desired SSID (if any)
  711. */
  712. param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
  713. siteMgr_getParam( pSmeSm->hSiteMgr, &param );
  714. if ( utils_isAnySSID( &(param.content.siteMgrDesiredSSID) ) )
  715. {
  716. pScanParams->desiredSsid.len = 0;
  717. }
  718. else
  719. {
  720. pScanParams->desiredSsid.len = param.content.siteMgrDesiredSSID.len;
  721. os_memoryCopy( pSmeSm->hOs, (void *)pScanParams->desiredSsid.ssidString,
  722. (void *)param.content.siteMgrDesiredSSID.ssidString,
  723. param.content.siteMgrDesiredSSID.len );
  724. }
  725. /*
  726. * Prepare scan complete's aging, by increasing the scanned sites
  727. * scan attemps counter. The counter will be checked upon scan complete,
  728. * and the sites with no update scan results will be dropped.
  729. */
  730. siteMgr_setNotReceivedParameter(pSmeSm->hSiteMgr, &(pScanParams->desiredSsid), pScanParams->band );
  731. #ifdef TI_DBG
  732. /* scan results count statistics - nullify the count before starting scan */
  733. pSmeSm->smeStats.currentNumberOfScanResults = 0;
  734. #endif
  735. /*
  736. * Set and send the scan command.
  737. */
  738. if (scanConcentrator_scan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER, pScanParams ) !=
  739. SCAN_CRS_SCAN_RUNNING)
  740. {
  741. /* imitate scan complete event if scan could not be performed.*/
  742. smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE, pSmeSm);
  743. }
  744. return OK;
  745. }
  746. static TI_STATUS actionUnexpected(void *pData)
  747. {
  748. smeSm_t *pSmeSm = (smeSm_t *)pData;
  749. WLAN_REPORT_SM(pSmeSm->hReport, SME_SM_MODULE_LOG, ("State machine error, unexpected Event\n\n"));
  750. return OK;
  751. }
  752. static TI_STATUS actionNop(void *pData)
  753. {
  754. return OK;
  755. }
  756. static TI_STATUS smeSm_changeBandParams(TI_HANDLE hSmeSm, radioBand_e radioBand)
  757. {
  758. paramInfo_t param;
  759. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  760. /* change dot11 mode */
  761. param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
  762. if(radioBand == RADIO_BAND_2_4_GHZ)
  763. param.content.siteMgrDot11OperationalMode = DOT11_G_MODE;
  764. else
  765. param.content.siteMgrDot11OperationalMode = DOT11_A_MODE;
  766. siteMgr_setParam(pSmeSm->hSiteMgr, &param);
  767. param.paramType = SITE_MGR_RADIO_BAND_PARAM;
  768. param.content.siteMgrRadioBand = radioBand;
  769. siteMgr_setParam(pSmeSm->hSiteMgr, &param);
  770. siteMgr_setCurrentTable(pSmeSm->hSiteMgr, radioBand);
  771. /* configure hal with common core-hal parameters */
  772. whalCtrl_SetRadioBand(pSmeSm->hHalCtrl, radioBand);
  773. return OK;
  774. }
  775. /***********************************************************************
  776. * smeSm_startInterScanTimeout
  777. ***********************************************************************
  778. DESCRIPTION: Starts interscan timeout
  779. INPUT: hSmeSm - SME SM handle.
  780. OUTPUT:
  781. RETURN: OK on success, NOK otherwise
  782. ************************************************************************/
  783. static TI_STATUS smeSm_startInterScanTimeout(TI_HANDLE hSmeSm)
  784. {
  785. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  786. paramInfo_t param;
  787. /* If the SME scan is disabled, (scan is performed by the application)
  788. * don't start the inter scan timeout
  789. */
  790. if (pSmeSm->scanEnabled == SCAN_DISABLED)
  791. {
  792. return OK;
  793. }
  794. if (pSmeSm->scanEnabled == SKIP_NEXT_SCAN)
  795. {
  796. pSmeSm->scanEnabled = SCAN_ENABLED;
  797. }
  798. param.paramType = SITE_MGR_DESIRED_BSS_TYPE_PARAM;
  799. siteMgr_getParam(pSmeSm->hSiteMgr, &param);
  800. if (param.content.siteMgrDesiredBSSType == BSS_INDEPENDENT)
  801. {
  802. os_timerStart(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer, IBSS_INTER_SCAN_PERIOD, FALSE);
  803. }
  804. else
  805. {
  806. os_timerStart(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer, pSmeSm->interScanTimeout, FALSE);
  807. }
  808. return OK;
  809. }
  810. /***********************************************************************
  811. * smeSm_stopInterScanTimeout
  812. ***********************************************************************
  813. DESCRIPTION: Stops scan timeout
  814. INPUT: hSmeSm - SME SM handle.
  815. OUTPUT:
  816. RETURN: OK on success, NOK otherwise
  817. ************************************************************************/
  818. static TI_STATUS smeSm_stopInterScanTimeout(TI_HANDLE hSmeSm)
  819. {
  820. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  821. os_timerStop(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
  822. return OK;
  823. }
  824. /***********************************************************************
  825. * smeSm_sendDisassociateEvent
  826. ***********************************************************************
  827. DESCRIPTION: Send disassociate event with the reason
  828. INPUT: pSmeSm - SME SM handle.
  829. OUTPUT:
  830. RETURN:
  831. ************************************************************************/
  832. static void smeSm_sendDisassociateEvent(smeSm_t* pSmeSm)
  833. {
  834. OS_802_11_DISASSOCIATE_REASON_T eventReason;
  835. WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
  836. ("%s uDissconnectType = %d, uStatusCode = %d\n",__FUNCTION__, pSmeSm->DisAssoc.mgmtStatus, pSmeSm->DisAssoc.uStatusCode));
  837. /* Convert reason to OS layer */
  838. switch(pSmeSm->DisAssoc.mgmtStatus)
  839. {
  840. case STATUS_UNSPECIFIED:
  841. eventReason.eDisAssocType = OS_DISASSOC_STATUS_UNSPECIFIED;
  842. break;
  843. case STATUS_AUTH_REJECT:
  844. eventReason.eDisAssocType = OS_DISASSOC_STATUS_AUTH_REJECT;
  845. break;
  846. case STATUS_ASSOC_REJECT:
  847. eventReason.eDisAssocType = OS_DISASSOC_STATUS_ASSOC_REJECT;
  848. break;
  849. case STATUS_SECURITY_FAILURE:
  850. eventReason.eDisAssocType = OS_DISASSOC_STATUS_SECURITY_FAILURE;
  851. break;
  852. case STATUS_AP_DEAUTHENTICATE:
  853. eventReason.eDisAssocType = OS_DISASSOC_STATUS_AP_DEAUTHENTICATE;
  854. break;
  855. case STATUS_AP_DISASSOCIATE:
  856. eventReason.eDisAssocType = OS_DISASSOC_STATUS_AP_DISASSOCIATE;
  857. break;
  858. case STATUS_ROAMING_TRIGGER:
  859. eventReason.eDisAssocType = OS_DISASSOC_STATUS_ROAMING_TRIGGER;
  860. break;
  861. default:
  862. eventReason.eDisAssocType = OS_DISASSOC_STATUS_UNSPECIFIED;
  863. break;
  864. }
  865. /* Use the same status code for OS */
  866. eventReason.uStatusCode = pSmeSm->DisAssoc.uStatusCode;
  867. EvHandlerSendEvent(pSmeSm->hEvHandler, IPC_EVENT_DISASSOCIATED, (UINT8*)&eventReason, sizeof(OS_802_11_DISASSOCIATE_REASON_T));
  868. /* Reset status after sending the event */
  869. pSmeSm->DisAssoc.mgmtStatus = STATUS_UNSPECIFIED;
  870. pSmeSm->DisAssoc.uStatusCode = 0;
  871. }
  872. #ifdef TI_DBG
  873. /***********************************************************************
  874. * smeSm_resetStats
  875. ***********************************************************************
  876. DESCRIPTION: Reset SME statistics
  877. INPUT: hSmeSm - SME SM handle.
  878. OUTPUT:
  879. RETURN:
  880. ************************************************************************/
  881. void smeSm_resetStats( TI_HANDLE hSmeSm )
  882. {
  883. smeSm_t* pSmeSm = (smeSm_t*)hSmeSm;
  884. os_memoryZero( pSmeSm->hOs, &(pSmeSm->smeStats), sizeof(smeSmStats_t) );
  885. }
  886. /***********************************************************************
  887. * smeSm_printStats
  888. ***********************************************************************
  889. DESCRIPTION: Print SME statistics
  890. INPUT: hSmeSm - SME SM handle.
  891. OUTPUT:
  892. RETURN:
  893. ************************************************************************/
  894. void smeSm_printStats( TI_HANDLE hSmeSm )
  895. {
  896. smeSm_t* pSmeSm = (smeSm_t*)hSmeSm;
  897. WLAN_OS_REPORT(("----------------------- SME statistics -----------------------\n\n"));
  898. WLAN_OS_REPORT(("Scan attempts histogram:\n"));
  899. WLAN_OS_REPORT(("------------------------\n\n"));
  900. WLAN_OS_REPORT(("Attempts: %6d %6d %6d %6d %6d %6d %6d %6d\n", 1, 2, 3, 4, 5, 6, 7, 8));
  901. WLAN_OS_REPORT(("Count: %6d %6d %6d %6d %6d %6d %6d %6d\n\n", pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 0 ],
  902. pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 1 ], pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 2 ],
  903. pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 3 ], pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 4 ],
  904. pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 5 ], pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 6 ],
  905. pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 7 ]));
  906. WLAN_OS_REPORT(("Scan result count histogram:\n"));
  907. WLAN_OS_REPORT(("----------------------------\n\n"));
  908. WLAN_OS_REPORT(("Results: %6d %6d %6d %6d %6d %6d %6d %6d\n", 0, 1, 2, 3, 4, 5, 6, 7));
  909. WLAN_OS_REPORT(("Scans: %6d %6d %6d %6d %6d %6d %6d %6d\n\n", pSmeSm->smeStats.scanResulCountHistogram[ 0 ],
  910. pSmeSm->smeStats.scanResulCountHistogram[ 1 ], pSmeSm->smeStats.scanResulCountHistogram[ 2 ],
  911. pSmeSm->smeStats.scanResulCountHistogram[ 3 ], pSmeSm->smeStats.scanResulCountHistogram[ 4 ],
  912. pSmeSm->smeStats.scanResulCountHistogram[ 5 ], pSmeSm->smeStats.scanResulCountHistogram[ 6 ],
  913. pSmeSm->smeStats.scanResulCountHistogram[ 7 ]));
  914. WLAN_OS_REPORT(("Results: %6d %6d %6d %6d %6d %6d %6d %6d\n", 8, 9, 10, 11, 12, 13, 14, 15));
  915. WLAN_OS_REPORT(("Scans: %6d %6d %6d %6d %6d %6d %6d %6d\n", pSmeSm->smeStats.scanResulCountHistogram[ 8 ],
  916. pSmeSm->smeStats.scanResulCountHistogram[ 9 ], pSmeSm->smeStats.scanResulCountHistogram[ 10 ],
  917. pSmeSm->smeStats.scanResulCountHistogram[ 11 ], pSmeSm->smeStats.scanResulCountHistogram[ 12 ],
  918. pSmeSm->smeStats.scanResulCountHistogram[ 13 ], pSmeSm->smeStats.scanResulCountHistogram[ 14 ],
  919. pSmeSm->smeStats.scanResulCountHistogram[ 15 ]));
  920. }
  921. /***********************************************************************
  922. * smeSm_dbgPrintObject
  923. ***********************************************************************
  924. DESCRIPTION: Print the SME object
  925. INPUT: hSmeSm - SME SM handle.
  926. OUTPUT:
  927. RETURN:
  928. ************************************************************************/
  929. void smeSm_dbgPrintObject( TI_HANDLE hSmeSm )
  930. {
  931. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  932. WLAN_OS_REPORT(("Current SME State is <%s>\n",stateDesc[pSmeSm->state]));
  933. }
  934. #endif