1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
4 #ifndef __RTL92DE_TRX_H__
5 #define __RTL92DE_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 /* macros to read/write various fields in RX or TX descriptors */
19 static inline void set_tx_desc_pkt_size(__le32
*__pdesc
, u32 __val
)
21 le32p_replace_bits(__pdesc
, __val
, GENMASK(15, 0));
24 static inline void set_tx_desc_offset(__le32
*__pdesc
, u32 __val
)
26 le32p_replace_bits(__pdesc
, __val
, GENMASK(23, 16));
29 static inline void set_tx_desc_htc(__le32
*__pdesc
, u32 __val
)
31 le32p_replace_bits(__pdesc
, __val
, BIT(25));
34 static inline void set_tx_desc_last_seg(__le32
*__pdesc
, u32 __val
)
36 le32p_replace_bits(__pdesc
, __val
, BIT(26));
39 static inline void set_tx_desc_first_seg(__le32
*__pdesc
, u32 __val
)
41 le32p_replace_bits(__pdesc
, __val
, BIT(27));
44 static inline void set_tx_desc_linip(__le32
*__pdesc
, u32 __val
)
46 le32p_replace_bits(__pdesc
, __val
, BIT(28));
49 static inline void set_tx_desc_own(__le32
*__pdesc
, u32 __val
)
51 le32p_replace_bits(__pdesc
, __val
, BIT(31));
54 static inline u32
get_tx_desc_own(__le32
*__pdesc
)
56 return le32_get_bits(*__pdesc
, BIT(31));
59 static inline void set_tx_desc_macid(__le32
*__pdesc
, u32 __val
)
61 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(4, 0));
64 static inline void set_tx_desc_agg_enable(__le32
*__pdesc
, u32 __val
)
66 le32p_replace_bits((__pdesc
+ 1), __val
, BIT(5));
69 static inline void set_tx_desc_rdg_enable(__le32
*__pdesc
, u32 __val
)
71 le32p_replace_bits((__pdesc
+ 1), __val
, BIT(7));
74 static inline void set_tx_desc_queue_sel(__le32
*__pdesc
, u32 __val
)
76 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(12, 8));
79 static inline void set_tx_desc_rate_id(__le32
*__pdesc
, u32 __val
)
81 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(19, 16));
84 static inline void set_tx_desc_sec_type(__le32
*__pdesc
, u32 __val
)
86 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(23, 22));
89 static inline void set_tx_desc_pkt_offset(__le32
*__pdesc
, u32 __val
)
91 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(30, 26));
94 static inline void set_tx_desc_more_frag(__le32
*__pdesc
, u32 __val
)
96 le32p_replace_bits((__pdesc
+ 2), __val
, BIT(17));
99 static inline void set_tx_desc_ampdu_density(__le32
*__pdesc
, u32 __val
)
101 le32p_replace_bits((__pdesc
+ 2), __val
, GENMASK(22, 20));
104 static inline void set_tx_desc_seq(__le32
*__pdesc
, u32 __val
)
106 le32p_replace_bits((__pdesc
+ 3), __val
, GENMASK(27, 16));
109 static inline void set_tx_desc_pkt_id(__le32
*__pdesc
, u32 __val
)
111 le32p_replace_bits((__pdesc
+ 3), __val
, GENMASK(31, 28));
114 static inline void set_tx_desc_rts_rate(__le32
*__pdesc
, u32 __val
)
116 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(4, 0));
119 static inline void set_tx_desc_qos(__le32
*__pdesc
, u32 __val
)
121 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(6));
124 static inline void set_tx_desc_hwseq_en(__le32
*__pdesc
, u32 __val
)
126 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(7));
129 static inline void set_tx_desc_use_rate(__le32
*__pdesc
, u32 __val
)
131 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(8));
134 static inline void set_tx_desc_disable_fb(__le32
*__pdesc
, u32 __val
)
136 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(10));
139 static inline void set_tx_desc_cts2self(__le32
*__pdesc
, u32 __val
)
141 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(11));
144 static inline void set_tx_desc_rts_enable(__le32
*__pdesc
, u32 __val
)
146 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(12));
149 static inline void set_tx_desc_hw_rts_enable(__le32
*__pdesc
, u32 __val
)
151 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(13));
154 static inline void set_tx_desc_tx_sub_carrier(__le32
*__pdesc
, u32 __val
)
156 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(21, 20));
159 static inline void set_tx_desc_data_bw(__le32
*__pdesc
, u32 __val
)
161 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(25));
164 static inline void set_tx_desc_rts_short(__le32
*__pdesc
, u32 __val
)
166 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(26));
169 static inline void set_tx_desc_rts_bw(__le32
*__pdesc
, u32 __val
)
171 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(27));
174 static inline void set_tx_desc_rts_sc(__le32
*__pdesc
, u32 __val
)
176 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(29, 28));
179 static inline void set_tx_desc_rts_stbc(__le32
*__pdesc
, u32 __val
)
181 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(31, 30));
184 static inline void set_tx_desc_tx_rate(__le32
*__pdesc
, u32 __val
)
186 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(5, 0));
189 static inline void set_tx_desc_data_shortgi(__le32
*__pdesc
, u32 __val
)
191 le32p_replace_bits((__pdesc
+ 5), __val
, BIT(6));
194 static inline void set_tx_desc_data_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
196 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(12, 8));
199 static inline void set_tx_desc_rts_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
201 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(16, 13));
204 static inline void set_tx_desc_max_agg_num(__le32
*__pdesc
, u32 __val
)
206 le32p_replace_bits((__pdesc
+ 6), __val
, GENMASK(15, 11));
209 static inline void set_tx_desc_tx_buffer_size(__le32
*__pdesc
, u32 __val
)
211 le32p_replace_bits((__pdesc
+ 7), __val
, GENMASK(15, 0));
214 static inline void set_tx_desc_tx_buffer_address(__le32
*__pdesc
, u32 __val
)
216 *(__pdesc
+ 8) = cpu_to_le32(__val
);
219 static inline u32
get_tx_desc_tx_buffer_address(__le32
*__pdesc
)
221 return le32_to_cpu(*(__pdesc
+ 8));
224 static inline void set_tx_desc_next_desc_address(__le32
*__pdesc
, u32 __val
)
226 *(__pdesc
+ 10) = cpu_to_le32(__val
);
229 static inline u32
get_rx_desc_pkt_len(__le32
*__pdesc
)
231 return le32_get_bits(*__pdesc
, GENMASK(13, 0));
234 static inline u32
get_rx_desc_crc32(__le32
*__pdesc
)
236 return le32_get_bits(*__pdesc
, BIT(14));
239 static inline u32
get_rx_desc_icv(__le32
*__pdesc
)
241 return le32_get_bits(*__pdesc
, BIT(15));
244 static inline u32
get_rx_desc_drv_info_size(__le32
*__pdesc
)
246 return le32_get_bits(*__pdesc
, GENMASK(19, 16));
249 static inline u32
get_rx_desc_shift(__le32
*__pdesc
)
251 return le32_get_bits(*__pdesc
, GENMASK(25, 24));
254 static inline u32
get_rx_desc_physt(__le32
*__pdesc
)
256 return le32_get_bits(*__pdesc
, BIT(26));
259 static inline u32
get_rx_desc_swdec(__le32
*__pdesc
)
261 return le32_get_bits(*__pdesc
, BIT(27));
264 static inline u32
get_rx_desc_own(__le32
*__pdesc
)
266 return le32_get_bits(*__pdesc
, BIT(31));
269 static inline void set_rx_desc_pkt_len(__le32
*__pdesc
, u32 __val
)
271 le32p_replace_bits(__pdesc
, __val
, GENMASK(13, 0));
274 static inline void set_rx_desc_eor(__le32
*__pdesc
, u32 __val
)
276 le32p_replace_bits(__pdesc
, __val
, BIT(30));
279 static inline void set_rx_desc_own(__le32
*__pdesc
, u32 __val
)
281 le32p_replace_bits(__pdesc
, __val
, BIT(31));
284 static inline u32
get_rx_desc_paggr(__le32
*__pdesc
)
286 return le32_get_bits(*(__pdesc
+ 1), BIT(14));
289 static inline u32
get_rx_desc_faggr(__le32
*__pdesc
)
291 return le32_get_bits(*(__pdesc
+ 1), BIT(15));
294 static inline u32
get_rx_desc_rxmcs(__le32
*__pdesc
)
296 return le32_get_bits(*(__pdesc
+ 3), GENMASK(5, 0));
299 static inline u32
get_rx_desc_rxht(__le32
*__pdesc
)
301 return le32_get_bits(*(__pdesc
+ 3), BIT(6));
304 static inline u32
get_rx_desc_splcp(__le32
*__pdesc
)
306 return le32_get_bits(*(__pdesc
+ 3), BIT(8));
309 static inline u32
get_rx_desc_bw(__le32
*__pdesc
)
311 return le32_get_bits(*(__pdesc
+ 3), BIT(9));
314 static inline u32
get_rx_desc_tsfl(__le32
*__pdesc
)
316 return le32_to_cpu(*(__pdesc
+ 5));
319 static inline u32
get_rx_desc_buff_addr(__le32
*__pdesc
)
321 return le32_to_cpu(*(__pdesc
+ 6));
324 static inline void set_rx_desc_buff_addr(__le32
*__pdesc
, u32 __val
)
326 *(__pdesc
+ 6) = cpu_to_le32(__val
);
329 static inline void clear_pci_tx_desc_content(__le32
*__pdesc
, u32 _size
)
331 memset((void *)__pdesc
, 0,
332 min_t(size_t, _size
, TX_DESC_NEXT_DESC_OFFSET
));
335 /* For 92D early mode */
336 static inline void set_earlymode_pktnum(__le32
*__paddr
, u32 __value
)
338 le32p_replace_bits(__paddr
, __value
, GENMASK(2, 0));
341 static inline void set_earlymode_len0(__le32
*__paddr
, u32 __value
)
343 le32p_replace_bits(__paddr
, __value
, GENMASK(15, 4));
346 static inline void set_earlymode_len1(__le32
*__paddr
, u32 __value
)
348 le32p_replace_bits(__paddr
, __value
, GENMASK(27, 16));
351 static inline void set_earlymode_len2_1(__le32
*__paddr
, u32 __value
)
353 le32p_replace_bits(__paddr
, __value
, GENMASK(31, 28));
356 static inline void set_earlymode_len2_2(__le32
*__paddr
, u32 __value
)
358 le32p_replace_bits((__paddr
+ 1), __value
, GENMASK(7, 0));
361 static inline void set_earlymode_len3(__le32
*__paddr
, u32 __value
)
363 le32p_replace_bits((__paddr
+ 1), __value
, GENMASK(19, 8));
366 static inline void set_earlymode_len4(__le32
*__paddr
, u32 __value
)
368 le32p_replace_bits((__paddr
+ 1), __value
, GENMASK(31, 20));
371 struct rx_fwinfo_92d
{
463 u32 rtsrate_fb_lmt
:4;
481 u32 mcsg15sgimaxlen
:4;
486 u32 nextdescaddress64
;
488 u32 reserve_pass_pcie_mm_limit
[4];
549 void rtl92de_tx_fill_desc(struct ieee80211_hw
*hw
,
550 struct ieee80211_hdr
*hdr
, u8
*pdesc
,
551 u8
*pbd_desc_tx
, struct ieee80211_tx_info
*info
,
552 struct ieee80211_sta
*sta
,
553 struct sk_buff
*skb
, u8 hw_queue
,
554 struct rtl_tcb_desc
*ptcb_desc
);
555 bool rtl92de_rx_query_desc(struct ieee80211_hw
*hw
,
556 struct rtl_stats
*stats
,
557 struct ieee80211_rx_status
*rx_status
,
558 u8
*pdesc
, struct sk_buff
*skb
);
559 void rtl92de_set_desc(struct ieee80211_hw
*hw
, u8
*pdesc
, bool istx
,
560 u8 desc_name
, u8
*val
);
561 u64
rtl92de_get_desc(struct ieee80211_hw
*hw
,
562 u8
*p_desc
, bool istx
, u8 desc_name
);
563 bool rtl92de_is_tx_desc_closed(struct ieee80211_hw
*hw
,
564 u8 hw_queue
, u16 index
);
565 void rtl92de_tx_polling(struct ieee80211_hw
*hw
, u8 hw_queue
);
566 void rtl92de_tx_fill_cmddesc(struct ieee80211_hw
*hw
, u8
*pdesc
,
567 bool b_firstseg
, bool b_lastseg
,
568 struct sk_buff
*skb
);