diff options
Diffstat (limited to 'drivers/staging/rt2860/sta')
-rw-r--r-- | drivers/staging/rt2860/sta/assoc.c | 586 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/auth.c | 14 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/auth_rsp.c | 19 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/connect.c | 602 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/dls.c | 2197 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/rtmp_data.c | 336 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/sanity.c | 2 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/sync.c | 290 | ||||
-rw-r--r-- | drivers/staging/rt2860/sta/wpa.c | 12 |
9 files changed, 716 insertions, 3342 deletions
diff --git a/drivers/staging/rt2860/sta/assoc.c b/drivers/staging/rt2860/sta/assoc.c index 34f1c1490f4..a0734c65bc2 100644 --- a/drivers/staging/rt2860/sta/assoc.c +++ b/drivers/staging/rt2860/sta/assoc.c @@ -341,7 +341,6 @@ VOID MlmeAssocReqAction( FrameLen += tmp; } -#ifdef DOT11_N_SUPPORT // HT if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { @@ -360,32 +359,14 @@ VOID MlmeAssocReqAction( } else { -#ifdef RT_BIG_ENDIAN - HT_CAPABILITY_IE HtCapabilityTmp; -#endif - -#ifndef RT_BIG_ENDIAN MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, 1, &HtCapIe, 1, &pAd->MlmeAux.HtCapabilityLen, pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability, END_OF_ARGS); -#else - NdisZeroMemory(&HtCapabilityTmp, sizeof(HT_CAPABILITY_IE)); - NdisMoveMemory(&HtCapabilityTmp, &pAd->MlmeAux.HtCapability, pAd->MlmeAux.HtCapabilityLen); - *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo)); - *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo)); - - MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, - 1, &HtCapIe, - 1, &pAd->MlmeAux.HtCapabilityLen, - pAd->MlmeAux.HtCapabilityLen,&HtCapabilityTmp, - END_OF_ARGS); -#endif } FrameLen += TmpLen; } -#endif // DOT11_N_SUPPORT // // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION // Case I: (Aggregation + Piggy-Back) @@ -473,6 +454,11 @@ VOID MlmeAssocReqAction( RSNIe = IE_WPA2; } +#ifdef RT30xx +#ifdef SIOCSIWGENIE + if (pAd->StaCfg.WpaSupplicantUP != 1) +#endif // SIOCSIWGENIE // +#endif RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0); // Check for WPA PMK cache list @@ -499,6 +485,17 @@ VOID MlmeAssocReqAction( } } +#ifdef RT30xx +#ifdef SIOCSIWGENIE + if (pAd->StaCfg.WpaSupplicantUP == 1) + { + MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, + pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE, + END_OF_ARGS); + } + else +#endif +#endif { MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, 1, &RSNIe, @@ -509,6 +506,11 @@ VOID MlmeAssocReqAction( FrameLen += tmp; +#ifdef RT30xx +#ifdef SIOCSIWGENIE + if (pAd->StaCfg.WpaSupplicantUP != 1) +#endif +#endif { // Append Variable IE NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &RSNIe, 1); @@ -560,34 +562,6 @@ VOID MlmeAssocReqAction( END_OF_ARGS); FrameLen += tmp; - // - // Add CipherSuite CCKM or LeapTkip if setting. - // -#ifdef LEAP_SUPPORT - if (LEAP_CCKM_ON(pAd)) - { - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - CipherSuiteCiscoCCKMLen, CipherSuiteCiscoCCKM, - END_OF_ARGS); - FrameLen += tmp; - - // Third add RSN - NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen); //Save CipherSuite - VarIesOffset += CipherSuiteCiscoCCKMLen; - } - else if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)) - { - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - CipherSuiteCCXTkipLen, CipherSuiteCCXTkip, - END_OF_ARGS); - FrameLen += tmp; - - // Third add RSN - NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCCXTkip, CipherSuiteCCXTkipLen); - VarIesOffset += CipherSuiteCCXTkipLen; - } -#endif // LEAP_SUPPORT // - // Add by James 03/06/27 // Set Variable IEs Length pAd->StaCfg.ReqVarIELen = VarIesOffset; @@ -647,23 +621,6 @@ VOID MlmeReassocReqAction( NDIS_STATUS NStatus; ULONG tmp; PUCHAR pOutBuffer = NULL; -//CCX 2.X -#ifdef LEAP_SUPPORT - UCHAR CkipFlag; - UCHAR CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH]; - UCHAR AironetCkipIe = IE_AIRONET_CKIP; - UCHAR AironetCkipLen = CKIP_NEGOTIATION_LENGTH; - UCHAR AironetIPAddressIE = IE_AIRONET_IPADDRESS; - UCHAR AironetIPAddressLen = AIRONET_IPADDRESS_LENGTH; - UCHAR AironetIPAddressBuffer[AIRONET_IPADDRESS_LENGTH] = {0x00, 0x40, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00}; - UCHAR AironetCCKMReassocIE = IE_AIRONET_CCKMREASSOC; - UCHAR AironetCCKMReassocLen = AIRONET_CCKMREASSOC_LENGTH; - UCHAR AironetCCKMReassocBuffer[AIRONET_CCKMREASSOC_LENGTH]; - UCHAR AironetOUI[] = {0x00, 0x40, 0x96, 0x00}; - UCHAR MICMN[16]; - UCHAR CalcMicBuffer[80]; - ULONG CalcMicBufferLen = 0; -#endif // LEAP_SUPPORT // USHORT Status; // Block all authentication request durning WPA block period @@ -738,7 +695,6 @@ VOID MlmeReassocReqAction( FrameLen += tmp; } -#ifdef DOT11_N_SUPPORT // HT if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { @@ -765,7 +721,6 @@ VOID MlmeReassocReqAction( } FrameLen += TmpLen; } -#endif // DOT11_N_SUPPORT // // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION // Case I: (Aggregation + Piggy-Back) @@ -805,73 +760,6 @@ VOID MlmeReassocReqAction( END_OF_ARGS); FrameLen += TmpLen; } -#ifdef LEAP_SUPPORT - if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE)) - { - CkipFlag = pAd->StaCfg.CkipFlag; // We have update that at PeerBeaconAtJoinRequest() - if (CkipFlag != 0) - { - NdisZeroMemory(CkipNegotiationBuffer, CKIP_NEGOTIATION_LENGTH); - CkipNegotiationBuffer[2] = 0x66; - // Make it try KP & MIC, since we have to follow the result from AssocRsp - CkipNegotiationBuffer[8] = 0x18; - CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH - 1] = 0x22; - - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &AironetCkipIe, - 1, &AironetCkipLen, - AironetCkipLen, CkipNegotiationBuffer, - END_OF_ARGS); - FrameLen += tmp; - } - - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &AironetIPAddressIE, - 1, &AironetIPAddressLen, - AironetIPAddressLen, AironetIPAddressBuffer, - END_OF_ARGS); - FrameLen += tmp; - - // - // The RN is incremented before each reassociation request. - // - pAd->StaCfg.CCKMRN++; - // - // Calculate MIC = hmac-md5(krk, STA-ID|BSSID|RSNIE|TSF|RN); - // - COPY_MAC_ADDR(CalcMicBuffer, pAd->CurrentAddress); - CalcMicBufferLen = MAC_ADDR_LEN; - COPY_MAC_ADDR(CalcMicBuffer + CalcMicBufferLen, pAd->MlmeAux.Bssid); - CalcMicBufferLen += MAC_ADDR_LEN; - NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen); - CalcMicBufferLen += CipherSuiteCiscoCCKMLen; - NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR) &pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp)); - CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp); - NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR)&pAd->StaCfg.CCKMRN, sizeof(pAd->StaCfg.CCKMRN)); - CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMRN); - hmac_md5(pAd->StaCfg.KRK, LEN_EAP_MICK, CalcMicBuffer, CalcMicBufferLen, MICMN); - - // - // fill up CCKM reassociation request element - // - NdisMoveMemory(AironetCCKMReassocBuffer, AironetOUI, 4); - NdisMoveMemory(AironetCCKMReassocBuffer + 4, (PUCHAR)&pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, 8); - NdisMoveMemory(AironetCCKMReassocBuffer + 12, (PUCHAR) &pAd->StaCfg.CCKMRN, 4); - NdisMoveMemory(AironetCCKMReassocBuffer +16, MICMN, 8); - - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &AironetCCKMReassocIE, - 1, &AironetCCKMReassocLen, - AironetCCKMReassocLen, AironetCCKMReassocBuffer, - END_OF_ARGS); - FrameLen += tmp; - - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - CipherSuiteCiscoCCKMLen,CipherSuiteCiscoCCKM, - END_OF_ARGS); - FrameLen += tmp; - } -#endif // LEAP_SUPPORT // // Add CCX v2 request if CCX2 admin state is on if (pAd->StaCfg.CCXControl.field.Enable == 1) @@ -927,36 +815,6 @@ VOID MlmeDisassocReqAction( ULONG Timeout = 0; USHORT Status; -#ifdef QOS_DLS_SUPPORT - // send DLS-TEAR_DOWN message, - if (pAd->CommonCfg.bDLSCapable) - { - UCHAR i; - - // tear down local dls table entry - for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) - { - RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - } - } - - // tear down peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) - { - RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - } - } - } -#endif // QOS_DLS_SUPPORT // - // skip sanity check pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg); @@ -999,27 +857,11 @@ VOID MlmeDisassocReqAction( RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */ pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP; -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) - { - union iwreq_data wrqu; - //send disassociate event to wpa_supplicant - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_DISASSOC_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT { union iwreq_data wrqu; memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN); wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // - } /* @@ -1057,31 +899,15 @@ VOID PeerAssocRspAction( if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) { DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status)); -#ifdef DOT11_N_SUPPORT DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",Elem->Wcid, pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags)); -#endif // DOT11_N_SUPPORT // RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled); if(Status == MLME_SUCCESS) { +#ifdef RT2860 // go to procedure listed on page 376 AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo); -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) - { - union iwreq_data wrqu; - - SendAssocIEsToWpaSupplicant(pAd); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_ASSOC_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT { union iwreq_data wrqu; wext_notify_event_assoc(pAd); @@ -1091,9 +917,29 @@ VOID PeerAssocRspAction( wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // +#endif +#ifdef RT2870 + UCHAR MaxSupportedRateIn500Kbps = 0; + UCHAR idx; + // supported rates array may not be sorted. sort it and find the maximum rate + for (idx=0; idx<SupRateLen; idx++) + { + if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f)) + MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f; + } + + for (idx=0; idx<ExtRateLen; idx++) + { + if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f)) + MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f; + } + // go to procedure listed on page 376 + AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, + &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo); + StaAddMacTableEntry(pAd, &pAd->MacTab.Content[BSSID_WCID], MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo); +#endif pAd->StaCfg.CkipFlag = CkipFlag; if (CkipFlag & 0x18) { @@ -1109,14 +955,6 @@ VOID PeerAssocRspAction( } else { - // Faile on Association, we need to check the status code - // Is that a Rogue AP? -#ifdef LEAP_SUPPORT - if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (Status == MLME_ALG_NOT_SUPPORT)) - { //Possibly Rogue AP - RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, pAd->MlmeAux.Bssid, LEAP_REASON_INVALID_AUTH); - } -#endif // LEAP_SUPPORT // } pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status); @@ -1172,21 +1010,6 @@ VOID PeerReassocRspAction( AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo); -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) - { - union iwreq_data wrqu; - - SendAssocIEsToWpaSupplicant(pAd); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_ASSOC_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT { union iwreq_data wrqu; wext_notify_event_assoc(pAd); @@ -1196,41 +1019,9 @@ VOID PeerReassocRspAction( wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // } - // - // Cisco Leap CCKM supported Re-association. - // -#ifdef LEAP_SUPPORT - if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE)) - { - if (CCKMAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen) == TRUE) - { - pAd->StaCfg.CkipFlag = CkipFlag; - if (CkipFlag & 0x18) - { - NdisZeroMemory(pAd->StaCfg.TxSEQ, 4); - NdisZeroMemory(pAd->StaCfg.RxSEQ, 4); - NdisZeroMemory(pAd->StaCfg.CKIPMIC, 4); - pAd->StaCfg.GIV[0] = RandomByte(pAd); - pAd->StaCfg.GIV[1] = RandomByte(pAd); - pAd->StaCfg.GIV[2] = RandomByte(pAd); - pAd->StaCfg.bCkipOn = TRUE; - DBGPRINT(RT_DEBUG_TRACE, ("<CCX> pAd->StaCfg.CkipFlag = 0x%02x\n", pAd->StaCfg.CkipFlag)); - } - - pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; - MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status); - } - else - { - DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - CCKMAssocRspSanity() sanity check fail\n")); - } - } - else -#endif // LEAP_SUPPORT // { // CkipFlag is no use for reassociate pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; @@ -1275,7 +1066,7 @@ VOID AssocPostProc( COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2); pAd->MlmeAux.Aid = Aid; pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO; -#ifdef DOT11_N_SUPPORT + // Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on. if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE)) { @@ -1301,7 +1092,6 @@ VOID AssocPostProc( pEdcaParm->Txop[3] = 48; } -#endif // DOT11_N_SUPPORT // NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM)); @@ -1315,7 +1105,6 @@ VOID AssocPostProc( NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen); RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen); -#ifdef DOT11_N_SUPPORT if (HtCapabilityLen > 0) { RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo); @@ -1324,7 +1113,6 @@ VOID AssocPostProc( DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n", pAd->MacTab.Content[BSSID_WCID].MmpsMode, pAd->MacTab.Content[BSSID_WCID].AMsduSize)); -#endif // DOT11_N_SUPPORT // // Set New WPA information Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel); @@ -1414,21 +1202,6 @@ VOID PeerDisassocAction( RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); } - -#ifdef LEAP_SUPPORT - if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) - { - // Cisco_LEAP has start a timer - // We should cancel it if using LEAP - RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled); - //Check is it mach the LEAP Authentication failed as possible a Rogue AP - //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Association. - if ((pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE) && (pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED)) - { - RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT); - } - } -#endif // LEAP_SUPPORT // // // Get Current System time and Turn on AdjacentAPReport // @@ -1437,26 +1210,11 @@ VOID PeerDisassocAction( LinkDown(pAd, TRUE); pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) - { - union iwreq_data wrqu; - //send disassociate event to wpa_supplicant - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_DISASSOC_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT { union iwreq_data wrqu; memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN); wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // } } else @@ -1739,36 +1497,6 @@ VOID SwitchBetweenWepAndCkip( } } -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT -VOID SendAssocIEsToWpaSupplicant( - IN PRTMP_ADAPTER pAd) -{ - union iwreq_data wrqu; - unsigned char custom[IW_CUSTOM_MAX] = {0}; - - if ((pAd->StaCfg.ReqVarIELen + 17) <= IW_CUSTOM_MAX) - { - sprintf(custom, "ASSOCINFO_ReqIEs="); - NdisMoveMemory(custom+17, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = pAd->StaCfg.ReqVarIELen + 17; - wrqu.data.flags = RT_REQIE_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom); - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_ASSOCINFO_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } - else - DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen + 17 > MAX_CUSTOM_LEN\n")); - - return; -} -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT int wext_notify_event_assoc( IN RTMP_ADAPTER *pAd) { @@ -1791,7 +1519,7 @@ int wext_notify_event_assoc( wrqu.data.length = (pAd->StaCfg.ReqVarIELen*2) + 17; sprintf(custom, "ASSOCINFO(ReqIEs="); for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++) - sprintf(custom, "%s%02x", custom, pAd->StaCfg.ReqVarIEs[idx]); + sprintf(custom + strlen(custom), "%02x", pAd->StaCfg.ReqVarIEs[idx]); wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom); } else @@ -1801,5 +1529,227 @@ int wext_notify_event_assoc( return 0; } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // +#ifdef RT2870 +BOOLEAN StaAddMacTableEntry( + IN PRTMP_ADAPTER pAd, + IN PMAC_TABLE_ENTRY pEntry, + IN UCHAR MaxSupportedRateIn500Kbps, + IN HT_CAPABILITY_IE *pHtCapability, + IN UCHAR HtCapabilityLen, + IN USHORT CapabilityInfo) +{ + UCHAR MaxSupportedRate = RATE_11; + + if (ADHOC_ON(pAd)) + CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE); + + switch (MaxSupportedRateIn500Kbps) + { + case 108: MaxSupportedRate = RATE_54; break; + case 96: MaxSupportedRate = RATE_48; break; + case 72: MaxSupportedRate = RATE_36; break; + case 48: MaxSupportedRate = RATE_24; break; + case 36: MaxSupportedRate = RATE_18; break; + case 24: MaxSupportedRate = RATE_12; break; + case 18: MaxSupportedRate = RATE_9; break; + case 12: MaxSupportedRate = RATE_6; break; + case 22: MaxSupportedRate = RATE_11; break; + case 11: MaxSupportedRate = RATE_5_5; break; + case 4: MaxSupportedRate = RATE_2; break; + case 2: MaxSupportedRate = RATE_1; break; + default: MaxSupportedRate = RATE_11; break; + } + + if ((pAd->CommonCfg.PhyMode == PHY_11G) && (MaxSupportedRate < RATE_FIRST_OFDM_RATE)) + return FALSE; + + // 11n only + if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G))&& (HtCapabilityLen == 0)) + return FALSE; + + if (!pEntry) + return FALSE; + + NdisAcquireSpinLock(&pAd->MacTabLock); + if (pEntry) + { + pEntry->PortSecured = WPA_802_1X_PORT_SECURED; + if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) || + (pAd->CommonCfg.PhyMode == PHY_11B)) + { + pEntry->RateLen = 4; + if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE) + MaxSupportedRate = RATE_11; + } + else + pEntry->RateLen = 12; + + pEntry->MaxHTPhyMode.word = 0; + pEntry->MinHTPhyMode.word = 0; + pEntry->HTPhyMode.word = 0; + pEntry->MaxSupportedRate = MaxSupportedRate; + if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) + { + pEntry->MaxHTPhyMode.field.MODE = MODE_CCK; + pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate; + pEntry->MinHTPhyMode.field.MODE = MODE_CCK; + pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate; + pEntry->HTPhyMode.field.MODE = MODE_CCK; + pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate; + } + else + { + pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM; + pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; + pEntry->MinHTPhyMode.field.MODE = MODE_OFDM; + pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; + pEntry->HTPhyMode.field.MODE = MODE_OFDM; + pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; + } + pEntry->CapabilityInfo = CapabilityInfo; + CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE); + CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE); + } + + // If this Entry supports 802.11n, upgrade to HT rate. + if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) + { + UCHAR j, bitmask; //k,bitmask; + CHAR i; + + if (ADHOC_ON(pAd)) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE); + if ((pHtCapability->HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF)) + { + pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD; + } + else + { + pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; + pAd->MacTab.fAnyStationNonGF = TRUE; + pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1; + } + + if ((pHtCapability->HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth)) + { + pEntry->MaxHTPhyMode.field.BW= BW_40; + pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(pHtCapability->HtCapInfo.ShortGIfor40)); + } + else + { + pEntry->MaxHTPhyMode.field.BW = BW_20; + pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(pHtCapability->HtCapInfo.ShortGIfor20)); + pAd->MacTab.fAnyStation20Only = TRUE; + } + + // 3*3 + if (pAd->MACVersion >= RALINK_2883_VERSION && pAd->MACVersion < RALINK_3070_VERSION) + pEntry->MaxHTPhyMode.field.TxBF = pAd->CommonCfg.RegTransmitSetting.field.TxBF; + + // find max fixed rate + for (i=23; i>=0; i--) // 3*3 + { + j = i/8; + bitmask = (1<<(i-(j*8))); + if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask) && (pHtCapability->MCSSet[j] & bitmask)) + { + pEntry->MaxHTPhyMode.field.MCS = i; + break; + } + if (i==0) + break; + } + + + if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) + { + if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) + { + // Fix MCS as HT Duplicated Mode + pEntry->MaxHTPhyMode.field.BW = 1; + pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; + pEntry->MaxHTPhyMode.field.STBC = 0; + pEntry->MaxHTPhyMode.field.ShortGI = 0; + pEntry->MaxHTPhyMode.field.MCS = 32; + } + else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS) + { + // STA supports fixed MCS + pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; + } + } + + pEntry->MaxHTPhyMode.field.STBC = (pHtCapability->HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC)); + pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity; + pEntry->MaxRAmpduFactor = pHtCapability->HtCapParm.MaxRAmpduFactor; + pEntry->MmpsMode = (UCHAR)pHtCapability->HtCapInfo.MimoPs; + pEntry->AMsduSize = (UCHAR)pHtCapability->HtCapInfo.AMsduSize; + pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; + + if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE)) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED); + if (pHtCapability->HtCapInfo.ShortGIfor20) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE); + if (pHtCapability->HtCapInfo.ShortGIfor40) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE); + if (pHtCapability->HtCapInfo.TxSTBC) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE); + if (pHtCapability->HtCapInfo.RxSTBC) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE); + if (pHtCapability->ExtHtCapInfo.PlusHTC) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE); + if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE); + if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03) + CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE); + } + else + { + pAd->MacTab.fAnyStationIsLegacy = TRUE; + } + + NdisMoveMemory(&pEntry->HTCapability, pHtCapability, sizeof(HT_CAPABILITY_IE)); + + pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; + pEntry->CurrTxRate = pEntry->MaxSupportedRate; + + // Set asic auto fall back + if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) + { + PUCHAR pTable; + UCHAR TableSize = 0; + + MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex); + pEntry->bAutoTxRateSwitch = TRUE; + } + else + { + pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE; + pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; + pEntry->bAutoTxRateSwitch = FALSE; + + // If the legacy mode is set, overwrite the transmit setting of this entry. + RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry); + } + + pEntry->PortSecured = WPA_802_1X_PORT_SECURED; + pEntry->Sst = SST_ASSOC; + pEntry->AuthState = AS_AUTH_OPEN; + pEntry->AuthMode = pAd->StaCfg.AuthMode; + pEntry->WepStatus = pAd->StaCfg.WepStatus; + + NdisReleaseSpinLock(&pAd->MacTabLock); + + { + union iwreq_data wrqu; + wext_notify_event_assoc(pAd); + + memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN); + memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN); + wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); + + } + return TRUE; +} +#endif /* RT2870 */ diff --git a/drivers/staging/rt2860/sta/auth.c b/drivers/staging/rt2860/sta/auth.c index 73fb8d6ea76..d8414eac42f 100644 --- a/drivers/staging/rt2860/sta/auth.c +++ b/drivers/staging/rt2860/sta/auth.c @@ -218,15 +218,9 @@ VOID PeerAuthRspAtSeq2Action( { // Authentication Mode "LEAP" has allow for CCX 1.X if ((pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen) -#ifdef LEAP_SUPPORT - || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) -#endif // LEAP_SUPPORT // ) { pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE; -#ifdef LEAP_SUPPORT - pAd->Mlme.LeapMachine.CurrState = LEAP_IDLE; -#endif // LEAP_SUPPORT // MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status); } else @@ -282,14 +276,6 @@ VOID PeerAuthRspAtSeq2Action( } else { -#ifdef LEAP_SUPPORT - if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) - { - //Invalid Authentication possible rogue AP - //Add this Ap to Rogue AP. - RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_INVALID_AUTH); - } -#endif // LEAP_SUPPORT // pAd->StaCfg.AuthFailReason = Status; COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2); pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE; diff --git a/drivers/staging/rt2860/sta/auth_rsp.c b/drivers/staging/rt2860/sta/auth_rsp.c index f7aa4b99cf5..cc639b1c6c1 100644 --- a/drivers/staging/rt2860/sta/auth_rsp.c +++ b/drivers/staging/rt2860/sta/auth_rsp.c @@ -127,36 +127,17 @@ VOID PeerDeauthAction( { DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n", Reason)); - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT { union iwreq_data wrqu; memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN); wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // - // send wireless event - for deauthentication if (pAd->CommonCfg.bWirelessEvent) RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); LinkDown(pAd, TRUE); - - // Authentication Mode Cisco_LEAP has start a timer - // We should cancel it if using LEAP -#ifdef LEAP_SUPPORT - if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) - { - RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled); - //Check is it mach the LEAP Authentication failed as possible a Rogue AP - //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Authenticaton. - if ((pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED) && (pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE)) - { - RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT); - } - } -#endif // LEAP_SUPPORT // } } else diff --git a/drivers/staging/rt2860/sta/connect.c b/drivers/staging/rt2860/sta/connect.c index d8bcc76688a..ac713518666 100644 --- a/drivers/staging/rt2860/sta/connect.c +++ b/drivers/staging/rt2860/sta/connect.c @@ -178,13 +178,6 @@ VOID MlmeCntlMachinePerformAction( pAd->bLedOnScanning = FALSE; RTMPSetLED(pAd, pAd->LedStatus); } -#ifdef DOT11N_DRAFT3 - // AP sent a 2040Coexistence mgmt frame, then station perform a scan, and then send back the respone. - if (pAd->CommonCfg.BSSCoexist2040.field.InfoReq == 1) - { - Update2040CoexistFrameAndNotify(pAd, BSSID_WCID, TRUE); - } -#endif // DOT11N_DRAFT3 // } break; @@ -195,6 +188,38 @@ VOID MlmeCntlMachinePerformAction( pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; } break; +#ifdef RT2870 + // + // This state is for that we want to connect to an AP but + // it didn't find on BSS List table. So we need to scan the air first, + // after that we can try to connect to the desired AP if available. + // + case CNTL_WAIT_SCAN_FOR_CONNECT: + if(Elem->MsgType == MT2_SCAN_CONF) + { + // Resume TxRing after SCANING complete. We hope the out-of-service time + // won't be too long to let upper layer time-out the waiting frames + RTMPResumeMsduTransmission(pAd); +#ifdef CCX_SUPPORT + if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) + { + // Cisco scan request is finished, prepare beacon report + MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL); + } +#endif // CCX_SUPPORT // + pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; + + // + // Check if we can connect to. + // + BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen); + if (pAd->MlmeAux.SsidBssTab.BssNr > 0) + { + MlmeAutoReconnectLastSSID(pAd); + } + } + break; +#endif // RT2870 // default: DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", Elem->MsgType)); break; @@ -234,19 +259,11 @@ VOID CntlIdleProc( break; case OID_802_11_DISASSOCIATE: -#ifdef RALINK_ATE - if(ATE_ON(pAd)) - { - DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n")); - break; - } -#endif // RALINK_ATE // DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING); MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq); pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC; -#ifdef WPA_SUPPLICANT_SUPPORT + if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE_WITH_WEB_UI) -#endif // WPA_SUPPLICANT_SUPPORT // { // Set the AutoReconnectSsid to prevent it reconnect to old SSID // Since calling this indicate user don't want to connect to that SSID anymore. @@ -263,12 +280,6 @@ VOID CntlIdleProc( WpaMicFailureReportFrame(pAd, Elem); break; -#ifdef QOS_DLS_SUPPORT - case RT_OID_802_11_SET_DLS_PARAM: - CntlOidDLSSetupProc(pAd, Elem); - break; -#endif // QOS_DLS_SUPPORT // - default: DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem->MsgType)); break; @@ -283,13 +294,6 @@ VOID CntlOidScanProc( ULONG BssIdx = BSS_NOT_FOUND; BSS_ENTRY CurrBss; -#ifdef RALINK_ATE -/* Disable scanning when ATE is running. */ - if (ATE_ON(pAd)) - return; -#endif // RALINK_ATE // - - // record current BSS if network is connected. // 2003-2-13 do not include current IBSS if this is the only STA in this IBSS. if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) @@ -337,9 +341,11 @@ VOID CntlOidSsidProc( MLME_DISASSOC_REQ_STRUCT DisassocReq; ULONG Now; +#ifdef RT2860 // BBP and RF are not accessible in PS mode, we has to wake them up first if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) AsicForceWakeup(pAd, RTMP_HALT); +#endif // Step 1. record the desired user settings to MlmeAux NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID); @@ -377,9 +383,6 @@ VOID CntlOidSsidProc( (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) -#ifdef LEAP_SUPPORT - || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) -#endif // LEAP_SUPPORT // ) && (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) { @@ -420,7 +423,7 @@ VOID CntlOidSsidProc( } pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT + { union iwreq_data wrqu; @@ -429,7 +432,6 @@ VOID CntlOidSsidProc( wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // } } else if (INFRA_ON(pAd)) @@ -513,12 +515,6 @@ VOID CntlOidRTBssidProc( MLME_DISASSOC_REQ_STRUCT DisassocReq; MLME_JOIN_REQ_STRUCT JoinReq; -#ifdef RALINK_ATE -/* No need to perform this routine when ATE is running. */ - if (ATE_ON(pAd)) - return; -#endif // RALINK_ATE // - // record user desired settings COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pOidBssid); pAd->MlmeAux.BssType = pAd->StaCfg.BssType; @@ -558,7 +554,7 @@ VOID CntlOidRTBssidProc( // already connected to the same BSSID, go back to idle state directly DBGPRINT(RT_DEBUG_TRACE, ("CNTL - already in this BSSID. ignore this SET_BSSID request\n")); pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT + { union iwreq_data wrqu; @@ -567,7 +563,6 @@ VOID CntlOidRTBssidProc( wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // } else { @@ -672,113 +667,6 @@ VOID CntlMlmeRoamingProc( IterateOnBssTab(pAd); } -#ifdef QOS_DLS_SUPPORT -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== -*/ -VOID CntlOidDLSSetupProc( - IN PRTMP_ADAPTER pAd, - IN MLME_QUEUE_ELEM *Elem) -{ - PRT_802_11_DLS pDLS = (PRT_802_11_DLS)Elem->Msg; - MLME_DLS_REQ_STRUCT MlmeDlsReq; - INT i; - USHORT reason = REASON_UNSPECIFY; - - DBGPRINT(RT_DEBUG_TRACE,("CNTL - (OID set %02x:%02x:%02x:%02x:%02x:%02x with Valid=%d, Status=%d, TimeOut=%d, CountDownTimer=%d)\n", - pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5], - pDLS->Valid, pDLS->Status, pDLS->TimeOut, pDLS->CountDownTimer)); - - if (!pAd->CommonCfg.bDLSCapable) - return; - - // DLS will not be supported when Adhoc mode - if (INFRA_ON(pAd)) - { - for (i = 0; i < MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && - (pDLS->TimeOut == pAd->StaCfg.DLSEntry[i].TimeOut) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - // 1. Same setting, just drop it - DBGPRINT(RT_DEBUG_TRACE,("CNTL - setting unchanged\n")); - break; - } - else if (!pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && - MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - // 2. Disable DLS link case, just tear down DLS link - reason = REASON_QOS_UNWANTED_MECHANISM; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - DBGPRINT(RT_DEBUG_TRACE,("CNTL - start tear down procedure\n")); - break; - } - else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && !pAd->StaCfg.DLSEntry[i].Valid) - { - // 3. Enable case, start DLS setup procedure - NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI)); - - //Update countdown timer - pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut; - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS setup case\n")); - break; - } - else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && - (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && !MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - // 4. update mac case, tear down old DLS and setup new DLS - reason = REASON_QOS_UNWANTED_MECHANISM; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI)); - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS tear down and restart case\n")); - break; - } - else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && - MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr) && (pAd->StaCfg.DLSEntry[i].TimeOut != pDLS->TimeOut)) - { - // 5. update timeout case, start DLS setup procedure (no tear down) - pAd->StaCfg.DLSEntry[i].TimeOut = pDLS->TimeOut; - //Update countdown timer - pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut; - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS update timeout case\n")); - break; - } - else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && - (pAd->StaCfg.DLSEntry[i].Status != DLS_FINISH) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - // 6. re-setup case, start DLS setup procedure (no tear down) - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS retry setup procedure\n")); - break; - } - else - { - DBGPRINT(RT_DEBUG_WARN,("CNTL - DLS not changed in entry - %d - Valid=%d, Status=%d, TimeOut=%d\n", - i, pAd->StaCfg.DLSEntry[i].Valid, pAd->StaCfg.DLSEntry[i].Status, pAd->StaCfg.DLSEntry[i].TimeOut)); - } - } - } -} -#endif // QOS_DLS_SUPPORT // - /* ========================================================================== Description: @@ -870,14 +758,6 @@ VOID CntlWaitJoinProc( // 2. joined a new INFRA network, start from authentication else { -#ifdef LEAP_SUPPORT - // Add AuthMode "LEAP" for CCX 1.X - if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) - { - AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP); - } - else -#endif // LEAP_SUPPORT // { // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) || @@ -937,7 +817,7 @@ VOID CntlWaitStartProc( DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel)); return; } -#ifdef DOT11_N_SUPPORT + if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) { N_ChannelCheck(pAd); @@ -961,7 +841,6 @@ VOID CntlWaitStartProc( } } else -#endif // DOT11_N_SUPPORT // { pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE; } @@ -974,9 +853,6 @@ VOID CntlWaitStartProc( { pAd->CommonCfg.RadarDetect.RDMode = RD_SILENCE_MODE; pAd->CommonCfg.RadarDetect.RDCount = 0; -#ifdef DFS_SUPPORT - BbpRadarDetectionStart(pAd); -#endif // DFS_SUPPORT // } DBGPRINT(RT_DEBUG_TRACE, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n", @@ -1016,21 +892,6 @@ VOID CntlWaitAuthProc( AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo, ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount); -#ifdef LEAP_SUPPORT - // - // Cisco Leap CCKM supported Re-association. - // - if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE)) - { - //if CCKM is turn on , that's mean Fast Reauthentication - //Use CCKM Reassociation instead of normal association for Fast Roaming. - MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ, - sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq); - - pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC; - } - else -#endif // LEAP_SUPPORT // { MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ, sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq); @@ -1044,14 +905,7 @@ VOID CntlWaitAuthProc( // ageing-out. The previous authentication attempt must have let it remove us. // so try Authentication again may help. For D-Link DWL-900AP+ compatibility. DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try again...\n")); -#ifdef LEAP_SUPPORT - //Add AuthMode "LEAP" for CCX 1.X - if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) - { - AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP); - } - else -#endif // LEAP_SUPPORT // + { if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch)) @@ -1103,20 +957,6 @@ VOID CntlWaitAuthProc2( } else { -#ifdef LEAP_SUPPORT - // Process LEAP first, since it use different control variable - // We don't want to affect other poven operation - if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) - { - // LEAP Auth not success, try next BSS - DBGPRINT(RT_DEBUG_TRACE, ("CNTL - *LEAP* AUTH FAIL, give up; try next BSS\n")); - DBGPRINT(RT_DEBUG_TRACE, ("Total match BSSID [=%d]\n", pAd->MlmeAux.SsidBssTab.BssNr)); - pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; - pAd->MlmeAux.BssIdx++; - IterateOnBssTab(pAd); - } - else -#endif // LEAP_SUPPORT // if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) && (pAd->MlmeAux.Alg == Ndis802_11AuthModeShared)) { @@ -1205,14 +1045,6 @@ VOID CntlWaitReassocProc( if (pAd->CommonCfg.bWirelessEvent) RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); - -#ifdef LEAP_SUPPORT - if (LEAP_CCKM_ON(pAd)) - { - STA_PORT_SECURED(pAd); - pAd->StaCfg.WpaState = SS_FINISH; - } -#endif // LEAP_SUPPORT // pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd->MlmeAux.RoamIdx)); } @@ -1226,6 +1058,44 @@ VOID CntlWaitReassocProc( } } + +#ifdef RT2870 +VOID AdhocTurnOnQos( + IN PRTMP_ADAPTER pAd) +{ +#define AC0_DEF_TXOP 0 +#define AC1_DEF_TXOP 0 +#define AC2_DEF_TXOP 94 +#define AC3_DEF_TXOP 47 + + // Turn on QOs if use HT rate. + if (pAd->CommonCfg.APEdcaParm.bValid == FALSE) + { + pAd->CommonCfg.APEdcaParm.bValid = TRUE; + pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3; + pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7; + pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1; + pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1; + + pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4; + pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4; + pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3; + pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2; + + pAd->CommonCfg.APEdcaParm.Cwmax[0] = 10; + pAd->CommonCfg.APEdcaParm.Cwmax[1] = 6; + pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4; + pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3; + + pAd->CommonCfg.APEdcaParm.Txop[0] = 0; + pAd->CommonCfg.APEdcaParm.Txop[1] = 0; + pAd->CommonCfg.APEdcaParm.Txop[2] = AC2_DEF_TXOP; + pAd->CommonCfg.APEdcaParm.Txop[3] = AC3_DEF_TXOP; + } + AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm); +} +#endif /* RT2870 */ + /* ========================================================================== Description: @@ -1244,12 +1114,14 @@ VOID LinkUp( UCHAR Value = 0, idx; MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry; +#ifdef RT2860 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)) { RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT); RTMPusecDelay(6000); pAd->bPCIclkOff = FALSE; } +#endif pEntry = &pAd->MacTab.Content[BSSID_WCID]; @@ -1266,15 +1138,15 @@ VOID LinkUp( COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd); -#ifdef DOT11_N_SUPPORT COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd); -#endif // DOT11_N_SUPPORT // + // It's quite difficult to tell if a newly added KEY is WEP or CKIP until a new BSS // is formed (either ASSOC/RE-ASSOC done or IBSS started. LinkUP should be a safe place // to examine if cipher algorithm switching is required. //rt2860b. Don't know why need this SwitchBetweenWepAndCkip(pAd); +#ifdef RT2860 // Before power save before link up function, We will force use 1R. // So after link up, check Rx antenna # again. RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); @@ -1292,17 +1164,30 @@ VOID LinkUp( } RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); pAd->StaCfg.BBPR3 = Value; +#endif /* RT2860 */ if (BssType == BSS_ADHOC) { OPSTATUS_SET_FLAG(pAd, fOP_STATUS_ADHOC_ON); OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON); -#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier - // No carrier detection when adhoc - // CarrierDetectionStop(pAd); - pAd->CommonCfg.CarrierDetect.CD_State = CD_NORMAL; -#endif // CARRIER_DETECTION_SUPPORT // +#ifdef RT30xx + if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) && + (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE)) + { + pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2; + } + else if ((pAd->CommonCfg.Channel > 2) && + (pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) && + (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW)) + { + pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2; + } +#endif +#ifdef RT2870 + if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) + AdhocTurnOnQos(pAd); +#endif DBGPRINT(RT_DEBUG_TRACE, ("!!!Adhoc LINK UP !!! \n" )); } @@ -1321,7 +1206,6 @@ VOID LinkUp( Value |= pAd->CommonCfg.RegTransmitSetting.field.TxBF; RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value); -#ifdef DOT11_N_SUPPORT // Change to AP channel if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40)) { @@ -1339,7 +1223,9 @@ VOID LinkUp( RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); Value &= (~0x20); RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); +#ifdef RT2860 pAd->StaCfg.BBPR3 = Value; +#endif RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data); Data &= 0xfffffffe; @@ -1374,7 +1260,9 @@ VOID LinkUp( RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); Value |= (0x20); RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); +#ifdef RT2860 pAd->StaCfg.BBPR3 = Value; +#endif if (pAd->MACVersion == 0x28600100) { @@ -1387,7 +1275,6 @@ VOID LinkUp( DBGPRINT(RT_DEBUG_TRACE, ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel )); } else -#endif // DOT11_N_SUPPORT // { pAd->CommonCfg.BBPCurrentBW = BW_20; pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel; @@ -1405,7 +1292,9 @@ VOID LinkUp( RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); Value &= (~0x20); RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); +#ifdef RT2860 pAd->StaCfg.BBPR3 = Value; +#endif if (pAd->MACVersion == 0x28600100) { @@ -1427,9 +1316,7 @@ VOID LinkUp( DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n", BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel)); -#ifdef DOT11_N_SUPPORT DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (Density =%d, )\n", pAd->MacTab.Content[BSSID_WCID].MpduDensity)); -#endif // DOT11_N_SUPPORT // AsicSetBssid(pAd, pAd->CommonCfg.Bssid); @@ -1439,7 +1326,6 @@ VOID LinkUp( // Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit AsicUpdateProtect(pAd, 0, (OFDMSETPROTECT | CCKSETPROTECT), TRUE, FALSE); -#ifdef DOT11_N_SUPPORT if ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE)) { // Update HT protectionfor based on AP's operating mode. @@ -1450,7 +1336,6 @@ VOID LinkUp( else AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE); } -#endif // DOT11_N_SUPPORT // NdisZeroMemory(&pAd->DrsCounters, sizeof(COUNTER_DRS)); @@ -1467,9 +1352,6 @@ VOID LinkUp( if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE) { -#ifdef DFS_SUPPORT - RadarDetectionStop(pAd); -#endif // DFS_SUPPORT // } pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE; @@ -1602,7 +1484,9 @@ VOID LinkUp( IV |= (pAd->StaCfg.DefaultKeyId << 30); AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0); +#ifdef RT2860 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); +#endif } // NOTE: // the decision of using "short slot time" or not may change dynamically due to @@ -1643,15 +1527,11 @@ VOID LinkUp( // If WEP is enabled, add paiewise and shared key -#ifdef WPA_SUPPLICANT_SUPPORT if (((pAd->StaCfg.WpaSupplicantUP)&& (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)&& (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)) || ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)&& (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled))) -#else - if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) -#endif // WPA_SUPPLICANT_SUPPORT // { PUCHAR Key; UCHAR CipherAlg; @@ -1687,9 +1567,14 @@ VOID LinkUp( { pAd->IndicateMediaState = NdisMediaStateConnected; pAd->ExtraInfo = GENERAL_LINK_UP; +#ifdef RT2870 + RTMP_IndicateMediaState(pAd); +#endif } // -- +#ifdef RT2860 RTMP_IndicateMediaState(pAd); +#endif // Add BSSID in my MAC Table. NdisAcquireSpinLock(&pAd->MacTabLock); @@ -1700,6 +1585,9 @@ VOID LinkUp( pAd->MacTab.Size = 1; // infra mode always set MACtab size =1. pAd->MacTab.Content[BSSID_WCID].Sst = SST_ASSOC; pAd->MacTab.Content[BSSID_WCID].AuthState = SST_ASSOC; +#ifdef RT30xx + pAd->MacTab.Content[BSSID_WCID].AuthMode = pAd->StaCfg.AuthMode; +#endif pAd->MacTab.Content[BSSID_WCID].WepStatus = pAd->StaCfg.WepStatus; NdisReleaseSpinLock(&pAd->MacTabLock); @@ -1707,17 +1595,8 @@ VOID LinkUp( pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags)); MlmeUpdateTxRates(pAd, TRUE, BSS0); -#ifdef DOT11_N_SUPPORT MlmeUpdateHtTxRates(pAd, BSS0); DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", pAd->StaActive.SupportedPhyInfo.bHtEnable)); -#endif // DOT11_N_SUPPORT // - - // - // Report Adjacent AP report. - // -#ifdef LEAP_SUPPORT - CCXAdjacentAPReport(pAd); -#endif // LEAP_SUPPORT // if (pAd->CommonCfg.bAggregationCapable) { @@ -1737,12 +1616,11 @@ VOID LinkUp( if (pAd->MlmeAux.APRalinkIe != 0x0) { -#ifdef DOT11_N_SUPPORT if (CLIENT_STATUS_TEST_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RDG_CAPABLE)) { AsicEnableRDG(pAd); } -#endif // DOT11_N_SUPPORT // + OPSTATUS_SET_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET); CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET); } @@ -1753,9 +1631,7 @@ VOID LinkUp( } } -#ifdef DOT11_N_SUPPORT 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)); -#endif // DOT11_N_SUPPORT // // Set LED RTMPSetLED(pAd, LED_LINK_UP); @@ -1780,13 +1656,13 @@ VOID LinkUp( if (pAd->StaCfg.bAutoTxRateSwitch == FALSE) { pEntry->bAutoTxRateSwitch = FALSE; -#ifdef DOT11_N_SUPPORT + if (pEntry->HTPhyMode.field.MCS == 32) pEntry->HTPhyMode.field.ShortGI = GI_800; if ((pEntry->HTPhyMode.field.MCS > MCS_7) || (pEntry->HTPhyMode.field.MCS == 32)) pEntry->HTPhyMode.field.STBC = STBC_NONE; -#endif // DOT11_N_SUPPORT // + // If the legacy mode is set, overwrite the transmit setting of this entry. if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM) RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry); @@ -1815,7 +1691,6 @@ VOID LinkUp( RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value); } -#ifdef DOT11_N_SUPPORT if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) { } @@ -1825,7 +1700,6 @@ VOID LinkUp( // Because our Init value is 1 at MACRegTable. RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x0fff); } -#endif // DOT11_N_SUPPORT // // Patch for Marvel AP to gain high throughput // Need to set as following, @@ -1837,9 +1711,15 @@ VOID LinkUp( // Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable // // if 1. Legacy AP WMM on, or 2. 11n AP, AMPDU disable. Force turn off burst no matter what bEnableTxBurst is. -#ifdef DOT11_N_SUPPORT +#ifdef RT30xx + if (!((pAd->CommonCfg.RxStream == 1)&&(pAd->CommonCfg.TxStream == 1)) && + (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)) + || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE)))) +#endif +#ifndef RT30xx if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))) || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE))) +#endif { RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data); Data &= 0xFFFFFF00; @@ -1849,7 +1729,6 @@ VOID LinkUp( DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n")); } else -#endif // DOT11_N_SUPPORT // if (pAd->CommonCfg.bEnableTxBurst) { RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data); @@ -1871,7 +1750,6 @@ VOID LinkUp( DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n")); } -#ifdef DOT11_N_SUPPORT // Re-check to turn on TX burst or not. if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE) && ((STA_WEP_ON(pAd))||(STA_TKIP_ON(pAd)))) { @@ -1891,7 +1769,6 @@ VOID LinkUp( { pAd->CommonCfg.IOTestParm.bNextDisableRxBA = FALSE; } -#endif // DOT11_N_SUPPORT // pAd->CommonCfg.IOTestParm.bLastAtheros = FALSE; COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid); @@ -1924,17 +1801,9 @@ VOID LinkUp( } RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); +#ifdef RT2860 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW); - -#ifdef DOT11_N_SUPPORT -#ifdef DOT11N_DRAFT3 - if ((pAd->CommonCfg.BACapability.field.b2040CoexistScanSup) && (pAd->CommonCfg.Channel <= 11)) - { - OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SCAN_2040); - BuildEffectedChannelList(pAd); - } -#endif // DOT11N_DRAFT3 // -#endif // DOT11_N_SUPPORT // +#endif } /* @@ -1967,23 +1836,21 @@ VOID LinkDown( IN BOOLEAN IsReqFromAP) { UCHAR i, ByteValue = 0; +#ifdef RT2860 BOOLEAN Cancelled; +#endif // Do nothing if monitor mode is on if (MONITOR_ON(pAd)) return; -#ifdef RALINK_ATE - // Nothing to do in ATE mode. - if (ATE_ON(pAd)) - return; -#endif // RALINK_ATE // - +#ifdef RT2860 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW); RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled); // Not allow go to sleep within linkdown function. RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); +#endif if (pAd->CommonCfg.bWirelessEvent) { @@ -1993,6 +1860,7 @@ VOID LinkDown( DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n")); OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED); +#ifdef RT2860 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) { BOOLEAN Cancelled; @@ -2009,6 +1877,7 @@ VOID LinkDown( } pAd->bPCIclkOff = FALSE; +#endif if (ADHOC_ON(pAd)) // Adhoc mode link down { DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 1!!!\n")); @@ -2025,33 +1894,6 @@ VOID LinkDown( { DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 2!!!\n")); -#ifdef QOS_DLS_SUPPORT - // DLS tear down frame must be sent before link down - // send DLS-TEAR_DOWN message - if (pAd->CommonCfg.bDLSCapable) - { - // tear down local dls table entry - for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) - { - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } - - // tear down peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) - { - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } - } -#endif // QOS_DLS_SUPPORT // - OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON); OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); @@ -2095,17 +1937,6 @@ VOID LinkDown( NdisMoveMemory(pAd->StaCfg.CCXAdjacentAPSsid, pAd->CommonCfg.Ssid, pAd->StaCfg.CCXAdjacentAPSsidLen); COPY_MAC_ADDR(pAd->StaCfg.CCXAdjacentAPBssid, pAd->CommonCfg.Bssid); } - -#ifdef EXT_BUILD_CHANNEL_LIST - // Country IE of the AP will be evaluated and will be used. - if (pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None) - { - NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pAd->StaCfg.StaOriCountryCode[0], 2); - pAd->CommonCfg.Geography = pAd->StaCfg.StaOriGeography; - BuildChannelListEx(pAd); - } -#endif // EXT_BUILD_CHANNEL_LIST // - } for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++) @@ -2137,12 +1968,11 @@ VOID LinkDown( NdisZeroMemory(pAd->CommonCfg.Ssid, MAX_LEN_OF_SSID); pAd->CommonCfg.SsidLen = 0; } -#ifdef DOT11_N_SUPPORT + NdisZeroMemory(&pAd->MlmeAux.HtCapability, sizeof(HT_CAPABILITY_IE)); NdisZeroMemory(&pAd->MlmeAux.AddHtInfo, sizeof(ADD_HT_INFO_IE)); pAd->MlmeAux.HtCapabilityLen = 0; pAd->MlmeAux.NewExtChannelOffset = 0xff; -#endif // DOT11_N_SUPPORT // // Reset WPA-PSK state. Only reset when supplicant enabled if (pAd->StaCfg.WpaState != SS_NOTUSE) @@ -2150,11 +1980,6 @@ VOID LinkDown( pAd->StaCfg.WpaState = SS_START; // Clear Replay counter NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8); - -#ifdef QOS_DLS_SUPPORT - if (pAd->CommonCfg.bDLSCapable) - NdisZeroMemory(pAd->StaCfg.DlsReplayCounter, 8); -#endif // QOS_DLS_SUPPORT // } @@ -2169,7 +1994,7 @@ VOID LinkDown( } // 802.1x port control -#ifdef WPA_SUPPLICANT_SUPPORT + // Prevent clear PortSecured here with static WEP // NetworkManger set security policy first then set SSID to connect AP. if (pAd->StaCfg.WpaSupplicantUP && @@ -2179,7 +2004,6 @@ VOID LinkDown( pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; } else -#endif // WPA_SUPPLICANT_SUPPORT // { pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP; @@ -2199,13 +2023,18 @@ VOID LinkDown( // Update extra information to link is up pAd->ExtraInfo = GENERAL_LINK_DOWN; +#ifdef RT2860 pAd->StaCfg.AdhocBOnlyJoined = FALSE; pAd->StaCfg.AdhocBGJoined = FALSE; pAd->StaCfg.Adhoc20NJoined = FALSE; +#endif pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE; // Reset the Current AP's IP address NdisZeroMemory(pAd->StaCfg.AironetIPAddress, 4); +#ifdef RT2870 + pAd->bUsbTxBulkAggre = FALSE; +#endif // RT2870 // // Clean association information NdisZeroMemory(&pAd->StaCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION)); @@ -2227,7 +2056,6 @@ VOID LinkDown( pAd->CommonCfg.MlmeRate = pAd->CommonCfg.BasicMlmeRate; pAd->CommonCfg.RtsRate = pAd->CommonCfg.BasicMlmeRate; -#ifdef DOT11_N_SUPPORT // // After Link down, reset piggy-back setting in ASIC. Disable RDG. // @@ -2238,7 +2066,7 @@ VOID LinkDown( ByteValue &= (~0x18); RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, ByteValue); } -#endif // DOT11_N_SUPPORT // + // Reset DAC RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &ByteValue); ByteValue &= (~0x18); @@ -2251,9 +2079,7 @@ VOID LinkDown( RTMPSetPiggyBack(pAd,FALSE); OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED); -#ifdef DOT11_N_SUPPORT pAd->CommonCfg.BACapability.word = pAd->CommonCfg.REGBACapability.word; -#endif // DOT11_N_SUPPORT // // Restore all settings in the following. AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT|CCKSETPROTECT|OFDMSETPROTECT), TRUE, FALSE); @@ -2261,43 +2087,35 @@ VOID LinkDown( pAd->CommonCfg.IOTestParm.bCurrentAtheros = FALSE; pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE; -#ifdef DOT11_N_SUPPORT -#ifdef DOT11N_DRAFT3 - OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SCAN_2040); - pAd->CommonCfg.BSSCoexist2040.word = 0; - TriEventInit(pAd); - for (i = 0; i < (pAd->ChannelListNum - 1); i++) - { - pAd->ChannelList[i].bEffectedChannel = FALSE; - } -#endif // DOT11N_DRAFT3 // -#endif // DOT11_N_SUPPORT // - RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); +#ifdef RT2860 // Allow go to sleep after linkdown steps. RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); +#endif -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - if (pAd->StaCfg.WpaSupplicantUP) { - union iwreq_data wrqu; - //send disassociate event to wpa_supplicant - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_DISASSOC_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT { union iwreq_data wrqu; memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN); wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // + +#ifdef RT30xx + if (IS_RT3090(pAd)) + { + UINT32 macdata; + // disable MMPS BBP control register + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &ByteValue); + ByteValue &= ~(0x04); //bit 2 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, ByteValue); + + // disable MMPS MAC control register + RTMP_IO_READ32(pAd, 0x1210, &macdata); + macdata &= ~(0x09); //bit 0, 3 + RTMP_IO_WRITE32(pAd, 0x1210, macdata); + } +#endif // RT30xx // } /* @@ -2457,26 +2275,6 @@ VOID ScanParmFill( ScanReq->ScanType = ScanType; } -#ifdef QOS_DLS_SUPPORT -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== -*/ -VOID DlsParmFill( - IN PRTMP_ADAPTER pAd, - IN OUT MLME_DLS_REQ_STRUCT *pDlsReq, - IN PRT_802_11_DLS pDls, - IN USHORT reason) -{ - pDlsReq->pDLS = pDls; - pDlsReq->Reason = reason; -} -#endif // QOS_DLS_SUPPORT // - /* ========================================================================== Description: @@ -2523,21 +2321,61 @@ VOID AuthParmFill( ========================================================================== */ + + +#ifdef RT2870 + +VOID MlmeCntlConfirm( + IN PRTMP_ADAPTER pAd, + IN ULONG MsgType, + IN USHORT Msg) +{ + MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(USHORT), &Msg); +} +#endif + VOID ComposePsPoll( IN PRTMP_ADAPTER pAd) { +#ifdef RT2870 + PTXINFO_STRUC pTxInfo; + PTXWI_STRUC pTxWI; + + DBGPRINT(RT_DEBUG_TRACE, ("ComposePsPoll\n")); +#endif NdisZeroMemory(&pAd->PsPollFrame, sizeof(PSPOLL_FRAME)); + +#ifdef RT2870 + pAd->PsPollFrame.FC.PwrMgmt = 0; +#endif pAd->PsPollFrame.FC.Type = BTYPE_CNTL; pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL; pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000; COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid); COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress); + +#ifdef RT2870 + RTMPZeroMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0], 100); + pTxInfo = (PTXINFO_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0]; + RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(PSPOLL_FRAME)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE); + pTxWI = (PTXWI_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE]; + RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(PSPOLL_FRAME)), + 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit); + RTMPMoveMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->PsPollFrame, sizeof(PSPOLL_FRAME)); + // Append 4 extra zero bytes. + pAd->PsPollContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(PSPOLL_FRAME) + 4; +#endif } // IRQL = DISPATCH_LEVEL VOID ComposeNullFrame( IN PRTMP_ADAPTER pAd) { +#ifdef RT2870 + PTXINFO_STRUC pTxInfo; + PTXWI_STRUC pTxWI; +#endif + NdisZeroMemory(&pAd->NullFrame, sizeof(HEADER_802_11)); pAd->NullFrame.FC.Type = BTYPE_DATA; pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC; @@ -2545,6 +2383,16 @@ VOID ComposeNullFrame( COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid); COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress); COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid); +#ifdef RT2870 + RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[0], 100); + pTxInfo = (PTXINFO_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[0]; + RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(HEADER_802_11)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE); + pTxWI = (PTXWI_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE]; + RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(HEADER_802_11)), + 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit); + RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11)); + pAd->NullContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4; +#endif } @@ -2688,22 +2536,15 @@ ULONG MakeIbssBeacon( FrameLen += tmp; } -#ifdef DOT11_N_SUPPORT if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { ULONG TmpLen; UCHAR HtLen, HtLen1; -#ifdef RT_BIG_ENDIAN - HT_CAPABILITY_IE HtCapabilityTmp; - ADD_HT_INFO_IE addHTInfoTmp; - USHORT b2lTmp, b2lTmp2; -#endif - // add HT Capability IE HtLen = sizeof(pAd->CommonCfg.HtCapability); HtLen1 = sizeof(pAd->CommonCfg.AddHTInfo); -#ifndef RT_BIG_ENDIAN + MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen, 1, &HtCapIe, 1, &HtLen, @@ -2712,27 +2553,9 @@ ULONG MakeIbssBeacon( 1, &HtLen1, HtLen1, &pAd->CommonCfg.AddHTInfo, END_OF_ARGS); -#else - NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen); - *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo)); - *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo)); - - NdisMoveMemory(&addHTInfoTmp, &pAd->CommonCfg.AddHTInfo, HtLen1); - *(USHORT *)(&addHTInfoTmp.AddHtInfo2) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo2)); - *(USHORT *)(&addHTInfoTmp.AddHtInfo3) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo3)); - MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen, - 1, &HtCapIe, - 1, &HtLen, - HtLen, &HtCapabilityTmp, - 1, &AddHtInfoIe, - 1, &HtLen1, - HtLen1, &addHTInfoTmp, - END_OF_ARGS); -#endif FrameLen += TmpLen; } -#endif // DOT11_N_SUPPORT // //beacon use reserved WCID 0xff if (pAd->CommonCfg.Channel > 14) @@ -2749,11 +2572,6 @@ ULONG MakeIbssBeacon( PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &Transmit); } -#ifdef RT_BIG_ENDIAN - RTMPFrameEndianChange(pAd, pBeaconFrame, DIR_WRITE, FALSE); - RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI); -#endif - DBGPRINT(RT_DEBUG_TRACE, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n", FrameLen, SupRateLen, ExtRateLen, pAd->CommonCfg.Channel, pAd->CommonCfg.PhyMode)); return FrameLen; diff --git a/drivers/staging/rt2860/sta/dls.c b/drivers/staging/rt2860/sta/dls.c deleted file mode 100644 index 873cf7f1de9..00000000000 --- a/drivers/staging/rt2860/sta/dls.c +++ /dev/null @@ -1,2197 +0,0 @@ -/* - ************************************************************************* - * Ralink Tech Inc. - * 5F., No.36, Taiyuan St., Jhubei City, - * Hsinchu County 302, - * Taiwan, R.O.C. - * - * (c) Copyright 2002-2007, Ralink Technology, Inc. - * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * * - ************************************************************************* - - Module Name: - dls.c - - Abstract: - Handle WMM-DLS state machine - - Revision History: - Who When What - -------- ---------- ---------------------------------------------- - Rory Chen 02-14-2006 - Arvin Tai 06-03-2008 Modified for RT28xx - */ - -#include "../rt_config.h" - -/* - ========================================================================== - Description: - dls state machine init, including state transition and timer init - Parameters: - Sm - pointer to the dls state machine - Note: - The state machine looks like this - - DLS_IDLE - MT2_MLME_DLS_REQUEST MlmeDlsReqAction - MT2_PEER_DLS_REQUEST PeerDlsReqAction - MT2_PEER_DLS_RESPONSE PeerDlsRspAction - MT2_MLME_DLS_TEARDOWN MlmeTearDownAction - MT2_PEER_DLS_TEARDOWN PeerTearDownAction - - IRQL = PASSIVE_LEVEL - - ========================================================================== - */ -void DlsStateMachineInit( - IN PRTMP_ADAPTER pAd, - IN STATE_MACHINE *Sm, - OUT STATE_MACHINE_FUNC Trans[]) -{ - UCHAR i; - - StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_DLS_STATE, MAX_DLS_MSG, (STATE_MACHINE_FUNC)Drop, DLS_IDLE, DLS_MACHINE_BASE); - - // the first column - StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_REQ, (STATE_MACHINE_FUNC)MlmeDlsReqAction); - StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_REQ, (STATE_MACHINE_FUNC)PeerDlsReqAction); - StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_RSP, (STATE_MACHINE_FUNC)PeerDlsRspAction); - StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)MlmeDlsTearDownAction); - StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)PeerDlsTearDownAction); - - for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - pAd->StaCfg.DLSEntry[i].pAd = pAd; - RTMPInitTimer(pAd, &pAd->StaCfg.DLSEntry[i].Timer, GET_TIMER_FUNCTION(DlsTimeoutAction), pAd, FALSE); - } -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -VOID MlmeDlsReqAction( - IN PRTMP_ADAPTER pAd, - IN MLME_QUEUE_ELEM *Elem) -{ - PUCHAR pOutBuffer = NULL; - NDIS_STATUS NStatus; - ULONG FrameLen = 0; - HEADER_802_11 DlsReqHdr; - PRT_802_11_DLS pDLS = NULL; - UCHAR Category = CATEGORY_DLS; - UCHAR Action = ACTION_DLS_REQUEST; - ULONG tmp; - USHORT reason; - ULONG Timeout; - BOOLEAN TimerCancelled; - - if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &reason)) - return; - - DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsReqAction() \n")); - - NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory - if (NStatus != NDIS_STATUS_SUCCESS) - { - DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsReqAction() allocate memory failed \n")); - return; - } - - ActHeaderInit(pAd, &DlsReqHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid); - - // Build basic frame first - MakeOutgoingFrame(pOutBuffer, &FrameLen, - sizeof(HEADER_802_11), &DlsReqHdr, - 1, &Category, - 1, &Action, - 6, &pDLS->MacAddr, - 6, pAd->CurrentAddress, - 2, &pAd->StaActive.CapabilityInfo, - 2, &pDLS->TimeOut, - 1, &SupRateIe, - 1, &pAd->MlmeAux.SupRateLen, - pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate, - END_OF_ARGS); - - if (pAd->MlmeAux.ExtRateLen != 0) - { - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &ExtRateIe, - 1, &pAd->MlmeAux.ExtRateLen, - pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate, - END_OF_ARGS); - FrameLen += tmp; - } - -#ifdef DOT11_N_SUPPORT - if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) - { - UCHAR HtLen; - -#ifdef RT_BIG_ENDIAN - HT_CAPABILITY_IE HtCapabilityTmp; -#endif - - // add HT Capability IE - HtLen = sizeof(HT_CAPABILITY_IE); -#ifndef RT_BIG_ENDIAN - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &HtCapIe, - 1, &HtLen, - HtLen, &pAd->CommonCfg.HtCapability, - END_OF_ARGS); -#else - NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen); - *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo)); - *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo)); - - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &HtCapIe, - 1, &HtLen, - HtLen, &HtCapabilityTmp, - END_OF_ARGS); -#endif - FrameLen = FrameLen + tmp; - } -#endif // DOT11_N_SUPPORT // - - RTMPCancelTimer(&pDLS->Timer, &TimerCancelled); - Timeout = DLS_TIMEOUT; - RTMPSetTimer(&pDLS->Timer, Timeout); - - MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen); - MlmeFreeMemory(pAd, pOutBuffer); -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -VOID PeerDlsReqAction( - IN PRTMP_ADAPTER pAd, - IN MLME_QUEUE_ELEM *Elem) -{ - PUCHAR pOutBuffer = NULL; - NDIS_STATUS NStatus; - ULONG FrameLen = 0; - USHORT StatusCode = MLME_SUCCESS; - HEADER_802_11 DlsRspHdr; - UCHAR Category = CATEGORY_DLS; - UCHAR Action = ACTION_DLS_RESPONSE; - ULONG tmp; - USHORT CapabilityInfo; - UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN]; - USHORT DLSTimeOut; - SHORT i; - ULONG Timeout; - BOOLEAN TimerCancelled; - PRT_802_11_DLS pDLS = NULL; - UCHAR MaxSupportedRateIn500Kbps = 0; - UCHAR SupportedRatesLen; - UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES]; - UCHAR HtCapabilityLen; - HT_CAPABILITY_IE HtCapability; - - if (!PeerDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &DLSTimeOut, - &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability)) - return; - - // supported rates array may not be sorted. sort it and find the maximum rate - for (i = 0; i < SupportedRatesLen; i++) - { - if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f)) - MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f; - } - - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() from %02x:%02x:%02x:%02x:%02x:%02x\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5])); - - NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory - if (NStatus != NDIS_STATUS_SUCCESS) - { - DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() allocate memory failed \n")); - return; - } - - if (!INFRA_ON(pAd)) - { - StatusCode = MLME_REQUEST_DECLINED; - } - else if (!pAd->CommonCfg.bWmmCapable) - { - StatusCode = MLME_DEST_STA_IS_NOT_A_QSTA; - } - else if (!pAd->CommonCfg.bDLSCapable) - { - StatusCode = MLME_REQUEST_DECLINED; - } - else - { - // find table to update parameters - for (i = (MAX_NUM_OF_DLS_ENTRY-1); i >= 0; i--) - { - if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) - pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY; - else - { - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH; - } - - pAd->StaCfg.DLSEntry[i].Sequence = 0; - pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut; - pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut; - if (HtCapabilityLen != 0) - pAd->StaCfg.DLSEntry[i].bHTCap = TRUE; - else - pAd->StaCfg.DLSEntry[i].bHTCap = FALSE; - pDLS = &pAd->StaCfg.DLSEntry[i]; - break; - } - } - - // can not find in table, create a new one - if (i < 0) - { - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() can not find same entry \n")); - for (i=(MAX_NUM_OF_DLS_ENTRY - 1); i >= MAX_NUM_OF_INIT_DLS_ENTRY; i--) - { - if (!pAd->StaCfg.DLSEntry[i].Valid) - { - MAC_TABLE_ENTRY *pEntry; - UCHAR MaxSupportedRate = RATE_11; - - if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) - { - pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY; - } - else - { - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH; - } - - pAd->StaCfg.DLSEntry[i].Sequence = 0; - pAd->StaCfg.DLSEntry[i].Valid = TRUE; - pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut; - pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut; - NdisMoveMemory(pAd->StaCfg.DLSEntry[i].MacAddr, SA, MAC_ADDR_LEN); - if (HtCapabilityLen != 0) - pAd->StaCfg.DLSEntry[i].bHTCap = TRUE; - else - pAd->StaCfg.DLSEntry[i].bHTCap = FALSE; - pDLS = &pAd->StaCfg.DLSEntry[i]; - pEntry = MacTableInsertDlsEntry(pAd, SA, i); - - switch (MaxSupportedRateIn500Kbps) - { - case 108: MaxSupportedRate = RATE_54; break; - case 96: MaxSupportedRate = RATE_48; break; - case 72: MaxSupportedRate = RATE_36; break; - case 48: MaxSupportedRate = RATE_24; break; - case 36: MaxSupportedRate = RATE_18; break; - case 24: MaxSupportedRate = RATE_12; break; - case 18: MaxSupportedRate = RATE_9; break; - case 12: MaxSupportedRate = RATE_6; break; - case 22: MaxSupportedRate = RATE_11; break; - case 11: MaxSupportedRate = RATE_5_5; break; - case 4: MaxSupportedRate = RATE_2; break; - case 2: MaxSupportedRate = RATE_1; break; - default: MaxSupportedRate = RATE_11; break; - } - - pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate); - - if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) - { - pEntry->MaxHTPhyMode.field.MODE = MODE_CCK; - pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate; - pEntry->MinHTPhyMode.field.MODE = MODE_CCK; - pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate; - pEntry->HTPhyMode.field.MODE = MODE_CCK; - pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate; - } - else - { - pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM; - pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - pEntry->MinHTPhyMode.field.MODE = MODE_OFDM; - pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - pEntry->HTPhyMode.field.MODE = MODE_OFDM; - pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - } - - pEntry->MaxHTPhyMode.field.BW = BW_20; - pEntry->MinHTPhyMode.field.BW = BW_20; - -#ifdef DOT11_N_SUPPORT - pEntry->HTCapability.MCSSet[0] = 0; - pEntry->HTCapability.MCSSet[1] = 0; - - // If this Entry supports 802.11n, upgrade to HT rate. - if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) - { - UCHAR j, bitmask; //k,bitmask; - CHAR ii; - - DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsReqAction() Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n", - SA[0], SA[1], SA[2], SA[3], SA[4], SA[5])); - - if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF)) - { - pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD; - } - else - { - pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; - pAd->MacTab.fAnyStationNonGF = TRUE; - pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1; - } - - if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth)) - { - pEntry->MaxHTPhyMode.field.BW= BW_40; - pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40)); - } - else - { - pEntry->MaxHTPhyMode.field.BW = BW_20; - pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20)); - pAd->MacTab.fAnyStation20Only = TRUE; - } - - // find max fixed rate - for (ii=15; ii>=0; ii--) - { - j = ii/8; - bitmask = (1<<(ii-(j*8))); - if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask)) - { - pEntry->MaxHTPhyMode.field.MCS = ii; - break; - } - if (ii==0) - break; - } - - - if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) - { - - printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n", - pAd->StaCfg.DesiredTransmitSetting.field.MCS); - if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) - { - // Fix MCS as HT Duplicated Mode - pEntry->MaxHTPhyMode.field.BW = 1; - pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; - pEntry->MaxHTPhyMode.field.STBC = 0; - pEntry->MaxHTPhyMode.field.ShortGI = 0; - pEntry->MaxHTPhyMode.field.MCS = 32; - } - else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS) - { - // STA supports fixed MCS - pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; - } - } - - pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC)); - pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity; - pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor; - pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs; - pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize; - pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; - - if (HtCapability.HtCapInfo.ShortGIfor20) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE); - if (HtCapability.HtCapInfo.ShortGIfor40) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE); - if (HtCapability.HtCapInfo.TxSTBC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE); - if (HtCapability.HtCapInfo.RxSTBC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE); - if (HtCapability.ExtHtCapInfo.PlusHTC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE); - if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE); - if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE); - - NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE)); - } -#endif // DOT11_N_SUPPORT // - - pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; - pEntry->CurrTxRate = pEntry->MaxSupportedRate; - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE); - - if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) - { - PUCHAR pTable; - UCHAR TableSize = 0; - - MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex); - pEntry->bAutoTxRateSwitch = TRUE; - } - else - { - pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE; - pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; - pEntry->bAutoTxRateSwitch = FALSE; - - RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry); - } - pEntry->RateLen = SupportedRatesLen; - - break; - } - } - } - StatusCode = MLME_SUCCESS; - - // can not find in table, create a new one - if (i < 0) - { - StatusCode = MLME_QOS_UNSPECIFY; - DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() DLSEntry table full(only can support %d DLS session) \n", MAX_NUM_OF_DLS_ENTRY - MAX_NUM_OF_INIT_DLS_ENTRY)); - } - else - { - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() use entry(%d) %02x:%02x:%02x:%02x:%02x:%02x\n", - i, SA[0], SA[1], SA[2], SA[3], SA[4], SA[5])); - } - } - - ActHeaderInit(pAd, &DlsRspHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid); - - // Build basic frame first - if (StatusCode == MLME_SUCCESS) - { - MakeOutgoingFrame(pOutBuffer, &FrameLen, - sizeof(HEADER_802_11), &DlsRspHdr, - 1, &Category, - 1, &Action, - 2, &StatusCode, - 6, SA, - 6, pAd->CurrentAddress, - 2, &pAd->StaActive.CapabilityInfo, - 1, &SupRateIe, - 1, &pAd->MlmeAux.SupRateLen, - pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate, - END_OF_ARGS); - - if (pAd->MlmeAux.ExtRateLen != 0) - { - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &ExtRateIe, - 1, &pAd->MlmeAux.ExtRateLen, - pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate, - END_OF_ARGS); - FrameLen += tmp; - } - -#ifdef DOT11_N_SUPPORT - if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) - { - UCHAR HtLen; - -#ifdef RT_BIG_ENDIAN - HT_CAPABILITY_IE HtCapabilityTmp; -#endif - - // add HT Capability IE - HtLen = sizeof(HT_CAPABILITY_IE); -#ifndef RT_BIG_ENDIAN - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &HtCapIe, - 1, &HtLen, - HtLen, &pAd->CommonCfg.HtCapability, - END_OF_ARGS); -#else - NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen); - *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo)); - *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo)); - - MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, - 1, &HtCapIe, - 1, &HtLen, - HtLen, &HtCapabilityTmp, - END_OF_ARGS); -#endif - FrameLen = FrameLen + tmp; - } -#endif // DOT11_N_SUPPORT // - - if (pDLS && (pDLS->Status != DLS_FINISH)) - { - RTMPCancelTimer(&pDLS->Timer, &TimerCancelled); - Timeout = DLS_TIMEOUT; - RTMPSetTimer(&pDLS->Timer, Timeout); - } - } - else - { - MakeOutgoingFrame(pOutBuffer, &FrameLen, - sizeof(HEADER_802_11), &DlsRspHdr, - 1, &Category, - 1, &Action, - 2, &StatusCode, - 6, SA, - 6, pAd->CurrentAddress, - END_OF_ARGS); - } - - MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen); - MlmeFreeMemory(pAd, pOutBuffer); -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -VOID PeerDlsRspAction( - IN PRTMP_ADAPTER pAd, - IN MLME_QUEUE_ELEM *Elem) -{ - USHORT CapabilityInfo; - UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN]; - USHORT StatusCode; - SHORT i; - BOOLEAN TimerCancelled; - UCHAR MaxSupportedRateIn500Kbps = 0; - UCHAR SupportedRatesLen; - UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES]; - UCHAR HtCapabilityLen; - HT_CAPABILITY_IE HtCapability; - - if (!pAd->CommonCfg.bDLSCapable) - return; - - if (!INFRA_ON(pAd)) - return; - - if (!PeerDlsRspSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &StatusCode, - &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability)) - return; - - // supported rates array may not be sorted. sort it and find the maximum rate - for (i=0; i<SupportedRatesLen; i++) - { - if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f)) - MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f; - } - - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x with StatusCode=%d, CapabilityInfo=0x%x\n", - SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], StatusCode, CapabilityInfo)); - - for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - if (StatusCode == MLME_SUCCESS) - { - MAC_TABLE_ENTRY *pEntry; - UCHAR MaxSupportedRate = RATE_11; - - pEntry = MacTableInsertDlsEntry(pAd, SA, i); - - switch (MaxSupportedRateIn500Kbps) - { - case 108: MaxSupportedRate = RATE_54; break; - case 96: MaxSupportedRate = RATE_48; break; - case 72: MaxSupportedRate = RATE_36; break; - case 48: MaxSupportedRate = RATE_24; break; - case 36: MaxSupportedRate = RATE_18; break; - case 24: MaxSupportedRate = RATE_12; break; - case 18: MaxSupportedRate = RATE_9; break; - case 12: MaxSupportedRate = RATE_6; break; - case 22: MaxSupportedRate = RATE_11; break; - case 11: MaxSupportedRate = RATE_5_5; break; - case 4: MaxSupportedRate = RATE_2; break; - case 2: MaxSupportedRate = RATE_1; break; - default: MaxSupportedRate = RATE_11; break; - } - - pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate); - - if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) - { - pEntry->MaxHTPhyMode.field.MODE = MODE_CCK; - pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate; - pEntry->MinHTPhyMode.field.MODE = MODE_CCK; - pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate; - pEntry->HTPhyMode.field.MODE = MODE_CCK; - pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate; - } - else - { - pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM; - pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - pEntry->MinHTPhyMode.field.MODE = MODE_OFDM; - pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - pEntry->HTPhyMode.field.MODE = MODE_OFDM; - pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - } - - pEntry->MaxHTPhyMode.field.BW = BW_20; - pEntry->MinHTPhyMode.field.BW = BW_20; - -#ifdef DOT11_N_SUPPORT - pEntry->HTCapability.MCSSet[0] = 0; - pEntry->HTCapability.MCSSet[1] = 0; - - // If this Entry supports 802.11n, upgrade to HT rate. - if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) - { - UCHAR j, bitmask; //k,bitmask; - CHAR ii; - - DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsRspAction Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n", - SA[0], SA[1], SA[2], SA[3], SA[4], SA[5])); - - if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF)) - { - pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD; - } - else - { - pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; - pAd->MacTab.fAnyStationNonGF = TRUE; - pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1; - } - - if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth)) - { - pEntry->MaxHTPhyMode.field.BW= BW_40; - pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40)); - } - else - { - pEntry->MaxHTPhyMode.field.BW = BW_20; - pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20)); - pAd->MacTab.fAnyStation20Only = TRUE; - } - - // find max fixed rate - for (ii=15; ii>=0; ii--) - { - j = ii/8; - bitmask = (1<<(ii-(j*8))); - if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask)) - { - pEntry->MaxHTPhyMode.field.MCS = ii; - break; - } - if (ii==0) - break; - } - - if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) - { - if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) - { - // Fix MCS as HT Duplicated Mode - pEntry->MaxHTPhyMode.field.BW = 1; - pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; - pEntry->MaxHTPhyMode.field.STBC = 0; - pEntry->MaxHTPhyMode.field.ShortGI = 0; - pEntry->MaxHTPhyMode.field.MCS = 32; - } - else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS) - { - // STA supports fixed MCS - pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; - } - } - - pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC)); - pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity; - pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor; - pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs; - pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize; - pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; - - if (HtCapability.HtCapInfo.ShortGIfor20) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE); - if (HtCapability.HtCapInfo.ShortGIfor40) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE); - if (HtCapability.HtCapInfo.TxSTBC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE); - if (HtCapability.HtCapInfo.RxSTBC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE); - if (HtCapability.ExtHtCapInfo.PlusHTC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE); - if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE); - if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE); - - NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE)); - } -#endif // DOT11_N_SUPPORT // - pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; - pEntry->CurrTxRate = pEntry->MaxSupportedRate; - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE); - - if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) - { - PUCHAR pTable; - UCHAR TableSize = 0; - - MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex); - pEntry->bAutoTxRateSwitch = TRUE; - } - else - { - pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE; - pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; - pEntry->bAutoTxRateSwitch = FALSE; - - RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry); - } - pEntry->RateLen = SupportedRatesLen; - - if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) - { - // If support WPA or WPA2, start STAKey hand shake, - // If failed hand shake, just tear down peer DLS - if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS) - { - MLME_DLS_REQ_STRUCT MlmeDlsReq; - USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT; - - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n")); - } - else - { - pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY; - DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n")); - } - } - else - { - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH; - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5])); - } - - //initialize seq no for DLS frames. - pAd->StaCfg.DLSEntry[i].Sequence = 0; - if (HtCapabilityLen != 0) - pAd->StaCfg.DLSEntry[i].bHTCap = TRUE; - else - pAd->StaCfg.DLSEntry[i].bHTCap = FALSE; - } - else - { - // DLS setup procedure failed. - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode)); - } - } - } - - if (i >= MAX_NUM_OF_INIT_DLS_ENTRY) - { - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() update timeout value \n")); - for (i=(MAX_NUM_OF_DLS_ENTRY-1); i>=MAX_NUM_OF_INIT_DLS_ENTRY; i--) - { - if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - if (StatusCode == MLME_SUCCESS) - { - MAC_TABLE_ENTRY *pEntry; - UCHAR MaxSupportedRate = RATE_11; - - pEntry = MacTableInsertDlsEntry(pAd, SA, i); - - switch (MaxSupportedRateIn500Kbps) - { - case 108: MaxSupportedRate = RATE_54; break; - case 96: MaxSupportedRate = RATE_48; break; - case 72: MaxSupportedRate = RATE_36; break; - case 48: MaxSupportedRate = RATE_24; break; - case 36: MaxSupportedRate = RATE_18; break; - case 24: MaxSupportedRate = RATE_12; break; - case 18: MaxSupportedRate = RATE_9; break; - case 12: MaxSupportedRate = RATE_6; break; - case 22: MaxSupportedRate = RATE_11; break; - case 11: MaxSupportedRate = RATE_5_5; break; - case 4: MaxSupportedRate = RATE_2; break; - case 2: MaxSupportedRate = RATE_1; break; - default: MaxSupportedRate = RATE_11; break; - } - - pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate); - - if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) - { - pEntry->MaxHTPhyMode.field.MODE = MODE_CCK; - pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate; - pEntry->MinHTPhyMode.field.MODE = MODE_CCK; - pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate; - pEntry->HTPhyMode.field.MODE = MODE_CCK; - pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate; - } - else - { - pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM; - pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - pEntry->MinHTPhyMode.field.MODE = MODE_OFDM; - pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - pEntry->HTPhyMode.field.MODE = MODE_OFDM; - pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; - } - - pEntry->MaxHTPhyMode.field.BW = BW_20; - pEntry->MinHTPhyMode.field.BW = BW_20; - -#ifdef DOT11_N_SUPPORT - pEntry->HTCapability.MCSSet[0] = 0; - pEntry->HTCapability.MCSSet[1] = 0; - - // If this Entry supports 802.11n, upgrade to HT rate. - if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) - { - UCHAR j, bitmask; //k,bitmask; - CHAR ii; - - DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsRspAction Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n", - SA[0], SA[1], SA[2], SA[3], SA[4], SA[5])); - - if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF)) - { - pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD; - } - else - { - pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; - pAd->MacTab.fAnyStationNonGF = TRUE; - pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1; - } - - if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth)) - { - pEntry->MaxHTPhyMode.field.BW= BW_40; - pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40)); - } - else - { - pEntry->MaxHTPhyMode.field.BW = BW_20; - pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20)); - pAd->MacTab.fAnyStation20Only = TRUE; - } - - // find max fixed rate - for (ii=15; ii>=0; ii--) - { - j = ii/8; - bitmask = (1<<(ii-(j*8))); - if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask)) - { - pEntry->MaxHTPhyMode.field.MCS = ii; - break; - } - if (ii==0) - break; - } - - if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) - { - printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n", - pAd->StaCfg.DesiredTransmitSetting.field.MCS); - if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) - { - // Fix MCS as HT Duplicated Mode - pEntry->MaxHTPhyMode.field.BW = 1; - pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; - pEntry->MaxHTPhyMode.field.STBC = 0; - pEntry->MaxHTPhyMode.field.ShortGI = 0; - pEntry->MaxHTPhyMode.field.MCS = 32; - } - else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS) - { - // STA supports fixed MCS - pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; - } - } - - pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC)); - pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity; - pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor; - pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs; - pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize; - pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; - - if (HtCapability.HtCapInfo.ShortGIfor20) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE); - if (HtCapability.HtCapInfo.ShortGIfor40) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE); - if (HtCapability.HtCapInfo.TxSTBC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE); - if (HtCapability.HtCapInfo.RxSTBC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE); - if (HtCapability.ExtHtCapInfo.PlusHTC) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE); - if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE); - if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03) - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE); - - NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE)); - } -#endif // DOT11_N_SUPPORT // - - pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; - pEntry->CurrTxRate = pEntry->MaxSupportedRate; - CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE); - - if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) - { - PUCHAR pTable; - UCHAR TableSize = 0; - - MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex); - pEntry->bAutoTxRateSwitch = TRUE; - } - else - { - pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE; - pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; - pEntry->bAutoTxRateSwitch = FALSE; - - RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry); - } - pEntry->RateLen = SupportedRatesLen; - - if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) - { - // If support WPA or WPA2, start STAKey hand shake, - // If failed hand shake, just tear down peer DLS - if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS) - { - MLME_DLS_REQ_STRUCT MlmeDlsReq; - USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT; - - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n")); - } - else - { - pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY; - DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n")); - } - } - else - { - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH; - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5])); - } - pAd->StaCfg.DLSEntry[i].Sequence = 0; - if (HtCapabilityLen != 0) - pAd->StaCfg.DLSEntry[i].bHTCap = TRUE; - else - pAd->StaCfg.DLSEntry[i].bHTCap = FALSE; - } - else - { - // DLS setup procedure failed. - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode)); - } - } - } - } -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -VOID MlmeDlsTearDownAction( - IN PRTMP_ADAPTER pAd, - IN MLME_QUEUE_ELEM *Elem) -{ - PUCHAR pOutBuffer = NULL; - NDIS_STATUS NStatus; - ULONG FrameLen = 0; - UCHAR Category = CATEGORY_DLS; - UCHAR Action = ACTION_DLS_TEARDOWN; - USHORT ReasonCode = REASON_QOS_UNSPECIFY; - HEADER_802_11 DlsTearDownHdr; - PRT_802_11_DLS pDLS; - BOOLEAN TimerCancelled; - UCHAR i; - - if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &ReasonCode)) - return; - - DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsTearDownAction() with ReasonCode=%d \n", ReasonCode)); - - NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory - if (NStatus != NDIS_STATUS_SUCCESS) - { - DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsTearDownAction() allocate memory failed \n")); - return; - } - - ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid); - - // Build basic frame first - MakeOutgoingFrame(pOutBuffer, &FrameLen, - sizeof(HEADER_802_11), &DlsTearDownHdr, - 1, &Category, - 1, &Action, - 6, &pDLS->MacAddr, - 6, pAd->CurrentAddress, - 2, &ReasonCode, - END_OF_ARGS); - - MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen); - MlmeFreeMemory(pAd, pOutBuffer); - RTMPCancelTimer(&pDLS->Timer, &TimerCancelled); - - // Remove key in local dls table entry - for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } - - // clear peer dls table entry - for (i = MAX_NUM_OF_INIT_DLS_ENTRY; i < MAX_NUM_OF_DLS_ENTRY; i++) - { - if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -VOID PeerDlsTearDownAction( - IN PRTMP_ADAPTER pAd, - IN MLME_QUEUE_ELEM *Elem) -{ - UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN]; - USHORT ReasonCode; - UINT i; - BOOLEAN TimerCancelled; - - if (!pAd->CommonCfg.bDLSCapable) - return; - - if (!INFRA_ON(pAd)) - return; - - if (!PeerDlsTearDownSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &ReasonCode)) - return; - - DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsTearDownAction() from %02x:%02x:%02x:%02x:%02x:%02x with ReasonCode=%d\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], ReasonCode)); - - // clear local dls table entry - for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID); - //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID); - MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } - - // clear peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID); - //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID); - MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -VOID RTMPCheckDLSTimeOut( - IN PRTMP_ADAPTER pAd) -{ - ULONG i; - MLME_DLS_REQ_STRUCT MlmeDlsReq; - USHORT reason = REASON_QOS_UNSPECIFY; - - if (! pAd->CommonCfg.bDLSCapable) - return; - - if (! INFRA_ON(pAd)) - return; - - // If timeout value is equaled to zero, it means always not be timeout. - - // update local dls table entry - for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) - && (pAd->StaCfg.DLSEntry[i].TimeOut != 0)) - { - pAd->StaCfg.DLSEntry[i].CountDownTimer --; - - if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0) - { - reason = REASON_QOS_REQUEST_TIMEOUT; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - } - } - } - - // update peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) - && (pAd->StaCfg.DLSEntry[i].TimeOut != 0)) - { - pAd->StaCfg.DLSEntry[i].CountDownTimer --; - - if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0) - { - reason = REASON_QOS_REQUEST_TIMEOUT; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - } - } - } -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -BOOLEAN RTMPRcvFrameDLSCheck( - IN PRTMP_ADAPTER pAd, - IN PHEADER_802_11 pHeader, - IN ULONG Len, - IN PRT28XX_RXD_STRUC pRxD) -{ - ULONG i; - BOOLEAN bFindEntry = FALSE; - BOOLEAN bSTAKeyFrame = FALSE; - PEAPOL_PACKET pEap; - PUCHAR pProto, pAddr = NULL; - PUCHAR pSTAKey = NULL; - UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY]; - UCHAR Mic[16], OldMic[16]; - UCHAR digest[80]; - UCHAR DlsPTK[80]; - UCHAR temp[64]; - BOOLEAN TimerCancelled; - CIPHER_KEY PairwiseKey; - - - if (! pAd->CommonCfg.bDLSCapable) - return bSTAKeyFrame; - - if (! INFRA_ON(pAd)) - return bSTAKeyFrame; - - if (! (pHeader->FC.SubType & 0x08)) - return bSTAKeyFrame; - - if (Len < LENGTH_802_11 + 6 + 2 + 2) - return bSTAKeyFrame; - - pProto = (PUCHAR)pHeader + LENGTH_802_11 + 2 + 6; // QOS Control field , 0xAA 0xAA 0xAA 0x00 0x00 0x00 - pAddr = pHeader->Addr2; - - // L2PAD bit on will pad 2 bytes at LLC - if (pRxD->L2PAD) - { - pProto += 2; - } - - if (RTMPEqualMemory(EAPOL, pProto, 2) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)) - { - pEap = (PEAPOL_PACKET) (pProto + 2); - - DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff Len=%ld, DataLen=%d, KeyMic=%d, Install=%d, KeyAck=%d, Secure=%d, EKD_DL=%d, Error=%d, Request=%d\n", Len, - (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16), - pEap->KeyDesc.KeyInfo.KeyMic, - pEap->KeyDesc.KeyInfo.Install, - pEap->KeyDesc.KeyInfo.KeyAck, - pEap->KeyDesc.KeyInfo.Secure, - pEap->KeyDesc.KeyInfo.EKD_DL, - pEap->KeyDesc.KeyInfo.Error, - pEap->KeyDesc.KeyInfo.Request)); - - if ((Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16)) && pEap->KeyDesc.KeyInfo.KeyMic - && pEap->KeyDesc.KeyInfo.Install && pEap->KeyDesc.KeyInfo.KeyAck && pEap->KeyDesc.KeyInfo.Secure - && pEap->KeyDesc.KeyInfo.EKD_DL && !pEap->KeyDesc.KeyInfo.Error && !pEap->KeyDesc.KeyInfo.Request) - { - // First validate replay counter, only accept message with larger replay counter - // Let equal pass, some AP start with all zero replay counter - NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY); - if ((RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) && - (RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0)) - return bSTAKeyFrame; - - //RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY); - RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY); - DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter (%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n", - pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2], - pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5], - pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1])); - - // put these code segment to get the replay counter - if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) - return bSTAKeyFrame; - - // Check MIC value - // Save the MIC and replace with zero - // use proprietary PTK - NdisZeroMemory(temp, 64); - NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32); - WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK); - - NdisMoveMemory(OldMic, pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC); - NdisZeroMemory(pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC); - if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) - { - // AES - HMAC_SHA1((PUCHAR) pEap, pEap->Body_Len[1] + 4, DlsPTK, LEN_EAP_MICK, digest); - NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC); - } - else - { - hmac_md5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic); - } - - if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC)) - { - DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in Msg1 of STAKey handshake! \n")); - return bSTAKeyFrame; - } - else - DBGPRINT(RT_DEBUG_TRACE, ("MIC VALID in Msg1 of STAKey handshake! \n")); -#if 1 - if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0C) - && (pEap->KeyDesc.KeyData[4] == 0x43) && (pEap->KeyDesc.KeyData[5] == 0x02)) - { - pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2) - pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6) - - DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%ld, KeyDataLen=%d\n", - pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1])); - - bSTAKeyFrame = TRUE; - } -#else - if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0F) - && (pEap->KeyDesc.KeyData[4] == 0xAC) && (pEap->KeyDesc.KeyData[5] == 0x02)) - { - pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2) - pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6) - - DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%d, KeyDataLen=%d\n", - pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1])); - - bSTAKeyFrame = TRUE; - } -#endif - - } - else if (Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE)) - { -#if 0 - RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY); - -#endif - RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY); - DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter 2(%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n", - pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2], - pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5], - pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1])); - - } - } - - // If timeout value is equaled to zero, it means always not be timeout. - // update local dls table entry - for (i= 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - if (bSTAKeyFrame) - { - PMAC_TABLE_ENTRY pEntry; - - // STAKey frame, add pairwise key table - pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH; - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - - PairwiseKey.KeyLen = LEN_TKIP_EK; - NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK); - NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK); - NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK); - - PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg; - - pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE); - //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast - //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr); - // Add Pair-wise key to Asic - AsicAddPairwiseKeyEntry(pAd, - pAd->StaCfg.DLSEntry[i].MacAddr, - (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, - &PairwiseKey); - - RTMPAddWcidAttributeEntry(pAd, - BSS0, - 0, - PairwiseKey.CipherAlg, - pEntry); - - NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY)); - DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Peer STA MAC Address STAKey) \n")); - - RTMPSendSTAKeyHandShake(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); - - DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Initiator side)\n")); - } - else - { - // Data frame, update timeout value - if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) - { - pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut; - //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr); - } - } - - bFindEntry = TRUE; - } - } - - // update peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - if (bSTAKeyFrame) - { - PMAC_TABLE_ENTRY pEntry = NULL; - - // STAKey frame, add pairwise key table, and send STAkey Msg-2 - pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH; - RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled); - - PairwiseKey.KeyLen = LEN_TKIP_EK; - NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK); - NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK); - NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK); - - PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg; - - pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE); - //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast - //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr); - // Add Pair-wise key to Asic - AsicAddPairwiseKeyEntry(pAd, - pAd->StaCfg.DLSEntry[i].MacAddr, - (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, - &PairwiseKey); - - RTMPAddWcidAttributeEntry(pAd, - BSS0, - 0, - PairwiseKey.CipherAlg, - pEntry); - NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY)); - DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Initiator STA MAC Address STAKey)\n")); - - // If support WPA or WPA2, start STAKey hand shake, - // If failed hand shake, just tear down peer DLS - if (RTMPSendSTAKeyHandShake(pAd, pAddr) != NDIS_STATUS_SUCCESS) - { - MLME_DLS_REQ_STRUCT MlmeDlsReq; - USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT; - - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - } - else - { - DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Peer side)\n")); - } - } - else - { - // Data frame, update timeout value - if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) - { - pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut; - } - } - - bFindEntry = TRUE; - } - } - - - return bSTAKeyFrame; -} - -/* - ======================================================================== - - Routine Description: - Check if the frame can be sent through DLS direct link interface - - Arguments: - pAd Pointer to adapter - - Return Value: - DLS entry index - - Note: - - ======================================================================== -*/ -INT RTMPCheckDLSFrame( - IN PRTMP_ADAPTER pAd, - IN PUCHAR pDA) -{ - INT rval = -1; - INT i; - - if (!pAd->CommonCfg.bDLSCapable) - return rval; - - if (!INFRA_ON(pAd)) - return rval; - - do{ - // check local dls table entry - for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && - MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - rval = i; - break; - } - } - - // check peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && - MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - rval = i; - break; - } - } - } while (FALSE); - - return rval; -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -VOID RTMPSendDLSTearDownFrame( - IN PRTMP_ADAPTER pAd, - IN PUCHAR pDA) -{ - PUCHAR pOutBuffer = NULL; - NDIS_STATUS NStatus; - HEADER_802_11 DlsTearDownHdr; - ULONG FrameLen = 0; - USHORT Reason = REASON_QOS_QSTA_LEAVING_QBSS; - UCHAR Category = CATEGORY_DLS; - UCHAR Action = ACTION_DLS_TEARDOWN; - UCHAR i = 0; - - if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) || - RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) - return; - - DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame \n")); - - NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory - if (NStatus != NDIS_STATUS_SUCCESS) - { - DBGPRINT(RT_DEBUG_ERROR,("ASSOC - RTMPSendDLSTearDownFrame() allocate memory failed \n")); - return; - } - - ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid); - MakeOutgoingFrame(pOutBuffer, &FrameLen, - sizeof(HEADER_802_11), &DlsTearDownHdr, - 1, &Category, - 1, &Action, - 6, pDA, - 6, pAd->CurrentAddress, - 2, &Reason, - END_OF_ARGS); - - MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); - MlmeFreeMemory(pAd, pOutBuffer); - - // Remove key in local dls table entry - for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) - && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } - - // Remove key in peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) - && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr)) - { - MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr); - } - } - - DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame and remove key in (i=%d) \n", i)); -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -NDIS_STATUS RTMPSendSTAKeyRequest( - IN PRTMP_ADAPTER pAd, - IN PUCHAR pDA) -{ - UCHAR Header802_3[14]; - NDIS_STATUS NStatus; - ULONG FrameLen = 0; - EAPOL_PACKET Packet; - UCHAR Mic[16]; - UCHAR digest[80]; - PUCHAR pOutBuffer = NULL; - PNDIS_PACKET pNdisPacket; - UCHAR temp[64]; - UCHAR DlsPTK[80]; - - DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyRequest() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5])); - - pAd->Sequence ++; - MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL); - - // Zero message body - NdisZeroMemory(&Packet, sizeof(Packet)); - Packet.ProVer = EAPOL_VER; - Packet.ProType = EAPOLKey; - Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE andPeer MAC address - - // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE) - if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) - { - Packet.KeyDesc.Type = WPA1_KEY_DESC; - } - else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) - { - Packet.KeyDesc.Type = WPA2_KEY_DESC; - } - - // Key descriptor version - Packet.KeyDesc.KeyInfo.KeyDescVer = - (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP)); - - Packet.KeyDesc.KeyInfo.KeyMic = 1; - Packet.KeyDesc.KeyInfo.Secure = 1; - Packet.KeyDesc.KeyInfo.Request = 1; - - Packet.KeyDesc.KeyDataLen[1] = 12; - - // use our own OUI to distinguish proprietary with standard. - Packet.KeyDesc.KeyData[0] = 0xDD; - Packet.KeyDesc.KeyData[1] = 0x0A; - Packet.KeyDesc.KeyData[2] = 0x00; - Packet.KeyDesc.KeyData[3] = 0x0C; - Packet.KeyDesc.KeyData[4] = 0x43; - Packet.KeyDesc.KeyData[5] = 0x03; - NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN); - - NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY); - - // Allocate buffer for transmitting message - NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); - if (NStatus != NDIS_STATUS_SUCCESS) - return NStatus; - - // Prepare EAPOL frame for MIC calculation - // Be careful, only EAPOL frame is counted for MIC calculation - MakeOutgoingFrame(pOutBuffer, &FrameLen, - Packet.Body_Len[1] + 4, &Packet, - END_OF_ARGS); - - // use proprietary PTK - NdisZeroMemory(temp, 64); - NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32); - WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK); - - // calculate MIC - if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) - { - // AES - NdisZeroMemory(digest, sizeof(digest)); - HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest); - NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC); - } - else - { - NdisZeroMemory(Mic, sizeof(Mic)); - hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic); - NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC); - } - - MakeOutgoingFrame(pOutBuffer, &FrameLen, - sizeof(Header802_3), Header802_3, - Packet.Body_Len[1] + 4, &Packet, - END_OF_ARGS); - - NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen); - if (NStatus == NDIS_STATUS_SUCCESS) - { - RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID); - STASendPacket(pAd, pNdisPacket); - RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } - - MlmeFreeMemory(pAd, pOutBuffer); - - DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyRequest- Send STAKey request (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen)); - - return NStatus; -} - -/* - ========================================================================== - Description: - - IRQL = DISPATCH_LEVEL - - ========================================================================== - */ -NDIS_STATUS RTMPSendSTAKeyHandShake( - IN PRTMP_ADAPTER pAd, - IN PUCHAR pDA) -{ - UCHAR Header802_3[14]; - NDIS_STATUS NStatus; - ULONG FrameLen = 0; - EAPOL_PACKET Packet; - UCHAR Mic[16]; - UCHAR digest[80]; - PUCHAR pOutBuffer = NULL; - PNDIS_PACKET pNdisPacket; - UCHAR temp[64]; - UCHAR DlsPTK[80]; // Due to dirver can not get PTK, use proprietary PTK - - DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyHandShake() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5])); - - pAd->Sequence ++; - MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL); - - // Zero message body - NdisZeroMemory(&Packet, sizeof(Packet)); - Packet.ProVer = EAPOL_VER; - Packet.ProType = EAPOLKey; - Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE and Peer MAC address - - // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE) - if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) - { - Packet.KeyDesc.Type = WPA1_KEY_DESC; - } - else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) - { - Packet.KeyDesc.Type = WPA2_KEY_DESC; - } - - // Key descriptor version - Packet.KeyDesc.KeyInfo.KeyDescVer = - (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP)); - - Packet.KeyDesc.KeyInfo.KeyMic = 1; - Packet.KeyDesc.KeyInfo.Secure = 1; - - Packet.KeyDesc.KeyDataLen[1] = 12; - - // use our own OUI to distinguish proprietary with standard. - Packet.KeyDesc.KeyData[0] = 0xDD; - Packet.KeyDesc.KeyData[1] = 0x0A; - Packet.KeyDesc.KeyData[2] = 0x00; - Packet.KeyDesc.KeyData[3] = 0x0C; - Packet.KeyDesc.KeyData[4] = 0x43; - Packet.KeyDesc.KeyData[5] = 0x03; - NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN); - - NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY); - - // Allocate buffer for transmitting message - NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); - if (NStatus != NDIS_STATUS_SUCCESS) - return NStatus; - - // Prepare EAPOL frame for MIC calculation - // Be careful, only EAPOL frame is counted for MIC calculation - MakeOutgoingFrame(pOutBuffer, &FrameLen, - Packet.Body_Len[1] + 4, &Packet, - END_OF_ARGS); - - // use proprietary PTK - NdisZeroMemory(temp, 64); - NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32); - WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK); - - // calculate MIC - if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) - { - // AES - NdisZeroMemory(digest, sizeof(digest)); - HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest); - NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC); - } - else - { - NdisZeroMemory(Mic, sizeof(Mic)); - hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic); - NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC); - } - - MakeOutgoingFrame(pOutBuffer, &FrameLen, - sizeof(Header802_3), Header802_3, - Packet.Body_Len[1] + 4, &Packet, - END_OF_ARGS); - - NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen); - if (NStatus == NDIS_STATUS_SUCCESS) - { - RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID); - STASendPacket(pAd, pNdisPacket); - RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } - - MlmeFreeMemory(pAd, pOutBuffer); - - DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyHandShake- Send STAKey Message-2 (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen)); - - return NStatus; -} - -VOID DlsTimeoutAction( - IN PVOID SystemSpecific1, - IN PVOID FunctionContext, - IN PVOID SystemSpecific2, - IN PVOID SystemSpecific3) -{ - MLME_DLS_REQ_STRUCT MlmeDlsReq; - USHORT reason; - PRT_802_11_DLS pDLS = (PRT_802_11_DLS)FunctionContext; - PRTMP_ADAPTER pAd = pDLS->pAd; - - DBGPRINT(RT_DEBUG_TRACE, ("DlsTimeout - Tear down DLS links (%02x:%02x:%02x:%02x:%02x:%02x)\n", - pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5])); - - if ((pDLS) && (pDLS->Valid)) - { - reason = REASON_QOS_REQUEST_TIMEOUT; - pDLS->Valid = FALSE; - pDLS->Status = DLS_NONE; - DlsParmFill(pAd, &MlmeDlsReq, pDLS, reason); - MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq); - RT28XX_MLME_HANDLER(pAd); - } -} - -/* -================================================================ -Description : because DLS and CLI share the same WCID table in ASIC. -Mesh entry also insert to pAd->MacTab.content[]. Such is marked as ValidAsDls = TRUE. -Also fills the pairwise key. -Because front MAX_AID_BA entries have direct mapping to BAEntry, which is only used as CLI. So we insert Dls -from index MAX_AID_BA. -================================================================ -*/ -MAC_TABLE_ENTRY *MacTableInsertDlsEntry( - IN PRTMP_ADAPTER pAd, - IN PUCHAR pAddr, - IN UINT DlsEntryIdx) -{ - PMAC_TABLE_ENTRY pEntry = NULL; - - DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableInsertDlsEntry\n")); - // if FULL, return - if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE) - return NULL; - - do - { - if((pEntry = DlsEntryTableLookup(pAd, pAddr, TRUE)) != NULL) - break; - - // allocate one MAC entry - pEntry = MacTableInsertEntry(pAd, pAddr, DlsEntryIdx + MIN_NET_DEVICE_FOR_DLS, TRUE); - if (pEntry) - { - pAd->StaCfg.DLSEntry[DlsEntryIdx].MacTabMatchWCID = pEntry->Aid; - pEntry->MatchDlsEntryIdx = DlsEntryIdx; - pEntry->AuthMode = pAd->StaCfg.AuthMode; - pEntry->WepStatus = pAd->StaCfg.WepStatus; - pEntry->PortSecured = WPA_802_1X_PORT_SECURED; - - DBGPRINT(RT_DEBUG_TRACE, ("MacTableInsertDlsEntry - allocate entry #%d, Total= %d\n",pEntry->Aid, pAd->MacTab.Size)); - - // If legacy WEP is used, set pair-wise cipherAlg into WCID attribute table for this entry - if ((pEntry->ValidAsDls) && (pEntry->WepStatus == Ndis802_11WEPEnabled)) - { - UCHAR KeyIdx = 0; - UCHAR CipherAlg = 0; - - KeyIdx = pAd->StaCfg.DefaultKeyId; - - CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg; - - RTMPAddWcidAttributeEntry(pAd, - BSS0, - pAd->StaCfg.DefaultKeyId, - pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, - pEntry); - } - - break; - } - } while(FALSE); - - DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableInsertDlsEntry\n")); - - return pEntry; -} - - -/* - ========================================================================== - Description: - Delete all Mesh Entry in pAd->MacTab - ========================================================================== - */ -BOOLEAN MacTableDeleteDlsEntry( - IN PRTMP_ADAPTER pAd, - IN USHORT wcid, - IN PUCHAR pAddr) -{ - DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableDeleteDlsEntry\n")); - - if (!VALID_WCID(wcid)) - return FALSE; - - MacTableDeleteEntry(pAd, wcid, pAddr); - - DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableDeleteDlsEntry\n")); - - return TRUE; -} - -MAC_TABLE_ENTRY *DlsEntryTableLookup( - IN PRTMP_ADAPTER pAd, - IN PUCHAR pAddr, - IN BOOLEAN bResetIdelCount) -{ - ULONG HashIdx; - MAC_TABLE_ENTRY *pEntry = NULL; - - RTMP_SEM_LOCK(&pAd->MacTabLock); - HashIdx = MAC_ADDR_HASH_INDEX(pAddr); - pEntry = pAd->MacTab.Hash[HashIdx]; - - while (pEntry) - { - if ((pEntry->ValidAsDls == TRUE) - && MAC_ADDR_EQUAL(pEntry->Addr, pAddr)) - { - if(bResetIdelCount) - pEntry->NoDataIdleCount = 0; - break; - } - else - pEntry = pEntry->pNext; - } - - RTMP_SEM_UNLOCK(&pAd->MacTabLock); - return pEntry; -} - -MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid( - IN PRTMP_ADAPTER pAd, - IN UCHAR wcid, - IN PUCHAR pAddr, - IN BOOLEAN bResetIdelCount) -{ - ULONG DLsIndex; - PMAC_TABLE_ENTRY pCurEntry = NULL; - PMAC_TABLE_ENTRY pEntry = NULL; - - if (!VALID_WCID(wcid)) - return NULL; - - RTMP_SEM_LOCK(&pAd->MacTabLock); - - do - { - pCurEntry = &pAd->MacTab.Content[wcid]; - - DLsIndex = 0xff; - if ((pCurEntry) && (pCurEntry->ValidAsDls== TRUE)) - { - DLsIndex = pCurEntry->MatchDlsEntryIdx; - } - - if (DLsIndex == 0xff) - break; - - if (MAC_ADDR_EQUAL(pCurEntry->Addr, pAddr)) - { - if(bResetIdelCount) - pCurEntry->NoDataIdleCount = 0; - pEntry = pCurEntry; - break; - } - } while(FALSE); - - RTMP_SEM_UNLOCK(&pAd->MacTabLock); - - return pEntry; -} - -INT Set_DlsEntryInfo_Display_Proc( - IN PRTMP_ADAPTER pAd, - IN PUCHAR arg) -{ - INT i; - - printk("\n%-19s%-8s\n", "MAC", "TIMEOUT\n"); - for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) - { - PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[pAd->StaCfg.DLSEntry[i].MacTabMatchWCID]; - - printk("%02x:%02x:%02x:%02x:%02x:%02x ", - pAd->StaCfg.DLSEntry[i].MacAddr[0], pAd->StaCfg.DLSEntry[i].MacAddr[1], pAd->StaCfg.DLSEntry[i].MacAddr[2], - pAd->StaCfg.DLSEntry[i].MacAddr[3], pAd->StaCfg.DLSEntry[i].MacAddr[4], pAd->StaCfg.DLSEntry[i].MacAddr[5]); - printk("%-8d\n", pAd->StaCfg.DLSEntry[i].TimeOut); - - printk("\n"); - printk("\n%-19s%-4s%-4s%-4s%-4s%-8s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n", - "MAC", "AID", "BSS", "PSM", "WMM", "MIMOPS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC"); - printk("%02X:%02X:%02X:%02X:%02X:%02X ", - pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2], - pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]); - printk("%-4d", (int)pEntry->Aid); - printk("%-4d", (int)pEntry->apidx); - printk("%-4d", (int)pEntry->PsMode); - printk("%-4d", (int)CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE)); - printk("%-8d", (int)pEntry->MmpsMode); - printk("%-7d", pEntry->RssiSample.AvgRssi0); - printk("%-7d", pEntry->RssiSample.AvgRssi1); - printk("%-7d", pEntry->RssiSample.AvgRssi2); - printk("%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE)); - printk("%-6s", GetBW(pEntry->HTPhyMode.field.BW)); - printk("%-6d", pEntry->HTPhyMode.field.MCS); - printk("%-6d", pEntry->HTPhyMode.field.ShortGI); - printk("%-6d", pEntry->HTPhyMode.field.STBC); - printk("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount, - (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0); - printk("\n"); - - } - } - - return TRUE; -} - -INT Set_DlsAddEntry_Proc( - IN PRTMP_ADAPTER pAd, - IN PUCHAR arg) -{ - UCHAR mac[MAC_ADDR_LEN]; - USHORT Timeout; - char *token, sepValue[] = ":", DASH = '-'; - INT i; - RT_802_11_DLS Dls; - - if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and timeout value in decimal format. - return FALSE; - - token = strchr(arg, DASH); - if ((token != NULL) && (strlen(token)>1)) - { - Timeout = simple_strtol((token+1), 0, 10); - - *token = '\0'; - for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++) - { - if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1)))) - return FALSE; - AtoH(token, (PUCHAR)(&mac[i]), 1); - } - if(i != 6) - return FALSE; - - printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%d", mac[0], mac[1], - mac[2], mac[3], mac[4], mac[5], (int)Timeout); - - NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS)); - Dls.TimeOut = Timeout; - COPY_MAC_ADDR(Dls.MacAddr, mac); - Dls.Valid = 1; - - MlmeEnqueue(pAd, - MLME_CNTL_STATE_MACHINE, - RT_OID_802_11_SET_DLS_PARAM, - sizeof(RT_802_11_DLS), - &Dls); - - return TRUE; - } - - return FALSE; - -} - -INT Set_DlsTearDownEntry_Proc( - IN PRTMP_ADAPTER pAd, - IN PUCHAR arg) -{ - UCHAR macAddr[MAC_ADDR_LEN]; - CHAR *value; - INT i; - RT_802_11_DLS Dls; - - if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17 - return FALSE; - - for (i=0, value = rstrtok(arg,":"); value; value = rstrtok(NULL,":")) - { - if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) - return FALSE; //Invalid - - AtoH(value, &macAddr[i++], 2); - } - - printk("\n%02x:%02x:%02x:%02x:%02x:%02x", macAddr[0], macAddr[1], - macAddr[2], macAddr[3], macAddr[4], macAddr[5]); - - NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS)); - COPY_MAC_ADDR(Dls.MacAddr, macAddr); - Dls.Valid = 0; - - MlmeEnqueue(pAd, - MLME_CNTL_STATE_MACHINE, - RT_OID_802_11_SET_DLS_PARAM, - sizeof(RT_802_11_DLS), - &Dls); - - return TRUE; -} - diff --git a/drivers/staging/rt2860/sta/rtmp_data.c b/drivers/staging/rt2860/sta/rtmp_data.c index c5e76a2da56..b41ce230c50 100644 --- a/drivers/staging/rt2860/sta/rtmp_data.c +++ b/drivers/staging/rt2860/sta/rtmp_data.c @@ -50,7 +50,6 @@ VOID STARxEAPOLFrameIndicate( PRXWI_STRUC pRxWI = pRxBlk->pRxWI; UCHAR *pTmpBuf; -#ifdef WPA_SUPPLICANT_SUPPORT if (pAd->StaCfg.WpaSupplicantUP) { // All EAPoL frames have to pass to upper layer (ex. WPA_SUPPLICANT daemon) @@ -75,6 +74,7 @@ VOID STARxEAPOLFrameIndicate( if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0) { +#ifdef RT2860 MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[BSSID_WCID]; // Set key material and cipherAlg to Asic @@ -88,6 +88,32 @@ VOID STARxEAPOLFrameIndicate( pAd->IndicateMediaState = NdisMediaStateConnected; pAd->ExtraInfo = GENERAL_LINK_UP; +#endif +#ifdef RT2870 + union + { + char buf[sizeof(NDIS_802_11_WEP)+MAX_LEN_OF_KEY- 1]; + NDIS_802_11_WEP keyinfo; + } WepKey; + int len; + + + NdisZeroMemory(&WepKey, sizeof(WepKey)); + len =pAd->StaCfg.DesireSharedKey[idx].KeyLen; + + NdisMoveMemory(WepKey.keyinfo.KeyMaterial, + pAd->StaCfg.DesireSharedKey[idx].Key, + pAd->StaCfg.DesireSharedKey[idx].KeyLen); + + WepKey.keyinfo.KeyIndex = 0x80000000 + idx; + WepKey.keyinfo.KeyLength = len; + pAd->SharedKey[BSS0][idx].KeyLen =(UCHAR) (len <= 5 ? 5 : 13); + + pAd->IndicateMediaState = NdisMediaStateConnected; + pAd->ExtraInfo = GENERAL_LINK_UP; + // need to enqueue cmd to thread + RTUSBEnqueueCmdFromNdis(pAd, OID_802_11_ADD_WEP, TRUE, &WepKey, sizeof(WepKey.keyinfo) + len - 1); +#endif // RT2870 // // For Preventing ShardKey Table is cleared by remove key procedure. pAd->SharedKey[BSS0][idx].CipherAlg = CipherAlg; pAd->SharedKey[BSS0][idx].KeyLen = pAd->StaCfg.DesireSharedKey[idx].KeyLen; @@ -103,7 +129,6 @@ VOID STARxEAPOLFrameIndicate( } } else -#endif // WPA_SUPPLICANT_SUPPORT // { // Special DATA frame that has to pass to MLME // 1. Cisco Aironet frames for CCX2. We need pass it to MLME for special process @@ -168,20 +193,16 @@ VOID STARxDataFrameAnnounce( // ARALINK CmmRxRalinkFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID); } -#ifdef QOS_DLS_SUPPORT - RX_BLK_CLEAR_FLAG(pRxBlk, fRX_DLS); -#endif // QOS_DLS_SUPPORT // } else { RX_BLK_SET_FLAG(pRxBlk, fRX_EAP); -#ifdef DOT11_N_SUPPORT + if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0)) { Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID); } else -#endif // DOT11_N_SUPPORT // { // Determin the destination of the EAP frame // to WPA state machine or upper layer @@ -226,13 +247,11 @@ BOOLEAN STACheckTkipMICValue( { DBGPRINT_RAW(RT_DEBUG_ERROR,("Rx MIC Value error 2\n")); -#ifdef WPA_SUPPLICANT_SUPPORT if (pAd->StaCfg.WpaSupplicantUP) { WpaSendMicFailureToWpaSupplicant(pAd, (pWpaKey->Type == PAIRWISEKEY) ? TRUE : FALSE); } else -#endif // WPA_SUPPLICANT_SUPPORT // { RTMPReportMicError(pAd, pWpaKey); } @@ -276,14 +295,6 @@ VOID STAHandleRxDataFrame( return; } -#ifdef QOS_DLS_SUPPORT - //if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0)) - if (RTMPRcvFrameDLSCheck(pAd, pHeader, pRxWI->MPDUtotalByteCount, pRxD)) - { - return; - } -#endif // QOS_DLS_SUPPORT // - // Drop not my BSS frames if (pRxD->MyBss == 0) { @@ -342,10 +353,7 @@ VOID STAHandleRxDataFrame( } // Drop not my BSS frame (we can not only check the MyBss bit in RxD) -#ifdef QOS_DLS_SUPPORT - if (!pAd->CommonCfg.bDLSCapable) - { -#endif // QOS_DLS_SUPPORT // + if (INFRA_ON(pAd)) { // Infrastructure mode, check address 2 for BSSID @@ -368,9 +376,6 @@ VOID STAHandleRxDataFrame( return; } } -#ifdef QOS_DLS_SUPPORT - } -#endif // QOS_DLS_SUPPORT // // // find pEntry @@ -391,11 +396,6 @@ VOID STAHandleRxDataFrame( if (INFRA_ON(pAd)) { RX_BLK_SET_FLAG(pRxBlk, fRX_INFRA); -#ifdef QOS_DLS_SUPPORT - if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0)) - RX_BLK_SET_FLAG(pRxBlk, fRX_DLS); - else -#endif // QOS_DLS_SUPPORT // ASSERT(pRxWI->WirelessCliID == BSSID_WCID); } @@ -453,12 +453,10 @@ VOID STAHandleRxDataFrame( else #endif { -#ifdef DOT11_N_SUPPORT RX_BLK_SET_FLAG(pRxBlk, fRX_HTC); // skip HTC contorl field pRxBlk->pData += 4; pRxBlk->DataSize -= 4; -#endif // DOT11_N_SUPPORT // } } @@ -471,13 +469,10 @@ VOID STAHandleRxDataFrame( pRxBlk->pData += 2; } -#ifdef DOT11_N_SUPPORT if (pRxD->BA) { RX_BLK_SET_FLAG(pRxBlk, fRX_AMPDU); } -#endif // DOT11_N_SUPPORT // - // // Case I Process Broadcast & Multicast data frame @@ -509,18 +504,6 @@ VOID STAHandleRxDataFrame( { pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ; - -#ifdef QOS_DLS_SUPPORT - if (RX_BLK_TEST_FLAG(pRxBlk, fRX_DLS)) - { - MAC_TABLE_ENTRY *pDlsEntry = NULL; - - pDlsEntry = DlsEntryTableLookupByWcid(pAd, pRxWI->WirelessCliID, pHeader->Addr2, TRUE); - if(pDlsEntry) - Update_Rssi_Sample(pAd, &pDlsEntry->RssiSample, pRxWI); - } - else -#endif // QOS_DLS_SUPPORT // if (ADHOC_ON(pAd)) { pEntry = MacTableLookup(pAd, pHeader->Addr2); @@ -592,7 +575,13 @@ VOID STAHandleRxMgmtFrame( { // We should collect RSSI not only U2M data but also my beacon +#ifdef RT30xx + if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2)) + && (pAd->RxAnt.EvaluatePeriod == 0)) +#endif +#ifndef RT30xx if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))) +#endif { Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI); @@ -600,6 +589,18 @@ VOID STAHandleRxMgmtFrame( pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1); } +#ifdef RT30xx + // collect rssi information for antenna diversity + if (pAd->NicConfig2.field.AntDiversity) + { + if ((pRxD->U2M) || ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2)))) + { + COLLECT_RX_ANTENNA_AVERAGE_RSSI(pAd, ConvertToRssi(pAd, (UCHAR)pRxWI->RSSI0, RSSI_0), 0); //Note: RSSI2 not used on RT73 + pAd->StaCfg.NumOfAvgRssiSample ++; + } + } +#endif // RT30xx // + // First check the size, it MUST not exceed the mlme queue size if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE) { @@ -618,21 +619,17 @@ VOID STAHandleRxControlFrame( IN PRTMP_ADAPTER pAd, IN RX_BLK *pRxBlk) { -#ifdef DOT11_N_SUPPORT PRXWI_STRUC pRxWI = pRxBlk->pRxWI; -#endif // DOT11_N_SUPPORT // PHEADER_802_11 pHeader = pRxBlk->pHeader; PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket; switch (pHeader->FC.SubType) { case SUBTYPE_BLOCK_ACK_REQ: -#ifdef DOT11_N_SUPPORT { CntlEnqueueForRecv(pAd, pRxWI->WirelessCliID, (pRxWI->MPDUtotalByteCount), (PFRAME_BA_REQ)pHeader); } break; -#endif // DOT11_N_SUPPORT // case SUBTYPE_BLOCK_ACK: case SUBTYPE_ACK: default: @@ -691,12 +688,14 @@ BOOLEAN STARxDoneInterruptHandle( break; } +#ifdef RT2860 if (RxProcessed++ > MAX_RX_PROCESS_CNT) { // need to reschedule rx handle bReschedule = TRUE; break; } +#endif RxProcessed ++; // test @@ -721,11 +720,6 @@ BOOLEAN STARxDoneInterruptHandle( pRxWI = (PRXWI_STRUC) pData; pHeader = (PHEADER_802_11) (pData+RXWI_SIZE) ; -#ifdef RT_BIG_ENDIAN - RTMPFrameEndianChange(pAd, (PUCHAR)pHeader, DIR_READ, TRUE); - RTMPWIEndianChange((PUCHAR)pRxWI, TYPE_RXWI); -#endif - // build RxCell RxCell.pRxWI = pRxWI; RxCell.pHeader = pHeader; @@ -749,22 +743,6 @@ BOOLEAN STARxDoneInterruptHandle( break; } /* RT2870 invokes STARxDoneInterruptHandle() in rtusb_bulk.c */ -#ifdef RALINK_ATE - if (ATE_ON(pAd)) - { - pAd->ate.RxCntPerSec++; - ATESampleRssi(pAd, pRxWI); -#ifdef RALINK_28xx_QA - if (pAd->ate.bQARxStart == TRUE) - { - /* (*pRxD) has been swapped in GetPacketFromRxRing() */ - ATE_QA_Statistics(pAd, pRxWI, pRxD, pHeader); - } -#endif // RALINK_28xx_QA // - RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS); - continue; - } -#endif // RALINK_ATE // // Check for all RxD errors Status = RTMPCheckRxError(pAd, pHeader, pRxWI, pRxD); @@ -807,6 +785,7 @@ BOOLEAN STARxDoneInterruptHandle( } } +#ifdef RT2860 // fRTMP_PS_GO_TO_SLEEP_NOW is set if receiving beacon. if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW) && (INFRA_ON(pAd))) { @@ -814,6 +793,7 @@ BOOLEAN STARxDoneInterruptHandle( AsicSleepThenAutoWakeup(pAd, pAd->ThisTbttNumToNextWakeUp); bReschedule = FALSE; } +#endif return bReschedule; } @@ -831,7 +811,12 @@ BOOLEAN STARxDoneInterruptHandle( VOID RTMPHandleTwakeupInterrupt( IN PRTMP_ADAPTER pAd) { +#ifdef RT2860 AsicForceWakeup(pAd, DOT11POWERSAVE); +#endif +#ifdef RT2870 + AsicForceWakeup(pAd, FALSE); +#endif } /* @@ -885,17 +870,6 @@ VOID STASendPackets( { // Record that orignal packet source is from NDIS layer,so that // later on driver knows how to release this NDIS PACKET -#ifdef QOS_DLS_SUPPORT - MAC_TABLE_ENTRY *pEntry; - PUCHAR pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket); - - pEntry = MacTableLookup(pAd, pSrcBufVA); - if (pEntry && (pEntry->ValidAsDls == TRUE)) - { - RTMP_SET_PACKET_WCID(pPacket, pEntry->Aid); - } - else -#endif // QOS_DLS_SUPPORT // RTMP_SET_PACKET_WCID(pPacket, 0); // this field is useless when in STA mode RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS); NDIS_SET_PACKET_STATUS(pPacket, NDIS_STATUS_PENDING); @@ -977,18 +951,6 @@ NDIS_STATUS STASendPacket( { if(INFRA_ON(pAd)) { -#ifdef QOS_DLS_SUPPORT - USHORT tmpWcid; - - tmpWcid = RTMP_GET_PACKET_WCID(pPacket); - if (VALID_WCID(tmpWcid) && - (pAd->MacTab.Content[tmpWcid].ValidAsDls== TRUE)) - { - pEntry = &pAd->MacTab.Content[tmpWcid]; - Rate = pAd->MacTab.Content[tmpWcid].CurrTxRate; - } - else -#endif // QOS_DLS_SUPPORT // { pEntry = &pAd->MacTab.Content[BSSID_WCID]; RTMP_SET_PACKET_WCID(pPacket, BSSID_WCID); @@ -1039,12 +1001,7 @@ NDIS_STATUS STASendPacket( (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) -#ifdef WPA_SUPPLICANT_SUPPORT || (pAd->StaCfg.IEEE8021X == TRUE) -#endif // WPA_SUPPLICANT_SUPPORT // -#ifdef LEAP_SUPPORT - || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) -#endif // LEAP_SUPPORT // ) && ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || (pAd->StaCfg.MicErrCnt >= 2)) && (RTMP_GET_PACKET_EAPOL(pPacket)== FALSE) @@ -1070,10 +1027,8 @@ NDIS_STATUS STASendPacket( NumberOfFrag = 1; // Aggregation overwhelms fragmentation else if (CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED)) NumberOfFrag = 1; // Aggregation overwhelms fragmentation -#ifdef DOT11_N_SUPPORT else if ((pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTMIX) || (pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTGREENFIELD)) NumberOfFrag = 1; // MIMO RATE overwhelms fragmentation -#endif // DOT11_N_SUPPORT // else { // The calculated "NumberOfFrag" is a rough estimation because of various @@ -1110,7 +1065,13 @@ NDIS_STATUS STASendPacket( // UserPriority = 0; QueIdx = QID_AC_BE; +#ifdef RT2860 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)) +#endif +#ifdef RT2870 + if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && + CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE)) +#endif { USHORT Protocol; UCHAR LlcSnapLen = 0, Byte0, Byte1; @@ -1163,9 +1124,6 @@ NDIS_STATUS STASendPacket( if (pAd->TxSwQueue[QueIdx].Number >= MAX_PACKETS_IN_QUEUE) { RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags); -#ifdef BLOCK_NET_IF - StopNetIfQueue(pAd, QueIdx, pPacket); -#endif // BLOCK_NET_IF // RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE); return NDIS_STATUS_FAILURE; @@ -1176,9 +1134,13 @@ NDIS_STATUS STASendPacket( } RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags); -#ifdef DOT11_N_SUPPORT if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&& +#ifdef RT2860 (pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE)) +#endif +#ifdef RT2870 + IS_HT_STA(pEntry)) +#endif { if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) && ((pEntry->BADeclineBitmap & (1<<UserPriority)) == 0) && @@ -1194,7 +1156,6 @@ NDIS_STATUS STASendPacket( BAOriSessionSetUp(pAd, pEntry, 0, 0, 10, FALSE); } } -#endif // DOT11_N_SUPPORT // pAd->RalinkCounters.OneSecOsTxCount[QueIdx]++; // TODO: for debug only. to be removed return NDIS_STATUS_SUCCESS; @@ -1223,14 +1184,27 @@ NDIS_STATUS STASendPacket( ======================================================================== */ + +#ifdef RT2870 +/* + Actually, this function used to check if the TxHardware Queue still has frame need to send. + If no frame need to send, go to sleep, else, still wake up. +*/ +#endif NDIS_STATUS RTMPFreeTXDRequest( IN PRTMP_ADAPTER pAd, IN UCHAR QueIdx, IN UCHAR NumberRequired, IN PUCHAR FreeNumberIs) { +#ifdef RT2860 ULONG FreeNumber = 0; +#endif NDIS_STATUS Status = NDIS_STATUS_FAILURE; +#ifdef RT2870 + unsigned long IrqFlags; + HT_TX_CONTEXT *pHTTXContext; +#endif switch (QueIdx) { @@ -1239,6 +1213,7 @@ NDIS_STATUS RTMPFreeTXDRequest( case QID_AC_VI: case QID_AC_VO: case QID_HCCA: +#ifdef RT2860 if (pAd->TxRing[QueIdx].TxSwFreeIdx > pAd->TxRing[QueIdx].TxCpuIdx) FreeNumber = pAd->TxRing[QueIdx].TxSwFreeIdx - pAd->TxRing[QueIdx].TxCpuIdx - 1; else @@ -1246,9 +1221,27 @@ NDIS_STATUS RTMPFreeTXDRequest( if (FreeNumber >= NumberRequired) Status = NDIS_STATUS_SUCCESS; +#endif +#ifdef RT2870 + { + pHTTXContext = &pAd->TxContext[QueIdx]; + RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags); + if ((pHTTXContext->CurWritePosition != pHTTXContext->ENextBulkOutPosition) || + (pHTTXContext->IRPPending == TRUE)) + { + Status = NDIS_STATUS_FAILURE; + } + else + { + Status = NDIS_STATUS_SUCCESS; + } + RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags); + } +#endif break; case QID_MGMT: +#ifdef RT2860 if (pAd->MgmtRing.TxSwFreeIdx > pAd->MgmtRing.TxCpuIdx) FreeNumber = pAd->MgmtRing.TxSwFreeIdx - pAd->MgmtRing.TxCpuIdx - 1; else @@ -1256,13 +1249,22 @@ NDIS_STATUS RTMPFreeTXDRequest( if (FreeNumber >= NumberRequired) Status = NDIS_STATUS_SUCCESS; +#endif +#ifdef RT2870 + if (pAd->MgmtRing.TxSwFreeIdx != MGMT_RING_SIZE) + Status = NDIS_STATUS_FAILURE; + else + Status = NDIS_STATUS_SUCCESS; +#endif break; default: DBGPRINT(RT_DEBUG_ERROR,("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx)); break; } +#ifdef RT2860 *FreeNumberIs = (UCHAR)FreeNumber; +#endif return (Status); } @@ -1283,22 +1285,12 @@ VOID RTMPSendNullFrame( ULONG Length; PHEADER_802_11 pHeader_802_11; - -#ifdef RALINK_ATE - if(ATE_ON(pAd)) - { - return; - } -#endif // RALINK_ATE // - // WPA 802.1x secured port control if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) -#ifdef WPA_SUPPLICANT_SUPPORT || (pAd->StaCfg.IEEE8021X == TRUE) -#endif ) && (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) { @@ -1402,30 +1394,6 @@ VOID STAFindCipherAlgorithm( } else if (Cipher == Ndis802_11Encryption1Enabled) { -#ifdef LEAP_SUPPORT - if (pAd->StaCfg.CkipFlag & 0x10) // Cisco CKIP KP is on - { - if (LEAP_CCKM_ON(pAd)) - { - if (((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))) - KeyIdx = 1; - else - KeyIdx = 0; - } - else - KeyIdx = pAd->StaCfg.DefaultKeyId; - } - else if (pAd->StaCfg.CkipFlag & 0x08) // only CKIP CMIC - KeyIdx = pAd->StaCfg.DefaultKeyId; - else if (LEAP_CCKM_ON(pAd)) - { - if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd))) - KeyIdx = 1; - else - KeyIdx = 0; - } - else // standard WEP64 or WEP128 -#endif // LEAP_SUPPORT // KeyIdx = pAd->StaCfg.DefaultKeyId; } else if ((Cipher == Ndis802_11Encryption2Enabled) || @@ -1443,13 +1411,11 @@ VOID STAFindCipherAlgorithm( CipherAlg = CIPHER_NONE; else if ((Cipher == Ndis802_11EncryptionDisabled) || (pAd->SharedKey[BSS0][KeyIdx].KeyLen == 0)) CipherAlg = CIPHER_NONE; -#ifdef WPA_SUPPLICANT_SUPPORT else if ( pAd->StaCfg.WpaSupplicantUP && (Cipher == Ndis802_11Encryption1Enabled) && (pAd->StaCfg.IEEE8021X == TRUE) && (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) CipherAlg = CIPHER_NONE; -#endif // WPA_SUPPLICANT_SUPPORT // else { //Header_802_11.FC.Wep = 1; @@ -1467,12 +1433,7 @@ VOID STABuildCommon802_11Header( IN PRTMP_ADAPTER pAd, IN TX_BLK *pTxBlk) { - HEADER_802_11 *pHeader_802_11; -#ifdef QOS_DLS_SUPPORT - BOOLEAN bDLSFrame = FALSE; - INT DlsEntryIndex = 0; -#endif // QOS_DLS_SUPPORT // // // MAKE A COMMON 802.11 HEADER @@ -1489,19 +1450,6 @@ VOID STABuildCommon802_11Header( pHeader_802_11->FC.Type = BTYPE_DATA; pHeader_802_11->FC.SubType = ((TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) ? SUBTYPE_QDATA : SUBTYPE_DATA); -#ifdef QOS_DLS_SUPPORT - if (INFRA_ON(pAd)) - { - // Check if the frame can be sent through DLS direct link interface - // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability) - DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader); - if (DlsEntryIndex >= 0) - bDLSFrame = TRUE; - else - bDLSFrame = FALSE; - } -#endif // QOS_DLS_SUPPORT // - if (pTxBlk->pMacEntry) { if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS)) @@ -1511,14 +1459,6 @@ VOID STABuildCommon802_11Header( } else { -#ifdef QOS_DLS_SUPPORT - if (bDLSFrame) - { - pHeader_802_11->Sequence = pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence; - pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence = (pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence+1) & MAXSEQ; - } - else -#endif // QOS_DLS_SUPPORT // { pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]; pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ; @@ -1538,16 +1478,6 @@ VOID STABuildCommon802_11Header( { if (INFRA_ON(pAd)) { -#ifdef QOS_DLS_SUPPORT - if (bDLSFrame) - { - COPY_MAC_ADDR(pHeader_802_11->Addr1, pTxBlk->pSrcBufHeader); - COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress); - COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid); - pHeader_802_11->FC.ToDs = 0; - } - else -#endif // QOS_DLS_SUPPORT // { COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid); COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress); @@ -1576,7 +1506,6 @@ VOID STABuildCommon802_11Header( pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE); } -#ifdef DOT11_N_SUPPORT VOID STABuildCache802_11Header( IN RTMP_ADAPTER *pAd, IN TX_BLK *pTxBlk, @@ -1603,29 +1532,7 @@ VOID STABuildCache802_11Header( pMacEntry->TxSeq[pTxBlk->UserPriority] = (pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ; { - // Check if the frame can be sent through DLS direct link interface - // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability) -#ifdef QOS_DLS_SUPPORT - BOOLEAN bDLSFrame = FALSE; - INT DlsEntryIndex = 0; - - DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader); - if (DlsEntryIndex >= 0) - bDLSFrame = TRUE; - else - bDLSFrame = FALSE; -#endif // QOS_DLS_SUPPORT // - // The addr3 of normal packet send from DS is Dest Mac address. -#ifdef QOS_DLS_SUPPORT - if (bDLSFrame) - { - COPY_MAC_ADDR(pHeader80211->Addr1, pTxBlk->pSrcBufHeader); - COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid); - pHeader80211->FC.ToDs = 0; - } - else -#endif // QOS_DLS_SUPPORT // if (ADHOC_ON(pAd)) COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid); else @@ -1640,7 +1547,6 @@ VOID STABuildCache802_11Header( else pHeader80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE); } -#endif // DOT11_N_SUPPORT // static inline PUCHAR STA_Build_ARalink_Frame_Header( IN RTMP_ADAPTER *pAd, @@ -1700,7 +1606,6 @@ static inline PUCHAR STA_Build_ARalink_Frame_Header( } -#ifdef DOT11_N_SUPPORT static inline PUCHAR STA_Build_AMSDU_Frame_Header( IN RTMP_ADAPTER *pAd, IN TX_BLK *pTxBlk) @@ -1890,7 +1795,9 @@ VOID STA_AMPDU_Frame_Tx( // // Kick out Tx // +#ifdef RT2860 if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX)) +#endif HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx); pAd->RalinkCounters.KickTxCount++; @@ -2021,10 +1928,11 @@ VOID STA_AMSDU_Frame_Tx( // // Kick out Tx // +#ifdef RT2860 if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX)) +#endif HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx); } -#endif // DOT11_N_SUPPORT // VOID STA_Legacy_Frame_Tx( IN PRTMP_ADAPTER pAd, @@ -2142,7 +2050,9 @@ VOID STA_Legacy_Frame_Tx( // // Kick out Tx // +#ifdef RT2860 if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX)) +#endif HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx); } @@ -2253,7 +2163,9 @@ VOID STA_ARalink_Frame_Tx( // // Kick out Tx // +#ifdef RT2860 if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX)) +#endif HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx); } @@ -2513,15 +2425,6 @@ NDIS_STATUS STAHardTransmit( pPacket = QUEUE_ENTRY_TO_PACKET(pTxBlk->TxPacketList.Head); -#if 0 //def CARRIER_DETECTION_SUPPORT // Roger sync Carrier - if ((pAd->CommonCfg.CarrierDetect.Enable == TRUE) && (isCarrierDetectExist(pAd) == TRUE)) - { - DBGPRINT(RT_DEBUG_INFO,("STAHardTransmit --> radar detect not in normal mode !!!\n")); - RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE); - return (NDIS_STATUS_FAILURE); - } -#endif // CARRIER_DETECTION_SUPPORT // - // ------------------------------------------------------------------ // STEP 1. WAKE UP PHY // outgoing frame always wakeup PHY to prevent frame lost and @@ -2531,7 +2434,12 @@ NDIS_STATUS STAHardTransmit( if ((pAd->StaCfg.Psm == PWR_SAVE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicForceWakeup At HardTx\n")); +#ifdef RT2860 AsicForceWakeup(pAd, FROM_TX); +#endif +#ifdef RT2870 + AsicForceWakeup(pAd, TRUE); +#endif } // It should not change PSM bit, when APSD turn on. @@ -2546,14 +2454,12 @@ NDIS_STATUS STAHardTransmit( switch (pTxBlk->TxFrameType) { -#ifdef DOT11_N_SUPPORT case TX_AMPDU_FRAME: STA_AMPDU_Frame_Tx(pAd, pTxBlk); break; case TX_AMSDU_FRAME: STA_AMSDU_Frame_Tx(pAd, pTxBlk); break; -#endif // DOT11_N_SUPPORT // case TX_LEGACY_FRAME: STA_Legacy_Frame_Tx(pAd, pTxBlk); break; diff --git a/drivers/staging/rt2860/sta/sanity.c b/drivers/staging/rt2860/sta/sanity.c index 239872464be..7d530f60160 100644 --- a/drivers/staging/rt2860/sta/sanity.c +++ b/drivers/staging/rt2860/sta/sanity.c @@ -184,7 +184,6 @@ BOOLEAN PeerAssocRspSanity( } break; -#ifdef DOT11_N_SUPPORT case IE_ADD_HT: case IE_ADD_HT2: if (pEid->Len >= sizeof(ADD_HT_INFO_IE)) @@ -213,7 +212,6 @@ BOOLEAN PeerAssocRspSanity( { DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n")); } -#endif // DOT11_N_SUPPORT // break; case IE_AIRONET_CKIP: // 0. Check Aironet IE length, it must be larger or equal to 28 diff --git a/drivers/staging/rt2860/sta/sync.c b/drivers/staging/rt2860/sta/sync.c index 148037a79d5..87b5e49cec5 100644 --- a/drivers/staging/rt2860/sta/sync.c +++ b/drivers/staging/rt2860/sta/sync.c @@ -37,6 +37,7 @@ */ #include "../rt_config.h" +#ifdef RT2860 #define AC0_DEF_TXOP 0 #define AC1_DEF_TXOP 0 #define AC2_DEF_TXOP 94 @@ -71,6 +72,10 @@ VOID AdhocTurnOnQos( } AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm); } +#endif /* RT2860 */ +#ifdef RT2870 +#define ADHOC_ENTRY_BEACON_LOST_TIME (2*OS_HZ) // 2 sec +#endif /* ========================================================================== @@ -141,7 +146,6 @@ VOID BeaconTimeout( if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) return; -#ifdef DOT11_N_SUPPORT if ((pAd->CommonCfg.BBPCurrentBW == BW_40) ) { @@ -154,7 +158,6 @@ VOID BeaconTimeout( RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue); DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr)); } -#endif // DOT11_N_SUPPORT // MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_BEACON_TIMEOUT, 0, NULL); RT28XX_MLME_HANDLER(pAd); @@ -228,6 +231,7 @@ VOID MlmeScanReqAction( // Increase the scan retry counters. pAd->StaCfg.ScanCnt++; +#ifdef RT2860 if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) && (IDLE_ON(pAd)) && (pAd->StaCfg.bRadio == TRUE) && @@ -235,6 +239,7 @@ VOID MlmeScanReqAction( { RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE); } +#endif // first check the parameter sanity if (MlmeScanReqSanity(pAd, @@ -347,6 +352,7 @@ VOID MlmeJoinReqAction( DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx)); +#ifdef RT2860 if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) && (IDLE_ON(pAd)) && (pAd->StaCfg.bRadio == TRUE) && @@ -354,6 +360,7 @@ VOID MlmeJoinReqAction( { RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE); } +#endif // reset all the timers RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled); @@ -375,22 +382,6 @@ VOID MlmeJoinReqAction( pAd->MlmeAux.Channel = pBss->Channel; pAd->MlmeAux.CentralChannel = pBss->CentralChannel; -#ifdef EXT_BUILD_CHANNEL_LIST - // Country IE of the AP will be evaluated and will be used. - if ((pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None) && - (pBss->bHasCountryIE == TRUE)) - { - NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pBss->CountryString[0], 2); - if (pBss->CountryString[2] == 'I') - pAd->CommonCfg.Geography = IDOR; - else if (pBss->CountryString[2] == 'O') - pAd->CommonCfg.Geography = ODOR; - else - pAd->CommonCfg.Geography = BOTH; - BuildChannelListEx(pAd); - } -#endif // EXT_BUILD_CHANNEL_LIST // - // Let BBP register at 20MHz to do scan RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue); BBPValue &= (~0x18); @@ -407,9 +398,6 @@ VOID MlmeJoinReqAction( if (((pAd->CommonCfg.bIEEE80211H == 1) && (pAd->MlmeAux.Channel > 14) && RadarChannelCheck(pAd, pAd->MlmeAux.Channel)) -#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier - || (pAd->CommonCfg.CarrierDetect.Enable == TRUE) -#endif // CARRIER_DETECTION_SUPPORT // ) { // @@ -541,7 +529,7 @@ VOID MlmeStartReqAction( pAd->MlmeAux.ExtRateLen = pAd->CommonCfg.ExtRateLen; NdisMoveMemory(pAd->MlmeAux.ExtRate, pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES); RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen); -#ifdef DOT11_N_SUPPORT + if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) { RTMPUpdateHTIE(&pAd->CommonCfg.DesiredHtPhy, &pAd->StaCfg.DesiredHtPhyInfo.MCSSet[0], &pAd->MlmeAux.HtCapability, &pAd->MlmeAux.AddHtInfo); @@ -550,7 +538,6 @@ VOID MlmeStartReqAction( DBGPRINT(RT_DEBUG_TRACE, ("SYNC -pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE\n")); } else -#endif // DOT11_N_SUPPORT // { pAd->MlmeAux.HtCapabilityLen = 0; pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE; @@ -618,10 +605,9 @@ VOID PeerBeaconAtScanAction( // Init Variable IE structure pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; pVIE->Length = 0; -#ifdef DOT11_N_SUPPORT + RTMPZeroMemory(&HtCapability, sizeof(HtCapability)); RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE)); -#endif // DOT11_N_SUPPORT // if (PeerBeaconAndProbeRspSanity(pAd, Elem->Msg, @@ -672,11 +658,9 @@ VOID PeerBeaconAtScanAction( Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2)); - -#ifdef DOT11_N_SUPPORT if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0)) HtCapabilityLen = SIZE_HT_CAP_IE; -#endif // DOT11_N_SUPPORT // + if ((pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) && (Channel == pAd->StaCfg.CCXScanChannel)) { Idx = BssTableSetEntry(pAd, &pAd->StaCfg.CCXBssTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod, @@ -698,16 +682,7 @@ VOID PeerBeaconAtScanAction( &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability, &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag, &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE); -#ifdef DOT11_N_SUPPORT -#ifdef DOT11N_DRAFT3 - if (pAd->ChannelList[pAd->CommonCfg.ChannelListIdx].bEffectedChannel == TRUE) - { - UCHAR RegClass; - PeerBeaconAndProbeRspSanity2(pAd, Elem->Msg, Elem->MsgLen, &RegClass); - TriEventTableSetEntry(pAd, &pAd->CommonCfg.TriggerEventTab, Bssid, &HtCapability, HtCapabilityLen, RegClass, Channel); - } -#endif // DOT11N_DRAFT3 // -#endif // DOT11_N_SUPPORT // + if (Idx != BSS_NOT_FOUND) { NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4); @@ -755,9 +730,7 @@ VOID PeerBeaconAtJoinAction( UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0; UCHAR AddHtInfoLen; UCHAR NewExtChannelOffset = 0xff; -#ifdef DOT11_N_SUPPORT UCHAR CentralChannel; -#endif // DOT11_N_SUPPORT // // Init Variable IE structure pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; @@ -873,7 +846,7 @@ VOID PeerBeaconAtJoinAction( RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen); NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, 16); -#ifdef DOT11_N_SUPPORT + pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset; pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen; @@ -918,7 +891,6 @@ VOID PeerBeaconAtJoinAction( } else -#endif // DOT11_N_SUPPORT // { // To prevent error, let legacy AP must have same CentralChannel and Channel. if ((HtCapabilityLen == 0) && (PreNHtCapabilityLen == 0)) @@ -933,9 +905,7 @@ VOID PeerBeaconAtJoinAction( // copy QOS related information if ((pAd->CommonCfg.bWmmCapable) -#ifdef DOT11_N_SUPPORT || (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) -#endif // DOT11_N_SUPPORT // ) { NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, &EdcaParm, sizeof(EDCA_PARM)); @@ -952,15 +922,6 @@ VOID PeerBeaconAtJoinAction( DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n", pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen)); -#ifdef LEAP_SUPPORT - // Update CkipFlag - pAd->StaCfg.CkipFlag = CkipFlag; - - // Keep TimeStamp for Re-Association used. - if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE)) - pAd->StaCfg.CCKMBeaconAtJoinTimeStamp = TimeStamp; -#endif // LEAP_SUPPORT // - if (AironetCellPowerLimit != 0xFF) { //We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power @@ -1018,14 +979,6 @@ VOID PeerBeacon( UCHAR AddHtInfoLen; UCHAR NewExtChannelOffset = 0xff; - -#ifdef RALINK_ATE - if (ATE_ON(pAd)) - { - return; - } -#endif // RALINK_ATE // - if (!(INFRA_ON(pAd) || ADHOC_ON(pAd) )) return; @@ -1093,14 +1046,12 @@ VOID PeerBeacon( if (pAd->Mlme.CntlMachine.CurrState == CNTL_WAIT_DISASSOC) return; -#ifdef DOT11_N_SUPPORT // Copy Control channel for this BSSID. if (AddHtInfoLen != 0) Channel = AddHtInfo.ControlChan; if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0)) HtCapabilityLen = SIZE_HT_CAP_IE; -#endif // DOT11_N_SUPPORT // // // Housekeeping "SsidBssTab" table for later-on ROAMing usage. @@ -1165,6 +1116,10 @@ VOID PeerBeacon( // Add the safeguard against the mismatch of adhoc wep status if (pAd->StaCfg.WepStatus != pAd->ScanTab.BssEntry[Bssidx].WepStatus) { +#ifdef RT30xx + DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Not matched wep status %d %d\n", pAd->StaCfg.WepStatus, pAd->ScanTab.BssEntry[Bssidx].WepStatus)); + DBGPRINT(RT_DEBUG_TRACE, ("bssid=%s\n", pAd->ScanTab.BssEntry[Bssidx].Bssid)); +#endif return; } @@ -1228,11 +1183,14 @@ VOID PeerBeacon( pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault; } +#ifdef RT2860 // at least one 11b peer joined. downgrade the MaxTxRate to 11Mbps // after last 11b peer left for several seconds, we'll auto switch back to 11G rate // in MlmePeriodicExec() +#endif if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo))) { +#ifdef RT2860 BOOLEAN bRestart; BOOLEAN bnRestart; @@ -1260,7 +1218,7 @@ VOID PeerBeacon( pAd->StaCfg.Last11bBeaconRxTime = Now; break; } -#ifdef DOT11_N_SUPPORT + // Update Ht Phy. if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { @@ -1316,7 +1274,6 @@ VOID PeerBeacon( } else -#endif // DOT11_N_SUPPORT // { RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE); RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo, SIZE_ADD_HT_INFO_IE); @@ -1330,7 +1287,6 @@ VOID PeerBeacon( MakeIbssBeacon(pAd); // re-build BEACON frame AsicEnableIbssSync(pAd); // copy to on-chip memory } -#ifdef DOT11_N_SUPPORT else if ((bRestart == TRUE) && (bnRestart == TRUE)) { MlmeUpdateTxRates(pAd, FALSE, BSS0); @@ -1338,7 +1294,6 @@ VOID PeerBeacon( MakeIbssBeacon(pAd); // re-build BEACON frame AsicEnableIbssSync(pAd); // copy to on-chip memory } -#endif // DOT11_N_SUPPORT // // At least another peer in this IBSS, declare MediaState as CONNECTED if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) @@ -1402,29 +1357,12 @@ VOID PeerBeacon( } MlmeUpdateTxRates(pAd, FALSE, 0); } -#ifdef DOT11_N_SUPPORT else { MlmeUpdateTxRates(pAd, FALSE, 0); MlmeUpdateHtTxRates(pAd, BSS0); } -#endif // DOT11_N_SUPPORT // -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - if (pAd->StaCfg.WpaSupplicantUP) - { - union iwreq_data wrqu; - - SendAssocIEsToWpaSupplicant(pAd); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_ASSOC_EVENT_FLAG; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT { union iwreq_data wrqu; wext_notify_event_assoc(pAd); @@ -1434,10 +1372,82 @@ VOID PeerBeacon( wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // } } } +#endif /* RT2860 */ +#ifdef RT2870 + UCHAR MaxSupportedRateIn500Kbps = 0; + UCHAR idx; + MAC_TABLE_ENTRY *pEntry; + + // supported rates array may not be sorted. sort it and find the maximum rate + for (idx=0; idx<SupRateLen; idx++) + { + if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f)) + MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f; + } + + for (idx=0; idx<ExtRateLen; idx++) + { + if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f)) + MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f; + } + + // look up the existing table + pEntry = MacTableLookup(pAd, Addr2); + + // Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon. + // To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station. + if ((ADHOC_ON(pAd) && (Elem->Wcid == RESERVED_WCID)) || + (pEntry && ((pEntry->LastBeaconRxTime + ADHOC_ENTRY_BEACON_LOST_TIME) < Now))) + { + if (pEntry == NULL) + // Another adhoc joining, add to our MAC table. + pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE); + + if (StaAddMacTableEntry(pAd, pEntry, MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo) == FALSE) + { + DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n")); + return; + } + + if (pEntry && + (Elem->Wcid == RESERVED_WCID)) + { + idx = pAd->StaCfg.DefaultKeyId; + RT28XX_STA_SECURITY_INFO_ADD(pAd, BSS0, idx, pEntry); + } + } + + if (pEntry && pEntry->ValidAsCLI) + pEntry->LastBeaconRxTime = Now; + + // At least another peer in this IBSS, declare MediaState as CONNECTED + if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) + { + OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); + + pAd->IndicateMediaState = NdisMediaStateConnected; + RTMP_IndicateMediaState(pAd); + pAd->ExtraInfo = GENERAL_LINK_UP; + AsicSetBssid(pAd, pAd->CommonCfg.Bssid); + + // 2003/03/12 - john + // Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that + // "site survey" result should always include the current connected network. + // + Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel); + if (Bssidx == BSS_NOT_FOUND) + { + Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod, + &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability, + &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0, + &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE); + } + DBGPRINT(RT_DEBUG_TRACE, ("ADHOC fOP_STATUS_MEDIA_STATE_CONNECTED.\n")); + } +#endif /* RT2870 */ } if (INFRA_ON(pAd)) @@ -1476,7 +1486,6 @@ VOID PeerBeacon( DBGPRINT(RT_DEBUG_WARN, ("SYNC - AP changed B/G protection to %d\n", bUseBGProtection)); } -#ifdef DOT11_N_SUPPORT // check Ht protection mode. and adhere to the Non-GF device indication by AP. if ((AddHtInfoLen != 0) && ((AddHtInfo.AddHtInfo2.OperaionMode != pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode) || @@ -1493,7 +1502,6 @@ VOID PeerBeacon( DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP changed N OperaionMode to %d\n", pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode)); } -#endif // DOT11_N_SUPPORT // if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED) && ERP_IS_USE_BARKER_PREAMBLE(Erp)) @@ -1528,10 +1536,12 @@ VOID PeerBeacon( // 5. otherwise, put PHY back to sleep to save battery. if (MessageToMe) { +#ifdef RT2860 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) { RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3); } +#endif if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable && pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO) { @@ -1542,10 +1552,12 @@ VOID PeerBeacon( } else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM)) { +#ifdef RT2860 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) { RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3); } +#endif } else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) || (pAd->TxSwQueue[QID_AC_BE].Number != 0) || @@ -1559,10 +1571,12 @@ VOID PeerBeacon( { // TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme // can we cheat here (i.e. just check MGMT & AC_BE) for better performance? +#ifdef RT2860 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) { RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3); } +#endif } else { @@ -1577,10 +1591,14 @@ VOID PeerBeacon( if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { +#ifdef RT2860 // Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode. RTMP_SET_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW); pAd->ThisTbttNumToNextWakeUp = TbttNumToNextWakeUp; - //AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp); +#endif +#ifdef RT2870 + AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp); +#endif } } } @@ -1603,9 +1621,7 @@ VOID PeerProbeReqAction( UCHAR Addr2[MAC_ADDR_LEN]; CHAR Ssid[MAX_LEN_OF_SSID]; UCHAR SsidLen; -#ifdef DOT11_N_SUPPORT UCHAR HtLen, AddHtLen, NewExtLen; -#endif // DOT11_N_SUPPORT // HEADER_802_11 ProbeRspHdr; NDIS_STATUS NStatus; PUCHAR pOutBuffer = NULL; @@ -1678,7 +1694,7 @@ VOID PeerProbeReqAction( END_OF_ARGS); FrameLen += tmp; } -#ifdef DOT11_N_SUPPORT + if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) { ULONG TmpLen; @@ -1711,7 +1727,7 @@ VOID PeerProbeReqAction( } FrameLen += TmpLen; } -#endif // DOT11_N_SUPPORT // + MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); MlmeFreeMemory(pAd, pOutBuffer); } @@ -1811,14 +1827,6 @@ VOID InvalidStateWhenStart( VOID EnqueuePsPoll( IN PRTMP_ADAPTER pAd) { -#ifdef RALINK_ATE - if (ATE_ON(pAd)) - { - return; - } -#endif // RALINK_ATE // - - if (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeLegacy_PSP) pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE; MiniportMMRequest(pAd, 0, (PUCHAR)&pAd->PsPollFrame, sizeof(PSPOLL_FRAME)); @@ -1861,88 +1869,6 @@ VOID EnqueueProbeRequest( } -#ifdef DOT11_N_SUPPORT -#ifdef DOT11N_DRAFT3 -VOID BuildEffectedChannelList( - IN PRTMP_ADAPTER pAd) -{ - UCHAR EChannel[11]; - UCHAR i, j, k; - UCHAR UpperChannel = 0, LowerChannel = 0; - - RTMPZeroMemory(EChannel, 11); - i = 0; - // Find upper channel and lower channel. - if (pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) - { - UpperChannel = pAd->CommonCfg.Channel; - LowerChannel = pAd->CommonCfg.CentralChannel; - } - else if (pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) - { - UpperChannel = pAd->CommonCfg.CentralChannel; - LowerChannel = pAd->CommonCfg.Channel; - } - else - { - return; - } - - // Record channels that is below lower channel.. - if (LowerChannel > 1) - { - EChannel[0] = LowerChannel - 1; - i = 1; - if (LowerChannel > 2) - { - EChannel[1] = LowerChannel - 2; - i = 2; - if (LowerChannel > 3) - { - EChannel[2] = LowerChannel - 3; - i = 3; - } - } - } - // Record channels that is between lower channel and upper channel. - for (k = LowerChannel;k < UpperChannel;k++) - { - EChannel[i] = k; - i++; - } - // Record channels that is above upper channel.. - if (LowerChannel < 11) - { - EChannel[i] = UpperChannel + 1; - i++; - if (LowerChannel < 10) - { - EChannel[i] = LowerChannel + 2; - i++; - if (LowerChannel < 9) - { - EChannel[i] = LowerChannel + 3; - i++; - } - } - } - // - for (j = 0;j < i;j++) - { - for (k = 0;k < pAd->ChannelListNum;k++) - { - if (pAd->ChannelList[k].Channel == EChannel[j]) - { - pAd->ChannelList[k].bEffectedChannel = TRUE; - DBGPRINT(RT_DEBUG_TRACE,(" EffectedChannel( =%d)\n", EChannel[j])); - break; - } - } - } -} -#endif // DOT11N_DRAFT3 // -#endif // DOT11_N_SUPPORT // - BOOLEAN ScanRunning( IN PRTMP_ADAPTER pAd) { diff --git a/drivers/staging/rt2860/sta/wpa.c b/drivers/staging/rt2860/sta/wpa.c index 2609d845fd5..58274364d78 100644 --- a/drivers/staging/rt2860/sta/wpa.c +++ b/drivers/staging/rt2860/sta/wpa.c @@ -1384,10 +1384,12 @@ VOID WpaGroupMsg1Action( pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP; else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled) pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES; +#ifndef RT30xx else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled) pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64; else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled) pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128; +#endif //hex_dump("Group Key :", pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, LEN_TKIP_EK); } @@ -1764,7 +1766,12 @@ BOOLEAN ParseKeyData( // Get GTK length - refer to IEEE 802.11i-2004 p.82 GTKLEN = pKDE->Len -6; +#ifdef RT30xx + if (GTKLEN < LEN_AES_KEY) +#endif +#ifndef RT30xx if (GTKLEN < MIN_LEN_OF_GTK) +#endif { DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN)); return FALSE; @@ -1790,10 +1797,12 @@ BOOLEAN ParseKeyData( pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP; else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled) pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES; +#ifndef RT30xx else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled) pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64; else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled) pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128; +#endif return TRUE; @@ -1915,8 +1924,6 @@ VOID RTMPReportMicError( } } - -#ifdef WPA_SUPPLICANT_SUPPORT #define LENGTH_EAP_H 4 // If the received frame is EAP-Packet ,find out its EAP-Code (Request(0x01), Response(0x02), Success(0x03), Failure(0x04)). INT WpaCheckEapCode( @@ -1957,7 +1964,6 @@ VOID WpaSendMicFailureToWpaSupplicant( return; } -#endif // WPA_SUPPLICANT_SUPPORT // VOID WpaMicFailureReportFrame( IN PRTMP_ADAPTER pAd, |