/kern_2.6.32/drivers/staging/rt3090/rtmp.h
http://omnia2droid.googlecode.com/ · C++ Header · 6873 lines · 4998 code · 1315 blank · 560 comment · 96 complexity · 6fd45c494fabd737451d1d3036c7fffa MD5 · raw file
Large files are truncated click here to view the full file
- /*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- Module Name:
- rtmp.h
- Abstract:
- 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 "link_list.h"
- #include "spectrum_def.h"
- #include "rtmp_dot11.h"
- #ifdef MLME_EX
- #include "mlme_ex_def.h"
- #endif // MLME_EX //
- #ifdef CONFIG_STA_SUPPORT
- #endif // CONFIG_STA_SUPPORT //
- #undef AP_WSC_INCLUDED
- #undef STA_WSC_INCLUDED
- #undef WSC_INCLUDED
- #ifdef CONFIG_STA_SUPPORT
- #endif // CONFIG_STA_SUPPORT //
- #if defined(AP_WSC_INCLUDED) || defined(STA_WSC_INCLUDED)
- #define WSC_INCLUDED
- #endif
- #include "rtmp_chip.h"
- typedef struct _RTMP_ADAPTER RTMP_ADAPTER;
- typedef struct _RTMP_ADAPTER *PRTMP_ADAPTER;
- typedef struct _RTMP_CHIP_OP_ RTMP_CHIP_OP;
- //#define DBG 1
- //#define DBG_DIAGNOSE 1
- //+++Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function
- #define MAX_DATAMM_RETRY 3
- #define MGMT_USE_QUEUE_FLAG 0x80
- //---Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function
- #define MAXSEQ (0xFFF)
- #if defined(CONFIG_AP_SUPPORT) && defined(CONFIG_STA_SUPPORT)
- #define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd) if(_pAd->OpMode == OPMODE_AP)
- #define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd) if(_pAd->OpMode == OPMODE_STA)
- #else
- #define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd)
- #define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd)
- #endif
- extern unsigned char SNAP_AIRONET[];
- extern unsigned char CISCO_OUI[];
- extern UCHAR BaSizeArray[4];
- extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN];
- extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN];
- extern ULONG BIT32[32];
- extern UCHAR BIT8[8];
- extern char* CipherName[];
- extern char* MCSToMbps[];
- extern UCHAR RxwiMCSToOfdmRate[12];
- extern UCHAR SNAP_802_1H[6];
- extern UCHAR SNAP_BRIDGE_TUNNEL[6];
- extern UCHAR SNAP_AIRONET[8];
- extern UCHAR CKIP_LLC_SNAP[8];
- extern UCHAR EAPOL_LLC_SNAP[8];
- extern UCHAR EAPOL[2];
- extern UCHAR IPX[2];
- extern UCHAR APPLE_TALK[2];
- extern UCHAR RateIdToPlcpSignal[12]; // see IEEE802.11a-1999 p.14
- extern UCHAR OfdmRateToRxwiMCS[];
- extern UCHAR OfdmSignalToRateId[16] ;
- extern UCHAR default_cwmin[4];
- extern UCHAR default_cwmax[4];
- extern UCHAR default_sta_aifsn[4];
- extern UCHAR MapUserPriorityToAccessCategory[8];
- extern USHORT RateUpPER[];
- extern USHORT RateDownPER[];
- extern UCHAR Phy11BNextRateDownward[];
- extern UCHAR Phy11BNextRateUpward[];
- extern UCHAR Phy11BGNextRateDownward[];
- extern UCHAR Phy11BGNextRateUpward[];
- extern UCHAR Phy11ANextRateDownward[];
- extern UCHAR Phy11ANextRateUpward[];
- extern CHAR RssiSafeLevelForTxRate[];
- extern UCHAR RateIdToMbps[];
- extern USHORT RateIdTo500Kbps[];
- extern UCHAR CipherSuiteWpaNoneTkip[];
- extern UCHAR CipherSuiteWpaNoneTkipLen;
- extern UCHAR CipherSuiteWpaNoneAes[];
- extern UCHAR CipherSuiteWpaNoneAesLen;
- extern UCHAR SsidIe;
- extern UCHAR SupRateIe;
- extern UCHAR ExtRateIe;
- #ifdef DOT11_N_SUPPORT
- extern UCHAR HtCapIe;
- extern UCHAR AddHtInfoIe;
- extern UCHAR NewExtChanIe;
- #ifdef DOT11N_DRAFT3
- extern UCHAR ExtHtCapIe;
- #endif // DOT11N_DRAFT3 //
- #endif // DOT11_N_SUPPORT //
- extern UCHAR ErpIe;
- extern UCHAR DsIe;
- extern UCHAR TimIe;
- extern UCHAR WpaIe;
- extern UCHAR Wpa2Ie;
- extern UCHAR IbssIe;
- extern UCHAR Ccx2Ie;
- extern UCHAR WapiIe;
- extern UCHAR WPA_OUI[];
- extern UCHAR RSN_OUI[];
- extern UCHAR WAPI_OUI[];
- extern UCHAR WME_INFO_ELEM[];
- extern UCHAR WME_PARM_ELEM[];
- extern UCHAR Ccx2QosInfo[];
- extern UCHAR Ccx2IeInfo[];
- extern UCHAR RALINK_OUI[];
- extern UCHAR PowerConstraintIE[];
- extern UCHAR RateSwitchTable[];
- extern UCHAR RateSwitchTable11B[];
- extern UCHAR RateSwitchTable11G[];
- extern UCHAR RateSwitchTable11BG[];
- #ifdef DOT11_N_SUPPORT
- extern UCHAR RateSwitchTable11BGN1S[];
- extern UCHAR RateSwitchTable11BGN2S[];
- extern UCHAR RateSwitchTable11BGN2SForABand[];
- extern UCHAR RateSwitchTable11N1S[];
- extern UCHAR RateSwitchTable11N2S[];
- extern UCHAR RateSwitchTable11N2SForABand[];
- #ifdef CONFIG_STA_SUPPORT
- extern UCHAR PRE_N_HT_OUI[];
- #endif // CONFIG_STA_SUPPORT //
- #endif // DOT11_N_SUPPORT //
- #ifdef RALINK_ATE
- typedef struct _ATE_INFO {
- UCHAR Mode;
- CHAR TxPower0;
- CHAR TxPower1;
- CHAR TxAntennaSel;
- CHAR RxAntennaSel;
- TXWI_STRUC TxWI; // TXWI
- USHORT QID;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR Addr3[MAC_ADDR_LEN];
- UCHAR Channel;
- UINT32 TxLength;
- UINT32 TxCount;
- UINT32 TxDoneCount; // Tx DMA Done
- UINT32 RFFreqOffset;
- BOOLEAN bRxFER; // Show Rx Frame Error Rate
- BOOLEAN bQATxStart; // Have compiled QA in and use it to ATE tx.
- BOOLEAN bQARxStart; // Have compiled QA in and use it to ATE rx.
- #ifdef RTMP_MAC_PCI
- BOOLEAN bFWLoading; // Reload firmware when ATE is done.
- #endif // RTMP_MAC_PCI //
- UINT32 RxTotalCnt;
- UINT32 RxCntPerSec;
- CHAR LastSNR0; // last received SNR
- CHAR LastSNR1; // last received SNR for 2nd antenna
- CHAR LastRssi0; // last received RSSI
- CHAR LastRssi1; // last received RSSI for 2nd antenna
- CHAR LastRssi2; // last received RSSI for 3rd antenna
- CHAR AvgRssi0; // last 8 frames' average RSSI
- CHAR AvgRssi1; // last 8 frames' average RSSI
- CHAR AvgRssi2; // last 8 frames' average RSSI
- SHORT AvgRssi0X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi1X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi2X8; // sum of last 8 frames' RSSI
- UINT32 NumOfAvgRssiSample;
- #ifdef RALINK_28xx_QA
- // Tx frame
- USHORT HLen; // Header Length
- USHORT PLen; // Pattern Length
- UCHAR Header[32]; // Header buffer
- UCHAR Pattern[32]; // Pattern buffer
- USHORT DLen; // Data Length
- USHORT seq;
- UINT32 CID;
- RTMP_OS_PID AtePid;
- // counters
- UINT32 U2M;
- UINT32 OtherData;
- UINT32 Beacon;
- UINT32 OtherCount;
- UINT32 TxAc0;
- UINT32 TxAc1;
- UINT32 TxAc2;
- UINT32 TxAc3;
- /*UINT32 TxHCCA;*/
- UINT32 TxMgmt;
- UINT32 RSSI0;
- UINT32 RSSI1;
- UINT32 RSSI2;
- UINT32 SNR0;
- UINT32 SNR1;
- // TxStatus : 0 --> task is idle, 1 --> task is running
- UCHAR TxStatus;
- #endif // RALINK_28xx_QA //
- } ATE_INFO, *PATE_INFO;
- #ifdef RALINK_28xx_QA
- struct ate_racfghdr {
- UINT32 magic_no;
- USHORT command_type;
- USHORT command_id;
- USHORT length;
- USHORT sequence;
- USHORT status;
- UCHAR data[2046];
- } __attribute__((packed));
- #endif // RALINK_28xx_QA //
- #endif // RALINK_ATE //
- typedef struct _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;
- } RSSI_SAMPLE;
- //
- // Queue structure and macros
- //
- typedef struct _QUEUE_ENTRY {
- struct _QUEUE_ENTRY *Next;
- } QUEUE_ENTRY, *PQUEUE_ENTRY;
- // Queue structure
- typedef struct _QUEUE_HEADER {
- PQUEUE_ENTRY Head;
- PQUEUE_ENTRY Tail;
- ULONG Number;
- } QUEUE_HEADER, *PQUEUE_HEADER;
- #define InitializeQueueHeader(QueueHeader) \
- { \
- (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
- (QueueHeader)->Number = 0; \
- }
- #define RemoveHeadQueue(QueueHeader) \
- (QueueHeader)->Head; \
- { \
- PQUEUE_ENTRY pNext; \
- 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) \
- { \
- ((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \
- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
- if ((QueueHeader)->Tail == NULL) \
- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Number++; \
- }
- #define InsertTailQueue(QueueHeader, QueueEntry) \
- { \
- ((PQUEUE_ENTRY)QueueEntry)->Next = NULL; \
- if ((QueueHeader)->Tail) \
- (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
- else \
- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Number++; \
- }
- #define InsertTailQueueAc(pAd, pEntry, QueueHeader, QueueEntry) \
- { \
- ((PQUEUE_ENTRY)QueueEntry)->Next = NULL; \
- if ((QueueHeader)->Tail) \
- (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
- else \
- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Number++; \
- }
- //
- // Macros for flag and ref count operations
- //
- #define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
- #define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
- #define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
- #define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
- #define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
- // 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)
- #ifdef CONFIG_STA_SUPPORT
- #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)
- #endif // CONFIG_STA_SUPPORT //
- #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); \
- }
- #ifdef DOT11_N_SUPPORT
- // StaActive.SupportedHtPhy.MCSSet is copied from AP beacon. Don't need to update here.
- #define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
- { \
- _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(UCHAR) * 16);\
- }
- #define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability) \
- { \
- _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (UCHAR)(_pHtCapability->HtCapInfo.AMsduSize); \
- _pAd->MacTab.Content[BSSID_WCID].MmpsMode= (UCHAR)(_pHtCapability->HtCapInfo.MimoPs); \
- _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (UCHAR)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \
- }
- #endif // DOT11_N_SUPPORT //
- //
- // MACRO for 32-bit PCI register read / write
- //
- // Usage : RTMP_IO_READ32(
- // PRTMP_ADAPTER pAd,
- // ULONG Register_Offset,
- // PULONG pValue)
- //
- // RTMP_IO_WRITE32(
- // PRTMP_ADAPTER pAd,
- // ULONG Register_Offset,
- // ULONG Value)
- //
- //
- // Common fragment list structure - Identical to the scatter gather frag list structure
- //
- //#define RTMP_SCATTER_GATHER_ELEMENT SCATTER_GATHER_ELEMENT
- //#define PRTMP_SCATTER_GATHER_ELEMENT PSCATTER_GATHER_ELEMENT
- #define NIC_MAX_PHYS_BUF_COUNT 8
- typedef struct _RTMP_SCATTER_GATHER_ELEMENT {
- PVOID Address;
- ULONG Length;
- PULONG Reserved;
- } RTMP_SCATTER_GATHER_ELEMENT, *PRTMP_SCATTER_GATHER_ELEMENT;
- typedef struct _RTMP_SCATTER_GATHER_LIST {
- ULONG NumberOfElements;
- PULONG Reserved;
- RTMP_SCATTER_GATHER_ELEMENT Elements[NIC_MAX_PHYS_BUF_COUNT];
- } RTMP_SCATTER_GATHER_LIST, *PRTMP_SCATTER_GATHER_LIST;
- //
- // Some utility macros
- //
- #ifndef min
- #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
- #endif
- #ifndef max
- #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
- #endif
- #define 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 INFRA_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
- #define ADHOC_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
- #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)) \
- { \
- PUCHAR pProto = _pData + 6; \
- \
- if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \
- NdisEqualMemory(SNAP_802_1H, _pData, 6)) \
- { \
- LLC_Len[0] = (UCHAR)(_DataSize / 256); \
- LLC_Len[1] = (UCHAR)(_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] = (UCHAR)(_DataSize / 256); \
- LLC_Len[1] = (UCHAR)(_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
- #ifdef RTMP_MAC_PCI
- #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
- { \
- UINT32 High32TSF, Low32TSF; \
- RTMP_IO_READ32(_pAd, TSF_TIMER_DW1, &High32TSF); \
- RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \
- MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
- }
- #endif // RTMP_MAC_PCI //
- #define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(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))
- #ifdef CONFIG_STA_SUPPORT
- #define STA_EXTRA_SETTING(_pAd)
- #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);\
- STA_EXTRA_SETTING(_pAd); \
- }
- #endif // CONFIG_STA_SUPPORT //
- //
- // Data buffer for DMA operation, the buffer must be contiguous physical memory
- // Both DMA to / from CPU use the same structure.
- //
- typedef struct _RTMP_DMABUF
- {
- ULONG AllocSize;
- PVOID AllocVa; // TxBuf virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // TxBuf physical address
- } RTMP_DMABUF, *PRTMP_DMABUF;
- //
- // Control block (Descriptor) for all ring descriptor DMA operation, buffer must be
- // contiguous physical memory. NDIS_PACKET 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, NDIS_PACKET stored the tx packet descriptor
- // which driver should ACK upper layer when the tx is physically done or failed.
- //
- typedef struct _RTMP_DMACB
- {
- ULONG AllocSize; // Control block size
- PVOID AllocVa; // Control block virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // Control block physical address
- PNDIS_PACKET pNdisPacket;
- PNDIS_PACKET pNextNdisPacket;
- RTMP_DMABUF DmaBuf; // Associated DMA buffer structure
- } RTMP_DMACB, *PRTMP_DMACB;
- typedef struct _RTMP_TX_RING
- {
- RTMP_DMACB Cell[TX_RING_SIZE];
- UINT32 TxCpuIdx;
- UINT32 TxDmaIdx;
- UINT32 TxSwFreeIdx; // software next free tx index
- } RTMP_TX_RING, *PRTMP_TX_RING;
- typedef struct _RTMP_RX_RING
- {
- RTMP_DMACB Cell[RX_RING_SIZE];
- UINT32 RxCpuIdx;
- UINT32 RxDmaIdx;
- INT32 RxSwReadIdx; // software next read index
- } RTMP_RX_RING, *PRTMP_RX_RING;
- typedef struct _RTMP_MGMT_RING
- {
- RTMP_DMACB Cell[MGMT_RING_SIZE];
- UINT32 TxCpuIdx;
- UINT32 TxDmaIdx;
- UINT32 TxSwFreeIdx; // software next free tx index
- } RTMP_MGMT_RING, *PRTMP_MGMT_RING;
- //
- // Statistic counter structure
- //
- typedef struct _COUNTER_802_3
- {
- // General Stats
- ULONG GoodTransmits;
- ULONG GoodReceives;
- ULONG TxErrors;
- ULONG RxErrors;
- ULONG RxNoBuffer;
- // Ethernet Stats
- ULONG RcvAlignmentErrors;
- ULONG OneCollision;
- ULONG MoreCollisions;
- } COUNTER_802_3, *PCOUNTER_802_3;
- typedef struct _COUNTER_802_11 {
- ULONG Length;
- LARGE_INTEGER LastTransmittedFragmentCount;
- LARGE_INTEGER TransmittedFragmentCount;
- LARGE_INTEGER MulticastTransmittedFrameCount;
- LARGE_INTEGER FailedCount;
- LARGE_INTEGER RetryCount;
- LARGE_INTEGER MultipleRetryCount;
- LARGE_INTEGER RTSSuccessCount;
- LARGE_INTEGER RTSFailureCount;
- LARGE_INTEGER ACKFailureCount;
- LARGE_INTEGER FrameDuplicateCount;
- LARGE_INTEGER ReceivedFragmentCount;
- LARGE_INTEGER MulticastReceivedFrameCount;
- LARGE_INTEGER FCSErrorCount;
- } COUNTER_802_11, *PCOUNTER_802_11;
- typedef struct _COUNTER_RALINK {
- ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput
- ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput
- ULONG BeenDisassociatedCount;
- ULONG BadCQIAutoRecoveryCount;
- ULONG PoorCQIRoamingCount;
- ULONG MgmtRingFullCount;
- ULONG RxCountSinceLastNULL;
- ULONG RxCount;
- ULONG RxRingErrCount;
- ULONG KickTxCount;
- ULONG TxRingErrCount;
- LARGE_INTEGER RealFcsErrCount;
- ULONG PendingNdisPacketCount;
- ULONG OneSecOsTxCount[NUM_OF_TX_RING];
- ULONG OneSecDmaDoneCount[NUM_OF_TX_RING];
- UINT32 OneSecTxDoneCount;
- ULONG OneSecRxCount;
- UINT32 OneSecTxAggregationCount;
- UINT32 OneSecRxAggregationCount;
- UINT32 OneSecReceivedByteCount;
- UINT32 OneSecFrameDuplicateCount;
- UINT32 OneSecTransmittedByteCount; // both successful and failure, used to calculate TX throughput
- UINT32 OneSecTxNoRetryOkCount;
- UINT32 OneSecTxRetryOkCount;
- UINT32 OneSecTxFailCount;
- UINT32 OneSecFalseCCACnt; // CCA error count, for debug purpose, might move to global counter
- UINT32 OneSecRxOkCnt; // RX without error
- UINT32 OneSecRxOkDataCnt; // unicast-to-me DATA frame count
- UINT32 OneSecRxFcsErrCnt; // CRC error
- UINT32 OneSecBeaconSentCnt;
- UINT32 LastOneSecTotalTxCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
- UINT32 LastOneSecRxOkDataCnt; // OneSecRxOkDataCnt
- ULONG DuplicateRcv;
- ULONG TxAggCount;
- ULONG TxNonAggCount;
- ULONG TxAgg1MPDUCount;
- ULONG TxAgg2MPDUCount;
- ULONG TxAgg3MPDUCount;
- ULONG TxAgg4MPDUCount;
- ULONG TxAgg5MPDUCount;
- ULONG TxAgg6MPDUCount;
- ULONG TxAgg7MPDUCount;
- ULONG TxAgg8MPDUCount;
- ULONG TxAgg9MPDUCount;
- ULONG TxAgg10MPDUCount;
- ULONG TxAgg11MPDUCount;
- ULONG TxAgg12MPDUCount;
- ULONG TxAgg13MPDUCount;
- ULONG TxAgg14MPDUCount;
- ULONG TxAgg15MPDUCount;
- ULONG TxAgg16MPDUCount;
- LARGE_INTEGER TransmittedOctetsInAMSDU;
- LARGE_INTEGER TransmittedAMSDUCount;
- LARGE_INTEGER ReceivedOctesInAMSDUCount;
- LARGE_INTEGER ReceivedAMSDUCount;
- LARGE_INTEGER TransmittedAMPDUCount;
- LARGE_INTEGER TransmittedMPDUsInAMPDUCount;
- LARGE_INTEGER TransmittedOctetsInAMPDUCount;
- LARGE_INTEGER MPDUInReceivedAMPDUCount;
- } COUNTER_RALINK, *PCOUNTER_RALINK;
- typedef struct _COUNTER_DRS {
- // to record the each TX rate's quality. 0 is best, the bigger the worse.
- USHORT TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
- UCHAR PER[MAX_STEP_OF_TX_RATE_SWITCH];
- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
- ULONG CurrTxRateStableTime; // # of second in current TX rate
- BOOLEAN fNoisyEnvironment;
- BOOLEAN fLastSecAccordingRSSI;
- UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
- UCHAR LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
- ULONG LastTxOkCount;
- } COUNTER_DRS, *PCOUNTER_DRS;
- /***************************************************************************
- * security key related data structure
- **************************************************************************/
- typedef struct _CIPHER_KEY {
- UCHAR Key[16]; // right now we implement 4 keys, 128 bits max
- UCHAR RxMic[8]; // make alignment
- UCHAR TxMic[8];
- UCHAR TxTsc[6]; // 48bit TSC value
- UCHAR RxTsc[6]; // 48bit TSC value
- UCHAR CipherAlg; // 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128
- UCHAR KeyLen;
- #ifdef CONFIG_STA_SUPPORT
- UCHAR BssId[6];
- #endif // CONFIG_STA_SUPPORT //
- // Key length for each key, 0: entry is invalid
- UCHAR Type; // Indicate Pairwise/Group when reporting MIC error
- } CIPHER_KEY, *PCIPHER_KEY;
- // structure to define WPA Group Key Rekey Interval
- typedef struct PACKED _RT_802_11_WPA_REKEY {
- ULONG ReKeyMethod; // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
- ULONG ReKeyInterval; // time-based: seconds, packet-based: kilo-packets
- } RT_WPA_REKEY,*PRT_WPA_REKEY, RT_802_11_WPA_REKEY, *PRT_802_11_WPA_REKEY;
- typedef struct {
- UCHAR Addr[MAC_ADDR_LEN];
- UCHAR 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;
- } ROGUEAP_ENTRY, *PROGUEAP_ENTRY;
- typedef struct {
- UCHAR RogueApNr;
- ROGUEAP_ENTRY RogueApEntry[MAX_LEN_OF_BSS_TABLE];
- } ROGUEAP_TABLE, *PROGUEAP_TABLE;
- //
- // Cisco IAPP format
- //
- typedef struct _CISCO_IAPP_CONTENT_
- {
- USHORT Length; //IAPP Length
- UCHAR MessageType; //IAPP type
- UCHAR FunctionCode; //IAPP function type
- UCHAR DestinaionMAC[MAC_ADDR_LEN];
- UCHAR SourceMAC[MAC_ADDR_LEN];
- USHORT Tag; //Tag(element IE) - Adjacent AP report
- USHORT TagLength; //Length of element not including 4 byte header
- UCHAR OUI[4]; //0x00, 0x40, 0x96, 0x00
- UCHAR PreviousAP[MAC_ADDR_LEN]; //MAC Address of access point
- USHORT Channel;
- USHORT SsidLen;
- UCHAR Ssid[MAX_LEN_OF_SSID];
- USHORT Seconds; //Seconds that the client has been disassociated.
- } CISCO_IAPP_CONTENT, *PCISCO_IAPP_CONTENT;
- /*
- * Fragment Frame structure
- */
- typedef struct _FRAGMENT_FRAME {
- PNDIS_PACKET pFragPacket;
- ULONG RxSize;
- USHORT Sequence;
- USHORT LastFrag;
- ULONG Flags; // Some extra frame information. bit 0: LLC presented
- } FRAGMENT_FRAME, *PFRAGMENT_FRAME;
- //
- // Packet information for NdisQueryPacket
- //
- typedef struct _PACKET_INFO {
- UINT PhysicalBufferCount; // Physical breaks of buffer descripor chained
- UINT BufferCount ; // Number of Buffer descriptor chained
- UINT TotalPacketLength ; // Self explained
- PNDIS_BUFFER pFirstBuffer; // Pointer to first buffer descriptor
- } PACKET_INFO, *PPACKET_INFO;
- //
- // Arcfour Structure Added by PaulWu
- //
- typedef struct _ARCFOUR
- {
- UINT X;
- UINT Y;
- UCHAR STATE[256];
- } ARCFOURCONTEXT, *PARCFOURCONTEXT;
- //
- // Tkip Key structure which RC4 key & MIC calculation
- //
- typedef struct _TKIP_KEY_INFO {
- UINT nBytesInM; // # bytes in M for MICKEY
- ULONG IV16;
- ULONG IV32;
- ULONG K0; // for MICKEY Low
- ULONG K1; // for MICKEY Hig
- ULONG L; // Current state for MICKEY
- ULONG R; // Current state for MICKEY
- ULONG M; // Message accumulator for MICKEY
- UCHAR RC4KEY[16];
- UCHAR MIC[8];
- } TKIP_KEY_INFO, *PTKIP_KEY_INFO;
- //
- // Private / Misc data, counters for driver internal use
- //
- typedef struct __PRIVATE_STRUC {
- UINT SystemResetCnt; // System reset counter
- UINT TxRingFullCnt; // Tx ring full occurrance number
- UINT PhyRxErrCnt; // PHY Rx error count, for debug purpose, might move to global counter
- // Variables for WEP encryption / decryption in rtmp_wep.c
- UINT FCSCRC32;
- ARCFOURCONTEXT WEPCONTEXT;
- // Tkip stuff
- TKIP_KEY_INFO Tx;
- TKIP_KEY_INFO Rx;
- } PRIVATE_STRUC, *PPRIVATE_STRUC;
- /***************************************************************************
- * Channel and BBP related data structures
- **************************************************************************/
- // structure to tune BBP R66 (BBP TUNING)
- typedef struct _BBP_R66_TUNING {
- BOOLEAN bEnable;
- USHORT FalseCcaLowerThreshold; // default 100
- USHORT FalseCcaUpperThreshold; // default 512
- UCHAR R66Delta;
- UCHAR R66CurrentValue;
- BOOLEAN R66LowerUpperSelect; //Before LinkUp, Used LowerBound or UpperBound as R66 value.
- } BBP_R66_TUNING, *PBBP_R66_TUNING;
- // structure to store channel TX power
- typedef struct _CHANNEL_TX_POWER {
- USHORT RemainingTimeForUse; //unit: sec
- UCHAR Channel;
- #ifdef DOT11N_DRAFT3
- BOOLEAN bEffectedChannel; // For BW 40 operating in 2.4GHz , the "effected channel" is the channel that is covered in 40Mhz.
- #endif // DOT11N_DRAFT3 //
- CHAR Power;
- CHAR Power2;
- UCHAR MaxTxPwr;
- UCHAR DfsReq;
- } CHANNEL_TX_POWER, *PCHANNEL_TX_POWER;
- // structure to store 802.11j channel TX power
- typedef struct _CHANNEL_11J_TX_POWER {
- UCHAR Channel;
- UCHAR BW; // BW_10 or BW_20
- CHAR Power;
- CHAR Power2;
- USHORT RemainingTimeForUse; //unit: sec
- } CHANNEL_11J_TX_POWER, *PCHANNEL_11J_TX_POWER;
- typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
- UCHAR EvaluatePeriod; // 0:not evalute status, 1: evaluate status, 2: switching status
- UCHAR EvaluateStableCnt;
- UCHAR Pair1PrimaryRxAnt; // 0:Ant-E1, 1:Ant-E2
- UCHAR Pair1SecondaryRxAnt; // 0:Ant-E1, 1:Ant-E2
- UCHAR Pair2PrimaryRxAnt; // 0:Ant-E3, 1:Ant-E4
- UCHAR Pair2SecondaryRxAnt; // 0:Ant-E3, 1:Ant-E4
- #ifdef CONFIG_STA_SUPPORT
- SHORT Pair1AvgRssi[2]; // AvgRssi[0]:E1, AvgRssi[1]:E2
- SHORT Pair2AvgRssi[2]; // AvgRssi[0]:E3, AvgRssi[1]:E4
- #endif // CONFIG_STA_SUPPORT //
- SHORT Pair1LastAvgRssi; //
- SHORT Pair2LastAvgRssi; //
- ULONG RcvPktNumWhenEvaluate;
- BOOLEAN FirstPktArrivedWhenEvaluate;
- RALINK_TIMER_STRUCT RxAntDiversityTimer;
- } SOFT_RX_ANT_DIVERSITY, *PSOFT_RX_ANT_DIVERSITY;
- /***************************************************************************
- * structure for radar detection and channel switch
- **************************************************************************/
- typedef struct _RADAR_DETECT_STRUCT {
- //BOOLEAN IEEE80211H; // 0: disable, 1: enable IEEE802.11h
- UCHAR CSCount; //Channel switch counter
- UCHAR CSPeriod; //Channel switch period (beacon count)
- UCHAR RDCount; //Radar detection counter
- UCHAR RDMode; //Radar Detection mode
- UCHAR RDDurRegion; //Radar detection duration region
- UCHAR BBPR16;
- UCHAR BBPR17;
- UCHAR BBPR18;
- UCHAR BBPR21;
- UCHAR BBPR22;
- UCHAR BBPR64;
- ULONG InServiceMonitorCount; // unit: sec
- UINT8 DfsSessionTime;
- #ifdef DFS_FCC_BW40_FIX
- CHAR DfsSessionFccOff;
- #endif
- BOOLEAN bFastDfs;
- UINT8 ChMovingTime;
- UINT8 LongPulseRadarTh;
- #ifdef MERGE_ARCH_TEAM
- CHAR AvgRssiReq;
- ULONG DfsLowerLimit;
- ULONG DfsUpperLimit;
- UINT8 FixDfsLimit;
- ULONG upperlimit;
- ULONG lowerlimit;
- #endif // MERGE_ARCH_TEAM //
- } RADAR_DETECT_STRUCT, *PRADAR_DETECT_STRUCT;
- #ifdef CARRIER_DETECTION_SUPPORT
- typedef enum CD_STATE_n
- {
- CD_NORMAL,
- CD_SILENCE,
- CD_MAX_STATE
- } CD_STATE;
- #ifdef TONE_RADAR_DETECT_SUPPORT
- #define CARRIER_DETECT_RECHECK_TIME 3
- #ifdef CARRIER_SENSE_NEW_ALGO
- #define CARRIER_DETECT_CRITIRIA 400
- #define CARRIER_DETECT_STOP_RATIO 0x11
- #define CARRIER_DETECT_STOP_RATIO_OLD_3090 2
- #endif // CARRIER_SENSE_NEW_ALGO //
- #define CARRIER_DETECT_STOP_RECHECK_TIME 4
- #define CARRIER_DETECT_CRITIRIA_A 230
- #define CARRIER_DETECT_DELTA 7
- #define CARRIER_DETECT_DIV_FLAG 0
- #ifdef RT3090
- #define CARRIER_DETECT_THRESHOLD_3090A 0x1fffffff
- #endif // RT3090 //
- #ifdef RT3390
- #define CARRIER_DETECT_THRESHOLD 0x0fffffff
- #endif // RT3390 //
- #ifndef RT3390
- #define CARRIER_DETECT_THRESHOLD 0x0fffffff
- #endif // RT3390 //
- #endif // TONE_RADAR_DETECT_SUPPORT //
- typedef struct CARRIER_DETECTION_s
- {
- BOOLEAN Enable;
- UINT8 CDSessionTime;
- UINT8 CDPeriod;
- CD_STATE CD_State;
- #ifdef TONE_RADAR_DETECT_SUPPORT
- UINT8 delta;
- UINT8 div_flag;
- UINT32 threshold;
- UINT8 recheck;
- UINT8 recheck1;
- UINT8 recheck2;
- UINT32 TimeStamp;
- UINT32 criteria;
- UINT32 CarrierDebug;
- ULONG idle_time;
- ULONG busy_time;
- ULONG Debug;
- #endif // TONE_RADAR_DETECT_SUPPORT //
- }CARRIER_DETECTION_STRUCT, *PCARRIER_DETECTION_STRUCT;
- #endif // CARRIER_DETECTION_SUPPORT //
- #ifdef NEW_DFS
- typedef struct _NewDFSDebug
- {
- UCHAR channel;
- ULONG wait_time;
- UCHAR delta_delay_range;
- UCHAR delta_delay_step;
- UCHAR EL_range;
- UCHAR EL_step;
- UCHAR EH_range;
- UCHAR EH_step;
- UCHAR WL_range;
- UCHAR WL_step;
- UCHAR WH_range;
- UCHAR WH_step;
- ULONG T_expected;
- ULONG T_margin;
- UCHAR start;
- ULONG count;
- ULONG idx;
- }NewDFSDebug, *pNewDFSDebug;
- #define NEW_DFS_FCC_5_ENT_NUM 5
- #define NEW_DFS_DBG_PORT_ENT_NUM_POWER 8
- #define NEW_DFS_DBG_PORT_ENT_NUM (1 << NEW_DFS_DBG_PORT_ENT_NUM_POWER) // CE Debug Port entry number, 256
- #define NEW_DFS_DBG_PORT_MASK 0xff
- // Matched Period definition
- #define NEW_DFS_MPERIOD_ENT_NUM_POWER 8
- #define NEW_DFS_MPERIOD_ENT_NUM (1 << NEW_DFS_MPERIOD_ENT_NUM_POWER) // CE Period Table entry number, 512
- #define NEW_DFS_MAX_CHANNEL 4
- typedef struct _NewDFSDebugPort{
- ULONG counter;
- ULONG timestamp;
- USHORT width;
- USHORT start_idx; // start index to period table
- USHORT end_idx; // end index to period table
- }NewDFSDebugPort, *pNewDFSDebugPort;
- // Matched Period Table
- typedef struct _NewDFSMPeriod{
- USHORT idx;
- USHORT width;
- USHORT idx2;
- USHORT width2;
- ULONG period;
- }NewDFSMPeriod, *pNewDFSMPeriod;
- #endif // NEW_DFS //
- typedef enum _ABGBAND_STATE_ {
- UNKNOWN_BAND,
- BG_BAND,
- A_BAND,
- } ABGBAND_STATE;
- #ifdef RTMP_MAC_PCI
- #ifdef CONFIG_STA_SUPPORT
- // Power save method control
- typedef union _PS_CONTROL {
- struct {
- ULONG EnablePSinIdle:1; // Enable radio off when not connect to AP. radio on only when sitesurvey,
- ULONG EnableNewPS:1; // Enable new Chip power save fucntion . New method can only be applied in chip version after 2872. and PCIe.
- ULONG rt30xxPowerMode:2; // Power Level Mode for rt30xx chip
- ULONG rt30xxFollowHostASPM:1; // Card Follows Host's setting for rt30xx chip.
- ULONG rt30xxForceASPMTest:1; // Force enable L1 for rt30xx chip. This has higher priority than rt30xxFollowHostASPM Mode.
- ULONG rsv:26; // Radio Measurement Enable
- } field;
- ULONG word;
- } PS_CONTROL, *PPS_CONTROL;
- #endif // CONFIG_STA_SUPPORT //
- #endif // RTMP_MAC_PCI //
- /***************************************************************************
- * structure for MLME state machine
- **************************************************************************/
- typedef struct _MLME_STRUCT {
- #ifdef CONFIG_STA_SUPPORT
- // STA state machines
- STATE_MACHINE CntlMachine;
- STATE_MACHINE AssocMachine;
- STATE_MACHINE AuthMachine;
- STATE_MACHINE AuthRspMachine;
- STATE_MACHINE SyncMachine;
- STATE_MACHINE WpaPskMachine;
- STATE_MACHINE LeapMachine;
- STATE_MACHINE_FUNC AssocFunc[ASSOC_FUNC_SIZE];
- STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE];
- STATE_MACHINE_FUNC AuthRspFunc[AUTH_RSP_FUNC_SIZE];
- STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
- #endif // CONFIG_STA_SUPPORT //
- STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
- // Action
- STATE_MACHINE ActMachine;
- #ifdef QOS_DLS_SUPPORT
- STATE_MACHINE DlsMachine;
- STATE_MACHINE_FUNC DlsFunc[DLS_FUNC_SIZE];
- #endif // QOS_DLS_SUPPORT //
- // common WPA state machine
- STATE_MACHINE WpaMachine;
- STATE_MACHINE_FUNC WpaFunc[WPA_FUNC_SIZE];
- ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
- ULONG Now32; // latch the value of NdisGetSystemUpTime()
- ULONG LastSendNULLpsmTime;
- BOOLEAN bRunning;
- NDIS_SPIN_LOCK TaskLock;
- MLME_QUEUE Queue;
- UINT ShiftReg;
- RALINK_TIMER_STRUCT PeriodicTimer;
- RALINK_TIMER_STRUCT APSDPeriodicTimer;
- RALINK_TIMER_STRUCT LinkDownTimer;
- RALINK_TIMER_STRUCT LinkUpTimer;
- #ifdef RTMP_MAC_PCI
- UCHAR bPsPollTimerRunning;
- RALINK_TIMER_STRUCT PsPollTimer;
- RALINK_TIMER_STRUCT RadioOnOffTimer;
- #endif // RTMP_MAC_PCI //
- ULONG PeriodicRound;
- ULONG OneSecPeriodicRound;
- UCHAR RealRxPath;
- BOOLEAN bLowThroughput;
- BOOLEAN bEnableAutoAntennaCheck;
- RALINK_TIMER_STRUCT RxAntEvalTimer;
- #ifdef RT30xx
- UCHAR CaliBW40RfR24;
- UCHAR CaliBW20RfR24;
- #endif // RT30xx //
- } MLME_STRUCT, *PMLME_STRUCT;
- #ifdef DOT11_N_SUPPORT
- /***************************************************************************
- * 802.11 N related data structures
- **************************************************************************/
- struct reordering_mpdu
- {
- struct reordering_mpdu *next;
- PNDIS_PACKET pPacket; /* coverted to 802.3 frame */
- int Sequence; /* sequence number of MPDU */
- BOOLEAN bAMSDU;
- };
- struct reordering_list
- {
- struct reordering_mpdu *next;
- int qlen;
- };
- struct reordering_mpdu_pool
- {
- PVOID mem;
- NDIS_SPIN_LOCK lock;
- struct reordering_list freelist;
- };
- typedef enum _REC_BLOCKACK_STATUS
- {
- Recipient_NONE=0,
- Recipient_USED,
- Recipient_HandleRes,
- Recipient_Accept
- } REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
- typedef enum _ORI_BLOCKACK_STATUS
- {
- Originator_NONE=0,
- Originator_USED,
- Originator_WaitRes,
- Originator_Done
- } ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
- typedef struct _BA_ORI_ENTRY{
- UCHAR Wcid;
- UCHAR TID;
- UCHAR BAWinSize;
- UCHAR Token;
- // Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header.
- USHORT Sequence;
- USHORT TimeOutValue;
- ORI_BLOCKACK_STATUS ORI_BA_Status;
- RALINK_TIMER_STRUCT ORIBATimer;
- PVOID pAdapter;
- } BA_ORI_ENTRY, *PBA_ORI_ENTRY;
- typedef struct _BA_REC_ENTRY {
- UCHAR Wcid;
- UCHAR TID;
- UCHAR BAWinSize; // 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU.
- //UCHAR NumOfRxPkt;
- //UCHAR Curindidx; // the head in the RX reordering buffer
- USHORT LastIndSeq;
- // USHORT LastIndSeqAtTimer;
- USHORT TimeOutValue;
- RALINK_TIMER_STRUCT RECBATimer;
- ULONG LastIndSeqAtTimer;
- ULONG nDropPacket;
- ULONG rcvSeq;
- REC_BLOCKACK_STATUS REC_BA_Status;
- // UCHAR RxBufIdxUsed;
- // corresponding virtual address for RX reordering packet storage.
- //RTMP_REORDERDMABUF MAP_RXBuf[MAX_RX_REORDERBUF];
- NDIS_SPIN_LOCK RxReRingLock; // Rx Ring spinlock
- // struct _BA_REC_ENTRY *pNext;
- PVOID pAdapter;
- struct reordering_list list;
- } BA_REC_ENTRY, *PBA_REC_ENTRY;
- typedef struct {
- ULONG numAsRecipient; // I am recipient of numAsRecipient clients. These client are in the BARecEntry[]
- ULONG numAsOriginator; // I am originator of numAsOriginator clients. These clients are in the BAOriEntry[]
- ULONG numDoneOriginator; // count Done Originator sessions
- BA_ORI_ENTRY BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
- BA_REC_ENTRY BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
- } BA_TABLE, *PBA_TABLE;
- //For QureyBATableOID use;
- typedef struct PACKED _OID_BA_REC_ENTRY{
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize
- UCHAR rsv;
- UCHAR BufSize[8];
- REC_BLOCKACK_STATUS REC_BA_Status[8];
- } OID_BA_REC_ENTRY, *POID_BA_REC_ENTRY;
- //For QureyBATableOID use;
- typedef struct PACKED _OID_BA_ORI_ENTRY{
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status
- UCHAR rsv;
- UCHAR BufSize[8];
- ORI_BLOCKACK_STATUS ORI_BA_Status[8];
- } OID_BA_ORI_ENTRY, *POID_BA_ORI_ENTRY;
- typedef struct _QUERYBA_TABLE{
- OID_BA_ORI_ENTRY BAOriEntry[32];
- OID_BA_REC_ENTRY BARecEntry[32];
- UCHAR OriNum;// Number of below BAOriEntry
- UCHAR RecNum;// Number of below BARecEntry
- } QUERYBA_TABLE, *PQUERYBA_TABLE;
- typedef union _BACAP_STRUC {
- #ifdef RT_BIG_ENDIAN
- struct {
- UINT32 :4;
- UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
- UINT32 bHtAdhoc:1; // adhoc can use ht rate.
- UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
- UINT32 MpduDensity:3;
- UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
- UINT32 AutoBA:1; // automatically BA
- UINT32 TxBAWinLimit:8;
- UINT32 RxBAWinLimit:8;
- } field;
- #else
- struct {
- UINT32 RxBAWinLimit:8;
- UINT32 TxBAWinLimit:8;
- UINT32 AutoBA:1; // automatically BA
- UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
- UINT32 MpduDensity:3;
- UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
- UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- UINT32 bHtAdhoc:1; // adhoc can use ht rate.
- UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
- UINT32 :4;
- } field;
- #endif
- UINT32 word;
- } BACAP_STRUC, *PBACAP_STRUC;
- typedef struct {
- BOOLEAN IsRecipient;
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR TID;
- UCHAR nMSDU;
- USHORT TimeOut;
- BOOLEAN bAllTid; // If True, delete all TID for BA sessions with this MACaddr.
- } OID_ADD_BA_ENTRY, *POID_ADD_BA_ENTRY;
- #ifdef DOT11N_DRAFT3
- typedef enum _BSS2040COEXIST_FLAG{
- BSS_2040_COEXIST_DISABLE = 0,
- BSS_2040_COEXIST_TIMER_FIRED = 1,
- BSS_2040_COEXIST_INFO_SYNC = 2,
- BSS_2040_COEXIST_INFO_NOTIFY = 4,
- }BSS2040COEXIST_FLAG;
- #endif // DOT11N_DRAFT3 //
- #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)
- #endif // DOT11_N_SUPPORT //
- //This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic)
- typedef struct _IOT_STRUC {
- UCHAR Threshold[2];
- UCHAR ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[0]
- UCHAR RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[1]
- ULONG OneSecInWindowCount;
- ULONG OneSecFrameDuplicateCount;
- ULONG OneSecOutWindowCount;
- UCHAR DelOriAct;
- UCHAR DelRecAct;
- UCHAR RTSShortProt;
- UCHAR RTSLongProt;
- BOOLEAN bRTSLongProtOn;
- #ifdef CONFIG_STA_SUPPORT
- BOOLEAN bLastAtheros;
- BOOLEAN bCurrentAtheros;
- BOOLEAN bNowAtherosBurstOn;
- BOOLEAN bNextDisableRxBA;
- BOOLEAN bToggle;
- #endif // CONFIG_STA_SUPPORT //
- } IOT_STRUC, *PIOT_STRUC;
- // This is the registry setting for 802.11n transmit setting. Used in advanced page.
- typedef union _REG_TRANSMIT_SETTING {
- #ifdef RT_BIG_ENDIAN
- struct {
- UINT32 rsv:13;
- UINT32 EXTCHA:2;
- UINT32 HTMODE:1;
- UINT32 TRANSNO:2;
- UINT32 STBC:1; //SPACE
- UINT32 ShortGI:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 TxBF:1; // 3*3
- UINT32 rsv0:10;
- //UINT32 MCS:7; // MCS
- //UINT32 PhyMode:4;
- } field;
- #else
- struct {
- //UINT32 PhyMode:4;
- //UINT32 MCS:7; // MCS
- UINT32 rsv0:10;
- UINT32 TxBF:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 STBC:1; //SPACE
- UINT32 TRANSNO:2;
- UINT32 HTMODE:1;
- UINT32 EXTCHA:2;
- UINT32 rsv:13;
- } field;
- #endif
- UINT32 word;
- } REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
- typedef union _DESIRED_TRANSMIT_SETTING {
- #ifdef RT_BI…