Merge git://git.kernel.org/pub/scm/linux/kernel/git/lwfinger/linux-staging into staging-next

* git://git.kernel.org/pub/scm/linux/kernel/git/lwfinger/linux-staging:
  staging: rt2860sta and rt2870sta: Remove drivers replaced in net/wireless

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2011-04-25 16:55:53 -07:00
commit 60b0fa1af9
163 changed files with 0 additions and 74159 deletions

View file

@ -67,10 +67,6 @@ source "drivers/staging/echo/Kconfig"
source "drivers/staging/brcm80211/Kconfig"
source "drivers/staging/rt2860/Kconfig"
source "drivers/staging/rt2870/Kconfig"
source "drivers/staging/comedi/Kconfig"
source "drivers/staging/olpc_dcon/Kconfig"

View file

@ -18,8 +18,6 @@ obj-$(CONFIG_PRISM2_USB) += wlan-ng/
obj-$(CONFIG_ECHO) += echo/
obj-$(CONFIG_BRCMSMAC) += brcm80211/
obj-$(CONFIG_BRCMFMAC) += brcm80211/
obj-$(CONFIG_RT2860) += rt2860/
obj-$(CONFIG_RT2870) += rt2870/
obj-$(CONFIG_COMEDI) += comedi/
obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/
obj-$(CONFIG_ASUS_OLED) += asus_oled/

View file

@ -1,10 +0,0 @@
config RT2860
tristate "Ralink 2860/3090 wireless support"
depends on PCI && X86 && WLAN
select WIRELESS_EXT
select WEXT_PRIV
select CRC_CCITT
select FW_LOADER
---help---
This is an experimental driver for the Ralink 2860 and 3090
wireless chips.

View file

@ -1,52 +0,0 @@
obj-$(CONFIG_RT2860) += rt2860sta.o
# TODO: all of these should be removed
ccflags-y := -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
ccflags-y += -DRTMP_MAC_PCI -DRTMP_PCI_SUPPORT -DRT2860
ccflags-y += -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT -DRT30xx -DRT3090
ccflags-y += -DDBG
rt2860sta-y := \
common/crypt_md5.o \
common/crypt_sha2.o \
common/crypt_hmac.o \
common/mlme.o \
common/cmm_wep.o \
common/action.o \
common/cmm_data.o \
common/rtmp_init.o \
common/cmm_tkip.o \
common/cmm_aes.o \
common/cmm_sync.o \
common/eeprom.o \
common/cmm_sanity.o \
common/cmm_info.o \
common/cmm_cfg.o \
common/cmm_wpa.o \
common/dfs.o \
common/spectrum.o \
common/rtmp_timer.o \
common/rt_channel.o \
common/cmm_asic.o \
sta/assoc.o \
sta/auth.o \
sta/auth_rsp.o \
sta/sync.o \
sta/sanity.o \
sta/rtmp_data.o \
sta/connect.o \
sta/wpa.o \
rt_linux.o \
rt_main_dev.o \
sta_ioctl.o \
common/ba_action.o \
pci_main_dev.o \
rt_pci_rbus.o \
common/cmm_mac_pci.o \
common/cmm_data_pci.o \
common/ee_prom.o \
common/rtmp_mcu.o \
common/ee_efuse.o \
chips/rt30xx.o \
common/rt_rf.o \
chips/rt3090.o

View file

@ -1,16 +0,0 @@
I'm hesitant to add a TODO file here, as the wireless developers would
really have people help them out on the "clean" rt2860 driver that can
be found at the http://rt2x00.serialmonkey.com/ site.
But, if you wish to clean up this driver instead, here's a short list of
things that need to be done to get it into a more mergable shape:
TODO:
- checkpatch.pl clean
- sparse clean
- port to in-kernel 80211 stack and common rt2x00 infrastructure
- review by the wireless developer community
Please send any patches or complaints about this driver to Greg
Kroah-Hartman <greg@kroah.com> and don't bother the upstream wireless
kernel developers about it, they want nothing to do with it.

View file

@ -1,68 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
ap.h
Abstract:
Miniport generic portion header file
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Lin 08-01-2002 created
James Tan 09-06-2002 modified (Revise NTCRegTable)
John Chang 12-22-2004 modified for RT2561/2661. merge with STA driver
*/
#ifndef __AP_H__
#define __AP_H__
/* ap_wpa.c */
void WpaStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *Sm,
OUT STATE_MACHINE_FUNC Trans[]);
#ifdef RTMP_MAC_USB
void BeaconUpdateExec(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
#endif /* RTMP_MAC_USB // */
void RTMPSetPiggyBack(struct rt_rtmp_adapter *pAd, IN BOOLEAN bPiggyBack);
void MacTableReset(struct rt_rtmp_adapter *pAd);
struct rt_mac_table_entry *MacTableInsertEntry(struct rt_rtmp_adapter *pAd,
u8 *pAddr,
u8 apidx, IN BOOLEAN CleanAll);
BOOLEAN MacTableDeleteEntry(struct rt_rtmp_adapter *pAd,
u16 wcid, u8 *pAddr);
struct rt_mac_table_entry *MacTableLookup(struct rt_rtmp_adapter *pAd,
u8 *pAddr);
#endif /* __AP_H__ */

View file

@ -1,355 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
mac_pci.h
Abstract:
Revision History:
Who When What
Justin P. Mattock 11/07/2010 Fix some typos
--------- ---------- ----------------------------------------------
*/
#ifndef __MAC_PCI_H__
#define __MAC_PCI_H__
#include "../rtmp_type.h"
#include "rtmp_mac.h"
#include "rtmp_phy.h"
#include "../rtmp_iface.h"
#include "../rtmp_dot11.h"
/* */
/* Device ID & Vendor ID related definitions, */
/* NOTE: you should not add the new VendorID/DeviceID here unless you know for sure what chip it belongs too. */
/* */
#define NIC_PCI_VENDOR_ID 0x1814
#define PCIBUS_INTEL_VENDOR 0x8086
#if !defined(PCI_CAP_ID_EXP)
#define PCI_CAP_ID_EXP 0x10
#endif
#if !defined(PCI_EXP_LNKCTL)
#define PCI_EXP_LNKCTL 0x10
#endif
#if !defined(PCI_CLASS_BRIDGE_PCI)
#define PCI_CLASS_BRIDGE_PCI 0x0604
#endif
#define TXINFO_SIZE 0
#define RTMP_PKT_TAIL_PADDING 0
#define fRTMP_ADAPTER_NEED_STOP_TX 0
#define AUX_CTRL 0x10c
/* */
/* TX descriptor format, Tx ring, Mgmt Ring */
/* */
struct PACKED rt_txd {
/* Word 0 */
u32 SDPtr0;
/* Word 1 */
u32 SDLen1:14;
u32 LastSec1:1;
u32 Burst:1;
u32 SDLen0:14;
u32 LastSec0:1;
u32 DMADONE:1;
/*Word2 */
u32 SDPtr1;
/*Word3 */
u32 rsv2:24;
u32 WIV:1; /* Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correct position */
u32 QSEL:2; /* select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA */
u32 rsv:2;
u32 TCO:1; /* */
u32 UCO:1; /* */
u32 ICO:1; /* */
};
/* */
/* Rx descriptor format, Rx Ring */
/* */
typedef struct PACKED rt_rxd {
/* Word 0 */
u32 SDP0;
/* Word 1 */
u32 SDL1:14;
u32 Rsv:2;
u32 SDL0:14;
u32 LS0:1;
u32 DDONE:1;
/* Word 2 */
u32 SDP1;
/* Word 3 */
u32 BA:1;
u32 DATA:1;
u32 NULLDATA:1;
u32 FRAG:1;
u32 U2M:1; /* 1: this RX frame is unicast to me */
u32 Mcast:1; /* 1: this is a multicast frame */
u32 Bcast:1; /* 1: this is a broadcast frame */
u32 MyBss:1; /* 1: this frame belongs to the same BSSID */
u32 Crc:1; /* 1: CRC error */
u32 CipherErr:2; /* 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid */
u32 AMSDU:1; /* rx with 802.3 header, not 802.11 header. */
u32 HTC:1;
u32 RSSI:1;
u32 L2PAD:1;
u32 AMPDU:1;
u32 Decrypted:1; /* this frame is being decrypted. */
u32 PlcpSignal:1; /* To be moved */
u32 PlcpRssil:1; /* To be moved */
u32 Rsv1:13;
} RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
typedef union _TX_ATTENUATION_CTRL_STRUC {
struct {
unsigned long RF_ISOLATION_ENABLE:1;
unsigned long Reserve2:7;
unsigned long PCIE_PHY_TX_ATTEN_VALUE:3;
unsigned long PCIE_PHY_TX_ATTEN_EN:1;
unsigned long Reserve1:20;
} field;
unsigned long word;
} TX_ATTENUATION_CTRL_STRUC, *PTX_ATTENUATION_CTRL_STRUC;
/* ----------------- EEPROM Related MACRO ----------------- */
/* 8051 firmware image for RT2860 - base address = 0x4000 */
#define FIRMWARE_IMAGE_BASE 0x2000
#define MAX_FIRMWARE_IMAGE_SIZE 0x2000 /* 8kbyte */
/* ----------------- Frimware Related MACRO ----------------- */
#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
do { \
unsigned long _i, _firm; \
RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x10000); \
\
for (_i = 0; _i < _FwLen; _i += 4) { \
_firm = _pFwImage[_i] + \
(_pFwImage[_i+3] << 24) + \
(_pFwImage[_i+2] << 16) + \
(_pFwImage[_i+1] << 8); \
RTMP_IO_WRITE32(_pAd, FIRMWARE_IMAGE_BASE + _i, _firm); \
} \
RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x00000); \
RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x00001); \
\
/* initialize BBP R/W access agent */ \
RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, 0); \
RTMP_IO_WRITE32(_pAd, H2M_MAILBOX_CSR, 0); \
} while (0)
/* ----------------- TX Related MACRO ----------------- */
#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) do {} while (0)
#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) do {} while (0)
#define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
((freeNum) >= (unsigned long)(pTxBlk->TotalFragNum + RTMP_GET_PACKET_FRAGMENTS(pPacket) + 3)) /* rough estimate we will use 3 more descriptor. */
#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) do {} while (0)
#define NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, freeNum, _TxFrameType) \
(((freeNum != (TX_RING_SIZE-1)) && \
(pAd->TxSwQueue[QueIdx].Number == 0)) || (freeNum < 3))
#define HAL_KickOutMgmtTx(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen) \
RtmpPCIMgmtKickOut(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)
#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
/* RtmpPCI_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) */
#define HAL_WriteTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
RtmpPCI_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
RtmpPCI_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
#define HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) \
RtmpPCI_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)
#define HAL_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx) \
RtmpPCI_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)
#define HAL_LastTxIdx(_pAd, _QueIdx, _LastTxIdx) \
/*RtmpPCIDataLastTxIdx(_pAd, _QueIdx,_LastTxIdx) */
#define HAL_KickOutTx(_pAd, _pTxBlk, _QueIdx) \
RTMP_IO_WRITE32((_pAd), TX_CTX_IDX0+((_QueIdx)*0x10), (_pAd)->TxRing[(_QueIdx)].TxCpuIdx)
/* RtmpPCIDataKickOut(_pAd, _pTxBlk, _QueIdx)*/
#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen) \
MiniportMMRequest(_pAd, _QueIdx, _pNullFrame, _frameLen)
#define GET_TXRING_FREENO(_pAd, _QueIdx) \
(_pAd->TxRing[_QueIdx].TxSwFreeIdx > _pAd->TxRing[_QueIdx].TxCpuIdx) ? \
(_pAd->TxRing[_QueIdx].TxSwFreeIdx - _pAd->TxRing[_QueIdx].TxCpuIdx - 1) \
: \
(_pAd->TxRing[_QueIdx].TxSwFreeIdx + TX_RING_SIZE - _pAd->TxRing[_QueIdx].TxCpuIdx - 1);
#define GET_MGMTRING_FREENO(_pAd) \
(_pAd->MgmtRing.TxSwFreeIdx > _pAd->MgmtRing.TxCpuIdx) ? \
(_pAd->MgmtRing.TxSwFreeIdx - _pAd->MgmtRing.TxCpuIdx - 1) \
: \
(_pAd->MgmtRing.TxSwFreeIdx + MGMT_RING_SIZE - _pAd->MgmtRing.TxCpuIdx - 1);
/* ----------------- RX Related MACRO ----------------- */
/* ----------------- ASIC Related MACRO ----------------- */
/* reset MAC of a station entry to 0x000000000000 */
#define RTMP_STA_ENTRY_MAC_RESET(pAd, Wcid) \
AsicDelWcidTab(pAd, Wcid);
/* add this entry into ASIC RX WCID search table */
#define RTMP_STA_ENTRY_ADD(pAd, pEntry) \
AsicUpdateRxWCIDTable(pAd, pEntry->Aid, pEntry->Addr);
/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
/* Set MAC register value according operation mode */
#define RTMP_UPDATE_PROTECT(pAd) \
AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT), TRUE, 0);
/* end johnli */
/* remove Pair-wise key material from ASIC */
#define RTMP_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid) \
AsicRemovePairwiseKeyEntry(pAd, BssIdx, (u8)Wcid);
/* add Client security information into ASIC WCID table and IVEIV table */
#define RTMP_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry) \
RTMPAddWcidAttributeEntry(pAd, apidx, KeyID, \
pAd->SharedKey[apidx][KeyID].CipherAlg, pEntry);
#define RTMP_SECURITY_KEY_ADD(pAd, apidx, KeyID, pEntry) \
{ /* update pairwise key information to ASIC Shared Key Table */ \
AsicAddSharedKeyEntry(pAd, apidx, KeyID, \
pAd->SharedKey[apidx][KeyID].CipherAlg, \
pAd->SharedKey[apidx][KeyID].Key, \
pAd->SharedKey[apidx][KeyID].TxMic, \
pAd->SharedKey[apidx][KeyID].RxMic); \
/* update ASIC WCID attribute table and IVEIV table */ \
RTMPAddWcidAttributeEntry(pAd, apidx, KeyID, \
pAd->SharedKey[apidx][KeyID].CipherAlg, \
pEntry); }
/* Insert the BA bitmap to ASIC for the Wcid entry */
#define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID) \
do { \
u32 _Value = 0, _Offset; \
_Offset = MAC_WCID_BASE + (_Aid) * HW_WCID_ENTRY_SIZE + 4; \
RTMP_IO_READ32((_pAd), _Offset, &_Value);\
_Value |= (0x10000<<(_TID)); \
RTMP_IO_WRITE32((_pAd), _Offset, _Value);\
} while (0)
/* Remove the BA bitmap from ASIC for the Wcid entry */
/* bitmap field starts at 0x10000 in ASIC WCID table */
#define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID) \
do { \
u32 _Value = 0, _Offset; \
_Offset = MAC_WCID_BASE + (_Wcid) * HW_WCID_ENTRY_SIZE + 4; \
RTMP_IO_READ32((_pAd), _Offset, &_Value); \
_Value &= (~(0x10000 << (_TID))); \
RTMP_IO_WRITE32((_pAd), _Offset, _Value); \
} while (0)
/* ----------------- Interface Related MACRO ----------------- */
/* */
/* Enable & Disable NIC interrupt via writing interrupt mask register */
/* Since it use ADAPTER structure, it have to be put after structure definition. */
/* */
#define RTMP_ASIC_INTERRUPT_DISABLE(_pAd) \
do { \
RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, 0x0); /* 0: disable */ \
RTMP_CLEAR_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \
} while (0)
#define RTMP_ASIC_INTERRUPT_ENABLE(_pAd)\
do { \
RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, (_pAd)->int_enable_reg /*DELAYINTMASK*/); /* 1:enable */ \
RTMP_SET_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \
} while (0)
#define RTMP_IRQ_INIT(pAd) \
{ pAd->int_enable_reg = ((DELAYINTMASK) | \
(RxINT|TxDataInt|TxMgmtInt)) & ~(0x03); \
pAd->int_disable_mask = 0; \
pAd->int_pending = 0; }
#define RTMP_IRQ_ENABLE(pAd) \
{ /* clear garbage ints */ \
RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff);\
RTMP_ASIC_INTERRUPT_ENABLE(pAd); }
/* ----------------- MLME Related MACRO ----------------- */
#define RTMP_MLME_HANDLER(pAd) MlmeHandler(pAd)
#define RTMP_MLME_PRE_SANITY_CHECK(pAd)
#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
#define RTMP_MLME_RESET_STATE_MACHINE(pAd) \
MlmeRestartStateMachine(pAd)
#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)\
HandleCounterMeasure(_pAd, _pEntry)
/* ----------------- Power Save Related MACRO ----------------- */
#define RTMP_PS_POLL_ENQUEUE(pAd) EnqueuePsPoll(pAd)
/* For RTMPPCIePowerLinkCtrlRestore () function */
#define RESTORE_HALT 1
#define RESTORE_WAKEUP 2
#define RESTORE_CLOSE 3
#define PowerSafeCID 1
#define PowerRadioOffCID 2
#define PowerWakeCID 3
#define CID0MASK 0x000000ff
#define CID1MASK 0x0000ff00
#define CID2MASK 0x00ff0000
#define CID3MASK 0xff000000
#define RTMP_STA_FORCE_WAKEUP(pAd, bFromTx) \
RT28xxPciStaAsicForceWakeup(pAd, bFromTx);
#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
RT28xxPciStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
#define RTMP_SET_PSM_BIT(_pAd, _val) \
MlmeSetPsmBit(_pAd, _val);
#define RTMP_MLME_RADIO_ON(pAd) \
RT28xxPciMlmeRadioOn(pAd);
#define RTMP_MLME_RADIO_OFF(pAd) \
RT28xxPciMlmeRadioOFF(pAd);
#endif /*__MAC_PCI_H__ // */

View file

@ -1,345 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
mac_usb.h
Abstract:
Revision History:
Who When What
Justin P. Mattock 11/07/2010 Fix a typo
--------- ---------- ----------------------------------------------
*/
#ifndef __MAC_USB_H__
#define __MAC_USB_H__
#include "../rtmp_type.h"
#include "rtmp_mac.h"
#include "rtmp_phy.h"
#include "../rtmp_iface.h"
#include "../rtmp_dot11.h"
#define USB_CYC_CFG 0x02a4
#define BEACON_RING_SIZE 2
#define MGMTPIPEIDX 0 /* EP6 is highest priority */
#define RTMP_PKT_TAIL_PADDING 11 /* 3(max 4 byte padding) + 4 (last packet padding) + 4 (MaxBulkOutsize align padding) */
#define fRTMP_ADAPTER_NEED_STOP_TX \
(fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_BULKOUT_RESET | \
fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_REMOVE_IN_PROGRESS)
/* */
/* RXINFO appends at the end of each rx packet. */
/* */
#define RXINFO_SIZE 4
#define RT2870_RXDMALEN_FIELD_SIZE 4
typedef struct PACKED rt_rxinfo {
u32 BA:1;
u32 DATA:1;
u32 NULLDATA:1;
u32 FRAG:1;
u32 U2M:1; /* 1: this RX frame is unicast to me */
u32 Mcast:1; /* 1: this is a multicast frame */
u32 Bcast:1; /* 1: this is a broadcast frame */
u32 MyBss:1; /* 1: this frame belongs to the same BSSID */
u32 Crc:1; /* 1: CRC error */
u32 CipherErr:2; /* 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid */
u32 AMSDU:1; /* rx with 802.3 header, not 802.11 header. */
u32 HTC:1;
u32 RSSI:1;
u32 L2PAD:1;
u32 AMPDU:1; /* To be moved */
u32 Decrypted:1;
u32 PlcpRssil:1;
u32 CipherAlg:1;
u32 LastAMSDU:1;
u32 PlcpSignal:12;
} RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
/* */
/* TXINFO */
/* */
#define TXINFO_SIZE 4
struct rt_txinfo {
/* Word 0 */
u32 USBDMATxPktLen:16; /*used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame. */
u32 rsv:8;
u32 WIV:1; /* Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correct position */
u32 QSEL:2; /* select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA */
u32 SwUseLastRound:1; /* Software use. */
u32 rsv2:2; /* Software use. */
u32 USBDMANextVLD:1; /*used ONLY in USB bulk Aggregation, NextValid */
u32 USBDMATxburst:1; /*used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint */
};
/* */
/* Management ring buffer format */
/* */
struct rt_mgmt {
BOOLEAN Valid;
u8 *pBuffer;
unsigned long Length;
};
/*////////////////////////////////////////////////////////////////////////// */
/* The struct rt_tx_buffer structure forms the transmitted USB packet to the device */
/*////////////////////////////////////////////////////////////////////////// */
struct rt_tx_buffer {
union {
u8 WirelessPacket[TX_BUFFER_NORMSIZE];
struct rt_header_802_11 NullFrame;
struct rt_pspoll_frame PsPollPacket;
struct rt_rts_frame RTSFrame;
} field;
u8 Aggregation[4]; /*Buffer for save Aggregation size. */
};
struct rt_httx_buffer {
union {
u8 WirelessPacket[MAX_TXBULK_SIZE];
struct rt_header_802_11 NullFrame;
struct rt_pspoll_frame PsPollPacket;
struct rt_rts_frame RTSFrame;
} field;
u8 Aggregation[4]; /*Buffer for save Aggregation size. */
};
/* used to track driver-generated write irps */
struct rt_tx_context {
void *pAd; /*Initialized in MiniportInitialize */
PURB pUrb; /*Initialized in MiniportInitialize */
PIRP pIrp; /*used to cancel pending bulk out. */
/*Initialized in MiniportInitialize */
struct rt_tx_buffer *TransferBuffer; /*Initialized in MiniportInitialize */
unsigned long BulkOutSize;
u8 BulkOutPipeId;
u8 SelfIdx;
BOOLEAN InUse;
BOOLEAN bWaitingBulkOut; /* at least one packet is in this TxContext, ready for making IRP anytime. */
BOOLEAN bFullForBulkOut; /* all tx buffer are full , so waiting for tx bulkout. */
BOOLEAN IRPPending;
BOOLEAN LastOne;
BOOLEAN bAggregatible;
u8 Header_802_3[LENGTH_802_3];
u8 Rsv[2];
unsigned long DataOffset;
u32 TxRate;
dma_addr_t data_dma; /* urb dma on linux */
};
/* used to track driver-generated write irps */
struct rt_ht_tx_context {
void *pAd; /*Initialized in MiniportInitialize */
PURB pUrb; /*Initialized in MiniportInitialize */
PIRP pIrp; /*used to cancel pending bulk out. */
/*Initialized in MiniportInitialize */
struct rt_httx_buffer *TransferBuffer; /*Initialized in MiniportInitialize */
unsigned long BulkOutSize; /* Indicate the total bulk-out size in bytes in one bulk-transmission */
u8 BulkOutPipeId;
BOOLEAN IRPPending;
BOOLEAN LastOne;
BOOLEAN bCurWriting;
BOOLEAN bRingEmpty;
BOOLEAN bCopySavePad;
u8 SavedPad[8];
u8 Header_802_3[LENGTH_802_3];
unsigned long CurWritePosition; /* Indicate the buffer offset which packet will be inserted start from. */
unsigned long CurWriteRealPos; /* Indicate the buffer offset which packet now are writing to. */
unsigned long NextBulkOutPosition; /* Indicate the buffer start offset of a bulk-transmission */
unsigned long ENextBulkOutPosition; /* Indicate the buffer end offset of a bulk-transmission */
u32 TxRate;
dma_addr_t data_dma; /* urb dma on linux */
};
/* */
/* Structure to keep track of receive packets and buffers to indicate */
/* receive data to the protocol. */
/* */
struct rt_rx_context {
u8 *TransferBuffer;
void *pAd;
PIRP pIrp; /*used to cancel pending bulk in. */
PURB pUrb;
/*These 2 Boolean shouldn't both be 1 at the same time. */
unsigned long BulkInOffset; /* number of packets waiting for reordering . */
/* BOOLEAN ReorderInUse; // At least one packet in this buffer are in reordering buffer and wait for receive indication */
BOOLEAN bRxHandling; /* Notify this packet is being process now. */
BOOLEAN InUse; /* USB Hardware Occupied. Wait for USB HW to put packet. */
BOOLEAN Readable; /* Receive Complete back. OK for driver to indicate receiving packet. */
BOOLEAN IRPPending; /* TODO: To be removed */
atomic_t IrpLock;
spinlock_t RxContextLock;
dma_addr_t data_dma; /* urb dma on linux */
};
/******************************************************************************
USB Frimware Related MACRO
******************************************************************************/
/* 8051 firmware image for usb - use last-half base address = 0x3000 */
#define FIRMWARE_IMAGE_BASE 0x3000
#define MAX_FIRMWARE_IMAGE_SIZE 0x1000 /* 4kbyte */
#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)
/******************************************************************************
USB TX Related MACRO
******************************************************************************/
#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) \
do { \
RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
if (pAd->DeQueueRunning[QueIdx]) { \
RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
DBGPRINT(RT_DEBUG_OFF, ("DeQueueRunning[%d]= TRUE!\n", QueIdx)); \
continue; \
} else { \
pAd->DeQueueRunning[QueIdx] = TRUE; \
RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
} \
} while (0)
#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) \
do { \
RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
pAd->DeQueueRunning[QueIdx] = FALSE; \
RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
} while (0)
#define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
(RTUSBFreeDescriptorRequest(pAd, pTxBlk->QueIdx, (pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))) == NDIS_STATUS_SUCCESS)
#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) \
do {} while (0)
#define NEED_QUEUE_BACK_FOR_AGG(_pAd, _QueIdx, _freeNum, _TxFrameType) \
((_TxFrameType == TX_RALINK_FRAME) && \
(RTUSBNeedQueueBackForAgg(_pAd, _QueIdx)))
#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
#define HAL_WriteTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
RtmpUSB_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
#define HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) \
RtmpUSB_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)
#define HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx) \
RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)
#define HAL_LastTxIdx(pAd, QueIdx, TxIdx) \
/*RtmpUSBDataLastTxIdx(pAd, QueIdx,TxIdx) */
#define HAL_KickOutTx(pAd, pTxBlk, QueIdx) \
RtmpUSBDataKickOut(pAd, pTxBlk, QueIdx)
#define HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen) \
RtmpUSBMgmtKickOut(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)
#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen) \
RtmpUSBNullFrameKickOut(_pAd, _QueIdx, _pNullFrame, _frameLen)
#define GET_TXRING_FREENO(_pAd, _QueIdx) (_QueIdx) /*(_pAd->TxRing[_QueIdx].TxSwFreeIdx) */
#define GET_MGMTRING_FREENO(_pAd) (_pAd->MgmtRing.TxSwFreeIdx)
/* ----------------- RX Related MACRO ----------------- */
/*
* Device Hardware Interface Related MACRO
*/
#define RTMP_IRQ_INIT(pAd) do {} while (0)
#define RTMP_IRQ_ENABLE(pAd) do {} while (0)
/*
* MLME Related MACRO
*/
#define RTMP_MLME_HANDLER(pAd) RTUSBMlmeUp(pAd)
#define RTMP_MLME_PRE_SANITY_CHECK(pAd) \
{ if ((pAd->CommonCfg.bHardwareRadio == TRUE) && \
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && \
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))) { \
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_CHECK_GPIO, NULL, 0); } }
#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
{ RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_QKERIODIC_EXECUT, NULL, 0); \
RTUSBMlmeUp(pAd); }
#define RTMP_MLME_RESET_STATE_MACHINE(pAd) \
{ MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_RESET_CONF, 0, NULL); \
RTUSBMlmeUp(pAd); }
#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry) \
{ RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_802_11_COUNTER_MEASURE, _pEntry, sizeof(struct rt_mac_table_entry)); \
RTUSBMlmeUp(_pAd); \
}
/*
* Power Save Related MACRO
*/
#define RTMP_PS_POLL_ENQUEUE(pAd) \
{ RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL); \
RTUSBKickBulkOut(pAd); }
#define RTMP_STA_FORCE_WAKEUP(_pAd, bFromTx) \
RT28xxUsbStaAsicForceWakeup(_pAd, bFromTx);
#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
RT28xxUsbStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
#define RTMP_SET_PSM_BIT(_pAd, _val) \
{\
if ((_pAd)->StaCfg.WindowsPowerMode == Ndis802_11PowerModeFast_PSP) \
MlmeSetPsmBit(_pAd, _val);\
else { \
u16 _psm_val; \
_psm_val = _val; \
RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_SET_PSM_BIT, &(_psm_val), sizeof(u16)); \
} \
}
#define RTMP_MLME_RADIO_ON(pAd) \
RT28xxUsbMlmeRadioOn(pAd);
#define RTMP_MLME_RADIO_OFF(pAd) \
RT28xxUsbMlmeRadioOFF(pAd);
#endif /*__MAC_USB_H__ // */

View file

@ -1,54 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __RT2860_H__
#define __RT2860_H__
#include "mac_pci.h"
#ifndef RTMP_PCI_SUPPORT
#error "For RT2860, you should define the compile flag -DRTMP_PCI_SUPPORT"
#endif
#ifndef RTMP_MAC_PCI
#error "For RT2880, you should define the compile flag -DRTMP_MAC_PCI"
#endif
/* */
/* Device ID & Vendor ID, these values should match EEPROM value */
/* */
#define NIC2860_PCI_DEVICE_ID 0x0601
#define NIC2860_PCIe_DEVICE_ID 0x0681
#define NIC2760_PCI_DEVICE_ID 0x0701 /* 1T/2R Cardbus ??? */
#define NIC2790_PCIe_DEVICE_ID 0x0781 /* 1T/2R miniCard */
#define VEN_AWT_PCIe_DEVICE_ID 0x1059
#define VEN_AWT_PCI_VENDOR_ID 0x1A3B
#define EDIMAX_PCI_VENDOR_ID 0x1432
#endif /*__RT2860_H__ // */

View file

@ -1,46 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __RT2870_H__
#define __RT2870_H__
#ifdef RT2870
#ifndef RTMP_USB_SUPPORT
#error "For RT2870, you should define the compile flag -DRTMP_USB_SUPPORT"
#endif
#ifndef RTMP_MAC_USB
#error "For RT2870, you should define the compile flag -DRTMP_MAC_USB"
#endif
#include "../rtmp_type.h"
#include "mac_usb.h"
/*#define RTMP_CHIP_NAME "RT2870" */
#endif /* RT2870 // */
#endif /*__RT2870_H__ // */

View file

@ -1,67 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt3070.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RT3070_H__
#define __RT3070_H__
#ifdef RT3070
#ifndef RTMP_USB_SUPPORT
#error "For RT3070, you should define the compile flag -DRTMP_USB_SUPPORT"
#endif
#ifndef RTMP_MAC_USB
#error "For RT3070, you should define the compile flag -DRTMP_MAC_USB"
#endif
#ifndef RTMP_RF_RW_SUPPORT
#error "For RT3070, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
#endif
#ifndef RT30xx
#error "For RT3070, you should define the compile flag -DRT30xx"
#endif
#include "mac_usb.h"
#include "rt30xx.h"
/* */
/* Device ID & Vendor ID, these values should match EEPROM value */
/* */
#endif /* RT3070 // */
#endif /*__RT3070_H__ // */

View file

@ -1,72 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt3090.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RT3090_H__
#define __RT3090_H__
#ifdef RT3090
#ifndef RTMP_PCI_SUPPORT
#error "For RT3090, you should define the compile flag -DRTMP_PCI_SUPPORT"
#endif
#ifndef RTMP_MAC_PCI
#error "For RT3090, you should define the compile flag -DRTMP_MAC_PCI"
#endif
#ifndef RTMP_RF_RW_SUPPORT
#error "For RT3090, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
#endif
#ifndef RT30xx
#error "For RT3090, you should define the compile flag -DRT30xx"
#endif
#define PCIE_PS_SUPPORT
#include "mac_pci.h"
#include "rt30xx.h"
/* */
/* Device ID & Vendor ID, these values should match EEPROM value */
/* */
#define NIC3090_PCIe_DEVICE_ID 0x3090 /* 1T/1R miniCard */
#define NIC3091_PCIe_DEVICE_ID 0x3091 /* 1T/2R miniCard */
#define NIC3092_PCIe_DEVICE_ID 0x3092 /* 2T/2R miniCard */
#endif /* RT3090 // */
#endif /*__RT3090_H__ // */

View file

@ -1,47 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt30xx.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RT30XX_H__
#define __RT30XX_H__
#ifdef RT30xx
extern struct rt_reg_pair RT30xx_RFRegTable[];
extern u8 NUM_RF_REG_PARMS;
#endif /* RT30xx // */
#endif /*__RT30XX_H__ // */

File diff suppressed because it is too large Load diff

View file

@ -1,516 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_phy.h
Abstract:
Ralink Wireless Chip PHY(BBP/RF) related definition & structures
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifndef __RTMP_PHY_H__
#define __RTMP_PHY_H__
/*
RF sections
*/
#define RF_R00 0
#define RF_R01 1
#define RF_R02 2
#define RF_R03 3
#define RF_R04 4
#define RF_R05 5
#define RF_R06 6
#define RF_R07 7
#define RF_R08 8
#define RF_R09 9
#define RF_R10 10
#define RF_R11 11
#define RF_R12 12
#define RF_R13 13
#define RF_R14 14
#define RF_R15 15
#define RF_R16 16
#define RF_R17 17
#define RF_R18 18
#define RF_R19 19
#define RF_R20 20
#define RF_R21 21
#define RF_R22 22
#define RF_R23 23
#define RF_R24 24
#define RF_R25 25
#define RF_R26 26
#define RF_R27 27
#define RF_R28 28
#define RF_R29 29
#define RF_R30 30
#define RF_R31 31
/* value domain of pAd->RfIcType */
#define RFIC_2820 1 /* 2.4G 2T3R */
#define RFIC_2850 2 /* 2.4G/5G 2T3R */
#define RFIC_2720 3 /* 2.4G 1T2R */
#define RFIC_2750 4 /* 2.4G/5G 1T2R */
#define RFIC_3020 5 /* 2.4G 1T1R */
#define RFIC_2020 6 /* 2.4G B/G */
#define RFIC_3021 7 /* 2.4G 1T2R */
#define RFIC_3022 8 /* 2.4G 2T2R */
#define RFIC_3052 9 /* 2.4G/5G 2T2R */
/*
BBP sections
*/
#define BBP_R0 0 /* version */
#define BBP_R1 1 /* TSSI */
#define BBP_R2 2 /* TX configure */
#define BBP_R3 3
#define BBP_R4 4
#define BBP_R5 5
#define BBP_R6 6
#define BBP_R14 14 /* RX configure */
#define BBP_R16 16
#define BBP_R17 17 /* RX sensibility */
#define BBP_R18 18
#define BBP_R21 21
#define BBP_R22 22
#define BBP_R24 24
#define BBP_R25 25
#define BBP_R26 26
#define BBP_R27 27
#define BBP_R31 31
#define BBP_R49 49 /*TSSI */
#define BBP_R50 50
#define BBP_R51 51
#define BBP_R52 52
#define BBP_R55 55
#define BBP_R62 62 /* Rx SQ0 Threshold HIGH */
#define BBP_R63 63
#define BBP_R64 64
#define BBP_R65 65
#define BBP_R66 66
#define BBP_R67 67
#define BBP_R68 68
#define BBP_R69 69
#define BBP_R70 70 /* Rx AGC SQ CCK Xcorr threshold */
#define BBP_R73 73
#define BBP_R75 75
#define BBP_R77 77
#define BBP_R78 78
#define BBP_R79 79
#define BBP_R80 80
#define BBP_R81 81
#define BBP_R82 82
#define BBP_R83 83
#define BBP_R84 84
#define BBP_R86 86
#define BBP_R91 91
#define BBP_R92 92
#define BBP_R94 94 /* Tx Gain Control */
#define BBP_R103 103
#define BBP_R105 105
#define BBP_R106 106
#define BBP_R113 113
#define BBP_R114 114
#define BBP_R115 115
#define BBP_R116 116
#define BBP_R117 117
#define BBP_R118 118
#define BBP_R119 119
#define BBP_R120 120
#define BBP_R121 121
#define BBP_R122 122
#define BBP_R123 123
#ifdef RT30xx
#define BBP_R138 138 /* add by johnli, RF power sequence setup, ADC dynamic on/off control */
#endif /* RT30xx // */
#define BBPR94_DEFAULT 0x06 /* Add 1 value will gain 1db */
/* */
/* BBP & RF are using indirect access. Before write any value into it. */
/* We have to make sure there is no outstanding command pending via checking busy bit. */
/* */
#define MAX_BUSY_COUNT 100 /* Number of retry before failing access BBP & RF indirect register */
/*#define PHY_TR_SWITCH_TIME 5 // usec */
/*#define BBP_R17_LOW_SENSIBILITY 0x50 */
/*#define BBP_R17_MID_SENSIBILITY 0x41 */
/*#define BBP_R17_DYNAMIC_UP_BOUND 0x40 */
#define RSSI_FOR_VERY_LOW_SENSIBILITY -35
#define RSSI_FOR_LOW_SENSIBILITY -58
#define RSSI_FOR_MID_LOW_SENSIBILITY -80
#define RSSI_FOR_MID_SENSIBILITY -90
/*****************************************************************************
RF register Read/Write marco definition
*****************************************************************************/
#ifdef RTMP_MAC_PCI
#define RTMP_RF_IO_WRITE32(_A, _V) \
{ \
if ((_A)->bPCIclkOff == FALSE) { \
PHY_CSR4_STRUC _value; \
unsigned long _busyCnt = 0; \
\
do { \
RTMP_IO_READ32((_A), RF_CSR_CFG0, &_value.word); \
if (_value.field.Busy == IDLE) \
break; \
_busyCnt++; \
} while (_busyCnt < MAX_BUSY_COUNT); \
if (_busyCnt < MAX_BUSY_COUNT) { \
RTMP_IO_WRITE32((_A), RF_CSR_CFG0, (_V)); \
} \
} \
}
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
#define RTMP_RF_IO_WRITE32(_A, _V) RTUSBWriteRFRegister(_A, _V)
#endif /* RTMP_MAC_USB // */
#ifdef RT30xx
#define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV) RT30xxReadRFRegister(_A, _I, _pV)
#define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V) RT30xxWriteRFRegister(_A, _I, _V)
#endif /* RT30xx // */
/*****************************************************************************
BBP register Read/Write marco definitions.
we read/write the bbp value by register's ID.
Generate PER to test BA
*****************************************************************************/
#ifdef RTMP_MAC_PCI
/*
basic marco for BBP read operation.
_pAd: the data structure pointer of struct rt_rtmp_adapter
_bbpID : the bbp register ID
_pV: data pointer used to save the value of queried bbp register.
_bViaMCU: if we need access the bbp via the MCU.
*/
#define RTMP_BBP_IO_READ8(_pAd, _bbpID, _pV, _bViaMCU) \
do { \
BBP_CSR_CFG_STRUC BbpCsr; \
int _busyCnt, _secCnt, _regID; \
\
_regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \
for (_busyCnt = 0; _busyCnt < MAX_BUSY_COUNT; _busyCnt++) { \
RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) \
continue; \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 1; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.RegNum = _bbpID; \
RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \
if ((_bViaMCU) == TRUE) { \
AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
RTMPusecDelay(1000); \
} \
for (_secCnt = 0; _secCnt < MAX_BUSY_COUNT; _secCnt++) { \
RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
if (BbpCsr.field.Busy == IDLE) \
break; \
} \
if ((BbpCsr.field.Busy == IDLE) && \
(BbpCsr.field.RegNum == _bbpID)) { \
*(_pV) = (u8)BbpCsr.field.Value; \
break; \
} \
} \
if (BbpCsr.field.Busy == BUSY) { \
DBGPRINT_ERR("BBP(viaMCU=%d) read R%d fail\n", (_bViaMCU), _bbpID); \
*(_pV) = (_pAd)->BbpWriteLatch[_bbpID]; \
if ((_bViaMCU) == TRUE) { \
RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
BbpCsr.field.Busy = 0; \
RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \
} \
} \
} while (0)
/*
This marco used for the BBP read operation which didn't need via MCU.
*/
#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE)
/*
This marco used for the BBP read operation which need via MCU.
But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
will use this function too and didn't access the bbp register via the MCU.
*/
/* Read BBP register by register's ID. Generate PER to test BA */
#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
{ \
BBP_CSR_CFG_STRUC BbpCsr; \
int i, k; \
BOOLEAN brc; \
BbpCsr.field.Busy = IDLE; \
if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \
&& ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
&& ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE) \
&& ((_A)->bPCIclkOff == FALSE) \
&& ((_A)->brt30xxBanMcuCmd == FALSE)) { \
for (i = 0; i < MAX_BUSY_COUNT; i++) { \
RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) { \
continue; \
} \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 1; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.RegNum = _I; \
RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
if (brc == TRUE) { \
for (k = 0; k < MAX_BUSY_COUNT; k++) { \
RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
if (BbpCsr.field.Busy == IDLE) \
break; \
} \
if ((BbpCsr.field.Busy == IDLE) && \
(BbpCsr.field.RegNum == _I)) { \
*(_pV) = (u8)BbpCsr.field.Value; \
break; \
} \
} else { \
BbpCsr.field.Busy = 0; \
RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
} \
} \
} \
else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
&& ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)) \
&& ((_A)->bPCIclkOff == FALSE)) { \
for (i = 0; i < MAX_BUSY_COUNT; i++) { \
RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) { \
continue; \
} \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 1; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.RegNum = _I; \
RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
for (k = 0; k < MAX_BUSY_COUNT; k++) { \
RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
if (BbpCsr.field.Busy == IDLE) \
break; \
} \
if ((BbpCsr.field.Busy == IDLE) && \
(BbpCsr.field.RegNum == _I)) { \
*(_pV) = (u8)BbpCsr.field.Value; \
break; \
} \
} \
} else { \
DBGPRINT_ERR(" , brt30xxBanMcuCmd = %d, Read BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I)); \
*(_pV) = (_A)->BbpWriteLatch[_I]; \
} \
if ((BbpCsr.field.Busy == BUSY) || ((_A)->bPCIclkOff == TRUE)) { \
DBGPRINT_ERR("BBP read R%d=0x%x fail\n", _I, BbpCsr.word); \
*(_pV) = (_A)->BbpWriteLatch[_I]; \
} \
}
/*
basic marco for BBP write operation.
_pAd: the data structure pointer of struct rt_rtmp_adapter
_bbpID : the bbp register ID
_pV: data used to save the value of queried bbp register.
_bViaMCU: if we need access the bbp via the MCU.
*/
#define RTMP_BBP_IO_WRITE8(_pAd, _bbpID, _pV, _bViaMCU) \
do { \
BBP_CSR_CFG_STRUC BbpCsr; \
int _busyCnt, _regID; \
\
_regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \
for (_busyCnt = 0; _busyCnt < MAX_BUSY_COUNT; _busyCnt++) { \
RTMP_IO_READ32((_pAd), BBP_CSR_CFG, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) \
continue; \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 0; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.Value = _pV; \
BbpCsr.field.RegNum = _bbpID; \
RTMP_IO_WRITE32((_pAd), BBP_CSR_CFG, BbpCsr.word); \
if ((_bViaMCU) == TRUE) { \
AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
if ((_pAd)->OpMode == OPMODE_AP) \
RTMPusecDelay(1000); \
} \
(_pAd)->BbpWriteLatch[_bbpID] = _pV; \
break; \
} \
if (_busyCnt == MAX_BUSY_COUNT) { \
DBGPRINT_ERR("BBP write R%d fail\n", _bbpID); \
if ((_bViaMCU) == TRUE) { \
RTMP_IO_READ32(_pAd, H2M_BBP_AGENT, &BbpCsr.word); \
BbpCsr.field.Busy = 0; \
RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, BbpCsr.word); \
} \
} \
} while (0)
/*
This marco used for the BBP write operation which didn't need via MCU.
*/
#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV) \
RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE)
/*
This marco used for the BBP write operation which need via MCU.
But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
will use this function too and didn't access the bbp register via the MCU.
*/
/* Write BBP register by register's ID & value */
#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) \
{ \
BBP_CSR_CFG_STRUC BbpCsr; \
int BusyCnt = 0; \
BOOLEAN brc; \
if (_I < MAX_NUM_OF_BBP_LATCH) { \
if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \
&& ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
&& ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE) \
&& ((_A)->bPCIclkOff == FALSE) \
&& ((_A)->brt30xxBanMcuCmd == FALSE)) { \
if (_A->AccessBBPFailCount > 20) { \
AsicResetBBPAgent(_A); \
_A->AccessBBPFailCount = 0; \
} \
for (BusyCnt = 0; BusyCnt < MAX_BUSY_COUNT; BusyCnt++) { \
RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) \
continue; \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 0; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.Value = _V; \
BbpCsr.field.RegNum = _I; \
RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
if (brc == TRUE) { \
(_A)->BbpWriteLatch[_I] = _V; \
} else { \
BbpCsr.field.Busy = 0; \
RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
} \
break; \
} \
} \
else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \
&& ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
&& ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)) \
&& ((_A)->bPCIclkOff == FALSE)) { \
if (_A->AccessBBPFailCount > 20) { \
AsicResetBBPAgent(_A); \
_A->AccessBBPFailCount = 0; \
} \
for (BusyCnt = 0; BusyCnt < MAX_BUSY_COUNT; BusyCnt++) { \
RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) \
continue; \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 0; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.Value = _V; \
BbpCsr.field.RegNum = _I; \
RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
(_A)->BbpWriteLatch[_I] = _V; \
break; \
} \
} else { \
DBGPRINT_ERR(" brt30xxBanMcuCmd = %d. Write BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I)); \
} \
if ((BusyCnt == MAX_BUSY_COUNT) || ((_A)->bPCIclkOff == TRUE)) { \
if (BusyCnt == MAX_BUSY_COUNT) \
(_A)->AccessBBPFailCount++; \
DBGPRINT_ERR("BBP write R%d=0x%x fail. BusyCnt= %d.bPCIclkOff = %d. \n", _I, BbpCsr.word, BusyCnt, (_A)->bPCIclkOff); \
} \
} else { \
DBGPRINT_ERR("****** BBP_Write_Latch Buffer exceeds max boundary ****** \n"); \
} \
}
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
#endif /* RTMP_MAC_USB // */
#ifdef RT30xx
#define RTMP_ASIC_MMPS_DISABLE(_pAd) \
do { \
u32 _macData; \
u8 _bbpData = 0; \
/* disable MMPS BBP control register */ \
RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData); \
_bbpData &= ~(0x04); /*bit 2*/ \
RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData); \
\
/* disable MMPS MAC control register */ \
RTMP_IO_READ32(_pAd, 0x1210, &_macData); \
_macData &= ~(0x09); /*bit 0, 3*/ \
RTMP_IO_WRITE32(_pAd, 0x1210, _macData); \
} while (0)
#define RTMP_ASIC_MMPS_ENABLE(_pAd) \
do { \
u32 _macData; \
u8 _bbpData = 0; \
/* enable MMPS BBP control register */ \
RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData); \
_bbpData |= (0x04); /*bit 2*/ \
RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData); \
\
/* enable MMPS MAC control register */ \
RTMP_IO_READ32(_pAd, 0x1210, &_macData); \
_macData |= (0x09); /*bit 0, 3*/ \
RTMP_IO_WRITE32(_pAd, 0x1210, _macData); \
} while (0)
#endif /* RT30xx // */
#endif /* __RTMP_PHY_H__ // */

View file

@ -1,169 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt3070.c
Abstract:
Specific funcitons and variables for RT3070
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifdef RT3070
#include "../rt_config.h"
#ifndef RTMP_RF_RW_SUPPORT
#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
#endif /* RTMP_RF_RW_SUPPORT // */
void NICInitRT3070RFRegisters(struct rt_rtmp_adapter *pAd)
{
int i;
u8 RFValue;
/* Driver must read EEPROM to get RfIcType before initial RF registers */
/* Initialize RF register to default value */
if (IS_RT3070(pAd) || IS_RT3071(pAd)) {
/* Init RF calibration */
/* Driver should toggle RF R30 bit7 before init RF registers */
u32 RfReg = 0;
u32 data;
RT30xxReadRFRegister(pAd, RF_R30, (u8 *)&RfReg);
RfReg |= 0x80;
RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
RTMPusecDelay(1000);
RfReg &= 0x7F;
RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
/* Initialize RF register to default value */
for (i = 0; i < NUM_RF_REG_PARMS; i++) {
RT30xxWriteRFRegister(pAd,
RT30xx_RFRegTable[i].Register,
RT30xx_RFRegTable[i].Value);
}
/* add by johnli */
if (IS_RT3070(pAd)) {
/* */
/* The DAC issue(LDO_CFG0) has been fixed in RT3070(F). */
/* The voltage raising patch is no longer needed for RT3070(F) */
/* */
if ((pAd->MACVersion & 0xffff) < 0x0201) {
/* Update MAC 0x05D4 from 01xxxxxx to 0Dxxxxxx (voltage 1.2V to 1.35V) for RT3070 to improve yield rate */
RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
data = ((data & 0xF0FFFFFF) | 0x0D000000);
RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
}
} else if (IS_RT3071(pAd)) {
/* Driver should set RF R6 bit6 on before init RF registers */
RT30xxReadRFRegister(pAd, RF_R06, (u8 *)&RfReg);
RfReg |= 0x40;
RT30xxWriteRFRegister(pAd, RF_R06, (u8)RfReg);
/* init R31 */
RT30xxWriteRFRegister(pAd, RF_R31, 0x14);
/* RT3071 version E has fixed this issue */
if ((pAd->NicConfig2.field.DACTestBit == 1)
&& ((pAd->MACVersion & 0xffff) < 0x0211)) {
/* patch tx EVM issue temporarily */
RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
data = ((data & 0xE0FFFFFF) | 0x0D000000);
RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
} else {
RTMP_IO_READ32(pAd, LDO_CFG0, &data);
data = ((data & 0xE0FFFFFF) | 0x01000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
}
/* patch LNA_PE_G1 failed issue */
RTUSBReadMACRegister(pAd, GPIO_SWITCH, &data);
data &= ~(0x20);
RTUSBWriteMACRegister(pAd, GPIO_SWITCH, data);
}
/*For RF filter Calibration */
RTMPFilterCalibration(pAd);
/* Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration() */
/* */
/* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
/* Raising RF voltage is no longer needed for RT3070(F) */
/* */
if ((IS_RT3070(pAd)) && ((pAd->MACVersion & 0xffff) < 0x0201)) {
RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
} else if ((IS_RT3071(pAd))
&& ((pAd->MACVersion & 0xffff) < 0x0211)) {
RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
}
/* set led open drain enable */
RTUSBReadMACRegister(pAd, OPT_14, &data);
data |= 0x01;
RTUSBWriteMACRegister(pAd, OPT_14, data);
/* move from RT30xxLoadRFNormalModeSetup because it's needed for both RT3070 and RT3071 */
/* TX_LO1_en, RF R17 register Bit 3 to 0 */
RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
RFValue &= (~0x08);
/* to fix rx long range issue */
if (pAd->NicConfig2.field.ExternalLNAForG == 0) {
if ((IS_RT3071(pAd)
&& ((pAd->MACVersion & 0xffff) >= 0x0211))
|| IS_RT3070(pAd)) {
RFValue |= 0x20;
}
}
/* set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h */
if (pAd->TxMixerGain24G >= 1) {
RFValue &= (~0x7); /* clean bit [2:0] */
RFValue |= pAd->TxMixerGain24G;
}
RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
if (IS_RT3071(pAd)) {
/* add by johnli, RF power sequence setup, load RF normal operation-mode setup */
RT30xxLoadRFNormalModeSetup(pAd);
} else if (IS_RT3070(pAd)) {
/* add by johnli, reset RF_R27 when interface down & up to fix throughput problem */
/* LDORF_VC, RF R27 register Bit 2 to 0 */
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
/* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
/* Raising RF voltage is no longer needed for RT3070(F) */
if ((pAd->MACVersion & 0xffff) < 0x0201)
RFValue = (RFValue & (~0x77)) | 0x3;
else
RFValue = (RFValue & (~0x77));
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
/* end johnli */
}
}
}
#endif /* RT3070 // */

View file

@ -1,121 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt3090.c
Abstract:
Specific functions and variables for RT3070
Revision History:
Who When What
Justin P. Mattock 11/07/2010 Fix a typo
-------- ---------- ----------------------------------------------
*/
#ifdef RT3090
#include "../rt_config.h"
#ifndef RTMP_RF_RW_SUPPORT
#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
#endif /* RTMP_RF_RW_SUPPORT // */
void NICInitRT3090RFRegisters(struct rt_rtmp_adapter *pAd)
{
int i;
/* Driver must read EEPROM to get RfIcType before initial RF registers */
/* Initialize RF register to default value */
if (IS_RT3090(pAd)) {
/* Init RF calibration */
/* Driver should toggle RF R30 bit7 before init RF registers */
u8 RfReg;
u32 data;
RT30xxReadRFRegister(pAd, RF_R30, (u8 *)&RfReg);
RfReg |= 0x80;
RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
RTMPusecDelay(1000);
RfReg &= 0x7F;
RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
/* init R24, R31 */
RT30xxWriteRFRegister(pAd, RF_R24, 0x0F);
RT30xxWriteRFRegister(pAd, RF_R31, 0x0F);
/* RT309x version E has fixed this issue */
if ((pAd->NicConfig2.field.DACTestBit == 1)
&& ((pAd->MACVersion & 0xffff) < 0x0211)) {
/* patch tx EVM issue temporarily */
RTMP_IO_READ32(pAd, LDO_CFG0, &data);
data = ((data & 0xE0FFFFFF) | 0x0D000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
} else {
RTMP_IO_READ32(pAd, LDO_CFG0, &data);
data = ((data & 0xE0FFFFFF) | 0x01000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
}
/* patch LNA_PE_G1 failed issue */
RTMP_IO_READ32(pAd, GPIO_SWITCH, &data);
data &= ~(0x20);
RTMP_IO_WRITE32(pAd, GPIO_SWITCH, data);
/* Initialize RF register to default value */
for (i = 0; i < NUM_RF_REG_PARMS; i++) {
RT30xxWriteRFRegister(pAd,
RT30xx_RFRegTable[i].Register,
RT30xx_RFRegTable[i].Value);
}
/* Driver should set RF R6 bit6 on before calibration */
RT30xxReadRFRegister(pAd, RF_R06, (u8 *)&RfReg);
RfReg |= 0x40;
RT30xxWriteRFRegister(pAd, RF_R06, (u8)RfReg);
/*For RF filter Calibration */
RTMPFilterCalibration(pAd);
/* Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration() */
if ((pAd->MACVersion & 0xffff) < 0x0211)
RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
/* set led open drain enable */
RTMP_IO_READ32(pAd, OPT_14, &data);
data |= 0x01;
RTMP_IO_WRITE32(pAd, OPT_14, data);
/* set default antenna as main */
if (pAd->RfIcType == RFIC_3020)
AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
/* add by johnli, RF power sequence setup, load RF normal operation-mode setup */
RT30xxLoadRFNormalModeSetup(pAd);
}
}
#endif /* RT3090 // */

View file

@ -1,516 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt30xx.c
Abstract:
Specific functions and variables for RT30xx.
Revision History:
Who When What
Justin P. Mattock 11/07/2010 Fix some typos
-------- ---------- ----------------------------------------------
*/
#ifdef RT30xx
#ifndef RTMP_RF_RW_SUPPORT
#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
#endif /* RTMP_RF_RW_SUPPORT // */
#include "../rt_config.h"
/* */
/* RF register initialization set */
/* */
struct rt_reg_pair RT30xx_RFRegTable[] = {
{RF_R04, 0x40}
,
{RF_R05, 0x03}
,
{RF_R06, 0x02}
,
{RF_R07, 0x60}
,
{RF_R09, 0x0F}
,
{RF_R10, 0x41}
,
{RF_R11, 0x21}
,
{RF_R12, 0x7B}
,
{RF_R14, 0x90}
,
{RF_R15, 0x58}
,
{RF_R16, 0xB3}
,
{RF_R17, 0x92}
,
{RF_R18, 0x2C}
,
{RF_R19, 0x02}
,
{RF_R20, 0xBA}
,
{RF_R21, 0xDB}
,
{RF_R24, 0x16}
,
{RF_R25, 0x01}
,
{RF_R29, 0x1F}
,
};
u8 NUM_RF_REG_PARMS = (sizeof(RT30xx_RFRegTable) / sizeof(struct rt_reg_pair));
/* Antenna diversity use GPIO3 and EESK pin for control */
/* Antenna and EEPROM access are both using EESK pin, */
/* Therefor we should avoid accessing EESK at the same time */
/* Then restore antenna after EEPROM access */
/* The original name of this function is AsicSetRxAnt(), now change to */
/*void AsicSetRxAnt( */
void RT30xxSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant)
{
u32 Value;
#ifdef RTMP_MAC_PCI
u32 x;
#endif
if ((pAd->EepromAccess) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
return;
}
/* the antenna selection is through firmware and MAC register(GPIO3) */
if (Ant == 0) {
/* Main antenna */
#ifdef RTMP_MAC_PCI
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x |= (EESK);
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
#else
AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x1, 0x0);
#endif /* RTMP_MAC_PCI // */
RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
Value &= ~(0x0808);
RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
DBGPRINT_RAW(RT_DEBUG_TRACE,
("AsicSetRxAnt, switch to main antenna\n"));
} else {
/* Aux antenna */
#ifdef RTMP_MAC_PCI
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x &= ~(EESK);
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
#else
AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x0, 0x0);
#endif /* RTMP_MAC_PCI // */
RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
Value &= ~(0x0808);
Value |= 0x08;
RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
DBGPRINT_RAW(RT_DEBUG_TRACE,
("AsicSetRxAnt, switch to aux antenna\n"));
}
}
/*
========================================================================
Routine Description:
For RF filter calibration purpose
Arguments:
pAd Pointer to our adapter
Return Value:
None
IRQL = PASSIVE_LEVEL
========================================================================
*/
void RTMPFilterCalibration(struct rt_rtmp_adapter *pAd)
{
u8 R55x = 0, value, FilterTarget = 0x1E, BBPValue = 0;
u32 loop = 0, count = 0, loopcnt = 0, ReTry = 0;
u8 RF_R24_Value = 0;
/* Give bbp filter initial value */
pAd->Mlme.CaliBW20RfR24 = 0x1F;
pAd->Mlme.CaliBW40RfR24 = 0x2F; /*Bit[5] must be 1 for BW 40 */
do {
if (loop == 1) { /*BandWidth = 40 MHz */
/* Write 0x27 to RF_R24 to program filter */
RF_R24_Value = 0x27;
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
FilterTarget = 0x15;
else
FilterTarget = 0x19;
/* when calibrate BW40, BBP mask must set to BW40. */
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
BBPValue |= (0x10);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
/* set to BW40 */
RT30xxReadRFRegister(pAd, RF_R31, &value);
value |= 0x20;
RT30xxWriteRFRegister(pAd, RF_R31, value);
} else { /*BandWidth = 20 MHz */
/* Write 0x07 to RF_R24 to program filter */
RF_R24_Value = 0x07;
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
FilterTarget = 0x13;
else
FilterTarget = 0x16;
/* set to BW20 */
RT30xxReadRFRegister(pAd, RF_R31, &value);
value &= (~0x20);
RT30xxWriteRFRegister(pAd, RF_R31, value);
}
/* Write 0x01 to RF_R22 to enable baseband loopback mode */
RT30xxReadRFRegister(pAd, RF_R22, &value);
value |= 0x01;
RT30xxWriteRFRegister(pAd, RF_R22, value);
/* Write 0x00 to BBP_R24 to set power & frequency of passband test tone */
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
do {
/* Write 0x90 to BBP_R25 to transmit test tone */
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
RTMPusecDelay(1000);
/* Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0] */
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
R55x = value & 0xFF;
} while ((ReTry++ < 100) && (R55x == 0));
/* Write 0x06 to BBP_R24 to set power & frequency of stopband test tone */
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0x06);
while (TRUE) {
/* Write 0x90 to BBP_R25 to transmit test tone */
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
/*We need to wait for calibration */
RTMPusecDelay(1000);
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
value &= 0xFF;
if ((R55x - value) < FilterTarget) {
RF_R24_Value++;
} else if ((R55x - value) == FilterTarget) {
RF_R24_Value++;
count++;
} else {
break;
}
/* prevent infinite loop; causes driver hang. */
if (loopcnt++ > 100) {
DBGPRINT(RT_DEBUG_ERROR,
("RTMPFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating",
loopcnt));
break;
}
/* Write RF_R24 to program filter */
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
}
if (count > 0) {
RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0));
}
/* Store for future usage */
if (loopcnt < 100) {
if (loop++ == 0) {
/*BandWidth = 20 MHz */
pAd->Mlme.CaliBW20RfR24 = (u8)RF_R24_Value;
} else {
/*BandWidth = 40 MHz */
pAd->Mlme.CaliBW40RfR24 = (u8)RF_R24_Value;
break;
}
} else
break;
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
/* reset count */
count = 0;
} while (TRUE);
/* */
/* Set back to initial state */
/* */
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
RT30xxReadRFRegister(pAd, RF_R22, &value);
value &= ~(0x01);
RT30xxWriteRFRegister(pAd, RF_R22, value);
/* set BBP back to BW20 */
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
DBGPRINT(RT_DEBUG_TRACE,
("RTMPFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n",
pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24));
}
/* add by johnli, RF power sequence setup */
/*
==========================================================================
Description:
Load RF normal operation-mode setup
==========================================================================
*/
void RT30xxLoadRFNormalModeSetup(struct rt_rtmp_adapter *pAd)
{
u8 RFValue;
/* RX0_PD & TX0_PD, RF R1 register Bit 2 & Bit 3 to 0 and RF_BLOCK_en,RX1_PD & TX1_PD, Bit0, Bit 4 & Bit5 to 1 */
RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
RFValue = (RFValue & (~0x0C)) | 0x31;
RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
/* TX_LO2_en, RF R15 register Bit 3 to 0 */
RT30xxReadRFRegister(pAd, RF_R15, &RFValue);
RFValue &= (~0x08);
RT30xxWriteRFRegister(pAd, RF_R15, RFValue);
/* move to NICInitRT30xxRFRegisters
// TX_LO1_en, RF R17 register Bit 3 to 0
RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
RFValue &= (~0x08);
// to fix rx long range issue
if (((pAd->MACVersion & 0xffff) >= 0x0211) && (pAd->NicConfig2.field.ExternalLNAForG == 0))
{
RFValue |= 0x20;
}
// set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h
if (pAd->TxMixerGain24G >= 2)
{
RFValue &= (~0x7); // clean bit [2:0]
RFValue |= pAd->TxMixerGain24G;
}
RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
*/
/* RX_LO1_en, RF R20 register Bit 3 to 0 */
RT30xxReadRFRegister(pAd, RF_R20, &RFValue);
RFValue &= (~0x08);
RT30xxWriteRFRegister(pAd, RF_R20, RFValue);
/* RX_LO2_en, RF R21 register Bit 3 to 0 */
RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
RFValue &= (~0x08);
RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
/* add by johnli, reset RF_R27 when interface down & up to fix throughput problem */
/* LDORF_VC, RF R27 register Bit 2 to 0 */
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
/* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
/* Raising RF voltage is no longer needed for RT3070(F) */
if (IS_RT3090(pAd)) { /* RT309x and RT3071/72 */
if ((pAd->MACVersion & 0xffff) < 0x0211)
RFValue = (RFValue & (~0x77)) | 0x3;
else
RFValue = (RFValue & (~0x77));
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
}
/* end johnli */
}
/*
==========================================================================
Description:
Load RF sleep-mode setup
==========================================================================
*/
void RT30xxLoadRFSleepModeSetup(struct rt_rtmp_adapter *pAd)
{
u8 RFValue;
u32 MACValue;
#ifdef RTMP_MAC_USB
if (!IS_RT3572(pAd))
#endif /* RTMP_MAC_USB // */
{
/* RF_BLOCK_en. RF R1 register Bit 0 to 0 */
RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
RFValue &= (~0x01);
RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
/* VCO_IC, RF R7 register Bit 4 & Bit 5 to 0 */
RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
RFValue &= (~0x30);
RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
/* Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 0 */
RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
RFValue &= (~0x0E);
RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
/* RX_CTB_en, RF R21 register Bit 7 to 0 */
RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
RFValue &= (~0x80);
RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
}
if (IS_RT3090(pAd) || /* IS_RT3090 including RT309x and RT3071/72 */
IS_RT3572(pAd) ||
(IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201))) {
#ifdef RTMP_MAC_USB
if (!IS_RT3572(pAd))
#endif /* RTMP_MAC_USB // */
{
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
RFValue |= 0x77;
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
}
RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
MACValue |= 0x1D000000;
RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
}
}
/*
==========================================================================
Description:
Reverse RF sleep-mode setup
==========================================================================
*/
void RT30xxReverseRFSleepModeSetup(struct rt_rtmp_adapter *pAd)
{
u8 RFValue;
u32 MACValue;
#ifdef RTMP_MAC_USB
if (!IS_RT3572(pAd))
#endif /* RTMP_MAC_USB // */
{
/* RF_BLOCK_en, RF R1 register Bit 0 to 1 */
RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
RFValue |= 0x01;
RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
/* VCO_IC, RF R7 register Bit 4 & Bit 5 to 1 */
RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
RFValue |= 0x20;
RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
/* Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 1 */
RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
RFValue |= 0x0E;
RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
/* RX_CTB_en, RF R21 register Bit 7 to 1 */
RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
RFValue |= 0x80;
RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
}
if (IS_RT3090(pAd) || /* IS_RT3090 including RT309x and RT3071/72 */
IS_RT3572(pAd) ||
IS_RT3390(pAd) ||
(IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201))) {
#ifdef RTMP_MAC_USB
if (!IS_RT3572(pAd))
#endif /* RTMP_MAC_USB // */
{
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
if ((pAd->MACVersion & 0xffff) < 0x0211)
RFValue = (RFValue & (~0x77)) | 0x3;
else
RFValue = (RFValue & (~0x77));
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
}
/* RT3071 version E has fixed this issue */
if ((pAd->NicConfig2.field.DACTestBit == 1)
&& ((pAd->MACVersion & 0xffff) < 0x0211)) {
/* patch tx EVM issue temporarily */
RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
MACValue = ((MACValue & 0xE0FFFFFF) | 0x0D000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
} else {
RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
MACValue = ((MACValue & 0xE0FFFFFF) | 0x01000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
}
}
if (IS_RT3572(pAd))
RT30xxWriteRFRegister(pAd, RF_R08, 0x80);
}
/* end johnli */
void RT30xxHaltAction(struct rt_rtmp_adapter *pAd)
{
u32 TxPinCfg = 0x00050F0F;
/* */
/* Turn off LNA_PE or TRSW_POL */
/* */
if (IS_RT3070(pAd) || IS_RT3071(pAd) || IS_RT3572(pAd)) {
if ((IS_RT3071(pAd) || IS_RT3572(pAd))
#ifdef RTMP_EFUSE_SUPPORT
&& (pAd->bUseEfuse)
#endif /* RTMP_EFUSE_SUPPORT // */
) {
TxPinCfg &= 0xFFFBF0F0; /* bit18 off */
} else {
TxPinCfg &= 0xFFFFF0F0;
}
RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
}
}
#endif /* RT30xx // */

View file

@ -1,113 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
chlist.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Fonchi Wu 2007-12-19 created
*/
#ifndef __CHLIST_H__
#define __CHLIST_H__
#include "rtmp_type.h"
#include "rtmp_def.h"
#define ODOR 0
#define IDOR 1
#define BOTH 2
#define BAND_5G 0
#define BAND_24G 1
#define BAND_BOTH 2
struct rt_ch_desp {
u8 FirstChannel;
u8 NumOfCh;
char MaxTxPwr; /* dBm */
u8 Geography; /* 0:out door, 1:in door, 2:both */
BOOLEAN DfsReq; /* Dfs require, 0: No, 1: yes. */
};
struct rt_ch_region {
u8 CountReg[3];
u8 DfsType; /* 0: CE, 1: FCC, 2: JAP, 3:JAP_W53, JAP_W56 */
struct rt_ch_desp ChDesp[10];
};
extern struct rt_ch_region ChRegion[];
struct rt_ch_freq_map {
u16 channel;
u16 freqKHz;
};
extern struct rt_ch_freq_map CH_HZ_ID_MAP[];
extern int CH_HZ_ID_MAP_NUM;
#define MAP_CHANNEL_ID_TO_KHZ(_ch, _khz) \
do { \
int _chIdx; \
for (_chIdx = 0; _chIdx < CH_HZ_ID_MAP_NUM; _chIdx++) {\
if ((_ch) == CH_HZ_ID_MAP[_chIdx].channel) { \
(_khz) = CH_HZ_ID_MAP[_chIdx].freqKHz * 1000;\
break; \
} \
} \
if (_chIdx == CH_HZ_ID_MAP_NUM) \
(_khz) = 2412000; \
} while (0)
#define MAP_KHZ_TO_CHANNEL_ID(_khz, _ch) \
do { \
int _chIdx; \
for (_chIdx = 0; _chIdx < CH_HZ_ID_MAP_NUM; _chIdx++) {\
if ((_khz) == CH_HZ_ID_MAP[_chIdx].freqKHz) {\
(_ch) = CH_HZ_ID_MAP[_chIdx].channel; \
break; \
} \
} \
if (_chIdx == CH_HZ_ID_MAP_NUM) \
(_ch) = 1; \
} while (0)
void BuildChannelListEx(struct rt_rtmp_adapter *pAd);
void BuildBeaconChList(struct rt_rtmp_adapter *pAd,
u8 *pBuf, unsigned long *pBufLen);
void N_ChannelCheck(struct rt_rtmp_adapter *pAd);
void N_SetCenCh(struct rt_rtmp_adapter *pAd);
u8 GetCuntryMaxTxPwr(struct rt_rtmp_adapter *pAd, u8 channel);
#endif /* __CHLIST_H__ */

View file

@ -1,606 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
action.c
Abstract:
Handle association related requests either from WSTA or from local MLME
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Jan Lee 2006 created for rt2860
*/
#include "../rt_config.h"
#include "action.h"
static void ReservedAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
/*
==========================================================================
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
MT2_MLME_DISASSOC_REQ mlme_disassoc_req_action
MT2_PEER_DISASSOC_REQ peer_disassoc_action
MT2_PEER_ASSOC_REQ drop
MT2_PEER_REASSOC_REQ drop
MT2_CLS3ERR cls3err_action
==========================================================================
*/
void ActionStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *S,
OUT STATE_MACHINE_FUNC Trans[])
{
StateMachineInit(S, (STATE_MACHINE_FUNC *) Trans, MAX_ACT_STATE,
MAX_ACT_MSG, (STATE_MACHINE_FUNC) Drop, ACT_IDLE,
ACT_MACHINE_BASE);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE,
(STATE_MACHINE_FUNC) PeerSpectrumAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE,
(STATE_MACHINE_FUNC) PeerQOSAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE,
(STATE_MACHINE_FUNC) ReservedAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE,
(STATE_MACHINE_FUNC) PeerBAAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE,
(STATE_MACHINE_FUNC) PeerHTAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE,
(STATE_MACHINE_FUNC) MlmeADDBAAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE,
(STATE_MACHINE_FUNC) MlmeDELBAAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE,
(STATE_MACHINE_FUNC) MlmeDELBAAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE,
(STATE_MACHINE_FUNC) PeerPublicAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE,
(STATE_MACHINE_FUNC) PeerRMAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE,
(STATE_MACHINE_FUNC) MlmeQOSAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE,
(STATE_MACHINE_FUNC) MlmeDLSAction);
StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID,
(STATE_MACHINE_FUNC) MlmeInvalidAction);
}
void MlmeADDBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
struct rt_mlme_addba_req *pInfo;
u8 Addr[6];
u8 *pOutBuffer = NULL;
int NStatus;
unsigned long Idx;
struct rt_frame_addba_req Frame;
unsigned long FrameLen;
struct rt_ba_ori_entry *pBAEntry = NULL;
pInfo = (struct rt_mlme_addba_req *)Elem->Msg;
NdisZeroMemory(&Frame, sizeof(struct rt_frame_addba_req));
if (MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr)) {
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("BA - MlmeADDBAAction() allocate memory failed \n"));
return;
}
/* 1. find entry */
Idx =
pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
if (Idx == 0) {
MlmeFreeMemory(pAd, pOutBuffer);
DBGPRINT(RT_DEBUG_ERROR,
("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
return;
} else {
pBAEntry = &pAd->BATable.BAOriEntry[Idx];
}
{
if (ADHOC_ON(pAd))
ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr,
pAd->CurrentAddress,
pAd->CommonCfg.Bssid);
else
ActHeaderInit(pAd, &Frame.Hdr,
pAd->CommonCfg.Bssid,
pAd->CurrentAddress,
pInfo->pAddr);
}
Frame.Category = CATEGORY_BA;
Frame.Action = ADDBA_REQ;
Frame.BaParm.AMSDUSupported = 0;
Frame.BaParm.BAPolicy = IMMED_BA;
Frame.BaParm.TID = pInfo->TID;
Frame.BaParm.BufSize = pInfo->BaBufSize;
Frame.Token = pInfo->Token;
Frame.TimeOutValue = pInfo->TimeOutValue;
Frame.BaStartSeq.field.FragNum = 0;
Frame.BaStartSeq.field.StartSeq =
pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
*(u16 *) (&Frame.BaParm) =
cpu2le16(*(u16 *) (&Frame.BaParm));
Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(struct rt_frame_addba_req), &Frame, END_OF_ARGS);
MiniportMMRequest(pAd,
(MGMT_USE_QUEUE_FLAG |
MapUserPriorityToAccessCategory[pInfo->TID]),
pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
DBGPRINT(RT_DEBUG_TRACE,
("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n",
Frame.BaStartSeq.field.StartSeq, FrameLen,
Frame.BaParm.BufSize));
}
}
/*
==========================================================================
Description:
send DELBA and delete BaEntry if any
Parametrs:
Elem - MLME message struct rt_mlme_delba_req
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void MlmeDELBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
struct rt_mlme_delba_req *pInfo;
u8 *pOutBuffer = NULL;
u8 *pOutBuffer2 = NULL;
int NStatus;
unsigned long Idx;
struct rt_frame_delba_req Frame;
unsigned long FrameLen;
struct rt_frame_bar FrameBar;
pInfo = (struct rt_mlme_delba_req *)Elem->Msg;
/* must send back DELBA */
NdisZeroMemory(&Frame, sizeof(struct rt_frame_delba_req));
DBGPRINT(RT_DEBUG_TRACE,
("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
if (MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen)) {
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_ERROR,
("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
return;
}
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS) {
MlmeFreeMemory(pAd, pOutBuffer);
DBGPRINT(RT_DEBUG_ERROR,
("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
return;
}
/* SEND BAR (Send BAR to refresh peer reordering buffer.) */
Idx =
pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
BarHeaderInit(pAd, &FrameBar,
pAd->MacTab.Content[pInfo->Wcid].Addr,
pAd->CurrentAddress);
FrameBar.StartingSeq.field.FragNum = 0; /* make sure sequence not clear in DEL funciton. */
FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; /* make sure sequence not clear in DEL funciton. */
FrameBar.BarControl.TID = pInfo->TID; /* make sure sequence not clear in DEL funciton. */
FrameBar.BarControl.ACKPolicy = IMMED_BA; /* make sure sequence not clear in DEL funciton. */
FrameBar.BarControl.Compressed = 1; /* make sure sequence not clear in DEL funciton. */
FrameBar.BarControl.MTID = 0; /* make sure sequence not clear in DEL funciton. */
MakeOutgoingFrame(pOutBuffer2, &FrameLen,
sizeof(struct rt_frame_bar), &FrameBar, END_OF_ARGS);
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer2);
DBGPRINT(RT_DEBUG_TRACE,
("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
/* SEND DELBA FRAME */
FrameLen = 0;
{
if (ADHOC_ON(pAd))
ActHeaderInit(pAd, &Frame.Hdr,
pAd->MacTab.Content[pInfo->Wcid].
Addr, pAd->CurrentAddress,
pAd->CommonCfg.Bssid);
else
ActHeaderInit(pAd, &Frame.Hdr,
pAd->CommonCfg.Bssid,
pAd->CurrentAddress,
pAd->MacTab.Content[pInfo->Wcid].
Addr);
}
Frame.Category = CATEGORY_BA;
Frame.Action = DELBA;
Frame.DelbaParm.Initiator = pInfo->Initiator;
Frame.DelbaParm.TID = pInfo->TID;
Frame.ReasonCode = 39; /* Time Out */
*(u16 *) (&Frame.DelbaParm) =
cpu2le16(*(u16 *) (&Frame.DelbaParm));
Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(struct rt_frame_delba_req), &Frame, END_OF_ARGS);
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
DBGPRINT(RT_DEBUG_TRACE,
("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n",
pInfo->Initiator));
}
}
void MlmeQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
}
void MlmeDLSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
}
void MlmeInvalidAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
/*u8 * pOutBuffer = NULL; */
/*Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11 */
}
void PeerQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
}
void PeerBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u8 Action = Elem->Msg[LENGTH_802_11 + 1];
switch (Action) {
case ADDBA_REQ:
PeerAddBAReqAction(pAd, Elem);
break;
case ADDBA_RESP:
PeerAddBARspAction(pAd, Elem);
break;
case DELBA:
PeerDelBAAction(pAd, Elem);
break;
}
}
void PeerPublicAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
return;
}
static void ReservedAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u8 Category;
if (Elem->MsgLen <= LENGTH_802_11) {
return;
}
Category = Elem->Msg[LENGTH_802_11];
DBGPRINT(RT_DEBUG_TRACE,
("Rcv reserved category(%d) Action Frame\n", Category));
hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
}
void PeerRMAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
return;
}
static void respond_ht_information_exchange_action(struct rt_rtmp_adapter *pAd,
struct rt_mlme_queue_elem *Elem)
{
u8 *pOutBuffer = NULL;
int NStatus;
unsigned long FrameLen;
struct rt_frame_ht_info HTINFOframe, *pFrame;
u8 *pAddr;
/* 2. Always send back ADDBA Response */
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
return;
}
/* get RA */
pFrame = (struct rt_frame_ht_info *) & Elem->Msg[0];
pAddr = pFrame->Hdr.Addr2;
NdisZeroMemory(&HTINFOframe, sizeof(struct rt_frame_ht_info));
/* 2-1. Prepare ADDBA Response frame. */
{
if (ADHOC_ON(pAd))
ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr,
pAd->CurrentAddress,
pAd->CommonCfg.Bssid);
else
ActHeaderInit(pAd, &HTINFOframe.Hdr,
pAd->CommonCfg.Bssid, pAd->CurrentAddress,
pAddr);
}
HTINFOframe.Category = CATEGORY_HT;
HTINFOframe.Action = HT_INFO_EXCHANGE;
HTINFOframe.HT_Info.Request = 0;
HTINFOframe.HT_Info.Forty_MHz_Intolerant =
pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
HTINFOframe.HT_Info.STA_Channel_Width =
pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(struct rt_frame_ht_info), &HTINFOframe, END_OF_ARGS);
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
}
void PeerHTAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u8 Action = Elem->Msg[LENGTH_802_11 + 1];
if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
return;
switch (Action) {
case NOTIFY_BW_ACTION:
DBGPRINT(RT_DEBUG_TRACE,
("ACTION - HT Notify Channel bandwidth action----> \n"));
if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) {
/* Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps */
/* sending BW_Notify Action frame, and cause us to linkup and linkdown. */
/* In legacy mode, don't need to parse HT action frame. */
DBGPRINT(RT_DEBUG_TRACE,
("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
Elem->Msg[LENGTH_802_11 + 2]));
break;
}
if (Elem->Msg[LENGTH_802_11 + 2] == 0) /* 7.4.8.2. if value is 1, keep the same as supported channel bandwidth. */
pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
break;
case SMPS_ACTION:
/* 7.3.1.25 */
DBGPRINT(RT_DEBUG_TRACE, ("ACTION - SMPS action----> \n"));
if (((Elem->Msg[LENGTH_802_11 + 2] & 0x1) == 0)) {
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
} else if (((Elem->Msg[LENGTH_802_11 + 2] & 0x2) == 0)) {
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
} else {
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
}
DBGPRINT(RT_DEBUG_TRACE,
("Aid(%d) MIMO PS = %d\n", Elem->Wcid,
pAd->MacTab.Content[Elem->Wcid].MmpsMode));
/* rt2860c : add something for smps change. */
break;
case SETPCO_ACTION:
break;
case MIMO_CHA_MEASURE_ACTION:
break;
case HT_INFO_EXCHANGE:
{
struct rt_ht_information_octet *pHT_info;
pHT_info =
(struct rt_ht_information_octet *) & Elem->Msg[LENGTH_802_11 +
2];
/* 7.4.8.10 */
DBGPRINT(RT_DEBUG_TRACE,
("ACTION - HT Information Exchange action----> \n"));
if (pHT_info->Request) {
respond_ht_information_exchange_action(pAd,
Elem);
}
}
break;
}
}
/*
==========================================================================
Description:
Retry sending ADDBA Reqest.
IRQL = DISPATCH_LEVEL
Parametrs:
p8023Header: if this is already 802.3 format, p8023Header is NULL
Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
FALSE , then continue indicaterx at this moment.
==========================================================================
*/
void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd)
{
struct rt_mac_table_entry *pEntry;
int i, total;
u8 TID;
total = pAd->MacTab.Size * NUM_OF_TID;
for (i = 1; ((i < MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)); i++) {
if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done) {
pEntry =
&pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].
Wcid];
TID = pAd->BATable.BAOriEntry[i].TID;
ASSERT(pAd->BATable.BAOriEntry[i].Wcid <
MAX_LEN_OF_MAC_TABLE);
}
total--;
}
}
void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry)
{
struct rt_frame_bar FrameBar;
unsigned long FrameLen;
int NStatus;
u8 *pOutBuffer = NULL;
u16 Sequence;
u8 i, TID;
u16 idx;
struct rt_ba_ori_entry *pBAEntry;
for (i = 0; i < NUM_OF_TID; i++) {
idx = pEntry->BAOriWcidArray[i];
if (idx == 0) {
continue;
}
pBAEntry = &pAd->BATable.BAOriEntry[idx];
if (pBAEntry->ORI_BA_Status == Originator_Done) {
TID = pBAEntry->TID;
ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_ERROR,
("BA - MlmeADDBAAction() allocate memory failed \n"));
return;
}
Sequence = pEntry->TxSeq[TID];
BarHeaderInit(pAd, &FrameBar, pEntry->Addr,
pAd->CurrentAddress);
FrameBar.StartingSeq.field.FragNum = 0; /* make sure sequence not clear in DEL function. */
FrameBar.StartingSeq.field.StartSeq = Sequence; /* make sure sequence not clear in DEL funciton. */
FrameBar.BarControl.TID = TID; /* make sure sequence not clear in DEL funciton. */
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(struct rt_frame_bar), &FrameBar,
END_OF_ARGS);
/*if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET))) */
if (1) /* Now we always send BAR. */
{
/*MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen); */
MiniportMMRequest(pAd,
(MGMT_USE_QUEUE_FLAG |
MapUserPriorityToAccessCategory
[TID]), pOutBuffer,
FrameLen);
}
MlmeFreeMemory(pAd, pOutBuffer);
}
}
}
void ActHeaderInit(struct rt_rtmp_adapter *pAd,
struct rt_header_802_11 * pHdr80211,
u8 *Addr1, u8 *Addr2, u8 *Addr3)
{
NdisZeroMemory(pHdr80211, sizeof(struct rt_header_802_11));
pHdr80211->FC.Type = BTYPE_MGMT;
pHdr80211->FC.SubType = SUBTYPE_ACTION;
COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
}
void BarHeaderInit(struct rt_rtmp_adapter *pAd,
struct rt_frame_bar * pCntlBar, u8 *pDA, u8 *pSA)
{
NdisZeroMemory(pCntlBar, sizeof(struct rt_frame_bar));
pCntlBar->FC.Type = BTYPE_CNTL;
pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
pCntlBar->BarControl.MTID = 0;
pCntlBar->BarControl.Compressed = 1;
pCntlBar->BarControl.ACKPolicy = 0;
pCntlBar->Duration =
16 + RTMPCalcDuration(pAd, RATE_1, sizeof(struct rt_frame_ba));
COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
}
/*
==========================================================================
Description:
Insert Category and action code into the action frame.
Parametrs:
1. frame buffer pointer.
2. frame length.
3. category code of the frame.
4. action code of the frame.
Return : None.
==========================================================================
*/
void InsertActField(struct rt_rtmp_adapter *pAd,
u8 *pFrameBuf,
unsigned long *pFrameLen, u8 Category, u8 ActCode)
{
unsigned long TempLen;
MakeOutgoingFrame(pFrameBuf, &TempLen,
1, &Category, 1, &ActCode, END_OF_ARGS);
*pFrameLen = *pFrameLen + TempLen;
return;
}

View file

@ -1,56 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
aironet.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Paul Lin 04-06-15 Initial
*/
#ifndef __ACTION_H__
#define __ACTION_H__
struct PACKED rt_ht_information_octet {
u8 Request:1;
u8 Forty_MHz_Intolerant:1;
u8 STA_Channel_Width:1;
u8 Reserved:5;
};
struct PACKED rt_frame_ht_info {
struct rt_header_802_11 Hdr;
u8 Category;
u8 Action;
struct rt_ht_information_octet HT_Info;
};
#endif /* __ACTION_H__ */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,258 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
cmm_cfg.c
Abstract:
Ralink WiFi Driver configuration related subroutines
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#include "../rt_config.h"
char *GetPhyMode(int Mode)
{
switch (Mode) {
case MODE_CCK:
return "CCK";
case MODE_OFDM:
return "OFDM";
case MODE_HTMIX:
return "HTMIX";
case MODE_HTGREENFIELD:
return "GREEN";
default:
return "N/A";
}
}
char *GetBW(int BW)
{
switch (BW) {
case BW_10:
return "10M";
case BW_20:
return "20M";
case BW_40:
return "40M";
default:
return "N/A";
}
}
/*
==========================================================================
Description:
Set Country Region to pAd->CommonCfg.CountryRegion.
This command will not work, if the field of CountryRegion in eeprom is programmed.
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
int RT_CfgSetCountryRegion(struct rt_rtmp_adapter *pAd, char *arg, int band)
{
long region, regionMax;
u8 *pCountryRegion;
region = simple_strtol(arg, 0, 10);
if (band == BAND_24G) {
pCountryRegion = &pAd->CommonCfg.CountryRegion;
regionMax = REGION_MAXIMUM_BG_BAND;
} else {
pCountryRegion = &pAd->CommonCfg.CountryRegionForABand;
regionMax = REGION_MAXIMUM_A_BAND;
}
/* TODO: Is it neccesay for following check??? */
/* Country can be set only when EEPROM not programmed */
if (*pCountryRegion & 0x80) {
DBGPRINT(RT_DEBUG_ERROR,
("CfgSetCountryRegion():CountryRegion in eeprom was programmed\n"));
return FALSE;
}
if ((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND)) {
*pCountryRegion = (u8)region;
} else if ((region == REGION_31_BG_BAND) && (band == BAND_24G)) {
*pCountryRegion = (u8)region;
} else {
DBGPRINT(RT_DEBUG_ERROR,
("CfgSetCountryRegion():region(%ld) out of range!\n",
region));
return FALSE;
}
return TRUE;
}
/*
==========================================================================
Description:
Set Wireless Mode
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
int RT_CfgSetWirelessMode(struct rt_rtmp_adapter *pAd, char *arg)
{
int MaxPhyMode = PHY_11G;
long WirelessMode;
MaxPhyMode = PHY_11N_5G;
WirelessMode = simple_strtol(arg, 0, 10);
if (WirelessMode <= MaxPhyMode) {
pAd->CommonCfg.PhyMode = WirelessMode;
return TRUE;
}
return FALSE;
}
int RT_CfgSetShortSlot(struct rt_rtmp_adapter *pAd, char *arg)
{
long ShortSlot;
ShortSlot = simple_strtol(arg, 0, 10);
if (ShortSlot == 1)
pAd->CommonCfg.bUseShortSlotTime = TRUE;
else if (ShortSlot == 0)
pAd->CommonCfg.bUseShortSlotTime = FALSE;
else
return FALSE; /*Invalid argument */
return TRUE;
}
/*
==========================================================================
Description:
Set WEP KEY base on KeyIdx
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
int RT_CfgSetWepKey(struct rt_rtmp_adapter *pAd,
char *keyString,
struct rt_cipher_key *pSharedKey, int keyIdx)
{
int KeyLen;
int i;
u8 CipherAlg = CIPHER_NONE;
BOOLEAN bKeyIsHex = FALSE;
/* TODO: Shall we do memset for the original key info?? */
memset(pSharedKey, 0, sizeof(struct rt_cipher_key));
KeyLen = strlen(keyString);
switch (KeyLen) {
case 5: /*wep 40 Ascii type */
case 13: /*wep 104 Ascii type */
bKeyIsHex = FALSE;
pSharedKey->KeyLen = KeyLen;
NdisMoveMemory(pSharedKey->Key, keyString, KeyLen);
break;
case 10: /*wep 40 Hex type */
case 26: /*wep 104 Hex type */
for (i = 0; i < KeyLen; i++) {
if (!isxdigit(*(keyString + i)))
return FALSE; /*Not Hex value; */
}
bKeyIsHex = TRUE;
pSharedKey->KeyLen = KeyLen / 2;
AtoH(keyString, pSharedKey->Key, pSharedKey->KeyLen);
break;
default: /*Invalid argument */
DBGPRINT(RT_DEBUG_TRACE,
("RT_CfgSetWepKey(keyIdx=%d):Invalid argument (arg=%s)\n",
keyIdx, keyString));
return FALSE;
}
pSharedKey->CipherAlg = ((KeyLen % 5) ? CIPHER_WEP128 : CIPHER_WEP64);
DBGPRINT(RT_DEBUG_TRACE,
("RT_CfgSetWepKey:(KeyIdx=%d,type=%s, Alg=%s)\n", keyIdx,
(bKeyIsHex == FALSE ? "Ascii" : "Hex"),
CipherName[CipherAlg]));
return TRUE;
}
/*
==========================================================================
Description:
Set WPA PSK key
Arguments:
pAdapter Pointer to our adapter
keyString WPA pre-shared key string
pHashStr String used for password hash function
hashStrLen Length of the hash string
pPMKBuf Output buffer of WPAPSK key
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
int RT_CfgSetWPAPSKKey(struct rt_rtmp_adapter *pAd,
char *keyString,
u8 * pHashStr,
int hashStrLen, u8 *pPMKBuf)
{
int keyLen;
u8 keyMaterial[40];
keyLen = strlen(keyString);
if ((keyLen < 8) || (keyLen > 64)) {
DBGPRINT(RT_DEBUG_TRACE,
("WPAPSK Key length(%d) error, required 8 ~ 64 characters!(keyStr=%s)\n",
keyLen, keyString));
return FALSE;
}
memset(pPMKBuf, 0, 32);
if (keyLen == 64) {
AtoH(keyString, pPMKBuf, 32);
} else {
PasswordHash(keyString, pHashStr, hashStrLen, keyMaterial);
NdisMoveMemory(pPMKBuf, keyMaterial, 32);
}
return TRUE;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,951 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
/*
All functions in this file must be USB-depended, or you should out your function
in other files.
*/
#ifdef RTMP_MAC_USB
#include "../rt_config.h"
/*
We can do copy the frame into pTxContext when match following conditions.
=>
=>
=>
*/
static inline int RtmpUSBCanDoWrite(struct rt_rtmp_adapter *pAd,
u8 QueIdx,
struct rt_ht_tx_context *pHTTXContext)
{
int canWrite = NDIS_STATUS_RESOURCES;
if (((pHTTXContext->CurWritePosition) <
pHTTXContext->NextBulkOutPosition)
&& (pHTTXContext->CurWritePosition + LOCAL_TXBUF_SIZE) >
pHTTXContext->NextBulkOutPosition) {
DBGPRINT(RT_DEBUG_ERROR, ("RtmpUSBCanDoWrite c1!\n"));
RTUSB_SET_BULK_FLAG(pAd,
(fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
} else if ((pHTTXContext->CurWritePosition == 8)
&& (pHTTXContext->NextBulkOutPosition < LOCAL_TXBUF_SIZE)) {
DBGPRINT(RT_DEBUG_ERROR, ("RtmpUSBCanDoWrite c2!\n"));
RTUSB_SET_BULK_FLAG(pAd,
(fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
} else if (pHTTXContext->bCurWriting == TRUE) {
DBGPRINT(RT_DEBUG_ERROR, ("RtmpUSBCanDoWrite c3!\n"));
} else {
canWrite = NDIS_STATUS_SUCCESS;
}
return canWrite;
}
u16 RtmpUSB_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
struct rt_tx_blk *pTxBlk,
IN BOOLEAN bIsLast, u16 * FreeNumber)
{
/* Dummy function. Should be removed in the future. */
return 0;
}
u16 RtmpUSB_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
struct rt_tx_blk *pTxBlk,
u8 fragNum, u16 * FreeNumber)
{
struct rt_ht_tx_context *pHTTXContext;
u16 hwHdrLen; /* The hwHdrLen consist of 802.11 header length plus the header padding length. */
u32 fillOffset;
struct rt_txinfo *pTxInfo;
struct rt_txwi *pTxWI;
u8 *pWirelessPacket = NULL;
u8 QueIdx;
int Status;
unsigned long IrqFlags;
u32 USBDMApktLen = 0, DMAHdrLen, padding;
BOOLEAN TxQLastRound = FALSE;
/* */
/* get Tx Ring Resource & Dma Buffer address */
/* */
QueIdx = pTxBlk->QueIdx;
pHTTXContext = &pAd->TxContext[QueIdx];
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
pHTTXContext = &pAd->TxContext[QueIdx];
fillOffset = pHTTXContext->CurWritePosition;
if (fragNum == 0) {
/* Check if we have enough space for this bulk-out batch. */
Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
if (Status == NDIS_STATUS_SUCCESS) {
pHTTXContext->bCurWriting = TRUE;
/* Reserve space for 8 bytes padding. */
if ((pHTTXContext->ENextBulkOutPosition ==
pHTTXContext->CurWritePosition)) {
pHTTXContext->ENextBulkOutPosition += 8;
pHTTXContext->CurWritePosition += 8;
fillOffset += 8;
}
pTxBlk->Priv = 0;
pHTTXContext->CurWriteRealPos =
pHTTXContext->CurWritePosition;
} else {
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx],
IrqFlags);
RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket,
NDIS_STATUS_FAILURE);
return (Status);
}
} else {
/* For sub-sequent frames of this bulk-out batch. Just copy it to our bulk-out buffer. */
Status =
((pHTTXContext->bCurWriting ==
TRUE) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE);
if (Status == NDIS_STATUS_SUCCESS) {
fillOffset += pTxBlk->Priv;
} else {
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx],
IrqFlags);
RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket,
NDIS_STATUS_FAILURE);
return (Status);
}
}
NdisZeroMemory((u8 *)(&pTxBlk->HeaderBuf[0]), TXINFO_SIZE);
pTxInfo = (struct rt_txinfo *)(&pTxBlk->HeaderBuf[0]);
pTxWI = (struct rt_txwi *) (&pTxBlk->HeaderBuf[TXINFO_SIZE]);
pWirelessPacket =
&pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset];
/* copy TXWI + WLAN Header + LLC into DMA Header Buffer */
/*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
/* Build our URB for USBD */
DMAHdrLen = TXWI_SIZE + hwHdrLen;
USBDMApktLen = DMAHdrLen + pTxBlk->SrcBufLen;
padding = (4 - (USBDMApktLen % 4)) & 0x03; /* round up to 4 byte alignment */
USBDMApktLen += padding;
pTxBlk->Priv += (TXINFO_SIZE + USBDMApktLen);
/* For TxInfo, the length of USBDMApktLen = TXWI_SIZE + 802.11 header + payload */
RTMPWriteTxInfo(pAd, pTxInfo, (u16)(USBDMApktLen), FALSE, FIFO_EDCA,
FALSE /*NextValid */ , FALSE);
if (fragNum == pTxBlk->TotalFragNum) {
pTxInfo->USBDMATxburst = 0;
if ((pHTTXContext->CurWritePosition + pTxBlk->Priv + 3906) >
MAX_TXBULK_LIMIT) {
pTxInfo->SwUseLastRound = 1;
TxQLastRound = TRUE;
}
} else {
pTxInfo->USBDMATxburst = 1;
}
NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
pHTTXContext->CurWriteRealPos += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen);
/* Zero the last padding. */
pWirelessPacket += pTxBlk->SrcBufLen;
NdisZeroMemory(pWirelessPacket, padding + 8);
if (fragNum == pTxBlk->TotalFragNum) {
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
/* Update the pHTTXContext->CurWritePosition. 3906 used to prevent the NextBulkOut is a A-RALINK/A-MSDU Frame. */
pHTTXContext->CurWritePosition += pTxBlk->Priv;
if (TxQLastRound == TRUE)
pHTTXContext->CurWritePosition = 8;
pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
/* Finally, set bCurWriting as FALSE */
pHTTXContext->bCurWriting = FALSE;
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
/* succeed and release the skb buffer */
RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
}
return (Status);
}
u16 RtmpUSB_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
struct rt_tx_blk *pTxBlk,
IN BOOLEAN bIsLast,
u16 * FreeNumber)
{
struct rt_ht_tx_context *pHTTXContext;
u16 hwHdrLen;
u32 fillOffset;
struct rt_txinfo *pTxInfo;
struct rt_txwi *pTxWI;
u8 *pWirelessPacket;
u8 QueIdx;
unsigned long IrqFlags;
int Status;
u32 USBDMApktLen = 0, DMAHdrLen, padding;
BOOLEAN bTxQLastRound = FALSE;
/* For USB, didn't need PCI_MAP_SINGLE() */
/*SrcBufPA = PCI_MAP_SINGLE(pAd, (char *) pTxBlk->pSrcBufData, pTxBlk->SrcBufLen, PCI_DMA_TODEVICE); */
/* */
/* get Tx Ring Resource & Dma Buffer address */
/* */
QueIdx = pTxBlk->QueIdx;
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
pHTTXContext = &pAd->TxContext[QueIdx];
fillOffset = pHTTXContext->CurWritePosition;
/* Check ring full. */
Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
if (Status == NDIS_STATUS_SUCCESS) {
pHTTXContext->bCurWriting = TRUE;
pTxInfo = (struct rt_txinfo *)(&pTxBlk->HeaderBuf[0]);
pTxWI = (struct rt_txwi *) (&pTxBlk->HeaderBuf[TXINFO_SIZE]);
/* Reserve space for 8 bytes padding. */
if ((pHTTXContext->ENextBulkOutPosition ==
pHTTXContext->CurWritePosition)) {
pHTTXContext->ENextBulkOutPosition += 8;
pHTTXContext->CurWritePosition += 8;
fillOffset += 8;
}
pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
pWirelessPacket =
&pHTTXContext->TransferBuffer->field.
WirelessPacket[fillOffset];
/* copy TXWI + WLAN Header + LLC into DMA Header Buffer */
/*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
/* Build our URB for USBD */
DMAHdrLen = TXWI_SIZE + hwHdrLen;
USBDMApktLen = DMAHdrLen + pTxBlk->SrcBufLen;
padding = (4 - (USBDMApktLen % 4)) & 0x03; /* round up to 4 byte alignment */
USBDMApktLen += padding;
pTxBlk->Priv = (TXINFO_SIZE + USBDMApktLen);
/* For TxInfo, the length of USBDMApktLen = TXWI_SIZE + 802.11 header + payload */
RTMPWriteTxInfo(pAd, pTxInfo, (u16)(USBDMApktLen), FALSE,
FIFO_EDCA, FALSE /*NextValid */ , FALSE);
if ((pHTTXContext->CurWritePosition + 3906 + pTxBlk->Priv) >
MAX_TXBULK_LIMIT) {
pTxInfo->SwUseLastRound = 1;
bTxQLastRound = TRUE;
}
NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
/* We unlock it here to prevent the first 8 bytes maybe over-writed issue. */
/* 1. First we got CurWritePosition but the first 8 bytes still not write to the pTxcontext. */
/* 2. An interrupt break our routine and handle bulk-out complete. */
/* 3. In the bulk-out compllete, it need to do another bulk-out, */
/* if the ENextBulkOutPosition is just the same as CurWritePosition, it will save the first 8 bytes from CurWritePosition, */
/* but the payload still not copyed. the pTxContext->SavedPad[] will save as allzero. and set the bCopyPad = TRUE. */
/* 4. Interrupt complete. */
/* 5. Our interrupted routine go back and fill the first 8 bytes to pTxContext. */
/* 6. Next time when do bulk-out, it found the bCopyPad==TRUE and will copy the SavedPad[] to pTxContext->NextBulkOutPosition. */
/* and the packet will wrong. */
pHTTXContext->CurWriteRealPos +=
(TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData,
pTxBlk->SrcBufLen);
pWirelessPacket += pTxBlk->SrcBufLen;
NdisZeroMemory(pWirelessPacket, padding + 8);
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
pHTTXContext->CurWritePosition += pTxBlk->Priv;
if (bTxQLastRound)
pHTTXContext->CurWritePosition = 8;
pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
pHTTXContext->bCurWriting = FALSE;
}
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
/* succeed and release the skb buffer */
RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
return (Status);
}
u16 RtmpUSB_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
struct rt_tx_blk *pTxBlk,
u8 frameNum, u16 * FreeNumber)
{
struct rt_ht_tx_context *pHTTXContext;
u16 hwHdrLen; /* The hwHdrLen consist of 802.11 header length plus the header padding length. */
u32 fillOffset;
struct rt_txinfo *pTxInfo;
struct rt_txwi *pTxWI;
u8 *pWirelessPacket = NULL;
u8 QueIdx;
int Status;
unsigned long IrqFlags;
/*u32 USBDMApktLen = 0, DMAHdrLen, padding; */
/* */
/* get Tx Ring Resource & Dma Buffer address */
/* */
QueIdx = pTxBlk->QueIdx;
pHTTXContext = &pAd->TxContext[QueIdx];
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
if (frameNum == 0) {
/* Check if we have enough space for this bulk-out batch. */
Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
if (Status == NDIS_STATUS_SUCCESS) {
pHTTXContext->bCurWriting = TRUE;
pTxInfo = (struct rt_txinfo *)(&pTxBlk->HeaderBuf[0]);
pTxWI = (struct rt_txwi *) (&pTxBlk->HeaderBuf[TXINFO_SIZE]);
/* Reserve space for 8 bytes padding. */
if ((pHTTXContext->ENextBulkOutPosition ==
pHTTXContext->CurWritePosition)) {
pHTTXContext->CurWritePosition += 8;
pHTTXContext->ENextBulkOutPosition += 8;
}
fillOffset = pHTTXContext->CurWritePosition;
pHTTXContext->CurWriteRealPos =
pHTTXContext->CurWritePosition;
pWirelessPacket =
&pHTTXContext->TransferBuffer->field.
WirelessPacket[fillOffset];
/* */
/* Copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */
/* */
if (pTxBlk->TxFrameType == TX_AMSDU_FRAME)
/*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD; */
hwHdrLen =
pTxBlk->MpduHeaderLen -
LENGTH_AMSDU_SUBFRAMEHEAD +
pTxBlk->HdrPadLen +
LENGTH_AMSDU_SUBFRAMEHEAD;
else if (pTxBlk->TxFrameType == TX_RALINK_FRAME)
/*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_ARALINK_HEADER_FIELD, 4)+LENGTH_ARALINK_HEADER_FIELD; */
hwHdrLen =
pTxBlk->MpduHeaderLen -
LENGTH_ARALINK_HEADER_FIELD +
pTxBlk->HdrPadLen +
LENGTH_ARALINK_HEADER_FIELD;
else
/*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
hwHdrLen =
pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
/* Update the pTxBlk->Priv. */
pTxBlk->Priv = TXINFO_SIZE + TXWI_SIZE + hwHdrLen;
/* pTxInfo->USBDMApktLen now just a temp value and will to correct latter. */
RTMPWriteTxInfo(pAd, pTxInfo, (u16)(pTxBlk->Priv),
FALSE, FIFO_EDCA, FALSE /*NextValid */ ,
FALSE);
/* Copy it. */
NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
pTxBlk->Priv);
pHTTXContext->CurWriteRealPos += pTxBlk->Priv;
pWirelessPacket += pTxBlk->Priv;
}
} else { /* For sub-sequent frames of this bulk-out batch. Just copy it to our bulk-out buffer. */
Status =
((pHTTXContext->bCurWriting ==
TRUE) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE);
if (Status == NDIS_STATUS_SUCCESS) {
fillOffset =
(pHTTXContext->CurWritePosition + pTxBlk->Priv);
pWirelessPacket =
&pHTTXContext->TransferBuffer->field.
WirelessPacket[fillOffset];
/*hwHdrLen = pTxBlk->MpduHeaderLen; */
NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
pTxBlk->MpduHeaderLen);
pWirelessPacket += (pTxBlk->MpduHeaderLen);
pTxBlk->Priv += pTxBlk->MpduHeaderLen;
} else { /* It should not happened now unless we are going to shutdown. */
DBGPRINT(RT_DEBUG_ERROR,
("WriteMultiTxResource():bCurWriting is FALSE when handle sub-sequent frames.\n"));
Status = NDIS_STATUS_FAILURE;
}
}
/* We unlock it here to prevent the first 8 bytes maybe over-write issue. */
/* 1. First we got CurWritePosition but the first 8 bytes still not write to the pTxContext. */
/* 2. An interrupt break our routine and handle bulk-out complete. */
/* 3. In the bulk-out compllete, it need to do another bulk-out, */
/* if the ENextBulkOutPosition is just the same as CurWritePosition, it will save the first 8 bytes from CurWritePosition, */
/* but the payload still not copyed. the pTxContext->SavedPad[] will save as allzero. and set the bCopyPad = TRUE. */
/* 4. Interrupt complete. */
/* 5. Our interrupted routine go back and fill the first 8 bytes to pTxContext. */
/* 6. Next time when do bulk-out, it found the bCopyPad==TRUE and will copy the SavedPad[] to pTxContext->NextBulkOutPosition. */
/* and the packet will wrong. */
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
if (Status != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_ERROR,
("WriteMultiTxResource: CWPos = %ld, NBOutPos = %ld.\n",
pHTTXContext->CurWritePosition,
pHTTXContext->NextBulkOutPosition));
goto done;
}
/* Copy the frame content into DMA buffer and update the pTxBlk->Priv */
NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen);
pWirelessPacket += pTxBlk->SrcBufLen;
pTxBlk->Priv += pTxBlk->SrcBufLen;
done:
/* Release the skb buffer here */
RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
return (Status);
}
void RtmpUSB_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
struct rt_tx_blk *pTxBlk,
u16 totalMPDUSize, u16 TxIdx)
{
u8 QueIdx;
struct rt_ht_tx_context *pHTTXContext;
u32 fillOffset;
struct rt_txinfo *pTxInfo;
struct rt_txwi *pTxWI;
u32 USBDMApktLen, padding;
unsigned long IrqFlags;
u8 *pWirelessPacket;
QueIdx = pTxBlk->QueIdx;
pHTTXContext = &pAd->TxContext[QueIdx];
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
if (pHTTXContext->bCurWriting == TRUE) {
fillOffset = pHTTXContext->CurWritePosition;
if (((pHTTXContext->ENextBulkOutPosition ==
pHTTXContext->CurWritePosition)
|| ((pHTTXContext->ENextBulkOutPosition - 8) ==
pHTTXContext->CurWritePosition))
&& (pHTTXContext->bCopySavePad == TRUE))
pWirelessPacket = (u8 *)(&pHTTXContext->SavedPad[0]);
else
pWirelessPacket =
(u8 *)(&pHTTXContext->TransferBuffer->field.
WirelessPacket[fillOffset]);
/* */
/* Update TxInfo->USBDMApktLen , */
/* the length = TXWI_SIZE + 802.11_hdr + 802.11_hdr_pad + payload_of_all_batch_frames + Bulk-Out-padding */
/* */
pTxInfo = (struct rt_txinfo *)(pWirelessPacket);
/* Calculate the bulk-out padding */
USBDMApktLen = pTxBlk->Priv - TXINFO_SIZE;
padding = (4 - (USBDMApktLen % 4)) & 0x03; /* round up to 4 byte alignment */
USBDMApktLen += padding;
pTxInfo->USBDMATxPktLen = USBDMApktLen;
/* */
/* Update TXWI->MPDUtotalByteCount , */
/* the length = 802.11 header + payload_of_all_batch_frames */
pTxWI = (struct rt_txwi *) (pWirelessPacket + TXINFO_SIZE);
pTxWI->MPDUtotalByteCount = totalMPDUSize;
/* */
/* Update the pHTTXContext->CurWritePosition */
/* */
pHTTXContext->CurWritePosition += (TXINFO_SIZE + USBDMApktLen);
if ((pHTTXContext->CurWritePosition + 3906) > MAX_TXBULK_LIMIT) { /* Add 3906 for prevent the NextBulkOut packet size is a A-RALINK/A-MSDU Frame. */
pHTTXContext->CurWritePosition = 8;
pTxInfo->SwUseLastRound = 1;
}
pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
/* */
/* Zero the last padding. */
/* */
pWirelessPacket =
(&pHTTXContext->TransferBuffer->field.
WirelessPacket[fillOffset + pTxBlk->Priv]);
NdisZeroMemory(pWirelessPacket, padding + 8);
/* Finally, set bCurWriting as FALSE */
pHTTXContext->bCurWriting = FALSE;
} else { /* It should not happened now unless we are going to shutdown. */
DBGPRINT(RT_DEBUG_ERROR,
("FinalWriteTxResource():bCurWriting is FALSE when handle last frames.\n"));
}
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
}
void RtmpUSBDataLastTxIdx(struct rt_rtmp_adapter *pAd,
u8 QueIdx, u16 TxIdx)
{
/* DO nothing for USB. */
}
/*
When can do bulk-out:
1. TxSwFreeIdx < TX_RING_SIZE;
It means has at least one Ring entity is ready for bulk-out, kick it out.
2. If TxSwFreeIdx == TX_RING_SIZE
Check if the CurWriting flag is FALSE, if it's FALSE, we can do kick out.
*/
void RtmpUSBDataKickOut(struct rt_rtmp_adapter *pAd,
struct rt_tx_blk *pTxBlk, u8 QueIdx)
{
RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
RTUSBKickBulkOut(pAd);
}
/*
Must be run in Interrupt context
This function handle RT2870 specific TxDesc and cpu index update and kick the packet out.
*/
int RtmpUSBMgmtKickOut(struct rt_rtmp_adapter *pAd,
u8 QueIdx,
void *pPacket,
u8 *pSrcBufVA, u32 SrcBufLen)
{
struct rt_txinfo *pTxInfo;
unsigned long BulkOutSize;
u8 padLen;
u8 *pDest;
unsigned long SwIdx = pAd->MgmtRing.TxCpuIdx;
struct rt_tx_context *pMLMEContext =
(struct rt_tx_context *)pAd->MgmtRing.Cell[SwIdx].AllocVa;
unsigned long IrqFlags;
pTxInfo = (struct rt_txinfo *)(pSrcBufVA);
/* Build our URB for USBD */
BulkOutSize = SrcBufLen;
BulkOutSize = (BulkOutSize + 3) & (~3);
RTMPWriteTxInfo(pAd, pTxInfo, (u16)(BulkOutSize - TXINFO_SIZE),
TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
BulkOutSize += 4; /* Always add 4 extra bytes at every packet. */
/* If BulkOutSize is multiple of BulkOutMaxPacketSize, add extra 4 bytes again. */
if ((BulkOutSize % pAd->BulkOutMaxPacketSize) == 0)
BulkOutSize += 4;
padLen = BulkOutSize - SrcBufLen;
ASSERT((padLen <= RTMP_PKT_TAIL_PADDING));
/* Now memzero all extra padding bytes. */
pDest = (u8 *)(pSrcBufVA + SrcBufLen);
skb_put(GET_OS_PKT_TYPE(pPacket), padLen);
NdisZeroMemory(pDest, padLen);
RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags);
pAd->MgmtRing.Cell[pAd->MgmtRing.TxCpuIdx].pNdisPacket = pPacket;
pMLMEContext->TransferBuffer =
(struct rt_tx_buffer *)(GET_OS_PKT_DATAPTR(pPacket));
/* Length in TxInfo should be 8 less than bulkout size. */
pMLMEContext->BulkOutSize = BulkOutSize;
pMLMEContext->InUse = TRUE;
pMLMEContext->bWaitingBulkOut = TRUE;
/*for debug */
/*hex_dump("RtmpUSBMgmtKickOut", &pMLMEContext->TransferBuffer->field.WirelessPacket[0], (pMLMEContext->BulkOutSize > 16 ? 16 : pMLMEContext->BulkOutSize)); */
/*pAd->RalinkCounters.KickTxCount++; */
/*pAd->RalinkCounters.OneSecTxDoneCount++; */
/*if (pAd->MgmtRing.TxSwFreeIdx == MGMT_RING_SIZE) */
/* needKickOut = TRUE; */
/* Decrease the TxSwFreeIdx and Increase the TX_CTX_IDX */
pAd->MgmtRing.TxSwFreeIdx--;
INC_RING_INDEX(pAd->MgmtRing.TxCpuIdx, MGMT_RING_SIZE);
RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags);
RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
/*if (needKickOut) */
RTUSBKickBulkOut(pAd);
return 0;
}
void RtmpUSBNullFrameKickOut(struct rt_rtmp_adapter *pAd,
u8 QueIdx,
u8 * pNullFrame, u32 frameLen)
{
if (pAd->NullContext.InUse == FALSE) {
struct rt_tx_context *pNullContext;
struct rt_txinfo *pTxInfo;
struct rt_txwi * pTxWI;
u8 *pWirelessPkt;
pNullContext = &(pAd->NullContext);
/* Set the in use bit */
pNullContext->InUse = TRUE;
pWirelessPkt =
(u8 *)& pNullContext->TransferBuffer->field.
WirelessPacket[0];
RTMPZeroMemory(&pWirelessPkt[0], 100);
pTxInfo = (struct rt_txinfo *)& pWirelessPkt[0];
RTMPWriteTxInfo(pAd, pTxInfo,
(u16)(sizeof(struct rt_header_802_11) + TXWI_SIZE),
TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
pTxInfo->QSEL = FIFO_EDCA;
pTxWI = (struct rt_txwi *) & pWirelessPkt[TXINFO_SIZE];
RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE,
FALSE, 0, BSSID_WCID, (sizeof(struct rt_header_802_11)), 0,
0, (u8)pAd->CommonCfg.MlmeTransmit.field.MCS,
IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
RTMPMoveMemory(&pWirelessPkt[TXWI_SIZE + TXINFO_SIZE],
&pAd->NullFrame, sizeof(struct rt_header_802_11));
pAd->NullContext.BulkOutSize =
TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
/* Fill out frame length information for global Bulk out arbitor */
/*pNullContext->BulkOutSize = TransferBufferLength; */
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - send NULL Frame @%d Mbps...\n",
RateIdToMbps[pAd->CommonCfg.TxRate]));
RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL);
/* Kick bulk out */
RTUSBKickBulkOut(pAd);
}
}
/*
========================================================================
Routine Description:
Get a received packet.
Arguments:
pAd device control block
pSaveRxD receive descriptor information
*pbReschedule need reschedule flag
*pRxPending pending received packet flag
Return Value:
the received packet
Note:
========================================================================
*/
void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd,
OUT PRT28XX_RXD_STRUC pSaveRxD,
OUT BOOLEAN * pbReschedule,
IN u32 * pRxPending)
{
struct rt_rx_context *pRxContext;
void *pSkb;
u8 *pData;
unsigned long ThisFrameLen;
unsigned long RxBufferLength;
struct rt_rxwi * pRxWI;
pRxContext = &pAd->RxContext[pAd->NextRxBulkInReadIndex];
if ((pRxContext->Readable == FALSE) || (pRxContext->InUse == TRUE))
return NULL;
RxBufferLength = pRxContext->BulkInOffset - pAd->ReadPosition;
if (RxBufferLength <
(RT2870_RXDMALEN_FIELD_SIZE + sizeof(struct rt_rxwi) +
sizeof(struct rt_rxinfo))) {
goto label_null;
}
pData = &pRxContext->TransferBuffer[pAd->ReadPosition]; /* 4KB */
/* The RXDMA field is 4 bytes, now just use the first 2 bytes. The Length including the (RXWI + MSDU + Padding) */
ThisFrameLen = *pData + (*(pData + 1) << 8);
if (ThisFrameLen == 0) {
DBGPRINT(RT_DEBUG_TRACE,
("BIRIdx(%d): RXDMALen is zero.[%ld], BulkInBufLen = %ld)\n",
pAd->NextRxBulkInReadIndex, ThisFrameLen,
pRxContext->BulkInOffset));
goto label_null;
}
if ((ThisFrameLen & 0x3) != 0) {
DBGPRINT(RT_DEBUG_ERROR,
("BIRIdx(%d): RXDMALen not multiple of 4.[%ld], BulkInBufLen = %ld)\n",
pAd->NextRxBulkInReadIndex, ThisFrameLen,
pRxContext->BulkInOffset));
goto label_null;
}
if ((ThisFrameLen + 8) > RxBufferLength) /* 8 for (RT2870_RXDMALEN_FIELD_SIZE + sizeof(struct rt_rxinfo)) */
{
DBGPRINT(RT_DEBUG_TRACE,
("BIRIdx(%d):FrameLen(0x%lx) outranges. BulkInLen=0x%lx, remaining RxBufLen=0x%lx, ReadPos=0x%lx\n",
pAd->NextRxBulkInReadIndex, ThisFrameLen,
pRxContext->BulkInOffset, RxBufferLength,
pAd->ReadPosition));
/* error frame. finish this loop */
goto label_null;
}
/* skip USB frame length field */
pData += RT2870_RXDMALEN_FIELD_SIZE;
pRxWI = (struct rt_rxwi *) pData;
if (pRxWI->MPDUtotalByteCount > ThisFrameLen) {
DBGPRINT(RT_DEBUG_ERROR,
("%s():pRxWIMPDUtotalByteCount(%d) large than RxDMALen(%ld)\n",
__FUNCTION__, pRxWI->MPDUtotalByteCount,
ThisFrameLen));
goto label_null;
}
/* allocate a rx packet */
pSkb = dev_alloc_skb(ThisFrameLen);
if (pSkb == NULL) {
DBGPRINT(RT_DEBUG_ERROR,
("%s():Cannot Allocate sk buffer for this Bulk-In buffer!\n",
__FUNCTION__));
goto label_null;
}
/* copy the rx packet */
memcpy(skb_put(pSkb, ThisFrameLen), pData, ThisFrameLen);
RTPKT_TO_OSPKT(pSkb)->dev = get_netdev_from_bssid(pAd, BSS0);
RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pSkb), PKTSRC_NDIS);
/* copy RxD */
*pSaveRxD = *(struct rt_rxinfo *) (pData + ThisFrameLen);
/* update next packet read position. */
pAd->ReadPosition += (ThisFrameLen + RT2870_RXDMALEN_FIELD_SIZE + RXINFO_SIZE); /* 8 for (RT2870_RXDMALEN_FIELD_SIZE + sizeof(struct rt_rxinfo)) */
return pSkb;
label_null:
return NULL;
}
/*
========================================================================
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:
========================================================================
*/
int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
struct rt_header_802_11 * pHeader,
struct rt_rxwi * pRxWI, IN PRT28XX_RXD_STRUC pRxINFO)
{
struct rt_cipher_key *pWpaKey;
int dBm;
if (pAd->bPromiscuous == TRUE)
return (NDIS_STATUS_SUCCESS);
if (pRxINFO == NULL)
return (NDIS_STATUS_FAILURE);
/* Phy errors & CRC errors */
if (pRxINFO->Crc) {
/* Check RSSI for Noise Hist statistic collection. */
dBm = (int)(pRxWI->RSSI0) - pAd->BbpRssiToDbmDelta;
if (dBm <= -87)
pAd->StaCfg.RPIDensity[0] += 1;
else if (dBm <= -82)
pAd->StaCfg.RPIDensity[1] += 1;
else if (dBm <= -77)
pAd->StaCfg.RPIDensity[2] += 1;
else if (dBm <= -72)
pAd->StaCfg.RPIDensity[3] += 1;
else if (dBm <= -67)
pAd->StaCfg.RPIDensity[4] += 1;
else if (dBm <= -62)
pAd->StaCfg.RPIDensity[5] += 1;
else if (dBm <= -57)
pAd->StaCfg.RPIDensity[6] += 1;
else if (dBm > -57)
pAd->StaCfg.RPIDensity[7] += 1;
return (NDIS_STATUS_FAILURE);
}
/* Add Rx size to channel load counter, we should ignore error counts */
pAd->StaCfg.CLBusyBytes += (pRxWI->MPDUtotalByteCount + 14);
/* Drop ToDs promiscuous frame, it is opened due to CCX 2 channel load statistics */
if (pHeader->FC.ToDs) {
DBGPRINT_RAW(RT_DEBUG_ERROR, ("Err;FC.ToDs\n"));
return NDIS_STATUS_FAILURE;
}
/* Paul 04-03 for OFDM Rx length issue */
if (pRxWI->MPDUtotalByteCount > MAX_AGGREGATION_SIZE) {
DBGPRINT_RAW(RT_DEBUG_ERROR, ("received packet too long\n"));
return NDIS_STATUS_FAILURE;
}
/* Drop not U2M frames, can't's drop here because we will drop beacon in this case */
/* I am kind of doubting the U2M bit operation */
/* if (pRxD->U2M == 0) */
/* return(NDIS_STATUS_FAILURE); */
/* drop decyption fail frame */
if (pRxINFO->Decrypted && pRxINFO->CipherErr) {
if (((pRxINFO->CipherErr & 1) == 1)
&& pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
RTMPSendWirelessEvent(pAd, IW_ICV_ERROR_EVENT_FLAG,
pAd->MacTab.Content[BSSID_WCID].
Addr, BSS0, 0);
if (((pRxINFO->CipherErr & 2) == 2)
&& pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
RTMPSendWirelessEvent(pAd, IW_MIC_ERROR_EVENT_FLAG,
pAd->MacTab.Content[BSSID_WCID].
Addr, BSS0, 0);
/* */
/* MIC Error */
/* */
if ((pRxINFO->CipherErr == 2) && pRxINFO->MyBss) {
pWpaKey = &pAd->SharedKey[BSS0][pRxWI->KeyIndex];
RTMPReportMicError(pAd, pWpaKey);
DBGPRINT_RAW(RT_DEBUG_ERROR, ("Rx MIC Value error\n"));
}
if (pRxINFO->Decrypted &&
(pAd->SharedKey[BSS0][pRxWI->KeyIndex].CipherAlg ==
CIPHER_AES)
&& (pHeader->Sequence == pAd->FragFrame.Sequence)) {
/* */
/* Acceptable since the First FragFrame no CipherErr problem. */
/* */
return (NDIS_STATUS_SUCCESS);
}
return (NDIS_STATUS_FAILURE);
}
return (NDIS_STATUS_SUCCESS);
}
void RtmpUsbStaAsicForceWakeupTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2,
void *SystemSpecific3)
{
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
if (pAd && pAd->Mlme.AutoWakeupTimerRunning) {
AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
pAd->Mlme.AutoWakeupTimerRunning = FALSE;
}
}
void RT28xxUsbStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx)
{
BOOLEAN Canceled;
if (pAd->Mlme.AutoWakeupTimerRunning)
RTMPCancelTimer(&pAd->Mlme.AutoWakeupTimer, &Canceled);
AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
}
void RT28xxUsbStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
u16 TbttNumToNextWakeUp)
{
/* we have decided to SLEEP, so at least do it for a BEACON period. */
if (TbttNumToNextWakeUp == 0)
TbttNumToNextWakeUp = 1;
RTMPSetTimer(&pAd->Mlme.AutoWakeupTimer, AUTO_WAKEUP_TIMEOUT);
pAd->Mlme.AutoWakeupTimerRunning = TRUE;
AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02); /* send POWER-SAVE command to MCU. Timeout 40us. */
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
}
#endif /* RTMP_MAC_USB // */

View file

@ -1,955 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#include <linux/sched.h>
#include "../rt_config.h"
/*
========================================================================
Routine Description:
Remove WPA Key process
Arguments:
pAd Pointer to our adapter
pBuf Pointer to the where the key stored
Return Value:
NDIS_SUCCESS Add key successfully
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPSetDesiredRates(struct rt_rtmp_adapter *pAdapter, long Rates)
{
NDIS_802_11_RATES aryRates;
memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
switch (pAdapter->CommonCfg.PhyMode) {
case PHY_11A: /* A only */
switch (Rates) {
case 6000000: /*6M */
aryRates[0] = 0x0c; /* 6M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_0;
break;
case 9000000: /*9M */
aryRates[0] = 0x12; /* 9M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_1;
break;
case 12000000: /*12M */
aryRates[0] = 0x18; /* 12M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_2;
break;
case 18000000: /*18M */
aryRates[0] = 0x24; /* 18M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_3;
break;
case 24000000: /*24M */
aryRates[0] = 0x30; /* 24M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_4;
break;
case 36000000: /*36M */
aryRates[0] = 0x48; /* 36M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_5;
break;
case 48000000: /*48M */
aryRates[0] = 0x60; /* 48M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_6;
break;
case 54000000: /*54M */
aryRates[0] = 0x6c; /* 54M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_7;
break;
case -1: /*Auto */
default:
aryRates[0] = 0x6c; /* 54Mbps */
aryRates[1] = 0x60; /* 48Mbps */
aryRates[2] = 0x48; /* 36Mbps */
aryRates[3] = 0x30; /* 24Mbps */
aryRates[4] = 0x24; /* 18M */
aryRates[5] = 0x18; /* 12M */
aryRates[6] = 0x12; /* 9M */
aryRates[7] = 0x0c; /* 6M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_AUTO;
break;
}
break;
case PHY_11BG_MIXED: /* B/G Mixed */
case PHY_11B: /* B only */
case PHY_11ABG_MIXED: /* A/B/G Mixed */
default:
switch (Rates) {
case 1000000: /*1M */
aryRates[0] = 0x02;
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_0;
break;
case 2000000: /*2M */
aryRates[0] = 0x04;
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_1;
break;
case 5000000: /*5.5M */
aryRates[0] = 0x0b; /* 5.5M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_2;
break;
case 11000000: /*11M */
aryRates[0] = 0x16; /* 11M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_3;
break;
case 6000000: /*6M */
aryRates[0] = 0x0c; /* 6M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_0;
break;
case 9000000: /*9M */
aryRates[0] = 0x12; /* 9M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_1;
break;
case 12000000: /*12M */
aryRates[0] = 0x18; /* 12M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_2;
break;
case 18000000: /*18M */
aryRates[0] = 0x24; /* 18M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_3;
break;
case 24000000: /*24M */
aryRates[0] = 0x30; /* 24M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_4;
break;
case 36000000: /*36M */
aryRates[0] = 0x48; /* 36M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_5;
break;
case 48000000: /*48M */
aryRates[0] = 0x60; /* 48M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_6;
break;
case 54000000: /*54M */
aryRates[0] = 0x6c; /* 54M */
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_7;
break;
case -1: /*Auto */
default:
if (pAdapter->CommonCfg.PhyMode == PHY_11B) { /*B Only */
aryRates[0] = 0x16; /* 11Mbps */
aryRates[1] = 0x0b; /* 5.5Mbps */
aryRates[2] = 0x04; /* 2Mbps */
aryRates[3] = 0x02; /* 1Mbps */
} else { /*(B/G) Mixed or (A/B/G) Mixed */
aryRates[0] = 0x6c; /* 54Mbps */
aryRates[1] = 0x60; /* 48Mbps */
aryRates[2] = 0x48; /* 36Mbps */
aryRates[3] = 0x30; /* 24Mbps */
aryRates[4] = 0x16; /* 11Mbps */
aryRates[5] = 0x0b; /* 5.5Mbps */
aryRates[6] = 0x04; /* 2Mbps */
aryRates[7] = 0x02; /* 1Mbps */
}
pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
MCS_AUTO;
break;
}
break;
}
NdisZeroMemory(pAdapter->CommonCfg.DesireRate,
MAX_LEN_OF_SUPPORTED_RATES);
NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates,
sizeof(NDIS_802_11_RATES));
DBGPRINT(RT_DEBUG_TRACE,
(" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
pAdapter->CommonCfg.DesireRate[0],
pAdapter->CommonCfg.DesireRate[1],
pAdapter->CommonCfg.DesireRate[2],
pAdapter->CommonCfg.DesireRate[3],
pAdapter->CommonCfg.DesireRate[4],
pAdapter->CommonCfg.DesireRate[5],
pAdapter->CommonCfg.DesireRate[6],
pAdapter->CommonCfg.DesireRate[7]));
/* Changing DesiredRate may affect the MAX TX rate we used to TX frames out */
MlmeUpdateTxRates(pAdapter, FALSE, 0);
}
/*
========================================================================
Routine Description:
Remove All WPA Keys
Arguments:
pAd Pointer to our adapter
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPWPARemoveAllKeys(struct rt_rtmp_adapter *pAd)
{
u8 i;
DBGPRINT(RT_DEBUG_TRACE,
("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n",
pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
/* For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after */
/* Link up. And it will be replaced if user changed it. */
if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
return;
/* For WPA-None, there is no need to remove it, since WinXP won't set it again after */
/* Link up. And it will be replaced if user changed it. */
if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
return;
/* set BSSID wcid entry of the Pair-wise Key table as no-security mode */
AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
/* set all shared key mode as no-security. */
for (i = 0; i < SHARE_KEY_NUM; i++) {
DBGPRINT(RT_DEBUG_TRACE,
("remove %s key #%d\n",
CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(struct rt_cipher_key));
AsicRemoveSharedKeyEntry(pAd, BSS0, i);
}
RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
}
/*
========================================================================
Routine Description:
As STA's BSSID is a WC too, it uses shared key table.
This function write correct unicast TX key to ASIC WCID.
And we still make a copy in our MacTab.Content[BSSID_WCID].PairwiseKey.
Caller guarantee TKIP/AES always has keyidx = 0. (pairwise key)
Caller guarantee WEP calls this function when set Txkey, default key index=0~3.
Arguments:
pAd Pointer to our adapter
pKey Pointer to the where the key stored
Return Value:
NDIS_SUCCESS Add key successfully
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
/*
========================================================================
Routine Description:
Change NIC PHY mode. Re-association may be necessary. possible settings
include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
Arguments:
pAd - Pointer to our adapter
phymode -
IRQL = PASSIVE_LEVEL
IRQL = DISPATCH_LEVEL
========================================================================
*/
void RTMPSetPhyMode(struct rt_rtmp_adapter *pAd, unsigned long phymode)
{
int i;
/* the selected phymode must be supported by the RF IC encoded in E2PROM */
/* if no change, do nothing */
/* bug fix
if (pAd->CommonCfg.PhyMode == phymode)
return;
*/
pAd->CommonCfg.PhyMode = (u8)phymode;
DBGPRINT(RT_DEBUG_TRACE,
("RTMPSetPhyMode : PhyMode=%d, channel=%d \n",
pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
BuildChannelList(pAd);
/* sanity check user setting */
for (i = 0; i < pAd->ChannelListNum; i++) {
if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
break;
}
if (i == pAd->ChannelListNum) {
pAd->CommonCfg.Channel = FirstChannel(pAd);
DBGPRINT(RT_DEBUG_ERROR,
("RTMPSetPhyMode: channel is out of range, use first channel=%d \n",
pAd->CommonCfg.Channel));
}
NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
switch (phymode) {
case PHY_11B:
pAd->CommonCfg.SupRate[0] = 0x82; /* 1 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[1] = 0x84; /* 2 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[2] = 0x8B; /* 5.5 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[3] = 0x96; /* 11 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRateLen = 4;
pAd->CommonCfg.ExtRateLen = 0;
pAd->CommonCfg.DesireRate[0] = 2; /* 1 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[1] = 4; /* 2 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[2] = 11; /* 5.5 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[3] = 22; /* 11 mbps, in units of 0.5 Mbps */
/*pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use */
break;
case PHY_11G:
case PHY_11BG_MIXED:
case PHY_11ABG_MIXED:
case PHY_11N_2_4G:
case PHY_11ABGN_MIXED:
case PHY_11BGN_MIXED:
case PHY_11GN_MIXED:
pAd->CommonCfg.SupRate[0] = 0x82; /* 1 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[1] = 0x84; /* 2 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[2] = 0x8B; /* 5.5 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[3] = 0x96; /* 11 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[4] = 0x12; /* 9 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRate[5] = 0x24; /* 18 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRate[6] = 0x48; /* 36 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRate[7] = 0x6c; /* 54 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRateLen = 8;
pAd->CommonCfg.ExtRate[0] = 0x0C; /* 6 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.ExtRate[1] = 0x18; /* 12 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.ExtRate[2] = 0x30; /* 24 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.ExtRate[3] = 0x60; /* 48 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.ExtRateLen = 4;
pAd->CommonCfg.DesireRate[0] = 2; /* 1 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[1] = 4; /* 2 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[2] = 11; /* 5.5 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[3] = 22; /* 11 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[4] = 12; /* 6 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[5] = 18; /* 9 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[6] = 24; /* 12 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[7] = 36; /* 18 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[8] = 48; /* 24 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[9] = 72; /* 36 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[10] = 96; /* 48 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[11] = 108; /* 54 mbps, in units of 0.5 Mbps */
break;
case PHY_11A:
case PHY_11AN_MIXED:
case PHY_11AGN_MIXED:
case PHY_11N_5G:
pAd->CommonCfg.SupRate[0] = 0x8C; /* 6 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[1] = 0x12; /* 9 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRate[2] = 0x98; /* 12 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[3] = 0x24; /* 18 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRate[4] = 0xb0; /* 24 mbps, in units of 0.5 Mbps, basic rate */
pAd->CommonCfg.SupRate[5] = 0x48; /* 36 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRate[6] = 0x60; /* 48 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRate[7] = 0x6c; /* 54 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.SupRateLen = 8;
pAd->CommonCfg.ExtRateLen = 0;
pAd->CommonCfg.DesireRate[0] = 12; /* 6 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[1] = 18; /* 9 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[2] = 24; /* 12 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[3] = 36; /* 18 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[4] = 48; /* 24 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[5] = 72; /* 36 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[6] = 96; /* 48 mbps, in units of 0.5 Mbps */
pAd->CommonCfg.DesireRate[7] = 108; /* 54 mbps, in units of 0.5 Mbps */
/*pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use */
break;
default:
break;
}
pAd->CommonCfg.BandState = UNKNOWN_BAND;
}
/*
========================================================================
Routine Description:
Caller ensures we has 802.11n support.
Calls at setting HT from AP/STASetinformation
Arguments:
pAd - Pointer to our adapter
phymode -
========================================================================
*/
void RTMPSetHT(struct rt_rtmp_adapter *pAd, struct rt_oid_set_ht_phymode *pHTPhyMode)
{
/*unsigned long *pmcs; */
u32 Value = 0;
u8 BBPValue = 0;
u8 BBP3Value = 0;
u8 RxStream = pAd->CommonCfg.RxStream;
DBGPRINT(RT_DEBUG_TRACE,
("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
pHTPhyMode->HtMode, pHTPhyMode->ExtOffset, pHTPhyMode->MCS,
pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
/* Don't zero supportedHyPhy structure. */
RTMPZeroMemory(&pAd->CommonCfg.HtCapability,
sizeof(pAd->CommonCfg.HtCapability));
RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo,
sizeof(pAd->CommonCfg.AddHTInfo));
RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset,
sizeof(pAd->CommonCfg.NewExtChanOffset));
RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy,
sizeof(pAd->CommonCfg.DesiredHtPhy));
if (pAd->CommonCfg.bRdg) {
pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
} else {
pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
}
pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
DBGPRINT(RT_DEBUG_TRACE,
("RTMPSetHT : RxBAWinLimit = %d\n",
pAd->CommonCfg.BACapability.field.RxBAWinLimit));
/* Mimo power save, A-MSDU size, */
pAd->CommonCfg.DesiredHtPhy.AmsduEnable =
(u16)pAd->CommonCfg.BACapability.field.AmsduEnable;
pAd->CommonCfg.DesiredHtPhy.AmsduSize =
(u8)pAd->CommonCfg.BACapability.field.AmsduSize;
pAd->CommonCfg.DesiredHtPhy.MimoPs =
(u8)pAd->CommonCfg.BACapability.field.MMPSmode;
pAd->CommonCfg.DesiredHtPhy.MpduDensity =
(u8)pAd->CommonCfg.BACapability.field.MpduDensity;
pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize =
(u16)pAd->CommonCfg.BACapability.field.AmsduSize;
pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs =
(u16)pAd->CommonCfg.BACapability.field.MMPSmode;
pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity =
(u8)pAd->CommonCfg.BACapability.field.MpduDensity;
DBGPRINT(RT_DEBUG_TRACE,
("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
pAd->CommonCfg.DesiredHtPhy.AmsduSize,
pAd->CommonCfg.DesiredHtPhy.MimoPs,
pAd->CommonCfg.DesiredHtPhy.MpduDensity,
pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
if (pHTPhyMode->HtMode == HTMODE_GF) {
pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
pAd->CommonCfg.DesiredHtPhy.GF = 1;
} else
pAd->CommonCfg.DesiredHtPhy.GF = 0;
/* Decide Rx MCSSet */
switch (RxStream) {
case 1:
pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
break;
case 2:
pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
break;
case 3: /* 3*3 */
pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
break;
}
if (pAd->CommonCfg.bForty_Mhz_Intolerant
&& (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40)) {
pHTPhyMode->BW = BW_20;
pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
}
if (pHTPhyMode->BW == BW_40) {
pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; /* MCS 32 */
pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
if (pAd->CommonCfg.Channel <= 14)
pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset =
(pHTPhyMode->ExtOffset ==
EXTCHA_BELOW) ? (EXTCHA_BELOW) : EXTCHA_ABOVE;
/* Set Regsiter for extension channel position. */
RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW)) {
Value |= 0x1;
BBP3Value |= (0x20);
RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
} else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE)) {
Value &= 0xfe;
BBP3Value &= (~0x20);
RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
}
/* Turn on BBP 40MHz mode now only as AP . */
/* Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection. */
if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
) {
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
BBPValue |= 0x10;
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
pAd->CommonCfg.BBPCurrentBW = BW_40;
}
} else {
pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
/* Turn on BBP 20MHz mode by request here. */
{
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
pAd->CommonCfg.BBPCurrentBW = BW_20;
}
}
if (pHTPhyMode->STBC == STBC_USE) {
pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
} else {
pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
}
if (pHTPhyMode->SHORTGI == GI_400) {
pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
} else {
pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
}
/* We support link adaptation for unsolicit MCS feedback, set to 2. */
pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; /*MCSFBK_UNSOLICIT; */
pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
/* 1, the extension channel above the control channel. */
/* EDCA parameters used for AP's own transmission */
if (pAd->CommonCfg.APEdcaParm.bValid == FALSE) {
pAd->CommonCfg.APEdcaParm.bValid = TRUE;
pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
}
AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
{
RTMPSetIndividualHT(pAd, 0);
}
}
/*
========================================================================
Routine Description:
Caller ensures we has 802.11n support.
Calls at setting HT from AP/STASetinformation
Arguments:
pAd - Pointer to our adapter
phymode -
========================================================================
*/
void RTMPSetIndividualHT(struct rt_rtmp_adapter *pAd, u8 apidx)
{
struct rt_ht_phy_info *pDesired_ht_phy = NULL;
u8 TxStream = pAd->CommonCfg.TxStream;
u8 DesiredMcs = MCS_AUTO;
do {
{
pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
DesiredMcs =
pAd->StaCfg.DesiredTransmitSetting.field.MCS;
/*pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE; */
break;
}
} while (FALSE);
if (pDesired_ht_phy == NULL) {
DBGPRINT(RT_DEBUG_ERROR,
("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
return;
}
RTMPZeroMemory(pDesired_ht_phy, sizeof(struct rt_ht_phy_info));
DBGPRINT(RT_DEBUG_TRACE,
("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
/* Check the validity of MCS */
if ((TxStream == 1)
&& ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15))) {
DBGPRINT(RT_DEBUG_WARN,
("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n",
DesiredMcs));
DesiredMcs = MCS_7;
}
if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20)
&& (DesiredMcs == MCS_32)) {
DBGPRINT(RT_DEBUG_WARN,
("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
DesiredMcs = MCS_0;
}
pDesired_ht_phy->bHtEnable = TRUE;
/* Decide desired Tx MCS */
switch (TxStream) {
case 1:
if (DesiredMcs == MCS_AUTO) {
pDesired_ht_phy->MCSSet[0] = 0xff;
pDesired_ht_phy->MCSSet[1] = 0x00;
} else if (DesiredMcs <= MCS_7) {
pDesired_ht_phy->MCSSet[0] = 1 << DesiredMcs;
pDesired_ht_phy->MCSSet[1] = 0x00;
}
break;
case 2:
if (DesiredMcs == MCS_AUTO) {
pDesired_ht_phy->MCSSet[0] = 0xff;
pDesired_ht_phy->MCSSet[1] = 0xff;
} else if (DesiredMcs <= MCS_15) {
unsigned long mode;
mode = DesiredMcs / 8;
if (mode < 2)
pDesired_ht_phy->MCSSet[mode] =
(1 << (DesiredMcs - mode * 8));
}
break;
case 3: /* 3*3 */
if (DesiredMcs == MCS_AUTO) {
/* MCS0 ~ MCS23, 3 bytes */
pDesired_ht_phy->MCSSet[0] = 0xff;
pDesired_ht_phy->MCSSet[1] = 0xff;
pDesired_ht_phy->MCSSet[2] = 0xff;
} else if (DesiredMcs <= MCS_23) {
unsigned long mode;
mode = DesiredMcs / 8;
if (mode < 3)
pDesired_ht_phy->MCSSet[mode] =
(1 << (DesiredMcs - mode * 8));
}
break;
}
if (pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40) {
if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
pDesired_ht_phy->MCSSet[4] = 0x1;
}
/* update HT Rate setting */
if (pAd->OpMode == OPMODE_STA)
MlmeUpdateHtTxRates(pAd, BSS0);
else
MlmeUpdateHtTxRates(pAd, apidx);
}
/*
========================================================================
Routine Description:
Update HT IE from our capability.
Arguments:
Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
========================================================================
*/
void RTMPUpdateHTIE(struct rt_ht_capability *pRtHt,
u8 * pMcsSet,
struct rt_ht_capability_ie * pHtCapability,
struct rt_add_ht_info_ie * pAddHtInfo)
{
RTMPZeroMemory(pHtCapability, sizeof(struct rt_ht_capability_ie));
RTMPZeroMemory(pAddHtInfo, sizeof(struct rt_add_ht_info_ie));
pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
pHtCapability->HtCapInfo.GF = pRtHt->GF;
pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset;
pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet */ pMcsSet, 4); /* rt2860 only support MCS max=32, no need to copy all 16 uchar. */
DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateHTIE <== \n"));
}
/*
========================================================================
Description:
Add Client security information into ASIC WCID table and IVEIV table.
Return:
========================================================================
*/
void RTMPAddWcidAttributeEntry(struct rt_rtmp_adapter *pAd,
u8 BssIdx,
u8 KeyIdx,
u8 CipherAlg, struct rt_mac_table_entry *pEntry)
{
u32 WCIDAttri = 0;
u16 offset;
u8 IVEIV = 0;
u16 Wcid = 0;
{
{
if (BssIdx > BSS0) {
DBGPRINT(RT_DEBUG_ERROR,
("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n",
BssIdx));
return;
}
/* 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists. */
/* 2. In Infra mode, the AID:1 MUST be wcid of infra STA. */
/* the AID:2~ assign to mesh link entry. */
if (pEntry)
Wcid = pEntry->Aid;
else
Wcid = MCAST_WCID;
}
}
/* Update WCID attribute table */
offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
{
if (pEntry && pEntry->ValidAsMesh)
WCIDAttri = (CipherAlg << 1) | PAIRWISEKEYTABLE;
else
WCIDAttri = (CipherAlg << 1) | SHAREDKEYTABLE;
}
RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
/* Update IV/EIV table */
offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
/* WPA mode */
if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC)
|| (CipherAlg == CIPHER_AES)) {
/* Eiv bit on. keyid always is 0 for pairwise key */
IVEIV = (KeyIdx << 6) | 0x20;
} else {
/* WEP KeyIdx is default tx key. */
IVEIV = (KeyIdx << 6);
}
/* For key index and ext IV bit, so only need to update the position(offset+3). */
#ifdef RTMP_MAC_PCI
RTMP_IO_WRITE8(pAd, offset + 3, IVEIV);
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
RTUSBMultiWrite_OneByte(pAd, offset + 3, &IVEIV);
#endif /* RTMP_MAC_USB // */
DBGPRINT(RT_DEBUG_TRACE,
("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",
Wcid, KeyIdx, CipherName[CipherAlg]));
DBGPRINT(RT_DEBUG_TRACE, (" WCIDAttri = 0x%x \n", WCIDAttri));
}
/*
==========================================================================
Description:
Parse encryption type
Arguments:
pAdapter Pointer to our adapter
wrq Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
char *GetEncryptType(char enc)
{
if (enc == Ndis802_11WEPDisabled)
return "NONE";
if (enc == Ndis802_11WEPEnabled)
return "WEP";
if (enc == Ndis802_11Encryption2Enabled)
return "TKIP";
if (enc == Ndis802_11Encryption3Enabled)
return "AES";
if (enc == Ndis802_11Encryption4Enabled)
return "TKIPAES";
else
return "UNKNOW";
}
char *GetAuthMode(char auth)
{
if (auth == Ndis802_11AuthModeOpen)
return "OPEN";
if (auth == Ndis802_11AuthModeShared)
return "SHARED";
if (auth == Ndis802_11AuthModeAutoSwitch)
return "AUTOWEP";
if (auth == Ndis802_11AuthModeWPA)
return "WPA";
if (auth == Ndis802_11AuthModeWPAPSK)
return "WPAPSK";
if (auth == Ndis802_11AuthModeWPANone)
return "WPANONE";
if (auth == Ndis802_11AuthModeWPA2)
return "WPA2";
if (auth == Ndis802_11AuthModeWPA2PSK)
return "WPA2PSK";
if (auth == Ndis802_11AuthModeWPA1WPA2)
return "WPA1WPA2";
if (auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
return "WPA1PSKWPA2PSK";
return "UNKNOW";
}
int SetCommonHT(struct rt_rtmp_adapter *pAd)
{
struct rt_oid_set_ht_phymode SetHT;
if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
return FALSE;
SetHT.PhyMode = pAd->CommonCfg.PhyMode;
SetHT.TransmitNo = ((u8)pAd->Antenna.field.TxPath);
SetHT.HtMode = (u8)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
SetHT.ExtOffset =
(u8)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
SetHT.MCS = MCS_AUTO;
SetHT.BW = (u8)pAd->CommonCfg.RegTransmitSetting.field.BW;
SetHT.STBC = (u8)pAd->CommonCfg.RegTransmitSetting.field.STBC;
SetHT.SHORTGI = (u8)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
RTMPSetHT(pAd, &SetHT);
return TRUE;
}
char *RTMPGetRalinkEncryModeStr(u16 encryMode)
{
switch (encryMode) {
case Ndis802_11WEPDisabled:
return "NONE";
case Ndis802_11WEPEnabled:
return "WEP";
case Ndis802_11Encryption2Enabled:
return "TKIP";
case Ndis802_11Encryption3Enabled:
return "AES";
case Ndis802_11Encryption4Enabled:
return "TKIPAES";
default:
return "UNKNOW";
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,718 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
cmm_sync.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
John Chang 2004-09-01 modified for rt2561/2661
*/
#include "../rt_config.h"
/* 2.4 Ghz channel plan index in the TxPower arrays. */
#define BG_BAND_REGION_0_START 0 /* 1,2,3,4,5,6,7,8,9,10,11 */
#define BG_BAND_REGION_0_SIZE 11
#define BG_BAND_REGION_1_START 0 /* 1,2,3,4,5,6,7,8,9,10,11,12,13 */
#define BG_BAND_REGION_1_SIZE 13
#define BG_BAND_REGION_2_START 9 /* 10,11 */
#define BG_BAND_REGION_2_SIZE 2
#define BG_BAND_REGION_3_START 9 /* 10,11,12,13 */
#define BG_BAND_REGION_3_SIZE 4
#define BG_BAND_REGION_4_START 13 /* 14 */
#define BG_BAND_REGION_4_SIZE 1
#define BG_BAND_REGION_5_START 0 /* 1,2,3,4,5,6,7,8,9,10,11,12,13,14 */
#define BG_BAND_REGION_5_SIZE 14
#define BG_BAND_REGION_6_START 2 /* 3,4,5,6,7,8,9 */
#define BG_BAND_REGION_6_SIZE 7
#define BG_BAND_REGION_7_START 4 /* 5,6,7,8,9,10,11,12,13 */
#define BG_BAND_REGION_7_SIZE 9
#define BG_BAND_REGION_31_START 0 /* 1,2,3,4,5,6,7,8,9,10,11,12,13,14 */
#define BG_BAND_REGION_31_SIZE 14
/* 5 Ghz channel plan index in the TxPower arrays. */
u8 A_BAND_REGION_0_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165 };
u8 A_BAND_REGION_1_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
132, 136, 140 };
u8 A_BAND_REGION_2_CHANNEL_LIST[] = { 36, 40, 44, 48, 52, 56, 60, 64 };
u8 A_BAND_REGION_3_CHANNEL_LIST[] = { 52, 56, 60, 64, 149, 153, 157, 161 };
u8 A_BAND_REGION_4_CHANNEL_LIST[] = { 149, 153, 157, 161, 165 };
u8 A_BAND_REGION_5_CHANNEL_LIST[] = { 149, 153, 157, 161 };
u8 A_BAND_REGION_6_CHANNEL_LIST[] = { 36, 40, 44, 48 };
u8 A_BAND_REGION_7_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
132, 136, 140, 149, 153, 157, 161, 165, 169, 173 };
u8 A_BAND_REGION_8_CHANNEL_LIST[] = { 52, 56, 60, 64 };
u8 A_BAND_REGION_9_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140,
149, 153, 157, 161, 165 };
u8 A_BAND_REGION_10_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 149, 153, 157, 161, 165 };
u8 A_BAND_REGION_11_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153,
157, 161 };
u8 A_BAND_REGION_12_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
132, 136, 140 };
u8 A_BAND_REGION_13_CHANNEL_LIST[] =
{ 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
149, 153, 157, 161 };
u8 A_BAND_REGION_14_CHANNEL_LIST[] =
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149,
153, 157, 161, 165 };
u8 A_BAND_REGION_15_CHANNEL_LIST[] = { 149, 153, 157, 161, 165, 169, 173 };
/*BaSizeArray follows the 802.11n definition as MaxRxFactor. 2^(13+factor) bytes. When factor =0, it's about Ba buffer size =8. */
u8 BaSizeArray[4] = { 8, 16, 32, 64 };
/*
==========================================================================
Description:
Update StaCfg->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.
IRQL = PASSIVE_LEVEL
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void BuildChannelList(struct rt_rtmp_adapter *pAd)
{
u8 i, j, index = 0, num = 0;
u8 *pChannelList = NULL;
NdisZeroMemory(pAd->ChannelList,
MAX_NUM_OF_CHANNELS * sizeof(struct rt_channel_tx_power));
/* if not 11a-only mode, channel list starts from 2.4Ghz band */
if ((pAd->CommonCfg.PhyMode != PHY_11A)
&& (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED)
&& (pAd->CommonCfg.PhyMode != PHY_11N_5G)
) {
switch (pAd->CommonCfg.CountryRegion & 0x7f) {
case REGION_0_BG_BAND: /* 1 -11 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_0_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_0_SIZE);
index += BG_BAND_REGION_0_SIZE;
break;
case REGION_1_BG_BAND: /* 1 - 13 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_1_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_1_SIZE);
index += BG_BAND_REGION_1_SIZE;
break;
case REGION_2_BG_BAND: /* 10 - 11 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_2_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_2_SIZE);
index += BG_BAND_REGION_2_SIZE;
break;
case REGION_3_BG_BAND: /* 10 - 13 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_3_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_3_SIZE);
index += BG_BAND_REGION_3_SIZE;
break;
case REGION_4_BG_BAND: /* 14 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_4_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_4_SIZE);
index += BG_BAND_REGION_4_SIZE;
break;
case REGION_5_BG_BAND: /* 1 - 14 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_5_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_5_SIZE);
index += BG_BAND_REGION_5_SIZE;
break;
case REGION_6_BG_BAND: /* 3 - 9 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_6_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_6_SIZE);
index += BG_BAND_REGION_6_SIZE;
break;
case REGION_7_BG_BAND: /* 5 - 13 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_7_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_7_SIZE);
index += BG_BAND_REGION_7_SIZE;
break;
case REGION_31_BG_BAND: /* 1 - 14 */
NdisMoveMemory(&pAd->ChannelList[index],
&pAd->TxPower[BG_BAND_REGION_31_START],
sizeof(struct rt_channel_tx_power) *
BG_BAND_REGION_31_SIZE);
index += BG_BAND_REGION_31_SIZE;
break;
default: /* Error. should never happen */
break;
}
for (i = 0; i < index; i++)
pAd->ChannelList[i].MaxTxPwr = 20;
}
if ((pAd->CommonCfg.PhyMode == PHY_11A)
|| (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)
|| (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
|| (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
|| (pAd->CommonCfg.PhyMode == PHY_11N_5G)
) {
switch (pAd->CommonCfg.CountryRegionForABand & 0x7f) {
case REGION_0_A_BAND:
num =
sizeof(A_BAND_REGION_0_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_0_CHANNEL_LIST;
break;
case REGION_1_A_BAND:
num =
sizeof(A_BAND_REGION_1_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_1_CHANNEL_LIST;
break;
case REGION_2_A_BAND:
num =
sizeof(A_BAND_REGION_2_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_2_CHANNEL_LIST;
break;
case REGION_3_A_BAND:
num =
sizeof(A_BAND_REGION_3_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_3_CHANNEL_LIST;
break;
case REGION_4_A_BAND:
num =
sizeof(A_BAND_REGION_4_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_4_CHANNEL_LIST;
break;
case REGION_5_A_BAND:
num =
sizeof(A_BAND_REGION_5_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_5_CHANNEL_LIST;
break;
case REGION_6_A_BAND:
num =
sizeof(A_BAND_REGION_6_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_6_CHANNEL_LIST;
break;
case REGION_7_A_BAND:
num =
sizeof(A_BAND_REGION_7_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_7_CHANNEL_LIST;
break;
case REGION_8_A_BAND:
num =
sizeof(A_BAND_REGION_8_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_8_CHANNEL_LIST;
break;
case REGION_9_A_BAND:
num =
sizeof(A_BAND_REGION_9_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_9_CHANNEL_LIST;
break;
case REGION_10_A_BAND:
num =
sizeof(A_BAND_REGION_10_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_10_CHANNEL_LIST;
break;
case REGION_11_A_BAND:
num =
sizeof(A_BAND_REGION_11_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
break;
case REGION_12_A_BAND:
num =
sizeof(A_BAND_REGION_12_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_12_CHANNEL_LIST;
break;
case REGION_13_A_BAND:
num =
sizeof(A_BAND_REGION_13_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_13_CHANNEL_LIST;
break;
case REGION_14_A_BAND:
num =
sizeof(A_BAND_REGION_14_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_14_CHANNEL_LIST;
break;
case REGION_15_A_BAND:
num =
sizeof(A_BAND_REGION_15_CHANNEL_LIST) /
sizeof(u8);
pChannelList = A_BAND_REGION_15_CHANNEL_LIST;
break;
default: /* Error. should never happen */
DBGPRINT(RT_DEBUG_WARN,
("countryregion=%d not support",
pAd->CommonCfg.CountryRegionForABand));
break;
}
if (num != 0) {
u8 RadarCh[15] =
{ 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124,
128, 132, 136, 140 };
for (i = 0; i < num; i++) {
for (j = 0; j < MAX_NUM_OF_CHANNELS; j++) {
if (pChannelList[i] ==
pAd->TxPower[j].Channel)
NdisMoveMemory(&pAd->
ChannelList[index
+ i],
&pAd->TxPower[j],
sizeof
(struct rt_channel_tx_power));
}
for (j = 0; j < 15; j++) {
if (pChannelList[i] == RadarCh[j])
pAd->ChannelList[index +
i].DfsReq =
TRUE;
}
pAd->ChannelList[index + i].MaxTxPwr = 20;
}
index += num;
}
}
pAd->ChannelListNum = index;
DBGPRINT(RT_DEBUG_TRACE,
("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n",
pAd->CommonCfg.CountryRegion,
pAd->CommonCfg.CountryRegionForABand, pAd->RfIcType,
pAd->CommonCfg.PhyMode, pAd->ChannelListNum));
#ifdef DBG
for (i = 0; i < pAd->ChannelListNum; i++) {
DBGPRINT_RAW(RT_DEBUG_TRACE,
("BuildChannel # %d :: Pwr0 = %d, Pwr1 =%d, \n ",
pAd->ChannelList[i].Channel,
pAd->ChannelList[i].Power,
pAd->ChannelList[i].Power2));
}
#endif
}
/*
==========================================================================
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
IRQL = PASSIVE_LEVEL
==========================================================================
*/
u8 FirstChannel(struct rt_rtmp_adapter *pAd)
{
return pAd->ChannelList[0].Channel;
}
/*
==========================================================================
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
==========================================================================
*/
u8 NextChannel(struct rt_rtmp_adapter *pAd, u8 channel)
{
int i;
u8 next_channel = 0;
for (i = 0; i < (pAd->ChannelListNum - 1); i++)
if (channel == pAd->ChannelList[i].Channel) {
next_channel = pAd->ChannelList[i + 1].Channel;
break;
}
return next_channel;
}
/*
==========================================================================
Description:
This routine is for Cisco Compatible Extensions 2.X
Spec31. AP Control of Client Transmit Power
Return:
None
Note:
Required by Aironet dBm(mW)
0dBm(1mW), 1dBm(5mW), 13dBm(20mW), 15dBm(30mW),
17dBm(50mw), 20dBm(100mW)
We supported
3dBm(Lowest), 6dBm(10%), 9dBm(25%), 12dBm(50%),
14dBm(75%), 15dBm(100%)
The client station's actual transmit power shall be within +/- 5dB of
the minimum value or next lower value.
==========================================================================
*/
void ChangeToCellPowerLimit(struct rt_rtmp_adapter *pAd,
u8 AironetCellPowerLimit)
{
/*valud 0xFF means that hasn't found power limit information */
/*from the AP's Beacon/Probe response. */
if (AironetCellPowerLimit == 0xFF)
return;
if (AironetCellPowerLimit < 6) /*Used Lowest Power Percentage. */
pAd->CommonCfg.TxPowerPercentage = 6;
else if (AironetCellPowerLimit < 9)
pAd->CommonCfg.TxPowerPercentage = 10;
else if (AironetCellPowerLimit < 12)
pAd->CommonCfg.TxPowerPercentage = 25;
else if (AironetCellPowerLimit < 14)
pAd->CommonCfg.TxPowerPercentage = 50;
else if (AironetCellPowerLimit < 15)
pAd->CommonCfg.TxPowerPercentage = 75;
else
pAd->CommonCfg.TxPowerPercentage = 100; /*else used maximum */
if (pAd->CommonCfg.TxPowerPercentage > pAd->CommonCfg.TxPowerDefault)
pAd->CommonCfg.TxPowerPercentage =
pAd->CommonCfg.TxPowerDefault;
}
char ConvertToRssi(struct rt_rtmp_adapter *pAd, char Rssi, u8 RssiNumber)
{
u8 RssiOffset, LNAGain;
/* Rssi equals to zero should be an invalid value */
if (Rssi == 0)
return -99;
LNAGain = GET_LNA_GAIN(pAd);
if (pAd->LatchRfRegs.Channel > 14) {
if (RssiNumber == 0)
RssiOffset = pAd->ARssiOffset0;
else if (RssiNumber == 1)
RssiOffset = pAd->ARssiOffset1;
else
RssiOffset = pAd->ARssiOffset2;
} else {
if (RssiNumber == 0)
RssiOffset = pAd->BGRssiOffset0;
else if (RssiNumber == 1)
RssiOffset = pAd->BGRssiOffset1;
else
RssiOffset = pAd->BGRssiOffset2;
}
return (-12 - RssiOffset - LNAGain - Rssi);
}
/*
==========================================================================
Description:
Scan next channel
==========================================================================
*/
void ScanNextChannel(struct rt_rtmp_adapter *pAd)
{
struct rt_header_802_11 Hdr80211;
u8 *pOutBuffer = NULL;
int NStatus;
unsigned long FrameLen = 0;
u8 SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0;
u16 Status;
struct rt_header_802_11 * pHdr80211;
u32 ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
{
if (MONITOR_ON(pAd))
return;
}
if (pAd->MlmeAux.Channel == 0) {
if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
&& (INFRA_ON(pAd)
|| (pAd->OpMode == OPMODE_AP))
) {
AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel,
FALSE);
AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
BBPValue |= 0x10;
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",
pAd->CommonCfg.CentralChannel,
pAd->ScanTab.BssNr));
} else {
AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
AsicLockChannel(pAd, pAd->CommonCfg.Channel);
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",
pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
}
{
/* */
/* To prevent data lost. */
/* Send an NULL data with turned PSM bit on to current associated AP before SCAN progress. */
/* Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done */
/* */
if (OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
&& (INFRA_ON(pAd))) {
NStatus =
MlmeAllocateMemory(pAd,
(void *)& pOutBuffer);
if (NStatus == NDIS_STATUS_SUCCESS) {
pHdr80211 = (struct rt_header_802_11 *) pOutBuffer;
MgtMacHeaderInit(pAd, pHdr80211,
SUBTYPE_NULL_FUNC, 1,
pAd->CommonCfg.Bssid,
pAd->CommonCfg.Bssid);
pHdr80211->Duration = 0;
pHdr80211->FC.Type = BTYPE_DATA;
pHdr80211->FC.PwrMgmt =
(pAd->StaCfg.Psm == PWR_SAVE);
/* Send using priority queue */
MiniportMMRequest(pAd, 0, pOutBuffer,
sizeof
(struct rt_header_802_11));
DBGPRINT(RT_DEBUG_TRACE,
("MlmeScanReqAction -- Send PSM Data frame\n"));
MlmeFreeMemory(pAd, pOutBuffer);
RTMPusecDelay(5000);
}
}
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF,
2, &Status);
}
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
}
#ifdef RTMP_MAC_USB
else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)
&& (pAd->OpMode == OPMODE_STA)) {
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE);
}
#endif /* RTMP_MAC_USB // */
else {
{
/* BBP and RF are not accessible in PS mode, we has to wake them up first */
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
AsicForceWakeup(pAd, TRUE);
/* leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON */
if (pAd->StaCfg.Psm == PWR_SAVE)
RTMP_SET_PSM_BIT(pAd, PWR_ACTIVE);
}
AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, TRUE);
AsicLockChannel(pAd, pAd->MlmeAux.Channel);
{
if (pAd->MlmeAux.Channel > 14) {
if ((pAd->CommonCfg.bIEEE80211H == 1)
&& RadarChannelCheck(pAd,
pAd->MlmeAux.
Channel)) {
ScanType = SCAN_PASSIVE;
ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
}
}
}
/*Global country domain(ch1-11:active scan, ch12-14 passive scan) */
if ((pAd->MlmeAux.Channel <= 14) && (pAd->MlmeAux.Channel >= 12)
&& ((pAd->CommonCfg.CountryRegion & 0x7f) ==
REGION_31_BG_BAND)) {
ScanType = SCAN_PASSIVE;
}
/* We need to shorten active scan time in order for WZC connect issue */
/* Chnage the channel scan time for CISCO stuff based on its IAPP announcement */
if (ScanType == FAST_SCAN_ACTIVE)
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
FAST_ACTIVE_SCAN_TIME);
else /* must be SCAN_PASSIVE or SCAN_ACTIVE */
{
if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)
|| (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
) {
if (pAd->MlmeAux.Channel > 14)
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
ScanTimeIn5gChannel);
else
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
MIN_CHANNEL_TIME);
} else
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
MAX_CHANNEL_TIME);
}
if ((ScanType == SCAN_ACTIVE)
|| (ScanType == FAST_SCAN_ACTIVE)
) {
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*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;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
MT2_SCAN_CONF, 2, &Status);
}
return;
}
/* There is no need to send broadcast probe request if active scan is in effect. */
if ((ScanType == SCAN_ACTIVE)
|| (ScanType == FAST_SCAN_ACTIVE)
)
SsidLen = pAd->MlmeAux.SsidLen;
else
SsidLen = 0;
MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0,
BROADCAST_ADDR, BROADCAST_ADDR);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(struct rt_header_802_11), &Hdr80211, 1,
&SsidIe, 1, &SsidLen, SsidLen,
pAd->MlmeAux.Ssid, 1, &SupRateIe, 1,
&pAd->CommonCfg.SupRateLen,
pAd->CommonCfg.SupRateLen,
pAd->CommonCfg.SupRate, END_OF_ARGS);
if (pAd->CommonCfg.ExtRateLen) {
unsigned long Tmp;
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
1, &ExtRateIe,
1, &pAd->CommonCfg.ExtRateLen,
pAd->CommonCfg.ExtRateLen,
pAd->CommonCfg.ExtRate,
END_OF_ARGS);
FrameLen += Tmp;
}
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
unsigned long Tmp;
u8 HtLen;
u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
if (pAd->bBroadComHT == TRUE) {
HtLen =
pAd->MlmeAux.HtCapabilityLen + 4;
MakeOutgoingFrame(pOutBuffer + FrameLen,
&Tmp, 1, &WpaIe, 1,
&HtLen, 4,
&BROADCOM[0],
pAd->MlmeAux.
HtCapabilityLen,
&pAd->MlmeAux.
HtCapability,
END_OF_ARGS);
} else {
HtLen = pAd->MlmeAux.HtCapabilityLen;
MakeOutgoingFrame(pOutBuffer + FrameLen,
&Tmp, 1, &HtCapIe, 1,
&HtLen, HtLen,
&pAd->CommonCfg.
HtCapability,
END_OF_ARGS);
}
FrameLen += Tmp;
}
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
}
/* For SCAN_CISCO_PASSIVE, do nothing and silently wait for beacon or other probe response */
pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
}
}
void MgtProbReqMacHeaderInit(struct rt_rtmp_adapter *pAd,
struct rt_header_802_11 * pHdr80211,
u8 SubType,
u8 ToDs, u8 *pDA, u8 *pBssid)
{
NdisZeroMemory(pHdr80211, sizeof(struct rt_header_802_11));
pHdr80211->FC.Type = BTYPE_MGMT;
pHdr80211->FC.SubType = SubType;
if (SubType == SUBTYPE_ACK)
pHdr80211->FC.Type = BTYPE_CNTL;
pHdr80211->FC.ToDs = ToDs;
COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
}

View file

@ -1,833 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
cmm_tkip.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Wu 02-25-02 Initial
*/
#include "../rt_config.h"
/* Rotation functions on 32 bit values */
#define ROL32( A, n ) \
( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
#define ROR32( A, n ) ROL32( (A), 32-(n) )
u32 Tkip_Sbox_Lower[256] = {
0xA5, 0x84, 0x99, 0x8D, 0x0D, 0xBD, 0xB1, 0x54,
0x50, 0x03, 0xA9, 0x7D, 0x19, 0x62, 0xE6, 0x9A,
0x45, 0x9D, 0x40, 0x87, 0x15, 0xEB, 0xC9, 0x0B,
0xEC, 0x67, 0xFD, 0xEA, 0xBF, 0xF7, 0x96, 0x5B,
0xC2, 0x1C, 0xAE, 0x6A, 0x5A, 0x41, 0x02, 0x4F,
0x5C, 0xF4, 0x34, 0x08, 0x93, 0x73, 0x53, 0x3F,
0x0C, 0x52, 0x65, 0x5E, 0x28, 0xA1, 0x0F, 0xB5,
0x09, 0x36, 0x9B, 0x3D, 0x26, 0x69, 0xCD, 0x9F,
0x1B, 0x9E, 0x74, 0x2E, 0x2D, 0xB2, 0xEE, 0xFB,
0xF6, 0x4D, 0x61, 0xCE, 0x7B, 0x3E, 0x71, 0x97,
0xF5, 0x68, 0x00, 0x2C, 0x60, 0x1F, 0xC8, 0xED,
0xBE, 0x46, 0xD9, 0x4B, 0xDE, 0xD4, 0xE8, 0x4A,
0x6B, 0x2A, 0xE5, 0x16, 0xC5, 0xD7, 0x55, 0x94,
0xCF, 0x10, 0x06, 0x81, 0xF0, 0x44, 0xBA, 0xE3,
0xF3, 0xFE, 0xC0, 0x8A, 0xAD, 0xBC, 0x48, 0x04,
0xDF, 0xC1, 0x75, 0x63, 0x30, 0x1A, 0x0E, 0x6D,
0x4C, 0x14, 0x35, 0x2F, 0xE1, 0xA2, 0xCC, 0x39,
0x57, 0xF2, 0x82, 0x47, 0xAC, 0xE7, 0x2B, 0x95,
0xA0, 0x98, 0xD1, 0x7F, 0x66, 0x7E, 0xAB, 0x83,
0xCA, 0x29, 0xD3, 0x3C, 0x79, 0xE2, 0x1D, 0x76,
0x3B, 0x56, 0x4E, 0x1E, 0xDB, 0x0A, 0x6C, 0xE4,
0x5D, 0x6E, 0xEF, 0xA6, 0xA8, 0xA4, 0x37, 0x8B,
0x32, 0x43, 0x59, 0xB7, 0x8C, 0x64, 0xD2, 0xE0,
0xB4, 0xFA, 0x07, 0x25, 0xAF, 0x8E, 0xE9, 0x18,
0xD5, 0x88, 0x6F, 0x72, 0x24, 0xF1, 0xC7, 0x51,
0x23, 0x7C, 0x9C, 0x21, 0xDD, 0xDC, 0x86, 0x85,
0x90, 0x42, 0xC4, 0xAA, 0xD8, 0x05, 0x01, 0x12,
0xA3, 0x5F, 0xF9, 0xD0, 0x91, 0x58, 0x27, 0xB9,
0x38, 0x13, 0xB3, 0x33, 0xBB, 0x70, 0x89, 0xA7,
0xB6, 0x22, 0x92, 0x20, 0x49, 0xFF, 0x78, 0x7A,
0x8F, 0xF8, 0x80, 0x17, 0xDA, 0x31, 0xC6, 0xB8,
0xC3, 0xB0, 0x77, 0x11, 0xCB, 0xFC, 0xD6, 0x3A
};
u32 Tkip_Sbox_Upper[256] = {
0xC6, 0xF8, 0xEE, 0xF6, 0xFF, 0xD6, 0xDE, 0x91,
0x60, 0x02, 0xCE, 0x56, 0xE7, 0xB5, 0x4D, 0xEC,
0x8F, 0x1F, 0x89, 0xFA, 0xEF, 0xB2, 0x8E, 0xFB,
0x41, 0xB3, 0x5F, 0x45, 0x23, 0x53, 0xE4, 0x9B,
0x75, 0xE1, 0x3D, 0x4C, 0x6C, 0x7E, 0xF5, 0x83,
0x68, 0x51, 0xD1, 0xF9, 0xE2, 0xAB, 0x62, 0x2A,
0x08, 0x95, 0x46, 0x9D, 0x30, 0x37, 0x0A, 0x2F,
0x0E, 0x24, 0x1B, 0xDF, 0xCD, 0x4E, 0x7F, 0xEA,
0x12, 0x1D, 0x58, 0x34, 0x36, 0xDC, 0xB4, 0x5B,
0xA4, 0x76, 0xB7, 0x7D, 0x52, 0xDD, 0x5E, 0x13,
0xA6, 0xB9, 0x00, 0xC1, 0x40, 0xE3, 0x79, 0xB6,
0xD4, 0x8D, 0x67, 0x72, 0x94, 0x98, 0xB0, 0x85,
0xBB, 0xC5, 0x4F, 0xED, 0x86, 0x9A, 0x66, 0x11,
0x8A, 0xE9, 0x04, 0xFE, 0xA0, 0x78, 0x25, 0x4B,
0xA2, 0x5D, 0x80, 0x05, 0x3F, 0x21, 0x70, 0xF1,
0x63, 0x77, 0xAF, 0x42, 0x20, 0xE5, 0xFD, 0xBF,
0x81, 0x18, 0x26, 0xC3, 0xBE, 0x35, 0x88, 0x2E,
0x93, 0x55, 0xFC, 0x7A, 0xC8, 0xBA, 0x32, 0xE6,
0xC0, 0x19, 0x9E, 0xA3, 0x44, 0x54, 0x3B, 0x0B,
0x8C, 0xC7, 0x6B, 0x28, 0xA7, 0xBC, 0x16, 0xAD,
0xDB, 0x64, 0x74, 0x14, 0x92, 0x0C, 0x48, 0xB8,
0x9F, 0xBD, 0x43, 0xC4, 0x39, 0x31, 0xD3, 0xF2,
0xD5, 0x8B, 0x6E, 0xDA, 0x01, 0xB1, 0x9C, 0x49,
0xD8, 0xAC, 0xF3, 0xCF, 0xCA, 0xF4, 0x47, 0x10,
0x6F, 0xF0, 0x4A, 0x5C, 0x38, 0x57, 0x73, 0x97,
0xCB, 0xA1, 0xE8, 0x3E, 0x96, 0x61, 0x0D, 0x0F,
0xE0, 0x7C, 0x71, 0xCC, 0x90, 0x06, 0xF7, 0x1C,
0xC2, 0x6A, 0xAE, 0x69, 0x17, 0x99, 0x3A, 0x27,
0xD9, 0xEB, 0x2B, 0x22, 0xD2, 0xA9, 0x07, 0x33,
0x2D, 0x3C, 0x15, 0xC9, 0x87, 0xAA, 0x50, 0xA5,
0x03, 0x59, 0x09, 0x1A, 0x65, 0xD7, 0x84, 0xD0,
0x82, 0x29, 0x5A, 0x1E, 0x7B, 0xA8, 0x6D, 0x2C
};
/* */
/* Expanded IV for TKIP function. */
/* */
struct PACKED rt_tkip_iv {
union PACKED {
struct PACKED {
u8 rc0;
u8 rc1;
u8 rc2;
union PACKED {
struct PACKED {
u8 Rsvd:5;
u8 ExtIV:1;
u8 KeyID:2;
} field;
u8 Byte;
} CONTROL;
} field;
unsigned long word;
} IV16;
unsigned long IV32;
};
/*
========================================================================
Routine Description:
Convert from u8[] to unsigned long in a portable way
Arguments:
pMICKey pointer to MIC Key
Return Value:
None
Note:
========================================================================
*/
unsigned long RTMPTkipGetUInt32(u8 *pMICKey)
{
unsigned long res = 0;
int i;
for (i = 0; i < 4; i++) {
res |= (*pMICKey++) << (8 * i);
}
return res;
}
/*
========================================================================
Routine Description:
Convert from unsigned long to u8[] in a portable way
Arguments:
pDst pointer to destination for convert unsigned long to u8[]
val the value for convert
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPTkipPutUInt32(IN u8 *pDst, unsigned long val)
{
int i;
for (i = 0; i < 4; i++) {
*pDst++ = (u8)(val & 0xff);
val >>= 8;
}
}
/*
========================================================================
Routine Description:
Set the MIC Key.
Arguments:
pAd Pointer to our adapter
pMICKey pointer to MIC Key
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPTkipSetMICKey(struct rt_tkip_key_info *pTkip, u8 *pMICKey)
{
/* Set the key */
pTkip->K0 = RTMPTkipGetUInt32(pMICKey);
pTkip->K1 = RTMPTkipGetUInt32(pMICKey + 4);
/* and reset the message */
pTkip->L = pTkip->K0;
pTkip->R = pTkip->K1;
pTkip->nBytesInM = 0;
pTkip->M = 0;
}
/*
========================================================================
Routine Description:
Calculate the MIC Value.
Arguments:
pAd Pointer to our adapter
uChar Append this uChar
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPTkipAppendByte(struct rt_tkip_key_info *pTkip, u8 uChar)
{
/* Append the byte to our word-sized buffer */
pTkip->M |= (uChar << (8 * pTkip->nBytesInM));
pTkip->nBytesInM++;
/* Process the word if it is full. */
if (pTkip->nBytesInM >= 4) {
pTkip->L ^= pTkip->M;
pTkip->R ^= ROL32(pTkip->L, 17);
pTkip->L += pTkip->R;
pTkip->R ^=
((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->
L & 0x00ff00ff) << 8);
pTkip->L += pTkip->R;
pTkip->R ^= ROL32(pTkip->L, 3);
pTkip->L += pTkip->R;
pTkip->R ^= ROR32(pTkip->L, 2);
pTkip->L += pTkip->R;
/* Clear the buffer */
pTkip->M = 0;
pTkip->nBytesInM = 0;
}
}
/*
========================================================================
Routine Description:
Calculate the MIC Value.
Arguments:
pAd Pointer to our adapter
pSrc Pointer to source data for Calculate MIC Value
Len Indicate the length of the source data
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPTkipAppend(struct rt_tkip_key_info *pTkip, u8 *pSrc, u32 nBytes)
{
/* This is simple */
while (nBytes > 0) {
RTMPTkipAppendByte(pTkip, *pSrc++);
nBytes--;
}
}
/*
========================================================================
Routine Description:
Get the MIC Value.
Arguments:
pAd Pointer to our adapter
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
the MIC Value is store in pAd->PrivateInfo.MIC
========================================================================
*/
void RTMPTkipGetMIC(struct rt_tkip_key_info *pTkip)
{
/* Append the minimum padding */
RTMPTkipAppendByte(pTkip, 0x5a);
RTMPTkipAppendByte(pTkip, 0);
RTMPTkipAppendByte(pTkip, 0);
RTMPTkipAppendByte(pTkip, 0);
RTMPTkipAppendByte(pTkip, 0);
/* and then zeroes until the length is a multiple of 4 */
while (pTkip->nBytesInM != 0) {
RTMPTkipAppendByte(pTkip, 0);
}
/* The appendByte function has already computed the result. */
RTMPTkipPutUInt32(pTkip->MIC, pTkip->L);
RTMPTkipPutUInt32(pTkip->MIC + 4, pTkip->R);
}
/*
========================================================================
Routine Description:
Init Tkip function.
Arguments:
pAd Pointer to our adapter
pTKey Pointer to the Temporal Key (TK), TK shall be 128bits.
KeyId TK Key ID
pTA Pointer to transmitter address
pMICKey pointer to MIC Key
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPInitTkipEngine(struct rt_rtmp_adapter *pAd,
u8 *pKey,
u8 KeyId,
u8 *pTA,
u8 *pMICKey,
u8 *pTSC, unsigned long *pIV16, unsigned long *pIV32)
{
struct rt_tkip_iv tkipIv;
/* Prepare 8 bytes TKIP encapsulation for MPDU */
NdisZeroMemory(&tkipIv, sizeof(struct rt_tkip_iv));
tkipIv.IV16.field.rc0 = *(pTSC + 1);
tkipIv.IV16.field.rc1 = (tkipIv.IV16.field.rc0 | 0x20) & 0x7f;
tkipIv.IV16.field.rc2 = *pTSC;
tkipIv.IV16.field.CONTROL.field.ExtIV = 1; /* 0: non-extended IV, 1: an extended IV */
tkipIv.IV16.field.CONTROL.field.KeyID = KeyId;
/* tkipIv.IV32 = *(unsigned long *)(pTSC + 2); */
NdisMoveMemory(&tkipIv.IV32, (pTSC + 2), 4); /* Copy IV */
*pIV16 = tkipIv.IV16.word;
*pIV32 = tkipIv.IV32;
}
/*
========================================================================
Routine Description:
Init MIC Value calculation function which include set MIC key &
calculate first 16 bytes (DA + SA + priority + 0)
Arguments:
pAd Pointer to our adapter
pTKey Pointer to the Temporal Key (TK), TK shall be 128bits.
pDA Pointer to DA address
pSA Pointer to SA address
pMICKey pointer to MIC Key
Return Value:
None
Note:
========================================================================
*/
void RTMPInitMICEngine(struct rt_rtmp_adapter *pAd,
u8 *pKey,
u8 *pDA,
u8 *pSA, u8 UserPriority, u8 *pMICKey)
{
unsigned long Priority = UserPriority;
/* Init MIC value calculation */
RTMPTkipSetMICKey(&pAd->PrivateInfo.Tx, pMICKey);
/* DA */
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pDA, MAC_ADDR_LEN);
/* SA */
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSA, MAC_ADDR_LEN);
/* Priority + 3 bytes of 0 */
RTMPTkipAppend(&pAd->PrivateInfo.Tx, (u8 *)& Priority, 4);
}
/*
========================================================================
Routine Description:
Compare MIC value of received MSDU
Arguments:
pAd Pointer to our adapter
pSrc Pointer to the received Plain text data
pDA Pointer to DA address
pSA Pointer to SA address
pMICKey pointer to MIC Key
Len the length of the received plain text data exclude MIC value
Return Value:
TRUE MIC value matched
FALSE MIC value mismatched
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
BOOLEAN RTMPTkipCompareMICValue(struct rt_rtmp_adapter *pAd,
u8 *pSrc,
u8 *pDA,
u8 *pSA,
u8 *pMICKey,
u8 UserPriority, u32 Len)
{
u8 OldMic[8];
unsigned long Priority = UserPriority;
/* Init MIC value calculation */
RTMPTkipSetMICKey(&pAd->PrivateInfo.Rx, pMICKey);
/* DA */
RTMPTkipAppend(&pAd->PrivateInfo.Rx, pDA, MAC_ADDR_LEN);
/* SA */
RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
/* Priority + 3 bytes of 0 */
RTMPTkipAppend(&pAd->PrivateInfo.Rx, (u8 *)& Priority, 4);
/* Calculate MIC value from plain text data */
RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
/* Get MIC valude from received frame */
NdisMoveMemory(OldMic, pSrc + Len, 8);
/* Get MIC value from decrypted plain data */
RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
/* Move MIC value from MSDU, this steps should move to data path. */
/* Since the MIC value might cross MPDUs. */
if (!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8)) {
DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValue(): TKIP MIC Error !\n")); /*MIC error. */
return (FALSE);
}
return (TRUE);
}
/*
========================================================================
Routine Description:
Copy frame from waiting queue into relative ring buffer and set
appropriate ASIC register to kick hardware transmit function
Arguments:
pAd Pointer to our adapter
void * Pointer to Ndis Packet for MIC calculation
pEncap Pointer to LLC encap data
LenEncap Total encap length, might be 0 which indicates no encap
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPCalculateMICValue(struct rt_rtmp_adapter *pAd,
void *pPacket,
u8 *pEncap,
struct rt_cipher_key *pKey, u8 apidx)
{
struct rt_packet_info PacketInfo;
u8 *pSrcBufVA;
u32 SrcBufLen;
u8 *pSrc;
u8 UserPriority;
u8 vlan_offset = 0;
RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
UserPriority = RTMP_GET_PACKET_UP(pPacket);
pSrc = pSrcBufVA;
/* determine if this is a vlan packet */
if (((*(pSrc + 12) << 8) + *(pSrc + 13)) == 0x8100)
vlan_offset = 4;
{
RTMPInitMICEngine(pAd,
pKey->Key,
pSrc, pSrc + 6, UserPriority, pKey->TxMic);
}
if (pEncap != NULL) {
/* LLC encapsulation */
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pEncap, 6);
/* Protocol Type */
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset,
2);
}
SrcBufLen -= (14 + vlan_offset);
pSrc += (14 + vlan_offset);
do {
if (SrcBufLen > 0) {
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc, SrcBufLen);
}
break; /* No need handle next packet */
} while (TRUE); /* End of copying payload */
/* Compute the final MIC Value */
RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
}
/************************************************************/
/* tkip_sbox() */
/* Returns a 16 bit value from a 64K entry table. The Table */
/* is synthesized from two 256 entry byte wide tables. */
/************************************************************/
u32 tkip_sbox(u32 index)
{
u32 index_low;
u32 index_high;
u32 left, right;
index_low = (index % 256);
index_high = ((index >> 8) % 256);
left = Tkip_Sbox_Lower[index_low] + (Tkip_Sbox_Upper[index_low] * 256);
right =
Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256);
return (left ^ right);
}
u32 rotr1(u32 a)
{
unsigned int b;
if ((a & 0x01) == 0x01) {
b = (a >> 1) | 0x8000;
} else {
b = (a >> 1) & 0x7fff;
}
b = b % 65536;
return b;
}
void RTMPTkipMixKey(u8 * key, u8 * ta, unsigned long pnl, /* Least significant 16 bits of PN */
unsigned long pnh, /* Most significant 32 bits of PN */
u8 * rc4key, u32 * p1k)
{
u32 tsc0;
u32 tsc1;
u32 tsc2;
u32 ppk0;
u32 ppk1;
u32 ppk2;
u32 ppk3;
u32 ppk4;
u32 ppk5;
int i;
int j;
tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
tsc1 = (unsigned int)(pnh % 65536);
tsc2 = (unsigned int)(pnl % 65536); /* lsb */
/* Phase 1, step 1 */
p1k[0] = tsc1;
p1k[1] = tsc0;
p1k[2] = (u32)(ta[0] + (ta[1] * 256));
p1k[3] = (u32)(ta[2] + (ta[3] * 256));
p1k[4] = (u32)(ta[4] + (ta[5] * 256));
/* Phase 1, step 2 */
for (i = 0; i < 8; i++) {
j = 2 * (i & 1);
p1k[0] =
(p1k[0] +
tkip_sbox((p1k[4] ^ ((256 * key[1 + j]) + key[j])) %
65536)) % 65536;
p1k[1] =
(p1k[1] +
tkip_sbox((p1k[0] ^ ((256 * key[5 + j]) + key[4 + j])) %
65536)) % 65536;
p1k[2] =
(p1k[2] +
tkip_sbox((p1k[1] ^ ((256 * key[9 + j]) + key[8 + j])) %
65536)) % 65536;
p1k[3] =
(p1k[3] +
tkip_sbox((p1k[2] ^ ((256 * key[13 + j]) + key[12 + j])) %
65536)) % 65536;
p1k[4] =
(p1k[4] +
tkip_sbox((p1k[3] ^ (((256 * key[1 + j]) + key[j]))) %
65536)) % 65536;
p1k[4] = (p1k[4] + i) % 65536;
}
/* Phase 2, Step 1 */
ppk0 = p1k[0];
ppk1 = p1k[1];
ppk2 = p1k[2];
ppk3 = p1k[3];
ppk4 = p1k[4];
ppk5 = (p1k[4] + tsc2) % 65536;
/* Phase2, Step 2 */
ppk0 = ppk0 + tkip_sbox((ppk5 ^ ((256 * key[1]) + key[0])) % 65536);
ppk1 = ppk1 + tkip_sbox((ppk0 ^ ((256 * key[3]) + key[2])) % 65536);
ppk2 = ppk2 + tkip_sbox((ppk1 ^ ((256 * key[5]) + key[4])) % 65536);
ppk3 = ppk3 + tkip_sbox((ppk2 ^ ((256 * key[7]) + key[6])) % 65536);
ppk4 = ppk4 + tkip_sbox((ppk3 ^ ((256 * key[9]) + key[8])) % 65536);
ppk5 = ppk5 + tkip_sbox((ppk4 ^ ((256 * key[11]) + key[10])) % 65536);
ppk0 = ppk0 + rotr1(ppk5 ^ ((256 * key[13]) + key[12]));
ppk1 = ppk1 + rotr1(ppk0 ^ ((256 * key[15]) + key[14]));
ppk2 = ppk2 + rotr1(ppk1);
ppk3 = ppk3 + rotr1(ppk2);
ppk4 = ppk4 + rotr1(ppk3);
ppk5 = ppk5 + rotr1(ppk4);
/* Phase 2, Step 3 */
/* Phase 2, Step 3 */
tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
tsc1 = (unsigned int)(pnh % 65536);
tsc2 = (unsigned int)(pnl % 65536); /* lsb */
rc4key[0] = (tsc2 >> 8) % 256;
rc4key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
rc4key[2] = tsc2 % 256;
rc4key[3] = ((ppk5 ^ ((256 * key[1]) + key[0])) >> 1) % 256;
rc4key[4] = ppk0 % 256;
rc4key[5] = (ppk0 >> 8) % 256;
rc4key[6] = ppk1 % 256;
rc4key[7] = (ppk1 >> 8) % 256;
rc4key[8] = ppk2 % 256;
rc4key[9] = (ppk2 >> 8) % 256;
rc4key[10] = ppk3 % 256;
rc4key[11] = (ppk3 >> 8) % 256;
rc4key[12] = ppk4 % 256;
rc4key[13] = (ppk4 >> 8) % 256;
rc4key[14] = ppk5 % 256;
rc4key[15] = (ppk5 >> 8) % 256;
}
/* */
/* TRUE: Success! */
/* FALSE: Decrypt Error! */
/* */
BOOLEAN RTMPSoftDecryptTKIP(struct rt_rtmp_adapter *pAd,
u8 *pData,
unsigned long DataByteCnt,
u8 UserPriority, struct rt_cipher_key *pWpaKey)
{
u8 KeyID;
u32 HeaderLen;
u8 fc0;
u8 fc1;
u16 fc;
u32 frame_type;
u32 frame_subtype;
u32 from_ds;
u32 to_ds;
int a4_exists;
int qc_exists;
u16 duration;
u16 seq_control;
u16 qos_control;
u8 TA[MAC_ADDR_LEN];
u8 DA[MAC_ADDR_LEN];
u8 SA[MAC_ADDR_LEN];
u8 RC4Key[16];
u32 p1k[5]; /*for mix_key; */
unsigned long pnl; /* Least significant 16 bits of PN */
unsigned long pnh; /* Most significant 32 bits of PN */
u32 num_blocks;
u32 payload_remainder;
struct rt_arcfourcontext ArcFourContext;
u32 crc32 = 0;
u32 trailfcs = 0;
u8 MIC[8];
u8 TrailMIC[8];
fc0 = *pData;
fc1 = *(pData + 1);
fc = *((u16 *)pData);
frame_type = ((fc0 >> 2) & 0x03);
frame_subtype = ((fc0 >> 4) & 0x0f);
from_ds = (fc1 & 0x2) >> 1;
to_ds = (fc1 & 0x1);
a4_exists = (from_ds & to_ds);
qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
(frame_subtype == 0x09) || /* Likely to change. */
(frame_subtype == 0x0a) || (frame_subtype == 0x0b)
);
HeaderLen = 24;
if (a4_exists)
HeaderLen += 6;
KeyID = *((u8 *)(pData + HeaderLen + 3));
KeyID = KeyID >> 6;
if (pWpaKey[KeyID].KeyLen == 0) {
DBGPRINT(RT_DEBUG_TRACE,
("RTMPSoftDecryptTKIP failed!(KeyID[%d] Length can not be 0)\n",
KeyID));
return FALSE;
}
duration = *((u16 *)(pData + 2));
seq_control = *((u16 *)(pData + 22));
if (qc_exists) {
if (a4_exists) {
qos_control = *((u16 *)(pData + 30));
} else {
qos_control = *((u16 *)(pData + 24));
}
}
if (to_ds == 0 && from_ds == 1) {
NdisMoveMemory(DA, pData + 4, MAC_ADDR_LEN);
NdisMoveMemory(SA, pData + 16, MAC_ADDR_LEN);
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN); /*BSSID */
} else if (to_ds == 0 && from_ds == 0) {
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
NdisMoveMemory(DA, pData + 4, MAC_ADDR_LEN);
NdisMoveMemory(SA, pData + 10, MAC_ADDR_LEN);
} else if (to_ds == 1 && from_ds == 0) {
NdisMoveMemory(SA, pData + 10, MAC_ADDR_LEN);
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
NdisMoveMemory(DA, pData + 16, MAC_ADDR_LEN);
} else if (to_ds == 1 && from_ds == 1) {
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
NdisMoveMemory(DA, pData + 16, MAC_ADDR_LEN);
NdisMoveMemory(SA, pData + 22, MAC_ADDR_LEN);
}
num_blocks = (DataByteCnt - 16) / 16;
payload_remainder = (DataByteCnt - 16) % 16;
pnl = (*(pData + HeaderLen)) * 256 + *(pData + HeaderLen + 2);
pnh = *((unsigned long *)(pData + HeaderLen + 4));
pnh = cpu2le32(pnh);
RTMPTkipMixKey(pWpaKey[KeyID].Key, TA, pnl, pnh, RC4Key, p1k);
ARCFOUR_INIT(&ArcFourContext, RC4Key, 16);
ARCFOUR_DECRYPT(&ArcFourContext, pData + HeaderLen,
pData + HeaderLen + 8, DataByteCnt - HeaderLen - 8);
NdisMoveMemory(&trailfcs, pData + DataByteCnt - 8 - 4, 4);
crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 4); /*Skip IV+EIV 8 bytes & Skip last 4 bytes(FCS). */
crc32 ^= 0xffffffff; /* complement */
if (crc32 != cpu2le32(trailfcs)) {
DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP, WEP Data ICV Error !\n")); /*ICV error. */
return (FALSE);
}
NdisMoveMemory(TrailMIC, pData + DataByteCnt - 8 - 8 - 4, 8);
RTMPInitMICEngine(pAd, pWpaKey[KeyID].Key, DA, SA, UserPriority,
pWpaKey[KeyID].RxMic);
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pData + HeaderLen,
DataByteCnt - HeaderLen - 8 - 12);
RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
NdisMoveMemory(MIC, pAd->PrivateInfo.Tx.MIC, 8);
if (!NdisEqualMemory(MIC, TrailMIC, 8)) {
DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptTKIP, WEP Data MIC Error !\n")); /*MIC error. */
/*RTMPReportMicError(pAd, &pWpaKey[KeyID]); // marked by AlbertY @ 20060630 */
return (FALSE);
}
/*DBGPRINT(RT_DEBUG_TRACE, "RTMPSoftDecryptTKIP Decript done!\n"); */
return TRUE;
}

View file

@ -1,473 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_wep.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Wu 10-28-02 Initial
*/
#include "../rt_config.h"
u32 FCSTAB_32[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
/*
u8 WEPKEY[] = {
//IV
0x00, 0x11, 0x22,
//WEP KEY
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
};
*/
/*
========================================================================
Routine Description:
Init WEP function.
Arguments:
pAd Pointer to our adapter
pKey Pointer to the WEP KEY
KeyId WEP Key ID
KeyLen the length of WEP KEY
pDest Pointer to the destination which Encryption data will store in.
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPInitWepEngine(struct rt_rtmp_adapter *pAd,
u8 *pKey,
u8 KeyId, u8 KeyLen, IN u8 *pDest)
{
u32 i;
u8 WEPKEY[] = {
/*IV */
0x00, 0x11, 0x22,
/*WEP KEY */
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
0xAA, 0xBB, 0xCC
};
pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; /*Init crc32. */
{
NdisMoveMemory(WEPKEY + 3, pKey, KeyLen);
for (i = 0; i < 3; i++)
WEPKEY[i] = RandomByte(pAd); /*Call mlme RandomByte() function. */
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3); /*INIT SBOX, KEYLEN+3(IV) */
NdisMoveMemory(pDest, WEPKEY, 3); /*Append Init Vector */
}
*(pDest + 3) = (KeyId << 6); /*Append KEYID */
}
/*
========================================================================
Routine Description:
Encrypt transimitted data
Arguments:
pAd Pointer to our adapter
pSrc Pointer to the transimitted source data that will be encrypt
pDest Pointer to the destination where entryption data will be store in.
Len Indicate the length of the source data
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPEncryptData(struct rt_rtmp_adapter *pAd,
u8 *pSrc, u8 *pDest, u32 Len)
{
pAd->PrivateInfo.FCSCRC32 =
RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, pSrc, Len);
ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, pSrc, Len);
}
/*
========================================================================
Routine Description:
Decrypt received WEP data
Arguments:
pAdapter Pointer to our adapter
pSrc Pointer to the received data
Len the length of the received data
Return Value:
TRUE Decrypt WEP data success
FALSE Decrypt WEP data failed
Note:
========================================================================
*/
BOOLEAN RTMPSoftDecryptWEP(struct rt_rtmp_adapter *pAd,
u8 *pData,
unsigned long DataByteCnt, struct rt_cipher_key *pGroupKey)
{
u32 trailfcs;
u32 crc32;
u8 KeyIdx;
u8 WEPKEY[] = {
/*IV */
0x00, 0x11, 0x22,
/*WEP KEY */
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
0xAA, 0xBB, 0xCC
};
u8 *pPayload = (u8 *) pData + LENGTH_802_11;
unsigned long payload_len = DataByteCnt - LENGTH_802_11;
NdisMoveMemory(WEPKEY, pPayload, 3); /*Get WEP IV */
KeyIdx = (*(pPayload + 3) & 0xc0) >> 6;
if (pGroupKey[KeyIdx].KeyLen == 0)
return (FALSE);
NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key,
pGroupKey[KeyIdx].KeyLen);
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY,
pGroupKey[KeyIdx].KeyLen + 3);
ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, pPayload, pPayload + 4,
payload_len - 4);
NdisMoveMemory(&trailfcs, pPayload + payload_len - 8, 4);
crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pPayload, payload_len - 8); /*Skip last 4 bytes(FCS). */
crc32 ^= 0xffffffff; /* complement */
if (crc32 != cpu2le32(trailfcs)) {
DBGPRINT(RT_DEBUG_TRACE, ("WEP Data CRC Error!\n")); /*CRC error. */
return (FALSE);
}
return (TRUE);
}
/*
========================================================================
Routine Description:
The Stream Cipher Encryption Algorithm "struct rt_arcfour" initialize
Arguments:
Ctx Pointer to struct rt_arcfour CONTEXT (SBOX)
pKey Pointer to the WEP KEY
KeyLen Indicate the length fo the WEP KEY
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void ARCFOUR_INIT(struct rt_arcfourcontext *Ctx, u8 *pKey, u32 KeyLen)
{
u8 t, u;
u32 keyindex;
u32 stateindex;
u8 *state;
u32 counter;
state = Ctx->STATE;
Ctx->X = 0;
Ctx->Y = 0;
for (counter = 0; counter < 256; counter++)
state[counter] = (u8)counter;
keyindex = 0;
stateindex = 0;
for (counter = 0; counter < 256; counter++) {
t = state[counter];
stateindex = (stateindex + pKey[keyindex] + t) & 0xff;
u = state[stateindex];
state[stateindex] = t;
state[counter] = u;
if (++keyindex >= KeyLen)
keyindex = 0;
}
}
/*
========================================================================
Routine Description:
Get bytes from struct rt_arcfour CONTEXT (S-BOX)
Arguments:
Ctx Pointer to struct rt_arcfour CONTEXT (SBOX)
Return Value:
u8 - the value of the struct rt_arcfour CONTEXT (S-BOX)
Note:
========================================================================
*/
u8 ARCFOUR_BYTE(struct rt_arcfourcontext *Ctx)
{
u32 x;
u32 y;
u8 sx, sy;
u8 *state;
state = Ctx->STATE;
x = (Ctx->X + 1) & 0xff;
sx = state[x];
y = (sx + Ctx->Y) & 0xff;
sy = state[y];
Ctx->X = x;
Ctx->Y = y;
state[y] = sx;
state[x] = sy;
return (state[(sx + sy) & 0xff]);
}
/*
========================================================================
Routine Description:
The Stream Cipher Decryption Algorithm
Arguments:
Ctx Pointer to struct rt_arcfour CONTEXT (SBOX)
pDest Pointer to the Destination
pSrc Pointer to the Source data
Len Indicate the length of the Source data
Return Value:
None
Note:
========================================================================
*/
void ARCFOUR_DECRYPT(struct rt_arcfourcontext *Ctx,
u8 *pDest, u8 *pSrc, u32 Len)
{
u32 i;
for (i = 0; i < Len; i++)
pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
}
/*
========================================================================
Routine Description:
The Stream Cipher Encryption Algorithm
Arguments:
Ctx Pointer to struct rt_arcfour CONTEXT (SBOX)
pDest Pointer to the Destination
pSrc Pointer to the Source data
Len Indicate the length of the Source dta
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void ARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
u8 *pDest, u8 *pSrc, u32 Len)
{
u32 i;
for (i = 0; i < Len; i++)
pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
}
/*
========================================================================
Routine Description:
The Stream Cipher Encryption Algorithm which conform to the special requirement to encrypt GTK.
Arguments:
Ctx Pointer to struct rt_arcfour CONTEXT (SBOX)
pDest Pointer to the Destination
pSrc Pointer to the Source data
Len Indicate the length of the Source dta
========================================================================
*/
void WPAARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
u8 *pDest, u8 *pSrc, u32 Len)
{
u32 i;
/*discard first 256 bytes */
for (i = 0; i < 256; i++)
ARCFOUR_BYTE(Ctx);
for (i = 0; i < Len; i++)
pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
}
/*
========================================================================
Routine Description:
Calculate a new FCS given the current FCS and the new data.
Arguments:
Fcs the original FCS value
Cp pointer to the data which will be calculate the FCS
Len the length of the data
Return Value:
u32 - FCS 32 bits
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
u32 RTMP_CALC_FCS32(u32 Fcs, u8 *Cp, int Len)
{
while (Len--)
Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
return (Fcs);
}
/*
========================================================================
Routine Description:
Get last FCS and encrypt it to the destination
Arguments:
pDest Pointer to the Destination
Return Value:
None
Note:
========================================================================
*/
void RTMPSetICV(struct rt_rtmp_adapter *pAd, u8 *pDest)
{
pAd->PrivateInfo.FCSCRC32 ^= 0xffffffff; /* complement */
pAd->PrivateInfo.FCSCRC32 = cpu2le32(pAd->PrivateInfo.FCSCRC32);
ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest,
(u8 *)& pAd->PrivateInfo.FCSCRC32, 4);
}

File diff suppressed because it is too large Load diff

View file

@ -1,187 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#include "../crypt_hmac.h"
#ifdef HMAC_SHA1_SUPPORT
/*
========================================================================
Routine Description:
HMAC using SHA1 hash function
Arguments:
key Secret key
key_len The length of the key in bytes
message Message context
message_len The length of message in bytes
macLen Request the length of message authentication code
Return Value:
mac Message authentication code
Note:
None
========================================================================
*/
void HMAC_SHA1(IN const u8 Key[],
u32 KeyLen,
IN const u8 Message[],
u32 MessageLen, u8 MAC[], u32 MACLen)
{
struct rt_sha1_ctx sha_ctx1;
struct rt_sha1_ctx sha_ctx2;
u8 K0[SHA1_BLOCK_SIZE];
u8 Digest[SHA1_DIGEST_SIZE];
u32 index;
NdisZeroMemory(&sha_ctx1, sizeof(struct rt_sha1_ctx));
NdisZeroMemory(&sha_ctx2, sizeof(struct rt_sha1_ctx));
/*
* If the length of K = B(Block size): K0 = K.
* If the length of K > B: hash K to obtain an L byte string,
* then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
* If the length of K < B: append zeros to the end of K to create a B-byte string K0
*/
NdisZeroMemory(K0, SHA1_BLOCK_SIZE);
if (KeyLen <= SHA1_BLOCK_SIZE)
NdisMoveMemory(K0, Key, KeyLen);
else
RT_SHA1(Key, KeyLen, K0);
/* End of if */
/* Exclusive-Or K0 with ipad */
/* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
for (index = 0; index < SHA1_BLOCK_SIZE; index++)
K0[index] ^= 0x36;
/* End of for */
RT_SHA1_Init(&sha_ctx1);
/* H(K0^ipad) */
SHA1_Append(&sha_ctx1, K0, sizeof(K0));
/* H((K0^ipad)||text) */
SHA1_Append(&sha_ctx1, Message, MessageLen);
SHA1_End(&sha_ctx1, Digest);
/* Exclusive-Or K0 with opad and remove ipad */
/* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
for (index = 0; index < SHA1_BLOCK_SIZE; index++)
K0[index] ^= 0x36 ^ 0x5c;
/* End of for */
RT_SHA1_Init(&sha_ctx2);
/* H(K0^opad) */
SHA1_Append(&sha_ctx2, K0, sizeof(K0));
/* H( (K0^opad) || H((K0^ipad)||text) ) */
SHA1_Append(&sha_ctx2, Digest, SHA1_DIGEST_SIZE);
SHA1_End(&sha_ctx2, Digest);
if (MACLen > SHA1_DIGEST_SIZE)
NdisMoveMemory(MAC, Digest, SHA1_DIGEST_SIZE);
else
NdisMoveMemory(MAC, Digest, MACLen);
} /* End of HMAC_SHA1 */
#endif /* HMAC_SHA1_SUPPORT */
#ifdef HMAC_MD5_SUPPORT
/*
========================================================================
Routine Description:
HMAC using MD5 hash function
Arguments:
key Secret key
key_len The length of the key in bytes
message Message context
message_len The length of message in bytes
macLen Request the length of message authentication code
Return Value:
mac Message authentication code
Note:
None
========================================================================
*/
void HMAC_MD5(IN const u8 Key[],
u32 KeyLen,
IN const u8 Message[],
u32 MessageLen, u8 MAC[], u32 MACLen)
{
struct rt_md5_ctx_struc md5_ctx1;
struct rt_md5_ctx_struc md5_ctx2;
u8 K0[MD5_BLOCK_SIZE];
u8 Digest[MD5_DIGEST_SIZE];
u32 index;
NdisZeroMemory(&md5_ctx1, sizeof(struct rt_md5_ctx_struc));
NdisZeroMemory(&md5_ctx2, sizeof(struct rt_md5_ctx_struc));
/*
* If the length of K = B(Block size): K0 = K.
* If the length of K > B: hash K to obtain an L byte string,
* then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
* If the length of K < B: append zeros to the end of K to create a B-byte string K0
*/
NdisZeroMemory(K0, MD5_BLOCK_SIZE);
if (KeyLen <= MD5_BLOCK_SIZE) {
NdisMoveMemory(K0, Key, KeyLen);
} else {
RT_MD5(Key, KeyLen, K0);
}
/* Exclusive-Or K0 with ipad */
/* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
for (index = 0; index < MD5_BLOCK_SIZE; index++)
K0[index] ^= 0x36;
/* End of for */
MD5_Init(&md5_ctx1);
/* H(K0^ipad) */
MD5_Append(&md5_ctx1, K0, sizeof(K0));
/* H((K0^ipad)||text) */
MD5_Append(&md5_ctx1, Message, MessageLen);
MD5_End(&md5_ctx1, Digest);
/* Exclusive-Or K0 with opad and remove ipad */
/* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
for (index = 0; index < MD5_BLOCK_SIZE; index++)
K0[index] ^= 0x36 ^ 0x5c;
/* End of for */
MD5_Init(&md5_ctx2);
/* H(K0^opad) */
MD5_Append(&md5_ctx2, K0, sizeof(K0));
/* H( (K0^opad) || H((K0^ipad)||text) ) */
MD5_Append(&md5_ctx2, Digest, MD5_DIGEST_SIZE);
MD5_End(&md5_ctx2, Digest);
if (MACLen > MD5_DIGEST_SIZE)
NdisMoveMemory(MAC, Digest, MD5_DIGEST_SIZE);
else
NdisMoveMemory(MAC, Digest, MACLen);
} /* End of HMAC_SHA256 */
#endif /* HMAC_MD5_SUPPORT */
/* End of crypt_hmac.c */

View file

@ -1,339 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#include "../crypt_md5.h"
#ifdef MD5_SUPPORT
/*
* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
#define ROTL(x,n,w) ((x << n) | (x >> (w - n)))
#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
#define ROUND1(a, b, c, d, x, s, ac) { \
(a) += F((b),(c),(d)) + (x) + (u32)(ac); \
(a) = ROTL32((a),(s)); \
(a) += (b); \
}
#define ROUND2(a, b, c, d, x, s, ac) { \
(a) += G((b),(c),(d)) + (x) + (u32)(ac); \
(a) = ROTL32((a),(s)); \
(a) += (b); \
}
#define ROUND3(a, b, c, d, x, s, ac) { \
(a) += H((b),(c),(d)) + (x) + (u32)(ac); \
(a) = ROTL32((a),(s)); \
(a) += (b); \
}
#define ROUND4(a, b, c, d, x, s, ac) { \
(a) += I((b),(c),(d)) + (x) + (u32)(ac); \
(a) = ROTL32((a),(s)); \
(a) += (b); \
}
static const u32 MD5_DefaultHashValue[4] = {
0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL
};
#endif /* MD5_SUPPORT */
#ifdef MD5_SUPPORT
/*
========================================================================
Routine Description:
Initial Md5_CTX_STRUC
Arguments:
pMD5_CTX Pointer to Md5_CTX_STRUC
Return Value:
None
Note:
None
========================================================================
*/
void MD5_Init(struct rt_md5_ctx_struc *pMD5_CTX)
{
NdisMoveMemory(pMD5_CTX->HashValue, MD5_DefaultHashValue,
sizeof(MD5_DefaultHashValue));
NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
pMD5_CTX->BlockLen = 0;
pMD5_CTX->MessageLen = 0;
} /* End of MD5_Init */
/*
========================================================================
Routine Description:
MD5 computation for one block (512 bits)
Arguments:
pMD5_CTX Pointer to Md5_CTX_STRUC
Return Value:
None
Note:
T[i] := floor(abs(sin(i + 1)) * (2 pow 32)), i is number of round
========================================================================
*/
void MD5_Hash(struct rt_md5_ctx_struc *pMD5_CTX)
{
u32 X_i;
u32 X[16];
u32 a, b, c, d;
/* Prepare the message schedule, {X_i} */
NdisMoveMemory(X, pMD5_CTX->Block, MD5_BLOCK_SIZE);
for (X_i = 0; X_i < 16; X_i++)
X[X_i] = cpu2le32(X[X_i]); /* Endian Swap */
/* End of for */
/* MD5 hash computation */
/* Initialize the working variables */
a = pMD5_CTX->HashValue[0];
b = pMD5_CTX->HashValue[1];
c = pMD5_CTX->HashValue[2];
d = pMD5_CTX->HashValue[3];
/*
* Round 1
* Let [abcd k s i] denote the operation
* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s)
*/
ROUND1(a, b, c, d, X[0], 7, 0xd76aa478); /* 1 */
ROUND1(d, a, b, c, X[1], 12, 0xe8c7b756); /* 2 */
ROUND1(c, d, a, b, X[2], 17, 0x242070db); /* 3 */
ROUND1(b, c, d, a, X[3], 22, 0xc1bdceee); /* 4 */
ROUND1(a, b, c, d, X[4], 7, 0xf57c0faf); /* 5 */
ROUND1(d, a, b, c, X[5], 12, 0x4787c62a); /* 6 */
ROUND1(c, d, a, b, X[6], 17, 0xa8304613); /* 7 */
ROUND1(b, c, d, a, X[7], 22, 0xfd469501); /* 8 */
ROUND1(a, b, c, d, X[8], 7, 0x698098d8); /* 9 */
ROUND1(d, a, b, c, X[9], 12, 0x8b44f7af); /* 10 */
ROUND1(c, d, a, b, X[10], 17, 0xffff5bb1); /* 11 */
ROUND1(b, c, d, a, X[11], 22, 0x895cd7be); /* 12 */
ROUND1(a, b, c, d, X[12], 7, 0x6b901122); /* 13 */
ROUND1(d, a, b, c, X[13], 12, 0xfd987193); /* 14 */
ROUND1(c, d, a, b, X[14], 17, 0xa679438e); /* 15 */
ROUND1(b, c, d, a, X[15], 22, 0x49b40821); /* 16 */
/*
* Round 2
* Let [abcd k s i] denote the operation
* a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s)
*/
ROUND2(a, b, c, d, X[1], 5, 0xf61e2562); /* 17 */
ROUND2(d, a, b, c, X[6], 9, 0xc040b340); /* 18 */
ROUND2(c, d, a, b, X[11], 14, 0x265e5a51); /* 19 */
ROUND2(b, c, d, a, X[0], 20, 0xe9b6c7aa); /* 20 */
ROUND2(a, b, c, d, X[5], 5, 0xd62f105d); /* 21 */
ROUND2(d, a, b, c, X[10], 9, 0x2441453); /* 22 */
ROUND2(c, d, a, b, X[15], 14, 0xd8a1e681); /* 23 */
ROUND2(b, c, d, a, X[4], 20, 0xe7d3fbc8); /* 24 */
ROUND2(a, b, c, d, X[9], 5, 0x21e1cde6); /* 25 */
ROUND2(d, a, b, c, X[14], 9, 0xc33707d6); /* 26 */
ROUND2(c, d, a, b, X[3], 14, 0xf4d50d87); /* 27 */
ROUND2(b, c, d, a, X[8], 20, 0x455a14ed); /* 28 */
ROUND2(a, b, c, d, X[13], 5, 0xa9e3e905); /* 29 */
ROUND2(d, a, b, c, X[2], 9, 0xfcefa3f8); /* 30 */
ROUND2(c, d, a, b, X[7], 14, 0x676f02d9); /* 31 */
ROUND2(b, c, d, a, X[12], 20, 0x8d2a4c8a); /* 32 */
/*
* Round 3
* Let [abcd k s t] denote the operation
* a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s)
*/
ROUND3(a, b, c, d, X[5], 4, 0xfffa3942); /* 33 */
ROUND3(d, a, b, c, X[8], 11, 0x8771f681); /* 34 */
ROUND3(c, d, a, b, X[11], 16, 0x6d9d6122); /* 35 */
ROUND3(b, c, d, a, X[14], 23, 0xfde5380c); /* 36 */
ROUND3(a, b, c, d, X[1], 4, 0xa4beea44); /* 37 */
ROUND3(d, a, b, c, X[4], 11, 0x4bdecfa9); /* 38 */
ROUND3(c, d, a, b, X[7], 16, 0xf6bb4b60); /* 39 */
ROUND3(b, c, d, a, X[10], 23, 0xbebfbc70); /* 40 */
ROUND3(a, b, c, d, X[13], 4, 0x289b7ec6); /* 41 */
ROUND3(d, a, b, c, X[0], 11, 0xeaa127fa); /* 42 */
ROUND3(c, d, a, b, X[3], 16, 0xd4ef3085); /* 43 */
ROUND3(b, c, d, a, X[6], 23, 0x4881d05); /* 44 */
ROUND3(a, b, c, d, X[9], 4, 0xd9d4d039); /* 45 */
ROUND3(d, a, b, c, X[12], 11, 0xe6db99e5); /* 46 */
ROUND3(c, d, a, b, X[15], 16, 0x1fa27cf8); /* 47 */
ROUND3(b, c, d, a, X[2], 23, 0xc4ac5665); /* 48 */
/*
* Round 4
* Let [abcd k s t] denote the operation
* a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s)
*/
ROUND4(a, b, c, d, X[0], 6, 0xf4292244); /* 49 */
ROUND4(d, a, b, c, X[7], 10, 0x432aff97); /* 50 */
ROUND4(c, d, a, b, X[14], 15, 0xab9423a7); /* 51 */
ROUND4(b, c, d, a, X[5], 21, 0xfc93a039); /* 52 */
ROUND4(a, b, c, d, X[12], 6, 0x655b59c3); /* 53 */
ROUND4(d, a, b, c, X[3], 10, 0x8f0ccc92); /* 54 */
ROUND4(c, d, a, b, X[10], 15, 0xffeff47d); /* 55 */
ROUND4(b, c, d, a, X[1], 21, 0x85845dd1); /* 56 */
ROUND4(a, b, c, d, X[8], 6, 0x6fa87e4f); /* 57 */
ROUND4(d, a, b, c, X[15], 10, 0xfe2ce6e0); /* 58 */
ROUND4(c, d, a, b, X[6], 15, 0xa3014314); /* 59 */
ROUND4(b, c, d, a, X[13], 21, 0x4e0811a1); /* 60 */
ROUND4(a, b, c, d, X[4], 6, 0xf7537e82); /* 61 */
ROUND4(d, a, b, c, X[11], 10, 0xbd3af235); /* 62 */
ROUND4(c, d, a, b, X[2], 15, 0x2ad7d2bb); /* 63 */
ROUND4(b, c, d, a, X[9], 21, 0xeb86d391); /* 64 */
/* Compute the i^th intermediate hash value H^(i) */
pMD5_CTX->HashValue[0] += a;
pMD5_CTX->HashValue[1] += b;
pMD5_CTX->HashValue[2] += c;
pMD5_CTX->HashValue[3] += d;
NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
pMD5_CTX->BlockLen = 0;
} /* End of MD5_Hash */
/*
========================================================================
Routine Description:
The message is appended to block. If block size > 64 bytes, the MD5_Hash
will be called.
Arguments:
pMD5_CTX Pointer to struct rt_md5_ctx_struc
message Message context
messageLen The length of message in bytes
Return Value:
None
Note:
None
========================================================================
*/
void MD5_Append(struct rt_md5_ctx_struc *pMD5_CTX,
IN const u8 Message[], u32 MessageLen)
{
u32 appendLen = 0;
u32 diffLen = 0;
while (appendLen != MessageLen) {
diffLen = MessageLen - appendLen;
if ((pMD5_CTX->BlockLen + diffLen) < MD5_BLOCK_SIZE) {
NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
Message + appendLen, diffLen);
pMD5_CTX->BlockLen += diffLen;
appendLen += diffLen;
} else {
NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
Message + appendLen,
MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
appendLen += (MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
pMD5_CTX->BlockLen = MD5_BLOCK_SIZE;
MD5_Hash(pMD5_CTX);
} /* End of if */
} /* End of while */
pMD5_CTX->MessageLen += MessageLen;
} /* End of MD5_Append */
/*
========================================================================
Routine Description:
1. Append bit 1 to end of the message
2. Append the length of message in rightmost 64 bits
3. Transform the Hash Value to digest message
Arguments:
pMD5_CTX Pointer to struct rt_md5_ctx_struc
Return Value:
digestMessage Digest message
Note:
None
========================================================================
*/
void MD5_End(struct rt_md5_ctx_struc *pMD5_CTX, u8 DigestMessage[])
{
u32 index;
u64 message_length_bits;
/* append 1 bits to end of the message */
NdisFillMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen, 1, 0x80);
/* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
if (pMD5_CTX->BlockLen > 55)
MD5_Hash(pMD5_CTX);
/* End of if */
/* Append the length of message in rightmost 64 bits */
message_length_bits = pMD5_CTX->MessageLen * 8;
message_length_bits = cpu2le64(message_length_bits);
NdisMoveMemory(&pMD5_CTX->Block[56], &message_length_bits, 8);
MD5_Hash(pMD5_CTX);
/* Return message digest, transform the u32 hash value to bytes */
for (index = 0; index < 4; index++)
pMD5_CTX->HashValue[index] =
cpu2le32(pMD5_CTX->HashValue[index]);
/* End of for */
NdisMoveMemory(DigestMessage, pMD5_CTX->HashValue, MD5_DIGEST_SIZE);
} /* End of MD5_End */
/*
========================================================================
Routine Description:
MD5 algorithm
Arguments:
message Message context
messageLen The length of message in bytes
Return Value:
digestMessage Digest message
Note:
None
========================================================================
*/
void RT_MD5(IN const u8 Message[],
u32 MessageLen, u8 DigestMessage[])
{
struct rt_md5_ctx_struc md5_ctx;
NdisZeroMemory(&md5_ctx, sizeof(struct rt_md5_ctx_struc));
MD5_Init(&md5_ctx);
MD5_Append(&md5_ctx, Message, MessageLen);
MD5_End(&md5_ctx, DigestMessage);
} /* End of RT_MD5 */
#endif /* MD5_SUPPORT */
/* End of crypt_md5.c */

View file

@ -1,269 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#include "../crypt_sha2.h"
/* Basic operations */
#define SHR(x,n) (x >> n) /* SHR(x)^n, right shift n bits , x is w-bit word, 0 <= n <= w */
#define ROTR(x,n,w) ((x >> n) | (x << (w - n))) /* ROTR(x)^n, circular right shift n bits , x is w-bit word, 0 <= n <= w */
#define ROTL(x,n,w) ((x << n) | (x >> (w - n))) /* ROTL(x)^n, circular left shift n bits , x is w-bit word, 0 <= n <= w */
#define ROTR32(x,n) ROTR(x,n,32) /* 32 bits word */
#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
/* Basic functions */
#define Ch(x,y,z) ((x & y) ^ ((~x) & z))
#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z))
#define Parity(x,y,z) (x ^ y ^ z)
#ifdef SHA1_SUPPORT
/* SHA1 constants */
#define SHA1_MASK 0x0000000f
static const u32 SHA1_K[4] = {
0x5a827999UL, 0x6ed9eba1UL, 0x8f1bbcdcUL, 0xca62c1d6UL
};
static const u32 SHA1_DefaultHashValue[5] = {
0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL
};
/*
========================================================================
Routine Description:
Initial struct rt_sha1_ctx
Arguments:
pSHA_CTX Pointer to struct rt_sha1_ctx
Return Value:
None
Note:
None
========================================================================
*/
void RT_SHA1_Init(struct rt_sha1_ctx *pSHA_CTX)
{
NdisMoveMemory(pSHA_CTX->HashValue, SHA1_DefaultHashValue,
sizeof(SHA1_DefaultHashValue));
NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
pSHA_CTX->MessageLen = 0;
pSHA_CTX->BlockLen = 0;
} /* End of RT_SHA1_Init */
/*
========================================================================
Routine Description:
SHA1 computation for one block (512 bits)
Arguments:
pSHA_CTX Pointer to struct rt_sha1_ctx
Return Value:
None
Note:
None
========================================================================
*/
void SHA1_Hash(struct rt_sha1_ctx *pSHA_CTX)
{
u32 W_i, t, s;
u32 W[16];
u32 a, b, c, d, e, T, f_t = 0;
/* Prepare the message schedule, {W_i}, 0 < t < 15 */
NdisMoveMemory(W, pSHA_CTX->Block, SHA1_BLOCK_SIZE);
for (W_i = 0; W_i < 16; W_i++)
W[W_i] = cpu2be32(W[W_i]); /* Endian Swap */
/* End of for */
/* SHA256 hash computation */
/* Initialize the working variables */
a = pSHA_CTX->HashValue[0];
b = pSHA_CTX->HashValue[1];
c = pSHA_CTX->HashValue[2];
d = pSHA_CTX->HashValue[3];
e = pSHA_CTX->HashValue[4];
/* 80 rounds */
for (t = 0; t < 80; t++) {
s = t & SHA1_MASK;
if (t > 15) { /* Prepare the message schedule, {W_i}, 16 < t < 79 */
W[s] =
(W[(s + 13) & SHA1_MASK]) ^ (W[(s + 8) & SHA1_MASK])
^ (W[(s + 2) & SHA1_MASK]) ^ W[s];
W[s] = ROTL32(W[s], 1);
} /* End of if */
switch (t / 20) {
case 0:
f_t = Ch(b, c, d);
break;
case 1:
f_t = Parity(b, c, d);
break;
case 2:
f_t = Maj(b, c, d);
break;
case 3:
f_t = Parity(b, c, d);
break;
} /* End of switch */
T = ROTL32(a, 5) + f_t + e + SHA1_K[t / 20] + W[s];
e = d;
d = c;
c = ROTL32(b, 30);
b = a;
a = T;
} /* End of for */
/* Compute the i^th intermediate hash value H^(i) */
pSHA_CTX->HashValue[0] += a;
pSHA_CTX->HashValue[1] += b;
pSHA_CTX->HashValue[2] += c;
pSHA_CTX->HashValue[3] += d;
pSHA_CTX->HashValue[4] += e;
NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
pSHA_CTX->BlockLen = 0;
} /* End of SHA1_Hash */
/*
========================================================================
Routine Description:
The message is appended to block. If block size > 64 bytes, the SHA1_Hash
will be called.
Arguments:
pSHA_CTX Pointer to struct rt_sha1_ctx
message Message context
messageLen The length of message in bytes
Return Value:
None
Note:
None
========================================================================
*/
void SHA1_Append(struct rt_sha1_ctx *pSHA_CTX,
IN const u8 Message[], u32 MessageLen)
{
u32 appendLen = 0;
u32 diffLen = 0;
while (appendLen != MessageLen) {
diffLen = MessageLen - appendLen;
if ((pSHA_CTX->BlockLen + diffLen) < SHA1_BLOCK_SIZE) {
NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
Message + appendLen, diffLen);
pSHA_CTX->BlockLen += diffLen;
appendLen += diffLen;
} else {
NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
Message + appendLen,
SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
appendLen += (SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
pSHA_CTX->BlockLen = SHA1_BLOCK_SIZE;
SHA1_Hash(pSHA_CTX);
} /* End of if */
} /* End of while */
pSHA_CTX->MessageLen += MessageLen;
} /* End of SHA1_Append */
/*
========================================================================
Routine Description:
1. Append bit 1 to end of the message
2. Append the length of message in rightmost 64 bits
3. Transform the Hash Value to digest message
Arguments:
pSHA_CTX Pointer to struct rt_sha1_ctx
Return Value:
digestMessage Digest message
Note:
None
========================================================================
*/
void SHA1_End(struct rt_sha1_ctx *pSHA_CTX, u8 DigestMessage[])
{
u32 index;
u64 message_length_bits;
/* Append bit 1 to end of the message */
NdisFillMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, 1, 0x80);
/* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
if (pSHA_CTX->BlockLen > 55)
SHA1_Hash(pSHA_CTX);
/* End of if */
/* Append the length of message in rightmost 64 bits */
message_length_bits = pSHA_CTX->MessageLen * 8;
message_length_bits = cpu2be64(message_length_bits);
NdisMoveMemory(&pSHA_CTX->Block[56], &message_length_bits, 8);
SHA1_Hash(pSHA_CTX);
/* Return message digest, transform the u32 hash value to bytes */
for (index = 0; index < 5; index++)
pSHA_CTX->HashValue[index] =
cpu2be32(pSHA_CTX->HashValue[index]);
/* End of for */
NdisMoveMemory(DigestMessage, pSHA_CTX->HashValue, SHA1_DIGEST_SIZE);
} /* End of SHA1_End */
/*
========================================================================
Routine Description:
SHA1 algorithm
Arguments:
message Message context
messageLen The length of message in bytes
Return Value:
digestMessage Digest message
Note:
None
========================================================================
*/
void RT_SHA1(IN const u8 Message[],
u32 MessageLen, u8 DigestMessage[])
{
struct rt_sha1_ctx sha_ctx;
NdisZeroMemory(&sha_ctx, sizeof(struct rt_sha1_ctx));
RT_SHA1_Init(&sha_ctx);
SHA1_Append(&sha_ctx, Message, MessageLen);
SHA1_End(&sha_ctx, DigestMessage);
} /* End of RT_SHA1 */
#endif /* SHA1_SUPPORT */
/* End of crypt_sha2.c */

View file

@ -1,68 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
ap_dfs.c
Abstract:
Support DFS function.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#include "../rt_config.h"
/*
========================================================================
Routine Description:
Radar channel check routine
Arguments:
pAd Pointer to our adapter
Return Value:
TRUE need to do radar detect
FALSE need not to do radar detect
========================================================================
*/
BOOLEAN RadarChannelCheck(struct rt_rtmp_adapter *pAd, u8 Ch)
{
int i;
BOOLEAN result = FALSE;
for (i = 0; i < pAd->ChannelListNum; i++) {
if (Ch == pAd->ChannelList[i].Channel) {
result = pAd->ChannelList[i].DfsReq;
break;
}
}
return result;
}

View file

@ -1,351 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
ee_efuse.c
Abstract:
Miniport generic portion header file
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#include "../rt_config.h"
#define EFUSE_USAGE_MAP_START 0x2d0
#define EFUSE_USAGE_MAP_END 0x2fc
#define EFUSE_USAGE_MAP_SIZE 45
#define EFUSE_EEPROM_DEFULT_FILE "RT30xxEEPROM.bin"
#define MAX_EEPROM_BIN_FILE_SIZE 1024
#define EFUSE_TAG 0x2fe
typedef union _EFUSE_CTRL_STRUC {
struct {
u32 EFSROM_AOUT:6;
u32 EFSROM_MODE:2;
u32 EFSROM_LDO_OFF_TIME:6;
u32 EFSROM_LDO_ON_TIME:2;
u32 EFSROM_AIN:10;
u32 RESERVED:4;
u32 EFSROM_KICK:1;
u32 SEL_EFUSE:1;
} field;
u32 word;
} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
/*
========================================================================
Routine Description:
Arguments:
Return Value:
Note:
========================================================================
*/
u8 eFuseReadRegisters(struct rt_rtmp_adapter *pAd,
u16 Offset, u16 Length, u16 * pData)
{
EFUSE_CTRL_STRUC eFuseCtrlStruc;
int i;
u16 efuseDataOffset;
u32 data;
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
/*Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. */
/*Use the eeprom logical address and covert to address to block number */
eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
/*Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 0. */
eFuseCtrlStruc.field.EFSROM_MODE = 0;
/*Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. */
eFuseCtrlStruc.field.EFSROM_KICK = 1;
NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
/*Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. */
i = 0;
while (i < 500) {
/*rtmp.HwMemoryReadDword(EFUSE_CTRL, (DWORD *) &eFuseCtrlStruc, 4); */
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
if (eFuseCtrlStruc.field.EFSROM_KICK == 0) {
break;
}
RTMPusecDelay(2);
i++;
}
/*if EFSROM_AOUT is not found in physical address, write 0xffff */
if (eFuseCtrlStruc.field.EFSROM_AOUT == 0x3f) {
for (i = 0; i < Length / 2; i++)
*(pData + 2 * i) = 0xffff;
} else {
/*Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x590-0x59C) */
efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC);
/*data hold 4 bytes data. */
/*In RTMP_IO_READ32 will automatically execute 32-bytes swapping */
RTMP_IO_READ32(pAd, efuseDataOffset, &data);
/*Decide the upper 2 bytes or the bottom 2 bytes. */
/* Little-endian S | S Big-endian */
/* addr 3 2 1 0 | 0 1 2 3 */
/* Ori-V D C B A | A B C D */
/*After swapping */
/* D C B A | D C B A */
/*Return 2-bytes */
/*The return byte statrs from S. Therefore, the little-endian will return BA, the Big-endian will return DC. */
/*For returning the bottom 2 bytes, the Big-endian should shift right 2-bytes. */
data = data >> (8 * (Offset & 0x3));
NdisMoveMemory(pData, &data, Length);
}
return (u8)eFuseCtrlStruc.field.EFSROM_AOUT;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
Note:
========================================================================
*/
void eFusePhysicalReadRegisters(struct rt_rtmp_adapter *pAd,
u16 Offset,
u16 Length, u16 * pData)
{
EFUSE_CTRL_STRUC eFuseCtrlStruc;
int i;
u16 efuseDataOffset;
u32 data;
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
/*Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. */
eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
/*Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1. */
/*Read in physical view */
eFuseCtrlStruc.field.EFSROM_MODE = 1;
/*Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. */
eFuseCtrlStruc.field.EFSROM_KICK = 1;
NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
/*Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. */
i = 0;
while (i < 500) {
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
if (eFuseCtrlStruc.field.EFSROM_KICK == 0)
break;
RTMPusecDelay(2);
i++;
}
/*Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590) */
/*Because the size of each EFUSE_DATA is 4 Bytes, the size of address of each is 2 bits. */
/*The previous 2 bits is the EFUSE_DATA number, the last 2 bits is used to decide which bytes */
/*Decide which EFUSE_DATA to read */
/*590:F E D C */
/*594:B A 9 8 */
/*598:7 6 5 4 */
/*59C:3 2 1 0 */
efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC);
RTMP_IO_READ32(pAd, efuseDataOffset, &data);
data = data >> (8 * (Offset & 0x3));
NdisMoveMemory(pData, &data, Length);
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
Note:
========================================================================
*/
static void eFuseReadPhysical(struct rt_rtmp_adapter *pAd,
u16 *lpInBuffer,
unsigned long nInBufferSize,
u16 *lpOutBuffer, unsigned long nOutBufferSize)
{
u16 *pInBuf = (u16 *) lpInBuffer;
u16 *pOutBuf = (u16 *) lpOutBuffer;
u16 Offset = pInBuf[0]; /*addr */
u16 Length = pInBuf[1]; /*length */
int i;
for (i = 0; i < Length; i += 2) {
eFusePhysicalReadRegisters(pAd, Offset + i, 2, &pOutBuf[i / 2]);
}
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
Note:
========================================================================
*/
int set_eFuseGetFreeBlockCount_Proc(struct rt_rtmp_adapter *pAd, char *arg)
{
u16 i;
u16 LogicalAddress;
u16 efusefreenum = 0;
if (!pAd->bUseEfuse)
return FALSE;
for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i += 2) {
eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
if ((LogicalAddress & 0xff) == 0) {
efusefreenum = (u8)(EFUSE_USAGE_MAP_END - i + 1);
break;
} else if (((LogicalAddress >> 8) & 0xff) == 0) {
efusefreenum = (u8)(EFUSE_USAGE_MAP_END - i);
break;
}
if (i == EFUSE_USAGE_MAP_END)
efusefreenum = 0;
}
printk(KERN_DEBUG "efuseFreeNumber is %d\n", efusefreenum);
return TRUE;
}
int set_eFusedump_Proc(struct rt_rtmp_adapter *pAd, char *arg)
{
u16 InBuf[3];
int i = 0;
if (!pAd->bUseEfuse)
return FALSE;
printk(KERN_DEBUG "Block 0: ");
for (i = 0; i < EFUSE_USAGE_MAP_END / 2; i++) {
InBuf[0] = 2 * i;
InBuf[1] = 2;
InBuf[2] = 0x0;
eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
if (i && i % 4 == 0) {
printk(KERN_CONT "\n");
printk(KERN_DEBUG "Block %x:", i / 8);
}
printk(KERN_CONT "%04x ", InBuf[2]);
}
printk(KERN_CONT "\n");
return TRUE;
}
int rtmp_ee_efuse_read16(struct rt_rtmp_adapter *pAd,
u16 Offset, u16 * pValue)
{
eFuseReadRegisters(pAd, Offset, 2, pValue);
return (*pValue);
}
int RtmpEfuseSupportCheck(struct rt_rtmp_adapter *pAd)
{
u16 value;
if (IS_RT30xx(pAd)) {
eFusePhysicalReadRegisters(pAd, EFUSE_TAG, 2, &value);
pAd->EFuseTag = (value & 0xff);
}
return 0;
}
void eFuseGetFreeBlockCount(struct rt_rtmp_adapter *pAd, u32 *EfuseFreeBlock)
{
u16 i;
u16 LogicalAddress;
if (!pAd->bUseEfuse) {
DBGPRINT(RT_DEBUG_TRACE,
("eFuseGetFreeBlockCount Only supports efuse Mode\n"));
return;
}
for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i += 2) {
eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
if ((LogicalAddress & 0xff) == 0) {
*EfuseFreeBlock = (u8)(EFUSE_USAGE_MAP_END - i + 1);
break;
} else if (((LogicalAddress >> 8) & 0xff) == 0) {
*EfuseFreeBlock = (u8)(EFUSE_USAGE_MAP_END - i);
break;
}
if (i == EFUSE_USAGE_MAP_END)
*EfuseFreeBlock = 0;
}
DBGPRINT(RT_DEBUG_TRACE,
("eFuseGetFreeBlockCount is 0x%x\n", *EfuseFreeBlock));
}
int eFuse_init(struct rt_rtmp_adapter *pAd)
{
u32 EfuseFreeBlock = 0;
DBGPRINT(RT_DEBUG_ERROR,
("NVM is Efuse and its size =%x[%x-%x] \n",
EFUSE_USAGE_MAP_SIZE, EFUSE_USAGE_MAP_START,
EFUSE_USAGE_MAP_END));
eFuseGetFreeBlockCount(pAd, &EfuseFreeBlock);
return 0;
}

View file

@ -1,197 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
ee_prom.c
Abstract:
Miniport generic portion header file
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#include "../rt_config.h"
/* IRQL = PASSIVE_LEVEL */
static inline void RaiseClock(struct rt_rtmp_adapter *pAd, u32 * x)
{
*x = *x | EESK;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
RTMPusecDelay(1); /* Max frequency = 1MHz in Spec. definition */
}
/* IRQL = PASSIVE_LEVEL */
static inline void LowerClock(struct rt_rtmp_adapter *pAd, u32 * x)
{
*x = *x & ~EESK;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
RTMPusecDelay(1);
}
/* IRQL = PASSIVE_LEVEL */
static inline u16 ShiftInBits(struct rt_rtmp_adapter *pAd)
{
u32 x, i;
u16 data = 0;
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x &= ~(EEDO | EEDI);
for (i = 0; i < 16; i++) {
data = data << 1;
RaiseClock(pAd, &x);
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
LowerClock(pAd, &x); /*prevent read failed */
x &= ~(EEDI);
if (x & EEDO)
data |= 1;
}
return data;
}
/* IRQL = PASSIVE_LEVEL */
static inline void ShiftOutBits(struct rt_rtmp_adapter *pAd,
u16 data, u16 count)
{
u32 x, mask;
mask = 0x01 << (count - 1);
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x &= ~(EEDO | EEDI);
do {
x &= ~EEDI;
if (data & mask)
x |= EEDI;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
RaiseClock(pAd, &x);
LowerClock(pAd, &x);
mask = mask >> 1;
} while (mask);
x &= ~EEDI;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
}
/* IRQL = PASSIVE_LEVEL */
static inline void EEpromCleanup(struct rt_rtmp_adapter *pAd)
{
u32 x;
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x &= ~(EECS | EEDI);
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
RaiseClock(pAd, &x);
LowerClock(pAd, &x);
}
static inline void EWEN(struct rt_rtmp_adapter *pAd)
{
u32 x;
/* reset bits and set EECS */
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x &= ~(EEDI | EEDO | EESK);
x |= EECS;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
/* kick a pulse */
RaiseClock(pAd, &x);
LowerClock(pAd, &x);
/* output the read_opcode and six pulse in that order */
ShiftOutBits(pAd, EEPROM_EWEN_OPCODE, 5);
ShiftOutBits(pAd, 0, 6);
EEpromCleanup(pAd);
}
static inline void EWDS(struct rt_rtmp_adapter *pAd)
{
u32 x;
/* reset bits and set EECS */
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x &= ~(EEDI | EEDO | EESK);
x |= EECS;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
/* kick a pulse */
RaiseClock(pAd, &x);
LowerClock(pAd, &x);
/* output the read_opcode and six pulse in that order */
ShiftOutBits(pAd, EEPROM_EWDS_OPCODE, 5);
ShiftOutBits(pAd, 0, 6);
EEpromCleanup(pAd);
}
/* IRQL = PASSIVE_LEVEL */
int rtmp_ee_prom_read16(struct rt_rtmp_adapter *pAd,
u16 Offset, u16 * pValue)
{
u32 x;
u16 data;
Offset /= 2;
/* reset bits and set EECS */
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
x &= ~(EEDI | EEDO | EESK);
x |= EECS;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
/* patch can not access e-Fuse issue */
if (!(IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))) {
/* kick a pulse */
RaiseClock(pAd, &x);
LowerClock(pAd, &x);
}
/* output the read_opcode and register number in that order */
ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
/* Now read the data (16 bits) in from the selected EEPROM word */
data = ShiftInBits(pAd);
EEpromCleanup(pAd);
*pValue = data;
return NDIS_STATUS_SUCCESS;
}

View file

@ -1,91 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
eeprom.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
*/
#include "../rt_config.h"
int RtmpChipOpsEepromHook(struct rt_rtmp_adapter *pAd, int infType)
{
struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
#ifdef RT30xx
#ifdef RTMP_EFUSE_SUPPORT
u32 eFuseCtrl, MacCsr0;
int index;
index = 0;
do {
RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
pAd->MACVersion = MacCsr0;
if ((pAd->MACVersion != 0x00)
&& (pAd->MACVersion != 0xFFFFFFFF))
break;
RTMPusecDelay(10);
} while (index++ < 100);
pAd->bUseEfuse = FALSE;
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrl);
pAd->bUseEfuse = ((eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0;
if (pAd->bUseEfuse) {
pChipOps->eeinit = eFuse_init;
pChipOps->eeread = rtmp_ee_efuse_read16;
return 0;
} else
DBGPRINT(RT_DEBUG_TRACE, ("NVM is EEPROM\n"));
#endif /* RTMP_EFUSE_SUPPORT // */
#endif /* RT30xx // */
switch (infType) {
#ifdef RTMP_PCI_SUPPORT
case RTMP_DEV_INF_PCI:
pChipOps->eeinit = NULL;
pChipOps->eeread = rtmp_ee_prom_read16;
break;
#endif /* RTMP_PCI_SUPPORT // */
#ifdef RTMP_USB_SUPPORT
case RTMP_DEV_INF_USB:
pChipOps->eeinit = NULL;
pChipOps->eeread = RTUSBReadEEPROM16;
break;
#endif /* RTMP_USB_SUPPORT // */
default:
DBGPRINT(RT_DEBUG_ERROR, ("RtmpChipOpsEepromHook() failed!\n"));
break;
}
return 0;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,187 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_rf.c
Abstract:
Ralink Wireless driver RF related functions
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#include "../rt_config.h"
#ifdef RTMP_RF_RW_SUPPORT
/*
========================================================================
Routine Description: Write RT30xx RF register through MAC
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
int RT30xxWriteRFRegister(struct rt_rtmp_adapter *pAd,
u8 regID, u8 value)
{
RF_CSR_CFG_STRUC rfcsr;
u32 i = 0;
do {
RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
if (!rfcsr.field.RF_CSR_KICK)
break;
i++;
}
while ((i < RETRY_LIMIT)
&& (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
if ((i == RETRY_LIMIT)
|| (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
DBGPRINT_RAW(RT_DEBUG_ERROR,
("Retry count exhausted or device removed!\n"));
return STATUS_UNSUCCESSFUL;
}
rfcsr.field.RF_CSR_WR = 1;
rfcsr.field.RF_CSR_KICK = 1;
rfcsr.field.TESTCSR_RFACC_REGNUM = regID;
rfcsr.field.RF_CSR_DATA = value;
RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
return NDIS_STATUS_SUCCESS;
}
/*
========================================================================
Routine Description: Read RT30xx RF register through MAC
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
int RT30xxReadRFRegister(struct rt_rtmp_adapter *pAd,
u8 regID, u8 *pValue)
{
RF_CSR_CFG_STRUC rfcsr;
u32 i = 0, k = 0;
for (i = 0; i < MAX_BUSY_COUNT; i++) {
RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
if (rfcsr.field.RF_CSR_KICK == BUSY) {
continue;
}
rfcsr.word = 0;
rfcsr.field.RF_CSR_WR = 0;
rfcsr.field.RF_CSR_KICK = 1;
rfcsr.field.TESTCSR_RFACC_REGNUM = regID;
RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
for (k = 0; k < MAX_BUSY_COUNT; k++) {
RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
if (rfcsr.field.RF_CSR_KICK == IDLE)
break;
}
if ((rfcsr.field.RF_CSR_KICK == IDLE) &&
(rfcsr.field.TESTCSR_RFACC_REGNUM == regID)) {
*pValue = (u8)rfcsr.field.RF_CSR_DATA;
break;
}
}
if (rfcsr.field.RF_CSR_KICK == BUSY) {
DBGPRINT_ERR("RF read R%d=0x%x fail, i[%d], k[%d]\n", regID, rfcsr.word, i, k);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
}
void NICInitRFRegisters(struct rt_rtmp_adapter *pAd)
{
if (pAd->chipOps.AsicRfInit)
pAd->chipOps.AsicRfInit(pAd);
}
void RtmpChipOpsRFHook(struct rt_rtmp_adapter *pAd)
{
struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
pChipOps->pRFRegTable = NULL;
pChipOps->AsicRfInit = NULL;
pChipOps->AsicRfTurnOn = NULL;
pChipOps->AsicRfTurnOff = NULL;
pChipOps->AsicReverseRfFromSleepMode = NULL;
pChipOps->AsicHaltAction = NULL;
/* We depends on RfICType and MACVersion to assign the corresponding operation callbacks. */
#ifdef RT30xx
if (IS_RT30xx(pAd)) {
pChipOps->pRFRegTable = RT30xx_RFRegTable;
pChipOps->AsicHaltAction = RT30xxHaltAction;
#ifdef RT3070
if ((IS_RT3070(pAd) || IS_RT3071(pAd))
&& (pAd->infType == RTMP_DEV_INF_USB)) {
pChipOps->AsicRfInit = NICInitRT3070RFRegisters;
if (IS_RT3071(pAd)) {
pChipOps->AsicRfTurnOff =
RT30xxLoadRFSleepModeSetup;
pChipOps->AsicReverseRfFromSleepMode =
RT30xxReverseRFSleepModeSetup;
}
}
#endif /* RT3070 // */
#ifdef RT3090
if (IS_RT3090(pAd) && (pAd->infType == RTMP_DEV_INF_PCI)) {
pChipOps->AsicRfTurnOff = RT30xxLoadRFSleepModeSetup;
pChipOps->AsicRfInit = NICInitRT3090RFRegisters;
pChipOps->AsicReverseRfFromSleepMode =
RT30xxReverseRFSleepModeSetup;
}
#endif /* RT3090 // */
}
#endif /* RT30xx // */
}
#endif /* RTMP_RF_RW_SUPPORT // */

File diff suppressed because it is too large Load diff

View file

@ -1,336 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_mcu.c
Abstract:
Miniport generic portion header file
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#include "../rt_config.h"
#include <linux/crc-ccitt.h>
#include <linux/firmware.h>
#ifdef RTMP_MAC_USB
#define FIRMWAREIMAGE_LENGTH 0x1000
#define FIRMWARE_2870_MIN_VERSION 12
#define FIRMWARE_2870_FILENAME "rt2870.bin"
MODULE_FIRMWARE(FIRMWARE_2870_FILENAME);
#define FIRMWARE_3070_MIN_VERSION 17
#define FIRMWARE_3070_FILENAME "rt3070.bin"
MODULE_FIRMWARE(FIRMWARE_3070_FILENAME);
#define FIRMWARE_3071_MIN_VERSION 17
#define FIRMWARE_3071_FILENAME "rt3071.bin" /* for RT3071/RT3072 */
MODULE_FIRMWARE(FIRMWARE_3071_FILENAME);
#else /* RTMP_MAC_PCI */
#define FIRMWAREIMAGE_LENGTH 0x2000
#define FIRMWARE_2860_MIN_VERSION 11
#define FIRMWARE_2860_FILENAME "rt2860.bin"
MODULE_FIRMWARE(FIRMWARE_2860_FILENAME);
#define FIRMWARE_3090_MIN_VERSION 19
#define FIRMWARE_3090_FILENAME "rt3090.bin" /* for RT3090/RT3390 */
MODULE_FIRMWARE(FIRMWARE_3090_FILENAME);
#endif
/*
========================================================================
Routine Description:
erase 8051 firmware image in MAC ASIC
Arguments:
Adapter Pointer to our adapter
IRQL = PASSIVE_LEVEL
========================================================================
*/
int RtmpAsicEraseFirmware(struct rt_rtmp_adapter *pAd)
{
unsigned long i;
for (i = 0; i < MAX_FIRMWARE_IMAGE_SIZE; i += 4)
RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, 0);
return 0;
}
static const struct firmware *rtmp_get_firmware(struct rt_rtmp_adapter *adapter)
{
const char *name;
const struct firmware *fw = NULL;
u8 min_version;
struct device *dev;
int err;
if (adapter->firmware)
return adapter->firmware;
#ifdef RTMP_MAC_USB
if (IS_RT3071(adapter)) {
name = FIRMWARE_3071_FILENAME;
min_version = FIRMWARE_3071_MIN_VERSION;
} else if (IS_RT3070(adapter)) {
name = FIRMWARE_3070_FILENAME;
min_version = FIRMWARE_3070_MIN_VERSION;
} else {
name = FIRMWARE_2870_FILENAME;
min_version = FIRMWARE_2870_MIN_VERSION;
}
dev = &((struct os_cookie *)adapter->OS_Cookie)->pUsb_Dev->dev;
#else /* RTMP_MAC_PCI */
if (IS_RT3090(adapter) || IS_RT3390(adapter)) {
name = FIRMWARE_3090_FILENAME;
min_version = FIRMWARE_3090_MIN_VERSION;
} else {
name = FIRMWARE_2860_FILENAME;
min_version = FIRMWARE_2860_MIN_VERSION;
}
dev = &((struct os_cookie *)adapter->OS_Cookie)->pci_dev->dev;
#endif
err = request_firmware(&fw, name, dev);
if (err) {
dev_err(dev, "firmware file %s request failed (%d)\n",
name, err);
return NULL;
}
if (fw->size < FIRMWAREIMAGE_LENGTH) {
dev_err(dev, "firmware file %s size is invalid\n", name);
goto invalid;
}
/* is it new enough? */
adapter->FirmwareVersion = fw->data[FIRMWAREIMAGE_LENGTH - 3];
if (adapter->FirmwareVersion < min_version) {
dev_err(dev,
"firmware file %s is too old;"
" driver requires v%d or later\n",
name, min_version);
goto invalid;
}
/* is the internal CRC correct? */
if (crc_ccitt(0xffff, fw->data, FIRMWAREIMAGE_LENGTH - 2) !=
(fw->data[FIRMWAREIMAGE_LENGTH - 2] |
(fw->data[FIRMWAREIMAGE_LENGTH - 1] << 8))) {
dev_err(dev, "firmware file %s failed internal CRC\n", name);
goto invalid;
}
adapter->firmware = fw;
return fw;
invalid:
release_firmware(fw);
return NULL;
}
/*
========================================================================
Routine Description:
Load 8051 firmware file into MAC ASIC
Arguments:
Adapter Pointer to our adapter
Return Value:
NDIS_STATUS_SUCCESS firmware image load ok
NDIS_STATUS_FAILURE image not found
IRQL = PASSIVE_LEVEL
========================================================================
*/
int RtmpAsicLoadFirmware(struct rt_rtmp_adapter *pAd)
{
const struct firmware *fw;
int Status = NDIS_STATUS_SUCCESS;
unsigned long Index;
u32 MacReg = 0;
fw = rtmp_get_firmware(pAd);
if (!fw)
return NDIS_STATUS_FAILURE;
RTMP_WRITE_FIRMWARE(pAd, fw->data, FIRMWAREIMAGE_LENGTH);
/* check if MCU is ready */
Index = 0;
do {
RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacReg);
if (MacReg & 0x80)
break;
RTMPusecDelay(1000);
} while (Index++ < 1000);
if (Index > 1000) {
DBGPRINT(RT_DEBUG_ERROR,
("NICLoadFirmware: MCU is not ready\n"));
Status = NDIS_STATUS_FAILURE;
}
DBGPRINT(RT_DEBUG_TRACE, ("<=== %s (status=%d)\n", __func__, Status));
return Status;
}
int RtmpAsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
u8 Command,
u8 Token, u8 Arg0, u8 Arg1)
{
HOST_CMD_CSR_STRUC H2MCmd;
H2M_MAILBOX_STRUC H2MMailbox;
unsigned long i = 0;
#ifdef PCIE_PS_SUPPORT
/* 3090F power solution 3 has hw limitation that needs to ban all mcu command */
/* when firmware is in radio state. For other chip doesn't have this limitation. */
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
&& IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
RTMP_SEM_LOCK(&pAd->McuCmdLock);
if ((pAd->brt30xxBanMcuCmd == TRUE)
&& (Command != WAKE_MCU_CMD) && (Command != RFOFF_MCU_CMD)) {
RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
DBGPRINT(RT_DEBUG_TRACE,
(" Ban Mcu Cmd %x in sleep mode\n", Command));
return FALSE;
} else if ((Command == SLEEP_MCU_CMD)
|| (Command == RFOFF_MCU_CMD)) {
pAd->brt30xxBanMcuCmd = TRUE;
} else if (Command != WAKE_MCU_CMD) {
pAd->brt30xxBanMcuCmd = FALSE;
}
RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
}
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
&& IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
&& (Command == WAKE_MCU_CMD)) {
do {
RTMP_IO_FORCE_READ32(pAd, H2M_MAILBOX_CSR,
&H2MMailbox.word);
if (H2MMailbox.field.Owner == 0)
break;
RTMPusecDelay(2);
DBGPRINT(RT_DEBUG_INFO,
("AsicSendCommanToMcu::Mail box is busy\n"));
} while (i++ < 100);
if (i > 100) {
DBGPRINT_ERR("H2M_MAILBOX still hold by MCU. command fail\n");
return FALSE;
}
H2MMailbox.field.Owner = 1; /* pass ownership to MCU */
H2MMailbox.field.CmdToken = Token;
H2MMailbox.field.HighByte = Arg1;
H2MMailbox.field.LowByte = Arg0;
RTMP_IO_FORCE_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
H2MCmd.word = 0;
H2MCmd.field.HostCommand = Command;
RTMP_IO_FORCE_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
} else
#endif /* PCIE_PS_SUPPORT // */
{
do {
RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
if (H2MMailbox.field.Owner == 0)
break;
RTMPusecDelay(2);
} while (i++ < 100);
if (i > 100) {
#ifdef RTMP_MAC_PCI
#endif /* RTMP_MAC_PCI // */
{
DBGPRINT_ERR("H2M_MAILBOX still hold by MCU. command fail\n");
}
return FALSE;
}
#ifdef RTMP_MAC_PCI
#endif /* RTMP_MAC_PCI // */
H2MMailbox.field.Owner = 1; /* pass ownership to MCU */
H2MMailbox.field.CmdToken = Token;
H2MMailbox.field.HighByte = Arg1;
H2MMailbox.field.LowByte = Arg0;
RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
H2MCmd.word = 0;
H2MCmd.field.HostCommand = Command;
RTMP_IO_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
if (Command != 0x80) {
}
}
#ifdef PCIE_PS_SUPPORT
/* 3090 MCU Wakeup command needs more time to be stable. */
/* Before stable, don't issue other MCU command to prevent from firmware error. */
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
&& IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
&& (Command == WAKE_MCU_CMD)) {
RTMPusecDelay(2000);
/*Put this is after RF programming. */
/*NdisAcquireSpinLock(&pAd->McuCmdLock); */
/*pAd->brt30xxBanMcuCmd = FALSE; */
/*NdisReleaseSpinLock(&pAd->McuCmdLock); */
}
#endif /* PCIE_PS_SUPPORT // */
return TRUE;
}

View file

@ -1,302 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_timer.c
Abstract:
task for timer handling
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Shiang Tu 08-28-2008 init version
*/
#include "../rt_config.h"
BUILD_TIMER_FUNCTION(MlmePeriodicExec);
/*BUILD_TIMER_FUNCTION(MlmeRssiReportExec); */
BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
BUILD_TIMER_FUNCTION(APSDPeriodicExec);
BUILD_TIMER_FUNCTION(AsicRfTuningExec);
#ifdef RTMP_MAC_USB
BUILD_TIMER_FUNCTION(BeaconUpdateExec);
#endif /* RTMP_MAC_USB // */
BUILD_TIMER_FUNCTION(BeaconTimeout);
BUILD_TIMER_FUNCTION(ScanTimeout);
BUILD_TIMER_FUNCTION(AuthTimeout);
BUILD_TIMER_FUNCTION(AssocTimeout);
BUILD_TIMER_FUNCTION(ReassocTimeout);
BUILD_TIMER_FUNCTION(DisassocTimeout);
BUILD_TIMER_FUNCTION(LinkDownExec);
BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
#ifdef RTMP_MAC_PCI
BUILD_TIMER_FUNCTION(PsPollWakeExec);
BUILD_TIMER_FUNCTION(RadioOnExec);
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
BUILD_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
#endif /* RTMP_MAC_USB // */
#if defined(AP_LED) || defined(STA_LED)
extern void LedCtrlMain(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
BUILD_TIMER_FUNCTION(LedCtrlMain);
#endif
#ifdef RTMP_TIMER_TASK_SUPPORT
static void RtmpTimerQHandle(struct rt_rtmp_adapter *pAd)
{
#ifndef KTHREAD_SUPPORT
int status;
#endif
struct rt_ralink_timer *pTimer;
struct rt_rtmp_timer_task_entry *pEntry;
unsigned long irqFlag;
struct rt_rtmp_os_task *pTask;
pTask = &pAd->timerTask;
while (!pTask->task_killed) {
pTimer = NULL;
#ifdef KTHREAD_SUPPORT
RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
#else
RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);
#endif
if (pAd->TimerQ.status == RTMP_TASK_STAT_STOPED)
break;
/* event happened. */
while (pAd->TimerQ.pQHead) {
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlag);
pEntry = pAd->TimerQ.pQHead;
if (pEntry) {
pTimer = pEntry->pRaTimer;
/* update pQHead */
pAd->TimerQ.pQHead = pEntry->pNext;
if (pEntry == pAd->TimerQ.pQTail)
pAd->TimerQ.pQTail = NULL;
/* return this queue entry to timerQFreeList. */
pEntry->pNext = pAd->TimerQ.pQPollFreeList;
pAd->TimerQ.pQPollFreeList = pEntry;
}
RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlag);
if (pTimer) {
if ((pTimer->handle != NULL)
&& (!pAd->PM_FlgSuspend))
pTimer->handle(NULL,
(void *)pTimer->cookie,
NULL, pTimer);
if ((pTimer->Repeat)
&& (pTimer->State == FALSE))
RTMP_OS_Add_Timer(&pTimer->TimerObj,
pTimer->TimerValue);
}
}
#ifndef KTHREAD_SUPPORT
if (status != 0) {
pAd->TimerQ.status = RTMP_TASK_STAT_STOPED;
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
break;
}
#endif
}
}
int RtmpTimerQThread(IN void *Context)
{
struct rt_rtmp_os_task *pTask;
struct rt_rtmp_adapter *pAd;
pTask = Context;
pAd = pTask->priv;
RtmpOSTaskCustomize(pTask);
RtmpTimerQHandle(pAd);
DBGPRINT(RT_DEBUG_TRACE, ("<---%s\n", __func__));
#ifndef KTHREAD_SUPPORT
pTask->taskPID = THREAD_PID_INIT_VALUE;
#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().
*/
RtmpOSTaskNotifyToExit(pTask);
return 0;
}
struct rt_rtmp_timer_task_entry *RtmpTimerQInsert(struct rt_rtmp_adapter *pAd,
struct rt_ralink_timer *pTimer)
{
struct rt_rtmp_timer_task_entry *pQNode = NULL, *pQTail;
unsigned long irqFlags;
struct rt_rtmp_os_task *pTask = &pAd->timerTask;
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
if (pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT) {
if (pAd->TimerQ.pQPollFreeList) {
pQNode = pAd->TimerQ.pQPollFreeList;
pAd->TimerQ.pQPollFreeList = pQNode->pNext;
pQNode->pRaTimer = pTimer;
pQNode->pNext = NULL;
pQTail = pAd->TimerQ.pQTail;
if (pAd->TimerQ.pQTail != NULL)
pQTail->pNext = pQNode;
pAd->TimerQ.pQTail = pQNode;
if (pAd->TimerQ.pQHead == NULL)
pAd->TimerQ.pQHead = pQNode;
}
}
RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
if (pQNode) {
#ifdef KTHREAD_SUPPORT
WAKE_UP(pTask);
#else
RTMP_SEM_EVENT_UP(&pTask->taskSema);
#endif
}
return pQNode;
}
BOOLEAN RtmpTimerQRemove(struct rt_rtmp_adapter *pAd, struct rt_ralink_timer *pTimer)
{
struct rt_rtmp_timer_task_entry *pNode, *pPrev = NULL;
unsigned long irqFlags;
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
if (pAd->TimerQ.status >= RTMP_TASK_STAT_INITED) {
pNode = pAd->TimerQ.pQHead;
while (pNode) {
if (pNode->pRaTimer == pTimer)
break;
pPrev = pNode;
pNode = pNode->pNext;
}
/* Now move it to freeList queue. */
if (pNode) {
if (pNode == pAd->TimerQ.pQHead)
pAd->TimerQ.pQHead = pNode->pNext;
if (pNode == pAd->TimerQ.pQTail)
pAd->TimerQ.pQTail = pPrev;
if (pPrev != NULL)
pPrev->pNext = pNode->pNext;
/* return this queue entry to timerQFreeList. */
pNode->pNext = pAd->TimerQ.pQPollFreeList;
pAd->TimerQ.pQPollFreeList = pNode;
}
}
RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
return TRUE;
}
void RtmpTimerQExit(struct rt_rtmp_adapter *pAd)
{
struct rt_rtmp_timer_task_entry *pTimerQ;
unsigned long irqFlags;
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
while (pAd->TimerQ.pQHead) {
pTimerQ = pAd->TimerQ.pQHead;
pAd->TimerQ.pQHead = pTimerQ->pNext;
/* remove the timeQ */
}
pAd->TimerQ.pQPollFreeList = NULL;
os_free_mem(pAd, pAd->TimerQ.pTimerQPoll);
pAd->TimerQ.pQTail = NULL;
pAd->TimerQ.pQHead = NULL;
#ifndef KTHREAD_SUPPORT
pAd->TimerQ.status = RTMP_TASK_STAT_STOPED;
#endif
RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
}
void RtmpTimerQInit(struct rt_rtmp_adapter *pAd)
{
int i;
struct rt_rtmp_timer_task_entry *pQNode, *pEntry;
unsigned long irqFlags;
NdisAllocateSpinLock(&pAd->TimerQLock);
NdisZeroMemory(&pAd->TimerQ, sizeof(pAd->TimerQ));
os_alloc_mem(pAd, &pAd->TimerQ.pTimerQPoll,
sizeof(struct rt_rtmp_timer_task_entry) * TIMER_QUEUE_SIZE_MAX);
if (pAd->TimerQ.pTimerQPoll) {
pEntry = NULL;
pQNode = (struct rt_rtmp_timer_task_entry *)pAd->TimerQ.pTimerQPoll;
NdisZeroMemory(pAd->TimerQ.pTimerQPoll,
sizeof(struct rt_rtmp_timer_task_entry) *
TIMER_QUEUE_SIZE_MAX);
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
for (i = 0; i < TIMER_QUEUE_SIZE_MAX; i++) {
pQNode->pNext = pEntry;
pEntry = pQNode;
pQNode++;
}
pAd->TimerQ.pQPollFreeList = pEntry;
pAd->TimerQ.pQHead = NULL;
pAd->TimerQ.pQTail = NULL;
pAd->TimerQ.status = RTMP_TASK_STAT_INITED;
RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
}
}
#endif /* RTMP_TIMER_TASK_SUPPORT // */

File diff suppressed because it is too large Load diff

View file

@ -1,65 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
/****************************************************************************
Module Name:
HMAC
Abstract:
FIPS 198: The Keyed-Hash Message Authentication Code (HMAC)
Revision History:
Who When What
-------- ---------- ------------------------------------------
Eddy 2008/11/24 Create HMAC-SHA1, HMAC-SHA256
***************************************************************************/
#ifndef __CRYPT_HMAC_H__
#define __CRYPT_HMAC_H__
#ifdef CRYPT_TESTPLAN
#include "crypt_testplan.h"
#else
#include "rt_config.h"
#endif /* CRYPT_TESTPLAN */
#ifdef SHA1_SUPPORT
#define HMAC_SHA1_SUPPORT
void HMAC_SHA1(IN const u8 Key[],
u32 KeyLen,
IN const u8 Message[],
u32 MessageLen, u8 MAC[], u32 MACLen);
#endif /* SHA1_SUPPORT */
#ifdef MD5_SUPPORT
#define HMAC_MD5_SUPPORT
void HMAC_MD5(IN const u8 Key[],
u32 KeyLen,
IN const u8 Message[],
u32 MessageLen, u8 MAC[], u32 MACLen);
#endif /* MD5_SUPPORT */
#endif /* __CRYPT_HMAC_H__ */

View file

@ -1,73 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
/****************************************************************************
Module Name:
MD5
Abstract:
RFC1321: The MD5 Message-Digest Algorithm
Revision History:
Who When What
-------- ---------- ------------------------------------------
Eddy 2008/11/24 Create md5
***************************************************************************/
#ifndef __CRYPT_MD5_H__
#define __CRYPT_MD5_H__
#ifdef CRYPT_TESTPLAN
#include "crypt_testplan.h"
#else
#include "rt_config.h"
#endif /* CRYPT_TESTPLAN */
/* Algorithm options */
#define MD5_SUPPORT
#ifdef MD5_SUPPORT
#define MD5_BLOCK_SIZE 64 /* 512 bits = 64 bytes */
#define MD5_DIGEST_SIZE 16 /* 128 bits = 16 bytes */
struct rt_md5_ctx_struc {
u32 HashValue[4];
u64 MessageLen;
u8 Block[MD5_BLOCK_SIZE];
u32 BlockLen;
};
void MD5_Init(struct rt_md5_ctx_struc *pMD5_CTX);
void MD5_Hash(struct rt_md5_ctx_struc *pMD5_CTX);
void MD5_Append(struct rt_md5_ctx_struc *pMD5_CTX,
IN const u8 Message[], u32 MessageLen);
void MD5_End(struct rt_md5_ctx_struc *pMD5_CTX, u8 DigestMessage[]);
void RT_MD5(IN const u8 Message[],
u32 MessageLen, u8 DigestMessage[]);
#endif /* MD5_SUPPORT */
#endif /* __CRYPT_MD5_H__ */

View file

@ -1,73 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
/****************************************************************************
Module Name:
SHA2
Abstract:
FIPS 180-2: Secure Hash Standard (SHS)
Revision History:
Who When What
-------- ---------- ------------------------------------------
Eddy 2008/11/24 Create SHA1
Eddy 2008/07/23 Create SHA256
***************************************************************************/
#ifndef __CRYPT_SHA2_H__
#define __CRYPT_SHA2_H__
#ifdef CRYPT_TESTPLAN
#include "crypt_testplan.h"
#else
#include "rt_config.h"
#endif /* CRYPT_TESTPLAN */
/* Algorithm options */
#define SHA1_SUPPORT
#ifdef SHA1_SUPPORT
#define SHA1_BLOCK_SIZE 64 /* 512 bits = 64 bytes */
#define SHA1_DIGEST_SIZE 20 /* 160 bits = 20 bytes */
struct rt_sha1_ctx {
u32 HashValue[5]; /* 5 = (SHA1_DIGEST_SIZE / 32) */
u64 MessageLen; /* total size */
u8 Block[SHA1_BLOCK_SIZE];
u32 BlockLen;
};
void RT_SHA1_Init(struct rt_sha1_ctx *pSHA_CTX);
void SHA1_Hash(struct rt_sha1_ctx *pSHA_CTX);
void SHA1_Append(struct rt_sha1_ctx *pSHA_CTX,
IN const u8 Message[], u32 MessageLen);
void SHA1_End(struct rt_sha1_ctx *pSHA_CTX, u8 DigestMessage[]);
void RT_SHA1(IN const u8 Message[],
u32 MessageLen, u8 DigestMessage[]);
#endif /* SHA1_SUPPORT */
#endif /* __CRYPT_SHA2_H__ */

View file

@ -1,39 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
dfs.h
Abstract:
Support DFS function.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Fonchi 03-12-2007 created
*/
BOOLEAN RadarChannelCheck(struct rt_rtmp_adapter *pAd, u8 Ch);

View file

@ -1,67 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
eeprom.h
Abstract:
Miniport header file for eeprom related information
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifndef __EEPROM_H__
#define __EEPROM_H__
#ifdef RTMP_PCI_SUPPORT
/*************************************************************************
* Public function declarations for prom-based chipset
************************************************************************/
int rtmp_ee_prom_read16(struct rt_rtmp_adapter *pAd,
u16 Offset, u16 *pValue);
#endif /* RTMP_PCI_SUPPORT // */
#ifdef RTMP_USB_SUPPORT
/*************************************************************************
* Public function declarations for usb-based prom chipset
************************************************************************/
int RTUSBReadEEPROM16(struct rt_rtmp_adapter *pAd,
u16 offset, u16 *pData);
#endif /* RTMP_USB_SUPPORT // */
#ifdef RT30xx
#ifdef RTMP_EFUSE_SUPPORT
int rtmp_ee_efuse_read16(struct rt_rtmp_adapter *pAd,
u16 Offset, u16 *pValue);
#endif /* RTMP_EFUSE_SUPPORT // */
#endif /* RT30xx // */
/*************************************************************************
* Public function declarations for prom operation callback functions setting
************************************************************************/
int RtmpChipOpsEepromHook(struct rt_rtmp_adapter *pAd, int infType);
#endif /* __EEPROM_H__ // */

View file

@ -1,80 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __RTMP_PCI_H__
#define __RTMP_PCI_H__
#define RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p) \
((struct os_cookie *)handle)->pci_dev = dev_p;
#ifdef LINUX
/* set driver data */
#define RT28XX_DRVDATA_SET(_a) pci_set_drvdata(_a, net_dev);
#define RT28XX_PUT_DEVICE(dev_p)
#define SA_SHIRQ IRQF_SHARED
#ifdef PCI_MSI_SUPPORT
#define RTMP_MSI_ENABLE(_pAd) \
{ struct os_cookie *_pObj = (struct os_cookie *)(_pAd->OS_Cookie); \
(_pAd)->HaveMsi = pci_enable_msi(_pObj->pci_dev) \
== 0 ? TRUE : FALSE; \
}
#define RTMP_MSI_DISABLE(_pAd) \
{ struct os_cookie *_pObj = (struct os_cookie *)(_pAd->OS_Cookie); \
if (_pAd->HaveMsi == TRUE) \
pci_disable_msi(_pObj->pci_dev); \
_pAd->HaveMsi = FALSE; \
}
#else
#define RTMP_MSI_ENABLE(_pAd) do {} while (0)
#define RTMP_MSI_DISABLE(_pAd) do {} while (0)
#endif /* PCI_MSI_SUPPORT */
#define RTMP_PCI_DEV_UNMAP() \
{ if (net_dev->base_addr) { \
iounmap((void *)(net_dev->base_addr)); \
release_mem_region(pci_resource_start(dev_p, 0), \
pci_resource_len(dev_p, 0)); } \
if (net_dev->irq) \
pci_release_regions(dev_p); }
#define PCI_REG_READ_WORD(pci_dev, offset, Configuration) {\
if (pci_read_config_word(pci_dev, offset, &reg16) == 0) \
Configuration = le2cpu16(reg16); \
else \
Configuration = 0; }
#define PCI_REG_WIRTE_WORD(pci_dev, offset, Configuration) {\
reg16 = cpu2le16(Configuration); \
pci_write_config_word(pci_dev, offset, reg16); }
#endif /* LINUX */
#endif /* __RTMP_PCI_H__ */

View file

@ -1,196 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __RTMP_USB_H__
#define __RTMP_USB_H__
#include "../rtusb_io.h"
#ifdef LINUX
#include <linux/usb.h>
#endif /* LINUX */
extern u8 EpToQueue[6];
#define RXBULKAGGRE_ZISE 12
#define MAX_TXBULK_LIMIT (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))
#define MAX_TXBULK_SIZE (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)
#define MAX_RXBULK_SIZE (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)
#define MAX_MLME_HANDLER_MEMORY 20
/* Flags for Bulkflags control for bulk out data */
#define fRTUSB_BULK_OUT_DATA_NULL 0x00000001
#define fRTUSB_BULK_OUT_RTS 0x00000002
#define fRTUSB_BULK_OUT_MLME 0x00000004
#define fRTUSB_BULK_OUT_PSPOLL 0x00000010
#define fRTUSB_BULK_OUT_DATA_FRAG 0x00000020
#define fRTUSB_BULK_OUT_DATA_FRAG_2 0x00000040
#define fRTUSB_BULK_OUT_DATA_FRAG_3 0x00000080
#define fRTUSB_BULK_OUT_DATA_FRAG_4 0x00000100
#define fRTUSB_BULK_OUT_DATA_NORMAL 0x00010000
#define fRTUSB_BULK_OUT_DATA_NORMAL_2 0x00020000
#define fRTUSB_BULK_OUT_DATA_NORMAL_3 0x00040000
#define fRTUSB_BULK_OUT_DATA_NORMAL_4 0x00080000
/* TODO:move to ./ate/include/iface/ate_usb.h */
#define FREE_HTTX_RING(_pCookie, _pipeId, _txContext) \
{ \
if ((_txContext)->ENextBulkOutPosition == \
(_txContext)->CurWritePosition) {\
(_txContext)->bRingEmpty = TRUE; \
} \
/*NdisInterlockedDecrement(&(_p)->TxCount); */\
}
/******************************************************************************
USB Bulk operation related definitions
******************************************************************************/
#ifdef LINUX
#define BULKAGGRE_ZISE 100
#define RT28XX_PUT_DEVICE usb_put_dev
#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC)
#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, \
GFP_ATOMIC)
#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, \
BufSize, \
pDma_addr) \
usb_alloc_coherent(\
pUsb_Dev, \
BufSize, \
GFP_ATOMIC, \
pDma_addr)
#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, \
BufSize, \
pTransferBuf, \
Dma_addr) \
usb_free_coherent( \
pUsb_Dev, \
BufSize, \
pTransferBuf, \
Dma_addr)
#define RTUSB_FREE_URB(pUrb) usb_free_urb(pUrb)
/* unlink urb */
#define RTUSB_UNLINK_URB(pUrb) usb_kill_urb(pUrb)
extern void dump_urb(struct urb *purb);
#define InterlockedIncrement atomic_inc
#define NdisInterlockedIncrement atomic_inc
#define InterlockedDecrement atomic_dec
#define NdisInterlockedDecrement atomic_dec
#define InterlockedExchange atomic_set
#endif /* LINUX */
#define NT_SUCCESS(status) (((status) >= 0) ? (TRUE) : (FALSE))
#define USBD_TRANSFER_DIRECTION_OUT 0
#define USBD_TRANSFER_DIRECTION_IN 0
#define USBD_SHORT_TRANSFER_OK 0
#define PURB struct urb *
#define PIRP void *
#define NDIS_OID u32
#ifndef USB_ST_NOERROR
#define USB_ST_NOERROR 0
#endif
/* vendor-specific control operations */
#define CONTROL_TIMEOUT_JIFFIES ((100 * OS_HZ) / 1000)
#define UNLINK_TIMEOUT_MS 3
void RTUSBBulkOutDataPacketComplete(struct urb *purb, struct pt_regs *pt_regs);
void RTUSBBulkOutMLMEPacketComplete(struct urb *pUrb, struct pt_regs *pt_regs);
void RTUSBBulkOutNullFrameComplete(struct urb *pUrb, struct pt_regs *pt_regs);
void RTUSBBulkOutRTSFrameComplete(struct urb *pUrb, struct pt_regs *pt_regs);
void RTUSBBulkOutPsPollComplete(struct urb *pUrb, struct pt_regs *pt_regs);
void RTUSBBulkRxComplete(struct urb *pUrb, struct pt_regs *pt_regs);
#ifdef KTHREAD_SUPPORT
#define RTUSBMlmeUp(pAd) \
do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->mlmeTask);\
if (_pTask->kthread_task) {\
_pTask->kthread_running = TRUE; \
wake_up(&_pTask->kthread_q); \
} \
} while (0)
#else
#define RTUSBMlmeUp(pAd) \
do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->mlmeTask);\
CHECK_PID_LEGALITY(_pTask->taskPID) \
{ \
RTMP_SEM_EVENT_UP(&(_pTask->taskSema)); \
} \
} while (0)
#endif
#ifdef KTHREAD_SUPPORT
#define RTUSBCMDUp(pAd) \
do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->cmdQTask); \
{ \
_pTask->kthread_running = TRUE; \
wake_up(&_pTask->kthread_q); \
} \
} while (0)
#else
#define RTUSBCMDUp(pAd) \
do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->cmdQTask); \
CHECK_PID_LEGALITY(_pTask->taskPID) \
{\
RTMP_SEM_EVENT_UP(&(_pTask->taskSema)); \
} \
} while (0)
#endif
#define DEVICE_VENDOR_REQUEST_OUT 0x40
#define DEVICE_VENDOR_REQUEST_IN 0xc0
/*#define INTERFACE_VENDOR_REQUEST_OUT 0x41*/
/*#define INTERFACE_VENDOR_REQUEST_IN 0xc1*/
#define BULKOUT_MGMT_RESET_FLAG 0x80
#define RTUSB_SET_BULK_FLAG(_M, _F) ((_M)->BulkFlags |= (_F))
#define RTUSB_CLEAR_BULK_FLAG(_M, _F) ((_M)->BulkFlags &= ~(_F))
#define RTUSB_TEST_BULK_FLAG(_M, _F) (((_M)->BulkFlags & (_F)) != 0)
#define RTMP_IRQ_REQUEST(net_dev) do {} while (0)
#define RTMP_IRQ_RELEASE(net_dev) do {} while (0)
#endif /* __RTMP_USB_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,779 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
oid.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Justin P. Mattock 11/07/2010 Fix typos in comments
*/
#ifndef _OID_H_
#define _OID_H_
/*#include <linux/wireless.h> */
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* */
/* IEEE 802.11 Structures and definitions */
/* */
#define MAX_TX_POWER_LEVEL 100 /* mW */
#define MAX_RSSI_TRIGGER -10 /* dBm */
#define MIN_RSSI_TRIGGER -200 /* dBm */
#define MAX_FRAG_THRESHOLD 2346 /* byte count */
#define MIN_FRAG_THRESHOLD 256 /* byte count */
#define MAX_RTS_THRESHOLD 2347 /* byte count */
/* new types for Media Specific Indications */
/* Extension channel offset */
#define EXTCHA_NONE 0
#define EXTCHA_ABOVE 0x1
#define EXTCHA_BELOW 0x3
/* BW */
#define BAND_WIDTH_20 0
#define BAND_WIDTH_40 1
#define BAND_WIDTH_BOTH 2
#define BAND_WIDTH_10 3 /* 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field. */
/* SHORTGI */
#define GAP_INTERVAL_400 1 /* only support in HT mode */
#define GAP_INTERVAL_800 0
#define GAP_INTERVAL_BOTH 2
#define NdisMediaStateConnected 1
#define NdisMediaStateDisconnected 0
#define NDIS_802_11_LENGTH_SSID 32
#define NDIS_802_11_LENGTH_RATES 8
#define NDIS_802_11_LENGTH_RATES_EX 16
#define MAC_ADDR_LENGTH 6
/*#define MAX_NUM_OF_CHS 49 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination */
#define MAX_NUM_OF_CHS 54 /* 14 channels @2.4G + 12@UNII(lower/middle) + 16@HiperLAN2 + 11@UNII(upper) + 0 @Japan + 1 as NULL termination */
#define MAX_NUMBER_OF_EVENT 10 /* entry # in EVENT table */
#define MAX_NUMBER_OF_MAC 32 /* if MAX_MBSSID_NUM is 8, this value can't be larger than 211 */
#define MAX_NUMBER_OF_ACL 64
#define MAX_LENGTH_OF_SUPPORT_RATES 12 /* 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 */
#define MAX_NUMBER_OF_DLS_ENTRY 4
#define RT_QUERY_SIGNAL_CONTEXT 0x0402
#define RT_SET_IAPP_PID 0x0404
#define RT_SET_APD_PID 0x0405
#define RT_SET_DEL_MAC_ENTRY 0x0406
#define RT_QUERY_EVENT_TABLE 0x0407
/* */
/* IEEE 802.11 OIDs */
/* */
#define OID_GET_SET_TOGGLE 0x8000
#define OID_GET_SET_FROM_UI 0x4000
#define OID_802_11_ADD_WEP 0x0112
#define OID_802_11_DISASSOCIATE 0x0114
#define OID_802_11_BSSID_LIST_SCAN 0x0508
#define OID_802_11_SSID 0x0509
#define OID_802_11_BSSID 0x050A
#define OID_802_11_MIC_FAILURE_REPORT_FRAME 0x0528
#define RT_OID_DEVICE_NAME 0x0607
#define RT_OID_VERSION_INFO 0x0608
#define OID_802_11_BSSID_LIST 0x0609
#define OID_802_3_CURRENT_ADDRESS 0x060A
#define OID_GEN_MEDIA_CONNECT_STATUS 0x060B
#define RT_OID_802_11_QUERY_LINK_STATUS 0x060C
#define OID_802_11_RSSI 0x060D
#define OID_802_11_STATISTICS 0x060E
#define OID_GEN_RCV_OK 0x060F
#define OID_GEN_RCV_NO_BUFFER 0x0610
#define RT_OID_802_11_QUERY_EEPROM_VERSION 0x0611
#define RT_OID_802_11_QUERY_FIRMWARE_VERSION 0x0612
#define RT_OID_802_11_QUERY_LAST_RX_RATE 0x0613
#define RT_OID_802_11_TX_POWER_LEVEL_1 0x0614
#define RT_OID_802_11_QUERY_PIDVID 0x0615
/*for WPA_SUPPLICANT_SUPPORT */
#define OID_SET_COUNTERMEASURES 0x0616
#define RT_OID_WPA_SUPPLICANT_SUPPORT 0x0621
#define RT_OID_WE_VERSION_COMPILED 0x0622
#define RT_OID_NEW_DRIVER 0x0623
#define RT_OID_DRIVER_DEVICE_NAME 0x0645
#define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT 0x0647
typedef enum _NDIS_802_11_STATUS_TYPE {
Ndis802_11StatusType_Authentication,
Ndis802_11StatusType_MediaStreamMode,
Ndis802_11StatusType_PMKID_CandidateList,
Ndis802_11StatusTypeMax /* not a real type, defined as an upper bound */
} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
typedef u8 NDIS_802_11_MAC_ADDRESS[6];
struct rt_ndis_802_11_status_indication {
NDIS_802_11_STATUS_TYPE StatusType;
};
/* mask for authentication/integrity fields */
#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f
#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01
#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02
#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E
struct rt_ndis_802_11_authentication_request {
unsigned long Length; /* Length of structure */
NDIS_802_11_MAC_ADDRESS Bssid;
unsigned long Flags;
};
/*Added new types for PMKID Candidate lists. */
struct rt_pmkid_candidate {
NDIS_802_11_MAC_ADDRESS BSSID;
unsigned long Flags;
};
struct rt_ndis_802_11_pmkid_candidate_list {
unsigned long Version; /* Version of the structure */
unsigned long NumCandidates; /* No. of pmkid candidates */
struct rt_pmkid_candidate CandidateList[1];
};
/*Flags for PMKID Candidate list structure */
#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
/* Added new types for OFDM 5G and 2.4G */
typedef enum _NDIS_802_11_NETWORK_TYPE {
Ndis802_11FH,
Ndis802_11DS,
Ndis802_11OFDM5,
Ndis802_11OFDM24,
Ndis802_11Automode,
Ndis802_11OFDM5_N,
Ndis802_11OFDM24_N,
Ndis802_11NetworkTypeMax /* not a real type, defined as an upper bound */
} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
struct rt_ndis_802_11_network_type_list {
u32 NumberOfItems; /* in list below, at least 1 */
NDIS_802_11_NETWORK_TYPE NetworkType[1];
};
typedef enum _NDIS_802_11_POWER_MODE {
Ndis802_11PowerModeCAM,
Ndis802_11PowerModeMAX_PSP,
Ndis802_11PowerModeFast_PSP,
Ndis802_11PowerModeLegacy_PSP,
Ndis802_11PowerModeMax /* not a real mode, defined as an upper bound */
} NDIS_802_11_POWER_MODE, *PNDIS_802_11_POWER_MODE;
typedef unsigned long NDIS_802_11_TX_POWER_LEVEL; /* in milliwatts */
/* */
/* Received Signal Strength Indication */
/* */
typedef long NDIS_802_11_RSSI; /* in dBm */
struct rt_ndis_802_11_configuration_fh {
unsigned long Length; /* Length of structure */
unsigned long HopPattern; /* As defined by 802.11, MSB set */
unsigned long HopSet; /* to one if non-802.11 */
unsigned long DwellTime; /* units are Kusec */
};
struct rt_ndis_802_11_configuration {
unsigned long Length; /* Length of structure */
unsigned long BeaconPeriod; /* units are Kusec */
unsigned long ATIMWindow; /* units are Kusec */
unsigned long DSConfig; /* Frequency, units are kHz */
struct rt_ndis_802_11_configuration_fh FHConfig;
};
struct rt_ndis_802_11_statistics {
unsigned long Length; /* Length of structure */
LARGE_INTEGER TransmittedFragmentCount;
LARGE_INTEGER MulticastTransmittedFrameCount;
LARGE_INTEGER FailedCount;
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;
LARGE_INTEGER TKIPLocalMICFailures;
LARGE_INTEGER TKIPRemoteMICErrors;
LARGE_INTEGER TKIPICVErrors;
LARGE_INTEGER TKIPCounterMeasuresInvoked;
LARGE_INTEGER TKIPReplays;
LARGE_INTEGER CCMPFormatErrors;
LARGE_INTEGER CCMPReplays;
LARGE_INTEGER CCMPDecryptErrors;
LARGE_INTEGER FourWayHandshakeFailures;
};
typedef unsigned long NDIS_802_11_KEY_INDEX;
typedef unsigned long long NDIS_802_11_KEY_RSC;
#define MAX_RADIUS_SRV_NUM 2 /* 802.1x failover number */
struct PACKED rt_radius_srv_info {
u32 radius_ip;
u32 radius_port;
u8 radius_key[64];
u8 radius_key_len;
};
struct PACKED rt_radius_key_info {
u8 radius_srv_num;
struct rt_radius_srv_info radius_srv_info[MAX_RADIUS_SRV_NUM];
u8 ieee8021xWEP; /* dynamic WEP */
u8 key_index;
u8 key_length; /* length of key in bytes */
u8 key_material[13];
};
/* It's used by 802.1x daemon to require relative configuration */
struct PACKED rt_radius_conf {
u32 Length; /* Length of this structure */
u8 mbss_num; /* indicate multiple BSS number */
u32 own_ip_addr;
u32 retry_interval;
u32 session_timeout_interval;
u8 EAPifname[8][IFNAMSIZ];
u8 EAPifname_len[8];
u8 PreAuthifname[8][IFNAMSIZ];
u8 PreAuthifname_len[8];
struct rt_radius_key_info RadiusInfo[8];
};
/* Key mapping keys require a BSSID */
struct rt_ndis_802_11_key {
u32 Length; /* Length of this structure */
u32 KeyIndex;
u32 KeyLength; /* length of key in bytes */
NDIS_802_11_MAC_ADDRESS BSSID;
NDIS_802_11_KEY_RSC KeyRSC;
u8 KeyMaterial[1]; /* variable length depending on above field */
};
struct rt_ndis_802_11_passphrase {
u32 KeyLength; /* length of key in bytes */
NDIS_802_11_MAC_ADDRESS BSSID;
u8 KeyMaterial[1]; /* variable length depending on above field */
};
struct rt_ndis_802_11_remove_key {
u32 Length; /* Length of this structure */
u32 KeyIndex;
NDIS_802_11_MAC_ADDRESS BSSID;
};
struct rt_ndis_802_11_wep {
u32 Length; /* Length of this structure */
u32 KeyIndex; /* 0 is the per-client key, 1-N are the */
/* global keys */
u32 KeyLength; /* length of key in bytes */
u8 KeyMaterial[1]; /* variable length depending on above field */
};
typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE {
Ndis802_11IBSS,
Ndis802_11Infrastructure,
Ndis802_11AutoUnknown,
Ndis802_11Monitor,
Ndis802_11InfrastructureMax /* Not a real value, defined as upper bound */
} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
/* Add new authentication modes */
typedef enum _NDIS_802_11_AUTHENTICATION_MODE {
Ndis802_11AuthModeOpen,
Ndis802_11AuthModeShared,
Ndis802_11AuthModeAutoSwitch,
Ndis802_11AuthModeWPA,
Ndis802_11AuthModeWPAPSK,
Ndis802_11AuthModeWPANone,
Ndis802_11AuthModeWPA2,
Ndis802_11AuthModeWPA2PSK,
Ndis802_11AuthModeWPA1WPA2,
Ndis802_11AuthModeWPA1PSKWPA2PSK,
Ndis802_11AuthModeMax /* Not a real mode, defined as upper bound */
} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
typedef u8 NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; /* Set of 8 data rates */
typedef u8 NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; /* Set of 16 data rates */
struct PACKED rt_ndis_802_11_ssid {
u32 SsidLength; /* length of SSID field below, in bytes; */
/* this can be zero. */
u8 Ssid[NDIS_802_11_LENGTH_SSID]; /* SSID information field */
};
struct PACKED rt_ndis_wlan_bssid {
unsigned long Length; /* Length of this structure */
NDIS_802_11_MAC_ADDRESS MacAddress; /* BSSID */
u8 Reserved[2];
struct rt_ndis_802_11_ssid Ssid; /* SSID */
unsigned long Privacy; /* WEP encryption requirement */
NDIS_802_11_RSSI Rssi; /* receive signal strength in dBm */
NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
struct rt_ndis_802_11_configuration Configuration;
NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
NDIS_802_11_RATES SupportedRates;
};
struct PACKED rt_ndis_802_11_bssid_list {
u32 NumberOfItems; /* in list below, at least 1 */
struct rt_ndis_wlan_bssid Bssid[1];
};
/* Added Capabilities, IELength and IEs for each BSSID */
struct PACKED rt_ndis_wlan_bssid_ex {
unsigned long Length; /* Length of this structure */
NDIS_802_11_MAC_ADDRESS MacAddress; /* BSSID */
u8 Reserved[2];
struct rt_ndis_802_11_ssid Ssid; /* SSID */
u32 Privacy; /* WEP encryption requirement */
NDIS_802_11_RSSI Rssi; /* receive signal */
/* strength in dBm */
NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
struct rt_ndis_802_11_configuration Configuration;
NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
NDIS_802_11_RATES_EX SupportedRates;
unsigned long IELength;
u8 IEs[1];
};
struct PACKED rt_ndis_802_11_bssid_list_ex {
u32 NumberOfItems; /* in list below, at least 1 */
struct rt_ndis_wlan_bssid_ex Bssid[1];
};
struct PACKED rt_ndis_802_11_fixed_ies {
u8 Timestamp[8];
u16 BeaconInterval;
u16 Capabilities;
};
struct rt_ndis_802_11_variable_ies {
u8 ElementID;
u8 Length; /* Number of bytes in data field */
u8 data[1];
};
typedef unsigned long NDIS_802_11_FRAGMENTATION_THRESHOLD;
typedef unsigned long NDIS_802_11_RTS_THRESHOLD;
typedef unsigned long NDIS_802_11_ANTENNA;
typedef enum _NDIS_802_11_PRIVACY_FILTER {
Ndis802_11PrivFilterAcceptAll,
Ndis802_11PrivFilter8021xWEP
} NDIS_802_11_PRIVACY_FILTER, *PNDIS_802_11_PRIVACY_FILTER;
/* Added new encryption types */
/* Also aliased typedef to new name */
typedef enum _NDIS_802_11_WEP_STATUS {
Ndis802_11WEPEnabled,
Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
Ndis802_11WEPDisabled,
Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
Ndis802_11WEPKeyAbsent,
Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
Ndis802_11WEPNotSupported,
Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
Ndis802_11Encryption2Enabled,
Ndis802_11Encryption2KeyAbsent,
Ndis802_11Encryption3Enabled,
Ndis802_11Encryption3KeyAbsent,
Ndis802_11Encryption4Enabled, /* TKIP or AES mix */
Ndis802_11Encryption4KeyAbsent,
Ndis802_11GroupWEP40Enabled,
Ndis802_11GroupWEP104Enabled,
} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
typedef enum _NDIS_802_11_RELOAD_DEFAULTS {
Ndis802_11ReloadWEPKeys
} NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
#define NDIS_802_11_AI_REQFI_CAPABILITIES 1
#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2
#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4
#define NDIS_802_11_AI_RESFI_CAPABILITIES 1
#define NDIS_802_11_AI_RESFI_STATUSCODE 2
#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4
struct rt_ndis_802_11_ai_reqfi {
u16 Capabilities;
u16 ListenInterval;
NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
};
struct rt_ndis_802_11_ai_resfi {
u16 Capabilities;
u16 StatusCode;
u16 AssociationId;
};
struct rt_ndis_802_11_association_information {
unsigned long Length;
u16 AvailableRequestFixedIEs;
struct rt_ndis_802_11_ai_reqfi RequestFixedIEs;
unsigned long RequestIELength;
unsigned long OffsetRequestIEs;
u16 AvailableResponseFixedIEs;
struct rt_ndis_802_11_ai_resfi ResponseFixedIEs;
unsigned long ResponseIELength;
unsigned long OffsetResponseIEs;
};
struct rt_ndis_802_11_authentication_event {
struct rt_ndis_802_11_status_indication Status;
struct rt_ndis_802_11_authentication_request Request[1];
};
/* 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE */
typedef enum _NDIS_802_11_MEDIA_STREAM_MODE {
Ndis802_11MediaStreamOff,
Ndis802_11MediaStreamOn,
} NDIS_802_11_MEDIA_STREAM_MODE, *PNDIS_802_11_MEDIA_STREAM_MODE;
/* PMKID Structures */
typedef u8 NDIS_802_11_PMKID_VALUE[16];
struct rt_bssid_info {
NDIS_802_11_MAC_ADDRESS BSSID;
NDIS_802_11_PMKID_VALUE PMKID;
};
struct rt_ndis_802_11_pmkid {
u32 Length;
u32 BSSIDInfoCount;
struct rt_bssid_info BSSIDInfo[1];
};
struct rt_ndis_802_11_authentication_encryption {
NDIS_802_11_AUTHENTICATION_MODE AuthModeSupported;
NDIS_802_11_ENCRYPTION_STATUS EncryptStatusSupported;
};
struct rt_ndis_802_11_capability {
unsigned long Length;
unsigned long Version;
unsigned long NoOfPMKIDs;
unsigned long NoOfAuthEncryptPairsSupported;
struct rt_ndis_802_11_authentication_encryption
AuthenticationEncryptionSupported[1];
};
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x01) /* Sync. with AP for wsc upnp daemon */
#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
#define RTPRIV_IOCTL_STATISTICS (SIOCIWFIRSTPRIV + 0x09)
#define RTPRIV_IOCTL_ADD_PMKID_CACHE (SIOCIWFIRSTPRIV + 0x0A)
#define RTPRIV_IOCTL_RADIUS_DATA (SIOCIWFIRSTPRIV + 0x0C)
#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
#define RT_PRIV_IOCTL_EXT (SIOCIWFIRSTPRIV + 0x0E) /* Sync. with RT61 (for wpa_supplicant) */
#define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F)
#define RTPRIV_IOCTL_SHOW (SIOCIWFIRSTPRIV + 0x11)
enum {
SHOW_CONN_STATUS = 4,
SHOW_DRVIER_VERION = 5,
SHOW_BA_INFO = 6,
SHOW_DESC_INFO = 7,
#ifdef RTMP_MAC_USB
SHOW_RXBULK_INFO = 8,
SHOW_TXBULK_INFO = 9,
#endif /* RTMP_MAC_USB // */
RAIO_OFF = 10,
RAIO_ON = 11,
SHOW_CFG_VALUE = 20,
SHOW_ADHOC_ENTRY_INFO = 21,
};
#define OID_802_11_BUILD_CHANNEL_EX 0x0714
#define OID_802_11_GET_CH_LIST 0x0715
#define OID_802_11_GET_COUNTRY_CODE 0x0716
#define OID_802_11_GET_CHANNEL_GEOGRAPHY 0x0717
#define RT_OID_WSC_SET_PASSPHRASE 0x0740 /* passphrase for wpa(2)-psk */
#define RT_OID_WSC_DRIVER_AUTO_CONNECT 0x0741
#define RT_OID_WSC_QUERY_DEFAULT_PROFILE 0x0742
#define RT_OID_WSC_SET_CONN_BY_PROFILE_INDEX 0x0743
#define RT_OID_WSC_SET_ACTION 0x0744
#define RT_OID_WSC_SET_SSID 0x0745
#define RT_OID_WSC_SET_PIN_CODE 0x0746
#define RT_OID_WSC_SET_MODE 0x0747 /* PIN or PBC */
#define RT_OID_WSC_SET_CONF_MODE 0x0748 /* Enrollee or Registrar */
#define RT_OID_WSC_SET_PROFILE 0x0749
#define RT_OID_WSC_CONFIG_STATUS 0x074F
#define RT_OID_802_11_WSC_QUERY_PROFILE 0x0750
/* for consistency with RT61 */
#define RT_OID_WSC_QUERY_STATUS 0x0751
#define RT_OID_WSC_PIN_CODE 0x0752
#define RT_OID_WSC_UUID 0x0753
#define RT_OID_WSC_SET_SELECTED_REGISTRAR 0x0754
#define RT_OID_WSC_EAPMSG 0x0755
#define RT_OID_WSC_MANUFACTURER 0x0756
#define RT_OID_WSC_MODEL_NAME 0x0757
#define RT_OID_WSC_MODEL_NO 0x0758
#define RT_OID_WSC_SERIAL_NO 0x0759
#define RT_OID_WSC_MAC_ADDRESS 0x0760
/* New for MeetingHouse Api support */
#define OID_MH_802_1X_SUPPORTED 0xFFEDC100
/* MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition! */
typedef union _HTTRANSMIT_SETTING {
struct {
u16 MCS:7; /* MCS */
u16 BW:1; /*channel bandwidth 20MHz or 40 MHz */
u16 ShortGI:1;
u16 STBC:2; /*SPACE */
/* u16 rsv:3; */
u16 rsv:2;
u16 TxBF:1;
u16 MODE:2; /* Use definition MODE_xxx. */
} field;
u16 word;
} HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
typedef enum _RT_802_11_PREAMBLE {
Rt802_11PreambleLong,
Rt802_11PreambleShort,
Rt802_11PreambleAuto
} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
typedef enum _RT_802_11_PHY_MODE {
PHY_11BG_MIXED = 0,
PHY_11B,
PHY_11A,
PHY_11ABG_MIXED,
PHY_11G,
PHY_11ABGN_MIXED, /* both band 5 */
PHY_11N_2_4G, /* 11n-only with 2.4G band 6 */
PHY_11GN_MIXED, /* 2.4G band 7 */
PHY_11AN_MIXED, /* 5G band 8 */
PHY_11BGN_MIXED, /* if check 802.11b. 9 */
PHY_11AGN_MIXED, /* if check 802.11b. 10 */
PHY_11N_5G, /* 11n-only with 5G band 11 */
} RT_802_11_PHY_MODE;
/* put all proprietery for-query objects here to reduce # of Query_OID */
struct rt_802_11_link_status {
unsigned long CurrTxRate; /* in units of 0.5Mbps */
unsigned long ChannelQuality; /* 0..100 % */
unsigned long TxByteCount; /* both ok and fail */
unsigned long RxByteCount; /* both ok and fail */
unsigned long CentralChannel; /* 40MHz central channel number */
};
struct rt_802_11_event_log {
LARGE_INTEGER SystemTime; /* timestammp via NdisGetCurrentSystemTime() */
u8 Addr[MAC_ADDR_LENGTH];
u16 Event; /* EVENT_xxx */
};
struct rt_802_11_event_table {
unsigned long Num;
unsigned long Rsv; /* to align Log[] at LARGE_INTEGER boundary */
struct rt_802_11_event_log Log[MAX_NUMBER_OF_EVENT];
};
/* MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition! */
typedef union _MACHTTRANSMIT_SETTING {
struct {
u16 MCS:7; /* MCS */
u16 BW:1; /*channel bandwidth 20MHz or 40 MHz */
u16 ShortGI:1;
u16 STBC:2; /*SPACE */
u16 rsv:3;
u16 MODE:2; /* Use definition MODE_xxx. */
} field;
u16 word;
} MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
struct rt_802_11_mac_entry {
u8 Addr[MAC_ADDR_LENGTH];
u8 Aid;
u8 Psm; /* 0:PWR_ACTIVE, 1:PWR_SAVE */
u8 MimoPs; /* 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled */
char AvgRssi0;
char AvgRssi1;
char AvgRssi2;
u32 ConnectedTime;
MACHTTRANSMIT_SETTING TxRate;
};
struct rt_802_11_mac_table {
unsigned long Num;
struct rt_802_11_mac_entry Entry[MAX_NUMBER_OF_MAC];
};
/* structure for query/set hardware register - MAC, BBP, RF register */
struct rt_802_11_hardware_register {
unsigned long HardwareType; /* 0:MAC, 1:BBP, 2:RF register, 3:EEPROM */
unsigned long Offset; /* Q/S register offset addr */
unsigned long Data; /* R/W data buffer */
};
struct rt_802_11_ap_config {
unsigned long EnableTxBurst; /* 0-disable, 1-enable */
unsigned long EnableTurboRate; /* 0-disable, 1-enable 72/100mbps turbo rate */
unsigned long IsolateInterStaTraffic; /* 0-disable, 1-enable isolation */
unsigned long HideSsid; /* 0-disable, 1-enable hiding */
unsigned long UseBGProtection; /* 0-AUTO, 1-always ON, 2-always OFF */
unsigned long UseShortSlotTime; /* 0-no use, 1-use 9-us short slot time */
unsigned long Rsv1; /* must be 0 */
unsigned long SystemErrorBitmap; /* ignore upon SET, return system error upon QUERY */
};
/* structure to query/set STA_CONFIG */
struct rt_802_11_sta_config {
unsigned long EnableTxBurst; /* 0-disable, 1-enable */
unsigned long EnableTurboRate; /* 0-disable, 1-enable 72/100mbps turbo rate */
unsigned long UseBGProtection; /* 0-AUTO, 1-always ON, 2-always OFF */
unsigned long UseShortSlotTime; /* 0-no use, 1-use 9-us short slot time when applicable */
unsigned long AdhocMode; /* 0-11b rates only (WIFI spec), 1 - b/g mixed, 2 - g only */
unsigned long HwRadioStatus; /* 0-OFF, 1-ON, default is 1, Read-Only */
unsigned long Rsv1; /* must be 0 */
unsigned long SystemErrorBitmap; /* ignore upon SET, return system error upon QUERY */
};
/* */
/* For OID Query or Set about BA structure */
/* */
struct rt_oid_bacap {
u8 RxBAWinLimit;
u8 TxBAWinLimit;
u8 Policy; /* 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid */
u8 MpduDensity; /* 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid */
u8 AmsduEnable; /*Enable AMSDU transmisstion */
u8 AmsduSize; /* 0:3839, 1:7935 bytes. u32 MSDUSizeToBytes[] = { 3839, 7935}; */
u8 MMPSmode; /* MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable */
BOOLEAN AutoBA; /* Auto BA will automatically */
};
struct rt_802_11_acl_entry {
u8 Addr[MAC_ADDR_LENGTH];
u16 Rsv;
};
struct PACKED rt_rt_802_11_acl {
unsigned long Policy; /* 0-disable, 1-positive list, 2-negative list */
unsigned long Num;
struct rt_802_11_acl_entry Entry[MAX_NUMBER_OF_ACL];
};
struct rt_802_11_wds {
unsigned long Num;
NDIS_802_11_MAC_ADDRESS Entry[24 /*MAX_NUM_OF_WDS_LINK */];
unsigned long KeyLength;
u8 KeyMaterial[32];
};
struct rt_802_11_tx_rates {
u8 SupRateLen;
u8 SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
u8 ExtRateLen;
u8 ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
};
/* Definition of extra information code */
#define GENERAL_LINK_UP 0x0 /* Link is Up */
#define GENERAL_LINK_DOWN 0x1 /* Link is Down */
#define HW_RADIO_OFF 0x2 /* Hardware radio off */
#define SW_RADIO_OFF 0x3 /* Software radio off */
#define AUTH_FAIL 0x4 /* Open authentication fail */
#define AUTH_FAIL_KEYS 0x5 /* Shared authentication fail */
#define ASSOC_FAIL 0x6 /* Association failed */
#define EAP_MIC_FAILURE 0x7 /* Deauthentication because MIC failure */
#define EAP_4WAY_TIMEOUT 0x8 /* Deauthentication on 4-way handshake timeout */
#define EAP_GROUP_KEY_TIMEOUT 0x9 /* Deauthentication on group key handshake timeout */
#define EAP_SUCCESS 0xa /* EAP succeed */
#define DETECT_RADAR_SIGNAL 0xb /* Radar signal occur in current channel */
#define EXTRA_INFO_MAX 0xb /* Indicate Last OID */
#define EXTRA_INFO_CLEAR 0xffffffff
/* This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use. */
struct rt_oid_set_ht_phymode {
RT_802_11_PHY_MODE PhyMode; /* */
u8 TransmitNo;
u8 HtMode; /*HTMODE_GF or HTMODE_MM */
u8 ExtOffset; /*extension channel above or below */
u8 MCS;
u8 BW;
u8 STBC;
u8 SHORTGI;
u8 rsv;
};
#define MAX_CUSTOM_LEN 128
typedef enum _RT_802_11_D_CLIENT_MODE {
Rt802_11_D_None,
Rt802_11_D_Flexible,
Rt802_11_D_Strict,
} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
struct rt_channel_list_info {
u8 ChannelList[MAX_NUM_OF_CHS]; /* list all supported channels for site survey */
u8 ChannelListNum; /* number of channel in ChannelList[] */
};
/* WSC configured credential */
struct rt_wsc_credential {
struct rt_ndis_802_11_ssid SSID; /* mandatory */
u16 AuthType; /* mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk */
u16 EncrType; /* mandatory, 1: none, 2: wep, 4: tkip, 8: aes */
u8 Key[64]; /* mandatory, Maximum 64 byte */
u16 KeyLength;
u8 MacAddr[6]; /* mandatory, AP MAC address */
u8 KeyIndex; /* optional, default is 1 */
u8 Rsvd[3]; /* Make alignment */
};
/* WSC configured profiles */
struct rt_wsc_profile {
u32 ProfileCnt;
u32 ApplyProfileIdx; /* add by johnli, fix WPS test plan 5.1.1 */
struct rt_wsc_credential Profile[8]; /* Support up to 8 profiles */
};
#endif /* _OID_H_ */

File diff suppressed because it is too large Load diff

View file

@ -1,71 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_config.h
Abstract:
Central header file to maintain all include files for all NDIS
miniport driver routines.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Lin 08-01-2002 created
*/
#ifndef __RT_CONFIG_H__
#define __RT_CONFIG_H__
#include "rtmp_type.h"
#include "rtmp_os.h"
#include "rtmp_def.h"
#include "rtmp_chip.h"
#include "rtmp_timer.h"
#include "oid.h"
#include "mlme.h"
#include "wpa.h"
#include "crypt_md5.h"
#include "crypt_sha2.h"
#include "crypt_hmac.h"
#include "rtmp.h"
#include "ap.h"
#include "dfs.h"
#include "chlist.h"
#include "spectrum.h"
#include "eeprom.h"
#if defined(RTMP_PCI_SUPPORT) || defined(RTMP_USB_SUPPORT)
#include "rtmp_mcu.h"
#endif
#ifdef IGMP_SNOOP_SUPPORT
#include "igmp_snoop.h"
#endif /* IGMP_SNOOP_SUPPORT // */
#endif /* __RT_CONFIG_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,835 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_linux.h
Abstract:
Revision History:
Who When What
Justin P. Mattock 11/07/2010 Fix typo in a comment
--------- ---------- ----------------------------------------------
*/
#ifndef __RT_LINUX_H__
#define __RT_LINUX_H__
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.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/vmalloc.h>
#include <net/iw_handler.h>
/* load firmware */
#define __KERNEL_SYSCALLS__
#include <linux/unistd.h>
#include <asm/uaccess.h>
#include <asm/types.h>
#include <asm/unaligned.h> /* for get_unaligned() */
#define KTHREAD_SUPPORT 1
/* RT2870 2.1.0.0 has it disabled */
#ifdef KTHREAD_SUPPORT
#include <linux/err.h>
#include <linux/kthread.h>
#endif /* KTHREAD_SUPPORT // */
/***********************************************************************************
* Profile related sections
***********************************************************************************/
#ifdef RTMP_MAC_PCI
#define STA_DRIVER_VERSION "2.1.0.0"
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
#define STA_DRIVER_VERSION "2.1.0.0"
/* RT3070 version: 2.1.1.0 */
#endif /* RTMP_MAC_USB // */
extern const struct iw_handler_def rt28xx_iw_handler_def;
/***********************************************************************************
* Compiler related definitions
***********************************************************************************/
#undef __inline
#define __inline static inline
#define IN
#define OUT
#define INOUT
/***********************************************************************************
* OS Specific definitions and data structures
***********************************************************************************/
typedef int (*HARD_START_XMIT_FUNC) (struct sk_buff *skb,
struct net_device *net_dev);
#ifdef RTMP_MAC_PCI
#ifndef PCI_DEVICE
#define PCI_DEVICE(vend,dev) \
.vendor = (vend), .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
#endif /* PCI_DEVICE // */
#endif /* RTMP_MAC_PCI // */
#define RT_MOD_INC_USE_COUNT() \
if (!try_module_get(THIS_MODULE)) \
{ \
DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
return -1; \
}
#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
#define RTMP_INC_REF(_A) 0
#define RTMP_DEC_REF(_A) 0
#define RTMP_GET_REF(_A) 0
/* This function will be called when query /proc */
struct iw_statistics *rt28xx_get_wireless_stats(IN struct net_device *net_dev);
/***********************************************************************************
* Network related constant definitions
***********************************************************************************/
#ifndef IFNAMSIZ
#define IFNAMSIZ 16
#endif
#define ETH_LENGTH_OF_ADDRESS 6
#define NDIS_STATUS_SUCCESS 0x00
#define NDIS_STATUS_FAILURE 0x01
#define NDIS_STATUS_INVALID_DATA 0x02
#define NDIS_STATUS_RESOURCES 0x03
#define NDIS_SET_PACKET_STATUS(_p, _status) do{} while(0)
#define NdisWriteErrorLogEntry(_a, _b, _c, _d) do{} while(0)
/* statistics counter */
#define STATS_INC_RX_PACKETS(_pAd, _dev)
#define STATS_INC_TX_PACKETS(_pAd, _dev)
#define STATS_INC_RX_BYTESS(_pAd, _dev, len)
#define STATS_INC_TX_BYTESS(_pAd, _dev, len)
#define STATS_INC_RX_ERRORS(_pAd, _dev)
#define STATS_INC_TX_ERRORS(_pAd, _dev)
#define STATS_INC_RX_DROPPED(_pAd, _dev)
#define STATS_INC_TX_DROPPED(_pAd, _dev)
/***********************************************************************************
* Ralink Specific network related constant definitions
***********************************************************************************/
#define MIN_NET_DEVICE_FOR_AID 0x00 /*0x00~0x3f */
#define MIN_NET_DEVICE_FOR_MBSSID 0x00 /*0x00,0x10,0x20,0x30 */
#define MIN_NET_DEVICE_FOR_WDS 0x10 /*0x40,0x50,0x60,0x70 */
#define MIN_NET_DEVICE_FOR_APCLI 0x20
#define MIN_NET_DEVICE_FOR_MESH 0x30
#define MIN_NET_DEVICE_FOR_DLS 0x40
#define NET_DEVICE_REAL_IDX_MASK 0x0f /* for each operation mode, we maximum support 15 entities. */
#define NDIS_PACKET_TYPE_DIRECTED 0
#define NDIS_PACKET_TYPE_MULTICAST 1
#define NDIS_PACKET_TYPE_BROADCAST 2
#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
#define NDIS_PACKET_TYPE_PROMISCUOUS 4
/***********************************************************************************
* OS signaling related constant definitions
***********************************************************************************/
/***********************************************************************************
* OS file operation related data structure definitions
***********************************************************************************/
struct rt_rtmp_os_fs_info {
int fsuid;
int fsgid;
mm_segment_t fs;
};
#define IS_FILE_OPEN_ERR(_fd) IS_ERR((_fd))
/***********************************************************************************
* OS semaphore related data structure and definitions
***********************************************************************************/
struct os_lock {
spinlock_t lock;
unsigned long flags;
};
/* */
/* spin_lock enhanced for Nested spin lock */
/* */
#define NdisAllocateSpinLock(__lock) \
{ \
spin_lock_init((spinlock_t *)(__lock)); \
}
#define NdisFreeSpinLock(lock) \
do{}while(0)
#define RTMP_SEM_LOCK(__lock) \
{ \
spin_lock_bh((spinlock_t *)(__lock)); \
}
#define RTMP_SEM_UNLOCK(__lock) \
{ \
spin_unlock_bh((spinlock_t *)(__lock)); \
}
/* sample, use semaphore lock to replace IRQ lock, 2007/11/15 */
#define RTMP_IRQ_LOCK(__lock, __irqflags) \
{ \
__irqflags = 0; \
spin_lock_bh((spinlock_t *)(__lock)); \
pAd->irq_disabled |= 1; \
}
#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
{ \
pAd->irq_disabled &= 0; \
spin_unlock_bh((spinlock_t *)(__lock)); \
}
#define RTMP_INT_LOCK(__lock, __irqflags) \
{ \
spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
}
#define RTMP_INT_UNLOCK(__lock, __irqflag) \
{ \
spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
}
#define NdisAcquireSpinLock RTMP_SEM_LOCK
#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
#ifndef wait_event_interruptible_timeout
#define __wait_event_interruptible_timeout(wq, condition, ret) \
do { \
wait_queue_t __wait; \
init_waitqueue_entry(&__wait, current); \
add_wait_queue(&wq, &__wait); \
for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \
if (condition) \
break; \
if (!signal_pending(current)) { \
ret = schedule_timeout(ret); \
if (!ret) \
break; \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
current->state = TASK_RUNNING; \
remove_wait_queue(&wq, &__wait); \
} while (0)
#define wait_event_interruptible_timeout(wq, condition, timeout) \
({ \
long __ret = timeout; \
if (!(condition)) \
__wait_event_interruptible_timeout(wq, condition, __ret); \
__ret; \
})
#endif
#define RTMP_SEM_EVENT_INIT_LOCKED(_pSema) sema_init((_pSema), 0)
#define RTMP_SEM_EVENT_INIT(_pSema) sema_init((_pSema), 1)
#define RTMP_SEM_EVENT_WAIT(_pSema, _status) ((_status) = down_interruptible((_pSema)))
#define RTMP_SEM_EVENT_UP(_pSema) up(_pSema)
#ifdef KTHREAD_SUPPORT
#define RTMP_WAIT_EVENT_INTERRUPTIBLE(_pAd, _pTask) \
{ \
wait_event_interruptible(_pTask->kthread_q, \
_pTask->kthread_running || kthread_should_stop()); \
_pTask->kthread_running = FALSE; \
if (kthread_should_stop()) \
{ \
RTMP_SET_FLAG(_pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); \
break; \
} \
}
#endif
#ifdef KTHREAD_SUPPORT
#define WAKE_UP(_pTask) \
do{ \
if ((_pTask)->kthread_task) \
{ \
(_pTask)->kthread_running = TRUE; \
wake_up(&(_pTask)->kthread_q); \
} \
}while(0)
#endif
/***********************************************************************************
* OS Memory Access related data structure and definitions
***********************************************************************************/
#define MEM_ALLOC_FLAG (GFP_ATOMIC) /*(GFP_DMA | GFP_ATOMIC) */
#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
#define NdisCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
#define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
#define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
#define NdisCmpMemory(Destination, Source, Length) memcmp(Destination, Source, Length)
#define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
#define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
#define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
/***********************************************************************************
* OS task related data structure and definitions
***********************************************************************************/
#define RTMP_OS_MGMT_TASK_FLAGS CLONE_VM
#define THREAD_PID_INIT_VALUE NULL
#define GET_PID(_v) find_get_pid((_v))
#define GET_PID_NUMBER(_v) pid_nr((_v))
#define CHECK_PID_LEGALITY(_pid) if (pid_nr((_pid)) > 0)
#define KILL_THREAD_PID(_A, _B, _C) kill_pid((_A), (_B), (_C))
/***********************************************************************************
* Timer related definitions and data structures.
**********************************************************************************/
#define OS_HZ HZ
typedef void (*TIMER_FUNCTION) (unsigned long);
#define OS_WAIT(_time) \
{ int _i; \
long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
wait_queue_head_t _wait; \
init_waitqueue_head(&_wait); \
for (_i=0; _i<(_loop); _i++) \
wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
#define RTMP_TIME_AFTER(a,b) \
(typecheck(unsigned long, (unsigned long)a) && \
typecheck(unsigned long, (unsigned long)b) && \
((long)(b) - (long)(a) < 0))
#define RTMP_TIME_AFTER_EQ(a,b) \
(typecheck(unsigned long, (unsigned long)a) && \
typecheck(unsigned long, (unsigned long)b) && \
((long)(a) - (long)(b) >= 0))
#define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
#define ONE_TICK 1
static inline void NdisGetSystemUpTime(unsigned long *time)
{
*time = jiffies;
}
/***********************************************************************************
* OS specific cookie data structure binding to struct rt_rtmp_adapter
***********************************************************************************/
struct os_cookie {
#ifdef RTMP_MAC_PCI
struct pci_dev *pci_dev;
struct pci_dev *parent_pci_dev;
u16 DeviceID;
dma_addr_t pAd_pa;
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
struct usb_device *pUsb_Dev;
#endif /* RTMP_MAC_USB // */
struct tasklet_struct rx_done_task;
struct tasklet_struct mgmt_dma_done_task;
struct tasklet_struct ac0_dma_done_task;
struct tasklet_struct ac1_dma_done_task;
struct tasklet_struct ac2_dma_done_task;
struct tasklet_struct ac3_dma_done_task;
struct tasklet_struct tbtt_task;
#ifdef RTMP_MAC_PCI
struct tasklet_struct fifo_statistic_full_task;
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
struct tasklet_struct null_frame_complete_task;
struct tasklet_struct rts_frame_complete_task;
struct tasklet_struct pspoll_frame_complete_task;
#endif /* RTMP_MAC_USB // */
unsigned long apd_pid; /*802.1x daemon pid */
int ioctl_if_type;
int ioctl_if;
};
/***********************************************************************************
* OS debugging and printing related definitions and data structure
***********************************************************************************/
#ifdef DBG
extern unsigned long RTDebugLevel;
#define DBGPRINT_RAW(Level, Fmt) \
do{ \
if (Level <= RTDebugLevel) \
{ \
printk Fmt; \
} \
}while(0)
#define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
#define DBGPRINT_ERR(fmt, args...) printk(KERN_ERR fmt, ##args)
#define DBGPRINT_S(Status, Fmt) \
{ \
printk Fmt; \
}
#else
#define DBGPRINT(Level, Fmt)
#define DBGPRINT_RAW(Level, Fmt)
#define DBGPRINT_S(Status, Fmt)
#define DBGPRINT_ERR(Fmt)
#endif
#define ASSERT(x)
void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
/*********************************************************************************************************
The following code are not revised, temporary put it here.
*********************************************************************************************************/
/***********************************************************************************
* Device DMA Access related definitions and data structures.
**********************************************************************************/
#ifdef RTMP_MAC_PCI
struct rt_rtmp_adapter;
dma_addr_t linux_pci_map_single(struct rt_rtmp_adapter *pAd, void *ptr,
size_t size, int sd_idx, int direction);
void linux_pci_unmap_single(struct rt_rtmp_adapter *pAd, dma_addr_t dma_addr,
size_t size, int direction);
#define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \
linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir)
#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) \
linux_pci_unmap_single(_handle, _ptr, _size, _dir)
#define PCI_ALLOC_CONSISTENT(_pci_dev, _size, _ptr) \
pci_alloc_consistent(_pci_dev, _size, _ptr)
#define PCI_FREE_CONSISTENT(_pci_dev, _size, _virtual_addr, _physical_addr) \
pci_free_consistent(_pci_dev, _size, _virtual_addr, _physical_addr)
#define DEV_ALLOC_SKB(_length) \
dev_alloc_skb(_length)
#endif /* RTMP_MAC_PCI // */
/*
* unsigned long
* RTMP_GetPhysicalAddressLow(
* dma_addr_t PhysicalAddress);
*/
#define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
/*
* unsigned long
* RTMP_GetPhysicalAddressHigh(
* dma_addr_t PhysicalAddress);
*/
#define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
/*
* void
* RTMP_SetPhysicalAddressLow(
* dma_addr_t PhysicalAddress,
* unsigned long Value);
*/
#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
PhysicalAddress = Value;
/*
* void
* RTMP_SetPhysicalAddressHigh(
* dma_addr_t PhysicalAddress,
* unsigned long Value);
*/
#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
#define NdisMIndicateStatus(_w, _x, _y, _z)
/***********************************************************************************
* Device Register I/O Access related definitions and data structures.
**********************************************************************************/
#ifdef RTMP_MAC_PCI
/*Patch for ASIC turst read/write bug, needs to remove after metel fix */
#define RTMP_IO_READ32(_A, _R, _pV) \
{ \
if ((_A)->bPCIclkOff == FALSE) \
{ \
(*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
(*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \
} \
else \
*_pV = 0; \
}
#define RTMP_IO_FORCE_READ32(_A, _R, _pV) \
{ \
(*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
(*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \
}
#define RTMP_IO_READ8(_A, _R, _pV) \
{ \
(*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
(*_pV = readb((void *)((_A)->CSRBaseAddress + (_R)))); \
}
#define RTMP_IO_WRITE32(_A, _R, _V) \
{ \
if ((_A)->bPCIclkOff == FALSE) \
{ \
u32 Val; \
Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
writel((_V), (void *)((_A)->CSRBaseAddress + (_R))); \
} \
}
#define RTMP_IO_FORCE_WRITE32(_A, _R, _V) \
{ \
u32 Val; \
Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
writel(_V, (void *)((_A)->CSRBaseAddress + (_R))); \
}
#if defined(RALINK_2880) || defined(RALINK_3052)
#define RTMP_IO_WRITE8(_A, _R, _V) \
{ \
unsigned long Val; \
u8 _i; \
_i = ((_R) & 0x3); \
Val = readl((void *)((_A)->CSRBaseAddress + ((_R) - _i))); \
Val = Val & (~(0x000000ff << ((_i)*8))); \
Val = Val | ((unsigned long)(_V) << ((_i)*8)); \
writel((Val), (void *)((_A)->CSRBaseAddress + ((_R) - _i))); \
}
#else
#define RTMP_IO_WRITE8(_A, _R, _V) \
{ \
u32 Val; \
Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
writeb((_V), (u8 *)((_A)->CSRBaseAddress + (_R))); \
}
#endif /* #if defined(BRCM_6358) || defined(RALINK_2880) // */
#define RTMP_IO_WRITE16(_A, _R, _V) \
{ \
u32 Val; \
Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
writew((_V), (u16 *)((_A)->CSRBaseAddress + (_R))); \
}
#endif /* RTMP_MAC_PCI // */
#ifdef RTMP_MAC_USB
/*Patch for ASIC turst read/write bug, needs to remove after metel fix */
#define RTMP_IO_READ32(_A, _R, _pV) \
RTUSBReadMACRegister((_A), (_R), (u32 *)(_pV))
#define RTMP_IO_READ8(_A, _R, _pV) \
{ \
}
#define RTMP_IO_WRITE32(_A, _R, _V) \
RTUSBWriteMACRegister((_A), (_R), (u32)(_V))
#define RTMP_IO_WRITE8(_A, _R, _V) \
{ \
u16 _Val = _V; \
RTUSBSingleWrite((_A), (_R), (u16)(_Val)); \
}
#define RTMP_IO_WRITE16(_A, _R, _V) \
{ \
RTUSBSingleWrite((_A), (_R), (u16)(_V)); \
}
#endif /* RTMP_MAC_USB // */
/***********************************************************************************
* Network Related data structure and marco definitions
***********************************************************************************/
#define PKTSRC_NDIS 0x7f
#define PKTSRC_DRIVER 0x0f
#define RTMP_OS_NETDEV_SET_PRIV(_pNetDev, _pPriv) ((_pNetDev)->ml_priv = (_pPriv))
#define RTMP_OS_NETDEV_GET_PRIV(_pNetDev) ((_pNetDev)->ml_priv)
#define RTMP_OS_NETDEV_GET_DEVNAME(_pNetDev) ((_pNetDev)->name)
#define RTMP_OS_NETDEV_GET_PHYADDR(_PNETDEV) ((_PNETDEV)->dev_addr)
#define RTMP_OS_NETDEV_START_QUEUE(_pNetDev) netif_start_queue((_pNetDev))
#define RTMP_OS_NETDEV_STOP_QUEUE(_pNetDev) netif_stop_queue((_pNetDev))
#define RTMP_OS_NETDEV_WAKE_QUEUE(_pNetDev) netif_wake_queue((_pNetDev))
#define RTMP_OS_NETDEV_CARRIER_OFF(_pNetDev) netif_carrier_off((_pNetDev))
#define QUEUE_ENTRY_TO_PACKET(pEntry) \
(void *)(pEntry)
#define PACKET_TO_QUEUE_ENTRY(pPacket) \
(struct rt_queue_entry *)(pPacket)
#define GET_SG_LIST_FROM_PACKET(_p, _sc) \
rt_get_sg_list_from_packet(_p, _sc)
#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
{ \
RTMPFreeNdisPacket(_pAd, _pPacket); \
}
/*
* packet helper
* - convert internal rt packet to os packet or
* os packet to rt packet
*/
#define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
#define OSPKT_TO_RTPKT(_p) ((void *)(_p))
#define GET_OS_PKT_DATAPTR(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->data)
#define SET_OS_PKT_DATAPTR(_pkt, _dataPtr) \
(RTPKT_TO_OSPKT(_pkt)->data) = (_dataPtr)
#define GET_OS_PKT_LEN(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->len)
#define SET_OS_PKT_LEN(_pkt, _len) \
(RTPKT_TO_OSPKT(_pkt)->len) = (_len)
#define GET_OS_PKT_DATATAIL(_pkt) \
(skb_tail_pointer(RTPKT_TO_OSPKT(_pkt))
#define SET_OS_PKT_DATATAIL(_pkt, _start, _len) \
(skb_set_tail_pointer(RTPKT_TO_OSPKT(_pkt), _len))
#define GET_OS_PKT_HEAD(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->head)
#define GET_OS_PKT_END(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->end)
#define GET_OS_PKT_NETDEV(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->dev)
#define SET_OS_PKT_NETDEV(_pkt, _pNetDev) \
(RTPKT_TO_OSPKT(_pkt)->dev) = (_pNetDev)
#define GET_OS_PKT_TYPE(_pkt) \
(RTPKT_TO_OSPKT(_pkt))
#define GET_OS_PKT_NEXT(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->next)
#define OS_PKT_CLONED(_pkt) skb_cloned(RTPKT_TO_OSPKT(_pkt))
#define OS_NTOHS(_Val) \
(ntohs(_Val))
#define OS_HTONS(_Val) \
(htons(_Val))
#define OS_NTOHL(_Val) \
(ntohl(_Val))
#define OS_HTONL(_Val) \
(htonl(_Val))
#define CB_OFF 10
/* User Priority */
#define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
#define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
/* Fragment # */
#define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
#define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
/* 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too. */
/*(this value also as MAC(on-chip WCID) table index) */
/* 0x80~0xff: TX to a WDS link. b0~6: WDS index */
#define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
#define RTMP_GET_PACKET_WCID(_p) ((u8)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
/* 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet */
#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
#define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
/* RTS/CTS-to-self protection method */
#define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
#define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
/* see RTMP_S(G)ET_PACKET_EMACTAB */
/* TX rate index */
#define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
#define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
/* From which Interface */
#define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
#define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
#define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
#define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
#define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
/* */
/* Specific Packet Type definition */
/* */
#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
#define RTMP_PACKET_SPECIFIC_DHCP 0x01
#define RTMP_PACKET_SPECIFIC_EAPOL 0x02
#define RTMP_PACKET_SPECIFIC_IPV4 0x04
#define RTMP_PACKET_SPECIFIC_WAI 0x08
#define RTMP_PACKET_SPECIFIC_VLAN 0x10
#define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
/*Specific */
#define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
/*DHCP */
#define RTMP_SET_PACKET_DHCP(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \
}while(0)
#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
/*EAPOL */
#define RTMP_SET_PACKET_EAPOL(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \
}while(0)
#define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
/*WAI */
#define RTMP_SET_PACKET_WAI(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \
}while(0)
#define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
#define RTMP_GET_PACKET_LOWRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
/*VLAN */
#define RTMP_SET_PACKET_VLAN(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \
}while(0)
#define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
/*LLC/SNAP */
#define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \
}while(0)
#define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
/* IP */
#define RTMP_SET_PACKET_IPV4(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \
}while(0)
#define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
/* If this flag is set, it indicates that this EAPoL frame MUST be clear. */
#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
/* use bit3 of cb[CB_OFF+16] */
#define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
#define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
/* Max skb->cb = 48B = [CB_OFF+38] */
/***********************************************************************************
* Other function prototypes definitions
***********************************************************************************/
void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
int rt28xx_packet_xmit(struct sk_buff *skb);
#ifdef RTMP_MAC_PCI
/* function declarations */
#define IRQ_HANDLE_TYPE irqreturn_t
IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance);
#endif /* RTMP_MAC_PCI // */
int rt28xx_sta_ioctl(struct net_device *net_dev, IN OUT struct ifreq *rq, int cmd);
extern int ra_mtd_write(int num, loff_t to, size_t len, const u_char *buf);
extern int ra_mtd_read(int num, loff_t from, size_t len, u_char *buf);
#define GET_PAD_FROM_NET_DEV(_pAd, _net_dev) (_pAd) = (struct rt_rtmp_adapter *)(_net_dev)->ml_priv;
#endif /* __RT_LINUX_H__ // */

View file

@ -1,736 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_main_dev.c
Abstract:
Create and register network interface.
Revision History:
Who When What
Justin P. Mattock 11/07/2010 Fix typos in comments
-------- ---------- ----------------------------------------------
*/
#include "rt_config.h"
/*---------------------------------------------------------------------*/
/* Private Variables Used */
/*---------------------------------------------------------------------*/
char *mac = ""; /* default 00:00:00:00:00:00 */
char *hostname = ""; /* default CMPC */
module_param(mac, charp, 0);
MODULE_PARM_DESC(mac, "rt28xx: wireless mac addr");
/*---------------------------------------------------------------------*/
/* Prototypes of Functions Used */
/*---------------------------------------------------------------------*/
/* public function prototype */
int rt28xx_close(IN struct net_device *net_dev);
int rt28xx_open(struct net_device *net_dev);
/* private function prototype */
static int rt28xx_send_packets(IN struct sk_buff *skb_p,
IN struct net_device *net_dev);
static struct net_device_stats *RT28xx_get_ether_stats(IN struct net_device
*net_dev);
/*
========================================================================
Routine Description:
Close raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int MainVirtualIF_close(IN struct net_device *net_dev)
{
struct rt_rtmp_adapter *pAd = NULL;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
/* Sanity check for pAd */
if (pAd == NULL)
return 0; /* close ok */
netif_carrier_off(pAd->net_dev);
netif_stop_queue(pAd->net_dev);
{
BOOLEAN Cancelled;
if (INFRA_ON(pAd) &&
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
struct rt_mlme_disassoc_req DisReq;
struct rt_mlme_queue_elem *MsgElem =
kmalloc(sizeof(struct rt_mlme_queue_elem),
MEM_ALLOC_FLAG);
if (MsgElem) {
COPY_MAC_ADDR(DisReq.Addr,
pAd->CommonCfg.Bssid);
DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
MsgElem->Machine = ASSOC_STATE_MACHINE;
MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
MsgElem->MsgLen =
sizeof(struct rt_mlme_disassoc_req);
NdisMoveMemory(MsgElem->Msg, &DisReq,
sizeof
(struct rt_mlme_disassoc_req));
/* Prevent to connect AP again in STAMlmePeriodicExec */
pAd->MlmeAux.AutoReconnectSsidLen = 32;
NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid,
pAd->MlmeAux.
AutoReconnectSsidLen);
pAd->Mlme.CntlMachine.CurrState =
CNTL_WAIT_OID_DISASSOC;
MlmeDisassocReqAction(pAd, MsgElem);
kfree(MsgElem);
}
RTMPusecDelay(1000);
}
RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer,
&Cancelled);
RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer,
&Cancelled);
}
VIRTUAL_IF_DOWN(pAd);
RT_MOD_DEC_USE_COUNT();
return 0; /* close ok */
}
/*
========================================================================
Routine Description:
Open raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int MainVirtualIF_open(IN struct net_device *net_dev)
{
struct rt_rtmp_adapter *pAd = NULL;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
/* Sanity check for pAd */
if (pAd == NULL)
return 0; /* close ok */
if (VIRTUAL_IF_UP(pAd) != 0)
return -1;
/* increase MODULE use count */
RT_MOD_INC_USE_COUNT();
netif_start_queue(net_dev);
netif_carrier_on(net_dev);
netif_wake_queue(net_dev);
return 0;
}
/*
========================================================================
Routine Description:
Close raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int rt28xx_close(struct net_device *dev)
{
struct net_device *net_dev = (struct net_device *)dev;
struct rt_rtmp_adapter *pAd = NULL;
BOOLEAN Cancelled;
u32 i = 0;
#ifdef RTMP_MAC_USB
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup);
DECLARE_WAITQUEUE(wait, current);
#endif /* RTMP_MAC_USB // */
GET_PAD_FROM_NET_DEV(pAd, net_dev);
DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
Cancelled = FALSE;
/* Sanity check for pAd */
if (pAd == NULL)
return 0; /* close ok */
{
#ifdef RTMP_MAC_PCI
RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE);
#endif /* RTMP_MAC_PCI // */
/* If driver doesn't wake up firmware here, */
/* NICLoadFirmware will hang forever when interface is up again. */
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) {
AsicForceWakeup(pAd, TRUE);
}
#ifdef RTMP_MAC_USB
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
#endif /* RTMP_MAC_USB // */
MlmeRadioOff(pAd);
#ifdef RTMP_MAC_PCI
pAd->bPCIclkOff = FALSE;
#endif /* RTMP_MAC_PCI // */
}
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
for (i = 0; i < NUM_OF_TX_RING; i++) {
while (pAd->DeQueueRunning[i] == TRUE) {
DBGPRINT(RT_DEBUG_TRACE,
("Waiting for TxQueue[%d] done..........\n",
i));
RTMPusecDelay(1000);
}
}
#ifdef RTMP_MAC_USB
/* ensure there are no more active urbs. */
add_wait_queue(&unlink_wakeup, &wait);
pAd->wait = &unlink_wakeup;
/* maybe wait for deletions to finish. */
i = 0;
/*while((i < 25) && atomic_read(&pAd->PendingRx) > 0) */
while (i < 25) {
unsigned long IrqFlags;
RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
if (pAd->PendingRx == 0) {
RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
break;
}
RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
msleep(UNLINK_TIMEOUT_MS); /*Time in millisecond */
i++;
}
pAd->wait = NULL;
remove_wait_queue(&unlink_wakeup, &wait);
#endif /* RTMP_MAC_USB // */
/* Stop Mlme state machine */
MlmeHalt(pAd);
/* Close net tasklets */
RtmpNetTaskExit(pAd);
{
MacTableReset(pAd);
}
MeasureReqTabExit(pAd);
TpcReqTabExit(pAd);
/* Close kernel threads */
RtmpMgmtTaskExit(pAd);
#ifdef RTMP_MAC_PCI
{
BOOLEAN brc;
/* unsigned long Value; */
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) {
RTMP_ASIC_INTERRUPT_DISABLE(pAd);
}
/* Receive packets to clear DMA index after disable interrupt. */
/* RTMPHandleRxDoneInterrupt(pAd); */
/* put radio off to save power when driver unloads. After radiooff, can't write/read register, so need to finish all. */
/* register access before Radio off. */
brc = RT28xxPciAsicRadioOff(pAd, RTMP_HALT, 0);
/*In solution 3 of 3090F, the bPCIclkOff will be set to TRUE after calling RT28xxPciAsicRadioOff */
pAd->bPCIclkOff = FALSE;
if (brc == FALSE) {
DBGPRINT(RT_DEBUG_ERROR,
("%s call RT28xxPciAsicRadioOff fail!\n",
__func__));
}
}
/*
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
{
RTMP_ASIC_INTERRUPT_DISABLE(pAd);
}
// Disable Rx, register value supposed will remain after reset
NICIssueReset(pAd);
*/
#endif /* RTMP_MAC_PCI // */
/* Free IRQ */
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
#ifdef RTMP_MAC_PCI
/* Deregister interrupt function */
RtmpOSIRQRelease(net_dev);
#endif /* RTMP_MAC_PCI // */
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
}
/* Free Ring or USB buffers */
RTMPFreeTxRxRingMemory(pAd);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
/* Free BA reorder resource */
ba_reordering_resource_release(pAd);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
/*+++Modify by woody to solve the bulk fail+++*/
{
}
DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n"));
return 0; /* close ok */
} /* End of rt28xx_close */
/*
========================================================================
Routine Description:
Open raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
========================================================================
*/
int rt28xx_open(struct net_device *dev)
{
struct net_device *net_dev = (struct net_device *)dev;
struct rt_rtmp_adapter *pAd = NULL;
int retval = 0;
/*struct os_cookie *pObj; */
GET_PAD_FROM_NET_DEV(pAd, net_dev);
/* Sanity check for pAd */
if (pAd == NULL) {
/* if 1st open fail, pAd will be free;
So the net_dev->ml_priv will be NULL in 2rd open */
return -1;
}
if (net_dev->priv_flags == INT_MAIN) {
if (pAd->OpMode == OPMODE_STA)
net_dev->wireless_handlers =
(struct iw_handler_def *)&rt28xx_iw_handler_def;
}
/* Request interrupt service routine for PCI device */
/* register the interrupt routine with the os */
RtmpOSIRQRequest(net_dev);
/* Init IRQ parameters stored in pAd */
RTMP_IRQ_INIT(pAd);
/* Chip & other init */
if (rt28xx_init(pAd, mac, hostname) == FALSE)
goto err;
/* Enable Interrupt */
RTMP_IRQ_ENABLE(pAd);
/* Now Enable RxTx */
RTMPEnableRxTx(pAd);
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
{
u32 reg = 0;
RTMP_IO_READ32(pAd, 0x1300, &reg); /* clear garbage interrupts */
printk(KERN_DEBUG "0x1300 = %08x\n", reg);
}
{
/* u32 reg; */
/* u8 byte; */
/* u16 tmp; */
/* RTMP_IO_READ32(pAd, XIFS_TIME_CFG, &reg); */
/* tmp = 0x0805; */
/* reg = (reg & 0xffff0000) | tmp; */
/* RTMP_IO_WRITE32(pAd, XIFS_TIME_CFG, reg); */
}
#ifdef RTMP_MAC_PCI
RTMPInitPCIeLinkCtrlValue(pAd);
#endif /* RTMP_MAC_PCI // */
return retval;
err:
/*+++Add by shiang, move from rt28xx_init() to here. */
RtmpOSIRQRelease(net_dev);
/*---Add by shiang, move from rt28xx_init() to here. */
return -1;
} /* End of rt28xx_open */
static const struct net_device_ops rt2860_netdev_ops = {
.ndo_open = MainVirtualIF_open,
.ndo_stop = MainVirtualIF_close,
.ndo_do_ioctl = rt28xx_sta_ioctl,
.ndo_get_stats = RT28xx_get_ether_stats,
.ndo_validate_addr = NULL,
.ndo_set_mac_address = eth_mac_addr,
.ndo_change_mtu = eth_change_mtu,
.ndo_start_xmit = rt28xx_send_packets,
};
struct net_device *RtmpPhyNetDevInit(struct rt_rtmp_adapter *pAd,
struct rt_rtmp_os_netdev_op_hook *pNetDevHook)
{
struct net_device *net_dev = NULL;
/* int Status; */
net_dev =
RtmpOSNetDevCreate(pAd, INT_MAIN, 0, sizeof(struct rt_rtmp_adapter *),
INF_MAIN_DEV_NAME);
if (net_dev == NULL) {
printk
("RtmpPhyNetDevInit(): creation failed for main physical net device!\n");
return NULL;
}
NdisZeroMemory((unsigned char *)pNetDevHook,
sizeof(struct rt_rtmp_os_netdev_op_hook));
pNetDevHook->netdev_ops = &rt2860_netdev_ops;
pNetDevHook->priv_flags = INT_MAIN;
pNetDevHook->needProtcted = FALSE;
net_dev->ml_priv = (void *)pAd;
pAd->net_dev = net_dev;
return net_dev;
}
/*
========================================================================
Routine Description:
The entry point for Linux kernel sent packet to our driver.
Arguments:
sk_buff *skb the pointer refer to a sk_buffer.
Return Value:
0
Note:
This function is the entry point of Tx Path for Os delivery packet to
our driver. You only can put OS-depened & STA/AP common handle procedures
in here.
========================================================================
*/
int rt28xx_packet_xmit(struct sk_buff *skb)
{
struct net_device *net_dev = skb->dev;
struct rt_rtmp_adapter *pAd = NULL;
int status = NETDEV_TX_OK;
void *pPacket = (void *)skb;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
/* RT2870STA does this in RTMPSendPackets() */
{
/* Drop send request since we are in monitor mode */
if (MONITOR_ON(pAd)) {
RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
goto done;
}
}
/* EapolStart size is 18 */
if (skb->len < 14) {
/*printk("bad packet size: %d\n", pkt->len); */
hex_dump("bad packet", skb->data, skb->len);
RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
goto done;
}
RTMP_SET_PACKET_5VT(pPacket, 0);
STASendPackets((void *)pAd, (void **)&pPacket, 1);
status = NETDEV_TX_OK;
done:
return status;
}
/*
========================================================================
Routine Description:
Send a packet to WLAN.
Arguments:
skb_p points to our adapter
dev_p which WLAN network interface
Return Value:
0: transmit successfully
otherwise: transmit fail
Note:
========================================================================
*/
static int rt28xx_send_packets(IN struct sk_buff *skb_p,
IN struct net_device *net_dev)
{
struct rt_rtmp_adapter *pAd = NULL;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
if (!(net_dev->flags & IFF_UP)) {
RELEASE_NDIS_PACKET(pAd, (void *)skb_p,
NDIS_STATUS_FAILURE);
return NETDEV_TX_OK;
}
NdisZeroMemory((u8 *)&skb_p->cb[CB_OFF], 15);
RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
return rt28xx_packet_xmit(skb_p);
}
/* This function will be called when query /proc */
struct iw_statistics *rt28xx_get_wireless_stats(IN struct net_device *net_dev)
{
struct rt_rtmp_adapter *pAd = NULL;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
pAd->iw_stats.status = 0; /* Status - device dependent for now */
/* link quality */
if (pAd->OpMode == OPMODE_STA)
pAd->iw_stats.qual.qual =
((pAd->Mlme.ChannelQuality * 12) / 10 + 10);
if (pAd->iw_stats.qual.qual > 100)
pAd->iw_stats.qual.qual = 100;
if (pAd->OpMode == OPMODE_STA) {
pAd->iw_stats.qual.level =
RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0,
pAd->StaCfg.RssiSample.LastRssi1,
pAd->StaCfg.RssiSample.LastRssi2);
}
pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; /* noise level (dBm) */
pAd->iw_stats.qual.noise += 256 - 143;
pAd->iw_stats.qual.updated = 1; /* Flags to know if updated */
#ifdef IW_QUAL_DBM
pAd->iw_stats.qual.updated |= IW_QUAL_DBM; /* Level + Noise are dBm */
#endif /* IW_QUAL_DBM // */
pAd->iw_stats.discard.nwid = 0; /* Rx : Wrong nwid/essid */
pAd->iw_stats.miss.beacon = 0; /* Missed beacons/superframe */
DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
return &pAd->iw_stats;
}
void tbtt_tasklet(unsigned long data)
{
/*#define MAX_TX_IN_TBTT (16) */
}
/*
========================================================================
Routine Description:
return ethernet statistics counter
Arguments:
net_dev Pointer to net_device
Return Value:
net_device_stats*
Note:
========================================================================
*/
static struct net_device_stats *RT28xx_get_ether_stats(IN struct net_device
*net_dev)
{
struct rt_rtmp_adapter *pAd = NULL;
if (net_dev)
GET_PAD_FROM_NET_DEV(pAd, net_dev);
if (pAd) {
pAd->stats.rx_packets =
pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
pAd->stats.tx_packets =
pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
pAd->stats.rx_dropped = 0;
pAd->stats.tx_dropped = 0;
pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; /* multicast packets received */
pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; /* Collision packets */
pAd->stats.rx_length_errors = 0;
pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; /* receiver ring buff overflow */
pAd->stats.rx_crc_errors = 0; /*pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error */
pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; /* recv'd frame alignment error */
pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; /* recv'r fifo overrun */
pAd->stats.rx_missed_errors = 0; /* receiver missed packet */
/* detailed tx_errors */
pAd->stats.tx_aborted_errors = 0;
pAd->stats.tx_carrier_errors = 0;
pAd->stats.tx_fifo_errors = 0;
pAd->stats.tx_heartbeat_errors = 0;
pAd->stats.tx_window_errors = 0;
/* for cslip etc */
pAd->stats.rx_compressed = 0;
pAd->stats.tx_compressed = 0;
return &pAd->stats;
} else
return NULL;
}
BOOLEAN RtmpPhyNetDevExit(struct rt_rtmp_adapter *pAd, struct net_device *net_dev)
{
/* Unregister network device */
if (net_dev != NULL) {
printk
("RtmpOSNetDevDetach(): RtmpOSNetDeviceDetach(), dev->name=%s!\n",
net_dev->name);
RtmpOSNetDevDetach(net_dev);
}
return TRUE;
}
/*
========================================================================
Routine Description:
Allocate memory for adapter control block.
Arguments:
pAd Pointer to our adapter
Return Value:
NDIS_STATUS_SUCCESS
NDIS_STATUS_FAILURE
NDIS_STATUS_RESOURCES
Note:
========================================================================
*/
int AdapterBlockAllocateMemory(void *handle, void ** ppAd)
{
*ppAd = vmalloc(sizeof(struct rt_rtmp_adapter));
/* pci_alloc_consistent(pci_dev, sizeof(struct rt_rtmp_adapter), phy_addr); */
if (*ppAd) {
NdisZeroMemory(*ppAd, sizeof(struct rt_rtmp_adapter));
((struct rt_rtmp_adapter *)*ppAd)->OS_Cookie = handle;
return NDIS_STATUS_SUCCESS;
} else {
return NDIS_STATUS_FAILURE;
}
}

View file

@ -1,837 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_pci_rbus.c
Abstract:
Create and register network interface.
Revision History:
Who When What
Justin P. Mattock 11/07/2010 Fix a typo
-------- ---------- ----------------------------------------------
*/
#include "rt_config.h"
#include <linux/pci.h>
IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance);
static void rx_done_tasklet(unsigned long data);
static void mgmt_dma_done_tasklet(unsigned long data);
static void ac0_dma_done_tasklet(unsigned long data);
static void ac1_dma_done_tasklet(unsigned long data);
static void ac2_dma_done_tasklet(unsigned long data);
static void ac3_dma_done_tasklet(unsigned long data);
static void fifo_statistic_full_tasklet(unsigned long data);
/*---------------------------------------------------------------------*/
/* Symbol & Macro Definitions */
/*---------------------------------------------------------------------*/
#define RT2860_INT_RX_DLY (1<<0) /* bit 0 */
#define RT2860_INT_TX_DLY (1<<1) /* bit 1 */
#define RT2860_INT_RX_DONE (1<<2) /* bit 2 */
#define RT2860_INT_AC0_DMA_DONE (1<<3) /* bit 3 */
#define RT2860_INT_AC1_DMA_DONE (1<<4) /* bit 4 */
#define RT2860_INT_AC2_DMA_DONE (1<<5) /* bit 5 */
#define RT2860_INT_AC3_DMA_DONE (1<<6) /* bit 6 */
#define RT2860_INT_HCCA_DMA_DONE (1<<7) /* bit 7 */
#define RT2860_INT_MGMT_DONE (1<<8) /* bit 8 */
#define INT_RX RT2860_INT_RX_DONE
#define INT_AC0_DLY (RT2860_INT_AC0_DMA_DONE) /*| RT2860_INT_TX_DLY) */
#define INT_AC1_DLY (RT2860_INT_AC1_DMA_DONE) /*| RT2860_INT_TX_DLY) */
#define INT_AC2_DLY (RT2860_INT_AC2_DMA_DONE) /*| RT2860_INT_TX_DLY) */
#define INT_AC3_DLY (RT2860_INT_AC3_DMA_DONE) /*| RT2860_INT_TX_DLY) */
#define INT_HCCA_DLY (RT2860_INT_HCCA_DMA_DONE) /*| RT2860_INT_TX_DLY) */
#define INT_MGMT_DLY RT2860_INT_MGMT_DONE
/***************************************************************************
*
* Interface-depended memory allocation/Free related procedures.
* Mainly for Hardware TxDesc/RxDesc/MgmtDesc, DMA Memory for TxData/RxData, etc.,
*
**************************************************************************/
/* Function for TxDesc Memory allocation. */
void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd,
u32 Index,
unsigned long Length,
IN BOOLEAN Cached,
void **VirtualAddress,
dma_addr_t *PhysicalAddress)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
*VirtualAddress =
(void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
PhysicalAddress);
}
/* Function for MgmtDesc Memory allocation. */
void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd,
unsigned long Length,
IN BOOLEAN Cached,
void **VirtualAddress,
dma_addr_t *PhysicalAddress)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
*VirtualAddress =
(void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
PhysicalAddress);
}
/* Function for RxDesc Memory allocation. */
void RTMP_AllocateRxDescMemory(struct rt_rtmp_adapter *pAd,
unsigned long Length,
IN BOOLEAN Cached,
void **VirtualAddress,
dma_addr_t *PhysicalAddress)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
*VirtualAddress =
(void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
PhysicalAddress);
}
/* Function for free allocated Desc Memory. */
void RTMP_FreeDescMemory(struct rt_rtmp_adapter *pAd,
unsigned long Length,
void *VirtualAddress,
dma_addr_t PhysicalAddress)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
pci_free_consistent(pObj->pci_dev, Length, VirtualAddress,
PhysicalAddress);
}
/* Function for TxData DMA Memory allocation. */
void RTMP_AllocateFirstTxBuffer(struct rt_rtmp_adapter *pAd,
u32 Index,
unsigned long Length,
IN BOOLEAN Cached,
void **VirtualAddress,
dma_addr_t *PhysicalAddress)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
*VirtualAddress =
(void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
PhysicalAddress);
}
void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd,
unsigned long Length,
IN BOOLEAN Cached,
void *VirtualAddress,
dma_addr_t PhysicalAddress)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
pci_free_consistent(pObj->pci_dev, Length, VirtualAddress,
PhysicalAddress);
}
/*
* FUNCTION: Allocate a common buffer for DMA
* ARGUMENTS:
* AdapterHandle: AdapterHandle
* Length: Number of bytes to allocate
* Cached: Whether or not the memory can be cached
* VirtualAddress: Pointer to memory is returned here
* PhysicalAddress: Physical address corresponding to virtual address
*/
void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd,
unsigned long Length,
IN BOOLEAN Cached,
void **VirtualAddress,
dma_addr_t *PhysicalAddress)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
*VirtualAddress =
(void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
PhysicalAddress);
}
/*
* FUNCTION: Allocate a packet buffer for DMA
* ARGUMENTS:
* AdapterHandle: AdapterHandle
* Length: Number of bytes to allocate
* Cached: Whether or not the memory can be cached
* VirtualAddress: Pointer to memory is returned here
* PhysicalAddress: Physical address corresponding to virtual address
* Notes:
* Cached is ignored: always cached memory
*/
void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd,
unsigned long Length,
IN BOOLEAN Cached,
void **VirtualAddress,
OUT dma_addr_t *
PhysicalAddress)
{
struct sk_buff *pkt;
pkt = dev_alloc_skb(Length);
if (pkt == NULL) {
DBGPRINT(RT_DEBUG_ERROR,
("can't allocate rx %ld size packet\n", Length));
}
if (pkt) {
RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
*VirtualAddress = (void *)pkt->data;
*PhysicalAddress =
PCI_MAP_SINGLE(pAd, *VirtualAddress, Length, -1,
PCI_DMA_FROMDEVICE);
} else {
*VirtualAddress = (void *)NULL;
*PhysicalAddress = (dma_addr_t)NULL;
}
return (void *)pkt;
}
void Invalid_Remaining_Packet(struct rt_rtmp_adapter *pAd, unsigned long VirtualAddress)
{
dma_addr_t PhysicalAddress;
PhysicalAddress =
PCI_MAP_SINGLE(pAd, (void *)(VirtualAddress + 1600),
RX_BUFFER_NORMSIZE - 1600, -1, PCI_DMA_FROMDEVICE);
}
int RtmpNetTaskInit(struct rt_rtmp_adapter *pAd)
{
struct os_cookie *pObj;
pObj = (struct os_cookie *)pAd->OS_Cookie;
tasklet_init(&pObj->rx_done_task, rx_done_tasklet, (unsigned long)pAd);
tasklet_init(&pObj->mgmt_dma_done_task, mgmt_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac0_dma_done_task, ac0_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac1_dma_done_task, ac1_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac2_dma_done_task, ac2_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac3_dma_done_task, ac3_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->tbtt_task, tbtt_tasklet, (unsigned long)pAd);
tasklet_init(&pObj->fifo_statistic_full_task,
fifo_statistic_full_tasklet, (unsigned long)pAd);
return NDIS_STATUS_SUCCESS;
}
void RtmpNetTaskExit(struct rt_rtmp_adapter *pAd)
{
struct os_cookie *pObj;
pObj = (struct os_cookie *)pAd->OS_Cookie;
tasklet_kill(&pObj->rx_done_task);
tasklet_kill(&pObj->mgmt_dma_done_task);
tasklet_kill(&pObj->ac0_dma_done_task);
tasklet_kill(&pObj->ac1_dma_done_task);
tasklet_kill(&pObj->ac2_dma_done_task);
tasklet_kill(&pObj->ac3_dma_done_task);
tasklet_kill(&pObj->tbtt_task);
tasklet_kill(&pObj->fifo_statistic_full_task);
}
int RtmpMgmtTaskInit(struct rt_rtmp_adapter *pAd)
{
return NDIS_STATUS_SUCCESS;
}
/*
========================================================================
Routine Description:
Close kernel threads.
Arguments:
*pAd the raxx interface data pointer
Return Value:
NONE
Note:
========================================================================
*/
void RtmpMgmtTaskExit(struct rt_rtmp_adapter *pAd)
{
return;
}
static inline void rt2860_int_enable(struct rt_rtmp_adapter *pAd, unsigned int mode)
{
u32 regValue;
pAd->int_disable_mask &= ~(mode);
regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);
/*if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) */
{
RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue); /* 1:enable */
}
/*else */
/* DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_DOZE !\n")); */
if (regValue != 0)
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
}
static inline void rt2860_int_disable(struct rt_rtmp_adapter *pAd, unsigned int mode)
{
u32 regValue;
pAd->int_disable_mask |= mode;
regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);
RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue); /* 0: disable */
if (regValue == 0) {
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
}
}
/***************************************************************************
*
* tasklet related procedures.
*
**************************************************************************/
static void mgmt_dma_done_tasklet(unsigned long data)
{
unsigned long flags;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
INT_SOURCE_CSR_STRUC IntSource;
struct os_cookie *pObj;
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
pObj = (struct os_cookie *)pAd->OS_Cookie;
/* printk("mgmt_dma_done_process\n"); */
IntSource.word = 0;
IntSource.field.MgmtDmaDone = 1;
pAd->int_pending &= ~INT_MGMT_DLY;
RTMPHandleMgmtRingDmaDoneInterrupt(pAd);
/* if you use RTMP_SEM_LOCK, sometimes kernel will hang up, without any */
/* bug report output */
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
* double check to avoid lose of interrupts
*/
if (pAd->int_pending & INT_MGMT_DLY) {
tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
return;
}
/* enable TxDataInt again */
rt2860_int_enable(pAd, INT_MGMT_DLY);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
}
static void rx_done_tasklet(unsigned long data)
{
unsigned long flags;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
BOOLEAN bReschedule = 0;
struct os_cookie *pObj;
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
pObj = (struct os_cookie *)pAd->OS_Cookie;
pAd->int_pending &= ~(INT_RX);
bReschedule = STARxDoneInterruptHandle(pAd, 0);
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
* double check to avoid rotting packet
*/
if (pAd->int_pending & INT_RX || bReschedule) {
tasklet_hi_schedule(&pObj->rx_done_task);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
return;
}
/* enable Rxint again */
rt2860_int_enable(pAd, INT_RX);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
}
void fifo_statistic_full_tasklet(unsigned long data)
{
unsigned long flags;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
struct os_cookie *pObj;
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
pObj = (struct os_cookie *)pAd->OS_Cookie;
pAd->int_pending &= ~(FifoStaFullInt);
NICUpdateFifoStaCounters(pAd);
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
* double check to avoid rotting packet
*/
if (pAd->int_pending & FifoStaFullInt) {
tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
return;
}
/* enable Rxint again */
rt2860_int_enable(pAd, FifoStaFullInt);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
}
static void ac3_dma_done_tasklet(unsigned long data)
{
unsigned long flags;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
INT_SOURCE_CSR_STRUC IntSource;
struct os_cookie *pObj;
BOOLEAN bReschedule = 0;
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
pObj = (struct os_cookie *)pAd->OS_Cookie;
/* printk("ac0_dma_done_process\n"); */
IntSource.word = 0;
IntSource.field.Ac3DmaDone = 1;
pAd->int_pending &= ~INT_AC3_DLY;
bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
* double check to avoid lose of interrupts
*/
if ((pAd->int_pending & INT_AC3_DLY) || bReschedule) {
tasklet_hi_schedule(&pObj->ac3_dma_done_task);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
return;
}
/* enable TxDataInt again */
rt2860_int_enable(pAd, INT_AC3_DLY);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
}
static void ac2_dma_done_tasklet(unsigned long data)
{
unsigned long flags;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
INT_SOURCE_CSR_STRUC IntSource;
struct os_cookie *pObj;
BOOLEAN bReschedule = 0;
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
pObj = (struct os_cookie *)pAd->OS_Cookie;
IntSource.word = 0;
IntSource.field.Ac2DmaDone = 1;
pAd->int_pending &= ~INT_AC2_DLY;
bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
* double check to avoid lose of interrupts
*/
if ((pAd->int_pending & INT_AC2_DLY) || bReschedule) {
tasklet_hi_schedule(&pObj->ac2_dma_done_task);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
return;
}
/* enable TxDataInt again */
rt2860_int_enable(pAd, INT_AC2_DLY);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
}
static void ac1_dma_done_tasklet(unsigned long data)
{
unsigned long flags;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
INT_SOURCE_CSR_STRUC IntSource;
struct os_cookie *pObj;
BOOLEAN bReschedule = 0;
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
pObj = (struct os_cookie *)pAd->OS_Cookie;
/* printk("ac0_dma_done_process\n"); */
IntSource.word = 0;
IntSource.field.Ac1DmaDone = 1;
pAd->int_pending &= ~INT_AC1_DLY;
bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
* double check to avoid lose of interrupts
*/
if ((pAd->int_pending & INT_AC1_DLY) || bReschedule) {
tasklet_hi_schedule(&pObj->ac1_dma_done_task);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
return;
}
/* enable TxDataInt again */
rt2860_int_enable(pAd, INT_AC1_DLY);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
}
static void ac0_dma_done_tasklet(unsigned long data)
{
unsigned long flags;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
INT_SOURCE_CSR_STRUC IntSource;
struct os_cookie *pObj;
BOOLEAN bReschedule = 0;
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
pObj = (struct os_cookie *)pAd->OS_Cookie;
/* printk("ac0_dma_done_process\n"); */
IntSource.word = 0;
IntSource.field.Ac0DmaDone = 1;
pAd->int_pending &= ~INT_AC0_DLY;
/* RTMPHandleMgmtRingDmaDoneInterrupt(pAd); */
bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
* double check to avoid lose of interrupts
*/
if ((pAd->int_pending & INT_AC0_DLY) || bReschedule) {
tasklet_hi_schedule(&pObj->ac0_dma_done_task);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
return;
}
/* enable TxDataInt again */
rt2860_int_enable(pAd, INT_AC0_DLY);
RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
}
/***************************************************************************
*
* interrupt handler related procedures.
*
**************************************************************************/
int print_int_count;
IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance)
{
struct net_device *net_dev = (struct net_device *)dev_instance;
struct rt_rtmp_adapter *pAd = NULL;
INT_SOURCE_CSR_STRUC IntSource;
struct os_cookie *pObj;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
pObj = (struct os_cookie *)pAd->OS_Cookie;
/* Note 03312008: we can not return here before
RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IntSource.word);
RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, IntSource.word);
Or kernel will panic after ifconfig ra0 down sometimes */
/* */
/* Initial the Interrupt source. */
/* */
IntSource.word = 0x00000000L;
/* McuIntSource.word = 0x00000000L; */
/* */
/* Get the interrupt sources & saved to local variable */
/* */
/*RTMP_IO_READ32(pAd, where, &McuIntSource.word); */
/*RTMP_IO_WRITE32(pAd, , McuIntSource.word); */
/* */
/* Flag fOP_STATUS_DOZE On, means ASIC put to sleep, elase means ASICK WakeUp */
/* And at the same time, clock maybe turned off that say there is no DMA service. */
/* when ASIC get to sleep. */
/* To prevent system hang on power saving. */
/* We need to check it before handle the INT_SOURCE_CSR, ASIC must be wake up. */
/* */
/* RT2661 => when ASIC is sleeping, MAC register cannot be read and written. */
/* RT2860 => when ASIC is sleeping, MAC register can be read and written. */
/* if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) */
{
RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IntSource.word);
RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, IntSource.word); /* write 1 to clear */
}
/* else */
/* DBGPRINT(RT_DEBUG_TRACE, (">>>fOP_STATUS_DOZE<<<\n")); */
/* RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IsrAfterClear); */
/* RTMP_IO_READ32(pAd, MCU_INT_SOURCE_CSR, &McuIsrAfterClear); */
/* DBGPRINT(RT_DEBUG_INFO, ("====> RTMPHandleInterrupt(ISR=%08x,Mcu ISR=%08x, After clear ISR=%08x, MCU ISR=%08x)\n", */
/* IntSource.word, McuIntSource.word, IsrAfterClear, McuIsrAfterClear)); */
/* Do nothing if Reset in progress */
if (RTMP_TEST_FLAG
(pAd,
(fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS))) {
return IRQ_HANDLED;
}
/* */
/* Handle interrupt, walk through all bits */
/* Should start from highest priority interrupt */
/* The priority can be adjust by altering processing if statement */
/* */
#ifdef DBG
#endif
pAd->bPCIclkOff = FALSE;
/* If required spinlock, each interrupt service routine has to acquire */
/* and release itself. */
/* */
/* Do nothing if NIC doesn't exist */
if (IntSource.word == 0xffffffff) {
RTMP_SET_FLAG(pAd,
(fRTMP_ADAPTER_NIC_NOT_EXIST |
fRTMP_ADAPTER_HALT_IN_PROGRESS));
return IRQ_HANDLED;
}
if (IntSource.word & TxCoherent) {
DBGPRINT(RT_DEBUG_ERROR, (">>>TxCoherent<<<\n"));
RTMPHandleRxCoherentInterrupt(pAd);
}
if (IntSource.word & RxCoherent) {
DBGPRINT(RT_DEBUG_ERROR, (">>>RxCoherent<<<\n"));
RTMPHandleRxCoherentInterrupt(pAd);
}
if (IntSource.word & FifoStaFullInt) {
if ((pAd->int_disable_mask & FifoStaFullInt) == 0) {
/* mask FifoStaFullInt */
rt2860_int_disable(pAd, FifoStaFullInt);
tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
}
pAd->int_pending |= FifoStaFullInt;
}
if (IntSource.word & INT_MGMT_DLY) {
if ((pAd->int_disable_mask & INT_MGMT_DLY) == 0) {
rt2860_int_disable(pAd, INT_MGMT_DLY);
tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
}
pAd->int_pending |= INT_MGMT_DLY;
}
if (IntSource.word & INT_RX) {
if ((pAd->int_disable_mask & INT_RX) == 0) {
/* mask Rxint */
rt2860_int_disable(pAd, INT_RX);
tasklet_hi_schedule(&pObj->rx_done_task);
}
pAd->int_pending |= INT_RX;
}
if (IntSource.word & INT_AC3_DLY) {
if ((pAd->int_disable_mask & INT_AC3_DLY) == 0) {
/* mask TxDataInt */
rt2860_int_disable(pAd, INT_AC3_DLY);
tasklet_hi_schedule(&pObj->ac3_dma_done_task);
}
pAd->int_pending |= INT_AC3_DLY;
}
if (IntSource.word & INT_AC2_DLY) {
if ((pAd->int_disable_mask & INT_AC2_DLY) == 0) {
/* mask TxDataInt */
rt2860_int_disable(pAd, INT_AC2_DLY);
tasklet_hi_schedule(&pObj->ac2_dma_done_task);
}
pAd->int_pending |= INT_AC2_DLY;
}
if (IntSource.word & INT_AC1_DLY) {
pAd->int_pending |= INT_AC1_DLY;
if ((pAd->int_disable_mask & INT_AC1_DLY) == 0) {
/* mask TxDataInt */
rt2860_int_disable(pAd, INT_AC1_DLY);
tasklet_hi_schedule(&pObj->ac1_dma_done_task);
}
}
if (IntSource.word & INT_AC0_DLY) {
/*
if (IntSource.word & 0x2) {
u32 reg;
RTMP_IO_READ32(pAd, DELAY_INT_CFG, &reg);
printk("IntSource.word = %08x, DELAY_REG = %08x\n", IntSource.word, reg);
}
*/
pAd->int_pending |= INT_AC0_DLY;
if ((pAd->int_disable_mask & INT_AC0_DLY) == 0) {
/* mask TxDataInt */
rt2860_int_disable(pAd, INT_AC0_DLY);
tasklet_hi_schedule(&pObj->ac0_dma_done_task);
}
}
if (IntSource.word & PreTBTTInt) {
RTMPHandlePreTBTTInterrupt(pAd);
}
if (IntSource.word & TBTTInt) {
RTMPHandleTBTTInterrupt(pAd);
}
{
if (IntSource.word & AutoWakeupInt)
RTMPHandleTwakeupInterrupt(pAd);
}
return IRQ_HANDLED;
}
/*
* invalid or writeback cache
* and convert virtual address to physical address
*/
dma_addr_t linux_pci_map_single(struct rt_rtmp_adapter *pAd, void *ptr,
size_t size, int sd_idx, int direction)
{
struct os_cookie *pObj;
/*
------ Porting Information ------
> For Tx Alloc:
mgmt packets => sd_idx = 0
SwIdx: pAd->MgmtRing.TxCpuIdx
pTxD : pAd->MgmtRing.Cell[SwIdx].AllocVa;
data packets => sd_idx = 1
TxIdx : pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx
QueIdx: pTxBlk->QueIdx
pTxD : pAd->TxRing[pTxBlk->QueIdx].Cell[TxIdx].AllocVa;
> For Rx Alloc:
sd_idx = -1
*/
pObj = (struct os_cookie *)pAd->OS_Cookie;
if (sd_idx == 1) {
struct rt_tx_blk *pTxBlk;
pTxBlk = (struct rt_tx_blk *)ptr;
return pci_map_single(pObj->pci_dev, pTxBlk->pSrcBufData,
pTxBlk->SrcBufLen, direction);
} else {
return pci_map_single(pObj->pci_dev, ptr, size, direction);
}
}
void linux_pci_unmap_single(struct rt_rtmp_adapter *pAd, dma_addr_t dma_addr,
size_t size, int direction)
{
struct os_cookie *pObj;
pObj = (struct os_cookie *)pAd->OS_Cookie;
pci_unmap_single(pObj->pci_dev, dma_addr, size, direction);
}

View file

@ -1,794 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtusb_bulk.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Justin P. Mattock 11/07/2010 Fix some typos.
*/
#include "rt_config.h"
void dump_urb(struct urb *purb)
{
printk(KERN_DEBUG "urb :0x%08lx\n", (unsigned long)purb);
printk(KERN_DEBUG "\tdev :0x%08lx\n", (unsigned long)purb->dev);
printk(KERN_DEBUG "\t\tdev->state :0x%d\n", purb->dev->state);
printk(KERN_DEBUG "\tpipe :0x%08x\n", purb->pipe);
printk(KERN_DEBUG "\tstatus :%d\n", purb->status);
printk(KERN_DEBUG "\ttransfer_flags :0x%08x\n", purb->transfer_flags);
printk(KERN_DEBUG "\ttransfer_buffer :0x%08lx\n",
(unsigned long)purb->transfer_buffer);
printk(KERN_DEBUG "\ttransfer_buffer_length:%d\n", purb->transfer_buffer_length);
printk(KERN_DEBUG "\tactual_length :%d\n", purb->actual_length);
printk(KERN_DEBUG "\tsetup_packet :0x%08lx\n",
(unsigned long)purb->setup_packet);
printk(KERN_DEBUG "\tstart_frame :%d\n", purb->start_frame);
printk(KERN_DEBUG "\tnumber_of_packets :%d\n", purb->number_of_packets);
printk(KERN_DEBUG "\tinterval :%d\n", purb->interval);
printk(KERN_DEBUG "\terror_count :%d\n", purb->error_count);
printk(KERN_DEBUG "\tcontext :0x%08lx\n",
(unsigned long)purb->context);
printk(KERN_DEBUG "\tcomplete :0x%08lx\n\n",
(unsigned long)purb->complete);
}
/*
========================================================================
Routine Description:
Create kernel threads & tasklets.
Arguments:
*net_dev Pointer to wireless net device interface
Return Value:
NDIS_STATUS_SUCCESS
NDIS_STATUS_FAILURE
Note:
========================================================================
*/
int RtmpMgmtTaskInit(struct rt_rtmp_adapter *pAd)
{
struct rt_rtmp_os_task *pTask;
int status;
/*
Creat TimerQ Thread, We need init timerQ related structure before create the timer thread.
*/
RtmpTimerQInit(pAd);
pTask = &pAd->timerTask;
RtmpOSTaskInit(pTask, "RtmpTimerTask", pAd);
status = RtmpOSTaskAttach(pTask, RtmpTimerQThread, pTask);
if (status == NDIS_STATUS_FAILURE) {
printk(KERN_WARNING "%s: unable to start RtmpTimerQThread\n",
RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev));
return NDIS_STATUS_FAILURE;
}
/* Creat MLME Thread */
pTask = &pAd->mlmeTask;
RtmpOSTaskInit(pTask, "RtmpMlmeTask", pAd);
status = RtmpOSTaskAttach(pTask, MlmeThread, pTask);
if (status == NDIS_STATUS_FAILURE) {
printk(KERN_WARNING "%s: unable to start MlmeThread\n",
RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev));
return NDIS_STATUS_FAILURE;
}
/* Creat Command Thread */
pTask = &pAd->cmdQTask;
RtmpOSTaskInit(pTask, "RtmpCmdQTask", pAd);
status = RtmpOSTaskAttach(pTask, RTUSBCmdThread, pTask);
if (status == NDIS_STATUS_FAILURE) {
printk(KERN_WARNING "%s: unable to start RTUSBCmdThread\n",
RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev));
return NDIS_STATUS_FAILURE;
}
return NDIS_STATUS_SUCCESS;
}
/*
========================================================================
Routine Description:
Close kernel threads.
Arguments:
*pAd the raxx interface data pointer
Return Value:
NONE
Note:
========================================================================
*/
void RtmpMgmtTaskExit(struct rt_rtmp_adapter *pAd)
{
int ret;
struct rt_rtmp_os_task *pTask;
/* Sleep 50 milliseconds so pending io might finish normally */
RTMPusecDelay(50000);
/* We want to wait until all pending receives and sends to the */
/* device object. We cancel any */
/* irps. Wait until sends and receives have stopped. */
RTUSBCancelPendingIRPs(pAd);
/* We need clear timerQ related structure before exits of the timer thread. */
RtmpTimerQExit(pAd);
/* Terminate Mlme Thread */
pTask = &pAd->mlmeTask;
ret = RtmpOSTaskKill(pTask);
if (ret == NDIS_STATUS_FAILURE) {
DBGPRINT(RT_DEBUG_ERROR, ("%s: kill task(%s) failed!\n",
RTMP_OS_NETDEV_GET_DEVNAME(pAd->
net_dev),
pTask->taskName));
}
/* Terminate cmdQ thread */
pTask = &pAd->cmdQTask;
#ifdef KTHREAD_SUPPORT
if (pTask->kthread_task)
#else
CHECK_PID_LEGALITY(pTask->taskPID)
#endif
{
mb();
NdisAcquireSpinLock(&pAd->CmdQLock);
pAd->CmdQ.CmdQState = RTMP_TASK_STAT_STOPED;
NdisReleaseSpinLock(&pAd->CmdQLock);
mb();
/*RTUSBCMDUp(pAd); */
ret = RtmpOSTaskKill(pTask);
if (ret == NDIS_STATUS_FAILURE) {
DBGPRINT(RT_DEBUG_ERROR, ("%s: kill task(%s) failed!\n",
RTMP_OS_NETDEV_GET_DEVNAME
(pAd->net_dev),
pTask->taskName));
}
pAd->CmdQ.CmdQState = RTMP_TASK_STAT_UNKNOWN;
}
/* Terminate timer thread */
pTask = &pAd->timerTask;
ret = RtmpOSTaskKill(pTask);
if (ret == NDIS_STATUS_FAILURE) {
DBGPRINT(RT_DEBUG_ERROR, ("%s: kill task(%s) failed!\n",
RTMP_OS_NETDEV_GET_DEVNAME(pAd->
net_dev),
pTask->taskName));
}
}
static void rtusb_dataout_complete(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct urb *pUrb;
struct os_cookie *pObj;
struct rt_ht_tx_context *pHTTXContext;
u8 BulkOutPipeId;
int Status;
unsigned long IrqFlags;
pUrb = (struct urb *)data;
pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
pAd = pHTTXContext->pAd;
pObj = (struct os_cookie *)pAd->OS_Cookie;
Status = pUrb->status;
/* Store BulkOut PipeId */
BulkOutPipeId = pHTTXContext->BulkOutPipeId;
pAd->BulkOutDataOneSecCount++;
/*DBGPRINT(RT_DEBUG_LOUD, ("Done-B(%d):I=0x%lx, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", BulkOutPipeId, in_interrupt(), pHTTXContext->CurWritePosition, */
/* pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); */
RTMP_IRQ_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
pAd->BulkOutPending[BulkOutPipeId] = FALSE;
pHTTXContext->IRPPending = FALSE;
pAd->watchDogTxPendingCnt[BulkOutPipeId] = 0;
if (Status == USB_ST_NOERROR) {
pAd->BulkOutComplete++;
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
pAd->Counters8023.GoodTransmits++;
/*RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
FREE_HTTX_RING(pAd, BulkOutPipeId, pHTTXContext);
/*RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
} else { /* STATUS_OTHER */
u8 *pBuf;
pAd->BulkOutCompleteOther++;
pBuf =
&pHTTXContext->TransferBuffer->field.
WirelessPacket[pHTTXContext->NextBulkOutPosition];
if (!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST |
fRTMP_ADAPTER_BULKOUT_RESET))) {
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
pAd->bulkResetPipeid = BulkOutPipeId;
pAd->bulkResetReq[BulkOutPipeId] = pAd->BulkOutReq;
}
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
DBGPRINT_RAW(RT_DEBUG_ERROR,
("BulkOutDataPacket failed: ReasonCode=%d!\n",
Status));
DBGPRINT_RAW(RT_DEBUG_ERROR,
("\t>>BulkOut Req=0x%lx, Complete=0x%lx, Other=0x%lx\n",
pAd->BulkOutReq, pAd->BulkOutComplete,
pAd->BulkOutCompleteOther));
DBGPRINT_RAW(RT_DEBUG_ERROR,
("\t>>BulkOut Header:%x %x %x %x %x %x %x %x\n",
pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4],
pBuf[5], pBuf[6], pBuf[7]));
/*DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOutCompleteCancel=0x%x, BulkOutCompleteOther=0x%x\n", pAd->BulkOutCompleteCancel, pAd->BulkOutCompleteOther)); */
}
/* */
/* bInUse = TRUE, means some process are filling TX data, after that must turn on bWaitingBulkOut */
/* bWaitingBulkOut = TRUE, means the TX data are waiting for bulk out. */
/* */
/*RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
if ((pHTTXContext->ENextBulkOutPosition !=
pHTTXContext->CurWritePosition)
&& (pHTTXContext->ENextBulkOutPosition !=
(pHTTXContext->CurWritePosition + 8))
&& !RTUSB_TEST_BULK_FLAG(pAd,
(fRTUSB_BULK_OUT_DATA_FRAG <<
BulkOutPipeId))) {
/* Indicate There is data available */
RTUSB_SET_BULK_FLAG(pAd,
(fRTUSB_BULK_OUT_DATA_NORMAL <<
BulkOutPipeId));
}
/*RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
/* Always call Bulk routine, even reset bulk. */
/* The protection of rest bulk should be in BulkOut routine */
RTUSBKickBulkOut(pAd);
}
static void rtusb_null_frame_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_tx_context *pNullContext;
struct urb *pUrb;
int Status;
unsigned long irqFlag;
pUrb = (struct urb *)data;
pNullContext = (struct rt_tx_context *)pUrb->context;
pAd = pNullContext->pAd;
Status = pUrb->status;
/* Reset Null frame context flags */
RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], irqFlag);
pNullContext->IRPPending = FALSE;
pNullContext->InUse = FALSE;
pAd->BulkOutPending[0] = FALSE;
pAd->watchDogTxPendingCnt[0] = 0;
if (Status == USB_ST_NOERROR) {
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
} else { /* STATUS_OTHER */
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_NIC_NOT_EXIST)) &&
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
DBGPRINT_RAW(RT_DEBUG_ERROR,
("Bulk Out Null Frame Failed, ReasonCode=%d!\n",
Status));
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
pAd->bulkResetPipeid =
(MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
} else {
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
}
}
/* Always call Bulk routine, even reset bulk. */
/* The protection of rest bulk should be in BulkOut routine */
RTUSBKickBulkOut(pAd);
}
static void rtusb_rts_frame_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_tx_context *pRTSContext;
struct urb *pUrb;
int Status;
unsigned long irqFlag;
pUrb = (struct urb *)data;
pRTSContext = (struct rt_tx_context *)pUrb->context;
pAd = pRTSContext->pAd;
Status = pUrb->status;
/* Reset RTS frame context flags */
RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], irqFlag);
pRTSContext->IRPPending = FALSE;
pRTSContext->InUse = FALSE;
if (Status == USB_ST_NOERROR) {
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
} else { /* STATUS_OTHER */
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_NIC_NOT_EXIST)) &&
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
DBGPRINT_RAW(RT_DEBUG_ERROR,
("Bulk Out RTS Frame Failed\n"));
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
pAd->bulkResetPipeid =
(MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
} else {
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
}
}
RTMP_SEM_LOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId]);
pAd->BulkOutPending[pRTSContext->BulkOutPipeId] = FALSE;
RTMP_SEM_UNLOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId]);
/* Always call Bulk routine, even reset bulk. */
/* The protection of rest bulk should be in BulkOut routine */
RTUSBKickBulkOut(pAd);
}
static void rtusb_pspoll_frame_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_tx_context *pPsPollContext;
struct urb *pUrb;
int Status;
pUrb = (struct urb *)data;
pPsPollContext = (struct rt_tx_context *)pUrb->context;
pAd = pPsPollContext->pAd;
Status = pUrb->status;
/* Reset PsPoll context flags */
pPsPollContext->IRPPending = FALSE;
pPsPollContext->InUse = FALSE;
pAd->watchDogTxPendingCnt[0] = 0;
if (Status == USB_ST_NOERROR) {
RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
} else { /* STATUS_OTHER */
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_NIC_NOT_EXIST)) &&
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
DBGPRINT_RAW(RT_DEBUG_ERROR,
("Bulk Out PSPoll Failed\n"));
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
pAd->bulkResetPipeid =
(MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
}
}
RTMP_SEM_LOCK(&pAd->BulkOutLock[0]);
pAd->BulkOutPending[0] = FALSE;
RTMP_SEM_UNLOCK(&pAd->BulkOutLock[0]);
/* Always call Bulk routine, even reset bulk. */
/* The protection of rest bulk should be in BulkOut routine */
RTUSBKickBulkOut(pAd);
}
/*
========================================================================
Routine Description:
Handle received packets.
Arguments:
data - URB information pointer
Return Value:
None
Note:
========================================================================
*/
static void rx_done_tasklet(unsigned long data)
{
struct urb *pUrb;
struct rt_rx_context *pRxContext;
struct rt_rtmp_adapter *pAd;
int Status;
unsigned int IrqFlags;
pUrb = (struct urb *)data;
pRxContext = (struct rt_rx_context *)pUrb->context;
pAd = pRxContext->pAd;
Status = pUrb->status;
RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
pRxContext->InUse = FALSE;
pRxContext->IRPPending = FALSE;
pRxContext->BulkInOffset += pUrb->actual_length;
/*NdisInterlockedDecrement(&pAd->PendingRx); */
pAd->PendingRx--;
if (Status == USB_ST_NOERROR) {
pAd->BulkInComplete++;
pAd->NextRxBulkInPosition = 0;
if (pRxContext->BulkInOffset) { /* As jan's comment, it may bulk-in success but size is zero. */
pRxContext->Readable = TRUE;
INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE);
}
RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
} else { /* STATUS_OTHER */
pAd->BulkInCompleteFail++;
/* Still read this packet although it may comtain wrong bytes. */
pRxContext->Readable = FALSE;
RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
/* Parsing all packets. because after reset, the index will reset to all zero. */
if ((!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_BULKIN_RESET |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
DBGPRINT_RAW(RT_DEBUG_ERROR,
("Bulk In Failed. Status=%d, BIIdx=0x%x, BIRIdx=0x%x, actual_length= 0x%x\n",
Status, pAd->NextRxBulkInIndex,
pAd->NextRxBulkInReadIndex,
pRxContext->pUrb->actual_length));
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN,
NULL, 0);
}
}
ASSERT((pRxContext->InUse == pRxContext->IRPPending));
RTUSBBulkReceive(pAd);
return;
}
static void rtusb_mgmt_dma_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_tx_context *pMLMEContext;
int index;
void *pPacket;
struct urb *pUrb;
int Status;
unsigned long IrqFlags;
pUrb = (struct urb *)data;
pMLMEContext = (struct rt_tx_context *)pUrb->context;
pAd = pMLMEContext->pAd;
Status = pUrb->status;
index = pMLMEContext->SelfIdx;
ASSERT((pAd->MgmtRing.TxDmaIdx == index));
RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
if (Status != USB_ST_NOERROR) {
/*Bulk-Out fail status handle */
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_NIC_NOT_EXIST)) &&
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
DBGPRINT_RAW(RT_DEBUG_ERROR,
("Bulk Out MLME Failed, Status=%d!\n",
Status));
/* TODO: How to handle about the MLMEBulkOut failed issue. Need to resend the mgmt pkt? */
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
pAd->bulkResetPipeid =
(MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
}
}
pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags);
/* Reset MLME context flags */
pMLMEContext->IRPPending = FALSE;
pMLMEContext->InUse = FALSE;
pMLMEContext->bWaitingBulkOut = FALSE;
pMLMEContext->BulkOutSize = 0;
pPacket = pAd->MgmtRing.Cell[index].pNdisPacket;
pAd->MgmtRing.Cell[index].pNdisPacket = NULL;
/* Increase MgmtRing Index */
INC_RING_INDEX(pAd->MgmtRing.TxDmaIdx, MGMT_RING_SIZE);
pAd->MgmtRing.TxSwFreeIdx++;
RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags);
/* No-matter success or fail, we free the mgmt packet. */
if (pPacket)
RTMPFreeNdisPacket(pAd, pPacket);
if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
/* do nothing and return directly. */
} else {
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET) && ((pAd->bulkResetPipeid & BULKOUT_MGMT_RESET_FLAG) == BULKOUT_MGMT_RESET_FLAG)) { /* For Mgmt Bulk-Out failed, ignore it now. */
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
} else {
/* Always call Bulk routine, even reset bulk. */
/* The protection of rest bulk should be in BulkOut routine */
if (pAd->MgmtRing.TxSwFreeIdx <
MGMT_RING_SIZE
/* pMLMEContext->bWaitingBulkOut == TRUE */) {
RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
}
RTUSBKickBulkOut(pAd);
}
}
}
static void rtusb_ac3_dma_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_ht_tx_context *pHTTXContext;
u8 BulkOutPipeId = 3;
struct urb *pUrb;
pUrb = (struct urb *)data;
pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
pAd = pHTTXContext->pAd;
rtusb_dataout_complete((unsigned long)pUrb);
if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
/* do nothing and return directly. */
} else {
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
} else {
pHTTXContext = &pAd->TxContext[BulkOutPipeId];
if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
/*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
(pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
(pHTTXContext->bCurWriting == FALSE)) {
RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
MAX_TX_PROCESS);
}
RTUSB_SET_BULK_FLAG(pAd,
fRTUSB_BULK_OUT_DATA_NORMAL << 3);
RTUSBKickBulkOut(pAd);
}
}
return;
}
static void rtusb_ac2_dma_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_ht_tx_context *pHTTXContext;
u8 BulkOutPipeId = 2;
struct urb *pUrb;
pUrb = (struct urb *)data;
pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
pAd = pHTTXContext->pAd;
rtusb_dataout_complete((unsigned long)pUrb);
if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
/* do nothing and return directly. */
} else {
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
} else {
pHTTXContext = &pAd->TxContext[BulkOutPipeId];
if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
/*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
(pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
(pHTTXContext->bCurWriting == FALSE)) {
RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
MAX_TX_PROCESS);
}
RTUSB_SET_BULK_FLAG(pAd,
fRTUSB_BULK_OUT_DATA_NORMAL << 2);
RTUSBKickBulkOut(pAd);
}
}
return;
}
static void rtusb_ac1_dma_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_ht_tx_context *pHTTXContext;
u8 BulkOutPipeId = 1;
struct urb *pUrb;
pUrb = (struct urb *)data;
pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
pAd = pHTTXContext->pAd;
rtusb_dataout_complete((unsigned long)pUrb);
if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
/* do nothing and return directly. */
} else {
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
} else {
pHTTXContext = &pAd->TxContext[BulkOutPipeId];
if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
/*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
(pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
(pHTTXContext->bCurWriting == FALSE)) {
RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
MAX_TX_PROCESS);
}
RTUSB_SET_BULK_FLAG(pAd,
fRTUSB_BULK_OUT_DATA_NORMAL << 1);
RTUSBKickBulkOut(pAd);
}
}
return;
}
static void rtusb_ac0_dma_done_tasklet(unsigned long data)
{
struct rt_rtmp_adapter *pAd;
struct rt_ht_tx_context *pHTTXContext;
u8 BulkOutPipeId = 0;
struct urb *pUrb;
pUrb = (struct urb *)data;
pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
pAd = pHTTXContext->pAd;
rtusb_dataout_complete((unsigned long)pUrb);
if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
/* do nothing and return directly. */
} else {
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
NULL, 0);
} else {
pHTTXContext = &pAd->TxContext[BulkOutPipeId];
if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
/* ((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
(pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
(pHTTXContext->bCurWriting == FALSE)) {
RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
MAX_TX_PROCESS);
}
RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL);
RTUSBKickBulkOut(pAd);
}
}
return;
}
int RtmpNetTaskInit(struct rt_rtmp_adapter *pAd)
{
struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
/* Create receive tasklet */
tasklet_init(&pObj->rx_done_task, rx_done_tasklet, (unsigned long)pAd);
tasklet_init(&pObj->mgmt_dma_done_task, rtusb_mgmt_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac0_dma_done_task, rtusb_ac0_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac1_dma_done_task, rtusb_ac1_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac2_dma_done_task, rtusb_ac2_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->ac3_dma_done_task, rtusb_ac3_dma_done_tasklet,
(unsigned long)pAd);
tasklet_init(&pObj->tbtt_task, tbtt_tasklet, (unsigned long)pAd);
tasklet_init(&pObj->null_frame_complete_task,
rtusb_null_frame_done_tasklet, (unsigned long)pAd);
tasklet_init(&pObj->rts_frame_complete_task,
rtusb_rts_frame_done_tasklet, (unsigned long)pAd);
tasklet_init(&pObj->pspoll_frame_complete_task,
rtusb_pspoll_frame_done_tasklet, (unsigned long)pAd);
return NDIS_STATUS_SUCCESS;
}
void RtmpNetTaskExit(struct rt_rtmp_adapter *pAd)
{
struct os_cookie *pObj;
pObj = (struct os_cookie *)pAd->OS_Cookie;
tasklet_kill(&pObj->rx_done_task);
tasklet_kill(&pObj->mgmt_dma_done_task);
tasklet_kill(&pObj->ac0_dma_done_task);
tasklet_kill(&pObj->ac1_dma_done_task);
tasklet_kill(&pObj->ac2_dma_done_task);
tasklet_kill(&pObj->ac3_dma_done_task);
tasklet_kill(&pObj->tbtt_task);
tasklet_kill(&pObj->null_frame_complete_task);
tasklet_kill(&pObj->rts_frame_complete_task);
tasklet_kill(&pObj->pspoll_frame_complete_task);
}

File diff suppressed because it is too large Load diff

View file

@ -1,258 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_chip.h
Abstract:
Ralink Wireless Chip related definition & structures
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifndef __RTMP_CHIP_H__
#define __RTMP_CHIP_H__
#include "rtmp_type.h"
#ifdef RT2860
#include "chip/rt2860.h"
#endif /* RT2860 // */
#ifdef RT2870
#include "chip/rt2870.h"
#endif /* RT2870 // */
#ifdef RT3070
#include "chip/rt3070.h"
#endif /* RT3070 // */
#ifdef RT3090
#include "chip/rt3090.h"
#endif /* RT3090 // */
/* We will have a cost down version which mac version is 0x3090xxxx */
/* */
/* RT3090A facts */
/* */
/* a) 2.4 GHz */
/* b) Replacement for RT3090 */
/* c) Internal LNA */
/* d) Interference over channel #14 */
/* e) New BBP features (e.g., SIG re-modulation) */
/* */
#define IS_RT3090A(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30900000))
/* We will have a cost down version which mac version is 0x3090xxxx */
#define IS_RT3090(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (IS_RT3090A(_pAd)))
#define IS_RT3070(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30700000)
#define IS_RT3071(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30710000)
#define IS_RT2070(_pAd) (((_pAd)->RfIcType == RFIC_2020) || ((_pAd)->EFuseTag == 0x27))
#define IS_RT30xx(_pAd) (((_pAd)->MACVersion & 0xfff00000) == 0x30700000||IS_RT3090A(_pAd))
/*#define IS_RT305X(_pAd) ((_pAd)->MACVersion == 0x28720200) */
/* RT3572, 3592, 3562, 3062 share the same MAC version */
#define IS_RT3572(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x35720000)
#define IS_VERSION_BEFORE_F(_pAd) (((_pAd)->MACVersion&0xffff) <= 0x0211)
/* F version is 0x0212, E version is 0x0211. 309x can save more power after F version. */
#define IS_VERSION_AFTER_F(_pAd) ((((_pAd)->MACVersion&0xffff) >= 0x0212) || (((_pAd)->b3090ESpecialChip == TRUE)))
/* */
/* RT3390 facts */
/* */
/* a) Base on RT3090 (RF IC: RT3020) */
/* b) 2.4 GHz */
/* c) 1x1 */
/* d) Single chip */
/* e) Internal components: PA and LNA */
/* */
/*RT3390,RT3370 */
#define IS_RT3390(_pAd) (((_pAd)->MACVersion & 0xFFFF0000) == 0x33900000)
/* ------------------------------------------------------ */
/* PCI registers - base address 0x0000 */
/* ------------------------------------------------------ */
#define CHIP_PCI_CFG 0x0000
#define CHIP_PCI_EECTRL 0x0004
#define CHIP_PCI_MCUCTRL 0x0008
#define OPT_14 0x114
#define RETRY_LIMIT 10
/* ------------------------------------------------------ */
/* BBP & RF definition */
/* ------------------------------------------------------ */
#define BUSY 1
#define IDLE 0
/*------------------------------------------------------------------------- */
/* EEPROM definition */
/*------------------------------------------------------------------------- */
#define EEDO 0x08
#define EEDI 0x04
#define EECS 0x02
#define EESK 0x01
#define EERL 0x80
#define EEPROM_WRITE_OPCODE 0x05
#define EEPROM_READ_OPCODE 0x06
#define EEPROM_EWDS_OPCODE 0x10
#define EEPROM_EWEN_OPCODE 0x13
#define NUM_EEPROM_BBP_PARMS 19 /* Include NIC Config 0, 1, CR, TX ALC step, BBPs */
#define NUM_EEPROM_TX_G_PARMS 7
#define EEPROM_NIC1_OFFSET 0x34 /* The address is from NIC config 0, not BBP register ID */
#define EEPROM_NIC2_OFFSET 0x36 /* The address is from NIC config 0, not BBP register ID */
#define EEPROM_BBP_BASE_OFFSET 0xf0 /* The address is from NIC config 0, not BBP register ID */
#define EEPROM_G_TX_PWR_OFFSET 0x52
#define EEPROM_G_TX2_PWR_OFFSET 0x60
#define EEPROM_LED1_OFFSET 0x3c
#define EEPROM_LED2_OFFSET 0x3e
#define EEPROM_LED3_OFFSET 0x40
#define EEPROM_LNA_OFFSET 0x44
#define EEPROM_RSSI_BG_OFFSET 0x46
#define EEPROM_TXMIXER_GAIN_2_4G 0x48
#define EEPROM_RSSI_A_OFFSET 0x4a
#define EEPROM_TXMIXER_GAIN_5G 0x4c
#define EEPROM_DEFINE_MAX_TXPWR 0x4e
#define EEPROM_TXPOWER_BYRATE_20MHZ_2_4G 0xde /* 20MHZ 2.4G tx power. */
#define EEPROM_TXPOWER_BYRATE_40MHZ_2_4G 0xee /* 40MHZ 2.4G tx power. */
#define EEPROM_TXPOWER_BYRATE_20MHZ_5G 0xfa /* 20MHZ 5G tx power. */
#define EEPROM_TXPOWER_BYRATE_40MHZ_5G 0x10a /* 40MHZ 5G tx power. */
#define EEPROM_A_TX_PWR_OFFSET 0x78
#define EEPROM_A_TX2_PWR_OFFSET 0xa6
/*#define EEPROM_Japan_TX_PWR_OFFSET 0x90 // 802.11j */
/*#define EEPROM_Japan_TX2_PWR_OFFSET 0xbe */
/*#define EEPROM_TSSI_REF_OFFSET 0x54 */
/*#define EEPROM_TSSI_DELTA_OFFSET 0x24 */
/*#define EEPROM_CCK_TX_PWR_OFFSET 0x62 */
/*#define EEPROM_CALIBRATE_OFFSET 0x7c */
#define EEPROM_VERSION_OFFSET 0x02
#define EEPROM_FREQ_OFFSET 0x3a
#define EEPROM_TXPOWER_BYRATE 0xde /* 20MHZ power. */
#define EEPROM_TXPOWER_DELTA 0x50 /* 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ. */
#define VALID_EEPROM_VERSION 1
/*
* EEPROM operation related marcos
*/
#define RT28xx_EEPROM_READ16(_pAd, _offset, _value) \
(_pAd)->chipOps.eeread((struct rt_rtmp_adapter *)(_pAd), (u16)(_offset), (u16 *)&(_value))
/* ------------------------------------------------------------------- */
/* E2PROM data layout */
/* ------------------------------------------------------------------- */
/* */
/* MCU_LEDCS: MCU LED Control Setting. */
/* */
typedef union _MCU_LEDCS_STRUC {
struct {
u8 LedMode:7;
u8 Polarity:1;
} field;
u8 word;
} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
/* */
/* EEPROM antenna select format */
/* */
typedef union _EEPROM_ANTENNA_STRUC {
struct {
u16 RxPath:4; /* 1: 1R, 2: 2R, 3: 3R */
u16 TxPath:4; /* 1: 1T, 2: 2T */
u16 RfIcType:4; /* see E2PROM document */
u16 Rsv:4;
} field;
u16 word;
} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
typedef union _EEPROM_NIC_CINFIG2_STRUC {
struct {
u16 HardwareRadioControl:1; /* 1:enable, 0:disable */
u16 DynamicTxAgcControl:1; /* */
u16 ExternalLNAForG:1; /* */
u16 ExternalLNAForA:1; /* external LNA enable for 2.4G */
u16 CardbusAcceleration:1; /* ! NOTE: 0 - enable, 1 - disable */
u16 BW40MSidebandForG:1;
u16 BW40MSidebandForA:1;
u16 EnableWPSPBC:1; /* WPS PBC Control bit */
u16 BW40MAvailForG:1; /* 0:enable, 1:disable */
u16 BW40MAvailForA:1; /* 0:enable, 1:disable */
u16 Rsv1:1; /* must be 0 */
u16 AntDiversity:1; /* Antenna diversity */
u16 Rsv2:3; /* must be 0 */
u16 DACTestBit:1; /* control if driver should patch the DAC issue */
} field;
u16 word;
} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
/* */
/* TX_PWR Value valid range 0xFA(-6) ~ 0x24(36) */
/* */
typedef union _EEPROM_TX_PWR_STRUC {
struct {
char Byte0; /* Low Byte */
char Byte1; /* High Byte */
} field;
u16 word;
} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
typedef union _EEPROM_VERSION_STRUC {
struct {
u8 FaeReleaseNumber; /* Low Byte */
u8 Version; /* High Byte */
} field;
u16 word;
} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
typedef union _EEPROM_LED_STRUC {
struct {
u16 PolarityRDY_G:1; /* Polarity RDY_G setting. */
u16 PolarityRDY_A:1; /* Polarity RDY_A setting. */
u16 PolarityACT:1; /* Polarity ACT setting. */
u16 PolarityGPIO_0:1; /* Polarity GPIO#0 setting. */
u16 PolarityGPIO_1:1; /* Polarity GPIO#1 setting. */
u16 PolarityGPIO_2:1; /* Polarity GPIO#2 setting. */
u16 PolarityGPIO_3:1; /* Polarity GPIO#3 setting. */
u16 PolarityGPIO_4:1; /* Polarity GPIO#4 setting. */
u16 LedMode:5; /* Led mode. */
u16 Rsvd:3; /* Reserved */
} field;
u16 word;
} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
typedef union _EEPROM_TXPOWER_DELTA_STRUC {
struct {
u8 DeltaValue:6; /* Tx Power dalta value (MAX=4) */
u8 Type:1; /* 1: plus the delta value, 0: minus the delta value */
u8 TxPowerEnable:1; /* Enable */
} field;
u8 value;
} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
#endif /* __RTMP_CHIP_H__ // */

View file

@ -1,63 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_ckipmic.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
*/
#ifndef __RTMP_CKIPMIC_H__
#define __RTMP_CKIPMIC_H__
struct rt_mic_context {
/* --- MMH context */
u8 CK[16]; /* the key */
u8 coefficient[16]; /* current aes counter mode coefficients */
unsigned long long accum; /* accumulated mic, reduced to u32 in final() */
u32 position; /* current position (byte offset) in message */
u8 part[4]; /* for conversion of message to u32 for mmh */
};
void xor_128(u8 *a, u8 *b, u8 *out);
u8 RTMPCkipSbox(u8 a);
void xor_32(u8 *a, u8 *b, u8 *out);
void next_key(u8 *key, int round);
void byte_sub(u8 *in, u8 *out);
void shift_row(u8 *in, u8 *out);
void mix_column(u8 *in, u8 *out);
#endif /*__RTMP_CKIPMIC_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,100 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __DOT11_BASE_H__
#define __DOT11_BASE_H__
#include "rtmp_type.h"
/* 4-byte HTC field. maybe included in any frame except non-QOS data frame. The Order bit must set 1. */
struct PACKED rt_ht_control {
u32 MA:1; /*management action payload exist in (QoS Null+HTC) */
u32 TRQ:1; /*sounding request */
u32 MRQ:1; /*MCS feedback. Request for a MCS feedback */
u32 MRSorASI:3; /* MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110. */
u32 MFS:3; /*SET to the received value of MRS. 0x111 for unsolicited MFB. */
u32 MFBorASC:7; /*Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available */
u32 CalPos:2; /* calibration position */
u32 CalSeq:2; /*calibration sequence */
u32 FBKReq:2; /*feedback request */
u32 CSISTEERING:2; /*CSI/ STEERING */
u32 ZLFAnnouce:1; /* ZLF announcement */
u32 rsv:5; /*calibration sequence */
u32 ACConstraint:1; /*feedback request */
u32 RDG:1; /*RDG / More PPDU */
};
/* 2-byte QOS CONTROL field */
struct PACKED rt_qos_control {
u16 TID:4;
u16 EOSP:1;
u16 AckPolicy:2; /*0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA */
u16 AMsduPresent:1;
u16 Txop_QueueSize:8;
};
/* 2-byte Frame control field */
struct PACKED rt_frame_control {
u16 Ver:2; /* Protocol version */
u16 Type:2; /* MSDU type */
u16 SubType:4; /* MSDU subtype */
u16 ToDs:1; /* To DS indication */
u16 FrDs:1; /* From DS indication */
u16 MoreFrag:1; /* More fragment bit */
u16 Retry:1; /* Retry status bit */
u16 PwrMgmt:1; /* Power management bit */
u16 MoreData:1; /* More data bit */
u16 Wep:1; /* Wep data */
u16 Order:1; /* Strict order expected */
};
struct PACKED rt_header_802_11 {
struct rt_frame_control FC;
u16 Duration;
u8 Addr1[MAC_ADDR_LEN];
u8 Addr2[MAC_ADDR_LEN];
u8 Addr3[MAC_ADDR_LEN];
u16 Frag:4;
u16 Sequence:12;
u8 Octet[0];
};
struct PACKED rt_pspoll_frame {
struct rt_frame_control FC;
u16 Aid;
u8 Bssid[MAC_ADDR_LEN];
u8 Ta[MAC_ADDR_LEN];
};
struct PACKED rt_rts_frame {
struct rt_frame_control FC;
u16 Duration;
u8 Addr1[MAC_ADDR_LEN];
u8 Addr2[MAC_ADDR_LEN];
};
#endif /* __DOT11_BASE_H__ // */

View file

@ -1,75 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_iface.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RTMP_IFACE_H__
#define __RTMP_IFACE_H__
#ifdef RTMP_PCI_SUPPORT
#include "iface/rtmp_pci.h"
#endif /* RTMP_PCI_SUPPORT // */
#ifdef RTMP_USB_SUPPORT
#include "iface/rtmp_usb.h"
#endif /* RTMP_USB_SUPPORT // */
struct rt_inf_pci_config {
unsigned long CSRBaseAddress; /* PCI MMIO Base Address, all access will use */
unsigned int irq_num;
};
struct rt_inf_usb_config {
u8 BulkInEpAddr; /* bulk-in endpoint address */
u8 BulkOutEpAddr[6]; /* bulk-out endpoint address */
};
struct rt_inf_rbus_config {
unsigned long csr_addr;
unsigned int irq;
};
typedef enum _RTMP_INF_TYPE_ {
RTMP_DEV_INF_UNKNOWN = 0,
RTMP_DEV_INF_PCI = 1,
RTMP_DEV_INF_USB = 2,
RTMP_DEV_INF_RBUS = 4,
} RTMP_INF_TYPE;
typedef union _RTMP_INF_CONFIG_ {
struct rt_inf_pci_config pciConfig;
struct rt_inf_usb_config usbConfig;
struct rt_inf_rbus_config rbusConfig;
} RTMP_INF_CONFIG;
#endif /* __RTMP_IFACE_H__ // */

View file

@ -1,49 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_mcu.h
Abstract:
Miniport header file for mcu related information
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifndef __RTMP_MCU_H__
#define __RTMP_MCU_H__
int RtmpAsicEraseFirmware(struct rt_rtmp_adapter *pAd);
int RtmpAsicLoadFirmware(struct rt_rtmp_adapter *pAd);
int RtmpAsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
u8 Command,
u8 Token, u8 Arg0, u8 Arg1);
#endif /* __RTMP_MCU_H__ // */

View file

@ -1,90 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_os.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RTMP_OS_H__
#define __RTMP_OS_H__
#ifdef LINUX
#include "rt_linux.h"
#endif /* LINUX // */
/*
This data structure mainly strip some callback function defined in
"struct net_device" in kernel source "include/linux/netdevice.h".
The definition of this data structure may various depends on different
OS. Use it carefully.
*/
struct rt_rtmp_os_netdev_op_hook {
const struct net_device_ops *netdev_ops;
void *priv;
int priv_flags;
unsigned char devAddr[6];
unsigned char devName[16];
unsigned char needProtcted;
};
typedef enum _RTMP_TASK_STATUS_ {
RTMP_TASK_STAT_UNKNOWN = 0,
RTMP_TASK_STAT_INITED = 1,
RTMP_TASK_STAT_RUNNING = 2,
RTMP_TASK_STAT_STOPED = 4,
} RTMP_TASK_STATUS;
#define RTMP_TASK_CAN_DO_INSERT (RTMP_TASK_STAT_INITED |RTMP_TASK_STAT_RUNNING)
#define RTMP_OS_TASK_NAME_LEN 16
struct rt_rtmp_os_task {
char taskName[RTMP_OS_TASK_NAME_LEN];
void *priv;
/*unsigned long taskFlags; */
RTMP_TASK_STATUS taskStatus;
#ifndef KTHREAD_SUPPORT
struct semaphore taskSema;
struct pid *taskPID;
struct completion taskComplete;
#endif
unsigned char task_killed;
#ifdef KTHREAD_SUPPORT
struct task_struct *kthread_task;
wait_queue_head_t kthread_q;
BOOLEAN kthread_running;
#endif
};
int RtmpOSIRQRequest(struct net_device *pNetDev);
int RtmpOSIRQRelease(struct net_device *pNetDev);
#endif /* __RMTP_OS_H__ // */

View file

@ -1,148 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_timer.h
Abstract:
Ralink Wireless Driver timer related data structures and declarations
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Shiang Tu Aug-28-2008 init version
Justin P. Mattock 11/07/2010 Fix a typo
*/
#ifndef __RTMP_TIMER_H__
#define __RTMP_TIMER_H__
#include "rtmp_os.h"
#define DECLARE_TIMER_FUNCTION(_func) \
void rtmp_timer_##_func(unsigned long data)
#define GET_TIMER_FUNCTION(_func) \
rtmp_timer_##_func
/* ----------------- Timer Related MARCO ---------------*/
/* In some os or chipset, we have a lot of timer functions and will read/write register, */
/* it's not allowed in Linux USB sub-system to do it ( because of sleep issue when */
/* submit to ctrl pipe). So we need a wrapper function to take care it. */
#ifdef RTMP_TIMER_TASK_SUPPORT
typedef void(*RTMP_TIMER_TASK_HANDLE) (void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2,
void *SystemSpecific3);
#endif /* RTMP_TIMER_TASK_SUPPORT // */
struct rt_ralink_timer {
struct timer_list TimerObj; /* Ndis Timer object */
BOOLEAN Valid; /* Set to True when call RTMPInitTimer */
BOOLEAN State; /* True if timer cancelled */
BOOLEAN PeriodicType; /* True if timer is periodic timer */
BOOLEAN Repeat; /* True if periodic timer */
unsigned long TimerValue; /* Timer value in milliseconds */
unsigned long cookie; /* os specific object */
#ifdef RTMP_TIMER_TASK_SUPPORT
RTMP_TIMER_TASK_HANDLE handle;
void *pAd;
#endif /* RTMP_TIMER_TASK_SUPPORT // */
};
#ifdef RTMP_TIMER_TASK_SUPPORT
struct rt_rtmp_timer_task_entry {
struct rt_ralink_timer *pRaTimer;
struct rt_rtmp_timer_task_entry *pNext;
};
#define TIMER_QUEUE_SIZE_MAX 128
struct rt_rtmp_timer_task_queue {
unsigned int status;
unsigned char *pTimerQPoll;
struct rt_rtmp_timer_task_entry *pQPollFreeList;
struct rt_rtmp_timer_task_entry *pQHead;
struct rt_rtmp_timer_task_entry *pQTail;
};
#define BUILD_TIMER_FUNCTION(_func) \
void rtmp_timer_##_func(unsigned long data) \
{ \
struct rt_ralink_timer *_pTimer = (struct rt_ralink_timer *)data; \
struct rt_rtmp_timer_task_entry *_pQNode; \
struct rt_rtmp_adapter *_pAd; \
\
_pTimer->handle = _func; \
_pAd = (struct rt_rtmp_adapter *)_pTimer->pAd; \
_pQNode = RtmpTimerQInsert(_pAd, _pTimer); \
if ((_pQNode == NULL) && (_pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT)) \
RTMP_OS_Add_Timer(&_pTimer->TimerObj, OS_HZ); \
}
#else
#define BUILD_TIMER_FUNCTION(_func) \
void rtmp_timer_##_func(unsigned long data) \
{ \
struct rt_ralink_timer *pTimer = (struct rt_ralink_timer *)data; \
\
_func(NULL, (void *)pTimer->cookie, NULL, pTimer); \
if (pTimer->Repeat) \
RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \
}
#endif /* RTMP_TIMER_TASK_SUPPORT // */
DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
#ifdef RTMP_MAC_USB
DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
#endif /* RTMP_MAC_USB // */
DECLARE_TIMER_FUNCTION(BeaconTimeout);
DECLARE_TIMER_FUNCTION(ScanTimeout);
DECLARE_TIMER_FUNCTION(AuthTimeout);
DECLARE_TIMER_FUNCTION(AssocTimeout);
DECLARE_TIMER_FUNCTION(ReassocTimeout);
DECLARE_TIMER_FUNCTION(DisassocTimeout);
DECLARE_TIMER_FUNCTION(LinkDownExec);
DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
DECLARE_TIMER_FUNCTION(PsPollWakeExec);
DECLARE_TIMER_FUNCTION(RadioOnExec);
#ifdef RTMP_MAC_USB
DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
#endif /* RTMP_MAC_USB // */
#if defined(AP_LED) || defined(STA_LED)
DECLARE_TIMER_FUNCTION(LedCtrlMain);
#endif
#endif /* __RTMP_TIMER_H__ // */

View file

@ -1,89 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_type.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Paul Lin 1-2-2004
*/
#ifndef __RTMP_TYPE_H__
#define __RTMP_TYPE_H__
#include <linux/types.h>
#define PACKED __attribute__ ((packed))
typedef unsigned char BOOLEAN;
typedef union _LARGE_INTEGER {
struct {
u32 LowPart;
int HighPart;
} u;
long long QuadPart;
} LARGE_INTEGER;
/* */
/* Register set pair for initialzation register set definition */
/* */
struct rt_rtmp_reg_pair {
unsigned long Register;
unsigned long Value;
};
struct rt_reg_pair {
u8 Register;
u8 Value;
};
/* */
/* Register set pair for initialzation register set definition */
/* */
struct rt_rtmp_rf_regs {
u8 Channel;
unsigned long R1;
unsigned long R2;
unsigned long R3;
unsigned long R4;
};
struct rt_frequency_item {
u8 Channel;
u8 N;
u8 R;
u8 K;
};
#define STATUS_SUCCESS 0x00
#define STATUS_UNSUCCESSFUL 0x01
#endif /* __RTMP_TYPE_H__ // */

View file

@ -1,185 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __RTUSB_IO_H__
#define __RTUSB_IO_H__
#include "rtmp_type.h"
/* New for MeetingHouse Api support */
#define CMDTHREAD_VENDOR_RESET 0x0D730101 /* cmd */
#define CMDTHREAD_VENDOR_UNPLUG 0x0D730102 /* cmd */
#define CMDTHREAD_VENDOR_SWITCH_FUNCTION 0x0D730103 /* cmd */
#define CMDTHREAD_MULTI_WRITE_MAC 0x0D730107 /* cmd */
#define CMDTHREAD_MULTI_READ_MAC 0x0D730108 /* cmd */
#define CMDTHREAD_VENDOR_EEPROM_WRITE 0x0D73010A /* cmd */
#define CMDTHREAD_VENDOR_EEPROM_READ 0x0D73010B /* cmd */
#define CMDTHREAD_VENDOR_ENTER_TESTMODE 0x0D73010C /* cmd */
#define CMDTHREAD_VENDOR_EXIT_TESTMODE 0x0D73010D /* cmd */
#define CMDTHREAD_VENDOR_WRITE_BBP 0x0D730119 /* cmd */
#define CMDTHREAD_VENDOR_READ_BBP 0x0D730118 /* cmd */
#define CMDTHREAD_VENDOR_WRITE_RF 0x0D73011A /* cmd */
#define CMDTHREAD_VENDOR_FLIP_IQ 0x0D73011D /* cmd */
#define CMDTHREAD_RESET_BULK_OUT 0x0D730210 /* cmd */
#define CMDTHREAD_RESET_BULK_IN 0x0D730211 /* cmd */
#define CMDTHREAD_SET_PSM_BIT 0x0D730212 /* cmd */
#define CMDTHREAD_SET_RADIO 0x0D730214 /* cmd */
#define CMDTHREAD_UPDATE_TX_RATE 0x0D730216 /* cmd */
#define CMDTHREAD_802_11_ADD_KEY_WEP 0x0D730218 /* cmd */
#define CMDTHREAD_RESET_FROM_ERROR 0x0D73021A /* cmd */
#define CMDTHREAD_LINK_DOWN 0x0D73021B /* cmd */
#define CMDTHREAD_RESET_FROM_NDIS 0x0D73021C /* cmd */
#define CMDTHREAD_CHECK_GPIO 0x0D730215 /* cmd */
#define CMDTHREAD_FORCE_WAKE_UP 0x0D730222 /* cmd */
#define CMDTHREAD_SET_BW 0x0D730225 /* cmd */
#define CMDTHREAD_SET_ASIC_WCID 0x0D730226 /* cmd */
#define CMDTHREAD_SET_ASIC_WCID_CIPHER 0x0D730227 /* cmd */
#define CMDTHREAD_QKERIODIC_EXECUT 0x0D73023D /* cmd */
#define RT_CMD_SET_KEY_TABLE 0x0D730228 /* cmd */
#define RT_CMD_SET_RX_WCID_TABLE 0x0D730229 /* cmd */
#define CMDTHREAD_SET_CLIENT_MAC_ENTRY 0x0D73023E /* cmd */
#define CMDTHREAD_SET_GROUP_KEY 0x0D73023F /* cmd */
#define CMDTHREAD_SET_PAIRWISE_KEY 0x0D730240 /* cmd */
#define CMDTHREAD_802_11_QUERY_HARDWARE_REGISTER 0x0D710105 /* cmd */
#define CMDTHREAD_802_11_SET_PHY_MODE 0x0D79010C /* cmd */
#define CMDTHREAD_802_11_SET_STA_CONFIG 0x0D790111 /* cmd */
#define CMDTHREAD_802_11_SET_PREAMBLE 0x0D790101 /* cmd */
#define CMDTHREAD_802_11_COUNTER_MEASURE 0x0D790102 /* cmd */
/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
#define CMDTHREAD_UPDATE_PROTECT 0x0D790103 /* cmd */
/* end johnli */
/*CMDTHREAD_MULTI_READ_MAC */
/*CMDTHREAD_MULTI_WRITE_MAC */
/*CMDTHREAD_VENDOR_EEPROM_READ */
/*CMDTHREAD_VENDOR_EEPROM_WRITE */
struct rt_cmdhandler_tlv {
u16 Offset;
u16 Length;
u8 DataFirst;
};
struct rt_cmdqelmt;
struct rt_cmdqelmt {
u32 command;
void *buffer;
unsigned long bufferlength;
BOOLEAN CmdFromNdis;
BOOLEAN SetOperation;
struct rt_cmdqelmt *next;
};
struct rt_cmdq {
u32 size;
struct rt_cmdqelmt *head;
struct rt_cmdqelmt *tail;
u32 CmdQState;
};
#define EnqueueCmd(cmdq, cmdqelmt) \
{ \
if (cmdq->size == 0) \
cmdq->head = cmdqelmt; \
else \
cmdq->tail->next = cmdqelmt; \
cmdq->tail = cmdqelmt; \
cmdqelmt->next = NULL; \
cmdq->size++; \
}
/******************************************************************************
USB Cmd to ASIC Related MACRO
******************************************************************************/
/* reset MAC of a station entry to 0xFFFFFFFFFFFF */
#define RTMP_STA_ENTRY_MAC_RESET(pAd, Wcid) \
{ struct rt_set_asic_wcid SetAsicWcid; \
SetAsicWcid.WCID = Wcid; \
SetAsicWcid.SetTid = 0xffffffff; \
SetAsicWcid.DeleteTid = 0xffffffff; \
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID, \
&SetAsicWcid, sizeof(struct rt_set_asic_wcid)); }
/* add this entry into ASIC RX WCID search table */
#define RTMP_STA_ENTRY_ADD(pAd, pEntry) \
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_CLIENT_MAC_ENTRY, \
pEntry, sizeof(struct rt_mac_table_entry));
/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
/* Set MAC register value according operation mode */
#define RTMP_UPDATE_PROTECT(pAd) \
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_UPDATE_PROTECT, NULL, 0);
/* end johnli */
/* remove Pair-wise key material from ASIC */
/* yet implement */
#define RTMP_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid)
/* add Client security information into ASIC WCID table and IVEIV table */
#define RTMP_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry) \
{ RTMP_STA_ENTRY_MAC_RESET(pAd, pEntry->Aid); \
if (pEntry->Aid >= 1) { \
struct rt_set_asic_wcid_attri SetAsicWcidAttri; \
SetAsicWcidAttri.WCID = pEntry->Aid; \
if ((pEntry->AuthMode <= Ndis802_11AuthModeAutoSwitch) && \
(pEntry->WepStatus == Ndis802_11Encryption1Enabled)) \
{ \
SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg; \
} \
else if (pEntry->AuthMode == Ndis802_11AuthModeWPANone) \
{ \
SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg; \
} \
else SetAsicWcidAttri.Cipher = 0; \
DBGPRINT(RT_DEBUG_TRACE, ("aid cipher = %ld\n",SetAsicWcidAttri.Cipher)); \
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID_CIPHER, \
&SetAsicWcidAttri, sizeof(struct rt_set_asic_wcid_attri)); } }
/* Insert the BA bitmap to ASIC for the Wcid entry */
#define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID) \
do{ \
struct rt_set_asic_wcid SetAsicWcid; \
SetAsicWcid.WCID = (_Aid); \
SetAsicWcid.SetTid = (0x10000<<(_TID)); \
SetAsicWcid.DeleteTid = 0xffffffff; \
RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(struct rt_set_asic_wcid)); \
}while(0)
/* Remove the BA bitmap from ASIC for the Wcid entry */
#define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID) \
do{ \
struct rt_set_asic_wcid SetAsicWcid; \
SetAsicWcid.WCID = (_Wcid); \
SetAsicWcid.SetTid = (0xffffffff); \
SetAsicWcid.DeleteTid = (0x10000<<(_TID) ); \
RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(struct rt_set_asic_wcid)); \
}while(0)
#endif /* __RTUSB_IO_H__ // */

View file

@ -1,189 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __SPECTRUM_H__
#define __SPECTRUM_H__
#include "rtmp_type.h"
#include "spectrum_def.h"
char RTMP_GetTxPwr(struct rt_rtmp_adapter *pAd, IN HTTRANSMIT_SETTING HTTxMode);
/*
==========================================================================
Description:
Prepare Measurement request action frame and enqueue it into
management queue waiting for transmission.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
void MakeMeasurementReqFrame(struct rt_rtmp_adapter *pAd,
u8 *pOutBuffer,
unsigned long *pFrameLen,
u8 TotalLen,
u8 Category,
u8 Action,
u8 MeasureToken,
u8 MeasureReqMode,
u8 MeasureReqType,
u8 NumOfRepetitions);
/*
==========================================================================
Description:
Prepare Measurement report action frame and enqueue it into
management queue waiting for transmission.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
void EnqueueMeasurementRep(struct rt_rtmp_adapter *pAd,
u8 *pDA,
u8 DialogToken,
u8 MeasureToken,
u8 MeasureReqMode,
u8 MeasureReqType,
u8 ReportInfoLen, u8 *pReportInfo);
/*
==========================================================================
Description:
Prepare TPC Request action frame and enqueue it into
management queue waiting for transmission.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
void EnqueueTPCReq(struct rt_rtmp_adapter *pAd, u8 *pDA, u8 DialogToken);
/*
==========================================================================
Description:
Prepare TPC Report action frame and enqueue it into
management queue waiting for transmission.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
void EnqueueTPCRep(struct rt_rtmp_adapter *pAd,
u8 *pDA,
u8 DialogToken, u8 TxPwr, u8 LinkMargin);
/*
==========================================================================
Description:
Prepare Channel Switch Announcement action frame and enqueue it into
management queue waiting for transmission.
Parametrs:
1. the destination mac address of the frame.
2. Channel switch announcement mode.
2. a New selected channel.
Return : None.
==========================================================================
*/
void EnqueueChSwAnn(struct rt_rtmp_adapter *pAd,
u8 *pDA, u8 ChSwMode, u8 NewCh);
/*
==========================================================================
Description:
Spectrun action frames Handler such as channel switch announcement,
measurement report, measurement request actions frames.
Parametrs:
Elme - MLME message containing the received frame
Return : None.
==========================================================================
*/
void PeerSpectrumAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
/*
==========================================================================
Description:
Parametrs:
Return : None.
==========================================================================
*/
int Set_MeasureReq_Proc(struct rt_rtmp_adapter *pAd, char *arg);
int Set_TpcReq_Proc(struct rt_rtmp_adapter *pAd, char *arg);
int Set_PwrConstraint(struct rt_rtmp_adapter *pAd, char *arg);
void MeasureReqTabInit(struct rt_rtmp_adapter *pAd);
void MeasureReqTabExit(struct rt_rtmp_adapter *pAd);
struct rt_measure_req_entry *MeasureReqLookUp(struct rt_rtmp_adapter *pAd, u8 DialogToken);
struct rt_measure_req_entry *MeasureReqInsert(struct rt_rtmp_adapter *pAd, u8 DialogToken);
void MeasureReqDelete(struct rt_rtmp_adapter *pAd, u8 DialogToken);
void InsertChannelRepIE(struct rt_rtmp_adapter *pAd,
u8 *pFrameBuf,
unsigned long *pFrameLen,
char *pCountry, u8 RegulatoryClass);
void InsertTpcReportIE(struct rt_rtmp_adapter *pAd,
u8 *pFrameBuf,
unsigned long *pFrameLen,
u8 TxPwr, u8 LinkMargin);
void InsertDialogToken(struct rt_rtmp_adapter *pAd,
u8 *pFrameBuf,
unsigned long *pFrameLen, u8 DialogToken);
void TpcReqTabInit(struct rt_rtmp_adapter *pAd);
void TpcReqTabExit(struct rt_rtmp_adapter *pAd);
void NotifyChSwAnnToPeerAPs(struct rt_rtmp_adapter *pAd,
u8 *pRA,
u8 *pTA, u8 ChSwMode, u8 Channel);
void RguClass_BuildBcnChList(struct rt_rtmp_adapter *pAd,
u8 *pBuf, unsigned long *pBufLen);
#endif /* __SPECTRUM_H__ // */

View file

@ -1,202 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
spectrum_def.h
Abstract:
Handle association related requests either from WSTA or from local MLME
Revision History:
Who When What
--------- ---------- ----------------------------------------------
Fonchi Wu 2008 created for 802.11h
*/
#ifndef __SPECTRUM_DEF_H__
#define __SPECTRUM_DEF_H__
#define MAX_MEASURE_REQ_TAB_SIZE 32
#define MAX_HASH_MEASURE_REQ_TAB_SIZE MAX_MEASURE_REQ_TAB_SIZE
#define MAX_TPC_REQ_TAB_SIZE 32
#define MAX_HASH_TPC_REQ_TAB_SIZE MAX_TPC_REQ_TAB_SIZE
#define MIN_RCV_PWR 100 /* Negative value ((dBm) */
#define TPC_REQ_AGE_OUT 500 /* ms */
#define MQ_REQ_AGE_OUT 500 /* ms */
#define TPC_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_HASH_TPC_REQ_TAB_SIZE)
#define MQ_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_MEASURE_REQ_TAB_SIZE)
struct rt_measure_req_entry;
struct rt_measure_req_entry {
struct rt_measure_req_entry *pNext;
unsigned long lastTime;
BOOLEAN Valid;
u8 DialogToken;
u8 MeasureDialogToken[3]; /* 0:basic measure, 1: CCA measure, 2: RPI_Histogram measure. */
};
struct rt_measure_req_tab {
u8 Size;
struct rt_measure_req_entry *Hash[MAX_HASH_MEASURE_REQ_TAB_SIZE];
struct rt_measure_req_entry Content[MAX_MEASURE_REQ_TAB_SIZE];
};
struct rt_tpc_req_entry;
struct rt_tpc_req_entry {
struct rt_tpc_req_entry *pNext;
unsigned long lastTime;
BOOLEAN Valid;
u8 DialogToken;
};
struct rt_tpc_req_tab {
u8 Size;
struct rt_tpc_req_entry *Hash[MAX_HASH_TPC_REQ_TAB_SIZE];
struct rt_tpc_req_entry Content[MAX_TPC_REQ_TAB_SIZE];
};
/* The regulatory information */
struct rt_dot11_channel_set {
u8 NumberOfChannels;
u8 MaxTxPwr;
u8 ChannelList[16];
};
struct rt_dot11_regulatory_information {
u8 RegulatoryClass;
struct rt_dot11_channel_set ChannelSet;
};
#define RM_TPC_REQ 0
#define RM_MEASURE_REQ 1
#define RM_BASIC 0
#define RM_CCA 1
#define RM_RPI_HISTOGRAM 2
#define RM_CH_LOAD 3
#define RM_NOISE_HISTOGRAM 4
struct PACKED rt_tpc_report_info {
u8 TxPwr;
u8 LinkMargin;
};
struct PACKED rt_ch_sw_ann_info {
u8 ChSwMode;
u8 Channel;
u8 ChSwCnt;
};
typedef union PACKED _MEASURE_REQ_MODE {
struct PACKED {
u8 Parallel:1;
u8 Enable:1;
u8 Request:1;
u8 Report:1;
u8 DurationMandatory:1;
u8:3;
} field;
u8 word;
} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
struct PACKED rt_measure_req {
u8 ChNum;
u64 MeasureStartTime;
u16 MeasureDuration;
};
struct PACKED rt_measure_req_info {
u8 Token;
MEASURE_REQ_MODE ReqMode;
u8 ReqType;
u8 Oct[0];
};
typedef union PACKED _MEASURE_BASIC_REPORT_MAP {
struct PACKED {
u8 BSS:1;
u8 OfdmPreamble:1;
u8 UnidentifiedSignal:1;
u8 Radar:1;
u8 Unmeasure:1;
u8 Rev:3;
} field;
u8 word;
} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
struct PACKED rt_measure_basic_report {
u8 ChNum;
u64 MeasureStartTime;
u16 MeasureDuration;
MEASURE_BASIC_REPORT_MAP Map;
};
struct PACKED rt_measure_cca_report {
u8 ChNum;
u64 MeasureStartTime;
u16 MeasureDuration;
u8 CCA_Busy_Fraction;
};
struct PACKED rt_measure_rpi_report {
u8 ChNum;
u64 MeasureStartTime;
u16 MeasureDuration;
u8 RPI_Density[8];
};
typedef union PACKED _MEASURE_REPORT_MODE {
struct PACKED {
u8 Late:1;
u8 Incapable:1;
u8 Refused:1;
u8 Rev:5;
} field;
u8 word;
} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
struct PACKED rt_measure_report_info {
u8 Token;
u8 ReportMode;
u8 ReportType;
u8 Octect[0];
};
struct PACKED rt_quiet_info {
u8 QuietCnt;
u8 QuietPeriod;
u16 QuietDuration;
u16 QuietOffset;
};
#endif /* __SPECTRUM_DEF_H__ // */

File diff suppressed because it is too large Load diff

View file

@ -1,517 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
auth.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
John 2004-9-3 porting from RT2500
Justin P. Mattock 11/07/2010 Fix typos
*/
#include "../rt_config.h"
/*
==========================================================================
Description:
authenticate state machine init, including state transition and timer init
Parameters:
Sm - pointer to the auth state machine
Note:
The state machine looks like this
AUTH_REQ_IDLE AUTH_WAIT_SEQ2 AUTH_WAIT_SEQ4
MT2_MLME_AUTH_REQ mlme_auth_req_action invalid_state_when_auth invalid_state_when_auth
MT2_PEER_AUTH_EVEN drop peer_auth_even_at_seq2_action peer_auth_even_at_seq4_action
MT2_AUTH_TIMEOUT Drop auth_timeout_action auth_timeout_action
IRQL = PASSIVE_LEVEL
==========================================================================
*/
void AuthStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *Sm, OUT STATE_MACHINE_FUNC Trans[])
{
StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG,
(STATE_MACHINE_FUNC) Drop, AUTH_REQ_IDLE,
AUTH_MACHINE_BASE);
/* the first column */
StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ,
(STATE_MACHINE_FUNC) MlmeAuthReqAction);
/* the second column */
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenAuth);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN,
(STATE_MACHINE_FUNC) PeerAuthRspAtSeq2Action);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT,
(STATE_MACHINE_FUNC) AuthTimeoutAction);
/* the third column */
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenAuth);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN,
(STATE_MACHINE_FUNC) PeerAuthRspAtSeq4Action);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT,
(STATE_MACHINE_FUNC) AuthTimeoutAction);
RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer,
GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
}
/*
==========================================================================
Description:
function to be executed at timer thread when auth timer expires
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void AuthTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3)
{
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeout\n"));
/* Do nothing if the driver is starting halt state. */
/* This might happen when timer already been fired before cancel timer with mlmehalt */
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
/* send a de-auth to reset AP's state machine (Patch AP-Dir635) */
if (pAd->Mlme.AuthMachine.CurrState == AUTH_WAIT_SEQ2)
Cls2errAction(pAd, pAd->MlmeAux.Bssid);
MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
RTMP_MLME_HANDLER(pAd);
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void MlmeAuthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
if (AUTH_ReqSend
(pAd, Elem, &pAd->MlmeAux.AuthTimer, "AUTH", 1, NULL, 0))
pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
else {
u16 Status;
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_INVALID_FORMAT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2,
&Status);
}
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void PeerAuthRspAtSeq2Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u8 Addr2[MAC_ADDR_LEN];
u16 Seq, Status, RemoteStatus, Alg;
u8 ChlgText[CIPHER_TEXT_LEN];
u8 CyperChlgText[CIPHER_TEXT_LEN + 8 + 8];
u8 Element[2];
struct rt_header_802_11 AuthHdr;
BOOLEAN TimerCancelled;
u8 *pOutBuffer = NULL;
int NStatus;
unsigned long FrameLen = 0;
u16 Status2;
if (PeerAuthSanity
(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status,
(char *)ChlgText)) {
if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n",
Alg, Status));
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer,
&TimerCancelled);
if (Status == MLME_SUCCESS) {
/* Authentication Mode "LEAP" has allow for CCX 1.X */
if (pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen) {
pAd->Mlme.AuthMachine.CurrState =
AUTH_REQ_IDLE;
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
MT2_AUTH_CONF, 2, &Status);
} else {
/* 2. shared key, need to be challenged */
Seq++;
RemoteStatus = MLME_SUCCESS;
/* Get an unused nonpaged memory */
NStatus =
MlmeAllocateMemory(pAd,
&pOutBuffer);
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
pAd->Mlme.AuthMachine.
CurrState = AUTH_REQ_IDLE;
Status2 = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
MT2_AUTH_CONF, 2,
&Status2);
return;
}
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Send AUTH request seq#3...\n"));
MgtMacHeaderInit(pAd, &AuthHdr,
SUBTYPE_AUTH, 0, Addr2,
pAd->MlmeAux.Bssid);
AuthHdr.FC.Wep = 1;
/* Encrypt challenge text & auth information */
RTMPInitWepEngine(pAd,
pAd->
SharedKey[BSS0][pAd->
StaCfg.
DefaultKeyId].
Key,
pAd->StaCfg.
DefaultKeyId,
pAd->
SharedKey[BSS0][pAd->
StaCfg.
DefaultKeyId].
KeyLen,
CyperChlgText);
Alg = cpu2le16(*(u16 *) & Alg);
Seq = cpu2le16(*(u16 *) & Seq);
RemoteStatus =
cpu2le16(*(u16 *) &
RemoteStatus);
RTMPEncryptData(pAd, (u8 *)& Alg,
CyperChlgText + 4, 2);
RTMPEncryptData(pAd, (u8 *)& Seq,
CyperChlgText + 6, 2);
RTMPEncryptData(pAd,
(u8 *)& RemoteStatus,
CyperChlgText + 8, 2);
Element[0] = 16;
Element[1] = 128;
RTMPEncryptData(pAd, Element,
CyperChlgText + 10, 2);
RTMPEncryptData(pAd, ChlgText,
CyperChlgText + 12,
128);
RTMPSetICV(pAd, CyperChlgText + 140);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(struct rt_header_802_11),
&AuthHdr,
CIPHER_TEXT_LEN + 16,
CyperChlgText,
END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer,
FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
RTMPSetTimer(&pAd->MlmeAux.AuthTimer,
AUTH_TIMEOUT);
pAd->Mlme.AuthMachine.CurrState =
AUTH_WAIT_SEQ4;
}
} else {
pAd->StaCfg.AuthFailReason = Status;
COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
MT2_AUTH_CONF, 2, &Status);
}
}
} else {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - PeerAuthSanity() sanity check fail\n"));
}
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void PeerAuthRspAtSeq4Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u8 Addr2[MAC_ADDR_LEN];
u16 Alg, Seq, Status;
char ChlgText[CIPHER_TEXT_LEN];
BOOLEAN TimerCancelled;
if (PeerAuthSanity
(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status,
ChlgText)) {
if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Receive AUTH_RSP seq#4 to me\n"));
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer,
&TimerCancelled);
if (Status != MLME_SUCCESS) {
pAd->StaCfg.AuthFailReason = Status;
COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
}
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF,
2, &Status);
}
} else {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - PeerAuthRspAtSeq4Action() sanity check fail\n"));
}
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void MlmeDeauthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
struct rt_mlme_deauth_req *pInfo;
struct rt_header_802_11 DeauthHdr;
u8 *pOutBuffer = NULL;
int NStatus;
unsigned long FrameLen = 0;
u16 Status;
pInfo = (struct rt_mlme_deauth_req *)Elem->Msg;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2,
&Status);
return;
}
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Send DE-AUTH request (Reason=%d)...\n",
pInfo->Reason));
MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
&DeauthHdr, 2, &pInfo->Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
pAd->StaCfg.DeauthReason = pInfo->Reason;
COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
/* send wireless event - for deauthentication */
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG,
pAd->MacTab.Content[BSSID_WCID].Addr,
BSS0, 0);
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void AuthTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u16 Status;
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_REJ_TIMEOUT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void InvalidStateWhenAuth(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u16 Status;
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n",
pAd->Mlme.AuthMachine.CurrState));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
/*
==========================================================================
Description:
Some STA/AP
Note:
This action should never trigger AUTH state transition, therefore we
separate it from AUTH state machine, and make it as a standalone service
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void Cls2errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr)
{
struct rt_header_802_11 DeauthHdr;
u8 *pOutBuffer = NULL;
int NStatus;
unsigned long FrameLen = 0;
u16 Reason = REASON_CLS2ERR;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS)
return;
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Class 2 error, Send DEAUTH frame...\n"));
MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
&DeauthHdr, 2, &Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
pAd->StaCfg.DeauthReason = Reason;
COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pAddr);
}
BOOLEAN AUTH_ReqSend(struct rt_rtmp_adapter *pAd,
struct rt_mlme_queue_elem *pElem,
struct rt_ralink_timer *pAuthTimer,
char *pSMName,
u16 SeqNo,
u8 *pNewElement, unsigned long ElementLen)
{
u16 Alg, Seq, Status;
u8 Addr[6];
unsigned long Timeout;
struct rt_header_802_11 AuthHdr;
BOOLEAN TimerCancelled;
int NStatus;
u8 *pOutBuffer = NULL;
unsigned long FrameLen = 0, tmp = 0;
/* Block all authentication request during WPA block period */
if (pAd->StaCfg.bBlockAssoc == TRUE) {
DBGPRINT(RT_DEBUG_TRACE,
("%s - Block Auth request during WPA block period!\n",
pSMName));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2,
&Status);
} else
if (MlmeAuthReqSanity
(pAd, pElem->Msg, pElem->MsgLen, Addr, &Timeout, &Alg)) {
/* reset timer */
RTMPCancelTimer(pAuthTimer, &TimerCancelled);
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
pAd->MlmeAux.Alg = Alg;
Seq = SeqNo;
Status = MLME_SUCCESS;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("%s - MlmeAuthReqAction(Alg:%d) allocate memory failed\n",
pSMName, Alg));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF,
2, &Status);
return FALSE;
}
DBGPRINT(RT_DEBUG_TRACE,
("%s - Send AUTH request seq#1 (Alg=%d)...\n", pSMName,
Alg));
MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
&AuthHdr, 2, &Alg, 2, &Seq, 2, &Status,
END_OF_ARGS);
if (pNewElement && ElementLen) {
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
ElementLen, pNewElement, END_OF_ARGS);
FrameLen += tmp;
}
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
RTMPSetTimer(pAuthTimer, Timeout);
return TRUE;
} else {
DBGPRINT_ERR("%s - MlmeAuthReqAction() sanity check failed\n", pSMName);
return FALSE;
}
return TRUE;
}

View file

@ -1,142 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
auth_rsp.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
John 2004-10-1 copy from RT2560
*/
#include "../rt_config.h"
/*
==========================================================================
Description:
authentication state machine init procedure
Parameters:
Sm - the state machine
IRQL = PASSIVE_LEVEL
==========================================================================
*/
void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *Sm,
IN STATE_MACHINE_FUNC Trans[])
{
StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG,
(STATE_MACHINE_FUNC) Drop, AUTH_RSP_IDLE,
AUTH_RSP_MACHINE_BASE);
/* column 1 */
StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH,
(STATE_MACHINE_FUNC) PeerDeauthAction);
/* column 2 */
StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH,
(STATE_MACHINE_FUNC) PeerDeauthAction);
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd,
struct rt_header_802_11 * pHdr80211,
u16 Alg,
u16 Seq,
u16 Reason, u16 Status)
{
struct rt_header_802_11 AuthHdr;
unsigned long FrameLen = 0;
u8 *pOutBuffer = NULL;
int NStatus;
if (Reason != MLME_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
return;
}
/*Get an unused nonpaged memory */
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
if (NStatus != NDIS_STATUS_SUCCESS)
return;
DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
&AuthHdr, 2, &Alg, 2, &Seq, 2, &Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u8 Addr2[MAC_ADDR_LEN];
u16 Reason;
if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) {
if (INFRA_ON(pAd)
&& MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid)
) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n",
Reason));
RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
0);
/* send wireless event - for deauthentication */
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG,
pAd->MacTab.
Content[BSSID_WCID].Addr,
BSS0, 0);
LinkDown(pAd, TRUE);
}
} else {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,362 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
sanity.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
John Chang 2004-09-01 add WMM support
Justin P. Mattock 11/07/2010 Fix typos
*/
#include "../rt_config.h"
extern u8 CISCO_OUI[];
extern u8 WPA_OUI[];
extern u8 RSN_OUI[];
extern u8 WME_INFO_ELEM[];
extern u8 WME_PARM_ELEM[];
extern u8 Ccx2QosInfo[];
extern u8 RALINK_OUI[];
extern u8 BROADCOM_OUI[];
/*
==========================================================================
Description:
MLME message sanity check
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
BOOLEAN MlmeStartReqSanity(struct rt_rtmp_adapter *pAd,
void * Msg,
unsigned long MsgLen,
char Ssid[], u8 * pSsidLen)
{
struct rt_mlme_start_req *Info;
Info = (struct rt_mlme_start_req *)(Msg);
if (Info->SsidLen > MAX_LEN_OF_SSID) {
DBGPRINT(RT_DEBUG_TRACE,
("MlmeStartReqSanity fail - wrong SSID length\n"));
return FALSE;
}
*pSsidLen = Info->SsidLen;
NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
return TRUE;
}
/*
==========================================================================
Description:
MLME message sanity check
Return:
TRUE if all parameters are OK, FALSE otherwise
IRQL = DISPATCH_LEVEL
==========================================================================
*/
BOOLEAN PeerAssocRspSanity(struct rt_rtmp_adapter *pAd, void * pMsg, unsigned long MsgLen, u8 *pAddr2, u16 * pCapabilityInfo, u16 * pStatus, u16 * pAid, u8 SupRate[], u8 * pSupRateLen, u8 ExtRate[], u8 * pExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo, /* AP might use this additional ht info IE */
u8 * pHtCapabilityLen,
u8 * pAddHtInfoLen,
u8 * pNewExtChannelOffset,
struct rt_edca_parm *pEdcaParm, u8 * pCkipFlag)
{
char IeType, *Ptr;
struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) pMsg;
struct rt_eid * pEid;
unsigned long Length = 0;
*pNewExtChannelOffset = 0xff;
*pHtCapabilityLen = 0;
*pAddHtInfoLen = 0;
COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
Ptr = (char *)pFrame->Octet;
Length += LENGTH_802_11;
NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
Length += 2;
NdisMoveMemory(pStatus, &pFrame->Octet[2], 2);
Length += 2;
*pCkipFlag = 0;
*pExtRateLen = 0;
pEdcaParm->bValid = FALSE;
if (*pStatus != MLME_SUCCESS)
return TRUE;
NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
Length += 2;
/* Aid already swapped byte order in RTMPFrameEndianChange() for big endian platform */
*pAid = (*pAid) & 0x3fff; /* AID is low 14-bit */
/* -- get supported rates from payload and advance the pointer */
IeType = pFrame->Octet[6];
*pSupRateLen = pFrame->Octet[7];
if ((IeType != IE_SUPP_RATES)
|| (*pSupRateLen > MAX_LEN_OF_SUPPORTED_RATES)) {
DBGPRINT(RT_DEBUG_TRACE,
("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
return FALSE;
} else
NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
Length = Length + 2 + *pSupRateLen;
/* many AP implement proprietary IEs in non-standard order, we'd better */
/* tolerate mis-ordered IEs to get best compatibility */
pEid = (struct rt_eid *) & pFrame->Octet[8 + (*pSupRateLen)];
/* get variable fields from payload and advance the pointer */
while ((Length + 2 + pEid->Len) <= MsgLen) {
switch (pEid->Eid) {
case IE_EXT_SUPP_RATES:
if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES) {
NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
*pExtRateLen = pEid->Len;
}
break;
case IE_HT_CAP:
case IE_HT_CAP2:
if (pEid->Len >= SIZE_HT_CAP_IE) /*Note: allow extension! */
{
NdisMoveMemory(pHtCapability, pEid->Octet,
SIZE_HT_CAP_IE);
*(u16 *) (&pHtCapability->HtCapInfo) =
cpu2le16(*(u16 *)
(&pHtCapability->HtCapInfo));
*(u16 *) (&pHtCapability->ExtHtCapInfo) =
cpu2le16(*(u16 *)
(&pHtCapability->ExtHtCapInfo));
*pHtCapabilityLen = SIZE_HT_CAP_IE;
} else {
DBGPRINT(RT_DEBUG_WARN,
("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
}
break;
case IE_ADD_HT:
case IE_ADD_HT2:
if (pEid->Len >= sizeof(struct rt_add_ht_info_ie)) {
/* This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only */
/* copy first sizeof(struct rt_add_ht_info_ie) */
NdisMoveMemory(pAddHtInfo, pEid->Octet,
sizeof(struct rt_add_ht_info_ie));
*(u16 *) (&pAddHtInfo->AddHtInfo2) =
cpu2le16(*(u16 *)
(&pAddHtInfo->AddHtInfo2));
*(u16 *) (&pAddHtInfo->AddHtInfo3) =
cpu2le16(*(u16 *)
(&pAddHtInfo->AddHtInfo3));
*pAddHtInfoLen = SIZE_ADD_HT_INFO_IE;
} else {
DBGPRINT(RT_DEBUG_WARN,
("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
}
break;
case IE_SECONDARY_CH_OFFSET:
if (pEid->Len == 1) {
*pNewExtChannelOffset = pEid->Octet[0];
} else {
DBGPRINT(RT_DEBUG_WARN,
("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
}
break;
case IE_VENDOR_SPECIFIC:
/* handle WME PARAMTER ELEMENT */
if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6)
&& (pEid->Len == 24)) {
u8 *ptr;
int i;
/* parsing EDCA parameters */
pEdcaParm->bValid = TRUE;
pEdcaParm->bQAck = FALSE; /* pEid->Octet[0] & 0x10; */
pEdcaParm->bQueueRequest = FALSE; /* pEid->Octet[0] & 0x20; */
pEdcaParm->bTxopRequest = FALSE; /* pEid->Octet[0] & 0x40; */
/*pEdcaParm->bMoreDataAck = FALSE; // pEid->Octet[0] & 0x80; */
pEdcaParm->EdcaUpdateCount =
pEid->Octet[6] & 0x0f;
pEdcaParm->bAPSDCapable =
(pEid->Octet[6] & 0x80) ? 1 : 0;
ptr = (u8 *)& pEid->Octet[8];
for (i = 0; i < 4; i++) {
u8 aci = (*ptr & 0x60) >> 5; /* b5~6 is AC INDEX */
pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); /* b5 is ACM */
pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; /* b0~3 is AIFSN */
pEdcaParm->Cwmin[aci] = *(ptr + 1) & 0x0f; /* b0~4 is Cwmin */
pEdcaParm->Cwmax[aci] = *(ptr + 1) >> 4; /* b5~8 is Cwmax */
pEdcaParm->Txop[aci] = *(ptr + 2) + 256 * (*(ptr + 3)); /* in unit of 32-us */
ptr += 4; /* point to next AC */
}
}
break;
default:
DBGPRINT(RT_DEBUG_TRACE,
("PeerAssocRspSanity - ignore unrecognized EID = %d\n",
pEid->Eid));
break;
}
Length = Length + 2 + pEid->Len;
pEid = (struct rt_eid *) ((u8 *) pEid + 2 + pEid->Len);
}
return TRUE;
}
/*
==========================================================================
Description:
MLME message sanity check
Return:
TRUE if all parameters are OK, FALSE otherwise
IRQL = DISPATCH_LEVEL
==========================================================================
*/
BOOLEAN PeerProbeReqSanity(struct rt_rtmp_adapter *pAd,
void * Msg,
unsigned long MsgLen,
u8 *pAddr2,
char Ssid[], u8 * pSsidLen)
{
u8 Idx;
u8 RateLen;
char IeType;
struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) Msg;
COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
if ((pFrame->Octet[0] != IE_SSID)
|| (pFrame->Octet[1] > MAX_LEN_OF_SSID)) {
DBGPRINT(RT_DEBUG_TRACE,
("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",
pFrame->Octet[0], pFrame->Octet[1]));
return FALSE;
}
*pSsidLen = pFrame->Octet[1];
NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
Idx = *pSsidLen + 2;
/* -- get supported rates from payload and advance the pointer */
IeType = pFrame->Octet[Idx];
RateLen = pFrame->Octet[Idx + 1];
if (IeType != IE_SUPP_RATES) {
DBGPRINT(RT_DEBUG_TRACE,
("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",
pFrame->Octet[Idx], pFrame->Octet[Idx + 1]));
return FALSE;
} else {
if ((pAd->CommonCfg.PhyMode == PHY_11G) && (RateLen < 8))
return (FALSE);
}
return TRUE;
}
/*
==========================================================================
Description:
IRQL = DISPATCH_LEVEL
==========================================================================
*/
BOOLEAN GetTimBit(char * Ptr,
u16 Aid,
u8 * TimLen,
u8 * BcastFlag,
u8 * DtimCount,
u8 * DtimPeriod, u8 * MessageToMe)
{
u8 BitCntl, N1, N2, MyByte, MyBit;
char *IdxPtr;
IdxPtr = Ptr;
IdxPtr++;
*TimLen = *IdxPtr;
/* get DTIM Count from TIM element */
IdxPtr++;
*DtimCount = *IdxPtr;
/* get DTIM Period from TIM element */
IdxPtr++;
*DtimPeriod = *IdxPtr;
/* get Bitmap Control from TIM element */
IdxPtr++;
BitCntl = *IdxPtr;
if ((*DtimCount == 0) && (BitCntl & 0x01))
*BcastFlag = TRUE;
else
*BcastFlag = FALSE;
/* Parse Partial Virtual Bitmap from TIM element */
N1 = BitCntl & 0xfe; /* N1 is the first bitmap byte# */
N2 = *TimLen - 4 + N1; /* N2 is the last bitmap byte# */
if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
*MessageToMe = FALSE;
else {
MyByte = (Aid >> 3) - N1; /* my byte position in the bitmap byte-stream */
MyBit = Aid % 16 - ((MyByte & 0x01) ? 8 : 0);
IdxPtr += (MyByte + 1);
/*if (*IdxPtr) */
/* DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr)); */
if (*IdxPtr & (0x01 << MyBit))
*MessageToMe = TRUE;
else
*MessageToMe = FALSE;
}
return TRUE;
}

File diff suppressed because it is too large Load diff

View file

@ -1,374 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
wpa.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Jan Lee 03-07-22 Initial
Paul Lin 03-11-28 Modify for supplicant
Justin P. Mattock 11/07/2010 Fix typos
*/
#include "../rt_config.h"
void inc_byte_array(u8 * counter, int len);
/*
========================================================================
Routine Description:
Process MIC error indication and record MIC error timer.
Arguments:
pAd Pointer to our adapter
pWpaKey Pointer to the WPA key structure
Return Value:
None
IRQL = DISPATCH_LEVEL
Note:
========================================================================
*/
void RTMPReportMicError(struct rt_rtmp_adapter *pAd, struct rt_cipher_key *pWpaKey)
{
unsigned long Now;
u8 unicastKey = (pWpaKey->Type == PAIRWISE_KEY ? 1 : 0);
/* Record Last MIC error time and count */
NdisGetSystemUpTime(&Now);
if (pAd->StaCfg.MicErrCnt == 0) {
pAd->StaCfg.MicErrCnt++;
pAd->StaCfg.LastMicErrorTime = Now;
NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
} else if (pAd->StaCfg.MicErrCnt == 1) {
if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now) {
/* Update Last MIC error time, this did not violate two MIC errors within 60 seconds */
pAd->StaCfg.LastMicErrorTime = Now;
} else {
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd,
IW_COUNTER_MEASURES_EVENT_FLAG,
pAd->MacTab.
Content[BSSID_WCID].Addr,
BSS0, 0);
pAd->StaCfg.LastMicErrorTime = Now;
/* Violate MIC error counts, MIC countermeasures kicks in */
pAd->StaCfg.MicErrCnt++;
/* We shall block all reception */
/* We shall clean all Tx ring and disassociate from AP after next EAPOL frame */
/* */
/* No necessary to clean all Tx ring, on RTMPHardTransmit will stop sending non-802.1X EAPOL packets */
/* if pAd->StaCfg.MicErrCnt greater than 2. */
/* */
/* RTMPRingCleanUp(pAd, QID_AC_BK); */
/* RTMPRingCleanUp(pAd, QID_AC_BE); */
/* RTMPRingCleanUp(pAd, QID_AC_VI); */
/* RTMPRingCleanUp(pAd, QID_AC_VO); */
/* RTMPRingCleanUp(pAd, QID_HCCA); */
}
} else {
/* MIC error count >= 2 */
/* This should not happen */
;
}
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
OID_802_11_MIC_FAILURE_REPORT_FRAME, 1, &unicastKey);
if (pAd->StaCfg.MicErrCnt == 2) {
RTMPSetTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, 100);
}
}
#define LENGTH_EAP_H 4
/* If the received frame is EAP-Packet ,find out its EAP-Code (Request(0x01), Response(0x02), Success(0x03), Failure(0x04)). */
int WpaCheckEapCode(struct rt_rtmp_adapter *pAd,
u8 *pFrame, u16 FrameLen, u16 OffSet)
{
u8 *pData;
int result = 0;
if (FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H)
return result;
pData = pFrame + OffSet; /* skip offset bytes */
if (*(pData + 1) == EAPPacket) /* 802.1x header - Packet Type */
{
result = *(pData + 4); /* EAP header - Code */
}
return result;
}
void WpaSendMicFailureToWpaSupplicant(struct rt_rtmp_adapter *pAd, IN BOOLEAN bUnicast)
{
char custom[IW_CUSTOM_MAX] = { 0 };
sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
if (bUnicast)
sprintf(custom, "%s unicast", custom);
RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, (u8 *)custom,
strlen(custom));
return;
}
void WpaMicFailureReportFrame(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
{
u8 *pOutBuffer = NULL;
u8 Header802_3[14];
unsigned long FrameLen = 0;
struct rt_eapol_packet Packet;
u8 Mic[16];
BOOLEAN bUnicast;
DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame ----->\n"));
bUnicast = (Elem->Msg[0] == 1 ? TRUE : FALSE);
pAd->Sequence = ((pAd->Sequence) + 1) & (MAX_SEQ_NUMBER);
/* init 802.3 header and Fill Packet */
MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid,
pAd->CurrentAddress, EAPOL);
NdisZeroMemory(&Packet, sizeof(Packet));
Packet.ProVer = EAPOL_VER;
Packet.ProType = EAPOLKey;
Packet.KeyDesc.Type = WPA1_KEY_DESC;
/* Request field presented */
Packet.KeyDesc.KeyInfo.Request = 1;
if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) {
Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
} else /* TKIP */
{
Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
}
Packet.KeyDesc.KeyInfo.KeyType = (bUnicast ? PAIRWISEKEY : GROUPKEY);
/* KeyMic field presented */
Packet.KeyDesc.KeyInfo.KeyMic = 1;
/* Error field presented */
Packet.KeyDesc.KeyInfo.Error = 1;
/* Update packet length after decide Key data payload */
SET_u16_TO_ARRARY(Packet.Body_Len, LEN_EAPOL_KEY_MSG)
/* Key Replay Count */
NdisMoveMemory(Packet.KeyDesc.ReplayCounter,
pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
inc_byte_array(pAd->StaCfg.ReplayCounter, 8);
/* Convert to little-endian format. */
*((u16 *) & Packet.KeyDesc.KeyInfo) =
cpu2le16(*((u16 *) & Packet.KeyDesc.KeyInfo));
MlmeAllocateMemory(pAd, (u8 **) & pOutBuffer); /* allocate memory */
if (pOutBuffer == NULL) {
return;
}
/* Prepare EAPOL frame for MIC calculation */
/* Be careful, only EAPOL frame is counted for MIC calculation */
MakeOutgoingFrame(pOutBuffer, &FrameLen,
CONV_ARRARY_TO_u16(Packet.Body_Len) + 4, &Packet,
END_OF_ARGS);
/* Prepare and Fill MIC value */
NdisZeroMemory(Mic, sizeof(Mic));
if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) { /* AES */
u8 digest[20] = { 0 };
HMAC_SHA1(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen,
digest, SHA1_DIGEST_SIZE);
NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
} else { /* TKIP */
HMAC_MD5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen,
Mic, MD5_DIGEST_SIZE);
}
NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
/* copy frame to Tx ring and send MIC failure report frame to authenticator */
RTMPToWirelessSta(pAd, &pAd->MacTab.Content[BSSID_WCID],
Header802_3, LENGTH_802_3,
(u8 *)& Packet,
CONV_ARRARY_TO_u16(Packet.Body_Len) + 4, FALSE);
MlmeFreeMemory(pAd, (u8 *)pOutBuffer);
DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame <-----\n"));
}
/** from wpa_supplicant
* inc_byte_array - Increment arbitrary length byte array by one
* @counter: Pointer to byte array
* @len: Length of the counter in bytes
*
* This function increments the last byte of the counter by one and continues
* rolling over to more significant bytes if the byte was incremented from
* 0xff to 0x00.
*/
void inc_byte_array(u8 * counter, int len)
{
int pos = len - 1;
while (pos >= 0) {
counter[pos]++;
if (counter[pos] != 0)
break;
pos--;
}
}
void WpaDisassocApAndBlockAssoc(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2,
void *SystemSpecific3)
{
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
struct rt_mlme_disassoc_req DisassocReq;
/* disassoc from current AP first */
DBGPRINT(RT_DEBUG_TRACE,
("RTMPReportMicError - disassociate with current AP after sending second continuous EAPOL frame\n"));
DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid,
REASON_MIC_FAILURE);
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
sizeof(struct rt_mlme_disassoc_req), &DisassocReq);
pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
pAd->StaCfg.bBlockAssoc = TRUE;
}
void WpaStaPairwiseKeySetting(struct rt_rtmp_adapter *pAd)
{
struct rt_cipher_key *pSharedKey;
struct rt_mac_table_entry *pEntry;
pEntry = &pAd->MacTab.Content[BSSID_WCID];
/* Pairwise key shall use key#0 */
pSharedKey = &pAd->SharedKey[BSS0][0];
NdisMoveMemory(pAd->StaCfg.PTK, pEntry->PTK, LEN_PTK);
/* Prepare pair-wise key information into shared key table */
NdisZeroMemory(pSharedKey, sizeof(struct rt_cipher_key));
pSharedKey->KeyLen = LEN_TKIP_EK;
NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48],
LEN_TKIP_RXMICK);
NdisMoveMemory(pSharedKey->TxMic,
&pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
/* Decide its ChiperAlg */
if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
pSharedKey->CipherAlg = CIPHER_TKIP;
else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
pSharedKey->CipherAlg = CIPHER_AES;
else
pSharedKey->CipherAlg = CIPHER_NONE;
/* Update these related information to struct rt_mac_table_entry */
NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32],
LEN_TKIP_EK);
NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48],
LEN_TKIP_RXMICK);
NdisMoveMemory(pEntry->PairwiseKey.TxMic,
&pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
pEntry->PairwiseKey.CipherAlg = pSharedKey->CipherAlg;
/* Update pairwise key information to ASIC Shared Key Table */
AsicAddSharedKeyEntry(pAd,
BSS0,
0,
pSharedKey->CipherAlg,
pSharedKey->Key,
pSharedKey->TxMic, pSharedKey->RxMic);
/* Update ASIC WCID attribute table and IVEIV table */
RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pSharedKey->CipherAlg, pEntry);
STA_PORT_SECURED(pAd);
pAd->IndicateMediaState = NdisMediaStateConnected;
DBGPRINT(RT_DEBUG_TRACE,
("%s : AID(%d) port secured\n", __func__, pEntry->Aid));
}
void WpaStaGroupKeySetting(struct rt_rtmp_adapter *pAd)
{
struct rt_cipher_key *pSharedKey;
pSharedKey = &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId];
/* Prepare pair-wise key information into shared key table */
NdisZeroMemory(pSharedKey, sizeof(struct rt_cipher_key));
pSharedKey->KeyLen = LEN_TKIP_EK;
NdisMoveMemory(pSharedKey->Key, pAd->StaCfg.GTK, LEN_TKIP_EK);
NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16],
LEN_TKIP_RXMICK);
NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24],
LEN_TKIP_TXMICK);
/* Update Shared Key CipherAlg */
pSharedKey->CipherAlg = CIPHER_NONE;
if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
pSharedKey->CipherAlg = CIPHER_TKIP;
else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
pSharedKey->CipherAlg = CIPHER_AES;
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
pSharedKey->CipherAlg = CIPHER_WEP64;
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
pSharedKey->CipherAlg = CIPHER_WEP128;
/* Update group key information to ASIC Shared Key Table */
AsicAddSharedKeyEntry(pAd,
BSS0,
pAd->StaCfg.DefaultKeyId,
pSharedKey->CipherAlg,
pSharedKey->Key,
pSharedKey->TxMic, pSharedKey->RxMic);
/* Update ASIC WCID attribute table and IVEIV table */
RTMPAddWcidAttributeEntry(pAd,
BSS0,
pAd->StaCfg.DefaultKeyId,
pSharedKey->CipherAlg, NULL);
}

File diff suppressed because it is too large Load diff

View file

@ -1,927 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#include "rt_config.h"
/* Following information will be show when you run 'modinfo' */
/* If you have a solution for the bug in current version of driver, please e-mail me. */
/* Otherwise post to the forum at ralinktech's web site(www.ralinktech.com) and let all users help you. */
MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>");
MODULE_DESCRIPTION("RT2870/RT3070 Wireless Lan Linux Driver");
MODULE_LICENSE("GPL");
#ifdef MODULE_VERSION
MODULE_VERSION(STA_DRIVER_VERSION);
#endif
/* module table */
struct usb_device_id rtusb_usb_id[] = {
#ifdef RT2870
{USB_DEVICE(0x148F, 0x2770)}, /* Ralink */
{USB_DEVICE(0x148F, 0x2870)}, /* Ralink */
{USB_DEVICE(0x07B8, 0x2870)}, /* AboCom */
{USB_DEVICE(0x07B8, 0x2770)}, /* AboCom */
{USB_DEVICE(0x0DF6, 0x0039)}, /* Sitecom 2770 */
{USB_DEVICE(0x0DF6, 0x003F)}, /* Sitecom 2770 */
{USB_DEVICE(0x083A, 0x7512)}, /* Arcadyan 2770 */
{USB_DEVICE(0x0789, 0x0162)}, /* Logitec 2870 */
{USB_DEVICE(0x0789, 0x0163)}, /* Logitec 2870 */
{USB_DEVICE(0x0789, 0x0164)}, /* Logitec 2870 */
{USB_DEVICE(0x177f, 0x0302)}, /* lsusb */
{USB_DEVICE(0x0B05, 0x1731)}, /* Asus */
{USB_DEVICE(0x0B05, 0x1732)}, /* Asus */
{USB_DEVICE(0x0B05, 0x1742)}, /* Asus */
{USB_DEVICE(0x0DF6, 0x0017)}, /* Sitecom */
{USB_DEVICE(0x0DF6, 0x002B)}, /* Sitecom */
{USB_DEVICE(0x0DF6, 0x002C)}, /* Sitecom */
{USB_DEVICE(0x0DF6, 0x002D)}, /* Sitecom */
{USB_DEVICE(0x14B2, 0x3C06)}, /* Conceptronic */
{USB_DEVICE(0x14B2, 0x3C28)}, /* Conceptronic */
{USB_DEVICE(0x2019, 0xED06)}, /* Planex Communications, Inc. */
{USB_DEVICE(0x07D1, 0x3C09)}, /* D-Link */
{USB_DEVICE(0x07D1, 0x3C11)}, /* D-Link */
{USB_DEVICE(0x14B2, 0x3C07)}, /* AL */
{USB_DEVICE(0x050D, 0x8053)}, /* Belkin */
{USB_DEVICE(0x050D, 0x825B)}, /* Belkin */
{USB_DEVICE(0x050D, 0x935A)}, /* Belkin F6D4050 v1 */
{USB_DEVICE(0x050D, 0x935B)}, /* Belkin F6D4050 v2 */
{USB_DEVICE(0x14B2, 0x3C23)}, /* Airlink */
{USB_DEVICE(0x14B2, 0x3C27)}, /* Airlink */
{USB_DEVICE(0x07AA, 0x002F)}, /* Corega */
{USB_DEVICE(0x07AA, 0x003C)}, /* Corega */
{USB_DEVICE(0x07AA, 0x003F)}, /* Corega */
{USB_DEVICE(0x1044, 0x800B)}, /* Gigabyte */
{USB_DEVICE(0x15A9, 0x0006)}, /* Sparklan */
{USB_DEVICE(0x083A, 0xB522)}, /* SMC */
{USB_DEVICE(0x083A, 0xA618)}, /* SMC */
{USB_DEVICE(0x083A, 0x8522)}, /* Arcadyan */
{USB_DEVICE(0x083A, 0x7522)}, /* Arcadyan */
{USB_DEVICE(0x0CDE, 0x0022)}, /* ZCOM */
{USB_DEVICE(0x0586, 0x3416)}, /* Zyxel */
{USB_DEVICE(0x0586, 0x341a)}, /* Zyxel NWD-270N */
{USB_DEVICE(0x0CDE, 0x0025)}, /* Zyxel */
{USB_DEVICE(0x1740, 0x9701)}, /* EnGenius */
{USB_DEVICE(0x1740, 0x9702)}, /* EnGenius */
{USB_DEVICE(0x0471, 0x200f)}, /* Philips */
{USB_DEVICE(0x14B2, 0x3C25)}, /* Draytek */
{USB_DEVICE(0x13D3, 0x3247)}, /* AzureWave */
{USB_DEVICE(0x083A, 0x6618)}, /* Accton */
{USB_DEVICE(0x15c5, 0x0008)}, /* Amit */
{USB_DEVICE(0x0E66, 0x0001)}, /* Hawking */
{USB_DEVICE(0x0E66, 0x0003)}, /* Hawking */
{USB_DEVICE(0x129B, 0x1828)}, /* Siemens */
{USB_DEVICE(0x157E, 0x300E)}, /* U-Media */
{USB_DEVICE(0x050d, 0x805c)},
{USB_DEVICE(0x050d, 0x815c)},
{USB_DEVICE(0x1482, 0x3C09)}, /* Abocom */
{USB_DEVICE(0x14B2, 0x3C09)}, /* Alpha */
{USB_DEVICE(0x04E8, 0x2018)}, /* samsung linkstick2 */
{USB_DEVICE(0x1690, 0x0740)}, /* Askey */
{USB_DEVICE(0x5A57, 0x0280)}, /* Zinwell */
{USB_DEVICE(0x5A57, 0x0282)}, /* Zinwell */
{USB_DEVICE(0x7392, 0x7718)},
{USB_DEVICE(0x7392, 0x7717)},
{USB_DEVICE(0x0411, 0x016f)}, /* MelCo.,Inc. WLI-UC-G301N */
{USB_DEVICE(0x1737, 0x0070)}, /* Linksys WUSB100 */
{USB_DEVICE(0x1737, 0x0071)}, /* Linksys WUSB600N */
{USB_DEVICE(0x1737, 0x0078)}, /* Linksys WUSB100v2 */
{USB_DEVICE(0x0411, 0x00e8)}, /* Buffalo WLI-UC-G300N */
{USB_DEVICE(0x050d, 0x815c)}, /* Belkin F5D8053 */
{USB_DEVICE(0x100D, 0x9031)}, /* Motorola 2770 */
#endif /* RT2870 // */
#ifdef RT3070
{USB_DEVICE(0x148F, 0x3070)}, /* Ralink 3070 */
{USB_DEVICE(0x148F, 0x3071)}, /* Ralink 3071 */
{USB_DEVICE(0x148F, 0x3072)}, /* Ralink 3072 */
{USB_DEVICE(0x0DB0, 0x3820)}, /* Ralink 3070 */
{USB_DEVICE(0x0DB0, 0x871C)}, /* Ralink 3070 */
{USB_DEVICE(0x0DB0, 0x822C)}, /* Ralink 3070 */
{USB_DEVICE(0x0DB0, 0x871B)}, /* Ralink 3070 */
{USB_DEVICE(0x0DB0, 0x822B)}, /* Ralink 3070 */
{USB_DEVICE(0x0DF6, 0x003E)}, /* Sitecom 3070 */
{USB_DEVICE(0x0DF6, 0x0042)}, /* Sitecom 3072 */
{USB_DEVICE(0x0DF6, 0x0048)}, /* Sitecom 3070 */
{USB_DEVICE(0x0DF6, 0x0047)}, /* Sitecom 3071 */
{USB_DEVICE(0x14B2, 0x3C12)}, /* AL 3070 */
{USB_DEVICE(0x18C5, 0x0012)}, /* Corega 3070 */
{USB_DEVICE(0x083A, 0x7511)}, /* Arcadyan 3070 */
{USB_DEVICE(0x083A, 0xA701)}, /* SMC 3070 */
{USB_DEVICE(0x083A, 0xA702)}, /* SMC 3072 */
{USB_DEVICE(0x1740, 0x9703)}, /* EnGenius 3070 */
{USB_DEVICE(0x1740, 0x9705)}, /* EnGenius 3071 */
{USB_DEVICE(0x1740, 0x9706)}, /* EnGenius 3072 */
{USB_DEVICE(0x1740, 0x9707)}, /* EnGenius 3070 */
{USB_DEVICE(0x1740, 0x9708)}, /* EnGenius 3071 */
{USB_DEVICE(0x1740, 0x9709)}, /* EnGenius 3072 */
{USB_DEVICE(0x13D3, 0x3273)}, /* AzureWave 3070 */
{USB_DEVICE(0x13D3, 0x3305)}, /* AzureWave 3070*/
{USB_DEVICE(0x1044, 0x800D)}, /* Gigabyte GN-WB32L 3070 */
{USB_DEVICE(0x2019, 0xAB25)}, /* Planex Communications, Inc. RT3070 */
{USB_DEVICE(0x07B8, 0x3070)}, /* AboCom 3070 */
{USB_DEVICE(0x07B8, 0x3071)}, /* AboCom 3071 */
{USB_DEVICE(0x07B8, 0x3072)}, /* Abocom 3072 */
{USB_DEVICE(0x7392, 0x7711)}, /* Edimax 3070 */
{USB_DEVICE(0x1A32, 0x0304)}, /* Quanta 3070 */
{USB_DEVICE(0x1EDA, 0x2310)}, /* AirTies 3070 */
{USB_DEVICE(0x07D1, 0x3C0A)}, /* D-Link 3072 */
{USB_DEVICE(0x07D1, 0x3C0D)}, /* D-Link 3070 */
{USB_DEVICE(0x07D1, 0x3C0E)}, /* D-Link 3070 */
{USB_DEVICE(0x07D1, 0x3C0F)}, /* D-Link 3070 */
{USB_DEVICE(0x07D1, 0x3C16)}, /* D-Link 3070 */
{USB_DEVICE(0x07D1, 0x3C17)}, /* D-Link 8070 */
{USB_DEVICE(0x1D4D, 0x000C)}, /* Pegatron Corporation 3070 */
{USB_DEVICE(0x1D4D, 0x000E)}, /* Pegatron Corporation 3070 */
{USB_DEVICE(0x5A57, 0x5257)}, /* Zinwell 3070 */
{USB_DEVICE(0x5A57, 0x0283)}, /* Zinwell 3072 */
{USB_DEVICE(0x04BB, 0x0945)}, /* I-O DATA 3072 */
{USB_DEVICE(0x04BB, 0x0947)}, /* I-O DATA 3070 */
{USB_DEVICE(0x04BB, 0x0948)}, /* I-O DATA 3072 */
{USB_DEVICE(0x203D, 0x1480)}, /* Encore 3070 */
{USB_DEVICE(0x20B8, 0x8888)}, /* PARA INDUSTRIAL 3070 */
{USB_DEVICE(0x0B05, 0x1784)}, /* Asus 3072 */
{USB_DEVICE(0x203D, 0x14A9)}, /* Encore 3070*/
{USB_DEVICE(0x0DB0, 0x899A)}, /* MSI 3070*/
{USB_DEVICE(0x0DB0, 0x3870)}, /* MSI 3070*/
{USB_DEVICE(0x0DB0, 0x870A)}, /* MSI 3070*/
{USB_DEVICE(0x0DB0, 0x6899)}, /* MSI 3070 */
{USB_DEVICE(0x0DB0, 0x3822)}, /* MSI 3070 */
{USB_DEVICE(0x0DB0, 0x3871)}, /* MSI 3070 */
{USB_DEVICE(0x0DB0, 0x871A)}, /* MSI 3070 */
{USB_DEVICE(0x0DB0, 0x822A)}, /* MSI 3070 */
{USB_DEVICE(0x0DB0, 0x3821)}, /* Ralink 3070 */
{USB_DEVICE(0x0DB0, 0x821A)}, /* Ralink 3070 */
{USB_DEVICE(0x083A, 0xA703)}, /* IO-MAGIC */
{USB_DEVICE(0x13D3, 0x3307)}, /* Azurewave */
{USB_DEVICE(0x13D3, 0x3321)}, /* Azurewave */
{USB_DEVICE(0x07FA, 0x7712)}, /* Edimax */
{USB_DEVICE(0x0789, 0x0166)}, /* Edimax */
{USB_DEVICE(0x148F, 0x2070)}, /* Edimax */
#endif /* RT3070 // */
{USB_DEVICE(0x1737, 0x0077)}, /* Linksys WUSB54GC-EU v3 */
{USB_DEVICE(0x2001, 0x3C09)}, /* D-Link */
{USB_DEVICE(0x2001, 0x3C0A)}, /* D-Link 3072 */
{USB_DEVICE(0x2019, 0xED14)}, /* Planex Communications, Inc. */
{USB_DEVICE(0x0411, 0x015D)}, /* Buffalo Airstation WLI-UC-GN */
{} /* Terminating entry */
};
int const rtusb_usb_id_len =
sizeof(rtusb_usb_id) / sizeof(struct usb_device_id);
MODULE_DEVICE_TABLE(usb, rtusb_usb_id);
static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pAd);
static int __devinit rt2870_probe(IN struct usb_interface *intf,
IN struct usb_device *usb_dev,
IN const struct usb_device_id *dev_id,
struct rt_rtmp_adapter **ppAd);
#ifndef PF_NOFREEZE
#define PF_NOFREEZE 0
#endif
extern int rt28xx_close(IN struct net_device *net_dev);
extern int rt28xx_open(struct net_device *net_dev);
static BOOLEAN USBDevConfigInit(IN struct usb_device *dev,
IN struct usb_interface *intf,
struct rt_rtmp_adapter *pAd);
/*
========================================================================
Routine Description:
Check the chipset vendor/product ID.
Arguments:
_dev_p Point to the PCI or USB device
Return Value:
TRUE Check ok
FALSE Check fail
Note:
========================================================================
*/
BOOLEAN RT28XXChipsetCheck(IN void *_dev_p)
{
struct usb_interface *intf = (struct usb_interface *)_dev_p;
struct usb_device *dev_p = interface_to_usbdev(intf);
u32 i;
for (i = 0; i < rtusb_usb_id_len; i++) {
if (dev_p->descriptor.idVendor == rtusb_usb_id[i].idVendor &&
dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) {
printk(KERN_INFO "rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
dev_p->descriptor.idVendor,
dev_p->descriptor.idProduct);
break;
}
}
if (i == rtusb_usb_id_len) {
printk(KERN_ERR "rt2870: Error! Device Descriptor not matching!\n");
return FALSE;
}
return TRUE;
}
/**************************************************************************/
/**************************************************************************/
/*tested for kernel 2.6series */
/**************************************************************************/
/**************************************************************************/
#ifdef CONFIG_PM
static int rt2870_suspend(struct usb_interface *intf, pm_message_t state);
static int rt2870_resume(struct usb_interface *intf);
#endif /* CONFIG_PM // */
static BOOLEAN USBDevConfigInit(IN struct usb_device *dev,
IN struct usb_interface *intf,
struct rt_rtmp_adapter *pAd)
{
struct usb_host_interface *iface_desc;
unsigned long BulkOutIdx;
u32 i;
/* get the active interface descriptor */
iface_desc = intf->cur_altsetting;
/* get # of enpoints */
pAd->NumberOfPipes = iface_desc->desc.bNumEndpoints;
DBGPRINT(RT_DEBUG_TRACE,
("NumEndpoints=%d\n", iface_desc->desc.bNumEndpoints));
/* Configure Pipes */
BulkOutIdx = 0;
for (i = 0; i < pAd->NumberOfPipes; i++) {
if ((iface_desc->endpoint[i].desc.bmAttributes ==
USB_ENDPOINT_XFER_BULK) &&
((iface_desc->endpoint[i].desc.bEndpointAddress &
USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)) {
pAd->BulkInEpAddr =
iface_desc->endpoint[i].desc.bEndpointAddress;
pAd->BulkInMaxPacketSize =
le2cpu16(iface_desc->endpoint[i].desc.
wMaxPacketSize);
DBGPRINT_RAW(RT_DEBUG_TRACE,
("BULK IN MaxPacketSize = %d\n",
pAd->BulkInMaxPacketSize));
DBGPRINT_RAW(RT_DEBUG_TRACE,
("EP address = 0x%2x\n",
iface_desc->endpoint[i].desc.
bEndpointAddress));
} else
if ((iface_desc->endpoint[i].desc.bmAttributes ==
USB_ENDPOINT_XFER_BULK)
&&
((iface_desc->endpoint[i].desc.
bEndpointAddress & USB_ENDPOINT_DIR_MASK) ==
USB_DIR_OUT)) {
/* there are 6 bulk out EP. EP6 highest priority. */
/* EP1-4 is EDCA. EP5 is HCCA. */
pAd->BulkOutEpAddr[BulkOutIdx++] =
iface_desc->endpoint[i].desc.bEndpointAddress;
pAd->BulkOutMaxPacketSize =
le2cpu16(iface_desc->endpoint[i].desc.
wMaxPacketSize);
DBGPRINT_RAW(RT_DEBUG_TRACE,
("BULK OUT MaxPacketSize = %d\n",
pAd->BulkOutMaxPacketSize));
DBGPRINT_RAW(RT_DEBUG_TRACE,
("EP address = 0x%2x \n",
iface_desc->endpoint[i].desc.
bEndpointAddress));
}
}
if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0])) {
printk
(KERN_ERR "%s: Could not find both bulk-in and bulk-out endpoints\n",
__FUNCTION__);
return FALSE;
}
pAd->config = &dev->config->desc;
usb_set_intfdata(intf, pAd);
return TRUE;
}
static int __devinit rtusb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct rt_rtmp_adapter *pAd;
struct usb_device *dev;
int rv;
dev = interface_to_usbdev(intf);
dev = usb_get_dev(dev);
rv = rt2870_probe(intf, dev, id, &pAd);
if (rv != 0)
usb_put_dev(dev);
return rv;
}
static void rtusb_disconnect(struct usb_interface *intf)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct rt_rtmp_adapter *pAd;
pAd = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL);
rt2870_disconnect(dev, pAd);
}
struct usb_driver rtusb_driver = {
.name = "rt2870",
.probe = rtusb_probe,
.disconnect = rtusb_disconnect,
.id_table = rtusb_usb_id,
#ifdef CONFIG_PM
suspend:rt2870_suspend,
resume:rt2870_resume,
#endif
};
#ifdef CONFIG_PM
void RT2870RejectPendingPackets(struct rt_rtmp_adapter *pAd)
{
/* clear PS packets */
/* clear TxSw packets */
}
static int rt2870_suspend(struct usb_interface *intf, pm_message_t state)
{
struct net_device *net_dev;
struct rt_rtmp_adapter *pAd = usb_get_intfdata(intf);
DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_suspend()\n"));
net_dev = pAd->net_dev;
netif_device_detach(net_dev);
pAd->PM_FlgSuspend = 1;
if (netif_running(net_dev)) {
RTUSBCancelPendingBulkInIRP(pAd);
RTUSBCancelPendingBulkOutIRP(pAd);
}
DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_suspend()\n"));
return 0;
}
static int rt2870_resume(struct usb_interface *intf)
{
struct net_device *net_dev;
struct rt_rtmp_adapter *pAd = usb_get_intfdata(intf);
DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()\n"));
pAd->PM_FlgSuspend = 0;
net_dev = pAd->net_dev;
netif_device_attach(net_dev);
netif_start_queue(net_dev);
netif_carrier_on(net_dev);
netif_wake_queue(net_dev);
DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()\n"));
return 0;
}
#endif /* CONFIG_PM // */
/* Init driver module */
int __init rtusb_init(void)
{
printk(KERN_DEBUG "rtusb init --->\n");
return usb_register(&rtusb_driver);
}
/* Deinit driver module */
void __exit rtusb_exit(void)
{
usb_deregister(&rtusb_driver);
printk(KERN_DEBUG "<--- rtusb exit\n");
}
module_init(rtusb_init);
module_exit(rtusb_exit);
/*--------------------------------------------------------------------- */
/* function declarations */
/*--------------------------------------------------------------------- */
/*
========================================================================
Routine Description:
MLME kernel thread.
Arguments:
*Context the pAd, driver control block pointer
Return Value:
0 close the thread
Note:
========================================================================
*/
int MlmeThread(IN void *Context)
{
struct rt_rtmp_adapter *pAd;
struct rt_rtmp_os_task *pTask;
int status;
status = 0;
pTask = Context;
pAd = pTask->priv;
RtmpOSTaskCustomize(pTask);
while (!pTask->task_killed) {
#ifdef KTHREAD_SUPPORT
RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
#else
RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);
/* unlock the device pointers */
if (status != 0) {
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
break;
}
#endif
/* lock the device pointers , need to check if required */
/*down(&(pAd->usbdev_semaphore)); */
if (!pAd->PM_FlgSuspend)
MlmeHandler(pAd);
}
/* 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().
*/
DBGPRINT(RT_DEBUG_TRACE, ("<---%s\n", __FUNCTION__));
#ifndef KTHREAD_SUPPORT
pTask->taskPID = THREAD_PID_INIT_VALUE;
complete_and_exit(&pTask->taskComplete, 0);
#endif
return 0;
}
/*
========================================================================
Routine Description:
USB command kernel thread.
Arguments:
*Context the pAd, driver control block pointer
Return Value:
0 close the thread
Note:
========================================================================
*/
int RTUSBCmdThread(IN void *Context)
{
struct rt_rtmp_adapter *pAd;
struct rt_rtmp_os_task *pTask;
int status;
status = 0;
pTask = Context;
pAd = pTask->priv;
RtmpOSTaskCustomize(pTask);
NdisAcquireSpinLock(&pAd->CmdQLock);
pAd->CmdQ.CmdQState = RTMP_TASK_STAT_RUNNING;
NdisReleaseSpinLock(&pAd->CmdQLock);
while (pAd && pAd->CmdQ.CmdQState == RTMP_TASK_STAT_RUNNING) {
#ifdef KTHREAD_SUPPORT
RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
#else
/* lock the device pointers */
RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);
if (status != 0) {
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
break;
}
#endif
if (pAd->CmdQ.CmdQState == RTMP_TASK_STAT_STOPED)
break;
if (!pAd->PM_FlgSuspend)
CMDHandler(pAd);
}
if (pAd && !pAd->PM_FlgSuspend) { /* Clear the CmdQElements. */
struct rt_cmdqelmt *pCmdQElmt = NULL;
NdisAcquireSpinLock(&pAd->CmdQLock);
pAd->CmdQ.CmdQState = RTMP_TASK_STAT_STOPED;
while (pAd->CmdQ.size) {
RTUSBDequeueCmd(&pAd->CmdQ, &pCmdQElmt);
if (pCmdQElmt) {
if (pCmdQElmt->CmdFromNdis == TRUE) {
if (pCmdQElmt->buffer != NULL)
os_free_mem(pAd,
pCmdQElmt->buffer);
os_free_mem(pAd, (u8 *)pCmdQElmt);
} else {
if ((pCmdQElmt->buffer != NULL)
&& (pCmdQElmt->bufferlength != 0))
os_free_mem(pAd,
pCmdQElmt->buffer);
os_free_mem(pAd, (u8 *)pCmdQElmt);
}
}
}
NdisReleaseSpinLock(&pAd->CmdQLock);
}
/* 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().
*/
DBGPRINT(RT_DEBUG_TRACE, ("<---RTUSBCmdThread\n"));
#ifndef KTHREAD_SUPPORT
pTask->taskPID = THREAD_PID_INIT_VALUE;
complete_and_exit(&pTask->taskComplete, 0);
#endif
return 0;
}
void RTUSBWatchDog(struct rt_rtmp_adapter *pAd)
{
struct rt_ht_tx_context *pHTTXContext;
int idx;
unsigned long irqFlags;
PURB pUrb;
BOOLEAN needDumpSeq = FALSE;
u32 MACValue;
u32 TxRxQ_Pcnt;
idx = 0;
RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
if ((MACValue & 0xff) != 0) {
DBGPRINT(RT_DEBUG_TRACE,
("TX QUEUE 0 Not EMPTY(Value=0x%0x)!\n",
MACValue));
RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40012);
while ((MACValue & 0xff) != 0 && (idx++ < 10)) {
RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
RTMPusecDelay(1);
}
RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
}
if (pAd->watchDogRxOverFlowCnt >= 2) {
DBGPRINT(RT_DEBUG_TRACE,
("Maybe the Rx Bulk-In hanged! Cancel the pending Rx bulks request!\n"));
if ((!RTMP_TEST_FLAG
(pAd,
(fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_BULKIN_RESET |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
DBGPRINT(RT_DEBUG_TRACE,
("Call CMDTHREAD_RESET_BULK_IN to cancel the pending Rx Bulk!\n"));
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN,
NULL, 0);
needDumpSeq = TRUE;
}
pAd->watchDogRxOverFlowCnt = 0;
}
RTUSBReadMACRegister(pAd, 0x438, &TxRxQ_Pcnt);
for (idx = 0; idx < NUM_OF_TX_RING; idx++) {
pUrb = NULL;
RTMP_IRQ_LOCK(&pAd->BulkOutLock[idx], irqFlags);
if ((pAd->BulkOutPending[idx] == TRUE)
&& pAd->watchDogTxPendingCnt) {
int actual_length = 0, transfer_buffer_length = 0;
BOOLEAN isDataPacket = FALSE;
pAd->watchDogTxPendingCnt[idx]++;
if ((pAd->watchDogTxPendingCnt[idx] > 2) &&
(!RTMP_TEST_FLAG
(pAd,
(fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
fRTMP_ADAPTER_NIC_NOT_EXIST |
fRTMP_ADAPTER_BULKOUT_RESET)))
) {
/* FIXME: Following code just support single bulk out. If you wanna support multiple bulk out. Modify it! */
pHTTXContext =
(struct rt_ht_tx_context *)(&pAd->TxContext[idx]);
if (pHTTXContext->IRPPending) { /* Check TxContext. */
pUrb = pHTTXContext->pUrb;
actual_length = pUrb->actual_length;
transfer_buffer_length =
pUrb->transfer_buffer_length;
isDataPacket = TRUE;
} else if (idx == MGMTPIPEIDX) {
struct rt_tx_context *pMLMEContext, *pNULLContext,
*pPsPollContext;
/*Check MgmtContext. */
pMLMEContext =
(struct rt_tx_context *)(pAd->MgmtRing.
Cell[pAd->MgmtRing.
TxDmaIdx].
AllocVa);
pPsPollContext =
(struct rt_tx_context *)(&pAd->PsPollContext);
pNULLContext =
(struct rt_tx_context *)(&pAd->NullContext);
if (pMLMEContext->IRPPending) {
ASSERT(pMLMEContext->
IRPPending);
pUrb = pMLMEContext->pUrb;
} else if (pNULLContext->IRPPending) {
ASSERT(pNULLContext->
IRPPending);
pUrb = pNULLContext->pUrb;
} else if (pPsPollContext->IRPPending) {
ASSERT(pPsPollContext->
IRPPending);
pUrb = pPsPollContext->pUrb;
}
}
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx],
irqFlags);
printk(KERN_INFO "%d:%lu LTL=%d , TL=%d L:%d\n",
idx, pAd->watchDogTxPendingCnt[idx],
pAd->TransferedLength[idx],
actual_length, transfer_buffer_length);
if (pUrb) {
if ((isDataPacket
&& pAd->TransferedLength[idx] ==
actual_length
&& pAd->TransferedLength[idx] <
transfer_buffer_length
&& actual_length != 0
/* && TxRxQ_Pcnt==0 */
&& pAd->watchDogTxPendingCnt[idx] >
3)
|| isDataPacket == FALSE
|| pAd->watchDogTxPendingCnt[idx] >
6) {
DBGPRINT(RT_DEBUG_TRACE,
("Maybe the Tx Bulk-Out hanged! Cancel the pending Tx bulks request of idx(%d)!\n",
idx));
DBGPRINT(RT_DEBUG_TRACE,
("Unlink the pending URB!\n"));
/* unlink it now */
RTUSB_UNLINK_URB(pUrb);
/* Sleep 200 microseconds to give cancellation time to work */
/*RTMPusecDelay(200); */
needDumpSeq = TRUE;
}
} else {
DBGPRINT(RT_DEBUG_ERROR,
("Unknown bulkOut URB maybe hanged!\n"));
}
} else {
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx],
irqFlags);
}
if (isDataPacket == TRUE)
pAd->TransferedLength[idx] = actual_length;
} else {
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
}
}
/* For Sigma debug, dump the ba_reordering sequence. */
if ((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0)) {
u16 Idx;
struct rt_ba_rec_entry *pBAEntry = NULL;
u8 count = 0;
struct reordering_mpdu *mpdu_blk;
Idx = pAd->MacTab.Content[BSSID_WCID].BARecWcidArray[0];
pBAEntry = &pAd->BATable.BARecEntry[Idx];
if ((pBAEntry->list.qlen > 0) && (pBAEntry->list.next != NULL)) {
DBGPRINT(RT_DEBUG_TRACE,
("NICUpdateRawCounters():The Queueing pkt in reordering buffer:\n"));
NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
mpdu_blk = pBAEntry->list.next;
while (mpdu_blk) {
DBGPRINT(RT_DEBUG_TRACE,
("\t%d:Seq-%d, bAMSDU-%d!\n", count,
mpdu_blk->Sequence,
mpdu_blk->bAMSDU));
mpdu_blk = mpdu_blk->next;
count++;
}
DBGPRINT(RT_DEBUG_TRACE,
("\npBAEntry->LastIndSeq=%d!\n",
pBAEntry->LastIndSeq));
NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
}
}
}
/*
========================================================================
Routine Description:
Release allocated resources.
Arguments:
*dev Point to the PCI or USB device
pAd driver control block pointer
Return Value:
None
Note:
========================================================================
*/
static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pAd)
{
DBGPRINT(RT_DEBUG_ERROR,
("rtusb_disconnect: unregister usbnet usb-%s-%s\n",
dev->bus->bus_name, dev->devpath));
if (!pAd) {
usb_put_dev(dev);
printk(KERN_ERR "rtusb_disconnect: pAd == NULL!\n");
return;
}
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST);
/* for debug, wait to show some messages to /proc system */
udelay(1);
RtmpPhyNetDevExit(pAd, pAd->net_dev);
/* FIXME: Shall we need following delay and flush the schedule?? */
udelay(1);
flush_scheduled_work();
udelay(1);
/* free the root net_device */
RtmpOSNetDevFree(pAd->net_dev);
RtmpRaDevCtrlExit(pAd);
/* release a use of the usb device structure */
usb_put_dev(dev);
udelay(1);
DBGPRINT(RT_DEBUG_ERROR, (" RTUSB disconnect successfully\n"));
}
static int __devinit rt2870_probe(IN struct usb_interface *intf,
IN struct usb_device *usb_dev,
IN const struct usb_device_id *dev_id,
struct rt_rtmp_adapter **ppAd)
{
struct net_device *net_dev = NULL;
struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL;
int status, rv;
void *handle;
struct rt_rtmp_os_netdev_op_hook netDevHook;
DBGPRINT(RT_DEBUG_TRACE, ("===>rt2870_probe()!\n"));
/* Check chipset vendor/product ID */
/*if (RT28XXChipsetCheck(_dev_p) == FALSE) */
/* goto err_out; */
/*RtmpDevInit============================================= */
/* Allocate struct rt_rtmp_adapter adapter structure */
handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
if (handle == NULL) {
printk
("rt2870_probe(): Allocate memory for os handle failed!\n");
return -ENOMEM;
}
((struct os_cookie *)handle)->pUsb_Dev = usb_dev;
rv = RTMPAllocAdapterBlock(handle, &pAd);
if (rv != NDIS_STATUS_SUCCESS) {
kfree(handle);
goto err_out;
}
/*USBDevInit============================================== */
if (USBDevConfigInit(usb_dev, intf, pAd) == FALSE)
goto err_out_free_radev;
RtmpRaDevCtrlInit(pAd, RTMP_DEV_INF_USB);
/*NetDevInit============================================== */
net_dev = RtmpPhyNetDevInit(pAd, &netDevHook);
if (net_dev == NULL)
goto err_out_free_radev;
/* Here are the net_device structure with usb specific parameters.
* for supporting Network Manager.
* Set the sysfs physical device reference for the network logical device if set prior to registration will
* cause a symlink during initialization.
*/
SET_NETDEV_DEV(net_dev, &(usb_dev->dev));
pAd->StaCfg.OriDevType = net_dev->type;
/*All done, it's time to register the net device to linux kernel. */
/* Register this device */
status = RtmpOSNetDevAttach(net_dev, &netDevHook);
if (status != 0)
goto err_out_free_netdev;
#ifdef KTHREAD_SUPPORT
init_waitqueue_head(&pAd->mlmeTask.kthread_q);
init_waitqueue_head(&pAd->timerTask.kthread_q);
init_waitqueue_head(&pAd->cmdQTask.kthread_q);
#endif
*ppAd = pAd;
DBGPRINT(RT_DEBUG_TRACE, ("<===rt2870_probe()!\n"));
return 0;
/* --------------------------- ERROR HANDLE --------------------------- */
err_out_free_netdev:
RtmpOSNetDevFree(net_dev);
err_out_free_radev:
RTMPFreeAdapter(pAd);
err_out:
*ppAd = NULL;
return -1;
}

View file

@ -1,390 +0,0 @@
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
wpa.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Justin P. Mattock 11/07/2010 Fix a typo
*/
#ifndef __WPA_H__
#define __WPA_H__
/* EAPOL Key descriptor frame format related length */
#define LEN_KEY_DESC_NONCE 32
#define LEN_KEY_DESC_IV 16
#define LEN_KEY_DESC_RSC 8
#define LEN_KEY_DESC_ID 8
#define LEN_KEY_DESC_REPLAY 8
#define LEN_KEY_DESC_MIC 16
/* The length is the EAPoL-Key frame except key data field. */
/* Please refer to 802.11i-2004 ,Figure 43u in p.78 */
#define LEN_EAPOL_KEY_MSG (sizeof(struct rt_key_descripter) - MAX_LEN_OF_RSNIE)
/* EAP Code Type. */
#define EAP_CODE_REQUEST 1
#define EAP_CODE_RESPONSE 2
#define EAP_CODE_SUCCESS 3
#define EAP_CODE_FAILURE 4
/* EAPOL frame Protocol Version */
#define EAPOL_VER 1
#define EAPOL_VER2 2
/* EAPOL-KEY Descriptor Type */
#define WPA1_KEY_DESC 0xfe
#define WPA2_KEY_DESC 0x02
/* Key Descriptor Version of Key Information */
#define DESC_TYPE_TKIP 1
#define DESC_TYPE_AES 2
#define LEN_MSG1_2WAY 0x7f
#define MAX_LEN_OF_EAP_HS 256
#define LEN_MASTER_KEY 32
/* EAPOL EK, MK */
#define LEN_EAP_EK 16
#define LEN_EAP_MICK 16
#define LEN_EAP_KEY ((LEN_EAP_EK)+(LEN_EAP_MICK))
/* TKIP key related */
#define LEN_PMKID 16
#define LEN_TKIP_EK 16
#define LEN_TKIP_RXMICK 8
#define LEN_TKIP_TXMICK 8
#define LEN_AES_EK 16
#define LEN_AES_KEY LEN_AES_EK
#define LEN_TKIP_KEY ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
#define TKIP_AP_TXMICK_OFFSET ((LEN_EAP_KEY)+(LEN_TKIP_EK))
#define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
#define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
#define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
#define MIN_LEN_OF_GTK 5
#define LEN_PMK 32
#define LEN_PMK_NAME 16
#define LEN_NONCE 32
/* RSN IE Length definition */
#define MAX_LEN_OF_RSNIE 255
#define MIN_LEN_OF_RSNIE 8
#define KEY_LIFETIME 3600
/*EAP Packet Type */
#define EAPPacket 0
#define EAPOLStart 1
#define EAPOLLogoff 2
#define EAPOLKey 3
#define EAPOLASFAlert 4
#define EAPTtypeMax 5
#define EAPOL_MSG_INVALID 0
#define EAPOL_PAIR_MSG_1 1
#define EAPOL_PAIR_MSG_2 2
#define EAPOL_PAIR_MSG_3 3
#define EAPOL_PAIR_MSG_4 4
#define EAPOL_GROUP_MSG_1 5
#define EAPOL_GROUP_MSG_2 6
#define PAIRWISEKEY 1
#define GROUPKEY 0
/* Retry timer counter initial value */
#define PEER_MSG1_RETRY_TIMER_CTR 0
#define PEER_MSG3_RETRY_TIMER_CTR 10
#define GROUP_MSG1_RETRY_TIMER_CTR 20
/*#ifdef CONFIG_AP_SUPPORT */
/* WPA mechanism retry timer interval */
#define PEER_MSG1_RETRY_EXEC_INTV 1000 /* 1 sec */
#define PEER_MSG3_RETRY_EXEC_INTV 3000 /* 3 sec */
#define GROUP_KEY_UPDATE_EXEC_INTV 1000 /* 1 sec */
#define PEER_GROUP_KEY_UPDATE_INIV 2000 /* 2 sec */
#define ENQUEUE_EAPOL_START_TIMER 200 /* 200 ms */
/* group rekey interval */
#define TIME_REKEY 0
#define PKT_REKEY 1
#define DISABLE_REKEY 2
#define MAX_REKEY 2
#define MAX_REKEY_INTER 0x3ffffff
/*#endif // CONFIG_AP_SUPPORT // */
#define GROUP_SUITE 0
#define PAIRWISE_SUITE 1
#define AKM_SUITE 2
#define PMKID_LIST 3
#define EAPOL_START_DISABLE 0
#define EAPOL_START_PSK 1
#define EAPOL_START_1X 2
#define MIX_CIPHER_WPA_TKIP_ON(x) (((x) & 0x08) != 0)
#define MIX_CIPHER_WPA_AES_ON(x) (((x) & 0x04) != 0)
#define MIX_CIPHER_WPA2_TKIP_ON(x) (((x) & 0x02) != 0)
#define MIX_CIPHER_WPA2_AES_ON(x) (((x) & 0x01) != 0)
#ifndef ROUND_UP
#define ROUND_UP(__x, __y) \
(((unsigned long)((__x)+((__y)-1))) & ((unsigned long)~((__y)-1)))
#endif
#define SET_u16_TO_ARRARY(_V, _LEN) \
{ \
_V[0] = (_LEN & 0xFF00) >> 8; \
_V[1] = (_LEN & 0xFF); \
}
#define INC_u16_TO_ARRARY(_V, _LEN) \
{ \
u16 var_len; \
\
var_len = (_V[0]<<8) | (_V[1]); \
var_len += _LEN; \
\
_V[0] = (var_len & 0xFF00) >> 8; \
_V[1] = (var_len & 0xFF); \
}
#define CONV_ARRARY_TO_u16(_V) ((_V[0]<<8) | (_V[1]))
#define ADD_ONE_To_64BIT_VAR(_V) \
{ \
u8 cnt = LEN_KEY_DESC_REPLAY; \
do \
{ \
cnt--; \
_V[cnt]++; \
if (cnt == 0) \
break; \
}while (_V[cnt] == 0); \
}
#define IS_WPA_CAPABILITY(a) (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
/* EAPOL Key Information definition within Key descriptor format */
struct PACKED rt_key_info {
u8 KeyMic:1;
u8 Secure:1;
u8 Error:1;
u8 Request:1;
u8 EKD_DL:1; /* EKD for AP; DL for STA */
u8 Rsvd:3;
u8 KeyDescVer:3;
u8 KeyType:1;
u8 KeyIndex:2;
u8 Install:1;
u8 KeyAck:1;
};
/* EAPOL Key descriptor format */
struct PACKED rt_key_descripter {
u8 Type;
struct rt_key_info KeyInfo;
u8 KeyLength[2];
u8 ReplayCounter[LEN_KEY_DESC_REPLAY];
u8 KeyNonce[LEN_KEY_DESC_NONCE];
u8 KeyIv[LEN_KEY_DESC_IV];
u8 KeyRsc[LEN_KEY_DESC_RSC];
u8 KeyId[LEN_KEY_DESC_ID];
u8 KeyMic[LEN_KEY_DESC_MIC];
u8 KeyDataLen[2];
u8 KeyData[MAX_LEN_OF_RSNIE];
};
struct PACKED rt_eapol_packet {
u8 ProVer;
u8 ProType;
u8 Body_Len[2];
struct rt_key_descripter KeyDesc;
};
/*802.11i D10 page 83 */
struct PACKED rt_gtk_encap {
u8 Kid:2;
u8 tx:1;
u8 rsv:5;
u8 rsv1;
u8 GTK[TKIP_GTK_LENGTH];
};
struct PACKED rt_kde_encap {
u8 Type;
u8 Len;
u8 OUI[3];
u8 DataType;
struct rt_gtk_encap GTKEncap;
};
/* For WPA1 */
struct PACKED rt_rsnie {
u8 oui[4];
u16 version;
u8 mcast[4];
u16 ucount;
struct PACKED {
u8 oui[4];
} ucast[1];
};
/* For WPA2 */
struct PACKED rt_rsnie2 {
u16 version;
u8 mcast[4];
u16 ucount;
struct PACKED {
u8 oui[4];
} ucast[1];
};
/* AKM Suite */
struct PACKED rt_rsnie_auth {
u16 acount;
struct PACKED {
u8 oui[4];
} auth[1];
};
typedef union PACKED _RSN_CAPABILITIES {
struct PACKED {
u16 PreAuth:1;
u16 No_Pairwise:1;
u16 PTKSA_R_Counter:2;
u16 GTKSA_R_Counter:2;
u16 Rsvd:10;
} field;
u16 word;
} RSN_CAPABILITIES, *PRSN_CAPABILITIES;
struct PACKED rt_eap_hdr {
u8 ProVer;
u8 ProType;
u8 Body_Len[2];
u8 code;
u8 identifier;
u8 length[2]; /* including code and identifier, followed by length-2 octets of data */
};
/* For supplicant state machine states. 802.11i Draft 4.1, p. 97 */
/* We simplified it */
typedef enum _WpaState {
SS_NOTUSE, /* 0 */
SS_START, /* 1 */
SS_WAIT_MSG_3, /* 2 */
SS_WAIT_GROUP, /* 3 */
SS_FINISH, /* 4 */
SS_KEYUPDATE, /* 5 */
} WPA_STATE;
/* */
/* The definition of the cipher combination */
/* */
/* bit3 bit2 bit1 bit0 */
/* +------------+------------+ */
/* | WPA | WPA2 | */
/* +------+-----+------+-----+ */
/* | TKIP | AES | TKIP | AES | */
/* | 0 | 1 | 1 | 0 | -> 0x06 */
/* | 0 | 1 | 1 | 1 | -> 0x07 */
/* | 1 | 0 | 0 | 1 | -> 0x09 */
/* | 1 | 0 | 1 | 1 | -> 0x0B */
/* | 1 | 1 | 0 | 1 | -> 0x0D */
/* | 1 | 1 | 1 | 0 | -> 0x0E */
/* | 1 | 1 | 1 | 1 | -> 0x0F */
/* +------+-----+------+-----+ */
/* */
typedef enum _WpaMixPairCipher {
MIX_CIPHER_NOTUSE = 0x00,
WPA_NONE_WPA2_TKIPAES = 0x03, /* WPA2-TKIPAES */
WPA_AES_WPA2_TKIP = 0x06,
WPA_AES_WPA2_TKIPAES = 0x07,
WPA_TKIP_WPA2_AES = 0x09,
WPA_TKIP_WPA2_TKIPAES = 0x0B,
WPA_TKIPAES_WPA2_NONE = 0x0C, /* WPA-TKIPAES */
WPA_TKIPAES_WPA2_AES = 0x0D,
WPA_TKIPAES_WPA2_TKIP = 0x0E,
WPA_TKIPAES_WPA2_TKIPAES = 0x0F,
} WPA_MIX_PAIR_CIPHER;
struct PACKED rt_rsn_ie_header {
u8 Eid;
u8 Length;
u16 Version; /* Little endian format */
};
/* Cipher suite selector types */
struct PACKED rt_cipher_suite_struct {
u8 Oui[3];
u8 Type;
};
/* Authentication and Key Management suite selector */
struct PACKED rt_akm_suite {
u8 Oui[3];
u8 Type;
};
/* RSN capability */
struct PACKED rt_rsn_capability {
u16 Rsv:10;
u16 GTKSAReplayCnt:2;
u16 PTKSAReplayCnt:2;
u16 NoPairwise:1;
u16 PreAuth:1;
};
/*========================================
The prototype is defined in cmm_wpa.c
========================================*/
BOOLEAN WpaMsgTypeSubst(u8 EAPType, int *MsgType);
void PRF(u8 *key, int key_len, u8 *prefix, int prefix_len,
u8 *data, int data_len, u8 *output, int len);
int PasswordHash(char *password,
unsigned char *ssid, int ssidlength, unsigned char *output);
u8 *GetSuiteFromRSNIE(u8 *rsnie, u32 rsnie_len, u8 type, u8 *count);
void WpaShowAllsuite(u8 *rsnie, u32 rsnie_len);
void RTMPInsertRSNIE(u8 *pFrameBuf,
unsigned long *pFrameLen,
u8 *rsnie_ptr,
u8 rsnie_len,
u8 *pmkid_ptr, u8 pmkid_len);
#endif

View file

@ -1,9 +0,0 @@
config RT2870
tristate "Ralink 2870/3070 wireless support"
depends on USB && (X86 || ARM) && WLAN
select WIRELESS_EXT
select WEXT_PRIV
select CRC_CCITT
select FW_LOADER
---help---
This is an experimental driver for the Ralink xx70 wireless chips.

View file

@ -1,55 +0,0 @@
#
obj-$(CONFIG_RT2870) += rt2870sta.o
# TODO: all of these should be removed
ccflags-y := -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
ccflags-y += -DRTMP_MAC_USB -DRTMP_USB_SUPPORT -DRT2870 -DRTMP_TIMER_TASK_SUPPORT
ccflags-y += -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT -DRT30xx -DRT3070
ccflags-y += -DDBG
rt2870sta-y := \
common/crypt_md5.o \
common/crypt_sha2.o \
common/crypt_hmac.o \
common/mlme.o \
common/cmm_wep.o \
common/action.o \
common/cmm_data.o \
common/rtmp_init.o \
common/cmm_tkip.o \
common/cmm_aes.o \
common/cmm_sync.o \
common/eeprom.o \
common/cmm_sanity.o \
common/cmm_info.o \
common/cmm_cfg.o \
common/cmm_wpa.o \
common/dfs.o \
common/spectrum.o \
common/rtmp_timer.o \
common/rt_channel.o \
common/cmm_asic.o \
sta/assoc.o \
sta/auth.o \
sta/auth_rsp.o \
sta/sync.o \
sta/sanity.o \
sta/rtmp_data.o \
sta/connect.o \
sta/wpa.o \
rt_linux.o \
rt_main_dev.o \
sta_ioctl.o \
common/ba_action.o \
usb_main_dev.o \
rt_usb.o \
common/cmm_mac_usb.o \
common/rtusb_io.o \
common/rtusb_bulk.o \
common/rtusb_data.o \
common/cmm_data_usb.o \
common/rtmp_mcu.o \
common/ee_efuse.o \
chips/rt30xx.o \
common/rt_rf.o \
chips/rt3070.o

View file

@ -1,17 +0,0 @@
I'm hesitant to add a TODO file here, as the wireless developers would
really have people help them out on the "clean" rt2870 driver that can
be found at the http://rt2x00.serialmonkey.com/ site.
But, if you wish to clean up this driver instead, here's a short list of
things that need to be done to get it into a more mergable shape:
TODO:
- checkpatch.pl clean
- sparse clean
- port to in-kernel 80211 stack and common rt2x00 infrastructure
- remove reading from /etc/ config files
- review by the wireless developer community
Please send any patches or complaints about this driver to Greg
Kroah-Hartman <greg@kroah.com> and don't bother the upstream wireless
kernel developers about it, they want nothing to do with it.

View file

@ -1 +0,0 @@
#include "../rt2860/aironet.h"

View file

@ -1 +0,0 @@
#include "../rt2860/ap.h"

View file

@ -1 +0,0 @@
#include "../../rt2860/chips/rt3070.c"

View file

@ -1 +0,0 @@
#include "../../rt2860/chips/rt30xx.c"

View file

@ -1 +0,0 @@
#include "../rt2860/chlist.h"

View file

@ -1 +0,0 @@
#include "../../rt2860/common/action.c"

View file

@ -1 +0,0 @@
#include "../../rt2860/common/action.c"

Some files were not shown because too many files have changed in this diff Show more