2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
34 -------- ---------- ----------------------------------------------
35 John 2004-08-08 Major modification from RT2560
37 #include "../rt_config.h"
39 UCHAR CipherSuiteWpaNoneTkip
[] = {
40 0x00, 0x50, 0xf2, 0x01, // oui
41 0x01, 0x00, // Version
42 0x00, 0x50, 0xf2, 0x02, // Multicast
43 0x01, 0x00, // Number of unicast
44 0x00, 0x50, 0xf2, 0x02, // unicast
45 0x01, 0x00, // number of authentication method
46 0x00, 0x50, 0xf2, 0x00 // authentication
48 UCHAR CipherSuiteWpaNoneTkipLen
= (sizeof(CipherSuiteWpaNoneTkip
) / sizeof(UCHAR
));
50 UCHAR CipherSuiteWpaNoneAes
[] = {
51 0x00, 0x50, 0xf2, 0x01, // oui
52 0x01, 0x00, // Version
53 0x00, 0x50, 0xf2, 0x04, // Multicast
54 0x01, 0x00, // Number of unicast
55 0x00, 0x50, 0xf2, 0x04, // unicast
56 0x01, 0x00, // number of authentication method
57 0x00, 0x50, 0xf2, 0x00 // authentication
59 UCHAR CipherSuiteWpaNoneAesLen
= (sizeof(CipherSuiteWpaNoneAes
) / sizeof(UCHAR
));
61 // The following MACRO is called after 1. starting an new IBSS, 2. succesfully JOIN an IBSS,
62 // or 3. succesfully ASSOCIATE to a BSS, 4. successfully RE_ASSOCIATE to a BSS
63 // All settings successfuly negotiated furing MLME state machines become final settings
64 // and are copied to pAd->StaActive
65 #define COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
67 (_pAd)->CommonCfg.SsidLen = (_pAd)->MlmeAux.SsidLen; \
68 NdisMoveMemory((_pAd)->CommonCfg.Ssid, (_pAd)->MlmeAux.Ssid, (_pAd)->MlmeAux.SsidLen); \
69 COPY_MAC_ADDR((_pAd)->CommonCfg.Bssid, (_pAd)->MlmeAux.Bssid); \
70 (_pAd)->CommonCfg.Channel = (_pAd)->MlmeAux.Channel; \
71 (_pAd)->CommonCfg.CentralChannel = (_pAd)->MlmeAux.CentralChannel; \
72 (_pAd)->StaActive.Aid = (_pAd)->MlmeAux.Aid; \
73 (_pAd)->StaActive.AtimWin = (_pAd)->MlmeAux.AtimWin; \
74 (_pAd)->StaActive.CapabilityInfo = (_pAd)->MlmeAux.CapabilityInfo; \
75 (_pAd)->CommonCfg.BeaconPeriod = (_pAd)->MlmeAux.BeaconPeriod; \
76 (_pAd)->StaActive.CfpMaxDuration = (_pAd)->MlmeAux.CfpMaxDuration; \
77 (_pAd)->StaActive.CfpPeriod = (_pAd)->MlmeAux.CfpPeriod; \
78 (_pAd)->StaActive.SupRateLen = (_pAd)->MlmeAux.SupRateLen; \
79 NdisMoveMemory((_pAd)->StaActive.SupRate, (_pAd)->MlmeAux.SupRate, (_pAd)->MlmeAux.SupRateLen);\
80 (_pAd)->StaActive.ExtRateLen = (_pAd)->MlmeAux.ExtRateLen; \
81 NdisMoveMemory((_pAd)->StaActive.ExtRate, (_pAd)->MlmeAux.ExtRate, (_pAd)->MlmeAux.ExtRateLen);\
82 NdisMoveMemory(&(_pAd)->CommonCfg.APEdcaParm, &(_pAd)->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));\
83 NdisMoveMemory(&(_pAd)->CommonCfg.APQosCapability, &(_pAd)->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));\
84 NdisMoveMemory(&(_pAd)->CommonCfg.APQbssLoad, &(_pAd)->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));\
85 COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].Addr, (_pAd)->MlmeAux.Bssid); \
86 (_pAd)->MacTab.Content[BSSID_WCID].Aid = (_pAd)->MlmeAux.Aid; \
87 (_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = (_pAd)->StaCfg.PairCipher;\
88 COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.BssId, (_pAd)->MlmeAux.Bssid);\
89 (_pAd)->MacTab.Content[BSSID_WCID].RateLen = (_pAd)->StaActive.SupRateLen + (_pAd)->StaActive.ExtRateLen;\
93 ==========================================================================
98 ==========================================================================
101 IN PRTMP_ADAPTER pAd
,
103 OUT STATE_MACHINE_FUNC Trans
[])
105 // Control state machine differs from other state machines, the interface
106 // follows the standard interface
107 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
111 ==========================================================================
114 IRQL = DISPATCH_LEVEL
116 ==========================================================================
118 VOID
MlmeCntlMachinePerformAction(
119 IN PRTMP_ADAPTER pAd
,
121 IN MLME_QUEUE_ELEM
*Elem
)
123 switch(pAd
->Mlme
.CntlMachine
.CurrState
)
127 CntlIdleProc(pAd
, Elem
);
130 case CNTL_WAIT_DISASSOC
:
131 CntlWaitDisassocProc(pAd
, Elem
);
134 CntlWaitJoinProc(pAd
, Elem
);
137 // CNTL_WAIT_REASSOC is the only state in CNTL machine that does
138 // not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
139 // Therefore not protected by NDIS's "only one outstanding OID request"
140 // rule. Which means NDIS may SET OID in the middle of ROAMing attempts.
141 // Current approach is to block new SET request at RTMPSetInformation()
142 // when CntlMachine.CurrState is not CNTL_IDLE
143 case CNTL_WAIT_REASSOC
:
144 CntlWaitReassocProc(pAd
, Elem
);
147 case CNTL_WAIT_START
:
148 CntlWaitStartProc(pAd
, Elem
);
151 CntlWaitAuthProc(pAd
, Elem
);
153 case CNTL_WAIT_AUTH2
:
154 CntlWaitAuthProc2(pAd
, Elem
);
156 case CNTL_WAIT_ASSOC
:
157 CntlWaitAssocProc(pAd
, Elem
);
160 case CNTL_WAIT_OID_LIST_SCAN
:
161 if(Elem
->MsgType
== MT2_SCAN_CONF
)
163 // Resume TxRing after SCANING complete. We hope the out-of-service time
164 // won't be too long to let upper layer time-out the waiting frames
165 RTMPResumeMsduTransmission(pAd
);
166 if (pAd
->StaCfg
.CCXReqType
!= MSRN_TYPE_UNUSED
)
168 // Cisco scan request is finished, prepare beacon report
169 MlmeEnqueue(pAd
, AIRONET_STATE_MACHINE
, MT2_AIRONET_SCAN_DONE
, 0, NULL
);
171 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
174 // Set LED status to previous status.
176 if (pAd
->bLedOnScanning
)
178 pAd
->bLedOnScanning
= FALSE
;
179 RTMPSetLED(pAd
, pAd
->LedStatus
);
184 case CNTL_WAIT_OID_DISASSOC
:
185 if (Elem
->MsgType
== MT2_DISASSOC_CONF
)
187 LinkDown(pAd
, FALSE
);
188 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
193 // This state is for that we want to connect to an AP but
194 // it didn't find on BSS List table. So we need to scan the air first,
195 // after that we can try to connect to the desired AP if available.
197 case CNTL_WAIT_SCAN_FOR_CONNECT
:
198 if(Elem
->MsgType
== MT2_SCAN_CONF
)
200 // Resume TxRing after SCANING complete. We hope the out-of-service time
201 // won't be too long to let upper layer time-out the waiting frames
202 RTMPResumeMsduTransmission(pAd
);
204 if (pAd
->StaCfg
.CCXReqType
!= MSRN_TYPE_UNUSED
)
206 // Cisco scan request is finished, prepare beacon report
207 MlmeEnqueue(pAd
, AIRONET_STATE_MACHINE
, MT2_AIRONET_SCAN_DONE
, 0, NULL
);
209 #endif // CCX_SUPPORT //
210 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
213 // Check if we can connect to.
215 BssTableSsidSort(pAd
, &pAd
->MlmeAux
.SsidBssTab
, pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.AutoReconnectSsidLen
);
216 if (pAd
->MlmeAux
.SsidBssTab
.BssNr
> 0)
218 MlmeAutoReconnectLastSSID(pAd
);
224 DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", Elem
->MsgType
));
231 ==========================================================================
234 IRQL = DISPATCH_LEVEL
236 ==========================================================================
239 IN PRTMP_ADAPTER pAd
,
240 IN MLME_QUEUE_ELEM
*Elem
)
242 MLME_DISASSOC_REQ_STRUCT DisassocReq
;
244 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_RADIO_OFF
))
247 switch(Elem
->MsgType
)
249 case OID_802_11_SSID
:
250 CntlOidSsidProc(pAd
, Elem
);
253 case OID_802_11_BSSID
:
254 CntlOidRTBssidProc(pAd
,Elem
);
257 case OID_802_11_BSSID_LIST_SCAN
:
258 CntlOidScanProc(pAd
,Elem
);
261 case OID_802_11_DISASSOCIATE
:
262 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
263 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
, sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
264 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_DISASSOC
;
266 if (pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_ENABLE_WITH_WEB_UI
)
268 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
269 // Since calling this indicate user don't want to connect to that SSID anymore.
270 pAd
->MlmeAux
.AutoReconnectSsidLen
= 32;
271 NdisZeroMemory(pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.AutoReconnectSsidLen
);
275 case MT2_MLME_ROAMING_REQ
:
276 CntlMlmeRoamingProc(pAd
, Elem
);
279 case OID_802_11_MIC_FAILURE_REPORT_FRAME
:
280 WpaMicFailureReportFrame(pAd
, Elem
);
284 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem
->MsgType
));
289 VOID
CntlOidScanProc(
290 IN PRTMP_ADAPTER pAd
,
291 IN MLME_QUEUE_ELEM
*Elem
)
293 MLME_SCAN_REQ_STRUCT ScanReq
;
294 ULONG BssIdx
= BSS_NOT_FOUND
;
297 // record current BSS if network is connected.
298 // 2003-2-13 do not include current IBSS if this is the only STA in this IBSS.
299 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
))
301 BssIdx
= BssSsidTableSearch(&pAd
->ScanTab
, pAd
->CommonCfg
.Bssid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.SsidLen
, pAd
->CommonCfg
.Channel
);
302 if (BssIdx
!= BSS_NOT_FOUND
)
304 NdisMoveMemory(&CurrBss
, &pAd
->ScanTab
.BssEntry
[BssIdx
], sizeof(BSS_ENTRY
));
308 // clean up previous SCAN result, add current BSS back to table if any
309 BssTableInit(&pAd
->ScanTab
);
310 if (BssIdx
!= BSS_NOT_FOUND
)
312 // DDK Note: If the NIC is associated with a particular BSSID and SSID
313 // that are not contained in the list of BSSIDs generated by this scan, the
314 // BSSID description of the currently associated BSSID and SSID should be
315 // appended to the list of BSSIDs in the NIC's database.
316 // To ensure this, we append this BSS as the first entry in SCAN result
317 NdisMoveMemory(&pAd
->ScanTab
.BssEntry
[0], &CurrBss
, sizeof(BSS_ENTRY
));
318 pAd
->ScanTab
.BssNr
= 1;
321 ScanParmFill(pAd
, &ScanReq
, "", 0, BSS_ANY
, SCAN_ACTIVE
);
322 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_SCAN_REQ
,
323 sizeof(MLME_SCAN_REQ_STRUCT
), &ScanReq
);
324 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_LIST_SCAN
;
328 ==========================================================================
330 Before calling this routine, user desired SSID should already been
331 recorded in CommonCfg.Ssid[]
332 IRQL = DISPATCH_LEVEL
334 ==========================================================================
336 VOID
CntlOidSsidProc(
337 IN PRTMP_ADAPTER pAd
,
338 IN MLME_QUEUE_ELEM
* Elem
)
340 PNDIS_802_11_SSID pOidSsid
= (NDIS_802_11_SSID
*)Elem
->Msg
;
341 MLME_DISASSOC_REQ_STRUCT DisassocReq
;
345 // BBP and RF are not accessible in PS mode, we has to wake them up first
346 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_DOZE
))
347 AsicForceWakeup(pAd
, RTMP_HALT
);
350 // Step 1. record the desired user settings to MlmeAux
351 NdisZeroMemory(pAd
->MlmeAux
.Ssid
, MAX_LEN_OF_SSID
);
352 NdisMoveMemory(pAd
->MlmeAux
.Ssid
, pOidSsid
->Ssid
, pOidSsid
->SsidLength
);
353 pAd
->MlmeAux
.SsidLen
= (UCHAR
)pOidSsid
->SsidLength
;
354 NdisZeroMemory(pAd
->MlmeAux
.Bssid
, MAC_ADDR_LEN
);
355 pAd
->MlmeAux
.BssType
= pAd
->StaCfg
.BssType
;
359 // Update Reconnect Ssid, that user desired to connect.
361 NdisZeroMemory(pAd
->MlmeAux
.AutoReconnectSsid
, MAX_LEN_OF_SSID
);
362 NdisMoveMemory(pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
363 pAd
->MlmeAux
.AutoReconnectSsidLen
= pAd
->MlmeAux
.SsidLen
;
365 // step 2. find all matching BSS in the lastest SCAN result (inBssTab)
366 // & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order
367 BssTableSsidSort(pAd
, &pAd
->MlmeAux
.SsidBssTab
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
369 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - %d BSS of %d BSS match the desire (%d)SSID - %s\n",
370 pAd
->MlmeAux
.SsidBssTab
.BssNr
, pAd
->ScanTab
.BssNr
, pAd
->MlmeAux
.SsidLen
, pAd
->MlmeAux
.Ssid
));
371 NdisGetSystemUpTime(&Now
);
373 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
) &&
374 (pAd
->CommonCfg
.SsidLen
== pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0].SsidLen
) &&
375 NdisEqualMemory(pAd
->CommonCfg
.Ssid
, pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0].Ssid
, pAd
->CommonCfg
.SsidLen
) &&
376 MAC_ADDR_EQUAL(pAd
->CommonCfg
.Bssid
, pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0].Bssid
))
378 // Case 1. already connected with an AP who has the desired SSID
381 // Add checking Mode "LEAP" for CCX 1.0
382 if (((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) ||
383 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
) ||
384 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
) ||
385 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
)
387 (pAd
->StaCfg
.PortSecured
== WPA_802_1X_PORT_NOT_SECURED
))
389 // case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
390 // connection process
391 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
392 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
393 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
394 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
395 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
397 else if (pAd
->bConfigChanged
== TRUE
)
399 // case 1.2 Important Config has changed, we have to reconnect to the same AP
400 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n"));
401 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
402 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
403 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
404 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
408 // case 1.3. already connected to the SSID with highest RSSI.
409 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n"));
411 // (HCT 12.1) 1c_wlan_mediaevents required
412 // media connect events are indicated when associating with the same AP
417 // Since MediaState already is NdisMediaStateConnected
418 // We just indicate the connect event again to meet the WHQL required.
420 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
421 RTMP_IndicateMediaState(pAd
);
422 pAd
->ExtraInfo
= GENERAL_LINK_UP
; // Update extra information to link is up
425 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
428 union iwreq_data wrqu
;
430 memset(wrqu
.ap_addr
.sa_data
, 0, MAC_ADDR_LEN
);
431 memcpy(wrqu
.ap_addr
.sa_data
, pAd
->MlmeAux
.Bssid
, MAC_ADDR_LEN
);
432 wireless_send_event(pAd
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
437 else if (INFRA_ON(pAd
))
441 // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
442 // RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect
443 // But media status is connected, so the SSID not report correctly.
445 if (!SSID_EQUAL(pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.SsidLen
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
))
448 // Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event.
450 pAd
->MlmeAux
.CurrReqIsFromNdis
= TRUE
;
452 // case 2. active INFRA association existent
453 // roaming is done within miniport driver, nothing to do with configuration
454 // utility. so upon a new SET(OID_802_11_SSID) is received, we just
455 // disassociate with the current associated AP,
456 // then perform a new association with this new SSID, no matter the
457 // new/old SSID are the same or not.
458 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
459 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
460 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
461 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
462 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
468 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - drop current ADHOC\n"));
469 LinkDown(pAd
, FALSE
);
470 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
471 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
472 RTMP_IndicateMediaState(pAd
);
473 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
474 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
477 if ((pAd
->MlmeAux
.SsidBssTab
.BssNr
== 0) &&
478 (pAd
->StaCfg
.bAutoReconnect
== TRUE
) &&
479 (pAd
->MlmeAux
.BssType
== BSS_INFRA
) &&
480 (MlmeValidateSSID(pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
) == TRUE
)
483 MLME_SCAN_REQ_STRUCT ScanReq
;
485 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - No matching BSS, start a new scan\n"));
486 ScanParmFill(pAd
, &ScanReq
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
, BSS_ANY
, SCAN_ACTIVE
);
487 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_SCAN_REQ
, sizeof(MLME_SCAN_REQ_STRUCT
), &ScanReq
);
488 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_LIST_SCAN
;
489 // Reset Missed scan number
490 pAd
->StaCfg
.LastScanTime
= Now
;
494 pAd
->MlmeAux
.BssIdx
= 0;
495 IterateOnBssTab(pAd
);
502 ==========================================================================
505 IRQL = DISPATCH_LEVEL
507 ==========================================================================
509 VOID
CntlOidRTBssidProc(
510 IN PRTMP_ADAPTER pAd
,
511 IN MLME_QUEUE_ELEM
* Elem
)
514 PUCHAR pOidBssid
= (PUCHAR
)Elem
->Msg
;
515 MLME_DISASSOC_REQ_STRUCT DisassocReq
;
516 MLME_JOIN_REQ_STRUCT JoinReq
;
518 // record user desired settings
519 COPY_MAC_ADDR(pAd
->MlmeAux
.Bssid
, pOidBssid
);
520 pAd
->MlmeAux
.BssType
= pAd
->StaCfg
.BssType
;
523 // Update Reconnect Ssid, that user desired to connect.
525 NdisZeroMemory(pAd
->MlmeAux
.AutoReconnectSsid
, MAX_LEN_OF_SSID
);
526 pAd
->MlmeAux
.AutoReconnectSsidLen
= pAd
->MlmeAux
.SsidLen
;
527 NdisMoveMemory(pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
529 // find the desired BSS in the latest SCAN result table
530 BssIdx
= BssTableSearch(&pAd
->ScanTab
, pOidBssid
, pAd
->MlmeAux
.Channel
);
531 if (BssIdx
== BSS_NOT_FOUND
)
533 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
534 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
538 // copy the matched BSS entry from ScanTab to MlmeAux.SsidBssTab. Why?
539 // Because we need this entry to become the JOIN target in later on SYNC state machine
540 pAd
->MlmeAux
.BssIdx
= 0;
541 pAd
->MlmeAux
.SsidBssTab
.BssNr
= 1;
542 NdisMoveMemory(&pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0], &pAd
->ScanTab
.BssEntry
[BssIdx
], sizeof(BSS_ENTRY
));
544 // 2002-11-26 skip the following checking. i.e. if user wants to re-connect to same AP
545 // we just follow normal procedure. The reason of user doing this may because he/she changed
546 // AP to another channel, but we still received BEACON from it thus don't claim Link Down.
547 // Since user knows he's changed AP channel, he'll re-connect again. By skipping the following
548 // checking, we'll disassociate then re-do normal association with this AP at the new channel.
549 // 2003-1-6 Re-enable this feature based on microsoft requirement which prefer not to re-do
550 // connection when setting the same BSSID.
551 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
) &&
552 MAC_ADDR_EQUAL(pAd
->CommonCfg
.Bssid
, pOidBssid
))
554 // already connected to the same BSSID, go back to idle state directly
555 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - already in this BSSID. ignore this SET_BSSID request\n"));
556 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
559 union iwreq_data wrqu
;
561 memset(wrqu
.ap_addr
.sa_data
, 0, MAC_ADDR_LEN
);
562 memcpy(wrqu
.ap_addr
.sa_data
, pAd
->MlmeAux
.Bssid
, MAC_ADDR_LEN
);
563 wireless_send_event(pAd
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
571 // disassoc from current AP first
572 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - disassociate with current AP ...\n"));
573 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
574 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
575 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
577 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
583 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - drop current ADHOC\n"));
584 LinkDown(pAd
, FALSE
);
585 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
586 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
587 RTMP_IndicateMediaState(pAd
);
588 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
589 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
592 // Change the wepstatus to original wepstatus
593 pAd
->StaCfg
.WepStatus
= pAd
->StaCfg
.OrigWepStatus
;
594 pAd
->StaCfg
.PairCipher
= pAd
->StaCfg
.OrigWepStatus
;
595 pAd
->StaCfg
.GroupCipher
= pAd
->StaCfg
.OrigWepStatus
;
597 // Check cipher suite, AP must have more secured cipher than station setting
598 // Set the Pairwise and Group cipher to match the intended AP setting
599 // We can only connect to AP with less secured cipher setting
600 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
))
602 pAd
->StaCfg
.GroupCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.GroupCipher
;
604 if (pAd
->StaCfg
.WepStatus
== pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipher
)
605 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipher
;
606 else if (pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
!= Ndis802_11WEPDisabled
)
607 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
;
608 else // There is no PairCipher Aux, downgrade our capability to TKIP
609 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
611 else if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
))
613 pAd
->StaCfg
.GroupCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.GroupCipher
;
615 if (pAd
->StaCfg
.WepStatus
== pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
)
616 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
;
617 else if (pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
!= Ndis802_11WEPDisabled
)
618 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
;
619 else // There is no PairCipher Aux, downgrade our capability to TKIP
620 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
623 pAd
->StaCfg
.RsnCapability
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.RsnCapability
;
626 // Set Mix cipher flag
627 pAd
->StaCfg
.bMixCipher
= (pAd
->StaCfg
.PairCipher
== pAd
->StaCfg
.GroupCipher
) ? FALSE
: TRUE
;
628 if (pAd
->StaCfg
.bMixCipher
== TRUE
)
630 // If mix cipher, re-build RSNIE
631 RTMPMakeRSNIE(pAd
, pAd
->StaCfg
.AuthMode
, pAd
->StaCfg
.WepStatus
, 0);
633 // No active association, join the BSS immediately
634 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n",
635 pOidBssid
[0],pOidBssid
[1],pOidBssid
[2],pOidBssid
[3],pOidBssid
[4],pOidBssid
[5]));
637 JoinParmFill(pAd
, &JoinReq
, pAd
->MlmeAux
.BssIdx
);
638 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_JOIN_REQ
, sizeof(MLME_JOIN_REQ_STRUCT
), &JoinReq
);
640 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_JOIN
;
645 // Roaming is the only external request triggering CNTL state machine
646 // despite of other "SET OID" operation. All "SET OID" related oerations
647 // happen in sequence, because no other SET OID will be sent to this device
648 // until the the previous SET operation is complete (successful o failed).
649 // So, how do we quarantee this ROAMING request won't corrupt other "SET OID"?
650 // or been corrupted by other "SET OID"?
652 // IRQL = DISPATCH_LEVEL
653 VOID
CntlMlmeRoamingProc(
654 IN PRTMP_ADAPTER pAd
,
655 IN MLME_QUEUE_ELEM
*Elem
)
658 // AP in different channel may show lower RSSI than actual value??
659 // should we add a weighting factor to compensate it?
660 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - Roaming in MlmeAux.RoamTab...\n"));
662 NdisMoveMemory(&pAd
->MlmeAux
.SsidBssTab
, &pAd
->MlmeAux
.RoamTab
, sizeof(pAd
->MlmeAux
.RoamTab
));
663 pAd
->MlmeAux
.SsidBssTab
.BssNr
= pAd
->MlmeAux
.RoamTab
.BssNr
;
665 BssTableSortByRssi(&pAd
->MlmeAux
.SsidBssTab
);
666 pAd
->MlmeAux
.BssIdx
= 0;
667 IterateOnBssTab(pAd
);
671 ==========================================================================
674 IRQL = DISPATCH_LEVEL
676 ==========================================================================
678 VOID
CntlWaitDisassocProc(
679 IN PRTMP_ADAPTER pAd
,
680 IN MLME_QUEUE_ELEM
*Elem
)
682 MLME_START_REQ_STRUCT StartReq
;
684 if (Elem
->MsgType
== MT2_DISASSOC_CONF
)
686 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Dis-associate successful\n"));
688 if (pAd
->CommonCfg
.bWirelessEvent
)
690 RTMPSendWirelessEvent(pAd
, IW_DISASSOC_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
693 LinkDown(pAd
, FALSE
);
695 // case 1. no matching BSS, and user wants ADHOC, so we just start a new one
696 if ((pAd
->MlmeAux
.SsidBssTab
.BssNr
==0) && (pAd
->StaCfg
.BssType
== BSS_ADHOC
))
698 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd
->MlmeAux
.Ssid
));
699 StartParmFill(pAd
, &StartReq
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
700 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_START_REQ
, sizeof(MLME_START_REQ_STRUCT
), &StartReq
);
701 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_START
;
703 // case 2. try each matched BSS
706 pAd
->MlmeAux
.BssIdx
= 0;
708 IterateOnBssTab(pAd
);
714 ==========================================================================
717 IRQL = DISPATCH_LEVEL
719 ==========================================================================
721 VOID
CntlWaitJoinProc(
722 IN PRTMP_ADAPTER pAd
,
723 IN MLME_QUEUE_ELEM
*Elem
)
726 MLME_AUTH_REQ_STRUCT AuthReq
;
728 if (Elem
->MsgType
== MT2_JOIN_CONF
)
730 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
731 if (Reason
== MLME_SUCCESS
)
733 // 1. joined an IBSS, we are pretty much done here
734 if (pAd
->MlmeAux
.BssType
== BSS_ADHOC
)
737 // 5G bands rules of Japan:
738 // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
740 if ( (pAd
->CommonCfg
.bIEEE80211H
== 1) &&
741 RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
)
744 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
745 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd
->CommonCfg
.Channel
));
749 LinkUp(pAd
, BSS_ADHOC
);
750 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
751 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
752 pAd
->CommonCfg
.Bssid
[0],pAd
->CommonCfg
.Bssid
[1],pAd
->CommonCfg
.Bssid
[2],
753 pAd
->CommonCfg
.Bssid
[3],pAd
->CommonCfg
.Bssid
[4],pAd
->CommonCfg
.Bssid
[5]));
755 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
756 pAd
->ExtraInfo
= GENERAL_LINK_UP
;
758 // 2. joined a new INFRA network, start from authentication
762 // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
763 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
) ||
764 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeAutoSwitch
))
766 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeShared
);
770 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeOpen
);
773 MlmeEnqueue(pAd
, AUTH_STATE_MACHINE
, MT2_MLME_AUTH_REQ
,
774 sizeof(MLME_AUTH_REQ_STRUCT
), &AuthReq
);
776 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_AUTH
;
781 // 3. failed, try next BSS
782 pAd
->MlmeAux
.BssIdx
++;
783 IterateOnBssTab(pAd
);
790 ==========================================================================
793 IRQL = DISPATCH_LEVEL
795 ==========================================================================
797 VOID
CntlWaitStartProc(
798 IN PRTMP_ADAPTER pAd
,
799 IN MLME_QUEUE_ELEM
*Elem
)
803 if (Elem
->MsgType
== MT2_START_CONF
)
805 NdisMoveMemory(&Result
, Elem
->Msg
, sizeof(USHORT
));
806 if (Result
== MLME_SUCCESS
)
809 // 5G bands rules of Japan:
810 // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
812 if ( (pAd
->CommonCfg
.bIEEE80211H
== 1) &&
813 RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
)
816 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
817 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd
->CommonCfg
.Channel
));
821 if (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
)
825 NdisMoveMemory(&pAd
->MlmeAux
.AddHtInfo
, &pAd
->CommonCfg
.AddHTInfo
, sizeof(ADD_HT_INFO_IE
));
826 RTMPCheckHt(pAd
, BSSID_WCID
, &pAd
->CommonCfg
.HtCapability
, &pAd
->CommonCfg
.AddHTInfo
);
827 pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
= TRUE
;
828 NdisZeroMemory(&pAd
->StaActive
.SupportedPhyInfo
.MCSSet
[0], 16);
829 NdisMoveMemory(&pAd
->StaActive
.SupportedPhyInfo
.MCSSet
[0], &pAd
->CommonCfg
.HtCapability
.MCSSet
[0], 16);
830 COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd
);
832 if ((pAd
->CommonCfg
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
) &&
833 (pAd
->CommonCfg
.AddHTInfo
.AddHtInfo
.ExtChanOffset
== EXTCHA_ABOVE
))
835 pAd
->MlmeAux
.CentralChannel
= pAd
->CommonCfg
.Channel
+ 2;
837 else if ((pAd
->CommonCfg
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
) &&
838 (pAd
->CommonCfg
.AddHTInfo
.AddHtInfo
.ExtChanOffset
== EXTCHA_BELOW
))
840 pAd
->MlmeAux
.CentralChannel
= pAd
->CommonCfg
.Channel
- 2;
845 pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
= FALSE
;
847 LinkUp(pAd
, BSS_ADHOC
);
848 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
849 // Before send beacon, driver need do radar detection
850 if ((pAd
->CommonCfg
.Channel
> 14 )
851 && (pAd
->CommonCfg
.bIEEE80211H
== 1)
852 && RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
))
854 pAd
->CommonCfg
.RadarDetect
.RDMode
= RD_SILENCE_MODE
;
855 pAd
->CommonCfg
.RadarDetect
.RDCount
= 0;
858 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
859 pAd
->CommonCfg
.Bssid
[0],pAd
->CommonCfg
.Bssid
[1],pAd
->CommonCfg
.Bssid
[2],
860 pAd
->CommonCfg
.Bssid
[3],pAd
->CommonCfg
.Bssid
[4],pAd
->CommonCfg
.Bssid
[5]));
864 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Start IBSS fail. BUG!!!!!\n"));
865 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
871 ==========================================================================
874 IRQL = DISPATCH_LEVEL
876 ==========================================================================
878 VOID
CntlWaitAuthProc(
879 IN PRTMP_ADAPTER pAd
,
880 IN MLME_QUEUE_ELEM
*Elem
)
883 MLME_ASSOC_REQ_STRUCT AssocReq
;
884 MLME_AUTH_REQ_STRUCT AuthReq
;
886 if (Elem
->MsgType
== MT2_AUTH_CONF
)
888 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
889 if (Reason
== MLME_SUCCESS
)
891 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH OK\n"));
892 AssocParmFill(pAd
, &AssocReq
, pAd
->MlmeAux
.Bssid
, pAd
->MlmeAux
.CapabilityInfo
,
893 ASSOC_TIMEOUT
, pAd
->StaCfg
.DefaultListenCount
);
896 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_ASSOC_REQ
,
897 sizeof(MLME_ASSOC_REQ_STRUCT
), &AssocReq
);
899 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_ASSOC
;
904 // This fail may because of the AP already keep us in its MAC table without
905 // ageing-out. The previous authentication attempt must have let it remove us.
906 // so try Authentication again may help. For D-Link DWL-900AP+ compatibility.
907 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH FAIL, try again...\n"));
910 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
) ||
911 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeAutoSwitch
))
913 // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
914 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeShared
);
918 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeOpen
);
921 MlmeEnqueue(pAd
, AUTH_STATE_MACHINE
, MT2_MLME_AUTH_REQ
,
922 sizeof(MLME_AUTH_REQ_STRUCT
), &AuthReq
);
924 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_AUTH2
;
930 ==========================================================================
933 IRQL = DISPATCH_LEVEL
935 ==========================================================================
937 VOID
CntlWaitAuthProc2(
938 IN PRTMP_ADAPTER pAd
,
939 IN MLME_QUEUE_ELEM
*Elem
)
942 MLME_ASSOC_REQ_STRUCT AssocReq
;
943 MLME_AUTH_REQ_STRUCT AuthReq
;
945 if (Elem
->MsgType
== MT2_AUTH_CONF
)
947 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
948 if (Reason
== MLME_SUCCESS
)
950 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH OK\n"));
951 AssocParmFill(pAd
, &AssocReq
, pAd
->MlmeAux
.Bssid
, pAd
->MlmeAux
.CapabilityInfo
,
952 ASSOC_TIMEOUT
, pAd
->StaCfg
.DefaultListenCount
);
953 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_ASSOC_REQ
,
954 sizeof(MLME_ASSOC_REQ_STRUCT
), &AssocReq
);
956 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_ASSOC
;
960 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeAutoSwitch
) &&
961 (pAd
->MlmeAux
.Alg
== Ndis802_11AuthModeShared
))
963 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH FAIL, try OPEN system...\n"));
964 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeOpen
);
965 MlmeEnqueue(pAd
, AUTH_STATE_MACHINE
, MT2_MLME_AUTH_REQ
,
966 sizeof(MLME_AUTH_REQ_STRUCT
), &AuthReq
);
968 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_AUTH2
;
972 // not success, try next BSS
973 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH FAIL, give up; try next BSS\n"));
974 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
; //???????
975 pAd
->MlmeAux
.BssIdx
++;
976 IterateOnBssTab(pAd
);
983 ==========================================================================
986 IRQL = DISPATCH_LEVEL
988 ==========================================================================
990 VOID
CntlWaitAssocProc(
991 IN PRTMP_ADAPTER pAd
,
992 IN MLME_QUEUE_ELEM
*Elem
)
996 if (Elem
->MsgType
== MT2_ASSOC_CONF
)
998 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
999 if (Reason
== MLME_SUCCESS
)
1001 LinkUp(pAd
, BSS_INFRA
);
1002 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
1003 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Association successful on BSS #%ld\n",pAd
->MlmeAux
.BssIdx
));
1005 if (pAd
->CommonCfg
.bWirelessEvent
)
1007 RTMPSendWirelessEvent(pAd
, IW_ASSOC_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
1012 // not success, try next BSS
1013 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Association fails on BSS #%ld\n",pAd
->MlmeAux
.BssIdx
));
1014 pAd
->MlmeAux
.BssIdx
++;
1015 IterateOnBssTab(pAd
);
1021 ==========================================================================
1024 IRQL = DISPATCH_LEVEL
1026 ==========================================================================
1028 VOID
CntlWaitReassocProc(
1029 IN PRTMP_ADAPTER pAd
,
1030 IN MLME_QUEUE_ELEM
*Elem
)
1034 if (Elem
->MsgType
== MT2_REASSOC_CONF
)
1036 NdisMoveMemory(&Result
, Elem
->Msg
, sizeof(USHORT
));
1037 if (Result
== MLME_SUCCESS
)
1040 // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
1042 LinkUp(pAd
, BSS_INFRA
);
1044 // send wireless event - for association
1045 if (pAd
->CommonCfg
.bWirelessEvent
)
1046 RTMPSendWirelessEvent(pAd
, IW_ASSOC_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
1048 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
1049 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd
->MlmeAux
.RoamIdx
));
1053 // reassoc failed, try to pick next BSS in the BSS Table
1054 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Re-assocition fails on BSS #%ld\n", pAd
->MlmeAux
.RoamIdx
));
1055 pAd
->MlmeAux
.RoamIdx
++;
1056 IterateOnBssTab2(pAd
);
1063 VOID
AdhocTurnOnQos(
1064 IN PRTMP_ADAPTER pAd
)
1066 #define AC0_DEF_TXOP 0
1067 #define AC1_DEF_TXOP 0
1068 #define AC2_DEF_TXOP 94
1069 #define AC3_DEF_TXOP 47
1071 // Turn on QOs if use HT rate.
1072 if (pAd
->CommonCfg
.APEdcaParm
.bValid
== FALSE
)
1074 pAd
->CommonCfg
.APEdcaParm
.bValid
= TRUE
;
1075 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[0] = 3;
1076 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[1] = 7;
1077 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[2] = 1;
1078 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[3] = 1;
1080 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[0] = 4;
1081 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[1] = 4;
1082 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[2] = 3;
1083 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[3] = 2;
1085 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[0] = 10;
1086 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[1] = 6;
1087 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[2] = 4;
1088 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[3] = 3;
1090 pAd
->CommonCfg
.APEdcaParm
.Txop
[0] = 0;
1091 pAd
->CommonCfg
.APEdcaParm
.Txop
[1] = 0;
1092 pAd
->CommonCfg
.APEdcaParm
.Txop
[2] = AC2_DEF_TXOP
;
1093 pAd
->CommonCfg
.APEdcaParm
.Txop
[3] = AC3_DEF_TXOP
;
1095 AsicSetEdcaParm(pAd
, &pAd
->CommonCfg
.APEdcaParm
);
1100 ==========================================================================
1103 IRQL = DISPATCH_LEVEL
1105 ==========================================================================
1108 IN PRTMP_ADAPTER pAd
,
1114 UCHAR Value
= 0, idx
;
1115 MAC_TABLE_ENTRY
*pEntry
= NULL
, *pCurrEntry
;
1118 if (RTMP_TEST_PSFLAG(pAd
, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND
))
1120 RTMPPCIeLinkCtrlValueRestore(pAd
, RESTORE_HALT
);
1121 RTMPusecDelay(6000);
1122 pAd
->bPCIclkOff
= FALSE
;
1126 pEntry
= &pAd
->MacTab
.Content
[BSSID_WCID
];
1129 // ASSOC - DisassocTimeoutAction
1130 // CNTL - Dis-associate successful
1131 // !!! LINK DOWN !!!
1132 // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
1134 // To prevent DisassocTimeoutAction to call Link down after we link up,
1135 // cancel the DisassocTimer no matter what it start or not.
1137 RTMPCancelTimer(&pAd
->MlmeAux
.DisassocTimer
, &Cancelled
);
1139 COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd
);
1141 COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd
);
1143 // It's quite difficult to tell if a newly added KEY is WEP or CKIP until a new BSS
1144 // is formed (either ASSOC/RE-ASSOC done or IBSS started. LinkUP should be a safe place
1145 // to examine if cipher algorithm switching is required.
1146 //rt2860b. Don't know why need this
1147 SwitchBetweenWepAndCkip(pAd
);
1150 // Before power save before link up function, We will force use 1R.
1151 // So after link up, check Rx antenna # again.
1152 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &Value
);
1153 if(pAd
->Antenna
.field
.RxPath
== 3)
1157 else if(pAd
->Antenna
.field
.RxPath
== 2)
1161 else if(pAd
->Antenna
.field
.RxPath
== 1)
1165 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, Value
);
1166 pAd
->StaCfg
.BBPR3
= Value
;
1169 if (BssType
== BSS_ADHOC
)
1171 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_ADHOC_ON
);
1172 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_INFRA_ON
);
1174 if ((pAd
->CommonCfg
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
) &&
1175 (pAd
->CommonCfg
.AddHTInfo
.AddHtInfo
.ExtChanOffset
== EXTCHA_ABOVE
))
1177 pAd
->CommonCfg
.CentralChannel
= pAd
->CommonCfg
.Channel
+ 2;
1179 else if ((pAd
->CommonCfg
.Channel
> 2) &&
1180 (pAd
->CommonCfg
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
) &&
1181 (pAd
->CommonCfg
.AddHTInfo
.AddHtInfo
.ExtChanOffset
== EXTCHA_BELOW
))
1183 pAd
->CommonCfg
.CentralChannel
= pAd
->CommonCfg
.Channel
- 2;
1186 if (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
)
1187 AdhocTurnOnQos(pAd
);
1190 DBGPRINT(RT_DEBUG_TRACE
, ("!!!Adhoc LINK UP !!! \n" ));
1194 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_INFRA_ON
);
1195 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_ADHOC_ON
);
1197 DBGPRINT(RT_DEBUG_TRACE
, ("!!!Infra LINK UP !!! \n" ));
1201 // reset Tx beamforming bit
1202 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1204 Value
|= pAd
->CommonCfg
.RegTransmitSetting
.field
.TxBF
;
1205 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1207 // Change to AP channel
1208 if ((pAd
->CommonCfg
.CentralChannel
> pAd
->CommonCfg
.Channel
) && (pAd
->MlmeAux
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
))
1210 // Must using 40MHz.
1211 pAd
->CommonCfg
.BBPCurrentBW
= BW_40
;
1212 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.CentralChannel
, FALSE
);
1213 AsicLockChannel(pAd
, pAd
->CommonCfg
.CentralChannel
);
1215 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1218 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1220 // RX : control channel at lower
1221 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &Value
);
1223 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, Value
);
1225 pAd
->StaCfg
.BBPR3
= Value
;
1228 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Data
);
1230 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Data
);
1232 if (pAd
->MACVersion
== 0x28600100)
1234 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, 0x1A);
1235 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, 0x0A);
1236 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, 0x16);
1237 DBGPRINT(RT_DEBUG_TRACE
, ("!!!rt2860C !!! \n" ));
1240 DBGPRINT(RT_DEBUG_TRACE
, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd
->CommonCfg
.CentralChannel
));
1242 else if ((pAd
->CommonCfg
.CentralChannel
< pAd
->CommonCfg
.Channel
) && (pAd
->MlmeAux
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
))
1244 // Must using 40MHz.
1245 pAd
->CommonCfg
.BBPCurrentBW
= BW_40
;
1246 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.CentralChannel
, FALSE
);
1247 AsicLockChannel(pAd
, pAd
->CommonCfg
.CentralChannel
);
1249 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1252 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1254 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Data
);
1256 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Data
);
1258 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &Value
);
1260 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, Value
);
1262 pAd
->StaCfg
.BBPR3
= Value
;
1265 if (pAd
->MACVersion
== 0x28600100)
1267 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, 0x1A);
1268 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, 0x0A);
1269 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, 0x16);
1270 DBGPRINT(RT_DEBUG_TRACE
, ("!!!rt2860C !!! \n" ));
1273 DBGPRINT(RT_DEBUG_TRACE
, ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd
->CommonCfg
.CentralChannel
));
1277 pAd
->CommonCfg
.BBPCurrentBW
= BW_20
;
1278 pAd
->CommonCfg
.CentralChannel
= pAd
->CommonCfg
.Channel
;
1279 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
1280 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
1282 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1284 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1286 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Data
);
1288 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Data
);
1290 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &Value
);
1292 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, Value
);
1294 pAd
->StaCfg
.BBPR3
= Value
;
1297 if (pAd
->MACVersion
== 0x28600100)
1299 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, 0x16);
1300 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, 0x08);
1301 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, 0x11);
1302 DBGPRINT(RT_DEBUG_TRACE
, ("!!!rt2860C !!! \n" ));
1305 DBGPRINT(RT_DEBUG_TRACE
, ("!!! 20MHz LINK UP !!! \n" ));
1308 RTMPSetAGCInitValue(pAd
, pAd
->CommonCfg
.BBPCurrentBW
);
1310 // Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission
1312 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R66
, &pAd
->BbpTuning
.R66CurrentValue
);
1314 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n",
1315 BssType
, pAd
->StaActive
.Aid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.Channel
, pAd
->CommonCfg
.CentralChannel
));
1317 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !!! (Density =%d, )\n", pAd
->MacTab
.Content
[BSSID_WCID
].MpduDensity
));
1319 AsicSetBssid(pAd
, pAd
->CommonCfg
.Bssid
);
1321 AsicSetSlotTime(pAd
, TRUE
);
1322 AsicSetEdcaParm(pAd
, &pAd
->CommonCfg
.APEdcaParm
);
1324 // Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit
1325 AsicUpdateProtect(pAd
, 0, (OFDMSETPROTECT
| CCKSETPROTECT
), TRUE
, FALSE
);
1327 if ((pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== TRUE
))
1329 // Update HT protectionfor based on AP's operating mode.
1330 if (pAd
->MlmeAux
.AddHtInfo
.AddHtInfo2
.NonGfPresent
== 1)
1332 AsicUpdateProtect(pAd
, pAd
->MlmeAux
.AddHtInfo
.AddHtInfo2
.OperaionMode
, ALLN_SETPROTECT
, FALSE
, TRUE
);
1335 AsicUpdateProtect(pAd
, pAd
->MlmeAux
.AddHtInfo
.AddHtInfo2
.OperaionMode
, ALLN_SETPROTECT
, FALSE
, FALSE
);
1338 NdisZeroMemory(&pAd
->DrsCounters
, sizeof(COUNTER_DRS
));
1340 NdisGetSystemUpTime(&Now
);
1341 pAd
->StaCfg
.LastBeaconRxTime
= Now
; // last RX timestamp
1343 if ((pAd
->CommonCfg
.TxPreamble
!= Rt802_11PreambleLong
) &&
1344 CAP_IS_SHORT_PREAMBLE_ON(pAd
->StaActive
.CapabilityInfo
))
1346 MlmeSetTxPreamble(pAd
, Rt802_11PreambleShort
);
1349 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
1351 if (pAd
->CommonCfg
.RadarDetect
.RDMode
== RD_SILENCE_MODE
)
1354 pAd
->CommonCfg
.RadarDetect
.RDMode
= RD_NORMAL_MODE
;
1356 if (BssType
== BSS_ADHOC
)
1358 MakeIbssBeacon(pAd
);
1359 if ((pAd
->CommonCfg
.Channel
> 14)
1360 && (pAd
->CommonCfg
.bIEEE80211H
== 1)
1361 && RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
))
1367 AsicEnableIbssSync(pAd
);
1370 // In ad hoc mode, use MAC table from index 1.
1371 // p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here.
1372 RTMP_IO_WRITE32(pAd
, MAC_WCID_BASE
, 0x00);
1373 RTMP_IO_WRITE32(pAd
, 0x1808, 0x00);
1375 // If WEP is enabled, add key material and cipherAlg into Asic
1376 // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
1378 if (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
)
1383 for (idx
=0; idx
< SHARE_KEY_NUM
; idx
++)
1385 CipherAlg
= pAd
->SharedKey
[BSS0
][idx
].CipherAlg
;
1386 Key
= pAd
->SharedKey
[BSS0
][idx
].Key
;
1388 if (pAd
->SharedKey
[BSS0
][idx
].KeyLen
> 0)
1390 // Set key material and cipherAlg to Asic
1391 AsicAddSharedKeyEntry(pAd
, BSS0
, idx
, CipherAlg
, Key
, NULL
, NULL
);
1393 if (idx
== pAd
->StaCfg
.DefaultKeyId
)
1395 // Update WCID attribute table and IVEIV table for this group key table
1396 RTMPAddWcidAttributeEntry(pAd
, BSS0
, idx
, CipherAlg
, NULL
);
1403 // If WPANone is enabled, add key material and cipherAlg into Asic
1404 // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
1405 else if (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
1407 pAd
->StaCfg
.DefaultKeyId
= 0; // always be zero
1409 NdisZeroMemory(&pAd
->SharedKey
[BSS0
][0], sizeof(CIPHER_KEY
));
1410 pAd
->SharedKey
[BSS0
][0].KeyLen
= LEN_TKIP_EK
;
1411 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].Key
, pAd
->StaCfg
.PMK
, LEN_TKIP_EK
);
1413 if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption2Enabled
)
1415 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].RxMic
, &pAd
->StaCfg
.PMK
[16], LEN_TKIP_RXMICK
);
1416 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].TxMic
, &pAd
->StaCfg
.PMK
[16], LEN_TKIP_TXMICK
);
1419 // Decide its ChiperAlg
1420 if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption2Enabled
)
1421 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_TKIP
;
1422 else if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption3Enabled
)
1423 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_AES
;
1426 DBGPRINT(RT_DEBUG_TRACE
, ("Unknow Cipher (=%d), set Cipher to AES\n", pAd
->StaCfg
.PairCipher
));
1427 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_AES
;
1430 // Set key material and cipherAlg to Asic
1431 AsicAddSharedKeyEntry(pAd
,
1434 pAd
->SharedKey
[BSS0
][0].CipherAlg
,
1435 pAd
->SharedKey
[BSS0
][0].Key
,
1436 pAd
->SharedKey
[BSS0
][0].TxMic
,
1437 pAd
->SharedKey
[BSS0
][0].RxMic
);
1439 // Update WCID attribute table and IVEIV table for this group key table
1440 RTMPAddWcidAttributeEntry(pAd
, BSS0
, 0, pAd
->SharedKey
[BSS0
][0].CipherAlg
, NULL
);
1447 // Check the new SSID with last SSID
1448 while (Cancelled
== TRUE
)
1450 if (pAd
->CommonCfg
.LastSsidLen
== pAd
->CommonCfg
.SsidLen
)
1452 if (RTMPCompareMemory(pAd
->CommonCfg
.LastSsid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.LastSsidLen
) == 0)
1454 // Link to the old one no linkdown is required.
1458 // Send link down event before set to link up
1459 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
1460 RTMP_IndicateMediaState(pAd
);
1461 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
1462 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n"));
1467 // On WPA mode, Remove All Keys if not connect to the last BSSID
1468 // Key will be set after 4-way handshake.
1470 if ((pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
))
1474 // Remove all WPA keys
1475 RTMPWPARemoveAllKeys(pAd
);
1476 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
1477 pAd
->StaCfg
.PrivacyFilter
= Ndis802_11PrivFilter8021xWEP
;
1479 // Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP
1480 // If IV related values are too large in GroupMsg2, AP would ignore this message.
1482 IV
|= (pAd
->StaCfg
.DefaultKeyId
<< 30);
1483 AsicUpdateWCIDIVEIV(pAd
, BSSID_WCID
, IV
, 0);
1486 RTMP_CLEAR_PSFLAG(pAd
, fRTMP_PS_CAN_GO_SLEEP
);
1490 // the decision of using "short slot time" or not may change dynamically due to
1491 // new STA association to the AP. so we have to decide that upon parsing BEACON, not here
1494 // the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically
1495 // due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here
1498 ComposeNullFrame(pAd
);
1500 AsicEnableBssSync(pAd
);
1502 // Add BSSID to WCID search table
1503 AsicUpdateRxWCIDTable(pAd
, BSSID_WCID
, pAd
->CommonCfg
.Bssid
);
1505 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1506 // add this BSSID entry into HASH table
1510 //pEntry = &pAd->MacTab.Content[BSSID_WCID];
1511 HashIdx
= MAC_ADDR_HASH_INDEX(pAd
->CommonCfg
.Bssid
);
1512 if (pAd
->MacTab
.Hash
[HashIdx
] == NULL
)
1514 pAd
->MacTab
.Hash
[HashIdx
] = pEntry
;
1518 pCurrEntry
= pAd
->MacTab
.Hash
[HashIdx
];
1519 while (pCurrEntry
->pNext
!= NULL
)
1520 pCurrEntry
= pCurrEntry
->pNext
;
1521 pCurrEntry
->pNext
= pEntry
;
1524 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1527 // If WEP is enabled, add paiewise and shared key
1528 if (((pAd
->StaCfg
.WpaSupplicantUP
)&&
1529 (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
)&&
1530 (pAd
->StaCfg
.PortSecured
== WPA_802_1X_PORT_SECURED
)) ||
1531 ((pAd
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_DISABLE
)&&
1532 (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
)))
1537 for (idx
=0; idx
< SHARE_KEY_NUM
; idx
++)
1539 CipherAlg
= pAd
->SharedKey
[BSS0
][idx
].CipherAlg
;
1540 Key
= pAd
->SharedKey
[BSS0
][idx
].Key
;
1542 if (pAd
->SharedKey
[BSS0
][idx
].KeyLen
> 0)
1544 // Set key material and cipherAlg to Asic
1545 AsicAddSharedKeyEntry(pAd
, BSS0
, idx
, CipherAlg
, Key
, NULL
, NULL
);
1547 if (idx
== pAd
->StaCfg
.DefaultKeyId
)
1549 // Assign group key info
1550 RTMPAddWcidAttributeEntry(pAd
, BSS0
, idx
, CipherAlg
, NULL
);
1552 // Assign pairwise key info
1553 RTMPAddWcidAttributeEntry(pAd
, BSS0
, idx
, CipherAlg
, pEntry
);
1559 // only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode
1560 // should wait until at least 2 active nodes in this BSSID.
1561 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
1564 if (pAd
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
)
1566 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
1567 pAd
->ExtraInfo
= GENERAL_LINK_UP
;
1569 RTMP_IndicateMediaState(pAd
);
1574 RTMP_IndicateMediaState(pAd
);
1577 // Add BSSID in my MAC Table.
1578 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1579 RTMPMoveMemory(pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, pAd
->CommonCfg
.Bssid
, MAC_ADDR_LEN
);
1580 pAd
->MacTab
.Content
[BSSID_WCID
].Aid
= BSSID_WCID
;
1581 pAd
->MacTab
.Content
[BSSID_WCID
].pAd
= pAd
;
1582 pAd
->MacTab
.Content
[BSSID_WCID
].ValidAsCLI
= TRUE
; //Although this is bssid..still set ValidAsCl
1583 pAd
->MacTab
.Size
= 1; // infra mode always set MACtab size =1.
1584 pAd
->MacTab
.Content
[BSSID_WCID
].Sst
= SST_ASSOC
;
1585 pAd
->MacTab
.Content
[BSSID_WCID
].AuthState
= SST_ASSOC
;
1586 pAd
->MacTab
.Content
[BSSID_WCID
].AuthMode
= pAd
->StaCfg
.AuthMode
;
1587 pAd
->MacTab
.Content
[BSSID_WCID
].WepStatus
= pAd
->StaCfg
.WepStatus
;
1588 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1590 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !!! ClientStatusFlags=%lx)\n",
1591 pAd
->MacTab
.Content
[BSSID_WCID
].ClientStatusFlags
));
1593 MlmeUpdateTxRates(pAd
, TRUE
, BSS0
);
1594 MlmeUpdateHtTxRates(pAd
, BSS0
);
1595 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
));
1597 if (pAd
->CommonCfg
.bAggregationCapable
)
1599 if ((pAd
->CommonCfg
.bPiggyBackCapable
) && (pAd
->MlmeAux
.APRalinkIe
& 0x00000003) == 3)
1602 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_PIGGYBACK_INUSED
);
1603 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
1604 RTMPSetPiggyBack(pAd
, TRUE
);
1605 DBGPRINT(RT_DEBUG_TRACE
, ("Turn on Piggy-Back\n"));
1607 else if (pAd
->MlmeAux
.APRalinkIe
& 0x00000001)
1609 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
1613 if (pAd
->MlmeAux
.APRalinkIe
!= 0x0)
1615 if (CLIENT_STATUS_TEST_FLAG(&pAd
->MacTab
.Content
[BSSID_WCID
], fCLIENT_STATUS_RDG_CAPABLE
))
1620 OPSTATUS_SET_FLAG(pAd
, fCLIENT_STATUS_RALINK_CHIPSET
);
1621 CLIENT_STATUS_SET_FLAG(&pAd
->MacTab
.Content
[BSSID_WCID
], fCLIENT_STATUS_RALINK_CHIPSET
);
1625 OPSTATUS_CLEAR_FLAG(pAd
, fCLIENT_STATUS_RALINK_CHIPSET
);
1626 CLIENT_STATUS_CLEAR_FLAG(&pAd
->MacTab
.Content
[BSSID_WCID
], fCLIENT_STATUS_RALINK_CHIPSET
);
1630 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_CONNECT Event B!.BACapability = %x. ClientStatusFlags = %lx\n", pAd
->CommonCfg
.BACapability
.word
, pAd
->MacTab
.Content
[BSSID_WCID
].ClientStatusFlags
));
1633 RTMPSetLED(pAd
, LED_LINK_UP
);
1635 pAd
->Mlme
.PeriodicRound
= 0;
1636 pAd
->Mlme
.OneSecPeriodicRound
= 0;
1637 pAd
->bConfigChanged
= FALSE
; // Reset config flag
1638 pAd
->ExtraInfo
= GENERAL_LINK_UP
; // Update extra information to link is up
1640 // Set asic auto fall back
1643 UCHAR TableSize
= 0;
1645 MlmeSelectTxRateTable(pAd
, &pAd
->MacTab
.Content
[BSSID_WCID
], &pTable
, &TableSize
, &pAd
->CommonCfg
.TxRateIndex
);
1646 AsicUpdateAutoFallBackTable(pAd
, pTable
);
1649 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1650 pEntry
->HTPhyMode
.word
= pAd
->StaCfg
.HTPhyMode
.word
;
1651 pEntry
->MaxHTPhyMode
.word
= pAd
->StaCfg
.HTPhyMode
.word
;
1652 if (pAd
->StaCfg
.bAutoTxRateSwitch
== FALSE
)
1654 pEntry
->bAutoTxRateSwitch
= FALSE
;
1656 if (pEntry
->HTPhyMode
.field
.MCS
== 32)
1657 pEntry
->HTPhyMode
.field
.ShortGI
= GI_800
;
1659 if ((pEntry
->HTPhyMode
.field
.MCS
> MCS_7
) || (pEntry
->HTPhyMode
.field
.MCS
== 32))
1660 pEntry
->HTPhyMode
.field
.STBC
= STBC_NONE
;
1662 // If the legacy mode is set, overwrite the transmit setting of this entry.
1663 if (pEntry
->HTPhyMode
.field
.MODE
<= MODE_OFDM
)
1664 RTMPUpdateLegacyTxSetting((UCHAR
)pAd
->StaCfg
.DesiredTransmitSetting
.field
.FixedTxMode
, pEntry
);
1667 pEntry
->bAutoTxRateSwitch
= TRUE
;
1668 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1670 // Let Link Status Page display first initial rate.
1671 pAd
->LastTxRate
= (USHORT
)(pEntry
->HTPhyMode
.word
);
1672 // Select DAC according to HT or Legacy
1673 if (pAd
->StaActive
.SupportedPhyInfo
.MCSSet
[0] != 0x00)
1675 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &Value
);
1677 if (pAd
->Antenna
.field
.TxPath
== 2)
1681 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, Value
);
1685 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &Value
);
1687 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, Value
);
1690 if (pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== FALSE
)
1693 else if (pEntry
->MaxRAmpduFactor
== 0)
1695 // If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0.
1696 // Because our Init value is 1 at MACRegTable.
1697 RTMP_IO_WRITE32(pAd
, MAX_LEN_CFG
, 0x0fff);
1700 // Patch for Marvel AP to gain high throughput
1701 // Need to set as following,
1702 // 1. Set txop in register-EDCA_AC0_CFG as 0x60
1703 // 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero
1704 // 3. PBF_MAX_PCNT as 0x1F3FBF9F
1705 // 4. kick per two packets when dequeue
1707 // Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable
1709 // if 1. Legacy AP WMM on, or 2. 11n AP, AMPDU disable. Force turn off burst no matter what bEnableTxBurst is.
1711 !(pAd
->CommonCfg
.RxStream
== 1 && pAd
->CommonCfg
.TxStream
== 1) &&
1712 (((pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== FALSE
) && OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_WMM_INUSED
))
1713 || ((pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== TRUE
) && (pAd
->CommonCfg
.BACapability
.field
.Policy
== BA_NOTUSE
))))
1715 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &Data
);
1717 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, Data
);
1719 RTMP_IO_WRITE32(pAd
, PBF_MAX_PCNT
, 0x1F3F7F9F);
1720 DBGPRINT(RT_DEBUG_TRACE
, ("Txburst 1\n"));
1723 if (pAd
->CommonCfg
.bEnableTxBurst
)
1725 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &Data
);
1728 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, Data
);
1729 pAd
->CommonCfg
.IOTestParm
.bNowAtherosBurstOn
= TRUE
;
1731 RTMP_IO_WRITE32(pAd
, PBF_MAX_PCNT
, 0x1F3FBF9F);
1732 DBGPRINT(RT_DEBUG_TRACE
, ("Txburst 2\n"));
1736 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &Data
);
1738 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, Data
);
1740 RTMP_IO_WRITE32(pAd
, PBF_MAX_PCNT
, 0x1F3F7F9F);
1741 DBGPRINT(RT_DEBUG_TRACE
, ("Txburst 3\n"));
1744 // Re-check to turn on TX burst or not.
1745 if ((pAd
->CommonCfg
.IOTestParm
.bLastAtheros
== TRUE
) && ((STA_WEP_ON(pAd
))||(STA_TKIP_ON(pAd
))))
1747 pAd
->CommonCfg
.IOTestParm
.bNextDisableRxBA
= TRUE
;
1748 if (pAd
->CommonCfg
.bEnableTxBurst
)
1750 UINT32 MACValue
= 0;
1751 // Force disable TXOP value in this case. The same action in MLMEUpdateProtect too.
1752 // I didn't change PBF_MAX_PCNT setting.
1753 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &MACValue
);
1754 MACValue
&= 0xFFFFFF00;
1755 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, MACValue
);
1756 pAd
->CommonCfg
.IOTestParm
.bNowAtherosBurstOn
= FALSE
;
1761 pAd
->CommonCfg
.IOTestParm
.bNextDisableRxBA
= FALSE
;
1764 pAd
->CommonCfg
.IOTestParm
.bLastAtheros
= FALSE
;
1765 COPY_MAC_ADDR(pAd
->CommonCfg
.LastBssid
, pAd
->CommonCfg
.Bssid
);
1766 DBGPRINT(RT_DEBUG_TRACE
, ("!!!pAd->bNextDisableRxBA= %d \n", pAd
->CommonCfg
.IOTestParm
.bNextDisableRxBA
));
1767 // BSSID add in one MAC entry too. Because in Tx, ASIC need to check Cipher and IV/EIV, BAbitmap
1768 // Pther information in MACTab.Content[BSSID_WCID] is not necessary for driver.
1769 // Note: As STA, The MACTab.Content[BSSID_WCID]. PairwiseKey and Shared Key for BSS0 are the same.
1771 if (pAd
->StaCfg
.WepStatus
<= Ndis802_11WEPDisabled
)
1773 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_SECURED
;
1774 pAd
->StaCfg
.PrivacyFilter
= Ndis802_11PrivFilterAcceptAll
;
1777 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1778 pEntry
->PortSecured
= pAd
->StaCfg
.PortSecured
;
1779 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1782 // Patch Atheros AP TX will breakdown issue.
1783 // AP Model: DLink DWL-8200AP
1785 if (INFRA_ON(pAd
) && OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_WMM_INUSED
) && STA_TKIP_ON(pAd
))
1787 RTMP_IO_WRITE32(pAd
, RX_PARSER_CFG
, 0x01);
1791 RTMP_IO_WRITE32(pAd
, RX_PARSER_CFG
, 0x00);
1794 RTMP_CLEAR_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
);
1796 RTMP_CLEAR_PSFLAG(pAd
, fRTMP_PS_GO_TO_SLEEP_NOW
);
1801 ==========================================================================
1803 Routine Description:
1804 Disconnect current BSSID
1807 pAd - Pointer to our adapter
1808 IsReqFromAP - Request from AP
1813 IRQL = DISPATCH_LEVEL
1816 We need more information to know it's this requst from AP.
1817 If yes! we need to do extra handling, for example, remove the WPA key.
1818 Otherwise on 4-way handshaking will faied, since the WPA key didn't be
1819 remove while auto reconnect.
1820 Disconnect request from AP, it means we will start afresh 4-way handshaking
1823 ==========================================================================
1826 IN PRTMP_ADAPTER pAd
,
1827 IN BOOLEAN IsReqFromAP
)
1829 UCHAR i
, ByteValue
= 0;
1834 // Do nothing if monitor mode is on
1835 if (MONITOR_ON(pAd
))
1839 RTMP_CLEAR_PSFLAG(pAd
, fRTMP_PS_GO_TO_SLEEP_NOW
);
1840 RTMPCancelTimer(&pAd
->Mlme
.PsPollTimer
, &Cancelled
);
1842 // Not allow go to sleep within linkdown function.
1843 RTMP_CLEAR_PSFLAG(pAd
, fRTMP_PS_CAN_GO_SLEEP
);
1846 if (pAd
->CommonCfg
.bWirelessEvent
)
1848 RTMPSendWirelessEvent(pAd
, IW_STA_LINKDOWN_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
1851 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK DOWN !!!\n"));
1852 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
1855 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE
))
1858 pAd
->Mlme
.bPsPollTimerRunning
= FALSE
;
1859 RTMPCancelTimer(&pAd
->Mlme
.PsPollTimer
, &Cancelled
);
1862 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_DOZE
) ||
1863 RTMP_TEST_PSFLAG(pAd
, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND
) ||
1864 RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_IDLE_RADIO_OFF
))
1866 AsicForceWakeup(pAd
, RTMP_HALT
);
1867 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_DOZE
);
1870 pAd
->bPCIclkOff
= FALSE
;
1872 if (ADHOC_ON(pAd
)) // Adhoc mode link down
1874 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK DOWN 1!!!\n"));
1876 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_ADHOC_ON
);
1877 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
1878 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
1879 RTMP_IndicateMediaState(pAd
);
1880 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
1881 BssTableDeleteEntry(&pAd
->ScanTab
, pAd
->CommonCfg
.Bssid
, pAd
->CommonCfg
.Channel
);
1882 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MacTab.Size=%d !!!\n", pAd
->MacTab
.Size
));
1884 else // Infra structure mode
1886 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK DOWN 2!!!\n"));
1888 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_INFRA_ON
);
1889 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
1891 // Saved last SSID for linkup comparison
1892 pAd
->CommonCfg
.LastSsidLen
= pAd
->CommonCfg
.SsidLen
;
1893 NdisMoveMemory(pAd
->CommonCfg
.LastSsid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.LastSsidLen
);
1894 COPY_MAC_ADDR(pAd
->CommonCfg
.LastBssid
, pAd
->CommonCfg
.Bssid
);
1895 if (pAd
->MlmeAux
.CurrReqIsFromNdis
== TRUE
)
1897 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
1898 RTMP_IndicateMediaState(pAd
);
1899 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
1900 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event A!\n"));
1901 pAd
->MlmeAux
.CurrReqIsFromNdis
= FALSE
;
1906 // If disassociation request is from NDIS, then we don't need to delete BSSID from entry.
1907 // Otherwise lost beacon or receive De-Authentication from AP,
1908 // then we should delete BSSID from BssTable.
1909 // If we don't delete from entry, roaming will fail.
1911 BssTableDeleteEntry(&pAd
->ScanTab
, pAd
->CommonCfg
.Bssid
, pAd
->CommonCfg
.Channel
);
1914 // restore back to -
1915 // 1. long slot (20 us) or short slot (9 us) time
1916 // 2. turn on/off RTS/CTS and/or CTS-to-self protection
1917 // 3. short preamble
1918 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_BG_PROTECTION_INUSED
);
1920 if (pAd
->StaCfg
.CCXAdjacentAPReportFlag
== TRUE
)
1923 // Record current AP's information.
1924 // for later used reporting Adjacent AP report.
1926 pAd
->StaCfg
.CCXAdjacentAPChannel
= pAd
->CommonCfg
.Channel
;
1927 pAd
->StaCfg
.CCXAdjacentAPSsidLen
= pAd
->CommonCfg
.SsidLen
;
1928 NdisMoveMemory(pAd
->StaCfg
.CCXAdjacentAPSsid
, pAd
->CommonCfg
.Ssid
, pAd
->StaCfg
.CCXAdjacentAPSsidLen
);
1929 COPY_MAC_ADDR(pAd
->StaCfg
.CCXAdjacentAPBssid
, pAd
->CommonCfg
.Bssid
);
1933 for (i
=1; i
<MAX_LEN_OF_MAC_TABLE
; i
++)
1935 if (pAd
->MacTab
.Content
[i
].ValidAsCLI
== TRUE
)
1936 MacTableDeleteEntry(pAd
, pAd
->MacTab
.Content
[i
].Aid
, pAd
->MacTab
.Content
[i
].Addr
);
1939 pAd
->StaCfg
.CCXQosECWMin
= 4;
1940 pAd
->StaCfg
.CCXQosECWMax
= 10;
1942 AsicSetSlotTime(pAd
, TRUE
); //FALSE);
1943 AsicSetEdcaParm(pAd
, NULL
);
1946 RTMPSetLED(pAd
, LED_LINK_DOWN
);
1947 pAd
->LedIndicatorStregth
= 0xF0;
1948 RTMPSetSignalLED(pAd
, -100); // Force signal strength Led to be turned off, firmware is not done it.
1950 AsicDisableSync(pAd
);
1952 pAd
->Mlme
.PeriodicRound
= 0;
1953 pAd
->Mlme
.OneSecPeriodicRound
= 0;
1955 if (pAd
->StaCfg
.BssType
== BSS_INFRA
)
1957 // Remove StaCfg Information after link down
1958 NdisZeroMemory(pAd
->CommonCfg
.Bssid
, MAC_ADDR_LEN
);
1959 NdisZeroMemory(pAd
->CommonCfg
.Ssid
, MAX_LEN_OF_SSID
);
1960 pAd
->CommonCfg
.SsidLen
= 0;
1963 NdisZeroMemory(&pAd
->MlmeAux
.HtCapability
, sizeof(HT_CAPABILITY_IE
));
1964 NdisZeroMemory(&pAd
->MlmeAux
.AddHtInfo
, sizeof(ADD_HT_INFO_IE
));
1965 pAd
->MlmeAux
.HtCapabilityLen
= 0;
1966 pAd
->MlmeAux
.NewExtChannelOffset
= 0xff;
1968 // Reset WPA-PSK state. Only reset when supplicant enabled
1969 if (pAd
->StaCfg
.WpaState
!= SS_NOTUSE
)
1971 pAd
->StaCfg
.WpaState
= SS_START
;
1972 // Clear Replay counter
1973 NdisZeroMemory(pAd
->StaCfg
.ReplayCounter
, 8);
1978 // if link down come from AP, we need to remove all WPA keys on WPA mode.
1979 // otherwise will cause 4-way handshaking failed, since the WPA key not empty.
1981 if ((IsReqFromAP
) && (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
))
1983 // Remove all WPA keys
1984 RTMPWPARemoveAllKeys(pAd
);
1987 // 802.1x port control
1989 // Prevent clear PortSecured here with static WEP
1990 // NetworkManger set security policy first then set SSID to connect AP.
1991 if (pAd
->StaCfg
.WpaSupplicantUP
&&
1992 (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
) &&
1993 (pAd
->StaCfg
.IEEE8021X
== FALSE
))
1995 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_SECURED
;
1999 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
2000 pAd
->StaCfg
.PrivacyFilter
= Ndis802_11PrivFilter8021xWEP
;
2003 NdisAcquireSpinLock(&pAd
->MacTabLock
);
2004 pAd
->MacTab
.Content
[BSSID_WCID
].PortSecured
= pAd
->StaCfg
.PortSecured
;
2005 NdisReleaseSpinLock(&pAd
->MacTabLock
);
2007 pAd
->StaCfg
.MicErrCnt
= 0;
2009 // Turn off Ckip control flag
2010 pAd
->StaCfg
.bCkipOn
= FALSE
;
2011 pAd
->StaCfg
.CCXEnable
= FALSE
;
2013 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
2014 // Update extra information to link is up
2015 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
2018 pAd
->StaCfg
.AdhocBOnlyJoined
= FALSE
;
2019 pAd
->StaCfg
.AdhocBGJoined
= FALSE
;
2020 pAd
->StaCfg
.Adhoc20NJoined
= FALSE
;
2022 pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
= FALSE
;
2024 // Reset the Current AP's IP address
2025 NdisZeroMemory(pAd
->StaCfg
.AironetIPAddress
, 4);
2027 pAd
->bUsbTxBulkAggre
= FALSE
;
2030 // Clean association information
2031 NdisZeroMemory(&pAd
->StaCfg
.AssocInfo
, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
));
2032 pAd
->StaCfg
.AssocInfo
.Length
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
2033 pAd
->StaCfg
.ReqVarIELen
= 0;
2034 pAd
->StaCfg
.ResVarIELen
= 0;
2037 // Reset RSSI value after link down
2039 pAd
->StaCfg
.RssiSample
.AvgRssi0
= 0;
2040 pAd
->StaCfg
.RssiSample
.AvgRssi0X8
= 0;
2041 pAd
->StaCfg
.RssiSample
.AvgRssi1
= 0;
2042 pAd
->StaCfg
.RssiSample
.AvgRssi1X8
= 0;
2043 pAd
->StaCfg
.RssiSample
.AvgRssi2
= 0;
2044 pAd
->StaCfg
.RssiSample
.AvgRssi2X8
= 0;
2047 pAd
->CommonCfg
.MlmeRate
= pAd
->CommonCfg
.BasicMlmeRate
;
2048 pAd
->CommonCfg
.RtsRate
= pAd
->CommonCfg
.BasicMlmeRate
;
2051 // After Link down, reset piggy-back setting in ASIC. Disable RDG.
2053 if (pAd
->CommonCfg
.BBPCurrentBW
== BW_40
)
2055 pAd
->CommonCfg
.BBPCurrentBW
= BW_20
;
2056 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &ByteValue
);
2057 ByteValue
&= (~0x18);
2058 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, ByteValue
);
2062 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &ByteValue
);
2063 ByteValue
&= (~0x18);
2064 if (pAd
->Antenna
.field
.TxPath
== 2)
2068 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, ByteValue
);
2070 RTMPSetPiggyBack(pAd
,FALSE
);
2071 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_PIGGYBACK_INUSED
);
2073 pAd
->CommonCfg
.BACapability
.word
= pAd
->CommonCfg
.REGBACapability
.word
;
2075 // Restore all settings in the following.
2076 AsicUpdateProtect(pAd
, 0, (ALLN_SETPROTECT
|CCKSETPROTECT
|OFDMSETPROTECT
), TRUE
, FALSE
);
2077 AsicDisableRDG(pAd
);
2078 pAd
->CommonCfg
.IOTestParm
.bCurrentAtheros
= FALSE
;
2079 pAd
->CommonCfg
.IOTestParm
.bNowAtherosBurstOn
= FALSE
;
2081 RTMP_IO_WRITE32(pAd
, MAX_LEN_CFG
, 0x1fff);
2082 RTMP_CLEAR_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
);
2085 // Allow go to sleep after linkdown steps.
2086 RTMP_SET_PSFLAG(pAd
, fRTMP_PS_CAN_GO_SLEEP
);
2090 union iwreq_data wrqu
;
2091 memset(wrqu
.ap_addr
.sa_data
, 0, MAC_ADDR_LEN
);
2092 wireless_send_event(pAd
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
2098 // disable MMPS BBP control register
2099 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &ByteValue
);
2100 ByteValue
&= ~(0x04); //bit 2
2101 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, ByteValue
);
2103 // disable MMPS MAC control register
2104 RTMP_IO_READ32(pAd
, 0x1210, &macdata
);
2105 macdata
&= ~(0x09); //bit 0, 3
2106 RTMP_IO_WRITE32(pAd
, 0x1210, macdata
);
2111 ==========================================================================
2114 IRQL = DISPATCH_LEVEL
2116 ==========================================================================
2118 VOID
IterateOnBssTab(
2119 IN PRTMP_ADAPTER pAd
)
2121 MLME_START_REQ_STRUCT StartReq
;
2122 MLME_JOIN_REQ_STRUCT JoinReq
;
2125 // Change the wepstatus to original wepstatus
2126 pAd
->StaCfg
.WepStatus
= pAd
->StaCfg
.OrigWepStatus
;
2127 pAd
->StaCfg
.PairCipher
= pAd
->StaCfg
.OrigWepStatus
;
2128 pAd
->StaCfg
.GroupCipher
= pAd
->StaCfg
.OrigWepStatus
;
2130 BssIdx
= pAd
->MlmeAux
.BssIdx
;
2131 if (BssIdx
< pAd
->MlmeAux
.SsidBssTab
.BssNr
)
2133 // Check cipher suite, AP must have more secured cipher than station setting
2134 // Set the Pairwise and Group cipher to match the intended AP setting
2135 // We can only connect to AP with less secured cipher setting
2136 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
))
2138 pAd
->StaCfg
.GroupCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.GroupCipher
;
2140 if (pAd
->StaCfg
.WepStatus
== pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipher
)
2141 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipher
;
2142 else if (pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
!= Ndis802_11WEPDisabled
)
2143 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
;
2144 else // There is no PairCipher Aux, downgrade our capability to TKIP
2145 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
2147 else if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
))
2149 pAd
->StaCfg
.GroupCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.GroupCipher
;
2151 if (pAd
->StaCfg
.WepStatus
== pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
)
2152 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
;
2153 else if (pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
!= Ndis802_11WEPDisabled
)
2154 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
;
2155 else // There is no PairCipher Aux, downgrade our capability to TKIP
2156 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
2159 pAd
->StaCfg
.RsnCapability
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.RsnCapability
;
2162 // Set Mix cipher flag
2163 pAd
->StaCfg
.bMixCipher
= (pAd
->StaCfg
.PairCipher
== pAd
->StaCfg
.GroupCipher
) ? FALSE
: TRUE
;
2164 if (pAd
->StaCfg
.bMixCipher
== TRUE
)
2166 // If mix cipher, re-build RSNIE
2167 RTMPMakeRSNIE(pAd
, pAd
->StaCfg
.AuthMode
, pAd
->StaCfg
.WepStatus
, 0);
2170 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - iterate BSS %ld of %d\n", BssIdx
, pAd
->MlmeAux
.SsidBssTab
.BssNr
));
2171 JoinParmFill(pAd
, &JoinReq
, BssIdx
);
2172 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_JOIN_REQ
, sizeof(MLME_JOIN_REQ_STRUCT
),
2174 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_JOIN
;
2176 else if (pAd
->StaCfg
.BssType
== BSS_ADHOC
)
2178 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",pAd
->MlmeAux
.Ssid
));
2179 StartParmFill(pAd
, &StartReq
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
2180 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_START_REQ
, sizeof(MLME_START_REQ_STRUCT
), &StartReq
);
2181 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_START
;
2185 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - All roaming failed, stay @ ch #%d\n", pAd
->CommonCfg
.Channel
));
2186 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
2187 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
2188 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
2192 // for re-association only
2193 // IRQL = DISPATCH_LEVEL
2194 VOID
IterateOnBssTab2(
2195 IN PRTMP_ADAPTER pAd
)
2197 MLME_REASSOC_REQ_STRUCT ReassocReq
;
2201 BssIdx
= pAd
->MlmeAux
.RoamIdx
;
2202 pBss
= &pAd
->MlmeAux
.RoamTab
.BssEntry
[BssIdx
];
2204 if (BssIdx
< pAd
->MlmeAux
.RoamTab
.BssNr
)
2206 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - iterate BSS %ld of %d\n", BssIdx
, pAd
->MlmeAux
.RoamTab
.BssNr
));
2208 AsicSwitchChannel(pAd
, pBss
->Channel
, FALSE
);
2209 AsicLockChannel(pAd
, pBss
->Channel
);
2211 // reassociate message has the same structure as associate message
2212 AssocParmFill(pAd
, &ReassocReq
, pBss
->Bssid
, pBss
->CapabilityInfo
,
2213 ASSOC_TIMEOUT
, pAd
->StaCfg
.DefaultListenCount
);
2214 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_REASSOC_REQ
,
2215 sizeof(MLME_REASSOC_REQ_STRUCT
), &ReassocReq
);
2217 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_REASSOC
;
2221 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - All fast roaming failed, back to ch #%d\n",pAd
->CommonCfg
.Channel
));
2222 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
2223 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
2224 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
2229 ==========================================================================
2232 IRQL = DISPATCH_LEVEL
2234 ==========================================================================
2237 IN PRTMP_ADAPTER pAd
,
2238 IN OUT MLME_JOIN_REQ_STRUCT
*JoinReq
,
2241 JoinReq
->BssIdx
= BssIdx
;
2245 ==========================================================================
2248 IRQL = DISPATCH_LEVEL
2250 ==========================================================================
2253 IN PRTMP_ADAPTER pAd
,
2254 IN OUT MLME_SCAN_REQ_STRUCT
*ScanReq
,
2260 NdisZeroMemory(ScanReq
->Ssid
, MAX_LEN_OF_SSID
);
2261 ScanReq
->SsidLen
= SsidLen
;
2262 NdisMoveMemory(ScanReq
->Ssid
, Ssid
, SsidLen
);
2263 ScanReq
->BssType
= BssType
;
2264 ScanReq
->ScanType
= ScanType
;
2268 ==========================================================================
2271 IRQL = DISPATCH_LEVEL
2273 ==========================================================================
2276 IN PRTMP_ADAPTER pAd
,
2277 IN OUT MLME_START_REQ_STRUCT
*StartReq
,
2281 ASSERT(SsidLen
<= MAX_LEN_OF_SSID
);
2282 NdisMoveMemory(StartReq
->Ssid
, Ssid
, SsidLen
);
2283 StartReq
->SsidLen
= SsidLen
;
2287 ==========================================================================
2290 IRQL = DISPATCH_LEVEL
2292 ==========================================================================
2295 IN PRTMP_ADAPTER pAd
,
2296 IN OUT MLME_AUTH_REQ_STRUCT
*AuthReq
,
2300 COPY_MAC_ADDR(AuthReq
->Addr
, pAddr
);
2302 AuthReq
->Timeout
= AUTH_TIMEOUT
;
2306 ==========================================================================
2309 IRQL = DISPATCH_LEVEL
2311 ==========================================================================
2317 VOID
MlmeCntlConfirm(
2318 IN PRTMP_ADAPTER pAd
,
2322 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MsgType
, sizeof(USHORT
), &Msg
);
2327 IN PRTMP_ADAPTER pAd
)
2330 PTXINFO_STRUC pTxInfo
;
2333 DBGPRINT(RT_DEBUG_TRACE
, ("ComposePsPoll\n"));
2335 NdisZeroMemory(&pAd
->PsPollFrame
, sizeof(PSPOLL_FRAME
));
2338 pAd
->PsPollFrame
.FC
.PwrMgmt
= 0;
2340 pAd
->PsPollFrame
.FC
.Type
= BTYPE_CNTL
;
2341 pAd
->PsPollFrame
.FC
.SubType
= SUBTYPE_PS_POLL
;
2342 pAd
->PsPollFrame
.Aid
= pAd
->StaActive
.Aid
| 0xC000;
2343 COPY_MAC_ADDR(pAd
->PsPollFrame
.Bssid
, pAd
->CommonCfg
.Bssid
);
2344 COPY_MAC_ADDR(pAd
->PsPollFrame
.Ta
, pAd
->CurrentAddress
);
2347 RTMPZeroMemory(&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[0], 100);
2348 pTxInfo
= (PTXINFO_STRUC
)&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[0];
2349 RTMPWriteTxInfo(pAd
, pTxInfo
, (USHORT
)(sizeof(PSPOLL_FRAME
)+TXWI_SIZE
), TRUE
, EpToQueue
[MGMTPIPEIDX
], FALSE
, FALSE
);
2350 pTxWI
= (PTXWI_STRUC
)&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[TXINFO_SIZE
];
2351 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, FALSE
, FALSE
, TRUE
, FALSE
, 0, BSSID_WCID
, (sizeof(PSPOLL_FRAME
)),
2352 0, 0, (UCHAR
)pAd
->CommonCfg
.MlmeTransmit
.field
.MCS
, IFS_BACKOFF
, FALSE
, &pAd
->CommonCfg
.MlmeTransmit
);
2353 RTMPMoveMemory(&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[TXWI_SIZE
+TXINFO_SIZE
], &pAd
->PsPollFrame
, sizeof(PSPOLL_FRAME
));
2354 // Append 4 extra zero bytes.
2355 pAd
->PsPollContext
.BulkOutSize
= TXINFO_SIZE
+ TXWI_SIZE
+ sizeof(PSPOLL_FRAME
) + 4;
2359 // IRQL = DISPATCH_LEVEL
2360 VOID
ComposeNullFrame(
2361 IN PRTMP_ADAPTER pAd
)
2364 PTXINFO_STRUC pTxInfo
;
2368 NdisZeroMemory(&pAd
->NullFrame
, sizeof(HEADER_802_11
));
2369 pAd
->NullFrame
.FC
.Type
= BTYPE_DATA
;
2370 pAd
->NullFrame
.FC
.SubType
= SUBTYPE_NULL_FUNC
;
2371 pAd
->NullFrame
.FC
.ToDs
= 1;
2372 COPY_MAC_ADDR(pAd
->NullFrame
.Addr1
, pAd
->CommonCfg
.Bssid
);
2373 COPY_MAC_ADDR(pAd
->NullFrame
.Addr2
, pAd
->CurrentAddress
);
2374 COPY_MAC_ADDR(pAd
->NullFrame
.Addr3
, pAd
->CommonCfg
.Bssid
);
2376 RTMPZeroMemory(&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[0], 100);
2377 pTxInfo
= (PTXINFO_STRUC
)&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[0];
2378 RTMPWriteTxInfo(pAd
, pTxInfo
, (USHORT
)(sizeof(HEADER_802_11
)+TXWI_SIZE
), TRUE
, EpToQueue
[MGMTPIPEIDX
], FALSE
, FALSE
);
2379 pTxWI
= (PTXWI_STRUC
)&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[TXINFO_SIZE
];
2380 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, FALSE
, FALSE
, TRUE
, FALSE
, 0, BSSID_WCID
, (sizeof(HEADER_802_11
)),
2381 0, 0, (UCHAR
)pAd
->CommonCfg
.MlmeTransmit
.field
.MCS
, IFS_BACKOFF
, FALSE
, &pAd
->CommonCfg
.MlmeTransmit
);
2382 RTMPMoveMemory(&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[TXWI_SIZE
+TXINFO_SIZE
], &pAd
->NullFrame
, sizeof(HEADER_802_11
));
2383 pAd
->NullContext
.BulkOutSize
= TXINFO_SIZE
+ TXWI_SIZE
+ sizeof(pAd
->NullFrame
) + 4;
2391 ==========================================================================
2393 Pre-build a BEACON frame in the shared memory
2395 IRQL = PASSIVE_LEVEL
2396 IRQL = DISPATCH_LEVEL
2398 ==========================================================================
2400 ULONG
MakeIbssBeacon(
2401 IN PRTMP_ADAPTER pAd
)
2403 UCHAR DsLen
= 1, IbssLen
= 2;
2404 UCHAR LocalErpIe
[3] = {IE_ERP
, 1, 0x04};
2405 HEADER_802_11 BcnHdr
;
2406 USHORT CapabilityInfo
;
2407 LARGE_INTEGER FakeTimestamp
;
2409 PTXWI_STRUC pTxWI
= &pAd
->BeaconTxWI
;
2410 CHAR
*pBeaconFrame
= pAd
->BeaconBuf
;
2412 UCHAR SupRate
[MAX_LEN_OF_SUPPORTED_RATES
];
2413 UCHAR SupRateLen
= 0;
2414 UCHAR ExtRate
[MAX_LEN_OF_SUPPORTED_RATES
];
2415 UCHAR ExtRateLen
= 0;
2416 UCHAR RSNIe
= IE_WPA
;
2418 if ((pAd
->CommonCfg
.PhyMode
== PHY_11B
) && (pAd
->CommonCfg
.Channel
<= 14))
2420 SupRate
[0] = 0x82; // 1 mbps
2421 SupRate
[1] = 0x84; // 2 mbps
2422 SupRate
[2] = 0x8b; // 5.5 mbps
2423 SupRate
[3] = 0x96; // 11 mbps
2427 else if (pAd
->CommonCfg
.Channel
> 14)
2429 SupRate
[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
2430 SupRate
[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
2431 SupRate
[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
2432 SupRate
[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
2433 SupRate
[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
2434 SupRate
[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
2435 SupRate
[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
2436 SupRate
[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2441 // Also Update MlmeRate & RtsRate for G only & A only
2443 pAd
->CommonCfg
.MlmeRate
= RATE_6
;
2444 pAd
->CommonCfg
.RtsRate
= RATE_6
;
2445 pAd
->CommonCfg
.MlmeTransmit
.field
.MODE
= MODE_OFDM
;
2446 pAd
->CommonCfg
.MlmeTransmit
.field
.MCS
= OfdmRateToRxwiMCS
[pAd
->CommonCfg
.MlmeRate
];
2447 pAd
->MacTab
.Content
[BSS0Mcast_WCID
].HTPhyMode
.field
.MODE
= MODE_OFDM
;
2448 pAd
->MacTab
.Content
[BSS0Mcast_WCID
].HTPhyMode
.field
.MCS
= OfdmRateToRxwiMCS
[pAd
->CommonCfg
.MlmeRate
];
2452 SupRate
[0] = 0x82; // 1 mbps
2453 SupRate
[1] = 0x84; // 2 mbps
2454 SupRate
[2] = 0x8b; // 5.5 mbps
2455 SupRate
[3] = 0x96; // 11 mbps
2458 ExtRate
[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps,
2459 ExtRate
[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
2460 ExtRate
[2] = 0x18; // 12 mbps, in units of 0.5 Mbps,
2461 ExtRate
[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
2462 ExtRate
[4] = 0x30; // 24 mbps, in units of 0.5 Mbps,
2463 ExtRate
[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
2464 ExtRate
[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
2465 ExtRate
[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2469 pAd
->StaActive
.SupRateLen
= SupRateLen
;
2470 NdisMoveMemory(pAd
->StaActive
.SupRate
, SupRate
, SupRateLen
);
2471 pAd
->StaActive
.ExtRateLen
= ExtRateLen
;
2472 NdisMoveMemory(pAd
->StaActive
.ExtRate
, ExtRate
, ExtRateLen
);
2474 // compose IBSS beacon frame
2475 MgtMacHeaderInit(pAd
, &BcnHdr
, SUBTYPE_BEACON
, 0, BROADCAST_ADDR
, pAd
->CommonCfg
.Bssid
);
2476 Privacy
= (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption1Enabled
) ||
2477 (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption2Enabled
) ||
2478 (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption3Enabled
);
2479 CapabilityInfo
= CAP_GENERATE(0, 1, Privacy
, (pAd
->CommonCfg
.TxPreamble
== Rt802_11PreambleShort
), 0, 0);
2481 MakeOutgoingFrame(pBeaconFrame
, &FrameLen
,
2482 sizeof(HEADER_802_11
), &BcnHdr
,
2483 TIMESTAMP_LEN
, &FakeTimestamp
,
2484 2, &pAd
->CommonCfg
.BeaconPeriod
,
2487 1, &pAd
->CommonCfg
.SsidLen
,
2488 pAd
->CommonCfg
.SsidLen
, pAd
->CommonCfg
.Ssid
,
2491 SupRateLen
, SupRate
,
2494 1, &pAd
->CommonCfg
.Channel
,
2497 2, &pAd
->StaActive
.AtimWin
,
2500 // add ERP_IE and EXT_RAE IE of in 802.11g
2505 MakeOutgoingFrame(pBeaconFrame
+ FrameLen
, &tmp
,
2509 ExtRateLen
, ExtRate
,
2514 // If adhoc secruity is set for WPA-None, append the cipher suite IE
2515 if (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
2518 RTMPMakeRSNIE(pAd
, pAd
->StaCfg
.AuthMode
, pAd
->StaCfg
.WepStatus
, BSS0
);
2520 MakeOutgoingFrame(pBeaconFrame
+ FrameLen
, &tmp
,
2522 1, &pAd
->StaCfg
.RSNIE_Len
,
2523 pAd
->StaCfg
.RSNIE_Len
, pAd
->StaCfg
.RSN_IE
,
2528 if ((pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
))
2531 UCHAR HtLen
, HtLen1
;
2533 // add HT Capability IE
2534 HtLen
= sizeof(pAd
->CommonCfg
.HtCapability
);
2535 HtLen1
= sizeof(pAd
->CommonCfg
.AddHTInfo
);
2537 MakeOutgoingFrame(pBeaconFrame
+FrameLen
, &TmpLen
,
2540 HtLen
, &pAd
->CommonCfg
.HtCapability
,
2543 HtLen1
, &pAd
->CommonCfg
.AddHTInfo
,
2549 //beacon use reserved WCID 0xff
2550 if (pAd
->CommonCfg
.Channel
> 14)
2552 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, TRUE
, FALSE
, FALSE
, TRUE
, 0, 0xff, FrameLen
,
2553 PID_MGMT
, PID_BEACON
, RATE_1
, IFS_HTTXOP
, FALSE
, &pAd
->CommonCfg
.MlmeTransmit
);
2557 // Set to use 1Mbps for Adhoc beacon.
2558 HTTRANSMIT_SETTING Transmit
;
2560 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, TRUE
, FALSE
, FALSE
, TRUE
, 0, 0xff, FrameLen
,
2561 PID_MGMT
, PID_BEACON
, RATE_1
, IFS_HTTXOP
, FALSE
, &Transmit
);
2564 DBGPRINT(RT_DEBUG_TRACE
, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n",
2565 FrameLen
, SupRateLen
, ExtRateLen
, pAd
->CommonCfg
.Channel
, pAd
->CommonCfg
.PhyMode
));