rtl871x_xmit.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * Modifications for inclusion into the Linux staging tree are
  19. * Copyright(c) 2010 Larry Finger. All rights reserved.
  20. *
  21. * Contact information:
  22. * WLAN FAE <wlanfae@realtek.com>
  23. * Larry Finger <Larry.Finger@lwfinger.net>
  24. *
  25. ******************************************************************************/
  26. #ifndef _RTL871X_XMIT_H_
  27. #define _RTL871X_XMIT_H_
  28. #include "osdep_service.h"
  29. #include "drv_types.h"
  30. #include "xmit_osdep.h"
  31. #ifdef CONFIG_R8712_TX_AGGR
  32. #define MAX_XMITBUF_SZ (16384)
  33. #else
  34. #define MAX_XMITBUF_SZ (2048)
  35. #endif
  36. #define NR_XMITBUFF (4)
  37. #ifdef CONFIG_R8712_TX_AGGR
  38. #define AGGR_NR_HIGH_BOUND (4) /*(8) */
  39. #define AGGR_NR_LOW_BOUND (2)
  40. #endif
  41. #define XMITBUF_ALIGN_SZ 512
  42. #define TX_GUARD_BAND 5
  43. #define MAX_NUMBLKS (1)
  44. /* Fixed the Big Endian bug when using the software driver encryption.*/
  45. #define WEP_IV(pattrib_iv, txpn, keyidx)\
  46. do { \
  47. pattrib_iv[0] = txpn._byte_.TSC0;\
  48. pattrib_iv[1] = txpn._byte_.TSC1;\
  49. pattrib_iv[2] = txpn._byte_.TSC2;\
  50. pattrib_iv[3] = ((keyidx & 0x3)<<6);\
  51. txpn.val = (txpn.val == 0xffffff) ? 0 : (txpn.val+1);\
  52. } while (0)
  53. /* Fixed the Big Endian bug when doing the Tx.
  54. * The Linksys WRH54G will check this.*/
  55. #define TKIP_IV(pattrib_iv, txpn, keyidx)\
  56. do { \
  57. pattrib_iv[0] = txpn._byte_.TSC1;\
  58. pattrib_iv[1] = (txpn._byte_.TSC1 | 0x20) & 0x7f;\
  59. pattrib_iv[2] = txpn._byte_.TSC0;\
  60. pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
  61. pattrib_iv[4] = txpn._byte_.TSC2;\
  62. pattrib_iv[5] = txpn._byte_.TSC3;\
  63. pattrib_iv[6] = txpn._byte_.TSC4;\
  64. pattrib_iv[7] = txpn._byte_.TSC5;\
  65. txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
  66. (txpn.val+1);\
  67. } while (0)
  68. #define AES_IV(pattrib_iv, txpn, keyidx)\
  69. do { \
  70. pattrib_iv[0] = txpn._byte_.TSC0;\
  71. pattrib_iv[1] = txpn._byte_.TSC1;\
  72. pattrib_iv[2] = 0;\
  73. pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
  74. pattrib_iv[4] = txpn._byte_.TSC2;\
  75. pattrib_iv[5] = txpn._byte_.TSC3;\
  76. pattrib_iv[6] = txpn._byte_.TSC4;\
  77. pattrib_iv[7] = txpn._byte_.TSC5;\
  78. txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
  79. (txpn.val+1);\
  80. } while (0)
  81. struct hw_xmit {
  82. spinlock_t xmit_lock;
  83. struct list_head pending;
  84. struct __queue *sta_queue;
  85. struct hw_txqueue *phwtxqueue;
  86. sint txcmdcnt;
  87. int accnt;
  88. };
  89. struct pkt_attrib {
  90. u8 type;
  91. u8 subtype;
  92. u8 bswenc;
  93. u8 dhcp_pkt;
  94. u16 seqnum;
  95. u16 ether_type;
  96. u16 pktlen; /* the original 802.3 pkt raw_data len
  97. * (not include ether_hdr data) */
  98. u16 last_txcmdsz;
  99. u8 pkt_hdrlen; /*the original 802.3 pkt header len*/
  100. u8 hdrlen; /*the WLAN Header Len*/
  101. u8 nr_frags;
  102. u8 ack_policy;
  103. u8 mac_id;
  104. u8 vcs_mode; /*virtual carrier sense method*/
  105. u8 pctrl;/*per packet txdesc control enable*/
  106. u8 qsel;
  107. u8 priority;
  108. u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
  109. * indicate the encrypt algorithm*/
  110. u8 iv_len;
  111. u8 icv_len;
  112. unsigned char iv[8];
  113. unsigned char icv[8];
  114. u8 dst[ETH_ALEN];
  115. u8 src[ETH_ALEN];
  116. u8 ta[ETH_ALEN];
  117. u8 ra[ETH_ALEN];
  118. struct sta_info *psta;
  119. };
  120. #define WLANHDR_OFFSET 64
  121. #define DATA_FRAMETAG 0x01
  122. #define L2_FRAMETAG 0x02
  123. #define MGNT_FRAMETAG 0x03
  124. #define AMSDU_FRAMETAG 0x04
  125. #define EII_FRAMETAG 0x05
  126. #define IEEE8023_FRAMETAG 0x06
  127. #define MP_FRAMETAG 0x07
  128. #define TXAGG_FRAMETAG 0x08
  129. struct xmit_buf {
  130. struct list_head list;
  131. u8 *pallocated_buf;
  132. u8 *pbuf;
  133. void *priv_data;
  134. struct urb *pxmit_urb[8];
  135. u32 aggr_nr;
  136. };
  137. struct xmit_frame {
  138. struct list_head list;
  139. struct pkt_attrib attrib;
  140. _pkt *pkt;
  141. int frame_tag;
  142. struct _adapter *padapter;
  143. u8 *buf_addr;
  144. struct xmit_buf *pxmitbuf;
  145. u8 *mem_addr;
  146. u16 sz[8];
  147. struct urb *pxmit_urb[8];
  148. u8 bpending[8];
  149. u8 last[8];
  150. };
  151. struct tx_servq {
  152. struct list_head tx_pending;
  153. struct __queue sta_pending;
  154. int qcnt;
  155. };
  156. struct sta_xmit_priv {
  157. spinlock_t lock;
  158. sint option;
  159. sint apsd_setting; /* When bit mask is on, the associated edca
  160. * queue supports APSD.*/
  161. struct tx_servq be_q; /* priority == 0,3 */
  162. struct tx_servq bk_q; /* priority == 1,2*/
  163. struct tx_servq vi_q; /*priority == 4,5*/
  164. struct tx_servq vo_q; /*priority == 6,7*/
  165. struct list_head legacy_dz;
  166. struct list_head apsd;
  167. u16 txseq_tid[16];
  168. uint sta_tx_bytes;
  169. u64 sta_tx_pkts;
  170. uint sta_tx_fail;
  171. };
  172. struct hw_txqueue {
  173. /*volatile*/ sint head;
  174. /*volatile*/ sint tail;
  175. /*volatile*/ sint free_sz; /*in units of 64 bytes*/
  176. /*volatile*/ sint free_cmdsz;
  177. /*volatile*/ sint txsz[8];
  178. uint ff_hwaddr;
  179. uint cmd_hwaddr;
  180. sint ac_tag;
  181. };
  182. struct xmit_priv {
  183. spinlock_t lock;
  184. struct __queue be_pending;
  185. struct __queue bk_pending;
  186. struct __queue vi_pending;
  187. struct __queue vo_pending;
  188. struct __queue bm_pending;
  189. struct __queue legacy_dz_queue;
  190. struct __queue apsd_queue;
  191. u8 *pallocated_frame_buf;
  192. u8 *pxmit_frame_buf;
  193. uint free_xmitframe_cnt;
  194. uint mapping_addr;
  195. uint pkt_sz;
  196. struct __queue free_xmit_queue;
  197. struct hw_txqueue be_txqueue;
  198. struct hw_txqueue bk_txqueue;
  199. struct hw_txqueue vi_txqueue;
  200. struct hw_txqueue vo_txqueue;
  201. struct hw_txqueue bmc_txqueue;
  202. uint frag_len;
  203. struct _adapter *adapter;
  204. u8 vcs_setting;
  205. u8 vcs;
  206. u8 vcs_type;
  207. u16 rts_thresh;
  208. uint tx_bytes;
  209. u64 tx_pkts;
  210. uint tx_drop;
  211. struct hw_xmit *hwxmits;
  212. u8 hwxmit_entry;
  213. u8 txirp_cnt;
  214. struct tasklet_struct xmit_tasklet;
  215. struct work_struct xmit_pipe4_reset_wi;
  216. struct work_struct xmit_pipe6_reset_wi;
  217. struct work_struct xmit_piped_reset_wi;
  218. /*per AC pending irp*/
  219. int beq_cnt;
  220. int bkq_cnt;
  221. int viq_cnt;
  222. int voq_cnt;
  223. struct __queue free_amsdu_xmit_queue;
  224. u8 *pallocated_amsdu_frame_buf;
  225. u8 *pxmit_amsdu_frame_buf;
  226. uint free_amsdu_xmitframe_cnt;
  227. struct __queue free_txagg_xmit_queue;
  228. u8 *pallocated_txagg_frame_buf;
  229. u8 *pxmit_txagg_frame_buf;
  230. uint free_txagg_xmitframe_cnt;
  231. int cmdseq;
  232. struct __queue free_xmitbuf_queue;
  233. struct __queue pending_xmitbuf_queue;
  234. u8 *pallocated_xmitbuf;
  235. u8 *pxmitbuf;
  236. uint free_xmitbuf_cnt;
  237. };
  238. static inline struct __queue *get_free_xmit_queue(
  239. struct xmit_priv *pxmitpriv)
  240. {
  241. return &(pxmitpriv->free_xmit_queue);
  242. }
  243. int r8712_free_xmitbuf(struct xmit_priv *pxmitpriv,
  244. struct xmit_buf *pxmitbuf);
  245. struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
  246. void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len);
  247. struct xmit_frame *r8712_alloc_xmitframe(struct xmit_priv *pxmitpriv);
  248. void r8712_free_xmitframe(struct xmit_priv *pxmitpriv,
  249. struct xmit_frame *pxmitframe);
  250. void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
  251. struct __queue *pframequeue);
  252. sint r8712_xmit_classifier(struct _adapter *padapter,
  253. struct xmit_frame *pxmitframe);
  254. sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt,
  255. struct xmit_frame *pxmitframe);
  256. sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
  257. void _r8712_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
  258. sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
  259. struct pkt_attrib *pattrib);
  260. int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
  261. struct pkt_attrib *pattrib);
  262. sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
  263. struct _adapter *padapter);
  264. void _free_xmit_priv(struct xmit_priv *pxmitpriv);
  265. void r8712_free_xmitframe_ex(struct xmit_priv *pxmitpriv,
  266. struct xmit_frame *pxmitframe);
  267. int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe);
  268. int r8712_xmit_enqueue(struct _adapter *padapter,
  269. struct xmit_frame *pxmitframe);
  270. int r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe);
  271. void r8712_xmit_bh(void *priv);
  272. void xmitframe_xmitbuf_attach(struct xmit_frame *pxmitframe,
  273. struct xmit_buf *pxmitbuf);
  274. #include "rtl8712_xmit.h"
  275. #endif /*_RTL871X_XMIT_H_*/