1 /****************************************************************************
2 **+-----------------------------------------------------------------------+**
3 **| |**
4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
5 **| All rights reserved. |**
6 **| |**
7 **| Redistribution and use in source and binary forms, with or without |**
8 **| modification, are permitted provided that the following conditions |**
9 **| are met: |**
10 **| |**
11 **| * Redistributions of source code must retain the above copyright |**
12 **| notice, this list of conditions and the following disclaimer. |**
13 **| * Redistributions in binary form must reproduce the above copyright |**
14 **| notice, this list of conditions and the following disclaimer in |**
15 **| the documentation and/or other materials provided with the |**
16 **| distribution. |**
17 **| * Neither the name Texas Instruments nor the names of its |**
18 **| contributors may be used to endorse or promote products derived |**
19 **| from this software without specific prior written permission. |**
20 **| |**
21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
32 **| |**
33 **+-----------------------------------------------------------------------+**
34 ****************************************************************************/
35
36 /** \file smeSmApi.c
37 * \brief SME SM API implementation
38 *
39 * The state machine itself is implemented in the file smeSm.c.
40 *
41 * \see smeSmApi.h
42 */
43
44 #include "report.h"
45 #include "osTIType.h"
46 #include "osApi.h"
47 #include "smeSm.h"
48 #include "smeApi.h"
49 #include "smeSmApi.h"
50 #include "utils.h"
51 #include "802_11Defs.h"
52 #include "regulatoryDomainApi.h"
53 #include "siteMgrApi.h"
54 #include "connApi.h"
55 #include "EvHandler.h"
56 #include "TI_IPC_Api.h"
57
58
59 #define WLAN_INTER_SCAN_DELTA 10
60
61 /* State machine definitions */
62 #define SME_INIT_BIT 1
63 #define SM_INIT_BIT 2
64 #define TIMER_INIT_BIT 3
65
66 /* Local functions prototypes */
67
68 static void release_module(smeSm_t *pSmeSm, UINT32 initVec);
69
70 void smeSm_InterScanTimeoutCB(TI_HANDLE hSmeSm);
71
72
73 /* Interface functions Implementation */
74
75 /************************************************************************
76 * smeSm_create *
77 ************************************************************************
78 DESCRIPTION: SME SM module creation function, called by the config mgr in creation phase
79 performs the following:
80 - Allocate the SME SM handle
81 - Create the SME state machine
82
83 INPUT: hOs - Handle to OS
84
85
86 OUTPUT:
87
88 RETURN: Handle to the SME SM module on success, NULL otherwise
89
90 ************************************************************************/
smeSm_create(TI_HANDLE hOs)91 TI_HANDLE smeSm_create(TI_HANDLE hOs)
92 {
93 smeSm_t *pSmeSm;
94 UINT32 initVec;
95
96 initVec = 0;
97
98 pSmeSm = os_memoryAlloc(hOs, sizeof(smeSm_t));
99 if (pSmeSm == NULL)
100 return NULL;
101 os_memoryZero(hOs, pSmeSm, sizeof(smeSm_t)); /* Dm: Fix */
102
103 initVec |= (1 << SME_INIT_BIT);
104
105 pSmeSm->pFsm = smeSm_smCreate(hOs);
106 if (pSmeSm->pFsm == NULL)
107 {
108 release_module(pSmeSm, initVec);
109 return NULL;
110 }
111
112 initVec |= (1 << SM_INIT_BIT);
113
114 pSmeSm->hOs = hOs;
115
116 pSmeSm->interScanTimeoutTimer = os_timerCreate(hOs, smeSm_InterScanTimeoutCB, pSmeSm);
117 if(pSmeSm->interScanTimeoutTimer == NULL)
118 {
119 release_module(pSmeSm, initVec);
120 WLAN_OS_REPORT(("FATAL ERROR: smeSm_create(): Error Creating smeSm - Aborting\n"));
121 return NULL;
122 }
123 initVec |= (1 << TIMER_INIT_BIT);
124
125 return(pSmeSm);
126 }
127
128 /************************************************************************
129 * smeSm_config *
130 ************************************************************************
131 DESCRIPTION: SME SM module configuration function, called by the config mgr in configuration phase
132 performs the following:
133 - Reset & initiailzes local variables
134 - Init the handles to be used by the module
135
136 INPUT: hSmeSm - SME SM handle
137 List of handles to be used by the module
138
139 OUTPUT:
140
141 RETURN: OK on success, NOK otherwise
142
143 ************************************************************************/
smeSm_config(TI_HANDLE hSmeSm,TI_HANDLE hConn,TI_HANDLE hScanCncn,TI_HANDLE hSiteMgr,TI_HANDLE hHalCtrl,TI_HANDLE hReport,TI_HANDLE hOs,TI_HANDLE hEvHandler,TI_HANDLE hScr,TI_HANDLE hApConn,TI_HANDLE hCurrBss,TI_HANDLE hPowerMgr,TI_HANDLE hRegulatoryDomain,smeInitParams_t * smeInitParams)144 TI_STATUS smeSm_config(TI_HANDLE hSmeSm,
145 TI_HANDLE hConn,
146 TI_HANDLE hScanCncn,
147 TI_HANDLE hSiteMgr,
148 TI_HANDLE hHalCtrl,
149 TI_HANDLE hReport,
150 TI_HANDLE hOs,
151 TI_HANDLE hEvHandler,
152 TI_HANDLE hScr,
153 TI_HANDLE hApConn,
154 TI_HANDLE hCurrBss,
155 TI_HANDLE hPowerMgr,
156 TI_HANDLE hRegulatoryDomain,
157 smeInitParams_t* smeInitParams)
158
159 {
160 TI_STATUS status;
161 int index;
162
163 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
164
165 pSmeSm->state = SME_SM_STATE_IDLE;
166 pSmeSm->hConn = hConn;
167 pSmeSm->hScanCncn = hScanCncn;
168 pSmeSm->hSiteMgr = hSiteMgr;
169 pSmeSm->hHalCtrl = hHalCtrl;
170 pSmeSm->hReport = hReport;
171 pSmeSm->hOs = hOs;
172 pSmeSm->hEvHandler = hEvHandler;
173 pSmeSm->hScr = hScr;
174 pSmeSm->hApConn = hApConn;
175 pSmeSm->hCurrBss = hCurrBss;
176 pSmeSm->hPowerMgr = hPowerMgr;
177 pSmeSm->hRegulatoryDomain = hRegulatoryDomain;
178
179 /* interscan timeout values */
180 pSmeSm->scanEnabled = (scanEnabledOptions_e)smeInitParams->EnableFirstConnScan;
181 pSmeSm->interScanTimeoutMin = smeInitParams->InterScanIntervalMin;
182 pSmeSm->interScanTimeoutMax = smeInitParams->InterScanIntervalMax;
183 pSmeSm->interScanTimeoutDelta = smeInitParams->InterScanIntervalDelta;
184 pSmeSm->shutDownStatus = 0;
185
186
187 /*
188 * Setting scan parameters for band 2.4Ghtz
189 */
190 os_memoryCopy(hOs, &(pSmeSm->scanParamsBG), &(smeInitParams->scanParamsBG), sizeof(sme_scan_Params_t));
191 /* The channel list is represented as char string terminate in zeros. */
192
193 for( index = 0;
194 ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsBG.channelsList[index] != 0));
195 index++ );
196
197 pSmeSm->scanParamsBG.numOfChannels = index;
198
199 /*
200 * Setting scan parameters for band 5.0Ghtz
201 */
202 os_memoryCopy(hOs, &(pSmeSm->scanParamsA), &(smeInitParams->scanParamsA), sizeof(sme_scan_Params_t));
203
204 for( index = 0;
205 ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsA.channelsList[index] != 0));
206 index++ );
207
208 pSmeSm->scanParamsA.numOfChannels = index;
209
210
211
212 /* register to scan result callback */
213 scanConcentrator_registerScanResultCB( pSmeSm->hScanCncn, SCAN_SCC_DRIVER, smeSm_scanComplete, hSmeSm );
214
215 status = smeSm_smConfig(pSmeSm);
216
217 if (status != OK)
218 WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG, (".....Sme state machine configuration Failure\n"));
219 else
220 WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG, (".....Sme state machine configuration Success\n"));
221
222 return status;
223 }
224
225 /************************************************************************
226 * smeSm_getDriverShutdownStatus *
227 ************************************************************************
228 DESCRIPTION: Return shutdown status of driver.
229
230 INPUT: hSmeSm - SME SM handle.
231
232 OUTPUT:
233
234 RETURN: shutdown status of driver (SME/HAL)
235
236 ************************************************************************/
smeSm_getDriverShutdownStatus(TI_HANDLE hSmeSm)237 UINT8 smeSm_getDriverShutdownStatus (TI_HANDLE hSmeSm)
238 {
239 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
240 return (pSmeSm->shutDownStatus);
241 }
242
243
244 /************************************************************************
245 * smeSm_unLoad *
246 ************************************************************************
247 DESCRIPTION: SME SM module unload function, called by the config mgr in the unlod phase
248 performs the following:
249 - Free all memory allocated by the module
250
251 INPUT: hSmeSm - SME SM handle.
252
253
254 OUTPUT:
255
256 RETURN: OK on success, NOK otherwise
257
258 ************************************************************************/
smeSm_unLoad(TI_HANDLE hSmeSm)259 TI_STATUS smeSm_unLoad(TI_HANDLE hSmeSm)
260 {
261 UINT32 initVec;
262 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
263
264 if (!pSmeSm)
265 return OK;
266
267 initVec = 0xFFFF;
268 release_module(pSmeSm, initVec);
269
270 return OK;
271 }
272
273 /***********************************************************************
274 * smeSm_start
275 ***********************************************************************
276 DESCRIPTION: Called by the configuration module in order to start the driver
277 Calls the SME SM with a start event
278
279 INPUT: hSmeSm - SME SM handle.
280
281 OUTPUT:
282
283 RETURN: OK on success, NOK otherwise
284
285 ************************************************************************/
smeSm_start(TI_HANDLE hSmeSm)286 TI_STATUS smeSm_start(TI_HANDLE hSmeSm)
287 {
288 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
289
290 pSmeSm->radioOn = TRUE;
291 pSmeSm->immediateShutdownRequired = FALSE;
292
293 return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_START, pSmeSm);
294 }
295
296
297
298 /***********************************************************************
299 * smeSm_restart
300 ***********************************************************************
301 DESCRIPTION: Called by the configuration module in order to start the driver
302 Calls the SME SM with a start event
303
304 INPUT: hSmeSm - SME SM handle.
305
306 OUTPUT:
307
308 RETURN: OK on success, NOK otherwise
309
310 ************************************************************************/
smeSm_reselect(TI_HANDLE hSmeSm)311 TI_STATUS smeSm_reselect(TI_HANDLE hSmeSm)
312 {
313 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
314 paramInfo_t param;
315
316 /* For new SSID reset interScanTimeout */
317 pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
318
319 /*
320 Junk SSID is used for disabling connection attempts, if it is
321 set the driver will be stopped at "inter scan" state.
322 */
323
324 param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
325 siteMgr_getParam(pSmeSm->hSiteMgr, ¶m);
326
327 if (utils_isJunkSSID(¶m.content.siteMgrDesiredSSID))
328 {
329 pSmeSm->connectEnabled = FALSE;
330
331 WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
332 ("Sme Set JUNK SSID\n"));
333
334 if( pSmeSm->state == SME_SM_STATE_SCANNING )
335 /* If in scanning stop the scan, the disconnect event will
336 be sent by the scan complete function. */
337 scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
338 else
339 smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
340 }
341 else
342 {
343 pSmeSm->connectEnabled = TRUE;
344 smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
345 }
346
347 return OK;
348 }
349
350
351 /***********************************************************************
352 * smeSm_stop
353 ***********************************************************************
354 DESCRIPTION: Called by the configuration module in order to stop the driver
355 Calls the SME SM with a stop event
356
357 INPUT: hSmeSm - SME SM handle.
358
359 OUTPUT:
360
361 RETURN: OK on success, NOK otherwise
362
363 ************************************************************************/
smeSm_stop(TI_HANDLE hSmeSm)364 TI_STATUS smeSm_stop(TI_HANDLE hSmeSm)
365 {
366 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
367
368 pSmeSm->radioOn = FALSE;
369 pSmeSm->immediateShutdownRequired = FALSE;
370
371 return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
372 }
373
374 /***********************************************************************
375 * smeSm_stopAndShutdown
376 ***********************************************************************
377 DESCRIPTION: Called by the configuration module in order to stop the driver
378 Calls the SME SM with a stop event
379
380 INPUT: hSmeSm - SME SM handle.
381
382 OUTPUT:
383
384 RETURN: OK on success, NOK otherwise
385
386 ************************************************************************/
smeSm_stopAndShutdown(TI_HANDLE hSmeSm)387 void smeSm_stopAndShutdown(TI_HANDLE hSmeSm)
388 {
389 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
390
391 pSmeSm->radioOn = FALSE;
392 pSmeSm->immediateShutdownRequired = TRUE;
393
394 smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
395 }
396
397 /***********************************************************************
398 * smeSm_scanComplete
399 ***********************************************************************
400 DESCRIPTION: Called by the site manager When scan is completed
401 Calls the SME SM with a scan complete event
402
403 INPUT: hSmeSm - SME SM handle.
404
405 OUTPUT:
406
407 RETURN: OK on success, NOK otherwise
408
409 ************************************************************************/
smeSm_scanComplete(TI_HANDLE hSmeSm,scan_cncnResultStatus_e status,scan_frameInfo_t * frameInfo,UINT16 SPSStatus)410 void smeSm_scanComplete( TI_HANDLE hSmeSm, scan_cncnResultStatus_e status,
411 scan_frameInfo_t *frameInfo, UINT16 SPSStatus )
412 {
413 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
414
415 /* if this call is due to a scan result received, simply store it in the site mngr */
416 if ( SCAN_CRS_RECEIVED_FRAME == status )
417 {
418 siteMgr_updateSite( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->parsedIEs, frameInfo->channel, frameInfo->band, FALSE);
419 if ( BEACON == frameInfo->parsedIEs->subType )
420 {
421 siteMgr_saveBeaconBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
422 }
423 else
424 {
425 siteMgr_saveProbeRespBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
426 }
427 #ifdef TI_DBG
428 /* update statistics - count one more result that was received */
429 pSmeSm->smeStats.currentNumberOfScanResults++;
430 #endif
431 return;
432 }
433
434 #ifdef TI_DBG
435 /* update statistics - update scan results histogram */
436 if ( SCAN_RESULT_HISTOGRAM_SIZE <= pSmeSm->smeStats.currentNumberOfScanResults )
437 {
438 pSmeSm->smeStats.scanResulCountHistogram[ SCAN_RESULT_HISTOGRAM_SIZE -1 ]++;
439 }
440 else
441 {
442 pSmeSm->smeStats.scanResulCountHistogram[ pSmeSm->smeStats.currentNumberOfScanResults ]++;
443 }
444 pSmeSm->smeStats.currentNumberOfScanResults = 0;
445 #endif
446
447 WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
448 ("smeSm_scanComplete\n"));
449
450 siteMgr_removeNotReceivedSites(pSmeSm->hSiteMgr);
451
452 if ( pSmeSm->connectEnabled )
453 {
454 /* check for rescan and perform scan when it is on */
455 if ( TRUE == pSmeSm->reScanFlag )
456 {
457 WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
458 ("SME_SM: doing additional scan due to reScanFlag = ON\n") );
459 pSmeSm->reScanFlag = FALSE;
460 sme_startScan(pSmeSm);
461 }
462 /* check for dual band rescan */
463 else if ( TRUE == pSmeSm->dualBandReScanFlag )
464 {
465 WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
466 ("SME_SM: doing additional scan due to dualBandReScanFlag = ON\n") );
467 sme_startScan(pSmeSm);
468 }
469 else
470 {
471 smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE, pSmeSm);
472 }
473 }
474 else
475 {
476 /* If connection is disabled then send disconnect event, the SM will
477 * move into inter scan state
478 */
479 pSmeSm->reScanFlag = FALSE; /* (Just to make sure) */
480 pSmeSm->dualBandReScanFlag = FALSE;
481 smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
482 }
483 }
484
485
486 /***********************************************************************
487 * smeSm_reportConnStatus
488 ***********************************************************************
489 DESCRIPTION: Called by the connection module when connection status changes
490 Calls the SME SM with a connection suceess or connection failure based on the status
491
492 INPUT: hSmeSm - SME SM handle.
493 statusType - Connection status
494 uStatusCode - extra information to statusType (usually status code of the packet)
495
496 OUTPUT:
497
498 RETURN: OK on success, NOK otherwise
499
500 ************************************************************************/
smeSm_reportConnStatus(TI_HANDLE hSmeSm,mgmtStatus_e statusType,UINT32 uStatusCode)501 TI_STATUS smeSm_reportConnStatus(TI_HANDLE hSmeSm, mgmtStatus_e statusType, UINT32 uStatusCode)
502 {
503 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
504
505 WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,
506 ("%s statusType = %d, uStatusCode = %d \n",__FUNCTION__, statusType, uStatusCode));
507
508 switch(statusType)
509 {
510 case STATUS_SUCCESSFUL:
511 return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_SUCCESS, pSmeSm);
512
513 /*
514 * The next section handles connection failures, all cases are sending same event to SM.
515 */
516 case STATUS_AUTH_REJECT:
517 case STATUS_ASSOC_REJECT:
518 case STATUS_SECURITY_FAILURE:
519 case STATUS_AP_DEAUTHENTICATE:
520 case STATUS_AP_DISASSOCIATE:
521 case STATUS_ROAMING_TRIGGER:
522 pSmeSm->DisAssoc.mgmtStatus = statusType;
523 pSmeSm->DisAssoc.uStatusCode = uStatusCode;
524 /* Note that in case of unspecified status we won't update the status. This is done since this function could be called twice */
525 /* for example: apConn called this function and than SME called conn_stop and this function is called again */
526 case STATUS_UNSPECIFIED:
527
528 return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_FAILURE, pSmeSm);
529
530 default:
531 WLAN_REPORT_WARNING(pSmeSm->hReport, SME_SM_MODULE_LOG,
532 ("%s unknown statusType = %d\n",__FUNCTION__, statusType));
533
534 break;
535 }
536
537 return OK;
538 }
539
540 /***********************************************************************
541 * smeSm_reportSelectStatus
542 ***********************************************************************
543 DESCRIPTION: Called by the selection function
544 Calls the SME SM with a selection suceess or selection failure based on the status
545
546 INPUT: hSmeSm - SME SM handle.
547 status - selection status
548
549 OUTPUT:
550
551 RETURN: OK on success, NOK otherwise
552
553 ************************************************************************/
smeSm_reportSelectStatus(TI_HANDLE hSmeSm,mgmtStatus_e status)554 TI_STATUS smeSm_reportSelectStatus(TI_HANDLE hSmeSm,
555 mgmtStatus_e status)
556 {
557 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
558
559 if (status == SELECT_STATUS_SUCCESS)
560 return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_SUCCESS, pSmeSm);
561 else
562 return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_FAILURE, pSmeSm);
563 }
564
565
566 /***********************************************************************
567 * smeSm_startScan
568 ***********************************************************************
569 DESCRIPTION: Timer callback, on expiration of which, scan started
570
571 INPUT: hSmeSm - SME SM handle.
572
573 OUTPUT:
574
575 RETURN: OK on success, NOK otherwise
576
577 ************************************************************************/
smeSm_InterScanTimeoutCB(TI_HANDLE hSmeSm)578 void smeSm_InterScanTimeoutCB(TI_HANDLE hSmeSm)
579 {
580 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
581
582 if ( pSmeSm->connectEnabled )
583 {
584 pSmeSm->interScanTimeout += pSmeSm->interScanTimeoutDelta;
585
586 if( pSmeSm->interScanTimeout > pSmeSm->interScanTimeoutMax )
587 pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMax;
588
589 smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
590 }
591 }
592
593
594 /***********************************************************************
595 * release_module
596 ***********************************************************************
597 DESCRIPTION: Called by the un load function
598 Go over the vector, for each bit that is set, release the corresponding module.
599
600 INPUT: hConn - SME SM handle.
601 pSmeSm - Vector that contains a bit set for each module thah had been initiualized
602
603 OUTPUT:
604
605 RETURN: OK on success, NOK otherwise
606
607 ************************************************************************/
release_module(smeSm_t * pSmeSm,UINT32 initVec)608 static void release_module(smeSm_t *pSmeSm, UINT32 initVec)
609 {
610
611 if (initVec & (1 << SM_INIT_BIT))
612 smeSm_smUnLoad(pSmeSm->hOs, pSmeSm->pFsm);
613
614 if (initVec & (1 << TIMER_INIT_BIT))
615 {
616 os_timerStop(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
617 utils_nullTimerDestroy(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
618 }
619
620 if (initVec & (1 << SME_INIT_BIT))
621 utils_nullMemoryFree(pSmeSm->hOs, pSmeSm, sizeof(smeSm_t));
622
623
624 initVec = 0;
625 }
626
627 /***********************************************************************
628 * smeSm_setParam
629 ***********************************************************************
630 DESCRIPTION: SME SM set param function, called by the following:
631 - config mgr in order to set a parameter from the OS abstraction layer.
632 - Form inside the driver
633
634 INPUT: hSmeSm - SME SM handle.
635 pParam - Pointer to the parameter
636
637 OUTPUT:
638
639 RETURN: OK on success, NOK otherwise
640
641 ************************************************************************/
smeSm_setParam(TI_HANDLE hSmeSm,paramInfo_t * pParam)642 TI_STATUS smeSm_setParam(TI_HANDLE hSmeSm,
643 paramInfo_t *pParam)
644 {
645 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
646
647 switch(pParam->paramType)
648 {
649 case SME_SCAN_ENABLED_PARAM:
650 if (pSmeSm->scanEnabled != pParam->content.smeSMScanEnabled)
651 {
652 if ((pParam->content.smeSMScanEnabled == SCAN_ENABLED) &&
653 (pSmeSm->scanEnabled == SKIP_NEXT_SCAN))
654 {
655 /* Requested to st scanEnable to TRUE;
656 if we are about to skip the nextcoming scan, ignore the request */
657 break;
658 }
659 if ((pParam->content.smeSMScanEnabled == SKIP_NEXT_SCAN) &&
660 (pSmeSm->scanEnabled == SCAN_DISABLED))
661 {
662 /* Requested to st scanEnable to SKIP_NEXT_SCAN
663 while it is currently set to FALSE - error, ignore the request */
664 WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG,
665 ("Set param, error changing scan enabled param from %d to %d\n",
666 pSmeSm->scanEnabled, pParam->content.smeSMScanEnabled));
667 break;
668 }
669 pSmeSm->scanEnabled = pParam->content.smeSMScanEnabled;
670 }
671 break;
672
673 default:
674 WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG,
675 ("Set param, Params is not supported, %d\n\n", pParam->paramType));
676 return PARAM_NOT_SUPPORTED;
677 }
678
679 return OK;
680 }
681
682 /***********************************************************************
683 * smeSm_getParam
684 ***********************************************************************
685 DESCRIPTION: SME SM get param function, called by the following:
686 - config mgr in order to get a parameter from the OS abstraction layer.
687 - Fomr inside the dirver
688
689 INPUT: hSmeSm - SME SM handle.
690 pParam - Pointer to the parameter
691
692 OUTPUT:
693
694 RETURN: OK on success, NOK otherwise
695
696 ************************************************************************/
smeSm_getParam(TI_HANDLE hSmeSm,paramInfo_t * pParam)697 TI_STATUS smeSm_getParam(TI_HANDLE hSmeSm,
698 paramInfo_t *pParam)
699 {
700 smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
701
702 switch(pParam->paramType)
703 {
704 case SITE_MGR_CONNECTION_STATUS_PARAM:
705 switch (pSmeSm->state)
706 {
707 case SME_SM_STATE_IDLE:
708 case SME_SM_STATE_INTER_SCAN:
709 pParam->content.smeSmConnectionStatus = eDot11Idle;
710 break;
711 case SME_SM_STATE_SCANNING:
712 pParam->content.smeSmConnectionStatus = eDot11Scaning;
713 break;
714 case SME_SM_STATE_CONNECTING:
715 pParam->content.smeSmConnectionStatus = eDot11Connecting;
716 break;
717 default:
718 pParam->content.smeSmConnectionStatus = eDot11Associated;
719 break;
720 }
721 break;
722
723 case SME_SM_STATE_PARAM:
724 pParam->content.smeSmState = pSmeSm->state;
725 break;
726
727 case SME_SCAN_ENABLED_PARAM:
728 pParam->content.smeSMScanEnabled = pSmeSm->scanEnabled;
729 break;
730
731 default:
732 WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->paramType));
733 return PARAM_NOT_SUPPORTED;
734 }
735
736 return OK;
737 }
738