desc.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*
  2. * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * File: desc.h
  20. *
  21. * Purpose:The header file of descriptor
  22. *
  23. * Revision History:
  24. *
  25. * Author: Tevin Chen
  26. *
  27. * Date: May 21, 1996
  28. *
  29. */
  30. #ifndef __DESC_H__
  31. #define __DESC_H__
  32. #include <linux/types.h>
  33. #include <linux/mm.h>
  34. #include "linux/ieee80211.h"
  35. #include "ttype.h"
  36. #include "tether.h"
  37. #define B_OWNED_BY_CHIP 1
  38. #define B_OWNED_BY_HOST 0
  39. //
  40. // Bits in the RSR register
  41. //
  42. #define RSR_ADDRBROAD 0x80
  43. #define RSR_ADDRMULTI 0x40
  44. #define RSR_ADDRUNI 0x00
  45. #define RSR_IVLDTYP 0x20
  46. #define RSR_IVLDLEN 0x10 // invalid len (> 2312 byte)
  47. #define RSR_BSSIDOK 0x08
  48. #define RSR_CRCOK 0x04
  49. #define RSR_BCNSSIDOK 0x02
  50. #define RSR_ADDROK 0x01
  51. //
  52. // Bits in the new RSR register
  53. //
  54. #define NEWRSR_DECRYPTOK 0x10
  55. #define NEWRSR_CFPIND 0x08
  56. #define NEWRSR_HWUTSF 0x04
  57. #define NEWRSR_BCNHITAID 0x02
  58. #define NEWRSR_BCNHITAID0 0x01
  59. //
  60. // Bits in the TSR0 register
  61. //
  62. #define TSR0_PWRSTS1_2 0xC0
  63. #define TSR0_PWRSTS7 0x20
  64. #define TSR0_NCR 0x1F
  65. //
  66. // Bits in the TSR1 register
  67. //
  68. #define TSR1_TERR 0x80
  69. #define TSR1_PWRSTS4_6 0x70
  70. #define TSR1_RETRYTMO 0x08
  71. #define TSR1_TMO 0x04
  72. #define TSR1_PWRSTS3 0x02
  73. #define ACK_DATA 0x01
  74. //
  75. // Bits in the TCR register
  76. //
  77. #define EDMSDU 0x04 // end of sdu
  78. #define TCR_EDP 0x02 // end of packet
  79. #define TCR_STP 0x01 // start of packet
  80. // max transmit or receive buffer size
  81. #define CB_MAX_BUF_SIZE 2900U
  82. // NOTE: must be multiple of 4
  83. #define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE
  84. #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE
  85. #define CB_BEACON_BUF_SIZE 512U
  86. #define CB_MAX_RX_DESC 128
  87. #define CB_MIN_RX_DESC 16
  88. #define CB_MAX_TX_DESC 64
  89. #define CB_MIN_TX_DESC 16
  90. #define CB_MAX_RECEIVED_PACKETS 16
  91. // limit our receive routine to indicating
  92. // this many at a time for 2 reasons:
  93. // 1. driver flow control to protocol layer
  94. // 2. limit the time used in ISR routine
  95. #define CB_EXTRA_RD_NUM 32
  96. #define CB_RD_NUM 32
  97. #define CB_TD_NUM 32
  98. // max number of physical segments
  99. // in a single NDIS packet. Above this threshold, the packet
  100. // is copied into a single physically contiguous buffer
  101. #define CB_MAX_SEGMENT 4
  102. #define CB_MIN_MAP_REG_NUM 4
  103. #define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
  104. #define CB_PROTOCOL_RESERVED_SECTION 16
  105. // if retrys excess 15 times , tx will abort, and
  106. // if tx fifo underflow, tx will fail
  107. // we should try to resend it
  108. #define CB_MAX_TX_ABORT_RETRY 3
  109. #ifdef __BIG_ENDIAN
  110. // WMAC definition FIFO Control
  111. #define FIFOCTL_AUTO_FB_1 0x0010
  112. #define FIFOCTL_AUTO_FB_0 0x0008
  113. #define FIFOCTL_GRPACK 0x0004
  114. #define FIFOCTL_11GA 0x0003
  115. #define FIFOCTL_11GB 0x0002
  116. #define FIFOCTL_11B 0x0001
  117. #define FIFOCTL_11A 0x0000
  118. #define FIFOCTL_RTS 0x8000
  119. #define FIFOCTL_ISDMA0 0x4000
  120. #define FIFOCTL_GENINT 0x2000
  121. #define FIFOCTL_TMOEN 0x1000
  122. #define FIFOCTL_LRETRY 0x0800
  123. #define FIFOCTL_CRCDIS 0x0400
  124. #define FIFOCTL_NEEDACK 0x0200
  125. #define FIFOCTL_LHEAD 0x0100
  126. //WMAC definition Frag Control
  127. #define FRAGCTL_AES 0x0003
  128. #define FRAGCTL_TKIP 0x0002
  129. #define FRAGCTL_LEGACY 0x0001
  130. #define FRAGCTL_NONENCRYPT 0x0000
  131. #define FRAGCTL_ENDFRAG 0x0300
  132. #define FRAGCTL_MIDFRAG 0x0200
  133. #define FRAGCTL_STAFRAG 0x0100
  134. #define FRAGCTL_NONFRAG 0x0000
  135. #else
  136. #define FIFOCTL_AUTO_FB_1 0x1000
  137. #define FIFOCTL_AUTO_FB_0 0x0800
  138. #define FIFOCTL_GRPACK 0x0400
  139. #define FIFOCTL_11GA 0x0300
  140. #define FIFOCTL_11GB 0x0200
  141. #define FIFOCTL_11B 0x0100
  142. #define FIFOCTL_11A 0x0000
  143. #define FIFOCTL_RTS 0x0080
  144. #define FIFOCTL_ISDMA0 0x0040
  145. #define FIFOCTL_GENINT 0x0020
  146. #define FIFOCTL_TMOEN 0x0010
  147. #define FIFOCTL_LRETRY 0x0008
  148. #define FIFOCTL_CRCDIS 0x0004
  149. #define FIFOCTL_NEEDACK 0x0002
  150. #define FIFOCTL_LHEAD 0x0001
  151. //WMAC definition Frag Control
  152. #define FRAGCTL_AES 0x0300
  153. #define FRAGCTL_TKIP 0x0200
  154. #define FRAGCTL_LEGACY 0x0100
  155. #define FRAGCTL_NONENCRYPT 0x0000
  156. #define FRAGCTL_ENDFRAG 0x0003
  157. #define FRAGCTL_MIDFRAG 0x0002
  158. #define FRAGCTL_STAFRAG 0x0001
  159. #define FRAGCTL_NONFRAG 0x0000
  160. #endif
  161. #define TYPE_TXDMA0 0
  162. #define TYPE_AC0DMA 1
  163. #define TYPE_ATIMDMA 2
  164. #define TYPE_SYNCDMA 3
  165. #define TYPE_MAXTD 2
  166. #define TYPE_BEACONDMA 4
  167. #define TYPE_RXDMA0 0
  168. #define TYPE_RXDMA1 1
  169. #define TYPE_MAXRD 2
  170. // TD_INFO flags control bit
  171. #define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
  172. #define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
  173. #define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
  174. // ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
  175. // Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
  176. // may link to older skb that leads error.
  177. typedef struct tagDEVICE_RD_INFO {
  178. struct sk_buff *skb;
  179. dma_addr_t skb_dma;
  180. dma_addr_t curr_desc;
  181. } DEVICE_RD_INFO, *PDEVICE_RD_INFO;
  182. #ifdef __BIG_ENDIAN
  183. typedef struct tagRDES0 {
  184. volatile unsigned short wResCount;
  185. union {
  186. volatile u16 f15Reserved;
  187. struct {
  188. volatile u8 f8Reserved1;
  189. volatile u8 f1Owner:1;
  190. volatile u8 f7Reserved:7;
  191. } __attribute__ ((__packed__));
  192. } __attribute__ ((__packed__));
  193. } __attribute__ ((__packed__))
  194. SRDES0, *PSRDES0;
  195. #else
  196. typedef struct tagRDES0 {
  197. unsigned short wResCount;
  198. unsigned short f15Reserved:15;
  199. unsigned short f1Owner:1;
  200. } __attribute__ ((__packed__))
  201. SRDES0;
  202. #endif
  203. typedef struct tagRDES1 {
  204. unsigned short wReqCount;
  205. unsigned short wReserved;
  206. } __attribute__ ((__packed__))
  207. SRDES1;
  208. //
  209. // Rx descriptor
  210. //
  211. typedef struct tagSRxDesc {
  212. volatile SRDES0 m_rd0RD0;
  213. volatile SRDES1 m_rd1RD1;
  214. volatile u32 buff_addr;
  215. volatile u32 next_desc;
  216. struct tagSRxDesc *next __aligned(8);
  217. volatile PDEVICE_RD_INFO pRDInfo __aligned(8);
  218. } __attribute__ ((__packed__))
  219. SRxDesc, *PSRxDesc;
  220. typedef const SRxDesc *PCSRxDesc;
  221. #ifdef __BIG_ENDIAN
  222. typedef struct tagTDES0 {
  223. volatile unsigned char byTSR0;
  224. volatile unsigned char byTSR1;
  225. union {
  226. volatile u16 f15Txtime;
  227. struct {
  228. volatile u8 f8Reserved1;
  229. volatile u8 f1Owner:1;
  230. volatile u8 f7Reserved:7;
  231. } __attribute__ ((__packed__));
  232. } __attribute__ ((__packed__));
  233. } __attribute__ ((__packed__))
  234. STDES0, PSTDES0;
  235. #else
  236. typedef struct tagTDES0 {
  237. volatile unsigned char byTSR0;
  238. volatile unsigned char byTSR1;
  239. volatile unsigned short f15Txtime:15;
  240. volatile unsigned short f1Owner:1;
  241. } __attribute__ ((__packed__))
  242. STDES0;
  243. #endif
  244. typedef struct tagTDES1 {
  245. volatile unsigned short wReqCount;
  246. volatile unsigned char byTCR;
  247. volatile unsigned char byReserved;
  248. } __attribute__ ((__packed__))
  249. STDES1;
  250. typedef struct tagDEVICE_TD_INFO {
  251. struct sk_buff *skb;
  252. unsigned char *buf;
  253. dma_addr_t skb_dma;
  254. dma_addr_t buf_dma;
  255. dma_addr_t curr_desc;
  256. unsigned long dwReqCount;
  257. unsigned long dwHeaderLength;
  258. unsigned char byFlags;
  259. } DEVICE_TD_INFO, *PDEVICE_TD_INFO;
  260. //
  261. // transmit descriptor
  262. //
  263. typedef struct tagSTxDesc {
  264. volatile STDES0 m_td0TD0;
  265. volatile STDES1 m_td1TD1;
  266. volatile u32 buff_addr;
  267. volatile u32 next_desc;
  268. struct tagSTxDesc *next __aligned(8);
  269. volatile PDEVICE_TD_INFO pTDInfo __aligned(8);
  270. } __attribute__ ((__packed__))
  271. STxDesc, *PSTxDesc;
  272. typedef const STxDesc *PCSTxDesc;
  273. typedef struct tagSTxSyncDesc {
  274. volatile STDES0 m_td0TD0;
  275. volatile STDES1 m_td1TD1;
  276. volatile u32 buff_addr; // pointer to logical buffer
  277. volatile u32 next_desc; // pointer to next logical descriptor
  278. volatile unsigned short m_wFIFOCtl;
  279. volatile unsigned short m_wTimeStamp;
  280. struct tagSTxSyncDesc *next __aligned(8);
  281. volatile PDEVICE_TD_INFO pTDInfo __aligned(8);
  282. } __attribute__ ((__packed__))
  283. STxSyncDesc, *PSTxSyncDesc;
  284. typedef const STxSyncDesc *PCSTxSyncDesc;
  285. //
  286. // RsvTime buffer header
  287. //
  288. typedef struct tagSRrvTime_atim {
  289. unsigned short wCTSTxRrvTime_ba;
  290. unsigned short wTxRrvTime_a;
  291. } __attribute__ ((__packed__))
  292. SRrvTime_atim, *PSRrvTime_atim;
  293. typedef const SRrvTime_atim *PCSRrvTime_atim;
  294. /* Length, Service, and Signal fields of Phy for Tx */
  295. struct vnt_phy_field {
  296. u8 signal;
  297. u8 service;
  298. __le16 len;
  299. } __packed;
  300. union vnt_phy_field_swap {
  301. struct vnt_phy_field field_read;
  302. u16 swap[2];
  303. u32 field_write;
  304. };
  305. //
  306. // Tx FIFO header
  307. //
  308. typedef struct tagSTxBufHead {
  309. u32 adwTxKey[4];
  310. unsigned short wFIFOCtl;
  311. unsigned short wTimeStamp;
  312. unsigned short wFragCtl;
  313. unsigned char byTxPower;
  314. unsigned char wReserved;
  315. } __attribute__ ((__packed__))
  316. STxBufHead, *PSTxBufHead;
  317. typedef const STxBufHead *PCSTxBufHead;
  318. typedef struct tagSBEACONCtl {
  319. u32 BufReady:1;
  320. u32 TSF:15;
  321. u32 BufLen:11;
  322. u32 Reserved:5;
  323. } __attribute__ ((__packed__))
  324. SBEACONCtl;
  325. typedef struct tagSSecretKey {
  326. u32 dwLowDword;
  327. unsigned char byHighByte;
  328. } __attribute__ ((__packed__))
  329. SSecretKey;
  330. typedef struct tagSKeyEntry {
  331. unsigned char abyAddrHi[2];
  332. unsigned short wKCTL;
  333. unsigned char abyAddrLo[4];
  334. u32 dwKey0[4];
  335. u32 dwKey1[4];
  336. u32 dwKey2[4];
  337. u32 dwKey3[4];
  338. u32 dwKey4[4];
  339. } __attribute__ ((__packed__))
  340. SKeyEntry;
  341. #endif // __DESC_H__