📄 rt2870.h
字号:
/* ************************************************************************* * Ralink Tech Inc. * 5F., No.36, Taiyuan St., Jhubei City, * Hsinchu County 302, * Taiwan, R.O.C. * * (c) Copyright 2002-2007, Ralink Technology, Inc. * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * ************************************************************************* */#ifndef __RT2870_H__#define __RT2870_H__//usb header files#include <linux/usb.h>/* rtmp_def.h *///#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)#define BULKAGGRE_ZISE 100#define RT28XX_DRVDATA_SET(_a) usb_set_intfdata(_a, pAd);#define RT28XX_PUT_DEVICE usb_put_dev#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC)#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, GFP_ATOMIC)#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) usb_buffer_alloc(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) usb_buffer_free(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)#else#define BULKAGGRE_ZISE 60#define RT28XX_DRVDATA_SET(_a)#define RT28XX_PUT_DEVICE(dev_p)#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso)#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb)#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) kmalloc(BufSize, GFP_ATOMIC)#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) kfree(pTransferBuf)#endif#define RXBULKAGGRE_ZISE 12#define MAX_TXBULK_LIMIT (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))#define MAX_TXBULK_SIZE (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)#define MAX_RXBULK_SIZE (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)#define MAX_MLME_HANDLER_MEMORY 20#define BUFFER_SIZE 2400 //2048#define TX_RING 0xa#define PRIO_RING 0xc// Flags for Bulkflags control for bulk out data//#define fRTUSB_BULK_OUT_DATA_NULL 0x00000001#define fRTUSB_BULK_OUT_RTS 0x00000002#define fRTUSB_BULK_OUT_MLME 0x00000004#define fRTUSB_BULK_OUT_DATA_NORMAL 0x00010000#define fRTUSB_BULK_OUT_DATA_NORMAL_2 0x00020000#define fRTUSB_BULK_OUT_DATA_NORMAL_3 0x00040000#define fRTUSB_BULK_OUT_DATA_NORMAL_4 0x00080000#define fRTUSB_BULK_OUT_DATA_NORMAL_5 0x00100000#define fRTUSB_BULK_OUT_PSPOLL 0x00000020#define fRTUSB_BULK_OUT_DATA_FRAG 0x00000040#define fRTUSB_BULK_OUT_DATA_FRAG_2 0x00000080#define fRTUSB_BULK_OUT_DATA_FRAG_3 0x00000100#define fRTUSB_BULK_OUT_DATA_FRAG_4 0x00000200#ifdef RALINK_ATE#define fRTUSB_BULK_OUT_DATA_ATE 0x00100000#endif // RALINK_ATE //#define RT2870_USB_DEVICES \{ \ {USB_DEVICE(0x148F,0x2770)}, /* Ralink */ \ {USB_DEVICE(0x148F,0x2870)}, /* Ralink */ \ {USB_DEVICE(0x148F,0x3070)}, /* Ralink 3070 */ \ {USB_DEVICE(0x148F,0x3071)}, /* Ralink 3071 */ \ {USB_DEVICE(0x148F,0x3072)}, /* Ralink 3072 */ \ {USB_DEVICE(0x0B05,0x1731)}, /* Asus */ \ {USB_DEVICE(0x0B05,0x1732)}, /* Asus */ \ {USB_DEVICE(0x0B05,0x1742)}, /* Asus */ \ {USB_DEVICE(0x0DF6,0x0017)}, /* Sitecom */ \ {USB_DEVICE(0x0DF6,0x002B)}, /* Sitecom */ \ {USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */ \ {USB_DEVICE(0x0DF6,0x003E)}, /* Sitecom 3070 */ \ {USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */ \ {USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom 2770 */ \ {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \ {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \ {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \ {USB_DEVICE(0x2019,0xAB25)}, /* Planex Communications, Inc. RT3070 */ \ {USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */ \ {USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */ \ {USB_DEVICE(0x2001,0x3C09)}, /* D-Link */ \ {USB_DEVICE(0x2001,0x3C0A)}, /* D-Link 3072*/ \ {USB_DEVICE(0x14B2,0x3C07)}, /* AL */ \ {USB_DEVICE(0x14B2,0x3C12)}, /* AL 3070 */ \ {USB_DEVICE(0x050D,0x8053)}, /* Belkin */ \ {USB_DEVICE(0x14B2,0x3C23)}, /* Airlink */ \ {USB_DEVICE(0x14B2,0x3C27)}, /* Airlink */ \ {USB_DEVICE(0x07AA,0x002F)}, /* Corega */ \ {USB_DEVICE(0x07AA,0x003C)}, /* Corega */ \ {USB_DEVICE(0x07AA,0x003F)}, /* Corega */ \ {USB_DEVICE(0x18C5,0x0012)}, /* Corega 3070 */ \ {USB_DEVICE(0x1044,0x800B)}, /* Gigabyte */ \ {USB_DEVICE(0x1044,0x800D)}, /* Gigabyte GN-WB32L 3070 */ \ {USB_DEVICE(0x15A9,0x0006)}, /* Sparklan */ \ {USB_DEVICE(0x083A,0xB522)}, /* SMC */ \ {USB_DEVICE(0x083A,0xA618)}, /* SMC */ \ {USB_DEVICE(0x083A,0x8522)}, /* Arcadyan */ \ {USB_DEVICE(0x083A,0x7512)}, /* Arcadyan 2770 */ \ {USB_DEVICE(0x083A,0x7522)}, /* Arcadyan */ \ {USB_DEVICE(0x083A,0x7511)}, /* Arcadyan 3070 */ \ {USB_DEVICE(0x0CDE,0x0022)}, /* ZCOM */ \ {USB_DEVICE(0x0586,0x3416)}, /* Zyxel */ \ {USB_DEVICE(0x0CDE,0x0025)}, /* Zyxel */ \ {USB_DEVICE(0x1740,0x9701)}, /* EnGenius */ \ {USB_DEVICE(0x1740,0x9702)}, /* EnGenius */ \ {USB_DEVICE(0x1740,0x9703)}, /* EnGenius 3070 */ \ {USB_DEVICE(0x0471,0x200f)}, /* Philips */ \ {USB_DEVICE(0x14B2,0x3C25)}, /* Draytek */ \ {USB_DEVICE(0x13D3,0x3247)}, /* AzureWave */ \ {USB_DEVICE(0x13D3,0x3273)}, /* AzureWave 3070*/ \ {USB_DEVICE(0x083A,0x6618)}, /* Accton */ \ {USB_DEVICE(0x15c5,0x0008)}, /* Amit */ \ {USB_DEVICE(0x0E66,0x0001)}, /* Hawking */ \ {USB_DEVICE(0x0E66,0x0003)}, /* Hawking */ \ {USB_DEVICE(0x129B,0x1828)}, /* Siemens */ \ {USB_DEVICE(0x157E,0x300E)}, /* U-Media */ \ {USB_DEVICE(0x050d,0x805c)}, \ {USB_DEVICE(0x1482,0x3C09)}, /* Abocom*/ \ {USB_DEVICE(0x14B2,0x3C09)}, /* Alpha */ \ {USB_DEVICE(0x04E8,0x2018)}, /* samsung */ \ {USB_DEVICE(0x07B8,0x3070)}, /* AboCom 3070 */ \ {USB_DEVICE(0x07B8,0x3071)}, /* AboCom 3071 */ \ {USB_DEVICE(0x07B8,0x3072)}, /* Abocom 3072 */ \ {USB_DEVICE(0x7392,0x7711)}, /* Edimax 3070 */ \ {USB_DEVICE(0x5A57,0x0280)}, /* Zinwell */ \ {USB_DEVICE(0x5A57,0x0282)}, /* Zinwell */ \ {USB_DEVICE(0x1A32,0x0304)}, /* Quanta 3070 */ \ {USB_DEVICE(0x0789,0x0162)}, /* Logitec 2870 */ \ {USB_DEVICE(0x0789,0x0163)}, /* Logitec 2870 */ \ {USB_DEVICE(0x0789,0x0164)}, /* Logitec 2870 */ \ {USB_DEVICE(0x1EDA,0x2310)}, /* AirTies 3070 */ \ { }/* Terminating entry */ \}#define FREE_HTTX_RING(_p, _b, _t) \{ \ if ((_t)->ENextBulkOutPosition == (_t)->CurWritePosition) \ { \ (_t)->bRingEmpty = TRUE; \ } \ /*NdisInterlockedDecrement(&(_p)->TxCount); */\}//// RXINFO appends at the end of each rx packet.//#ifdef RT_BIG_ENDIANtypedef struct PACKED _RXINFO_STRUC { UINT32 PlcpSignal:12; UINT32 LastAMSDU:1; UINT32 CipherAlg:1; UINT32 PlcpRssil:1; UINT32 Decrypted:1; UINT32 AMPDU:1; // To be moved UINT32 L2PAD:1; UINT32 RSSI:1; UINT32 HTC:1; UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header. UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid UINT32 Crc:1; // 1: CRC error UINT32 MyBss:1; // 1: this frame belongs to the same BSSID UINT32 Bcast:1; // 1: this is a broadcast frame UINT32 Mcast:1; // 1: this is a multicast frame UINT32 U2M:1; // 1: this RX frame is unicast to me UINT32 FRAG:1; UINT32 NULLDATA:1; UINT32 DATA:1; UINT32 BA:1;} RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;#elsetypedef struct PACKED _RXINFO_STRUC { UINT32 BA:1; UINT32 DATA:1; UINT32 NULLDATA:1; UINT32 FRAG:1; UINT32 U2M:1; // 1: this RX frame is unicast to me UINT32 Mcast:1; // 1: this is a multicast frame UINT32 Bcast:1; // 1: this is a broadcast frame UINT32 MyBss:1; // 1: this frame belongs to the same BSSID UINT32 Crc:1; // 1: CRC error UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header. UINT32 HTC:1; UINT32 RSSI:1; UINT32 L2PAD:1; UINT32 AMPDU:1; // To be moved UINT32 Decrypted:1; UINT32 PlcpRssil:1; UINT32 CipherAlg:1; UINT32 LastAMSDU:1; UINT32 PlcpSignal:12;} RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;#endif//// TXINFO//#ifdef RT_BIG_ENDIANtypedef struct _TXINFO_STRUC { // Word 0 UINT32 USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint UINT32 USBDMANextVLD:1; //used ONLY in USB bulk Aggregation, NextValid UINT32 rsv2:2; // Software use. UINT32 SwUseLastRound:1; // Software use. UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition UINT32 rsv:8; UINT32 USBDMATxPktLen:16; //used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame.} TXINFO_STRUC, *PTXINFO_STRUC;#elsetypedef struct _TXINFO_STRUC { // Word 0 UINT32 USBDMATxPktLen:16; //used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame. UINT32 rsv:8; UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA UINT32 SwUseLastRound:1; // Software use. UINT32 rsv2:2; // Software use. UINT32 USBDMANextVLD:1; //used ONLY in USB bulk Aggregation, NextValid UINT32 USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint} TXINFO_STRUC, *PTXINFO_STRUC;#endif#define TXINFO_SIZE 4#define RXINFO_SIZE 4#define TXPADDING_SIZE 11//// Management ring buffer format//typedef struct _MGMT_STRUC { BOOLEAN Valid; PUCHAR pBuffer; ULONG Length;} MGMT_STRUC, *PMGMT_STRUC;/* ----------------- EEPROM Related MACRO ----------------- */#ifdef RT30xx#define RT28xx_EEPROM_READ16(pAd, offset, var) \ do { \ RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2); \ if(!pAd->bUseEfuse) \ var = le2cpu16(var); \ }while(0)#define RT28xx_EEPROM_WRITE16(pAd, offset, var) \ do{ \ USHORT _tmpVar=var; \ if(!pAd->bUseEfuse) \ _tmpVar = cpu2le16(var); \ RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2); \ }while(0)#endif // RT30xx //#ifndef RT30xx#define RT28xx_EEPROM_READ16(pAd, offset, var) \ do { \ RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2); \ var = le2cpu16(var); \ }while(0)#define RT28xx_EEPROM_WRITE16(pAd, offset, var) \ do{ \ USHORT _tmpVar=var; \ _tmpVar = cpu2le16(var); \ RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2); \ }while(0)#endif // RT30xx ///* ----------------- TASK/THREAD Related MACRO ----------------- */#define RT28XX_TASK_THREAD_INIT(pAd, Status) \ Status = CreateThreads(net_dev);/* ----------------- Frimware Related MACRO ----------------- */#define RT28XX_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \ RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)/* ----------------- TX Related MACRO ----------------- */#define RT28XX_START_DEQUEUE(pAd, QueIdx, irqFlags) \ { \ RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \ if (pAd->DeQueueRunning[QueIdx]) \ { \ RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\ printk("DeQueueRunning[%d]= TRUE!\n", QueIdx); \ continue; \ } \ else \ { \ pAd->DeQueueRunning[QueIdx] = TRUE; \ RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\ } \ }#define RT28XX_STOP_DEQUEUE(pAd, QueIdx, irqFlags) \ do{ \ RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \ pAd->DeQueueRunning[QueIdx] = FALSE; \ RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \ }while(0) #define RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \ (RTUSBFreeDescriptorRequest(pAd, pTxBlk->QueIdx, (pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))) == NDIS_STATUS_SUCCESS)#define RT28XX_RELEASE_DESC_RESOURCE(pAd, QueIdx) \ do{}while(0)#define NEED_QUEUE_BACK_FOR_AGG(_pAd, _QueIdx, _freeNum, _TxFrameType) \ ((_TxFrameType == TX_RALINK_FRAME) && (RTUSBNeedQueueBackForAgg(_pAd, _QueIdx))) #define fRTMP_ADAPTER_NEED_STOP_TX \ (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \ fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_BULKOUT_RESET | \ fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_REMOVE_IN_PROGRESS)#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \ RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) #define HAL_WriteTxResource(pAd, pTxBlk,bIsLast, pFreeNumber) \ RtmpUSB_WriteSingleTxResource(pAd, pTxBlk,bIsLast, pFreeNumber)#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \ RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) #define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) \ RtmpUSB_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) #define HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx) \ RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)#define HAL_LastTxIdx(pAd, QueIdx,TxIdx) \ /*RtmpUSBDataLastTxIdx(pAd, QueIdx,TxIdx)*/ #define HAL_KickOutTx(pAd, pTxBlk, QueIdx) \ RtmpUSBDataKickOut(pAd, pTxBlk, QueIdx)#define HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen) \ RtmpUSBMgmtKickOut(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen) \ RtmpUSBNullFrameKickOut(_pAd, _QueIdx, _pNullFrame, _frameLen) #define RTMP_PKT_TAIL_PADDING 11 // 3(max 4 byte padding) + 4 (last packet padding) + 4 (MaxBulkOutsize align padding)extern UCHAR EpToQueue[6];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -