提交 ca97b838 编写于 作者: B Bartlomiej Zolnierkiewicz 提交者: Greg Kroah-Hartman

Staging: rt28x0: updates from vendor's V2.1.0.0 drivers

Port changes from:

* 2009_0420_RT2860_Linux_STA_V2.1.0.0
* 2009_0302_RT2870_Linux_STA_v2.1.0.0
* 2009_0525_RT3070_Linux_STA_v2.1.1.0

to in-kernel drivers.


From the RT2860 driver release note:

[2.1.0.0]
1. New generation schema for multiple OS porting
2. Fixed Ad-hoc ping failed in noisy environment. (Probe Response has too
    many retry packet then cause "not enough space in MgmtRing")
3. Fixed WPA(2)PSK issue when group cipher of AP is WEP40 or WEP104.
4. Modified iwpriv ra0 get_site_survey:
	In scan list result: Security shows "NONE" when AP is OPEN/NONE,
	shows "WEP" when AP is OPEN/WEP or SHARED/WEP, shows
	"WPAPSK(WPA2PSK)/TKIP(AES)" when AP is WPAPSK(WPA2PSK)/TKIP(AES)
	shows "WPA(WPA2)/TKIP(AES)" when AP is WPA(WPA2)/TKIP(AES)
5. Support kthread.
6. Add New A band channel list region 15 contains the whole channels in
   the A band region 4 and the new CE channel 167,169,171,173
7. Add New IEEE802.11r functionality.
8. Fixed WPA2-Enterprise failed when AP reboot or turn off then turn on.
9. Fixed STA cannot connect to 11B only AP when the setting of is PHY_11GN.


From the RT2870 driver release note:

[V2.1.0.0]
1. New generation schema for multiple OS porting.
2. Fixed Ad-hoc ping failed in noisy environment. (Probe Response has too
   many retry packet then cause "not enough space in MgmtRing").
3. Fixed WPS failed with D-Link DIR-628 in 5GHz.
4. Change FastRoaming in DAT file to AutoRoaming.
5. Support kthread.
6. Add New A band channel list region 15 contains the whole channels in
   the A band region and the new CE channel 167,169,171,173.
7. New IEEE802.11r functionality.


From the RT3070 driver release note:

Version V2.1.1.0
       1. Linux kernel 2.6.29 support.
       2. Fix eFuse write from BIN file bug.

Version 2.1.0.0
       1. New generation schema for multiple OS porting
       2. Fixed Ad-hoc ping failed in noisy environment.
       3. Modified iwpriv ra0 get_site_survey:
       4. Change FastRoaming in DAT file to AutoRoaming.
       5. Support kthread.
       6. New IEEE802.11r functionality.


Tested with RT2860 and RT3070 chipsets.
Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 3441d25f
......@@ -2,26 +2,33 @@ obj-$(CONFIG_RT2860) += rt2860sta.o
# TODO: all of these should be removed
EXTRA_CFLAGS += -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
EXTRA_CFLAGS += -DRT2860
EXTRA_CFLAGS += -DRTMP_MAC_PCI -DRTMP_PCI_SUPPORT -DRT2860
EXTRA_CFLAGS += -DDBG
rt2860sta-objs := \
common/md5.o \
common/crypt_md5.o \
common/crypt_sha2.o \
common/crypt_hmac.o \
common/mlme.o \
common/rtmp_wep.o \
common/cmm_wep.o \
common/action.o \
common/cmm_data.o \
common/rtmp_init.o \
common/rtmp_tkip.o \
common/cmm_tkip.o \
common/cmm_aes.o \
common/cmm_sync.o \
common/eeprom.o \
common/cmm_sanity.o \
common/cmm_info.o \
common/cmm_cfg.o \
common/cmm_wpa.o \
common/dfs.o \
common/spectrum.o \
common/rtmp_timer.o \
common/rt_channel.o \
common/cmm_profile.o \
common/cmm_asic.o \
sta/assoc.o \
sta/aironet.o \
sta/auth.o \
sta/auth_rsp.o \
sta/sync.o \
......@@ -34,6 +41,9 @@ rt2860sta-objs := \
rt_main_dev.o \
sta_ioctl.o \
common/ba_action.o \
common/2860_rtmp_init.o \
2860_main_dev.o \
common/cmm_data_2860.o
pci_main_dev.o \
rt_pci_rbus.o \
common/cmm_mac_pci.o \
common/cmm_data_pci.o \
common/ee_prom.o \
common/rtmp_mcu.o
/*
*************************************************************************
* 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__
......@@ -40,22 +40,24 @@
#ifndef __AP_H__
#define __AP_H__
// ap_mlme.c
// ap_wpa.c
VOID WpaStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *Sm,
OUT STATE_MACHINE_FUNC Trans[]);
#ifdef RT2870
#ifdef RTMP_MAC_USB
VOID BeaconUpdateExec(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
#endif // RT2870 //
#endif // RTMP_MAC_USB //
VOID RTMPSetPiggyBack(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN bPiggyBack);
// ap.c
VOID MacTableReset(
IN PRTMP_ADAPTER pAd);
......
......@@ -23,36 +23,126 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
mac_pci.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RT2860_H__
#define __RT2860_H__
#ifndef __MAC_PCI_H__
#define __MAC_PCI_H__
#include "../rtmp_type.h"
#include "rtmp_mac.h"
#include "rtmp_phy.h"
#include "../rtmp_iface.h"
#include "../rtmp_dot11.h"
//
// Device ID & Vendor ID related definitions,
// NOTE: you should not add the new VendorID/DeviceID here unless you not sure it belongs to what chip.
//
#define NIC_PCI_VENDOR_ID 0x1814
#define PCIBUS_INTEL_VENDOR 0x8086
#if !defined(PCI_CAP_ID_EXP)
#define PCI_CAP_ID_EXP 0x10
#endif
#if !defined(PCI_EXP_LNKCTL)
#define PCI_EXP_LNKCTL 0x10
#endif
#if !defined(PCI_CLASS_BRIDGE_PCI)
#define PCI_CLASS_BRIDGE_PCI 0x0604
#endif
#define RT28xx_CHIP_NAME "RT2860"
#define TXINFO_SIZE 0
#define TXPADDING_SIZE 0
#define RTMP_PKT_TAIL_PADDING 0
#define fRTMP_ADAPTER_NEED_STOP_TX 0
/* ----------------- EEPROM Related MACRO ----------------- */
#define RT28xx_EEPROM_READ16(pAd, offset, var) \
var = RTMP_EEPROM_READ16(pAd, offset)
#define AUX_CTRL 0x10c
#define RT28xx_EEPROM_WRITE16(pAd, offset, var) \
RTMP_EEPROM_WRITE16(pAd, offset, var)
//
// 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;
/* ----------------- TASK/THREAD Related MACRO ----------------- */
#define RT28XX_TASK_THREAD_INIT(pAd, Status) \
init_thread_task(pAd); NICInitTxRxRingAndBacklogQueue(pAd); \
Status = NDIS_STATUS_SUCCESS;
/* function declarations */
#define IRQ_HANDLE_TYPE irqreturn_t
//
// Rx descriptor format, Rx Ring
//
typedef struct PACKED _RXD_STRUC{
// Word 0
UINT32 SDP0;
// Word 1
UINT32 SDL1:14;
UINT32 Rsv:2;
UINT32 SDL0:14;
UINT32 LS0:1;
UINT32 DDONE:1;
// Word 2
UINT32 SDP1;
// Word 3
UINT32 BA:1;
UINT32 DATA:1;
UINT32 NULLDATA:1;
UINT32 FRAG:1;
UINT32 U2M:1; // 1: this RX frame is unicast to me
UINT32 Mcast:1; // 1: this is a multicast frame
UINT32 Bcast:1; // 1: this is a broadcast frame
UINT32 MyBss:1; // 1: this frame belongs to the same BSSID
UINT32 Crc:1; // 1: CRC error
UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header.
UINT32 HTC:1;
UINT32 RSSI:1;
UINT32 L2PAD:1;
UINT32 AMPDU:1;
UINT32 Decrypted:1; // this frame is being decrypted.
UINT32 PlcpSignal:1; // To be moved
UINT32 PlcpRssil:1;// To be moved
UINT32 Rsv1:13;
} RXD_STRUC, *PRXD_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
/* ----------------- EEPROM Related MACRO ----------------- */
// 8051 firmware image for RT2860 - base address = 0x4000
#define FIRMWARE_IMAGE_BASE 0x2000
#define MAX_FIRMWARE_IMAGE_SIZE 0x2000 // 8kbyte
IRQ_HANDLE_TYPE
rt2860_interrupt(int irq, void *dev_instance);
/* ----------------- Frimware Related MACRO ----------------- */
#define RT28XX_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
do{ \
ULONG _i, _firm; \
RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x10000); \
......@@ -73,14 +163,15 @@ rt2860_interrupt(int irq, void *dev_instance);
RTMP_IO_WRITE32(_pAd, H2M_MAILBOX_CSR, 0); \
}while(0)
/* ----------------- TX Related MACRO ----------------- */
#define RT28XX_START_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0)
#define RT28XX_STOP_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0)
#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0)
#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0)
#define RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
#define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
((freeNum) >= (ULONG)(pTxBlk->TotalFragNum + RTMP_GET_PACKET_FRAGMENTS(pPacket) + 3)) /* rough estimate we will use 3 more descriptor. */
#define RT28XX_RELEASE_DESC_RESOURCE(pAd, QueIdx) \
#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) \
do{}while(0)
#define NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, freeNum, _TxFrameType) \
......@@ -91,10 +182,6 @@ rt2860_interrupt(int irq, void *dev_instance);
#define HAL_KickOutMgmtTx(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen) \
RtmpPCIMgmtKickOut(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)
#define RTMP_PKT_TAIL_PADDING 0
#define fRTMP_ADAPTER_NEED_STOP_TX 0
#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
/* RtmpPCI_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)*/
......@@ -136,34 +223,32 @@ rt2860_interrupt(int irq, void *dev_instance);
/* ----------------- RX Related MACRO ----------------- */
// no use
#define RT28XX_RCV_PKT_GET_INIT(pAd)
#define RT28XX_RV_A_BUF_END
//#define RT28XX_RV_ALL_BUF_END
/* ----------------- ASIC Related MACRO ----------------- */
// no use
#define RT28XX_DMA_POST_WRITE(pAd)
// reset MAC of a station entry to 0x000000000000
#define RT28XX_STA_ENTRY_MAC_RESET(pAd, Wcid) \
#define RTMP_STA_ENTRY_MAC_RESET(pAd, Wcid) \
AsicDelWcidTab(pAd, Wcid);
// add this entry into ASIC RX WCID search table
#define RT28XX_STA_ENTRY_ADD(pAd, pEntry) \
#define RTMP_STA_ENTRY_ADD(pAd, pEntry) \
AsicUpdateRxWCIDTable(pAd, pEntry->Aid, pEntry->Addr);
// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
// Set MAC register value according operation mode
#define RTMP_UPDATE_PROTECT(pAd) \
AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT), TRUE, 0);
// end johnli
// remove Pair-wise key material from ASIC
#define RT28XX_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid) \
#define RTMP_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid) \
AsicRemovePairwiseKeyEntry(pAd, BssIdx, (UCHAR)Wcid);
// add Client security information into ASIC WCID table and IVEIV table
#define RT28XX_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry) \
#define RTMP_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry) \
RTMPAddWcidAttributeEntry(pAd, apidx, KeyID, \
pAd->SharedKey[apidx][KeyID].CipherAlg, pEntry);
#define RT28XX_SECURITY_KEY_ADD(pAd, apidx, KeyID, pEntry) \
#define RTMP_SECURITY_KEY_ADD(pAd, apidx, KeyID, pEntry) \
{ /* update pairwise key information to ASIC Shared Key Table */ \
AsicAddSharedKeyEntry(pAd, apidx, KeyID, \
pAd->SharedKey[apidx][KeyID].CipherAlg, \
......@@ -177,19 +262,19 @@ rt2860_interrupt(int irq, void *dev_instance);
// Insert the BA bitmap to ASIC for the Wcid entry
#define RT28XX_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID) \
#define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID) \
do{ \
UINT32 _Value = 0, _Offset; \
_Offset = MAC_WCID_BASE + (_Aid) * HW_WCID_ENTRY_SIZE + 4; \
RTMP_IO_READ32((_pAd), _Offset, &_Value); \
RTMP_IO_READ32((_pAd), _Offset, &_Value);\
_Value |= (0x10000<<(_TID)); \
RTMP_IO_WRITE32((_pAd), _Offset, _Value); \
RTMP_IO_WRITE32((_pAd), _Offset, _Value);\
}while(0)
// Remove the BA bitmap from ASIC for the Wcid entry
// bitmap field starts at 0x10000 in ASIC WCID table
#define RT28XX_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID) \
#define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID) \
do{ \
UINT32 _Value = 0, _Offset; \
_Offset = MAC_WCID_BASE + (_Wcid) * HW_WCID_ENTRY_SIZE + 4; \
......@@ -199,100 +284,54 @@ rt2860_interrupt(int irq, void *dev_instance);
}while(0)
/* ----------------- PCI/USB Related MACRO ----------------- */
#define RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p) \
((POS_COOKIE)handle)->pci_dev = dev_p;
// set driver data
#define RT28XX_DRVDATA_SET(_a) pci_set_drvdata(_a, net_dev);
#define RT28XX_UNMAP() \
{ if (net_dev->base_addr) { \
iounmap((void *)(net_dev->base_addr)); \
release_mem_region(pci_resource_start(dev_p, 0), \
pci_resource_len(dev_p, 0)); } \
if (net_dev->irq) pci_release_regions(dev_p); }
#ifdef PCI_MSI_SUPPORT
#define RTMP_MSI_ENABLE(_pAd) \
{ POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
(_pAd)->HaveMsi = pci_enable_msi(_pObj->pci_dev) == 0 ? TRUE : FALSE; }
#define RTMP_MSI_DISABLE(_pAd) \
{ POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
if (_pAd->HaveMsi == TRUE) \
pci_disable_msi(_pObj->pci_dev); \
_pAd->HaveMsi = FALSE; }
#else
#define RTMP_MSI_ENABLE(_pAd)
#define RTMP_MSI_DISABLE(_pAd)
#endif // PCI_MSI_SUPPORT //
#define SA_SHIRQ IRQF_SHARED
#define RT28XX_IRQ_REQUEST(net_dev) \
{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)((net_dev)->ml_priv); \
POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
RTMP_MSI_ENABLE(_pAd); \
if ((retval = request_irq(_pObj->pci_dev->irq, \
rt2860_interrupt, SA_SHIRQ, \
(net_dev)->name, (net_dev)))) { \
printk("RT2860: request_irq ERROR(%d)\n", retval); \
return retval; } }
#define RT28XX_IRQ_RELEASE(net_dev) \
{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)((net_dev)->ml_priv); \
POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
synchronize_irq(_pObj->pci_dev->irq); \
free_irq(_pObj->pci_dev->irq, (net_dev)); \
RTMP_MSI_DISABLE(_pAd); }
#define RT28XX_IRQ_INIT(pAd) \
/* ----------------- Interface Related MACRO ----------------- */
//
// Enable & Disable NIC interrupt via writing interrupt mask register
// Since it use ADAPTER structure, it have to be put after structure definition.
//
#define RTMP_ASIC_INTERRUPT_DISABLE(_pAd) \
do{ \
RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, 0x0); /* 0: disable */ \
RTMP_CLEAR_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \
}while(0)
#define RTMP_ASIC_INTERRUPT_ENABLE(_pAd)\
do{ \
RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, (_pAd)->int_enable_reg /*DELAYINTMASK*/); /* 1:enable */ \
RTMP_SET_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \
}while(0)
#define RTMP_IRQ_INIT(pAd) \
{ pAd->int_enable_reg = ((DELAYINTMASK) | \
(RxINT|TxDataInt|TxMgmtInt)) & ~(0x03); \
pAd->int_disable_mask = 0; \
pAd->int_pending = 0; }
#define RT28XX_IRQ_ENABLE(pAd) \
#define RTMP_IRQ_ENABLE(pAd) \
{ /* clear garbage ints */ \
RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff); \
NICEnableInterrupt(pAd); }
#define RT28XX_PUT_DEVICE(dev_p)
RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff);\
RTMP_ASIC_INTERRUPT_ENABLE(pAd); }
/* ----------------- MLME Related MACRO ----------------- */
#define RT28XX_MLME_HANDLER(pAd) MlmeHandler(pAd)
#define RTMP_MLME_HANDLER(pAd) MlmeHandler(pAd)
#define RT28XX_MLME_PRE_SANITY_CHECK(pAd)
#define RTMP_MLME_PRE_SANITY_CHECK(pAd)
#define RT28XX_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
#define RT28XX_MLME_RESET_STATE_MACHINE(pAd) \
#define RTMP_MLME_RESET_STATE_MACHINE(pAd) \
MlmeRestartStateMachine(pAd)
#define RT28XX_HANDLE_COUNTER_MEASURE(_pAd, _pEntry) \
#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)\
HandleCounterMeasure(_pAd, _pEntry)
/* ----------------- Power Save Related MACRO ----------------- */
#define RT28XX_PS_POLL_ENQUEUE(pAd) EnqueuePsPoll(pAd)
#define RTMP_PS_POLL_ENQUEUE(pAd) EnqueuePsPoll(pAd)
//
// Device ID & Vendor ID, these values should match EEPROM value
//
#define NIC2860_PCI_DEVICE_ID 0x0601
#define NIC2860_PCIe_DEVICE_ID 0x0681
#define NIC2760_PCI_DEVICE_ID 0x0701 // 1T/2R Cardbus ???
#define NIC2790_PCIe_DEVICE_ID 0x0781 // 1T/2R miniCard
#define NIC_PCI_VENDOR_ID 0x1814
#define VEN_AWT_PCIe_DEVICE_ID 0x1059
#define VEN_AWT_PCI_VENDOR_ID 0x1A3B
#define EDIMAX_PCI_VENDOR_ID 0x1432
// For RTMPPCIePowerLinkCtrlRestore () function
#define RESTORE_HALT 1
......@@ -307,27 +346,20 @@ rt2860_interrupt(int irq, void *dev_instance);
#define CID2MASK 0x00ff0000
#define CID3MASK 0xff000000
#define PCI_REG_READ_WORD(pci_dev, offset, Configuration) \
if (pci_read_config_word(pci_dev, offset, &reg16) == 0) \
Configuration = le2cpu16(reg16); \
else \
Configuration = 0;
#define PCI_REG_WIRTE_WORD(pci_dev, offset, Configuration) \
reg16 = cpu2le16(Configuration); \
pci_write_config_word(pci_dev, offset, reg16); \
#define RTMP_STA_FORCE_WAKEUP(pAd, bFromTx) \
RT28xxPciStaAsicForceWakeup(pAd, bFromTx);
#define RT28XX_STA_FORCE_WAKEUP(pAd, Level) \
RT28xxPciStaAsicForceWakeup(pAd, Level);
#define RT28XX_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
RT28xxPciStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
#define RT28XX_MLME_RADIO_ON(pAd) \
#define RTMP_SET_PSM_BIT(_pAd, _val) \
MlmeSetPsmBit(_pAd, _val);
#define RTMP_MLME_RADIO_ON(pAd) \
RT28xxPciMlmeRadioOn(pAd);
#define RT28XX_MLME_RADIO_OFF(pAd) \
#define RTMP_MLME_RADIO_OFF(pAd) \
RT28xxPciMlmeRadioOFF(pAd);
#endif //__RT2860_H__
#endif //__MAC_PCI_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:
mac_usb.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __MAC_USB_H__
#define __MAC_USB_H__
#include "../rtmp_type.h"
#include "rtmp_mac.h"
#include "rtmp_phy.h"
#include "../rtmp_iface.h"
#include "../rtmp_dot11.h"
#define USB_CYC_CFG 0x02a4
#define BEACON_RING_SIZE 2
#define MGMTPIPEIDX 0 // EP6 is highest priority
#define RTMP_PKT_TAIL_PADDING 11 // 3(max 4 byte padding) + 4 (last packet padding) + 4 (MaxBulkOutsize align padding)
#define fRTMP_ADAPTER_NEED_STOP_TX \
(fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_BULKOUT_RESET | \
fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_REMOVE_IN_PROGRESS)
//
// RXINFO appends at the end of each rx packet.
//
#define RXINFO_SIZE 4
#define RT2870_RXDMALEN_FIELD_SIZE 4
typedef struct PACKED _RXINFO_STRUC {
UINT32 BA:1;
UINT32 DATA:1;
UINT32 NULLDATA:1;
UINT32 FRAG:1;
UINT32 U2M:1; // 1: this RX frame is unicast to me
UINT32 Mcast:1; // 1: this is a multicast frame
UINT32 Bcast:1; // 1: this is a broadcast frame
UINT32 MyBss:1; // 1: this frame belongs to the same BSSID
UINT32 Crc:1; // 1: CRC error
UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header.
UINT32 HTC:1;
UINT32 RSSI:1;
UINT32 L2PAD:1;
UINT32 AMPDU:1; // To be moved
UINT32 Decrypted:1;
UINT32 PlcpRssil:1;
UINT32 CipherAlg:1;
UINT32 LastAMSDU:1;
UINT32 PlcpSignal:12;
} RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
//
// TXINFO
//
#define TXINFO_SIZE 4
typedef struct _TXINFO_STRUC {
// Word 0
UINT32 USBDMATxPktLen:16; //used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame.
UINT32 rsv:8;
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 SwUseLastRound:1; // Software use.
UINT32 rsv2:2; // Software use.
UINT32 USBDMANextVLD:1; //used ONLY in USB bulk Aggregation, NextValid
UINT32 USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
} TXINFO_STRUC, *PTXINFO_STRUC;
//
// Management ring buffer format
//
typedef struct _MGMT_STRUC {
BOOLEAN Valid;
PUCHAR pBuffer;
ULONG Length;
} MGMT_STRUC, *PMGMT_STRUC;
////////////////////////////////////////////////////////////////////////////
// The TX_BUFFER structure forms the transmitted USB packet to the device
////////////////////////////////////////////////////////////////////////////
typedef struct __TX_BUFFER{
union{
UCHAR WirelessPacket[TX_BUFFER_NORMSIZE];
HEADER_802_11 NullFrame;
PSPOLL_FRAME PsPollPacket;
RTS_FRAME RTSFrame;
}field;
UCHAR Aggregation[4]; //Buffer for save Aggregation size.
} TX_BUFFER, *PTX_BUFFER;
typedef struct __HTTX_BUFFER{
union{
UCHAR WirelessPacket[MAX_TXBULK_SIZE];
HEADER_802_11 NullFrame;
PSPOLL_FRAME PsPollPacket;
RTS_FRAME RTSFrame;
}field;
UCHAR Aggregation[4]; //Buffer for save Aggregation size.
} HTTX_BUFFER, *PHTTX_BUFFER;
// used to track driver-generated write irps
typedef struct _TX_CONTEXT
{
PVOID pAd; //Initialized in MiniportInitialize
PURB pUrb; //Initialized in MiniportInitialize
PIRP pIrp; //used to cancel pending bulk out.
//Initialized in MiniportInitialize
PTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
ULONG BulkOutSize;
UCHAR BulkOutPipeId;
UCHAR SelfIdx;
BOOLEAN InUse;
BOOLEAN bWaitingBulkOut; // at least one packet is in this TxContext, ready for making IRP anytime.
BOOLEAN bFullForBulkOut; // all tx buffer are full , so waiting for tx bulkout.
BOOLEAN IRPPending;
BOOLEAN LastOne;
BOOLEAN bAggregatible;
UCHAR Header_802_3[LENGTH_802_3];
UCHAR Rsv[2];
ULONG DataOffset;
UINT TxRate;
dma_addr_t data_dma; // urb dma on linux
} TX_CONTEXT, *PTX_CONTEXT, **PPTX_CONTEXT;
// used to track driver-generated write irps
typedef struct _HT_TX_CONTEXT
{
PVOID pAd; //Initialized in MiniportInitialize
PURB pUrb; //Initialized in MiniportInitialize
PIRP pIrp; //used to cancel pending bulk out.
//Initialized in MiniportInitialize
PHTTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
ULONG BulkOutSize; // Indicate the total bulk-out size in bytes in one bulk-transmission
UCHAR BulkOutPipeId;
BOOLEAN IRPPending;
BOOLEAN LastOne;
BOOLEAN bCurWriting;
BOOLEAN bRingEmpty;
BOOLEAN bCopySavePad;
UCHAR SavedPad[8];
UCHAR Header_802_3[LENGTH_802_3];
ULONG CurWritePosition; // Indicate the buffer offset which packet will be inserted start from.
ULONG CurWriteRealPos; // Indicate the buffer offset which packet now are writing to.
ULONG NextBulkOutPosition; // Indicate the buffer start offset of a bulk-transmission
ULONG ENextBulkOutPosition; // Indicate the buffer end offset of a bulk-transmission
UINT TxRate;
dma_addr_t data_dma; // urb dma on linux
} HT_TX_CONTEXT, *PHT_TX_CONTEXT, **PPHT_TX_CONTEXT;
//
// Structure to keep track of receive packets and buffers to indicate
// receive data to the protocol.
//
typedef struct _RX_CONTEXT
{
PUCHAR TransferBuffer;
PVOID pAd;
PIRP pIrp;//used to cancel pending bulk in.
PURB pUrb;
//These 2 Boolean shouldn't both be 1 at the same time.
ULONG BulkInOffset; // number of packets waiting for reordering .
// BOOLEAN ReorderInUse; // At least one packet in this buffer are in reordering buffer and wait for receive indication
BOOLEAN bRxHandling; // Notify this packet is being process now.
BOOLEAN InUse; // USB Hardware Occupied. Wait for USB HW to put packet.
BOOLEAN Readable; // Receive Complete back. OK for driver to indicate receiving packet.
BOOLEAN IRPPending; // TODO: To be removed
atomic_t IrpLock;
NDIS_SPIN_LOCK RxContextLock;
dma_addr_t data_dma; // urb dma on linux
} RX_CONTEXT, *PRX_CONTEXT;
/******************************************************************************
USB Frimware Related MACRO
******************************************************************************/
// 8051 firmware image for usb - use last-half base address = 0x3000
#define FIRMWARE_IMAGE_BASE 0x3000
#define MAX_FIRMWARE_IMAGE_SIZE 0x1000 // 4kbyte
#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)
/******************************************************************************
USB TX Related MACRO
******************************************************************************/
#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) \
do{ \
RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
if (pAd->DeQueueRunning[QueIdx]) \
{ \
RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
DBGPRINT(RT_DEBUG_OFF, ("DeQueueRunning[%d]= TRUE!\n", QueIdx)); \
continue; \
} \
else \
{ \
pAd->DeQueueRunning[QueIdx] = TRUE; \
RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
} \
}while(0)
#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) \
do{ \
RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
pAd->DeQueueRunning[QueIdx] = FALSE; \
RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
}while(0)
#define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
(RTUSBFreeDescriptorRequest(pAd, pTxBlk->QueIdx, (pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))) == NDIS_STATUS_SUCCESS)
#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) \
do{}while(0)
#define NEED_QUEUE_BACK_FOR_AGG(_pAd, _QueIdx, _freeNum, _TxFrameType) \
((_TxFrameType == TX_RALINK_FRAME) && (RTUSBNeedQueueBackForAgg(_pAd, _QueIdx)))
#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
#define HAL_WriteTxResource(pAd, pTxBlk,bIsLast, pFreeNumber) \
RtmpUSB_WriteSingleTxResource(pAd, pTxBlk,bIsLast, pFreeNumber)
#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
#define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) \
RtmpUSB_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber)
#define HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx) \
RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)
#define HAL_LastTxIdx(pAd, QueIdx,TxIdx) \
/*RtmpUSBDataLastTxIdx(pAd, QueIdx,TxIdx)*/
#define HAL_KickOutTx(pAd, pTxBlk, QueIdx) \
RtmpUSBDataKickOut(pAd, pTxBlk, QueIdx)
#define HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen) \
RtmpUSBMgmtKickOut(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)
#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen) \
RtmpUSBNullFrameKickOut(_pAd, _QueIdx, _pNullFrame, _frameLen)
#define GET_TXRING_FREENO(_pAd, _QueIdx) (_QueIdx) //(_pAd->TxRing[_QueIdx].TxSwFreeIdx)
#define GET_MGMTRING_FREENO(_pAd) (_pAd->MgmtRing.TxSwFreeIdx)
/* ----------------- RX Related MACRO ----------------- */
/*
* Device Hardware Interface Related MACRO
*/
#define RTMP_IRQ_INIT(pAd) do{}while(0)
#define RTMP_IRQ_ENABLE(pAd) do{}while(0)
/*
* MLME Related MACRO
*/
#define RTMP_MLME_HANDLER(pAd) RTUSBMlmeUp(pAd)
#define RTMP_MLME_PRE_SANITY_CHECK(pAd) \
{ if ((pAd->CommonCfg.bHardwareRadio == TRUE) && \
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && \
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))) { \
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_CHECK_GPIO, NULL, 0); } }
#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
{ RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_QKERIODIC_EXECUT, NULL, 0); \
RTUSBMlmeUp(pAd); }
#define RTMP_MLME_RESET_STATE_MACHINE(pAd) \
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_RESET_CONF, 0, NULL); \
RTUSBMlmeUp(pAd);
#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry) \
{ RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_802_11_COUNTER_MEASURE, _pEntry, sizeof(MAC_TABLE_ENTRY)); \
RTUSBMlmeUp(_pAd); \
}
/*
* Power Save Related MACRO
*/
#define RTMP_PS_POLL_ENQUEUE(pAd) \
{ RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL); \
RTUSBKickBulkOut(pAd); }
#define RTMP_STA_FORCE_WAKEUP(_pAd, bFromTx) \
RT28xxUsbStaAsicForceWakeup(_pAd, bFromTx);
#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
RT28xxUsbStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
#define RTMP_SET_PSM_BIT(_pAd, _val) \
{\
if ((_pAd)->StaCfg.WindowsPowerMode == Ndis802_11PowerModeFast_PSP) \
MlmeSetPsmBit(_pAd, _val);\
else \
{ \
USHORT _psm_val; \
_psm_val = _val; \
RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_SET_PSM_BIT, &(_psm_val), sizeof(USHORT)); \
}\
}
#define RTMP_MLME_RADIO_ON(pAd) \
RT28xxUsbMlmeRadioOn(pAd);
#define RTMP_MLME_RADIO_OFF(pAd) \
RT28xxUsbMlmeRadioOFF(pAd);
#endif //__MAC_USB_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 __RT2860_H__
#define __RT2860_H__
#include "mac_pci.h"
#ifndef RTMP_PCI_SUPPORT
#error "For RT2860, you should define the compile flag -DRTMP_PCI_SUPPORT"
#endif
#ifndef RTMP_MAC_PCI
#error "For RT2880, you should define the compile flag -DRTMP_MAC_PCI"
#endif
//
// Device ID & Vendor ID, these values should match EEPROM value
//
#define NIC2860_PCI_DEVICE_ID 0x0601
#define NIC2860_PCIe_DEVICE_ID 0x0681
#define NIC2760_PCI_DEVICE_ID 0x0701 // 1T/2R Cardbus ???
#define NIC2790_PCIe_DEVICE_ID 0x0781 // 1T/2R miniCard
#define VEN_AWT_PCIe_DEVICE_ID 0x1059
#define VEN_AWT_PCI_VENDOR_ID 0x1A3B
#define EDIMAX_PCI_VENDOR_ID 0x1432
#endif //__RT2860_H__ //
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
*/
#ifndef __RT2870_H__
#define __RT2870_H__
#ifdef RT2870
#ifndef RTMP_USB_SUPPORT
#error "For RT2870, you should define the compile flag -DRTMP_USB_SUPPORT"
#endif
#ifndef RTMP_MAC_USB
#error "For RT2870, you should define the compile flag -DRTMP_MAC_USB"
#endif
#include "../rtmp_type.h"
#include "mac_usb.h"
//#define RTMP_CHIP_NAME "RT2870"
#endif // RT2870 //
#endif //__RT2870_H__ //
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt3070.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RT3070_H__
#define __RT3070_H__
#ifdef RT3070
#ifndef RTMP_USB_SUPPORT
#error "For RT3070, you should define the compile flag -DRTMP_USB_SUPPORT"
#endif
#ifndef RTMP_MAC_USB
#error "For RT3070, you should define the compile flag -DRTMP_MAC_USB"
#endif
#ifndef RTMP_RF_RW_SUPPORT
#error "For RT3070, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
#endif
#ifndef RT30xx
#error "For RT3070, you should define the compile flag -DRT30xx"
#endif
#include "mac_usb.h"
#include "rt30xx.h"
//
// Device ID & Vendor ID, these values should match EEPROM value
//
#endif // RT3070 //
#endif //__RT3070_H__ //
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt30xx.h
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifndef __RT30XX_H__
#define __RT30XX_H__
#ifdef RT30xx
extern REG_PAIR RT30xx_RFRegTable[];
extern UCHAR NUM_RF_REG_PARMS;
#endif // RT30xx //
#endif //__RT30XX_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_phy.h
Abstract:
Ralink Wireless Chip PHY(BBP/RF) related definition & structures
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifndef __RTMP_PHY_H__
#define __RTMP_PHY_H__
/*
RF sections
*/
#define RF_R00 0
#define RF_R01 1
#define RF_R02 2
#define RF_R03 3
#define RF_R04 4
#define RF_R05 5
#define RF_R06 6
#define RF_R07 7
#define RF_R08 8
#define RF_R09 9
#define RF_R10 10
#define RF_R11 11
#define RF_R12 12
#define RF_R13 13
#define RF_R14 14
#define RF_R15 15
#define RF_R16 16
#define RF_R17 17
#define RF_R18 18
#define RF_R19 19
#define RF_R20 20
#define RF_R21 21
#define RF_R22 22
#define RF_R23 23
#define RF_R24 24
#define RF_R25 25
#define RF_R26 26
#define RF_R27 27
#define RF_R28 28
#define RF_R29 29
#define RF_R30 30
#define RF_R31 31
// value domain of pAd->RfIcType
#define RFIC_2820 1 // 2.4G 2T3R
#define RFIC_2850 2 // 2.4G/5G 2T3R
#define RFIC_2720 3 // 2.4G 1T2R
#define RFIC_2750 4 // 2.4G/5G 1T2R
#define RFIC_3020 5 // 2.4G 1T1R
#define RFIC_2020 6 // 2.4G B/G
#define RFIC_3021 7 // 2.4G 1T2R
#define RFIC_3022 8 // 2.4G 2T2R
#define RFIC_3052 9 // 2.4G/5G 2T2R
/*
BBP sections
*/
#define BBP_R0 0 // version
#define BBP_R1 1 // TSSI
#define BBP_R2 2 // TX configure
#define BBP_R3 3
#define BBP_R4 4
#define BBP_R5 5
#define BBP_R6 6
#define BBP_R14 14 // RX configure
#define BBP_R16 16
#define BBP_R17 17 // RX sensibility
#define BBP_R18 18
#define BBP_R21 21
#define BBP_R22 22
#define BBP_R24 24
#define BBP_R25 25
#define BBP_R26 26
#define BBP_R27 27
#define BBP_R31 31
#define BBP_R49 49 //TSSI
#define BBP_R50 50
#define BBP_R51 51
#define BBP_R52 52
#define BBP_R55 55
#define BBP_R62 62 // Rx SQ0 Threshold HIGH
#define BBP_R63 63
#define BBP_R64 64
#define BBP_R65 65
#define BBP_R66 66
#define BBP_R67 67
#define BBP_R68 68
#define BBP_R69 69
#define BBP_R70 70 // Rx AGC SQ CCK Xcorr threshold
#define BBP_R73 73
#define BBP_R75 75
#define BBP_R77 77
#define BBP_R78 78
#define BBP_R79 79
#define BBP_R80 80
#define BBP_R81 81
#define BBP_R82 82
#define BBP_R83 83
#define BBP_R84 84
#define BBP_R86 86
#define BBP_R91 91
#define BBP_R92 92
#define BBP_R94 94 // Tx Gain Control
#define BBP_R103 103
#define BBP_R105 105
#define BBP_R106 106
#define BBP_R113 113
#define BBP_R114 114
#define BBP_R115 115
#define BBP_R116 116
#define BBP_R117 117
#define BBP_R118 118
#define BBP_R119 119
#define BBP_R120 120
#define BBP_R121 121
#define BBP_R122 122
#define BBP_R123 123
#ifdef RT30xx
#define BBP_R138 138 // add by johnli, RF power sequence setup, ADC dynamic on/off control
#endif // RT30xx //
#define BBPR94_DEFAULT 0x06 // Add 1 value will gain 1db
//
// BBP & RF are using indirect access. Before write any value into it.
// We have to make sure there is no outstanding command pending via checking busy bit.
//
#define MAX_BUSY_COUNT 100 // Number of retry before failing access BBP & RF indirect register
//#define PHY_TR_SWITCH_TIME 5 // usec
//#define BBP_R17_LOW_SENSIBILITY 0x50
//#define BBP_R17_MID_SENSIBILITY 0x41
//#define BBP_R17_DYNAMIC_UP_BOUND 0x40
#define RSSI_FOR_VERY_LOW_SENSIBILITY -35
#define RSSI_FOR_LOW_SENSIBILITY -58
#define RSSI_FOR_MID_LOW_SENSIBILITY -80
#define RSSI_FOR_MID_SENSIBILITY -90
/*****************************************************************************
RF register Read/Write marco definition
*****************************************************************************/
#ifdef RTMP_MAC_PCI
#define RTMP_RF_IO_WRITE32(_A, _V) \
{ \
if ((_A)->bPCIclkOff == FALSE) \
{ \
PHY_CSR4_STRUC _value; \
ULONG _busyCnt = 0; \
\
do { \
RTMP_IO_READ32((_A), RF_CSR_CFG0, &_value.word); \
if (_value.field.Busy == IDLE) \
break; \
_busyCnt++; \
}while (_busyCnt < MAX_BUSY_COUNT); \
if(_busyCnt < MAX_BUSY_COUNT) \
{ \
RTMP_IO_WRITE32((_A), RF_CSR_CFG0, (_V)); \
} \
} \
}
#endif // RTMP_MAC_PCI //
#ifdef RTMP_MAC_USB
#define RTMP_RF_IO_WRITE32(_A, _V) RTUSBWriteRFRegister(_A, _V)
#endif // RTMP_MAC_USB //
#ifdef RT30xx
#define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV) RT30xxReadRFRegister(_A, _I, _pV)
#define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V) RT30xxWriteRFRegister(_A, _I, _V)
#endif // RT30xx //
/*****************************************************************************
BBP register Read/Write marco definitions.
we read/write the bbp value by register's ID.
Generate PER to test BA
*****************************************************************************/
#ifdef RTMP_MAC_PCI
/*
basic marco for BBP read operation.
_pAd: the data structure pointer of RTMP_ADAPTER
_bbpID : the bbp register ID
_pV: data pointer used to save the value of queried bbp register.
_bViaMCU: if we need access the bbp via the MCU.
*/
#define RTMP_BBP_IO_READ8(_pAd, _bbpID, _pV, _bViaMCU) \
do{ \
BBP_CSR_CFG_STRUC BbpCsr; \
int _busyCnt, _secCnt, _regID; \
\
_regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \
for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++) \
{ \
RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) \
continue; \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 1; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.RegNum = _bbpID; \
RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \
if ((_bViaMCU) == TRUE) \
{ \
AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
RTMPusecDelay(1000); \
} \
for (_secCnt=0; _secCnt<MAX_BUSY_COUNT; _secCnt++) \
{ \
RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
if (BbpCsr.field.Busy == IDLE) \
break; \
} \
if ((BbpCsr.field.Busy == IDLE) && \
(BbpCsr.field.RegNum == _bbpID)) \
{ \
*(_pV) = (UCHAR)BbpCsr.field.Value; \
break; \
} \
} \
if (BbpCsr.field.Busy == BUSY) \
{ \
DBGPRINT_ERR(("BBP(viaMCU=%d) read R%d fail\n", (_bViaMCU), _bbpID)); \
*(_pV) = (_pAd)->BbpWriteLatch[_bbpID]; \
if ((_bViaMCU) == TRUE) \
{ \
RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
BbpCsr.field.Busy = 0; \
RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \
} \
} \
}while(0)
/*
This marco used for the BBP read operation which didn't need via MCU.
*/
#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE)
/*
This marco used for the BBP read operation which need via MCU.
But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
will use this function too and didn't access the bbp register via the MCU.
*/
#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
do{ \
if ((_A)->bPCIclkOff == FALSE) \
{ \
if ((_A)->infType == RTMP_DEV_INF_RBUS) \
RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE); \
else \
RTMP_BBP_IO_READ8((_A), (_I), (_pV), TRUE); \
} \
}while(0)
/*
basic marco for BBP write operation.
_pAd: the data structure pointer of RTMP_ADAPTER
_bbpID : the bbp register ID
_pV: data used to save the value of queried bbp register.
_bViaMCU: if we need access the bbp via the MCU.
*/
#define RTMP_BBP_IO_WRITE8(_pAd, _bbpID, _pV, _bViaMCU) \
do{ \
BBP_CSR_CFG_STRUC BbpCsr; \
int _busyCnt, _regID; \
\
_regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \
for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++) \
{ \
RTMP_IO_READ32((_pAd), BBP_CSR_CFG, &BbpCsr.word); \
if (BbpCsr.field.Busy == BUSY) \
continue; \
BbpCsr.word = 0; \
BbpCsr.field.fRead = 0; \
BbpCsr.field.BBP_RW_MODE = 1; \
BbpCsr.field.Busy = 1; \
BbpCsr.field.Value = _pV; \
BbpCsr.field.RegNum = _bbpID; \
RTMP_IO_WRITE32((_pAd), BBP_CSR_CFG, BbpCsr.word); \
if ((_bViaMCU) == TRUE) \
{ \
AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
if ((_pAd)->OpMode == OPMODE_AP) \
RTMPusecDelay(1000); \
} \
(_pAd)->BbpWriteLatch[_bbpID] = _pV; \
break; \
} \
if (_busyCnt == MAX_BUSY_COUNT) \
{ \
DBGPRINT_ERR(("BBP write R%d fail\n", _bbpID)); \
if((_bViaMCU) == TRUE) \
{ \
RTMP_IO_READ32(_pAd, H2M_BBP_AGENT, &BbpCsr.word); \
BbpCsr.field.Busy = 0; \
RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, BbpCsr.word); \
} \
} \
}while(0)
/*
This marco used for the BBP write operation which didn't need via MCU.
*/
#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV) \
RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE)
/*
This marco used for the BBP write operation which need via MCU.
But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
will use this function too and didn't access the bbp register via the MCU.
*/
#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV) \
do{ \
if ((_A)->bPCIclkOff == FALSE) \
{ \
if ((_A)->infType == RTMP_DEV_INF_RBUS) \
RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE); \
else \
RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), TRUE); \
} \
}while(0)
#endif // RTMP_MAC_PCI //
#ifdef RTMP_MAC_USB
#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
#endif // RTMP_MAC_USB //
#ifdef RT30xx
#define RTMP_ASIC_MMPS_DISABLE(_pAd) \
do{ \
UCHAR _bbpData; \
UINT32 _macData; \
/* disable MMPS BBP control register */ \
RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData); \
_bbpData &= ~(0x04); /*bit 2*/ \
RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData); \
\
/* disable MMPS MAC control register */ \
RTMP_IO_READ32(_pAd, 0x1210, &_macData); \
_macData &= ~(0x09); /*bit 0, 3*/ \
RTMP_IO_WRITE32(_pAd, 0x1210, _macData); \
}while(0)
#define RTMP_ASIC_MMPS_ENABLE(_pAd) \
do{ \
UCHAR _bbpData; \
UINT32 _macData; \
/* enable MMPS BBP control register */ \
RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData); \
_bbpData |= (0x04); /*bit 2*/ \
RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData); \
\
/* enable MMPS MAC control register */ \
RTMP_IO_READ32(_pAd, 0x1210, &_macData); \
_macData |= (0x09); /*bit 0, 3*/ \
RTMP_IO_WRITE32(_pAd, 0x1210, _macData); \
}while(0)
#endif // RT30xx //
#endif // __RTMP_PHY_H__ //
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt3070.c
Abstract:
Specific funcitons and variables for RT3070
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifdef RT3070
#include "../rt_config.h"
#ifndef RTMP_RF_RW_SUPPORT
#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
#endif // RTMP_RF_RW_SUPPORT //
VOID NICInitRT3070RFRegisters(IN PRTMP_ADAPTER pAd)
{
INT i;
UCHAR RFValue;
// Driver must read EEPROM to get RfIcType before initial RF registers
// Initialize RF register to default value
if (IS_RT3070(pAd) || IS_RT3071(pAd))
{
// Init RF calibration
// Driver should toggle RF R30 bit7 before init RF registers
UINT32 RfReg = 0;
UINT32 data;
RT30xxReadRFRegister(pAd, RF_R30, (PUCHAR)&RfReg);
RfReg |= 0x80;
RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
RTMPusecDelay(1000);
RfReg &= 0x7F;
RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
// Initialize RF register to default value
for (i = 0; i < NUM_RF_REG_PARMS; i++)
{
RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value);
}
// add by johnli
if (IS_RT3070(pAd))
{
//
// The DAC issue(LDO_CFG0) has been fixed in RT3070(F).
// The voltage raising patch is no longer needed for RT3070(F)
//
if ((pAd->MACVersion & 0xffff) < 0x0201)
{
// Update MAC 0x05D4 from 01xxxxxx to 0Dxxxxxx (voltage 1.2V to 1.35V) for RT3070 to improve yield rate
RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
data = ((data & 0xF0FFFFFF) | 0x0D000000);
RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
}
}
else if (IS_RT3071(pAd))
{
// Driver should set RF R6 bit6 on before init RF registers
RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RfReg);
RfReg |= 0x40;
RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RfReg);
// init R31
RT30xxWriteRFRegister(pAd, RF_R31, 0x14);
// RT3071 version E has fixed this issue
if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211))
{
// patch tx EVM issue temporarily
RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
data = ((data & 0xE0FFFFFF) | 0x0D000000);
RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
}
else
{
RTMP_IO_READ32(pAd, LDO_CFG0, &data);
data = ((data & 0xE0FFFFFF) | 0x01000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
}
// patch LNA_PE_G1 failed issue
RTUSBReadMACRegister(pAd, GPIO_SWITCH, &data);
data &= ~(0x20);
RTUSBWriteMACRegister(pAd, GPIO_SWITCH, data);
}
//For RF filter Calibration
RTMPFilterCalibration(pAd);
// Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration()
//
// TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F).
// Raising RF voltage is no longer needed for RT3070(F)
//
if ((IS_RT3070(pAd)) && ((pAd->MACVersion & 0xffff) < 0x0201))
{
RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
}
else if ((IS_RT3071(pAd)) && ((pAd->MACVersion & 0xffff) < 0x0211))
{
RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
}
// set led open drain enable
RTUSBReadMACRegister(pAd, OPT_14, &data);
data |= 0x01;
RTUSBWriteMACRegister(pAd, OPT_14, data);
// move from RT30xxLoadRFNormalModeSetup because it's needed for both RT3070 and RT3071
// TX_LO1_en, RF R17 register Bit 3 to 0
RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
RFValue &= (~0x08);
// to fix rx long range issue
if (pAd->NicConfig2.field.ExternalLNAForG == 0)
{
if ((IS_RT3071(pAd) && ((pAd->MACVersion & 0xffff) >= 0x0211)) || IS_RT3070(pAd))
{
RFValue |= 0x20;
}
}
// set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h
if (pAd->TxMixerGain24G >= 1)
{
RFValue &= (~0x7); // clean bit [2:0]
RFValue |= pAd->TxMixerGain24G;
}
RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
if (IS_RT3071(pAd))
{
// add by johnli, RF power sequence setup, load RF normal operation-mode setup
RT30xxLoadRFNormalModeSetup(pAd);
}
else if (IS_RT3070(pAd))
{
/* add by johnli, reset RF_R27 when interface down & up to fix throughput problem*/
// LDORF_VC, RF R27 register Bit 2 to 0
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
// TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F).
// Raising RF voltage is no longer needed for RT3070(F)
if ((pAd->MACVersion & 0xffff) < 0x0201)
RFValue = (RFValue & (~0x77)) | 0x3;
else
RFValue = (RFValue & (~0x77));
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
/* end johnli */
}
}
}
#endif // RT3070 //
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
Module Name:
rt30xx.c
Abstract:
Specific funcitons and variables for RT30xx.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifdef RT30xx
#ifndef RTMP_RF_RW_SUPPORT
#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
#endif // RTMP_RF_RW_SUPPORT //
#include "../rt_config.h"
//
// RF register initialization set
//
REG_PAIR RT30xx_RFRegTable[] = {
{RF_R04, 0x40},
{RF_R05, 0x03},
{RF_R06, 0x02},
{RF_R07, 0x70},
{RF_R09, 0x0F},
{RF_R10, 0x41},
{RF_R11, 0x21},
{RF_R12, 0x7B},
{RF_R14, 0x90},
{RF_R15, 0x58},
{RF_R16, 0xB3},
{RF_R17, 0x92},
{RF_R18, 0x2C},
{RF_R19, 0x02},
{RF_R20, 0xBA},
{RF_R21, 0xDB},
{RF_R24, 0x16},
{RF_R25, 0x01},
{RF_R29, 0x1F},
};
UCHAR NUM_RF_REG_PARMS = (sizeof(RT30xx_RFRegTable) / sizeof(REG_PAIR));
// Antenna divesity use GPIO3 and EESK pin for control
// Antenna and EEPROM access are both using EESK pin,
// Therefor we should avoid accessing EESK at the same time
// Then restore antenna after EEPROM access
// The original name of this function is AsicSetRxAnt(), now change to
//VOID AsicSetRxAnt(
VOID RT30xxSetRxAnt(
IN PRTMP_ADAPTER pAd,
IN UCHAR Ant)
{
UINT32 Value;
UINT32 x;
if ((pAd->EepromAccess) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) ||
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
{
return;
}
// the antenna selection is through firmware and MAC register(GPIO3)
if (Ant == 0)
{
// Main antenna
AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x1, 0x0);
RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
Value &= ~(0x0808);
RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to main antenna\n"));
}
else
{
// Aux antenna
AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x0, 0x0);
RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
Value &= ~(0x0808);
Value |= 0x08;
RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to aux antenna\n"));
}
}
/*
========================================================================
Routine Description:
For RF filter calibration purpose
Arguments:
pAd Pointer to our adapter
Return Value:
None
IRQL = PASSIVE_LEVEL
========================================================================
*/
VOID RTMPFilterCalibration(
IN PRTMP_ADAPTER pAd)
{
UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue=0;
UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0;
UCHAR RF_R24_Value = 0;
// Give bbp filter initial value
pAd->Mlme.CaliBW20RfR24 = 0x1F;
pAd->Mlme.CaliBW40RfR24 = 0x2F; //Bit[5] must be 1 for BW 40
do
{
if (loop == 1) //BandWidth = 40 MHz
{
// Write 0x27 to RF_R24 to program filter
RF_R24_Value = 0x27;
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
if (IS_RT3090(pAd) || IS_RT3572(pAd)|| IS_RT3390(pAd))
FilterTarget = 0x15;
else
FilterTarget = 0x19;
// when calibrate BW40, BBP mask must set to BW40.
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue&= (~0x18);
BBPValue|= (0x10);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
// set to BW40
RT30xxReadRFRegister(pAd, RF_R31, &value);
value |= 0x20;
RT30xxWriteRFRegister(pAd, RF_R31, value);
}
else //BandWidth = 20 MHz
{
// Write 0x07 to RF_R24 to program filter
RF_R24_Value = 0x07;
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
if (IS_RT3090(pAd) || IS_RT3572(pAd)|| IS_RT3390(pAd))
FilterTarget = 0x13;
else
FilterTarget = 0x16;
// set to BW20
RT30xxReadRFRegister(pAd, RF_R31, &value);
value &= (~0x20);
RT30xxWriteRFRegister(pAd, RF_R31, value);
}
// Write 0x01 to RF_R22 to enable baseband loopback mode
RT30xxReadRFRegister(pAd, RF_R22, &value);
value |= 0x01;
RT30xxWriteRFRegister(pAd, RF_R22, value);
// Write 0x00 to BBP_R24 to set power & frequency of passband test tone
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
do
{
// Write 0x90 to BBP_R25 to transmit test tone
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
RTMPusecDelay(1000);
// Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0]
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
R55x = value & 0xFF;
} while ((ReTry++ < 100) && (R55x == 0));
// Write 0x06 to BBP_R24 to set power & frequency of stopband test tone
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0x06);
while(TRUE)
{
// Write 0x90 to BBP_R25 to transmit test tone
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
//We need to wait for calibration
RTMPusecDelay(1000);
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
value &= 0xFF;
if ((R55x - value) < FilterTarget)
{
RF_R24_Value ++;
}
else if ((R55x - value) == FilterTarget)
{
RF_R24_Value ++;
count ++;
}
else
{
break;
}
// prevent infinite loop cause driver hang.
if (loopcnt++ > 100)
{
DBGPRINT(RT_DEBUG_ERROR, ("RTMPFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt));
break;
}
// Write RF_R24 to program filter
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
}
if (count > 0)
{
RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0));
}
// Store for future usage
if (loopcnt < 100)
{
if (loop++ == 0)
{
//BandWidth = 20 MHz
pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value;
}
else
{
//BandWidth = 40 MHz
pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value;
break;
}
}
else
break;
RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
// reset count
count = 0;
} while(TRUE);
//
// Set back to initial state
//
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
RT30xxReadRFRegister(pAd, RF_R22, &value);
value &= ~(0x01);
RT30xxWriteRFRegister(pAd, RF_R22, value);
// set BBP back to BW20
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue&= (~0x18);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
DBGPRINT(RT_DEBUG_TRACE, ("RTMPFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24));
}
// add by johnli, RF power sequence setup
/*
==========================================================================
Description:
Load RF normal operation-mode setup
==========================================================================
*/
VOID RT30xxLoadRFNormalModeSetup(
IN PRTMP_ADAPTER pAd)
{
UCHAR RFValue;
// RX0_PD & TX0_PD, RF R1 register Bit 2 & Bit 3 to 0 and RF_BLOCK_en,RX1_PD & TX1_PD, Bit0, Bit 4 & Bit5 to 1
RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
RFValue = (RFValue & (~0x0C)) | 0x31;
RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
// TX_LO2_en, RF R15 register Bit 3 to 0
RT30xxReadRFRegister(pAd, RF_R15, &RFValue);
RFValue &= (~0x08);
RT30xxWriteRFRegister(pAd, RF_R15, RFValue);
/* move to NICInitRT30xxRFRegisters
// TX_LO1_en, RF R17 register Bit 3 to 0
RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
RFValue &= (~0x08);
// to fix rx long range issue
if (((pAd->MACVersion & 0xffff) >= 0x0211) && (pAd->NicConfig2.field.ExternalLNAForG == 0))
{
RFValue |= 0x20;
}
// set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h
if (pAd->TxMixerGain24G >= 2)
{
RFValue &= (~0x7); // clean bit [2:0]
RFValue |= pAd->TxMixerGain24G;
}
RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
*/
// RX_LO1_en, RF R20 register Bit 3 to 0
RT30xxReadRFRegister(pAd, RF_R20, &RFValue);
RFValue &= (~0x08);
RT30xxWriteRFRegister(pAd, RF_R20, RFValue);
// RX_LO2_en, RF R21 register Bit 3 to 0
RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
RFValue &= (~0x08);
RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
/* add by johnli, reset RF_R27 when interface down & up to fix throughput problem*/
// LDORF_VC, RF R27 register Bit 2 to 0
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
// TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F).
// Raising RF voltage is no longer needed for RT3070(F)
if (IS_RT3090(pAd)) // RT309x and RT3071/72
{
if ((pAd->MACVersion & 0xffff) < 0x0211)
RFValue = (RFValue & (~0x77)) | 0x3;
else
RFValue = (RFValue & (~0x77));
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
}
/* end johnli */
}
/*
==========================================================================
Description:
Load RF sleep-mode setup
==========================================================================
*/
VOID RT30xxLoadRFSleepModeSetup(
IN PRTMP_ADAPTER pAd)
{
UCHAR RFValue;
UINT32 MACValue;
#ifdef RTMP_MAC_USB
if(!IS_RT3572(pAd))
#endif // RTMP_MAC_USB //
{
// RF_BLOCK_en. RF R1 register Bit 0 to 0
RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
RFValue &= (~0x01);
RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
// VCO_IC, RF R7 register Bit 4 & Bit 5 to 0
RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
RFValue &= (~0x30);
RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
// Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 0
RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
RFValue &= (~0x0E);
RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
// RX_CTB_en, RF R21 register Bit 7 to 0
RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
RFValue &= (~0x80);
RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
}
if (IS_RT3090(pAd) || // IS_RT3090 including RT309x and RT3071/72
IS_RT3572(pAd) ||
(IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201)))
{
#ifdef RTMP_MAC_USB
if (!IS_RT3572(pAd))
#endif // RTMP_MAC_USB //
{
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
RFValue |= 0x77;
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
}
RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
MACValue |= 0x1D000000;
RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
}
}
/*
==========================================================================
Description:
Reverse RF sleep-mode setup
==========================================================================
*/
VOID RT30xxReverseRFSleepModeSetup(
IN PRTMP_ADAPTER pAd)
{
UCHAR RFValue;
UINT32 MACValue;
#ifdef RTMP_MAC_USB
if(!IS_RT3572(pAd))
#endif // RTMP_MAC_USB //
{
// RF_BLOCK_en, RF R1 register Bit 0 to 1
RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
RFValue |= 0x01;
RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
// VCO_IC, RF R7 register Bit 4 & Bit 5 to 1
RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
RFValue |= 0x30;
RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
// Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 1
RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
RFValue |= 0x0E;
RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
// RX_CTB_en, RF R21 register Bit 7 to 1
RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
RFValue |= 0x80;
RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
}
if (IS_RT3090(pAd) || // IS_RT3090 including RT309x and RT3071/72
IS_RT3572(pAd) ||
IS_RT3390(pAd) ||
(IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201)))
{
#ifdef RTMP_MAC_USB
if (!IS_RT3572(pAd))
#endif // RTMP_MAC_USB //
{
RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
if ((pAd->MACVersion & 0xffff) < 0x0211)
RFValue = (RFValue & (~0x77)) | 0x3;
else
RFValue = (RFValue & (~0x77));
RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
}
// RT3071 version E has fixed this issue
if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211))
{
// patch tx EVM issue temporarily
RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
MACValue = ((MACValue & 0xE0FFFFFF) | 0x0D000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
}
else
{
RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
MACValue = ((MACValue & 0xE0FFFFFF) | 0x01000000);
RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
}
}
if(IS_RT3572(pAd))
RT30xxWriteRFRegister(pAd, RF_R08, 0x80);
}
// end johnli
VOID RT30xxHaltAction(
IN PRTMP_ADAPTER pAd)
{
UINT32 TxPinCfg = 0x00050F0F;
//
// Turn off LNA_PE or TRSW_POL
//
if (IS_RT3070(pAd) || IS_RT3071(pAd) || IS_RT3572(pAd))
{
if ((IS_RT3071(pAd) || IS_RT3572(pAd))
#ifdef RTMP_EFUSE_SUPPORT
&& (pAd->bUseEfuse)
#endif // RTMP_EFUSE_SUPPORT //
)
{
TxPinCfg &= 0xFFFBF0F0; // bit18 off
}
else
{
TxPinCfg &= 0xFFFFF0F0;
}
RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
}
}
#endif // RT30xx //
此差异已折叠。
......@@ -150,7 +150,9 @@ VOID MlmeADDBAAction(
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(FRAME_ADDBA_REQ), &Frame,
END_OF_ARGS);
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
MiniportMMRequest(pAd, (MGMT_USE_QUEUE_FLAG | MapUserPriorityToAccessCategory[pInfo->TID]), pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
DBGPRINT(RT_DEBUG_TRACE, ("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n", Frame.BaStartSeq.field.StartSeq, FrameLen, Frame.BaParm.BufSize));
......@@ -527,9 +529,13 @@ VOID SendRefreshBAR(
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(FRAME_BAR), &FrameBar,
END_OF_ARGS);
//if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET)))
if (1) // Now we always send BAR.
{
//MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen);
MiniportMMRequest(pAd, (MGMT_USE_QUEUE_FLAG | MapUserPriorityToAccessCategory[TID]), pOutBuffer, FrameLen);
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
}
MlmeFreeMemory(pAd, pOutBuffer);
}
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -25,7 +25,7 @@
*************************************************************************
Module Name:
sync.c
cmm_sync.c
Abstract:
......@@ -64,11 +64,16 @@ UCHAR A_BAND_REGION_3_CHANNEL_LIST[]={52, 56, 60, 64, 149, 153, 157, 161};
UCHAR A_BAND_REGION_4_CHANNEL_LIST[]={149, 153, 157, 161, 165};
UCHAR A_BAND_REGION_5_CHANNEL_LIST[]={149, 153, 157, 161};
UCHAR A_BAND_REGION_6_CHANNEL_LIST[]={36, 40, 44, 48};
UCHAR A_BAND_REGION_7_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165};
UCHAR A_BAND_REGION_7_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, 169, 173};
UCHAR A_BAND_REGION_8_CHANNEL_LIST[]={52, 56, 60, 64};
UCHAR A_BAND_REGION_9_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165};
UCHAR A_BAND_REGION_10_CHANNEL_LIST[]={36, 40, 44, 48, 149, 153, 157, 161, 165};
UCHAR A_BAND_REGION_11_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161};
UCHAR A_BAND_REGION_12_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
UCHAR A_BAND_REGION_13_CHANNEL_LIST[]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161};
UCHAR A_BAND_REGION_14_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165};
UCHAR A_BAND_REGION_15_CHANNEL_LIST[]={149, 153, 157, 161, 165, 169, 173};
//BaSizeArray follows the 802.11n definition as MaxRxFactor. 2^(13+factor) bytes. When factor =0, it's about Ba buffer size =8.
UCHAR BaSizeArray[4] = {8,16,32,64};
......@@ -200,7 +205,22 @@ VOID BuildChannelList(
num = sizeof(A_BAND_REGION_11_CHANNEL_LIST)/sizeof(UCHAR);
pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
break;
case REGION_12_A_BAND:
num = sizeof(A_BAND_REGION_12_CHANNEL_LIST)/sizeof(UCHAR);
pChannelList = A_BAND_REGION_12_CHANNEL_LIST;
break;
case REGION_13_A_BAND:
num = sizeof(A_BAND_REGION_13_CHANNEL_LIST)/sizeof(UCHAR);
pChannelList = A_BAND_REGION_13_CHANNEL_LIST;
break;
case REGION_14_A_BAND:
num = sizeof(A_BAND_REGION_14_CHANNEL_LIST)/sizeof(UCHAR);
pChannelList = A_BAND_REGION_14_CHANNEL_LIST;
break;
case REGION_15_A_BAND:
num = sizeof(A_BAND_REGION_15_CHANNEL_LIST)/sizeof(UCHAR);
pChannelList = A_BAND_REGION_15_CHANNEL_LIST;
break;
default: // Error. should never happen
DBGPRINT(RT_DEBUG_WARN,("countryregion=%d not support", pAd->CommonCfg.CountryRegionForABand));
break;
......@@ -383,8 +403,11 @@ VOID ScanNextChannel(
PHEADER_802_11 pHdr80211;
UINT ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
{
if (MONITOR_ON(pAd))
return;
}
if (pAd->MlmeAux.Channel == 0)
{
......@@ -409,6 +432,19 @@ VOID ScanNextChannel(
}
{
#ifdef RT2860
/*
If all peer Ad-hoc clients leave, driver would do LinkDown and LinkUp.
In LinkUp, CommonCfg.Ssid would copy SSID from MlmeAux.
To prevent SSID is zero or wrong in Beacon, need to recover MlmeAux.SSID here.
*/
if (ADHOC_ON(pAd))
{
NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen);
}
#endif // RT2860 //
//
// To prevent data lost.
// Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
......@@ -438,29 +474,26 @@ VOID ScanNextChannel(
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
}
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
}
#ifdef RT2870
#ifdef RTMP_MAC_USB
else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->OpMode == OPMODE_STA))
{
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE);
}
#endif // RT2870 //
#endif // RTMP_MAC_USB //
else
{
{
// BBP and RF are not accessible in PS mode, we has to wake them up first
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
#ifdef RT2860
AsicForceWakeup(pAd, FROM_TX);
#endif
#ifdef RT2870
AsicForceWakeup(pAd, TRUE);
#endif
// leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON
if (pAd->StaCfg.Psm == PWR_SAVE)
MlmeSetPsmBit(pAd, PWR_ACTIVE);
RTMP_SET_PSM_BIT(pAd, PWR_ACTIVE);
}
AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, TRUE);
......@@ -487,16 +520,6 @@ VOID ScanNextChannel(
// Chnage the channel scan time for CISCO stuff based on its IAPP announcement
if (ScanType == FAST_SCAN_ACTIVE)
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, FAST_ACTIVE_SCAN_TIME);
else if (((ScanType == SCAN_CISCO_ACTIVE) ||
(ScanType == SCAN_CISCO_PASSIVE) ||
(ScanType == SCAN_CISCO_CHANNEL_LOAD) ||
(ScanType == SCAN_CISCO_NOISE)) && (pAd->OpMode == OPMODE_STA))
{
if (pAd->StaCfg.CCXScanTime < 25)
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, pAd->StaCfg.CCXScanTime * 2);
else
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, pAd->StaCfg.CCXScanTime);
}
else // must be SCAN_PASSIVE or SCAN_ACTIVE
{
if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
......@@ -512,8 +535,9 @@ VOID ScanNextChannel(
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MAX_CHANNEL_TIME);
}
if ((ScanType == SCAN_ACTIVE) || (ScanType == FAST_SCAN_ACTIVE) ||
(ScanType == SCAN_CISCO_ACTIVE))
if ((ScanType == SCAN_ACTIVE)
|| (ScanType == FAST_SCAN_ACTIVE)
)
{
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
......
......@@ -105,6 +105,15 @@ UINT FCSTAB_32[256] =
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
/*
UCHAR WEPKEY[] = {
//IV
0x00, 0x11, 0x22,
//WEP KEY
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
};
*/
/*
========================================================================
......@@ -144,12 +153,6 @@ VOID RTMPInitWepEngine(
pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
if (pAd->StaCfg.bCkipOn && (pAd->StaCfg.CkipFlag & 0x10) && (pAd->OpMode == OPMODE_STA))
{
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, pKey, KeyLen); //INIT SBOX, KEYLEN+3(IV)
NdisMoveMemory(pDest, pKey, 3); //Append Init Vector
}
else
{
NdisMoveMemory(WEPKEY + 3, pKey, KeyLen);
......@@ -494,4 +497,3 @@ VOID RTMPSetICV(
ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, (PUCHAR) &pAd->PrivateInfo.FCSCRC32, 4);
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -43,7 +43,7 @@
/* AUTO GEN PLEASE DO NOT MODIFY IT */
UCHAR FirmwareImage [] = {
UCHAR FirmwareImage_2860 [] = {
0x02, 0x03, 0x5e, 0x02, 0x02, 0xb1, 0x22, 0x22, 0xff, 0xff, 0xff, 0x02, 0x01, 0x82, 0xff, 0xff,
0xff, 0xff, 0xff, 0x02, 0x00, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x01, 0x33, 0xc0, 0xe0,
0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x18, 0xc2, 0xaf, 0x30, 0x45, 0x03,
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -43,6 +43,33 @@
#define WIDTH_RD_CHECK 1
/*************************************************************************
*
* DFS Radar related definitions.
*
************************************************************************/
//#define CARRIER_DETECT_TASK_NUM 6
//#define RADAR_DETECT_TASK_NUM 7
// McuRadarState && McuCarrierState for 2880-SW-MCU
#define FREE_FOR_TX 0
#define WAIT_CTS_BEING_SENT 1
#define DO_DETECTION 2
// McuRadarEvent
#define RADAR_EVENT_CTS_SENT 0x01 // Host signal MCU that CTS has been sent
#define RADAR_EVENT_CTS_CARRIER_SENT 0x02 // Host signal MCU that CTS has been sent (Carrier)
#define RADAR_EVENT_RADAR_DETECTING 0x04 // Radar detection is on going, carrier detection hold back
#define RADAR_EVENT_CARRIER_DETECTING 0x08 // Carrier detection is on going, radar detection hold back
#define RADAR_EVENT_WIDTH_RADAR 0x10 // BBP == 2 radar detected
#define RADAR_EVENT_CTS_KICKED 0x20 // Radar detection need to sent double CTS, first CTS sent
// McuRadarCmd
#define DETECTION_STOP 0
#define RADAR_DETECTION 1
#define CARRIER_DETECTION 2
VOID BbpRadarDetectionStart(
IN PRTMP_ADAPTER pAd);
......@@ -77,12 +104,13 @@ ULONG RTMPReadRadarDuration(
VOID RTMPCleanRadarDuration(
IN PRTMP_ADAPTER pAd);
INT Set_ChMovingTime_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
IN PSTRING arg);
INT Set_LongPulseRadarTh_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
IN PSTRING arg);
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
#include "../../rt2860/chips/rt3070.c"
#include "../../rt2860/chips/rt30xx.c"
#include "../../rt2860/common/action.c"
#include "../../rt2860/common/cmm_aes.c"
#include "../../rt2860/common/cmm_asic.c"
#include "../../rt2860/common/cmm_cfg.c"
#include "../../rt2860/common/cmm_data_usb.c"
#include "../../rt2860/common/cmm_mac_usb.c"
#include "../../rt2860/common/cmm_profile.c"
#include "../../rt2860/common/cmm_tkip.c"
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册