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
)
126 CntlIdleProc(pAd
, Elem
);
128 case CNTL_WAIT_DISASSOC
:
129 CntlWaitDisassocProc(pAd
, Elem
);
132 CntlWaitJoinProc(pAd
, Elem
);
135 // CNTL_WAIT_REASSOC is the only state in CNTL machine that does
136 // not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
137 // Therefore not protected by NDIS's "only one outstanding OID request"
138 // rule. Which means NDIS may SET OID in the middle of ROAMing attempts.
139 // Current approach is to block new SET request at RTMPSetInformation()
140 // when CntlMachine.CurrState is not CNTL_IDLE
141 case CNTL_WAIT_REASSOC
:
142 CntlWaitReassocProc(pAd
, Elem
);
145 case CNTL_WAIT_START
:
146 CntlWaitStartProc(pAd
, Elem
);
149 CntlWaitAuthProc(pAd
, Elem
);
151 case CNTL_WAIT_AUTH2
:
152 CntlWaitAuthProc2(pAd
, Elem
);
154 case CNTL_WAIT_ASSOC
:
155 CntlWaitAssocProc(pAd
, Elem
);
158 case CNTL_WAIT_OID_LIST_SCAN
:
159 if(Elem
->MsgType
== MT2_SCAN_CONF
)
161 // Resume TxRing after SCANING complete. We hope the out-of-service time
162 // won't be too long to let upper layer time-out the waiting frames
163 RTMPResumeMsduTransmission(pAd
);
164 if (pAd
->StaCfg
.CCXReqType
!= MSRN_TYPE_UNUSED
)
166 // Cisco scan request is finished, prepare beacon report
167 MlmeEnqueue(pAd
, AIRONET_STATE_MACHINE
, MT2_AIRONET_SCAN_DONE
, 0, NULL
);
169 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
172 // Set LED status to previous status.
174 if (pAd
->bLedOnScanning
)
176 pAd
->bLedOnScanning
= FALSE
;
177 RTMPSetLED(pAd
, pAd
->LedStatus
);
180 // AP sent a 2040Coexistence mgmt frame, then station perform a scan, and then send back the respone.
181 if (pAd
->CommonCfg
.BSSCoexist2040
.field
.InfoReq
== 1)
183 Update2040CoexistFrameAndNotify(pAd
, BSSID_WCID
, TRUE
);
185 #endif // DOT11N_DRAFT3 //
189 case CNTL_WAIT_OID_DISASSOC
:
190 if (Elem
->MsgType
== MT2_DISASSOC_CONF
)
192 LinkDown(pAd
, FALSE
);
193 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
198 // This state is for that we want to connect to an AP but
199 // it didn't find on BSS List table. So we need to scan the air first,
200 // after that we can try to connect to the desired AP if available.
202 case CNTL_WAIT_SCAN_FOR_CONNECT
:
203 if(Elem
->MsgType
== MT2_SCAN_CONF
)
205 // Resume TxRing after SCANING complete. We hope the out-of-service time
206 // won't be too long to let upper layer time-out the waiting frames
207 RTMPResumeMsduTransmission(pAd
);
209 if (pAd
->StaCfg
.CCXReqType
!= MSRN_TYPE_UNUSED
)
211 // Cisco scan request is finished, prepare beacon report
212 MlmeEnqueue(pAd
, AIRONET_STATE_MACHINE
, MT2_AIRONET_SCAN_DONE
, 0, NULL
);
214 #endif // CCX_SUPPORT //
215 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
218 // Check if we can connect to.
220 BssTableSsidSort(pAd
, &pAd
->MlmeAux
.SsidBssTab
, pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.AutoReconnectSsidLen
);
221 if (pAd
->MlmeAux
.SsidBssTab
.BssNr
> 0)
223 MlmeAutoReconnectLastSSID(pAd
);
229 DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", Elem
->MsgType
));
236 ==========================================================================
239 IRQL = DISPATCH_LEVEL
241 ==========================================================================
244 IN PRTMP_ADAPTER pAd
,
245 IN MLME_QUEUE_ELEM
*Elem
)
247 MLME_DISASSOC_REQ_STRUCT DisassocReq
;
249 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_RADIO_OFF
))
252 switch(Elem
->MsgType
)
254 case OID_802_11_SSID
:
255 CntlOidSsidProc(pAd
, Elem
);
258 case OID_802_11_BSSID
:
259 CntlOidRTBssidProc(pAd
,Elem
);
262 case OID_802_11_BSSID_LIST_SCAN
:
263 CntlOidScanProc(pAd
,Elem
);
266 case OID_802_11_DISASSOCIATE
:
270 DBGPRINT(RT_DEBUG_TRACE
, ("The driver is in ATE mode now\n"));
273 #endif // RALINK_ATE //
274 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
275 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
, sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
276 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_DISASSOC
;
277 #ifdef WPA_SUPPLICANT_SUPPORT
278 if (pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_ENABLE_WITH_WEB_UI
)
279 #endif // WPA_SUPPLICANT_SUPPORT //
281 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
282 // Since calling this indicate user don't want to connect to that SSID anymore.
283 pAd
->MlmeAux
.AutoReconnectSsidLen
= 32;
284 NdisZeroMemory(pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.AutoReconnectSsidLen
);
288 case MT2_MLME_ROAMING_REQ
:
289 CntlMlmeRoamingProc(pAd
, Elem
);
292 case OID_802_11_MIC_FAILURE_REPORT_FRAME
:
293 WpaMicFailureReportFrame(pAd
, Elem
);
296 #ifdef QOS_DLS_SUPPORT
297 case RT_OID_802_11_SET_DLS_PARAM
:
298 CntlOidDLSSetupProc(pAd
, Elem
);
300 #endif // QOS_DLS_SUPPORT //
303 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem
->MsgType
));
308 VOID
CntlOidScanProc(
309 IN PRTMP_ADAPTER pAd
,
310 IN MLME_QUEUE_ELEM
*Elem
)
312 MLME_SCAN_REQ_STRUCT ScanReq
;
313 ULONG BssIdx
= BSS_NOT_FOUND
;
317 /* Disable scanning when ATE is running. */
320 #endif // RALINK_ATE //
323 // record current BSS if network is connected.
324 // 2003-2-13 do not include current IBSS if this is the only STA in this IBSS.
325 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
))
327 BssIdx
= BssSsidTableSearch(&pAd
->ScanTab
, pAd
->CommonCfg
.Bssid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.SsidLen
, pAd
->CommonCfg
.Channel
);
328 if (BssIdx
!= BSS_NOT_FOUND
)
330 NdisMoveMemory(&CurrBss
, &pAd
->ScanTab
.BssEntry
[BssIdx
], sizeof(BSS_ENTRY
));
334 // clean up previous SCAN result, add current BSS back to table if any
335 BssTableInit(&pAd
->ScanTab
);
336 if (BssIdx
!= BSS_NOT_FOUND
)
338 // DDK Note: If the NIC is associated with a particular BSSID and SSID
339 // that are not contained in the list of BSSIDs generated by this scan, the
340 // BSSID description of the currently associated BSSID and SSID should be
341 // appended to the list of BSSIDs in the NIC's database.
342 // To ensure this, we append this BSS as the first entry in SCAN result
343 NdisMoveMemory(&pAd
->ScanTab
.BssEntry
[0], &CurrBss
, sizeof(BSS_ENTRY
));
344 pAd
->ScanTab
.BssNr
= 1;
347 ScanParmFill(pAd
, &ScanReq
, "", 0, BSS_ANY
, SCAN_ACTIVE
);
348 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_SCAN_REQ
,
349 sizeof(MLME_SCAN_REQ_STRUCT
), &ScanReq
);
350 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_LIST_SCAN
;
354 ==========================================================================
356 Before calling this routine, user desired SSID should already been
357 recorded in CommonCfg.Ssid[]
358 IRQL = DISPATCH_LEVEL
360 ==========================================================================
362 VOID
CntlOidSsidProc(
363 IN PRTMP_ADAPTER pAd
,
364 IN MLME_QUEUE_ELEM
* Elem
)
366 PNDIS_802_11_SSID pOidSsid
= (NDIS_802_11_SSID
*)Elem
->Msg
;
367 MLME_DISASSOC_REQ_STRUCT DisassocReq
;
370 // Step 1. record the desired user settings to MlmeAux
371 NdisZeroMemory(pAd
->MlmeAux
.Ssid
, MAX_LEN_OF_SSID
);
372 NdisMoveMemory(pAd
->MlmeAux
.Ssid
, pOidSsid
->Ssid
, pOidSsid
->SsidLength
);
373 pAd
->MlmeAux
.SsidLen
= (UCHAR
)pOidSsid
->SsidLength
;
374 NdisZeroMemory(pAd
->MlmeAux
.Bssid
, MAC_ADDR_LEN
);
375 pAd
->MlmeAux
.BssType
= pAd
->StaCfg
.BssType
;
379 // Update Reconnect Ssid, that user desired to connect.
381 NdisZeroMemory(pAd
->MlmeAux
.AutoReconnectSsid
, MAX_LEN_OF_SSID
);
382 NdisMoveMemory(pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
383 pAd
->MlmeAux
.AutoReconnectSsidLen
= pAd
->MlmeAux
.SsidLen
;
385 // step 2. find all matching BSS in the lastest SCAN result (inBssTab)
386 // & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order
387 BssTableSsidSort(pAd
, &pAd
->MlmeAux
.SsidBssTab
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
389 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - %d BSS of %d BSS match the desire (%d)SSID - %s\n",
390 pAd
->MlmeAux
.SsidBssTab
.BssNr
, pAd
->ScanTab
.BssNr
, pAd
->MlmeAux
.SsidLen
, pAd
->MlmeAux
.Ssid
));
391 NdisGetSystemUpTime(&Now
);
393 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
) &&
394 (pAd
->CommonCfg
.SsidLen
== pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0].SsidLen
) &&
395 NdisEqualMemory(pAd
->CommonCfg
.Ssid
, pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0].Ssid
, pAd
->CommonCfg
.SsidLen
) &&
396 MAC_ADDR_EQUAL(pAd
->CommonCfg
.Bssid
, pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0].Bssid
))
398 // Case 1. already connected with an AP who has the desired SSID
401 // Add checking Mode "LEAP" for CCX 1.0
402 if (((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) ||
403 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
) ||
404 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
) ||
405 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
)
407 || (pAd
->StaCfg
.LeapAuthMode
== CISCO_AuthModeLEAP
)
408 #endif // LEAP_SUPPORT //
410 (pAd
->StaCfg
.PortSecured
== WPA_802_1X_PORT_NOT_SECURED
))
412 // case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
413 // connection process
414 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
415 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
416 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
417 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
418 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
420 else if (pAd
->bConfigChanged
== TRUE
)
422 // case 1.2 Important Config has changed, we have to reconnect to the same AP
423 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n"));
424 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
425 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
426 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
427 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
431 // case 1.3. already connected to the SSID with highest RSSI.
432 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n"));
434 // (HCT 12.1) 1c_wlan_mediaevents required
435 // media connect events are indicated when associating with the same AP
440 // Since MediaState already is NdisMediaStateConnected
441 // We just indicate the connect event again to meet the WHQL required.
443 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
444 RTMP_IndicateMediaState(pAd
);
445 pAd
->ExtraInfo
= GENERAL_LINK_UP
; // Update extra information to link is up
448 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
449 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
451 union iwreq_data wrqu
;
453 memset(wrqu
.ap_addr
.sa_data
, 0, MAC_ADDR_LEN
);
454 memcpy(wrqu
.ap_addr
.sa_data
, pAd
->MlmeAux
.Bssid
, MAC_ADDR_LEN
);
455 wireless_send_event(pAd
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
458 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
461 else if (INFRA_ON(pAd
))
465 // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
466 // RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect
467 // But media status is connected, so the SSID not report correctly.
469 if (!SSID_EQUAL(pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.SsidLen
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
))
472 // Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event.
474 pAd
->MlmeAux
.CurrReqIsFromNdis
= TRUE
;
476 // case 2. active INFRA association existent
477 // roaming is done within miniport driver, nothing to do with configuration
478 // utility. so upon a new SET(OID_802_11_SSID) is received, we just
479 // disassociate with the current associated AP,
480 // then perform a new association with this new SSID, no matter the
481 // new/old SSID are the same or not.
482 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
483 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
484 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
485 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
486 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
492 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - drop current ADHOC\n"));
493 LinkDown(pAd
, FALSE
);
494 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
495 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
496 RTMP_IndicateMediaState(pAd
);
497 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
498 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
501 if ((pAd
->MlmeAux
.SsidBssTab
.BssNr
== 0) &&
502 (pAd
->StaCfg
.bAutoReconnect
== TRUE
) &&
503 (pAd
->MlmeAux
.BssType
== BSS_INFRA
) &&
504 (MlmeValidateSSID(pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
) == TRUE
)
507 MLME_SCAN_REQ_STRUCT ScanReq
;
509 DBGPRINT(RT_DEBUG_TRACE
, ("CntlOidSsidProc():CNTL - No matching BSS, start a new scan\n"));
510 ScanParmFill(pAd
, &ScanReq
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
, BSS_ANY
, SCAN_ACTIVE
);
511 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_SCAN_REQ
, sizeof(MLME_SCAN_REQ_STRUCT
), &ScanReq
);
512 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_LIST_SCAN
;
513 // Reset Missed scan number
514 pAd
->StaCfg
.LastScanTime
= Now
;
518 pAd
->MlmeAux
.BssIdx
= 0;
519 IterateOnBssTab(pAd
);
526 ==========================================================================
529 IRQL = DISPATCH_LEVEL
531 ==========================================================================
533 VOID
CntlOidRTBssidProc(
534 IN PRTMP_ADAPTER pAd
,
535 IN MLME_QUEUE_ELEM
* Elem
)
538 PUCHAR pOidBssid
= (PUCHAR
)Elem
->Msg
;
539 MLME_DISASSOC_REQ_STRUCT DisassocReq
;
540 MLME_JOIN_REQ_STRUCT JoinReq
;
543 /* No need to perform this routine when ATE is running. */
546 #endif // RALINK_ATE //
548 // record user desired settings
549 COPY_MAC_ADDR(pAd
->MlmeAux
.Bssid
, pOidBssid
);
550 pAd
->MlmeAux
.BssType
= pAd
->StaCfg
.BssType
;
553 // Update Reconnect Ssid, that user desired to connect.
555 NdisZeroMemory(pAd
->MlmeAux
.AutoReconnectSsid
, MAX_LEN_OF_SSID
);
556 pAd
->MlmeAux
.AutoReconnectSsidLen
= pAd
->MlmeAux
.SsidLen
;
557 NdisMoveMemory(pAd
->MlmeAux
.AutoReconnectSsid
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
559 // find the desired BSS in the latest SCAN result table
560 BssIdx
= BssTableSearch(&pAd
->ScanTab
, pOidBssid
, pAd
->MlmeAux
.Channel
);
561 if (BssIdx
== BSS_NOT_FOUND
)
563 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
564 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
568 // copy the matched BSS entry from ScanTab to MlmeAux.SsidBssTab. Why?
569 // Because we need this entry to become the JOIN target in later on SYNC state machine
570 pAd
->MlmeAux
.BssIdx
= 0;
571 pAd
->MlmeAux
.SsidBssTab
.BssNr
= 1;
572 NdisMoveMemory(&pAd
->MlmeAux
.SsidBssTab
.BssEntry
[0], &pAd
->ScanTab
.BssEntry
[BssIdx
], sizeof(BSS_ENTRY
));
574 //pAd->MlmeAux.AutoReconnectSsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
575 //NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->ScanTab.BssEntry[BssIdx].SsidLen);
577 // Add SSID into MlmeAux for site surey joining hidden SSID
578 //pAd->MlmeAux.SsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
579 //NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->MlmeAux.SsidLen);
581 // 2002-11-26 skip the following checking. i.e. if user wants to re-connect to same AP
582 // we just follow normal procedure. The reason of user doing this may because he/she changed
583 // AP to another channel, but we still received BEACON from it thus don't claim Link Down.
584 // Since user knows he's changed AP channel, he'll re-connect again. By skipping the following
585 // checking, we'll disassociate then re-do normal association with this AP at the new channel.
586 // 2003-1-6 Re-enable this feature based on microsoft requirement which prefer not to re-do
587 // connection when setting the same BSSID.
588 if (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
) &&
589 MAC_ADDR_EQUAL(pAd
->CommonCfg
.Bssid
, pOidBssid
))
591 // already connected to the same BSSID, go back to idle state directly
592 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - already in this BSSID. ignore this SET_BSSID request\n"));
593 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
594 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
596 union iwreq_data wrqu
;
598 memset(wrqu
.ap_addr
.sa_data
, 0, MAC_ADDR_LEN
);
599 memcpy(wrqu
.ap_addr
.sa_data
, pAd
->MlmeAux
.Bssid
, MAC_ADDR_LEN
);
600 wireless_send_event(pAd
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
603 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
609 // disassoc from current AP first
610 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - disassociate with current AP ...\n"));
611 DisassocParmFill(pAd
, &DisassocReq
, pAd
->CommonCfg
.Bssid
, REASON_DISASSOC_STA_LEAVING
);
612 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_DISASSOC_REQ
,
613 sizeof(MLME_DISASSOC_REQ_STRUCT
), &DisassocReq
);
615 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_DISASSOC
;
621 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - drop current ADHOC\n"));
622 LinkDown(pAd
, FALSE
);
623 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
624 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
625 RTMP_IndicateMediaState(pAd
);
626 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
627 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
630 // Change the wepstatus to original wepstatus
631 pAd
->StaCfg
.WepStatus
= pAd
->StaCfg
.OrigWepStatus
;
632 pAd
->StaCfg
.PairCipher
= pAd
->StaCfg
.OrigWepStatus
;
633 pAd
->StaCfg
.GroupCipher
= pAd
->StaCfg
.OrigWepStatus
;
635 // Check cipher suite, AP must have more secured cipher than station setting
636 // Set the Pairwise and Group cipher to match the intended AP setting
637 // We can only connect to AP with less secured cipher setting
638 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
))
640 pAd
->StaCfg
.GroupCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.GroupCipher
;
642 if (pAd
->StaCfg
.WepStatus
== pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipher
)
643 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipher
;
644 else if (pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
!= Ndis802_11WEPDisabled
)
645 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
;
646 else // There is no PairCipher Aux, downgrade our capability to TKIP
647 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
649 else if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
))
651 pAd
->StaCfg
.GroupCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.GroupCipher
;
653 if (pAd
->StaCfg
.WepStatus
== pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
)
654 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
;
655 else if (pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
!= Ndis802_11WEPDisabled
)
656 pAd
->StaCfg
.PairCipher
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
;
657 else // There is no PairCipher Aux, downgrade our capability to TKIP
658 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
661 pAd
->StaCfg
.RsnCapability
= pAd
->ScanTab
.BssEntry
[BssIdx
].WPA2
.RsnCapability
;
664 // Set Mix cipher flag
665 pAd
->StaCfg
.bMixCipher
= (pAd
->StaCfg
.PairCipher
== pAd
->StaCfg
.GroupCipher
) ? FALSE
: TRUE
;
666 if (pAd
->StaCfg
.bMixCipher
== TRUE
)
668 // If mix cipher, re-build RSNIE
669 RTMPMakeRSNIE(pAd
, pAd
->StaCfg
.AuthMode
, pAd
->StaCfg
.WepStatus
, 0);
671 // No active association, join the BSS immediately
672 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n",
673 pOidBssid
[0],pOidBssid
[1],pOidBssid
[2],pOidBssid
[3],pOidBssid
[4],pOidBssid
[5]));
675 JoinParmFill(pAd
, &JoinReq
, pAd
->MlmeAux
.BssIdx
);
676 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_JOIN_REQ
, sizeof(MLME_JOIN_REQ_STRUCT
), &JoinReq
);
678 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_JOIN
;
683 // Roaming is the only external request triggering CNTL state machine
684 // despite of other "SET OID" operation. All "SET OID" related oerations
685 // happen in sequence, because no other SET OID will be sent to this device
686 // until the the previous SET operation is complete (successful o failed).
687 // So, how do we quarantee this ROAMING request won't corrupt other "SET OID"?
688 // or been corrupted by other "SET OID"?
690 // IRQL = DISPATCH_LEVEL
691 VOID
CntlMlmeRoamingProc(
692 IN PRTMP_ADAPTER pAd
,
693 IN MLME_QUEUE_ELEM
*Elem
)
696 // AP in different channel may show lower RSSI than actual value??
697 // should we add a weighting factor to compensate it?
698 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - Roaming in MlmeAux.RoamTab...\n"));
700 NdisMoveMemory(&pAd
->MlmeAux
.SsidBssTab
, &pAd
->MlmeAux
.RoamTab
, sizeof(pAd
->MlmeAux
.RoamTab
));
701 pAd
->MlmeAux
.SsidBssTab
.BssNr
= pAd
->MlmeAux
.RoamTab
.BssNr
;
703 BssTableSortByRssi(&pAd
->MlmeAux
.SsidBssTab
);
704 pAd
->MlmeAux
.BssIdx
= 0;
705 IterateOnBssTab(pAd
);
708 #ifdef QOS_DLS_SUPPORT
710 ==========================================================================
713 IRQL = DISPATCH_LEVEL
715 ==========================================================================
717 VOID
CntlOidDLSSetupProc(
718 IN PRTMP_ADAPTER pAd
,
719 IN MLME_QUEUE_ELEM
*Elem
)
721 PRT_802_11_DLS pDLS
= (PRT_802_11_DLS
)Elem
->Msg
;
722 MLME_DLS_REQ_STRUCT MlmeDlsReq
;
724 USHORT reason
= REASON_UNSPECIFY
;
726 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - (OID set %02x:%02x:%02x:%02x:%02x:%02x with Valid=%d, Status=%d, TimeOut=%d, CountDownTimer=%d)\n",
727 pDLS
->MacAddr
[0], pDLS
->MacAddr
[1], pDLS
->MacAddr
[2], pDLS
->MacAddr
[3], pDLS
->MacAddr
[4], pDLS
->MacAddr
[5],
728 pDLS
->Valid
, pDLS
->Status
, pDLS
->TimeOut
, pDLS
->CountDownTimer
));
730 if (!pAd
->CommonCfg
.bDLSCapable
)
733 // DLS will not be supported when Adhoc mode
736 for (i
= 0; i
< MAX_NUM_OF_DLS_ENTRY
; i
++)
738 if (pDLS
->Valid
&& pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
) &&
739 (pDLS
->TimeOut
== pAd
->StaCfg
.DLSEntry
[i
].TimeOut
) && MAC_ADDR_EQUAL(pDLS
->MacAddr
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
))
741 // 1. Same setting, just drop it
742 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - setting unchanged\n"));
745 else if (!pDLS
->Valid
&& pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
) &&
746 MAC_ADDR_EQUAL(pDLS
->MacAddr
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
))
748 // 2. Disable DLS link case, just tear down DLS link
749 reason
= REASON_QOS_UNWANTED_MECHANISM
;
750 pAd
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
751 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
752 DlsParmFill(pAd
, &MlmeDlsReq
, &pAd
->StaCfg
.DLSEntry
[i
], reason
);
753 MlmeEnqueue(pAd
, DLS_STATE_MACHINE
, MT2_MLME_DLS_TEAR_DOWN
, sizeof(MLME_DLS_REQ_STRUCT
), &MlmeDlsReq
);
754 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - start tear down procedure\n"));
757 else if ((i
< MAX_NUM_OF_DLS_ENTRY
) && pDLS
->Valid
&& !pAd
->StaCfg
.DLSEntry
[i
].Valid
)
759 // 3. Enable case, start DLS setup procedure
760 NdisMoveMemory(&pAd
->StaCfg
.DLSEntry
[i
], pDLS
, sizeof(RT_802_11_DLS_UI
));
762 //Update countdown timer
763 pAd
->StaCfg
.DLSEntry
[i
].CountDownTimer
= pAd
->StaCfg
.DLSEntry
[i
].TimeOut
;
764 DlsParmFill(pAd
, &MlmeDlsReq
, &pAd
->StaCfg
.DLSEntry
[i
], reason
);
765 MlmeEnqueue(pAd
, DLS_STATE_MACHINE
, MT2_MLME_DLS_REQ
, sizeof(MLME_DLS_REQ_STRUCT
), &MlmeDlsReq
);
766 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - DLS setup case\n"));
769 else if ((i
< MAX_NUM_OF_DLS_ENTRY
) && pDLS
->Valid
&& pAd
->StaCfg
.DLSEntry
[i
].Valid
&&
770 (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
) && !MAC_ADDR_EQUAL(pDLS
->MacAddr
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
))
772 // 4. update mac case, tear down old DLS and setup new DLS
773 reason
= REASON_QOS_UNWANTED_MECHANISM
;
774 pAd
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
775 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
776 DlsParmFill(pAd
, &MlmeDlsReq
, &pAd
->StaCfg
.DLSEntry
[i
], reason
);
777 MlmeEnqueue(pAd
, DLS_STATE_MACHINE
, MT2_MLME_DLS_TEAR_DOWN
, sizeof(MLME_DLS_REQ_STRUCT
), &MlmeDlsReq
);
778 NdisMoveMemory(&pAd
->StaCfg
.DLSEntry
[i
], pDLS
, sizeof(RT_802_11_DLS_UI
));
779 DlsParmFill(pAd
, &MlmeDlsReq
, &pAd
->StaCfg
.DLSEntry
[i
], reason
);
780 MlmeEnqueue(pAd
, DLS_STATE_MACHINE
, MT2_MLME_DLS_REQ
, sizeof(MLME_DLS_REQ_STRUCT
), &MlmeDlsReq
);
781 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - DLS tear down and restart case\n"));
784 else if (pDLS
->Valid
&& pAd
->StaCfg
.DLSEntry
[i
].Valid
&&
785 MAC_ADDR_EQUAL(pDLS
->MacAddr
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
) && (pAd
->StaCfg
.DLSEntry
[i
].TimeOut
!= pDLS
->TimeOut
))
787 // 5. update timeout case, start DLS setup procedure (no tear down)
788 pAd
->StaCfg
.DLSEntry
[i
].TimeOut
= pDLS
->TimeOut
;
789 //Update countdown timer
790 pAd
->StaCfg
.DLSEntry
[i
].CountDownTimer
= pAd
->StaCfg
.DLSEntry
[i
].TimeOut
;
791 DlsParmFill(pAd
, &MlmeDlsReq
, &pAd
->StaCfg
.DLSEntry
[i
], reason
);
792 MlmeEnqueue(pAd
, DLS_STATE_MACHINE
, MT2_MLME_DLS_REQ
, sizeof(MLME_DLS_REQ_STRUCT
), &MlmeDlsReq
);
793 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - DLS update timeout case\n"));
796 else if (pDLS
->Valid
&& pAd
->StaCfg
.DLSEntry
[i
].Valid
&&
797 (pAd
->StaCfg
.DLSEntry
[i
].Status
!= DLS_FINISH
) && MAC_ADDR_EQUAL(pDLS
->MacAddr
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
))
799 // 6. re-setup case, start DLS setup procedure (no tear down)
800 DlsParmFill(pAd
, &MlmeDlsReq
, &pAd
->StaCfg
.DLSEntry
[i
], reason
);
801 MlmeEnqueue(pAd
, DLS_STATE_MACHINE
, MT2_MLME_DLS_REQ
, sizeof(MLME_DLS_REQ_STRUCT
), &MlmeDlsReq
);
802 DBGPRINT(RT_DEBUG_TRACE
,("CNTL - DLS retry setup procedure\n"));
807 DBGPRINT(RT_DEBUG_WARN
,("CNTL - DLS not changed in entry - %d - Valid=%d, Status=%d, TimeOut=%d\n",
808 i
, pAd
->StaCfg
.DLSEntry
[i
].Valid
, pAd
->StaCfg
.DLSEntry
[i
].Status
, pAd
->StaCfg
.DLSEntry
[i
].TimeOut
));
813 #endif // QOS_DLS_SUPPORT //
816 ==========================================================================
819 IRQL = DISPATCH_LEVEL
821 ==========================================================================
823 VOID
CntlWaitDisassocProc(
824 IN PRTMP_ADAPTER pAd
,
825 IN MLME_QUEUE_ELEM
*Elem
)
827 MLME_START_REQ_STRUCT StartReq
;
829 if (Elem
->MsgType
== MT2_DISASSOC_CONF
)
831 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Dis-associate successful\n"));
833 if (pAd
->CommonCfg
.bWirelessEvent
)
835 RTMPSendWirelessEvent(pAd
, IW_DISASSOC_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
838 LinkDown(pAd
, FALSE
);
840 // case 1. no matching BSS, and user wants ADHOC, so we just start a new one
841 if ((pAd
->MlmeAux
.SsidBssTab
.BssNr
==0) && (pAd
->StaCfg
.BssType
== BSS_ADHOC
))
843 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd
->MlmeAux
.Ssid
));
844 StartParmFill(pAd
, &StartReq
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
845 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_START_REQ
, sizeof(MLME_START_REQ_STRUCT
), &StartReq
);
846 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_START
;
848 // case 2. try each matched BSS
851 pAd
->MlmeAux
.BssIdx
= 0;
853 IterateOnBssTab(pAd
);
859 ==========================================================================
862 IRQL = DISPATCH_LEVEL
864 ==========================================================================
866 VOID
CntlWaitJoinProc(
867 IN PRTMP_ADAPTER pAd
,
868 IN MLME_QUEUE_ELEM
*Elem
)
871 MLME_AUTH_REQ_STRUCT AuthReq
;
873 if (Elem
->MsgType
== MT2_JOIN_CONF
)
875 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
876 if (Reason
== MLME_SUCCESS
)
878 // 1. joined an IBSS, we are pretty much done here
879 if (pAd
->MlmeAux
.BssType
== BSS_ADHOC
)
882 // 5G bands rules of Japan:
883 // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
885 if ( (pAd
->CommonCfg
.bIEEE80211H
== 1) &&
886 RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
)
889 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
890 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd
->CommonCfg
.Channel
));
894 LinkUp(pAd
, BSS_ADHOC
);
895 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
896 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
897 pAd
->CommonCfg
.Bssid
[0],pAd
->CommonCfg
.Bssid
[1],pAd
->CommonCfg
.Bssid
[2],
898 pAd
->CommonCfg
.Bssid
[3],pAd
->CommonCfg
.Bssid
[4],pAd
->CommonCfg
.Bssid
[5]));
900 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
901 pAd
->ExtraInfo
= GENERAL_LINK_UP
;
903 // 2. joined a new INFRA network, start from authentication
907 // Add AuthMode "LEAP" for CCX 1.X
908 if (pAd
->StaCfg
.LeapAuthMode
== CISCO_AuthModeLEAP
)
910 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, CISCO_AuthModeLEAP
);
913 #endif // LEAP_SUPPORT //
915 // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
916 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
) ||
917 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeAutoSwitch
))
919 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeShared
);
923 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeOpen
);
926 MlmeEnqueue(pAd
, AUTH_STATE_MACHINE
, MT2_MLME_AUTH_REQ
,
927 sizeof(MLME_AUTH_REQ_STRUCT
), &AuthReq
);
929 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_AUTH
;
934 // 3. failed, try next BSS
935 pAd
->MlmeAux
.BssIdx
++;
936 IterateOnBssTab(pAd
);
943 ==========================================================================
946 IRQL = DISPATCH_LEVEL
948 ==========================================================================
950 VOID
CntlWaitStartProc(
951 IN PRTMP_ADAPTER pAd
,
952 IN MLME_QUEUE_ELEM
*Elem
)
956 if (Elem
->MsgType
== MT2_START_CONF
)
958 NdisMoveMemory(&Result
, Elem
->Msg
, sizeof(USHORT
));
959 if (Result
== MLME_SUCCESS
)
962 // 5G bands rules of Japan:
963 // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
965 if ( (pAd
->CommonCfg
.bIEEE80211H
== 1) &&
966 RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
)
969 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
970 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd
->CommonCfg
.Channel
));
973 #ifdef DOT11_N_SUPPORT
974 if (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
)
978 NdisMoveMemory(&pAd
->MlmeAux
.AddHtInfo
, &pAd
->CommonCfg
.AddHTInfo
, sizeof(ADD_HT_INFO_IE
));
979 RTMPCheckHt(pAd
, BSSID_WCID
, &pAd
->CommonCfg
.HtCapability
, &pAd
->CommonCfg
.AddHTInfo
);
980 pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
= TRUE
;
981 NdisZeroMemory(&pAd
->StaActive
.SupportedPhyInfo
.MCSSet
[0], 16);
982 NdisMoveMemory(&pAd
->StaActive
.SupportedPhyInfo
.MCSSet
[0], &pAd
->CommonCfg
.HtCapability
.MCSSet
[0], 16);
983 COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd
);
985 if ((pAd
->CommonCfg
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
) &&
986 (pAd
->CommonCfg
.AddHTInfo
.AddHtInfo
.ExtChanOffset
== EXTCHA_ABOVE
))
988 pAd
->MlmeAux
.CentralChannel
= pAd
->CommonCfg
.Channel
+ 2;
990 else if ((pAd
->CommonCfg
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
) &&
991 (pAd
->CommonCfg
.AddHTInfo
.AddHtInfo
.ExtChanOffset
== EXTCHA_BELOW
))
993 pAd
->MlmeAux
.CentralChannel
= pAd
->CommonCfg
.Channel
- 2;
997 #endif // DOT11_N_SUPPORT //
999 pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
= FALSE
;
1001 LinkUp(pAd
, BSS_ADHOC
);
1002 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
1003 // Before send beacon, driver need do radar detection
1004 if ((pAd
->CommonCfg
.Channel
> 14 )
1005 && (pAd
->CommonCfg
.bIEEE80211H
== 1)
1006 && RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
))
1008 pAd
->CommonCfg
.RadarDetect
.RDMode
= RD_SILENCE_MODE
;
1009 pAd
->CommonCfg
.RadarDetect
.RDCount
= 0;
1011 BbpRadarDetectionStart(pAd
);
1012 #endif // DFS_SUPPORT //
1015 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
1016 pAd
->CommonCfg
.Bssid
[0],pAd
->CommonCfg
.Bssid
[1],pAd
->CommonCfg
.Bssid
[2],
1017 pAd
->CommonCfg
.Bssid
[3],pAd
->CommonCfg
.Bssid
[4],pAd
->CommonCfg
.Bssid
[5]));
1021 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Start IBSS fail. BUG!!!!!\n"));
1022 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
1028 ==========================================================================
1031 IRQL = DISPATCH_LEVEL
1033 ==========================================================================
1035 VOID
CntlWaitAuthProc(
1036 IN PRTMP_ADAPTER pAd
,
1037 IN MLME_QUEUE_ELEM
*Elem
)
1040 MLME_ASSOC_REQ_STRUCT AssocReq
;
1041 MLME_AUTH_REQ_STRUCT AuthReq
;
1043 if (Elem
->MsgType
== MT2_AUTH_CONF
)
1045 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
1046 if (Reason
== MLME_SUCCESS
)
1048 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH OK\n"));
1049 AssocParmFill(pAd
, &AssocReq
, pAd
->MlmeAux
.Bssid
, pAd
->MlmeAux
.CapabilityInfo
,
1050 ASSOC_TIMEOUT
, pAd
->StaCfg
.DefaultListenCount
);
1054 // Cisco Leap CCKM supported Re-association.
1056 if (LEAP_CCKM_ON(pAd
) && (pAd
->StaCfg
.CCKMLinkUpFlag
== TRUE
))
1058 //if CCKM is turn on , that's mean Fast Reauthentication
1059 //Use CCKM Reassociation instead of normal association for Fast Roaming.
1060 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_REASSOC_REQ
,
1061 sizeof(MLME_ASSOC_REQ_STRUCT
), &AssocReq
);
1063 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_REASSOC
;
1066 #endif // LEAP_SUPPORT //
1068 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_ASSOC_REQ
,
1069 sizeof(MLME_ASSOC_REQ_STRUCT
), &AssocReq
);
1071 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_ASSOC
;
1076 // This fail may because of the AP already keep us in its MAC table without
1077 // ageing-out. The previous authentication attempt must have let it remove us.
1078 // so try Authentication again may help. For D-Link DWL-900AP+ compatibility.
1079 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH FAIL, try again...\n"));
1081 //Add AuthMode "LEAP" for CCX 1.X
1082 if (pAd
->StaCfg
.LeapAuthMode
== CISCO_AuthModeLEAP
)
1084 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, CISCO_AuthModeLEAP
);
1087 #endif // LEAP_SUPPORT //
1089 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
) ||
1090 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeAutoSwitch
))
1092 // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
1093 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeShared
);
1097 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeOpen
);
1100 MlmeEnqueue(pAd
, AUTH_STATE_MACHINE
, MT2_MLME_AUTH_REQ
,
1101 sizeof(MLME_AUTH_REQ_STRUCT
), &AuthReq
);
1103 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_AUTH2
;
1109 ==========================================================================
1112 IRQL = DISPATCH_LEVEL
1114 ==========================================================================
1116 VOID
CntlWaitAuthProc2(
1117 IN PRTMP_ADAPTER pAd
,
1118 IN MLME_QUEUE_ELEM
*Elem
)
1121 MLME_ASSOC_REQ_STRUCT AssocReq
;
1122 MLME_AUTH_REQ_STRUCT AuthReq
;
1124 if (Elem
->MsgType
== MT2_AUTH_CONF
)
1126 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
1127 if (Reason
== MLME_SUCCESS
)
1129 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH OK\n"));
1130 AssocParmFill(pAd
, &AssocReq
, pAd
->MlmeAux
.Bssid
, pAd
->MlmeAux
.CapabilityInfo
,
1131 ASSOC_TIMEOUT
, pAd
->StaCfg
.DefaultListenCount
);
1132 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_ASSOC_REQ
,
1133 sizeof(MLME_ASSOC_REQ_STRUCT
), &AssocReq
);
1135 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_ASSOC
;
1140 // Process LEAP first, since it use different control variable
1141 // We don't want to affect other poven operation
1142 if (pAd
->StaCfg
.LeapAuthMode
== CISCO_AuthModeLEAP
)
1144 // LEAP Auth not success, try next BSS
1145 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - *LEAP* AUTH FAIL, give up; try next BSS\n"));
1146 DBGPRINT(RT_DEBUG_TRACE
, ("Total match BSSID [=%d]\n", pAd
->MlmeAux
.SsidBssTab
.BssNr
));
1147 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
1148 pAd
->MlmeAux
.BssIdx
++;
1149 IterateOnBssTab(pAd
);
1152 #endif // LEAP_SUPPORT //
1153 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeAutoSwitch
) &&
1154 (pAd
->MlmeAux
.Alg
== Ndis802_11AuthModeShared
))
1156 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH FAIL, try OPEN system...\n"));
1157 AuthParmFill(pAd
, &AuthReq
, pAd
->MlmeAux
.Bssid
, Ndis802_11AuthModeOpen
);
1158 MlmeEnqueue(pAd
, AUTH_STATE_MACHINE
, MT2_MLME_AUTH_REQ
,
1159 sizeof(MLME_AUTH_REQ_STRUCT
), &AuthReq
);
1161 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_AUTH2
;
1165 // not success, try next BSS
1166 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - AUTH FAIL, give up; try next BSS\n"));
1167 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
; //???????
1168 pAd
->MlmeAux
.BssIdx
++;
1169 IterateOnBssTab(pAd
);
1176 ==========================================================================
1179 IRQL = DISPATCH_LEVEL
1181 ==========================================================================
1183 VOID
CntlWaitAssocProc(
1184 IN PRTMP_ADAPTER pAd
,
1185 IN MLME_QUEUE_ELEM
*Elem
)
1189 if (Elem
->MsgType
== MT2_ASSOC_CONF
)
1191 NdisMoveMemory(&Reason
, Elem
->Msg
, sizeof(USHORT
));
1192 if (Reason
== MLME_SUCCESS
)
1194 LinkUp(pAd
, BSS_INFRA
);
1195 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
1196 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Association successful on BSS #%ld\n",pAd
->MlmeAux
.BssIdx
));
1198 if (pAd
->CommonCfg
.bWirelessEvent
)
1200 RTMPSendWirelessEvent(pAd
, IW_ASSOC_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
1205 // not success, try next BSS
1206 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Association fails on BSS #%ld\n",pAd
->MlmeAux
.BssIdx
));
1207 pAd
->MlmeAux
.BssIdx
++;
1208 IterateOnBssTab(pAd
);
1214 ==========================================================================
1217 IRQL = DISPATCH_LEVEL
1219 ==========================================================================
1221 VOID
CntlWaitReassocProc(
1222 IN PRTMP_ADAPTER pAd
,
1223 IN MLME_QUEUE_ELEM
*Elem
)
1227 if (Elem
->MsgType
== MT2_REASSOC_CONF
)
1229 NdisMoveMemory(&Result
, Elem
->Msg
, sizeof(USHORT
));
1230 if (Result
== MLME_SUCCESS
)
1233 // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
1235 LinkUp(pAd
, BSS_INFRA
);
1237 // send wireless event - for association
1238 if (pAd
->CommonCfg
.bWirelessEvent
)
1239 RTMPSendWirelessEvent(pAd
, IW_ASSOC_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
1243 if (LEAP_CCKM_ON(pAd
))
1245 STA_PORT_SECURED(pAd
);
1246 pAd
->StaCfg
.WpaState
= SS_FINISH
;
1248 #endif // LEAP_SUPPORT //
1249 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
1250 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd
->MlmeAux
.RoamIdx
));
1254 // reassoc failed, try to pick next BSS in the BSS Table
1255 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - Re-assocition fails on BSS #%ld\n", pAd
->MlmeAux
.RoamIdx
));
1256 pAd
->MlmeAux
.RoamIdx
++;
1257 IterateOnBssTab2(pAd
);
1263 VOID
AdhocTurnOnQos(
1264 IN PRTMP_ADAPTER pAd
)
1266 #define AC0_DEF_TXOP 0
1267 #define AC1_DEF_TXOP 0
1268 #define AC2_DEF_TXOP 94
1269 #define AC3_DEF_TXOP 47
1271 // Turn on QOs if use HT rate.
1272 if (pAd
->CommonCfg
.APEdcaParm
.bValid
== FALSE
)
1274 pAd
->CommonCfg
.APEdcaParm
.bValid
= TRUE
;
1275 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[0] = 3;
1276 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[1] = 7;
1277 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[2] = 1;
1278 pAd
->CommonCfg
.APEdcaParm
.Aifsn
[3] = 1;
1280 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[0] = 4;
1281 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[1] = 4;
1282 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[2] = 3;
1283 pAd
->CommonCfg
.APEdcaParm
.Cwmin
[3] = 2;
1285 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[0] = 10;
1286 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[1] = 6;
1287 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[2] = 4;
1288 pAd
->CommonCfg
.APEdcaParm
.Cwmax
[3] = 3;
1290 pAd
->CommonCfg
.APEdcaParm
.Txop
[0] = 0;
1291 pAd
->CommonCfg
.APEdcaParm
.Txop
[1] = 0;
1292 pAd
->CommonCfg
.APEdcaParm
.Txop
[2] = AC2_DEF_TXOP
;
1293 pAd
->CommonCfg
.APEdcaParm
.Txop
[3] = AC3_DEF_TXOP
;
1295 AsicSetEdcaParm(pAd
, &pAd
->CommonCfg
.APEdcaParm
);
1299 ==========================================================================
1302 IRQL = DISPATCH_LEVEL
1304 ==========================================================================
1307 IN PRTMP_ADAPTER pAd
,
1313 UCHAR Value
= 0, idx
;
1314 MAC_TABLE_ENTRY
*pEntry
= NULL
, *pCurrEntry
;
1316 pEntry
= &pAd
->MacTab
.Content
[BSSID_WCID
];
1319 // ASSOC - DisassocTimeoutAction
1320 // CNTL - Dis-associate successful
1321 // !!! LINK DOWN !!!
1322 // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
1324 // To prevent DisassocTimeoutAction to call Link down after we link up,
1325 // cancel the DisassocTimer no matter what it start or not.
1327 RTMPCancelTimer(&pAd
->MlmeAux
.DisassocTimer
, &Cancelled
);
1329 COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd
);
1331 #ifdef DOT11_N_SUPPORT
1332 COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd
);
1333 #endif // DOT11_N_SUPPORT //
1334 // It's quite difficult to tell if a newly added KEY is WEP or CKIP until a new BSS
1335 // is formed (either ASSOC/RE-ASSOC done or IBSS started. LinkUP should be a safe place
1336 // to examine if cipher algorithm switching is required.
1337 //rt2860b. Don't know why need this
1338 SwitchBetweenWepAndCkip(pAd
);
1341 if (BssType
== BSS_ADHOC
)
1343 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_ADHOC_ON
);
1344 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_INFRA_ON
);
1346 #ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
1347 // No carrier detection when adhoc
1348 // CarrierDetectionStop(pAd);
1349 pAd
->CommonCfg
.CarrierDetect
.CD_State
= CD_NORMAL
;
1350 #endif // CARRIER_DETECTION_SUPPORT //
1352 #ifdef DOT11_N_SUPPORT
1353 if (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
)
1354 AdhocTurnOnQos(pAd
);
1355 #endif // DOT11_N_SUPPORT //
1357 DBGPRINT(RT_DEBUG_TRACE
, ("!!!Adhoc LINK UP !!! \n" ));
1361 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_INFRA_ON
);
1362 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_ADHOC_ON
);
1364 DBGPRINT(RT_DEBUG_TRACE
, ("!!!Infra LINK UP !!! \n" ));
1368 // reset Tx beamforming bit
1369 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1371 Value
|= pAd
->CommonCfg
.RegTransmitSetting
.field
.TxBF
;
1372 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1374 #ifdef DOT11_N_SUPPORT
1375 // Change to AP channel
1376 if ((pAd
->CommonCfg
.CentralChannel
> pAd
->CommonCfg
.Channel
) && (pAd
->MlmeAux
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
))
1378 // Must using 40MHz.
1379 pAd
->CommonCfg
.BBPCurrentBW
= BW_40
;
1380 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.CentralChannel
, FALSE
);
1381 AsicLockChannel(pAd
, pAd
->CommonCfg
.CentralChannel
);
1383 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1386 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1388 // RX : control channel at lower
1389 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &Value
);
1391 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, Value
);
1393 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Data
);
1395 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Data
);
1397 if (pAd
->MACVersion
== 0x28600100)
1399 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, 0x1A);
1400 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, 0x0A);
1401 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, 0x16);
1402 DBGPRINT(RT_DEBUG_TRACE
, ("!!!rt2860C !!! \n" ));
1405 DBGPRINT(RT_DEBUG_TRACE
, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd
->CommonCfg
.CentralChannel
));
1407 else if ((pAd
->CommonCfg
.CentralChannel
< pAd
->CommonCfg
.Channel
) && (pAd
->MlmeAux
.HtCapability
.HtCapInfo
.ChannelWidth
== BW_40
))
1409 // Must using 40MHz.
1410 pAd
->CommonCfg
.BBPCurrentBW
= BW_40
;
1411 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.CentralChannel
, FALSE
);
1412 AsicLockChannel(pAd
, pAd
->CommonCfg
.CentralChannel
);
1414 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1417 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1419 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Data
);
1421 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Data
);
1423 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &Value
);
1425 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, Value
);
1427 if (pAd
->MACVersion
== 0x28600100)
1429 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, 0x1A);
1430 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, 0x0A);
1431 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, 0x16);
1432 DBGPRINT(RT_DEBUG_TRACE
, ("!!!rt2860C !!! \n" ));
1435 DBGPRINT(RT_DEBUG_TRACE
, ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd
->CommonCfg
.CentralChannel
));
1438 #endif // DOT11_N_SUPPORT //
1440 pAd
->CommonCfg
.BBPCurrentBW
= BW_20
;
1441 pAd
->CommonCfg
.CentralChannel
= pAd
->CommonCfg
.Channel
;
1442 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
1443 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
1445 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &Value
);
1447 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, Value
);
1449 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Data
);
1451 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Data
);
1453 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &Value
);
1455 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, Value
);
1457 if (pAd
->MACVersion
== 0x28600100)
1459 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, 0x16);
1460 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, 0x08);
1461 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, 0x11);
1462 DBGPRINT(RT_DEBUG_TRACE
, ("!!!rt2860C !!! \n" ));
1465 DBGPRINT(RT_DEBUG_TRACE
, ("!!! 20MHz LINK UP !!! \n" ));
1468 RTMPSetAGCInitValue(pAd
, pAd
->CommonCfg
.BBPCurrentBW
);
1470 // Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission
1472 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R66
, &pAd
->BbpTuning
.R66CurrentValue
);
1474 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n",
1475 BssType
, pAd
->StaActive
.Aid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.Channel
, pAd
->CommonCfg
.CentralChannel
));
1477 #ifdef DOT11_N_SUPPORT
1478 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !!! (Density =%d, )\n", pAd
->MacTab
.Content
[BSSID_WCID
].MpduDensity
));
1479 #endif // DOT11_N_SUPPORT //
1481 AsicSetBssid(pAd
, pAd
->CommonCfg
.Bssid
);
1483 AsicSetSlotTime(pAd
, TRUE
);
1484 AsicSetEdcaParm(pAd
, &pAd
->CommonCfg
.APEdcaParm
);
1486 // Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit
1487 AsicUpdateProtect(pAd
, 0, (OFDMSETPROTECT
| CCKSETPROTECT
), TRUE
, FALSE
);
1489 #ifdef DOT11_N_SUPPORT
1490 if ((pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== TRUE
))
1492 // Update HT protectionfor based on AP's operating mode.
1493 if (pAd
->MlmeAux
.AddHtInfo
.AddHtInfo2
.NonGfPresent
== 1)
1495 AsicUpdateProtect(pAd
, pAd
->MlmeAux
.AddHtInfo
.AddHtInfo2
.OperaionMode
, ALLN_SETPROTECT
, FALSE
, TRUE
);
1498 AsicUpdateProtect(pAd
, pAd
->MlmeAux
.AddHtInfo
.AddHtInfo2
.OperaionMode
, ALLN_SETPROTECT
, FALSE
, FALSE
);
1500 #endif // DOT11_N_SUPPORT //
1502 NdisZeroMemory(&pAd
->DrsCounters
, sizeof(COUNTER_DRS
));
1504 NdisGetSystemUpTime(&Now
);
1505 pAd
->StaCfg
.LastBeaconRxTime
= Now
; // last RX timestamp
1507 if ((pAd
->CommonCfg
.TxPreamble
!= Rt802_11PreambleLong
) &&
1508 CAP_IS_SHORT_PREAMBLE_ON(pAd
->StaActive
.CapabilityInfo
))
1510 MlmeSetTxPreamble(pAd
, Rt802_11PreambleShort
);
1513 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
1515 if (pAd
->CommonCfg
.RadarDetect
.RDMode
== RD_SILENCE_MODE
)
1518 RadarDetectionStop(pAd
);
1519 #endif // DFS_SUPPORT //
1521 pAd
->CommonCfg
.RadarDetect
.RDMode
= RD_NORMAL_MODE
;
1523 if (BssType
== BSS_ADHOC
)
1525 MakeIbssBeacon(pAd
);
1526 if ((pAd
->CommonCfg
.Channel
> 14)
1527 && (pAd
->CommonCfg
.bIEEE80211H
== 1)
1528 && RadarChannelCheck(pAd
, pAd
->CommonCfg
.Channel
))
1534 AsicEnableIbssSync(pAd
);
1537 // In ad hoc mode, use MAC table from index 1.
1538 // 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.
1539 RTMP_IO_WRITE32(pAd
, MAC_WCID_BASE
, 0x00);
1540 RTMP_IO_WRITE32(pAd
, 0x1808, 0x00);
1542 // If WEP is enabled, add key material and cipherAlg into Asic
1543 // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
1545 if (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
)
1550 for (idx
=0; idx
< SHARE_KEY_NUM
; idx
++)
1552 CipherAlg
= pAd
->SharedKey
[BSS0
][idx
].CipherAlg
;
1553 Key
= pAd
->SharedKey
[BSS0
][idx
].Key
;
1555 if (pAd
->SharedKey
[BSS0
][idx
].KeyLen
> 0)
1557 // Set key material and cipherAlg to Asic
1558 AsicAddSharedKeyEntry(pAd
, BSS0
, idx
, CipherAlg
, Key
, NULL
, NULL
);
1560 if (idx
== pAd
->StaCfg
.DefaultKeyId
)
1562 // Update WCID attribute table and IVEIV table for this group key table
1563 RTMPAddWcidAttributeEntry(pAd
, BSS0
, idx
, CipherAlg
, NULL
);
1570 // If WPANone is enabled, add key material and cipherAlg into Asic
1571 // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
1572 else if (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
1574 pAd
->StaCfg
.DefaultKeyId
= 0; // always be zero
1576 NdisZeroMemory(&pAd
->SharedKey
[BSS0
][0], sizeof(CIPHER_KEY
));
1577 pAd
->SharedKey
[BSS0
][0].KeyLen
= LEN_TKIP_EK
;
1578 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].Key
, pAd
->StaCfg
.PMK
, LEN_TKIP_EK
);
1580 if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption2Enabled
)
1582 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].RxMic
, &pAd
->StaCfg
.PMK
[16], LEN_TKIP_RXMICK
);
1583 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].TxMic
, &pAd
->StaCfg
.PMK
[16], LEN_TKIP_TXMICK
);
1586 // Decide its ChiperAlg
1587 if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption2Enabled
)
1588 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_TKIP
;
1589 else if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption3Enabled
)
1590 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_AES
;
1593 DBGPRINT(RT_DEBUG_TRACE
, ("Unknow Cipher (=%d), set Cipher to AES\n", pAd
->StaCfg
.PairCipher
));
1594 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_AES
;
1597 // Set key material and cipherAlg to Asic
1598 AsicAddSharedKeyEntry(pAd
,
1601 pAd
->SharedKey
[BSS0
][0].CipherAlg
,
1602 pAd
->SharedKey
[BSS0
][0].Key
,
1603 pAd
->SharedKey
[BSS0
][0].TxMic
,
1604 pAd
->SharedKey
[BSS0
][0].RxMic
);
1606 // Update WCID attribute table and IVEIV table for this group key table
1607 RTMPAddWcidAttributeEntry(pAd
, BSS0
, 0, pAd
->SharedKey
[BSS0
][0].CipherAlg
, NULL
);
1614 // Check the new SSID with last SSID
1615 while (Cancelled
== TRUE
)
1617 if (pAd
->CommonCfg
.LastSsidLen
== pAd
->CommonCfg
.SsidLen
)
1619 if (RTMPCompareMemory(pAd
->CommonCfg
.LastSsid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.LastSsidLen
) == 0)
1621 // Link to the old one no linkdown is required.
1625 // Send link down event before set to link up
1626 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
1627 RTMP_IndicateMediaState(pAd
);
1628 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
1629 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n"));
1634 // On WPA mode, Remove All Keys if not connect to the last BSSID
1635 // Key will be set after 4-way handshake.
1637 if ((pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
))
1641 // Remove all WPA keys
1642 RTMPWPARemoveAllKeys(pAd
);
1643 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
1644 pAd
->StaCfg
.PrivacyFilter
= Ndis802_11PrivFilter8021xWEP
;
1646 // Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP
1647 // If IV related values are too large in GroupMsg2, AP would ignore this message.
1649 IV
|= (pAd
->StaCfg
.DefaultKeyId
<< 30);
1650 AsicUpdateWCIDIVEIV(pAd
, BSSID_WCID
, IV
, 0);
1653 // the decision of using "short slot time" or not may change dynamically due to
1654 // new STA association to the AP. so we have to decide that upon parsing BEACON, not here
1657 // the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically
1658 // due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here
1661 ComposeNullFrame(pAd
);
1663 AsicEnableBssSync(pAd
);
1665 // Add BSSID to WCID search table
1666 AsicUpdateRxWCIDTable(pAd
, BSSID_WCID
, pAd
->CommonCfg
.Bssid
);
1668 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1669 // add this BSSID entry into HASH table
1673 //pEntry = &pAd->MacTab.Content[BSSID_WCID];
1674 HashIdx
= MAC_ADDR_HASH_INDEX(pAd
->CommonCfg
.Bssid
);
1675 if (pAd
->MacTab
.Hash
[HashIdx
] == NULL
)
1677 pAd
->MacTab
.Hash
[HashIdx
] = pEntry
;
1681 pCurrEntry
= pAd
->MacTab
.Hash
[HashIdx
];
1682 while (pCurrEntry
->pNext
!= NULL
)
1683 pCurrEntry
= pCurrEntry
->pNext
;
1684 pCurrEntry
->pNext
= pEntry
;
1687 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1690 // If WEP is enabled, add paiewise and shared key
1691 #ifdef WPA_SUPPLICANT_SUPPORT
1692 if (((pAd
->StaCfg
.WpaSupplicantUP
)&&
1693 (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
)&&
1694 (pAd
->StaCfg
.PortSecured
== WPA_802_1X_PORT_SECURED
)) ||
1695 ((pAd
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_DISABLE
)&&
1696 (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
)))
1698 if (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
)
1699 #endif // WPA_SUPPLICANT_SUPPORT //
1704 for (idx
=0; idx
< SHARE_KEY_NUM
; idx
++)
1706 CipherAlg
= pAd
->SharedKey
[BSS0
][idx
].CipherAlg
;
1707 Key
= pAd
->SharedKey
[BSS0
][idx
].Key
;
1709 if (pAd
->SharedKey
[BSS0
][idx
].KeyLen
> 0)
1711 // Set key material and cipherAlg to Asic
1712 AsicAddSharedKeyEntry(pAd
, BSS0
, idx
, CipherAlg
, Key
, NULL
, NULL
);
1714 if (idx
== pAd
->StaCfg
.DefaultKeyId
)
1716 // Assign group key info
1717 RTMPAddWcidAttributeEntry(pAd
, BSS0
, idx
, CipherAlg
, NULL
);
1719 // Assign pairwise key info
1720 RTMPAddWcidAttributeEntry(pAd
, BSS0
, idx
, CipherAlg
, pEntry
);
1726 // only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode
1727 // should wait until at least 2 active nodes in this BSSID.
1728 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
1731 if (pAd
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
)
1733 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
1734 pAd
->ExtraInfo
= GENERAL_LINK_UP
;
1735 RTMP_IndicateMediaState(pAd
);
1739 // Add BSSID in my MAC Table.
1740 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1741 RTMPMoveMemory(pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, pAd
->CommonCfg
.Bssid
, MAC_ADDR_LEN
);
1742 pAd
->MacTab
.Content
[BSSID_WCID
].Aid
= BSSID_WCID
;
1743 pAd
->MacTab
.Content
[BSSID_WCID
].pAd
= pAd
;
1744 pAd
->MacTab
.Content
[BSSID_WCID
].ValidAsCLI
= TRUE
; //Although this is bssid..still set ValidAsCl
1745 pAd
->MacTab
.Size
= 1; // infra mode always set MACtab size =1.
1746 pAd
->MacTab
.Content
[BSSID_WCID
].Sst
= SST_ASSOC
;
1747 pAd
->MacTab
.Content
[BSSID_WCID
].AuthState
= SST_ASSOC
;
1748 pAd
->MacTab
.Content
[BSSID_WCID
].WepStatus
= pAd
->StaCfg
.WepStatus
;
1749 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1751 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !!! ClientStatusFlags=%lx)\n",
1752 pAd
->MacTab
.Content
[BSSID_WCID
].ClientStatusFlags
));
1754 MlmeUpdateTxRates(pAd
, TRUE
, BSS0
);
1755 #ifdef DOT11_N_SUPPORT
1756 MlmeUpdateHtTxRates(pAd
, BSS0
);
1757 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
));
1758 #endif // DOT11_N_SUPPORT //
1761 // Report Adjacent AP report.
1764 CCXAdjacentAPReport(pAd
);
1765 #endif // LEAP_SUPPORT //
1767 if (pAd
->CommonCfg
.bAggregationCapable
)
1769 if ((pAd
->CommonCfg
.bPiggyBackCapable
) && (pAd
->MlmeAux
.APRalinkIe
& 0x00000003) == 3)
1772 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_PIGGYBACK_INUSED
);
1773 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
1774 RTMPSetPiggyBack(pAd
, TRUE
);
1775 DBGPRINT(RT_DEBUG_TRACE
, ("Turn on Piggy-Back\n"));
1777 else if (pAd
->MlmeAux
.APRalinkIe
& 0x00000001)
1779 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
1783 if (pAd
->MlmeAux
.APRalinkIe
!= 0x0)
1785 #ifdef DOT11_N_SUPPORT
1786 if (CLIENT_STATUS_TEST_FLAG(&pAd
->MacTab
.Content
[BSSID_WCID
], fCLIENT_STATUS_RDG_CAPABLE
))
1790 #endif // DOT11_N_SUPPORT //
1791 OPSTATUS_SET_FLAG(pAd
, fCLIENT_STATUS_RALINK_CHIPSET
);
1792 CLIENT_STATUS_SET_FLAG(&pAd
->MacTab
.Content
[BSSID_WCID
], fCLIENT_STATUS_RALINK_CHIPSET
);
1796 OPSTATUS_CLEAR_FLAG(pAd
, fCLIENT_STATUS_RALINK_CHIPSET
);
1797 CLIENT_STATUS_CLEAR_FLAG(&pAd
->MacTab
.Content
[BSSID_WCID
], fCLIENT_STATUS_RALINK_CHIPSET
);
1801 #ifdef DOT11_N_SUPPORT
1802 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
));
1803 #endif // DOT11_N_SUPPORT //
1806 RTMPSetLED(pAd
, LED_LINK_UP
);
1808 pAd
->Mlme
.PeriodicRound
= 0;
1809 pAd
->Mlme
.OneSecPeriodicRound
= 0;
1810 pAd
->bConfigChanged
= FALSE
; // Reset config flag
1811 pAd
->ExtraInfo
= GENERAL_LINK_UP
; // Update extra information to link is up
1813 // Set asic auto fall back
1816 UCHAR TableSize
= 0;
1818 MlmeSelectTxRateTable(pAd
, &pAd
->MacTab
.Content
[BSSID_WCID
], &pTable
, &TableSize
, &pAd
->CommonCfg
.TxRateIndex
);
1819 AsicUpdateAutoFallBackTable(pAd
, pTable
);
1822 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1823 pEntry
->HTPhyMode
.word
= pAd
->StaCfg
.HTPhyMode
.word
;
1824 pEntry
->MaxHTPhyMode
.word
= pAd
->StaCfg
.HTPhyMode
.word
;
1825 if (pAd
->StaCfg
.bAutoTxRateSwitch
== FALSE
)
1827 pEntry
->bAutoTxRateSwitch
= FALSE
;
1828 #ifdef DOT11_N_SUPPORT
1829 if (pEntry
->HTPhyMode
.field
.MCS
== 32)
1830 pEntry
->HTPhyMode
.field
.ShortGI
= GI_800
;
1832 if ((pEntry
->HTPhyMode
.field
.MCS
> MCS_7
) || (pEntry
->HTPhyMode
.field
.MCS
== 32))
1833 pEntry
->HTPhyMode
.field
.STBC
= STBC_NONE
;
1834 #endif // DOT11_N_SUPPORT //
1835 // If the legacy mode is set, overwrite the transmit setting of this entry.
1836 if (pEntry
->HTPhyMode
.field
.MODE
<= MODE_OFDM
)
1837 RTMPUpdateLegacyTxSetting((UCHAR
)pAd
->StaCfg
.DesiredTransmitSetting
.field
.FixedTxMode
, pEntry
);
1840 pEntry
->bAutoTxRateSwitch
= TRUE
;
1841 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1843 // Let Link Status Page display first initial rate.
1844 pAd
->LastTxRate
= (USHORT
)(pEntry
->HTPhyMode
.word
);
1845 // Select DAC according to HT or Legacy
1846 if (pAd
->StaActive
.SupportedPhyInfo
.MCSSet
[0] != 0x00)
1848 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &Value
);
1850 if (pAd
->Antenna
.field
.TxPath
== 2)
1854 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, Value
);
1858 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &Value
);
1860 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, Value
);
1863 #ifdef DOT11_N_SUPPORT
1864 if (pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== FALSE
)
1867 else if (pEntry
->MaxRAmpduFactor
== 0)
1869 // If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0.
1870 // Because our Init value is 1 at MACRegTable.
1871 RTMP_IO_WRITE32(pAd
, MAX_LEN_CFG
, 0x0fff);
1873 #endif // DOT11_N_SUPPORT //
1875 // Patch for Marvel AP to gain high throughput
1876 // Need to set as following,
1877 // 1. Set txop in register-EDCA_AC0_CFG as 0x60
1878 // 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero
1879 // 3. PBF_MAX_PCNT as 0x1F3FBF9F
1880 // 4. kick per two packets when dequeue
1882 // Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable
1884 // if 1. Legacy AP WMM on, or 2. 11n AP, AMPDU disable. Force turn off burst no matter what bEnableTxBurst is.
1885 #ifdef DOT11_N_SUPPORT
1886 if (((pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== FALSE
) && (OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_WMM_INUSED
)))
1887 || ((pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
== TRUE
) && (pAd
->CommonCfg
.BACapability
.field
.Policy
== BA_NOTUSE
)))
1889 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &Data
);
1891 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, Data
);
1893 RTMP_IO_WRITE32(pAd
, PBF_MAX_PCNT
, 0x1F3F7F9F);
1894 DBGPRINT(RT_DEBUG_TRACE
, ("Txburst 1\n"));
1897 #endif // DOT11_N_SUPPORT //
1898 if (pAd
->CommonCfg
.bEnableTxBurst
)
1900 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &Data
);
1903 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, Data
);
1904 pAd
->CommonCfg
.IOTestParm
.bNowAtherosBurstOn
= TRUE
;
1906 RTMP_IO_WRITE32(pAd
, PBF_MAX_PCNT
, 0x1F3FBF9F);
1907 DBGPRINT(RT_DEBUG_TRACE
, ("Txburst 2\n"));
1911 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &Data
);
1913 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, Data
);
1915 RTMP_IO_WRITE32(pAd
, PBF_MAX_PCNT
, 0x1F3F7F9F);
1916 DBGPRINT(RT_DEBUG_TRACE
, ("Txburst 3\n"));
1919 #ifdef DOT11_N_SUPPORT
1920 // Re-check to turn on TX burst or not.
1921 if ((pAd
->CommonCfg
.IOTestParm
.bLastAtheros
== TRUE
) && ((STA_WEP_ON(pAd
))||(STA_TKIP_ON(pAd
))))
1923 pAd
->CommonCfg
.IOTestParm
.bNextDisableRxBA
= TRUE
;
1924 if (pAd
->CommonCfg
.bEnableTxBurst
)
1926 UINT32 MACValue
= 0;
1927 // Force disable TXOP value in this case. The same action in MLMEUpdateProtect too.
1928 // I didn't change PBF_MAX_PCNT setting.
1929 RTMP_IO_READ32(pAd
, EDCA_AC0_CFG
, &MACValue
);
1930 MACValue
&= 0xFFFFFF00;
1931 RTMP_IO_WRITE32(pAd
, EDCA_AC0_CFG
, MACValue
);
1932 pAd
->CommonCfg
.IOTestParm
.bNowAtherosBurstOn
= FALSE
;
1937 pAd
->CommonCfg
.IOTestParm
.bNextDisableRxBA
= FALSE
;
1939 #endif // DOT11_N_SUPPORT //
1941 pAd
->CommonCfg
.IOTestParm
.bLastAtheros
= FALSE
;
1942 COPY_MAC_ADDR(pAd
->CommonCfg
.LastBssid
, pAd
->CommonCfg
.Bssid
);
1943 DBGPRINT(RT_DEBUG_TRACE
, ("!!!pAd->bNextDisableRxBA= %d \n", pAd
->CommonCfg
.IOTestParm
.bNextDisableRxBA
));
1944 // BSSID add in one MAC entry too. Because in Tx, ASIC need to check Cipher and IV/EIV, BAbitmap
1945 // Pther information in MACTab.Content[BSSID_WCID] is not necessary for driver.
1946 // Note: As STA, The MACTab.Content[BSSID_WCID]. PairwiseKey and Shared Key for BSS0 are the same.
1948 if (pAd
->StaCfg
.WepStatus
<= Ndis802_11WEPDisabled
)
1950 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_SECURED
;
1951 pAd
->StaCfg
.PrivacyFilter
= Ndis802_11PrivFilterAcceptAll
;
1954 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1955 pEntry
->PortSecured
= pAd
->StaCfg
.PortSecured
;
1956 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1959 // Patch Atheros AP TX will breakdown issue.
1960 // AP Model: DLink DWL-8200AP
1962 if (INFRA_ON(pAd
) && OPSTATUS_TEST_FLAG(pAd
, fOP_STATUS_WMM_INUSED
) && STA_TKIP_ON(pAd
))
1964 RTMP_IO_WRITE32(pAd
, RX_PARSER_CFG
, 0x01);
1968 RTMP_IO_WRITE32(pAd
, RX_PARSER_CFG
, 0x00);
1971 RTMP_CLEAR_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
);
1974 #ifdef DOT11_N_SUPPORT
1975 #ifdef DOT11N_DRAFT3
1976 if ((pAd
->CommonCfg
.BACapability
.field
.b2040CoexistScanSup
) && (pAd
->CommonCfg
.Channel
<= 11))
1978 OPSTATUS_SET_FLAG(pAd
, fOP_STATUS_SCAN_2040
);
1979 BuildEffectedChannelList(pAd
);
1981 #endif // DOT11N_DRAFT3 //
1982 #endif // DOT11_N_SUPPORT //
1986 ==========================================================================
1988 Routine Description:
1989 Disconnect current BSSID
1992 pAd - Pointer to our adapter
1993 IsReqFromAP - Request from AP
1998 IRQL = DISPATCH_LEVEL
2001 We need more information to know it's this requst from AP.
2002 If yes! we need to do extra handling, for example, remove the WPA key.
2003 Otherwise on 4-way handshaking will faied, since the WPA key didn't be
2004 remove while auto reconnect.
2005 Disconnect request from AP, it means we will start afresh 4-way handshaking
2008 ==========================================================================
2011 IN PRTMP_ADAPTER pAd
,
2012 IN BOOLEAN IsReqFromAP
)
2014 UCHAR i
, ByteValue
= 0;
2016 // Do nothing if monitor mode is on
2017 if (MONITOR_ON(pAd
))
2021 // Nothing to do in ATE mode.
2024 #endif // RALINK_ATE //
2026 if (pAd
->CommonCfg
.bWirelessEvent
)
2028 RTMPSendWirelessEvent(pAd
, IW_STA_LINKDOWN_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
2031 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK DOWN !!!\n"));
2032 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_AGGREGATION_INUSED
);
2034 if (ADHOC_ON(pAd
)) // Adhoc mode link down
2036 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK DOWN 1!!!\n"));
2038 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_ADHOC_ON
);
2039 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
2040 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
2041 RTMP_IndicateMediaState(pAd
);
2042 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
2043 BssTableDeleteEntry(&pAd
->ScanTab
, pAd
->CommonCfg
.Bssid
, pAd
->CommonCfg
.Channel
);
2044 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MacTab.Size=%d !!!\n", pAd
->MacTab
.Size
));
2046 else // Infra structure mode
2048 DBGPRINT(RT_DEBUG_TRACE
, ("!!! LINK DOWN 2!!!\n"));
2050 #ifdef QOS_DLS_SUPPORT
2051 // DLS tear down frame must be sent before link down
2052 // send DLS-TEAR_DOWN message
2053 if (pAd
->CommonCfg
.bDLSCapable
)
2055 // tear down local dls table entry
2056 for (i
=0; i
<MAX_NUM_OF_INIT_DLS_ENTRY
; i
++)
2058 if (pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
2060 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
2061 RTMPSendDLSTearDownFrame(pAd
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
);
2065 // tear down peer dls table entry
2066 for (i
=MAX_NUM_OF_INIT_DLS_ENTRY
; i
<MAX_NUM_OF_DLS_ENTRY
; i
++)
2068 if (pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
2070 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
2071 RTMPSendDLSTearDownFrame(pAd
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
);
2075 #endif // QOS_DLS_SUPPORT //
2077 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_INFRA_ON
);
2078 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
2080 // Saved last SSID for linkup comparison
2081 pAd
->CommonCfg
.LastSsidLen
= pAd
->CommonCfg
.SsidLen
;
2082 NdisMoveMemory(pAd
->CommonCfg
.LastSsid
, pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.LastSsidLen
);
2083 COPY_MAC_ADDR(pAd
->CommonCfg
.LastBssid
, pAd
->CommonCfg
.Bssid
);
2084 if (pAd
->MlmeAux
.CurrReqIsFromNdis
== TRUE
)
2086 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
2087 RTMP_IndicateMediaState(pAd
);
2088 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
2089 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event A!\n"));
2090 pAd
->MlmeAux
.CurrReqIsFromNdis
= FALSE
;
2095 // If disassociation request is from NDIS, then we don't need to delete BSSID from entry.
2096 // Otherwise lost beacon or receive De-Authentication from AP,
2097 // then we should delete BSSID from BssTable.
2098 // If we don't delete from entry, roaming will fail.
2100 BssTableDeleteEntry(&pAd
->ScanTab
, pAd
->CommonCfg
.Bssid
, pAd
->CommonCfg
.Channel
);
2103 // restore back to -
2104 // 1. long slot (20 us) or short slot (9 us) time
2105 // 2. turn on/off RTS/CTS and/or CTS-to-self protection
2106 // 3. short preamble
2107 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_BG_PROTECTION_INUSED
);
2109 if (pAd
->StaCfg
.CCXAdjacentAPReportFlag
== TRUE
)
2112 // Record current AP's information.
2113 // for later used reporting Adjacent AP report.
2115 pAd
->StaCfg
.CCXAdjacentAPChannel
= pAd
->CommonCfg
.Channel
;
2116 pAd
->StaCfg
.CCXAdjacentAPSsidLen
= pAd
->CommonCfg
.SsidLen
;
2117 NdisMoveMemory(pAd
->StaCfg
.CCXAdjacentAPSsid
, pAd
->CommonCfg
.Ssid
, pAd
->StaCfg
.CCXAdjacentAPSsidLen
);
2118 COPY_MAC_ADDR(pAd
->StaCfg
.CCXAdjacentAPBssid
, pAd
->CommonCfg
.Bssid
);
2121 #ifdef EXT_BUILD_CHANNEL_LIST
2122 // Country IE of the AP will be evaluated and will be used.
2123 if (pAd
->StaCfg
.IEEE80211dClientMode
!= Rt802_11_D_None
)
2125 NdisMoveMemory(&pAd
->CommonCfg
.CountryCode
[0], &pAd
->StaCfg
.StaOriCountryCode
[0], 2);
2126 pAd
->CommonCfg
.Geography
= pAd
->StaCfg
.StaOriGeography
;
2127 BuildChannelListEx(pAd
);
2129 #endif // EXT_BUILD_CHANNEL_LIST //
2133 for (i
=1; i
<MAX_LEN_OF_MAC_TABLE
; i
++)
2135 if (pAd
->MacTab
.Content
[i
].ValidAsCLI
== TRUE
)
2136 MacTableDeleteEntry(pAd
, pAd
->MacTab
.Content
[i
].Aid
, pAd
->MacTab
.Content
[i
].Addr
);
2139 pAd
->StaCfg
.CCXQosECWMin
= 4;
2140 pAd
->StaCfg
.CCXQosECWMax
= 10;
2142 AsicSetSlotTime(pAd
, TRUE
); //FALSE);
2143 AsicSetEdcaParm(pAd
, NULL
);
2146 RTMPSetLED(pAd
, LED_LINK_DOWN
);
2147 pAd
->LedIndicatorStregth
= 0xF0;
2148 RTMPSetSignalLED(pAd
, -100); // Force signal strength Led to be turned off, firmware is not done it.
2150 AsicDisableSync(pAd
);
2152 pAd
->Mlme
.PeriodicRound
= 0;
2153 pAd
->Mlme
.OneSecPeriodicRound
= 0;
2155 if (pAd
->StaCfg
.BssType
== BSS_INFRA
)
2157 // Remove StaCfg Information after link down
2158 NdisZeroMemory(pAd
->CommonCfg
.Bssid
, MAC_ADDR_LEN
);
2159 NdisZeroMemory(pAd
->CommonCfg
.Ssid
, MAX_LEN_OF_SSID
);
2160 pAd
->CommonCfg
.SsidLen
= 0;
2162 #ifdef DOT11_N_SUPPORT
2163 NdisZeroMemory(&pAd
->MlmeAux
.HtCapability
, sizeof(HT_CAPABILITY_IE
));
2164 NdisZeroMemory(&pAd
->MlmeAux
.AddHtInfo
, sizeof(ADD_HT_INFO_IE
));
2165 pAd
->MlmeAux
.HtCapabilityLen
= 0;
2166 pAd
->MlmeAux
.NewExtChannelOffset
= 0xff;
2167 #endif // DOT11_N_SUPPORT //
2169 // Reset WPA-PSK state. Only reset when supplicant enabled
2170 if (pAd
->StaCfg
.WpaState
!= SS_NOTUSE
)
2172 pAd
->StaCfg
.WpaState
= SS_START
;
2173 // Clear Replay counter
2174 NdisZeroMemory(pAd
->StaCfg
.ReplayCounter
, 8);
2176 #ifdef QOS_DLS_SUPPORT
2177 if (pAd
->CommonCfg
.bDLSCapable
)
2178 NdisZeroMemory(pAd
->StaCfg
.DlsReplayCounter
, 8);
2179 #endif // QOS_DLS_SUPPORT //
2184 // if link down come from AP, we need to remove all WPA keys on WPA mode.
2185 // otherwise will cause 4-way handshaking failed, since the WPA key not empty.
2187 if ((IsReqFromAP
) && (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
))
2189 // Remove all WPA keys
2190 RTMPWPARemoveAllKeys(pAd
);
2193 // 802.1x port control
2194 #ifdef WPA_SUPPLICANT_SUPPORT
2195 // Prevent clear PortSecured here with static WEP
2196 // NetworkManger set security policy first then set SSID to connect AP.
2197 if (pAd
->StaCfg
.WpaSupplicantUP
&&
2198 (pAd
->StaCfg
.WepStatus
== Ndis802_11WEPEnabled
) &&
2199 (pAd
->StaCfg
.IEEE8021X
== FALSE
))
2201 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_SECURED
;
2204 #endif // WPA_SUPPLICANT_SUPPORT //
2206 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
2207 pAd
->StaCfg
.PrivacyFilter
= Ndis802_11PrivFilter8021xWEP
;
2210 NdisAcquireSpinLock(&pAd
->MacTabLock
);
2211 pAd
->MacTab
.Content
[BSSID_WCID
].PortSecured
= pAd
->StaCfg
.PortSecured
;
2212 NdisReleaseSpinLock(&pAd
->MacTabLock
);
2214 pAd
->StaCfg
.MicErrCnt
= 0;
2216 // Turn off Ckip control flag
2217 pAd
->StaCfg
.bCkipOn
= FALSE
;
2218 pAd
->StaCfg
.CCXEnable
= FALSE
;
2220 pAd
->IndicateMediaState
= NdisMediaStateDisconnected
;
2221 // Update extra information to link is up
2222 pAd
->ExtraInfo
= GENERAL_LINK_DOWN
;
2224 //pAd->StaCfg.AdhocBOnlyJoined = FALSE;
2225 //pAd->StaCfg.AdhocBGJoined = FALSE;
2226 //pAd->StaCfg.Adhoc20NJoined = FALSE;
2227 pAd
->StaActive
.SupportedPhyInfo
.bHtEnable
= FALSE
;
2229 // Reset the Current AP's IP address
2230 NdisZeroMemory(pAd
->StaCfg
.AironetIPAddress
, 4);
2232 pAd
->bUsbTxBulkAggre
= FALSE
;
2235 // Clean association information
2236 NdisZeroMemory(&pAd
->StaCfg
.AssocInfo
, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
));
2237 pAd
->StaCfg
.AssocInfo
.Length
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
2238 pAd
->StaCfg
.ReqVarIELen
= 0;
2239 pAd
->StaCfg
.ResVarIELen
= 0;
2242 // Reset RSSI value after link down
2244 pAd
->StaCfg
.RssiSample
.AvgRssi0
= 0;
2245 pAd
->StaCfg
.RssiSample
.AvgRssi0X8
= 0;
2246 pAd
->StaCfg
.RssiSample
.AvgRssi1
= 0;
2247 pAd
->StaCfg
.RssiSample
.AvgRssi1X8
= 0;
2248 pAd
->StaCfg
.RssiSample
.AvgRssi2
= 0;
2249 pAd
->StaCfg
.RssiSample
.AvgRssi2X8
= 0;
2252 pAd
->CommonCfg
.MlmeRate
= pAd
->CommonCfg
.BasicMlmeRate
;
2253 pAd
->CommonCfg
.RtsRate
= pAd
->CommonCfg
.BasicMlmeRate
;
2255 #ifdef DOT11_N_SUPPORT
2257 // After Link down, reset piggy-back setting in ASIC. Disable RDG.
2259 if (pAd
->CommonCfg
.BBPCurrentBW
== BW_40
)
2261 pAd
->CommonCfg
.BBPCurrentBW
= BW_20
;
2262 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &ByteValue
);
2263 ByteValue
&= (~0x18);
2264 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, ByteValue
);
2266 #endif // DOT11_N_SUPPORT //
2268 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &ByteValue
);
2269 ByteValue
&= (~0x18);
2270 if (pAd
->Antenna
.field
.TxPath
== 2)
2274 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, ByteValue
);
2276 RTMPSetPiggyBack(pAd
,FALSE
);
2277 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_PIGGYBACK_INUSED
);
2279 #ifdef DOT11_N_SUPPORT
2280 pAd
->CommonCfg
.BACapability
.word
= pAd
->CommonCfg
.REGBACapability
.word
;
2281 #endif // DOT11_N_SUPPORT //
2283 // Restore all settings in the following.
2284 AsicUpdateProtect(pAd
, 0, (ALLN_SETPROTECT
|CCKSETPROTECT
|OFDMSETPROTECT
), TRUE
, FALSE
);
2285 AsicDisableRDG(pAd
);
2286 pAd
->CommonCfg
.IOTestParm
.bCurrentAtheros
= FALSE
;
2287 pAd
->CommonCfg
.IOTestParm
.bNowAtherosBurstOn
= FALSE
;
2289 #ifdef DOT11_N_SUPPORT
2290 #ifdef DOT11N_DRAFT3
2291 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_SCAN_2040
);
2292 pAd
->CommonCfg
.BSSCoexist2040
.word
= 0;
2294 for (i
= 0; i
< (pAd
->ChannelListNum
- 1); i
++)
2296 pAd
->ChannelList
[i
].bEffectedChannel
= FALSE
;
2298 #endif // DOT11N_DRAFT3 //
2299 #endif // DOT11_N_SUPPORT //
2301 RTMP_IO_WRITE32(pAd
, MAX_LEN_CFG
, 0x1fff);
2302 RTMP_CLEAR_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
);
2304 #ifdef WPA_SUPPLICANT_SUPPORT
2305 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
2306 if (pAd
->StaCfg
.WpaSupplicantUP
) {
2307 union iwreq_data wrqu
;
2308 //send disassociate event to wpa_supplicant
2309 memset(&wrqu
, 0, sizeof(wrqu
));
2310 wrqu
.data
.flags
= RT_DISASSOC_EVENT_FLAG
;
2311 wireless_send_event(pAd
->net_dev
, IWEVCUSTOM
, &wrqu
, NULL
);
2313 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2314 #endif // WPA_SUPPLICANT_SUPPORT //
2316 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2318 union iwreq_data wrqu
;
2319 memset(wrqu
.ap_addr
.sa_data
, 0, MAC_ADDR_LEN
);
2320 wireless_send_event(pAd
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
2322 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2326 ==========================================================================
2329 IRQL = DISPATCH_LEVEL
2331 ==========================================================================
2333 VOID
IterateOnBssTab(
2334 IN PRTMP_ADAPTER pAd
)
2336 MLME_START_REQ_STRUCT StartReq
;
2337 MLME_JOIN_REQ_STRUCT JoinReq
;
2340 // Change the wepstatus to original wepstatus
2341 pAd
->StaCfg
.WepStatus
= pAd
->StaCfg
.OrigWepStatus
;
2342 pAd
->StaCfg
.PairCipher
= pAd
->StaCfg
.OrigWepStatus
;
2343 pAd
->StaCfg
.GroupCipher
= pAd
->StaCfg
.OrigWepStatus
;
2345 BssIdx
= pAd
->MlmeAux
.BssIdx
;
2346 if (BssIdx
< pAd
->MlmeAux
.SsidBssTab
.BssNr
)
2348 // Check cipher suite, AP must have more secured cipher than station setting
2349 // Set the Pairwise and Group cipher to match the intended AP setting
2350 // We can only connect to AP with less secured cipher setting
2351 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
))
2353 pAd
->StaCfg
.GroupCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.GroupCipher
;
2355 if (pAd
->StaCfg
.WepStatus
== pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipher
)
2356 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipher
;
2357 else if (pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
!= Ndis802_11WEPDisabled
)
2358 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA
.PairCipherAux
;
2359 else // There is no PairCipher Aux, downgrade our capability to TKIP
2360 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
2362 else if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
) || (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
))
2364 pAd
->StaCfg
.GroupCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.GroupCipher
;
2366 if (pAd
->StaCfg
.WepStatus
== pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
)
2367 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipher
;
2368 else if (pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
!= Ndis802_11WEPDisabled
)
2369 pAd
->StaCfg
.PairCipher
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.PairCipherAux
;
2370 else // There is no PairCipher Aux, downgrade our capability to TKIP
2371 pAd
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
2374 pAd
->StaCfg
.RsnCapability
= pAd
->MlmeAux
.SsidBssTab
.BssEntry
[BssIdx
].WPA2
.RsnCapability
;
2377 // Set Mix cipher flag
2378 pAd
->StaCfg
.bMixCipher
= (pAd
->StaCfg
.PairCipher
== pAd
->StaCfg
.GroupCipher
) ? FALSE
: TRUE
;
2379 if (pAd
->StaCfg
.bMixCipher
== TRUE
)
2381 // If mix cipher, re-build RSNIE
2382 RTMPMakeRSNIE(pAd
, pAd
->StaCfg
.AuthMode
, pAd
->StaCfg
.WepStatus
, 0);
2385 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - iterate BSS %ld of %d\n", BssIdx
, pAd
->MlmeAux
.SsidBssTab
.BssNr
));
2386 JoinParmFill(pAd
, &JoinReq
, BssIdx
);
2387 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_JOIN_REQ
, sizeof(MLME_JOIN_REQ_STRUCT
),
2389 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_JOIN
;
2391 else if (pAd
->StaCfg
.BssType
== BSS_ADHOC
)
2393 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",pAd
->MlmeAux
.Ssid
));
2394 StartParmFill(pAd
, &StartReq
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
2395 MlmeEnqueue(pAd
, SYNC_STATE_MACHINE
, MT2_MLME_START_REQ
, sizeof(MLME_START_REQ_STRUCT
), &StartReq
);
2396 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_START
;
2400 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - All roaming failed, stay @ ch #%d\n", pAd
->CommonCfg
.Channel
));
2401 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
2402 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
2403 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
2407 // for re-association only
2408 // IRQL = DISPATCH_LEVEL
2409 VOID
IterateOnBssTab2(
2410 IN PRTMP_ADAPTER pAd
)
2412 MLME_REASSOC_REQ_STRUCT ReassocReq
;
2416 BssIdx
= pAd
->MlmeAux
.RoamIdx
;
2417 pBss
= &pAd
->MlmeAux
.RoamTab
.BssEntry
[BssIdx
];
2419 if (BssIdx
< pAd
->MlmeAux
.RoamTab
.BssNr
)
2421 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - iterate BSS %ld of %d\n", BssIdx
, pAd
->MlmeAux
.RoamTab
.BssNr
));
2423 AsicSwitchChannel(pAd
, pBss
->Channel
, FALSE
);
2424 AsicLockChannel(pAd
, pBss
->Channel
);
2426 // reassociate message has the same structure as associate message
2427 AssocParmFill(pAd
, &ReassocReq
, pBss
->Bssid
, pBss
->CapabilityInfo
,
2428 ASSOC_TIMEOUT
, pAd
->StaCfg
.DefaultListenCount
);
2429 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_MLME_REASSOC_REQ
,
2430 sizeof(MLME_REASSOC_REQ_STRUCT
), &ReassocReq
);
2432 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_REASSOC
;
2436 DBGPRINT(RT_DEBUG_TRACE
, ("CNTL - All fast roaming failed, back to ch #%d\n",pAd
->CommonCfg
.Channel
));
2437 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
2438 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
2439 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
2444 ==========================================================================
2447 IRQL = DISPATCH_LEVEL
2449 ==========================================================================
2452 IN PRTMP_ADAPTER pAd
,
2453 IN OUT MLME_JOIN_REQ_STRUCT
*JoinReq
,
2456 JoinReq
->BssIdx
= BssIdx
;
2460 ==========================================================================
2463 IRQL = DISPATCH_LEVEL
2465 ==========================================================================
2468 IN PRTMP_ADAPTER pAd
,
2469 IN OUT MLME_SCAN_REQ_STRUCT
*ScanReq
,
2475 NdisZeroMemory(ScanReq
->Ssid
, MAX_LEN_OF_SSID
);
2476 ScanReq
->SsidLen
= SsidLen
;
2477 NdisMoveMemory(ScanReq
->Ssid
, Ssid
, SsidLen
);
2478 ScanReq
->BssType
= BssType
;
2479 ScanReq
->ScanType
= ScanType
;
2482 #ifdef QOS_DLS_SUPPORT
2484 ==========================================================================
2487 IRQL = DISPATCH_LEVEL
2489 ==========================================================================
2492 IN PRTMP_ADAPTER pAd
,
2493 IN OUT MLME_DLS_REQ_STRUCT
*pDlsReq
,
2494 IN PRT_802_11_DLS pDls
,
2497 pDlsReq
->pDLS
= pDls
;
2498 pDlsReq
->Reason
= reason
;
2500 #endif // QOS_DLS_SUPPORT //
2503 ==========================================================================
2506 IRQL = DISPATCH_LEVEL
2508 ==========================================================================
2511 IN PRTMP_ADAPTER pAd
,
2512 IN OUT MLME_START_REQ_STRUCT
*StartReq
,
2516 ASSERT(SsidLen
<= MAX_LEN_OF_SSID
);
2517 NdisMoveMemory(StartReq
->Ssid
, Ssid
, SsidLen
);
2518 StartReq
->SsidLen
= SsidLen
;
2522 ==========================================================================
2525 IRQL = DISPATCH_LEVEL
2527 ==========================================================================
2530 IN PRTMP_ADAPTER pAd
,
2531 IN OUT MLME_AUTH_REQ_STRUCT
*AuthReq
,
2535 COPY_MAC_ADDR(AuthReq
->Addr
, pAddr
);
2537 AuthReq
->Timeout
= AUTH_TIMEOUT
;
2541 ==========================================================================
2544 IRQL = DISPATCH_LEVEL
2546 ==========================================================================
2552 VOID
MlmeCntlConfirm(
2553 IN PRTMP_ADAPTER pAd
,
2557 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MsgType
, sizeof(USHORT
), &Msg
);
2561 IN PRTMP_ADAPTER pAd
)
2563 PTXINFO_STRUC pTxInfo
;
2566 DBGPRINT(RT_DEBUG_TRACE
, ("ComposePsPoll\n"));
2567 NdisZeroMemory(&pAd
->PsPollFrame
, sizeof(PSPOLL_FRAME
));
2569 pAd
->PsPollFrame
.FC
.PwrMgmt
= 0;
2570 pAd
->PsPollFrame
.FC
.Type
= BTYPE_CNTL
;
2571 pAd
->PsPollFrame
.FC
.SubType
= SUBTYPE_PS_POLL
;
2572 pAd
->PsPollFrame
.Aid
= pAd
->StaActive
.Aid
| 0xC000;
2573 COPY_MAC_ADDR(pAd
->PsPollFrame
.Bssid
, pAd
->CommonCfg
.Bssid
);
2574 COPY_MAC_ADDR(pAd
->PsPollFrame
.Ta
, pAd
->CurrentAddress
);
2576 RTMPZeroMemory(&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[0], 100);
2577 pTxInfo
= (PTXINFO_STRUC
)&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[0];
2578 RTMPWriteTxInfo(pAd
, pTxInfo
, (USHORT
)(sizeof(PSPOLL_FRAME
)+TXWI_SIZE
), TRUE
, EpToQueue
[MGMTPIPEIDX
], FALSE
, FALSE
);
2579 pTxWI
= (PTXWI_STRUC
)&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[TXINFO_SIZE
];
2580 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, FALSE
, FALSE
, TRUE
, FALSE
, 0, BSSID_WCID
, (sizeof(PSPOLL_FRAME
)),
2581 0, 0, (UCHAR
)pAd
->CommonCfg
.MlmeTransmit
.field
.MCS
, IFS_BACKOFF
, FALSE
, &pAd
->CommonCfg
.MlmeTransmit
);
2582 RTMPMoveMemory(&pAd
->PsPollContext
.TransferBuffer
->field
.WirelessPacket
[TXWI_SIZE
+TXINFO_SIZE
], &pAd
->PsPollFrame
, sizeof(PSPOLL_FRAME
));
2583 // Append 4 extra zero bytes.
2584 pAd
->PsPollContext
.BulkOutSize
= TXINFO_SIZE
+ TXWI_SIZE
+ sizeof(PSPOLL_FRAME
) + 4;
2587 // IRQL = DISPATCH_LEVEL
2588 VOID
ComposeNullFrame(
2589 IN PRTMP_ADAPTER pAd
)
2591 PTXINFO_STRUC pTxInfo
;
2594 NdisZeroMemory(&pAd
->NullFrame
, sizeof(HEADER_802_11
));
2595 pAd
->NullFrame
.FC
.Type
= BTYPE_DATA
;
2596 pAd
->NullFrame
.FC
.SubType
= SUBTYPE_NULL_FUNC
;
2597 pAd
->NullFrame
.FC
.ToDs
= 1;
2598 COPY_MAC_ADDR(pAd
->NullFrame
.Addr1
, pAd
->CommonCfg
.Bssid
);
2599 COPY_MAC_ADDR(pAd
->NullFrame
.Addr2
, pAd
->CurrentAddress
);
2600 COPY_MAC_ADDR(pAd
->NullFrame
.Addr3
, pAd
->CommonCfg
.Bssid
);
2601 RTMPZeroMemory(&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[0], 100);
2602 pTxInfo
= (PTXINFO_STRUC
)&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[0];
2603 RTMPWriteTxInfo(pAd
, pTxInfo
, (USHORT
)(sizeof(HEADER_802_11
)+TXWI_SIZE
), TRUE
, EpToQueue
[MGMTPIPEIDX
], FALSE
, FALSE
);
2604 pTxWI
= (PTXWI_STRUC
)&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[TXINFO_SIZE
];
2605 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, FALSE
, FALSE
, TRUE
, FALSE
, 0, BSSID_WCID
, (sizeof(HEADER_802_11
)),
2606 0, 0, (UCHAR
)pAd
->CommonCfg
.MlmeTransmit
.field
.MCS
, IFS_BACKOFF
, FALSE
, &pAd
->CommonCfg
.MlmeTransmit
);
2607 RTMPMoveMemory(&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[TXWI_SIZE
+TXINFO_SIZE
], &pAd
->NullFrame
, sizeof(HEADER_802_11
));
2608 pAd
->NullContext
.BulkOutSize
= TXINFO_SIZE
+ TXWI_SIZE
+ sizeof(pAd
->NullFrame
) + 4;
2614 ==========================================================================
2616 Pre-build a BEACON frame in the shared memory
2618 IRQL = PASSIVE_LEVEL
2619 IRQL = DISPATCH_LEVEL
2621 ==========================================================================
2623 ULONG
MakeIbssBeacon(
2624 IN PRTMP_ADAPTER pAd
)
2626 UCHAR DsLen
= 1, IbssLen
= 2;
2627 UCHAR LocalErpIe
[3] = {IE_ERP
, 1, 0x04};
2628 HEADER_802_11 BcnHdr
;
2629 USHORT CapabilityInfo
;
2630 LARGE_INTEGER FakeTimestamp
;
2632 PTXWI_STRUC pTxWI
= &pAd
->BeaconTxWI
;
2633 CHAR
*pBeaconFrame
= pAd
->BeaconBuf
;
2635 UCHAR SupRate
[MAX_LEN_OF_SUPPORTED_RATES
];
2636 UCHAR SupRateLen
= 0;
2637 UCHAR ExtRate
[MAX_LEN_OF_SUPPORTED_RATES
];
2638 UCHAR ExtRateLen
= 0;
2639 UCHAR RSNIe
= IE_WPA
;
2641 if ((pAd
->CommonCfg
.PhyMode
== PHY_11B
) && (pAd
->CommonCfg
.Channel
<= 14))
2643 SupRate
[0] = 0x82; // 1 mbps
2644 SupRate
[1] = 0x84; // 2 mbps
2645 SupRate
[2] = 0x8b; // 5.5 mbps
2646 SupRate
[3] = 0x96; // 11 mbps
2650 else if (pAd
->CommonCfg
.Channel
> 14)
2652 SupRate
[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
2653 SupRate
[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
2654 SupRate
[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
2655 SupRate
[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
2656 SupRate
[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
2657 SupRate
[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
2658 SupRate
[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
2659 SupRate
[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2664 // Also Update MlmeRate & RtsRate for G only & A only
2666 pAd
->CommonCfg
.MlmeRate
= RATE_6
;
2667 pAd
->CommonCfg
.RtsRate
= RATE_6
;
2668 pAd
->CommonCfg
.MlmeTransmit
.field
.MODE
= MODE_OFDM
;
2669 pAd
->CommonCfg
.MlmeTransmit
.field
.MCS
= OfdmRateToRxwiMCS
[pAd
->CommonCfg
.MlmeRate
];
2670 pAd
->MacTab
.Content
[BSS0Mcast_WCID
].HTPhyMode
.field
.MODE
= MODE_OFDM
;
2671 pAd
->MacTab
.Content
[BSS0Mcast_WCID
].HTPhyMode
.field
.MCS
= OfdmRateToRxwiMCS
[pAd
->CommonCfg
.MlmeRate
];
2675 SupRate
[0] = 0x82; // 1 mbps
2676 SupRate
[1] = 0x84; // 2 mbps
2677 SupRate
[2] = 0x8b; // 5.5 mbps
2678 SupRate
[3] = 0x96; // 11 mbps
2681 ExtRate
[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps,
2682 ExtRate
[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
2683 ExtRate
[2] = 0x18; // 12 mbps, in units of 0.5 Mbps,
2684 ExtRate
[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
2685 ExtRate
[4] = 0x30; // 24 mbps, in units of 0.5 Mbps,
2686 ExtRate
[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
2687 ExtRate
[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
2688 ExtRate
[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2692 pAd
->StaActive
.SupRateLen
= SupRateLen
;
2693 NdisMoveMemory(pAd
->StaActive
.SupRate
, SupRate
, SupRateLen
);
2694 pAd
->StaActive
.ExtRateLen
= ExtRateLen
;
2695 NdisMoveMemory(pAd
->StaActive
.ExtRate
, ExtRate
, ExtRateLen
);
2697 // compose IBSS beacon frame
2698 MgtMacHeaderInit(pAd
, &BcnHdr
, SUBTYPE_BEACON
, 0, BROADCAST_ADDR
, pAd
->CommonCfg
.Bssid
);
2699 Privacy
= (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption1Enabled
) ||
2700 (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption2Enabled
) ||
2701 (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption3Enabled
);
2702 CapabilityInfo
= CAP_GENERATE(0, 1, Privacy
, (pAd
->CommonCfg
.TxPreamble
== Rt802_11PreambleShort
), 0, 0);
2704 MakeOutgoingFrame(pBeaconFrame
, &FrameLen
,
2705 sizeof(HEADER_802_11
), &BcnHdr
,
2706 TIMESTAMP_LEN
, &FakeTimestamp
,
2707 2, &pAd
->CommonCfg
.BeaconPeriod
,
2710 1, &pAd
->CommonCfg
.SsidLen
,
2711 pAd
->CommonCfg
.SsidLen
, pAd
->CommonCfg
.Ssid
,
2714 SupRateLen
, SupRate
,
2717 1, &pAd
->CommonCfg
.Channel
,
2720 2, &pAd
->StaActive
.AtimWin
,
2723 // add ERP_IE and EXT_RAE IE of in 802.11g
2728 MakeOutgoingFrame(pBeaconFrame
+ FrameLen
, &tmp
,
2732 ExtRateLen
, ExtRate
,
2737 // If adhoc secruity is set for WPA-None, append the cipher suite IE
2738 if (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
2741 RTMPMakeRSNIE(pAd
, pAd
->StaCfg
.AuthMode
, pAd
->StaCfg
.WepStatus
, BSS0
);
2743 MakeOutgoingFrame(pBeaconFrame
+ FrameLen
, &tmp
,
2745 1, &pAd
->StaCfg
.RSNIE_Len
,
2746 pAd
->StaCfg
.RSNIE_Len
, pAd
->StaCfg
.RSN_IE
,
2751 #ifdef DOT11_N_SUPPORT
2752 if ((pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
))
2755 UCHAR HtLen
, HtLen1
;
2757 #ifdef RT_BIG_ENDIAN
2758 HT_CAPABILITY_IE HtCapabilityTmp
;
2759 ADD_HT_INFO_IE addHTInfoTmp
;
2760 USHORT b2lTmp
, b2lTmp2
;
2763 // add HT Capability IE
2764 HtLen
= sizeof(pAd
->CommonCfg
.HtCapability
);
2765 HtLen1
= sizeof(pAd
->CommonCfg
.AddHTInfo
);
2766 #ifndef RT_BIG_ENDIAN
2767 MakeOutgoingFrame(pBeaconFrame
+FrameLen
, &TmpLen
,
2770 HtLen
, &pAd
->CommonCfg
.HtCapability
,
2773 HtLen1
, &pAd
->CommonCfg
.AddHTInfo
,
2776 NdisMoveMemory(&HtCapabilityTmp
, &pAd
->CommonCfg
.HtCapability
, HtLen
);
2777 *(USHORT
*)(&HtCapabilityTmp
.HtCapInfo
) = SWAP16(*(USHORT
*)(&HtCapabilityTmp
.HtCapInfo
));
2778 *(USHORT
*)(&HtCapabilityTmp
.ExtHtCapInfo
) = SWAP16(*(USHORT
*)(&HtCapabilityTmp
.ExtHtCapInfo
));
2780 NdisMoveMemory(&addHTInfoTmp
, &pAd
->CommonCfg
.AddHTInfo
, HtLen1
);
2781 *(USHORT
*)(&addHTInfoTmp
.AddHtInfo2
) = SWAP16(*(USHORT
*)(&addHTInfoTmp
.AddHtInfo2
));
2782 *(USHORT
*)(&addHTInfoTmp
.AddHtInfo3
) = SWAP16(*(USHORT
*)(&addHTInfoTmp
.AddHtInfo3
));
2784 MakeOutgoingFrame(pBeaconFrame
+FrameLen
, &TmpLen
,
2787 HtLen
, &HtCapabilityTmp
,
2790 HtLen1
, &addHTInfoTmp
,
2795 #endif // DOT11_N_SUPPORT //
2797 //beacon use reserved WCID 0xff
2798 if (pAd
->CommonCfg
.Channel
> 14)
2800 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, TRUE
, FALSE
, FALSE
, TRUE
, 0, 0xff, FrameLen
,
2801 PID_MGMT
, PID_BEACON
, RATE_1
, IFS_HTTXOP
, FALSE
, &pAd
->CommonCfg
.MlmeTransmit
);
2805 // Set to use 1Mbps for Adhoc beacon.
2806 HTTRANSMIT_SETTING Transmit
;
2808 RTMPWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, TRUE
, FALSE
, FALSE
, TRUE
, 0, 0xff, FrameLen
,
2809 PID_MGMT
, PID_BEACON
, RATE_1
, IFS_HTTXOP
, FALSE
, &Transmit
);
2812 #ifdef RT_BIG_ENDIAN
2813 RTMPFrameEndianChange(pAd
, pBeaconFrame
, DIR_WRITE
, FALSE
);
2814 RTMPWIEndianChange((PUCHAR
)pTxWI
, TYPE_TXWI
);
2817 DBGPRINT(RT_DEBUG_TRACE
, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n",
2818 FrameLen
, SupRateLen
, ExtRateLen
, pAd
->CommonCfg
.Channel
, pAd
->CommonCfg
.PhyMode
));