aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/rt3090/sta
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/rt3090/sta')
-rw-r--r--drivers/staging/rt3090/sta/assoc.c1673
-rw-r--r--drivers/staging/rt3090/sta/auth.c491
-rw-r--r--drivers/staging/rt3090/sta/auth_rsp.c151
-rw-r--r--drivers/staging/rt3090/sta/connect.c2759
-rw-r--r--drivers/staging/rt3090/sta/dls.c2207
-rw-r--r--drivers/staging/rt3090/sta/rtmp_ckipmic.c579
-rw-r--r--drivers/staging/rt3090/sta/rtmp_data.c2661
-rw-r--r--drivers/staging/rt3090/sta/sanity.c382
-rw-r--r--drivers/staging/rt3090/sta/sync.c1840
-rw-r--r--drivers/staging/rt3090/sta/wpa.c396
10 files changed, 0 insertions, 13139 deletions
diff --git a/drivers/staging/rt3090/sta/assoc.c b/drivers/staging/rt3090/sta/assoc.c
deleted file mode 100644
index 012ed2b06083..000000000000
--- a/drivers/staging/rt3090/sta/assoc.c
+++ /dev/null
@@ -1,1673 +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:
- assoc.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-9-3 porting from RT2500
-*/
-
-#include "../rt_config.h"
-
-
-UCHAR CipherWpaTemplate[] = {
- 0xdd, // WPA IE
- 0x16, // Length
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x01 // authentication
- };
-
-UCHAR CipherWpa2Template[] = {
- 0x30, // RSN IE
- 0x14, // Length
- 0x01, 0x00, // Version
- 0x00, 0x0f, 0xac, 0x02, // group cipher, TKIP
- 0x01, 0x00, // number of pairwise
- 0x00, 0x0f, 0xac, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x0f, 0xac, 0x02, // authentication
- 0x00, 0x00, // RSN capability
- };
-
-UCHAR Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02};
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID AssocStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG, (STATE_MACHINE_FUNC)Drop, ASSOC_IDLE, ASSOC_MACHINE_BASE);
-
- // first column
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)MlmeAssocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)MlmeReassocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)MlmeDisassocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
-
- // second column
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
- //
- // Patch 3Com AP MOde:3CRWE454G72
- // We send Assoc request frame to this AP, it always send Reassoc Rsp not Associate Rsp.
- //
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_ASSOC_TIMEOUT, (STATE_MACHINE_FUNC)AssocTimeoutAction);
-
- // third column
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
- //
- // Patch, AP doesn't send Reassociate Rsp frame to Station.
- //
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT, (STATE_MACHINE_FUNC)ReassocTimeoutAction);
-
- // fourth column
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT, (STATE_MACHINE_FUNC)DisassocTimeoutAction);
-
- // initialize the timer
- RTMPInitTimer(pAd, &pAd->MlmeAux.AssocTimer, GET_TIMER_FUNCTION(AssocTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.ReassocTimer, GET_TIMER_FUNCTION(ReassocTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.DisassocTimer, GET_TIMER_FUNCTION(DisassocTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- Association timeout procedure. After association timeout, this function
- will be called and it will put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL);
- RTMP_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Reassociation timeout procedure. After reassociation timeout, this
- function will be called and put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ReassocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL);
- RTMP_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Disassociation timeout procedure. After disassociation timeout, this
- function will be called and put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID DisassocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL);
- RTMP_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- mlme assoc req handling procedure
- Parameters:
- Adapter - Adapter pointer
- Elem - MLME Queue Element
- Pre:
- the station has been authenticated and the following information is stored in the config
- -# SSID
- -# supported rates and their length
- -# listen interval (Adapter->StaCfg.default_listen_count)
- -# Transmit power (Adapter->StaCfg.tx_power)
- Post :
- -# An association request frame is generated and sent to the air
- -# Association timer starts
- -# Association state -> ASSOC_WAIT_RSP
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeAssocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR ApAddr[6];
- HEADER_802_11 AssocHdr;
- UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
- USHORT ListenIntv;
- ULONG Timeout;
- USHORT CapabilityInfo;
- BOOLEAN TimerCancelled;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- ULONG tmp;
- USHORT VarIesOffset;
- USHORT Status;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block Assoc request durning WPA block period!\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
- // check sanity first
- else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
- {
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
- // Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- return;
- }
-
- // Add by James 03/06/27
- pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
- // Association don't need to report MAC address
- pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs =
- NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL;
- pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities = CapabilityInfo;
- pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;
- // Only reassociate need this
- //COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr);
- pAd->StaCfg.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
-
- NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
- // First add SSID
- VarIesOffset = 0;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SsidLen, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- VarIesOffset += pAd->MlmeAux.SsidLen;
-
- // Second add Supported rates
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SupRateLen, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen);
- VarIesOffset += pAd->MlmeAux.SupRateLen;
- // End Add by James
-
- if ((pAd->CommonCfg.Channel > 14) &&
- (pAd->CommonCfg.bIEEE80211H == TRUE))
- CapabilityInfo |= 0x0100;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n"));
- MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr, ApAddr);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AssocHdr,
- 2, &CapabilityInfo,
- 2, &ListenIntv,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 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
- // HT
- if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
- {
- HtLen = SIZE_HT_CAP_IE + 4;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- 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)
- // 1. user enable aggregation, AND
- // 2. Mac support piggy-back
- // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
- // Case II: (Aggregation)
- // 1. user enable aggregation, AND
- // 2. AP annouces it's AGGREGATION-capable in BEACON
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- }
- else
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
-
- if (pAd->MlmeAux.APEdcaParm.bValid)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
- {
- QBSS_STA_INFO_PARM QosInfo;
-
- NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
- QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
- QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
- QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
- QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
- QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
- WmeIe[8] |= *(PUCHAR)&QosInfo;
- }
- else
- {
- // The Parameter Set Count is set to ��0�� in the association request frames
- // WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 9, &WmeIe[0],
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- //
- // Let WPA(#221) Element ID on the end of this association frame.
- // Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp.
- // For example: Put Vendor Specific IE on the front of WPA IE.
- // This happens on AP (Model No:Linksys WRK54G)
- //
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
- )
- )
- {
- UCHAR RSNIe = IE_WPA;
-
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
- {
- RSNIe = IE_WPA2;
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if ((pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE) &&
- (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
-#endif // SIOCSIWGENIE //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-
- // Check for WPA PMK cache list
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
- {
- INT idx;
- BOOLEAN FoundPMK = FALSE;
- // Search chched PMKID, append it if existed
- for (idx = 0; idx < PMKID_NO; idx++)
- {
- if (NdisEqualMemory(ApAddr, &pAd->StaCfg.SavedPMK[idx].BSSID, 6))
- {
- FoundPMK = TRUE;
- break;
- }
- }
-
- if (FoundPMK)
- {
- // Set PMK number
- *(PUSHORT) &pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len] = 1;
- NdisMoveMemory(&pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len + 2], &pAd->StaCfg.SavedPMK[idx].PMKID, 16);
- pAd->StaCfg.RSNIE_Len += 18;
- }
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
- (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == TRUE))
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- }
- else
-#endif
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- }
-
- FrameLen += tmp;
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if ((pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE) ||
- (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
-#endif
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- // Append Variable IE
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &RSNIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->StaCfg.RSNIE_Len, 1);
- VarIesOffset += 1;
- }
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
- VarIesOffset += pAd->StaCfg.RSNIE_Len;
-
- // Set Variable IEs Length
- pAd->StaCfg.ReqVarIELen = VarIesOffset;
- }
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- mlme reassoc req handling procedure
- Parameters:
- Elem -
- Pre:
- -# SSID (Adapter->StaCfg.ssid[])
- -# BSSID (AP address, Adapter->StaCfg.bssid)
- -# Supported rates (Adapter->StaCfg.supported_rates[])
- -# Supported rates length (Adapter->StaCfg.supported_rates_len)
- -# Tx power (Adapter->StaCfg.tx_power)
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeReassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR ApAddr[6];
- HEADER_802_11 ReassocHdr;
- UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
- USHORT CapabilityInfo, ListenIntv;
- ULONG Timeout;
- ULONG FrameLen = 0;
- BOOLEAN TimerCancelled;
- NDIS_STATUS NStatus;
- ULONG tmp;
- PUCHAR pOutBuffer = NULL;
- USHORT Status;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block ReAssoc request durning WPA block period!\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- // the parameters are the same as the association
- else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
- {
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- return;
- }
-
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
- // make frame, use bssid as the AP address??
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send RE-ASSOC request...\n"));
- MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0, ApAddr, ApAddr);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &ReassocHdr,
- 2, &CapabilityInfo,
- 2, &ListenIntv,
- MAC_ADDR_LEN, ApAddr,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 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;
- }
-
-
- if (pAd->MlmeAux.APEdcaParm.bValid)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
- {
- QBSS_STA_INFO_PARM QosInfo;
-
- NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
- QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
- QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
- QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
- QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
- QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
- WmeIe[8] |= *(PUCHAR)&QosInfo;
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 9, &WmeIe[0],
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- // HT
- if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
- {
- HtLen = SIZE_HT_CAP_IE + 4;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- 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)
- // 1. user enable aggregation, AND
- // 2. Mac support piggy-back
- // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
- // Case II: (Aggregation)
- // 1. user enable aggregation, AND
- // 2. AP annouces it's AGGREGATION-capable in BEACON
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- }
- else
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */
- pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- Upper layer issues disassoc request
- Parameters:
- Elem -
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PMLME_DISASSOC_REQ_STRUCT pDisassocReq;
- HEADER_802_11 DisassocHdr;
- PHEADER_802_11 pDisassocHdr;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- NDIS_STATUS NStatus;
- BOOLEAN TimerCancelled;
- ULONG Timeout = 500;
- 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);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
- return;
- }
-
-
-
-
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled);
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n",
- pDisassocReq->Addr[0], pDisassocReq->Addr[1], pDisassocReq->Addr[2],
- pDisassocReq->Addr[3], pDisassocReq->Addr[4], pDisassocReq->Addr[5], pDisassocReq->Reason));
- MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr); // patch peap ttls switching issue
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DisassocHdr,
- 2, &pDisassocReq->Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- // To patch Instance and Buffalo(N) AP
- // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
- // Therefore, we send both of them.
- pDisassocHdr = (PHEADER_802_11)pOutBuffer;
- pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;
- COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pDisassocReq->Addr);
-
- 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)
- {
- //send disassociate event to wpa_supplicant
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_DISASSOC_EVENT_FLAG, NULL, NULL, 0);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-}
-
-/*
- ==========================================================================
- Description:
- peer sends assoc rsp back
- Parameters:
- Elme - MLME message containing the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAssocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo, Status, Aid;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
- UCHAR Addr2[MAC_ADDR_LEN];
- BOOLEAN TimerCancelled;
- UCHAR CkipFlag;
- EDCA_PARM EdcaParm;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
- if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
- &HtCapability,&AddHtInfo, &HtCapabilityLen,&AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
- {
- // The frame is for me ?
- 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)
- {
- 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,
- &AddHtInfo,
- AddHtInfoLen,
- CapabilityInfo);
- }
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerAssocRspAction() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
- peer sends reassoc rsp
- Parametrs:
- Elem - MLME message cntaining the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerReassocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo;
- USHORT Status;
- USHORT Aid;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR CkipFlag;
- BOOLEAN TimerCancelled;
- EDCA_PARM EdcaParm;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
- if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
- &HtCapability, &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
- {
- if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ?
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status));
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
-
- if(Status == MLME_SUCCESS)
- {
- // 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)
- {
- SendAssocIEsToWpaSupplicant(pAd);
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_ASSOC_EVENT_FLAG, NULL, NULL, 0);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- wext_notify_event_assoc(pAd);
- RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, &pAd->MlmeAux.Bssid[0], NULL, 0);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
- }
-
- // CkipFlag is no use for reassociate
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerReassocRspAction() sanity check fail\n"));
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- procedures on IEEE 802.11/1999 p.376
- Parametrs:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocPostProc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr2,
- IN USHORT CapabilityInfo,
- IN USHORT Aid,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN PEDCA_PARM pEdcaParm,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN ADD_HT_INFO_IE *pAddHtInfo) // AP might use this additional ht info IE
-{
- ULONG Idx;
-
- pAd->MlmeAux.BssType = BSS_INFRA;
- 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))
- {
- pEdcaParm->bValid = TRUE;
- pEdcaParm->Aifsn[0] = 3;
- pEdcaParm->Aifsn[1] = 7;
- pEdcaParm->Aifsn[2] = 2;
- pEdcaParm->Aifsn[3] = 2;
-
- pEdcaParm->Cwmin[0] = 4;
- pEdcaParm->Cwmin[1] = 4;
- pEdcaParm->Cwmin[2] = 3;
- pEdcaParm->Cwmin[3] = 2;
-
- pEdcaParm->Cwmax[0] = 10;
- pEdcaParm->Cwmax[1] = 10;
- pEdcaParm->Cwmax[2] = 4;
- pEdcaParm->Cwmax[3] = 3;
-
- pEdcaParm->Txop[0] = 0;
- pEdcaParm->Txop[1] = 0;
- pEdcaParm->Txop[2] = 96;
- pEdcaParm->Txop[3] = 48;
-
- }
-#endif // DOT11_N_SUPPORT //
-
- NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM));
-
- // filter out un-supported rates
- pAd->MlmeAux.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
-
- // filter out un-supported rates
- pAd->MlmeAux.ExtRateLen = ExtRateLen;
- 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);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n", pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
- 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);
- if (Idx == BSS_NOT_FOUND)
- {
- DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n"));
- }
- else
- {
- // Init variable
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = 0;
- NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, MAX_LEN_OF_RSNIE);
-
- // Store appropriate RSN_IE for WPA SM negotiation later
- if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0))
- {
- PUCHAR pVIE;
- USHORT len;
- PEID_STRUCT pEid;
-
- pVIE = pAd->ScanTab.BssEntry[Idx].VarIEs;
- len = pAd->ScanTab.BssEntry[Idx].VarIELen;
- //KH need to check again
- // Don't allow to go to sleep mode if authmode is WPA-related.
- //This can make Authentication process more smoothly.
- RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-
- while (len > 0)
- {
- pEid = (PEID_STRUCT) pVIE;
- // For WPA/WPAPSK
- if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
- && (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
- }
- // For WPA2/WPA2PSK
- else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
- && (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
- }
-
- pVIE += (pEid->Len + 2);
- len -= (pEid->Len + 2);
- }
-
-
- }
-
- if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> no RSN_IE \n"));
- }
- else
- {
- hex_dump("RSN_IE", pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- left part of IEEE 802.11/1999 p.374
- Parameters:
- Elem - MLME message containing the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDisassocAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Reason;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n"));
- if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() Reason = %d\n", Reason));
- if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2))
- {
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
-
- 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)
- {
- //send disassociate event to wpa_supplicant
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_DISASSOC_EVENT_FLAG, NULL, NULL, 0);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() sanity check fail\n"));
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after assoc timeout
- Parameters:
- Elme -
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - AssocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after reassoc timeout
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ReassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - ReassocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after disassoc timeout
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID DisassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenAssoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenReassoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenDisassociate(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- right part of IEEE 802.11/1999 page 374
- Note:
- This event should never cause ASSOC state machine perform state
- transition, and has no relationship with CNTL machine. So we separate
- this routine as a service outside of ASSOC state transition table.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID Cls3errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr)
-{
- HEADER_802_11 DisassocHdr;
- PHEADER_802_11 pDisassocHdr;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- NDIS_STATUS NStatus;
- USHORT Reason = REASON_CLS3ERR;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
- MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid); // patch peap ttls switching issue
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DisassocHdr,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- // To patch Instance and Buffalo(N) AP
- // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
- // Therefore, we send both of them.
- pDisassocHdr = (PHEADER_802_11)pOutBuffer;
- pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DisassocReason = REASON_CLS3ERR;
- COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pAddr);
-}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-VOID SendAssocIEsToWpaSupplicant(
- IN PRTMP_ADAPTER pAd)
-{
- STRING 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);
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_REQIE_EVENT_FLAG, NULL, (PUCHAR)custom, pAd->StaCfg.ReqVarIELen + 17);
-
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_ASSOCINFO_EVENT_FLAG, NULL, NULL, 0);
- }
- 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)
-{
- char custom[IW_CUSTOM_MAX] = {0};
-
-#if WIRELESS_EXT > 17
- if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX)
- {
- NdisMoveMemory(custom, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
- RtmpOSWrielessEventSend(pAd, IWEVASSOCREQIE, -1, NULL, custom, pAd->StaCfg.ReqVarIELen);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
-#else
- int len;
-
- len = (pAd->StaCfg.ReqVarIELen*2) + 17;
- if (len <= IW_CUSTOM_MAX)
- {
- UCHAR idx;
- sprintf(custom, "ASSOCINFO(ReqIEs=");
- for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++)
- sprintf(custom, "%s%02x", custom, pAd->StaCfg.ReqVarIEs[idx]);
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, custom, len);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("len(%d) > MAX_CUSTOM_LEN\n", len));
-#endif
-
- return 0;
-
-}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-
-BOOLEAN StaAddMacTableEntry(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN UCHAR MaxSupportedRateIn500Kbps,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN ADD_HT_INFO_IE *pAddHtInfo,
- IN UCHAR AddHtInfoLen,
- 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;
-
-#ifdef DOT11_N_SUPPORT
- // 11n only
- if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G))&& (HtCapabilityLen == 0))
- return FALSE;
-#endif // DOT11_N_SUPPORT //
-
- 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);
- }
-
-#ifdef DOT11_N_SUPPORT
- NdisZeroMemory(&pEntry->HTCapability, sizeof(pEntry->HTCapability));
- // 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) &&
- ((pAd->StaCfg.BssType == BSS_INFRA) || ((pAd->StaCfg.BssType == BSS_ADHOC) && (pAddHtInfo->AddHtInfo.ExtChanOffset == pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset))))
- {
- 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);
- NdisMoveMemory(&pEntry->HTCapability, pHtCapability, HtCapabilityLen);
- }
- else
- {
- pAd->MacTab.fAnyStationIsLegacy = TRUE;
- }
-#endif // DOT11_N_SUPPORT //
-
- 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);
-
-#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);
-
- 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);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- return TRUE;
-}
diff --git a/drivers/staging/rt3090/sta/auth.c b/drivers/staging/rt3090/sta/auth.c
deleted file mode 100644
index 157e2999fa19..000000000000
--- a/drivers/staging/rt3090/sta/auth.c
+++ /dev/null
@@ -1,491 +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:
- auth.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-9-3 porting from RT2500
-*/
-
-#include "../rt_config.h"
-
-
-/*
- ==========================================================================
- Description:
- authenticate state machine init, including state transition and timer init
- Parameters:
- Sm - pointer to the auth state machine
- Note:
- The state machine looks like this
-
- AUTH_REQ_IDLE AUTH_WAIT_SEQ2 AUTH_WAIT_SEQ4
- MT2_MLME_AUTH_REQ mlme_auth_req_action invalid_state_when_auth invalid_state_when_auth
- MT2_PEER_AUTH_EVEN drop peer_auth_even_at_seq2_action peer_auth_even_at_seq4_action
- MT2_AUTH_TIMEOUT Drop auth_timeout_action auth_timeout_action
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-
-void AuthStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_REQ_IDLE, AUTH_MACHINE_BASE);
-
- // the first column
- StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)MlmeAuthReqAction);
-
- // the second column
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq2Action);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-
- // the third column
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq4Action);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-
- RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer, GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- function to be executed at timer thread when auth timer expires
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- DBGPRINT(RT_DEBUG_TRACE,("AUTH - AuthTimeout\n"));
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- // send a de-auth to reset AP's state machine (Patch AP-Dir635)
- if (pAd->Mlme.AuthMachine.CurrState == AUTH_WAIT_SEQ2)
- Cls2errAction(pAd, pAd->MlmeAux.Bssid);
-
-
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
- RTMP_MLME_HANDLER(pAd);
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeAuthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- if (AUTH_ReqSend(pAd, Elem, &pAd->MlmeAux.AuthTimer, "AUTH", 1, NULL, 0))
- pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
- else
- {
- USHORT Status;
-
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAuthRspAtSeq2Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Seq, Status, RemoteStatus, Alg;
- UCHAR ChlgText[CIPHER_TEXT_LEN];
- UCHAR CyperChlgText[CIPHER_TEXT_LEN + 8 + 8];
- UCHAR Element[2];
- HEADER_802_11 AuthHdr;
- BOOLEAN TimerCancelled;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Status2;
-
- if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, (PCHAR)ChlgText))
- {
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n", Alg, Status));
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-
- if (Status == MLME_SUCCESS)
- {
- // Authentication Mode "LEAP" has allow for CCX 1.X
- if (pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen)
- {
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- else
- {
- // 2. shared key, need to be challenged
- Seq++;
- RemoteStatus = MLME_SUCCESS;
-
- // Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status2 = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status2);
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#3...\n"));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr2, pAd->MlmeAux.Bssid);
- AuthHdr.FC.Wep = 1;
- // Encrypt challenge text & auth information
- RTMPInitWepEngine(
- pAd,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen,
- CyperChlgText);
-
- Alg = cpu2le16(*(USHORT *)&Alg);
- Seq = cpu2le16(*(USHORT *)&Seq);
- RemoteStatus= cpu2le16(*(USHORT *)&RemoteStatus);
-
- RTMPEncryptData(pAd, (PUCHAR) &Alg, CyperChlgText + 4, 2);
- RTMPEncryptData(pAd, (PUCHAR) &Seq, CyperChlgText + 6, 2);
- RTMPEncryptData(pAd, (PUCHAR) &RemoteStatus, CyperChlgText + 8, 2);
- Element[0] = 16;
- Element[1] = 128;
- RTMPEncryptData(pAd, Element, CyperChlgText + 10, 2);
- RTMPEncryptData(pAd, ChlgText, CyperChlgText + 12, 128);
- RTMPSetICV(pAd, CyperChlgText + 140);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AuthHdr,
- CIPHER_TEXT_LEN + 16, CyperChlgText,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AuthTimer, AUTH_TIMEOUT);
- pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ4;
- }
- }
- else
- {
- pAd->StaCfg.AuthFailReason = Status;
- COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthSanity() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAuthRspAtSeq4Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Alg, Seq, Status;
- CHAR ChlgText[CIPHER_TEXT_LEN];
- BOOLEAN TimerCancelled;
-
- if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
- {
- if(MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#4 to me\n"));
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-
- if (Status != MLME_SUCCESS)
- {
- pAd->StaCfg.AuthFailReason = Status;
- COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
- }
-
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq4Action() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DEAUTH_REQ_STRUCT *pInfo;
- HEADER_802_11 DeauthHdr;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Status;
-
- pInfo = (MLME_DEAUTH_REQ_STRUCT *)Elem->Msg;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
- return;
- }
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send DE-AUTH request (Reason=%d)...\n", pInfo->Reason));
- MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DeauthHdr,
- 2, &pInfo->Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DeauthReason = pInfo->Reason;
- COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
-
- // send wireless event - for deauthentication
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AuthTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID InvalidStateWhenAuth(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n", pAd->Mlme.AuthMachine.CurrState));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- Some STA/AP
- Note:
- This action should never trigger AUTH state transition, therefore we
- separate it from AUTH state machine, and make it as a standalone service
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID Cls2errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr)
-{
- HEADER_802_11 DeauthHdr;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Reason = REASON_CLS2ERR;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Class 2 error, Send DEAUTH frame...\n"));
- MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DeauthHdr,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DeauthReason = Reason;
- COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pAddr);
-}
-
-BOOLEAN AUTH_ReqSend(
- IN PRTMP_ADAPTER pAd,
- IN PMLME_QUEUE_ELEM pElem,
- IN PRALINK_TIMER_STRUCT pAuthTimer,
- IN PSTRING pSMName,
- IN USHORT SeqNo,
- IN PUCHAR pNewElement,
- IN ULONG ElementLen)
-{
- USHORT Alg, Seq, Status;
- UCHAR Addr[6];
- ULONG Timeout;
- HEADER_802_11 AuthHdr;
- BOOLEAN TimerCancelled;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0, tmp = 0;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s - Block Auth request durning WPA block period!\n", pSMName));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- else if(MlmeAuthReqSanity(pAd, pElem->Msg, pElem->MsgLen, Addr, &Timeout, &Alg))
- {
- /* reset timer */
- RTMPCancelTimer(pAuthTimer, &TimerCancelled);
-
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
- pAd->MlmeAux.Alg = Alg;
- Seq = SeqNo;
- Status = MLME_SUCCESS;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s - MlmeAuthReqAction(Alg:%d) allocate memory failed\n", pSMName, Alg));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- return FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s - Send AUTH request seq#1 (Alg=%d)...\n", pSMName, Alg));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&AuthHdr,
- 2, &Alg,
- 2, &Seq,
- 2, &Status,
- END_OF_ARGS);
-
- if (pNewElement && ElementLen)
- {
- MakeOutgoingFrame(pOutBuffer+FrameLen, &tmp,
- ElementLen, pNewElement,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(pAuthTimer, Timeout);
- return TRUE;
- }
- else
- {
- DBGPRINT_ERR(("%s - MlmeAuthReqAction() sanity check failed\n", pSMName));
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/drivers/staging/rt3090/sta/auth_rsp.c b/drivers/staging/rt3090/sta/auth_rsp.c
deleted file mode 100644
index 207bfeada1e4..000000000000
--- a/drivers/staging/rt3090/sta/auth_rsp.c
+++ /dev/null
@@ -1,151 +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:
- auth_rsp.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-10-1 copy from RT2560
-*/
-
-#include "../rt_config.h"
-
-
-/*
- ==========================================================================
- Description:
- authentication state machine init procedure
- Parameters:
- Sm - the state machine
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID AuthRspStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE Sm,
- IN STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_RSP_IDLE, AUTH_RSP_MACHINE_BASE);
-
- // column 1
- StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
-
- // column 2
- StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
-
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID PeerAuthSimpleRspGenAndSend(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHdr80211,
- IN USHORT Alg,
- IN USHORT Seq,
- IN USHORT Reason,
- IN USHORT Status)
-{
- HEADER_802_11 AuthHdr;
- ULONG FrameLen = 0;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
-
- if (Reason != MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
- return;
- }
-
- //Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AuthHdr,
- 2, &Alg,
- 2, &Seq,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID PeerDeauthAction(
- IN PRTMP_ADAPTER pAd,
- IN PMLME_QUEUE_ELEM Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Reason;
-
- if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
- {
- if (INFRA_ON(pAd)
- && MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid)
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n", Reason));
-
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
-#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);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
- }
-}
diff --git a/drivers/staging/rt3090/sta/connect.c b/drivers/staging/rt3090/sta/connect.c
deleted file mode 100644
index 4aa35ee3ade1..000000000000
--- a/drivers/staging/rt3090/sta/connect.c
+++ /dev/null
@@ -1,2759 +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:
- connect.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-08-08 Major modification from RT2560
-*/
-
-#include "../rt_config.h"
-
-
-UCHAR CipherSuiteWpaNoneTkip[] = {
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x00 // authentication
- };
-UCHAR CipherSuiteWpaNoneTkipLen = (sizeof(CipherSuiteWpaNoneTkip) / sizeof(UCHAR));
-
-UCHAR CipherSuiteWpaNoneAes[] = {
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x04, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x04, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x00 // authentication
- };
-UCHAR CipherSuiteWpaNoneAesLen = (sizeof(CipherSuiteWpaNoneAes) / sizeof(UCHAR));
-
-// The following MACRO is called after 1. starting an new IBSS, 2. succesfully JOIN an IBSS,
-// or 3. succesfully ASSOCIATE to a BSS, 4. successfully RE_ASSOCIATE to a BSS
-// All settings successfuly negotiated furing MLME state machines become final settings
-// and are copied to pAd->StaActive
-#define COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
-{ \
- NdisZeroMemory((_pAd)->CommonCfg.Ssid, MAX_LEN_OF_SSID); \
- (_pAd)->CommonCfg.SsidLen = (_pAd)->MlmeAux.SsidLen; \
- NdisMoveMemory((_pAd)->CommonCfg.Ssid, (_pAd)->MlmeAux.Ssid, (_pAd)->MlmeAux.SsidLen); \
- COPY_MAC_ADDR((_pAd)->CommonCfg.Bssid, (_pAd)->MlmeAux.Bssid); \
- (_pAd)->CommonCfg.Channel = (_pAd)->MlmeAux.Channel; \
- (_pAd)->CommonCfg.CentralChannel = (_pAd)->MlmeAux.CentralChannel; \
- (_pAd)->StaActive.Aid = (_pAd)->MlmeAux.Aid; \
- (_pAd)->StaActive.AtimWin = (_pAd)->MlmeAux.AtimWin; \
- (_pAd)->StaActive.CapabilityInfo = (_pAd)->MlmeAux.CapabilityInfo; \
- (_pAd)->CommonCfg.BeaconPeriod = (_pAd)->MlmeAux.BeaconPeriod; \
- (_pAd)->StaActive.CfpMaxDuration = (_pAd)->MlmeAux.CfpMaxDuration; \
- (_pAd)->StaActive.CfpPeriod = (_pAd)->MlmeAux.CfpPeriod; \
- (_pAd)->StaActive.SupRateLen = (_pAd)->MlmeAux.SupRateLen; \
- NdisMoveMemory((_pAd)->StaActive.SupRate, (_pAd)->MlmeAux.SupRate, (_pAd)->MlmeAux.SupRateLen);\
- (_pAd)->StaActive.ExtRateLen = (_pAd)->MlmeAux.ExtRateLen; \
- NdisMoveMemory((_pAd)->StaActive.ExtRate, (_pAd)->MlmeAux.ExtRate, (_pAd)->MlmeAux.ExtRateLen);\
- NdisMoveMemory(&(_pAd)->CommonCfg.APEdcaParm, &(_pAd)->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));\
- NdisMoveMemory(&(_pAd)->CommonCfg.APQosCapability, &(_pAd)->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));\
- NdisMoveMemory(&(_pAd)->CommonCfg.APQbssLoad, &(_pAd)->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));\
- COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].Addr, (_pAd)->MlmeAux.Bssid); \
- (_pAd)->MacTab.Content[BSSID_WCID].Aid = (_pAd)->MlmeAux.Aid; \
- (_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = (_pAd)->StaCfg.PairCipher;\
- COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.BssId, (_pAd)->MlmeAux.Bssid);\
- (_pAd)->MacTab.Content[BSSID_WCID].RateLen = (_pAd)->StaActive.SupRateLen + (_pAd)->StaActive.ExtRateLen;\
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
-*/
-VOID MlmeCntlInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- // Control state machine differs from other state machines, the interface
- // follows the standard interface
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID MlmeCntlMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem)
-{
- switch(pAd->Mlme.CntlMachine.CurrState)
- {
- case CNTL_IDLE:
- CntlIdleProc(pAd, Elem);
- break;
- case CNTL_WAIT_DISASSOC:
- CntlWaitDisassocProc(pAd, Elem);
- break;
- case CNTL_WAIT_JOIN:
- CntlWaitJoinProc(pAd, Elem);
- break;
-
- // CNTL_WAIT_REASSOC is the only state in CNTL machine that does
- // not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
- // Therefore not protected by NDIS's "only one outstanding OID request"
- // rule. Which means NDIS may SET OID in the middle of ROAMing attempts.
- // Current approach is to block new SET request at RTMPSetInformation()
- // when CntlMachine.CurrState is not CNTL_IDLE
- case CNTL_WAIT_REASSOC:
- CntlWaitReassocProc(pAd, Elem);
- break;
-
- case CNTL_WAIT_START:
- CntlWaitStartProc(pAd, Elem);
- break;
- case CNTL_WAIT_AUTH:
- CntlWaitAuthProc(pAd, Elem);
- break;
- case CNTL_WAIT_AUTH2:
- CntlWaitAuthProc2(pAd, Elem);
- break;
- case CNTL_WAIT_ASSOC:
- CntlWaitAssocProc(pAd, Elem);
- break;
-
- case CNTL_WAIT_OID_LIST_SCAN:
- 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);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
- //
- // Set LED status to previous status.
- //
- if (pAd->bLedOnScanning)
- {
- 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;
-
- case CNTL_WAIT_OID_DISASSOC:
- if (Elem->MsgType == MT2_DISASSOC_CONF)
- {
- LinkDown(pAd, FALSE);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
- break;
- default:
- DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", Elem->MsgType));
- break;
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlIdleProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- return;
-
- switch(Elem->MsgType)
- {
- case OID_802_11_SSID:
- CntlOidSsidProc(pAd, Elem);
- break;
-
- case OID_802_11_BSSID:
- CntlOidRTBssidProc(pAd,Elem);
- break;
-
- case OID_802_11_BSSID_LIST_SCAN:
- CntlOidScanProc(pAd,Elem);
- break;
-
- case OID_802_11_DISASSOCIATE:
- 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.
- pAd->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
- }
- break;
-
- case MT2_MLME_ROAMING_REQ:
- CntlMlmeRoamingProc(pAd, Elem);
- break;
-
- case OID_802_11_MIC_FAILURE_REPORT_FRAME:
- 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;
- }
-}
-
-VOID CntlOidScanProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_SCAN_REQ_STRUCT ScanReq;
- 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))
- {
- BssIdx = BssSsidTableSearch(&pAd->ScanTab, pAd->CommonCfg.Bssid, (PUCHAR)pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->CommonCfg.Channel);
- if (BssIdx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(&CurrBss, &pAd->ScanTab.BssEntry[BssIdx], sizeof(BSS_ENTRY));
- }
- }
-
- // clean up previous SCAN result, add current BSS back to table if any
- BssTableInit(&pAd->ScanTab);
- if (BssIdx != BSS_NOT_FOUND)
- {
- // DDK Note: If the NIC is associated with a particular BSSID and SSID
- // that are not contained in the list of BSSIDs generated by this scan, the
- // BSSID description of the currently associated BSSID and SSID should be
- // appended to the list of BSSIDs in the NIC's database.
- // To ensure this, we append this BSS as the first entry in SCAN result
- NdisMoveMemory(&pAd->ScanTab.BssEntry[0], &CurrBss, sizeof(BSS_ENTRY));
- pAd->ScanTab.BssNr = 1;
- }
-
- ScanParmFill(pAd, &ScanReq, (PSTRING) Elem->Msg, Elem->MsgLen, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
- sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-}
-
-/*
- ==========================================================================
- Description:
- Before calling this routine, user desired SSID should already been
- recorded in CommonCfg.Ssid[]
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidSsidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem)
-{
- PNDIS_802_11_SSID pOidSsid = (NDIS_802_11_SSID *)Elem->Msg;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
- ULONG Now;
-
-
- // Step 1. record the desired user settings to MlmeAux
- NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, pOidSsid->Ssid, pOidSsid->SsidLength);
- pAd->MlmeAux.SsidLen = (UCHAR)pOidSsid->SsidLength;
- NdisZeroMemory(pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
-
- pAd->StaCfg.bAutoConnectByBssid = FALSE;
-
- //
- // Update Reconnect Ssid, that user desired to connect.
- //
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
-
- // step 2. find all matching BSS in the lastest SCAN result (inBssTab)
- // & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order
- BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, (PCHAR)pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - %d BSS of %d BSS match the desire (%d)SSID - %s\n",
- pAd->MlmeAux.SsidBssTab.BssNr, pAd->ScanTab.BssNr, pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid));
- NdisGetSystemUpTime(&Now);
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
- (pAd->CommonCfg.SsidLen == pAd->MlmeAux.SsidBssTab.BssEntry[0].SsidLen) &&
- NdisEqualMemory(pAd->CommonCfg.Ssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Ssid, pAd->CommonCfg.SsidLen) &&
- MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Bssid))
- {
- // Case 1. already connected with an AP who has the desired SSID
- // with highest RSSI
-
- // Add checking Mode "LEAP" for CCX 1.0
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- ) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- // case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
- // connection process
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
- 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_DISASSOC;
- }
- else if (pAd->bConfigChanged == TRUE)
- {
- // case 1.2 Important Config has changed, we have to reconnect to the same AP
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n"));
- 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_DISASSOC;
- }
- else
- {
- // case 1.3. already connected to the SSID with highest RSSI.
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n"));
- //
- // (HCT 12.1) 1c_wlan_mediaevents required
- // media connect events are indicated when associating with the same AP
- //
- if (INFRA_ON(pAd))
- {
- //
- // Since MediaState already is NdisMediaStateConnected
- // We just indicate the connect event again to meet the WHQL required.
- //
- pAd->IndicateMediaState = NdisMediaStateConnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_UP; // Update extra information to link is up
- }
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, &pAd->MlmeAux.Bssid[0], NULL, 0);
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- }
- else if (INFRA_ON(pAd))
- {
- //
- // For RT61
- // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
- // RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect
- // But media status is connected, so the SSID not report correctly.
- //
- if (!SSID_EQUAL(pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen))
- {
- //
- // Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event.
- //
- pAd->MlmeAux.CurrReqIsFromNdis = TRUE;
- }
- // case 2. active INFRA association existent
- // roaming is done within miniport driver, nothing to do with configuration
- // utility. so upon a new SET(OID_802_11_SSID) is received, we just
- // disassociate with the current associated AP,
- // then perform a new association with this new SSID, no matter the
- // new/old SSID are the same or not.
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
- 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_DISASSOC;
- }
- else
- {
- if (ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - drop current ADHOC\n"));
- LinkDown(pAd, FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
- }
-
- if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) &&
- (pAd->StaCfg.bAutoReconnect == TRUE) &&
- (pAd->MlmeAux.BssType == BSS_INFRA) &&
- (MlmeValidateSSID(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen) == TRUE)
- )
- {
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - No matching BSS, start a new scan\n"));
- ScanParmFill(pAd, &ScanReq, (PSTRING) pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- // Reset Missed scan number
- pAd->StaCfg.LastScanTime = Now;
- }
- else
- {
-
- pAd->MlmeAux.BssIdx = 0;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidRTBssidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem)
-{
- ULONG BssIdx;
- PUCHAR pOidBssid = (PUCHAR)Elem->Msg;
- 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;
-
- // find the desired BSS in the latest SCAN result table
- BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel);
- if (BssIdx == BSS_NOT_FOUND)
- {
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
- //pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - BSSID not found. start a new scan\n"));
- ScanParmFill(pAd, &ScanReq, (PSTRING) pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- // Reset Missed scan number
- NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime);
- return;
- }
-
- //
- // Update Reconnect Ssid, that user desired to connect.
- //
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->ScanTab.BssEntry[BssIdx].SsidLen);
-
- // copy the matched BSS entry from ScanTab to MlmeAux.SsidBssTab. Why?
- // Because we need this entry to become the JOIN target in later on SYNC state machine
- pAd->MlmeAux.BssIdx = 0;
- pAd->MlmeAux.SsidBssTab.BssNr = 1;
- NdisMoveMemory(&pAd->MlmeAux.SsidBssTab.BssEntry[0], &pAd->ScanTab.BssEntry[BssIdx], sizeof(BSS_ENTRY));
-
- // Add SSID into MlmeAux for site surey joining hidden SSID
- pAd->MlmeAux.SsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
- NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->MlmeAux.SsidLen);
-
- {
- if (INFRA_ON(pAd))
- {
- // disassoc from current AP first
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - disassociate with current AP ...\n"));
- 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_DISASSOC;
- }
- else
- {
- if (ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - drop current ADHOC\n"));
- LinkDown(pAd, FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
- }
-
- // Change the wepstatus to original wepstatus
- pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
- // Check cipher suite, AP must have more secured cipher than station setting
- // Set the Pairwise and Group cipher to match the intended AP setting
- // We can only connect to AP with less secured cipher setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher;
- else if (pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher;
- else if (pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
-
- // RSN capability
- pAd->StaCfg.RsnCapability = pAd->ScanTab.BssEntry[BssIdx].WPA2.RsnCapability;
- }
-
- // Set Mix cipher flag
- pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
- /*if (pAd->StaCfg.bMixCipher == TRUE)
- {
- // If mix cipher, re-build RSNIE
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- }*/
- // No active association, join the BSS immediately
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pOidBssid[0],pOidBssid[1],pOidBssid[2],pOidBssid[3],pOidBssid[4],pOidBssid[5]));
-
- JoinParmFill(pAd, &JoinReq, pAd->MlmeAux.BssIdx);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, sizeof(MLME_JOIN_REQ_STRUCT), &JoinReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
- }
- }
-}
-
-// Roaming is the only external request triggering CNTL state machine
-// despite of other "SET OID" operation. All "SET OID" related oerations
-// happen in sequence, because no other SET OID will be sent to this device
-// until the the previous SET operation is complete (successful o failed).
-// So, how do we quarantee this ROAMING request won't corrupt other "SET OID"?
-// or been corrupted by other "SET OID"?
-//
-// IRQL = DISPATCH_LEVEL
-VOID CntlMlmeRoamingProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR BBPValue = 0;
-
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - Roaming in MlmeAux.RoamTab...\n"));
-
- {
- //Let BBP register at 20MHz to do (fast) roaming.
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
- NdisMoveMemory(&pAd->MlmeAux.SsidBssTab, &pAd->MlmeAux.RoamTab, sizeof(pAd->MlmeAux.RoamTab));
- pAd->MlmeAux.SsidBssTab.BssNr = pAd->MlmeAux.RoamTab.BssNr;
-
- BssTableSortByRssi(&pAd->MlmeAux.SsidBssTab);
- pAd->MlmeAux.BssIdx = 0;
- 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:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitDisassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_START_REQ_STRUCT StartReq;
-
- if (Elem->MsgType == MT2_DISASSOC_CONF)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Dis-associate successful\n"));
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
- LinkDown(pAd, FALSE);
-
- // case 1. no matching BSS, and user wants ADHOC, so we just start a new one
- if ((pAd->MlmeAux.SsidBssTab.BssNr==0) && (pAd->StaCfg.BssType == BSS_ADHOC))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd->MlmeAux.Ssid));
- StartParmFill(pAd, &StartReq, (PCHAR)pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
- // case 2. try each matched BSS
- else
- {
- pAd->MlmeAux.BssIdx = 0;
-
- IterateOnBssTab(pAd);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitJoinProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_JOIN_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- // 1. joined an IBSS, we are pretty much done here
- if (pAd->MlmeAux.BssType == BSS_ADHOC)
- {
- //
- // 5G bands rules of Japan:
- // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
- //
- if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
- RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
- )
- {
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel));
- return;
- }
-
- LinkUp(pAd, BSS_ADHOC);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- }
- // 2. joined a new INFRA network, start from authentication
- else
- {
- {
- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, AUTH_MODE_KEY);
- }
- else
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, AUTH_MODE_OPEN);
- }
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
- }
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH;
- }
- }
- else
- {
- // 3. failed, try next BSS
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitStartProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Result;
-
- if (Elem->MsgType == MT2_START_CONF)
- {
- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
- if (Result == MLME_SUCCESS)
- {
- //
- // 5G bands rules of Japan:
- // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
- //
- if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
- RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
- )
- {
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- 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
- NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- N_ChannelCheck(pAd);
- SetCommonHT(pAd);
- NdisMoveMemory(&pAd->MlmeAux.AddHtInfo, &pAd->CommonCfg.AddHTInfo, sizeof(ADD_HT_INFO_IE));
- RTMPCheckHt(pAd, BSSID_WCID, &pAd->CommonCfg.HtCapability, &pAd->CommonCfg.AddHTInfo);
- pAd->StaActive.SupportedPhyInfo.bHtEnable = TRUE;
- NdisMoveMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], &pAd->CommonCfg.HtCapability.MCSSet[0], 16);
- COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-
- if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE))
- {
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel + 2;
- }
- else if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW))
- {
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel - 2;
- }
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- }
- LinkUp(pAd, BSS_ADHOC);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- // Before send beacon, driver need do radar detection
- if ((pAd->CommonCfg.Channel > 14 )
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- 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",
- pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Start IBSS fail. BUG!!!!!\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAuthProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_ASSOC_REQ_STRUCT AssocReq;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_AUTH_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
- AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
-
- {
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
- }
- }
- else
- {
- // This fail may because of the AP already keep us in its MAC table without
- // 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"));
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
- {
- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, AUTH_MODE_KEY);
- }
- else
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, AUTH_MODE_OPEN);
- }
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- }
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAuthProc2(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_ASSOC_REQ_STRUCT AssocReq;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_AUTH_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
- AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
- {
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
- }
- }
- else
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) &&
- (pAd->MlmeAux.Alg == Ndis802_11AuthModeShared))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try OPEN system...\n"));
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
- }
- else
- {
- // not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, give up; try next BSS\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; //???????
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAssocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
-
- if (Elem->MsgType == MT2_ASSOC_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
- LinkUp(pAd, BSS_INFRA);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association successful on BSS #%ld\n",pAd->MlmeAux.BssIdx));
- }
- else
- {
- // not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association fails on BSS #%ld\n",pAd->MlmeAux.BssIdx));
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitReassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Result;
-
- if (Elem->MsgType == MT2_REASSOC_CONF)
- {
- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
- if (Result == MLME_SUCCESS)
- {
- // send wireless event - for association
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- //
- // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
- //
- LinkUp(pAd, BSS_INFRA);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
- }
- else
- {
- // reassoc failed, try to pick next BSS in the BSS Table
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition fails on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
- {
- pAd->MlmeAux.RoamIdx++;
- IterateOnBssTab2(pAd);
- }
- }
- }
-}
-
-
-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);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID LinkUp(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssType)
-{
- ULONG Now;
- UINT32 Data;
- BOOLEAN Cancelled;
- UCHAR Value = 0, idx = 0, HashIdx = 0;
- MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry = NULL;
-
- // Init ChannelQuality to prevent DEAD_CQI at initial LinkUp
- pAd->Mlme.ChannelQuality = 50;
-
- pEntry = MacTableLookup(pAd, pAd->CommonCfg.Bssid);
- if (pEntry)
- {
- MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
- pEntry = NULL;
- }
-
-
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
-
- //
- // ASSOC - DisassocTimeoutAction
- // CNTL - Dis-associate successful
- // !!! LINK DOWN !!!
- // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
- //
- // To prevent DisassocTimeoutAction to call Link down after we link up,
- // cancel the DisassocTimer no matter what it start or not.
- //
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
-
- 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 //
-
-#ifdef RTMP_MAC_PCI
- // 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);
- if(pAd->Antenna.field.RxPath == 3)
- {
- Value |= (0x10);
- }
- else if(pAd->Antenna.field.RxPath == 2)
- {
- Value |= (0x8);
- }
- else if(pAd->Antenna.field.RxPath == 1)
- {
- Value |= (0x0);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
- pAd->StaCfg.BBPR3 = Value;
-#endif // RTMP_MAC_PCI //
-
- 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 DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- AdhocTurnOnQos(pAd);
-#endif // DOT11_N_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!Adhoc LINK UP !!! \n" ));
- }
- else
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!Infra LINK UP !!! \n" ));
- }
-
- // 3*3
- // reset Tx beamforming bit
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x01);
- 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))
- {
- // Must using 40MHz.
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- Value |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- // RX : control channel at lower
- 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 RTMP_MAC_PCI
- pAd->StaCfg.BBPR3 = Value;
-#endif // RTMP_MAC_PCI //
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data &= 0xfffffffe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- // Must using 40MHz.
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- Value |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data |= 0x1;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- 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 RTMP_MAC_PCI
- pAd->StaCfg.BBPR3 = Value;
-#endif // RTMP_MAC_PCI //
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- 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;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data &= 0xfffffffe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- 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 RTMP_MAC_PCI
- pAd->StaCfg.BBPR3 = Value;
-#endif // RTMP_MAC_PCI //
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! 20MHz LINK UP !!! \n" ));
- }
-
- RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);
- //
- // Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission
- //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);
-
- 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);
-
- AsicSetSlotTime(pAd, TRUE);
- AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
-
- // 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.
- if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, TRUE);
- }
- else
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
- }
-#endif // DOT11_N_SUPPORT //
-
- NdisZeroMemory(&pAd->DrsCounters, sizeof(COUNTER_DRS));
-
- NdisGetSystemUpTime(&Now);
- pAd->StaCfg.LastBeaconRxTime = Now; // last RX timestamp
-
- if ((pAd->CommonCfg.TxPreamble != Rt802_11PreambleLong) &&
- CAP_IS_SHORT_PREAMBLE_ON(pAd->StaActive.CapabilityInfo))
- {
- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
- }
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
- if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE)
- {
-#ifdef DFS_SUPPORT
- RadarDetectionStop(pAd);
-#endif // DFS_SUPPORT //
- }
- pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-
- if (BssType == BSS_ADHOC)
- {
- MakeIbssBeacon(pAd);
- if ((pAd->CommonCfg.Channel > 14)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- ; //Do nothing
- }
- else
- {
- AsicEnableIbssSync(pAd);
- }
-
- // In ad hoc mode, use MAC table from index 1.
- // p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here.
- RTMP_IO_WRITE32(pAd, MAC_WCID_BASE, 0x00);
- RTMP_IO_WRITE32(pAd, 0x1808, 0x00);
-
- // If WEP is enabled, add key material and cipherAlg into Asic
- // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
-
- if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
- {
- PUCHAR Key;
- UCHAR CipherAlg;
-
- for (idx=0; idx < SHARE_KEY_NUM; idx++)
- {
- CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
- Key = pAd->SharedKey[BSS0][idx].Key;
-
- if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
- {
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
-
- if (idx == pAd->StaCfg.DefaultKeyId)
- {
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
- }
- }
-
-
- }
- }
- // If WPANone is enabled, add key material and cipherAlg into Asic
- // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
- else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- pAd->StaCfg.DefaultKeyId = 0; // always be zero
-
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
-
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
- }
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Unknow Cipher (=%d), set Cipher to AES\n", pAd->StaCfg.PairCipher));
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- }
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pAd->SharedKey[BSS0][0].CipherAlg, NULL);
-
- }
-
- }
- else // BSS_INFRA
- {
- // Check the new SSID with last SSID
- while (Cancelled == TRUE)
- {
- if (pAd->CommonCfg.LastSsidLen == pAd->CommonCfg.SsidLen)
- {
- if (RTMPCompareMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, pAd->CommonCfg.LastSsidLen) == 0)
- {
- // Link to the old one no linkdown is required.
- break;
- }
- }
- // Send link down event before set to link up
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n"));
- break;
- }
-
- //
- // On WPA mode, Remove All Keys if not connect to the last BSSID
- // Key will be set after 4-way handshake.
- //
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- ULONG IV;
-
- // Remove all WPA keys
- RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
- RTMPWPARemoveAllKeys(pAd);
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-
- // Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP
- // If IV related values are too large in GroupMsg2, AP would ignore this message.
- IV = 1;
- IV |= (pAd->StaCfg.DefaultKeyId << 30);
- AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
- //RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
- }
-
- // NOTE:
- // the decision of using "short slot time" or not may change dynamically due to
- // new STA association to the AP. so we have to decide that upon parsing BEACON, not here
-
- // NOTE:
- // the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically
- // due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here
-
- ComposePsPoll(pAd);
- ComposeNullFrame(pAd);
-
- AsicEnableBssSync(pAd);
-
- // Add BSSID to WCID search table
- AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid);
-
- // 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;
-
- for (idx=0; idx < SHARE_KEY_NUM; idx++)
- {
- CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
- Key = pAd->SharedKey[BSS0][idx].Key;
-
- if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
- {
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
-
- if (idx == pAd->StaCfg.DefaultKeyId)
- {
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
-
- pEntry->Aid = BSSID_WCID;
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);
- }
- }
- }
- }
-
- // only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode
- // should wait until at least 2 active nodes in this BSSID.
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
- // For GUI ++
- if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- {
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- RTMP_IndicateMediaState(pAd);
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)
-#endif // WPA_SUPPLICANT_SUPPORT //
- RTMPSetTimer(&pAd->Mlme.LinkDownTimer, LINK_DOWN_TIMEOUT);
- }
- // --
-
- // Add BSSID in my MAC Table.
- NdisAcquireSpinLock(&pAd->MacTabLock);
- // add this MAC entry into HASH table
- if (pEntry)
- {
- HashIdx = MAC_ADDR_HASH_INDEX(pAd->CommonCfg.Bssid);
- if (pAd->MacTab.Hash[HashIdx] == NULL)
- {
- pAd->MacTab.Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pAd->MacTab.Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- {
- pCurrEntry = pCurrEntry->pNext;
- }
- pCurrEntry->pNext = pEntry;
- }
- }
- RTMPMoveMemory(pEntry->Addr, pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
- pEntry->Aid = BSSID_WCID;
- pEntry->pAd = pAd;
- pEntry->ValidAsCLI = TRUE; //Although this is bssid..still set ValidAsCl
- pAd->MacTab.Size = 1; // infra mode always set MACtab size =1.
- pEntry->Sst = SST_ASSOC;
- pEntry->AuthState = SST_ASSOC;
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
- if (pEntry->AuthMode < Ndis802_11AuthModeWPA)
- {
- pEntry->WpaState = AS_NOTUSE;
- pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
- }
- else
- {
- pEntry->WpaState = AS_PTKSTART;
- pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
- }
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! ClientStatusFlags=%lx)\n",
- 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 //
-
-
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && (pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)
- {
-
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE);
- RTMPSetPiggyBack(pAd, TRUE);
- DBGPRINT(RT_DEBUG_TRACE, ("Turn on Piggy-Back\n"));
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
- }
- }
-
- 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);
- }
- else
- {
- OPSTATUS_CLEAR_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
- CLIENT_STATUS_CLEAR_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);
- }
- }
-
-
-#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);
-
- pAd->Mlme.PeriodicRound = 0;
- pAd->Mlme.OneSecPeriodicRound = 0;
- pAd->bConfigChanged = FALSE; // Reset config flag
- pAd->ExtraInfo = GENERAL_LINK_UP; // Update extra information to link is up
-
- // Set asic auto fall back
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, &pAd->MacTab.Content[BSSID_WCID], &pTable, &TableSize, &pAd->CommonCfg.TxRateIndex);
- AsicUpdateAutoFallBackTable(pAd, pTable);
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pEntry->HTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
- pEntry->MaxHTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
- 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);
- }
- else
- pEntry->bAutoTxRateSwitch = TRUE;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- // Let Link Status Page display first initial rate.
- pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);
- // Select DAC according to HT or Legacy
- if (pAd->StaActive.SupportedPhyInfo.MCSSet[0] != 0x00)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
- Value &= (~0x18);
- if (pAd->Antenna.field.TxPath == 2)
- {
- Value |= 0x10;
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
- Value &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
- }
-
-#ifdef DOT11_N_SUPPORT
- if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
- {
- }
- else if (pEntry->MaxRAmpduFactor == 0)
- {
- // If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0.
- // 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,
- // 1. Set txop in register-EDCA_AC0_CFG as 0x60
- // 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero
- // 3. PBF_MAX_PCNT as 0x1F3FBF9F
- // 4. kick per two packets when dequeue
- //
- // 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
- if (!((pAd->CommonCfg.RxStream == 1)&&(pAd->CommonCfg.TxStream == 1)) &&
- (pAd->StaCfg.bForceTxBurst == FALSE) &&
- (((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))))
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n"));
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (pAd->CommonCfg.bEnableTxBurst)
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- Data |= 0x60;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = TRUE;
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3FBF9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 2\n"));
- }
- else
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
- 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))))
- {
- pAd->CommonCfg.IOTestParm.bNextDisableRxBA = TRUE;
- if (pAd->CommonCfg.bEnableTxBurst)
- {
- UINT32 MACValue = 0;
- // Force disable TXOP value in this case. The same action in MLMEUpdateProtect too.
- // I didn't change PBF_MAX_PCNT setting.
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &MACValue);
- MACValue &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, MACValue);
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
- }
- }
- else
- {
- pAd->CommonCfg.IOTestParm.bNextDisableRxBA = FALSE;
- }
-#endif // DOT11_N_SUPPORT //
-
- pAd->CommonCfg.IOTestParm.bLastAtheros = FALSE;
- COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!pAd->bNextDisableRxBA= %d \n", pAd->CommonCfg.IOTestParm.bNextDisableRxBA));
- // BSSID add in one MAC entry too. Because in Tx, ASIC need to check Cipher and IV/EIV, BAbitmap
- // Pther information in MACTab.Content[BSSID_WCID] is not necessary for driver.
- // Note: As STA, The MACTab.Content[BSSID_WCID]. PairwiseKey and Shared Key for BSS0 are the same.
-
- if (pAd->StaCfg.WepStatus <= Ndis802_11WEPDisabled)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP &&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
- (pAd->StaCfg.IEEE8021X == TRUE))
- ;
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
- }
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pEntry->PortSecured = pAd->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- //
- // Patch Atheros AP TX will breakdown issue.
- // AP Model: DLink DWL-8200AP
- //
- if (INFRA_ON(pAd) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && STA_TKIP_ON(pAd))
- {
- RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x01);
- }
- else
- {
- RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x00);
- }
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- 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 //
-}
-
-/*
- ==========================================================================
-
- Routine Description:
- Disconnect current BSSID
-
- Arguments:
- pAd - Pointer to our adapter
- IsReqFromAP - Request from AP
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- We need more information to know it's this requst from AP.
- If yes! we need to do extra handling, for example, remove the WPA key.
- Otherwise on 4-way handshaking will faied, since the WPA key didn't be
- remove while auto reconnect.
- Disconnect request from AP, it means we will start afresh 4-way handshaking
- on WPA mode.
-
- ==========================================================================
-*/
-VOID LinkDown(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN IsReqFromAP)
-{
- UCHAR i, ByteValue = 0;
-
- BOOLEAN Cancelled;
-
- // 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 //
- RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
- //Comment the codes, beasue the line 2291 call the same function.
- //RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
- // Not allow go to sleep within linkdown function.
- RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n"));
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
-#ifdef RTMP_MAC_PCI
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
- {
- BOOLEAN Cancelled;
- pAd->Mlme.bPsPollTimerRunning = FALSE;
- RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
- }
-
- pAd->bPCIclkOff = FALSE;
-#endif // RTMP_MAC_PCI //
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
-|| RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)
- || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
- {
- AUTO_WAKEUP_STRUC AutoWakeupCfg;
- AsicForceWakeup(pAd, TRUE);
- AutoWakeupCfg.word = 0;
- RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
- }
-#ifdef RTMP_MAC_PCI
- pAd->bPCIclkOff = FALSE;
-#endif // RTMP_MAC_PCI //
- if (ADHOC_ON(pAd)) // Adhoc mode link down
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 1!!!\n"));
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MacTab.Size=%d !!!\n", pAd->MacTab.Size));
- }
- else // Infra structure mode
- {
- 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);
-
- // Saved last SSID for linkup comparison
- pAd->CommonCfg.LastSsidLen = pAd->CommonCfg.SsidLen;
- NdisMoveMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, pAd->CommonCfg.LastSsidLen);
- COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
- if (pAd->MlmeAux.CurrReqIsFromNdis == TRUE)
- {
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event A!\n"));
- pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
- }
- else
- {
- //
- // If disassociation request is from NDIS, then we don't need to delete BSSID from entry.
- // Otherwise lost beacon or receive De-Authentication from AP,
- // then we should delete BSSID from BssTable.
- // If we don't delete from entry, roaming will fail.
- //
- BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Channel);
- }
-
- // restore back to -
- // 1. long slot (20 us) or short slot (9 us) time
- // 2. turn on/off RTS/CTS and/or CTS-to-self protection
- // 3. short preamble
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
-
-#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++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
- MacTableDeleteEntry(pAd, pAd->MacTab.Content[i].Aid, pAd->MacTab.Content[i].Addr);
- }
-
- AsicSetSlotTime(pAd, TRUE); //FALSE);
- AsicSetEdcaParm(pAd, NULL);
-
- // Set LED
- RTMPSetLED(pAd, LED_LINK_DOWN);
- pAd->LedIndicatorStrength = 0xF0;
- RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it.
-
- AsicDisableSync(pAd);
-
- pAd->Mlme.PeriodicRound = 0;
- pAd->Mlme.OneSecPeriodicRound = 0;
-
- if (pAd->StaCfg.BssType == BSS_INFRA)
- {
- // Remove StaCfg Information after link down
- NdisZeroMemory(pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
- 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)
- {
- 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 //
- }
-
- //
- // if link down come from AP, we need to remove all WPA keys on WPA mode.
- // otherwise will cause 4-way handshaking failed, since the WPA key not empty.
- //
- if ((IsReqFromAP) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- // Remove all WPA keys
- RTMPWPARemoveAllKeys(pAd);
- }
-
- // 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 &&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
- (pAd->StaCfg.IEEE8021X == FALSE))
- {
- 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;
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- NdisZeroMemory(&pAd->MacTab, sizeof(MAC_TABLE));
- pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- pAd->StaCfg.MicErrCnt = 0;
-
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- // Update extra information to link is up
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
-
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
-
-
- // Clean association information
- NdisZeroMemory(&pAd->StaCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));
- pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
- pAd->StaCfg.ReqVarIELen = 0;
- pAd->StaCfg.ResVarIELen = 0;
-
- //
- // Reset RSSI value after link down
- //
- pAd->StaCfg.RssiSample.AvgRssi0 = 0;
- pAd->StaCfg.RssiSample.AvgRssi0X8 = 0;
- pAd->StaCfg.RssiSample.AvgRssi1 = 0;
- pAd->StaCfg.RssiSample.AvgRssi1X8 = 0;
- pAd->StaCfg.RssiSample.AvgRssi2 = 0;
- pAd->StaCfg.RssiSample.AvgRssi2X8 = 0;
-
- // Restore MlmeRate
- 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.
- //
- if (pAd->CommonCfg.BBPCurrentBW == BW_40)
- {
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &ByteValue);
- 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);
- if (pAd->Antenna.field.TxPath == 2)
- {
- ByteValue |= 0x10;
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, ByteValue);
-
- 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);
- AsicDisableRDG(pAd);
- 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);
-// Allow go to sleep after linkdown steps.
- RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP) {
- //send disassociate event to wpa_supplicant
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_DISASSOC_EVENT_FLAG, NULL, NULL, 0);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#ifdef RT30xx
- if ((IS_RT30xx(pAd) || IS_RT3090(pAd)||IS_RT3390(pAd))
- &&(pAd->Antenna.field.RxPath>1||pAd->Antenna.field.TxPath>1))
- {
- RTMP_ASIC_MMPS_DISABLE(pAd);
- }
-#endif // RT30xx //
-
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID IterateOnBssTab(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_START_REQ_STRUCT StartReq;
- MLME_JOIN_REQ_STRUCT JoinReq;
- ULONG BssIdx;
-
- // Change the wepstatus to original wepstatus
- pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
- BssIdx = pAd->MlmeAux.BssIdx;
- if (BssIdx < pAd->MlmeAux.SsidBssTab.BssNr)
- {
- // Check cipher suite, AP must have more secured cipher than station setting
- // Set the Pairwise and Group cipher to match the intended AP setting
- // We can only connect to AP with less secured cipher setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher;
- else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher;
- else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
-
- // RSN capability
- pAd->StaCfg.RsnCapability = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.RsnCapability;
- }
-
- // Set Mix cipher flag
- pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
- /*if (pAd->StaCfg.bMixCipher == TRUE)
- {
- // If mix cipher, re-build RSNIE
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- }*/
-
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - iterate BSS %ld of %d\n", BssIdx, pAd->MlmeAux.SsidBssTab.BssNr));
- JoinParmFill(pAd, &JoinReq, BssIdx);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, sizeof(MLME_JOIN_REQ_STRUCT),
- &JoinReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
- }
- else if (pAd->StaCfg.BssType == BSS_ADHOC)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",pAd->MlmeAux.Ssid));
- StartParmFill(pAd, &StartReq, (PCHAR)pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
- else // no more BSS
- {
-
-#ifdef DOT11_N_SUPPORT
-#endif // DOT11_N_SUPPORT //
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
- }
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
-}
-
-// for re-association only
-// IRQL = DISPATCH_LEVEL
-VOID IterateOnBssTab2(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_REASSOC_REQ_STRUCT ReassocReq;
- ULONG BssIdx;
- BSS_ENTRY *pBss;
-
- BssIdx = pAd->MlmeAux.RoamIdx;
- pBss = &pAd->MlmeAux.RoamTab.BssEntry[BssIdx];
-
- if (BssIdx < pAd->MlmeAux.RoamTab.BssNr)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - iterate BSS %ld of %d\n", BssIdx, pAd->MlmeAux.RoamTab.BssNr));
-
- AsicSwitchChannel(pAd, pBss->Channel, FALSE);
- AsicLockChannel(pAd, pBss->Channel);
-
- // reassociate message has the same structure as associate message
- AssocParmFill(pAd, &ReassocReq, pBss->Bssid, pBss->CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
- sizeof(MLME_REASSOC_REQ_STRUCT), &ReassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
- }
- else // no more BSS
- {
-
-#ifdef DOT11_N_SUPPORT
-#endif // DOT11_N_SUPPORT //
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
- }
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID JoinParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
- IN ULONG BssIdx)
-{
- JoinReq->BssIdx = BssIdx;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID ScanParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
- IN STRING Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN UCHAR ScanType)
-{
- NdisZeroMemory(ScanReq->Ssid, MAX_LEN_OF_SSID);
- ScanReq->SsidLen = SsidLen;
- NdisMoveMemory(ScanReq->Ssid, Ssid, SsidLen);
- ScanReq->BssType = BssType;
- 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:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID StartParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_START_REQ_STRUCT *StartReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen)
-{
- ASSERT(SsidLen <= MAX_LEN_OF_SSID);
- NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen);
- StartReq->SsidLen = SsidLen;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID AuthParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
- IN PUCHAR pAddr,
- IN USHORT Alg)
-{
- COPY_MAC_ADDR(AuthReq->Addr, pAddr);
- AuthReq->Alg = Alg;
- AuthReq->Timeout = AUTH_TIMEOUT;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-#ifdef RTMP_MAC_PCI
-VOID ComposePsPoll(
- IN PRTMP_ADAPTER pAd)
-{
- NdisZeroMemory(&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
- 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);
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID ComposeNullFrame(
- IN PRTMP_ADAPTER pAd)
-{
- NdisZeroMemory(&pAd->NullFrame, sizeof(HEADER_802_11));
- pAd->NullFrame.FC.Type = BTYPE_DATA;
- pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC;
- pAd->NullFrame.FC.ToDs = 1;
- 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);
-}
-#endif // RTMP_MAC_PCI //
-
-
-
-
-/*
- ==========================================================================
- Description:
- Pre-build a BEACON frame in the shared memory
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-ULONG MakeIbssBeacon(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR DsLen = 1, IbssLen = 2;
- UCHAR LocalErpIe[3] = {IE_ERP, 1, 0x04};
- HEADER_802_11 BcnHdr;
- USHORT CapabilityInfo;
- LARGE_INTEGER FakeTimestamp;
- ULONG FrameLen = 0;
- PTXWI_STRUC pTxWI = &pAd->BeaconTxWI;
- UCHAR *pBeaconFrame = pAd->BeaconBuf;
- BOOLEAN Privacy;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen = 0;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRateLen = 0;
- UCHAR RSNIe = IE_WPA;
-
- if ((pAd->CommonCfg.PhyMode == PHY_11B) && (pAd->CommonCfg.Channel <= 14))
- {
- SupRate[0] = 0x82; // 1 mbps
- SupRate[1] = 0x84; // 2 mbps
- SupRate[2] = 0x8b; // 5.5 mbps
- SupRate[3] = 0x96; // 11 mbps
- SupRateLen = 4;
- ExtRateLen = 0;
- }
- else if (pAd->CommonCfg.Channel > 14)
- {
- SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
- SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
- SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
- SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- SupRateLen = 8;
- ExtRateLen = 0;
-
- //
- // Also Update MlmeRate & RtsRate for G only & A only
- //
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.RtsRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = MODE_OFDM;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- }
- else
- {
- SupRate[0] = 0x82; // 1 mbps
- SupRate[1] = 0x84; // 2 mbps
- SupRate[2] = 0x8b; // 5.5 mbps
- SupRate[3] = 0x96; // 11 mbps
- SupRateLen = 4;
-
- ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps,
- ExtRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- ExtRate[2] = 0x18; // 12 mbps, in units of 0.5 Mbps,
- ExtRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- ExtRate[4] = 0x30; // 24 mbps, in units of 0.5 Mbps,
- ExtRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- ExtRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- ExtRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- ExtRateLen = 8;
- }
-
- pAd->StaActive.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->StaActive.SupRate, SupRate, SupRateLen);
- pAd->StaActive.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->StaActive.ExtRate, ExtRate, ExtRateLen);
-
- // compose IBSS beacon frame
- MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, BROADCAST_ADDR, pAd->CommonCfg.Bssid);
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
-
- MakeOutgoingFrame(pBeaconFrame, &FrameLen,
- sizeof(HEADER_802_11), &BcnHdr,
- TIMESTAMP_LEN, &FakeTimestamp,
- 2, &pAd->CommonCfg.BeaconPeriod,
- 2, &CapabilityInfo,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &SupRateLen,
- SupRateLen, SupRate,
- 1, &DsIe,
- 1, &DsLen,
- 1, &pAd->CommonCfg.Channel,
- 1, &IbssIe,
- 1, &IbssLen,
- 2, &pAd->StaActive.AtimWin,
- END_OF_ARGS);
-
- // add ERP_IE and EXT_RAE IE of in 802.11g
- if (ExtRateLen)
- {
- ULONG tmp;
-
- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
- 3, LocalErpIe,
- 1, &ExtRateIe,
- 1, &ExtRateLen,
- ExtRateLen, ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // If adhoc secruity is set for WPA-None, append the cipher suite IE
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- ULONG tmp;
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-
- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- 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,
- HtLen, &pAd->CommonCfg.HtCapability,
- 1, &AddHtInfoIe,
- 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)
- {
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
- PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
- }
- else
- {
- // Set to use 1Mbps for Adhoc beacon.
- HTTRANSMIT_SETTING Transmit;
- Transmit.word = 0;
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
- 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/rt3090/sta/dls.c b/drivers/staging/rt3090/sta/dls.c
deleted file mode 100644
index 306e16fdeeae..000000000000
--- a/drivers/staging/rt3090/sta/dls.c
+++ /dev/null
@@ -1,2207 +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_TRACE, ("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)
- {
-
- DBGPRINT(RT_DEBUG_OFF, ("@@@ 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_TRACE, ("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)
- {
- DBGPRINT(RT_DEBUG_OFF, ("@@@ 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 (Len < LENGTH_802_11 + 6 + 2) /* LENGTH_802_11 + LLC + EAPOL protocol type */
- return bSTAKeyFrame;
-
- pProto = (PUCHAR)pHeader + LENGTH_802_11;
-
- if ((pHeader->FC.SubType & 0x08))
- pProto += 2; /* QOS Control field */
-
- /* Skip 4-bytes for HTC */
- if (pHeader->FC.Order && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)))
- {
- pProto += 4;
- }
-
- /* L2PAD bit on will pad 2 bytes at LLC */
- if (pRxD->L2PAD)
- {
- pProto += 2;
- }
-
- pProto += 6; /* 0xAA 0xAA 0xAA 0x00 0x00 0x00 */
-
- if ((!(pHeader->FC.SubType & 0x08)) && (!RTMPEqualMemory(EAPOL, pProto, 2)))
- return bSTAKeyFrame;
-
- pAddr = pHeader->Addr2;
-
- 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);
- WpaDerivePTK(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(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, digest, SHA1_DIGEST_SIZE);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- HMAC_MD5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic, MD5_DIGEST_SIZE);
- }
-
- 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 ((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 (Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE))
- {
- 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;
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- PairwiseKey.CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- PairwiseKey.CipherAlg = CIPHER_AES;
-
- 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
-#ifdef RTMP_MAC_PCI
- AsicAddPairwiseKeyEntry(pAd,
- pAd->StaCfg.DLSEntry[i].MacAddr,
- (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
- &PairwiseKey);
-
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- PairwiseKey.CipherAlg,
- pEntry);
-
-#endif // RTMP_MAC_PCI //
- 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;
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- PairwiseKey.CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- PairwiseKey.CipherAlg = CIPHER_AES;
-
- 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
-#ifdef RTMP_MAC_PCI
- AsicAddPairwiseKeyEntry(pAd,
- pAd->StaCfg.DLSEntry[i].MacAddr,
- (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
- &PairwiseKey);
-
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- PairwiseKey.CipherAlg,
- pEntry);
-#endif // RTMP_MAC_PCI //
- 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);
- WpaDerivePTK(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(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- HMAC_MD5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic, MD5_DIGEST_SIZE);
- 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);
- WpaDerivePTK(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(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- HMAC_MD5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic, MD5_DIGEST_SIZE);
- 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);
- RTMP_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) && (pAd->StaCfg.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;
-
- DBGPRINT(RT_DEBUG_OFF, ("\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];
-
- DBGPRINT(RT_DEBUG_OFF, ("%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]));
- DBGPRINT(RT_DEBUG_OFF, ("%-8d\n", pAd->StaCfg.DLSEntry[i].TimeOut));
-
- DBGPRINT(RT_DEBUG_OFF, ("\n"));
- DBGPRINT(RT_DEBUG_OFF, ("\n%-19s%-4s%-4s%-4s%-4s%-7s%-7s%-7s","MAC", "AID", "BSS", "PSM", "WMM", "RSSI0", "RSSI1", "RSSI2"));
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_OFF, ("%-8s%-10s%-6s%-6s%-6s%-6s", "MIMOPS", "PhMd", "BW", "MCS", "SGI", "STBC"));
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_OFF, ("\n%02X:%02X:%02X:%02X:%02X:%02X ",
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]));
- DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)pEntry->Aid));
- DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)pEntry->apidx));
- DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)pEntry->PsMode));
- DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE)));
- DBGPRINT(RT_DEBUG_OFF, ("%-7d", pEntry->RssiSample.AvgRssi0));
- DBGPRINT(RT_DEBUG_OFF, ("%-7d", pEntry->RssiSample.AvgRssi1));
- DBGPRINT(RT_DEBUG_OFF, ("%-7d", pEntry->RssiSample.AvgRssi2));
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_OFF, ("%-8d", (int)pEntry->MmpsMode));
- DBGPRINT(RT_DEBUG_OFF, ("%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE)));
- DBGPRINT(RT_DEBUG_OFF, ("%-6s", GetBW(pEntry->HTPhyMode.field.BW)));
- DBGPRINT(RT_DEBUG_OFF, ("%-6d", pEntry->HTPhyMode.field.MCS));
- DBGPRINT(RT_DEBUG_OFF, ("%-6d", pEntry->HTPhyMode.field.ShortGI));
- DBGPRINT(RT_DEBUG_OFF, ("%-6d", pEntry->HTPhyMode.field.STBC));
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_OFF, ("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
- (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0));
- DBGPRINT(RT_DEBUG_OFF, ("\n"));
-
- }
- }
-
- return TRUE;
-}
-
-INT Set_DlsAddEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PSTRING arg)
-{
- UCHAR mac[MAC_ADDR_LEN];
- USHORT Timeout;
- PSTRING token;
- STRING 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 = (USHORT) 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, (&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- DBGPRINT(RT_DEBUG_OFF, ("\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 PSTRING arg)
-{
- UCHAR macAddr[MAC_ADDR_LEN];
- PSTRING 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);
- }
-
- DBGPRINT(RT_DEBUG_OFF, ("\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/rt3090/sta/rtmp_ckipmic.c b/drivers/staging/rt3090/sta/rtmp_ckipmic.c
deleted file mode 100644
index 5f6dbd7cf057..000000000000
--- a/drivers/staging/rt3090/sta/rtmp_ckipmic.c
+++ /dev/null
@@ -1,579 +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:
- rtmp_ckipmic.c
-
- Abstract:
- Data path subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
-*/
-
-#include "../rt_config.h"
-#include "../rtmp_ckipmic.h"
-
-
-#define MIC_ACCUM(v) pContext->accum += (ULONGLONG)v * RTMPMicGetCoefficient(pContext)
-#define GB(p,i,s) ( ((ULONG) *((UCHAR*)(p)+i) ) << (s) )
-#define GETBIG32(p) GB(p,0,24)|GB(p,1,16)|GB(p,2,8)|GB(p,3,0)
-
-/*****************************/
-/******** SBOX Table *********/
-/*****************************/
-
-UCHAR SboxTable[256] =
-{
- 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
- 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
- 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
- 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
- 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
- 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
- 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
- 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
- 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
- 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
- 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
- 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
- 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
- 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
- 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
- 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
- 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
- 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
- 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
- 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
- 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
- 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
- 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
- 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
- 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
- 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
- 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
- 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
- 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
- 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
- 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
- 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-
-/*===========================================================================*/
-/*=================== CKIP KEY PERMUTATION ==================================*/
-/*===========================================================================*/
-
-/* 2-byte by 2-byte subset of the full AES table */
-static const USHORT Sbox[256] =
-{
- 0xC6A5,0xF884,0xEE99,0xF68D,0xFF0D,0xD6BD,0xDEB1,0x9154,
- 0x6050,0x0203,0xCEA9,0x567D,0xE719,0xB562,0x4DE6,0xEC9A,
- 0x8F45,0x1F9D,0x8940,0xFA87,0xEF15,0xB2EB,0x8EC9,0xFB0B,
- 0x41EC,0xB367,0x5FFD,0x45EA,0x23BF,0x53F7,0xE496,0x9B5B,
- 0x75C2,0xE11C,0x3DAE,0x4C6A,0x6C5A,0x7E41,0xF502,0x834F,
- 0x685C,0x51F4,0xD134,0xF908,0xE293,0xAB73,0x6253,0x2A3F,
- 0x080C,0x9552,0x4665,0x9D5E,0x3028,0x37A1,0x0A0F,0x2FB5,
- 0x0E09,0x2436,0x1B9B,0xDF3D,0xCD26,0x4E69,0x7FCD,0xEA9F,
- 0x121B,0x1D9E,0x5874,0x342E,0x362D,0xDCB2,0xB4EE,0x5BFB,
- 0xA4F6,0x764D,0xB761,0x7DCE,0x527B,0xDD3E,0x5E71,0x1397,
- 0xA6F5,0xB968,0x0000,0xC12C,0x4060,0xE31F,0x79C8,0xB6ED,
- 0xD4BE,0x8D46,0x67D9,0x724B,0x94DE,0x98D4,0xB0E8,0x854A,
- 0xBB6B,0xC52A,0x4FE5,0xED16,0x86C5,0x9AD7,0x6655,0x1194,
- 0x8ACF,0xE910,0x0406,0xFE81,0xA0F0,0x7844,0x25BA,0x4BE3,
- 0xA2F3,0x5DFE,0x80C0,0x058A,0x3FAD,0x21BC,0x7048,0xF104,
- 0x63DF,0x77C1,0xAF75,0x4263,0x2030,0xE51A,0xFD0E,0xBF6D,
- 0x814C,0x1814,0x2635,0xC32F,0xBEE1,0x35A2,0x88CC,0x2E39,
- 0x9357,0x55F2,0xFC82,0x7A47,0xC8AC,0xBAE7,0x322B,0xE695,
- 0xC0A0,0x1998,0x9ED1,0xA37F,0x4466,0x547E,0x3BAB,0x0B83,
- 0x8CCA,0xC729,0x6BD3,0x283C,0xA779,0xBCE2,0x161D,0xAD76,
- 0xDB3B,0x6456,0x744E,0x141E,0x92DB,0x0C0A,0x486C,0xB8E4,
- 0x9F5D,0xBD6E,0x43EF,0xC4A6,0x39A8,0x31A4,0xD337,0xF28B,
- 0xD532,0x8B43,0x6E59,0xDAB7,0x018C,0xB164,0x9CD2,0x49E0,
- 0xD8B4,0xACFA,0xF307,0xCF25,0xCAAF,0xF48E,0x47E9,0x1018,
- 0x6FD5,0xF088,0x4A6F,0x5C72,0x3824,0x57F1,0x73C7,0x9751,
- 0xCB23,0xA17C,0xE89C,0x3E21,0x96DD,0x61DC,0x0D86,0x0F85,
- 0xE090,0x7C42,0x71C4,0xCCAA,0x90D8,0x0605,0xF701,0x1C12,
- 0xC2A3,0x6A5F,0xAEF9,0x69D0,0x1791,0x9958,0x3A27,0x27B9,
- 0xD938,0xEB13,0x2BB3,0x2233,0xD2BB,0xA970,0x0789,0x33A7,
- 0x2DB6,0x3C22,0x1592,0xC920,0x8749,0xAAFF,0x5078,0xA57A,
- 0x038F,0x59F8,0x0980,0x1A17,0x65DA,0xD731,0x84C6,0xD0B8,
- 0x82C3,0x29B0,0x5A77,0x1E11,0x7BCB,0xA8FC,0x6DD6,0x2C3A
- };
-
-#define Lo8(v16) ((v16) & 0xFF)
-#define Hi8(v16) (((v16) >> 8) & 0xFF)
-#define u16Swap(i) ( (((i) >> 8) & 0xFF) | (((i) << 8) & 0xFF00) )
-#define _S_(i) (Sbox[Lo8(i)] ^ u16Swap(Sbox[Hi8(i)]))
-
-#define rotLeft_1(x) ((((x) << 1) | ((x) >> 15)) & 0xFFFF)
-VOID CKIP_key_permute
- (
- OUT UCHAR *PK, /* output permuted key */
- IN UCHAR *CK, /* input CKIP key */
- IN UCHAR toDsFromDs, /* input toDs/FromDs bits */
- IN UCHAR *piv /* input pointer to IV */
- )
-{
- int i;
- USHORT H[2], tmp; /* H=32-bits of per-packet hash value */
- USHORT L[8], R[8]; /* L=u16 array of CK, R=u16 array of PK */
-
- /* build L from input key */
- memset(L, 0, sizeof(L));
- for (i=0; i<16; i++) {
- L[i>>1] |= ( ((USHORT)(CK[i])) << ( i & 1 ? 8 : 0) );
- }
-
- H[0] = (((USHORT)piv[0]) << 8) + piv[1];
- H[1] = ( ((USHORT)toDsFromDs) << 8) | piv[2];
-
- for (i=0; i<8; i++) {
- H[0] ^= L[i]; /* 16-bits of key material */
- tmp = _S_(H[0]); /* 16x16 permutation */
- H[0] = tmp ^ H[1]; /* set up for next round */
- H[1] = tmp;
- R[i] = H[0]; /* store into key array */
- }
-
- /* sweep in the other direction */
- tmp=L[0];
- for (i=7; i>0; i--) {
- R[i] = tmp = rotLeft_1(tmp) + R[i];
- }
-
- /* IV of the permuted key is unchanged */
- PK[0] = piv[0];
- PK[1] = piv[1];
- PK[2] = piv[2];
-
- /* key portion of the permuted key is changed */
- for (i=3; i<16; i++) {
- PK[i] = (UCHAR) (R[i>>1] >> (i & 1 ? 8 : 0));
- }
-}
-
-/* prepare for calculation of a new mic */
-VOID RTMPCkipMicInit(
- IN PMIC_CONTEXT pContext,
- IN PUCHAR CK)
-{
- /* prepare for new mic calculation */
- NdisMoveMemory(pContext->CK, CK, sizeof(pContext->CK));
- pContext->accum = 0;
- pContext->position = 0;
-}
-
-/* add some bytes to the mic calculation */
-VOID RTMPMicUpdate(
- IN PMIC_CONTEXT pContext,
- IN PUCHAR pOctets,
- IN INT len)
-{
- INT byte_position;
- ULONG val;
-
- byte_position = (pContext->position & 3);
- while (len > 0) {
- /* build a 32-bit word for MIC multiply accumulate */
- do {
- if (len == 0) return;
- pContext->part[byte_position++] = *pOctets++;
- pContext->position++;
- len--;
- } while (byte_position < 4);
- /* have a full 32-bit word to process */
- val = GETBIG32(&pContext->part[0]);
- MIC_ACCUM(val);
- byte_position = 0;
- }
-}
-
-ULONG RTMPMicGetCoefficient(
- IN PMIC_CONTEXT pContext)
-{
- UCHAR aes_counter[16];
- INT coeff_position;
- UCHAR *p;
-
- coeff_position = (pContext->position - 1) >> 2;
- if ( (coeff_position & 3) == 0) {
- /* fetching the first coefficient -- get new 16-byte aes counter output */
- u32 counter = (coeff_position >> 2);
-
- /* new counter value */
- memset(&aes_counter[0], 0, sizeof(aes_counter));
- aes_counter[15] = (UINT8)(counter >> 0);
- aes_counter[14] = (UINT8)(counter >> 8);
- aes_counter[13] = (UINT8)(counter >> 16);
- aes_counter[12] = (UINT8)(counter >> 24);
-
- RTMPAesEncrypt(&pContext->CK[0], &aes_counter[0], pContext->coefficient);
- }
- p = &(pContext->coefficient[ (coeff_position & 3) << 2 ]);
- return GETBIG32(p);
-}
-
-/****************************************/
-/* aes128k128d() */
-/* Performs a 128 bit AES encrypt with */
-/* 128 bit data. */
-/****************************************/
-VOID xor_128(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0;i<16; i++)
- {
- out[i] = a[i] ^ b[i];
- }
-}
-
-UCHAR RTMPCkipSbox(
- IN UCHAR a)
-{
- return SboxTable[(int)a];
-}
-
-VOID xor_32(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0;i<4; i++)
- {
- out[i] = a[i] ^ b[i];
- }
-}
-
-VOID next_key(
- IN PUCHAR key,
- IN INT round)
-{
- UCHAR rcon;
- UCHAR sbox_key[4];
- UCHAR rcon_table[12] =
- {
- 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
- 0x1b, 0x36, 0x36, 0x36
- };
-
- sbox_key[0] = RTMPCkipSbox(key[13]);
- sbox_key[1] = RTMPCkipSbox(key[14]);
- sbox_key[2] = RTMPCkipSbox(key[15]);
- sbox_key[3] = RTMPCkipSbox(key[12]);
-
- rcon = rcon_table[round];
-
- xor_32(&key[0], sbox_key, &key[0]);
- key[0] = key[0] ^ rcon;
-
- xor_32(&key[4], &key[0], &key[4]);
- xor_32(&key[8], &key[4], &key[8]);
- xor_32(&key[12], &key[8], &key[12]);
-}
-
-VOID byte_sub(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0; i< 16; i++)
- {
- out[i] = RTMPCkipSbox(in[i]);
- }
-}
-
-VOID shift_row(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- out[0] = in[0];
- out[1] = in[5];
- out[2] = in[10];
- out[3] = in[15];
- out[4] = in[4];
- out[5] = in[9];
- out[6] = in[14];
- out[7] = in[3];
- out[8] = in[8];
- out[9] = in[13];
- out[10] = in[2];
- out[11] = in[7];
- out[12] = in[12];
- out[13] = in[1];
- out[14] = in[6];
- out[15] = in[11];
-}
-
-VOID mix_column(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- INT i;
- UCHAR add1b[4];
- UCHAR add1bf7[4];
- UCHAR rotl[4];
- UCHAR swap_halfs[4];
- UCHAR andf7[4];
- UCHAR rotr[4];
- UCHAR temp[4];
- UCHAR tempb[4];
-
- for (i=0 ; i<4; i++)
- {
- if ((in[i] & 0x80)== 0x80)
- add1b[i] = 0x1b;
- else
- add1b[i] = 0x00;
- }
-
- swap_halfs[0] = in[2]; /* Swap halfs */
- swap_halfs[1] = in[3];
- swap_halfs[2] = in[0];
- swap_halfs[3] = in[1];
-
- rotl[0] = in[3]; /* Rotate left 8 bits */
- rotl[1] = in[0];
- rotl[2] = in[1];
- rotl[3] = in[2];
-
- andf7[0] = in[0] & 0x7f;
- andf7[1] = in[1] & 0x7f;
- andf7[2] = in[2] & 0x7f;
- andf7[3] = in[3] & 0x7f;
-
- for (i = 3; i>0; i--) /* logical shift left 1 bit */
- {
- andf7[i] = andf7[i] << 1;
- if ((andf7[i-1] & 0x80) == 0x80)
- {
- andf7[i] = (andf7[i] | 0x01);
- }
- }
- andf7[0] = andf7[0] << 1;
- andf7[0] = andf7[0] & 0xfe;
-
- xor_32(add1b, andf7, add1bf7);
-
- xor_32(in, add1bf7, rotr);
-
- temp[0] = rotr[0]; /* Rotate right 8 bits */
- rotr[0] = rotr[1];
- rotr[1] = rotr[2];
- rotr[2] = rotr[3];
- rotr[3] = temp[0];
-
- xor_32(add1bf7, rotr, temp);
- xor_32(swap_halfs, rotl,tempb);
- xor_32(temp, tempb, out);
-}
-
-VOID RTMPAesEncrypt(
- IN PUCHAR key,
- IN PUCHAR data,
- IN PUCHAR ciphertext)
-{
- INT round;
- INT i;
- UCHAR intermediatea[16];
- UCHAR intermediateb[16];
- UCHAR round_key[16];
-
- for(i=0; i<16; i++) round_key[i] = key[i];
-
- for (round = 0; round < 11; round++)
- {
- if (round == 0)
- {
- xor_128(round_key, data, ciphertext);
- next_key(round_key, round);
- }
- else if (round == 10)
- {
- byte_sub(ciphertext, intermediatea);
- shift_row(intermediatea, intermediateb);
- xor_128(intermediateb, round_key, ciphertext);
- }
- else /* 1 - 9 */
- {
- byte_sub(ciphertext, intermediatea);
- shift_row(intermediatea, intermediateb);
- mix_column(&intermediateb[0], &intermediatea[0]);
- mix_column(&intermediateb[4], &intermediatea[4]);
- mix_column(&intermediateb[8], &intermediatea[8]);
- mix_column(&intermediateb[12], &intermediatea[12]);
- xor_128(intermediatea, round_key, ciphertext);
- next_key(round_key, round);
- }
- }
-
-}
-
-/* calculate the mic */
-VOID RTMPMicFinal(
- IN PMIC_CONTEXT pContext,
- OUT UCHAR digest[4])
-{
- INT byte_position;
- ULONG val;
- ULONGLONG sum, utmp;
- LONGLONG stmp;
-
- /* deal with partial 32-bit word left over from last update */
- if ( (byte_position = (pContext->position & 3)) != 0) {
- /* have a partial word in part to deal with -- zero unused bytes */
- do {
- pContext->part[byte_position++] = 0;
- pContext->position++;
- } while (byte_position < 4);
- val = GETBIG32(&pContext->part[0]);
- MIC_ACCUM(val);
- }
-
- /* reduce the accumulated u64 to a 32-bit MIC */
- sum = pContext->accum;
- stmp = (sum & 0xffffffffL) - ((sum >> 32) * 15);
- utmp = (stmp & 0xffffffffL) - ((stmp >> 32) * 15);
- sum = utmp & 0xffffffffL;
- if (utmp > 0x10000000fL)
- sum -= 15;
-
- val = (ULONG)sum;
- digest[0] = (UCHAR)((val>>24) & 0xFF);
- digest[1] = (UCHAR) ((val>>16) & 0xFF);
- digest[2] = (UCHAR) ((val>>8) & 0xFF);
- digest[3] = (UCHAR)((val>>0) & 0xFF);
-}
-
-VOID RTMPCkipInsertCMIC(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pMIC,
- IN PUCHAR p80211hdr,
- IN PNDIS_PACKET pPacket,
- IN PCIPHER_KEY pKey,
- IN PUCHAR mic_snap)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- ULONG SrcBufLen;
- PUCHAR pDA, pSA, pProto;
- UCHAR bigethlen[2];
- UCHAR ckip_ck[16];
- MIC_CONTEXT mic_ctx;
- USHORT payloadlen;
- UCHAR i;
-
- if (pKey == NULL)
- {
- DBGPRINT_ERR(("RTMPCkipInsertCMIC, Before to form the CKIP key (CK), pKey can't be NULL\n"));
- return;
- }
-
- switch (*(p80211hdr+1) & 3)
- {
- case 0: /* FromDs=0, ToDs=0 */
- pDA = p80211hdr+4;
- pSA = p80211hdr+10;
- break;
- case 1: /* FromDs=0, ToDs=1 */
- pDA = p80211hdr+16;
- pSA = p80211hdr+10;
- break;
- case 2: /* FromDs=1, ToDs=0 */
- pDA = p80211hdr+4;
- pSA = p80211hdr+16;
- break;
- case 3: /* FromDs=1, ToDs=1 */
- pDA = p80211hdr+16;
- pSA = p80211hdr+24;
- break;
- }
-
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- if (SrcBufLen < LENGTH_802_3)
- return;
-
- pProto = pSrcBufVA + 12;
- payloadlen = PacketInfo.TotalPacketLength - LENGTH_802_3 + 18; // CKIP_LLC(8)+CMIC(4)+TxSEQ(4)+PROTO(2)=18
-
- bigethlen[0] = (unsigned char)(payloadlen >> 8);
- bigethlen[1] = (unsigned char)payloadlen;
-
- //
- // Encryption Key expansion to form the CKIP Key (CKIP_CK).
- //
- if (pKey->KeyLen < 16)
- {
- for(i = 0; i < (16 / pKey->KeyLen); i++)
- {
- NdisMoveMemory(ckip_ck + i * pKey->KeyLen,
- pKey->Key,
- pKey->KeyLen);
- }
- NdisMoveMemory(ckip_ck + i * pKey->KeyLen,
- pKey->Key,
- 16 - (i * pKey->KeyLen));
- }
- else
- {
- NdisMoveMemory(ckip_ck, pKey->Key, pKey->KeyLen);
- }
- RTMPCkipMicInit(&mic_ctx, ckip_ck);
- RTMPMicUpdate(&mic_ctx, pDA, MAC_ADDR_LEN); // MIC <-- DA
- RTMPMicUpdate(&mic_ctx, pSA, MAC_ADDR_LEN); // MIC <-- SA
- RTMPMicUpdate(&mic_ctx, bigethlen, 2); // MIC <-- payload length starting from CKIP SNAP
- RTMPMicUpdate(&mic_ctx, mic_snap, 8); // MIC <-- snap header
- RTMPMicUpdate(&mic_ctx, pAd->StaCfg.TxSEQ, 4); // MIC <-- TxSEQ
- RTMPMicUpdate(&mic_ctx, pProto, 2); // MIC <-- Protocol
-
- pSrcBufVA += LENGTH_802_3;
- SrcBufLen -= LENGTH_802_3;
-
- // Mic <-- original payload. loop until all payload processed
- do
- {
- if (SrcBufLen > 0)
- RTMPMicUpdate(&mic_ctx, pSrcBufVA, SrcBufLen);
-
- NdisGetNextBuffer(PacketInfo.pFirstBuffer, &PacketInfo.pFirstBuffer);
- if (PacketInfo.pFirstBuffer)
- {
- NDIS_QUERY_BUFFER(PacketInfo.pFirstBuffer, &pSrcBufVA, &SrcBufLen);
- }
- else
- break;
- } while (TRUE);
-
- RTMPMicFinal(&mic_ctx, pMIC); // update MIC
-}
diff --git a/drivers/staging/rt3090/sta/rtmp_data.c b/drivers/staging/rt3090/sta/rtmp_data.c
deleted file mode 100644
index 559136409ff2..000000000000
--- a/drivers/staging/rt3090/sta/rtmp_data.c
+++ /dev/null
@@ -1,2661 +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:
- rtmp_data.c
-
- Abstract:
- Data path subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
-*/
-
-#include "../rt_config.h"
-
-
-VOID STARxEAPOLFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- 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)
- // TBD : process fragmented EAPol frames
- {
- // In 802.1x mode, if the received frame is EAP-SUCCESS packet, turn on the PortSecured variable
- if ( pAd->StaCfg.IEEE8021X == TRUE &&
- (EAP_CODE_SUCCESS == WpaCheckEapCode(pAd, pRxBlk->pData, pRxBlk->DataSize, LENGTH_802_1_H)))
- {
- PUCHAR Key;
- UCHAR CipherAlg;
- int idx = 0;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("Receive EAP-SUCCESS Packet\n"));
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- if (pAd->StaCfg.IEEE8021x_required_keys == FALSE)
- {
- idx = pAd->StaCfg.DesireSharedKeyId;
- CipherAlg = pAd->StaCfg.DesireSharedKey[idx].CipherAlg;
- Key = pAd->StaCfg.DesireSharedKey[idx].Key;
-
- if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0)
- {
-#ifdef RTMP_MAC_PCI
- MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[BSSID_WCID];
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
-
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
-
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
-#endif // RTMP_MAC_PCI //
- // 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;
- NdisMoveMemory(pAd->SharedKey[BSS0][idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].KeyLen);
- }
- }
- }
-
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- }
- 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
- // 2. EAPOL handshaking frames when driver supplicant enabled, pass to MLME for special process
- {
- pTmpBuf = pRxBlk->pData - LENGTH_802_11;
- NdisMoveMemory(pTmpBuf, pRxBlk->pHeader, LENGTH_802_11);
- REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pTmpBuf, pRxBlk->DataSize + LENGTH_802_11, pRxWI->RSSI0, pRxWI->RSSI1, pRxWI->RSSI2, pRxD->PlcpSignal);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! report EAPOL/AIRONET DATA to MLME (len=%d) !!!\n", pRxBlk->DataSize));
- }
- }
-
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
-
-}
-
-VOID STARxDataFrameAnnounce(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
-
- // non-EAP frame
- if (!RTMPCheckWPAframe(pAd, pEntry, pRxBlk->pData, pRxBlk->DataSize, FromWhichBSSID))
- {
-
- {
- // drop all non-EAP DATA frame before
- // this client's Port-Access-Control is secured
- if (pRxBlk->pHeader->FC.Wep)
- {
- // unsupported cipher suite
- if (pAd->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- else
- {
- // encryption in-use but receive a non-EAPOL clear text frame, drop it
- if ((pAd->StaCfg.WepStatus != Ndis802_11EncryptionDisabled) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- }
- RX_BLK_CLEAR_FLAG(pRxBlk, fRX_EAP);
-
-
- if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_ARALINK))
- {
- // Normal legacy, AMPDU or AMSDU
- CmmRxnonRalinkFrameIndicate(pAd, pRxBlk, FromWhichBSSID);
-
- }
- else
- {
- // 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
- STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
- }
- }
-}
-
-
-// For TKIP frame, calculate the MIC value
-BOOLEAN STACheckTkipMICValue(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk)
-{
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- UCHAR *pData = pRxBlk->pData;
- USHORT DataSize = pRxBlk->DataSize;
- UCHAR UserPriority = pRxBlk->UserPriority;
- PCIPHER_KEY pWpaKey;
- UCHAR *pDA, *pSA;
-
- pWpaKey = &pAd->SharedKey[BSS0][pRxBlk->pRxWI->KeyIndex];
-
- pDA = pHeader->Addr1;
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_INFRA))
- {
- pSA = pHeader->Addr3;
- }
- else
- {
- pSA = pHeader->Addr2;
- }
-
- if (RTMPTkipCompareMICValue(pAd,
- pData,
- pDA,
- pSA,
- pWpaKey->RxMic,
- UserPriority,
- DataSize) == FALSE)
- {
- 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);
- }
-
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-//
-// All Rx routines use RX_BLK structure to hande rx events
-// It is very important to build pRxBlk attributes
-// 1. pHeader pointer to 802.11 Header
-// 2. pData pointer to payload including LLC (just skip Header)
-// 3. set payload size including LLC to DataSize
-// 4. set some flags with RX_BLK_SET_FLAG()
-//
-VOID STAHandleRxDataFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
- BOOLEAN bFragment = FALSE;
- MAC_TABLE_ENTRY *pEntry = NULL;
- UCHAR FromWhichBSSID = BSS0;
- UCHAR UserPriority = 0;
-
- {
- // before LINK UP, all DATA frames are rejected
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- 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)
- {
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
-
- pAd->RalinkCounters.RxCountSinceLastNULL++;
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable && (pHeader->FC.SubType & 0x08))
- {
- UCHAR *pData;
- DBGPRINT(RT_DEBUG_INFO,("bAPSDCapable\n"));
-
- // Qos bit 4
- pData = (PUCHAR)pHeader + LENGTH_802_11;
- if ((*pData >> 4) & 0x01)
- {
- DBGPRINT(RT_DEBUG_INFO,("RxDone- Rcv EOSP frame, driver may fall into sleep\n"));
- pAd->CommonCfg.bInServicePeriod = FALSE;
-
- // Force driver to fall into sleep mode when rcv EOSP frame
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- USHORT TbttNumToNextWakeUp;
- USHORT NextDtim = pAd->StaCfg.DtimPeriod;
- ULONG Now;
-
- NdisGetSystemUpTime(&Now);
- NextDtim -= (USHORT)(Now - pAd->StaCfg.LastBeaconRxTime)/pAd->CommonCfg.BeaconPeriod;
-
- TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM) && (TbttNumToNextWakeUp > NextDtim))
- TbttNumToNextWakeUp = NextDtim;
-
- RTMP_SET_PSM_BIT(pAd, PWR_SAVE);
- // if WMM-APSD is failed, try to disable following line
- AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
- }
- }
-
- if ((pHeader->FC.MoreData) && (pAd->CommonCfg.bInServicePeriod))
- {
- DBGPRINT(RT_DEBUG_TRACE,("Sending another trigger frame when More Data bit is set to 1\n"));
- }
- }
-
- // Drop NULL, CF-ACK(no data), CF-POLL(no data), and CF-ACK+CF-POLL(no data) data frame
- if ((pHeader->FC.SubType & 0x04)) // bit 2 : no DATA
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // 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
- if (!RTMPEqualMemory(&pHeader->Addr2, &pAd->CommonCfg.Bssid, 6))
- {
- // Receive frame not my BSSID
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- else // Ad-Hoc mode or Not associated
- {
- // Ad-Hoc mode, check address 3 for BSSID
- if (!RTMPEqualMemory(&pHeader->Addr3, &pAd->CommonCfg.Bssid, 6))
- {
- // Receive frame not my BSSID
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
-#ifdef QOS_DLS_SUPPORT
- }
-#endif // QOS_DLS_SUPPORT //
-
- //
- // find pEntry
- //
- if (pRxWI->WirelessCliID < MAX_LEN_OF_MAC_TABLE)
- {
- pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
-
- }
- else
- {
- // 1. release packet if infra mode
- // 2. new a pEntry if ad-hoc mode
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // infra or ad-hoc
- 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);
- }
-
- // check Atheros Client
- if ((pEntry->bIAmBadAtheros == FALSE) && (pRxD->AMPDU == 1) && (pHeader->FC.Retry ))
- {
- pEntry->bIAmBadAtheros = TRUE;
- pAd->CommonCfg.IOTestParm.bCurrentAtheros = TRUE;
- pAd->CommonCfg.IOTestParm.bLastAtheros = TRUE;
- if (!STA_AES_ON(pAd))
- {
- AsicUpdateProtect(pAd, 8, ALLN_SETPROTECT, TRUE, FALSE);
- }
- }
- }
-
- pRxBlk->pData = (UCHAR *)pHeader;
-
- //
- // update RxBlk->pData, DataSize
- // 802.11 Header, QOS, HTC, Hw Padding
- //
-
- // 1. skip 802.11 HEADER
- {
- pRxBlk->pData += LENGTH_802_11;
- pRxBlk->DataSize -= LENGTH_802_11;
- }
-
- // 2. QOS
- if (pHeader->FC.SubType & 0x08)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_QOS);
- UserPriority = *(pRxBlk->pData) & 0x0f;
- // bit 7 in QoS Control field signals the HT A-MSDU format
- if ((*pRxBlk->pData) & 0x80)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_AMSDU);
- }
-
- // skip QOS contorl field
- pRxBlk->pData += 2;
- pRxBlk->DataSize -=2;
- }
- pRxBlk->UserPriority = UserPriority;
-
- /* check if need to resend PS Poll when received packet with MoreData = 1 */
- if ((pAd->StaCfg.Psm == PWR_SAVE) && (pHeader->FC.MoreData == 1))
- {
- if ((((UserPriority == 0) || (UserPriority == 3)) &&
- pAd->CommonCfg.bAPSDAC_BE == 0) ||
- (((UserPriority == 1) || (UserPriority == 2)) &&
- pAd->CommonCfg.bAPSDAC_BK == 0) ||
- (((UserPriority == 4) || (UserPriority == 5)) &&
- pAd->CommonCfg.bAPSDAC_VI == 0) ||
- (((UserPriority == 6) || (UserPriority == 7)) &&
- pAd->CommonCfg.bAPSDAC_VO == 0))
- {
- /* non-UAPSD delivery-enabled AC */
- RTMP_PS_POLL_ENQUEUE(pAd);
- }
- }
-
- // 3. Order bit: A-Ralink or HTC+
- if (pHeader->FC.Order)
- {
-#ifdef AGGREGATION_SUPPORT
- if ((pRxWI->PHYMODE <= MODE_OFDM) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)))
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_ARALINK);
- }
- else
-#endif // AGGREGATION_SUPPORT //
- {
-#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 //
- }
- }
-
- // 4. skip HW padding
- if (pRxD->L2PAD)
- {
- // just move pData pointer
- // because DataSize excluding HW padding
- RX_BLK_SET_FLAG(pRxBlk, fRX_PAD);
- 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
- //
- if (pRxD->Bcast || pRxD->Mcast)
- {
- INC_COUNTER64(pAd->WlanCounters.MulticastReceivedFrameCount);
-
- // Drop Mcast/Bcast frame with fragment bit on
- if (pHeader->FC.MoreFrag)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // Filter out Bcast frame which AP relayed for us
- if (pHeader->FC.FrDs && MAC_ADDR_EQUAL(pHeader->Addr3, pAd->CurrentAddress))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- else if (pRxD->U2M)
- {
- 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);
- if (pEntry)
- Update_Rssi_Sample(pAd, &pEntry->RssiSample, pRxWI);
- }
-
-
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
- pAd->StaCfg.LastSNR0 = (UCHAR)(pRxWI->SNR0);
- pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
-
- pAd->RalinkCounters.OneSecRxOkDataCnt++;
-
-
- if (!((pHeader->Frag == 0) && (pHeader->FC.MoreFrag == 0)))
- {
- // re-assemble the fragmented packets
- // return complete frame (pRxPacket) or NULL
- bFragment = TRUE;
- pRxPacket = RTMPDeFragmentDataFrame(pAd, pRxBlk);
- }
-
- if (pRxPacket)
- {
- pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
-
- // process complete frame
- if (bFragment && (pRxD->Decrypted) && (pEntry->WepStatus == Ndis802_11Encryption2Enabled))
- {
- // Minus MIC length
- pRxBlk->DataSize -= 8;
-
- // For TKIP frame, calculate the MIC value
- if (STACheckTkipMICValue(pAd, pEntry, pRxBlk) == FALSE)
- {
- return;
- }
- }
-
- STARxDataFrameAnnounce(pAd, pEntry, pRxBlk, FromWhichBSSID);
- return;
- }
- else
- {
- // just return
- // because RTMPDeFragmentDataFrame() will release rx packet,
- // if packet is fragmented
- return;
- }
- }
-
- ASSERT(0);
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-VOID STAHandleRxMgmtFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
-
- do
- {
-
-
- /* check if need to resend PS Poll when received packet with MoreData = 1 */
- if ((pAd->StaCfg.Psm == PWR_SAVE) && (pHeader->FC.MoreData == 1))
- {
- /* for UAPSD, all management frames will be VO priority */
- if (pAd->CommonCfg.bAPSDAC_VO == 0)
- {
- /* non-UAPSD delivery-enabled AC */
- RTMP_PS_POLL_ENQUEUE(pAd);
- }
- }
-
- /* TODO: if MoreData == 0, station can go to sleep */
-
-
- // We should collect RSSI not only U2M data but also my beacon
- if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))
- && (pAd->RxAnt.EvaluatePeriod == 0))
- {
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
- pAd->StaCfg.LastSNR0 = (UCHAR)(pRxWI->SNR0);
- pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
- }
-
-#ifdef RT30xx
-#ifdef ANT_DIVERSITY_SUPPORT
- // collect rssi information for antenna diversity
- if ((pAd->NicConfig2.field.AntDiversity) &&
- (pAd->CommonCfg.bRxAntDiversity != ANT_DIVERSITY_DISABLE))
- {
- 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 // ANT_DIVERSITY_SUPPORT //
-#endif // RT30xx //
-
- // First check the size, it MUST not exceed the mlme queue size
- if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("STAHandleRxMgmtFrame: frame too large, size = %d \n", pRxWI->MPDUtotalByteCount));
- break;
- }
-
- REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pHeader, pRxWI->MPDUtotalByteCount,
- pRxWI->RSSI0, pRxWI->RSSI1, pRxWI->RSSI2, pRxD->PlcpSignal);
- } while (FALSE);
-
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS);
-}
-
-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:
- break;
- }
-
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Process RxDone interrupt, running in DPC level
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- This routine has to maintain Rx ring read pointer.
- Need to consider QOS DATA format when converting to 802.3
- ========================================================================
-*/
-BOOLEAN STARxDoneInterruptHandle(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN argc)
-{
- NDIS_STATUS Status;
- UINT32 RxProcessed, RxPending;
- BOOLEAN bReschedule = FALSE;
- RT28XX_RXD_STRUC *pRxD;
- UCHAR *pData;
- PRXWI_STRUC pRxWI;
- PNDIS_PACKET pRxPacket;
- PHEADER_802_11 pHeader;
- RX_BLK RxCell;
-
- RxProcessed = RxPending = 0;
-
- // process whole rx ring
- while (1)
- {
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST) ||
- !RTMP_TEST_FLAG(pAd,fRTMP_ADAPTER_START_UP))
- {
- break;
- }
-
-#ifdef RTMP_MAC_PCI
- if (RxProcessed++ > MAX_RX_PROCESS_CNT)
- {
- // need to reschedule rx handle
- bReschedule = TRUE;
- break;
- }
-#endif // RTMP_MAC_PCI //
-
- RxProcessed ++; // test
-
- // 1. allocate a new data packet into rx ring to replace received packet
- // then processing the received packet
- // 2. the callee must take charge of release of packet
- // 3. As far as driver is concerned ,
- // the rx packet must
- // a. be indicated to upper layer or
- // b. be released if it is discarded
- pRxPacket = GetPacketFromRxRing(pAd, &(RxCell.RxD), &bReschedule, &RxPending);
- if (pRxPacket == NULL)
- {
- // no more packet to process
- break;
- }
-
- // get rx ring descriptor
- pRxD = &(RxCell.RxD);
- // get rx data buffer
- pData = GET_OS_PKT_DATAPTR(pRxPacket);
- 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;
- RxCell.pRxPacket = pRxPacket;
- RxCell.pData = (UCHAR *) pHeader;
- RxCell.DataSize = pRxWI->MPDUtotalByteCount;
- RxCell.Flags = 0;
-
- // Increase Total receive byte counter after real data received no mater any error or not
- pAd->RalinkCounters.ReceivedByteCount += pRxWI->MPDUtotalByteCount;
- pAd->RalinkCounters.OneSecReceivedByteCount += pRxWI->MPDUtotalByteCount;
- pAd->RalinkCounters.RxCount ++;
-
- INC_COUNTER64(pAd->WlanCounters.ReceivedFragmentCount);
-
- if (pRxWI->MPDUtotalByteCount < 14)
- Status = NDIS_STATUS_FAILURE;
-
- if (MONITOR_ON(pAd))
- {
- send_monitor_packets(pAd, &RxCell);
- break;
- }
-
- /* STARxDoneInterruptHandle() is called 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);
-
- // Handle the received frame
- if (Status == NDIS_STATUS_SUCCESS)
- {
- switch (pHeader->FC.Type)
- {
- // CASE I, receive a DATA frame
- case BTYPE_DATA:
- {
- // process DATA frame
- STAHandleRxDataFrame(pAd, &RxCell);
- }
- break;
- // CASE II, receive a MGMT frame
- case BTYPE_MGMT:
- {
- STAHandleRxMgmtFrame(pAd, &RxCell);
- }
- break;
- // CASE III. receive a CNTL frame
- case BTYPE_CNTL:
- {
- STAHandleRxControlFrame(pAd, &RxCell);
- }
- break;
- // discard other type
- default:
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- break;
- }
- }
- else
- {
- pAd->Counters8023.RxErrors++;
- // discard this frame
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- }
- }
-
- return bReschedule;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Arguments:
- pAd Pointer to our adapter
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID RTMPHandleTwakeupInterrupt(
- IN PRTMP_ADAPTER pAd)
-{
- AsicForceWakeup(pAd, FALSE);
-}
-
-/*
-========================================================================
-Routine Description:
- Early checking and OS-depened parsing for Tx packet send to our STA driver.
-
-Arguments:
- NDIS_HANDLE MiniportAdapterContext Pointer refer to the device handle, i.e., the pAd.
- PPNDIS_PACKET ppPacketArray The packet array need to do transmission.
- UINT NumberOfPackets Number of packet in packet array.
-
-Return Value:
- NONE
-
-Note:
- This function do early checking and classification for send-out packet.
- You only can put OS-depened & STA related code in here.
-========================================================================
-*/
-VOID STASendPackets(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN PPNDIS_PACKET ppPacketArray,
- IN UINT NumberOfPackets)
-{
- UINT Index;
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) MiniportAdapterContext;
- PNDIS_PACKET pPacket;
- BOOLEAN allowToSend = FALSE;
-
-
- for (Index = 0; Index < NumberOfPackets; Index++)
- {
- pPacket = ppPacketArray[Index];
-
- do
- {
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- {
- // Drop send request since hardware is in reset state
- break;
- }
- else if (!INFRA_ON(pAd) && !ADHOC_ON(pAd))
- {
- // Drop send request since there are no physical connection yet
- break;
- }
- else
- {
- // 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);
- pAd->RalinkCounters.PendingNdisPacketCount++;
-
- allowToSend = TRUE;
- }
- } while(FALSE);
-
- if (allowToSend == TRUE)
- STASendPacket(pAd, pPacket);
- else
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
-
- // Dequeue outgoing frames from TxSwQueue[] and process it
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-
-}
-
-
-/*
-========================================================================
-Routine Description:
- This routine is used to do packet parsing and classification for Tx packet
- to STA device, and it will en-queue packets to our TxSwQueue depends on AC
- class.
-
-Arguments:
- pAd Pointer to our adapter
- pPacket Pointer to send packet
-
-Return Value:
- NDIS_STATUS_SUCCESS If succes to queue the packet into TxSwQueue.
- NDIS_STATUS_FAILURE If failed to do en-queue.
-
-Note:
- You only can put OS-indepened & STA related code in here.
-========================================================================
-*/
-NDIS_STATUS STASendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- UINT SrcBufLen;
- UINT AllowFragSize;
- UCHAR NumberOfFrag;
- UCHAR RTSRequired;
- UCHAR QueIdx, UserPriority;
- MAC_TABLE_ENTRY *pEntry = NULL;
- unsigned int IrqFlags;
- UCHAR FlgIsIP = 0;
- UCHAR Rate;
-
- // Prepare packet information structure for buffer descriptor
- // chained within a single NDIS packet.
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- if (pSrcBufVA == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket --> pSrcBufVA == NULL !!!SrcBufLen=%x\n",SrcBufLen));
- // Resourece is low, system did not allocate virtual address
- // return NDIS_STATUS_FAILURE directly to upper layer
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return NDIS_STATUS_FAILURE;
- }
-
-
- if (SrcBufLen < 14)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket --> Ndis Packet buffer error !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return (NDIS_STATUS_FAILURE);
- }
-
- // In HT rate adhoc mode, A-MPDU is often used. So need to lookup BA Table and MAC Entry.
- // Note multicast packets in adhoc also use BSSID_WCID index.
- {
- 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);
- Rate = pAd->CommonCfg.TxRate;
- }
- }
- else if (ADHOC_ON(pAd))
- {
- if (*pSrcBufVA & 0x01)
- {
- RTMP_SET_PACKET_WCID(pPacket, MCAST_WCID);
- pEntry = &pAd->MacTab.Content[MCAST_WCID];
- }
- else
- {
- pEntry = MacTableLookup(pAd, pSrcBufVA);
- }
- Rate = pAd->CommonCfg.TxRate;
- }
- }
-
- if (!pEntry)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket->Cannot find pEntry(%2x:%2x:%2x:%2x:%2x:%2x) in MacTab!\n", PRINT_MAC(pSrcBufVA)));
- // Resourece is low, system did not allocate virtual address
- // return NDIS_STATUS_FAILURE directly to upper layer
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return NDIS_STATUS_FAILURE;
- }
-
- if (ADHOC_ON(pAd)
- )
- {
- RTMP_SET_PACKET_WCID(pPacket, (UCHAR)pEntry->Aid);
- }
-
- //
- // Check the Ethernet Frame type of this packet, and set the RTMP_SET_PACKET_SPECIFIC flags.
- // Here we set the PACKET_SPECIFIC flags(LLC, VLAN, DHCP/ARP, EAPOL).
- RTMPCheckEtherType(pAd, pPacket);
-
-
-
- //
- // WPA 802.1x secured port control - drop all non-802.1x frame before port secured
- //
- 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 // WPA_SUPPLICANT_SUPPORT //
- )
- && ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || (pAd->StaCfg.MicErrCnt >= 2))
- && (RTMP_GET_PACKET_EAPOL(pPacket)== FALSE)
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("STASendPacket --> Drop packet before port secured !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-
- return (NDIS_STATUS_FAILURE);
- }
-
-
- // STEP 1. Decide number of fragments required to deliver this MSDU.
- // The estimation here is not very accurate because difficult to
- // take encryption overhead into consideration here. The result
- // "NumberOfFrag" is then just used to pre-check if enough free
- // TXD are available to hold this MSDU.
-
-
- if (*pSrcBufVA & 0x01) // fragmentation not allowed on multicast & broadcast
- NumberOfFrag = 1;
- else if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED))
- 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
- // encryption/encapsulation overhead not taken into consideration. This number is just
- // used to make sure enough free TXD are available before fragmentation takes place.
- // In case the actual required number of fragments of an NDIS packet
- // excceeds "NumberOfFrag"caculated here and not enough free TXD available, the
- // last fragment (i.e. last MPDU) will be dropped in RTMPHardTransmit() due to out of
- // resource, and the NDIS packet will be indicated NDIS_STATUS_FAILURE. This should
- // rarely happen and the penalty is just like a TX RETRY fail. Affordable.
-
- AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
- NumberOfFrag = ((PacketInfo.TotalPacketLength - LENGTH_802_3 + LENGTH_802_1_H) / AllowFragSize) + 1;
- // To get accurate number of fragmentation, Minus 1 if the size just match to allowable fragment size
- if (((PacketInfo.TotalPacketLength - LENGTH_802_3 + LENGTH_802_1_H) % AllowFragSize) == 0)
- {
- NumberOfFrag--;
- }
- }
-
- // Save fragment number to Ndis packet reserved field
- RTMP_SET_PACKET_FRAGMENTS(pPacket, NumberOfFrag);
-
-
- // STEP 2. Check the requirement of RTS:
- // If multiple fragment required, RTS is required only for the first fragment
- // if the fragment size large than RTS threshold
- // For RT28xx, Let ASIC send RTS/CTS
-// RTMP_SET_PACKET_RTS(pPacket, 0);
- if (NumberOfFrag > 1)
- RTSRequired = (pAd->CommonCfg.FragmentThreshold > pAd->CommonCfg.RtsThreshold) ? 1 : 0;
- else
- RTSRequired = (PacketInfo.TotalPacketLength > pAd->CommonCfg.RtsThreshold) ? 1 : 0;
-
- // Save RTS requirement to Ndis packet reserved field
- RTMP_SET_PACKET_RTS(pPacket, RTSRequired);
- RTMP_SET_PACKET_TXRATE(pPacket, pAd->CommonCfg.TxRate);
-
- //
- // STEP 3. Traffic classification. outcome = <UserPriority, QueIdx>
- //
- UserPriority = 0;
- QueIdx = QID_AC_BE;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE))
- {
- USHORT Protocol;
- UCHAR LlcSnapLen = 0, Byte0, Byte1;
- do
- {
- // get Ethernet protocol field
- Protocol = (USHORT)((pSrcBufVA[12] << 8) + pSrcBufVA[13]);
- if (Protocol <= 1500)
- {
- // get Ethernet protocol field from LLC/SNAP
- if (Sniff2BytesFromNdisBuffer(PacketInfo.pFirstBuffer, LENGTH_802_3 + 6, &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
- break;
-
- Protocol = (USHORT)((Byte0 << 8) + Byte1);
- LlcSnapLen = 8;
- }
-
- // always AC_BE for non-IP packet
- if (Protocol != 0x0800)
- break;
-
- // get IP header
- if (Sniff2BytesFromNdisBuffer(PacketInfo.pFirstBuffer, LENGTH_802_3 + LlcSnapLen, &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
- break;
-
- // return AC_BE if packet is not IPv4
- if ((Byte0 & 0xf0) != 0x40)
- break;
-
- FlgIsIP = 1;
- UserPriority = (Byte1 & 0xe0) >> 5;
- QueIdx = MapUserPriorityToAccessCategory[UserPriority];
-
- // TODO: have to check ACM bit. apply TSPEC if ACM is ON
- // TODO: downgrade UP & QueIdx before passing ACM
- /*
- Under WMM ACM control, we dont need to check the bit;
- Or when a TSPEC is built for VO but we will change to issue
- BA session for BE here, so we will not use BA to send VO packets.
- */
- if (pAd->CommonCfg.APEdcaParm.bACM[QueIdx])
- {
- UserPriority = 0;
- QueIdx = QID_AC_BE;
- }
- } while (FALSE);
- }
-
- RTMP_SET_PACKET_UP(pPacket, UserPriority);
-
-
-
- // Make sure SendTxWait queue resource won't be used by other threads
- RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
- 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;
- }
- else
- {
- InsertTailQueueAc(pAd, pEntry, &pAd->TxSwQueue[QueIdx], PACKET_TO_QUEUE_ENTRY(pPacket));
- }
- RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&&
- IS_HT_STA(pEntry))
- {
- //PMAC_TABLE_ENTRY pMacEntry = &pAd->MacTab.Content[BSSID_WCID];
- if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) &&
- ((pEntry->BADeclineBitmap & (1<<UserPriority)) == 0) &&
- (pEntry->PortSecured == WPA_802_1X_PORT_SECURED)
- // For IOT compatibility, if
- // 1. It is Ralink chip or
- // 2. It is OPEN or AES mode,
- // then BA session can be bulit.
- && ((pEntry->ValidAsCLI && pAd->MlmeAux.APRalinkIe != 0x0) ||
- (pEntry->WepStatus != Ndis802_11WEPEnabled && pEntry->WepStatus != Ndis802_11Encryption2Enabled))
- )
- {
- BAOriSessionSetUp(pAd, pEntry, UserPriority, 0, 10, FALSE);
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- pAd->RalinkCounters.OneSecOsTxCount[QueIdx]++; // TODO: for debug only. to be removed
- return NDIS_STATUS_SUCCESS;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- This subroutine will scan through releative ring descriptor to find
- out avaliable free ring descriptor and compare with request size.
-
- Arguments:
- pAd Pointer to our adapter
- QueIdx Selected TX Ring
-
- Return Value:
- NDIS_STATUS_FAILURE Not enough free descriptor
- NDIS_STATUS_SUCCESS Enough free descriptor
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-#ifdef RTMP_MAC_PCI
-NDIS_STATUS RTMPFreeTXDRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN UCHAR NumberRequired,
- IN PUCHAR FreeNumberIs)
-{
- ULONG FreeNumber = 0;
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
-
- switch (QueIdx)
- {
- case QID_AC_BK:
- case QID_AC_BE:
- case QID_AC_VI:
- case QID_AC_VO:
- /*case QID_HCCA:*/
- if (pAd->TxRing[QueIdx].TxSwFreeIdx > pAd->TxRing[QueIdx].TxCpuIdx)
- FreeNumber = pAd->TxRing[QueIdx].TxSwFreeIdx - pAd->TxRing[QueIdx].TxCpuIdx - 1;
- else
- FreeNumber = pAd->TxRing[QueIdx].TxSwFreeIdx + TX_RING_SIZE - pAd->TxRing[QueIdx].TxCpuIdx - 1;
-
- if (FreeNumber >= NumberRequired)
- Status = NDIS_STATUS_SUCCESS;
- break;
-
- case QID_MGMT:
- if (pAd->MgmtRing.TxSwFreeIdx > pAd->MgmtRing.TxCpuIdx)
- FreeNumber = pAd->MgmtRing.TxSwFreeIdx - pAd->MgmtRing.TxCpuIdx - 1;
- else
- FreeNumber = pAd->MgmtRing.TxSwFreeIdx + MGMT_RING_SIZE - pAd->MgmtRing.TxCpuIdx - 1;
-
- if (FreeNumber >= NumberRequired)
- Status = NDIS_STATUS_SUCCESS;
- break;
-
- default:
- DBGPRINT(RT_DEBUG_ERROR,("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
- break;
- }
- *FreeNumberIs = (UCHAR)FreeNumber;
-
- return (Status);
-}
-#endif // RTMP_MAC_PCI //
-
-
-
-VOID RTMPSendDisassociationFrame(
- IN PRTMP_ADAPTER pAd)
-{
-}
-
-VOID RTMPSendNullFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR TxRate,
- IN BOOLEAN bQosNull)
-{
- UCHAR NullFrame[48];
- 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))
- {
- return;
- }
-
- NdisZeroMemory(NullFrame, 48);
- Length = sizeof(HEADER_802_11);
-
- pHeader_802_11 = (PHEADER_802_11) NullFrame;
-
- pHeader_802_11->FC.Type = BTYPE_DATA;
- pHeader_802_11->FC.SubType = SUBTYPE_NULL_FUNC;
- pHeader_802_11->FC.ToDs = 1;
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
-
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- {
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- }
- else
- {
- pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE) ? 1: 0;
- }
- pHeader_802_11->Duration = pAd->CommonCfg.Dsifs + RTMPCalcDuration(pAd, TxRate, 14);
-
- pAd->Sequence++;
- pHeader_802_11->Sequence = pAd->Sequence;
-
- // Prepare QosNull function frame
- if (bQosNull)
- {
- pHeader_802_11->FC.SubType = SUBTYPE_QOS_NULL;
-
- // copy QOS control bytes
- NullFrame[Length] = 0;
- NullFrame[Length+1] = 0;
- Length += 2;// if pad with 2 bytes for alignment, APSD will fail
- }
-
- HAL_KickOutNullFrameTx(pAd, 0, NullFrame, Length);
-
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID RTMPSendRTSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN unsigned int NextMpduSize,
- IN UCHAR TxRate,
- IN UCHAR RTSRate,
- IN USHORT AckDuration,
- IN UCHAR QueIdx,
- IN UCHAR FrameGap)
-{
-}
-
-
-
-// --------------------------------------------------------
-// FIND ENCRYPT KEY AND DECIDE CIPHER ALGORITHM
-// Find the WPA key, either Group or Pairwise Key
-// LEAP + TKIP also use WPA key.
-// --------------------------------------------------------
-// Decide WEP bit and cipher suite to be used. Same cipher suite should be used for whole fragment burst
-// In Cisco CCX 2.0 Leap Authentication
-// WepStatus is Ndis802_11Encryption1Enabled but the key will use PairwiseKey
-// Instead of the SharedKey, SharedKey Length may be Zero.
-VOID STAFindCipherAlgorithm(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- NDIS_802_11_ENCRYPTION_STATUS Cipher; // To indicate cipher used for this packet
- UCHAR CipherAlg = CIPHER_NONE; // cipher alogrithm
- UCHAR KeyIdx = 0xff;
- PUCHAR pSrcBufVA;
- PCIPHER_KEY pKey = NULL;
-
- pSrcBufVA = GET_OS_PKT_DATAPTR(pTxBlk->pPacket);
-
- {
- // Select Cipher
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
- Cipher = pAd->StaCfg.GroupCipher; // Cipher for Multicast or Broadcast
- else
- Cipher = pAd->StaCfg.PairCipher; // Cipher for Unicast
-
- if (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
- {
- ASSERT(pAd->SharedKey[BSS0][0].CipherAlg <= CIPHER_CKIP128);
-
- // 4-way handshaking frame must be clear
- if (!(TX_BLK_TEST_FLAG(pTxBlk, fTX_bClearEAPFrame)) && (pAd->SharedKey[BSS0][0].CipherAlg) &&
- (pAd->SharedKey[BSS0][0].KeyLen))
- {
- CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
- KeyIdx = 0;
- }
- }
- else if (Cipher == Ndis802_11Encryption1Enabled)
- {
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
- else if ((Cipher == Ndis802_11Encryption2Enabled) ||
- (Cipher == Ndis802_11Encryption3Enabled))
- {
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd))) // multicast
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- else if (pAd->SharedKey[BSS0][0].KeyLen)
- KeyIdx = 0;
- else
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
-
- if (KeyIdx == 0xff)
- 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;
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- pKey = &pAd->SharedKey[BSS0][KeyIdx];
- }
- }
-
- pTxBlk->CipherAlg = CipherAlg;
- pTxBlk->pKey = pKey;
-}
-
-
-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
- //
-
- // normal wlan header size : 24 octets
- pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
-
- pHeader_802_11 = (HEADER_802_11 *) &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-
- NdisZeroMemory(pHeader_802_11, sizeof(HEADER_802_11));
-
- pHeader_802_11->FC.FrDs = 0;
- 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))
- {
- pHeader_802_11->Sequence = pTxBlk->pMacEntry->NonQosDataSeq;
- pTxBlk->pMacEntry->NonQosDataSeq = (pTxBlk->pMacEntry->NonQosDataSeq+1) & MAXSEQ;
- }
- else
- {
- {
- pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority];
- pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
- }
- }
- }
- else
- {
- pHeader_802_11->Sequence = pAd->Sequence;
- pAd->Sequence = (pAd->Sequence+1) & MAXSEQ; // next sequence
- }
-
- pHeader_802_11->Frag = 0;
-
- pHeader_802_11->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
- {
- 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);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pTxBlk->pSrcBufHeader);
- pHeader_802_11->FC.ToDs = 1;
- }
- }
- else if (ADHOC_ON(pAd))
- {
- 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;
- }
- }
-
- if (pTxBlk->CipherAlg != CIPHER_NONE)
- pHeader_802_11->FC.Wep = 1;
-
- // -----------------------------------------------------------------
- // STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
- // -----------------------------------------------------------------
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- else
- 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,
- IN UCHAR *pHeader)
-{
- MAC_TABLE_ENTRY *pMacEntry;
- PHEADER_802_11 pHeader80211;
-
- pHeader80211 = (PHEADER_802_11)pHeader;
- pMacEntry = pTxBlk->pMacEntry;
-
- //
- // Update the cached 802.11 HEADER
- //
-
- // normal wlan header size : 24 octets
- pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
-
- // More Bit
- pHeader80211->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
- // Sequence
- pHeader80211->Sequence = pMacEntry->TxSeq[pTxBlk->UserPriority];
- 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
- COPY_MAC_ADDR(pHeader80211->Addr3, pTxBlk->pSrcBufHeader);
- }
-
- // -----------------------------------------------------------------
- // STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
- // -----------------------------------------------------------------
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- pHeader80211->FC.PwrMgmt = PWR_SAVE;
- 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,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- HEADER_802_11 *pHeader_802_11;
- PNDIS_PACKET pNextPacket;
- UINT32 nextBufLen;
- PQUEUE_ENTRY pQEntry;
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // steal "order" bit to mark "aggregation"
- pHeader_802_11->FC.Order = 1;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- // padding at front of LLC header. LLC header should at 4-bytes aligment.
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PUCHAR)ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- // For RA Aggregation,
- // put the 2nd MSDU length(extra 2-byte field) after QOS_CONTROL in little endian format
- pQEntry = pTxBlk->TxPacketList.Head;
- pNextPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- nextBufLen = GET_OS_PKT_LEN(pNextPacket);
- if (RTMP_GET_PACKET_VLAN(pNextPacket))
- nextBufLen -= LENGTH_802_1Q;
-
- *pHeaderBufPtr = (UCHAR)nextBufLen & 0xff;
- *(pHeaderBufPtr+1) = (UCHAR)(nextBufLen >> 8);
-
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += 2;
-
- return pHeaderBufPtr;
-
-}
-
-#ifdef DOT11_N_SUPPORT
-static inline PUCHAR STA_Build_AMSDU_Frame_Header(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;//, pSaveBufPtr;
- HEADER_802_11 *pHeader_802_11;
-
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- //
- // A-MSDU packet
- //
- *pHeaderBufPtr |= 0x80;
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
-
- //pSaveBufPtr = pHeaderBufPtr;
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- // @@@ MpduHeaderLen excluding padding @@@
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PUCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- return pHeaderBufPtr;
-
-}
-
-
-VOID STA_AMPDU_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- MAC_TABLE_ENTRY *pMacEntry;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
- ASSERT(pTxBlk);
-
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if ( RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- pMacEntry = pTxBlk->pMacEntry;
- if (pMacEntry->isCached)
- {
- // NOTE: Please make sure the size of pMacEntry->CachedBuf[] is smaller than pTxBlk->HeaderBuf[]!!!!
- NdisMoveMemory((PUCHAR)&pTxBlk->HeaderBuf[TXINFO_SIZE], (PUCHAR)&pMacEntry->CachedBuf[0], TXWI_SIZE + sizeof(HEADER_802_11));
- pHeaderBufPtr = (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE]);
- STABuildCache802_11Header(pAd, pTxBlk, pHeaderBufPtr);
- }
- else
- {
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- }
-
-
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
-
- //
- // build HTC+
- // HTC control filed following QoS field
- //
- if ((pAd->CommonCfg.bRdg == TRUE) && CLIENT_STATUS_TEST_FLAG(pTxBlk->pMacEntry, fCLIENT_STATUS_RDG_CAPABLE))
- {
- if (pMacEntry->isCached == FALSE)
- {
- // mark HTC bit
- pHeader_802_11->FC.Order = 1;
-
- NdisZeroMemory(pHeaderBufPtr, 4);
- *(pHeaderBufPtr+3) |= 0x80;
- }
- pHeaderBufPtr += 4;
- pTxBlk->MpduHeaderLen += 4;
- }
-
- //pTxBlk->MpduHeaderLen = pHeaderBufPtr - pTxBlk->HeaderBuf - TXWI_SIZE - TXINFO_SIZE;
- ASSERT(pTxBlk->MpduHeaderLen >= 24);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- // @@@ MpduHeaderLen excluding padding @@@
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PUCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- {
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
- }
-
- if (pMacEntry->isCached)
- {
- RTMPWriteTxWI_Cache(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
- }
- else
- {
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- NdisZeroMemory((PUCHAR)(&pMacEntry->CachedBuf[0]), sizeof(pMacEntry->CachedBuf));
- NdisMoveMemory((PUCHAR)(&pMacEntry->CachedBuf[0]), (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), (pHeaderBufPtr - (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE])));
- pMacEntry->isCached = TRUE;
- }
-
- // calculate Transmitted AMPDU count and ByteCount
- {
- pAd->RalinkCounters.TransmittedMPDUsInAMPDUCount.u.LowPart ++;
- pAd->RalinkCounters.TransmittedOctetsInAMPDUCount.QuadPart += pTxBlk->SrcBufLen;
- }
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
-
- HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
- //
- // Kick out Tx
- //
- if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
- }
-
-}
-
-
-VOID STA_AMSDU_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- USHORT subFramePayloadLen = 0; // AMSDU Subframe length without AMSDU-Header / Padding.
- USHORT totalMPDUSize=0;
- UCHAR *subFrameHeader;
- UCHAR padding = 0;
- USHORT FirstTx = 0, LastTxIdx = 0;
- BOOLEAN bVLANPkt;
- int frameNum = 0;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- ASSERT((pTxBlk->TxPacketList.Number > 1));
-
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- if (frameNum == 0)
- {
- pHeaderBufPtr = STA_Build_AMSDU_Frame_Header(pAd, pTxBlk);
-
- // NOTE: TxWI->MPDUtotalByteCount will be updated after final frame was handled.
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
- }
- else
- {
- pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
- padding = ROUND_UP(LENGTH_AMSDU_SUBFRAMEHEAD + subFramePayloadLen, 4) - (LENGTH_AMSDU_SUBFRAMEHEAD + subFramePayloadLen);
- NdisZeroMemory(pHeaderBufPtr, padding + LENGTH_AMSDU_SUBFRAMEHEAD);
- pHeaderBufPtr += padding;
- pTxBlk->MpduHeaderLen = padding;
- }
-
- //
- // A-MSDU subframe
- // DA(6)+SA(6)+Length(2) + LLC/SNAP Encap
- //
- subFrameHeader = pHeaderBufPtr;
- subFramePayloadLen = pTxBlk->SrcBufLen;
-
- NdisMoveMemory(subFrameHeader, pTxBlk->pSrcBufHeader, 12);
-
-
- pHeaderBufPtr += LENGTH_AMSDU_SUBFRAMEHEAD;
- pTxBlk->MpduHeaderLen += LENGTH_AMSDU_SUBFRAMEHEAD;
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
-
- subFramePayloadLen = pTxBlk->SrcBufLen;
-
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- subFramePayloadLen += LENGTH_802_1_H;
- }
-
- // update subFrame Length field
- subFrameHeader[12] = (subFramePayloadLen & 0xFF00) >> 8;
- subFrameHeader[13] = subFramePayloadLen & 0xFF;
-
- totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
- if (frameNum ==0)
- FirstTx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
- else
- LastTxIdx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
-
- frameNum++;
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- // calculate Transmitted AMSDU Count and ByteCount
- {
- pAd->RalinkCounters.TransmittedAMSDUCount.u.LowPart ++;
- pAd->RalinkCounters.TransmittedOctetsInAMSDU.QuadPart += totalMPDUSize;
- }
-
- }
-
- HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
- HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
- //
- // Kick out Tx
- //
- if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-#endif // DOT11_N_SUPPORT //
-
-VOID STA_Legacy_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
- ASSERT(pTxBlk);
-
-
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- if (pTxBlk->TxFrameType == TX_MCAST_FRAME)
- {
- INC_COUNTER64(pAd->WlanCounters.MulticastTransmittedFrameCount);
- }
-
- if (RTMP_GET_PACKET_RTS(pTxBlk->pPacket))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bRtsRequired);
- else
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bRtsRequired);
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- if (pTxBlk->TxRate < pAd->CommonCfg.MinTxRate)
- pTxBlk->TxRate = pAd->CommonCfg.MinTxRate;
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *(pHeaderBufPtr) = ((pTxBlk->UserPriority & 0x0F) | (pAd->CommonCfg.AckPolicy[pTxBlk->QueIdx]<<5));
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- // The remaining content of MPDU header should locate at 4-octets aligment
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PUCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- {
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- //
- // if original Ethernet frame contains no LLC/SNAP,
- // then an extra LLC/SNAP encap is required
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- UCHAR vlan_size;
-
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // skip vlan tag
- vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader+12+vlan_size, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
- }
-
- //
- // prepare for TXWI
- // use Wcid as Key Index
- //
-
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
-
- HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- //
- // Kick out Tx
- //
- if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-
-VOID STA_ARalink_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- USHORT totalMPDUSize=0;
- USHORT FirstTx, LastTxIdx;
- int frameNum = 0;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- ASSERT((pTxBlk->TxPacketList.Number== 2));
-
-
- FirstTx = LastTxIdx = 0; // Is it ok init they as 0?
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- if (frameNum == 0)
- { // For first frame, we need to create the 802.11 header + padding(optional) + RA-AGG-LEN + SNAP Header
-
- pHeaderBufPtr = STA_Build_ARalink_Frame_Header(pAd, pTxBlk);
-
- // It's ok write the TxWI here, because the TxWI->MPDUtotalByteCount
- // will be updated after final frame was handled.
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
-
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
- }
- else
- { // For second aggregated frame, we need create the 802.3 header to headerBuf, because PCI will copy it to SDPtr0.
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
- pTxBlk->MpduHeaderLen = 0;
-
- // A-Ralink sub-sequent frame header is the same as 802.3 header.
- // DA(6)+SA(6)+FrameType(2)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader, 12);
- pHeaderBufPtr += 12;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen = LENGTH_ARALINK_SUBFRAMEHEAD;
- }
-
- totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
- if (frameNum ==0)
- FirstTx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
- else
- LastTxIdx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
-
- frameNum++;
-
- pAd->RalinkCounters.OneSecTxAggregationCount++;
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- }
-
- HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
- HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
- //
- // Kick out Tx
- //
- if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
-}
-
-
-VOID STA_Fragment_Frame_Tx(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- UCHAR fragNum = 0;
- PACKET_INFO PacketInfo;
- USHORT EncryptionOverhead = 0;
- UINT32 FreeMpduSize, SrcRemainingBytes;
- USHORT AckDuration;
- UINT NextMpduSize;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
- HTTRANSMIT_SETTING *pTransmit;
-
-
- ASSERT(pTxBlk);
-
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- ASSERT(TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag));
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- if (pTxBlk->CipherAlg == CIPHER_TKIP)
- {
- pTxBlk->pPacket = duplicate_pkt_with_TKIP_MIC(pAd, pTxBlk->pPacket);
- if (pTxBlk->pPacket == NULL)
- return;
- RTMP_QueryPacketInfo(pTxBlk->pPacket, &PacketInfo, &pTxBlk->pSrcBufHeader, &pTxBlk->SrcBufLen);
- }
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *)pHeaderBufPtr;
-
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PUCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- //
- // if original Ethernet frame contains no LLC/SNAP,
- // then an extra LLC/SNAP encap is required
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- UCHAR vlan_size;
-
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // skip vlan tag
- vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader+12+vlan_size, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
-
- // If TKIP is used and fragmentation is required. Driver has to
- // append TKIP MIC at tail of the scatter buffer
- // MAC ASIC will only perform IV/EIV/ICV insertion but no TKIP MIC
- if (pTxBlk->CipherAlg == CIPHER_TKIP)
- {
- RTMPCalculateMICValue(pAd, pTxBlk->pPacket, pTxBlk->pExtraLlcSnapEncap, pTxBlk->pKey, 0);
-
- // NOTE: DON'T refer the skb->len directly after following copy. Becasue the length is not adjust
- // to correct lenght, refer to pTxBlk->SrcBufLen for the packet length in following progress.
- NdisMoveMemory(pTxBlk->pSrcBufData + pTxBlk->SrcBufLen, &pAd->PrivateInfo.Tx.MIC[0], 8);
- //skb_put((RTPKT_TO_OSPKT(pTxBlk->pPacket))->tail, 8);
- pTxBlk->SrcBufLen += 8;
- pTxBlk->TotalFrameLen += 8;
- pTxBlk->CipherAlg = CIPHER_TKIP_NO_MIC;
- }
-
- //
- // calcuate the overhead bytes that encryption algorithm may add. This
- // affects the calculate of "duration" field
- //
- if ((pTxBlk->CipherAlg == CIPHER_WEP64) || (pTxBlk->CipherAlg == CIPHER_WEP128))
- EncryptionOverhead = 8; //WEP: IV[4] + ICV[4];
- else if (pTxBlk->CipherAlg == CIPHER_TKIP_NO_MIC)
- EncryptionOverhead = 12;//TKIP: IV[4] + EIV[4] + ICV[4], MIC will be added to TotalPacketLength
- else if (pTxBlk->CipherAlg == CIPHER_TKIP)
- EncryptionOverhead = 20;//TKIP: IV[4] + EIV[4] + ICV[4] + MIC[8]
- else if (pTxBlk->CipherAlg == CIPHER_AES)
- EncryptionOverhead = 16; // AES: IV[4] + EIV[4] + MIC[8]
- else
- EncryptionOverhead = 0;
-
- pTransmit = pTxBlk->pTransmit;
- // Decide the TX rate
- if (pTransmit->field.MODE == MODE_CCK)
- pTxBlk->TxRate = pTransmit->field.MCS;
- else if (pTransmit->field.MODE == MODE_OFDM)
- pTxBlk->TxRate = pTransmit->field.MCS + RATE_FIRST_OFDM_RATE;
- else
- pTxBlk->TxRate = RATE_6_5;
-
- // decide how much time an ACK/CTS frame will consume in the air
- if (pTxBlk->TxRate <= RATE_LAST_OFDM_RATE)
- AckDuration = RTMPCalcDuration(pAd, pAd->CommonCfg.ExpectedACKRate[pTxBlk->TxRate], 14);
- else
- AckDuration = RTMPCalcDuration(pAd, RATE_6_5, 14);
-
- // Init the total payload length of this frame.
- SrcRemainingBytes = pTxBlk->SrcBufLen;
-
- pTxBlk->TotalFragNum = 0xff;
-
- do {
-
- FreeMpduSize = pAd->CommonCfg.FragmentThreshold - LENGTH_CRC;
-
- FreeMpduSize -= pTxBlk->MpduHeaderLen;
-
- if (SrcRemainingBytes <= FreeMpduSize)
- { // this is the last or only fragment
-
- pTxBlk->SrcBufLen = SrcRemainingBytes;
-
- pHeader_802_11->FC.MoreFrag = 0;
- pHeader_802_11->Duration = pAd->CommonCfg.Dsifs + AckDuration;
-
- // Indicate the lower layer that this's the last fragment.
- pTxBlk->TotalFragNum = fragNum;
- }
- else
- { // more fragment is required
-
- pTxBlk->SrcBufLen = FreeMpduSize;
-
- NextMpduSize = min(((UINT)SrcRemainingBytes - pTxBlk->SrcBufLen), ((UINT)pAd->CommonCfg.FragmentThreshold));
- pHeader_802_11->FC.MoreFrag = 1;
- pHeader_802_11->Duration = (3 * pAd->CommonCfg.Dsifs) + (2 * AckDuration) + RTMPCalcDuration(pAd, pTxBlk->TxRate, NextMpduSize + EncryptionOverhead);
- }
-
- if (fragNum == 0)
- pTxBlk->FrameGap = IFS_HTTXOP;
- else
- pTxBlk->FrameGap = IFS_SIFS;
-
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, &FreeNumber);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- // Update the frame number, remaining size of the NDIS packet payload.
-
- // space for 802.11 header.
- if (fragNum == 0 && pTxBlk->pExtraLlcSnapEncap)
- pTxBlk->MpduHeaderLen -= LENGTH_802_1_H;
-
- fragNum++;
- SrcRemainingBytes -= pTxBlk->SrcBufLen;
- pTxBlk->pSrcBufData += pTxBlk->SrcBufLen;
-
- pHeader_802_11->Frag++; // increase Frag #
-
- }while(SrcRemainingBytes > 0);
-
- //
- // Kick out Tx
- //
- if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-
-#define RELEASE_FRAMES_OF_TXBLK(_pAd, _pTxBlk, _pQEntry, _Status) \
- while(_pTxBlk->TxPacketList.Head) \
- { \
- _pQEntry = RemoveHeadQueue(&_pTxBlk->TxPacketList); \
- RELEASE_NDIS_PACKET(_pAd, QUEUE_ENTRY_TO_PACKET(_pQEntry), _Status); \
- }
-
-
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware encryption before really
- sent out to air.
-
- Arguments:
- pAd Pointer to our adapter
- PNDIS_PACKET Pointer to outgoing Ndis frame
- NumberOfFrag Number of fragment required
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS STAHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx)
-{
- NDIS_PACKET *pPacket;
- PQUEUE_ENTRY pQEntry;
-
- // ---------------------------------------------
- // STEP 0. DO SANITY CHECK AND SOME EARLY PREPARATION.
- // ---------------------------------------------
- //
- ASSERT(pTxBlk->TxPacketList.Number);
- if (pTxBlk->TxPacketList.Head == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("pTxBlk->TotalFrameNum == %ld!\n", pTxBlk->TxPacketList.Number));
- return NDIS_STATUS_FAILURE;
- }
-
- pPacket = QUEUE_ENTRY_TO_PACKET(pTxBlk->TxPacketList.Head);
-
-
- // ------------------------------------------------------------------
- // STEP 1. WAKE UP PHY
- // outgoing frame always wakeup PHY to prevent frame lost and
- // turn off PSM bit to improve performance
- // ------------------------------------------------------------------
- // not to change PSM bit, just send this frame out?
- if ((pAd->StaCfg.Psm == PWR_SAVE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- DBGPRINT_RAW(RT_DEBUG_INFO, ("AsicForceWakeup At HardTx\n"));
-#ifdef RTMP_MAC_PCI
- AsicForceWakeup(pAd, TRUE);
-#endif // RTMP_MAC_PCI //
- }
-
- // It should not change PSM bit, when APSD turn on.
- if ((!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable) && (pAd->CommonCfg.bAPSDForcePowerSave == FALSE))
- || (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
- || (RTMP_GET_PACKET_WAI(pTxBlk->pPacket)))
- {
- if ((pAd->StaCfg.Psm == PWR_SAVE) &&
- (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeFast_PSP))
- RTMP_SET_PSM_BIT(pAd, PWR_ACTIVE);
- }
-
- 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;
- case TX_MCAST_FRAME:
- STA_Legacy_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_RALINK_FRAME:
- STA_ARalink_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_FRAG_FRAME:
- STA_Fragment_Frame_Tx(pAd, pTxBlk);
- break;
- default:
- {
- // It should not happened!
- DBGPRINT(RT_DEBUG_ERROR, ("Send a pacekt was not classified!! It should not happen!\n"));
- while(pTxBlk->TxPacketList.Number)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (pPacket)
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
- }
- break;
- }
-
- return (NDIS_STATUS_SUCCESS);
-
-}
-
-ULONG HashBytesPolynomial(UCHAR *value, unsigned int len)
-{
- unsigned char *word = value;
- unsigned int ret = 0;
- unsigned int i;
-
- for(i=0; i < len; i++)
- {
- int mod = i % 32;
- ret ^=(unsigned int) (word[i]) << mod;
- ret ^=(unsigned int) (word[i]) >> (32 - mod);
- }
- return ret;
-}
-
-VOID Sta_Announce_or_Forward_802_3_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID)
-{
- if (TRUE
- )
- {
- announce_802_3_packet(pAd, pPacket);
- }
- else
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
-}
diff --git a/drivers/staging/rt3090/sta/sanity.c b/drivers/staging/rt3090/sta/sanity.c
deleted file mode 100644
index aeda15bd5bca..000000000000
--- a/drivers/staging/rt3090/sta/sanity.c
+++ /dev/null
@@ -1,382 +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:
- sanity.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 add WMM support
-*/
-
-#include "../rt_config.h"
-
-
-extern UCHAR CISCO_OUI[];
-
-extern UCHAR WPA_OUI[];
-extern UCHAR RSN_OUI[];
-extern UCHAR WME_INFO_ELEM[];
-extern UCHAR WME_PARM_ELEM[];
-extern UCHAR Ccx2QosInfo[];
-extern UCHAR RALINK_OUI[];
-extern UCHAR BROADCOM_OUI[];
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN MlmeStartReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen)
-{
- MLME_START_REQ_STRUCT *Info;
-
- Info = (MLME_START_REQ_STRUCT *)(Msg);
-
- if (Info->SsidLen > MAX_LEN_OF_SSID)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqSanity fail - wrong SSID length\n"));
- return FALSE;
- }
-
- *pSsidLen = Info->SsidLen;
- NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT USHORT *pAid,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- OUT UCHAR *pHtCapabilityLen,
- OUT UCHAR *pAddHtInfoLen,
- OUT UCHAR *pNewExtChannelOffset,
- OUT PEDCA_PARM pEdcaParm,
- OUT UCHAR *pCkipFlag)
-{
- CHAR IeType, *Ptr;
- PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PEID_STRUCT pEid;
- ULONG Length = 0;
-
- *pNewExtChannelOffset = 0xff;
- *pHtCapabilityLen = 0;
- *pAddHtInfoLen = 0;
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- Ptr = (PCHAR)pFrame->Octet;
- Length += LENGTH_802_11;
-
- NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
- Length += 2;
- NdisMoveMemory(pStatus, &pFrame->Octet[2], 2);
- Length += 2;
- *pCkipFlag = 0;
- *pExtRateLen = 0;
- pEdcaParm->bValid = FALSE;
-
- if (*pStatus != MLME_SUCCESS)
- return TRUE;
-
- NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
- Length += 2;
-
- // Aid already swaped byte order in RTMPFrameEndianChange() for big endian platform
- *pAid = (*pAid) & 0x3fff; // AID is low 14-bit
-
- // -- get supported rates from payload and advance the pointer
- IeType = pFrame->Octet[6];
- *pSupRateLen = pFrame->Octet[7];
- if ((IeType != IE_SUPP_RATES) || (*pSupRateLen > MAX_LEN_OF_SUPPORTED_RATES))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
- return FALSE;
- }
- else
- NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
-
-
- Length = Length + 2 + *pSupRateLen;
-
- // many AP implement proprietary IEs in non-standard order, we'd better
- // tolerate mis-ordered IEs to get best compatibility
- pEid = (PEID_STRUCT) &pFrame->Octet[8 + (*pSupRateLen)];
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- switch (pEid->Eid)
- {
- case IE_EXT_SUPP_RATES:
- if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
- *pExtRateLen = pEid->Len;
- }
- break;
-
- case IE_HT_CAP:
- case IE_HT_CAP2:
- if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
- {
- NdisMoveMemory(pHtCapability, pEid->Octet, SIZE_HT_CAP_IE);
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
-
- *pHtCapabilityLen = SIZE_HT_CAP_IE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
- }
-
- break;
-#ifdef DOT11_N_SUPPORT
- case IE_ADD_HT:
- case IE_ADD_HT2:
- if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
- {
- // This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
- // copy first sizeof(ADD_HT_INFO_IE)
- NdisMoveMemory(pAddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
-
- *(USHORT *)(&pAddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo2));
- *(USHORT *)(&pAddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo3));
-
- *pAddHtInfoLen = SIZE_ADD_HT_INFO_IE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
- }
-
- break;
- case IE_SECONDARY_CH_OFFSET:
- if (pEid->Len == 1)
- {
- *pNewExtChannelOffset = pEid->Octet[0];
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
- }
-#endif // DOT11_N_SUPPORT //
- break;
-
- case IE_VENDOR_SPECIFIC:
- // handle WME PARAMTER ELEMENT
- if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6) && (pEid->Len == 24))
- {
- PUCHAR ptr;
- int i;
-
- // parsing EDCA parameters
- pEdcaParm->bValid = TRUE;
- pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
- pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
- pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
- //pEdcaParm->bMoreDataAck = FALSE; // pEid->Octet[0] & 0x80;
- pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
- pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
- ptr = (PUCHAR)&pEid->Octet[8];
- for (i=0; i<4; i++)
- {
- UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
- pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
- pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
- pEdcaParm->Cwmin[aci] = *(ptr+1) & 0x0f; // b0~4 is Cwmin
- pEdcaParm->Cwmax[aci] = *(ptr+1) >> 4; // b5~8 is Cwmax
- pEdcaParm->Txop[aci] = *(ptr+2) + 256 * (*(ptr+3)); // in unit of 32-us
- ptr += 4; // point to next AC
- }
- }
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity - ignore unrecognized EID = %d\n", pEid->Eid));
- break;
- }
-
- Length = Length + 2 + pEid->Len;
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerProbeReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen)
-{
- UCHAR Idx;
- UCHAR RateLen;
- CHAR IeType;
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-
- if ((pFrame->Octet[0] != IE_SSID) || (pFrame->Octet[1] > MAX_LEN_OF_SSID))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",pFrame->Octet[0],pFrame->Octet[1]));
- return FALSE;
- }
-
- *pSsidLen = pFrame->Octet[1];
- NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
-
- Idx = *pSsidLen + 2;
-
- // -- get supported rates from payload and advance the pointer
- IeType = pFrame->Octet[Idx];
- RateLen = pFrame->Octet[Idx + 1];
- if (IeType != IE_SUPP_RATES)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",pFrame->Octet[Idx],pFrame->Octet[Idx+1]));
- return FALSE;
- }
- else
- {
- if ((pAd->CommonCfg.PhyMode == PHY_11G) && (RateLen < 8))
- return (FALSE);
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN GetTimBit(
- IN CHAR *Ptr,
- IN USHORT Aid,
- OUT UCHAR *TimLen,
- OUT UCHAR *BcastFlag,
- OUT UCHAR *DtimCount,
- OUT UCHAR *DtimPeriod,
- OUT UCHAR *MessageToMe)
-{
- UCHAR BitCntl, N1, N2, MyByte, MyBit;
- CHAR *IdxPtr;
-
- IdxPtr = Ptr;
-
- IdxPtr ++;
- *TimLen = *IdxPtr;
-
- // get DTIM Count from TIM element
- IdxPtr ++;
- *DtimCount = *IdxPtr;
-
- // get DTIM Period from TIM element
- IdxPtr++;
- *DtimPeriod = *IdxPtr;
-
- // get Bitmap Control from TIM element
- IdxPtr++;
- BitCntl = *IdxPtr;
-
- if ((*DtimCount == 0) && (BitCntl & 0x01))
- *BcastFlag = TRUE;
- else
- *BcastFlag = FALSE;
-
- // Parse Partial Virtual Bitmap from TIM element
- N1 = BitCntl & 0xfe; // N1 is the first bitmap byte#
- N2 = *TimLen - 4 + N1; // N2 is the last bitmap byte#
-
- if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
- *MessageToMe = FALSE;
- else
- {
- MyByte = (Aid >> 3) - N1; // my byte position in the bitmap byte-stream
- MyBit = Aid % 16 - ((MyByte & 0x01)? 8:0);
-
- IdxPtr += (MyByte + 1);
-
- //if (*IdxPtr)
- // DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
-
- if (*IdxPtr & (0x01 << MyBit))
- *MessageToMe = TRUE;
- else
- *MessageToMe = FALSE;
- }
-
- return TRUE;
-}
diff --git a/drivers/staging/rt3090/sta/sync.c b/drivers/staging/rt3090/sta/sync.c
deleted file mode 100644
index 2520e038cb82..000000000000
--- a/drivers/staging/rt3090/sta/sync.c
+++ /dev/null
@@ -1,1840 +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:
- sync.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 modified for rt2561/2661
- Jan Lee 2006-08-01 modified for rt2860 for 802.11n
-*/
-
-#include "../rt_config.h"
-
-
-#define ADHOC_ENTRY_BEACON_LOST_TIME (2*OS_HZ) // 2 sec
-
-/*
- ==========================================================================
- Description:
- The sync state machine,
- Parameters:
- Sm - pointer to the state machine
- Note:
- the state machine looks like the following
-
- ==========================================================================
- */
-VOID SyncStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_SYNC_STATE, MAX_SYNC_MSG, (STATE_MACHINE_FUNC)Drop, SYNC_IDLE, SYNC_MACHINE_BASE);
-
- // column 1
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)MlmeScanReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)MlmeJoinReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)MlmeStartReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeacon);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction);
-
- //column 2
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtJoinAction);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_BEACON_TIMEOUT, (STATE_MACHINE_FUNC)BeaconTimeoutAtJoinAction);
-
- // column 3
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_PROBE_RSP, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_SCAN_TIMEOUT, (STATE_MACHINE_FUNC)ScanTimeoutAction);
-
- // timer init
- RTMPInitTimer(pAd, &pAd->MlmeAux.BeaconTimer, GET_TIMER_FUNCTION(BeaconTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.ScanTimer, GET_TIMER_FUNCTION(ScanTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- Beacon timeout handler, executed in timer thread
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID BeaconTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- DBGPRINT(RT_DEBUG_TRACE,("SYNC - BeaconTimeout\n"));
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
- )
- {
- UCHAR BBPValue = 0;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- BBPValue |= 0x10;
- 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);
- RTMP_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Scan timeout handler, executed in timer thread
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ScanTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
- if (MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL))
- {
- RTMP_MLME_HANDLER(pAd);
-}
- else
- {
- // To prevent SyncMachine.CurrState is SCAN_LISTEN forever.
- pAd->MlmeAux.Channel = 0;
- ScanNextChannel(pAd);
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME SCAN req state machine procedure
- ==========================================================================
- */
-VOID MlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType, BBPValue = 0;
- BOOLEAN TimerCancelled;
- ULONG Now;
- USHORT Status;
- PHEADER_802_11 pHdr80211;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
-
- // Check the total scan tries for one single OID command
- // If this is the CCX 2.0 Case, skip that!
- if ( !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeScanReqAction before Startup\n"));
- return;
- }
-
- // Increase the scan retry counters.
- pAd->StaCfg.ScanCnt++;
-
-#ifdef RTMP_MAC_PCI
- if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
- (IDLE_ON(pAd)) &&
- (pAd->StaCfg.bRadio == TRUE) &&
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
- {
- if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
- {
- AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
- AsicCheckCommanOk(pAd, PowerWakeCID);
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
- DBGPRINT(RT_DEBUG_TRACE, ("PSM - Issue Wake up command \n"));
- }
- else
- {
- RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
- }
- }
-#endif // RTMP_MAC_PCI //
-
- // first check the parameter sanity
- if (MlmeScanReqSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- &BssType,
- (PCHAR)Ssid,
- &SsidLen,
- &ScanType))
- {
-
- // Check for channel load and noise hist request
- // Suspend MSDU only at scan request, not the last two mentioned
- // Suspend MSDU transmission here
- RTMPSuspendMsduTransmission(pAd);
-
- //
- // To prevent data lost.
- // Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
- // And should send an NULL data with turned PSM bit off to AP, when scan progress done
- //
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
- {
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- pHdr80211 = (PHEADER_802_11) pOutBuffer;
- MgtMacHeaderInit(pAd, pHdr80211, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pHdr80211->Duration = 0;
- pHdr80211->FC.Type = BTYPE_DATA;
- pHdr80211->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqAction -- Send PSM Data frame for off channel RM\n"));
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPusecDelay(5000);
- }
- }
-
- NdisGetSystemUpTime(&Now);
- pAd->StaCfg.LastScanTime = Now;
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
-
- // record desired BSS parameters
- pAd->MlmeAux.BssType = BssType;
- pAd->MlmeAux.ScanType = ScanType;
- pAd->MlmeAux.SsidLen = SsidLen;
- NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
-
- // start from the first channel
- pAd->MlmeAux.Channel = FirstChannel(pAd);
-
- // Let BBP register at 20MHz to do scan
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
- ScanNextChannel(pAd);
- }
- else
- {
- DBGPRINT_ERR(("SYNC - MlmeScanReqAction() sanity check fail\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME JOIN req state machine procedure
- ==========================================================================
- */
-VOID MlmeJoinReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR BBPValue = 0;
- BSS_ENTRY *pBss;
- BOOLEAN TimerCancelled;
- HEADER_802_11 Hdr80211;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- PUCHAR pOutBuffer = NULL;
- PUCHAR pSupRate = NULL;
- UCHAR SupRateLen;
- PUCHAR pExtRate = NULL;
- UCHAR ExtRateLen;
- UCHAR ASupRate[] = {0x8C, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6C};
- UCHAR ASupRateLen = sizeof(ASupRate)/sizeof(UCHAR);
- MLME_JOIN_REQ_STRUCT *pInfo = (MLME_JOIN_REQ_STRUCT *)(Elem->Msg);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
-
-#ifdef RTMP_MAC_PCI
- if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
- (IDLE_ON(pAd)) &&
- (pAd->StaCfg.bRadio == TRUE) &&
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
- {
- RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
- }
-#endif // RTMP_MAC_PCI //
-
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- pBss = &pAd->MlmeAux.SsidBssTab.BssEntry[pInfo->BssIdx];
-
- // record the desired SSID & BSSID we're waiting for
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pBss->Bssid);
-
- // If AP's SSID is not hidden, it is OK for updating ssid to MlmeAux again.
- if (pBss->Hidden == 0)
- {
- RTMPZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, pBss->Ssid, pBss->SsidLen);
- pAd->MlmeAux.SsidLen = pBss->SsidLen;
- }
-
- pAd->MlmeAux.BssType = pBss->BssType;
- 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);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
-
- // switch channel and waiting for beacon timer
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
-
- RTMPSetTimer(&pAd->MlmeAux.BeaconTimer, JOIN_TIMEOUT);
-
- do
- {
- 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 //
- )
- {
- //
- // We can't send any Probe request frame to meet 802.11h.
- //
- if (pBss->Hidden == 0)
- break;
- }
-
- //
- // send probe request
- //
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- if (pAd->MlmeAux.Channel <= 14)
- {
- pSupRate = pAd->CommonCfg.SupRate;
- SupRateLen = pAd->CommonCfg.SupRateLen;
- pExtRate = pAd->CommonCfg.ExtRate;
- ExtRateLen = pAd->CommonCfg.ExtRateLen;
- }
- else
- {
- //
- // Overwrite Support Rate, CCK rate are not allowed
- //
- pSupRate = ASupRate;
- SupRateLen = ASupRateLen;
- ExtRateLen = 0;
- }
-
- if (pAd->MlmeAux.BssType == BSS_INFRA)
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, pAd->MlmeAux.Bssid, pAd->MlmeAux.Bssid);
- else
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &SupRateLen,
- SupRateLen, pSupRate,
- END_OF_ARGS);
-
- if (ExtRateLen)
- {
- ULONG Tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtRateIe,
- 1, &ExtRateLen,
- ExtRateLen, pExtRate,
- END_OF_ARGS);
- FrameLen += Tmp;
- }
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- } while (FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Switch to ch %d, Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x\n",
- pBss->Channel, pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2], pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
-
- pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON;
-}
-
-/*
- ==========================================================================
- Description:
- MLME START Request state machine procedure, starting an IBSS
- ==========================================================================
- */
-VOID MlmeStartReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen;
- BOOLEAN TimerCancelled;
-
- // New for WPA security suites
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- LARGE_INTEGER TimeStamp;
- BOOLEAN Privacy;
- USHORT Status;
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- TimeStamp.u.LowPart = 0;
- TimeStamp.u.HighPart = 0;
-
- if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, (PCHAR)Ssid, &SsidLen))
- {
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- //
- // Start a new IBSS. All IBSS parameters are decided now....
- //
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - Start a new IBSS. All IBSS parameters are decided now.... \n"));
- pAd->MlmeAux.BssType = BSS_ADHOC;
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
- pAd->MlmeAux.SsidLen = SsidLen;
-
- // generate a radom number as BSSID
- MacAddrRandomBssid(pAd, pAd->MlmeAux.Bssid);
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - generate a radom number as BSSID \n"));
-
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- pAd->MlmeAux.CapabilityInfo = CAP_GENERATE(0,1,Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 1, 0);
- pAd->MlmeAux.BeaconPeriod = pAd->CommonCfg.BeaconPeriod;
- pAd->MlmeAux.AtimWin = pAd->StaCfg.AtimWin;
- pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
-
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.CentralChannel;
-
- pAd->MlmeAux.SupRateLen= pAd->CommonCfg.SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
- 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);
- pAd->MlmeAux.HtCapabilityLen = sizeof(HT_CAPABILITY_IE);
- // Not turn pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE here.
- 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;
- NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
- }
- // temporarily not support QOS in IBSS
- NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
-
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeStartReqAction(ch= %d,sup rates= %d, ext rates=%d)\n",
- pAd->MlmeAux.Channel, pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
- }
- else
- {
- DBGPRINT_ERR(("SYNC - MlmeStartReqAction() sanity check fail.\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- peer sends beacon back when scanning
- ==========================================================================
- */
-VOID PeerBeaconAtScanAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, NewChannel,
- SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe;
- CF_PARM CfParm;
- USHORT BeaconPeriod, AtimWin, CapabilityInfo;
- PFRAME_802_11 pFrame;
- LARGE_INTEGER TimeStamp;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- USHORT LenVIE;
- UCHAR CkipFlag;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- ULONG RalinkIe;
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
-
- // NdisFillMemory(Ssid, MAX_LEN_OF_SSID, 0x00);
- pFrame = (PFRAME_802_11) Elem->Msg;
- // 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,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- (PCHAR)Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &CfParm,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- ULONG Idx;
- CHAR Rssi = 0;
-
- Idx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Idx != BSS_NOT_FOUND)
- Rssi = pAd->ScanTab.BssEntry[Idx].Rssi;
-
- 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 //
-
- Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (PCHAR)Ssid, SsidLen, BssType, BeaconPeriod,
- &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);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
- }
-
- }
- // sanity check fail, ignored
-}
-
-/*
- ==========================================================================
- Description:
- When waiting joining the (I)BSS, beacon received from external
- ==========================================================================
- */
-VOID PeerBeaconAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe,
- DtimCount, DtimPeriod, BcastFlag, NewChannel;
- LARGE_INTEGER TimeStamp;
- USHORT BeaconPeriod, AtimWin, CapabilityInfo;
- CF_PARM Cf;
- BOOLEAN TimerCancelled;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- UCHAR CkipFlag;
- USHORT LenVIE;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- USHORT Status;
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- ULONG RalinkIe;
- ULONG Idx;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-#ifdef DOT11_N_SUPPORT
- UCHAR CentralChannel;
- BOOLEAN bAllowNrate = FALSE;
-#endif // DOT11_N_SUPPORT //
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- (PCHAR)Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &Cf,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- // Disqualify 11b only adhoc when we are in 11g only adhoc mode
- if ((BssType == BSS_ADHOC) && (pAd->CommonCfg.PhyMode == PHY_11G) && ((SupRateLen+ExtRateLen)< 12))
- return;
-
- // BEACON from desired BSS/IBSS found. We should be able to decide most
- // BSS parameters here.
- // Q. But what happen if this JOIN doesn't conclude a successful ASSOCIATEION?
- // Do we need to receover back all parameters belonging to previous BSS?
- // A. Should be not. There's no back-door recover to previous AP. It still need
- // a new JOIN-AUTH-ASSOC sequence.
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - receive desired BEACON at JoinWaitBeacon... Channel = %d\n", Channel));
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- // Update RSSI to prevent No signal display when cards first initialized
- pAd->StaCfg.RssiSample.LastRssi0 = ConvertToRssi(pAd, Elem->Rssi0, RSSI_0);
- pAd->StaCfg.RssiSample.LastRssi1 = ConvertToRssi(pAd, Elem->Rssi1, RSSI_1);
- pAd->StaCfg.RssiSample.LastRssi2 = ConvertToRssi(pAd, Elem->Rssi2, RSSI_2);
- pAd->StaCfg.RssiSample.AvgRssi0 = pAd->StaCfg.RssiSample.LastRssi0;
- pAd->StaCfg.RssiSample.AvgRssi0X8 = pAd->StaCfg.RssiSample.AvgRssi0 << 3;
- pAd->StaCfg.RssiSample.AvgRssi1 = pAd->StaCfg.RssiSample.LastRssi1;
- pAd->StaCfg.RssiSample.AvgRssi1X8 = pAd->StaCfg.RssiSample.AvgRssi1 << 3;
- pAd->StaCfg.RssiSample.AvgRssi2 = pAd->StaCfg.RssiSample.LastRssi2;
- pAd->StaCfg.RssiSample.AvgRssi2X8 = pAd->StaCfg.RssiSample.AvgRssi2 << 3;
-
- //
- // We need to check if SSID only set to any, then we can record the current SSID.
- // Otherwise will cause hidden SSID association failed.
- //
- if (pAd->MlmeAux.SsidLen == 0)
- {
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
- pAd->MlmeAux.SsidLen = SsidLen;
- }
- else
- {
- Idx = BssSsidTableSearch(&pAd->ScanTab, Bssid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, Channel);
-
- if (Idx == BSS_NOT_FOUND)
- {
- CHAR Rssi = 0;
- Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
- Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (CHAR *) Ssid, SsidLen, BssType, BeaconPeriod,
- &Cf, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
- &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
- &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
- if (Idx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
- CapabilityInfo = pAd->ScanTab.BssEntry[Idx].CapabilityInfo;
- }
- }
- else
- {
- //
- // Multiple SSID case, used correct CapabilityInfo
- //
- CapabilityInfo = pAd->ScanTab.BssEntry[Idx].CapabilityInfo;
- }
- }
- NdisMoveMemory(pAd->MlmeAux.Bssid, Bssid, MAC_ADDR_LEN);
- pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
- pAd->MlmeAux.BssType = BssType;
- pAd->MlmeAux.BeaconPeriod = BeaconPeriod;
- pAd->MlmeAux.Channel = Channel;
- pAd->MlmeAux.AtimWin = AtimWin;
- pAd->MlmeAux.CfpPeriod = Cf.CfpPeriod;
- pAd->MlmeAux.CfpMaxDuration = Cf.CfpMaxDuration;
- pAd->MlmeAux.APRalinkIe = RalinkIe;
-
- // Copy AP's supported rate to MlmeAux for creating assoication request
- // Also filter out not supported rate
- pAd->MlmeAux.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
- pAd->MlmeAux.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-
- NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, 16);
-
-
-#ifdef DOT11_N_SUPPORT
- if (((pAd->StaCfg.WepStatus != Ndis802_11WEPEnabled) && (pAd->StaCfg.WepStatus != Ndis802_11Encryption2Enabled))
- || (pAd->CommonCfg.HT_DisallowTKIP == FALSE))
- {
- bAllowNrate = TRUE;
- }
-
- pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
- pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen;
-
- RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- // filter out un-supported ht rates
- if (((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0)) &&
- ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (bAllowNrate)))
- {
- RTMPMoveMemory(&pAd->MlmeAux.AddHtInfo, &AddHtInfo, SIZE_ADD_HT_INFO_IE);
-
- // StaActive.SupportedHtPhy.MCSSet stores Peer AP's 11n Rx capability
- NdisMoveMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, HtCapability.MCSSet, 16);
- pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
- pAd->MlmeAux.HtCapabilityLen = SIZE_HT_CAP_IE;
- pAd->StaActive.SupportedPhyInfo.bHtEnable = TRUE;
- if (PreNHtCapabilityLen > 0)
- pAd->StaActive.SupportedPhyInfo.bPreNHt = TRUE;
- RTMPCheckHt(pAd, BSSID_WCID, &HtCapability, &AddHtInfo);
- // Copy AP Parameter to StaActive. This is also in LinkUp.
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n",
- pAd->StaActive.SupportedHtPhy.MpduDensity, pAd->StaActive.SupportedHtPhy.MaxRAmpduFactor, HtCapability.HtCapInfo.ChannelWidth));
-
- if (AddHtInfoLen > 0)
- {
- CentralChannel = AddHtInfo.ControlChan;
- // Check again the Bandwidth capability of this AP.
- if ((AddHtInfo.ControlChan > 2)&& (AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- CentralChannel = AddHtInfo.ControlChan - 2;
- }
- else if ((AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- CentralChannel = AddHtInfo.ControlChan + 2;
- }
-
- // Check Error .
- if (pAd->MlmeAux.CentralChannel != CentralChannel)
- DBGPRINT(RT_DEBUG_ERROR, ("PeerBeaconAtJoinAction HT===>Beacon Central Channel = %d, Control Channel = %d. Mlmeaux CentralChannel = %d\n", CentralChannel, AddHtInfo.ControlChan, pAd->MlmeAux.CentralChannel));
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction HT===>Central Channel = %d, Control Channel = %d, .\n", CentralChannel, AddHtInfo.ControlChan));
-
- }
-
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // To prevent error, let legacy AP must have same CentralChannel and Channel.
- if ((HtCapabilityLen == 0) && (PreNHtCapabilityLen == 0))
- pAd->MlmeAux.CentralChannel = pAd->MlmeAux.Channel;
-
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- pAd->MlmeAux.NewExtChannelOffset = 0xff;
- RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- pAd->MlmeAux.HtCapabilityLen = 0;
- RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo, SIZE_ADD_HT_INFO_IE);
- }
-
- RTMPUpdateMlmeRate(pAd);
-
- // 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));
- NdisMoveMemory(&pAd->MlmeAux.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisMoveMemory(&pAd->MlmeAux.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
- else
- {
- NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
-
- if (AironetCellPowerLimit != 0xFF)
- {
- //We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power
- ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
- }
- else //Used the default TX Power Percentage.
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
- }
- // not to me BEACON, ignored
- }
- // sanity check fail, ignore this frame
-}
-
-/*
- ==========================================================================
- Description:
- receive BEACON from peer
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerBeacon(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- CHAR Ssid[MAX_LEN_OF_SSID];
- CF_PARM CfParm;
- UCHAR SsidLen, MessageToMe=0, BssType, Channel, NewChannel, index=0;
- UCHAR DtimCount=0, DtimPeriod=0, BcastFlag=0;
- USHORT CapabilityInfo, AtimWin, BeaconPeriod;
- LARGE_INTEGER TimeStamp;
- USHORT TbttNumToNextWakeUp;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- UCHAR CkipFlag;
- USHORT LenVIE;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- ULONG RalinkIe;
- // New for WPA security suites
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen, PreNHtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- if (!(INFRA_ON(pAd) || ADHOC_ON(pAd)
- ))
- return;
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &CfParm,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- BOOLEAN is_my_bssid, is_my_ssid;
- ULONG Bssidx, Now;
- BSS_ENTRY *pBss;
- CHAR RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
- is_my_bssid = MAC_ADDR_EQUAL(Bssid, pAd->CommonCfg.Bssid)? TRUE : FALSE;
- is_my_ssid = SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen)? TRUE:FALSE;
-
-
- // ignore BEACON not for my SSID
- if ((! is_my_ssid) && (! is_my_bssid))
- return;
-
- // It means STA waits disassoc completely from this AP, ignores this beacon.
- 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.
- //
- Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Bssidx == BSS_NOT_FOUND)
- {
- // discover new AP of this network, create BSS entry
- 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, CkipFlag, &EdcaParm, &QosCapability,
- &QbssLoad, LenVIE, pVIE);
- if (Bssidx == BSS_NOT_FOUND) // return if BSS table full
- return;
-
- NdisMoveMemory(pAd->ScanTab.BssEntry[Bssidx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
-
-
-
- }
-
- if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0) && (Channel != NewChannel))
- {
- // Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection).
- // In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results.
- AsicSwitchChannel(pAd, 1, FALSE);
- AsicLockChannel(pAd, 1);
- LinkDown(pAd, FALSE);
- MlmeQueueInit(&pAd->Mlme.Queue);
- BssTableInit(&pAd->ScanTab);
- RTMPusecDelay(1000000); // use delay to prevent STA do reassoc
-
- // channel sanity check
- for (index = 0 ; index < pAd->ChannelListNum; index++)
- {
- if (pAd->ChannelList[index].Channel == NewChannel)
- {
- pAd->ScanTab.BssEntry[Bssidx].Channel = NewChannel;
- pAd->CommonCfg.Channel = NewChannel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeacon - STA receive channel switch announcement IE (New Channel =%d)\n", NewChannel));
- break;
- }
- }
-
- if (index >= pAd->ChannelListNum)
- {
- DBGPRINT_ERR(("PeerBeacon(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum));
- }
- }
-
- // if the ssid matched & bssid unmatched, we should select the bssid with large value.
- // This might happened when two STA start at the same time
- if ((! is_my_bssid) && ADHOC_ON(pAd))
- {
- INT i;
-
- // Add the safeguard against the mismatch of adhoc wep status
- if (pAd->StaCfg.WepStatus != pAd->ScanTab.BssEntry[Bssidx].WepStatus)
- {
- return;
- }
-
- // collapse into the ADHOC network which has bigger BSSID value.
- for (i = 0; i < 6; i++)
- {
- if (Bssid[i] > pAd->CommonCfg.Bssid[i])
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - merge to the IBSS with bigger BSSID=%02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
- AsicDisableSync(pAd);
- COPY_MAC_ADDR(pAd->CommonCfg.Bssid, Bssid);
- AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
- MakeIbssBeacon(pAd); // re-build BEACON frame
- AsicEnableIbssSync(pAd); // copy BEACON frame to on-chip memory
- is_my_bssid = TRUE;
- break;
- }
- else if (Bssid[i] < pAd->CommonCfg.Bssid[i])
- break;
- }
- }
-
-
- NdisGetSystemUpTime(&Now);
- pBss = &pAd->ScanTab.BssEntry[Bssidx];
- pBss->Rssi = RealRssi; // lastest RSSI
- pBss->LastBeaconRxTime = Now; // last RX timestamp
-
- //
- // BEACON from my BSSID - either IBSS or INFRA network
- //
- if (is_my_bssid)
- {
- RXWI_STRUC RxWI;
-
- pAd->StaCfg.DtimCount = DtimCount;
- pAd->StaCfg.DtimPeriod = DtimPeriod;
- pAd->StaCfg.LastBeaconRxTime = Now;
-
-
- RxWI.RSSI0 = Elem->Rssi0;
- RxWI.RSSI1 = Elem->Rssi1;
- RxWI.RSSI2 = Elem->Rssi2;
-
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, &RxWI);
- if (AironetCellPowerLimit != 0xFF)
- {
- //
- // We get the Cisco (ccx) "TxPower Limit" required
- // Changed to appropriate TxPower Limit for Ciso Compatible Extensions
- //
- ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
- }
- else
- {
- //
- // AironetCellPowerLimit equal to 0xFF means the Cisco (ccx) "TxPower Limit" not exist.
- // Used the default TX Power Percentage, that set from UI.
- //
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
- }
-
- if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))
- {
- 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,
- &AddHtInfo,
- AddHtInfoLen,
- CapabilityInfo) == FALSE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n"));
- return;
- }
-
- if (pEntry &&
- (Elem->Wcid == RESERVED_WCID))
- {
- idx = pAd->StaCfg.DefaultKeyId;
- RTMP_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"));
- }
- }
-
- if (INFRA_ON(pAd))
- {
- BOOLEAN bUseShortSlot, bUseBGProtection;
-
- // decide to use/change to -
- // 1. long slot (20 us) or short slot (9 us) time
- // 2. turn on/off RTS/CTS and/or CTS-to-self protection
- // 3. short preamble
-
- //bUseShortSlot = pAd->CommonCfg.bUseShortSlotTime && CAP_IS_SHORT_SLOT(CapabilityInfo);
- bUseShortSlot = CAP_IS_SHORT_SLOT(CapabilityInfo);
- if (bUseShortSlot != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED))
- AsicSetSlotTime(pAd, bUseShortSlot);
-
- bUseBGProtection = (pAd->CommonCfg.UseBGProtection == 1) || // always use
- ((pAd->CommonCfg.UseBGProtection == 0) && ERP_IS_USE_PROTECTION(Erp));
-
- if (pAd->CommonCfg.Channel > 14) // always no BG protection in A-band. falsely happened when switching A/G band to a dual-band AP
- bUseBGProtection = FALSE;
-
- if (bUseBGProtection != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
- {
- if (bUseBGProtection)
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),FALSE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
- }
- else
- {
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),TRUE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
- }
-
- 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) ||
- (AddHtInfo.AddHtInfo2.NonGfPresent != pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent)))
- {
- pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent = AddHtInfo.AddHtInfo2.NonGfPresent;
- pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode = AddHtInfo.AddHtInfo2.OperaionMode;
- if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, TRUE);
- }
- else
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
-
- 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))
- {
- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP forced to use LONG preamble\n"));
- }
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- (EdcaParm.bValid == TRUE) &&
- (EdcaParm.EdcaUpdateCount != pAd->CommonCfg.APEdcaParm.EdcaUpdateCount))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP change EDCA parameters(from %d to %d)\n",
- pAd->CommonCfg.APEdcaParm.EdcaUpdateCount,
- EdcaParm.EdcaUpdateCount));
- AsicSetEdcaParm(pAd, &EdcaParm);
- }
-
- // copy QOS related information
- NdisMoveMemory(&pAd->CommonCfg.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisMoveMemory(&pAd->CommonCfg.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
-
- // only INFRASTRUCTURE mode support power-saving feature
- if ((INFRA_ON(pAd) && (pAd->StaCfg.Psm == PWR_SAVE)) || (pAd->CommonCfg.bAPSDForcePowerSave))
- {
- UCHAR FreeNumber;
- // 1. AP has backlogged unicast-to-me frame, stay AWAKE, send PSPOLL
- // 2. AP has backlogged broadcast/multicast frame and we want those frames, stay AWAKE
- // 3. we have outgoing frames in TxRing or MgmtRing, better stay AWAKE
- // 4. Psm change to PWR_SAVE, but AP not been informed yet, we better stay AWAKE
- // 5. otherwise, put PHY back to sleep to save battery.
- if (MessageToMe)
- {
-#ifdef RTMP_MAC_PCI
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
- {
- // Restore to correct BBP R3 value
- if (pAd->Antenna.field.RxPath > 1)
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
- // Turn clk to 80Mhz.
- }
-#endif // RTMP_MAC_PCI //
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable &&
- pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO)
- {
- pAd->CommonCfg.bNeedSendTriggerFrame = TRUE;
- }
- else
- RTMP_PS_POLL_ENQUEUE(pAd);
- }
- else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
- {
-#ifdef RTMP_MAC_PCI
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
- {
- if (pAd->Antenna.field.RxPath > 1)
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
- }
-#endif // RTMP_MAC_PCI //
- }
- else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_BE].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_VI].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_VO].Number != 0) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_BK, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_BE, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_VI, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_VO, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_MGMT, MGMT_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS))
- {
- // 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 RTMP_MAC_PCI
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
- {
- if (pAd->Antenna.field.RxPath > 1)
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
- }
-#endif // RTMP_MAC_PCI //
- }
- else
- {
- if ((pAd->CommonCfg.bACMAPSDTr[QID_AC_VO]) ||
- (pAd->CommonCfg.bACMAPSDTr[QID_AC_VI]) ||
- (pAd->CommonCfg.bACMAPSDTr[QID_AC_BK]) ||
- (pAd->CommonCfg.bACMAPSDTr[QID_AC_BE]))
- {
- /*
- WMM Spec v1.0 3.6.2.4,
- The WMM STA shall remain awake until it receives a
- QoS Data or Null frame addressed to it, with the
- EOSP subfield in QoS Control field set to 1.
-
- So we can not sleep here or we will suffer a case:
-
- PS Management Frame -->
- Trigger frame -->
- Beacon (TIM=0) (Beacon is closer to Trig frame) -->
- Station goes to sleep -->
- AP delivery queued UAPSD packets -->
- Station can NOT receive the reply
-
- Maybe we need a timeout timer to avoid that we do
- NOT receive the EOSP frame.
-
- We can not use More Data to check if SP is ended
- due to MaxSPLength.
- */
- }
- else
- {
- USHORT NextDtim = DtimCount;
-
-
- if (NextDtim == 0)
- NextDtim = DtimPeriod;
-
- TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM) && (TbttNumToNextWakeUp > NextDtim))
- TbttNumToNextWakeUp = NextDtim;
-
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- // Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode.
- pAd->ThisTbttNumToNextWakeUp = TbttNumToNextWakeUp;
- AsicSleepThenAutoWakeup(pAd, pAd->ThisTbttNumToNextWakeUp);
-
- }
- }
- }
- }
- }
- // not my BSSID, ignore it
- }
- // sanity check fail, ignore this frame
-}
-
-/*
- ==========================================================================
- Description:
- Receive PROBE REQ from remote peer when operating in IBSS mode
- ==========================================================================
- */
-VOID PeerProbeReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- 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;
- ULONG FrameLen = 0;
- LARGE_INTEGER FakeTimestamp;
- UCHAR DsLen = 1, IbssLen = 2;
- UCHAR LocalErpIe[3] = {IE_ERP, 1, 0};
- BOOLEAN Privacy;
- USHORT CapabilityInfo;
- UCHAR RSNIe = IE_WPA;
-
- if (! ADHOC_ON(pAd))
- return;
-
- if (PeerProbeReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, Ssid, &SsidLen))
- {
- if ((SsidLen == 0) || SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
- {
- // allocate and send out ProbeRsp frame
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- //pAd->StaCfg.AtimWin = 0; // ??????
-
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &ProbeRspHdr,
- TIMESTAMP_LEN, &FakeTimestamp,
- 2, &pAd->CommonCfg.BeaconPeriod,
- 2, &CapabilityInfo,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &pAd->StaActive.SupRateLen,
- pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
- 1, &DsIe,
- 1, &DsLen,
- 1, &pAd->CommonCfg.Channel,
- 1, &IbssIe,
- 1, &IbssLen,
- 2, &pAd->StaActive.AtimWin,
- END_OF_ARGS);
-
- if (pAd->StaActive.ExtRateLen)
- {
- ULONG tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 3, LocalErpIe,
- 1, &ExtRateIe,
- 1, &pAd->StaActive.ExtRateLen,
- pAd->StaActive.ExtRateLen, &pAd->StaActive.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // If adhoc secruity is set for WPA-None, append the cipher suite IE
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- ULONG tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- ULONG TmpLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- HtLen = sizeof(pAd->CommonCfg.HtCapability);
- AddHtLen = sizeof(pAd->CommonCfg.AddHTInfo);
- NewExtLen = 1;
- //New extension channel offset IE is included in Beacon, Probe Rsp or channel Switch Announcement Frame
- if (pAd->bBroadComHT == TRUE)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- sizeof(HT_CAPABILITY_IE), &pAd->CommonCfg.HtCapability,
- 1, &AddHtInfoIe,
- 1, &AddHtLen,
- sizeof(ADD_HT_INFO_IE), &pAd->CommonCfg.AddHTInfo,
- 1, &NewExtChanIe,
- 1, &NewExtLen,
- sizeof(NEW_EXT_CHAN_IE), &pAd->CommonCfg.NewExtChanOffset,
- END_OF_ARGS);
- }
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- }
-}
-
-VOID BeaconTimeoutAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeoutAtJoinAction\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- Scan timeout procedure. basically add channel index by 1 and rescan
- ==========================================================================
- */
-VOID ScanTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- pAd->MlmeAux.Channel = NextChannel(pAd, pAd->MlmeAux.Channel);
-
- // Only one channel scanned for CISCO beacon request
- if ((pAd->MlmeAux.ScanType == SCAN_CISCO_ACTIVE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_PASSIVE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_NOISE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_CHANNEL_LOAD))
- pAd->MlmeAux.Channel = 0;
-
- // this routine will stop if pAd->MlmeAux.Channel == 0
- ScanNextChannel(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenScan(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AYNC - InvalidStateWhenScan(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenJoin(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenJoin(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenStart(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenStart(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-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));
-}
-
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID EnqueueProbeRequest(
- IN PRTMP_ADAPTER pAd)
-{
- NDIS_STATUS NState;
- PUCHAR pOutBuffer;
- ULONG FrameLen = 0;
- HEADER_802_11 Hdr80211;
-
- DBGPRINT(RT_DEBUG_TRACE, ("force out a ProbeRequest ...\n"));
-
- NState = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NState == NDIS_STATUS_SUCCESS)
- {
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
-
- // this ProbeRequest explicitly specify SSID to reduce unwanted ProbeResponse
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &pAd->StaActive.SupRateLen,
- pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
-
-}
-
-#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)
-{
- return (pAd->Mlme.SyncMachine.CurrState == SCAN_LISTEN) ? TRUE : FALSE;
-}
diff --git a/drivers/staging/rt3090/sta/wpa.c b/drivers/staging/rt3090/sta/wpa.c
deleted file mode 100644
index 2dbdba541c3f..000000000000
--- a/drivers/staging/rt3090/sta/wpa.c
+++ /dev/null
@@ -1,396 +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:
- wpa.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee 03-07-22 Initial
- Paul Lin 03-11-28 Modify for supplicant
-*/
-
-#include "../rt_config.h"
-
-
-void inc_byte_array(UCHAR *counter, int len);
-
-/*
- ========================================================================
-
- Routine Description:
- Process MIC error indication and record MIC error timer.
-
- Arguments:
- pAd Pointer to our adapter
- pWpaKey Pointer to the WPA key structure
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPReportMicError(
- IN PRTMP_ADAPTER pAd,
- IN PCIPHER_KEY pWpaKey)
-{
- ULONG Now;
- UCHAR unicastKey = (pWpaKey->Type == PAIRWISE_KEY ? 1:0);
-
- // Record Last MIC error time and count
- NdisGetSystemUpTime(&Now);
- if (pAd->StaCfg.MicErrCnt == 0)
- {
- pAd->StaCfg.MicErrCnt++;
- pAd->StaCfg.LastMicErrorTime = Now;
- NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
- }
- else if (pAd->StaCfg.MicErrCnt == 1)
- {
- if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now)
- {
- // Update Last MIC error time, this did not violate two MIC errors within 60 seconds
- pAd->StaCfg.LastMicErrorTime = Now;
- }
- else
- {
-
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_COUNTER_MEASURES_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- pAd->StaCfg.LastMicErrorTime = Now;
- // Violate MIC error counts, MIC countermeasures kicks in
- pAd->StaCfg.MicErrCnt++;
- // We shall block all reception
- // We shall clean all Tx ring and disassoicate from AP after next EAPOL frame
- //
- // No necessary to clean all Tx ring, on RTMPHardTransmit will stop sending non-802.1X EAPOL packets
- // if pAd->StaCfg.MicErrCnt greater than 2.
- //
- // RTMPRingCleanUp(pAd, QID_AC_BK);
- // RTMPRingCleanUp(pAd, QID_AC_BE);
- // RTMPRingCleanUp(pAd, QID_AC_VI);
- // RTMPRingCleanUp(pAd, QID_AC_VO);
- // RTMPRingCleanUp(pAd, QID_HCCA);
- }
- }
- else
- {
- // MIC error count >= 2
- // This should not happen
- ;
- }
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_MIC_FAILURE_REPORT_FRAME,
- 1,
- &unicastKey);
-
- if (pAd->StaCfg.MicErrCnt == 2)
- {
- RTMPSetTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, 100);
- }
-}
-
-
-#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(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFrame,
- IN USHORT FrameLen,
- IN USHORT OffSet)
-{
-
- PUCHAR pData;
- INT result = 0;
-
- if( FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H )
- return result;
-
- pData = pFrame + OffSet; // skip offset bytes
-
- if(*(pData+1) == EAPPacket) // 802.1x header - Packet Type
- {
- result = *(pData+4); // EAP header - Code
- }
-
- return result;
-}
-
-VOID WpaSendMicFailureToWpaSupplicant(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUnicast)
-{
- char custom[IW_CUSTOM_MAX] = {0};
-
- sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
- if(bUnicast)
- sprintf(custom, "%s unicast", custom);
-
- RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, (PUCHAR)custom, strlen(custom));
-
- return;
-}
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-VOID WpaMicFailureReportFrame(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- BOOLEAN bUnicast;
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame ----->\n"));
-
- bUnicast = (Elem->Msg[0] == 1 ? TRUE:FALSE);
- pAd->Sequence = ((pAd->Sequence) + 1) & (MAX_SEQ_NUMBER);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
-
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
-
- // Request field presented
- Packet.KeyDesc.KeyInfo.Request = 1;
-
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
- }
- else // TKIP
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
- }
-
- Packet.KeyDesc.KeyInfo.KeyType = (bUnicast ? PAIRWISEKEY : GROUPKEY);
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // Error field presented
- Packet.KeyDesc.KeyInfo.Error = 1;
-
- // Update packet length after decide Key data payload
- SET_UINT16_TO_ARRARY(Packet.Body_Len, LEN_EAPOL_KEY_MSG)
-
- // Key Replay Count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
- inc_byte_array(pAd->StaCfg.ReplayCounter, 8);
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
-
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- { // AES
- UCHAR digest[20] = {0};
- HMAC_SHA1(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- { // TKIP
- HMAC_MD5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic, MD5_DIGEST_SIZE);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- // copy frame to Tx ring and send MIC failure report frame to authenticator
- RTMPToWirelessSta(pAd, &pAd->MacTab.Content[BSSID_WCID],
- Header802_3, LENGTH_802_3,
- (PUCHAR)&Packet,
- CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 4, FALSE);
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame <-----\n"));
-}
-
-/** from wpa_supplicant
- * inc_byte_array - Increment arbitrary length byte array by one
- * @counter: Pointer to byte array
- * @len: Length of the counter in bytes
- *
- * This function increments the last byte of the counter by one and continues
- * rolling over to more significant bytes if the byte was incremented from
- * 0xff to 0x00.
- */
-void inc_byte_array(UCHAR *counter, int len)
-{
- int pos = len - 1;
- while (pos >= 0) {
- counter[pos]++;
- if (counter[pos] != 0)
- break;
- pos--;
- }
-}
-
-VOID WpaDisassocApAndBlockAssoc(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (PRTMP_ADAPTER)FunctionContext;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
-
- // disassoc from current AP first
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPReportMicError - disassociate with current AP after sending second continuous EAPOL frame\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_MIC_FAILURE);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- pAd->StaCfg.bBlockAssoc = TRUE;
-}
-
-VOID WpaStaPairwiseKeySetting(
- IN PRTMP_ADAPTER pAd)
-{
- PCIPHER_KEY pSharedKey;
- PMAC_TABLE_ENTRY pEntry;
-
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
-
- // Pairwise key shall use key#0
- pSharedKey = &pAd->SharedKey[BSS0][0];
-
- NdisMoveMemory(pAd->StaCfg.PTK, pEntry->PTK, LEN_PTK);
-
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
- pSharedKey->KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pSharedKey->CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pSharedKey->CipherAlg = CIPHER_AES;
- else
- pSharedKey->CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pSharedKey->CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pSharedKey->CipherAlg,
- pSharedKey->Key,
- pSharedKey->TxMic,
- pSharedKey->RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pSharedKey->CipherAlg,
- pEntry);
- STA_PORT_SECURED(pAd);
- pAd->IndicateMediaState = NdisMediaStateConnected;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s : AID(%d) port secured\n", __FUNCTION__, pEntry->Aid));
-
-}
-
-VOID WpaStaGroupKeySetting(
- IN PRTMP_ADAPTER pAd)
-{
- PCIPHER_KEY pSharedKey;
-
- pSharedKey = &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId];
-
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
- pSharedKey->KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pSharedKey->Key, pAd->StaCfg.GTK, LEN_TKIP_EK);
- NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24], LEN_TKIP_TXMICK);
-
- // Update Shared Key CipherAlg
- pSharedKey->CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pSharedKey->CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pSharedKey->CipherAlg = CIPHER_AES;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
- pSharedKey->CipherAlg = CIPHER_WEP64;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
- pSharedKey->CipherAlg = CIPHER_WEP128;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pSharedKey->CipherAlg,
- pSharedKey->Key,
- pSharedKey->TxMic,
- pSharedKey->RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pSharedKey->CipherAlg,
- NULL);
-
-}