2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/ais_fsm.c#1 $
6 \brief This file defines the FSM for SAA and AAA MODULE.
8 This file defines the FSM for SAA and AAA MODULE.
17 ** [ALPS00382763] N820_JB:[WIFI]N820JB WLAN ±K???,«ÝÉó?¬y¥\¯Ó¤j
18 ** do not try reconnecting when being disconnected by the peer
21 * [WCXRP00000913] [MT6620 Wi-Fi] create repository of source code dedicated for MT6620 E6 ASIC
25 * [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band configuration with corresponding network configuration
26 * add wlanSetPreferBandByNetwork() for glue layer to invoke for setting preferred band configuration corresponding to network type.
29 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
30 * Adjust code for DBG and CONFIG_XLOG.
33 * [WCXRP00001120] [MT6620 Wi-Fi][Driver] Modify roaming to AIS state transition from synchronous to asynchronous approach to avoid incomplete state termination
34 * 1. change RDD related compile option brace position.
35 * 2. when roaming is triggered, ask AIS to transit immediately only when AIS is in Normal TR state without join timeout timer ticking
36 * 3. otherwise, insert AIS_REQUEST into pending request queue
39 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
40 * modify the xlog related code.
43 * [WCXRP00001086] [MT6620 Wi-Fi][Driver] On Android, indicate an extra DISCONNECT for REASSOCIATED cases as an explicit trigger for Android framework
44 * correct reference to BSSID field in Association-Response frame.
47 * [WCXRP00001086] [MT6620 Wi-Fi][Driver] On Android, indicate an extra DISCONNECT for REASSOCIATED cases as an explicit trigger for Android framework
48 * 1. for DEAUTH/DISASSOC cases, indicate for DISCONNECTION immediately.
49 * 2. (Android only) when reassociation-and-non-roaming cases happened, indicate an extra DISCONNECT indication to Android Wi-Fi framework
52 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
53 * adding the code for XLOG.
55 * 10 26 2011 tsaiyuan.hsu
56 * [WCXRP00001064] [MT6620 Wi-Fi][DRV]] add code with roaming awareness when disconnecting AIS network
57 * be aware roaming when disconnecting AIS network.
60 * [WCXRP00001058] [All Wi-Fi][Driver] Fix sta_rec's phyTypeSet and OBSS scan in AP mode
61 * STA_REC shall be NULL for Beacon's MSDU
64 * [MT6620 Wi-Fi][Driver] Reduce join failure count limit to 2 for faster re-join for other BSS
65 * 1. short join failure count limit to 2
66 * 2. treat join timeout as kind of join failure as well
69 * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
70 * adding the 802.11w related function and define .
73 * [WCXRP00001020] [MT6620 Wi-Fi][Driver] Handle secondary channel offset of AP in 5GHz band
76 * 09 20 2011 tsaiyuan.hsu
77 * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
78 * change window registry of driver for roaming.
81 * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
82 * Handle client mode about preamble type and slot time
84 * 09 08 2011 tsaiyuan.hsu
85 * [WCXRP00000972] [MT6620 Wi-Fi][DRV]] check if roaming occurs after join failure to avoid state incosistence.
86 * check if roaming occurs after join failure to avoid deactivation of network.
88 * 08 24 2011 chinghwa.yu
89 * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
90 * Update RDD test mode cases.
92 * 08 16 2011 tsaiyuan.hsu
93 * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
94 * EnableRoaming in registry is deprecated.
96 * 08 16 2011 tsaiyuan.hsu
97 * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
98 * use registry to enable or disable roaming.
101 * [WCXRP00000840] [MT6620 Wi-Fi][Driver][AIS] Stop timer for joining when channel is released due to join failure count exceeding limit
102 * stop timer when joining operation is failed due to try count exceeds limitation
105 * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky AP which use space character as hidden SSID
106 * do not handle SCAN request immediately after connected to increase the probability of receiving 1st beacon frame.
109 * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
110 * change parameter name from PeerAddr to BSSID
113 * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
114 * 1. specify target's BSSID when requesting channel privilege.
115 * 2. pass BSSID information to firmware domain
118 * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
119 * ensure DEAUTH is always sent before establish a new connection
122 * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
123 * typo fix: a right brace is missed.
126 * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
127 * When RECONNECT request is identified as disconnected, it is necessary to check for pending scan request.
130 * [WCXRP00000757] [MT6620 Wi-Fi][Driver][SCN] take use of RLM API to filter out BSS in disallowed channels
131 * mark fgIsTransition as TRUE for state rolling.
134 * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
135 * always check for pending scan after switched into NORMAL_TR state.
138 * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
139 * always treat connection request at higher priority over scanning request
141 * 06 09 2011 tsaiyuan.hsu
142 * [WCXRP00000760] [MT5931 Wi-Fi][FW] Refine rxmHandleMacRxDone to reduce code size
143 * move send_auth at rxmHandleMacRxDone in firmware to driver to reduce code size.
146 * [WCXRP00000681] [MT5931][Firmware] HIF code size reduction
147 * eliminate unused parameters for SAA-FSM
150 * [WCXRP00000732] [MT6620 Wi-Fi][AIS] No need to switch back to IDLE state when DEAUTH frame is dropped due to bss disconnection
151 * change SCAN handling behavior when followed by a CONNECT/DISCONNECT requests by pending instead of dropping.
154 * [WCXRP00000732] [MT6620 Wi-Fi][AIS] No need to switch back to IDLE state when DEAUTH frame is dropped due to bss disconnection
155 * when TX DONE status is TX_RESULT_DROPPED_IN_DRIVER, no need to switch back to IDLE state.
157 * 04 14 2011 cm.chang
158 * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
161 * 04 13 2011 george.huang
162 * [WCXRP00000628] [MT6620 Wi-Fi][FW][Driver] Modify U-APSD setting to default OFF
166 * [WCXRP00000575] [MT6620 Wi-Fi][Driver][AIS] reduce memory usage when generating mailbox message for scan request
167 * when there is no IE needed for probe request, then request a smaller memory for mailbox message
169 * 03 17 2011 chinglan.wang
170 * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
173 * 03 17 2011 chinglan.wang
174 * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
177 * 03 16 2011 tsaiyuan.hsu
178 * [WCXRP00000517] [MT6620 Wi-Fi][Driver][FW] Fine Tune Performance of Roaming
179 * remove obsolete definition and unused variables.
182 * [WCXRP00000535] [MT6620 Wi-Fi][Driver] Fixed channel operation when AIS and Tethering are operating concurrently
183 * When fixed channel operation is necessary, AIS-FSM would scan and only connect for BSS on the specific channel
185 * 03 09 2011 tsaiyuan.hsu
186 * [WCXRP00000517] [MT6620 Wi-Fi][Driver][FW] Fine Tune Performance of Roaming
187 * avoid clearing fgIsScanReqIssued so as to add scan results.
189 * 03 07 2011 terry.wu
190 * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
191 * Toggle non-standard debug messages to comments.
193 * 03 04 2011 tsaiyuan.hsu
194 * [WCXRP00000517] [MT6620 Wi-Fi][Driver][FW] Fine Tune Performance of Roaming
195 * reset retry conter of attemp to connect to ap after completion of join.
198 * [WCXRP00000515] [MT6620 Wi-Fi][Driver] Surpress compiler warning which is identified by GNU compiler collection
199 * surpress compile warning occured when compiled by GNU compiler collection.
202 * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after connection is built.
203 * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
205 * 02 26 2011 tsaiyuan.hsu
206 * [WCXRP00000391] [MT6620 Wi-Fi][FW] Add Roaming Support
207 * not send disassoc or deauth to leaving AP so as to improve performace of roaming.
210 * [WCXRP00000487] [MT6620 Wi-Fi][Driver][AIS] Serve scan and connect request with a queue-based approach to improve response time for scanning request
211 * when handling reconnect request, set fgTryScan as TRUE
214 * [WCXRP00000487] [MT6620 Wi-Fi][Driver][AIS] Serve scan and connect request with a queue-based approach to improve response time for scanning request
215 * handle SCAN and RECONNECT with a FIFO approach.
217 * 02 09 2011 tsaiyuan.hsu
218 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
219 * Check if prRegInfo is null or not before initializing roaming parameters.
222 * [WCXRP00000416] [MT6620 Wi-Fi][Driver] treat "unable to find BSS" as connection trial to prevent infinite reconnection trials
223 * treat "unable to find BSS" as connection trial to prevent infinite reconnection trials.
225 * 01 27 2011 tsaiyuan.hsu
226 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
228 * 1. not support 11r, only use strength of signal to determine roaming.
229 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
230 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
231 * 4. assume that change of link quality in smooth way.
233 * 01 26 2011 yuche.tsai
234 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
237 * 01 25 2011 yuche.tsai
238 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
239 * Fix Compile Error when DBG is disabled.
241 * 01 25 2011 yuche.tsai
242 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
243 * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
246 * [WCXRP00000359] [MT6620 Wi-Fi][Driver] add an extra state to ensure DEAUTH frame is always sent
247 * Add an extra state to guarantee DEAUTH frame is sent then connect to new BSS.
248 * This change is due to WAPI AP needs DEAUTH frame as a necessary step in handshaking protocol.
251 * [WCXRP00000307] [MT6620 Wi-Fi][SQA]WHQL test .2c_wlan_adhoc case fail.
252 * [IBSS] when merged in, the bss state should be updated to firmware to pass WHQL adhoc failed item
255 * [WCXRP00000351] [MT6620 Wi-Fi][Driver] remove from scanning result in OID handling layer when the corresponding BSS is disconnected due to beacon timeout
256 * remove from scanning result when the BSS is disconnected due to beacon timeout.
259 * [WCXRP00000337] [MT6620 Wi-FI][Driver] AIS-FSM not to invoke cnmStaRecResetStatus directly 'cause it frees all belonging STA-RECs
260 * do not invoke cnmStaRecResetStatus() directly, nicUpdateBss will do the things after bss is disconnected
263 * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
264 * do not need to manipulate prStaRec after indicating BSS disconnection to firmware, 'cause all STA-RECs belongs to BSS has been freed already
267 * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
268 * add DEBUGFUNC() macro invoking for more detailed debugging information
270 * 12 23 2010 george.huang
271 * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
272 * 1. update WMM IE parsing, with ASSOC REQ handling
273 * 2. extend U-APSD parameter passing from driver to FW
276 * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
277 * before BSS disconnection is indicated to firmware, all correlated peer should be cleared and freed
279 * 12 07 2010 cm.chang
280 * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
281 * 1. BSSINFO include RLM parameter
282 * 2. free all sta records when network is disconnected
284 * 11 25 2010 yuche.tsai
286 * Update SLT Function for QoS Support and not be affected by fixed rate function.
289 * [WCXRP00000208] [MT6620 Wi-Fi][Driver] Add scanning with specified SSID to AIS FSM
290 * add scanning with specified SSID facility to AIS-FSM
293 * [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
294 * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
295 * 2) Remove CNM CH-RECOVER event handling
296 * 3) cfg read/write API renamed with kal prefix for unified naming rules.
299 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000137] [MT6620 Wi-Fi] [FW] Support NIC capability query command
300 * 1) update NVRAM content template to ver 1.02
301 * 2) add compile option for querying NIC capability (default: off)
302 * 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
303 * 4) correct auto-rate compiler error under linux (treat warning as error)
304 * 5) simplify usage of NVRAM and REG_INFO_T
305 * 6) add version checking between driver and firmware
308 * [WCXRP00000097] [MT6620 Wi-Fi] [Driver] Fixed the P2P not setting the fgIsChannelExt value make scan not abort
309 * initial the fgIsChannelExt value.
312 * [WCXRP00000087] [MT6620 Wi-Fi][Driver] Cannot connect to 5GHz AP, driver will cause FW assert.
313 * correct erroneous logic: specifying eBand with incompatible eSco
316 * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by ENUM_NETWORK_TYPE_INDEX_T only
317 * remove ENUM_NETWORK_TYPE_T definitions
319 * 09 27 2010 chinghwa.yu
320 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
321 * Update BCM/BoW design and settings.
324 * [WCXRP00000049] [MT6620 Wi-Fi][Driver] Adhoc cannot be created successfully.
325 * keep IBSS-ALONE state retrying until further instruction is received
328 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
329 * Do a complete reset with STA-REC null checking for RF test re-entry
331 * 09 09 2010 yuche.tsai
333 * Fix NULL IE Beacon issue. Sync Beacon Content to FW before enable beacon.
334 * Both in IBSS Create & IBSS Merge
338 * frequency is in unit of KHz thus no need to divide 1000 once more.
342 * 1) initialize for correct parameter even for disassociation.
343 * 2) AIS-FSM should have a limit on trials to build connection
345 * 09 03 2010 kevin.huang
347 * Refine #include sequence and solve recursive/nested #include issue
351 * eliminate klockwork errors
353 * 08 29 2010 yuche.tsai
355 * Finish SLT TX/RX & Rate Changing Support.
359 * add option for enabling AIS 5GHz scan
363 * [AIS-FSM] IBSS no longer needs to acquire channel for beaconing, RLM/CNM will handle the channel switching when BSS information is updated
365 * 08 25 2010 george.huang
367 * update OID/ registry control path for PM related settings
369 * 08 24 2010 cm.chang
371 * Support RLM initail channel of Ad-hoc, P2P and BOW
373 * 08 20 2010 cm.chang
375 * Migrate RLM code to host from FW
379 * check-in missed files.
381 * 08 12 2010 kevin.huang
383 * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
387 * reset fgIsScanReqIssued when abort request is received right after join completion.
391 * surpress compilation warning.
395 * comment out deprecated members in BSS_INFO, which are only used by firmware rather than driver.
399 * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
400 * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
401 * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
405 * eliminate u4FreqInKHz usage, combined into rConnections.ucAdHoc*
409 * allocate on MGMT packet for IBSS beaconing.
413 * [AIS-FSM] fix: when join failed, release channel privilege as well
417 * reuse join-abort sub-procedure to reduce code size.
421 * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
422 * 2) change nicMediaStateChange() API prototype
426 * AIS-FSM: when scan request is coming in the 1st 5 seconds of channel privilege period, just pend it til 5-sec. period finishes
430 * AIS-FSM FIX: return channel privilege even when the privilege is not granted yet
431 * QM: qmGetFrameAction() won't assert when corresponding STA-REC index is not found
435 * re-commit code logic being overwriten.
439 * .support the Wi-Fi RSN
443 * 1) re-enable AIS-FSM beacon timeout handling.
444 * 2) scan done API revised
449 * 2) disable beacon timeout handling temporally due to unexpected beacon timeout event.
453 * indicate scan done for linux wireless extension
457 * add AIS-FSM handling for beacon timeout event.
461 * 1) refine AIS-FSM indent.
462 * 2) when entering RF Test mode, flush 802.1X frames as well
463 * 3) when entering D3 state, flush 802.1X frames as well
467 * separate AIS-FSM states into different cases of channel request.
471 * 1) change BG_SCAN to ONLINE_SCAN for consistent term
472 * 2) only clear scanning result when scan is permitted to do
476 * 1) [AIS] when new scan is issued, clear currently available scanning result except the connected one
477 * 2) refine disconnection behaviour when issued during BG-SCAN process
481 * 1) bugfix: do not stop timer for join after switched into normal_tr state, for providing chance for DHCP handshasking
482 * 2) modify rsnPerformPolicySelection() invoking
486 * 1) init AIS_BSS_INFO as channel number = 1 with band = 2.4GHz
491 * update for security supporting.
495 * [WPD00003833] [MT6620 and MT5931] Driver migration.
496 * when IBSS is being merged-in, send command packet to PM for connected indication
500 * [WPD00003833] [MT6620 and MT5931] Driver migration.
501 * Add Ad-Hoc support to AIS-FSM
503 * 07 19 2010 jeffrey.chang
505 * Linux port modification
509 * [WPD00003833] [MT6620 and MT5931] Driver migration.
510 * bugfix for SCN migration
511 * 1) modify QUEUE_CONCATENATE_QUEUES() so it could be used to concatence with an empty queue
512 * 2) before AIS issues scan request, network(BSS) needs to be activated first
513 * 3) only invoke COPY_SSID when using specified SSID for scan
517 * [WPD00003833] [MT6620 and MT5931] Driver migration.
518 * for AIS scanning, driver specifies no extra IE for probe request
522 * [WPD00003833] [MT6620 and MT5931] Driver migration.
523 * driver no longer generates probe request frames
525 * 07 14 2010 yarco.yang
527 * Remove CFG_MQM_MIGRATION
531 * [WPD00003833] [MT6620 and MT5931] Driver migration.
532 * Refine AIS-FSM by divided into more states
534 * 07 13 2010 cm.chang
536 * Rename MSG_CH_RELEASE_T to MSG_CH_ABORT_T
540 * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
541 * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
542 * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
544 * 07 09 2010 george.huang
546 * [WPD00001556] Migrate PM variables from FW to driver: for composing QoS Info
550 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
553 * [WPD00003833][MT6620 and MT5931] Driver migration
554 * take use of RLM module for parsing/generating HT IEs for 11n capability
556 * 07 08 2010 cm.chang
557 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
558 * Rename MID_MNY_CNM_CH_RELEASE to MID_MNY_CNM_CH_ABORT
561 * [WPD00003833][MT6620 and MT5931] Driver migration
562 * for first connection, if connecting failed do not enter into scan state.
565 * [WPD00003833][MT6620 and MT5931] Driver migration
566 * once STA-REC is allocated and updated, invoke cnmStaRecChangeState() to sync. with firmware.
568 * 07 06 2010 george.huang
569 * [WPD00001556]Basic power managemenet function
570 * Update arguments for nicUpdateBeaconIETemplate()
573 * [WPD00003833][MT6620 and MT5931] Driver migration
574 * STA-REC is maintained by CNM only.
577 * [WPD00003833][MT6620 and MT5931] Driver migration
578 * remove unused definitions.
581 * [WPD00003833][MT6620 and MT5931] Driver migration
582 * AIS-FSM integration with CNM channel request messages
585 * [WPD00003833][MT6620 and MT5931] Driver migration
586 * implementation of DRV-SCN and related mailbox message handling.
589 * [WPD00003833][MT6620 and MT5931] Driver migration
590 * sync. with CMD/EVENT document ver0.07.
593 * [WPD00003833][MT6620 and MT5931] Driver migration
594 * 1) sync to. CMD/EVENT document v0.03
595 * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
596 * 3) send command packet to indicate FW-PM after
597 * a) 1st beacon is received after AIS has connected to an AP
598 * b) IBSS-ALONE has been created
599 * c) IBSS-MERGE has occured
602 * [WPD00003833][MT6620 and MT5931] Driver migration
603 * modify Beacon/ProbeResp to complete parsing,
604 * because host software has looser memory usage restriction
607 * [WPD00003833][MT6620 and MT5931] Driver migration
611 * [WPD00003833][MT6620 and MT5931] Driver migration
612 * comment out RLM APIs by CFG_RLM_MIGRATION.
615 * [WPD00003833][MT6620 and MT5931] Driver migration
616 * 1) add command warpper for STA-REC/BSS-INFO sync.
617 * 2) enhance command packet sending procedure for non-oid part
618 * 3) add command packet definitions for STA-REC/BSS-INFO sync.
620 * 06 21 2010 yarco.yang
621 * [WPD00003837][MT6620]Data Path Refine
622 * Support CFG_MQM_MIGRATION flag
625 * [WPD00003833][MT6620 and MT5931] Driver migration
626 * add scan_fsm into building.
629 * [WPD00003833][MT6620 and MT5931] Driver migration
630 * RSN/PRIVACY compilation flag awareness correction
632 * 06 18 2010 cm.chang
633 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
634 * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
637 * [WPD00003840][MT6620 5931] Security migration
638 * migration from MT6620 firmware.
641 * [WPD00003833][MT6620 and MT5931] Driver migration
645 * [WPD00003833][MT6620 and MT5931] Driver migration
646 * restore utility function invoking via hem_mbox to direct calls
649 * [WPD00003833][MT6620 and MT5931] Driver migration
650 * auth.c is migrated.
653 * [WPD00003833][MT6620 and MT5931] Driver migration
657 * [WPD00003833][MT6620 and MT5931] Driver migration
658 * 1) migrate assoc.c.
659 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
660 * 3) add configuration options for CNM_MEM and RSN modules
661 * 4) add data path for management frames
662 * 5) eliminate rPacketInfo of MSDU_INFO_T
665 * [WPD00003833][MT6620 and MT5931] Driver migration
666 * change to enqueue TX frame infinitely.
669 * [WPD00003833][MT6620 and MT5931] Driver migration
670 * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
671 * 2) when disconnected, indicate nic directly (no event is needed)
674 * [WPD00003833][MT6620 and MT5931] Driver migration
675 * add buildable & linkable ais_fsm.c
677 * related reference are still waiting to be resolved
679 * 06 01 2010 cm.chang
680 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
681 * Add conditionial compiling flag to choose default available bandwidth
683 * 05 28 2010 kevin.huang
684 * [BORA00000794][WIFISYS][New Feature]Power Management Support
685 * Add ClientList handling API - bssClearClientList, bssAddStaRecToClientList
687 * 05 24 2010 kevin.huang
688 * [BORA00000794][WIFISYS][New Feature]Power Management Support
689 * Refine authSendAuthFrame() for NULL STA_RECORD_T case and minimum deauth interval.
691 * 05 21 2010 kevin.huang
692 * [BORA00000794][WIFISYS][New Feature]Power Management Support
693 * Fix compile error if CFG_CMD_EVENT_VER_009 == 0 for prEventConnStatus->ucNetworkType.
695 * 05 21 2010 kevin.huang
696 * [BORA00000794][WIFISYS][New Feature]Power Management Support
697 * Refine txmInitWtblTxRateTable() - set TX initial rate according to AP's operation rate set
699 * 05 17 2010 kevin.huang
700 * [BORA00000794][WIFISYS][New Feature]Power Management Support
701 * Call pmAbort() and add ucNetworkType field in EVENT_CONNECTION_STATUS
703 * 05 14 2010 kevin.huang
704 * [BORA00000794][WIFISYS][New Feature]Power Management Support
705 * Fix compile warning - define of MQM_WMM_PARSING was removed
707 * 05 12 2010 kevin.huang
708 * [BORA00000794][WIFISYS][New Feature]Power Management Support
709 * Add Power Management - Legacy PS-POLL support.
711 * 04 28 2010 tehuang.liu
712 * [BORA00000605][WIFISYS] Phase3 Integration
713 * Removed the use of compiling flag MQM_WMM_PARSING
715 * 04 27 2010 kevin.huang
716 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
720 * 04 27 2010 kevin.huang
721 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
722 * Add Set Slot Time and Beacon Timeout Support for AdHoc Mode
724 * 04 19 2010 kevin.huang
725 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
726 * Add Send Deauth for Class 3 Error and Leave Network Support
729 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
730 * fixed the protected bit at cap info for ad-hoc.
732 * 04 13 2010 kevin.huang
733 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
734 * Add new HW CH macro support
736 * 04 07 2010 chinghwa.yu
737 * [BORA00000563]Add WiFi CoEx BCM module
738 * Add TX Power Control RCPI function.
741 * [BORA00000605][WIFISYS] Phase3 Integration
742 * move the wlan table alloc / free to change state function.
745 * [BORA00000676][MT6620] Support the frequency setting and query at build connection / connection event
746 * modify the build connection and status event structure bu CMD_EVENT doc 0.09 draft, default is disable.
749 * [BORA00000605][WIFISYS] Phase3 Integration
750 * fixed some WHQL testing error.
752 * 03 24 2010 kevin.huang
753 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
754 * Add Set / Unset POWER STATE in AIS Network
756 * 03 16 2010 kevin.huang
757 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
760 * 03 10 2010 kevin.huang
761 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
762 * Add Channel Manager for arbitration of JOIN and SCAN Req
764 * 03 03 2010 kevin.huang
765 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
766 * Add PHY_CONFIG to change Phy Type
768 * 03 03 2010 chinghwa.yu
769 * [BORA00000563]Add WiFi CoEx BCM module
770 * Use bcmWiFiNotify to replace wifi_send_msg to pass infomation to BCM module.
772 * 03 03 2010 chinghwa.yu
773 * [BORA00000563]Add WiFi CoEx BCM module
774 * Remove wmt_task definition and add PTA function.
776 * 03 02 2010 tehuang.liu
777 * [BORA00000569][WIFISYS] Phase 2 Integration Test
778 * Init TXM and MQM testing procedures in aisFsmRunEventJoinComplete()
780 * 03 01 2010 tehuang.liu
781 * [BORA00000569][WIFISYS] Phase 2 Integration Test
782 * Modified aisUpdateBssInfo() to call TXM's functions for setting WTBL TX parameters
785 * [BORA00000605][WIFISYS] Phase3 Integration
786 * clear the pmkid cache while indicate media disconnect.
788 * 02 26 2010 tehuang.liu
789 * [BORA00000569][WIFISYS] Phase 2 Integration Test
792 * 02 26 2010 tehuang.liu
793 * [BORA00000569][WIFISYS] Phase 2 Integration Test
794 * Enabled MQM parsing WMM IEs for non-AP mode
796 * 02 26 2010 kevin.huang
797 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
798 * Remove CFG_TEST_VIRTUAL_CMD and add support of Driver STA_RECORD_T activation
801 * [BORA00000605][WIFISYS] Phase3 Integration
802 * use the Rx0 dor event indicate.
804 * 02 23 2010 kevin.huang
805 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
806 * Support dynamic channel selection
809 * [BORA00000621][MT6620 Wi-Fi] Add the RSSI indicate to avoid XP stalled for query rssi value
810 * Adding the RSSI event support, using the HAL function to get the rcpi value and tranlsate to RSSI and indicate to driver
812 * 02 12 2010 cm.chang
813 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
814 * Use bss info array for concurrent handle
816 * 02 05 2010 kevin.huang
817 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
818 * Revise data structure to share the same BSS_INFO_T for avoiding coding error
820 * 02 04 2010 kevin.huang
821 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
822 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
824 * 01 27 2010 tehuang.liu
825 * [BORA00000569][WIFISYS] Phase 2 Integration Test
826 * Set max AMDPU size supported by the peer to 64 KB, removed mqmInit() and mqmTxSendAddBaReq() function calls in aisUpdateBssInfo()
829 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
830 * add and fixed some security function.
832 * 01 22 2010 cm.chang
833 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
834 * Support protection and bandwidth switch
836 * 01 20 2010 kevin.huang
837 * [BORA00000569][WIFISYS] Phase 2 Integration Test
838 * Add PHASE_2_INTEGRATION_WORK_AROUND and CFG_SUPPORT_BCM flags
840 * 01 15 2010 tehuang.liu
841 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
842 * Configured the AMPDU factor to 3 for the APu1rwduu`wvpghlqg|q`mpdkb+ilp
844 * 01 14 2010 chinghwa.yu
845 * [BORA00000563]Add WiFi CoEx BCM module
846 * Add WiFi BCM module for the 1st time.
848 * 01 11 2010 kevin.huang
849 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
850 * Add Deauth and Disassoc Handler
852 * 01 07 2010 kevin.huang
853 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
854 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
856 * Refine JOIN Complete and seperate the function of Media State indication
858 * 01 04 2010 tehuang.liu
859 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
860 * For working out the first connection Chariot-verified version
862 * 12 18 2009 cm.chang
863 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
866 * Dec 10 2009 mtk01088
867 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
868 * adding the sample code to update the wlan table rate,
870 * Dec 10 2009 mtk01104
871 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
872 * Different function prototype of wifi_send_msg()
874 * Dec 9 2009 mtk01104
875 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
876 * Call rlm related function to process HT info when join complete
878 * Dec 9 2009 mtk01088
879 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
880 * default the acquired wlan table entry code off
882 * Dec 9 2009 mtk01088
883 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
884 * adding the code to acquired the wlan table entry, and a sample code to update the BA bit at table
886 * Dec 7 2009 mtk01461
887 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
888 * Fix the problem of prSwRfb overwrited by event packet in aisFsmRunEventJoinComplete()
890 * Dec 4 2009 mtk01088
891 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
892 * adding the code to integrate the security related code
894 * Dec 3 2009 mtk01461
895 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
896 * Remove redundant declaration
898 * Dec 3 2009 mtk01461
899 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
900 * Add code for JOIN init and JOIN complete
902 * Nov 30 2009 mtk01461
903 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
904 * Rename u4RSSI to i4RSSI
906 * Nov 30 2009 mtk01461
907 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
908 * Revise ENUM_MEDIA_STATE to ENUM_PARAM_MEDIA_STATE
910 * Nov 30 2009 mtk01461
911 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
912 * Add fgIsScanReqIssued to CONNECTION_SETTINGS_T
914 * Nov 26 2009 mtk01461
915 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
916 * Revise Virtual CMD handler due to structure changed
918 * Nov 25 2009 mtk01461
919 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
920 * Add Virtual CMD & RESP for testing CMD PATH
922 * Nov 23 2009 mtk01461
923 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
924 * Add aisFsmInitializeConnectionSettings()
926 * Nov 20 2009 mtk01461
927 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
928 * Add CFG_TEST_MGMT_FSM flag for aisFsmTest()
930 * Nov 16 2009 mtk01461
931 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
935 /*******************************************************************************
936 * C O M P I L E R F L A G S
937 ********************************************************************************
940 /*******************************************************************************
941 * E X T E R N A L R E F E R E N C E S
942 ********************************************************************************
946 /*******************************************************************************
948 ********************************************************************************
950 #define AIS_ROAMING_CONNECTION_TRIAL_LIMIT 2
952 /*******************************************************************************
954 ********************************************************************************
957 /*******************************************************************************
958 * P U B L I C D A T A
959 ********************************************************************************
962 /*******************************************************************************
963 * P R I V A T E D A T A
964 ********************************************************************************
967 /*lint -save -e64 Type mismatch */
968 static PUINT_8 apucDebugAisState
[AIS_STATE_NUM
] = {
969 (PUINT_8
) DISP_STRING("AIS_STATE_IDLE"),
970 (PUINT_8
) DISP_STRING("AIS_STATE_SEARCH"),
971 (PUINT_8
) DISP_STRING("AIS_STATE_SCAN"),
972 (PUINT_8
) DISP_STRING("AIS_STATE_ONLINE_SCAN"),
973 (PUINT_8
) DISP_STRING("AIS_STATE_LOOKING_FOR"),
974 (PUINT_8
) DISP_STRING("AIS_STATE_WAIT_FOR_NEXT_SCAN"),
975 (PUINT_8
) DISP_STRING("AIS_STATE_REQ_CHANNEL_JOIN"),
976 (PUINT_8
) DISP_STRING("AIS_STATE_JOIN"),
977 (PUINT_8
) DISP_STRING("AIS_STATE_IBSS_ALONE"),
978 (PUINT_8
) DISP_STRING("AIS_STATE_IBSS_MERGE"),
979 (PUINT_8
) DISP_STRING("AIS_STATE_NORMAL_TR"),
980 (PUINT_8
) DISP_STRING("AIS_STATE_DISCONNECTING")
986 /*******************************************************************************
988 ********************************************************************************
991 /*******************************************************************************
992 * F U N C T I O N D E C L A R A T I O N S
993 ********************************************************************************
996 /*******************************************************************************
998 ********************************************************************************
1000 /*----------------------------------------------------------------------------*/
1002 * @brief the function is used to initialize the value of the connection settings for
1009 /*----------------------------------------------------------------------------*/
1010 VOID
aisInitializeConnectionSettings(IN P_ADAPTER_T prAdapter
, IN P_REG_INFO_T prRegInfo
)
1012 P_CONNECTION_SETTINGS_T prConnSettings
;
1013 UINT_8 aucAnyBSSID
[] = BC_BSSID
;
1014 UINT_8 aucZeroMacAddr
[] = NULL_MAC_ADDR
;
1017 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
1019 /* Setup default values for operation */
1020 COPY_MAC_ADDR(prConnSettings
->aucMacAddress
, aucZeroMacAddr
);
1022 prConnSettings
->ucDelayTimeOfDisconnectEvent
= AIS_DELAY_TIME_OF_DISCONNECT_SEC
;
1024 COPY_MAC_ADDR(prConnSettings
->aucBSSID
, aucAnyBSSID
);
1025 prConnSettings
->fgIsConnByBssidIssued
= FALSE
;
1027 prConnSettings
->fgIsConnReqIssued
= FALSE
;
1028 prConnSettings
->fgIsDisconnectedByNonRequest
= FALSE
;
1030 prConnSettings
->ucSSIDLen
= 0;
1032 prConnSettings
->eOPMode
= NET_TYPE_INFRA
;
1034 prConnSettings
->eConnectionPolicy
= CONNECT_BY_SSID_BEST_RSSI
;
1037 prConnSettings
->ucAdHocChannelNum
=
1038 (UINT_8
) nicFreq2ChannelNum(prRegInfo
->u4StartFreq
);
1039 prConnSettings
->eAdHocBand
= prRegInfo
->u4StartFreq
< 5000000 ? BAND_2G4
: BAND_5G
;
1040 prConnSettings
->eAdHocMode
= (ENUM_PARAM_AD_HOC_MODE_T
) (prRegInfo
->u4AdhocMode
);
1043 prConnSettings
->eAuthMode
= AUTH_MODE_OPEN
;
1045 prConnSettings
->eEncStatus
= ENUM_ENCRYPTION_DISABLED
;
1047 prConnSettings
->fgIsScanReqIssued
= FALSE
;
1049 /* MIB attributes */
1050 prConnSettings
->u2BeaconPeriod
= DOT11_BEACON_PERIOD_DEFAULT
;
1052 prConnSettings
->u2RTSThreshold
= DOT11_RTS_THRESHOLD_DEFAULT
;
1054 prConnSettings
->u2DesiredNonHTRateSet
= RATE_SET_ALL_ABG
;
1056 /* prConnSettings->u4FreqInKHz; /* Center frequency */ */
1060 prConnSettings
->bmfgApsdEnAc
= PM_UAPSD_NONE
;
1062 secInit(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1065 prConnSettings
->fgIsEnableRoaming
= FALSE
;
1066 #if CFG_SUPPORT_ROAMING
1068 prConnSettings
->fgIsEnableRoaming
=
1069 ((prRegInfo
->fgDisRoaming
> 0) ? (FALSE
) : (TRUE
));
1071 #endif /* CFG_SUPPORT_ROAMING */
1073 prConnSettings
->fgIsAdHocQoSEnable
= FALSE
;
1075 prConnSettings
->eDesiredPhyConfig
= PHY_CONFIG_802_11ABGN
;
1077 /* Set default bandwidth modes */
1078 prConnSettings
->uc2G4BandwidthMode
= CONFIG_BW_20M
;
1079 prConnSettings
->uc5GBandwidthMode
= CONFIG_BW_20_40M
;
1081 prConnSettings
->rRsnInfo
.ucElemId
= 0x30;
1082 prConnSettings
->rRsnInfo
.u2Version
= 0x0001;
1083 prConnSettings
->rRsnInfo
.u4GroupKeyCipherSuite
= 0;
1084 prConnSettings
->rRsnInfo
.u4PairwiseKeyCipherSuiteCount
= 0;
1085 for (i
= 0; i
< MAX_NUM_SUPPORTED_CIPHER_SUITES
; i
++)
1086 prConnSettings
->rRsnInfo
.au4PairwiseKeyCipherSuite
[i
] = 0;
1087 prConnSettings
->rRsnInfo
.u4AuthKeyMgtSuiteCount
= 0;
1088 for (i
= 0; i
< MAX_NUM_SUPPORTED_AKM_SUITES
; i
++)
1089 prConnSettings
->rRsnInfo
.au4AuthKeyMgtSuite
[i
] = 0;
1090 prConnSettings
->rRsnInfo
.u2RsnCap
= 0;
1091 prConnSettings
->rRsnInfo
.fgRsnCapPresent
= FALSE
;
1094 } /* end of aisFsmInitializeConnectionSettings() */
1097 /*----------------------------------------------------------------------------*/
1099 * @brief the function is used to initialize the value in AIS_FSM_INFO_T for
1106 /*----------------------------------------------------------------------------*/
1107 VOID
aisFsmInit(IN P_ADAPTER_T prAdapter
)
1109 P_AIS_FSM_INFO_T prAisFsmInfo
;
1110 P_BSS_INFO_T prAisBssInfo
;
1111 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecificBssInfo
;
1113 DEBUGFUNC("aisFsmInit()");
1114 DBGLOG(SW1
, INFO
, ("->aisFsmInit()\n"));
1116 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1117 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
1118 prAisSpecificBssInfo
= &(prAdapter
->rWifiVar
.rAisSpecificBssInfo
);
1120 /* 4 <1> Initiate FSM */
1121 prAisFsmInfo
->ePreviousState
= AIS_STATE_IDLE
;
1122 prAisFsmInfo
->eCurrentState
= AIS_STATE_IDLE
;
1124 prAisFsmInfo
->ucAvailableAuthTypes
= 0;
1126 prAisFsmInfo
->prTargetBssDesc
= (P_BSS_DESC_T
) NULL
;
1128 prAisFsmInfo
->ucSeqNumOfReqMsg
= 0;
1129 prAisFsmInfo
->ucSeqNumOfChReq
= 0;
1130 prAisFsmInfo
->ucSeqNumOfScanReq
= 0;
1132 prAisFsmInfo
->fgIsInfraChannelFinished
= TRUE
;
1133 #if CFG_SUPPORT_ROAMING
1134 prAisFsmInfo
->fgIsRoamingScanPending
= FALSE
;
1135 #endif /* CFG_SUPPORT_ROAMING */
1136 prAisFsmInfo
->fgIsChannelRequested
= FALSE
;
1137 prAisFsmInfo
->fgIsChannelGranted
= FALSE
;
1139 /* 4 <1.1> Initiate FSM - Timer INIT */
1140 cnmTimerInitTimer(prAdapter
,
1141 &prAisFsmInfo
->rBGScanTimer
,
1142 (PFN_MGMT_TIMEOUT_FUNC
) aisFsmRunEventBGSleepTimeOut
, (UINT_32
) NULL
);
1144 cnmTimerInitTimer(prAdapter
,
1145 &prAisFsmInfo
->rIbssAloneTimer
,
1146 (PFN_MGMT_TIMEOUT_FUNC
) aisFsmRunEventIbssAloneTimeOut
, (UINT_32
) NULL
);
1148 cnmTimerInitTimer(prAdapter
,
1149 &prAisFsmInfo
->rIndicationOfDisconnectTimer
,
1150 (PFN_MGMT_TIMEOUT_FUNC
) aisPostponedEventOfDisconnTimeout
,
1153 cnmTimerInitTimer(prAdapter
,
1154 &prAisFsmInfo
->rJoinTimeoutTimer
,
1155 (PFN_MGMT_TIMEOUT_FUNC
) aisFsmRunEventJoinTimeout
, (UINT_32
) NULL
);
1157 /* 4 <1.2> Initiate PWR STATE */
1158 SET_NET_PWR_STATE_IDLE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1161 /* 4 <2> Initiate BSS_INFO_T - common part */
1162 BSS_INFO_INIT(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1163 COPY_MAC_ADDR(prAisBssInfo
->aucOwnMacAddr
, prAdapter
->rWifiVar
.aucMacAddress
);
1165 /* 4 <3> Initiate BSS_INFO_T - private part */
1167 prAisBssInfo
->eBand
= BAND_2G4
;
1168 prAisBssInfo
->ucPrimaryChannel
= 1;
1169 prAisBssInfo
->prStaRecOfAP
= (P_STA_RECORD_T
) NULL
;
1171 /* 4 <4> Allocate MSDU_INFO_T for Beacon */
1172 prAisBssInfo
->prBeacon
= cnmMgtPktAlloc(prAdapter
,
1173 OFFSET_OF(WLAN_BEACON_FRAME_T
,
1174 aucInfoElem
[0]) + MAX_IE_LENGTH
);
1176 if (prAisBssInfo
->prBeacon
) {
1177 prAisBssInfo
->prBeacon
->eSrc
= TX_PACKET_MGMT
;
1178 prAisBssInfo
->prBeacon
->ucStaRecIndex
= 0xFF; /* NULL STA_REC */
1184 prAisBssInfo
->rPmProfSetupInfo
.ucBmpDeliveryAC
= PM_UAPSD_ALL
;
1185 prAisBssInfo
->rPmProfSetupInfo
.ucBmpTriggerAC
= PM_UAPSD_ALL
;
1186 prAisBssInfo
->rPmProfSetupInfo
.ucUapsdSp
= WMM_MAX_SP_LENGTH_2
;
1188 if (prAdapter
->u4UapsdAcBmp
== 0) {
1189 prAdapter
->u4UapsdAcBmp
= CFG_INIT_UAPSD_AC_BMP
;
1190 /* ASSERT(prAdapter->u4UapsdAcBmp); */
1192 prAisBssInfo
->rPmProfSetupInfo
.ucBmpDeliveryAC
= (UINT_8
) prAdapter
->u4UapsdAcBmp
;
1193 prAisBssInfo
->rPmProfSetupInfo
.ucBmpTriggerAC
= (UINT_8
) prAdapter
->u4UapsdAcBmp
;
1194 prAisBssInfo
->rPmProfSetupInfo
.ucUapsdSp
= (UINT_8
) prAdapter
->u4MaxSpLen
;
1197 /* request list initialization */
1198 LINK_INITIALIZE(&prAisFsmInfo
->rPendingReqList
);
1200 /* DBGPRINTF("[2] ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x, ucUapsdSp:0x%x", */
1201 /* prAisBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC, */
1202 /* prAisBssInfo->rPmProfSetupInfo.ucBmpTriggerAC, */
1203 /* prAisBssInfo->rPmProfSetupInfo.ucUapsdSp); */
1206 } /* end of aisFsmInit() */
1208 /*----------------------------------------------------------------------------*/
1210 * @brief the function is used to uninitialize the value in AIS_FSM_INFO_T for
1217 /*----------------------------------------------------------------------------*/
1218 VOID
aisFsmUninit(IN P_ADAPTER_T prAdapter
)
1220 P_AIS_FSM_INFO_T prAisFsmInfo
;
1221 P_BSS_INFO_T prAisBssInfo
;
1222 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecificBssInfo
;
1224 DEBUGFUNC("aisFsmUninit()");
1225 DBGLOG(SW1
, INFO
, ("->aisFsmUninit()\n"));
1227 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1228 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
1229 prAisSpecificBssInfo
= &(prAdapter
->rWifiVar
.rAisSpecificBssInfo
);
1231 /* 4 <1> Stop all timers */
1232 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rBGScanTimer
);
1233 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rIbssAloneTimer
);
1234 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rIndicationOfDisconnectTimer
);
1235 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rJoinTimeoutTimer
);
1237 /* 4 <2> flush pending request */
1238 aisFsmFlushRequest(prAdapter
);
1240 /* 4 <3> Reset driver-domain BSS-INFO */
1241 if (prAisBssInfo
->prBeacon
) {
1242 cnmMgtPktFree(prAdapter
, prAisBssInfo
->prBeacon
);
1243 prAisBssInfo
->prBeacon
= NULL
;
1245 #if CFG_SUPPORT_802_11W
1246 rsnStopSaQuery(prAdapter
);
1250 } /* end of aisFsmUninit() */
1253 /*----------------------------------------------------------------------------*/
1255 * @brief Initialization of JOIN STATE
1257 * @param[in] prBssDesc The pointer of BSS_DESC_T which is the BSS we will try to join with.
1261 /*----------------------------------------------------------------------------*/
1262 VOID
aisFsmStateInit_JOIN(IN P_ADAPTER_T prAdapter
, P_BSS_DESC_T prBssDesc
)
1264 P_AIS_FSM_INFO_T prAisFsmInfo
;
1265 P_BSS_INFO_T prAisBssInfo
;
1266 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecificBssInfo
;
1267 P_CONNECTION_SETTINGS_T prConnSettings
;
1268 P_STA_RECORD_T prStaRec
;
1269 P_MSG_JOIN_REQ_T prJoinReqMsg
;
1271 DEBUGFUNC("aisFsmStateInit_JOIN()");
1273 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1274 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
1275 prAisSpecificBssInfo
= &(prAdapter
->rWifiVar
.rAisSpecificBssInfo
);
1276 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
1280 /* 4 <1> We are going to connect to this BSS. */
1281 prBssDesc
->fgIsConnecting
= TRUE
;
1284 /* 4 <2> Setup corresponding STA_RECORD_T */
1285 prStaRec
= bssCreateStaRecFromBssDesc(prAdapter
,
1287 NETWORK_TYPE_AIS_INDEX
, prBssDesc
);
1289 prAisFsmInfo
->prTargetStaRec
= prStaRec
;
1291 /* 4 <2.1> sync. to firmware domain */
1292 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_1
);
1294 /* 4 <3> Update ucAvailableAuthTypes which we can choice during SAA */
1295 if (prAisBssInfo
->eConnectionState
== PARAM_MEDIA_STATE_DISCONNECTED
) {
1297 prStaRec
->fgIsReAssoc
= FALSE
;
1299 switch (prConnSettings
->eAuthMode
) {
1300 case AUTH_MODE_OPEN
: /* Note: Omit break here. */
1302 case AUTH_MODE_WPA_PSK
:
1303 case AUTH_MODE_WPA2
:
1304 case AUTH_MODE_WPA2_PSK
:
1305 prAisFsmInfo
->ucAvailableAuthTypes
= (UINT_8
) AUTH_TYPE_OPEN_SYSTEM
;
1309 case AUTH_MODE_SHARED
:
1310 prAisFsmInfo
->ucAvailableAuthTypes
= (UINT_8
) AUTH_TYPE_SHARED_KEY
;
1314 case AUTH_MODE_AUTO_SWITCH
:
1315 DBGLOG(AIS
, LOUD
, ("JOIN INIT: eAuthMode == AUTH_MODE_AUTO_SWITCH\n"));
1316 prAisFsmInfo
->ucAvailableAuthTypes
= (UINT_8
) (AUTH_TYPE_OPEN_SYSTEM
|
1317 AUTH_TYPE_SHARED_KEY
);
1321 ASSERT(!(prConnSettings
->eAuthMode
== AUTH_MODE_WPA_NONE
));
1323 ("JOIN INIT: Auth Algorithm : %d was not supported by JOIN\n",
1324 prConnSettings
->eAuthMode
));
1325 /* TODO(Kevin): error handling ? */
1329 /* TODO(tyhsu): Assume that Roaming Auth Type is equal to ConnSettings eAuthMode */
1330 prAisSpecificBssInfo
->ucRoamingAuthTypes
= prAisFsmInfo
->ucAvailableAuthTypes
;
1332 prStaRec
->ucTxAuthAssocRetryLimit
= TX_AUTH_ASSOCI_RETRY_LIMIT
;
1335 ASSERT(prBssDesc
->eBSSType
== BSS_TYPE_INFRASTRUCTURE
);
1336 ASSERT(!prBssDesc
->fgIsConnected
);
1338 DBGLOG(AIS
, LOUD
, ("JOIN INIT: AUTH TYPE = %d for Roaming\n",
1339 prAisSpecificBssInfo
->ucRoamingAuthTypes
));
1342 prStaRec
->fgIsReAssoc
= TRUE
; /* We do roaming while the medium is connected */
1344 /* TODO(Kevin): We may call a sub function to acquire the Roaming Auth Type */
1345 prAisFsmInfo
->ucAvailableAuthTypes
= prAisSpecificBssInfo
->ucRoamingAuthTypes
;
1347 prStaRec
->ucTxAuthAssocRetryLimit
= TX_AUTH_ASSOCI_RETRY_LIMIT_FOR_ROAMING
;
1351 /* 4 <4> Use an appropriate Authentication Algorithm Number among the ucAvailableAuthTypes */
1352 if (prAisFsmInfo
->ucAvailableAuthTypes
& (UINT_8
) AUTH_TYPE_OPEN_SYSTEM
) {
1355 ("JOIN INIT: Try to do Authentication with AuthType == OPEN_SYSTEM.\n"));
1356 prAisFsmInfo
->ucAvailableAuthTypes
&= ~(UINT_8
) AUTH_TYPE_OPEN_SYSTEM
;
1358 prStaRec
->ucAuthAlgNum
= (UINT_8
) AUTH_ALGORITHM_NUM_OPEN_SYSTEM
;
1359 } else if (prAisFsmInfo
->ucAvailableAuthTypes
& (UINT_8
) AUTH_TYPE_SHARED_KEY
) {
1362 ("JOIN INIT: Try to do Authentication with AuthType == SHARED_KEY.\n"));
1364 prAisFsmInfo
->ucAvailableAuthTypes
&= ~(UINT_8
) AUTH_TYPE_SHARED_KEY
;
1366 prStaRec
->ucAuthAlgNum
= (UINT_8
) AUTH_ALGORITHM_NUM_SHARED_KEY
;
1367 } else if (prAisFsmInfo
->ucAvailableAuthTypes
& (UINT_8
) AUTH_TYPE_FAST_BSS_TRANSITION
) {
1370 ("JOIN INIT: Try to do Authentication with AuthType == FAST_BSS_TRANSITION.\n"));
1372 prAisFsmInfo
->ucAvailableAuthTypes
&= ~(UINT_8
) AUTH_TYPE_FAST_BSS_TRANSITION
;
1374 prStaRec
->ucAuthAlgNum
= (UINT_8
) AUTH_ALGORITHM_NUM_FAST_BSS_TRANSITION
;
1379 /* 4 <5> Overwrite Connection Setting for eConnectionPolicy == ANY (Used by Assoc Req) */
1380 if (prConnSettings
->eConnectionPolicy
== CONNECT_BY_SSID_ANY
) {
1382 if (prBssDesc
->ucSSIDLen
) {
1383 COPY_SSID(prConnSettings
->aucSSID
,
1384 prConnSettings
->ucSSIDLen
,
1385 prBssDesc
->aucSSID
, prBssDesc
->ucSSIDLen
);
1388 /* 4 <6> Send a Msg to trigger SAA to start JOIN process. */
1390 (P_MSG_JOIN_REQ_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_JOIN_REQ_T
));
1391 if (!prJoinReqMsg
) {
1393 ASSERT(0); /* Can't trigger SAA FSM */
1397 prJoinReqMsg
->rMsgHdr
.eMsgId
= MID_AIS_SAA_FSM_START
;
1398 prJoinReqMsg
->ucSeqNum
= ++prAisFsmInfo
->ucSeqNumOfReqMsg
;
1399 prJoinReqMsg
->prStaRec
= prStaRec
;
1403 P_FRAG_INFO_T prFragInfo
;
1404 for (j
= 0; j
< MAX_NUM_CONCURRENT_FRAGMENTED_MSDUS
; j
++) {
1405 prFragInfo
= &prStaRec
->rFragInfo
[j
];
1407 if (prFragInfo
->pr1stFrag
) {
1408 /* nicRxReturnRFB(prAdapter, prFragInfo->pr1stFrag); */
1409 prFragInfo
->pr1stFrag
= (P_SW_RFB_T
) NULL
;
1414 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prJoinReqMsg
, MSG_SEND_METHOD_BUF
);
1417 } /* end of aisFsmInit_JOIN() */
1420 /*----------------------------------------------------------------------------*/
1422 * @brief Retry JOIN for AUTH_MODE_AUTO_SWITCH
1424 * @param[in] prStaRec Pointer to the STA_RECORD_T
1426 * @retval TRUE We will retry JOIN
1427 * @retval FALSE We will not retry JOIN
1429 /*----------------------------------------------------------------------------*/
1430 BOOLEAN
aisFsmStateInit_RetryJOIN(IN P_ADAPTER_T prAdapter
, P_STA_RECORD_T prStaRec
)
1432 P_AIS_FSM_INFO_T prAisFsmInfo
;
1433 P_MSG_JOIN_REQ_T prJoinReqMsg
;
1435 DEBUGFUNC("aisFsmStateInit_RetryJOIN()");
1437 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1439 /* Retry other AuthType if possible */
1440 if (!prAisFsmInfo
->ucAvailableAuthTypes
) {
1444 if (prAisFsmInfo
->ucAvailableAuthTypes
& (UINT_8
) AUTH_TYPE_SHARED_KEY
) {
1447 ("RETRY JOIN INIT: Retry Authentication with AuthType == SHARED_KEY.\n"));
1449 prAisFsmInfo
->ucAvailableAuthTypes
&= ~(UINT_8
) AUTH_TYPE_SHARED_KEY
;
1451 prStaRec
->ucAuthAlgNum
= (UINT_8
) AUTH_ALGORITHM_NUM_SHARED_KEY
;
1454 ("RETRY JOIN INIT: Retry Authentication with Unexpected AuthType.\n"));
1458 prAisFsmInfo
->ucAvailableAuthTypes
= 0; /* No more available Auth Types */
1460 /* Trigger SAA to start JOIN process. */
1462 (P_MSG_JOIN_REQ_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_JOIN_REQ_T
));
1463 if (!prJoinReqMsg
) {
1465 ASSERT(0); /* Can't trigger SAA FSM */
1469 prJoinReqMsg
->rMsgHdr
.eMsgId
= MID_AIS_SAA_FSM_START
;
1470 prJoinReqMsg
->ucSeqNum
= ++prAisFsmInfo
->ucSeqNumOfReqMsg
;
1471 prJoinReqMsg
->prStaRec
= prStaRec
;
1473 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prJoinReqMsg
, MSG_SEND_METHOD_BUF
);
1477 } /* end of aisFsmRetryJOIN() */
1480 #if CFG_SUPPORT_ADHOC
1481 /*----------------------------------------------------------------------------*/
1483 * @brief State Initialization of AIS_STATE_IBSS_ALONE
1489 /*----------------------------------------------------------------------------*/
1490 VOID
aisFsmStateInit_IBSS_ALONE(IN P_ADAPTER_T prAdapter
)
1492 P_AIS_FSM_INFO_T prAisFsmInfo
;
1493 P_CONNECTION_SETTINGS_T prConnSettings
;
1494 P_BSS_INFO_T prAisBssInfo
;
1496 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1497 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
1498 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
1500 /* 4 <1> Check if IBSS was created before ? */
1501 if (prAisBssInfo
->fgIsBeaconActivated
) {
1503 /* 4 <2> Start IBSS Alone Timer for periodic SCAN and then SEARCH */
1504 #if !CFG_SLT_SUPPORT
1505 cnmTimerStartTimer(prAdapter
,
1506 &prAisFsmInfo
->rIbssAloneTimer
,
1507 SEC_TO_MSEC(AIS_IBSS_ALONE_TIMEOUT_SEC
));
1511 aisFsmCreateIBSS(prAdapter
);
1514 } /* end of aisFsmStateInit_IBSS_ALONE() */
1517 /*----------------------------------------------------------------------------*/
1519 * @brief State Initialization of AIS_STATE_IBSS_MERGE
1521 * @param[in] prBssDesc The pointer of BSS_DESC_T which is the IBSS we will try to merge with.
1525 /*----------------------------------------------------------------------------*/
1526 VOID
aisFsmStateInit_IBSS_MERGE(IN P_ADAPTER_T prAdapter
, P_BSS_DESC_T prBssDesc
)
1528 P_AIS_FSM_INFO_T prAisFsmInfo
;
1529 P_CONNECTION_SETTINGS_T prConnSettings
;
1530 P_BSS_INFO_T prAisBssInfo
;
1531 P_STA_RECORD_T prStaRec
= (P_STA_RECORD_T
) NULL
;
1536 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1537 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
1538 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
1540 /* 4 <1> We will merge with to this BSS immediately. */
1541 prBssDesc
->fgIsConnecting
= FALSE
;
1542 prBssDesc
->fgIsConnected
= TRUE
;
1544 /* 4 <2> Setup corresponding STA_RECORD_T */
1545 prStaRec
= bssCreateStaRecFromBssDesc(prAdapter
,
1546 STA_TYPE_ADHOC_PEER
,
1547 NETWORK_TYPE_AIS_INDEX
, prBssDesc
);
1549 prStaRec
->fgIsMerging
= TRUE
;
1551 prAisFsmInfo
->prTargetStaRec
= prStaRec
;
1553 /* 4 <2.1> sync. to firmware domain */
1554 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_1
);
1556 /* 4 <3> IBSS-Merge */
1557 aisFsmMergeIBSS(prAdapter
, prStaRec
);
1560 } /* end of aisFsmStateInit_IBSS_MERGE() */
1562 #endif /* CFG_SUPPORT_ADHOC */
1565 /*----------------------------------------------------------------------------*/
1567 * @brief Process of JOIN Abort
1573 /*----------------------------------------------------------------------------*/
1574 VOID
aisFsmStateAbort_JOIN(IN P_ADAPTER_T prAdapter
)
1576 P_AIS_FSM_INFO_T prAisFsmInfo
;
1577 P_MSG_JOIN_ABORT_T prJoinAbortMsg
;
1579 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1581 /* 1. Abort JOIN process */
1583 (P_MSG_JOIN_ABORT_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_JOIN_ABORT_T
));
1584 if (!prJoinAbortMsg
) {
1586 ASSERT(0); /* Can't abort SAA FSM */
1590 kalIndicateStatusAndComplete(prAdapter
->prGlueInfo
,
1591 WLAN_STATUS_CONNECT_INDICATION
, NULL
, 0);
1593 prJoinAbortMsg
->rMsgHdr
.eMsgId
= MID_AIS_SAA_FSM_ABORT
;
1594 prJoinAbortMsg
->ucSeqNum
= prAisFsmInfo
->ucSeqNumOfReqMsg
;
1595 prJoinAbortMsg
->prStaRec
= prAisFsmInfo
->prTargetStaRec
;
1597 scanRemoveConnFlagOfBssDescByBssid(prAdapter
, prAisFsmInfo
->prTargetStaRec
->aucMacAddr
);
1599 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prJoinAbortMsg
, MSG_SEND_METHOD_BUF
);
1601 /* 2. Return channel privilege */
1602 aisFsmReleaseCh(prAdapter
);
1604 /* 3.1 stop join timeout timer */
1605 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rJoinTimeoutTimer
);
1607 /* 3.2 reset local variable */
1608 prAisFsmInfo
->fgIsInfraChannelFinished
= TRUE
;
1611 } /* end of aisFsmAbortJOIN() */
1614 /*----------------------------------------------------------------------------*/
1616 * @brief Process of SCAN Abort
1622 /*----------------------------------------------------------------------------*/
1623 VOID
aisFsmStateAbort_SCAN(IN P_ADAPTER_T prAdapter
)
1625 P_AIS_FSM_INFO_T prAisFsmInfo
;
1626 P_MSG_SCN_SCAN_CANCEL prScanCancelMsg
;
1628 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1630 /* Abort JOIN process. */
1632 (P_MSG_SCN_SCAN_CANCEL
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
,
1633 sizeof(MSG_SCN_SCAN_CANCEL
));
1634 if (!prScanCancelMsg
) {
1636 ASSERT(0); /* Can't abort SCN FSM */
1640 prScanCancelMsg
->rMsgHdr
.eMsgId
= MID_AIS_SCN_SCAN_CANCEL
;
1641 prScanCancelMsg
->ucSeqNum
= prAisFsmInfo
->ucSeqNumOfScanReq
;
1642 prScanCancelMsg
->ucNetTypeIndex
= (UINT_8
) NETWORK_TYPE_AIS_INDEX
;
1643 #if CFG_ENABLE_WIFI_DIRECT
1644 if (prAdapter
->fgIsP2PRegistered
) {
1645 prScanCancelMsg
->fgIsChannelExt
= FALSE
;
1649 /* unbuffered message to guarantee scan is cancelled in sequence */
1650 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prScanCancelMsg
, MSG_SEND_METHOD_UNBUF
);
1653 } /* end of aisFsmAbortSCAN() */
1656 /*----------------------------------------------------------------------------*/
1658 * @brief Process of NORMAL_TR Abort
1664 /*----------------------------------------------------------------------------*/
1665 VOID
aisFsmStateAbort_NORMAL_TR(IN P_ADAPTER_T prAdapter
)
1667 P_AIS_FSM_INFO_T prAisFsmInfo
;
1670 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1672 /* TODO(Kevin): Do abort other MGMT func */
1674 /* 1. Release channel to CNM */
1675 aisFsmReleaseCh(prAdapter
);
1677 /* 2.1 stop join timeout timer */
1678 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rJoinTimeoutTimer
);
1680 /* 2.2 reset local variable */
1681 prAisFsmInfo
->fgIsInfraChannelFinished
= TRUE
;
1684 } /* end of aisFsmAbortNORMAL_TR() */
1687 #if CFG_SUPPORT_ADHOC
1688 /*----------------------------------------------------------------------------*/
1690 * @brief Process of NORMAL_TR Abort
1696 /*----------------------------------------------------------------------------*/
1697 VOID
aisFsmStateAbort_IBSS(IN P_ADAPTER_T prAdapter
)
1699 P_AIS_FSM_INFO_T prAisFsmInfo
;
1700 P_BSS_DESC_T prBssDesc
;
1702 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1704 /* reset BSS-DESC */
1705 if (prAisFsmInfo
->prTargetStaRec
) {
1706 prBssDesc
= scanSearchBssDescByTA(prAdapter
,
1707 prAisFsmInfo
->prTargetStaRec
->aucMacAddr
);
1710 prBssDesc
->fgIsConnected
= FALSE
;
1711 prBssDesc
->fgIsConnecting
= FALSE
;
1714 /* release channel privilege */
1715 aisFsmReleaseCh(prAdapter
);
1719 #endif /* CFG_SUPPORT_ADHOC */
1722 /*----------------------------------------------------------------------------*/
1724 * @brief The Core FSM engine of AIS(Ad-hoc, Infra STA)
1726 * @param[in] eNextState Enum value of next AIS STATE
1730 /*----------------------------------------------------------------------------*/
1731 VOID
aisFsmSteps(IN P_ADAPTER_T prAdapter
, ENUM_AIS_STATE_T eNextState
)
1733 P_AIS_FSM_INFO_T prAisFsmInfo
;
1734 P_BSS_INFO_T prAisBssInfo
;
1735 P_CONNECTION_SETTINGS_T prConnSettings
;
1736 P_BSS_DESC_T prBssDesc
;
1737 P_MSG_CH_REQ_T prMsgChReq
;
1738 P_MSG_SCN_SCAN_REQ prScanReqMsg
;
1739 P_AIS_REQ_HDR_T prAisReq
;
1742 UINT_16 u2ScanIELen
;
1744 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
1746 DEBUGFUNC("aisFsmSteps()");
1748 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
1749 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
1750 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
1754 /* Do entering Next State */
1755 prAisFsmInfo
->ePreviousState
= prAisFsmInfo
->eCurrentState
;
1758 DBGLOG(AIS
, STATE
, ("TRANSITION: [%s] -> [%s]\n",
1759 apucDebugAisState
[prAisFsmInfo
->eCurrentState
],
1760 apucDebugAisState
[eNextState
]));
1762 DBGLOG(AIS
, STATE
, ("[%d] TRANSITION: [%d] -> [%d]\n",
1763 DBG_AIS_IDX
, prAisFsmInfo
->eCurrentState
, eNextState
));
1765 /* NOTE(Kevin): This is the only place to change the eCurrentState(except initial) */
1766 prAisFsmInfo
->eCurrentState
= eNextState
;
1768 fgIsTransition
= (BOOLEAN
) FALSE
;
1770 /* Do tasks of the State that we just entered */
1771 switch (prAisFsmInfo
->eCurrentState
) {
1772 /* NOTE(Kevin): we don't have to rearrange the sequence of following
1773 * switch case. Instead I would like to use a common lookup table of array
1774 * of function pointer to speed up state search.
1776 case AIS_STATE_IDLE
:
1778 prAisReq
= aisFsmGetNextRequest(prAdapter
);
1780 if (prAisReq
== NULL
|| prAisReq
->eReqType
== AIS_REQUEST_RECONNECT
) {
1781 if (prConnSettings
->fgIsConnReqIssued
== TRUE
&&
1782 prConnSettings
->fgIsDisconnectedByNonRequest
== FALSE
) {
1784 prAisFsmInfo
->fgTryScan
= TRUE
;
1786 SET_NET_ACTIVE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1787 SET_NET_PWR_STATE_ACTIVE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1789 /* sync with firmware */
1790 nicActivateNetwork(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1792 /* reset trial count */
1793 prAisFsmInfo
->ucConnTrialCount
= 0;
1795 eNextState
= AIS_STATE_SEARCH
;
1796 fgIsTransition
= TRUE
;
1798 UNSET_NET_ACTIVE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1799 SET_NET_PWR_STATE_IDLE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1801 /* sync with firmware */
1802 nicDeactivateNetwork(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1804 /* check for other pending request */
1806 if (aisFsmIsRequestPending
1807 (prAdapter
, AIS_REQUEST_SCAN
, TRUE
) == TRUE
) {
1808 wlanClearScanningResult(prAdapter
);
1809 eNextState
= AIS_STATE_SCAN
;
1811 fgIsTransition
= TRUE
;
1817 /* free the message */
1818 cnmMemFree(prAdapter
, prAisReq
);
1820 } else if (prAisReq
->eReqType
== AIS_REQUEST_SCAN
) {
1821 #if CFG_SUPPORT_ROAMING
1822 prAisFsmInfo
->fgIsRoamingScanPending
= FALSE
;
1823 #endif /* CFG_SUPPORT_ROAMING */
1824 wlanClearScanningResult(prAdapter
);
1826 eNextState
= AIS_STATE_SCAN
;
1827 fgIsTransition
= TRUE
;
1829 /* free the message */
1830 cnmMemFree(prAdapter
, prAisReq
);
1831 } else if (prAisReq
->eReqType
== AIS_REQUEST_ROAMING_CONNECT
1832 || prAisReq
->eReqType
== AIS_REQUEST_ROAMING_SEARCH
) {
1834 /* free the message */
1835 cnmMemFree(prAdapter
, prAisReq
);
1838 prAisFsmInfo
->u4SleepInterval
= AIS_BG_SCAN_INTERVAL_MIN_SEC
;
1842 case AIS_STATE_SEARCH
:
1843 /* 4 <1> Search for a matched candidate and save it to prTargetBssDesc. */
1845 prBssDesc
= prAdapter
->rWifiVar
.rSltInfo
.prPseudoBssDesc
;
1847 prBssDesc
= scanSearchBssDescByPolicy(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
1850 /* we are under Roaming Condition. */
1851 if (prAisBssInfo
->eConnectionState
== PARAM_MEDIA_STATE_CONNECTED
) {
1852 if (prAisFsmInfo
->ucConnTrialCount
>
1853 AIS_ROAMING_CONNECTION_TRIAL_LIMIT
) {
1854 #if CFG_SUPPORT_ROAMING
1855 roamingFsmRunEventFail(prAdapter
,
1856 ROAMING_FAIL_REASON_CONNLIMIT
);
1857 #endif /* CFG_SUPPORT_ROAMING */
1858 /* reset retry count */
1859 prAisFsmInfo
->ucConnTrialCount
= 0;
1861 /* abort connection trial */
1862 prConnSettings
->fgIsConnReqIssued
= FALSE
;
1864 eNextState
= AIS_STATE_NORMAL_TR
;
1865 fgIsTransition
= TRUE
;
1870 /* 4 <2> We are not under Roaming Condition. */
1871 if (prAisBssInfo
->eConnectionState
== PARAM_MEDIA_STATE_DISCONNECTED
) {
1873 /* 4 <2.a> If we have the matched one */
1876 /* 4 <A> Stored the Selected BSS security cipher. For later asoc req compose IE */
1877 prAisBssInfo
->u4RsnSelectedGroupCipher
=
1878 prBssDesc
->u4RsnSelectedGroupCipher
;
1879 prAisBssInfo
->u4RsnSelectedPairwiseCipher
=
1880 prBssDesc
->u4RsnSelectedPairwiseCipher
;
1881 prAisBssInfo
->u4RsnSelectedAKMSuite
=
1882 prBssDesc
->u4RsnSelectedAKMSuite
;
1884 /* 4 <B> Do STATE transition and update current Operation Mode. */
1885 if (prBssDesc
->eBSSType
== BSS_TYPE_INFRASTRUCTURE
) {
1887 prAisBssInfo
->eCurrentOPMode
=
1888 OP_MODE_INFRASTRUCTURE
;
1890 /* Record the target BSS_DESC_T for next STATE. */
1891 prAisFsmInfo
->prTargetBssDesc
= prBssDesc
;
1893 /* Transit to channel acquire */
1894 eNextState
= AIS_STATE_REQ_CHANNEL_JOIN
;
1895 fgIsTransition
= TRUE
;
1897 /* increase connection trial count */
1898 prAisFsmInfo
->ucConnTrialCount
++;
1900 #if CFG_SUPPORT_ADHOC
1901 else if (prBssDesc
->eBSSType
== BSS_TYPE_IBSS
) {
1903 prAisBssInfo
->eCurrentOPMode
= OP_MODE_IBSS
;
1905 /* Record the target BSS_DESC_T for next STATE. */
1906 prAisFsmInfo
->prTargetBssDesc
= prBssDesc
;
1908 eNextState
= AIS_STATE_IBSS_MERGE
;
1909 fgIsTransition
= TRUE
;
1911 #endif /* CFG_SUPPORT_ADHOC */
1914 eNextState
= AIS_STATE_WAIT_FOR_NEXT_SCAN
;
1915 fgIsTransition
= TRUE
;
1918 /* 4 <2.b> If we don't have the matched one */
1921 /* increase connection trial count for infrastructure connection */
1922 if (prConnSettings
->eOPMode
== NET_TYPE_INFRA
) {
1923 prAisFsmInfo
->ucConnTrialCount
++;
1925 /* 4 <A> Try to SCAN */
1926 if (prAisFsmInfo
->fgTryScan
) {
1927 eNextState
= AIS_STATE_LOOKING_FOR
;
1929 fgIsTransition
= TRUE
;
1931 /* 4 <B> We've do SCAN already, now wait in some STATE. */
1933 if (prConnSettings
->eOPMode
== NET_TYPE_INFRA
) {
1935 /* issue reconnect request, and retreat to idle state for scheduling */
1936 aisFsmInsertRequest(prAdapter
,
1937 AIS_REQUEST_RECONNECT
);
1939 eNextState
= AIS_STATE_IDLE
;
1940 fgIsTransition
= TRUE
;
1942 #if CFG_SUPPORT_ADHOC
1943 else if ((prConnSettings
->eOPMode
== NET_TYPE_IBSS
)
1944 || (prConnSettings
->eOPMode
==
1945 NET_TYPE_AUTO_SWITCH
)
1946 || (prConnSettings
->eOPMode
==
1947 NET_TYPE_DEDICATED_IBSS
)) {
1949 prAisBssInfo
->eCurrentOPMode
= OP_MODE_IBSS
;
1950 prAisFsmInfo
->prTargetBssDesc
= NULL
;
1952 eNextState
= AIS_STATE_IBSS_ALONE
;
1953 fgIsTransition
= TRUE
;
1955 #endif /* CFG_SUPPORT_ADHOC */
1958 eNextState
= AIS_STATE_WAIT_FOR_NEXT_SCAN
;
1959 fgIsTransition
= TRUE
;
1964 /* 4 <3> We are under Roaming Condition. */
1965 else { /* prAdapter->eConnectionState == MEDIA_STATE_CONNECTED. */
1967 /* 4 <3.a> This BSS_DESC_T is our AP. */
1968 /* NOTE(Kevin 2008/05/16): Following cases will go back to NORMAL_TR.
1969 * CASE I: During Roaming, APP(WZC/NDISTEST) change the connection
1970 * settings. That make we can NOT match the original AP, so the
1971 * prBssDesc is NULL.
1972 * CASE II: The same reason as CASE I. Because APP change the
1973 * eOPMode to other network type in connection setting
1974 * (e.g. NET_TYPE_IBSS), so the BssDesc become the IBSS node.
1975 * (For CASE I/II, before WZC/NDISTEST set the OID_SSID, it will change
1976 * other parameters in connection setting first. So if we do roaming
1977 * at the same time, it will hit these cases.)
1979 * CASE III: Normal case, we can't find other candidate to roam
1980 * out, so only the current AP will be matched.
1982 * CASE VI: Timestamp of the current AP might be reset
1984 if ((!prBssDesc
) || /* CASE I */
1985 (prBssDesc
->eBSSType
!= BSS_TYPE_INFRASTRUCTURE
) || /* CASE II */
1986 (prBssDesc
->fgIsConnected
) || /* CASE III */
1987 (EQUAL_MAC_ADDR(prBssDesc
->aucBSSID
, prAisBssInfo
->aucBSSID
))
1990 if ((prBssDesc
) && (prBssDesc
->fgIsConnected
)) {
1991 ASSERT(EQUAL_MAC_ADDR
1992 (prBssDesc
->aucBSSID
,
1993 prAisBssInfo
->aucBSSID
));
1996 /* We already associated with it, go back to NORMAL_TR */
1997 /* TODO(Kevin): Roaming Fail */
1998 #if CFG_SUPPORT_ROAMING
1999 roamingFsmRunEventFail(prAdapter
,
2000 ROAMING_FAIL_REASON_NOCANDIDATE
);
2001 #endif /* CFG_SUPPORT_ROAMING */
2003 /* Retreat to NORMAL_TR state */
2004 eNextState
= AIS_STATE_NORMAL_TR
;
2005 fgIsTransition
= TRUE
;
2007 /* 4 <3.b> Try to roam out for JOIN this BSS_DESC_T. */
2010 ASSERT(UNEQUAL_MAC_ADDR
2011 (prBssDesc
->aucBSSID
, prAisBssInfo
->aucBSSID
));
2014 /* 4 <A> Record the target BSS_DESC_T for next STATE. */
2015 prAisFsmInfo
->prTargetBssDesc
= prBssDesc
;
2017 /* tyhsu: increase connection trial count */
2018 prAisFsmInfo
->ucConnTrialCount
++;
2020 /* Transit to channel acquire */
2021 eNextState
= AIS_STATE_REQ_CHANNEL_JOIN
;
2022 fgIsTransition
= TRUE
;
2028 case AIS_STATE_WAIT_FOR_NEXT_SCAN
:
2031 ("SCAN: Idle Begin - Current Time = %ld\n", kalGetTimeTick()));
2033 cnmTimerStartTimer(prAdapter
,
2034 &prAisFsmInfo
->rBGScanTimer
,
2035 SEC_TO_MSEC(prAisFsmInfo
->u4SleepInterval
));
2037 SET_NET_PWR_STATE_IDLE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
2039 if (prAisFsmInfo
->u4SleepInterval
< AIS_BG_SCAN_INTERVAL_MAX_SEC
) {
2040 prAisFsmInfo
->u4SleepInterval
<<= 1;
2044 case AIS_STATE_SCAN
:
2045 case AIS_STATE_ONLINE_SCAN
:
2046 case AIS_STATE_LOOKING_FOR
:
2048 if (!IS_NET_ACTIVE(prAdapter
, NETWORK_TYPE_AIS_INDEX
)) {
2049 SET_NET_ACTIVE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
2051 /* sync with firmware */
2052 nicActivateNetwork(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
2055 /* IE length decision */
2056 if (prAisFsmInfo
->u4ScanIELength
> 0) {
2057 u2ScanIELen
= (UINT_16
) prAisFsmInfo
->u4ScanIELength
;
2059 #if CFG_SUPPORT_WPS2
2060 u2ScanIELen
= prAdapter
->prGlueInfo
->u2WSCIELen
;
2066 prScanReqMsg
= (P_MSG_SCN_SCAN_REQ
) cnmMemAlloc(prAdapter
,
2068 OFFSET_OF(MSG_SCN_SCAN_REQ
,
2071 if (!prScanReqMsg
) {
2072 ASSERT(0); /* Can't trigger SCAN FSM */
2076 prScanReqMsg
->rMsgHdr
.eMsgId
= MID_AIS_SCN_SCAN_REQ
;
2077 prScanReqMsg
->ucSeqNum
= ++prAisFsmInfo
->ucSeqNumOfScanReq
;
2078 prScanReqMsg
->ucNetTypeIndex
= (UINT_8
) NETWORK_TYPE_AIS_INDEX
;
2080 #if CFG_SUPPORT_RDD_TEST_MODE
2081 prScanReqMsg
->eScanType
= SCAN_TYPE_PASSIVE_SCAN
;
2083 prScanReqMsg
->eScanType
= SCAN_TYPE_ACTIVE_SCAN
;
2086 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_SCAN
2087 || prAisFsmInfo
->eCurrentState
== AIS_STATE_ONLINE_SCAN
) {
2088 if (prAisFsmInfo
->ucScanSSIDLen
== 0) {
2089 /* Scan for all available SSID */
2090 prScanReqMsg
->ucSSIDType
= SCAN_REQ_SSID_WILDCARD
;
2092 prScanReqMsg
->ucSSIDType
= SCAN_REQ_SSID_SPECIFIED
;
2093 COPY_SSID(prScanReqMsg
->aucSSID
,
2094 prScanReqMsg
->ucSSIDLength
,
2095 prAisFsmInfo
->aucScanSSID
,
2096 prAisFsmInfo
->ucScanSSIDLen
);
2099 /* Scan for determined SSID */
2100 prScanReqMsg
->ucSSIDType
= SCAN_REQ_SSID_SPECIFIED
;
2101 COPY_SSID(prScanReqMsg
->aucSSID
,
2102 prScanReqMsg
->ucSSIDLength
,
2103 prConnSettings
->aucSSID
, prConnSettings
->ucSSIDLen
);
2106 /* check if tethering is running and need to fix on specific channel */
2107 if (cnmAisInfraChannelFixed(prAdapter
, &eBand
, &ucChannel
) == TRUE
) {
2108 prScanReqMsg
->eScanChannel
= SCAN_CHANNEL_SPECIFIED
;
2109 prScanReqMsg
->ucChannelListNum
= 1;
2110 prScanReqMsg
->arChnlInfoList
[0].eBand
= eBand
;
2111 prScanReqMsg
->arChnlInfoList
[0].ucChannelNum
= ucChannel
;
2112 } else if (prAdapter
->aePreferBand
[NETWORK_TYPE_AIS_INDEX
] == BAND_NULL
) {
2113 if (prAdapter
->fgEnable5GBand
== TRUE
) {
2114 prScanReqMsg
->eScanChannel
= SCAN_CHANNEL_FULL
;
2116 prScanReqMsg
->eScanChannel
= SCAN_CHANNEL_2G4
;
2118 } else if (prAdapter
->aePreferBand
[NETWORK_TYPE_AIS_INDEX
] == BAND_2G4
) {
2119 prScanReqMsg
->eScanChannel
= SCAN_CHANNEL_2G4
;
2120 } else if (prAdapter
->aePreferBand
[NETWORK_TYPE_AIS_INDEX
] == BAND_5G
) {
2121 prScanReqMsg
->eScanChannel
= SCAN_CHANNEL_5G
;
2123 prScanReqMsg
->eScanChannel
= SCAN_CHANNEL_FULL
;
2127 if (prAisFsmInfo
->u4ScanIELength
> 0) {
2128 kalMemCopy(prScanReqMsg
->aucIE
, prAisFsmInfo
->aucScanIEBuf
,
2129 prAisFsmInfo
->u4ScanIELength
);
2131 #if CFG_SUPPORT_WPS2
2132 if (prAdapter
->prGlueInfo
->u2WSCIELen
> 0) {
2133 kalMemCopy(prScanReqMsg
->aucIE
,
2134 &prAdapter
->prGlueInfo
->aucWSCIE
,
2135 prAdapter
->prGlueInfo
->u2WSCIELen
);
2140 prScanReqMsg
->u2IELen
= u2ScanIELen
;
2142 mboxSendMsg(prAdapter
,
2143 MBOX_ID_0
, (P_MSG_HDR_T
) prScanReqMsg
, MSG_SEND_METHOD_BUF
);
2145 prAisFsmInfo
->fgTryScan
= FALSE
; /* Will enable background sleep for infrastructure */
2149 case AIS_STATE_REQ_CHANNEL_JOIN
:
2150 /* send message to CNM for acquiring channel */
2152 (P_MSG_CH_REQ_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
,
2153 sizeof(MSG_CH_REQ_T
));
2155 ASSERT(0); /* Can't indicate CNM for channel acquiring */
2159 prMsgChReq
->rMsgHdr
.eMsgId
= MID_MNY_CNM_CH_REQ
;
2160 prMsgChReq
->ucNetTypeIndex
= NETWORK_TYPE_AIS_INDEX
;
2161 prMsgChReq
->ucTokenID
= ++prAisFsmInfo
->ucSeqNumOfChReq
;
2162 prMsgChReq
->eReqType
= CH_REQ_TYPE_JOIN
;
2163 prMsgChReq
->u4MaxInterval
= AIS_JOIN_CH_REQUEST_INTERVAL
;
2164 prMsgChReq
->ucPrimaryChannel
= prAisFsmInfo
->prTargetBssDesc
->ucChannelNum
;
2165 prMsgChReq
->eRfSco
= prAisFsmInfo
->prTargetBssDesc
->eSco
;
2166 prMsgChReq
->eRfBand
= prAisFsmInfo
->prTargetBssDesc
->eBand
;
2167 COPY_MAC_ADDR(prMsgChReq
->aucBSSID
,
2168 prAisFsmInfo
->prTargetBssDesc
->aucBSSID
);
2170 mboxSendMsg(prAdapter
,
2171 MBOX_ID_0
, (P_MSG_HDR_T
) prMsgChReq
, MSG_SEND_METHOD_BUF
);
2173 prAisFsmInfo
->fgIsChannelRequested
= TRUE
;
2176 case AIS_STATE_JOIN
:
2177 aisFsmStateInit_JOIN(prAdapter
, prAisFsmInfo
->prTargetBssDesc
);
2180 #if CFG_SUPPORT_ADHOC
2181 case AIS_STATE_IBSS_ALONE
:
2182 aisFsmStateInit_IBSS_ALONE(prAdapter
);
2185 case AIS_STATE_IBSS_MERGE
:
2186 aisFsmStateInit_IBSS_MERGE(prAdapter
, prAisFsmInfo
->prTargetBssDesc
);
2188 #endif /* CFG_SUPPORT_ADHOC */
2190 case AIS_STATE_NORMAL_TR
:
2191 if (prAisFsmInfo
->fgIsInfraChannelFinished
== FALSE
) {
2192 /* Don't do anything when rJoinTimeoutTimer is still ticking */
2194 /* 1. Process for pending scan */
2195 if (aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_SCAN
, TRUE
) ==
2197 wlanClearScanningResult(prAdapter
);
2198 eNextState
= AIS_STATE_ONLINE_SCAN
;
2199 fgIsTransition
= TRUE
;
2201 /* 2. Process for pending roaming scan */
2202 else if (aisFsmIsRequestPending
2203 (prAdapter
, AIS_REQUEST_ROAMING_SEARCH
, TRUE
) == TRUE
) {
2204 eNextState
= AIS_STATE_LOOKING_FOR
;
2205 fgIsTransition
= TRUE
;
2207 /* 3. Process for pending roaming scan */
2208 else if (aisFsmIsRequestPending
2209 (prAdapter
, AIS_REQUEST_ROAMING_CONNECT
, TRUE
) == TRUE
) {
2210 eNextState
= AIS_STATE_SEARCH
;
2211 fgIsTransition
= TRUE
;
2217 case AIS_STATE_DISCONNECTING
:
2218 /* send for deauth frame for disconnection */
2219 authSendDeauthFrame(prAdapter
,
2220 prAisBssInfo
->prStaRecOfAP
,
2222 REASON_CODE_DEAUTH_LEAVING_BSS
, aisDeauthXmitComplete
);
2226 ASSERT(0); /* Make sure we have handle all STATEs */
2231 while (fgIsTransition
);
2235 } /* end of aisFsmSteps() */
2238 /*----------------------------------------------------------------------------*/
2246 /*----------------------------------------------------------------------------*/
2247 VOID
aisFsmRunEventScanDone(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
)
2249 P_MSG_SCN_SCAN_DONE prScanDoneMsg
;
2250 P_AIS_FSM_INFO_T prAisFsmInfo
;
2251 ENUM_AIS_STATE_T eNextState
;
2252 UINT_8 ucSeqNumOfCompMsg
;
2253 P_CONNECTION_SETTINGS_T prConnSettings
;
2255 DEBUGFUNC("aisFsmRunEventScanDone()");
2260 DBGLOG(AIS
, LOUD
, ("EVENT-SCAN DONE: Current Time = %ld\n", kalGetTimeTick()));
2262 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
2263 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2265 prScanDoneMsg
= (P_MSG_SCN_SCAN_DONE
) prMsgHdr
;
2266 ASSERT(prScanDoneMsg
->ucNetTypeIndex
== (UINT_8
) NETWORK_TYPE_AIS_INDEX
);
2268 ucSeqNumOfCompMsg
= prScanDoneMsg
->ucSeqNum
;
2269 cnmMemFree(prAdapter
, prMsgHdr
);
2271 eNextState
= prAisFsmInfo
->eCurrentState
;
2273 if (ucSeqNumOfCompMsg
!= prAisFsmInfo
->ucSeqNumOfScanReq
) {
2274 DBGLOG(AIS
, WARN
, ("SEQ NO of AIS SCN DONE MSG is not matched.\n"));
2276 switch (prAisFsmInfo
->eCurrentState
) {
2277 case AIS_STATE_SCAN
:
2278 prConnSettings
->fgIsScanReqIssued
= FALSE
;
2280 /* reset scan IE buffer */
2281 prAisFsmInfo
->u4ScanIELength
= 0;
2283 kalScanDone(prAdapter
->prGlueInfo
, KAL_NETWORK_TYPE_AIS_INDEX
,
2284 WLAN_STATUS_SUCCESS
);
2285 eNextState
= AIS_STATE_IDLE
;
2289 case AIS_STATE_ONLINE_SCAN
:
2290 prConnSettings
->fgIsScanReqIssued
= FALSE
;
2292 /* reset scan IE buffer */
2293 prAisFsmInfo
->u4ScanIELength
= 0;
2295 kalScanDone(prAdapter
->prGlueInfo
, KAL_NETWORK_TYPE_AIS_INDEX
,
2296 WLAN_STATUS_SUCCESS
);
2297 #if CFG_SUPPORT_ROAMING
2298 eNextState
= aisFsmRoamingScanResultsUpdate(prAdapter
);
2300 eNextState
= AIS_STATE_NORMAL_TR
;
2301 #endif /* CFG_SUPPORT_ROAMING */
2305 case AIS_STATE_LOOKING_FOR
:
2306 #if CFG_SUPPORT_ROAMING
2307 eNextState
= aisFsmRoamingScanResultsUpdate(prAdapter
);
2309 eNextState
= AIS_STATE_SEARCH
;
2310 #endif /* CFG_SUPPORT_ROAMING */
2319 if (eNextState
!= prAisFsmInfo
->eCurrentState
) {
2320 aisFsmSteps(prAdapter
, eNextState
);
2324 } /* end of aisFsmRunEventScanDone() */
2327 /*----------------------------------------------------------------------------*/
2335 /*----------------------------------------------------------------------------*/
2336 VOID
aisFsmRunEventAbort(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
)
2338 P_MSG_AIS_ABORT_T prAisAbortMsg
;
2339 P_AIS_FSM_INFO_T prAisFsmInfo
;
2340 UINT_8 ucReasonOfDisconnect
;
2341 BOOLEAN fgDelayIndication
;
2342 P_CONNECTION_SETTINGS_T prConnSettings
;
2344 DEBUGFUNC("aisFsmRunEventAbort()");
2348 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
2349 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2351 /* 4 <1> Extract information of Abort Message and then free memory. */
2352 prAisAbortMsg
= (P_MSG_AIS_ABORT_T
) prMsgHdr
;
2353 ucReasonOfDisconnect
= prAisAbortMsg
->ucReasonOfDisconnect
;
2354 fgDelayIndication
= prAisAbortMsg
->fgDelayIndication
;
2356 cnmMemFree(prAdapter
, prMsgHdr
);
2359 DBGLOG(AIS
, LOUD
, ("EVENT-ABORT: Current State %s\n",
2360 apucDebugAisState
[prAisFsmInfo
->eCurrentState
]));
2362 DBGLOG(AIS
, LOUD
, ("[%d] EVENT-ABORT: Current State [%d]\n",
2363 DBG_AIS_IDX
, prAisFsmInfo
->eCurrentState
));
2366 /* 4 <2> clear previous pending connection request and insert new one */
2367 if (ucReasonOfDisconnect
== DISCONNECT_REASON_CODE_DEAUTHENTICATED
2368 || ucReasonOfDisconnect
== DISCONNECT_REASON_CODE_DISASSOCIATED
) {
2369 prConnSettings
->fgIsDisconnectedByNonRequest
= TRUE
;
2371 prConnSettings
->fgIsDisconnectedByNonRequest
= FALSE
;
2374 aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_RECONNECT
, TRUE
);
2375 aisFsmInsertRequest(prAdapter
, AIS_REQUEST_RECONNECT
);
2377 if (prAisFsmInfo
->eCurrentState
!= AIS_STATE_DISCONNECTING
) {
2378 /* 4 <3> invoke abort handler */
2379 aisFsmStateAbort(prAdapter
, ucReasonOfDisconnect
, fgDelayIndication
);
2383 } /* end of aisFsmRunEventAbort() */
2386 /*----------------------------------------------------------------------------*/
2388 * \brief This function handles AIS-FSM abort event/command
2390 * \param[in] prAdapter Pointer of ADAPTER_T
2391 * ucReasonOfDisconnect Reason for disonnection
2392 * fgDelayIndication Option to delay disconnection indication
2396 /*----------------------------------------------------------------------------*/
2398 aisFsmStateAbort(IN P_ADAPTER_T prAdapter
, UINT_8 ucReasonOfDisconnect
, BOOLEAN fgDelayIndication
)
2400 P_AIS_FSM_INFO_T prAisFsmInfo
;
2401 P_BSS_INFO_T prAisBssInfo
;
2402 P_CONNECTION_SETTINGS_T prConnSettings
;
2403 BOOLEAN fgIsCheckConnected
;
2407 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
2408 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
2409 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2410 fgIsCheckConnected
= FALSE
;
2412 /* 4 <1> Save information of Abort Message and then free memory. */
2413 prAisBssInfo
->ucReasonOfDisconnect
= ucReasonOfDisconnect
;
2415 /* 4 <2> Abort current job. */
2416 switch (prAisFsmInfo
->eCurrentState
) {
2417 case AIS_STATE_IDLE
:
2418 case AIS_STATE_SEARCH
:
2421 case AIS_STATE_WAIT_FOR_NEXT_SCAN
:
2422 /* Do cancel timer */
2423 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rBGScanTimer
);
2425 /* in case roaming is triggered */
2426 fgIsCheckConnected
= TRUE
;
2429 case AIS_STATE_SCAN
:
2431 aisFsmStateAbort_SCAN(prAdapter
);
2433 /* queue for later handling */
2434 if (aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_SCAN
, FALSE
) == FALSE
) {
2435 aisFsmInsertRequest(prAdapter
, AIS_REQUEST_SCAN
);
2440 case AIS_STATE_LOOKING_FOR
:
2442 aisFsmStateAbort_SCAN(prAdapter
);
2444 /* in case roaming is triggered */
2445 fgIsCheckConnected
= TRUE
;
2448 case AIS_STATE_REQ_CHANNEL_JOIN
:
2449 /* Release channel to CNM */
2450 aisFsmReleaseCh(prAdapter
);
2452 /* in case roaming is triggered */
2453 fgIsCheckConnected
= TRUE
;
2456 case AIS_STATE_JOIN
:
2458 aisFsmStateAbort_JOIN(prAdapter
);
2460 /* in case roaming is triggered */
2461 fgIsCheckConnected
= TRUE
;
2464 #if CFG_SUPPORT_ADHOC
2465 case AIS_STATE_IBSS_ALONE
:
2466 case AIS_STATE_IBSS_MERGE
:
2467 aisFsmStateAbort_IBSS(prAdapter
);
2469 #endif /* CFG_SUPPORT_ADHOC */
2471 case AIS_STATE_ONLINE_SCAN
:
2473 aisFsmStateAbort_SCAN(prAdapter
);
2475 /* queue for later handling */
2476 if (aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_SCAN
, FALSE
) == FALSE
) {
2477 aisFsmInsertRequest(prAdapter
, AIS_REQUEST_SCAN
);
2480 fgIsCheckConnected
= TRUE
;
2483 case AIS_STATE_NORMAL_TR
:
2484 fgIsCheckConnected
= TRUE
;
2487 case AIS_STATE_DISCONNECTING
:
2488 /* Do abort NORMAL_TR */
2489 aisFsmStateAbort_NORMAL_TR(prAdapter
);
2497 if (fgIsCheckConnected
&& (PARAM_MEDIA_STATE_CONNECTED
== prAisBssInfo
->eConnectionState
)) {
2499 /* switch into DISCONNECTING state for sending DEAUTH if necessary */
2500 if (prAisBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
&&
2501 prAisBssInfo
->ucReasonOfDisconnect
== DISCONNECT_REASON_CODE_NEW_CONNECTION
&&
2502 prAisBssInfo
->prStaRecOfAP
&& prAisBssInfo
->prStaRecOfAP
->fgIsInUse
) {
2503 aisFsmSteps(prAdapter
, AIS_STATE_DISCONNECTING
);
2507 /* Do abort NORMAL_TR */
2508 aisFsmStateAbort_NORMAL_TR(prAdapter
);
2512 aisFsmDisconnect(prAdapter
, fgDelayIndication
);
2516 } /* end of aisFsmStateAbort() */
2519 /*----------------------------------------------------------------------------*/
2521 * @brief This function will handle the Join Complete Event from SAA FSM for AIS FSM
2523 * @param[in] prMsgHdr Message of Join Complete of SAA FSM.
2527 /*----------------------------------------------------------------------------*/
2528 VOID
aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
)
2530 P_MSG_JOIN_COMP_T prJoinCompMsg
;
2531 P_AIS_FSM_INFO_T prAisFsmInfo
;
2532 ENUM_AIS_STATE_T eNextState
;
2533 P_STA_RECORD_T prStaRec
;
2534 P_SW_RFB_T prAssocRspSwRfb
;
2536 DEBUGFUNC("aisFsmRunEventJoinComplete()");
2540 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
2541 prJoinCompMsg
= (P_MSG_JOIN_COMP_T
) prMsgHdr
;
2542 prStaRec
= prJoinCompMsg
->prStaRec
;
2543 prAssocRspSwRfb
= prJoinCompMsg
->prSwRfb
;
2545 eNextState
= prAisFsmInfo
->eCurrentState
;
2547 /* Check State and SEQ NUM */
2549 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_JOIN
) {
2550 P_BSS_INFO_T prAisBssInfo
;
2552 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
2555 if (prJoinCompMsg
->ucSeqNum
== prAisFsmInfo
->ucSeqNumOfReqMsg
) {
2558 /* 4 <1> JOIN was successful */
2559 if (prJoinCompMsg
->rJoinStatus
== WLAN_STATUS_SUCCESS
) {
2561 /* 1. Reset retry count */
2562 prAisFsmInfo
->ucConnTrialCount
= 0;
2564 /* Completion of roaming */
2565 if (prAisBssInfo
->eConnectionState
== PARAM_MEDIA_STATE_CONNECTED
) {
2567 #if CFG_SUPPORT_ROAMING
2568 /* 2. Deactivate previous BSS */
2569 aisFsmRoamingDisconnectPrevAP(prAdapter
, prStaRec
);
2571 /* 3. Update bss based on roaming staRec */
2572 aisUpdateBssInfoForRoamingAP(prAdapter
, prStaRec
,
2574 #endif /* CFG_SUPPORT_ROAMING */
2576 /* 4 <1.1> Change FW's Media State immediately. */
2577 aisChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_CONNECTED
);
2579 /* 4 <1.2> Deactivate previous AP's STA_RECORD_T in Driver if have. */
2580 if ((prAisBssInfo
->prStaRecOfAP
) &&
2581 (prAisBssInfo
->prStaRecOfAP
!= prStaRec
) &&
2582 (prAisBssInfo
->prStaRecOfAP
->fgIsInUse
)) {
2584 cnmStaRecChangeState(prAdapter
,
2585 prAisBssInfo
->prStaRecOfAP
,
2588 /* 4 <1.3> Update BSS_INFO_T */
2589 aisUpdateBssInfoForJOIN(prAdapter
, prStaRec
,
2592 /* 4 <1.4> Activate current AP's STA_RECORD_T in Driver. */
2593 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_3
);
2595 /* 4 <1.5> Update RSSI if necessary */
2596 nicUpdateRSSI(prAdapter
, NETWORK_TYPE_AIS_INDEX
,
2597 (INT_8
) (RCPI_TO_dBm(prStaRec
->ucRCPI
)), 0);
2599 /* 4 <1.6> Indicate Connected Event to Host immediately. */
2600 /* Require BSSID, Association ID, Beacon Interval.. from AIS_BSS_INFO_T */
2601 aisIndicationOfMediaStateToHost(prAdapter
,
2602 PARAM_MEDIA_STATE_CONNECTED
,
2606 #if CFG_SUPPORT_ROAMING
2607 roamingFsmRunEventStart(prAdapter
);
2608 #endif /* CFG_SUPPORT_ROAMING */
2610 /* 4 <1.7> Set the Next State of AIS FSM */
2611 eNextState
= AIS_STATE_NORMAL_TR
;
2613 /* 4 <2> JOIN was not successful */
2615 /* 4 <2.1> Redo JOIN process with other Auth Type if possible */
2616 if (aisFsmStateInit_RetryJOIN(prAdapter
, prStaRec
) == FALSE
) {
2617 P_BSS_DESC_T prBssDesc
;
2619 /* 1. Increase Failure Count */
2620 prStaRec
->ucJoinFailureCount
++;
2622 /* 2. release channel */
2623 aisFsmReleaseCh(prAdapter
);
2625 /* 3.1 stop join timeout timer */
2626 cnmTimerStopTimer(prAdapter
,
2627 &prAisFsmInfo
->rJoinTimeoutTimer
);
2629 /* 3.2 reset local variable */
2630 prAisFsmInfo
->fgIsInfraChannelFinished
= TRUE
;
2633 scanSearchBssDescByBssid(prAdapter
,
2634 prStaRec
->aucMacAddr
);
2635 if (prBssDesc
== NULL
)
2638 //ASSERT(prBssDesc);
2639 //ASSERT(prBssDesc->fgIsConnecting);
2642 prBssDesc
->fgIsConnecting
= FALSE
;
2645 /* 3.3 Free STA-REC */
2646 if (prStaRec
!= prAisBssInfo
->prStaRecOfAP
) {
2647 cnmStaRecFree(prAdapter
, prStaRec
, FALSE
);
2650 if (prAisBssInfo
->eConnectionState
==
2651 PARAM_MEDIA_STATE_CONNECTED
) {
2652 #if CFG_SUPPORT_ROAMING
2653 eNextState
= AIS_STATE_WAIT_FOR_NEXT_SCAN
;
2654 #endif /* CFG_SUPPORT_ROAMING */
2656 /* abort connection trial */
2657 prAdapter
->rWifiVar
.rConnSettings
.
2658 fgIsConnReqIssued
= FALSE
;
2660 kalIndicateStatusAndComplete(prAdapter
->prGlueInfo
,
2661 WLAN_STATUS_CONNECT_INDICATION
,
2664 eNextState
= AIS_STATE_IDLE
;
2671 DBGLOG(AIS
, WARN
, ("SEQ NO of AIS JOIN COMP MSG is not matched.\n"));
2677 if (eNextState
!= prAisFsmInfo
->eCurrentState
) {
2678 aisFsmSteps(prAdapter
, eNextState
);
2682 if (prAssocRspSwRfb
) {
2683 nicRxReturnRFB(prAdapter
, prAssocRspSwRfb
);
2686 cnmMemFree(prAdapter
, prMsgHdr
);
2689 } /* end of aisFsmRunEventJoinComplete() */
2692 #if CFG_SUPPORT_ADHOC
2693 /*----------------------------------------------------------------------------*/
2695 * @brief This function will handle the Grant Msg of IBSS Create which was sent by
2696 * CNM to indicate that channel was changed for creating IBSS.
2698 * @param[in] prAdapter Pointer of ADAPTER_T
2702 /*----------------------------------------------------------------------------*/
2703 VOID
aisFsmCreateIBSS(IN P_ADAPTER_T prAdapter
)
2705 P_AIS_FSM_INFO_T prAisFsmInfo
;
2709 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
2713 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_IBSS_ALONE
) {
2714 aisUpdateBssInfoForCreateIBSS(prAdapter
);
2720 } /* end of aisFsmCreateIBSS() */
2723 /*----------------------------------------------------------------------------*/
2725 * @brief This function will handle the Grant Msg of IBSS Merge which was sent by
2726 * CNM to indicate that channel was changed for merging IBSS.
2728 * @param[in] prAdapter Pointer of ADAPTER_T
2729 * @param[in] prStaRec Pointer of STA_RECORD_T for merge
2733 /*----------------------------------------------------------------------------*/
2734 VOID
aisFsmMergeIBSS(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prStaRec
)
2736 P_AIS_FSM_INFO_T prAisFsmInfo
;
2737 ENUM_AIS_STATE_T eNextState
;
2738 P_BSS_INFO_T prAisBssInfo
;
2743 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
2744 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
2748 eNextState
= prAisFsmInfo
->eCurrentState
;
2750 switch (prAisFsmInfo
->eCurrentState
) {
2751 case AIS_STATE_IBSS_MERGE
:
2753 P_BSS_DESC_T prBssDesc
;
2755 /* 4 <1.1> Change FW's Media State immediately. */
2756 aisChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_CONNECTED
);
2758 /* 4 <1.2> Deactivate previous Peers' STA_RECORD_T in Driver if have. */
2759 bssClearClientList(prAdapter
, prAisBssInfo
);
2761 /* 4 <1.3> Unmark connection flag of previous BSS_DESC_T. */
2763 scanSearchBssDescByBssid(prAdapter
,
2764 prAisBssInfo
->aucBSSID
)) != NULL
) {
2765 prBssDesc
->fgIsConnecting
= FALSE
;
2766 prBssDesc
->fgIsConnected
= FALSE
;
2768 /* 4 <1.4> Update BSS_INFO_T */
2769 aisUpdateBssInfoForMergeIBSS(prAdapter
, prStaRec
);
2771 /* 4 <1.5> Add Peers' STA_RECORD_T to Client List */
2772 bssAddStaRecToClientList(prAdapter
, prAisBssInfo
, prStaRec
);
2774 /* 4 <1.6> Activate current Peer's STA_RECORD_T in Driver. */
2775 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_3
);
2776 prStaRec
->fgIsMerging
= FALSE
;
2778 /* 4 <1.7> Enable other features */
2780 /* 4 <1.8> Indicate Connected Event to Host immediately. */
2781 aisIndicationOfMediaStateToHost(prAdapter
,
2782 PARAM_MEDIA_STATE_CONNECTED
, FALSE
);
2784 /* 4 <1.9> Set the Next State of AIS FSM */
2785 eNextState
= AIS_STATE_NORMAL_TR
;
2787 /* 4 <1.10> Release channel privilege */
2788 aisFsmReleaseCh(prAdapter
);
2791 prAdapter
->rWifiVar
.rSltInfo
.prPseudoStaRec
= prStaRec
;
2800 if (eNextState
!= prAisFsmInfo
->eCurrentState
) {
2801 aisFsmSteps(prAdapter
, eNextState
);
2808 } /* end of aisFsmMergeIBSS() */
2811 /*----------------------------------------------------------------------------*/
2813 * @brief This function will handle the Notification of existing IBSS was found
2816 * @param[in] prMsgHdr Message of Notification of an IBSS was present.
2820 /*----------------------------------------------------------------------------*/
2821 VOID
aisFsmRunEventFoundIBSSPeer(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
)
2823 P_MSG_AIS_IBSS_PEER_FOUND_T prAisIbssPeerFoundMsg
;
2824 P_AIS_FSM_INFO_T prAisFsmInfo
;
2825 ENUM_AIS_STATE_T eNextState
;
2826 P_STA_RECORD_T prStaRec
;
2827 P_BSS_INFO_T prAisBssInfo
;
2828 P_BSS_DESC_T prBssDesc
;
2829 BOOLEAN fgIsMergeIn
;
2834 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
2835 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
2837 prAisIbssPeerFoundMsg
= (P_MSG_AIS_IBSS_PEER_FOUND_T
) prMsgHdr
;
2839 ASSERT(prAisIbssPeerFoundMsg
->ucNetTypeIndex
== NETWORK_TYPE_AIS_INDEX
);
2841 prStaRec
= prAisIbssPeerFoundMsg
->prStaRec
;
2844 fgIsMergeIn
= prAisIbssPeerFoundMsg
->fgIsMergeIn
;
2846 cnmMemFree(prAdapter
, prMsgHdr
);
2849 eNextState
= prAisFsmInfo
->eCurrentState
;
2850 switch (prAisFsmInfo
->eCurrentState
) {
2851 case AIS_STATE_IBSS_ALONE
:
2853 /* 4 <1> An IBSS Peer 'merged in'. */
2856 /* 4 <1.1> Change FW's Media State immediately. */
2857 aisChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_CONNECTED
);
2859 /* 4 <1.2> Add Peers' STA_RECORD_T to Client List */
2860 bssAddStaRecToClientList(prAdapter
, prAisBssInfo
, prStaRec
);
2863 /* 4 <1.3> Mark connection flag of BSS_DESC_T. */
2865 scanSearchBssDescByTA(prAdapter
,
2866 prStaRec
->aucMacAddr
)) != NULL
) {
2867 prBssDesc
->fgIsConnecting
= FALSE
;
2868 prBssDesc
->fgIsConnected
= TRUE
;
2870 ASSERT(0); /* Should be able to find a BSS_DESC_T here. */
2873 /* 4 <1.4> Activate current Peer's STA_RECORD_T in Driver. */
2874 prStaRec
->fgIsQoS
= TRUE
; /* TODO(Kevin): TBD */
2876 /* 4 <1.3> Mark connection flag of BSS_DESC_T. */
2878 scanSearchBssDescByBssid(prAdapter
,
2879 prAisBssInfo
->aucBSSID
)) != NULL
) {
2880 prBssDesc
->fgIsConnecting
= FALSE
;
2881 prBssDesc
->fgIsConnected
= TRUE
;
2883 ASSERT(0); /* Should be able to find a BSS_DESC_T here. */
2887 /* 4 <1.4> Activate current Peer's STA_RECORD_T in Driver. */
2888 prStaRec
->fgIsQoS
= FALSE
; /* TODO(Kevin): TBD */
2892 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_3
);
2893 prStaRec
->fgIsMerging
= FALSE
;
2895 /* 4 <1.6> sync. to firmware */
2896 nicUpdateBss(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
2898 /* 4 <1.7> Indicate Connected Event to Host immediately. */
2899 aisIndicationOfMediaStateToHost(prAdapter
,
2900 PARAM_MEDIA_STATE_CONNECTED
, FALSE
);
2902 /* 4 <1.8> indicate PM for connected */
2903 nicPmIndicateBssConnected(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
2905 /* 4 <1.9> Set the Next State of AIS FSM */
2906 eNextState
= AIS_STATE_NORMAL_TR
;
2908 /* 4 <1.10> Release channel privilege */
2909 aisFsmReleaseCh(prAdapter
);
2911 /* 4 <2> We need 'merge out' to this IBSS */
2914 /* 4 <2.1> Get corresponding BSS_DESC_T */
2915 prBssDesc
= scanSearchBssDescByTA(prAdapter
, prStaRec
->aucMacAddr
);
2917 prAisFsmInfo
->prTargetBssDesc
= prBssDesc
;
2919 /* 4 <2.2> Set the Next State of AIS FSM */
2920 eNextState
= AIS_STATE_IBSS_MERGE
;
2925 case AIS_STATE_NORMAL_TR
:
2928 /* 4 <3> An IBSS Peer 'merged in'. */
2931 /* 4 <3.1> Add Peers' STA_RECORD_T to Client List */
2932 bssAddStaRecToClientList(prAdapter
, prAisBssInfo
, prStaRec
);
2935 /* 4 <3.2> Activate current Peer's STA_RECORD_T in Driver. */
2936 prStaRec
->fgIsQoS
= TRUE
; /* TODO(Kevin): TBD */
2938 /* 4 <3.2> Activate current Peer's STA_RECORD_T in Driver. */
2939 prStaRec
->fgIsQoS
= FALSE
; /* TODO(Kevin): TBD */
2942 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_3
);
2943 prStaRec
->fgIsMerging
= FALSE
;
2946 /* 4 <4> We need 'merge out' to this IBSS */
2949 /* 4 <4.1> Get corresponding BSS_DESC_T */
2950 prBssDesc
= scanSearchBssDescByTA(prAdapter
, prStaRec
->aucMacAddr
);
2952 prAisFsmInfo
->prTargetBssDesc
= prBssDesc
;
2954 /* 4 <4.2> Set the Next State of AIS FSM */
2955 eNextState
= AIS_STATE_IBSS_MERGE
;
2965 if (eNextState
!= prAisFsmInfo
->eCurrentState
) {
2966 aisFsmSteps(prAdapter
, eNextState
);
2970 } /* end of aisFsmRunEventFoundIBSSPeer() */
2971 #endif /* CFG_SUPPORT_ADHOC */
2974 /*----------------------------------------------------------------------------*/
2976 * @brief This function will indicate the Media State to HOST
2978 * @param[in] eConnectionState Current Media State
2979 * @param[in] fgDelayIndication Set TRUE for postponing the Disconnect Indication.
2983 /*----------------------------------------------------------------------------*/
2985 aisIndicationOfMediaStateToHost(IN P_ADAPTER_T prAdapter
,
2986 ENUM_PARAM_MEDIA_STATE_T eConnectionState
,
2987 BOOLEAN fgDelayIndication
)
2989 EVENT_CONNECTION_STATUS rEventConnStatus
;
2990 P_CONNECTION_SETTINGS_T prConnSettings
;
2991 P_BSS_INFO_T prAisBssInfo
;
2992 P_AIS_FSM_INFO_T prAisFsmInfo
;
2994 DEBUGFUNC("aisIndicationOfMediaStateToHost()");
2996 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2997 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
2998 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3000 /* NOTE(Kevin): Move following line to aisChangeMediaState() macro per CM's request. */
3001 /* prAisBssInfo->eConnectionState = eConnectionState; */
3003 /* For indicating the Disconnect Event only if current media state is
3004 * disconnected and we didn't do indication yet.
3006 if (prAisBssInfo
->eConnectionState
== PARAM_MEDIA_STATE_DISCONNECTED
) {
3007 if (prAisBssInfo
->eConnectionStateIndicated
== eConnectionState
) {
3012 if (!fgDelayIndication
) {
3013 /* 4 <0> Cancel Delay Timer */
3014 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rIndicationOfDisconnectTimer
);
3016 /* 4 <1> Fill EVENT_CONNECTION_STATUS */
3017 rEventConnStatus
.ucMediaStatus
= (UINT_8
) eConnectionState
;
3019 if (eConnectionState
== PARAM_MEDIA_STATE_CONNECTED
) {
3020 rEventConnStatus
.ucReasonOfDisconnect
= DISCONNECT_REASON_CODE_RESERVED
;
3022 if (prAisBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
) {
3023 rEventConnStatus
.ucInfraMode
= (UINT_8
) NET_TYPE_INFRA
;
3024 rEventConnStatus
.u2AID
= prAisBssInfo
->u2AssocId
;
3025 rEventConnStatus
.u2ATIMWindow
= 0;
3026 } else if (prAisBssInfo
->eCurrentOPMode
== OP_MODE_IBSS
) {
3027 rEventConnStatus
.ucInfraMode
= (UINT_8
) NET_TYPE_IBSS
;
3028 rEventConnStatus
.u2AID
= 0;
3029 rEventConnStatus
.u2ATIMWindow
= prAisBssInfo
->u2ATIMWindow
;
3034 COPY_SSID(rEventConnStatus
.aucSsid
,
3035 rEventConnStatus
.ucSsidLen
,
3036 prConnSettings
->aucSSID
, prConnSettings
->ucSSIDLen
);
3038 COPY_MAC_ADDR(rEventConnStatus
.aucBssid
, prAisBssInfo
->aucBSSID
);
3040 rEventConnStatus
.u2BeaconPeriod
= prAisBssInfo
->u2BeaconInterval
;
3041 rEventConnStatus
.u4FreqInKHz
=
3042 nicChannelNum2Freq(prAisBssInfo
->ucPrimaryChannel
);
3044 switch (prAisBssInfo
->ucNonHTBasicPhyType
) {
3045 case PHY_TYPE_HR_DSSS_INDEX
:
3046 rEventConnStatus
.ucNetworkType
= (UINT_8
) PARAM_NETWORK_TYPE_DS
;
3049 case PHY_TYPE_ERP_INDEX
:
3050 rEventConnStatus
.ucNetworkType
= (UINT_8
) PARAM_NETWORK_TYPE_OFDM24
;
3053 case PHY_TYPE_OFDM_INDEX
:
3054 rEventConnStatus
.ucNetworkType
= (UINT_8
) PARAM_NETWORK_TYPE_OFDM5
;
3059 rEventConnStatus
.ucNetworkType
= (UINT_8
) PARAM_NETWORK_TYPE_DS
;
3063 /* Deactivate previous Peers' STA_RECORD_T in Driver if have. */
3064 bssClearClientList(prAdapter
, prAisBssInfo
);
3066 #if CFG_PRIVACY_MIGRATION
3067 /* Clear the pmkid cache while media disconnect */
3068 secClearPmkid(prAdapter
);
3071 rEventConnStatus
.ucReasonOfDisconnect
= prAisBssInfo
->ucReasonOfDisconnect
;
3074 /* 4 <2> Indication */
3075 nicMediaStateChange(prAdapter
, NETWORK_TYPE_AIS_INDEX
, &rEventConnStatus
);
3076 prAisBssInfo
->eConnectionStateIndicated
= eConnectionState
;
3078 /* NOTE: Only delay the Indication of Disconnect Event */
3079 ASSERT(eConnectionState
== PARAM_MEDIA_STATE_DISCONNECTED
);
3081 DBGLOG(AIS
, INFO
, ("Postpone the indication of Disconnect for %d seconds\n",
3082 prConnSettings
->ucDelayTimeOfDisconnectEvent
));
3084 cnmTimerStartTimer(prAdapter
,
3085 &prAisFsmInfo
->rIndicationOfDisconnectTimer
,
3086 SEC_TO_MSEC(prConnSettings
->ucDelayTimeOfDisconnectEvent
));
3090 } /* end of aisIndicationOfMediaStateToHost() */
3093 /*----------------------------------------------------------------------------*/
3095 * @brief This function will indicate an Event of "Media Disconnect" to HOST
3097 * @param[in] u4Param Unused timer parameter
3101 /*----------------------------------------------------------------------------*/
3102 VOID
aisPostponedEventOfDisconnTimeout(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
)
3104 P_BSS_INFO_T prAisBssInfo
;
3105 P_CONNECTION_SETTINGS_T prConnSettings
;
3107 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3108 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
3110 /* 4 <1> Deactivate previous AP's STA_RECORD_T in Driver if have. */
3111 if (prAisBssInfo
->prStaRecOfAP
) {
3112 /* cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1); */
3114 prAisBssInfo
->prStaRecOfAP
= (P_STA_RECORD_T
) NULL
;
3116 /* 4 <2> Remove pending connection request */
3117 aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_RECONNECT
, TRUE
);
3118 prConnSettings
->fgIsDisconnectedByNonRequest
= TRUE
;
3120 /* 4 <3> Indicate Disconnected Event to Host immediately. */
3121 aisIndicationOfMediaStateToHost(prAdapter
, PARAM_MEDIA_STATE_DISCONNECTED
, FALSE
);
3124 } /* end of aisPostponedEventOfDisconnTimeout() */
3127 /*----------------------------------------------------------------------------*/
3129 * @brief This function will update the contain of BSS_INFO_T for AIS network once
3130 * the association was completed.
3132 * @param[in] prStaRec Pointer to the STA_RECORD_T
3133 * @param[in] prAssocRspSwRfb Pointer to SW RFB of ASSOC RESP FRAME.
3137 /*----------------------------------------------------------------------------*/
3139 aisUpdateBssInfoForJOIN(IN P_ADAPTER_T prAdapter
,
3140 P_STA_RECORD_T prStaRec
, P_SW_RFB_T prAssocRspSwRfb
)
3142 P_AIS_FSM_INFO_T prAisFsmInfo
;
3143 P_BSS_INFO_T prAisBssInfo
;
3144 P_CONNECTION_SETTINGS_T prConnSettings
;
3145 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame
;
3146 P_BSS_DESC_T prBssDesc
;
3150 DEBUGFUNC("aisUpdateBssInfoForJOIN()");
3153 ASSERT(prAssocRspSwRfb
);
3155 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3156 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3157 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
3158 prAssocRspFrame
= (P_WLAN_ASSOC_RSP_FRAME_T
) prAssocRspSwRfb
->pvHeader
;
3161 DBGLOG(AIS
, INFO
, ("Update AIS_BSS_INFO_T and apply settings to MAC\n"));
3164 /* 3 <1> Update BSS_INFO_T from AIS_FSM_INFO_T or User Settings */
3165 /* 4 <1.1> Setup Operation Mode */
3166 prAisBssInfo
->eCurrentOPMode
= OP_MODE_INFRASTRUCTURE
;
3168 /* 4 <1.2> Setup SSID */
3169 COPY_SSID(prAisBssInfo
->aucSSID
,
3170 prAisBssInfo
->ucSSIDLen
, prConnSettings
->aucSSID
, prConnSettings
->ucSSIDLen
);
3172 /* 4 <1.3> Setup Channel, Band */
3173 prAisBssInfo
->ucPrimaryChannel
= prAisFsmInfo
->prTargetBssDesc
->ucChannelNum
;
3174 prAisBssInfo
->eBand
= prAisFsmInfo
->prTargetBssDesc
->eBand
;
3177 /* 3 <2> Update BSS_INFO_T from STA_RECORD_T */
3178 /* 4 <2.1> Save current AP's STA_RECORD_T and current AID */
3179 prAisBssInfo
->prStaRecOfAP
= prStaRec
;
3180 prAisBssInfo
->u2AssocId
= prStaRec
->u2AssocId
;
3182 /* 4 <2.2> Setup Capability */
3183 prAisBssInfo
->u2CapInfo
= prStaRec
->u2CapInfo
; /* Use AP's Cap Info as BSS Cap Info */
3185 if (prAisBssInfo
->u2CapInfo
& CAP_INFO_SHORT_PREAMBLE
) {
3186 prAisBssInfo
->fgIsShortPreambleAllowed
= TRUE
;
3188 prAisBssInfo
->fgIsShortPreambleAllowed
= FALSE
;
3191 /* 4 <2.3> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
3192 prAisBssInfo
->ucPhyTypeSet
= prStaRec
->ucDesiredPhyTypeSet
;
3194 prAisBssInfo
->ucNonHTBasicPhyType
= prStaRec
->ucNonHTBasicPhyType
;
3196 prAisBssInfo
->u2OperationalRateSet
= prStaRec
->u2OperationalRateSet
;
3197 prAisBssInfo
->u2BSSBasicRateSet
= prStaRec
->u2BSSBasicRateSet
;
3200 /* 3 <3> Update BSS_INFO_T from SW_RFB_T (Association Resp Frame) */
3201 /* 4 <3.1> Setup BSSID */
3202 COPY_MAC_ADDR(prAisBssInfo
->aucBSSID
, prAssocRspFrame
->aucBSSID
);
3205 u2IELength
= (UINT_16
) ((prAssocRspSwRfb
->u2PacketLen
- prAssocRspSwRfb
->u2HeaderLen
) -
3206 (OFFSET_OF(WLAN_ASSOC_RSP_FRAME_T
, aucInfoElem
[0]) -
3207 WLAN_MAC_MGMT_HEADER_LEN
));
3208 pucIE
= prAssocRspFrame
->aucInfoElem
;
3211 /* 4 <3.2> Parse WMM and setup QBSS flag */
3212 /* Parse WMM related IEs and configure HW CRs accordingly */
3213 mqmProcessAssocRsp(prAdapter
, prAssocRspSwRfb
, pucIE
, u2IELength
);
3215 prAisBssInfo
->fgIsQBSS
= prStaRec
->fgIsQoS
;
3217 /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
3218 prBssDesc
= scanSearchBssDescByBssid(prAdapter
, prAssocRspFrame
->aucBSSID
);
3220 prBssDesc
->fgIsConnecting
= FALSE
;
3221 prBssDesc
->fgIsConnected
= TRUE
;
3223 /* 4 <4.1> Setup MIB for current BSS */
3224 prAisBssInfo
->u2BeaconInterval
= prBssDesc
->u2BeaconInterval
;
3226 /* should never happen */
3230 /* NOTE: Defer ucDTIMPeriod updating to when beacon is received after connection */
3231 prAisBssInfo
->ucDTIMPeriod
= 0;
3232 prAisBssInfo
->u2ATIMWindow
= 0;
3234 prAisBssInfo
->ucBeaconTimeoutCount
= AIS_BEACON_TIMEOUT_COUNT_INFRA
;
3236 /* 4 <4.2> Update HT information and set channel */
3237 /* Record HT related parameters in rStaRec and rBssInfo
3238 * Note: it shall be called before nicUpdateBss()
3240 rlmProcessAssocRsp(prAdapter
, prAssocRspSwRfb
, pucIE
, u2IELength
);
3242 /* 4 <4.3> Sync with firmware for BSS-INFO */
3243 nicUpdateBss(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3245 /* 4 <4.4> *DEFER OPERATION* nicPmIndicateBssConnected() will be invoked */
3246 /* inside scanProcessBeaconAndProbeResp() after 1st beacon is received */
3249 } /* end of aisUpdateBssInfoForJOIN() */
3252 #if CFG_SUPPORT_ADHOC
3253 /*----------------------------------------------------------------------------*/
3255 * @brief This function will create an Ad-Hoc network and start sending Beacon Frames.
3261 /*----------------------------------------------------------------------------*/
3262 VOID
aisUpdateBssInfoForCreateIBSS(IN P_ADAPTER_T prAdapter
)
3264 P_AIS_FSM_INFO_T prAisFsmInfo
;
3265 P_BSS_INFO_T prAisBssInfo
;
3266 P_CONNECTION_SETTINGS_T prConnSettings
;
3268 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3269 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3270 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
3272 if (prAisBssInfo
->fgIsBeaconActivated
) {
3275 /* 3 <1> Update BSS_INFO_T per Network Basis */
3276 /* 4 <1.1> Setup Operation Mode */
3277 prAisBssInfo
->eCurrentOPMode
= OP_MODE_IBSS
;
3279 /* 4 <1.2> Setup SSID */
3280 COPY_SSID(prAisBssInfo
->aucSSID
,
3281 prAisBssInfo
->ucSSIDLen
, prConnSettings
->aucSSID
, prConnSettings
->ucSSIDLen
);
3283 /* 4 <1.3> Clear current AP's STA_RECORD_T and current AID */
3284 prAisBssInfo
->prStaRecOfAP
= (P_STA_RECORD_T
) NULL
;
3285 prAisBssInfo
->u2AssocId
= 0;
3287 /* 4 <1.4> Setup Channel, Band and Phy Attributes */
3288 prAisBssInfo
->ucPrimaryChannel
= prConnSettings
->ucAdHocChannelNum
;
3289 prAisBssInfo
->eBand
= prConnSettings
->eAdHocBand
;
3291 if (prAisBssInfo
->eBand
== BAND_2G4
) {
3293 prAisBssInfo
->ucPhyTypeSet
= prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
& PHY_TYPE_SET_802_11BGN
; /* Depend on eBand */
3295 prAisBssInfo
->ucConfigAdHocAPMode
= AD_HOC_MODE_MIXED_11BG
; /* Depend on eCurrentOPMode and ucPhyTypeSet */
3298 prAisBssInfo
->ucPhyTypeSet
= prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
& PHY_TYPE_SET_802_11AN
; /* Depend on eBand */
3300 prAisBssInfo
->ucConfigAdHocAPMode
= AD_HOC_MODE_11A
; /* Depend on eCurrentOPMode and ucPhyTypeSet */
3303 /* 4 <1.5> Setup MIB for current BSS */
3304 prAisBssInfo
->u2BeaconInterval
= prConnSettings
->u2BeaconPeriod
;
3305 prAisBssInfo
->ucDTIMPeriod
= 0;
3306 prAisBssInfo
->u2ATIMWindow
= prConnSettings
->u2AtimWindow
;
3308 prAisBssInfo
->ucBeaconTimeoutCount
= AIS_BEACON_TIMEOUT_COUNT_ADHOC
;
3310 #if CFG_PRIVACY_MIGRATION
3311 if (prConnSettings
->eEncStatus
== ENUM_ENCRYPTION1_ENABLED
||
3312 prConnSettings
->eEncStatus
== ENUM_ENCRYPTION2_ENABLED
||
3313 prConnSettings
->eEncStatus
== ENUM_ENCRYPTION3_ENABLED
) {
3314 prAisBssInfo
->fgIsProtection
= TRUE
;
3316 prAisBssInfo
->fgIsProtection
= FALSE
;
3319 prAisBssInfo
->fgIsProtection
= FALSE
;
3322 /* 3 <2> Update BSS_INFO_T common part */
3323 ibssInitForAdHoc(prAdapter
, prAisBssInfo
);
3327 /* 3 <3> Set MAC HW */
3328 /* 4 <3.1> Setup channel and bandwidth */
3329 rlmBssInitForAPandIbss(prAdapter
, prAisBssInfo
);
3331 /* 4 <3.2> use command packets to inform firmware */
3332 nicUpdateBss(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3334 /* 4 <3.3> enable beaconing */
3335 bssUpdateBeaconContent(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3337 /* 4 <3.4> Update AdHoc PM parameter */
3338 nicPmIndicateBssCreated(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3340 /* 3 <4> Set ACTIVE flag. */
3341 prAisBssInfo
->fgIsBeaconActivated
= TRUE
;
3342 prAisBssInfo
->fgHoldSameBssidForIBSS
= TRUE
;
3344 /* 3 <5> Start IBSS Alone Timer */
3345 cnmTimerStartTimer(prAdapter
,
3346 &prAisFsmInfo
->rIbssAloneTimer
, SEC_TO_MSEC(AIS_IBSS_ALONE_TIMEOUT_SEC
));
3350 } /* end of aisCreateIBSS() */
3353 /*----------------------------------------------------------------------------*/
3355 * @brief This function will update the contain of BSS_INFO_T for AIS network once
3356 * the existing IBSS was found.
3358 * @param[in] prStaRec Pointer to the STA_RECORD_T
3362 /*----------------------------------------------------------------------------*/
3363 VOID
aisUpdateBssInfoForMergeIBSS(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prStaRec
)
3365 P_AIS_FSM_INFO_T prAisFsmInfo
;
3366 P_BSS_INFO_T prAisBssInfo
;
3367 P_CONNECTION_SETTINGS_T prConnSettings
;
3368 P_BSS_DESC_T prBssDesc
;
3369 /* UINT_16 u2IELength; */
3370 /* PUINT_8 pucIE; */
3375 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3376 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3377 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
3379 cnmTimerStopTimer(prAdapter
, &prAisFsmInfo
->rIbssAloneTimer
);
3381 if (!prAisBssInfo
->fgIsBeaconActivated
) {
3383 /* 3 <1> Update BSS_INFO_T per Network Basis */
3384 /* 4 <1.1> Setup Operation Mode */
3385 prAisBssInfo
->eCurrentOPMode
= OP_MODE_IBSS
;
3387 /* 4 <1.2> Setup SSID */
3388 COPY_SSID(prAisBssInfo
->aucSSID
,
3389 prAisBssInfo
->ucSSIDLen
,
3390 prConnSettings
->aucSSID
, prConnSettings
->ucSSIDLen
);
3392 /* 4 <1.3> Clear current AP's STA_RECORD_T and current AID */
3393 prAisBssInfo
->prStaRecOfAP
= (P_STA_RECORD_T
) NULL
;
3394 prAisBssInfo
->u2AssocId
= 0;
3396 /* 3 <2> Update BSS_INFO_T from STA_RECORD_T */
3397 /* 4 <2.1> Setup Capability */
3398 prAisBssInfo
->u2CapInfo
= prStaRec
->u2CapInfo
; /* Use Peer's Cap Info as IBSS Cap Info */
3400 if (prAisBssInfo
->u2CapInfo
& CAP_INFO_SHORT_PREAMBLE
) {
3401 prAisBssInfo
->fgIsShortPreambleAllowed
= TRUE
;
3402 prAisBssInfo
->fgUseShortPreamble
= TRUE
;
3404 prAisBssInfo
->fgIsShortPreambleAllowed
= FALSE
;
3405 prAisBssInfo
->fgUseShortPreamble
= FALSE
;
3408 /* 7.3.1.4 For IBSS, the Short Slot Time subfield shall be set to 0. */
3409 prAisBssInfo
->fgUseShortSlotTime
= FALSE
; /* Set to FALSE for AdHoc */
3410 prAisBssInfo
->u2CapInfo
&= ~CAP_INFO_SHORT_SLOT_TIME
;
3412 if (prAisBssInfo
->u2CapInfo
& CAP_INFO_PRIVACY
) {
3413 prAisBssInfo
->fgIsProtection
= TRUE
;
3415 prAisBssInfo
->fgIsProtection
= FALSE
;
3418 /* 4 <2.2> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
3419 prAisBssInfo
->ucPhyTypeSet
= prStaRec
->ucDesiredPhyTypeSet
;
3421 prAisBssInfo
->ucNonHTBasicPhyType
= prStaRec
->ucNonHTBasicPhyType
;
3423 prAisBssInfo
->u2OperationalRateSet
= prStaRec
->u2OperationalRateSet
;
3424 prAisBssInfo
->u2BSSBasicRateSet
= prStaRec
->u2BSSBasicRateSet
;
3426 rateGetDataRatesFromRateSet(prAisBssInfo
->u2OperationalRateSet
,
3427 prAisBssInfo
->u2BSSBasicRateSet
,
3428 prAisBssInfo
->aucAllSupportedRates
,
3429 &prAisBssInfo
->ucAllSupportedRatesLen
);
3431 /* 3 <3> X Update BSS_INFO_T from SW_RFB_T (Association Resp Frame) */
3434 /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
3435 prBssDesc
= scanSearchBssDescByTA(prAdapter
, prStaRec
->aucMacAddr
);
3437 prBssDesc
->fgIsConnecting
= FALSE
;
3438 prBssDesc
->fgIsConnected
= TRUE
;
3440 /* 4 <4.1> Setup BSSID */
3441 COPY_MAC_ADDR(prAisBssInfo
->aucBSSID
, prBssDesc
->aucBSSID
);
3443 /* 4 <4.2> Setup Channel, Band */
3444 prAisBssInfo
->ucPrimaryChannel
= prBssDesc
->ucChannelNum
;
3445 prAisBssInfo
->eBand
= prBssDesc
->eBand
;
3447 /* 4 <4.3> Setup MIB for current BSS */
3448 prAisBssInfo
->u2BeaconInterval
= prBssDesc
->u2BeaconInterval
;
3449 prAisBssInfo
->ucDTIMPeriod
= 0;
3450 prAisBssInfo
->u2ATIMWindow
= 0; /* TBD(Kevin) */
3452 prAisBssInfo
->ucBeaconTimeoutCount
= AIS_BEACON_TIMEOUT_COUNT_ADHOC
;
3454 /* should never happen */
3459 /* 3 <5> Set MAC HW */
3460 /* 4 <5.1> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
3462 UINT_8 ucLowestBasicRateIndex
;
3464 if (!rateGetLowestRateIndexFromRateSet(prAisBssInfo
->u2BSSBasicRateSet
,
3465 &ucLowestBasicRateIndex
)) {
3467 if (prAisBssInfo
->ucPhyTypeSet
& PHY_TYPE_BIT_OFDM
) {
3468 ucLowestBasicRateIndex
= RATE_6M_INDEX
;
3470 ucLowestBasicRateIndex
= RATE_1M_INDEX
;
3474 prAisBssInfo
->ucHwDefaultFixedRateCode
=
3475 aucRateIndex2RateCode
[prAisBssInfo
->fgUseShortPreamble
][ucLowestBasicRateIndex
];
3478 /* 4 <5.2> Setup channel and bandwidth */
3479 rlmBssInitForAPandIbss(prAdapter
, prAisBssInfo
);
3481 /* 4 <5.3> use command packets to inform firmware */
3482 nicUpdateBss(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3484 /* 4 <5.4> enable beaconing */
3485 bssUpdateBeaconContent(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3487 /* 4 <5.5> Update AdHoc PM parameter */
3488 nicPmIndicateBssConnected(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3490 /* 3 <6> Set ACTIVE flag. */
3491 prAisBssInfo
->fgIsBeaconActivated
= TRUE
;
3492 prAisBssInfo
->fgHoldSameBssidForIBSS
= TRUE
;
3495 } /* end of aisUpdateBssInfoForMergeIBSS() */
3498 /*----------------------------------------------------------------------------*/
3500 * @brief This function will validate the Rx Probe Request Frame and then return
3501 * result to BSS to indicate if need to send the corresponding Probe Response
3502 * Frame if the specified conditions were matched.
3504 * @param[in] prAdapter Pointer to the Adapter structure.
3505 * @param[in] prSwRfb Pointer to SW RFB data structure.
3506 * @param[out] pu4ControlFlags Control flags for replying the Probe Response
3508 * @retval TRUE Reply the Probe Response
3509 * @retval FALSE Don't reply the Probe Response
3511 /*----------------------------------------------------------------------------*/
3513 aisValidateProbeReq(IN P_ADAPTER_T prAdapter
, IN P_SW_RFB_T prSwRfb
, OUT PUINT_32 pu4ControlFlags
)
3515 P_WLAN_MAC_MGMT_HEADER_T prMgtHdr
;
3516 P_BSS_INFO_T prBssInfo
;
3517 P_IE_SSID_T prIeSsid
= (P_IE_SSID_T
) NULL
;
3520 UINT_16 u2Offset
= 0;
3521 BOOLEAN fgReplyProbeResp
= FALSE
;
3525 ASSERT(pu4ControlFlags
);
3527 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3529 /* 4 <1> Parse Probe Req IE and Get IE ptr (SSID, Supported Rate IE, ...) */
3530 prMgtHdr
= (P_WLAN_MAC_MGMT_HEADER_T
) prSwRfb
->pvHeader
;
3532 u2IELength
= prSwRfb
->u2PacketLen
- prSwRfb
->u2HeaderLen
;
3533 pucIE
= (PUINT_8
) ((UINT_32
) prSwRfb
->pvHeader
+ prSwRfb
->u2HeaderLen
);
3535 IE_FOR_EACH(pucIE
, u2IELength
, u2Offset
) {
3536 if (ELEM_ID_SSID
== IE_ID(pucIE
)) {
3537 if ((!prIeSsid
) && (IE_LEN(pucIE
) <= ELEM_MAX_LEN_SSID
)) {
3538 prIeSsid
= (P_IE_SSID_T
) pucIE
;
3542 } /* end of IE_FOR_EACH */
3544 /* 4 <2> Check network conditions */
3546 if (prBssInfo
->eCurrentOPMode
== OP_MODE_IBSS
) {
3548 if ((prIeSsid
) && ((prIeSsid
->ucLength
== BC_SSID_LEN
) || /* WILDCARD SSID */
3549 EQUAL_SSID(prBssInfo
->aucSSID
, prBssInfo
->ucSSIDLen
, /* CURRENT SSID */
3550 prIeSsid
->aucSSID
, prIeSsid
->ucLength
))) {
3551 fgReplyProbeResp
= TRUE
;
3555 return fgReplyProbeResp
;
3557 } /* end of aisValidateProbeReq() */
3559 #endif /* CFG_SUPPORT_ADHOC */
3561 /*----------------------------------------------------------------------------*/
3563 * @brief This function will modify and update necessary information to firmware
3564 * for disconnection handling
3566 * @param[in] prAdapter Pointer to the Adapter structure.
3570 /*----------------------------------------------------------------------------*/
3571 VOID
aisFsmDisconnect(IN P_ADAPTER_T prAdapter
, IN BOOLEAN fgDelayIndication
)
3573 P_BSS_INFO_T prAisBssInfo
;
3577 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3579 nicPmIndicateBssAbort(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3581 #if CFG_SUPPORT_ADHOC
3582 if (prAisBssInfo
->fgIsBeaconActivated
) {
3583 nicUpdateBeaconIETemplate(prAdapter
,
3584 IE_UPD_METHOD_DELETE_ALL
,
3585 NETWORK_TYPE_AIS_INDEX
, 0, NULL
, 0);
3587 prAisBssInfo
->fgIsBeaconActivated
= FALSE
;
3591 rlmBssAborted(prAdapter
, prAisBssInfo
);
3593 /* 4 <3> Unset the fgIsConnected flag of BSS_DESC_T and send Deauth if needed. */
3594 if (PARAM_MEDIA_STATE_CONNECTED
== prAisBssInfo
->eConnectionState
) {
3596 if (prAisBssInfo
->ucReasonOfDisconnect
== DISCONNECT_REASON_CODE_RADIO_LOST
) {
3597 scanRemoveBssDescByBssid(prAdapter
, prAisBssInfo
->aucBSSID
);
3599 /* remove from scanning results as well */
3600 wlanClearBssInScanningResult(prAdapter
, prAisBssInfo
->aucBSSID
);
3602 /* trials for re-association */
3603 if (fgDelayIndication
) {
3604 aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_RECONNECT
, TRUE
);
3605 aisFsmInsertRequest(prAdapter
, AIS_REQUEST_RECONNECT
);
3608 scanRemoveConnFlagOfBssDescByBssid(prAdapter
, prAisBssInfo
->aucBSSID
);
3611 if (fgDelayIndication
) {
3612 if (OP_MODE_IBSS
!= prAisBssInfo
->eCurrentOPMode
) {
3613 prAisBssInfo
->fgHoldSameBssidForIBSS
= FALSE
;
3616 prAisBssInfo
->fgHoldSameBssidForIBSS
= FALSE
;
3619 prAisBssInfo
->fgHoldSameBssidForIBSS
= FALSE
;
3623 /* 4 <4> Change Media State immediately. */
3624 aisChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_DISCONNECTED
);
3626 /* 4 <4.1> sync. with firmware */
3627 nicUpdateBss(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3629 if (!fgDelayIndication
) {
3630 /* 4 <5> Deactivate previous AP's STA_RECORD_T or all Clients in Driver if have. */
3631 if (prAisBssInfo
->prStaRecOfAP
) {
3632 /* cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1); */
3634 prAisBssInfo
->prStaRecOfAP
= (P_STA_RECORD_T
) NULL
;
3637 #if CFG_SUPPORT_ROAMING
3638 roamingFsmRunEventAbort(prAdapter
);
3640 /* clear pending roaming connection request */
3641 aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_ROAMING_SEARCH
, TRUE
);
3642 aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_ROAMING_CONNECT
, TRUE
);
3643 #endif /* CFG_SUPPORT_ROAMING */
3645 /* 4 <6> Indicate Disconnected Event to Host */
3646 aisIndicationOfMediaStateToHost(prAdapter
,
3647 PARAM_MEDIA_STATE_DISCONNECTED
, fgDelayIndication
);
3650 /* 4 <7> Trigger AIS FSM */
3651 aisFsmSteps(prAdapter
, AIS_STATE_IDLE
);
3654 } /* end of aisFsmDisconnect() */
3657 /*----------------------------------------------------------------------------*/
3659 * @brief This function will indicate an Event of "Background Scan Time-Out" to AIS FSM.
3661 * @param[in] u4Param Unused timer parameter
3665 /*----------------------------------------------------------------------------*/
3666 VOID
aisFsmRunEventBGSleepTimeOut(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
)
3668 P_AIS_FSM_INFO_T prAisFsmInfo
;
3669 ENUM_AIS_STATE_T eNextState
;
3671 DEBUGFUNC("aisFsmRunEventBGSleepTimeOut()");
3673 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3675 eNextState
= prAisFsmInfo
->eCurrentState
;
3677 switch (prAisFsmInfo
->eCurrentState
) {
3678 case AIS_STATE_WAIT_FOR_NEXT_SCAN
:
3680 ("EVENT - SCAN TIMER: Idle End - Current Time = %ld\n", kalGetTimeTick()));
3682 eNextState
= AIS_STATE_LOOKING_FOR
;
3684 SET_NET_PWR_STATE_ACTIVE(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
3692 /* Call aisFsmSteps() when we are going to change AIS STATE */
3693 if (eNextState
!= prAisFsmInfo
->eCurrentState
) {
3694 aisFsmSteps(prAdapter
, eNextState
);
3698 } /* end of aisFsmBGSleepTimeout() */
3701 /*----------------------------------------------------------------------------*/
3703 * @brief This function will indicate an Event of "IBSS ALONE Time-Out" to AIS FSM.
3705 * @param[in] u4Param Unused timer parameter
3709 /*----------------------------------------------------------------------------*/
3710 VOID
aisFsmRunEventIbssAloneTimeOut(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
)
3712 P_AIS_FSM_INFO_T prAisFsmInfo
;
3713 ENUM_AIS_STATE_T eNextState
;
3715 DEBUGFUNC("aisFsmRunEventIbssAloneTimeOut()");
3717 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3718 eNextState
= prAisFsmInfo
->eCurrentState
;
3720 switch (prAisFsmInfo
->eCurrentState
) {
3721 case AIS_STATE_IBSS_ALONE
:
3723 /* There is no one participate in our AdHoc during this TIMEOUT Interval
3724 * so go back to search for a valid IBSS again.
3727 DBGLOG(AIS
, LOUD
, ("EVENT-IBSS ALONE TIMER: Start pairing\n"));
3729 prAisFsmInfo
->fgTryScan
= TRUE
;
3732 aisFsmReleaseCh(prAdapter
);
3734 /* Pull back to SEARCH to find candidate again */
3735 eNextState
= AIS_STATE_SEARCH
;
3744 /* Call aisFsmSteps() when we are going to change AIS STATE */
3745 if (eNextState
!= prAisFsmInfo
->eCurrentState
) {
3746 aisFsmSteps(prAdapter
, eNextState
);
3750 } /* end of aisIbssAloneTimeOut() */
3753 /*----------------------------------------------------------------------------*/
3755 * @brief This function will indicate an Event of "Join Time-Out" to AIS FSM.
3757 * @param[in] u4Param Unused timer parameter
3761 /*----------------------------------------------------------------------------*/
3762 VOID
aisFsmRunEventJoinTimeout(IN P_ADAPTER_T prAdapter
, UINT_32 u4Param
)
3764 P_AIS_FSM_INFO_T prAisFsmInfo
;
3765 ENUM_AIS_STATE_T eNextState
;
3767 DEBUGFUNC("aisFsmRunEventJoinTimeout()");
3769 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3770 eNextState
= prAisFsmInfo
->eCurrentState
;
3772 switch (prAisFsmInfo
->eCurrentState
) {
3773 case AIS_STATE_JOIN
:
3774 DBGLOG(AIS
, LOUD
, ("EVENT- JOIN TIMEOUT\n"));
3776 /* 1. Do abort JOIN */
3777 aisFsmStateAbort_JOIN(prAdapter
);
3779 /* 2. Increase Join Failure Count */
3780 prAisFsmInfo
->prTargetStaRec
->ucJoinFailureCount
++;
3781 /* For JB nl802.11 */
3783 if (prAisFsmInfo
->prTargetStaRec
->ucJoinFailureCount
< JOIN_MAX_RETRY_FAILURE_COUNT
) {
3784 /* 3.1 Retreat to AIS_STATE_SEARCH state for next try */
3785 eNextState
= AIS_STATE_SEARCH
;
3787 /* 3.2 Retreat to AIS_STATE_WAIT_FOR_NEXT_SCAN state for next try */
3788 eNextState
= AIS_STATE_WAIT_FOR_NEXT_SCAN
;
3791 eNextState
= AIS_STATE_IDLE
;
3794 case AIS_STATE_NORMAL_TR
:
3795 /* 1. release channel */
3796 aisFsmReleaseCh(prAdapter
);
3797 prAisFsmInfo
->fgIsInfraChannelFinished
= TRUE
;
3799 /* 2. process if there is pending scan */
3800 if (aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_SCAN
, TRUE
) == TRUE
) {
3801 wlanClearScanningResult(prAdapter
);
3802 eNextState
= AIS_STATE_ONLINE_SCAN
;
3808 /* release channel */
3809 aisFsmReleaseCh(prAdapter
);
3815 /* Call aisFsmSteps() when we are going to change AIS STATE */
3816 if (eNextState
!= prAisFsmInfo
->eCurrentState
) {
3817 aisFsmSteps(prAdapter
, eNextState
);
3821 } /* end of aisFsmRunEventJoinTimeout() */
3824 #if defined(CFG_TEST_MGMT_FSM) && (CFG_TEST_MGMT_FSM != 0)
3825 /*----------------------------------------------------------------------------*/
3833 /*----------------------------------------------------------------------------*/
3836 P_MSG_AIS_ABORT_T prAisAbortMsg
;
3837 P_CONNECTION_SETTINGS_T prConnSettings
;
3838 UINT_8 aucSSID
[] = "pci-11n";
3839 UINT_8 ucSSIDLen
= 7;
3841 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
3843 /* Set Connection Request Issued Flag */
3844 prConnSettings
->fgIsConnReqIssued
= TRUE
;
3845 prConnSettings
->ucSSIDLen
= ucSSIDLen
;
3846 kalMemCopy(prConnSettings
->aucSSID
, aucSSID
, ucSSIDLen
);
3849 (P_MSG_AIS_ABORT_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_AIS_ABORT_T
));
3850 if (!prAisAbortMsg
) {
3852 ASSERT(0); /* Can't trigger SCAN FSM */
3856 prAisAbortMsg
->rMsgHdr
.eMsgId
= MID_HEM_AIS_FSM_ABORT
;
3858 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prAisAbortMsg
, MSG_SEND_METHOD_BUF
);
3860 wifi_send_msg(INDX_WIFI
, MSG_ID_WIFI_IST
, 0);
3864 #endif /* CFG_TEST_MGMT_FSM */
3867 /*----------------------------------------------------------------------------*/
3869 * \brief This function is used to handle OID_802_11_BSSID_LIST_SCAN
3871 * \param[in] prAdapter Pointer of ADAPTER_T
3872 * \param[in] prSsid Pointer of SSID_T if specified
3873 * \param[in] pucIe Pointer to buffer of extra information elements to be attached
3874 * \param[in] u4IeLength Length of information elements
3878 /*----------------------------------------------------------------------------*/
3880 aisFsmScanRequest(IN P_ADAPTER_T prAdapter
,
3881 IN P_PARAM_SSID_T prSsid
, IN PUINT_8 pucIe
, IN UINT_32 u4IeLength
)
3883 P_CONNECTION_SETTINGS_T prConnSettings
;
3884 P_BSS_INFO_T prAisBssInfo
;
3885 P_AIS_FSM_INFO_T prAisFsmInfo
;
3887 DEBUGFUNC("aisFsmScanRequest()");
3890 ASSERT(u4IeLength
<= MAX_IE_LENGTH
);
3892 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3893 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3894 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
3896 if (!prConnSettings
->fgIsScanReqIssued
) {
3897 prConnSettings
->fgIsScanReqIssued
= TRUE
;
3899 if (prSsid
== NULL
) {
3900 prAisFsmInfo
->ucScanSSIDLen
= 0;
3902 COPY_SSID(prAisFsmInfo
->aucScanSSID
,
3903 prAisFsmInfo
->ucScanSSIDLen
,
3904 prSsid
->aucSsid
, (UINT_8
) prSsid
->u4SsidLen
);
3907 if (u4IeLength
> 0 && u4IeLength
<= MAX_IE_LENGTH
) {
3908 prAisFsmInfo
->u4ScanIELength
= u4IeLength
;
3909 kalMemCopy(prAisFsmInfo
->aucScanIEBuf
, pucIe
, u4IeLength
);
3911 prAisFsmInfo
->u4ScanIELength
= 0;
3914 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_NORMAL_TR
) {
3915 if (prAisBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
3916 && prAisFsmInfo
->fgIsInfraChannelFinished
== FALSE
) {
3917 /* 802.1x might not finished yet, pend it for later handling .. */
3918 aisFsmInsertRequest(prAdapter
, AIS_REQUEST_SCAN
);
3920 if (prAisFsmInfo
->fgIsChannelGranted
== TRUE
) {
3922 ("Scan Request with channel granted for join operation: %d, %d",
3923 prAisFsmInfo
->fgIsChannelGranted
,
3924 prAisFsmInfo
->fgIsChannelRequested
));
3927 /* start online scan */
3928 wlanClearScanningResult(prAdapter
);
3929 aisFsmSteps(prAdapter
, AIS_STATE_ONLINE_SCAN
);
3931 } else if (prAisFsmInfo
->eCurrentState
== AIS_STATE_IDLE
) {
3932 wlanClearScanningResult(prAdapter
);
3933 aisFsmSteps(prAdapter
, AIS_STATE_SCAN
);
3935 aisFsmInsertRequest(prAdapter
, AIS_REQUEST_SCAN
);
3939 ("Scan Request dropped. (state: %d)\n", prAisFsmInfo
->eCurrentState
));
3943 } /* end of aisFsmScanRequest() */
3946 /*----------------------------------------------------------------------------*/
3948 * \brief This function is invoked when CNM granted channel privilege
3950 * \param[in] prAdapter Pointer of ADAPTER_T
3954 /*----------------------------------------------------------------------------*/
3955 VOID
aisFsmRunEventChGrant(IN P_ADAPTER_T prAdapter
, IN P_MSG_HDR_T prMsgHdr
)
3957 P_BSS_INFO_T prAisBssInfo
;
3958 P_AIS_FSM_INFO_T prAisFsmInfo
;
3959 P_MSG_CH_GRANT_T prMsgChGrant
;
3961 UINT_32 u4GrantInterval
;
3966 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
3967 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
3968 prMsgChGrant
= (P_MSG_CH_GRANT_T
) prMsgHdr
;
3970 ucTokenID
= prMsgChGrant
->ucTokenID
;
3971 u4GrantInterval
= prMsgChGrant
->u4GrantInterval
;
3973 /* 1. free message */
3974 cnmMemFree(prAdapter
, prMsgHdr
);
3976 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_REQ_CHANNEL_JOIN
&&
3977 prAisFsmInfo
->ucSeqNumOfChReq
== ucTokenID
) {
3978 /* 2. channel privilege has been approved */
3979 prAisFsmInfo
->u4ChGrantedInterval
= u4GrantInterval
;
3981 /* 3. state transition to join/ibss-alone/ibss-merge */
3982 /* 3.1 set timeout timer in cases join could not be completed */
3983 cnmTimerStartTimer(prAdapter
,
3984 &prAisFsmInfo
->rJoinTimeoutTimer
,
3985 prAisFsmInfo
->u4ChGrantedInterval
- AIS_JOIN_CH_GRANT_THRESHOLD
);
3986 /* 3.2 set local variable to indicate join timer is ticking */
3987 prAisFsmInfo
->fgIsInfraChannelFinished
= FALSE
;
3989 /* 3.3 switch to join state */
3990 aisFsmSteps(prAdapter
, AIS_STATE_JOIN
);
3992 prAisFsmInfo
->fgIsChannelGranted
= TRUE
;
3993 } else { /* mismatched grant */
3994 /* 2. return channel privilege to CNM immediately */
3995 aisFsmReleaseCh(prAdapter
);
3999 } /* end of aisFsmRunEventChGrant() */
4002 /*----------------------------------------------------------------------------*/
4004 * \brief This function is to inform CNM that channel privilege
4007 * \param[in] prAdapter Pointer of ADAPTER_T
4011 /*----------------------------------------------------------------------------*/
4012 VOID
aisFsmReleaseCh(IN P_ADAPTER_T prAdapter
)
4014 P_AIS_FSM_INFO_T prAisFsmInfo
;
4015 P_MSG_CH_ABORT_T prMsgChAbort
;
4019 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
4021 if (prAisFsmInfo
->fgIsChannelGranted
== TRUE
|| prAisFsmInfo
->fgIsChannelRequested
== TRUE
) {
4023 prAisFsmInfo
->fgIsChannelRequested
= FALSE
;
4024 prAisFsmInfo
->fgIsChannelGranted
= FALSE
;
4026 /* 1. return channel privilege to CNM immediately */
4028 (P_MSG_CH_ABORT_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_CH_ABORT_T
));
4029 if (!prMsgChAbort
) {
4030 ASSERT(0); /* Can't release Channel to CNM */
4034 prMsgChAbort
->rMsgHdr
.eMsgId
= MID_MNY_CNM_CH_ABORT
;
4035 prMsgChAbort
->ucNetTypeIndex
= NETWORK_TYPE_AIS_INDEX
;
4036 prMsgChAbort
->ucTokenID
= prAisFsmInfo
->ucSeqNumOfChReq
;
4038 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prMsgChAbort
, MSG_SEND_METHOD_BUF
);
4042 } /* end of aisFsmReleaseCh() */
4045 /*----------------------------------------------------------------------------*/
4047 * \brief This function is to inform AIS that corresponding beacon has not
4048 * been received for a while and probing is not successful
4050 * \param[in] prAdapter Pointer of ADAPTER_T
4054 /*----------------------------------------------------------------------------*/
4055 VOID
aisBssBeaconTimeout(IN P_ADAPTER_T prAdapter
)
4057 P_BSS_INFO_T prAisBssInfo
;
4058 BOOLEAN fgDoAbortIndication
= FALSE
;
4062 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
4064 /* 4 <1> Diagnose Connection for Beacon Timeout Event */
4065 if (PARAM_MEDIA_STATE_CONNECTED
== prAisBssInfo
->eConnectionState
) {
4066 if (OP_MODE_INFRASTRUCTURE
== prAisBssInfo
->eCurrentOPMode
) {
4067 P_STA_RECORD_T prStaRec
= prAisBssInfo
->prStaRecOfAP
;
4070 fgDoAbortIndication
= TRUE
;
4072 } else if (OP_MODE_IBSS
== prAisBssInfo
->eCurrentOPMode
) {
4073 fgDoAbortIndication
= TRUE
;
4076 /* 4 <2> invoke abort handler */
4077 if (fgDoAbortIndication
) {
4078 aisFsmStateAbort(prAdapter
, DISCONNECT_REASON_CODE_RADIO_LOST
, TRUE
);
4082 } /* end of aisBssBeaconTimeout() */
4085 /*----------------------------------------------------------------------------*/
4087 * \brief This function is to inform AIS that DEAUTH frame has been
4088 * sent and thus state machine could go ahead
4090 * \param[in] prAdapter Pointer of ADAPTER_T
4091 * \param[in] prMsduInfo Pointer of MSDU_INFO_T for DEAUTH frame
4092 * \param[in] prAdapter Pointer of ADAPTER_T
4094 * \return WLAN_STATUS_SUCCESS
4096 /*----------------------------------------------------------------------------*/
4098 aisDeauthXmitComplete(IN P_ADAPTER_T prAdapter
,
4099 IN P_MSDU_INFO_T prMsduInfo
, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
)
4101 P_AIS_FSM_INFO_T prAisFsmInfo
;
4105 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
4107 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_DISCONNECTING
) {
4108 if (rTxDoneStatus
!= TX_RESULT_DROPPED_IN_DRIVER
) {
4109 aisFsmStateAbort(prAdapter
, DISCONNECT_REASON_CODE_NEW_CONNECTION
, FALSE
);
4112 DBGLOG(AIS
, WARN
, ("DEAUTH frame transmitted without further handling"));
4115 return WLAN_STATUS_SUCCESS
;
4117 } /* end of aisDeauthXmitComplete() */
4119 #if CFG_SUPPORT_ROAMING
4120 /*----------------------------------------------------------------------------*/
4122 * @brief This function will indicate an Event of "Looking for a candidate due to weak signal" to AIS FSM.
4124 * @param[in] u4ReqScan Requesting Scan or not
4128 /*----------------------------------------------------------------------------*/
4129 VOID
aisFsmRunEventRoamingDiscovery(IN P_ADAPTER_T prAdapter
, UINT_32 u4ReqScan
)
4131 P_AIS_FSM_INFO_T prAisFsmInfo
;
4132 P_CONNECTION_SETTINGS_T prConnSettings
;
4133 ENUM_AIS_REQUEST_TYPE_T eAisRequest
;
4135 DBGLOG(AIS
, LOUD
, ("aisFsmRunEventRoamingDiscovery()\n"));
4137 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
4138 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
4140 /* search candidates by best rssi */
4141 prConnSettings
->eConnectionPolicy
= CONNECT_BY_SSID_BEST_RSSI
;
4143 /* results are still new */
4145 roamingFsmRunEventRoam(prAdapter
);
4146 eAisRequest
= AIS_REQUEST_ROAMING_CONNECT
;
4148 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_ONLINE_SCAN
4149 || prAisFsmInfo
->eCurrentState
== AIS_STATE_LOOKING_FOR
) {
4150 eAisRequest
= AIS_REQUEST_ROAMING_CONNECT
;
4152 eAisRequest
= AIS_REQUEST_ROAMING_SEARCH
;
4156 if (prAisFsmInfo
->eCurrentState
== AIS_STATE_NORMAL_TR
4157 && prAisFsmInfo
->fgIsInfraChannelFinished
== TRUE
) {
4158 if (eAisRequest
== AIS_REQUEST_ROAMING_SEARCH
) {
4159 aisFsmSteps(prAdapter
, AIS_STATE_LOOKING_FOR
);
4161 aisFsmSteps(prAdapter
, AIS_STATE_SEARCH
);
4164 aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_ROAMING_SEARCH
, TRUE
);
4165 aisFsmIsRequestPending(prAdapter
, AIS_REQUEST_ROAMING_CONNECT
, TRUE
);
4167 aisFsmInsertRequest(prAdapter
, eAisRequest
);
4171 } /* end of aisFsmRunEventRoamingDiscovery() */
4173 /*----------------------------------------------------------------------------*/
4175 * @brief Update the time of ScanDone for roaming and transit to Roam state.
4181 /*----------------------------------------------------------------------------*/
4182 ENUM_AIS_STATE_T
aisFsmRoamingScanResultsUpdate(IN P_ADAPTER_T prAdapter
)
4184 P_AIS_FSM_INFO_T prAisFsmInfo
;
4185 P_ROAMING_INFO_T prRoamingFsmInfo
;
4186 ENUM_AIS_STATE_T eNextState
;
4188 DBGLOG(AIS
, LOUD
, ("->aisFsmRoamingScanResultsUpdate()\n"));
4190 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
4191 prRoamingFsmInfo
= (P_ROAMING_INFO_T
) &(prAdapter
->rWifiVar
.rRoamingInfo
);
4193 roamingFsmScanResultsUpdate(prAdapter
);
4195 eNextState
= prAisFsmInfo
->eCurrentState
;
4196 if (prRoamingFsmInfo
->eCurrentState
== ROAMING_STATE_DISCOVERY
) {
4197 roamingFsmRunEventRoam(prAdapter
);
4198 eNextState
= AIS_STATE_SEARCH
;
4199 } else if (prAisFsmInfo
->eCurrentState
== AIS_STATE_LOOKING_FOR
) {
4200 eNextState
= AIS_STATE_SEARCH
;
4201 } else if (prAisFsmInfo
->eCurrentState
== AIS_STATE_ONLINE_SCAN
) {
4202 eNextState
= AIS_STATE_NORMAL_TR
;
4206 } /* end of aisFsmRoamingScanResultsUpdate() */
4208 /*----------------------------------------------------------------------------*/
4210 * @brief This function will modify and update necessary information to firmware
4211 * for disconnection of last AP before switching to roaming bss.
4213 * @param IN prAdapter Pointer to the Adapter structure.
4214 * prTargetStaRec Target of StaRec of roaming
4218 /*----------------------------------------------------------------------------*/
4219 VOID
aisFsmRoamingDisconnectPrevAP(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prTargetStaRec
)
4221 P_BSS_INFO_T prAisBssInfo
;
4223 DBGLOG(AIS
, LOUD
, ("aisFsmRoamingDisconnectPrevAP()"));
4227 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
4229 nicPmIndicateBssAbort(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
4231 /* Not invoke rlmBssAborted() here to avoid prAisBssInfo->fg40mBwAllowed
4232 * to be reset. RLM related parameters will be reset again when handling
4233 * association response in rlmProcessAssocRsp(). 20110413
4235 /* rlmBssAborted(prAdapter, prAisBssInfo); */
4237 /* 4 <3> Unset the fgIsConnected flag of BSS_DESC_T and send Deauth if needed. */
4238 if (PARAM_MEDIA_STATE_CONNECTED
== prAisBssInfo
->eConnectionState
) {
4239 scanRemoveConnFlagOfBssDescByBssid(prAdapter
, prAisBssInfo
->aucBSSID
);
4241 /* 4 <4> Change Media State immediately. */
4242 aisChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_DISCONNECTED
);
4244 /* 4 <4.1> sync. with firmware */
4245 prTargetStaRec
->ucNetTypeIndex
= 0xff; /* Virtial NetType */
4246 nicUpdateBss(prAdapter
, NETWORK_TYPE_AIS_INDEX
);
4247 prTargetStaRec
->ucNetTypeIndex
= NETWORK_TYPE_AIS_INDEX
; /* Virtial NetType */
4250 } /* end of aisFsmRoamingDisconnectPrevAP() */
4252 /*----------------------------------------------------------------------------*/
4254 * @brief This function will update the contain of BSS_INFO_T for AIS network once
4255 * the roaming was completed.
4257 * @param IN prAdapter Pointer to the Adapter structure.
4258 * prStaRec StaRec of roaming AP
4263 /*----------------------------------------------------------------------------*/
4265 aisUpdateBssInfoForRoamingAP(IN P_ADAPTER_T prAdapter
,
4266 IN P_STA_RECORD_T prStaRec
, IN P_SW_RFB_T prAssocRspSwRfb
)
4268 P_BSS_INFO_T prAisBssInfo
;
4270 DBGLOG(AIS
, LOUD
, ("aisUpdateBssInfoForRoamingAP()"));
4274 prAisBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_AIS_INDEX
]);
4276 /* 4 <1.1> Change FW's Media State immediately. */
4277 aisChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_CONNECTED
);
4279 /* 4 <1.2> Deactivate previous AP's STA_RECORD_T in Driver if have. */
4280 if ((prAisBssInfo
->prStaRecOfAP
) &&
4281 (prAisBssInfo
->prStaRecOfAP
!= prStaRec
) && (prAisBssInfo
->prStaRecOfAP
->fgIsInUse
)) {
4282 cnmStaRecChangeState(prAdapter
, prAisBssInfo
->prStaRecOfAP
, STA_STATE_1
);
4284 /* 4 <1.3> Update BSS_INFO_T */
4285 aisUpdateBssInfoForJOIN(prAdapter
, prStaRec
, prAssocRspSwRfb
);
4287 /* 4 <1.4> Activate current AP's STA_RECORD_T in Driver. */
4288 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_3
);
4290 /* 4 <1.6> Indicate Connected Event to Host immediately. */
4291 /* Require BSSID, Association ID, Beacon Interval.. from AIS_BSS_INFO_T */
4292 aisIndicationOfMediaStateToHost(prAdapter
, PARAM_MEDIA_STATE_CONNECTED
, FALSE
);
4295 } /* end of aisFsmRoamingUpdateBss() */
4297 #endif /* CFG_SUPPORT_ROAMING */
4300 /*----------------------------------------------------------------------------*/
4302 * @brief Check if there is any pending request and remove it (optional)
4311 /*----------------------------------------------------------------------------*/
4313 aisFsmIsRequestPending(IN P_ADAPTER_T prAdapter
,
4314 IN ENUM_AIS_REQUEST_TYPE_T eReqType
, IN BOOLEAN bRemove
)
4316 P_AIS_FSM_INFO_T prAisFsmInfo
;
4317 P_AIS_REQ_HDR_T prPendingReqHdr
, prPendingReqHdrNext
;
4320 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
4322 /* traverse through pending request list */
4323 LINK_FOR_EACH_ENTRY_SAFE(prPendingReqHdr
,
4324 prPendingReqHdrNext
,
4325 &(prAisFsmInfo
->rPendingReqList
), rLinkEntry
, AIS_REQ_HDR_T
) {
4326 /* check for specified type */
4327 if (prPendingReqHdr
->eReqType
== eReqType
) {
4328 /* check if need to remove */
4329 if (bRemove
== TRUE
) {
4330 LINK_REMOVE_KNOWN_ENTRY(&(prAisFsmInfo
->rPendingReqList
),
4331 &(prPendingReqHdr
->rLinkEntry
));
4333 cnmMemFree(prAdapter
, prPendingReqHdr
);
4344 /*----------------------------------------------------------------------------*/
4346 * @brief Get next pending request
4350 * @return P_AIS_REQ_HDR_T
4352 /*----------------------------------------------------------------------------*/
4353 P_AIS_REQ_HDR_T
aisFsmGetNextRequest(IN P_ADAPTER_T prAdapter
)
4355 P_AIS_FSM_INFO_T prAisFsmInfo
;
4356 P_AIS_REQ_HDR_T prPendingReqHdr
;
4359 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
4361 LINK_REMOVE_HEAD(&(prAisFsmInfo
->rPendingReqList
), prPendingReqHdr
, P_AIS_REQ_HDR_T
);
4363 return prPendingReqHdr
;
4367 /*----------------------------------------------------------------------------*/
4369 * @brief Insert a new request
4377 /*----------------------------------------------------------------------------*/
4378 BOOLEAN
aisFsmInsertRequest(IN P_ADAPTER_T prAdapter
, IN ENUM_AIS_REQUEST_TYPE_T eReqType
)
4380 P_AIS_REQ_HDR_T prAisReq
;
4381 P_AIS_FSM_INFO_T prAisFsmInfo
;
4384 prAisFsmInfo
= &(prAdapter
->rWifiVar
.rAisFsmInfo
);
4386 prAisReq
= (P_AIS_REQ_HDR_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(AIS_REQ_HDR_T
));
4389 ASSERT(0); /* Can't generate new message */
4393 prAisReq
->eReqType
= eReqType
;
4395 /* attach request into pending request list */
4396 LINK_INSERT_TAIL(&prAisFsmInfo
->rPendingReqList
, &prAisReq
->rLinkEntry
);
4402 /*----------------------------------------------------------------------------*/
4404 * @brief Flush all pending requests
4410 /*----------------------------------------------------------------------------*/
4411 VOID
aisFsmFlushRequest(IN P_ADAPTER_T prAdapter
)
4413 P_AIS_REQ_HDR_T prAisReq
;
4417 while ((prAisReq
= aisFsmGetNextRequest(prAdapter
)) != NULL
) {
4418 cnmMemFree(prAdapter
, prAisReq
);