Commit 3fb468ab authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Greg Kroah-Hartman

Staging: rt28[67]0: merge rt28[67]0/*.[ch]

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3a32ed12
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
aironet.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Paul Lin 04-06-15 Initial
*/
#ifndef __AIRONET_H__
#define __AIRONET_H__
// Measurement Type definition
#define MSRN_TYPE_UNUSED 0
#define MSRN_TYPE_CHANNEL_LOAD_REQ 1
#define MSRN_TYPE_NOISE_HIST_REQ 2
#define MSRN_TYPE_BEACON_REQ 3
#define MSRN_TYPE_FRAME_REQ 4
// Scan Mode in Beacon Request
#define MSRN_SCAN_MODE_PASSIVE 0
#define MSRN_SCAN_MODE_ACTIVE 1
#define MSRN_SCAN_MODE_BEACON_TABLE 2
// PHY type definition for Aironet beacon report, CCX 2 table 36-9
#define PHY_FH 1
#define PHY_DSS 2
#define PHY_UNUSED 3
#define PHY_OFDM 4
#define PHY_HR_DSS 5
#define PHY_ERP 6
// RPI table in dBm
#define RPI_0 0 // Power <= -87
#define RPI_1 1 // -87 < Power <= -82
#define RPI_2 2 // -82 < Power <= -77
#define RPI_3 3 // -77 < Power <= -72
#define RPI_4 4 // -72 < Power <= -67
#define RPI_5 5 // -67 < Power <= -62
#define RPI_6 6 // -62 < Power <= -57
#define RPI_7 7 // -57 < Power
// Cisco Aironet IAPP definetions
#define AIRONET_IAPP_TYPE 0x32
#define AIRONET_IAPP_SUBTYPE_REQUEST 0x01
#define AIRONET_IAPP_SUBTYPE_REPORT 0x81
// Measurement Request detail format
typedef struct _MEASUREMENT_REQUEST {
UCHAR Channel;
UCHAR ScanMode; // Use only in beacon request, other requests did not use this field
USHORT Duration;
} MEASUREMENT_REQUEST, *PMEASUREMENT_REQUEST;
// Beacon Measurement Report
// All these field might change to UCHAR, because we didn't do anything to these report.
// We copy all these beacons and report to CCX 2 AP.
typedef struct _BEACON_REPORT {
UCHAR Channel;
UCHAR Spare;
USHORT Duration;
UCHAR PhyType; // Definiation is listed above table 36-9
UCHAR RxPower;
UCHAR BSSID[6];
UCHAR ParentTSF[4];
UCHAR TargetTSF[8];
USHORT BeaconInterval;
USHORT CapabilityInfo;
} BEACON_REPORT, *PBEACON_REPORT;
// Frame Measurement Report (Optional)
typedef struct _FRAME_REPORT {
UCHAR Channel;
UCHAR Spare;
USHORT Duration;
UCHAR TA;
UCHAR BSSID[6];
UCHAR RSSI;
UCHAR Count;
} FRAME_REPORT, *PFRAME_REPORT;
#pragma pack(1)
// Channel Load Report
typedef struct _CHANNEL_LOAD_REPORT {
UCHAR Channel;
UCHAR Spare;
USHORT Duration;
UCHAR CCABusy;
} CHANNEL_LOAD_REPORT, *PCHANNEL_LOAD_REPORT;
#pragma pack()
// Nosie Histogram Report
typedef struct _NOISE_HIST_REPORT {
UCHAR Channel;
UCHAR Spare;
USHORT Duration;
UCHAR Density[8];
} NOISE_HIST_REPORT, *PNOISE_HIST_REPORT;
// Radio Management Capability element
typedef struct _RADIO_MANAGEMENT_CAPABILITY {
UCHAR Eid; // TODO: Why the Eid is 1 byte, not normal 2 bytes???
UCHAR Length;
UCHAR AironetOui[3]; // AIronet OUI (00 40 96)
UCHAR Type; // Type / Version
USHORT Status; // swap16 required
} RADIO_MANAGEMENT_CAPABILITY, *PRADIO_MANAGEMENT_CAPABILITY;
// Measurement Mode Bit definition
typedef struct _MEASUREMENT_MODE {
UCHAR Rsvd:4;
UCHAR Report:1;
UCHAR NotUsed:1;
UCHAR Enable:1;
UCHAR Parallel:1;
} MEASUREMENT_MODE, *PMEASUREMENT_MODE;
// Measurement Request element, This is little endian mode
typedef struct _MEASUREMENT_REQUEST_ELEMENT {
USHORT Eid;
USHORT Length; // swap16 required
USHORT Token; // non-zero unique token
UCHAR Mode; // Measurement Mode
UCHAR Type; // Measurement type
} MEASUREMENT_REQUEST_ELEMENT, *PMEASUREMENT_REQUEST_ELEMENT;
// Measurement Report element, This is little endian mode
typedef struct _MEASUREMENT_REPORT_ELEMENT {
USHORT Eid;
USHORT Length; // swap16 required
USHORT Token; // non-zero unique token
UCHAR Mode; // Measurement Mode
UCHAR Type; // Measurement type
} MEASUREMENT_REPORT_ELEMENT, *PMEASUREMENT_REPORT_ELEMENT;
// Cisco Aironet IAPP Frame Header, Network byte order used
typedef struct _AIRONET_IAPP_HEADER {
UCHAR CiscoSnapHeader[8]; // 8 bytes Cisco snap header
USHORT Length; // IAPP ID & length, remember to swap16 in LE system
UCHAR Type; // IAPP type
UCHAR SubType; // IAPP subtype
UCHAR DA[6]; // Destination MAC address
UCHAR SA[6]; // Source MAC address
USHORT Token; // Dialog token, no need to swap16 since it is for yoken usage only
} AIRONET_IAPP_HEADER, *PAIRONET_IAPP_HEADER;
// Radio Measurement Request frame
typedef struct _AIRONET_RM_REQUEST_FRAME {
AIRONET_IAPP_HEADER IAPP; // Common header
UCHAR Delay; // Activation Delay
UCHAR Offset; // Measurement offset
} AIRONET_RM_REQUEST_FRAME, *PAIRONET_RM_REQUEST_FRAME;
// Radio Measurement Report frame
typedef struct _AIRONET_RM_REPORT_FRAME {
AIRONET_IAPP_HEADER IAPP; // Common header
} AIRONET_RM_REPORT_FRAME, *PAIRONET_RM_REPORT_FRAME;
// Saved element request actions which will saved in StaCfg.
typedef struct _RM_REQUEST_ACTION {
MEASUREMENT_REQUEST_ELEMENT ReqElem; // Saved request element
MEASUREMENT_REQUEST Measurement; // Saved measurement within the request element
} RM_REQUEST_ACTION, *PRM_REQUEST_ACTION;
// CCX administration control
typedef union _CCX_CONTROL {
struct {
UINT32 Enable:1; // Enable CCX2
UINT32 LeapEnable:1; // Enable LEAP at CCX2
UINT32 RMEnable:1; // Radio Measurement Enable
UINT32 DCRMEnable:1; // Non serving channel Radio Measurement enable
UINT32 QOSEnable:1; // Enable QOS for CCX 2.0 support
UINT32 FastRoamEnable:1; // Enable fast roaming
UINT32 Rsvd:2; // Not used
UINT32 dBmToRoam:8; // the condition to roam when receiving Rssi less than this value. It's negative value.
UINT32 TuLimit:16; // Limit for different channel scan
} field;
UINT32 word;
} CCX_CONTROL, *PCCX_CONTROL;
#endif // __AIRONET_H__
#include "../rt2860/aironet.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
ap.h
Abstract:
Miniport generic portion header file
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Lin 08-01-2002 created
James Tan 09-06-2002 modified (Revise NTCRegTable)
John Chang 12-22-2004 modified for RT2561/2661. merge with STA driver
*/
#ifndef __AP_H__
#define __AP_H__
// ========================= AP RTMP.h ================================
// =============================================================
// Function Prototypes
// =============================================================
// ap_data.c
BOOLEAN APBridgeToWirelessSta(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pHeader,
IN UINT HdrLen,
IN PUCHAR pData,
IN UINT DataLen,
IN ULONG fromwdsidx);
BOOLEAN APHandleRxDoneInterrupt(
IN PRTMP_ADAPTER pAd);
VOID APSendPackets(
IN NDIS_HANDLE MiniportAdapterContext,
IN PPNDIS_PACKET ppPacketArray,
IN UINT NumberOfPackets);
NDIS_STATUS APSendPacket(
IN PRTMP_ADAPTER pAd,
IN PNDIS_PACKET pPacket);
NDIS_STATUS APHardTransmit(
IN PRTMP_ADAPTER pAd,
IN TX_BLK *pTxBlk,
IN UCHAR QueIdx);
VOID APRxEAPOLFrameIndicate(
IN PRTMP_ADAPTER pAd,
IN MAC_TABLE_ENTRY *pEntry,
IN RX_BLK *pRxBlk,
IN UCHAR FromWhichBSSID);
NDIS_STATUS APCheckRxError(
IN PRTMP_ADAPTER pAd,
IN PRT28XX_RXD_STRUC pRxD,
IN UCHAR Wcid);
BOOLEAN APCheckClass2Class3Error(
IN PRTMP_ADAPTER pAd,
IN ULONG Wcid,
IN PHEADER_802_11 pHeader);
VOID APHandleRxPsPoll(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN USHORT Aid,
IN BOOLEAN isActive);
VOID RTMPDescriptorEndianChange(
IN PUCHAR pData,
IN ULONG DescriptorType);
VOID RTMPFrameEndianChange(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pData,
IN ULONG Dir,
IN BOOLEAN FromRxDoneInt);
// ap_assoc.c
VOID APAssocStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *S,
OUT STATE_MACHINE_FUNC Trans[]);
VOID APPeerAssocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APPeerReassocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APPeerDisassocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID MbssKickOutStas(
IN PRTMP_ADAPTER pAd,
IN INT apidx,
IN USHORT Reason);
VOID APMlmeKickOutSta(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pStaAddr,
IN UCHAR Wcid,
IN USHORT Reason);
VOID APMlmeDisassocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APCls3errAction(
IN PRTMP_ADAPTER pAd,
IN ULONG Wcid,
IN PHEADER_802_11 pHeader);
USHORT APBuildAssociation(
IN PRTMP_ADAPTER pAd,
IN MAC_TABLE_ENTRY *pEntry,
IN USHORT CapabilityInfo,
IN UCHAR MaxSupportedRateIn500Kbps,
IN UCHAR *RSN,
IN UCHAR *pRSNLen,
IN BOOLEAN bWmmCapable,
IN ULONG RalinkIe,
IN HT_CAPABILITY_IE *pHtCapability,
IN UCHAR HtCapabilityLen,
OUT USHORT *pAid);
// ap_auth.c
void APAuthStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *Sm,
OUT STATE_MACHINE_FUNC Trans[]);
VOID APMlmeDeauthReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APCls2errAction(
IN PRTMP_ADAPTER pAd,
IN ULONG Wcid,
IN PHEADER_802_11 pHeader);
// ap_authrsp.c
VOID APAuthRspStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN PSTATE_MACHINE Sm,
IN STATE_MACHINE_FUNC Trans[]);
VOID APPeerAuthAtAuthRspIdleAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APPeerDeauthReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APPeerAuthSimpleRspGenAndSend(
IN PRTMP_ADAPTER pAd,
IN PHEADER_802_11 pHdr80211,
IN USHORT Alg,
IN USHORT Seq,
IN USHORT StatusCode);
// ap_connect.c
BOOLEAN BeaconTransmitRequired(
IN PRTMP_ADAPTER pAd,
IN INT apidx);
VOID APMakeBssBeacon(
IN PRTMP_ADAPTER pAd,
IN INT apidx);
VOID APUpdateBeaconFrame(
IN PRTMP_ADAPTER pAd,
IN INT apidx);
VOID APMakeAllBssBeacon(
IN PRTMP_ADAPTER pAd);
VOID APUpdateAllBeaconFrame(
IN PRTMP_ADAPTER pAd);
// ap_sync.c
VOID APSyncStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *Sm,
OUT STATE_MACHINE_FUNC Trans[]);
VOID APScanTimeout(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
VOID APInvalidStateWhenScan(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APScanTimeoutAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APPeerProbeReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APPeerBeaconAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APMlmeScanReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APPeerBeaconAtScanAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID APScanCnclAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
VOID ApSiteSurvey(
IN PRTMP_ADAPTER pAd);
VOID SupportRate(
IN PUCHAR SupRate,
IN UCHAR SupRateLen,
IN PUCHAR ExtRate,
IN UCHAR ExtRateLen,
OUT PUCHAR *Rates,
OUT PUCHAR RatesLen,
OUT PUCHAR pMaxSupportRate);
BOOLEAN ApScanRunning(
IN PRTMP_ADAPTER pAd);
// ap_wpa.c
VOID APWpaStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *Sm,
OUT STATE_MACHINE_FUNC Trans[]);
// ap_mlme.c
VOID APMlmePeriodicExec(
IN PRTMP_ADAPTER pAd);
VOID APMlmeSelectTxRateTable(
IN PRTMP_ADAPTER pAd,
IN PMAC_TABLE_ENTRY pEntry,
IN PUCHAR *ppTable,
IN PUCHAR pTableSize,
IN PUCHAR pInitTxRateIdx);
VOID APMlmeSetTxRate(
IN PRTMP_ADAPTER pAd,
IN PMAC_TABLE_ENTRY pEntry,
IN PRTMP_TX_RATE_SWITCH pTxRate);
VOID APMlmeDynamicTxRateSwitching(
IN PRTMP_ADAPTER pAd);
VOID APQuickResponeForRateUpExec(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
BOOLEAN APMsgTypeSubst(
IN PRTMP_ADAPTER pAd,
IN PFRAME_802_11 pFrame,
OUT INT *Machine,
OUT INT *MsgType);
VOID APQuickResponeForRateUpExec(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
#ifdef RT2870
VOID BeaconUpdateExec(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
#endif // RT2870 //
VOID RTMPSetPiggyBack(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN bPiggyBack);
VOID APAsicEvaluateRxAnt(
IN PRTMP_ADAPTER pAd);
VOID APAsicRxAntEvalTimeout(
IN PRTMP_ADAPTER pAd);
// ap.c
VOID APSwitchChannel(
IN PRTMP_ADAPTER pAd,
IN INT Channel);
NDIS_STATUS APInitialize(
IN PRTMP_ADAPTER pAd);
VOID APShutdown(
IN PRTMP_ADAPTER pAd);
VOID APStartUp(
IN PRTMP_ADAPTER pAd);
VOID APStop(
IN PRTMP_ADAPTER pAd);
VOID APCleanupPsQueue(
IN PRTMP_ADAPTER pAd,
IN PQUEUE_HEADER pQueue);
VOID MacTableReset(
IN PRTMP_ADAPTER pAd);
MAC_TABLE_ENTRY *MacTableInsertEntry(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN UCHAR apidx,
IN BOOLEAN CleanAll);
BOOLEAN MacTableDeleteEntry(
IN PRTMP_ADAPTER pAd,
IN USHORT wcid,
IN PUCHAR pAddr);
MAC_TABLE_ENTRY *MacTableLookup(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr);
VOID MacTableMaintenance(
IN PRTMP_ADAPTER pAd);
UINT32 MacTableAssocStaNumGet(
IN PRTMP_ADAPTER pAd);
MAC_TABLE_ENTRY *APSsPsInquiry(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
OUT SST *Sst,
OUT USHORT *Aid,
OUT UCHAR *PsMode,
OUT UCHAR *Rate);
BOOLEAN APPsIndicate(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN ULONG Wcid,
IN UCHAR Psm);
VOID ApLogEvent(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN USHORT Event);
VOID APUpdateOperationMode(
IN PRTMP_ADAPTER pAd);
VOID APUpdateCapabilityAndErpIe(
IN PRTMP_ADAPTER pAd);
BOOLEAN ApCheckAccessControlList(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN UCHAR Apidx);
VOID ApUpdateAccessControlList(
IN PRTMP_ADAPTER pAd,
IN UCHAR Apidx);
VOID ApEnqueueNullFrame(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN UCHAR TxRate,
IN UCHAR PID,
IN UCHAR apidx,
IN BOOLEAN bQosNull,
IN BOOLEAN bEOSP,
IN UCHAR OldUP);
VOID ApSendFrame(
IN PRTMP_ADAPTER pAd,
IN PVOID pBuffer,
IN ULONG Length,
IN UCHAR TxRate,
IN UCHAR PID);
VOID ApEnqueueAckFrame(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN UCHAR TxRate,
IN UCHAR apidx);
UCHAR APAutoSelectChannel(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN Optimal);
// ap_sanity.c
BOOLEAN PeerAssocReqCmmSanity(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN isRessoc,
IN VOID *Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT USHORT *pCapabilityInfo,
OUT USHORT *pListenInterval,
OUT PUCHAR pApAddr,
OUT UCHAR *pSsidLen,
OUT char *Ssid,
OUT UCHAR *pRatesLen,
OUT UCHAR Rates[],
OUT UCHAR *RSN,
OUT UCHAR *pRSNLen,
OUT BOOLEAN *pbWmmCapable,
OUT ULONG *pRalinkIe,
OUT UCHAR *pHtCapabilityLen,
OUT HT_CAPABILITY_IE *pHtCapability);
BOOLEAN PeerDisassocReqSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT USHORT *Reason);
BOOLEAN PeerDeauthReqSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT USHORT *Reason);
BOOLEAN APPeerAuthSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr1,
OUT PUCHAR pAddr2,
OUT USHORT *Alg,
OUT USHORT *Seq,
OUT USHORT *Status,
CHAR *ChlgText);
BOOLEAN APPeerProbeReqSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT CHAR Ssid[],
OUT UCHAR *SsidLen);
BOOLEAN APPeerBeaconAndProbeRspSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT PUCHAR pBssid,
OUT CHAR Ssid[],
OUT UCHAR *SsidLen,
OUT UCHAR *BssType,
OUT USHORT *BeaconPeriod,
OUT UCHAR *Channel,
OUT LARGE_INTEGER *Timestamp,
OUT USHORT *CapabilityInfo,
OUT UCHAR Rate[],
OUT UCHAR *RateLen,
OUT BOOLEAN *ExtendedRateIeExist,
OUT UCHAR *Erp);
// ================== end of AP RTMP.h ========================
#endif // __AP_H__
#include "../rt2860/ap.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
chlist.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Fonchi Wu 2007-12-19 created
*/
#ifndef __CHLIST_H__
#define __CHLIST_H__
#include "rtmp_type.h"
#include "rtmp_def.h"
#define ODOR 0
#define IDOR 1
#define BOTH 2
#define BAND_5G 0
#define BAND_24G 1
#define BAND_BOTH 2
typedef struct _CH_DESP {
UCHAR FirstChannel;
UCHAR NumOfCh;
CHAR MaxTxPwr; // dBm
UCHAR Geography; // 0:out door, 1:in door, 2:both
BOOLEAN DfsReq; // Dfs require, 0: No, 1: yes.
} CH_DESP, *PCH_DESP;
typedef struct _CH_REGION {
UCHAR CountReg[3];
UCHAR DfsType; // 0: CE, 1: FCC, 2: JAP, 3:JAP_W53, JAP_W56
CH_DESP ChDesp[10];
} CH_REGION, *PCH_REGION;
static CH_REGION ChRegion[] =
{
{ // Antigua and Berbuda
"AG",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Argentina
"AR",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Aruba
"AW",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Australia
"AU",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Austria
"AT",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Bahamas
"BS",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Barbados
"BB",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Bermuda
"BM",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Brazil
"BR",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 24, BOTH, FALSE}, // 5G, ch 100~140
{ 149, 5, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Belgium
"BE",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 18, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 18, IDOR, FALSE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // Bulgaria
"BG",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Canada
"CA",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Cayman IsLands
"KY",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Chile
"CL",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // China
"CN",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Colombia
"CO",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Costa Rica
"CR",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Cyprus
"CY",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Czech_Republic
"CZ",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // Denmark
"DK",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Dominican Republic
"DO",
CE,
{
{ 1, 0, 20, BOTH, FALSE}, // 2.4 G, ch 0
{ 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Equador
"EC",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 100, 11, 27, BOTH, FALSE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // El Salvador
"SV",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 30, BOTH, TRUE}, // 5G, ch 52~64
{ 149, 4, 36, BOTH, TRUE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Finland
"FI",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // France
"FR",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // Germany
"DE",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Greece
"GR",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Guam
"GU",
CE,
{
{ 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
{ 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Guatemala
"GT",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Haiti
"HT",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Honduras
"HN",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Hong Kong
"HK",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
{ 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Hungary
"HU",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // Iceland
"IS",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // India
"IN",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 149, 4, 24, IDOR, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Indonesia
"ID",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Ireland
"IE",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Israel
"IL",
CE,
{
{ 1, 3, 20, IDOR, FALSE}, // 2.4 G, ch 1~3
{ 4, 6, 20, BOTH, FALSE}, // 2.4 G, ch 4~9
{ 10, 4, 20, IDOR, FALSE}, // 2.4 G, ch 10~13
{ 0}, // end
}
},
{ // Italy
"IT",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Japan
"JP",
JAP,
{
{ 1, 14, 20, BOTH, FALSE}, // 2.4 G, ch 1~14
#ifndef RT30xx
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
#endif
#ifdef RT30xx
{ 34, 4, 23, IDOR, FALSE}, // 5G, ch 34~46
#endif
{ 0}, // end
}
},
{ // Jordan
"JO",
CE,
{
{ 1, 13, 20, IDOR, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 149, 4, 23, IDOR, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Latvia
"LV",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Liechtenstein
"LI",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Lithuania
"LT",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Luxemburg
"LU",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Malaysia
"MY",
CE,
{
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Malta
"MT",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Marocco
"MA",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
{ 0}, // end
}
},
{ // Mexico
"MX",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 5, 30, IDOR, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Netherlands
"NL",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // New Zealand
"NZ",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 24, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Norway
"NO",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Peru
"PE",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Portugal
"PT",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Poland
"PL",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Romania
"RO",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Russia
"RU",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 149, 4, 20, IDOR, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Saudi Arabia
"SA",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 4, 23, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Serbia_and_Montenegro
"CS",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 0}, // end
}
},
{ // Singapore
"SG",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
{ 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Slovakia
"SK",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Slovenia
"SI",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // South Africa
"ZA",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // South Korea
"KR",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 8, 20, BOTH, FALSE}, // 5G, ch 100~128
{ 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Spain
"ES",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 17, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Sweden
"SE",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Switzerland
"CH",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
{ 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // Taiwan
"TW",
CE,
{
{ 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // Turkey
"TR",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
{ 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
{ 0}, // end
}
},
{ // UK
"GB",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
{ 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 0}, // end
}
},
{ // Ukraine
"UA",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 0}, // end
}
},
{ // United_Arab_Emirates
"AE",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 0}, // end
}
},
{ // United_States
"US",
CE,
{
{ 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 36, 4, 17, IDOR, FALSE}, // 5G, ch 52~64
{ 52, 4, 24, BOTH, TRUE}, // 5G, ch 52~64
{ 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
{ 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
{ // Venezuela
"VE",
CE,
{
{ 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
{ 0}, // end
}
},
{ // Default
"",
CE,
{
{ 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
{ 36, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
{ 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
{ 100, 11, 20, BOTH, FALSE}, // 5G, ch 100~140
{ 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
{ 0}, // end
}
},
};
static inline PCH_REGION GetChRegion(
IN PUCHAR CntryCode)
{
INT loop = 0;
PCH_REGION pChRegion = NULL;
while (strcmp(ChRegion[loop].CountReg, "") != 0)
{
if (strncmp(ChRegion[loop].CountReg, CntryCode, 2) == 0)
{
pChRegion = &ChRegion[loop];
break;
}
loop++;
}
if (pChRegion == NULL)
pChRegion = &ChRegion[loop];
return pChRegion;
}
static inline VOID ChBandCheck(
IN UCHAR PhyMode,
OUT PUCHAR pChType)
{
switch(PhyMode)
{
case PHY_11A:
case PHY_11AN_MIXED:
*pChType = BAND_5G;
break;
case PHY_11ABG_MIXED:
case PHY_11AGN_MIXED:
case PHY_11ABGN_MIXED:
*pChType = BAND_BOTH;
break;
default:
*pChType = BAND_24G;
break;
}
}
static inline UCHAR FillChList(
IN PRTMP_ADAPTER pAd,
IN PCH_DESP pChDesp,
IN UCHAR Offset,
IN UCHAR increment)
{
INT i, j, l;
UCHAR channel;
j = Offset;
for (i = 0; i < pChDesp->NumOfCh; i++)
{
channel = pChDesp->FirstChannel + i * increment;
for (l=0; l<MAX_NUM_OF_CHANNELS; l++)
{
if (channel == pAd->TxPower[l].Channel)
{
pAd->ChannelList[j].Power = pAd->TxPower[l].Power;
pAd->ChannelList[j].Power2 = pAd->TxPower[l].Power2;
break;
}
}
if (l == MAX_NUM_OF_CHANNELS)
continue;
pAd->ChannelList[j].Channel = pChDesp->FirstChannel + i * increment;
pAd->ChannelList[j].MaxTxPwr = pChDesp->MaxTxPwr;
pAd->ChannelList[j].DfsReq = pChDesp->DfsReq;
j++;
}
pAd->ChannelListNum = j;
return j;
}
static inline VOID CreateChList(
IN PRTMP_ADAPTER pAd,
IN PCH_REGION pChRegion,
IN UCHAR Geography)
{
INT i;
UCHAR offset = 0;
PCH_DESP pChDesp;
UCHAR ChType;
UCHAR increment;
if (pChRegion == NULL)
return;
ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
for (i=0; i<10; i++)
{
pChDesp = &pChRegion->ChDesp[i];
if (pChDesp->FirstChannel == 0)
break;
if (ChType == BAND_5G)
{
if (pChDesp->FirstChannel <= 14)
continue;
}
else if (ChType == BAND_24G)
{
if (pChDesp->FirstChannel > 14)
continue;
}
if ((pChDesp->Geography == BOTH)
|| (pChDesp->Geography == Geography))
{
if (pChDesp->FirstChannel > 14)
increment = 4;
else
increment = 1;
offset = FillChList(pAd, pChDesp, offset, increment);
}
}
}
static inline VOID BuildChannelListEx(
IN PRTMP_ADAPTER pAd)
{
PCH_REGION pChReg;
pChReg = GetChRegion(pAd->CommonCfg.CountryCode);
CreateChList(pAd, pChReg, pAd->CommonCfg.Geography);
}
static inline VOID BuildBeaconChList(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf,
OUT PULONG pBufLen)
{
INT i;
ULONG TmpLen;
PCH_REGION pChRegion;
PCH_DESP pChDesp;
UCHAR ChType;
pChRegion = GetChRegion(pAd->CommonCfg.CountryCode);
if (pChRegion == NULL)
return;
ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
*pBufLen = 0;
for (i=0; i<10; i++)
{
pChDesp = &pChRegion->ChDesp[i];
if (pChDesp->FirstChannel == 0)
break;
if (ChType == BAND_5G)
{
if (pChDesp->FirstChannel <= 14)
continue;
}
else if (ChType == BAND_24G)
{
if (pChDesp->FirstChannel > 14)
continue;
}
if ((pChDesp->Geography == BOTH)
|| (pChDesp->Geography == pAd->CommonCfg.Geography))
{
MakeOutgoingFrame(pBuf + *pBufLen, &TmpLen,
1, &pChDesp->FirstChannel,
1, &pChDesp->NumOfCh,
1, &pChDesp->MaxTxPwr,
END_OF_ARGS);
*pBufLen += TmpLen;
}
}
}
static inline BOOLEAN IsValidChannel(
IN PRTMP_ADAPTER pAd,
IN UCHAR channel)
{
INT i;
for (i = 0; i < pAd->ChannelListNum; i++)
{
if (pAd->ChannelList[i].Channel == channel)
break;
}
if (i == pAd->ChannelListNum)
return FALSE;
else
return TRUE;
}
static inline UCHAR GetExtCh(
IN UCHAR Channel,
IN UCHAR Direction)
{
CHAR ExtCh;
if (Direction == EXTCHA_ABOVE)
ExtCh = Channel + 4;
else
ExtCh = (Channel - 4) > 0 ? (Channel - 4) : 0;
return ExtCh;
}
static inline VOID N_ChannelCheck(
IN PRTMP_ADAPTER pAd)
{
//UCHAR ChannelNum = pAd->ChannelListNum;
UCHAR Channel = pAd->CommonCfg.Channel;
if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
{
if (Channel > 14)
{
if ((Channel == 36) || (Channel == 44) || (Channel == 52) || (Channel == 60) || (Channel == 100) || (Channel == 108) ||
(Channel == 116) || (Channel == 124) || (Channel == 132) || (Channel == 149) || (Channel == 157))
{
pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
}
else if ((Channel == 40) || (Channel == 48) || (Channel == 56) || (Channel == 64) || (Channel == 104) || (Channel == 112) ||
(Channel == 120) || (Channel == 128) || (Channel == 136) || (Channel == 153) || (Channel == 161))
{
pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
}
}
else
{
do
{
UCHAR ExtCh;
UCHAR Dir = pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
ExtCh = GetExtCh(Channel, Dir);
if (IsValidChannel(pAd, ExtCh))
break;
Dir = (Dir == EXTCHA_ABOVE) ? EXTCHA_BELOW : EXTCHA_ABOVE;
ExtCh = GetExtCh(Channel, Dir);
if (IsValidChannel(pAd, ExtCh))
{
pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = Dir;
break;
}
pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
} while(FALSE);
if (Channel == 14)
{
pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
//pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_NONE; // We didn't set the ExtCh as NONE due to it'll set in RTMPSetHT()
}
}
}
}
static inline VOID N_SetCenCh(
IN PRTMP_ADAPTER pAd)
{
if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
{
if (pAd->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
{
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
}
else
{
if (pAd->CommonCfg.Channel == 14)
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 1;
else
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
}
}
else
{
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
}
}
static inline UINT8 GetCuntryMaxTxPwr(
IN PRTMP_ADAPTER pAd,
IN UINT8 channel)
{
int i;
for (i = 0; i < pAd->ChannelListNum; i++)
{
if (pAd->ChannelList[i].Channel == channel)
break;
}
if (i == pAd->ChannelListNum)
return 0xff;
else
return pAd->ChannelList[i].MaxTxPwr;
}
#endif // __CHLIST_H__
#include "../rt2860/chlist.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
dfs.h
Abstract:
Support DFS function.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Fonchi 03-12-2007 created
*/
#define RADAR_PULSE 1
#define RADAR_WIDTH 2
#define WIDTH_RD_IDLE 0
#define WIDTH_RD_CHECK 1
VOID BbpRadarDetectionStart(
IN PRTMP_ADAPTER pAd);
VOID BbpRadarDetectionStop(
IN PRTMP_ADAPTER pAd);
VOID RadarDetectionStart(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN CTS_Protect,
IN UINT8 CTSPeriod);
VOID RadarDetectionStop(
IN PRTMP_ADAPTER pAd);
VOID RadarDetectPeriodic(
IN PRTMP_ADAPTER pAd);
BOOLEAN RadarChannelCheck(
IN PRTMP_ADAPTER pAd,
IN UCHAR Ch);
ULONG JapRadarType(
IN PRTMP_ADAPTER pAd);
ULONG RTMPBbpReadRadarDuration(
IN PRTMP_ADAPTER pAd);
ULONG RTMPReadRadarDuration(
IN PRTMP_ADAPTER pAd);
VOID RTMPCleanRadarDuration(
IN PRTMP_ADAPTER pAd);
VOID RTMPPrepareRDCTSFrame(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pDA,
IN ULONG Duration,
IN UCHAR RTSRate,
IN ULONG CTSBaseAddr,
IN UCHAR FrameGap);
VOID RTMPPrepareRadarDetectParams(
IN PRTMP_ADAPTER pAd);
INT Set_ChMovingTime_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
INT Set_LongPulseRadarTh_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
#include "../rt2860/dfs.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __LINK_LIST_H__
#define __LINK_LIST_H__
typedef struct _LIST_ENTRY
{
struct _LIST_ENTRY *pNext;
} LIST_ENTRY, *PLIST_ENTRY;
typedef struct _LIST_HEADR
{
PLIST_ENTRY pHead;
PLIST_ENTRY pTail;
UCHAR size;
} LIST_HEADER, *PLIST_HEADER;
static inline VOID initList(
IN PLIST_HEADER pList)
{
pList->pHead = pList->pTail = NULL;
pList->size = 0;
return;
}
static inline VOID insertTailList(
IN PLIST_HEADER pList,
IN PLIST_ENTRY pEntry)
{
pEntry->pNext = NULL;
if (pList->pTail)
pList->pTail->pNext = pEntry;
else
pList->pHead = pEntry;
pList->pTail = pEntry;
pList->size++;
return;
}
static inline PLIST_ENTRY removeHeadList(
IN PLIST_HEADER pList)
{
PLIST_ENTRY pNext;
PLIST_ENTRY pEntry;
pEntry = pList->pHead;
if (pList->pHead != NULL)
{
pNext = pList->pHead->pNext;
pList->pHead = pNext;
if (pNext == NULL)
pList->pTail = NULL;
pList->size--;
}
return pEntry;
}
static inline int getListSize(
IN PLIST_HEADER pList)
{
return pList->size;
}
static inline PLIST_ENTRY delEntryList(
IN PLIST_HEADER pList,
IN PLIST_ENTRY pEntry)
{
PLIST_ENTRY pCurEntry;
PLIST_ENTRY pPrvEntry;
if(pList->pHead == NULL)
return NULL;
if(pEntry == pList->pHead)
{
pCurEntry = pList->pHead;
pList->pHead = pCurEntry->pNext;
if(pList->pHead == NULL)
pList->pTail = NULL;
pList->size--;
return pCurEntry;
}
pPrvEntry = pList->pHead;
pCurEntry = pPrvEntry->pNext;
while(pCurEntry != NULL)
{
if (pEntry == pCurEntry)
{
pPrvEntry->pNext = pCurEntry->pNext;
if(pEntry == pList->pTail)
pList->pTail = pPrvEntry;
pList->size--;
break;
}
pPrvEntry = pCurEntry;
pCurEntry = pPrvEntry->pNext;
}
return pCurEntry;
}
#endif // ___LINK_LIST_H__ //
#include "../rt2860/link_list.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
md5.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
jan 10-28-03 Initial
Rita 11-23-04 Modify MD5 and SHA-1
*/
#ifndef uint8
#define uint8 unsigned char
#endif
#ifndef uint32
#define uint32 unsigned long int
#endif
#ifndef __MD5_H__
#define __MD5_H__
#define MD5_MAC_LEN 16
typedef struct _MD5_CTX {
UINT32 Buf[4]; // buffers of four states
UCHAR Input[64]; // input message
UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
} MD5_CTX;
VOID MD5Init(MD5_CTX *pCtx);
VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx);
VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16]);
void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
//
// SHA context
//
typedef struct _SHA_CTX
{
UINT32 Buf[5]; // buffers of five states
UCHAR Input[80]; // input message
UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
} SHA_CTX;
VOID SHAInit(SHA_CTX *pCtx);
UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20]);
VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20]);
#define SHA_DIGEST_LEN 20
#endif // __MD5_H__
/******************************************************************************/
#ifndef _AES_H
#define _AES_H
typedef struct
{
uint32 erk[64]; /* encryption round keys */
uint32 drk[64]; /* decryption round keys */
int nr; /* number of rounds */
}
aes_context;
int rtmp_aes_set_key( aes_context *ctx, uint8 *key, int nbits );
void rtmp_aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
void rtmp_aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output);
int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output);
#endif /* aes.h */
#include "../rt2860/md5.h"
/*
*************************************************************************
* 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:
mlme.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
John Chang 2003-08-28 Created
John Chang 2004-09-06 modified for RT2600
*/
#ifndef __MLME_H__
#define __MLME_H__
// maximum supported capability information -
// ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot
#define SUPPORTED_CAPABILITY_INFO 0x0533
#define END_OF_ARGS -1
#define LFSR_MASK 0x80000057
#define MLME_TASK_EXEC_INTV 100/*200*/ //
#define LEAD_TIME 5
#define MLME_TASK_EXEC_MULTIPLE 10 /*5*/ // MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec
#define REORDER_EXEC_INTV 100 // 0.1 sec
// The definition of Radar detection duration region
#define CE 0
#define FCC 1
#define JAP 2
#define JAP_W53 3
#define JAP_W56 4
#define MAX_RD_REGION 5
#ifdef NDIS51_MINIPORT
#define BEACON_LOST_TIME 4000 // 2048 msec = 2 sec
#else
#define BEACON_LOST_TIME 4 * OS_HZ // 2048 msec = 2 sec
#endif
#define DLS_TIMEOUT 1200 // unit: msec
#define AUTH_TIMEOUT 300 // unit: msec
#define ASSOC_TIMEOUT 300 // unit: msec
#define JOIN_TIMEOUT 2 * OS_HZ // unit: msec
#define SHORT_CHANNEL_TIME 90 // unit: msec
#define MIN_CHANNEL_TIME 110 // unit: msec, for dual band scan
#define MAX_CHANNEL_TIME 140 // unit: msec, for single band scan
#define FAST_ACTIVE_SCAN_TIME 30 // Active scan waiting for probe response time
#define CW_MIN_IN_BITS 4 // actual CwMin = 2^CW_MIN_IN_BITS - 1
#define CW_MAX_IN_BITS 10 // actual CwMax = 2^CW_MAX_IN_BITS - 1
// Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720).
// SHould not refer to this constant anymore
//#define RSSI_TO_DBM_OFFSET 120 // for RT2530 RSSI-115 = dBm
#define RSSI_FOR_MID_TX_POWER -55 // -55 db is considered mid-distance
#define RSSI_FOR_LOW_TX_POWER -45 // -45 db is considered very short distance and
// eligible to use a lower TX power
#define RSSI_FOR_LOWEST_TX_POWER -30
//#define MID_TX_POWER_DELTA 0 // 0 db from full TX power upon mid-distance to AP
#define LOW_TX_POWER_DELTA 6 // -3 db from full TX power upon very short distance. 1 grade is 0.5 db
#define LOWEST_TX_POWER_DELTA 16 // -8 db from full TX power upon shortest distance. 1 grade is 0.5 db
#define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD 0
#define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD 1
#define RSSI_THRESHOLD_FOR_ROAMING 25
#define RSSI_DELTA 5
// Channel Quality Indication
#define CQI_IS_GOOD(cqi) ((cqi) >= 50)
//#define CQI_IS_FAIR(cqi) (((cqi) >= 20) && ((cqi) < 50))
#define CQI_IS_POOR(cqi) (cqi < 50) //(((cqi) >= 5) && ((cqi) < 20))
#define CQI_IS_BAD(cqi) (cqi < 5)
#define CQI_IS_DEAD(cqi) (cqi == 0)
// weighting factor to calculate Channel quality, total should be 100%
#define RSSI_WEIGHTING 50
#define TX_WEIGHTING 30
#define RX_WEIGHTING 20
#define BSS_NOT_FOUND 0xFFFFFFFF
#define MAX_LEN_OF_MLME_QUEUE 40 //10
#define SCAN_PASSIVE 18 // scan with no probe request, only wait beacon and probe response
#define SCAN_ACTIVE 19 // scan with probe request, and wait beacon and probe response
#define SCAN_CISCO_PASSIVE 20 // Single channel passive scan
#define SCAN_CISCO_ACTIVE 21 // Single channel active scan
#define SCAN_CISCO_NOISE 22 // Single channel passive scan for noise histogram collection
#define SCAN_CISCO_CHANNEL_LOAD 23 // Single channel passive scan for channel load collection
#define FAST_SCAN_ACTIVE 24 // scan with probe request, and wait beacon and probe response
#define MAC_ADDR_IS_GROUP(Addr) (((Addr[0]) & 0x01))
#define MAC_ADDR_HASH(Addr) (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
#define MAC_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
#define TID_MAC_HASH(Addr,TID) (TID^Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
#define TID_MAC_HASH_INDEX(Addr,TID) (TID_MAC_HASH(Addr,TID) % HASH_TABLE_SIZE)
// LED Control
// assoiation ON. one LED ON. another blinking when TX, OFF when idle
// no association, both LED off
#define ASIC_LED_ACT_ON(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00031e46)
#define ASIC_LED_ACT_OFF(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00001e46)
// bit definition of the 2-byte pBEACON->Capability field
#define CAP_IS_ESS_ON(x) (((x) & 0x0001) != 0)
#define CAP_IS_IBSS_ON(x) (((x) & 0x0002) != 0)
#define CAP_IS_CF_POLLABLE_ON(x) (((x) & 0x0004) != 0)
#define CAP_IS_CF_POLL_REQ_ON(x) (((x) & 0x0008) != 0)
#define CAP_IS_PRIVACY_ON(x) (((x) & 0x0010) != 0)
#define CAP_IS_SHORT_PREAMBLE_ON(x) (((x) & 0x0020) != 0)
#define CAP_IS_PBCC_ON(x) (((x) & 0x0040) != 0)
#define CAP_IS_AGILITY_ON(x) (((x) & 0x0080) != 0)
#define CAP_IS_SPECTRUM_MGMT(x) (((x) & 0x0100) != 0) // 802.11e d9
#define CAP_IS_QOS(x) (((x) & 0x0200) != 0) // 802.11e d9
#define CAP_IS_SHORT_SLOT(x) (((x) & 0x0400) != 0)
#define CAP_IS_APSD(x) (((x) & 0x0800) != 0) // 802.11e d9
#define CAP_IS_IMMED_BA(x) (((x) & 0x1000) != 0) // 802.11e d9
#define CAP_IS_DSSS_OFDM(x) (((x) & 0x2000) != 0)
#define CAP_IS_DELAY_BA(x) (((x) & 0x4000) != 0) // 802.11e d9
#define CAP_GENERATE(ess,ibss,priv,s_pre,s_slot,spectrum) (((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((s_pre) ? 0x0020 : 0x0000) | ((s_slot) ? 0x0400 : 0x0000) | ((spectrum) ? 0x0100 : 0x0000))
#define ERP_IS_NON_ERP_PRESENT(x) (((x) & 0x01) != 0) // 802.11g
#define ERP_IS_USE_PROTECTION(x) (((x) & 0x02) != 0) // 802.11g
#define ERP_IS_USE_BARKER_PREAMBLE(x) (((x) & 0x04) != 0) // 802.11g
#define DRS_TX_QUALITY_WORST_BOUND 8// 3 // just test by gary
#define DRS_PENALTY 8
#define BA_NOTUSE 2
//BA Policy subfiled value in ADDBA frame
#define IMMED_BA 1
#define DELAY_BA 0
// BA Initiator subfield in DELBA frame
#define ORIGINATOR 1
#define RECIPIENT 0
// ADDBA Status Code
#define ADDBA_RESULTCODE_SUCCESS 0
#define ADDBA_RESULTCODE_REFUSED 37
#define ADDBA_RESULTCODE_INVALID_PARAMETERS 38
// DELBA Reason Code
#define DELBA_REASONCODE_QSTA_LEAVING 36
#define DELBA_REASONCODE_END_BA 37
#define DELBA_REASONCODE_UNKNOWN_BA 38
#define DELBA_REASONCODE_TIMEOUT 39
// reset all OneSecTx counters
#define RESET_ONE_SEC_TX_CNT(__pEntry) \
if (((__pEntry)) != NULL) \
{ \
(__pEntry)->OneSecTxRetryOkCount = 0; \
(__pEntry)->OneSecTxFailCount = 0; \
(__pEntry)->OneSecTxNoRetryOkCount = 0; \
}
//
// 802.11 frame formats
//
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
USHORT AdvCoding:1;
USHORT ChannelWidth:1;
USHORT MimoPs:2;//momi power safe
USHORT GF:1; //green field
USHORT ShortGIfor20:1;
USHORT ShortGIfor40:1; //for40MHz
USHORT TxSTBC:1;
USHORT RxSTBC:2;
USHORT DelayedBA:1; //rt2860c not support
USHORT AMsduSize:1; // only support as zero
USHORT CCKmodein40:1;
USHORT PSMP:1;
USHORT Forty_Mhz_Intolerant:1;
USHORT LSIGTxopProSup:1;
} HT_CAP_INFO, *PHT_CAP_INFO;
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
UCHAR MaxRAmpduFactor:2;
UCHAR MpduDensity:3;
UCHAR rsv:3;//momi power safe
} HT_CAP_PARM, *PHT_CAP_PARM;
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
UCHAR MCSSet[10];
UCHAR SupRate[2]; // unit : 1Mbps
UCHAR TxMCSSetDefined:1;
UCHAR TxRxNotEqual:1;
UCHAR TxStream:2;
UCHAR MpduDensity:1;
UCHAR rsv:3;
UCHAR rsv3[3];
} HT_MCS_SET, *PHT_MCS_SET;
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
USHORT Pco:1;
USHORT TranTime:2;
USHORT rsv:5;//momi power safe
USHORT MCSFeedback:2; //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback, 1:rsv.
USHORT PlusHTC:1; //+HTC control field support
USHORT RDGSupport:1; //reverse Direction Grant support
USHORT rsv2:4;
} EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
// HT Beamforming field in HT Cap IE .
typedef struct PACKED _HT_BF_CAP{
ULONG TxBFRecCapable:1;
ULONG RxSoundCapable:1;
ULONG TxSoundCapable:1;
ULONG RxNDPCapable:1;
ULONG TxNDPCapable:1;
ULONG ImpTxBFCapable:1;
ULONG Calibration:2;
ULONG ExpCSICapable:1;
ULONG ExpNoComSteerCapable:1;
ULONG ExpComSteerCapable:1;
ULONG ExpCSIFbk:2;
ULONG ExpNoComBF:2;
ULONG ExpComBF:2;
ULONG MinGrouping:2;
ULONG CSIBFAntSup:2;
ULONG NoComSteerBFAntSup:2;
ULONG ComSteerBFAntSup:2;
ULONG CSIRowBFSup:2;
ULONG ChanEstimation:2;
ULONG rsv:3;
} HT_BF_CAP, *PHT_BF_CAP;
// HT antenna selection field in HT Cap IE .
typedef struct PACKED _HT_AS_CAP{
UCHAR AntSelect:1;
UCHAR ExpCSIFbkTxASEL:1;
UCHAR AntIndFbkTxASEL:1;
UCHAR ExpCSIFbk:1;
UCHAR AntIndFbk:1;
UCHAR RxASel:1;
UCHAR TxSoundPPDU:1;
UCHAR rsv:1;
} HT_AS_CAP, *PHT_AS_CAP;
// Draft 1.0 set IE length 26, but is extensible..
#define SIZE_HT_CAP_IE 26
// The structure for HT Capability IE.
typedef struct PACKED _HT_CAPABILITY_IE{
HT_CAP_INFO HtCapInfo;
HT_CAP_PARM HtCapParm;
// HT_MCS_SET HtMCSSet;
UCHAR MCSSet[16];
EXT_HT_CAP_INFO ExtHtCapInfo;
HT_BF_CAP TxBFCap; // beamforming cap. rt2860c not support beamforming.
HT_AS_CAP ASCap; //antenna selection.
} HT_CAPABILITY_IE, *PHT_CAPABILITY_IE;
// 802.11n draft3 related structure definitions.
// 7.3.2.60
#define dot11OBSSScanPassiveDwell 20 // in TU. min amount of time that the STA continously scans each channel when performing an active OBSS scan.
#define dot11OBSSScanActiveDwell 10 // in TU.min amount of time that the STA continously scans each channel when performing an passive OBSS scan.
#define dot11BSSWidthTriggerScanInterval 300 // in sec. max interval between scan operations to be performed to detect BSS channel width trigger events.
#define dot11OBSSScanPassiveTotalPerChannel 200 // in TU. min total amount of time that the STA scans each channel when performing a passive OBSS scan.
#define dot11OBSSScanActiveTotalPerChannel 20 //in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan
#define dot11BSSWidthChannelTransactionDelayFactor 5 // min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maxima
// interval between overlapping BSS scan operations.
#define dot11BSSScanActivityThreshold 25 // in %%, max total time that a STA may be active on the medium during a period of
// (dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without
// being obligated to perform OBSS Scan operations. default is 25(== 0.25%)
typedef struct PACKED _OVERLAP_BSS_SCAN_IE{
USHORT ScanPassiveDwell;
USHORT ScanActiveDwell;
USHORT TriggerScanInt; // Trigger scan interval
USHORT PassiveTalPerChannel; // passive total per channel
USHORT ActiveTalPerChannel; // active total per channel
USHORT DelayFactor; // BSS width channel transition delay factor
USHORT ScanActThre; // Scan Activity threshold
}OVERLAP_BSS_SCAN_IE, *POVERLAP_BSS_SCAN_IE;
// 7.3.2.56. 20/40 Coexistence element used in Element ID = 72 = IE_2040_BSS_COEXIST
typedef union PACKED _BSS_2040_COEXIST_IE{
struct PACKED {
UCHAR InfoReq:1;
UCHAR Intolerant40:1; // Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
UCHAR BSS20WidthReq:1; // Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS.
UCHAR rsv:5;
} field;
UCHAR word;
} BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
typedef struct _TRIGGER_EVENTA{
BOOLEAN bValid;
UCHAR BSSID[6];
UCHAR RegClass; // Regulatory Class
USHORT Channel;
ULONG CDCounter; // Maintain a seperate count down counter for each Event A.
} TRIGGER_EVENTA, *PTRIGGER_EVENTA;
// 20/40 trigger event table
// If one Event A delete or created, or if Event B is detected or not detected, STA should send 2040BSSCoexistence to AP.
#define MAX_TRIGGER_EVENT 64
typedef struct _TRIGGER_EVENT_TAB{
UCHAR EventANo;
TRIGGER_EVENTA EventA[MAX_TRIGGER_EVENT];
ULONG EventBCountDown; // Count down counter for Event B.
} TRIGGER_EVENT_TAB, *PTRIGGER_EVENT_TAB;
// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
// This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
UCHAR BssCoexistMgmtSupport:1;
UCHAR rsv:1;
UCHAR ExtendChannelSwitch:1;
UCHAR rsv2:5;
}EXT_CAP_INFO_ELEMENT, *PEXT_CAP_INFO_ELEMENT;
// 802.11n 7.3.2.61
typedef struct PACKED _BSS_2040_COEXIST_ELEMENT{
UCHAR ElementID; // ID = IE_2040_BSS_COEXIST = 72
UCHAR Len;
BSS_2040_COEXIST_IE BssCoexistIe;
}BSS_2040_COEXIST_ELEMENT, *PBSS_2040_COEXIST_ELEMENT;
//802.11n 7.3.2.59
typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
UCHAR ElementID; // ID = IE_2040_BSS_INTOLERANT_REPORT = 73
UCHAR Len;
UCHAR RegulatoryClass;
UCHAR ChList[0];
}BSS_2040_INTOLERANT_CH_REPORT, *PBSS_2040_INTOLERANT_CH_REPORT;
// The structure for channel switch annoucement IE. This is in 802.11n D3.03
typedef struct PACKED _CHA_SWITCH_ANNOUNCE_IE{
UCHAR SwitchMode; //channel switch mode
UCHAR NewChannel; //
UCHAR SwitchCount; //
} CHA_SWITCH_ANNOUNCE_IE, *PCHA_SWITCH_ANNOUNCE_IE;
// The structure for channel switch annoucement IE. This is in 802.11n D3.03
typedef struct PACKED _SEC_CHA_OFFSET_IE{
UCHAR SecondaryChannelOffset; // 1: Secondary above, 3: Secondary below, 0: no Secondary
} SEC_CHA_OFFSET_IE, *PSEC_CHA_OFFSET_IE;
// This structure is extracted from struct RT_HT_CAPABILITY
typedef struct {
BOOLEAN bHtEnable; // If we should use ht rate.
BOOLEAN bPreNHt; // If we should use ht rate.
//Substract from HT Capability IE
UCHAR MCSSet[16]; //only supoort MCS=0-15,32 ,
} RT_HT_PHY_INFO, *PRT_HT_PHY_INFO;
//This structure substracts ralink supports from all 802.11n-related features.
//Features not listed here but contained in 802.11n spec are not supported in rt2860.
typedef struct {
USHORT ChannelWidth:1;
USHORT MimoPs:2;//mimo power safe MMPS_
USHORT GF:1; //green field
USHORT ShortGIfor20:1;
USHORT ShortGIfor40:1; //for40MHz
USHORT TxSTBC:1;
USHORT RxSTBC:2; // 2 bits
USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
USHORT AmsduSize:1; // Max receiving A-MSDU size
USHORT rsv:5;
//Substract from Addiont HT INFO IE
UCHAR MaxRAmpduFactor:2;
UCHAR MpduDensity:3;
UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
UCHAR RecomWidth:1;
USHORT OperaionMode:2;
USHORT NonGfPresent:1;
USHORT rsv3:1;
USHORT OBSS_NonHTExist:1;
USHORT rsv2:11;
// New Extension Channel Offset IE
UCHAR NewExtChannelOffset;
// Extension Capability IE = 127
UCHAR BSSCoexist2040;
} RT_HT_CAPABILITY, *PRT_HT_CAPABILITY;
// field in Addtional HT Information IE .
typedef struct PACKED {
UCHAR ExtChanOffset:2;
UCHAR RecomWidth:1;
UCHAR RifsMode:1;
UCHAR S_PSMPSup:1; //Indicate support for scheduled PSMP
UCHAR SerInterGranu:3; //service interval granularity
} ADD_HTINFO, *PADD_HTINFO;
typedef struct PACKED{
USHORT OperaionMode:2;
USHORT NonGfPresent:1;
USHORT rsv:1;
USHORT OBSS_NonHTExist:1;
USHORT rsv2:11;
} ADD_HTINFO2, *PADD_HTINFO2;
// TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved.
typedef struct PACKED{
USHORT StbcMcs:6;
USHORT DualBeacon:1;
USHORT DualCTSProtect:1;
USHORT STBCBeacon:1;
USHORT LsigTxopProt:1; // L-SIG TXOP protection full support
USHORT PcoActive:1;
USHORT PcoPhase:1;
USHORT rsv:4;
} ADD_HTINFO3, *PADD_HTINFO3;
#define SIZE_ADD_HT_INFO_IE 22
typedef struct PACKED{
UCHAR ControlChan;
ADD_HTINFO AddHtInfo;
ADD_HTINFO2 AddHtInfo2;
ADD_HTINFO3 AddHtInfo3;
UCHAR MCSSet[16]; // Basic MCS set
} ADD_HT_INFO_IE, *PADD_HT_INFO_IE;
typedef struct PACKED{
UCHAR NewExtChanOffset;
} NEW_EXT_CHAN_IE, *PNEW_EXT_CHAN_IE;
// 4-byte HTC field. maybe included in any frame except non-QOS data frame. The Order bit must set 1.
typedef struct PACKED {
UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
UINT32 TRQ:1; //sounding request
UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
UINT32 MRSorASI:3; // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
UINT32 MFS:3; //SET to the received value of MRS. 0x111 for unsolicited MFB.
UINT32 MFBorASC:7; //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
UINT32 CalPos:2; // calibration position
UINT32 CalSeq:2; //calibration sequence
UINT32 FBKReq:2; //feedback request
UINT32 CSISTEERING:2; //CSI/ STEERING
UINT32 ZLFAnnouce:1; // ZLF announcement
UINT32 rsv:5; //calibration sequence
UINT32 ACConstraint:1; //feedback request
UINT32 RDG:1; //RDG / More PPDU
} HT_CONTROL, *PHT_CONTROL;
// 2-byte QOS CONTROL field
typedef struct PACKED {
USHORT TID:4;
USHORT EOSP:1;
USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
USHORT AMsduPresent:1;
USHORT Txop_QueueSize:8;
} QOS_CONTROL, *PQOS_CONTROL;
// 2-byte Frame control field
typedef struct PACKED {
USHORT Ver:2; // Protocol version
USHORT Type:2; // MSDU type
USHORT SubType:4; // MSDU subtype
USHORT ToDs:1; // To DS indication
USHORT FrDs:1; // From DS indication
USHORT MoreFrag:1; // More fragment bit
USHORT Retry:1; // Retry status bit
USHORT PwrMgmt:1; // Power management bit
USHORT MoreData:1; // More data bit
USHORT Wep:1; // Wep data
USHORT Order:1; // Strict order expected
} FRAME_CONTROL, *PFRAME_CONTROL;
typedef struct PACKED _HEADER_802_11 {
FRAME_CONTROL FC;
USHORT Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
UCHAR Addr3[MAC_ADDR_LEN];
USHORT Frag:4;
USHORT Sequence:12;
UCHAR Octet[0];
} HEADER_802_11, *PHEADER_802_11;
typedef struct PACKED _FRAME_802_11 {
HEADER_802_11 Hdr;
UCHAR Octet[1];
} FRAME_802_11, *PFRAME_802_11;
// QoSNull embedding of management action. When HT Control MA field set to 1.
typedef struct PACKED _MA_BODY {
UCHAR Category;
UCHAR Action;
UCHAR Octet[1];
} MA_BODY, *PMA_BODY;
typedef struct PACKED _HEADER_802_3 {
UCHAR DAAddr1[MAC_ADDR_LEN];
UCHAR SAAddr2[MAC_ADDR_LEN];
UCHAR Octet[2];
} HEADER_802_3, *PHEADER_802_3;
////Block ACK related format
// 2-byte BA Parameter field in DELBA frames to terminate an already set up bA
typedef struct PACKED{
USHORT Rsv:11; // always set to 0
USHORT Initiator:1; // 1: originator 0:recipient
USHORT TID:4; // value of TC os TS
} DELBA_PARM, *PDELBA_PARM;
// 2-byte BA Parameter Set field in ADDBA frames to signal parm for setting up a BA
typedef struct PACKED {
USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
USHORT TID:4; // value of TC os TS
USHORT BufSize:10; // number of buffe of size 2304 octetsr
} BA_PARM, *PBA_PARM;
// 2-byte BA Starting Seq CONTROL field
typedef union PACKED {
struct PACKED {
USHORT FragNum:4; // always set to 0
USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
} field;
USHORT word;
} BASEQ_CONTROL, *PBASEQ_CONTROL;
//BAControl and BARControl are the same
// 2-byte BA CONTROL field in BA frame
typedef struct PACKED {
USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
USHORT MTID:1; //EWC V1.24
USHORT Compressed:1;
USHORT Rsv:9;
USHORT TID:4;
} BA_CONTROL, *PBA_CONTROL;
// 2-byte BAR CONTROL field in BAR frame
typedef struct PACKED {
USHORT ACKPolicy:1; // 0:normal ack, 1:no ack.
USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
USHORT Compressed:1;
USHORT Rsv1:9;
USHORT TID:4;
} BAR_CONTROL, *PBAR_CONTROL;
// BARControl in MTBAR frame
typedef struct PACKED {
USHORT ACKPolicy:1;
USHORT MTID:1;
USHORT Compressed:1;
USHORT Rsv1:9;
USHORT NumTID:4;
} MTBAR_CONTROL, *PMTBAR_CONTROL;
typedef struct PACKED {
USHORT Rsv1:12;
USHORT TID:4;
} PER_TID_INFO, *PPER_TID_INFO;
typedef struct {
PER_TID_INFO PerTID;
BASEQ_CONTROL BAStartingSeq;
} EACH_TID, *PEACH_TID;
typedef struct PACKED _PSPOLL_FRAME {
FRAME_CONTROL FC;
USHORT Aid;
UCHAR Bssid[MAC_ADDR_LEN];
UCHAR Ta[MAC_ADDR_LEN];
} PSPOLL_FRAME, *PPSPOLL_FRAME;
typedef struct PACKED _RTS_FRAME {
FRAME_CONTROL FC;
USHORT Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
}RTS_FRAME, *PRTS_FRAME;
// BAREQ AND MTBAREQ have the same subtype BAR, 802.11n BAR use compressed bitmap.
typedef struct PACKED _FRAME_BA_REQ {
FRAME_CONTROL FC;
USHORT Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
BAR_CONTROL BARControl;
BASEQ_CONTROL BAStartingSeq;
} FRAME_BA_REQ, *PFRAME_BA_REQ;
typedef struct PACKED _FRAME_MTBA_REQ {
FRAME_CONTROL FC;
USHORT Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
MTBAR_CONTROL MTBARControl;
PER_TID_INFO PerTIDInfo;
BASEQ_CONTROL BAStartingSeq;
} FRAME_MTBA_REQ, *PFRAME_MTBA_REQ;
// Compressed format is mandantory in HT STA
typedef struct PACKED _FRAME_MTBA {
FRAME_CONTROL FC;
USHORT Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
BA_CONTROL BAControl;
BASEQ_CONTROL BAStartingSeq;
UCHAR BitMap[8];
} FRAME_MTBA, *PFRAME_MTBA;
typedef struct PACKED _FRAME_PSMP_ACTION {
HEADER_802_11 Hdr;
UCHAR Category;
UCHAR Action;
UCHAR Psmp; // 7.3.1.25
} FRAME_PSMP_ACTION, *PFRAME_PSMP_ACTION;
typedef struct PACKED _FRAME_ACTION_HDR {
HEADER_802_11 Hdr;
UCHAR Category;
UCHAR Action;
} FRAME_ACTION_HDR, *PFRAME_ACTION_HDR;
//Action Frame
//Action Frame Category:Spectrum, Action:Channel Switch. 7.3.2.20
typedef struct PACKED _CHAN_SWITCH_ANNOUNCE {
UCHAR ElementID; // ID = IE_CHANNEL_SWITCH_ANNOUNCEMENT = 37
UCHAR Len;
CHA_SWITCH_ANNOUNCE_IE CSAnnounceIe;
} CHAN_SWITCH_ANNOUNCE, *PCHAN_SWITCH_ANNOUNCE;
//802.11n : 7.3.2.20a
typedef struct PACKED _SECOND_CHAN_OFFSET {
UCHAR ElementID; // ID = IE_SECONDARY_CH_OFFSET = 62
UCHAR Len;
SEC_CHA_OFFSET_IE SecChOffsetIe;
} SECOND_CHAN_OFFSET, *PSECOND_CHAN_OFFSET;
typedef struct PACKED _FRAME_SPETRUM_CS {
HEADER_802_11 Hdr;
UCHAR Category;
UCHAR Action;
CHAN_SWITCH_ANNOUNCE CSAnnounce;
SECOND_CHAN_OFFSET SecondChannel;
} FRAME_SPETRUM_CS, *PFRAME_SPETRUM_CS;
typedef struct PACKED _FRAME_ADDBA_REQ {
HEADER_802_11 Hdr;
UCHAR Category;
UCHAR Action;
UCHAR Token; // 1
BA_PARM BaParm; // 2 - 10
USHORT TimeOutValue; // 0 - 0
BASEQ_CONTROL BaStartSeq; // 0-0
} FRAME_ADDBA_REQ, *PFRAME_ADDBA_REQ;
typedef struct PACKED _FRAME_ADDBA_RSP {
HEADER_802_11 Hdr;
UCHAR Category;
UCHAR Action;
UCHAR Token;
USHORT StatusCode;
BA_PARM BaParm; //0 - 2
USHORT TimeOutValue;
} FRAME_ADDBA_RSP, *PFRAME_ADDBA_RSP;
typedef struct PACKED _FRAME_DELBA_REQ {
HEADER_802_11 Hdr;
UCHAR Category;
UCHAR Action;
DELBA_PARM DelbaParm;
USHORT ReasonCode;
} FRAME_DELBA_REQ, *PFRAME_DELBA_REQ;
//7.2.1.7
typedef struct PACKED _FRAME_BAR {
FRAME_CONTROL FC;
USHORT Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
BAR_CONTROL BarControl;
BASEQ_CONTROL StartingSeq;
} FRAME_BAR, *PFRAME_BAR;
//7.2.1.7
typedef struct PACKED _FRAME_BA {
FRAME_CONTROL FC;
USHORT Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
BAR_CONTROL BarControl;
BASEQ_CONTROL StartingSeq;
UCHAR bitmask[8];
} FRAME_BA, *PFRAME_BA;
// Radio Measuement Request Frame Format
typedef struct PACKED _FRAME_RM_REQ_ACTION {
HEADER_802_11 Hdr;
UCHAR Category;
UCHAR Action;
UCHAR Token;
USHORT Repetition;
UCHAR data[0];
} FRAME_RM_REQ_ACTION, *PFRAME_RM_REQ_ACTION;
typedef struct PACKED {
UCHAR ID;
UCHAR Length;
UCHAR ChannelSwitchMode;
UCHAR NewRegClass;
UCHAR NewChannelNum;
UCHAR ChannelSwitchCount;
} HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE, *PHT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE;
//
// _Limit must be the 2**n - 1
// _SEQ1 , _SEQ2 must be within 0 ~ _Limit
//
#define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit) ((_SEQ1 == ((_SEQ2+1) & _Limit)))
#define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit) (((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
#define SEQ_LARGER(_SEQ1, _SEQ2, _Limit) ((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
#define SEQ_WITHIN_WIN(_SEQ1, _SEQ2, _WIN, _Limit) (SEQ_LARGER(_SEQ1, _SEQ2, _Limit) && \
SEQ_SMALLER(_SEQ1, ((_SEQ2+_WIN+1)&_Limit), _Limit))
//
// Contention-free parameter (without ID and Length)
//
typedef struct PACKED {
BOOLEAN bValid; // 1: variable contains valid value
UCHAR CfpCount;
UCHAR CfpPeriod;
USHORT CfpMaxDuration;
USHORT CfpDurRemaining;
} CF_PARM, *PCF_PARM;
typedef struct _CIPHER_SUITE {
NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher 1, this one has more secured cipher suite
NDIS_802_11_ENCRYPTION_STATUS PairCipherAux; // Unicast cipher 2 if AP announce two unicast cipher suite
NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Group cipher
USHORT RsnCapability; // RSN capability from beacon
BOOLEAN bMixMode; // Indicate Pair & Group cipher might be different
} CIPHER_SUITE, *PCIPHER_SUITE;
// EDCA configuration from AP's BEACON/ProbeRsp
typedef struct {
BOOLEAN bValid; // 1: variable contains valid value
BOOLEAN bAdd; // 1: variable contains valid value
BOOLEAN bQAck;
BOOLEAN bQueueRequest;
BOOLEAN bTxopRequest;
BOOLEAN bAPSDCapable;
// BOOLEAN bMoreDataAck;
UCHAR EdcaUpdateCount;
UCHAR Aifsn[4]; // 0:AC_BK, 1:AC_BE, 2:AC_VI, 3:AC_VO
UCHAR Cwmin[4];
UCHAR Cwmax[4];
USHORT Txop[4]; // in unit of 32-us
BOOLEAN bACM[4]; // 1: Admission Control of AC_BK is mandattory
} EDCA_PARM, *PEDCA_PARM;
// QBSS LOAD information from QAP's BEACON/ProbeRsp
typedef struct {
BOOLEAN bValid; // 1: variable contains valid value
USHORT StaNum;
UCHAR ChannelUtilization;
USHORT RemainingAdmissionControl; // in unit of 32-us
} QBSS_LOAD_PARM, *PQBSS_LOAD_PARM;
// QBSS Info field in QSTA's assoc req
typedef struct PACKED {
UCHAR UAPSD_AC_VO:1;
UCHAR UAPSD_AC_VI:1;
UCHAR UAPSD_AC_BK:1;
UCHAR UAPSD_AC_BE:1;
UCHAR Rsv1:1;
UCHAR MaxSPLength:2;
UCHAR Rsv2:1;
} QBSS_STA_INFO_PARM, *PQBSS_STA_INFO_PARM;
// QBSS Info field in QAP's Beacon/ProbeRsp
typedef struct PACKED {
UCHAR ParamSetCount:4;
UCHAR Rsv:3;
UCHAR UAPSD:1;
} QBSS_AP_INFO_PARM, *PQBSS_AP_INFO_PARM;
// QOS Capability reported in QAP's BEACON/ProbeRsp
// QOS Capability sent out in QSTA's AssociateReq/ReAssociateReq
typedef struct {
BOOLEAN bValid; // 1: variable contains valid value
BOOLEAN bQAck;
BOOLEAN bQueueRequest;
BOOLEAN bTxopRequest;
// BOOLEAN bMoreDataAck;
UCHAR EdcaUpdateCount;
} QOS_CAPABILITY_PARM, *PQOS_CAPABILITY_PARM;
typedef struct {
UCHAR IELen;
UCHAR IE[MAX_CUSTOM_LEN];
} WPA_IE_;
typedef struct {
UCHAR Bssid[MAC_ADDR_LEN];
UCHAR Channel;
UCHAR CentralChannel; //Store the wide-band central channel for 40MHz. .used in 40MHz AP. Or this is the same as Channel.
UCHAR BssType;
USHORT AtimWin;
USHORT BeaconPeriod;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen;
UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR ExtRateLen;
HT_CAPABILITY_IE HtCapability;
UCHAR HtCapabilityLen;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR AddHtInfoLen;
UCHAR NewExtChanOffset;
CHAR Rssi;
UCHAR Privacy; // Indicate security function ON/OFF. Don't mess up with auth mode.
UCHAR Hidden;
USHORT DtimPeriod;
USHORT CapabilityInfo;
USHORT CfpCount;
USHORT CfpPeriod;
USHORT CfpMaxDuration;
USHORT CfpDurRemaining;
UCHAR SsidLen;
CHAR Ssid[MAX_LEN_OF_SSID];
ULONG LastBeaconRxTime; // OS's timestamp
BOOLEAN bSES;
// New for WPA2
CIPHER_SUITE WPA; // AP announced WPA cipher suite
CIPHER_SUITE WPA2; // AP announced WPA2 cipher suite
// New for microsoft WPA support
NDIS_802_11_FIXED_IEs FixIEs;
NDIS_802_11_AUTHENTICATION_MODE AuthModeAux; // Addition mode for WPA2 / WPA capable AP
NDIS_802_11_AUTHENTICATION_MODE AuthMode;
NDIS_802_11_WEP_STATUS WepStatus; // Unicast Encryption Algorithm extract from VAR_IE
USHORT VarIELen; // Length of next VIE include EID & Length
UCHAR VarIEs[MAX_VIE_LEN];
// CCX Ckip information
UCHAR CkipFlag;
// CCX 2 TSF
UCHAR PTSF[4]; // Parent TSF
UCHAR TTSF[8]; // Target TSF
// 802.11e d9, and WMM
EDCA_PARM EdcaParm;
QOS_CAPABILITY_PARM QosCapability;
QBSS_LOAD_PARM QbssLoad;
WPA_IE_ WpaIE;
WPA_IE_ RsnIE;
} BSS_ENTRY, *PBSS_ENTRY;
typedef struct {
UCHAR BssNr;
UCHAR BssOverlapNr;
BSS_ENTRY BssEntry[MAX_LEN_OF_BSS_TABLE];
} BSS_TABLE, *PBSS_TABLE;
typedef struct _MLME_QUEUE_ELEM {
ULONG Machine;
ULONG MsgType;
ULONG MsgLen;
UCHAR Msg[MGMT_DMA_BUFFER_SIZE];
LARGE_INTEGER TimeStamp;
UCHAR Rssi0;
UCHAR Rssi1;
UCHAR Rssi2;
UCHAR Signal;
UCHAR Channel;
UCHAR Wcid;
BOOLEAN Occupied;
} MLME_QUEUE_ELEM, *PMLME_QUEUE_ELEM;
typedef struct _MLME_QUEUE {
ULONG Num;
ULONG Head;
ULONG Tail;
NDIS_SPIN_LOCK Lock;
MLME_QUEUE_ELEM Entry[MAX_LEN_OF_MLME_QUEUE];
} MLME_QUEUE, *PMLME_QUEUE;
typedef VOID (*STATE_MACHINE_FUNC)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem);
typedef struct _STATE_MACHINE {
ULONG Base;
ULONG NrState;
ULONG NrMsg;
ULONG CurrState;
STATE_MACHINE_FUNC *TransFunc;
} STATE_MACHINE, *PSTATE_MACHINE;
// MLME AUX data structure that hold temporarliy settings during a connection attempt.
// Once this attemp succeeds, all settings will be copy to pAd->StaActive.
// A connection attempt (user set OID, roaming, CCX fast roaming,..) consists of
// several steps (JOIN, AUTH, ASSOC or REASSOC) and may fail at any step. We purposely
// separate this under-trial settings away from pAd->StaActive so that once
// this new attempt failed, driver can auto-recover back to the active settings.
typedef struct _MLME_AUX {
UCHAR BssType;
UCHAR Ssid[MAX_LEN_OF_SSID];
UCHAR SsidLen;
UCHAR Bssid[MAC_ADDR_LEN];
UCHAR AutoReconnectSsid[MAX_LEN_OF_SSID];
UCHAR AutoReconnectSsidLen;
USHORT Alg;
UCHAR ScanType;
UCHAR Channel;
UCHAR CentralChannel;
USHORT Aid;
USHORT CapabilityInfo;
USHORT BeaconPeriod;
USHORT CfpMaxDuration;
USHORT CfpPeriod;
USHORT AtimWin;
// Copy supported rate from desired AP's beacon. We are trying to match
// AP's supported and extended rate settings.
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen;
UCHAR ExtRateLen;
HT_CAPABILITY_IE HtCapability;
UCHAR HtCapabilityLen;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR NewExtChannelOffset;
//RT_HT_CAPABILITY SupportedHtPhy;
// new for QOS
QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
// new to keep Ralink specific feature
ULONG APRalinkIe;
BSS_TABLE SsidBssTab; // AP list for the same SSID
BSS_TABLE RoamTab; // AP list eligible for roaming
ULONG BssIdx;
ULONG RoamIdx;
BOOLEAN CurrReqIsFromNdis;
RALINK_TIMER_STRUCT BeaconTimer, ScanTimer;
RALINK_TIMER_STRUCT AuthTimer;
RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer;
} MLME_AUX, *PMLME_AUX;
typedef struct _MLME_ADDBA_REQ_STRUCT{
UCHAR Wcid; //
UCHAR pAddr[MAC_ADDR_LEN];
UCHAR BaBufSize;
USHORT TimeOutValue;
UCHAR TID;
UCHAR Token;
USHORT BaStartSeq;
} MLME_ADDBA_REQ_STRUCT, *PMLME_ADDBA_REQ_STRUCT;
typedef struct _MLME_DELBA_REQ_STRUCT{
UCHAR Wcid; //
UCHAR Addr[MAC_ADDR_LEN];
UCHAR TID;
UCHAR Initiator;
} MLME_DELBA_REQ_STRUCT, *PMLME_DELBA_REQ_STRUCT;
// assoc struct is equal to reassoc
typedef struct _MLME_ASSOC_REQ_STRUCT{
UCHAR Addr[MAC_ADDR_LEN];
USHORT CapabilityInfo;
USHORT ListenIntv;
ULONG Timeout;
} MLME_ASSOC_REQ_STRUCT, *PMLME_ASSOC_REQ_STRUCT, MLME_REASSOC_REQ_STRUCT, *PMLME_REASSOC_REQ_STRUCT;
typedef struct _MLME_DISASSOC_REQ_STRUCT{
UCHAR Addr[MAC_ADDR_LEN];
USHORT Reason;
} MLME_DISASSOC_REQ_STRUCT, *PMLME_DISASSOC_REQ_STRUCT;
typedef struct _MLME_AUTH_REQ_STRUCT {
UCHAR Addr[MAC_ADDR_LEN];
USHORT Alg;
ULONG Timeout;
} MLME_AUTH_REQ_STRUCT, *PMLME_AUTH_REQ_STRUCT;
typedef struct _MLME_DEAUTH_REQ_STRUCT {
UCHAR Addr[MAC_ADDR_LEN];
USHORT Reason;
} MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT;
typedef struct {
ULONG BssIdx;
} MLME_JOIN_REQ_STRUCT;
typedef struct _MLME_SCAN_REQ_STRUCT {
UCHAR Bssid[MAC_ADDR_LEN];
UCHAR BssType;
UCHAR ScanType;
UCHAR SsidLen;
CHAR Ssid[MAX_LEN_OF_SSID];
} MLME_SCAN_REQ_STRUCT, *PMLME_SCAN_REQ_STRUCT;
typedef struct _MLME_START_REQ_STRUCT {
CHAR Ssid[MAX_LEN_OF_SSID];
UCHAR SsidLen;
} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
typedef struct PACKED {
UCHAR Eid;
UCHAR Len;
CHAR Octet[1];
} EID_STRUCT,*PEID_STRUCT, BEACON_EID_STRUCT, *PBEACON_EID_STRUCT;
typedef struct PACKED _RTMP_TX_RATE_SWITCH
{
UCHAR ItemNo;
UCHAR STBC:1;
UCHAR ShortGI:1;
UCHAR BW:1;
UCHAR Rsv1:1;
UCHAR Mode:2;
UCHAR Rsv2:2;
UCHAR CurrMCS;
UCHAR TrainUp;
UCHAR TrainDown;
} RRTMP_TX_RATE_SWITCH, *PRTMP_TX_RATE_SWITCH;
// ========================== AP mlme.h ===============================
#define TBTT_PRELOAD_TIME 384 // usec. LomgPreamble + 24-byte at 1Mbps
#define DEFAULT_DTIM_PERIOD 1
#define MAC_TABLE_AGEOUT_TIME 300 // unit: sec
#define MAC_TABLE_ASSOC_TIMEOUT 5 // unit: sec
#define MAC_TABLE_FULL(Tab) ((Tab).size == MAX_LEN_OF_MAC_TABLE)
// AP shall drop the sta if contine Tx fail count reach it.
#define MAC_ENTRY_LIFE_CHECK_CNT 20 // packet cnt.
// Value domain of pMacEntry->Sst
typedef enum _Sst {
SST_NOT_AUTH, // 0: equivalent to IEEE 802.11/1999 state 1
SST_AUTH, // 1: equivalent to IEEE 802.11/1999 state 2
SST_ASSOC // 2: equivalent to IEEE 802.11/1999 state 3
} SST;
// value domain of pMacEntry->AuthState
typedef enum _AuthState {
AS_NOT_AUTH,
AS_AUTH_OPEN, // STA has been authenticated using OPEN SYSTEM
AS_AUTH_KEY, // STA has been authenticated using SHARED KEY
AS_AUTHENTICATING // STA is waiting for AUTH seq#3 using SHARED KEY
} AUTH_STATE;
//for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
typedef enum _ApWpaState {
AS_NOTUSE, // 0
AS_DISCONNECT, // 1
AS_DISCONNECTED, // 2
AS_INITIALIZE, // 3
AS_AUTHENTICATION, // 4
AS_AUTHENTICATION2, // 5
AS_INITPMK, // 6
AS_INITPSK, // 7
AS_PTKSTART, // 8
AS_PTKINIT_NEGOTIATING, // 9
AS_PTKINITDONE, // 10
AS_UPDATEKEYS, // 11
AS_INTEGRITY_FAILURE, // 12
AS_KEYUPDATE, // 13
} AP_WPA_STATE;
// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
typedef enum _GTKState {
REKEY_NEGOTIATING,
REKEY_ESTABLISHED,
KEYERROR,
} GTK_STATE;
// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
typedef enum _WpaGTKState {
SETKEYS,
SETKEYS_DONE,
} WPA_GTK_STATE;
// ====================== end of AP mlme.h ============================
#endif // MLME_H__
#include "../rt2860/mlme.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
oid.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
*/
#ifndef _OID_H_
#define _OID_H_
#define TRUE 1
#define FALSE 0
//
// IEEE 802.11 Structures and definitions
//
#define MAX_TX_POWER_LEVEL 100 /* mW */
#define MAX_RSSI_TRIGGER -10 /* dBm */
#define MIN_RSSI_TRIGGER -200 /* dBm */
#define MAX_FRAG_THRESHOLD 2346 /* byte count */
#define MIN_FRAG_THRESHOLD 256 /* byte count */
#define MAX_RTS_THRESHOLD 2347 /* byte count */
// new types for Media Specific Indications
// Extension channel offset
#define EXTCHA_NONE 0
#define EXTCHA_ABOVE 0x1
#define EXTCHA_BELOW 0x3
// BW
#define BAND_WIDTH_20 0
#define BAND_WIDTH_40 1
#define BAND_WIDTH_BOTH 2
#define BAND_WIDTH_10 3 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
// SHORTGI
#define GAP_INTERVAL_400 1 // only support in HT mode
#define GAP_INTERVAL_800 0
#define GAP_INTERVAL_BOTH 2
#define NdisMediaStateConnected 1
#define NdisMediaStateDisconnected 0
#define NDIS_802_11_LENGTH_SSID 32
#define NDIS_802_11_LENGTH_RATES 8
#define NDIS_802_11_LENGTH_RATES_EX 16
#define MAC_ADDR_LENGTH 6
#define MAX_NUM_OF_CHS 49 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL terminationc
#define MAX_NUMBER_OF_EVENT 10 // entry # in EVENT table
#define MAX_NUMBER_OF_MAC 32 // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
#define MAX_NUMBER_OF_ACL 64
#define MAX_LENGTH_OF_SUPPORT_RATES 12 // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
#define MAX_NUMBER_OF_DLS_ENTRY 4
#define OID_GEN_MACHINE_NAME 0x0001021A
#define RT_QUERY_SIGNAL_CONTEXT 0x0402
#define RT_SET_IAPP_PID 0x0404
#define RT_SET_APD_PID 0x0405
#define RT_SET_DEL_MAC_ENTRY 0x0406
//
// IEEE 802.11 OIDs
//
#define OID_GET_SET_TOGGLE 0x8000
#define OID_802_11_NETWORK_TYPES_SUPPORTED 0x0103
#define OID_802_11_NETWORK_TYPE_IN_USE 0x0104
#define OID_802_11_RSSI_TRIGGER 0x0107
#define RT_OID_802_11_RSSI 0x0108 //rt2860 only , kathy
#define RT_OID_802_11_RSSI_1 0x0109 //rt2860 only , kathy
#define RT_OID_802_11_RSSI_2 0x010A //rt2860 only , kathy
#define OID_802_11_NUMBER_OF_ANTENNAS 0x010B
#define OID_802_11_RX_ANTENNA_SELECTED 0x010C
#define OID_802_11_TX_ANTENNA_SELECTED 0x010D
#define OID_802_11_SUPPORTED_RATES 0x010E
#define OID_802_11_ADD_WEP 0x0112
#define OID_802_11_REMOVE_WEP 0x0113
#define OID_802_11_DISASSOCIATE 0x0114
#define OID_802_11_PRIVACY_FILTER 0x0118
#define OID_802_11_ASSOCIATION_INFORMATION 0x011E
#define OID_802_11_TEST 0x011F
#define RT_OID_802_11_COUNTRY_REGION 0x0507
#define OID_802_11_BSSID_LIST_SCAN 0x0508
#define OID_802_11_SSID 0x0509
#define OID_802_11_BSSID 0x050A
#define RT_OID_802_11_RADIO 0x050B
#define RT_OID_802_11_PHY_MODE 0x050C
#define RT_OID_802_11_STA_CONFIG 0x050D
#define OID_802_11_DESIRED_RATES 0x050E
#define RT_OID_802_11_PREAMBLE 0x050F
#define OID_802_11_WEP_STATUS 0x0510
#define OID_802_11_AUTHENTICATION_MODE 0x0511
#define OID_802_11_INFRASTRUCTURE_MODE 0x0512
#define RT_OID_802_11_RESET_COUNTERS 0x0513
#define OID_802_11_RTS_THRESHOLD 0x0514
#define OID_802_11_FRAGMENTATION_THRESHOLD 0x0515
#define OID_802_11_POWER_MODE 0x0516
#define OID_802_11_TX_POWER_LEVEL 0x0517
#define RT_OID_802_11_ADD_WPA 0x0518
#define OID_802_11_REMOVE_KEY 0x0519
#define OID_802_11_ADD_KEY 0x0520
#define OID_802_11_CONFIGURATION 0x0521
#define OID_802_11_TX_PACKET_BURST 0x0522
#define RT_OID_802_11_QUERY_NOISE_LEVEL 0x0523
#define RT_OID_802_11_EXTRA_INFO 0x0524
#ifdef DBG
#define RT_OID_802_11_HARDWARE_REGISTER 0x0525
#endif
#define OID_802_11_ENCRYPTION_STATUS OID_802_11_WEP_STATUS
#define OID_802_11_DEAUTHENTICATION 0x0526
#define OID_802_11_DROP_UNENCRYPTED 0x0527
#define OID_802_11_MIC_FAILURE_REPORT_FRAME 0x0528
// For 802.1x daemin using to require current driver configuration
#define OID_802_11_RADIUS_QUERY_SETTING 0x0540
#define RT_OID_DEVICE_NAME 0x0607
#define RT_OID_VERSION_INFO 0x0608
#define OID_802_11_BSSID_LIST 0x0609
#define OID_802_3_CURRENT_ADDRESS 0x060A
#define OID_GEN_MEDIA_CONNECT_STATUS 0x060B
#define RT_OID_802_11_QUERY_LINK_STATUS 0x060C
#define OID_802_11_RSSI 0x060D
#define OID_802_11_STATISTICS 0x060E
#define OID_GEN_RCV_OK 0x060F
#define OID_GEN_RCV_NO_BUFFER 0x0610
#define RT_OID_802_11_QUERY_EEPROM_VERSION 0x0611
#define RT_OID_802_11_QUERY_FIRMWARE_VERSION 0x0612
#define RT_OID_802_11_QUERY_LAST_RX_RATE 0x0613
#define RT_OID_802_11_TX_POWER_LEVEL_1 0x0614
#define RT_OID_802_11_QUERY_PIDVID 0x0615
#define OID_SET_COUNTERMEASURES 0x0616
#define OID_802_11_SET_IEEE8021X 0x0617
#define OID_802_11_SET_IEEE8021X_REQUIRE_KEY 0x0618
#define OID_802_11_PMKID 0x0620
#define RT_OID_WPA_SUPPLICANT_SUPPORT 0x0621
#define RT_OID_WE_VERSION_COMPILED 0x0622
#define RT_OID_NEW_DRIVER 0x0623
//rt2860 , kathy
#define RT_OID_802_11_SNR_0 0x0630
#define RT_OID_802_11_SNR_1 0x0631
#define RT_OID_802_11_QUERY_LAST_TX_RATE 0x0632
#define RT_OID_802_11_QUERY_HT_PHYMODE 0x0633
#define RT_OID_802_11_SET_HT_PHYMODE 0x0634
#define OID_802_11_RELOAD_DEFAULTS 0x0635
#define RT_OID_802_11_QUERY_APSD_SETTING 0x0636
#define RT_OID_802_11_SET_APSD_SETTING 0x0637
#define RT_OID_802_11_QUERY_APSD_PSM 0x0638
#define RT_OID_802_11_SET_APSD_PSM 0x0639
#define RT_OID_802_11_QUERY_DLS 0x063A
#define RT_OID_802_11_SET_DLS 0x063B
#define RT_OID_802_11_QUERY_DLS_PARAM 0x063C
#define RT_OID_802_11_SET_DLS_PARAM 0x063D
#define RT_OID_802_11_QUERY_WMM 0x063E
#define RT_OID_802_11_SET_WMM 0x063F
#define RT_OID_802_11_QUERY_IMME_BA_CAP 0x0640
#define RT_OID_802_11_SET_IMME_BA_CAP 0x0641
#define RT_OID_802_11_QUERY_BATABLE 0x0642
#define RT_OID_802_11_ADD_IMME_BA 0x0643
#define RT_OID_802_11_TEAR_IMME_BA 0x0644
#define RT_OID_DRIVER_DEVICE_NAME 0x0645
#define RT_OID_802_11_QUERY_DAT_HT_PHYMODE 0x0646
#define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT 0x0647
// Ralink defined OIDs
// Dennis Lee move to platform specific
#define RT_OID_802_11_BSSID (OID_GET_SET_TOGGLE | OID_802_11_BSSID)
#define RT_OID_802_11_SSID (OID_GET_SET_TOGGLE | OID_802_11_SSID)
#define RT_OID_802_11_INFRASTRUCTURE_MODE (OID_GET_SET_TOGGLE | OID_802_11_INFRASTRUCTURE_MODE)
#define RT_OID_802_11_ADD_WEP (OID_GET_SET_TOGGLE | OID_802_11_ADD_WEP)
#define RT_OID_802_11_ADD_KEY (OID_GET_SET_TOGGLE | OID_802_11_ADD_KEY)
#define RT_OID_802_11_REMOVE_WEP (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_WEP)
#define RT_OID_802_11_REMOVE_KEY (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_KEY)
#define RT_OID_802_11_DISASSOCIATE (OID_GET_SET_TOGGLE | OID_802_11_DISASSOCIATE)
#define RT_OID_802_11_AUTHENTICATION_MODE (OID_GET_SET_TOGGLE | OID_802_11_AUTHENTICATION_MODE)
#define RT_OID_802_11_PRIVACY_FILTER (OID_GET_SET_TOGGLE | OID_802_11_PRIVACY_FILTER)
#define RT_OID_802_11_BSSID_LIST_SCAN (OID_GET_SET_TOGGLE | OID_802_11_BSSID_LIST_SCAN)
#define RT_OID_802_11_WEP_STATUS (OID_GET_SET_TOGGLE | OID_802_11_WEP_STATUS)
#define RT_OID_802_11_RELOAD_DEFAULTS (OID_GET_SET_TOGGLE | OID_802_11_RELOAD_DEFAULTS)
#define RT_OID_802_11_NETWORK_TYPE_IN_USE (OID_GET_SET_TOGGLE | OID_802_11_NETWORK_TYPE_IN_USE)
#define RT_OID_802_11_TX_POWER_LEVEL (OID_GET_SET_TOGGLE | OID_802_11_TX_POWER_LEVEL)
#define RT_OID_802_11_RSSI_TRIGGER (OID_GET_SET_TOGGLE | OID_802_11_RSSI_TRIGGER)
#define RT_OID_802_11_FRAGMENTATION_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_FRAGMENTATION_THRESHOLD)
#define RT_OID_802_11_RTS_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_RTS_THRESHOLD)
#define RT_OID_802_11_RX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_RX_ANTENNA_SELECTED)
#define RT_OID_802_11_TX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_TX_ANTENNA_SELECTED)
#define RT_OID_802_11_SUPPORTED_RATES (OID_GET_SET_TOGGLE | OID_802_11_SUPPORTED_RATES)
#define RT_OID_802_11_DESIRED_RATES (OID_GET_SET_TOGGLE | OID_802_11_DESIRED_RATES)
#define RT_OID_802_11_CONFIGURATION (OID_GET_SET_TOGGLE | OID_802_11_CONFIGURATION)
#define RT_OID_802_11_POWER_MODE (OID_GET_SET_TOGGLE | OID_802_11_POWER_MODE)
typedef enum _NDIS_802_11_STATUS_TYPE
{
Ndis802_11StatusType_Authentication,
Ndis802_11StatusType_MediaStreamMode,
Ndis802_11StatusType_PMKID_CandidateList,
Ndis802_11StatusTypeMax // not a real type, defined as an upper bound
} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
typedef UCHAR NDIS_802_11_MAC_ADDRESS[6];
typedef struct _NDIS_802_11_STATUS_INDICATION
{
NDIS_802_11_STATUS_TYPE StatusType;
} NDIS_802_11_STATUS_INDICATION, *PNDIS_802_11_STATUS_INDICATION;
// mask for authentication/integrity fields
#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f
#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01
#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02
#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E
typedef struct _NDIS_802_11_AUTHENTICATION_REQUEST
{
ULONG Length; // Length of structure
NDIS_802_11_MAC_ADDRESS Bssid;
ULONG Flags;
} NDIS_802_11_AUTHENTICATION_REQUEST, *PNDIS_802_11_AUTHENTICATION_REQUEST;
//Added new types for PMKID Candidate lists.
typedef struct _PMKID_CANDIDATE {
NDIS_802_11_MAC_ADDRESS BSSID;
ULONG Flags;
} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
typedef struct _NDIS_802_11_PMKID_CANDIDATE_LIST
{
ULONG Version; // Version of the structure
ULONG NumCandidates; // No. of pmkid candidates
PMKID_CANDIDATE CandidateList[1];
} NDIS_802_11_PMKID_CANDIDATE_LIST, *PNDIS_802_11_PMKID_CANDIDATE_LIST;
//Flags for PMKID Candidate list structure
#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
// Added new types for OFDM 5G and 2.4G
typedef enum _NDIS_802_11_NETWORK_TYPE
{
Ndis802_11FH,
Ndis802_11DS,
Ndis802_11OFDM5,
Ndis802_11OFDM5_N,
Ndis802_11OFDM24,
Ndis802_11OFDM24_N,
Ndis802_11Automode,
Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
typedef struct _NDIS_802_11_NETWORK_TYPE_LIST
{
UINT NumberOfItems; // in list below, at least 1
NDIS_802_11_NETWORK_TYPE NetworkType [1];
} NDIS_802_11_NETWORK_TYPE_LIST, *PNDIS_802_11_NETWORK_TYPE_LIST;
typedef enum _NDIS_802_11_POWER_MODE
{
Ndis802_11PowerModeCAM,
Ndis802_11PowerModeMAX_PSP,
Ndis802_11PowerModeFast_PSP,
Ndis802_11PowerModeLegacy_PSP,
Ndis802_11PowerModeMax // not a real mode, defined as an upper bound
} NDIS_802_11_POWER_MODE, *PNDIS_802_11_POWER_MODE;
typedef ULONG NDIS_802_11_TX_POWER_LEVEL; // in milliwatts
//
// Received Signal Strength Indication
//
typedef LONG NDIS_802_11_RSSI; // in dBm
typedef struct _NDIS_802_11_CONFIGURATION_FH
{
ULONG Length; // Length of structure
ULONG HopPattern; // As defined by 802.11, MSB set
ULONG HopSet; // to one if non-802.11
ULONG DwellTime; // units are Kusec
} NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
typedef struct _NDIS_802_11_CONFIGURATION
{
ULONG Length; // Length of structure
ULONG BeaconPeriod; // units are Kusec
ULONG ATIMWindow; // units are Kusec
ULONG DSConfig; // Frequency, units are kHz
NDIS_802_11_CONFIGURATION_FH FHConfig;
} NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
typedef struct _NDIS_802_11_STATISTICS
{
ULONG Length; // Length of structure
LARGE_INTEGER TransmittedFragmentCount;
LARGE_INTEGER MulticastTransmittedFrameCount;
LARGE_INTEGER FailedCount;
LARGE_INTEGER RetryCount;
LARGE_INTEGER MultipleRetryCount;
LARGE_INTEGER RTSSuccessCount;
LARGE_INTEGER RTSFailureCount;
LARGE_INTEGER ACKFailureCount;
LARGE_INTEGER FrameDuplicateCount;
LARGE_INTEGER ReceivedFragmentCount;
LARGE_INTEGER MulticastReceivedFrameCount;
LARGE_INTEGER FCSErrorCount;
LARGE_INTEGER TKIPLocalMICFailures;
LARGE_INTEGER TKIPRemoteMICErrors;
LARGE_INTEGER TKIPICVErrors;
LARGE_INTEGER TKIPCounterMeasuresInvoked;
LARGE_INTEGER TKIPReplays;
LARGE_INTEGER CCMPFormatErrors;
LARGE_INTEGER CCMPReplays;
LARGE_INTEGER CCMPDecryptErrors;
LARGE_INTEGER FourWayHandshakeFailures;
} NDIS_802_11_STATISTICS, *PNDIS_802_11_STATISTICS;
typedef ULONG NDIS_802_11_KEY_INDEX;
typedef ULONGLONG NDIS_802_11_KEY_RSC;
#define MAX_RADIUS_SRV_NUM 2 // 802.1x failover number
typedef struct PACKED _RADIUS_SRV_INFO {
UINT32 radius_ip;
UINT32 radius_port;
UCHAR radius_key[64];
UCHAR radius_key_len;
} RADIUS_SRV_INFO, *PRADIUS_SRV_INFO;
typedef struct PACKED _RADIUS_KEY_INFO
{
UCHAR radius_srv_num;
RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
UCHAR ieee8021xWEP; // dynamic WEP
UCHAR key_index;
UCHAR key_length; // length of key in bytes
UCHAR key_material[13];
} RADIUS_KEY_INFO, *PRADIUS_KEY_INFO;
// It's used by 802.1x daemon to require relative configuration
typedef struct PACKED _RADIUS_CONF
{
UINT32 Length; // Length of this structure
UCHAR mbss_num; // indicate multiple BSS number
UINT32 own_ip_addr;
UINT32 retry_interval;
UINT32 session_timeout_interval;
UCHAR EAPifname[IFNAMSIZ];
UCHAR EAPifname_len;
UCHAR PreAuthifname[IFNAMSIZ];
UCHAR PreAuthifname_len;
RADIUS_KEY_INFO RadiusInfo[8/*MAX_MBSSID_NUM*/];
} RADIUS_CONF, *PRADIUS_CONF;
// Key mapping keys require a BSSID
typedef struct _NDIS_802_11_KEY
{
UINT Length; // Length of this structure
UINT KeyIndex;
UINT KeyLength; // length of key in bytes
NDIS_802_11_MAC_ADDRESS BSSID;
NDIS_802_11_KEY_RSC KeyRSC;
UCHAR KeyMaterial[1]; // variable length depending on above field
} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
typedef struct _NDIS_802_11_REMOVE_KEY
{
UINT Length; // Length of this structure
UINT KeyIndex;
NDIS_802_11_MAC_ADDRESS BSSID;
} NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
typedef struct _NDIS_802_11_WEP
{
UINT Length; // Length of this structure
UINT KeyIndex; // 0 is the per-client key, 1-N are the
// global keys
UINT KeyLength; // length of key in bytes
UCHAR KeyMaterial[1];// variable length depending on above field
} NDIS_802_11_WEP, *PNDIS_802_11_WEP;
typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE
{
Ndis802_11IBSS,
Ndis802_11Infrastructure,
Ndis802_11AutoUnknown,
Ndis802_11Monitor,
Ndis802_11InfrastructureMax // Not a real value, defined as upper bound
} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
// Add new authentication modes
typedef enum _NDIS_802_11_AUTHENTICATION_MODE
{
Ndis802_11AuthModeOpen,
Ndis802_11AuthModeShared,
Ndis802_11AuthModeAutoSwitch,
Ndis802_11AuthModeWPA,
Ndis802_11AuthModeWPAPSK,
Ndis802_11AuthModeWPANone,
Ndis802_11AuthModeWPA2,
Ndis802_11AuthModeWPA2PSK,
Ndis802_11AuthModeWPA1WPA2,
Ndis802_11AuthModeWPA1PSKWPA2PSK,
Ndis802_11AuthModeMax // Not a real mode, defined as upper bound
} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
typedef UCHAR NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; // Set of 8 data rates
typedef UCHAR NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; // Set of 16 data rates
typedef struct PACKED _NDIS_802_11_SSID
{
UINT SsidLength; // length of SSID field below, in bytes;
// this can be zero.
UCHAR Ssid[NDIS_802_11_LENGTH_SSID]; // SSID information field
} NDIS_802_11_SSID, *PNDIS_802_11_SSID;
typedef struct PACKED _NDIS_WLAN_BSSID
{
ULONG Length; // Length of this structure
NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
UCHAR Reserved[2];
NDIS_802_11_SSID Ssid; // SSID
ULONG Privacy; // WEP encryption requirement
NDIS_802_11_RSSI Rssi; // receive signal strength in dBm
NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
NDIS_802_11_CONFIGURATION Configuration;
NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
NDIS_802_11_RATES SupportedRates;
} NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;
typedef struct PACKED _NDIS_802_11_BSSID_LIST
{
UINT NumberOfItems; // in list below, at least 1
NDIS_WLAN_BSSID Bssid[1];
} NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;
// Added Capabilities, IELength and IEs for each BSSID
typedef struct PACKED _NDIS_WLAN_BSSID_EX
{
ULONG Length; // Length of this structure
NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
UCHAR Reserved[2];
NDIS_802_11_SSID Ssid; // SSID
UINT Privacy; // WEP encryption requirement
NDIS_802_11_RSSI Rssi; // receive signal
// strength in dBm
NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
NDIS_802_11_CONFIGURATION Configuration;
NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
NDIS_802_11_RATES_EX SupportedRates;
ULONG IELength;
UCHAR IEs[1];
} NDIS_WLAN_BSSID_EX, *PNDIS_WLAN_BSSID_EX;
typedef struct PACKED _NDIS_802_11_BSSID_LIST_EX
{
UINT NumberOfItems; // in list below, at least 1
NDIS_WLAN_BSSID_EX Bssid[1];
} NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
typedef struct PACKED _NDIS_802_11_FIXED_IEs
{
UCHAR Timestamp[8];
USHORT BeaconInterval;
USHORT Capabilities;
} NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
typedef struct _NDIS_802_11_VARIABLE_IEs
{
UCHAR ElementID;
UCHAR Length; // Number of bytes in data field
UCHAR data[1];
} NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
typedef ULONG NDIS_802_11_FRAGMENTATION_THRESHOLD;
typedef ULONG NDIS_802_11_RTS_THRESHOLD;
typedef ULONG NDIS_802_11_ANTENNA;
typedef enum _NDIS_802_11_PRIVACY_FILTER
{
Ndis802_11PrivFilterAcceptAll,
Ndis802_11PrivFilter8021xWEP
} NDIS_802_11_PRIVACY_FILTER, *PNDIS_802_11_PRIVACY_FILTER;
// Added new encryption types
// Also aliased typedef to new name
typedef enum _NDIS_802_11_WEP_STATUS
{
Ndis802_11WEPEnabled,
Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
Ndis802_11WEPDisabled,
Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
Ndis802_11WEPKeyAbsent,
Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
Ndis802_11WEPNotSupported,
Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
Ndis802_11Encryption2Enabled,
Ndis802_11Encryption2KeyAbsent,
Ndis802_11Encryption3Enabled,
Ndis802_11Encryption3KeyAbsent,
Ndis802_11Encryption4Enabled, // TKIP or AES mix
Ndis802_11Encryption4KeyAbsent,
#ifndef RT30xx
Ndis802_11GroupWEP40Enabled,
Ndis802_11GroupWEP104Enabled,
#endif
} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
typedef enum _NDIS_802_11_RELOAD_DEFAULTS
{
Ndis802_11ReloadWEPKeys
} NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
#define NDIS_802_11_AI_REQFI_CAPABILITIES 1
#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2
#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4
#define NDIS_802_11_AI_RESFI_CAPABILITIES 1
#define NDIS_802_11_AI_RESFI_STATUSCODE 2
#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4
typedef struct _NDIS_802_11_AI_REQFI
{
USHORT Capabilities;
USHORT ListenInterval;
NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
typedef struct _NDIS_802_11_AI_RESFI
{
USHORT Capabilities;
USHORT StatusCode;
USHORT AssociationId;
} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
{
ULONG Length;
USHORT AvailableRequestFixedIEs;
NDIS_802_11_AI_REQFI RequestFixedIEs;
ULONG RequestIELength;
ULONG OffsetRequestIEs;
USHORT AvailableResponseFixedIEs;
NDIS_802_11_AI_RESFI ResponseFixedIEs;
ULONG ResponseIELength;
ULONG OffsetResponseIEs;
} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
typedef struct _NDIS_802_11_AUTHENTICATION_EVENT
{
NDIS_802_11_STATUS_INDICATION Status;
NDIS_802_11_AUTHENTICATION_REQUEST Request[1];
} NDIS_802_11_AUTHENTICATION_EVENT, *PNDIS_802_11_AUTHENTICATION_EVENT;
// 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE
typedef enum _NDIS_802_11_MEDIA_STREAM_MODE
{
Ndis802_11MediaStreamOff,
Ndis802_11MediaStreamOn,
} NDIS_802_11_MEDIA_STREAM_MODE, *PNDIS_802_11_MEDIA_STREAM_MODE;
// PMKID Structures
typedef UCHAR NDIS_802_11_PMKID_VALUE[16];
typedef struct _BSSID_INFO
{
NDIS_802_11_MAC_ADDRESS BSSID;
NDIS_802_11_PMKID_VALUE PMKID;
} BSSID_INFO, *PBSSID_INFO;
typedef struct _NDIS_802_11_PMKID
{
UINT Length;
UINT BSSIDInfoCount;
BSSID_INFO BSSIDInfo[1];
} NDIS_802_11_PMKID, *PNDIS_802_11_PMKID;
typedef struct _NDIS_802_11_AUTHENTICATION_ENCRYPTION
{
NDIS_802_11_AUTHENTICATION_MODE AuthModeSupported;
NDIS_802_11_ENCRYPTION_STATUS EncryptStatusSupported;
} NDIS_802_11_AUTHENTICATION_ENCRYPTION, *PNDIS_802_11_AUTHENTICATION_ENCRYPTION;
typedef struct _NDIS_802_11_CAPABILITY
{
ULONG Length;
ULONG Version;
ULONG NoOfPMKIDs;
ULONG NoOfAuthEncryptPairsSupported;
NDIS_802_11_AUTHENTICATION_ENCRYPTION AuthenticationEncryptionSupported[1];
} NDIS_802_11_CAPABILITY, *PNDIS_802_11_CAPABILITY;
#if WIRELESS_EXT <= 11
#ifndef SIOCDEVPRIVATE
#define SIOCDEVPRIVATE 0x8BE0
#endif
#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
#endif
#ifdef RT30xx
#define RT_PRIV_IOCTL_EXT (SIOCIWFIRSTPRIV + 0x01) // Sync. with AP for wsc upnp daemon
#endif
#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
#ifdef DBG
#define RTPRIV_IOCTL_BBP (SIOCIWFIRSTPRIV + 0x03)
#define RTPRIV_IOCTL_MAC (SIOCIWFIRSTPRIV + 0x05)
#ifdef RT30xx
#define RTPRIV_IOCTL_RF (SIOCIWFIRSTPRIV + 0x13)
#endif
#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
#endif
#define RTPRIV_IOCTL_STATISTICS (SIOCIWFIRSTPRIV + 0x09)
#define RTPRIV_IOCTL_ADD_PMKID_CACHE (SIOCIWFIRSTPRIV + 0x0A)
#define RTPRIV_IOCTL_RADIUS_DATA (SIOCIWFIRSTPRIV + 0x0C)
#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E) // Sync. with RT61 (for wpa_supplicant)
#define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F)
#define RTPRIV_IOCTL_SHOW (SIOCIWFIRSTPRIV + 0x11)
enum {
SHOW_CONN_STATUS = 4,
SHOW_DRVIER_VERION = 5,
SHOW_BA_INFO = 6,
SHOW_DESC_INFO = 7,
#ifdef RT2870
SHOW_RXBULK_INFO = 8,
SHOW_TXBULK_INFO = 9,
#endif // RT2870 //
RAIO_OFF = 10,
RAIO_ON = 11,
SHOW_CFG_VALUE = 20,
#ifndef RT30xx
SHOW_ADHOC_ENTRY_INFO = 21,
#endif
};
#define OID_802_11_BUILD_CHANNEL_EX 0x0714
#define OID_802_11_GET_CH_LIST 0x0715
#define OID_802_11_GET_COUNTRY_CODE 0x0716
#define OID_802_11_GET_CHANNEL_GEOGRAPHY 0x0717
#ifdef RT30xx
#define RT_OID_WSC_SET_PASSPHRASE 0x0740 // passphrase for wpa(2)-psk
#define RT_OID_WSC_DRIVER_AUTO_CONNECT 0x0741
#define RT_OID_WSC_QUERY_DEFAULT_PROFILE 0x0742
#define RT_OID_WSC_SET_CONN_BY_PROFILE_INDEX 0x0743
#define RT_OID_WSC_SET_ACTION 0x0744
#define RT_OID_WSC_SET_SSID 0x0745
#define RT_OID_WSC_SET_PIN_CODE 0x0746
#define RT_OID_WSC_SET_MODE 0x0747 // PIN or PBC
#define RT_OID_WSC_SET_CONF_MODE 0x0748 // Enrollee or Registrar
#define RT_OID_WSC_SET_PROFILE 0x0749
#define RT_OID_802_11_WSC_QUERY_PROFILE 0x0750
// for consistency with RT61
#define RT_OID_WSC_QUERY_STATUS 0x0751
#define RT_OID_WSC_PIN_CODE 0x0752
#define RT_OID_WSC_UUID 0x0753
#define RT_OID_WSC_SET_SELECTED_REGISTRAR 0x0754
#define RT_OID_WSC_EAPMSG 0x0755
#define RT_OID_WSC_MANUFACTURER 0x0756
#define RT_OID_WSC_MODEL_NAME 0x0757
#define RT_OID_WSC_MODEL_NO 0x0758
#define RT_OID_WSC_SERIAL_NO 0x0759
#define RT_OID_WSC_MAC_ADDRESS 0x0760
#endif
#ifdef LLTD_SUPPORT
// for consistency with RT61
#define RT_OID_GET_PHY_MODE 0x761
#endif // LLTD_SUPPORT //
#ifdef RT30xx
// New for MeetingHouse Api support
#define OID_MH_802_1X_SUPPORTED 0xFFEDC100
#endif
// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
typedef union _HTTRANSMIT_SETTING {
struct {
USHORT MCS:7; // MCS
USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
USHORT ShortGI:1;
USHORT STBC:2; //SPACE
USHORT rsv:2;
USHORT TxBF:1;
USHORT MODE:2; // Use definition MODE_xxx.
} field;
USHORT word;
} HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
typedef enum _RT_802_11_PREAMBLE {
Rt802_11PreambleLong,
Rt802_11PreambleShort,
Rt802_11PreambleAuto
} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
// Only for STA, need to sync with AP
typedef enum _RT_802_11_PHY_MODE {
PHY_11BG_MIXED = 0,
PHY_11B,
PHY_11A,
PHY_11ABG_MIXED,
PHY_11G,
PHY_11ABGN_MIXED, // both band 5
PHY_11N_2_4G, // 11n-only with 2.4G band 6
PHY_11GN_MIXED, // 2.4G band 7
PHY_11AN_MIXED, // 5G band 8
PHY_11BGN_MIXED, // if check 802.11b. 9
PHY_11AGN_MIXED, // if check 802.11b. 10
PHY_11N_5G, // 11n-only with 5G band 11
} RT_802_11_PHY_MODE;
// put all proprietery for-query objects here to reduce # of Query_OID
typedef struct _RT_802_11_LINK_STATUS {
ULONG CurrTxRate; // in units of 0.5Mbps
ULONG ChannelQuality; // 0..100 %
ULONG TxByteCount; // both ok and fail
ULONG RxByteCount; // both ok and fail
ULONG CentralChannel; // 40MHz central channel number
} RT_802_11_LINK_STATUS, *PRT_802_11_LINK_STATUS;
typedef struct _RT_802_11_EVENT_LOG {
LARGE_INTEGER SystemTime; // timestammp via NdisGetCurrentSystemTime()
UCHAR Addr[MAC_ADDR_LENGTH];
USHORT Event; // EVENT_xxx
} RT_802_11_EVENT_LOG, *PRT_802_11_EVENT_LOG;
typedef struct _RT_802_11_EVENT_TABLE {
ULONG Num;
ULONG Rsv; // to align Log[] at LARGE_INEGER boundary
RT_802_11_EVENT_LOG Log[MAX_NUMBER_OF_EVENT];
} RT_802_11_EVENT_TABLE, PRT_802_11_EVENT_TABLE;
// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
typedef union _MACHTTRANSMIT_SETTING {
struct {
USHORT MCS:7; // MCS
USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
USHORT ShortGI:1;
USHORT STBC:2; //SPACE
USHORT rsv:3;
USHORT MODE:2; // Use definition MODE_xxx.
} field;
USHORT word;
} MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
typedef struct _RT_802_11_MAC_ENTRY {
UCHAR Addr[MAC_ADDR_LENGTH];
UCHAR Aid;
UCHAR Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE
UCHAR MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
CHAR AvgRssi0;
CHAR AvgRssi1;
CHAR AvgRssi2;
UINT32 ConnectedTime;
MACHTTRANSMIT_SETTING TxRate;
} RT_802_11_MAC_ENTRY, *PRT_802_11_MAC_ENTRY;
typedef struct _RT_802_11_MAC_TABLE {
ULONG Num;
RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
} RT_802_11_MAC_TABLE, *PRT_802_11_MAC_TABLE;
// structure for query/set hardware register - MAC, BBP, RF register
typedef struct _RT_802_11_HARDWARE_REGISTER {
ULONG HardwareType; // 0:MAC, 1:BBP, 2:RF register, 3:EEPROM
ULONG Offset; // Q/S register offset addr
ULONG Data; // R/W data buffer
} RT_802_11_HARDWARE_REGISTER, *PRT_802_11_HARDWARE_REGISTER;
typedef struct _RT_802_11_AP_CONFIG {
ULONG EnableTxBurst; // 0-disable, 1-enable
ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
ULONG IsolateInterStaTraffic; // 0-disable, 1-enable isolation
ULONG HideSsid; // 0-disable, 1-enable hiding
ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time
ULONG Rsv1; // must be 0
ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
} RT_802_11_AP_CONFIG, *PRT_802_11_AP_CONFIG;
// structure to query/set STA_CONFIG
typedef struct _RT_802_11_STA_CONFIG {
ULONG EnableTxBurst; // 0-disable, 1-enable
ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time when applicable
ULONG AdhocMode; // 0-11b rates only (WIFI spec), 1 - b/g mixed, 2 - g only
ULONG HwRadioStatus; // 0-OFF, 1-ON, default is 1, Read-Only
ULONG Rsv1; // must be 0
ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
} RT_802_11_STA_CONFIG, *PRT_802_11_STA_CONFIG;
//
// For OID Query or Set about BA structure
//
typedef struct _OID_BACAP_STRUC {
UCHAR RxBAWinLimit;
UCHAR TxBAWinLimit;
UCHAR Policy; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
UCHAR MpduDensity; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
UCHAR AmsduEnable; //Enable AMSDU transmisstion
UCHAR AmsduSize; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
UCHAR MMPSmode; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
BOOLEAN AutoBA; // Auto BA will automatically
} OID_BACAP_STRUC, *POID_BACAP_STRUC;
typedef struct _RT_802_11_ACL_ENTRY {
UCHAR Addr[MAC_ADDR_LENGTH];
USHORT Rsv;
} RT_802_11_ACL_ENTRY, *PRT_802_11_ACL_ENTRY;
typedef struct PACKED _RT_802_11_ACL {
ULONG Policy; // 0-disable, 1-positive list, 2-negative list
ULONG Num;
RT_802_11_ACL_ENTRY Entry[MAX_NUMBER_OF_ACL];
} RT_802_11_ACL, *PRT_802_11_ACL;
typedef struct _RT_802_11_WDS {
ULONG Num;
NDIS_802_11_MAC_ADDRESS Entry[24/*MAX_NUM_OF_WDS_LINK*/];
ULONG KeyLength;
UCHAR KeyMaterial[32];
} RT_802_11_WDS, *PRT_802_11_WDS;
typedef struct _RT_802_11_TX_RATES_ {
UCHAR SupRateLen;
UCHAR SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
UCHAR ExtRateLen;
UCHAR ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
} RT_802_11_TX_RATES, *PRT_802_11_TX_RATES;
// Definition of extra information code
#define GENERAL_LINK_UP 0x0 // Link is Up
#define GENERAL_LINK_DOWN 0x1 // Link is Down
#define HW_RADIO_OFF 0x2 // Hardware radio off
#define SW_RADIO_OFF 0x3 // Software radio off
#define AUTH_FAIL 0x4 // Open authentication fail
#define AUTH_FAIL_KEYS 0x5 // Shared authentication fail
#define ASSOC_FAIL 0x6 // Association failed
#define EAP_MIC_FAILURE 0x7 // Deauthencation because MIC failure
#define EAP_4WAY_TIMEOUT 0x8 // Deauthencation on 4-way handshake timeout
#define EAP_GROUP_KEY_TIMEOUT 0x9 // Deauthencation on group key handshake timeout
#define EAP_SUCCESS 0xa // EAP succeed
#define DETECT_RADAR_SIGNAL 0xb // Radar signal occur in current channel
#define EXTRA_INFO_MAX 0xb // Indicate Last OID
#define EXTRA_INFO_CLEAR 0xffffffff
// This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use.
typedef struct {
RT_802_11_PHY_MODE PhyMode; //
UCHAR TransmitNo;
UCHAR HtMode; //HTMODE_GF or HTMODE_MM
UCHAR ExtOffset; //extension channel above or below
UCHAR MCS;
UCHAR BW;
UCHAR STBC;
UCHAR SHORTGI;
UCHAR rsv;
} OID_SET_HT_PHYMODE, *POID_SET_HT_PHYMODE;
#ifdef LLTD_SUPPORT
typedef struct _RT_LLTD_ASSOICATION_ENTRY {
UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
unsigned short MOR; // maximum operational rate
UCHAR phyMode;
} RT_LLTD_ASSOICATION_ENTRY, *PRT_LLTD_ASSOICATION_ENTRY;
typedef struct _RT_LLTD_ASSOICATION_TABLE {
unsigned int Num;
RT_LLTD_ASSOICATION_ENTRY Entry[MAX_NUMBER_OF_MAC];
} RT_LLTD_ASSOICATION_TABLE, *PRT_LLTD_ASSOICATION_TABLE;
#endif // LLTD_SUPPORT //
#define MAX_CUSTOM_LEN 128
typedef enum _RT_802_11_D_CLIENT_MODE
{
Rt802_11_D_None,
Rt802_11_D_Flexible,
Rt802_11_D_Strict,
} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
typedef struct _RT_CHANNEL_LIST_INFO
{
UCHAR ChannelList[MAX_NUM_OF_CHS]; // list all supported channels for site survey
UCHAR ChannelListNum; // number of channel in ChannelList[]
} RT_CHANNEL_LIST_INFO, *PRT_CHANNEL_LIST_INFO;
// WSC configured credential
typedef struct _WSC_CREDENTIAL
{
NDIS_802_11_SSID SSID; // mandatory
USHORT AuthType; // mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk
USHORT EncrType; // mandatory, 1: none, 2: wep, 4: tkip, 8: aes
UCHAR Key[64]; // mandatory, Maximum 64 byte
USHORT KeyLength;
UCHAR MacAddr[6]; // mandatory, AP MAC address
UCHAR KeyIndex; // optional, default is 1
UCHAR Rsvd[3]; // Make alignment
} WSC_CREDENTIAL, *PWSC_CREDENTIAL;
// WSC configured profiles
typedef struct _WSC_PROFILE
{
UINT ProfileCnt;
WSC_CREDENTIAL Profile[8]; // Support up to 8 profiles
} WSC_PROFILE, *PWSC_PROFILE;
#endif // _OID_H_
#include "../rt2860/oid.h"
/*
*************************************************************************
* 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:
rt28xx.h
Abstract:
RT28xx ASIC related definition & structures
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Jan Lee Jan-3-2006 created for RT2860c
*/
#ifndef __RT28XX_H__
#define __RT28XX_H__
//
// PCI registers - base address 0x0000
//
#define PCI_CFG 0x0000
#define PCI_EECTRL 0x0004
#define PCI_MCUCTRL 0x0008
#ifdef RT30xx
#define OPT_14 0x114
typedef int NTSTATUS;
#define RETRY_LIMIT 10
#define STATUS_SUCCESS 0x00
#define STATUS_UNSUCCESSFUL 0x01
#endif
//
// SCH/DMA registers - base address 0x0200
//
// INT_SOURCE_CSR: Interrupt source register. Write one to clear corresponding bit
//
#define DMA_CSR0 0x200
#define INT_SOURCE_CSR 0x200
typedef union _INT_SOURCE_CSR_STRUC {
struct {
UINT32 RxDelayINT:1;
UINT32 TxDelayINT:1;
UINT32 RxDone:1;
UINT32 Ac0DmaDone:1;//4
UINT32 Ac1DmaDone:1;
UINT32 Ac2DmaDone:1;
UINT32 Ac3DmaDone:1;
UINT32 HccaDmaDone:1; // bit7
UINT32 MgmtDmaDone:1;
UINT32 MCUCommandINT:1;//bit 9
UINT32 RxTxCoherent:1;
UINT32 TBTTInt:1;
UINT32 PreTBTT:1;
UINT32 TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
UINT32 AutoWakeup:1;//bit14
UINT32 GPTimer:1;
UINT32 RxCoherent:1;//bit16
UINT32 TxCoherent:1;
UINT32 :14;
} field;
UINT32 word;
} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
//
// INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF
//
#define INT_MASK_CSR 0x204
typedef union _INT_MASK_CSR_STRUC {
struct {
UINT32 RXDelay_INT_MSK:1;
UINT32 TxDelay:1;
UINT32 RxDone:1;
UINT32 Ac0DmaDone:1;
UINT32 Ac1DmaDone:1;
UINT32 Ac2DmaDone:1;
UINT32 Ac3DmaDone:1;
UINT32 HccaDmaDone:1;
UINT32 MgmtDmaDone:1;
UINT32 MCUCommandINT:1;
UINT32 :20;
UINT32 RxCoherent:1;
UINT32 TxCoherent:1;
} field;
UINT32 word;
} INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
#define WPDMA_GLO_CFG 0x208
typedef union _WPDMA_GLO_CFG_STRUC {
struct {
UINT32 EnableTxDMA:1;
UINT32 TxDMABusy:1;
UINT32 EnableRxDMA:1;
UINT32 RxDMABusy:1;
UINT32 WPDMABurstSIZE:2;
UINT32 EnTXWriteBackDDONE:1;
UINT32 BigEndian:1;
UINT32 RXHdrScater:8;
UINT32 HDR_SEG_LEN:16;
} field;
UINT32 word;
} WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
#define WPDMA_RST_IDX 0x20c
typedef union _WPDMA_RST_IDX_STRUC {
struct {
UINT32 RST_DTX_IDX0:1;
UINT32 RST_DTX_IDX1:1;
UINT32 RST_DTX_IDX2:1;
UINT32 RST_DTX_IDX3:1;
UINT32 RST_DTX_IDX4:1;
UINT32 RST_DTX_IDX5:1;
UINT32 rsv:10;
UINT32 RST_DRX_IDX0:1;
UINT32 :15;
} field;
UINT32 word;
} WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
#define DELAY_INT_CFG 0x0210
typedef union _DELAY_INT_CFG_STRUC {
struct {
UINT32 RXMAX_PTIME:8;
UINT32 RXMAX_PINT:7;
UINT32 RXDLY_INT_EN:1;
UINT32 TXMAX_PTIME:8;
UINT32 TXMAX_PINT:7;
UINT32 TXDLY_INT_EN:1;
} field;
UINT32 word;
} DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
#define WMM_AIFSN_CFG 0x0214
typedef union _AIFSN_CSR_STRUC {
struct {
UINT32 Aifsn0:4; // for AC_BE
UINT32 Aifsn1:4; // for AC_BK
UINT32 Aifsn2:4; // for AC_VI
UINT32 Aifsn3:4; // for AC_VO
UINT32 Rsv:16;
} field;
UINT32 word;
} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
//
// CWMIN_CSR: CWmin for each EDCA AC
//
#define WMM_CWMIN_CFG 0x0218
typedef union _CWMIN_CSR_STRUC {
struct {
UINT32 Cwmin0:4; // for AC_BE
UINT32 Cwmin1:4; // for AC_BK
UINT32 Cwmin2:4; // for AC_VI
UINT32 Cwmin3:4; // for AC_VO
UINT32 Rsv:16;
} field;
UINT32 word;
} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
//
// CWMAX_CSR: CWmin for each EDCA AC
//
#define WMM_CWMAX_CFG 0x021c
typedef union _CWMAX_CSR_STRUC {
struct {
UINT32 Cwmax0:4; // for AC_BE
UINT32 Cwmax1:4; // for AC_BK
UINT32 Cwmax2:4; // for AC_VI
UINT32 Cwmax3:4; // for AC_VO
UINT32 Rsv:16;
} field;
UINT32 word;
} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
//
// AC_TXOP_CSR0: AC_BK/AC_BE TXOP register
//
#define WMM_TXOP0_CFG 0x0220
typedef union _AC_TXOP_CSR0_STRUC {
struct {
USHORT Ac0Txop; // for AC_BK, in unit of 32us
USHORT Ac1Txop; // for AC_BE, in unit of 32us
} field;
UINT32 word;
} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
//
// AC_TXOP_CSR1: AC_VO/AC_VI TXOP register
//
#define WMM_TXOP1_CFG 0x0224
typedef union _AC_TXOP_CSR1_STRUC {
struct {
USHORT Ac2Txop; // for AC_VI, in unit of 32us
USHORT Ac3Txop; // for AC_VO, in unit of 32us
} field;
UINT32 word;
} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
#define RINGREG_DIFF 0x10
#define GPIO_CTRL_CFG 0x0228 //MAC_CSR13
#define MCU_CMD_CFG 0x022c
#define TX_BASE_PTR0 0x0230 //AC_BK base address
#define TX_MAX_CNT0 0x0234
#define TX_CTX_IDX0 0x0238
#define TX_DTX_IDX0 0x023c
#define TX_BASE_PTR1 0x0240 //AC_BE base address
#define TX_MAX_CNT1 0x0244
#define TX_CTX_IDX1 0x0248
#define TX_DTX_IDX1 0x024c
#define TX_BASE_PTR2 0x0250 //AC_VI base address
#define TX_MAX_CNT2 0x0254
#define TX_CTX_IDX2 0x0258
#define TX_DTX_IDX2 0x025c
#define TX_BASE_PTR3 0x0260 //AC_VO base address
#define TX_MAX_CNT3 0x0264
#define TX_CTX_IDX3 0x0268
#define TX_DTX_IDX3 0x026c
#define TX_BASE_PTR4 0x0270 //HCCA base address
#define TX_MAX_CNT4 0x0274
#define TX_CTX_IDX4 0x0278
#define TX_DTX_IDX4 0x027c
#define TX_BASE_PTR5 0x0280 //MGMT base address
#define TX_MAX_CNT5 0x0284
#define TX_CTX_IDX5 0x0288
#define TX_DTX_IDX5 0x028c
#define TX_MGMTMAX_CNT TX_MAX_CNT5
#define TX_MGMTCTX_IDX TX_CTX_IDX5
#define TX_MGMTDTX_IDX TX_DTX_IDX5
#define RX_BASE_PTR 0x0290 //RX base address
#define RX_MAX_CNT 0x0294
#define RX_CRX_IDX 0x0298
#define RX_DRX_IDX 0x029c
#define USB_DMA_CFG 0x02a0
typedef union _USB_DMA_CFG_STRUC {
struct {
UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
UINT32 RxBulkAggLmt:8; //Rx Bulk Aggregation Limit in unit of 256 bytes
UINT32 phyclear:1; //phy watch dog enable. write 1
UINT32 rsv:2;
UINT32 TxClear:1; //Clear USB DMA TX path
UINT32 TxopHalt:1; //Halt TXOP count down when TX buffer is full.
UINT32 RxBulkAggEn:1; //Enable Rx Bulk Aggregation
UINT32 RxBulkEn:1; //Enable USB DMA Rx
UINT32 TxBulkEn:1; //Enable USB DMA Tx
UINT32 EpoutValid:6; //OUT endpoint data valid
UINT32 RxBusy:1; //USB DMA RX FSM busy
UINT32 TxBusy:1; //USB DMA TX FSM busy
} field;
UINT32 word;
} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
//
// 3 PBF registers
//
//
// Most are for debug. Driver doesn't touch PBF register.
#define PBF_SYS_CTRL 0x0400
#define PBF_CFG 0x0408
#define PBF_MAX_PCNT 0x040C
#define PBF_CTRL 0x0410
#define PBF_INT_STA 0x0414
#define PBF_INT_ENA 0x0418
#define TXRXQ_PCNT 0x0438
#define PBF_DBG 0x043c
#define PBF_CAP_CTRL 0x0440
#ifdef RT30xx
// eFuse registers
#define EFUSE_CTRL 0x0580
#define EFUSE_DATA0 0x0590
#define EFUSE_DATA1 0x0594
#define EFUSE_DATA2 0x0598
#define EFUSE_DATA3 0x059c
#define EFUSE_USAGE_MAP_START 0x2d0
#define EFUSE_USAGE_MAP_END 0x2fc
#define EFUSE_TAG 0x2fe
#define EFUSE_USAGE_MAP_SIZE 45
typedef union _EFUSE_CTRL_STRUC {
struct {
UINT32 EFSROM_AOUT:6;
UINT32 EFSROM_MODE:2;
UINT32 EFSROM_LDO_OFF_TIME:6;
UINT32 EFSROM_LDO_ON_TIME:2;
UINT32 EFSROM_AIN:10;
UINT32 RESERVED:4;
UINT32 EFSROM_KICK:1;
UINT32 SEL_EFUSE:1;
} field;
UINT32 word;
} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
#define LDO_CFG0 0x05d4
#define GPIO_SWITCH 0x05dc
#endif /* RT30xx */
//
// 4 MAC registers
//
//
// 4.1 MAC SYSTEM configuration registers (offset:0x1000)
//
#define MAC_CSR0 0x1000
typedef union _ASIC_VER_ID_STRUC {
struct {
USHORT ASICRev; // reversion : 0
USHORT ASICVer; // version : 2860
} field;
UINT32 word;
} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
#define MAC_SYS_CTRL 0x1004 //MAC_CSR1
#define MAC_ADDR_DW0 0x1008 // MAC ADDR DW0
#define MAC_ADDR_DW1 0x100c // MAC ADDR DW1
//
// MAC_CSR2: STA MAC register 0
//
typedef union _MAC_DW0_STRUC {
struct {
UCHAR Byte0; // MAC address byte 0
UCHAR Byte1; // MAC address byte 1
UCHAR Byte2; // MAC address byte 2
UCHAR Byte3; // MAC address byte 3
} field;
UINT32 word;
} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
//
// MAC_CSR3: STA MAC register 1
//
typedef union _MAC_DW1_STRUC {
struct {
UCHAR Byte4; // MAC address byte 4
UCHAR Byte5; // MAC address byte 5
UCHAR U2MeMask;
UCHAR Rsvd1;
} field;
UINT32 word;
} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
#define MAC_BSSID_DW0 0x1010 // MAC BSSID DW0
#define MAC_BSSID_DW1 0x1014 // MAC BSSID DW1
//
// MAC_CSR5: BSSID register 1
//
typedef union _MAC_CSR5_STRUC {
struct {
UCHAR Byte4; // BSSID byte 4
UCHAR Byte5; // BSSID byte 5
USHORT BssIdMask:2; // 0: one BSSID, 10: 4 BSSID, 01: 2 BSSID , 11: 8BSSID
USHORT MBssBcnNum:3;
USHORT Rsvd:11;
} field;
UINT32 word;
} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
#define MAX_LEN_CFG 0x1018 // rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
#define BBP_CSR_CFG 0x101c //
//
// BBP_CSR_CFG: BBP serial control register
//
typedef union _BBP_CSR_CFG_STRUC {
struct {
UINT32 Value:8; // Register value to program into BBP
UINT32 RegNum:8; // Selected BBP register
UINT32 fRead:1; // 0: Write BBP, 1: Read BBP
UINT32 Busy:1; // 1: ASIC is busy execute BBP programming.
UINT32 BBP_PAR_DUR:1; // 0: 4 MAC clock cycles 1: 8 MAC clock cycles
UINT32 BBP_RW_MODE:1; // 0: use serial mode 1:parallel
UINT32 :12;
} field;
UINT32 word;
} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
#define RF_CSR_CFG0 0x1020
//
// RF_CSR_CFG: RF control register
//
typedef union _RF_CSR_CFG0_STRUC {
struct {
UINT32 RegIdAndContent:24; // Register value to program into BBP
UINT32 bitwidth:5; // Selected BBP register
UINT32 StandbyMode:1; // 0: high when stand by 1: low when standby
UINT32 Sel:1; // 0:RF_LE0 activate 1:RF_LE1 activate
UINT32 Busy:1; // 0: idle 1: 8busy
} field;
UINT32 word;
} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
#define RF_CSR_CFG1 0x1024
typedef union _RF_CSR_CFG1_STRUC {
struct {
UINT32 RegIdAndContent:24; // Register value to program into BBP
UINT32 RFGap:5; // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
UINT32 rsv:7; // 0: idle 1: 8busy
} field;
UINT32 word;
} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
#define RF_CSR_CFG2 0x1028 //
typedef union _RF_CSR_CFG2_STRUC {
struct {
UINT32 RegIdAndContent:24; // Register value to program into BBP
UINT32 rsv:8; // 0: idle 1: 8busy
} field;
UINT32 word;
} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
#define LED_CFG 0x102c // MAC_CSR14
typedef union _LED_CFG_STRUC {
struct {
UINT32 OnPeriod:8; // blinking on period unit 1ms
UINT32 OffPeriod:8; // blinking off period unit 1ms
UINT32 SlowBlinkPeriod:6; // slow blinking period. unit:1ms
UINT32 rsv:2;
UINT32 RLedMode:2; // red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on
UINT32 GLedMode:2; // green Led Mode
UINT32 YLedMode:2; // yellow Led Mode
UINT32 LedPolar:1; // Led Polarity. 0: active low1: active high
UINT32 :1;
} field;
UINT32 word;
} LED_CFG_STRUC, *PLED_CFG_STRUC;
//
// 4.2 MAC TIMING configuration registers (offset:0x1100)
//
#define XIFS_TIME_CFG 0x1100 // MAC_CSR8 MAC_CSR9
typedef union _IFS_SLOT_CFG_STRUC {
struct {
UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
UINT32 OfdmSifsTime:8; // unit 1us. Applied after OFDM RX/TX
UINT32 OfdmXifsTime:4; //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
UINT32 EIFS:9; // unit 1us
UINT32 BBRxendEnable:1; // reference RXEND signal to begin XIFS defer
UINT32 rsv:2;
} field;
UINT32 word;
} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
#define BKOFF_SLOT_CFG 0x1104 // mac_csr9 last 8 bits
#define NAV_TIME_CFG 0x1108 // NAV (MAC_CSR15)
#define CH_TIME_CFG 0x110C // Count as channel busy
#define PBF_LIFE_TIMER 0x1110 //TX/RX MPDU timestamp timer (free run)Unit: 1us
#define BCN_TIME_CFG 0x1114 // TXRX_CSR9
#define BCN_OFFSET0 0x042C
#define BCN_OFFSET1 0x0430
//
// BCN_TIME_CFG : Synchronization control register
//
typedef union _BCN_TIME_CFG_STRUC {
struct {
UINT32 BeaconInterval:16; // in unit of 1/16 TU
UINT32 bTsfTicking:1; // Enable TSF auto counting
UINT32 TsfSyncMode:2; // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
UINT32 bTBTTEnable:1;
UINT32 bBeaconGen:1; // Enable beacon generator
UINT32 :3;
UINT32 TxTimestampCompensate:8;
} field;
UINT32 word;
} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
#define TBTT_SYNC_CFG 0x1118 // txrx_csr10
#define TSF_TIMER_DW0 0x111C // Local TSF timer lsb 32 bits. Read-only
#define TSF_TIMER_DW1 0x1120 // msb 32 bits. Read-only.
#define TBTT_TIMER 0x1124 // TImer remains till next TBTT. Read-only. TXRX_CSR14
#define INT_TIMER_CFG 0x1128 //
#define INT_TIMER_EN 0x112c // GP-timer and pre-tbtt Int enable
#define CH_IDLE_STA 0x1130 // channel idle time
#define CH_BUSY_STA 0x1134 // channle busy time
//
// 4.2 MAC POWER configuration registers (offset:0x1200)
//
#define MAC_STATUS_CFG 0x1200 // old MAC_CSR12
#define PWR_PIN_CFG 0x1204 // old MAC_CSR12
#define AUTO_WAKEUP_CFG 0x1208 // old MAC_CSR10
//
// AUTO_WAKEUP_CFG: Manual power control / status register
//
typedef union _AUTO_WAKEUP_STRUC {
struct {
UINT32 AutoLeadTime:8;
UINT32 NumofSleepingTbtt:7; // ForceWake has high privilege than PutToSleep when both set
UINT32 EnableAutoWakeup:1; // 0:sleep, 1:awake
UINT32 :16;
} field;
UINT32 word;
} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
//
// 4.3 MAC TX configuration registers (offset:0x1300)
//
#define EDCA_AC0_CFG 0x1300 //AC_TXOP_CSR0 0x3474
#define EDCA_AC1_CFG 0x1304
#define EDCA_AC2_CFG 0x1308
#define EDCA_AC3_CFG 0x130c
typedef union _EDCA_AC_CFG_STRUC {
struct {
UINT32 AcTxop:8; // in unit of 32us
UINT32 Aifsn:4; // # of slot time
UINT32 Cwmin:4; //
UINT32 Cwmax:4; //unit power of 2
UINT32 :12; //
} field;
UINT32 word;
} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
#define EDCA_TID_AC_MAP 0x1310
#define TX_PWR_CFG_0 0x1314
#define TX_PWR_CFG_1 0x1318
#define TX_PWR_CFG_2 0x131C
#define TX_PWR_CFG_3 0x1320
#define TX_PWR_CFG_4 0x1324
#define TX_PIN_CFG 0x1328
#define TX_BAND_CFG 0x132c // 0x1 use upper 20MHz. 0 juse lower 20MHz
#define TX_SW_CFG0 0x1330
#define TX_SW_CFG1 0x1334
#define TX_SW_CFG2 0x1338
#define TXOP_THRES_CFG 0x133c
#define TXOP_CTRL_CFG 0x1340
#define TX_RTS_CFG 0x1344
typedef union _TX_RTS_CFG_STRUC {
struct {
UINT32 AutoRtsRetryLimit:8;
UINT32 RtsThres:16; // unit:byte
UINT32 RtsFbkEn:1; // enable rts rate fallback
UINT32 rsv:7; // 1: HT non-STBC control frame enable
} field;
UINT32 word;
} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
#define TX_TIMEOUT_CFG 0x1348
typedef union _TX_TIMEOUT_CFG_STRUC {
struct {
UINT32 rsv:4;
UINT32 MpduLifeTime:4; // expiration time = 2^(9+MPDU LIFE TIME) us
UINT32 RxAckTimeout:8; // unit:slot. Used for TX precedure
UINT32 TxopTimeout:8; //TXOP timeout value for TXOP truncation. It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
UINT32 rsv2:8; // 1: HT non-STBC control frame enable
} field;
UINT32 word;
} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
#define TX_RTY_CFG 0x134c
typedef union PACKED _TX_RTY_CFG_STRUC {
struct {
UINT32 ShortRtyLimit:8; // short retry limit
UINT32 LongRtyLimit:8; //long retry limit
UINT32 LongRtyThre:12; // Long retry threshoold
UINT32 NonAggRtyMode:1; // Non-Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
UINT32 AggRtyMode:1; // Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
UINT32 TxautoFBEnable:1; // Tx retry PHY rate auto fallback enable
UINT32 rsv:1; // 1: HT non-STBC control frame enable
} field;
UINT32 word;
} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
#define TX_LINK_CFG 0x1350
typedef union PACKED _TX_LINK_CFG_STRUC {
struct PACKED {
UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
UINT32 MFBEnable:1; // TX apply remote MFB 1:enable
UINT32 RemoteUMFSEnable:1; // remote unsolicit MFB enable. 0: not apply remote remote unsolicit (MFS=7)
UINT32 TxMRQEn:1; // MCS request TX enable
UINT32 TxRDGEn:1; // RDG TX enable
UINT32 TxCFAckEn:1; // Piggyback CF-ACK enable
UINT32 rsv:3; //
UINT32 RemotMFB:8; // remote MCS feedback
UINT32 RemotMFS:8; //remote MCS feedback sequence number
} field;
UINT32 word;
} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
#define HT_FBK_CFG0 0x1354
typedef union PACKED _HT_FBK_CFG0_STRUC {
struct {
UINT32 HTMCS0FBK:4;
UINT32 HTMCS1FBK:4;
UINT32 HTMCS2FBK:4;
UINT32 HTMCS3FBK:4;
UINT32 HTMCS4FBK:4;
UINT32 HTMCS5FBK:4;
UINT32 HTMCS6FBK:4;
UINT32 HTMCS7FBK:4;
} field;
UINT32 word;
} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
#define HT_FBK_CFG1 0x1358
typedef union _HT_FBK_CFG1_STRUC {
struct {
UINT32 HTMCS8FBK:4;
UINT32 HTMCS9FBK:4;
UINT32 HTMCS10FBK:4;
UINT32 HTMCS11FBK:4;
UINT32 HTMCS12FBK:4;
UINT32 HTMCS13FBK:4;
UINT32 HTMCS14FBK:4;
UINT32 HTMCS15FBK:4;
} field;
UINT32 word;
} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
#define LG_FBK_CFG0 0x135c
typedef union _LG_FBK_CFG0_STRUC {
struct {
UINT32 OFDMMCS0FBK:4; //initial value is 0
UINT32 OFDMMCS1FBK:4; //initial value is 0
UINT32 OFDMMCS2FBK:4; //initial value is 1
UINT32 OFDMMCS3FBK:4; //initial value is 2
UINT32 OFDMMCS4FBK:4; //initial value is 3
UINT32 OFDMMCS5FBK:4; //initial value is 4
UINT32 OFDMMCS6FBK:4; //initial value is 5
UINT32 OFDMMCS7FBK:4; //initial value is 6
} field;
UINT32 word;
} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
#define LG_FBK_CFG1 0x1360
typedef union _LG_FBK_CFG1_STRUC {
struct {
UINT32 CCKMCS0FBK:4; //initial value is 0
UINT32 CCKMCS1FBK:4; //initial value is 0
UINT32 CCKMCS2FBK:4; //initial value is 1
UINT32 CCKMCS3FBK:4; //initial value is 2
UINT32 rsv:16;
} field;
UINT32 word;
} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
//=======================================================
//================ Protection Paramater================================
//=======================================================
#define CCK_PROT_CFG 0x1364 //CCK Protection
#define ASIC_SHORTNAV 1
#define ASIC_LONGNAV 2
#define ASIC_RTS 1
#define ASIC_CTS 2
typedef union _PROT_CFG_STRUC {
struct {
UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
UINT32 ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
UINT32 ProtectNav:2; //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect, 2:LongNAVProtect, 3:rsv
UINT32 TxopAllowCck:1; //CCK TXOP allowance.0:disallow.
UINT32 TxopAllowOfdm:1; //CCK TXOP allowance.0:disallow.
UINT32 TxopAllowMM20:1; //CCK TXOP allowance. 0:disallow.
UINT32 TxopAllowMM40:1; //CCK TXOP allowance.0:disallow.
UINT32 TxopAllowGF20:1; //CCK TXOP allowance.0:disallow.
UINT32 TxopAllowGF40:1; //CCK TXOP allowance.0:disallow.
UINT32 RTSThEn:1; //RTS threshold enable on CCK TX
UINT32 rsv:5;
} field;
UINT32 word;
} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
#define OFDM_PROT_CFG 0x1368 //OFDM Protection
#define MM20_PROT_CFG 0x136C //MM20 Protection
#define MM40_PROT_CFG 0x1370 //MM40 Protection
#define GF20_PROT_CFG 0x1374 //GF20 Protection
#define GF40_PROT_CFG 0x1378 //GR40 Protection
#define EXP_CTS_TIME 0x137C //
#define EXP_ACK_TIME 0x1380 //
//
// 4.4 MAC RX configuration registers (offset:0x1400)
//
#define RX_FILTR_CFG 0x1400 //TXRX_CSR0
#define AUTO_RSP_CFG 0x1404 //TXRX_CSR4
//
// TXRX_CSR4: Auto-Responder/
//
typedef union _AUTO_RSP_CFG_STRUC {
struct {
UINT32 AutoResponderEnable:1;
UINT32 BACAckPolicyEnable:1; // 0:long, 1:short preamble
UINT32 CTS40MMode:1; // Response CTS 40MHz duplicate mode
UINT32 CTS40MRef:1; // Response CTS 40MHz duplicate mode
UINT32 AutoResponderPreamble:1; // 0:long, 1:short preamble
UINT32 rsv:1; // Power bit value in conrtrol frame
UINT32 DualCTSEn:1; // Power bit value in conrtrol frame
UINT32 AckCtsPsmBit:1; // Power bit value in conrtrol frame
UINT32 :24;
} field;
UINT32 word;
} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
#define LEGACY_BASIC_RATE 0x1408 // TXRX_CSR5 0x3054
#define HT_BASIC_RATE 0x140c
#define HT_CTRL_CFG 0x1410
#define SIFS_COST_CFG 0x1414
#define RX_PARSER_CFG 0x1418 //Set NAV for all received frames
//
// 4.5 MAC Security configuration (offset:0x1500)
//
#define TX_SEC_CNT0 0x1500 //
#define RX_SEC_CNT0 0x1504 //
#define CCMP_FC_MUTE 0x1508 //
//
// 4.6 HCCA/PSMP (offset:0x1600)
//
#define TXOP_HLDR_ADDR0 0x1600
#define TXOP_HLDR_ADDR1 0x1604
#define TXOP_HLDR_ET 0x1608
#define QOS_CFPOLL_RA_DW0 0x160c
#define QOS_CFPOLL_A1_DW1 0x1610
#define QOS_CFPOLL_QC 0x1614
//
// 4.7 MAC Statistis registers (offset:0x1700)
//
#define RX_STA_CNT0 0x1700 //
#define RX_STA_CNT1 0x1704 //
#define RX_STA_CNT2 0x1708 //
//
// RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count
//
typedef union _RX_STA_CNT0_STRUC {
struct {
USHORT CrcErr;
USHORT PhyErr;
} field;
UINT32 word;
} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
//
// RX_STA_CNT1_STRUC: RX False CCA count & RX LONG frame count
//
typedef union _RX_STA_CNT1_STRUC {
struct {
USHORT FalseCca;
USHORT PlcpErr;
} field;
UINT32 word;
} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
//
// RX_STA_CNT2_STRUC:
//
typedef union _RX_STA_CNT2_STRUC {
struct {
USHORT RxDupliCount;
USHORT RxFifoOverflowCount;
} field;
UINT32 word;
} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
#define TX_STA_CNT0 0x170C //
//
// STA_CSR3: TX Beacon count
//
typedef union _TX_STA_CNT0_STRUC {
struct {
USHORT TxFailCount;
USHORT TxBeaconCount;
} field;
UINT32 word;
} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
#define TX_STA_CNT1 0x1710 //
//
// TX_STA_CNT1: TX tx count
//
typedef union _TX_STA_CNT1_STRUC {
struct {
USHORT TxSuccess;
USHORT TxRetransmit;
} field;
UINT32 word;
} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
#define TX_STA_CNT2 0x1714 //
//
// TX_STA_CNT2: TX tx count
//
typedef union _TX_STA_CNT2_STRUC {
struct {
USHORT TxZeroLenCount;
USHORT TxUnderFlowCount;
} field;
UINT32 word;
} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
#define TX_STA_FIFO 0x1718 //
//
// TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register
//
typedef union PACKED _TX_STA_FIFO_STRUC {
struct {
UINT32 bValid:1; // 1:This register contains a valid TX result
UINT32 PidType:4;
UINT32 TxSuccess:1; // Tx No retry success
UINT32 TxAggre:1; // Tx Retry Success
UINT32 TxAckRequired:1; // Tx fail
UINT32 wcid:8; //wireless client index
// UINT32 SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
UINT32 SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
UINT32 TxBF:1;
UINT32 Reserve:2;
} field;
UINT32 word;
} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
// Debug counter
#define TX_AGG_CNT 0x171c
typedef union _TX_AGG_CNT_STRUC {
struct {
USHORT NonAggTxCount;
USHORT AggTxCount;
} field;
UINT32 word;
} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
// Debug counter
#define TX_AGG_CNT0 0x1720
typedef union _TX_AGG_CNT0_STRUC {
struct {
USHORT AggSize1Count;
USHORT AggSize2Count;
} field;
UINT32 word;
} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
// Debug counter
#define TX_AGG_CNT1 0x1724
typedef union _TX_AGG_CNT1_STRUC {
struct {
USHORT AggSize3Count;
USHORT AggSize4Count;
} field;
UINT32 word;
} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
#define TX_AGG_CNT2 0x1728
typedef union _TX_AGG_CNT2_STRUC {
struct {
USHORT AggSize5Count;
USHORT AggSize6Count;
} field;
UINT32 word;
} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
// Debug counter
#define TX_AGG_CNT3 0x172c
typedef union _TX_AGG_CNT3_STRUC {
struct {
USHORT AggSize7Count;
USHORT AggSize8Count;
} field;
UINT32 word;
} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
// Debug counter
#define TX_AGG_CNT4 0x1730
typedef union _TX_AGG_CNT4_STRUC {
struct {
USHORT AggSize9Count;
USHORT AggSize10Count;
} field;
UINT32 word;
} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
#define TX_AGG_CNT5 0x1734
typedef union _TX_AGG_CNT5_STRUC {
struct {
USHORT AggSize11Count;
USHORT AggSize12Count;
} field;
UINT32 word;
} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
#define TX_AGG_CNT6 0x1738
typedef union _TX_AGG_CNT6_STRUC {
struct {
USHORT AggSize13Count;
USHORT AggSize14Count;
} field;
UINT32 word;
} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
#define TX_AGG_CNT7 0x173c
typedef union _TX_AGG_CNT7_STRUC {
struct {
USHORT AggSize15Count;
USHORT AggSize16Count;
} field;
UINT32 word;
} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
#define MPDU_DENSITY_CNT 0x1740
typedef union _MPDU_DEN_CNT_STRUC {
struct {
USHORT TXZeroDelCount; //TX zero length delimiter count
USHORT RXZeroDelCount; //RX zero length delimiter count
} field;
UINT32 word;
} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
//
// TXRX control registers - base address 0x3000
//
// rt2860b UNKNOWN reg use R/O Reg Addr 0x77d0 first..
#define TXRX_CSR1 0x77d0
//
// Security key table memory, base address = 0x1000
//
#define MAC_WCID_BASE 0x1800 //8-bytes(use only 6-bytes) * 256 entry =
#define HW_WCID_ENTRY_SIZE 8
#define PAIRWISE_KEY_TABLE_BASE 0x4000 // 32-byte * 256-entry = -byte
#define HW_KEY_ENTRY_SIZE 0x20
#define PAIRWISE_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
#define MAC_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
#define HW_IVEIV_ENTRY_SIZE 8
#define MAC_WCID_ATTRIBUTE_BASE 0x6800 // 4-byte * 256-entry = -byte
#define HW_WCID_ATTRI_SIZE 4
#define WCID_RESERVED 0x6bfc
#define SHARED_KEY_TABLE_BASE 0x6c00 // 32-byte * 16-entry = 512-byte
#define SHARED_KEY_MODE_BASE 0x7000 // 32-byte * 16-entry = 512-byte
#define HW_SHARED_KEY_MODE_SIZE 4
#define SHAREDKEYTABLE 0
#define PAIRWISEKEYTABLE 1
typedef union _SHAREDKEY_MODE_STRUC {
struct {
UINT32 Bss0Key0CipherAlg:3;
UINT32 :1;
UINT32 Bss0Key1CipherAlg:3;
UINT32 :1;
UINT32 Bss0Key2CipherAlg:3;
UINT32 :1;
UINT32 Bss0Key3CipherAlg:3;
UINT32 :1;
UINT32 Bss1Key0CipherAlg:3;
UINT32 :1;
UINT32 Bss1Key1CipherAlg:3;
UINT32 :1;
UINT32 Bss1Key2CipherAlg:3;
UINT32 :1;
UINT32 Bss1Key3CipherAlg:3;
UINT32 :1;
} field;
UINT32 word;
} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
// 64-entry for pairwise key table
typedef struct _HW_WCID_ENTRY { // 8-byte per entry
UCHAR Address[6];
UCHAR Rsv[2];
} HW_WCID_ENTRY, PHW_WCID_ENTRY;
//
// Other on-chip shared memory space, base = 0x2000
//
// CIS space - base address = 0x2000
#define HW_CIS_BASE 0x2000
// Carrier-sense CTS frame base address. It's where mac stores carrier-sense frame for carrier-sense function.
#define HW_CS_CTS_BASE 0x7700
// DFS CTS frame base address. It's where mac stores CTS frame for DFS.
#define HW_DFS_CTS_BASE 0x7780
#define HW_CTS_FRAME_SIZE 0x80
// 2004-11-08 john - since NULL frame won't be that long (256 byte). We steal 16 tail bytes
// to save debugging settings
#define HW_DEBUG_SETTING_BASE 0x77f0 // 0x77f0~0x77ff total 16 bytes
#define HW_DEBUG_SETTING_BASE2 0x7770 // 0x77f0~0x77ff total 16 bytes
// In order to support maximum 8 MBSS and its maximum length is 512 for each beacon
// Three section discontinue memory segments will be used.
// 1. The original region for BCN 0~3
// 2. Extract memory from FCE table for BCN 4~5
// 3. Extract memory from Pair-wise key table for BCN 6~7
// It occupied those memory of wcid 238~253 for BCN 6
// and wcid 222~237 for BCN 7
#define HW_BEACON_MAX_SIZE 0x1000 /* unit: byte */
#define HW_BEACON_BASE0 0x7800
#define HW_BEACON_BASE1 0x7A00
#define HW_BEACON_BASE2 0x7C00
#define HW_BEACON_BASE3 0x7E00
#define HW_BEACON_BASE4 0x7200
#define HW_BEACON_BASE5 0x7400
#define HW_BEACON_BASE6 0x5DC0
#define HW_BEACON_BASE7 0x5BC0
#define HW_BEACON_MAX_COUNT 8
#define HW_BEACON_OFFSET 0x0200
#define HW_BEACON_CONTENT_LEN (HW_BEACON_OFFSET - TXWI_SIZE)
// HOST-MCU shared memory - base address = 0x2100
#define HOST_CMD_CSR 0x404
#define H2M_MAILBOX_CSR 0x7010
#define H2M_MAILBOX_CID 0x7014
#define H2M_MAILBOX_STATUS 0x701c
#define H2M_INT_SRC 0x7024
#define H2M_BBP_AGENT 0x7028
#define M2H_CMD_DONE_CSR 0x000c
#define MCU_TXOP_ARRAY_BASE 0x000c // TODO: to be provided by Albert
#define MCU_TXOP_ENTRY_SIZE 32 // TODO: to be provided by Albert
#define MAX_NUM_OF_TXOP_ENTRY 16 // TODO: must be same with 8051 firmware
#define MCU_MBOX_VERSION 0x01 // TODO: to be confirmed by Albert
#define MCU_MBOX_VERSION_OFFSET 5 // TODO: to be provided by Albert
//
// Host DMA registers - base address 0x200 . TX0-3=EDCAQid0-3, TX4=HCCA, TX5=MGMT,
//
//
// DMA RING DESCRIPTOR
//
#define E2PROM_CSR 0x0004
#define IO_CNTL_CSR 0x77d0
#ifdef RT2870
// 8051 firmware image for usb - use last-half base address = 0x3000
#define FIRMWARE_IMAGE_BASE 0x3000
#define MAX_FIRMWARE_IMAGE_SIZE 0x1000 // 4kbyte
#endif // RT2870 //
// ================================================================
// Tx / Rx / Mgmt ring descriptor definition
// ================================================================
// the following PID values are used to mark outgoing frame type in TXD->PID so that
// proper TX statistics can be collected based on these categories
// b3-2 of PID field -
#define PID_MGMT 0x05
#define PID_BEACON 0x0c
#define PID_DATA_NORMALUCAST 0x02
#define PID_DATA_AMPDU 0x04
#define PID_DATA_NO_ACK 0x08
#define PID_DATA_NOT_NORM_ACK 0x03
// value domain of pTxD->HostQId (4-bit: 0~15)
#define QID_AC_BK 1 // meet ACI definition in 802.11e
#define QID_AC_BE 0 // meet ACI definition in 802.11e
#define QID_AC_VI 2
#define QID_AC_VO 3
#define QID_HCCA 4
#define NUM_OF_TX_RING 5
#define QID_MGMT 13
#define QID_RX 14
#define QID_OTHER 15
// ------------------------------------------------------
// BBP & RF definition
// ------------------------------------------------------
#define BUSY 1
#define IDLE 0
#define RF_R00 0
#define RF_R01 1
#define RF_R02 2
#define RF_R03 3
#define RF_R04 4
#define RF_R05 5
#define RF_R06 6
#define RF_R07 7
#define RF_R08 8
#define RF_R09 9
#define RF_R10 10
#define RF_R11 11
#define RF_R12 12
#define RF_R13 13
#define RF_R14 14
#define RF_R15 15
#define RF_R16 16
#define RF_R17 17
#define RF_R18 18
#define RF_R19 19
#define RF_R20 20
#define RF_R21 21
#define RF_R22 22
#define RF_R23 23
#define RF_R24 24
#define RF_R25 25
#define RF_R26 26
#define RF_R27 27
#define RF_R28 28
#define RF_R29 29
#define RF_R30 30
#define RF_R31 31
#define BBP_R0 0 // version
#define BBP_R1 1 // TSSI
#define BBP_R2 2 // TX configure
#define BBP_R3 3
#define BBP_R4 4
#define BBP_R5 5
#define BBP_R6 6
#define BBP_R14 14 // RX configure
#define BBP_R16 16
#define BBP_R17 17 // RX sensibility
#define BBP_R18 18
#define BBP_R21 21
#define BBP_R22 22
#define BBP_R24 24
#define BBP_R25 25
#ifdef RT30xx
#define BBP_R31 31
#endif
#define BBP_R49 49 //TSSI
#define BBP_R50 50
#define BBP_R51 51
#define BBP_R52 52
#define BBP_R55 55
#define BBP_R62 62 // Rx SQ0 Threshold HIGH
#define BBP_R63 63
#define BBP_R64 64
#define BBP_R65 65
#define BBP_R66 66
#define BBP_R67 67
#define BBP_R68 68
#define BBP_R69 69
#define BBP_R70 70 // Rx AGC SQ CCK Xcorr threshold
#define BBP_R73 73
#define BBP_R75 75
#define BBP_R77 77
#ifdef RT30xx
#define BBP_R79 79
#define BBP_R80 80
#endif
#define BBP_R81 81
#define BBP_R82 82
#define BBP_R83 83
#define BBP_R84 84
#define BBP_R86 86
#define BBP_R91 91
#define BBP_R92 92
#define BBP_R94 94 // Tx Gain Control
#define BBP_R103 103
#define BBP_R105 105
#define BBP_R113 113
#define BBP_R114 114
#define BBP_R115 115
#define BBP_R116 116
#define BBP_R117 117
#define BBP_R118 118
#define BBP_R119 119
#define BBP_R120 120
#define BBP_R121 121
#define BBP_R122 122
#define BBP_R123 123
#ifdef RT30xx
#define BBP_R138 138 // add by johnli, RF power sequence setup, ADC dynamic on/off control
#endif // RT30xx //
#define BBPR94_DEFAULT 0x06 // Add 1 value will gain 1db
#define RSSI_FOR_VERY_LOW_SENSIBILITY -35
#define RSSI_FOR_LOW_SENSIBILITY -58
#define RSSI_FOR_MID_LOW_SENSIBILITY -80
#define RSSI_FOR_MID_SENSIBILITY -90
//-------------------------------------------------------------------------
// EEPROM definition
//-------------------------------------------------------------------------
#define EEDO 0x08
#define EEDI 0x04
#define EECS 0x02
#define EESK 0x01
#define EERL 0x80
#define EEPROM_WRITE_OPCODE 0x05
#define EEPROM_READ_OPCODE 0x06
#define EEPROM_EWDS_OPCODE 0x10
#define EEPROM_EWEN_OPCODE 0x13
#define NUM_EEPROM_BBP_PARMS 19 // Include NIC Config 0, 1, CR, TX ALC step, BBPs
#define NUM_EEPROM_TX_G_PARMS 7
#define EEPROM_NIC1_OFFSET 0x34 // The address is from NIC config 0, not BBP register ID
#define EEPROM_NIC2_OFFSET 0x36 // The address is from NIC config 0, not BBP register ID
#define EEPROM_BBP_BASE_OFFSET 0xf0 // The address is from NIC config 0, not BBP register ID
#define EEPROM_G_TX_PWR_OFFSET 0x52
#define EEPROM_G_TX2_PWR_OFFSET 0x60
#define EEPROM_LED1_OFFSET 0x3c
#define EEPROM_LED2_OFFSET 0x3e
#define EEPROM_LED3_OFFSET 0x40
#define EEPROM_LNA_OFFSET 0x44
#define EEPROM_RSSI_BG_OFFSET 0x46
#define EEPROM_RSSI_A_OFFSET 0x4a
#define EEPROM_DEFINE_MAX_TXPWR 0x4e
#define EEPROM_TXPOWER_BYRATE_20MHZ_2_4G 0xde // 20MHZ 2.4G tx power.
#define EEPROM_TXPOWER_BYRATE_40MHZ_2_4G 0xee // 40MHZ 2.4G tx power.
#define EEPROM_TXPOWER_BYRATE_20MHZ_5G 0xfa // 20MHZ 5G tx power.
#define EEPROM_TXPOWER_BYRATE_40MHZ_5G 0x10a // 40MHZ 5G tx power.
#define EEPROM_A_TX_PWR_OFFSET 0x78
#define EEPROM_A_TX2_PWR_OFFSET 0xa6
#define EEPROM_VERSION_OFFSET 0x02
#define EEPROM_FREQ_OFFSET 0x3a
#define EEPROM_TXPOWER_BYRATE 0xde // 20MHZ power.
#define EEPROM_TXPOWER_DELTA 0x50 // 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ.
#define VALID_EEPROM_VERSION 1
// PairKeyMode definition
#define PKMODE_NONE 0
#define PKMODE_WEP64 1
#define PKMODE_WEP128 2
#define PKMODE_TKIP 3
#define PKMODE_AES 4
#define PKMODE_CKIP64 5
#define PKMODE_CKIP128 6
#define PKMODE_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
// =================================================================================
// WCID format
// =================================================================================
//7.1 WCID ENTRY format : 8bytes
typedef struct _WCID_ENTRY_STRUC {
UCHAR RXBABitmap7; // bit0 for TID8, bit7 for TID 15
UCHAR RXBABitmap0; // bit0 for TID0, bit7 for TID 7
UCHAR MAC[6]; // 0 for shared key table. 1 for pairwise key table
} WCID_ENTRY_STRUC, *PWCID_ENTRY_STRUC;
//8.1.1 SECURITY KEY format : 8DW
// 32-byte per entry, total 16-entry for shared key table, 64-entry for pairwise key table
typedef struct _HW_KEY_ENTRY { // 32-byte per entry
UCHAR Key[16];
UCHAR TxMic[8];
UCHAR RxMic[8];
} HW_KEY_ENTRY, *PHW_KEY_ENTRY;
//8.1.2 IV/EIV format : 2DW
//8.1.3 RX attribute entry format : 1DW
typedef struct _MAC_ATTRIBUTE_STRUC {
UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
UINT32 PairKeyMode:3;
UINT32 BSSIDIdx:3; //multipleBSS index for the WCID
UINT32 RXWIUDF:3;
UINT32 rsv:22;
} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
// =================================================================================
// TX / RX ring descriptor format
// =================================================================================
// the first 24-byte in TXD is called TXINFO and will be DMAed to MAC block through TXFIFO.
// MAC block use this TXINFO to control the transmission behavior of this frame.
#define FIFO_MGMT 0
#define FIFO_HCCA 1
#define FIFO_EDCA 2
//
// TX descriptor format, Tx ring, Mgmt Ring
//
typedef struct PACKED _TXD_STRUC {
// Word 0
UINT32 SDPtr0;
// Word 1
UINT32 SDLen1:14;
UINT32 LastSec1:1;
UINT32 Burst:1;
UINT32 SDLen0:14;
UINT32 LastSec0:1;
UINT32 DMADONE:1;
//Word2
UINT32 SDPtr1;
//Word3
UINT32 rsv2:24;
UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
UINT32 rsv:2;
UINT32 TCO:1; //
UINT32 UCO:1; //
UINT32 ICO:1; //
} TXD_STRUC, *PTXD_STRUC;
//
// TXD Wireless Information format for Tx ring and Mgmt Ring
//
//txop : for txop mode
// 0:txop for the MPDU frame will be handles by ASIC by register
// 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS
typedef struct PACKED _TXWI_STRUC {
// Word 0
UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
UINT32 MIMOps:1; // the remote peer is in dynamic MIMO-PS mode
UINT32 CFACK:1;
UINT32 TS:1;
UINT32 AMPDU:1;
UINT32 MpduDensity:3;
UINT32 txop:2; //FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
UINT32 rsv:6;
UINT32 MCS:7;
UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
UINT32 ShortGI:1;
UINT32 STBC:2; // 1: STBC support MCS =0-7, 2,3 : RESERVE
UINT32 Ifs:1; //
UINT32 rsv2:1;
UINT32 TxBF:1; // 3*3
UINT32 PHYMODE:2;
// Word 1
UINT32 ACK:1;
UINT32 NSEQ:1;
UINT32 BAWinSize:6;
UINT32 WirelessCliID:8;
UINT32 MPDUtotalByteCount:12;
UINT32 PacketId:4;
//Word2
UINT32 IV;
//Word3
UINT32 EIV;
} TXWI_STRUC, *PTXWI_STRUC;
//
// Rx descriptor format, Rx Ring
//
//
// RXWI wireless information format, in PBF. invisible in driver.
//
typedef struct PACKED _RXWI_STRUC {
// Word 0
UINT32 WirelessCliID:8;
UINT32 KeyIndex:2;
UINT32 BSSID:3;
UINT32 UDF:3;
UINT32 MPDUtotalByteCount:12;
UINT32 TID:4;
// Word 1
UINT32 FRAG:4;
UINT32 SEQUENCE:12;
UINT32 MCS:7;
UINT32 BW:1;
UINT32 ShortGI:1;
UINT32 STBC:2;
UINT32 rsv:3;
UINT32 PHYMODE:2; // 1: this RX frame is unicast to me
//Word2
UINT32 RSSI0:8;
UINT32 RSSI1:8;
UINT32 RSSI2:8;
UINT32 rsv1:8;
//Word3
UINT32 SNR0:8;
UINT32 SNR1:8;
UINT32 rsv2:16;
} RXWI_STRUC, *PRXWI_STRUC;
// =================================================================================
// HOST-MCU communication data structure
// =================================================================================
//
// H2M_MAILBOX_CSR: Host-to-MCU Mailbox
//
typedef union _H2M_MAILBOX_STRUC {
struct {
UINT32 LowByte:8;
UINT32 HighByte:8;
UINT32 CmdToken:8;
UINT32 Owner:8;
} field;
UINT32 word;
} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
//
// M2H_CMD_DONE_CSR: MCU-to-Host command complete indication
//
typedef union _M2H_CMD_DONE_STRUC {
struct {
UINT32 CmdToken0;
UINT32 CmdToken1;
UINT32 CmdToken2;
UINT32 CmdToken3;
} field;
UINT32 word;
} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
//
// MCU_LEDCS: MCU LED Control Setting.
//
typedef union _MCU_LEDCS_STRUC {
struct {
UCHAR LedMode:7;
UCHAR Polarity:1;
} field;
UCHAR word;
} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
// =================================================================================
// Register format
// =================================================================================
//NAV_TIME_CFG :NAV
typedef union _NAV_TIME_CFG_STRUC {
struct {
UCHAR Sifs; // in unit of 1-us
UCHAR SlotTime; // in unit of 1-us
USHORT Eifs:9; // in unit of 1-us
USHORT ZeroSifs:1; // Applied zero SIFS timer after OFDM RX 0: disable
USHORT rsv:6;
} field;
UINT32 word;
} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
//
// RX_FILTR_CFG: /RX configuration register
//
typedef union _RX_FILTR_CFG_STRUC {
struct {
UINT32 DropCRCErr:1; // Drop CRC error
UINT32 DropPhyErr:1; // Drop physical error
UINT32 DropNotToMe:1; // Drop not to me unicast frame
UINT32 DropNotMyBSSID:1; // Drop fram ToDs bit is true
UINT32 DropVerErr:1; // Drop version error frame
UINT32 DropMcast:1; // Drop multicast frames
UINT32 DropBcast:1; // Drop broadcast frames
UINT32 DropDuplicate:1; // Drop duplicate frame
UINT32 DropCFEndAck:1; // Drop Ps-Poll
UINT32 DropCFEnd:1; // Drop Ps-Poll
UINT32 DropAck:1; // Drop Ps-Poll
UINT32 DropCts:1; // Drop Ps-Poll
UINT32 DropRts:1; // Drop Ps-Poll
UINT32 DropPsPoll:1; // Drop Ps-Poll
UINT32 DropBA:1; //
UINT32 DropBAR:1; //
UINT32 DropRsvCntlType:1;
UINT32 :15;
} field;
UINT32 word;
} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
//
// PHY_CSR4: RF serial control register
//
typedef union _PHY_CSR4_STRUC {
struct {
UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
UINT32 NumberOfBits:5; // Number of bits used in RFRegValue (I:20, RFMD:22)
UINT32 IFSelect:1; // 1: select IF to program, 0: select RF to program
UINT32 PLL_LD:1; // RF PLL_LD status
UINT32 Busy:1; // 1: ASIC is busy execute RF programming.
} field;
UINT32 word;
} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
//
// SEC_CSR5: shared key table security mode register
//
typedef union _SEC_CSR5_STRUC {
struct {
UINT32 Bss2Key0CipherAlg:3;
UINT32 :1;
UINT32 Bss2Key1CipherAlg:3;
UINT32 :1;
UINT32 Bss2Key2CipherAlg:3;
UINT32 :1;
UINT32 Bss2Key3CipherAlg:3;
UINT32 :1;
UINT32 Bss3Key0CipherAlg:3;
UINT32 :1;
UINT32 Bss3Key1CipherAlg:3;
UINT32 :1;
UINT32 Bss3Key2CipherAlg:3;
UINT32 :1;
UINT32 Bss3Key3CipherAlg:3;
UINT32 :1;
} field;
UINT32 word;
} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
//
// HOST_CMD_CSR: For HOST to interrupt embedded processor
//
typedef union _HOST_CMD_CSR_STRUC {
struct {
UINT32 HostCommand:8;
UINT32 Rsv:24;
} field;
UINT32 word;
} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
//
// AIFSN_CSR: AIFSN for each EDCA AC
//
//
// E2PROM_CSR: EEPROM control register
//
typedef union _E2PROM_CSR_STRUC {
struct {
UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
UINT32 EepromSK:1;
UINT32 EepromCS:1;
UINT32 EepromDI:1;
UINT32 EepromDO:1;
UINT32 Type:1; // 1: 93C46, 0:93C66
UINT32 LoadStatus:1; // 1:loading, 0:done
UINT32 Rsvd:25;
} field;
UINT32 word;
} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
// -------------------------------------------------------------------
// E2PROM data layout
// -------------------------------------------------------------------
//
// EEPROM antenna select format
//
typedef union _EEPROM_ANTENNA_STRUC {
struct {
USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
USHORT TxPath:4; // 1: 1T, 2: 2T
USHORT RfIcType:4; // see E2PROM document
USHORT Rsv:4;
} field;
USHORT word;
} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
typedef union _EEPROM_NIC_CINFIG2_STRUC {
struct {
USHORT HardwareRadioControl:1; // 1:enable, 0:disable
USHORT DynamicTxAgcControl:1; //
USHORT ExternalLNAForG:1; //
USHORT ExternalLNAForA:1; // external LNA enable for 2.4G
USHORT CardbusAcceleration:1; // !!! NOTE: 0 - enable, 1 - disable
USHORT BW40MSidebandForG:1;
USHORT BW40MSidebandForA:1;
USHORT EnableWPSPBC:1; // WPS PBC Control bit
USHORT BW40MAvailForG:1; // 0:enable, 1:disable
USHORT BW40MAvailForA:1; // 0:enable, 1:disable
#ifndef RT30xx
USHORT Rsv2:6; // must be 0
#endif
#ifdef RT30xx
USHORT Rsv1:1; // must be 0
USHORT AntDiversity:1; // Antenna diversity
USHORT Rsv2:3; // must be 0
USHORT DACTestBit:1; // control if driver should patch the DAC issue
#endif
} field;
USHORT word;
} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
//
// TX_PWR Value valid range 0xFA(-6) ~ 0x24(36)
//
typedef union _EEPROM_TX_PWR_STRUC {
struct {
CHAR Byte0; // Low Byte
CHAR Byte1; // High Byte
} field;
USHORT word;
} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
typedef union _EEPROM_VERSION_STRUC {
struct {
UCHAR FaeReleaseNumber; // Low Byte
UCHAR Version; // High Byte
} field;
USHORT word;
} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
typedef union _EEPROM_LED_STRUC {
struct {
USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
USHORT PolarityRDY_A:1; // Polarity RDY_A setting.
USHORT PolarityACT:1; // Polarity ACT setting.
USHORT PolarityGPIO_0:1; // Polarity GPIO#0 setting.
USHORT PolarityGPIO_1:1; // Polarity GPIO#1 setting.
USHORT PolarityGPIO_2:1; // Polarity GPIO#2 setting.
USHORT PolarityGPIO_3:1; // Polarity GPIO#3 setting.
USHORT PolarityGPIO_4:1; // Polarity GPIO#4 setting.
USHORT LedMode:5; // Led mode.
USHORT Rsvd:3; // Reserved
} field;
USHORT word;
} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
typedef union _EEPROM_TXPOWER_DELTA_STRUC {
struct {
UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
UCHAR Type:1; // 1: plus the delta value, 0: minus the delta value
UCHAR TxPowerEnable:1;// Enable
} field;
UCHAR value;
} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
//
// QOS_CSR0: TXOP holder address0 register
//
typedef union _QOS_CSR0_STRUC {
struct {
UCHAR Byte0; // MAC address byte 0
UCHAR Byte1; // MAC address byte 1
UCHAR Byte2; // MAC address byte 2
UCHAR Byte3; // MAC address byte 3
} field;
UINT32 word;
} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
//
// QOS_CSR1: TXOP holder address1 register
//
typedef union _QOS_CSR1_STRUC {
struct {
UCHAR Byte4; // MAC address byte 4
UCHAR Byte5; // MAC address byte 5
UCHAR Rsvd0;
UCHAR Rsvd1;
} field;
UINT32 word;
} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
#define RF_CSR_CFG 0x500
typedef union _RF_CSR_CFG_STRUC {
struct {
UINT RF_CSR_DATA:8; // DATA
UINT TESTCSR_RFACC_REGNUM:5; // RF register ID
UINT Rsvd2:3; // Reserved
UINT RF_CSR_WR:1; // 0: read 1: write
UINT RF_CSR_KICK:1; // kick RF register read/write
UINT Rsvd1:14; // Reserved
} field;
UINT word;
} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
#endif // __RT28XX_H__
#include "../rt2860/rt28xx.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_config.h
Abstract:
Central header file to maintain all include files for all NDIS
miniport driver routines.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Lin 08-01-2002 created
*/
#ifndef __RT_CONFIG_H__
#define __RT_CONFIG_H__
#include "rtmp_type.h"
#ifdef LINUX
#include "rt_linux.h"
#endif
#include "rtmp_def.h"
#include "rt28xx.h"
#ifdef RT2870
#include "rt2870.h"
#endif // RT2870 //
#include "oid.h"
#include "mlme.h"
#include "wpa.h"
#include "md5.h"
#include "rtmp.h"
#include "ap.h"
#include "dfs.h"
#include "chlist.h"
#include "spectrum.h"
#ifdef IGMP_SNOOP_SUPPORT
#include "igmp_snoop.h"
#endif // IGMP_SNOOP_SUPPORT //
#ifdef IKANOS_VX_1X0
#include "vr_ikans.h"
#endif // IKANOS_VX_1X0 //
#endif // __RT_CONFIG_H__
#include "../rt2860/rt_config.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#include "rt_config.h"
ULONG RTDebugLevel = RT_DEBUG_ERROR;
BUILD_TIMER_FUNCTION(MlmePeriodicExec);
BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
BUILD_TIMER_FUNCTION(APSDPeriodicExec);
BUILD_TIMER_FUNCTION(AsicRfTuningExec);
#ifdef RT2870
BUILD_TIMER_FUNCTION(BeaconUpdateExec);
#endif // RT2870 //
BUILD_TIMER_FUNCTION(BeaconTimeout);
BUILD_TIMER_FUNCTION(ScanTimeout);
BUILD_TIMER_FUNCTION(AuthTimeout);
BUILD_TIMER_FUNCTION(AssocTimeout);
BUILD_TIMER_FUNCTION(ReassocTimeout);
BUILD_TIMER_FUNCTION(DisassocTimeout);
BUILD_TIMER_FUNCTION(LinkDownExec);
BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
// for wireless system event message
char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
// system status event
"had associated successfully", /* IW_ASSOC_EVENT_FLAG */
"had disassociated", /* IW_DISASSOC_EVENT_FLAG */
"had deauthenticated", /* IW_DEAUTH_EVENT_FLAG */
"had been aged-out and disassociated", /* IW_AGEOUT_EVENT_FLAG */
"occurred CounterMeasures attack", /* IW_COUNTER_MEASURES_EVENT_FLAG */
"occurred replay counter different in Key Handshaking", /* IW_REPLAY_COUNTER_DIFF_EVENT_FLAG */
"occurred RSNIE different in Key Handshaking", /* IW_RSNIE_DIFF_EVENT_FLAG */
"occurred MIC different in Key Handshaking", /* IW_MIC_DIFF_EVENT_FLAG */
"occurred ICV error in RX", /* IW_ICV_ERROR_EVENT_FLAG */
"occurred MIC error in RX", /* IW_MIC_ERROR_EVENT_FLAG */
"Group Key Handshaking timeout", /* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */
"Pairwise Key Handshaking timeout", /* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */
"RSN IE sanity check failure", /* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */
"set key done in WPA/WPAPSK", /* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */
"set key done in WPA2/WPA2PSK", /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */
"connects with our wireless client", /* IW_STA_LINKUP_EVENT_FLAG */
"disconnects with our wireless client", /* IW_STA_LINKDOWN_EVENT_FLAG */
"scan completed" /* IW_SCAN_COMPLETED_EVENT_FLAG */
"scan terminate!! Busy!! Enqueue fail!!" /* IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG */
};
// for wireless IDS_spoof_attack event message
char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
"detected conflict SSID", /* IW_CONFLICT_SSID_EVENT_FLAG */
"detected spoofed association response", /* IW_SPOOF_ASSOC_RESP_EVENT_FLAG */
"detected spoofed reassociation responses", /* IW_SPOOF_REASSOC_RESP_EVENT_FLAG */
"detected spoofed probe response", /* IW_SPOOF_PROBE_RESP_EVENT_FLAG */
"detected spoofed beacon", /* IW_SPOOF_BEACON_EVENT_FLAG */
"detected spoofed disassociation", /* IW_SPOOF_DISASSOC_EVENT_FLAG */
"detected spoofed authentication", /* IW_SPOOF_AUTH_EVENT_FLAG */
"detected spoofed deauthentication", /* IW_SPOOF_DEAUTH_EVENT_FLAG */
"detected spoofed unknown management frame", /* IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG */
"detected replay attack" /* IW_REPLAY_ATTACK_EVENT_FLAG */
};
// for wireless IDS_flooding_attack event message
char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {
"detected authentication flooding", /* IW_FLOOD_AUTH_EVENT_FLAG */
"detected association request flooding", /* IW_FLOOD_ASSOC_REQ_EVENT_FLAG */
"detected reassociation request flooding", /* IW_FLOOD_REASSOC_REQ_EVENT_FLAG */
"detected probe request flooding", /* IW_FLOOD_PROBE_REQ_EVENT_FLAG */
"detected disassociation flooding", /* IW_FLOOD_DISASSOC_EVENT_FLAG */
"detected deauthentication flooding", /* IW_FLOOD_DEAUTH_EVENT_FLAG */
"detected 802.1x eap-request flooding" /* IW_FLOOD_EAP_REQ_EVENT_FLAG */
};
/* timeout -- ms */
VOID RTMP_SetPeriodicTimer(
IN NDIS_MINIPORT_TIMER *pTimer,
IN unsigned long timeout)
{
timeout = ((timeout*HZ) / 1000);
pTimer->expires = jiffies + timeout;
add_timer(pTimer);
}
/* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */
VOID RTMP_OS_Init_Timer(
IN PRTMP_ADAPTER pAd,
IN NDIS_MINIPORT_TIMER *pTimer,
IN TIMER_FUNCTION function,
IN PVOID data)
{
init_timer(pTimer);
pTimer->data = (unsigned long)data;
pTimer->function = function;
}
VOID RTMP_OS_Add_Timer(
IN NDIS_MINIPORT_TIMER *pTimer,
IN unsigned long timeout)
{
if (timer_pending(pTimer))
return;
timeout = ((timeout*HZ) / 1000);
pTimer->expires = jiffies + timeout;
add_timer(pTimer);
}
VOID RTMP_OS_Mod_Timer(
IN NDIS_MINIPORT_TIMER *pTimer,
IN unsigned long timeout)
{
timeout = ((timeout*HZ) / 1000);
mod_timer(pTimer, jiffies + timeout);
}
VOID RTMP_OS_Del_Timer(
IN NDIS_MINIPORT_TIMER *pTimer,
OUT BOOLEAN *pCancelled)
{
if (timer_pending(pTimer))
{
*pCancelled = del_timer_sync(pTimer);
}
else
{
*pCancelled = TRUE;
}
}
VOID RTMP_OS_Release_Packet(
IN PRTMP_ADAPTER pAd,
IN PQUEUE_ENTRY pEntry)
{
//RTMPFreeNdisPacket(pAd, (struct sk_buff *)pEntry);
}
// Unify all delay routine by using udelay
VOID RTMPusecDelay(
IN ULONG usec)
{
ULONG i;
for (i = 0; i < (usec / 50); i++)
udelay(50);
if (usec % 50)
udelay(usec % 50);
}
void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time)
{
time->u.LowPart = jiffies;
}
// pAd MUST allow to be NULL
NDIS_STATUS os_alloc_mem(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR *mem,
IN ULONG size)
{
*mem = (PUCHAR) kmalloc(size, GFP_ATOMIC);
if (*mem)
return (NDIS_STATUS_SUCCESS);
else
return (NDIS_STATUS_FAILURE);
}
// pAd MUST allow to be NULL
NDIS_STATUS os_free_mem(
IN PRTMP_ADAPTER pAd,
IN PUCHAR mem)
{
ASSERT(mem);
kfree(mem);
return (NDIS_STATUS_SUCCESS);
}
PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
IN PRTMP_ADAPTER pAd,
IN ULONG Length)
{
struct sk_buff *pkt;
pkt = dev_alloc_skb(Length);
if (pkt == NULL)
{
DBGPRINT(RT_DEBUG_ERROR, ("can't allocate frag rx %ld size packet\n",Length));
}
if (pkt)
{
RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
}
return (PNDIS_PACKET) pkt;
}
PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
IN PRTMP_ADAPTER pAd,
IN ULONG Length,
IN BOOLEAN Cached,
OUT PVOID *VirtualAddress)
{
struct sk_buff *pkt;
pkt = dev_alloc_skb(Length);
if (pkt == NULL)
{
DBGPRINT(RT_DEBUG_ERROR, ("can't allocate tx %ld size packet\n",Length));
}
if (pkt)
{
RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
*VirtualAddress = (PVOID) pkt->data;
}
else
{
*VirtualAddress = (PVOID) NULL;
}
return (PNDIS_PACKET) pkt;
}
VOID build_tx_packet(
IN PRTMP_ADAPTER pAd,
IN PNDIS_PACKET pPacket,
IN PUCHAR pFrame,
IN ULONG FrameLen)
{
struct sk_buff *pTxPkt;
ASSERT(pPacket);
pTxPkt = RTPKT_TO_OSPKT(pPacket);
NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);
}
VOID RTMPFreeAdapter(
IN PRTMP_ADAPTER pAd)
{
POS_COOKIE os_cookie;
int index;
os_cookie=(POS_COOKIE)pAd->OS_Cookie;
kfree(pAd->BeaconBuf);
NdisFreeSpinLock(&pAd->MgmtRingLock);
for (index =0 ; index < NUM_OF_TX_RING; index++)
{
NdisFreeSpinLock(&pAd->TxSwQueueLock[index]);
NdisFreeSpinLock(&pAd->DeQueueLock[index]);
pAd->DeQueueRunning[index] = FALSE;
}
NdisFreeSpinLock(&pAd->irq_lock);
vfree(pAd); // pci_free_consistent(os_cookie->pci_dev,sizeof(RTMP_ADAPTER),pAd,os_cookie->pAd_pa);
kfree(os_cookie);
}
BOOLEAN OS_Need_Clone_Packet(void)
{
return (FALSE);
}
/*
========================================================================
Routine Description:
clone an input NDIS PACKET to another one. The new internally created NDIS PACKET
must have only one NDIS BUFFER
return - byte copied. 0 means can't create NDIS PACKET
NOTE: internally created NDIS_PACKET should be destroyed by RTMPFreeNdisPacket
Arguments:
pAd Pointer to our adapter
pInsAMSDUHdr EWC A-MSDU format has extra 14-bytes header. if TRUE, insert this 14-byte hdr in front of MSDU.
*pSrcTotalLen return total packet length. This lenght is calculated with 802.3 format packet.
Return Value:
NDIS_STATUS_SUCCESS
NDIS_STATUS_FAILURE
Note:
========================================================================
*/
NDIS_STATUS RTMPCloneNdisPacket(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN pInsAMSDUHdr,
IN PNDIS_PACKET pInPacket,
OUT PNDIS_PACKET *ppOutPacket)
{
struct sk_buff *pkt;
ASSERT(pInPacket);
ASSERT(ppOutPacket);
// 1. Allocate a packet
pkt = dev_alloc_skb(2048);
if (pkt == NULL)
{
return NDIS_STATUS_FAILURE;
}
skb_put(pkt, GET_OS_PKT_LEN(pInPacket));
NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket), GET_OS_PKT_LEN(pInPacket));
*ppOutPacket = OSPKT_TO_RTPKT(pkt);
RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
printk("###Clone###\n");
return NDIS_STATUS_SUCCESS;
}
// the allocated NDIS PACKET must be freed via RTMPFreeNdisPacket()
NDIS_STATUS RTMPAllocateNdisPacket(
IN PRTMP_ADAPTER pAd,
OUT PNDIS_PACKET *ppPacket,
IN PUCHAR pHeader,
IN UINT HeaderLen,
IN PUCHAR pData,
IN UINT DataLen)
{
PNDIS_PACKET pPacket;
ASSERT(pData);
ASSERT(DataLen);
// 1. Allocate a packet
pPacket = (PNDIS_PACKET *) dev_alloc_skb(HeaderLen + DataLen + TXPADDING_SIZE);
if (pPacket == NULL)
{
*ppPacket = NULL;
#ifdef DEBUG
printk("RTMPAllocateNdisPacket Fail\n\n");
#endif
return NDIS_STATUS_FAILURE;
}
// 2. clone the frame content
if (HeaderLen > 0)
NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket), pHeader, HeaderLen);
if (DataLen > 0)
NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket) + HeaderLen, pData, DataLen);
// 3. update length of packet
skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
// printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket));
*ppPacket = pPacket;
return NDIS_STATUS_SUCCESS;
}
/*
========================================================================
Description:
This routine frees a miniport internally allocated NDIS_PACKET and its
corresponding NDIS_BUFFER and allocated memory.
========================================================================
*/
VOID RTMPFreeNdisPacket(
IN PRTMP_ADAPTER pAd,
IN PNDIS_PACKET pPacket)
{
dev_kfree_skb_any(RTPKT_TO_OSPKT(pPacket));
}
// IRQL = DISPATCH_LEVEL
// NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same
// scatter gather buffer
NDIS_STATUS Sniff2BytesFromNdisBuffer(
IN PNDIS_BUFFER pFirstBuffer,
IN UCHAR DesiredOffset,
OUT PUCHAR pByte0,
OUT PUCHAR pByte1)
{
*pByte0 = *(PUCHAR)(pFirstBuffer + DesiredOffset);
*pByte1 = *(PUCHAR)(pFirstBuffer + DesiredOffset + 1);
return NDIS_STATUS_SUCCESS;
}
void RTMP_QueryPacketInfo(
IN PNDIS_PACKET pPacket,
OUT PACKET_INFO *pPacketInfo,
OUT PUCHAR *pSrcBufVA,
OUT UINT *pSrcBufLen)
{
pPacketInfo->BufferCount = 1;
pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
pPacketInfo->PhysicalBufferCount = 1;
pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
*pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
*pSrcBufLen = GET_OS_PKT_LEN(pPacket);
}
void RTMP_QueryNextPacketInfo(
IN PNDIS_PACKET *ppPacket,
OUT PACKET_INFO *pPacketInfo,
OUT PUCHAR *pSrcBufVA,
OUT UINT *pSrcBufLen)
{
PNDIS_PACKET pPacket = NULL;
if (*ppPacket)
pPacket = GET_OS_PKT_NEXT(*ppPacket);
if (pPacket)
{
pPacketInfo->BufferCount = 1;
pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
pPacketInfo->PhysicalBufferCount = 1;
pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
*pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
*pSrcBufLen = GET_OS_PKT_LEN(pPacket);
*ppPacket = GET_OS_PKT_NEXT(pPacket);
}
else
{
pPacketInfo->BufferCount = 0;
pPacketInfo->pFirstBuffer = NULL;
pPacketInfo->PhysicalBufferCount = 0;
pPacketInfo->TotalPacketLength = 0;
*pSrcBufVA = NULL;
*pSrcBufLen = 0;
*ppPacket = NULL;
}
}
// not yet support MBSS
PNET_DEV get_netdev_from_bssid(
IN PRTMP_ADAPTER pAd,
IN UCHAR FromWhichBSSID)
{
PNET_DEV dev_p = NULL;
dev_p = pAd->net_dev;
ASSERT(dev_p);
return dev_p; /* return one of MBSS */
}
PNDIS_PACKET DuplicatePacket(
IN PRTMP_ADAPTER pAd,
IN PNDIS_PACKET pPacket,
IN UCHAR FromWhichBSSID)
{
struct sk_buff *skb;
PNDIS_PACKET pRetPacket = NULL;
USHORT DataSize;
UCHAR *pData;
DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
skb = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
if (skb)
{
skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
pRetPacket = OSPKT_TO_RTPKT(skb);
}
return pRetPacket;
}
PNDIS_PACKET duplicate_pkt(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pHeader802_3,
IN UINT HdrLen,
IN PUCHAR pData,
IN ULONG DataSize,
IN UCHAR FromWhichBSSID)
{
struct sk_buff *skb;
PNDIS_PACKET pPacket = NULL;
if ((skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG)) != NULL)
{
skb_reserve(skb, 2);
NdisMoveMemory(skb->tail, pHeader802_3, HdrLen);
skb_put(skb, HdrLen);
NdisMoveMemory(skb->tail, pData, DataSize);
skb_put(skb, DataSize);
skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
pPacket = OSPKT_TO_RTPKT(skb);
}
return pPacket;
}
#define TKIP_TX_MIC_SIZE 8
PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
IN PRTMP_ADAPTER pAd,
IN PNDIS_PACKET pPacket)
{
struct sk_buff *skb, *newskb;
skb = RTPKT_TO_OSPKT(pPacket);
if (skb_tailroom(skb) < TKIP_TX_MIC_SIZE)
{
// alloc a new skb and copy the packet
newskb = skb_copy_expand(skb, skb_headroom(skb), TKIP_TX_MIC_SIZE, GFP_ATOMIC);
dev_kfree_skb_any(skb);
if (newskb == NULL)
{
DBGPRINT(RT_DEBUG_ERROR, ("Extend Tx.MIC for packet failed!, dropping packet!\n"));
return NULL;
}
skb = newskb;
}
return OSPKT_TO_RTPKT(skb);
}
PNDIS_PACKET ClonePacket(
IN PRTMP_ADAPTER pAd,
IN PNDIS_PACKET pPacket,
IN PUCHAR pData,
IN ULONG DataSize)
{
struct sk_buff *pRxPkt;
struct sk_buff *pClonedPkt;
ASSERT(pPacket);
pRxPkt = RTPKT_TO_OSPKT(pPacket);
// clone the packet
pClonedPkt = skb_clone(pRxPkt, MEM_ALLOC_FLAG);
if (pClonedPkt)
{
// set the correct dataptr and data len
pClonedPkt->dev = pRxPkt->dev;
pClonedPkt->data = pData;
pClonedPkt->len = DataSize;
pClonedPkt->tail = pClonedPkt->data + pClonedPkt->len;
ASSERT(DataSize < 1530);
}
return pClonedPkt;
}
//
// change OS packet DataPtr and DataLen
//
void update_os_packet_info(
IN PRTMP_ADAPTER pAd,
IN RX_BLK *pRxBlk,
IN UCHAR FromWhichBSSID)
{
struct sk_buff *pOSPkt;
ASSERT(pRxBlk->pRxPacket);
pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
pOSPkt->data = pRxBlk->pData;
pOSPkt->len = pRxBlk->DataSize;
pOSPkt->tail = pOSPkt->data + pOSPkt->len;
}
void wlan_802_11_to_802_3_packet(
IN PRTMP_ADAPTER pAd,
IN RX_BLK *pRxBlk,
IN PUCHAR pHeader802_3,
IN UCHAR FromWhichBSSID)
{
struct sk_buff *pOSPkt;
ASSERT(pRxBlk->pRxPacket);
ASSERT(pHeader802_3);
pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
pOSPkt->data = pRxBlk->pData;
pOSPkt->len = pRxBlk->DataSize;
pOSPkt->tail = pOSPkt->data + pOSPkt->len;
//
// copy 802.3 header
//
//
NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3, LENGTH_802_3);
}
void announce_802_3_packet(
IN PRTMP_ADAPTER pAd,
IN PNDIS_PACKET pPacket)
{
struct sk_buff *pRxPkt;
ASSERT(pPacket);
pRxPkt = RTPKT_TO_OSPKT(pPacket);
/* Push up the protocol stack */
#ifdef IKANOS_VX_1X0
IKANOS_DataFrameRx(pAd, pRxPkt->dev, pRxPkt, pRxPkt->len);
#else
pRxPkt->protocol = eth_type_trans(pRxPkt, pRxPkt->dev);
netif_rx(pRxPkt);
#endif // IKANOS_VX_1X0 //
}
PRTMP_SCATTER_GATHER_LIST
rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg)
{
sg->NumberOfElements = 1;
sg->Elements[0].Address = GET_OS_PKT_DATAPTR(pPacket);
sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);
return (sg);
}
void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
{
unsigned char *pt;
int x;
if (RTDebugLevel < RT_DEBUG_TRACE)
return;
pt = pSrcBufVA;
printk("%s: %p, len = %d\n",str, pSrcBufVA, SrcBufLen);
for (x=0; x<SrcBufLen; x++)
{
if (x % 16 == 0)
printk("0x%04x : ", x);
printk("%02x ", ((unsigned char)pt[x]));
if (x%16 == 15) printk("\n");
}
printk("\n");
}
/*
========================================================================
Routine Description:
Send log message through wireless event
Support standard iw_event with IWEVCUSTOM. It is used below.
iwreq_data.data.flags is used to store event_flag that is defined by user.
iwreq_data.data.length is the length of the event log.
The format of the event log is composed of the entry's MAC address and
the desired log message (refer to pWirelessEventText).
ex: 11:22:33:44:55:66 has associated successfully
p.s. The requirement of Wireless Extension is v15 or newer.
========================================================================
*/
VOID RTMPSendWirelessEvent(
IN PRTMP_ADAPTER pAd,
IN USHORT Event_flag,
IN PUCHAR pAddr,
IN UCHAR BssIdx,
IN CHAR Rssi)
{
#if WIRELESS_EXT >= 15
union iwreq_data wrqu;
PUCHAR pBuf = NULL, pBufPtr = NULL;
USHORT event, type, BufLen;
UCHAR event_table_len = 0;
type = Event_flag & 0xFF00;
event = Event_flag & 0x00FF;
switch (type)
{
case IW_SYS_EVENT_FLAG_START:
event_table_len = IW_SYS_EVENT_TYPE_NUM;
break;
case IW_SPOOF_EVENT_FLAG_START:
event_table_len = IW_SPOOF_EVENT_TYPE_NUM;
break;
case IW_FLOOD_EVENT_FLAG_START:
event_table_len = IW_FLOOD_EVENT_TYPE_NUM;
break;
}
if (event_table_len == 0)
{
DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __func__, type));
return;
}
if (event >= event_table_len)
{
DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __func__, event));
return;
}
//Allocate memory and copy the msg.
if((pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC)) != NULL)
{
//Prepare the payload
memset(pBuf, 0, IW_CUSTOM_MAX_LEN);
pBufPtr = pBuf;
if (pAddr)
pBufPtr += sprintf(pBufPtr, "(RT2860) STA(%02x:%02x:%02x:%02x:%02x:%02x) ", PRINT_MAC(pAddr));
else if (BssIdx < MAX_MBSSID_NUM)
pBufPtr += sprintf(pBufPtr, "(RT2860) BSS(ra%d) ", BssIdx);
else
pBufPtr += sprintf(pBufPtr, "(RT2860) ");
if (type == IW_SYS_EVENT_FLAG_START)
pBufPtr += sprintf(pBufPtr, "%s", pWirelessSysEventText[event]);
else if (type == IW_SPOOF_EVENT_FLAG_START)
pBufPtr += sprintf(pBufPtr, "%s (RSSI=%d)", pWirelessSpoofEventText[event], Rssi);
else if (type == IW_FLOOD_EVENT_FLAG_START)
pBufPtr += sprintf(pBufPtr, "%s", pWirelessFloodEventText[event]);
else
pBufPtr += sprintf(pBufPtr, "%s", "unknown event");
pBufPtr[pBufPtr - pBuf] = '\0';
BufLen = pBufPtr - pBuf;
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.flags = Event_flag;
wrqu.data.length = BufLen;
//send wireless event
wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
//DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf));
kfree(pBuf);
}
else
DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __func__));
#else
DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __func__));
#endif /* WIRELESS_EXT >= 15 */
}
void send_monitor_packets(
IN PRTMP_ADAPTER pAd,
IN RX_BLK *pRxBlk)
{
struct sk_buff *pOSPkt;
wlan_ng_prism2_header *ph;
int rate_index = 0;
USHORT header_len = 0;
UCHAR temp_header[40] = {0};
u_int32_t ralinkrate[256] = {2,4,11,22, 12,18,24,36,48,72,96, 108, 109, 110, 111, 112, 13, 26, 39, 52,78,104, 117, 130, 26, 52, 78,104, 156, 208, 234, 260, 27, 54,81,108,162, 216, 243, 270, // Last 38
54, 108, 162, 216, 324, 432, 486, 540, 14, 29, 43, 57, 87, 115, 130, 144, 29, 59,87,115, 173, 230,260, 288, 30, 60,90,120,180,240,270,300,60,120,180,240,360,480,540,600, 0,1,2,3,4,5,6,7,8,9,10,
11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80};
ASSERT(pRxBlk->pRxPacket);
if (pRxBlk->DataSize < 10)
{
DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __func__, pRxBlk->DataSize));
goto err_free_sk_buff;
}
if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
{
#ifndef RT30xx
DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%zu)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
#endif
#ifdef RT30xx
DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
#endif
goto err_free_sk_buff;
}
pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0);
if (pRxBlk->pHeader->FC.Type == BTYPE_DATA)
{
pRxBlk->DataSize -= LENGTH_802_11;
if ((pRxBlk->pHeader->FC.ToDs == 1) &&
(pRxBlk->pHeader->FC.FrDs == 1))
header_len = LENGTH_802_11_WITH_ADDR4;
else
header_len = LENGTH_802_11;
// QOS
if (pRxBlk->pHeader->FC.SubType & 0x08)
{
header_len += 2;
// Data skip QOS contorl field
pRxBlk->DataSize -=2;
}
// Order bit: A-Ralink or HTC+
if (pRxBlk->pHeader->FC.Order)
{
header_len += 4;
// Data skip HTC contorl field
pRxBlk->DataSize -= 4;
}
// Copy Header
if (header_len <= 40)
NdisMoveMemory(temp_header, pRxBlk->pData, header_len);
// skip HW padding
if (pRxBlk->RxD.L2PAD)
pRxBlk->pData += (header_len + 2);
else
pRxBlk->pData += header_len;
} //end if
if (pRxBlk->DataSize < pOSPkt->len) {
skb_trim(pOSPkt,pRxBlk->DataSize);
} else {
skb_put(pOSPkt,(pRxBlk->DataSize - pOSPkt->len));
} //end if
if ((pRxBlk->pData - pOSPkt->data) > 0) {
skb_put(pOSPkt,(pRxBlk->pData - pOSPkt->data));
skb_pull(pOSPkt,(pRxBlk->pData - pOSPkt->data));
} //end if
if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __func__));
goto err_free_sk_buff;
} //end if
} //end if
if (header_len > 0)
NdisMoveMemory(skb_push(pOSPkt, header_len), temp_header, header_len);
ph = (wlan_ng_prism2_header *) skb_push(pOSPkt, sizeof(wlan_ng_prism2_header));
NdisZeroMemory(ph, sizeof(wlan_ng_prism2_header));
ph->msgcode = DIDmsg_lnxind_wlansniffrm;
ph->msglen = sizeof(wlan_ng_prism2_header);
strcpy(ph->devname, pAd->net_dev->name);
ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
ph->hosttime.status = 0;
ph->hosttime.len = 4;
ph->hosttime.data = jiffies;
ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
ph->mactime.status = 0;
ph->mactime.len = 0;
ph->mactime.data = 0;
ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
ph->istx.status = 0;
ph->istx.len = 0;
ph->istx.data = 0;
ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
ph->channel.status = 0;
ph->channel.len = 4;
ph->channel.data = (u_int32_t)pAd->CommonCfg.Channel;
ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
ph->rssi.status = 0;
ph->rssi.len = 4;
ph->rssi.data = (u_int32_t)RTMPMaxRssi(pAd, ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI0, RSSI_0), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI1, RSSI_1), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI2, RSSI_2));;
ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
ph->signal.status = 0;
ph->signal.len = 4;
ph->signal.data = 0; //rssi + noise;
ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
ph->noise.status = 0;
ph->noise.len = 4;
ph->noise.data = 0;
if (pRxBlk->pRxWI->PHYMODE >= MODE_HTMIX)
{
rate_index = 16 + ((UCHAR)pRxBlk->pRxWI->BW *16) + ((UCHAR)pRxBlk->pRxWI->ShortGI *32) + ((UCHAR)pRxBlk->pRxWI->MCS);
}
else
if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
rate_index = (UCHAR)(pRxBlk->pRxWI->MCS) + 4;
else
rate_index = (UCHAR)(pRxBlk->pRxWI->MCS);
if (rate_index < 0)
rate_index = 0;
if (rate_index > 255)
rate_index = 255;
ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
ph->rate.status = 0;
ph->rate.len = 4;
ph->rate.data = ralinkrate[rate_index];
ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
ph->frmlen.status = 0;
ph->frmlen.len = 4;
ph->frmlen.data = (u_int32_t)pRxBlk->DataSize;
pOSPkt->pkt_type = PACKET_OTHERHOST;
pOSPkt->protocol = eth_type_trans(pOSPkt, pOSPkt->dev);
pOSPkt->ip_summed = CHECKSUM_NONE;
netif_rx(pOSPkt);
return;
err_free_sk_buff:
RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
return;
}
void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
{
daemonize(pThreadName /*"%s",pAd->net_dev->name*/);
allow_signal(SIGTERM);
allow_signal(SIGKILL);
current->flags |= PF_NOFREEZE;
/* signal that we've started the thread */
complete(pNotify);
}
void RTMP_IndicateMediaState(
IN PRTMP_ADAPTER pAd)
{
if (pAd->CommonCfg.bWirelessEvent)
{
if (pAd->IndicateMediaState == NdisMediaStateConnected)
{
RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
}
else
{
RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
}
}
}
#include "../rt2860/rt_linux.c"
/*
*************************************************************************
* 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. *
* *
*************************************************************************
*/
/***********************************************************************/
/* */
/* Program: rt_linux.c */
/* Created: 4/21/2006 1:17:38 PM */
/* Author: Wu Xi-Kun */
/* Comments: `description` */
/* */
/*---------------------------------------------------------------------*/
/* */
/* History: */
/* Revision 1.1 4/21/2006 1:17:38 PM xsikun */
/* Initial revision */
/* */
/***********************************************************************/
#include "rtmp_type.h"
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#ifndef RT30xx
#include <linux/kthread.h>
#endif
#include <linux/spinlock.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/ethtool.h>
#include <linux/wireless.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
#include <linux/if_arp.h>
#include <linux/ctype.h>
#include <linux/vmalloc.h>
#ifdef RT30xx
#include <linux/wireless.h>
#endif
#include <net/iw_handler.h>
// load firmware
#define __KERNEL_SYSCALLS__
#include <linux/unistd.h>
#include <asm/uaccess.h>
#define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
#ifndef IFNAMSIZ
#define IFNAMSIZ 16
#endif
//#define CONFIG_CKIP_SUPPORT
#undef __inline
#define __inline static inline
typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
// add by kathy
#ifdef RT2870
#define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
#define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin"
#define STA_NIC_DEVICE_NAME "RT2870STA"
#ifndef RT30xx
#define STA_DRIVER_VERSION "1.4.0.0"
#endif
#ifdef RT30xx
#define STA_DRIVER_VERSION "2.0.1.0"
#endif
#endif // RT2870 //
#define RTMP_TIME_AFTER(a,b) \
(typecheck(unsigned long, (unsigned long)a) && \
typecheck(unsigned long, (unsigned long)b) && \
((long)(b) - (long)(a) < 0))
#define RTMP_TIME_AFTER_EQ(a,b) \
(typecheck(unsigned long, (unsigned long)a) && \
typecheck(unsigned long, (unsigned long)b) && \
((long)(a) - (long)(b) >= 0))
#define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
#define RT_MOD_INC_USE_COUNT() \
if (!try_module_get(THIS_MODULE)) \
{ \
DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
return -1; \
}
#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
#define OS_HZ HZ
#define ETH_LENGTH_OF_ADDRESS 6
#define IN
#define OUT
#define NDIS_STATUS INT
#define NDIS_STATUS_SUCCESS 0x00
#define NDIS_STATUS_FAILURE 0x01
#define NDIS_STATUS_INVALID_DATA 0x02
#define NDIS_STATUS_RESOURCES 0x03
#define MIN_NET_DEVICE_FOR_AID 0x00 //0x00~0x3f
#define MIN_NET_DEVICE_FOR_MBSSID 0x00 //0x00,0x10,0x20,0x30
#define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70
#define MIN_NET_DEVICE_FOR_APCLI 0x20
#define MIN_NET_DEVICE_FOR_MESH 0x30
#define MIN_NET_DEVICE_FOR_DLS 0x40
#define NDIS_PACKET_TYPE_DIRECTED 0
#define NDIS_PACKET_TYPE_MULTICAST 1
#define NDIS_PACKET_TYPE_BROADCAST 2
#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
#ifndef RT30xx
typedef struct pid * THREAD_PID;
#define GET_PID(_v) find_get_pid(_v)
#define GET_PID_NUMBER(_v) pid_nr(_v)
#define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0)
#define KILL_THREAD_PID(_A, _B, _C) kill_pid(_A, _B, _C)
#endif
struct os_lock {
spinlock_t lock;
unsigned long flags;
};
struct os_cookie {
#ifdef RT2870
struct usb_device *pUsb_Dev;
#ifndef RT30xx
struct task_struct *MLMEThr_task;
struct task_struct *RTUSBCmdThr_task;
struct task_struct *TimerQThr_task;
#endif
#ifdef RT30xx
struct pid * MLMEThr_pid;
struct pid * RTUSBCmdThr_pid;
struct pid * TimerQThr_pid;
#endif
#endif // RT2870 //
struct tasklet_struct rx_done_task;
struct tasklet_struct mgmt_dma_done_task;
struct tasklet_struct ac0_dma_done_task;
struct tasklet_struct ac1_dma_done_task;
struct tasklet_struct ac2_dma_done_task;
struct tasklet_struct ac3_dma_done_task;
struct tasklet_struct hcca_dma_done_task;
struct tasklet_struct tbtt_task;
#ifdef RT2870
struct tasklet_struct null_frame_complete_task;
struct tasklet_struct rts_frame_complete_task;
struct tasklet_struct pspoll_frame_complete_task;
#endif // RT2870 //
unsigned long apd_pid; //802.1x daemon pid
INT ioctl_if_type;
INT ioctl_if;
};
typedef struct _VIRTUAL_ADAPTER
{
struct net_device *RtmpDev;
struct net_device *VirtualDev;
} VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
#undef ASSERT
#define ASSERT(x)
typedef struct os_cookie * POS_COOKIE;
typedef struct pci_dev * PPCI_DEV;
typedef struct net_device * PNET_DEV;
typedef void * PNDIS_PACKET;
typedef char NDIS_PACKET;
typedef PNDIS_PACKET * PPNDIS_PACKET;
typedef dma_addr_t NDIS_PHYSICAL_ADDRESS;
typedef dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
typedef spinlock_t NDIS_SPIN_LOCK;
typedef struct timer_list NDIS_MINIPORT_TIMER;
typedef void * NDIS_HANDLE;
typedef char * PNDIS_BUFFER;
void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);
////////////////////////////////////////
// MOVE TO rtmp.h ?
/////////////////////////////////////////
#define PKTSRC_NDIS 0x7f
#define PKTSRC_DRIVER 0x0f
#define PRINT_MAC(addr) \
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
#define RT2860_PCI_DEVICE_ID 0x0601
#ifdef RT2870
#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
#endif // RT2870 //
#define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \
dma_cache_wback(_ptr, _size)
//////////////////////////////////////////
//
//////////////////////////////////////////
#define NdisMIndicateStatus(_w, _x, _y, _z)
typedef struct timer_list RTMP_OS_TIMER;
#ifdef RT2870
/* ----------------- Timer Related MARCO ---------------*/
// In RT2870, we have a lot of timer functions and will read/write register, it's
// not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
// to ctrl pipe). So we need a wrapper function to take care it.
typedef VOID (*RT2870_TIMER_HANDLE)(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
#endif // RT2870 //
typedef struct _RALINK_TIMER_STRUCT {
RTMP_OS_TIMER TimerObj; // Ndis Timer object
BOOLEAN Valid; // Set to True when call RTMPInitTimer
BOOLEAN State; // True if timer cancelled
BOOLEAN PeriodicType; // True if timer is periodic timer
BOOLEAN Repeat; // True if periodic timer
ULONG TimerValue; // Timer value in milliseconds
ULONG cookie; // os specific object
#ifdef RT2870
RT2870_TIMER_HANDLE handle;
void *pAd;
#endif // RT2870 //
} RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
#ifdef RT2870
typedef enum _RT2870_KERNEL_THREAD_STATUS_
{
RT2870_THREAD_UNKNOWN = 0,
RT2870_THREAD_INITED = 1,
RT2870_THREAD_RUNNING = 2,
RT2870_THREAD_STOPED = 4,
}RT2870_KERNEL_THREAD_STATUS;
#define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
typedef struct _RT2870_TIMER_ENTRY_
{
RALINK_TIMER_STRUCT *pRaTimer;
struct _RT2870_TIMER_ENTRY_ *pNext;
}RT2870_TIMER_ENTRY;
#define TIMER_QUEUE_SIZE_MAX 128
typedef struct _RT2870_TIMER_QUEUE_
{
unsigned int status;
UCHAR *pTimerQPoll;
RT2870_TIMER_ENTRY *pQPollFreeList;
RT2870_TIMER_ENTRY *pQHead;
RT2870_TIMER_ENTRY *pQTail;
}RT2870_TIMER_QUEUE;
#endif // RT2870 //
//#define DBG 1
//
// MACRO for debugging information
//
#ifdef DBG
extern ULONG RTDebugLevel;
#define DBGPRINT_RAW(Level, Fmt) \
{ \
if (Level <= RTDebugLevel) \
{ \
printk Fmt; \
} \
}
#define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
#define DBGPRINT_ERR(Fmt) \
{ \
printk("ERROR!!! "); \
printk Fmt; \
}
#define DBGPRINT_S(Status, Fmt) \
{ \
printk Fmt; \
}
#else
#define DBGPRINT(Level, Fmt)
#define DBGPRINT_RAW(Level, Fmt)
#define DBGPRINT_S(Status, Fmt)
#define DBGPRINT_ERR(Fmt)
#endif
//
// spin_lock enhanced for Nested spin lock
//
#define NdisAllocateSpinLock(__lock) \
{ \
spin_lock_init((spinlock_t *)(__lock)); \
}
#define NdisFreeSpinLock(lock) \
{ \
}
#define RTMP_SEM_LOCK(__lock) \
{ \
spin_lock_bh((spinlock_t *)(__lock)); \
}
#define RTMP_SEM_UNLOCK(__lock) \
{ \
spin_unlock_bh((spinlock_t *)(__lock)); \
}
// sample, use semaphore lock to replace IRQ lock, 2007/11/15
#define RTMP_IRQ_LOCK(__lock, __irqflags) \
{ \
__irqflags = 0; \
spin_lock_bh((spinlock_t *)(__lock)); \
pAd->irq_disabled |= 1; \
}
#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
{ \
pAd->irq_disabled &= 0; \
spin_unlock_bh((spinlock_t *)(__lock)); \
}
#define RTMP_INT_LOCK(__lock, __irqflags) \
{ \
spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
}
#define RTMP_INT_UNLOCK(__lock, __irqflag) \
{ \
spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
}
#ifdef RT2870
//Patch for ASIC turst read/write bug, needs to remove after metel fix
#define RTMP_IO_READ32(_A, _R, _pV) \
RTUSBReadMACRegister(_A, _R, _pV)
#define RTMP_IO_READ8(_A, _R, _pV) \
{ \
}
#define RTMP_IO_WRITE32(_A, _R, _V) \
RTUSBWriteMACRegister(_A, _R, _V)
#define RTMP_IO_WRITE8(_A, _R, _V) \
{ \
USHORT _Val = _V; \
RTUSBSingleWrite(_A, _R, _Val); \
}
#define RTMP_IO_WRITE16(_A, _R, _V) \
{ \
RTUSBSingleWrite(_A, _R, _V); \
}
#endif // RT2870 //
#ifndef wait_event_interruptible_timeout
#define __wait_event_interruptible_timeout(wq, condition, ret) \
do { \
wait_queue_t __wait; \
init_waitqueue_entry(&__wait, current); \
add_wait_queue(&wq, &__wait); \
for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \
if (condition) \
break; \
if (!signal_pending(current)) { \
ret = schedule_timeout(ret); \
if (!ret) \
break; \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
current->state = TASK_RUNNING; \
remove_wait_queue(&wq, &__wait); \
} while (0)
#define wait_event_interruptible_timeout(wq, condition, timeout) \
({ \
long __ret = timeout; \
if (!(condition)) \
__wait_event_interruptible_timeout(wq, condition, __ret); \
__ret; \
})
#endif
#define ONE_TICK 1
#define OS_WAIT(_time) \
{ int _i; \
long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
wait_queue_head_t _wait; \
init_waitqueue_head(&_wait); \
for (_i=0; _i<(_loop); _i++) \
wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
typedef void (*TIMER_FUNCTION)(unsigned long);
#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
#define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
#ifdef RT2870
#define BUILD_TIMER_FUNCTION(_func) \
void linux_##_func(unsigned long data) \
{ \
PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
RT2870_TIMER_ENTRY *_pQNode; \
RTMP_ADAPTER *_pAd; \
\
_pTimer->handle = _func; \
_pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
_pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \
if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \
RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \
}
#endif // RT2870 //
#define DECLARE_TIMER_FUNCTION(_func) \
void linux_##_func(unsigned long data)
#define GET_TIMER_FUNCTION(_func) \
linux_##_func
DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
#ifdef RT2870
DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
#endif // RT2870 //
DECLARE_TIMER_FUNCTION(BeaconTimeout);
DECLARE_TIMER_FUNCTION(ScanTimeout);
DECLARE_TIMER_FUNCTION(AuthTimeout);
DECLARE_TIMER_FUNCTION(AssocTimeout);
DECLARE_TIMER_FUNCTION(ReassocTimeout);
DECLARE_TIMER_FUNCTION(DisassocTimeout);
DECLARE_TIMER_FUNCTION(LinkDownExec);
DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
DECLARE_TIMER_FUNCTION(PsPollWakeExec);
DECLARE_TIMER_FUNCTION(RadioOnExec);
void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
/*
* packet helper
* - convert internal rt packet to os packet or
* os packet to rt packet
*/
#define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
#define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p))
#define GET_OS_PKT_DATAPTR(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->data)
#define GET_OS_PKT_LEN(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->len)
#define GET_OS_PKT_DATATAIL(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->tail)
#define GET_OS_PKT_HEAD(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->head)
#define GET_OS_PKT_END(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->end)
#define GET_OS_PKT_NETDEV(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->dev)
#define GET_OS_PKT_TYPE(_pkt) \
(RTPKT_TO_OSPKT(_pkt))
#define GET_OS_PKT_NEXT(_pkt) \
(RTPKT_TO_OSPKT(_pkt)->next)
#define OS_NTOHS(_Val) \
(ntohs(_Val))
#define OS_HTONS(_Val) \
(htons(_Val))
#define OS_NTOHL(_Val) \
(ntohl(_Val))
#define OS_HTONL(_Val) \
(htonl(_Val))
/* statistics counter */
#define STATS_INC_RX_PACKETS(_pAd, _dev)
#define STATS_INC_TX_PACKETS(_pAd, _dev)
#define STATS_INC_RX_BYTESS(_pAd, _dev, len)
#define STATS_INC_TX_BYTESS(_pAd, _dev, len)
#define STATS_INC_RX_ERRORS(_pAd, _dev)
#define STATS_INC_TX_ERRORS(_pAd, _dev)
#define STATS_INC_RX_DROPPED(_pAd, _dev)
#define STATS_INC_TX_DROPPED(_pAd, _dev)
#define CB_OFF 10
// check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without
// ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver
//
// User Priority
#define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
#define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
// Fragment #
#define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
#define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
// 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too.
//(this value also as MAC(on-chip WCID) table index)
// 0x80~0xff: TX to a WDS link. b0~6: WDS index
#define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
#define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
// 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
#define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
// RTS/CTS-to-self protection method
#define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
#define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
// see RTMP_S(G)ET_PACKET_EMACTAB
// TX rate index
#define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
#define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
// From which Interface
#define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
#define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
#define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
#define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
#define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
//
// Sepcific Pakcet Type definition
//
#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
#define RTMP_PACKET_SPECIFIC_DHCP 0x01
#define RTMP_PACKET_SPECIFIC_EAPOL 0x02
#define RTMP_PACKET_SPECIFIC_IPV4 0x04
#define RTMP_PACKET_SPECIFIC_WAI 0x08
#define RTMP_PACKET_SPECIFIC_VLAN 0x10
#define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
//Specific
#define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
//DHCP
#define RTMP_SET_PACKET_DHCP(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \
}while(0)
#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
//EAPOL
#define RTMP_SET_PACKET_EAPOL(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \
}while(0)
#define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
//WAI
#define RTMP_SET_PACKET_WAI(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \
}while(0)
#define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
#define RTMP_GET_PACKET_LOWRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
//VLAN
#define RTMP_SET_PACKET_VLAN(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \
}while(0)
#define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
//LLC/SNAP
#define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \
}while(0)
#define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
// IP
#define RTMP_SET_PACKET_IPV4(_p, _flg) \
do{ \
if (_flg) \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
else \
(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \
}while(0)
#define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
// If this flag is set, it indicates that this EAPoL frame MUST be clear.
#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
#define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
#define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
#ifdef CONFIG_5VT_ENHANCE
#define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c
#endif
#define NDIS_SET_PACKET_STATUS(_p, _status)
#define GET_SG_LIST_FROM_PACKET(_p, _sc) \
rt_get_sg_list_from_packet(_p, _sc)
#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
#define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
#define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
#define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
#define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
#define RTMP_INC_REF(_A) 0
#define RTMP_DEC_REF(_A) 0
#define RTMP_GET_REF(_A) 0
/*
* ULONG
* RTMP_GetPhysicalAddressLow(
* IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
*/
#define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
/*
* ULONG
* RTMP_GetPhysicalAddressHigh(
* IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
*/
#define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
/*
* VOID
* RTMP_SetPhysicalAddressLow(
* IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
* IN ULONG Value);
*/
#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
PhysicalAddress = Value;
/*
* VOID
* RTMP_SetPhysicalAddressHigh(
* IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
* IN ULONG Value);
*/
#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
//CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
#define QUEUE_ENTRY_TO_PACKET(pEntry) \
(PNDIS_PACKET)(pEntry)
#define PACKET_TO_QUEUE_ENTRY(pPacket) \
(PQUEUE_ENTRY)(pPacket)
#ifndef CONTAINING_RECORD
#define CONTAINING_RECORD(address, type, field) \
((type *)((PCHAR)(address) - offsetof(type, field)))
#endif
#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
{ \
RTMPFreeNdisPacket(_pAd, _pPacket); \
}
#define SWITCH_PhyAB(_pAA, _pBB) \
{ \
ULONG AABasePaHigh; \
ULONG AABasePaLow; \
ULONG BBBasePaHigh; \
ULONG BBBasePaLow; \
BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB); \
BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB); \
AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA); \
AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA); \
RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh); \
RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow); \
RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh); \
RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow); \
}
#define NdisWriteErrorLogEntry(_a, _b, _c, _d)
#define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e) NDIS_STATUS_SUCCESS
#define NdisAcquireSpinLock RTMP_SEM_LOCK
#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
static inline void NdisGetSystemUpTime(ULONG *time)
{
*time = jiffies;
}
//pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
#define QUEUE_ENTRY_TO_PKT(pEntry) \
((PNDIS_PACKET) (pEntry))
int rt28xx_packet_xmit(struct sk_buff *skb);
void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
#include "../rt2860/rt_linux.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt_main_dev.c
Abstract:
Create and register network interface.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Sample Mar/21/07 Merge RT2870 and RT2860 drivers.
*/
#include "rt_config.h"
#define FORTY_MHZ_INTOLERANT_INTERVAL (60*1000) // 1 min
/*---------------------------------------------------------------------*/
/* Private Variables Used */
/*---------------------------------------------------------------------*/
//static RALINK_TIMER_STRUCT PeriodicTimer;
char *mac = ""; // default 00:00:00:00:00:00
char *hostname = "";
module_param (mac, charp, 0);
MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
/*---------------------------------------------------------------------*/
/* Prototypes of Functions Used */
/*---------------------------------------------------------------------*/
extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
// public function prototype
INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
// private function prototype
static int rt28xx_init(IN struct net_device *net_dev);
INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
static void CfgInitHook(PRTMP_ADAPTER pAd);
extern const struct iw_handler_def rt28xx_iw_handler_def;
#if WIRELESS_EXT >= 12
// This function will be called when query /proc
struct iw_statistics *rt28xx_get_wireless_stats(
IN struct net_device *net_dev);
#endif
struct net_device_stats *RT28xx_get_ether_stats(
IN struct net_device *net_dev);
/*
========================================================================
Routine Description:
Close raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int MainVirtualIF_close(IN struct net_device *net_dev)
{
RTMP_ADAPTER *pAd = net_dev->ml_priv;
// Sanity check for pAd
if (pAd == NULL)
return 0; // close ok
netif_carrier_off(pAd->net_dev);
netif_stop_queue(pAd->net_dev);
VIRTUAL_IF_DOWN(pAd);
RT_MOD_DEC_USE_COUNT();
return 0; // close ok
}
/*
========================================================================
Routine Description:
Open raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int MainVirtualIF_open(IN struct net_device *net_dev)
{
RTMP_ADAPTER *pAd = net_dev->ml_priv;
// Sanity check for pAd
if (pAd == NULL)
return 0; // close ok
if (VIRTUAL_IF_UP(pAd) != 0)
return -1;
// increase MODULE use count
RT_MOD_INC_USE_COUNT();
netif_start_queue(net_dev);
netif_carrier_on(net_dev);
netif_wake_queue(net_dev);
return 0;
}
/*
========================================================================
Routine Description:
Close raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int rt28xx_close(IN PNET_DEV dev)
{
struct net_device * net_dev = (struct net_device *)dev;
RTMP_ADAPTER *pAd = net_dev->ml_priv;
BOOLEAN Cancelled = FALSE;
UINT32 i = 0;
#ifdef RT2870
DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
DECLARE_WAITQUEUE(wait, current);
//RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
#endif // RT2870 //
DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
// Sanity check for pAd
if (pAd == NULL)
return 0; // close ok
{
// If dirver doesn't wake up firmware here,
// NICLoadFirmware will hang forever when interface is up again.
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
{
AsicForceWakeup(pAd, TRUE);
}
if (INFRA_ON(pAd) &&
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
{
MLME_DISASSOC_REQ_STRUCT DisReq;
MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
MsgElem->Machine = ASSOC_STATE_MACHINE;
MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
// Prevent to connect AP again in STAMlmePeriodicExec
pAd->MlmeAux.AutoReconnectSsidLen= 32;
NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
MlmeDisassocReqAction(pAd, MsgElem);
kfree(MsgElem);
RTMPusecDelay(1000);
}
#ifdef RT2870
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
#endif // RT2870 //
#ifdef CCX_SUPPORT
RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
#endif
RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
MlmeRadioOff(pAd);
}
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
for (i = 0 ; i < NUM_OF_TX_RING; i++)
{
while (pAd->DeQueueRunning[i] == TRUE)
{
printk("Waiting for TxQueue[%d] done..........\n", i);
RTMPusecDelay(1000);
}
}
#ifdef RT2870
// ensure there are no more active urbs.
add_wait_queue (&unlink_wakeup, &wait);
pAd->wait = &unlink_wakeup;
// maybe wait for deletions to finish.
i = 0;
//while((i < 25) && atomic_read(&pAd->PendingRx) > 0)
while(i < 25)
{
unsigned long IrqFlags;
RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
if (pAd->PendingRx == 0)
{
RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
break;
}
RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
msleep(UNLINK_TIMEOUT_MS); //Time in millisecond
i++;
}
pAd->wait = NULL;
remove_wait_queue (&unlink_wakeup, &wait);
#endif // RT2870 //
#ifdef RT2870
// We need clear timerQ related structure before exits of the timer thread.
RT2870_TimerQ_Exit(pAd);
// Close kernel threads or tasklets
RT28xxThreadTerminate(pAd);
#endif // RT2870 //
// Stop Mlme state machine
MlmeHalt(pAd);
// Close kernel threads or tasklets
kill_thread_task(pAd);
MacTableReset(pAd);
MeasureReqTabExit(pAd);
TpcReqTabExit(pAd);
// Free Ring or USB buffers
RTMPFreeTxRxRingMemory(pAd);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
// Free BA reorder resource
ba_reordering_resource_release(pAd);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
return 0; // close ok
} /* End of rt28xx_close */
static int rt28xx_init(IN struct net_device *net_dev)
{
PRTMP_ADAPTER pAd = net_dev->ml_priv;
UINT index;
UCHAR TmpPhy;
NDIS_STATUS Status;
UINT32 MacCsr0 = 0;
// Allocate BA Reordering memory
ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
// Make sure MAC gets ready.
index = 0;
do
{
RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
pAd->MACVersion = MacCsr0;
if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
break;
RTMPusecDelay(10);
} while (index++ < 100);
DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
/*Iverson patch PCIE L1 issue */
// Disable DMA
RT28XXDMADisable(pAd);
// Load 8051 firmware
Status = NICLoadFirmware(pAd);
if (Status != NDIS_STATUS_SUCCESS)
{
DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
goto err1;
}
NICLoadRateSwitchingParams(pAd);
// Disable interrupts here which is as soon as possible
// This statement should never be true. We might consider to remove it later
Status = RTMPAllocTxRxRingMemory(pAd);
if (Status != NDIS_STATUS_SUCCESS)
{
DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
goto err1;
}
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
// initialize MLME
//
Status = MlmeInit(pAd);
if (Status != NDIS_STATUS_SUCCESS)
{
DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
goto err2;
}
// Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
//
UserCfgInit(pAd);
#ifdef RT2870
// We need init timerQ related structure before create the timer thread.
RT2870_TimerQ_Init(pAd);
#endif // RT2870 //
RT28XX_TASK_THREAD_INIT(pAd, Status);
if (Status != NDIS_STATUS_SUCCESS)
goto err1;
CfgInitHook(pAd);
NdisAllocateSpinLock(&pAd->MacTabLock);
MeasureReqTabInit(pAd);
TpcReqTabInit(pAd);
//
// Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
//
Status = NICInitializeAdapter(pAd, TRUE);
if (Status != NDIS_STATUS_SUCCESS)
{
DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
if (Status != NDIS_STATUS_SUCCESS)
goto err3;
}
// Read parameters from Config File
Status = RTMPReadParametersHook(pAd);
printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
if (Status != NDIS_STATUS_SUCCESS)
{
DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
goto err4;
}
#ifdef RT2870
pAd->CommonCfg.bMultipleIRP = FALSE;
if (pAd->CommonCfg.bMultipleIRP)
pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE;
else
pAd->CommonCfg.NumOfBulkInIRP = 1;
#endif // RT2870 //
//Init Ba Capability parameters.
pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
// UPdata to HT IE
pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
// We should read EEPROM for all cases. rt2860b
NICReadEEPROMParameters(pAd, mac);
printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
NICInitAsicFromEEPROM(pAd); //rt2860b
// Set PHY to appropriate mode
TmpPhy = pAd->CommonCfg.PhyMode;
pAd->CommonCfg.PhyMode = 0xff;
RTMPSetPhyMode(pAd, TmpPhy);
SetCommonHT(pAd);
// No valid channels.
if (pAd->ChannelListNum == 0)
{
printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
goto err4;
}
printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
#ifdef RT2870
//Init RT30xx RFRegisters after read RFIC type from EEPROM
NICInitRT30xxRFRegisters(pAd);
#endif // RT2870 //
#ifdef IKANOS_VX_1X0
VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
#endif // IKANOS_VX_1X0 //
//
// Initialize RF register to default value
//
AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
AsicLockChannel(pAd, pAd->CommonCfg.Channel);
#ifndef RT30xx
// 8051 firmware require the signal during booting time.
AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
#endif
if (pAd && (Status != NDIS_STATUS_SUCCESS))
{
//
// Undo everything if it failed
//
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
{
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
}
}
else if (pAd)
{
// Microsoft HCT require driver send a disconnect event after driver initialization.
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
#ifdef RT2870
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
//
// Support multiple BulkIn IRP,
// the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.
//
for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++)
{
RTUSBBulkReceive(pAd);
DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" ));
}
#endif // RT2870 //
}// end of else
DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
return TRUE;
err4:
err3:
MlmeHalt(pAd);
err2:
RTMPFreeTxRxRingMemory(pAd);
err1:
os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
RT28XX_IRQ_RELEASE(net_dev);
// shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
//net_dev->ml_priv = 0;
printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
return FALSE;
} /* End of rt28xx_init */
/*
========================================================================
Routine Description:
Open raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
========================================================================
*/
int rt28xx_open(IN PNET_DEV dev)
{
struct net_device * net_dev = (struct net_device *)dev;
PRTMP_ADAPTER pAd = net_dev->ml_priv;
int retval = 0;
POS_COOKIE pObj;
// Sanity check for pAd
if (pAd == NULL)
{
/* if 1st open fail, pAd will be free;
So the net_dev->ml_priv will be NULL in 2rd open */
return -1;
}
// Init
pObj = (POS_COOKIE)pAd->OS_Cookie;
// reset Adapter flags
RTMP_CLEAR_FLAGS(pAd);
// Request interrupt service routine for PCI device
// register the interrupt routine with the os
RT28XX_IRQ_REQUEST(net_dev);
// Init BssTab & ChannelInfo tabbles for auto channel select.
// Chip & other init
if (rt28xx_init(net_dev) == FALSE)
goto err;
NdisZeroMemory(pAd->StaCfg.dev_name, 16);
NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
// Set up the Mac address
NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
// Init IRQ parameters
RT28XX_IRQ_INIT(pAd);
// Various AP function init
// Enable Interrupt
RT28XX_IRQ_ENABLE(pAd);
// Now Enable RxTx
RTMPEnableRxTx(pAd);
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
{
UINT32 reg = 0;
RTMP_IO_READ32(pAd, 0x1300, &reg); // clear garbage interrupts
printk("0x1300 = %08x\n", reg);
}
return (retval);
err:
return (-1);
} /* End of rt28xx_open */
static const struct net_device_ops rt2870_netdev_ops = {
.ndo_open = MainVirtualIF_open,
.ndo_stop = MainVirtualIF_close,
.ndo_do_ioctl = rt28xx_ioctl,
.ndo_get_stats = RT28xx_get_ether_stats,
.ndo_validate_addr = NULL,
.ndo_set_mac_address = eth_mac_addr,
.ndo_change_mtu = eth_change_mtu,
#ifdef IKANOS_VX_1X0
.ndo_start_xmit = IKANOS_DataFramesTx,
#else
.ndo_start_xmit = rt28xx_send_packets,
#endif
};
/* Must not be called for mdev and apdev */
static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
{
NDIS_STATUS Status;
INT i=0;
CHAR slot_name[IFNAMSIZ];
struct net_device *device;
#if WIRELESS_EXT >= 12
if (pAd->OpMode == OPMODE_STA)
{
dev->wireless_handlers = &rt28xx_iw_handler_def;
}
#endif //WIRELESS_EXT >= 12
#if WIRELESS_EXT < 21
dev->get_wireless_stats = rt28xx_get_wireless_stats;
#endif
dev->priv_flags = INT_MAIN;
dev->netdev_ops = &rt2870_netdev_ops;
// find available device name
for (i = 0; i < 8; i++)
{
sprintf(slot_name, "ra%d", i);
device = dev_get_by_name(dev_net(dev), slot_name);
if (device != NULL)
dev_put(device);
if (device == NULL)
break;
}
if(i == 8)
{
DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
Status = NDIS_STATUS_FAILURE;
}
else
{
sprintf(dev->name, "ra%d", i);
Status = NDIS_STATUS_SUCCESS;
}
return Status;
}
/*
========================================================================
Routine Description:
Probe RT28XX chipset.
Arguments:
_dev_p Point to the PCI or USB device
_dev_id_p Point to the PCI or USB device ID
Return Value:
0 Probe OK
-ENODEV Probe Fail
Note:
========================================================================
*/
INT __devinit rt28xx_probe(
IN void *_dev_p,
IN void *_dev_id_p,
IN UINT argc,
OUT PRTMP_ADAPTER *ppAd)
{
struct net_device *net_dev;
PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
INT status;
PVOID handle;
#ifdef RT2870
struct usb_interface *intf = (struct usb_interface *)_dev_p;
struct usb_device *dev_p = interface_to_usbdev(intf);
dev_p = usb_get_dev(dev_p);
#endif // RT2870 //
DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
if (net_dev == NULL)
{
printk("alloc_netdev failed\n");
goto err_out;
}
netif_stop_queue(net_dev);
/* for supporting Network Manager */
/* Set the sysfs physical device reference for the network logical device
* if set prior to registration will cause a symlink during initialization.
*/
SET_NETDEV_DEV(net_dev, &(dev_p->dev));
// Allocate RTMP_ADAPTER miniport adapter structure
handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
status = RTMPAllocAdapterBlock(handle, &pAd);
if (status != NDIS_STATUS_SUCCESS)
goto err_out_free_netdev;
net_dev->ml_priv = (PVOID)pAd;
pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
RT28XXNetDevInit(_dev_p, net_dev, pAd);
pAd->StaCfg.OriDevType = net_dev->type;
// Post config
if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
goto err_out_unmap;
pAd->OpMode = OPMODE_STA;
// sample move
if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
goto err_out_unmap;
// Register this device
status = register_netdev(net_dev);
if (status)
goto err_out_unmap;
// Set driver data
RT28XX_DRVDATA_SET(_dev_p);
*ppAd = pAd;
return 0; // probe ok
/* --------------------------- ERROR HANDLE --------------------------- */
err_out_unmap:
RTMPFreeAdapter(pAd);
RT28XX_UNMAP();
err_out_free_netdev:
free_netdev(net_dev);
err_out:
RT28XX_PUT_DEVICE(dev_p);
return -ENODEV; /* probe fail */
} /* End of rt28xx_probe */
/*
========================================================================
Routine Description:
The entry point for Linux kernel sent packet to our driver.
Arguments:
sk_buff *skb the pointer refer to a sk_buffer.
Return Value:
0
Note:
This function is the entry point of Tx Path for Os delivery packet to
our driver. You only can put OS-depened & STA/AP common handle procedures
in here.
========================================================================
*/
int rt28xx_packet_xmit(struct sk_buff *skb)
{
struct net_device *net_dev = skb->dev;
PRTMP_ADAPTER pAd = net_dev->ml_priv;
int status = 0;
PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
{
// Drop send request since we are in monitor mode
if (MONITOR_ON(pAd))
{
RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
goto done;
}
}
// EapolStart size is 18
if (skb->len < 14)
{
//printk("bad packet size: %d\n", pkt->len);
hex_dump("bad packet", skb->data, skb->len);
RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
goto done;
}
RTMP_SET_PACKET_5VT(pPacket, 0);
#ifdef CONFIG_5VT_ENHANCE
if (*(int*)(skb->cb) == BRIDGE_TAG) {
RTMP_SET_PACKET_5VT(pPacket, 1);
}
#endif
STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
status = 0;
done:
return status;
}
/*
========================================================================
Routine Description:
Send a packet to WLAN.
Arguments:
skb_p points to our adapter
dev_p which WLAN network interface
Return Value:
0: transmit successfully
otherwise: transmit fail
Note:
========================================================================
*/
INT rt28xx_send_packets(
IN struct sk_buff *skb_p,
IN struct net_device *net_dev)
{
RTMP_ADAPTER *pAd = net_dev->ml_priv;
if (!(net_dev->flags & IFF_UP))
{
RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
return 0;
}
NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
return rt28xx_packet_xmit(skb_p);
} /* End of MBSS_VirtualIF_PacketSend */
void CfgInitHook(PRTMP_ADAPTER pAd)
{
pAd->bBroadComHT = TRUE;
} /* End of CfgInitHook */
#if WIRELESS_EXT >= 12
// This function will be called when query /proc
struct iw_statistics *rt28xx_get_wireless_stats(
IN struct net_device *net_dev)
{
PRTMP_ADAPTER pAd = net_dev->ml_priv;
DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
pAd->iw_stats.status = 0; // Status - device dependent for now
// link quality
pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
if(pAd->iw_stats.qual.qual > 100)
pAd->iw_stats.qual.qual = 100;
if (pAd->OpMode == OPMODE_STA)
pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
pAd->iw_stats.qual.noise += 256 - 143;
pAd->iw_stats.qual.updated = 1; // Flags to know if updated
#ifdef IW_QUAL_DBM
pAd->iw_stats.qual.updated |= IW_QUAL_DBM; // Level + Noise are dBm
#endif // IW_QUAL_DBM //
pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
return &pAd->iw_stats;
} /* End of rt28xx_get_wireless_stats */
#endif // WIRELESS_EXT //
void tbtt_tasklet(unsigned long data)
{
#define MAX_TX_IN_TBTT (16)
}
INT rt28xx_ioctl(
IN struct net_device *net_dev,
IN OUT struct ifreq *rq,
IN INT cmd)
{
VIRTUAL_ADAPTER *pVirtualAd = NULL;
RTMP_ADAPTER *pAd = NULL;
INT ret = 0;
if (net_dev->priv_flags == INT_MAIN)
{
pAd = net_dev->ml_priv;
}
else
{
pVirtualAd = net_dev->ml_priv;
pAd = pVirtualAd->RtmpDev->ml_priv;
}
if (pAd == NULL)
{
/* if 1st open fail, pAd will be free;
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
return ret;
}
/*
========================================================================
Routine Description:
return ethernet statistics counter
Arguments:
net_dev Pointer to net_device
Return Value:
net_device_stats*
Note:
========================================================================
*/
struct net_device_stats *RT28xx_get_ether_stats(
IN struct net_device *net_dev)
{
RTMP_ADAPTER *pAd = NULL;
if (net_dev)
pAd = net_dev->ml_priv;
if (pAd)
{
pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
pAd->stats.rx_dropped = 0;
pAd->stats.tx_dropped = 0;
pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; // multicast packets received
pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; // Collision packets
pAd->stats.rx_length_errors = 0;
pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; // receiver ring buff overflow
pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error
pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; // recv'd frame alignment error
pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; // recv'r fifo overrun
pAd->stats.rx_missed_errors = 0; // receiver missed packet
// detailed tx_errors
pAd->stats.tx_aborted_errors = 0;
pAd->stats.tx_carrier_errors = 0;
pAd->stats.tx_fifo_errors = 0;
pAd->stats.tx_heartbeat_errors = 0;
pAd->stats.tx_window_errors = 0;
// for cslip etc
pAd->stats.rx_compressed = 0;
pAd->stats.tx_compressed = 0;
return &pAd->stats;
}
else
return NULL;
}
#include "../rt2860/rt_main_dev.c"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#include "rt_config.h"
static void HTParametersHook(
IN PRTMP_ADAPTER pAd,
IN CHAR *pValueStr,
IN CHAR *pInput);
#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
BOOLEAN rtstrmactohex(char *s1, char *s2)
{
int i = 0;
char *ptokS = s1, *ptokE = s1;
if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
return FALSE;
while((*ptokS) != '\0')
{
if((ptokE = strchr(ptokS, ':')) != NULL)
*ptokE++ = '\0';
if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
break; // fail
AtoH(ptokS, &s2[i++], 1);
ptokS = ptokE;
if (i == 6)
break; // parsing finished
}
return ( i == 6 ? TRUE : FALSE);
}
// we assume the s1 and s2 both are strings.
BOOLEAN rtstrcasecmp(char *s1, char *s2)
{
char *p1 = s1, *p2 = s2;
if (strlen(s1) != strlen(s2))
return FALSE;
while(*p1 != '\0')
{
if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
return FALSE;
p1++;
p2++;
}
return TRUE;
}
// we assume the s1 (buffer) and s2 (key) both are strings.
char * rtstrstruncasecmp(char * s1, char * s2)
{
INT l1, l2, i;
char temp1, temp2;
l2 = strlen(s2);
if (!l2)
return (char *) s1;
l1 = strlen(s1);
while (l1 >= l2)
{
l1--;
for(i=0; i<l2; i++)
{
temp1 = *(s1+i);
temp2 = *(s2+i);
if (('a' <= temp1) && (temp1 <= 'z'))
temp1 = 'A'+(temp1-'a');
if (('a' <= temp2) && (temp2 <= 'z'))
temp2 = 'A'+(temp2-'a');
if (temp1 != temp2)
break;
}
if (i == l2)
return (char *) s1;
s1++;
}
return NULL; // not found
}
//add by kathy
/**
* strstr - Find the first substring in a %NUL terminated string
* @s1: The string to be searched
* @s2: The string to search for
*/
char * rtstrstr(const char * s1,const char * s2)
{
INT l1, l2;
l2 = strlen(s2);
if (!l2)
return (char *) s1;
l1 = strlen(s1);
while (l1 >= l2)
{
l1--;
if (!memcmp(s1,s2,l2))
return (char *) s1;
s1++;
}
return NULL;
}
/**
* rstrtok - Split a string into tokens
* @s: The string to be searched
* @ct: The characters to search for
* * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
*/
char * __rstrtok;
char * rstrtok(char * s,const char * ct)
{
char *sbegin, *send;
sbegin = s ? s : __rstrtok;
if (!sbegin)
{
return NULL;
}
sbegin += strspn(sbegin,ct);
if (*sbegin == '\0')
{
__rstrtok = NULL;
return( NULL );
}
send = strpbrk( sbegin, ct);
if (send && *send != '\0')
*send++ = '\0';
__rstrtok = send;
return (sbegin);
}
/**
* delimitcnt - return the count of a given delimiter in a given string.
* @s: The string to be searched.
* @ct: The delimiter to search for.
* Notice : We suppose the delimiter is a single-char string(for example : ";").
*/
INT delimitcnt(char * s,const char * ct)
{
INT count = 0;
/* point to the beginning of the line */
const char *token = s;
for ( ;; )
{
token = strpbrk(token, ct); /* search for delimiters */
if ( token == NULL )
{
/* advanced to the terminating null character */
break;
}
/* skip the delimiter */
++token;
/*
* Print the found text: use len with %.*s to specify field width.
*/
/* accumulate delimiter count */
++count;
}
return count;
}
/*
* converts the Internet host address from the standard numbers-and-dots notation
* into binary data.
* returns nonzero if the address is valid, zero if not.
*/
int rtinet_aton(const char *cp, unsigned int *addr)
{
unsigned int val;
int base, n;
char c;
unsigned int parts[4];
unsigned int *pp = parts;
for (;;)
{
/*
* Collect number up to ``.''.
* Values are specified as for C:
* 0x=hex, 0=octal, other=decimal.
*/
val = 0;
base = 10;
if (*cp == '0')
{
if (*++cp == 'x' || *cp == 'X')
base = 16, cp++;
else
base = 8;
}
while ((c = *cp) != '\0')
{
if (isdigit((unsigned char) c))
{
val = (val * base) + (c - '0');
cp++;
continue;
}
if (base == 16 && isxdigit((unsigned char) c))
{
val = (val << 4) +
(c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
cp++;
continue;
}
break;
}
if (*cp == '.')
{
/*
* Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
* a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3 || val > 0xff)
return 0;
*pp++ = val, cp++;
}
else
break;
}
/*
* Check for trailing junk.
*/
while (*cp)
if (!isspace((unsigned char) *cp++))
return 0;
/*
* Concoct the address according to the number of parts specified.
*/
n = pp - parts + 1;
switch (n)
{
case 1: /* a -- 32 bits */
break;
case 2: /* a.b -- 8.24 bits */
if (val > 0xffffff)
return 0;
val |= parts[0] << 24;
break;
case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff)
return 0;
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff)
return 0;
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
*addr = htonl(val);
return 1;
}
/*
========================================================================
Routine Description:
Find key section for Get key parameter.
Arguments:
buffer Pointer to the buffer to start find the key section
section the key of the secion to be find
Return Value:
NULL Fail
Others Success
========================================================================
*/
PUCHAR RTMPFindSection(
IN PCHAR buffer)
{
CHAR temp_buf[32];
PUCHAR ptr;
strcpy(temp_buf, "Default");
if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
return (ptr+strlen("\n"));
else
return NULL;
}
/*
========================================================================
Routine Description:
Get key parameter.
Arguments:
key Pointer to key string
dest Pointer to destination
destsize The datasize of the destination
buffer Pointer to the buffer to start find the key
Return Value:
TRUE Success
FALSE Fail
Note:
This routine get the value with the matched key (case case-sensitive)
========================================================================
*/
INT RTMPGetKeyParameter(
IN PCHAR key,
OUT PCHAR dest,
IN INT destsize,
IN PCHAR buffer)
{
UCHAR *temp_buf1 = NULL;
UCHAR *temp_buf2 = NULL;
CHAR *start_ptr;
CHAR *end_ptr;
CHAR *ptr;
CHAR *offset = 0;
INT len;
//temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
if(temp_buf1 == NULL)
return (FALSE);
//temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
if(temp_buf2 == NULL)
{
os_free_mem(NULL, temp_buf1);
return (FALSE);
}
//find section
if((offset = RTMPFindSection(buffer)) == NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
strcpy(temp_buf1, "\n");
strcat(temp_buf1, key);
strcat(temp_buf1, "=");
//search key
if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
start_ptr+=strlen("\n");
if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
end_ptr=start_ptr+strlen(start_ptr);
if (end_ptr<start_ptr)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
temp_buf2[end_ptr-start_ptr]='\0';
len = strlen(temp_buf2);
strcpy(temp_buf1, temp_buf2);
if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
strcpy(temp_buf2, start_ptr+1);
ptr = temp_buf2;
//trim space or tab
while(*ptr != 0x00)
{
if( (*ptr == ' ') || (*ptr == '\t') )
ptr++;
else
break;
}
len = strlen(ptr);
memset(dest, 0x00, destsize);
strncpy(dest, ptr, len >= destsize ? destsize: len);
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return TRUE;
}
/*
========================================================================
Routine Description:
Get key parameter.
Arguments:
key Pointer to key string
dest Pointer to destination
destsize The datasize of the destination
buffer Pointer to the buffer to start find the key
Return Value:
TRUE Success
FALSE Fail
Note:
This routine get the value with the matched key (case case-sensitive).
It is called for parsing SSID and any key string.
========================================================================
*/
INT RTMPGetCriticalParameter(
IN PCHAR key,
OUT PCHAR dest,
IN INT destsize,
IN PCHAR buffer)
{
UCHAR *temp_buf1 = NULL;
UCHAR *temp_buf2 = NULL;
CHAR *start_ptr;
CHAR *end_ptr;
CHAR *ptr;
CHAR *offset = 0;
INT len;
//temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
if(temp_buf1 == NULL)
return (FALSE);
//temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
if(temp_buf2 == NULL)
{
os_free_mem(NULL, temp_buf1);
return (FALSE);
}
//find section
if((offset = RTMPFindSection(buffer)) == NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
strcpy(temp_buf1, "\n");
strcat(temp_buf1, key);
strcat(temp_buf1, "=");
//search key
if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
start_ptr+=strlen("\n");
if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
end_ptr=start_ptr+strlen(start_ptr);
if (end_ptr<start_ptr)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
temp_buf2[end_ptr-start_ptr]='\0';
len = strlen(temp_buf2);
strcpy(temp_buf1, temp_buf2);
if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
strcpy(temp_buf2, start_ptr+1);
ptr = temp_buf2;
//trim tab
/* We cannot trim space(' ') for SSID and key string. */
while(*ptr != 0x00)
{
//if( (*ptr == ' ') || (*ptr == '\t') )
if( (*ptr == '\t') )
ptr++;
else
break;
}
len = strlen(ptr);
memset(dest, 0x00, destsize);
strncpy(dest, ptr, len >= destsize ? destsize: len);
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return TRUE;
}
/*
========================================================================
Routine Description:
Get multiple key parameter.
Arguments:
key Pointer to key string
dest Pointer to destination
destsize The datasize of the destination
buffer Pointer to the buffer to start find the key
Return Value:
TRUE Success
FALSE Fail
Note:
This routine get the value with the matched key (case case-sensitive)
========================================================================
*/
INT RTMPGetKeyParameterWithOffset(
IN PCHAR key,
OUT PCHAR dest,
OUT USHORT *end_offset,
IN INT destsize,
IN PCHAR buffer,
IN BOOLEAN bTrimSpace)
{
UCHAR *temp_buf1 = NULL;
UCHAR *temp_buf2 = NULL;
CHAR *start_ptr;
CHAR *end_ptr;
CHAR *ptr;
CHAR *offset = 0;
INT len;
if (*end_offset >= MAX_INI_BUFFER_SIZE)
return (FALSE);
os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
if(temp_buf1 == NULL)
return (FALSE);
os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
if(temp_buf2 == NULL)
{
os_free_mem(NULL, temp_buf1);
return (FALSE);
}
//find section
if(*end_offset == 0)
{
if ((offset = RTMPFindSection(buffer)) == NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
}
else
offset = buffer + (*end_offset);
strcpy(temp_buf1, "\n");
strcat(temp_buf1, key);
strcat(temp_buf1, "=");
//search key
if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
start_ptr+=strlen("\n");
if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
end_ptr=start_ptr+strlen(start_ptr);
if (end_ptr<start_ptr)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
*end_offset = end_ptr - buffer;
NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
temp_buf2[end_ptr-start_ptr]='\0';
len = strlen(temp_buf2);
strcpy(temp_buf1, temp_buf2);
if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
{
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return (FALSE);
}
strcpy(temp_buf2, start_ptr+1);
ptr = temp_buf2;
//trim space or tab
while(*ptr != 0x00)
{
if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
ptr++;
else
break;
}
len = strlen(ptr);
memset(dest, 0x00, destsize);
strncpy(dest, ptr, len >= destsize ? destsize: len);
os_free_mem(NULL, temp_buf1);
os_free_mem(NULL, temp_buf2);
return TRUE;
}
static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN char *buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
{
PUCHAR keybuff;
INT i = BSSIdx, idx = KeyIdx;
ULONG KeyLen;
UCHAR CipherAlg = CIPHER_WEP64;
keybuff = buffer;
KeyLen = strlen(keybuff);
if (KeyType == 1)
{//Ascii
if( (KeyLen == 5) || (KeyLen == 13))
{
pAd->SharedKey[i][idx].KeyLen = KeyLen;
NdisMoveMemory(pAd->SharedKey[i][idx].Key, keybuff, KeyLen);
if (KeyLen == 5)
CipherAlg = CIPHER_WEP64;
else
CipherAlg = CIPHER_WEP128;
pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
return 1;
}
else
{//Invalid key length
DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length! KeyLen = %ld!\n", idx+1, KeyLen));
return 0;
}
}
else
{//Hex type
if( (KeyLen == 10) || (KeyLen == 26))
{
pAd->SharedKey[i][idx].KeyLen = KeyLen / 2;
AtoH(keybuff, pAd->SharedKey[i][idx].Key, KeyLen / 2);
if (KeyLen == 10)
CipherAlg = CIPHER_WEP64;
else
CipherAlg = CIPHER_WEP128;
pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
return 1;
}
else
{//Invalid key length
DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) Key%dStr is Invalid key length! KeyLen = %ld!\n", i, idx+1, KeyLen));
return 0;
}
}
}
static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
{
char tok_str[16];
PUCHAR macptr;
INT i = 0, idx;
ULONG KeyType[MAX_MBSSID_NUM];
ULONG KeyIdx;
NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
//DefaultKeyID
if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
{
{
KeyIdx = simple_strtol(tmpbuf, 0, 10);
if((KeyIdx >= 1 ) && (KeyIdx <= 4))
pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
else
pAd->StaCfg.DefaultKeyId = 0;
DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
}
}
for (idx = 0; idx < 4; idx++)
{
sprintf(tok_str, "Key%dType", idx + 1);
//Key1Type
if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
{
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
KeyType[i] = simple_strtol(macptr, 0, 10);
}
{
sprintf(tok_str, "Key%dStr", idx + 1);
if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
{
rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
}
}
}
}
}
static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
{
PUCHAR macptr;
INT i=0;
BOOLEAN bWmmEnable = FALSE;
//WmmCapable
if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
{
pAd->CommonCfg.bWmmCapable = TRUE;
bWmmEnable = TRUE;
}
else //Disable
{
pAd->CommonCfg.bWmmCapable = FALSE;
}
DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
}
//AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
{
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
}
}
if (bWmmEnable)
{
//APSDCapable
if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
pAd->CommonCfg.bAPSDCapable = TRUE;
else
pAd->CommonCfg.bAPSDCapable = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
}
//APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
{
BOOLEAN apsd_ac[4];
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
}
pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
}
}
}
NDIS_STATUS RTMPReadParametersHook(
IN PRTMP_ADAPTER pAd)
{
PUCHAR src = NULL;
struct file *srcf;
INT retval, orgfsuid, orgfsgid;
mm_segment_t orgfs;
CHAR *buffer;
CHAR *tmpbuf;
ULONG RtsThresh;
ULONG FragThresh;
UCHAR keyMaterial[40];
PUCHAR macptr;
INT i = 0;
buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
if(buffer == NULL)
return NDIS_STATUS_FAILURE;
tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
if(tmpbuf == NULL)
{
kfree(buffer);
return NDIS_STATUS_FAILURE;
}
src = STA_PROFILE_PATH;
// Save uid and gid used for filesystem access.
// Set user and group to 0 (root)
#ifndef RT30xx
orgfsuid = current_fsuid();
orgfsgid = current_fsgid();
/* Hm, can't really do this nicely anymore, so rely on these files
* being set to the proper permission to read them... */
/* current->cred->fsuid = current->cred->fsgid = 0; */
#endif
orgfs = get_fs();
set_fs(KERNEL_DS);
if (src && *src)
{
srcf = filp_open(src, O_RDONLY, 0);
if (IS_ERR(srcf))
{
DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
}
else
{
// The object must have a read method
if (srcf->f_op && srcf->f_op->read)
{
memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
if (retval < 0)
{
DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
}
else
{
// set file parameter to portcfg
//CountryRegion
if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
{
pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
}
//CountryRegionABand
if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
{
pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
}
//CountryCode
if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
{
NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
if (strlen(pAd->CommonCfg.CountryCode) != 0)
{
pAd->CommonCfg.bCountryFlag = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
}
//ChannelGeography
if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
{
UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
if (Geography <= BOTH)
{
pAd->CommonCfg.Geography = Geography;
pAd->CommonCfg.CountryCode[2] =
(pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
}
}
else
{
pAd->CommonCfg.Geography = BOTH;
pAd->CommonCfg.CountryCode[2] = ' ';
}
{
//SSID
if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
{
if (strlen(tmpbuf) <= 32)
{
pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
}
}
}
{
//NetworkType
if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
{
pAd->bConfigChanged = TRUE;
if (strcmp(tmpbuf, "Adhoc") == 0)
pAd->StaCfg.BssType = BSS_ADHOC;
else //Default Infrastructure mode
pAd->StaCfg.BssType = BSS_INFRA;
// Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
pAd->StaCfg.WpaState = SS_NOTUSE;
DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
}
}
//Channel
if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
{
pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
}
//WirelessMode
if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
{
int value = 0, maxPhyMode = PHY_11G;
maxPhyMode = PHY_11N_5G;
value = simple_strtol(tmpbuf, 0, 10);
if (value <= maxPhyMode)
{
pAd->CommonCfg.PhyMode = value;
}
DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
}
//BasicRate
if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
{
pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
}
//BeaconPeriod
if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
{
pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
}
//TxPower
if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
{
pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
}
//BGProtection
if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
{
switch (simple_strtol(tmpbuf, 0, 10))
{
case 1: //Always On
pAd->CommonCfg.UseBGProtection = 1;
break;
case 2: //Always OFF
pAd->CommonCfg.UseBGProtection = 2;
break;
case 0: //AUTO
default:
pAd->CommonCfg.UseBGProtection = 0;
break;
}
DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
}
//OLBCDetection
if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
{
switch (simple_strtol(tmpbuf, 0, 10))
{
case 1: //disable OLBC Detection
pAd->CommonCfg.DisableOLBCDetect = 1;
break;
case 0: //enable OLBC Detection
pAd->CommonCfg.DisableOLBCDetect = 0;
break;
default:
pAd->CommonCfg.DisableOLBCDetect= 0;
break;
}
DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
}
//TxPreamble
if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
{
switch (simple_strtol(tmpbuf, 0, 10))
{
case Rt802_11PreambleShort:
pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
break;
case Rt802_11PreambleLong:
default:
pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
break;
}
DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
}
//RTSThreshold
if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
{
RtsThresh = simple_strtol(tmpbuf, 0, 10);
if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
else
pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
}
//FragThreshold
if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
{
FragThresh = simple_strtol(tmpbuf, 0, 10);
pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
{ //illegal FragThresh so we set it to default
pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
}
else if (FragThresh % 2 == 1)
{
// The length of each fragment shall always be an even number of octets, except for the last fragment
// of an MSDU or MMPDU, which may be either an even or an odd number of octets.
pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
}
else
{
pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
}
//pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
}
//TxBurst
if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
pAd->CommonCfg.bEnableTxBurst = TRUE;
else //Disable
pAd->CommonCfg.bEnableTxBurst = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
}
#ifdef AGGREGATION_SUPPORT
//PktAggregate
if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
pAd->CommonCfg.bAggregationCapable = TRUE;
else //Disable
pAd->CommonCfg.bAggregationCapable = FALSE;
#ifdef PIGGYBACK_SUPPORT
pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
#endif // PIGGYBACK_SUPPORT //
DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
}
#else
pAd->CommonCfg.bAggregationCapable = FALSE;
pAd->CommonCfg.bPiggyBackCapable = FALSE;
#endif // AGGREGATION_SUPPORT //
// WmmCapable
rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
//ShortSlot
if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
pAd->CommonCfg.bUseShortSlotTime = TRUE;
else //Disable
pAd->CommonCfg.bUseShortSlotTime = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
}
//IEEE80211H
if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
{
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
if(simple_strtol(macptr, 0, 10) != 0) //Enable
pAd->CommonCfg.bIEEE80211H = TRUE;
else //Disable
pAd->CommonCfg.bIEEE80211H = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
}
}
//CSPeriod
if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) != 0)
pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
else
pAd->CommonCfg.RadarDetect.CSPeriod = 0;
DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
}
//RDRegion
if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
{
if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
{
pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
}
else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
{
pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
}
else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
{
pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
}
else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
{
pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
}
else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
{
pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
}
else
{
pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
}
DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
}
else
{
pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
}
//WirelessEvent
if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
{
#if WIRELESS_EXT >= 15
if(simple_strtol(tmpbuf, 0, 10) != 0)
pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
else
pAd->CommonCfg.bWirelessEvent = 0; // disable
#else
pAd->CommonCfg.bWirelessEvent = 0; // disable
#endif
DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
}
if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) != 0)
pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
else
pAd->CommonCfg.bWiFiTest = 0; // disable
DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
}
//AuthMode
if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
{
{
if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
else
pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
}
}
//EncrypType
if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
{
{
if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
else
pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
// Update all wepstatus related
pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
pAd->StaCfg.bMixCipher = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
}
}
{
if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
{
int err=0;
tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
(pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
(pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
)
{
err = 1;
}
else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
{
PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
}
else if (strlen(tmpbuf) == 64)
{
AtoH(tmpbuf, keyMaterial, 32);
NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
}
else
{
err = 1;
DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
}
if (err == 0)
{
if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
{
// Start STA supplicant state machine
pAd->StaCfg.WpaState = SS_START;
}
else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
{
pAd->StaCfg.WpaState = SS_NOTUSE;
}
DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
}
}
}
//DefaultKeyID, KeyType, KeyStr
rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
HTParametersHook(pAd, tmpbuf, buffer);
{
//PSMode
if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
{
if (pAd->StaCfg.BssType == BSS_INFRA)
{
if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
{
// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
// to exclude certain situations.
// MlmeSetPsm(pAd, PWR_SAVE);
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
pAd->StaCfg.DefaultListenCount = 5;
}
else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
|| (strcmp(tmpbuf, "FAST_PSP") == 0))
{
// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
// to exclude certain situations.
// MlmeSetPsmBit(pAd, PWR_SAVE);
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
pAd->StaCfg.DefaultListenCount = 3;
}
else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
|| (strcmp(tmpbuf, "LEGACY_PSP") == 0))
{
// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
// to exclude certain situations.
// MlmeSetPsmBit(pAd, PWR_SAVE);
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
pAd->StaCfg.DefaultListenCount = 3;
}
else
{ //Default Ndis802_11PowerModeCAM
// clear PSM bit immediately
MlmeSetPsmBit(pAd, PWR_ACTIVE);
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
}
DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
}
}
// FastRoaming
if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
{
if (simple_strtol(tmpbuf, 0, 10) == 0)
pAd->StaCfg.bFastRoaming = FALSE;
else
pAd->StaCfg.bFastRoaming = TRUE;
DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
}
// RoamThreshold
if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
{
long lInfo = simple_strtol(tmpbuf, 0, 10);
if (lInfo > 90 || lInfo < 60)
pAd->StaCfg.dBmToRoam = -70;
else
pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
}
if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
{
if(simple_strtol(tmpbuf, 0, 10) == 0)
pAd->StaCfg.bTGnWifiTest = FALSE;
else
pAd->StaCfg.bTGnWifiTest = TRUE;
DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
}
}
#ifdef RT30xx
{
if(RTMPGetKeyParameter("AntDiversity", tmpbuf, 10, buffer))
{
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
if(simple_strtol(macptr, 0, 10) != 0) //Enable
pAd->CommonCfg.bRxAntDiversity = TRUE;
else //Disable
pAd->CommonCfg.bRxAntDiversity = FALSE;
DBGPRINT(RT_DEBUG_ERROR, ("AntDiversity=%d\n", pAd->CommonCfg.bRxAntDiversity));
}
}
}
#endif // RT30xx //
}
}
else
{
DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
}
retval=filp_close(srcf,NULL);
if (retval)
{
DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
}
}
}
set_fs(orgfs);
kfree(buffer);
kfree(tmpbuf);
return (NDIS_STATUS_SUCCESS);
}
static void HTParametersHook(
IN PRTMP_ADAPTER pAd,
IN CHAR *pValueStr,
IN CHAR *pInput)
{
INT Value;
if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bHTProtect = FALSE;
}
else
{
pAd->CommonCfg.bHTProtect = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
}
if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bMIMOPSEnable = FALSE;
}
else
{
pAd->CommonCfg.bMIMOPSEnable = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
}
if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value > MMPS_ENABLE)
{
pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
}
else
{
//TODO: add mimo power saving mechanism
pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
//pAd->CommonCfg.BACapability.field.MMPSmode = Value;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", Value));
}
if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bBADecline = FALSE;
}
else
{
pAd->CommonCfg.bBADecline = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
}
if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bDisableReordering = FALSE;
}
else
{
pAd->CommonCfg.bDisableReordering = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
}
if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
#ifdef RT30xx
pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
#endif
}
else
{
pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
#ifdef RT30xx
pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
#endif
}
pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
#ifdef RT30xx
pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
#endif
DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
}
// Tx_+HTC frame
if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->HTCEnable = FALSE;
}
else
{
pAd->HTCEnable = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
}
// Enable HT Link Adaptation Control
if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->bLinkAdapt = FALSE;
}
else
{
pAd->HTCEnable = TRUE;
pAd->bLinkAdapt = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
}
// Reverse Direction Mechanism
if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bRdg = FALSE;
}
else
{
pAd->HTCEnable = TRUE;
pAd->CommonCfg.bRdg = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
}
// Tx A-MSUD ?
if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
}
else
{
pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
}
// MPDU Density
if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value <=7 && Value >= 0)
{
pAd->CommonCfg.BACapability.field.MpduDensity = Value;
DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
}
else
{
pAd->CommonCfg.BACapability.field.MpduDensity = 4;
DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
}
}
// Max Rx BA Window Size
if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value >=1 && Value <= 64)
{
pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
}
else
{
pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
}
}
// Guard Interval
if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == GI_400)
{
pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
}
// HT Operation Mode : Mixed Mode , Green Field
if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == HTMODE_GF)
{
pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
}
// Fixed Tx mode : CCK, OFDM
if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
{
UCHAR fix_tx_mode;
{
fix_tx_mode = FIXED_TXMODE_HT;
if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
{
fix_tx_mode = FIXED_TXMODE_OFDM;
}
else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
{
fix_tx_mode = FIXED_TXMODE_CCK;
}
else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
{
fix_tx_mode = FIXED_TXMODE_HT;
}
else
{
Value = simple_strtol(pValueStr, 0, 10);
// 1 : CCK
// 2 : OFDM
// otherwise : HT
if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
fix_tx_mode = Value;
else
fix_tx_mode = FIXED_TXMODE_HT;
}
pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
}
}
// Channel Width
if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == BW_40)
{
pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
}
#ifdef MCAST_RATE_SPECIFIC
pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
#endif // MCAST_RATE_SPECIFIC //
DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
}
if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
}
// MSC
if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
{
{
Value = simple_strtol(pValueStr, 0, 10);
if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
{
pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
pAd->StaCfg.bAutoTxRateSwitch = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
}
else
{
pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
pAd->StaCfg.bAutoTxRateSwitch = TRUE;
DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
}
}
}
// STBC
if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == STBC_USE)
{
pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
}
// 40_Mhz_Intolerant
if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
}
else
{
pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
}
//HT_TxStream
if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
{
switch (simple_strtol(pValueStr, 0, 10))
{
case 1:
pAd->CommonCfg.TxStream = 1;
break;
case 2:
pAd->CommonCfg.TxStream = 2;
break;
case 3: // 3*3
default:
pAd->CommonCfg.TxStream = 3;
if (pAd->MACVersion < RALINK_2883_VERSION)
pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
break;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
}
//HT_RxStream
if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
{
switch (simple_strtol(pValueStr, 0, 10))
{
case 1:
pAd->CommonCfg.RxStream = 1;
break;
case 2:
pAd->CommonCfg.RxStream = 2;
break;
case 3:
default:
pAd->CommonCfg.RxStream = 3;
if (pAd->MACVersion < RALINK_2883_VERSION)
pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
break;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
}
}
#include "../rt2860/rt_profile.c"
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_ckipmic.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
*/
#ifndef __RTMP_CKIPMIC_H__
#define __RTMP_CKIPMIC_H__
typedef struct _MIC_CONTEXT {
/* --- MMH context */
UCHAR CK[16]; /* the key */
UCHAR coefficient[16]; /* current aes counter mode coefficients */
ULONGLONG accum; /* accumulated mic, reduced to u32 in final() */
UINT position; /* current position (byte offset) in message */
UCHAR part[4]; /* for conversion of message to u32 for mmh */
} MIC_CONTEXT, *PMIC_CONTEXT;
VOID CKIP_key_permute(
OUT UCHAR *PK, /* output permuted key */
IN UCHAR *CK, /* input CKIP key */
IN UCHAR toDsFromDs, /* input toDs/FromDs bits */
IN UCHAR *piv); /* input pointer to IV */
VOID RTMPCkipMicInit(
IN PMIC_CONTEXT pContext,
IN PUCHAR CK);
VOID RTMPMicUpdate(
IN PMIC_CONTEXT pContext,
IN PUCHAR pOctets,
IN INT len);
ULONG RTMPMicGetCoefficient(
IN PMIC_CONTEXT pContext);
VOID xor_128(
IN PUCHAR a,
IN PUCHAR b,
OUT PUCHAR out);
UCHAR RTMPCkipSbox(
IN UCHAR a);
VOID xor_32(
IN PUCHAR a,
IN PUCHAR b,
OUT PUCHAR out);
VOID next_key(
IN PUCHAR key,
IN INT round);
VOID byte_sub(
IN PUCHAR in,
OUT PUCHAR out);
VOID shift_row(
IN PUCHAR in,
OUT PUCHAR out);
VOID mix_column(
IN PUCHAR in,
OUT PUCHAR out);
VOID RTMPAesEncrypt(
IN PUCHAR key,
IN PUCHAR data,
IN PUCHAR ciphertext);
VOID RTMPMicFinal(
IN PMIC_CONTEXT pContext,
OUT UCHAR digest[4]);
VOID RTMPCkipInsertCMIC(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pMIC,
IN PUCHAR p80211hdr,
IN PNDIS_PACKET pPacket,
IN PCIPHER_KEY pKey,
IN PUCHAR mic_snap);
#endif //__RTMP_CKIPMIC_H__
#include "../rt2860/rtmp_ckipmic.h"
/*
*************************************************************************
* 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_def.h
Abstract:
Miniport related definition header
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Paul Lin 08-01-2002 created
John Chang 08-05-2003 add definition for 11g & other drafts
*/
#ifndef __RTMP_DEF_H__
#define __RTMP_DEF_H__
#include "oid.h"
//
// Debug information verbosity: lower values indicate higher urgency
//
#define RT_DEBUG_OFF 0
#define RT_DEBUG_ERROR 1
#define RT_DEBUG_WARN 2
#define RT_DEBUG_TRACE 3
#define RT_DEBUG_INFO 4
#define RT_DEBUG_LOUD 5
#define NIC_TAG ((ULONG)'0682')
#define NIC_DBG_STRING ("**RT28xx**")
#define RALINK_2883_VERSION ((UINT32)0x28830300)
#define RALINK_2880E_VERSION ((UINT32)0x28720200)
#define RALINK_3070_VERSION ((UINT32)0x30700200)
//
// NDIS version in use by the NIC driver.
// The high byte is the major version. The low byte is the minor version.
//
#ifdef NDIS51_MINIPORT
#define NIC_DRIVER_VERSION 0x0501
#else
#define NIC_DRIVER_VERSION 0x0500
#endif
//
// NDIS media type, current is ethernet, change if native wireless supported
//
#define NIC_MEDIA_TYPE NdisMedium802_3
#define NIC_PCI_HDR_LENGTH 0xe2
#define NIC_MAX_PACKET_SIZE 2304
#define NIC_HEADER_SIZE 14
#define MAX_MAP_REGISTERS_NEEDED 32
#define MIN_MAP_REGISTERS_NEEDED 2 //Todo: should consider fragment issue.
//
// interface type, we use PCI
//
#define NIC_INTERFACE_TYPE NdisInterfacePci
#define NIC_INTERRUPT_MODE NdisInterruptLevelSensitive
//
// buffer size passed in NdisMQueryAdapterResources
// We should only need three adapter resources (IO, interrupt and memory),
// Some devices get extra resources, so have room for 10 resources
// UF_SIZE (sizeof(NDIS_RESOURCE_LIST) + (10*sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)))
#define NIC_RESOURCE_B//
// IO space length
//
#define NIC_MAP_IOSPACE_LENGTH sizeof(CSR_STRUC)
#define MAX_RX_PKT_LEN 1520
//
// Entry number for each DMA descriptor ring
//
#ifdef RT2870
#define TX_RING_SIZE 8 // 1
#define PRIO_RING_SIZE 8
#define MGMT_RING_SIZE 32 // PRIO_RING_SIZE
#define RX_RING_SIZE 8
#define MAX_TX_PROCESS 4
#define LOCAL_TXBUF_SIZE 2048
#endif // RT2870 //
#define MAX_RX_PROCESS 128 //64 //32
#define NUM_OF_LOCAL_TXBUF 2
#define TXD_SIZE 16
#define TXWI_SIZE 16
#define RXD_SIZE 16
#define RXWI_SIZE 16
// TXINFO_SIZE + TXWI_SIZE + 802.11 Header Size + AMSDU sub frame header
#define TX_DMA_1ST_BUFFER_SIZE 96 // only the 1st physical buffer is pre-allocated
#define MGMT_DMA_BUFFER_SIZE 1536 //2048
#define RX_BUFFER_AGGRESIZE 3840 //3904 //3968 //4096 //2048 //4096
#define RX_BUFFER_NORMSIZE 3840 //3904 //3968 //4096 //2048 //4096
#define TX_BUFFER_NORMSIZE RX_BUFFER_NORMSIZE
#define MAX_FRAME_SIZE 2346 // Maximum 802.11 frame size
#define MAX_AGGREGATION_SIZE 3840 //3904 //3968 //4096
#define MAX_NUM_OF_TUPLE_CACHE 2
#define MAX_MCAST_LIST_SIZE 32
#define MAX_LEN_OF_VENDOR_DESC 64
//#define MAX_SIZE_OF_MCAST_PSQ (NUM_OF_LOCAL_TXBUF >> 2) // AP won't spend more than 1/4 of total buffers on M/BCAST PSQ
#define MAX_SIZE_OF_MCAST_PSQ 32
#define MAX_RX_PROCESS_CNT (RX_RING_SIZE)
#define MAX_PACKETS_IN_QUEUE (512) //(512) // to pass WMM A5-WPAPSK
#define MAX_PACKETS_IN_MCAST_PS_QUEUE 32
#define MAX_PACKETS_IN_PS_QUEUE 128 //32
#define WMM_NUM_OF_AC 4 /* AC0, AC1, AC2, and AC3 */
#ifdef RT30xx
//2008/09/11:KH add to support efuse<--
#define MAX_EEPROM_BIN_FILE_SIZE 1024
//2008/09/11:KH add to support efuse-->
#endif
// RxFilter
#define STANORMAL 0x17f97
#define APNORMAL 0x15f97
//
// RTMP_ADAPTER flags
//
#define fRTMP_ADAPTER_MAP_REGISTER 0x00000001
#define fRTMP_ADAPTER_INTERRUPT_IN_USE 0x00000002
#define fRTMP_ADAPTER_HARDWARE_ERROR 0x00000004
#define fRTMP_ADAPTER_SCATTER_GATHER 0x00000008
#define fRTMP_ADAPTER_SEND_PACKET_ERROR 0x00000010
#define fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS 0x00000020
#define fRTMP_ADAPTER_HALT_IN_PROGRESS 0x00000040
#define fRTMP_ADAPTER_RESET_IN_PROGRESS 0x00000080
#define fRTMP_ADAPTER_NIC_NOT_EXIST 0x00000100
#define fRTMP_ADAPTER_TX_RING_ALLOCATED 0x00000200
#define fRTMP_ADAPTER_REMOVE_IN_PROGRESS 0x00000400
#define fRTMP_ADAPTER_MIMORATE_INUSED 0x00000800
#define fRTMP_ADAPTER_RX_RING_ALLOCATED 0x00001000
#define fRTMP_ADAPTER_INTERRUPT_ACTIVE 0x00002000
#define fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS 0x00004000
#define fRTMP_ADAPTER_REASSOC_IN_PROGRESS 0x00008000
#define fRTMP_ADAPTER_MEDIA_STATE_PENDING 0x00010000
#define fRTMP_ADAPTER_RADIO_OFF 0x00020000
#define fRTMP_ADAPTER_BULKOUT_RESET 0x00040000
#define fRTMP_ADAPTER_BULKIN_RESET 0x00080000
#define fRTMP_ADAPTER_RDG_ACTIVE 0x00100000
#define fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE 0x00200000
#define fRTMP_ADAPTER_SCAN_2040 0x04000000
#define fRTMP_ADAPTER_RADIO_MEASUREMENT 0x08000000
#define fRTMP_ADAPTER_START_UP 0x10000000 //Devive already initialized and enabled Tx/Rx.
#define fRTMP_ADAPTER_MEDIA_STATE_CHANGE 0x20000000
#define fRTMP_ADAPTER_IDLE_RADIO_OFF 0x40000000
//
// STA operation status flags
//
#define fOP_STATUS_INFRA_ON 0x00000001
#define fOP_STATUS_ADHOC_ON 0x00000002
#define fOP_STATUS_BG_PROTECTION_INUSED 0x00000004
#define fOP_STATUS_SHORT_SLOT_INUSED 0x00000008
#define fOP_STATUS_SHORT_PREAMBLE_INUSED 0x00000010
#define fOP_STATUS_RECEIVE_DTIM 0x00000020
#define fOP_STATUS_MEDIA_STATE_CONNECTED 0x00000080
#define fOP_STATUS_WMM_INUSED 0x00000100
#define fOP_STATUS_AGGREGATION_INUSED 0x00000200
#define fOP_STATUS_DOZE 0x00000400 // debug purpose
#define fOP_STATUS_PIGGYBACK_INUSED 0x00000800 // piggy-back, and aggregation
#define fOP_STATUS_APSD_INUSED 0x00001000
#define fOP_STATUS_TX_AMSDU_INUSED 0x00002000
#define fOP_STATUS_MAX_RETRY_ENABLED 0x00004000
#define fOP_STATUS_WAKEUP_NOW 0x00008000
#define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE 0x00020000
#define CCKSETPROTECT 0x1
#define OFDMSETPROTECT 0x2
#define MM20SETPROTECT 0x4
#define MM40SETPROTECT 0x8
#define GF20SETPROTECT 0x10
#define GR40SETPROTECT 0x20
#define ALLN_SETPROTECT (GR40SETPROTECT | GF20SETPROTECT | MM40SETPROTECT | MM20SETPROTECT)
//
// AP's client table operation status flags
//
#define fCLIENT_STATUS_WMM_CAPABLE 0x00000001 // CLIENT can parse QOS DATA frame
#define fCLIENT_STATUS_AGGREGATION_CAPABLE 0x00000002 // CLIENT can receive Ralink's proprietary TX aggregation frame
#define fCLIENT_STATUS_PIGGYBACK_CAPABLE 0x00000004 // CLIENT support piggy-back
#define fCLIENT_STATUS_AMSDU_INUSED 0x00000008
#define fCLIENT_STATUS_SGI20_CAPABLE 0x00000010
#define fCLIENT_STATUS_SGI40_CAPABLE 0x00000020
#define fCLIENT_STATUS_TxSTBC_CAPABLE 0x00000040
#define fCLIENT_STATUS_RxSTBC_CAPABLE 0x00000080
#define fCLIENT_STATUS_HTC_CAPABLE 0x00000100
#define fCLIENT_STATUS_RDG_CAPABLE 0x00000200
#define fCLIENT_STATUS_MCSFEEDBACK_CAPABLE 0x00000400
#define fCLIENT_STATUS_APSD_CAPABLE 0x00000800 /* UAPSD STATION */
#define fCLIENT_STATUS_RALINK_CHIPSET 0x00100000
//
// STA configuration flags
//
// 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case
#define HT_NO_PROTECT 0
#define HT_LEGACY_PROTECT 1
#define HT_40_PROTECT 2
#define HT_2040_PROTECT 3
#define HT_RTSCTS_6M 7
//following is our own definition in order to turn on our ASIC protection register in INFRASTRUCTURE.
#define HT_ATHEROS 8 // rt2860c has problem with atheros chip. we need to turn on RTS/CTS .
#define HT_FORCERTSCTS 9 // Force turn on RTS/CTS first. then go to evaluate if this force RTS is necessary.
//
// RX Packet Filter control flags. Apply on pAd->PacketFilter
//
#define fRX_FILTER_ACCEPT_DIRECT NDIS_PACKET_TYPE_DIRECTED
#define fRX_FILTER_ACCEPT_MULTICAST NDIS_PACKET_TYPE_MULTICAST
#define fRX_FILTER_ACCEPT_BROADCAST NDIS_PACKET_TYPE_BROADCAST
#define fRX_FILTER_ACCEPT_ALL_MULTICAST NDIS_PACKET_TYPE_ALL_MULTICAST
//
// Error code section
//
// NDIS_ERROR_CODE_ADAPTER_NOT_FOUND
#define ERRLOG_READ_PCI_SLOT_FAILED 0x00000101L
#define ERRLOG_WRITE_PCI_SLOT_FAILED 0x00000102L
#define ERRLOG_VENDOR_DEVICE_NOMATCH 0x00000103L
// NDIS_ERROR_CODE_ADAPTER_DISABLED
#define ERRLOG_BUS_MASTER_DISABLED 0x00000201L
// NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION
#define ERRLOG_INVALID_SPEED_DUPLEX 0x00000301L
#define ERRLOG_SET_SECONDARY_FAILED 0x00000302L
// NDIS_ERROR_CODE_OUT_OF_RESOURCES
#define ERRLOG_OUT_OF_MEMORY 0x00000401L
#define ERRLOG_OUT_OF_SHARED_MEMORY 0x00000402L
#define ERRLOG_OUT_OF_MAP_REGISTERS 0x00000403L
#define ERRLOG_OUT_OF_BUFFER_POOL 0x00000404L
#define ERRLOG_OUT_OF_NDIS_BUFFER 0x00000405L
#define ERRLOG_OUT_OF_PACKET_POOL 0x00000406L
#define ERRLOG_OUT_OF_NDIS_PACKET 0x00000407L
#define ERRLOG_OUT_OF_LOOKASIDE_MEMORY 0x00000408L
// NDIS_ERROR_CODE_HARDWARE_FAILURE
#define ERRLOG_SELFTEST_FAILED 0x00000501L
#define ERRLOG_INITIALIZE_ADAPTER 0x00000502L
#define ERRLOG_REMOVE_MINIPORT 0x00000503L
// NDIS_ERROR_CODE_RESOURCE_CONFLICT
#define ERRLOG_MAP_IO_SPACE 0x00000601L
#define ERRLOG_QUERY_ADAPTER_RESOURCES 0x00000602L
#define ERRLOG_NO_IO_RESOURCE 0x00000603L
#define ERRLOG_NO_INTERRUPT_RESOURCE 0x00000604L
#define ERRLOG_NO_MEMORY_RESOURCE 0x00000605L
// WDS definition
#define MAX_WDS_ENTRY 4
#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
#define WDS_DISABLE_MODE 0
#define WDS_RESTRICT_MODE 1
#define WDS_BRIDGE_MODE 2
#define WDS_REPEATER_MODE 3
#define WDS_LAZY_MODE 4
#define MAX_MESH_NUM 0
#define MAX_APCLI_NUM 0
#define MAX_MBSSID_NUM 1
#ifdef RT30xx
#ifdef MBSS_SUPPORT
#undef MAX_MBSSID_NUM
#define MAX_MBSSID_NUM (8 - MAX_MESH_NUM - MAX_APCLI_NUM)
#endif // MBSS_SUPPORT //
#endif
/* sanity check for apidx */
#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
{ if (apidx > MAX_MBSSID_NUM) { \
printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx); \
apidx = MAIN_MBSSID; } }
#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
#define MAIN_MBSSID 0
#define FIRST_MBSSID 1
#define MAX_BEACON_SIZE 512
// If the MAX_MBSSID_NUM is larger than 6,
// it shall reserve some WCID space(wcid 222~253) for beacon frames.
// - these wcid 238~253 are reserved for beacon#6(ra6).
// - these wcid 222~237 are reserved for beacon#7(ra7).
#if defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 8)
#define HW_RESERVED_WCID 222
#elif defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 7)
#define HW_RESERVED_WCID 238
#else
#define HW_RESERVED_WCID 255
#endif
// Then dedicate wcid of DFS and Carrier-Sense.
#define DFS_CTS_WCID (HW_RESERVED_WCID - 1)
#define CS_CTS_WCID (HW_RESERVED_WCID - 2)
#define LAST_SPECIFIC_WCID (HW_RESERVED_WCID - 2)
// If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211.
// If MAX_MBSSID_NUM is 7, the maximum available wcid for the associated STA is 228.
#define MAX_AVAILABLE_CLIENT_WCID (LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1)
// TX need WCID to find Cipher Key
// these wcid 212 ~ 219 are reserved for bc/mc packets if MAX_MBSSID_NUM is 8.
#define GET_GroupKey_WCID(__wcid, __bssidx) \
{ \
__wcid = LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM) + __bssidx; \
}
#define IsGroupKeyWCID(__wcid) (((__wcid) < LAST_SPECIFIC_WCID) && ((__wcid) >= (LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM))))
// definition to support multiple BSSID
#define BSS0 0
#define BSS1 1
#define BSS2 2
#define BSS3 3
#define BSS4 4
#define BSS5 5
#define BSS6 6
#define BSS7 7
//============================================================
// Length definitions
#define PEER_KEY_NO 2
#define MAC_ADDR_LEN 6
#define TIMESTAMP_LEN 8
#define MAX_LEN_OF_SUPPORTED_RATES MAX_LENGTH_OF_SUPPORT_RATES // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
#define MAX_LEN_OF_KEY 32 // 32 octets == 256 bits, Redefine for WPA
#define MAX_NUM_OF_CHANNELS MAX_NUM_OF_CHS // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
#define MAX_NUM_OF_11JCHANNELS 20 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
#define MAX_LEN_OF_SSID 32
#define CIPHER_TEXT_LEN 128
#define HASH_TABLE_SIZE 256
#define MAX_VIE_LEN 1024 // New for WPA cipher suite variable IE sizes.
#define MAX_SUPPORT_MCS 32
//============================================================
// ASIC WCID Table definition.
//============================================================
#define BSSID_WCID 1 // in infra mode, always put bssid with this WCID
#define MCAST_WCID 0x0
#define BSS0Mcast_WCID 0x0
#define BSS1Mcast_WCID 0xf8
#define BSS2Mcast_WCID 0xf9
#define BSS3Mcast_WCID 0xfa
#define BSS4Mcast_WCID 0xfb
#define BSS5Mcast_WCID 0xfc
#define BSS6Mcast_WCID 0xfd
#define BSS7Mcast_WCID 0xfe
#define RESERVED_WCID 0xff
#define MAX_NUM_OF_ACL_LIST MAX_NUMBER_OF_ACL
#define MAX_LEN_OF_MAC_TABLE MAX_NUMBER_OF_MAC // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
#if MAX_LEN_OF_MAC_TABLE>MAX_AVAILABLE_CLIENT_WCID
#error MAX_LEN_OF_MAC_TABLE can not be larger than MAX_AVAILABLE_CLIENT_WCID!!!!
#endif
#define MAX_NUM_OF_WDS_LINK_PERBSSID 3
#define MAX_NUM_OF_WDS_LINK (MAX_NUM_OF_WDS_LINK_PERBSSID*MAX_MBSSID_NUM)
#define MAX_NUM_OF_EVENT MAX_NUMBER_OF_EVENT
#define WDS_LINK_START_WCID (MAX_LEN_OF_MAC_TABLE-1)
#define NUM_OF_TID 8
#define MAX_AID_BA 4
#define MAX_LEN_OF_BA_REC_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) //Block ACK recipient
#define MAX_LEN_OF_BA_ORI_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) // Block ACK originator
#define MAX_LEN_OF_BSS_TABLE 64
#define MAX_REORDERING_MPDU_NUM 512
// key related definitions
#define SHARE_KEY_NUM 4
#define MAX_LEN_OF_SHARE_KEY 16 // byte count
#define MAX_LEN_OF_PEER_KEY 16 // byte count
#define PAIRWISE_KEY_NUM 64 // in MAC ASIC pairwise key table
#define GROUP_KEY_NUM 4
#define PMK_LEN 32
#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
#define PMKID_NO 4 // Number of PMKID saved supported
#define MAX_LEN_OF_MLME_BUFFER 2048
// power status related definitions
#define PWR_ACTIVE 0
#define PWR_SAVE 1
#define PWR_MMPS 2 //MIMO power save
// Auth and Assoc mode related definitions
#define AUTH_MODE_OPEN 0x00
#define AUTH_MODE_KEY 0x01
// BSS Type definitions
#define BSS_ADHOC 0 // = Ndis802_11IBSS
#define BSS_INFRA 1 // = Ndis802_11Infrastructure
#define BSS_ANY 2 // = Ndis802_11AutoUnknown
#define BSS_MONITOR 3 // = Ndis802_11Monitor
// Reason code definitions
#define REASON_RESERVED 0
#define REASON_UNSPECIFY 1
#define REASON_NO_LONGER_VALID 2
#define REASON_DEAUTH_STA_LEAVING 3
#define REASON_DISASSOC_INACTIVE 4
#define REASON_DISASSPC_AP_UNABLE 5
#define REASON_CLS2ERR 6
#define REASON_CLS3ERR 7
#define REASON_DISASSOC_STA_LEAVING 8
#define REASON_STA_REQ_ASSOC_NOT_AUTH 9
#define REASON_INVALID_IE 13
#define REASON_MIC_FAILURE 14
#define REASON_4_WAY_TIMEOUT 15
#define REASON_GROUP_KEY_HS_TIMEOUT 16
#define REASON_IE_DIFFERENT 17
#define REASON_MCIPHER_NOT_VALID 18
#define REASON_UCIPHER_NOT_VALID 19
#define REASON_AKMP_NOT_VALID 20
#define REASON_UNSUPPORT_RSNE_VER 21
#define REASON_INVALID_RSNE_CAP 22
#define REASON_8021X_AUTH_FAIL 23
#define REASON_CIPHER_SUITE_REJECTED 24
#define REASON_DECLINED 37
#define REASON_QOS_UNSPECIFY 32
#define REASON_QOS_LACK_BANDWIDTH 33
#define REASON_POOR_CHANNEL_CONDITION 34
#define REASON_QOS_OUTSIDE_TXOP_LIMITION 35
#define REASON_QOS_QSTA_LEAVING_QBSS 36
#define REASON_QOS_UNWANTED_MECHANISM 37
#define REASON_QOS_MECH_SETUP_REQUIRED 38
#define REASON_QOS_REQUEST_TIMEOUT 39
#define REASON_QOS_CIPHER_NOT_SUPPORT 45
// Status code definitions
#define MLME_SUCCESS 0
#define MLME_UNSPECIFY_FAIL 1
#define MLME_CANNOT_SUPPORT_CAP 10
#define MLME_REASSOC_DENY_ASSOC_EXIST 11
#define MLME_ASSOC_DENY_OUT_SCOPE 12
#define MLME_ALG_NOT_SUPPORT 13
#define MLME_SEQ_NR_OUT_OF_SEQUENCE 14
#define MLME_REJ_CHALLENGE_FAILURE 15
#define MLME_REJ_TIMEOUT 16
#define MLME_ASSOC_REJ_UNABLE_HANDLE_STA 17
#define MLME_ASSOC_REJ_DATA_RATE 18
#define MLME_ASSOC_REJ_NO_EXT_RATE 22
#define MLME_ASSOC_REJ_NO_EXT_RATE_PBCC 23
#define MLME_ASSOC_REJ_NO_CCK_OFDM 24
#define MLME_QOS_UNSPECIFY 32
#define MLME_REQUEST_DECLINED 37
#define MLME_REQUEST_WITH_INVALID_PARAM 38
#define MLME_DLS_NOT_ALLOW_IN_QBSS 48
#define MLME_DEST_STA_NOT_IN_QBSS 49
#define MLME_DEST_STA_IS_NOT_A_QSTA 50
#define MLME_INVALID_FORMAT 0x51
#define MLME_FAIL_NO_RESOURCE 0x52
#define MLME_STATE_MACHINE_REJECT 0x53
#define MLME_MAC_TABLE_FAIL 0x54
// IE code
#define IE_SSID 0
#define IE_SUPP_RATES 1
#define IE_FH_PARM 2
#define IE_DS_PARM 3
#define IE_CF_PARM 4
#define IE_TIM 5
#define IE_IBSS_PARM 6
#define IE_COUNTRY 7 // 802.11d
#define IE_802_11D_REQUEST 10 // 802.11d
#define IE_QBSS_LOAD 11 // 802.11e d9
#define IE_EDCA_PARAMETER 12 // 802.11e d9
#define IE_TSPEC 13 // 802.11e d9
#define IE_TCLAS 14 // 802.11e d9
#define IE_SCHEDULE 15 // 802.11e d9
#define IE_CHALLENGE_TEXT 16
#define IE_POWER_CONSTRAINT 32 // 802.11h d3.3
#define IE_POWER_CAPABILITY 33 // 802.11h d3.3
#define IE_TPC_REQUEST 34 // 802.11h d3.3
#define IE_TPC_REPORT 35 // 802.11h d3.3
#define IE_SUPP_CHANNELS 36 // 802.11h d3.3
#define IE_CHANNEL_SWITCH_ANNOUNCEMENT 37 // 802.11h d3.3
#define IE_MEASUREMENT_REQUEST 38 // 802.11h d3.3
#define IE_MEASUREMENT_REPORT 39 // 802.11h d3.3
#define IE_QUIET 40 // 802.11h d3.3
#define IE_IBSS_DFS 41 // 802.11h d3.3
#define IE_ERP 42 // 802.11g
#define IE_TS_DELAY 43 // 802.11e d9
#define IE_TCLAS_PROCESSING 44 // 802.11e d9
#define IE_QOS_CAPABILITY 46 // 802.11e d6
#define IE_HT_CAP 45 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
#define IE_AP_CHANNEL_REPORT 51 // 802.11k d6
#define IE_HT_CAP2 52 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
#define IE_RSN 48 // 802.11i d3.0
#define IE_WPA2 48 // WPA2
#define IE_EXT_SUPP_RATES 50 // 802.11g
#define IE_SUPP_REG_CLASS 59 // 802.11y. Supported regulatory classes.
#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT 60 // 802.11n
#define IE_ADD_HT 61 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
#define IE_ADD_HT2 53 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
// For 802.11n D3.03
//#define IE_NEW_EXT_CHA_OFFSET 62 // 802.11n d1. New extension channel offset elemet
#define IE_SECONDARY_CH_OFFSET 62 // 802.11n D3.03 Secondary Channel Offset element
#define IE_WAPI 68 // WAPI information element
#define IE_2040_BSS_COEXIST 72 // 802.11n D3.0.3
#define IE_2040_BSS_INTOLERANT_REPORT 73 // 802.11n D3.03
#define IE_OVERLAPBSS_SCAN_PARM 74 // 802.11n D3.03
#define IE_EXT_CAPABILITY 127 // 802.11n D3.03
#define IE_WPA 221 // WPA
#define IE_VENDOR_SPECIFIC 221 // Wifi WMM (WME)
#define OUI_BROADCOM_HT 51 //
#define OUI_BROADCOM_HTADD 52 //
#define OUI_PREN_HT_CAP 51 //
#define OUI_PREN_ADD_HT 52 //
// CCX information
#define IE_AIRONET_CKIP 133 // CCX1.0 ID 85H for CKIP
#define IE_AP_TX_POWER 150 // CCX 2.0 for AP transmit power
#define IE_MEASUREMENT_CAPABILITY 221 // CCX 2.0
#define IE_CCX_V2 221
#define IE_AIRONET_IPADDRESS 149 // CCX ID 95H for IP Address
#define IE_AIRONET_CCKMREASSOC 156 // CCX ID 9CH for CCKM Reassociation Request element
#define CKIP_NEGOTIATION_LENGTH 30
#define AIRONET_IPADDRESS_LENGTH 10
#define AIRONET_CCKMREASSOC_LENGTH 24
// ========================================================
// MLME state machine definition
// ========================================================
// STA MLME state mahcines
#define ASSOC_STATE_MACHINE 1
#define AUTH_STATE_MACHINE 2
#define AUTH_RSP_STATE_MACHINE 3
#define SYNC_STATE_MACHINE 4
#define MLME_CNTL_STATE_MACHINE 5
#define WPA_PSK_STATE_MACHINE 6
#define LEAP_STATE_MACHINE 7
#define AIRONET_STATE_MACHINE 8
#define ACTION_STATE_MACHINE 9
// AP MLME state machines
#define AP_ASSOC_STATE_MACHINE 11
#define AP_AUTH_STATE_MACHINE 12
#define AP_AUTH_RSP_STATE_MACHINE 13
#define AP_SYNC_STATE_MACHINE 14
#define AP_CNTL_STATE_MACHINE 15
#define AP_WPA_STATE_MACHINE 16
#ifdef RT30xx
#define WSC_STATE_MACHINE 17
#define WSC_UPNP_STATE_MACHINE 18
#endif
//
// STA's CONTROL/CONNECT state machine: states, events, total function #
//
#define CNTL_IDLE 0
#define CNTL_WAIT_DISASSOC 1
#define CNTL_WAIT_JOIN 2
#define CNTL_WAIT_REASSOC 3
#define CNTL_WAIT_START 4
#define CNTL_WAIT_AUTH 5
#define CNTL_WAIT_ASSOC 6
#define CNTL_WAIT_AUTH2 7
#define CNTL_WAIT_OID_LIST_SCAN 8
#define CNTL_WAIT_OID_DISASSOC 9
#ifdef RT2870
#define CNTL_WAIT_SCAN_FOR_CONNECT 10
#endif // RT2870 //
#define MT2_ASSOC_CONF 34
#define MT2_AUTH_CONF 35
#define MT2_DEAUTH_CONF 36
#define MT2_DISASSOC_CONF 37
#define MT2_REASSOC_CONF 38
#define MT2_PWR_MGMT_CONF 39
#define MT2_JOIN_CONF 40
#define MT2_SCAN_CONF 41
#define MT2_START_CONF 42
#define MT2_GET_CONF 43
#define MT2_SET_CONF 44
#define MT2_RESET_CONF 45
#define MT2_MLME_ROAMING_REQ 52
#define CNTL_FUNC_SIZE 1
//
// STA's ASSOC state machine: states, events, total function #
//
#define ASSOC_IDLE 0
#define ASSOC_WAIT_RSP 1
#define REASSOC_WAIT_RSP 2
#define DISASSOC_WAIT_RSP 3
#define MAX_ASSOC_STATE 4
#define ASSOC_MACHINE_BASE 0
#define MT2_MLME_ASSOC_REQ 0
#define MT2_MLME_REASSOC_REQ 1
#define MT2_MLME_DISASSOC_REQ 2
#define MT2_PEER_DISASSOC_REQ 3
#define MT2_PEER_ASSOC_REQ 4
#define MT2_PEER_ASSOC_RSP 5
#define MT2_PEER_REASSOC_REQ 6
#define MT2_PEER_REASSOC_RSP 7
#define MT2_DISASSOC_TIMEOUT 8
#define MT2_ASSOC_TIMEOUT 9
#define MT2_REASSOC_TIMEOUT 10
#define MAX_ASSOC_MSG 11
#define ASSOC_FUNC_SIZE (MAX_ASSOC_STATE * MAX_ASSOC_MSG)
//
// ACT state machine: states, events, total function #
//
#define ACT_IDLE 0
#define MAX_ACT_STATE 1
#define ACT_MACHINE_BASE 0
//Those PEER_xx_CATE number is based on real Categary value in IEEE spec. Please don'es modify it by your self.
//Category
#define MT2_PEER_SPECTRUM_CATE 0
#define MT2_PEER_QOS_CATE 1
#define MT2_PEER_DLS_CATE 2
#define MT2_PEER_BA_CATE 3
#define MT2_PEER_PUBLIC_CATE 4
#define MT2_PEER_RM_CATE 5
#define MT2_PEER_HT_CATE 7 // 7.4.7
#define MAX_PEER_CATE_MSG 7
#define MT2_MLME_ADD_BA_CATE 8
#define MT2_MLME_ORI_DELBA_CATE 9
#define MT2_MLME_REC_DELBA_CATE 10
#define MT2_MLME_QOS_CATE 11
#define MT2_MLME_DLS_CATE 12
#define MT2_ACT_INVALID 13
#define MAX_ACT_MSG 14
//Category field
#define CATEGORY_SPECTRUM 0
#define CATEGORY_QOS 1
#define CATEGORY_DLS 2
#define CATEGORY_BA 3
#define CATEGORY_PUBLIC 4
#define CATEGORY_RM 5
#define CATEGORY_HT 7
// DLS Action frame definition
#define ACTION_DLS_REQUEST 0
#define ACTION_DLS_RESPONSE 1
#define ACTION_DLS_TEARDOWN 2
//Spectrum Action field value 802.11h 7.4.1
#define SPEC_MRQ 0 // Request
#define SPEC_MRP 1 //Report
#define SPEC_TPCRQ 2
#define SPEC_TPCRP 3
#define SPEC_CHANNEL_SWITCH 4
//BA Action field value
#define ADDBA_REQ 0
#define ADDBA_RESP 1
#define DELBA 2
//Public's Action field value in Public Category. Some in 802.11y and some in 11n
#define ACTION_BSS_2040_COEXIST 0 // 11n
#define ACTION_DSE_ENABLEMENT 1 // 11y D9.0
#define ACTION_DSE_DEENABLEMENT 2 // 11y D9.0
#define ACTION_DSE_REG_LOCATION_ANNOUNCE 3 // 11y D9.0
#define ACTION_EXT_CH_SWITCH_ANNOUNCE 4 // 11y D9.0
#define ACTION_DSE_MEASUREMENT_REQ 5 // 11y D9.0
#define ACTION_DSE_MEASUREMENT_REPORT 6 // 11y D9.0
#define ACTION_MEASUREMENT_PILOT_ACTION 7 // 11y D9.0
#define ACTION_DSE_POWER_CONSTRAINT 8 // 11y D9.0
//HT Action field value
#define NOTIFY_BW_ACTION 0
#define SMPS_ACTION 1
#define PSMP_ACTION 2
#define SETPCO_ACTION 3
#define MIMO_CHA_MEASURE_ACTION 4
#define MIMO_N_BEACONFORM 5
#define MIMO_BEACONFORM 6
#define ANTENNA_SELECT 7
#define HT_INFO_EXCHANGE 8
#define ACT_FUNC_SIZE (MAX_ACT_STATE * MAX_ACT_MSG)
//
// STA's AUTHENTICATION state machine: states, evvents, total function #
//
#define AUTH_REQ_IDLE 0
#define AUTH_WAIT_SEQ2 1
#define AUTH_WAIT_SEQ4 2
#define MAX_AUTH_STATE 3
#define AUTH_MACHINE_BASE 0
#define MT2_MLME_AUTH_REQ 0
#define MT2_PEER_AUTH_EVEN 1
#define MT2_AUTH_TIMEOUT 2
#define MAX_AUTH_MSG 3
#define AUTH_FUNC_SIZE (MAX_AUTH_STATE * MAX_AUTH_MSG)
//
// STA's AUTH_RSP state machine: states, events, total function #
//
#define AUTH_RSP_IDLE 0
#define AUTH_RSP_WAIT_CHAL 1
#define MAX_AUTH_RSP_STATE 2
#define AUTH_RSP_MACHINE_BASE 0
#define MT2_AUTH_CHALLENGE_TIMEOUT 0
#define MT2_PEER_AUTH_ODD 1
#define MT2_PEER_DEAUTH 2
#define MAX_AUTH_RSP_MSG 3
#define AUTH_RSP_FUNC_SIZE (MAX_AUTH_RSP_STATE * MAX_AUTH_RSP_MSG)
//
// STA's SYNC state machine: states, events, total function #
//
#define SYNC_IDLE 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
#define JOIN_WAIT_BEACON 1
#define SCAN_LISTEN 2
#define MAX_SYNC_STATE 3
#define SYNC_MACHINE_BASE 0
#define MT2_MLME_SCAN_REQ 0
#define MT2_MLME_JOIN_REQ 1
#define MT2_MLME_START_REQ 2
#define MT2_PEER_BEACON 3
#define MT2_PEER_PROBE_RSP 4
#define MT2_PEER_ATIM 5
#define MT2_SCAN_TIMEOUT 6
#define MT2_BEACON_TIMEOUT 7
#define MT2_ATIM_TIMEOUT 8
#define MT2_PEER_PROBE_REQ 9
#define MAX_SYNC_MSG 10
#define SYNC_FUNC_SIZE (MAX_SYNC_STATE * MAX_SYNC_MSG)
//Messages for the DLS state machine
#define DLS_IDLE 0
#define MAX_DLS_STATE 1
#define DLS_MACHINE_BASE 0
#define MT2_MLME_DLS_REQ 0
#define MT2_PEER_DLS_REQ 1
#define MT2_PEER_DLS_RSP 2
#define MT2_MLME_DLS_TEAR_DOWN 3
#define MT2_PEER_DLS_TEAR_DOWN 4
#define MAX_DLS_MSG 5
#define DLS_FUNC_SIZE (MAX_DLS_STATE * MAX_DLS_MSG)
//
// STA's WPA-PSK State machine: states, events, total function #
//
#define WPA_PSK_IDLE 0
#define MAX_WPA_PSK_STATE 1
#define WPA_MACHINE_BASE 0
#define MT2_EAPPacket 0
#define MT2_EAPOLStart 1
#define MT2_EAPOLLogoff 2
#define MT2_EAPOLKey 3
#define MT2_EAPOLASFAlert 4
#define MAX_WPA_PSK_MSG 5
#define WPA_PSK_FUNC_SIZE (MAX_WPA_PSK_STATE * MAX_WPA_PSK_MSG)
//
// STA's CISCO-AIRONET State machine: states, events, total function #
//
#define AIRONET_IDLE 0
#define AIRONET_SCANNING 1
#define MAX_AIRONET_STATE 2
#define AIRONET_MACHINE_BASE 0
#define MT2_AIRONET_MSG 0
#define MT2_AIRONET_SCAN_REQ 1
#define MT2_AIRONET_SCAN_DONE 2
#define MAX_AIRONET_MSG 3
#define AIRONET_FUNC_SIZE (MAX_AIRONET_STATE * MAX_AIRONET_MSG)
//
// AP's CONTROL/CONNECT state machine: states, events, total function #
//
#define AP_CNTL_FUNC_SIZE 1
//
// AP's ASSOC state machine: states, events, total function #
//
#define AP_ASSOC_IDLE 0
#define AP_MAX_ASSOC_STATE 1
#define AP_ASSOC_MACHINE_BASE 0
#define APMT2_MLME_DISASSOC_REQ 0
#define APMT2_PEER_DISASSOC_REQ 1
#define APMT2_PEER_ASSOC_REQ 2
#define APMT2_PEER_REASSOC_REQ 3
#define APMT2_CLS3ERR 4
#define AP_MAX_ASSOC_MSG 5
#define AP_ASSOC_FUNC_SIZE (AP_MAX_ASSOC_STATE * AP_MAX_ASSOC_MSG)
//
// AP's AUTHENTICATION state machine: states, events, total function #
//
#define AP_AUTH_REQ_IDLE 0
#define AP_MAX_AUTH_STATE 1
#define AP_AUTH_MACHINE_BASE 0
#define APMT2_MLME_DEAUTH_REQ 0
#define APMT2_CLS2ERR 1
#define AP_MAX_AUTH_MSG 2
#define AP_AUTH_FUNC_SIZE (AP_MAX_AUTH_STATE * AP_MAX_AUTH_MSG)
//
// AP's AUTH-RSP state machine: states, events, total function #
//
#define AP_AUTH_RSP_IDLE 0
#define AP_MAX_AUTH_RSP_STATE 1
#define AP_AUTH_RSP_MACHINE_BASE 0
#define APMT2_AUTH_CHALLENGE_TIMEOUT 0
#define APMT2_PEER_AUTH_ODD 1
#define APMT2_PEER_DEAUTH 2
#define AP_MAX_AUTH_RSP_MSG 3
#define AP_AUTH_RSP_FUNC_SIZE (AP_MAX_AUTH_RSP_STATE * AP_MAX_AUTH_RSP_MSG)
//
// AP's SYNC state machine: states, events, total function #
//
#define AP_SYNC_IDLE 0
#define AP_SCAN_LISTEN 1
#define AP_MAX_SYNC_STATE 2
#define AP_SYNC_MACHINE_BASE 0
#define APMT2_PEER_PROBE_REQ 0
#define APMT2_PEER_BEACON 1
#define APMT2_MLME_SCAN_REQ 2
#define APMT2_PEER_PROBE_RSP 3
#define APMT2_SCAN_TIMEOUT 4
#define APMT2_MLME_SCAN_CNCL 5
#define AP_MAX_SYNC_MSG 6
#define AP_SYNC_FUNC_SIZE (AP_MAX_SYNC_STATE * AP_MAX_SYNC_MSG)
//
// AP's WPA state machine: states, events, total function #
//
#define AP_WPA_PTK 0
#define AP_MAX_WPA_PTK_STATE 1
#define AP_WPA_MACHINE_BASE 0
#define APMT2_EAPPacket 0
#define APMT2_EAPOLStart 1
#define APMT2_EAPOLLogoff 2
#define APMT2_EAPOLKey 3
#define APMT2_EAPOLASFAlert 4
#define AP_MAX_WPA_MSG 5
#define AP_WPA_FUNC_SIZE (AP_MAX_WPA_PTK_STATE * AP_MAX_WPA_MSG)
// =============================================================================
// value domain of 802.11 header FC.Tyte, which is b3..b2 of the 1st-byte of MAC header
#define BTYPE_MGMT 0
#define BTYPE_CNTL 1
#define BTYPE_DATA 2
// value domain of 802.11 MGMT frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
#define SUBTYPE_ASSOC_REQ 0
#define SUBTYPE_ASSOC_RSP 1
#define SUBTYPE_REASSOC_REQ 2
#define SUBTYPE_REASSOC_RSP 3
#define SUBTYPE_PROBE_REQ 4
#define SUBTYPE_PROBE_RSP 5
#define SUBTYPE_BEACON 8
#define SUBTYPE_ATIM 9
#define SUBTYPE_DISASSOC 10
#define SUBTYPE_AUTH 11
#define SUBTYPE_DEAUTH 12
#define SUBTYPE_ACTION 13
#define SUBTYPE_ACTION_NO_ACK 14
// value domain of 802.11 CNTL frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
#define SUBTYPE_WRAPPER 7
#define SUBTYPE_BLOCK_ACK_REQ 8
#define SUBTYPE_BLOCK_ACK 9
#define SUBTYPE_PS_POLL 10
#define SUBTYPE_RTS 11
#define SUBTYPE_CTS 12
#define SUBTYPE_ACK 13
#define SUBTYPE_CFEND 14
#define SUBTYPE_CFEND_CFACK 15
// value domain of 802.11 DATA frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
#define SUBTYPE_DATA 0
#define SUBTYPE_DATA_CFACK 1
#define SUBTYPE_DATA_CFPOLL 2
#define SUBTYPE_DATA_CFACK_CFPOLL 3
#define SUBTYPE_NULL_FUNC 4
#define SUBTYPE_CFACK 5
#define SUBTYPE_CFPOLL 6
#define SUBTYPE_CFACK_CFPOLL 7
#define SUBTYPE_QDATA 8
#define SUBTYPE_QDATA_CFACK 9
#define SUBTYPE_QDATA_CFPOLL 10
#define SUBTYPE_QDATA_CFACK_CFPOLL 11
#define SUBTYPE_QOS_NULL 12
#define SUBTYPE_QOS_CFACK 13
#define SUBTYPE_QOS_CFPOLL 14
#define SUBTYPE_QOS_CFACK_CFPOLL 15
// ACK policy of QOS Control field bit 6:5
#define NORMAL_ACK 0x00 // b6:5 = 00
#define NO_ACK 0x20 // b6:5 = 01
#define NO_EXPLICIT_ACK 0x40 // b6:5 = 10
#define BLOCK_ACK 0x60 // b6:5 = 11
//
// rtmp_data.c use these definition
//
#define LENGTH_802_11 24
#define LENGTH_802_11_AND_H 30
#define LENGTH_802_11_CRC_H 34
#define LENGTH_802_11_CRC 28
#define LENGTH_802_11_WITH_ADDR4 30
#define LENGTH_802_3 14
#define LENGTH_802_3_TYPE 2
#define LENGTH_802_1_H 8
#define LENGTH_EAPOL_H 4
#define LENGTH_WMMQOS_H 2
#define LENGTH_CRC 4
#define MAX_SEQ_NUMBER 0x0fff
#define LENGTH_802_3_NO_TYPE 12
#define LENGTH_802_1Q 4 /* VLAN related */
// STA_CSR4.field.TxResult
#define TX_RESULT_SUCCESS 0
#define TX_RESULT_ZERO_LENGTH 1
#define TX_RESULT_UNDER_RUN 2
#define TX_RESULT_OHY_ERROR 4
#define TX_RESULT_RETRY_FAIL 6
// All PHY rate summary in TXD
// Preamble MODE in TxD
#define MODE_CCK 0
#define MODE_OFDM 1
#define MODE_HTMIX 2
#define MODE_HTGREENFIELD 3
// MCS for CCK. BW.SGI.STBC are reserved
#define MCS_LONGP_RATE_1 0 // long preamble CCK 1Mbps
#define MCS_LONGP_RATE_2 1 // long preamble CCK 1Mbps
#define MCS_LONGP_RATE_5_5 2
#define MCS_LONGP_RATE_11 3
#define MCS_SHORTP_RATE_1 4 // long preamble CCK 1Mbps. short is forbidden in 1Mbps
#define MCS_SHORTP_RATE_2 5 // short preamble CCK 2Mbps
#define MCS_SHORTP_RATE_5_5 6
#define MCS_SHORTP_RATE_11 7
// To send duplicate legacy OFDM. set BW=BW_40. SGI.STBC are reserved
#define MCS_RATE_6 0 // legacy OFDM
#define MCS_RATE_9 1 // OFDM
#define MCS_RATE_12 2 // OFDM
#define MCS_RATE_18 3 // OFDM
#define MCS_RATE_24 4 // OFDM
#define MCS_RATE_36 5 // OFDM
#define MCS_RATE_48 6 // OFDM
#define MCS_RATE_54 7 // OFDM
// HT
#define MCS_0 0 // 1S
#define MCS_1 1
#define MCS_2 2
#define MCS_3 3
#define MCS_4 4
#define MCS_5 5
#define MCS_6 6
#define MCS_7 7
#define MCS_8 8 // 2S
#define MCS_9 9
#define MCS_10 10
#define MCS_11 11
#define MCS_12 12
#define MCS_13 13
#define MCS_14 14
#define MCS_15 15
#define MCS_16 16 // 3*3
#define MCS_17 17
#define MCS_18 18
#define MCS_19 19
#define MCS_20 20
#define MCS_21 21
#define MCS_22 22
#define MCS_23 23
#define MCS_32 32
#define MCS_AUTO 33
// OID_HTPHYMODE
// MODE
#define HTMODE_MM 0
#define HTMODE_GF 1
// Fixed Tx MODE - HT, CCK or OFDM
#define FIXED_TXMODE_HT 0
#define FIXED_TXMODE_CCK 1
#define FIXED_TXMODE_OFDM 2
// BW
#define BW_20 BAND_WIDTH_20
#define BW_40 BAND_WIDTH_40
#define BW_BOTH BAND_WIDTH_BOTH
#define BW_10 BAND_WIDTH_10 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
// SHORTGI
#define GI_400 GAP_INTERVAL_400 // only support in HT mode
#define GI_BOTH GAP_INTERVAL_BOTH
#define GI_800 GAP_INTERVAL_800
// STBC
#define STBC_NONE 0
#define STBC_USE 1 // limited use in rt2860b phy
#define RXSTBC_ONE 1 // rx support of one spatial stream
#define RXSTBC_TWO 2 // rx support of 1 and 2 spatial stream
#define RXSTBC_THR 3 // rx support of 1~3 spatial stream
// MCS FEEDBACK
#define MCSFBK_NONE 0 // not support mcs feedback /
#define MCSFBK_RSV 1 // reserved
#define MCSFBK_UNSOLICIT 2 // only support unsolict mcs feedback
#define MCSFBK_MRQ 3 // response to both MRQ and unsolict mcs feedback
// MIMO power safe
#define MMPS_STATIC 0
#define MMPS_DYNAMIC 1
#define MMPS_RSV 2
#define MMPS_ENABLE 3
// A-MSDU size
#define AMSDU_0 0
#define AMSDU_1 1
// MCS use 7 bits
#define TXRATEMIMO 0x80
#define TXRATEMCS 0x7F
#define TXRATEOFDM 0x7F
#define RATE_1 0
#define RATE_2 1
#define RATE_5_5 2
#define RATE_11 3
#define RATE_6 4 // OFDM
#define RATE_9 5 // OFDM
#define RATE_12 6 // OFDM
#define RATE_18 7 // OFDM
#define RATE_24 8 // OFDM
#define RATE_36 9 // OFDM
#define RATE_48 10 // OFDM
#define RATE_54 11 // OFDM
#define RATE_FIRST_OFDM_RATE RATE_6
#define RATE_LAST_OFDM_RATE RATE_54
#define RATE_6_5 12 // HT mix
#define RATE_13 13 // HT mix
#define RATE_19_5 14 // HT mix
#define RATE_26 15 // HT mix
#define RATE_39 16 // HT mix
#define RATE_52 17 // HT mix
#define RATE_58_5 18 // HT mix
#define RATE_65 19 // HT mix
#define RATE_78 20 // HT mix
#define RATE_104 21 // HT mix
#define RATE_117 22 // HT mix
#define RATE_130 23 // HT mix
//#define RATE_AUTO_SWITCH 255 // for StaCfg.FixedTxRate only
#define HTRATE_0 12
#define RATE_FIRST_MM_RATE HTRATE_0
#define RATE_FIRST_HT_RATE HTRATE_0
#define RATE_LAST_HT_RATE HTRATE_0
// pTxWI->txop
#define IFS_HTTXOP 0 // The txop will be handles by ASIC.
#define IFS_PIFS 1
#define IFS_SIFS 2
#define IFS_BACKOFF 3
// pTxD->RetryMode
#define LONG_RETRY 1
#define SHORT_RETRY 0
// Country Region definition
#define REGION_MINIMUM_BG_BAND 0
#define REGION_0_BG_BAND 0 // 1-11
#define REGION_1_BG_BAND 1 // 1-13
#define REGION_2_BG_BAND 2 // 10-11
#define REGION_3_BG_BAND 3 // 10-13
#define REGION_4_BG_BAND 4 // 14
#define REGION_5_BG_BAND 5 // 1-14
#define REGION_6_BG_BAND 6 // 3-9
#define REGION_7_BG_BAND 7 // 5-13
#define REGION_31_BG_BAND 31 // 5-13
#define REGION_MAXIMUM_BG_BAND 7
#define REGION_MINIMUM_A_BAND 0
#define REGION_0_A_BAND 0 // 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165
#define REGION_1_A_BAND 1 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
#define REGION_2_A_BAND 2 // 36, 40, 44, 48, 52, 56, 60, 64
#define REGION_3_A_BAND 3 // 52, 56, 60, 64, 149, 153, 157, 161
#define REGION_4_A_BAND 4 // 149, 153, 157, 161, 165
#define REGION_5_A_BAND 5 // 149, 153, 157, 161
#define REGION_6_A_BAND 6 // 36, 40, 44, 48
#define REGION_7_A_BAND 7 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
#define REGION_8_A_BAND 8 // 52, 56, 60, 64
#define REGION_9_A_BAND 9 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
#define REGION_10_A_BAND 10 // 36, 40, 44, 48, 149, 153, 157, 161, 165
#define REGION_11_A_BAND 11 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
#define REGION_MAXIMUM_A_BAND 11
// pTxD->CipherAlg
#define CIPHER_NONE 0
#define CIPHER_WEP64 1
#define CIPHER_WEP128 2
#define CIPHER_TKIP 3
#define CIPHER_AES 4
#define CIPHER_CKIP64 5
#define CIPHER_CKIP128 6
#define CIPHER_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
#define CIPHER_SMS4 8
// value domain of pAd->RfIcType
#define RFIC_2820 1 // 2.4G 2T3R
#define RFIC_2850 2 // 2.4G/5G 2T3R
#define RFIC_2720 3 // 2.4G 1T2R
#define RFIC_2750 4 // 2.4G/5G 1T2R
#define RFIC_3020 5 // 2.4G 1T1R
#define RFIC_2020 6 // 2.4G B/G
#ifdef RT30xx
#define RFIC_3021 7 // 2.4G 1T2R
#define RFIC_3022 8 // 2.4G 2T2R
#endif
// LED Status.
#define LED_LINK_DOWN 0
#define LED_LINK_UP 1
#define LED_RADIO_OFF 2
#define LED_RADIO_ON 3
#define LED_HALT 4
#define LED_WPS 5
#define LED_ON_SITE_SURVEY 6
#define LED_POWER_UP 7
// value domain of pAd->LedCntl.LedMode and E2PROM
#define LED_MODE_DEFAULT 0
#define LED_MODE_TWO_LED 1
#define LED_MODE_SIGNAL_STREGTH 8 // EEPROM define =8
// RC4 init value, used fro WEP & TKIP
#define PPPINITFCS32 0xffffffff /* Initial FCS value */
// value domain of pAd->StaCfg.PortSecured. 802.1X controlled port definition
#define WPA_802_1X_PORT_SECURED 1
#define WPA_802_1X_PORT_NOT_SECURED 2
#define PAIRWISE_KEY 1
#define GROUP_KEY 2
//definition of DRS
#define MAX_STEP_OF_TX_RATE_SWITCH 32
// pre-allocated free NDIS PACKET/BUFFER poll for internal usage
#define MAX_NUM_OF_FREE_NDIS_PACKET 128
//Block ACK
#define MAX_TX_REORDERBUF 64
#define MAX_RX_REORDERBUF 64
#define DEFAULT_TX_TIMEOUT 30
#define DEFAULT_RX_TIMEOUT 30
// definition of Recipient or Originator
#define I_RECIPIENT TRUE
#define I_ORIGINATOR FALSE
#define DEFAULT_BBP_TX_POWER 0
#define DEFAULT_RF_TX_POWER 5
#define MAX_INI_BUFFER_SIZE 4096
#define MAX_PARAM_BUFFER_SIZE (2048) // enough for ACL (18*64)
//18 : the length of Mac address acceptable format "01:02:03:04:05:06;")
//64 : MAX_NUM_OF_ACL_LIST
// definition of pAd->OpMode
#define OPMODE_STA 0
#define OPMODE_AP 1
//#define OPMODE_L3_BRG 2 // as AP and STA at the same time
// ========================= AP rtmp_def.h ===========================
// value domain for pAd->EventTab.Log[].Event
#define EVENT_RESET_ACCESS_POINT 0 // Log = "hh:mm:ss Restart Access Point"
#define EVENT_ASSOCIATED 1 // Log = "hh:mm:ss STA 00:01:02:03:04:05 associated"
#define EVENT_DISASSOCIATED 2 // Log = "hh:mm:ss STA 00:01:02:03:04:05 left this BSS"
#define EVENT_AGED_OUT 3 // Log = "hh:mm:ss STA 00:01:02:03:04:05 was aged-out and removed from this BSS"
#define EVENT_COUNTER_M 4
#define EVENT_INVALID_PSK 5
#define EVENT_MAX_EVENT_TYPE 6
// ==== end of AP rtmp_def.h ============
// definition RSSI Number
#define RSSI_0 0
#define RSSI_1 1
#define RSSI_2 2
// definition of radar detection
#define RD_NORMAL_MODE 0 // Not found radar signal
#define RD_SWITCHING_MODE 1 // Found radar signal, and doing channel switch
#define RD_SILENCE_MODE 2 // After channel switch, need to be silence a while to ensure radar not found
//Driver defined cid for mapping status and command.
#define SLEEPCID 0x11
#define WAKECID 0x22
#define QUERYPOWERCID 0x33
#define OWNERMCU 0x1
#define OWNERCPU 0x0
// MBSSID definition
#define ENTRY_NOT_FOUND 0xFF
/* After Linux 2.6.9,
* VLAN module use Private (from user) interface flags (netdevice->priv_flags).
* #define IFF_802_1Q_VLAN 0x1 -- 802.1Q VLAN device. in if.h
* ref to ip_sabotage_out() [ out->priv_flags & IFF_802_1Q_VLAN ] in br_netfilter.c
*
* For this reason, we MUST use EVEN value in priv_flags
*/
#define INT_MAIN 0x0100
#define INT_MBSSID 0x0200
#define INT_WDS 0x0300
#define INT_APCLI 0x0400
#define INT_MESH 0x0500
// Use bitmap to allow coexist of ATE_TXFRAME and ATE_RXFRAME(i.e.,to support LoopBack mode)
// WEP Key TYPE
#define WEP_HEXADECIMAL_TYPE 0
#define WEP_ASCII_TYPE 1
// WIRELESS EVENTS definition
/* Max number of char in custom event, refer to wireless_tools.28/wireless.20.h */
#define IW_CUSTOM_MAX_LEN 255 /* In bytes */
// For system event - start
#define IW_SYS_EVENT_FLAG_START 0x0200
#define IW_ASSOC_EVENT_FLAG 0x0200
#define IW_DISASSOC_EVENT_FLAG 0x0201
#define IW_DEAUTH_EVENT_FLAG 0x0202
#define IW_AGEOUT_EVENT_FLAG 0x0203
#define IW_COUNTER_MEASURES_EVENT_FLAG 0x0204
#define IW_REPLAY_COUNTER_DIFF_EVENT_FLAG 0x0205
#define IW_RSNIE_DIFF_EVENT_FLAG 0x0206
#define IW_MIC_DIFF_EVENT_FLAG 0x0207
#define IW_ICV_ERROR_EVENT_FLAG 0x0208
#define IW_MIC_ERROR_EVENT_FLAG 0x0209
#define IW_GROUP_HS_TIMEOUT_EVENT_FLAG 0x020A
#define IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG 0x020B
#define IW_RSNIE_SANITY_FAIL_EVENT_FLAG 0x020C
#define IW_SET_KEY_DONE_WPA1_EVENT_FLAG 0x020D
#define IW_SET_KEY_DONE_WPA2_EVENT_FLAG 0x020E
#define IW_STA_LINKUP_EVENT_FLAG 0x020F
#define IW_STA_LINKDOWN_EVENT_FLAG 0x0210
#define IW_SCAN_COMPLETED_EVENT_FLAG 0x0211
#define IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG 0x0212
// if add new system event flag, please upadte the IW_SYS_EVENT_FLAG_END
#define IW_SYS_EVENT_FLAG_END 0x0212
#define IW_SYS_EVENT_TYPE_NUM (IW_SYS_EVENT_FLAG_END - IW_SYS_EVENT_FLAG_START + 1)
// For system event - end
// For spoof attack event - start
#define IW_SPOOF_EVENT_FLAG_START 0x0300
#define IW_CONFLICT_SSID_EVENT_FLAG 0x0300
#define IW_SPOOF_ASSOC_RESP_EVENT_FLAG 0x0301
#define IW_SPOOF_REASSOC_RESP_EVENT_FLAG 0x0302
#define IW_SPOOF_PROBE_RESP_EVENT_FLAG 0x0303
#define IW_SPOOF_BEACON_EVENT_FLAG 0x0304
#define IW_SPOOF_DISASSOC_EVENT_FLAG 0x0305
#define IW_SPOOF_AUTH_EVENT_FLAG 0x0306
#define IW_SPOOF_DEAUTH_EVENT_FLAG 0x0307
#define IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG 0x0308
#define IW_REPLAY_ATTACK_EVENT_FLAG 0x0309
// if add new spoof attack event flag, please upadte the IW_SPOOF_EVENT_FLAG_END
#define IW_SPOOF_EVENT_FLAG_END 0x0309
#define IW_SPOOF_EVENT_TYPE_NUM (IW_SPOOF_EVENT_FLAG_END - IW_SPOOF_EVENT_FLAG_START + 1)
// For spoof attack event - end
// For flooding attack event - start
#define IW_FLOOD_EVENT_FLAG_START 0x0400
#define IW_FLOOD_AUTH_EVENT_FLAG 0x0400
#define IW_FLOOD_ASSOC_REQ_EVENT_FLAG 0x0401
#define IW_FLOOD_REASSOC_REQ_EVENT_FLAG 0x0402
#define IW_FLOOD_PROBE_REQ_EVENT_FLAG 0x0403
#define IW_FLOOD_DISASSOC_EVENT_FLAG 0x0404
#define IW_FLOOD_DEAUTH_EVENT_FLAG 0x0405
#define IW_FLOOD_EAP_REQ_EVENT_FLAG 0x0406
// if add new flooding attack event flag, please upadte the IW_FLOOD_EVENT_FLAG_END
#define IW_FLOOD_EVENT_FLAG_END 0x0406
#define IW_FLOOD_EVENT_TYPE_NUM (IW_FLOOD_EVENT_FLAG_END - IW_FLOOD_EVENT_FLAG_START + 1)
// For flooding attack - end
// End - WIRELESS EVENTS definition
// definition for DLS, kathy
#define MAX_NUM_OF_INIT_DLS_ENTRY 1
#define MAX_NUM_OF_DLS_ENTRY MAX_NUMBER_OF_DLS_ENTRY
//Block ACK , rt2860, kathy
#define MAX_TX_REORDERBUF 64
#define MAX_RX_REORDERBUF 64
#define DEFAULT_TX_TIMEOUT 30
#define DEFAULT_RX_TIMEOUT 30
#define MAX_BARECI_SESSION 8
#ifndef IW_ESSID_MAX_SIZE
/* Maximum size of the ESSID and pAd->nickname strings */
#define IW_ESSID_MAX_SIZE 32
#endif
#ifdef MCAST_RATE_SPECIFIC
#define MCAST_DISABLE 0
#define MCAST_CCK 1
#define MCAST_OFDM 2
#define MCAST_HTMIX 3
#endif // MCAST_RATE_SPECIFIC //
// For AsicRadioOff/AsicRadioOn function
#define DOT11POWERSAVE 0
#define GUIRADIO_OFF 1
#define RTMP_HALT 2
#define GUI_IDLE_POWER_SAVE 3
// --
// definition for WpaSupport flag
#define WPA_SUPPLICANT_DISABLE 0
#define WPA_SUPPLICANT_ENABLE 1
#define WPA_SUPPLICANT_ENABLE_WITH_WEB_UI 2
// Endian byte swapping codes
#define SWAP16(x) \
((UINT16)( \
(((UINT16)(x) & (UINT16) 0x00ffU) << 8) | \
(((UINT16)(x) & (UINT16) 0xff00U) >> 8) ))
#define SWAP32(x) \
((UINT32)( \
(((UINT32)(x) & (UINT32) 0x000000ffUL) << 24) | \
(((UINT32)(x) & (UINT32) 0x0000ff00UL) << 8) | \
(((UINT32)(x) & (UINT32) 0x00ff0000UL) >> 8) | \
(((UINT32)(x) & (UINT32) 0xff000000UL) >> 24) ))
#define SWAP64(x) \
((UINT64)( \
(UINT64)(((UINT64)(x) & (UINT64) 0x00000000000000ffULL) << 56) | \
(UINT64)(((UINT64)(x) & (UINT64) 0x000000000000ff00ULL) << 40) | \
(UINT64)(((UINT64)(x) & (UINT64) 0x0000000000ff0000ULL) << 24) | \
(UINT64)(((UINT64)(x) & (UINT64) 0x00000000ff000000ULL) << 8) | \
(UINT64)(((UINT64)(x) & (UINT64) 0x000000ff00000000ULL) >> 8) | \
(UINT64)(((UINT64)(x) & (UINT64) 0x0000ff0000000000ULL) >> 24) | \
(UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
(UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
#define cpu2le64(x) ((UINT64)(x))
#define le2cpu64(x) ((UINT64)(x))
#define cpu2le32(x) ((UINT32)(x))
#define le2cpu32(x) ((UINT32)(x))
#define cpu2le16(x) ((UINT16)(x))
#define le2cpu16(x) ((UINT16)(x))
#define cpu2be64(x) SWAP64((x))
#define be2cpu64(x) SWAP64((x))
#define cpu2be32(x) SWAP32((x))
#define be2cpu32(x) SWAP32((x))
#define cpu2be16(x) SWAP16((x))
#define be2cpu16(x) SWAP16((x))
#endif // __RTMP_DEF_H__
#include "../rt2860/rtmp_def.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rtmp_type.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Paul Lin 1-2-2004
*/
#ifndef __RTMP_TYPE_H__
#define __RTMP_TYPE_H__
#define PACKED __attribute__ ((packed))
// Put platform dependent declaration here
// For example, linux type definition
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned long long UINT64;
typedef int INT32;
typedef long long INT64;
typedef unsigned char * PUINT8;
typedef unsigned short * PUINT16;
typedef unsigned int * PUINT32;
typedef unsigned long long * PUINT64;
typedef int * PINT32;
typedef long long * PINT64;
typedef signed char CHAR;
typedef signed short SHORT;
typedef signed int INT;
typedef signed long LONG;
typedef signed long long LONGLONG;
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned int UINT;
typedef unsigned long ULONG;
typedef unsigned long long ULONGLONG;
typedef unsigned char BOOLEAN;
typedef void VOID;
typedef VOID * PVOID;
typedef CHAR * PCHAR;
typedef UCHAR * PUCHAR;
typedef USHORT * PUSHORT;
typedef LONG * PLONG;
typedef ULONG * PULONG;
typedef UINT * PUINT;
typedef unsigned int NDIS_MEDIA_STATE;
typedef union _LARGE_INTEGER {
struct {
UINT LowPart;
INT32 HighPart;
} u;
INT64 QuadPart;
} LARGE_INTEGER;
#endif // __RTMP_TYPE_H__
#include "../rt2860/rtmp_type.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __SPECTRUM_H__
#define __SPECTRUM_H__
#include "rtmp_type.h"
#include "spectrum_def.h"
typedef struct PACKED _TPC_REPORT_INFO
{
UINT8 TxPwr;
UINT8 LinkMargin;
} TPC_REPORT_INFO, *PTPC_REPORT_INFO;
typedef struct PACKED _CH_SW_ANN_INFO
{
UINT8 ChSwMode;
UINT8 Channel;
UINT8 ChSwCnt;
} CH_SW_ANN_INFO, *PCH_SW_ANN_INFO;
typedef union PACKED _MEASURE_REQ_MODE
{
struct PACKED
{
UINT8 Rev0:1;
UINT8 Enable:1;
UINT8 Request:1;
UINT8 Report:1;
UINT8 Rev1:4;
} field;
UINT8 word;
} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
typedef struct PACKED _MEASURE_REQ
{
UINT8 ChNum;
UINT64 MeasureStartTime;
UINT16 MeasureDuration;
} MEASURE_REQ, *PMEASURE_REQ;
typedef struct PACKED _MEASURE_REQ_INFO
{
UINT8 Token;
MEASURE_REQ_MODE ReqMode;
UINT8 ReqType;
MEASURE_REQ MeasureReq;
} MEASURE_REQ_INFO, *PMEASURE_REQ_INFO;
typedef union PACKED _MEASURE_BASIC_REPORT_MAP
{
struct PACKED
{
UINT8 BSS:1;
UINT8 OfdmPreamble:1;
UINT8 UnidentifiedSignal:1;
UINT8 Radar:1;
UINT8 Unmeasure:1;
UINT8 Rev:3;
} field;
UINT8 word;
} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
typedef struct PACKED _MEASURE_BASIC_REPORT
{
UINT8 ChNum;
UINT64 MeasureStartTime;
UINT16 MeasureDuration;
MEASURE_BASIC_REPORT_MAP Map;
} MEASURE_BASIC_REPORT, *PMEASURE_BASIC_REPORT;
typedef struct PACKED _MEASURE_CCA_REPORT
{
UINT8 ChNum;
UINT64 MeasureStartTime;
UINT16 MeasureDuration;
UINT8 CCA_Busy_Fraction;
} MEASURE_CCA_REPORT, *PMEASURE_CCA_REPORT;
typedef struct PACKED _MEASURE_RPI_REPORT
{
UINT8 ChNum;
UINT64 MeasureStartTime;
UINT16 MeasureDuration;
UINT8 RPI_Density[8];
} MEASURE_RPI_REPORT, *PMEASURE_RPI_REPORT;
typedef union PACKED _MEASURE_REPORT_MODE
{
struct PACKED
{
UINT8 Late:1;
UINT8 Incapable:1;
UINT8 Refused:1;
UINT8 Rev:5;
} field;
UINT8 word;
} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
typedef struct PACKED _MEASURE_REPORT_INFO
{
UINT8 Token;
MEASURE_REPORT_MODE ReportMode;
UINT8 ReportType;
UINT8 Octect[0];
} MEASURE_REPORT_INFO, *PMEASURE_REPORT_INFO;
typedef struct PACKED _QUIET_INFO
{
UINT8 QuietCnt;
UINT8 QuietPeriod;
UINT8 QuietDuration;
UINT8 QuietOffset;
} QUIET_INFO, *PQUIET_INFO;
/*
==========================================================================
Description:
Prepare Measurement request action frame and enqueue it into
management queue waiting for transmition.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
VOID EnqueueMeasurementReq(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pDA,
IN UINT8 MeasureToken,
IN UINT8 MeasureReqMode,
IN UINT8 MeasureReqType,
IN UINT8 MeasureCh,
IN UINT16 MeasureDuration);
/*
==========================================================================
Description:
Prepare Measurement report action frame and enqueue it into
management queue waiting for transmition.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
VOID EnqueueMeasurementRep(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pDA,
IN UINT8 DialogToken,
IN UINT8 MeasureToken,
IN UINT8 MeasureReqMode,
IN UINT8 MeasureReqType,
IN UINT8 ReportInfoLen,
IN PUINT8 pReportInfo);
/*
==========================================================================
Description:
Prepare TPC Request action frame and enqueue it into
management queue waiting for transmition.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
VOID EnqueueTPCReq(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pDA,
IN UCHAR DialogToken);
/*
==========================================================================
Description:
Prepare TPC Report action frame and enqueue it into
management queue waiting for transmition.
Parametrs:
1. the destination mac address of the frame.
Return : None.
==========================================================================
*/
VOID EnqueueTPCRep(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pDA,
IN UINT8 DialogToken,
IN UINT8 TxPwr,
IN UINT8 LinkMargin);
/*
==========================================================================
Description:
Prepare Channel Switch Announcement action frame and enqueue it into
management queue waiting for transmition.
Parametrs:
1. the destination mac address of the frame.
2. Channel switch announcement mode.
2. a New selected channel.
Return : None.
==========================================================================
*/
VOID EnqueueChSwAnn(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pDA,
IN UINT8 ChSwMode,
IN UINT8 NewCh);
/*
==========================================================================
Description:
Spectrun action frames Handler such as channel switch annoucement,
measurement report, measurement request actions frames.
Parametrs:
Elme - MLME message containing the received frame
Return : None.
==========================================================================
*/
VOID PeerSpectrumAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
/*
==========================================================================
Description:
Parametrs:
Return : None.
==========================================================================
*/
INT Set_MeasureReq_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
INT Set_TpcReq_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
VOID MeasureReqTabInit(
IN PRTMP_ADAPTER pAd);
VOID MeasureReqTabExit(
IN PRTMP_ADAPTER pAd);
VOID TpcReqTabInit(
IN PRTMP_ADAPTER pAd);
VOID TpcReqTabExit(
IN PRTMP_ADAPTER pAd);
VOID NotifyChSwAnnToPeerAPs(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pRA,
IN PUCHAR pTA,
IN UINT8 ChSwMode,
IN UINT8 Channel);
#endif // __SPECTRUM_H__ //
#include "../rt2860/spectrum.h"
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
spectrum_def.h
Abstract:
Handle association related requests either from WSTA or from local MLME
Revision History:
Who When What
--------- ---------- ----------------------------------------------
Fonchi Wu 2008 created for 802.11h
*/
#ifndef __SPECTRUM_DEF_H__
#define __SPECTRUM_DEF_H__
#define MAX_MEASURE_REQ_TAB_SIZE 3
#define MAX_HASH_MEASURE_REQ_TAB_SIZE MAX_MEASURE_REQ_TAB_SIZE
#define MAX_TPC_REQ_TAB_SIZE 3
#define MAX_HASH_TPC_REQ_TAB_SIZE MAX_TPC_REQ_TAB_SIZE
#define MIN_RCV_PWR 100 /* Negative value ((dBm) */
#define RM_TPC_REQ 0
#define RM_MEASURE_REQ 1
#define RM_BASIC 0
#define RM_CCA 1
#define RM_RPI_HISTOGRAM 2
#define TPC_REQ_AGE_OUT 500 /* ms */
#define MQ_REQ_AGE_OUT 500 /* ms */
#define TPC_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_HASH_TPC_REQ_TAB_SIZE)
#define MQ_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_MEASURE_REQ_TAB_SIZE)
typedef struct _MEASURE_REQ_ENTRY
{
struct _MEASURE_REQ_ENTRY *pNext;
ULONG lastTime;
BOOLEAN Valid;
UINT8 DialogToken;
UINT8 MeasureDialogToken[3]; // 0:basic measure, 1: CCA measure, 2: RPI_Histogram measure.
} MEASURE_REQ_ENTRY, *PMEASURE_REQ_ENTRY;
typedef struct _MEASURE_REQ_TAB
{
UCHAR Size;
PMEASURE_REQ_ENTRY Hash[MAX_HASH_MEASURE_REQ_TAB_SIZE];
MEASURE_REQ_ENTRY Content[MAX_MEASURE_REQ_TAB_SIZE];
} MEASURE_REQ_TAB, *PMEASURE_REQ_TAB;
typedef struct _TPC_REQ_ENTRY
{
struct _TPC_REQ_ENTRY *pNext;
ULONG lastTime;
BOOLEAN Valid;
UINT8 DialogToken;
} TPC_REQ_ENTRY, *PTPC_REQ_ENTRY;
typedef struct _TPC_REQ_TAB
{
UCHAR Size;
PTPC_REQ_ENTRY Hash[MAX_HASH_TPC_REQ_TAB_SIZE];
TPC_REQ_ENTRY Content[MAX_TPC_REQ_TAB_SIZE];
} TPC_REQ_TAB, *PTPC_REQ_TAB;
#endif // __SPECTRUM_DEF_H__ //
#include "../rt2860/spectrum_def.h"
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
wpa.h
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
*/
#ifndef __WPA_H__
#define __WPA_H__
// EAPOL Key descripter frame format related length
#define LEN_KEY_DESC_NONCE 32
#define LEN_KEY_DESC_IV 16
#define LEN_KEY_DESC_RSC 8
#define LEN_KEY_DESC_ID 8
#define LEN_KEY_DESC_REPLAY 8
#define LEN_KEY_DESC_MIC 16
// The length is the EAPoL-Key frame except key data field.
// Please refer to 802.11i-2004 ,Figure 43u in p.78
#define LEN_EAPOL_KEY_MSG (sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE)
// EAP Code Type.
#define EAP_CODE_REQUEST 1
#define EAP_CODE_RESPONSE 2
#define EAP_CODE_SUCCESS 3
#define EAP_CODE_FAILURE 4
// EAPOL frame Protocol Version
#define EAPOL_VER 1
#define EAPOL_VER2 2
// EAPOL-KEY Descriptor Type
#define WPA1_KEY_DESC 0xfe
#define WPA2_KEY_DESC 0x02
// Key Descriptor Version of Key Information
#define DESC_TYPE_TKIP 1
#define DESC_TYPE_AES 2
#define DESC_TYPE_MESH 3
#define LEN_MSG1_2WAY 0x7f
#define MAX_LEN_OF_EAP_HS 256
#define LEN_MASTER_KEY 32
// EAPOL EK, MK
#define LEN_EAP_EK 16
#define LEN_EAP_MICK 16
#define LEN_EAP_KEY ((LEN_EAP_EK)+(LEN_EAP_MICK))
// TKIP key related
#define LEN_PMKID 16
#define LEN_TKIP_EK 16
#define LEN_TKIP_RXMICK 8
#define LEN_TKIP_TXMICK 8
#define LEN_AES_EK 16
#define LEN_AES_KEY LEN_AES_EK
#define LEN_TKIP_KEY ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
#define TKIP_AP_TXMICK_OFFSET ((LEN_EAP_KEY)+(LEN_TKIP_EK))
#define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
#define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
#define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
#ifndef RT30xx
#define MIN_LEN_OF_GTK 5
#endif
// RSN IE Length definition
#define MAX_LEN_OF_RSNIE 90
#define MIN_LEN_OF_RSNIE 8
//EAP Packet Type
#define EAPPacket 0
#define EAPOLStart 1
#define EAPOLLogoff 2
#define EAPOLKey 3
#define EAPOLASFAlert 4
#define EAPTtypeMax 5
#define EAPOL_MSG_INVALID 0
#define EAPOL_PAIR_MSG_1 1
#define EAPOL_PAIR_MSG_2 2
#define EAPOL_PAIR_MSG_3 3
#define EAPOL_PAIR_MSG_4 4
#define EAPOL_GROUP_MSG_1 5
#define EAPOL_GROUP_MSG_2 6
#define PAIRWISEKEY 1
#define GROUPKEY 0
// Retry timer counter initial value
#define PEER_MSG1_RETRY_TIMER_CTR 0
#define PEER_MSG3_RETRY_TIMER_CTR 10
#define GROUP_MSG1_RETRY_TIMER_CTR 20
#define EAPOL_START_DISABLE 0
#define EAPOL_START_PSK 1
#define EAPOL_START_1X 2
#define MIX_CIPHER_WPA_TKIP_ON(x) (((x) & 0x08) != 0)
#define MIX_CIPHER_WPA_AES_ON(x) (((x) & 0x04) != 0)
#define MIX_CIPHER_WPA2_TKIP_ON(x) (((x) & 0x02) != 0)
#define MIX_CIPHER_WPA2_AES_ON(x) (((x) & 0x01) != 0)
#define ROUND_UP(__x, __y) \
(((ULONG)((__x)+((__y)-1))) & ((ULONG)~((__y)-1)))
#define ADD_ONE_To_64BIT_VAR(_V) \
{ \
UCHAR cnt = LEN_KEY_DESC_REPLAY; \
do \
{ \
cnt--; \
_V[cnt]++; \
if (cnt == 0) \
break; \
}while (_V[cnt] == 0); \
}
#define IS_WPA_CAPABILITY(a) (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
// EAPOL Key Information definition within Key descriptor format
typedef struct PACKED _KEY_INFO
{
UCHAR KeyMic:1;
UCHAR Secure:1;
UCHAR Error:1;
UCHAR Request:1;
UCHAR EKD_DL:1; // EKD for AP; DL for STA
UCHAR Rsvd:3;
UCHAR KeyDescVer:3;
UCHAR KeyType:1;
UCHAR KeyIndex:2;
UCHAR Install:1;
UCHAR KeyAck:1;
} KEY_INFO, *PKEY_INFO;
// EAPOL Key descriptor format
typedef struct PACKED _KEY_DESCRIPTER
{
UCHAR Type;
KEY_INFO KeyInfo;
UCHAR KeyLength[2];
UCHAR ReplayCounter[LEN_KEY_DESC_REPLAY];
UCHAR KeyNonce[LEN_KEY_DESC_NONCE];
UCHAR KeyIv[LEN_KEY_DESC_IV];
UCHAR KeyRsc[LEN_KEY_DESC_RSC];
UCHAR KeyId[LEN_KEY_DESC_ID];
UCHAR KeyMic[LEN_KEY_DESC_MIC];
UCHAR KeyDataLen[2];
UCHAR KeyData[MAX_LEN_OF_RSNIE];
} KEY_DESCRIPTER, *PKEY_DESCRIPTER;
typedef struct PACKED _EAPOL_PACKET
{
UCHAR ProVer;
UCHAR ProType;
UCHAR Body_Len[2];
KEY_DESCRIPTER KeyDesc;
} EAPOL_PACKET, *PEAPOL_PACKET;
//802.11i D10 page 83
typedef struct PACKED _GTK_ENCAP
{
UCHAR Kid:2;
UCHAR tx:1;
UCHAR rsv:5;
UCHAR rsv1;
UCHAR GTK[TKIP_GTK_LENGTH];
} GTK_ENCAP, *PGTK_ENCAP;
typedef struct PACKED _KDE_ENCAP
{
UCHAR Type;
UCHAR Len;
UCHAR OUI[3];
UCHAR DataType;
GTK_ENCAP GTKEncap;
} KDE_ENCAP, *PKDE_ENCAP;
// For WPA1
typedef struct PACKED _RSNIE {
UCHAR oui[4];
USHORT version;
UCHAR mcast[4];
USHORT ucount;
struct PACKED {
UCHAR oui[4];
}ucast[1];
} RSNIE, *PRSNIE;
// For WPA2
typedef struct PACKED _RSNIE2 {
USHORT version;
UCHAR mcast[4];
USHORT ucount;
struct PACKED {
UCHAR oui[4];
}ucast[1];
} RSNIE2, *PRSNIE2;
// AKM Suite
typedef struct PACKED _RSNIE_AUTH {
USHORT acount;
struct PACKED {
UCHAR oui[4];
}auth[1];
} RSNIE_AUTH,*PRSNIE_AUTH;
typedef union PACKED _RSN_CAPABILITIES {
struct PACKED {
USHORT PreAuth:1;
USHORT No_Pairwise:1;
USHORT PTKSA_R_Counter:2;
USHORT GTKSA_R_Counter:2;
USHORT Rsvd:10;
} field;
USHORT word;
} RSN_CAPABILITIES, *PRSN_CAPABILITIES;
typedef struct PACKED _EAP_HDR {
UCHAR ProVer;
UCHAR ProType;
UCHAR Body_Len[2];
UCHAR code;
UCHAR identifier;
UCHAR length[2]; // including code and identifier, followed by length-2 octets of data
} EAP_HDR, *PEAP_HDR;
// For supplicant state machine states. 802.11i Draft 4.1, p. 97
// We simplified it
typedef enum _WpaState
{
SS_NOTUSE, // 0
SS_START, // 1
SS_WAIT_MSG_3, // 2
SS_WAIT_GROUP, // 3
SS_FINISH, // 4
SS_KEYUPDATE, // 5
} WPA_STATE;
//
// The definition of the cipher combination
//
// bit3 bit2 bit1 bit0
// +------------+------------+
// | WPA | WPA2 |
// +------+-----+------+-----+
// | TKIP | AES | TKIP | AES |
// | 0 | 1 | 1 | 0 | -> 0x06
// | 0 | 1 | 1 | 1 | -> 0x07
// | 1 | 0 | 0 | 1 | -> 0x09
// | 1 | 0 | 1 | 1 | -> 0x0B
// | 1 | 1 | 0 | 1 | -> 0x0D
// | 1 | 1 | 1 | 0 | -> 0x0E
// | 1 | 1 | 1 | 1 | -> 0x0F
// +------+-----+------+-----+
//
typedef enum _WpaMixPairCipher
{
MIX_CIPHER_NOTUSE = 0x00,
WPA_NONE_WPA2_TKIPAES = 0x03, // WPA2-TKIPAES
WPA_AES_WPA2_TKIP = 0x06,
WPA_AES_WPA2_TKIPAES = 0x07,
WPA_TKIP_WPA2_AES = 0x09,
WPA_TKIP_WPA2_TKIPAES = 0x0B,
WPA_TKIPAES_WPA2_NONE = 0x0C, // WPA-TKIPAES
WPA_TKIPAES_WPA2_AES = 0x0D,
WPA_TKIPAES_WPA2_TKIP = 0x0E,
WPA_TKIPAES_WPA2_TKIPAES = 0x0F,
} WPA_MIX_PAIR_CIPHER;
typedef struct PACKED _RSN_IE_HEADER_STRUCT {
UCHAR Eid;
UCHAR Length;
USHORT Version; // Little endian format
} RSN_IE_HEADER_STRUCT, *PRSN_IE_HEADER_STRUCT;
// Cipher suite selector types
typedef struct PACKED _CIPHER_SUITE_STRUCT {
UCHAR Oui[3];
UCHAR Type;
} CIPHER_SUITE_STRUCT, *PCIPHER_SUITE_STRUCT;
// Authentication and Key Management suite selector
typedef struct PACKED _AKM_SUITE_STRUCT {
UCHAR Oui[3];
UCHAR Type;
} AKM_SUITE_STRUCT, *PAKM_SUITE_STRUCT;
// RSN capability
typedef struct PACKED _RSN_CAPABILITY {
USHORT Rsv:10;
USHORT GTKSAReplayCnt:2;
USHORT PTKSAReplayCnt:2;
USHORT NoPairwise:1;
USHORT PreAuth:1;
} RSN_CAPABILITY, *PRSN_CAPABILITY;
#endif
#include "../rt2860/wpa.h"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment