2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/mgmt/ais_fsm.h#1 $
6 \brief Declaration of functions and finite state machine for AIS Module.
8 Declaration of functions and finite state machine for AIS Module.
17 * [WCXRP00001120] [MT6620 Wi-Fi][Driver] Modify roaming to AIS state transition from synchronous to asynchronous approach to avoid incomplete state termination
18 * 1. change RDD related compile option brace position.
19 * 2. when roaming is triggered, ask AIS to transit immediately only when AIS is in Normal TR state without join timeout timer ticking
20 * 3. otherwise, insert AIS_REQUEST into pending request queue
23 * [WCXRP00000676] [MT6620 Wi-Fi][Driver] AIS to reduce request channel period from 5 seconds to 2 seconds
24 * channel interval for joining is shortened to 2 seconds to avoid interruption of concurrent operating network.
26 * 02 26 2011 tsaiyuan.hsu
27 * [WCXRP00000391] [MT6620 Wi-Fi][FW] Add Roaming Support
28 * not send disassoc or deauth to leaving AP so as to improve performace of roaming.
31 * [WCXRP00000487] [MT6620 Wi-Fi][Driver][AIS] Serve scan and connect request with a queue-based approach to improve response time for scanning request
32 * handle SCAN and RECONNECT with a FIFO approach.
34 * 01 27 2011 tsaiyuan.hsu
35 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
37 * 1. not support 11r, only use strength of signal to determine roaming.
38 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
39 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
40 * 4. assume that change of link quality in smooth way.
43 * [WCXRP00000359] [MT6620 Wi-Fi][Driver] add an extra state to ensure DEAUTH frame is always sent
44 * Add an extra state to guarantee DEAUTH frame is sent then connect to new BSS.
45 * This change is due to WAPI AP needs DEAUTH frame as a necessary step in handshaking protocol.
48 * [WCXRP00000208] [MT6620 Wi-Fi][Driver] Add scanning with specified SSID to AIS FSM
49 * add scanning with specified SSID facility to AIS-FSM
52 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] Add implementation for querying current TX rate from firmware auto rate module
53 * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
54 * 2) Remove CNM CH-RECOVER event handling
55 * 3) cfg read/write API renamed with kal prefix for unified naming rules.
59 * 1) initialize for correct parameter even for disassociation.
60 * 2) AIS-FSM should have a limit on trials to build connection
62 * 09 03 2010 kevin.huang
64 * Refine #include sequence and solve recursive/nested #include issue
68 * [AIS-FSM] IBSS no longer needs to acquire channel for beaconing, RLM/CNM will handle the channel switching when BSS information is updated
70 * 08 12 2010 kevin.huang
72 * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
76 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
80 * surpress compilation warning.
84 * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
85 * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
86 * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
90 * AIS-FSM: when scan request is coming in the 1st 5 seconds of channel privilege period, just pend it til 5-sec. period finishes
94 * AIS-FSM FIX: return channel privilege even when the privilege is not granted yet
95 * QM: qmGetFrameAction() won't assert when corresponding STA-REC index is not found
99 * add AIS-FSM handling for beacon timeout event.
103 * separate AIS-FSM states into different cases of channel request.
107 * 1) change BG_SCAN to ONLINE_SCAN for consistent term
108 * 2) only clear scanning result when scan is permitted to do
112 * [WPD00003833] [MT6620 and MT5931] Driver migration.
113 * Add Ad-Hoc support to AIS-FSM
117 * [WPD00003833] [MT6620 and MT5931] Driver migration.
118 * Refine AIS-FSM by divided into more states
122 * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
123 * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
124 * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
128 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
131 * [WPD00003833][MT6620 and MT5931] Driver migration
132 * AIS-FSM integration with CNM channel request messages
135 * [WPD00003833][MT6620 and MT5931] Driver migration
136 * implementation of DRV-SCN and related mailbox message handling.
139 * [WPD00003833][MT6620 and MT5931] Driver migration
140 * add buildable & linkable ais_fsm.c
142 * related reference are still waiting to be resolved
145 * [WPD00003833][MT6620 and MT5931] Driver migration
146 * add definitions for module migration.
149 * [WPD00003833][MT6620 and MT5931] Driver migration
150 * add aa_fsm.h, ais_fsm.h, bss.h, mib.h and scan.h.
152 * 05 12 2010 kevin.huang
153 * [BORA00000794][WIFISYS][New Feature]Power Management Support
154 * Add Power Management - Legacy PS-POLL support.
157 * [BORA00000605][WIFISYS] Phase3 Integration
158 * reduce the backgroud ssid idle time min and max value
160 * 04 19 2010 kevin.huang
161 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
162 * Add Beacon Timeout Support
163 * * and will send Null frame to diagnose connection
165 * 03 16 2010 kevin.huang
166 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
169 * 03 10 2010 kevin.huang
170 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
172 * * Add Channel Manager for arbitration of JOIN and SCAN Req
174 * 02 26 2010 kevin.huang
175 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
176 * Remove CFG_TEST_VIRTUAL_CMD and add support of Driver STA_RECORD_T activation
178 * 02 23 2010 kevin.huang
179 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
180 * Support dynamic channel selection
182 * 02 04 2010 kevin.huang
183 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
184 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
186 * 01 11 2010 kevin.huang
187 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
188 * Add Deauth and Disassoc Handler
190 * 01 07 2010 kevin.huang
191 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
192 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
193 * Add Media disconnect indication and related postpone functions
195 * Dec 3 2009 mtk01461
196 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
197 * Add aisFsmRunEventJoinComplete()
199 * Nov 25 2009 mtk01461
200 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
201 * Add Virtual CMD & RESP for testing CMD PATH
203 * Nov 23 2009 mtk01461
204 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
205 * add aisFsmInitializeConnectionSettings()
207 * Nov 20 2009 mtk01461
208 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
209 * Add CFG_TEST_MGMT_FSM for aisFsmTest()
211 * Nov 18 2009 mtk01104
212 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
213 * Add function prototype of aisFsmInit()
215 * Nov 16 2009 mtk01461
216 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
223 /*******************************************************************************
224 * C O M P I L E R F L A G S
225 ********************************************************************************
228 /*******************************************************************************
229 * E X T E R N A L R E F E R E N C E S
230 ********************************************************************************
233 /*******************************************************************************
235 ********************************************************************************
237 #define AIS_BG_SCAN_INTERVAL_MIN_SEC 2 //30 // exponential to 960
238 #define AIS_BG_SCAN_INTERVAL_MAX_SEC 2 //960 // 16min
240 #define AIS_DELAY_TIME_OF_DISCONNECT_SEC 10
242 #define AIS_IBSS_ALONE_TIMEOUT_SEC 20 // seconds
244 #define AIS_BEACON_TIMEOUT_COUNT_ADHOC 30
245 #define AIS_BEACON_TIMEOUT_COUNT_INFRA 10
246 #define AIS_BEACON_TIMEOUT_GUARD_TIME_SEC 1 /* Second */
248 #define AIS_BEACON_MAX_TIMEOUT_TU 100
249 #define AIS_BEACON_MIN_TIMEOUT_TU 5
250 #define AIS_BEACON_MAX_TIMEOUT_VALID TRUE
251 #define AIS_BEACON_MIN_TIMEOUT_VALID TRUE
253 #define AIS_BMC_MAX_TIMEOUT_TU 100
254 #define AIS_BMC_MIN_TIMEOUT_TU 5
255 #define AIS_BMC_MAX_TIMEOUT_VALID TRUE
256 #define AIS_BMC_MIN_TIMEOUT_VALID TRUE
258 #define AIS_JOIN_CH_GRANT_THRESHOLD 10
259 #define AIS_JOIN_CH_REQUEST_INTERVAL 2000
261 /*******************************************************************************
263 ********************************************************************************
265 typedef enum _ENUM_AIS_STATE_T {
269 AIS_STATE_ONLINE_SCAN,
270 AIS_STATE_LOOKING_FOR,
271 AIS_STATE_WAIT_FOR_NEXT_SCAN,
272 AIS_STATE_REQ_CHANNEL_JOIN,
274 AIS_STATE_IBSS_ALONE,
275 AIS_STATE_IBSS_MERGE,
277 AIS_STATE_DISCONNECTING,
282 typedef struct _MSG_AIS_ABORT_T {
283 MSG_HDR_T rMsgHdr; /* Must be the first member */
284 UINT_8 ucReasonOfDisconnect;
285 BOOLEAN fgDelayIndication;
286 } MSG_AIS_ABORT_T, *P_MSG_AIS_ABORT_T;
289 typedef struct _MSG_AIS_IBSS_PEER_FOUND_T {
290 MSG_HDR_T rMsgHdr; /* Must be the first member */
291 UINT_8 ucNetTypeIndex;
292 BOOLEAN fgIsMergeIn; /* TRUE: Merge In, FALSE: Merge Out */
293 P_STA_RECORD_T prStaRec;
294 } MSG_AIS_IBSS_PEER_FOUND_T, *P_MSG_AIS_IBSS_PEER_FOUND_T;
296 typedef enum _ENUM_AIS_REQUEST_TYPE_T {
298 AIS_REQUEST_RECONNECT,
299 AIS_REQUEST_ROAMING_SEARCH,
300 AIS_REQUEST_ROAMING_CONNECT,
302 } ENUM_AIS_REQUEST_TYPE_T;
304 typedef struct _AIS_REQ_HDR_T {
305 LINK_ENTRY_T rLinkEntry;
306 ENUM_AIS_REQUEST_TYPE_T eReqType;
307 } AIS_REQ_HDR_T, *P_AIS_REQ_HDR_T;
310 typedef struct _AIS_FSM_INFO_T {
311 ENUM_AIS_STATE_T ePreviousState;
312 ENUM_AIS_STATE_T eCurrentState;
316 BOOLEAN fgIsInfraChannelFinished;
317 BOOLEAN fgIsChannelRequested;
318 BOOLEAN fgIsChannelGranted;
320 #if CFG_SUPPORT_ROAMING
321 BOOLEAN fgIsRoamingScanPending;
322 #endif /* CFG_SUPPORT_ROAMING */
324 UINT_8 ucAvailableAuthTypes; /* Used for AUTH_MODE_AUTO_SWITCH */
326 P_BSS_DESC_T prTargetBssDesc; /* For destination */
328 P_STA_RECORD_T prTargetStaRec; /* For JOIN Abort */
330 UINT_32 u4SleepInterval;
332 TIMER_T rBGScanTimer;
334 TIMER_T rIbssAloneTimer;
336 TIMER_T rIndicationOfDisconnectTimer;
338 TIMER_T rJoinTimeoutTimer;
340 UINT_8 ucSeqNumOfReqMsg;
341 UINT_8 ucSeqNumOfChReq;
342 UINT_8 ucSeqNumOfScanReq;
344 UINT_32 u4ChGrantedInterval;
346 UINT_8 ucConnTrialCount;
348 UINT_8 ucScanSSIDLen;
349 UINT_8 aucScanSSID[ELEM_MAX_LEN_SSID];
351 UINT_32 u4ScanIELength;
352 UINT_8 aucScanIEBuf[MAX_IE_LENGTH];
354 /* Pending Request List */
355 LINK_T rPendingReqList;
357 } AIS_FSM_INFO_T, *P_AIS_FSM_INFO_T;
360 /*******************************************************************************
361 * P U B L I C D A T A
362 ********************************************************************************
365 /*******************************************************************************
366 * P R I V A T E D A T A
367 ********************************************************************************
370 /*******************************************************************************
372 ********************************************************************************
374 #define aisChangeMediaState(_prAdapter, _eNewMediaState) \
375 (_prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].eConnectionState = (_eNewMediaState));
378 /*******************************************************************************
379 * F U N C T I O N D E C L A R A T I O N S
380 ********************************************************************************
383 aisInitializeConnectionSettings (
384 IN P_ADAPTER_T prAdapter,
385 IN P_REG_INFO_T prRegInfo
390 IN P_ADAPTER_T prAdapter
395 IN P_ADAPTER_T prAdapter
399 aisFsmStateInit_JOIN (
400 IN P_ADAPTER_T prAdapter,
401 P_BSS_DESC_T prBssDesc
405 aisFsmStateInit_RetryJOIN (
406 IN P_ADAPTER_T prAdapter,
407 IN P_STA_RECORD_T prStaRec
411 aisFsmStateInit_IBSS_ALONE (
412 IN P_ADAPTER_T prAdapter
416 aisFsmStateInit_IBSS_MERGE (
417 IN P_ADAPTER_T prAdapter,
418 P_BSS_DESC_T prBssDesc
423 IN P_ADAPTER_T prAdapter,
424 UINT_8 ucReasonOfDisconnect,
425 BOOLEAN fgDelayIndication
429 aisFsmStateAbort_JOIN (
430 IN P_ADAPTER_T prAdapter
434 aisFsmStateAbort_SCAN (
435 IN P_ADAPTER_T prAdapter
439 aisFsmStateAbort_NORMAL_TR (
440 IN P_ADAPTER_T prAdapter
444 aisFsmStateAbort_IBSS (
445 IN P_ADAPTER_T prAdapter
450 IN P_ADAPTER_T prAdapter,
451 ENUM_AIS_STATE_T eNextState
454 /*----------------------------------------------------------------------------*/
455 /* Mailbox Message Handling */
456 /*----------------------------------------------------------------------------*/
458 aisFsmRunEventScanDone (
459 IN P_ADAPTER_T prAdapter,
460 IN P_MSG_HDR_T prMsgHdr
464 aisFsmRunEventAbort (
465 IN P_ADAPTER_T prAdapter,
466 IN P_MSG_HDR_T prMsgHdr
470 aisFsmRunEventJoinComplete (
471 IN P_ADAPTER_T prAdapter,
472 IN P_MSG_HDR_T prMsgHdr
476 aisFsmRunEventFoundIBSSPeer (
477 IN P_ADAPTER_T prAdapter,
478 IN P_MSG_HDR_T prMsgHdr
481 /*----------------------------------------------------------------------------*/
482 /* Handling for Ad-Hoc Network */
483 /*----------------------------------------------------------------------------*/
486 IN P_ADAPTER_T prAdapter
491 IN P_ADAPTER_T prAdapter,
492 IN P_STA_RECORD_T prStaRec
495 /*----------------------------------------------------------------------------*/
496 /* Handling of Incoming Mailbox Message from CNM */
497 /*----------------------------------------------------------------------------*/
499 aisFsmRunEventChGrant (
500 IN P_ADAPTER_T prAdapter,
501 IN P_MSG_HDR_T prMsgHdr
505 /*----------------------------------------------------------------------------*/
506 /* Generating Outgoing Mailbox Message to CNM */
507 /*----------------------------------------------------------------------------*/
510 IN P_ADAPTER_T prAdapter
514 /*----------------------------------------------------------------------------*/
515 /* Event Indication */
516 /*----------------------------------------------------------------------------*/
518 aisIndicationOfMediaStateToHost (
519 IN P_ADAPTER_T prAdapter,
520 ENUM_PARAM_MEDIA_STATE_T eConnectionState,
521 BOOLEAN fgDelayIndication
525 aisPostponedEventOfDisconnTimeout (
526 IN P_ADAPTER_T prAdapter,
531 aisUpdateBssInfoForJOIN (
532 IN P_ADAPTER_T prAdapter,
533 P_STA_RECORD_T prStaRec,
534 P_SW_RFB_T prAssocRspSwRfb
538 aisUpdateBssInfoForCreateIBSS (
539 IN P_ADAPTER_T prAdapter
543 aisUpdateBssInfoForMergeIBSS (
544 IN P_ADAPTER_T prAdapter,
545 IN P_STA_RECORD_T prStaRec
549 aisValidateProbeReq (
550 IN P_ADAPTER_T prAdapter,
551 IN P_SW_RFB_T prSwRfb,
552 OUT PUINT_32 pu4ControlFlags
555 /*----------------------------------------------------------------------------*/
556 /* Disconnection Handling */
557 /*----------------------------------------------------------------------------*/
560 IN P_ADAPTER_T prAdapter,
561 IN BOOLEAN fgDelayIndication
565 /*----------------------------------------------------------------------------*/
567 /*----------------------------------------------------------------------------*/
569 aisBssBeaconTimeout (
570 IN P_ADAPTER_T prAdapter
574 aisDeauthXmitComplete (
575 IN P_ADAPTER_T prAdapter,
576 IN P_MSDU_INFO_T prMsduInfo,
577 IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
580 #if CFG_SUPPORT_ROAMING
582 aisFsmRunEventRoamingDiscovery (
583 IN P_ADAPTER_T prAdapter,
588 aisFsmRoamingScanResultsUpdate (
589 IN P_ADAPTER_T prAdapter
593 aisFsmRoamingDisconnectPrevAP (
594 IN P_ADAPTER_T prAdapter,
595 IN P_STA_RECORD_T prTargetStaRec
599 aisUpdateBssInfoForRoamingAP (
600 IN P_ADAPTER_T prAdapter,
601 IN P_STA_RECORD_T prStaRec,
602 IN P_SW_RFB_T prAssocRspSwRfb
604 #endif /*CFG_SUPPORT_ROAMING */
606 /*----------------------------------------------------------------------------*/
607 /* Timeout Handling */
608 /*----------------------------------------------------------------------------*/
610 aisFsmRunEventBGSleepTimeOut (
611 IN P_ADAPTER_T prAdapter,
616 aisFsmRunEventIbssAloneTimeOut (
617 IN P_ADAPTER_T prAdapter,
622 aisFsmRunEventJoinTimeout (
623 IN P_ADAPTER_T prAdapter,
627 /*----------------------------------------------------------------------------*/
628 /* OID/IOCTL Handling */
629 /*----------------------------------------------------------------------------*/
632 IN P_ADAPTER_T prAdapter,
633 IN P_PARAM_SSID_T prSsid,
635 IN UINT_32 u4IeLength
638 /*----------------------------------------------------------------------------*/
639 /* Internal State Checking */
640 /*----------------------------------------------------------------------------*/
642 aisFsmIsRequestPending (
643 IN P_ADAPTER_T prAdapter,
644 IN ENUM_AIS_REQUEST_TYPE_T eReqType,
649 aisFsmGetNextRequest (
650 IN P_ADAPTER_T prAdapter
654 aisFsmInsertRequest (
655 IN P_ADAPTER_T prAdapter,
656 IN ENUM_AIS_REQUEST_TYPE_T eReqType
661 IN P_ADAPTER_T prAdapter
665 #if defined(CFG_TEST_MGMT_FSM) && (CFG_TEST_MGMT_FSM != 0)
670 #endif /* CFG_TEST_MGMT_FSM */
671 /*******************************************************************************
673 ********************************************************************************
676 #endif /* _AIS_FSM_H */