PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/CyanogenMod/cm-kernel
C | 737 lines | 349 code | 102 blank | 286 comment | 44 complexity | 38cabf39011c014a853e92f5b7576f94 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 smeSmApi.c
  36. * \brief SME SM API implementation
  37. *
  38. * The state machine itself is implemented in the file smeSm.c.
  39. *
  40. * \see smeSmApi.h
  41. */
  42. #include "report.h"
  43. #include "osTIType.h"
  44. #include "osApi.h"
  45. #include "smeSm.h"
  46. #include "smeApi.h"
  47. #include "smeSmApi.h"
  48. #include "utils.h"
  49. #include "802_11Defs.h"
  50. #include "regulatoryDomainApi.h"
  51. #include "siteMgrApi.h"
  52. #include "connApi.h"
  53. #include "EvHandler.h"
  54. #include "TI_IPC_Api.h"
  55. #define WLAN_INTER_SCAN_DELTA 10
  56. /* State machine definitions */
  57. #define SME_INIT_BIT 1
  58. #define SM_INIT_BIT 2
  59. #define TIMER_INIT_BIT 3
  60. /* Local functions prototypes */
  61. static void release_module(smeSm_t *pSmeSm, UINT32 initVec);
  62. void smeSm_InterScanTimeoutCB(TI_HANDLE hSmeSm);
  63. /* Interface functions Implementation */
  64. /************************************************************************
  65. * smeSm_create *
  66. ************************************************************************
  67. DESCRIPTION: SME SM module creation function, called by the config mgr in creation phase
  68. performs the following:
  69. - Allocate the SME SM handle
  70. - Create the SME state machine
  71. INPUT: hOs - Handle to OS
  72. OUTPUT:
  73. RETURN: Handle to the SME SM module on success, NULL otherwise
  74. ************************************************************************/
  75. TI_HANDLE smeSm_create(TI_HANDLE hOs)
  76. {
  77. smeSm_t *pSmeSm;
  78. UINT32 initVec;
  79. initVec = 0;
  80. pSmeSm = os_memoryAlloc(hOs, sizeof(smeSm_t));
  81. if (pSmeSm == NULL)
  82. return NULL;
  83. os_memoryZero(hOs, pSmeSm, sizeof(smeSm_t)); /* Dm: Fix */
  84. initVec |= (1 << SME_INIT_BIT);
  85. pSmeSm->pFsm = smeSm_smCreate(hOs);
  86. if (pSmeSm->pFsm == NULL)
  87. {
  88. release_module(pSmeSm, initVec);
  89. return NULL;
  90. }
  91. initVec |= (1 << SM_INIT_BIT);
  92. pSmeSm->hOs = hOs;
  93. pSmeSm->interScanTimeoutTimer = os_timerCreate(hOs, smeSm_InterScanTimeoutCB, pSmeSm);
  94. if(pSmeSm->interScanTimeoutTimer == NULL)
  95. {
  96. release_module(pSmeSm, initVec);
  97. WLAN_OS_REPORT(("FATAL ERROR: smeSm_create(): Error Creating smeSm - Aborting\n"));
  98. return NULL;
  99. }
  100. initVec |= (1 << TIMER_INIT_BIT);
  101. return(pSmeSm);
  102. }
  103. /************************************************************************
  104. * smeSm_config *
  105. ************************************************************************
  106. DESCRIPTION: SME SM module configuration function, called by the config mgr in configuration phase
  107. performs the following:
  108. - Reset & initiailzes local variables
  109. - Init the handles to be used by the module
  110. INPUT: hSmeSm - SME SM handle
  111. List of handles to be used by the module
  112. OUTPUT:
  113. RETURN: OK on success, NOK otherwise
  114. ************************************************************************/
  115. TI_STATUS smeSm_config(TI_HANDLE hSmeSm,
  116. TI_HANDLE hConn,
  117. TI_HANDLE hScanCncn,
  118. TI_HANDLE hSiteMgr,
  119. TI_HANDLE hHalCtrl,
  120. TI_HANDLE hReport,
  121. TI_HANDLE hOs,
  122. TI_HANDLE hEvHandler,
  123. TI_HANDLE hScr,
  124. TI_HANDLE hApConn,
  125. TI_HANDLE hCurrBss,
  126. TI_HANDLE hPowerMgr,
  127. TI_HANDLE hRegulatoryDomain,
  128. smeInitParams_t* smeInitParams)
  129. {
  130. TI_STATUS status;
  131. int index;
  132. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  133. pSmeSm->state = SME_SM_STATE_IDLE;
  134. pSmeSm->hConn = hConn;
  135. pSmeSm->hScanCncn = hScanCncn;
  136. pSmeSm->hSiteMgr = hSiteMgr;
  137. pSmeSm->hHalCtrl = hHalCtrl;
  138. pSmeSm->hReport = hReport;
  139. pSmeSm->hOs = hOs;
  140. pSmeSm->hEvHandler = hEvHandler;
  141. pSmeSm->hScr = hScr;
  142. pSmeSm->hApConn = hApConn;
  143. pSmeSm->hCurrBss = hCurrBss;
  144. pSmeSm->hPowerMgr = hPowerMgr;
  145. pSmeSm->hRegulatoryDomain = hRegulatoryDomain;
  146. /* interscan timeout values */
  147. pSmeSm->scanEnabled = (scanEnabledOptions_e)smeInitParams->EnableFirstConnScan;
  148. pSmeSm->interScanTimeoutMin = smeInitParams->InterScanIntervalMin;
  149. pSmeSm->interScanTimeoutMax = smeInitParams->InterScanIntervalMax;
  150. pSmeSm->interScanTimeoutDelta = smeInitParams->InterScanIntervalDelta;
  151. pSmeSm->shutDownStatus = 0;
  152. /*
  153. * Setting scan parameters for band 2.4Ghtz
  154. */
  155. os_memoryCopy(hOs, &(pSmeSm->scanParamsBG), &(smeInitParams->scanParamsBG), sizeof(sme_scan_Params_t));
  156. /* The channel list is represented as char string terminate in zeros. */
  157. for( index = 0;
  158. ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsBG.channelsList[index] != 0));
  159. index++ );
  160. pSmeSm->scanParamsBG.numOfChannels = index;
  161. /*
  162. * Setting scan parameters for band 5.0Ghtz
  163. */
  164. os_memoryCopy(hOs, &(pSmeSm->scanParamsA), &(smeInitParams->scanParamsA), sizeof(sme_scan_Params_t));
  165. for( index = 0;
  166. ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsA.channelsList[index] != 0));
  167. index++ );
  168. pSmeSm->scanParamsA.numOfChannels = index;
  169. /* register to scan result callback */
  170. scanConcentrator_registerScanResultCB( pSmeSm->hScanCncn, SCAN_SCC_DRIVER, smeSm_scanComplete, hSmeSm );
  171. status = smeSm_smConfig(pSmeSm);
  172. if (status != OK)
  173. WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG, (".....Sme state machine configuration Failure\n"));
  174. else
  175. WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG, (".....Sme state machine configuration Success\n"));
  176. return status;
  177. }
  178. /************************************************************************
  179. * smeSm_getDriverShutdownStatus *
  180. ************************************************************************
  181. DESCRIPTION: Return shutdown status of driver.
  182. INPUT: hSmeSm - SME SM handle.
  183. OUTPUT:
  184. RETURN: shutdown status of driver (SME/HAL)
  185. ************************************************************************/
  186. UINT8 smeSm_getDriverShutdownStatus (TI_HANDLE hSmeSm)
  187. {
  188. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  189. return (pSmeSm->shutDownStatus);
  190. }
  191. /************************************************************************
  192. * smeSm_unLoad *
  193. ************************************************************************
  194. DESCRIPTION: SME SM module unload function, called by the config mgr in the unlod phase
  195. performs the following:
  196. - Free all memory allocated by the module
  197. INPUT: hSmeSm - SME SM handle.
  198. OUTPUT:
  199. RETURN: OK on success, NOK otherwise
  200. ************************************************************************/
  201. TI_STATUS smeSm_unLoad(TI_HANDLE hSmeSm)
  202. {
  203. UINT32 initVec;
  204. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  205. if (!pSmeSm)
  206. return OK;
  207. initVec = 0xFFFF;
  208. release_module(pSmeSm, initVec);
  209. return OK;
  210. }
  211. /***********************************************************************
  212. * smeSm_start
  213. ***********************************************************************
  214. DESCRIPTION: Called by the configuration module in order to start the driver
  215. Calls the SME SM with a start event
  216. INPUT: hSmeSm - SME SM handle.
  217. OUTPUT:
  218. RETURN: OK on success, NOK otherwise
  219. ************************************************************************/
  220. TI_STATUS smeSm_start(TI_HANDLE hSmeSm)
  221. {
  222. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  223. pSmeSm->radioOn = TRUE;
  224. pSmeSm->immediateShutdownRequired = FALSE;
  225. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_START, pSmeSm);
  226. }
  227. /***********************************************************************
  228. * smeSm_restart
  229. ***********************************************************************
  230. DESCRIPTION: Called by the configuration module in order to start the driver
  231. Calls the SME SM with a start event
  232. INPUT: hSmeSm - SME SM handle.
  233. OUTPUT:
  234. RETURN: OK on success, NOK otherwise
  235. ************************************************************************/
  236. TI_STATUS smeSm_reselect(TI_HANDLE hSmeSm)
  237. {
  238. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  239. paramInfo_t param;
  240. /* For new SSID reset interScanTimeout */
  241. pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
  242. /*
  243. Junk SSID is used for disabling connection attempts, if it is
  244. set the driver will be stopped at "inter scan" state.
  245. */
  246. param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
  247. siteMgr_getParam(pSmeSm->hSiteMgr, &param);
  248. if (utils_isJunkSSID(&param.content.siteMgrDesiredSSID))
  249. {
  250. pSmeSm->connectEnabled = FALSE;
  251. WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
  252. ("Sme Set JUNK SSID\n"));
  253. if( pSmeSm->state == SME_SM_STATE_SCANNING )
  254. /* If in scanning stop the scan, the disconnect event will
  255. be sent by the scan complete function. */
  256. scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
  257. else
  258. smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
  259. }
  260. else
  261. {
  262. pSmeSm->connectEnabled = TRUE;
  263. smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
  264. }
  265. return OK;
  266. }
  267. /***********************************************************************
  268. * smeSm_stop
  269. ***********************************************************************
  270. DESCRIPTION: Called by the configuration module in order to stop the driver
  271. Calls the SME SM with a stop event
  272. INPUT: hSmeSm - SME SM handle.
  273. OUTPUT:
  274. RETURN: OK on success, NOK otherwise
  275. ************************************************************************/
  276. TI_STATUS smeSm_stop(TI_HANDLE hSmeSm)
  277. {
  278. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  279. pSmeSm->radioOn = FALSE;
  280. pSmeSm->immediateShutdownRequired = FALSE;
  281. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
  282. }
  283. /***********************************************************************
  284. * smeSm_stopAndShutdown
  285. ***********************************************************************
  286. DESCRIPTION: Called by the configuration module in order to stop the driver
  287. Calls the SME SM with a stop event
  288. INPUT: hSmeSm - SME SM handle.
  289. OUTPUT:
  290. RETURN: OK on success, NOK otherwise
  291. ************************************************************************/
  292. void smeSm_stopAndShutdown(TI_HANDLE hSmeSm)
  293. {
  294. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  295. pSmeSm->radioOn = FALSE;
  296. pSmeSm->immediateShutdownRequired = TRUE;
  297. smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
  298. }
  299. /***********************************************************************
  300. * smeSm_scanComplete
  301. ***********************************************************************
  302. DESCRIPTION: Called by the site manager When scan is completed
  303. Calls the SME SM with a scan complete event
  304. INPUT: hSmeSm - SME SM handle.
  305. OUTPUT:
  306. RETURN: OK on success, NOK otherwise
  307. ************************************************************************/
  308. void smeSm_scanComplete( TI_HANDLE hSmeSm, scan_cncnResultStatus_e status,
  309. scan_frameInfo_t *frameInfo, UINT16 SPSStatus )
  310. {
  311. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  312. /* if this call is due to a scan result received, simply store it in the site mngr */
  313. if ( SCAN_CRS_RECEIVED_FRAME == status )
  314. {
  315. siteMgr_updateSite( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->parsedIEs, frameInfo->channel, frameInfo->band, FALSE);
  316. if ( BEACON == frameInfo->parsedIEs->subType )
  317. {
  318. siteMgr_saveBeaconBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
  319. }
  320. else
  321. {
  322. siteMgr_saveProbeRespBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
  323. }
  324. #ifdef TI_DBG
  325. /* update statistics - count one more result that was received */
  326. pSmeSm->smeStats.currentNumberOfScanResults++;
  327. #endif
  328. return;
  329. }
  330. #ifdef TI_DBG
  331. /* update statistics - update scan results histogram */
  332. if ( SCAN_RESULT_HISTOGRAM_SIZE <= pSmeSm->smeStats.currentNumberOfScanResults )
  333. {
  334. pSmeSm->smeStats.scanResulCountHistogram[ SCAN_RESULT_HISTOGRAM_SIZE -1 ]++;
  335. }
  336. else
  337. {
  338. pSmeSm->smeStats.scanResulCountHistogram[ pSmeSm->smeStats.currentNumberOfScanResults ]++;
  339. }
  340. pSmeSm->smeStats.currentNumberOfScanResults = 0;
  341. #endif
  342. WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
  343. ("smeSm_scanComplete\n"));
  344. siteMgr_removeNotReceivedSites(pSmeSm->hSiteMgr);
  345. if ( pSmeSm->connectEnabled )
  346. {
  347. /* check for rescan and perform scan when it is on */
  348. if ( TRUE == pSmeSm->reScanFlag )
  349. {
  350. WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
  351. ("SME_SM: doing additional scan due to reScanFlag = ON\n") );
  352. pSmeSm->reScanFlag = FALSE;
  353. sme_startScan(pSmeSm);
  354. }
  355. /* check for dual band rescan */
  356. else if ( TRUE == pSmeSm->dualBandReScanFlag )
  357. {
  358. WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
  359. ("SME_SM: doing additional scan due to dualBandReScanFlag = ON\n") );
  360. sme_startScan(pSmeSm);
  361. }
  362. else
  363. {
  364. smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE, pSmeSm);
  365. }
  366. }
  367. else
  368. {
  369. /* If connection is disabled then send disconnect event, the SM will
  370. * move into inter scan state
  371. */
  372. pSmeSm->reScanFlag = FALSE; /* (Just to make sure) */
  373. pSmeSm->dualBandReScanFlag = FALSE;
  374. smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
  375. }
  376. }
  377. /***********************************************************************
  378. * smeSm_reportConnStatus
  379. ***********************************************************************
  380. DESCRIPTION: Called by the connection module when connection status changes
  381. Calls the SME SM with a connection suceess or connection failure based on the status
  382. INPUT: hSmeSm - SME SM handle.
  383. statusType - Connection status
  384. uStatusCode - extra information to statusType (usually status code of the packet)
  385. OUTPUT:
  386. RETURN: OK on success, NOK otherwise
  387. ************************************************************************/
  388. TI_STATUS smeSm_reportConnStatus(TI_HANDLE hSmeSm, mgmtStatus_e statusType, UINT32 uStatusCode)
  389. {
  390. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  391. WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
  392. ("%s statusType = %d, uStatusCode = %d \n",__FUNCTION__, statusType, uStatusCode));
  393. switch(statusType)
  394. {
  395. case STATUS_SUCCESSFUL:
  396. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_SUCCESS, pSmeSm);
  397. /*
  398. * The next section handles connection failures, all cases are sending same event to SM.
  399. */
  400. case STATUS_AUTH_REJECT:
  401. case STATUS_ASSOC_REJECT:
  402. case STATUS_SECURITY_FAILURE:
  403. case STATUS_AP_DEAUTHENTICATE:
  404. case STATUS_AP_DISASSOCIATE:
  405. case STATUS_ROAMING_TRIGGER:
  406. pSmeSm->DisAssoc.mgmtStatus = statusType;
  407. pSmeSm->DisAssoc.uStatusCode = uStatusCode;
  408. /* Note that in case of unspecified status we won't update the status. This is done since this function could be called twice */
  409. /* for example: apConn called this function and than SME called conn_stop and this function is called again */
  410. case STATUS_UNSPECIFIED:
  411. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_FAILURE, pSmeSm);
  412. default:
  413. WLAN_REPORT_WARNING(pSmeSm->hReport, SME_SM_MODULE_LOG,
  414. ("%s unknown statusType = %d\n",__FUNCTION__, statusType));
  415. break;
  416. }
  417. return OK;
  418. }
  419. /***********************************************************************
  420. * smeSm_reportSelectStatus
  421. ***********************************************************************
  422. DESCRIPTION: Called by the selection function
  423. Calls the SME SM with a selection suceess or selection failure based on the status
  424. INPUT: hSmeSm - SME SM handle.
  425. status - selection status
  426. OUTPUT:
  427. RETURN: OK on success, NOK otherwise
  428. ************************************************************************/
  429. TI_STATUS smeSm_reportSelectStatus(TI_HANDLE hSmeSm,
  430. mgmtStatus_e status)
  431. {
  432. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  433. if (status == SELECT_STATUS_SUCCESS)
  434. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_SUCCESS, pSmeSm);
  435. else
  436. return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_FAILURE, pSmeSm);
  437. }
  438. /***********************************************************************
  439. * smeSm_startScan
  440. ***********************************************************************
  441. DESCRIPTION: Timer callback, on expiration of which, scan started
  442. INPUT: hSmeSm - SME SM handle.
  443. OUTPUT:
  444. RETURN: OK on success, NOK otherwise
  445. ************************************************************************/
  446. void smeSm_InterScanTimeoutCB(TI_HANDLE hSmeSm)
  447. {
  448. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  449. if ( pSmeSm->connectEnabled )
  450. {
  451. pSmeSm->interScanTimeout += pSmeSm->interScanTimeoutDelta;
  452. if( pSmeSm->interScanTimeout > pSmeSm->interScanTimeoutMax )
  453. pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMax;
  454. smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
  455. }
  456. }
  457. /***********************************************************************
  458. * release_module
  459. ***********************************************************************
  460. DESCRIPTION: Called by the un load function
  461. Go over the vector, for each bit that is set, release the corresponding module.
  462. INPUT: hConn - SME SM handle.
  463. pSmeSm - Vector that contains a bit set for each module thah had been initiualized
  464. OUTPUT:
  465. RETURN: OK on success, NOK otherwise
  466. ************************************************************************/
  467. static void release_module(smeSm_t *pSmeSm, UINT32 initVec)
  468. {
  469. if (initVec & (1 << SM_INIT_BIT))
  470. smeSm_smUnLoad(pSmeSm->hOs, pSmeSm->pFsm);
  471. if (initVec & (1 << TIMER_INIT_BIT))
  472. {
  473. os_timerStop(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
  474. utils_nullTimerDestroy(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
  475. }
  476. if (initVec & (1 << SME_INIT_BIT))
  477. utils_nullMemoryFree(pSmeSm->hOs, pSmeSm, sizeof(smeSm_t));
  478. initVec = 0;
  479. }
  480. /***********************************************************************
  481. * smeSm_setParam
  482. ***********************************************************************
  483. DESCRIPTION: SME SM set param function, called by the following:
  484. - config mgr in order to set a parameter from the OS abstraction layer.
  485. - Form inside the driver
  486. INPUT: hSmeSm - SME SM handle.
  487. pParam - Pointer to the parameter
  488. OUTPUT:
  489. RETURN: OK on success, NOK otherwise
  490. ************************************************************************/
  491. TI_STATUS smeSm_setParam(TI_HANDLE hSmeSm,
  492. paramInfo_t *pParam)
  493. {
  494. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  495. switch(pParam->paramType)
  496. {
  497. case SME_SCAN_ENABLED_PARAM:
  498. if (pSmeSm->scanEnabled != pParam->content.smeSMScanEnabled)
  499. {
  500. if ((pParam->content.smeSMScanEnabled == SCAN_ENABLED) &&
  501. (pSmeSm->scanEnabled == SKIP_NEXT_SCAN))
  502. {
  503. /* Requested to st scanEnable to TRUE;
  504. if we are about to skip the nextcoming scan, ignore the request */
  505. break;
  506. }
  507. if ((pParam->content.smeSMScanEnabled == SKIP_NEXT_SCAN) &&
  508. (pSmeSm->scanEnabled == SCAN_DISABLED))
  509. {
  510. /* Requested to st scanEnable to SKIP_NEXT_SCAN
  511. while it is currently set to FALSE - error, ignore the request */
  512. WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG,
  513. ("Set param, error changing scan enabled param from %d to %d\n",
  514. pSmeSm->scanEnabled, pParam->content.smeSMScanEnabled));
  515. break;
  516. }
  517. pSmeSm->scanEnabled = pParam->content.smeSMScanEnabled;
  518. }
  519. break;
  520. default:
  521. WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG,
  522. ("Set param, Params is not supported, %d\n\n", pParam->paramType));
  523. return PARAM_NOT_SUPPORTED;
  524. }
  525. return OK;
  526. }
  527. /***********************************************************************
  528. * smeSm_getParam
  529. ***********************************************************************
  530. DESCRIPTION: SME SM get param function, called by the following:
  531. - config mgr in order to get a parameter from the OS abstraction layer.
  532. - Fomr inside the dirver
  533. INPUT: hSmeSm - SME SM handle.
  534. pParam - Pointer to the parameter
  535. OUTPUT:
  536. RETURN: OK on success, NOK otherwise
  537. ************************************************************************/
  538. TI_STATUS smeSm_getParam(TI_HANDLE hSmeSm,
  539. paramInfo_t *pParam)
  540. {
  541. smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
  542. switch(pParam->paramType)
  543. {
  544. case SITE_MGR_CONNECTION_STATUS_PARAM:
  545. switch (pSmeSm->state)
  546. {
  547. case SME_SM_STATE_IDLE:
  548. case SME_SM_STATE_INTER_SCAN:
  549. pParam->content.smeSmConnectionStatus = eDot11Idle;
  550. break;
  551. case SME_SM_STATE_SCANNING:
  552. pParam->content.smeSmConnectionStatus = eDot11Scaning;
  553. break;
  554. case SME_SM_STATE_CONNECTING:
  555. pParam->content.smeSmConnectionStatus = eDot11Connecting;
  556. break;
  557. default:
  558. pParam->content.smeSmConnectionStatus = eDot11Associated;
  559. break;
  560. }
  561. break;
  562. case SME_SM_STATE_PARAM:
  563. pParam->content.smeSmState = pSmeSm->state;
  564. break;
  565. case SME_SCAN_ENABLED_PARAM:
  566. pParam->content.smeSMScanEnabled = pSmeSm->scanEnabled;
  567. break;
  568. default:
  569. WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->paramType));
  570. return PARAM_NOT_SUPPORTED;
  571. }
  572. return OK;
  573. }