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 #define AIS_SCN_DONE_TIMEOUT_SEC 5
263 /*******************************************************************************
265 ********************************************************************************
267 typedef enum _ENUM_AIS_STATE_T {
271 AIS_STATE_ONLINE_SCAN,
272 AIS_STATE_LOOKING_FOR,
273 AIS_STATE_WAIT_FOR_NEXT_SCAN,
274 AIS_STATE_REQ_CHANNEL_JOIN,
276 AIS_STATE_IBSS_ALONE,
277 AIS_STATE_IBSS_MERGE,
279 AIS_STATE_DISCONNECTING,
284 typedef struct _MSG_AIS_ABORT_T {
285 MSG_HDR_T rMsgHdr; /* Must be the first member */
286 UINT_8 ucReasonOfDisconnect;
287 BOOLEAN fgDelayIndication;
288 } MSG_AIS_ABORT_T, *P_MSG_AIS_ABORT_T;
291 typedef struct _MSG_AIS_IBSS_PEER_FOUND_T {
292 MSG_HDR_T rMsgHdr; /* Must be the first member */
293 UINT_8 ucNetTypeIndex;
294 BOOLEAN fgIsMergeIn; /* TRUE: Merge In, FALSE: Merge Out */
295 P_STA_RECORD_T prStaRec;
296 } MSG_AIS_IBSS_PEER_FOUND_T, *P_MSG_AIS_IBSS_PEER_FOUND_T;
298 typedef enum _ENUM_AIS_REQUEST_TYPE_T {
300 AIS_REQUEST_RECONNECT,
301 AIS_REQUEST_ROAMING_SEARCH,
302 AIS_REQUEST_ROAMING_CONNECT,
304 } ENUM_AIS_REQUEST_TYPE_T;
306 typedef struct _AIS_REQ_HDR_T {
307 LINK_ENTRY_T rLinkEntry;
308 ENUM_AIS_REQUEST_TYPE_T eReqType;
309 } AIS_REQ_HDR_T, *P_AIS_REQ_HDR_T;
312 typedef struct _AIS_FSM_INFO_T {
313 ENUM_AIS_STATE_T ePreviousState;
314 ENUM_AIS_STATE_T eCurrentState;
318 BOOLEAN fgIsInfraChannelFinished;
319 BOOLEAN fgIsChannelRequested;
320 BOOLEAN fgIsChannelGranted;
322 #if CFG_SUPPORT_ROAMING
323 BOOLEAN fgIsRoamingScanPending;
324 #endif /* CFG_SUPPORT_ROAMING */
326 UINT_8 ucAvailableAuthTypes; /* Used for AUTH_MODE_AUTO_SWITCH */
328 P_BSS_DESC_T prTargetBssDesc; /* For destination */
330 P_STA_RECORD_T prTargetStaRec; /* For JOIN Abort */
332 UINT_32 u4SleepInterval;
334 TIMER_T rBGScanTimer;
336 TIMER_T rIbssAloneTimer;
338 TIMER_T rIndicationOfDisconnectTimer;
340 TIMER_T rJoinTimeoutTimer;
343 TIMER_T rScanDoneTimer;
345 UINT_8 ucSeqNumOfReqMsg;
346 UINT_8 ucSeqNumOfChReq;
347 UINT_8 ucSeqNumOfScanReq;
349 UINT_32 u4ChGrantedInterval;
351 UINT_8 ucConnTrialCount;
353 UINT_8 ucScanSSIDLen;
354 UINT_8 aucScanSSID[ELEM_MAX_LEN_SSID];
356 UINT_32 u4ScanIELength;
357 UINT_8 aucScanIEBuf[MAX_IE_LENGTH];
359 /* Pending Request List */
360 LINK_T rPendingReqList;
362 } AIS_FSM_INFO_T, *P_AIS_FSM_INFO_T;
365 /*******************************************************************************
366 * P U B L I C D A T A
367 ********************************************************************************
370 /*******************************************************************************
371 * P R I V A T E D A T A
372 ********************************************************************************
375 /*******************************************************************************
377 ********************************************************************************
379 #define aisChangeMediaState(_prAdapter, _eNewMediaState) \
380 (_prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].eConnectionState = (_eNewMediaState));
383 /*******************************************************************************
384 * F U N C T I O N D E C L A R A T I O N S
385 ********************************************************************************
388 aisInitializeConnectionSettings (
389 IN P_ADAPTER_T prAdapter,
390 IN P_REG_INFO_T prRegInfo
395 IN P_ADAPTER_T prAdapter
400 IN P_ADAPTER_T prAdapter
404 aisFsmStateInit_JOIN (
405 IN P_ADAPTER_T prAdapter,
406 P_BSS_DESC_T prBssDesc
410 aisFsmStateInit_RetryJOIN (
411 IN P_ADAPTER_T prAdapter,
412 IN P_STA_RECORD_T prStaRec
416 aisFsmStateInit_IBSS_ALONE (
417 IN P_ADAPTER_T prAdapter
421 aisFsmStateInit_IBSS_MERGE (
422 IN P_ADAPTER_T prAdapter,
423 P_BSS_DESC_T prBssDesc
428 IN P_ADAPTER_T prAdapter,
429 UINT_8 ucReasonOfDisconnect,
430 BOOLEAN fgDelayIndication
434 aisFsmStateAbort_JOIN (
435 IN P_ADAPTER_T prAdapter
439 aisFsmStateAbort_SCAN (
440 IN P_ADAPTER_T prAdapter
444 aisFsmStateAbort_NORMAL_TR (
445 IN P_ADAPTER_T prAdapter
449 aisFsmStateAbort_IBSS (
450 IN P_ADAPTER_T prAdapter
455 IN P_ADAPTER_T prAdapter,
456 ENUM_AIS_STATE_T eNextState
459 /*----------------------------------------------------------------------------*/
460 /* Mailbox Message Handling */
461 /*----------------------------------------------------------------------------*/
463 aisFsmRunEventScanDone (
464 IN P_ADAPTER_T prAdapter,
465 IN P_MSG_HDR_T prMsgHdr
469 aisFsmRunEventAbort (
470 IN P_ADAPTER_T prAdapter,
471 IN P_MSG_HDR_T prMsgHdr
475 aisFsmRunEventJoinComplete (
476 IN P_ADAPTER_T prAdapter,
477 IN P_MSG_HDR_T prMsgHdr
481 aisFsmRunEventFoundIBSSPeer (
482 IN P_ADAPTER_T prAdapter,
483 IN P_MSG_HDR_T prMsgHdr
486 /*----------------------------------------------------------------------------*/
487 /* Handling for Ad-Hoc Network */
488 /*----------------------------------------------------------------------------*/
491 IN P_ADAPTER_T prAdapter
496 IN P_ADAPTER_T prAdapter,
497 IN P_STA_RECORD_T prStaRec
500 /*----------------------------------------------------------------------------*/
501 /* Handling of Incoming Mailbox Message from CNM */
502 /*----------------------------------------------------------------------------*/
504 aisFsmRunEventChGrant (
505 IN P_ADAPTER_T prAdapter,
506 IN P_MSG_HDR_T prMsgHdr
510 /*----------------------------------------------------------------------------*/
511 /* Generating Outgoing Mailbox Message to CNM */
512 /*----------------------------------------------------------------------------*/
515 IN P_ADAPTER_T prAdapter
519 /*----------------------------------------------------------------------------*/
520 /* Event Indication */
521 /*----------------------------------------------------------------------------*/
523 aisIndicationOfMediaStateToHost (
524 IN P_ADAPTER_T prAdapter,
525 ENUM_PARAM_MEDIA_STATE_T eConnectionState,
526 BOOLEAN fgDelayIndication
530 aisPostponedEventOfDisconnTimeout (
531 IN P_ADAPTER_T prAdapter,
536 aisUpdateBssInfoForJOIN (
537 IN P_ADAPTER_T prAdapter,
538 P_STA_RECORD_T prStaRec,
539 P_SW_RFB_T prAssocRspSwRfb
543 aisUpdateBssInfoForCreateIBSS (
544 IN P_ADAPTER_T prAdapter
548 aisUpdateBssInfoForMergeIBSS (
549 IN P_ADAPTER_T prAdapter,
550 IN P_STA_RECORD_T prStaRec
554 aisValidateProbeReq (
555 IN P_ADAPTER_T prAdapter,
556 IN P_SW_RFB_T prSwRfb,
557 OUT PUINT_32 pu4ControlFlags
560 /*----------------------------------------------------------------------------*/
561 /* Disconnection Handling */
562 /*----------------------------------------------------------------------------*/
565 IN P_ADAPTER_T prAdapter,
566 IN BOOLEAN fgDelayIndication
570 /*----------------------------------------------------------------------------*/
572 /*----------------------------------------------------------------------------*/
574 aisBssBeaconTimeout (
575 IN P_ADAPTER_T prAdapter
579 aisDeauthXmitComplete (
580 IN P_ADAPTER_T prAdapter,
581 IN P_MSDU_INFO_T prMsduInfo,
582 IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
585 #if CFG_SUPPORT_ROAMING
587 aisFsmRunEventRoamingDiscovery (
588 IN P_ADAPTER_T prAdapter,
593 aisFsmRoamingScanResultsUpdate (
594 IN P_ADAPTER_T prAdapter
598 aisFsmRoamingDisconnectPrevAP (
599 IN P_ADAPTER_T prAdapter,
600 IN P_STA_RECORD_T prTargetStaRec
604 aisUpdateBssInfoForRoamingAP (
605 IN P_ADAPTER_T prAdapter,
606 IN P_STA_RECORD_T prStaRec,
607 IN P_SW_RFB_T prAssocRspSwRfb
609 #endif /*CFG_SUPPORT_ROAMING */
611 /*----------------------------------------------------------------------------*/
612 /* Timeout Handling */
613 /*----------------------------------------------------------------------------*/
615 aisFsmRunEventBGSleepTimeOut (
616 IN P_ADAPTER_T prAdapter,
621 aisFsmRunEventIbssAloneTimeOut (
622 IN P_ADAPTER_T prAdapter,
627 aisFsmRunEventJoinTimeout (
628 IN P_ADAPTER_T prAdapter,
633 aisFsmRunEventScanDoneTimeOut (
634 IN P_ADAPTER_T prAdapter,
639 /*----------------------------------------------------------------------------*/
640 /* OID/IOCTL Handling */
641 /*----------------------------------------------------------------------------*/
644 IN P_ADAPTER_T prAdapter,
645 IN P_PARAM_SSID_T prSsid,
647 IN UINT_32 u4IeLength
650 /*----------------------------------------------------------------------------*/
651 /* Internal State Checking */
652 /*----------------------------------------------------------------------------*/
654 aisFsmIsRequestPending (
655 IN P_ADAPTER_T prAdapter,
656 IN ENUM_AIS_REQUEST_TYPE_T eReqType,
661 aisFsmGetNextRequest (
662 IN P_ADAPTER_T prAdapter
666 aisFsmInsertRequest (
667 IN P_ADAPTER_T prAdapter,
668 IN ENUM_AIS_REQUEST_TYPE_T eReqType
673 IN P_ADAPTER_T prAdapter
677 #if defined(CFG_TEST_MGMT_FSM) && (CFG_TEST_MGMT_FSM != 0)
682 #endif /* CFG_TEST_MGMT_FSM */
683 /*******************************************************************************
685 ********************************************************************************
688 #endif /* _AIS_FSM_H */