Commit | Line | Data |
---|---|---|
364e30eb LF |
1 | /****************************************************************************** |
2 | * | |
3 | * Copyright(c) 2007 - 2011 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 | ******************************************************************************/ | |
15 | #ifndef _RTW_XMIT_H_ | |
16 | #define _RTW_XMIT_H_ | |
17 | ||
18 | #include <osdep_service.h> | |
19 | #include <drv_types.h> | |
20 | ||
21 | #define MAX_XMITBUF_SZ 2048 | |
22 | #define NR_XMITBUFF 4 | |
23 | ||
24 | #define XMITBUF_ALIGN_SZ 512 | |
25 | ||
26 | /* xmit extension buff defination */ | |
27 | #define MAX_XMIT_EXTBUF_SZ 1536 | |
28 | #define NR_XMIT_EXTBUFF 32 | |
29 | ||
30 | #define MAX_NUMBLKS 1 | |
31 | ||
32 | #define XMIT_VO_QUEUE 0 | |
33 | #define XMIT_VI_QUEUE 1 | |
34 | #define XMIT_BE_QUEUE 2 | |
35 | #define XMIT_BK_QUEUE 3 | |
36 | ||
37 | #define VO_QUEUE_INX 0 | |
38 | #define VI_QUEUE_INX 1 | |
39 | #define BE_QUEUE_INX 2 | |
40 | #define BK_QUEUE_INX 3 | |
41 | #define BCN_QUEUE_INX 4 | |
42 | #define MGT_QUEUE_INX 5 | |
43 | #define HIGH_QUEUE_INX 6 | |
44 | #define TXCMD_QUEUE_INX 7 | |
45 | ||
46 | #define HW_QUEUE_ENTRY 8 | |
47 | ||
48 | #define WEP_IV(pattrib_iv, dot11txpn, keyidx) \ | |
49 | do { \ | |
50 | pattrib_iv[0] = dot11txpn._byte_.TSC0; \ | |
51 | pattrib_iv[1] = dot11txpn._byte_.TSC1; \ | |
52 | pattrib_iv[2] = dot11txpn._byte_.TSC2; \ | |
53 | pattrib_iv[3] = ((keyidx & 0x3) << 6); \ | |
54 | dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : \ | |
55 | (dot11txpn.val+1); \ | |
56 | } while (0) | |
57 | ||
58 | #define TKIP_IV(pattrib_iv, dot11txpn, keyidx) \ | |
59 | do { \ | |
60 | pattrib_iv[0] = dot11txpn._byte_.TSC1; \ | |
61 | pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f; \ | |
62 | pattrib_iv[2] = dot11txpn._byte_.TSC0; \ | |
63 | pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6); \ | |
64 | pattrib_iv[4] = dot11txpn._byte_.TSC2; \ | |
65 | pattrib_iv[5] = dot11txpn._byte_.TSC3; \ | |
66 | pattrib_iv[6] = dot11txpn._byte_.TSC4; \ | |
67 | pattrib_iv[7] = dot11txpn._byte_.TSC5; \ | |
68 | dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : \ | |
69 | (dot11txpn.val+1); \ | |
70 | } while (0) | |
71 | ||
72 | #define AES_IV(pattrib_iv, dot11txpn, keyidx)\ | |
73 | do { \ | |
74 | pattrib_iv[0] = dot11txpn._byte_.TSC0; \ | |
75 | pattrib_iv[1] = dot11txpn._byte_.TSC1; \ | |
76 | pattrib_iv[2] = 0; \ | |
77 | pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6); \ | |
78 | pattrib_iv[4] = dot11txpn._byte_.TSC2; \ | |
79 | pattrib_iv[5] = dot11txpn._byte_.TSC3; \ | |
80 | pattrib_iv[6] = dot11txpn._byte_.TSC4; \ | |
81 | pattrib_iv[7] = dot11txpn._byte_.TSC5; \ | |
82 | dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : \ | |
83 | (dot11txpn.val+1); \ | |
84 | } while (0) | |
85 | ||
86 | #define HWXMIT_ENTRY 4 | |
87 | ||
88 | #define TXDESC_SIZE 32 | |
89 | ||
90 | #define PACKET_OFFSET_SZ 8 | |
91 | #define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ) | |
92 | ||
93 | struct tx_desc { | |
94 | /* DWORD 0 */ | |
caa90ab1 LF |
95 | __le32 txdw0; |
96 | __le32 txdw1; | |
97 | __le32 txdw2; | |
98 | __le32 txdw3; | |
99 | __le32 txdw4; | |
100 | __le32 txdw5; | |
101 | __le32 txdw6; | |
102 | __le32 txdw7; | |
364e30eb LF |
103 | }; |
104 | ||
105 | union txdesc { | |
106 | struct tx_desc txdesc; | |
107 | unsigned int value[TXDESC_SIZE>>2]; | |
108 | }; | |
109 | ||
110 | struct hw_xmit { | |
111 | struct rtw_queue *sta_queue; | |
112 | int accnt; | |
113 | }; | |
114 | ||
115 | /* reduce size */ | |
116 | struct pkt_attrib { | |
b2f72cae | 117 | u16 type; |
364e30eb LF |
118 | u8 bswenc; |
119 | u8 dhcp_pkt; | |
120 | u16 ether_type; | |
121 | u16 seqnum; | |
122 | u16 pkt_hdrlen; /* the original 802.3 pkt header len */ | |
123 | u16 hdrlen; /* the WLAN Header Len */ | |
124 | u32 pktlen; /* the original 802.3 pkt raw_data len */ | |
125 | u32 last_txcmdsz; | |
9e3d6df2 | 126 | u32 encrypt; /* when 0 indicate no encrypt. */ |
364e30eb | 127 | u8 nr_frags; |
364e30eb LF |
128 | u8 iv_len; |
129 | u8 icv_len; | |
130 | u8 iv[18]; | |
131 | u8 icv[16]; | |
132 | u8 priority; | |
133 | u8 ack_policy; | |
134 | u8 mac_id; | |
135 | u8 vcs_mode; /* virtual carrier sense method */ | |
136 | u8 dst[ETH_ALEN]; | |
137 | u8 src[ETH_ALEN]; | |
138 | u8 ta[ETH_ALEN]; | |
139 | u8 ra[ETH_ALEN]; | |
140 | u8 key_idx; | |
141 | u8 qos_en; | |
142 | u8 ht_en; | |
143 | u8 raid;/* rate adpative id */ | |
144 | u8 bwmode; | |
145 | u8 ch_offset;/* PRIME_CHNL_OFFSET */ | |
146 | u8 sgi;/* short GI */ | |
147 | u8 ampdu_en;/* tx ampdu enable */ | |
148 | u8 mdata;/* more data bit */ | |
149 | u8 pctrl;/* per packet txdesc control enable */ | |
150 | u8 triggered;/* for ap mode handling Power Saving sta */ | |
151 | u8 qsel; | |
152 | u8 eosp; | |
153 | u8 rate; | |
154 | u8 retry_ctrl; | |
155 | struct sta_info *psta; | |
156 | }; | |
157 | ||
158 | #define WLANHDR_OFFSET 64 | |
159 | ||
160 | #define NULL_FRAMETAG 0x0 | |
161 | #define DATA_FRAMETAG 0x01 | |
162 | #define L2_FRAMETAG 0x02 | |
163 | #define MGNT_FRAMETAG 0x03 | |
164 | #define AMSDU_FRAMETAG 0x04 | |
165 | ||
166 | #define EII_FRAMETAG 0x05 | |
167 | #define IEEE8023_FRAMETAG 0x06 | |
168 | ||
169 | #define MP_FRAMETAG 0x07 | |
170 | ||
171 | #define TXAGG_FRAMETAG 0x08 | |
172 | ||
173 | struct submit_ctx { | |
174 | u32 timeout_ms; /* <0: not synchronous, 0: wait forever, | |
175 | * >0: up to ms waiting | |
176 | */ | |
177 | int status; /* status for operation */ | |
178 | struct completion done; | |
179 | }; | |
180 | ||
181 | enum { | |
182 | RTW_SCTX_SUBMITTED = -1, | |
183 | RTW_SCTX_DONE_SUCCESS = 0, | |
184 | RTW_SCTX_DONE_UNKNOWN, | |
185 | RTW_SCTX_DONE_TIMEOUT, | |
186 | RTW_SCTX_DONE_BUF_ALLOC, | |
187 | RTW_SCTX_DONE_BUF_FREE, | |
188 | RTW_SCTX_DONE_WRITE_PORT_ERR, | |
189 | RTW_SCTX_DONE_TX_DESC_NA, | |
190 | RTW_SCTX_DONE_TX_DENY, | |
191 | RTW_SCTX_DONE_CCX_PKT_FAIL, | |
192 | RTW_SCTX_DONE_DRV_STOP, | |
193 | RTW_SCTX_DONE_DEV_REMOVE, | |
194 | }; | |
195 | ||
196 | void rtw_sctx_init23a(struct submit_ctx *sctx, int timeout_ms); | |
197 | int rtw_sctx_wait23a(struct submit_ctx *sctx); | |
198 | void rtw23a_sctx_done_err(struct submit_ctx **sctx, int status); | |
364e30eb LF |
199 | |
200 | struct xmit_buf { | |
201 | struct list_head list, list2; | |
202 | struct rtw_adapter *padapter; | |
203 | ||
204 | u8 *pallocated_buf; | |
205 | u8 *pbuf; | |
206 | void *priv_data; | |
207 | ||
208 | u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */ | |
209 | u16 flags; | |
210 | u32 alloc_sz; | |
211 | u32 len; | |
212 | struct submit_ctx *sctx; | |
213 | u32 ff_hwaddr; | |
214 | struct urb *pxmit_urb[8]; | |
215 | u8 bpending[8]; | |
216 | int last[8]; | |
217 | #if defined(DBG_XMIT_BUF) || defined(DBG_XMIT_BUF_EXT) | |
218 | u8 no; | |
219 | #endif | |
220 | }; | |
221 | ||
222 | struct xmit_frame { | |
223 | struct list_head list; | |
224 | struct pkt_attrib attrib; | |
225 | struct sk_buff *pkt; | |
226 | int frame_tag; | |
227 | struct rtw_adapter *padapter; | |
228 | u8 *buf_addr; | |
229 | struct xmit_buf *pxmitbuf; | |
230 | ||
231 | s8 pkt_offset; | |
232 | ||
233 | u8 ack_report; | |
234 | ||
235 | u8 ext_tag; /* 0:data, 1:mgmt */ | |
236 | }; | |
237 | ||
238 | struct tx_servq { | |
239 | struct list_head tx_pending; | |
240 | struct rtw_queue sta_pending; | |
241 | int qcnt; | |
242 | }; | |
243 | ||
244 | struct sta_xmit_priv { | |
245 | spinlock_t lock; | |
246 | int option; | |
247 | int apsd_setting; /* When bit mask is on, the associated edca | |
248 | * queue supports APSD. | |
249 | */ | |
250 | struct tx_servq be_q; /* priority == 0,3 */ | |
251 | struct tx_servq bk_q; /* priority == 1,2 */ | |
252 | struct tx_servq vi_q; /* priority == 4,5 */ | |
253 | struct tx_servq vo_q; /* priority == 6,7 */ | |
254 | struct list_head legacy_dz; | |
255 | struct list_head apsd; | |
256 | u16 txseq_tid[16]; | |
257 | }; | |
258 | ||
259 | struct hw_txqueue { | |
260 | volatile int head; | |
261 | volatile int tail; | |
262 | volatile int free_sz; /* in units of 64 bytes */ | |
263 | volatile int free_cmdsz; | |
264 | volatile int txsz[8]; | |
265 | uint ff_hwaddr; | |
266 | uint cmd_hwaddr; | |
267 | int ac_tag; | |
268 | }; | |
269 | ||
270 | struct agg_pkt_info { | |
271 | u16 offset; | |
272 | u16 pkt_len; | |
273 | }; | |
274 | ||
275 | struct xmit_priv { | |
276 | spinlock_t lock; | |
277 | ||
278 | struct semaphore xmit_sema; | |
279 | struct semaphore terminate_xmitthread_sema; | |
280 | ||
281 | struct rtw_queue be_pending; | |
282 | struct rtw_queue bk_pending; | |
283 | struct rtw_queue vi_pending; | |
284 | struct rtw_queue vo_pending; | |
285 | struct rtw_queue bm_pending; | |
286 | ||
251ccc2d | 287 | int free_xmitframe_cnt; |
364e30eb LF |
288 | struct rtw_queue free_xmit_queue; |
289 | ||
3a35058f | 290 | int free_xframe_ext_cnt; |
364e30eb LF |
291 | struct rtw_queue free_xframe_ext_queue; |
292 | ||
293 | uint frag_len; | |
294 | ||
295 | struct rtw_adapter *adapter; | |
296 | ||
364e30eb LF |
297 | u64 tx_bytes; |
298 | u64 tx_pkts; | |
299 | u64 tx_drop; | |
300 | u64 last_tx_bytes; | |
301 | u64 last_tx_pkts; | |
302 | ||
303 | struct hw_xmit *hwxmits; | |
304 | u8 hwxmit_entry; | |
f7d6e7c7 JS |
305 | u8 vcs; |
306 | u8 nqos_ssn; | |
364e30eb LF |
307 | |
308 | u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength from | |
309 | * large to small. it's value is 0->vo, 1->vi, | |
310 | * 2->be, 3->bk. | |
311 | */ | |
312 | ||
313 | struct semaphore tx_retevt;/* all tx return event; */ | |
364e30eb LF |
314 | |
315 | struct tasklet_struct xmit_tasklet; | |
364e30eb LF |
316 | |
317 | struct rtw_queue free_xmitbuf_queue; | |
318 | struct list_head xmitbuf_list; /* track buffers for cleanup */ | |
319 | struct rtw_queue pending_xmitbuf_queue; | |
320 | uint free_xmitbuf_cnt; | |
321 | ||
322 | struct rtw_queue free_xmit_extbuf_queue; | |
323 | struct list_head xmitextbuf_list; /* track buffers for cleanup */ | |
324 | uint free_xmit_extbuf_cnt; | |
325 | ||
364e30eb LF |
326 | int ack_tx; |
327 | struct mutex ack_tx_mutex; | |
328 | struct submit_ctx ack_tx_ops; | |
329 | spinlock_t lock_sctx; | |
330 | }; | |
331 | ||
332 | struct xmit_buf *rtw_alloc_xmitbuf23a_ext(struct xmit_priv *pxmitpriv); | |
333 | s32 rtw_free_xmitbuf_ext23a(struct xmit_priv *pxmitpriv, | |
334 | struct xmit_buf *pxmitbuf); | |
335 | ||
336 | struct xmit_buf *rtw_alloc_xmitbuf23a(struct xmit_priv *pxmitpriv); | |
337 | s32 rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); | |
338 | ||
339 | void rtw_count_tx_stats23a(struct rtw_adapter *padapter, | |
340 | struct xmit_frame *pxmitframe, int sz); | |
341 | void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len); | |
364e30eb LF |
342 | struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv); |
343 | struct xmit_frame *rtw_alloc_xmitframe23a_once(struct xmit_priv *pxmitpriv); | |
344 | s32 rtw_free_xmitframe23a(struct xmit_priv *pxmitpriv, | |
345 | struct xmit_frame *pxmitframe); | |
346 | void rtw_free_xmitframe_queue23a(struct xmit_priv *pxmitpriv, struct rtw_queue *pframequeue); | |
347 | struct tx_servq *rtw_get_sta_pending23a(struct rtw_adapter *padapter, | |
348 | struct sta_info *psta, int up, u8 *ac); | |
349 | s32 rtw_xmitframe_enqueue23a(struct rtw_adapter *padapter, | |
350 | struct xmit_frame *pxmitframe); | |
351 | struct xmit_frame *rtw_dequeue_xframe23a(struct xmit_priv *pxmitpriv, | |
352 | struct hw_xmit *phwxmit_i, int entry); | |
353 | s32 rtw_xmit23a_classifier(struct rtw_adapter *padapter, | |
354 | struct xmit_frame *pxmitframe); | |
364e30eb LF |
355 | s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, |
356 | struct xmit_frame *pxmitframe); | |
357 | s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); | |
358 | void _rtw_init_sta_xmit_priv23a(struct sta_xmit_priv *psta_xmitpriv); | |
359 | ||
360 | s32 rtw_txframes_pending23a(struct rtw_adapter *padapter); | |
361 | s32 rtw_txframes_sta_ac_pending23a(struct rtw_adapter *padapter, | |
362 | struct pkt_attrib *pattrib); | |
363 | void rtw_init_hwxmits23a(struct hw_xmit *phwxmit, int entry); | |
269746a4 | 364 | int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, |
364e30eb LF |
365 | struct rtw_adapter *padapter); |
366 | void _rtw_free_xmit_priv23a(struct xmit_priv *pxmitpriv); | |
367 | void rtw_alloc_hwxmits23a(struct rtw_adapter *padapter); | |
368 | void rtw_free_hwxmits23a(struct rtw_adapter *padapter); | |
369 | int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *pkt); | |
370 | #if defined(CONFIG_8723AU_AP_MODE) | |
371 | int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, | |
372 | struct xmit_frame *pxmitframe); | |
373 | void stop_sta_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta); | |
374 | void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta); | |
375 | void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, | |
376 | struct sta_info *psta); | |
377 | #endif | |
378 | u8 qos_acm23a(u8 acm_mask, u8 priority); | |
379 | u32 rtw_get_ff_hwaddr23a(struct xmit_frame *pxmitframe); | |
380 | int rtw_ack_tx_wait23a(struct xmit_priv *pxmitpriv, u32 timeout_ms); | |
364e30eb LF |
381 | |
382 | /* include after declaring struct xmit_buf, in order to avoid warning */ | |
383 | #include <xmit_osdep.h> | |
384 | ||
385 | #endif /* _RTL871X_XMIT_H_ */ |