• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2019 Realtek Corporation.
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 
19 #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
20 	#ifdef CONFIG_TX_AGGREGATION
21 		#ifdef CONFIG_RTL8822C
22 			#ifdef CONFIG_SDIO_TX_FORMAT_DUMMY_AUTO
23 				#define MAX_XMITBUF_SZ	(51200)
24 			#else
25 				#define MAX_XMITBUF_SZ	(32764)
26 			#endif
27 		#else
28 			#define MAX_XMITBUF_SZ	(20480)	/* 20k */
29 		#endif
30 		/* #define SDIO_TX_AGG_MAX	5 */
31 	#else
32 		#define MAX_XMITBUF_SZ (1664)
33 		#define SDIO_TX_AGG_MAX	1
34 	#endif
35 
36 	#if defined CONFIG_SDIO_HCI
37 		#define NR_XMITBUFF	(16)
38 		#define SDIO_TX_DIV_NUM (2)
39 	#endif
40 	#if defined(CONFIG_GSPI_HCI)
41 		#define NR_XMITBUFF	(128)
42 	#endif
43 
44 #elif defined (CONFIG_USB_HCI)
45 
46 	#ifdef CONFIG_USB_TX_AGGREGATION
47 		#if defined(CONFIG_PLATFORM_ARM_SUNxI) || defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) || defined(CONFIG_PLATFORM_ARM_SUN8I) || defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
48 			#define MAX_XMITBUF_SZ (12288)  /* 12k 1536*8 */
49 		#elif defined (CONFIG_PLATFORM_MSTAR)
50 			#define MAX_XMITBUF_SZ	7680	/* 7.5k */
51 		#else
52 			#define MAX_XMITBUF_SZ	(20480)	/* 20k */
53 		#endif
54 	#else
55 		#define MAX_XMITBUF_SZ	(2048)
56 	#endif
57 
58 	#ifdef CONFIG_SINGLE_XMIT_BUF
59 		#define NR_XMITBUFF	(1)
60 	#else
61 		#define NR_XMITBUFF	(4)
62 	#endif /* CONFIG_SINGLE_XMIT_BUF */
63 #elif defined (CONFIG_PCI_HCI)
64 #ifdef CONFIG_TX_AMSDU
65 	#define MAX_XMITBUF_SZ	(3500)
66 #else
67 	#define MAX_XMITBUF_SZ	(1664)
68 #endif
69 #ifdef CONFIG_PCI_TX_POLLING
70 	#define NR_XMITBUFF	(256)
71 #else
72 	#define NR_XMITBUFF	(128)
73 #endif
74 #endif
75 
76 
77 #ifdef CONFIG_PCI_HCI
78 	#define XMITBUF_ALIGN_SZ 4
79 #else
80 	#ifdef USB_XMITBUF_ALIGN_SZ
81 		#define XMITBUF_ALIGN_SZ (USB_XMITBUF_ALIGN_SZ)
82 	#else
83 		#define XMITBUF_ALIGN_SZ 512
84 	#endif
85 #endif
86 
87 
88 /* xmit extension buff defination */
89 #define MAX_XMIT_EXTBUF_SZ	(1536)
90 
91 #ifdef CONFIG_SINGLE_XMIT_BUF
92 	#define NR_XMIT_EXTBUFF	(1)
93 #elif defined(CONFIG_RTW_MGMT_QUEUE)
94 	#define NR_XMIT_EXTBUFF	(64)
95 #else
96 	#define NR_XMIT_EXTBUFF	(32)
97 #endif
98 
99 #ifdef CONFIG_RTL8812A
100 	#define MAX_CMDBUF_SZ	(512 * 18)
101 #elif defined(CONFIG_RTL8723D) && defined(CONFIG_LPS_POFF)
102 	#define MAX_CMDBUF_SZ	(128*70) /*(8960)*/
103 #elif defined(CONFIG_RTL8822C) && defined(CONFIG_WAR_OFFLOAD)
104 	#define MAX_CMDBUF_SZ	(128*128) /*(16k) */
105 #else
106 	#define MAX_CMDBUF_SZ	(5120)	/* (4096) */
107 #endif
108 
109 #define MAX_BEACON_LEN	512
110 
111 #define MAX_NUMBLKS		(1)
112 
113 #define XMIT_VO_QUEUE (0)
114 #define XMIT_VI_QUEUE (1)
115 #define XMIT_BE_QUEUE (2)
116 #define XMIT_BK_QUEUE (3)
117 
118 #define VO_QUEUE_INX		0
119 #define VI_QUEUE_INX		1
120 #define BE_QUEUE_INX		2
121 #define BK_QUEUE_INX		3
122 #define BCN_QUEUE_INX		4
123 #define MGT_QUEUE_INX		5
124 #define TXCMD_QUEUE_INX		6
125 #define HIGH_QUEUE_INX		7
126 /* keep high queue to be the last one, so we can extend HIQ to port 1, 2, ... */
127 
128 #ifndef CONFIG_PORT_BASED_HIQ
129 #define HW_QUEUE_ENTRY	8
130 #else
131 #define HI_QUEUE_INX(n)	(HIGH_QUEUE_INX + (n))
132 #define HW_QUEUE_ENTRY	(8 + CONFIG_IFACE_NUMBER - 1)
133 #endif
134 
135 #ifdef CONFIG_PCI_HCI
136 	#ifdef CONFIG_TRX_BD_ARCH
137 		#define TX_BD_NUM			(128+1)	/* +1 result from ring buffer */
138 	#else
139 		#define TXDESC_NUM			128
140 	#endif
141 #endif
142 
143 #define WEP_IV(pattrib_iv, dot11txpn, keyidx)\
144 	do {\
145 		dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val + 1);\
146 		pattrib_iv[0] = dot11txpn._byte_.TSC0;\
147 		pattrib_iv[1] = dot11txpn._byte_.TSC1;\
148 		pattrib_iv[2] = dot11txpn._byte_.TSC2;\
149 		pattrib_iv[3] = ((keyidx & 0x3)<<6);\
150 	} while (0)
151 
152 
153 #define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\
154 	do {\
155 		dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val + 1);\
156 		pattrib_iv[0] = dot11txpn._byte_.TSC1;\
157 		pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\
158 		pattrib_iv[2] = dot11txpn._byte_.TSC0;\
159 		pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
160 		pattrib_iv[4] = dot11txpn._byte_.TSC2;\
161 		pattrib_iv[5] = dot11txpn._byte_.TSC3;\
162 		pattrib_iv[6] = dot11txpn._byte_.TSC4;\
163 		pattrib_iv[7] = dot11txpn._byte_.TSC5;\
164 	} while (0)
165 
166 #define AES_IV(pattrib_iv, dot11txpn, keyidx)\
167 	do {\
168 		dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val + 1);\
169 		pattrib_iv[0] = dot11txpn._byte_.TSC0;\
170 		pattrib_iv[1] = dot11txpn._byte_.TSC1;\
171 		pattrib_iv[2] = 0;\
172 		pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
173 		pattrib_iv[4] = dot11txpn._byte_.TSC2;\
174 		pattrib_iv[5] = dot11txpn._byte_.TSC3;\
175 		pattrib_iv[6] = dot11txpn._byte_.TSC4;\
176 		pattrib_iv[7] = dot11txpn._byte_.TSC5;\
177 	} while (0)
178 
179 #define GCMP_IV(a, b, c) AES_IV(a, b, c)
180 
181 /* Check if AMPDU Tx is supported or not. If it is supported,
182 * it need to check "amsdu in ampdu" is supported or not.
183 * (ampdu_en, amsdu_ampdu_en) =
184 * (0, x) : AMPDU is not enable, but AMSDU is valid to send.
185 * (1, 0) : AMPDU is enable, AMSDU in AMPDU is not enable. So, AMSDU is not valid to send.
186 * (1, 1) : AMPDU and AMSDU in AMPDU are enable. So, AMSDU is valid to send.
187 */
188 #define IS_AMSDU_AMPDU_NOT_VALID(pattrib)\
189 	 ((pattrib->ampdu_en == _TRUE) && (pattrib->amsdu_ampdu_en == _FALSE))
190 
191 #define IS_AMSDU_AMPDU_VALID(pattrib)\
192 	 !((pattrib->ampdu_en == _TRUE) && (pattrib->amsdu_ampdu_en == _FALSE))
193 
194 #ifdef CONFIG_RTW_MGMT_QUEUE
195 #define HWXMIT_ENTRY 5
196 #else
197 #define HWXMIT_ENTRY 4
198 #endif
199 
200 enum DEQUEUE_TYPE {
201 	UNI_BMC_DATA,
202 	UNI_MGMT,
203 	ALL_FRAME
204 };
205 
206 /* For Buffer Descriptor ring architecture */
207 #if defined(BUF_DESC_ARCH) || defined(CONFIG_TRX_BD_ARCH)
208 	#if defined(CONFIG_RTL8192E)
209 		#define TX_BUFFER_SEG_NUM	1 /* 0:2 seg, 1: 4 seg, 2: 8 seg. */
210 	#elif defined(CONFIG_RTL8814A)
211 		#define TX_BUFFER_SEG_NUM	1 /* 0:2 seg, 1: 4 seg, 2: 8 seg. */
212 	#else
213 		#define TX_BUFFER_SEG_NUM	1 /* 0:2 seg, 1: 4 seg, 2: 8 seg. */
214 	#endif
215 #endif
216 
217 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) ||\
218 	defined(CONFIG_RTL8723B) || defined(CONFIG_RTL8192E) ||\
219 	defined(CONFIG_RTL8814A) || defined(CONFIG_RTL8703B) ||\
220 	defined(CONFIG_RTL8188F) || defined(CONFIG_RTL8188GTV) || defined(CONFIG_RTL8723D) ||\
221 	defined(CONFIG_RTL8710B) || defined(CONFIG_RTL8192F) ||\
222 	defined(CONFIG_RTL8723F)
223 	#define TXDESC_SIZE 40
224 #elif defined(CONFIG_RTL8822B) || defined(CONFIG_RTL8822C)
225 	#define TXDESC_SIZE 48		/* HALMAC_TX_DESC_SIZE_8822B */
226 #elif defined(CONFIG_RTL8821C)
227 	#define TXDESC_SIZE 48		/* HALMAC_TX_DESC_SIZE_8821C */
228 #elif defined(CONFIG_RTL8814B)
229 	#define TXDESC_SIZE (16 + 32)
230 #else
231 	#define TXDESC_SIZE 32 /* old IC (ex: 8188E) */
232 #endif
233 
234 #ifdef CONFIG_TX_EARLY_MODE
235 	#define EARLY_MODE_INFO_SIZE	8
236 #endif
237 
238 
239 #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
240 	#define TXDESC_OFFSET TXDESC_SIZE
241 #endif
242 
243 #ifdef CONFIG_USB_HCI
244 	#ifdef USB_PACKET_OFFSET_SZ
245 		#define PACKET_OFFSET_SZ (USB_PACKET_OFFSET_SZ)
246 	#else
247 		#define PACKET_OFFSET_SZ (8)
248 	#endif
249 	#define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ)
250 #endif
251 
252 #ifdef CONFIG_PCI_HCI
253 	#if defined(CONFIG_RTL8192E) || defined(CONFIG_RTL8814A) || defined(CONFIG_RTL8822B) || defined(CONFIG_RTL8821C) || defined(CONFIG_RTL8822C) || defined(CONFIG_TRX_BD_ARCH)
254 		/* this section is defined for buffer descriptor ring architecture */
255 		#define TX_WIFI_INFO_SIZE (TXDESC_SIZE) /* it may add 802.11 hdr or others... */
256 		/* tx desc and payload are in the same buf */
257 		#define TXDESC_OFFSET (TX_WIFI_INFO_SIZE)
258 	#else
259 		/* tx desc and payload are NOT in the same buf */
260 		#define TXDESC_OFFSET (0)
261 		/* 8188ee/8723be/8812ae/8821ae has extra PCI DMA info in tx desc */
262 		#define TX_DESC_NEXT_DESC_OFFSET	(TXDESC_SIZE + 8)
263 	#endif
264 #endif /* CONFIG_PCI_HCI */
265 
266 enum TXDESC_SC {
267 	SC_DONT_CARE = 0x00,
268 	SC_UPPER = 0x01,
269 	SC_LOWER = 0x02,
270 	SC_DUPLICATE = 0x03
271 };
272 
273 #ifdef CONFIG_PCI_HCI
274 	#ifndef CONFIG_TRX_BD_ARCH	/* CONFIG_TRX_BD_ARCH doesn't need this */
275 		#define TXDESC_64_BYTES
276 	#endif
277 #elif defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) || defined(CONFIG_RTL8723B) \
278 	|| defined(CONFIG_RTL8188F) || defined(CONFIG_RTL8188GTV) || defined(CONFIG_RTL8723D) \
279 	|| defined(CONFIG_RTL8192F) || defined(CONFIG_RTL8723F)
280 	#define TXDESC_40_BYTES
281 #endif
282 
283 #ifdef CONFIG_TRX_BD_ARCH
284 struct tx_buf_desc {
285 #ifdef CONFIG_64BIT_DMA
286 #define TX_BUFFER_SEG_SIZE	4	/* in unit of DWORD */
287 #else
288 #define TX_BUFFER_SEG_SIZE	2	/* in unit of DWORD */
289 #endif
290 	unsigned int dword[TX_BUFFER_SEG_SIZE * (2 << TX_BUFFER_SEG_NUM)];
291 } __packed;
292 #elif (defined(CONFIG_RTL8192E) || defined(CONFIG_RTL8814A) || defined(CONFIG_RTL8822B) || defined(CONFIG_RTL8822C)) && defined(CONFIG_PCI_HCI) /* 8192ee or 8814ae */
293 /* 8192EE_TODO */
294 struct tx_desc {
295 	unsigned int txdw0;
296 	unsigned int txdw1;
297 	unsigned int txdw2;
298 	unsigned int txdw3;
299 	unsigned int txdw4;
300 	unsigned int txdw5;
301 	unsigned int txdw6;
302 	unsigned int txdw7;
303 };
304 #else
305 struct tx_desc {
306 	unsigned int txdw0;
307 	unsigned int txdw1;
308 	unsigned int txdw2;
309 	unsigned int txdw3;
310 	unsigned int txdw4;
311 	unsigned int txdw5;
312 	unsigned int txdw6;
313 	unsigned int txdw7;
314 
315 #if defined(TXDESC_40_BYTES) || defined(TXDESC_64_BYTES)
316 	unsigned int txdw8;
317 	unsigned int txdw9;
318 #endif /* TXDESC_40_BYTES */
319 
320 #ifdef TXDESC_64_BYTES
321 	unsigned int txdw10;
322 	unsigned int txdw11;
323 
324 	/* 2008/05/15 MH Because PCIE HW memory R/W 4K limit. And now,  our descriptor */
325 	/* size is 40 bytes. If you use more than 102 descriptor( 103*40>4096), HW will execute */
326 	/* memoryR/W CRC error. And then all DMA fetch will fail. We must decrease descriptor */
327 	/* number or enlarge descriptor size as 64 bytes. */
328 	unsigned int txdw12;
329 	unsigned int txdw13;
330 	unsigned int txdw14;
331 	unsigned int txdw15;
332 #endif
333 };
334 #endif
335 
336 #ifndef CONFIG_TRX_BD_ARCH
337 union txdesc {
338 	struct tx_desc txdesc;
339 	unsigned int value[TXDESC_SIZE >> 2];
340 };
341 #endif
342 
343 #ifdef CONFIG_PCI_HCI
344 #define PCI_MAX_TX_QUEUE_COUNT	HW_QUEUE_ENTRY
345 
346 struct rtw_tx_ring {
347 	unsigned char	qid;
348 #ifdef CONFIG_TRX_BD_ARCH
349 	struct tx_buf_desc	*buf_desc;
350 #else
351 	struct tx_desc	*desc;
352 #endif
353 	dma_addr_t	dma;
354 	unsigned int	idx;
355 	unsigned int	entries;
356 	_queue		queue;
357 	u32		qlen;
358 #ifdef CONFIG_TRX_BD_ARCH
359 	u16		hw_rp_cache;
360 #endif
361 };
362 
363 #ifdef DBG_TXBD_DESC_DUMP
364 
365 #define TX_BAK_FRMAE_CNT	10
366 #define TX_BAK_DESC_LEN	48	/* byte */
367 #define TX_BAK_DATA_LEN		30	/* byte */
368 
369 struct rtw_tx_desc_backup {
370 	int tx_bak_rp;
371 	int tx_bak_wp;
372 	u8 tx_bak_desc[TX_BAK_DESC_LEN];
373 	u8 tx_bak_data_hdr[TX_BAK_DATA_LEN];
374 	u8 tx_desc_size;
375 };
376 #endif
377 #endif
378 
379 struct	hw_xmit	{
380 	/* _lock xmit_lock; */
381 	/* _list	pending; */
382 	_queue *sta_queue;
383 	/* struct hw_txqueue *phwtxqueue; */
384 	/* sint	txcmdcnt; */
385 	int	accnt;
386 };
387 
388 struct pkt_attrib {
389 	u8	type;
390 	u8	subtype;
391 	u8	bswenc;
392 	u8	dhcp_pkt;
393 	u16	ether_type;
394 	u16	seqnum;
395 	u8	hw_ssn_sel;	/* for HW_SEQ0,1,2,3 */
396 	u16	pkt_hdrlen;	/* the original 802.3 pkt header len */
397 	u16	hdrlen;		/* the WLAN Header Len */
398 	u32	pktlen;		/* the original 802.3 pkt raw_data len (not include ether_hdr data) */
399 	u32	last_txcmdsz;
400 	u8	nr_frags;
401 	u8	encrypt;	/* when 0 indicate no encrypt. when non-zero, indicate the encrypt algorith */
402 	u8	bmc_camid;
403 	u8	iv_len;
404 	u8	icv_len;
405 	u8	iv[18];
406 	u8	icv[16];
407 	u8	priority;
408 	u8	ack_policy;
409 	u8	mac_id;
410 	u8	vcs_mode;	/* virtual carrier sense method */
411 	u8	dst[ETH_ALEN];
412 	u8	src[ETH_ALEN];
413 	u8	ta[ETH_ALEN];
414 	u8	ra[ETH_ALEN];
415 #ifdef CONFIG_RTW_WDS
416 	u8	wds;
417 #endif
418 #ifdef CONFIG_RTW_MESH
419 	u8	mda[ETH_ALEN];	/* mesh da */
420 	u8	msa[ETH_ALEN];	/* mesh sa */
421 	u8	meshctrl_len;	/* Length of Mesh Control field */
422 	u8	mesh_frame_mode;
423 	#if CONFIG_RTW_MESH_DATA_BMC_TO_UC
424 	u8 mb2u;
425 	#endif
426 	u8 mfwd_ttl;
427 	u32 mseq;
428 #endif
429 #ifdef CONFIG_TCP_CSUM_OFFLOAD_TX
430 	u8	hw_csum;
431 #endif
432 	u8	key_idx;
433 	u8	qos_en;
434 	u8	ht_en;
435 	u8	raid;/* rate adpative id */
436 	u8	bwmode;
437 	u8	ch_offset;/* PRIME_CHNL_OFFSET */
438 	u8	sgi;/* short GI */
439 	u8	ampdu_en;/* tx ampdu enable */
440 	u8	ampdu_spacing; /* ampdu_min_spacing for peer sta's rx */
441 	u8	amsdu;
442 	u8	amsdu_ampdu_en;/* tx amsdu in ampdu enable */
443 	u8	mdata;/* more data bit */
444 	u8	pctrl;/* per packet txdesc control enable */
445 	u8	triggered;/* for ap mode handling Power Saving sta */
446 	u8	qsel;
447 	u8	order;/* order bit */
448 	u8	eosp;
449 	u8	rate;
450 	u8	intel_proxim;
451 	u8	retry_ctrl;
452 	u8   mbssid;
453 	u8	ldpc;
454 	u8	stbc;
455 #ifdef CONFIG_WMMPS_STA
456 	u8	trigger_frame;
457 #endif /* CONFIG_WMMPS_STA */
458 
459 	struct sta_info *psta;
460 
461 	u8 rtsen;
462 	u8 cts2self;
463 	union Keytype	dot11tkiptxmickey;
464 	/* union Keytype	dot11tkiprxmickey; */
465 	union Keytype	dot118021x_UncstKey;
466 
467 #ifdef CONFIG_TDLS
468 	u8 direct_link;
469 	struct sta_info *ptdls_sta;
470 #endif /* CONFIG_TDLS */
471 	u8 key_type;
472 
473 	u8 icmp_pkt;
474 	u8 hipriority_pkt; /* high priority packet */
475 
476 #ifdef CONFIG_BEAMFORMING
477 	u16 txbf_p_aid;/*beamforming Partial_AID*/
478 	u16 txbf_g_id;/*beamforming Group ID*/
479 
480 	/*
481 	 * 2'b00: Unicast NDPA
482 	 * 2'b01: Broadcast NDPA
483 	 * 2'b10: Beamforming Report Poll
484 	 * 2'b11: Final Beamforming Report Poll
485 	 */
486 	u8 bf_pkt_type;
487 #endif
488 
489 #ifdef CONFIG_RTW_MGMT_QUEUE
490 	u8 ps_dontq; /* 1: this frame can't be queued at PS state */
491 #endif
492 };
493 
494 #ifdef CONFIG_RTW_WDS
495 #define XATTRIB_GET_WDS(xattrib) ((xattrib)->wds)
496 #else
497 #define XATTRIB_GET_WDS(xattrib) 0
498 #endif
499 
500 #ifdef CONFIG_RTW_MESH
501 #define XATTRIB_GET_MCTRL_LEN(xattrib) ((xattrib)->meshctrl_len)
502 #else
503 #define XATTRIB_GET_MCTRL_LEN(xattrib) 0
504 #endif
505 
506 #ifdef CONFIG_TX_AMSDU
507 enum {
508 	RTW_AMSDU_TIMER_UNSET = 0,
509 	RTW_AMSDU_TIMER_SETTING,
510 	RTW_AMSDU_TIMER_TIMEOUT,
511 };
512 #endif
513 
514 #define WLANHDR_OFFSET	64
515 
516 #define NULL_FRAMETAG		(0x0)
517 #define DATA_FRAMETAG		0x01
518 #define L2_FRAMETAG		0x02
519 #define MGNT_FRAMETAG		0x03
520 #define AMSDU_FRAMETAG	0x04
521 
522 #define EII_FRAMETAG		0x05
523 #define IEEE8023_FRAMETAG  0x06
524 
525 #define MP_FRAMETAG		0x07
526 
527 #define TXAGG_FRAMETAG	0x08
528 
529 enum {
530 	XMITBUF_DATA = 0,
531 	XMITBUF_MGNT = 1,
532 	XMITBUF_CMD = 2,
533 };
534 
535 bool rtw_xmit_ac_blocked(_adapter *adapter);
536 
537 struct  submit_ctx {
538 	systime submit_time; /* */
539 	u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */
540 	int status; /* status for operation */
541 #ifdef PLATFORM_LINUX
542 	struct completion done;
543 #endif
544 };
545 
546 enum {
547 	RTW_SCTX_SUBMITTED = -1,
548 	RTW_SCTX_DONE_SUCCESS = 0,
549 	RTW_SCTX_DONE_UNKNOWN,
550 	RTW_SCTX_DONE_TIMEOUT,
551 	RTW_SCTX_DONE_BUF_ALLOC,
552 	RTW_SCTX_DONE_BUF_FREE,
553 	RTW_SCTX_DONE_WRITE_PORT_ERR,
554 	RTW_SCTX_DONE_TX_DESC_NA,
555 	RTW_SCTX_DONE_TX_DENY,
556 	RTW_SCTX_DONE_CCX_PKT_FAIL,
557 	RTW_SCTX_DONE_DRV_STOP,
558 	RTW_SCTX_DONE_DEV_REMOVE,
559 	RTW_SCTX_DONE_CMD_ERROR,
560 	RTW_SCTX_DONE_CMD_DROP,
561 	RTX_SCTX_CSTR_WAIT_RPT2,
562 };
563 
564 
565 void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms);
566 int rtw_sctx_wait(struct submit_ctx *sctx, const char *msg);
567 void rtw_sctx_done_err(struct submit_ctx **sctx, int status);
568 void rtw_sctx_done(struct submit_ctx **sctx);
569 
570 struct xmit_buf {
571 	_list	list;
572 
573 	_adapter *padapter;
574 
575 	u8 *pallocated_buf;
576 
577 	u8 *pbuf;
578 
579 	void *priv_data;
580 
581 	u16 buf_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf, 2:cmd xmitbuf */
582 	u16 flags;
583 	u32 alloc_sz;
584 
585 	u32  len;
586 
587 	struct submit_ctx *sctx;
588 
589 #ifdef CONFIG_USB_HCI
590 
591 	/* u32 sz[8]; */
592 	u32	ff_hwaddr;
593 #ifdef RTW_HALMAC
594 	u8 bulkout_id; /* for halmac */
595 #endif /* RTW_HALMAC */
596 
597 	PURB	pxmit_urb[8];
598 	dma_addr_t dma_transfer_addr;	/* (in) dma addr for transfer_buffer */
599 
600 	u8 bpending[8];
601 
602 	sint last[8];
603 
604 #endif
605 
606 #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
607 	u8 *phead;
608 	u8 *pdata;
609 	u8 *ptail;
610 	u8 *pend;
611 	u32 ff_hwaddr;
612 	u8	pg_num;
613 	u8	agg_num;
614 #endif
615 
616 #ifdef CONFIG_PCI_HCI
617 #ifdef CONFIG_TRX_BD_ARCH
618 	/*struct tx_buf_desc *buf_desc;*/
619 #else
620 	struct tx_desc *desc;
621 #endif
622 #endif
623 
624 #ifdef CONFIG_PCIE_DMA_COHERENT
625 	dma_addr_t dma_bpa;
626 #endif
627 
628 #if defined(DBG_XMIT_BUF) || defined(DBG_XMIT_BUF_EXT)
629 	u8 no;
630 #endif
631 
632 };
633 
634 
635 struct xmit_frame {
636 	_list	list;
637 
638 	struct pkt_attrib attrib;
639 
640 	u16 os_qid;
641 	_pkt *pkt;
642 
643 	int	frame_tag;
644 
645 	_adapter *padapter;
646 
647 	u8	*buf_addr;
648 
649 	struct xmit_buf *pxmitbuf;
650 
651 #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
652 	u8	pg_num;
653 	u8	agg_num;
654 #endif
655 
656 #ifdef CONFIG_USB_HCI
657 #ifdef CONFIG_USB_TX_AGGREGATION
658 	u8	agg_num;
659 #endif
660 	s8	pkt_offset;
661 #endif
662 
663 #ifdef CONFIG_XMIT_ACK
664 	u8 ack_report;
665 #endif
666 
667 	u8 *alloc_addr; /* the actual address this xmitframe allocated */
668 	u8 ext_tag; /* 0:data, 1:mgmt */
669 
670 };
671 
672 struct tx_servq {
673 	_list	tx_pending;
674 	_queue	sta_pending;
675 	int qcnt;
676 };
677 
678 
679 struct sta_xmit_priv {
680 	_lock	lock;
681 	sint	option;
682 	sint	apsd_setting;	/* When bit mask is on, the associated edca queue supports APSD. */
683 
684 
685 	/* struct tx_servq blk_q[MAX_NUMBLKS]; */
686 	struct tx_servq	be_q;			/* priority == 0,3 */
687 	struct tx_servq	bk_q;			/* priority == 1,2 */
688 	struct tx_servq	vi_q;			/* priority == 4,5 */
689 	struct tx_servq	vo_q;			/* priority == 6,7 */
690 #ifdef CONFIG_RTW_MGMT_QUEUE
691 	struct tx_servq	mgmt_q;
692 #endif
693 
694 	_list	legacy_dz;
695 	_list  apsd;
696 
697 	u16 txseq_tid[16];
698 
699 	/* uint	sta_tx_bytes; */
700 	/* u64	sta_tx_pkts; */
701 	/* uint	sta_tx_fail; */
702 
703 
704 };
705 
706 
707 struct	hw_txqueue	{
708 	volatile sint	head;
709 	volatile sint	tail;
710 	volatile sint 	free_sz;	/* in units of 64 bytes */
711 	volatile sint      free_cmdsz;
712 	volatile sint	 txsz[8];
713 	uint	ff_hwaddr;
714 	uint	cmd_hwaddr;
715 	sint	ac_tag;
716 };
717 
718 struct agg_pkt_info {
719 	u16 offset;
720 	u16 pkt_len;
721 };
722 
723 enum cmdbuf_type {
724 	CMDBUF_BEACON = 0x00,
725 	CMDBUF_RSVD,
726 	CMDBUF_MAX
727 };
728 
729 u8 rtw_get_hwseq_no(_adapter *padapter);
730 
731 struct	xmit_priv	{
732 
733 	_lock	lock;
734 
735 	_sema	xmit_sema;
736 
737 	/* _queue	blk_strms[MAX_NUMBLKS]; */
738 	_queue	be_pending;
739 	_queue	bk_pending;
740 	_queue	vi_pending;
741 	_queue	vo_pending;
742 	_queue	mgmt_pending;
743 
744 	/* _queue	legacy_dz_queue; */
745 	/* _queue	apsd_queue; */
746 
747 	u8 *pallocated_frame_buf;
748 	u8 *pxmit_frame_buf;
749 	uint free_xmitframe_cnt;
750 	_queue	free_xmit_queue;
751 
752 	/* uint mapping_addr; */
753 	/* uint pkt_sz; */
754 
755 	u8 *xframe_ext_alloc_addr;
756 	u8 *xframe_ext;
757 	uint free_xframe_ext_cnt;
758 	_queue free_xframe_ext_queue;
759 
760 	/* struct	hw_txqueue	be_txqueue; */
761 	/* struct	hw_txqueue	bk_txqueue; */
762 	/* struct	hw_txqueue	vi_txqueue; */
763 	/* struct	hw_txqueue	vo_txqueue; */
764 	/* struct	hw_txqueue	bmc_txqueue; */
765 
766 	uint	frag_len;
767 
768 	_adapter	*adapter;
769 
770 	u8   vcs_setting;
771 	u8	vcs;
772 	u8	vcs_type;
773 	/* u16  rts_thresh; */
774 
775 	u64	tx_bytes;
776 	u64	tx_pkts;
777 	u64	tx_drop;
778 	u64	last_tx_pkts;
779 
780 	struct hw_xmit *hwxmits;
781 	u8	hwxmit_entry;
782 
783 	u8	wmm_para_seq[4];/* sequence for wmm ac parameter strength from large to small. it's value is 0->vo, 1->vi, 2->be, 3->bk. */
784 
785 #ifdef CONFIG_USB_HCI
786 	_sema	tx_retevt;/* all tx return event; */
787 	u8		txirp_cnt;
788 
789 	_tasklet xmit_tasklet;
790 
791 	/* per AC pending irp */
792 	int beq_cnt;
793 	int bkq_cnt;
794 	int viq_cnt;
795 	int voq_cnt;
796 
797 #endif
798 
799 #ifdef CONFIG_PCI_HCI
800 	/* Tx */
801 	struct rtw_tx_ring	tx_ring[PCI_MAX_TX_QUEUE_COUNT];
802 	int	txringcount[PCI_MAX_TX_QUEUE_COUNT];
803 	u8 	beaconDMAing;		/* flag of indicating beacon is transmiting to HW by DMA */
804 	_tasklet xmit_tasklet;
805 #endif
806 
807 #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
808 #ifdef CONFIG_SDIO_TX_TASKLET
809 	_tasklet xmit_tasklet;
810 #else
811 	_thread_hdl_	SdioXmitThread;
812 	_sema		SdioXmitSema;
813 	#ifdef SDIO_FREE_XMIT_BUF_SEMA
814 	_sema		sdio_free_xmitbuf_sema;
815 	#endif
816 #endif /* CONFIG_SDIO_TX_TASKLET */
817 #endif /* CONFIG_SDIO_HCI */
818 
819 	_queue free_xmitbuf_queue;
820 	_queue pending_xmitbuf_queue;
821 	u8 *pallocated_xmitbuf;
822 	u8 *pxmitbuf;
823 	uint free_xmitbuf_cnt;
824 
825 	_queue free_xmit_extbuf_queue;
826 	u8 *pallocated_xmit_extbuf;
827 	u8 *pxmit_extbuf;
828 	uint free_xmit_extbuf_cnt;
829 
830 	struct xmit_buf	pcmd_xmitbuf[CMDBUF_MAX];
831 	u8   hw_ssn_seq_no;/* mapping to REG_HW_SEQ 0,1,2,3 */
832 	u16	nqos_ssn;
833 #ifdef CONFIG_TX_EARLY_MODE
834 
835 #ifdef CONFIG_SDIO_HCI
836 #define MAX_AGG_PKT_NUM 20
837 #else
838 #define MAX_AGG_PKT_NUM 256 /* Max tx ampdu coounts		 */
839 #endif
840 
841 	struct agg_pkt_info agg_pkt[MAX_AGG_PKT_NUM];
842 #endif
843 
844 #ifdef CONFIG_XMIT_ACK
845 	int	ack_tx;
846 	_mutex ack_tx_mutex;
847 	struct submit_ctx ack_tx_ops;
848 	u8 seq_no;
849 #ifdef CONFIG_REMOVE_DUP_TX_STATE
850 	u8 retry_count;
851 #endif
852 #endif
853 
854 #ifdef CONFIG_TX_AMSDU
855 	_timer amsdu_vo_timer;
856 	u8 amsdu_vo_timeout;
857 
858 	_timer amsdu_vi_timer;
859 	u8 amsdu_vi_timeout;
860 
861 	_timer amsdu_be_timer;
862 	u8 amsdu_be_timeout;
863 
864 	_timer amsdu_bk_timer;
865 	u8 amsdu_bk_timeout;
866 
867 	u32 amsdu_debug_set_timer;
868 	u32 amsdu_debug_timeout;
869 	u32 amsdu_debug_coalesce_one;
870 	u32 amsdu_debug_coalesce_two;
871 
872 #endif
873 #ifdef DBG_TXBD_DESC_DUMP
874 	BOOLEAN	 dump_txbd_desc;
875 #endif
876 #ifdef CONFIG_PCI_TX_POLLING
877 	_timer tx_poll_timer;
878 #endif
879 #ifdef CONFIG_LAYER2_ROAMING
880 	_queue	rpkt_queue;
881 #endif
882 	_lock lock_sctx;
883 
884 };
885 
886 extern struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
887 		enum cmdbuf_type buf_type);
888 #define rtw_alloc_cmdxmitframe(p) __rtw_alloc_cmdxmitframe(p, CMDBUF_RSVD)
889 #if defined(CONFIG_RTL8192E) && defined(CONFIG_PCI_HCI)
890 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8192ee(struct xmit_priv *pxmitpriv,
891 		enum cmdbuf_type buf_type);
892 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8192ee(p, CMDBUF_BEACON)
893 #elif defined(CONFIG_RTL8822B) && defined(CONFIG_PCI_HCI)
894 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8822be(struct xmit_priv *pxmitpriv,
895 		enum cmdbuf_type buf_type);
896 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8822be(p, CMDBUF_BEACON)
897 #elif defined(CONFIG_RTL8822C) && defined(CONFIG_PCI_HCI)
898 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8822ce(struct xmit_priv *pxmitpriv,
899 		enum cmdbuf_type buf_type);
900 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8822ce(p, CMDBUF_BEACON)
901 #elif defined(CONFIG_RTL8821C) && defined(CONFIG_PCI_HCI)
902 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8821ce(struct xmit_priv *pxmitpriv,
903 		enum cmdbuf_type buf_type);
904 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8821ce(p, CMDBUF_BEACON)
905 #elif defined(CONFIG_RTL8192F) && defined(CONFIG_PCI_HCI)
906 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8192fe(struct xmit_priv *pxmitpriv,
907 		enum cmdbuf_type buf_type);
908 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8192fe(p, CMDBUF_BEACON)
909 #elif defined(CONFIG_RTL8812A) && defined(CONFIG_PCI_HCI)
910 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8812ae(struct xmit_priv *pxmitpriv,
911 		enum cmdbuf_type buf_type);
912 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8812ae(p, CMDBUF_BEACON)
913 #elif defined(CONFIG_RTL8723D) && defined(CONFIG_PCI_HCI)
914 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8723de(struct xmit_priv *pxmitpriv,
915 		enum cmdbuf_type buf_type);
916 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8723de(p, CMDBUF_BEACON)
917 #elif defined(CONFIG_RTL8723B) && defined(CONFIG_PCI_HCI)
918 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8723be(struct xmit_priv *pxmitpriv,
919 		enum cmdbuf_type buf_type);
920 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8723be(p, CMDBUF_BEACON)
921 #elif defined(CONFIG_RTL8814A) && defined(CONFIG_PCI_HCI)
922 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8814ae(struct xmit_priv *pxmitpriv,
923 		enum cmdbuf_type buf_type);
924 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8814ae(p, CMDBUF_BEACON)
925 #elif defined(CONFIG_RTL8814B) && defined(CONFIG_PCI_HCI)
926 extern struct xmit_frame *__rtw_alloc_cmdxmitframe_8814be(struct xmit_priv *pxmitpriv,
927 		enum cmdbuf_type buf_type);
928 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe_8814be(p, CMDBUF_BEACON)
929 #else
930 #define rtw_alloc_bcnxmitframe(p) __rtw_alloc_cmdxmitframe(p, CMDBUF_BEACON)
931 #endif
932 
933 extern struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv);
934 extern s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
935 
936 extern struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
937 extern s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
938 
939 void rtw_count_tx_stats(_adapter *padapter, struct xmit_frame *pxmitframe, int sz);
940 extern void rtw_update_protection(_adapter *padapter, u8 *ie, uint ie_len);
941 
942 extern s32 rtw_make_wlanhdr(_adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib);
943 extern s32 rtw_put_snap(u8 *data, u16 h_proto);
944 
945 extern struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv, u16 os_qid);
946 struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv);
947 struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv);
948 extern s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe);
949 extern void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, _queue *pframequeue);
950 struct tx_servq *rtw_get_sta_pending(_adapter *padapter, struct sta_info *psta, sint up, u8 *ac);
951 extern s32 rtw_xmitframe_enqueue(_adapter *padapter, struct xmit_frame *pxmitframe);
952 
953 #ifdef CONFIG_RTW_MGMT_QUEUE
954 void rtw_free_mgmt_xmitframe_queue(struct xmit_priv *pxmitpriv, _queue *mgmt_queue);
955 u8 rtw_mgmt_xmitframe_enqueue(_adapter *padapter, struct xmit_frame *pxmitframe);
956 struct xmit_frame *rtw_dequeue_mgmt_xframe(struct xmit_priv *pxmitpriv);
957 #endif /* CONFIG_RTW_MGMT_QUEUE */
958 
959 extern struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, sint entry);
960 
961 extern s32 rtw_xmit_classifier(_adapter *padapter, struct xmit_frame *pxmitframe);
962 extern u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib);
963 #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib)
964 extern s32 rtw_xmitframe_coalesce(_adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe);
965 #if defined(CONFIG_IEEE80211W) || defined(CONFIG_RTW_MESH)
966 extern s32 rtw_mgmt_xmitframe_coalesce(_adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe);
967 #endif
968 #ifdef CONFIG_TDLS
969 extern struct tdls_txmgmt *ptxmgmt;
970 s32 rtw_xmit_tdls_coalesce(_adapter *padapter, struct xmit_frame *pxmitframe, struct tdls_txmgmt *ptxmgmt);
971 s32 update_tdls_attrib(_adapter *padapter, struct pkt_attrib *pattrib);
972 #endif
973 s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
974 void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
975 
976 
977 s32 rtw_txframes_pending(_adapter *padapter);
978 s32 rtw_txframes_sta_ac_pending(_adapter *padapter, struct pkt_attrib *pattrib);
979 void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry);
980 
981 
982 s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter);
983 void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
984 
985 
986 void rtw_alloc_hwxmits(_adapter *padapter);
987 void rtw_free_hwxmits(_adapter *padapter);
988 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
989 s32 rtw_monitor_xmit_entry(struct sk_buff *skb, struct net_device *ndev);
990 #endif
991 void rtw_xmit_dequeue_callback(_workitem *work);
992 void rtw_xmit_queue_set(struct sta_info *sta);
993 void rtw_xmit_queue_clear(struct sta_info *sta);
994 s32 rtw_xmit_posthandle(_adapter *padapter, struct xmit_frame *pxmitframe, _pkt *pkt);
995 s32 rtw_xmit(_adapter *padapter, _pkt **pkt, u16 os_qid);
996 bool xmitframe_hiq_filter(struct xmit_frame *xmitframe);
997 #if defined(CONFIG_AP_MODE) || defined(CONFIG_TDLS)
998 #ifdef CONFIG_RTW_MGMT_QUEUE
999 u8 mgmt_xmitframe_enqueue_for_sleeping_sta(_adapter *padapter, struct xmit_frame *pxmitframe);
1000 #endif
1001 sint xmitframe_enqueue_for_sleeping_sta(_adapter *padapter, struct xmit_frame *pxmitframe);
1002 void stop_sta_xmit(_adapter *padapter, struct sta_info *psta);
1003 void wakeup_sta_to_xmit(_adapter *padapter, struct sta_info *psta, u8 dequeue_type);
1004 void xmit_delivery_enabled_frames(_adapter *padapter, struct sta_info *psta);
1005 #endif
1006 
1007 u8 rtw_get_tx_bw_mode(_adapter *adapter, struct sta_info *sta);
1008 
1009 void rtw_update_tx_rate_bmp(struct dvobj_priv *dvobj);
1010 u8 rtw_get_tx_bw_bmp_of_ht_rate(struct dvobj_priv *dvobj, u8 rate, u8 max_bw);
1011 u8 rtw_get_tx_bw_bmp_of_vht_rate(struct dvobj_priv *dvobj, u8 rate, u8 max_bw);
1012 s16 rtw_adapter_get_oper_txpwr_max_mbm(_adapter *adapter, bool eirp);
1013 s16 rtw_rfctl_get_oper_txpwr_max_mbm(struct rf_ctl_t *rfctl, u8 ch, u8 bw, u8 offset, u8 ifbmp_mod, u8 if_op, bool eirp);
1014 s16 rtw_get_oper_txpwr_max_mbm(struct dvobj_priv *dvobj, bool erip);
1015 s16 rtw_rfctl_get_reg_max_txpwr_mbm(struct rf_ctl_t *rfctl, u8 ch, u8 bw, u8 offset, bool eirp);
1016 
1017 u8 query_ra_short_GI(struct sta_info *psta, u8 bw);
1018 
1019 u8	qos_acm(u8 acm_mask, u8 priority);
1020 
1021 #ifdef CONFIG_XMIT_THREAD_MODE
1022 void	enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
1023 void enqueue_pending_xmitbuf_to_head(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
1024 struct xmit_buf	*dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv);
1025 struct xmit_buf	*select_and_dequeue_pending_xmitbuf(_adapter *padapter);
1026 sint	check_pending_xmitbuf(struct xmit_priv *pxmitpriv);
1027 thread_return	rtw_xmit_thread(thread_context context);
1028 #endif
1029 
1030 #ifdef CONFIG_TX_AMSDU
1031 extern void rtw_amsdu_vo_timeout_handler(void *FunctionContext);
1032 extern void rtw_amsdu_vi_timeout_handler(void *FunctionContext);
1033 extern void rtw_amsdu_be_timeout_handler(void *FunctionContext);
1034 extern void rtw_amsdu_bk_timeout_handler(void *FunctionContext);
1035 
1036 extern u8 rtw_amsdu_get_timer_status(_adapter *padapter, u8 priority);
1037 extern void rtw_amsdu_set_timer_status(_adapter *padapter, u8 priority, u8 status);
1038 extern void rtw_amsdu_set_timer(_adapter *padapter, u8 priority);
1039 extern void rtw_amsdu_cancel_timer(_adapter *padapter, u8 priority);
1040 
1041 extern s32 rtw_xmitframe_coalesce_amsdu(_adapter *padapter, struct xmit_frame *pxmitframe, struct xmit_frame *pxmitframe_queue);
1042 extern s32 check_amsdu(struct xmit_frame *pxmitframe);
1043 extern s32 check_amsdu_tx_support(_adapter *padapter);
1044 extern struct xmit_frame *rtw_get_xframe(struct xmit_priv *pxmitpriv, int *num_frame);
1045 #endif
1046 
1047 #ifdef DBG_TXBD_DESC_DUMP
1048 void rtw_tx_desc_backup(_adapter *padapter, struct xmit_frame *pxmitframe, u8 desc_size, u8 hwq);
1049 void rtw_tx_desc_backup_reset(void);
1050 u8 rtw_get_tx_desc_backup(_adapter *padapter, u8 hwq, struct rtw_tx_desc_backup **pbak);
1051 #endif
1052 
1053 #ifdef CONFIG_PCI_TX_POLLING
1054 void rtw_tx_poll_init(_adapter *padapter);
1055 void rtw_tx_poll_timeout_handler(void *FunctionContext);
1056 void rtw_tx_poll_timer_set(_adapter *padapter, u32 delay);
1057 void rtw_tx_poll_timer_cancel(_adapter *padapter);
1058 #endif
1059 
1060 u32	rtw_get_ff_hwaddr(struct xmit_frame	*pxmitframe);
1061 
1062 #ifdef CONFIG_XMIT_ACK
1063 int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms);
1064 void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status);
1065 #endif /* CONFIG_XMIT_ACK */
1066 
1067 enum XMIT_BLOCK_REASON {
1068 	XMIT_BLOCK_NONE = 0,
1069 	XMIT_BLOCK_REDLMEM = BIT0, /*LPS-PG*/
1070 	XMIT_BLOCK_SUSPEND = BIT1, /*WOW*/
1071 	XMIT_BLOCK_MAX = 0xFF,
1072 };
1073 void rtw_init_xmit_block(_adapter *padapter);
1074 void rtw_deinit_xmit_block(_adapter *padapter);
1075 
1076 #ifdef DBG_XMIT_BLOCK
1077 void dump_xmit_block(void *sel, _adapter *padapter);
1078 #endif
1079 void rtw_set_xmit_block(_adapter *padapter, enum XMIT_BLOCK_REASON reason);
1080 void rtw_clr_xmit_block(_adapter *padapter, enum XMIT_BLOCK_REASON reason);
1081 bool rtw_is_xmit_blocked(_adapter *padapter);
1082 void rtw_hci_flush(_adapter *padapter);
1083 
1084 /* include after declaring struct xmit_buf, in order to avoid warning */
1085 #include <xmit_osdep.h>
1086 
1087 #endif /* _RTL871X_XMIT_H_ */
1088