Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / net / wireless / realtek / rtlwifi / rtl8723be / trx.h
blob174aca20c7e1a0241165448d0225a57ea2bb2933
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2014 Realtek Corporation.*/
4 #ifndef __RTL8723BE_TRX_H__
5 #define __RTL8723BE_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
15 #define CRCLENGTH 4
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(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_rate(__le32 *__pdesc, u32 __val)
149 le32p_replace_bits((__pdesc + 4), __val, GENMASK(6, 0));
152 static inline void set_tx_desc_data_rate_fb_limit(__le32 *__pdesc, u32 __val)
154 le32p_replace_bits((__pdesc + 4), __val, GENMASK(12, 8));
157 static inline void set_tx_desc_rts_rate_fb_limit(__le32 *__pdesc, u32 __val)
159 le32p_replace_bits((__pdesc + 4), __val, GENMASK(16, 13));
162 static inline void set_tx_desc_rts_rate(__le32 *__pdesc, u32 __val)
164 le32p_replace_bits((__pdesc + 4), __val, GENMASK(28, 24));
167 static inline void set_tx_desc_tx_sub_carrier(__le32 *__pdesc, u32 __val)
169 le32p_replace_bits((__pdesc + 5), __val, GENMASK(3, 0));
172 static inline void set_tx_desc_data_shortgi(__le32 *__pdesc, u32 __val)
174 le32p_replace_bits((__pdesc + 5), __val, BIT(4));
177 static inline void set_tx_desc_data_bw(__le32 *__pdesc, u32 __val)
179 le32p_replace_bits((__pdesc + 5), __val, GENMASK(6, 5));
182 static inline void set_tx_desc_rts_short(__le32 *__pdesc, u32 __val)
184 le32p_replace_bits((__pdesc + 5), __val, BIT(12));
187 static inline void set_tx_desc_rts_sc(__le32 *__pdesc, u32 __val)
189 le32p_replace_bits((__pdesc + 5), __val, GENMASK(16, 13));
192 static inline void set_tx_desc_tx_buffer_size(__le32 *__pdesc, u32 __val)
194 le32p_replace_bits((__pdesc + 7), __val, GENMASK(15, 0));
197 static inline void set_tx_desc_hwseq_en(__le32 *__pdesc, u32 __val)
199 le32p_replace_bits((__pdesc + 8), __val, BIT(15));
202 static inline void set_tx_desc_seq(__le32 *__pdesc, u32 __val)
204 le32p_replace_bits((__pdesc + 9), __val, GENMASK(23, 12));
207 static inline void set_tx_desc_tx_buffer_address(__le32 *__pdesc, u32 __val)
209 *(__pdesc + 10) = cpu_to_le32(__val);
212 static inline u32 get_tx_desc_tx_buffer_address(__le32 *__pdesc)
214 return le32_to_cpu(*((__pdesc + 10)));
217 static inline void set_tx_desc_next_desc_address(__le32 *__pdesc, u32 __val)
219 *(__pdesc + 12) = cpu_to_le32(__val);
222 static inline u32 get_rx_desc_pkt_len(__le32 *__pdesc)
224 return le32_get_bits(*__pdesc, GENMASK(13, 0));
227 static inline u32 get_rx_desc_crc32(__le32 *__pdesc)
229 return le32_get_bits(*__pdesc, BIT(14));
232 static inline u32 get_rx_desc_icv(__le32 *__pdesc)
234 return le32_get_bits(*__pdesc, BIT(15));
237 static inline u32 get_rx_desc_drv_info_size(__le32 *__pdesc)
239 return le32_get_bits(*__pdesc, GENMASK(19, 16));
242 static inline u32 get_rx_desc_shift(__le32 *__pdesc)
244 return le32_get_bits(*__pdesc, GENMASK(25, 24));
247 static inline u32 get_rx_desc_physt(__le32 *__pdesc)
249 return le32_get_bits(*__pdesc, BIT(26));
252 static inline u32 get_rx_desc_swdec(__le32 *__pdesc)
254 return le32_get_bits(*__pdesc, BIT(27));
257 static inline u32 get_rx_desc_own(__le32 *__pdesc)
259 return le32_get_bits(*__pdesc, BIT(31));
262 static inline void set_rx_desc_pkt_len(__le32 *__pdesc, u32 __val)
264 le32p_replace_bits(__pdesc, __val, GENMASK(13, 0));
267 static inline void set_rx_desc_eor(__le32 *__pdesc, u32 __val)
269 le32p_replace_bits(__pdesc, __val, BIT(30));
272 static inline void set_rx_desc_own(__le32 *__pdesc, u32 __val)
274 le32p_replace_bits(__pdesc, __val, BIT(31));
277 static inline u32 get_rx_desc_macid(__le32 *__pdesc)
279 return le32_get_bits(*(__pdesc + 1), GENMASK(6, 0));
282 static inline u32 get_rx_desc_paggr(__le32 *__pdesc)
284 return le32_get_bits(*(__pdesc + 1), BIT(15));
287 static inline u32 get_rx_status_desc_rpt_sel(__le32 *__pdesc)
289 return le32_get_bits(*(__pdesc + 2), BIT(28));
292 static inline u32 get_rx_desc_rxmcs(__le32 *__pdesc)
294 return le32_get_bits(*(__pdesc + 3), GENMASK(6, 0));
297 static inline u32 get_rx_desc_rxht(__le32 *__pdesc)
299 return le32_get_bits(*(__pdesc + 3), BIT(6));
302 static inline u32 get_rx_status_desc_pattern_match(__le32 *__pdesc)
304 return le32_get_bits(*(__pdesc + 3), BIT(29));
307 static inline u32 get_rx_status_desc_unicast_match(__le32 *__pdesc)
309 return le32_get_bits(*(__pdesc + 3), BIT(30));
312 static inline u32 get_rx_status_desc_magic_match(__le32 *__pdesc)
314 return le32_get_bits(*(__pdesc + 3), BIT(31));
317 static inline u32 get_rx_desc_splcp(__le32 *__pdesc)
319 return le32_get_bits(*(__pdesc + 4), BIT(0));
322 static inline u32 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 *__rxstatusdesc)
346 return le32_to_cpu(*((__rxstatusdesc + 4)));
349 static inline u32 get_rx_rpt2_desc_macid_valid_2(__le32 *__rxstatusdesc)
351 return le32_to_cpu(*((__rxstatusdesc + 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 + 1), __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, u32 _size)
391 if (_size > TX_DESC_NEXT_DESC_OFFSET)
392 memset(__pdesc, 0, TX_DESC_NEXT_DESC_OFFSET);
393 else
394 memset(__pdesc, 0, _size);
397 struct phy_rx_agc_info_t {
398 #ifdef __LITTLE_ENDIAN
399 u8 gain:7, trsw:1;
400 #else
401 u8 trsw:1, gain:7;
402 #endif
404 struct phy_status_rpt {
405 struct phy_rx_agc_info_t path_agc[2];
406 u8 ch_corr[2];
407 u8 cck_sig_qual_ofdm_pwdb_all;
408 u8 cck_agc_rpt_ofdm_cfosho_a;
409 u8 cck_rpt_b_ofdm_cfosho_b;
410 u8 rsvd_1;/* ch_corr_msb; */
411 u8 noise_power_db_msb;
412 s8 path_cfotail[2];
413 u8 pcts_mask[2];
414 s8 stream_rxevm[2];
415 u8 path_rxsnr[2];
416 u8 noise_power_db_lsb;
417 u8 rsvd_2[3];
418 u8 stream_csi[2];
419 u8 stream_target_csi[2];
420 u8 sig_evm;
421 u8 rsvd_3;
422 #ifdef __LITTLE_ENDIAN
423 u8 antsel_rx_keep_2:1; /*ex_intf_flg:1;*/
424 u8 sgi_en:1;
425 u8 rxsc:2;
426 u8 idle_long:1;
427 u8 r_ant_train_en:1;
428 u8 ant_sel_b:1;
429 u8 ant_sel:1;
430 #else /* _BIG_ENDIAN_ */
431 u8 ant_sel:1;
432 u8 ant_sel_b:1;
433 u8 r_ant_train_en:1;
434 u8 idle_long:1;
435 u8 rxsc:2;
436 u8 sgi_en:1;
437 u8 antsel_rx_keep_2:1; /*ex_intf_flg:1;*/
438 #endif
439 } __packed;
441 struct rx_fwinfo_8723be {
442 u8 gain_trsw[2];
443 u16 chl_num:10;
444 u16 sub_chnl:4;
445 u16 r_rfmod:2;
446 u8 pwdb_all;
447 u8 cfosho[4];
448 u8 cfotail[4];
449 s8 rxevm[2];
450 s8 rxsnr[2];
451 u8 pcts_msk_rpt[2];
452 u8 pdsnr[2];
453 u8 csi_current[2];
454 u8 rx_gain_c;
455 u8 rx_gain_d;
456 u8 sigevm;
457 u8 resvd_0;
458 u8 antidx_anta:3;
459 u8 antidx_antb:3;
460 u8 resvd_1:2;
461 } __packed;
463 struct tx_desc_8723be {
464 u32 pktsize:16;
465 u32 offset:8;
466 u32 bmc:1;
467 u32 htc:1;
468 u32 lastseg:1;
469 u32 firstseg:1;
470 u32 linip:1;
471 u32 noacm:1;
472 u32 gf:1;
473 u32 own:1;
475 u32 macid:6;
476 u32 rsvd0:2;
477 u32 queuesel:5;
478 u32 rd_nav_ext:1;
479 u32 lsig_txop_en:1;
480 u32 pifs:1;
481 u32 rateid:4;
482 u32 nav_usehdr:1;
483 u32 en_descid:1;
484 u32 sectype:2;
485 u32 pktoffset:8;
487 u32 rts_rc:6;
488 u32 data_rc:6;
489 u32 agg_en:1;
490 u32 rdg_en:1;
491 u32 bar_retryht:2;
492 u32 agg_break:1;
493 u32 morefrag:1;
494 u32 raw:1;
495 u32 ccx:1;
496 u32 ampdudensity:3;
497 u32 bt_int:1;
498 u32 ant_sela:1;
499 u32 ant_selb:1;
500 u32 txant_cck:2;
501 u32 txant_l:2;
502 u32 txant_ht:2;
504 u32 nextheadpage:8;
505 u32 tailpage:8;
506 u32 seq:12;
507 u32 cpu_handle:1;
508 u32 tag1:1;
509 u32 trigger_int:1;
510 u32 hwseq_en:1;
512 u32 rtsrate:5;
513 u32 apdcfe:1;
514 u32 qos:1;
515 u32 hwseq_ssn:1;
516 u32 userrate:1;
517 u32 dis_rtsfb:1;
518 u32 dis_datafb:1;
519 u32 cts2self:1;
520 u32 rts_en:1;
521 u32 hwrts_en:1;
522 u32 portid:1;
523 u32 pwr_status:3;
524 u32 waitdcts:1;
525 u32 cts2ap_en:1;
526 u32 txsc:2;
527 u32 stbc:2;
528 u32 txshort:1;
529 u32 txbw:1;
530 u32 rtsshort:1;
531 u32 rtsbw:1;
532 u32 rtssc:2;
533 u32 rtsstbc:2;
535 u32 txrate:6;
536 u32 shortgi:1;
537 u32 ccxt:1;
538 u32 txrate_fb_lmt:5;
539 u32 rtsrate_fb_lmt:4;
540 u32 retrylmt_en:1;
541 u32 txretrylmt:6;
542 u32 usb_txaggnum:8;
544 u32 txagca:5;
545 u32 txagcb:5;
546 u32 usemaxlen:1;
547 u32 maxaggnum:5;
548 u32 mcsg1maxlen:4;
549 u32 mcsg2maxlen:4;
550 u32 mcsg3maxlen:4;
551 u32 mcs7sgimaxlen:4;
553 u32 txbuffersize:16;
554 u32 sw_offset30:8;
555 u32 sw_offset31:4;
556 u32 rsvd1:1;
557 u32 antsel_c:1;
558 u32 null_0:1;
559 u32 null_1:1;
561 u32 txbuffaddr;
562 u32 txbufferaddr64;
563 u32 nextdescaddress;
564 u32 nextdescaddress64;
566 u32 reserve_pass_pcie_mm_limit[4];
567 } __packed;
569 struct rx_desc_8723be {
570 u32 length:14;
571 u32 crc32:1;
572 u32 icverror:1;
573 u32 drv_infosize:4;
574 u32 security:3;
575 u32 qos:1;
576 u32 shift:2;
577 u32 phystatus:1;
578 u32 swdec:1;
579 u32 lastseg:1;
580 u32 firstseg:1;
581 u32 eor:1;
582 u32 own:1;
584 u32 macid:6;
585 u32 tid:4;
586 u32 hwrsvd:5;
587 u32 paggr:1;
588 u32 faggr:1;
589 u32 a1_fit:4;
590 u32 a2_fit:4;
591 u32 pam:1;
592 u32 pwr:1;
593 u32 moredata:1;
594 u32 morefrag:1;
595 u32 type:2;
596 u32 mc:1;
597 u32 bc:1;
599 u32 seq:12;
600 u32 frag:4;
601 u32 nextpktlen:14;
602 u32 nextind:1;
603 u32 rsvd:1;
605 u32 rxmcs:6;
606 u32 rxht:1;
607 u32 amsdu:1;
608 u32 splcp:1;
609 u32 bandwidth:1;
610 u32 htc:1;
611 u32 tcpchk_rpt:1;
612 u32 ipcchk_rpt:1;
613 u32 tcpchk_valid:1;
614 u32 hwpcerr:1;
615 u32 hwpcind:1;
616 u32 iv0:16;
618 u32 iv1;
620 u32 tsfl;
622 u32 bufferaddress;
623 u32 bufferaddress64;
625 } __packed;
627 void rtl8723be_tx_fill_desc(struct ieee80211_hw *hw,
628 struct ieee80211_hdr *hdr,
629 u8 *pdesc_tx, u8 *txbd,
630 struct ieee80211_tx_info *info,
631 struct ieee80211_sta *sta, struct sk_buff *skb,
632 u8 hw_queue, struct rtl_tcb_desc *ptcb_desc);
633 bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw,
634 struct rtl_stats *status,
635 struct ieee80211_rx_status *rx_status,
636 u8 *pdesc, struct sk_buff *skb);
637 void rtl8723be_set_desc(struct ieee80211_hw *hw, u8 *pdesc,
638 bool istx, u8 desc_name, u8 *val);
639 u64 rtl8723be_get_desc(struct ieee80211_hw *hw,
640 u8 *pdesc, bool istx, u8 desc_name);
641 bool rtl8723be_is_tx_desc_closed(struct ieee80211_hw *hw,
642 u8 hw_queue, u16 index);
643 void rtl8723be_tx_polling(struct ieee80211_hw *hw, u8 hw_queue);
644 void rtl8723be_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
645 bool firstseg, bool lastseg,
646 struct sk_buff *skb);
647 #endif