desc.h 6.0 KB

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