1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
4 #ifndef __RTL92CE_TRX_H__
5 #define __RTL92CE_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_bmc(__le32
*__pdesc
, u32 __val
)
31 le32p_replace_bits(__pdesc
, __val
, BIT(24));
34 static inline void set_tx_desc_htc(__le32
*__pdesc
, u32 __val
)
36 le32p_replace_bits(__pdesc
, __val
, BIT(25));
39 static inline void set_tx_desc_last_seg(__le32
*__pdesc
, u32 __val
)
41 le32p_replace_bits(__pdesc
, __val
, BIT(26));
44 static inline void set_tx_desc_first_seg(__le32
*__pdesc
, u32 __val
)
46 le32p_replace_bits(__pdesc
, __val
, BIT(27));
49 static inline void set_tx_desc_linip(__le32
*__pdesc
, u32 __val
)
51 le32p_replace_bits(__pdesc
, __val
, BIT(28));
54 static inline void set_tx_desc_own(__le32
*__pdesc
, u32 __val
)
56 le32p_replace_bits(__pdesc
, __val
, BIT(31));
59 static inline int get_tx_desc_own(__le32
*__pdesc
)
61 return le32_get_bits(*(__pdesc
), BIT(31));
64 static inline void set_tx_desc_macid(__le32
*__pdesc
, u32 __val
)
66 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(4, 0));
69 static inline void set_tx_desc_agg_break(__le32
*__pdesc
, u32 __val
)
71 le32p_replace_bits((__pdesc
+ 1), __val
, BIT(5));
74 static inline void set_tx_desc_rdg_enable(__le32
*__pdesc
, u32 __val
)
76 le32p_replace_bits((__pdesc
+ 1), __val
, BIT(7));
79 static inline void set_tx_desc_queue_sel(__le32
*__pdesc
, u32 __val
)
81 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(12, 8));
84 static inline void set_tx_desc_rate_id(__le32
*__pdesc
, u32 __val
)
86 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(19, 16));
89 static inline void set_tx_desc_sec_type(__le32
*__pdesc
, u32 __val
)
91 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(23, 22));
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 int get_rx_desc_pkt_len(__le32
*__pdesc
)
231 return le32_get_bits(*(__pdesc
), GENMASK(13, 0));
234 static inline int get_rx_desc_crc32(__le32
*__pdesc
)
236 return le32_get_bits(*(__pdesc
), BIT(14));
239 static inline int get_rx_desc_icv(__le32
*__pdesc
)
241 return le32_get_bits(*(__pdesc
), BIT(15));
244 static inline int get_rx_desc_drv_info_size(__le32
*__pdesc
)
246 return le32_get_bits(*(__pdesc
), GENMASK(19, 16));
249 static inline int get_rx_desc_shift(__le32
*__pdesc
)
251 return le32_get_bits(*(__pdesc
), GENMASK(25, 24));
254 static inline int get_rx_desc_physt(__le32
*__pdesc
)
256 return le32_get_bits(*(__pdesc
), BIT(26));
259 static inline int get_rx_desc_swdec(__le32
*__pdesc
)
261 return le32_get_bits(*(__pdesc
), BIT(27));
264 static inline int 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 int get_rx_desc_paggr(__le32
*__pdesc
)
286 return le32_get_bits(*((__pdesc
+ 1)), BIT(14));
289 static inline int get_rx_desc_faggr(__le32
*__pdesc
)
291 return le32_get_bits(*((__pdesc
+ 1)), BIT(15));
294 static inline int get_rx_desc_rxmcs(__le32
*__pdesc
)
296 return le32_get_bits(*((__pdesc
+ 3)), GENMASK(5, 0));
299 static inline int get_rx_desc_rxht(__le32
*__pdesc
)
301 return le32_get_bits(*((__pdesc
+ 3)), BIT(6));
304 static inline int get_rx_desc_splcp(__le32
*__pdesc
)
306 return le32_get_bits(*((__pdesc
+ 3)), BIT(8));
309 static inline int 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
, int _size
)
331 memset(__pdesc
, 0, min_t(size_t, _size
, TX_DESC_NEXT_DESC_OFFSET
));
334 struct rx_fwinfo_92c
{
426 u32 rtsrate_fb_lmt
:4;
444 u32 mcsg15sgimaxlen
:4;
449 u32 nextdescaddress64
;
451 u32 reserve_pass_pcie_mm_limit
[4];
512 void rtl92ce_tx_fill_desc(struct ieee80211_hw
*hw
,
513 struct ieee80211_hdr
*hdr
, u8
*pdesc
,
514 u8
*pbd_desc_tx
, struct ieee80211_tx_info
*info
,
515 struct ieee80211_sta
*sta
,
516 struct sk_buff
*skb
, u8 hw_queue
,
517 struct rtl_tcb_desc
*ptcb_desc
);
518 bool rtl92ce_rx_query_desc(struct ieee80211_hw
*hw
,
519 struct rtl_stats
*stats
,
520 struct ieee80211_rx_status
*rx_status
,
521 u8
*pdesc
, struct sk_buff
*skb
);
522 void rtl92ce_set_desc(struct ieee80211_hw
*hw
, u8
*pdesc
, bool istx
,
523 u8 desc_name
, u8
*val
);
524 u64
rtl92ce_get_desc(struct ieee80211_hw
*hw
, u8
*p_desc
,
525 bool istx
, u8 desc_name
);
526 bool rtl92ce_is_tx_desc_closed(struct ieee80211_hw
*hw
,
527 u8 hw_queue
, u16 index
);
528 void rtl92ce_tx_polling(struct ieee80211_hw
*hw
, u8 hw_queue
);
529 void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw
*hw
, u8
*pdesc
,
530 bool b_firstseg
, bool b_lastseg
,
531 struct sk_buff
*skb
);