1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
4 #ifndef __RTL8723E_TRX_H__
5 #define __RTL8723E_TRX_H__
7 #define TX_DESC_SIZE 64
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 32
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 u32
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(4, 0));
67 static inline void set_tx_desc_agg_break(__le32
*__pdesc
, u32 __val
)
69 le32p_replace_bits((__pdesc
+ 1), __val
, BIT(5));
72 static inline void set_tx_desc_rdg_enable(__le32
*__pdesc
, u32 __val
)
74 le32p_replace_bits((__pdesc
+ 1), __val
, BIT(7));
77 static inline void set_tx_desc_queue_sel(__le32
*__pdesc
, u32 __val
)
79 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(12, 8));
82 static inline void set_tx_desc_rate_id(__le32
*__pdesc
, u32 __val
)
84 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(19, 16));
87 static inline void set_tx_desc_sec_type(__le32
*__pdesc
, u32 __val
)
89 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(23, 22));
92 static inline void set_tx_desc_more_frag(__le32
*__pdesc
, u32 __val
)
94 le32p_replace_bits((__pdesc
+ 2), __val
, BIT(17));
97 static inline void set_tx_desc_ampdu_density(__le32
*__pdesc
, u32 __val
)
99 le32p_replace_bits((__pdesc
+ 2), __val
, GENMASK(22, 20));
102 static inline void set_tx_desc_seq(__le32
*__pdesc
, u32 __val
)
104 le32p_replace_bits((__pdesc
+ 3), __val
, GENMASK(27, 16));
107 static inline void set_tx_desc_pkt_id(__le32
*__pdesc
, u32 __val
)
109 le32p_replace_bits((__pdesc
+ 3), __val
, GENMASK(31, 28));
113 static inline void set_tx_desc_hwseq_en_8723(__le32
*__pdesc
, u32 __val
)
115 le32p_replace_bits((__pdesc
+ 3), __val
, BIT(31));
118 static inline void set_tx_desc_hwseq_sel_8723(__le32
*__txdesc
, u32 __value
)
120 le32p_replace_bits((__txdesc
+ 4), __value
, GENMASK(7, 6));
123 static inline void set_tx_desc_rts_rate(__le32
*__pdesc
, u32 __val
)
125 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(4, 0));
128 static inline void set_tx_desc_use_rate(__le32
*__pdesc
, u32 __val
)
130 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(8));
133 static inline void set_tx_desc_disable_fb(__le32
*__pdesc
, u32 __val
)
135 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(10));
138 static inline void set_tx_desc_cts2self(__le32
*__pdesc
, u32 __val
)
140 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(11));
143 static inline void set_tx_desc_rts_enable(__le32
*__pdesc
, u32 __val
)
145 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(12));
148 static inline void set_tx_desc_hw_rts_enable(__le32
*__pdesc
, u32 __val
)
150 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(13));
153 static inline void set_tx_desc_tx_sub_carrier(__le32
*__pdesc
, u32 __val
)
155 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(21, 20));
158 static inline void set_tx_desc_data_bw(__le32
*__pdesc
, u32 __val
)
160 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(25));
163 static inline void set_tx_desc_rts_short(__le32
*__pdesc
, u32 __val
)
165 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(26));
168 static inline void set_tx_desc_rts_bw(__le32
*__pdesc
, u32 __val
)
170 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(27));
173 static inline void set_tx_desc_rts_sc(__le32
*__pdesc
, u32 __val
)
175 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(29, 28));
178 static inline void set_tx_desc_rts_stbc(__le32
*__pdesc
, u32 __val
)
180 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(31, 30));
183 static inline void set_tx_desc_tx_rate(__le32
*__pdesc
, u32 __val
)
185 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(5, 0));
188 static inline void set_tx_desc_data_shortgi(__le32
*__pdesc
, u32 __val
)
190 le32p_replace_bits((__pdesc
+ 5), __val
, BIT(6));
193 static inline void set_tx_desc_data_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
195 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(12, 8));
198 static inline void set_tx_desc_rts_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
200 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(16, 13));
203 static inline void set_tx_desc_max_agg_num(__le32
*__pdesc
, u32 __val
)
205 le32p_replace_bits((__pdesc
+ 6), __val
, GENMASK(15, 11));
208 static inline void set_tx_desc_tx_buffer_size(__le32
*__pdesc
, u32 __val
)
210 le32p_replace_bits((__pdesc
+ 7), __val
, GENMASK(15, 0));
213 static inline void set_tx_desc_tx_buffer_address(__le32
*__pdesc
, u32 __val
)
215 *(__pdesc
+ 8) = cpu_to_le32(__val
);
218 static inline u32
get_tx_desc_tx_buffer_address(__le32
*__pdesc
)
220 return le32_to_cpu(*(__pdesc
+ 8));
223 static inline void set_tx_desc_next_desc_address(__le32
*__pdesc
, u32 __val
)
225 *(__pdesc
+ 10) = cpu_to_le32(__val
);
228 static inline u32
get_rx_desc_pkt_len(__le32
*__pdesc
)
230 return le32_get_bits(*__pdesc
, GENMASK(13, 0));
233 static inline u32
get_rx_desc_crc32(__le32
*__pdesc
)
235 return le32_get_bits(*__pdesc
, BIT(14));
238 static inline u32
get_rx_desc_icv(__le32
*__pdesc
)
240 return le32_get_bits(*__pdesc
, BIT(15));
243 static inline u32
get_rx_desc_drv_info_size(__le32
*__pdesc
)
245 return le32_get_bits(*__pdesc
, GENMASK(19, 16));
248 static inline u32
get_rx_desc_shift(__le32
*__pdesc
)
250 return le32_get_bits(*__pdesc
, GENMASK(25, 24));
253 static inline u32
get_rx_desc_physt(__le32
*__pdesc
)
255 return le32_get_bits(*__pdesc
, BIT(26));
258 static inline u32
get_rx_desc_swdec(__le32
*__pdesc
)
260 return le32_get_bits(*__pdesc
, BIT(27));
263 static inline u32
get_rx_desc_own(__le32
*__pdesc
)
265 return le32_get_bits(*__pdesc
, BIT(31));
268 static inline void set_rx_desc_pkt_len(__le32
*__pdesc
, u32 __val
)
270 le32p_replace_bits(__pdesc
, __val
, GENMASK(13, 0));
273 static inline void set_rx_desc_eor(__le32
*__pdesc
, u32 __val
)
275 le32p_replace_bits(__pdesc
, __val
, BIT(30));
278 static inline void set_rx_desc_own(__le32
*__pdesc
, u32 __val
)
280 le32p_replace_bits(__pdesc
, __val
, BIT(31));
283 static inline u32
get_rx_desc_paggr(__le32
*__pdesc
)
285 return le32_get_bits(*(__pdesc
+ 1), BIT(14));
288 static inline u32
get_rx_desc_faggr(__le32
*__pdesc
)
290 return le32_get_bits(*(__pdesc
+ 1), BIT(15));
293 static inline u32
get_rx_desc_rxmcs(__le32
*__pdesc
)
295 return le32_get_bits(*(__pdesc
+ 3), GENMASK(5, 0));
298 static inline u32
get_rx_desc_rxht(__le32
*__pdesc
)
300 return le32_get_bits(*(__pdesc
+ 3), BIT(6));
303 static inline u32
get_rx_desc_splcp(__le32
*__pdesc
)
305 return le32_get_bits(*(__pdesc
+ 3), BIT(8));
308 static inline u32
get_rx_desc_bw(__le32
*__pdesc
)
310 return le32_get_bits(*(__pdesc
+ 3), BIT(9));
313 static inline u32
get_rx_desc_tsfl(__le32
*__pdesc
)
315 return le32_to_cpu(*(__pdesc
+ 5));
318 static inline u32
get_rx_desc_buff_addr(__le32
*__pdesc
)
320 return le32_to_cpu(*(__pdesc
+ 6));
323 static inline void set_rx_desc_buff_addr(__le32
*__pdesc
, u32 __val
)
325 *(__pdesc
+ 6) = cpu_to_le32(__val
);
328 static inline void clear_pci_tx_desc_content(__le32
*__pdesc
, u32 _size
)
330 if (_size
> TX_DESC_NEXT_DESC_OFFSET
)
331 memset(__pdesc
, 0, TX_DESC_NEXT_DESC_OFFSET
);
333 memset(__pdesc
, 0, _size
);
336 struct rx_fwinfo_8723e
{
354 struct tx_desc_8723e
{
428 u32 rtsrate_fb_lmt
:4;
446 u32 mcsg15sgimaxlen
:4;
451 u32 nextdescaddress64
;
453 u32 reserve_pass_pcie_mm_limit
[4];
456 struct rx_desc_8723e
{
514 void rtl8723e_tx_fill_desc(struct ieee80211_hw
*hw
,
515 struct ieee80211_hdr
*hdr
,
517 struct ieee80211_tx_info
*info
,
518 struct ieee80211_sta
*sta
,
519 struct sk_buff
*skb
, u8 hw_queue
,
520 struct rtl_tcb_desc
*ptcb_desc
);
521 bool rtl8723e_rx_query_desc(struct ieee80211_hw
*hw
,
522 struct rtl_stats
*status
,
523 struct ieee80211_rx_status
*rx_status
,
524 u8
*pdesc
, struct sk_buff
*skb
);
525 void rtl8723e_set_desc(struct ieee80211_hw
*hw
,
526 u8
*pdesc
, bool istx
, u8 desc_name
, u8
*val
);
527 u64
rtl8723e_get_desc(struct ieee80211_hw
*hw
,
528 u8
*pdesc
, bool istx
, u8 desc_name
);
529 bool rtl8723e_is_tx_desc_closed(struct ieee80211_hw
*hw
,
530 u8 hw_queue
, u16 index
);
531 void rtl8723e_tx_polling(struct ieee80211_hw
*hw
, u8 hw_queue
);
532 void rtl8723e_tx_fill_cmddesc(struct ieee80211_hw
*hw
, u8
*pdesc
,
533 bool firstseg
, bool lastseg
,
534 struct sk_buff
*skb
);