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

Language C Lines 738
MD5 Hash 38cabf39011c014a853e92f5b7576f94 Estimated Cost $8,946 (why?)
Repository git://github.com/CyanogenMod/cm-kernel.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/****************************************************************************
**+-----------------------------------------------------------------------+**
**|                                                                       |**
**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
**| All rights reserved.                                                  |**
**|                                                                       |**
**| Redistribution and use in source and binary forms, with or without    |**
**| modification, are permitted provided that the following conditions    |**
**| are met:                                                              |**
**|                                                                       |**
**|  * Redistributions of source code must retain the above copyright     |**
**|    notice, this list of conditions and the following disclaimer.      |**
**|  * Redistributions in binary form must reproduce the above copyright  |**
**|    notice, this list of conditions and the following disclaimer in    |**
**|    the documentation and/or other materials provided with the         |**
**|    distribution.                                                      |**
**|  * Neither the name Texas Instruments nor the names of its            |**
**|    contributors may be used to endorse or promote products derived    |**
**|    from this software without specific prior written permission.      |**
**|                                                                       |**
**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
**|                                                                       |**
**+-----------------------------------------------------------------------+**
****************************************************************************/

/** \file smeSmApi.c
 *  \brief SME SM API implementation
 * 
 *  The state machine itself is implemented in the file	smeSm.c.				
 *
 *  \see smeSmApi.h
 */

#include "report.h"
#include "osTIType.h"
#include "osApi.h"
#include "smeSm.h"
#include "smeApi.h"
#include "smeSmApi.h"
#include "utils.h"
#include "802_11Defs.h"
#include "regulatoryDomainApi.h"
#include "siteMgrApi.h"
#include "connApi.h"
#include "EvHandler.h"
#include "TI_IPC_Api.h"


#define WLAN_INTER_SCAN_DELTA 10

/* State machine definitions */
#define SME_INIT_BIT			1
#define SM_INIT_BIT				2
#define TIMER_INIT_BIT			3

/* Local functions prototypes */

static void release_module(smeSm_t *pSmeSm, UINT32 initVec);

void smeSm_InterScanTimeoutCB(TI_HANDLE     hSmeSm);


/* Interface functions Implementation */

/************************************************************************
 *                        smeSm_create								*
 ************************************************************************
DESCRIPTION: SME SM module creation function, called by the config mgr in creation phase 
				performs the following:
				-	Allocate the SME SM handle
				-	Create the SME state machine
                                                                                                   
INPUT:      hOs -			Handle to OS		


OUTPUT:		

RETURN:     Handle to the SME SM module on success, NULL otherwise

************************************************************************/
TI_HANDLE smeSm_create(TI_HANDLE hOs)
{
	smeSm_t			*pSmeSm;
	UINT32			initVec;

	initVec = 0;

	pSmeSm = os_memoryAlloc(hOs, sizeof(smeSm_t));
	if (pSmeSm == NULL)
		return NULL;
	os_memoryZero(hOs, pSmeSm, sizeof(smeSm_t)); /* Dm: Fix */
	
	initVec |= (1 << SME_INIT_BIT);

	pSmeSm->pFsm = smeSm_smCreate(hOs);
	if (pSmeSm->pFsm == NULL)
	{
		release_module(pSmeSm, initVec);
		return NULL;
	}
	
	initVec |= (1 << SM_INIT_BIT);

	pSmeSm->hOs	= hOs;

	pSmeSm->interScanTimeoutTimer = os_timerCreate(hOs, smeSm_InterScanTimeoutCB, pSmeSm);
	if(pSmeSm->interScanTimeoutTimer == NULL)
	{
		release_module(pSmeSm, initVec);
	    WLAN_OS_REPORT(("FATAL ERROR: smeSm_create(): Error Creating smeSm - Aborting\n"));
		return NULL;
	}
	initVec |= (1 << TIMER_INIT_BIT);

	return(pSmeSm);
}

/************************************************************************
 *                        smeSm_config									*
 ************************************************************************
DESCRIPTION: SME SM module configuration function, called by the config mgr in configuration phase
				performs the following:
				-	Reset & initiailzes local variables
				-	Init the handles to be used by the module
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle
			List of handles to be used by the module

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS 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)

{
	TI_STATUS status;
	int index;
	
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	pSmeSm->state = SME_SM_STATE_IDLE;
	pSmeSm->hConn			= hConn;
	pSmeSm->hScanCncn		= hScanCncn;
	pSmeSm->hSiteMgr		= hSiteMgr;
	pSmeSm->hHalCtrl		= hHalCtrl;
	pSmeSm->hReport			= hReport;
	pSmeSm->hOs				= hOs;
    pSmeSm->hEvHandler  	= hEvHandler;
	pSmeSm->hScr			= hScr;
	pSmeSm->hApConn			= hApConn;
	pSmeSm->hCurrBss		= hCurrBss;
	pSmeSm->hPowerMgr		= hPowerMgr;
    pSmeSm->hRegulatoryDomain = hRegulatoryDomain;

	/* interscan timeout values */
	pSmeSm->scanEnabled				= (scanEnabledOptions_e)smeInitParams->EnableFirstConnScan; 
    pSmeSm->interScanTimeoutMin 	= smeInitParams->InterScanIntervalMin;
    pSmeSm->interScanTimeoutMax 	= smeInitParams->InterScanIntervalMax;
    pSmeSm->interScanTimeoutDelta 	= smeInitParams->InterScanIntervalDelta;
    pSmeSm->shutDownStatus = 0;


	/* 
	 *    Setting scan parameters for band 2.4Ghtz
	 */
	os_memoryCopy(hOs, &(pSmeSm->scanParamsBG), &(smeInitParams->scanParamsBG), sizeof(sme_scan_Params_t)); 
	/* The channel list is represented as char string terminate in zeros. */
	
	for( index = 0; 
		 ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsBG.channelsList[index] != 0)); 
		 index++ );

	pSmeSm->scanParamsBG.numOfChannels = index;

	/* 
	 *    Setting scan parameters for band 5.0Ghtz
	 */
	os_memoryCopy(hOs, &(pSmeSm->scanParamsA), &(smeInitParams->scanParamsA), sizeof(sme_scan_Params_t));
	
	for( index = 0; 
		 ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsA.channelsList[index] != 0)); 
		 index++ );

	pSmeSm->scanParamsA.numOfChannels = index;


    
    /* register to scan result callback */
    scanConcentrator_registerScanResultCB( pSmeSm->hScanCncn, SCAN_SCC_DRIVER, smeSm_scanComplete, hSmeSm );

	status = smeSm_smConfig(pSmeSm);

	if (status != OK)
		WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG,  (".....Sme state machine configuration Failure\n"));
	else
		WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG,  (".....Sme state machine configuration Success\n"));

	return status;
}

/************************************************************************
 *                        smeSm_getDriverShutdownStatus									*
 ************************************************************************
DESCRIPTION: Return shutdown status of driver.
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.		

OUTPUT:		

RETURN:     shutdown status of driver (SME/HAL)

************************************************************************/
UINT8 smeSm_getDriverShutdownStatus (TI_HANDLE		hSmeSm)
{
	smeSm_t			*pSmeSm = (smeSm_t *)hSmeSm;
    return (pSmeSm->shutDownStatus);
}


/************************************************************************
 *                        smeSm_unLoad									*
 ************************************************************************
DESCRIPTION: SME SM module unload function, called by the config mgr in the unlod phase 
				performs the following:
				-	Free all memory allocated by the module
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.		


OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_unLoad(TI_HANDLE		hSmeSm)
{
	UINT32			initVec;
	smeSm_t			*pSmeSm = (smeSm_t *)hSmeSm;

	if (!pSmeSm)
		return OK;

	initVec = 0xFFFF;
	release_module(pSmeSm, initVec);

	return OK;
}

/***********************************************************************
 *                        smeSm_start									
 ***********************************************************************
DESCRIPTION: Called by the configuration module in order to start the driver
			 Calls the SME SM with a start event
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_start(TI_HANDLE		hSmeSm)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	pSmeSm->radioOn = TRUE;
    pSmeSm->immediateShutdownRequired = FALSE;

	return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_START, pSmeSm);
}



/***********************************************************************
 *                        smeSm_restart									
 ***********************************************************************
DESCRIPTION: Called by the configuration module in order to start the driver
			 Calls the SME SM with a start event
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_reselect(TI_HANDLE		hSmeSm)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
	paramInfo_t			param;

	/* For new SSID reset interScanTimeout */
	pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;

	/* 
		Junk SSID is used for disabling connection attempts, if it is 
	   set the driver will be stopped at "inter scan" state.
	*/    

	param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
	siteMgr_getParam(pSmeSm->hSiteMgr, &param);

	if (utils_isJunkSSID(&param.content.siteMgrDesiredSSID))
	{
		pSmeSm->connectEnabled    = FALSE;

		WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
					("Sme Set JUNK SSID\n"));
		
		if( pSmeSm->state == SME_SM_STATE_SCANNING )
			/* If in scanning stop the scan, the disconnect event will
			   be sent by the scan complete function. */
			scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
		else
			smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
	}
	else 
	{
		pSmeSm->connectEnabled    = TRUE;
		smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
	}

	return OK;
}


/***********************************************************************
 *                        smeSm_stop									
 ***********************************************************************
DESCRIPTION: Called by the configuration module in order to stop the driver
			 Calls the SME SM with a stop event
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_stop(TI_HANDLE		hSmeSm)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	pSmeSm->radioOn = FALSE;
    pSmeSm->immediateShutdownRequired = FALSE;    

	return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
}

/***********************************************************************
 *                        smeSm_stopAndShutdown									
 ***********************************************************************
DESCRIPTION: Called by the configuration module in order to stop the driver
			 Calls the SME SM with a stop event
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
void smeSm_stopAndShutdown(TI_HANDLE		hSmeSm)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	pSmeSm->radioOn = FALSE;
    pSmeSm->immediateShutdownRequired = TRUE;

	smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
}

/***********************************************************************
 *                        smeSm_scanComplete									
 ***********************************************************************
DESCRIPTION: Called by the site manager When scan is completed
			 Calls the SME SM with a scan complete event
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
void smeSm_scanComplete( TI_HANDLE hSmeSm, scan_cncnResultStatus_e status,
                         scan_frameInfo_t *frameInfo, UINT16 SPSStatus )
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

    /* if this call is due to a scan result received, simply store it in the site mngr */
	if ( SCAN_CRS_RECEIVED_FRAME == status )
    {
		siteMgr_updateSite( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->parsedIEs, frameInfo->channel, frameInfo->band, FALSE);
        if ( BEACON == frameInfo->parsedIEs->subType )
        {
            siteMgr_saveBeaconBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
        }
        else
        {
            siteMgr_saveProbeRespBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
        }
#ifdef TI_DBG
		/* update statistics - count one more result that was received */
		pSmeSm->smeStats.currentNumberOfScanResults++;
#endif
        return;
    }

#ifdef TI_DBG
	/* update statistics - update scan results histogram */
	if ( SCAN_RESULT_HISTOGRAM_SIZE <= pSmeSm->smeStats.currentNumberOfScanResults )
	{
		pSmeSm->smeStats.scanResulCountHistogram[ SCAN_RESULT_HISTOGRAM_SIZE -1 ]++;
	}
	else
	{
		pSmeSm->smeStats.scanResulCountHistogram[ pSmeSm->smeStats.currentNumberOfScanResults ]++;
	}
	pSmeSm->smeStats.currentNumberOfScanResults = 0;
#endif

	WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
				("smeSm_scanComplete\n"));

    siteMgr_removeNotReceivedSites(pSmeSm->hSiteMgr);

	if ( pSmeSm->connectEnabled ) 
    {
	    /* check for rescan and perform scan when it is on */
		if ( TRUE == pSmeSm->reScanFlag )
        {
		    WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
                                     ("SME_SM: doing additional scan due to reScanFlag = ON\n") );
		    pSmeSm->reScanFlag = FALSE;
			sme_startScan(pSmeSm);
		} 
        /* check for dual band rescan */
		else if ( TRUE == pSmeSm->dualBandReScanFlag )
        {
		    WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
                                     ("SME_SM: doing additional scan due to dualBandReScanFlag = ON\n") );
			sme_startScan(pSmeSm);
        }
        else
        {
			smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE, pSmeSm);
		}
	} 
	else
    {
		/* If connection is disabled then send disconnect event, the SM will
		 * move into inter scan state
		 */
		pSmeSm->reScanFlag = FALSE;	/* (Just to make sure) */
        pSmeSm->dualBandReScanFlag = FALSE;
		smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
	}
}


/***********************************************************************
 *                        smeSm_reportConnStatus					
 ***********************************************************************
DESCRIPTION: Called by the connection module when connection status changes
			 Calls the SME SM with a connection suceess or connection failure based on the status
                                                                                                   
INPUT:      hSmeSm		-	SME SM handle.
			statusType	-	Connection status
			uStatusCode -	extra information to statusType (usually status code of the packet)

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_reportConnStatus(TI_HANDLE	hSmeSm, mgmtStatus_e statusType, UINT32 uStatusCode)							 
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
		("%s statusType = %d, uStatusCode = %d \n",__FUNCTION__, statusType, uStatusCode));

	switch(statusType)
	{
		case STATUS_SUCCESSFUL:
			return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_SUCCESS, pSmeSm);

		/*
		*  The next section handles connection failures, all cases are sending same event to SM. 
		*/              
		case		STATUS_AUTH_REJECT:										
		case		STATUS_ASSOC_REJECT:										
		case		STATUS_SECURITY_FAILURE:                                   
		case		STATUS_AP_DEAUTHENTICATE:	
		case		STATUS_AP_DISASSOCIATE:
		case		STATUS_ROAMING_TRIGGER:		
			pSmeSm->DisAssoc.mgmtStatus  = statusType;
			pSmeSm->DisAssoc.uStatusCode = uStatusCode;
			/* Note that in case of unspecified status we won't update the status. This is done since this function could be called twice */
			/* for example: apConn called this function and than SME called conn_stop and this function is called again					  */
		case		STATUS_UNSPECIFIED:                                        

			return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_FAILURE, pSmeSm);

	default:
		WLAN_REPORT_WARNING(pSmeSm->hReport, SME_SM_MODULE_LOG,  
			("%s unknown statusType = %d\n",__FUNCTION__, statusType));

		break;
	}

	return OK;
}

/***********************************************************************
 *                        smeSm_reportSelectStatus									
 ***********************************************************************
DESCRIPTION: Called by the selection function
			 Calls the SME SM with a selection suceess or selection failure based on the status
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.
			status	-	selection status

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_reportSelectStatus(TI_HANDLE		hSmeSm, 
								mgmtStatus_e	status)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
	
	if (status == SELECT_STATUS_SUCCESS)
		return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_SUCCESS, pSmeSm);
	else
		return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_FAILURE, pSmeSm);
}


/***********************************************************************
 *                        smeSm_startScan									
 ***********************************************************************
DESCRIPTION: Timer callback, on expiration of which, scan started
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
void smeSm_InterScanTimeoutCB(TI_HANDLE     hSmeSm)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	if ( pSmeSm->connectEnabled )
	{
		pSmeSm->interScanTimeout += pSmeSm->interScanTimeoutDelta;

		if( pSmeSm->interScanTimeout > pSmeSm->interScanTimeoutMax )
			pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMax;

		smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
	}
}


/***********************************************************************
 *                        release_module									
 ***********************************************************************
DESCRIPTION:	Called by the un load function
				Go over the vector, for each bit that is set, release the corresponding module.
                                                                                                   
INPUT:      hConn	-	SME SM handle.
			pSmeSm	-	Vector that contains a bit set for each module thah had been initiualized

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
static void release_module(smeSm_t *pSmeSm, UINT32 initVec)
{

	if (initVec & (1 << SM_INIT_BIT))
		smeSm_smUnLoad(pSmeSm->hOs, pSmeSm->pFsm);

	if (initVec & (1 << TIMER_INIT_BIT))
	{
		os_timerStop(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
		utils_nullTimerDestroy(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
	}

	if (initVec & (1 << SME_INIT_BIT))
		utils_nullMemoryFree(pSmeSm->hOs, pSmeSm, sizeof(smeSm_t));


	initVec = 0;
}

/***********************************************************************
 *                        smeSm_setParam									
 ***********************************************************************
DESCRIPTION: SME SM set param function, called by the following:
				-	config mgr in order to set a parameter from the OS abstraction layer.
				-	Form inside the driver
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.
			pParam	-	Pointer to the parameter		

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_setParam(TI_HANDLE			hSmeSm,
						paramInfo_t		*pParam)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	switch(pParam->paramType)
	{
	case SME_SCAN_ENABLED_PARAM:
		if (pSmeSm->scanEnabled != pParam->content.smeSMScanEnabled)
		{
			if ((pParam->content.smeSMScanEnabled == SCAN_ENABLED) &&
				(pSmeSm->scanEnabled == SKIP_NEXT_SCAN))
			{
				/* Requested to st scanEnable to TRUE; 
				  if we are about to skip the nextcoming scan, ignore the request */
				break;
			}
			if ((pParam->content.smeSMScanEnabled == SKIP_NEXT_SCAN) &&
				(pSmeSm->scanEnabled == SCAN_DISABLED))
			{
				/* Requested to st scanEnable to SKIP_NEXT_SCAN 
				   while it is currently set to FALSE - error, ignore the request */
				WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG, 
								   ("Set param, error changing scan enabled param from %d to %d\n",
									pSmeSm->scanEnabled, pParam->content.smeSMScanEnabled));
				break;
			}
			pSmeSm->scanEnabled = pParam->content.smeSMScanEnabled;
		}
		break;

	default:
		WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG, 
						   ("Set param, Params is not supported, %d\n\n", pParam->paramType));
		return PARAM_NOT_SUPPORTED;
	}

	return OK;
}

/***********************************************************************
 *                        smeSm_getParam									
 ***********************************************************************
DESCRIPTION: SME SM get param function, called by the following:
			-	config mgr in order to get a parameter from the OS abstraction layer.
			-	Fomr inside the dirver	
                                                                                                   
INPUT:      hSmeSm	-	SME SM handle.
			pParam	-	Pointer to the parameter		

OUTPUT:		

RETURN:     OK on success, NOK otherwise

************************************************************************/
TI_STATUS smeSm_getParam(TI_HANDLE			hSmeSm, 
						paramInfo_t		*pParam)
{
	smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;

	switch(pParam->paramType)
	{
	case SITE_MGR_CONNECTION_STATUS_PARAM:
		switch (pSmeSm->state)
		{
		case SME_SM_STATE_IDLE:
		case SME_SM_STATE_INTER_SCAN:
			pParam->content.smeSmConnectionStatus = eDot11Idle;
			break;
		case SME_SM_STATE_SCANNING:
			pParam->content.smeSmConnectionStatus = eDot11Scaning;
			break;
		case SME_SM_STATE_CONNECTING:
			pParam->content.smeSmConnectionStatus = eDot11Connecting;
			break;
		default: 
			pParam->content.smeSmConnectionStatus = eDot11Associated;
			break;
		}
		break;

	case SME_SM_STATE_PARAM:
		pParam->content.smeSmState = pSmeSm->state;
		break;

	case SME_SCAN_ENABLED_PARAM:
		pParam->content.smeSMScanEnabled = pSmeSm->scanEnabled;
		break;

	default:
		WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->paramType));
		return PARAM_NOT_SUPPORTED;
	}

	return OK;
}
Back to Top