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.
16 ** 02 07 2014 yuche.tsai
17 ** [ALPS01425175] [6589][6628][KK][S5/Altai][W] MT6589 Roaming???20?, Pass Criteria?14?
18 ** Shorten Beacon Timeout indication time from 3 sec to 1 sec.
19 ** Shorten Disconnect indication time to supplicant from 10 sec to 2 sec.
21 ** MT6620 E3: 20140207_ALPS_WIFI_FW_MT6620E3_V1_19.
22 ** MT6628: 20140207_ALPS_WIFI_FW_MT6628_V1_30.
25 * [WCXRP00001120] [MT6620 Wi-Fi][Driver] Modify roaming to AIS state transition from synchronous to asynchronous approach to avoid incomplete state termination
26 * 1. change RDD related compile option brace position.
27 * 2. when roaming is triggered, ask AIS to transit immediately only when AIS is in Normal TR state without join timeout timer ticking
28 * 3. otherwise, insert AIS_REQUEST into pending request queue
31 * [WCXRP00000676] [MT6620 Wi-Fi][Driver] AIS to reduce request channel period from 5 seconds to 2 seconds
32 * channel interval for joining is shortened to 2 seconds to avoid interruption of concurrent operating network.
34 * 02 26 2011 tsaiyuan.hsu
35 * [WCXRP00000391] [MT6620 Wi-Fi][FW] Add Roaming Support
36 * not send disassoc or deauth to leaving AP so as to improve performace of roaming.
39 * [WCXRP00000487] [MT6620 Wi-Fi][Driver][AIS] Serve scan and connect request with a queue-based approach to improve response time for scanning request
40 * handle SCAN and RECONNECT with a FIFO approach.
42 * 01 27 2011 tsaiyuan.hsu
43 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
45 * 1. not support 11r, only use strength of signal to determine roaming.
46 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
47 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
48 * 4. assume that change of link quality in smooth way.
51 * [WCXRP00000359] [MT6620 Wi-Fi][Driver] add an extra state to ensure DEAUTH frame is always sent
52 * Add an extra state to guarantee DEAUTH frame is sent then connect to new BSS.
53 * This change is due to WAPI AP needs DEAUTH frame as a necessary step in handshaking protocol.
56 * [WCXRP00000208] [MT6620 Wi-Fi][Driver] Add scanning with specified SSID to AIS FSM
57 * add scanning with specified SSID facility to AIS-FSM
60 * [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
61 * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
62 * 2) Remove CNM CH-RECOVER event handling
63 * 3) cfg read/write API renamed with kal prefix for unified naming rules.
67 * 1) initialize for correct parameter even for disassociation.
68 * 2) AIS-FSM should have a limit on trials to build connection
70 * 09 03 2010 kevin.huang
72 * Refine #include sequence and solve recursive/nested #include issue
76 * [AIS-FSM] IBSS no longer needs to acquire channel for beaconing, RLM/CNM will handle the channel switching when BSS information is updated
78 * 08 12 2010 kevin.huang
80 * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
84 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
88 * surpress compilation warning.
92 * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
93 * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
94 * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
98 * AIS-FSM: when scan request is coming in the 1st 5 seconds of channel privilege period, just pend it til 5-sec. period finishes
102 * AIS-FSM FIX: return channel privilege even when the privilege is not granted yet
103 * QM: qmGetFrameAction() won't assert when corresponding STA-REC index is not found
107 * add AIS-FSM handling for beacon timeout event.
111 * separate AIS-FSM states into different cases of channel request.
115 * 1) change BG_SCAN to ONLINE_SCAN for consistent term
116 * 2) only clear scanning result when scan is permitted to do
120 * [WPD00003833] [MT6620 and MT5931] Driver migration.
121 * Add Ad-Hoc support to AIS-FSM
125 * [WPD00003833] [MT6620 and MT5931] Driver migration.
126 * Refine AIS-FSM by divided into more states
130 * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
131 * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
132 * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
136 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
139 * [WPD00003833][MT6620 and MT5931] Driver migration
140 * AIS-FSM integration with CNM channel request messages
143 * [WPD00003833][MT6620 and MT5931] Driver migration
144 * implementation of DRV-SCN and related mailbox message handling.
147 * [WPD00003833][MT6620 and MT5931] Driver migration
148 * add buildable & linkable ais_fsm.c
150 * related reference are still waiting to be resolved
153 * [WPD00003833][MT6620 and MT5931] Driver migration
154 * add definitions for module migration.
157 * [WPD00003833][MT6620 and MT5931] Driver migration
158 * add aa_fsm.h, ais_fsm.h, bss.h, mib.h and scan.h.
160 * 05 12 2010 kevin.huang
161 * [BORA00000794][WIFISYS][New Feature]Power Management Support
162 * Add Power Management - Legacy PS-POLL support.
165 * [BORA00000605][WIFISYS] Phase3 Integration
166 * reduce the backgroud ssid idle time min and max value
168 * 04 19 2010 kevin.huang
169 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
170 * Add Beacon Timeout Support
171 * * and will send Null frame to diagnose connection
173 * 03 16 2010 kevin.huang
174 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
177 * 03 10 2010 kevin.huang
178 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
180 * * Add Channel Manager for arbitration of JOIN and SCAN Req
182 * 02 26 2010 kevin.huang
183 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
184 * Remove CFG_TEST_VIRTUAL_CMD and add support of Driver STA_RECORD_T activation
186 * 02 23 2010 kevin.huang
187 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
188 * Support dynamic channel selection
190 * 02 04 2010 kevin.huang
191 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
192 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
194 * 01 11 2010 kevin.huang
195 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
196 * Add Deauth and Disassoc Handler
198 * 01 07 2010 kevin.huang
199 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
200 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
201 * Add Media disconnect indication and related postpone functions
203 * Dec 3 2009 mtk01461
204 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
205 * Add aisFsmRunEventJoinComplete()
207 * Nov 25 2009 mtk01461
208 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
209 * Add Virtual CMD & RESP for testing CMD PATH
211 * Nov 23 2009 mtk01461
212 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
213 * add aisFsmInitializeConnectionSettings()
215 * Nov 20 2009 mtk01461
216 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
217 * Add CFG_TEST_MGMT_FSM for aisFsmTest()
219 * Nov 18 2009 mtk01104
220 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
221 * Add function prototype of aisFsmInit()
223 * Nov 16 2009 mtk01461
224 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
231 /*******************************************************************************
232 * C O M P I L E R F L A G S
233 ********************************************************************************
236 /*******************************************************************************
237 * E X T E R N A L R E F E R E N C E S
238 ********************************************************************************
241 /*******************************************************************************
243 ********************************************************************************
245 #define AIS_BG_SCAN_INTERVAL_MIN_SEC 2 /* 30 // exponential to 960 */
246 #define AIS_BG_SCAN_INTERVAL_MAX_SEC 2 /* 960 // 16min */
248 #define AIS_DELAY_TIME_OF_DISCONNECT_SEC 2
250 #define AIS_IBSS_ALONE_TIMEOUT_SEC 20 /* seconds */
252 #define AIS_BEACON_TIMEOUT_COUNT_ADHOC 30
253 #define AIS_BEACON_TIMEOUT_COUNT_INFRA 10
254 #define AIS_BEACON_TIMEOUT_GUARD_TIME_SEC 1 /* Second */
256 #define AIS_BEACON_MAX_TIMEOUT_TU 100
257 #define AIS_BEACON_MIN_TIMEOUT_TU 5
258 #define AIS_BEACON_MAX_TIMEOUT_VALID TRUE
259 #define AIS_BEACON_MIN_TIMEOUT_VALID TRUE
261 #define AIS_BMC_MAX_TIMEOUT_TU 100
262 #define AIS_BMC_MIN_TIMEOUT_TU 5
263 #define AIS_BMC_MAX_TIMEOUT_VALID TRUE
264 #define AIS_BMC_MIN_TIMEOUT_VALID TRUE
266 #define AIS_JOIN_CH_GRANT_THRESHOLD 10
267 #define AIS_JOIN_CH_REQUEST_INTERVAL 2000
269 /*******************************************************************************
271 ********************************************************************************
273 typedef enum _ENUM_AIS_STATE_T
{
277 AIS_STATE_ONLINE_SCAN
,
278 AIS_STATE_LOOKING_FOR
,
279 AIS_STATE_WAIT_FOR_NEXT_SCAN
,
280 AIS_STATE_REQ_CHANNEL_JOIN
,
282 AIS_STATE_IBSS_ALONE
,
283 AIS_STATE_IBSS_MERGE
,
285 AIS_STATE_DISCONNECTING
,
290 typedef struct _MSG_AIS_ABORT_T
{
291 MSG_HDR_T rMsgHdr
; /* Must be the first member */
292 UINT_8 ucReasonOfDisconnect
;
293 BOOLEAN fgDelayIndication
;
294 } MSG_AIS_ABORT_T
, *P_MSG_AIS_ABORT_T
;
297 typedef struct _MSG_AIS_IBSS_PEER_FOUND_T
{
298 MSG_HDR_T rMsgHdr
; /* Must be the first member */
299 UINT_8 ucNetTypeIndex
;
300 BOOLEAN fgIsMergeIn
; /* TRUE: Merge In, FALSE: Merge Out */
301 P_STA_RECORD_T prStaRec
;
302 } MSG_AIS_IBSS_PEER_FOUND_T
, *P_MSG_AIS_IBSS_PEER_FOUND_T
;
304 typedef enum _ENUM_AIS_REQUEST_TYPE_T
{
306 AIS_REQUEST_RECONNECT
,
307 AIS_REQUEST_ROAMING_SEARCH
,
308 AIS_REQUEST_ROAMING_CONNECT
,
310 } ENUM_AIS_REQUEST_TYPE_T
;
312 typedef struct _AIS_REQ_HDR_T
{
313 LINK_ENTRY_T rLinkEntry
;
314 ENUM_AIS_REQUEST_TYPE_T eReqType
;
315 } AIS_REQ_HDR_T
, *P_AIS_REQ_HDR_T
;
318 typedef struct _AIS_FSM_INFO_T
{
319 ENUM_AIS_STATE_T ePreviousState
;
320 ENUM_AIS_STATE_T eCurrentState
;
324 BOOLEAN fgIsInfraChannelFinished
;
325 BOOLEAN fgIsChannelRequested
;
326 BOOLEAN fgIsChannelGranted
;
328 #if CFG_SUPPORT_ROAMING
329 BOOLEAN fgIsRoamingScanPending
;
330 #endif /* CFG_SUPPORT_ROAMING */
332 UINT_8 ucAvailableAuthTypes
; /* Used for AUTH_MODE_AUTO_SWITCH */
334 P_BSS_DESC_T prTargetBssDesc
; /* For destination */
336 P_STA_RECORD_T prTargetStaRec
; /* For JOIN Abort */
338 UINT_32 u4SleepInterval
;
340 TIMER_T rBGScanTimer
;
342 TIMER_T rIbssAloneTimer
;
344 TIMER_T rIndicationOfDisconnectTimer
;
346 TIMER_T rJoinTimeoutTimer
;
348 UINT_8 ucSeqNumOfReqMsg
;
349 UINT_8 ucSeqNumOfChReq
;
350 UINT_8 ucSeqNumOfScanReq
;
352 UINT_32 u4ChGrantedInterval
;
354 UINT_8 ucConnTrialCount
;
356 UINT_8 ucScanSSIDLen
;
357 UINT_8 aucScanSSID
[ELEM_MAX_LEN_SSID
];
359 UINT_32 u4ScanIELength
;
360 UINT_8 aucScanIEBuf
[MAX_IE_LENGTH
];
362 /* Pending Request List */
363 LINK_T rPendingReqList
;
365 } AIS_FSM_INFO_T
, *P_AIS_FSM_INFO_T
;
368 /*******************************************************************************
369 * P U B L I C D A T A
370 ********************************************************************************
373 /*******************************************************************************
374 * P R I V A T E D A T A
375 ********************************************************************************
378 /*******************************************************************************
380 ********************************************************************************
382 #define aisChangeMediaState(_prAdapter, _eNewMediaState) \
383 (_prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].eConnectionState = (_eNewMediaState));
386 /*******************************************************************************
387 * F U N C T I O N D E C L A R A T I O N S
388 ********************************************************************************
390 VOID
aisInitializeConnectionSettings(IN P_ADAPTER_T prAdapter
, IN P_REG_INFO_T prRegInfo
);
392 VOID
aisFsmInit(IN P_ADAPTER_T prAdapter
);
394 VOID
aisFsmUninit(IN P_ADAPTER_T prAdapter
);
396 VOID
aisFsmStateInit_JOIN(IN P_ADAPTER_T prAdapter
, P_BSS_DESC_T prBssDesc
);
398 BOOLEAN
aisFsmStateInit_RetryJOIN(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prStaRec
);
400 VOID
aisFsmStateInit_IBSS_ALONE(IN P_ADAPTER_T prAdapter
);
402 VOID
aisFsmStateInit_IBSS_MERGE(IN P_ADAPTER_T prAdapter
, P_BSS_DESC_T prBssDesc
);
405 aisFsmStateAbort(IN P_ADAPTER_T prAdapter
, UINT_8 ucReasonOfDisconnect
, BOOLEAN fgDelayIndication
);
407 VOID
aisFsmStateAbort_JOIN(IN P_ADAPTER_T prAdapter
);
409 VOID
aisFsmStateAbort_SCAN(IN P_ADAPTER_T prAdapter
);
411 VOID
aisFsmStateAbort_NORMAL_TR(IN P_ADAPTER_T prAdapter
);
413 VOID
aisFsmStateAbort_IBSS(IN P_ADAPTER_T prAdapter
);
415 VOID
aisFsmSteps(IN P_ADAPTER_T prAdapter
, ENUM_AIS_STATE_T eNextState
);
417 /*----------------------------------------------------------------------------*/
418 /* Mailbox Message Handling */
419 /*----------------------------------------------------------------------------*/
420 VOID
aisFsmRunEventScanDone(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
);
422 VOID
aisFsmRunEventAbort(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
);
424 VOID
aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
);
426 VOID
aisFsmRunEventFoundIBSSPeer(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
);
428 /*----------------------------------------------------------------------------*/
429 /* Handling for Ad-Hoc Network */
430 /*----------------------------------------------------------------------------*/
431 VOID
aisFsmCreateIBSS(IN P_ADAPTER_T prAdapter
);
433 VOID
aisFsmMergeIBSS(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prStaRec
);
435 /*----------------------------------------------------------------------------*/
436 /* Handling of Incoming Mailbox Message from CNM */
437 /*----------------------------------------------------------------------------*/
438 VOID
aisFsmRunEventChGrant(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
);
441 /*----------------------------------------------------------------------------*/
442 /* Generating Outgoing Mailbox Message to CNM */
443 /*----------------------------------------------------------------------------*/
444 VOID
aisFsmReleaseCh(IN P_ADAPTER_T prAdapter
);
447 /*----------------------------------------------------------------------------*/
448 /* Event Indication */
449 /*----------------------------------------------------------------------------*/
451 aisIndicationOfMediaStateToHost(IN P_ADAPTER_T prAdapter
,
452 ENUM_PARAM_MEDIA_STATE_T eConnectionState
,
453 BOOLEAN fgDelayIndication
);
455 VOID
aisPostponedEventOfDisconnTimeout(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
);
458 aisUpdateBssInfoForJOIN(IN P_ADAPTER_T prAdapter
,
459 P_STA_RECORD_T prStaRec
, P_SW_RFB_T prAssocRspSwRfb
);
461 VOID
aisUpdateBssInfoForCreateIBSS(IN P_ADAPTER_T prAdapter
);
463 VOID
aisUpdateBssInfoForMergeIBSS(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prStaRec
);
466 aisValidateProbeReq(IN P_ADAPTER_T prAdapter
, IN P_SW_RFB_T prSwRfb
, OUT PUINT_32 pu4ControlFlags
);
468 /*----------------------------------------------------------------------------*/
469 /* Disconnection Handling */
470 /*----------------------------------------------------------------------------*/
471 VOID
aisFsmDisconnect(IN P_ADAPTER_T prAdapter
, IN BOOLEAN fgDelayIndication
);
474 /*----------------------------------------------------------------------------*/
476 /*----------------------------------------------------------------------------*/
477 VOID
aisBssBeaconTimeout(IN P_ADAPTER_T prAdapter
);
480 aisDeauthXmitComplete(IN P_ADAPTER_T prAdapter
,
481 IN P_MSDU_INFO_T prMsduInfo
, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
);
483 #if CFG_SUPPORT_ROAMING
484 VOID
aisFsmRunEventRoamingDiscovery(IN P_ADAPTER_T prAdapter
, UINT_32 u4ReqScan
);
486 ENUM_AIS_STATE_T
aisFsmRoamingScanResultsUpdate(IN P_ADAPTER_T prAdapter
);
488 VOID
aisFsmRoamingDisconnectPrevAP(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prTargetStaRec
);
491 aisUpdateBssInfoForRoamingAP(IN P_ADAPTER_T prAdapter
,
492 IN P_STA_RECORD_T prStaRec
, IN P_SW_RFB_T prAssocRspSwRfb
);
493 #endif /*CFG_SUPPORT_ROAMING */
495 /*----------------------------------------------------------------------------*/
496 /* Timeout Handling */
497 /*----------------------------------------------------------------------------*/
498 VOID
aisFsmRunEventBGSleepTimeOut(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
);
500 VOID
aisFsmRunEventIbssAloneTimeOut(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
);
502 VOID
aisFsmRunEventJoinTimeout(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
);
504 /*----------------------------------------------------------------------------*/
505 /* OID/IOCTL Handling */
506 /*----------------------------------------------------------------------------*/
508 aisFsmScanRequest(IN P_ADAPTER_T prAdapter
,
509 IN P_PARAM_SSID_T prSsid
, IN PUINT_8 pucIe
, IN UINT_32 u4IeLength
);
511 /*----------------------------------------------------------------------------*/
512 /* Internal State Checking */
513 /*----------------------------------------------------------------------------*/
515 aisFsmIsRequestPending(IN P_ADAPTER_T prAdapter
,
516 IN ENUM_AIS_REQUEST_TYPE_T eReqType
, IN BOOLEAN bRemove
);
518 P_AIS_REQ_HDR_T
aisFsmGetNextRequest(IN P_ADAPTER_T prAdapter
);
520 BOOLEAN
aisFsmInsertRequest(IN P_ADAPTER_T prAdapter
, IN ENUM_AIS_REQUEST_TYPE_T eReqType
);
522 VOID
aisFsmFlushRequest(IN P_ADAPTER_T prAdapter
);
525 #if defined(CFG_TEST_MGMT_FSM) && (CFG_TEST_MGMT_FSM != 0)
527 #endif /* CFG_TEST_MGMT_FSM */
528 /*******************************************************************************
530 ********************************************************************************
533 #endif /* _AIS_FSM_H */