From 3a32ed12b69113094f0921dad50f112626cde44d Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Sun, 26 Apr 2009 16:06:25 +0200 Subject: [PATCH] Staging: rt2860: prepare for rt28[67]0/*.[ch] merge Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rt2860/Makefile | 1 + drivers/staging/rt2860/ap.h | 7 + drivers/staging/rt2860/chlist.h | 5 + drivers/staging/rt2860/oid.h | 65 +- drivers/staging/rt2860/rt28xx.h | 67 +- drivers/staging/rt2860/rt_config.h | 6 +- drivers/staging/rt2860/rt_linux.c | 14 +- drivers/staging/rt2860/rt_linux.h | 151 ++++- drivers/staging/rt2860/rt_main_dev.c | 114 +++- drivers/staging/rt2860/rt_profile.c | 33 + drivers/staging/rt2860/rtmp.h | 903 ++++++++++++++++++++++++++- drivers/staging/rt2860/rtmp_def.h | 48 +- drivers/staging/rt2860/sta_ioctl.c | 574 ++++++++++++++++- drivers/staging/rt2860/wpa.h | 2 + 14 files changed, 1952 insertions(+), 38 deletions(-) diff --git a/drivers/staging/rt2860/Makefile b/drivers/staging/rt2860/Makefile index 6b033cda1d31..c9fe92583d7e 100644 --- a/drivers/staging/rt2860/Makefile +++ b/drivers/staging/rt2860/Makefile @@ -2,6 +2,7 @@ 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 += -DDBG rt2860sta-objs := \ diff --git a/drivers/staging/rt2860/ap.h b/drivers/staging/rt2860/ap.h index a9ce57be8140..a814d55abeff 100644 --- a/drivers/staging/rt2860/ap.h +++ b/drivers/staging/rt2860/ap.h @@ -324,6 +324,13 @@ VOID APQuickResponeForRateUpExec( 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, diff --git a/drivers/staging/rt2860/chlist.h b/drivers/staging/rt2860/chlist.h index f49a35c95de6..1ad26b574083 100644 --- a/drivers/staging/rt2860/chlist.h +++ b/drivers/staging/rt2860/chlist.h @@ -524,7 +524,12 @@ static CH_REGION ChRegion[] = 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 } }, diff --git a/drivers/staging/rt2860/oid.h b/drivers/staging/rt2860/oid.h index b4d32a7e4317..8519afccd979 100644 --- a/drivers/staging/rt2860/oid.h +++ b/drivers/staging/rt2860/oid.h @@ -535,8 +535,10 @@ typedef enum _NDIS_802_11_WEP_STATUS 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; @@ -631,11 +633,17 @@ typedef struct _NDIS_802_11_CAPABILITY #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 @@ -652,9 +660,16 @@ enum { 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, +#if !defined(RT2860) && !defined(RT30xx) + SHOW_ADHOC_ENTRY_INFO = 21, +#endif }; #define OID_802_11_BUILD_CHANNEL_EX 0x0714 @@ -662,13 +677,41 @@ enum { #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 // +#if defined(RT2860) || defined(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 { @@ -691,7 +734,6 @@ typedef enum _RT_802_11_PREAMBLE { } RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE; // Only for STA, need to sync with AP -// 2005-03-08 match current RaConfig. typedef enum _RT_802_11_PHY_MODE { PHY_11BG_MIXED = 0, PHY_11B, @@ -886,6 +928,27 @@ typedef struct _RT_CHANNEL_LIST_INFO UCHAR ChannelListNum; // number of channel in ChannelList[] } RT_CHANNEL_LIST_INFO, *PRT_CHANNEL_LIST_INFO; +#ifdef RT2870 +// 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 #endif // _OID_H_ diff --git a/drivers/staging/rt2860/rt28xx.h b/drivers/staging/rt2860/rt28xx.h index 565358bb0b84..6e71acb16dc3 100644 --- a/drivers/staging/rt2860/rt28xx.h +++ b/drivers/staging/rt2860/rt28xx.h @@ -47,6 +47,15 @@ #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 // @@ -282,6 +291,36 @@ typedef union _USB_DMA_CFG_STRUC { #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 // @@ -1007,10 +1046,16 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry #define E2PROM_CSR 0x0004 #define IO_CNTL_CSR 0x77d0 +#ifdef RT2860 // 8051 firmware image for RT2860 - base address = 0x4000 #define FIRMWARE_IMAGE_BASE 0x2000 #define MAX_FIRMWARE_IMAGE_SIZE 0x2000 // 8kbyte - +#endif +#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 @@ -1091,6 +1136,9 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry #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 @@ -1108,6 +1156,10 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry #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 @@ -1129,6 +1181,9 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry #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 @@ -1294,6 +1349,7 @@ typedef struct PACKED _TXWI_STRUC { // // Rx descriptor format, Rx Ring // +#ifdef RT2860 typedef struct PACKED _RXD_STRUC { // Word 0 UINT32 SDP0; @@ -1326,6 +1382,7 @@ typedef struct PACKED _RXD_STRUC { UINT32 PlcpRssil:1;// To be moved UINT32 Rsv1:13; } RXD_STRUC, *PRXD_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC; +#endif /* RT2860 */ // // RXWI wireless information format, in PBF. invisible in driver. @@ -1550,7 +1607,15 @@ typedef union _EEPROM_NIC_CINFIG2_STRUC { 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; diff --git a/drivers/staging/rt2860/rt_config.h b/drivers/staging/rt2860/rt_config.h index 8944806e7dba..a19cbe1dedeb 100644 --- a/drivers/staging/rt2860/rt_config.h +++ b/drivers/staging/rt2860/rt_config.h @@ -47,8 +47,12 @@ #include "rtmp_def.h" #include "rt28xx.h" +#ifdef RT2860 #include "rt2860.h" - +#endif +#ifdef RT2870 +#include "../rt2870/rt2870.h" +#endif // RT2870 // #include "oid.h" #include "mlme.h" diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c index d74c593def79..80176b20db07 100644 --- a/drivers/staging/rt2860/rt_linux.c +++ b/drivers/staging/rt2860/rt_linux.c @@ -33,6 +33,9 @@ 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); @@ -43,8 +46,10 @@ BUILD_TIMER_FUNCTION(DisassocTimeout); BUILD_TIMER_FUNCTION(LinkDownExec); BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec); BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc); +#ifdef RT2860 BUILD_TIMER_FUNCTION(PsPollWakeExec); BUILD_TIMER_FUNCTION(RadioOnExec); +#endif // for wireless system event message char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = { @@ -281,9 +286,9 @@ VOID RTMPFreeAdapter( NdisFreeSpinLock(&pAd->MgmtRingLock); - +#ifdef RT2860 NdisFreeSpinLock(&pAd->RxRingLock); - +#endif for (index =0 ; index < NUM_OF_TX_RING; index++) { NdisFreeSpinLock(&pAd->TxSwQueueLock[index]); @@ -829,7 +834,12 @@ void send_monitor_packets( 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; } diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h index bfd9d062d095..85175c182432 100644 --- a/drivers/staging/rt2860/rt_linux.h +++ b/drivers/staging/rt2860/rt_linux.h @@ -43,6 +43,9 @@ #include "rtmp_type.h" #include #include +#if !defined(RT2860) && !defined(RT30xx) +#include +#endif #include #include @@ -64,6 +67,9 @@ #include +#ifdef RT30xx +#include +#endif #include // load firmware @@ -87,16 +93,31 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_ // add by kathy +#ifdef RT2860 #define STA_PROFILE_PATH "/etc/Wireless/RT2860STA/RT2860STA.dat" #define STA_RTMP_FIRMWARE_FILE_NAME "/etc/Wireless/RT2860STA/RT2860STA.bin" #define STA_NIC_DEVICE_NAME "RT2860STA" #define STA_DRIVER_VERSION "1.8.1.1" +#endif +#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 +#ifdef RT2860 #ifndef PCI_DEVICE #define PCI_DEVICE(vend,dev) \ .vendor = (vend), .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID #endif // PCI_DEVICE // +#endif #define RTMP_TIME_AFTER(a,b) \ (typecheck(unsigned long, (unsigned long)a) && \ @@ -143,12 +164,16 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_ #define NDIS_PACKET_TYPE_BROADCAST 2 #define NDIS_PACKET_TYPE_ALL_MULTICAST 3 +#ifndef RT30xx typedef struct pid * THREAD_PID; +#ifdef RT2860 #define THREAD_PID_INIT_VALUE NULL +#endif #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; @@ -157,10 +182,25 @@ struct os_lock { struct os_cookie { +#ifdef RT2860 struct pci_dev *pci_dev; struct pci_dev *parent_pci_dev; dma_addr_t pAd_pa; +#endif +#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; @@ -170,8 +210,14 @@ struct os_cookie { struct tasklet_struct ac3_dma_done_task; struct tasklet_struct hcca_dma_done_task; struct tasklet_struct tbtt_task; +#ifdef RT2860 struct tasklet_struct fifo_statistic_full_task; - +#endif +#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; @@ -219,6 +265,7 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int #define RT2860_PCI_DEVICE_ID 0x0601 +#ifdef RT2860 #define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \ linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir) @@ -233,7 +280,12 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int #define DEV_ALLOC_SKB(_length) \ dev_alloc_skb(_length) +#endif +#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) \ @@ -247,9 +299,20 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int #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 { @@ -260,9 +323,42 @@ typedef struct _RALINK_TIMER_STRUCT { 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 @@ -352,6 +448,7 @@ extern ULONG RTDebugLevel; spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \ } +#ifdef RT2860 #if defined(INF_TWINPASS) || defined(INF_DANUBE) || defined(IKANOS_VX_1X0) //Patch for ASIC turst read/write bug, needs to remove after metel fix #define RTMP_IO_READ32(_A, _R, _pV) \ @@ -453,7 +550,32 @@ extern ULONG RTDebugLevel; writew((_V), (PUSHORT)((_A)->CSRBaseAddress + (_R))); \ } #endif +#endif /* RT2860 */ +#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) \ @@ -496,7 +618,6 @@ do { \ wait_event_interruptible_timeout(_wait, 0, ONE_TICK); } -/* Modified by Wu Xi-Kun 4/21/2006 */ typedef void (*TIMER_FUNCTION)(unsigned long); #define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN) @@ -504,6 +625,7 @@ typedef void (*TIMER_FUNCTION)(unsigned long); #define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE) #define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA) +#ifdef RT2860 #define BUILD_TIMER_FUNCTION(_func) \ void linux_##_func(unsigned long data) \ { \ @@ -513,7 +635,22 @@ void linux_##_func(unsigned long data) \ if (pTimer->Repeat) \ RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \ } - +#endif +#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) \ @@ -527,6 +664,9 @@ 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); @@ -849,6 +989,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb); void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify); +#ifdef RT2860 #if !defined(PCI_CAP_ID_EXP) #define PCI_CAP_ID_EXP 0x10 #endif @@ -862,5 +1003,5 @@ void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify); #endif #define PCIBUS_INTEL_VENDOR 0x8086 - +#endif diff --git a/drivers/staging/rt2860/rt_main_dev.c b/drivers/staging/rt2860/rt_main_dev.c index 5951567b2cb4..f298b9bcec39 100644 --- a/drivers/staging/rt2860/rt_main_dev.c +++ b/drivers/staging/rt2860/rt_main_dev.c @@ -58,7 +58,9 @@ 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); +#ifdef RT2860 extern void init_thread_task(PRTMP_ADAPTER pAd); +#endif // public function prototype INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p, @@ -187,6 +189,12 @@ int rt28xx_close(IN PNET_DEV 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")); @@ -198,11 +206,21 @@ int rt28xx_close(IN PNET_DEV dev) { // If dirver doesn't wake up firmware here, // NICLoadFirmware will hang forever when interface is up again. +#ifdef RT2860 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) || RTMP_SET_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)) +#endif +#ifdef RT2870 + if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) +#endif { +#ifdef RT2860 AsicForceWakeup(pAd, RTMP_HALT); +#endif +#ifdef RT2870 + AsicForceWakeup(pAd, TRUE); +#endif } if (INFRA_ON(pAd) && @@ -230,6 +248,9 @@ int rt28xx_close(IN PNET_DEV dev) RTMPusecDelay(1000); } +#ifdef RT2870 + RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); +#endif // RT2870 // #ifdef CCX_SUPPORT RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled); @@ -239,7 +260,9 @@ int rt28xx_close(IN PNET_DEV dev) RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled); MlmeRadioOff(pAd); +#ifdef RT2860 pAd->bPCIclkOff = FALSE; +#endif } RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); @@ -253,6 +276,40 @@ int rt28xx_close(IN PNET_DEV dev) } } +#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); @@ -264,7 +321,7 @@ int rt28xx_close(IN PNET_DEV dev) MeasureReqTabExit(pAd); TpcReqTabExit(pAd); - +#ifdef RT2860 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { NICDisableInterrupt(pAd); @@ -280,7 +337,7 @@ int rt28xx_close(IN PNET_DEV dev) RT28XX_IRQ_RELEASE(net_dev) RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); } - +#endif // Free Ring or USB buffers RTMPFreeTxRxRingMemory(pAd); @@ -297,7 +354,12 @@ int rt28xx_close(IN PNET_DEV dev) static int rt28xx_init(IN struct net_device *net_dev) { +#ifdef RT2860 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->ml_priv; +#endif +#ifdef RT2870 + PRTMP_ADAPTER pAd = net_dev->ml_priv; +#endif UINT index; UCHAR TmpPhy; NDIS_STATUS Status; @@ -320,11 +382,11 @@ static int rt28xx_init(IN struct net_device *net_dev) } 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) @@ -337,10 +399,12 @@ static int rt28xx_init(IN struct net_device *net_dev) // Disable interrupts here which is as soon as possible // This statement should never be true. We might consider to remove it later +#ifdef RT2860 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { NICDisableInterrupt(pAd); } +#endif Status = RTMPAllocTxRxRingMemory(pAd); if (Status != NDIS_STATUS_SUCCESS) @@ -365,6 +429,10 @@ static int rt28xx_init(IN struct net_device *net_dev) // 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) @@ -398,6 +466,14 @@ static int rt28xx_init(IN struct net_device *net_dev) 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. @@ -436,6 +512,11 @@ static int rt28xx_init(IN struct net_device *net_dev) 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 // @@ -446,8 +527,10 @@ static int rt28xx_init(IN struct net_device *net_dev) 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)) { @@ -464,9 +547,24 @@ static int rt28xx_init(IN struct net_device *net_dev) // 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; indexCommonCfg.NumOfBulkInIRP; index++) + { + RTUSBBulkReceive(pAd); + DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" )); + } +#endif // RT2870 // }// end of else @@ -565,8 +663,9 @@ int rt28xx_open(IN PNET_DEV dev) printk("0x1300 = %08x\n", reg); } +#ifdef RT2860 RTMPInitPCIeLinkCtrlValue(pAd); - +#endif return (retval); err: @@ -662,8 +761,15 @@ INT __devinit rt28xx_probe( PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL; INT status; PVOID handle; +#ifdef RT2860 struct pci_dev *dev_p = (struct pci_dev *)_dev_p; +#endif +#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)); diff --git a/drivers/staging/rt2860/rt_profile.c b/drivers/staging/rt2860/rt_profile.c index a279eed5b453..d92b14328d40 100644 --- a/drivers/staging/rt2860/rt_profile.c +++ b/drivers/staging/rt2860/rt_profile.c @@ -886,11 +886,13 @@ NDIS_STATUS RTMPReadParametersHook( // 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); @@ -1352,7 +1354,12 @@ NDIS_STATUS RTMPReadParametersHook( { //PSMode +#ifdef RT2860 if (RTMPGetKeyParameter("PSMode", tmpbuf, 32, buffer)) +#endif +#ifdef RT2870 + if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer)) +#endif { if (pAd->StaCfg.BssType == BSS_INFRA) { @@ -1435,6 +1442,23 @@ NDIS_STATUS RTMPReadParametersHook( 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 @@ -1547,12 +1571,21 @@ static void HTParametersHook( 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")); } diff --git a/drivers/staging/rt2860/rtmp.h b/drivers/staging/rt2860/rtmp.h index 55149537a4aa..25c31998d071 100644 --- a/drivers/staging/rt2860/rtmp.h +++ b/drivers/staging/rt2860/rtmp.h @@ -51,6 +51,104 @@ #define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--) #define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt) +#ifdef RT2870 +//////////////////////////////////////////////////////////////////////////// +// 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 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; +#endif // RT2870 // // @@ -136,9 +234,15 @@ extern UCHAR WpaIe; extern UCHAR Wpa2Ie; extern UCHAR IbssIe; extern UCHAR Ccx2Ie; +#ifdef RT30xx +extern UCHAR WapiIe; +#endif extern UCHAR WPA_OUI[]; extern UCHAR RSN_OUI[]; +#ifdef RT30xx +extern UCHAR WAPI_OUI[]; +#endif extern UCHAR WME_INFO_ELEM[]; extern UCHAR WME_PARM_ELEM[]; extern UCHAR Ccx2QosInfo[]; @@ -259,12 +363,14 @@ typedef struct _QUEUE_HEADER { #define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0) #define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F)) +#ifdef RT2860 // Macro for power save flag. #define RTMP_SET_PSFLAG(_M, _F) ((_M)->PSFlags |= (_F)) #define RTMP_CLEAR_PSFLAG(_M, _F) ((_M)->PSFlags &= ~(_F)) #define RTMP_CLEAR_PSFLAGS(_M) ((_M)->PSFlags = 0) #define RTMP_TEST_PSFLAG(_M, _F) (((_M)->PSFlags & (_F)) != 0) #define RTMP_TEST_PSFLAGS(_M, _F) (((_M)->PSFlags & (_F)) == (_F)) +#endif #define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F)) #define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F)) @@ -294,7 +400,17 @@ typedef struct _QUEUE_HEADER { (_idx) = (_idx+1) % (_RingSize); \ } +#ifdef RT30xx +// We will have a cost down version which mac version is 0x3090xxxx +#define IS_RT3090(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (((_pAd)->MACVersion & 0xffff0000) == 0x30900000)) +#endif #define IS_RT3070(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30700000) +#ifdef RT30xx +#define IS_RT3071(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30710000) +#define IS_RT2070(_pAd) (((_pAd)->RfIcType == RFIC_2020) || ((_pAd)->EFuseTag == 0x27)) + +#define IS_RT30xx(_pAd) (((_pAd)->MACVersion & 0xfff00000) == 0x30700000) +#endif #define RING_PACKET_INIT(_TxRing, _idx) \ { \ @@ -374,6 +490,7 @@ typedef struct _QUEUE_HEADER { // #define MAX_BUSY_COUNT 100 // Number of retry before failing access BBP & RF indirect register // +#ifdef RT2860 #define RTMP_RF_IO_WRITE32(_A, _V) \ { \ PHY_CSR4_STRUC Value; \ @@ -537,7 +654,20 @@ typedef struct _QUEUE_HEADER { } \ } \ } +#endif /* RT2860 */ +#ifdef RT2870 +#define RTMP_RF_IO_WRITE32(_A, _V) RTUSBWriteRFRegister(_A, _V) +#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 // RT2870 // +#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 // #define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \ switch (ch) \ @@ -788,6 +918,7 @@ typedef struct _RTMP_SCATTER_GATHER_LIST { // Enqueue this frame to MLME engine // We need to enqueue the whole frame because MLME need to pass data type // information from 802.11 header +#ifdef RT2860 #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \ { \ UINT32 High32TSF, Low32TSF; \ @@ -795,6 +926,49 @@ typedef struct _RTMP_SCATTER_GATHER_LIST { RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \ MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \ } +#endif +#ifdef RT2870 +#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \ +{ \ + UINT32 High32TSF=0, Low32TSF=0; \ + MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \ +} +#endif // RT2870 // + +#ifdef RT30xx +//Need to collect each ant's rssi concurrently +//rssi1 is report to pair2 Ant and rss2 is reprot to pair1 Ant when 4 Ant +#define COLLECT_RX_ANTENNA_AVERAGE_RSSI(_pAd, _rssi1, _rssi2) \ +{ \ + SHORT AvgRssi; \ + UCHAR UsedAnt; \ + if (_pAd->RxAnt.EvaluatePeriod == 0) \ + { \ + UsedAnt = _pAd->RxAnt.Pair1PrimaryRxAnt; \ + AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \ + if (AvgRssi < 0) \ + AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \ + else \ + AvgRssi = _rssi1 << 3; \ + _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \ + } \ + else \ + { \ + UsedAnt = _pAd->RxAnt.Pair1SecondaryRxAnt; \ + AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \ + if ((AvgRssi < 0) && (_pAd->RxAnt.FirstPktArrivedWhenEvaluate)) \ + AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \ + else \ + { \ + _pAd->RxAnt.FirstPktArrivedWhenEvaluate = TRUE; \ + AvgRssi = _rssi1 << 3; \ + } \ + _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \ + _pAd->RxAnt.RcvPktNumWhenEvaluate++; \ + } \ +} +#endif // RT30xx // + #define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \ NdisQueryBuffer(_NdisBuf, _ppVA, _pBufLen) @@ -807,6 +981,7 @@ typedef struct _RTMP_SCATTER_GATHER_LIST { // #define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64)) +#ifdef RT2860 #define STA_PORT_SECURED(_pAd) \ { \ _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \ @@ -815,6 +990,16 @@ typedef struct _RTMP_SCATTER_GATHER_LIST { _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \ NdisReleaseSpinLock(&(_pAd)->MacTabLock); \ } +#endif +#ifdef RT2870 +#define STA_PORT_SECURED(_pAd) \ +{ \ + _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \ + NdisAcquireSpinLock(&_pAd->MacTabLock); \ + _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \ + NdisReleaseSpinLock(&_pAd->MacTabLock); \ +} +#endif // // Register set pair for initialzation register set definition @@ -883,7 +1068,12 @@ typedef struct _RTMP_REORDERBUF UCHAR DataOffset; USHORT Datasize; ULONG AllocSize; +#ifdef RT2860 NDIS_PHYSICAL_ADDRESS AllocPa; // TxBuf physical address +#endif +#ifdef RT2870 + PUCHAR AllocPa; +#endif // RT2870 // } RTMP_REORDERBUF, *PRTMP_REORDERBUF; // @@ -982,7 +1172,9 @@ typedef struct _COUNTER_802_11 { typedef struct _COUNTER_RALINK { ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput +#ifdef RT2860 ULONG LastReceivedByteCount; +#endif ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput ULONG BeenDisassociatedCount; ULONG BadCQIAutoRecoveryCount; @@ -1005,6 +1197,9 @@ typedef struct _COUNTER_RALINK { UINT32 OneSecFrameDuplicateCount; +#ifdef RT2870 + ULONG OneSecTransmittedByteCount; // both successful and failure, used to calculate TX throughput +#endif // RT2870 // UINT32 OneSecTxNoRetryOkCount; UINT32 OneSecTxRetryOkCount; @@ -1117,6 +1312,9 @@ typedef struct _BBP_TUNING_STRUCT { typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT { UCHAR EvaluatePeriod; // 0:not evalute status, 1: evaluate status, 2: switching status +#ifdef RT30xx + UCHAR EvaluateStableCnt; +#endif UCHAR Pair1PrimaryRxAnt; // 0:Ant-E1, 1:Ant-E2 UCHAR Pair1SecondaryRxAnt; // 0:Ant-E1, 1:Ant-E2 UCHAR Pair2PrimaryRxAnt; // 0:Ant-E3, 1:Ant-E4 @@ -1292,9 +1490,11 @@ typedef struct _MLME_STRUCT { RALINK_TIMER_STRUCT APSDPeriodicTimer; RALINK_TIMER_STRUCT LinkDownTimer; RALINK_TIMER_STRUCT LinkUpTimer; +#ifdef RT2860 UCHAR bPsPollTimerRunning; RALINK_TIMER_STRUCT PsPollTimer; RALINK_TIMER_STRUCT RadioOnOffTimer; +#endif ULONG PeriodicRound; ULONG OneSecPeriodicRound; @@ -1303,7 +1503,10 @@ typedef struct _MLME_STRUCT { BOOLEAN bEnableAutoAntennaCheck; RALINK_TIMER_STRUCT RxAntEvalTimer; - +#ifdef RT2870 + UCHAR CaliBW40RfR24; + UCHAR CaliBW20RfR24; +#endif // RT2870 // } MLME_STRUCT, *PMLME_STRUCT; // structure for radar detection and channel switch @@ -1502,6 +1705,19 @@ typedef struct { UCHAR bit_offset = wcid & 0x7; \ ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; } +#ifdef RT2870 +#define BEACON_BITMAP_MASK 0xff +typedef struct _BEACON_SYNC_STRUCT_ +{ + UCHAR BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET]; + UCHAR BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE]; + ULONG TimIELocationInBeacon[HW_BEACON_MAX_COUNT]; + ULONG CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT]; + BOOLEAN EnableBeacon; // trigger to enable beacon transmission. + UCHAR BeaconBitMap; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change. + UCHAR DtimBitOn; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change. +}BEACON_SYNC_STRUCT; +#endif // RT2870 // typedef struct _MULTISSID_STRUCT { UCHAR Bssid[MAC_ADDR_LEN]; @@ -1700,6 +1916,9 @@ typedef struct _COMMON_CONFIG { BOOLEAN NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff. ABGBAND_STATE BandState; // For setting BBP used on B/G or A mode. +#ifdef RT30xx + BOOLEAN bRxAntDiversity; // 0:disable, 1:enable Software Rx Antenna Diversity. +#endif // IEEE802.11H--DFS. RADAR_DETECT_STRUCT RadarDetect; @@ -1741,6 +1960,20 @@ typedef struct _COMMON_CONFIG { BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled +#ifdef RT2870 + BOOLEAN bMultipleIRP; // Multiple Bulk IN flag + UCHAR NumOfBulkInIRP; // if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1 + RT_HT_CAPABILITY SupportedHtPhy; + ULONG MaxPktOneTxBulk; + UCHAR TxBulkFactor; + UCHAR RxBulkFactor; + + BEACON_SYNC_STRUCT *pBeaconSync; + RALINK_TIMER_STRUCT BeaconUpdateTimer; + UINT32 BeaconAdjust; + UINT32 BeaconFactor; + UINT32 BeaconRemain; +#endif // RT2870 // NDIS_SPIN_LOCK MeasureReqTabLock; @@ -1842,11 +2075,11 @@ typedef struct _STA_ADMIN_CONFIG { BOOLEAN bRadio; // Radio state, And of Sw & Hw radio state BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled BOOLEAN bShowHiddenSSID; // Show all known SSID in SSID list get operation - +#ifdef RT2860 BOOLEAN AdhocBOnlyJoined; // Indicate Adhoc B Join. BOOLEAN AdhocBGJoined; // Indicate Adhoc B/G Join. BOOLEAN Adhoc20NJoined; // Indicate Adhoc 20MHz N Join. - +#endif // New for WPA, windows want us to to keep association information and // Fixed IEs from last association response NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo; @@ -1960,7 +2193,9 @@ typedef struct _STA_ADMIN_CONFIG { RT_HT_PHY_INFO DesiredHtPhyInfo; BOOLEAN bAutoTxRateSwitch; +#ifdef RT2860 UCHAR BBPR3; +#endif } STA_ADMIN_CONFIG, *PSTA_ADMIN_CONFIG; // This data structure keep the current active BSS/IBSS's configuration that this STA @@ -1987,6 +2222,15 @@ typedef struct _STA_ACTIVE_CONFIG { RT_HT_CAPABILITY SupportedHtPhy; } STA_ACTIVE_CONFIG, *PSTA_ACTIVE_CONFIG; +#ifdef RT2870 +// for USB interface, avoid in interrupt when write key +typedef struct RT_ADD_PAIRWISE_KEY_ENTRY { + NDIS_802_11_MAC_ADDRESS MacAddr; + USHORT MacTabMatchWCID; // ASIC + CIPHER_KEY CipherKey; +} RT_ADD_PAIRWISE_KEY_ENTRY,*PRT_ADD_PAIRWISE_KEY_ENTRY; +#endif // RT2870 // + // ----------- start of AP -------------------------- // AUTH-RSP State Machine Aux data structure typedef struct _AP_MLME_AUX { @@ -2124,6 +2368,9 @@ typedef struct _MAC_TABLE_ENTRY { UINT32 TXMCSSuccessful[16]; UINT32 TXMCSFailed[16]; UINT32 TXMCSAutoFallBack[16][16]; +#ifdef RT2870 + ULONG LastBeaconRxTime; +#endif } MAC_TABLE_ENTRY, *PMAC_TABLE_ENTRY; typedef struct _MAC_TABLE { @@ -2135,6 +2382,9 @@ typedef struct _MAC_TABLE { BOOLEAN fAnyStationInPsm; BOOLEAN fAnyStationBadAtheros; // Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip. BOOLEAN fAnyTxOPForceDisable; // Check if it is necessary to disable BE TxOP +#ifdef RT2870 + BOOLEAN fAllStationAsRalink; // Check if all stations are ralink-chipset +#endif BOOLEAN fAnyStationIsLegacy; // Check if I use legacy rate to transmit to my BSS Station/ BOOLEAN fAnyStationNonGF; // Check if any Station can't support GF. BOOLEAN fAnyStation20Only; // Check if any Station can't support GF. @@ -2330,6 +2580,7 @@ typedef struct _RTMP_ADAPTER PNET_DEV net_dev; ULONG VirtualIfCnt; +#ifdef RT2860 USHORT LnkCtrlBitMask; USHORT RLnkCtrlConfiguration; USHORT RLnkCtrlOffset; @@ -2356,11 +2607,51 @@ typedef struct _RTMP_ADAPTER RTMP_DMABUF RxDescRing; // Shared memory for RX descriptors RTMP_DMABUF TxDescRing[NUM_OF_TX_RING]; // Shared memory for Tx descriptors RTMP_TX_RING TxRing[NUM_OF_TX_RING]; // AC0~4 + HCCA - +#endif NDIS_SPIN_LOCK irq_lock; UCHAR irq_disabled; +#ifdef RT2870 +/*****************************************************************************************/ +/* USB related parameters */ +/*****************************************************************************************/ + struct usb_config_descriptor *config; + UINT BulkInEpAddr; // bulk-in endpoint address + UINT BulkOutEpAddr[6]; // bulk-out endpoint address + + UINT NumberOfPipes; + USHORT BulkOutMaxPacketSize; + USHORT BulkInMaxPacketSize; + + //======Control Flags + LONG PendingIoCount; + ULONG BulkFlags; + BOOLEAN bUsbTxBulkAggre; // Flags for bulk out data priority + + + //======Timer Thread + RT2870_TIMER_QUEUE TimerQ; + NDIS_SPIN_LOCK TimerQLock; + + + //======Cmd Thread + CmdQ CmdQ; + NDIS_SPIN_LOCK CmdQLock; // CmdQLock spinlock + + BOOLEAN TimerFunc_kill; + BOOLEAN mlme_kill; + + + //======Semaphores (event) + struct semaphore mlme_semaphore; /* to sleep thread on */ + struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */ + struct semaphore RTUSBTimer_semaphore; + struct completion TimerQComplete; + struct completion mlmeComplete; + struct completion CmdQComplete; + wait_queue_head_t *wait; +#endif // RT2870 // /*****************************************************************************************/ @@ -2374,6 +2665,22 @@ typedef struct _RTMP_ADAPTER BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; // for ensuring RTUSBDeQueuePacket get call once NDIS_SPIN_LOCK DeQueueLock[NUM_OF_TX_RING]; +#ifdef RT2870 + // Data related context and AC specified, 4 AC supported + NDIS_SPIN_LOCK BulkOutLock[6]; // BulkOut spinlock for 4 ACs + NDIS_SPIN_LOCK MLMEBulkOutLock; // MLME BulkOut lock + + HT_TX_CONTEXT TxContext[NUM_OF_TX_RING]; + NDIS_SPIN_LOCK TxContextQueueLock[NUM_OF_TX_RING]; // TxContextQueue spinlock + + // 4 sets of Bulk Out index and pending flag + UCHAR NextBulkOutIndex[4]; // only used for 4 EDCA bulkout pipe + + BOOLEAN BulkOutPending[6]; // used for total 6 bulkout pipe + UCHAR bulkResetPipeid; + BOOLEAN MgmtBulkPending; + ULONG bulkResetReq[6]; +#endif // RT2870 // // resource for software backlog queues QUEUE_HEADER TxSwQueue[NUM_OF_TX_RING]; // 4 AC + 1 HCCA @@ -2387,10 +2694,20 @@ typedef struct _RTMP_ADAPTER /*****************************************************************************************/ /* Rx related parameters */ /*****************************************************************************************/ - +#ifdef RT2860 RTMP_RX_RING RxRing; NDIS_SPIN_LOCK RxRingLock; // Rx Ring spinlock - +#endif +#ifdef RT2870 + RX_CONTEXT RxContext[RX_RING_SIZE]; // 1 for redundant multiple IRP bulk in. + NDIS_SPIN_LOCK BulkInLock; // BulkIn spinlock for 4 ACs + UCHAR PendingRx; // The Maxima pending Rx value should be RX_RING_SIZE. + UCHAR NextRxBulkInIndex; // Indicate the current RxContext Index which hold by Host controller. + UCHAR NextRxBulkInReadIndex; // Indicate the current RxContext Index which driver can read & process it. + ULONG NextRxBulkInPosition; // Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength. + ULONG TransferBufferLength; // current length of the packet buffer + ULONG ReadPosition; // current read position in a packet buffer +#endif // RT2870 // /*****************************************************************************************/ @@ -2404,6 +2721,10 @@ typedef struct _RTMP_ADAPTER ULONG EepromVersion; // byte 0: version, byte 1: revision, byte 2~3: unused UCHAR EEPROMAddressNum; // 93c46=6 93c66=8 USHORT EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS]; +#ifdef RT30xx + BOOLEAN EepromAccess; + UCHAR EFuseTag; +#endif ULONG FirmwareVersion; // byte 0: Minor version, byte 1: Major version, otherwise unused. // --------------------------- @@ -2496,6 +2817,15 @@ typedef struct _RTMP_ADAPTER PSPOLL_FRAME PsPollFrame; HEADER_802_11 NullFrame; +#ifdef RT2870 + TX_CONTEXT BeaconContext[BEACON_RING_SIZE]; + TX_CONTEXT NullContext; + TX_CONTEXT PsPollContext; + TX_CONTEXT RTSContext; +#endif // RT2870 // + + + //=========AP=========== @@ -2556,7 +2886,9 @@ typedef struct _RTMP_ADAPTER // flags, see fRTMP_ADAPTER_xxx flags ULONG Flags; // Represent current device status +#ifdef RT2860 ULONG PSFlags; // Power Save operation flag. +#endif // current TX sequence # USHORT Sequence; @@ -2589,6 +2921,14 @@ typedef struct _RTMP_ADAPTER /*****************************************************************************************/ /* Statistic related parameters */ /*****************************************************************************************/ +#ifdef RT2870 + ULONG BulkOutDataOneSecCount; + ULONG BulkInDataOneSecCount; + ULONG BulkLastOneSecCount; // BulkOutDataOneSecCount + BulkInDataOneSecCount + ULONG watchDogRxCnt; + ULONG watchDogRxOverFlowCnt; + ULONG watchDogTxPendingCnt[NUM_OF_TX_RING]; +#endif // RT2870 // BOOLEAN bUpdateBcnCntDone; ULONG watchDogMacDeadlock; // prevent MAC/BBP into deadlock condition @@ -2663,6 +3003,13 @@ typedef struct _RTMP_ADAPTER UINT8 PM_FlgSuspend; + +#ifdef RT30xx +//======efuse + BOOLEAN bUseEfuse; + BOOLEAN bEEPROMFile; +#endif // RT30xx // + } RTMP_ADAPTER, *PRTMP_ADAPTER; // @@ -2815,7 +3162,7 @@ typedef struct _TX_BLK_ //------------------------------------------------------------------------------------------ - +#ifdef RT2860 // // Enable & Disable NIC interrupt via writing interrupt mask register // Since it use ADAPTER structure, it have to be put after structure definition. @@ -2886,6 +3233,7 @@ static inline VOID ConvertMulticastIP2MAC( return; } +#endif /* RT2860 */ BOOLEAN RTMPCheckForHang( IN NDIS_HANDLE MiniportAdapterContext @@ -2925,6 +3273,10 @@ NDIS_STATUS NICReadRegParameters( IN NDIS_HANDLE WrapperConfigurationContext ); +#ifdef RT2870 +VOID NICInitRT30xxRFRegisters( + IN PRTMP_ADAPTER pAd); +#endif // RT2870 // VOID NICReadEEPROMParameters( IN PRTMP_ADAPTER pAd, @@ -2943,10 +3295,10 @@ NDIS_STATUS NICInitializeAdapter( NDIS_STATUS NICInitializeAsic( IN PRTMP_ADAPTER pAd, IN BOOLEAN bHardReset); - +#ifdef RT2860 VOID NICRestoreBBPValue( IN PRTMP_ADAPTER pAd); - +#endif VOID NICIssueReset( IN PRTMP_ADAPTER pAd); @@ -3345,7 +3697,13 @@ NDIS_STATUS MiniportMMRequest( IN UCHAR QueIdx, IN PUCHAR pData, IN UINT Length); - +#ifdef RT2870 +NDIS_STATUS MiniportDataMMRequest( + IN PRTMP_ADAPTER pAd, + IN UCHAR QueIdx, + IN PUCHAR pData, + IN UINT Length); +#endif VOID RTMPSendNullFrame( IN PRTMP_ADAPTER pAd, IN UCHAR TxRate, @@ -3535,7 +3893,12 @@ VOID AsicForceSleep( VOID AsicForceWakeup( IN PRTMP_ADAPTER pAd, +#ifdef RT2860 IN UCHAR Level); +#endif +#ifdef RT2870 + IN BOOLEAN bFromTx); +#endif VOID AsicSetBssid( IN PRTMP_ADAPTER pAd, @@ -3629,11 +3992,11 @@ BOOLEAN AsicSendCommandToMcu( IN UCHAR Token, IN UCHAR Arg0, IN UCHAR Arg1); - +#ifdef RT2860 BOOLEAN AsicCheckCommanOk( IN PRTMP_ADAPTER pAd, IN UCHAR Command); - +#endif VOID MacAddrRandomBssid( IN PRTMP_ADAPTER pAd, OUT PUCHAR pAddr); @@ -3939,6 +4302,12 @@ VOID InvalidStateWhenDisassociate( IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM *Elem); +#ifdef RT2870 +VOID MlmeCntlConfirm( + IN PRTMP_ADAPTER pAd, + IN ULONG MsgType, + IN USHORT Msg); +#endif // RT2870 // VOID ComposePsPoll( IN PRTMP_ADAPTER pAd); @@ -4541,6 +4910,12 @@ CHAR RTMPMaxRssi( IN CHAR Rssi1, IN CHAR Rssi2); +#ifdef RT30xx +VOID AsicSetRxAnt( + IN PRTMP_ADAPTER pAd, + IN UCHAR Ant); +#endif + VOID AsicEvaluateRxAnt( IN PRTMP_ADAPTER pAd); @@ -5214,6 +5589,10 @@ VOID RTMPSendTriggerFrame( IN UCHAR TxRate, IN BOOLEAN bQosNull); +#ifdef RT30xx +VOID RTMPFilterCalibration( + IN PRTMP_ADAPTER pAd); +#endif // RT30xx // /* timeout -- ms */ VOID RTMP_SetPeriodicTimer( @@ -6053,6 +6432,7 @@ void kill_thread_task(PRTMP_ADAPTER pAd); void tbtt_tasklet(unsigned long data); +#ifdef RT2860 // // Function Prototype in cmm_data_2860.c // @@ -6165,6 +6545,7 @@ VOID RT28xxPciMlmeRadioOn( VOID RT28xxPciMlmeRadioOFF( IN PRTMP_ADAPTER pAd); +#endif /* RT2860 */ VOID AsicTurnOffRFClk( IN PRTMP_ADAPTER pAd, @@ -6174,6 +6555,493 @@ VOID AsicTurnOnRFClk( IN PRTMP_ADAPTER pAd, IN UCHAR Channel); +#ifdef RT30xx +NTSTATUS RT30xxWriteRFRegister( + IN PRTMP_ADAPTER pAd, + IN UCHAR RegID, + IN UCHAR Value); + +NTSTATUS RT30xxReadRFRegister( + IN PRTMP_ADAPTER pAd, + IN UCHAR RegID, + IN PUCHAR pValue); + +//2008/09/11:KH add to support efuse<-- +UCHAR eFuseReadRegisters( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN USHORT Length, + OUT USHORT* pData); + +VOID eFuseReadPhysical( + IN PRTMP_ADAPTER pAd, + IN PUSHORT lpInBuffer, + IN ULONG nInBufferSize, + OUT PUSHORT lpOutBuffer, + IN ULONG nOutBufferSize +); + +NTSTATUS eFuseRead( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + OUT PUCHAR pData, + IN USHORT Length); + +VOID eFusePhysicalWriteRegisters( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN USHORT Length, + OUT USHORT* pData); + +NTSTATUS eFuseWriteRegisters( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN USHORT Length, + IN USHORT* pData); + +VOID eFuseWritePhysical( + IN PRTMP_ADAPTER pAd, + PUSHORT lpInBuffer, + ULONG nInBufferSize, + PUCHAR lpOutBuffer, + ULONG nOutBufferSize +); + +NTSTATUS eFuseWrite( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN PUCHAR pData, + IN USHORT length); + +INT set_eFuseGetFreeBlockCount_Proc( + IN PRTMP_ADAPTER pAd, + IN PUCHAR arg); + +INT set_eFusedump_Proc( + IN PRTMP_ADAPTER pAd, + IN PUCHAR arg); + +INT set_eFuseLoadFromBin_Proc( + IN PRTMP_ADAPTER pAd, + IN PUCHAR arg); + +NTSTATUS eFuseWriteRegistersFromBin( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN USHORT Length, + IN USHORT* pData); + +VOID eFusePhysicalReadRegisters( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN USHORT Length, + OUT USHORT* pData); + +NDIS_STATUS NICLoadEEPROM( + IN PRTMP_ADAPTER pAd); + +BOOLEAN bNeedLoadEEPROM( + IN PRTMP_ADAPTER pAd); +//2008/09/11:KH add to support efuse--> +#endif // RT30xx // + +#ifdef RT30xx +// add by johnli, RF power sequence setup +VOID RT30xxLoadRFNormalModeSetup( + IN PRTMP_ADAPTER pAd); + +VOID RT30xxLoadRFSleepModeSetup( + IN PRTMP_ADAPTER pAd); + +VOID RT30xxReverseRFSleepModeSetup( + IN PRTMP_ADAPTER pAd); +// end johnli +#endif // RT30xx // + +#ifdef RT2870 +// +// Function Prototype in rtusb_bulk.c +// +VOID RTUSBInitTxDesc( + IN PRTMP_ADAPTER pAd, + IN PTX_CONTEXT pTxContext, + IN UCHAR BulkOutPipeId, + IN usb_complete_t Func); + +VOID RTUSBInitHTTxDesc( + IN PRTMP_ADAPTER pAd, + IN PHT_TX_CONTEXT pTxContext, + IN UCHAR BulkOutPipeId, + IN ULONG BulkOutSize, + IN usb_complete_t Func); + +VOID RTUSBInitRxDesc( + IN PRTMP_ADAPTER pAd, + IN PRX_CONTEXT pRxContext); + +VOID RTUSBCleanUpDataBulkOutQueue( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBCancelPendingBulkOutIRP( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBBulkOutDataPacket( + IN PRTMP_ADAPTER pAd, + IN UCHAR BulkOutPipeId, + IN UCHAR Index); + +VOID RTUSBBulkOutNullFrame( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBBulkOutRTSFrame( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBCancelPendingBulkInIRP( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBCancelPendingIRPs( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBBulkOutMLMEPacket( + IN PRTMP_ADAPTER pAd, + IN UCHAR Index); + +VOID RTUSBBulkOutPsPoll( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBCleanUpMLMEBulkOutQueue( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBKickBulkOut( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBBulkReceive( + IN PRTMP_ADAPTER pAd); + +VOID DoBulkIn( + IN RTMP_ADAPTER *pAd); + +VOID RTUSBInitRxDesc( + IN PRTMP_ADAPTER pAd, + IN PRX_CONTEXT pRxContext); + +VOID RTUSBBulkRxHandle( + IN unsigned long data); + +// +// Function Prototype in rtusb_io.c +// +NTSTATUS RTUSBMultiRead( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + OUT PUCHAR pData, + IN USHORT length); + +NTSTATUS RTUSBMultiWrite( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN PUCHAR pData, + IN USHORT length); + +NTSTATUS RTUSBMultiWrite_OneByte( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN PUCHAR pData); + +NTSTATUS RTUSBReadBBPRegister( + IN PRTMP_ADAPTER pAd, + IN UCHAR Id, + IN PUCHAR pValue); + +NTSTATUS RTUSBWriteBBPRegister( + IN PRTMP_ADAPTER pAd, + IN UCHAR Id, + IN UCHAR Value); + +NTSTATUS RTUSBWriteRFRegister( + IN PRTMP_ADAPTER pAd, + IN UINT32 Value); + +#ifndef RT30xx +NTSTATUS RT30xxWriteRFRegister( + IN PRTMP_ADAPTER pAd, + IN UCHAR RegID, + IN UCHAR Value); + +NTSTATUS RT30xxReadRFRegister( + IN PRTMP_ADAPTER pAd, + IN UCHAR RegID, + IN PUCHAR pValue); +#endif + +NTSTATUS RTUSB_VendorRequest( + IN PRTMP_ADAPTER pAd, + IN UINT32 TransferFlags, + IN UCHAR ReservedBits, + IN UCHAR Request, + IN USHORT Value, + IN USHORT Index, + IN PVOID TransferBuffer, + IN UINT32 TransferBufferLength); + +NTSTATUS RTUSBReadEEPROM( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + OUT PUCHAR pData, + IN USHORT length); + +NTSTATUS RTUSBWriteEEPROM( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN PUCHAR pData, + IN USHORT length); + +VOID RTUSBPutToSleep( + IN PRTMP_ADAPTER pAd); + +NTSTATUS RTUSBWakeUp( + IN PRTMP_ADAPTER pAd); + +VOID RTUSBInitializeCmdQ( + IN PCmdQ cmdq); + +NDIS_STATUS RTUSBEnqueueCmdFromNdis( + IN PRTMP_ADAPTER pAd, + IN NDIS_OID Oid, + IN BOOLEAN SetInformation, + IN PVOID pInformationBuffer, + IN UINT32 InformationBufferLength); + +NDIS_STATUS RTUSBEnqueueInternalCmd( + IN PRTMP_ADAPTER pAd, + IN NDIS_OID Oid, + IN PVOID pInformationBuffer, + IN UINT32 InformationBufferLength); + +VOID RTUSBDequeueCmd( + IN PCmdQ cmdq, + OUT PCmdQElmt *pcmdqelmt); + +INT RTUSBCmdThread( + IN OUT PVOID Context); + +INT TimerQThread( + IN OUT PVOID Context); + +RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert( + IN RTMP_ADAPTER *pAd, + IN RALINK_TIMER_STRUCT *pTimer); + +BOOLEAN RT2870_TimerQ_Remove( + IN RTMP_ADAPTER *pAd, + IN RALINK_TIMER_STRUCT *pTimer); + +void RT2870_TimerQ_Exit( + IN RTMP_ADAPTER *pAd); + +void RT2870_TimerQ_Init( + IN RTMP_ADAPTER *pAd); + +VOID RT2870_BssBeaconExit( + IN RTMP_ADAPTER *pAd); + +VOID RT2870_BssBeaconStop( + IN RTMP_ADAPTER *pAd); + +VOID RT2870_BssBeaconStart( + IN RTMP_ADAPTER * pAd); + +VOID RT2870_BssBeaconInit( + IN RTMP_ADAPTER *pAd); + +VOID RT2870_WatchDog( + IN RTMP_ADAPTER *pAd); + +NTSTATUS RTUSBWriteMACRegister( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + IN UINT32 Value); + +NTSTATUS RTUSBReadMACRegister( + IN PRTMP_ADAPTER pAd, + IN USHORT Offset, + OUT PUINT32 pValue); + +NTSTATUS RTUSBSingleWrite( + IN RTMP_ADAPTER *pAd, + IN USHORT Offset, + IN USHORT Value); + +NTSTATUS RTUSBFirmwareRun( + IN PRTMP_ADAPTER pAd); + +NTSTATUS RTUSBFirmwareWrite( + IN PRTMP_ADAPTER pAd, + IN PUCHAR pFwImage, + IN ULONG FwLen); + +NTSTATUS RTUSBFirmwareOpmode( + IN PRTMP_ADAPTER pAd, + OUT PUINT32 pValue); + +NTSTATUS RTUSBVenderReset( + IN PRTMP_ADAPTER pAd); + +NDIS_STATUS RTUSBSetHardWareRegister( + IN PRTMP_ADAPTER pAdapter, + IN PVOID pBuf); + +NDIS_STATUS RTUSBQueryHardWareRegister( + IN PRTMP_ADAPTER pAdapter, + IN PVOID pBuf); + +VOID CMDHandler( + IN PRTMP_ADAPTER pAd); + + +NDIS_STATUS CreateThreads( + IN struct net_device *net_dev ); + + +VOID MacTableInitialize( + IN PRTMP_ADAPTER pAd); + +VOID MlmeSetPsm( + IN PRTMP_ADAPTER pAd, + IN USHORT psm); + +NDIS_STATUS RTMPWPAAddKeyProc( + IN PRTMP_ADAPTER pAd, + IN PVOID pBuf); + +VOID AsicRxAntEvalAction( + IN PRTMP_ADAPTER pAd); + +void append_pkt( + IN PRTMP_ADAPTER pAd, + IN PUCHAR pHeader802_3, + IN UINT HdrLen, + IN PUCHAR pData, + IN ULONG DataSize, + OUT PNDIS_PACKET *ppPacket); + +UINT deaggregate_AMSDU_announce( + IN PRTMP_ADAPTER pAd, + PNDIS_PACKET pPacket, + IN PUCHAR pData, + IN ULONG DataSize); + +NDIS_STATUS RTMPCheckRxError( + IN PRTMP_ADAPTER pAd, + IN PHEADER_802_11 pHeader, + IN PRXWI_STRUC pRxWI, + IN PRT28XX_RXD_STRUC pRxINFO); + + +VOID RTUSBMlmeHardTransmit( + IN PRTMP_ADAPTER pAd, + IN PMGMT_STRUC pMgmt); + +INT MlmeThread( + IN PVOID Context); + +// +// Function Prototype in rtusb_data.c +// +NDIS_STATUS RTUSBFreeDescriptorRequest( + IN PRTMP_ADAPTER pAd, + IN UCHAR BulkOutPipeId, + IN UINT32 NumberRequired); + + +BOOLEAN RTUSBNeedQueueBackForAgg( + IN RTMP_ADAPTER *pAd, + IN UCHAR BulkOutPipeId); + + +VOID RTMPWriteTxInfo( + IN PRTMP_ADAPTER pAd, + IN PTXINFO_STRUC pTxInfo, + IN USHORT USBDMApktLen, + IN BOOLEAN bWiv, + IN UCHAR QueueSel, + IN UCHAR NextValid, + IN UCHAR TxBurst); + +// +// Function Prototype in cmm_data_2870.c +// +USHORT RtmpUSB_WriteSubTxResource( + IN PRTMP_ADAPTER pAd, + IN TX_BLK *pTxBlk, + IN BOOLEAN bIsLast, + OUT USHORT *FreeNumber); + +USHORT RtmpUSB_WriteSingleTxResource( + IN PRTMP_ADAPTER pAd, + IN TX_BLK *pTxBlk, + IN BOOLEAN bIsLast, + OUT USHORT *FreeNumber); + +USHORT RtmpUSB_WriteFragTxResource( + IN PRTMP_ADAPTER pAd, + IN TX_BLK *pTxBlk, + IN UCHAR fragNum, + OUT USHORT *FreeNumber); + +USHORT RtmpUSB_WriteMultiTxResource( + IN PRTMP_ADAPTER pAd, + IN TX_BLK *pTxBlk, + IN UCHAR frameNum, + OUT USHORT *FreeNumber); + +VOID RtmpUSB_FinalWriteTxResource( + IN PRTMP_ADAPTER pAd, + IN TX_BLK *pTxBlk, + IN USHORT totalMPDUSize, +#ifdef RT2860 + IN USHORT FirstTxIdx); +#endif + IN USHORT TxIdx); + +VOID RtmpUSBDataLastTxIdx( + IN PRTMP_ADAPTER pAd, + IN UCHAR QueIdx, + IN USHORT TxIdx); + +VOID RtmpUSBDataKickOut( + IN PRTMP_ADAPTER pAd, + IN TX_BLK *pTxBlk, + IN UCHAR QueIdx); + + +int RtmpUSBMgmtKickOut( + IN RTMP_ADAPTER *pAd, + IN UCHAR QueIdx, + IN PNDIS_PACKET pPacket, + IN PUCHAR pSrcBufVA, + IN UINT SrcBufLen); + +VOID RtmpUSBNullFrameKickOut( + IN RTMP_ADAPTER *pAd, + IN UCHAR QueIdx, + IN UCHAR *pNullFrame, + IN UINT32 frameLen); + +VOID RT28xxUsbStaAsicForceWakeup( + IN PRTMP_ADAPTER pAd, + IN BOOLEAN bFromTx); + +VOID RT28xxUsbStaAsicSleepThenAutoWakeup( + IN PRTMP_ADAPTER pAd, + IN USHORT TbttNumToNextWakeUp); + +VOID RT28xxUsbMlmeRadioOn( + IN PRTMP_ADAPTER pAd); + +VOID RT28xxUsbMlmeRadioOFF( + IN PRTMP_ADAPTER pAd); +#endif // RT2870 // //////////////////////////////////////// @@ -6203,6 +7071,7 @@ PCHAR RTMPGetRalinkEncryModeStr( VOID AsicStaBbpTuning( IN PRTMP_ADAPTER pAd); +#ifdef RT2860 VOID AsicResetFromDMABusy( IN PRTMP_ADAPTER pAd); @@ -6214,6 +7083,16 @@ VOID AsicResetMAC( VOID AsicResetPBF( IN PRTMP_ADAPTER pAd); +#endif +#ifdef RT2870 +BOOLEAN StaAddMacTableEntry( + IN PRTMP_ADAPTER pAd, + IN PMAC_TABLE_ENTRY pEntry, + IN UCHAR MaxSupportedRateIn500Kbps, + IN HT_CAPABILITY_IE *pHtCapability, + IN UCHAR HtCapabilityLen, + IN USHORT CapabilityInfo); +#endif void RTMP_IndicateMediaState( IN PRTMP_ADAPTER pAd); diff --git a/drivers/staging/rt2860/rtmp_def.h b/drivers/staging/rt2860/rtmp_def.h index 7ba584ce0d8c..5dde860cbbd4 100644 --- a/drivers/staging/rt2860/rtmp_def.h +++ b/drivers/staging/rt2860/rtmp_def.h @@ -102,6 +102,7 @@ // Entry number for each DMA descriptor ring // +#ifdef RT2860 #define TX_RING_SIZE 64 //64 #define MGMT_RING_SIZE 128 #define RX_RING_SIZE 128 //64 @@ -109,6 +110,15 @@ #define MAX_DMA_DONE_PROCESS TX_RING_SIZE #define MAX_TX_DONE_PROCESS TX_RING_SIZE //8 #define LOCAL_TXBUF_SIZE 2 +#endif +#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 @@ -138,7 +148,11 @@ #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 @@ -195,6 +209,7 @@ #define fOP_STATUS_WAKEUP_NOW 0x00008000 #define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE 0x00020000 +#ifdef RT2860 // // RTMP_ADAPTER PSFlags : related to advanced power save. // @@ -207,6 +222,7 @@ // Indicate driver should IMMEDIATELY fo to sleep after receiving AP's beacon in which doesn't indicate unicate nor multicast packets for me //. This flag is used ONLY in RTMPHandleRxDoneInterrupt routine. #define fRTMP_PS_GO_TO_SLEEP_NOW 0x00000008 +#endif #define CCKSETPROTECT 0x1 #define OFDMSETPROTECT 0x2 @@ -309,10 +325,12 @@ #define MAX_APCLI_NUM 0 #define MAX_MBSSID_NUM 1 +#if defined(RT2860) || defined(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) \ @@ -555,6 +573,9 @@ // 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 +#ifdef RT2870 +#define IE_WAPI 68 // WAPI information element +#endif #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 @@ -603,6 +624,11 @@ #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 # // @@ -616,6 +642,9 @@ #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 @@ -1186,6 +1215,10 @@ #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 @@ -1286,6 +1319,8 @@ #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 @@ -1378,6 +1413,7 @@ #define MCAST_HTMIX 3 #endif // MCAST_RATE_SPECIFIC // +#ifdef RT2860 // For AsicRadioOff/AsicRadioOn/AsicForceWakeup function // This is to indicate from where to call this function. #define DOT11POWERSAVE 0 // TO do .11 power save sleep @@ -1385,8 +1421,14 @@ #define RTMP_HALT 2 // Called from Halt handler. #define GUI_IDLE_POWER_SAVE 3 // Call to sleep before link up with AP #define FROM_TX 4 // Force wake up from Tx packet. - - +#endif +#ifdef RT2870 +// For AsicRadioOff/AsicRadioOn function +#define DOT11POWERSAVE 0 +#define GUIRADIO_OFF 1 +#define RTMP_HALT 2 +#define GUI_IDLE_POWER_SAVE 3 +#endif // definition for WpaSupport flag #define WPA_SUPPLICANT_DISABLE 0 diff --git a/drivers/staging/rt2860/sta_ioctl.c b/drivers/staging/rt2860/sta_ioctl.c index 73a83d490b37..eb0109ad2fc0 100644 --- a/drivers/staging/rt2860/sta_ioctl.c +++ b/drivers/staging/rt2860/sta_ioctl.c @@ -87,6 +87,10 @@ struct iw_priv_args privtab[] = { 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" }, { SHOW_CFG_VALUE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" }, +#if !defined(RT2860) && !defined(RT30xx) + { SHOW_ADHOC_ENTRY_INFO, + 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" }, +#endif /* --- sub-ioctls relations --- */ #ifdef DBG @@ -96,6 +100,11 @@ struct iw_priv_args privtab[] = { { RTPRIV_IOCTL_MAC, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024, "mac"}, +#ifdef RT30xx +{ RTPRIV_IOCTL_RF, + IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, + "rf"}, +#endif // RT30xx // { RTPRIV_IOCTL_E2P, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024, "e2p"}, @@ -165,9 +174,11 @@ INT Set_Wpa_Support( IN PUCHAR arg); #ifdef DBG +#if !defined(RT2860) && !defined(RT30xx) VOID RTMPIoctlBBP( IN PRTMP_ADAPTER pAdapter, IN struct iwreq *wrq); +#endif VOID RTMPIoctlMAC( IN PRTMP_ADAPTER pAdapter, @@ -176,6 +187,12 @@ VOID RTMPIoctlMAC( VOID RTMPIoctlE2PROM( IN PRTMP_ADAPTER pAdapter, IN struct iwreq *wrq); + +#ifdef RT30xx +VOID RTMPIoctlRF( + IN PRTMP_ADAPTER pAdapter, + IN struct iwreq *wrq); +#endif // RT30xx // #endif // DBG // @@ -199,6 +216,12 @@ INT Set_ShortRetryLimit_Proc( IN PRTMP_ADAPTER pAdapter, IN PUCHAR arg); +#if !defined(RT2860) && !defined(RT30xx) +INT Show_Adhoc_MacTable_Proc( + IN PRTMP_ADAPTER pAd, + IN PCHAR extra); +#endif + static struct { CHAR *name; INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg); @@ -256,6 +279,13 @@ static struct { {"ForceGF", Set_ForceGF_Proc}, {"LongRetry", Set_LongRetryLimit_Proc}, {"ShortRetry", Set_ShortRetryLimit_Proc}, +//2008/09/11:KH add to support efuse<-- +#ifdef RT30xx + {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc}, + {"efuseDump", set_eFusedump_Proc}, + {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc}, +#endif // RT30xx // +//2008/09/11:KH add to support efuse--> {NULL,} }; @@ -269,6 +299,7 @@ VOID RTMPAddKey( DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n")); +#ifdef RT2860 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)) { @@ -282,6 +313,7 @@ VOID RTMPAddKey( RTMPusecDelay(6000); pAd->bPCIclkOff = FALSE; } +#endif if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) { @@ -474,8 +506,10 @@ VOID RTMPAddKey( } } end: +#ifdef RT2860 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n")); +#endif return; } @@ -497,8 +531,12 @@ rt_ioctl_giwname(struct net_device *dev, char *name, char *extra) { // PRTMP_ADAPTER pAdapter = dev->ml_priv; - +#ifdef RT2860 strncpy(name, "RT2860 Wireless", IFNAMSIZ); +#endif +#ifdef RT2870 + strncpy(name, "RT2870 Wireless", IFNAMSIZ); +#endif // RT2870 // return 0; } @@ -540,7 +578,12 @@ int rt_ioctl_giwfreq(struct net_device *dev, struct iw_freq *freq, char *extra) { VIRTUAL_ADAPTER *pVirtualAd = NULL; +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter; +#endif UCHAR ch; ULONG m; @@ -551,7 +594,9 @@ int rt_ioctl_giwfreq(struct net_device *dev, else { pVirtualAd = dev->ml_priv; +#ifndef RT30xx if (pVirtualAd && pVirtualAd->RtmpDev) +#endif pAdapter = pVirtualAd->RtmpDev->ml_priv; } @@ -611,6 +656,7 @@ int rt_ioctl_giwmode(struct net_device *dev, struct iw_request_info *info, __u32 *mode, char *extra) { +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; @@ -631,6 +677,10 @@ int rt_ioctl_giwmode(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif if (ADHOC_ON(pAdapter)) *mode = IW_MODE_ADHOC; @@ -674,12 +724,18 @@ int rt_ioctl_giwrange(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *extra) { +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif struct iw_range *range = (struct iw_range *) extra; u16 val; int i; +#ifndef RT30xx if (dev->priv_flags == INT_MAIN) { pAdapter = dev->ml_priv; @@ -697,6 +753,7 @@ int rt_ioctl_giwrange(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n")); data->length = sizeof(struct iw_range); @@ -816,6 +873,7 @@ int rt_ioctl_giwap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *ap_addr, char *extra) { +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; @@ -836,6 +894,10 @@ int rt_ioctl_giwap(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter)) { @@ -954,7 +1016,7 @@ int rt_ioctl_siwscan(struct net_device *dev, DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n")); return -EINVAL; } - +#ifdef RT2860 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter)) && (pAdapter->StaCfg.bRadio == TRUE) && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF))) @@ -964,7 +1026,7 @@ int rt_ioctl_siwscan(struct net_device *dev, // Check if still radio off. else if (pAdapter->bPCIclkOff == TRUE) return 0; - +#endif if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) { pAdapter->StaCfg.WpaSupplicantScanCount++; @@ -1082,6 +1144,87 @@ int rt_ioctl_giwscan(struct net_device *dev, previous_ev = current_ev; current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN); +#ifdef RT30xx + if (current_ev == previous_ev) +#if WIRELESS_EXT >= 17 + return -E2BIG; +#else + break; +#endif + + /* + Protocol: + it will show scanned AP's WirelessMode . + it might be + 802.11a + 802.11a/n + 802.11g/n + 802.11b/g/n + 802.11g + 802.11b/g + */ + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = SIOCGIWNAME; + + + { + PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i]; + BOOLEAN isGonly=FALSE; + int rateCnt=0; + + if (pBssEntry->Channel>14) + { + if (pBssEntry->HtCapabilityLen!=0) + strcpy(iwe.u.name,"802.11a/n"); + else + strcpy(iwe.u.name,"802.11a"); + } + else + { + /* + if one of non B mode rate is set supported rate . it mean G only. + */ + for (rateCnt=0;rateCntSupRateLen;rateCnt++) + { + /* + 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only. + */ + if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152) + isGonly=TRUE; + } + + for (rateCnt=0;rateCntExtRateLen;rateCnt++) + { + if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152) + isGonly=TRUE; + } + + + if (pBssEntry->HtCapabilityLen!=0) + { + if (isGonly==TRUE) + strcpy(iwe.u.name,"802.11g/n"); + else + strcpy(iwe.u.name,"802.11b/g/n"); + } + else + { + if (isGonly==TRUE) + strcpy(iwe.u.name,"802.11g"); + else + { + if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0) + strcpy(iwe.u.name,"802.11b"); + else + strcpy(iwe.u.name,"802.11b/g"); + } + } + } + } + + previous_ev = current_ev; + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); +#endif /* RT30xx */ if (current_ev == previous_ev) #if WIRELESS_EXT >= 17 return -E2BIG; @@ -1351,6 +1494,7 @@ int rt_ioctl_giwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *essid) { +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; @@ -1371,6 +1515,10 @@ int rt_ioctl_giwessid(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif data->flags = 1; if (MONITOR_ON(pAdapter)) @@ -1385,6 +1533,14 @@ int rt_ioctl_giwessid(struct net_device *dev, data->length = pAdapter->CommonCfg.SsidLen; memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen); } +#ifdef RT2870 + // Add for RT2870 + else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) + { + data->length = pAdapter->CommonCfg.SsidLen; + memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen); + } +#endif // RT2870 // else {//the ANY ssid was specified data->length = 0; @@ -1422,6 +1578,7 @@ int rt_ioctl_giwnickn(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *nickname) { +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; @@ -1442,6 +1599,10 @@ int rt_ioctl_giwnickn(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif if (data->length > strlen(pAdapter->nickname) + 1) data->length = strlen(pAdapter->nickname) + 1; @@ -1485,6 +1646,7 @@ int rt_ioctl_giwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *rts, char *extra) { +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; @@ -1505,6 +1667,10 @@ int rt_ioctl_giwrts(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) @@ -1551,6 +1717,7 @@ int rt_ioctl_giwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *frag, char *extra) { +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; @@ -1571,6 +1738,10 @@ int rt_ioctl_giwfrag(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) @@ -1611,8 +1782,13 @@ int rt_ioctl_siwencode(struct net_device *dev, pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; goto done; } +#ifndef RT30xx else if ((erq->length == 0) && (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)) +#endif +#ifdef RT30xx + else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN) +#endif { STA_PORT_SECURED(pAdapter); pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled; @@ -1623,7 +1799,9 @@ int rt_ioctl_siwencode(struct net_device *dev, pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared; else pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; +#ifndef RT30xx goto done; +#endif } if (erq->length > 0) @@ -1642,6 +1820,12 @@ int rt_ioctl_siwencode(struct net_device *dev, //Using default key keyIdx = pAdapter->StaCfg.DefaultKeyId; } +#ifdef RT30xx + else + { + pAdapter->StaCfg.DefaultKeyId=keyIdx; + } +#endif NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16); @@ -1693,7 +1877,11 @@ rt_ioctl_giwencode(struct net_device *dev, struct iw_request_info *info, struct iw_point *erq, char *key) { +#ifdef RT30xx + PRTMP_ADAPTER pAdapter = dev->ml_priv; +#endif int kid; +#ifndef RT30xx PRTMP_ADAPTER pAdapter = NULL; VIRTUAL_ADAPTER *pVirtualAd = NULL; @@ -1714,6 +1902,7 @@ rt_ioctl_giwencode(struct net_device *dev, So the net_dev->ml_priv will be NULL in 2rd open */ return -ENETDOWN; } +#endif //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) @@ -2046,6 +2235,14 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info, wrq->length = strlen(extra) + 1; // 1: size of '\0' break; case RAIO_ON: +#ifdef RT2870 + if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) + { + sprintf(extra, "Scanning\n"); + wrq->length = strlen(extra) + 1; // 1: size of '\0' + break; + } +#endif pAd->StaCfg.bSwRadio = TRUE; //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio)) { @@ -2068,6 +2265,12 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info, wrq->length = strlen(extra) + 1; // 1: size of '\0' } break; +#if !defined(RT2860) && !defined(RT30xx) + case SHOW_ADHOC_ENTRY_INFO: + Show_Adhoc_MacTable_Proc(pAd, extra); + wrq->length = strlen(extra) + 1; // 1: size of '\0' + break; +#endif default: DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd)); break; @@ -2311,6 +2514,7 @@ void fnSetCipherKey( IN BOOLEAN bGTK, IN struct iw_encode_ext *ext) { +#ifdef RT2860 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP); if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)) { @@ -2324,7 +2528,7 @@ void fnSetCipherKey( RTMPusecDelay(6000); pAdapter->bPCIclkOff = FALSE; } - +#endif NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY)); pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK; NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK); @@ -2355,8 +2559,9 @@ void fnSetCipherKey( keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, &pAdapter->MacTab.Content[BSSID_WCID]); - +#ifdef RT2860 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP); +#endif } int rt_ioctl_siwencodeext(struct net_device *dev, @@ -2421,7 +2626,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev, NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16); NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len); - +#ifndef RT30xx if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled || pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled) { @@ -2436,6 +2641,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev, // Indicate Connected for GUI pAdapter->IndicateMediaState = NdisMediaStateConnected; } +#endif break; case IW_ENCODE_ALG_TKIP: DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len)); @@ -2747,7 +2953,12 @@ rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info, DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value)); if (sscanf(this_char, "%d", &(bbpId)) == 1) { +#ifndef RT30xx if (bbpId <= 136) +#endif // RT30xx // +#ifdef RT30xx + if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control +#endif // RT30xx // { { RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); @@ -2772,7 +2983,12 @@ rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info, { //Write if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1)) { +#ifndef RT30xx if (bbpId <= 136) +#endif // RT30xx // +#ifdef RT30xx + if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control +#endif // RT30xx // { { RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue); @@ -2804,14 +3020,24 @@ next: { memset(extra, 0x00, IW_PRIV_SIZE_MASK); sprintf(extra, "\n"); +#ifndef RT30xx for (bbpId = 0; bbpId <= 136; bbpId++) +#endif // RT30xx // +#ifdef RT30xx + for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control +#endif // RT30xx // { if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10)) break; RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); +#ifndef RT30xx sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP); if (bbpId%5 == 4) sprintf(extra+strlen(extra), "\n"); +#endif +#ifdef RT30xx + sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format +#endif } wrq->length = strlen(extra) + 1; // 1: size of '\0' @@ -3300,9 +3526,14 @@ INT RTMPSetInformation( { // allow dynamic change of "USE OFDM rate or not" in ADHOC mode // if setting changed, need to reset current TX rate as well as BEACON frame format +#ifdef RT30xx + pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode; +#endif if (pAdapter->StaCfg.BssType == BSS_ADHOC) { +#ifndef RT30xx pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode; +#endif RTMPSetPhyMode(pAdapter, PhyMode); MlmeUpdateTxRates(pAdapter, FALSE, 0); MakeIbssBeacon(pAdapter); // re-build BEACON frame @@ -3466,6 +3697,15 @@ INT RTMPSetInformation( pAdapter->Counters8023.RxNoBuffer = 0; pAdapter->Counters8023.GoodReceives = 0; pAdapter->Counters8023.RxNoBuffer = 0; +#ifdef RT2870 + pAdapter->BulkOutComplete = 0; + pAdapter->BulkOutCompleteOther= 0; + pAdapter->BulkOutCompleteCancel = 0; + pAdapter->BulkOutReq = 0; + pAdapter->BulkInReq= 0; + pAdapter->BulkInComplete = 0; + pAdapter->BulkInCompleteFail = 0; +#endif // RT2870 // DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n")); break; case OID_802_11_RTS_THRESHOLD: @@ -4012,8 +4252,13 @@ INT RTMPSetInformation( pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg; pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx; } - +#ifndef RT30xx +#ifdef RT2860 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) && +#endif +#ifdef RT2870 + if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) && +#endif (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)) { Key = pWepKey->KeyMaterial; @@ -4030,6 +4275,10 @@ INT RTMPSetInformation( pAdapter->IndicateMediaState = NdisMediaStateConnected; } else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) +#endif +#ifdef RT30xx + if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) +#endif { Key = pAdapter->SharedKey[BSS0][KeyIdx].Key; @@ -5054,6 +5303,9 @@ INT rt28xx_sta_ioctl( Status = -EOPNOTSUPP; break; case RT_PRIV_IOCTL: +#ifdef RT30xx + case RT_PRIV_IOCTL_EXT: +#endif subcmd = wrq->u.data.flags; if( subcmd & OID_GET_SET_TOGGLE) Status = RTMPSetInformation(pAd, rq, subcmd); @@ -5085,6 +5337,11 @@ INT rt28xx_sta_ioctl( case RTPRIV_IOCTL_E2P: RTMPIoctlE2PROM(pAd, wrq); break; +#ifdef RT30xx + case RTPRIV_IOCTL_RF: + RTMPIoctlRF(pAd, wrq); + break; +#endif // RT30xx // #endif // DBG // case SIOCETHTOOL: break; @@ -5180,6 +5437,9 @@ INT Set_WmmCapable_Proc( bWmmCapable = simple_strtol(arg, 0, 10); if ((bWmmCapable == 1) +#ifdef RT2870 + && (pAd->NumberOfPipes >= 5) +#endif // RT2870 // ) pAd->CommonCfg.bWmmCapable = TRUE; else if (bWmmCapable == 0) @@ -6012,7 +6272,9 @@ VOID RTMPIoctlMAC( UCHAR temp[16], temp2[16]; UINT32 macValue = 0; INT Status; - +#ifdef RT30xx + BOOLEAN bIsPrintAllMAC = FALSE; +#endif memset(msg, 0x00, 1024); if (wrq->u.data.length > 1) //No parameters. @@ -6063,7 +6325,13 @@ VOID RTMPIoctlMAC( sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue); } else +#ifndef RT30xx {//Invalid parametes, so default printk all bbp +#endif +#ifdef RT30xx + {//Invalid parametes, so default printk all mac + bIsPrintAllMAC = TRUE; +#endif goto next; } } @@ -6147,7 +6415,52 @@ VOID RTMPIoctlMAC( } } } +#ifdef RT30xx + else + bIsPrintAllMAC = TRUE; +#endif next: +#ifdef RT30xx + if (bIsPrintAllMAC) + { + struct file *file_w; + PCHAR fileName = "MacDump.txt"; + mm_segment_t orig_fs; + + orig_fs = get_fs(); + set_fs(KERNEL_DS); + + // open file + file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0); + if (IS_ERR(file_w)) + { + DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName)); + } + else + { + if (file_w->f_op && file_w->f_op->write) + { + file_w->f_pos = 0; + macAddr = 0x1000; + + while (macAddr <= 0x1800) + { + RTMP_IO_READ32(pAdapter, macAddr, &macValue); + sprintf(msg, "%08lx = %08X\n", macAddr, macValue); + + // write data to file + file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos); + + printk("%s", msg); + macAddr += 4; + } + sprintf(msg, "\nDump all MAC values to %s\n", fileName); + } + filp_close(file_w, NULL); + } + set_fs(orig_fs); + } +#endif /* RT30xx */ if(strlen(msg) == 1) sprintf(msg+strlen(msg), "===>Error command format!"); @@ -6188,7 +6501,9 @@ VOID RTMPIoctlE2PROM( UCHAR temp[16], temp2[16]; USHORT eepValue; int Status; - +#ifdef RT30xx + BOOLEAN bIsPrintAllE2P = FALSE; +#endif memset(msg, 0x00, 1024); if (wrq->u.data.length > 1) //No parameters. @@ -6242,6 +6557,9 @@ VOID RTMPIoctlE2PROM( } else {//Invalid parametes, so default printk all bbp +#ifdef RT30xx + bIsPrintAllE2P = TRUE; +#endif goto next; } } @@ -6300,7 +6618,52 @@ VOID RTMPIoctlE2PROM( sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue); } } +#ifdef RT30xx + else + bIsPrintAllE2P = TRUE; +#endif next: +#ifdef RT30xx + if (bIsPrintAllE2P) + { + struct file *file_w; + PCHAR fileName = "EEPROMDump.txt"; + mm_segment_t orig_fs; + + orig_fs = get_fs(); + set_fs(KERNEL_DS); + + // open file + file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0); + if (IS_ERR(file_w)) + { + DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName)); + } + else + { + if (file_w->f_op && file_w->f_op->write) + { + file_w->f_pos = 0; + eepAddr = 0x00; + + while (eepAddr <= 0xFE) + { + RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue); + sprintf(msg, "%08x = %04x\n", eepAddr , eepValue); + + // write data to file + file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos); + + printk("%s", msg); + eepAddr += 2; + } + sprintf(msg, "\nDump all EEPROM values to %s\n", fileName); + } + filp_close(file_w, NULL); + } + set_fs(orig_fs); + } +#endif /* RT30xx */ if(strlen(msg) == 1) sprintf(msg+strlen(msg), "===>Error command format!"); @@ -6311,6 +6674,154 @@ next: DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n")); } +#ifdef RT30xx +/* + ========================================================================== + Description: + Read / Write RF register +Arguments: + pAdapter Pointer to our adapter + wrq Pointer to the ioctl argument + + Return Value: + None + + Note: + Usage: + 1.) iwpriv ra0 rf ==> read all RF registers + 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1 + 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10 + ========================================================================== +*/ +VOID RTMPIoctlRF( + IN PRTMP_ADAPTER pAdapter, + IN struct iwreq *wrq) +{ + CHAR *this_char; + CHAR *value; + UCHAR regRF = 0; + CHAR msg[2048]; + CHAR arg[255]; + INT rfId; + LONG rfValue; + int Status; + BOOLEAN bIsPrintAllRF = FALSE; + + + memset(msg, 0x00, 2048); + if (wrq->u.data.length > 1) //No parameters. + { + Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length); + sprintf(msg, "\n"); + + //Parsing Read or Write + this_char = arg; + if (!*this_char) + goto next; + + if ((value = strchr(this_char, '=')) != NULL) + *value++ = 0; + + if (!value || !*value) + { //Read + if (sscanf(this_char, "%d", &(rfId)) == 1) + { + if (rfId <= 31) + { + // In RT2860 ATE mode, we do not load 8051 firmware. + //We must access RF directly. + // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined. + // according to Andy, Gary, David require. + // the command rf shall read rf register directly for dubug. + // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); + RT30xxReadRFRegister(pAdapter, rfId, ®RF); + + sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF); + } + else + {//Invalid parametes, so default printk all RF + bIsPrintAllRF = TRUE; + goto next; + } + } + else + { //Invalid parametes, so default printk all RF + bIsPrintAllRF = TRUE; + goto next; + } + } + else + { //Write + if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1)) + { + if (rfId <= 31) + { + // In RT2860 ATE mode, we do not load 8051 firmware. + // We should access RF registers directly. + // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined. + { + // according to Andy, Gary, David require. + // the command RF shall read/write RF register directly for dubug. + //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); + //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue); + RT30xxReadRFRegister(pAdapter, rfId, ®RF); + RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue); + //Read it back for showing + //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); + RT30xxReadRFRegister(pAdapter, rfId, ®RF); + sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF); + } + } + else + {//Invalid parametes, so default printk all RF + bIsPrintAllRF = TRUE; + } + } + else + { //Invalid parametes, so default printk all RF + bIsPrintAllRF = TRUE; + } + } + } + else + bIsPrintAllRF = TRUE; +next: + if (bIsPrintAllRF) + { + memset(msg, 0x00, 2048); + sprintf(msg, "\n"); + for (rfId = 0; rfId <= 31; rfId++) + { + // according to Andy, Gary, David require. + // the command RF shall read/write RF register directly for dubug. + RT30xxReadRFRegister(pAdapter, rfId, ®RF); + sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF); + } + // Copy the information into the user buffer + DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg))); + wrq->u.data.length = strlen(msg); + if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length)) + { + DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__)); + } + } + else + { + if(strlen(msg) == 1) + sprintf(msg+strlen(msg), "===>Error command format!"); + + DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg)); + // Copy the information into the user buffer + DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg))); + + // Copy the information into the user buffer + wrq->u.data.length = strlen(msg); + Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length); + } + + DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n")); +} +#endif // RT30xx // #endif // DBG // @@ -6356,3 +6867,48 @@ INT Set_ShortRetryLimit_Proc( DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word)); return TRUE; } + +#if !defined(RT2860) && !defined(RT30xx) +INT Show_Adhoc_MacTable_Proc( + IN PRTMP_ADAPTER pAd, + IN PCHAR extra) +{ + INT i; + + sprintf(extra, "\n"); + + sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode); + + sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n", + "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC"); + + for (i=1; iMacTab.Content[i]; + + if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30)) + break; + if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC)) + { + sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ", + pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2], + pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]); + sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid); + sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx); + sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0); + sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1); + sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2); + sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE)); + sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW)); + sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS); + sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI); + sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC); + sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount, + (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0); + sprintf(extra, "%s\n", extra); + } + } + + return TRUE; +} +#endif /* RT2870 */ diff --git a/drivers/staging/rt2860/wpa.h b/drivers/staging/rt2860/wpa.h index 355309a68632..e6716748adfa 100644 --- a/drivers/staging/rt2860/wpa.h +++ b/drivers/staging/rt2860/wpa.h @@ -90,7 +90,9 @@ #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 -- 2.20.1