blob: 65a33a07c8ee27bba8f0728ead8464d5575d0a23 [file] [log] [blame]
Larry Finger364e30e2014-03-28 21:37:41 -05001/******************************************************************************
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) \
49do { \
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) \
59do { \
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)\
73do { \
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
93struct tx_desc {
94 /* DWORD 0 */
95 unsigned int txdw0;
96 unsigned int txdw1;
97 unsigned int txdw2;
98 unsigned int txdw3;
99 unsigned int txdw4;
100 unsigned int txdw5;
101 unsigned int txdw6;
102 unsigned int txdw7;
103};
104
105union txdesc {
106 struct tx_desc txdesc;
107 unsigned int value[TXDESC_SIZE>>2];
108};
109
110struct hw_xmit {
111 struct rtw_queue *sta_queue;
112 int accnt;
113};
114
115/* reduce size */
116struct pkt_attrib {
117 u8 type;
118 u8 subtype;
119 u8 bswenc;
120 u8 dhcp_pkt;
121 u16 ether_type;
122 u16 seqnum;
123 u16 pkt_hdrlen; /* the original 802.3 pkt header len */
124 u16 hdrlen; /* the WLAN Header Len */
125 u32 pktlen; /* the original 802.3 pkt raw_data len */
126 u32 last_txcmdsz;
127 u8 nr_frags;
128 u8 encrypt; /* when 0 indicate no encrypt. */
129 u8 iv_len;
130 u8 icv_len;
131 u8 iv[18];
132 u8 icv[16];
133 u8 priority;
134 u8 ack_policy;
135 u8 mac_id;
136 u8 vcs_mode; /* virtual carrier sense method */
137 u8 dst[ETH_ALEN];
138 u8 src[ETH_ALEN];
139 u8 ta[ETH_ALEN];
140 u8 ra[ETH_ALEN];
141 u8 key_idx;
142 u8 qos_en;
143 u8 ht_en;
144 u8 raid;/* rate adpative id */
145 u8 bwmode;
146 u8 ch_offset;/* PRIME_CHNL_OFFSET */
147 u8 sgi;/* short GI */
148 u8 ampdu_en;/* tx ampdu enable */
149 u8 mdata;/* more data bit */
150 u8 pctrl;/* per packet txdesc control enable */
151 u8 triggered;/* for ap mode handling Power Saving sta */
152 u8 qsel;
153 u8 eosp;
154 u8 rate;
155 u8 retry_ctrl;
156 struct sta_info *psta;
157};
158
159#define WLANHDR_OFFSET 64
160
161#define NULL_FRAMETAG 0x0
162#define DATA_FRAMETAG 0x01
163#define L2_FRAMETAG 0x02
164#define MGNT_FRAMETAG 0x03
165#define AMSDU_FRAMETAG 0x04
166
167#define EII_FRAMETAG 0x05
168#define IEEE8023_FRAMETAG 0x06
169
170#define MP_FRAMETAG 0x07
171
172#define TXAGG_FRAMETAG 0x08
173
174struct submit_ctx {
175 u32 timeout_ms; /* <0: not synchronous, 0: wait forever,
176 * >0: up to ms waiting
177 */
178 int status; /* status for operation */
179 struct completion done;
180};
181
182enum {
183 RTW_SCTX_SUBMITTED = -1,
184 RTW_SCTX_DONE_SUCCESS = 0,
185 RTW_SCTX_DONE_UNKNOWN,
186 RTW_SCTX_DONE_TIMEOUT,
187 RTW_SCTX_DONE_BUF_ALLOC,
188 RTW_SCTX_DONE_BUF_FREE,
189 RTW_SCTX_DONE_WRITE_PORT_ERR,
190 RTW_SCTX_DONE_TX_DESC_NA,
191 RTW_SCTX_DONE_TX_DENY,
192 RTW_SCTX_DONE_CCX_PKT_FAIL,
193 RTW_SCTX_DONE_DRV_STOP,
194 RTW_SCTX_DONE_DEV_REMOVE,
195};
196
197void rtw_sctx_init23a(struct submit_ctx *sctx, int timeout_ms);
198int rtw_sctx_wait23a(struct submit_ctx *sctx);
199void rtw23a_sctx_done_err(struct submit_ctx **sctx, int status);
200void rtw_sctx_done23a(struct submit_ctx **sctx);
201
202struct xmit_buf {
203 struct list_head list, list2;
204 struct rtw_adapter *padapter;
205
206 u8 *pallocated_buf;
207 u8 *pbuf;
208 void *priv_data;
209
210 u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */
211 u16 flags;
212 u32 alloc_sz;
213 u32 len;
214 struct submit_ctx *sctx;
215 u32 ff_hwaddr;
216 struct urb *pxmit_urb[8];
217 u8 bpending[8];
218 int last[8];
219#if defined(DBG_XMIT_BUF) || defined(DBG_XMIT_BUF_EXT)
220 u8 no;
221#endif
222};
223
224struct xmit_frame {
225 struct list_head list;
226 struct pkt_attrib attrib;
227 struct sk_buff *pkt;
228 int frame_tag;
229 struct rtw_adapter *padapter;
230 u8 *buf_addr;
231 struct xmit_buf *pxmitbuf;
232
233 s8 pkt_offset;
234
235 u8 ack_report;
236
237 u8 ext_tag; /* 0:data, 1:mgmt */
238};
239
240struct tx_servq {
241 struct list_head tx_pending;
242 struct rtw_queue sta_pending;
243 int qcnt;
244};
245
246struct sta_xmit_priv {
247 spinlock_t lock;
248 int option;
249 int apsd_setting; /* When bit mask is on, the associated edca
250 * queue supports APSD.
251 */
252 struct tx_servq be_q; /* priority == 0,3 */
253 struct tx_servq bk_q; /* priority == 1,2 */
254 struct tx_servq vi_q; /* priority == 4,5 */
255 struct tx_servq vo_q; /* priority == 6,7 */
256 struct list_head legacy_dz;
257 struct list_head apsd;
258 u16 txseq_tid[16];
259};
260
261struct hw_txqueue {
262 volatile int head;
263 volatile int tail;
264 volatile int free_sz; /* in units of 64 bytes */
265 volatile int free_cmdsz;
266 volatile int txsz[8];
267 uint ff_hwaddr;
268 uint cmd_hwaddr;
269 int ac_tag;
270};
271
272struct agg_pkt_info {
273 u16 offset;
274 u16 pkt_len;
275};
276
277struct xmit_priv {
278 spinlock_t lock;
279
280 struct semaphore xmit_sema;
281 struct semaphore terminate_xmitthread_sema;
282
283 struct rtw_queue be_pending;
284 struct rtw_queue bk_pending;
285 struct rtw_queue vi_pending;
286 struct rtw_queue vo_pending;
287 struct rtw_queue bm_pending;
288
289 u8 *pallocated_frame_buf;
290 u8 *pxmit_frame_buf;
291 uint free_xmitframe_cnt;
292 struct rtw_queue free_xmit_queue;
293
294 u8 *xframe_ext_alloc_addr;
295 u8 *xframe_ext;
296 uint free_xframe_ext_cnt;
297 struct rtw_queue free_xframe_ext_queue;
298
299 uint frag_len;
300
301 struct rtw_adapter *adapter;
302
303 u8 vcs_setting;
304 u8 vcs;
305 u8 vcs_type;
306
307 u64 tx_bytes;
308 u64 tx_pkts;
309 u64 tx_drop;
310 u64 last_tx_bytes;
311 u64 last_tx_pkts;
312
313 struct hw_xmit *hwxmits;
314 u8 hwxmit_entry;
315
316 u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength from
317 * large to small. it's value is 0->vo, 1->vi,
318 * 2->be, 3->bk.
319 */
320
321 struct semaphore tx_retevt;/* all tx return event; */
322 u8 txirp_cnt;/* */
323
324 struct tasklet_struct xmit_tasklet;
325 /* per AC pending irp */
326 int beq_cnt;
327 int bkq_cnt;
328 int viq_cnt;
329 int voq_cnt;
330
331 struct rtw_queue free_xmitbuf_queue;
332 struct list_head xmitbuf_list; /* track buffers for cleanup */
333 struct rtw_queue pending_xmitbuf_queue;
334 uint free_xmitbuf_cnt;
335
336 struct rtw_queue free_xmit_extbuf_queue;
337 struct list_head xmitextbuf_list; /* track buffers for cleanup */
338 uint free_xmit_extbuf_cnt;
339
340 u16 nqos_ssn;
341 int ack_tx;
342 struct mutex ack_tx_mutex;
343 struct submit_ctx ack_tx_ops;
344 spinlock_t lock_sctx;
345};
346
347struct xmit_buf *rtw_alloc_xmitbuf23a_ext(struct xmit_priv *pxmitpriv);
348s32 rtw_free_xmitbuf_ext23a(struct xmit_priv *pxmitpriv,
349 struct xmit_buf *pxmitbuf);
350
351struct xmit_buf *rtw_alloc_xmitbuf23a(struct xmit_priv *pxmitpriv);
352s32 rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
353
354void rtw_count_tx_stats23a(struct rtw_adapter *padapter,
355 struct xmit_frame *pxmitframe, int sz);
356void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len);
357s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr,
358 struct pkt_attrib *pattrib);
359s32 rtw_put_snap23a(u8 *data, u16 h_proto);
360struct xmit_frame *rtw_alloc_xmitframe23a(struct xmit_priv *pxmitpriv);
361struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv);
362struct xmit_frame *rtw_alloc_xmitframe23a_once(struct xmit_priv *pxmitpriv);
363s32 rtw_free_xmitframe23a(struct xmit_priv *pxmitpriv,
364 struct xmit_frame *pxmitframe);
365void rtw_free_xmitframe_queue23a(struct xmit_priv *pxmitpriv, struct rtw_queue *pframequeue);
366struct tx_servq *rtw_get_sta_pending23a(struct rtw_adapter *padapter,
367 struct sta_info *psta, int up, u8 *ac);
368s32 rtw_xmitframe_enqueue23a(struct rtw_adapter *padapter,
369 struct xmit_frame *pxmitframe);
370struct xmit_frame *rtw_dequeue_xframe23a(struct xmit_priv *pxmitpriv,
371 struct hw_xmit *phwxmit_i, int entry);
372s32 rtw_xmit23a_classifier(struct rtw_adapter *padapter,
373 struct xmit_frame *pxmitframe);
374u32 rtw_calculate_wlan_pkt_size_by_attribue23a(struct pkt_attrib *pattrib);
375#define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue23a(&f->attrib)
376s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
377 struct xmit_frame *pxmitframe);
378s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
379void _rtw_init_sta_xmit_priv23a(struct sta_xmit_priv *psta_xmitpriv);
380
381s32 rtw_txframes_pending23a(struct rtw_adapter *padapter);
382s32 rtw_txframes_sta_ac_pending23a(struct rtw_adapter *padapter,
383 struct pkt_attrib *pattrib);
384void rtw_init_hwxmits23a(struct hw_xmit *phwxmit, int entry);
385s32 _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv,
386 struct rtw_adapter *padapter);
387void _rtw_free_xmit_priv23a(struct xmit_priv *pxmitpriv);
388void rtw_alloc_hwxmits23a(struct rtw_adapter *padapter);
389void rtw_free_hwxmits23a(struct rtw_adapter *padapter);
390int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *pkt);
391#if defined(CONFIG_8723AU_AP_MODE)
392int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter,
393 struct xmit_frame *pxmitframe);
394void stop_sta_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta);
395void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta);
396void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter,
397 struct sta_info *psta);
398#endif
399u8 qos_acm23a(u8 acm_mask, u8 priority);
400u32 rtw_get_ff_hwaddr23a(struct xmit_frame *pxmitframe);
401int rtw_ack_tx_wait23a(struct xmit_priv *pxmitpriv, u32 timeout_ms);
402void rtw_ack_tx_done23a(struct xmit_priv *pxmitpriv, int status);
403
404/* include after declaring struct xmit_buf, in order to avoid warning */
405#include <xmit_osdep.h>
406
407#endif /* _RTL871X_XMIT_H_ */