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 __queue *sta_queue;
121 u16 pkt_hdrlen; /* the original 802.3 pkt header len */
122 u16 hdrlen; /* the WLAN Header Len */
123 u32 pktlen; /* the original 802.3 pkt raw_data len (not include
127 u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
128 * indicate the encrypt algorith */
136 u8 vcs_mode; /* virtual carrier sense method */
144 u8 raid;/* rate adpative id */
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 */
157 struct sta_info *psta;
160 #define WLANHDR_OFFSET 64
162 #define NULL_FRAMETAG (0x0)
163 #define DATA_FRAMETAG 0x01
164 #define L2_FRAMETAG 0x02
165 #define MGNT_FRAMETAG 0x03
166 #define AMSDU_FRAMETAG 0x04
168 #define EII_FRAMETAG 0x05
169 #define IEEE8023_FRAMETAG 0x06
171 #define MP_FRAMETAG 0x07
173 #define TXAGG_FRAMETAG 0x08
176 u32 submit_time; /* */
177 u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */
178 int status; /* status for operation */
179 struct completion done;
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,
197 void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms);
198 int rtw_sctx_wait(struct submit_ctx *sctx);
199 void rtw_sctx_done_err(struct submit_ctx **sctx, int status);
200 void rtw_sctx_done(struct submit_ctx **sctx);
203 struct list_head list;
204 struct adapter *padapter;
208 u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */
212 struct submit_ctx *sctx;
214 struct urb *pxmit_urb[8];
215 dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */
221 struct list_head list;
222 struct pkt_attrib attrib;
225 struct adapter *padapter;
227 struct xmit_buf *pxmitbuf;
235 struct list_head tx_pending;
236 struct __queue sta_pending;
240 struct sta_xmit_priv {
243 int apsd_setting; /* When bit mask is on, the associated edca
244 * queue supports APSD. */
245 struct tx_servq be_q; /* priority == 0,3 */
246 struct tx_servq bk_q; /* priority == 1,2 */
247 struct tx_servq vi_q; /* priority == 4,5 */
248 struct tx_servq vo_q; /* priority == 6,7 */
249 struct list_head legacy_dz;
250 struct list_head apsd;
257 volatile int free_sz; /* in units of 64 bytes */
258 volatile int free_cmdsz;
259 volatile int txsz[8];
265 struct agg_pkt_info {
272 struct semaphore xmit_sema;
273 struct semaphore terminate_xmitthread_sema;
274 struct __queue be_pending;
275 struct __queue bk_pending;
276 struct __queue vi_pending;
277 struct __queue vo_pending;
278 struct __queue bm_pending;
279 u8 *pallocated_frame_buf;
281 uint free_xmitframe_cnt;
282 struct __queue free_xmit_queue;
284 struct adapter *adapter;
293 struct hw_xmit *hwxmits;
295 u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength
296 * from large to small. it's value is 0->vo,
297 * 1->vi, 2->be, 3->bk. */
298 struct semaphore tx_retevt;/* all tx return event; */
300 struct tasklet_struct xmit_tasklet;
301 /* per AC pending irp */
306 struct __queue free_xmitbuf_queue;
307 struct __queue pending_xmitbuf_queue;
308 u8 *pallocated_xmitbuf;
310 uint free_xmitbuf_cnt;
311 struct __queue free_xmit_extbuf_queue;
312 u8 *pallocated_xmit_extbuf;
314 uint free_xmit_extbuf_cnt;
317 struct mutex ack_tx_mutex;
318 struct submit_ctx ack_tx_ops;
321 struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv);
322 s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv,
323 struct xmit_buf *pxmitbuf);
324 struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
325 s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv,
326 struct xmit_buf *pxmitbuf);
327 void rtw_count_tx_stats(struct adapter *padapter,
328 struct xmit_frame *pxmitframe, int sz);
329 void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len);
330 s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr,
331 struct pkt_attrib *pattrib);
332 s32 rtw_put_snap(u8 *data, u16 h_proto);
334 struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv);
335 s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv,
336 struct xmit_frame *pxmitframe);
337 void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
338 struct __queue *pframequeue);
339 struct tx_servq *rtw_get_sta_pending(struct adapter *padapter,
340 struct sta_info *psta, int up, u8 *ac);
341 s32 rtw_xmitframe_enqueue(struct adapter *padapter,
342 struct xmit_frame *pxmitframe);
343 struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv,
344 struct hw_xmit *phwxmit_i, int entry);
346 s32 rtw_xmit_classifier(struct adapter *padapter,
347 struct xmit_frame *pxmitframe);
348 u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib);
349 #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib)
350 s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt,
351 struct xmit_frame *pxmitframe);
352 s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
353 void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
354 s32 rtw_txframes_pending(struct adapter *padapter);
355 s32 rtw_txframes_sta_ac_pending(struct adapter *padapter,
356 struct pkt_attrib *pattrib);
357 void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry);
358 s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
359 void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
360 void rtw_alloc_hwxmits(struct adapter *padapter);
361 void rtw_free_hwxmits(struct adapter *padapter);
362 s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
364 #if defined(CONFIG_88EU_AP_MODE)
365 int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
366 void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta);
367 void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta);
368 void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta);
371 u8 qos_acm(u8 acm_mask, u8 priority);
372 u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe);
373 int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms);
374 void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status);
376 /* include after declaring struct xmit_buf, in order to avoid warning */
377 #include <xmit_osdep.h>
379 #endif /* _RTL871X_XMIT_H_ */