1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
23 #include <osdep_service.h>
24 #include <drv_types.h>
26 #define MAX_XMITBUF_SZ (20480) /* 20k */
27 #define NR_XMITBUFF (4)
29 #define XMITBUF_ALIGN_SZ 4
31 /* xmit extension buff defination */
32 #define MAX_XMIT_EXTBUF_SZ (1536)
33 #define NR_XMIT_EXTBUFF (32)
35 #define MAX_NUMBLKS (1)
37 #define XMIT_VO_QUEUE (0)
38 #define XMIT_VI_QUEUE (1)
39 #define XMIT_BE_QUEUE (2)
40 #define XMIT_BK_QUEUE (3)
42 #define VO_QUEUE_INX 0
43 #define VI_QUEUE_INX 1
44 #define BE_QUEUE_INX 2
45 #define BK_QUEUE_INX 3
46 #define BCN_QUEUE_INX 4
47 #define MGT_QUEUE_INX 5
48 #define HIGH_QUEUE_INX 6
49 #define TXCMD_QUEUE_INX 7
51 #define HW_QUEUE_ENTRY 8
53 #define WEP_IV(pattrib_iv, dot11txpn, keyidx)\
55 pattrib_iv[0] = dot11txpn._byte_.TSC0;\
56 pattrib_iv[1] = dot11txpn._byte_.TSC1;\
57 pattrib_iv[2] = dot11txpn._byte_.TSC2;\
58 pattrib_iv[3] = ((keyidx & 0x3)<<6);\
59 dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val+1);\
63 #define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\
65 pattrib_iv[0] = dot11txpn._byte_.TSC1;\
66 pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\
67 pattrib_iv[2] = dot11txpn._byte_.TSC0;\
68 pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
69 pattrib_iv[4] = dot11txpn._byte_.TSC2;\
70 pattrib_iv[5] = dot11txpn._byte_.TSC3;\
71 pattrib_iv[6] = dot11txpn._byte_.TSC4;\
72 pattrib_iv[7] = dot11txpn._byte_.TSC5;\
73 dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\
76 #define AES_IV(pattrib_iv, dot11txpn, keyidx)\
78 pattrib_iv[0] = dot11txpn._byte_.TSC0; \
79 pattrib_iv[1] = dot11txpn._byte_.TSC1; \
81 pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6); \
82 pattrib_iv[4] = dot11txpn._byte_.TSC2; \
83 pattrib_iv[5] = dot11txpn._byte_.TSC3; \
84 pattrib_iv[6] = dot11txpn._byte_.TSC4; \
85 pattrib_iv[7] = dot11txpn._byte_.TSC5; \
86 dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\
89 #define HWXMIT_ENTRY 4
91 #define TXDESC_SIZE 32
93 #define PACKET_OFFSET_SZ (8)
94 #define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ)
109 struct tx_desc txdesc;
110 unsigned int value[TXDESC_SIZE>>2];
114 struct __queue *sta_queue;
126 u16 pkt_hdrlen; /* the original 802.3 pkt header len */
127 u16 hdrlen; /* the WLAN Header Len */
128 u32 pktlen; /* the original 802.3 pkt raw_data len (not include
132 u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
133 * indicate the encrypt algorith */
141 u8 vcs_mode; /* virtual carrier sense method */
149 u8 raid;/* rate adpative id */
151 u8 ch_offset;/* PRIME_CHNL_OFFSET */
152 u8 sgi;/* short GI */
153 u8 ampdu_en;/* tx ampdu enable */
154 u8 mdata;/* more data bit */
155 u8 pctrl;/* per packet txdesc control enable */
156 u8 triggered;/* for ap mode handling Power Saving sta */
162 struct sta_info *psta;
165 #define WLANHDR_OFFSET 64
167 #define NULL_FRAMETAG (0x0)
168 #define DATA_FRAMETAG 0x01
169 #define L2_FRAMETAG 0x02
170 #define MGNT_FRAMETAG 0x03
171 #define AMSDU_FRAMETAG 0x04
173 #define EII_FRAMETAG 0x05
174 #define IEEE8023_FRAMETAG 0x06
176 #define MP_FRAMETAG 0x07
178 #define TXAGG_FRAMETAG 0x08
181 u32 submit_time; /* */
182 u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */
183 int status; /* status for operation */
184 struct completion done;
188 RTW_SCTX_SUBMITTED = -1,
189 RTW_SCTX_DONE_SUCCESS = 0,
190 RTW_SCTX_DONE_UNKNOWN,
191 RTW_SCTX_DONE_TIMEOUT,
192 RTW_SCTX_DONE_BUF_ALLOC,
193 RTW_SCTX_DONE_BUF_FREE,
194 RTW_SCTX_DONE_WRITE_PORT_ERR,
195 RTW_SCTX_DONE_TX_DESC_NA,
196 RTW_SCTX_DONE_TX_DENY,
197 RTW_SCTX_DONE_CCX_PKT_FAIL,
198 RTW_SCTX_DONE_DRV_STOP,
199 RTW_SCTX_DONE_DEV_REMOVE,
202 void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms);
203 int rtw_sctx_wait(struct submit_ctx *sctx);
204 void rtw_sctx_done_err(struct submit_ctx **sctx, int status);
205 void rtw_sctx_done(struct submit_ctx **sctx);
208 struct list_head list;
209 struct adapter *padapter;
213 u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */
217 struct submit_ctx *sctx;
219 struct urb *pxmit_urb[8];
220 dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */
226 struct list_head list;
227 struct pkt_attrib attrib;
230 struct adapter *padapter;
232 struct xmit_buf *pxmitbuf;
240 struct list_head tx_pending;
241 struct __queue sta_pending;
245 struct sta_xmit_priv {
248 int apsd_setting; /* When bit mask is on, the associated edca
249 * queue supports APSD. */
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;
262 volatile int free_sz; /* in units of 64 bytes */
263 volatile int free_cmdsz;
264 volatile int txsz[8];
270 struct agg_pkt_info {
277 struct semaphore xmit_sema;
278 struct semaphore terminate_xmitthread_sema;
279 struct __queue be_pending;
280 struct __queue bk_pending;
281 struct __queue vi_pending;
282 struct __queue vo_pending;
283 struct __queue bm_pending;
284 u8 *pallocated_frame_buf;
286 uint free_xmitframe_cnt;
287 struct __queue free_xmit_queue;
289 struct adapter *adapter;
298 struct hw_xmit *hwxmits;
300 u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength
301 * from large to small. it's value is 0->vo,
302 * 1->vi, 2->be, 3->bk. */
303 struct semaphore tx_retevt;/* all tx return event; */
305 struct tasklet_struct xmit_tasklet;
306 /* per AC pending irp */
311 struct __queue free_xmitbuf_queue;
312 struct __queue pending_xmitbuf_queue;
313 u8 *pallocated_xmitbuf;
315 uint free_xmitbuf_cnt;
316 struct __queue free_xmit_extbuf_queue;
317 u8 *pallocated_xmit_extbuf;
319 uint free_xmit_extbuf_cnt;
322 struct mutex ack_tx_mutex;
323 struct submit_ctx ack_tx_ops;
326 struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv);
327 s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv,
328 struct xmit_buf *pxmitbuf);
329 struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
330 s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv,
331 struct xmit_buf *pxmitbuf);
332 void rtw_count_tx_stats(struct adapter *padapter,
333 struct xmit_frame *pxmitframe, int sz);
334 void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len);
335 s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr,
336 struct pkt_attrib *pattrib);
337 s32 rtw_put_snap(u8 *data, u16 h_proto);
339 struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv);
340 s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv,
341 struct xmit_frame *pxmitframe);
342 void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
343 struct __queue *pframequeue);
344 struct tx_servq *rtw_get_sta_pending(struct adapter *padapter,
345 struct sta_info *psta, int up, u8 *ac);
346 s32 rtw_xmitframe_enqueue(struct adapter *padapter,
347 struct xmit_frame *pxmitframe);
348 struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv,
349 struct hw_xmit *phwxmit_i, int entry);
351 s32 rtw_xmit_classifier(struct adapter *padapter,
352 struct xmit_frame *pxmitframe);
353 u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib);
354 #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib)
355 s32 rtw_xmitframe_coalesce(struct 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_priv(struct sta_xmit_priv *psta_xmitpriv);
359 s32 rtw_txframes_pending(struct adapter *padapter);
360 s32 rtw_txframes_sta_ac_pending(struct adapter *padapter,
361 struct pkt_attrib *pattrib);
362 void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry);
363 s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
364 void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
365 void rtw_alloc_hwxmits(struct adapter *padapter);
366 void rtw_free_hwxmits(struct adapter *padapter);
367 s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
369 #if defined(CONFIG_88EU_AP_MODE)
370 int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
371 void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta);
372 void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta);
373 void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta);
376 u8 qos_acm(u8 acm_mask, u8 priority);
377 u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe);
378 int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms);
379 void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status);
381 /* include after declaring struct xmit_buf, in order to avoid warning */
382 #include <xmit_osdep.h>
384 #endif /* _RTL871X_XMIT_H_ */