1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2013 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 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(5, 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(19, 16));
77 static inline void set_tx_desc_nav_use_hdr(__le32
*__pdesc
, u32 __val
)
79 le32p_replace_bits(__pdesc
+ 1, __val
, BIT(20));
82 static inline void set_tx_desc_sec_type(__le32
*__pdesc
, u32 __val
)
84 le32p_replace_bits(__pdesc
+ 1, __val
, GENMASK(23, 22));
87 static inline void set_tx_desc_pkt_offset(__le32
*__pdesc
, u32 __val
)
89 le32p_replace_bits(__pdesc
+ 1, __val
, GENMASK(30, 26));
92 static inline void set_tx_desc_agg_enable(__le32
*__pdesc
, u32 __val
)
94 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(12));
97 static inline void set_tx_desc_rdg_enable(__le32
*__pdesc
, u32 __val
)
99 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(13));
102 static inline void set_tx_desc_more_frag(__le32
*__pdesc
, u32 __val
)
104 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(17));
107 static inline void set_tx_desc_ampdu_density(__le32
*__pdesc
, u32 __val
)
109 le32p_replace_bits(__pdesc
+ 2, __val
, GENMASK(22, 20));
112 static inline void set_tx_desc_antsel_a(__le32
*__pdesc
, u32 __val
)
114 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(24));
117 static inline void set_tx_desc_antsel_b(__le32
*__pdesc
, u32 __val
)
119 le32p_replace_bits(__pdesc
+ 2, __val
, BIT(25));
122 static inline void set_tx_desc_seq(__le32
*__pdesc
, u32 __val
)
124 le32p_replace_bits(__pdesc
+ 3, __val
, GENMASK(27, 16));
127 static inline void set_tx_desc_hwseq_en(__le32
*__pdesc
, u32 __val
)
129 le32p_replace_bits(__pdesc
+ 3, __val
, BIT(31));
132 static inline void set_tx_desc_rts_rate(__le32
*__pdesc
, u32 __val
)
134 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(4, 0));
137 static inline void set_tx_desc_qos(__le32
*__pdesc
, u32 __val
)
139 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(6));
142 static inline void set_tx_desc_use_rate(__le32
*__pdesc
, u32 __val
)
144 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(8));
147 static inline void set_tx_desc_disable_fb(__le32
*__pdesc
, u32 __val
)
149 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(10));
152 static inline void set_tx_desc_cts2self(__le32
*__pdesc
, u32 __val
)
154 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(11));
157 static inline void set_tx_desc_rts_enable(__le32
*__pdesc
, u32 __val
)
159 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(12));
162 static inline void set_tx_desc_hw_rts_enable(__le32
*__pdesc
, u32 __val
)
164 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(13));
167 static inline void set_tx_desc_tx_sub_carrier(__le32
*__pdesc
, u32 __val
)
169 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(21, 20));
172 static inline void set_tx_desc_tx_stbc(__le32
*__pdesc
, u32 __val
)
174 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(23, 22));
177 static inline void set_tx_desc_data_bw(__le32
*__pdesc
, u32 __val
)
179 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(25));
182 static inline void set_tx_desc_rts_short(__le32
*__pdesc
, u32 __val
)
184 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(26));
187 static inline void set_tx_desc_rts_bw(__le32
*__pdesc
, u32 __val
)
189 le32p_replace_bits(__pdesc
+ 4, __val
, BIT(27));
192 static inline void set_tx_desc_rts_sc(__le32
*__pdesc
, u32 __val
)
194 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(29, 28));
197 static inline void set_tx_desc_rts_stbc(__le32
*__pdesc
, u32 __val
)
199 le32p_replace_bits(__pdesc
+ 4, __val
, GENMASK(31, 30));
202 static inline void set_tx_desc_tx_rate(__le32
*__pdesc
, u32 __val
)
204 le32p_replace_bits(__pdesc
+ 5, __val
, GENMASK(5, 0));
207 static inline void set_tx_desc_data_shortgi(__le32
*__pdesc
, u32 __val
)
209 le32p_replace_bits(__pdesc
+ 5, __val
, BIT(6));
212 static inline void set_tx_desc_data_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
214 le32p_replace_bits(__pdesc
+ 5, __val
, GENMASK(12, 8));
217 static inline void set_tx_desc_rts_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
219 le32p_replace_bits(__pdesc
+ 5, __val
, GENMASK(16, 13));
222 static inline void set_tx_desc_max_agg_num(__le32
*__pdesc
, u32 __val
)
224 le32p_replace_bits(__pdesc
+ 6, __val
, GENMASK(15, 11));
227 static inline void set_tx_desc_antsel_c(__le32
*__pdesc
, u32 __val
)
229 le32p_replace_bits(__pdesc
+ 7, __val
, BIT(29));
232 static inline void set_tx_desc_tx_buffer_size(__le32
*__pdesc
, u32 __val
)
234 le32p_replace_bits(__pdesc
+ 7, __val
, GENMASK(15, 0));
237 static inline int get_tx_desc_tx_buffer_size(__le32
*__pdesc
)
239 return le32_get_bits(*(__pdesc
+ 7), GENMASK(15, 0));
242 static inline void set_tx_desc_tx_buffer_address(__le32
*__pdesc
, u32 __val
)
244 *(__pdesc
+ 8) = cpu_to_le32(__val
);
247 static inline u32
get_tx_desc_tx_buffer_address(__le32
*__pdesc
)
249 return le32_to_cpu(*(__pdesc
+ 8));
252 static inline void set_tx_desc_next_desc_address(__le32
*__pdesc
, u32 __val
)
254 *(__pdesc
+ 10) = cpu_to_le32(__val
);
257 static inline int get_rx_desc_pkt_len(__le32
*__pdesc
)
259 return le32_get_bits(*(__pdesc
), GENMASK(13, 0));
262 static inline int get_rx_desc_crc32(__le32
*__pdesc
)
264 return le32_get_bits(*(__pdesc
), BIT(14));
267 static inline int get_rx_desc_icv(__le32
*__pdesc
)
269 return le32_get_bits(*(__pdesc
), BIT(15));
272 static inline int get_rx_desc_drv_info_size(__le32
*__pdesc
)
274 return le32_get_bits(*(__pdesc
), GENMASK(19, 16));
277 static inline int get_rx_desc_security(__le32
*__pdesc
)
279 return le32_get_bits(*(__pdesc
), GENMASK(22, 20));
282 static inline int get_rx_desc_qos(__le32
*__pdesc
)
284 return le32_get_bits(*(__pdesc
), BIT(23));
287 static inline int get_rx_desc_shift(__le32
*__pdesc
)
289 return le32_get_bits(*(__pdesc
), GENMASK(25, 24));
292 static inline int get_rx_desc_physt(__le32
*__pdesc
)
294 return le32_get_bits(*(__pdesc
), BIT(26));
297 static inline int get_rx_desc_swdec(__le32
*__pdesc
)
299 return le32_get_bits(*(__pdesc
), BIT(27));
302 static inline int get_rx_desc_ls(__le32
*__pdesc
)
304 return le32_get_bits(*(__pdesc
), BIT(28));
307 static inline int get_rx_desc_fs(__le32
*__pdesc
)
309 return le32_get_bits(*(__pdesc
), BIT(29));
312 static inline int get_rx_desc_eor(__le32
*__pdesc
)
314 return le32_get_bits(*(__pdesc
), BIT(30));
317 static inline int get_rx_desc_own(__le32
*__pdesc
)
319 return le32_get_bits(*(__pdesc
), BIT(31));
322 static inline void set_rx_desc_pkt_len(__le32
*__pdesc
, u32 __val
)
324 le32p_replace_bits(__pdesc
, __val
, GENMASK(13, 0));
327 static inline void set_rx_desc_eor(__le32
*__pdesc
, u32 __val
)
329 le32p_replace_bits(__pdesc
, __val
, BIT(30));
332 static inline void set_rx_desc_own(__le32
*__pdesc
, u32 __val
)
334 le32p_replace_bits(__pdesc
, __val
, BIT(31));
337 static inline int get_rx_desc_macid(__le32
*__pdesc
)
339 return le32_get_bits(*(__pdesc
+ 1), GENMASK(5, 0));
342 static inline int get_rx_desc_paggr(__le32
*__pdesc
)
344 return le32_get_bits(*(__pdesc
+ 1), BIT(14));
347 static inline int get_rx_desc_faggr(__le32
*__pdesc
)
349 return le32_get_bits(*(__pdesc
+ 1), BIT(15));
352 static inline int get_rx_desc_a1_fit(__le32
*__pdesc
)
354 return le32_get_bits(*(__pdesc
+ 1), GENMASK(19, 16));
357 static inline int get_rx_desc_a2_fit(__le32
*__pdesc
)
359 return le32_get_bits(*(__pdesc
+ 1), GENMASK(23, 20));
362 static inline int get_rx_desc_pam(__le32
*__pdesc
)
364 return le32_get_bits(*(__pdesc
+ 1), BIT(24));
367 static inline int get_rx_desc_pwr(__le32
*__pdesc
)
369 return le32_get_bits(*(__pdesc
+ 1), BIT(25));
372 static inline int get_rx_desc_md(__le32
*__pdesc
)
374 return le32_get_bits(*(__pdesc
+ 1), BIT(26));
377 static inline int get_rx_desc_mf(__le32
*__pdesc
)
379 return le32_get_bits(*(__pdesc
+ 1), BIT(27));
382 static inline int get_rx_desc_type(__le32
*__pdesc
)
384 return le32_get_bits(*(__pdesc
+ 1), GENMASK(29, 28));
387 static inline int get_rx_desc_mc(__le32
*__pdesc
)
389 return le32_get_bits(*(__pdesc
+ 1), BIT(30));
392 static inline int get_rx_desc_bc(__le32
*__pdesc
)
394 return le32_get_bits(*(__pdesc
+ 1), BIT(31));
397 static inline int get_rx_desc_seq(__le32
*__pdesc
)
399 return le32_get_bits(*(__pdesc
+ 2), GENMASK(11, 0));
402 static inline int get_rx_desc_frag(__le32
*__pdesc
)
404 return le32_get_bits(*(__pdesc
+ 2), GENMASK(15, 12));
407 static inline int get_rx_desc_rxmcs(__le32
*__pdesc
)
409 return le32_get_bits(*(__pdesc
+ 3), GENMASK(5, 0));
412 static inline int get_rx_desc_rxht(__le32
*__pdesc
)
414 return le32_get_bits(*(__pdesc
+ 3), BIT(6));
417 static inline int get_rx_status_desc_rx_gf(__le32
*__pdesc
)
419 return le32_get_bits(*(__pdesc
+ 3), BIT(7));
422 static inline int get_rx_desc_splcp(__le32
*__pdesc
)
424 return le32_get_bits(*(__pdesc
+ 3), BIT(8));
427 static inline int get_rx_desc_bw(__le32
*__pdesc
)
429 return le32_get_bits(*(__pdesc
+ 3), BIT(9));
432 static inline int get_rx_desc_htc(__le32
*__pdesc
)
434 return le32_get_bits(*(__pdesc
+ 3), BIT(10));
437 static inline int get_rx_status_desc_eosp(__le32
*__pdesc
)
439 return le32_get_bits(*(__pdesc
+ 3), BIT(11));
442 static inline int get_rx_status_desc_bssid_fit(__le32
*__pdesc
)
444 return le32_get_bits(*(__pdesc
+ 3), GENMASK(13, 12));
447 static inline int get_rx_status_desc_rpt_sel(__le32
*__pdesc
)
449 return le32_get_bits(*(__pdesc
+ 3), GENMASK(15, 14));
452 static inline int get_rx_status_desc_pattern_match(__le32
*__pdesc
)
454 return le32_get_bits(*(__pdesc
+ 3), BIT(29));
457 static inline int get_rx_status_desc_unicast_match(__le32
*__pdesc
)
459 return le32_get_bits(*(__pdesc
+ 3), BIT(30));
462 static inline int get_rx_status_desc_magic_match(__le32
*__pdesc
)
464 return le32_get_bits(*(__pdesc
+ 3), BIT(31));
467 static inline u32
get_rx_desc_iv1(__le32
*__pdesc
)
469 return le32_to_cpu(*(__pdesc
+ 4));
472 static inline u32
get_rx_desc_tsfl(__le32
*__pdesc
)
474 return le32_to_cpu(*(__pdesc
+ 5));
477 static inline u32
get_rx_desc_buff_addr(__le32
*__pdesc
)
479 return le32_to_cpu(*(__pdesc
+ 6));
482 static inline u32
get_rx_desc_buff_addr64(__le32
*__pdesc
)
484 return le32_to_cpu(*(__pdesc
+ 7));
487 static inline void set_rx_desc_buff_addr(__le32
*__pdesc
, u32 __val
)
489 *(__pdesc
+ 6) = cpu_to_le32(__val
);
492 static inline void set_rx_desc_buff_addr64(__le32
*__pdesc
, u32 __val
)
494 *(__pdesc
+ 7) = cpu_to_le32(__val
);
497 /* TX report 2 format in Rx desc*/
499 static inline int get_rx_rpt2_desc_pkt_len(__le32
*__status
)
501 return le32_get_bits(*(__status
), GENMASK(8, 0));
504 static inline u32
get_rx_rpt2_desc_macid_valid_1(__le32
*__status
)
506 return le32_to_cpu(*(__status
+ 4));
509 static inline u32
get_rx_rpt2_desc_macid_valid_2(__le32
*__status
)
511 return le32_to_cpu(*(__status
+ 5));
514 static inline void set_earlymode_pktnum(__le32
*__paddr
, u32 __value
)
516 le32p_replace_bits(__paddr
, __value
, GENMASK(3, 0));
519 static inline void set_earlymode_len0(__le32
*__paddr
, u32 __value
)
521 le32p_replace_bits(__paddr
, __value
, GENMASK(15, 4));
524 static inline void set_earlymode_len1(__le32
*__paddr
, u32 __value
)
526 le32p_replace_bits(__paddr
, __value
, GENMASK(27, 16));
529 static inline void set_earlymode_len2_1(__le32
*__paddr
, u32 __value
)
531 le32p_replace_bits(__paddr
, __value
, GENMASK(31, 28));
534 static inline void set_earlymode_len2_2(__le32
*__paddr
, u32 __value
)
536 le32p_replace_bits(__paddr
+ 1, __value
, GENMASK(7, 0));
539 static inline void set_earlymode_len3(__le32
*__paddr
, u32 __value
)
541 le32p_replace_bits(__paddr
+ 1, __value
, GENMASK(19, 8));
544 static inline void set_earlymode_len4(__le32
*__paddr
, u32 __value
)
546 le32p_replace_bits(__paddr
+ 1, __value
, GENMASK(31, 20));
549 static inline void clear_pci_tx_desc_content(__le32
*__pdesc
, int _size
)
551 if (_size
> TX_DESC_NEXT_DESC_OFFSET
)
552 memset(__pdesc
, 0, TX_DESC_NEXT_DESC_OFFSET
);
554 memset(__pdesc
, 0, _size
);
557 #define RTL8188_RX_HAL_IS_CCK_RATE(rxmcs)\
558 (rxmcs == DESC92C_RATE1M ||\
559 rxmcs == DESC92C_RATE2M ||\
560 rxmcs == DESC92C_RATE5_5M ||\
561 rxmcs == DESC92C_RATE11M)
563 struct phy_status_rpt
{
566 u8 cck_sig_qual_ofdm_pwdb_all
;
567 u8 cck_agc_rpt_ofdm_cfosho_a
;
568 u8 cck_rpt_b_ofdm_cfosho_b
;
569 u8 rsvd_1
;/* ch_corr_msb; */
570 u8 noise_power_db_msb
;
575 u8 noise_power_db_lsb
;
578 u8 stream_target_csi
[2];
581 #if defined(__LITTLE_ENDIAN)
582 u8 antsel_rx_keep_2
:1; /*ex_intf_flg:1;*/
589 #else /* __BIG_ENDIAN */
596 u8 antsel_rx_keep_2
:1; /*ex_intf_flg:1;*/
600 struct rx_fwinfo_88e
{
694 u32 rtsrate_fb_lmt
:4;
719 u32 nextdescaddress64
;
721 u32 reserve_pass_pcie_mm_limit
[4];
782 void rtl88ee_tx_fill_desc(struct ieee80211_hw
*hw
,
783 struct ieee80211_hdr
*hdr
, u8
*pdesc_tx
,
784 u8
*txbd
, struct ieee80211_tx_info
*info
,
785 struct ieee80211_sta
*sta
,
787 u8 hw_queue
, struct rtl_tcb_desc
*ptcb_desc
);
788 bool rtl88ee_rx_query_desc(struct ieee80211_hw
*hw
,
789 struct rtl_stats
*status
,
790 struct ieee80211_rx_status
*rx_status
,
791 u8
*pdesc
, struct sk_buff
*skb
);
792 void rtl88ee_set_desc(struct ieee80211_hw
*hw
, u8
*pdesc
,
793 bool istx
, u8 desc_name
, u8
*val
);
794 u64
rtl88ee_get_desc(struct ieee80211_hw
*hw
,
795 u8
*pdesc
, bool istx
, u8 desc_name
);
796 bool rtl88ee_is_tx_desc_closed(struct ieee80211_hw
*hw
,
797 u8 hw_queue
, u16 index
);
798 void rtl88ee_tx_polling(struct ieee80211_hw
*hw
, u8 hw_queue
);
799 void rtl88ee_tx_fill_cmddesc(struct ieee80211_hw
*hw
, u8
*pdesc
,
800 bool firstseg
, bool lastseg
,
801 struct sk_buff
*skb
);