desc.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. #define B_OWNED_BY_CHIP 1
  36. #define B_OWNED_BY_HOST 0
  37. /* Bits in the RSR register */
  38. #define RSR_ADDRBROAD 0x80
  39. #define RSR_ADDRMULTI 0x40
  40. #define RSR_ADDRUNI 0x00
  41. #define RSR_IVLDTYP 0x20
  42. #define RSR_IVLDLEN 0x10 /* invalid len (> 2312 byte) */
  43. #define RSR_BSSIDOK 0x08
  44. #define RSR_CRCOK 0x04
  45. #define RSR_BCNSSIDOK 0x02
  46. #define RSR_ADDROK 0x01
  47. /* Bits in the new RSR register */
  48. #define NEWRSR_DECRYPTOK 0x10
  49. #define NEWRSR_CFPIND 0x08
  50. #define NEWRSR_HWUTSF 0x04
  51. #define NEWRSR_BCNHITAID 0x02
  52. #define NEWRSR_BCNHITAID0 0x01
  53. /* Bits in the TSR0 register */
  54. #define TSR0_PWRSTS1_2 0xC0
  55. #define TSR0_PWRSTS7 0x20
  56. #define TSR0_NCR 0x1F
  57. /* Bits in the TSR1 register */
  58. #define TSR1_TERR 0x80
  59. #define TSR1_PWRSTS4_6 0x70
  60. #define TSR1_RETRYTMO 0x08
  61. #define TSR1_TMO 0x04
  62. #define TSR1_PWRSTS3 0x02
  63. #define ACK_DATA 0x01
  64. /* Bits in the TCR register */
  65. #define EDMSDU 0x04 /* end of sdu */
  66. #define TCR_EDP 0x02 /* end of packet */
  67. #define TCR_STP 0x01 /* start of packet */
  68. /* max transmit or receive buffer size */
  69. #define CB_MAX_BUF_SIZE 2900U
  70. /* NOTE: must be multiple of 4 */
  71. #define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE
  72. #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE
  73. #define CB_BEACON_BUF_SIZE 512U
  74. #define CB_MAX_RX_DESC 128
  75. #define CB_MIN_RX_DESC 16
  76. #define CB_MAX_TX_DESC 64
  77. #define CB_MIN_TX_DESC 16
  78. #define CB_MAX_RECEIVED_PACKETS 16
  79. /*
  80. * limit our receive routine to indicating
  81. * this many at a time for 2 reasons:
  82. * 1. driver flow control to protocol layer
  83. * 2. limit the time used in ISR routine
  84. */
  85. #define CB_EXTRA_RD_NUM 32
  86. #define CB_RD_NUM 32
  87. #define CB_TD_NUM 32
  88. /*
  89. * max number of physical segments in a single NDIS packet. Above this
  90. * threshold, the packet is copied into a single physically contiguous buffer
  91. */
  92. #define CB_MAX_SEGMENT 4
  93. #define CB_MIN_MAP_REG_NUM 4
  94. #define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
  95. #define CB_PROTOCOL_RESERVED_SECTION 16
  96. /*
  97. * if retrys excess 15 times , tx will abort, and if tx fifo underflow,
  98. * tx will fail, we should try to resend it
  99. */
  100. #define CB_MAX_TX_ABORT_RETRY 3
  101. /* WMAC definition FIFO Control */
  102. #define FIFOCTL_AUTO_FB_1 0x1000
  103. #define FIFOCTL_AUTO_FB_0 0x0800
  104. #define FIFOCTL_GRPACK 0x0400
  105. #define FIFOCTL_11GA 0x0300
  106. #define FIFOCTL_11GB 0x0200
  107. #define FIFOCTL_11B 0x0100
  108. #define FIFOCTL_11A 0x0000
  109. #define FIFOCTL_RTS 0x0080
  110. #define FIFOCTL_ISDMA0 0x0040
  111. #define FIFOCTL_GENINT 0x0020
  112. #define FIFOCTL_TMOEN 0x0010
  113. #define FIFOCTL_LRETRY 0x0008
  114. #define FIFOCTL_CRCDIS 0x0004
  115. #define FIFOCTL_NEEDACK 0x0002
  116. #define FIFOCTL_LHEAD 0x0001
  117. /* WMAC definition Frag Control */
  118. #define FRAGCTL_AES 0x0300
  119. #define FRAGCTL_TKIP 0x0200
  120. #define FRAGCTL_LEGACY 0x0100
  121. #define FRAGCTL_NONENCRYPT 0x0000
  122. #define FRAGCTL_ENDFRAG 0x0003
  123. #define FRAGCTL_MIDFRAG 0x0002
  124. #define FRAGCTL_STAFRAG 0x0001
  125. #define FRAGCTL_NONFRAG 0x0000
  126. #define TYPE_TXDMA0 0
  127. #define TYPE_AC0DMA 1
  128. #define TYPE_ATIMDMA 2
  129. #define TYPE_SYNCDMA 3
  130. #define TYPE_MAXTD 2
  131. #define TYPE_BEACONDMA 4
  132. #define TYPE_RXDMA0 0
  133. #define TYPE_RXDMA1 1
  134. #define TYPE_MAXRD 2
  135. /* TD_INFO flags control bit */
  136. #define TD_FLAGS_NETIF_SKB 0x01 /* check if need release skb */
  137. #define TD_FLAGS_PRIV_SKB 0x02 /* check if called from private skb (hostap) */
  138. #define TD_FLAGS_PS_RETRY 0x04 /* check if PS STA frame re-transmit */
  139. /*
  140. * ref_sk_buff is used for mapping the skb structure between pre-built
  141. * driver-obj & running kernel. Since different kernel version (2.4x) may
  142. * change skb structure, i.e. pre-built driver-obj may link to older skb that
  143. * leads error.
  144. */
  145. struct vnt_rd_info {
  146. struct sk_buff *skb;
  147. dma_addr_t skb_dma;
  148. };
  149. struct vnt_rdes0 {
  150. volatile __le16 res_count;
  151. #ifdef __BIG_ENDIAN
  152. union {
  153. volatile u16 f15_reserved;
  154. struct {
  155. volatile u8 f8_reserved1;
  156. volatile u8 owner:1;
  157. volatile u8 f7_reserved:7;
  158. } __packed;
  159. } __packed;
  160. #else
  161. u16 f15_reserved:15;
  162. u16 owner:1;
  163. #endif
  164. } __packed;
  165. struct vnt_rdes1 {
  166. __le16 req_count;
  167. u16 reserved;
  168. } __packed;
  169. /* Rx descriptor*/
  170. struct vnt_rx_desc {
  171. volatile struct vnt_rdes0 rd0;
  172. volatile struct vnt_rdes1 rd1;
  173. volatile __le32 buff_addr;
  174. volatile __le32 next_desc;
  175. struct vnt_rx_desc *next __aligned(8);
  176. struct vnt_rd_info *rd_info __aligned(8);
  177. } __packed;
  178. struct vnt_tdes0 {
  179. volatile u8 tsr0;
  180. volatile u8 tsr1;
  181. #ifdef __BIG_ENDIAN
  182. union {
  183. volatile u16 f15_txtime;
  184. struct {
  185. volatile u8 f8_reserved;
  186. volatile u8 owner:1;
  187. volatile u8 f7_reserved:7;
  188. } __packed;
  189. } __packed;
  190. #else
  191. volatile u16 f15_txtime:15;
  192. volatile u16 owner:1;
  193. #endif
  194. } __packed;
  195. struct vnt_tdes1 {
  196. volatile __le16 req_count;
  197. volatile u8 tcr;
  198. volatile u8 reserved;
  199. } __packed;
  200. struct vnt_td_info {
  201. void *mic_hdr;
  202. struct sk_buff *skb;
  203. unsigned char *buf;
  204. dma_addr_t buf_dma;
  205. u16 req_count;
  206. u8 flags;
  207. };
  208. /* transmit descriptor */
  209. struct vnt_tx_desc {
  210. volatile struct vnt_tdes0 td0;
  211. volatile struct vnt_tdes1 td1;
  212. volatile __le32 buff_addr;
  213. volatile __le32 next_desc;
  214. struct vnt_tx_desc *next __aligned(8);
  215. struct vnt_td_info *td_info __aligned(8);
  216. } __packed;
  217. /* Length, Service, and Signal fields of Phy for Tx */
  218. struct vnt_phy_field {
  219. u8 signal;
  220. u8 service;
  221. __le16 len;
  222. } __packed;
  223. union vnt_phy_field_swap {
  224. struct vnt_phy_field field_read;
  225. u16 swap[2];
  226. u32 field_write;
  227. };
  228. #endif /* __DESC_H__ */