1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef _RTL871X_XMIT_H_
27#define _RTL871X_XMIT_H_
28
29#include "osdep_service.h"
30#include "drv_types.h"
31#include "xmit_osdep.h"
32
33#ifdef CONFIG_R8712_TX_AGGR
34#define MAX_XMITBUF_SZ (16384)
35#else
36#define MAX_XMITBUF_SZ (2048)
37#endif
38
39#define NR_XMITBUFF (4)
40
41#ifdef CONFIG_R8712_TX_AGGR
42#define AGGR_NR_HIGH_BOUND (4)
43#define AGGR_NR_LOW_BOUND (2)
44#endif
45
46#define XMITBUF_ALIGN_SZ 512
47#define TX_GUARD_BAND 5
48#define MAX_NUMBLKS (1)
49
50
51#define WEP_IV(pattrib_iv, txpn, keyidx)\
52do { \
53 pattrib_iv[0] = txpn._byte_.TSC0;\
54 pattrib_iv[1] = txpn._byte_.TSC1;\
55 pattrib_iv[2] = txpn._byte_.TSC2;\
56 pattrib_iv[3] = ((keyidx & 0x3)<<6);\
57 txpn.val = (txpn.val == 0xffffff) ? 0 : (txpn.val+1);\
58} while (0)
59
60
61
62#define TKIP_IV(pattrib_iv, txpn, keyidx)\
63do { \
64 pattrib_iv[0] = txpn._byte_.TSC1;\
65 pattrib_iv[1] = (txpn._byte_.TSC1 | 0x20) & 0x7f;\
66 pattrib_iv[2] = txpn._byte_.TSC0;\
67 pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
68 pattrib_iv[4] = txpn._byte_.TSC2;\
69 pattrib_iv[5] = txpn._byte_.TSC3;\
70 pattrib_iv[6] = txpn._byte_.TSC4;\
71 pattrib_iv[7] = txpn._byte_.TSC5;\
72 txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
73 (txpn.val+1);\
74} while (0)
75
76#define AES_IV(pattrib_iv, txpn, keyidx)\
77do { \
78 pattrib_iv[0] = txpn._byte_.TSC0;\
79 pattrib_iv[1] = txpn._byte_.TSC1;\
80 pattrib_iv[2] = 0;\
81 pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
82 pattrib_iv[4] = txpn._byte_.TSC2;\
83 pattrib_iv[5] = txpn._byte_.TSC3;\
84 pattrib_iv[6] = txpn._byte_.TSC4;\
85 pattrib_iv[7] = txpn._byte_.TSC5;\
86 txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
87 (txpn.val+1);\
88} while (0)
89
90struct hw_xmit {
91 spinlock_t xmit_lock;
92 struct list_head pending;
93 struct __queue *sta_queue;
94 struct hw_txqueue *phwtxqueue;
95 sint txcmdcnt;
96 int accnt;
97};
98
99struct pkt_attrib {
100 u8 type;
101 u8 subtype;
102 u8 bswenc;
103 u8 dhcp_pkt;
104
105 u16 seqnum;
106 u16 ether_type;
107 u16 pktlen;
108
109 u16 last_txcmdsz;
110
111 u8 pkt_hdrlen;
112 u8 hdrlen;
113 u8 nr_frags;
114 u8 ack_policy;
115 u8 mac_id;
116 u8 vcs_mode;
117 u8 pctrl;
118 u8 qsel;
119
120 u8 priority;
121 u8 encrypt;
122
123 u8 iv_len;
124 u8 icv_len;
125 unsigned char iv[8];
126 unsigned char icv[8];
127 u8 dst[ETH_ALEN];
128 u8 src[ETH_ALEN];
129 u8 ta[ETH_ALEN];
130 u8 ra[ETH_ALEN];
131 struct sta_info *psta;
132};
133
134#define WLANHDR_OFFSET 64
135#define DATA_FRAMETAG 0x01
136#define L2_FRAMETAG 0x02
137#define MGNT_FRAMETAG 0x03
138#define AMSDU_FRAMETAG 0x04
139#define EII_FRAMETAG 0x05
140#define IEEE8023_FRAMETAG 0x06
141#define MP_FRAMETAG 0x07
142#define TXAGG_FRAMETAG 0x08
143
144struct xmit_buf {
145 struct list_head list;
146
147 u8 *pallocated_buf;
148 u8 *pbuf;
149 void *priv_data;
150 struct urb *pxmit_urb[8];
151 u32 aggr_nr;
152};
153
154struct xmit_frame {
155 struct list_head list;
156 struct pkt_attrib attrib;
157 _pkt *pkt;
158 int frame_tag;
159 struct _adapter *padapter;
160 u8 *buf_addr;
161 struct xmit_buf *pxmitbuf;
162 u8 *mem_addr;
163 u16 sz[8];
164 struct urb *pxmit_urb[8];
165 u8 bpending[8];
166 u8 last[8];
167};
168
169struct tx_servq {
170 struct list_head tx_pending;
171 struct __queue sta_pending;
172 int qcnt;
173};
174
175struct sta_xmit_priv {
176 spinlock_t lock;
177 sint option;
178 sint apsd_setting;
179
180 struct tx_servq be_q;
181 struct tx_servq bk_q;
182 struct tx_servq vi_q;
183 struct tx_servq vo_q;
184 struct list_head legacy_dz;
185 struct list_head apsd;
186 u16 txseq_tid[16];
187 uint sta_tx_bytes;
188 u64 sta_tx_pkts;
189 uint sta_tx_fail;
190};
191
192struct hw_txqueue {
193 sint head;
194 sint tail;
195 sint free_sz;
196 sint free_cmdsz;
197 sint txsz[8];
198 uint ff_hwaddr;
199 uint cmd_hwaddr;
200 sint ac_tag;
201};
202
203struct xmit_priv {
204 spinlock_t lock;
205 struct __queue be_pending;
206 struct __queue bk_pending;
207 struct __queue vi_pending;
208 struct __queue vo_pending;
209 struct __queue bm_pending;
210 struct __queue legacy_dz_queue;
211 struct __queue apsd_queue;
212 u8 *pallocated_frame_buf;
213 u8 *pxmit_frame_buf;
214 uint free_xmitframe_cnt;
215 uint mapping_addr;
216 uint pkt_sz;
217 struct __queue free_xmit_queue;
218 struct hw_txqueue be_txqueue;
219 struct hw_txqueue bk_txqueue;
220 struct hw_txqueue vi_txqueue;
221 struct hw_txqueue vo_txqueue;
222 struct hw_txqueue bmc_txqueue;
223 uint frag_len;
224 struct _adapter *adapter;
225 u8 vcs_setting;
226 u8 vcs;
227 u8 vcs_type;
228 u16 rts_thresh;
229 uint tx_bytes;
230 u64 tx_pkts;
231 uint tx_drop;
232 struct hw_xmit *hwxmits;
233 u8 hwxmit_entry;
234 u8 txirp_cnt;
235 struct tasklet_struct xmit_tasklet;
236 _workitem xmit_pipe4_reset_wi;
237 _workitem xmit_pipe6_reset_wi;
238 _workitem xmit_piped_reset_wi;
239
240 int beq_cnt;
241 int bkq_cnt;
242 int viq_cnt;
243 int voq_cnt;
244 struct __queue free_amsdu_xmit_queue;
245 u8 *pallocated_amsdu_frame_buf;
246 u8 *pxmit_amsdu_frame_buf;
247 uint free_amsdu_xmitframe_cnt;
248 struct __queue free_txagg_xmit_queue;
249 u8 *pallocated_txagg_frame_buf;
250 u8 *pxmit_txagg_frame_buf;
251 uint free_txagg_xmitframe_cnt;
252 int cmdseq;
253 struct __queue free_xmitbuf_queue;
254 struct __queue pending_xmitbuf_queue;
255 u8 *pallocated_xmitbuf;
256 u8 *pxmitbuf;
257 uint free_xmitbuf_cnt;
258};
259
260static inline struct __queue *get_free_xmit_queue(
261 struct xmit_priv *pxmitpriv)
262{
263 return &(pxmitpriv->free_xmit_queue);
264}
265
266int r8712_free_xmitbuf(struct xmit_priv *pxmitpriv,
267 struct xmit_buf *pxmitbuf);
268struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
269void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len);
270struct xmit_frame *r8712_alloc_xmitframe(struct xmit_priv *pxmitpriv);
271void r8712_free_xmitframe(struct xmit_priv *pxmitpriv,
272 struct xmit_frame *pxmitframe);
273void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
274 struct __queue *pframequeue);
275sint r8712_xmit_classifier(struct _adapter *padapter,
276 struct xmit_frame *pxmitframe);
277sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt,
278 struct xmit_frame *pxmitframe);
279sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
280void _r8712_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
281sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
282 struct pkt_attrib *pattrib);
283int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
284 struct pkt_attrib *pattrib);
285sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
286 struct _adapter *padapter);
287void _free_xmit_priv(struct xmit_priv *pxmitpriv);
288void r8712_free_xmitframe_ex(struct xmit_priv *pxmitpriv,
289 struct xmit_frame *pxmitframe);
290int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe);
291int r8712_xmit_enqueue(struct _adapter *padapter,
292 struct xmit_frame *pxmitframe);
293int r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe);
294void r8712_xmit_bh(void *priv);
295
296void xmitframe_xmitbuf_attach(struct xmit_frame *pxmitframe,
297 struct xmit_buf *pxmitbuf);
298
299#include "rtl8712_xmit.h"
300
301#endif
302
303