blob: 82b6e783b33fd4916f65cbe0a978850019a3ec5d [file] [log] [blame]
* 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 *
* 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:
Miniport generic portion header file
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Lin 2002-08-01 created
James Tan 2002-09-06 modified (Revise NTCRegTable)
John Chang 2004-09-06 modified for RT2600
#ifndef __RTMP_H__
#define __RTMP_H__
#include "spectrum_def.h"
#include "rtmp_dot11.h"
#include "rtmp_chip.h"
struct rt_rtmp_adapter;
/*#define DBG 1 */
/*#define DBG_DIAGNOSE 1 */
/*+++Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
#define MGMT_USE_QUEUE_FLAG 0x80
/*---Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
#define MAXSEQ (0xFFF)
extern unsigned char SNAP_AIRONET[];
extern unsigned char CISCO_OUI[];
extern u8 BaSizeArray[4];
extern unsigned long BIT32[32];
extern u8 BIT8[8];
extern char *CipherName[];
extern char *MCSToMbps[];
extern u8 RxwiMCSToOfdmRate[12];
extern u8 SNAP_802_1H[6];
extern u8 SNAP_BRIDGE_TUNNEL[6];
extern u8 SNAP_AIRONET[8];
extern u8 CKIP_LLC_SNAP[8];
extern u8 EAPOL_LLC_SNAP[8];
extern u8 EAPOL[2];
extern u8 IPX[2];
extern u8 APPLE_TALK[2];
extern u8 RateIdToPlcpSignal[12]; /* see IEEE802.11a-1999 p.14 */
extern u8 OfdmRateToRxwiMCS[];
extern u8 OfdmSignalToRateId[16];
extern u8 default_cwmin[4];
extern u8 default_cwmax[4];
extern u8 default_sta_aifsn[4];
extern u8 MapUserPriorityToAccessCategory[8];
extern u16 RateUpPER[];
extern u16 RateDownPER[];
extern u8 Phy11BNextRateDownward[];
extern u8 Phy11BNextRateUpward[];
extern u8 Phy11BGNextRateDownward[];
extern u8 Phy11BGNextRateUpward[];
extern u8 Phy11ANextRateDownward[];
extern u8 Phy11ANextRateUpward[];
extern char RssiSafeLevelForTxRate[];
extern u8 RateIdToMbps[];
extern u16 RateIdTo500Kbps[];
extern u8 CipherSuiteWpaNoneTkip[];
extern u8 CipherSuiteWpaNoneTkipLen;
extern u8 CipherSuiteWpaNoneAes[];
extern u8 CipherSuiteWpaNoneAesLen;
extern u8 SsidIe;
extern u8 SupRateIe;
extern u8 ExtRateIe;
extern u8 HtCapIe;
extern u8 AddHtInfoIe;
extern u8 NewExtChanIe;
extern u8 ErpIe;
extern u8 DsIe;
extern u8 TimIe;
extern u8 WpaIe;
extern u8 Wpa2Ie;
extern u8 IbssIe;
extern u8 Ccx2Ie;
extern u8 WapiIe;
extern u8 WPA_OUI[];
extern u8 RSN_OUI[];
extern u8 WAPI_OUI[];
extern u8 WME_INFO_ELEM[];
extern u8 WME_PARM_ELEM[];
extern u8 Ccx2QosInfo[];
extern u8 Ccx2IeInfo[];
extern u8 RALINK_OUI[];
extern u8 PowerConstraintIE[];
extern u8 RateSwitchTable[];
extern u8 RateSwitchTable11B[];
extern u8 RateSwitchTable11G[];
extern u8 RateSwitchTable11BG[];
extern u8 RateSwitchTable11BGN1S[];
extern u8 RateSwitchTable11BGN2S[];
extern u8 RateSwitchTable11BGN2SForABand[];
extern u8 RateSwitchTable11N1S[];
extern u8 RateSwitchTable11N2S[];
extern u8 RateSwitchTable11N2SForABand[];
extern u8 PRE_N_HT_OUI[];
struct rt_rssi_sample {
char LastRssi0; /* last received RSSI */
char LastRssi1; /* last received RSSI */
char LastRssi2; /* last received RSSI */
char AvgRssi0;
char AvgRssi1;
char AvgRssi2;
short AvgRssi0X8;
short AvgRssi1X8;
short AvgRssi2X8;
/* */
/* Queue structure and macros */
/* */
struct rt_queue_entry;
struct rt_queue_entry {
struct rt_queue_entry *Next;
/* Queue structure */
struct rt_queue_header {
struct rt_queue_entry *Head;
struct rt_queue_entry *Tail;
unsigned long Number;
#define InitializeQueueHeader(QueueHeader) \
{ \
(QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
(QueueHeader)->Number = 0; \
#define RemoveHeadQueue(QueueHeader) \
(QueueHeader)->Head; \
{ \
struct rt_queue_entry *pNext; \
if ((QueueHeader)->Head != NULL) { \
pNext = (QueueHeader)->Head->Next; \
(QueueHeader)->Head->Next = NULL; \
(QueueHeader)->Head = pNext; \
if (pNext == NULL) \
(QueueHeader)->Tail = NULL; \
(QueueHeader)->Number--; \
} \
#define InsertHeadQueue(QueueHeader, QueueEntry) \
{ \
((struct rt_queue_entry *)QueueEntry)->Next = (QueueHeader)->Head; \
(QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry); \
if ((QueueHeader)->Tail == NULL) \
(QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry); \
(QueueHeader)->Number++; \
#define InsertTailQueue(QueueHeader, QueueEntry) \
{ \
((struct rt_queue_entry *)QueueEntry)->Next = NULL; \
if ((QueueHeader)->Tail) \
(QueueHeader)->Tail->Next = (struct rt_queue_entry *)(QueueEntry); \
else \
(QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry); \
(QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry); \
(QueueHeader)->Number++; \
#define InsertTailQueueAc(pAd, pEntry, QueueHeader, QueueEntry) \
{ \
((struct rt_queue_entry *)QueueEntry)->Next = NULL; \
if ((QueueHeader)->Tail) \
(QueueHeader)->Tail->Next = (struct rt_queue_entry *)(QueueEntry); \
else \
(QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry); \
(QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry); \
(QueueHeader)->Number++; \
/* */
/* Macros for flag and ref count operations */
/* */
#define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
#define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
#define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
#define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
#define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
/* Macro for power save flag. */
#define RTMP_SET_PSFLAG(_M, _F) ((_M)->PSFlags |= (_F))
#define RTMP_CLEAR_PSFLAG(_M, _F) ((_M)->PSFlags &= ~(_F))
#define RTMP_CLEAR_PSFLAGS(_M) ((_M)->PSFlags = 0)
#define RTMP_TEST_PSFLAG(_M, _F) (((_M)->PSFlags & (_F)) != 0)
#define RTMP_TEST_PSFLAGS(_M, _F) (((_M)->PSFlags & (_F)) == (_F))
#define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
#define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
#define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
#define CLIENT_STATUS_SET_FLAG(_pEntry, _F) ((_pEntry)->ClientStatusFlags |= (_F))
#define CLIENT_STATUS_CLEAR_FLAG(_pEntry, _F) ((_pEntry)->ClientStatusFlags &= ~(_F))
#define CLIENT_STATUS_TEST_FLAG(_pEntry, _F) (((_pEntry)->ClientStatusFlags & (_F)) != 0)
#define RX_FILTER_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter |= (_F))
#define RX_FILTER_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
#define RX_FILTER_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
#define STA_NO_SECURITY_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
#define STA_WEP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
#define STA_TKIP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
#define STA_AES_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
#define STA_TGN_WIFI_ON(_p) (_p->StaCfg.bTGnWifiTest == TRUE)
#define CKIP_KP_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
#define CKIP_CMIC_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
#define INC_RING_INDEX(_idx, _RingSize) \
{ \
(_idx) = (_idx+1) % (_RingSize); \
/* StaActive.SupportedHtPhy.MCSSet is copied from AP beacon. Don't need to update here. */
{ \
_pAd->StaActive.SupportedHtPhy.ChannelWidth = _pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth; \
_pAd->StaActive.SupportedHtPhy.MimoPs = _pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs; \
_pAd->StaActive.SupportedHtPhy.GF = _pAd->MlmeAux.HtCapability.HtCapInfo.GF; \
_pAd->StaActive.SupportedHtPhy.ShortGIfor20 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20; \
_pAd->StaActive.SupportedHtPhy.ShortGIfor40 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40; \
_pAd->StaActive.SupportedHtPhy.TxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC; \
_pAd->StaActive.SupportedHtPhy.RxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC; \
_pAd->StaActive.SupportedHtPhy.ExtChanOffset = _pAd->MlmeAux.AddHtInfo.AddHtInfo.ExtChanOffset; \
_pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth; \
_pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode; \
_pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent; \
NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(u8) * 16);\
#define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability) \
{ \
_pAd->MacTab.Content[BSSID_WCID].AMsduSize = (u8)(_pHtCapability->HtCapInfo.AMsduSize); \
_pAd->MacTab.Content[BSSID_WCID].MmpsMode = (u8)(_pHtCapability->HtCapInfo.MimoPs); \
_pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (u8)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \
/* */
/* MACRO for 32-bit PCI register read / write */
/* */
/* Usage : RTMP_IO_READ32( */
/* struct rt_rtmp_adapter *pAd, */
/* unsigned long Register_Offset, */
/* unsigned long * pValue) */
/* */
/* RTMP_IO_WRITE32( */
/* struct rt_rtmp_adapter *pAd, */
/* unsigned long Register_Offset, */
/* unsigned long Value) */
/* */
/* */
/* Common fragment list structure - Identical to the scatter gather frag list structure */
/* */
/*#define struct rt_rtmp_sg_element SCATTER_GATHER_ELEMENT */
/*#define struct rt_rtmp_sg_element *PSCATTER_GATHER_ELEMENT */
struct rt_rtmp_sg_element {
void *Address;
unsigned long Length;
unsigned long *Reserved;
struct rt_rtmp_sg_list {
unsigned long NumberOfElements;
unsigned long *Reserved;
struct rt_rtmp_sg_element Elements[NIC_MAX_PHYS_BUF_COUNT];
/* */
/* Some utility macros */
/* */
#ifndef min
#define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
#ifndef max
#define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
#define GET_LNA_GAIN(_pAd) ((_pAd->LatchRfRegs.Channel <= 14) ? (_pAd->BLNAGain) : ((_pAd->LatchRfRegs.Channel <= 64) ? (_pAd->ALNAGain0) : ((_pAd->LatchRfRegs.Channel <= 128) ? (_pAd->ALNAGain1) : (_pAd->ALNAGain2))))
#define INC_COUNTER64(Val) (Val.QuadPart++)
#define MONITOR_ON(_p) (((_p)->StaCfg.BssType) == BSS_MONITOR)
#define IDLE_ON(_p) (!INFRA_ON(_p) && !ADHOC_ON(_p))
/* Check LEAP & CCKM flags */
#define LEAP_ON(_p) (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
#define LEAP_CCKM_ON(_p) ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
/* if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required */
#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap) \
{ \
if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) { \
_pExtraLlcSnapEncap = SNAP_802_1H; \
if (NdisEqualMemory(IPX, _pBufVA + 12, 2) || \
NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) { \
_pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
} \
} \
else { \
_pExtraLlcSnapEncap = NULL; \
} \
/* New Define for new Tx Path. */
#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap) \
{ \
if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) { \
_pExtraLlcSnapEncap = SNAP_802_1H; \
if (NdisEqualMemory(IPX, _pBufVA, 2) || \
NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) { \
_pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
} \
} \
else { \
_pExtraLlcSnapEncap = NULL; \
} \
#define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType) \
{ \
NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN); \
NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN); \
NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
/* if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way. */
/* else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field */
/* else remove the LLC/SNAP field from the result Ethernet frame */
/* Patch for WHQL only, which did not turn on Netbios but use IPX within its payload */
/* Note: */
/* _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO */
/* _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed */
#define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP) \
{ \
char LLC_Len[2]; \
_pRemovedLLCSNAP = NULL; \
if (NdisEqualMemory(SNAP_802_1H, _pData, 6) || \
NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) { \
u8 *pProto = _pData + 6; \
if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \
NdisEqualMemory(SNAP_802_1H, _pData, 6)) { \
LLC_Len[0] = (u8)(_DataSize / 256); \
LLC_Len[1] = (u8)(_DataSize % 256); \
MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
} \
else { \
MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \
_pRemovedLLCSNAP = _pData; \
_DataSize -= LENGTH_802_1_H; \
_pData += LENGTH_802_1_H; \
} \
} \
else { \
LLC_Len[0] = (u8)(_DataSize / 256); \
LLC_Len[1] = (u8)(_DataSize % 256); \
MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
} \
/* Enqueue this frame to MLME engine */
/* We need to enqueue the whole frame because MLME need to pass data type */
/* information from 802.11 header */
#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
{ \
u32 High32TSF, Low32TSF; \
RTMP_IO_READ32(_pAd, TSF_TIMER_DW1, &High32TSF); \
MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal); \
#endif /* RTMP_MAC_PCI // */
#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
{ \
u32 High32TSF = 0, Low32TSF = 0; \
MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal); \
#endif /* RTMP_MAC_USB // */
#define MAC_ADDR_EQUAL(pAddr1, pAddr2) RTMPEqualMemory((void *)(pAddr1), (void *)(pAddr2), MAC_ADDR_LEN)
#define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1 == len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
/* */
/* Check if it is Japan W53(ch52,56,60,64) channel. */
/* */
#define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
#define STA_PORT_SECURED(_pAd) \
{ \
BOOLEAN Cancelled; \
(_pAd)->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
NdisAcquireSpinLock(&((_pAd)->MacTabLock)); \
(_pAd)->MacTab.Content[BSSID_WCID].PortSecured = (_pAd)->StaCfg.PortSecured; \
(_pAd)->MacTab.Content[BSSID_WCID].PrivacyFilter = Ndis802_11PrivFilterAcceptAll;\
NdisReleaseSpinLock(&(_pAd)->MacTabLock); \
RTMPCancelTimer(&((_pAd)->Mlme.LinkDownTimer), &Cancelled);\
/* */
/* Data buffer for DMA operation, the buffer must be contiguous physical memory */
/* Both DMA to / from CPU use the same structure. */
/* */
struct rt_rtmp_dmabuf {
unsigned long AllocSize;
void *AllocVa; /* TxBuf virtual address */
dma_addr_t AllocPa; /* TxBuf physical address */
/* */
/* Control block (Descriptor) for all ring descriptor DMA operation, buffer must be */
/* contiguous physical memory. char stored the binding Rx packet descriptor */
/* which won't be released, driver has to wait until upper layer return the packet */
/* before giveing up this rx ring descriptor to ASIC. NDIS_BUFFER is assocaited pair */
/* to describe the packet buffer. For Tx, char stored the tx packet descriptor */
/* which driver should ACK upper layer when the tx is physically done or failed. */
/* */
struct rt_rtmp_dmacb {
unsigned long AllocSize; /* Control block size */
void *AllocVa; /* Control block virtual address */
dma_addr_t AllocPa; /* Control block physical address */
void *pNdisPacket;
void *pNextNdisPacket;
struct rt_rtmp_dmabuf DmaBuf; /* Associated DMA buffer structure */
struct rt_rtmp_tx_ring {
struct rt_rtmp_dmacb Cell[TX_RING_SIZE];
u32 TxCpuIdx;
u32 TxDmaIdx;
u32 TxSwFreeIdx; /* software next free tx index */
struct rt_rtmp_rx_ring {
struct rt_rtmp_dmacb Cell[RX_RING_SIZE];
u32 RxCpuIdx;
u32 RxDmaIdx;
int RxSwReadIdx; /* software next read index */
struct rt_rtmp_mgmt_ring {
struct rt_rtmp_dmacb Cell[MGMT_RING_SIZE];
u32 TxCpuIdx;
u32 TxDmaIdx;
u32 TxSwFreeIdx; /* software next free tx index */
/* */
/* Statistic counter structure */
/* */
struct rt_counter_802_3 {
/* General Stats */
unsigned long GoodTransmits;
unsigned long GoodReceives;
unsigned long TxErrors;
unsigned long RxErrors;
unsigned long RxNoBuffer;
/* Ethernet Stats */
unsigned long RcvAlignmentErrors;
unsigned long OneCollision;
unsigned long MoreCollisions;
struct rt_counter_802_11 {
unsigned long Length;
LARGE_INTEGER LastTransmittedFragmentCount;
LARGE_INTEGER TransmittedFragmentCount;
LARGE_INTEGER MulticastTransmittedFrameCount;
LARGE_INTEGER MultipleRetryCount;
LARGE_INTEGER FrameDuplicateCount;
LARGE_INTEGER ReceivedFragmentCount;
LARGE_INTEGER MulticastReceivedFrameCount;
struct rt_counter_ralink {
unsigned long TransmittedByteCount; /* both successful and failure, used to calculate TX throughput */
unsigned long ReceivedByteCount; /* both CRC okay and CRC error, used to calculate RX throughput */
unsigned long BeenDisassociatedCount;
unsigned long BadCQIAutoRecoveryCount;
unsigned long PoorCQIRoamingCount;
unsigned long MgmtRingFullCount;
unsigned long RxCountSinceLastNULL;
unsigned long RxCount;
unsigned long RxRingErrCount;
unsigned long KickTxCount;
unsigned long TxRingErrCount;
unsigned long PendingNdisPacketCount;
unsigned long OneSecOsTxCount[NUM_OF_TX_RING];
unsigned long OneSecDmaDoneCount[NUM_OF_TX_RING];
u32 OneSecTxDoneCount;
unsigned long OneSecRxCount;
u32 OneSecTxAggregationCount;
u32 OneSecRxAggregationCount;
u32 OneSecReceivedByteCount;
u32 OneSecFrameDuplicateCount;
u32 OneSecTransmittedByteCount; /* both successful and failure, used to calculate TX throughput */
u32 OneSecTxNoRetryOkCount;
u32 OneSecTxRetryOkCount;
u32 OneSecTxFailCount;
u32 OneSecFalseCCACnt; /* CCA error count, for debug purpose, might move to global counter */
u32 OneSecRxOkCnt; /* RX without error */
u32 OneSecRxOkDataCnt; /* unicast-to-me DATA frame count */
u32 OneSecRxFcsErrCnt; /* CRC error */
u32 OneSecBeaconSentCnt;
u32 LastOneSecTotalTxCount; /* OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount */
u32 LastOneSecRxOkDataCnt; /* OneSecRxOkDataCnt */
unsigned long DuplicateRcv;
unsigned long TxAggCount;
unsigned long TxNonAggCount;
unsigned long TxAgg1MPDUCount;
unsigned long TxAgg2MPDUCount;
unsigned long TxAgg3MPDUCount;
unsigned long TxAgg4MPDUCount;
unsigned long TxAgg5MPDUCount;
unsigned long TxAgg6MPDUCount;
unsigned long TxAgg7MPDUCount;
unsigned long TxAgg8MPDUCount;
unsigned long TxAgg9MPDUCount;
unsigned long TxAgg10MPDUCount;
unsigned long TxAgg11MPDUCount;
unsigned long TxAgg12MPDUCount;
unsigned long TxAgg13MPDUCount;
unsigned long TxAgg14MPDUCount;
unsigned long TxAgg15MPDUCount;
unsigned long TxAgg16MPDUCount;
LARGE_INTEGER TransmittedOctetsInAMPDUCount;
struct rt_counter_drs {
/* to record the each TX rate's quality. 0 is best, the bigger the worse. */
u8 TxRateUpPenalty; /* extra # of second penalty due to last unstable condition */
unsigned long CurrTxRateStableTime; /* # of second in current TX rate */
BOOLEAN fNoisyEnvironment;
BOOLEAN fLastSecAccordingRSSI;
u8 LastSecTxRateChangeAction; /* 0: no change, 1:rate UP, 2:rate down */
u8 LastTimeTxRateChangeAction; /*Keep last time value of LastSecTxRateChangeAction */
unsigned long LastTxOkCount;
* security key related data structure
struct rt_cipher_key {
u8 Key[16]; /* right now we implement 4 keys, 128 bits max */
u8 RxMic[8]; /* make alignment */
u8 TxMic[8];
u8 TxTsc[6]; /* 48bit TSC value */
u8 RxTsc[6]; /* 48bit TSC value */
u8 CipherAlg; /* 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128 */
u8 KeyLen;
u8 BssId[6];
/* Key length for each key, 0: entry is invalid */
u8 Type; /* Indicate Pairwise/Group when reporting MIC error */
/* structure to define WPA Group Key Rekey Interval */
struct PACKED rt_802_11_wpa_rekey {
unsigned long ReKeyMethod; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
unsigned long ReKeyInterval; /* time-based: seconds, packet-based: kilo-packets */
* RTUSB I/O related data structure
struct rt_set_asic_wcid {
unsigned long WCID; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
unsigned long SetTid; /* time-based: seconds, packet-based: kilo-packets */
unsigned long DeleteTid; /* time-based: seconds, packet-based: kilo-packets */
u8 Addr[MAC_ADDR_LEN]; /* avoid in interrupt when write key */
struct rt_set_asic_wcid_attri {
unsigned long WCID; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
unsigned long Cipher; /* ASIC Cipher definition */
/* for USB interface, avoid in interrupt when write key */
struct rt_add_pairwise_key_entry {
u8 MacAddr[6];
u16 MacTabMatchWCID; /* ASIC */
struct rt_cipher_key CipherKey;
/* Cipher suite type for mixed mode group cipher, P802.11i-2004 */
typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
#endif /* RTMP_MAC_USB // */
struct rt_rogueap_entry {
u8 Addr[MAC_ADDR_LEN];
u8 ErrorCode[2]; /*00 01-Invalid authentication type */
/*00 02-Authentication timeout */
/*00 03-Challenge from AP failed */
/*00 04-Challenge to AP failed */
BOOLEAN Reported;
struct rt_rogueap_table {
u8 RogueApNr;
struct rt_rogueap_entry RogueApEntry[MAX_LEN_OF_BSS_TABLE];
/* */
/* Cisco IAPP format */
/* */
struct rt_cisco_iapp_content {
u16 Length; /*IAPP Length */
u8 MessageType; /*IAPP type */
u8 FunctionCode; /*IAPP function type */
u8 DestinaionMAC[MAC_ADDR_LEN];
u16 Tag; /*Tag(element IE) - Adjacent AP report */
u16 TagLength; /*Length of element not including 4 byte header */
u8 OUI[4]; /*0x00, 0x40, 0x96, 0x00 */
u8 PreviousAP[MAC_ADDR_LEN]; /*MAC Address of access point */
u16 Channel;
u16 SsidLen;
u16 Seconds; /*Seconds that the client has been disassociated. */
* Fragment Frame structure
struct rt_fragment_frame {
void *pFragPacket;
unsigned long RxSize;
u16 Sequence;
u16 LastFrag;
unsigned long Flags; /* Some extra frame information. bit 0: LLC presented */
/* */
/* Packet information for NdisQueryPacket */
/* */
struct rt_packet_info {
u32 PhysicalBufferCount; /* Physical breaks of buffer descripor chained */
u32 BufferCount; /* Number of Buffer descriptor chained */
u32 TotalPacketLength; /* Self explained */
char *pFirstBuffer; /* Pointer to first buffer descriptor */
/* */
/* Arcfour Structure Added by PaulWu */
/* */
struct rt_arcfourcontext {
u32 X;
u32 Y;
u8 STATE[256];
/* */
/* Tkip Key structure which RC4 key & MIC calculation */
/* */
struct rt_tkip_key_info {
u32 nBytesInM; /* # bytes in M for MICKEY */
unsigned long IV16;
unsigned long IV32;
unsigned long K0; /* for MICKEY Low */
unsigned long K1; /* for MICKEY Hig */
unsigned long L; /* Current state for MICKEY */
unsigned long R; /* Current state for MICKEY */
unsigned long M; /* Message accumulator for MICKEY */
u8 RC4KEY[16];
u8 MIC[8];
/* */
/* Private / Misc data, counters for driver internal use */
/* */
struct rt_private {
u32 SystemResetCnt; /* System reset counter */
u32 TxRingFullCnt; /* Tx ring full occurrance number */
u32 PhyRxErrCnt; /* PHY Rx error count, for debug purpose, might move to global counter */
/* Variables for WEP encryption / decryption in rtmp_wep.c */
u32 FCSCRC32;
struct rt_arcfourcontext WEPCONTEXT;
/* Tkip stuff */
struct rt_tkip_key_info Tx;
struct rt_tkip_key_info Rx;
* Channel and BBP related data structures
/* structure to tune BBP R66 (BBP TUNING) */
struct rt_bbp_r66_tuning {
BOOLEAN bEnable;
u16 FalseCcaLowerThreshold; /* default 100 */
u16 FalseCcaUpperThreshold; /* default 512 */
u8 R66Delta;
u8 R66CurrentValue;
BOOLEAN R66LowerUpperSelect; /*Before LinkUp, Used LowerBound or UpperBound as R66 value. */
/* structure to store channel TX power */
struct rt_channel_tx_power {
u16 RemainingTimeForUse; /*unit: sec */
u8 Channel;
char Power;
char Power2;
u8 MaxTxPwr;
u8 DfsReq;
/* structure to store 802.11j channel TX power */
struct rt_channel_11j_tx_power {
u8 Channel;
u8 BW; /* BW_10 or BW_20 */
char Power;
char Power2;
u16 RemainingTimeForUse; /*unit: sec */
struct rt_soft_rx_ant_diversity {
u8 EvaluatePeriod; /* 0:not evalute status, 1: evaluate status, 2: switching status */
u8 EvaluateStableCnt;
u8 Pair1PrimaryRxAnt; /* 0:Ant-E1, 1:Ant-E2 */
u8 Pair1SecondaryRxAnt; /* 0:Ant-E1, 1:Ant-E2 */
u8 Pair2PrimaryRxAnt; /* 0:Ant-E3, 1:Ant-E4 */
u8 Pair2SecondaryRxAnt; /* 0:Ant-E3, 1:Ant-E4 */
short Pair1AvgRssi[2]; /* AvgRssi[0]:E1, AvgRssi[1]:E2 */
short Pair2AvgRssi[2]; /* AvgRssi[0]:E3, AvgRssi[1]:E4 */
short Pair1LastAvgRssi; /* */
short Pair2LastAvgRssi; /* */
unsigned long RcvPktNumWhenEvaluate;
BOOLEAN FirstPktArrivedWhenEvaluate;
struct rt_ralink_timer RxAntDiversityTimer;
* structure for radar detection and channel switch
struct rt_radar_detect {
/*BOOLEAN IEEE80211H; // 0: disable, 1: enable IEEE802.11h */
u8 CSCount; /*Channel switch counter */
u8 CSPeriod; /*Channel switch period (beacon count) */
u8 RDCount; /*Radar detection counter */
u8 RDMode; /*Radar Detection mode */
u8 RDDurRegion; /*Radar detection duration region */
u8 BBPR16;
u8 BBPR17;
u8 BBPR18;
u8 BBPR21;
u8 BBPR22;
u8 BBPR64;
unsigned long InServiceMonitorCount; /* unit: sec */
u8 DfsSessionTime;
u8 ChMovingTime;
u8 LongPulseRadarTh;
typedef enum _ABGBAND_STATE_ {
/* Power save method control */
typedef union _PS_CONTROL {
struct {
unsigned long EnablePSinIdle:1; /* Enable radio off when not connect to AP. radio on only when sitesurvey, */
unsigned long EnableNewPS:1; /* Enable new Chip power save fucntion . New method can only be applied in chip version after 2872. and PCIe. */
unsigned long rt30xxPowerMode:2; /* Power Level Mode for rt30xx chip */
unsigned long rt30xxFollowHostASPM:1; /* Card Follows Host's setting for rt30xx chip. */
unsigned long rt30xxForceASPMTest:1; /* Force enable L1 for rt30xx chip. This has higher priority than rt30xxFollowHostASPM Mode. */
unsigned long rsv:26; /* Radio Measurement Enable */
} field;
unsigned long word;
#endif /* RTMP_MAC_PCI // */
* structure for MLME state machine
struct rt_mlme {
/* STA state machines */
struct rt_state_machine CntlMachine;
struct rt_state_machine AssocMachine;
struct rt_state_machine AuthMachine;
struct rt_state_machine AuthRspMachine;
struct rt_state_machine SyncMachine;
struct rt_state_machine WpaPskMachine;
struct rt_state_machine LeapMachine;
/* Action */
struct rt_state_machine ActMachine;
/* common WPA state machine */
struct rt_state_machine WpaMachine;
unsigned long ChannelQuality; /* 0..100, Channel Quality Indication for Roaming */
unsigned long Now32; /* latch the value of NdisGetSystemUpTime() */
unsigned long LastSendNULLpsmTime;
BOOLEAN bRunning;
spinlock_t TaskLock;
struct rt_mlme_queue Queue;
u32 ShiftReg;
struct rt_ralink_timer PeriodicTimer;
struct rt_ralink_timer APSDPeriodicTimer;
struct rt_ralink_timer LinkDownTimer;
struct rt_ralink_timer LinkUpTimer;
u8 bPsPollTimerRunning;
struct rt_ralink_timer PsPollTimer;
struct rt_ralink_timer RadioOnOffTimer;
#endif /* RTMP_MAC_PCI // */
unsigned long PeriodicRound;
unsigned long OneSecPeriodicRound;
u8 RealRxPath;
BOOLEAN bLowThroughput;
BOOLEAN bEnableAutoAntennaCheck;
struct rt_ralink_timer RxAntEvalTimer;
#ifdef RT30xx
u8 CaliBW40RfR24;
u8 CaliBW20RfR24;
#endif /* RT30xx // */
struct rt_ralink_timer AutoWakeupTimer;
BOOLEAN AutoWakeupTimerRunning;
#endif /* RTMP_MAC_USB // */
* 802.11 N related data structures
struct reordering_mpdu {
struct reordering_mpdu *next;
void *pPacket; /* coverted to 802.3 frame */
int Sequence; /* sequence number of MPDU */
struct reordering_list {
struct reordering_mpdu *next;
int qlen;
struct reordering_mpdu_pool {
void *mem;
spinlock_t lock;
struct reordering_list freelist;
typedef enum _REC_BLOCKACK_STATUS {
Recipient_NONE = 0,
typedef enum _ORI_BLOCKACK_STATUS {
Originator_NONE = 0,
struct rt_ba_ori_entry {
u8 Wcid;
u8 TID;
u8 BAWinSize;
u8 Token;
/* Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header. */
u16 Sequence;
u16 TimeOutValue;
struct rt_ralink_timer ORIBATimer;
void *pAdapter;
struct rt_ba_rec_entry {
u8 Wcid;
u8 TID;
u8 BAWinSize; /* each buffer is capable of holding a max AMSDU or MSDU. */
/*u8 NumOfRxPkt; */
/*u8 Curindidx; // the head in the RX reordering buffer */
u16 LastIndSeq;
/* u16 LastIndSeqAtTimer; */
u16 TimeOutValue;
struct rt_ralink_timer RECBATimer;
unsigned long LastIndSeqAtTimer;
unsigned long nDropPacket;
unsigned long rcvSeq;
/* u8 RxBufIdxUsed; */
/* corresponding virtual address for RX reordering packet storage. */
spinlock_t RxReRingLock; /* Rx Ring spinlock */
/* struct _BA_REC_ENTRY *pNext; */
void *pAdapter;
struct reordering_list list;
struct rt_ba_table {
unsigned long numAsRecipient; /* I am recipient of numAsRecipient clients. These client are in the BARecEntry[] */
unsigned long numAsOriginator; /* I am originator of numAsOriginator clients. These clients are in the BAOriEntry[] */
unsigned long numDoneOriginator; /* count Done Originator sessions */
struct rt_ba_ori_entry BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
struct rt_ba_rec_entry BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
/*For QureyBATableOID use; */
struct PACKED rt_oid_ba_rec_entry {
u8 BaBitmap; /* if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize */
u8 rsv;
u8 BufSize[8];
/*For QureyBATableOID use; */
struct PACKED rt_oid_ba_ori_entry {
u8 BaBitmap; /* if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status */
u8 rsv;
u8 BufSize[8];
struct rt_queryba_table {
struct rt_oid_ba_ori_entry BAOriEntry[32];
struct rt_oid_ba_rec_entry BARecEntry[32];
u8 OriNum; /* Number of below BAOriEntry */
u8 RecNum; /* Number of below BARecEntry */
typedef union _BACAP_STRUC {
struct {
u32 RxBAWinLimit:8;
u32 TxBAWinLimit:8;
u32 AutoBA:1; /* automatically BA */
u32 Policy:2; /* 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use */
u32 MpduDensity:3;
u32 AmsduEnable:1; /*Enable AMSDU transmisstion */
u32 AmsduSize:1; /* 0:3839, 1:7935 bytes. u32 MSDUSizeToBytes[] = { 3839, 7935}; */
u32 MMPSmode:2; /* MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable */
u32 bHtAdhoc:1; /* adhoc can use ht rate. */
u32 b2040CoexistScanSup:1; /*As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz. */
u32: 4;
} field;
u32 word;
struct rt_oid_add_ba_entry {
BOOLEAN IsRecipient;
u8 TID;
u8 nMSDU;
u16 TimeOut;
BOOLEAN bAllTid; /* If True, delete all TID for BA sessions with this MACaddr. */
#define IS_HT_STA(_pMacEntry) \
(_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
#define IS_HT_RATE(_pMacEntry) \
(_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
#define PEER_IS_HT_RATE(_pMacEntry) \
(_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
/*This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic) */
struct rt_iot {
u8 Threshold[2];
u8 ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE]; /* compare with threshold[0] */
u8 RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; /* compare with threshold[1] */
unsigned long OneSecInWindowCount;
unsigned long OneSecFrameDuplicateCount;
unsigned long OneSecOutWindowCount;
u8 DelOriAct;
u8 DelRecAct;
u8 RTSShortProt;
u8 RTSLongProt;
BOOLEAN bLastAtheros;
BOOLEAN bCurrentAtheros;
BOOLEAN bNowAtherosBurstOn;
BOOLEAN bNextDisableRxBA;
BOOLEAN bToggle;
/* This is the registry setting for 802.11n transmit setting. Used in advanced page. */
typedef union _REG_TRANSMIT_SETTING {
struct {
/*u32 PhyMode:4; */
/*u32 MCS:7; // MCS */
u32 rsv0:10;
u32 TxBF:1;
u32 BW:1; /*channel bandwidth 20MHz or 40 MHz */
u32 ShortGI:1;
u32 STBC:1; /*SPACE */
u32 TRANSNO:2;
u32 HTMODE:1;
u32 EXTCHA:2;
u32 rsv:13;
} field;
u32 word;
struct {
u16 MCS:7; /* MCS */
u16 PhyMode:4;
u16 FixedTxMode:2; /* If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode. */
u16 rsv:3;
} field;
u16 word;
* USB-based chip Beacon related data structures
struct rt_beacon_sync {
unsigned long TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
unsigned long CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
BOOLEAN EnableBeacon; /* trigger to enable beacon transmission. */
u8 BeaconBitMap; /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change. */
u8 DtimBitOn; /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change. */
#endif /* RTMP_MAC_USB // */
* Multiple SSID related data structures
#define WLAN_MAX_NUM_OF_TIM ((MAX_LEN_OF_MAC_TABLE >> 3) + 1) /* /8 + 1 */
#define WLAN_CT_TIM_BCMC_OFFSET 0 /* unit: 32B */
/* clear bcmc TIM bit */
#define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
/* set bcmc TIM bit */
#define WLAN_MR_TIM_BCMC_SET(apidx) \
pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
/* clear a station PS TIM bit */
#define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
{ u8 tim_offset = wcid >> 3; \
u8 bit_offset = wcid & 0x7; \
ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
/* set a station PS TIM bit */
#define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
{ u8 tim_offset = wcid >> 3; \
u8 bit_offset = wcid & 0x7; \
ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
/* configuration common to OPMODE_AP as well as OPMODE_STA */
struct rt_common_config {
BOOLEAN bCountryFlag;
u8 CountryCode[3];
u8 Geography;
u8 CountryRegion; /* Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel */
u8 CountryRegionForABand; /* Enum of country region for A band */
u8 PhyMode; /* PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED */
u16 Dsifs; /* in units of usec */
unsigned long PacketFilter; /* Packet filter for receiving */
u8 RegulatoryClass;
char Ssid[MAX_LEN_OF_SSID]; /* NOT NULL-terminated */
u8 SsidLen; /* the actual ssid length in used */
u8 LastSsidLen; /* the actual ssid length in used */
char LastSsid[MAX_LEN_OF_SSID]; /* NOT NULL-terminated */
u8 LastBssid[MAC_ADDR_LEN];
u8 Bssid[MAC_ADDR_LEN];
u16 BeaconPeriod;
u8 Channel;
u8 CentralChannel; /* Central Channel when using 40MHz is indicating. not real channel. */
u8 SupRateLen;
u8 ExtRateLen;
u8 MaxDesiredRate;
unsigned long BasicRateBitmap; /* backup basic ratebitmap */
BOOLEAN bInServicePeriod;
/* because TSPEC can modify the APSD flag, we need to keep the APSD flag
requested in association stage from the station;
we need to recover the APSD flag after the TSPEC is deleted. */
BOOLEAN bACMAPSDBackup[4]; /* for delivery-enabled & trigger-enabled both */
BOOLEAN bACMAPSDTr[4]; /* no use */
BOOLEAN bNeedSendTriggerFrame;
BOOLEAN bAPSDForcePowerSave; /* Force power save mode, should only use in APSD-STAUT */
unsigned long TriggerTimerCount;
u8 MaxSPLength;
u8 BBPCurrentBW; /* BW_10, BW_20, BW_40 */
/* move to MULTISSID_STRUCT for MBSS */
/*HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI. */
REG_TRANSMIT_SETTING RegTransmitSetting; /*registry transmit setting. this is for reading registry setting only. not useful. */
/*u8 FixedTxMode; // Fixed Tx Mode (CCK, OFDM), for HT fixed tx mode (GF, MIX) , refer to RegTransmitSetting.field.HTMode */
u8 TxRate; /* Same value to fill in TXD. TxRate is 6-bit */
u8 MaxTxRate; /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
u8 TxRateIndex; /* Tx rate index in RateSwitchTable */
u8 TxRateTableSize; /* Valid Tx rate table size in RateSwitchTable */
/*BOOLEAN bAutoTxRateSwitch; */
u8 MinTxRate; /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
u8 RtsRate; /* RATE_xxx */
HTTRANSMIT_SETTING MlmeTransmit; /* MGMT frame PHY rate setting when operatin at Ht rate. */
u8 MlmeRate; /* RATE_xxx, used to send MLME frames */
u8 BasicMlmeRate; /* Default Rate for sending MLME frames */
u16 RtsThreshold; /* in unit of BYTE */
u16 FragmentThreshold; /* in unit of BYTE */
u8 TxPower; /* in unit of mW */
unsigned long TxPowerPercentage; /* 0~100 % */
unsigned long TxPowerDefault; /* keep for TxPowerPercentage */
u8 PwrConstraint;
BACAP_STRUC BACapability; /* NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0 */
struct rt_iot IOTestParm; /* 802.11n InterOpbility Test Parameter; */
unsigned long TxPreamble; /* Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto */
BOOLEAN bUseZeroToDisableFragment; /* Microsoft use 0 as disable */
unsigned long UseBGProtection; /* 0: auto, 1: always use, 2: always not use */
BOOLEAN bUseShortSlotTime; /* 0: disable, 1 - use short slot (9us) */
BOOLEAN bEnableTxBurst; /* 1: enble TX PACKET BURST (when BA is established or AP is not a legacy WMM AP), 0: disable TX PACKET BURST */
BOOLEAN bAggregationCapable; /* 1: enable TX aggregation when the peer supports it */
BOOLEAN bPiggyBackCapable; /* 1: enable TX piggy-back according MAC's version */
BOOLEAN bIEEE80211H; /* 1: enable IEEE802.11h spec. */
unsigned long DisableOLBCDetect; /* 0: enable OLBC detect; 1 disable OLBC detect */
BOOLEAN bWmmCapable; /* 0:disable WMM, 1:enable WMM */
struct rt_qos_capability_parm APQosCapability; /* QOS capability of the current associated AP */
struct rt_edca_parm APEdcaParm; /* EDCA parameters of the current associated AP */
struct rt_qbss_load_parm APQbssLoad; /* QBSS load of the current associated AP */
u8 AckPolicy[4]; /* ACK policy of the specified AC. see ACK_xxx */
BOOLEAN bDLSCapable; /* 0:disable DLS, 1:enable DLS */
/* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
/* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
/* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition */
unsigned long OpStatusFlags;
BOOLEAN NdisRadioStateOff; /*For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff. */
ABGBAND_STATE BandState; /* For setting BBP used on B/G or A mode. */
/* IEEE802.11H--DFS. */
struct rt_radar_detect RadarDetect;
/* HT */
u8 BASize; /* USer desired BAWindowSize. Should not exceed our max capability */
/*struct rt_ht_capability SupportedHtPhy; */
struct rt_ht_capability DesiredHtPhy;
struct rt_ht_capability_ie HtCapability;
struct rt_add_ht_info_ie AddHTInfo; /* Useful as AP. */
/*This IE is used with channel switch announcement element when changing to a new 40MHz. */
/*This IE is included in channel switch ammouncement frames, beacons, probe Rsp. */
struct rt_new_ext_chan_ie NewExtChanOffset; /*, 1 if extension channel is above the control channel, 3 if below, 0 if not present */
/*2008/11/05: KH add to support Antenna power-saving of AP<-- */
BOOLEAN bGreenAPEnable;
/*2008/11/05: KH add to support Antenna power-saving of AP--> */
BOOLEAN bDisableReordering;
BOOLEAN bForty_Mhz_Intolerant;
BOOLEAN bExtChannelSwitchAnnouncement;
BOOLEAN bRcvBSSWidthTriggerEvents;
unsigned long LastRcvBSSWidthTriggerEventsTime;
u8 TxBASize;
/* Enable wireless event */
BOOLEAN bWirelessEvent;
BOOLEAN bWiFiTest; /* Enable this parameter for WiFi test */
/* Tx & Rx Stream number selection */
u8 TxStream;
u8 RxStream;
BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
BOOLEAN bMultipleIRP; /* Multiple Bulk IN flag */
u8 NumOfBulkInIRP; /* if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1 */
struct rt_ht_capability SupportedHtPhy;
unsigned long MaxPktOneTxBulk;
u8 TxBulkFactor;
u8 RxBulkFactor;
BOOLEAN IsUpdateBeacon;
struct rt_beacon_sync *pBeaconSync;
struct rt_ralink_timer BeaconUpdateTimer;
u32 BeaconAdjust;
u32 BeaconFactor;
u32 BeaconRemain;
#endif /* RTMP_MAC_USB // */
spinlock_t MeasureReqTabLock;
struct rt_measure_req_tab *pMeasureReqTab;
spinlock_t TpcReqTabLock;
struct rt_tpc_req_tab *pTpcReqTab;
BOOLEAN PSPXlink; /* 0: Disable. 1: Enable */
#if defined(RT305x) || defined(RT30xx)
/* request by Gary, for High Power issue */
u8 HighPowerPatchDisabled;
BOOLEAN HT_DisallowTKIP; /* Restrict the encryption type in 11n HT mode */
/* Modified by Wu Xi-Kun 4/21/2006 */
/* STA configuration and status */
struct rt_sta_admin_config {
/* GROUP 1 - */
/* User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
/* the user intended configuration, but not necessary fully equal to the final */
/* settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either */
/* AP or IBSS holder). */
/* Once initialized, user configuration can only be changed via OID_xxx */
u8 BssType; /* BSS_INFRA or BSS_ADHOC */
u16 AtimWin; /* used when starting a new IBSS */
/* GROUP 2 - */
/* User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
/* the user intended configuration, and should be always applied to the final */
/* settings in ACTIVE BSS without compromising with the BSS holder. */
/* Once initialized, user configuration can only be changed via OID_xxx */
u8 RssiTrigger;
u16 DefaultListenCount; /* default listen count; */
unsigned long WindowsPowerMode; /* Power mode for AC power */
unsigned long WindowsBatteryPowerMode; /* Power mode for battery if exists */
BOOLEAN bWindowsACCAMEnable; /* Enable CAM power mode when AC on */
BOOLEAN bAutoReconnect; /* Set to TRUE when setting OID_802_11_SSID with no matching BSSID */
unsigned long WindowsPowerProfile; /* Windows power profile, for NDIS5.1 PnP */
/* MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1) */
u16 Psm; /* power management mode (PWR_ACTIVE|PWR_SAVE) */
u16 DisassocReason;
u8 DisassocSta[MAC_ADDR_LEN];
u16 DeauthReason;
u8 DeauthSta[MAC_ADDR_LEN];
u16 AuthFailReason;
u8 AuthFailSta[MAC_ADDR_LEN];
NDIS_802_11_PRIVACY_FILTER PrivacyFilter; /* PrivacyFilter enum for 802.1X */
NDIS_802_11_AUTHENTICATION_MODE AuthMode; /* This should match to whatever microsoft defined */
NDIS_802_11_WEP_STATUS WepStatus;
NDIS_802_11_WEP_STATUS OrigWepStatus; /* Original wep status set from OID */
/* Add to support different cipher suite for WPA2/WPA mode */
NDIS_802_11_ENCRYPTION_STATUS GroupCipher; /* Multicast cipher suite */
NDIS_802_11_ENCRYPTION_STATUS PairCipher; /* Unicast cipher suite */
BOOLEAN bMixCipher; /* Indicate current Pair & Group use different cipher suites */
u16 RsnCapability;
NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
u8 WpaPassPhrase[64]; /* WPA PSK pass phrase */
u32 WpaPassPhraseLen; /* the length of WPA PSK pass phrase */
u8 PMK[32]; /* WPA PSK mode PMK */
u8 PTK[64]; /* WPA PSK mode PTK */
u8 GTK[32]; /* GTK from authenticator */
struct rt_bssid_info SavedPMK[PMKID_NO];
u32 SavedPMKNum; /* Saved PMKID number */
u8 DefaultKeyId;
/* WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED */
u8 PortSecured;
/* For WPA countermeasures */
unsigned long LastMicErrorTime; /* record last MIC error time */
unsigned long MicErrCnt; /* Should be 0, 1, 2, then reset to zero (after disassoiciation). */
BOOLEAN bBlockAssoc; /* Block associate attempt for 60 seconds after counter measure occurred. */
/* For WPA-PSK supplicant state */
WPA_STATE WpaState; /* Default is SS_NOTUSE and handled by microsoft 802.1x */
u8 ReplayCounter[8];
u8 ANonce[32]; /* ANonce for WPA-PSK from aurhenticator */
u8 SNonce[32]; /* SNonce for WPA-PSK */
u8 LastSNR0; /* last received BEACON's SNR */
u8 LastSNR1; /* last received BEACON's SNR for 2nd antenna */
struct rt_rssi_sample RssiSample;
unsigned long NumOfAvgRssiSample;
unsigned long LastBeaconRxTime; /* OS's timestamp of the last BEACON RX time */
unsigned long Last11bBeaconRxTime; /* OS's timestamp of the last 11B BEACON RX time */
unsigned long Last11gBeaconRxTime; /* OS's timestamp of the last 11G BEACON RX time */
unsigned long Last20NBeaconRxTime; /* OS's timestamp of the last 20MHz N BEACON RX time */
unsigned long LastScanTime; /* Record last scan time for issue BSSID_SCAN_LIST */
unsigned long ScanCnt; /* Scan counts since most recent SSID, BSSID, SCAN OID request */
BOOLEAN bSwRadio; /* Software controlled Radio On/Off, TRUE: On */
BOOLEAN bHwRadio; /* Hardware controlled Radio On/Off, TRUE: On */
BOOLEAN bRadio; /* Radio state, And of Sw & Hw radio state */
BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
BOOLEAN bShowHiddenSSID; /* Show all known SSID in SSID list get operation */
/* New for WPA, windows want us to keep association information and */
/* Fixed IEs from last association response */
struct rt_ndis_802_11_association_information AssocInfo;
u16 ReqVarIELen; /* Length of next VIE include EID & Length */
u8 ReqVarIEs[MAX_VIE_LEN]; /* The content saved here should be little-endian format. */
u16 ResVarIELen; /* Length of next VIE include EID & Length */
u8 ResVarIEs[MAX_VIE_LEN];
u8 RSNIE_Len;
u8 RSN_IE[MAX_LEN_OF_RSNIE]; /* The content saved here should be little-endian format. */
unsigned long CLBusyBytes; /* Save the total bytes received durning channel load scan time */
u16 RPIDensity[8]; /* Array for RPI density collection */
u8 RMReqCnt; /* Number of measurement request saved. */
u8 CurrentRMReqIdx; /* Number of measurement request saved. */
BOOLEAN ParallelReq; /* Parallel measurement, only one request performed, */
/* It must be the same channel with maximum duration */
u16 ParallelDuration; /* Maximum duration for parallel measurement */
u8 ParallelChannel; /* Only one channel with parallel measurement */
u16 IAPPToken; /* IAPP dialog token */
/* Hack for channel load and noise histogram parameters */
u8 NHFactor; /* Parameter for Noise histogram */
u8 CLFactor; /* Parameter for channel load */
struct rt_ralink_timer StaQuickResponeForRateUpTimer;
BOOLEAN StaQuickResponeForRateUpTimerRunning;
u8 DtimCount; /* 0.. DtimPeriod-1 */
u8 DtimPeriod; /* default = 3 */
/*////////////////////////////////////////////////////////////////////////////////////// */
/* This is only for WHQL test. */
/*////////////////////////////////////////////////////////////////////////////////////// */
struct rt_ralink_timer WpaDisassocAndBlockAssocTimer;
/* Fast Roaming */
BOOLEAN bAutoRoaming; /* 0:disable auto roaming by RSSI, 1:enable auto roaming by RSSI */
char dBmToRoam; /* the condition to roam when receiving Rssi less than this value. It's negative value. */
BOOLEAN IEEE8021x_required_keys;
struct rt_cipher_key DesireSharedKey[4]; /* Record user desired WEP keys */
u8 DesireSharedKeyId;
/* 0: driver ignores wpa_supplicant */
/* 1: wpa_supplicant initiates scanning and AP selection */
/* 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters */
u8 WpaSupplicantUP;
u8 WpaSupplicantScanCount;
BOOLEAN bRSN_IE_FromWpaSupplicant;
char dev_name[16];
u16 OriDevType;
BOOLEAN bScanReqIsFromWebUI;
HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode; /* For transmit phy setting in TXWI. */
struct rt_ht_phy_info DesiredHtPhyInfo;
BOOLEAN bAutoTxRateSwitch;
u8 BBPR3;
/* PS Control has 2 meanings for advanced power save function. */
/* 1. EnablePSinIdle : When no connection, always radio off except need to do site survey. */
/* 2. EnableNewPS : will save more current in sleep or radio off mode. */
#endif /* RTMP_MAC_PCI // */
BOOLEAN bAutoConnectByBssid;
unsigned long BeaconLostTime; /* seconds */
BOOLEAN bForceTxBurst; /* 1: force enble TX PACKET BURST, 0: disable */
/* This data structure keep the current active BSS/IBSS's configuration that this STA */
/* had agreed upon joining the network. Which means these parameters are usually decided */
/* by the BSS/IBSS creator instead of user configuration. Data in this data structurre */
/* is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE. */
/* Normally, after SCAN or failed roaming attempts, we need to recover back to */
/* the current active settings. */
struct rt_sta_active_config {
u16 Aid;
u16 AtimWin; /* in kusec; IBSS parameter set element */
u16 CapabilityInfo;
u16 CfpMaxDuration;
u16 CfpPeriod;
/* Copy supported rate from desired AP's beacon. We are trying to match */
/* AP's supported and extended rate settings. */
u8 SupRateLen;
u8 ExtRateLen;
/* Copy supported ht from desired AP's beacon. We are trying to match */
struct rt_ht_phy_info SupportedPhyInfo;
struct rt_ht_capability SupportedHtPhy;
struct rt_mac_table_entry;
struct rt_mac_table_entry {
/*Choose 1 from ValidAsWDS and ValidAsCLI to validize. */
BOOLEAN ValidAsCLI; /* Sta mode, set this TRUE after Linkup,too. */
BOOLEAN ValidAsWDS; /* This is WDS Entry. only for AP mode. */
BOOLEAN ValidAsApCli; /*This is a AP-Client entry, only for AP mode which enable AP-Client functions. */
BOOLEAN ValidAsMesh;
BOOLEAN ValidAsDls; /* This is DLS Entry. only for STA mode. */
BOOLEAN isCached;
BOOLEAN bIAmBadAtheros; /* Flag if this is Atheros chip that has IOT problem. We need to turn on RTS/CTS protection. */
u8 EnqueueEapolStartTimerRunning; /* Enqueue EAPoL-Start for triggering EAP SM */
/*jan for wpa */
/* record which entry revoke MIC Failure , if it leaves the BSS itself, AP won't update aMICFailTime MIB */
u8 CMTimerRunning;
u8 apidx; /* MBSS number */
u8 RSNIE_Len;
u8 PTK[64];
u8 ReTryCounter;
struct rt_ralink_timer RetryTimer;
struct rt_ralink_timer EnqueueStartForPSKTimer; /* A timer which enqueue EAPoL-Start for triggering PSK SM */
NDIS_802_11_AUTHENTICATION_MODE AuthMode; /* This should match to whatever microsoft defined */
NDIS_802_11_WEP_STATUS WepStatus;
NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
u16 PortSecured;
NDIS_802_11_PRIVACY_FILTER PrivacyFilter; /* PrivacyFilter enum for 802.1X */
struct rt_cipher_key PairwiseKey;
void *pAd;
int PMKID_CacheIdx;
u8 Addr[MAC_ADDR_LEN];
u8 PsMode;
SST Sst;
AUTH_STATE AuthState; /* for SHARED KEY authentication state machine used only */
BOOLEAN IsReassocSta; /* Indicate whether this is a reassociation procedure */
u16 Aid;
u16 CapabilityInfo;
u8 LastRssi;
unsigned long NoDataIdleCount;
u16 StationKeepAliveCount; /* unit: second */
unsigned long PsQIdleCount;
struct rt_queue_header PsQueue;
u32 StaConnectTime; /* the live time of this station since associated with AP */
u16 NoBADataCountDown;
u32 CachedBuf[16]; /* u32 (4 bytes) for alignment */
u32 TxBFCount; /* 3*3 */
u32 FIFOCount;
u32 DebugFIFOCount;
u32 DebugTxCount;
/*==================================================== */
/*WDS entry needs these */
/* if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab */
u32 MatchWDSTabIdx;
u8 MaxSupportedRate;
u8 CurrTxRate;
u8 CurrTxRateIndex;
/* to record the each TX rate's quality. 0 is best, the bigger the worse. */
/* u16 OneSecTxOkCount; */
u32 OneSecTxNoRetryOkCount;
u32 OneSecTxRetryOkCount;
u32 OneSecTxFailCount;
u32 ContinueTxFailCnt;
u32 CurrTxRateStableTime; /* # of second in current TX rate */
u8 TxRateUpPenalty; /* extra # of second penalty due to last unstable condition */
/*==================================================== */
BOOLEAN fNoisyEnvironment;
BOOLEAN fLastSecAccordingRSSI;
u8 LastSecTxRateChangeAction; /* 0: no change, 1:rate UP, 2:rate down */
char LastTimeTxRateChangeAction; /*Keep last time value of LastSecTxRateChangeAction */
unsigned long LastTxOkCount;
/* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
/* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
/* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED */
unsigned long ClientStatusFlags;
HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode; /* For transmit phy setting in TXWI. */
/* HT EWC MIMO-N used parameters */
u16 RXBAbitmap; /* fill to on-chip RXWI_BA_BITMASK in 8.1.3RX attribute entry format */
u16 TXBAbitmap; /* This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI */
u16 TXAutoBAbitmap;
u16 BADeclineBitmap;
u16 BARecWcidArray[NUM_OF_TID]; /* The mapping wcid of recipient session. if RXBAbitmap bit is masked */
u16 BAOriWcidArray[NUM_OF_TID]; /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
u16 BAOriSequence[NUM_OF_TID]; /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
/* 802.11n features. */
u8 MpduDensity;
u8 MaxRAmpduFactor;
u8 AMsduSize;
u8 MmpsMode; /* MIMO power save more. */
struct rt_ht_capability_ie HTCapability;
BOOLEAN bAutoTxRateSwitch;
u8 RateLen;
struct rt_mac_table_entry *pNext;
u16 TxSeq[NUM_OF_TID];
u16 NonQosDataSeq;
struct rt_rssi_sample RssiSample;
u32 TXMCSExpected[16];
u32 TXMCSSuccessful[16];
u32 TXMCSFailed[16];
u32 TXMCSAutoFallBack[16][16];
unsigned long LastBeaconRxTime;
unsigned long AssocDeadLine;
struct rt_mac_table {
u16 Size;
struct rt_mac_table_entry *Hash[HASH_TABLE_SIZE];
struct rt_mac_table_entry Content[MAX_LEN_OF_MAC_TABLE];
struct rt_queue_header McastPsQueue;
unsigned long PsQIdleCount;
BOOLEAN fAnyStationInPsm;
BOOLEAN fAnyStationBadAtheros; /* Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip. */
BOOLEAN fAnyTxOPForceDisable; /* Check if it is necessary to disable BE TxOP */
BOOLEAN fAllStationAsRalink; /* Check if all stations are ralink-chipset */
BOOLEAN fAnyStationIsLegacy; /* Check if I use legacy rate to transmit to my BSS Station/ */
BOOLEAN fAnyStationNonGF; /* Check if any Station can't support GF. */
BOOLEAN fAnyStation20Only; /* Check if any Station can't support GF. */
BOOLEAN fAnyStationMIMOPSDynamic; /* Check if any Station is MIMO Dynamic */
BOOLEAN fAnyBASession; /* Check if there is BA session. Force turn on RTS/CTS */
/*2008/10/28: KH add to support Antenna power-saving of AP<-- */
/*2008/10/28: KH add to support Antenna power-saving of AP--> */
struct wificonf {
BOOLEAN bGreenField;
struct rt_rtmp_dev_info {
u8 chipName[16];
struct rt_rtmp_chip_op {
/* Calibration access related callback functions */
int (*eeinit) (struct rt_rtmp_adapter *pAd); /* int (*eeinit)(struct rt_rtmp_adapter *pAd); */
int (*eeread) (struct rt_rtmp_adapter *pAd, u16 offset, u16 *pValue); /* int (*eeread)(struct rt_rtmp_adapter *pAd, int offset, u16 *pValue); */
/* MCU related callback functions */
int (*loadFirmware) (struct rt_rtmp_adapter *pAd); /* int (*loadFirmware)(struct rt_rtmp_adapter *pAd); */
int (*eraseFirmware) (struct rt_rtmp_adapter *pAd); /* int (*eraseFirmware)(struct rt_rtmp_adapter *pAd); */
int (*sendCommandToMcu) (struct rt_rtmp_adapter *pAd, u8 cmd, u8 token, u8 arg0, u8 arg1);; /* int (*sendCommandToMcu)(struct rt_rtmp_adapter *pAd, u8 cmd, u8 token, u8 arg0, u8 arg1); */
/* RF access related callback functions */
struct rt_reg_pair *pRFRegTable;
void (*AsicRfInit) (struct rt_rtmp_adapter *pAd);
void (*AsicRfTurnOn) (struct rt_rtmp_adapter *pAd);
void (*AsicRfTurnOff) (struct rt_rtmp_adapter *pAd);
void (*AsicReverseRfFromSleepMode) (struct rt_rtmp_adapter *pAd);
void (*AsicHaltAction) (struct rt_rtmp_adapter *pAd);
/* */
/* The miniport adapter structure */
/* */
struct rt_rtmp_adapter {
void *OS_Cookie; /* save specific structure relative to OS */
struct net_device *net_dev;
unsigned long VirtualIfCnt;
const struct firmware *firmware;
struct rt_rtmp_chip_op chipOps;
u16 ThisTbttNumToNextWakeUp;
/* PCI related parameters */
u8 *CSRBaseAddress; /* PCI MMIO Base Address, all access will use */
unsigned int irq_num;
u16 LnkCtrlBitMask;
u16 RLnkCtrlConfiguration;
u16 RLnkCtrlOffset;
u16 HostLnkCtrlConfiguration;
u16 HostLnkCtrlOffset;
u16 PCIePowerSaveLevel;
unsigned long Rt3xxHostLinkCtrl; /* USed for 3090F chip */
unsigned long Rt3xxRalinkLinkCtrl; /* USed for 3090F chip */
u16 DeviceID; /* Read from PCI config */
unsigned long AccessBBPFailCount;
BOOLEAN bPCIclkOff; /* flag that indicate if the PICE power status in Configuration SPace.. */
BOOLEAN bPCIclkOffDisableTx; /* */
BOOLEAN brt30xxBanMcuCmd; /*when = 0xff means all commands are ok to set . */
BOOLEAN b3090ESpecialChip; /*3090E special chip that write EEPROM 0x24=0x9280. */
unsigned long CheckDmaBusyCount; /* Check Interrupt Status Register Count. */
u32 int_enable_reg;
u32 int_disable_mask;
u32 int_pending;
struct rt_rtmp_dmabuf TxBufSpace[NUM_OF_TX_RING]; /* Shared memory of all 1st pre-allocated TxBuf associated with each TXD */
struct rt_rtmp_dmabuf RxDescRing; /* Shared memory for RX descriptors */
struct rt_rtmp_dmabuf TxDescRing[NUM_OF_TX_RING]; /* Shared memory for Tx descriptors */
struct rt_rtmp_tx_ring TxRing[NUM_OF_TX_RING]; /* AC0~4 + HCCA */
#endif /* RTMP_MAC_PCI // */
spinlock_t irq_lock;
u8 irq_disabled;
/* USB related parameters */
struct usb_config_descriptor *config;
u32 BulkInEpAddr; /* bulk-in endpoint address */
u32 BulkOutEpAddr[6]; /* bulk-out endpoint address */
u32 NumberOfPipes;
u16 BulkOutMaxPacketSize;
u16 BulkInMaxPacketSize;
/*======Control Flags */
long PendingIoCount;
unsigned long BulkFlags;
BOOLEAN bUsbTxBulkAggre; /* Flags for bulk out data priority */
/*======Cmd Thread */
struct rt_cmdq CmdQ;
spinlock_t CmdQLock; /* CmdQLock spinlock */
struct rt_rtmp_os_task cmdQTask;
/*======Semaphores (event) */
struct semaphore UsbVendorReq_semaphore;
void *UsbVendorReqBuf;
wait_queue_head_t *wait;
#endif /* RTMP_MAC_USB // */
/* RBUS related parameters */
/* Both PCI/USB related parameters */
/*struct rt_rtmp_dev_info chipInfo; */
/* Driver Mgmt related parameters */
struct rt_rtmp_os_task mlmeTask;
/* If you want use timer task to handle the timer related jobs, enable this. */
struct rt_rtmp_timer_task_queue TimerQ;
spinlock_t TimerQLock;
struct rt_rtmp_os_task timerTask;
/* Tx related parameters */
BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; /* for ensuring RTUSBDeQueuePacket get call once */
spinlock_t DeQueueLock[NUM_OF_TX_RING];
/* Data related context and AC specified, 4 AC supported */
spinlock_t BulkOutLock[6]; /* BulkOut spinlock for 4 ACs */
spinlock_t MLMEBulkOutLock; /* MLME BulkOut lock */
struct rt_ht_tx_context TxContext[NUM_OF_TX_RING];
spinlock_t TxContextQueueLock[NUM_OF_TX_RING]; /* TxContextQueue spinlock */
/* 4 sets of Bulk Out index and pending flag */
u8 NextBulkOutIndex[4]; /* only used for 4 EDCA bulkout pipe */
BOOLEAN BulkOutPending[6]; /* used for total 6 bulkout pipe */
u8 bulkResetPipeid;
BOOLEAN MgmtBulkPending;
unsigned long bulkResetReq[6];
#endif /* RTMP_MAC_USB // */
/* resource for software backlog queues */
struct rt_queue_header TxSwQueue[NUM_OF_TX_RING]; /* 4 AC + 1 HCCA */
spinlock_t TxSwQueueLock[NUM_OF_TX_RING]; /* TxSwQueue spinlock */
struct rt_rtmp_dmabuf MgmtDescRing; /* Shared memory for MGMT descriptors */
struct rt_rtmp_mgmt_ring MgmtRing;
spinlock_t MgmtRingLock; /* Prio Ring spinlock */
/* Rx related parameters */
struct rt_rtmp_rx_ring RxRing;
spinlock_t RxRingLock; /* Rx Ring spinlock */
#ifdef RT3090
spinlock_t McuCmdLock; /*MCU Command Queue spinlock */
#endif /* RT3090 // */
#endif /* RTMP_MAC_PCI // */
struct rt_rx_context RxContext[RX_RING_SIZE]; /* 1 for redundant multiple IRP bulk in. */
spinlock_t BulkInLock; /* BulkIn spinlock for 4 ACs */
u8 PendingRx; /* The Maximum pending Rx value should be RX_RING_SIZE. */
u8 NextRxBulkInIndex; /* Indicate the current RxContext Index which hold by Host controller. */
u8 NextRxBulkInReadIndex; /* Indicate the current RxContext Index which driver can read & process it. */
unsigned long NextRxBulkInPosition; /* Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength. */
unsigned long TransferBufferLength; /* current length of the packet buffer */
unsigned long ReadPosition; /* current read position in a packet buffer */
#endif /* RTMP_MAC_USB // */
/* ASIC related parameters */
u32 MACVersion; /* MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101).. */
/* --------------------------- */
/* E2PROM */
/* --------------------------- */
unsigned long EepromVersion; /* byte 0: version, byte 1: revision, byte 2~3: unused */
unsigned long FirmwareVersion; /* byte 0: Minor version, byte 1: Major version, otherwise unused. */
u8 EEPROMAddressNum; /* 93c46=6 93c66=8 */
BOOLEAN EepromAccess;
u8 EFuseTag;
/* --------------------------- */
/* BBP Control */
/* --------------------------- */
u8 BbpWriteLatch[140]; /* record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID */
char BbpRssiToDbmDelta; /* change from u8 to char for high power */
struct rt_bbp_r66_tuning BbpTuning;
/* ---------------------------- */
/* RFIC control */
/* ---------------------------- */
u8 RfIcType; /* RFIC_xxx */
unsigned long RfFreqOffset; /* Frequency offset for channel switching */
struct rt_rtmp_rf_regs LatchRfRegs; /* latch th latest RF programming value since RF IC doesn't support READ */
EEPROM_ANTENNA_STRUC Antenna; /* Since ANtenna definition is different for a & g. We need to save it for future reference. */
/* This soft Rx Antenna Diversity mechanism is used only when user set */
/* RX Antenna = DIVERSITY ON */
struct rt_soft_rx_ant_diversity RxAnt;
u8 RFProgSeq;
struct rt_channel_tx_power TxPower[MAX_NUM_OF_CHANNELS]; /* Store Tx power value for all channels. */
struct rt_channel_tx_power ChannelList[MAX_NUM_OF_CHANNELS]; /* list all supported channels for site survey */
struct rt_channel_11j_tx_power TxPower11J[MAX_NUM_OF_11JCHANNELS]; /* 802.11j channel and bw */
struct rt_channel_11j_tx_power ChannelList11J[MAX_NUM_OF_11JCHANNELS]; /* list all supported channels for site survey */
u8 ChannelListNum; /* number of channel in ChannelList[] */
u8 Bbp94;
unsigned long Tx20MPwrCfgABand[5];
unsigned long Tx20MPwrCfgGBand[5];
unsigned long Tx40MPwrCfgABand[5];
unsigned long Tx40MPwrCfgGBand[5];
BOOLEAN bAutoTxAgcA; /* Enable driver auto Tx Agc control */
u8 TssiRefA; /* Store Tssi reference value as 25 temperature. */
u8 TssiPlusBoundaryA[5]; /* Tssi boundary for increase Tx power to compensate. */
u8 TssiMinusBoundaryA[5]; /* Tssi boundary for decrease Tx power to compensate. */
u8 TxAgcStepA; /* Store Tx TSSI delta increment / decrement value */
char TxAgcCompensateA; /* Store the compensation (TxAgcStep * (idx-1)) */
BOOLEAN bAutoTxAgcG; /* Enable driver auto Tx Agc control */
u8 TssiRefG; /* Store Tssi reference value as 25 temperature. */
u8 TssiPlusBoundaryG[5]; /* Tssi boundary for increase Tx power to compensate. */
u8 TssiMinusBoundaryG[5]; /* Tssi boundary for decrease Tx power to compensate. */
u8 TxAgcStepG; /* Store Tx TSSI delta increment / decrement value */
char TxAgcCompensateG; /* Store the compensation (TxAgcStep * (idx-1)) */
char BGRssiOffset0; /* Store B/G RSSI#0 Offset value on EEPROM 0x46h */
char BGRssiOffset1; /* Store B/G RSSI#1 Offset value */
char BGRssiOffset2; /* Store B/G RSSI#2 Offset value */
char ARssiOffset0; /* Store A RSSI#0 Offset value on EEPROM 0x4Ah */
char ARssiOffset1; /* Store A RSSI#1 Offset value */
char ARssiOffset2; /* Store A RSSI#2 Offset value */
char BLNAGain; /* Store B/G external LNA#0 value on EEPROM 0x44h */
char ALNAGain0; /* Store A external LNA#0 value for ch36~64 */
char ALNAGain1; /* Store A external LNA#1 value for ch100~128 */
char ALNAGain2; /* Store A external LNA#2 value for ch132~165 */
#ifdef RT30xx
/* for 3572 */
u8 Bbp25;
u8 Bbp26;
u8 TxMixerGain24G; /* Tx mixer gain value from EEPROM to improve Tx EVM / Tx DAC, 2.4G */
u8 TxMixerGain5G;
#endif /* RT30xx // */
/* ---------------------------- */
/* LED control */
/* ---------------------------- */
u16 Led1; /* read from EEPROM 0x3c */
u16 Led2; /* EEPROM 0x3e */
u16 Led3; /* EEPROM 0x40 */
u8 LedIndicatorStrength;
u8 RssiSingalstrengthOffet;
BOOLEAN bLedOnScanning;
u8 LedStatus;
/* 802.11 related parameters */
/* outgoing BEACON frame buffer and corresponding TXD */
struct rt_txwi BeaconTxWI;
u8 *BeaconBuf;
u16 BeaconOffset[HW_BEACON_MAX_COUNT];
/* pre-build PS-POLL and NULL frame upon link up. for efficiency purpose. */
struct rt_pspoll_frame PsPollFrame;
struct rt_header_802_11 NullFrame;
struct rt_tx_context BeaconContext[BEACON_RING_SIZE];
struct rt_tx_context NullContext;
struct rt_tx_context PsPollContext;
struct rt_tx_context RTSContext;
#endif /* RTMP_MAC_USB // */
/*=========AP=========== */
/*=======STA=========== */
/* ----------------------------------------------- */
/* STA specific configuration & operation status */
/* used only when pAd->OpMode == OPMODE_STA */
/* ----------------------------------------------- */
struct rt_sta_admin_config StaCfg; /* user desired settings */
struct rt_sta_active_config StaActive; /* valid only when ADHOC_ON(pAd) || INFRA_ON(pAd) */
char nickname[IW_ESSID_MAX_SIZE + 1]; /* nickname, only used in the iwconfig i/f */
int PreMediaState;
/*=======Common=========== */
/* OP mode: either AP or STA */
u8 OpMode; /* OPMODE_STA, OPMODE_AP */
int IndicateMediaState; /* Base on Indication state, default is NdisMediaStateDisConnected */
/* MAT related parameters */
/* configuration: read from Registry & E2PROM */
BOOLEAN bLocalAdminMAC; /* Use user changed MAC */
u8 PermanentAddress[MAC_ADDR_LEN]; /* Factory default MAC address */
u8 CurrentAddress[MAC_ADDR_LEN]; /* User changed MAC address */
/* ------------------------------------------------------ */
/* common configuration to both OPMODE_STA and OPMODE_AP */
/* ------------------------------------------------------ */
struct rt_common_config CommonCfg;
struct rt_mlme Mlme;
/* AP needs those vaiables for site survey feature. */
struct rt_mlme_aux MlmeAux; /* temporary settings used during MLME state machine */
struct rt_bss_table ScanTab; /* store the latest SCAN result */
/*About MacTab, the sta driver will use #0 and #1 for multicast and AP. */
struct rt_mac_table MacTab; /* ASIC on-chip WCID entry table. At TX, ASIC always use key according to this on-chip table. */
spinlock_t MacTabLock;
struct rt_ba_table BATable;
spinlock_t BATabLock;
struct rt_ralink_timer RECBATimer;
/* encryption/decryption KEY tables */
struct rt_cipher_key SharedKey[MAX_MBSSID_NUM][4]; /* STA always use SharedKey[BSS0][0..3] */
/* RX re-assembly buffer for fragmentation */
struct rt_fragment_frame FragFrame; /* Frame storage for fragment frame */
/* various Counters */
struct rt_counter_802_3 Counters8023; /* 802.3 counters */
struct rt_counter_802_11 WlanCounters; /* 802.11 MIB counters */
struct rt_counter_ralink RalinkCounters; /* Ralink propriety counters */
struct rt_counter_drs DrsCounters; /* counters for Dynamic TX Rate Switching */
struct rt_private PrivateInfo; /* Private information & counters */
/* flags, see fRTMP_ADAPTER_xxx flags */
unsigned long Flags; /* Represent current device status */
unsigned long PSFlags; /* Power Save operation flag. */
/* current TX sequence # */
u16 Sequence;
/* Control disconnect / connect event generation */
/*+++Didn't used anymore */
unsigned long LinkDownTime;
/*--- */
unsigned long LastRxRate;
unsigned long LastTxRate;
/*+++Used only for Station */
BOOLEAN bConfigChanged; /* Config Change flag for the same SSID setting */
/*--- */
unsigned long ExtraInfo; /* Extra information for displaying status */
unsigned long SystemErrorBitmap; /* b0: E2PROM version error */
/*+++Didn't used anymore */
unsigned long MacIcVersion; /* MAC/BBP serial interface issue solved after ver.D */
/*--- */
/* --------------------------- */
/* System event log */
/* --------------------------- */
struct rt_802_11_event_table EventTab;
/* Statistic related parameters */
unsigned long BulkOutDataOneSecCount;
unsigned long BulkInDataOneSecCount;
unsigned long BulkLastOneSecCount; /* BulkOutDataOneSecCount + BulkInDataOneSecCount */
unsigned long watchDogRxCnt;
unsigned long watchDogRxOverFlowCnt;
unsigned long watchDogTxPendingCnt[NUM_OF_TX_RING];
int TransferedLength[NUM_OF_TX_RING];
#endif /* RTMP_MAC_USB // */
BOOLEAN bUpdateBcnCntDone;
unsigned long watchDogMacDeadlock; /* prevent MAC/BBP into deadlock condition */
/* ---------------------------- */
/* DEBUG paramerts */
/* ---------------------------- */
/*unsigned long DebugSetting[4]; */
BOOLEAN bBanAllBaSetup;
BOOLEAN bPromiscuous;
/* ---------------------------- */
/* rt2860c emulation-use Parameters */
/* ---------------------------- */
/*unsigned long rtsaccu[30]; */
/*unsigned long ctsaccu[30]; */
/*unsigned long cfendaccu[30]; */
/*unsigned long bacontent[16]; */
/*unsigned long rxint[RX_RING_SIZE+1]; */
/*u8 rcvba[60]; */
BOOLEAN bLinkAdapt;
BOOLEAN bForcePrintTX;
BOOLEAN bForcePrintRX;
/*BOOLEAN bDisablescanning; //defined in RT2870 USB */
BOOLEAN bStaFifoTest;
BOOLEAN bProtectionTest;
/*+++Following add from RT2870 USB. */
unsigned long BulkOutReq;
unsigned long BulkOutComplete;
unsigned long BulkOutCompleteOther;
unsigned long BulkOutCompleteCancel; /* seems not use now? */
unsigned long BulkInReq;
unsigned long BulkInComplete;
unsigned long BulkInCompleteFail;
/*--- */
struct wificonf WIFItestbed;
struct reordering_mpdu_pool mpdu_blk_pool;
unsigned long OneSecondnonBEpackets; /* record non BE packets per second */
#ifdef LINUX
struct iw_statistics iw_stats;
struct net_device_stats stats;
#endif /* LINUX // */
unsigned long TbttTickCount;
#endif /* PCI_MSI_SUPPORT // */
u8 is_on;
#define TIME_BASE (1000000/OS_HZ)
#define TIME_ONE_SECOND (1000000/TIME_BASE)
u8 flg_be_adjust;
unsigned long be_adjust_last_time;
u8 FlgCtsEnabled;
u8 PM_FlgSuspend;
#ifdef RT30xx
BOOLEAN bUseEfuse;
u8 EEPROMImage[1024];
#endif /* RTMP_EFUSE_SUPPORT // */
#endif /* RT30xx // */
#define DELAYINTMASK 0x0003fffb
#define INTMASK 0x0003fffb
#define IndMask 0x0003fffc
#define RxINT 0x00000005 /* Delayed Rx or indivi rx */
#define TxDataInt 0x000000fa /* Delayed Tx or indivi tx */
#define TxMgmtInt 0x00000102 /* Delayed Tx or indivi tx */
#define TxCoherent 0x00020000 /* tx coherent */
#define RxCoherent 0x00010000 /* rx coherent */
#define McuCommand 0x00000200 /* mcu */
#define PreTBTTInt 0x00001000 /* Pre-TBTT interrupt */
#define TBTTInt 0x00000800 /* TBTT interrupt */
#define GPTimeOutInt 0x00008000 /* GPtimeout interrupt */
#define AutoWakeupInt 0x00004000 /* AutoWakeupInt interrupt */
#define FifoStaFullInt 0x00002000 /* fifo statistics full interrupt */
* Rx Path software control block related data structures
struct rt_rx_blk {
struct rt_rxwi *pRxWI;
struct rt_header_802_11 *pHeader;
void *pRxPacket;
u8 *pData;
u16 DataSize;
u16 Flags;
u8 UserPriority; /* for calculate TKIP MIC using */
#define RX_BLK_SET_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags |= _flag)
#define RX_BLK_TEST_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags & _flag)
#define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags &= ~(_flag))
#define fRX_WDS 0x0001
#define fRX_AMSDU 0x0002
#define fRX_ARALINK 0x0004
#define fRX_HTC 0x0008
#define fRX_PAD 0x0010
#define fRX_AMPDU 0x0020
#define fRX_QOS 0x0040
#define fRX_INFRA 0x0080
#define fRX_EAP 0x0100
#define fRX_MESH 0x0200
#define fRX_APCLI 0x0400
#define fRX_DLS 0x0800
#define fRX_WPI 0x1000
* Tx Path software control block related data structures
#define TX_UNKOWN_FRAME 0x00
#define TX_MCAST_FRAME 0x01
#define TX_LEGACY_FRAME 0x02
#define TX_AMPDU_FRAME 0x04
#define TX_AMSDU_FRAME 0x08
#define TX_RALINK_FRAME 0x10
#define TX_FRAG_FRAME 0x20
/* Currently the sizeof(struct rt_tx_blk) is 148 bytes. */
struct rt_tx_blk {
u8 QueIdx;
u8 TxFrameType; /* Indicate the Transmission type of the all frames in one batch */
u8 TotalFrameNum; /* Total frame number want to send-out in one batch */
u16 TotalFragNum; /* Total frame fragments required in one batch */
u16 TotalFrameLen; /* Total length of all frames want to send-out in one batch */
struct rt_queue_header TxPacketList;
struct rt_mac_table_entry *pMacEntry; /* NULL: packet with 802.11 RA field is multicast/broadcast address */
/* Following structure used for the characteristics of a specific packet. */
void *pPacket;
u8 *pSrcBufHeader; /* Reference to the head of sk_buff->data */
u8 *pSrcBufData; /* Reference to the sk_buff->data, will changed depends on hanlding progresss */
u32 SrcBufLen; /* Length of packet payload which not including Layer 2 header */
u8 *pExtraLlcSnapEncap; /* NULL means no extra LLC/SNAP is required */
u8 HeaderBuf[128]; /* TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP */
/*RT2870 uses only 80 bytes */
/*RT3070 uses only 96 bytes */
/*RT3090 uses only 96 bytes */
u8 MpduHeaderLen; /* 802.11 header length NOT including the padding */
u8 HdrPadLen; /* recording Header Padding Length; */
u8 apidx; /* The interface associated to this packet */
u8 Wcid; /* The MAC entry associated to this packet */
u8 UserPriority; /* priority class of packet */
u8 FrameGap; /* what kind of IFS this packet use */
u8 MpduReqNum; /* number of fragments of this frame */
u8 TxRate; /* TODO: Obsoleted? Should change to MCS? */
u8 CipherAlg; /* cipher alogrithm */
struct rt_cipher_key *pKey;
u16 Flags; /*See following definitions for detail. */
/*YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer. */
unsigned long Priv; /* Hardware specific value saved in here. */
#define fTX_bRtsRequired 0x0001 /* Indicate if need send RTS frame for protection. Not used in RT2860/RT2870. */
#define fTX_bAckRequired 0x0002 /* the packet need ack response */
#define fTX_bPiggyBack 0x0004 /* Legacy device use Piggback or not */
#define fTX_bHTRate 0x0008 /* allow to use HT rate */
#define fTX_bForceNonQoS 0x0010 /* force to transmit frame without WMM-QoS in HT mode */
#define fTX_bAllowFrag 0x0020 /* allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment */
#define fTX_bMoreData 0x0040 /* there are more data packets in PowerSave Queue */
#define fTX_bWMM 0x0080 /* QOS Data */
#define fTX_bClearEAPFrame 0x0100
#define TX_BLK_SET_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags |= _flag)
#define TX_BLK_TEST_FLAG(_pTxBlk, _flag) (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
#define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags &= ~(_flag))
* Other static inline function definitions
static inline void ConvertMulticastIP2MAC(u8 *pIpAddr,
u8 **ppMacAddr,
u16 ProtoType)
if (pIpAddr == NULL)
if (ppMacAddr == NULL || *ppMacAddr == NULL)
switch (ProtoType) {
case ETH_P_IPV6:
/* memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
*(*ppMacAddr) = 0x33;
*(*ppMacAddr + 1) = 0x33;
*(*ppMacAddr + 2) = pIpAddr[12];
*(*ppMacAddr + 3) = pIpAddr[13];
*(*ppMacAddr + 4) = pIpAddr[14];
*(*ppMacAddr + 5) = pIpAddr[15];
case ETH_P_IP:
/* memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
*(*ppMacAddr) = 0x01;
*(*ppMacAddr + 1) = 0x00;
*(*ppMacAddr + 2) = 0x5e;
*(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
*(*ppMacAddr + 4) = pIpAddr[2];
*(*ppMacAddr + 5) = pIpAddr[3];
char *GetPhyMode(int Mode);
char *GetBW(int BW);
/* */
/* Private routines in rtmp_init.c */
/* */
int RTMPAllocAdapterBlock(void *handle,
struct rt_rtmp_adapter **ppAdapter);
int RTMPAllocTxRxRingMemory(struct rt_rtmp_adapter *pAd);
void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd);
int NICReadRegParameters(struct rt_rtmp_adapter *pAd,
void *WrapperConfigurationContext);
void NICInitRFRegisters(struct rt_rtmp_adapter *pAd);
void RtmpChipOpsRFHook(struct rt_rtmp_adapter *pAd);
int RT30xxWriteRFRegister(struct rt_rtmp_adapter *pAd,
u8 regID, u8 value);
int RT30xxReadRFRegister(struct rt_rtmp_adapter *pAd,
u8 regID, u8 *pValue);
#endif /* RTMP_RF_RW_SUPPORT // */
void NICReadEEPROMParameters(struct rt_rtmp_adapter *pAd, u8 *mac_addr);
void NICInitAsicFromEEPROM(struct rt_rtmp_adapter *pAd);
int NICInitializeAdapter(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
int NICInitializeAsic(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
void NICIssueReset(struct rt_rtmp_adapter *pAd);
void RTMPRingCleanUp(struct rt_rtmp_adapter *pAd, u8 RingType);
void UserCfgInit(struct rt_rtmp_adapter *pAd);
void NICResetFromError(struct rt_rtmp_adapter *pAd);
int NICLoadFirmware(struct rt_rtmp_adapter *pAd);
void NICEraseFirmware(struct rt_rtmp_adapter *pAd);
int NICLoadRateSwitchingParams(struct rt_rtmp_adapter *pAd);
BOOLEAN NICCheckForHang(struct rt_rtmp_adapter *pAd);
void NICUpdateFifoStaCounters(struct rt_rtmp_adapter *pAd);
void NICUpdateRawCounters(struct rt_rtmp_adapter *pAd);
void RTMPZeroMemory(void *pSrc, unsigned long Length);
unsigned long RTMPCompareMemory(void *pSrc1, void *pSrc2, unsigned long Length);
void RTMPMoveMemory(void *pDest, void *pSrc, unsigned long Length);
void AtoH(char *src, u8 *dest, int destlen);
void RTMPPatchMacBbpBug(struct rt_rtmp_adapter *pAd);
void RTMPInitTimer(struct rt_rtmp_adapter *pAd,
struct rt_ralink_timer *pTimer,
void *pTimerFunc, void *pData, IN BOOLEAN Repeat);
void RTMPSetTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
void RTMPModTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
void RTMPCancelTimer(struct rt_ralink_timer *pTimer, OUT BOOLEAN * pCancelled);
void RTMPSetLED(struct rt_rtmp_adapter *pAd, u8 Status);
void RTMPSetSignalLED(struct rt_rtmp_adapter *pAd, IN NDIS_802_11_RSSI Dbm);
void RTMPEnableRxTx(struct rt_rtmp_adapter *pAd);
/* */
/* prototype in action.c */
/* */
void ActionStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *S,
void MlmeADDBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void MlmeDELBAAction(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);
void MlmeQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerAddBAReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerAddBARspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerDelBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void SendPSMPAction(struct rt_rtmp_adapter *pAd, u8 Wcid, u8 Psmp);
void PeerRMAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerPublicAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerHTAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void RECBATimerTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd);
void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
void ActHeaderInit(struct rt_rtmp_adapter *pAd,
struct rt_header_802_11 *pHdr80211,
u8 *Addr1, u8 *Addr2, u8 *Addr3);
void BarHeaderInit(struct rt_rtmp_adapter *pAd,
struct rt_frame_bar *pCntlBar, u8 *pDA, u8 *pSA);
void InsertActField(struct rt_rtmp_adapter *pAd,
u8 *pFrameBuf,
unsigned long *pFrameLen, u8 Category, u8 ActCode);
BOOLEAN CntlEnqueueForRecv(struct rt_rtmp_adapter *pAd,
unsigned long Wcid,
unsigned long MsgLen, struct rt_frame_ba_req *pMsg);
/* */
/* Private routines in rtmp_data.c */
/* */
BOOLEAN RTMPHandleRxDoneInterrupt(struct rt_rtmp_adapter *pAd);
BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd,
void RTMPHandleMgmtRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd);
void RTMPHandleTBTTInterrupt(struct rt_rtmp_adapter *pAd);
void RTMPHandlePreTBTTInterrupt(struct rt_rtmp_adapter *pAd);
void RTMPHandleTwakeupInterrupt(struct rt_rtmp_adapter *pAd);
void RTMPHandleRxCoherentInterrupt(struct rt_rtmp_adapter *pAd);
BOOLEAN TxFrameIsAggregatible(struct rt_rtmp_adapter *pAd,
u8 *pPrevAddr1, u8 *p8023hdr);
BOOLEAN PeerIsAggreOn(struct rt_rtmp_adapter *pAd,
unsigned long TxRate, struct rt_mac_table_entry *pMacEntry);
int Sniff2BytesFromNdisBuffer(char *pFirstBuffer,
u8 DesiredOffset,
u8 *pByte0, u8 *pByte1);
int STASendPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
void STASendPackets(void *MiniportAdapterContext,
void **ppPacketArray, u32 NumberOfPackets);
void RTMPDeQueuePacket(struct rt_rtmp_adapter *pAd,
IN BOOLEAN bIntContext,
u8 QueIdx, u8 Max_Tx_Packets);
int RTMPHardTransmit(struct rt_rtmp_adapter *pAd,
void *pPacket,
u8 QueIdx, unsigned long *pFreeTXDLeft);
int STAHardTransmit(struct rt_rtmp_adapter *pAd,
struct rt_tx_blk *pTxBlk, u8 QueIdx);
void STARxEAPOLFrameIndicate(struct rt_rtmp_adapter *pAd,
struct rt_mac_table_entry *pEntry,
struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
int RTMPFreeTXDRequest(struct rt_rtmp_adapter *pAd,
u8 RingType,
u8 NumberRequired, u8 *FreeNumberIs);
int MlmeHardTransmit(struct rt_rtmp_adapter *pAd,
u8 QueIdx, void *pPacket);
int MlmeHardTransmitMgmtRing(struct rt_rtmp_adapter *pAd,
u8 QueIdx, void *pPacket);
int MlmeHardTransmitTxRing(struct rt_rtmp_adapter *pAd,
u8 QueIdx, void *pPacket);
int MlmeDataHardTransmit(struct rt_rtmp_adapter *pAd,
u8 QueIdx, void *pPacket);
void RTMPWriteTxDescriptor(struct rt_rtmp_adapter *pAd,
struct rt_txd *pTxD, IN BOOLEAN bWIV, u8 QSEL);
#endif /* RTMP_MAC_PCI // */
u16 RTMPCalcDuration(struct rt_rtmp_adapter *pAd, u8 Rate, unsigned long Size);
void RTMPWriteTxWI(struct rt_rtmp_adapter *pAd, struct rt_txwi * pTxWI, IN BOOLEAN FRAG, IN BOOLEAN CFACK, IN BOOLEAN InsTimestamp, IN BOOLEAN AMPDU, IN BOOLEAN Ack, IN BOOLEAN NSeq, /* HW new a sequence. */
u8 BASize,
u8 WCID,
unsigned long Length,
u8 PID,
u8 TID,
u8 TxRate,
u8 Txopmode,
void RTMPWriteTxWI_Data(struct rt_rtmp_adapter *pAd,
struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk);
void RTMPWriteTxWI_Cache(struct rt_rtmp_adapter *pAd,
struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk);
void RTMPSuspendMsduTransmission(struct rt_rtmp_adapter *pAd);
void RTMPResumeMsduTransmission(struct rt_rtmp_adapter *pAd);
int MiniportMMRequest(struct rt_rtmp_adapter *pAd,
u8 QueIdx, u8 *pData, u32 Length);
/*+++mark by shiang, now this function merge to MiniportMMRequest() */
/*---mark by shiang, now this function merge to MiniportMMRequest() */
void RTMPSendNullFrame(struct rt_rtmp_adapter *pAd,
u8 TxRate, IN BOOLEAN bQosNull);
void RTMPSendDisassociationFrame(struct rt_rtmp_adapter *pAd);
void RTMPSendRTSFrame(struct rt_rtmp_adapter *pAd,
u8 *pDA,
IN unsigned int NextMpduSize,
u8 TxRate,
u8 RTSRate,
u16 AckDuration,
u8 QueIdx, u8 FrameGap);
struct rt_queue_header *RTMPCheckTxSwQueue(struct rt_rtmp_adapter *pAd, u8 * QueIdx);
void RTMPReportMicError(struct rt_rtmp_adapter *pAd, struct rt_cipher_key *pWpaKey);
void WpaMicFailureReportFrame(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void WpaDisassocApAndBlockAssoc(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2,
void *SystemSpecific3);
void WpaStaPairwiseKeySetting(struct rt_rtmp_adapter *pAd);
void WpaStaGroupKeySetting(struct rt_rtmp_adapter *pAd);
int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd,
void *pInPacket,
void **ppOutPacket);
int RTMPAllocateNdisPacket(struct rt_rtmp_adapter *pAd,
void **pPacket,
u8 *pHeader,
u32 HeaderLen,
u8 *pData, u32 DataLen);
void RTMPFreeNdisPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
BOOLEAN RTMPFreeTXDUponTxDmaDone(struct rt_rtmp_adapter *pAd, u8 QueIdx);
BOOLEAN RTMPCheckDHCPFrame(struct rt_rtmp_adapter *pAd, void *pPacket);
BOOLEAN RTMPCheckEtherType(struct rt_rtmp_adapter *pAd, void *pPacket);
/* */
/* Private routines in rtmp_wep.c */
/* */
void RTMPInitWepEngine(struct rt_rtmp_adapter *pAd,
u8 *pKey,
u8 KeyId, u8 KeyLen, u8 *pDest);
void RTMPEncryptData(struct rt_rtmp_adapter *pAd,
u8 *pSrc, u8 *pDest, u32 Len);
BOOLEAN RTMPSoftDecryptWEP(struct rt_rtmp_adapter *pAd,
u8 *pData,
unsigned long DataByteCnt, struct rt_cipher_key *pGroupKey);
void RTMPSetICV(struct rt_rtmp_adapter *pAd, u8 *pDest);
void ARCFOUR_INIT(struct rt_arcfourcontext *Ctx, u8 *pKey, u32 KeyLen);
u8 ARCFOUR_BYTE(struct rt_arcfourcontext *Ctx);
void ARCFOUR_DECRYPT(struct rt_arcfourcontext *Ctx,
u8 *pDest, u8 *pSrc, u32 Len);
void ARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
u8 *pDest, u8 *pSrc, u32 Len);
void WPAARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
u8 *pDest, u8 *pSrc, u32 Len);
u32 RTMP_CALC_FCS32(u32 Fcs, u8 *Cp, int Len);
/* */
/* MLME routines */
/* */
/* Asic/RF/BBP related functions */
void AsicAdjustTxPower(struct rt_rtmp_adapter *pAd);
void AsicUpdateProtect(struct rt_rtmp_adapter *pAd,
u16 OperaionMode,
u8 SetMask,
IN BOOLEAN bDisableBGProtect, IN BOOLEAN bNonGFExist);
void AsicSwitchChannel(struct rt_rtmp_adapter *pAd,
u8 Channel, IN BOOLEAN bScan);
void AsicLockChannel(struct rt_rtmp_adapter *pAd, u8 Channel);
void AsicRfTuningExec(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
void AsicResetBBPAgent(struct rt_rtmp_adapter *pAd);
void AsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
u16 TbttNumToNextWakeUp);
void AsicForceSleep(struct rt_rtmp_adapter *pAd);
void AsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
void AsicSetBssid(struct rt_rtmp_adapter *pAd, u8 *pBssid);
void AsicSetMcastWC(struct rt_rtmp_adapter *pAd);
void AsicDelWcidTab(struct rt_rtmp_adapter *pAd, u8 Wcid);
void AsicEnableRDG(struct rt_rtmp_adapter *pAd);
void AsicDisableRDG(struct rt_rtmp_adapter *pAd);
void AsicDisableSync(struct rt_rtmp_adapter *pAd);
void AsicEnableBssSync(struct rt_rtmp_adapter *pAd);
void AsicEnableIbssSync(struct rt_rtmp_adapter *pAd);
void AsicSetEdcaParm(struct rt_rtmp_adapter *pAd, struct rt_edca_parm *pEdcaParm);
void AsicSetSlotTime(struct rt_rtmp_adapter *pAd, IN BOOLEAN bUseShortSlotTime);
void AsicAddSharedKeyEntry(struct rt_rtmp_adapter *pAd,
u8 BssIndex,
u8 KeyIdx,
u8 CipherAlg,
u8 *pKey, u8 *pTxMic, u8 *pRxMic);
void AsicRemoveSharedKeyEntry(struct rt_rtmp_adapter *pAd,
u8 BssIndex, u8 KeyIdx);
void AsicUpdateWCIDAttribute(struct rt_rtmp_adapter *pAd,
u16 WCID,
u8 BssIndex,
u8 CipherAlg,
IN BOOLEAN bUsePairewiseKeyTable);
void AsicUpdateWCIDIVEIV(struct rt_rtmp_adapter *pAd,
u16 WCID, unsigned long uIV, unsigned long uEIV);
void AsicUpdateRxWCIDTable(struct rt_rtmp_adapter *pAd,
u16 WCID, u8 *pAddr);
void AsicAddKeyEntry(struct rt_rtmp_adapter *pAd,
u16 WCID,
u8 BssIndex,
u8 KeyIdx,
struct rt_cipher_key *pCipherKey,
IN BOOLEAN bUsePairewiseKeyTable, IN BOOLEAN bTxKey);
void AsicAddPairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
u8 *pAddr,
u8 WCID, struct rt_cipher_key *pCipherKey);
void AsicRemovePairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
u8 BssIdx, u8 Wcid);
BOOLEAN AsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
u8 Command,
u8 Token, u8 Arg0, u8 Arg1);
BOOLEAN AsicCheckCommanOk(struct rt_rtmp_adapter *pAd, u8 Command);
#endif /* RTMP_MAC_PCI // */
void MacAddrRandomBssid(struct rt_rtmp_adapter *pAd, u8 *pAddr);
void MgtMacHeaderInit(struct rt_rtmp_adapter *pAd,
struct rt_header_802_11 *pHdr80211,
u8 SubType,
u8 ToDs, u8 *pDA, u8 *pBssid);
void MlmeRadioOff(struct rt_rtmp_adapter *pAd);
void MlmeRadioOn(struct rt_rtmp_adapter *pAd);
void BssTableInit(struct rt_bss_table *Tab);
void BATableInit(struct rt_rtmp_adapter *pAd, struct rt_ba_table *Tab);
unsigned long BssTableSearch(struct rt_bss_table *Tab, u8 *pBssid, u8 Channel);
unsigned long BssSsidTableSearch(struct rt_bss_table *Tab,
u8 *pBssid,
u8 *pSsid, u8 SsidLen, u8 Channel);
unsigned long BssTableSearchWithSSID(struct rt_bss_table *Tab,
u8 *Bssid,
u8 *pSsid,
u8 SsidLen, u8 Channel);
unsigned long BssSsidTableSearchBySSID(struct rt_bss_table *Tab,
u8 *pSsid, u8 SsidLen);
void BssTableDeleteEntry(struct rt_bss_table *pTab,
u8 *pBssid, u8 Channel);
void BATableDeleteORIEntry(struct rt_rtmp_adapter *pAd,
struct rt_ba_ori_entry *pBAORIEntry);
void BssEntrySet(struct rt_rtmp_adapter *pAd, struct rt_bss_entry *pBss, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * CfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo, /* AP might use this additional ht info IE */
u8 HtCapabilityLen,
u8 AddHtInfoLen,
u8 NewExtChanOffset,
u8 Channel,
char Rssi,
u8 CkipFlag,
struct rt_edca_parm *pEdcaParm,
struct rt_qos_capability_parm *pQosCapability,
struct rt_qbss_load_parm *pQbssLoad,
u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
unsigned long BssTableSetEntry(struct rt_rtmp_adapter *pAd, struct rt_bss_table *pTab, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * CfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo, /* AP might use this additional ht info IE */
u8 HtCapabilityLen,
u8 AddHtInfoLen,
u8 NewExtChanOffset,
u8 Channel,
char Rssi,
u8 CkipFlag,
struct rt_edca_parm *pEdcaParm,
struct rt_qos_capability_parm *pQosCapability,
struct rt_qbss_load_parm *pQbssLoad,
u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
void BATableInsertEntry(struct rt_rtmp_adapter *pAd,
u16 Aid,
u16 TimeOutValue,
u16 StartingSeq,
u8 TID,
u8 BAWinSize,
u8 OriginatorStatus, IN BOOLEAN IsRecipient);
void BssTableSsidSort(struct rt_rtmp_adapter *pAd,
struct rt_bss_table *OutTab, char Ssid[], u8 SsidLen);
void BssTableSortByRssi(struct rt_bss_table *OutTab);
void BssCipherParse(struct rt_bss_entry *pBss);
int MlmeQueueInit(struct rt_mlme_queue *Queue);
void MlmeQueueDestroy(struct rt_mlme_queue *Queue);
BOOLEAN MlmeEnqueue(struct rt_rtmp_adapter *pAd,
unsigned long Machine,
unsigned long MsgType, unsigned long MsgLen, void *Msg);
BOOLEAN MlmeEnqueueForRecv(struct rt_rtmp_adapter *pAd,
unsigned long Wcid,
unsigned long TimeStampHigh,
unsigned long TimeStampLow,
u8 Rssi0,
u8 Rssi1,
u8 Rssi2,
unsigned long MsgLen, void *Msg, u8 Signal);
BOOLEAN MlmeDequeue(struct rt_mlme_queue *Queue, struct rt_mlme_queue_elem **Elem);
void MlmeRestartStateMachine(struct rt_rtmp_adapter *pAd);
BOOLEAN MlmeQueueEmpty(struct rt_mlme_queue *Queue);
BOOLEAN MlmeQueueFull(struct rt_mlme_queue *Queue);
BOOLEAN MsgTypeSubst(struct rt_rtmp_adapter *pAd,
struct rt_frame_802_11 *pFrame,
int *Machine, int *MsgType);
void StateMachineInit(struct rt_state_machine *Sm,
unsigned long StNr,
unsigned long MsgNr,
unsigned long InitState, unsigned long Base);
void StateMachineSetAction(struct rt_state_machine *S,
unsigned long St, unsigned long Msg, IN STATE_MACHINE_FUNC F);
void StateMachinePerformAction(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *S, struct rt_mlme_queue_elem *Elem);
void Drop(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void AssocStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *Sm,
void ReassocTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
void AssocTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
void DisassocTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
/*---------------------------------------------- */
void MlmeAssocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void MlmeReassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void MlmeDisassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerAssocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerReassocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerDisassocAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void DisassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void AssocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void ReassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void Cls3errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
void InvalidStateWhenAssoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void InvalidStateWhenReassoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void InvalidStateWhenDisassociate(struct rt_rtmp_adapter *pAd,
struct rt_mlme_queue_elem *Elem);
void MlmeCntlConfirm(struct rt_rtmp_adapter *pAd, unsigned long MsgType, u16 Msg);
#endif /* RTMP_MAC_USB // */
void ComposePsPoll(struct rt_rtmp_adapter *pAd);
void ComposeNullFrame(struct rt_rtmp_adapter *pAd);
void AssocPostProc(struct rt_rtmp_adapter *pAd,
u8 *pAddr2,
u16 CapabilityInfo,
u16 Aid,
u8 SupRate[],
u8 SupRateLen,
u8 ExtRate[],
u8 ExtRateLen,
struct rt_edca_parm *pEdcaParm,
struct rt_ht_capability_ie *pHtCapability,
u8 HtCapabilityLen, struct rt_add_ht_info_ie *pAddHtInfo);
void AuthStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *sm, OUT STATE_MACHINE_FUNC Trans[]);
void AuthTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
void MlmeAuthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerAuthRspAtSeq2Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerAuthRspAtSeq4Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void AuthTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void Cls2errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
void MlmeDeauthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void InvalidStateWhenAuth(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
/*============================================= */
void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *Sm,
void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd,
struct rt_header_802_11 *pHdr80211,
u16 Alg,
u16 Seq,
u16 Reason, u16 Status);
/* */
/* Private routines in dls.c */
/* */
/*======================================== */
void SyncStateMachineInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *Sm,
void BeaconTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
void ScanTimeout(void *SystemSpecific1,
void *FunctionContext,
void *SystemSpecific2, void *SystemSpecific3);
void InvalidStateWhenScan(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void InvalidStateWhenJoin(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void InvalidStateWhenStart(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void EnqueueProbeRequest(struct rt_rtmp_adapter *pAd);
BOOLEAN ScanRunning(struct rt_rtmp_adapter *pAd);
/*========================================= */
void MlmeCntlInit(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[]);
void MlmeCntlMachinePerformAction(struct rt_rtmp_adapter *pAd,
struct rt_state_machine *S,
struct rt_mlme_queue_elem *Elem);
void CntlIdleProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlOidScanProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlOidSsidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlOidRTBssidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlMlmeRoamingProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlWaitDisassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlWaitJoinProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlWaitReassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlWaitStartProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlWaitAuthProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlWaitAuthProc2(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void CntlWaitAssocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void LinkUp(struct rt_rtmp_adapter *pAd, u8 BssType);
void LinkDown(struct rt_rtmp_adapter *pAd, IN BOOLEAN IsReqFromAP);
void IterateOnBssTab(struct rt_rtmp_adapter *pAd);
void IterateOnBssTab2(struct rt_rtmp_adapter *pAd);;
void JoinParmFill(struct rt_rtmp_adapter *pAd,
struct rt_mlme_join_req *JoinReq, unsigned long BssIdx);
void AssocParmFill(struct rt_rtmp_adapter *pAd,
struct rt_mlme_assoc_req *AssocReq,
u8 *pAddr,
u16 CapabilityInfo,
unsigned long Timeout, u16 ListenIntv);
void ScanParmFill(struct rt_rtmp_adapter *pAd,
struct rt_mlme_scan_req *ScanReq,
char Ssid[],
u8 SsidLen, u8 BssType, u8 ScanType);
void DisassocParmFill(struct rt_rtmp_adapter *pAd,
struct rt_mlme_disassoc_req *DisassocReq,
u8 *pAddr, u16 Reason);
void StartParmFill(struct rt_rtmp_adapter *pAd,
struct rt_mlme_start_req *StartReq,
char Ssid[], u8 SsidLen);
void AuthParmFill(struct rt_rtmp_adapter *pAd,
struct rt_mlme_auth_req *AuthReq,
u8 *pAddr, u16 Alg);
void EnqueuePsPoll(struct rt_rtmp_adapter *pAd);
void EnqueueBeaconFrame(struct rt_rtmp_adapter *pAd);
void MlmeJoinReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void MlmeScanReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void MlmeStartReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void ScanTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void BeaconTimeoutAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerBeaconAtScanAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerBeaconAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerBeacon(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void PeerProbeReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
void ScanNextChannel(struct rt_rtmp_adapter *pAd);
unsigned long MakeIbssBeacon(struct rt_rtmp_adapter *pAd);
BOOLEAN MlmeScanReqSanity(struct rt_rtmp_adapter *pAd,
void *Msg,
unsigned long MsgLen,
u8 *BssType,
char ssid[],
u8 *SsidLen, u8 *ScanType);
BOOLEAN PeerBeaconAndProbeRspSanity(struct rt_rtmp_adapter *pAd,
void *Msg,
unsigned long MsgLen,
u8 MsgChannel,
u8 *pAddr2,
u8 *pBssid,