1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2010 Realtek Corporation.*/
4 #ifndef __RTL8821AE_TRX_H__
5 #define __RTL8821AE_TRX_H__
7 #define TX_DESC_SIZE 40
8 #define TX_DESC_AGGR_SUBFRAME_SIZE 32
10 #define RX_DESC_SIZE 32
11 #define RX_DRV_INFO_SIZE_UNIT 8
13 #define TX_DESC_NEXT_DESC_OFFSET 40
14 #define USB_HWDESC_HEADER_LEN 40
17 static inline void set_tx_desc_pkt_size(__le32
*__pdesc
, u32 __val
)
19 le32p_replace_bits(__pdesc
, __val
, GENMASK(15, 0));
22 static inline void set_tx_desc_offset(__le32
*__pdesc
, u32 __val
)
24 le32p_replace_bits(__pdesc
, __val
, GENMASK(23, 16));
27 static inline void set_tx_desc_bmc(__le32
*__pdesc
, u32 __val
)
29 le32p_replace_bits(__pdesc
, __val
, BIT(24));
32 static inline void set_tx_desc_htc(__le32
*__pdesc
, u32 __val
)
34 le32p_replace_bits(__pdesc
, __val
, BIT(25));
37 static inline void set_tx_desc_last_seg(__le32
*__pdesc
, u32 __val
)
39 le32p_replace_bits(__pdesc
, __val
, BIT(26));
42 static inline void set_tx_desc_first_seg(__le32
*__pdesc
, u32 __val
)
44 le32p_replace_bits(__pdesc
, __val
, BIT(27));
47 static inline void set_tx_desc_linip(__le32
*__pdesc
, u32 __val
)
49 le32p_replace_bits(__pdesc
, __val
, BIT(28));
52 static inline void set_tx_desc_own(__le32
*__pdesc
, u32 __val
)
54 le32p_replace_bits(__pdesc
, __val
, BIT(31));
57 static inline int get_tx_desc_own(__le32
*__pdesc
)
59 return le32_get_bits(*(__pdesc
), BIT(31));
62 static inline void set_tx_desc_macid(__le32
*__pdesc
, u32 __val
)
64 le32p_replace_bits(__pdesc
+ 1, __val
, GENMASK(6, 0));
67 static inline void set_tx_desc_queue_sel(__le32
*__pdesc
, u32 __val
)
69 le32p_replace_bits(__pdesc
+ 1, __val
, GENMASK(12, 8));
72 static inline void set_tx_desc_rate_id(__le32
*__pdesc
, u32 __val
)
74 le32p_replace_bits(__pdesc
+ 1, __val
, GENMASK(20, 16));
77 static inline void set_tx_desc_sec_type(__le32
*__pdesc
, u32 __val
)
79 le32p_replace_bits(__pdesc
+ 1, __val
, GENMASK(23, 22));
82 static inline void set_tx_desc_pkt_offset(__le32
*__pdesc
, u32 __val
)
84 le32p_replace_bits(__pdesc
+ 1, __val
, GENMASK(28, 24));
87 static inline void set_tx_desc_agg_enable(__le32
*__pdesc
, u32 __val
)
89 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(12));
92 static inline void set_tx_desc_rdg_enable(__le32
*__pdesc
, u32 __val
)
94 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(13));
97 static inline void set_tx_desc_more_frag(__le32
*__pdesc
, u32 __val
)
99 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(17));
102 static inline void set_tx_desc_ampdu_density(__le32
*__pdesc
, u32 __val
)
104 le32p_replace_bits(__pdesc
+ 2, __val
, GENMASK(22, 20));
107 static inline void set_tx_desc_hwseq_sel(__le32
*__pdesc
, u32 __val
)
109 le32p_replace_bits(__pdesc
+ 3, __val
, GENMASK(7, 6));
112 static inline void set_tx_desc_use_rate(__le32
*__pdesc
, u32 __val
)
114 le32p_replace_bits(__pdesc
+ 3, __val
, BIT(8));
117 static inline void set_tx_desc_disable_fb(__le32
*__pdesc
, u32 __val
)
119 le32p_replace_bits(__pdesc
+ 3, __val
, BIT(10));
122 static inline void set_tx_desc_cts2self(__le32
*__pdesc
, u32 __val
)
124 le32p_replace_bits(__pdesc
+ 3, __val
, BIT(11));
127 static inline void set_tx_desc_rts_enable(__le32
*__pdesc
, u32 __val
)
129 le32p_replace_bits(__pdesc
+ 3, __val
, BIT(12));
132 static inline void set_tx_desc_hw_rts_enable(__le32
*__pdesc
, u32 __val
)
134 le32p_replace_bits(__pdesc
+ 3, __val
, BIT(13));
137 static inline void set_tx_desc_nav_use_hdr(__le32
*__pdesc
, u32 __val
)
139 le32p_replace_bits(__pdesc
+ 3, __val
, BIT(15));
142 static inline void set_tx_desc_max_agg_num(__le32
*__pdesc
, u32 __val
)
144 le32p_replace_bits(__pdesc
+ 3, __val
, GENMASK(21, 17));
147 static inline void set_tx_desc_tx_ant(__le32
*__pdesc
, u32 __val
)
149 le32p_replace_bits(__pdesc
+ 5, __val
, GENMASK(27, 24));
152 static inline void set_tx_desc_tx_rate(__le32
*__pdesc
, u32 __val
)
154 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(6, 0));
157 static inline void set_tx_desc_data_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
159 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(12, 8));
162 static inline void set_tx_desc_rts_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
164 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(16, 13));
167 static inline void set_tx_desc_rts_rate(__le32
*__pdesc
, u32 __val
)
169 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(28, 24));
172 static inline void set_tx_desc_tx_sub_carrier(__le32
*__pdesc
, u32 __val
)
174 le32p_replace_bits(__pdesc
+ 5, __val
, GENMASK(3, 0));
177 static inline void set_tx_desc_data_shortgi(__le32
*__pdesc
, u32 __val
)
179 le32p_replace_bits(__pdesc
+ 5, __val
, BIT(4));
182 static inline void set_tx_desc_data_bw(__le32
*__pdesc
, u32 __val
)
184 le32p_replace_bits(__pdesc
+ 5, __val
, GENMASK(6, 5));
187 static inline void set_tx_desc_rts_short(__le32
*__pdesc
, u32 __val
)
189 le32p_replace_bits(__pdesc
+ 5, __val
, BIT(12));
192 static inline void set_tx_desc_rts_sc(__le32
*__pdesc
, u32 __val
)
194 le32p_replace_bits(__pdesc
+ 5, __val
, GENMASK(16, 13));
197 static inline void set_tx_desc_tx_buffer_size(__le32
*__pdesc
, u32 __val
)
199 le32p_replace_bits(__pdesc
+ 7, __val
, GENMASK(15, 0));
202 static inline void set_tx_desc_hwseq_en(__le32
*__pdesc
, u32 __val
)
204 le32p_replace_bits(__pdesc
+ 8, __val
, BIT(15));
207 static inline void set_tx_desc_seq(__le32
*__pdesc
, u32 __val
)
209 le32p_replace_bits(__pdesc
+ 9, __val
, GENMASK(23, 12));
212 static inline void set_tx_desc_tx_buffer_address(__le32
*__pdesc
, u32 __val
)
214 *(__pdesc
+ 10) = cpu_to_le32(__val
);
217 static inline u32
get_tx_desc_tx_buffer_address(__le32
*__pdesc
)
219 return le32_to_cpu(*(__pdesc
+ 10));
222 static inline void set_tx_desc_next_desc_address(__le32
*__pdesc
, u32 __val
)
224 *(__pdesc
+ 12) = cpu_to_le32(__val
);
227 static inline int get_rx_desc_pkt_len(__le32
*__pdesc
)
229 return le32_get_bits(*(__pdesc
), GENMASK(13, 0));
232 static inline int get_rx_desc_crc32(__le32
*__pdesc
)
234 return le32_get_bits(*(__pdesc
), BIT(14));
237 static inline int get_rx_desc_icv(__le32
*__pdesc
)
239 return le32_get_bits(*(__pdesc
), BIT(15));
242 static inline int get_rx_desc_drv_info_size(__le32
*__pdesc
)
244 return le32_get_bits(*(__pdesc
), GENMASK(19, 16));
247 static inline int get_rx_desc_shift(__le32
*__pdesc
)
249 return le32_get_bits(*(__pdesc
), GENMASK(25, 24));
252 static inline int get_rx_desc_physt(__le32
*__pdesc
)
254 return le32_get_bits(*(__pdesc
), BIT(26));
257 static inline int get_rx_desc_swdec(__le32
*__pdesc
)
259 return le32_get_bits(*(__pdesc
), BIT(27));
262 static inline int get_rx_desc_own(__le32
*__pdesc
)
264 return le32_get_bits(*(__pdesc
), BIT(31));
267 static inline void set_rx_desc_pkt_len(__le32
*__pdesc
, u32 __val
)
269 le32p_replace_bits(__pdesc
, __val
, GENMASK(13, 0));
272 static inline void set_rx_desc_eor(__le32
*__pdesc
, u32 __val
)
274 le32p_replace_bits(__pdesc
, __val
, BIT(30));
277 static inline void set_rx_desc_own(__le32
*__pdesc
, u32 __val
)
279 le32p_replace_bits(__pdesc
, __val
, BIT(31));
282 static inline int get_rx_desc_macid(__le32
*__pdesc
)
284 return le32_get_bits(*(__pdesc
+ 1), GENMASK(6, 0));
287 static inline int get_rx_desc_paggr(__le32
*__pdesc
)
289 return le32_get_bits(*(__pdesc
+ 1), BIT(15));
292 static inline int get_rx_status_desc_rpt_sel(__le32
*__pdesc
)
294 return le32_get_bits(*(__pdesc
+ 1), BIT(28));
297 static inline int get_rx_desc_rxmcs(__le32
*__pdesc
)
299 return le32_get_bits(*(__pdesc
+ 3), GENMASK(6, 0));
302 static inline int get_rx_status_desc_pattern_match(__le32
*__pdesc
)
304 return le32_get_bits(*(__pdesc
+ 3), BIT(29));
307 static inline int get_rx_status_desc_unicast_match(__le32
*__pdesc
)
309 return le32_get_bits(*(__pdesc
+ 3), BIT(30));
312 static inline int get_rx_status_desc_magic_match(__le32
*__pdesc
)
314 return le32_get_bits(*(__pdesc
+ 3), BIT(31));
317 static inline int get_rx_desc_splcp(__le32
*__pdesc
)
319 return le32_get_bits(*(__pdesc
+ 4), BIT(0));
322 static inline int get_rx_desc_bw(__le32
*__pdesc
)
324 return le32_get_bits(*(__pdesc
+ 4), GENMASK(5, 4));
327 static inline u32
get_rx_desc_tsfl(__le32
*__pdesc
)
329 return le32_to_cpu(*(__pdesc
+ 5));
332 static inline u32
get_rx_desc_buff_addr(__le32
*__pdesc
)
334 return le32_to_cpu(*(__pdesc
+ 6));
337 static inline void set_rx_desc_buff_addr(__le32
*__pdesc
, u32 __val
)
339 *(__pdesc
+ 6) = cpu_to_le32(__val
);
342 /* TX report 2 format in Rx desc*/
344 static inline u32
get_rx_rpt2_desc_macid_valid_1(__le32
*__status
)
346 return le32_to_cpu(*(__status
+ 4));
349 static inline u32
get_rx_rpt2_desc_macid_valid_2(__le32
*__status
)
351 return le32_to_cpu(*(__status
+ 5));
354 static inline void set_earlymode_pktnum(__le32
*__paddr
, u32 __value
)
356 le32p_replace_bits(__paddr
, __value
, GENMASK(3, 0));
359 static inline void set_earlymode_len0(__le32
*__paddr
, u32 __value
)
361 le32p_replace_bits(__paddr
, __value
, GENMASK(15, 4));
364 static inline void set_earlymode_len1(__le32
*__paddr
, u32 __value
)
366 le32p_replace_bits(__paddr
, __value
, GENMASK(27, 16));
369 static inline void set_earlymode_len2_1(__le32
*__paddr
, u32 __value
)
371 le32p_replace_bits(__paddr
, __value
, GENMASK(31, 28));
374 static inline void set_earlymode_len2_2(__le32
*__paddr
, u32 __value
)
376 le32p_replace_bits(__paddr
, __value
, GENMASK(7, 0));
379 static inline void set_earlymode_len3(__le32
*__paddr
, u32 __value
)
381 le32p_replace_bits((__paddr
+ 1), __value
, GENMASK(19, 8));
384 static inline void set_earlymode_len4(__le32
*__paddr
, u32 __value
)
386 le32p_replace_bits((__paddr
+ 1), __value
, GENMASK(31, 20));
389 static inline void clear_pci_tx_desc_content(__le32
*__pdesc
, int _size
)
391 if (_size
> TX_DESC_NEXT_DESC_OFFSET
)
392 memset(__pdesc
, 0, TX_DESC_NEXT_DESC_OFFSET
);
394 memset(__pdesc
, 0, _size
);
397 #define RTL8821AE_RX_HAL_IS_CCK_RATE(rxmcs)\
398 (rxmcs == DESC_RATE1M ||\
399 rxmcs == DESC_RATE2M ||\
400 rxmcs == DESC_RATE5_5M ||\
401 rxmcs == DESC_RATE11M)
403 struct phy_rx_agc_info_t
{
404 #ifdef __LITTLE_ENDIAN
411 struct phy_status_rpt
{
414 #ifdef __LITTLE_ENDIAN
418 #else /* _BIG_ENDIAN_ */
425 u8 cfosho
[4]; /* DW 1 byte 1 DW 2 byte 0 */
428 s8 cfotail
[4]; /* DW 2 byte 1 DW 3 byte 0 */
431 s8 rxevm
[2]; /* DW 3 byte 1 DW 3 byte 2 */
432 s8 rxsnr
[2]; /* DW 3 byte 3 DW 4 byte 0 */
436 u8 pdsnr
[2]; /* DW 4 byte 3 DW 5 Byte 0 */
451 struct rx_fwinfo_8821ae
{
469 struct tx_desc_8821ae
{
545 u32 rtsrate_fb_lmt
:4;
570 u32 nextdescaddress64
;
572 u32 reserve_pass_pcie_mm_limit
[4];
575 struct rx_desc_8821ae
{
633 void rtl8821ae_tx_fill_desc(struct ieee80211_hw
*hw
,
634 struct ieee80211_hdr
*hdr
, u8
*pdesc_tx
, u8
*txbd
,
635 struct ieee80211_tx_info
*info
,
636 struct ieee80211_sta
*sta
,
638 u8 hw_queue
, struct rtl_tcb_desc
*ptcb_desc
);
639 bool rtl8821ae_rx_query_desc(struct ieee80211_hw
*hw
,
640 struct rtl_stats
*status
,
641 struct ieee80211_rx_status
*rx_status
,
642 u8
*pdesc
, struct sk_buff
*skb
);
643 void rtl8821ae_set_desc(struct ieee80211_hw
*hw
, u8
*pdesc
,
644 bool istx
, u8 desc_name
, u8
*val
);
645 u64
rtl8821ae_get_desc(struct ieee80211_hw
*hw
,
646 u8
*pdesc
, bool istx
, u8 desc_name
);
647 bool rtl8821ae_is_tx_desc_closed(struct ieee80211_hw
*hw
,
648 u8 hw_queue
, u16 index
);
649 void rtl8821ae_tx_polling(struct ieee80211_hw
*hw
, u8 hw_queue
);
650 void rtl8821ae_tx_fill_cmddesc(struct ieee80211_hw
*hw
, u8
*pdesc
,
651 bool firstseg
, bool lastseg
,
652 struct sk_buff
*skb
);