Commit | Line | Data |
---|---|---|
7f8a0fba 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 | * | |
7f8a0fba LF |
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 (20480) /* 20k */ | |
22 | #define NR_XMITBUFF (4) | |
23 | ||
24 | #define XMITBUF_ALIGN_SZ 4 | |
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 : (dot11txpn.val+1);\ | |
55 | } while (0) | |
56 | ||
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 : (dot11txpn.val+1);\ | |
69 | } while (0) | |
70 | ||
71 | #define AES_IV(pattrib_iv, dot11txpn, keyidx)\ | |
72 | do { \ | |
73 | pattrib_iv[0] = dot11txpn._byte_.TSC0; \ | |
74 | pattrib_iv[1] = dot11txpn._byte_.TSC1; \ | |
75 | pattrib_iv[2] = 0; \ | |
76 | pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6); \ | |
77 | pattrib_iv[4] = dot11txpn._byte_.TSC2; \ | |
78 | pattrib_iv[5] = dot11txpn._byte_.TSC3; \ | |
79 | pattrib_iv[6] = dot11txpn._byte_.TSC4; \ | |
80 | pattrib_iv[7] = dot11txpn._byte_.TSC5; \ | |
81 | dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\ | |
82 | } while (0) | |
83 | ||
84 | #define HWXMIT_ENTRY 4 | |
85 | ||
86 | #define TXDESC_SIZE 32 | |
87 | ||
88 | #define PACKET_OFFSET_SZ (8) | |
89 | #define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ) | |
90 | ||
91 | struct tx_desc { | |
92 | /* DWORD 0 */ | |
93 | __le32 txdw0; | |
94 | __le32 txdw1; | |
95 | __le32 txdw2; | |
96 | __le32 txdw3; | |
97 | __le32 txdw4; | |
98 | __le32 txdw5; | |
99 | __le32 txdw6; | |
100 | __le32 txdw7; | |
101 | }; | |
102 | ||
7f8a0fba LF |
103 | struct hw_xmit { |
104 | struct __queue *sta_queue; | |
105 | int accnt; | |
106 | }; | |
107 | ||
108 | /* reduce size */ | |
109 | struct pkt_attrib { | |
110 | u8 type; | |
111 | u8 subtype; | |
112 | u8 bswenc; | |
113 | u8 dhcp_pkt; | |
114 | u16 ether_type; | |
115 | u16 seqnum; | |
116 | u16 pkt_hdrlen; /* the original 802.3 pkt header len */ | |
117 | u16 hdrlen; /* the WLAN Header Len */ | |
118 | u32 pktlen; /* the original 802.3 pkt raw_data len (not include | |
119 | * ether_hdr data) */ | |
120 | u32 last_txcmdsz; | |
121 | u8 nr_frags; | |
122 | u8 encrypt; /* when 0 indicate no encrypt. when non-zero, | |
123 | * indicate the encrypt algorith */ | |
124 | u8 iv_len; | |
125 | u8 icv_len; | |
126 | u8 iv[18]; | |
127 | u8 icv[16]; | |
128 | u8 priority; | |
129 | u8 ack_policy; | |
130 | u8 mac_id; | |
131 | u8 vcs_mode; /* virtual carrier sense method */ | |
132 | u8 dst[ETH_ALEN]; | |
133 | u8 src[ETH_ALEN]; | |
134 | u8 ta[ETH_ALEN]; | |
135 | u8 ra[ETH_ALEN]; | |
136 | u8 key_idx; | |
137 | u8 qos_en; | |
138 | u8 ht_en; | |
139 | u8 raid;/* rate adpative id */ | |
140 | u8 bwmode; | |
141 | u8 ch_offset;/* PRIME_CHNL_OFFSET */ | |
142 | u8 sgi;/* short GI */ | |
143 | u8 ampdu_en;/* tx ampdu enable */ | |
144 | u8 mdata;/* more data bit */ | |
145 | u8 pctrl;/* per packet txdesc control enable */ | |
146 | u8 triggered;/* for ap mode handling Power Saving sta */ | |
147 | u8 qsel; | |
148 | u8 eosp; | |
149 | u8 rate; | |
150 | u8 intel_proxim; | |
151 | u8 retry_ctrl; | |
152 | struct sta_info *psta; | |
153 | }; | |
154 | ||
155 | #define WLANHDR_OFFSET 64 | |
156 | ||
157 | #define NULL_FRAMETAG (0x0) | |
158 | #define DATA_FRAMETAG 0x01 | |
159 | #define L2_FRAMETAG 0x02 | |
160 | #define MGNT_FRAMETAG 0x03 | |
161 | #define AMSDU_FRAMETAG 0x04 | |
162 | ||
163 | #define EII_FRAMETAG 0x05 | |
164 | #define IEEE8023_FRAMETAG 0x06 | |
165 | ||
166 | #define MP_FRAMETAG 0x07 | |
167 | ||
168 | #define TXAGG_FRAMETAG 0x08 | |
169 | ||
170 | struct submit_ctx { | |
171 | u32 submit_time; /* */ | |
172 | u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */ | |
173 | int status; /* status for operation */ | |
174 | struct completion done; | |
175 | }; | |
176 | ||
177 | enum { | |
178 | RTW_SCTX_SUBMITTED = -1, | |
179 | RTW_SCTX_DONE_SUCCESS = 0, | |
180 | RTW_SCTX_DONE_UNKNOWN, | |
181 | RTW_SCTX_DONE_TIMEOUT, | |
182 | RTW_SCTX_DONE_BUF_ALLOC, | |
183 | RTW_SCTX_DONE_BUF_FREE, | |
184 | RTW_SCTX_DONE_WRITE_PORT_ERR, | |
185 | RTW_SCTX_DONE_TX_DESC_NA, | |
186 | RTW_SCTX_DONE_TX_DENY, | |
187 | RTW_SCTX_DONE_CCX_PKT_FAIL, | |
188 | RTW_SCTX_DONE_DRV_STOP, | |
189 | RTW_SCTX_DONE_DEV_REMOVE, | |
190 | }; | |
191 | ||
192 | void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms); | |
193 | int rtw_sctx_wait(struct submit_ctx *sctx); | |
194 | void rtw_sctx_done_err(struct submit_ctx **sctx, int status); | |
7f8a0fba LF |
195 | |
196 | struct xmit_buf { | |
197 | struct list_head list; | |
198 | struct adapter *padapter; | |
199 | u8 *pallocated_buf; | |
200 | u8 *pbuf; | |
201 | void *priv_data; | |
202 | u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */ | |
203 | u16 flags; | |
204 | u32 alloc_sz; | |
205 | u32 len; | |
206 | struct submit_ctx *sctx; | |
207 | u32 ff_hwaddr; | |
208 | struct urb *pxmit_urb[8]; | |
209 | dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ | |
210 | u8 bpending[8]; | |
211 | int last[8]; | |
212 | }; | |
213 | ||
214 | struct xmit_frame { | |
215 | struct list_head list; | |
216 | struct pkt_attrib attrib; | |
217 | struct sk_buff *pkt; | |
218 | int frame_tag; | |
219 | struct adapter *padapter; | |
220 | u8 *buf_addr; | |
221 | struct xmit_buf *pxmitbuf; | |
222 | ||
223 | u8 agg_num; | |
224 | s8 pkt_offset; | |
225 | u8 ack_report; | |
226 | }; | |
227 | ||
228 | struct tx_servq { | |
229 | struct list_head tx_pending; | |
230 | struct __queue sta_pending; | |
231 | int qcnt; | |
232 | }; | |
233 | ||
234 | struct sta_xmit_priv { | |
235 | spinlock_t lock; | |
236 | int option; | |
237 | int apsd_setting; /* When bit mask is on, the associated edca | |
238 | * queue supports APSD. */ | |
239 | struct tx_servq be_q; /* priority == 0,3 */ | |
240 | struct tx_servq bk_q; /* priority == 1,2 */ | |
241 | struct tx_servq vi_q; /* priority == 4,5 */ | |
242 | struct tx_servq vo_q; /* priority == 6,7 */ | |
243 | struct list_head legacy_dz; | |
244 | struct list_head apsd; | |
245 | u16 txseq_tid[16]; | |
246 | }; | |
247 | ||
248 | struct hw_txqueue { | |
249 | volatile int head; | |
250 | volatile int tail; | |
251 | volatile int free_sz; /* in units of 64 bytes */ | |
252 | volatile int free_cmdsz; | |
253 | volatile int txsz[8]; | |
254 | uint ff_hwaddr; | |
255 | uint cmd_hwaddr; | |
256 | int ac_tag; | |
257 | }; | |
258 | ||
7f8a0fba LF |
259 | struct xmit_priv { |
260 | spinlock_t lock; | |
7f8a0fba LF |
261 | struct __queue be_pending; |
262 | struct __queue bk_pending; | |
263 | struct __queue vi_pending; | |
264 | struct __queue vo_pending; | |
265 | struct __queue bm_pending; | |
266 | u8 *pallocated_frame_buf; | |
267 | u8 *pxmit_frame_buf; | |
268 | uint free_xmitframe_cnt; | |
269 | struct __queue free_xmit_queue; | |
270 | uint frag_len; | |
271 | struct adapter *adapter; | |
272 | u8 vcs_setting; | |
273 | u8 vcs; | |
274 | u8 vcs_type; | |
275 | u64 tx_bytes; | |
276 | u64 tx_pkts; | |
277 | u64 tx_drop; | |
278 | u64 last_tx_bytes; | |
279 | u64 last_tx_pkts; | |
280 | struct hw_xmit *hwxmits; | |
281 | u8 hwxmit_entry; | |
282 | u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength | |
283 | * from large to small. it's value is 0->vo, | |
284 | * 1->vi, 2->be, 3->bk. */ | |
7f8a0fba LF |
285 | u8 txirp_cnt;/* */ |
286 | struct tasklet_struct xmit_tasklet; | |
287 | /* per AC pending irp */ | |
288 | int beq_cnt; | |
289 | int bkq_cnt; | |
290 | int viq_cnt; | |
291 | int voq_cnt; | |
292 | struct __queue free_xmitbuf_queue; | |
293 | struct __queue pending_xmitbuf_queue; | |
294 | u8 *pallocated_xmitbuf; | |
295 | u8 *pxmitbuf; | |
296 | uint free_xmitbuf_cnt; | |
297 | struct __queue free_xmit_extbuf_queue; | |
298 | u8 *pallocated_xmit_extbuf; | |
299 | u8 *pxmit_extbuf; | |
300 | uint free_xmit_extbuf_cnt; | |
301 | u16 nqos_ssn; | |
302 | int ack_tx; | |
303 | struct mutex ack_tx_mutex; | |
304 | struct submit_ctx ack_tx_ops; | |
305 | }; | |
306 | ||
307 | struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv); | |
308 | s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, | |
309 | struct xmit_buf *pxmitbuf); | |
310 | struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv); | |
311 | s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, | |
312 | struct xmit_buf *pxmitbuf); | |
313 | void rtw_count_tx_stats(struct adapter *padapter, | |
314 | struct xmit_frame *pxmitframe, int sz); | |
315 | void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len); | |
316 | s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, | |
317 | struct pkt_attrib *pattrib); | |
318 | s32 rtw_put_snap(u8 *data, u16 h_proto); | |
319 | ||
320 | struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv); | |
321 | s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, | |
322 | struct xmit_frame *pxmitframe); | |
323 | void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, | |
324 | struct __queue *pframequeue); | |
325 | struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, | |
326 | struct sta_info *psta, int up, u8 *ac); | |
327 | s32 rtw_xmitframe_enqueue(struct adapter *padapter, | |
328 | struct xmit_frame *pxmitframe); | |
329 | struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, | |
330 | struct hw_xmit *phwxmit_i, int entry); | |
331 | ||
332 | s32 rtw_xmit_classifier(struct adapter *padapter, | |
333 | struct xmit_frame *pxmitframe); | |
334 | u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib); | |
335 | #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib) | |
336 | s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, | |
337 | struct xmit_frame *pxmitframe); | |
338 | s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); | |
339 | void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv); | |
340 | s32 rtw_txframes_pending(struct adapter *padapter); | |
341 | s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, | |
342 | struct pkt_attrib *pattrib); | |
343 | void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry); | |
344 | s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); | |
345 | void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv); | |
346 | void rtw_alloc_hwxmits(struct adapter *padapter); | |
347 | void rtw_free_hwxmits(struct adapter *padapter); | |
348 | s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt); | |
349 | ||
350 | #if defined(CONFIG_88EU_AP_MODE) | |
351 | int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe); | |
352 | void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta); | |
353 | void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta); | |
354 | void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta); | |
355 | #endif | |
356 | ||
357 | u8 qos_acm(u8 acm_mask, u8 priority); | |
358 | u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe); | |
359 | int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms); | |
360 | void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status); | |
361 | ||
362 | /* include after declaring struct xmit_buf, in order to avoid warning */ | |
363 | #include <xmit_osdep.h> | |
364 | ||
365 | #endif /* _RTL871X_XMIT_H_ */ |