Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 75574 Details for
Bug 115176
rt2570 doesn't work anymore with kernel >=2.6.14-gentoo-r2 becaus of unknown symbol verify_area
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
rt2570 latest cvs patch
rt2570-cvs-update.patch (text/plain), 663.22 KB, created by
Steev Klimaszewski (RETIRED)
on 2005-12-26 17:54:10 UTC
(
hide
)
Description:
rt2570 latest cvs patch
Filename:
MIME Type:
Creator:
Steev Klimaszewski (RETIRED)
Created:
2005-12-26 17:54:10 UTC
Size:
663.22 KB
patch
obsolete
>diff -ruN rt2570-1.1.0-b1/CHANGELOG rt2570-cvs-2005122616/CHANGELOG >--- rt2570-1.1.0-b1/CHANGELOG 2005-07-30 11:44:48.000000000 -0500 >+++ rt2570-cvs-2005122616/CHANGELOG 2005-12-06 02:24:45.000000000 -0600 >@@ -22,6 +22,17 @@ > > Changelog for 802.11g rt2570 USB driver > >+ Version: CVS >+ * Bugfix to allow multiple rt2570 devices >+ * Fix for module unloading under 2.4 kernel >+ * Fix for signal quality reporting (1247985) >+ * Enhancement for TX during RFMON (i.e. aireplay support) >+ * Prism Headers in RFMON >+ * Added new USB devices (F5D7050, Linksys@Home) >+ * Bugfix : race condition between thread stop and incoming mlme commands >+ (Mathieu Desnoyers mathieu.desnoyers@polymtl.ca) >+ >+ > Version: 1.1.0-beta1 > * Initial baseline code from Ralink (2.0.3.0) > * Added new USB devices (F5D7060,UB801R,C54RU,MSI6861,GN-WBKG) >diff -ruN rt2570-1.1.0-b1/Module/.#assoc.c.1.2 rt2570-cvs-2005122616/Module/.#assoc.c.1.2 >--- rt2570-1.1.0-b1/Module/.#assoc.c.1.2 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#assoc.c.1.2 1969-12-31 18:00:00.000000000 -0600 >@@ -1,919 +0,0 @@ >-/*************************************************************************** >- * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net * >- * * >- * 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. * >- * * >- * Licensed under the GNU GPL * >- * Original code supplied under license from RaLink Inc, 2004. * >- ***************************************************************************/ >- >-/*************************************************************************** >- * Module Name: assoc.c >- * >- * Abstract: >- * >- * Revision History: >- * Who When What >- * -------- ---------- ------------------------------- >- * Name Date Modification logs >- * Jan Lee 2005-06-01 Release >- ***************************************************************************/ >- >-#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 >- }; >- >-/* >- ========================================================================== >- Description: >- association state machine init, including state transition and timer init >- Parameters: >- S - pointer to the association state machine >- Note: >- The state machine looks like the following >- >- ASSOC_IDLE ASSOC_WAIT_RSP REASSOC_WAIT_RSP DISASSOC_WAIT_RSP >- MT2_MLME_ASSOC_REQ mlme_assoc_req_action invalid_state_when_assoc invalid_state_when_assoc invalid_state_when_assoc >- MT2_MLME_REASSOC_REQ mlme_reassoc_req_action invalid_state_when_reassoc invalid_state_when_reassoc invalid_state_when_reassoc >- MT2_MLME_DISASSOC_REQ mlme_disassoc_req_action mlme_disassoc_req_action mlme_disassoc_req_action mlme_disassoc_req_action >- MT2_PEER_DISASSOC_REQ peer_disassoc_action peer_disassoc_action peer_disassoc_action peer_disassoc_action >- MT2_PEER_ASSOC_REQ drop drop drop drop >- MT2_PEER_ASSOC_RSP drop peer_assoc_rsp_action drop drop >- MT2_PEER_REASSOC_REQ drop drop drop drop >- MT2_PEER_REASSOC_RSP drop drop peer_reassoc_rsp_action drop >- MT2_CLS3ERR cls3err_action cls3err_action cls3err_action cls3err_action >- MT2_ASSOC_TIMEOUT timer_nop assoc_timeout_action timer_nop timer_nop >- MT2_REASSOC_TIMEOUT timer_nop timer_nop reassoc_timeout_action timer_nop >- MT2_DISASSOC_TIMEOUT timer_nop timer_nop timer_nop disassoc_timeout_action >- >- IRQL = PASSIVE_LEVEL >- >- ========================================================================== >- */ >-VOID AssocStateMachineInit( >- IN PRT2570ADAPTER 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); >- //StateMachineSetAction(S, ASSOC_IDLE, MT2_CLS3ERR, Cls3errAction); >- >- // 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); >- //StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_CLS3ERR, Cls3errAction); >- 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); >- // StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_CLS3ERR, Cls3errAction); >- 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_CLS3ERR, Cls3errAction); >- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT, (STATE_MACHINE_FUNC)DisassocTimeoutAction); >- >- // initialize the timer >- RTMPInitTimer(pAd, &pAd->Mlme.AssocAux.AssocTimer, AssocTimeout); >- RTMPInitTimer(pAd, &pAd->Mlme.AssocAux.ReassocTimer, ReassocTimeout); >- RTMPInitTimer(pAd, &pAd->Mlme.AssocAux.DisassocTimer, DisassocTimeout); >-} >- >-/* >- ========================================================================== >- 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(unsigned long data) >-{ >- PRT2570ADAPTER pAd = (PRT2570ADAPTER)data; >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - enqueue MT2_ASSOC_TIMEOUT \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; >- >- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL); >- //KeSetEvent(&pAd->MLMEEvent, 0, FALSE); >- RTUSBUp(pAd, (&(pAd->mlme_semaphore))); >-} >- >-/* >- ========================================================================== >- 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(unsigned long data) >-{ >- PRT2570ADAPTER pAd = (PRT2570ADAPTER)data; >- DBGPRINT(RT_DEBUG_TRACE,"ASSOC - enqueue MT2_REASSOC_TIMEOUT \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; >- >- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL); >- //KeSetEvent(&pAd->MLMEEvent, 0, FALSE); >- RTUSBUp(pAd, (&(pAd->mlme_semaphore))); >-} >- >-/* >- ========================================================================== >- 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(unsigned long data) >-{ >- PRT2570ADAPTER pAd = (PRT2570ADAPTER)data; >- DBGPRINT(RT_DEBUG_TRACE,"ASSOC - enqueue MT2_DISASSOC_TIMEOUT \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; >- >- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL); >- //KeSetEvent(&pAd->MLMEEvent, 0, FALSE); >- RTUSBUp(pAd, (&(pAd->mlme_semaphore))); >-} >- >-/* >- ========================================================================== >- 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->PortCfg.default_listen_count) >- -# Transmit power (Adapter->PortCfg.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 PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MACADDR ApAddr; >- MACHDR AssocHdr; >- UCHAR SsidIe = IE_SSID, RateIe = IE_SUPP_RATES, ExtRateIe = IE_EXT_SUPP_RATES; >- UCHAR CipherTmp[64]; >- UCHAR CipherTmpLen; >- USHORT ListenIntv; >- ULONG Timeout; >- USHORT CapabilityInfo; >- UCHAR *OutBuffer = NULL; >- NDIS_STATUS NStatus; >- ULONG FrameLen = 0; >- ULONG tmp, idx; >- BOOLEAN FoundPMK = FALSE; >- UCHAR VarIesOffset; >- >- // Block all authentication request durning WPA block period >- if (pAd->PortCfg.bBlockAssoc == TRUE) >- { >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Block Assoc request durning WPA block period!\n"); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_STATE_MACHINE_REJECT); >- } >- // check sanity first >- else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, &ApAddr, &CapabilityInfo, &Timeout, &ListenIntv)) >- { >- RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer); >- COPY_MAC_ADDR(&pAd->Mlme.AssocAux.Addr, &ApAddr); >- // Mask out unnecessary capability information >- CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; // pAd->PortCfg.SupportedCapabilityInfo; >- pAd->Mlme.AssocAux.CapabilityInfo = CapabilityInfo; >- pAd->Mlme.AssocAux.ListenIntv = ListenIntv; >- >- NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory >- if (NStatus != NDIS_STATUS_SUCCESS) >- { >- DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeAssocReqAction() allocate memory failed \n"); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_FAIL_NO_RESOURCE); >- return; >- } >- >- // Add by James 03/06/27 >- pAd->PortCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); >- // Association don't need to report MAC address >- pAd->PortCfg.AssocInfo.AvailableRequestFixedIEs = >- NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL; >- pAd->PortCfg.AssocInfo.RequestFixedIEs.Capabilities = CapabilityInfo; >- pAd->PortCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv; >- // Only reassociate need this >- // NdisMoveMemory(pAd->PortCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, &AssocHdr, sizeof(NDIS_802_11_MAC_ADDRESS)); >- pAd->PortCfg.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); >- >- // First add SSID >- VarIesOffset = 0; >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, &SsidIe, 1); >- VarIesOffset += 1; >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, &pAd->PortCfg.SsidLen, 1); >- VarIesOffset += 1; >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, pAd->PortCfg.Ssid, pAd->PortCfg.SsidLen); >- VarIesOffset += pAd->PortCfg.SsidLen; >- >- // Second add Supported rates >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, &RateIe, 1); >- VarIesOffset += 1; >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, &pAd->PortCfg.SupportedRatesLen, 1); >- VarIesOffset += 1; >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, pAd->PortCfg.SupportedRates, pAd->PortCfg.SupportedRatesLen); >- VarIesOffset += pAd->PortCfg.SupportedRatesLen; >- // End Add by James >- >- MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, &ApAddr, &ApAddr); >- >- // Build basic frame first >- MakeOutgoingFrame( >- OutBuffer, &FrameLen, >- sizeof(MACHDR), &AssocHdr, >- 2, &CapabilityInfo, >- 2, &ListenIntv, >- 1, &SsidIe, >- 1, &pAd->PortCfg.SsidLen, >- pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid, >- 1, &RateIe, >- 1, &pAd->PortCfg.SupRateLen, >- pAd->PortCfg.SupRateLen, pAd->PortCfg.SupRate, >- END_OF_ARGS); >- if (pAd->PortCfg.ExtRateLen != 0) >- { >- MakeOutgoingFrame( >- OutBuffer + FrameLen, &tmp, >- 1, &ExtRateIe, >- 1, &pAd->PortCfg.ExtRateLen, >- pAd->PortCfg.ExtRateLen, pAd->PortCfg.ExtRate, >- END_OF_ARGS); >- FrameLen += tmp; >- } >- >- // For WPA / WPA-PSK >- if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) >- { >- // Copy WPA template to buffer >- CipherTmpLen = sizeof(CipherWpaTemplate); >- NdisMoveMemory(CipherTmp, CipherWpaTemplate, CipherTmpLen); >- // Modify Group cipher >- CipherTmp[11] = ((pAd->PortCfg.GroupCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4); >- // Modify Pairwise cipher >- CipherTmp[17] = ((pAd->PortCfg.PairCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4); >- // Modify AKM >- CipherTmp[23] = ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ? 0x1 : 0x2); >- // Make outgoing frame >- MakeOutgoingFrame( >- OutBuffer + FrameLen, &tmp, >- CipherTmpLen, &CipherTmp[0], >- END_OF_ARGS); >- FrameLen += tmp; >- >- // Append Variable IE >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, CipherTmp, CipherTmpLen); >- VarIesOffset += CipherTmpLen; >- >- // Set Variable IEs Length >- pAd->PortCfg.ReqVarIELen = VarIesOffset; >- pAd->PortCfg.AssocInfo.RequestIELength = VarIesOffset; >- // OffsetResponseIEs follow ReqVarIE >- pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen; >- } >- // For WPA2 / WPA2-PSK >- else if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) >- { >- // Copy WPA2 template to buffer >- CipherTmpLen = sizeof(CipherWpa2Template); >- NdisMoveMemory(CipherTmp, CipherWpa2Template, CipherTmpLen); >- // Modify Group cipher >- CipherTmp[7] = ((pAd->PortCfg.GroupCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4); >- // Modify Pairwise cipher >- CipherTmp[13] = ((pAd->PortCfg.PairCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4); >- // Modify AKM >- CipherTmp[19] = ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) ? 0x1 : 0x2); >- // Check for WPA PMK cache list >- if (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) >- { >- // Search chched PMKID, append it if existed >- for (idx = 0; idx < PMKID_NO; idx++) >- { >- if (NdisEqualMemory(&ApAddr, &pAd->PortCfg.SavedPMK[idx], 6)) >- { >- FoundPMK = TRUE; >- break; >- } >- >- } >- if (FoundPMK) >- { >- // Update length within RSN IE >- CipherTmp[1] += 18; >- // Set PMK number >- *(PUSHORT) &CipherTmp[CipherTmpLen] = 1; >- NdisMoveMemory(&CipherTmp[CipherTmpLen + 2], &pAd->PortCfg.SavedPMK[idx].PMKID, 16); >- CipherTmpLen += 18; >- } >- } >- >- // Make outgoing frame >- MakeOutgoingFrame( >- OutBuffer + FrameLen, &tmp, >- CipherTmpLen, &CipherTmp[0], >- END_OF_ARGS); >- FrameLen += tmp; >- >- // Append Variable IE >- NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, CipherTmp, CipherTmpLen); >- VarIesOffset += CipherTmpLen; >- >- // Set Variable IEs Length >- pAd->PortCfg.ReqVarIELen = VarIesOffset; >- pAd->PortCfg.AssocInfo.RequestIELength = VarIesOffset; >- // OffsetResponseIEs follow ReqVarIE >- pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen; >- } >- else >- { >- // Do nothing >- ; >- } >- >- MiniportMMRequest(pAd, OutBuffer, FrameLen); >- >- RTMPSetTimer(pAd, &pAd->Mlme.AssocAux.AssocTimer, Timeout); /* in mSec */ >- 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; >- MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_INVALID_FORMAT); >- } >-} >- >-/* >- ========================================================================== >- Description: >- mlme reassoc req handling procedure >- Parameters: >- Elem - >- Pre: >- -# SSID (Adapter->PortCfg.ssid[]) >- -# BSSID (AP address, Adapter->PortCfg.bssid) >- -# Supported rates (Adapter->PortCfg.supported_rates[]) >- -# Supported rates length (Adapter->PortCfg.supported_rates_len) >- -# Tx power (Adapter->PortCfg.tx_power) >- >- IRQL = DISPATCH_LEVEL >- >- ========================================================================== >- */ >-VOID MlmeReassocReqAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MACADDR ApAddr; >- MACHDR ReassocHdr; >- UCHAR SsidIe = IE_SSID, RateIe = IE_SUPP_RATES, ExtRateIe = IE_EXT_SUPP_RATES; >- USHORT CapabilityInfo, ListenIntv; >- ULONG Timeout; >- ULONG FrameLen = 0; >- NDIS_STATUS NStatus; >- ULONG tmp; >- UCHAR *OutBuffer = NULL; >- >- // Block all authentication request durning WPA block period >- if (pAd->PortCfg.bBlockAssoc == TRUE) >- { >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Block ReAssoc request durning WPA block period!\n"); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_STATE_MACHINE_REJECT); >- } >- // the parameters are the same as the association >- else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, &ApAddr, &CapabilityInfo, &Timeout, &ListenIntv)) >- { >- RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer); >- >- NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //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; >- MlmeCntlConfirm(pAd, MT2_REASSOC_CONF, MLME_FAIL_NO_RESOURCE); >- return; >- } >- >- // Mask out unnecessary capability information >- CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; // pAd->PortCfg.SupportedCapabilityInfo; >- pAd->Mlme.AssocAux.CapabilityInfo = CapabilityInfo; >- COPY_MAC_ADDR(&pAd->Mlme.AssocAux.Addr, &ApAddr); >- pAd->Mlme.AssocAux.ListenIntv = ListenIntv; >- >- // 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(OutBuffer, &FrameLen, >- sizeof(MACHDR), &ReassocHdr, >- 2, &CapabilityInfo, >- 2, &ListenIntv, >- MAC_ADDR_LEN, &ApAddr, >- 1, &SsidIe, >- 1, &pAd->PortCfg.SsidLen, >- pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid, >- 1, &RateIe, >- 1, &pAd->PortCfg.SupRateLen, >- pAd->PortCfg.SupRateLen, pAd->PortCfg.SupRate, >- END_OF_ARGS); >- if (pAd->PortCfg.ExtRateLen != 0) >- { >- MakeOutgoingFrame(OutBuffer + FrameLen, &tmp, >- 1, &ExtRateIe, >- 1, &pAd->PortCfg.ExtRateLen, >- pAd->PortCfg.ExtRateLen, pAd->PortCfg.ExtRate, >- END_OF_ARGS); >- FrameLen += tmp; >- } >- MiniportMMRequest(pAd, OutBuffer, FrameLen); >- >- RTMPSetTimer(pAd, &pAd->Mlme.AssocAux.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; >- MlmeCntlConfirm(pAd, MT2_REASSOC_CONF, MLME_INVALID_FORMAT); >- } >-} >- >-/* >- ========================================================================== >- Description: >- Upper layer issues disassoc request >- Parameters: >- Elem - >- >- IRQL = PASSIVE_LEVEL >- >- ========================================================================== >- */ >-VOID MlmeDisassocReqAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MLME_DISASSOC_REQ_STRUCT *DisassocReq; >- MACHDR DisassocHdr; >- CHAR *OutBuffer = NULL; >- ULONG FrameLen = 0; >- NDIS_STATUS NStatus; >- ULONG Timeout = 0; >- >- // skip sanity check >- DisassocReq = (MLME_DISASSOC_REQ_STRUCT *)(Elem->Msg); >- >- NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //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; >- MlmeCntlConfirm(pAd, MT2_DISASSOC_CONF, MLME_FAIL_NO_RESOURCE); >- return; >- } >- >- RTMPCancelTimer(&pAd->Mlme.AssocAux.DisassocTimer); >- >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Send DISASSOC request\n"); >- MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, &pAd->PortCfg.Bssid, &pAd->PortCfg.Bssid); >- MakeOutgoingFrame(OutBuffer, &FrameLen, >- sizeof(MACHDR), &DisassocHdr, >- 2, &DisassocReq->Reason, >- END_OF_ARGS); >- MiniportMMRequest(pAd, OutBuffer, FrameLen); >- NdisZeroMemory(&(pAd->PortCfg.Bssid), MAC_ADDR_LEN); >- >- pAd->PortCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING; >- COPY_MAC_ADDR(&pAd->PortCfg.DisassocSta, &DisassocReq->Addr); >- >- RTMPSetTimer(pAd, &pAd->Mlme.AssocAux.DisassocTimer, Timeout); /* in mSec */ >- pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP; >-} >- >-/* >- ========================================================================== >- Description: >- peer sends assoc rsp back >- Parameters: >- Elme - MLME message containing the received frame >- >- IRQL = DISPATCH_LEVEL >- >- ========================================================================== >- */ >-VOID PeerAssocRspAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- USHORT CapabilityInfo, Status, Aid; >- UCHAR Rates[MAX_LEN_OF_SUPPORTED_RATES], RatesLen; >- MACADDR Addr2; >- BOOLEAN ExtendedRateIeExist; >- >- if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &CapabilityInfo, &Status, &Aid, Rates, &RatesLen, &ExtendedRateIeExist)) >- { >- // The frame is for me ? >- if(MAC_ADDR_EQUAL(&Addr2, &pAd->Mlme.AssocAux.Addr)) >- { >- DBGPRINT(RT_DEBUG_INFO, "ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer); >- if(Status == MLME_SUCCESS) >- { >- // go to procedure listed on page 376 >- // Mask out unnecessary capability information >- CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; // pAd->PortCfg.SupportedCapabilityInfo; >- AssocPostProc(pAd, &Addr2, CapabilityInfo, Aid, Rates, RatesLen, ExtendedRateIeExist); >- } >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, 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 PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- USHORT CapabilityInfo; >- USHORT Status; >- USHORT Aid; >- UCHAR Rates[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR RatesLen; >- MACADDR Addr2; >- BOOLEAN ExtendedRateIeExist; >- >- if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &CapabilityInfo, &Status, &Aid, Rates, &RatesLen, &ExtendedRateIeExist)) >- { >- if(MAC_ADDR_EQUAL(&Addr2, &pAd->Mlme.AssocAux.Addr)) // The frame is for me ? >- { >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer); >- >- if(Status == MLME_SUCCESS) >- { >- // Mask out unnecessary capability information >- CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; // pAd->PortCfg.SupportedCapabilityInfo; >- // go to procedure listed on page 376 >- AssocPostProc(pAd, &Addr2, CapabilityInfo, Aid, Rates, RatesLen, ExtendedRateIeExist); >- } >- >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_REASSOC_CONF, 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 PRT2570ADAPTER pAd, >- IN PMACADDR Addr2, >- IN USHORT CapabilityInfo, >- IN USHORT Aid, >- IN UCHAR Rates[], >- IN UCHAR RatesLen, >- IN BOOLEAN ExtendedRateIeExist) >-{ >- ULONG Idx; >- UCHAR RateIe = IE_SUPP_RATES; >- UCHAR VarIesOffset; >- >- // 2003/12/11 - skip the following because experiment show that we can not >- // trust the "privacy" bit in AssocRsp. We can only trust "Privacy" bit specified in >- // BEACON and ProbeRsp. >- // pAd->PortCfg.PrivacyInvoked = CAP_IS_PRIVACY_ON(CapabilityInfo); >- >- pAd->PortCfg.Aid = Aid; >- NdisMoveMemory(pAd->PortCfg.SupportedRates, Rates, RatesLen); >- pAd->PortCfg.SupportedRatesLen = RatesLen; >- COPY_MAC_ADDR(&pAd->PortCfg.Bssid, Addr2); >- AsicSetBssid(pAd, &pAd->PortCfg.Bssid); >- >- // set listen interval >- pAd->PortCfg.DefaultListenCount = pAd->Mlme.AssocAux.ListenIntv; >-// pAd->PortCfg.CurrListenCount = pAd->Mlme.AssocAux.ListenIntv; >- >- // Set New WPA information >- Idx = BssTableSearch(&pAd->PortCfg.BssTab, Addr2); >- if (Idx == BSS_NOT_FOUND) >- { >- DBGPRINT(RT_DEBUG_ERROR, "ASSOC - Can't find BSS after receiving Assoc response\n"); >- } >- else >- { >- // Mod by James to fix OID_802_11_ASSOCIATION_INFORMATION >- pAd->PortCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); //+ sizeof(NDIS_802_11_FIXED_IEs); // Filled in assoc request >- pAd->PortCfg.AssocInfo.AvailableResponseFixedIEs = >- NDIS_802_11_AI_RESFI_CAPABILITIES | NDIS_802_11_AI_RESFI_STATUSCODE | NDIS_802_11_AI_RESFI_ASSOCIATIONID; >- pAd->PortCfg.AssocInfo.ResponseFixedIEs.Capabilities = CapabilityInfo; >- pAd->PortCfg.AssocInfo.ResponseFixedIEs.StatusCode = MLME_SUCCESS; // Should be success, add failed later >- pAd->PortCfg.AssocInfo.ResponseFixedIEs.AssociationId = Aid; >- >- // Copy BSS VarIEs to PortCfg associnfo structure. >- // First add Supported rates >- VarIesOffset = 0; >- NdisMoveMemory(pAd->PortCfg.ResVarIEs + VarIesOffset, &RateIe, 1); >- VarIesOffset += 1; >- NdisMoveMemory(pAd->PortCfg.ResVarIEs + VarIesOffset, &RatesLen, 1); >- VarIesOffset += 1; >- NdisMoveMemory(pAd->PortCfg.ResVarIEs + VarIesOffset, Rates, RatesLen); >- VarIesOffset += RatesLen; >- >- // Second add RSN >- NdisMoveMemory(pAd->PortCfg.ResVarIEs + VarIesOffset, pAd->PortCfg.BssTab.BssEntry[Idx].VarIEs, pAd->PortCfg.BssTab.BssEntry[Idx].VarIELen); >- VarIesOffset += pAd->PortCfg.BssTab.BssEntry[Idx].VarIELen; >- >- // Set Variable IEs Length >- pAd->PortCfg.ResVarIELen = VarIesOffset; >- pAd->PortCfg.AssocInfo.ResponseIELength = VarIesOffset; >- } >-} >- >-/* >- ========================================================================== >- Description: >- left part of IEEE 802.11/1999 p.374 >- Parameters: >- Elem - MLME message containing the received frame >- >- IRQL = DISPATCH_LEVEL >- >- ========================================================================== >- */ >-VOID PeerDisassocAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MACADDR Addr2; >- USHORT Reason; >- >- if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Reason)) >- { >- if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(&pAd->PortCfg.Bssid, &Addr2)) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "LinkDown(PeerDisassocAction(Reason = %d))\n", Reason);//steven:for debug >- LinkDown(pAd); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- >- // 2002/11/21 - >- // patch RT2430/RT2420 hangup issue. We suspect this AP DIS-ASSOCIATE frame >- // is caused by PHY hangup, so we reset PHY, then auto recover the connection. >- // if this attempt fails, then remains in LinkDown and leaves the problem >- // to MlmePeriodicExec() >- // NICPatchRT2430Bug(pAd); >- pAd->RalinkCounters.BeenDisassociatedCount ++; >- // Remove auto recover effort when disassociate by AP, re-enable for patch 2430 only >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Disassociated by AP, Auto Recovery attempt #%d\n", pAd->RalinkCounters.BeenDisassociatedCount); >- MlmeAutoReconnectLastSSID(pAd); >- } >- } >- 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 PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - AssocTimeoutAction\n"); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_REJ_TIMEOUT); >-} >- >-/* >- ========================================================================== >- Description: >- what the state machine will do after reassoc timeout >- >- IRQL = DISPATCH_LEVEL >- >- ========================================================================== >- */ >-VOID ReassocTimeoutAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - ReassocTimeoutAction\n"); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_REASSOC_CONF, MLME_REJ_TIMEOUT); >-} >- >-/* >- ========================================================================== >- Description: >- what the state machine will do after disassoc timeout >- >- IRQL = DISPATCH_LEVEL >- >- ========================================================================== >- */ >-VOID DisassocTimeoutAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - DisassocTimeoutAction\n"); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_DISASSOC_CONF, MLME_SUCCESS); >-} >- >-VOID InvalidStateWhenAssoc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenAssoc(state=%d), reset ASSOC state machine\n", >- pAd->Mlme.AssocMachine.CurrState); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_STATE_MACHINE_REJECT); >-} >- >-VOID InvalidStateWhenReassoc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenReassoc(state=%d), reset ASSOC state machine\n", >- pAd->Mlme.AssocMachine.CurrState); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_REASSOC_CONF, MLME_STATE_MACHINE_REJECT); >-} >- >-VOID InvalidStateWhenDisassociate( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenDisassoc(state=%d), reset ASSOC state machine\n", >- pAd->Mlme.AssocMachine.CurrState); >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- MlmeCntlConfirm(pAd, MT2_DISASSOC_CONF, MLME_STATE_MACHINE_REJECT); >-} >- >-/* >- ========================================================================== >- 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 PRT2570ADAPTER pAd, >- IN PMACADDR pAddr) >-{ >- MACHDR DisassocHdr; >- CHAR *OutBuffer = NULL; >- ULONG FrameLen = 0; >- NDIS_STATUS NStatus; >- USHORT Reason = REASON_CLS3ERR; >- >- NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //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->PortCfg.Bssid); >- MakeOutgoingFrame(OutBuffer, &FrameLen, >- sizeof(MACHDR), &DisassocHdr, >- 2, &Reason, >- END_OF_ARGS); >- MiniportMMRequest(pAd, OutBuffer, FrameLen); >- >- pAd->PortCfg.DisassocReason = REASON_CLS3ERR; >- COPY_MAC_ADDR(&pAd->PortCfg.DisassocSta, pAddr); >-} >diff -ruN rt2570-1.1.0-b1/Module/connect.c rt2570-cvs-2005122616/Module/connect.c >--- rt2570-1.1.0-b1/Module/connect.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/connect.c 2005-12-02 06:55:15.000000000 -0600 >@@ -1282,8 +1282,13 @@ > ULONG BulkOutLength; > PTX_CONTEXT pBeaconContext = &(pAd->BeaconContext[0]); > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (pAd->MLMEThr_pid <= 0) > return; >+#else >+ if (!pAd->MLMEThr_active) >+ return; >+#endif > // 2003-12-10 802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode > // make sure 1,2,5.5,11 are the firt 4 rates in PortCfg.SupportedRates[] array > if ((pAd->PortCfg.PhyMode == PHY_11BG_MIXED) && (pAd->PortCfg.AdhocMode == 0)) >diff -ruN rt2570-1.1.0-b1/Module/.#connect.c.1.2 rt2570-cvs-2005122616/Module/.#connect.c.1.2 >--- rt2570-1.1.0-b1/Module/.#connect.c.1.2 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#connect.c.1.2 1969-12-31 18:00:00.000000000 -0600 >@@ -1,1443 +0,0 @@ >-/*************************************************************************** >- * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net * >- * * >- * 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. * >- * * >- * Licensed under the GNU GPL * >- * Original code supplied under license from RaLink Inc, 2004. * >- ***************************************************************************/ >- >-/*************************************************************************** >- * Module Name: connect.c >- * >- * Abstract: >- * >- * Revision History: >- * Who When What >- * -------- ---------- ------------------------------- >- * Name Date Modification logs >- * Jan Lee 2005-06-01 Release >- ***************************************************************************/ >- >-#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, 0x00, // 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, 0x00, // unicast >- 0x01, 0x00, // number of authentication method >- 0x00, 0x50, 0xf2, 0x00 // authentication >- }; >-UCHAR CipherSuiteWpaNoneAesLen = (sizeof(CipherSuiteWpaNoneAes) / sizeof(UCHAR)); >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID MlmeCntlInit( >- IN PRT2570ADAPTER 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: >- ========================================================================== >-*/ >-VOID MlmeCntlMachinePerformAction( >- IN PRT2570ADAPTER 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 >- RTUSBResumeMsduTransmission(pAd); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- } >- // >- // Following line will potentially cause infinite loop >- // >- //if (pAd->MediaState == NdisMediaStateDisconnected) >- // MlmeAutoReconnectLastSSID(pAd); >- break; >- >- case CNTL_WAIT_OID_DISASSOC: >- if (Elem->MsgType == MT2_DISASSOC_CONF) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "LinkDown(MlmeCntlMachinePerformAction)\n"); >- LinkDown(pAd); >- >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- } >- break; >- >- default: >- DBGPRINT(RT_DEBUG_ERROR, "CNTL - Illegal message type(=%d)", Elem->MsgType); >- break; >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlIdleProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MLME_DISASSOC_REQ_STRUCT DisassocReq; >- >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) >- { >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_FAILURE); >- pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE; >- } >- return; >- } >- >- switch(Elem->MsgType) >- { >- case OID_802_11_SSID: >- CntlOidSsidProc(pAd, Elem); >- break; >- >- case RT_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->PortCfg.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; >- // Set the control aux SSID to prevent it reconnect to old SSID >- // Since calling this indicate user don't want to connect to that SSID anymore. >- pAd->Mlme.CntlAux.SsidLen = 32; >- NdisZeroMemory(pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidLen); >- break; >- >- case MT2_MLME_ROAMING_REQ: >- CntlMlmeRoamingProc(pAd, Elem); >- break; >- >- default: >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - Illegal message in CntlIdleProc(MsgType=%d)\n",Elem->MsgType); >- break; >- } >-} >- >-VOID CntlOidScanProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MLME_SCAN_REQ_STRUCT ScanReq; >- CHAR BroadSsid[MAX_LEN_OF_SSID]; >- ULONG BssIdx = BSS_NOT_FOUND; >- BSS_ENTRY CurrBss; >- ULONG Now; >- >- // 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 (pAd->MediaState == NdisMediaStateConnected) // if (INFRA_ON(pAd) || ADHOC_ON(pAd)) >- { >- BssIdx = BssTableSearch(&pAd->PortCfg.BssTab, &pAd->PortCfg.Bssid); >- if (BssIdx != BSS_NOT_FOUND) >- { >- NdisMoveMemory(&CurrBss, &pAd->PortCfg.BssTab.BssEntry[BssIdx], sizeof(BSS_ENTRY)); >- >- // 2003-2-20 reset this RSSI to a low value but not zero. In normal case, the coming SCAN >- // should return a correct RSSI to overwrite this. If no BEEACON received after SCAN, >- // at least we still report a "greater than 0" RSSI since we claim it's CONNECTED. >- CurrBss.Rssi = 18; // about -82 dB >- } >- } >- >- // clean up previous SCAN result, add current BSS back to table if any >- BssTableInit(&pAd->PortCfg.BssTab); >- 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->PortCfg.BssTab.BssEntry[0], &CurrBss, sizeof(BSS_ENTRY)); >- pAd->PortCfg.BssTab.BssNr = 1; >- } >- >- BroadSsid[0] = '\0'; >- ScanParmFill(pAd, &ScanReq, BroadSsid, 0, BSS_ANY, SCAN_PASSIVE); >- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, >- sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq); >- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN; >- Now = jiffies; >- pAd->PortCfg.LastScanTime = Now; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlOidSsidProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM * Elem) >-{ >- NDIS_802_11_SSID *OidSsid = (NDIS_802_11_SSID *)Elem->Msg; >- MLME_DISASSOC_REQ_STRUCT DisassocReq; >- ULONG Now; >- >- // Step 0. >- // record the desired SSID and all matching BSSes into CntlAux.SsidBssTab for >- // later-on iteration. Sort by RSSI order >- if (OidSsid->Ssid[0] == 0) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "empty string SSID\n"); >- pAd->Mlme.CntlAux.SsidLen = 0; >- } >- else >- pAd->Mlme.CntlAux.SsidLen = (UCHAR)OidSsid->SsidLength; >- >- NdisMoveMemory(pAd->Mlme.CntlAux.Ssid, OidSsid->Ssid, pAd->Mlme.CntlAux.SsidLen); >- BssTableSsidSort(pAd, &pAd->Mlme.CntlAux.SsidBssTab, pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidLen); >- pAd->Mlme.CntlAux.BssIdx = 0; >- DBGPRINT(RT_DEBUG_TRACE,"CNTL - %d BSS match the desire SSID %s\n",pAd->Mlme.CntlAux.SsidBssTab.BssNr, pAd->Mlme.CntlAux.Ssid); >- Now = jiffies; >- >- if ((pAd->MediaState == NdisMediaStateConnected) && >- MAC_ADDR_EQUAL(&pAd->PortCfg.Bssid, &pAd->Mlme.CntlAux.SsidBssTab.BssEntry[0].Bssid)) >- { >- if (((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) && >- (pAd->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) >- { >- // For WPA, WPA-PSK, if the 1x port is not secured, we have to redo >- // connection process >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP...\n"); >- DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.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) >- { >- // Config has changed, we have to reconnect the same AP >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP Because config changed...\n"); >- DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.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 >- { >- // We only check if same to the BSSID with highest RSSI. >- // If roaming of same SSID required, we still do the reconnection. >- // same BSSID, go back to idle state directly >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - already with this BSSID. ignore this SET_SSID request\n"); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- } >- } >- else if (INFRA_ON(pAd)) >- { >- // case 1. active 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 (or previous) associated AP, if any, >- // then perform a new association with this new SSID, no matter the >- // new/old SSID are the same or npt. >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP...\n"); >- DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.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")); >- DBGPRINT_RAW(RT_DEBUG_TRACE, "LinkDown(CntlOidSsidProc)\n"); >- LinkDown(pAd); >- pAd->MediaState = NdisMediaStateDisconnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"); >- } >- >- if ((pAd->Mlme.CntlAux.SsidBssTab.BssNr == 0) && >- (pAd->PortCfg.AutoReconnect == TRUE) && >- (pAd->PortCfg.BssType == BSS_INFRA) && >- (MlmeValidateSSID(pAd) == TRUE)) >- { >- >- MLME_SCAN_REQ_STRUCT ScanReq; >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - No matching BSS, start a new scan\n"); >- // BroadSsid[0] = '\0'; >- ScanParmFill(pAd, &ScanReq, pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.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->PortCfg.IgnoredScanNumber = 0; >- pAd->PortCfg.LastScanTime = Now; >- } >- else >- { >- IterateOnBssTab(pAd); >- } >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlOidRTBssidProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM * Elem) >-{ >- ULONG BssIdx; >- MACADDR *pOidBssid = (MACADDR *)Elem->Msg; >- MLME_DISASSOC_REQ_STRUCT DisassocReq; >- MLME_JOIN_REQ_STRUCT JoinReq; >- >- COPY_MAC_ADDR(&pAd->Mlme.CntlAux.Bssid, pOidBssid); >- BssIdx = BssTableSearch(&pAd->PortCfg.BssTab, pOidBssid); >- >- if (BssIdx == BSS_NOT_FOUND) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- //NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_NOT_ACCEPTED); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- return; >- } >- >- // copy the matched BSS entry from PortCfg.BssTab to CntlAux.SsidBssTab >- pAd->Mlme.CntlAux.BssIdx = 0; >- pAd->Mlme.CntlAux.SsidBssTab.BssNr = 1; >- NdisMoveMemory(&pAd->Mlme.CntlAux.SsidBssTab.BssEntry[0], &pAd->PortCfg.BssTab.BssEntry[BssIdx], sizeof(BSS_ENTRY)); >- >- // Add SSID into Mlme.CntlAux for site surey joining hidden SSID >- pAd->Mlme.CntlAux.SsidLen = pAd->Mlme.CntlAux.SsidBssTab.BssEntry[0].SsidLen; >- NdisMoveMemory(pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidBssTab.BssEntry[0].Ssid, pAd->Mlme.CntlAux.SsidLen); >- >- // 2002-11-26 skip the following checking. i.e. if user wants to re-connect to same AP >- // we just follow normal procedure. The reason of user doing this may because he/she changed >- // AP to another channel, but we still received BEACON from it thus don't claim Link Down. >- // Since user knows he's chnged AP channel, he'll re-connect again. By skipping the following >- // checking, we'll disassociate then re-do normal association with this AP at the new channel. >- // 2003-1-6 Re-enable this feature based on microsoft requirement which prefer not to re-do >- // connection when setting the same BSSID. >- if ( (pAd->MediaState == NdisMediaStateConnected) && //(INFRA_ON(pAd) || ADHOC_ON(pAd)) && >- MAC_ADDR_EQUAL(&pAd->PortCfg.Bssid, pOidBssid)) >- { >- // same BSSID, go back to idle state directly >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - already in this BSSID. ignore this SET_BSSID request\n"); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- } >- else >- { >- if (INFRA_ON(pAd)) >- { >- // disassoc from current AP first >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP ...\n"); >- DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.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_RAW(RT_DEBUG_TRACE, "LinkDown(CntlOidRTBssidProc)\n"); >- LinkDown(pAd); >- pAd->MediaState = NdisMediaStateDisconnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"); >- } >- >- // No active association, join the BSS immediately >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n", >- pOidBssid->Octet[0],pOidBssid->Octet[1],pOidBssid->Octet[2], >- pOidBssid->Octet[3],pOidBssid->Octet[4],pOidBssid->Octet[5]); >- JoinParmFill(pAd, &JoinReq, pAd->Mlme.CntlAux.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"? >-VOID CntlMlmeRoamingProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- // TODO: >- // AP in different channel may show lower RSSI than actual value?? >- // should we add a weighting factor to compensate it? >- DBGPRINT(RT_DEBUG_TRACE,"CNTL - Roaming in CntlAux.RoamTab...\n"); >- BssTableSortByRssi(&pAd->Mlme.CntlAux.RoamTab); >- pAd->Mlme.CntlAux.RoamIdx=0; >- IterateOnBssTab2(pAd); >- >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlWaitDisassocProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MLME_START_REQ_STRUCT StartReq; >- >- if (Elem->MsgType == MT2_DISASSOC_CONF) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "LinkDown(CntlWaitDisassocProc)\n"); >- LinkDown(pAd); >- >- // case 1. no matching BSS, and user wants ADHOC, so we just start a new one >- if ((pAd->Mlme.CntlAux.SsidBssTab.BssNr==0) && (pAd->PortCfg.BssType == BSS_INDEP)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd->Mlme.CntlAux.Ssid); >- StartParmFill(pAd, &StartReq, pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.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 >- { >- IterateOnBssTab(pAd); >- } >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlWaitJoinProc( >- IN PRT2570ADAPTER 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->PortCfg.BssType == BSS_INDEP) >- { >- LinkUp(pAd, BSS_INDEP); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- } >- // 2. joined a new INFRA network, start from authentication >- else >- { >-// RTUSBWriteMACRegister(pAd, TXRX_CSR2, 0x67e);//steven:for test >- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first >- if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeShared) || >- (pAd->PortCfg.AuthMode == Ndis802_11AuthModeAutoSwitch)) >- { >- AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.Bssid, Ndis802_11AuthModeShared); >- } >- else >- { >- AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.Bssid, Ndis802_11AuthModeOpen); >- } >- 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->Mlme.CntlAux.BssIdx++; >- IterateOnBssTab(pAd); >- } >- } >-} >- >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlWaitStartProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- USHORT Result; >- >- if (Elem->MsgType == MT2_START_CONF) >- { >- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT)); >- if (Result == MLME_SUCCESS) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - We have started a new ADHOC network\n"); >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - BSSID %02x:%02x:%02x:%02x:%02x:%02x ...\n", >- pAd->PortCfg.Bssid.Octet[0], >- pAd->PortCfg.Bssid.Octet[1], >- pAd->PortCfg.Bssid.Octet[2], >- pAd->PortCfg.Bssid.Octet[3], >- pAd->PortCfg.Bssid.Octet[4], >- pAd->PortCfg.Bssid.Octet[5]); >- LinkUp(pAd, BSS_INDEP); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- } >- else >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - Start FAIL. BUG!!!!!\n"); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_FAILURE); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- } >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlWaitAuthProc( >- IN PRT2570ADAPTER 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) >- { >- AssocParmFill(pAd, &AssocReq, &pAd->PortCfg.Bssid, pAd->PortCfg.CapabilityInfo, >- ASSOC_TIMEOUT, pAd->PortCfg.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->PortCfg.AuthMode == Ndis802_11AuthModeShared) || >- (pAd->PortCfg.AuthMode == Ndis802_11AuthModeAutoSwitch)) >- { >- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first >- AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.Bssid, Ndis802_11AuthModeShared); >- } >- else >- { >- AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.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; >- } >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlWaitAuthProc2( >- IN PRT2570ADAPTER 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) >- { >- AssocParmFill(pAd, &AssocReq, &pAd->PortCfg.Bssid, pAd->PortCfg.CapabilityInfo, >- ASSOC_TIMEOUT, pAd->PortCfg.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->PortCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) && >- (pAd->Mlme.AuthAux.Alg == Ndis802_11AuthModeShared)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - AUTH FAIL, try OPEN system...\n"); >- AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.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->Mlme.CntlAux.BssIdx++; >-// RTUSBWriteMACRegister(pAd, TXRX_CSR2, 0x7e);//steven:for test >- IterateOnBssTab(pAd); >- } >- } >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlWaitAssocProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- USHORT Reason; >- >- if (Elem->MsgType == MT2_ASSOC_CONF) >- { >- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT)); >- if (Reason == MLME_SUCCESS) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - Association successful on BSS #%d\n",pAd->Mlme.CntlAux.BssIdx); >-// RTUSBWriteMACRegister(pAd, TXRX_CSR2, 0x7e);//steven:for test >- LinkUp(pAd, BSS_INFRA); >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- } >- else >- { >- // not success, try next BSS >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - Association fails on BSS #%d\n",pAd->Mlme.CntlAux.BssIdx); >-// pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;//steven:for test >- pAd->Mlme.CntlAux.BssIdx++; >-// RTUSBWriteMACRegister(pAd, TXRX_CSR2, 0x7e);//steven:for test >- IterateOnBssTab(pAd); >- } >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID CntlWaitReassocProc( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- USHORT Result; >- >- if (Elem->MsgType == MT2_REASSOC_CONF) >- { >- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT)); >- if (Result == MLME_SUCCESS) >- { >- BSS_ENTRY *pBss = &pAd->Mlme.CntlAux.RoamTab.BssEntry[pAd->Mlme.CntlAux.RoamIdx]; >- >- // COPY_MAC_ADDR(&pAd->PortCfg.Bssid, &pBss->Bssid); >- // AsicSetBssid(pAd, &pAd->PortCfg.Bssid); >- >- // The following steps are supposed to be done after JOIN in normal procedure >- // But since this RE-ASSOC skips the JOIN procedure, we have to do it after >- // RE-ASSOC succeeds. If RE-ASSOC fails, then stay at original AP without any change >- pAd->PortCfg.BeaconPeriod = pBss->BeaconPeriod; >- pAd->PortCfg.Channel = pBss->Channel; >- // The security setting should always follow upper layer definition, not from frame >- //pAd->PortCfg.PrivacyInvoked = CAP_IS_PRIVACY_ON(pBss->CapabilityInfo); >- pAd->PortCfg.SupportedRatesLen = pBss->RatesLen; >- NdisMoveMemory(pAd->PortCfg.SupportedRates, pBss->Rates, pBss->RatesLen); >- >- // Check for 802.11g information, if 802.11 b /g mixed mode. >- pAd->PortCfg.CapabilityInfo = pBss->CapabilityInfo; >- >- pAd->PortCfg.CfpPeriod = pBss->CfpPeriod; >- pAd->PortCfg.CfpMaxDuration = pBss->CfpMaxDuration; >- pAd->PortCfg.CfpDurRemain = pBss->CfpDurRemaining; >- pAd->PortCfg.CfpCount = pBss->CfpCount; >- >- // >- // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC >- // >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - Re-assocition successful on BSS #%d\n", pAd->Mlme.CntlAux.RoamIdx); >- LinkUp(pAd, BSS_INFRA); >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS);//steven:for test >- } >- else >- { >- // reassoc failed, try to pick next BSS in the BSS Table >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - Re-assocition fails on BSS #%d\n", pAd->Mlme.CntlAux.RoamIdx); >- pAd->Mlme.CntlAux.RoamIdx++; >- IterateOnBssTab2(pAd); >- } >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID LinkUp( >- IN PRT2570ADAPTER pAd, >- IN UCHAR BssType) >-{ >- ULONG Now; >- UCHAR buffer[22]; >- >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! LINK UP !!!\n"); >- MlmeUpdateTxRates(pAd, TRUE); >- RTUSBMultiReadMAC(pAd, STA_CSR0, buffer, 22); >- NdisMoveMemory(&pAd->Mlme.PrevWlanCounters, &pAd->WlanCounters, sizeof(COUNTER_802_11)); >- NdisZeroMemory(&pAd->DrsCounters, sizeof(COUNTER_DRS)); >- >- Now = jiffies; >- pAd->PortCfg.LastBeaconRxTime = Now; // last RX timestamp >- >- if ((pAd->PortCfg.WindowsTxPreamble != Rt802_11PreambleLong) && >- CAP_IS_SHORT_PREAMBLE_ON(pAd->PortCfg.CapabilityInfo)) >- { >- >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! Set to short preamble!!!\n"); >- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort); >- } >- >- pAd->PortCfg.BssType = BssType; >- if (BssType == BSS_INDEP) >- { >-// USHORT SentBeaconsCount, ReceivedBeaconsCount; >-// RTUSBReadMACRegister(pAd, STA_CSR5, &SentBeaconsCount); >-// RTUSBReadMACRegister(pAd, STA_CSR10, &ReceivedBeaconsCount); >- pAd->PortCfg.Mibss = TRUE; >- pAd->PortCfg.Massoc = FALSE; >- AsicEnableIbssSync(pAd); >- >-#ifdef SINGLE_ADHOC_LINKUP >- // Although this did not follow microsoft's recommendation. >- //Change based on customer's request >- pAd->MediaState = NdisMediaStateConnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_CONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >-#endif >- >- } >- else // BSS_INFRA >- { >- // need to check >- //InterlockedExchange(&(pAd->PortCfg.DataPacketsFromAP), 0); >- pAd->PortCfg.Massoc = TRUE; >- pAd->PortCfg.Mibss = FALSE; >- >- // 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); >- if (pAd->PortCfg.EnableTxBurst) >- { >- //Set CWmin/CWmax to 0. >- RTUSBWriteMACRegister(pAd, MAC_CSR22, 0x100); >- } >- else >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR22, 0x53); >- } >- >- // only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode >- // should wait until at least 2 active nodes in this BSSID. >- pAd->MediaState = NdisMediaStateConnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_CONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- } >- >- DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_CONNECT Event B!\n"); >- >- if ((pAd->PortCfg.LedMode != LED_MODE_SINGLE)&&(pAd->PortCfg.LedMode != LED_MODE_TXRX_ACTIVITY)) >- { >- ASIC_LED_ACT_ON(pAd); >- } >- if (pAd->PortCfg.LedMode == LED_MODE_ALPHA){ >- pAd->PortCfg.LedCntl.fSiteSurvey = FALSE; >- pAd->PortCfg.LedCntl.fLinkUp = TRUE; >- } >- AsicSetSlotTime(pAd, FALSE); >- pAd->Mlme.PeriodicRound = 0; >- // Reset config flag >- pAd->bConfigChanged = FALSE; >- // Update extra information to link is up >- pAd->ExtraInfo = GENERAL_LINK_UP; >- pAd->PortCfg.WpaState = SS_START; >- >- RTUSBKickBulkOut(pAd); >- >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID LinkDown( >- IN PRT2570ADAPTER pAd) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! LINK DOWN !!!\n"); >- >- if (ADHOC_ON(pAd)) // Adhoc mode link down >- { >- pAd->PortCfg.Mibss = FALSE; >- >-#ifdef SINGLE_ADHOC_LINKUP >- pAd->MediaState = NdisMediaStateDisconnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- // clean up previous SCAN result, add current BSS back to table if any >- BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid)); >-#else >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) >- { >- pAd->MediaState = NdisMediaStateDisconnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- // clean up previous SCAN result, add current BSS back to table if any >- BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid)); >- } >-#endif >- >- } >- else // Infra structure mode >- { >- pAd->PortCfg.Massoc = FALSE; >- pAd->MediaState = NdisMediaStateDisconnected; >- DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event A!\n"); >- BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid)); >- >- // 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 >- if (pAd->PortCfg.BGProtectionInUsed == TRUE) >- { >- pAd->PortCfg.BGProtectionInUsed = FALSE; >- DBGPRINT(RT_DEBUG_TRACE, "Link down - turn off B/G protection\n"); >- } >- >- if (pAd->PortCfg.Pss == PWR_SAVE) >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR1, 1); >- RTUSBWriteMACRegister(pAd, MAC_CSR1, 4); >- pAd->PortCfg.Pss = PWR_ACTIVE; >- } >- } >- >- AsicSetSlotTime(pAd, FALSE); >- RTUSBWriteMACRegister(pAd, MAC_CSR22, 0x53); >- AsicRestoreBbpSensibility(pAd); >- >- if (pAd->PortCfg.WindowsTxPreamble == Rt802_11PreambleShort) >- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort); >- else >- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong); >- >- if ((pAd->PortCfg.LedMode != LED_MODE_SINGLE) && (pAd->PortCfg.LedMode != LED_MODE_ASUS)) >- { >- ASIC_LED_ACT_OFF(pAd); >- } >- else if ((pAd->PortCfg.LedMode == LED_MODE_ASUS) && (pAd->PortCfg.bRadio == TRUE)) >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR20, 0x0002); >- } >- AsicDisableSync(pAd); >- pAd->Mlme.PeriodicRound = 0; >- pAd->ScanAllowed = TRUE; >- >- // Remove PortCfg Information after link down >- NdisZeroMemory(&(pAd->PortCfg.Bssid), MAC_ADDR_LEN); >- NdisZeroMemory(pAd->PortCfg.Ssid, MAX_LEN_OF_SSID); >- pAd->PortCfg.SsidLen = 0; >- >- // Reset WPA-PSK state. Only reset when supplicant enabled >- if (pAd->PortCfg.WpaState != SS_NOTUSE) >- { >- pAd->PortCfg.WpaState = SS_START; >- // Clear Replay counter >- NdisZeroMemory(pAd->PortCfg.ReplayCounter, 8); >- } >- // Remove all WPA keys after link down >- RTMPWPARemoveAllKeys(pAd); >- // 802.1x port control >- pAd->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; >- pAd->PortCfg.MicErrCnt = 0; >- if (pAd->PortCfg.LedMode == LED_MODE_ALPHA) >- pAd->PortCfg.LedCntl.fLinkUp = FALSE; >- >- // Update extra information to link is up >- pAd->ExtraInfo = GENERAL_LINK_DOWN; >- // Start STA supplicant state machine >- //pAd->PortCfg.WpaState = SS_NOTUSE; >- >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID MlmeCntlConfirm( >- IN PRT2570ADAPTER pAd, >- IN ULONG MsgType, >- IN USHORT Msg) >-{ >- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(USHORT), &Msg); >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID IterateOnBssTab( >- IN PRT2570ADAPTER pAd) >-{ >- MLME_START_REQ_STRUCT StartReq; >- MLME_JOIN_REQ_STRUCT JoinReq; >- ULONG BssIdx; >- >- BssIdx = pAd->Mlme.CntlAux.BssIdx; >- if (BssIdx < pAd->Mlme.CntlAux.SsidBssTab.BssNr) >- { >- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS)) >- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - Trying BSSID %02x:%02x:%02x:%02x:%02x:%02x ...\n", >- pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[0], >- pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[1], >- pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[2], >- pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[3], >- pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[4], >- pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[5]); >- 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->PortCfg.BssType == BSS_INDEP) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",pAd->Mlme.CntlAux.Ssid); >- StartParmFill(pAd, &StartReq, pAd->Mlme.CntlAux.Ssid, (UCHAR)pAd->Mlme.CntlAux.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 >- { >- if (pAd->Mlme.CntlAux.CurrReqIsFromNdis) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - All BSS fail; reply NDIS_STATUS_NOT_ACCEPTED\n"); >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS); >- } >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- } >-} >- >-// for re-association only >-VOID IterateOnBssTab2( >- IN PRT2570ADAPTER pAd) >-{ >- MLME_REASSOC_REQ_STRUCT ReassocReq; >- ULONG BssIdx; >- BSS_ENTRY *pBss; >- >- BssIdx = pAd->Mlme.CntlAux.RoamIdx; >- pBss = &pAd->Mlme.CntlAux.RoamTab.BssEntry[BssIdx]; >- >- if (BssIdx < pAd->Mlme.CntlAux.RoamTab.BssNr) >- { >- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS)) >- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS);//steven:for test >- >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - try BSS #%d %02x:%02x:%02x:%02x:%02x:%02x ...\n", >- BssIdx, pBss->Bssid.Octet[0],pBss->Bssid.Octet[1],pBss->Bssid.Octet[2], >- pBss->Bssid.Octet[3],pBss->Bssid.Octet[4],pBss->Bssid.Octet[5]); >- >- AsicSwitchChannel(pAd, pBss->Channel); >- AsicLockChannel(pAd, pBss->Channel); >- >- // reassociate message has the same structure as associate message >- AssocParmFill(pAd, &ReassocReq, &pBss->Bssid, pBss->CapabilityInfo, >- ASSOC_TIMEOUT, pAd->PortCfg.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 >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - All roaming failed, stay with original AP\n"); >- AsicSwitchChannel(pAd, pAd->PortCfg.Channel); >- AsicLockChannel(pAd, pAd->PortCfg.Channel); >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS);//steven:for test >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID JoinParmFill( >- IN PRT2570ADAPTER pAd, >- IN OUT MLME_JOIN_REQ_STRUCT *JoinReq, >- IN ULONG BssIdx) >-{ >- JoinReq->BssIdx = BssIdx; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID AssocParmFill( >- IN PRT2570ADAPTER pAd, >- IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq, >- IN MACADDR *Addr, >- IN USHORT CapabilityInfo, >- IN ULONG Timeout, >- IN USHORT ListenIntv) >-{ >- COPY_MAC_ADDR(&AssocReq->Addr, Addr); >- // Add mask to support 802.11b mode only >- AssocReq->CapabilityInfo = CapabilityInfo & 0xfff3; // not cf-pollable, not cf-poll-request >- AssocReq->Timeout = Timeout; >- AssocReq->ListenIntv = ListenIntv; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID ScanParmFill( >- IN PRT2570ADAPTER pAd, >- IN OUT MLME_SCAN_REQ_STRUCT *ScanReq, >- IN CHAR Ssid[], >- IN UCHAR SsidLen, >- IN UCHAR BssType, >- IN UCHAR ScanType) >-{ >- ScanReq->SsidLen = SsidLen; >- NdisMoveMemory(ScanReq->Ssid, Ssid, SsidLen); >- ScanReq->BssType = BssType; >- ScanReq->ScanType = ScanType; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID DisassocParmFill( >- IN PRT2570ADAPTER pAd, >- IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq, >- IN MACADDR *Addr, >- IN USHORT Reason) >-{ >- COPY_MAC_ADDR(&DisassocReq->Addr, Addr); >- DisassocReq->Reason = Reason; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID StartParmFill( >- IN PRT2570ADAPTER pAd, >- IN OUT MLME_START_REQ_STRUCT *StartReq, >- IN CHAR Ssid[], >- IN UCHAR SsidLen) >-{ >- NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen); >- StartReq->SsidLen = SsidLen; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >-*/ >-VOID AuthParmFill( >- IN PRT2570ADAPTER pAd, >- IN OUT MLME_AUTH_REQ_STRUCT *AuthReq, >- IN MACADDR *Addr, >- IN USHORT Alg) >-{ >- COPY_MAC_ADDR(&AuthReq->Addr, Addr); >- AuthReq->Alg = Alg; >- AuthReq->Timeout = AUTH_TIMEOUT; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID ComposePsPoll( >- IN PRT2570ADAPTER pAd) >-{ >- PSPOLL_FRAME *pPsPoll = (PSPOLL_FRAME *)&(pAd->PsPollContext.TransferBuffer->WirelessPacket); >- NdisZeroMemory(pPsPoll, sizeof(PSPOLL_FRAME)); >- pPsPoll->Type = BTYPE_CNTL; >- pPsPoll->SubType = SUBTYPE_PS_POLL; >- pPsPoll->Aid = pAd->PortCfg.Aid | 0xC000; >- COPY_MAC_ADDR(&(pPsPoll->Bssid), &pAd->PortCfg.Bssid); >- COPY_MAC_ADDR(&(pPsPoll->Ta), &(pAd->CurrentAddress)); >-} >- >-VOID ComposeNullFrame( >- IN PRT2570ADAPTER pAd) >-{ >- PHEADER_802_11 pNullFrame = (PHEADER_802_11)&(pAd->NullContext.TransferBuffer->WirelessPacket); >- MgtMacHeaderInit(pAd, (PMACHDR)pNullFrame, SUBTYPE_NULL_FUNC, 1, &pAd->PortCfg.Bssid, &pAd->PortCfg.Bssid); >- pNullFrame->Controlhead.Duration = 0; >- pNullFrame->Controlhead.Frame.Type = BTYPE_DATA; >-} >- >-/* >- ========================================================================== >- Description: >- Pre-build a BEACON frame in the shared memory >- ========================================================================== >-*/ >-VOID MakeIbssBeacon( >- IN PRT2570ADAPTER pAd) >-{ >- UCHAR SsidIe = IE_SSID, DsIe = IE_DS_PARM, IbssIe = IE_IBSS_PARM, SuppIe = IE_SUPP_RATES, >- DsLen = 1, IbssLen = 2; >- UCHAR i, ExtRateIe = IE_EXT_SUPP_RATES, ExtRatesLen; >- UCHAR ErpIe[3] = {IE_ERP, 1, 0x04}; >- MACHDR BcnHdr; >- USHORT CapabilityInfo; >- LARGE_INTEGER FakeTimestamp; >- ULONG FrameLen; >- UCHAR SupportedRatesLen = 0; >- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES]; >- BOOLEAN Privacy; >- PUCHAR pBeaconFrame; >- PTXD_STRUC pTxD; >- ULONG BulkOutLength; >- PTX_CONTEXT pBeaconContext = &(pAd->BeaconContext[0]); >- >- if (pAd->MLMEThr_pid <= 0) >- return; >- // 2003-12-10 802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode >- // make sure 1,2,5.5,11 are the firt 4 rates in PortCfg.SupportedRates[] array >- if ((pAd->PortCfg.PhyMode == PHY_11BG_MIXED) && (pAd->PortCfg.AdhocMode == 0)) >- { >- for (i = 0; i < pAd->PortCfg.SupportedRatesLen; i++) >- { >- switch (pAd->PortCfg.SupportedRates[i] & 0x7f) >- { >- case 2: >- case 4: >- case 11: >- case 22: >- SupportedRates[SupportedRatesLen] = pAd->PortCfg.SupportedRates[i]; >- SupportedRatesLen ++; >- break; >- default: >- break; >- } >- } >- // error handling - should never happen >- if (SupportedRatesLen != 4) >- { >- SupportedRatesLen = 4; >- SupportedRates[0] = 0x82; >- SupportedRates[1] = 0x84; >- SupportedRates[2] = 0x8b; >- SupportedRates[3] = 0x96; >- } >- } >- else >- { >- SupportedRatesLen = pAd->PortCfg.SupportedRatesLen; >- NdisMoveMemory(SupportedRates, pAd->PortCfg.SupportedRates, SupportedRatesLen); >- } >- >- if (pBeaconContext->InUse == TRUE) >- return; >- else >- pBeaconContext->InUse = TRUE; >- >- pAd->PortCfg.AtimWin = 0; // ?????? >- >- // compose IBSS beacon frame >- MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, &pAd->PortCfg.Broadcast, &pAd->PortCfg.Bssid); >- Privacy = (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) || >- (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) || >- (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled); >- CapabilityInfo = CAP_GENERATE(0, 1, 0, 0, Privacy, (pAd->PortCfg.WindowsTxPreamble == Rt802_11PreambleShort)); >- >- // Prepare beacon frame, this should go to beacon_ring[1] which contains the real body. >- pBeaconFrame = (PUCHAR) pAd->BeaconContext[1].TransferBuffer->WirelessPacket; >- >- if (SupportedRatesLen <= 8) >- { >- MakeOutgoingFrame(pBeaconFrame, &FrameLen, >- MAC_HDR_LEN, &BcnHdr, >- TIMESTAMP_LEN, &FakeTimestamp, >- 2, &pAd->PortCfg.BeaconPeriod, >- 2, &CapabilityInfo, >- 1, &SsidIe, >- 1, &pAd->PortCfg.SsidLen, >- pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid, >- 1, &SuppIe, >- 1, &SupportedRatesLen, >- SupportedRatesLen, SupportedRates, >- 1, &DsIe, >- 1, &DsLen, >- 1, &pAd->PortCfg.Channel, >- 1, &IbssIe, >- 1, &IbssLen, >- 2, &pAd->PortCfg.AtimWin, >- END_OF_ARGS); >- } >- else >- { >- ExtRatesLen = SupportedRatesLen - 8; >- SupportedRatesLen = 8; >- MakeOutgoingFrame(pBeaconFrame, &FrameLen, >- MAC_HDR_LEN, &BcnHdr, >- TIMESTAMP_LEN, &FakeTimestamp, >- 2, &pAd->PortCfg.BeaconPeriod, >- 2, &CapabilityInfo, >- 1, &SsidIe, >- 1, &pAd->PortCfg.SsidLen, >- pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid, >- 1, &SuppIe, >- 1, &SupportedRatesLen, >- SupportedRatesLen, SupportedRates, >- 1, &DsIe, >- 1, &DsLen, >- 1, &pAd->PortCfg.Channel, >- 1, &IbssIe, >- 1, &IbssLen, >- 2, &pAd->PortCfg.AtimWin, >- 3, ErpIe, >- 1, &ExtRateIe, >- 1, &ExtRatesLen, >- ExtRatesLen, &SupportedRates[SupportedRatesLen], >- END_OF_ARGS); >- } >- >- // If adhoc secruity is set for WPA-None, append the cipher suite IE >- if (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPANone) >- { >- ULONG tmp = 0; >- UCHAR WpaIe = IE_WPA; >- >- if (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) // Tkip >- { >- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp, >- 1, &WpaIe, >- 1, &CipherSuiteWpaNoneTkipLen, >- CipherSuiteWpaNoneTkipLen, &CipherSuiteWpaNoneTkip[0], >- END_OF_ARGS); >- FrameLen += tmp; >- } >- else if (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled) // Aes >- { >- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp, >- 1, &WpaIe, >- 1, &CipherSuiteWpaNoneAesLen, >- CipherSuiteWpaNoneAesLen, &CipherSuiteWpaNoneAes[0], >- END_OF_ARGS); >- FrameLen += tmp; >- } >- } >- >- BulkOutLength = sizeof(TXD_STRUC) + FrameLen; >- if ((BulkOutLength % 2) == 1) >- BulkOutLength ++; >-// if (BulkOutLength % pAd->BulkOutMaxPacketSize == 0) >-// BulkOutLength += 2; >- >- for (i = 0; i < BEACON_RING_SIZE; i++) >- { >- pTxD = (PTXD_STRUC) &pAd->BeaconContext[i].TransferBuffer->TxDesc; >- NdisZeroMemory(pTxD, sizeof(TXD_STRUC)); >- pBeaconContext = &(pAd->BeaconContext[i]);; >- >- // Both TxD need to put in the right descriptor >- RTUSBWriteBeaconDescriptor(pTxD, FrameLen, FrameLen + 4, pAd->PortCfg.MlmeRate, 4, pAd->PortCfg.TxPreambleInUsed); >- if (i == 0) >- pBeaconContext->BulkOutSize = 1; >- else >- pBeaconContext->BulkOutSize = BulkOutLength; >- DBGPRINT(RT_DEBUG_TRACE, " (pBeaconContext->BulkOutSize=%d)\n", pBeaconContext->BulkOutSize); >- } >- >- // The flags will always start from beacon 0 >- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_BEACON_0); >- >- // Kick bulk out >- RTUSBKickBulkOut(pAd); >- >-} >diff -ruN rt2570-1.1.0-b1/Module/iwpriv_usage.txt rt2570-cvs-2005122616/Module/iwpriv_usage.txt >--- rt2570-1.1.0-b1/Module/iwpriv_usage.txt 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/iwpriv_usage.txt 2005-11-30 07:43:27.000000000 -0600 >@@ -1,151 +1,70 @@ >- >-This file provides some basic examples on the configuration of the driver using standard linux wireless tools. Where possible iwconfig should be used to adjust settings. Some settings are currently not avaiable via iwconfig and these include WPA, for these functions it is currently necessary to use iwpriv. >- >- >-Configuration Examples >-=================================================================== >-------------------------------------------------------------------------------------------------------- >-Example I: Config STA to link with AP which is OPEN/NONE(Authentication/Encryption) >- 1. iwconfig ra0 mode managed >- 2. iwconfig ra0 key open >- 3. iwconfig ra0 key off >- 4. iwconfig ra0 essid "AP's SSID" >- >-Example II: Config STA to link with AP which is SHARED/WEP(Authentication/Encryption) >- 1. iwconfig ra0 mode managed >- 2. iwconfig ra0 key restricted >- 3. iwconfig ra0 Key [1] "s:AP's wep key" >- 4. iwconfig ra0 key [1] >- 5. iwconfig ra0 essid "AP's SSID" >- >-Example III: Config STA to create/link as adhoc mode >- 1. iwconfig ra0 mode ad-hoc >- 2. iwconfig ra0 key off >- 4. iwconfig ra0 essid "AP's SSID" >- >-Example IV: Config STA to link with AP which is WPAPSK/TKIP(Authentication/Encryption) >- 1. iwconfig ra0 mode managed >- 2. iwpriv ra0 set AuthMode=WPAPSK >- 3. iwpriv ra0 set EncrypType=TKIP >- 4. iwpriv ra0 set WPAPSK="AP's wpa-preshared key" >- 5. iwconfig ra0 essid "AP's SSID" >- >-Example V: Config STA to link with AP which is WPAPSK/AES(Authentication/Encryption) >- 1. iwconfig ra0 mode managed >- 2. iwpriv ra0 set AuthMode=WPAPSK >- 3. iwpriv ra0 set EncrypType=AES >- 5. iwpriv ra0 set WPAPSK="AP's wpa-preshared key" >- 6. iwconfig ra0 essid "AP's SSID" >- >- >- >-iwpriv >-================= >-This is detailed explanation of each parameters for iwpriv. >-Before reading this document, make sure you already read README. >- >-------------------------------------------------------------------------------------------------------- >-USAGE: >- iwpriv ra0 set [parameters]=[val] >- >-where >- >-[parameters] [val] range explaination >------------------ ----------------------- --------------------------------------------- >-CountryRegion {0~7} Set country region >- 0: use 1 ~ 11 Channel >- 1: use 1 ~ 11 Channel >- 2: use 1 ~ 13 Channel >- 3: use 10, 11 Channel >- 4: use 10 ~ 13 Channel >- 5: use 14 Channel >- 6: use 1 ~ 14 Channel >- 7: use 3 ~ 9 Channel >- >-WirelessMode {0~2} Set Wireless Mode >- 0:11b/g mixed, 1:11B only >- >-TxRate {0~12} Set TxRate >- 0:Auto, 1:1Mbps, 2:2Mbps, 3:5.5Mbps, 4:11Mbps, >- 5:6Mbps, 6:9Mbps, 7:12Mbps, 8:18Mbps, 9:24Mbps, >- 10:36Mbps, 11:48Mbps, 12:54Mbps >- >-BGProtection {0~2} Set 11B/11G Protection >- 0:Auto, 1:Always on, 2:Always off >- >-TxPreamble {0~2} Set TxPreamble >- 0:Preamble Long, 1:Preamble Short, 2:Auto >- >-TxBurst {0,1} Set TxBurst Enable or Disable >- 0:Disable, 1:Enable >- >-TurboRate {0,1} Set TurboRate Enable or Disable >- 0:Disable, 1:Enable >- >-AdhocOfdm {0, 1} Set Adhoc mode tx rate >- 0: adhere WIFI spec., 1: violate WIFI spec. >- (802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode) >- AuthMode {OPEN,SHARED,WPAPSK} Set Authentication mode >- >-EncrypType {NONE,WEP,TKIP,AES} Set Encryption Type >- >-WPAPSK {8~63 ASCII or 64 HEX characters} WPA Pre-Shared Key >- >-ApClient {0,1} Set ApClient mode >- 0:Disable, 1:Enable >- >-iwlist >-================= >-This is detailed explanation of each parameters for iwlist. >- >-------------------------------------------------------------------------------------------------------- >- >-iwlist ra0 scanning ; list the result after scanning(site survey) >- >- >- >- >----------------------------------------------------------------------------------------------------------------------------------- >- >- >-Deprecated iwpriv >-================= >- >-*** PLEASE DO NOT USE THESE FUNCTIONS, THIS IS FOR HISTORICAL REFERENCE ONLY *** >-As the configuration utility still uses some iwpriv commands they have not been >-removed from the driver yet. These commands are likely to dissapear if the utility is >-updated. >- >-** ALL THESE COMMANDS HAVE A IWCONFIG REPLACEMENT, USE IT **** >- >-SSID {0~z, less than 32 characters} Set SoftAP SSID >- >-Channel {1~14} depends on country region Set Channel >- >-RTSThreshold {1~2347} Set RTS Threshold >- >-FragThreshold {256~2346} Set Fragment Threshold >- >-NetworkType {Infra,Adhoc} Set Network type >- >-DefaultKeyID {1~4} Set Default Key ID >- >-Key1 {5 ascii characters or Set Key1 String >- 10 hex number or >- 13 ascii characters or >- 26 hex numbers} >- >-Key2 {5 ascii characters or Set Key2 String >- 10 hex number or >- 13 ascii characters or >- 26 hex numbers} >- >-Key3 {5 ascii characters or Set Key3 String >- 10 hex number or >- 13 ascii characters or >- 26 hex numbers} >- >-Key4 {5 ascii characters or Set Key4 String >- 10 hex number or >- 13 ascii characters or >- 26 hex numbers} >+iwpriv >+================= >+This is detailed explanation of each parameters for iwpriv. >+Before reading this document, make sure you already read README. >+ >+------------------------------------------------------------------------------------------------------- >+USAGE: >+ iwpriv rausb0 set [parameters]=[val] >+ >+where >+ >+[parameters] [val] range explaination >+----------------- ----------------------- --------------------------------------------- >+auth 0~2 0:open >+ 1:shared >+ 2:wpapsk >+ 3:wpanone >+ >+keyid 1~4 wep key id >+ >+enc 1~3 1:none >+ 2:wep >+ 3:tkip >+ >+wpapsk 8~63 chars WPAPSK password >+ >+adhocmode 0~2 0: Plain 11Mbps >+ mode in >+ Ad-Hoc >+ (IEEE >+ 802.11g >+ standard) >+ 1: Auto mode >+ in Ad-Hoc >+ (violates >+ IEEE 802.11g >+ standard) >+ 2: 54Mbps only. >+ >+Examples >+=================================================================== >+------------------------------------------------------------------------------------------------------- >+Example I: Config STA to link with AP which is OPEN/NONE(Authentication/Encryption) >+ 1. iwconfig rausb0 mode Managed >+ 2. iwconfig rausb0 enc none >+ 3. iwconfig rausb0 essid "AP's SSID" >+ >+Example II: Config STA to link with AP which is OPEN/WEP(Authentication/Encryption) >+ 1. iwconfig rausb0 enc s:abcde >+ 2. iwconfig rausb0 essid "AP's SSID" >+ >+ >+Example III: Config STA to link with AP which is WPAPSK/TKIP(Authentication/Encryption) >+ 1. iwpriv rausb0 enc 3 >+ 2. iwconfig rausb0 essid "AP's SSID" >+ 3. iwpriv rausb0 wpapsk 12345678 >+ 4. iwconfig rausb0 essid "AP's SSID" >+ >+p.s Step 2 is part of generating wpapsk password and is necessary. >+ >+NOTE: >+ >+iwlist >+================= >+This is detailed explanation of each parameters for iwlist. >+ >+------------------------------------------------------------------------------------------------------- >+ >+iwlist rausb0 scanning ; list the result after scanning(site survey) >+ >diff -ruN rt2570-1.1.0-b1/Module/Makefile rt2570-cvs-2005122616/Module/Makefile >--- rt2570-1.1.0-b1/Module/Makefile 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/Makefile 2005-10-23 07:24:29.000000000 -0500 >@@ -73,6 +73,12 @@ > MODULE_ROOT := /lib/modules/$(shell uname -r)/extra > endif > >+ifdef KERNOUT >+ KERNEL_OUTPUT := KBUILD_OUTPUT=$(KERNOUT) >+else >+ KERNEL_OUTPUT := >+endif >+ > src ?= . > obj ?= . > >@@ -89,7 +95,7 @@ > $(LD) $(EXTRA_LDFLAGS) -r -o $@ $($(MODULE_NAME)-objs) > endif > >-KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(PWD) >+KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(PWD) $(KERNEL_OUTPUT) > > module: > @$(MAKE) $(KBUILD_PARAMS) modules; \ >@@ -98,6 +104,20 @@ > exit 1; \ > fi > >+arm: >+ @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-mstructure-size-boundary=8 -I$(src)' modules; >+ if ! [ -f $(MODULE_OBJECT) ]; then \ >+ echo "$(MODULE_OBJECT) failed to build!"; \ >+ exit 1; \ >+ fi >+ >+armdebug: >+ @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-mstructure-size-boundary=8 -I$(src) -DRT2500_DBG' modules; >+ if ! [ -f $(MODULE_OBJECT) ]; then \ >+ echo "$(MODULE_OBJECT) failed to build!"; \ >+ exit 1; \ >+ fi >+ > debug: > @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-I$(src) -DRT2500_DBG' modules; \ > if ! [ -f $(MODULE_OBJECT) ]; then \ >@@ -122,8 +142,10 @@ > else > echo "2.6 module install" > make $(KBUILD_PARAMS) modules_install >+ /sbin/depmod -a > endif > >+ > install: modules_install > @if ! grep -q 'rausb0' $(MODULE_CONF) ; then \ > echo "append 'alias rausb0 rt2570' to $(MODULE_CONF)"; \ >diff -ruN rt2570-1.1.0-b1/Module/.#md5.c.1.2 rt2570-cvs-2005122616/Module/.#md5.c.1.2 >--- rt2570-1.1.0-b1/Module/.#md5.c.1.2 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#md5.c.1.2 1969-12-31 18:00:00.000000000 -0600 >@@ -1,1369 +0,0 @@ >-/*************************************************************************** >- * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net * >- * * >- * 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. * >- * * >- * Licensed under the GNU GPL * >- * Original code supplied under license from RaLink Inc, 2004. * >- ***************************************************************************/ >- >-/*************************************************************************** >- * Module Name: md5.c >- * >- * Abstract: >- * >- * Revision History: >- * Who When What >- * -------- ---------- ------------------------------- >- * Name Date Modification logs >- * Jan Lee 2005-06-01 Release >- * Rita 11-23-04 Modify MD5 and SHA-1 >- ***************************************************************************/ >- >-#include "rt_config.h" >- >-/** >- * md5_mac: >- * @key: pointer to the key used for MAC generation >- * @key_len: length of the key in bytes >- * @data: pointer to the data area for which the MAC is generated >- * @data_len: length of the data in bytes >- * @mac: pointer to the buffer holding space for the MAC; the buffer should >- * have space for 128-bit (16 bytes) MD5 hash value >- * >- * md5_mac() determines the message authentication code by using secure hash >- * MD5(key | data | key). >- */ >-void md5_mac(UCHAR *key, ULONG key_len, UCHAR *data, ULONG data_len, UCHAR *mac) >-{ >- MD5_CTX context; >- >- MD5Init(&context); >- MD5Update(&context, key, key_len); >- MD5Update(&context, data, data_len); >- MD5Update(&context, key, key_len); >- MD5Final(mac, &context); >-} >- >- >-/** >- * hmac_md5: >- * @key: pointer to the key used for MAC generation >- * @key_len: length of the key in bytes >- * @data: pointer to the data area for which the MAC is generated >- * @data_len: length of the data in bytes >- * @mac: pointer to the buffer holding space for the MAC; the buffer should >- * have space for 128-bit (16 bytes) MD5 hash value >- * >- * hmac_md5() determines the message authentication code using HMAC-MD5. >- * This implementation is based on the sample code presented in RFC 2104. >- */ >-void hmac_md5(UCHAR *key, ULONG key_len, UCHAR *data, ULONG data_len, UCHAR *mac) >-{ >- MD5_CTX context; >- UCHAR k_ipad[65]; /* inner padding - key XORd with ipad */ >- UCHAR k_opad[65]; /* outer padding - key XORd with opad */ >- UCHAR tk[16]; >- int i; >- >- //assert(key != NULL && data != NULL && mac != NULL); >- >- /* if key is longer than 64 bytes reset it to key = MD5(key) */ >- if (key_len > 64) { >- MD5_CTX ttcontext; >- >- MD5Init(&ttcontext); >- MD5Update(&ttcontext, key, key_len); >- MD5Final(tk, &ttcontext); >- //key=(PUCHAR)ttcontext.buf; >- key = tk; >- key_len = 16; >- } >- >- /* the HMAC_MD5 transform looks like: >- * >- * MD5(K XOR opad, MD5(K XOR ipad, text)) >- * >- * where K is an n byte key >- * ipad is the byte 0x36 repeated 64 times >- * opad is the byte 0x5c repeated 64 times >- * and text is the data being protected */ >- >- /* start out by storing key in pads */ >- NdisZeroMemory(k_ipad, sizeof(k_ipad)); >- NdisZeroMemory(k_opad, sizeof(k_opad)); >- //assert(key_len < sizeof(k_ipad)); >- NdisMoveMemory(k_ipad, key, key_len); >- NdisMoveMemory(k_opad, key, key_len); >- >- /* XOR key with ipad and opad values */ >- for (i = 0; i < 64; i++) { >- k_ipad[i] ^= 0x36; >- k_opad[i] ^= 0x5c; >- } >- >- /* perform inner MD5 */ >- MD5Init(&context); /* init context for 1st pass */ >- MD5Update(&context, k_ipad, 64); /* start with inner pad */ >- MD5Update(&context, data, data_len); /* then text of datagram */ >- MD5Final(mac, &context); /* finish up 1st pass */ >- >- /* perform outer MD5 */ >- MD5Init(&context); /* init context for 2nd pass */ >- MD5Update(&context, k_opad, 64); /* start with outer pad */ >- MD5Update(&context, mac, 16); /* then results of 1st hash */ >- MD5Final(mac, &context); /* finish up 2nd pass */ >-} >- >-//#ifndef WORDS_BIGENDIAN >-#if 1 >-#define byteReverse(buf, len) /* Nothing */ >-#else >-void byteReverse(unsigned char *buf, unsigned longs); >- >-//#ifndef ASM_MD5 >-#if 1 >-/* >- * Note: this code is harmless on little-endian machines. >- */ >-void byteReverse(unsigned char *buf, unsigned longs) >-{ >- u32 t; >- DBGPRINT(RT_DEBUG_TRACE, ("bbjanbb byte reversee\n")); >- >- do { >- t = (u32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); >- *(u32 *) buf = t; >- buf += 4; >- } while (--longs); >-} >-#endif >-#endif >- >- >-/* ========================== MD5 implementation =========================== */ >-// four base functions for MD5 >-#define MD5_F1(x, y, z) (((x) & (y)) | ((~x) & (z))) >-#define MD5_F2(x, y, z) (((x) & (z)) | ((y) & (~z))) >-#define MD5_F3(x, y, z) ((x) ^ (y) ^ (z)) >-#define MD5_F4(x, y, z) ((y) ^ ((x) | (~z))) >-#define CYCLIC_LEFT_SHIFT(w, s) (((w) << (s)) | ((w) >> (32-(s)))) >- >-#define MD5Step(f, w, x, y, z, data, t, s) \ >- ( w += f(x, y, z) + data + t, w = (CYCLIC_LEFT_SHIFT(w, s)) & 0xffffffff, w += x ) >- >- >-/* >- * Function Description: >- * Initiate MD5 Context satisfied in RFC 1321 >- * >- * Arguments: >- * pCtx Pointer to MD5 context >- * >- * Return Value: >- * None >- */ >-VOID MD5Init(MD5_CTX *pCtx) >-{ >- pCtx->Buf[0]=0x67452301; >- pCtx->Buf[1]=0xefcdab89; >- pCtx->Buf[2]=0x98badcfe; >- pCtx->Buf[3]=0x10325476; >- >- pCtx->LenInBitCount[0]=0; >- pCtx->LenInBitCount[1]=0; >-} >- >- >-/* >- * Function Description: >- * Update MD5 Context, allow of an arrary of octets as the next portion >- * of the message >- * >- * Arguments: >- * pCtx Pointer to MD5 context >- * pData Pointer to input data >- * LenInBytes The length of input data (unit: byte) >- * >- * Return Value: >- * None >- * >- * Note: >- * Called after MD5Init or MD5Update(itself) >- */ >-VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, ULONG LenInBytes) >-{ >- >- ULONG TfTimes; >- ULONG temp; >- unsigned int i; >- >- temp = pCtx->LenInBitCount[0]; >- >- pCtx->LenInBitCount[0] = (ULONG) (pCtx->LenInBitCount[0] + (LenInBytes << 3)); >- >- if (pCtx->LenInBitCount[0] < temp) >- pCtx->LenInBitCount[1]++; //carry in >- >- pCtx->LenInBitCount[1] += LenInBytes >> 29; >- >- // mod 64 bytes >- temp = (temp >> 3) & 0x3f; >- >- // process lacks of 64-byte data >- if (temp) >- { >- UCHAR *pAds = (UCHAR *) pCtx->Input + temp; >- >- if ((temp+LenInBytes) < 64) >- { >- NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes); >- return; >- } >- >- NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp); >- byteReverse(pCtx->Input, 16); >- MD5Transform(pCtx->Buf, (ULONG *)pCtx->Input); >- >- pData += 64-temp; >- LenInBytes -= 64-temp; >- } // end of if (temp) >- >- >- TfTimes = (LenInBytes >> 6); >- >- for (i=TfTimes; i>0; i--) >- { >- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, 64); >- byteReverse(pCtx->Input, 16); >- MD5Transform(pCtx->Buf, (ULONG *)pCtx->Input); >- pData += 64; >- LenInBytes -= 64; >- } // end of for >- >- // buffering lacks of 64-byte data >- if(LenInBytes) >- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes); >- >-} >- >- >-/* >- * Function Description: >- * Append padding bits and length of original message in the tail >- * The message digest has to be completed in the end >- * >- * Arguments: >- * Digest Output of Digest-Message for MD5 >- * pCtx Pointer to MD5 context >- * >- * Return Value: >- * None >- * >- * Note: >- * Called after MD5Update >- */ >-VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx) >-{ >- UCHAR Remainder; >- UCHAR PadLenInBytes; >- UCHAR *pAppend=0; >- unsigned int i; >- >- Remainder = (UCHAR)((pCtx->LenInBitCount[0] >> 3) & 0x3f); >- >- PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder); >- >- pAppend = (UCHAR *)pCtx->Input + Remainder; >- >- // padding bits without crossing block(64-byte based) boundary >- if (Remainder < 56) >- { >- *pAppend = 0x80; >- PadLenInBytes --; >- >- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes); >- >- // add data-length field, from low to high >- for (i=0; i<4; i++) >- { >- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[0] >> (i << 3)) & 0xff); >- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[1] >> (i << 3)) & 0xff); >- } >- >- byteReverse(pCtx->Input, 16); >- MD5Transform(pCtx->Buf, (ULONG *)pCtx->Input); >- } // end of if >- >- // padding bits with crossing block(64-byte based) boundary >- else >- { >- // the first block === >- *pAppend = 0x80; >- PadLenInBytes --; >- >- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1)); >- PadLenInBytes -= (64 - Remainder - 1); >- >- byteReverse(pCtx->Input, 16); >- MD5Transform(pCtx->Buf, (ULONG *)pCtx->Input); >- >- >- // the second block === >- NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes); >- >- // add data-length field >- for (i=0; i<4; i++) >- { >- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[0] >> (i << 3)) & 0xff); >- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[1] >> (i << 3)) & 0xff); >- } >- >- byteReverse(pCtx->Input, 16); >- MD5Transform(pCtx->Buf, (ULONG *)pCtx->Input); >- } // end of else >- >- >- NdisMoveMemory((UCHAR *)Digest, (ULONG *)pCtx->Buf, 16); // output >- byteReverse((UCHAR *)Digest, 4); >- NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free >-} >- >- >-/* >- * Function Description: >- * The central algorithm of MD5, consists of four rounds and sixteen >- * steps per round >- * >- * Arguments: >- * Buf Buffers of four states (output: 16 bytes) >- * Mes Input data (input: 64 bytes) >- * >- * Return Value: >- * None >- * >- * Note: >- * Called by MD5Update or MD5Final >- */ >-VOID MD5Transform(ULONG Buf[4], ULONG Mes[16]) >-{ >- ULONG Reg[4], Temp; >- unsigned int i; >- >- static UCHAR LShiftVal[16] = >- { >- 7, 12, 17, 22, >- 5, 9 , 14, 20, >- 4, 11, 16, 23, >- 6, 10, 15, 21, >- }; >- >- >- // [equal to 4294967296*abs(sin(index))] >- static ULONG MD5Table[64] = >- { >- 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, >- 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, >- 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, >- 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, >- >- 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, >- 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, >- 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, >- 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, >- >- 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, >- 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, >- 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, >- 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, >- >- 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, >- 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, >- 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, >- 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 >- }; >- >- >- for (i=0; i<4; i++) >- Reg[i]=Buf[i]; >- >- >- // 64 steps in MD5 algorithm >- for (i=0; i<16; i++) >- { >- MD5Step(MD5_F1, Reg[0], Reg[1], Reg[2], Reg[3], Mes[i], >- MD5Table[i], LShiftVal[i & 0x3]); >- >- // one-word right shift >- Temp = Reg[3]; >- Reg[3] = Reg[2]; >- Reg[2] = Reg[1]; >- Reg[1] = Reg[0]; >- Reg[0] = Temp; >- } >- for (i=16; i<32; i++) >- { >- MD5Step(MD5_F2, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(5*(i & 0xf)+1) & 0xf], >- MD5Table[i], LShiftVal[(0x1 << 2)+(i & 0x3)]); >- >- // one-word right shift >- Temp = Reg[3]; >- Reg[3] = Reg[2]; >- Reg[2] = Reg[1]; >- Reg[1] = Reg[0]; >- Reg[0] = Temp; >- } >- for (i=32; i<48; i++) >- { >- MD5Step(MD5_F3, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(3*(i & 0xf)+5) & 0xf], >- MD5Table[i], LShiftVal[(0x1 << 3)+(i & 0x3)]); >- >- // one-word right shift >- Temp = Reg[3]; >- Reg[3] = Reg[2]; >- Reg[2] = Reg[1]; >- Reg[1] = Reg[0]; >- Reg[0] = Temp; >- } >- for (i=48; i<64; i++) >- { >- MD5Step(MD5_F4, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(7*(i & 0xf)) & 0xf], >- MD5Table[i], LShiftVal[(0x3 << 2)+(i & 0x3)]); >- >- // one-word right shift >- Temp = Reg[3]; >- Reg[3] = Reg[2]; >- Reg[2] = Reg[1]; >- Reg[1] = Reg[0]; >- Reg[0] = Temp; >- } >- >- >- // (temporary)output >- for (i=0; i<4; i++) >- Buf[i] += Reg[i]; >- >-} >- >- >- >-/* ========================= SHA-1 implementation ========================== */ >-// four base functions for SHA-1 >-#define SHA1_F1(b, c, d) (((b) & (c)) | ((~b) & (d))) >-#define SHA1_F2(b, c, d) ((b) ^ (c) ^ (d)) >-#define SHA1_F3(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) >- >- >-#define SHA1Step(f, a, b, c, d, e, w, k) \ >- ( e += ( f(b, c, d) + w + k + CYCLIC_LEFT_SHIFT(a, 5)) & 0xffffffff, \ >- b = CYCLIC_LEFT_SHIFT(b, 30) ) >- >-//Initiate SHA-1 Context satisfied in RFC 3174 >-VOID SHAInit(SHA_CTX *pCtx) >-{ >- pCtx->Buf[0]=0x67452301; >- pCtx->Buf[1]=0xefcdab89; >- pCtx->Buf[2]=0x98badcfe; >- pCtx->Buf[3]=0x10325476; >- pCtx->Buf[4]=0xc3d2e1f0; >- >- pCtx->LenInBitCount[0]=0; >- pCtx->LenInBitCount[1]=0; >-} >- >-/* >- * Function Description: >- * Update SHA-1 Context, allow of an arrary of octets as the next >- * portion of the message >- * >- * Arguments: >- * pCtx Pointer to SHA-1 context >- * pData Pointer to input data >- * LenInBytes The length of input data (unit: byte) >- * >- * Return Value: >- * error indicate more than pow(2,64) bits of data >- * >- * Note: >- * Called after SHAInit or SHAUpdate(itself) >- */ >-UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, ULONG LenInBytes) >-{ >- ULONG TfTimes; >- ULONG temp1,temp2; >- unsigned int i; >- UCHAR err=1; >- >- temp1 = pCtx->LenInBitCount[0]; >- temp2 = pCtx->LenInBitCount[1]; >- >- pCtx->LenInBitCount[0] = (ULONG) (pCtx->LenInBitCount[0] + (LenInBytes << 3)); >- if (pCtx->LenInBitCount[0] < temp1) >- pCtx->LenInBitCount[1]++; //carry in >- >- >- pCtx->LenInBitCount[1] = (ULONG) (pCtx->LenInBitCount[1] +(LenInBytes >> 29)); >- if (pCtx->LenInBitCount[1] < temp2) >- return (err); //check total length of original data >- >- >- // mod 64 bytes >- temp1 = (temp1 >> 3) & 0x3f; >- >- // process lacks of 64-byte data >- if (temp1) >- { >- UCHAR *pAds = (UCHAR *) pCtx->Input + temp1; >- >- if ((temp1+LenInBytes) < 64) >- { >- NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes); >- return (0); >- } >- >- NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp1); >- >- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16); >- SHATransform(pCtx->Buf, (ULONG *)pCtx->Input); >- >- pData += 64-temp1; >- LenInBytes -= 64-temp1; >- } // end of if (temp1) >- >- >- TfTimes = (LenInBytes >> 6); >- >- for (i=TfTimes; i>0; i--) >- { >- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, 64); >- >- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16); >- SHATransform(pCtx->Buf, (ULONG *)pCtx->Input); >- pData += 64; >- LenInBytes -= 64; >- } // end of for >- >- // buffering lacks of 64-byte data >- if(LenInBytes) >- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes); >- >- return (0); >- >-} >- >-// Append padding bits and length of original message in the tail >-// The message digest has to be completed in the end >-VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20]) >-{ >- UCHAR Remainder; >- UCHAR PadLenInBytes; >- UCHAR *pAppend=0; >- unsigned int i; >- >- Remainder = (UCHAR)((pCtx->LenInBitCount[0] >> 3) & 0x3f); >- >- pAppend = (UCHAR *)pCtx->Input + Remainder; >- >- PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder); >- >- // padding bits without crossing block(64-byte based) boundary >- if (Remainder < 56) >- { >- *pAppend = 0x80; >- PadLenInBytes --; >- >- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes); >- >- // add data-length field, from high to low >- for (i=0; i<4; i++) >- { >- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff); >- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff); >- } >- >- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 14); >- SHATransform(pCtx->Buf, (ULONG *)pCtx->Input); >- } // end of if >- >- // padding bits with crossing block(64-byte based) boundary >- else >- { >- // the first block === >- *pAppend = 0x80; >- PadLenInBytes --; >- >- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1)); >- PadLenInBytes -= (64 - Remainder - 1); >- >- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16); >- SHATransform(pCtx->Buf, (ULONG *)pCtx->Input); >- >- >- // the second block === >- NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes); >- >- // add data-length field >- for (i=0; i<4; i++) >- { >- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff); >- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff); >- } >- >- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16); >- SHATransform(pCtx->Buf, (ULONG *)pCtx->Input); >- } // end of else >- >- >- //Output, bytereverse >- for (i=0; i<20; i++) >- { >- Digest [i] = (UCHAR)(pCtx->Buf[i>>2] >> 8*(3-(i & 0x3))); >- } >- >- NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free >-} >- >- >-// The central algorithm of SHA-1, consists of four rounds and >-// twenty steps per round >-VOID SHATransform(ULONG Buf[5], ULONG Mes[20]) >-{ >- ULONG Reg[5],Temp; >- unsigned int i; >- ULONG W[80]; >- >- static ULONG SHA1Table[4] = { 0x5a827999, 0x6ed9eba1, >- 0x8f1bbcdc, 0xca62c1d6 }; >- >- Reg[0]=Buf[0]; >- Reg[1]=Buf[1]; >- Reg[2]=Buf[2]; >- Reg[3]=Buf[3]; >- Reg[4]=Buf[4]; >- >- //the first octet of a word is stored in the 0th element, bytereverse >- for(i = 0; i < 16; i++) >- { >- W[i] = (Mes[i] >> 24) & 0xff; >- W[i] |= (Mes[i] >> 8 ) & 0xff00; >- W[i] |= (Mes[i] << 8 ) & 0xff0000; >- W[i] |= (Mes[i] << 24) & 0xff000000; >- } >- >- >- for (i = 0; i < 64; i++) >- W[16+i] = CYCLIC_LEFT_SHIFT(W[i] ^ W[2+i] ^ W[8+i] ^ W[13+i], 1); >- >- >- // 80 steps in SHA-1 algorithm >- for (i=0; i<80; i++) >- { >- if (i<20) >- SHA1Step(SHA1_F1, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], >- W[i], SHA1Table[0]); >- >- else if (i>=20 && i<40) >- SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], >- W[i], SHA1Table[1]); >- >- else if (i>=40 && i<60) >- SHA1Step(SHA1_F3, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], >- W[i], SHA1Table[2]); >- >- else >- SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], >- W[i], SHA1Table[3]); >- >- >- // one-word right shift >- Temp = Reg[4]; >- Reg[4] = Reg[3]; >- Reg[3] = Reg[2]; >- Reg[2] = Reg[1]; >- Reg[1] = Reg[0]; >- Reg[0] = Temp; >- >- } // end of for-loop >- >- >- // (temporary)output >- for (i=0; i<5; i++) >- Buf[i] += Reg[i]; >- >-} >- >- >-/* ========================= AES En/Decryption ========================== */ >- >-/* forward S-box */ >-static uint32 FSb[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 >-}; >- >-/* forward table */ >-#define FT \ >-\ >- V(C6,63,63,A5), V(F8,7C,7C,84), V(EE,77,77,99), V(F6,7B,7B,8D), \ >- V(FF,F2,F2,0D), V(D6,6B,6B,BD), V(DE,6F,6F,B1), V(91,C5,C5,54), \ >- V(60,30,30,50), V(02,01,01,03), V(CE,67,67,A9), V(56,2B,2B,7D), \ >- V(E7,FE,FE,19), V(B5,D7,D7,62), V(4D,AB,AB,E6), V(EC,76,76,9A), \ >- V(8F,CA,CA,45), V(1F,82,82,9D), V(89,C9,C9,40), V(FA,7D,7D,87), \ >- V(EF,FA,FA,15), V(B2,59,59,EB), V(8E,47,47,C9), V(FB,F0,F0,0B), \ >- V(41,AD,AD,EC), V(B3,D4,D4,67), V(5F,A2,A2,FD), V(45,AF,AF,EA), \ >- V(23,9C,9C,BF), V(53,A4,A4,F7), V(E4,72,72,96), V(9B,C0,C0,5B), \ >- V(75,B7,B7,C2), V(E1,FD,FD,1C), V(3D,93,93,AE), V(4C,26,26,6A), \ >- V(6C,36,36,5A), V(7E,3F,3F,41), V(F5,F7,F7,02), V(83,CC,CC,4F), \ >- V(68,34,34,5C), V(51,A5,A5,F4), V(D1,E5,E5,34), V(F9,F1,F1,08), \ >- V(E2,71,71,93), V(AB,D8,D8,73), V(62,31,31,53), V(2A,15,15,3F), \ >- V(08,04,04,0C), V(95,C7,C7,52), V(46,23,23,65), V(9D,C3,C3,5E), \ >- V(30,18,18,28), V(37,96,96,A1), V(0A,05,05,0F), V(2F,9A,9A,B5), \ >- V(0E,07,07,09), V(24,12,12,36), V(1B,80,80,9B), V(DF,E2,E2,3D), \ >- V(CD,EB,EB,26), V(4E,27,27,69), V(7F,B2,B2,CD), V(EA,75,75,9F), \ >- V(12,09,09,1B), V(1D,83,83,9E), V(58,2C,2C,74), V(34,1A,1A,2E), \ >- V(36,1B,1B,2D), V(DC,6E,6E,B2), V(B4,5A,5A,EE), V(5B,A0,A0,FB), \ >- V(A4,52,52,F6), V(76,3B,3B,4D), V(B7,D6,D6,61), V(7D,B3,B3,CE), \ >- V(52,29,29,7B), V(DD,E3,E3,3E), V(5E,2F,2F,71), V(13,84,84,97), \ >- V(A6,53,53,F5), V(B9,D1,D1,68), V(00,00,00,00), V(C1,ED,ED,2C), \ >- V(40,20,20,60), V(E3,FC,FC,1F), V(79,B1,B1,C8), V(B6,5B,5B,ED), \ >- V(D4,6A,6A,BE), V(8D,CB,CB,46), V(67,BE,BE,D9), V(72,39,39,4B), \ >- V(94,4A,4A,DE), V(98,4C,4C,D4), V(B0,58,58,E8), V(85,CF,CF,4A), \ >- V(BB,D0,D0,6B), V(C5,EF,EF,2A), V(4F,AA,AA,E5), V(ED,FB,FB,16), \ >- V(86,43,43,C5), V(9A,4D,4D,D7), V(66,33,33,55), V(11,85,85,94), \ >- V(8A,45,45,CF), V(E9,F9,F9,10), V(04,02,02,06), V(FE,7F,7F,81), \ >- V(A0,50,50,F0), V(78,3C,3C,44), V(25,9F,9F,BA), V(4B,A8,A8,E3), \ >- V(A2,51,51,F3), V(5D,A3,A3,FE), V(80,40,40,C0), V(05,8F,8F,8A), \ >- V(3F,92,92,AD), V(21,9D,9D,BC), V(70,38,38,48), V(F1,F5,F5,04), \ >- V(63,BC,BC,DF), V(77,B6,B6,C1), V(AF,DA,DA,75), V(42,21,21,63), \ >- V(20,10,10,30), V(E5,FF,FF,1A), V(FD,F3,F3,0E), V(BF,D2,D2,6D), \ >- V(81,CD,CD,4C), V(18,0C,0C,14), V(26,13,13,35), V(C3,EC,EC,2F), \ >- V(BE,5F,5F,E1), V(35,97,97,A2), V(88,44,44,CC), V(2E,17,17,39), \ >- V(93,C4,C4,57), V(55,A7,A7,F2), V(FC,7E,7E,82), V(7A,3D,3D,47), \ >- V(C8,64,64,AC), V(BA,5D,5D,E7), V(32,19,19,2B), V(E6,73,73,95), \ >- V(C0,60,60,A0), V(19,81,81,98), V(9E,4F,4F,D1), V(A3,DC,DC,7F), \ >- V(44,22,22,66), V(54,2A,2A,7E), V(3B,90,90,AB), V(0B,88,88,83), \ >- V(8C,46,46,CA), V(C7,EE,EE,29), V(6B,B8,B8,D3), V(28,14,14,3C), \ >- V(A7,DE,DE,79), V(BC,5E,5E,E2), V(16,0B,0B,1D), V(AD,DB,DB,76), \ >- V(DB,E0,E0,3B), V(64,32,32,56), V(74,3A,3A,4E), V(14,0A,0A,1E), \ >- V(92,49,49,DB), V(0C,06,06,0A), V(48,24,24,6C), V(B8,5C,5C,E4), \ >- V(9F,C2,C2,5D), V(BD,D3,D3,6E), V(43,AC,AC,EF), V(C4,62,62,A6), \ >- V(39,91,91,A8), V(31,95,95,A4), V(D3,E4,E4,37), V(F2,79,79,8B), \ >- V(D5,E7,E7,32), V(8B,C8,C8,43), V(6E,37,37,59), V(DA,6D,6D,B7), \ >- V(01,8D,8D,8C), V(B1,D5,D5,64), V(9C,4E,4E,D2), V(49,A9,A9,E0), \ >- V(D8,6C,6C,B4), V(AC,56,56,FA), V(F3,F4,F4,07), V(CF,EA,EA,25), \ >- V(CA,65,65,AF), V(F4,7A,7A,8E), V(47,AE,AE,E9), V(10,08,08,18), \ >- V(6F,BA,BA,D5), V(F0,78,78,88), V(4A,25,25,6F), V(5C,2E,2E,72), \ >- V(38,1C,1C,24), V(57,A6,A6,F1), V(73,B4,B4,C7), V(97,C6,C6,51), \ >- V(CB,E8,E8,23), V(A1,DD,DD,7C), V(E8,74,74,9C), V(3E,1F,1F,21), \ >- V(96,4B,4B,DD), V(61,BD,BD,DC), V(0D,8B,8B,86), V(0F,8A,8A,85), \ >- V(E0,70,70,90), V(7C,3E,3E,42), V(71,B5,B5,C4), V(CC,66,66,AA), \ >- V(90,48,48,D8), V(06,03,03,05), V(F7,F6,F6,01), V(1C,0E,0E,12), \ >- V(C2,61,61,A3), V(6A,35,35,5F), V(AE,57,57,F9), V(69,B9,B9,D0), \ >- V(17,86,86,91), V(99,C1,C1,58), V(3A,1D,1D,27), V(27,9E,9E,B9), \ >- V(D9,E1,E1,38), V(EB,F8,F8,13), V(2B,98,98,B3), V(22,11,11,33), \ >- V(D2,69,69,BB), V(A9,D9,D9,70), V(07,8E,8E,89), V(33,94,94,A7), \ >- V(2D,9B,9B,B6), V(3C,1E,1E,22), V(15,87,87,92), V(C9,E9,E9,20), \ >- V(87,CE,CE,49), V(AA,55,55,FF), V(50,28,28,78), V(A5,DF,DF,7A), \ >- V(03,8C,8C,8F), V(59,A1,A1,F8), V(09,89,89,80), V(1A,0D,0D,17), \ >- V(65,BF,BF,DA), V(D7,E6,E6,31), V(84,42,42,C6), V(D0,68,68,B8), \ >- V(82,41,41,C3), V(29,99,99,B0), V(5A,2D,2D,77), V(1E,0F,0F,11), \ >- V(7B,B0,B0,CB), V(A8,54,54,FC), V(6D,BB,BB,D6), V(2C,16,16,3A) >- >-#define V(a,b,c,d) 0x##a##b##c##d >-static uint32 FT0[256] = { FT }; >-#undef V >- >-#define V(a,b,c,d) 0x##d##a##b##c >-static uint32 FT1[256] = { FT }; >-#undef V >- >-#define V(a,b,c,d) 0x##c##d##a##b >-static uint32 FT2[256] = { FT }; >-#undef V >- >-#define V(a,b,c,d) 0x##b##c##d##a >-static uint32 FT3[256] = { FT }; >-#undef V >- >-#undef FT >- >-/* reverse S-box */ >- >-static uint32 RSb[256] = >-{ >- 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, >- 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, >- 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, >- 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, >- 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, >- 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, >- 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, >- 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, >- 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, >- 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, >- 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, >- 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, >- 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, >- 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, >- 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, >- 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, >- 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, >- 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, >- 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, >- 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, >- 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, >- 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, >- 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, >- 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, >- 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, >- 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, >- 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, >- 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, >- 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, >- 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, >- 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, >- 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D >-}; >- >-/* reverse table */ >- >-#define RT \ >-\ >- V(51,F4,A7,50), V(7E,41,65,53), V(1A,17,A4,C3), V(3A,27,5E,96), \ >- V(3B,AB,6B,CB), V(1F,9D,45,F1), V(AC,FA,58,AB), V(4B,E3,03,93), \ >- V(20,30,FA,55), V(AD,76,6D,F6), V(88,CC,76,91), V(F5,02,4C,25), \ >- V(4F,E5,D7,FC), V(C5,2A,CB,D7), V(26,35,44,80), V(B5,62,A3,8F), \ >- V(DE,B1,5A,49), V(25,BA,1B,67), V(45,EA,0E,98), V(5D,FE,C0,E1), \ >- V(C3,2F,75,02), V(81,4C,F0,12), V(8D,46,97,A3), V(6B,D3,F9,C6), \ >- V(03,8F,5F,E7), V(15,92,9C,95), V(BF,6D,7A,EB), V(95,52,59,DA), \ >- V(D4,BE,83,2D), V(58,74,21,D3), V(49,E0,69,29), V(8E,C9,C8,44), \ >- V(75,C2,89,6A), V(F4,8E,79,78), V(99,58,3E,6B), V(27,B9,71,DD), \ >- V(BE,E1,4F,B6), V(F0,88,AD,17), V(C9,20,AC,66), V(7D,CE,3A,B4), \ >- V(63,DF,4A,18), V(E5,1A,31,82), V(97,51,33,60), V(62,53,7F,45), \ >- V(B1,64,77,E0), V(BB,6B,AE,84), V(FE,81,A0,1C), V(F9,08,2B,94), \ >- V(70,48,68,58), V(8F,45,FD,19), V(94,DE,6C,87), V(52,7B,F8,B7), \ >- V(AB,73,D3,23), V(72,4B,02,E2), V(E3,1F,8F,57), V(66,55,AB,2A), \ >- V(B2,EB,28,07), V(2F,B5,C2,03), V(86,C5,7B,9A), V(D3,37,08,A5), \ >- V(30,28,87,F2), V(23,BF,A5,B2), V(02,03,6A,BA), V(ED,16,82,5C), \ >- V(8A,CF,1C,2B), V(A7,79,B4,92), V(F3,07,F2,F0), V(4E,69,E2,A1), \ >- V(65,DA,F4,CD), V(06,05,BE,D5), V(D1,34,62,1F), V(C4,A6,FE,8A), \ >- V(34,2E,53,9D), V(A2,F3,55,A0), V(05,8A,E1,32), V(A4,F6,EB,75), \ >- V(0B,83,EC,39), V(40,60,EF,AA), V(5E,71,9F,06), V(BD,6E,10,51), \ >- V(3E,21,8A,F9), V(96,DD,06,3D), V(DD,3E,05,AE), V(4D,E6,BD,46), \ >- V(91,54,8D,B5), V(71,C4,5D,05), V(04,06,D4,6F), V(60,50,15,FF), \ >- V(19,98,FB,24), V(D6,BD,E9,97), V(89,40,43,CC), V(67,D9,9E,77), \ >- V(B0,E8,42,BD), V(07,89,8B,88), V(E7,19,5B,38), V(79,C8,EE,DB), \ >- V(A1,7C,0A,47), V(7C,42,0F,E9), V(F8,84,1E,C9), V(00,00,00,00), \ >- V(09,80,86,83), V(32,2B,ED,48), V(1E,11,70,AC), V(6C,5A,72,4E), \ >- V(FD,0E,FF,FB), V(0F,85,38,56), V(3D,AE,D5,1E), V(36,2D,39,27), \ >- V(0A,0F,D9,64), V(68,5C,A6,21), V(9B,5B,54,D1), V(24,36,2E,3A), \ >- V(0C,0A,67,B1), V(93,57,E7,0F), V(B4,EE,96,D2), V(1B,9B,91,9E), \ >- V(80,C0,C5,4F), V(61,DC,20,A2), V(5A,77,4B,69), V(1C,12,1A,16), \ >- V(E2,93,BA,0A), V(C0,A0,2A,E5), V(3C,22,E0,43), V(12,1B,17,1D), \ >- V(0E,09,0D,0B), V(F2,8B,C7,AD), V(2D,B6,A8,B9), V(14,1E,A9,C8), \ >- V(57,F1,19,85), V(AF,75,07,4C), V(EE,99,DD,BB), V(A3,7F,60,FD), \ >- V(F7,01,26,9F), V(5C,72,F5,BC), V(44,66,3B,C5), V(5B,FB,7E,34), \ >- V(8B,43,29,76), V(CB,23,C6,DC), V(B6,ED,FC,68), V(B8,E4,F1,63), \ >- V(D7,31,DC,CA), V(42,63,85,10), V(13,97,22,40), V(84,C6,11,20), \ >- V(85,4A,24,7D), V(D2,BB,3D,F8), V(AE,F9,32,11), V(C7,29,A1,6D), \ >- V(1D,9E,2F,4B), V(DC,B2,30,F3), V(0D,86,52,EC), V(77,C1,E3,D0), \ >- V(2B,B3,16,6C), V(A9,70,B9,99), V(11,94,48,FA), V(47,E9,64,22), \ >- V(A8,FC,8C,C4), V(A0,F0,3F,1A), V(56,7D,2C,D8), V(22,33,90,EF), \ >- V(87,49,4E,C7), V(D9,38,D1,C1), V(8C,CA,A2,FE), V(98,D4,0B,36), \ >- V(A6,F5,81,CF), V(A5,7A,DE,28), V(DA,B7,8E,26), V(3F,AD,BF,A4), \ >- V(2C,3A,9D,E4), V(50,78,92,0D), V(6A,5F,CC,9B), V(54,7E,46,62), \ >- V(F6,8D,13,C2), V(90,D8,B8,E8), V(2E,39,F7,5E), V(82,C3,AF,F5), \ >- V(9F,5D,80,BE), V(69,D0,93,7C), V(6F,D5,2D,A9), V(CF,25,12,B3), \ >- V(C8,AC,99,3B), V(10,18,7D,A7), V(E8,9C,63,6E), V(DB,3B,BB,7B), \ >- V(CD,26,78,09), V(6E,59,18,F4), V(EC,9A,B7,01), V(83,4F,9A,A8), \ >- V(E6,95,6E,65), V(AA,FF,E6,7E), V(21,BC,CF,08), V(EF,15,E8,E6), \ >- V(BA,E7,9B,D9), V(4A,6F,36,CE), V(EA,9F,09,D4), V(29,B0,7C,D6), \ >- V(31,A4,B2,AF), V(2A,3F,23,31), V(C6,A5,94,30), V(35,A2,66,C0), \ >- V(74,4E,BC,37), V(FC,82,CA,A6), V(E0,90,D0,B0), V(33,A7,D8,15), \ >- V(F1,04,98,4A), V(41,EC,DA,F7), V(7F,CD,50,0E), V(17,91,F6,2F), \ >- V(76,4D,D6,8D), V(43,EF,B0,4D), V(CC,AA,4D,54), V(E4,96,04,DF), \ >- V(9E,D1,B5,E3), V(4C,6A,88,1B), V(C1,2C,1F,B8), V(46,65,51,7F), \ >- V(9D,5E,EA,04), V(01,8C,35,5D), V(FA,87,74,73), V(FB,0B,41,2E), \ >- V(B3,67,1D,5A), V(92,DB,D2,52), V(E9,10,56,33), V(6D,D6,47,13), \ >- V(9A,D7,61,8C), V(37,A1,0C,7A), V(59,F8,14,8E), V(EB,13,3C,89), \ >- V(CE,A9,27,EE), V(B7,61,C9,35), V(E1,1C,E5,ED), V(7A,47,B1,3C), \ >- V(9C,D2,DF,59), V(55,F2,73,3F), V(18,14,CE,79), V(73,C7,37,BF), \ >- V(53,F7,CD,EA), V(5F,FD,AA,5B), V(DF,3D,6F,14), V(78,44,DB,86), \ >- V(CA,AF,F3,81), V(B9,68,C4,3E), V(38,24,34,2C), V(C2,A3,40,5F), \ >- V(16,1D,C3,72), V(BC,E2,25,0C), V(28,3C,49,8B), V(FF,0D,95,41), \ >- V(39,A8,01,71), V(08,0C,B3,DE), V(D8,B4,E4,9C), V(64,56,C1,90), \ >- V(7B,CB,84,61), V(D5,32,B6,70), V(48,6C,5C,74), V(D0,B8,57,42) >- >-#define V(a,b,c,d) 0x##a##b##c##d >-static uint32 RT0[256] = { RT }; >-#undef V >- >-#define V(a,b,c,d) 0x##d##a##b##c >-static uint32 RT1[256] = { RT }; >-#undef V >- >-#define V(a,b,c,d) 0x##c##d##a##b >-static uint32 RT2[256] = { RT }; >-#undef V >- >-#define V(a,b,c,d) 0x##b##c##d##a >-static uint32 RT3[256] = { RT }; >-#undef V >- >-#undef RT >- >-/* round constants */ >- >-static uint32 RCON[10] = >-{ >- 0x01000000, 0x02000000, 0x04000000, 0x08000000, >- 0x10000000, 0x20000000, 0x40000000, 0x80000000, >- 0x1B000000, 0x36000000 >-}; >- >-/* key schedule tables */ >- >-static int KT_init = 1; >- >-static uint32 KT0[256]; >-static uint32 KT1[256]; >-static uint32 KT2[256]; >-static uint32 KT3[256]; >- >-/* platform-independant 32-bit integer manipulation macros */ >- >-#define GET_UINT32(n,b,i) \ >-{ \ >- (n) = ( (uint32) (b)[(i) ] << 24 ) \ >- | ( (uint32) (b)[(i) + 1] << 16 ) \ >- | ( (uint32) (b)[(i) + 2] << 8 ) \ >- | ( (uint32) (b)[(i) + 3] ); \ >-} >- >-#define PUT_UINT32(n,b,i) \ >-{ \ >- (b)[(i) ] = (uint8) ( (n) >> 24 ); \ >- (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \ >- (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \ >- (b)[(i) + 3] = (uint8) ( (n) ); \ >-} >- >-/* AES key scheduling routine */ >- >-int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) >-{ >- int i; >- uint32 *RK, *SK; >- >- switch( nbits ) >- { >- case 128: ctx->nr = 10; break; >- case 192: ctx->nr = 12; break; >- case 256: ctx->nr = 14; break; >- default : return( 1 ); >- } >- >- RK = ctx->erk; >- >- for( i = 0; i < (nbits >> 5); i++ ) >- { >- GET_UINT32( RK[i], key, i * 4 ); >- } >- >- /* setup encryption round keys */ >- >- switch( nbits ) >- { >- case 128: >- >- for( i = 0; i < 10; i++, RK += 4 ) >- { >- RK[4] = RK[0] ^ RCON[i] ^ >- ( FSb[ (uint8) ( RK[3] >> 16 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( RK[3] >> 8 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( RK[3] ) ] << 8 ) ^ >- ( FSb[ (uint8) ( RK[3] >> 24 ) ] ); >- >- RK[5] = RK[1] ^ RK[4]; >- RK[6] = RK[2] ^ RK[5]; >- RK[7] = RK[3] ^ RK[6]; >- } >- break; >- >- case 192: >- >- for( i = 0; i < 8; i++, RK += 6 ) >- { >- RK[6] = RK[0] ^ RCON[i] ^ >- ( FSb[ (uint8) ( RK[5] >> 16 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( RK[5] >> 8 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( RK[5] ) ] << 8 ) ^ >- ( FSb[ (uint8) ( RK[5] >> 24 ) ] ); >- >- RK[7] = RK[1] ^ RK[6]; >- RK[8] = RK[2] ^ RK[7]; >- RK[9] = RK[3] ^ RK[8]; >- RK[10] = RK[4] ^ RK[9]; >- RK[11] = RK[5] ^ RK[10]; >- } >- break; >- >- case 256: >- >- for( i = 0; i < 7; i++, RK += 8 ) >- { >- RK[8] = RK[0] ^ RCON[i] ^ >- ( FSb[ (uint8) ( RK[7] >> 16 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( RK[7] >> 8 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( RK[7] ) ] << 8 ) ^ >- ( FSb[ (uint8) ( RK[7] >> 24 ) ] ); >- >- RK[9] = RK[1] ^ RK[8]; >- RK[10] = RK[2] ^ RK[9]; >- RK[11] = RK[3] ^ RK[10]; >- >- RK[12] = RK[4] ^ >- ( FSb[ (uint8) ( RK[11] >> 24 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( RK[11] >> 16 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( RK[11] >> 8 ) ] << 8 ) ^ >- ( FSb[ (uint8) ( RK[11] ) ] ); >- >- RK[13] = RK[5] ^ RK[12]; >- RK[14] = RK[6] ^ RK[13]; >- RK[15] = RK[7] ^ RK[14]; >- } >- break; >- } >- >- /* setup decryption round keys */ >- >- if( KT_init ) >- { >- for( i = 0; i < 256; i++ ) >- { >- KT0[i] = RT0[ FSb[i] ]; >- KT1[i] = RT1[ FSb[i] ]; >- KT2[i] = RT2[ FSb[i] ]; >- KT3[i] = RT3[ FSb[i] ]; >- } >- >- KT_init = 0; >- } >- >- SK = ctx->drk; >- >- *SK++ = *RK++; >- *SK++ = *RK++; >- *SK++ = *RK++; >- *SK++ = *RK++; >- >- for( i = 1; i < ctx->nr; i++ ) >- { >- RK -= 8; >- >- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ >- KT1[ (uint8) ( *RK >> 16 ) ] ^ >- KT2[ (uint8) ( *RK >> 8 ) ] ^ >- KT3[ (uint8) ( *RK ) ]; RK++; >- >- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ >- KT1[ (uint8) ( *RK >> 16 ) ] ^ >- KT2[ (uint8) ( *RK >> 8 ) ] ^ >- KT3[ (uint8) ( *RK ) ]; RK++; >- >- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ >- KT1[ (uint8) ( *RK >> 16 ) ] ^ >- KT2[ (uint8) ( *RK >> 8 ) ] ^ >- KT3[ (uint8) ( *RK ) ]; RK++; >- >- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^ >- KT1[ (uint8) ( *RK >> 16 ) ] ^ >- KT2[ (uint8) ( *RK >> 8 ) ] ^ >- KT3[ (uint8) ( *RK ) ]; RK++; >- } >- >- RK -= 8; >- >- *SK++ = *RK++; >- *SK++ = *RK++; >- *SK++ = *RK++; >- *SK++ = *RK++; >- >- return( 0 ); >-} >- >-/* AES 128-bit block encryption routine */ >- >-void aes_encrypt(aes_context *ctx, uint8 input[16], uint8 output[16] ) >-{ >- uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; >- >- RK = ctx->erk; >- GET_UINT32( X0, input, 0 ); X0 ^= RK[0]; >- GET_UINT32( X1, input, 4 ); X1 ^= RK[1]; >- GET_UINT32( X2, input, 8 ); X2 ^= RK[2]; >- GET_UINT32( X3, input, 12 ); X3 ^= RK[3]; >- >-#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ >-{ \ >- RK += 4; \ >- \ >- X0 = RK[0] ^ FT0[ (uint8) ( Y0 >> 24 ) ] ^ \ >- FT1[ (uint8) ( Y1 >> 16 ) ] ^ \ >- FT2[ (uint8) ( Y2 >> 8 ) ] ^ \ >- FT3[ (uint8) ( Y3 ) ]; \ >- \ >- X1 = RK[1] ^ FT0[ (uint8) ( Y1 >> 24 ) ] ^ \ >- FT1[ (uint8) ( Y2 >> 16 ) ] ^ \ >- FT2[ (uint8) ( Y3 >> 8 ) ] ^ \ >- FT3[ (uint8) ( Y0 ) ]; \ >- \ >- X2 = RK[2] ^ FT0[ (uint8) ( Y2 >> 24 ) ] ^ \ >- FT1[ (uint8) ( Y3 >> 16 ) ] ^ \ >- FT2[ (uint8) ( Y0 >> 8 ) ] ^ \ >- FT3[ (uint8) ( Y1 ) ]; \ >- \ >- X3 = RK[3] ^ FT0[ (uint8) ( Y3 >> 24 ) ] ^ \ >- FT1[ (uint8) ( Y0 >> 16 ) ] ^ \ >- FT2[ (uint8) ( Y1 >> 8 ) ] ^ \ >- FT3[ (uint8) ( Y2 ) ]; \ >-} >- >- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */ >- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */ >- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */ >- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */ >- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */ >- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */ >- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */ >- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */ >- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */ >- >- if( ctx->nr > 10 ) >- { >- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */ >- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */ >- } >- >- if( ctx->nr > 12 ) >- { >- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */ >- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */ >- } >- >- /* last round */ >- >- RK += 4; >- >- X0 = RK[0] ^ ( FSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^ >- ( FSb[ (uint8) ( Y3 ) ] ); >- >- X1 = RK[1] ^ ( FSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^ >- ( FSb[ (uint8) ( Y0 ) ] ); >- >- X2 = RK[2] ^ ( FSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^ >- ( FSb[ (uint8) ( Y1 ) ] ); >- >- X3 = RK[3] ^ ( FSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^ >- ( FSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^ >- ( FSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^ >- ( FSb[ (uint8) ( Y2 ) ] ); >- >- PUT_UINT32( X0, output, 0 ); >- PUT_UINT32( X1, output, 4 ); >- PUT_UINT32( X2, output, 8 ); >- PUT_UINT32( X3, output, 12 ); >-} >- >-/* AES 128-bit block decryption routine */ >- >-void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ) >-{ >- uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; >- >- RK = ctx->drk; >- >- GET_UINT32( X0, input, 0 ); X0 ^= RK[0]; >- GET_UINT32( X1, input, 4 ); X1 ^= RK[1]; >- GET_UINT32( X2, input, 8 ); X2 ^= RK[2]; >- GET_UINT32( X3, input, 12 ); X3 ^= RK[3]; >- >-#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ >-{ \ >- RK += 4; \ >- \ >- X0 = RK[0] ^ RT0[ (uint8) ( Y0 >> 24 ) ] ^ \ >- RT1[ (uint8) ( Y3 >> 16 ) ] ^ \ >- RT2[ (uint8) ( Y2 >> 8 ) ] ^ \ >- RT3[ (uint8) ( Y1 ) ]; \ >- \ >- X1 = RK[1] ^ RT0[ (uint8) ( Y1 >> 24 ) ] ^ \ >- RT1[ (uint8) ( Y0 >> 16 ) ] ^ \ >- RT2[ (uint8) ( Y3 >> 8 ) ] ^ \ >- RT3[ (uint8) ( Y2 ) ]; \ >- \ >- X2 = RK[2] ^ RT0[ (uint8) ( Y2 >> 24 ) ] ^ \ >- RT1[ (uint8) ( Y1 >> 16 ) ] ^ \ >- RT2[ (uint8) ( Y0 >> 8 ) ] ^ \ >- RT3[ (uint8) ( Y3 ) ]; \ >- \ >- X3 = RK[3] ^ RT0[ (uint8) ( Y3 >> 24 ) ] ^ \ >- RT1[ (uint8) ( Y2 >> 16 ) ] ^ \ >- RT2[ (uint8) ( Y1 >> 8 ) ] ^ \ >- RT3[ (uint8) ( Y0 ) ]; \ >-} >- >- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */ >- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */ >- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */ >- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */ >- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */ >- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */ >- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */ >- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */ >- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */ >- >- if( ctx->nr > 10 ) >- { >- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */ >- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */ >- } >- >- if( ctx->nr > 12 ) >- { >- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */ >- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */ >- } >- >- /* last round */ >- >- RK += 4; >- >- X0 = RK[0] ^ ( RSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^ >- ( RSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^ >- ( RSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^ >- ( RSb[ (uint8) ( Y1 ) ] ); >- >- X1 = RK[1] ^ ( RSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^ >- ( RSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^ >- ( RSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^ >- ( RSb[ (uint8) ( Y2 ) ] ); >- >- X2 = RK[2] ^ ( RSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^ >- ( RSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^ >- ( RSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^ >- ( RSb[ (uint8) ( Y3 ) ] ); >- >- X3 = RK[3] ^ ( RSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^ >- ( RSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^ >- ( RSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^ >- ( RSb[ (uint8) ( Y0 ) ] ); >- >- PUT_UINT32( X0, output, 0 ); >- PUT_UINT32( X1, output, 4 ); >- PUT_UINT32( X2, output, 8 ); >- PUT_UINT32( X3, output, 12 ); >-} >- >-/* >-* F(P, S, c, i) = U1 xor U2 xor ... Uc >-* U1 = PRF(P, S || Int(i)) >-* U2 = PRF(P, U1) >-* Uc = PRF(P, Uc-1) >-*/ >- >-void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output) >-{ >- unsigned char digest[36], digest1[SHA_DIGEST_LEN]; >- int i, j; >- >- /* U1 = PRF(P, S || int(i)) */ >- memcpy(digest, ssid, ssidlength); >- digest[ssidlength] = (unsigned char)((count>>24) & 0xff); >- digest[ssidlength+1] = (unsigned char)((count>>16) & 0xff); >- digest[ssidlength+2] = (unsigned char)((count>>8) & 0xff); >- digest[ssidlength+3] = (unsigned char)(count & 0xff); >- HMAC_SHA1(digest, ssidlength+4, (unsigned char*) password, (int) strlen(password), digest1); // for WPA update >- >- /* output = U1 */ >- memcpy(output, digest1, SHA_DIGEST_LEN); >- >- for (i = 1; i < iterations; i++) >- { >- /* Un = PRF(P, Un-1) */ >- HMAC_SHA1(digest1, SHA_DIGEST_LEN, (unsigned char*) password, (int) strlen(password), digest); // for WPA update >- memcpy(digest1, digest, SHA_DIGEST_LEN); >- >- /* output = output xor Un */ >- for (j = 0; j < SHA_DIGEST_LEN; j++) >- { >- output[j] ^= digest[j]; >- } >- } >-}/* >-* password - ascii string up to 63 characters in length >-* ssid - octet string up to 32 octets >-* ssidlength - length of ssid in octets >-* output must be 40 octets in length and outputs 256 bits of key >-*/ >-int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output) >-{ >- if ((strlen(password) > 63) || (ssidlength > 32)) >- return 0; >- >- F(password, ssid, ssidlength, 4096, 1, output); >- F(password, ssid, ssidlength, 4096, 2, &output[SHA_DIGEST_LEN]); >- return 1; >-} >- >- >diff -ruN rt2570-1.1.0-b1/Module/mlme.c rt2570-cvs-2005122616/Module/mlme.c >--- rt2570-1.1.0-b1/Module/mlme.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/mlme.c 2005-12-02 06:55:15.000000000 -0600 >@@ -31,6 +31,7 @@ > * Name Date Modification logs > * Jan Lee 2005-06-01 Release > * MathiasK 09-07-2005 kmalloc ATOMIC fixes >+ * RobinC 31-08-2005 Block mlme in MONITOR mode to keep from sending probe requests > ***************************************************************************/ > > #include "rt_config.h" >@@ -368,7 +369,7 @@ > break; > } > //From message type, determine which state machine I should drive >- if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) >+ if (MlmeDequeue(&pAd->Mlme.Queue, &Elem) && pAd->PortCfg.BssType!=BSS_MONITOR) > { > // if dequeue success > switch (Elem->Machine) >@@ -1083,7 +1084,7 @@ > Csr18.field.Offset = (temp & 0x000F); > Csr18.field.Interval = (temp >> 6); > RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >+ DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); > > pAd->BeaconIntervalChangeAllowed = FALSE; > } >@@ -1093,7 +1094,7 @@ > Csr18.field.Offset = (temp & 0x000F); > Csr18.field.Interval = (temp >> 6); > RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >+ DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); > > pAd->BeaconIntervalChangeAllowed = FALSE; > } >@@ -1103,7 +1104,7 @@ > Csr18.field.Offset = (temp & 0x000F); > Csr18.field.Interval = (temp >> 6); > RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >+ DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); > > pAd->BeaconIntervalChangeAllowed = FALSE; > } >@@ -1114,7 +1115,7 @@ > Csr18.field.Offset = (temp & 0x000F); > Csr18.field.Interval = (temp >> 6); > RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_TRACE, ("TXRX_CSR18 = 0x%x\n", Csr18.value)); >+ DBGPRINT(RT_DEBUG_TRACE, ("TXRX_CSR18 = 0x%x\n", Csr18.value)); > > pAd->BeaconIntervalChangeAllowed = FALSE; > } >@@ -1123,7 +1124,7 @@ > #if 0 > else if (pAd->ReceivedBeaconsCount > 9 * pAd->SentBeaconsCount) > { >- DBGPRINT_RAW(RT_DEBUG_TRACE, ("Do Nothing\n")); >+ DBGPRINT(RT_DEBUG_TRACE, ("Do Nothing\n")); > } > #endif > else >@@ -1132,7 +1133,7 @@ > Csr18.field.Offset = (temp & 0x000F); > Csr18.field.Interval = (temp >> 6); > RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >+ DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); > > pAd->BeaconIntervalChangeAllowed = TRUE; > } >@@ -1309,11 +1310,11 @@ > > if (pAd->DrsCounters.fNoisyEnvironment) > { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS(noisy):"); >+ DBGPRINT(RT_DEBUG_TRACE,"DRS(noisy): "); > } > else > { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS:"); >+ DBGPRINT(RT_DEBUG_TRACE,"DRS: "); > } > DBGPRINT_RAW(RT_DEBUG_TRACE,"Qty[%d]=%d PER=%d%% %d-sec, Qty[%d]=%d, Pty=%d\n", > RateIdToMbps[CurrRate], pAd->DrsCounters.TxQuality[CurrRate], >@@ -1401,7 +1402,7 @@ > // if rate-up happen, clear all bad history of all TX rates > if (pAd->PortCfg.TxRate > CurrRate) > { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS: ++TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); >+ DBGPRINT(RT_DEBUG_TRACE,"DRS: ++TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); > pAd->DrsCounters.CurrTxRateStableTime = 0; > pAd->DrsCounters.TxRateUpPenalty = 0; > pAd->DrsCounters.LastSecTxRateChangeAction = 1; // rate UP >@@ -1411,7 +1412,7 @@ > // if rate-down happen, only clear DownRate's bad history > else if (pAd->PortCfg.TxRate < CurrRate) > { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS: --TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); >+ DBGPRINT(RT_DEBUG_TRACE,"DRS: --TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); > // shorter stable time require more penalty in next rate UP criteria > if (pAd->DrsCounters.CurrTxRateStableTime < 4) // less then 4 sec > pAd->DrsCounters.TxRateUpPenalty = DRS_PENALTY; // add 8 sec penalty >@@ -1775,11 +1776,11 @@ > RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); > DBGPRINT(RT_DEBUG_ERROR, "4Set fRTMP_ADAPTER_RADIO_OFF "); > } >- DBGPRINT_RAW(RT_DEBUG_TEMP," MlmeRadioOff \n" ); >+ DBGPRINT_RAW(RT_DEBUG_TEMP,"MlmeRadioOff \n"); > RTUSBRejectPendingPackets(pAd);//reject all NDIS packets waiting in TX queue > RTUSBCleanUpDataBulkOutQueue(pAd); > MlmeSuspend(pAd); >- DBGPRINT_RAW(RT_DEBUG_TEMP," 2MlmeRadioOff \n" ); >+ DBGPRINT_RAW(RT_DEBUG_TEMP,"2MlmeRadioOff \n"); > // Abort Tx > // Disable Rx > RTUSBWriteMACRegister(pAd, TXRX_CSR2, 1); >@@ -1788,7 +1789,7 @@ > { > if (atomic_read(&pAd->PendingRx) > 0) > { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "BulkIn IRP Pending!!!\n"); >+ DBGPRINT(RT_DEBUG_TRACE, "BulkIn IRP Pending!!!\n"); > RTUSB_VendorRequest(pAd, > 0, > DEVICE_VENDOR_REQUEST_OUT, >@@ -1801,7 +1802,7 @@ > > if (pAd->BulkOutPending == TRUE) > { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "BulkOut IRP Pending!!!\n"); >+ DBGPRINT(RT_DEBUG_TRACE, "BulkOut IRP Pending!!!\n"); > if (i == 0) > { > RTUSBCancelPendingBulkOutIRP(pAd); >@@ -1824,7 +1825,7 @@ > > // Clean up old bss table > BssTableInit(&pAd->PortCfg.BssTab); >- DBGPRINT_RAW(RT_DEBUG_TEMP," <==MlmeRadioOff \n" ); >+ DBGPRINT(RT_DEBUG_TEMP,"<==MlmeRadioOff \n" ); > #endif > } > >@@ -2727,7 +2728,11 @@ > INT Tail; > MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue; > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (pAd->MLMEThr_pid > 0) >+#else >+ if (pAd->MLMEThr_active) >+#endif > { > > if (MlmeQueueFull(Queue)) >@@ -2783,8 +2788,13 @@ > ULONG MsgType; > > //DBGPRINT(RT_DEBUG_ERROR,"MlmeEnqueueForRecv "); >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if((pAd->MLMEThr_pid <= 0)) > return FALSE; >+#else >+ if(!pAd->MLMEThr_active) >+ return FALSE; >+#endif > // First check the size, it MUST not exceed the mlme queue size > if (MsgLen > MAX_LEN_OF_MLME_BUFFER) > { >diff -ruN rt2570-1.1.0-b1/Module/.#mlme.c.1.4 rt2570-cvs-2005122616/Module/.#mlme.c.1.4 >--- rt2570-1.1.0-b1/Module/.#mlme.c.1.4 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#mlme.c.1.4 1969-12-31 18:00:00.000000000 -0600 >@@ -1,4497 +0,0 @@ >-/*************************************************************************** >- * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net * >- * * >- * 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. * >- * * >- * Licensed under the GNU GPL * >- * Original code supplied under license from RaLink Inc, 2004. * >- ***************************************************************************/ >- >-/*************************************************************************** >- * Module Name: mlme.c >- * >- * Abstract: >- * >- * Revision History: >- * Who When What >- * -------- ---------- ------------------------------- >- * Name Date Modification logs >- * Jan Lee 2005-06-01 Release >- * MathiasK 09-07-2005 kmalloc ATOMIC fixes >- ***************************************************************************/ >- >-#include "rt_config.h" >- // 1 2 5.5 11 6 9 12 18 24 36 48 54 72 100 >-CHAR RssiSafeLevelForTxRate[] ={ -92, -91, -90, -87, -88, -86, -85, -83, -81, -78, -72, -71, -40, -40 }; >- >- // 1 2 5.5 11 >-UCHAR Phy11BNextRateDownward[] = {RATE_1, RATE_1, RATE_2, RATE_5_5}; >-UCHAR Phy11BNextRateUpward[] = {RATE_2, RATE_5_5, RATE_11, RATE_11}; >- >- // 1 2 5.5 11 6 9 12 18 24 36 48 54 >-UCHAR Phy11BGNextRateDownward[]= {RATE_1, RATE_1, RATE_2, RATE_5_5,RATE_11, RATE_6, RATE_11, RATE_12, RATE_18, RATE_24, RATE_36, RATE_48}; >-UCHAR Phy11BGNextRateUpward[] = {RATE_2, RATE_5_5, RATE_11, RATE_12, RATE_9, RATE_12, RATE_18, RATE_24, RATE_36, RATE_48, RATE_54, RATE_54}; >- >- // 1 2 5.5 11 6 9 12 18 24 36 48 54 >-UCHAR Phy11ANextRateDownward[] = {RATE_6, RATE_6, RATE_6, RATE_6, RATE_6, RATE_6, RATE_9, RATE_12, RATE_18, RATE_24, RATE_36, RATE_48}; >-UCHAR Phy11ANextRateUpward[] = {RATE_9, RATE_9, RATE_9, RATE_9, RATE_9, RATE_12, RATE_18, RATE_24, RATE_36, RATE_48, RATE_54, RATE_54}; >- >-// 2560D and after has implemented ASIC-based OFDM rate switching, but not >-// 2560C and before. thus software use different PER for rate switching >-// RATE_1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 >-USHORT NewRateUpPER[] = { 40, 40, 35, 20, 20, 20, 20, 16, 10, 16, 10, 6 }; // in percentage >-USHORT NewRateDownPER[] = { 50, 50, 45, 45, 35, 35, 35, 35, 25, 25, 25, 13 }; // in percentage >- >-USHORT OldRateUpPER[] = { 40, 40, 40, 40, 30, 30, 30, 30, 20, 20, 10, 10 }; // in percentage >-USHORT OldRateDownPER[] = { 45, 45, 45, 45, 35, 35, 35, 35, 25, 25, 25, 12 }; // in percentage >- >-UCHAR RateIdToMbps[] = { 1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 72, 100}; >-USHORT RateIdTo500Kbps[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 144, 200}; >- >-RTMP_RF_REGS RF2522RegTable[] = { >-// ch R1 R2 R3(TX0~4=0) R4 >- {1, 0x94002050, 0x940c1fda, 0x94000101, 0}, >- {2, 0x94002050, 0x940c1fee, 0x94000101, 0}, >- {3, 0x94002050, 0x940c2002, 0x94000101, 0}, >- {4, 0x94002050, 0x940c2016, 0x94000101, 0}, >- {5, 0x94002050, 0x940c202a, 0x94000101, 0}, >- {6, 0x94002050, 0x940c203e, 0x94000101, 0}, >- {7, 0x94002050, 0x940c2052, 0x94000101, 0}, >- {8, 0x94002050, 0x940c2066, 0x94000101, 0}, >- {9, 0x94002050, 0x940c207a, 0x94000101, 0}, >- {10, 0x94002050, 0x940c208e, 0x94000101, 0}, >- {11, 0x94002050, 0x940c20a2, 0x94000101, 0}, >- {12, 0x94002050, 0x940c20b6, 0x94000101, 0}, >- {13, 0x94002050, 0x940c20ca, 0x94000101, 0}, >- {14, 0x94002050, 0x940c20fa, 0x94000101, 0} >-}; >-#define NUM_OF_2522_CHNL (sizeof(RF2522RegTable) / sizeof(RTMP_RF_REGS)) >- >-RTMP_RF_REGS RF2523RegTable[] = { >-// ch R1 R2 R3(TX0~4=0) R4 >- {1, 0x94022010, 0x94000c9e, 0x940e0111, 0x94000a1b}, >- {2, 0x94022010, 0x94000ca2, 0x940e0111, 0x94000a1b}, >- {3, 0x94022010, 0x94000ca6, 0x940e0111, 0x94000a1b}, >- {4, 0x94022010, 0x94000caa, 0x940e0111, 0x94000a1b}, >- {5, 0x94022010, 0x94000cae, 0x940e0111, 0x94000a1b}, >- {6, 0x94022010, 0x94000cb2, 0x940e0111, 0x94000a1b}, >- {7, 0x94022010, 0x94000cb6, 0x940e0111, 0x94000a1b}, >- {8, 0x94022010, 0x94000cba, 0x940e0111, 0x94000a1b}, >- {9, 0x94022010, 0x94000cbe, 0x940e0111, 0x94000a1b}, >- {10, 0x94022010, 0x94000d02, 0x940e0111, 0x94000a1b}, >- {11, 0x94022010, 0x94000d06, 0x940e0111, 0x94000a1b}, >- {12, 0x94022010, 0x94000d0a, 0x940e0111, 0x94000a1b}, >- {13, 0x94022010, 0x94000d0e, 0x940e0111, 0x94000a1b}, >- {14, 0x94022010, 0x94000d1a, 0x940e0111, 0x94000a03} >-}; >-#define NUM_OF_2523_CHNL (sizeof(RF2523RegTable) / sizeof(RTMP_RF_REGS)) >- >-RTMP_RF_REGS RF2524RegTable[] = { >-// ch R1 R2 R3(TX0~4=0) R4 >- {1, 0x94032020, 0x94000c9e, 0x94000101, 0x94000a1b}, >- {2, 0x94032020, 0x94000ca2, 0x94000101, 0x94000a1b}, >- {3, 0x94032020, 0x94000ca6, 0x94000101, 0x94000a1b}, >- {4, 0x94032020, 0x94000caa, 0x94000101, 0x94000a1b}, >- {5, 0x94032020, 0x94000cae, 0x94000101, 0x94000a1b}, >- {6, 0x94032020, 0x94000cb2, 0x94000101, 0x94000a1b}, >- {7, 0x94032020, 0x94000cb6, 0x94000101, 0x94000a1b}, >- {8, 0x94032020, 0x94000cba, 0x94000101, 0x94000a1b}, >- {9, 0x94032020, 0x94000cbe, 0x94000101, 0x94000a1b}, >- {10, 0x94032020, 0x94000d02, 0x94000101, 0x94000a1b}, >- {11, 0x94032020, 0x94000d06, 0x94000101, 0x94000a1b}, >- {12, 0x94032020, 0x94000d0a, 0x94000101, 0x94000a1b}, >- {13, 0x94032020, 0x94000d0e, 0x94000101, 0x94000a1b}, >- {14, 0x94032020, 0x94000d1a, 0x94000101, 0x94000a03} >-}; >-#define NUM_OF_2524_CHNL (sizeof(RF2524RegTable) / sizeof(RTMP_RF_REGS)) >- >-RTMP_RF_REGS_1 RF2525RegTable[] = { >-// ch TempR2 R1 R2 R3(TX0~4=0) R4 >- {1, 0x94080cbe, 0x94022020, 0x94080c9e, 0x94060111, 0x94000a1b}, // {1, 0x94022010, 0x9408062e, 0x94060111, 0x94000a23}, >- {2, 0x94080d02, 0x94022020, 0x94080ca2, 0x94060111, 0x94000a1b}, >- {3, 0x94080d06, 0x94022020, 0x94080ca6, 0x94060111, 0x94000a1b}, >- {4, 0x94080d0a, 0x94022020, 0x94080caa, 0x94060111, 0x94000a1b}, >- {5, 0x94080d0e, 0x94022020, 0x94080cae, 0x94060111, 0x94000a1b}, >- {6, 0x94080d12, 0x94022020, 0x94080cb2, 0x94060111, 0x94000a1b}, >- {7, 0x94080d16, 0x94022020, 0x94080cb6, 0x94060111, 0x94000a1b}, >- {8, 0x94080d1a, 0x94022020, 0x94080cba, 0x94060111, 0x94000a1b}, >- {9, 0x94080d1e, 0x94022020, 0x94080cbe, 0x94060111, 0x94000a1b}, >- {10, 0x94080d22, 0x94022020, 0x94080d02, 0x94060111, 0x94000a1b}, >- {11, 0x94080d26, 0x94022020, 0x94080d06, 0x94060111, 0x94000a1b}, // {11, 0x94022010, 0x94080682, 0x94060111, 0x94000a23}, >- {12, 0x94080d2a, 0x94022020, 0x94080d0a, 0x94060111, 0x94000a1b}, >- {13, 0x94080d2e, 0x94022020, 0x94080d0e, 0x94060111, 0x94000a1b}, // {13, 0x94022010, 0x94080686, 0x94060111, 0x94000a23}, >- {14, 0x94080d3a, 0x94022020, 0x94080d1a, 0x94060111, 0x94000a03} >-}; >-#define NUM_OF_2525_CHNL (sizeof(RF2525RegTable) / sizeof(RTMP_RF_REGS_1)) >- >-RTMP_RF_REGS_1 RF2525eRegTable[] = { >-// using 10 Mhz reference clock >-// ch TempR2 R1 R2 R3(TX0~4=0) R4 >- {1, 0x940008aa, 0x94022010, 0x9400089a, 0x94060111, 0x94000e1b}, >- {2, 0x940008ae, 0x94022010, 0x9400089e, 0x94060111, 0x94000e07}, >- {3, 0x940008ae, 0x94022010, 0x9400089e, 0x94060111, 0x94000e1b}, >- {4, 0x940008b2, 0x94022010, 0x940008a2, 0x94060111, 0x94000e07}, >- {5, 0x940008b2, 0x94022010, 0x940008a2, 0x94060111, 0x94000e1b}, >- {6, 0x940008b6, 0x94022010, 0x940008a6, 0x94060111, 0x94000e07}, >- {7, 0x940008b6, 0x94022010, 0x940008a6, 0x94060111, 0x94000e1b}, >- {8, 0x940008ba, 0x94022010, 0x940008aa, 0x94060111, 0x94000e07}, >- {9, 0x940008ba, 0x94022010, 0x940008aa, 0x94060111, 0x94000e1b}, >- {10, 0x940008be, 0x94022010, 0x940008ae, 0x94060111, 0x94000e07}, >- {11, 0x940008b7, 0x94022010, 0x940008ae, 0x94060111, 0x94000e1b}, >- {12, 0x94000902, 0x94022010, 0x940008b2, 0x94060111, 0x94000e07}, >- {13, 0x94000902, 0x94022010, 0x940008b2, 0x94060111, 0x94000e1b}, >- {14, 0x94000906, 0x94022010, 0x940008b6, 0x94060111, 0x94000e23} >-}; >-#define NUM_OF_2525E_CHNL (sizeof(RF2525eRegTable) / sizeof(RTMP_RF_REGS_1)) >- >-RTMP_RF_REGS RF5222RegTable[] = { >-// ch R1 R2 R3(TX0~4=0) R4 >- {1, 0x94022020, 0x94001136, 0x94000101, 0x94000a0b}, >- {2, 0x94022020, 0x9400113a, 0x94000101, 0x94000a0b}, >- {3, 0x94022020, 0x9400113e, 0x94000101, 0x94000a0b}, >- {4, 0x94022020, 0x94001182, 0x94000101, 0x94000a0b}, >- {5, 0x94022020, 0x94001186, 0x94000101, 0x94000a0b}, >- {6, 0x94022020, 0x9400118a, 0x94000101, 0x94000a0b}, >- {7, 0x94022020, 0x9400118e, 0x94000101, 0x94000a0b}, >- {8, 0x94022020, 0x94001192, 0x94000101, 0x94000a0b}, >- {9, 0x94022020, 0x94001196, 0x94000101, 0x94000a0b}, >- {10, 0x94022020, 0x9400119a, 0x94000101, 0x94000a0b}, >- {11, 0x94022020, 0x9400119e, 0x94000101, 0x94000a0b}, >- {12, 0x94022020, 0x940011a2, 0x94000101, 0x94000a0b}, >- {13, 0x94022020, 0x940011a6, 0x94000101, 0x94000a0b}, >- {14, 0x94022020, 0x940011ae, 0x94000101, 0x94000a1b}, >- >- // still lack of MMAC(Japan) ch 34,38,42,46 >- >- {36, 0x94022010, 0x94018896, 0x94000101, 0x94000a1f}, >- {40, 0x94022010, 0x9401889a, 0x94000101, 0x94000a1f}, >- {44, 0x94022010, 0x9401889e, 0x94000101, 0x94000a1f}, >- {48, 0x94022010, 0x940188a2, 0x94000101, 0x94000a1f}, >- {52, 0x94022010, 0x940188a6, 0x94000101, 0x94000a1f}, >- {66, 0x94022010, 0x940188aa, 0x94000101, 0x94000a1f}, >- {60, 0x94022010, 0x940188ae, 0x94000101, 0x94000a1f}, >- {64, 0x94022010, 0x940188b2, 0x94000101, 0x94000a1f}, >- >- {100, 0x94022010, 0x94008802, 0x94000101, 0x94000a0f}, >- {104, 0x94022010, 0x94008806, 0x94000101, 0x94000a0f}, >- {108, 0x94022010, 0x9400880a, 0x94000101, 0x94000a0f}, >- {112, 0x94022010, 0x9400880e, 0x94000101, 0x94000a0f}, >- {116, 0x94022010, 0x94008812, 0x94000101, 0x94000a0f}, >- {120, 0x94022010, 0x94008816, 0x94000101, 0x94000a0f}, >- {124, 0x94022010, 0x9400881a, 0x94000101, 0x94000a0f}, >- {128, 0x94022010, 0x9400881e, 0x94000101, 0x94000a0f}, >- {132, 0x94022010, 0x94008822, 0x94000101, 0x94000a0f}, >- {136, 0x94022010, 0x94008826, 0x94000101, 0x94000a0f}, >- {140, 0x94022010, 0x9400882a, 0x94000101, 0x94000a0f}, >- >- {149, 0x94022020, 0x940090a6, 0x94000101, 0x94000a07}, >- {153, 0x94022020, 0x940090ae, 0x94000101, 0x94000a07}, >- {157, 0x94022020, 0x940090b6, 0x94000101, 0x94000a07}, >- {161, 0x94022020, 0x940090be, 0x94000101, 0x94000a07} >-}; >-#define NUM_OF_5222_CHNL (sizeof(RF5222RegTable) / sizeof(RTMP_RF_REGS)) >- >- >-/* >- ========================================================================== >- Description: >- initialize the MLME task and its data structure (queue, spinlock, >- timer, state machines). >- Return: >- always return NDIS_STATUS_SUCCESS >- ========================================================================== >-*/ >-NDIS_STATUS MlmeInit( >- IN PRT2570ADAPTER pAd) >-{ >- NDIS_STATUS Status = NDIS_STATUS_SUCCESS; >- >- DBGPRINT(RT_DEBUG_TRACE,"--> MLME Initialize\n"); >- >- do >- { >- Status = MlmeQueueInit(&pAd->Mlme.Queue); >- if(Status != NDIS_STATUS_SUCCESS) >- { >- break; >- } >- >- // Initialize Mlme Memory Handler >- // Allocate 20 nonpaged memory pool which size are MAX_LEN_OF_MLME_BUFFER for use >- Status = MlmeInitMemoryHandler(pAd, 20, MAX_LEN_OF_MLME_BUFFER); >- >- if(Status != NDIS_STATUS_SUCCESS) >- { >- break; >- } >- >- pAd->Mlme.Running = FALSE; >- NdisAllocateSpinLock(&pAd->Mlme.TaskLock); >- >- // initialize the two tables >- // MacTableInit(pAd); >- BssTableInit(&pAd->PortCfg.BssTab); >- // init state machines >- ASSERT(ASSOC_FUNC_SIZE == MAX_ASSOC_MSG * MAX_ASSOC_STATE); >- AssocStateMachineInit(pAd, &pAd->Mlme.AssocMachine, pAd->Mlme.AssocFunc); >- >- ASSERT(AUTH_FUNC_SIZE == MAX_AUTH_MSG * MAX_AUTH_STATE); >- AuthStateMachineInit(pAd, &pAd->Mlme.AuthMachine, pAd->Mlme.AuthFunc); >- >- ASSERT(AUTH_RSP_FUNC_SIZE == MAX_AUTH_RSP_MSG * MAX_AUTH_RSP_STATE); >- AuthRspStateMachineInit(pAd, &pAd->Mlme.AuthRspMachine, pAd->Mlme.AuthRspFunc); >- >- ASSERT(WPA_PSK_FUNC_SIZE == MAX_WPA_PSK_MSG * MAX_WPA_PSK_STATE); >- WpaPskStateMachineInit(pAd,&pAd->Mlme.WpaPskMachine,pAd->Mlme.WpaPskFunc); >- >- ASSERT(SYNC_FUNC_SIZE == MAX_SYNC_MSG * MAX_SYNC_STATE); >- SyncStateMachineInit(pAd, &pAd->Mlme.SyncMachine, pAd->Mlme.SyncFunc); >- >- // Since we are using switch/case to implement it, the init is different from the above >- // state machine init >- MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL); >- >- RTMPInitTimer(pAd, &pAd->Mlme.PeriodicTimer, &MlmePeriodicExec); >- //pAd->Mlme.PeriodicTimer.data = (unsigned long)pAd; >- //pAd->Mlme.PeriodicTimer.function = &MlmePeriodicExec; >- pAd->Mlme.PeriodicTimer.Timer.expires = jiffies + MLME_TASK_EXEC_INTV; >- // delay first mlme timer >- RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, 2*MLME_TASK_EXEC_INTV); >- >- if (pAd->PortCfg.LedMode == LED_MODE_TXRX_ACTIVITY) >- { >- RTMPInitTimer(pAd, &pAd->PortCfg.LedCntl.BlinkTimer, &AsicLedPeriodicExec); >- //pAd->PortCfg.LedCntl.BlinkTimer.data = (unsigned long)pAd; >- //pAd->PortCfg.LedCntl.BlinkTimer.function = &AsicLedPeriodicExec; >- pAd->PortCfg.LedCntl.BlinkTimer.Timer.expires = jiffies + (70 * HZ)/1000; >- RTMPSetTimer(pAd, &pAd->PortCfg.LedCntl.BlinkTimer, 70); >- } >- >- } while (FALSE); >- >- DBGPRINT(RT_DEBUG_TRACE,"<-- MLME Initialize\n"); >- >- return Status; >-} >- >- >-/* >- ========================================================================== >- Description: >- Destructor of MLME (Destroy queue, state machine, spin lock and timer) >- Parameters: >- Adapter - NIC Adapter pointer >- Post: >- The MLME task will no longer work properly >- >- IRQL = PASSIVE_LEVEL >- >- ========================================================================== >- */ >-VOID MlmeHalt( >- IN PRT2570ADAPTER pAd) >-{ >- >- DBGPRINT(RT_DEBUG_TRACE, "==> MlmeHalt\n"); >- >- // Cancel pending timers >- RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.DisassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer); >- RTMPCancelTimer(&pAd->Mlme.PeriodicTimer); >- if ((pAd->PortCfg.LedMode == LED_MODE_TXRX_ACTIVITY)||(pAd->PortCfg.LedMode == LED_MODE_ALPHA)) >- RTMPCancelTimer(&pAd->PortCfg.LedCntl.BlinkTimer); >- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)) >- { >- ASIC_LED_ACT_OFF(pAd); >- } >- >- // for timer callback routine to finish. >- NdisMSleep(1000); >- >- MlmeQueueDestroy(&pAd->Mlme.Queue); >- StateMachineDestroy(&pAd->Mlme.AssocMachine); >- StateMachineDestroy(&pAd->Mlme.AuthMachine); >- StateMachineDestroy(&pAd->Mlme.AuthRspMachine); >- StateMachineDestroy(&pAd->Mlme.SyncMachine); >- StateMachineDestroy(&pAd->Mlme.WpaPskMachine); >- // StateMachineDestroy(&pAd->Mlme.CntlMachine); >- // no need free spinlock of pAd->Mlme.TaskLock >- >- MlmeFreeMemoryHandler(pAd); //Free MLME memory handler >- >- DBGPRINT(RT_DEBUG_TRACE, "<== MlmeHalt\n"); >-} >- >-VOID MlmeHandler( >- IN PRT2570ADAPTER pAd) >-{ >- MLME_QUEUE_ELEM *Elem = NULL; >- // Only accept MLME and Frame from peer side, no other (control/data) frame should >- // get into this state machine >- >- NdisAcquireSpinLock(&pAd->Mlme.TaskLock); >- if(pAd->Mlme.Running) >- { >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- return; >- } >- else >- { >- pAd->Mlme.Running = TRUE; >- } >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- >- while (!MlmeQueueEmpty(&pAd->Mlme.Queue)) >- { >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS) || >- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) || >- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "Device Halted or Removed or MlmeRest, exit MlmeHandler! (queue num = %d)\n", pAd->Mlme.Queue.Num); >- break; >- } >- //From message type, determine which state machine I should drive >- if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) >- { >- // if dequeue success >- switch (Elem->Machine) >- { >- case ASSOC_STATE_MACHINE: >- StateMachinePerformAction(pAd, &pAd->Mlme.AssocMachine, Elem); >- break; >- case AUTH_STATE_MACHINE: >- StateMachinePerformAction(pAd, &pAd->Mlme.AuthMachine, Elem); >- break; >- case AUTH_RSP_STATE_MACHINE: >- StateMachinePerformAction(pAd, &pAd->Mlme.AuthRspMachine, Elem); >- break; >- case SYNC_STATE_MACHINE: >- StateMachinePerformAction(pAd, &pAd->Mlme.SyncMachine, Elem); >- break; >- case MLME_CNTL_STATE_MACHINE: >- MlmeCntlMachinePerformAction(pAd, &pAd->Mlme.CntlMachine, Elem); >- break; >- case WPA_PSK_STATE_MACHINE: >- StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem); >- break; >- default: >- DBGPRINT(RT_DEBUG_TRACE, "ERROR: Illegal machine %d in MlmeHandler()\n",Elem->Machine); >- break; >- } // end of switch >- >- // free MLME element >- Elem->Occupied = FALSE; >- Elem->MsgLen = 0; >- >- } >- else >- { >- DBGPRINT(RT_DEBUG_ERROR, "ERROR: empty Elem in MlmeQueue\n"); >- } >- } >- >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "MlmeHandler, Reset Mlme! (queue num = %d)\n", pAd->Mlme.Queue.Num); >- MlmeQueueDestroy(&pAd->Mlme.Queue); >- // Cancel all timer events >- // Be careful to cancel new added timer >- RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.DisassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer); >- // RTMPCancelTimer(&pAd->Mlme.AuthRspAux.AuthRspTimer, &Cancelled); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer); >- // Set all state machines back IDLE >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE; >- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE; >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS); >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS); >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS); >- } >- >- NdisAcquireSpinLock(&pAd->Mlme.TaskLock); >- pAd->Mlme.Running = FALSE; >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- >-} >- >- >-VOID MlmeSuspend( >- IN PRT2570ADAPTER pAd) >-{ >- MLME_QUEUE_ELEM *Elem = NULL; >- >- DBGPRINT(RT_DEBUG_TRACE, "==>MlmeSuspend\n"); >- >- // Cancel pending timers >- RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.DisassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer); >- // RTMPCancelTimer(&pAd->Mlme.AuthRspAux.AuthRspTimer, &Cancelled); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer); >- >- NdisAcquireSpinLock(&pAd->Mlme.TaskLock); >- if(pAd->Mlme.Running) >- { >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- return; >- } >- else >- { >- pAd->Mlme.Running = TRUE; >- } >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- >- // Remove all Mlme queues elements >- while (!MlmeQueueEmpty(&pAd->Mlme.Queue)) >- { >- //From message type, determine which state machine I should drive >- if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) >- { >- // free MLME element >- Elem->Occupied = FALSE; >- Elem->MsgLen = 0; >- >- } >- else >- { >- DBGPRINT(RT_DEBUG_ERROR, "ERROR: empty Elem in MlmeQueue\n"); >- } >- } >- >- // Remove running state >- NdisAcquireSpinLock(&pAd->Mlme.TaskLock); >- pAd->Mlme.Running = FALSE; >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- >- RTUSBCleanUpMLMEWaitQueue(pAd); >- RTUSBCleanUpMLMEBulkOutQueue(pAd); >- >- // Set all state machines back IDLE >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE; >- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE; >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS);//steven:for test >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);//steven:for test >- >- DBGPRINT(RT_DEBUG_TRACE, "<==MlmeSuspend\n"); >-} >- >-VOID MlmeResume( >- IN PRT2570ADAPTER pAd) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "==>MlmeResume\n"); >- >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS);//steven:for test >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);//steven:for test >- // Set all state machines back IDLE >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE; >- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE; >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- >- DBGPRINT(RT_DEBUG_TRACE, "<==MlmeResume\n"); >-} >- >-/* >- ========================================================================== >- Description: >- This routine is executed periodically to - >- 1. Decide if it's a right time to turn on PwrMgmt bit of all >- outgoiing frames >- 2. Calculate ChannelQuality based on statistics of the last >- period, so that TX rate won't toggling very frequently between a >- successful TX and a failed TX. >- 3. If the calculated ChannelQuality indicated current connection not >- healthy, then a ROAMing attempt is tried here. >- >- IRQL = DISPATCH_LEVEL >- >- ========================================================================== >- */ >-#define ADHOC_BEACON_LOST_TIME 10000 // 10 sec >-VOID MlmePeriodicExec( >- IN unsigned long data) >-{ >- PRT2570ADAPTER pAd = (PRT2570ADAPTER)data; >- ULONG Now32; >- // Timer need to reset every time, so using do-while loop >- 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_MLME_RESET_IN_PROGRESS)) || >- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "<---MlmePeriodicExec\n"); >- break; >- } >- >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_PENDING)) >- { >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_PENDING); >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"); >- } >- >- if (pAd->PortCfg.bHardwareRadio == TRUE) >- { >- RTUSBEnqueueInternalCmd(pAd, RT_OID_CHECK_GPIO); >- } >- >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "<---RADIO OFF\n"); >- break; >- } >- >- if (pAd->RalinkCounters.MgmtRingFullCount >= 2) >- { >- PCmdQElmt cmdqelmt; >- >- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS); >- >- NdisAcquireSpinLock(&pAd->CmdQLock); >- while (pAd->CmdQ.size > 0) >- { >- RTUSBDequeueCmd(&pAd->CmdQ, &cmdqelmt); >- if (cmdqelmt->CmdFromNdis == TRUE) >- { >- if ((cmdqelmt->command != OID_802_11_BSSID_LIST_SCAN) && >- (cmdqelmt->command != RT_OID_802_11_BSSID) && >- (cmdqelmt->command != OID_802_11_SSID) && >- (cmdqelmt->command != OID_802_11_DISASSOCIATE)) >- { >-#if 0 >- if (cmdqelmt->SetOperation) >- NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_NOT_ACCEPTED); >- else >- NdisMQueryInformationComplete(pAd->AdapterHandle, NDIS_STATUS_NOT_ACCEPTED); >-#endif >- } >- >- if ((cmdqelmt->command != RT_OID_SINGLE_READ_MAC) && >- (cmdqelmt->command != RT_OID_MULTI_READ_MAC) && >- (cmdqelmt->command != RT_OID_VENDOR_READ_BBP) && >- (cmdqelmt->command != RT_OID_USB_VENDOR_EEPROM_READ)) >- { >- if (cmdqelmt->buffer != NULL) >- kfree(cmdqelmt->buffer); >- } >- >- kfree(cmdqelmt); >- } >- else >- cmdqelmt->InUse = FALSE; >- } >- NdisReleaseSpinLock(&pAd->CmdQLock); >- >- RTUSBEnqueueInternalCmd(pAd, RT_OID_RESET_FROM_ERROR); >- >- DBGPRINT_RAW(RT_DEBUG_ERROR, "<---MlmePeriodicExec (Mgmt Ring Full)\n"); >- break; >- } >- pAd->RalinkCounters.MgmtRingFullCount = 0; >- >- if ((RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS))) >- { >- break;//steven:for test >- } >- pAd->Mlme.PeriodicRound ++; >- RTUSBEnqueueInternalCmd(pAd, RT_OID_PERIODIC_EXECUT); >- Now32 = jiffies; >- if (INFRA_ON(pAd)) >- { >- // Check for EAPOL frame sent after MIC countermeasures >- if (pAd->PortCfg.MicErrCnt >= 3) >- { >- MLME_DISASSOC_REQ_STRUCT DisassocReq; >- >- // disassoc from current AP first >- DBGPRINT(RT_DEBUG_TRACE, "MLME - disassociate with current AP after sending second continuous EAPOL frame\n"); >- DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.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->PortCfg.bBlockAssoc = TRUE; >- } >- else if ((pAd->PortCfg.LastBeaconRxTime + BEACON_LOST_TIME < Now32) ) >- { >- DBGPRINT(RT_DEBUG_TRACE, "BEACON lost for more than %d msec, let CQI = 0\n", BEACON_LOST_TIME); >- pAd->Mlme.ChannelQuality = 0; >- >- // Lost AP, send disconnect & link down event >- RTUSBEnqueueInternalCmd(pAd, RT_OID_LINK_DOWN); >- } >- else >- { >- atomic_set(&(pAd->PortCfg.DataPacketsFromAP), 0); >- MlmeCheckForPsmChange(pAd); >- } >- } >- else if (ADHOC_ON(pAd)) >- { >- // If all peers leave, and this STA becomes the last one in this IBSS, then change MediaState >- // to DISCONNECTED. But still holding this IBSS (i.e. sending BEACON) so that other STAs can >- // join later. >- if ((pAd->PortCfg.LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < Now32) && >- (pAd->MediaState == NdisMediaStateConnected)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n"); >- >- pAd->MediaState = NdisMediaStateDisconnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- >- // clean up previous SCAN result, add current BSS back to table if any >- BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid)); >- pAd->PortCfg.LastScanTime = Now32; >- } >- else >- { >- // if all 11b peers leave this BSS more than 5 seconds, update Tx rate >- if ((pAd->PortCfg.Channel <= 14) && >- (pAd->PortCfg.MaxTxRate <= RATE_11) && >- (pAd->PortCfg.MaxDesiredRate > RATE_11) && >- ((pAd->PortCfg.Last11bBeaconRxTime + 5000) < Now32)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "last 11B peer left, update Tx rates\n"); >- >- NdisMoveMemory(pAd->PortCfg.SupportedRates, pAd->PortCfg.IbssConfig.SupportedRates, MAX_LEN_OF_SUPPORTED_RATES); >- pAd->PortCfg.SupportedRatesLen = pAd->PortCfg.IbssConfig.SupportedRatesLen; >- RTUSBEnqueueInternalCmd(pAd, RT_OID_UPDATE_TX_RATE); >- } >- } >- } >- else >- { >- if ((pAd->PortCfg.bBlockAssoc == TRUE) && (pAd->PortCfg.LastMicErrorTime + (60 * 1000) < Now32)) >- { >- pAd->PortCfg.bBlockAssoc = FALSE; >- } >- >- if ((pAd->PortCfg.AutoReconnect == TRUE) && >- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) && >- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS)) && >- (MlmeValidateSSID(pAd) == TRUE)) >- { >- if (pAd->PortCfg.BssTab.BssNr==0) >- { >- MLME_SCAN_REQ_STRUCT ScanReq; >- CHAR BroadSsid[MAX_LEN_OF_SSID]; >- >- if ((pAd->PortCfg.LastScanTime + 10 * 1000) < Now32) >- { >- DBGPRINT(RT_DEBUG_TRACE, "CNTL - No matching BSS, start a new scan\n"); >- // BroadSsid[0] = '\0'; >- ScanParmFill(pAd, &ScanReq, BroadSsid, 0, 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->PortCfg.IgnoredScanNumber = 0; >- pAd->PortCfg.LastScanTime = Now32; >- } >- else if (pAd->PortCfg.BssType == BSS_INDEP) // Quit the forever scan when in a very clean room >- MlmeAutoReconnectLastSSID(pAd); >- } >- else >- { >- if ((pAd->Mlme.PeriodicRound % 10) == 7) >- { >- if ((pAd->PortCfg.LastScanTime + 10 * 1000) < Now32) >- { >- //MlmeAutoScan(pAd); >- pAd->PortCfg.LastScanTime = Now32; >- } >- MlmeAutoReconnectLastSSID(pAd); >- } >- else if ((pAd->Mlme.PeriodicRound % 30) == 8) >- { >- MlmeEnqueue(pAd, >- MLME_CNTL_STATE_MACHINE, >- OID_802_11_BSSID_LIST_SCAN, >- 0, >- NULL); >- } >- >- } >- } >- } >- >- RTUSBUp(pAd, (&(pAd->mlme_semaphore))); >- }while(0); >- >- 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_REMOVE_IN_PROGRESS))) >- { >- RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV); >- } >- >-} >- >-// IRQL = DISPATCH_LEVEL >-VOID MlmeAutoScan( >- IN PRT2570ADAPTER pAd) >-{ >- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request >- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) >- { >- DBGPRINT(RT_DEBUG_TRACE, "MMCHK - Driver auto scan\n"); >- >- // tell CNTL state machine NOT to call NdisMSetInformationComplete() after completing >- // this request, because this request is initiated by driver itself. >- pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE; >- MlmeEnqueue(pAd, >- MLME_CNTL_STATE_MACHINE, >- OID_802_11_BSSID_LIST_SCAN, >- 0, >- NULL); >- RTUSBUp(pAd, &pAd->mlme_semaphore); >- } >-} >-// IRQL = DISPATCH_LEVEL >-VOID MlmeAutoRecoverNetwork( >- IN PRT2570ADAPTER pAd) >-{ >- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request >- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) >- { >- NDIS_802_11_SSID OidSsid; >- OidSsid.SsidLength = pAd->PortCfg.SsidLen; >- NdisMoveMemory(OidSsid.Ssid, pAd->PortCfg.Ssid, pAd->PortCfg.SsidLen); >- >- DBGPRINT(RT_DEBUG_TRACE, "MMCHK - Driver auto recovering network - %s\n", pAd->PortCfg.Ssid); >- >- // tell CNTL state machine NOT to call NdisMSetInformationComplete() after completing >- // this request, because this request is initiated by driver itself. >- pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE; >- >- MlmeEnqueue(pAd, >- MLME_CNTL_STATE_MACHINE, >- OID_802_11_SSID, >- sizeof(NDIS_802_11_SSID), >- &OidSsid); >- RTUSBUp(pAd, (&(pAd->mlme_semaphore))); >- //KeSetEvent(&pAd->MLMEEvent, 0, FALSE); >- } >-} >- >-// IRQL = DISPATCH_LEVEL >-VOID MlmeAutoReconnectLastSSID( >- IN PRT2570ADAPTER pAd) >-{ >- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request >- if ((pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) && (MlmeValidateSSID(pAd) == TRUE)) >- { >- NDIS_802_11_SSID OidSsid; >- OidSsid.SsidLength = pAd->Mlme.CntlAux.SsidLen; >- NdisMoveMemory(OidSsid.Ssid, pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidLen); >- >- DBGPRINT(RT_DEBUG_TRACE, "Driver auto reconnect to last OID_802_11_SSID setting - %s\n", pAd->Mlme.CntlAux.Ssid); >- >- // We will only try this attemp once, therefore change the AutoReconnect flag afterwards. >- pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE; >- >- MlmeEnqueue(pAd, >- MLME_CNTL_STATE_MACHINE, >- OID_802_11_SSID, >- sizeof(NDIS_802_11_SSID), >- &OidSsid); >- >- RTUSBUp(pAd, &pAd->mlme_semaphore); >- >- } >-} >- >-// Validate SSID for connection try and rescan purpose >-// Valid SSID will have visible chars only. >-// The valid length is from 0 to 32. >-// IRQL = DISPATCH_LEVEL >-BOOLEAN MlmeValidateSSID( >- IN PRT2570ADAPTER pAd) >-{ >- NDIS_802_11_SSID OidSsid; >- ULONG index; >- >- // Copy the SSID into local buffer >- OidSsid.SsidLength = pAd->Mlme.CntlAux.SsidLen; >- NdisMoveMemory(OidSsid.Ssid, pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidLen); >- >- // First check the zero length "ANY" SSID >- if (OidSsid.SsidLength == 0) >- return (TRUE); >- else if (OidSsid.SsidLength > NDIS_802_11_LENGTH_SSID) >- return (FALSE); >- >- // Check each character value >- for (index = 0; index < OidSsid.SsidLength; index++) >- { >- if (OidSsid.Ssid[index] < 0x20) >- return (FALSE); >- } >- >- // All checked >- return (TRUE); >-} >- >-/* >- ========================================================================== >- Description: >- This routine checks if there're other APs out there capable for >- roaming. Caller should call this routine only when Massoc=TRUE and >- channel quality is below CQI_GOOD_THRESHOLD. >- >- IRQL = DISPATCH_LEVEL >- >- Output: >- ========================================================================== >- */ >-VOID MlmeCheckForRoaming( >- IN PRT2570ADAPTER pAd, >- IN ULONG Now32) >-{ >- USHORT i; >- BSS_TABLE *pBssTab = &pAd->PortCfg.BssTab; >- BSS_TABLE *pRoamTab = &pAd->Mlme.CntlAux.RoamTab; >- BSS_ENTRY *pBss; >- >- DBGPRINT(RT_DEBUG_TRACE, "==> MlmeCheckForRoaming\n"); >- // put all roaming candidates into RoamTab, and sort in RSSI order >- BssTableInit(pRoamTab); >- for (i = 0; i < pBssTab->BssNr; i++) >- { >- pBss = &pBssTab->BssEntry[i]; >- >- if ((pBssTab->BssEntry[i].LastBeaconRxTime + BEACON_LOST_TIME) < Now32) >- continue; // AP disappear >- if (pBss->Rssi <= RSSI_THRESHOLD_FOR_ROAMING) >- continue; // RSSI too weak. forget it. >- if (MAC_ADDR_EQUAL(&pBssTab->BssEntry[i].Bssid, &pAd->PortCfg.Bssid)) >- continue; // skip current AP >- if (CQI_IS_FAIR(pAd->Mlme.ChannelQuality) && (pAd->PortCfg.LastRssi + RSSI_DELTA > pBss->Rssi)) >- continue; // we're still okay, only AP with stronger RSSI is eligible for roaming >- >- // AP passing all above rules is put into roaming candidate table >- NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY)); >- pRoamTab->BssNr += 1; >- } >- >- if (pRoamTab->BssNr > 0) >- { >- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request >- if ((pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS))) >- { >- // tell CNTL state machine NOT to call NdisMSetInformationComplete() after completing >- // this request, because this request is initiated by driver itself, not from NDIS. >- pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE; >- >- pAd->RalinkCounters.PoorCQIRoamingCount ++; >- DBGPRINT(RT_DEBUG_TRACE, "MMCHK - Roaming attempt #%d\n", pAd->RalinkCounters.PoorCQIRoamingCount); >- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_MLME_ROAMING_REQ, 0, NULL); >- RTUSBUp(pAd, (&(pAd->mlme_semaphore))); >- //KeSetEvent(&pAd->MLMEEvent, 0, FALSE); >- } >- } >- DBGPRINT(RT_DEBUG_TRACE, "<== MlmeCheckForRoaming\n"); >-} >- >-VOID PeriodicExec( >- IN PRT2570ADAPTER pAd) >-{ >- >- USHORT TxFailCount, TxNoRetryCnt, TxOneRetryCnt, TxMRetryCnt, TxRetryOkCount, TxOkCount, TxTotalCnt, TxPER, TxPRR = 0, TxRealOkCount; >- USHORT RxFailCnt; >- ULONG RxOkCnt, RxCnt, RxPER; >- ULONG Now32; >- ULONG OldValue; >- UCHAR UpRate, DownRate, CurrRate; >- >- 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_REMOVE_IN_PROGRESS))) >- { >- DBGPRINT(RT_DEBUG_TRACE, "PeriodicExec not execute! (pAd->Flags=0x%08x)\n", pAd->Flags); >- return ; >- } >- AsicAdjustTxPower(pAd); >- RTUSBMultiReadMAC(pAd, STA_CSR0, (PUCHAR)pAd->MACCounters, 22); >- OldValue = pAd->WlanCounters.FCSErrorCount.vv.LowPart; >- pAd->WlanCounters.FCSErrorCount.vv.LowPart += pAd->MACCounters[0]; >- if (pAd->WlanCounters.FCSErrorCount.vv.LowPart < OldValue) >- { >- pAd->WlanCounters.FCSErrorCount.vv.HighPart++; >- } >- OldValue = pAd->WlanCounters.NoRetryCount.vv.LowPart; >- pAd->WlanCounters.NoRetryCount.vv.LowPart += pAd->MACCounters[6]; >- if (pAd->WlanCounters.NoRetryCount.vv.LowPart < OldValue) >- { >- pAd->WlanCounters.NoRetryCount.vv.HighPart++; >- } >- OldValue = pAd->WlanCounters.RetryCount.vv.LowPart; >- pAd->WlanCounters.RetryCount.vv.LowPart += pAd->MACCounters[7]; >- if (pAd->WlanCounters.RetryCount.vv.LowPart < OldValue) >- { >- pAd->WlanCounters.RetryCount.vv.HighPart++; >- } >- OldValue = pAd->WlanCounters.MultipleRetryCount.vv.LowPart; >- pAd->WlanCounters.MultipleRetryCount.vv.LowPart += pAd->MACCounters[8]; >- if (pAd->WlanCounters.MultipleRetryCount.vv.LowPart < OldValue) >- { >- pAd->WlanCounters.MultipleRetryCount.vv.HighPart++; >- } >- OldValue = pAd->WlanCounters.FailedCount.vv.LowPart; >- pAd->WlanCounters.FailedCount.vv.LowPart += pAd->MACCounters[9]; >- if (pAd->WlanCounters.FailedCount.vv.LowPart < OldValue) >- { >- pAd->WlanCounters.FailedCount.vv.HighPart++; >- } >- OldValue = pAd->QACounters.RXOverFlowCount.vv.LowPart; >- pAd->QACounters.RXOverFlowCount.vv.LowPart += pAd->MACCounters[4]; >- if (pAd->QACounters.RXOverFlowCount.vv.LowPart < OldValue) >- { >- pAd->QACounters.RXOverFlowCount.vv.HighPart++; >- } >- >- // >- // monitor TX counters change for the past period >- // >- TxFailCount = pAd->MACCounters[9]; >- TxNoRetryCnt = pAd->MACCounters[6]; >- TxOneRetryCnt = pAd->MACCounters[7]; >- TxMRetryCnt = pAd->MACCounters[8]; >- TxRetryOkCount = TxOneRetryCnt + TxMRetryCnt; >- TxOkCount = TxNoRetryCnt + TxRetryOkCount; >- TxTotalCnt = TxOkCount + TxFailCount; >- if (TxTotalCnt > 100) >- { >- pAd->ScanAllowed = FALSE; >- } >- else >- { >- pAd->ScanAllowed = TRUE; >- } >-#if 1//steven:exclude CTS >- if ((pAd->PortCfg.TxRate >= RATE_FIRST_OFDM_RATE) && (pAd->PortCfg.BGProtectionInUsed)) >- TxTotalCnt = TxTotalCnt / 2; >-#endif >- if (TxTotalCnt > TxFailCount) >- TxRealOkCount = TxTotalCnt - TxFailCount; >- else >- TxRealOkCount = 0; >- OldValue = pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart; >- pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart += TxRealOkCount; >- if (pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart < OldValue) >- { >- pAd->WlanCounters.TransmittedFragmentCount.vv.HighPart++; >- } >- >- AsicBbpTuning(pAd); >- if (pAd->MediaState == NdisMediaStateConnected) >- { >- if (TxTotalCnt < 5) // if too few TX samples, skip TX related statistics >- { >- TxPER = 0; // don't take TxPER into CQI consideration if too few sample >- TxPRR = 0; >- } >- else >- { >- if (TxFailCount < TxTotalCnt) >- { >- USHORT temp = TxOneRetryCnt + TxMRetryCnt + TxFailCount; >- TxPER = (TxFailCount * 100) / TxTotalCnt; >- if (temp < TxTotalCnt) >- TxPRR = (temp * 100) / TxTotalCnt; >- else >- TxPRR = 100; >- } >- else >- TxPER = 100; >- } >- >- // >- // calculate RX PER >- // >- RxFailCnt = pAd->MACCounters[0]; >- RxOkCnt = pAd->WlanCounters.ReceivedFragmentCount.vv.LowPart - >- pAd->Mlme.PrevWlanCounters.ReceivedFragmentCount.vv.LowPart; >- RxCnt = RxOkCnt + RxFailCnt; >- >- if (RxCnt < 5) >- RxPER = 0; // don't take RxPER into ChannelQuality consideration if too few sample >- else >- RxPER = (RxFailCnt * 100) / RxCnt; >- >- if ((ADHOC_ON(pAd)) && (pAd->MediaState == NdisMediaStateConnected)) >- { >- pAd->SentBeaconsCount += pAd->MACCounters[5]; >- pAd->ReceivedBeaconsCount += pAd->MACCounters[10]; >- >- if ((pAd->Mlme.PeriodicRound % 2) == 1) >- { >- TXRX_CSR18_STRUC Csr18; >- USHORT temp; >- >- DBGPRINT(RT_DEBUG_INFO, "SentBeaconsCount = %d ReceivedBeaconsCount = %d\n", pAd->SentBeaconsCount, pAd->ReceivedBeaconsCount); >- if (pAd->BeaconIntervalChangeAllowed == TRUE) >- { >- if (2 * pAd->SentBeaconsCount > pAd->ReceivedBeaconsCount) >- { >- temp = (pAd->PortCfg.BeaconPeriod << 8) + 1; >- Csr18.field.Offset = (temp & 0x000F); >- Csr18.field.Interval = (temp >> 6); >- RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >- >- pAd->BeaconIntervalChangeAllowed = FALSE; >- } >- else if (pAd->ReceivedBeaconsCount > 9 * pAd->SentBeaconsCount) >- { >- temp = (pAd->PortCfg.BeaconPeriod << 8) - 5; >- Csr18.field.Offset = (temp & 0x000F); >- Csr18.field.Interval = (temp >> 6); >- RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >- >- pAd->BeaconIntervalChangeAllowed = FALSE; >- } >- else if (pAd->ReceivedBeaconsCount > 3 * pAd->SentBeaconsCount) >- { >- temp = (pAd->PortCfg.BeaconPeriod << 8) - 1; >- Csr18.field.Offset = (temp & 0x000F); >- Csr18.field.Interval = (temp >> 6); >- RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >- >- pAd->BeaconIntervalChangeAllowed = FALSE; >- } >-#if 0 >- else if (pAd->ReceivedBeaconsCount > 2 * pAd->SentBeaconsCount) >- { >- temp = (pAd->PortCfg.BeaconPeriod << 8) - 1; >- Csr18.field.Offset = (temp & 0x000F); >- Csr18.field.Interval = (temp >> 6); >- RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_TRACE, ("TXRX_CSR18 = 0x%x\n", Csr18.value)); >- >- pAd->BeaconIntervalChangeAllowed = FALSE; >- } >-#endif >- } >-#if 0 >- else if (pAd->ReceivedBeaconsCount > 9 * pAd->SentBeaconsCount) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, ("Do Nothing\n")); >- } >-#endif >- else >- { >- temp = (pAd->PortCfg.BeaconPeriod << 8); >- Csr18.field.Offset = (temp & 0x000F); >- Csr18.field.Interval = (temp >> 6); >- RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); >- >- pAd->BeaconIntervalChangeAllowed = TRUE; >- } >- >- pAd->SentBeaconsCount = 0; >- pAd->ReceivedBeaconsCount = 0; >- } >- } >- Now32 = jiffies; >- >- { >- // ChannelQuality = W1*RSSI + W2*TxPRR + W3*RxPER (RSSI 0..100), (TxPER 100..0), (RxPER 100..0) >- pAd->Mlme.ChannelQuality = (RSSI_WEIGHTING * pAd->PortCfg.LastRssi + >- TX_WEIGHTING * (100 - TxPRR) + >- RX_WEIGHTING* (100 - RxPER)) / 100; >- if (pAd->Mlme.ChannelQuality >= 100) >- pAd->Mlme.ChannelQuality = 100; >- } >- >- DBGPRINT(RT_DEBUG_INFO, "MMCHK - CQI= %d, (Tx Fail=%d/Retry=%d/Total=%d, Rx Fail=%d/Total=%d, RSSI=%d dbm)\n", >- pAd->Mlme.ChannelQuality, TxFailCount, TxRetryOkCount, TxTotalCnt, RxFailCnt, RxCnt, pAd->PortCfg.LastRssi - pAd->BBPTuningParameters.RSSIToDbmOffset); >- >- // latch current WLAN counters for next check-for-roaming usage >- NdisMoveMemory(&pAd->Mlme.PrevWlanCounters, &pAd->WlanCounters, sizeof(COUNTER_802_11)); >- >-#if 1//steven:move this from MlmePeriodicExec >- if (INFRA_ON(pAd)) >- { >- if (CQI_IS_BAD(pAd->Mlme.ChannelQuality)) >- { >- pAd->RalinkCounters.BadCQIAutoRecoveryCount ++; >- DBGPRINT(RT_DEBUG_TRACE, "MMCHK - Bad CQI. Auto Recovery attempt #%d\n", pAd->RalinkCounters.BadCQIAutoRecoveryCount); >- MlmeAutoRecoverNetwork(pAd); >- } >- else if (CQI_IS_FAIR(pAd->Mlme.ChannelQuality) || CQI_IS_POOR(pAd->Mlme.ChannelQuality)) >- { >- // perform aggresive roaming only when SECURITY OFF or WEP64/128; >- // WPA and WPA-PSK has no aggresive roaming because re-negotiation >- // between 802.1x supplicant and authenticator/AAA server is required >- // but can't be guaranteed. >- if (pAd->PortCfg.AuthMode < Ndis802_11AuthModeWPA) >- MlmeCheckForRoaming(pAd, Now32); >- } >- } >-#endif >- >- pAd->PortCfg.CurrTxRateStableTime++; >- CurrRate = pAd->PortCfg.TxRate; >- do >- { >- USHORT TxErrorRatio; >- BOOLEAN fUpgradeQuality = FALSE; >- USHORT *pRateUpPER, *pRateDownPER; >- >- if (pAd->PortCfg.EnableAutoRateSwitching == FALSE) >- break; >- >- // do nothing if no traffic in the past period >- if (TxTotalCnt == 0) >- { >- // TxRateUpPenalty maybe too large, we don't want this penalty to affect >- // next Chariot throughput test too much therefore zero it here. >- pAd->PortCfg.TxRateUpPenalty = 0; >- NdisZeroMemory(pAd->DrsCounters.TxQuality, MAX_LEN_OF_SUPPORTED_RATES); >- NdisZeroMemory(pAd->DrsCounters.PER, MAX_LEN_OF_SUPPORTED_RATES); >- break; >- } >- >- // decide the next upgrade rate and downgrade rate, if any >- if (pAd->PortCfg.PhyMode == PHY_11BG_MIXED) >- { >- UpRate = Phy11BGNextRateUpward[CurrRate]; >- DownRate = Phy11BGNextRateDownward[CurrRate]; >- } >- else if (pAd->PortCfg.PhyMode == PHY_11B) >- { >- UpRate = Phy11BNextRateUpward[CurrRate]; >- DownRate = Phy11BNextRateDownward[CurrRate]; >- } >- else if (pAd->PortCfg.PhyMode == PHY_11A) >- { >- UpRate = Phy11ANextRateUpward[CurrRate]; >- DownRate = Phy11ANextRateDownward[CurrRate]; >- } >- else // PHY_11ABG_MIXED >- { >- if (pAd->PortCfg.Channel > 14) >- { >- UpRate = Phy11ANextRateUpward[CurrRate]; >- DownRate = Phy11ANextRateDownward[CurrRate]; >- } >- else >- { >- UpRate = Phy11BGNextRateUpward[CurrRate]; >- DownRate = Phy11BGNextRateDownward[CurrRate]; >- } >- } >- >- if (UpRate > pAd->PortCfg.MaxTxRate) >- UpRate = pAd->PortCfg.MaxTxRate; >- >- // decide TX quality based on Tx retry ratio when enough samples are available >- if (TxTotalCnt > 15) >- { >- USHORT temp = TxRetryOkCount + TxFailCount; >- if (temp < TxTotalCnt) >- TxErrorRatio = (temp *100) / TxTotalCnt; >- else >- TxErrorRatio = 100; >- >- pRateUpPER = &NewRateUpPER[0]; >- pRateDownPER = &NewRateDownPER[0]; >- >- // downgrade TX quality if retry+error ratio reached >- if (TxErrorRatio >= pRateDownPER[CurrRate]) >- { >- pAd->DrsCounters.TxQuality[CurrRate] = DRS_TX_QUALITY_WORST_BOUND; >- } >- // upgrade TX quality if retry+error ratio reached >- else if (TxErrorRatio <= pRateUpPER[CurrRate]) >- { >- fUpgradeQuality = TRUE; >- if (pAd->DrsCounters.TxQuality[CurrRate]) >- pAd->DrsCounters.TxQuality[CurrRate] --; // quality very good in CurrRate >- >- if (pAd->PortCfg.TxRateUpPenalty) >- pAd->PortCfg.TxRateUpPenalty --; >- else if (pAd->DrsCounters.TxQuality[UpRate]) >- pAd->DrsCounters.TxQuality[UpRate] --; // may improve next UP rate's quality >- } >- >- } >- >- // if not enough TX samples, decide by heuristic rules >- else >- { >- TxErrorRatio = 0; >- >- // Downgrade TX quality upon - >- // 1. any TX failure in the past second >- // 2. TX retry ratio too high when enough TX samples are available >- if (TxFailCount) >- { >- if ((TxFailCount <= 1) && >- (TxRealOkCount + TxRetryOkCount)) >- { >- pAd->DrsCounters.TxQuality[CurrRate] += 2; // degrade quality >- if (pAd->DrsCounters.TxQuality[CurrRate] > DRS_TX_QUALITY_WORST_BOUND) >- pAd->DrsCounters.TxQuality[CurrRate] = DRS_TX_QUALITY_WORST_BOUND; >- } >- else // more than 2 failure, or no TX ok cases >- { >- pAd->DrsCounters.TxQuality[CurrRate] = DRS_TX_QUALITY_WORST_BOUND; // quality bad >- } >- } >- // upgrade TX quality if - >- // 1. no TX failure but do have TX ok case, and >- // 2. there's more one-time-ok cases than retry-ok cases in the past second >- // 3. current rate's Tx retry ratio <= 10% >- else if ((TxRealOkCount > TxRetryOkCount)) >- { >- fUpgradeQuality = TRUE; >- if (pAd->DrsCounters.TxQuality[CurrRate]) >- pAd->DrsCounters.TxQuality[CurrRate] --; // quality very good in CurrRate >- >- if (pAd->PortCfg.TxRateUpPenalty) >- pAd->PortCfg.TxRateUpPenalty --; >- else if (pAd->DrsCounters.TxQuality[UpRate]) >- pAd->DrsCounters.TxQuality[UpRate] --; // may improve next UP rate's quality >- } >- } >- >- pAd->DrsCounters.PER[CurrRate] = (UCHAR)TxErrorRatio; >- >- if (pAd->DrsCounters.fNoisyEnvironment) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS(noisy):"); >- } >- else >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS:"); >- } >- DBGPRINT_RAW(RT_DEBUG_TRACE,"Qty[%d]=%d PER=%d%% %d-sec, Qty[%d]=%d, Pty=%d\n", >- RateIdToMbps[CurrRate], pAd->DrsCounters.TxQuality[CurrRate], >- TxErrorRatio, >- pAd->DrsCounters.CurrTxRateStableTime, >- RateIdToMbps[UpRate], pAd->DrsCounters.TxQuality[UpRate], >- pAd->DrsCounters.TxRateUpPenalty); >- >- // 2004-3-13 special case: Claim noisy environment >- // decide if there was a false "rate down" in the past 2 sec due to noisy >- // environment. if so, we would rather switch back to the higher TX rate. >- // criteria - >- // 1. there's a higher rate available, AND >- // 2. there was a rate-down happened, AND >- // 3. current rate has 75% > PER > 25%, AND >- // 4. comparing to UpRate, current rate didn't improve PER more than 5 % >- if ((UpRate != CurrRate) && >- (pAd->DrsCounters.LastSecTxRateChangeAction == 2) && >- (((pAd->DrsCounters.PER[CurrRate] > 20) || (pAd->DrsCounters.fNoisyEnvironment)) && >- (pAd->DrsCounters.PER[CurrRate] < 75)) && >- ((pAd->DrsCounters.PER[CurrRate]+5) > pAd->DrsCounters.PER[UpRate])) >- { >- // we believe this is a noisy environment. better stay at UpRate >- DBGPRINT(RT_DEBUG_TRACE,"DRS: #### enter Noisy environment ####\n"); >- pAd->DrsCounters.fNoisyEnvironment = TRUE; >- >- // 2004-3-14 when claiming noisy environment, we're not only switch back >- // to UpRate, but can be more aggressive to use one more rate up >- UpRate++; >-// if (UpRate>RATE_54) UpRate=RATE_54; >- if ((UpRate==RATE_6) || (UpRate==RATE_9)) UpRate=RATE_12; >- if (UpRate > pAd->PortCfg.MaxTxRate) >- UpRate = pAd->PortCfg.MaxTxRate; >- pAd->PortCfg.TxRate = UpRate; >- break; >- } >- >- // 2004-3-12 special case: Leave noisy environment >- // The interference has gone suddenly. reset TX rate to >- // the theoritical value according to RSSI. Criteria - >- // 1. it's currently in noisy environment >- // 2. PER drops to be below 12% >- if ((pAd->DrsCounters.fNoisyEnvironment == TRUE) && >- (TxTotalCnt > 15) && (pAd->DrsCounters.PER[CurrRate] <= 12)) >- { >- UCHAR JumpUpRate; >- >- pAd->DrsCounters.fNoisyEnvironment = FALSE; >- for (JumpUpRate = RATE_54; JumpUpRate > RATE_1; JumpUpRate--) >- { >- if (pAd->PortCfg.AvgRssi > (RssiSafeLevelForTxRate[JumpUpRate] + pAd->BBPTuningParameters.RSSIToDbmOffset)) >- break; >- } >- >- if (JumpUpRate > pAd->PortCfg.MaxTxRate) >- JumpUpRate = pAd->PortCfg.MaxTxRate; >- >- DBGPRINT(RT_DEBUG_TRACE,"DRS: #### leave Noisy environment ####, RSSI=%d, JumpUpRate=%d\n", >- pAd->PortCfg.AvgRssi - pAd->BBPTuningParameters.RSSIToDbmOffset, RateIdToMbps[JumpUpRate]); >- >- if (JumpUpRate > CurrRate) >- { >- pAd->PortCfg.TxRate = JumpUpRate; >- break; >- } >- } >- >- // perform DRS - consider TxRate Down first, then rate up. >- // 1. rate down, if current TX rate's quality is not good >- // 2. rate up, if UPRate's quality is very good >- if ((pAd->DrsCounters.TxQuality[CurrRate] >= DRS_TX_QUALITY_WORST_BOUND) && >- (CurrRate != DownRate)) >- { >- >- pAd->PortCfg.TxRate = DownRate; >- } >- else if ((pAd->DrsCounters.TxQuality[CurrRate] <= 0) && >- (pAd->DrsCounters.TxQuality[UpRate] <=0) && >- (CurrRate != UpRate)) >- { >- pAd->PortCfg.TxRate = UpRate; >- } >- }while (FALSE); >- >- // if rate-up happen, clear all bad history of all TX rates >- if (pAd->PortCfg.TxRate > CurrRate) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS: ++TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); >- pAd->DrsCounters.CurrTxRateStableTime = 0; >- pAd->DrsCounters.TxRateUpPenalty = 0; >- pAd->DrsCounters.LastSecTxRateChangeAction = 1; // rate UP >- NdisZeroMemory(pAd->DrsCounters.TxQuality, MAX_LEN_OF_SUPPORTED_RATES); >- NdisZeroMemory(pAd->DrsCounters.PER, MAX_LEN_OF_SUPPORTED_RATES); >- } >- // if rate-down happen, only clear DownRate's bad history >- else if (pAd->PortCfg.TxRate < CurrRate) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS: --TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); >- // shorter stable time require more penalty in next rate UP criteria >- if (pAd->DrsCounters.CurrTxRateStableTime < 4) // less then 4 sec >- pAd->DrsCounters.TxRateUpPenalty = DRS_PENALTY; // add 8 sec penalty >- else if (pAd->DrsCounters.CurrTxRateStableTime < 8) // less then 8 sec >- pAd->DrsCounters.TxRateUpPenalty = 2; // add 2 sec penalty >- else // >= 8 sec >- pAd->DrsCounters.TxRateUpPenalty = 0; // no penalty >- >- pAd->DrsCounters.CurrTxRateStableTime = 0; >- pAd->DrsCounters.LastSecTxRateChangeAction = 2; // rate DOWN >- pAd->DrsCounters.TxQuality[pAd->PortCfg.TxRate] = 0; >- pAd->DrsCounters.PER[pAd->PortCfg.TxRate] = 0; >- } >- else >- pAd->DrsCounters.LastSecTxRateChangeAction = 0; // rate no change >- } >- >- >-} >- >-/* >- ========================================================================== >- Description: >- This routine is executed periodically inside MlmePeriodicExec() after >- association with an AP. >- It checks if PortCfg.Psm is consistent with user policy (recorded in >- PortCfg.WindowsPowerMode). If not, enforce user policy. However, >- there're some conditions to consider: >- 1. we don't support power-saving in ADHOC mode, so Psm=PWR_ACTIVE all >- the time when Mibss==TRUE >- 2. When Massoc==TRUE (INFRA mode), Psm should not be switch to PWR_SAVE >- if outgoing traffic available in TxRing or PrioRing. >- Output: >- 1. change pAd->PortCfg.Psm to PWR_SAVE or leave it untouched >- >- IRQL = DISPATCH_LEVEL >- >- ========================================================================== >- */ >-VOID MlmeCheckForPsmChange( >- IN PRT2570ADAPTER pAd) >-{ >- ULONG PowerMode; >- // condition - >- // 1. Psm maybe ON only happen in INFRASTRUCTURE mode >- // 2. user wants either MAX_PSP or FAST_PSP >- // 3. but current psm is not in PWR_SAVE >- // 4. CNTL state machine is not doing SCANning >- // 5. no TX SUCCESS event for the past period >- PowerMode = pAd->PortCfg.WindowsPowerMode; >- >- if (INFRA_ON(pAd) && >- (PowerMode != Ndis802_11PowerModeCAM) && >- (pAd->BulkOutPending == FALSE) && >- (LOCAL_TX_RING_EMPTY(pAd)) && >- (pAd->SendTxWaitQueue.Number == 0) && >- (pAd->PortCfg.Psm == PWR_ACTIVE) && >- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) && >- (pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart == pAd->Mlme.PrevTxCnt)) >- { >- RTUSBEnqueueInternalCmd(pAd, RT_OID_SET_PSM_BIT_SAVE); >- } >- >- // latch current count for next-time comparison >- pAd->Mlme.PrevTxCnt = pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart; >- >-} >- >-// IRQL = PASSIVE_LEVEL >-// IRQL = DISPATCH_LEVEL >-VOID MlmeSetPsmBit( >- IN PRT2570ADAPTER pAd, >- IN USHORT psm) >-{ >- pAd->PortCfg.Psm = psm; >- >- DBGPRINT(RT_DEBUG_TEMP, "MMCHK - change PSM bit to %d <<<\n", psm); >-} >- >-// IRQL = DISPATCH_LEVEL >-// IRQL = DISPATCH_LEVEL >-VOID MlmeSetTxPreamble( >- IN PRT2570ADAPTER pAd, >- IN USHORT TxPreamble) >-{ >- USHORT value; >- >- RTUSBReadMACRegister(pAd, TXRX_CSR10, &value); >- if (TxPreamble == Rt802_11PreambleShort) >- { >- DBGPRINT(RT_DEBUG_TRACE, "MlmeSetTxPreamble (= SHORT PREAMBLE)\n"); >- value |= 0x0004; >- pAd->PortCfg.TxPreambleInUsed = Rt802_11PreambleShort; >- } >- else >- { >- DBGPRINT(RT_DEBUG_TRACE, "MlmeSetTxPreamble (= LONG PREAMBLE)\n"); >- value &= 0xFFFB; >- pAd->PortCfg.TxPreambleInUsed = Rt802_11PreambleLong; >- } >- >- RTUSBWriteMACRegister(pAd, TXRX_CSR10, value); >-} >- >-// IRQL = PASSIVE_LEVEL >-// IRQL = DISPATCH_LEVEL >-// bLinkUp is to identify the inital link speed. >-// TRUE indicates the rate update at linkup, we should not try to set the rate at 54Mbps. >-VOID MlmeUpdateTxRates( >- IN PRT2570ADAPTER pAd, >- IN BOOLEAN bLinkUp) >-{ >- int i, num; >- UCHAR Rate, MaxDesire = RATE_1, MaxSupport = RATE_1; >- USHORT BasicRateBitmap = 0; >- UCHAR CurrBasicRate = RATE_1; >- >- // find max desired rate >- num = 0; >- for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++) >- { >- switch (pAd->PortCfg.DesiredRates[i] & 0x7f) >- { >- case 2: Rate = RATE_1; num++; break; >- case 4: Rate = RATE_2; num++; break; >- case 11: Rate = RATE_5_5; num++; break; >- case 22: Rate = RATE_11; num++; break; >- case 12: Rate = RATE_6; num++; break; >- case 18: Rate = RATE_9; num++; break; >- case 24: Rate = RATE_12; num++; break; >- case 36: Rate = RATE_18; num++; break; >- case 48: Rate = RATE_24; num++; break; >- case 72: Rate = RATE_36; num++; break; >- case 96: Rate = RATE_48; num++; break; >- case 108: Rate = RATE_54; num++; break; >- default: Rate = RATE_1; break; >- } >- if (MaxDesire < Rate) MaxDesire = Rate; >- >- // Fixed the Maximum rate of 2426 to b only >- if (pAd->PortCfg.RfType == RFIC_2426) >- if (MaxDesire > RATE_11) >- MaxDesire = RATE_11; >- } >- >- // 2003-12-10 802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode >- if ((pAd->PortCfg.BssType == BSS_INDEP) && >- (pAd->PortCfg.PhyMode == PHY_11BG_MIXED) && >- (pAd->PortCfg.AdhocMode == 0) && >- (MaxDesire > RATE_11)) >- MaxDesire = RATE_11; >- >- pAd->PortCfg.MaxDesiredRate = MaxDesire; >- >- // Auto rate switching is enabled only if more than one DESIRED RATES are >- // specified; otherwise disabled >- if (num <= 1) >- pAd->PortCfg.EnableAutoRateSwitching = FALSE; >- else >- pAd->PortCfg.EnableAutoRateSwitching = TRUE; >- >- // find max supported rate >- for (i=0; i<pAd->PortCfg.SupportedRatesLen; i++) >- { >- switch (pAd->PortCfg.SupportedRates[i] & 0x7f) >- { >- case 2: Rate = RATE_1; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0001; >- break; >- case 4: Rate = RATE_2; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0002; >- break; >- case 11: >- Rate = RATE_5_5; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0004; >- break; >- case 22: >- Rate = RATE_11; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0008; >- break; >- case 12: >- Rate = RATE_6; >-// if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0010; >- break; >- case 18: >- Rate = RATE_9; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0020; >- break; >- case 24: >- Rate = RATE_12; >-// if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0040; >- break; >- case 36: >- Rate = RATE_18; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0080; >- break; >- case 48: >- Rate = RATE_24; >-// if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0100; >- break; >- case 72: >- Rate = RATE_36; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0200; >- break; >- case 96: >- Rate = RATE_48; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0400; >- break; >- case 108: >- Rate = RATE_54; >- if (pAd->PortCfg.SupportedRates[i] & 0x80) >- BasicRateBitmap |= 0x0800; >- break; >- default: >- Rate = RATE_1; >- break; >- } >- if (MaxSupport < Rate) MaxSupport = Rate; >- } >- >- // Limit the max support rate and basic rate map to 11b only >- if (pAd->PortCfg.RfType == RFIC_2426) >- { >- if (MaxSupport > RATE_11) >- { >- MaxSupport = RATE_11; >- BasicRateBitmap &= 0x000f; >- } >- } >- >- RTUSBWriteMACRegister(pAd, TXRX_CSR11, BasicRateBitmap); >- >- // calculate the exptected ACK rate for each TX rate. This info is used to caculate >- // the DURATION field of outgoing uniicast DATA/MGMT frame >- for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++) >- { >- if (BasicRateBitmap & (0x01 << i)) >- CurrBasicRate = (UCHAR)i; >- pAd->PortCfg.ExpectedACKRate[i] = CurrBasicRate; >- DBGPRINT(RT_DEBUG_INFO,"Exptected ACK rate[%d] = %d Mbps\n", RateIdToMbps[i], RateIdToMbps[CurrBasicRate]); >- } >- >- // max tx rate = min {max desire rate, max supported rate} >- if (MaxSupport < MaxDesire) >- pAd->PortCfg.MaxTxRate = MaxSupport; >- else >- pAd->PortCfg.MaxTxRate = MaxDesire; >- >- // 2003-07-31 john - 2500 doesn't have good sensitivity at high OFDM rates. to increase the success >- // ratio of initial DHCP packet exchange, TX rate starts from a lower rate >- if (pAd->PortCfg.EnableAutoRateSwitching) >- { >- if (pAd->PortCfg.Channel > 14) >- pAd->PortCfg.TxRate = RATE_6; // 802.11a >- else >- { >- int dbm = pAd->PortCfg.AvgRssi - pAd->BBPTuningParameters.RSSIToDbmOffset; >- if (dbm > -70) >- { >- pAd->PortCfg.TxRate = pAd->PortCfg.MaxTxRate; >- } >- else if (dbm > -75) >- { >- pAd->PortCfg.TxRate = min((INT)(pAd->PortCfg.MaxTxRate), RATE_36); >- } >- else >- { >- pAd->PortCfg.TxRate = min((INT)(pAd->PortCfg.MaxTxRate), RATE_11); >- } >- } >- } >- else >- pAd->PortCfg.TxRate = pAd->PortCfg.MaxTxRate; >- >- switch (pAd->PortCfg.PhyMode) { >- case PHY_11BG_MIXED: >- case PHY_11B: >- pAd->PortCfg.MlmeRate = RATE_2; >-#ifdef WIFI_TEST >- pAd->PortCfg.RtsRate = RATE_11; >-#else >- pAd->PortCfg.RtsRate = RATE_2; >-#endif >- break; >- case PHY_11A: >- pAd->PortCfg.MlmeRate = RATE_6; >- pAd->PortCfg.RtsRate = RATE_6; >- break; >- case PHY_11ABG_MIXED: >- if (pAd->PortCfg.Channel <= 14) >- { >- pAd->PortCfg.MlmeRate = RATE_2; >- pAd->PortCfg.RtsRate = RATE_2; >- } >- else >- { >- pAd->PortCfg.MlmeRate = RATE_6; >- pAd->PortCfg.RtsRate = RATE_6; >- } >- break; >- default: // error >- pAd->PortCfg.MlmeRate = RATE_2; >- pAd->PortCfg.RtsRate = RATE_2; >- break; >- } >- >- DBGPRINT(RT_DEBUG_TRACE, " MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, Rate Switching =%d)\n", >- RateIdToMbps[MaxDesire], RateIdToMbps[MaxSupport], RateIdToMbps[pAd->PortCfg.MaxTxRate], pAd->PortCfg.EnableAutoRateSwitching); >- DBGPRINT(RT_DEBUG_TRACE, " MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04x)\n", >- RateIdToMbps[pAd->PortCfg.TxRate], RateIdToMbps[pAd->PortCfg.RtsRate], BasicRateBitmap); >-} >- >-// IRQL = DISPATCH_LEVEL >-VOID MlmeRadioOff( >- IN PRT2570ADAPTER pAd) >-{ >- MLME_DISASSOC_REQ_STRUCT DisReq; >- MLME_QUEUE_ELEM MsgElem; >- UINT i = 0; >- >- // >- // Since set flag fRTMP_ADAPTER_RADIO_OFF will diable RTUSBKickBulkOut function. >- // So before set flag fRTMP_ADAPTER_RADIO_OFF, >- // we should send a disassoc frame to our AP if neend. >- // >- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)) >- { >- if (INFRA_ON(pAd)) >- { >- COPY_MAC_ADDR(&DisReq.Addr, &pAd->PortCfg.Bssid); >- DisReq.Reason = REASON_DISASSOC_STA_LEAVING; >- >- MsgElem.Machine = ASSOC_STATE_MACHINE; >- MsgElem.MsgType = MT2_MLME_DISASSOC_REQ; >- MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT); >- NdisMoveMemory(MsgElem.Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT)); >- >- MlmeDisassocReqAction(pAd, &MsgElem); >- NdisMSleep(1); >- } >- // Set Radio off flag will turn off RTUSBKickBulkOut function >- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); >- DBGPRINT(RT_DEBUG_ERROR, "3Set fRTMP_ADAPTER_RADIO_OFF "); >- >- LinkDown(pAd); >- } >- else >- { >- // Set Radio off flag will turn off RTUSBKickBulkOut function >- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); >- DBGPRINT(RT_DEBUG_ERROR, "4Set fRTMP_ADAPTER_RADIO_OFF "); >- } >- DBGPRINT_RAW(RT_DEBUG_TEMP," MlmeRadioOff \n" ); >- RTUSBRejectPendingPackets(pAd);//reject all NDIS packets waiting in TX queue >- RTUSBCleanUpDataBulkOutQueue(pAd); >- MlmeSuspend(pAd); >- DBGPRINT_RAW(RT_DEBUG_TEMP," 2MlmeRadioOff \n" ); >- // Abort Tx >- // Disable Rx >- RTUSBWriteMACRegister(pAd, TXRX_CSR2, 1); >- //Ask our device to complete any pending bulk in IRP. >- while (( atomic_read(&pAd->PendingRx) > 0) || (pAd->BulkOutPending == TRUE)) >- { >- if (atomic_read(&pAd->PendingRx) > 0) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "BulkIn IRP Pending!!!\n"); >- RTUSB_VendorRequest(pAd, >- 0, >- DEVICE_VENDOR_REQUEST_OUT, >- 0x0C, >- 0x0, >- 0x0, >- NULL, >- 0); >- } >- >- if (pAd->BulkOutPending == TRUE) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "BulkOut IRP Pending!!!\n"); >- if (i == 0) >- { >- RTUSBCancelPendingBulkOutIRP(pAd); >- i++; >- } >- } >- >- NdisMSleep(5); >- } >-#if 1 >- >- // Turn off radio >- RTUSBWriteMACRegister(pAd, MAC_CSR13, 0x2121); >- RTUSBWriteMACRegister(pAd, MAC_CSR14, 0x2121); >- >- if (pAd->PortCfg.LedMode == LED_MODE_ASUS) >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR20, 0x0001); >- } >- >- // Clean up old bss table >- BssTableInit(&pAd->PortCfg.BssTab); >- DBGPRINT_RAW(RT_DEBUG_TEMP," <==MlmeRadioOff \n" ); >-#endif >-} >- >-// IRQL = DISPATCH_LEVEL >-VOID MlmeRadioOn( >- IN PRT2570ADAPTER pAd) >-{ >- // Turn on radio >- RTUSBWriteMACRegister(pAd, MAC_CSR13, 0x3100); >- RTUSBWriteMACRegister(pAd, MAC_CSR14, 0x3f3b); >- >- // Abort Tx >- //steven:don't have this RTMP_IO_WRITE32(pAd, TXCSR0, 0x08); >- // Disable Rx >- RTUSBWriteMACRegister(pAd, TXRX_CSR2, 1); >- >- NICResetFromError(pAd); >- // Clear Radio off flag >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); >- MlmeResume(pAd); >- RTUSBBulkReceive(pAd); >- RTUSBWriteMACRegister(pAd, TXRX_CSR2, 0x7e); >- if (pAd->PortCfg.LedMode == LED_MODE_ASUS) >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR20, 0x0003); >- } >-} >- >- >-// =========================================================================================== >-// bss_table.c >-// =========================================================================================== >- >- >-/*! \brief initialize BSS table >- * \param p_tab pointer to the table >- * \return none >- * \pre >- * \post >- >- IRQL = PASSIVE_LEVEL >- IRQL = DISPATCH_LEVEL >- >- */ >-VOID BssTableInit( >- IN BSS_TABLE *Tab) >-{ >- int i; >- >- Tab->BssNr = 0; >- for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++) >- { >- NdisZeroMemory(&Tab->BssEntry[i], sizeof(BSS_ENTRY)); >- } >-} >- >-/*! \brief search the BSS table by SSID >- * \param p_tab pointer to the bss table >- * \param ssid SSID string >- * \return index of the table, BSS_NOT_FOUND if not in the table >- * \pre >- * \post >- * \note search by sequential search >- >- IRQL = DISPATCH_LEVEL >- >- */ >-ULONG BssTableSearch( >- IN BSS_TABLE *Tab, >- IN PMACADDR Bssid) >-{ >- UCHAR i; >- >- for (i = 0; i < Tab->BssNr; i++) >- { >- //printf("comparing %s and %s\n", p_tab->bss[i].ssid, ssid); >- if (MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid)) >- { >- return i; >- } >- } >- return (ULONG)BSS_NOT_FOUND; >-} >- >-// IRQL = DISPATCH_LEVEL >-VOID BssTableDeleteEntry( >- IN OUT BSS_TABLE *Tab, >- IN PMACADDR Bssid) >-{ >- UCHAR i, j; >- >- for (i = 0; i < Tab->BssNr; i++) >- { >- //printf("comparing %s and %s\n", p_tab->bss[i].ssid, ssid); >- if (MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid)) >- { >- for (j = i; j < Tab->BssNr - 1; j++) >- { >- NdisMoveMemory(&(Tab->BssEntry[j]), &(Tab->BssEntry[j + 1]), sizeof(BSS_ENTRY)); >- } >- Tab->BssNr -= 1; >- return; >- } >- } >-} >- >-UCHAR ZeroSsid[32] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, >- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; >-/*! \brief >- * \param >- * \return >- * \pre >- * \post >- >- IRQL = DISPATCH_LEVEL >- >- */ >-VOID BssEntrySet( >- IN PRT2570ADAPTER pAd, >- OUT BSS_ENTRY *pBss, >- IN MACADDR *pBssid, >- IN CHAR Ssid[], >- IN UCHAR SsidLen, >- IN UCHAR BssType, >- IN USHORT BeaconPeriod, >- IN BOOLEAN CfExist, >- IN CF_PARM *pCfParm, >- IN USHORT AtimWin, >- IN USHORT CapabilityInfo, >- IN UCHAR Rates[], >- IN UCHAR RatesLen, >- IN BOOLEAN ExtendedRateIeExist, >- IN UCHAR Channel, >- IN UCHAR Rssi, >- IN LARGE_INTEGER TimeStamp, >- IN UCHAR LengthVIE, >- IN PNDIS_802_11_VARIABLE_IEs pVIE) >-{ >- COPY_MAC_ADDR(&pBss->Bssid, pBssid); >- // Default Hidden SSID to be TRUE, it will be turned to FALSE after coping SSID >- pBss->Hidden = 1; >- if (SsidLen > 0) >- { >- // For hidden SSID AP, it might send beacon with SSID len equal to 0 >- // Or send beacon /probe response with SSID len matching real SSID length, >- // but SSID is all zero. such as "00-00-00-00" with length 4. >- // We have to prevent this case overwrite correct table >- if (NdisEqualMemory(Ssid, ZeroSsid, SsidLen) == 0) >- { >- NdisMoveMemory(pBss->Ssid, Ssid, SsidLen); >- pBss->SsidLen = SsidLen; >- pBss->Hidden = 0; >- } >- } >- pBss->BssType = BssType; >- pBss->BeaconPeriod = BeaconPeriod; >- if (BssType == BSS_INFRA) >- { >- if (CfExist) >- { >- pBss->CfpCount = pCfParm->CfpCount; >- pBss->CfpPeriod = pCfParm->CfpPeriod; >- pBss->CfpMaxDuration = pCfParm->CfpMaxDuration; >- pBss->CfpDurRemaining = pCfParm->CfpDurRemaining; >- } >- } >- else >- { >- pBss->AtimWin = AtimWin; >- } >- >- pBss->CapabilityInfo = CapabilityInfo; >- // The privacy bit indicate security is ON, it maight be WEP, TKIP or AES >- // Combine with AuthMode, they will decide the connection methods. >- pBss->Privacy = CAP_IS_PRIVACY_ON(pBss->CapabilityInfo); >- NdisMoveMemory(pBss->Rates, Rates, RatesLen); >- pBss->RatesLen = RatesLen; >- pBss->ExtendedRateIeExist = ExtendedRateIeExist; >- pBss->Channel = Channel; >- pBss->Rssi = Rssi; >- >- // New for microsoft Fixed IEs >- NdisMoveMemory(pBss->FixIEs.Timestamp, &TimeStamp, 8); >- pBss->FixIEs.BeaconInterval = BeaconPeriod; >- pBss->FixIEs.Capabilities = CapabilityInfo; >- >- // New for microsoft Variable IEs >- if (LengthVIE != 0) >- { >- pBss->VarIELen = LengthVIE; >- NdisMoveMemory(pBss->VarIEs, pVIE, pBss->VarIELen); >- BssCipherParse(pBss); >- } >- else >- { >- pBss->VarIELen = 0; >- // No SSN ID, if security is on, this is WEP algorithm >- if (pBss->Privacy) >- pBss->WepStatus = Ndis802_11WEPEnabled; >- // No SSN ID, security is also off. >- else >- pBss->WepStatus = Ndis802_11WEPDisabled; >- } >-} >- >-/*! >- * \brief insert an entry into the bss table >- * \param p_tab The BSS table >- * \param Bssid BSSID >- * \param ssid SSID >- * \param ssid_len Length of SSID >- * \param bss_type >- * \param beacon_period >- * \param timestamp >- * \param p_cf >- * \param atim_win >- * \param cap >- * \param rates >- * \param rates_len >- * \param channel_idx >- * \return none >- * \pre >- * \post >- * \note If SSID is identical, the old entry will be replaced by the new one >- >- IRQL = DISPATCH_LEVEL >- >- */ >-ULONG BssTableSetEntry( >- IN PRT2570ADAPTER pAd, >- OUT BSS_TABLE *Tab, >- IN MACADDR *Bssid, >- IN CHAR Ssid[], >- IN UCHAR SsidLen, >- IN UCHAR BssType, >- IN USHORT BeaconPeriod, >- IN BOOLEAN CfExist, >- IN CF_PARM *CfParm, >- IN USHORT AtimWin, >- IN USHORT CapabilityInfo, >- IN UCHAR Rates[], >- IN UCHAR RatesLen, >- IN BOOLEAN ExtendedRateIeExist, >- IN UCHAR ChannelNo, >- IN UCHAR Rssi, >- IN LARGE_INTEGER TimeStamp, >- IN UCHAR LengthVIE, >- IN PNDIS_802_11_VARIABLE_IEs pVIE) >-{ >- ULONG Idx; >- >- Idx = BssTableSearch(Tab, Bssid); >- if (Idx == BSS_NOT_FOUND) >- { >- if (Tab->BssNr >= MAX_LEN_OF_BSS_TABLE) >- return BSS_NOT_FOUND; >- Idx = Tab->BssNr; >- BssEntrySet(pAd, &Tab->BssEntry[Idx], Bssid, Ssid, SsidLen, BssType, BeaconPeriod, >- CfExist, CfParm, AtimWin, CapabilityInfo, Rates, RatesLen, ExtendedRateIeExist, >- ChannelNo, Rssi, TimeStamp, LengthVIE, pVIE); >- Tab->BssNr++; >- } >- else >- { >- BssEntrySet(pAd, &Tab->BssEntry[Idx], Bssid, Ssid, SsidLen, BssType, BeaconPeriod, >- CfExist, CfParm, AtimWin, CapabilityInfo, Rates, RatesLen, ExtendedRateIeExist, >- ChannelNo, Rssi, TimeStamp, LengthVIE, pVIE); >- } >- //DBGPRINT_RAW(RT_DEBUG_TEMP," %s Wep %d auth %d \n",Ssid, Tab->BssEntry[Idx].WepStatus, Tab->BssEntry[Idx].AuthMode); >- >- return Idx; >-} >- >- >-// IRQL = DISPATCH_LEVEL >-VOID BssTableSsidSort( >- IN PRT2570ADAPTER pAd, >- OUT BSS_TABLE *OutTab, >- IN CHAR Ssid[], >- IN UCHAR SsidLen) >-{ >- INT i; >- >- BssTableInit(OutTab); >- >- for (i = 0; i < pAd->PortCfg.BssTab.BssNr; i++) >- { >- BSS_ENTRY *pInBss = &pAd->PortCfg.BssTab.BssEntry[i]; >- >- if ((pInBss->BssType == pAd->PortCfg.BssType) && >- ((pInBss->SsidLen==SsidLen) && RTMPEqualMemory(pInBss->Ssid, Ssid, (ULONG) SsidLen))) >- { >- BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr]; >- // New for WPA2 >- // Check the Authmode first >- if (pAd->PortCfg.AuthMode >= Ndis802_11AuthModeWPA) >- { >- // Check AuthMode and AuthModeAux for matching, in case AP support dual-mode >- if ((pAd->PortCfg.AuthMode != pInBss->AuthMode) && (pAd->PortCfg.AuthMode != pInBss->AuthModeAux)) >- // None matched >- continue; >- >- // Check cipher suite, AP must have more secured cipher than station setting >- if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) >- { >- // If it's not mixed mode, we should only let BSS pass with the same encryption >- if (pInBss->WPA.bMixMode == FALSE) >- if (pAd->PortCfg.WepStatus != pInBss->WPA.GroupCipher) >- continue; >- >- // check group cipher >- if (pAd->PortCfg.WepStatus < pInBss->WPA.GroupCipher) >- continue; >- >- // check pairwise cipher, skip if none matched >- // If profile set to AES, let it pass without question. >- // If profile set to TKIP, we must find one mateched >- if ((pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && >- (pAd->PortCfg.WepStatus != pInBss->WPA.PairCipher) && >- (pAd->PortCfg.WepStatus != pInBss->WPA.PairCipherAux)) >- continue; >- } >- else if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) >- { >- // If it's not mixed mode, we should only let BSS pass with the same encryption >- if (pInBss->WPA2.bMixMode == FALSE) >- if (pAd->PortCfg.WepStatus != pInBss->WPA2.GroupCipher) >- continue; >- >- // check group cipher >- if (pAd->PortCfg.WepStatus < pInBss->WPA2.GroupCipher) >- continue; >- >- // check pairwise cipher, skip if none matched >- // If profile set to AES, let it pass without question. >- // If profile set to TKIP, we must find one mateched >- if ((pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && >- (pAd->PortCfg.WepStatus != pInBss->WPA2.PairCipher) && >- (pAd->PortCfg.WepStatus != pInBss->WPA2.PairCipherAux)) >- continue; >- } >- } >- // Bss Type matched, SSID matched. >- // We will check wepstatus for qualification Bss >- else if (pAd->PortCfg.WepStatus != pInBss->WepStatus) >- continue; >- >- // Since the AP is using hidden SSID, and we are trying to connect to ANY >- // It definitely will fail. So, skip it. >- // CCX also require not even try to connect it!! >- if (SsidLen == 0) >- continue; >- >- // copy matching BSS from InTab to OutTab >- NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY)); >- >- OutTab->BssNr++; >- } >- else if ((pInBss->BssType == pAd->PortCfg.BssType) && (SsidLen == 0)) >- { >- BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr]; >- >- // New for WPA2 >- // Check the Authmode first >- if (pAd->PortCfg.AuthMode >= Ndis802_11AuthModeWPA) >- { >- // Check AuthMode and AuthModeAux for matching, in case AP support dual-mode >- if ((pAd->PortCfg.AuthMode != pInBss->AuthMode) && (pAd->PortCfg.AuthMode != pInBss->AuthModeAux)) >- // None matched >- continue; >- >- // Check cipher suite, AP must have more secured cipher than station setting >- if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) >- { >- // If it's not mixed mode, we should only let BSS pass with the same encryption >- if (pInBss->WPA.bMixMode == FALSE) >- if (pAd->PortCfg.WepStatus != pInBss->WPA.GroupCipher) >- continue; >- >- // check group cipher >- if (pAd->PortCfg.WepStatus < pInBss->WPA.GroupCipher) >- continue; >- >- // check pairwise cipher, skip if none matched >- // If profile set to AES, let it pass without question. >- // If profile set to TKIP, we must find one mateched >- if ((pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && >- (pAd->PortCfg.WepStatus != pInBss->WPA.PairCipher) && >- (pAd->PortCfg.WepStatus != pInBss->WPA.PairCipherAux)) >- continue; >- } >- else if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) >- { >- // If it's not mixed mode, we should only let BSS pass with the same encryption >- if (pInBss->WPA2.bMixMode == FALSE) >- if (pAd->PortCfg.WepStatus != pInBss->WPA2.GroupCipher) >- continue; >- >- // check group cipher >- if (pAd->PortCfg.WepStatus < pInBss->WPA2.GroupCipher) >- continue; >- >- // check pairwise cipher, skip if none matched >- // If profile set to AES, let it pass without question. >- // If profile set to TKIP, we must find one mateched >- if ((pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && >- (pAd->PortCfg.WepStatus != pInBss->WPA2.PairCipher) && >- (pAd->PortCfg.WepStatus != pInBss->WPA2.PairCipherAux)) >- continue; >- } >- } >- // Bss Type matched, SSID matched. >- // We will check wepstatus for qualification Bss >- else if (pAd->PortCfg.WepStatus != pInBss->WepStatus) >- continue; >- >- // copy matching BSS from InTab to OutTab >- NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY)); >- >- OutTab->BssNr++; >- } >- >- if (OutTab->BssNr >= MAX_LEN_OF_BSS_TABLE) >- break; >- >- } >- BssTableSortByRssi(OutTab); >-} >- >- >- >- >-// IRQL = DISPATCH_LEVEL >-VOID BssTableSortByRssi( >- IN OUT BSS_TABLE *OutTab) >-{ >- INT i, j; >- BSS_ENTRY TmpBss; >- >- for (i = 0; i < OutTab->BssNr - 1; i++) >- { >- for (j = i+1; j < OutTab->BssNr; j++) >- { >- if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi) >- { >- NdisMoveMemory(&TmpBss, &OutTab->BssEntry[j], sizeof(BSS_ENTRY)); >- NdisMoveMemory(&OutTab->BssEntry[j], &OutTab->BssEntry[i], sizeof(BSS_ENTRY)); >- NdisMoveMemory(&OutTab->BssEntry[i], &TmpBss, sizeof(BSS_ENTRY)); >- } >- } >- } >-} >- >-extern UCHAR RSN_OUI[]; // in sanity.c >- >-VOID BssCipherParse( >- IN OUT PBSS_ENTRY pBss) >-{ >-#if 1 >- PBEACON_EID_STRUCT pEid; >- PUCHAR pTmp; >- PRSN_IE_HEADER_STRUCT pRsnHeader; >- PCIPHER_SUITE_STRUCT pCipher; >- PAKM_SUITE_STRUCT pAKM; >- USHORT Count; >- INT Length; >- NDIS_802_11_ENCRYPTION_STATUS TmpCipher; >- >- // Set default to disable & open authentication before parsing variable IE >- pBss->WepStatus = Ndis802_11WEPDisabled; >- pBss->AuthMode = Ndis802_11AuthModeOpen; >- pBss->AuthModeAux = Ndis802_11AuthModeOpen; >- >- // Init WPA setting >- pBss->WPA.PairCipher = Ndis802_11WEPDisabled; >- pBss->WPA.PairCipherAux = Ndis802_11WEPDisabled; >- pBss->WPA.GroupCipher = Ndis802_11WEPDisabled; >- pBss->WPA.RsnCapability = 0; >- pBss->WPA.bMixMode = FALSE; >- >- // Init WPA2 setting >- pBss->WPA2.PairCipher = Ndis802_11WEPDisabled; >- pBss->WPA2.PairCipherAux = Ndis802_11WEPDisabled; >- pBss->WPA2.GroupCipher = Ndis802_11WEPDisabled; >- pBss->WPA2.RsnCapability = 0; >- pBss->WPA2.bMixMode = FALSE; >- Length = (INT) pBss->VarIELen; >- >- while (Length > 0) >- { >- // Parse cipher suite base on WPA1 & WPA2, they should be parsed differently >- pTmp = ((PUCHAR) pBss->VarIEs) + pBss->VarIELen - Length; >- pEid = (PBEACON_EID_STRUCT) pTmp; >- switch (pEid->Eid) >- { >- case IE_WPA: >- // Skip OUI, version, and multicast suite >- // This part should be improved in the future when AP supported multiple cipher suite. >- // For now, it's OK since almost all APs have fixed cipher suite supported. >- // pTmp = (PUCHAR) pEid->Octet; >- pTmp += 11; >- >- // Cipher Suite Selectors from Spec P802.11i/D3.2 P26. >- // Value Meaning >- // 0 None >- // 1 WEP-40 >- // 2 Tkip >- // 3 WRAP >- // 4 AES >- // 5 WEP-104 >- // Parse group cipher >- switch (*pTmp) >- { >- case 1: >- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway >- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled; >- break; >- case 2: >- pBss->WPA.GroupCipher = Ndis802_11Encryption2Enabled; >- break; >- case 4: >- pBss->WPA.GroupCipher = Ndis802_11Encryption3Enabled; >- break; >- default: >- break; >- } >- // number of unicast suite >- pTmp += 1; >- >- // skip all unicast cipher suites >- Count = *(PUSHORT) pTmp; >- pTmp += sizeof(USHORT); >- >- // Parsing all unicast cipher suite >- while (Count > 0) >- { >- // Skip OUI >- pTmp += 3; >- TmpCipher = Ndis802_11WEPDisabled; >- switch (*pTmp) >- { >- case 1: >- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway >- TmpCipher = Ndis802_11Encryption1Enabled; >- break; >- case 2: >- TmpCipher = Ndis802_11Encryption2Enabled; >- break; >- case 4: >- TmpCipher = Ndis802_11Encryption3Enabled; >- break; >- default: >- break; >- } >- if (TmpCipher > pBss->WPA.PairCipher) >- { >- // Move the lower cipher suite to PairCipherAux >- pBss->WPA.PairCipherAux = pBss->WPA.PairCipher; >- pBss->WPA.PairCipher = TmpCipher; >- } >- else >- { >- pBss->WPA.PairCipherAux = TmpCipher; >- } >- pTmp++; >- Count--; >- } >- >- // 4. get AKM suite counts >- Count = *(PUSHORT) pTmp; >- pTmp += sizeof(USHORT); >- pTmp += 3; >- >- switch (*pTmp) >- { >- case 1: >- // Set AP support WPA mode >- if (pBss->AuthMode == Ndis802_11AuthModeOpen) >- pBss->AuthMode = Ndis802_11AuthModeWPA; >- else >- pBss->AuthModeAux = Ndis802_11AuthModeWPA; >- break; >- case 2: >- // Set AP support WPA mode >- if (pBss->AuthMode == Ndis802_11AuthModeOpen) >- pBss->AuthMode = Ndis802_11AuthModeWPAPSK; >- else >- pBss->AuthModeAux = Ndis802_11AuthModeWPAPSK; >- break; >- default: >- break; >- } >- pTmp += 1; >- >- // Fixed for WPA-None >- if (pBss->BssType == BSS_INDEP) >- { >- pBss->AuthMode = Ndis802_11AuthModeWPANone; >- pBss->AuthModeAux = Ndis802_11AuthModeWPANone; >- pBss->WepStatus = pBss->WPA.GroupCipher; >- // Patched bugs for old driver >- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled) >- pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher; >- } >- else >- pBss->WepStatus = pBss->WPA.PairCipher; >- >- // Check the Pair & Group, if different, turn on mixed mode flag >- if (pBss->WPA.GroupCipher != pBss->WPA.PairCipher) >- pBss->WPA.bMixMode = TRUE; >- >- break; >- >- case IE_RSN: >- pRsnHeader = (PRSN_IE_HEADER_STRUCT) pTmp; >- >- // 0. Version must be 1 >- if (pRsnHeader->Version != 1) >- break; >- pTmp += sizeof(RSN_IE_HEADER_STRUCT); >- >- // 1. Check group cipher >- pCipher = (PCIPHER_SUITE_STRUCT) pTmp; >- if (!RTMPEqualMemory(pTmp, RSN_OUI, 3)) >- break; >- >- // Parse group cipher >- switch (pCipher->Type) >- { >- case 1: >- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway >- pBss->WPA2.GroupCipher = Ndis802_11Encryption1Enabled; >- break; >- case 2: >- pBss->WPA2.GroupCipher = Ndis802_11Encryption2Enabled; >- break; >- case 4: >- pBss->WPA2.GroupCipher = Ndis802_11Encryption3Enabled; >- break; >- default: >- break; >- } >- // set to correct offset for next parsing >- pTmp += sizeof(CIPHER_SUITE_STRUCT); >- >- // 2. Get pairwise cipher counts >- Count = *(PUSHORT) pTmp; >- pTmp += sizeof(USHORT); >- >- // 3. Get pairwise cipher >- // Parsing all unicast cipher suite >- while (Count > 0) >- { >- // Skip OUI >- pCipher = (PCIPHER_SUITE_STRUCT) pTmp; >- TmpCipher = Ndis802_11WEPDisabled; >- switch (pCipher->Type) >- { >- case 1: >- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway >- TmpCipher = Ndis802_11Encryption1Enabled; >- break; >- case 2: >- TmpCipher = Ndis802_11Encryption2Enabled; >- break; >- case 4: >- TmpCipher = Ndis802_11Encryption3Enabled; >- break; >- default: >- break; >- } >- if (TmpCipher > pBss->WPA2.PairCipher) >- { >- // Move the lower cipher suite to PairCipherAux >- pBss->WPA2.PairCipherAux = pBss->WPA2.PairCipher; >- pBss->WPA2.PairCipher = TmpCipher; >- } >- else >- { >- pBss->WPA2.PairCipherAux = TmpCipher; >- } >- pTmp += sizeof(CIPHER_SUITE_STRUCT); >- Count--; >- } >- >- // 4. get AKM suite counts >- Count = *(PUSHORT) pTmp; >- pTmp += sizeof(USHORT); >- >- // 5. Get AKM ciphers >- pAKM = (PAKM_SUITE_STRUCT) pTmp; >- if (!RTMPEqualMemory(pTmp, RSN_OUI, 3)) >- break; >- >- switch (pAKM->Type) >- { >- case 1: >- // Set AP support WPA mode >- if (pBss->AuthMode == Ndis802_11AuthModeOpen) >- pBss->AuthMode = Ndis802_11AuthModeWPA2; >- else >- pBss->AuthModeAux = Ndis802_11AuthModeWPA2; >- break; >- case 2: >- // Set AP support WPA mode >- if (pBss->AuthMode == Ndis802_11AuthModeOpen) >- pBss->AuthMode = Ndis802_11AuthModeWPA2PSK; >- else >- pBss->AuthModeAux = Ndis802_11AuthModeWPA2PSK; >- break; >- default: >- break; >- } >- pTmp += (Count * sizeof(AKM_SUITE_STRUCT)); >- >- // Fixed for WPA-None >- if (pBss->BssType == BSS_INDEP) >- { >- pBss->AuthMode = Ndis802_11AuthModeWPANone; >- pBss->AuthModeAux = Ndis802_11AuthModeWPANone; >- pBss->WPA.PairCipherAux = pBss->WPA2.PairCipherAux; >- pBss->WPA.GroupCipher = pBss->WPA2.GroupCipher; >- pBss->WepStatus = pBss->WPA.GroupCipher; >- // Patched bugs for old driver >- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled) >- pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher; >- } >- pBss->WepStatus = pBss->WPA2.PairCipher; >- >- // 6. Get RSN capability >- pBss->WPA2.RsnCapability = *(PUSHORT) pTmp; >- pTmp += sizeof(USHORT); >- >- // Check the Pair & Group, if different, turn on mixed mode flag >- if (pBss->WPA2.GroupCipher != pBss->WPA2.PairCipher) >- pBss->WPA2.bMixMode = TRUE; >- >- break; >- >- default: >- break; >- } >- Length -= (pEid->Len + 2); >- } >-#endif >- return; >-} >- >-// =========================================================================================== >-// mac_table.c >-// =========================================================================================== >- >-/*! \brief generates a random mac address value for IBSS BSSID >- * \param Addr the bssid location >- * \return none >- * \pre >- * \post >- */ >-VOID MacAddrRandomBssid( >- IN PRT2570ADAPTER pAd, >- OUT MACADDR *Addr) >-{ >- INT i; >- >- for (i = 0; i < MAC_ADDR_LEN; i++) >- { >- Addr->Octet[i] = RandomByte(pAd); >- } >- >- Addr->Octet[0] = (Addr->Octet[0] & 0xfe) | 0x02; // the first 2 bits must be 01xxxxxxxx >-} >- >- >-/*! \brief init the management mac frame header >- * \param p_hdr mac header >- * \param subtype subtype of the frame >- * \param p_ds destination address, don't care if it is a broadcast address >- * \return none >- * \pre the station has the following information in the pAd->PortCfg >- * - bssid >- * - station address >- * \post >- * \note this function initializes the following field >- >- IRQL = PASSIVE_LEVEL >- IRQL = DISPATCH_LEVEL >- >- */ >-VOID MgtMacHeaderInit( >- IN PRT2570ADAPTER pAd, >- IN OUT PMACHDR Hdr, >- IN UCHAR Subtype, >- IN UCHAR ToDs, >- IN PMACADDR Ds, >- IN PMACADDR Bssid) >-{ >- NdisZeroMemory(Hdr, sizeof(MACHDR)); >- Hdr->Type = BTYPE_MGMT; >- Hdr->SubType = Subtype; >- Hdr->Tods = ToDs; >- COPY_MAC_ADDR(&Hdr->Addr1, Ds); >- COPY_MAC_ADDR(&Hdr->Addr2, &pAd->CurrentAddress); >- COPY_MAC_ADDR(&Hdr->Addr3, Bssid); >-} >- >- >- >-// =========================================================================================== >-// mem_mgmt.c >-// =========================================================================================== >- >-/*!*************************************************************************** >- * This routine build an outgoing frame, and fill all information specified >- * in argument list to the frame body. The actual frame size is the summation >- * of all arguments. >- * input params: >- * Buffer - pointer to a pre-allocated memory segment >- * args - a list of <int arg_size, arg> pairs. >- * NOTE NOTE NOTE!!!! the last argument must be NULL, otherwise this >- * function will FAIL!!! >- * return: >- * Size of the buffer >- * usage: >- * MakeOutgoingFrame(Buffer, output_length, 2, &fc, 2, &dur, 6, p_addr1, 6,p_addr2, END_OF_ARGS); >- >- IRQL = PASSIVE_LEVEL >- IRQL = DISPATCH_LEVEL >- >- ****************************************************************************/ >-ULONG MakeOutgoingFrame( >- OUT CHAR *Buffer, >- OUT ULONG *FrameLen, ...) >-{ >- CHAR *p; >- int leng; >- ULONG TotLeng; >- va_list Args; >- >- // calculates the total length >- TotLeng = 0; >- va_start(Args, FrameLen); >- do >- { >- leng = va_arg(Args, int); >- if (leng == END_OF_ARGS) >- { >- break; >- } >- p = va_arg(Args, PVOID); >- NdisMoveMemory(&Buffer[TotLeng], p, leng); >- TotLeng = TotLeng + leng; >- } while(TRUE); >- >- va_end(Args); /* clean up */ >- *FrameLen = TotLeng; >- return TotLeng; >-} >- >-// =========================================================================================== >-// mlme_queue.c >-// =========================================================================================== >- >-/*! \brief Initialize The MLME Queue, used by MLME Functions >- * \param *Queue The MLME Queue >- * \return Always Return NDIS_STATE_SUCCESS in this implementation >- * \pre >- * \post >- * \note Because this is done only once (at the init stage), no need to be locked >- */ >-NDIS_STATUS MlmeQueueInit( >- IN MLME_QUEUE *Queue) >-{ >- INT i; >- >- DBGPRINT(RT_DEBUG_INFO,"--> MlmeQueueInit\n"); >- >- NdisAllocateSpinLock(&Queue->Lock); >- Queue->Num = 0; >- Queue->Head = 0; >- Queue->Tail = 0; >- >- for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++) >- { >- Queue->Entry[i].Occupied = FALSE; >- Queue->Entry[i].MsgLen = 0; >- NdisZeroMemory(Queue->Entry[i].Msg, MAX_LEN_OF_MLME_BUFFER); >- } >- >- DBGPRINT(RT_DEBUG_INFO,"<-- MlmeQueueInit\n"); >- return NDIS_STATUS_SUCCESS; >-} >- >-BOOLEAN MlmeEnqueue( >- IN PRT2570ADAPTER pAd, >- IN ULONG Machine, >- IN ULONG MsgType, >- IN ULONG MsgLen, >- IN VOID *Msg) >-{ >- INT Tail; >- MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue; >- >- if (pAd->MLMEThr_pid > 0) >- { >- >- if (MlmeQueueFull(Queue)) >- { >- DBGPRINT(RT_DEBUG_ERROR,"MlmeEnqueue full, msg dropped and may corrupt MLME\n"); >- return FALSE; >- } >- >- NdisAcquireSpinLock(&(Queue->Lock)); >- Tail = Queue->Tail; >- Queue->Tail++; >- Queue->Num++; >- if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE) >- { >- Queue->Tail = 0; >- } >- NdisReleaseSpinLock(&(Queue->Lock)); >- DBGPRINT(RT_DEBUG_INFO,"MlmeEnqueue, num=%d\n",Queue->Num); >- >- Queue->Entry[Tail].Occupied = TRUE; >- Queue->Entry[Tail].Machine = Machine; >- Queue->Entry[Tail].MsgType = MsgType; >- Queue->Entry[Tail].MsgLen = MsgLen; >- NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen); >- } >- return TRUE; >-} >- >- >-/*! \brief This function is used when Recv gets a MLME message >- * \param *Queue The MLME Queue >- * \param TimeStampHigh The upper 32 bit of timestamp >- * \param TimeStampLow The lower 32 bit of timestamp >- * \param Rssi The receiving RSSI strength >- * \param MsgLen The length of the message >- * \param *Msg The message pointer >- * \return TRUE if everything ok, FALSE otherwise (like Queue Full) >- * \pre >- * \post >- >- IRQL = DISPATCH_LEVEL >- >- */ >-BOOLEAN MlmeEnqueueForRecv( >- IN PRT2570ADAPTER pAd, >- OUT MLME_QUEUE *Queue, >- IN UCHAR Rssi, >- IN ULONG MsgLen, >- IN VOID *Msg) >-{ >- INT Tail, Machine; >- MACFRAME *Fr = (MACFRAME *)Msg; >- ULONG MsgType; >- >- //DBGPRINT(RT_DEBUG_ERROR,"MlmeEnqueueForRecv "); >- if((pAd->MLMEThr_pid <= 0)) >- return FALSE; >- // First check the size, it MUST not exceed the mlme queue size >- if (MsgLen > MAX_LEN_OF_MLME_BUFFER) >- { >- DBGPRINT(RT_DEBUG_ERROR, "MlmeEnqueueForRecv mlme frame too large, size = %d \n", MsgLen); >- return FALSE; >- } >- >- if ((RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) || >- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS)) || >- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) || >- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))) >- { >- DBGPRINT(RT_DEBUG_TRACE, "MlmeEnqueueForRecv (not in operation) Flag = 0x%x\n", pAd->Flags); >- return FALSE; >- } >- >- if (MlmeQueueFull(Queue)) >- { >- //DBGPRINT(RT_DEBUG_ERROR, "MlmeEnqueueForRecv (queue full error) \n"); >- return FALSE; >- } >- >- if (!MsgTypeSubst(pAd, Fr, &Machine, &MsgType)) >- { >- DBGPRINT(RT_DEBUG_ERROR, "MlmeEnqueueForRecv (drop mgmt->subtype=%d)\n",Fr->Hdr.SubType); >- return FALSE; >- } >- >- // OK, we got all the informations, it is time to put things into queue >- NdisAcquireSpinLock(&(Queue->Lock)); >- Tail = Queue->Tail; >- Queue->Tail++; >- Queue->Num++; >- if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE) >- { >- Queue->Tail = 0; >- } >- NdisReleaseSpinLock(&(Queue->Lock)); >- DBGPRINT(RT_DEBUG_INFO, "MlmeEnqueueForRecv, num=%d\n",Queue->Num); >- >- Queue->Entry[Tail].Occupied = TRUE; >- Queue->Entry[Tail].Machine = Machine; >- Queue->Entry[Tail].MsgType = MsgType; >- Queue->Entry[Tail].MsgLen = MsgLen; >- >- Queue->Entry[Tail].Rssi = Rssi; >- NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen); >- >- RTUSBUp(pAd, (&(pAd->mlme_semaphore))); >- >- return TRUE; >-} >-/*! \brief Dequeue a message from the MLME Queue >- * \param *Queue The MLME Queue >- * \param *Elem The message dequeued from MLME Queue >- * \return TRUE if the Elem contains something, FALSE otherwise >- * \pre >- * \post >- >- IRQL = DISPATCH_LEVEL >- >- */ >-BOOLEAN MlmeDequeue( >- IN MLME_QUEUE *Queue, >- OUT MLME_QUEUE_ELEM **Elem) >-{ >- NdisAcquireSpinLock(&(Queue->Lock)); >- if (Queue->Num == 0) >- { >- NdisReleaseSpinLock(&(Queue->Lock)); >- return FALSE; //Empty >- } >- >- *Elem = &(Queue->Entry[Queue->Head]); >- Queue->Num--; >- Queue->Head++; >- if (Queue->Head == MAX_LEN_OF_MLME_QUEUE) >- { >- Queue->Head = 0; >- } >- >- NdisReleaseSpinLock(&(Queue->Lock)); >- DBGPRINT(RT_DEBUG_INFO, "MlmeDequeue, num=%d\n",Queue->Num); >- >- return TRUE; >-} >- >-// IRQL = DISPATCH_LEVEL >-VOID MlmeRestartStateMachine( >- IN PRT2570ADAPTER pAd) >-{ >- >- DBGPRINT(RT_DEBUG_TRACE, "==> MlmeRestartStateMachine\n"); >- >- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS); >- >- NdisAcquireSpinLock(&pAd->Mlme.TaskLock); >- if(pAd->Mlme.Running) >- { >- DBGPRINT(RT_DEBUG_TRACE, "<== MlmeRestartStateMachine, Mlme is Runing[Queue=%d]!\n", pAd->Mlme.Queue.Num); >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- return; >- } >- pAd->Mlme.Running = TRUE; >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- >- MlmeQueueDestroy(&pAd->Mlme.Queue); >- >- // Cancel all timer events >- // Be careful to cancel new added timer >- RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AssocAux.DisassocTimer); >- RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer); >- // RTMPCancelTimer(&pAd->Mlme.AuthRspAux.AuthRspTimer, &Cancelled); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer); >- >- // Set all state machines back IDLE >- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; >- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; >- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE; >- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE; >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS);//steven:for test >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);//steven:for test >- >- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS); >- >- // Remove running state >- NdisAcquireSpinLock(&pAd->Mlme.TaskLock); >- pAd->Mlme.Running = FALSE; >- NdisReleaseSpinLock(&pAd->Mlme.TaskLock); >- >- DBGPRINT(RT_DEBUG_TRACE, "<== MlmeRestartStateMachine\n"); >-} >- >-VOID MlmePostRestartStateMachine( >- IN PRT2570ADAPTER pAd) >-{ >- // >- // Flag fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS will be clear at MlmeHandler >- // when required to do MLME Reset! >- // Since MlmeRestartStateMachine will do nothing when Mlme is running. >- // >- while (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS)) >- NdisMSleep(100); >- >- // Change back to original channel in case of doing scan >- AsicSwitchChannel(pAd, pAd->PortCfg.Channel); >- AsicLockChannel(pAd, pAd->PortCfg.Channel); >- >- // Resume MSDU which is turned off durning scan >- RTUSBResumeMsduTransmission(pAd); >-} >- >-/*! \brief test if the MLME Queue is empty >- * \param *Queue The MLME Queue >- * \return TRUE if the Queue is empty, FALSE otherwise >- * \pre >- * \post >- >- IRQL = DISPATCH_LEVEL >- >- */ >-BOOLEAN MlmeQueueEmpty( >- IN MLME_QUEUE *Queue) >-{ >- BOOLEAN Ans; >- >- NdisAcquireSpinLock(&(Queue->Lock)); >- Ans = (Queue->Num == 0); >- NdisReleaseSpinLock(&(Queue->Lock)); >- >- return Ans; >-} >- >- >-/*! \brief test if the MLME Queue is full >- * \param *Queue The MLME Queue >- * \return TRUE if the Queue is empty, FALSE otherwise >- * \pre >- * \post >- >- IRQL = PASSIVE_LEVEL >- IRQL = DISPATCH_LEVEL >- >- */ >-BOOLEAN MlmeQueueFull( >- IN MLME_QUEUE *Queue) >-{ >- BOOLEAN Ans; >- >- NdisAcquireSpinLock(&(Queue->Lock)); >- Ans = (Queue->Num == MAX_LEN_OF_MLME_QUEUE); >- NdisReleaseSpinLock(&(Queue->Lock)); >- >- return Ans; >-} >- >-/*! \brief The destructor of MLME Queue >- * \param >- * \return >- * \pre >- * \post >- * \note Clear Mlme Queue, Set Queue->Num to Zero. >- >- IRQL = PASSIVE_LEVEL >- >- */ >-VOID MlmeQueueDestroy( >- IN MLME_QUEUE *Queue) >-{ >- NdisAcquireSpinLock(&(Queue->Lock)); >- Queue->Num = 0; >- Queue->Head = 0; >- Queue->Tail = 0; >- NdisReleaseSpinLock(&(Queue->Lock)); >-} >- >-/*! \brief To substitute the message type if the message is coming from external >- * \param *Fr The frame received >- * \param *Machine The state machine >- * \param *MsgType the message type for the state machine >- * \return TRUE if the substitution is successful, FALSE otherwise >- * \pre >- * \post >- >- IRQL = DISPATCH_LEVEL >- >- */ >-BOOLEAN MsgTypeSubst( >- IN PRT2570ADAPTER pAd, >- IN MACFRAME *Fr, >- OUT INT *Machine, >- OUT INT *MsgType) >-{ >- USHORT Seq; >- UCHAR EAPType; >- PHEADER_802_11 pHeader; >- >- // The only data type will pass to this function is EAPOL frame >- if (Fr->Hdr.Type == BTYPE_DATA) >- { >- *Machine = WPA_PSK_STATE_MACHINE; >- >- pHeader = (PHEADER_802_11)Fr; >- >- if( (pAd->PortCfg.CipherAlg == CIPHER_TKIP || pAd->PortCfg.CipherAlg == CIPHER_AES) && pHeader->Controlhead.Frame.Wep) >- EAPType = *((UCHAR*)Fr + LENGTH_802_11 + 8 + LENGTH_802_1_H + 1);//8 is IV + EIV >- else >- EAPType = *((UCHAR*)Fr + LENGTH_802_11 + LENGTH_802_1_H + 1); >- >- >- return(WpaMsgTypeSubst(EAPType, MsgType)); >- } >- >- >- switch (Fr->Hdr.SubType) >- { >- case SUBTYPE_ASSOC_REQ: >- *Machine = ASSOC_STATE_MACHINE; >- *MsgType = MT2_PEER_ASSOC_REQ; >- break; >- case SUBTYPE_ASSOC_RSP: >- *Machine = ASSOC_STATE_MACHINE; >- *MsgType = MT2_PEER_ASSOC_RSP; >- break; >- case SUBTYPE_REASSOC_REQ: >- *Machine = ASSOC_STATE_MACHINE; >- *MsgType = MT2_PEER_REASSOC_REQ; >- break; >- case SUBTYPE_REASSOC_RSP: >- *Machine = ASSOC_STATE_MACHINE; >- *MsgType = MT2_PEER_REASSOC_RSP; >- break; >- case SUBTYPE_PROBE_REQ: >- *Machine = SYNC_STATE_MACHINE; >- *MsgType = MT2_PEER_PROBE_REQ; >- break; >- case SUBTYPE_PROBE_RSP: >- *Machine = SYNC_STATE_MACHINE; >- *MsgType = MT2_PEER_PROBE_RSP; >- break; >- case SUBTYPE_BEACON: >- *Machine = SYNC_STATE_MACHINE; >- *MsgType = MT2_PEER_BEACON; >- break; >- case SUBTYPE_ATIM: >- *Machine = SYNC_STATE_MACHINE; >- *MsgType = MT2_PEER_ATIM; >- break; >- case SUBTYPE_DISASSOC: >- *Machine = ASSOC_STATE_MACHINE; >- *MsgType = MT2_PEER_DISASSOC_REQ; >- break; >- case SUBTYPE_AUTH: >- // get the sequence number from payload 24 Mac Header + 2 bytes algorithm >- NdisMoveMemory(&Seq, &Fr->Octet[2], sizeof(USHORT)); >- if (Seq == 1 || Seq == 3) >- { >- *Machine = AUTH_RSP_STATE_MACHINE; >- *MsgType = MT2_PEER_AUTH_ODD; >- } >- else if (Seq == 2 || Seq == 4) >- { >- *Machine = AUTH_STATE_MACHINE; >- *MsgType = MT2_PEER_AUTH_EVEN; >- } >- else >- { >- return FALSE; >- } >- break; >- case SUBTYPE_DEAUTH: >- *Machine = AUTH_RSP_STATE_MACHINE; >- *MsgType = MT2_PEER_DEAUTH; >- break; >- default: >- return FALSE; >- break; >- } >- >- return TRUE; >-} >- >-// =========================================================================================== >-// state_machine.c >-// =========================================================================================== >- >-/*! \brief Initialize the state machine. >- * \param *S pointer to the state machine >- * \param Trans State machine transition function >- * \param StNr number of states >- * \param MsgNr number of messages >- * \param DefFunc default function, when there is invalid state/message combination >- * \param InitState initial state of the state machine >- * \param Base StateMachine base, internal use only >- * \pre p_sm should be a legal pointer >- * \post >- >- IRQL = PASSIVE_LEVEL >- >- */ >- >-VOID StateMachineInit( >- IN STATE_MACHINE *S, >- IN STATE_MACHINE_FUNC Trans[], >- IN ULONG StNr, >- IN ULONG MsgNr, >- IN STATE_MACHINE_FUNC DefFunc, >- IN ULONG InitState, >- IN ULONG Base) >-{ >- ULONG i, j; >- >- // set number of states and messages >- S->NrState = StNr; >- S->NrMsg = MsgNr; >- S->Base = Base; >- >- S->TransFunc = Trans; >- >- // init all state transition to default function >- for (i = 0; i < StNr; i++) >- { >- for (j = 0; j < MsgNr; j++) >- { >- S->TransFunc[i * MsgNr + j] = DefFunc; >- } >- } >- >- // set the starting state >- S->CurrState = InitState; >-} >- >- >-/*! \brief This function fills in the function pointer into the cell in the state machine >- * \param *S pointer to the state machine >- * \param St state >- * \param Msg incoming message >- * \param f the function to be executed when (state, message) combination occurs at the state machine >- * \pre *S should be a legal pointer to the state machine, st, msg, should be all within the range, Base should be set in the initial state >- * \post >- >- IRQL = PASSIVE_LEVEL >- >- */ >-VOID StateMachineSetAction( >- IN STATE_MACHINE *S, >- IN ULONG St, >- IN ULONG Msg, >- IN STATE_MACHINE_FUNC Func) >-{ >- ULONG MsgIdx; >- >- MsgIdx = Msg - S->Base; >- >- if (St < S->NrState && MsgIdx < S->NrMsg) >- { >- // boundary checking before setting the action >- S->TransFunc[St * S->NrMsg + MsgIdx] = Func; >- } >-} >- >-/*! \brief The destructor of the state machine >- * \param *S the statemachine >- * \note doing nothing at this moment, may need to do something if the implementation changed >- >- IRQL = PASSIVE_LEVEL >- >- */ >-VOID >-StateMachineDestroy(IN STATE_MACHINE *S) >-{ >-} >-/*! \brief This function does the state transition >- * \param *Adapter the NIC adapter pointer >- * \param *S the state machine >- * \param *Elem the message to be executed >- * \return None >- >- IRQL = DISPATCH_LEVEL >- >- */ >-VOID StateMachinePerformAction( >- IN PRT2570ADAPTER pAd, >- IN STATE_MACHINE *S, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- (*(S->TransFunc[S->CurrState * S->NrMsg + Elem->MsgType - S->Base]))(pAd, Elem); >-} >- >-/* >- ========================================================================== >- Description: >- The drop function, when machine executes this, the message is simply >- ignored. This function does nothing, the message is freed in >- StateMachinePerformAction() >- ========================================================================== >- */ >-VOID Drop( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >-} >- >-/* >- ========================================================================== >- Description: >- >- IRQL = PASSIVE_LEVEL >- >- ========================================================================== >- */ >-VOID LfsrInit( >- IN PRT2570ADAPTER pAd, >- IN ULONG Seed) >-{ >- if (Seed == 0) >- pAd->Mlme.ShiftReg = 1; >- else >- pAd->Mlme.ShiftReg = Seed; >-} >- >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-UCHAR RandomByte( >- IN PRT2570ADAPTER pAd) >-{ >- ULONG i; >- UCHAR R, Result; >- >- R = 0; >- >- for (i = 0; i < 8; i++) >- { >- if (pAd->Mlme.ShiftReg & 0x00000001) >- { >- pAd->Mlme.ShiftReg = ((pAd->Mlme.ShiftReg ^ LFSR_MASK) >> 1) | 0x80000000; >- Result = 1; >- } >- else >- { >- pAd->Mlme.ShiftReg = pAd->Mlme.ShiftReg >> 1; >- Result = 0; >- } >- R = (R << 1) | Result; >- } >- >- return R; >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID AsicSwitchChannel( >- IN PRT2570ADAPTER pAd, >- IN UCHAR Channel) >-{ >- ULONG R3; >- UCHAR index; >- >- // TODO: need to update E2PROM format to add 802.11a channel's TX power calibration values >- if (Channel <= 14) >- R3 = pAd->PortCfg.ChannelTxPower[Channel - 1]; >- else >- R3 = pAd->PortCfg.ChannelTxPower[0]; >- >- if (R3 > 31) R3 = 31; >- >- // E2PROM setting is calibrated for maximum TX power (i.e. 100%) >- // We lower TX power here according to the percentage specified from UI >- if (pAd->PortCfg.TxPowerPercentage > 90) // 91 ~ 100%, treat as 100% in terms of mW >- ; >- else if (pAd->PortCfg.TxPowerPercentage > 60) // 61 ~ 90%, treat as 75% in terms of mW >- R3 -= 1; >- else if (pAd->PortCfg.TxPowerPercentage > 30) // 31 ~ 60%, treat as 50% in terms of mW >- R3 -= 3; >- else if (pAd->PortCfg.TxPowerPercentage > 15) // 16 ~ 30%, treat as 25% in terms of mW >- R3 -= 6; >- else if (pAd->PortCfg.TxPowerPercentage > 9) // 10 ~ 15%, treat as 12.5% in terms of mW >- R3 -= 9; >- else // 0 ~ 9 %, treat as 6.25% in terms of mW >- R3 -= 12; >- >- R3 = R3 << 9; // shift TX power control to correct RF R3 bit position >- switch (pAd->PortCfg.RfType) >- { >- case RFIC_2522: >- for (index = 0; index < NUM_OF_2522_CHNL; index++) >- { >- if (Channel == RF2522RegTable[index].Channel) >- { >- R3 = R3 | RF2522RegTable[index].R3; // set TX power >- RTUSBWriteRFRegister(pAd, RF2522RegTable[index].R1); >- RTUSBWriteRFRegister(pAd, RF2522RegTable[index].R2); >- RTUSBWriteRFRegister(pAd, R3); >- pAd->PortCfg.LatchRfRegs.Channel = Channel; >- pAd->PortCfg.LatchRfRegs.R1 = RF2522RegTable[index].R1; >- pAd->PortCfg.LatchRfRegs.R2 = RF2522RegTable[index].R2; >- pAd->PortCfg.LatchRfRegs.R3 = R3; >- pAd->PortCfg.LatchRfRegs.R4 = RF2522RegTable[index].R4; >- break; >- } >- } >- break; >- >- case RFIC_2523: >- for (index = 0; index < NUM_OF_2523_CHNL; index++) >- { >- if (Channel == RF2523RegTable[index].Channel) >- { >- R3 = R3 | RF2523RegTable[index].R3; // set TX power >- RTUSBWriteRFRegister(pAd, RF2523RegTable[index].R1); >- RTUSBWriteRFRegister(pAd, RF2523RegTable[index].R2); >- RTUSBWriteRFRegister(pAd, R3); >- RTUSBWriteRFRegister(pAd, RF2523RegTable[index].R4); >- pAd->PortCfg.LatchRfRegs.Channel = Channel; >- pAd->PortCfg.LatchRfRegs.R1 = RF2523RegTable[index].R1; >- pAd->PortCfg.LatchRfRegs.R2 = RF2523RegTable[index].R2; >- pAd->PortCfg.LatchRfRegs.R3 = R3; >- pAd->PortCfg.LatchRfRegs.R4 = RF2523RegTable[index].R4; >- break; >- } >- } >- break; >- >- case RFIC_2524: >- for (index = 0; index < NUM_OF_2524_CHNL; index++) >- { >- if (Channel == RF2524RegTable[index].Channel) >- { >- R3 = R3 | RF2524RegTable[index].R3; // set TX power >- RTUSBWriteRFRegister(pAd, RF2524RegTable[index].R1); >- RTUSBWriteRFRegister(pAd, RF2524RegTable[index].R2); >- RTUSBWriteRFRegister(pAd, R3); >- RTUSBWriteRFRegister(pAd, RF2524RegTable[index].R4); >- pAd->PortCfg.LatchRfRegs.Channel = Channel; >- pAd->PortCfg.LatchRfRegs.R1 = RF2524RegTable[index].R1; >- pAd->PortCfg.LatchRfRegs.R2 = RF2524RegTable[index].R2; >- pAd->PortCfg.LatchRfRegs.R3 = R3; >- pAd->PortCfg.LatchRfRegs.R4 = RF2524RegTable[index].R4; >- break; >- } >- } >- break; >- >- case RFIC_2525: >- for (index = 0; index < NUM_OF_2525_CHNL; index++) >- { >- if (Channel == RF2525RegTable[index].Channel) >- { >- R3 = R3 | RF2525RegTable[index].R3; // set TX power >- RTUSBWriteRFRegister(pAd, RF2525RegTable[index].R1); >- >- RTUSBWriteRFRegister(pAd, RF2525RegTable[index].R2); >- >- RTUSBWriteRFRegister(pAd, R3); >- >- RTUSBWriteRFRegister(pAd, RF2525RegTable[index].R4); >- >- pAd->PortCfg.LatchRfRegs.Channel = Channel; >- pAd->PortCfg.LatchRfRegs.R1 = RF2525RegTable[index].R1; >- pAd->PortCfg.LatchRfRegs.R2 = RF2525RegTable[index].R2; >- pAd->PortCfg.LatchRfRegs.R3 = R3; >- pAd->PortCfg.LatchRfRegs.R4 = RF2525RegTable[index].R4; >- break; >- } >- } >- break; >- >- case RFIC_2525E: >- for (index = 0; index < NUM_OF_2525E_CHNL; index++) >- { >- if (Channel == RF2525eRegTable[index].Channel) >- { >- RTUSBWriteRFRegister(pAd, RF2525eRegTable[index].TempR2); >- RTUSBWriteRFRegister(pAd, RF2525eRegTable[index].R4); >- R3 = R3 | RF2525eRegTable[index].R3; // set TX power >- RTUSBWriteRFRegister(pAd, RF2525eRegTable[index].R1); >- RTUSBWriteRFRegister(pAd, RF2525eRegTable[index].R2); >- RTUSBWriteRFRegister(pAd, R3); >- RTUSBWriteRFRegister(pAd, RF2525eRegTable[index].R4); >- pAd->PortCfg.LatchRfRegs.Channel = Channel; >- pAd->PortCfg.LatchRfRegs.R1 = RF2525eRegTable[index].R1; >- pAd->PortCfg.LatchRfRegs.R2 = RF2525eRegTable[index].R2; >- pAd->PortCfg.LatchRfRegs.R3 = R3; >- pAd->PortCfg.LatchRfRegs.R4 = RF2525eRegTable[index].R4; >- break; >- } >- } >- break; >- >- case RFIC_5222: >- for (index = 0; index < NUM_OF_5222_CHNL; index++) >- { >- if (Channel == RF5222RegTable[index].Channel) >- { >- R3 = R3 | RF5222RegTable[index].R3; // set TX power >- RTUSBWriteRFRegister(pAd, RF5222RegTable[index].R1); >- RTUSBWriteRFRegister(pAd, RF5222RegTable[index].R2); >- RTUSBWriteRFRegister(pAd, R3); >- RTUSBWriteRFRegister(pAd, RF5222RegTable[index].R4); >- pAd->PortCfg.LatchRfRegs.Channel = Channel; >- pAd->PortCfg.LatchRfRegs.R1 = RF5222RegTable[index].R1; >- pAd->PortCfg.LatchRfRegs.R2 = RF5222RegTable[index].R2; >- pAd->PortCfg.LatchRfRegs.R3 = R3; >- pAd->PortCfg.LatchRfRegs.R4 = RF5222RegTable[index].R4; >- break; >- } >- } >- break; >- >- default: >- break; >- } >- >- DBGPRINT(RT_DEBUG_INFO, "AsicSwitchChannel(RF=%d) to #%d, TXPwr=%x%% = %x, R1=0x%08x, R2=0x%08x, R3=0x%08x, R4=0x%08x\n", >- pAd->PortCfg.RfType, >- pAd->PortCfg.LatchRfRegs.Channel, >- pAd->PortCfg.TxPowerPercentage, >- pAd->PortCfg.ChannelTxPower[Channel - 1], >- pAd->PortCfg.LatchRfRegs.R1, >- pAd->PortCfg.LatchRfRegs.R2, >- pAd->PortCfg.LatchRfRegs.R3, >- pAd->PortCfg.LatchRfRegs.R4); >- >-} >- >- >- >-/* >- ========================================================================== >- Description: >- This function is required for 2421 only, and should not be used during >- site survey. It's only required after NIC decided to stay at a channel >- for a longer period. >- When this function is called, it's always after AsicSwitchChannel(). >- ========================================================================== >- */ >-VOID AsicLockChannel( >- IN PRT2570ADAPTER pAd, >- IN ULONG Channel) >-{ >- UCHAR r70; >- USHORT RxFailCnt; >- >- return; >- RTUSBReadBBPRegister(pAd, 70, &r70); >- if (Channel == 14) >- r70 |= 0x08; // turn on Japan filter bit >- else >- r70 &= 0xf7; // turn off Japan filter bit >- RTUSBWriteBBPRegister(pAd, 70, r70); >- >- // Clear false CRC durning switch channel >- RTUSBReadMACRegister(pAd, STA_CSR0, &RxFailCnt); >- >- >- NdisMSleep(10); >- >- switch (pAd->PortCfg.RfType) >- { >- case RFIC_2522: >- case RFIC_2524: >- case RFIC_2525: >- case RFIC_5222: >- case RFIC_2525E: >- pAd->PortCfg.LatchRfRegs.R1 &= 0xfffdffff; // RF R1.bit17 "tune_en1" OFF >- pAd->PortCfg.LatchRfRegs.R3 &= 0xfffffeff; // RF R3.bit8 "tune_en2" OFF >- RTUSBWriteRFRegister(pAd, pAd->PortCfg.LatchRfRegs.R1); >- RTUSBWriteRFRegister(pAd, pAd->PortCfg.LatchRfRegs.R3); >- DBGPRINT(RT_DEBUG_INFO, "AsicRfTuningExec(R1=0x%x,R3=0x%x)\n",pAd->PortCfg.LatchRfRegs.R1,pAd->PortCfg.LatchRfRegs.R3); >- break; >- >- case RFIC_2523: >- pAd->PortCfg.LatchRfRegs.R3 &= 0xfffffeff; // RF R3.bit8 "tune_en2" OFF >- RTUSBWriteRFRegister(pAd, pAd->PortCfg.LatchRfRegs.R3); >- DBGPRINT(RT_DEBUG_INFO, "AsicRfTuningExec(R3=0x%x)\n",pAd->PortCfg.LatchRfRegs.R3); >- break; >- >- default: >- break; >- } >-} >- >-/* >- ========================================================================== >- Description: >- Gives CCK TX rate 2 more dB TX power. >- This routine works only in LINK UP in INFRASTRUCTURE mode. >- >- calculate desired Tx power in RF R3.Tx0~5, should consider - >- 1. TxPowerPercentage >- 2. auto calibration based on TSSI feedback >- 3. extra 2 db for CCK >- 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP >- ========================================================================== >- */ >-VOID AsicAdjustTxPower( >- IN PRT2570ADAPTER pAd) >-{ >- ULONG R3, Channel, CurrTxPwr; >- >- if ((pAd->PortCfg.Channel >= 1) && (pAd->PortCfg.Channel <= 14)) >- Channel = pAd->PortCfg.Channel; >- else >- Channel = 1; // don't have calibration info for 11A, temporarily use Channel 1 >- >- // get TX Power base from E2PROM >- R3 = pAd->PortCfg.ChannelTxPower[Channel - 1]; >- if (R3 > 31) R3 = 31; >- >- // E2PROM setting is calibrated for maximum TX power (i.e. 100%) >- // We lower TX power here according to the percentage specified from UI >- if (pAd->PortCfg.TxPowerPercentage == 0xffffffff) // AUTO TX POWER control >- { >- // only INFRASTRUCTURE mode and 100% TX power need furthur calibration >- if (pAd->MediaState == NdisMediaStateConnected) >- { >- // low TX power upon very-short distance to AP to solve some vendor's AP RX problem >- // in this case, no TSSI compensation is required. >- if ((pAd->DrsCounters.fNoisyEnvironment == FALSE) && >- (pAd->PortCfg.AvgRssi > (pAd->BBPTuningParameters.RSSIToDbmOffset - RSSI_FOR_LOWEST_TX_POWER))) >- R3 -= LOWEST_TX_POWER_DELTA; >- else if ((pAd->DrsCounters.fNoisyEnvironment == FALSE) && >- (pAd->PortCfg.AvgRssi > (pAd->BBPTuningParameters.RSSIToDbmOffset - RSSI_FOR_LOW_TX_POWER))) >- R3 -= LOW_TX_POWER_DELTA; >- // 2004-03-16 give OFDM rates lower than 48 mbps 2 more DB >- else if ((pAd->PortCfg.TxRate <= RATE_36) && (pAd->PortCfg.TxRate > RATE_11)) >- { >- R3 +=2; >- if (R3 > 31) R3 = 31; >- } >- >- >- // 2 exclusive rules applied on CCK rates only - >- // 1. always plus 2 db for CCK >- // 2. adjust TX Power based on TSSI >- else >- if (pAd->PortCfg.TxRate <= RATE_11) >- { >- // if "auto calibration based on TSSI" is not required, then >- // always give CCK 2 more db >- if (pAd->PortCfg.bAutoTxAgc == FALSE) >- { >- // do not give RATE_11 2 more db to avoid the case that >- // the outgoing NULL frame (for rate upgrade evaluation) >- // using 12 Mbps OFDM rate is over-powered >- if (pAd->PortCfg.TxRate <= RATE_5_5) >- { >- R3 += 2; // plus 2 db >- if (R3 > 31) R3 = 31; >- } >- } >- >- // Auto calibrate Tx AGC if bAutoTxAgc is TRUE and TX rate is CCK, >- // because E2PROM's TSSI reference is valid only in CCK range. >- else >- { >- UCHAR R1,TxPowerRef, TssiRef; >- >- R3 = (pAd->PortCfg.LatchRfRegs.R3 >> 9) & 0x0000001f; >- if (pAd->Mlme.PeriodicRound % 4 == 0) // every 4 second >- { >- TxPowerRef = pAd->PortCfg.ChannelTxPower[Channel - 1]; >- TssiRef = pAd->PortCfg.ChannelTssiRef[Channel - 1]; >- RTUSBReadBBPRegister(pAd, BBP_Tx_Tssi, &R1); >- if ((TssiRef >= (R1 + pAd->PortCfg.ChannelTssiDelta)) || >- (TssiRef <= (R1 - pAd->PortCfg.ChannelTssiDelta))) >- { >- // Need R3 adjustment. However, we have to make sure there is only >- // plus / minus 5 variation allowed >- if (TssiRef > R1) >- { >- R3 = (R3 < (ULONG) (TxPowerRef + 5)) ? (R3 + 1) : R3; >- if (R3 > 31) >- R3 = 31; >- DBGPRINT(RT_DEBUG_TRACE,"TSSI(R1)=%d, ++TxPwr=%d\n", R1, R3); >- } >- else >- { >- R3 = (R3 > (ULONG) (TxPowerRef - 5)) ? (R3 - 1) : R3; >- DBGPRINT(RT_DEBUG_TRACE,"TSSI(R1)=%d, --TxPwr=%d\n", R1, R3); >- } >- } >- } >- } >- } >- >- } >- } >- else // fixed AUTO TX power >- { >- if (pAd->PortCfg.TxPowerPercentage > 90) // 91 ~ 100%, treat as 100% in terms of mW >- ; >- else if (pAd->PortCfg.TxPowerPercentage > 60) // 61 ~ 90%, treat as 75% in terms of mW >- R3 -= 1; >- else if (pAd->PortCfg.TxPowerPercentage > 30) // 31 ~ 60%, treat as 50% in terms of mW >- R3 -= 3; >- else if (pAd->PortCfg.TxPowerPercentage > 15) // 16 ~ 30%, treat as 25% in terms of mW >- R3 -= 6; >- else if (pAd->PortCfg.TxPowerPercentage > 9) // 10 ~ 15%, treat as 12.5% in terms of mW >- R3 -= 9; >- else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW >- R3 -= 12; >- if (R3 > 31) R3 = 0; // negative value, set as minimum 0 >- >- // 2004-03-16 give TX rates <= 36 mbps 2 more DB >- if (pAd->PortCfg.TxRate <= RATE_36) >- { >- R3 +=2; >- if (R3 > 31) R3 = 31; >- } >- } >- >- >- // compare the desired R3.TxPwr value with current R3, if not equal >- // set new R3.TxPwr >- CurrTxPwr = (pAd->PortCfg.LatchRfRegs.R3 >> 9) & 0x0000001f; >- if (CurrTxPwr != R3) >- { >- CurrTxPwr = R3; >- R3 = (pAd->PortCfg.LatchRfRegs.R3 & 0xffffc1ff) | (R3 << 9); >- RTUSBWriteRFRegister(pAd, R3); >- pAd->PortCfg.LatchRfRegs.R3 = R3; >- } >- DBGPRINT(RT_DEBUG_INFO, "AsicAdjustTxPower = %d, AvgRssi = %d\n", >- CurrTxPwr, pAd->PortCfg.AvgRssi - pAd->BBPTuningParameters.RSSIToDbmOffset); >- >-} >- >- >- >-/* >- ========================================================================== >- Description: >- put PHY to sleep here, and set next wakeup timer >- ========================================================================== >- */ >-VOID AsicSleepThenAutoWakeup( >- IN PRT2570ADAPTER pAd, >- IN USHORT TbttNumToNextWakeUp) >-{ >- MAC_CSR18_STRUC Csr20; >- MAC_CSR17_STRUC Pwrcsr1; >- >- // we have decided to SLEEP, so at least do it for a BEACON period. >- if (TbttNumToNextWakeUp==0) >- TbttNumToNextWakeUp=1; >- >- // PWRCSR0 remains untouched >- >- // set CSR20 for next wakeup >- Csr20.value = 0; >- Csr20.field.NumBcnBeforeWakeup = TbttNumToNextWakeUp - 1; >- Csr20.field.DelayAfterBcn = (pAd->PortCfg.BeaconPeriod - 20); // 20 TU ahead of desired TBTT >- Csr20.field.AutoWake = 1; >- RTUSBWriteMACRegister(pAd, MAC_CSR18, Csr20.value); >- >- // set PWRCSR1 to put PHY into SLEEP state >- Pwrcsr1.value = 0; >- Pwrcsr1.field.PutToSleep = 1; >- Pwrcsr1.field.BbpDesireState = 1; // 01:SLEEP >- Pwrcsr1.field.RfDesireState = 1; // 01:SLEEP >- RTUSBWriteMACRegister(pAd, MAC_CSR17, Pwrcsr1.value); >- Pwrcsr1.field.PutToSleep = 1; >- RTUSBWriteMACRegister(pAd, MAC_CSR17, Pwrcsr1.value); >- DBGPRINT(RT_DEBUG_TRACE,"MAC_CSR17 = 0x%x (AsicSleepThenAutoWakeup)\n", Pwrcsr1.value); >- pAd->PortCfg.Pss = PWR_SAVE; >-} >- >-/* >- ========================================================================== >- Description: >- AsicForceWakeup() is used whenever manual wakeup is required >- AsicForceSleep() should only be used when Massoc==FALSE. When >- Massoc==TRUE, we should use AsicSleepThenAutoWakeup() instead. >- ========================================================================== >- */ >-VOID AsicForceSleep( >- IN PRT2570ADAPTER pAd) >-{ >- MAC_CSR17_STRUC Pwrcsr1; >- >- if (pAd->PortCfg.Pss == PWR_ACTIVE) >- { >- DBGPRINT(RT_DEBUG_TRACE,">>>AsicForceSleep<<<\n"); >- Pwrcsr1.value = 0; >- Pwrcsr1.field.RfDesireState = 1; // 01:SLEEP state >- Pwrcsr1.field.BbpDesireState = 1; // 01:SLEEP state >- Pwrcsr1.field.SetState = 1; >- RTUSBWriteMACRegister(pAd, MAC_CSR17, Pwrcsr1.value); >- pAd->PortCfg.Pss = PWR_SAVE; >- } >-} >- >-VOID AsicForceWakeup( >- IN PRT2570ADAPTER pAd) >-{ >- MAC_CSR17_STRUC Pwrcsr1; >- >- if (pAd->PortCfg.Pss == PWR_SAVE) >- { >- UINT i, j; >- USHORT temp; >- DBGPRINT(RT_DEBUG_TRACE,"--->AsicForceWakeup\n"); >- >- // 2003-12-19 turn OFF auto wakeup first >- RTUSBWriteMACRegister(pAd, MAC_CSR18, 0); >- Pwrcsr1.value = 0; >- Pwrcsr1.field.RfDesireState = 3; // 11:AWAKE state >- Pwrcsr1.field.BbpDesireState = 3; // 11:AWAKE state >- RTUSBWriteMACRegister(pAd, MAC_CSR17, Pwrcsr1.value); >- Pwrcsr1.field.SetState = 1; >- RTUSBWriteMACRegister(pAd, MAC_CSR17, Pwrcsr1.value); >- //RTMPusecDelay(30000); >- NdisMSleep(30); >- RTUSBReadMACRegister(pAd, MAC_CSR17, &temp); >- if ((temp & 0x01E0) == 0x01E0) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "ASIC awaken!!!\n"); >- i = 0; >- } >- else >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "ASIC not awaken yet!!!\n"); >- Pwrcsr1.value = 0; >- Pwrcsr1.field.RfDesireState = 3; // 11:AWAKE state >- Pwrcsr1.field.BbpDesireState = 3; // 11:AWAKE state >- Pwrcsr1.field.SetState = 1; >- i = 5; >- } >- for (j = 0; j < 3; j++) >- { >- if (i == 5) >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR17, Pwrcsr1.value); >- DBGPRINT(RT_DEBUG_TRACE,"MAC_CSR17 = 0x%x (AsicForceWakeup)\n", Pwrcsr1.value); >- } >- else >- break; >- >- for (i = 0; i < 5; i++) >- { >- //RTMPusecDelay(5000); >- NdisMSleep(5); >- RTUSBReadMACRegister(pAd, MAC_CSR17, &temp); >- if ((temp & 0x01E0) == 0x01E0) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "ASIC awaken!!!\n"); >- break; >- } >- else >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "ASIC not awaken yet!!!\n"); >- } >- } >- } >- >- pAd->PortCfg.Pss = PWR_ACTIVE; >- DBGPRINT(RT_DEBUG_TRACE,"<---AsicForceWakeup\n"); >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID AsicSetBssid( >- IN PRT2570ADAPTER pAd, >- IN MACADDR *Bssid) >-{ >- USHORT Addr4; >- >- Addr4 = (USHORT)(Bssid->Octet[0]) | (USHORT)(Bssid->Octet[1] << 8); >- RTUSBWriteMACRegister(pAd, MAC_CSR5, Addr4); >- >- Addr4 = (USHORT)(Bssid->Octet[2]) | (USHORT)(Bssid->Octet[3] << 8); >- RTUSBWriteMACRegister(pAd, MAC_CSR6, Addr4); >- >- Addr4 = (USHORT)(Bssid->Octet[4]) | (USHORT)(Bssid->Octet[5] << 8); >- RTUSBWriteMACRegister(pAd, MAC_CSR7, Addr4); >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID AsicDisableSync( >- IN PRT2570ADAPTER pAd) >-{ >- DBGPRINT(RT_DEBUG_TRACE,"--->Disable TSF synchronization\n"); >- //per jerry's request RTUSBReadMACRegister(pAd, TXRX_CSR19, 9); >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID AsicEnableBssSync( >- IN PRT2570ADAPTER pAd) >-{ >- USHORT temp; >- TXRX_CSR18_STRUC Csr18; >- TXRX_CSR19_STRUC Csr14; >- TXRX_CSR20_STRUC Bcncsr1; >- >- DBGPRINT(RT_DEBUG_TRACE,"--->AsicEnableBssSync(INFRA mode)\n"); >- >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, 0); >- >- temp = (pAd->PortCfg.BeaconPeriod << 8); >- Csr18.field.Offset = (temp & 0x000F); >- Csr18.field.Interval = (temp >> 6); >- RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- >- Bcncsr1.value = 0; >- Bcncsr1.field.BeaconExpectWindow = 2; >- Bcncsr1.field.Offset = TBTT_PRELOAD_TIME >> 6; // we guess TBTT is 2 TU ahead of BEACON-RxEnd time >- RTUSBWriteMACRegister(pAd, TXRX_CSR20, Bcncsr1.value); >- >- >- Csr14.value = 0; >- Csr14.field.TsfCount = 1; >- Csr14.field.TsfSync = 1; // sync TSF in INFRASTRUCTURE mode >- Csr14.field.BeaconGen = 0; >-// Csr14.field.TbcnPreload = (pAd->PortCfg.BeaconPeriod - 30) << 4; // TODO: ???? 1 TU ??? >- Csr14.field.Tbcn = 1; >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, Csr14.value); >-} >- >-/* >- ========================================================================== >- Description: >- Note: >- BEACON frame in shared memory should be built ok before this routine >- can be called. Otherwise, a garbage frame maybe transmitted out every >- Beacon period. >- ========================================================================== >- */ >-VOID AsicEnableIbssSync( >- IN PRT2570ADAPTER pAd) >-{ >- USHORT temp; >- TXRX_CSR18_STRUC Csr18; >- TXRX_CSR19_STRUC Csr14; >- TXRX_CSR20_STRUC Bcncsr1; >- >- DBGPRINT(RT_DEBUG_TRACE,"--->AsicEnableIbssSync(ADHOC mode)\n"); >- >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, 0); >- MakeIbssBeacon(pAd); >- >- temp = (pAd->PortCfg.BeaconPeriod << 8); >- Csr18.field.Offset = (temp & 0x000F); >- Csr18.field.Interval = (temp >> 6); >- RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); >- >- Bcncsr1.value = 0; >- Bcncsr1.field.Offset = 0x140; >- RTUSBWriteMACRegister(pAd, TXRX_CSR20, Bcncsr1.value); >- >- Csr14.value = 0; >- Csr14.field.TsfCount = 1; >- Csr14.field.TsfSync = 2; // sync TSF in IBSS mode >- Csr14.field.Tbcn = 1; >- Csr14.field.BeaconGen = 1; >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, Csr14.value); >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, 0); >- Csr14.value = 0; >- Csr14.field.TsfCount = 1; >- Csr14.field.TsfSync = 2; // sync TSF in IBSS mode >- Csr14.field.Tbcn = 1; >- Csr14.field.BeaconGen = 1; >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, Csr14.value); >- // >- // Snice ADHOC Beacon Generation will get failed. >- // To prevent that, program the Register TXRX_CSR19 again. >- // >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, 0); >- >- Csr14.value = 0; >- Csr14.field.TsfCount = 1; >- Csr14.field.TsfSync = 2; // sync TSF in IBSS mode >- Csr14.field.Tbcn = 1; >- Csr14.field.BeaconGen = 1; >- RTUSBWriteMACRegister(pAd, TXRX_CSR19, Csr14.value); >-} >- >-/* Flash the S/W LED periodically. - Paul Chen */ >-VOID AsicLedPeriodicExec( >- IN unsigned long data) >-{ >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID AsicSetSlotTime( >- IN PRT2570ADAPTER pAd, >- IN BOOLEAN UseShortSlotTime) >-{ >- USHORT slottime=20; >- UCHAR PhyMode; >- pAd->PortCfg.ShortSlotInUsed = UseShortSlotTime; >- >- PhyMode = pAd->PortCfg.PhyMode; >- if (PhyMode == PHY_11ABG_MIXED) >- { >- if (pAd->PortCfg.Channel <=14) >- PhyMode = PHY_11BG_MIXED; >- else >- PhyMode = PHY_11A; >- } >- >- if ((INFRA_ON(pAd)) && (pAd->PortCfg.EnableTxBurst) && (pAd->PortCfg.WepStatus != Ndis802_11EncryptionDisabled)) >- //Extend slot time if any encryption method is used to give ASIC more time to do encryption/decryption during Tx burst mode. >- RTUSBWriteMACRegister(pAd, MAC_CSR10, 0x20); >- else >- { >- if (PhyMode == PHY_11A) >- slottime = 9; >- else >- slottime = (UseShortSlotTime)? 9 : 20; >- >- RTUSBWriteMACRegister(pAd, MAC_CSR10, slottime); >- } >- //set IFS values >- if (PhyMode == PHY_11B) >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR11, 16 - PHY_TR_SWITCH_TIME); >- RTUSBWriteMACRegister(pAd, MAC_CSR12, 64); >- } >- else >- { >- RTUSBWriteMACRegister(pAd, MAC_CSR11, 10 - PHY_TR_SWITCH_TIME); >- RTUSBWriteMACRegister(pAd, MAC_CSR12, 364); >- } >-} >-VOID AsicBbpTuning( >- IN PRT2570ADAPTER pAd) >-{ >- UCHAR R17; >- ULONG FalseCcaUpperThreshold = pAd->PortCfg.BbpTuning.FalseCcaUpperThreshold << 7; >- int dbm = pAd->PortCfg.AvgRssi - pAd->BBPTuningParameters.RSSIToDbmOffset; >- if ((! pAd->PortCfg.BbpTuningEnable) || (pAd->PortCfg.BbpTuning.VgcDelta==0)) >- return; >- >- R17 = pAd->PortCfg.BbpWriteLatch[17]; >- DBGPRINT(RT_DEBUG_INFO, "RSSI = %d dbm, False CCA = %d BBPTuningThreshold = %x\n", dbm, pAd->MACCounters[3], pAd->BBPTuningParameters.BBPTuningThreshold); >- if (pAd->MediaState == NdisMediaStateConnected) >- { >- if ((dbm + (INT)(pAd->BBPTuningParameters.BBPTuningThreshold)) > 0) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "RSSI > -%ddbm\n", pAd->BBPTuningParameters.BBPTuningThreshold); >- if (pAd->BBPTuningParameters.LargeCurrentRSSI == FALSE) >- { >- RTUSBWriteBBPRegister(pAd, 24, pAd->BBPTuningParameters.R24HigherValue); >- RTUSBWriteBBPRegister(pAd, 25, pAd->BBPTuningParameters.R25HigherValue); >- RTUSBWriteBBPRegister(pAd, 61, pAd->BBPTuningParameters.R61HigherValue); >- pAd->BBPTuningParameters.LargeCurrentRSSI = TRUE; >- } >- } >- else >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "RSSI <= -%ddbm\n", pAd->BBPTuningParameters.BBPTuningThreshold); >- if (pAd->BBPTuningParameters.LargeCurrentRSSI == TRUE) >- { >- RTUSBWriteBBPRegister(pAd, 24, pAd->BBPTuningParameters.R24LowerValue); >- RTUSBWriteBBPRegister(pAd, 25, pAd->BBPTuningParameters.R25LowerValue); >- RTUSBWriteBBPRegister(pAd, 61, pAd->BBPTuningParameters.R61LowerValue); >- pAd->BBPTuningParameters.LargeCurrentRSSI = FALSE; >- } >- } >- // Rule 0. >- // when RSSI is too weak, many signals will become false CCA thus affect R17 tuning. >- // so in this case, just stop R17 tuning (be sure R17 remains in <E2PROM-6, BBP_R17_DYNAMIC_UP_BOUND> range) >-#if 1 >- if ((dbm >= -40) && >- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)) >- { >- if (R17 != 0x60) >- { >- R17 = 0x60; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- } >- DBGPRINT(RT_DEBUG_INFO, "RSSI = %d dbm, fixed R17 at 0x%x\n", dbm, R17); >- return; >- } >- >-#else >- if ((dbm < -80) && (pAd->Mlme.PeriodicRound > 20)) >- { >- if (R17 >= pAd->BBPTuningParameters.BBPR17MidSensitivity) >- { >- R17 = pAd->PortCfg.LastR17Value; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- } >- DBGPRINT(RT_DEBUG_TRACE, "RSSI = %d dbm, stop R17 at 0x%x\n", dbm, R17); >- return; >- } >-#endif >- // Rule 1. "special big-R17 for short-distance" when not SCANNING >- else if ((dbm >= RSSI_FOR_LOW_SENSIBILITY) && >- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)) >- { >- if (R17 != pAd->BBPTuningParameters.BBPR17LowSensitivity) >- { >- R17 = pAd->BBPTuningParameters.BBPR17LowSensitivity; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- } >- DBGPRINT(RT_DEBUG_INFO, "RSSI = %d dbm, fixed R17 at Low 0x%x\n", dbm, R17); >- return; >- } >- // Rule 2. "special mid-R17 for mid-distance" when not SCANNING >- else if ((dbm >= RSSI_FOR_MID_SENSIBILITY) && >- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)) >- { >- if (R17 != pAd->BBPTuningParameters.BBPR17MidSensitivity) >- { >- R17 = pAd->BBPTuningParameters.BBPR17MidSensitivity; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- } >- DBGPRINT(RT_DEBUG_INFO, "RSSI = %d dbm, fixed R17 at Mid 0x%x\n", dbm, R17); >- return; >- } >- // Rule 3. leave "short or mid-distance" condition, restore R17 to the >- // dynamic tuning range <E2PROM-6, BBP_R17_DYNAMIC_UP_BOUND> >-#if 1 >- else if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) >- { >- UCHAR UpperBond; >- UCHAR LowerBond; >- >- LowerBond = pAd->BBPR17InitValue; >- if (dbm >= -77) >- UpperBond = pAd->PortCfg.BbpTuning.VgcUpperBound; >- else >- UpperBond = pAd->PortCfg.BbpTuning.VgcUpperBound - (-77 - dbm); >- >- if (UpperBond < LowerBond) >- UpperBond = LowerBond; >- >- DBGPRINT(RT_DEBUG_INFO, "R17 = %x , upper = %x, lower = %x\n", R17, UpperBond, LowerBond); >- >- if (R17 > UpperBond) >- { >- pAd->PortCfg.LastR17Value = R17 = UpperBond; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- DBGPRINT(RT_DEBUG_INFO, "RSSI = %d dbm, restore R17 to 0x%x\n", dbm, R17); >- return; >- } >- if ((pAd->MACCounters[3] > FalseCcaUpperThreshold) && >- (R17 < UpperBond)) >- { >- R17 += pAd->PortCfg.BbpTuning.VgcDelta; >- pAd->PortCfg.LastR17Value = R17; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- DBGPRINT(RT_DEBUG_INFO, "++R17= 0x%x\n", R17); >- } >- else if ((pAd->MACCounters[3] < pAd->PortCfg.BbpTuning.FalseCcaLowerThreshold) && >- (R17 > LowerBond)) >- { >- R17 -= pAd->PortCfg.BbpTuning.VgcDelta; >- pAd->PortCfg.LastR17Value = R17; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- DBGPRINT(RT_DEBUG_INFO, "--R17= 0x%x\n", R17); >- } >- return; >- } >-#else >- else if (R17 >= pAd->BBPTuningParameters.BBPR17MidSensitivity) >- { >- R17 = pAd->PortCfg.LastR17Value; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- DBGPRINT(RT_DEBUG_TRACE, "RSSI = %d dbm, restore R17 to 0x%x\n", dbm, R17); >- return; >- } >-#endif >- >- } >- >- // Rule 3. otherwise, R17 is currenly in dyanmic tuning range: <E2PROM-6, BBP_R17_DYNAMIC_UP_BOUND>. >- // Keep dynamic tuning based on False CCA conter >- >- DBGPRINT(RT_DEBUG_INFO, "CCA flase alarm = %d, Avg RSSI= %d dbm\n", pAd->MACCounters[3], dbm); >- if ((pAd->MACCounters[3] > FalseCcaUpperThreshold) && >- (R17 < pAd->PortCfg.BbpTuning.VgcUpperBound)) >- { >- R17 += pAd->PortCfg.BbpTuning.VgcDelta; >- pAd->PortCfg.LastR17Value = R17; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- DBGPRINT(RT_DEBUG_INFO, "++R17= 0x%x\n", R17); >- } >- else if ((pAd->MACCounters[3] < pAd->PortCfg.BbpTuning.FalseCcaLowerThreshold) && >- (R17 > pAd->PortCfg.VgcLowerBound)) >- { >- R17 -= pAd->PortCfg.BbpTuning.VgcDelta; >- pAd->PortCfg.LastR17Value = R17; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- DBGPRINT(RT_DEBUG_INFO, "--R17= 0x%x\n", R17); >- } >- >-} >- >-// stop and restore R17 value upon SITE-SURVEY and LINK-DOWN >-VOID AsicRestoreBbpSensibility( >- IN PRT2570ADAPTER pAd) >-{ >- UCHAR R17; >- DBGPRINT(RT_DEBUG_TRACE, "AsicRestoreBbpSensibility\n"); >- >- R17 = pAd->PortCfg.BbpWriteLatch[17]; >- if (R17 >= pAd->BBPTuningParameters.BBPR17MidSensitivity) >- { >- DBGPRINT(RT_DEBUG_TRACE, "1AsicRestoreBbpSensibility\n"); >- R17 = pAd->PortCfg.LastR17Value; >- RTUSBWriteBBPRegister(pAd, 17, R17); >- DBGPRINT(RT_DEBUG_ERROR, "AsicRestoreBbpSensibility(set R17= 0x%x)\n", R17); >- } >- >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Mlme free the in-used nonpaged memory, >- move it to the unused memory link list >- >- Arguments: >- pAd Pointer to our adapter >- AllocVa Pointer to the base virtual address for free >- >- Return Value: >- None >- >- Note: >- >- ======================================================================== >-*/ >-VOID MlmeFreeMemory( >- IN PRT2570ADAPTER pAd, >- IN PVOID AllocVa) >-{ >- PMLME_MEMORY_STRUCT pPrevious; >- PMLME_MEMORY_STRUCT pMlmeMemoryStruct; >- BOOLEAN bIsFound; >- >- if (AllocVa == NULL) >- return; >- >- bIsFound = FALSE; >- pPrevious = NULL; >- pMlmeMemoryStruct = pAd->Mlme.MemHandler.pInUseHead; >- while (pMlmeMemoryStruct) >- { >-// DBGPRINT(RT_DEBUG_TRACE,"pMlmeMemoryStruct->AllocVa=%x\n",(int)pMlmeMemoryStruct->AllocVa); >- if (pMlmeMemoryStruct->AllocVa == AllocVa) >- { >- //Found virtual address in the in-used link list >- //Remove it from the memory in-used link list, and move it to the unused link list >- if (pPrevious == NULL) >- pAd->Mlme.MemHandler.pInUseHead = pMlmeMemoryStruct->Next; >- else >- pPrevious->Next = pMlmeMemoryStruct->Next; >- pAd->Mlme.MemHandler.InUseCount--; >- >- //append it to the tail of unused list >- pMlmeMemoryStruct->Next = NULL; >- if ((pAd->Mlme.MemHandler.pUnUseHead == NULL)) >- { //No head, add it as head >- pAd->Mlme.MemHandler.pUnUseHead = pMlmeMemoryStruct; >- pAd->Mlme.MemHandler.pUnUseTail = pMlmeMemoryStruct; >- } >- else >- { >- //Append it to the tail in pAd->Mlme.MemHandler.pUnUseTail >- pAd->Mlme.MemHandler.pUnUseTail->Next = pMlmeMemoryStruct; >- pAd->Mlme.MemHandler.pUnUseTail = pAd->Mlme.MemHandler.pUnUseTail->Next; >- } >- pAd->Mlme.MemHandler.UnUseCount++; >- >- bIsFound = TRUE; >- break; >- } >- else >- { >- pPrevious = pMlmeMemoryStruct; >- pMlmeMemoryStruct = pMlmeMemoryStruct->Next; >- } >- } >- } >- >-/* >- ======================================================================== >- >- Routine Description: >- Get an unused nonpaged system-space memory for use >- >- Arguments: >- pAd Pointer to our adapter >- AllocVa Pointer to the base virtual address for later use >- >- Return Value: >- NDIS_STATUS_SUCCESS >- NDIS_STATUS_FAILURE >- NDIS_STATUS_RESOURCES >- >- Note: >- >- ======================================================================== >-*/ >- >-NDIS_STATUS MlmeAllocateMemory( >- IN PRT2570ADAPTER pAd, >- OUT PVOID *AllocVa) >-{ >- PMLME_MEMORY_STRUCT pMlmeMemoryStruct = NULL; >- >- DBGPRINT(RT_DEBUG_INFO,"==> MlmeAllocateMemory\n"); >- >- >- if (pAd->Mlme.MemHandler.pUnUseHead == NULL) >- { //There are no available memory for caller use >- DBGPRINT(RT_DEBUG_ERROR,"MlmeAllocateMemory, failed!! (There are no available memory in list)\n"); >- DBGPRINT(RT_DEBUG_ERROR,"<== MlmeAllocateMemory\n"); >- return (NDIS_STATUS_RESOURCES); >- } >- pMlmeMemoryStruct = pAd->Mlme.MemHandler.pUnUseHead; >- //Unused memory point to next available >- pAd->Mlme.MemHandler.pUnUseHead = pAd->Mlme.MemHandler.pUnUseHead->Next; >- if (pAd->Mlme.MemHandler.pUnUseHead == NULL) >- pAd->Mlme.MemHandler.pUnUseTail = NULL; >- pAd->Mlme.MemHandler.UnUseCount--; >- >- *AllocVa = pMlmeMemoryStruct->AllocVa; //Saved porint to Pointer the base virtual address of the nonpaged memory for caller use. >- >- pMlmeMemoryStruct->Next = NULL; >- //Append the unused memory link list to the in-used link list tail >- if (pAd->Mlme.MemHandler.pInUseHead == NULL) >- {//no head, so current Item assign to In-use Head. >- pAd->Mlme.MemHandler.pInUseHead = pMlmeMemoryStruct; >- pAd->Mlme.MemHandler.pInUseTail = pMlmeMemoryStruct; >- } >- else >- { >- pAd->Mlme.MemHandler.pInUseTail->Next = pMlmeMemoryStruct; >- pAd->Mlme.MemHandler.pInUseTail = pAd->Mlme.MemHandler.pInUseTail->Next; >- } >- pAd->Mlme.MemHandler.InUseCount++; >- >- >- >- DBGPRINT(RT_DEBUG_INFO, "MlmeAllocateMemory [pMlmeMemoryStruct=0x%lx][VA=0x%lx]\n", (unsigned long)pMlmeMemoryStruct, (unsigned long)pMlmeMemoryStruct->AllocVa); >- DBGPRINT(RT_DEBUG_INFO, "<== MlmeAllocateMemory[IN:%d][UN:%d]\n", >- pAd->Mlme.MemHandler.InUseCount, pAd->Mlme.MemHandler.UnUseCount); >- return (NDIS_STATUS_SUCCESS); >-} >- >- >-/* >- ======================================================================== >- >- Routine Description: >- Allocates resident (nonpaged) system-space memory for MLME send frames >- >- Arguments: >- pAd Pointer to our adapter >- Number Total nonpaged memory for use >- Size Each nonpaged memory size >- >- Return Value: >- NDIS_STATUS_SUCCESS >- NDIS_STATUS_RESOURCES >- >- Note: >- >- ======================================================================== >-*/ >-NDIS_STATUS MlmeInitMemoryHandler( >- IN PRT2570ADAPTER pAd, >- IN UINT Number, >- IN UINT Size) >-{ >- PMLME_MEMORY_STRUCT Current = NULL; >- NDIS_STATUS Status = NDIS_STATUS_SUCCESS; >- UINT i; >- >- DBGPRINT(RT_DEBUG_INFO,"==> MlmeInitMemory\n"); >- pAd->Mlme.MemHandler.MemoryCount = 0; >- pAd->Mlme.MemHandler.pInUseHead = NULL; >- pAd->Mlme.MemHandler.pInUseTail = NULL; >- pAd->Mlme.MemHandler.pUnUseHead = NULL; >- pAd->Mlme.MemHandler.pUnUseTail = NULL; >- pAd->Mlme.MemHandler.MemRunning = FALSE; >- >- //initial the memory free-pending array all to NULL; >- for (i = 0; i < MAX_MLME_HANDLER_MEMORY; i++) >- pAd->Mlme.MemHandler.MemFreePending[i] = NULL; >- >- // >- // Available nonpaged memory counts MAX_MLME_HANDLER_MEMORY >- // >- if (Number > MAX_MLME_HANDLER_MEMORY) >- Number = MAX_MLME_HANDLER_MEMORY; >- >- for (i = 0; i < Number; i++) >- { >- //Allocate a nonpaged memory for link list use. >- //Status = NdisAllocateMemoryWithTag((VOID *)&Current, sizeof(MLME_MEMORY_STRUCT), NIC_TAG); >- Current= (PMLME_MEMORY_STRUCT) kmalloc(sizeof(MLME_MEMORY_STRUCT), GFP_ATOMIC); >- if (!Current) { >- DBGPRINT(RT_DEBUG_ERROR,"Not enough memory\n"); >- Status = NDIS_STATUS_RESOURCES; >- break; >- } >- >- >- Current->AllocVa= (VOID *) kmalloc(Size, GFP_ATOMIC); >- if (!Current->AllocVa) { >- DBGPRINT(RT_DEBUG_ERROR,"Not enough memory\n"); >- kfree((VOID *)Current); >- Status = NDIS_STATUS_RESOURCES; >- break; >- } >- >- NdisZeroMemory(Current->AllocVa, Size); >- >- pAd->Mlme.MemHandler.MemoryCount++; >- >- //build up the link list >- if (pAd->Mlme.MemHandler.pUnUseHead != NULL) >- { >- Current->Next = pAd->Mlme.MemHandler.pUnUseHead; >- pAd->Mlme.MemHandler.pUnUseHead = Current; >- } >- else >- { >- Current->Next = NULL; >- pAd->Mlme.MemHandler.pUnUseHead = Current; >- } >- >- if (pAd->Mlme.MemHandler.pUnUseTail == NULL) >- pAd->Mlme.MemHandler.pUnUseTail = Current; >- >- } >- >- if (pAd->Mlme.MemHandler.MemoryCount < Number) >- { >- Status = NDIS_STATUS_RESOURCES; >- DBGPRINT(RT_DEBUG_TRACE,"MlmeInitMemory Initial failed [Require=%d, available=%d]\n", Number, pAd->Mlme.MemHandler.MemoryCount); >- } >- >- pAd->Mlme.MemHandler.InUseCount = 0; >- pAd->Mlme.MemHandler.UnUseCount = Number; >- pAd->Mlme.MemHandler.PendingCount = 0; >- DBGPRINT(RT_DEBUG_INFO,"<== MlmeInitMemory\n"); >- >- return (Status); >-} >- >- >-VOID DeleteTimer( >- IN PRT2570ADAPTER pAd) >-{ >-} >- >- >-/* >- ======================================================================== >- >- Routine Description: >- Free Mlme memory handler (link list, nonpaged memory, spin lock) >- >- Arguments: >- pAd Pointer to our adapter >- >- Return Value: >- None >- ======================================================================== >-*/ >-VOID MlmeFreeMemoryHandler( >- IN PRT2570ADAPTER pAd) >-{ >- PMLME_MEMORY_STRUCT pMlmeMemoryStruct = NULL; >- >- DBGPRINT_RAW(RT_DEBUG_INFO, "--->MlmeFreeMemoryHandler\n"); >- >- while (pAd->Mlme.MemHandler.pInUseHead != NULL) >- { >- pMlmeMemoryStruct = pAd->Mlme.MemHandler.pInUseHead; >- pAd->Mlme.MemHandler.pInUseHead = pAd->Mlme.MemHandler.pInUseHead->Next; >- //Free the virtual address in AllocVa which size is MAX_LEN_OF_MLME_BUFFER >- kfree(pMlmeMemoryStruct->AllocVa); >- //Free the link list item self >- kfree(pMlmeMemoryStruct); >- } >- >- //Free nonpaged memory, free it in the *Unused* link list. >- while (pAd->Mlme.MemHandler.pUnUseHead != NULL) >- { >- pMlmeMemoryStruct = pAd->Mlme.MemHandler.pUnUseHead; >- pAd->Mlme.MemHandler.pUnUseHead = pAd->Mlme.MemHandler.pUnUseHead->Next; >- //Free the virtual address in AllocVa which size is MAX_LEN_OF_MLME_BUFFER >- kfree(pMlmeMemoryStruct->AllocVa); >- //Free the link list item self >- kfree(pMlmeMemoryStruct); >- } >- >- DBGPRINT_RAW(RT_DEBUG_INFO, "<---MlmeFreeMemoryHandler\n"); >-} >-/* >- ======================================================================== >- >- Routine Description: >- Verify the support rate for different PHY type >- >- Arguments: >- pAd Pointer to our adapter >- >- Return Value: >- None >- >- IRQL = PASSIVE_LEVEL >- >- ======================================================================== >-*/ >-VOID RTMPCheckRates( >- IN PRT2570ADAPTER pAd, >- IN OUT UCHAR SupRate[], >- IN OUT UCHAR *SupRateLen) >-{ >- UCHAR RateIdx, i, j; >- UCHAR NewRate[12], NewRateLen; >- >- NewRateLen = 0; >- >- if (pAd->PortCfg.PhyMode == PHY_11B) >- RateIdx = 4; >- else >- RateIdx = 12; >- >- // Check for support rates exclude basic rate bit >- for (i = 0; i < *SupRateLen; i++) >- for (j = 0; j < RateIdx; j++) >- if ((SupRate[i] & 0x7f) == RateIdTo500Kbps[j]) >- NewRate[NewRateLen++] = SupRate[i]; >- >- *SupRateLen = NewRateLen; >- NdisMoveMemory(SupRate, NewRate, NewRateLen); >-} >- >diff -ruN rt2570-1.1.0-b1/Module/.#mlme.h.1.2 rt2570-cvs-2005122616/Module/.#mlme.h.1.2 >--- rt2570-1.1.0-b1/Module/.#mlme.h.1.2 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#mlme.h.1.2 1969-12-31 18:00:00.000000000 -0600 >@@ -1,498 +0,0 @@ >-/*************************************************************************** >- * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net * >- * * >- * 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. * >- * * >- * Licensed under the GNU GPL * >- * Original code supplied under license from RaLink Inc, 2004. * >- ***************************************************************************/ >- >-/*************************************************************************** >- * Module Name: mlme.h >- * >- * Abstract: >- * >- * Revision History: >- * Who When What >- * -------- ---------- ------------------------------- >- * Name Date Modification logs >- * Jan Lee 2005-06-01 Release >- ***************************************************************************/ >- >-#ifndef __MLME_H__ >-#define __MLME_H__ >- >-// maximum supported capability information - >-// ESS, IBSS, Privacy, Short Preamble, Short Slot >-#define SUPPORTED_CAPABILITY_INFO 0x0433 >- >-#define END_OF_ARGS -1 >-#define LFSR_MASK 0x80000057 >-#define TBTT_PRELOAD_TIME 384 // usec. LomgPreamble + 24-byte at 1Mbps >-#define MLME_TASK_EXEC_INTV (1000) // 1 sec >- >-#define BEACON_LOST_TIME (4*HZ) >- >-//#define AUTH_KEY_TIMEOUT 500 // unit: msec >-//#define AUTH_OPEN_TIMEOUT 200 // unit: msec >-#define AUTH_TIMEOUT 300 // unit: msec >-#define ASSOC_TIMEOUT 300 // unit: msec >-#define JOIN_TIMEOUT 2000 // unit: msec >-#define MIN_CHANNEL_TIME 110 // unit: msec, for dual band scan >-#define MAX_CHANNEL_TIME 140 // unit: msec, for single band scan >-#define ACTIVE_SCAN_TIME 40 // Active scan waiting for probe response time >- >-#define CW_MIN_IN_BITS 3 // actual CwMin = 2^CW_MIN_IN_BITS - 1 = 31 >-#define CW_MAX_IN_BITS 5 // actual CwMax = 2^CW_MAX_IN_BITS - 1 = 1023 >- >-#define BEACON_CW_IN_BITS 5 >- >-//blue,#define RSSI_TO_DBM_OFFSET 110 // for RT2530 RSSI-110 = dBm >-#define RSSI_TO_DBM_OFFSET 120 // for RT2530 RSSI-115 = dBm >-#define RSSI_FOR_MID_TX_POWER 55 // -55 db is considered mid-distance >-#define RSSI_FOR_LOW_TX_POWER 45 // -45 db is considered very short distance and >- // eligible to use a lower TX power >-#define RSSI_FOR_LOWEST_TX_POWER 30 >-#define MID_TX_POWER_DELTA 0 // -3 db from full TX power upon mid-distance to AP >-#define LOW_TX_POWER_DELTA 3 // -8 db from full TX power upon very short distance >-#define LOWEST_TX_POWER_DELTA 6 // -12 db from full TX power upon shortest distance >- >-#define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD 0 >-#define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD 1 >-#define RSSI_THRESHOLD_FOR_ROAMING 25 >-#define RSSI_DELTA 5 >- >-// Channel Quality Indication >-//#define CQI_GOOD_THRESHOLD 70 // >= this threshold means channel quality GOOD >-//#define CQI_FAIR_THRESHOLD 50 // >= this threshold means channel quality FAIR >-//#define CQI_POOR_THRESHOLD 30 // >= this threshold means channel quality POOR >- // < this threshold means channel quality really BAD, link down >-#define CQI_IS_GOOD(cqi) ((cqi) >= 50) >-#define CQI_IS_FAIR(cqi) (((cqi) >= 20) && ((cqi) < 50)) // (((cqi) >= 50) && ((cqi) < 70)) >-#define CQI_IS_POOR(cqi) (((cqi) >= 5) && ((cqi) < 20)) // (((cqi) >= 25) && ((cqi) < 50)) >-#define CQI_IS_BAD(cqi) ((cqi) < 5) // ((cqi) < 25) >- >-// weighting factor to calculate Channel quality, total should be 100% >-#define RSSI_WEIGHTING 40 >-#define TX_WEIGHTING 40 >-#define RX_WEIGHTING 20 >- >-// prime number closest to 256 >-//#define HASH_TABLE_SIZE 191 //191 is another prime >-// Only allows 32 entries in the table >-#define MAC_TABLE_MAX_CAPACITY 32 >- >-#define MAC_ENTRY_NOT_USED 0xff >-#define CONTENT_NOT_AVAIL 0xaa >- >-// 10 minute of age out >-#define MAC_TABLE_AGE_OUT_TIME 0xffffff >- >-#define MAC_ADDR_HASH_ERROR 0xfffffffe >-#define MAC_TABLE_UNKNOWN_INDEX 0xff >-#define MAC_TABLE_ADDR_NOT_IN 0xfffffffd >- >-#define PEER_KEY_NOT_USED 0 >-#define PEER_KEY_64_BIT 64 >-#define PEER_KEY_128_BIT 128 >- >-#define PEER_KEY_64BIT_LEN 8 >-#define PEER_KEY_128BIT_LEN 16 >- >-#define MAX_LEN_OF_BSS_TABLE 64 >-#define BSS_NOT_FOUND 0xFFFFFFFF >- >-#define MAX_LEN_OF_MLME_QUEUE 100 >-#define MAX_LEN_OF_MLME_QUEUE_MSG 512 >- >-//! assoc state-machine states >-#define ASSOC_IDLE 0 >-#define ASSOC_WAIT_RSP 1 >-#define REASSOC_WAIT_RSP 2 >-#define DISASSOC_WAIT_RSP 3 >-#define MAX_ASSOC_STATE 4 >- >-#define ASSOC_FUNC_SIZE 44 // 4-state * 12-event >- >-//authentication state machine >-#define AUTH_REQ_IDLE 0 >-#define AUTH_WAIT_SEQ2 1 >-#define AUTH_WAIT_SEQ4 2 >-#define MAX_AUTH_STATE 3 >- >-#define AUTH_FUNC_SIZE 15 // 3-state * 5-event >- >-#define AUTH_RSP_IDLE 0 >-#define AUTH_RSP_WAIT_CHAL 1 >-#define MAX_AUTH_RSP_STATE 2 >- >-#define AUTH_RSP_FUNC_SIZE 6 // 2-state * 3-event >- >-// SYNC state machine >-#define SYNC_IDLE 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state >-#define JOIN_WAIT_BEACON 1 >-#define SCAN_LISTEN 2 >-#define MAX_SYNC_STATE 3 >- >-#define SYNC_FUNC_SIZE 30 // 3-state * 10-event >- >-#define SCAN_PASSIVE 18 >-#define SCAN_ACTIVE 19 >- >-//WPA State machine >-#define WPA_PSK_IDLE 0 >-#define MAX_WPA_PSK_STATE 1 >-#define WPA_PSK_FUNC_SIZE 5 >- >- >-// Control state machine >-#define CNTL_IDLE 100 >-#define CNTL_WAIT_DISASSOC 101 >-#define CNTL_WAIT_JOIN 102 >-#define CNTL_WAIT_REASSOC 103 >-#define CNTL_WAIT_START 104 >-#define CNTL_WAIT_AUTH 105 >-#define CNTL_WAIT_ASSOC 106 >-#define CNTL_WAIT_AUTH2 107 >-#define CNTL_WAIT_OID_LIST_SCAN 108 >-#define CNTL_WAIT_OID_DISASSOC 109 >- >-//#define BSS_TABLE_EMPTY(x) ((x).BssNr == 0) >-#define CapabilityInfoGen(Ess,Ibss,Cfp,CfpReq,Priv) ((Ess) ? 0x0001 : 0x0000) | ((Ibss) ? 0x0002 : 0x0000) | ((Cfp) ? 0x0004 : 0x0000) | ((CfpReq) ? 0x0008 : 0x0000) | ((Priv) ? 0x0010: 0x0000) >- >- >-#define MAC_ADDR_IS_GROUP(Addr) ((((Addr).Octet[0]) & 0x01) != 0) >-#define MAC_ADDR_HASH(Addr) ((Addr).Octet[0] ^ (Addr).Octet[1] ^ (Addr).Octet[2] ^ (Addr).Octet[3] ^ (Addr).Octet[4] ^ (Addr).Octet[5]) >-#define MAC_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE) >-#define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(pAddr2), MAC_ADDR_LEN) >-#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), ETH_LENGTH_OF_ADDRESS) >-//#define MAKE_BROADCAST_ADDR(Addr) NdisFillMemory(&Addr, MAC_ADDR_LEN, 0xff) >- >-// LED Control >-// assoiation ON. one LED ON. another blinking when TX, OFF when idle >-#define ASIC_LED_ACT_ON(pAdapter) RTUSBWriteMACRegister(pAdapter, MAC_CSR20, 0x0003) >-// no association, both LED off >-#define ASIC_LED_ACT_OFF(pAdapter) RTUSBWriteMACRegister(pAdapter, MAC_CSR20, 0x0000) >-//#define ASIC_LED_LINK_UP(pAdapter) RTMP_IO_WRITE32(pAdapter, LEDCSR, 0x00011E46) >-//#define ASIC_LED_LINK_DOWN(pAdapter) RTMP_IO_WRITE32(pAdapter, LEDCSR, 0x00001E46) >- >-#define CAP_IS_ESS_ON(x) (((x) & 0x0001) != 0) >-#define CAP_IS_IBSS_ON(x) (((x) & 0x0002) != 0) >-#define CAP_IS_CF_POLLABLE_ON(x) (((x) & 0x0004) != 0) >-#define CAP_IS_CF_POLL_REQ_ON(x) (((x) & 0x0008) != 0) >-#define CAP_IS_PRIVACY_ON(x) (((x) & 0x0010) != 0) >- >-// 802.11G capability features >-#define CAP_IS_SHORT_PREAMBLE_ON(x) (((x) & 0x0020) != 0) >-#define CAP_IS_PBCC_ON(x) (((x) & 0x0040) != 0) >-#define CAP_IS_AGILITY_ON(x) (((x) & 0x0080) != 0) >-#define CAP_IS_EXT_RATE_PBCC_ON(x) (((x) & 0x0100) != 0) >-//#define CAP_IS_CCK_OFDM_ON(x) (((x) & 0x0200) != 0) >-#define CAP_IS_QOS(x) (((x) & 0x0200) != 0) // defined in 802.11e d4.3 >-#define CAP_IS_SHORT_SLOT_TIME(x) (((x) & 0x0400) != 0) >-#define CAP_IS_APSD(x) (((x) & 0x0800) != 0) // defined in 802.11e d4.3 >-#define CAP_IS_Q_ACK(x) (((x) & 0x1000) != 0) // defined in 802.11e d4.3 >-#define CAP_IS_DSSS_OFDM(x) (((x) & 0x2000) != 0) >-#define CAP_IS_BLOCK_ACK(x) (((x) & 0x4000) != 0) // defined in 802.11e d4.3 >- >-#define CAP_GENERATE(ess,ibss,cfp,cfpreq,priv,prea) ((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((cfp) ? 0x0004 : 0x0000) | ((cfpreq) ? 0x0008 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((prea) ? 0x0020 : 0x0000) >- >-#define ERP_IS_NON_ERP_PRESENT(x) (((x) & 0x01) != 0) // define in 802.11g >-#define ERP_IS_USE_PROTECTION(x) (((x) & 0x02) != 0) // define in 802.11g >-#define ERP_IS_USE_BARKER_PREAMBLE(x) (((x) & 0x04) != 0) // define in 802.11g >- >-#define TX_FER_TOO_HIGH(TxFER) ((TxFER) > 15) // consider rate down if FER>15% >-#define TX_FER_VERY_LOW(TxFER) ((TxFER) < 7) // consider rate up if FER<7% >-#define FAIR_FER 10 // any value between TOO_HIGH and VERY_LOW >-//blue,#define DRS_TX_QUALITY_WORST_BOUND 4 >-#if 1 >-#define DRS_TX_QUALITY_WORST_BOUND 4 >-#else >-#define DRS_TX_QUALITY_WORST_BOUND 6 >-#endif >-#define DRS_PENALTY 8 >- >-// Mac Address data structure >-typedef struct _MACADDR { >- UCHAR Octet[MAC_ADDR_LEN]; >-} MACADDR, *PMACADDR; >- >-// Mac Frame Header >-typedef struct _MACHDR { >- // 2-byte Frame Control. NOTE: bit field assigned from LSB first >- USHORT Ver:2; >- USHORT Type:2; >- USHORT SubType:4; >- USHORT Tods:1; >- USHORT Frds:1; >- USHORT MoreFrag:1; >- USHORT Retry:1; >- USHORT PwrMgmt:1; >- USHORT MoreData:1; >- USHORT Wep:1; >- USHORT Order:1; >- >- USHORT Duration; >- MACADDR Addr1; >- MACADDR Addr2; >- MACADDR Addr3; >- >- USHORT Frag:4; >- USHORT Seq:12; >-} MACHDR, *PMACHDR; >- >-typedef struct _MACFRAME { >- MACHDR Hdr; >- CHAR Octet[1]; >-} MACFRAME, *PMACFRAME; >- >-typedef struct _PSPOLL_FRAME { >- USHORT Ver:2; >- USHORT Type:2; >- USHORT SubType:4; >- USHORT Tods:1; >- USHORT Frds:1; >- USHORT MoreFrag:1; >- USHORT Retry:1; >- USHORT PwrMgmt:1; >- USHORT MoreData:1; >- USHORT Wep:1; >- USHORT Order:1; >- >- USHORT Aid; >- MACADDR Bssid; >- MACADDR Ta; >-} PSPOLL_FRAME; >- >-// >-// Contention-free parameter (without ID and Length) >-// >-typedef struct _CF_PARM { >- UCHAR CfpCount; >- UCHAR CfpPeriod; >- USHORT CfpMaxDuration; >- USHORT CfpDurRemaining; >-} CF_PARM, *PCF_PARM; >- >- >-typedef struct _CIPHER_SUITE { >- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher 1, this one has more secured cipher suite >- NDIS_802_11_ENCRYPTION_STATUS PairCipherAux; // Unicast cipher 2 if AP announce two unicast cipher suite >- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Group cipher >- USHORT RsnCapability; // RSN capability from beacon >- BOOLEAN bMixMode; // Indicate Pair & Group cipher might be different >-} CIPHER_SUITE, *PCIPHER_SUITE; >- >-typedef struct { >- MACADDR Bssid; >- UCHAR Channel; >- UCHAR BssType; >- USHORT AtimWin; >- USHORT BeaconPeriod; >- >- UCHAR Rates[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR RatesLen; >- BOOLEAN ExtendedRateIeExist; // records if this AP use EXTENDED_SUPPORTED_RATES IE >- UCHAR Rssi; >- UCHAR Privacy; // Indicate security function ON/OFF. Don't mess up with auth mode. >- UCHAR Hidden; >- >- USHORT DtimPeriod; >- USHORT CapabilityInfo; >- >- USHORT CfpCount; >- USHORT CfpPeriod; >- USHORT CfpMaxDuration; >- USHORT CfpDurRemaining; >- UCHAR SsidLen; >- CHAR Ssid[MAX_LEN_OF_SSID]; >- >- ULONG LastBeaconRxTime; // OS's timestamp >- >- // New for WPA2 >- CIPHER_SUITE WPA; // AP announced WPA cipher suite >- CIPHER_SUITE WPA2; // AP announced WPA2 cipher suite >- >- // New for microsoft WPA support >- NDIS_802_11_FIXED_IEs FixIEs; >- NDIS_802_11_AUTHENTICATION_MODE AuthModeAux; // Addition mode for WPA2 / WPA capable AP >- NDIS_802_11_AUTHENTICATION_MODE AuthMode; >- NDIS_802_11_WEP_STATUS WepStatus; // Unicast Encryption Algorithm extract from VAR_IE >- UCHAR VarIELen; // Length of next VIE include EID & Length >- UCHAR VarIEs[MAX_VIE_LEN]; >-} BSS_ENTRY, *PBSS_ENTRY; >- >-typedef struct { >- UCHAR BssNr; >- BSS_ENTRY BssEntry[MAX_LEN_OF_BSS_TABLE]; >-} BSS_TABLE, *PBSS_TABLE; >- >- >-typedef struct _MLME_QUEUE_ELEM { >- ULONG Machine; >- ULONG MsgType; >- ULONG MsgLen; >- UCHAR Rssi; >- BOOLEAN Occupied; >- UCHAR Msg[MAX_LEN_OF_MLME_BUFFER]; >-} MLME_QUEUE_ELEM, *PMLME_QUEUE_ELEM; >- >-typedef struct _MLME_QUEUE { >- ULONG Num; >- ULONG Head; >- ULONG Tail; >- spinlock_t Lock; >- MLME_QUEUE_ELEM Entry[MAX_LEN_OF_MLME_QUEUE]; >-} MLME_QUEUE, *PMLME_QUEUE; >- >-typedef VOID (*STATE_MACHINE_FUNC)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem); >- >-typedef struct _STATE_MACHINE { >- ULONG Base; >- ULONG NrState; >- ULONG NrMsg; >- ULONG CurrState; >- STATE_MACHINE_FUNC *TransFunc; >-} STATE_MACHINE, *PSTATE_MACHINE; >- >-// CNTL State Machine Aux data structure >-typedef struct _CNTL_AUX { >- UCHAR Ssid[MAX_LEN_OF_SSID]; >- UCHAR SsidLen; >- MACADDR Bssid; >- BSS_TABLE SsidBssTab; // AP list for the same SSID >- BSS_TABLE RoamTab; // AP list eligible for roaming >- ULONG BssIdx; >- ULONG RoamIdx; >- BOOLEAN CurrReqIsFromNdis; // TRUE - then we should call NdisMSetInformationComplete() >- // FALSE - req is from driver itself. >- // no NdisMSetInformationComplete() is required >-} CNTL_AUX, *PCNTL_AUX; >- >-// ASSOC State Machine Aux data structure >-typedef struct _ASSOC_AUX { >- MACADDR Addr; >- USHORT CapabilityInfo; >- USHORT ListenIntv; >- CHAR Ssid[MAX_LEN_OF_SSID]; >- UCHAR SsidLen; >- RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer; >-} ASSOC_AUX, *PASSOC_AUX; >- >-// AUTH State Machine Aux data structure >-typedef struct _AUTH_AUX { >- MACADDR Addr; >- USHORT Alg; >- RALINK_TIMER_STRUCT AuthTimer; >-} AUTH_AUX, *PAUTH_AUX; >- >-// AUTH-RSP State Machine Aux data structure >-typedef struct _AUTH_RSP_AUX { >- MACADDR Addr; >- USHORT Alg; >- CHAR Challenge[CIPHER_TEXT_LEN]; >- RALINK_TIMER_STRUCT AuthRspTimer; >-} AUTH_RSP_AUX, *PAUTH_RSP_AUX; >- >-// SYNC State Machine Aux data structure >-typedef struct _SYNC_AUX { >- MACADDR Addr; >- MACADDR Bssid; >- UCHAR BssType; >- UCHAR SsidLen; >- CHAR Ssid[MAX_LEN_OF_SSID]; >- UCHAR ScanType; >- UCHAR Channel; >- RALINK_TIMER_STRUCT BeaconTimer, ScanTimer; >-} SYNC_AUX; >- >- // assoc struct is equal to reassoc >-typedef struct _MLME_ASSOC_REQ_STRUCT{ >- MACADDR Addr; >- USHORT CapabilityInfo; >- USHORT ListenIntv; >- ULONG Timeout; >-} MLME_ASSOC_REQ_STRUCT, *PMLME_ASSOC_REQ_STRUCT, MLME_REASSOC_REQ_STRUCT, *PMLME_REASSOC_REQ_STRUCT; >- >-typedef struct _MLME_DISASSOC_REQ_STRUCT{ >- MACADDR Addr; >- USHORT Reason; >-} MLME_DISASSOC_REQ_STRUCT, *PMLME_DISASSOC_REQ_STRUCT; >- >-typedef struct _MLME_AUTH_REQ_STRUCT { >- MACADDR Addr; >- USHORT Alg; >- ULONG Timeout; >-} MLME_AUTH_REQ_STRUCT, *PMLME_AUTH_REQ_STRUCT; >- >-typedef struct _MLME_DEAUTH_REQ_STRUCT { >- MACADDR Addr; >- USHORT Reason; >-} MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT; >- >-//typedef struct _MLME_AUTH_IND_STRUCT { >-// MACADDR Addr; >-// USHORT Alg; >-//} MLME_AUTH_IND_STRUCT, *PMLME_AUTH_IND_STRUCT; >- >-//typedef struct _CLS2ERR_STRUCT { >-// MACADDR Addr; >-//} CLS2ERR_STRUCT, *PCLS2ERR_STRUCT; >- >-typedef struct { >- ULONG BssIdx; >-} MLME_JOIN_REQ_STRUCT; >- >-typedef struct _MLME_SCAN_REQ_STRUCT { >- MACADDR Bssid; >- UCHAR BssType; >- UCHAR ScanType; >- UCHAR SsidLen; >- CHAR Ssid[MAX_LEN_OF_SSID]; >-} MLME_SCAN_REQ_STRUCT, *PMLME_SCAN_REQ_STRUCT; >- >-typedef struct _MLME_START_REQ_STRUCT { >- CHAR Ssid[MAX_LEN_OF_SSID]; >- UCHAR SsidLen; >-} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT; >- >-typedef struct _ARC4_CONTEXT { >- UCHAR x, y, State[256], Key[16]; // 128 bits key >-} ARC4_CONTEXT, *PARC4_CONTEXT; >- >-typedef struct _BEACON_EID_STRUCT { >- UCHAR Eid; >- UCHAR Len; >- CHAR Octet[1]; >-} BEACON_EID_STRUCT,*PBEACON_EID_STRUCT; >- >-// New for WPA cipher suite >-typedef struct _RSN_EID_STRUCT { >- UCHAR Eid; >- UCHAR Length; >- UCHAR Oui[4]; >- USHORT Version; >- UCHAR Multicast[4]; >- USHORT Count; >- struct { >- UCHAR Oui[4]; >- } Unicast[1]; >-} RSN_EID_STRUCT, *PRSN_EID_STRUCT; >- >-extern UCHAR RateIdToMbps[]; >-extern USHORT RateIdTo500Kbps[]; >- >-#endif // MLME_H__ >diff -ruN rt2570-1.1.0-b1/Module/oid.h rt2570-cvs-2005122616/Module/oid.h >--- rt2570-1.1.0-b1/Module/oid.h 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/oid.h 2005-11-30 07:43:27.000000000 -0600 >@@ -44,13 +44,12 @@ > #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE > #endif > >-#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 1) >-#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0) >-#define RTPRIV_IOCTL_AUTH (SIOCIWFIRSTPRIV + 2) >-#define RTPRIV_IOCTL_KEYID (SIOCIWFIRSTPRIV + 7) >-#define RTPRIV_IOCTL_WEPSTATUS (SIOCIWFIRSTPRIV + 4) >-#define RTPRIV_IOCTL_WPAPSK (SIOCIWFIRSTPRIV + 5) >-#define RTPRIV_IOCTL_PSM (SIOCIWFIRSTPRIV + 6) >+#define RTPRIV_IOCTL_AUTH (SIOCIWFIRSTPRIV + 0) >+#define RTPRIV_IOCTL_WEPSTATUS (SIOCIWFIRSTPRIV + 1) >+#define RTPRIV_IOCTL_WPAPSK (SIOCIWFIRSTPRIV + 2) >+#define RTPRIV_IOCTL_PSM (SIOCIWFIRSTPRIV + 3) >+#define RTPRIV_IOCTL_ADHOCMODE (SIOCIWFIRSTPRIV + 4) >+#define RTPRIV_IOCTL_RFMONTX (SIOCIWFIRSTPRIV + 5) > > > // >@@ -59,8 +58,8 @@ > > > #ifdef RT2500_DBG >-#define RTPRIV_IOCTL_BBP SIOCIWFIRSTPRIV + 0x03 >-#define RTPRIV_IOCTL_MAC SIOCIWFIRSTPRIV + 0x05 >+#define RTPRIV_IOCTL_BBP SIOCIWFIRSTPRIV + 0x06 >+#define RTPRIV_IOCTL_MAC SIOCIWFIRSTPRIV + 0x07 > #endif > > >@@ -567,7 +566,7 @@ > #define RT_OID_802_11_POWER_MODE (OID_GET_SET_TOGGLE | OID_802_11_POWER_MODE) > #define RT_OID_802_11_STATISTICS (OID_GET_SET_TOGGLE | OID_802_11_STATISTICS) > >-#if DBG >+#ifdef DBG > #define RT_OID_802_11_QUERY_HARDWARE_REGISTER 0x0D710105 > #define RT_OID_802_11_SET_HARDWARE_REGISTER (OID_GET_SET_TOGGLE | RT_OID_802_11_QUERY_HARDWARE_REGISTER) > #endif >diff -ruN rt2570-1.1.0-b1/Module/rt2570sw.h rt2570-cvs-2005122616/Module/rt2570sw.h >--- rt2570-1.1.0-b1/Module/rt2570sw.h 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rt2570sw.h 2005-12-09 17:41:12.000000000 -0600 >@@ -37,13 +37,16 @@ > * PeterF 27-06-2005 Added GN-WBKG > * zak 03-07-2005 Added second GN-WBKG > * PedroP 04-07-2005 Added EMINENT 3035 >+ * MarkW 06-12-2005 Added Linksys@Home > ***************************************************************************/ > > > #ifndef __vnetsw_h_OK__ > #define __vnetsw_h_OK__ > >- >+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+#include <linux/kthread.h> >+#endif > > //red,extern unsigned long NIC_VENDOR_DRIVER_VERSION;//blue > //////////////////////////////////////////////////////////////////////////// >@@ -116,6 +119,8 @@ > { USB_DEVICE(0x0411, 0x0066)}, /* Melco */ \ > { USB_DEVICE(0x0411, 0x0067)}, /* Melco */ \ > { USB_DEVICE(0x050d, 0x7050)}, /* Belkin */ \ >+ { USB_DEVICE(0x050d, 0x705a)}, /* Belkin */ \ >+ { USB_DEVICE(0x06f8, 0xe000)}, /* GUILLEMOT */ \ > { USB_DEVICE(0x0707, 0xee13)}, /* SMC */ \ > { USB_DEVICE(0x0b05, 0x1706)}, /* ASUS */ \ > { USB_DEVICE(0x0b05, 0x1707)}, /* ASUS */ \ >@@ -127,12 +132,15 @@ > { USB_DEVICE(0x114b, 0x0110)}, /* Spairon */ \ > { USB_DEVICE(0x13b1, 0x000d)}, /* Cisco Systems */ \ > { USB_DEVICE(0x13b1, 0x0011)}, /* Cisco Systems */ \ >+ { USB_DEVICE(0x13b1, 0x001a)}, /* Cisco Systems */ \ > { USB_DEVICE(0x148f, 0x1706)}, /* Ralink */ \ > { USB_DEVICE(0x148f, 0x2570)}, /* Ralink */ \ >+ { USB_DEVICE(0x148f, 0x2573)}, /* CNET CWD-854 */ \ > { USB_DEVICE(0x148f, 0x9020)}, /* Ralink */ \ > { USB_DEVICE(0x14b2, 0x3c02)}, /* Conceptronic */ \ > { USB_DEVICE(0x14f8, 0x2570)}, /* Eminent */ \ > { USB_DEVICE(0x2001, 0x3c00)}, /* D-LINK */ \ >+ { USB_DEVICE(0x0411, 0x008b)}, /* Nintendo */ \ > {0,} \ > } > >@@ -157,24 +165,22 @@ > // > // MACRO for debugging information > // >-#if RT2500_DBG >+#ifdef RT2500_DBG > extern ULONG debug; > > #define DBGPRINT(Level, fmt, args...) \ > { \ >- if (Level <= debug) \ >+ if (Level <= debug) \ > { \ >- printk(NIC_DBG_STRING); \ >- printk(KERN_DEBUG fmt, ## args); \ >+ printk(KERN_DEBUG NIC_DBG_STRING fmt, ## args); \ > } \ > } > >-#define DBGPRINT_RAW(Level, fmt, args...) \ >-{ \ >- if (Level <= debug) \ >+#define DBGPRINT_RAW(Level, fmt, args...) \ >+ { \ >+ if (Level <= debug) \ > { \ >- printk(" "); \ >- printk(KERN_DEBUG fmt, ## args); \ >+ printk(fmt, ## args); \ > } \ > } > >@@ -272,10 +278,11 @@ > dev_kfree_skb_any(skb); \ > } > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > #define RTUSBUp(pAd, semaphore) \ >-{ \ >+{ \ > if(pAd->MLMEThr_pid>0) \ >- up(semaphore); \ >+ up(semaphore); \ > } > > #define RTUSBCMDUp(pAd, semaphore) \ >@@ -283,7 +290,19 @@ > if(pAd->RTUSBCmdThr_pid>0) \ > up(semaphore); \ > } >+#else >+#define RTUSBUp(pAd, semaphore) \ >+{ \ >+ if(pAd->MLMEThr_active) \ >+ up(semaphore); \ >+} > >+#define RTUSBCMDUp(pAd, semaphore) \ >+{ \ >+ if(pAd->RTUSBCmdThr_active) \ >+ up(semaphore); \ >+} >+#endif > > //Setup Packet used in Ctrl urb's filler.... > >@@ -911,6 +930,9 @@ > BOOLEAN Massoc; > BOOLEAN Mauth; > >+ // RFMON logic flags >+ BOOLEAN MallowRFMONTx; >+ > // PHY specification > UCHAR PhyMode; // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED > USHORT Dsifs; // in units of usec >@@ -1458,9 +1480,16 @@ > // Thread > struct semaphore mlme_semaphore; /* to sleep thread on */ > struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */ >- struct completion notify; /* thread begin/end */ >- pid_t MLMEThr_pid; >- pid_t RTUSBCmdThr_pid; >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >+ struct completion notify; /* thread begin/end */ >+ pid_t MLMEThr_pid; >+ pid_t RTUSBCmdThr_pid; >+#else >+ struct task_struct * MLMEThr; >+ volatile int MLMEThr_active; >+ struct task_struct * RTUSBCmdThr; >+ volatile int RTUSBCmdThr_active; >+#endif > wait_queue_head_t *wait; > > spinlock_t *lock; >@@ -3697,4 +3726,55 @@ > > int USB_CallUSBD(PRT2570ADAPTER Adapter, > IN PURB Urb); >+ >+#endif >+ >+#ifndef _PRISMHEADER >+#define _PRISMHEADER >+ >+enum { >+ DIDmsg_lnxind_wlansniffrm = 0x00000044, >+ DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044, >+ DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044, >+ DIDmsg_lnxind_wlansniffrm_channel = 0x00030044, >+ DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044, >+ DIDmsg_lnxind_wlansniffrm_sq = 0x00050044, >+ DIDmsg_lnxind_wlansniffrm_signal = 0x00060044, >+ DIDmsg_lnxind_wlansniffrm_noise = 0x00070044, >+ DIDmsg_lnxind_wlansniffrm_rate = 0x00080044, >+ DIDmsg_lnxind_wlansniffrm_istx = 0x00090044, >+ DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044 >+}; >+enum { >+ P80211ENUM_msgitem_status_no_value = 0x00 >+}; >+enum { >+ P80211ENUM_truth_false = 0x00, >+ P80211ENUM_truth_true = 0x01 >+}; >+ >+typedef struct { >+ u_int32_t did; >+ u_int16_t status; >+ u_int16_t len; >+ u_int32_t data; >+} p80211item_uint32_t; >+ >+typedef struct { >+ u_int32_t msgcode; >+ u_int32_t msglen; >+#define WLAN_DEVNAMELEN_MAX 16 >+ u_int8_t devname[WLAN_DEVNAMELEN_MAX]; >+ p80211item_uint32_t hosttime; >+ p80211item_uint32_t mactime; >+ p80211item_uint32_t channel; >+ p80211item_uint32_t rssi; >+ p80211item_uint32_t sq; >+ p80211item_uint32_t signal; >+ p80211item_uint32_t noise; >+ p80211item_uint32_t rate; >+ p80211item_uint32_t istx; >+ p80211item_uint32_t frmlen; >+} wlan_ng_prism2_header; >+ > #endif >diff -ruN rt2570-1.1.0-b1/Module/.#rt2570sw.h.1.13 rt2570-cvs-2005122616/Module/.#rt2570sw.h.1.13 >--- rt2570-1.1.0-b1/Module/.#rt2570sw.h.1.13 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#rt2570sw.h.1.13 1969-12-31 18:00:00.000000000 -0600 >@@ -1,3752 +0,0 @@ >-/*************************************************************************** >- * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net * >- * * >- * 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. * >- * * >- * Licensed under the GNU GPL * >- * Original code supplied under license from RaLink Inc, 2004. * >- ***************************************************************************/ >- >-/*************************************************************************** >- * Module Name: rt2570sw.h >- * >- * Abstract: >- * >- * Revision History: >- * Who When What >- * -------- ---------- ------------------------------------ >- * Name Date Modification logs >- * Jan Lee 2005-06-01 Release >- * Ivo 02-06-2005 Debug flag fix >- * FelipeaA 02-06-2005 Added Conceptronic C54RU >- * MathiasK 02-06-2005 Added F5D7050,UB801R >- * MarkW 02-08-2005 Added MSI 6861 >- * PeterF 27-06-2005 Added GN-WBKG >- * zak 03-07-2005 Added second GN-WBKG >- * PedroP 04-07-2005 Added EMINENT 3035 >- ***************************************************************************/ >- >- >-#ifndef __vnetsw_h_OK__ >-#define __vnetsw_h_OK__ >- >- >- >-//red,extern unsigned long NIC_VENDOR_DRIVER_VERSION;//blue >-//////////////////////////////////////////////////////////////////////////// >-// Frame Sizes >-//////////////////////////////////////////////////////////////////////////// >- >-#define MAC_ADDRESS_LENGTH 6 >- >-#define HEADER_SIZE 14 >-#define MAXIMUM_PACKET_SIZE 1500 >- >-#define MAX_QUEUE_SIZE 100 >- >-#define USB_TX_HEADER_SIZE 8//WLength+TxRate+PaddingBytes+Reserved >-#define USB_RX_HEADER_SIZE 12 >- >-#define WIRELESS_HEADER_OVERHEAD 18 >-#define MAX_TX_PADDING_BYTES 50 >-#define MAX_RX_PADDING_BYTES 66 >-#define CRC32_BYTES 4 >- >-#define MAX_WIRELESS_SIZE WIRELESS_HEADER_OVERHEAD + HEADER_SIZE + MAXIMUM_PACKET_SIZE + CRC32_BYTES >-extern unsigned long flagg; >- >- >-typedef UCHAR ADDRESS[MAC_ADDRESS_LENGTH]; >- >-//////////////////////////////////////////////////////////////////////////// >-// NDIS related definitions >-//////////////////////////////////////////////////////////////////////////// >-#define MAX_MULTICAST_ADDRESSES 32 >-#define MAX_LOOKAHEAD_SIZE MAXIMUM_PACKET_SIZE + HEADER_SIZE >-#define TRANSMIT_BUFFER_SPACE 0x3000 >-#define RECEIVE_BUFFER_SPACE 0x4000 >-#define MAXIMUM_SEND_PACKETS 8 >- >-#define OPER_RATE_SIZE 4 >- >-#define SUPPORTED_RATES_SET_1 0 >-#define SUPPORTED_RATES_SET_2 1 >- >- >-//////////////////////////////////////////////////////////////////////////// >-// Memory Macros >-//////////////////////////////////////////////////////////////////////////// >-#define FreeMemory(_buffer) kfree(_buffer) >- >-//////////////////////////////////////////////////////////////////////////// >-// 802,11 related definitions >-//////////////////////////////////////////////////////////////////////////// >-#define ESS_ID_SIZE 32 >-#define AD_HOC_MODE 1 >-#define INFRASTRUCTURE_MODE 2 >-#define WEP_KEY_SIZE 13 //128-bit encryption >-#define PREAMBLE_TYPE_LONG 0 >-#define PREAMBLE_TYPE_SHORT 1 >- >-//////////////////////////////////////////////////////////////////////////// >-// used to track information on usb pipes in use >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __BULKUSB_PIPEINFO { >- BOOLEAN fPipeOpened; >-} BULKUSB_PIPEINFO, *PBULKUSB_PIPEINFO; >- >- >-//#pragma pack (push, 1) >- >- >-#define RTUSB_DEVICES { \ >- { USB_DEVICE(0x0411, 0x0066)}, /* Melco */ \ >- { USB_DEVICE(0x0411, 0x0067)}, /* Melco */ \ >- { USB_DEVICE(0x050d, 0x7050)}, /* Belkin */ \ >- { USB_DEVICE(0x0707, 0xee13)}, /* SMC */ \ >- { USB_DEVICE(0x0b05, 0x1706)}, /* ASUS */ \ >- { USB_DEVICE(0x0b05, 0x1707)}, /* ASUS */ \ >- { USB_DEVICE(0x0db0, 0x6861)}, /* MSI */ \ >- { USB_DEVICE(0x0db0, 0x6865)}, /* MSI */ \ >- { USB_DEVICE(0x0db0, 0x6869)}, /* MSI */ \ >- { USB_DEVICE(0x1044, 0x8001)}, /* Gigabyte */ \ >- { USB_DEVICE(0x1044, 0x8007)}, /* Gigabyte */ \ >- { USB_DEVICE(0x114b, 0x0110)}, /* Spairon */ \ >- { USB_DEVICE(0x13b1, 0x000d)}, /* Cisco Systems */ \ >- { USB_DEVICE(0x13b1, 0x0011)}, /* Cisco Systems */ \ >- { USB_DEVICE(0x148f, 0x1706)}, /* Ralink */ \ >- { USB_DEVICE(0x148f, 0x2570)}, /* Ralink */ \ >- { USB_DEVICE(0x148f, 0x9020)}, /* Ralink */ \ >- { USB_DEVICE(0x14b2, 0x3c02)}, /* Conceptronic */ \ >- { USB_DEVICE(0x14f8, 0x2570)}, /* Eminent */ \ >- { USB_DEVICE(0x2001, 0x3c00)}, /* D-LINK */ \ >- {0,} \ >-} >- >- >-typedef struct urb *purbb_t; >-typedef struct usb_ctrlrequest devctrlrequest; >-// for vendor-specific control operations >-#define CONTROL_TIMEOUT_MS (500) /* msec */ >-#define CONTROL_TIMEOUT_JIFFIES ((CONTROL_TIMEOUT_MS * HZ)/1000) >-/* map devrequest fields onto usb_ctrlrequest's */ >-#define DEVREQ_REQUEST(x) ((x)->bRequest) >-#define DEVREQ_REQUESTTYPE(x) ((x)->bRequestType) >-#define DEVREQ_VALUE(x) ((x)->wValue) >-#define DEVREQ_INDEX(x) ((x)->wIndex) >-#define DEVREQ_LENGTH(x) ((x)->wLength) >-#define PURB purbb_t >-#define PIRP PVOID >-#define PMDL PVOID >- >-#define NDIS_OID UINT >- >-// >-// MACRO for debugging information >-// >-#if RT2500_DBG >-extern ULONG debug; >- >-#define DBGPRINT(Level, fmt, args...) \ >-{ \ >- if (Level <= debug) \ >- { \ >- printk(NIC_DBG_STRING); \ >- printk(KERN_DEBUG fmt, ## args); \ >- } \ >-} >- >-#define DBGPRINT_RAW(Level, fmt, args...) \ >-{ \ >- if (Level <= debug) \ >- { \ >- printk(" "); \ >- printk(KERN_DEBUG fmt, ## args); \ >- } \ >-} >- >-#else /* RT2500_DBG */ >-#define DBGPRINT(Level, fmt, args...) >-#define DBGPRINT_RAW(Level, fmt, args...) >-#endif /* RT2500_DBG */ >- >- >-# define assert(expr) \ >- if(unlikely(!(expr))) { \ >- printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ >- #expr,__FILE__,__FUNCTION__,__LINE__); \ >- } >- >- >-// >-// Defines the state of the LAN media >-// >-typedef enum _NDIS_MEDIA_STATE >-{ >- NdisMediaStateConnected, >- NdisMediaStateDisconnected >-} NDIS_MEDIA_STATE, *PNDIS_MEDIA_STATE; >- >- >-#define NdisMSetInformationComplete(handle, status) \ >-{ \ >-} >- >-#define NdisMIndicateStatusComplete(handle) \ >-{ \ >-} >- >-#define NdisMIndicateStatus(_M, _G, _SB, _BS) \ >-{ \ >-} >- >- >- >-// >-// The following structure defines the device power states. >-// >-typedef enum _NDIS_DEVICE_POWER_STATE >-{ >- NdisDeviceStateUnspecified = 0, >- NdisDeviceStateD0, >- NdisDeviceStateD1, >- NdisDeviceStateD2, >- NdisDeviceStateD3, >- NdisDeviceStateMaximum >-} NDIS_DEVICE_POWER_STATE, *PNDIS_DEVICE_POWER_STATE; >- >- >-#define ETH_LENGTH_OF_ADDRESS 6 >- >- >-#define STATUS_SUCCESS 0x00 >-#define STATUS_UNSUCCESSFUL 0x01 >- >-typedef LONG NTSTATUS; >-typedef NTSTATUS *PNTSTATUS; >- >-// >-// spin_lock enhanced for Nested spin lock >-// >-#define NdisAllocateSpinLock(lock) \ >-{ \ >- spin_lock_init(lock); \ >-} >- >-#define NdisReleaseSpinLock(lock) \ >-{ \ >- if (in_interrupt()) \ >-{ \ >- spin_unlock_irqrestore(lock, flagg); \ >-} \ >- else \ >-{ \ >- spin_unlock(lock); \ >-} \ >-} >- >-#define NdisAcquireSpinLock(lock) \ >-{ \ >- if (in_interrupt()) \ >- spin_lock_irqsave(lock, flagg); \ >- else \ >- spin_lock(lock); \ >-} >- >- >-#define RTUSBFreeSkbBuffer(skb) \ >-{ \ >- dev_kfree_skb_any(skb); \ >-} >- >-#define RTUSBUp(pAd, semaphore) \ >-{ \ >- if(pAd->MLMEThr_pid>0) \ >- up(semaphore); \ >-} >- >-#define RTUSBCMDUp(pAd, semaphore) \ >-{ \ >- if(pAd->RTUSBCmdThr_pid>0) \ >- up(semaphore); \ >-} >- >- >-//Setup Packet used in Ctrl urb's filler.... >- >-#define FILL_REQUEST(a,aa,ab,ac,ad,ae)\ >- do {\ >- (a)->devreq->request = aa;\ >- (a)->devreq->requesttype = ab;\ >- (a)->devreq->value = cpu_to_le16(ac);\ >- (a)->devreq->index = cpu_to_le16(ad);\ >- (a)->devreq->length = cpu_to_le16(ae);\ >- }while(0); >- >- >- >-// direction is specified in TransferFlags >- >-#define URB_FUNCTION_RESERVED0 0x0016 >- >-// >-// These are for sending vendor and class commands >-// on the default pipe >-// >-// direction is specified in TransferFlags >-// >- >-#define URB_FUNCTION_VENDOR_DEVICE 0x0017 >-#define URB_FUNCTION_VENDOR_INTERFACE 0x0018 >-#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019 >-#define URB_FUNCTION_VENDOR_OTHER 0x0020 >- >-#define URB_FUNCTION_CLASS_DEVICE 0x001A >-#define URB_FUNCTION_CLASS_INTERFACE 0x001B >-#define URB_FUNCTION_CLASS_ENDPOINT 0x001C >-#define URB_FUNCTION_CLASS_OTHER 0x001F >- >-// >-// Reserved function codes >-// >-#define URB_FUNCTION_RESERVED 0x001D >- >-#define URB_FUNCTION_GET_CONFIGURATION 0x0026 >-#define URB_FUNCTION_GET_INTERFACE 0x0027 >- >-#define URB_FUNCTION_LAST 0x0029 >- >- >-//define Vendor Command Constant >-#define CMD_VendorReset 0x01 >-#define CMD_Disconnect 0x02 >-#define CMD_FunctionSwitch 0x03 >-#define CMD_SetTestMode 0x04 >-#define CMD_ClearTestMode 0x05 >-#define CMD_WriteMacRegister 0x06 >-#define CMD_ReadMacRegister 0x07 >-#define CMD_EEPROMWrite 0x08 >-#define CMD_EEPROMRead 0x09 >-#define CMD_MultipleRead 0x0A >-#define CMD_MultipleWrite 0x0B >-#define CMD_SingleRead 0x0C >-#define CMD_SingleWrite 0x0D >- >-#define NdisMSleep mdelay >- >- >-// Assert MACRO to make sure program running >-// >-#undef ASSERT >-#define ASSERT(x) \ >-{ \ >- if (!(x)) \ >- { \ >- printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \ >- } \ >-} >- >-#if 0 >-#undef MOD_INC_USE_COUNT >-#define MOD_INC_USE_COUNT do { } while (0) >- >-#undef MOD_DEC_USE_COUNT >-#define MOD_DEC_USE_COUNT do { } while (0) >-#endif >- >- >-//add by james >- >-//////////////////////////////////////////////////////////////////////////// >-// VERSION_INFO exchanged between driver/application >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __VERSION_INFO{ >- UCHAR DriverMajorVersion; >- UCHAR DriverMinorVersion; >- UCHAR DriverSubVersion; >- USHORT DriverBuild; >- >- USHORT FwMajorVersion; >- USHORT FwMinorVersion; >- USHORT FwSubVersion; >- USHORT FwBuild; >-}VERSION_INFO, *PVERSION_INFO; >- >-#if 0 >-//////////////////////////////////////////////////////////////////////////// >-// The RX_BUFFER structure forms the Received USB packet from the device >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __RX_BUFFER{ >- USHORT WLength; >- UCHAR RxRate; //This field is not used in this version of Drv/FW >- UCHAR ChangeBSSID; >- UCHAR Fragmentation;//This field is not used in this version of Drv/FW >- UCHAR RSSI; >- UCHAR LinkQuality; >- UCHAR NoiseLevel; //This field is not used in this version of Drv/FW >- UCHAR RxTime[4]; //This field is not used in this version of Drv/FW >- UCHAR WirelessPacket[MAX_WIRELESS_SIZE]; >-} RX_BUFFER, *PRX_BUFFER; >-#endif >- >- >-//////////////////////////////////////////////////////////////////////////// >-// The TX_BUFFER structure forms the transmitted USB packet to the device >-//////////////////////////////////////////////////////////////////////////// >-typedef struct _TX_BUFFER{ >-// UINT BulkOutSize; >- TXD_STRUC TxDesc; >- UCHAR WirelessPacket[2342]; >-} TX_BUFFER, *PTX_BUFFER; >- >- >-//////////////////////////////////////////////////////////////////////////// >-// The RTS_BUFFER structure forms the transmitted USB packet to the device >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __RTS_BUFFER{ >- TXD_STRUC TxDesc; >- UCHAR RTSPacket[16]; >-} RTS_BUFFER, *PRTS_BUFFER; >- >-//////////////////////////////////////////////////////////////////////////// >-// The USB_CARD_CONFIG structure is used only during device initialization >-// to pass the initial operationg parameters to device >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __USB_CARD_CONFIG{ >- UCHAR ExcludeUnencrypted; >- UCHAR PromiscuousMode; >- UCHAR ShortRetryLimit; >- UCHAR EncryptionType; >- USHORT RtsThreshold; >- USHORT FragmentationThreshold; // 256..2346 >- UCHAR BasicRateSet[4]; >- BOOLEAN AutoRateFallBack; //0,1 >- UCHAR Channel; >- BOOLEAN PrivacyInvoked; >- UCHAR WEPDefaultKeyID; // 0..3 >- UCHAR CurrentSSID[32]; >- UCHAR WEPDefaultKeyValue[4][WEP_KEY_SIZE]; >- UCHAR SSIDLen; >- UCHAR ShortPreamble; >- USHORT BeaconPeriod; >-} USB_CARD_CONFIG, *PUSB_CARD_CONFIG; >- >- >-//////////////////////////////////////////////////////////////////////////// >-// In WEP_INFO are kept all the WEP related parameters. This structure is >-// also exchanged between driver and application. >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __WEP_INFO{ >- UCHAR WepKeyToUse; >- UCHAR WepMode; >- USHORT AuthenticationType; >- UCHAR EncryptionLevel; >- UCHAR WepKey1[WEP_KEY_SIZE]; >- UCHAR WepKey2[WEP_KEY_SIZE]; >- UCHAR WepKey3[WEP_KEY_SIZE]; >- UCHAR WepKey4[WEP_KEY_SIZE]; >-} WEP_INFO, *PWEP_INFO; >- >- >-//////////////////////////////////////////////////////////////////////////// >-// In the STATISTICS structure are kept all the device's statitrics. >-// This structure is also exchanged between driver and application. >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __STATISTICS{ >- ULONG TxDataPacketsOk; >- ULONG TxDataPacketsError; >- ULONG TxMgmtPacketsOk; >- ULONG TxMgmtPacketsError; >- >- ULONG RxDataPacketsOk; >- ULONG RxDataPacketsError; >- ULONG RxMgmtPacketsOk; >- ULONG RxMgmtPacketsError; >- >- ULONG RxLost; >- ULONG TxPacketsRejectedNotReady; >- ULONG TxPacketsRejectedResources; >- ULONG MatchingBeacons; >-}STATISTICS, *PSTATISTICS; >- >-//////////////////////////////////////////////////////////////////////////// >-// The BSS_INFO and SITE_SURVEY_INFO structures are used to form a custom >-// list of 12 maximum BSSs and keet there characteristics. >-// This list is the one that application displays in Site Survey Tab. >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __BSS_INFO{ >- UCHAR Channel; >- UCHAR SSID[ESS_ID_SIZE]; >- UCHAR SSIDsize; >- UCHAR BSSID[6]; >- UCHAR RSSI; >- UCHAR UsingWEP; >- UCHAR PreambleType; >- USHORT BeaconPeriod; >- UCHAR BSSType; //11->Ad-Hoc, 2->Infrastructure >-}BSS_INFO, *PBSS_INFO; >- >-#define MAX_AP_ENTRIES 30 >- >-typedef struct __SITE_SURVEY_INFO{ >- BSS_INFO BSSinfo[MAX_AP_ENTRIES]; >- UCHAR BSSsInList; >- UCHAR UserSelectedIndex; >- UCHAR SiteSurveyState; >-}SITE_SURVEY_INFO, *PSITE_SURVEY_INFO; >- >-#ifdef WINXP >-typedef struct __XP_BSSID_LIST{ >- ULONG NumberOfEntries; >- NDIS_WLAN_BSSID NdisBSSIDEntry[MAX_AP_ENTRIES]; >-}XP_BSSID_LIST; >-#endif >- >-//#pragma pack(pop) >- >- >- >-//////////////////////////////////////////////////////////////////////////// >-// The FRAGMENTED_PACKET structure is used for the reassembly of the >-// fragmented 802.11 packets in the driver >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __FRAGMENTED_PACKET{ >- USHORT Sequence; >- USHORT CurrentLen; >- UCHAR SourceAddress[6]; >- UCHAR FragmentNumber;//next fragment expected >- UCHAR WirelessPacket[MAX_WIRELESS_SIZE]; >-}FRAGMENTED_PACKET, *PFRAGMENTED_PACKET; >- >-//////////////////////////////////////////////////////////////////////////// >-// The ASYNC_OID structure is used for holding the context of an OID call >-// that the driver will complete asynchronously >-//////////////////////////////////////////////////////////////////////////// >-typedef struct __ASYNC_OID{ >- PVOID InformationBuffer; >- ULONG InformationBufferLength; >- PULONG Bytes; >- PULONG BytesNeeded; >-}ASYNC_OID, *PASYNC_OID; >- >-#if 1//RT2460 >-// >-// Some utility macros >-// >-#ifndef min >-#define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b)) >-#endif >- >-#ifndef max >-#define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b)) >-#endif >- >-#define INC_COUNTER(Val) (Val.QuadPart++) >- >-#define INFRA_ON(_p) (((_p)->PortCfg.Massoc) == TRUE) // Check Massoc >-#define ADHOC_ON(_p) (((_p)->PortCfg.Mibss) == TRUE) // check Mibss >- >-#define RTMP_SET_PACKET_FRAGMENTS(_p, number) ((_p)->cb[10] = number) >-#define RTMP_GET_PACKET_FRAGMENTS(_p) ((_p)->cb[10]) >-#define RTMP_SET_PACKET_RTS(_p, number) ((_p)->cb[11] = number) >-#define RTMP_GET_PACKET_RTS(_p) ((_p)->cb[11]) >-#define RTMP_SET_PACKET_FIRST_CONTEXT(_p, number) ((_p)->cb[12] = number) >-#define RTMP_GET_PACKET_FIRST_CONTEXT(_p) ((_p)->cb[12]) >-//blue,#define RTMP_SET_PACKET_CONTEXTS_REQUIRED(_p, number) ((_p)->cb[13] = number) >-//blue,#define RTMP_GET_PACKET_CONTEXTS_REQUIRED(_p) ((_p)->cb[13]) >-#define GET_NEXT_PACKET_IN_BULKOUT_QUEUE(_p) ((struct sk_buff **)&((_p)->cb[14])) >- >- >-#define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType) \ >-{ \ >- memcpy(_p, _pMac1, ETH_LENGTH_OF_ADDRESS); \ >- memcpy((_p + ETH_LENGTH_OF_ADDRESS), _pMac2, ETH_LENGTH_OF_ADDRESS); \ >- memcpy((_p + ETH_LENGTH_OF_ADDRESS * 2), _pType, LENGTH_802_3_TYPE); \ >-} >- >-// >-// Register set pair for initialzation register set definition >-// >-typedef struct _RTMP_REG_PAIR >-{ >- ULONG Register; >- ULONG Value; >-} RTMP_REG_PAIR, *PRTMP_REG_PAIR; >- >-// >-// Register set pair for initialzation register set definition >-// >-typedef struct _RTMP_RF_REGS >-{ >- UCHAR Channel; >- ULONG R1; >- ULONG R2; >- ULONG R3; >- ULONG R4; >-} RTMP_RF_REGS, *PRTMP_RF_REGS; >- >-typedef struct _RTMP_RF_REGS_1 >-{ >- UCHAR Channel; >- ULONG TempR2; >- ULONG R1; >- ULONG R2; >- ULONG R3; >- ULONG R4; >-} RTMP_RF_REGS_1, *PRTMP_RF_REGS_1; >-// >-// Queue structure and macros >-// >-typedef struct _QUEUE_ENTRY { >- struct _QUEUE_ENTRY *Next; >-} QUEUE_ENTRY, *PQUEUE_ENTRY; >- >-// Queue structure >-typedef struct _QUEUE_HEADER { >- PQUEUE_ENTRY Head; >- PQUEUE_ENTRY Tail; >- ULONG Number; >-} QUEUE_HEADER, *PQUEUE_HEADER; >- >-#define InitializeQueueHeader(QueueHeader) \ >-{ \ >- (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \ >- (QueueHeader)->Number = 0; \ >-} >- >-#define RemoveHeadQueue(QueueHeader) \ >-(QueueHeader)->Head; \ >-{ \ >- PQUEUE_ENTRY pNext; \ >- ASSERT((QueueHeader)->Head); \ >- pNext = (QueueHeader)->Head->Next; \ >- (QueueHeader)->Head = pNext; \ >- if (pNext == NULL) \ >- (QueueHeader)->Tail = NULL; \ >- (QueueHeader)->Number--; \ >-} >- >-#define InsertHeadQueue(QueueHeader, QueueEntry) \ >-{ \ >- ((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \ >- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \ >- if ((QueueHeader)->Tail == NULL) \ >- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \ >- (QueueHeader)->Number++; \ >-} >- >-#define InsertTailQueue(QueueHeader, QueueEntry) \ >-{ \ >- ((PQUEUE_ENTRY)QueueEntry)->Next = NULL; \ >- if ((QueueHeader)->Tail) \ >- (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \ >- else \ >- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \ >- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \ >- (QueueHeader)->Number++; \ >-} >- >-// >-// Macros for flag and ref count operations >-// >-#define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) >-#define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) >-#define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0) >-#define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0) >-#define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F)) >- >-#define RTMP_INC_REF(_A) NdisInterlockedIncrement(&(_A)->RefCount) >-#define RTMP_DEC_REF(_A) NdisInterlockedDecrement(&(_A)->RefCount); ASSERT(_A->RefCount >= 0) >-#define RTMP_GET_REF(_A) ((_A)->RefCount) >- >-#define RTMP_INC_RCV_REF(_A) ((_A)->RcvRefCount++) >-#define RTMP_DEC_RCV_REF(_A) ((_A)->RcvRefCount--) >-#define RTMP_GET_RCV_REF(_A) ((_A)->RcvRefCount) >- >-#define RTMP_INC_SEND_REF(_A) ((_A)->SendRefCount++) >-#define RTMP_DEC_SEND_REF(_A) ((_A)->SendRefCount--) >-#define RTMP_GET_SEND_REF(_A) ((_A)->SendRefCount) >- >-#define RTMP_OFFSET(field) ((UINT)FIELD_OFFSET(RTMP_ADAPTER, field)) >-#define RTMP_SIZE(field) sizeof(((PRT2570ADAPTER)0)->field) >-#define PORT_OFFSET(field) ((UINT)FIELD_OFFSET(PORT_CONFIG, field)) >-#define PORT_SIZE(field) sizeof(((PPORT_CONFIG)0)->field) >- >-//blue,#define RTMP_IO_READ32(_A, _R, _pV) RTUSBReadMACRegister((_A), (_R), (_pV)) >-//blue,#define RTMP_IO_WRITE32(_A, _R, _V) RTUSBReadMACRegister((_A), (_R), (_V)) >-// >-// Statistic counter structure >-// >-//mandatory counters from general and Ethernet statistics objects >-typedef struct _COUNTER_802_3 >-{ >- // General Stats >- ULONG GoodTransmits; >- ULONG GoodReceives; >- ULONG TxErrors; >- ULONG RxErrors; >- ULONG RxNoBuffer; >- >- // Ethernet Stats >- ULONG RcvAlignmentErrors; >- ULONG OneCollision; >- ULONG MoreCollisions; >- >-} COUNTER_802_3, *PCOUNTER_802_3; >-//OID_802_11_STATISTICS >-typedef struct _COUNTER_802_11 { >- ULONG Length; >- LARGE_INTEGER TransmittedFragmentCount; >- LARGE_INTEGER MulticastTransmittedFrameCount; >- LARGE_INTEGER FailedCount; >- LARGE_INTEGER NoRetryCount; >- LARGE_INTEGER RetryCount; >- LARGE_INTEGER MultipleRetryCount; >- LARGE_INTEGER RTSSuccessCount; >- LARGE_INTEGER RTSFailureCount; >- LARGE_INTEGER ACKFailureCount; >- LARGE_INTEGER FrameDuplicateCount; >- LARGE_INTEGER ReceivedFragmentCount; >- LARGE_INTEGER MulticastReceivedFrameCount; >- LARGE_INTEGER FCSErrorCount; >-} COUNTER_802_11, *PCOUNTER_802_11; >-//proprietary counters >-typedef struct _COUNTER_RALINK { >- ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput >- ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput >- ULONG BeenDisassociatedCount; >- ULONG BadCQIAutoRecoveryCount; >- ULONG PoorCQIRoamingCount; >- ULONG MgmtRingFullCount; >- ULONG RxCount; >- ULONG DecryptCount; >- ULONG RxRingErrCount; >- ULONG EncryptCount; >- ULONG KickTxCount; >- ULONG TxRingErrCount; >-} COUNTER_RALINK, *PCOUNTER_RALINK; >- >-typedef struct _COUNTER_DRS { >- USHORT TxQuality[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR PER[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition >- ULONG CurrTxRateStableTime; // # of second in current TX rate >- BOOLEAN fNoisyEnvironment; >- UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down >-} COUNTER_DRS, *PCOUNTER_DRS; >- >-typedef struct _COUNTER_QA { >- LARGE_INTEGER CRCErrorCount; >- LARGE_INTEGER RXOverFlowCount; >- LARGE_INTEGER PHYErrorCount; >- LARGE_INTEGER FalseCCACount; >- LARGE_INTEGER U2MDataCount; >- LARGE_INTEGER OtherDataCount; >- LARGE_INTEGER BeaconCount; >- LARGE_INTEGER othersCount; >-} COUNTER_QA, *PCOUNTER_QA; >- >- >-// >-// Arcfour Structure Added by PaulWu >-// >-typedef struct _ARCFOUR >-{ >- UINT X; >- UINT Y; >- UCHAR STATE[256]; >-} ARCFOURCONTEXT, *PARCFOURCONTEXT; >- >-// Shared key data structure >-typedef struct _WEP_KEY { >- UCHAR KeyLen; // Key length for each key, 0: entry is invalid >- UCHAR Key[MAX_LEN_OF_KEY]; // right now we implement 4 keys, 128 bits max >-} WEP_KEY, *PWEP_KEY; >- >-// Shared key data structure >-typedef struct _WPA_KEY { >- UCHAR KeyLen; // Key length for each key, 0: entry is invalid >- UCHAR Key[16]; // right now we implement 4 keys, 128 bits max >- UCHAR RxMic[8]; >- UCHAR TxMic[8]; >- NDIS_802_11_MAC_ADDRESS BssId; // For pairwise key only >- UCHAR TxTsc[6]; // 48bit TSC value >- UCHAR RxTsc[6]; // 48bit TSC value >- UCHAR Type; // Indicate Pairwise / Group >-} WPA_KEY, *PWPA_KEY; >- >-// configuration to be used when this STA starts a new ADHOC network >-typedef struct _IBSS_CONFIG { >- USHORT BeaconPeriod; >- USHORT AtimWin; >- UCHAR Channel; >- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES]; // Supported rates >- UCHAR SupportedRatesLen; >-} IBSS_CONFIG, *PIBSS_CONFIG; >- >-typedef struct _LED_CONTROL { >- BOOLEAN fOdd; >- BOOLEAN fRxActivity; >- BOOLEAN fSiteSurvey; >- BOOLEAN fLinkUp; >- RALINK_TIMER_STRUCT BlinkTimer; // 50 ms periodic timer >-// ULONG LastLedCsr; >- USHORT LastLedCsr; >-} LED_CONTROL; >- >- >-typedef struct _BBP_TUNING_STRUCT { >- BOOLEAN Enable; >- UCHAR FalseCcaCountUpperBound; // 100 per sec >- UCHAR FalseCcaCountLowerBound; // 10 per sec >- UCHAR R17LowerBound; // specified in E2PROM >- UCHAR R17UpperBound; // 0x68 according to David Tung >- UCHAR CurrentR17Value; >-} BBP_TUNING, *PBBP_TUNING; >- >-typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT { >- BOOLEAN PrimaryInUsed; >- UCHAR PrimaryRxAnt; // 0:Ant-A, 1:Ant-B >- UCHAR SecondaryRxAnt; // 0:Ant-A, 1:Ant-B >- USHORT AvgRssi[2]; // AvgRssi[0]:Ant-A, AvgRssi[1]:Ant-B >- RALINK_TIMER_STRUCT RxAntDiversityTimer; >-} SOFT_RX_ANT_DIVERSITY, *PSOFT_RX_ANT_DIVERSITY; >- >- >- >-// PortConfig >-typedef struct _PORT_CONFIG { >- >- // MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1) >- USHORT CapabilityInfo; >- USHORT Psm; // power management mode (PWR_ACTIVE|PWR_SAVE) >- USHORT BeaconPeriod; // in units of TU >- >- USHORT CfpMaxDuration; >- USHORT CfpDurRemain; >- USHORT CfpCount; >- USHORT CfpPeriod; >- >- USHORT DisassocReason; >- MACADDR DisassocSta; >- USHORT DeauthReason; >- MACADDR DeauthSta; >- USHORT AuthFailReason; >- MACADDR AuthFailSta; >- >- NDIS_802_11_AUTHENTICATION_MODE AuthMode;//set by OID_802_11_AUTHENTICATION_MODE. This should match to whatever microsoft defined >- NDIS_802_11_WEP_STATUS WepStatus;//set by OID_802_11_WEP_STATUS >- NDIS_802_11_WEP_STATUS OrigWepStatus; // Original wep status set from OID >- >- // Add to support different cipher suite for WPA2/WPA mode >- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite >- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite >- BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites >- USHORT RsnCapability; >- >-#if 1 >- // MIB:ieee802dot11.dot11smt(1).dot11WEPDefaultKeysTable(3) >- WEP_KEY SharedKey[SHARE_KEY_NO];//set by OID_802_11_ADD_KEY or OID_802_11_ADD_WEP. Keep for backward compatiable >- WPA_KEY PairwiseKey[PAIRWISE_KEY_NO];//set by OID_802_11_ADD_KEY >- WPA_KEY GroupKey[GROUP_KEY_NO];//set by OID_802_11_ADD_KEY >- WPA_KEY PskKey; // WPA PSK mode PMK >- BSSID_INFO SavedPMK[PMKID_NO]; >- ULONG SavedPMKNum; // Saved PMKID number >- UCHAR PTK[64]; >-#endif >- // WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED >- UCHAR PortSecured; >- >- // For WPA countermeasures >- ULONG LastMicErrorTime; // record last MIC error time >- ULONG MicErrCnt; // Should be 0, 1, 2, then reset to zero (after disassoiciation). >- BOOLEAN bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred. >- >- // For WPA-PSK supplicant state,red, add for WPA-PSK >- WPA_STATE WpaState; // Default is SS_NOTUSE and handled by microsoft 802.1x >- UCHAR ReplayCounter[8]; >- UCHAR ANonce[32]; // ANonce for WPA-PSK from aurhenticator >- UCHAR SNonce[32]; // SNonce for WPA-PSK >- >- // MIB:ieee802dot11.dot11smt(1).dot11WEPKeyMappingsTable(4) >- // not implemented yet >- >- // MIB:ieee802dot11.dot11smt(1).dot11PrivacyTable(5) >- UCHAR DefaultKeyId;//set by OID_802_11_ADD_KEY or OID_802_11_ADD_WEP >- NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X >- >- // MIB:ieee802dot11.dot11mac(2).dot11OperationTable(1) >- USHORT RtsThreshold; // in units of BYTE >- USHORT FragmentThreshold; >- BOOLEAN bFragmentZeroDisable; // Microsoft use 0 as disable >- >- // MIB:ieee802dot11.dot11phy(4).dot11PhyAntennaTable(2) >- UCHAR CurrentTxAntenna; >- UCHAR CurrentRxAntenna; >- UCHAR NumberOfAntenna; >- >- // MIB:ieee802dot11.dot11phy(4).dot11PhyTxPowerTable(3) >- UCHAR CurrentTxPowerLevelIndex; //default&other value=MaxPower,1=MinPower,2=1*MaxPower/4,3=2*MaxPower/4,4=3*MaxPower/4, >- UCHAR TxPower; >- UCHAR TxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11, ... >- BOOLEAN EnableAutoRateSwitching; // 1 - enable auto rate switching; 0 - disable >- ULONG TxPowerPercentage; // 0~100 %,blue >- >- // MIB:ieee802dot11.dot11phy(4).dot11PhyDSSSTable(5) >- UCHAR Channel; // current (I)BSS channel used in the station >- UCHAR CountryRegion; // Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel >- >- // MIB:ieee802dot11.dot11phy(4).dot11AntennasListTable(8) >- BOOLEAN AntennaSupportTx; >- BOOLEAN AntennaSupportRx; >- BOOLEAN AntennaSupportDiversityRx; >- >- // Use user changed MAC >- BOOLEAN bLocalAdminMAC; >- >- // MIB:ieee802dot11.dot11phy(4).dot11SupportedDataRatesTxTable(9) >- // MIB:ieee802dot11.dot11phy(4).dot11SupportedDataRatesRxTable(10) >- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES]; // Supported rates >- UCHAR SupportedRatesLen; >- UCHAR ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES]; >- >- //blue >- // Copy supported rate from desired AP's beacon. We are trying to match >- // AP's supported and extended rate settings. >- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR SupRateLen; >- UCHAR ExtRateLen; >- >- // >- // other parameters not defined in standard MIB >- // >- UCHAR DesiredRates[MAX_LEN_OF_SUPPORTED_RATES]; // OID_802_11_DESIRED_RATES >- UCHAR MaxDesiredRate; >- USHORT RecvDtim; >- MACADDR Bssid; >- MACADDR Broadcast; // FF:FF:FF:FF:FF:FF >- USHORT Pss; // current power saving status (PWR_SAVE|PWR_ACTIVE) >- UCHAR RssiTrigger; >- UCHAR RssiTriggerMode; // RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD >- UCHAR LastRssi; // last received BEACON's RSSI >- USHORT AvgRssi; // last 8 BEACON's average RSSI,blue >- USHORT AtimWin; // in kusec; IBSS parameter set element >- USHORT Aid; // association ID >- UCHAR RtsRate; // RATE_xxx >- UCHAR MlmeRate; // RATE_xxx, used to send MLME frames >- UCHAR MaxTxRate; // RATE_xxx >- USHORT DefaultListenCount; // default listen count; >- UCHAR BssType; // BSS_INFRA or BSS_INDEP >- >- UCHAR SsidLen; // the actual ssid length in used >- CHAR Ssid[MAX_LEN_OF_SSID]; // NOT NULL-terminated >- >- BSS_TABLE BssTab; // BSS Table >- >- // global variables mXXXX used in MAC protocol state machines >- BOOLEAN Mibss; >- BOOLEAN Massoc; >- BOOLEAN Mauth; >- >- // PHY specification >- UCHAR PhyMode; // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED >- USHORT Dsifs; // in units of usec >- >- ULONG WindowsPowerMode; // Power mode for AC power >- //ULONG WindowsBatteryPowerMode; // Power mode for battery if exists >- //BOOLEAN WindowsACCAMEnable; // Enable CAM power mode when AC on >- ULONG PacketFilter; // Packet filter for receiving >- BOOLEAN AutoReconnect; // Set to TRUE when setting OID_802_11_SSID with no matching BSSID >-#ifdef NDIS51_MINIPORT >- ULONG WindowsPowerProfile; // Windows power profile, for NDIS5.1 PnP >-#endif >- ULONG WindowsTxPreamble; // Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto >- >- UCHAR ChannelTxPower[MAX_LEN_OF_CHANNELS]; // Store Tx power value for all channels. >- >- //blue >- UCHAR ChannelTssiRef[MAX_LEN_OF_CHANNELS]; // Store Tssi Reference value for all channels. >- UCHAR ChannelTssiDelta; // Store Tx TSSI delta increment / decrement value >- BOOLEAN bAutoTxAgc; >- >- UCHAR ChannelList[MAX_LEN_OF_CHANNELS]; // list all supported channels for site survey >- UCHAR ChannelListNum; // number of channel in ChannelList[] >- BOOLEAN bShowHiddenSSID;//blue >- >- // configuration to be used when this STA starts a new ADHOC network >- IBSS_CONFIG IbssConfig; >- >- ULONG LastBeaconRxTime; // OS's timestamp of the last BEACON RX time >- atomic_t DataPacketsFromAP; // # of data packets received from AP since we receive last Beacon from AP >- ULONG Last11bBeaconRxTime; // OS's timestamp of the last 11B BEACON RX time >- ULONG LastScanTime; // Record last scan time for issue BSSID_SCAN_LIST >- ULONG IgnoredScanNumber; // Ignored BSSID_SCAN_LIST requests >- BOOLEAN bSwRadio; // Software controlled Radio On/Off, TRUE: On >- BOOLEAN bHwRadio; // Hardware controlled Radio On/Off, TRUE: On >- BOOLEAN bRadio; // Radio state, And of Sw & Hw radio state >- BOOLEAN bHardwareRadio; // Hardware-controlled Radio enabled >- >- LED_CONTROL LedCntl; >- UCHAR RfType; >- UCHAR LedMode; >- >- // New for WPA, windows want us to to keep association information and >- // Fixed IEs from last association response >- NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo; >-// NDIS_802_11_FIXED_IEs FixIEs; >- UCHAR ReqVarIELen; // Length of next VIE include EID & Length >- UCHAR ReqVarIEs[MAX_VIE_LEN]; >- UCHAR ResVarIELen; // Length of next VIE include EID & Length >- UCHAR ResVarIEs[MAX_VIE_LEN]; >- >- // the following fields are user setting from UI >- ULONG EnableTurboRate; // 0: disable, 1: enable 72/100 Mbps whenever applicable >- ULONG EnableTxBurst; // 0: disable, 1: enable TX PACKET BURST >- ULONG UseBGProtection; // 0: auto, 1: always use, 2: always not use >- ULONG UseShortSlotTime; // 0: disable, 1: enable 9us short slot time if AP supports >- //blue,ULONG UseOfdmRatesIn11gAdhoc; // 0:WIFI mode (11b rates only), 1:allow OFDM rates >- ULONG AdhocMode; // 0:WIFI mode (11b rates only), 1: b/g mixed, 2: 11g only,blue >- >- // this flag is the result calculated from UI settings and AP's ERP/Capability >- ULONG BGProtectionInUsed; // 0: not in-used, 1: in-used >- ULONG ShortSlotInUsed; // 0: not in-used, 1: in-used >- USHORT TxPreambleInUsed; // Rt802_11PreambleLong, Rt802_11PreambleShort >- UCHAR CipherAlg; >- >- // latch th latest RF programming value here since RF IC doesn't support READ operation >- RTMP_RF_REGS LatchRfRegs; >- >- //blue >- BOOLEAN BbpTuningEnable; >- UCHAR VgcLowerBound; >- RT_802_11_RX_AGC_VGC_TUNING BbpTuning; >- UCHAR LastR17Value; >- >- ULONG SystemErrorBitmap; // b0: E2PROM version error >- >- //blue >- UCHAR BbpWriteLatch[100]; // record last BBP register value written via BBP_IO_WRITE >- ULONG CurrTxRateStableTime; // # of second in current TX rate >- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition >- >- // For WPA-PSK supplicant state >- //red,WPA_STATE WpaState; // Default is SS_NOTUSE and handled by microsoft 802.1x >- >- >-} PORT_CONFIG, *PPORT_CONFIG; >- >-typedef struct _MLME_MEMORY_STRUCT { >- PVOID AllocVa; //Pointer to the base virtual address of the allocated memory >- struct _MLME_MEMORY_STRUCT *Next; //Pointer to the next virtual address of the allocated memory >-} MLME_MEMORY_STRUCT, *PMLME_MEMORY_STRUCT; >- >-typedef struct _MLME_MEMORY_HANDLER { >- BOOLEAN MemRunning; //The flag of the Mlme memory handler's status >- UINT MemoryCount; //Total nonpaged system-space memory not size >- UINT InUseCount; //Nonpaged system-space memory in used counts >- UINT UnUseCount; //Nonpaged system-space memory available counts >- UINT PendingCount; //Nonpaged system-space memory for free counts >- PMLME_MEMORY_STRUCT pInUseHead; //Pointer to the first nonpaed memory not used >- PMLME_MEMORY_STRUCT pInUseTail; //Pointer to the last nonpaged memory not used >- PMLME_MEMORY_STRUCT pUnUseHead; //Pointer to the first nonpaged memory in used >- PMLME_MEMORY_STRUCT pUnUseTail; //Pointer to the last nonpaged memory in used >- PULONG MemFreePending[MAX_MLME_HANDLER_MEMORY]; //an array to keep pending free-memory's pointer (32bits) >-} MLME_MEMORY_HANDLER, *PMLME_MEMORY_HANDLER; >- >-typedef struct _MLME_STRUCT { >- STATE_MACHINE CntlMachine, AssocMachine, AuthMachine, AuthRspMachine, SyncMachine,WpaPskMachine; >- STATE_MACHINE_FUNC CntlFunc[CNTL_FUNC_SIZE], AssocFunc[ASSOC_FUNC_SIZE]; >- STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE], AuthRspFunc[AUTH_RSP_FUNC_SIZE]; >- STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE],WpaPskFunc[WPA_PSK_FUNC_SIZE]; >- >- ASSOC_AUX AssocAux; >- AUTH_AUX AuthAux; >- AUTH_RSP_AUX AuthRspAux; >- SYNC_AUX SyncAux; >- CNTL_AUX CntlAux; >- >- COUNTER_802_11 PrevWlanCounters; >- ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming >- >- BOOLEAN Running; >- spinlock_t TaskLock; >- MLME_QUEUE Queue; >- >- UINT ShiftReg; >-// PSPOLL_FRAME PsFr; >-// MACHDR NullFr; >- >- RALINK_TIMER_STRUCT PeriodicTimer; >- ULONG PeriodicRound; >- ULONG PrevTxCnt; >- >- MLME_MEMORY_HANDLER MemHandler; //The handler of the nonpaged memory inside MLME >- >-} MLME_STRUCT, *PMLME_STRUCT; >- >-// >-// Management ring buffer format >-// >-typedef struct _MGMT_STRUC { >- BOOLEAN Valid; >- PUCHAR pBuffer; >- ULONG Length; >- UCHAR FirstIndex; >- UCHAR ContextsRequired; >- struct _MGMT_STRUC *next;//blue >-} MGMT_STRUC, *PMGMT_STRUC; >- >-// >-// P802.11 Frame control field, 16 bit >-// >-typedef struct _FRAME_CONTROL { >- USHORT Ver:2; // Protocol version >- USHORT Type:2; // MSDU type >- USHORT Subtype:4; // MSDU subtype >- USHORT ToDs:1; // To DS indication >- USHORT FrDs:1; // From DS indication >- USHORT MoreFrag:1; // More fragment bit >- USHORT Retry:1; // Retry status bit >- USHORT PwrMgt:1; // Power management bit >- USHORT MoreData:1; // More data bit >- USHORT Wep:1; // Wep data >- USHORT Order:1; // Strict order expected >-} FRAME_CONTROL, *PFRAME_CONTROL; >- >-// >-// P802.11 intermediate header format >-// >-typedef struct _CONTROL_HEADER { >- FRAME_CONTROL Frame; // Frame control structure >- USHORT Duration; // Duration value >- MACADDR Addr1; // Address 1 field >- MACADDR Addr2; // Address 2 field >-} CONTROL_HEADER, *PCONTROL_HEADER; >- >-typedef struct _PS_POLL_BUFFER { >- TXD_STRUC TxDesc; >- PSPOLL_FRAME PsPollPacket; >-} PS_POLL_BUFFER, *PPS_POLL_BUFFER; >- >-// >-// P802.11 header format >-// >-typedef struct _HEADER_802_11 { >- CONTROL_HEADER Controlhead; >- MACADDR Addr3; // Address 3 field >- USHORT Frag:4; // Fragment number >- USHORT Sequence:12; // Sequence number >-} HEADER_802_11, *PHEADER_802_11; >- >-typedef struct _NULL_FRAME_BUFFER { >- TXD_STRUC TxDesc; >- HEADER_802_11 NullFrame; >-} NULL_FRAME_BUFFER, *PNULL_FRAME_BUFFER; >- >-typedef struct _WPAPSK_BUFFER { >- TXD_STRUC TxDesc; >- UCHAR WpaPskFrame[512]; >-} WPAPSK_BUFFER, *PWPAPSK_BUFFER; >- >- >- >-typedef struct _STUFF_BUFFER { >- NULL_FRAME_BUFFER NullFrameBuffer; >- UCHAR StuffBuffer[512]; >-} STUFF_BUFFER, *PSTUFF_BUFFER; >- >-// >-// Receive Tuple Cache Format >-// >-typedef struct _TUPLE_CACHE { >- BOOLEAN Valid; >- MACADDR MAC; >- USHORT Sequence; >- USHORT Frag; >-} TUPLE_CACHE, *PTUPLE_CACHE; >- >-// >-// Fragment Frame structure >-// >-typedef struct _FRAGMENT_FRAME { >- UCHAR Header802_3[14]; >- UCHAR Header_LLC[8]; >- UCHAR Buffer[MAX_FRAME_SIZE]; >- ULONG RxSize; >- USHORT Sequence; >- USHORT LastFrag; >- ULONG Flags; // Some extra frame information. bit 0: LLC presented >-} FRAGMENT_FRAME, *PFRAGMENT_FRAME; >- >-// >-// Packet information for NdisQueryPacket >-// >-typedef struct _PACKET_INFO { >- UINT PhysicalBufferCount; // Physical breaks of buffer descripor chained >- UINT BufferCount ; // Number of Buffer descriptor chained >- UINT TotalPacketLength ; // Self explained >- //PNDIS_BUFFER pFirstBuffer; // Pointer to first buffer descriptor >-} PACKET_INFO, *PPACKET_INFO; >- >-// >-// Tkip Key structure which RC4 key & MIC calculation >-// >-typedef struct _TKIP_KEY_INFO { >- UINT nBytesInM; // # bytes in M for MICKEY >- ULONG IV16; >- ULONG IV32; >- ULONG K0; // for MICKEY Low >- ULONG K1; // for MICKEY Hig >- ULONG L; // Current state for MICKEY >- ULONG R; // Current state for MICKEY >- ULONG M; // Message accumulator for MICKEY >- UCHAR RC4KEY[16]; >- UCHAR MIC[8]; >-} TKIP_KEY_INFO, *PTKIP_KEY_INFO; >- >-// >-// Private / Misc data, counters for driver internal use >-// >-typedef struct __PRIVATE_STRUC { >- ULONG SystemResetCnt; // System reset counter >- ULONG ResetCountDown; // Count down before issue reset, patch for RT2430 >-// ULONG CCAErrCnt; // CCA error count, for debug purpose, might move to global counter >- ULONG PhyRxErrCnt; // PHY Rx error count, for debug purpose, might move to global counter >- ULONG PhyTxErrCnt; // PHY Tx error count, for debug purpose, might move to global counter >- // Variables for WEP encryption / decryption in rtmp_wep.c >- ULONG FCSCRC32; >- ULONG RxSetCnt; >- ULONG DecryptCnt; >- ARCFOURCONTEXT WEPCONTEXT; >- // Tkip stuff >- TKIP_KEY_INFO Tx; >- TKIP_KEY_INFO Rx; >-} PRIVATE_STRUC, *PPRIVATE_STRUC; >- >- >- >-///////////////// >-//Vendor Commands >-///////////////// >-#define COMMAND_QUEUE_SIZE 11 >- >-typedef struct _CmdQElmt { >- UINT command; >- PVOID buffer; >- ULONG bufferlength; >- BOOLEAN CmdFromNdis; >- BOOLEAN SetOperation; >- BOOLEAN InUse;//blue >- struct _CmdQElmt *next; >-} CmdQElmt, *PCmdQElmt; >- >-typedef struct _CmdQ { >- UINT size; >- CmdQElmt *head; >- CmdQElmt *tail; >-} CmdQ, *PCmdQ; >- >-typedef enum _BULK_OUT_TYPE { >- DATA, >- MLME, >- BEACON, >- PS_POLL, >- ALL >-} BULK_OUT_TYPE; >- >-#if 0 >-typedef struct _BULK_OUT_QUEUE_ELEMENT { >- BULK_OUT_TYPE BulkOutType; >- PVOID buffer; >- struct _BULK_OUT_QUEUE_ELEMENT *next; >-} BULK_OUT_QUEUE_ELEMENT, *PBULK_OUT_QUEUE_ELEMENT; >- >-typedef struct _BULK_OUT_QUEUE { >- UINT size; >- BULK_OUT_QUEUE_ELEMENT *head; >- BULK_OUT_QUEUE_ELEMENT *tail; >-} BULK_OUT_QUEUE, *PBULK_OUT_QUEUE; >- >-typedef struct _BULK_OUT_QUEUE_ELEMENT { >- PVOID buffer; >- struct _BULK_OUT_QUEUE_ELEMENT *next; >-} BULK_OUT_QUEUE_ELEMENT, *PBULK_OUT_QUEUE_ELEMENT; >- >-typedef struct _BULK_OUT_QUEUE { >- UINT size; >- BULK_OUT_QUEUE_ELEMENT *head; >- BULK_OUT_QUEUE_ELEMENT *tail; >-} BULK_OUT_QUEUE, *PBULK_OUT_QUEUE; >-#endif >- >-//blue >-typedef struct _DATA_BULKOUT_QUEUE { >- UINT size; >- struct sk_buff *head; >- struct sk_buff *tail; >-} DATA_BULKOUT_QUEUE, *PDATA_BULKOUT_QUEUE; >- >-typedef struct _MLME_BULKOUT_QUEUE { >- UINT size; >- PMGMT_STRUC head; >- PMGMT_STRUC tail; >-} MLME_BULKOUT_QUEUE, *PMLME_BULKOUT_QUEUE; >- >-#if 0 >-typedef enum bufferStates { >- FREE, >- USED, >- COMPLETED, >- PENDING >-} BufferState; >-#endif >- >-// used to track driver-generated write irps >-typedef struct _TX_CONTEXT >-{ >- >- PVOID pAdapter;//Initialized in MiniportInitialize >- // struct sk_buff *skb; >- PURB pUrb;//Initialized in MiniportInitialize >- PIRP pIrp;//used to cancel pending bulk out.//Initialized in MiniportInitialize >- PTX_BUFFER TransferBuffer;//Initialized in MiniportInitialize >- ULONG BulkOutSize; >- BOOLEAN InUse; >- BOOLEAN IRPPending; >- BOOLEAN LastOne; >-} >-TX_CONTEXT, *PTX_CONTEXT, **PPTX_CONTEXT; >- >-// used to track driver-generated write irps >-typedef struct _MLME_CONTEXT >-{ >- PVOID pAdapter;//Initialized in MiniportInitialize >- PMGMT_STRUC pMgmt; >- PURB pUrb;//Initialized in MiniportInitialize >- PIRP pIrp;//used to cancel pending bulk out.//Initialized in MiniportInitialize >- PTX_BUFFER TransferBuffer;//Initialized in MiniportInitialize >-// UINT TransferBufferLength;//TransferBufferLength >-// CONTEXT_TYPE Type; >-// BufferState fInUse; // Declared as ULONG so can use with InterlockedExchange() >- BOOLEAN InUse; >- BOOLEAN IRPPending; >- BOOLEAN LastOne; >- UCHAR Index; >-} >-MLME_CONTEXT, *PMLME_CONTEXT, **PPMLME_CONTEXT; >- >- >-typedef struct _NULL_CONTEXT >-{ >- PVOID pAdapter;//Initialized in MiniportInitialize >- PURB pUrb;//Initialized in MiniportInitialize >- PIRP pIrp;//used to cancel pending bulk out. >- PNULL_FRAME_BUFFER TransferBuffer;//Initialized in MiniportInitialize >-// UINT TransferBufferLength;//TransferBufferLength >-// BufferState fInUse; // Declared as ULONG so can use with InterlockedExchange() >- BOOLEAN InUse; >- BOOLEAN IRPPending; >-} >-NULL_CONTEXT, *PNULL_CONTEXT; >- >- >-typedef struct _WPAPSK_CONTEXT >-{ >- PVOID pAdapter;//Initialized in MiniportInitialize >- PURB pUrb;//Initialized in MiniportInitialize >- PIRP pIrp;//used to cancel pending bulk out. >- PWPAPSK_BUFFER TransferBuffer;//Initialized in MiniportInitialize >-// UINT TransferBufferLength;//TransferBufferLength >-// BufferState fInUse; // Declared as ULONG so can use with InterlockedExchange() >- BOOLEAN InUse; >- BOOLEAN Ready; >- BOOLEAN IRPPending; >-} >-WPAPSK_CONTEXT, *PWPAPSK_CONTEXT; >- >-typedef struct _PS_POLL_CONTEXT >-{ >- PVOID pAdapter;//Initialized in MiniportInitialize >- PURB pUrb;//Initialized in MiniportInitialize >- PIRP pIrp;//used to cancel pending bulk out. >- PPS_POLL_BUFFER TransferBuffer;//Initialized in MiniportInitialize >-// UINT TransferBufferLength;//TransferBufferLength >-// BufferState fInUse; // Declared as ULONG so can use with InterlockedExchange() >- BOOLEAN InUse; >- BOOLEAN Ready; >- BOOLEAN IRPPending; >-} >-PS_POLL_CONTEXT, *PPS_POLL_CONTEXT; >- >-typedef struct _STUFF_CONTEXT >-{ >- PVOID pAdapter;//Initialized in MiniportInitialize >- PURB pUrb;//Initialized in MiniportInitialize >- PIRP pIrp;//used to cancel pending bulk out. >- PSTUFF_BUFFER TransferBuffer;//Initialized in MiniportInitialize >-// UINT TransferBufferLength;//TransferBufferLength >-// BufferState fInUse; // Declared as ULONG so can use with InterlockedExchange() >- BOOLEAN InUse; >- BOOLEAN Ready; >- BOOLEAN IRPPending; >-} >-STUFF_CONTEXT, *PSTUFF_CONTEXT; >- >-// >-// Structure to keep track of receive packets and buffers to indicate >-// receive data to the protocol. >-// >-#define IRPLOCK_COMPLETED 0 >-#define IRPLOCK_CANCELABLE 1 >-#define IRPLOCK_CANCE_START 2 >-#define IRPLOCK_CANCE_COMPLETE 3 >- >-typedef struct _RX_CONTEXT >-{ >- PVOID pAdapter; >- PIRP pIrp; //used to cancel pending bulk in. >- PURB pUrb; >- BOOLEAN InUse; >- atomic_t IrpLock; >- PUCHAR TransferBuffer; >-} >-RX_CONTEXT, *PRX_CONTEXT; >-#if 0 >-// NDIS >-typedef struct _RX_CONTEXT >-{ >- PUCHAR TransferBuffer; >- PVOID pAdapter; >- PIRP pIrp;//used to cancel pending bulk in. >- PURB pUrb; >- BOOLEAN InUse; >- IRPLOCK IrpLock; >-} RX_CONTEXT, *PRX_CONTEXT; >-#endif >-typedef struct _VENDOR_REQUEST_URB >-{ >- PURB pUrb; >-// BOOLEAN InUse; >- PIRP pIrp;//used to cancel pending IRP >- BOOLEAN IRPPending; >-} >-VENDOR_REQUEST_URB; >- >- >-typedef struct _TX_RATE_SWITCHING_STRUC >-{ >- ULONG LastStableTime; >- UCHAR DownRate1Ratio; >- UCHAR DownRate2Ratio; >- UCHAR UpRateRatio; >- UCHAR StableTimeRequired; >- UCHAR PenaltyPeriod; >- UCHAR DownWaitingTime; >-} >-TX_RATE_SWITCHING_STRUC, *PTX_RATE_SWITCHING_STRUC; >- >-typedef struct _TX_RATE_SWITCHING_COUNTERS >-{ >- USHORT NoRetryOKCnt; >- USHORT OneRetryOKCnt; >- USHORT MRetryOKCnt; >- USHORT FailCnt; >-} >-TX_RATE_SWITCHING_COUNTERS, *PTX_RATE_SWITCHING_COUNTERS; >- >-typedef struct _BBP_TUNING_PARAMETERS_STRUC >-{ >- UCHAR BBPTuningThreshold; >- UCHAR R24LowerValue; >- UCHAR R24HigherValue; >- UCHAR R25LowerValue; >- UCHAR R25HigherValue; >- UCHAR R61LowerValue; >- UCHAR R61HigherValue; >- UCHAR BBPR17LowSensitivity; >- UCHAR BBPR17MidSensitivity; >- UCHAR RSSIToDbmOffset; >- BOOLEAN LargeCurrentRSSI; >-} >-BBP_TUNING_PARAMETERS_STRUC, *PBBP_TUNING_PARAMETERS_STRUC; >- >-#define IEEE80211_NWID_LEN 32 >- >- >-#define UNLINK_TIMEOUT_MS 3 >-// >-// The miniport adapter structure >-// >-typedef struct _RT2570_ADAPTER >-{ >- int nicknamelen; >- char nickn[IEEE80211_NWID_LEN+1]; // nickname, only used in the iwconfig i/f >- struct tasklet_struct rx_bh; >- struct usb_device *usb; >- //KERNEL266 >- struct usb_config_descriptor *config; >- //struct usb_host_config *config; >- devctrlrequest *devreq; >- /* The device we're working with >- * It's important to note: >- * (o) you must hold dev_semaphore to change pusb_dev >- */ >- struct semaphore usbdev_semaphore; /* protect usb */ >- // Thread >- struct semaphore mlme_semaphore; /* to sleep thread on */ >- struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */ >- struct completion notify; /* thread begin/end */ >- pid_t MLMEThr_pid; >- pid_t RTUSBCmdThr_pid; >- wait_queue_head_t *wait; >- >- spinlock_t *lock; >-#if 1 >- UINT SET_R17_FLAG; >- UCHAR BBPR17InitValue; >- UCHAR ResetRequest; >- UCHAR BulkAction; >-#endif >- >- struct net_device *net; >- BOOLEAN bNetDeviceStopQueue; >- >-#if WIRELESS_EXT >= 12 >- struct iw_statistics iw_stats; >-#endif >- >- struct net_device_stats netstats; >- >- // configuration >- UCHAR PermanentAddress[ETH_LENGTH_OF_ADDRESS]; // Factory default MAC address >- UCHAR CurrentAddress[ETH_LENGTH_OF_ADDRESS]; // User changed MAC address >- >- USHORT EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS]; >- USHORT EEPROMBBPTuningParameters[NUM_EEPROM_BBP_TUNING_PARMS]; >- >- // >- // Handle given by NDIS when the Adapter registered itself. >- // Various NDIS handle function >- // >- >- MGMT_STRUC MgmtRing[MGMT_RING_SIZE]; // management ring size >- >- UCHAR NextTxIndex; // Next TxD write pointer >- UCHAR NextMLMEIndex; // Next PrioD write pointer >- UCHAR PushMgmtIndex; // Next SW management ring index >- UCHAR PopMgmtIndex; // Next SW management ring index >- atomic_t MgmtQueueSize; // Number of Mgmt request stored in MgmtRing >- UCHAR NextRxBulkInIndex; >- UCHAR NextBulkOutIndex; >- BOOLEAN BulkOutPending; >- BOOLEAN ControlPending; >- ULONG PrioRingTxCnt; >- UCHAR PrioRingFirstIndex; >- >- // 802.3 multicast support >- ULONG NumberOfMcAddresses; // Number of mcast entry exists >- UCHAR McastTable[MAX_MCAST_LIST_SIZE][ETH_LENGTH_OF_ADDRESS]; // Mcast list >- ULONG Flags; // Represent current device status >- >- // Flags for bulk out data priority >- ULONG BulkFlags; >- ///////////////////// >- // Transmit Path >- ///////////////////// >- atomic_t TxCount; // Number of Bulkout waiting to be send. >- TX_CONTEXT TxContext[TX_RING_SIZE]; >- TX_CONTEXT MLMEContext[PRIO_RING_SIZE]; >- TX_CONTEXT BeaconContext[BEACON_RING_SIZE]; >- TX_CONTEXT NullContext; >- TX_CONTEXT PsPollContext; >- RTS_BUFFER RTSBuffer; >- >- WPAPSK_CONTEXT WpaPskContext; >- PUCHAR TxBuffer; >- TX_BUFFER TxMgmtBuf; >- >- ///////////////////// >- // Receive Path >- ///////////////////// >- RX_CONTEXT RxContext[RX_RING_SIZE]; >- PURB pRxUrb;//red: test mode only >- PIRP pRxIrp; >- PUCHAR RxBuffer; >- // SEND queue list >- QUEUE_HEADER SendTxWaitQueue; >- >- USHORT Sequence; // Current sequence number >- >- TUPLE_CACHE TupleCache[MAX_CLIENT]; // Maximum number of tuple caches, only useful in Ad-Hoc >- UCHAR TupleCacheLastUpdateIndex; // 0..MAX_CLIENT-1 >- FRAGMENT_FRAME FragFrame; // Frame storage for fragment frame >- >- // For MiniportTransferData >- PUCHAR pRxData; // Pointer to current RxRing offset / fragment frame offset >- >- // Counters for 802.3 & generic. >- // Add 802.11 specific counters later >- COUNTER_802_3 Counters; // 802.3 counters >- COUNTER_802_11 WlanCounters; // 802.11 MIB counters >- COUNTER_RALINK RalinkCounters; // Ralink propriety counters >- COUNTER_DRS DrsCounters; // counters for Dynamic Rate Switching >- COUNTER_QA QACounters; // Ralink propriety counters >- >- NDIS_MEDIA_STATE MediaState; >- UCHAR StationState; >- >- NDIS_DEVICE_POWER_STATE CurrentPowerState; // Current device power state >- NDIS_DEVICE_POWER_STATE NextPowerState; // Next device power state >- >- PRIVATE_STRUC PrivateInfo; // Private information & counters >- >- // SpinLocks >- spinlock_t SendTxWaitQueueLock; // SendTxWaitQueue spinlock >- spinlock_t MLMEWaitQueueLock; // SendTxWaitQueue spinlock >- spinlock_t CmdQLock; // SendTxWaitQueue spinlock >- spinlock_t BulkOutLock; // SendTxWaitQueue spinlock >- spinlock_t ControlLock; // SendTxWaitQueue spinlock >- spinlock_t MLMEQLock; // SendTxWaitQueue spinlock >- spinlock_t GenericLock; // SendTxWaitQueue spinlock >- spinlock_t MemLock; // need to check >- >- // Reference count >- LONG RefCount; // Keep adapter refer count for checkforhang & halt >- ULONG SendRefCount; // number of packet that have not been confirmed >- ULONG RcvRefCount; // number of packets that have not been returned back >- >- // Various NDIS Event >- int ExitEvent; >- >- >- NDIS_MEDIA_STATE LinkIsActive; >- ULONG CurrentLookAhead; >- CmdQ CmdQ; >- DATA_BULKOUT_QUEUE DataQ; >- MLME_BULKOUT_QUEUE MLMEQ; >- >- // Boolean control for packet filter >- BOOLEAN bAcceptDirect; >- BOOLEAN bAcceptMulticast; >- BOOLEAN bAcceptBroadcast; >- BOOLEAN bAcceptAllMulticast; >- >- // Control to check Tx hang >- BOOLEAN bTxBusy; >- PQUEUE_ENTRY FirstEntryInQueue; // The first packet in Tx queue >- >- // Control disconnect / connect event generation >- ULONG LinkDownTime; >- UCHAR LastSsidLen; // the actual ssid length in used >- CHAR LastSsid[MAX_LEN_OF_SSID]; // NOT NULL-terminated >- MACADDR LastBssid; >- BOOLEAN bConfigChanged; // Config Change flag for the same SSID setting >- >- PORT_CONFIG PortCfg; >- MLME_STRUCT Mlme; >- ///////////////////// >- // USB >- ///////////////////// >- USHORT BulkOutMaxPacketSize; // 64 in XP >- USHORT BulkInMaxPacketSize; >- >- ///////////////////// >- // Control Flags >- ///////////////////// >- LONG PendingTx; >- atomic_t PendingRx; >- LONG PendingReset; >- LONG BulkOutFailed; >- LONG BulkInFailed; >- LONG DeviceFailed; >- UCHAR DeviceMode; >- BOOLEAN UnplugDevice; >- atomic_t TerminateThreads; >- atomic_t PendingIoCount; >- BOOLEAN BSSSelected; >- BOOLEAN StationWasAssociated; >- BOOLEAN StationIsAssociated; >- BOOLEAN StationIsAuthenticated; >- UCHAR WepLevel; >- BOOLEAN OutOfRangeDetected; >- BOOLEAN AddressOverrided; >- BOOLEAN AutoAuthentication; >- BOOLEAN AutoPreamble; >- BOOLEAN AutoJoin; >- BOOLEAN UseInternalFWImage; >- BOOLEAN AnyAP; >- >- PVOID pInformationBuffer; >- ULONG InformationBufferLength; >- PULONG pBytesWritten; >- PULONG pBytesNeeded; >- BOOLEAN SendDelimitingPacket; >- ULONG DelimitingPacketSent; >- UINT FragmentsSent; >- USHORT BulkOutLength; >- USHORT BulkOutRemained; >- BOOLEAN ContinBulkOut; >- USHORT BulkInRemained; >- BOOLEAN ContinBulkIn; >- BOOLEAN BeaconIntervalChangeAllowed; >- USHORT SentBeaconsCount; >- USHORT ReceivedBeaconsCount; >- LARGE_INTEGER TransmittedFragmentCount; >-#ifdef TEST_MODE_SUPPORT >- CmdQElmt CmdQElements[12]; >-#else >- CmdQElmt CmdQElements[COMMAND_QUEUE_SIZE]; >-#endif >- >- USHORT MACCounters[11]; >- TX_RATE_SWITCHING_STRUC TxRateSwitchingStruc[12]; >- ULONG CurrRateGoodTime; >- UCHAR CurrRateBadTime; >- UCHAR TxQuality; >- BBP_TUNING_PARAMETERS_STRUC BBPTuningParameters; >- ULONG LastRxRate; >- ULONG PacketsSentBetweenTBTTs; >- BOOLEAN ScanAllowed; >- // Alpha can't link up problem >- ULONG ExtraInfo; // Extra information for displaying status >- struct net_device_stats net_device_stats; /* interface statistics */ >- >-} RT2570ADAPTER, *PRT2570ADAPTER; >- >- >- >-#endif >- >- >- >- >- >- >-//////////////////////////////////////////////////////////////////////////// >-// >-// inline FUNCTIONS >-// >-// IncrementIoCount and DecrementIoCount >-// >-// DESCRIPTION >-// >-// We keep a pending IO count. This count is initialized to one. >-// Subsequently, the count is incremented for each new IRP received or >-// created and is decremented when each IRP is completed. >-// Transition to 'one' therefore indicates no IO is pending and signals >-// Adapter->RemoveEvent. Transition to 'zero' signals an event >-// (Adapter->RemoveEvent) to enable device removal. >-// >-// INPUT >-// >-// Adapter Ptr to the adapter object >-// >-// OUTPUT >-// >-// - >-// >-//////////////////////////////////////////////////////////////////////////// >-inline VOID IncrementIoCount(PRT2570ADAPTER Adapter); >-inline VOID DecrementIoCount(IN PRT2570ADAPTER pAdapter); >- >- >- >-//////////////////////////////////////////////////////////////////////////// >-// __inline VOID EnQTxPacket(PRT2570ADAPTER Adapter, PNDIS_PACKET Packet) >-// { >-// PTX_QUEUE tempTxQnode; >-// >-// >-// if (AllocateMemory(&tempTxQnode, sizeof(TX_QUEUE))!=NDIS_STATUS_SUCCESS) >-// { >-// NdisMSendComplete(Adapter->AdapterHandle, Packet, NDIS_STATUS_SUCCESS); >-// return; >-// } >-// >-// tempTxQnode->pNdisPacket = Packet; >-// tempTxQnode->next = NULL; >-// >-// if (Adapter->TxQHead==NULL) >-// { >-// Adapter->TxQHead = tempTxQnode; >-// } >-// >-// if (Adapter->TxQTail!=NULL) >-// { >-// Adapter->TxQTail->next = tempTxQnode; >-// } >-// >-// Adapter->TxQTail = tempTxQnode; >-// } >- >- >- >-//////////////////////////////////////////////////////////////////////////// >-// __inline VOID DeQTxPacket(PRT2570ADAPTER Adapter) >-// { >-// PTX_QUEUE tempTxQnode; >-// >-// tempTxQnode = Adapter->TxQHead; >-// Adapter->TxQHead = tempTxQnode->next; >-// >-// if (Adapter->TxQHead==NULL) >-// { >-// Adapter->TxQTail=NULL; >-// } >-// >-// FreeMemory(tempTxQnode, sizeof(TX_QUEUE)); >-// } >- >- >- >-#define DEVICE_VENDOR_REQUEST_OUT (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) // 0x40 >-#define DEVICE_VENDOR_REQUEST_IN (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE ) //0xc0 >-#define INTERFACE_VENDOR_REQUEST_OUT 0x41 >-#define INTERFACE_VENDOR_REQUEST_IN 0xc1 >-#define PL_RESET_IN (1<<3) /* reset input pipe */ >- >-//////////////////////////////////////////////////////////////////////////// >-// Misc definitions >-//////////////////////////////////////////////////////////////////////////// >-#define OS_IS_WIN_2000 0 >-#define OS_IS_WIN_ME 1 >-#define OS_IS_WIN_98 2 >-#define OS_IS_WIN_XP 3 >- >- >-//////////////////////////////////////////////////////////////////////////// >-// Station States definitions >-//////////////////////////////////////////////////////////////////////////// >-#define STATION_STATE_INITIALIZING 0x00 >-#define STATION_STATE_SCANNING 0x01 >-#define STATION_STATE_JOINNING 0x02 >-#define STATION_STATE_AUTHENTICATING 0x03 >-#define STATION_STATE_ASSOCIATING 0x04 >-#define STATION_STATE_READY 0x05 >-#define STATION_STATE_OUT_OF_RANGE 0x06 >-#define STATION_STATE_DISASSOCIATING 0x07 >-#define STATION_STATE_DIAUTHENTICATING 0x08 >-#define STATION_STATE_REASSOCIATING 0x09 >-#define STATION_STATE_FORCED_JOINNING 0x0a >-#define STATION_STATE_RECONFIGURING 0x0b >-#define STATION_STATE_FW_UPGRADE 0x0c >-#define STATION_STATE_FORCED_JOIN_FAILURE 0x0d >-#define STATION_STATE_RESETTING 0x0e >-#define STATION_STATE_RESET_PENDING 0x0f >-#define STATION_STATE_NOT_NET_MODE 0x10 >-#define STATION_STATE_WAIT_ACTION 0x11 //under XP we need this state to allow XP to take control >-#define STATION_STATE_REJECTING_PACKETS 0x99 >-#define STATION_STATE_NO_CARD 0xf0 >-#define STATION_STATE_MGMT_ERROR 0xf1 >-#define STATION_STATE_GENERAL_ERROR 0xf2 >-#define STATION_STATE_POWER_DOWN 0xff >- >- >-//////////////////////////////////////////////////////////////////////////// >-// SCAN Type Definitions >-//////////////////////////////////////////////////////////////////////////// >-#define SCAN_TYPE_ACTIVE 0 >-#define SCAN_TYPE_PASSIVE 1 >- >- >-//////////////////////////////////////////////////////////////////////////// >-// Operating Modes definitions >-//////////////////////////////////////////////////////////////////////////// >-#define BSS_TYPE_AD_HOC 1 >-#define BSS_TYPE_INFRASTRUCTURE 2 >- >-// >-// Miniport routines in rtmp_main.c >-// >- >- >-VOID RTUSBHalt( IN PRT2570ADAPTER pAdapter, BOOLEAN IsFree); >- >- >-// >-// Private routines in rtmp_init.c >-// >- >-PUCHAR RTMPFindSection( >- IN PCHAR buffer, >- IN PCHAR section); >- >-INT RTMPIsFindSection( >- IN PUCHAR ptr, >- IN PUCHAR buffer); >- >- >-INT RTMPGetKeyParameter( >- IN PUCHAR section, >- IN PCHAR key, >- OUT PCHAR dest, >- IN INT destsize, >- IN PCHAR buffer); >-VOID RTMPReadParametersFromFile( >- IN PRT2570ADAPTER pAdapter); >- >- >- >-VOID NICReadEEPROMParameters( >- IN PRT2570ADAPTER pAdapter); >- >-VOID NICInitAsicFromEEPROM( >- IN PRT2570ADAPTER pAdapter); >- >- >-NDIS_STATUS NICInitRecv( >- IN PRT2570ADAPTER pAdapter); >- >-#if 0 >-NDIS_STATUS NICReadAdapterInfo( >- IN PRT2570ADAPTER pAdapter); >- >- >-VOID NICInitializeAdapter( >- IN PRT2570ADAPTER pAdapter); >-#endif//blue >- >-VOID RT2570InitializeAsic( >- IN PRT2570ADAPTER pAdapter); >- >-VOID NICIssueReset( >- IN PRT2570ADAPTER pAdapter); >- >-#if 0 >-VOID RTMPRingCleanUp( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR RingType); >-#endif >- >-VOID RxTest( >- IN PRT2570ADAPTER pAdapter); >- >-// >-#if 0 >-NDIS_STATUS DbgSendPacket( >- IN PRT2570ADAPTER pAdapter, >- IN PNDIS_PACKET pPacket); >-#endif >- >-VOID PortCfgInit( >- IN PRT2570ADAPTER pAdapter); >- >-VOID NICResetFromError( >- IN PRT2570ADAPTER pAdapter); >- >-BOOLEAN NICCheckForHang( >- IN PRT2570ADAPTER pAdapter); >- >-VOID CreateThreads( struct net_device *net_dev); >- >-#if 0 >-NDIS_STATUS RT2570ReadHWMACAddress( >- IN PRT2570ADAPTER pAdapter); >-#endif >-NDIS_STATUS RTUSBWriteHWMACAddress( >- IN PRT2570ADAPTER pAdapter); >- >-void AtoH(char * src, UCHAR * dest, int destlen); >-UCHAR BtoH(char ch); >- >-VOID RTMPInitTimer( >- IN PRT2570ADAPTER pAdapter, >- IN PRALINK_TIMER_STRUCT pTimer, >- IN PVOID pTimerFunc); >- >-VOID RTMPSetTimer( >- IN PRT2570ADAPTER pAdapter, >- IN PRALINK_TIMER_STRUCT pTimer, >- IN ULONG Value); >- >-VOID RTMPCancelTimer( >- IN PRALINK_TIMER_STRUCT pTimer); >- >- >-// >-// Private routines in rtmp_data.c >-// >-#if 0 >-VOID RTMPHandleRxDoneInterrupt( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTMPHandleTxRingTxDoneInterrupt( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTMPHandlePrioRingTxDoneInterrupt( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTMPHandleAtimRingTxDoneInterrupt( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTMPHandleTbcnInterrupt( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTMPHandleTwakeupInterrupt( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTMPHardTransmitDone( >- IN PRT2570ADAPTER pAdapter, >- IN PTXD_STRUC pTxD, >- IN UCHAR FrameType); >- >-NDIS_STATUS RTMPSendPacket( >- IN PRT2570ADAPTER pAdapter, >- IN PNDIS_PACKET pPacket); >- >-VOID RTMPDeQueuePacket( >- IN PRT2570ADAPTER pAdapter, >- IN PQUEUE_HEADER pQueue); >- >-NDIS_STATUS RTMPHardTransmit( >- IN PRT2570ADAPTER pAdapter, >- IN PNDIS_PACKET pPacket, >- IN UCHAR NumberRequired); >- >-NDIS_STATUS RTMPFreeDescriptorRequest( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR RingType, >- IN UCHAR NumberRequired); >-#endif//red >- >- >-VOID MlmeHardTransmit( >- IN PRT2570ADAPTER pAdapter, >- IN PMGMT_STRUC pMgmt); >- >-VOID >-BulkOutMLMEPacket >-( >- PRT2570ADAPTER pAdapter, >- UCHAR Index); >- >- >-void BulkOutMLMEPacketComplete(purbb_t purb,struct pt_regs *pt_regs); >- >-USHORT RTMPCalcDuration( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR Rate, >- IN ULONG Size); >- >- >-VOID RTMPWriteBeaconDescriptor( >- IN PTXD_STRUC pTxD, >- IN UINT Length, >- IN UINT PLCPLength, >- IN UINT Rate, >- IN UCHAR Service, >- IN USHORT TxPreamble); >- >- >-VOID RTUSBSuspendMsduTransmission( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTUSBResumeMsduTransmission( >- IN PRT2570ADAPTER pAdapter); >- >-VOID >-DequeueMLMEPacket( >- IN PRT2570ADAPTER pAdapter); >- >- >-VOID >-MiniportMMRequest( >- IN PRT2570ADAPTER pAdapter, >- IN PVOID pBuffer, >- IN ULONG Length); >- >-BOOLEAN RTMPSearchTupleCache( >- IN PRT2570ADAPTER pAdapter, >- IN PHEADER_802_11 pHeader); >- >-VOID RTMPUpdateTupleCache( >- IN PRT2570ADAPTER pAdapter, >- IN PHEADER_802_11 pHeader); >- >-NDIS_STATUS RTMPApplyPacketFilter( >- IN PRT2570ADAPTER pAdapter, >- IN PRXD_STRUC pRxD, >- IN PHEADER_802_11 pHeader); >- >-NDIS_STATUS RTMPCheckRxDescriptor( >- IN PRT2570ADAPTER pAdapter, >- IN PRXD_STRUC pRxD); >- >-VOID RTMPReportMicError( >- IN PRT2570ADAPTER pAdapter, >- IN PWPA_KEY pWpaKey); >- >-VOID RTUSBMlmeHardTransmit( >- IN PRT2570ADAPTER pAdapter, >- IN PMGMT_STRUC pMgmt); >- >- >-// >-// Private routines in rtmp_wep.c >-// >-VOID RTMPInitWepEngine( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pKey, >- IN UCHAR KeyId, >- IN UCHAR KeyLen, >- IN PUCHAR pDest); >- >-VOID RTMPEncryptData( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pSrc, >- IN PUCHAR pDest, >- IN UINT Len); >- >-BOOLEAN RTMPDecryptData( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pSrc, >- IN UINT Len); >- >-VOID RTMPSetICV( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pDest); >- >-VOID ARCFOUR_INIT( >- IN PARCFOURCONTEXT Ctx, >- IN PUCHAR pKey, >- IN UINT KeyLen); >- >-UCHAR ARCFOUR_BYTE( >- IN PARCFOURCONTEXT Ctx); >- >-VOID ARCFOUR_DECRYPT( >- IN PARCFOURCONTEXT Ctx, >- IN PUCHAR pDest, >- IN PUCHAR pSrc, >- IN UINT Len); >- >-VOID ARCFOUR_ENCRYPT( >- IN PARCFOURCONTEXT Ctx, >- IN PUCHAR pDest, >- IN PUCHAR pSrc, >- IN UINT Len); >- >-ULONG RTMP_CALC_FCS32( >- IN ULONG Fcs, >- IN PUCHAR Cp, >- IN INT Len); >- >-// >-// MLME routines >-// >-//VOID Arc4Init(ARC4_CONTEXT *Ctx, UCHAR *Key, ULONG KeyLen); >-//UCHAR Arc4Byte(ARC4_CONTEXT *Ctx); >-//VOID Arc4Cipher(ARC4_CONTEXT *Ctx, UCHAR *Dest, UCHAR *Src, ULONG Len); >- >-// Asic/RF/BBP related functions >- >-VOID AsicAdjustTxPower( >- IN PRT2570ADAPTER pAd); >- >-VOID AsicSwitchChannel( >- IN PRT2570ADAPTER pAdapter, >- UCHAR Channel); >- >-VOID AsicLockChannel( >- IN PRT2570ADAPTER pAd, >- IN ULONG Channel) ; >- >-#if 0 >-VOID AsicRfTuningExec( >- IN PVOID SystemSpecific1, >- IN PVOID FunctionContext, >- IN PVOID SystemSpecific2, >- IN PVOID SystemSpecific3); >-#endif >- >-#ifdef RALINK_ATE >-VOID AsicSwitchChannel_ATE( >- IN PRT2570ADAPTER pAdapter, >- ULONG Channel); >-#endif >- >-VOID AsicSleepThenAutoWakeup( >- IN PRT2570ADAPTER pAdapter, >- IN USHORT TbttNumToNextWakeUp); >- >-VOID AsicForceSleep( >- IN PRT2570ADAPTER pAdapter); >- >-VOID AsicForceWakeup( >- IN PRT2570ADAPTER pAdapter); >- >-VOID AsicSetBssid( >- IN PRT2570ADAPTER pAdapter, >- IN MACADDR *Bssid); >- >-VOID AsicDisableSync( >- IN PRT2570ADAPTER pAdapter); >- >-VOID AsicEnableBssSync( >- IN PRT2570ADAPTER pAdapter); >- >-VOID AsicEnableIbssSync( >- IN PRT2570ADAPTER pAdapter); >- >-VOID AsicLedPeriodicExec( >- IN unsigned long data); >- >-VOID AsicSetSlotTime( >- IN PRT2570ADAPTER pAd, >- IN BOOLEAN UseShortSlotTime); >- >-//blue >-VOID AsicBbpTuning( >- IN PRT2570ADAPTER pAd); >- >-VOID AsicRestoreBbpSensibility( >- IN PRT2570ADAPTER pAd); >- >- >-VOID MacAddrRandomBssid( >- IN PRT2570ADAPTER pAdapter, >- OUT PMACADDR Addr); >- >-VOID MgtMacHeaderInit( >- IN PRT2570ADAPTER pAdapter, >- IN OUT PMACHDR Hdr, >- IN UCHAR Subtype, >- IN UCHAR ToDs, >-// IN UCHAR AddrType, >- IN PMACADDR Ds, >- IN PMACADDR Bssid); >- >-VOID MlmeRadioOff( >- IN PRT2570ADAPTER pAd); >- >-VOID MlmeRadioOn( >- IN PRT2570ADAPTER pAd); >- >-VOID BssTableInit( >- IN BSS_TABLE *Tab); >- >-ULONG BssTableSearch( >- IN BSS_TABLE *Tab, >- IN PMACADDR Bssid); >- >-VOID BssTableDeleteEntry( >- IN OUT BSS_TABLE *Tab, >- IN PMACADDR Bssid); >- >-VOID BssEntrySet( >- IN PRT2570ADAPTER pAdapter, >- OUT BSS_ENTRY *Bss, >- IN MACADDR *Bssid, >- IN CHAR Ssid[], >- IN UCHAR SsidLen, >- IN UCHAR BssType, >- IN USHORT BeaconPeriod, >- IN BOOLEAN CfExist, >- IN CF_PARM *CfParm, >- IN USHORT AtimWin, >- IN USHORT CapabilityInfo, >- IN UCHAR Rates[], >- IN UCHAR RatesLen, >- IN BOOLEAN ExtendedRateIeExist, >- IN UCHAR Channel, >- IN UCHAR Rssi, >- IN LARGE_INTEGER TimeStamp, >- IN UCHAR LengthVIE, >- IN PNDIS_802_11_VARIABLE_IEs pVIE); >- >-ULONG BssTableSetEntry( >- IN PRT2570ADAPTER pAdapter, >- OUT BSS_TABLE *Tab, >- IN MACADDR *Bssid, >- IN CHAR Ssid[], >- IN UCHAR SsidLen, >- IN UCHAR BssType, >- IN USHORT BeaconPeriod, >- IN BOOLEAN CfExist, >- IN CF_PARM *CfParm, >- IN USHORT AtimWin, >- IN USHORT CapabilityInfo, >- IN UCHAR Rates[], >- IN UCHAR RatesLen, >- IN BOOLEAN ExtendedRateIeExist, >- IN UCHAR Channel, >- IN UCHAR Rssi, >- IN LARGE_INTEGER TimeStamp, >- IN UCHAR LengthVIE, >- IN PNDIS_802_11_VARIABLE_IEs pVIE); >- >-VOID BssTableSsidSort( >- IN PRT2570ADAPTER pAd, >- OUT BSS_TABLE *OutTab, >- IN CHAR Ssid[], >- IN UCHAR SsidLen); >- >-VOID BssTableSortByRssi( >- IN OUT BSS_TABLE *OutTab); >- >-VOID BssCipherParse( >- IN OUT PBSS_ENTRY pBss); >- >-NDIS_STATUS MlmeQueueInit( >- IN MLME_QUEUE *Queue); >- >-VOID MlmeQueueDestroy( >- IN MLME_QUEUE *Queue); >- >-BOOLEAN MlmeEnqueue( >- IN PRT2570ADAPTER pAd, >- IN ULONG Machine, >- IN ULONG MsgType, >- IN ULONG MsgLen, >- IN VOID *Msg); >- >-BOOLEAN MlmeEnqueueForRecv( >- IN PRT2570ADAPTER pAdapter, >- OUT MLME_QUEUE *Queue, >- IN UCHAR Rssi, >- IN ULONG MsgLen, >- IN PVOID Msg); >- >-BOOLEAN MlmeDequeue( >- IN MLME_QUEUE *Queue, >- OUT MLME_QUEUE_ELEM **Elem); >- >-#if 1 >-VOID MlmeRestartStateMachine( >- IN PRT2570ADAPTER pAd); >-#endif >- >-//blue >-VOID MlmePostRestartStateMachine( >- IN PRT2570ADAPTER pAd); >- >-BOOLEAN MlmeQueueEmpty( >- IN MLME_QUEUE *Queue); >- >-BOOLEAN MlmeQueueFull( >- IN MLME_QUEUE *Queue); >- >-BOOLEAN MsgTypeSubst( >- IN PRT2570ADAPTER pAd, >- IN MACFRAME *Fr, >- OUT INT *Machine, >- OUT INT *MsgType); >- >-VOID StateMachineInit( >- IN STATE_MACHINE *Sm, >- IN STATE_MACHINE_FUNC Trans[], >- IN ULONG StNr, >- IN ULONG MsgNr, >- IN STATE_MACHINE_FUNC DefFunc, >- IN ULONG InitState, >- IN ULONG Base); >- >-VOID StateMachineSetAction( >- IN STATE_MACHINE *S, >- IN ULONG St, >- ULONG Msg, >- IN STATE_MACHINE_FUNC F); >- >-VOID StateMachinePerformAction( >- IN PRT2570ADAPTER pAdapter, >- IN STATE_MACHINE *S, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID Drop( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID StateMachineDestroy( >- IN STATE_MACHINE *Sm); >- >-VOID AssocStateMachineInit( >- IN PRT2570ADAPTER pAdapter, >- IN STATE_MACHINE *Sm, >- OUT STATE_MACHINE_FUNC Trans[]); >- >-VOID ReassocTimeout( >- IN unsigned long data); >- >-VOID AssocTimeout( >- IN unsigned long data); >- >-VOID DisassocTimeout( >- IN unsigned long data); >- >-//---------------------------------------------- >-VOID MlmeDisassocReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID MlmeAssocReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID MlmeReassocReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID MlmeDisassocReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerAssocRspAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerReassocRspAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerDisassocAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID DisassocTimeoutAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID AssocTimeoutAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID ReassocTimeoutAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID Cls3errAction( >- IN PRT2570ADAPTER pAdapter, >- IN PMACADDR pAddr); >- >-VOID InvalidStateWhenAssoc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID InvalidStateWhenReassoc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID InvalidStateWhenDisassociate( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID ComposePsPoll( >- IN PRT2570ADAPTER pAdapter); >- >-VOID ComposeNullFrame( >- IN PRT2570ADAPTER pAdapter); >- >-VOID ComposeStuffFrame( >- IN PRT2570ADAPTER pAdapter); >- >-VOID AssocPostProc( >- IN PRT2570ADAPTER pAdapter, >- IN MACADDR *Addr2, >- IN USHORT CapabilityInfo, >- IN USHORT Aid, >- IN UCHAR Rates[], >- IN UCHAR RatesLen, >- IN BOOLEAN ExtendedRateIeExist); >- >-VOID AuthStateMachineInit( >- IN PRT2570ADAPTER pAdapter, >- IN PSTATE_MACHINE sm, >- OUT STATE_MACHINE_FUNC Trans[]); >- >-VOID AuthTimeout( >- IN unsigned long data); >- >- >-VOID MlmeAuthReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerAuthRspAtSeq2Action( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerAuthRspAtSeq4Action( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID AuthTimeoutAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID Cls2errAction( >- IN PRT2570ADAPTER pAdapter, >- IN PMACADDR pAddr); >- >-VOID MlmeDeauthReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID InvalidStateWhenAuth( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-//VOID MlmeDeauthReqProc( >-// IN PRT2570ADAPTER pAdapter, >-// IN MACADDR *Addr, >-// IN USHORT Reason); >- >-//============================================= >- >-VOID AuthRspStateMachineInit( >- IN PRT2570ADAPTER pAdapter, >- IN PSTATE_MACHINE Sm, >- IN STATE_MACHINE_FUNC Trans[]); >- >- >-VOID AuthRspChallengeTimeout( >- IN unsigned long data); >- >-VOID AuthRspChallengeTimeoutAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerAuthAtAuthRspIdleAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerAuthAtAuthRspWaitAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerDeauthAction( >- IN PRT2570ADAPTER pAdaptor, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerAuthSimpleRspGenAndSend( >- IN PRT2570ADAPTER pAdapter, >- IN PMACHDR Hdr, >- IN USHORT Alg, >- IN USHORT Seq, >- IN USHORT Reason, >- IN USHORT Status); >- >-//======================================== >- >-VOID SyncStateMachineInit( >- IN PRT2570ADAPTER pAdapter, >- IN STATE_MACHINE *Sm, >- OUT STATE_MACHINE_FUNC Trans[]); >- >-VOID BeaconTimeout( >- IN unsigned long data); >- >-VOID AtimTimeout( >- IN unsigned long data); >- >-VOID ScanTimeout( >- IN unsigned long data); >- >-VOID MlmeScanReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID InvalidStateWhenScan( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID InvalidStateWhenJoin( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID InvalidStateWhenStart( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerBeacon( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-//========================================= >- >-VOID MlmeCntlInit( >- IN PRT2570ADAPTER pAdapter, >- IN STATE_MACHINE *S, >- OUT STATE_MACHINE_FUNC Trans[]); >- >-VOID MlmeCntlMachinePerformAction( >- IN PRT2570ADAPTER pAdapter, >- IN STATE_MACHINE *S, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlIdleProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlOidScanProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlOidSsidProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM * Elem); >- >-VOID CntlOidRTBssidProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM * Elem); >- >-VOID CntlMlmeRoamingProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM * Elem); >- >-VOID CntlWaitDisassocProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlWaitJoinProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlWaitReassocProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlWaitStartProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlWaitAuthProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlWaitAuthProc2( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID CntlWaitAssocProc( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID LinkUp( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR BssType); >- >-VOID LinkDown( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MlmeCntlConfirm( >- IN PRT2570ADAPTER pAdapter, >- IN ULONG MsgType, >- IN USHORT Msg); >- >-VOID IterateOnBssTab( >- IN PRT2570ADAPTER pAdapter); >- >-VOID IterateOnBssTab2( >- IN PRT2570ADAPTER pAdapter);; >- >-VOID JoinParmFill( >- IN PRT2570ADAPTER pAdapter, >- IN OUT MLME_JOIN_REQ_STRUCT *JoinReq, >- IN ULONG BssIdx); >- >-VOID AssocParmFill( >- IN PRT2570ADAPTER pAdapter, >- IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq, >- IN MACADDR *Addr, >- IN USHORT CapabilityInfo, >- IN ULONG Timeout, >- IN USHORT ListenIntv); >- >-VOID ScanParmFill( >- IN PRT2570ADAPTER pAdapter, >- IN OUT MLME_SCAN_REQ_STRUCT *ScanReq, >- IN CHAR Ssid[], >- IN UCHAR SsidLen, >- IN UCHAR BssType, >- IN UCHAR ScanType); >- >-VOID DisassocParmFill( >- IN PRT2570ADAPTER pAdapter, >- IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq, >- IN MACADDR *Addr, >- IN USHORT Reason); >- >-VOID StartParmFill( >- IN PRT2570ADAPTER pAdapter, >- IN OUT MLME_START_REQ_STRUCT *StartReq, >- IN CHAR Ssid[], >- IN UCHAR SsidLen); >- >-VOID AuthParmFill( >- IN PRT2570ADAPTER pAdapter, >- IN OUT MLME_AUTH_REQ_STRUCT *AuthReq, >- IN MACADDR *Addr, >- IN USHORT Alg); >- >-VOID EnqueuePsPoll( >- IN PRT2570ADAPTER pAdapter); >- >-VOID EnqueueBeaconFrame( >- IN PRT2570ADAPTER pAdapter); >- >-void USB_SendNullFrameComplete(purbb_t purb,struct pt_regs *pt_regs); >- >-VOID EnqueueNullFrame( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR TxRate); >- >-VOID MlmeJoinReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >- >- >-VOID MlmeStartReqAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID ScanTimeoutAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID BeaconTimeoutAtJoinAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerBeaconAtScanAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerBeaconAtJoinAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerBeacon( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID PeerProbeReqAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID ScanNextChannel( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MakeIbssBeacon( >- IN PRT2570ADAPTER pAdapter); >- >-BOOLEAN MlmeScanReqSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT UCHAR *BssType, >- OUT CHAR ssid[], >- OUT UCHAR *SsidLen, >- OUT UCHAR *ScanType); >- >-BOOLEAN PeerBeaconAndProbeRspSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *Addr2, >- OUT MACADDR *Bssid, >- OUT CHAR Ssid[], >- OUT UCHAR *SsidLen, >- OUT UCHAR *BssType, >- OUT USHORT *BeaconPeriod, >- OUT UCHAR *Channel, >- OUT LARGE_INTEGER *Timestamp, >- OUT BOOLEAN *CfExist, >- OUT CF_PARM *Cf, >- OUT USHORT *AtimWin, >- OUT USHORT *CapabilityInfo, >- OUT UCHAR Rate[], >- OUT UCHAR *RateLen, >- OUT BOOLEAN *ExtendedRateIeExist, >- OUT UCHAR *Erp, >- OUT UCHAR *DtimCount, >- OUT UCHAR *DtimPeriod, >- OUT UCHAR *BcastFlag, >- OUT UCHAR *MessageToMe, >- OUT UCHAR *Legacy, >- OUT UCHAR SupRate[], >- OUT UCHAR *SupRateLen, >- OUT UCHAR ExtRate[], >- OUT UCHAR *ExtRateLen, >- OUT UCHAR *LengthVIE, >- OUT PNDIS_802_11_VARIABLE_IEs pVIE); >- >-//BOOLEAN JoinParmSanity( >-// IN PRT2570ADAPTER pAdapter, >-// IN VOID *Msg, >-// IN ULONG MsgLen, >-// OUT ULONG *BssIdx, >-// OUT UCHAR SupportedRates[], >-// OUT UCHAR *SupportedRatesLen); >- >-BOOLEAN MlmeAssocReqSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *ApAddr, >- OUT USHORT *CapabilityInfo, >- OUT ULONG *Timeout, >- OUT USHORT *ListenIntv); >- >-BOOLEAN MlmeAuthReqSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *Addr, >- OUT ULONG *Timeout, >- OUT USHORT *Alg); >- >-BOOLEAN MlmeStartReqSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT CHAR Ssid[], >- OUT UCHAR *Ssidlen); >- >-BOOLEAN PeerAuthSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *Addr, >- OUT USHORT *Alg, >- OUT USHORT *Seq, >- OUT USHORT *Status, >- OUT CHAR ChlgText[]); >- >-BOOLEAN PeerAssocRspSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *Addr2, >- OUT USHORT *CapabilityInfo, >- OUT USHORT *Status, >- OUT USHORT *Aid, >- OUT UCHAR Rates[], >- OUT UCHAR *RatesLen, >- OUT BOOLEAN *ExtendedRateIeExist); >- >-BOOLEAN PeerDisassocSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *Addr2, >- OUT USHORT *Reason); >- >-BOOLEAN PeerDeauthSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *Addr2, >- OUT USHORT *Reason); >- >-BOOLEAN PeerProbeReqSanity( >- IN PRT2570ADAPTER pAdapter, >- IN VOID *Msg, >- IN ULONG MsgLen, >- OUT MACADDR *Addr2, >- OUT CHAR Ssid[], >- OUT UCHAR *SsidLen); >-// OUT UCHAR Rates[], >-// OUT UCHAR *RatesLen); >-NDIS_STATUS RTMPWPAWepKeySanity( >- IN PRT2570ADAPTER pAdapter, >- IN PVOID pBuf); >- >-BOOLEAN GetTimBit( >- IN CHAR *Ptr, >- IN USHORT Aid, >- OUT UCHAR *TimLen, >- OUT UCHAR *BcastFlag, >- OUT UCHAR *DtimCount, >- OUT UCHAR *DtimPeriod, >- OUT UCHAR *MessageToMe); >- >-BOOLEAN GetLegacy( >- IN CHAR *Ptr, >- OUT UCHAR *Legacy); >- >-ULONG MakeOutgoingFrame( >- OUT CHAR *Buffer, >- OUT ULONG *Length, ...); >- >-VOID LfsrInit( >- IN PRT2570ADAPTER pAdapter, >- IN ULONG Seed); >- >-UCHAR RandomByte( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MlmePeriodicExec( >- IN unsigned long data); >- >-#if 1 >-VOID RxPeriodicExec( >- IN PVOID SystemSpecific1, >- IN PVOID FunctionContext, >- IN PVOID SystemSpecific2, >- IN PVOID SystemSpecific3); >- >-#endif >- >-VOID MlmeAutoScan( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MlmeAutoRecoverNetwork( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MlmeAutoReconnectLastSSID( >- IN PRT2570ADAPTER pAdapter); >- >-BOOLEAN MlmeValidateSSID( >- IN PRT2570ADAPTER pAd); >- >-VOID MlmeCheckForRoaming( >- IN PRT2570ADAPTER pAdapter, >- IN ULONG Now32); >- >-//blue,VOID MlmeCheckChannelQuality( >-VOID PeriodicExec( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MlmeCheckForPsmChange( >- IN PRT2570ADAPTER pAd); >- >-VOID MlmeSetPsmBit( >- IN PRT2570ADAPTER pAdapter, >- IN USHORT psm); >- >-VOID MlmeSetTxPreamble( >- IN PRT2570ADAPTER pAdapter, >- IN USHORT TxPreamble); >- >-VOID MlmeUpdateTxRates( >- IN PRT2570ADAPTER pAd, >- IN BOOLEAN bLinkUp); >- >-VOID RTMPCheckRates( >- IN PRT2570ADAPTER pAd, >- IN OUT UCHAR SupRate[], >- IN OUT UCHAR *SupRateLen); >- >-NDIS_STATUS MlmeInit( >- IN PRT2570ADAPTER pAdapter); >- >-struct net_device_stats * >-rt_getstats(struct net_device *dev); >- >-struct iw_statistics *RTUSB_get_wireless_stats( >- IN struct net_device *net_dev); >- >-VOID MlmeHalt( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MlmeHandler( >- IN PRT2570ADAPTER pAd); >- >-VOID MlmeSuspend( >- IN PRT2570ADAPTER pAd); >- >-int MlmeThread(void * Context); >-VOID CMDHandler( >- IN PRT2570ADAPTER pAdapter); >- >-int RTUSBCmdThread(void * Context); >-NDIS_STATUS MlmeInitMemoryHandler( >- IN PRT2570ADAPTER pAd, >- IN UINT Number, >- IN UINT Size); >- >-NDIS_STATUS MlmeAllocateMemory( >- IN PRT2570ADAPTER pAd, >- OUT PVOID *AllocVa); >- >-VOID MlmeFreeMemory( >- IN PRT2570ADAPTER pAd, >- IN PVOID AllocVa); >- >-VOID MlmeFreeMemoryHandler( >- IN PRT2570ADAPTER pAd); >- >- >-VOID DeleteTimer( >- IN PRT2570ADAPTER pAd); >- >-NTSTATUS >-RTUSBSingleRead >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- PUSHORT pValue >- ); >- >-NTSTATUS >-RTUSBSingleWrite >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- USHORT Value >- ); >- >-NTSTATUS >-RTUSBReadMACRegister >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- PUSHORT pValue >- ); >- >-NTSTATUS >-RTUSBWriteMACRegister >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- USHORT Value >- ); >- >-NTSTATUS >-RTUSBMultiRead >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- PUCHAR pData, >- USHORT length >- ); >- >-NTSTATUS >-RTUSBMultiWrite >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- PUCHAR pData, >- USHORT length >- ); >- >-#define RETRY_LIMIT 3 >-NTSTATUS >-RTUSBReadBBPRegister >-( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR Id, >- IN PUCHAR pValue >- ); >- >- >-NTSTATUS >-RTUSBWriteBBPRegister >-( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR Id, >- IN UCHAR Value >- ); >- >-NTSTATUS >-RTUSBWriteRFRegister >-( >- IN PRT2570ADAPTER pAdapter, >- IN ULONG Value >- ); >- >-NTSTATUS >-RTUSBReadEEPROM >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- PUCHAR pData, >- USHORT length >- ); >- >-NTSTATUS >-RT2570WriteEEPROM >-( >- IN PRT2570ADAPTER pAdapter, >- USHORT Offset, >- PUCHAR pData, >- USHORT length >- ); >- >- >-VOID >- UsbBuildVendorRequest( >- IN PRT2570ADAPTER pAdapter, >- IN PURB Urb, >- IN USHORT Function, >- IN USHORT Length, >- IN ULONG TransferFlags, >- IN UCHAR ReservedBits, >- IN UCHAR Request, >- IN USHORT Value, >- IN USHORT Index, >- IN PVOID TransferBuffer , >- IN PMDL TransferBufferMDL , >- IN ULONG TransferBufferLength, >- IN PURB Link >- ); >- >- >-void mod_use(UCHAR a, PRT2570ADAPTER pAdapter); >- >- >- >- >-#if 0 >-VOID >-EnqueueCmd >-( >- PCmdQ cmdq, >- PCmdQElmt cmdelmt >- ); >-#else >-#define EnqueueCmd(cmdq, cmdqelmt) \ >-{ \ >- if (cmdq->size == 0) \ >- cmdq->head = cmdqelmt; \ >- else \ >- cmdq->tail->next = cmdqelmt; \ >- cmdq->tail = cmdqelmt; \ >- cmdqelmt->next = NULL; \ >- cmdq->size++; \ >-} >-#endif >- >- >-VOID >-EnqueueInternalCmd >-( >- PRT2570ADAPTER pAdapter, >- NDIS_OID Oid >- ); >- >-VOID >-DequeueCmd >-( >- PCmdQ cmdq, >- PCmdQElmt *pcmdelmt >- ); >- >- >-//blue >-#if 0 >-VOID >-InitializeBulkOutQueue >-( >- PBULK_OUT_QUEUE cmdq >- ); >- >- >-VOID >-EnqueueBulkOut >-( >- PBULK_OUT_QUEUE cmdq, >- PBULK_OUT_QUEUE_ELEMENT cmdelmt >- ); >- >-VOID >-DequeueBulkOut >-( >- PBULK_OUT_QUEUE cmdq, >- PBULK_OUT_QUEUE_ELEMENT *pcmdelmt >- ); >-#endif >- >-VOID >-InitializeDataBulkOutQueue >-( >- PRT2570ADAPTER pAdapter >- ); >- >-#if 0 >-VOID >-EnqueueDataBulkOut >-( >- PRT2570ADAPTER pAdapter, >- PNDIS_PACKET cmdelmt >- ); >- >-VOID >-DequeueDataBulkOut >-( >- PRT2570ADAPTER pAdapter, >- PNDIS_PACKET *pcmdelmt >- ); >-#else >- >-#define EnqueueDataBulkOut(pAdapter, cmdqelmt) \ >-{ \ >- PDATA_BULKOUT_QUEUE cmdq = &(pAdapter->DataQ); \ >- if (cmdq->size == 0) \ >- cmdq->head = cmdqelmt; \ >- else \ >- *(GET_NEXT_PACKET_IN_BULKOUT_QUEUE(cmdq->tail)) = cmdqelmt; \ >- cmdq->tail = cmdqelmt; \ >- cmdq->size++; \ >- *(GET_NEXT_PACKET_IN_BULKOUT_QUEUE(cmdqelmt)) = NULL; \ >-} >- >-#define DequeueDataBulkOut(pAdapter, pcmdqelmt) \ >-{ \ >- PDATA_BULKOUT_QUEUE cmdq = &(pAdapter->DataQ); \ >- *pcmdqelmt = cmdq->head; \ >- cmdq->head = *(GET_NEXT_PACKET_IN_BULKOUT_QUEUE(*pcmdqelmt)); \ >- cmdq->size--; \ >- if (cmdq->size == 0) \ >- cmdq->tail = NULL; \ >-} >- >- >-#endif >- >-VOID >-InitializeMLMEBulkOutQueue >-( >- PRT2570ADAPTER pAdapter >- ); >- >-#if 0 >-VOID >-EnqueueMLMEBulkOut >-( >- PRT2570ADAPTER pAdapter, >- PMGMT_STRUC cmdelmt >- ); >- >-VOID >-DequeueMLMEBulkOut >-( >- PRT2570ADAPTER pAdapter, >- PMGMT_STRUC *pcmdelmt >- ); >-#else >-#define EnqueueMLMEBulkOut(pAdapter, cmdqelmt) \ >-{ \ >- PMLME_BULKOUT_QUEUE cmdq = &(pAdapter->MLMEQ); \ >- if (cmdq->size == 0) \ >- cmdq->head = cmdqelmt; \ >- else \ >- cmdq->tail->next = cmdqelmt; \ >- cmdq->tail = cmdqelmt; \ >- cmdq->size++; \ >- cmdqelmt->next = NULL; \ >-} >- >-#define DequeueMLMEBulkOut(pAdapter, pcmdqelmt) \ >-{ \ >- PMLME_BULKOUT_QUEUE cmdq = &(pAdapter->MLMEQ); \ >- *pcmdqelmt = cmdq->head; \ >- cmdq->head = (*pcmdqelmt)->next; \ >- cmdq->size--; \ >- if (cmdq->size == 0) \ >- cmdq->tail = NULL; \ >-} >-#endif >- >-NDIS_STATUS RTMPFreeDescriptorRequest( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR RingType, >- IN UCHAR NumberRequired); >- >- >-VOID MlmeSuspend( >- IN PRT2570ADAPTER pAdapter); >- >-VOID MlmeResume( >- IN PRT2570ADAPTER pAdapter); >- >-#ifdef TEST_MODE_SUPPORT >-NTSTATUS >-USB_BulkOut >-( >- PRT2570ADAPTER pAdapter, >- USHORT length, >- PVOID buffer >- ); >- >-//blue >-#if 0 >-VOID >-BulkInOnePacket >-( >- PRT2570ADAPTER Adapter >- ); >-#endif >- >-VOID >-BulkInPackets >-( >- PRT2570ADAPTER Adapter >- ); >- >-VOID >-BulkOutPackets >-( >- PRT2570ADAPTER pAdapter, >- USHORT length, PVOID buffer >- ); >-#endif >- >-#ifdef RALINK_ATE >-VOID DisableMlme( >- IN PRT2570ADAPTER pAd); >- >-VOID ReenableMlme( >- IN PRT2570ADAPTER pAd); >-#endif >- >-VOID BuildChannelList( >- IN PRT2570ADAPTER pAdapter); >- >-UCHAR FirstChannel( >- IN PRT2570ADAPTER pAdapter); >- >-UCHAR NextChannel( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR channel); >- >-VOID RaiseClock( >- IN PRT2570ADAPTER pAd, >- IN ULONG *x); >- >-VOID LowerClock( >- IN PRT2570ADAPTER pAd, >- IN ULONG *x); >- >-USHORT ShiftInBits( >- IN PRT2570ADAPTER pAd); >- >-VOID ShiftOutBits( >- IN PRT2570ADAPTER pAd, >- IN USHORT data, >- IN USHORT count); >- >-VOID EEpromCleanup( >- IN PRT2570ADAPTER pAd); >- >-VOID EWDS( >- IN PRT2570ADAPTER pAd); >- >-VOID EWEN( >- IN PRT2570ADAPTER pAd); >- >-USHORT RTMP_EEPROM_READ16( >- IN PRT2570ADAPTER pAd, >- IN USHORT Offset); >- >-VOID RTMP_EEPROM_WRITE16( >- IN PRT2570ADAPTER pAd, >- IN USHORT Offset, >- IN USHORT Data); >- >-UCHAR ChannelSanity( >- IN PRT2570ADAPTER pAd, >- IN UCHAR channel); >- >-// >-// Prototypes of function definition in rtmp_tkip.c >-// >-VOID RTMPInitTkipEngine( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pTKey, >- IN UCHAR KeyId, >- IN PUCHAR pTA, >- IN PUCHAR pMICKey, >- IN PUCHAR pTSC, >- IN INT DoEncrypt, >- OUT PULONG pIV16, >- OUT PULONG pIV32, >- IN PUCHAR pDest); >- >-BOOLEAN RTMPTkipCompareMICValue( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pSrc, >- IN PUCHAR pDA, >- IN PUCHAR pSA, >- IN PUCHAR pMICKey, >- IN UINT Len); >- >-VOID RTMPCalculateMICValue( >- IN PRT2570ADAPTER pAdapter, >- IN struct sk_buff *pPacket, >- IN PUCHAR pEncap, >- IN INT LenEncap, >- IN PWPA_KEY pWpaKey); >- >-VOID RTMPTkipMixTKey( >- IN PTKIP_KEY_INFO pTkip, >- IN PUCHAR pTKey, >- IN PUCHAR pTA ); >- >-BOOLEAN RTMPTkipCompareMICValueWithLLC( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pLLC, >- IN PUCHAR pSrc, >- IN PUCHAR pDA, >- IN PUCHAR pSA, >- IN PUCHAR pMICKey, >- IN UINT Len); >- >-BOOLEAN RTMPSoftDecryptTKIP( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pData, >- IN ULONG DataByteCnt, >- IN PWPA_KEY pWpaKey); >- >-NDIS_STATUS RTMPWPAAddKeyProc( >- IN PRT2570ADAPTER pAdapter, >- IN PVOID pBuf); >- >-NDIS_STATUS RTMPWPARemoveKeyProc( >- IN PRT2570ADAPTER pAdapter, >- IN PVOID pBuf); >- >-VOID RTMPWPARemoveAllKeys( >- IN PRT2570ADAPTER pAdapter); >- >-VOID RTMPSetPhyMode( >- IN PRT2570ADAPTER pAdapter, >- IN ULONG phymode); >- >-VOID RT2570SetDesiredRates( >- IN PRT2570ADAPTER pAdapter, >- IN LONG Rates); >-INT Set_R17_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Read_R17_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-int usb_rt2570_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd); >- >-VOID >-KickBulkOut >-( >- PRT2570ADAPTER pAdapter, >- BOOLEAN InBurst >- ); >- >-VOID >-BulkOutBeacon0 >-( >- PRT2570ADAPTER pAdapter >- ); >- >-VOID >-RejectPendingPackets >-( >- PRT2570ADAPTER pAdapter >- ); >- >-VOID >-CleanUpMLMEWaitQueue >-( >- IN PRT2570ADAPTER pAdapter >- ); >- >-#if 0 >-VOID >-CleanUpBulkOutQueues >-( >- PRT2570ADAPTER pAdapter, >- BULK_OUT_TYPE type >- ); >-#endif >- >-VOID >-CleanUpDataBulkOutQueue >-( >- PRT2570ADAPTER pAdapter >- ); >- >-VOID >-CleanUpMLMEBulkOutQueue >-( >- PRT2570ADAPTER pAdapter >- ); >- >-VOID >-CancelPendingIRPs >-( >- IN PRT2570ADAPTER pAdapter >- ); >- >-VOID >-CancelPendingBulkOutIRP >-( >- PRT2570ADAPTER pAdapter >- ); >- >-VOID >-CancelPendingBulkInIRP_bh >-( >- PRT2570ADAPTER pAdapter >- ); >- >- >- >-// >-// Prototypes of function definition for *iwpriv* in rtmp_info.c >-// >-INT Set_CountryRegion_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_SSID_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_WirelessMode_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_TxRate_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_Channel_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR >- arg); >- >-INT Set_BGProtection_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_TxPreamble_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_RTSThreshold_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_FragThreshold_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_TxBurst_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_TurboRate_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_AuthMode_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_EncrypType_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_DefaultKeyID_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_Key1_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_Key2_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_Key3_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_Key4_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-INT Set_WPAPSK_Proc( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR arg); >- >-#ifdef RT2500_DBG >-VOID RTMPIoctlBBP( >- IN PRT2570ADAPTER pAdapter, >- IN struct iwreq *wrq); >- >-VOID RTMPIoctlMAC( >- IN PRT2570ADAPTER pAdapter, >- IN struct iwreq *wrq); >-#endif >- >- >- >-// >-// prototype in wpa.c >-// >-BOOLEAN WpaMsgTypeSubst( >- IN UCHAR EAPType, >- OUT ULONG *MsgType); >- >-VOID WpaPskStateMachineInit( >- IN PRT2570ADAPTER pAd, >- IN STATE_MACHINE *S, >- OUT STATE_MACHINE_FUNC Trans[]); >- >-VOID WpaEAPOLKeyAction( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID WpaPairMsg1Action( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID WpaPairMsg3Action( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID WpaGroupMsg1Action( >- IN PRT2570ADAPTER pAdapter, >- IN MLME_QUEUE_ELEM *Elem); >- >-VOID WpaMacHeaderInit( >- IN PRT2570ADAPTER pAd, >- IN OUT PHEADER_802_11 Hdr, >- IN UCHAR wep, >- IN PMACADDR pAddr1); >- >-VOID WpaHardEncrypt( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pPacket, >- IN ULONG Len); >- >-VOID HMAC_SHA1( >- IN UCHAR *text, >- IN UINT text_len, >- IN UCHAR *key, >- IN UINT key_len, >- IN UCHAR *digest); >- void hmac_sha1(unsigned char *text, int text_len, unsigned char *key, int key_len, unsigned char *digest); >- >-VOID PRF( >- IN UCHAR *key, >- IN INT key_len, >- IN UCHAR *prefix, >- IN INT prefix_len, >- IN UCHAR *data, >- IN INT data_len, >- OUT UCHAR *output, >- IN INT len); >- >-VOID WpaCountPTK( >- IN UCHAR *PMK, >- IN UCHAR *ANonce, >- IN UCHAR *AA, >- IN UCHAR *SNonce, >- IN UCHAR *SA, >- OUT UCHAR *output, >- IN UINT len); >- >-VOID GenRandom( >- IN PRT2570ADAPTER pAd, >- OUT UCHAR *random); >- >-VOID AES_GTK_KEY_UNWRAP( >- IN UCHAR *key, >- OUT UCHAR *plaintext, >- IN UCHAR *ciphertext); >- >- >-// >-// SHA context >-// >-typedef struct _SHA_CTX >-{ >- ULONG Buf[5]; // buffers of five states >- UCHAR Input[80]; // input message >- ULONG LenInBitCount[2]; // length counter for input message, 0 up to 64 bits >- >-} SHA_CTX; >- >- >-VOID BulkOutWpaPskFrame( PRT2570ADAPTER pAd); >- >-VOID RTMPTkipEncryptData( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pSrc, >- IN PUCHAR pDest, >- IN UINT Len); >- >-VOID RTMPInitMICEngine( >- IN PRT2570ADAPTER pAdapter, >- IN PUCHAR pKey, >- IN PUCHAR pDA, >- IN PUCHAR pSA, >- IN PUCHAR pMICKey); >- >- >-VOID RTMPTkipAppend( >- IN PTKIP_KEY_INFO pTkip, >- IN PUCHAR pSrc, >- IN UINT nBytes); >- >-VOID RTMPTkipGetMIC( >- IN PTKIP_KEY_INFO pTkip); >- >-void USB_SendWpaPskComplete(purbb_t pUrb,struct pt_regs *pt_regs); >-//void USB_SendWpaPskComplete(purbb_t pUrb); >- >-// >-// extra prototype in md5.c >-// >-VOID SHAInit(SHA_CTX *ctx); >- >- VOID SHAHashBlock(SHA_CTX *ctx); >- >-UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, ULONG LenInBytes); >- >-VOID SHAFinal(SHA_CTX *ctx, unsigned char hashout[20]); >-#endif >-#ifndef _stdincl_h_OK__ >-#define _stdincl_h_OK__ >- >- >- >- >-//============================================= >-// functions in usbrx.c >-//============================================= >- >-int USB_RxPacket(PRT2570ADAPTER Adapter); >- >-//============================================= >-// functions in rt2570_main.c >-//============================================= >- >-VOID ReleaseAdapter(PRT2570ADAPTER Adapter, BOOLEAN IsFree); >- >- >-VOID RejectPendingPackets(PRT2570ADAPTER Adapter); >- >-int ControlThread(IN OUT PVOID Context); >- >- >-int TXThread(IN OUT PVOID Context); >- >- >-BOOLEAN RT2570UsbReset(PRT2570ADAPTER Adapter); >- >-NTSTATUS USB_ResetPipe(PRT2570ADAPTER Adapter, >- UINT BulkPipe); >- >-int USB_CallUSBD(PRT2570ADAPTER Adapter, >- IN PURB Urb); >-#endif >diff -ruN rt2570-1.1.0-b1/Module/rt_config.h rt2570-cvs-2005122616/Module/rt_config.h >--- rt2570-1.1.0-b1/Module/rt_config.h 2005-07-30 11:45:39.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rt_config.h 2005-07-11 04:38:21.000000000 -0500 >@@ -40,16 +40,16 @@ > #define PROFILE_PATH "/etc/Wireless/RT2570STA/RT2570STA.dat" > #define NIC_DEVICE_NAME "RT2500USBSTA" > #define DRV_MAJORVERSION 1 >-#define DRV_MINORVERSION 1 >+#define DRV_MINORVERSION 0 > #define DRV_SUBVERSION 0 > #define DRV_TESTVERSION 0 > #define DRV_YEAR 2005 >-#define DRV_MONTH 7 >-#define DRV_DAY 31 >+#define DRV_MONTH 6 >+#define DRV_DAY 1 > > #define DRV_NAME "rt2570" >-#define DRV_VERSION "1.1.0 BETA1" >-#define DRV_RELDATE "2005/07/31" >+#define DRV_VERSION "1.0.0 - CVS" >+#define DRV_RELDATE "2005/06/01" > > > /* Operational parameters that are set at compile time. */ >diff -ruN rt2570-1.1.0-b1/Module/.#rt_config.h.1.3 rt2570-cvs-2005122616/Module/.#rt_config.h.1.3 >--- rt2570-1.1.0-b1/Module/.#rt_config.h.1.3 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#rt_config.h.1.3 1969-12-31 18:00:00.000000000 -0600 >@@ -1,192 +0,0 @@ >-/* >- *************************************************************************** >- * Ralink Tech Inc. >- * 4F, No. 2 Technology 5th Rd. >- * Science-based Industrial Park >- * Hsin-chu, Taiwan, R.O.C. >- * >- * (c) Copyright 2002-2004, 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: >- rt_config.h >- >- Abstract: >- >- Revision History: >- Who When What >- -------- ---------- ---------------------------------------------- >- Name Date Modification logs >- Jan Lee 2005-06-01 Release >- RobinC 02-06-2005 usb_kill_urb fixes for kernels =>2.6.7 >-*/ >-#ifndef __RT_CONFIG_H__ >-#define __RT_CONFIG_H__ >- >-#define PROFILE_PATH "/etc/Wireless/RT2570STA/RT2570STA.dat" >-#define NIC_DEVICE_NAME "rt2570" >-#define DRV_MAJORVERSION 1 >-#define DRV_MINORVERSION 0 >-#define DRV_SUBVERSION 0 >-#define DRV_TESTVERSION 0 >-#define DRV_YEAR 2005 >-#define DRV_MONTH 7 >-#define DRV_DAY 13 >- >- >- >- >-/* Operational parameters that are set at compile time. */ >-#if !defined(__OPTIMIZE__) || !defined(__KERNEL__) >-#warning You must compile this file with the correct options! >-#warning See the last lines of the source file. >-#error You must compile this driver with "-O". >-#endif >- >-#include <linux/module.h> >-#include <linux/version.h> >-#include <linux/kernel.h> >-#include <linux/string.h> >-#include <linux/timer.h> >-#include <linux/errno.h> >-#include <linux/ioport.h> >-//#include <linux/interrupt.h> >-#include <linux/pci.h> >-#include <linux/netdevice.h> >-#include <linux/etherdevice.h> >-#include <linux/skbuff.h> >-#include <linux/init.h> >-#include <linux/delay.h> >-#include <linux/ethtool.h> >-#include <linux/wireless.h> >-#include <linux/proc_fs.h> >-#include <linux/delay.h> >-#include <linux/if_arp.h> >-#include <linux/ctype.h> >-#include <linux/sched.h> >-#include <linux/smp_lock.h> >-#include <linux/kmod.h> >-#include <linux/slab.h> >- >-//usb header files >-#include <linux/usb.h> >- >-#if LINUX_VERSION_CODE >= 0x20407 >-#include <linux/mii.h> >-#endif >-#include <asm/processor.h> /* Processor type for cache alignment. */ >-#include <asm/bitops.h> >-#include <asm/io.h> >-#include <asm/irq.h> >-#include <asm/uaccess.h> >-#include <asm/atomic.h> >- >-// The type definition has to be placed before including rt2460.h >-#ifndef ULONG >-#define CHAR char >-#define INT int >-#define UINT u32 >-#define ULONG u32 >-#define USHORT u16 >-#define UCHAR u8 >- >-#define BOOLEAN u8 >-//#define LARGE_INTEGER s64 >-#define VOID void >-#define LONG int >-#define ULONGLONG u64 >-typedef VOID *PVOID; >-typedef CHAR *PCHAR; >-typedef UCHAR *PUCHAR; >-typedef USHORT *PUSHORT; >-typedef LONG *PLONG; >-typedef ULONG *PULONG; >- >-typedef union _LARGE_INTEGER { >- struct { >- ULONG LowPart; >- LONG HighPart; >- }vv; >- struct { >- ULONG LowPart; >- LONG HighPart; >- } u; >- s64 QuadPart; >-} LARGE_INTEGER; >- >-#endif >- >-#define IN >-#define OUT >- >-#define TRUE 1 >-#define FALSE 0 >- >-#define ETH_LENGTH_OF_ADDRESS 6 >- >-#define NDIS_STATUS INT >-#define NDIS_STATUS_SUCCESS 0x00 >-#define NDIS_STATUS_FAILURE 0x01 >-#define NDIS_STATUS_RESOURCES 0x03 >-#define NDIS_STATUS_MEDIA_DISCONNECT 0x04 >-#define NDIS_STATUS_MEDIA_CONNECT 0x05 >-#define NDIS_STATUS_RESET 0x06 >- >- >-// >-// Hradware related header files >-// >-#include "rt2570.h" >- >-// >-// Miniport defined header files >-// >-#include "rtmp_type.h" >-#include "rtmp_def.h" >-#include "oid.h" >-#include "mlme.h" >-#include "md5.h" >-#include "wpa.h" >-#include "sha1.h" >-#include "rt2570sw.h" >-//#include "Stdincl.h" >-#include "rtusb.h" >- >- >-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) >-#define rtusb_submit_urb(purb) usb_submit_urb(purb, GFP_KERNEL) >-#else >-#define rtusb_submit_urb(purb) usb_submit_urb(purb) >-#endif >- >-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) >- #define usb_kill_urb usb_unlink_urb >-#endif >- >- >-#define __BH >-#define RHEL >- #ifndef KERNEL_VERSION >-#define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c)) >-#endif // __RT_CONFIG_H__ >-#ifndef USB_ST_NOERROR >-#define USB_ST_NOERROR 0 >-#endif >-#define INIT_FROM_EEPROM >-#define RT2570_DBG 1 >-#endif >diff -ruN rt2570-1.1.0-b1/Module/rtmp_def.h rt2570-cvs-2005122616/Module/rtmp_def.h >--- rt2570-1.1.0-b1/Module/rtmp_def.h 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtmp_def.h 2005-08-03 08:54:12.000000000 -0500 >@@ -49,7 +49,7 @@ > #define RT_DEBUG_ADHOC 3 > > #define NIC_TAG ((ULONG)'0752') >-#define NIC_DBG_STRING ("RTUSB ") >+#define NIC_DBG_STRING "RTUSB " > > // > // update the driver version number every time you release a new driver >diff -ruN rt2570-1.1.0-b1/Module/rtmp_tkip.c rt2570-cvs-2005122616/Module/rtmp_tkip.c >--- rt2570-1.1.0-b1/Module/rtmp_tkip.c 2005-07-30 11:44:29.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtmp_tkip.c 2005-08-17 04:00:39.000000000 -0500 >@@ -562,14 +562,14 @@ > // Since the MIC value might cross MPDUs. > if(memcmp(pAdapter->PrivateInfo.Rx.MIC, OldMic, 8) != 0) > { >- DBGPRINT_RAW(RT_DEBUG_ERROR, "! TKIP MIC Error Len=%d!\n", Len); //MIC error. >- DBGPRINT_RAW(RT_DEBUG_INFO, "Orig MIC value ="); //MIC error. >+ DBGPRINT(RT_DEBUG_ERROR, "! TKIP MIC Error Len=%d!\n", Len); //MIC error. >+ DBGPRINT(RT_DEBUG_INFO, "Orig MIC value = "); //MIC error. > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", OldMic[i]); //MIC error. > } > DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); //MIC error. >- DBGPRINT_RAW(RT_DEBUG_INFO, "Calculated MIC value ="); //MIC error. >+ DBGPRINT(RT_DEBUG_INFO, "Calculated MIC value = "); //MIC error. > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Rx.MIC[i]); //MIC error. >@@ -647,13 +647,13 @@ > if(memcmp(pAdapter->PrivateInfo.Rx.MIC, OldMic, 8) != 0) > { > DBGPRINT_RAW(RT_DEBUG_ERROR, "! TKIP MIC Error !\n"); //MIC error. >- DBGPRINT_RAW(RT_DEBUG_INFO, "Orig MIC value ="); //MIC error. >+ DBGPRINT(RT_DEBUG_INFO, "Orig MIC value = "); //MIC error. > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", OldMic[i]); //MIC error. > } > DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); //MIC error. >- DBGPRINT_RAW(RT_DEBUG_INFO, "Calculated MIC value ="); //MIC error. >+ DBGPRINT(RT_DEBUG_INFO, "Calculated MIC value = "); //MIC error. > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Rx.MIC[i]); //MIC error. >diff -ruN rt2570-1.1.0-b1/Module/rtusb_bulk.c rt2570-cvs-2005122616/Module/rtusb_bulk.c >--- rt2570-1.1.0-b1/Module/rtusb_bulk.c 2005-07-30 11:44:29.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtusb_bulk.c 2005-09-12 08:46:15.000000000 -0500 >@@ -107,7 +107,9 @@ > NdisReleaseSpinLock(&pAdapter->BulkOutLock); > return; > } >- else if (pAdapter->MediaState == NdisMediaStateDisconnected) >+ else if (pAdapter->MediaState == NdisMediaStateDisconnected && >+ !( pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE ) >+ ) > { > // > // Since there is no connection, so we need to empty the Tx Bulk out Ring. >diff -ruN rt2570-1.1.0-b1/Module/rtusb_data.c rt2570-cvs-2005122616/Module/rtusb_data.c >--- rt2570-1.1.0-b1/Module/rtusb_data.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtusb_data.c 2005-11-25 05:36:41.000000000 -0600 >@@ -40,6 +40,7 @@ > 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec > 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14 > 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14 >+static UINT _11G_RATES[12] = { 0, 0, 0, 0, 6, 9, 12, 18, 24, 36, 48, 54 }; > static UCHAR SNAP_802_1H[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; > static UCHAR SNAP_BRIDGE_TUNNEL[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; > static UCHAR EAPOL[] = {0x88, 0x8e}; >@@ -84,7 +85,9 @@ > return 0; > } > // Drop packets if no associations >- else if (!INFRA_ON(pAdapter) && !ADHOC_ON(pAdapter)) >+ else if (!INFRA_ON(pAdapter) && !ADHOC_ON(pAdapter) && >+ !( pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE ) >+ ) > { > RTUSBFreeSkbBuffer(skb); > return 0; >@@ -140,6 +143,15 @@ > // Init priority value > Priority = 0; > AccessCategory = 0; >+ >+ if (skb && pAdapter->PortCfg.BssType == BSS_MONITOR && >+ pAdapter->PortCfg.MallowRFMONTx == TRUE) >+ { >+ NdisAcquireSpinLock(&pAdapter->SendTxWaitQueueLock); >+ skb_queue_tail(&pAdapter->SendTxWaitQueue, skb); >+ NdisReleaseSpinLock(&pAdapter->SendTxWaitQueueLock); >+ return (NDIS_STATUS_SUCCESS); >+ } > > if (skb) > { >@@ -806,6 +818,36 @@ > DBGPRINT(RT_DEBUG_ERROR, "Error, Null skb data buffer!!!\n"); > return (NDIS_STATUS_FAILURE); > } >+ >+ if (pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE) >+ { >+ pTxContext = &pAdapter->TxContext[pAdapter->NextTxIndex]; >+ pTxContext->InUse = TRUE; >+ pTxContext->LastOne = TRUE; >+ >+ pAdapter->NextTxIndex++; >+ if (pAdapter->NextTxIndex >= TX_RING_SIZE) >+ pAdapter->NextTxIndex = 0; >+ >+ pTxD = &(pTxContext->TransferBuffer->TxDesc); >+ memset(pTxD, 0, sizeof(TXD_STRUC)); >+ pDest = pTxContext->TransferBuffer->WirelessPacket; >+ >+ memcpy( pDest, skb->data, skb->len ); >+ >+ RTUSBWriteTxDescriptor(pTxD, FALSE, 0, FALSE, FALSE, TRUE, IFS_BACKOFF, skb->len, FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, skb->len + 4, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >+ >+ TransferBufferLength = skb->len + sizeof(TXD_STRUC); >+ if ((TransferBufferLength % 2) == 1) >+ TransferBufferLength++; >+ >+ pTxContext->BulkOutSize = TransferBufferLength; >+ atomic_inc(&pAdapter->TxCount); >+ RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_DATA_FRAG); >+ RTUSBFreeSkbBuffer(skb); >+ return (NDIS_STATUS_SUCCESS); >+ } >+ > if (NdisBufferLength < 14) > { > DBGPRINT_RAW(RT_DEBUG_ERROR, "RTUSBHardEncrypt --> Ndis Packet buffer error !!!\n"); >@@ -1105,19 +1147,19 @@ > { > INT i; > >- DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP Key = "); >+ DBGPRINT(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP Key = "); > for (i = 0; i < 16; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->Key[i]); > } > DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxMic = "); >+ DBGPRINT(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxMic = "); > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->TxMic[i]); > } > DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxTsc = "); >+ DBGPRINT(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxTsc = "); > for (i = 0; i < 6; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->TxTsc[i]); >@@ -1407,7 +1449,7 @@ > INT i; > > NdisBufferLength = 8; // Set length to MIC length >- DBGPRINT_RAW(RT_DEBUG_INFO, "Calculated TX MIC value ="); >+ DBGPRINT(RT_DEBUG_INFO, "Calculated TX MIC value = "); > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Tx.MIC[i]); >@@ -1631,6 +1673,7 @@ > NDIS_802_11_ENCRYPTION_STATUS Cipher; > struct sk_buff *skb; > PVOID pManage; >+ wlan_ng_prism2_header *ph; > > pRxContext= (PRX_CONTEXT)pUrb->context; > pAdapter = pRxContext->pAdapter; >@@ -1668,6 +1711,62 @@ > struct sk_buff *skb; > if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL) > { >+ if (pAdapter->PortCfg.MallowRFMONTx == TRUE) >+ goto rfmontx_80211_receive; >+ >+ // setup the wlan-ng prismheader >+ >+ if (skb_headroom(skb) < sizeof(wlan_ng_prism2_header)) >+ pskb_expand_head(skb, sizeof(wlan_ng_prism2_header), 0, GFP_ATOMIC); >+ >+ ph = (wlan_ng_prism2_header *) >+ skb_push(skb, sizeof(wlan_ng_prism2_header)); >+ memset(ph, 0, sizeof(wlan_ng_prism2_header)); >+ >+ ph->msgcode = DIDmsg_lnxind_wlansniffrm; >+ ph->msglen = sizeof(wlan_ng_prism2_header); >+ strcpy(ph->devname, pAdapter->net->name); >+ >+ ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime; >+ ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime; >+ ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel; >+ ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi; >+ ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal; >+ ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise; >+ ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate; >+ ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx; >+ ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen; >+ >+ ph->hosttime.len = 4; >+ ph->mactime.len = 4; >+ ph->channel.len = 4; >+ ph->rssi.len = 4; >+ ph->signal.len = 4; >+ ph->noise.len = 4; >+ ph->rate.len = 4; >+ ph->istx.len = 4; >+ ph->frmlen.len = 4; >+ >+ ph->hosttime.data = jiffies; >+ ph->channel.data = pAdapter->PortCfg.IbssConfig.Channel; >+ ph->signal.data = pRxD->BBR1; >+ ph->noise.data = pAdapter->PortCfg.LastR17Value; >+ ph->rssi.data = ph->signal.data - ph->noise.data; >+ ph->frmlen.data = pRxD->DataByteCnt; >+ >+ if (pRxD->Ofdm == 1) >+ { >+ for (i = 4; i < 12; i++) >+ if (pRxD->BBR0 == PlcpSignal[i]) >+ ph->rate.data = _11G_RATES[i] * 2; >+ } >+ else >+ ph->rate.data = pRxD->BBR0 / 5; >+ >+ // end prismheader setup >+ >+ rfmontx_80211_receive: >+ > skb->dev = pAdapter->net; > memcpy(skb_put(skb, pRxD->DataByteCnt-4), pData, pRxD->DataByteCnt-4); > skb->mac.raw = skb->data; >@@ -2027,7 +2126,7 @@ > { > pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.PairwiseKey[idx]; > pWpaKey->Type = PAIRWISE_KEY; >- DBGPRINT(RT_DEBUG_TEMP, "Rx Use Pairwise Key %d\n",idx); >+ DBGPRINT(RT_DEBUG_LOUD, "Rx Use Pairwise Key %d\n",idx); > break; > } > } >@@ -2160,7 +2259,7 @@ > pAdapter->netstats.rx_packets++; > } > //memset(Header802_3, 0, LENGTH_802_3); >- DBGPRINT_RAW(RT_DEBUG_INFO, "!!! Broadcast Ethenet rx Indicated !!!\n"); >+ DBGPRINT_RAW(RT_DEBUG_INFO, "!!! Broadcast Ethernet rx Indicated !!!\n"); > } //if (pRxD->Bcast || pRxD->Mcast) > // Begin process unicast to me frame > else if (pRxD->U2M) >diff -ruN rt2570-1.1.0-b1/Module/.#rtusb_data.c.1.6 rt2570-cvs-2005122616/Module/.#rtusb_data.c.1.6 >--- rt2570-1.1.0-b1/Module/.#rtusb_data.c.1.6 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#rtusb_data.c.1.6 1969-12-31 18:00:00.000000000 -0600 >@@ -1,3112 +0,0 @@ >-/*************************************************************************** >- * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net * >- * * >- * 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. * >- * * >- * Licensed under the GNU GPL * >- * Original code supplied under license from RaLink Inc, 2004. * >- ***************************************************************************/ >- >-/*************************************************************************** >- * Module Name: rtusb_data.c >- * >- * Abstract: >- * >- * Revision History: >- * Who When What >- * -------- ---------- ------------------------------- >- * Name Date Modification logs >- * Jan Lee 2005-06-01 Release >- * RobinC 02-06-2005 RFMON Mode added >- * MathiasK 04-07-2005 big endian fix from gglomm >- ***************************************************************************/ >- >-#include "rt_config.h" >- >-static UCHAR PlcpSignal[12] = { >- 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec >- 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14 >- 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14 >-static UCHAR SNAP_802_1H[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; >-static UCHAR SNAP_BRIDGE_TUNNEL[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; >-static UCHAR EAPOL[] = {0x88, 0x8e}; >-static UCHAR IPX[] = {0x81, 0x37}; >-static UCHAR APPLE_TALK[] = {0x80, 0xf3}; >-UCHAR ARP[]={0x08, 0x06}; >-//////////////////////////////////////////////////////////////////////////// >-// >-// FUNCTION >-// RTUSBSendPackets >-// >-// DESCRIPTION >-// VNETMultipleSend handler is called by NDIS to transmit packets >-// through the adapter. If there are packets in the Q and the device >-// can accept the Tx requests initiate a transmission and queue the >-// rest of the packets (if any...). If we can not transmit or the >-// station is not ready we imediatelly complete the request >-// >-// INPUT >-// MiniportAdapterContext Context registered with the wrapper >-// (Ptr to to the Adapter object) >-// PacketArray Array of Ptrs to NDIS_PACKET structs >-// NumberOfPackets Number of packets in PacketArray >-// >-// OUTPUT >-// - >-// >-//////////////////////////////////////////////////////////////////////////// >-int RTUSBSendPackets(struct sk_buff *skb, struct net_device *net_dev) >-{ >- >- NDIS_STATUS Status = NDIS_STATUS_SUCCESS; >- PRT2570ADAPTER pAdapter = net_dev->priv; >- >- skb->data_len = skb->len; >- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS) || >- RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS) || >- RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF) || >- RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_HALT_IN_PROGRESS)) >- { >- RTUSBFreeSkbBuffer(skb); >- return 0; >- } >- // Drop packets if no associations >- else if (!INFRA_ON(pAdapter) && !ADHOC_ON(pAdapter)) >- { >- RTUSBFreeSkbBuffer(skb); >- return 0; >- } >- else >- { >- Status = RTUSBSendPacket(pAdapter, skb); >- if (Status != NDIS_STATUS_SUCCESS) >- { >- // Errors before enqueue stage >- RTUSBFreeSkbBuffer(skb); >- DBGPRINT(RT_DEBUG_TRACE,"<---RTUSBSendPackets not dequeue\n"); >- return 0; >- } >- } >- // Dequeue one frame from SendTxWait queue and process it >- // There are two place calling dequeue for TX ring. >- // 1. Here, right after queueing the frame. >- // 2. At the end of TxRingTxDone service routine. >- if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_HALT_IN_PROGRESS))) >- { >- //RTMPDeQueuePacket(pAdapter, &pAdapter->TxSwQueue0); >- // Call dequeue without selected queue, let the subroutine select the right priority >- // Tx software queue >- RTUSBDeQueuePacket(pAdapter); >- } >- >- // Kick bulk out >- RTUSBKickBulkOut(pAdapter); >- return 0; >-} >- >-NDIS_STATUS RTUSBSendPacket( >- IN PRT2570ADAPTER pAdapter, >- IN struct sk_buff *skb) >-{ >- >- >- PVOID pVirtualAddress; >- struct sk_buff_head *pTxQueue; >- ULONG Priority; >- UCHAR NumberOfFrag; >- UCHAR RTSRequired; >- UINT AllowFragSize; >- UCHAR AccessCategory; >- NDIS_STATUS Status = NDIS_STATUS_FAILURE; >- UCHAR PsMode; >- >- // Init priority value >- Priority = 0; >- AccessCategory = 0; >- >- if (skb) >- { >- Priority = skb->priority; >- // 802.11e/d4.4 June, 2003 >- if (Priority <=2) >- AccessCategory = 0; >- else if (Priority == 3) >- AccessCategory = 1; >- else if (Priority <= 5) >- AccessCategory = 2; >- else >- AccessCategory = 3; >- DBGPRINT(RT_DEBUG_INFO, "Priority = %d, AC = %d\n", Priority, AccessCategory); >- } >- // For TKIP, MIC value is treated as payload, it might be fragmented through >- // different MPDUs. >- if (pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) >- { >- skb->data_len += 8; >- } >- >- pVirtualAddress = (PVOID)skb->data; >- // Check for virtual address allocation, it might fail !!! >- if (pVirtualAddress == NULL) >- { >- DBGPRINT(RT_DEBUG_TRACE,"<---RTUSBSendPacket NULL pVirtualAddress\n"); >- // Resourece is low, system did not allocation virtual address >- // return NDIS_STATUS_FAILURE directly to upper layer >- return (Status); >- } >- >- // >- // Check for multicast or broadcast (First byte of DA) >- // >- if ((*((PUCHAR) pVirtualAddress) & 0x01) != 0) >- { >- // For multicast & broadcast, there is no fragment allowed >- NumberOfFrag = 1; >- } >- else >- { >- // Check for payload allowed for each fragment >- AllowFragSize = (pAdapter->PortCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC; >- >- // Calculate fragments required >- NumberOfFrag = ((skb->data_len - LENGTH_802_3 + LENGTH_802_1_H) / AllowFragSize) + 1; >- // Minus 1 if the size just match to allowable fragment size >- if (((skb->data_len - LENGTH_802_3 + LENGTH_802_1_H) % AllowFragSize) == 0) >- { >- NumberOfFrag--; >- } >- } >- >- // Check for requirement of RTS >- if (NumberOfFrag > 1) >- { >- // If multiple fragment required, RTS is required only for the first fragment >- // if the fragment size large than RTS threshold >- RTSRequired = (pAdapter->PortCfg.FragmentThreshold > pAdapter->PortCfg.RtsThreshold) ? 1 : 0; >- } >- else >- { >- RTSRequired = (skb->data_len > pAdapter->PortCfg.RtsThreshold) ? 1 : 0; >- } >- >- // RTS/CTS may also be required in order to protect OFDM frame >- if ((pAdapter->PortCfg.TxRate >= RATE_FIRST_OFDM_RATE) && pAdapter->PortCfg.BGProtectionInUsed) >- RTSRequired = 1; >- //DBGPRINT(RT_DEBUG_TEMP, "Number of fragments :%d , include RTS :%d\n", NumberOfFrag, NumberOfFrag + RTSRequired); >- >- // Save framnet number to Ndis packet reserved field >- RTMP_SET_PACKET_FRAGMENTS(skb, NumberOfFrag); >- >- // Save RTS requirement to Ndis packet reserved field >- RTMP_SET_PACKET_RTS(skb, RTSRequired); >- >- // Make sure SendTxWait queue resource won't be used by other threads >- NdisAcquireSpinLock(&pAdapter->SendTxWaitQueueLock); >- >- pTxQueue = &pAdapter->SendTxWaitQueue; >- if (INFRA_ON(pAdapter)) >- { >- // In infrastructure mode, simply enqueue the packet into Tx waiting queue. >- DBGPRINT(RT_DEBUG_INFO, "Infrastructure -> Enqueue one frame\n"); >- >- // Enqueue Ndis packet to end of Tx wait queue >- skb_queue_tail(pTxQueue, skb); >- Status = NDIS_STATUS_SUCCESS; >- } >- else >- { >- // In IBSS mode, power state of destination should be considered. >- PsMode = PWR_ACTIVE; // Faked >- if (PsMode == PWR_ACTIVE) >- { >- // Enqueue Ndis packet to end of Tx wait queue >- skb_queue_tail(pTxQueue, skb); >- Status = NDIS_STATUS_SUCCESS; >- } >- } >- >- NdisReleaseSpinLock(&pAdapter->SendTxWaitQueueLock); >- return Status; >-} >- >-VOID RTUSBDeQueuePacket( >- IN PRT2570ADAPTER pAdapter) >-{ >- >- UCHAR FragmentRequired; >- NDIS_STATUS Status = NDIS_STATUS_SUCCESS; >- struct sk_buff *skb; >- struct sk_buff_head *pQueue; >- UCHAR Count = 0; >- // Make sure SendTxWait queue resource won't be used by other threads >- NdisAcquireSpinLock(&pAdapter->SendTxWaitQueueLock); >- >- // Select Queue >- pQueue = &pAdapter->SendTxWaitQueue; >- >- // Check queue before dequeue >- while (!skb_queue_empty(pQueue) && (Count < MAX_TX_PROCESS)) >- { >- // Reset is in progress, stop immediately >- if ( RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS) || >- RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS) || >- RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_HALT_IN_PROGRESS)) >- { >- break; >- } >- >- // Dequeue the first entry from head of queue list >- skb = skb_dequeue(pQueue); >- >- >- // RTS or CTS-to-self for B/G protection mode has been set already. >- // There is no need to re-do it here. >- // Total fragment required = number of fragment + RST if required >- FragmentRequired = RTMP_GET_PACKET_FRAGMENTS(skb) + RTMP_GET_PACKET_RTS(skb); >- >- if (RTUSBFreeDescriptorRequest(pAdapter, TX_RING, FragmentRequired) == NDIS_STATUS_SUCCESS) >- { >- // Avaliable ring descriptors are enough for this frame >- // Call hard transmit >- // Nitro mode / Normal mode selection >- NdisReleaseSpinLock(&pAdapter->SendTxWaitQueueLock); >- if (pAdapter->PortCfg.EnableTxBurst == 1) >- Status = RTUSBHardEncrypt(pAdapter, skb, FragmentRequired, TRUE); >- else >- Status = RTUSBHardEncrypt(pAdapter, skb, FragmentRequired, FALSE); >- // >- // Acquire the resource again, snice we may need to process it in this while-loop. >- // >- NdisAcquireSpinLock(&pAdapter->SendTxWaitQueueLock); >- if (Status == NDIS_STATUS_FAILURE) >- { >- // Packet failed due to various Ndis Packet error >- RTUSBFreeSkbBuffer(skb); >- break; >- } >- else if (Status == NDIS_STATUS_RESOURCES) >- { >- // Not enough free tx ring, it might happen due to free descriptor inquery might be not correct >- // It also might change to NDIS_STATUS_FAILURE to simply drop the frame >- // Put the frame back into head of queue >- skb_queue_head(pQueue, skb); >- break; >- } >- Count++; >- } >- else >- { >- skb_queue_head(pQueue, skb); >- break; >- } >- } >- >- NdisReleaseSpinLock(&pAdapter->SendTxWaitQueueLock); >- return; >- >-} >- >-NDIS_STATUS RTUSBFreeDescriptorRequest( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR RingType, >- IN UCHAR NumberRequired) >-{ >- UCHAR FreeNumber = 0; >- UINT Index; >- NDIS_STATUS Status = NDIS_STATUS_FAILURE; >- >- switch (RingType) >- { >- case TX_RING: >- Index = pAdapter->NextTxIndex; >- do >- { >- PTX_CONTEXT pTxD = &pAdapter->TxContext[Index]; >- >- // While Owner bit is NIC, obviously ASIC still need it. >- // If valid bit is TRUE, indicate that TxDone has not process yet >- // We should not use it until TxDone finish cleanup job >- if (pTxD->InUse == FALSE) >- { >- // This one is free >- FreeNumber++; >- } >- else >- { >- break; >- } >- Index = (Index + 1) % TX_RING_SIZE; >- } while (FreeNumber < NumberRequired); // Quit here ! Free number is enough ! >- >- if (FreeNumber >= NumberRequired) >- { >- Status = NDIS_STATUS_SUCCESS; >- } >- >- break; >- >- case PRIO_RING: >- Index = pAdapter->NextMLMEIndex; >- do >- { >- PTX_CONTEXT pTxD = &pAdapter->MLMEContext[Index]; >- >- // While Owner bit is NIC, obviously ASIC still need it. >- // If valid bit is TRUE, indicate that TxDone has not process yet >- // We should not use it until TxDone finish cleanup job >- if (pTxD->InUse == FALSE) >- { >- // This one is free >- FreeNumber++; >- } >- else >- { >- break; >- } >- >- Index = (Index + 1) % PRIO_RING_SIZE; >- } while (FreeNumber < NumberRequired); // Quit here ! Free number is enough ! >- >- if (FreeNumber >= NumberRequired) >- { >- Status = NDIS_STATUS_SUCCESS; >- } >- break; >- >- default: >- break; >- >- >- >- } >- >- return (Status); >- >-} >-/* >- ======================================================================== >- >- Routine Description: >- >- Arguments: >- >- Return Value: >- >- IRQL = >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTUSBRejectPendingPackets( >- IN PRT2570ADAPTER pAdapter) >-{ >- DBGPRINT_RAW(RT_DEBUG_TRACE, "--->RejectPendingPackets\n"); >- >- NdisAcquireSpinLock(&pAdapter->SendTxWaitQueueLock); >- DBGPRINT_RAW(RT_DEBUG_TRACE, "Purge SendTxWaitQueue\n"); >- skb_queue_purge(&pAdapter->SendTxWaitQueue); >- NdisReleaseSpinLock(&pAdapter->SendTxWaitQueueLock); >- >- DBGPRINT_RAW(RT_DEBUG_TRACE, "<---RejectPendingPackets\n"); >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Suspend MSDU transmission >- >- Arguments: >- pAdapter Pointer to our adapter >- >- Return Value: >- None >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTUSBSuspendMsduTransmission( >- IN PRT2570ADAPTER pAdapter) >-{ >- DBGPRINT(RT_DEBUG_TRACE,"SCANNING, suspend MSDU transmission ...\n"); >- RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Resume MSDU transmission >- >- Arguments: >- pAdapter Pointer to our adapter >- >- Return Value: >- None >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTUSBResumeMsduTransmission( >- IN PRT2570ADAPTER pAdapter) >-{ >- DBGPRINT(RT_DEBUG_TRACE,"SCANNING, resume MSDU transmission ...\n"); >- RTMP_CLEAR_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); >- if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))) >- { >- // Call dequeue without selected queue, let the subroutine select the right priority >- // Tx software queue >- RTUSBDeQueuePacket(pAdapter); >- } >- >- // Kick bulk out >- RTUSBKickBulkOut(pAdapter); >- >-} >-/* >- ======================================================================== >- >- Routine Description: >- >- Arguments: >- >- Return Value: >- >- Note: >- >- ======================================================================== >-*/ >-USHORT RTUSBCalcDuration( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR Rate, >- IN ULONG Size) >-{ >- ULONG Duration = 0; >- >- if (Rate < RATE_FIRST_OFDM_RATE) // CCK >- { >- if ((Rate > RATE_1) && (pAdapter->PortCfg.TxPreambleInUsed == Rt802_11PreambleShort)) >- Duration = 96; // 72+24 preamble+plcp >- else >- Duration = 192; // 144+48 preamble+plcp >- >- Duration += (USHORT)((Size << 4) / RateIdTo500Kbps[Rate]); >- if ((Size << 4) % RateIdTo500Kbps[Rate]) >- Duration ++; >- } >- else // OFDM rates >- { >- Duration = 20 + 6; // 16+4 preamble+plcp + Signal Extension >- Duration += 4 * (USHORT)((11 + Size * 4) / RateIdTo500Kbps[Rate]); >- if ((11 + Size * 4) % RateIdTo500Kbps[Rate]) >- Duration += 4; >- } >- >- return (USHORT)Duration; >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Calculates the duration which is required to transmit out frames >- with given size and specified rate. >- >- Arguments: >- pTxD Pointer to transmit descriptor >- Ack Setting for Ack requirement bit >- Fragment Setting for Fragment bit >- RetryMode Setting for retry mode >- Ifs Setting for IFS gap >- Rate Setting for transmit rate >- Service Setting for service >- Length Frame length >- >- Return Value: >- None >- >- ======================================================================== >-*/ >-VOID RTUSBWriteTxDescriptor( >- IN PTXD_STRUC pTxD, >- IN BOOLEAN Fragment, >- IN UCHAR RetryLimit, >- IN BOOLEAN Ack, >- IN BOOLEAN InsTimestamp, >- IN BOOLEAN new_seq, >- IN UCHAR Ifs, >- IN UINT Length, >- IN BOOLEAN Cipher, >- IN UCHAR KeyID, >- IN UCHAR CWMin, >- IN UCHAR CWMax, >- IN UINT PLCPLength, >- IN UINT Rate, >- IN UCHAR Service, >- IN USHORT TxPreamble) >-{ >- UINT Residual; >- >- pTxD->RetryLimit = RetryLimit; >- pTxD->MoreFrag = Fragment; >- pTxD->ACK = Ack; >- pTxD->Timestamp = InsTimestamp; >- pTxD->newseq = new_seq; >- pTxD->IFS = Ifs; >- pTxD->DataByteCnt = Length; >- pTxD->Cipher = Cipher; >- pTxD->KeyID = KeyID; >- pTxD->CWmin = CWMin; // 2^5-1 = 31 >- pTxD->CWmax = CWMax; // 2^10 -1 = 1023 >- pTxD->Aifs = 2; // TC0: SIFS + 2*Slot + Random(CWmin,CWmax)*Slot >- >- if (Rate < RATE_FIRST_OFDM_RATE) >- pTxD->Ofdm = 0; >- else >- pTxD->Ofdm = 1; >- >- // fill up PLCP SIGNAL field >- pTxD->PlcpSignal = PlcpSignal[Rate]; >- if (((Rate == RATE_2) || (Rate == RATE_5_5) || (Rate == RATE_11)) && (TxPreamble == Rt802_11PreambleShort)) // no short preamble for RATE_1 >- { >- pTxD->PlcpSignal |= 0x0008; >- } >- >- // fill up PLCP SERVICE field, not used for OFDM rates >- pTxD->PlcpService = Service; >- >- // file up PLCP LENGTH_LOW and LENGTH_HIGH fields >- if (Rate < RATE_FIRST_OFDM_RATE) // 11b - RATE_1, RATE_2, RATE_5_5, RATE_11 >- { >- if ((Rate == RATE_1) || ( Rate == RATE_2)) >- { >- PLCPLength = PLCPLength * 8 / (Rate + 1); >- } >- else >- { >- Residual = ((PLCPLength * 16) % (11 * (1 + Rate - RATE_5_5))); >- PLCPLength = PLCPLength * 16 / (11 * (1 + Rate - RATE_5_5)); >- if (Residual != 0) >- { >- PLCPLength++; >- } >- if (Rate == RATE_11) >- { >- if ((Residual <= (3 * (1 + Rate - RATE_5_5))) && (Residual != 0)) >- { >- pTxD->PlcpService |= 0x80; // 11b's PLCP Length extension bit >- } >- } >- } >- >- pTxD->PlcpLengthHigh = PLCPLength / 256; >- pTxD->PlcpLengthLow = PLCPLength % 256; >- } >- else // OFDM - RATE_6, RATE_9, RATE_12, RATE_18, RATE_24, RATE_36, RATE_48, RATE_54 >- { >- pTxD->PlcpLengthHigh = PLCPLength / 64; // high 6-bit of total byte count >- pTxD->PlcpLengthLow = PLCPLength % 64; // low 6-bit of total byte count >- } >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Calculates the duration which is required to transmit out frames >- with given size and specified rate. >- >- Arguments: >- pTxD Pointer to transmit descriptor >- Ack Setting for Ack requirement bit >- Fragment Setting for Fragment bit >- RetryMode Setting for retry mode >- Ifs Setting for IFS gap >- Rate Setting for transmit rate >- Service Setting for service >- Length Frame length >- >- Return Value: >- None >- >- ======================================================================== >-*/ >-VOID RTUSBWriteBeaconDescriptor( >- IN PTXD_STRUC pTxD, >- IN UINT Length, >- IN UINT PLCPLength, >- IN UINT Rate, >- IN UCHAR Service, >- IN USHORT TxPreamble) >-{ >- UINT Residual; >- >- pTxD->RetryLimit = 0; >- pTxD->MoreFrag = 0; >- pTxD->ACK = 0; >- pTxD->Timestamp = 1; >- pTxD->newseq = 1; >- pTxD->IFS = IFS_NEW_BACKOFF; >- pTxD->DataByteCnt = Length; >- pTxD->Cipher = 0; >- pTxD->KeyID = 0; >- pTxD->CWmin = BEACON_CW_IN_BITS; // 2^5-1 = 31 >- pTxD->CWmax = BEACON_CW_IN_BITS; // 2^10 -1 = 1023 >- pTxD->Aifs = 2; // TC0: SIFS + 2*Slot + Random(CWmin,CWmax)*Slot >- >- if (Rate < RATE_FIRST_OFDM_RATE) >- pTxD->Ofdm = 0; >- else >- pTxD->Ofdm = 1; >- >- // fill up PLCP SIGNAL field >- pTxD->PlcpSignal = PlcpSignal[Rate]; >- if (((Rate == RATE_2) || (Rate == RATE_5_5) || (Rate == RATE_11)) && (TxPreamble == Rt802_11PreambleShort)) // no short preamble for RATE_1 >- { >- pTxD->PlcpSignal |= 0x0008; >- } >- >- // fill up PLCP SERVICE field, not used for OFDM rates >- pTxD->PlcpService = Service; >- >- // file up PLCP LENGTH_LOW and LENGTH_HIGH fields >- if (Rate < RATE_FIRST_OFDM_RATE) // 11b - RATE_1, RATE_2, RATE_5_5, RATE_11 >- { >- if ((Rate == RATE_1) || ( Rate == RATE_2)) >- { >- PLCPLength = PLCPLength * 8 / (Rate + 1); >- } >- else >- { >- Residual = ((PLCPLength * 16) % (11 * (1 + Rate - RATE_5_5))); >- PLCPLength = PLCPLength * 16 / (11 * (1 + Rate - RATE_5_5)); >- if (Residual != 0) >- { >- PLCPLength++; >- } >- if ((Residual <= (3 * (1 + Rate - RATE_5_5))) && (Residual != 0)) >- { >- pTxD->PlcpService |= 0x80; // 11b's PLCP Length extension bit >- } >- } >- >- pTxD->PlcpLengthHigh = PLCPLength / 256; >- pTxD->PlcpLengthLow = PLCPLength % 256; >- } >- else // OFDM - RATE_6, RATE_9, RATE_12, RATE_18, RATE_24, RATE_36, RATE_48, RATE_54 >- { >- pTxD->PlcpLengthHigh = PLCPLength / 64; // high 6-bit of total byte count >- pTxD->PlcpLengthLow = PLCPLength % 64; // low 6-bit of total byte count >- } >-} >- >-/* >- ======================================================================== >- >- 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: >- pAdapter 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 RTUSBHardEncrypt( >- IN PRT2570ADAPTER pAdapter, >- IN struct sk_buff *skb, >- IN UCHAR NumberRequired, >- IN ULONG EnableTxBurst) >-{ >- PVOID pVirtualAddress; >- UINT NdisBufferLength; >- UINT BytesCopied; >- UINT TxSize, PLCPLength; >- UINT FreeFragSize; >- UINT RemainSize; >- USHORT Protocol; >- UCHAR FrameGap; >- HEADER_802_11 Header_802_11; >- PUCHAR pDest; >- PUCHAR pSrc; >- PUCHAR pEncap = NULL; >- PTX_CONTEXT pTxContext; >- PTXD_STRUC pTxD; >- BOOLEAN StartOfFrame; >- BOOLEAN EAPOLFrame; >- BOOLEAN Encapped; >- ULONG Iv16; >- ULONG Iv32; >- BOOLEAN MICFrag; >- PWPA_KEY pWpaKey = (PWPA_KEY) NULL; >- BOOLEAN Cipher; >- UCHAR KeyID = 0; >- ULONG TransferBufferLength; >- BOOLEAN MoreFragment; >- UCHAR AckRate = RATE_2; >- USHORT AckDuration = 0; >- USHORT EncryptionOverhead = 0; >- BOOLEAN Bcast_8023; >- BOOLEAN SingleFrag; >-//for re-calculating the number of Fragment required. >- UINT AllowFragSize; >- UCHAR NumberOfFrag; >- UINT TotalPacketLength; >- // To indicate cipher used for this packet >- NDIS_802_11_ENCRYPTION_STATUS CipherSuite; >- >- CipherSuite = pAdapter->PortCfg.WepStatus; >- if (EnableTxBurst == 1) >- FrameGap = IFS_SIFS; >- else >- FrameGap = IFS_BACKOFF; // Default frame gap mode >- // Sequence Number is identical for all fragments belonged to the same frame >- // Sequence is 0 - 4095 >- pAdapter->Sequence = ((pAdapter->Sequence) + 1) & (MAX_SEQ_NUMBER); >- AckRate = pAdapter->PortCfg.ExpectedACKRate[pAdapter->PortCfg.TxRate]; >- AckDuration = RTUSBCalcDuration(pAdapter, AckRate, 14); >- >- pVirtualAddress = skb->data; >- NdisBufferLength = skb->len; >- if(pVirtualAddress == NULL) >- { >- DBGPRINT(RT_DEBUG_ERROR, "Error, Null skb data buffer!!!\n"); >- return (NDIS_STATUS_FAILURE); >- } >- if (NdisBufferLength < 14) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR, "RTUSBHardEncrypt --> Ndis Packet buffer error !!!\n"); >- return (NDIS_STATUS_FAILURE); >- } >- if ((*((PUCHAR) pVirtualAddress) & 0x01) != 0) // Multicast or Broadcast >- { >- INC_COUNTER(pAdapter->WlanCounters.MulticastTransmittedFrameCount); >- Bcast_8023 = TRUE; >- } >- else >- { >- Bcast_8023 = FALSE; >- } >- >- // New control flag for sending DHCP & BOOTP usinf 1MB rate >- if ((NumberRequired - RTUSB_GET_PACKET_RTS(skb)) == 1) >- { >- SingleFrag = TRUE; >- } >- else >- { >- SingleFrag = FALSE; >- } >- >- // Add 802.11x protocol check. >- // For non-WPA network, 802.11x message should not encrypt even >- // the privacy is on. >- if ((memcmp(EAPOL, ((PUCHAR) pVirtualAddress) + 12, 2) == 0)) >- { >- EAPOLFrame = TRUE; >- if (pAdapter->PortCfg.MicErrCnt >= 2)//steven:??? >- pAdapter->PortCfg.MicErrCnt++; >- } >- else >- { >- EAPOLFrame = FALSE; >- } // Initialize 802.11 header for each frame >- >- // WPA 802.1x secured port control >- if (((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || >- (pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) && >- ((pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || >- (pAdapter->PortCfg.MicErrCnt >= 2)) && >- (EAPOLFrame == FALSE)) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "RTUSBHardEncrypt --> Drop packet before port secured !!!\n"); >- return (NDIS_STATUS_FAILURE); >- } >- >- memset(&Header_802_11, 0, sizeof(HEADER_802_11)); >- // >- // Start making 802.11 frame header >- // >- if (INFRA_ON(pAdapter)) >- { >- // In BSS mode, AP's address(BSSID) is the destination address of all outgoing packets >- // Address 1 - BSSID >- memcpy(&Header_802_11.Controlhead.Addr1, &pAdapter->PortCfg.Bssid, ETH_LENGTH_OF_ADDRESS); >- // Address 3 - DA >- memcpy(&Header_802_11.Addr3, (PUCHAR) pVirtualAddress, ETH_LENGTH_OF_ADDRESS); >- Header_802_11.Controlhead.Frame.ToDs = 1; >- } >- else >- { >- // Address 1 - DA >- memcpy(&Header_802_11.Controlhead.Addr1, (PUCHAR) pVirtualAddress, ETH_LENGTH_OF_ADDRESS); >- // Address 3 - BSSID >- memcpy(&Header_802_11.Addr3, &pAdapter->PortCfg.Bssid, ETH_LENGTH_OF_ADDRESS); >- } >- // Address 2 - SA in both infrastructure & ad-hoc modes >- memcpy(&Header_802_11.Controlhead.Addr2, pAdapter->CurrentAddress, ETH_LENGTH_OF_ADDRESS); >- >-// Header_802_11.Sequence = pAdapter->Sequence; // Sequence number >- Header_802_11.Controlhead.Frame.Type = BTYPE_DATA; // Frame type >- Header_802_11.Controlhead.Frame.PwrMgt = (pAdapter->PortCfg.Psm == PWR_SAVE); >- >- // For the purpose to calculate duration for the second last fragment >- RemainSize = skb->data_len - LENGTH_802_3 + LENGTH_CRC; >- >- MICFrag = FALSE; // Flag to indicate MIC shall spread into two MPDUs >- Encapped = FALSE; >- pEncap = NULL; >- pSrc = (PUCHAR)pVirtualAddress; >- Protocol = *(pSrc + 12) * 256 + *(pSrc + 13); >- >- if (Protocol > 1500) // CHeck for LLC encaped >- { >- // >- // Large than 1500 means it's a type field, and thus a D/I/X packet. >- // >- pEncap = SNAP_802_1H; >- Encapped = TRUE; >- if ((memcmp(IPX, pSrc + 12, 2) == 0) || >- (memcmp(APPLE_TALK, pSrc + 12, 2) == 0)) >- { >- pEncap = SNAP_BRIDGE_TUNNEL; >- } >- } >- else >- { >- // >- //means it's a length field, thus an 802.3 packet >- //And we need to re-calculate the number of Fragment required. >- TotalPacketLength = skb->data_len; >- // >- //means it's a length field, thus an 802.3 packet >- //And we need to re-calculate the number of Fragment required. >- // >- // For TKIP, MIC value is treated as payload, it might be fragmented through >- // different MPDUs. >- if (pAdapter->PortCfg.GroupCipher == Ndis802_11Encryption2Enabled) >- { >- TotalPacketLength = skb->data_len + 8; >- } >- >- // Check for payload allowed for each fragment >- AllowFragSize = (pAdapter->PortCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC; >- >- // Calculate fragments required >- NumberOfFrag = ((TotalPacketLength - LENGTH_802_3) / AllowFragSize) + 1; >- // Minus 1 if the size just match to allowable fragment size >- if (((skb->data_len - LENGTH_802_3) % AllowFragSize) == 0) >- { >- NumberOfFrag--; >- } >- >- >- if (NumberOfFrag != RTUSB_GET_PACKET_FRAGMENTS(skb)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "Original fragment required = %d, new fragment required = %d\n", >- RTUSB_GET_PACKET_FRAGMENTS(skb), NumberOfFrag); >- // >- // Update number of Fragment >- // >- RTUSB_SET_PACKET_FRAGMENTS(skb, NumberOfFrag); >- NumberRequired = RTUSB_GET_PACKET_FRAGMENTS(skb) + RTUSB_GET_PACKET_RTS(skb); >- } >- } >- >- // >- // calcuate the overhead bytes that encryption algorithm may add. This >- // affects the calculate of "duration" field >- // >- if ((CipherSuite == Ndis802_11Encryption1Enabled) && >- (pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0)) >- EncryptionOverhead = 8; // WEP: IV + ICV >- else if (CipherSuite == Ndis802_11Encryption2Enabled) >- EncryptionOverhead = 12; // TKIP: IV + EIV + ICV, MIC already added to TotalPacketLength >- else if (CipherSuite == Ndis802_11Encryption3Enabled) >- EncryptionOverhead = 16; // AES: IV + EIV + Hardware MIC >- else >- EncryptionOverhead = 0; >- >- // >- // Make RTS frame if required >- // >- if (RTUSB_GET_PACKET_RTS(skb)) >- { >- PCONTROL_HEADER pControlHeader; >- ULONG NextFragSize; >- //UINT RTSFrameSize; //used only to calculate duration >- >- DBGPRINT_RAW(RT_DEBUG_INFO, "Making RTS Frame\n"); >- >- pTxContext = &pAdapter->TxContext[pAdapter->NextTxIndex]; >- pTxContext->InUse = TRUE; >- pTxContext->LastOne = FALSE; >- >- // Increase & maintain Tx Ring Index >- pAdapter->NextTxIndex++; >- if (pAdapter->NextTxIndex >= TX_RING_SIZE) >- { >- pAdapter->NextTxIndex = 0; >- } >- >- pTxD = &(pTxContext->TransferBuffer->TxDesc); >- memset(pTxD, 0, sizeof(TXD_STRUC)); >- pDest = pTxContext->TransferBuffer->WirelessPacket; >- >- pControlHeader = (PCONTROL_HEADER)pDest; >- memset(pControlHeader, 0, sizeof(CONTROL_HEADER)); >- >- //FrameControl >- pControlHeader->Frame.Type = BTYPE_CNTL; >- if (pAdapter->PortCfg.BGProtectionInUsed == 1) >- { >- pControlHeader->Frame.Subtype = SUBTYPE_CTS; >- memcpy(&pControlHeader->Addr1, pAdapter->CurrentAddress, ETH_LENGTH_OF_ADDRESS); >- } >- else >- { >- pControlHeader->Frame.Subtype = SUBTYPE_RTS; >- // RA >- if (INFRA_ON(pAdapter)) >- { >- memcpy(&pControlHeader->Addr1, &pAdapter->PortCfg.Bssid, ETH_LENGTH_OF_ADDRESS); >- } >- else >- { >- memcpy(&pControlHeader->Addr1, (PUCHAR) pVirtualAddress, ETH_LENGTH_OF_ADDRESS); >- } >- // TA >- memcpy(&pControlHeader->Addr2, pAdapter->CurrentAddress, ETH_LENGTH_OF_ADDRESS); >- } >- >- // Calculate duration = 2 SIFS + CTS + Data Frame size >- if (RTUSB_GET_PACKET_FRAGMENTS(skb) > 1) >- { >- // If fragment required, size is maximum fragment size >- NextFragSize = pAdapter->PortCfg.FragmentThreshold; >- } >- else >- { >- // Size should be frame with 802.11 header & CRC >- NextFragSize = skb->data_len + LENGTH_802_11 + LENGTH_CRC - LENGTH_802_3; >- >- if (Encapped) >- NextFragSize += LENGTH_802_1_H; >- } >- pControlHeader->Duration = 2 * (pAdapter->PortCfg.Dsifs) >- + RTUSBCalcDuration(pAdapter, pAdapter->PortCfg.TxRate, NextFragSize + EncryptionOverhead) >- + AckDuration; >- >- // Write Tx descriptor >- // Don't kick tx start until all frames are prepared >- // RTS has to set more fragment bit for fragment burst >- // RTS did not encrypt >- if (pAdapter->PortCfg.BGProtectionInUsed == 1) >- { >- RTUSBWriteTxDescriptor(pTxD, FALSE, 7, FALSE, FALSE, FALSE, FrameGap, 10, FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, 14, pAdapter->PortCfg.RtsRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- } >- else >- { >- RTUSBWriteTxDescriptor(pTxD, FALSE, 7, TRUE, FALSE, FALSE, FrameGap, sizeof(CONTROL_HEADER), FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, sizeof(CONTROL_HEADER) + 4, pAdapter->PortCfg.RtsRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >-//steven:should we need this? pTxD->RTS = 1; >- } >- >- TransferBufferLength = sizeof(CONTROL_HEADER) + sizeof(TXD_STRUC); >- if ((TransferBufferLength % 2) == 1) >- TransferBufferLength++; >- >- pTxContext->BulkOutSize = TransferBufferLength; >- >- NumberRequired--; >- // >- // Increase BulkOut stanby count. >- // >- atomic_inc(&pAdapter->TxCount); >- >- RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_DATA_NORMAL); >- } >- // Find the WPA key, either Group or Pairwise Key//steven:according to Controlhead.Addr1 (only when AuthMode >= Ndis802_11AuthModeWPA) >- if (pAdapter->PortCfg.AuthMode >= Ndis802_11AuthModeWPA) >- { >- INT idx; >- >- pWpaKey = (PWPA_KEY) NULL; >- // First lokup the DA, if it's a group address, use GROUP key >- if (Header_802_11.Controlhead.Addr1.Octet[0] & 0x01) >- { >- if (pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0) >- { >- pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId]; >- pWpaKey->Type = GROUP_KEY; >- KeyID = pAdapter->PortCfg.DefaultKeyId;//for Tx descriptor >- DBGPRINT(RT_DEBUG_INFO, "Tx Use Group Key\n"); >- } >- } >- // Try to find the Pairwise Key >- else >- { >- for (idx = 0; idx < PAIRWISE_KEY_NO; idx++) >- { >- if (((memcmp(&Header_802_11.Controlhead.Addr1, pAdapter->PortCfg.PairwiseKey[idx].BssId, 6)== 0)) && >- (pAdapter->PortCfg.PairwiseKey[idx].KeyLen != 0)) >- { >- pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.PairwiseKey[idx]; >- pWpaKey->Type = PAIRWISE_KEY; >- KeyID = (UCHAR)idx; >- DBGPRINT(RT_DEBUG_INFO, "Tx Use Pairwise Key\n"); >- break; >- } >- } >- // Use default Group Key if there is no Pairwise key present >- if ((pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0) && (pWpaKey == NULL)) >- { >- pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId]; >- pWpaKey->Type = GROUP_KEY; >- KeyID = pAdapter->PortCfg.DefaultKeyId;//for Tx descriptor >- DBGPRINT(RT_DEBUG_INFO, "Tx Use Group Key\n"); >- } >- } >- } >- >- if (pWpaKey != NULL) >- { >- INT i; >- >- DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP Key = "); >- for (i = 0; i < 16; i++) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->Key[i]); >- } >- DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxMic = "); >- for (i = 0; i < 8; i++) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->TxMic[i]); >- } >- DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxTsc = "); >- for (i = 0; i < 6; i++) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->TxTsc[i]); >- } >- DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); >- } >- >- StartOfFrame = TRUE; >- // Start Copy Ndis Packet into Ring buffer. >- // For frame required more than one ring buffer (fragment), all ring buffers >- // have to be filled before kicking start tx bit. >- do >- { >-// NdisAcquireSpinLock(&pAdapter->TxRingLock); >- // Get the Tx Ring descriptor & Dma Buffer address >- pTxContext = &pAdapter->TxContext[pAdapter->NextTxIndex]; >- pTxContext->InUse = TRUE; >- pTxContext->LastOne = FALSE; >- >- // Increase & maintain Tx Ring Index >- pAdapter->NextTxIndex++; >- if (pAdapter->NextTxIndex >= TX_RING_SIZE) >- { >- pAdapter->NextTxIndex = 0; >- } >-// NdisReleaseSpinLock(&pAdapter->TxRingLock); >- >- pTxD = &(pTxContext->TransferBuffer->TxDesc); >- memset(pTxD, 0, sizeof(TXD_STRUC)); >- pDest = pTxContext->TransferBuffer->WirelessPacket; >- // Maximum allowable payload with one ring buffer, bound by fragment size >- FreeFragSize = pAdapter->PortCfg.FragmentThreshold - LENGTH_CRC; >- >- // Make fragment number & more fragment bit of 802.11 header >- if (StartOfFrame == TRUE) >- { >- Header_802_11.Frag = 0; // Start of fragment burst / Single Frame >- } >- else >- { >- Header_802_11.Frag++; // Rest of fragmented frames. >- } >- >- // Turn on with no frames after this one >- if (NumberRequired > 1) >- { >- ULONG NextFragSize; >-// ULONG FragSize; >- >- Header_802_11.Controlhead.Frame.MoreFrag = 1; >- MoreFragment = TRUE; >- >- if (NumberRequired == 2) >- NextFragSize = RemainSize - pAdapter->PortCfg.FragmentThreshold + LENGTH_802_11 + LENGTH_802_11 + LENGTH_CRC; >- else >- NextFragSize = pAdapter->PortCfg.FragmentThreshold; >- >- Header_802_11.Controlhead.Duration = 3 * pAdapter->PortCfg.Dsifs >- + 2 * AckDuration >- + RTUSBCalcDuration(pAdapter, pAdapter->PortCfg.TxRate, NextFragSize + EncryptionOverhead); >- } >- else >- { >- Header_802_11.Controlhead.Frame.MoreFrag = 0; >- MoreFragment = FALSE; >- >- if (Header_802_11.Controlhead.Addr1.Octet[0] & 0x01) >- { >- // No ACK expected for multicast frame >- Header_802_11.Controlhead.Duration = 0; >- } >- else >- { >- // ACK size is 14 include CRC, and its rate is 2Mb >- Header_802_11.Controlhead.Duration = pAdapter->PortCfg.Dsifs + AckDuration; >- } >- } >- >- // Check for WEP enable bit and prepare for software WEP >- if ((CipherSuite == Ndis802_11Encryption1Enabled) && (EAPOLFrame == FALSE) && >- (pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0)) >- { >- Header_802_11.Controlhead.Frame.Wep = 1; >- Cipher = TRUE; >- } >- else if ((CipherSuite == Ndis802_11Encryption2Enabled) && (pWpaKey != NULL)) >- { >- Header_802_11.Controlhead.Frame.Wep = 1; >- Cipher = TRUE; >- } >- else if ((CipherSuite == Ndis802_11Encryption3Enabled) && (pWpaKey != NULL)) >- { >- Header_802_11.Controlhead.Frame.Wep = 1; >- Cipher = TRUE; >- } >- else >- { >- Header_802_11.Controlhead.Frame.Wep = 0; >- Cipher = FALSE; >- } >- >- // Copy 802.11 header to Tx ring buffer >- memcpy(pDest, &Header_802_11, sizeof(Header_802_11)); >- pDest += sizeof(Header_802_11); >- FreeFragSize -= sizeof(Header_802_11); >- >- if ((CipherSuite == Ndis802_11Encryption1Enabled) && (EAPOLFrame == FALSE) && >- (pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0)) >- { >- // Prepare IV, IV offset, Key for Hardware encryption >- RTMPInitWepEngine( >- pAdapter, >- pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].Key, >- pAdapter->PortCfg.DefaultKeyId, >- pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen, >- (PUCHAR) &pTxD->Iv); >- KeyID = pAdapter->PortCfg.DefaultKeyId; >- // Set Iv offset in TxD >- pTxD->IvOffset = LENGTH_802_11; >- >- memcpy(pDest, &pTxD->Iv, 4); >- pDest += 4; >- } >- else if ((CipherSuite == Ndis802_11Encryption2Enabled) && (pWpaKey != NULL)) >- { >- INT i; >- >- i = 0; >- // Prepare IV, EIV, IV offset, Key for hardware encryption >- RTMPInitTkipEngine( >- pAdapter, >- pWpaKey->Key, >- pAdapter->PortCfg.DefaultKeyId, // This might cause problem when using peer key >- Header_802_11.Controlhead.Addr2.Octet, >- pWpaKey->TxMic, >- pWpaKey->TxTsc, >- 0, >- &Iv16, >- &Iv32, >- pDest); >- >- // Increase TxTsc value for next transmission >- while (++pWpaKey->TxTsc[i] == 0x0) >- { >- i++; >- if (i == 6) >- break; >- } >- if (i == 6) >- { >- // TODO: TSC has done one full cycle, do re-keying stuff follow specs >- // Should send a special event microsoft defined to request re-key >- } >- >- // Copy IV >- memcpy(&pTxD->Iv, &Iv16, 4); >- >- // Copy EIV >- memcpy(&pTxD->Eiv, &Iv32, 4); >- >- // Set IV offset >- pTxD->IvOffset = LENGTH_802_11; >- >- memcpy(pDest, &Iv16, 4); >- pDest += 4; >- memcpy(pDest, &Iv32, 4); >- pDest += 4; >- >- } >- else if ((CipherSuite == Ndis802_11Encryption3Enabled) && (pWpaKey != NULL)) >- { >- INT i; >- PUCHAR pTmp; >- >- i = 0; >- pTmp = (PUCHAR) &Iv16; >- *pTmp = pWpaKey->TxTsc[0]; >- *(pTmp + 1) = pWpaKey->TxTsc[1]; >- *(pTmp + 2) = 0; >- *(pTmp + 3) = (pAdapter->PortCfg.DefaultKeyId << 6) | 0x20; >- >- Iv32 = *(PULONG)(&pWpaKey->TxTsc[2]); >- >- // Increase TxTsc value for next transmission >- while (++pWpaKey->TxTsc[i] == 0x0) >- { >- i++; >- if (i == 6) >- break; >- } >- if (i == 6) >- { >- // TODO: TSC has done one full cycle, do re-keying stuff follow specs >- // Should send a special event microsoft defined to request re-key >- } >- >- // Copy IV >- memcpy(&pTxD->Iv, &Iv16, 4); >- >- // Copy EIV >- memcpy(&pTxD->Eiv, &Iv32, 4); >- >- // Set IV offset >- pTxD->IvOffset = LENGTH_802_11; >- >- memcpy(pDest, &Iv16, 4); >- pDest += 4; >- memcpy(pDest, &Iv32, 4); >- pDest += 4; >- >- } >- >- // >- // Only the first fragment required LLC-SNAP header !!! >- // >- if ((StartOfFrame == TRUE) && (Encapped == TRUE)) >- { >- // For WEP & no encryption required frame, just copy LLC header into buffer, >- // Hardware will do the encryption job. >- // For TKIP, we have to calculate MIC and store it first >- if ((CipherSuite == Ndis802_11Encryption2Enabled) && (pWpaKey != NULL)) >- { >- // Calculate MSDU MIC Value >- RTMPCalculateMICValue(pAdapter, skb, pEncap, 6, pWpaKey); >- } >- // For WEP & no encryption required frame, just copy LLC header into buffer, >- // Hardware will do the encryption job. >- // For TKIP, we have to calculate MIC and store it first >- >- // Copy LLC header >- memcpy(pDest, pEncap, 6); >- pDest += 6; >- >- // Copy protocol type >- pSrc = (PUCHAR) pVirtualAddress; >- memcpy(pDest, pSrc + 12, 2); >- pDest += 2; >- >- // Exclude 802.3 header size, we will recalculate the size at >- // the end of fragment preparation. >- NdisBufferLength -= LENGTH_802_3; >- pSrc += LENGTH_802_3; >- FreeFragSize -= LENGTH_802_1_H; >- } >- else if ((StartOfFrame == TRUE) && (Encapped == FALSE)) >- { >- if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && (pWpaKey != NULL)) >- { >- // Calculate MSDU MIC Value >- RTMPCalculateMICValue(pAdapter, skb, pEncap, 0, pWpaKey); >- } >- >- pSrc = (PUCHAR) pVirtualAddress + LENGTH_802_3; >- NdisBufferLength -= LENGTH_802_3; >- } >- >- // Start copying payload >- BytesCopied = 0; >- do >- { >- if (NdisBufferLength >= FreeFragSize) >- { >- // Copy only the free fragment size, and save the pointer >- // of current buffer descriptor for next fragment buffer. >- memcpy(pDest, pSrc, FreeFragSize); >- BytesCopied += FreeFragSize; >- pSrc += FreeFragSize; >- pDest += FreeFragSize; >- NdisBufferLength -= FreeFragSize; >- break; >- } >- else >- { >- // Copy the rest of this buffer descriptor pointed data >- // into ring buffer. >- memcpy(pDest, pSrc, NdisBufferLength); >- BytesCopied += NdisBufferLength; >- pDest += NdisBufferLength; >- FreeFragSize -= NdisBufferLength; >- } >- // No more buffer descriptor >- // Add MIC value if needed >- if ((CipherSuite == Ndis802_11Encryption2Enabled) && >- (MICFrag == FALSE) && >- (pWpaKey != NULL)) >- { >- INT i; >- >- NdisBufferLength = 8; // Set length to MIC length >- DBGPRINT_RAW(RT_DEBUG_INFO, "Calculated TX MIC value ="); >- for (i = 0; i < 8; i++) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Tx.MIC[i]); >- } >- DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); >- >- if (FreeFragSize >= NdisBufferLength) >- { >- memcpy(pDest, pAdapter->PrivateInfo.Tx.MIC, NdisBufferLength); >- BytesCopied += NdisBufferLength; >- pDest += NdisBufferLength; >- FreeFragSize -= NdisBufferLength; >- NdisBufferLength = 0; >- RemainSize += 8; // Need to add MIC as payload >- } >- else >- { >- memcpy(pDest, pAdapter->PrivateInfo.Tx.MIC, FreeFragSize); >- BytesCopied += FreeFragSize; >- pSrc = pAdapter->PrivateInfo.Tx.MIC + FreeFragSize; >- pDest += FreeFragSize; >- NdisBufferLength -= FreeFragSize; >- MICFrag = TRUE; >- RemainSize += (8 - FreeFragSize); // Need to add MIC as payload >- } >- } >- } while (FALSE); // End of copying payload >- >- // Real packet size, No 802.1H header for fragments except the first one. >- if ((StartOfFrame == TRUE) && (Encapped == TRUE)) >- { >- TxSize = BytesCopied + LENGTH_802_11 + LENGTH_802_1_H; >- } >- else >- { >- TxSize = BytesCopied + LENGTH_802_11; >- } >- >- RemainSize = RemainSize - BytesCopied; >- >- if ((CipherSuite == Ndis802_11Encryption1Enabled) && (Header_802_11.Controlhead.Frame.Wep == 1)) >- { >- // IV + ICV which ASIC added after encryption done >- TxSize += 4; >- PLCPLength = TxSize + 8; >- } >- else if ((CipherSuite == Ndis802_11Encryption2Enabled) && (pWpaKey != NULL)) >- { >- // IV + EIV + ICV which ASIC added after encryption done >- TxSize += 8; >- PLCPLength = TxSize + 8; >- } >- else if ((CipherSuite == Ndis802_11Encryption3Enabled) && (pWpaKey != NULL)) >- { >- // IV + EIV + HW MIC >- TxSize += 8; >- PLCPLength = TxSize + 12; >- } >- else >- { >- PLCPLength = TxSize + 4; >- } >- DBGPRINT_RAW(RT_DEBUG_INFO, "TxSize = %d, PLCPLength = %d\n", TxSize, PLCPLength);//steven:for debug >- >- // Prepare Tx descriptors before kicking tx. >- // The BBP register index in Tx descriptor has to be configured too. >- if (Header_802_11.Controlhead.Addr1.Octet[0] & 0x01) >- { >- INC_COUNTER(pAdapter->WlanCounters.MulticastTransmittedFrameCount); >- // Multicast, retry bit is off >- if (StartOfFrame == TRUE) >- { >- if (RTUSB_GET_PACKET_RTS(skb) != 1) >- RTUSBWriteTxDescriptor(pTxD, FALSE, 0, FALSE, FALSE, TRUE, FrameGap, TxSize, Cipher, KeyID, CW_MIN_IN_BITS, CW_MAX_IN_BITS, PLCPLength, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- else >- RTUSBWriteTxDescriptor(pTxD, FALSE, 0, FALSE, FALSE, TRUE, FrameGap, TxSize, Cipher, KeyID, 0, 0, PLCPLength, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- } >- else >- RTUSBWriteTxDescriptor(pTxD, FALSE, 0, FALSE, FALSE, FALSE, FrameGap, TxSize, Cipher, KeyID, 0, 0, PLCPLength, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- } >- else >- { >- if (StartOfFrame == TRUE) >- { >- if (RTUSB_GET_PACKET_RTS(skb) != 1) >- RTUSBWriteTxDescriptor(pTxD, MoreFragment, 7, TRUE, FALSE, TRUE, FrameGap, TxSize, Cipher, KeyID, CW_MIN_IN_BITS, CW_MAX_IN_BITS, PLCPLength, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- else >- RTUSBWriteTxDescriptor(pTxD, MoreFragment, 7, TRUE, FALSE, TRUE, FrameGap, TxSize, Cipher, KeyID, 0, 0, PLCPLength, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- } >- else >- RTUSBWriteTxDescriptor(pTxD, MoreFragment, 7, TRUE, FALSE, FALSE, FrameGap, TxSize, Cipher, KeyID, 0, 0, PLCPLength, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- } >- >- TransferBufferLength = TxSize + sizeof(TXD_STRUC); >- if ((TransferBufferLength % 2) == 1)//always bulk out even number of bytes >- TransferBufferLength++; >- if ((TransferBufferLength % pAdapter->BulkOutMaxPacketSize) == 0) >- TransferBufferLength += 2; >- >- pTxContext->BulkOutSize = TransferBufferLength; >- RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_DATA_NORMAL); >- >- // Set frame gap for the rest of fragment burst. >- // It won't matter if there is only one fragment (single fragment frame). >- StartOfFrame = FALSE; >- NumberRequired--; >- if (NumberRequired == 0) >- { >- pTxContext->LastOne = TRUE; >- } >- else >- { >- pTxContext->LastOne = FALSE; >- } >-//steven:use ASIC counters to derive this count instead INC_COUNTER(pAdapter->WlanCounters.TransmittedFragmentCount); >- // >- // Increase BulkOut stanby count. >- // >- atomic_inc(&pAdapter->TxCount); >- } while (NumberRequired > 0); >- >-#if 0 >- // Add duplicate 1mb broadcast frames >- do >- { >- if ((pAdapter->PortCfg.TxRate != RATE_1) && (Bcast_8023 == TRUE) && (SingleFrag == TRUE)) >- { >- PTX_CONTEXT pTmpContext; >- PTXD_STRUC pTmpTxD; >- ULONG DataOffset = 0; >- >- pSrc = pTxContext->TransferBuffer->WirelessPacket; >- // >- // Check the offset of the original 802.3 data packet >- // >- if (CipherSuite == Ndis802_11EncryptionDisabled) >- DataOffset = 0; >- else if (CipherSuite == Ndis802_11Encryption1Enabled) >- DataOffset += 4; //Add IV >- else if (CipherSuite == Ndis802_11Encryption2Enabled) >- DataOffset += 8; //Add EIV >- else if (CipherSuite == Ndis802_11Encryption3Enabled) >- DataOffset += 8; //Add EIV >- >- // Check for DHCP & BOOTP protocol >- if ((*(pSrc + 0x35 + DataOffset) != 0x44) || (*(pSrc + 0x37 + DataOffset) != 0x43)) >- { >- // >- // 2054 (hex 0806) for ARP datagrams >- // if this packet is not ARP datagrams, then do nothing >- // ARP datagrams will also be duplicate at 1mb broadcast frames >- // >- if (Protocol != 0x0806 ) >- break; >- } >- >- // Get the Tx Ring descriptor & Dma Buffer address >- pTmpContext = &pAdapter->TxContext[pAdapter->NextTxIndex]; >- pDest = pTmpContext->TransferBuffer->WirelessPacket; >- >- if (pTmpContext->InUse == TRUE) >- break; //No available Tx Ring for Send 1mb broadcast frames. >- >- // Increase & maintain Tx Ring Index >- pAdapter->NextTxIndex++; >- if (pAdapter->NextTxIndex >= TX_RING_SIZE) >- { >- pAdapter->NextTxIndex = 0; >- } >- >- // >- // Reset LastOne Tx Ring descriptor >- // >- pTmpContext->InUse = TRUE; >- pTmpContext->LastOne = TRUE; >- >- pTmpTxD = &(pTmpContext->TransferBuffer->TxDesc); >- // >- // Duplicate TxD descriptor, and we will reset the its value later. >- // >- memcpy(pTmpTxD, pTxD, sizeof(TXD_STRUC)); >- // Start coping data to new ring >- memcpy(pDest, pSrc, pTxContext->BulkOutSize); >- pTmpContext->BulkOutSize = pTxContext->BulkOutSize; >- RTUSBWriteTxDescriptor(pTmpTxD, FALSE, 7, TRUE, FALSE, FALSE, FrameGap, TxSize, Cipher, KeyID, 0, 0, PLCPLength, RATE_1, 4, pAdapter->PortCfg.TxPreambleInUsed); >- // >- // Increase BulkOut stanby count. >- // >- atomic_inc(&pAdapter->TxCount); >- DBGPRINT(RT_DEBUG_TRACE, "Send 1M broadcast frame!\n"); >- } >- } while (FALSE); >-#endif >- >- // Acknowledge protocol send complete of pending packet. >- RTUSBFreeSkbBuffer(skb); >- return (NDIS_STATUS_SUCCESS); >- >-} >- >-VOID RTUSBRxPacket(unsigned long data) >-//VOID RTUSBRxPacket(purbb_t pUrb) >-{ >- //PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)data; >- purbb_t pUrb = (purbb_t)data; >- PRT2570ADAPTER pAdapter; >- PRX_CONTEXT pRxContext; >- PRXD_STRUC pRxD; >- NDIS_STATUS Status; >- PHEADER_802_11 pHeader; >- PUCHAR pData; >- PUCHAR pDestMac, pSrcMac; >- UCHAR KeyIdx; >- ULONG i; >- UINT PacketSize = 0; >- PUCHAR pEncap; >- UCHAR LLC_Len[2]; >- UCHAR Header802_3[14]; >- PWPA_KEY pWpaKey = NULL; >- // To indicate cipher used for this packet >- NDIS_802_11_ENCRYPTION_STATUS Cipher; >- struct sk_buff *skb; >- PVOID pManage; >- >- pRxContext= (PRX_CONTEXT)pUrb->context; >- pAdapter = pRxContext->pAdapter; >- >- if( RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS) ) >- return; >- >- do >- { >- if (pRxContext->pUrb->actual_length >= (sizeof(RXD_STRUC) + LENGTH_802_11))//blue >- { >- pData = pRxContext->TransferBuffer; >- pManage = (PVOID) pData; >- >- pRxD = (PRXD_STRUC)(pData + pRxContext->pUrb->actual_length - sizeof(RXD_STRUC)); >- pHeader = (PHEADER_802_11)pData; >- >- >- if (pRxD->DataByteCnt < 4) >- Status = NDIS_STATUS_FAILURE; >- else >- { >- pAdapter->PortCfg.Pss = PWR_ACTIVE; >- >- // Increase Total receive byte counter after real data received no mater any error or not >- pAdapter->RalinkCounters.ReceivedByteCount += (pRxD->DataByteCnt - 4); >- >- // Check for all RxD errors >- Status = RTMPCheckRxDescriptor(pAdapter, pRxD); >- } >- >- /* Only recieve valid packets in to monitor mode */ >- if (pAdapter->PortCfg.BssType == BSS_MONITOR && Status == NDIS_STATUS_SUCCESS) >- { >- struct sk_buff *skb; >- if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL) >- { >- skb->dev = pAdapter->net; >- memcpy(skb_put(skb, pRxD->DataByteCnt-4), pData, pRxD->DataByteCnt-4); >- skb->mac.raw = skb->data; >- skb->pkt_type = PACKET_OTHERHOST; >- skb->protocol = htons(ETH_P_802_2); >- skb->ip_summed = CHECKSUM_NONE; >- netif_rx(skb); >- } >- >- if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BULKIN_RESET)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))) >- RTUSBBulkReceive(pAdapter); >- continue; >- } >- >- if (Status == NDIS_STATUS_SUCCESS) >- { >- // Apply packet filtering rule based on microsoft requirements. >- Status = RTMPApplyPacketFilter(pAdapter, pRxD, pHeader); >- } >- >- // Add receive counters >- if (Status == NDIS_STATUS_SUCCESS) >- { >- // Increase 802.11 counters & general receive counters >- INC_COUNTER(pAdapter->WlanCounters.ReceivedFragmentCount); >- } >- else >- { >- // Increase general counters >- pAdapter->Counters.RxErrors++; >- } >- >- >- // Check for retry bit, if this bit is on, search the cache with SA & sequence >- // as index, if matched, discard this frame, otherwise, update cache >- // This check only apply to unicast data & management frames >- if ((pRxD->U2M) && (Status == NDIS_STATUS_SUCCESS) && (pHeader->Controlhead.Frame.Type != BTYPE_CNTL)) >- { >- if (pHeader->Controlhead.Frame.Retry) >- { >- if (RTMPSearchTupleCache(pAdapter, pHeader) == TRUE) >- { >- // Found retry frame in tuple cache, Discard this frame / fragment >- // Increase 802.11 counters >- INC_COUNTER(pAdapter->WlanCounters.FrameDuplicateCount); >- DBGPRINT_RAW(RT_DEBUG_INFO, "duplicate frame\n");//steven:for debug >- Status = NDIS_STATUS_FAILURE; >- } >- else >- { >- RTMPUpdateTupleCache(pAdapter, pHeader); >- } >- } >- else // Update Tuple Cache >- { >- RTMPUpdateTupleCache(pAdapter, pHeader); >- } >- } >- >- // Check and set the cipher variable >- if (pRxD->U2M) >- Cipher = pAdapter->PortCfg.PairCipher; >- else >- Cipher = pAdapter->PortCfg.GroupCipher; >- Cipher = pAdapter->PortCfg.WepStatus; >- >- // >- // Do RxD release operation for all failure frames >- // >- if (Status == NDIS_STATUS_SUCCESS) >- { >- // >- // Start of main loop to parse receiving frames. >- // The sequence will be Type first, then subtype... >- // >- switch (pHeader->Controlhead.Frame.Type) >- { >- // Frame with data type >- case BTYPE_DATA: >- // pData : Pointer skip the first 24 bytes, 802.11 HEADER >- pData += LENGTH_802_11; >- >- PacketSize = pRxD->DataByteCnt - LENGTH_802_11 - 4; //Minus FCS[4]. default for NoneWep. >- // Drop not my BSS frame >- if (INFRA_ON(pAdapter)) >- { >- // Infrastructure mode, check address 2 for BSSID >- if (memcmp(&pHeader->Controlhead.Addr2, &pAdapter->PortCfg.Bssid, 6) != 0) >- break; // Receive frame not my BSSID >- else >- atomic_inc(&(pAdapter->PortCfg.DataPacketsFromAP)); >- } >- else // Ad-Hoc mode or Not associated >- { >- // Ad-Hoc mode, check address 3 for BSSID >- if (memcmp(&pHeader->Addr3, &pAdapter->PortCfg.Bssid, 6) != 0) >- break; // Receive frame not my BSSID >- >- // Drop frame from AP while we are in Ad-hoc mode or not associated >- if (pHeader->Controlhead.Frame.FrDs) >- break; >- } >- >- // Drop Null data frame, or CF with NULL data frame >- if ((pHeader->Controlhead.Frame.Subtype == SUBTYPE_NULL_FUNC) || >- (pHeader->Controlhead.Frame.Subtype == SUBTYPE_CFACK) || >- (pHeader->Controlhead.Frame.Subtype == SUBTYPE_CFPOLL) || >- (pHeader->Controlhead.Frame.Subtype == SUBTYPE_CFACK_CFPOLL)) >- { >- break; >- } >- >- // Process Broadcast & Multicast data frame >- if (pRxD->Bcast || pRxD->Mcast) >- { >- // Multicast 802.11 Counter >- INC_COUNTER(pAdapter->WlanCounters.MulticastReceivedFrameCount); >- DBGPRINT(RT_DEBUG_INFO,"Receiving multicast frame\n"); >- // Drop Mcast / Bcast frame with fragment bit on >- if (pHeader->Controlhead.Frame.MoreFrag) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR,"Receiving multicast frame with fragment bit on\n"); >- break; >- } >- >- // Filter out Bcast frame which AP relayed for us >- if (((memcmp(&pHeader->Addr3, pAdapter->CurrentAddress, 6) == 0)) && pHeader->Controlhead.Frame.FrDs) >- break; >- >- // WEP encrypted frame >- if (pHeader->Controlhead.Frame.Wep) >- { >- // Check our WEP setting, if no WEP turning on, just drop this frame >- if (Cipher == Ndis802_11Encryption1Enabled) // WEP >- { >- if (pRxD->CiErr) >- break; >- else >- { >- pData = pData + 4; //Offset skip IV[4] >- pRxD->DataByteCnt = pRxD->DataByteCnt - 8; //Minus ICV[4] & FCS[4]. >- } >- >- PacketSize = pRxD->DataByteCnt - LENGTH_802_11 - 4; //Minus IV[4]. >- } >- else if (Cipher == Ndis802_11Encryption2Enabled) // TKIP >- { >- if (pRxD->CiErr) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR,"pRxD->CiErr\n"); >- break; >- } >- else >- { >- pData = pData + 8; //Offset skip IV[8] >- // >- // the MIC is stored on the last one no more Fragment. >- // that is only last MPDU only need to check MIC. >- // >- if (pHeader->Controlhead.Frame.MoreFrag == TRUE) >- { >- // No MIC here. >- pRxD->DataByteCnt = pRxD->DataByteCnt - 8; //ICV[4] &FCS[4]. >- } >- else >- { >- if (pHeader->Frag != 0) >- pRxD->DataByteCnt = pRxD->DataByteCnt - 8; //MIC been frag ICV[4] & FCS[4] >- else >- pRxD->DataByteCnt = pRxD->DataByteCnt - 16; //Minus MIC[8] & ICV[4] &FCS[4]. >- } >- } >- >- PacketSize = pRxD->DataByteCnt - LENGTH_802_11 - 8; //Minus IV+EIV[8]. >- } >- else if (Cipher == Ndis802_11Encryption3Enabled) // AES >- { >- if (pRxD->CiErr) >- break; >- else >- { >- pData = pData + 8; //Offset skip RSN[8] >- pRxD->DataByteCnt = pRxD->DataByteCnt - 12; //Minus MIC[8] & ICV[4] >- } >- >- PacketSize = pRxD->DataByteCnt - LENGTH_802_11 - 8; //Minus RSN[8] >- } >- else >- break; >- } >- }//if (pRxD->Bcast || pRxD->Mcast) >- // Begin process unicast to me frame >- else if (pRxD->U2M) >- { >- // >- // Begin frame processing >- // >- // DA is always address 1 >- pDestMac = (PUCHAR) &(pHeader->Controlhead.Addr1); >- // Seclect SA by different mode >- if (INFRA_ON(pAdapter)) // For infrastructure, SA is address 3 >- { >- pSrcMac = (PUCHAR) &(pHeader->Addr3); >- } >- else // For IBSS mode, SA is address 2 >- { >- pSrcMac = (PUCHAR) &(pHeader->Controlhead.Addr2); >- } >- // WEP encrypted frame >- if (Cipher == Ndis802_11Encryption1Enabled) // WEP >- { >- if (pHeader->Controlhead.Frame.Wep) >- { >- if (pRxD->CiErr) >- break; >- else >- { >- pData = pData + 4; //Offset skip IV[4] >- pRxD->DataByteCnt = pRxD->DataByteCnt - 8; //Minus ICV[4] & FCS[4]. >- } >- >- PacketSize = pRxD->DataByteCnt - LENGTH_802_11 - 4; //Minus IV[4]. >- } >- else if ((pAdapter->PortCfg.PrivacyFilter == Ndis802_11PrivFilter8021xWEP) && >- (pHeader->Frag == 0)) >- { >- // Check 802.1x frame, if not drop it. >- if (memcmp(EAPOL, pData + 6, 2) != 0) >- { >- // Not 802.1X frames >- // Add error counter >- break; >- } >- } >- } >- else if (Cipher == Ndis802_11Encryption2Enabled) // TKIP >- { >- if (pHeader->Controlhead.Frame.Wep) >- { >- if (pRxD->CiErr) >- { >- DBGPRINT(RT_DEBUG_TEMP,"pRxD->CiErr\n"); >- break; >- >- >- } >- else >- { >- pData = pData + 8; //Offset skip IV[8] >- // >- // the MIC is stored on the last one no more Fragment. >- // that is only last MPDU only need to check MIC. >- // >- if (pHeader->Controlhead.Frame.MoreFrag == TRUE) >- { >- //No MIC here. >- pRxD->DataByteCnt = pRxD->DataByteCnt - 8; //ICV[4] &FCS[4]. >- } >- else >- { >- if (pHeader->Frag != 0) >- pRxD->DataByteCnt = pRxD->DataByteCnt - 8; //MIC been frag ICV[4] & FCS[4] >- else >- pRxD->DataByteCnt = pRxD->DataByteCnt - 16; //Minus MIC[8] & ICV[4] & FCS[4]. >- } >- } >- >- PacketSize = pRxD->DataByteCnt - LENGTH_802_11 - 8; //Minus IV+EIV[8]. >- } >- else if ((pAdapter->PortCfg.PrivacyFilter == Ndis802_11PrivFilter8021xWEP) && >- (pHeader->Frag == 0)) >- { >- // Check 802.1x frame, if not drop it. >- if (memcmp(EAPOL, pData + 6, 2) != 0) >- { >- DBGPRINT(RT_DEBUG_TEMP,"Not 802.1X frames\n"); >- // Not 802.1X frames >- // Add error counter >- break; >- } >- DBGPRINT(RT_DEBUG_TEMP," 802.1X EAPOL frames\n"); >- } >- } >- else if (Cipher == Ndis802_11Encryption3Enabled) // AES >- { >- if (pHeader->Controlhead.Frame.Wep) >- { >- if (pRxD->CiErr) >- break; >- else >- { >- pData = pData + 8; //Offset skip IV[8] >- pRxD->DataByteCnt = pRxD->DataByteCnt - 12; //Minus MIC[8] & ICV[4] >- } >- >- PacketSize = pRxD->DataByteCnt - LENGTH_802_11 - 8; //Minus RSN[8] >- } >- else if ((pAdapter->PortCfg.PrivacyFilter == Ndis802_11PrivFilter8021xWEP) && >- (pHeader->Frag == 0)) >- { >- // Check 802.1x frame, if not drop it. >- if (memcmp(EAPOL, pData + 6, 2) != 0) >- { >- // Not 802.1X frames >- // Add error counter >- break; >- } >- } >- } >- else if (pHeader->Controlhead.Frame.Wep) >- { >- // Drop WEP frame when PrivacyInvoked is FALSE >- break; >- } >- }//else if (pRxD->U2M) >- >- // The total available payload should exclude 24-byte 802.11 Header >- //packetSize = pRxD->DataByteCnt - LENGTH_802_11 - 4; >- >- // Find the WPA key, either Group or Pairwise Key >- // Although the data has been decrypted by ASIC, >- // driver has to calculate the RxMIC which required the key. >- // The failed case should not happen. If it did, drop it. >- if ((pAdapter->PortCfg.CipherAlg == CIPHER_TKIP) && (pHeader->Controlhead.Frame.Wep)) >- { >- INT idx; >- >- pWpaKey = (PWPA_KEY) NULL; >- // First lookup the DA, if it's a group address, use GROUP key >- if (pRxD->Bcast || pRxD->Mcast) >- { >-#ifdef BIG_ENDIAN >- idx = (pRxD->Iv & 0xc0000000) >> 30; >-#else >- idx = (pRxD->Iv & 0x000000c0) >> 6; >-#endif >- if ((pAdapter->PortCfg.GroupKey[idx].KeyLen != 0) && >- ((INFRA_ON(pAdapter) && ((memcmp(&pHeader->Controlhead.Addr2, &pAdapter->PortCfg.Bssid, 6) == 0))) || >- (ADHOC_ON(pAdapter) && ((memcmp(&pHeader->Addr3, &pAdapter->PortCfg.Bssid, 6) == 0))))) >- { >- pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[idx]; >- pWpaKey->Type = GROUP_KEY; >- DBGPRINT(RT_DEBUG_INFO, "Rx Use Group Key %d\n", idx); >- } >- } >- // Try to find the Pairwise Key >- else >- { >- for (idx = 0; idx < PAIRWISE_KEY_NO; idx++) >- { >- if (((memcmp(&pHeader->Controlhead.Addr2, pAdapter->PortCfg.PairwiseKey[idx].BssId, 6) == 0)) && >- (pAdapter->PortCfg.PairwiseKey[idx].KeyLen != 0)) >- { >- pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.PairwiseKey[idx]; >- pWpaKey->Type = PAIRWISE_KEY; >- DBGPRINT(RT_DEBUG_TEMP, "Rx Use Pairwise Key %d\n",idx); >- break; >- } >- } >- // Use default Group Key if there is no Pairwise key present >- if ((pWpaKey == NULL) && (pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0)) >- { >- pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId]; >- pWpaKey->Type = GROUP_KEY; >- DBGPRINT(RT_DEBUG_INFO, "Rx Use Group Key\n"); >- } >- } >- >- if (pWpaKey == NULL) >- break; >- } >- >- // DA is always address 1 >- pDestMac = (PUCHAR) &(pHeader->Controlhead.Addr1); >- // Seclect SA by different mode >- if (INFRA_ON(pAdapter)) >- { >- // For infrastructure, SA is address 3 >- pSrcMac = (PUCHAR) &(pHeader->Addr3); >- } >- else >- { >- // For IBSS mode, SA is address 2 >- pSrcMac = (PUCHAR) &(pHeader->Controlhead.Addr2); >- } >- >- // Process Broadcast & Multicast data frame >- if (pRxD->Bcast || pRxD->Mcast) >- { >- // Save encapaturation starting pointer >- pEncap = pData; >- >- // For TKIP frame, calculate the MIC value >- if ((pAdapter->PortCfg.CipherAlg == CIPHER_TKIP) && (pHeader->Controlhead.Frame.Wep)) >- { >- i = 0; >- >- if (RTMPTkipCompareMICValue(pAdapter, >- pData, >- pDestMac, >- pSrcMac, >- pWpaKey->RxMic, >- PacketSize) == FALSE) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR,"BroadCast/Multicast Rx MIC Value error\n"); >- RTMPReportMicError(pAdapter, pWpaKey); >- Status = NDIS_STATUS_FAILURE; >- break; >- } >- >- // Second, increase RxTsc value for next transmission >- while (++pWpaKey->RxTsc[i] == 0x0) >- { >- i++; >- if (i == 6) >- break; >- } >- // Rx TSC has done one full cycle, since re-key is done by transmitter >- // We did not do anything for Rx path >- } >- // For WPA2 mixer mode PairCipher = AES, GroupCipher = TKIP >- else if ((pAdapter->PortCfg.PairCipher == Ndis802_11Encryption3Enabled) && >- (pAdapter->PortCfg.GroupCipher == Ndis802_11Encryption2Enabled) && >- (pHeader->Controlhead.Frame.Wep)) >- { >- //Use Software to decript TKIP packet. >- if (RTMPSoftDecryptTKIP(pAdapter, pRxContext->TransferBuffer, pRxD->DataByteCnt + 12, pAdapter->PortCfg.GroupKey)) >- { >- DBGPRINT(RT_DEBUG_INFO, "WPA2::RTMPSoftDecryptTKIP Complete\n"); >- pData = pRxContext->TransferBuffer + LENGTH_802_11; >- PacketSize = pRxD->DataByteCnt - 8 - LENGTH_802_11; //8 bytes MIC, 4 bytes ICV >- pEncap = pData; >- } >- } >- >- // Check for encapsulataion other than RFC1042 & Bridge tunnel >- if ((memcmp(SNAP_802_1H, pEncap, 6) != 0) && (memcmp(SNAP_BRIDGE_TUNNEL, pEncap, 6) != 0)) >- { >- LLC_Len[0] = PacketSize / 256; >- LLC_Len[1] = PacketSize % 256; >- MAKE_802_3_HEADER(Header802_3, pDestMac, pSrcMac, ((PUCHAR) LLC_Len)); >- } >- else >- { >- // Remove 802.11 H header & reconstruct 802.3 header >- pData += (LENGTH_802_1_H - LENGTH_802_3_TYPE); >- // Patch for WHQl only, which did not turn on Netbios but use IPX within its payload >- if (((memcmp(IPX, pData, 2) == 0) || (memcmp(APPLE_TALK, pData, 2) == 0)) && (memcmp(SNAP_802_1H, pEncap, 6) == 0)) >- { >- LLC_Len[0] = PacketSize / 256; >- LLC_Len[1] = PacketSize % 256; >- pData = pData - LENGTH_802_1_H; >- MAKE_802_3_HEADER(Header802_3, pDestMac, pSrcMac, ((PUCHAR) LLC_Len)); >- } >- else >- { >- MAKE_802_3_HEADER(Header802_3, pDestMac, pSrcMac, pData); >- // The total available payload should exclude 24-byte 802.11 Header >- // and 8-byte 802.2 LLC >- PacketSize -= LENGTH_802_1_H; >- } >- >- // Point to read 802.3 payload >- pData += LENGTH_802_3_TYPE; >- } >- >- // For miniportTransferData >- pAdapter->pRxData = pData; >- >- pAdapter->PortCfg.LedCntl.fRxActivity = TRUE; // for RX ACTIVITY LED >- >- // Acknolwdge upper layer the received frame >- // Copy header to head of data for compatibility with older protocol >- // eariler than W2K >- //memcpy(pData - LENGTH_802_3, Header802_3, LENGTH_802_3); >- // Acknowledge upper layer the received frame >- if ((skb = dev_alloc_skb(PacketSize + LENGTH_802_3 + 2)) != NULL) >- { >- skb->dev = pAdapter->net; >- skb_reserve(skb, 2); // 16 byte align the IP header >- memcpy(skb_put(skb, LENGTH_802_3), Header802_3, LENGTH_802_3); >- memcpy(skb_put(skb, PacketSize), pData, PacketSize); >- skb->protocol = eth_type_trans(skb, pAdapter->net); >- netif_rx(skb); >- pAdapter->net->last_rx = jiffies; >- pAdapter->netstats.rx_packets++; >- } >- //memset(Header802_3, 0, LENGTH_802_3); >- DBGPRINT_RAW(RT_DEBUG_INFO, "!!! Broadcast Ethenet rx Indicated !!!\n"); >- } //if (pRxD->Bcast || pRxD->Mcast) >- // Begin process unicast to me frame >- else if (pRxD->U2M) >- { >- // Update Rx data rate first. >- if (pRxD->Ofdm == 1) >- { >- for (i = 4; i < 12; i++) >- { >- if (pRxD->BBR0 == PlcpSignal[i]) >- break; >- } >- if (i < 12) >- pAdapter->LastRxRate = i; >- } >- else // receive CCK encoding >- { >- if (pRxD->BBR0 == 10) >- pAdapter->LastRxRate = 0; >- else if (pRxD->BBR0 == 20) >- pAdapter->LastRxRate = 1; >- else if (pRxD->BBR0 == 55) >- pAdapter->LastRxRate = 2; >- else if (pRxD->BBR0 == 110) >- pAdapter->LastRxRate = 3; >- } >- >- // Send PS-Poll for AP to send next data frame >- if ((pHeader->Controlhead.Frame.MoreData) && INFRA_ON(pAdapter) && (pAdapter->PortCfg.Psm == PWR_SAVE)) >- { >- //Send PS-Poll frame >- EnqueuePsPoll(pAdapter); >- DBGPRINT(RT_DEBUG_TRACE, "Sending PS-POLL\n"); >- } >- >- // >- // Begin frame processing >- // >- if (pHeader->Frag == 0) // First or Only fragment >- { >- // For TKIP frame, calculate the MIC value >- if (pHeader->Controlhead.Frame.MoreFrag == FALSE) >- { >- if ((pAdapter->PortCfg.CipherAlg == CIPHER_TKIP) && (pHeader->Controlhead.Frame.Wep)) >- { >- // >- // Use Software to descrypt if transmition keyID not 0 on ADHOC mode. >- // Since ASIC allows hardware descrypt only KeyID=0 as their pairwisekey. >- // >- // Check U2M and KeyID not pairwise key, used Software decypt >- // >- KeyIdx= *((PUCHAR)(pRxContext->TransferBuffer + LENGTH_802_11 + 3)); >- KeyIdx = KeyIdx >> 6; >- >- if(KeyIdx != 0) >- { >- //Use Software to decript TKIP packet. >- if (RTMPSoftDecryptTKIP(pAdapter, pRxContext->TransferBuffer, pRxD->DataByteCnt + 12, pAdapter->PortCfg.GroupKey)) >- { >- DBGPRINT(RT_DEBUG_TEMP, "U2M Use Groupkey RTMPSoftDecryptTKIP Complete\n"); >- pData = pRxContext->TransferBuffer + LENGTH_802_11; >- PacketSize = pRxD->DataByteCnt - 8 - LENGTH_802_11; //8 bytes MIC, 4 bytes ICV >- } >- else >- { >- DBGPRINT(RT_DEBUG_TEMP, "RTMPSoftDecryptTKIP failed\n"); >- break; >- } >- } >- else >- { >- if (RTMPTkipCompareMICValue(pAdapter, >- pData, >- pDestMac, >- pSrcMac, >- pWpaKey->RxMic,//steven:where is this from in RT2570 >- PacketSize) == FALSE) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR,"U2M Rx MIC Value error1\n"); >- RTMPReportMicError(pAdapter, pWpaKey); >- Status = NDIS_STATUS_FAILURE; >- break; >- } >- } >- >- // TODO: >- // Getting RxTSC from Rx descriptor >- } >- } >- >- // Save encapaturation starting pointer >- pEncap = pData; >- pAdapter->FragFrame.Flags &= 0xFFFFFFFE; >- >- // Check for encapsulataion other than RFC1042 & Bridge tunnel >- if ((memcmp(SNAP_802_1H, pEncap, 6) != 0) && (memcmp(SNAP_BRIDGE_TUNNEL, pEncap, 6) != 0)) >- { >- LLC_Len[0] = PacketSize / 256; >- LLC_Len[1] = PacketSize % 256; >- MAKE_802_3_HEADER(Header802_3, pDestMac, pSrcMac, ((PUCHAR) LLC_Len)); >- } >- else >- { >- // Remove 802.11 H header & reconstruct 802.3 header >- pData += (LENGTH_802_1_H - LENGTH_802_3_TYPE); >- if ((memcmp(EAPOL, pData, 2) == 0)) >- { >- PacketSize += LENGTH_802_11; >- DBGPRINT_RAW(RT_DEBUG_TEMP, "indicated packet EAPOL PacketSize%d\n", PacketSize);//steven:for debug >- // Enqueue this frame to MLME engine >- MlmeEnqueueForRecv( >- pAdapter, >- &pAdapter->Mlme.Queue, >- (UCHAR)pRxD->BBR1, >- PacketSize + LENGTH_802_1_H, >- pManage); >- break; >- } >- // Patch for WHQl only, which did not turn on Netbios but use IPX within its payload >- if ((((memcmp(IPX, pData, 2) != 0) || (memcmp(APPLE_TALK, pData, 2) != 0)) && memcmp(SNAP_802_1H, pEncap, 6) == 0)) >- { >- LLC_Len[0] = PacketSize / 256; >- LLC_Len[1] = PacketSize % 256; >- pData = pData - LENGTH_802_1_H; >- MAKE_802_3_HEADER(Header802_3, pDestMac, pSrcMac, ((PUCHAR) LLC_Len)); >- } >- else >- { >- >- MAKE_802_3_HEADER(Header802_3, pDestMac, pSrcMac, pData); >- // The total available payload should exclude 24-byte 802.11 Header >- // and 8-byte 802.2 LLC >- PacketSize -= LENGTH_802_1_H; >- memcpy(pAdapter->FragFrame.Header_LLC, pEncap, 8); >- pAdapter->FragFrame.Flags |= 0x01; >- } >- >- // Point to read 802.3 payload >- pData += LENGTH_802_3_TYPE; >- } >- >- // One & The only fragment >- if (pHeader->Controlhead.Frame.MoreFrag == FALSE) >- { >- // For miniportTransferData >- pAdapter->pRxData = pData; >- >- pAdapter->PortCfg.LedCntl.fRxActivity = TRUE; // for RX ACTIVITY LED >- >- DBGPRINT_RAW(RT_DEBUG_INFO, "indicated packet size = %d\n", PacketSize);//steven:for debug >- // Acknolwdge upper layer the received frame >- //memcpy((PUCHAR) pData - LENGTH_802_3, Header802_3, LENGTH_802_3); >- >- if ((skb = dev_alloc_skb(PacketSize + LENGTH_802_3 + 2)) != NULL) >- { >- skb->dev = pAdapter->net; >- skb_reserve(skb, 2); // 16 byte align the IP header >- memcpy(skb_put(skb, LENGTH_802_3), Header802_3, LENGTH_802_3); >- memcpy(skb_put(skb, PacketSize), pData, PacketSize); >- skb->protocol = eth_type_trans(skb, pAdapter->net); >- netif_rx(skb); >- pAdapter->net->last_rx = jiffies; >- pAdapter->netstats.rx_packets++; >- } >- // Increase general counters >- pAdapter->Counters.GoodReceives++; >- >- DBGPRINT_RAW(RT_DEBUG_INFO, "!!! Frame without Fragment Indicated !!!\n"); >- } >- // First fragment of fragmented frames >- else >- { >- memcpy(pAdapter->FragFrame.Buffer, pData, PacketSize); >- memcpy(pAdapter->FragFrame.Header802_3, Header802_3, LENGTH_802_3); >- pAdapter->FragFrame.RxSize = PacketSize; >- pAdapter->FragFrame.Sequence = pHeader->Sequence; >- pAdapter->FragFrame.LastFrag = pHeader->Frag; // Should be 0 >- } >- } >- // Middle & End of fragment burst fragments >- else >- { >- // No LLC-SNAP header in except the first fragment frame >- >- if ((pHeader->Sequence != pAdapter->FragFrame.Sequence) || >- (pHeader->Frag != (pAdapter->FragFrame.LastFrag + 1))) >- { >- // Fragment is not the same sequence or out of fragment number order >- // Clear Fragment frame contents >- memset(&pAdapter->FragFrame, 0, sizeof(FRAGMENT_FRAME)); >- Status = NDIS_STATUS_FAILURE; >- break; >- } >- else if ((pAdapter->FragFrame.RxSize + PacketSize) > MAX_FRAME_SIZE) >- { >- // Fragment frame is too large, it exeeds the maximum frame size. >- // We have to drop it. >- // Clear Fragment frame contents >- memset(&pAdapter->FragFrame, 0, sizeof(FRAGMENT_FRAME)); >- Status = NDIS_STATUS_FAILURE; >- break; >- } >- >- memcpy(&pAdapter->FragFrame.Buffer[pAdapter->FragFrame.RxSize], pData, PacketSize); >- pAdapter->FragFrame.RxSize += PacketSize; >- pData += PacketSize; >- pAdapter->FragFrame.LastFrag = pHeader->Frag; // Update fragment number >- >- // Last fragment >- if (pHeader->Controlhead.Frame.MoreFrag == FALSE) >- { >- // For miniportTransferData >- pAdapter->pRxData = pAdapter->FragFrame.Buffer; >- >- pAdapter->PortCfg.LedCntl.fRxActivity = TRUE; // for RX ACTIVITY LED >- >- // For TKIP frame, calculate the MIC value >- if ((pAdapter->PortCfg.CipherAlg == CIPHER_TKIP) && (pHeader->Controlhead.Frame.Wep)) >- { >- if (pWpaKey == NULL) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR,"No matched TKIP in decryption done calculate MIC routine!!!\n"); >- Status = NDIS_STATUS_FAILURE; >- break; >- } >- >- // >- // For the last fragment, we also need to copy the MIC >- // to the end of pAdapter->FragFrame.Buffer >- // for RTMPTkipCompareMICValueWithLLC used. >- // >- pAdapter->FragFrame.RxSize -= 8; //We need to Minus MIC[8] on Fragment case. >- >- if (pAdapter->FragFrame.Flags & 0x00000001) >- { >- if (RTMPTkipCompareMICValueWithLLC(pAdapter, >- pAdapter->FragFrame.Header_LLC, >- pAdapter->FragFrame.Buffer, >- pDestMac, >- pSrcMac, >- pWpaKey->RxMic, >- pAdapter->FragFrame.RxSize) == FALSE) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR,"Rx MIC Value error 2\n"); >- RTMPReportMicError(pAdapter, pWpaKey); >- Status = NDIS_STATUS_FAILURE; >- break; >- } >- } >- else >- { >- if (RTMPTkipCompareMICValue(pAdapter, >- pAdapter->FragFrame.Buffer, >- pDestMac, >- pSrcMac, >- pWpaKey->RxMic, >- pAdapter->FragFrame.RxSize) == FALSE) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR,"Rx MIC Value error 2\n"); >- RTMPReportMicError(pAdapter, pWpaKey); >- Status = NDIS_STATUS_FAILURE; >- break; >- } >- } >- } >- >- // Acknolwdge upper layer the received frame >- if ((skb = dev_alloc_skb(pAdapter->FragFrame.RxSize + LENGTH_802_3 + 2)) != NULL) >- { >- >- skb->dev = pAdapter->net; >- skb_reserve(skb, 2); /* 16 byte align the IP header */ >- memcpy(skb_put(skb, LENGTH_802_3), (PVOID) pAdapter->FragFrame.Header802_3, LENGTH_802_3); >- memcpy(skb_put(skb, pAdapter->FragFrame.RxSize), (PVOID) &pAdapter->FragFrame.Buffer[0], pAdapter->FragFrame.RxSize); >- skb->protocol = eth_type_trans(skb, pAdapter->net); >- netif_rx(skb); >- pAdapter->net->last_rx = jiffies; >- pAdapter->netstats.rx_packets++; >- } >- // Increase general counters >- pAdapter->Counters.GoodReceives++; >- >- // Clear Fragment frame contents >- //memset(&pAdapter->FragFrame, 0, sizeof(FRAGMENT_FRAME)); >- DBGPRINT_RAW(RT_DEBUG_INFO, "!!! Frame with Fragment Indicated !!!\n"); >- } //Last fragment //if (pHeader->Controlhead.Frame.MoreFrag == FALSE) >- } //Middle & End of fragment burst fragments >- }//else if (pRxD->U2M) >- break; >- >- case BTYPE_MGMT: >- // Enqueue this frame to MLME engine >- MlmeEnqueueForRecv(pAdapter, >- &pAdapter->Mlme.Queue, >- (UCHAR)pRxD->BBR1, >- pRxD->DataByteCnt - 4, >- pData); >- break; >- >- case BTYPE_CNTL: >- // Ignore ??? >- break; >- >- default : >- break; >- }//switch (pHeader->Controlhead.Frame.Type) >- pAdapter->RalinkCounters.RxCount ++; >- >- } >- else if (Status == NDIS_STATUS_RESET) >- { >- RTUSBEnqueueInternalCmd(pAdapter, RT_OID_USB_RESET_BULK_IN); >- return; >- } >- } >- >- pRxContext->InUse = FALSE; >- >- if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BULKIN_RESET)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && >- (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))) >- RTUSBBulkReceive(pAdapter); >- }while(0); >- >- >-} >-/* >- ======================================================================== >- >- Routine Description: >- >- Arguments: >- >- Return Value: >- >- IRQL = >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTUSBDequeueMLMEPacket( >- IN PRT2570ADAPTER pAdapter) >-{ >- PMGMT_STRUC pMgmt; >- >- DBGPRINT(RT_DEBUG_INFO, "RTUSBDequeueMLMEPacket\n"); >- NdisAcquireSpinLock(&pAdapter->MLMEWaitQueueLock); >- while ((pAdapter->PopMgmtIndex != pAdapter->PushMgmtIndex) || (atomic_read(&pAdapter->MgmtQueueSize) > 0)) >- { >- pMgmt = &pAdapter->MgmtRing[pAdapter->PopMgmtIndex]; >- >- if (RTUSBFreeDescriptorRequest(pAdapter, PRIO_RING, 1) == NDIS_STATUS_SUCCESS) >- { >- atomic_dec(&pAdapter->MgmtQueueSize); >- pAdapter->PopMgmtIndex = (pAdapter->PopMgmtIndex + 1) % MGMT_RING_SIZE; >- NdisReleaseSpinLock(&pAdapter->MLMEWaitQueueLock); >- >- RTUSBMlmeHardTransmit(pAdapter, pMgmt); >- >- MlmeFreeMemory(pAdapter, pMgmt->pBuffer); >- pMgmt->pBuffer = NULL; >- pMgmt->Valid = FALSE; >- >- NdisAcquireSpinLock(&pAdapter->MLMEWaitQueueLock); >- } >- else >- { >- DBGPRINT(RT_DEBUG_TRACE, "RTUSBDequeueMLMEPacket::PrioRingFirstIndex = %d, PrioRingTxCnt = %d, PopMgmtIndex = %d, PushMgmtIndex = %d, NextMLMEIndex = %d\n", >- pAdapter->PrioRingFirstIndex, pAdapter->PrioRingTxCnt, >- pAdapter->PopMgmtIndex, pAdapter->PushMgmtIndex, pAdapter->NextMLMEIndex); >- break; >- } >- } >- NdisReleaseSpinLock(&pAdapter->MLMEWaitQueueLock); >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- >- Arguments: >- >- Return Value: >- >- IRQL = >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTUSBCleanUpMLMEWaitQueue( >- IN PRT2570ADAPTER pAdapter) >-{ >- PMGMT_STRUC pMgmt; >- >- DBGPRINT(RT_DEBUG_TRACE, "--->CleanUpMLMEWaitQueue\n"); >- >- NdisAcquireSpinLock(&pAdapter->MLMEWaitQueueLock); >- while (pAdapter->PopMgmtIndex != pAdapter->PushMgmtIndex) >- { >- pMgmt = (PMGMT_STRUC)&pAdapter->MgmtRing[pAdapter->PopMgmtIndex]; >- MlmeFreeMemory(pAdapter, pMgmt->pBuffer); >- pMgmt->pBuffer = NULL; >- pMgmt->Valid = FALSE; >- atomic_dec(&pAdapter->MgmtQueueSize); >- >- pAdapter->PopMgmtIndex++; >- if (pAdapter->PopMgmtIndex >= MGMT_RING_SIZE) >- { >- pAdapter->PopMgmtIndex = 0; >- } >- } >- NdisReleaseSpinLock(&pAdapter->MLMEWaitQueueLock); >- >- DBGPRINT(RT_DEBUG_TRACE, "<---CleanUpMLMEWaitQueue\n"); >-} >- >- >-/* >- ======================================================================== >- >- Routine Description: >- API for MLME to transmit management frame to AP (BSS Mode) >- or station (IBSS Mode) >- >- Arguments: >- pAdapter Pointer to our adapter >- Buffer Pointer to memory of outgoing frame >- Length Size of outgoing management frame >- >- Return Value: >- NDIS_STATUS_FAILURE >- NDIS_STATUS_PENDING >- NDIS_STATUS_SUCCESS >- >- Note: >- >- ======================================================================== >-*/ >-VOID MiniportMMRequest( >- IN PRT2570ADAPTER pAdapter, >- IN PVOID pBuffer, >- IN ULONG Length) >-{ >- >- if (pBuffer) >- { >- PMGMT_STRUC pMgmt; >- >- // Check management ring free avaliability >- NdisAcquireSpinLock(&pAdapter->MLMEWaitQueueLock); >- pMgmt = (PMGMT_STRUC)&pAdapter->MgmtRing[pAdapter->PushMgmtIndex]; >- // This management cell has been occupied >- if (pMgmt->Valid == TRUE) >- { >- NdisReleaseSpinLock(&pAdapter->MLMEWaitQueueLock); >- MlmeFreeMemory(pAdapter, pBuffer); >- pAdapter->RalinkCounters.MgmtRingFullCount++; >- DBGPRINT_RAW(RT_DEBUG_WARN, "MiniportMMRequest (error:: MgmtRing full)\n"); >- } >- // Insert this request into software managemnet ring >- else >- { >- pMgmt->pBuffer = pBuffer; >- pMgmt->Length = Length; >- pMgmt->Valid = TRUE; >- pAdapter->PushMgmtIndex++; >- atomic_inc(&pAdapter->MgmtQueueSize); >- if (pAdapter->PushMgmtIndex >= MGMT_RING_SIZE) >- { >- pAdapter->PushMgmtIndex = 0; >- } >- NdisReleaseSpinLock(&pAdapter->MLMEWaitQueueLock); >- } >- } >- else >- DBGPRINT(RT_DEBUG_WARN, "MiniportMMRequest (error:: NULL msg)\n"); >- >- RTUSBDequeueMLMEPacket(pAdapter); >- >- // If pAdapter->PrioRingTxCnt is larger than 0, this means that prio_ring have something to transmit. >- // Then call KickBulkOut to transmit it >- if (pAdapter->PrioRingTxCnt > 0) >- { >- DBGPRINT(RT_DEBUG_INFO, "MiniportMMRequest::PrioRingFirstIndex = %d, PrioRingTxCnt = %d, PopMgmtIndex = %d, PushMgmtIndex = %d, NextMLMEIndex = %d\n", >- pAdapter->PrioRingFirstIndex, pAdapter->PrioRingTxCnt, >- pAdapter->PopMgmtIndex, pAdapter->PushMgmtIndex, pAdapter->NextMLMEIndex); >- >- AsicForceWakeup(pAdapter); >- RTUSBKickBulkOut(pAdapter); >- } >- >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Search tuple cache for receive duplicate frame from unicast frames. >- >- Arguments: >- pAdapter Pointer to our adapter >- pHeader 802.11 header of receiving frame >- >- Return Value: >- TRUE found matched tuple cache >- FALSE no matched found >- >- Note: >- >- ======================================================================== >-*/ >-BOOLEAN RTMPSearchTupleCache( >- IN PRT2570ADAPTER pAdapter, >- IN PHEADER_802_11 pHeader) >-{ >- INT Index; >- >- for (Index = 0; Index < MAX_CLIENT; Index++) >- { >- if (pAdapter->TupleCache[Index].Valid == FALSE) >- continue; >- >- if ((memcmp(&pAdapter->TupleCache[Index].MAC, &pHeader->Controlhead.Addr2, 6)== 0) && >- (pAdapter->TupleCache[Index].Sequence == pHeader->Sequence) && >- (pAdapter->TupleCache[Index].Frag == pHeader->Frag)) >- { >- return (TRUE); >- } >- } >- return (FALSE); >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Update tuple cache for new received unicast frames. >- >- Arguments: >- pAdapter Pointer to our adapter >- pHeader 802.11 header of receiving frame >- >- Return Value: >- None >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTMPUpdateTupleCache( >- IN PRT2570ADAPTER pAdapter, >- IN PHEADER_802_11 pHeader) >-{ >- UCHAR Index; >- >- for (Index = 0; Index < MAX_CLIENT; Index++) >- { >- if (pAdapter->TupleCache[Index].Valid == FALSE) >- { >- // Add new entry >- memcpy(&pAdapter->TupleCache[Index].MAC, &pHeader->Controlhead.Addr2, 6); >- pAdapter->TupleCache[Index].Sequence = pHeader->Sequence; >- pAdapter->TupleCache[Index].Frag = pHeader->Frag; >- pAdapter->TupleCache[Index].Valid = TRUE; >- pAdapter->TupleCacheLastUpdateIndex = Index; >- DBGPRINT(RT_DEBUG_INFO,"DUPCHECK - Add Entry %d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", >- Index, pAdapter->TupleCache[Index].MAC.Octet[0], pAdapter->TupleCache[Index].MAC.Octet[1], >- pAdapter->TupleCache[Index].MAC.Octet[2], pAdapter->TupleCache[Index].MAC.Octet[3], >- pAdapter->TupleCache[Index].MAC.Octet[4], pAdapter->TupleCache[Index].MAC.Octet[5]); >- return; >- } >- else if ((memcmp(&pAdapter->TupleCache[Index].MAC, &pHeader->Controlhead.Addr2, 6)== 0)) >- { >- // Update old entry >- pAdapter->TupleCache[Index].Sequence = pHeader->Sequence; >- pAdapter->TupleCache[Index].Frag = pHeader->Frag; >- return; >- } >- } >- >- // tuple cache full, replace the first inserted one (even though it may not be >- // least referenced one) >- if (Index == MAX_CLIENT) >- { >- pAdapter->TupleCacheLastUpdateIndex ++; >- if (pAdapter->TupleCacheLastUpdateIndex >= MAX_CLIENT) >- pAdapter->TupleCacheLastUpdateIndex = 0; >- Index = pAdapter->TupleCacheLastUpdateIndex; >- >- // replace with new entry >- memcpy(&pAdapter->TupleCache[Index].MAC, &pHeader->Controlhead.Addr2, 6); >- pAdapter->TupleCache[Index].Sequence = pHeader->Sequence; >- pAdapter->TupleCache[Index].Frag = pHeader->Frag; >- pAdapter->TupleCache[Index].Valid = TRUE; >- DBGPRINT(RT_DEBUG_INFO,"DUPCHECK - replace Entry %d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", >- Index, pAdapter->TupleCache[Index].MAC.Octet[0], pAdapter->TupleCache[Index].MAC.Octet[1], >- pAdapter->TupleCache[Index].MAC.Octet[2], pAdapter->TupleCache[Index].MAC.Octet[3], >- pAdapter->TupleCache[Index].MAC.Octet[4], pAdapter->TupleCache[Index].MAC.Octet[5]); >- } >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Apply packet filter policy, return NDIS_STATUS_FAILURE if this frame >- should be dropped. >- >- Arguments: >- pAdapter Pointer to our adapter >- pRxD Pointer to the Rx descriptor >- pHeader Pointer to the 802.11 frame header >- >- Return Value: >- NDIS_STATUS_SUCCESS Accept frame >- NDIS_STATUS_FAILURE Drop Frame >- >- Note: >- Maganement frame should bypass this filtering rule. >- >- ======================================================================== >-*/ >-NDIS_STATUS RTMPApplyPacketFilter( >- IN PRT2570ADAPTER pAdapter, >- IN PRXD_STRUC pRxD, >- IN PHEADER_802_11 pHeader) >-{ >- UCHAR i; >- >- // 0. Management frame should bypass all these filtering rules. >- if (pHeader->Controlhead.Frame.Type == BTYPE_MGMT) >- { >- if ((pRxD->U2M) || (pRxD->Bcast) || (pRxD->Mcast))//steven:for ASIC Bug Workaround >- return(NDIS_STATUS_SUCCESS); >- } >- >- // 0.1 Drop all Rx frames if MIC countermeasures kicks in >- if (pAdapter->PortCfg.MicErrCnt >= 2) >- { >- return(NDIS_STATUS_FAILURE); >- } >- >- // 1. Drop unicast to me packet if NDIS_PACKET_TYPE_DIRECTED is FALSE >- if (pRxD->U2M) >- { >- if (pAdapter->bAcceptDirect == FALSE) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "unicast not accepted\n");//steven:for debug >- return(NDIS_STATUS_FAILURE); >- } >- } >- >- // 2. Drop broadcast packet if NDIS_PACKET_TYPE_BROADCAST is FALSE >- else if (pRxD->Bcast) >- { >- if (pAdapter->bAcceptBroadcast == FALSE) >- { >- DBGPRINT(RT_DEBUG_INFO, "broadcast not accepted\n");//steven:for debug >- return(NDIS_STATUS_FAILURE); >- } >- } >- >- // 3. Drop multicast packet if NDIS_PACKET_TYPE_ALL_MULTICAST is false >- // and NDIS_PACKET_TYPE_MULTICAST is false. >- // If NDIS_PACKET_TYPE_MULTICAST is true, but NDIS_PACKET_TYPE_ALL_MULTICAST is false. >- // We have to deal with multicast table lookup & drop not matched packets. >- else if (pRxD->Mcast) >- { >- if (pAdapter->bAcceptAllMulticast == FALSE) >- { >- if (pAdapter->bAcceptMulticast == FALSE) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO, "multicast not accepted\n");//steven:for debug >- return(NDIS_STATUS_FAILURE); >- } >- else >- { >- // Selected accept multicast packet based on multicast table >- for (i = 0; i < pAdapter->NumberOfMcAddresses; i++) >- { >- if ((memcmp(&pHeader->Controlhead.Addr1, pAdapter->McastTable[i], ETH_LENGTH_OF_ADDRESS)== 0)) >- { >- break; // Matched >- } >- } >- >- // Not matched >- if (i == pAdapter->NumberOfMcAddresses) >- { >- DBGPRINT(RT_DEBUG_INFO,"Drop multicast %02x:%02x:%02x:%02x:%02x:%02x\n", >- pHeader->Controlhead.Addr1.Octet[0], pHeader->Controlhead.Addr1.Octet[1], >- pHeader->Controlhead.Addr1.Octet[2], pHeader->Controlhead.Addr1.Octet[3], >- pHeader->Controlhead.Addr1.Octet[4], pHeader->Controlhead.Addr1.Octet[5]); >- DBGPRINT(RT_DEBUG_LOUD, "multicast not matched\n"); >- return(NDIS_STATUS_FAILURE); >- } >- else >- { >- DBGPRINT(RT_DEBUG_INFO,"Accept multicast %02x:%02x:%02x:%02x:%02x:%02x\n", >- pHeader->Controlhead.Addr1.Octet[0], pHeader->Controlhead.Addr1.Octet[1], >- pHeader->Controlhead.Addr1.Octet[2], pHeader->Controlhead.Addr1.Octet[3], >- pHeader->Controlhead.Addr1.Octet[4], pHeader->Controlhead.Addr1.Octet[5]); >- } >- } >- } >- } >- >- // 4. Not U2M, not Mcast, not Bcast, must be unicast to other DA. >- // Since we did not implement promiscuous mode, just drop this kind of packet for now. >- else >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "not-to-me unicast\n");//steven:for debug >- return(NDIS_STATUS_FAILURE); >- } >- >- return(NDIS_STATUS_SUCCESS); >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Check Rx descriptor, return NDIS_STATUS_FAILURE if any error dound >- >- Arguments: >- pRxD Pointer to the Rx descriptor >- >- Return Value: >- NDIS_STATUS_SUCCESS No err >- NDIS_STATUS_FAILURE Error >- >- Note: >- >- ======================================================================== >-*/ >-NDIS_STATUS RTMPCheckRxDescriptor( >- IN PRT2570ADAPTER pAdapter, >- IN PRXD_STRUC pRxD) >-{ >- // Phy errors >- if (pRxD->PhyErr) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR, "pRxD->PhyErr 0x%x, 0x%x, 0x%x, 0x%x\n", *(ULONG*)pRxD, *((ULONG*)pRxD+1), *((ULONG*)pRxD+2), *((ULONG*)pRxD+3)); >- return(NDIS_STATUS_FAILURE); >- } >- >- // CRC errors >- if (pRxD->Crc) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR, "pRxD->Crc\n"); >- return(NDIS_STATUS_FAILURE); >- } >- >- // Paul 04-03 for OFDM Rx length issue >- if (pRxD->DataByteCnt > 1604) >- { >- DBGPRINT_RAW(RT_DEBUG_ERROR, "received too long, DataByteCnt = %d\n", pRxD->DataByteCnt); >- return NDIS_STATUS_RESET; >- } >- >- return(NDIS_STATUS_SUCCESS); >-} >- >-/* >- ======================================================================== >- >- Routine Description: >- Process MIC error indication and record MIC error timer. >- >- Arguments: >- pAdapter Pointer to our adapter >- pWpaKey Pointer to the WPA key structure >- >- Return Value: >- None >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTMPReportMicError( >- IN PRT2570ADAPTER pAdapter, >- IN PWPA_KEY pWpaKey) >-{ >- ULONG Now; >- struct >- { >- NDIS_802_11_STATUS_INDICATION Status; >- NDIS_802_11_AUTHENTICATION_REQUEST Request; >- } Report; >- >- // 0. Set Status to indicate auth error >- Report.Status.StatusType = Ndis802_11StatusType_Authentication; >- >- // 1. Check for Group or Pairwise MIC error >- if (pWpaKey->Type == PAIRWISE_KEY) >- Report.Request.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR; >- else >- Report.Request.Flags = NDIS_802_11_AUTH_REQUEST_GROUP_ERROR; >- >- // 2. Copy AP MAC address >- memcpy(Report.Request.Bssid, pWpaKey->BssId, 6); >- >- // 3. Calculate length >- Report.Request.Length = sizeof(NDIS_802_11_AUTHENTICATION_REQUEST); >- >- // 4. Indicate to NDIS >- NdisMIndicateStatus(pAdapter->AdapterHandle, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, (PVOID) &Report, sizeof(Report)); >- NdisMIndicateStatusComplete(pAdapter->AdapterHandle); >- >- // 5. Record Last MIC error time and count >- Now = jiffies; >- if (pAdapter->PortCfg.MicErrCnt == 0) >- { >- pAdapter->PortCfg.MicErrCnt++; >- pAdapter->PortCfg.LastMicErrorTime = Now; >- } >- else if (pAdapter->PortCfg.MicErrCnt == 1) >- { >- if ((pAdapter->PortCfg.LastMicErrorTime + (60 * 1000)) < Now) >- { >- // Update Last MIC error time, this did not violate two MIC errors within 60 seconds >- pAdapter->PortCfg.LastMicErrorTime = Now; >- } >- else >- { >- pAdapter->PortCfg.LastMicErrorTime = Now; >- // Violate MIC error counts, MIC countermeasures kicks in >- pAdapter->PortCfg.MicErrCnt++; >- // We shall block all reception >- // We shall clean all Tx ring and disassoicate from AP after next EAPOL frame >- RTUSBRejectPendingPackets(pAdapter); >- RTUSBCleanUpDataBulkOutQueue(pAdapter); >- } >- } >- else >- { >- // MIC error count >= 2 >- // This should not happen >- ; >- } >-} >-/* >- ======================================================================== >- >- Routine Description: >- Copy frame from waiting queue into relative ring buffer and set >- appropriate ASIC register to kick hardware transmit function >- >- Arguments: >- pAdapter Pointer to our adapter >- pBuffer Pointer to memory of outgoing frame >- Length Size of outgoing management frame >- >- Return Value: >- NDIS_STATUS_FAILURE >- NDIS_STATUS_PENDING >- NDIS_STATUS_SUCCESS >- >- Note: >- >- ======================================================================== >-*/ >-VOID RTUSBMlmeHardTransmit( >- IN PRT2570ADAPTER pAdapter, >- IN PMGMT_STRUC pMgmt) >-{ >- PTX_CONTEXT pMLMEContext; >- PTXD_STRUC pTxD; >- PUCHAR pDest; >- PHEADER_802_11 pHeader_802_11; >- BOOLEAN AckRequired, InsertTimestamp; >- ULONG TransferBufferLength; >- PVOID pBuffer = pMgmt->pBuffer; >- ULONG Length = pMgmt->Length; >- >- DBGPRINT_RAW(RT_DEBUG_INFO, "--->MlmeHardTransmit\n"); >- >- pAdapter->PrioRingTxCnt++; >- >- pMLMEContext = &pAdapter->MLMEContext[pAdapter->NextMLMEIndex]; >- pMLMEContext->InUse = TRUE; >- >- // Increase & maintain Tx Ring Index >- pAdapter->NextMLMEIndex++; >- if (pAdapter->NextMLMEIndex >= PRIO_RING_SIZE) >- { >- pAdapter->NextMLMEIndex = 0; >- } >- >- pDest = pMLMEContext->TransferBuffer->WirelessPacket; >- pTxD = (PTXD_STRUC)(pMLMEContext->TransferBuffer); >- memset(pTxD, 0, sizeof(TXD_STRUC)); >- >- pHeader_802_11 = (PHEADER_802_11) pBuffer; >- InsertTimestamp = FALSE; >- if (pHeader_802_11->Controlhead.Frame.Type == BTYPE_CNTL) // must be PS-POLL >- { >- AckRequired = FALSE; >- } >- else // BTYPE_MGMT or BMGMT_DATA(must be NULL frame) >- { >- pAdapter->Sequence = ((pAdapter->Sequence) + 1) & (MAX_SEQ_NUMBER); >- pHeader_802_11->Sequence = pAdapter->Sequence; >- >- if (pHeader_802_11->Controlhead.Addr1.Octet[0] & 0x01) // MULTICAST, BROADCAST >- { >- INC_COUNTER(pAdapter->WlanCounters.MulticastTransmittedFrameCount); >- AckRequired = FALSE; >- pHeader_802_11->Controlhead.Duration = 0; >- } >- else >- { >- AckRequired = TRUE; >- pHeader_802_11->Controlhead.Duration = RTUSBCalcDuration(pAdapter, pAdapter->PortCfg.MlmeRate, 14); >- if (pHeader_802_11->Controlhead.Frame.Subtype == SUBTYPE_PROBE_RSP) >- { >- InsertTimestamp = TRUE; >- } >- } >- } >- >- memcpy(pDest, pBuffer, Length); >- >- // Initialize Priority Descriptor >- // For inter-frame gap, the number is for this frame and next frame >- // For MLME rate, we will fix as 2Mb to match other vendor's implement >- RTUSBWriteTxDescriptor(pTxD, FALSE, 0, AckRequired, InsertTimestamp, >- TRUE, IFS_BACKOFF, Length, FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, >- Length + 4, pAdapter->PortCfg.MlmeRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- >- // Build our URB for USBD >- TransferBufferLength = sizeof(TXD_STRUC) + Length; >- if ((TransferBufferLength % 2) == 1) >- TransferBufferLength++; >- if ((TransferBufferLength % pAdapter->BulkOutMaxPacketSize) == 0) >- TransferBufferLength += 2; >- >- pMLMEContext->BulkOutSize = TransferBufferLength; >- RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_MLME); >- >- DBGPRINT(RT_DEBUG_INFO, "<---MlmeHardTransmit\n"); >-} >- >diff -ruN rt2570-1.1.0-b1/Module/rtusb.h rt2570-cvs-2005122616/Module/rtusb.h >--- rt2570-1.1.0-b1/Module/rtusb.h 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtusb.h 2005-10-21 12:31:22.000000000 -0500 >@@ -38,7 +38,7 @@ > // > // MACRO definitions > // >-#if (_WIN32_WINNT >= 0x0501) >+#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) > #define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \ > NdisQueryBufferSafe(_NdisBuf, _ppVA, _pBufLen, NormalPagePriority) > #else >diff -ruN rt2570-1.1.0-b1/Module/rtusb_info.c rt2570-cvs-2005122616/Module/rtusb_info.c >--- rt2570-1.1.0-b1/Module/rtusb_info.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtusb_info.c 2005-12-02 06:55:15.000000000 -0600 >@@ -200,6 +200,14 @@ > pAdapter->PortCfg.IbssConfig.Channel = chan; > DBGPRINT(RT_DEBUG_ERROR, "<==SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->PortCfg.IbssConfig.Channel); > >+ // CD: setting the channel in Monitor mode is unrelated to RFMONTx >+ >+ if (pAdapter->PortCfg.BssType == BSS_MONITOR) >+ { >+ pAdapter->PortCfg.Channel = pAdapter->PortCfg.IbssConfig.Channel; >+ AsicSwitchChannel(pAdapter, pAdapter->PortCfg.Channel); >+ AsicLockChannel(pAdapter, pAdapter->PortCfg.Channel); >+ } > > return 0; > } >@@ -269,7 +277,10 @@ > pAdapter->PortCfg.BssType=BSS_MONITOR; > RTUSBEnqueueInternalCmd(pAdapter, RT_OID_LINK_DOWN); > pAdapter->bConfigChanged = TRUE; >- pAdapter->net->type = 801; >+ if (pAdapter->PortCfg.MallowRFMONTx == TRUE) >+ pAdapter->net->type = 801; // ARPHRD_IEEE80211 >+ else >+ pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM > RTUSBWriteMACRegister(pAdapter, TXRX_CSR2, 0x4e); > break; > default: >@@ -288,10 +299,15 @@ > __u32 *mode, char *extra) > { > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; >- if (ADHOC_ON(pAdapter)) >- *mode = IW_MODE_ADHOC; >+ if (pAdapter->PortCfg.BssType == BSS_MONITOR) >+ *mode = IW_MODE_MONITOR; > else >- *mode = IW_MODE_INFRA; >+ { >+ if (ADHOC_ON(pAdapter)) >+ *mode = IW_MODE_ADHOC; >+ else >+ *mode = IW_MODE_INFRA; >+ } > DBGPRINT(RT_DEBUG_TEMP,"--->rtusb_ioctl_giwmode\n"); > return 0; > } >@@ -372,9 +388,7 @@ > break; > } > >- range->max_qual.qual = 70; /* what is correct max? This was not >- * documented exactly. At least >- * 69 has been observed. */ >+ range->max_qual.qual = 100; /* percentage */ > range->max_qual.level = 0; /* dB */ > range->max_qual.noise = 0; /* dB */ > >@@ -502,7 +516,11 @@ > if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF)) > return 0; > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if ((pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (pAdapter->MLMEThr_pid > 0)) >+#else >+ if ((pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (pAdapter->MLMEThr_active)) >+#endif > { > DBGPRINT(RT_DEBUG_ERROR, "!!! MLME busy, reset MLME state machine !!!\n"); > MlmeRestartStateMachine(pAdapter); >@@ -539,6 +557,13 @@ > char *current_val; > struct iw_event iwe; > >+ if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)){ >+ /* >+ * Still scanning, indicate the caller should try again. >+ */ >+ return -EAGAIN; >+ } >+ > for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++) > { > if (current_ev >= end_buf) >@@ -644,8 +669,11 @@ > // this request, because this request is initiated by NDIS. > pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE; > DBGPRINT(RT_DEBUG_TRACE,"--->Ssid.SsidLength = %d, %s\n",Ssid.SsidLength, Ssid.Ssid); >- >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (pAdapter->MLMEThr_pid > 0) >+#else >+ if (!IS_ERR(pAdapter->MLMEThr)) >+#endif > MlmeEnqueue(pAdapter, > MLME_CNTL_STATE_MACHINE, > OID_802_11_SSID, >@@ -909,9 +937,9 @@ > void *w, char *extra) > { > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; >- int *param = (int *) extra; >+ int param = *(int *) extra; > >- switch(param[0]) >+ switch(param) > { > case 1: > pAdapter->PortCfg.AuthMode = Ndis802_11AuthModeOpen; >@@ -936,7 +964,7 @@ > } > > >- pAdapter->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; >+ pAdapter->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; > > return 0; > } >@@ -946,10 +974,10 @@ > { > > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; >- int *param = (int *) extra; >+ int param = *(int *)extra; > USHORT Value; > >- switch(param[0]) >+ switch(param) > { > case 1: > pAdapter->PortCfg.DefaultKeyId = 0; >@@ -990,12 +1018,12 @@ > { > > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; >- int *param = (int *) extra; >+ int param = *(int *)extra; > NDIS_802_11_WEP_STATUS WepStatus;//set by OID_802_11_WEP_STATUS > DBGPRINT(RT_DEBUG_TRACE, "===>setencryp\n"); > DBGPRINT(RT_DEBUG_TRACE, "===>info->cmd 0x%x \n",(info->cmd)); >- DBGPRINT(RT_DEBUG_TRACE, "===>info->flags 0x%x , param %x , extra %x\n",(info->flags), param[0],*extra); >- switch(param[0]) >+ DBGPRINT(RT_DEBUG_TRACE, "===>info->flags 0x%x , param %x , extra %x\n",(info->flags), param,*extra); >+ switch(param) > { > case 1: > pAdapter->PortCfg.WepStatus= Ndis802_11WEPDisabled; >@@ -1100,14 +1128,74 @@ > return 0; > > } >+ >+static int rtusb_ioctl_setrfmontx(struct net_device *dev, >+ struct iw_request_info *info, >+ struct iw_point *data, char *extra) >+{ >+ PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; >+ int param; >+ char value; >+ >+ if (extra) { /* Change the state if there's param. */ >+ param = *(int *)extra; >+ switch(param) >+ { >+ case 1: >+ pAdapter->PortCfg.MallowRFMONTx = TRUE; >+ pAdapter->net->type = 801; // ARPHRD_IEEE80211 >+ break; >+ case 0: >+ pAdapter->PortCfg.MallowRFMONTx = FALSE; >+ pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM >+ break; >+ default: >+ return -EOPNOTSUPP; >+ } >+ } >+ >+ value = pAdapter->PortCfg.MallowRFMONTx == TRUE ? '1' : '0'; >+ >+ data->length = sizeof (char); >+ if (data->pointer != NULL && copy_to_user (data->pointer, &value, data->length)) >+ DBGPRINT (RT_DEBUG_ERROR, "rtusb_ioctl_setrfmontx - copy to user failure.\n"); >+ >+ return 0; >+} >+ >+static int rtusb_ioctl_setadhocmode(struct net_device *dev, >+ struct iw_request_info *info, >+ struct iw_point *data, char *extra) >+{ >+ PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; >+ int param = *(int *)extra; >+ >+ switch(param) >+ { >+ case 0: >+ pAdapter->PortCfg.AdhocMode = 0; >+ break; >+ case 1: >+ pAdapter->PortCfg.AdhocMode = 1; >+ break; >+ case 2: >+ pAdapter->PortCfg.AdhocMode = 2; >+ break; >+ default: >+ return -EOPNOTSUPP; >+ } >+ >+ return 0; >+} >+ > static int rtusb_ioctl_setpsm(struct net_device *dev, struct iw_request_info *info, > void *w, char *extra) > { > > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; >- int *param = (int *) extra; >+ int param = *(int *)extra; > >- switch(param[0]) >+ switch(param) > { > case 0: > // clear PSM bit immediately >@@ -1187,30 +1275,30 @@ > (iw_handler) NULL, /* SIOCGIWPOWER 2d*/ > }; > static const iw_handler rtusb_priv_handlers[] = { >- (iw_handler) NULL, /* SIOCWFIRSTPRIV+0 */ >- (iw_handler) NULL, /* SIOCWFIRSTPRIV+3 */ >- (iw_handler) rtusb_ioctl_setauth, /* SIOCWFIRSTPRIV+2 */ >- (iw_handler) NULL, /* SIOCWFIRSTPRIV+3 */ >- (iw_handler) rtusb_ioctl_setencryp, /* SIOCWFIRSTPRIV+4 */ >- (iw_handler) rtusb_ioctl_setwpapsk, /* SIOCWFIRSTPRIV+5 */ >- (iw_handler) rtusb_ioctl_setpsm, /* SIOCWFIRSTPRIV+6 */ >-// (iw_handler) rtusb_ioctl_setkeyid, /* SIOCWFIRSTPRIV+1 */ >+ (iw_handler) rtusb_ioctl_setauth, /* SIOCWFIRSTPRIV+0 */ >+ (iw_handler) rtusb_ioctl_setencryp, /* SIOCWFIRSTPRIV+1 */ >+ (iw_handler) rtusb_ioctl_setwpapsk, /* SIOCWFIRSTPRIV+2 */ >+ (iw_handler) rtusb_ioctl_setpsm, /* SIOCWFIRSTPRIV+3 */ >+ (iw_handler) rtusb_ioctl_setadhocmode, /* SIOCWFIRSTPRIV+4 */ >+ (iw_handler) rtusb_ioctl_setrfmontx, /* SIOCWFIRSTPRIV+5 */ > }; >-struct iw_priv_args privtab[] = { >-// { RTPRIV_IOCTL_SET, >-// IW_PRIV_TYPE_INT |1, 0, ""}, // Variable arg count >- { 1, >- IW_PRIV_TYPE_INT |1, 0, ""}, // Variable arg count >-// { RTPRIV_IOCTL_KEYID, >-// IW_PRIV_TYPE_INT |1, 0, "kid"}, // Variable arg count >+ >+#define MAX_WPAPSK_STRING 64 >+static const struct iw_priv_args privtab[] = { > { RTPRIV_IOCTL_AUTH, >- IW_PRIV_TYPE_INT |1, 0, "auth"}, // Variable arg count >+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "auth"}, > { RTPRIV_IOCTL_WEPSTATUS, >- IW_PRIV_TYPE_INT |1, 0, "enc"}, // Variable arg count >+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "enc"}, > { RTPRIV_IOCTL_WPAPSK, >- IW_PRIV_TYPE_CHAR |64, 0, "wpapsk"}, // Variable arg count >+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WPAPSK_STRING, >+ 0, "wpapsk"}, // Variable arg count > { RTPRIV_IOCTL_PSM, >- IW_PRIV_TYPE_INT |1, 0, "psm"}, // Variable arg count >+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "psm"}, // Variable arg count >+ { RTPRIV_IOCTL_ADHOCMODE, >+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "adhocmode"}, >+ { RTPRIV_IOCTL_RFMONTX, >+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, >+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | sizeof(char), "rfmontx"}, > #if 0 > { RTPRIV_IOCTL_BBP, > IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024, >@@ -1223,14 +1311,14 @@ > > const struct iw_handler_def rt2500usb_iw_handler_def = > { >-#define N(a) (sizeof (a) / sizeof (a[0])) >- .standard = (iw_handler *) rtusb_handler, >- .num_standard = sizeof(rtusb_handler) / sizeof(iw_handler), >- .private = (iw_handler *) rtusb_priv_handlers, >- .num_private = N(rtusb_priv_handlers), >- .private_args = (struct iw_priv_args *) privtab, >- .num_private_args = N(privtab), >+ .standard = (iw_handler *) rtusb_handler, >+ .num_standard = sizeof(rtusb_handler) / sizeof(iw_handler), >+ .private = (iw_handler *) rtusb_priv_handlers, >+ .num_private = ARRAY_SIZE(rtusb_handler), >+ .private_args = (struct iw_priv_args *) privtab, >+ .num_private_args = ARRAY_SIZE(privtab), > }; >+ > INT RTMPQueryInformation( > IN PRT2570ADAPTER pAdapter, > IN OUT struct ifreq *rq, >@@ -2174,14 +2262,17 @@ > #ifdef RT2500_DBG > { > int i; >- printk("RT_OID_802_11_ADD_WPA Key => \n"); >+ DBGPRINT(RT_DEBUG_LOUD, "RT_OID_802_11_ADD_WPA Key => \n"); >+ DBGPRINT(RT_DEBUG_LOUD, " "); > for (i = 0; i < Key.KeyLength; i++) > { >- printk("%02x:", pAdapter->PortCfg.PskKey.Key[i]); >- if (i%16 == 15) >- printk("\n"); >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "%02x:", pAdapter->PortCfg.PskKey.Key[i]); >+ if (i%16 == 15) { >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); >+ DBGPRINT(RT_DEBUG_LOUD, " "); >+ } > } >- printk("\n"); >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); > } > #endif > DBGPRINT(RT_DEBUG_TRACE, "Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", Key.KeyIndex, Key.KeyLength); >@@ -2238,10 +2329,10 @@ > TXRX_CSR0_STRUC TxRxCsr0; > UCHAR ZeroKey[4 * 16]; > >- DBGPRINT_RAW(RT_DEBUG_TEMP,"===>RTMPWPAAddKeyProc\n" ); >+ DBGPRINT(RT_DEBUG_TEMP,"===>RTMPWPAAddKeyProc\n" ); > pKey = (PNDIS_802_11_KEY) pBuf; > KeyIdx = pKey->KeyIndex & 0xff; >- DBGPRINT_RAW(RT_DEBUG_TEMP,"RTMPWPAAddKeyProc KeyIdx = %x\n", pKey->KeyIndex ); >+ DBGPRINT(RT_DEBUG_TEMP,"RTMPWPAAddKeyProc KeyIdx = %x\n", pKey->KeyIndex ); > // Bit 31 of Add-key, Tx Key > bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE; > // Bit 30 of Add-key PairwiseKey >@@ -2337,32 +2428,32 @@ > > Status = NDIS_STATUS_SUCCESS; > >- DBGPRINT_RAW(RT_DEBUG_TEMP,"Add Pairwise TKIP Key %d= ",PairwiseIdx); >- DBGPRINT_RAW(RT_DEBUG_TEMP,"Pairwise TKIP Key = "); >+ DBGPRINT(RT_DEBUG_TEMP,"Add Pairwise TKIP Key %d= ",PairwiseIdx); >+ DBGPRINT(RT_DEBUG_TEMP,"Pairwise TKIP Key = "); > for (i = 0; i < 16; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].Key[i]); > } > DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO,"TKIP Rx MIC Key = "); >+ DBGPRINT(RT_DEBUG_INFO,"TKIP Rx MIC Key = "); > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxMic[i]); > } > DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO,"TKIP Tx MIC Key = "); >+ DBGPRINT(RT_DEBUG_INFO,"TKIP Tx MIC Key = "); > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].TxMic[i]); > } > DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO,"TKIP RxTSC = "); >+ DBGPRINT(RT_DEBUG_INFO,"TKIP RxTSC = "); > for (i = 0; i < 6; i++) > { > DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc[i]); > } > DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); >- DBGPRINT_RAW(RT_DEBUG_INFO,"BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n", >+ DBGPRINT(RT_DEBUG_INFO,"BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n", > pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]); > > } >@@ -2453,13 +2544,13 @@ > { > DBGPRINT_RAW(RT_DEBUG_ERROR,"%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].Key[i]); > } >- DBGPRINT(RT_DEBUG_ERROR,"\n"); >+ DBGPRINT_RAW(RT_DEBUG_ERROR,"\n"); > DBGPRINT(RT_DEBUG_TRACE,"TKIP Rx MIC Key = \n"); > for (i = 0; i < 8; i++) > { > DBGPRINT_RAW(RT_DEBUG_TRACE,"%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxMic[i]); > } >- DBGPRINT(RT_DEBUG_TRACE,"\n"); >+ DBGPRINT_RAW(RT_DEBUG_TRACE,"\n"); > DBGPRINT(RT_DEBUG_TRACE,"TKIP Tx MIC Key = \n"); > for (i = 0; i < 8; i++) > { >@@ -2471,7 +2562,7 @@ > { > DBGPRINT_RAW(RT_DEBUG_TRACE,"%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxTsc[i]); > } >- DBGPRINT(RT_DEBUG_TRACE,"\n"); >+ DBGPRINT_RAW(RT_DEBUG_TRACE,"\n"); > DBGPRINT(RT_DEBUG_INFO,"BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n", > pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]); > >@@ -3814,14 +3905,17 @@ > // Start STA supplicant state machine > pAdapter->PortCfg.WpaState = SS_START; > #ifdef RT2500_DBG >- printk("Set_WPAPSK_Proc WPAPSK Key => \n"); >+ DBGPRINT(RT_DEBUG_LOUD, "Set_WPAPSK_Proc WPAPSK Key => \n"); >+ DBGPRINT(RT_DEBUG_LOUD, " "); > for (i = 0; i < 32; i++) > { >- printk("%02x:", pAdapter->PortCfg.PskKey.Key[i]); >- if (i%16 == 15) >- printk("\n"); >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "%02x:", pAdapter->PortCfg.PskKey.Key[i]); >+ if (i%16 == 15) { >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); >+ DBGPRINT(RT_DEBUG_LOUD, " "); >+ } > } >- printk("\n"); >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); > #endif > #endif > return TRUE; >@@ -3841,7 +3935,6 @@ > NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh; > NDIS_802_11_MAC_ADDRESS Bssid; > INT Status = NDIS_STATUS_SUCCESS; >- USHORT subcmd; > BOOLEAN StateMachineTouched = FALSE; > int chan = -1, index = 0, len = 0; > USHORT Value; >@@ -3851,8 +3944,13 @@ > DBGPRINT(RT_DEBUG_TRACE,"INFO::remove in progress!\n"); > return -ENETDOWN; > } >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (pAdapter->RTUSBCmdThr_pid < 0) > return -ENETDOWN; >+#else >+ if (!pAdapter->RTUSBCmdThr_active) >+ return -ENETDOWN; >+#endif > > switch(cmd) { > >@@ -4091,74 +4189,16 @@ > DBGPRINT(RT_DEBUG_TEMP, "Query::SIOCGIWAPLIST (%d BSS returned)\n",pAdapter->PortCfg.BssTab.BssNr); > DBGPRINT(RT_DEBUG_TEMP,"<==>WIRELESS_EXT=%d IOCTL::SIOCGIWAPLIST \n",WIRELESS_EXT); > break; >- case RT_PRIV_IOCTL: >- subcmd = wrq->u.data.flags; >- if( subcmd & OID_GET_SET_TOGGLE) >- Status = RTMPSetInformation(pAdapter, rq, subcmd); >- else >- Status = RTMPQueryInformation(pAdapter, rq, subcmd); >- break; > > case SIOCGIWPRIV: > if (wrq->u.data.pointer) { >- if ( verify_area(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) ) >+ if ( !access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) ) > break; > wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]); > if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab))) > Status = -EFAULT; > } > break; >- case RTPRIV_IOCTL_SET: >-#if 0 >- { >- int i; >- if( verify_area(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) ) >- break; >- >- DBGPRINT(RT_DEBUG_TEMP, "RTPRIV_IOCTL_SET 0x%08x, wrq->u.data.length = %d\n", cmd,wrq->u.data.length, wrq->u.data.length); >- DBGPRINT_RAW(RT_DEBUG_TRACE, "\n"); >- for (i=0;i<wrq->u.data.length;i++) >- DBGPRINT_RAW(RT_DEBUG_TRACE, "[%c]", (wrq->u.data.length+i)); >- DBGPRINT_RAW(RT_DEBUG_TRACE, "\n"); >- #if 0 >- char *this_char; >- char *value; >- char *poi = wrq->u.data.pointer; >- while ((this_char = strsep(&poi, ",")) != NULL) >- { >- if (!*this_char) >- continue; >- >- if ((value = strchr(this_char, '=')) != NULL) >- *value++ = 0; >- >- if (!value || !*value) >- continue; >- >- for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++) >- { >- if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0) >- { >- DBGPRINT(RT_DEBUG_TRACE, "ioctl::(iwpriv) [%s]\n", PRTMP_PRIVATE_SET_PROC->name); >- if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value)) >- { //FALSE:Set private failed then return Invalid argument >- Status = -EINVAL; >- } >- break; //Exit for loop. >- } >- } >- >- if(PRTMP_PRIVATE_SET_PROC->name == NULL) >- { //Not found argument >- Status = -EINVAL; >- DBGPRINT(RT_DEBUG_TRACE, "ioctl::(iwpriv) Not Support Set Command [%s=%s]\n", this_char, value); >- break; >- } >- } >- #endif >- } >-#endif >- break; > default: > DBGPRINT(RT_DEBUG_INFO, "IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd); > Status = -EOPNOTSUPP; >diff -ruN rt2570-1.1.0-b1/Module/rtusb_init.c rt2570-cvs-2005122616/Module/rtusb_init.c >--- rt2570-1.1.0-b1/Module/rtusb_init.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtusb_init.c 2005-12-08 11:28:03.000000000 -0600 >@@ -36,6 +36,7 @@ > #include "rt_config.h" > > #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) >+#include <linux/kthread.h> > #define RT2570_USB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC); > #else > #define RT2570_USB_ALLOC_URB(iso) usb_alloc_urb(iso); >@@ -367,14 +368,16 @@ > // Use RaConfig as PSK agent. > // Start STA supplicant state machine > pAd->PortCfg.WpaState = SS_START; >- printk("%s WPAPSK Key => \n", __FUNCTION__); >+ DBGPRINT(RT_DEBUG_LOUD, "%s WPAPSK Key => \n", __FUNCTION__); >+ DBGPRINT(RT_DEBUG_LOUD, " "); > for (i = 0; i < 32; i++) > { >- printk("%02x:", pAd->PortCfg.PskKey.Key[i]); >- if (i%16 == 15) >- printk("\n"); >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "%02x:", pAd->PortCfg.PskKey.Key[i]); >+ if (i%16 == 15) { >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); >+ DBGPRINT(RT_DEBUG_LOUD, " "); > } >- printk("\n"); >+ DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); > } > } > //DefaultKeyID >@@ -1119,7 +1122,7 @@ > > RTUSBWriteMACRegister(pAdapter, MAC_CSR1, 4); > RTUSBReadMACRegister(pAdapter, MAC_CSR0, &temp); >- if ( temp == 3){ >+ if ( temp >= 3){ > RTUSBReadMACRegister(pAdapter, PHY_CSR2, &temp); > RTUSBWriteMACRegister(pAdapter, PHY_CSR2, temp & 0xFFFD); > } >@@ -1244,25 +1247,32 @@ > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) net_dev->priv; > > // Creat MLME Thread >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >+ // Creat MLME Thread > pAdapter->MLMEThr_pid= -1; > > pAdapter->MLMEThr_pid = kernel_thread(MlmeThread, pAdapter, CLONE_VM); >- if (pAdapter->MLMEThr_pid < 0) { >- printk (KERN_WARNING "%s: unable to start mlme thread\n",pAdapter->net->name); >- } >+ if (pAdapter->MLMEThr_pid < 0) >+ printk(KERN_WARNING "%s: unable to start mlme thread\n",pAdapter->net->name); > > // Creat Command Thread > pAdapter->RTUSBCmdThr_pid= -1; >- > pAdapter->RTUSBCmdThr_pid = kernel_thread(RTUSBCmdThread, pAdapter, CLONE_VM); >- if (pAdapter->RTUSBCmdThr_pid < 0) { >- printk (KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAdapter->net->name); >- } >+ if (pAdapter->RTUSBCmdThr_pid < 0) >+ printk(KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAdapter->net->name); >+#else >+ // Creat MLME Thread >+ pAdapter->MLMEThr = kthread_run(MlmeThread, pAdapter, "rtusb-mlme"); >+ if (IS_ERR(pAdapter->MLMEThr)) >+ printk(KERN_WARNING "%s: unable to start mlme thread\n",pAdapter->net->name); >+ // Creat Command Thread >+ pAdapter->RTUSBCmdThr = kthread_run(RTUSBCmdThread, pAdapter, "rtusb-usbcmd"); >+ if (IS_ERR(pAdapter->RTUSBCmdThr)) >+ printk(KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAdapter->net->name); >+#endif >+} > >- /* Wait for the thread to start */ >- //wait_for_completion(&(pAdapter->notify)); > >-} > NDIS_STATUS RTMPAllocAdapterBlock( PRT2570ADAPTER *ppAdapter ) > { > NDIS_STATUS Status=NDIS_STATUS_SUCCESS; >@@ -1639,7 +1649,9 @@ > init_MUTEX(&(pAdapter->usbdev_semaphore)); > init_MUTEX_LOCKED(&(pAdapter->mlme_semaphore)); > init_MUTEX_LOCKED(&(pAdapter->RTUSBCmd_semaphore)); >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > init_completion (&pAdapter->notify); >+#endif > NdisAllocateSpinLock(&pAdapter->CmdQLock); > NdisAllocateSpinLock(&pAdapter->SendTxWaitQueueLock); > NdisAllocateSpinLock(&pAdapter->BulkOutLock); >@@ -1886,6 +1898,7 @@ > pAdapter->PortCfg.Mibss = FALSE; > pAdapter->PortCfg.Massoc = FALSE; > pAdapter->PortCfg.Mauth = FALSE; >+ pAdapter->PortCfg.MallowRFMONTx = FALSE; > > // PHY specification > pAdapter->PortCfg.PhyMode = PHY_11BG_MIXED; >@@ -1920,11 +1933,12 @@ > pAdapter->PortCfg.bHwRadio = TRUE; > pAdapter->PortCfg.bSwRadio = TRUE; > pAdapter->PortCfg.bRadio = TRUE; >- printk("INIT bRadio=%d\n", pAdapter->PortCfg.bRadio); >+ DBGPRINT(RT_DEBUG_TEMP, "INIT bRadio=%d\n", pAdapter->PortCfg.bRadio); > pAdapter->PortCfg.bHardwareRadio = FALSE; // Default is OFF > pAdapter->PortCfg.bAutoTxAgc = FALSE; // Default is OFF > pAdapter->PortCfg.bShowHiddenSSID = FALSE; // Default no show >- >+ pAdapter->PortCfg.AdhocMode = 0; // b/g in adhoc >+ > // Nitro mode control > pAdapter->PortCfg.EnableTxBurst = 0; > pAdapter->PortCfg.AutoReconnect = TRUE; >@@ -2106,4 +2120,3 @@ > del_timer_sync(&pTimer->Timer); > } > >- >diff -ruN rt2570-1.1.0-b1/Module/rtusb_io.c rt2570-cvs-2005122616/Module/rtusb_io.c >--- rt2570-1.1.0-b1/Module/rtusb_io.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtusb_io.c 2005-12-02 06:55:15.000000000 -0600 >@@ -725,10 +725,14 @@ > IN ULONG InformationBufferLength) > { > PCmdQElmt cmdqelmt = NULL; >- >- if (pAdapter->RTUSBCmdThr_pid < 0) >- return NDIS_STATUS_RESOURCES; > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >+ if (pAdapter->RTUSBCmdThr_pid < 0) >+ return NDIS_STATUS_RESOURCES; >+#else >+ if (!pAdapter->RTUSBCmdThr_active) >+ return NDIS_STATUS_RESOURCES; >+#endif > cmdqelmt = (PCmdQElmt) kmalloc(sizeof(CmdQElmt), GFP_KERNEL); > if (!cmdqelmt) > { >@@ -815,8 +819,13 @@ > { > PCmdQElmt cmdqelmt = NULL; > >- if (pAdapter->RTUSBCmdThr_pid < 0) >- return; >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >+ if (pAdapter->RTUSBCmdThr_pid < 0) >+ return NDIS_STATUS_RESOURCES; >+#else >+ if (!pAdapter->RTUSBCmdThr_active) >+ return NDIS_STATUS_RESOURCES; >+#endif > > switch (Oid) > { >@@ -865,7 +874,11 @@ > break; > } > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if ((cmdqelmt != NULL) && (cmdqelmt->InUse == FALSE) && (pAdapter->RTUSBCmdThr_pid > 0)) >+#else >+ if ((cmdqelmt != NULL) && (cmdqelmt->InUse == FALSE) && (pAdapter->RTUSBCmdThr_active)) >+#endif > { > cmdqelmt->InUse = TRUE; > cmdqelmt->command = Oid; >diff -ruN rt2570-1.1.0-b1/Module/rtusb_main.c rt2570-cvs-2005122616/Module/rtusb_main.c >--- rt2570-1.1.0-b1/Module/rtusb_main.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/rtusb_main.c 2005-12-18 15:59:59.000000000 -0600 >@@ -43,12 +43,14 @@ > #define KERNEL_20424 0x20418 > #define KERNEL_20418 0x20412 > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > /* Kernel thread and vars, which handles packets that are completed. Only > * packets that have a "complete" function are sent here. This way, the > * completion is run out of kernel context, and doesn't block the rest of > * the stack. */ > static int mlme_kill; > static int RTUSBCmd_kill; >+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) */ > > extern const struct iw_handler_def rt2500usb_iw_handler_def; > >@@ -199,7 +201,7 @@ > > pAd->iw_stats.status = 0; // Status - device dependent for now > >- pAd->iw_stats.qual.qual = 0;//pAd->Mlme.RoamCqi; // link quality (%retries, SNR, %missed beacons or better...) >+ pAd->iw_stats.qual.qual = pAd->Mlme.ChannelQuality;//pAd->Mlme.RoamCqi; // link quality (%retries, SNR, %missed beacons or better...) > pAd->iw_stats.qual.level = pAd->PortCfg.LastRssi - RSSI_TO_DBM_OFFSET; // signal level (dBm) > > pAd->iw_stats.qual.noise = (pAd->PortCfg.LastR17Value > BBP_R17_DYNAMIC_UP_BOUND) ? BBP_R17_DYNAMIC_UP_BOUND : ((ULONG) pAd->PortCfg.LastR17Value); // noise level (dBm) >@@ -244,22 +246,6 @@ > MLME_QUEUE_ELEM MsgElem; > > DBGPRINT(RT_DEBUG_TRACE, "====> RTUSBHalt\n"); >- // kill Mlme thread in close handler >-#if 0 >- if (pAdapter->MLMEThr_pid >= 0) { >- printk("kill MLME thread Process\n"); >- mlme_kill = 1; >- up(&pAdapter->mlme_semaphore); >- wmb(); // need to check >- ret = kill_proc (pAdapter->MLMEThr_pid, SIGTERM, 1); >- if (ret) { >- printk (KERN_ERR "%s: unable to signal thread\n", pAdapter->net->name); >- return; >- } >- wait_for_completion (&pAdapter->notify); >- } >-#endif >- // > // before set flag fRTMP_ADAPTER_HALT_IN_PROGRESS, > // we should send a disassoc frame to our AP. > // >@@ -1090,13 +1076,13 @@ > DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_ADD_KEY \n"); > { > int i = 0; >- PNDIS_802_11_KEY pkey = (PNDIS_802_11_KEY)pData; >- DBGPRINT(RT_DEBUG_INFO,"pKey->KeyMaterial =\n "); >+ DBGPRINT(RT_DEBUG_INFO,"pKey->KeyMaterial = "); > for (i = 0; i < 16; i++) > { >- DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pkey->KeyMaterial[i]); >+ DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", >+ ((PNDIS_802_11_KEY)pData)->KeyMaterial[i]); > } >- DBGPRINT(RT_DEBUG_INFO,"\n"); >+ DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); > } > NdisStatus = RTMPWPAAddKeyProc(pAdapter, pData); > RTUSBBulkReceive(pAdapter); >@@ -1135,7 +1121,7 @@ > if ((cmdqelmt->command != RT_OID_SINGLE_READ_MAC) && > (cmdqelmt->command != RT_OID_MULTI_READ_MAC) && > (cmdqelmt->command != RT_OID_VENDOR_READ_BBP) && >-#if DBG >+#ifdef DBG > (cmdqelmt->command != RT_OID_802_11_QUERY_HARDWARE_REGISTER) && > #endif > (cmdqelmt->command != RT_OID_USB_VENDOR_EEPROM_READ)) >@@ -1223,8 +1209,10 @@ > } > > // mlmethread flag restart >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > mlme_kill = 0; > RTUSBCmd_kill =0; >+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) */ > CreateThreads(net_dev); > > // at every open handler, copy mac address. >@@ -1289,10 +1277,11 @@ > pAdapter->wait = NULL; > remove_wait_queue (&unlink_wakeup, &wait); > >- if (pAdapter->MLMEThr_pid >= 0) >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >+ if (pAdapter->MLMEThr_pid >= 0) > { > mlme_kill = 1; >- RTUSBUp(pAdapter, (&(pAdapter->mlme_semaphore))); >+ RTUSBCMDUp(pAdapter, (&(pAdapter->mlme_semaphore))); > wmb(); // need to check > ret = kill_proc (pAdapter->MLMEThr_pid, SIGTERM, 1); > if (ret) >@@ -1302,10 +1291,10 @@ > } > wait_for_completion (&pAdapter->notify); > } >- if (pAdapter->RTUSBCmdThr_pid>= 0) >+ if (pAdapter->RTUSBCmdThr_pid>= 0) > { > RTUSBCmd_kill = 1; >- RTUSBUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); >+ RTUSBCMDUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); > wmb(); // need to check > ret = kill_proc (pAdapter->RTUSBCmdThr_pid, SIGTERM, 1); > if (ret) >@@ -1313,8 +1302,28 @@ > printk (KERN_ERR "%s: unable to signal thread\n", pAdapter->net->name); > return ret; > } >- wait_for_completion (&pAdapter->notify); >+ wait_for_completion (&pAdapter->notify); >+ } >+#else >+ if (pAdapter->MLMEThr_active) >+ { >+ ret = kthread_stop(pAdapter->MLMEThr); >+ if (ret) >+ { >+ printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); >+ return ret; >+ } > } >+ if (pAdapter->RTUSBCmdThr_active) >+ { >+ ret = kthread_stop(pAdapter->RTUSBCmdThr); >+ if (ret) >+ { >+ printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); >+ return ret; >+ } >+ } >+#endif > RTUSBHalt( pAdapter, FALSE); > DBGPRINT(RT_DEBUG_TEMP,"<--usb_rt2570_close\n"); > >@@ -1326,23 +1335,28 @@ > int MlmeThread(void * Context) > { > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; >- >+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ pAdapter->MLMEThr_active = 1; >+#else > daemonize(); > current->flags |= PF_NOFREEZE; > /* signal that we've started the thread */ > complete(&(pAdapter->notify)); >-#if 1 >+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) */ >+ > while (1) > { >- //if(down_interruptible(&pAdapter->mlme_semaphore)) >- //break; >- >+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ if (kthread_should_stop()) >+ break; >+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) */ > /* lock the device pointers */ > down(&(pAdapter->mlme_semaphore)); > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (mlme_kill) > break; >- >+#endif > /* lock the device pointers , need to check if required*/ > down(&(pAdapter->usbdev_semaphore)); > MlmeHandler(pAdapter); >@@ -1350,67 +1364,56 @@ > /* unlock the device pointers */ > up(&(pAdapter->usbdev_semaphore)); > } >-#else >- // I tried this way for thread handling >- while(1) >- { >- timeout = next_tick; >- do { >- timeout = interruptible_sleep_on_timeout (&pAdapter->MLMEThr_wait, timeout); >- /* make swsusp happy with our thread */ >- if (current->flags & PF_FREEZE) >- refrigerator(PF_FREEZE); >- DBGPRINT(RT_DEBUG_TRACE, "current->flags = 0x%x\n",current->flags ); >- } while (!signal_pending (current) && (timeout > 0)); >- >- if (signal_pending (current)) { >- flush_signals(current); >- } >- >- if (mlme_kill) >- break; >- } >-#endif > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > /* notify the exit routine that we're actually exiting now >- * >- * complete()/wait_for_completion() is similar to up()/down(), >- * except that complete() is safe in the case where the structure >- * is getting deleted in a parallel mode of execution (i.e. just >- * after the down() -- that's necessary for the thread-shutdown >- * case. >- * >- * complete_and_exit() goes even further than this -- it is safe in >- * the case that the thread of the caller is going away (not just >- * the structure) -- this is necessary for the module-remove case. >- * This is important in preemption kernels, which transfer the flow >- * of execution immediately upon a complete(). >- */ >+ * >+ * complete()/wait_for_completion() is similar to up()/down(), >+ * except that complete() is safe in the case where the structure >+ * is getting deleted in a parallel mode of execution (i.e. just >+ * after the down() -- that's necessary for the thread-shutdown >+ * case. >+ * >+ * complete_and_exit() goes even further than this -- it is safe in >+ * the case that the thread of the caller is going away (not just >+ * the structure) -- this is necessary for the module-remove case. >+ * This is important in preemption kernels, which transfer the flow >+ * of execution immediately upon a complete(). >+ */ > complete_and_exit (&pAdapter->notify, 0); > DBGPRINT(RT_DEBUG_TRACE, "<---MlmeThread\n"); >- >+#else >+ DBGPRINT(RT_DEBUG_TRACE, "MlmeThread end\n"); >+ pAdapter->MLMEThr_active = 0; >+#endif >+ return 0; > } >+ > int RTUSBCmdThread(void * Context) > { >- > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; >- >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > daemonize(); > current->flags |= PF_NOFREEZE; > /* signal that we've started the thread */ > complete(&(pAdapter->notify)); >+#else >+ pAdapter->RTUSBCmdThr_active = 1; >+#endif > > while (1) > { >- //if(down_interruptible(&pAdapter->mlme_semaphore)) >- //break; >+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ if (kthread_should_stop()) >+ break; >+#endif > > /* lock the device pointers */ > down(&(pAdapter->RTUSBCmd_semaphore)); >- >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (RTUSBCmd_kill) > break; >- >+#endif > /* lock the device pointers , need to check if required*/ > down(&(pAdapter->usbdev_semaphore)); > CMDHandler(pAdapter); >@@ -1418,24 +1421,14 @@ > /* unlock the device pointers */ > up(&(pAdapter->usbdev_semaphore)); > } >- >- /* notify the exit routine that we're actually exiting now >- * >- * complete()/wait_for_completion() is similar to up()/down(), >- * except that complete() is safe in the case where the structure >- * is getting deleted in a parallel mode of execution (i.e. just >- * after the down() -- that's necessary for the thread-shutdown >- * case. >- * >- * complete_and_exit() goes even further than this -- it is safe in >- * the case that the thread of the caller is going away (not just >- * the structure) -- this is necessary for the module-remove case. >- * This is important in preemption kernels, which transfer the flow >- * of execution immediately upon a complete(). >- */ >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > complete_and_exit (&pAdapter->notify, 0); > DBGPRINT(RT_DEBUG_TRACE, "<---RTUSBCmdThread\n"); >- >+#else >+ DBGPRINT(RT_DEBUG_TRACE, "RTUSBCmdThread end\n"); >+ pAdapter->RTUSBCmdThr_active = 0; >+#endif >+ return 0; > } > > static void *usb_rtusb_probe(struct usb_device *dev, UINT interface, >@@ -1449,10 +1442,12 @@ > > for (i = 0; i < rtusb_usb_id_len; i++) > { >- if (dev->descriptor.idVendor == rtusb_usb_id[i].idVendor && >- dev->descriptor.idProduct == rtusb_usb_id[i].idProduct) >+ if (le16_to_cpu(dev->descriptor.idVendor) == rtusb_usb_id[i].idVendor && >+ le16_to_cpu(dev->descriptor.idProduct) == rtusb_usb_id[i].idProduct) > { >- printk("idVendor = 0x%x, idProduct = 0x%x \n",dev->descriptor.idVendor, dev->descriptor.idProduct); >+ printk("idVendor = 0x%x, idProduct = 0x%x \n", >+ le16_to_cpu(dev->descriptor.idVendor), >+ le16_to_cpu(dev->descriptor.idProduct)); > break; > } > } >@@ -1508,7 +1503,7 @@ > > for (device = dev_base; device != NULL; device = device->next) > { >- if (strncmp(device->name, slot_name, 4) == 0) >+ if (strncmp(device->name, slot_name, 6) == 0) > { > break; > } >@@ -1535,7 +1530,7 @@ > // start as if the link is up > // netif_device_attach (pAdapter->net); > >- PortInitCfg(pAdapter); >+ PortCfgInit(pAdapter); > > return pAdapter; > out3: >@@ -1564,13 +1559,7 @@ > printk("unregister_netdev( )\n"); > unregister_netdev (pAdapter->net); > } >- udelay(1); >- udelay(1); > >- while (MOD_IN_USE > 0) { >- MOD_DEC_USE_COUNT; >- } >- udelay(1); > DBGPRINT(RT_DEBUG_ERROR,"<=== RTUSB disconnect successfully\n"); > > } >@@ -1601,10 +1590,11 @@ > pAdapter->wait = NULL; > remove_wait_queue (&unlink_wakeup, &wait); > >- if (pAdapter->MLMEThr_pid >= 0) >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >+ if (pAdapter->MLMEThr_pid >= 0) > { > mlme_kill = 1; >- RTUSBUp(pAdapter, (&(pAdapter->mlme_semaphore))); >+ RTUSBCMDUp(pAdapter, (&(pAdapter->mlme_semaphore))); > wmb(); // need to check > ret = kill_proc (pAdapter->MLMEThr_pid, SIGTERM, 1); > if (ret) >@@ -1614,10 +1604,10 @@ > } > wait_for_completion (&pAdapter->notify); > } >- if (pAdapter->RTUSBCmdThr_pid>= 0) >+ if (pAdapter->RTUSBCmdThr_pid>= 0) > { > RTUSBCmd_kill = 1; >- RTUSBUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); >+ RTUSBCMDUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); > wmb(); // need to check > ret = kill_proc (pAdapter->RTUSBCmdThr_pid, SIGTERM, 1); > if (ret) >@@ -1627,6 +1617,26 @@ > } > wait_for_completion (&pAdapter->notify); > } >+#else >+ if (pAdapter->MLMEThr_active) >+ { >+ ret = kthread_stop(pAdapter->MLMEThr); >+ if (ret) >+ { >+ printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); >+ return ret; >+ } >+ } >+ if (pAdapter->RTUSBCmdThr_active) >+ { >+ ret = kthread_stop(pAdapter->RTUSBCmdThr); >+ if (ret) >+ { >+ printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); >+ return ret; >+ } >+ } >+#endif > RTUSBHalt( pAdapter, FALSE); > DBGPRINT(RT_DEBUG_TEMP,"<--usb_rt2570_close\n"); > >@@ -1638,130 +1648,91 @@ > int MlmeThread(void * Context) > { > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; >- >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > daemonize("rt2500usb"); > allow_signal(SIGTERM); > current->flags |= PF_NOFREEZE; > /* signal that we've started the thread */ > complete(&(pAdapter->notify)); >-#if 1 >+#else >+ pAdapter->MLMEThr_active = 1; >+#endif >+ > while (1) > { >- //if(down_interruptible(&pAdapter->mlme_semaphore)) >- //break; >- >+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ if (kthread_should_stop()) >+ break; >+#endif > /* lock the device pointers */ > down(&(pAdapter->mlme_semaphore)); > >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (mlme_kill) > break; >- >+#endif > /* lock the device pointers , need to check if required*/ > down(&(pAdapter->usbdev_semaphore)); >-#if 0 >- if (current->flags & PF_FREEZE) { >- refrigerator(0); >- } >-#endif >+ > MlmeHandler(pAdapter); > > /* unlock the device pointers */ > up(&(pAdapter->usbdev_semaphore)); > } >-#else >- // I tried this way for thread handling >- while(1) >- { >- timeout = next_tick; >- do { >- timeout = interruptible_sleep_on_timeout (&pAdapter->MLMEThr_wait, timeout); >- /* make swsusp happy with our thread */ >- if (current->flags & PF_FREEZE) >- refrigerator(PF_FREEZE); >- DBGPRINT(RT_DEBUG_TRACE, "current->flags = 0x%x\n",current->flags ); >- } while (!signal_pending (current) && (timeout > 0)); >- >- if (signal_pending (current)) { >- flush_signals(current); >- } >- >- if (mlme_kill) >- break; >- } >-#endif >- >- /* notify the exit routine that we're actually exiting now >- * >- * complete()/wait_for_completion() is similar to up()/down(), >- * except that complete() is safe in the case where the structure >- * is getting deleted in a parallel mode of execution (i.e. just >- * after the down() -- that's necessary for the thread-shutdown >- * case. >- * >- * complete_and_exit() goes even further than this -- it is safe in >- * the case that the thread of the caller is going away (not just >- * the structure) -- this is necessary for the module-remove case. >- * This is important in preemption kernels, which transfer the flow >- * of execution immediately upon a complete(). >- */ >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > complete_and_exit (&pAdapter->notify, 0); > DBGPRINT(RT_DEBUG_TRACE, "<---MlmeThread\n"); >- >+#else >+ DBGPRINT(RT_DEBUG_TRACE, "MlmeThread end\n"); >+ pAdapter->MLMEThr_active = 0; >+#endif >+ return 0; > } >+ > int RTUSBCmdThread(void * Context) > { > > PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; >- >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > daemonize("rt2500usb"); > allow_signal(SIGTERM); > current->flags |= PF_NOFREEZE; > /* signal that we've started the thread */ > complete(&(pAdapter->notify)); >+#else >+ pAdapter->RTUSBCmdThr_active = 1; >+#endif > > while (1) > { >- //if(down_interruptible(&pAdapter->mlme_semaphore)) >- //break; >- >+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ if (kthread_should_stop()) >+ break; >+#endif > /* lock the device pointers */ > down(&(pAdapter->RTUSBCmd_semaphore)); >- >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > if (RTUSBCmd_kill) > break; >- >+#endif > /* lock the device pointers , need to check if required*/ > down(&(pAdapter->usbdev_semaphore)); >-#if 0 >- if (current->flags & PF_FREEZE) { >- refrigerator(0); >- // continue; >- } >-#endif >+ > CMDHandler(pAdapter); > > /* unlock the device pointers */ > up(&(pAdapter->usbdev_semaphore)); > } >- >- /* notify the exit routine that we're actually exiting now >- * >- * complete()/wait_for_completion() is similar to up()/down(), >- * except that complete() is safe in the case where the structure >- * is getting deleted in a parallel mode of execution (i.e. just >- * after the down() -- that's necessary for the thread-shutdown >- * case. >- * >- * complete_and_exit() goes even further than this -- it is safe in >- * the case that the thread of the caller is going away (not just >- * the structure) -- this is necessary for the module-remove case. >- * This is important in preemption kernels, which transfer the flow >- * of execution immediately upon a complete(). >- */ >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > complete_and_exit (&pAdapter->notify, 0); > DBGPRINT(RT_DEBUG_TRACE, "<---RTUSBCmdThread\n"); >- >+#else >+ DBGPRINT(RT_DEBUG_TRACE, "RTUSBCmdThread end\n"); >+ pAdapter->RTUSBCmdThr_active = 0; >+#endif >+ return 0; > } >+ > static int usb_rtusb_probe (struct usb_interface *intf, > const struct usb_device_id *id) > { >@@ -1775,10 +1746,12 @@ > usb_get_dev(dev); > for (i = 0; i < rtusb_usb_id_len; i++) > { >- if (dev->descriptor.idVendor == rtusb_usb_id[i].idVendor && >- dev->descriptor.idProduct == rtusb_usb_id[i].idProduct) >+ if (le16_to_cpu(dev->descriptor.idVendor) == rtusb_usb_id[i].idVendor && >+ le16_to_cpu(dev->descriptor.idProduct) == rtusb_usb_id[i].idProduct) > { >- printk("idVendor = 0x%x, idProduct = 0x%x \n",dev->descriptor.idVendor, dev->descriptor.idProduct); >+ printk("idVendor = 0x%x, idProduct = 0x%x \n", >+ le16_to_cpu(dev->descriptor.idVendor), >+ le16_to_cpu(dev->descriptor.idProduct)); > break; > } > } >@@ -1822,8 +1795,13 @@ > pAdapter->net->addr_len = 6; > pAdapter->net->weight = 64; > pAdapter->MediaState = NdisMediaStateDisconnected; >+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) > pAdapter->MLMEThr_pid= -1; > pAdapter->RTUSBCmdThr_pid= -1; >+#else >+ pAdapter->MLMEThr_active = 0; >+ pAdapter->RTUSBCmdThr_active = 0; >+#endif > RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS); > > SET_NETDEV_DEV(pAdapter->net, &intf->dev); >@@ -1839,7 +1817,7 @@ > > for (device = dev_base; device != NULL; device = device->next) > { >- if (strncmp(device->name, slot_name, 4) == 0) >+ if (strncmp(device->name, slot_name, 6) == 0) > { > break; > } >diff -ruN rt2570-1.1.0-b1/Module/sync.c rt2570-cvs-2005122616/Module/sync.c >--- rt2570-1.1.0-b1/Module/sync.c 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/sync.c 2005-09-12 08:46:15.000000000 -0500 >@@ -203,6 +203,9 @@ > UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType; > ULONG Now; > >+ if (pAd->PortCfg.BssType == BSS_MONITOR) >+ return; >+ > DBGPRINT(RT_DEBUG_INFO, "SYNC - MlmeScanReqAction\n"); > #if 0 > // Check the total scan tries for one single OID command >diff -ruN rt2570-1.1.0-b1/Module/.#sync.c.1.1 rt2570-cvs-2005122616/Module/.#sync.c.1.1 >--- rt2570-1.1.0-b1/Module/.#sync.c.1.1 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/Module/.#sync.c.1.1 1969-12-31 18:00:00.000000000 -0600 >@@ -1,1572 +0,0 @@ >-/* >- *************************************************************************** >- * Ralink Tech Inc. >- * 4F, No. 2 Technology 5th Rd. >- * Science-based Industrial Park >- * Hsin-chu, Taiwan, R.O.C. >- * >- * (c) Copyright 2002-2004, 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 >- -------- ---------- ---------------------------------------------- >- Name Date Modification logs >- Jan Lee 2005-06-01 Release >-*/ >- >-#include "rt_config.h" >- >-// 2.4 Ghz channel plan >-UCHAR Ra24Ghz_FCC[] = {1,2,3,4,5,6,7,8,9,10,11}; >-UCHAR Ra24Ghz_IC[] = {1,2,3,4,5,6,7,8,9,10,11}; >-UCHAR Ra24Ghz_ESTI[]= {1,2,3,4,5,6,7,8,9,10,11,12,13}; >-UCHAR Ra24Ghz_SPAIN[] = {10,11}; >-UCHAR Ra24Ghz_FRANCE[] = {10,11,12,13}; >-UCHAR Ra24Ghz_MKK[] = {14}; >-UCHAR Ra24Ghz_MKK1[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14}; >-UCHAR Ra24Ghz_ISRAEL[] = {3,4,5,6,7,8,9}; >- >-// 5 Ghz channel plan >-UCHAR Ra5Ghz_UNII[] = {36,40,44,48,52,56,60,64, 149,153,157,161}; >-UCHAR Ra5Ghz_MMAC[] = {34,38,42,46}; >-UCHAR Ra5Ghz_HyperLAN2[] = {36,40,44,48,52,56,60,64, 100,104,108,112,116,120,124,128,132,136,140}; >- >-extern UCHAR CipherSuiteWpaNoneTkip[]; >-extern UCHAR CipherSuiteWpaNoneTkipLen; >- >-extern UCHAR CipherSuiteWpaNoneAes[]; >-extern UCHAR CipherSuiteWpaNoneAesLen; >- >-/* >- ========================================================================== >- Description: >- The sync state machine, >- Parameters: >- Sm - pointer to the state machine >- Note: >- the state machine looks like the following >- >- Column 1-2 >- SYNC_IDLE JOIN_WAIT_BEACON >- MT2_MLME_SCAN_REQ mlme_scan_req_action invalid_state_when_scan >- MT2_MLME_JOIN_REQ mlme_join_req_action invalid_state_when_join >- MT2_MLME_START_REQ mlme_start_req_action invalid_state_when_start >- MT2_PEER_BEACON peer_beacon peer_beacon_at_join_wait_beacon_action >- MT2_PEER_PROBE_RSP peer_beacon drop >- MT2_PEER_ATIM drop drop >- MT2_SCAN_TIMEOUT Drop Drop >- MT2_BEACON_TIMEOUT Drop beacon_timeout_at_join_wait_beacon_action >- MT2_ATIM_TIMEOUT Drop Drop >- MT2_PEER_PROBE_REQ ???? drop >- >- column 3 >- SCAN_LISTEN >- MT2_MLME_SCAN_REQ invalid_state_when_scan >- MT2_MLME_JOIN_REQ invalid_state_when_join >- MT2_MLME_START_REQ invalid_state_when_start >- MT2_PEER_BEACON peer_beacon_at_scan_action >- MT2_PEER_PROBE_RSP peer_probe_rsp_at_scan_action >- MT2_PEER_ATIM drop >- MT2_SCAN_TIMEOUT scan_timeout_action >- MT2_BEACON_TIMEOUT Drop >- MT2_ATIM_TIMEOUT Drop >- MT2_PEER_PROBE_REQ drop >- ========================================================================== >- */ >-VOID SyncStateMachineInit( >- IN PRT2570ADAPTER 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_RSP, 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->Mlme.SyncAux.BeaconTimer, &BeaconTimeout); >- //pAd->Mlme.SyncAux.BeaconTimer.data = (unsigned long)pAd; >- //pAd->Mlme.SyncAux.BeaconTimer.function = &BeaconTimeout; >- RTMPInitTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, &ScanTimeout); >- //pAd->Mlme.SyncAux.ScanTimer.data = (unsigned long)pAd; >- //pAd->Mlme.SyncAux.ScanTimer.function = &ScanTimeout; >-} >- >-/* >- ========================================================================== >- Description: >- Becaon timeout handler, executed in timer thread >- ========================================================================== >- */ >-VOID BeaconTimeout( >- IN unsigned long data) >-{ >- PRT2570ADAPTER pAd = (PRT2570ADAPTER)data; >- >- 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; >- >- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_BEACON_TIMEOUT, 0, NULL); >- RTUSBUp(pAd, &pAd->mlme_semaphore); >-} >- >-/* >- ========================================================================== >- Description: >- ATIM timeout handler, executed in timer thread >- ========================================================================== >- */ >-VOID AtimTimeout( >- IN unsigned long data) >-{ >- PRT2570ADAPTER pAd = (PRT2570ADAPTER)data; >- >- DBGPRINT(RT_DEBUG_TRACE,"SYNC - AtimTimeout \n"); >- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_ATIM_TIMEOUT, 0, NULL); >- RTUSBUp(pAd, &pAd->mlme_semaphore); >-} >- >-/* >- ========================================================================== >- Description: >- Scan timeout handler, executed in timer thread >- ========================================================================== >- */ >-VOID ScanTimeout( >- IN unsigned long data) >-{ >- PRT2570ADAPTER pAd = (PRT2570ADAPTER)data; >- >- DBGPRINT(RT_DEBUG_INFO,"SYNC - Scan Timeout \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; >- >- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL); >- RTUSBUp(pAd, &pAd->mlme_semaphore); >-} >- >-/* >- ========================================================================== >- Description: >- MLME SCAN req state machine procedure >- ========================================================================== >- */ >-VOID MlmeScanReqAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType; >- ULONG Now; >- >- DBGPRINT(RT_DEBUG_INFO, "SYNC - MlmeScanReqAction\n"); >-#if 0 >- // Check the total scan tries for one single OID command >- if (pAd->PortCfg.IgnoredScanNumber >= 3) >- { >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - MlmeScanReqAction: Too many tries already\n"); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_INVALID_FORMAT); >- return; >- } >-#endif >- // Increase the scan retry counters. >- pAd->PortCfg.IgnoredScanNumber++; >- >- // Suspend MSDU transmission here >- RTUSBSuspendMsduTransmission(pAd); >- >- // first check the parameter sanity >- if (MlmeScanReqSanity(pAd, >- Elem->Msg, >- Elem->MsgLen, >- &BssType, >- Ssid, >- &SsidLen, >- &ScanType)) >- { >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - MlmeScanReqAction\n"); >- // temporarily recover BBP from short-distance-low-sensibility mode during SCAN >- // for best SCANNING result; >- AsicRestoreBbpSensibility(pAd); >- >- Now = jiffies; >- pAd->PortCfg.LastScanTime = Now; >- // reset all the timers >- RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer); >- >- // record desired BSS parameters >- pAd->Mlme.SyncAux.BssType = BssType; >- pAd->Mlme.SyncAux.ScanType = ScanType; >- pAd->Mlme.SyncAux.SsidLen = SsidLen; >- NdisMoveMemory(pAd->Mlme.SyncAux.Ssid, Ssid, SsidLen); >- >- // start from the first channel >- pAd->Mlme.SyncAux.Channel = FirstChannel(pAd); >- ScanNextChannel(pAd); >- } >- else >- { >- DBGPRINT(RT_DEBUG_ERROR, "SYNC - MlmeScanReqAction() sanity check fail. BUG!!!\n"); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_INVALID_FORMAT); >- } >-} >- >-/* >- ========================================================================== >- Description: >- MLME JOIN req state machine procedure >- ========================================================================== >- */ >-VOID MlmeJoinReqAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- BSS_ENTRY *pBss; >- MLME_JOIN_REQ_STRUCT *Info = (MLME_JOIN_REQ_STRUCT *)(Elem->Msg); >- >- DBGPRINT(RT_DEBUG_INFO, "SYNC - MlmeJoinReqAction(BSS #%d)\n", Info->BssIdx); >- >- // reset all the timers >- RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer); >- >- pBss = &pAd->Mlme.CntlAux.SsidBssTab.BssEntry[Info->BssIdx]; >- >- // record the desired SSID & BSSID we're waiting for >- COPY_MAC_ADDR(&pAd->Mlme.SyncAux.Bssid, &pBss->Bssid); >- NdisMoveMemory(pAd->Mlme.SyncAux.Ssid, pBss->Ssid, pBss->SsidLen); >- pAd->Mlme.SyncAux.SsidLen = pBss->SsidLen; >- >- // switch channel and waiting for beacon timer >- AsicSwitchChannel(pAd, pBss->Channel); >- AsicLockChannel(pAd, pBss->Channel); >- DBGPRINT(RT_DEBUG_INFO, "SYNC - Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x ...\n", >- pAd->Mlme.SyncAux.Bssid.Octet[0], pAd->Mlme.SyncAux.Bssid.Octet[1], >- pAd->Mlme.SyncAux.Bssid.Octet[2], pAd->Mlme.SyncAux.Bssid.Octet[3], >- pAd->Mlme.SyncAux.Bssid.Octet[4], pAd->Mlme.SyncAux.Bssid.Octet[5]); >- pAd->Mlme.SyncAux.BeaconTimer.Timer.expires = JOIN_TIMEOUT; >- RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.BeaconTimer, JOIN_TIMEOUT); >- pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON; >-} >- >-/* >- ========================================================================== >- Description: >- MLME START Request state machine procedure, starting an IBSS >- ========================================================================== >- */ >-VOID MlmeStartReqAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen; >- >- // 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; >-#ifdef SINGLE_ADHOC_LINKUP >- ULONG Bssidx; >- BOOLEAN CfExist = FALSE; >- CF_PARM CfParm; >-#endif >- >- // Init Variable IE structure >- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; >- pVIE->Length = 0; >- TimeStamp.vv.LowPart = 0; >- TimeStamp.vv.HighPart = 0; >- >- if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, Ssid, &SsidLen)) >- { >- // reset all the timers >- RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer); >- RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer); >- >- // PortCfg.PrivacyInvoked should have been set via OID_802_11_WEP_STATUS. >- // pAd->PortCfg.PrivacyInvoked = FALSE; >- >- NdisMoveMemory(pAd->PortCfg.Ssid, Ssid, SsidLen); >- pAd->PortCfg.SsidLen = SsidLen; >- pAd->PortCfg.BssType = BSS_INDEP; >- Privacy = (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) || >- (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) || >- (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled); >- pAd->PortCfg.CapabilityInfo = CAP_GENERATE(0,1,0,0,Privacy, (pAd->PortCfg.WindowsTxPreamble == Rt802_11PreambleShort)); >- pAd->PortCfg.BeaconPeriod = pAd->PortCfg.IbssConfig.BeaconPeriod; >- pAd->PortCfg.AtimWin = pAd->PortCfg.IbssConfig.AtimWin; >- pAd->PortCfg.Channel = pAd->PortCfg.IbssConfig.Channel; >- if ((pAd->PortCfg.PhyMode == PHY_11ABG_MIXED) && (pAd->PortCfg.Channel > 14)) >- { >- // no 1,2,5.5,11 Mbps when in 5Ghz band >- pAd->PortCfg.SupportedRatesLen = pAd->PortCfg.IbssConfig.SupportedRatesLen - 4; >- NdisZeroMemory(pAd->PortCfg.SupportedRates, MAX_LEN_OF_SUPPORTED_RATES); >- NdisMoveMemory(pAd->PortCfg.SupportedRates, &pAd->PortCfg.IbssConfig.SupportedRates[4], MAX_LEN_OF_SUPPORTED_RATES - 4); >- } >- else >- { >- pAd->PortCfg.SupportedRatesLen = pAd->PortCfg.IbssConfig.SupportedRatesLen; >- NdisMoveMemory(pAd->PortCfg.SupportedRates, pAd->PortCfg.IbssConfig.SupportedRates, MAX_LEN_OF_SUPPORTED_RATES); >- } >-// pAd->PortCfg.Pss = PWR_ACTIVE; >- >- // generate a radom number as BSSID >- MacAddrRandomBssid(pAd, &pAd->PortCfg.Bssid); >- AsicSetBssid(pAd, &pAd->PortCfg.Bssid); >- AsicSwitchChannel(pAd, pAd->PortCfg.Channel); >- AsicLockChannel(pAd, pAd->PortCfg.Channel); >- >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - MlmeStartReqAction(ch= %d,supported rate len= %d)\n", >- pAd->PortCfg.Channel, pAd->PortCfg.SupportedRatesLen); >- >-#ifdef SINGLE_ADHOC_LINKUP >- // Add itself as the entry within BSS table >- Bssidx = BssTableSearch(&pAd->PortCfg.BssTab, &pAd->PortCfg.Bssid); >- if (Bssidx == BSS_NOT_FOUND) >- { >- Bssidx = BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &pAd->PortCfg.Bssid, >- Ssid, SsidLen, pAd->PortCfg.BssType, pAd->PortCfg.BeaconPeriod, >- CfExist, &CfParm, pAd->PortCfg.AtimWin, pAd->PortCfg.CapabilityInfo, >- pAd->PortCfg.SupportedRates, pAd->PortCfg.SupportedRatesLen, TRUE, >- pAd->PortCfg.Channel, Elem->Rssi, TimeStamp, pVIE); >- } >-#endif >- >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_START_CONF, (USHORT)MLME_SUCCESS); >- } >- else >- { >- DBGPRINT(RT_DEBUG_ERROR, "SYNC - MlmeStartReqAction() sanity check fail. BUG!!!\n"); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_START_CONF, MLME_INVALID_FORMAT); >- } >-} >- >-/* >- ========================================================================== >- Description: >- peer sends beacon back when scanning >- ========================================================================== >- */ >-VOID PeerBeaconAtScanAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MACADDR Bssid, Addr2; >- UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, Rates[MAX_LEN_OF_SUPPORTED_RATES], RatesLen, >- SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe, Legacy; >- CF_PARM CfParm; >- USHORT BeaconPeriod, AtimWin, CapabilityInfo; >- MACFRAME *Fr; >- LARGE_INTEGER TimeStamp; >- BOOLEAN CfExist = FALSE; >- BOOLEAN ExtendedRateIeExist; >- UCHAR Erp; >- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR SupRateLen, ExtRateLen; >- UCHAR LenVIE; >- // New for WPA security suites >- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5 >- NDIS_802_11_VARIABLE_IEs *pVIE = NULL; >- >- >- // NdisFillMemory(Ssid, MAX_LEN_OF_SSID, 0x00); >- Fr = (MACFRAME *) Elem->Msg; >- // Init Variable IE structure >- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; >- pVIE->Length = 0; >- if (PeerBeaconAndProbeRspSanity(pAd, >- Elem->Msg, >- Elem->MsgLen, >- &Addr2, >- &Bssid, Ssid, >- &SsidLen, >- &BssType, >- &BeaconPeriod, >- &Channel, >- &TimeStamp, >- &CfExist, >- &CfParm, >- &AtimWin, >- &CapabilityInfo, >- Rates, >- &RatesLen, >- &ExtendedRateIeExist, >- &Erp, >- &DtimCount, >- &DtimPeriod, >- &BcastFlag, >- &MessageToMe, >- &Legacy, >- SupRate, >- &SupRateLen, >- ExtRate, >- &ExtRateLen, >- &LenVIE, >- pVIE)) >- { >- ULONG Idx; >- UCHAR Rssi = 0; >- >- // This correct im-proper RSSI indication during SITE SURVEY issue. >- // Always report bigger RSSI during SCANNING when receiving multiple BEACONs from the same AP. >- // This case happens because BEACONs come from adjacent channels, so RSSI become weaker as we >- // switch to more far away channels. >- Idx = BssTableSearch(&pAd->PortCfg.BssTab, &Bssid); >- if (pAd->Mlme.SyncAux.Channel != Channel) >- { >- return; >- } >- if (Idx != BSS_NOT_FOUND) >- Rssi = pAd->PortCfg.BssTab.BssEntry[Idx].Rssi; >- if (Elem->Rssi > Rssi) >- Rssi = Elem->Rssi; >- >- DBGPRINT(RT_DEBUG_INFO, "SYNC - PeerBeaconAtScanAction (Subtype=%d, SsidLen=%d, Ssid=%s)\n", Fr->Hdr.SubType, SsidLen,Ssid); >- >- // Mask out unnecessary capability information >- CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; >- >- BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &Bssid, Ssid, SsidLen, BssType, >- BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo, Rates, >- RatesLen, ExtendedRateIeExist, Channel, Rssi, TimeStamp, LenVIE, pVIE); >- } >- // sanity check fail, ignored >-} >- >-/* >- ========================================================================== >- Description: >- When waiting joining the (I)BSS, beacon received from external >- ========================================================================== >- */ >-VOID PeerBeaconAtJoinAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MACADDR Bssid, Addr2; >- UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, Rates[MAX_LEN_OF_SUPPORTED_RATES], RatesLen, >- SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe, Legacy; >- LARGE_INTEGER TimeStamp; >- USHORT BeaconPeriod, AtimWin, CapabilityInfo; >- CF_PARM Cf; >- BOOLEAN CfExist = FALSE, ExtendedRateIeExist; >- UCHAR Erp; >- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR SupRateLen, ExtRateLen; >- UCHAR LenVIE; >- >- // New for WPA security suites >- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5 >- NDIS_802_11_VARIABLE_IEs *pVIE = NULL; >- >- // Init Variable IE structure >- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; >- pVIE->Length = 0; >- if (PeerBeaconAndProbeRspSanity(pAd, >- Elem->Msg, >- Elem->MsgLen, >- &Addr2, >- &Bssid, >- Ssid, >- &SsidLen, >- &BssType, >- &BeaconPeriod, >- &Channel, >- &TimeStamp, >- &CfExist, >- &Cf, >- &AtimWin, >- &CapabilityInfo, >- Rates, >- &RatesLen, >- &ExtendedRateIeExist, >- &Erp, >- &DtimCount, >- &DtimPeriod, >- &BcastFlag, >- &MessageToMe, >- &Legacy, >- SupRate, >- &SupRateLen, >- ExtRate, >- &ExtRateLen, >- &LenVIE, >- pVIE)) >- { >- // Disqualify 11b only adhoc when we are in 11g only adhoc mode >- if ((BssType == BSS_INDEP) && (pAd->PortCfg.AdhocMode == 2) && (RatesLen < 12)) >- return; >- >- if (MAC_ADDR_EQUAL(&pAd->Mlme.SyncAux.Bssid, &Bssid)) >- { >- RTMPCancelTimer( &pAd->Mlme.SyncAux.BeaconTimer); >- // Update RSSI to prevent No signal display when cards first initialized >- pAd->PortCfg.LastRssi = Elem->Rssi; >- pAd->PortCfg.AvgRssi = Elem->Rssi; >- >- if (pAd->Mlme.CntlAux.SsidLen > 0) >- { >- NdisMoveMemory(pAd->PortCfg.Ssid, pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidLen); >- pAd->PortCfg.SsidLen = pAd->Mlme.CntlAux.SsidLen; >- } >- else >- { >- NdisMoveMemory(pAd->PortCfg.Ssid, Ssid, SsidLen); >- pAd->PortCfg.SsidLen = SsidLen; >- } >- >- COPY_MAC_ADDR(&pAd->PortCfg.Bssid, &Bssid); >- AsicSetBssid(pAd, &pAd->PortCfg.Bssid); >- >- pAd->PortCfg.BssType = BssType; >- pAd->PortCfg.BeaconPeriod = BeaconPeriod; >- pAd->PortCfg.Channel = Channel; >- >- // filter out non-supported rates >- { >- int i; >- pAd->PortCfg.SupportedRatesLen = 0; >- for (i=0;i<RatesLen;i++) >- { >- UCHAR Rate = Rates[i] & 0x7f; >- if ((pAd->PortCfg.PhyMode == PHY_11B) && >- (Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22)) >- { >- ///DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Supported Rate[%d] = 0x%02x\n",pAd->PortCfg.SupportedRatesLen, Rates[i])); >- pAd->PortCfg.SupportedRates[pAd->PortCfg.SupportedRatesLen] = Rates[i]; >- pAd->PortCfg.SupportedRatesLen ++; >- } >- else if ((Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22) || >- (Rate == 12 || Rate == 18 || Rate == 24 || Rate == 36) || >- (Rate == 48 || Rate == 72 || Rate == 96 || Rate == 108)) >- { >- // DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Supported Rate[%d] = 0x%02x\n",pAd->PortCfg.SupportedRatesLen, Rates[i])); >- pAd->PortCfg.SupportedRates[pAd->PortCfg.SupportedRatesLen] = Rates[i]; >- pAd->PortCfg.SupportedRatesLen ++; >- } >- } >- } >- >- // Copy AP's supported rate to portcfg for creating assoication request >- // Also filter out not supported rate >- // Supported rate >- { >- int i; >- pAd->PortCfg.SupRateLen = 0; >- for (i = 0; i < SupRateLen; i++) >- { >- UCHAR Rate = SupRate[i] & 0x7f; >- if ((pAd->PortCfg.PhyMode == PHY_11B) && >- (Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22)) >- { >- pAd->PortCfg.SupRate[pAd->PortCfg.SupRateLen] = SupRate[i]; >- pAd->PortCfg.SupRateLen ++; >- } >- else if ((Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22) || >- (Rate == 12 || Rate == 18 || Rate == 24 || Rate == 36) || >- (Rate == 48 || Rate == 72 || Rate == 96 || Rate == 108)) >- { >- pAd->PortCfg.SupRate[pAd->PortCfg.SupRateLen] = SupRate[i]; >- pAd->PortCfg.SupRateLen ++; >- } >- } >- } >- >- // Copy AP's supported rate to portcfg for creating assoication request >- // Also filter out not supported rate >- // Extended rate >- if (ExtendedRateIeExist == TRUE) >- { >- int i; >- pAd->PortCfg.ExtRateLen = 0; >- for (i = 0; i < ExtRateLen; i++) >- { >- UCHAR Rate = ExtRate[i] & 0x7f; >- if ((pAd->PortCfg.PhyMode == PHY_11B) && >- (Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22)) >- { >- pAd->PortCfg.ExtRate[pAd->PortCfg.ExtRateLen] = ExtRate[i]; >- pAd->PortCfg.ExtRateLen ++; >- } >- else if ((Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22) || >- (Rate == 12 || Rate == 18 || Rate == 24 || Rate == 36) || >- (Rate == 48 || Rate == 72 || Rate == 96 || Rate == 108)) >- { >- pAd->PortCfg.ExtRate[pAd->PortCfg.ExtRateLen] = ExtRate[i]; >- pAd->PortCfg.ExtRateLen ++; >- } >- } >- } >- else >- { >- pAd->PortCfg.ExtRateLen = 0; >- } >- >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - AP's SupportedRatesLen=%d, set STA's SupportedRateLen=%d\n", >- RatesLen, pAd->PortCfg.SupportedRatesLen); >- >- // Mask out unnecessary capability information >- CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; >- >- // Check for 802.11g information, if 802.11 b/g mixed mode. >- // We can't support its short preamble for now. >- pAd->PortCfg.CapabilityInfo = CapabilityInfo; >- >- if ((BssType == BSS_INDEP) && (CAP_IS_IBSS_ON(CapabilityInfo))) >- { >- pAd->PortCfg.AtimWin = AtimWin; >- } >- else if (BssType == BSS_INFRA) >- { >- pAd->PortCfg.CfpPeriod = Cf.CfpPeriod; >- pAd->PortCfg.CfpMaxDuration = Cf.CfpMaxDuration; >- pAd->PortCfg.CfpDurRemain = Cf.CfpDurRemaining; >- pAd->PortCfg.CfpCount = Cf.CfpCount; >- pAd->PortCfg.CfpPeriod = Cf.CfpPeriod; >- >- AsicEnableBssSync(pAd); >- } >- >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_JOIN_CONF, MLME_SUCCESS); >- } >- // not to me BEACON, ignored >- } >- // sanity check fail, ignore this frame >-} >- >-/* >- ========================================================================== >- Description: >- receive BEACON from peer >- ========================================================================== >- */ >-VOID PeerBeacon( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MACADDR Bssid, Addr2; >- CHAR Ssid[MAX_LEN_OF_SSID]; >- CF_PARM CfParm; >- UCHAR SsidLen, MessageToMe=0, BssType, Channel, Rates[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR RatesLen, DtimCount=0, DtimPeriod=0, BcastFlag=0, Legacy; >- USHORT CapabilityInfo, AtimWin, BeaconPeriod; >- LARGE_INTEGER TimeStamp; >- BOOLEAN CfExist = FALSE; >- USHORT TbttNumToNextWakeUp; >- BOOLEAN ExtendedRateIeExist; >- UCHAR Erp; >- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR SupRateLen, ExtRateLen; >- UCHAR LenVIE; >- >- // New for WPA security suites >- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5 >- NDIS_802_11_VARIABLE_IEs *pVIE = NULL; >- >- if (!INFRA_ON(pAd) && !ADHOC_ON(pAd)) >- { // return; >- >-} >- // Init Variable IE structure >- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; >- pVIE->Length = 0; >- if (PeerBeaconAndProbeRspSanity(pAd, >- Elem->Msg, >- Elem->MsgLen, >- &Addr2, >- &Bssid, >- Ssid, >- &SsidLen, >- &BssType, >- &BeaconPeriod, >- &Channel, >- &TimeStamp, >- &CfExist, >- &CfParm, >- &AtimWin, >- &CapabilityInfo, >- Rates, >- &RatesLen, >- &ExtendedRateIeExist, >- &Erp, >- &DtimCount, >- &DtimPeriod, >- &BcastFlag, >- &MessageToMe, >- &Legacy, >- SupRate, >- &SupRateLen, >- ExtRate, >- &ExtRateLen, >- &LenVIE, >- pVIE)) >- { >- BOOLEAN is_my_bssid, is_my_ssid; >- ULONG Bssidx, Now; >- BSS_ENTRY *pBss; >- >- // Init Variable IE structure >- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; >- pVIE->Length = 0; >- is_my_bssid = (MAC_ADDR_EQUAL(&Bssid, &pAd->PortCfg.Bssid) ? TRUE : FALSE); >- is_my_ssid = (((pAd->PortCfg.SsidLen == SsidLen) && RTMPEqualMemory(Ssid, pAd->PortCfg.Ssid, (ULONG) SsidLen)) ? TRUE : FALSE); >- // Mask out unnecessary capability information >- CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; >- >- // ignore BEACON not for my SSID >- if ((! is_my_ssid) && (! is_my_bssid)) >- { >- return; >- } >- >- // >- // Housekeeping "SsidBssTab" table for later-on ROAMing usage. >- // >- Bssidx = BssTableSearch(&pAd->Mlme.CntlAux.SsidBssTab, &Bssid); >- if (Bssidx == BSS_NOT_FOUND) >- { >- // Return immediately when in transition process when changing association >- // Found this bug when doing WHQL ad-hoc test case >- if (pAd->PortCfg.SsidLen != pAd->Mlme.CntlAux.SsidLen) >- return; >- if (!RTMPEqualMemory(pAd->PortCfg.Ssid, pAd->Mlme.CntlAux.Ssid, pAd->PortCfg.SsidLen)) >- return; >- >- // discover new AP of this network, create BSS entry >- Bssidx = BssTableSetEntry(pAd, &pAd->Mlme.CntlAux.SsidBssTab, &Bssid, Ssid, SsidLen, >- BssType, BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo, >- Rates, RatesLen, ExtendedRateIeExist, Channel, Elem->Rssi, TimeStamp, LenVIE, pVIE); >- >- if (Bssidx == BSS_NOT_FOUND) // return if BSS table full >- return; >- >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - New AP added to SsidBssTab[%d], RSSI=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", >- Bssidx, Elem->Rssi, Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2], >- Bssid.Octet[3], Bssid.Octet[4], Bssid.Octet[5]); >- } >- >- // 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_ssid && (! is_my_bssid) && ADHOC_ON(pAd)) >- { >- INT i; >- >- // Add to safe guard adhoc wep status mismatch >- if (pAd->PortCfg.WepStatus != pAd->Mlme.CntlAux.SsidBssTab.BssEntry[Bssidx].WepStatus) >- return; >- >- // link down the one with smaller BSSID value. >- for (i = 0; i < 6; i++) >- { >- if (Bssid.Octet[i] > pAd->PortCfg.Bssid.Octet[i]) >- { >- AsicDisableSync(pAd); >- NdisMoveMemory(&pAd->PortCfg.Bssid, &Bssid, 6); >- AsicSetBssid(pAd, &pAd->PortCfg.Bssid); >- AsicEnableIbssSync(pAd); >- break; >- } >- } >- } >- >- DBGPRINT(RT_DEBUG_INFO, "SYNC - PeerBeacon from %02x:%02x:%02x:%02x:%02x:%02x - Dtim=%d/%d, Rssi=%02x\n", >- Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2], >- Bssid.Octet[3], Bssid.Octet[4], Bssid.Octet[5], >- DtimCount, DtimPeriod, Elem->Rssi); >- >- Now = jiffies; >- pBss = &pAd->Mlme.CntlAux.SsidBssTab.BssEntry[Bssidx]; >- pBss->Rssi = Elem->Rssi; // lastest RSSI >- pBss->LastBeaconRxTime = Now; // last RX timestamp >- >- // >- // BEACON from my BSSID - either IBSS or INFRA network >- // >- if (is_my_bssid) >- { >- // 2002/12/06 - patch Abocom AP bug, which forgets to set "Privacy" bit in >- // AssocRsp even though this bit is ON in Beacon. So we update according >- // to following Beacon frame. >- // pAd->PortCfg.PrivacyInvoked = CAP_IS_PRIVACY_ON(CapabilityInfo); >- >- pAd->PortCfg.LastBeaconRxTime = Now; >-#if 1 >- // at least one 11b peer joined. downgrade the MaxTxRate to 11Mbps >- // after last 11b peer left for several seconds, we'll auto switch back to 11G rate >- // in MlmePeriodicExec() >- if (ADHOC_ON(pAd) && (RatesLen <= 4)) >- { >- // this timestamp is for MlmePeriodicExec() to check if all 11B peers have left >- pAd->PortCfg.Last11bBeaconRxTime = Now; >- >- if (pAd->PortCfg.MaxTxRate > RATE_11) >- { >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - 11b peer joined. down-grade to 11b TX rates \n"); >- NdisMoveMemory(pAd->PortCfg.SupportedRates, Rates, MAX_LEN_OF_SUPPORTED_RATES); >- pAd->PortCfg.SupportedRatesLen = RatesLen; >- MlmeUpdateTxRates(pAd, FALSE); >- MakeIbssBeacon(pAd); // supported rates changed >- } >- } >-#endif >- // check if RSSI reaches threshold >- pAd->PortCfg.LastRssi = (pAd->PortCfg.LastRssi + Elem->Rssi) / 2; >- pAd->PortCfg.AvgRssi = (pAd->PortCfg.AvgRssi * 7 + Elem->Rssi) >> 3; >- if ((pAd->PortCfg.RssiTriggerMode == RSSI_TRIGGERED_UPON_BELOW_THRESHOLD) && >- (pAd->PortCfg.LastRssi < pAd->PortCfg.RssiTrigger)) >- { >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, &Dbm, sizeof(NDIS_802_11_RSSI)); >- } >- else if ((pAd->PortCfg.RssiTriggerMode == RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD) && >- (pAd->PortCfg.LastRssi > pAd->PortCfg.RssiTrigger)) >- { >- //NDIS_802_11_RSSI Dbm = pAd->PortCfg.LastRssi - pAd->BBPTuningParameters.RSSIToDbmOffset; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, &Dbm, sizeof(NDIS_802_11_RSSI)); >- //DBGPRINT(RT_DEBUG_TRACE, "SYNC - NdisMIndicateStatus *** RSSI %d dBm, greater than threshold %d dBm\n", >- // Dbm, pAd->PortCfg.RssiTrigger - pAd->BBPTuningParameters.RSSIToDbmOffset); >- } >- >- if (INFRA_ON(pAd)) // && (pAd->PortCfg.PhyMode == PHY_11BG_MIXED)) >- { >- 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->PortCfg.UseShortSlotTime == TRUE) && CAP_IS_SHORT_SLOT_TIME(CapabilityInfo); >- if (bUseShortSlot != pAd->PortCfg.ShortSlotInUsed) >- AsicSetSlotTime(pAd, bUseShortSlot); >- >- bUseBGProtection = (pAd->PortCfg.UseBGProtection == 1) || // always use >- ((pAd->PortCfg.UseBGProtection == 0) && ERP_IS_USE_PROTECTION(Erp)); >- if (bUseBGProtection != pAd->PortCfg.BGProtectionInUsed) >- { >- pAd->PortCfg.BGProtectionInUsed = bUseBGProtection; >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - AP changed B/G protection to %d\n", bUseBGProtection); >- } >- >- if ((pAd->PortCfg.TxPreambleInUsed == Rt802_11PreambleShort) && ERP_IS_USE_BARKER_PREAMBLE(Erp)) >- { >- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong); >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - AP forced to use LONG preamble\n"); >- } >- } >- >- if (INFRA_ON(pAd)) >- { >- if (pAd->PortCfg.Psm == PWR_SAVE) >- { >- // 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 PrioRing, 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) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "SYNC - AP backlog unicast-to-me, stay AWAKE, send PSPOLL\n"); >- EnqueuePsPoll(pAd); >- } >- else if (BcastFlag && (DtimCount == 0) && pAd->PortCfg.RecvDtim) >- { >- DBGPRINT_RAW(RT_DEBUG_TRACE, "SYNC - AP backlog broadcast/multicast, stay AWAKE\n"); >- } >- else >- { >- USHORT temp; >- RTUSBSingleRead(pAd, 0x320, &temp); >- if (pAd->BulkOutPending || >- (!LOCAL_TX_RING_EMPTY(pAd)) || >- (pAd->PrioRingTxCnt != 0) || >- // (pAd->PsPollContext.Ready == TRUE) || >- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || >- (!(temp & 0x80))) >- { >-// DBGPRINT_RAW(RT_DEBUG_TRACE, ("SYNC - outgoing frame in TxRing/PrioRing, stay AWAKE\n")); >- if (pAd->BulkOutPending) >- DBGPRINT_RAW(RT_DEBUG_TRACE, "Bulk Out Pending\n"); >- if (!LOCAL_TX_RING_EMPTY(pAd)) >- DBGPRINT_RAW(RT_DEBUG_TRACE, "Data Queue Non-empty\n"); >- if (pAd->PrioRingTxCnt != 0) >- DBGPRINT_RAW(RT_DEBUG_TRACE, "MLME Queue Non-empty\n"); >- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) >- DBGPRINT_RAW(RT_DEBUG_TRACE, "Scan In Progress\n"); >- if (!(temp & 0x80)) >- DBGPRINT_RAW(RT_DEBUG_TRACE, "Device Queue Non-empty\n"); >- DBGPRINT_RAW(RT_DEBUG_TRACE, "Stay AWAKE\n"); >- } >- else >- { >- USHORT NextDtim = DtimCount; >- if (NextDtim == 0) >- NextDtim = DtimPeriod; >- >- TbttNumToNextWakeUp = pAd->PortCfg.DefaultListenCount; >- if (pAd->PortCfg.RecvDtim && (TbttNumToNextWakeUp > NextDtim)) >- TbttNumToNextWakeUp = NextDtim; >- >- DBGPRINT_RAW(RT_DEBUG_TRACE, "SYNC - PHY sleeps for %d Tbcn\n", TbttNumToNextWakeUp); >- AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp); >- } >- } >- } >- else >- { >- ULONG PowerMode; >- PowerMode = pAd->PortCfg.WindowsPowerMode; >- >- if ((PowerMode != Ndis802_11PowerModeCAM) && >- (pAd->BulkOutPending == FALSE) && >- (!LOCAL_TX_RING_EMPTY(pAd)) && >-// (pAd->MLMEQ.size == 0) && >-// (pAd->PsPollContext.Ready != TRUE) && >- (pAd->SendTxWaitQueue.Number == 0) && >-// (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) && >- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)) >- { >- MlmeSetPsmBit(pAd, PWR_SAVE); >- EnqueueNullFrame(pAd, pAd->PortCfg.TxRate); >- } >- } >- } >- >- // At least another peer in this IBSS, declare MediaState as CONNECTED >- if (ADHOC_ON(pAd) && (pAd->MediaState == NdisMediaStateDisconnected)) >- { >- pAd->BeaconIntervalChangeAllowed = TRUE; >- pAd->SentBeaconsCount = 0; >- pAd->ReceivedBeaconsCount = 0; >- pAd->MediaState = NdisMediaStateConnected; >- NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_CONNECT, (PVOID)NULL, 0); >- NdisMIndicateStatusComplete(pAd->AdapterHandle); >- >- // 2003/03/12 - john >- // Make sure this entry in "PortCfg.BssTab" table, thus complies to Microsoft's policy that >- // "site survey" result should always include the current connected network. >- // >- Bssidx = BssTableSearch(&pAd->PortCfg.BssTab, &Bssid); >- if (Bssidx == BSS_NOT_FOUND) >- { >- Bssidx = BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &Bssid, Ssid, SsidLen, >- BssType, BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo, >- Rates, RatesLen, ExtendedRateIeExist, Channel, Elem->Rssi, TimeStamp, LenVIE, pVIE); >- } >- } >- } >- // not my BSSID, ignore it >- } >- // sanity check fail, ignore this frame >- else >- DBGPRINT(RT_DEBUG_TRACE, " sanity check fail peerBEACON \n"); >- >-} >- >-/* >- ========================================================================== >- Description: >- Receive PROBE REQ from remote peer when operating in IBSS mode >- ========================================================================== >- */ >-VOID PeerProbeReqAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- MACADDR Addr2; >- CHAR Ssid[MAX_LEN_OF_SSID]; >- UCHAR SsidLen; >- MACHDR ProbeRspHdr; >- NDIS_STATUS NStatus; >- UCHAR *OutBuffer = NULL; >- ULONG FrameLen = 0; >- LARGE_INTEGER FakeTimestamp; >- UCHAR SsidIe = IE_SSID, DsIe = IE_DS_PARM, IbssIe = IE_IBSS_PARM, SuppIe = IE_SUPP_RATES, >- DsLen = 1, IbssLen = 2; >- UCHAR SupportedRatesLen; >- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES]; >- UCHAR ExtRateIe = IE_EXT_SUPP_RATES, ExtRatesLen; >- UCHAR ErpIe[3] = {IE_ERP, 1, 0}; >- >- if (! ADHOC_ON(pAd)) >- return; >- >- if (PeerProbeReqSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, Ssid, &SsidLen)) //, Rates, &RatesLen)) >- { >- if ((SsidLen == 0) || RTMPEqualMemory(Ssid, pAd->PortCfg.Ssid, (ULONG) SsidLen)) >- { >- // 2003-12-10 802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode >- // make sure 1,2,5.5,11 are the firt 4 rates in PortCfg.SupportedRates[] array >- if ((pAd->PortCfg.PhyMode == PHY_11BG_MIXED) && (pAd->PortCfg.AdhocMode == 0)) >- { >- int i; >- SupportedRatesLen=0; >- for (i=0;i<pAd->PortCfg.SupportedRatesLen;i++) >- { >- switch (pAd->PortCfg.SupportedRates[i] & 0x7f) >- { >- case 2: >- case 4: >- case 11: >- case 22: >- SupportedRates[SupportedRatesLen] = pAd->PortCfg.SupportedRates[i]; >- SupportedRatesLen ++; >- break; >- default: >- break; >- } >- } >- // error handling - should never happen >- if (SupportedRatesLen != 4) >- { >- SupportedRatesLen = 4; >- SupportedRates[0] = 0x82; >- SupportedRates[1] = 0x84; >- SupportedRates[2] = 0x8b; >- SupportedRates[3] = 0x96; >- } >- } >- else >- { >- SupportedRatesLen = pAd->PortCfg.SupportedRatesLen; >- NdisMoveMemory(SupportedRates, pAd->PortCfg.SupportedRates, SupportedRatesLen); >- } >- >- // allocate and send out ProbeRsp frame >- NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory >- if (NStatus != NDIS_STATUS_SUCCESS) >- return; >- >- pAd->PortCfg.AtimWin = 0; // ?????? >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - Send PROBE_RSP to %02x:%02x:%02x:%02x:%02x:%02x...\n", >- Addr2.Octet[0],Addr2.Octet[1],Addr2.Octet[2],Addr2.Octet[3],Addr2.Octet[4],Addr2.Octet[5] ); >- MgtMacHeaderInit(pAd, &ProbeRspHdr, SUBTYPE_PROBE_RSP, 0, &Addr2, &pAd->PortCfg.Bssid); >- >- if (SupportedRatesLen <= 8) >- { >- MakeOutgoingFrame(OutBuffer, &FrameLen, >- MAC_HDR_LEN, &ProbeRspHdr, >- TIMESTAMP_LEN, &FakeTimestamp, >- 2, &pAd->PortCfg.BeaconPeriod, >- 2, &pAd->PortCfg.CapabilityInfo, >- 1, &SsidIe, >- 1, &pAd->PortCfg.SsidLen, >- pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid, >- 1, &SuppIe, >- 1, &SupportedRatesLen, >- SupportedRatesLen, SupportedRates, >- 1, &DsIe, >- 1, &DsLen, >- 1, &pAd->PortCfg.Channel, >- 1, &IbssIe, >- 1, &IbssLen, >- 2, &pAd->PortCfg.AtimWin, >- END_OF_ARGS); >- } >- else >- { >- ExtRatesLen = SupportedRatesLen - 8; >- SupportedRatesLen = 8; >- MakeOutgoingFrame(OutBuffer, &FrameLen, >- MAC_HDR_LEN, &ProbeRspHdr, >- TIMESTAMP_LEN, &FakeTimestamp, >- 2, &pAd->PortCfg.BeaconPeriod, >- 2, &pAd->PortCfg.CapabilityInfo, >- 1, &SsidIe, >- 1, &pAd->PortCfg.SsidLen, >- pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid, >- 1, &SuppIe, >- 1, &SupportedRatesLen, >- SupportedRatesLen, SupportedRates, >- 1, &DsIe, >- 1, &DsLen, >- 1, &pAd->PortCfg.Channel, >- 1, &IbssIe, >- 1, &IbssLen, >- 2, &pAd->PortCfg.AtimWin, >- 3, ErpIe, >- 1, &ExtRateIe, >- 1, &ExtRatesLen, >- ExtRatesLen, &SupportedRates[SupportedRatesLen], >- END_OF_ARGS); >- } >- // If adhoc secruity is set for WPA-None, append the cipher suite IE >- if (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPANone) >- { >- ULONG tmp; >- UCHAR WpaIe = IE_WPA; >- >- if (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) // Tkip >- { >- MakeOutgoingFrame(OutBuffer + FrameLen, &tmp, >- 1, &WpaIe, >- 1, &CipherSuiteWpaNoneTkipLen, >- CipherSuiteWpaNoneTkipLen, &CipherSuiteWpaNoneTkip[0], >- END_OF_ARGS); >- FrameLen += tmp; >- } >- else if (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled) // Aes >- { >- MakeOutgoingFrame(OutBuffer + FrameLen, &tmp, >- 1, &WpaIe, >- 1, &CipherSuiteWpaNoneAesLen, >- CipherSuiteWpaNoneAesLen, &CipherSuiteWpaNoneAes[0], >- END_OF_ARGS); >- FrameLen += tmp; >- } >- } >- >- MiniportMMRequest(pAd, OutBuffer, FrameLen); >- } >- } >-} >- >-VOID BeaconTimeoutAtJoinAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - BeaconTimeoutAtJoinAction\n"); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_JOIN_CONF, MLME_REJ_TIMEOUT); >-} >- >-/* >- ========================================================================== >- Description: >- Scan timeout procedure. basically add channel index by 1 and rescan >- ========================================================================== >- */ >-VOID ScanTimeoutAction( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- if (pAd->Mlme.SyncMachine.CurrState == SCAN_LISTEN)//MLME could have been reset. Make sure this is not the case before going on. >- { >- pAd->Mlme.SyncAux.Channel = NextChannel(pAd, pAd->Mlme.SyncAux.Channel); >- ScanNextChannel(pAd); >- } >-} >- >-/* >- ========================================================================== >- Description: >- Scan next channel >- ========================================================================== >- */ >-VOID ScanNextChannel( >- IN PRT2570ADAPTER pAd) >-{ >- MACHDR Hdr; >- UCHAR SsidIe = IE_SSID, SuppRateIe = IE_SUPP_RATES; >- VOID *OutBuffer = NULL; >- VOID *OutBuffer2 = NULL; >- NDIS_STATUS NStatus; >- ULONG FrameLen = 0; >- UCHAR SsidLen = 0; >- >- if ((pAd->Mlme.SyncAux.Channel == 0) ) >- { >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - End of SCAN, restore to channel %d, find %d BSS\n",pAd->PortCfg.Channel, pAd->PortCfg.BssTab.BssNr); >- AsicSwitchChannel(pAd, pAd->PortCfg.Channel); >- AsicLockChannel(pAd, pAd->PortCfg.Channel); >- >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_SUCCESS); >- } >- else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)) >- { >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE); >- } >- else >- { >- AsicSwitchChannel(pAd, pAd->Mlme.SyncAux.Channel); >- AsicLockChannel(pAd, pAd->Mlme.SyncAux.Channel); >- >- // Total SCAN time still limits within 3 sec (DDK constraint). >- // TODO: We need more intelligent rules here to further improve out-of-service issue. >- // e.g. temporary stop copying NDIS packet to TxRing until SCAN complete >- >- // We need to shorten active scan time in order for WZC connect issue >- if (pAd->Mlme.SyncAux.ScanType == SCAN_ACTIVE) >- { >- RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, ACTIVE_SCAN_TIME); >- } >- else if (pAd->PortCfg.PhyMode == PHY_11ABG_MIXED) >- { >- RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, MIN_CHANNEL_TIME); >- } >- else >- { >- RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, MAX_CHANNEL_TIME); >- } >- >- MgtMacHeaderInit(pAd, &Hdr, SUBTYPE_PROBE_REQ, 0, &pAd->PortCfg.Broadcast, &pAd->PortCfg.Broadcast); >- // There is no need to send broadcast probe request if active scan is in effect. >- // The same rulr should apply to passive scan also. >- if (pAd->Mlme.SyncAux.ScanType == SCAN_PASSIVE) >- { >- // Send the first probe request with empty SSID >- NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory >- if (NStatus != NDIS_STATUS_SUCCESS) >- { >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - ScanNextChannel() allocate memory fail\n"); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE); >- return; >- } >- >- DBGPRINT(RT_DEBUG_INFO, "SYNC - send passive ProbeReq @ channel=%d...\n", pAd->Mlme.SyncAux.Channel); >- SsidLen = 0; >- MakeOutgoingFrame(OutBuffer, &FrameLen, >- sizeof(MACHDR), (UCHAR*)&Hdr, >- 1, &SsidIe, >- 1, &SsidLen, >- 1, &SuppRateIe, >- 1, &pAd->PortCfg.SupportedRatesLen, >- pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates, >- END_OF_ARGS); >- MiniportMMRequest(pAd, OutBuffer, FrameLen); >- } >- else if (pAd->Mlme.SyncAux.ScanType == SCAN_ACTIVE) >- { >- // Allocate another for probe scan with SSID >- NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer2); //Get an unused nonpaged memory >- if (NStatus != NDIS_STATUS_SUCCESS) >- { >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - ScanNextChannel() allocate memory fail\n"); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE); >- return; >- } >- // make another probe scan with SSID from mlme.cntlaux.ssid >- SsidLen = pAd->Mlme.SyncAux.SsidLen; >- MakeOutgoingFrame(OutBuffer2, &FrameLen, >- sizeof(MACHDR), &Hdr, >- 1, &SsidIe, >- 1, &SsidLen, >- SsidLen, pAd->Mlme.SyncAux.Ssid, >- 1, &SuppRateIe, >- 1, &pAd->PortCfg.SupportedRatesLen, >- pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates, >- END_OF_ARGS); >- MiniportMMRequest(pAd, OutBuffer2, FrameLen); >- >- DBGPRINT(RT_DEBUG_INFO, "SYNC - send active ProbeReq @ channel=%d with essid=%s and alternate=%s\n", pAd->Mlme.SyncAux.Channel, pAd->Mlme.SyncAux.Ssid, pAd->PortCfg.Ssid); >- } >- >- pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN; >- } >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID InvalidStateWhenScan( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "AYNC - InvalidStateWhenScan(state=%d). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_STATE_MACHINE_REJECT); >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID InvalidStateWhenJoin( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "InvalidStateWhenJoin(state=%d). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_JOIN_CONF, MLME_STATE_MACHINE_REJECT); >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID InvalidStateWhenStart( >- IN PRT2570ADAPTER pAd, >- IN MLME_QUEUE_ELEM *Elem) >-{ >- DBGPRINT(RT_DEBUG_TRACE, "InvalidStateWhenStart(state=%d). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState); >- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; >- MlmeCntlConfirm(pAd, MT2_START_CONF, MLME_STATE_MACHINE_REJECT); >-} >- >-/* >- ========================================================================== >- Description: >- ========================================================================== >- */ >-VOID EnqueuePsPoll( >- IN PRT2570ADAPTER pAdapter) >-{ >- PTX_CONTEXT pPsPollContext; >- PSPOLL_FRAME *pPsPollFrame; >- >- if ((RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)) || >- (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BULKOUT_RESET)) || >- (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))) >- { >- return; >- } >- >- pPsPollContext = &(pAdapter->PsPollContext); >- pPsPollFrame = (PSPOLL_FRAME*)pAdapter->PsPollContext.TransferBuffer->WirelessPacket; >- if (pPsPollContext->InUse == FALSE) >- { >- PTXD_STRUC pTxD; >- >- pPsPollContext->InUse = TRUE; >- >- pTxD = &(pPsPollContext->TransferBuffer->TxDesc); >- NdisZeroMemory(pTxD, sizeof(TXD_STRUC)); >- RTUSBWriteTxDescriptor(pTxD, FALSE, 0, FALSE, FALSE, TRUE, IFS_BACKOFF, >- sizeof(PSPOLL_FRAME), FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, >- sizeof(PSPOLL_FRAME) + 4, pAdapter->PortCfg.MlmeRate, 4, >- pAdapter->PortCfg.TxPreambleInUsed); >- >- pPsPollFrame->PwrMgmt = 0; >- >- // Fill out frame length information for global Bulk out arbitor >- pPsPollContext->BulkOutSize = sizeof(PS_POLL_BUFFER); >- RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_PSPOLL); >- >- // Kick bulk out >- RTUSBKickBulkOut(pAdapter); >- } >-} >- >-/* >- ========================================================================== >- Description: >- Send out a NULL frame to AP. The prpose is to inform AP this client >- current PSM bit. >- NOTE: >- This routine should only be used in infrastructure mode. >- ========================================================================== >- */ >-VOID EnqueueNullFrame( >- IN PRT2570ADAPTER pAdapter, >- IN UCHAR TxRate) >-{ >- PTX_CONTEXT pNullContext; >- PTXD_STRUC pTxD; >- HEADER_802_11 *pNullFrame; >- >- if ((RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)) || >- (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BULKOUT_RESET)) || >- (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_HALT_IN_PROGRESS)) || >- (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))) >- { >- return; >- } >- >- // WPA 802.1x secured port control >- if (((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || >- (pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) && >- (pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) >- { >- return; >- } >- pNullFrame = (HEADER_802_11*)pAdapter->NullContext.TransferBuffer->WirelessPacket; >- pNullContext = &(pAdapter->NullContext); >- if (pNullContext->InUse == FALSE) >- { >- // Set the in use bit >- pNullContext->InUse = TRUE; >- >- // Fill Null frame body and TxD >- pTxD = &(pNullContext->TransferBuffer->TxDesc); >- NdisZeroMemory(pTxD, sizeof(TXD_STRUC)); >- RTUSBWriteTxDescriptor(pTxD, FALSE, 7, TRUE, FALSE, TRUE, IFS_BACKOFF, sizeof(MACHDR), FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, sizeof(MACHDR) + 4, TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); >- pNullFrame->Controlhead.Duration = RTUSBCalcDuration(pAdapter, TxRate, 14); >- pNullFrame->Controlhead.Frame.PwrMgt = (pAdapter->PortCfg.Psm == PWR_SAVE); >- DBGPRINT(RT_DEBUG_TRACE, "SYNC - send NULL Frame @%d Mbps...\n", RateIdToMbps[TxRate]); >- >- // Fill out frame length information for global Bulk out arbitor >- pNullContext->BulkOutSize = sizeof(TXD_STRUC) + sizeof(HEADER_802_11); >- RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_DATA_NULL); >- >- // Kick bulk out >- RTUSBKickBulkOut(pAdapter); >- } >-} >- >-/* >- ========================================================================== >- Description: >- Update PortCfg->ChannelList[] according to 1) Country Region 2) RF IC type, >- and 3) PHY-mode user selected. >- The outcome is used by driver when doing site survey. >- ========================================================================== >- */ >-VOID BuildChannelList( >- IN PRT2570ADAPTER pAd) >-{ >- UCHAR i, index = 0; >- NdisZeroMemory(pAd->PortCfg.ChannelList, MAX_LEN_OF_CHANNELS); >- >- // if not 11a-only mode, channel list starts from 2.4Ghz band >- if (pAd->PortCfg.PhyMode != PHY_11A) >- { >- switch (pAd->PortCfg.CountryRegion) >- { >- case REGION_FCC: // 1 - 11 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_FCC, sizeof(Ra24Ghz_FCC)); >- index += sizeof(Ra24Ghz_FCC); >- break; >- case REGION_IC: // 1 -11 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_IC, sizeof(Ra24Ghz_IC)); >- index += sizeof(Ra24Ghz_IC); >- break; >- case REGION_ISRAEL: // 3 - 9 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_ISRAEL, sizeof(Ra24Ghz_ISRAEL)); >- index += sizeof(Ra24Ghz_ISRAEL); >- break; >- case REGION_ETSI: // 1 - 13 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_ESTI, sizeof(Ra24Ghz_ESTI)); >- index += sizeof(Ra24Ghz_ESTI); >- break; >- case REGION_SPAIN: // 10 - 11 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_SPAIN, sizeof(Ra24Ghz_SPAIN)); >- index += sizeof(Ra24Ghz_SPAIN); >- break; >- case REGION_FRANCE: // 10 -13 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_FRANCE, sizeof(Ra24Ghz_FRANCE)); >- index += sizeof(Ra24Ghz_FRANCE); >- break; >- case REGION_MKK: // 14 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_MKK, sizeof(Ra24Ghz_MKK)); >- index += sizeof(Ra24Ghz_MKK); >- break; >- case REGION_MKK1: // 1 - 14 >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra24Ghz_MKK1, sizeof(Ra24Ghz_MKK1)); >- index += sizeof(Ra24Ghz_MKK1); >- break; >- default: // Error. should never happen >- break; >- } >- } >- >- if ((pAd->PortCfg.PhyMode == PHY_11A) || (pAd->PortCfg.PhyMode == PHY_11ABG_MIXED)) >- { >- // 2003-10-05 john - use UNII temoparaily for all regulation domains for easy test untill >- // RF guys confirm the supported channel plans >- NdisMoveMemory(&pAd->PortCfg.ChannelList[index], Ra5Ghz_UNII, sizeof(Ra5Ghz_UNII)); >- index += sizeof(Ra5Ghz_UNII); >- } >- >- pAd->PortCfg.ChannelListNum = index; >- >- DBGPRINT(RT_DEBUG_TRACE,"country code=%d, RFIC=%d, PHY mode=%d, support %d channels\n", >- pAd->PortCfg.CountryRegion, pAd->PortCfg.RfType, pAd->PortCfg.PhyMode, pAd->PortCfg.ChannelListNum); >- for (i=0;i<index;i++) >- { >- DBGPRINT_RAW(RT_DEBUG_INFO,"channel #%d\n", pAd->PortCfg.ChannelList[i]); >- } >-} >- >-/* >- ========================================================================== >- Description: >- This routine return the first channel number according to the country >- code selection and RF IC selection (signal band or dual band). It is called >- whenever driver need to start a site survey of all supported channels. >- Return: >- ch - the first channel number of current country code setting >- ========================================================================== >- */ >-UCHAR FirstChannel( >- IN PRT2570ADAPTER pAd) >-{ >- return pAd->PortCfg.ChannelList[0]; >-} >- >-/* >- ========================================================================== >- Description: >- This routine returns the next channel number. This routine is called >- during driver need to start a site survey of all supported channels. >- Return: >- next_channel - the next channel number valid in current country code setting. >- Note: >- return 0 if no more next channel >- ========================================================================== >- */ >-UCHAR NextChannel( >- IN PRT2570ADAPTER pAd, >- IN UCHAR channel) >-{ >- int i; >- UCHAR next_channel = 0; >- >- for (i = 0; i < (pAd->PortCfg.ChannelListNum - 1); i++) >- if (channel == pAd->PortCfg.ChannelList[i]) >- { >- next_channel = pAd->PortCfg.ChannelList[i+1]; >- break; >- } >- return next_channel; >-} >- >diff -ruN rt2570-1.1.0-b1/README rt2570-cvs-2005122616/README >--- rt2570-1.1.0-b1/README 1969-12-31 18:00:00.000000000 -0600 >+++ rt2570-cvs-2005122616/README 2005-11-18 18:05:36.000000000 -0600 >@@ -0,0 +1,53 @@ >+Installation instructions for the rt2570 Module >+ >+======================================================================= >+Build Instructions: >+==================== >+ For 2.4 or 2.6 series kernel: >+ >+ a. $tar -xvzf rt2570-x.x.x.tar.gz >+ go to "./rt2570-x.x.x/Module" directory. >+ >+ b. $make # compile driver source code >+ >+ c. $make install # installs kernel module driver >+ >+ d. $modprobe rt2570 >+ >+======================================================================= >+UTILITY >+==================== >+ There is no utility as of yet, use iwconfig to configure your usb stick. >+ >+======================================================================= >+CONFIGURATION: >+==================== >+ RT2570 driver can be configured via following interfaces, >+ i.e. (i)"iwconfig" command, (ii)"iwpriv" command >+ >+ i) iwconfig comes with kernel. >+ ii) iwpriv usage, please refer to file "iwpriv_usage.txt" for details. >+ >+MORE INFORMATION >+================================================================================= >+ If you want for rt2570 driver to auto-load at boot time: >+ >+ A) choose rausb0 for first RT2570 WLAN card, rausb1 for second RT2570 WLAN card, etc. >+ >+ B) create(edit) 'ifcfg-rausb0' file in /etc/sysconfig/network-scripts/, >+ edit( or add the line) in /etc/modules.conf: >+ alias rausb0 rt2570 >+ >+ C) edit(create) the file /etc/sysconfig/network-scripts/ifcfg-rausb0 >+ DEVICE='rausb0' >+ ONBOOT='yes' >+ >+ >+ NOTE: >+ if you use dhcp, add this line too . >+ BOOTPROTO='dhcp' >+ >+ *D) To ease the Default Gateway setting, >+ add the line >+ GATEWAY=x.x.x.x >+ in /etc/sysconfig/network >diff -ruN rt2570-1.1.0-b1/THANKS rt2570-cvs-2005122616/THANKS >--- rt2570-1.1.0-b1/THANKS 2005-07-30 11:44:30.000000000 -0500 >+++ rt2570-cvs-2005122616/THANKS 2005-11-18 18:05:36.000000000 -0600 >@@ -17,3 +17,5 @@ > and hence progressed the rt2570 along the way > * Christian Casteyde - casteydec@users.sourceforge.net > * Mathias Klein - ma_klein@gmx.de >+* Stephen Warren - SWarren@nvidia.com >+* James Elsdon - monkesys@westnet.com.au
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 115176
:
75527
| 75574