1 /* SPDX-License-Identifier: ISC */
2 /*
3  * Copyright (C) 2022 MediaTek Inc.
4  */
5 
6 #ifndef __MT7996_MCU_H
7 #define __MT7996_MCU_H
8 
9 #include "../mt76_connac_mcu.h"
10 
11 struct mt7996_mcu_rxd {
12 	__le32 rxd[8];
13 
14 	__le16 len;
15 	__le16 pkt_type_id;
16 
17 	u8 eid;
18 	u8 seq;
19 	u8 option;
20 	u8 __rsv;
21 
22 	u8 ext_eid;
23 	u8 __rsv1[2];
24 	u8 s2d_index;
25 };
26 
27 struct mt7996_mcu_uni_event {
28 	u8 cid;
29 	u8 __rsv[3];
30 	__le32 status; /* 0: success, others: fail */
31 } __packed;
32 
33 struct mt7996_mcu_thermal_ctrl {
34 	u8 ctrl_id;
35 	u8 band_idx;
36 	union {
37 		struct {
38 			u8 protect_type; /* 1: duty admit, 2: radio off */
39 			u8 trigger_type; /* 0: low, 1: high */
40 		} __packed type;
41 		struct {
42 			u8 duty_level;	/* level 0~3 */
43 			u8 duty_cycle;
44 		} __packed duty;
45 	};
46 } __packed;
47 
48 struct mt7996_mcu_thermal_enable {
49 	__le32 trigger_temp;
50 	__le32 restore_temp;
51 	__le16 sustain_time;
52 	u8 rsv[2];
53 } __packed;
54 
55 struct mt7996_mcu_csa_notify {
56 	struct mt7996_mcu_rxd rxd;
57 
58 	u8 omac_idx;
59 	u8 csa_count;
60 	u8 band_idx;
61 	u8 rsv;
62 } __packed;
63 
64 struct mt7996_mcu_rdd_report {
65 	struct mt7996_mcu_rxd rxd;
66 
67 	u8 __rsv1[4];
68 
69 	__le16 tag;
70 	__le16 len;
71 
72 	u8 band_idx;
73 	u8 long_detected;
74 	u8 constant_prf_detected;
75 	u8 staggered_prf_detected;
76 	u8 radar_type_idx;
77 	u8 periodic_pulse_num;
78 	u8 long_pulse_num;
79 	u8 hw_pulse_num;
80 
81 	u8 out_lpn;
82 	u8 out_spn;
83 	u8 out_crpn;
84 	u8 out_crpw;
85 	u8 out_crbn;
86 	u8 out_stgpn;
87 	u8 out_stgpw;
88 
89 	u8 __rsv2;
90 
91 	__le32 out_pri_const;
92 	__le32 out_pri_stg[3];
93 	__le32 out_pri_stg_dmin;
94 
95 	struct {
96 		__le32 start;
97 		__le16 pulse_width;
98 		__le16 pulse_power;
99 		u8 mdrdy_flag;
100 		u8 rsv[3];
101 	} long_pulse[32];
102 
103 	struct {
104 		__le32 start;
105 		__le16 pulse_width;
106 		__le16 pulse_power;
107 		u8 mdrdy_flag;
108 		u8 rsv[3];
109 	} periodic_pulse[32];
110 
111 	struct {
112 		__le32 start;
113 		__le16 pulse_width;
114 		__le16 pulse_power;
115 		u8 sc_pass;
116 		u8 sw_reset;
117 		u8 mdrdy_flag;
118 		u8 tx_active;
119 	} hw_pulse[32];
120 } __packed;
121 
122 struct mt7996_mcu_background_chain_ctrl {
123 	u8 _rsv[4];
124 
125 	__le16 tag;
126 	__le16 len;
127 
128 	u8 chan;		/* primary channel */
129 	u8 central_chan;	/* central channel */
130 	u8 bw;
131 	u8 tx_stream;
132 	u8 rx_stream;
133 
134 	u8 monitor_chan;	/* monitor channel */
135 	u8 monitor_central_chan;/* monitor central channel */
136 	u8 monitor_bw;
137 	u8 monitor_tx_stream;
138 	u8 monitor_rx_stream;
139 
140 	u8 scan_mode;		/* 0: ScanStop
141 				 * 1: ScanStart
142 				 * 2: ScanRunning
143 				 */
144 	u8 band_idx;		/* DBDC */
145 	u8 monitor_scan_type;
146 	u8 band;		/* 0: 2.4GHz, 1: 5GHz */
147 	u8 rsv[2];
148 } __packed;
149 
150 struct mt7996_mcu_eeprom {
151 	u8 _rsv[4];
152 
153 	__le16 tag;
154 	__le16 len;
155 	u8 buffer_mode;
156 	u8 format;
157 	__le16 buf_len;
158 } __packed;
159 
160 struct mt7996_mcu_phy_rx_info {
161 	u8 category;
162 	u8 rate;
163 	u8 mode;
164 	u8 nsts;
165 	u8 gi;
166 	u8 coding;
167 	u8 stbc;
168 	u8 bw;
169 };
170 
171 struct mt7996_mcu_mib {
172 	__le16 tag;
173 	__le16 len;
174 	__le32 offs;
175 	__le64 data;
176 } __packed;
177 
178 struct all_sta_trx_rate {
179 	__le16 wlan_idx;
180 	u8 __rsv1[2];
181 	u8 tx_mode;
182 	u8 flags;
183 	u8 tx_stbc;
184 	u8 tx_gi;
185 	u8 tx_bw;
186 	u8 tx_ldpc;
187 	u8 tx_mcs;
188 	u8 tx_nss;
189 	u8 rx_rate;
190 	u8 rx_mode;
191 	u8 rx_nsts;
192 	u8 rx_gi;
193 	u8 rx_coding;
194 	u8 rx_stbc;
195 	u8 rx_bw;
196 	u8 __rsv2;
197 } __packed;
198 
199 struct mt7996_mcu_all_sta_info_event {
200 	u8 rsv[4];
201 	__le16 tag;
202 	__le16 len;
203 	u8 more;
204 	u8 rsv2;
205 	__le16 sta_num;
206 	u8 rsv3[4];
207 
208 	union {
209 		DECLARE_FLEX_ARRAY(struct all_sta_trx_rate, rate);
210 		DECLARE_FLEX_ARRAY(struct {
211 			__le16 wlan_idx;
212 			u8 rsv[2];
213 			__le32 tx_bytes[IEEE80211_NUM_ACS];
214 			__le32 rx_bytes[IEEE80211_NUM_ACS];
215 		} __packed, adm_stat);
216 
217 		DECLARE_FLEX_ARRAY(struct {
218 			__le16 wlan_idx;
219 			u8 rsv[2];
220 			__le32 tx_msdu_cnt;
221 			__le32 rx_msdu_cnt;
222 		} __packed, msdu_cnt);
223 	} __packed;
224 } __packed;
225 
226 struct mt7996_mcu_wed_rro_event {
227 	struct mt7996_mcu_rxd rxd;
228 
229 	u8 __rsv1[4];
230 
231 	__le16 tag;
232 	__le16 len;
233 } __packed;
234 
235 struct mt7996_mcu_wed_rro_ba_event {
236 	__le16 tag;
237 	__le16 len;
238 
239 	__le16 wlan_id;
240 	u8 tid;
241 	u8 __rsv1;
242 	__le32 status;
243 	__le16 id;
244 	u8 __rsv2[2];
245 } __packed;
246 
247 struct mt7996_mcu_wed_rro_ba_delete_event {
248 	__le16 tag;
249 	__le16 len;
250 
251 	__le16 session_id;
252 	u8 __rsv2[2];
253 } __packed;
254 
255 enum  {
256 	UNI_WED_RRO_BA_SESSION_STATUS,
257 	UNI_WED_RRO_BA_SESSION_TBL,
258 	UNI_WED_RRO_BA_SESSION_DELETE,
259 };
260 
261 struct mt7996_mcu_thermal_notify {
262 	struct mt7996_mcu_rxd rxd;
263 
264 	u8 __rsv1[4];
265 
266 	__le16 tag;
267 	__le16 len;
268 
269 	u8 event_id;
270 	u8 band_idx;
271 	u8 level_idx;
272 	u8 duty_percent;
273 	__le32 restore_temp;
274 	u8 __rsv2[4];
275 } __packed;
276 
277 enum mt7996_chan_mib_offs {
278 	UNI_MIB_OBSS_AIRTIME = 26,
279 	UNI_MIB_NON_WIFI_TIME = 27,
280 	UNI_MIB_TX_TIME = 28,
281 	UNI_MIB_RX_TIME = 29
282 };
283 
284 struct edca {
285 	__le16 tag;
286 	__le16 len;
287 
288 	u8 queue;
289 	u8 set;
290 	u8 cw_min;
291 	u8 cw_max;
292 	__le16 txop;
293 	u8 aifs;
294 	u8 __rsv;
295 };
296 
297 #define MCU_PQ_ID(p, q)			(((p) << 15) | ((q) << 10))
298 #define MCU_PKT_ID			0xa0
299 
300 enum {
301 	MCU_FW_LOG_WM,
302 	MCU_FW_LOG_WA,
303 	MCU_FW_LOG_TO_HOST,
304 	MCU_FW_LOG_RELAY = 16
305 };
306 
307 enum {
308 	MCU_TWT_AGRT_ADD,
309 	MCU_TWT_AGRT_MODIFY,
310 	MCU_TWT_AGRT_DELETE,
311 	MCU_TWT_AGRT_TEARDOWN,
312 	MCU_TWT_AGRT_GET_TSF,
313 };
314 
315 enum {
316 	MCU_WA_PARAM_CMD_QUERY,
317 	MCU_WA_PARAM_CMD_SET,
318 	MCU_WA_PARAM_CMD_CAPABILITY,
319 	MCU_WA_PARAM_CMD_DEBUG,
320 };
321 
322 enum {
323 	MCU_WA_PARAM_PDMA_RX = 0x04,
324 	MCU_WA_PARAM_CPU_UTIL = 0x0b,
325 	MCU_WA_PARAM_RED = 0x0e,
326 	MCU_WA_PARAM_HW_PATH_HIF_VER = 0x2f,
327 };
328 
329 enum mcu_mmps_mode {
330 	MCU_MMPS_STATIC,
331 	MCU_MMPS_DYNAMIC,
332 	MCU_MMPS_RSV,
333 	MCU_MMPS_DISABLE,
334 };
335 
336 struct bss_rate_tlv {
337 	__le16 tag;
338 	__le16 len;
339 	u8 __rsv1[4];
340 	__le16 bc_trans;
341 	__le16 mc_trans;
342 	u8 short_preamble;
343 	u8 bc_fixed_rate;
344 	u8 mc_fixed_rate;
345 	u8 __rsv2[9];
346 } __packed;
347 
348 enum {
349 	BP_DISABLE,
350 	BP_SW_MODE,
351 	BP_HW_MODE,
352 };
353 
354 struct mt7996_mcu_bcn_prot_tlv {
355 	__le16 tag;
356 	__le16 len;
357 	u8 pn[6];
358 	u8 enable;
359 	u8 cipher_id;
360 	u8 key[WLAN_MAX_KEY_LEN];
361 	u8 key_id;
362 	u8 __rsv[3];
363 } __packed;
364 
365 struct bss_ra_tlv {
366 	__le16 tag;
367 	__le16 len;
368 	u8 short_preamble;
369 	u8 force_sgi;
370 	u8 force_gf;
371 	u8 ht_mode;
372 	u8 se_off;
373 	u8 antenna_idx;
374 	__le16 max_phyrate;
375 	u8 force_tx_streams;
376 	u8 __rsv[3];
377 } __packed;
378 
379 struct bss_rlm_tlv {
380 	__le16 tag;
381 	__le16 len;
382 	u8 control_channel;
383 	u8 center_chan;
384 	u8 center_chan2;
385 	u8 bw;
386 	u8 tx_streams;
387 	u8 rx_streams;
388 	u8 ht_op_info;
389 	u8 sco;
390 	u8 band;
391 	u8 __rsv[3];
392 } __packed;
393 
394 struct bss_color_tlv {
395 	__le16 tag;
396 	__le16 len;
397 	u8 enable;
398 	u8 color;
399 	u8 rsv[2];
400 } __packed;
401 
402 struct bss_inband_discovery_tlv {
403 	__le16 tag;
404 	__le16 len;
405 	u8 tx_type;
406 	u8 tx_mode;
407 	u8 tx_interval;
408 	u8 enable;
409 	__le16 wcid;
410 	__le16 prob_rsp_len;
411 } __packed;
412 
413 struct bss_bcn_content_tlv {
414 	__le16 tag;
415 	__le16 len;
416 	__le16 tim_ie_pos;
417 	__le16 csa_ie_pos;
418 	__le16 bcc_ie_pos;
419 	u8 enable;
420 	u8 type;
421 	__le16 pkt_len;
422 } __packed;
423 
424 struct bss_bcn_cntdwn_tlv {
425 	__le16 tag;
426 	__le16 len;
427 	u8 cnt;
428 	u8 rsv[3];
429 } __packed;
430 
431 struct bss_bcn_mbss_tlv {
432 	__le16 tag;
433 	__le16 len;
434 	__le32 bitmap;
435 #define MAX_BEACON_NUM	32
436 	__le16 offset[MAX_BEACON_NUM];
437 } __packed __aligned(4);
438 
439 struct bss_txcmd_tlv {
440 	__le16 tag;
441 	__le16 len;
442 	u8 txcmd_mode;
443 	u8 __rsv[3];
444 } __packed;
445 
446 struct bss_sec_tlv {
447 	__le16 tag;
448 	__le16 len;
449 	u8 __rsv1[2];
450 	u8 cipher;
451 	u8 __rsv2[1];
452 } __packed;
453 
454 struct bss_ifs_time_tlv {
455 	__le16 tag;
456 	__le16 len;
457 	u8 slot_valid;
458 	u8 sifs_valid;
459 	u8 rifs_valid;
460 	u8 eifs_valid;
461 	__le16 slot_time;
462 	__le16 sifs_time;
463 	__le16 rifs_time;
464 	__le16 eifs_time;
465 	u8 eifs_cck_valid;
466 	u8 rsv;
467 	__le16 eifs_cck_time;
468 } __packed;
469 
470 struct bss_power_save {
471 	__le16 tag;
472 	__le16 len;
473 	u8 profile;
474 	u8 _rsv[3];
475 } __packed;
476 
477 struct bss_mld_tlv {
478 	__le16 tag;
479 	__le16 len;
480 	u8 group_mld_id;
481 	u8 own_mld_id;
482 	u8 mac_addr[ETH_ALEN];
483 	u8 remap_idx;
484 	u8 __rsv[3];
485 } __packed;
486 
487 struct sta_rec_ht_uni {
488 	__le16 tag;
489 	__le16 len;
490 	__le16 ht_cap;
491 	__le16 ht_cap_ext;
492 	u8 ampdu_param;
493 	u8 _rsv[3];
494 } __packed;
495 
496 struct sta_rec_ba_uni {
497 	__le16 tag;
498 	__le16 len;
499 	u8 tid;
500 	u8 ba_type;
501 	u8 amsdu;
502 	u8 ba_en;
503 	__le16 ssn;
504 	__le16 winsize;
505 	u8 ba_rdd_rro;
506 	u8 __rsv[3];
507 } __packed;
508 
509 struct sta_rec_eht {
510 	__le16 tag;
511 	__le16 len;
512 	u8 tid_bitmap;
513 	u8 _rsv;
514 	__le16 mac_cap;
515 	__le64 phy_cap;
516 	__le64 phy_cap_ext;
517 	u8 mcs_map_bw20[4];
518 	u8 mcs_map_bw80[3];
519 	u8 mcs_map_bw160[3];
520 	u8 mcs_map_bw320[3];
521 	u8 _rsv2[3];
522 } __packed;
523 
524 struct sec_key_uni {
525 	__le16 wlan_idx;
526 	u8 mgmt_prot;
527 	u8 cipher_id;
528 	u8 cipher_len;
529 	u8 key_id;
530 	u8 key_len;
531 	u8 need_resp;
532 	u8 key[32];
533 } __packed;
534 
535 struct sta_rec_sec_uni {
536 	__le16 tag;
537 	__le16 len;
538 	u8 add;
539 	u8 n_cipher;
540 	u8 rsv[2];
541 
542 	struct sec_key_uni key[2];
543 } __packed;
544 
545 struct sta_phy_uni {
546 	u8 type;
547 	u8 flag;
548 	u8 stbc;
549 	u8 sgi;
550 	u8 bw;
551 	u8 ldpc;
552 	u8 mcs;
553 	u8 nss;
554 	u8 he_ltf;
555 	u8 rsv[3];
556 };
557 
558 struct sta_rec_ra_uni {
559 	__le16 tag;
560 	__le16 len;
561 
562 	u8 valid;
563 	u8 auto_rate;
564 	u8 phy_mode;
565 	u8 channel;
566 	u8 bw;
567 	u8 disable_cck;
568 	u8 ht_mcs32;
569 	u8 ht_gf;
570 	u8 ht_mcs[4];
571 	u8 mmps_mode;
572 	u8 gband_256;
573 	u8 af;
574 	u8 auth_wapi_mode;
575 	u8 rate_len;
576 
577 	u8 supp_mode;
578 	u8 supp_cck_rate;
579 	u8 supp_ofdm_rate;
580 	__le32 supp_ht_mcs;
581 	__le16 supp_vht_mcs[4];
582 
583 	u8 op_mode;
584 	u8 op_vht_chan_width;
585 	u8 op_vht_rx_nss;
586 	u8 op_vht_rx_nss_type;
587 
588 	__le32 sta_cap;
589 
590 	struct sta_phy_uni phy;
591 	u8 rx_rcpi[4];
592 } __packed;
593 
594 struct sta_rec_ra_fixed_uni {
595 	__le16 tag;
596 	__le16 len;
597 
598 	__le32 field;
599 	u8 op_mode;
600 	u8 op_vht_chan_width;
601 	u8 op_vht_rx_nss;
602 	u8 op_vht_rx_nss_type;
603 
604 	struct sta_phy_uni phy;
605 
606 	u8 spe_idx;
607 	u8 short_preamble;
608 	u8 is_5g;
609 	u8 mmps_mode;
610 } __packed;
611 
612 struct sta_rec_hdrt {
613 	__le16 tag;
614 	__le16 len;
615 	u8 hdrt_mode;
616 	u8 rsv[3];
617 } __packed;
618 
619 struct sta_rec_hdr_trans {
620 	__le16 tag;
621 	__le16 len;
622 	u8 from_ds;
623 	u8 to_ds;
624 	u8 dis_rx_hdr_tran;
625 	u8 mesh;
626 } __packed;
627 
628 struct hdr_trans_en {
629 	__le16 tag;
630 	__le16 len;
631 	u8 enable;
632 	u8 check_bssid;
633 	u8 mode;
634 	u8 __rsv;
635 } __packed;
636 
637 struct hdr_trans_vlan {
638 	__le16 tag;
639 	__le16 len;
640 	u8 insert_vlan;
641 	u8 remove_vlan;
642 	u8 tid;
643 	u8 __rsv;
644 } __packed;
645 
646 struct hdr_trans_blacklist {
647 	__le16 tag;
648 	__le16 len;
649 	u8 idx;
650 	u8 enable;
651 	__le16 type;
652 } __packed;
653 
654 struct uni_header {
655 	u8 __rsv[4];
656 } __packed;
657 
658 struct vow_rx_airtime {
659 	__le16 tag;
660 	__le16 len;
661 
662 	u8 enable;
663 	u8 band;
664 	u8 __rsv[2];
665 } __packed;
666 
667 struct bf_sounding_on {
668 	__le16 tag;
669 	__le16 len;
670 
671 	u8 snd_mode;
672 	u8 sta_num;
673 	u8 __rsv[2];
674 	__le16 wlan_id[4];
675 	__le32 snd_period;
676 } __packed;
677 
678 struct bf_hw_en_status_update {
679 	__le16 tag;
680 	__le16 len;
681 
682 	bool ebf;
683 	bool ibf;
684 	u8 __rsv[2];
685 } __packed;
686 
687 struct bf_mod_en_ctrl {
688 	__le16 tag;
689 	__le16 len;
690 
691 	u8 bf_num;
692 	u8 bf_bitmap;
693 	u8 bf_sel[8];
694 	u8 __rsv[2];
695 } __packed;
696 
697 union bf_tag_tlv {
698 	struct bf_sounding_on bf_snd;
699 	struct bf_hw_en_status_update bf_hw_en;
700 	struct bf_mod_en_ctrl bf_mod_en;
701 };
702 
703 struct ra_rate {
704 	__le16 wlan_idx;
705 	u8 mode;
706 	u8 stbc;
707 	__le16 gi;
708 	u8 bw;
709 	u8 ldpc;
710 	u8 mcs;
711 	u8 nss;
712 	__le16 ltf;
713 	u8 spe;
714 	u8 preamble;
715 	u8 __rsv[2];
716 } __packed;
717 
718 struct ra_fixed_rate {
719 	__le16 tag;
720 	__le16 len;
721 
722 	__le16 version;
723 	struct ra_rate rate;
724 } __packed;
725 
726 enum {
727 	UNI_RA_FIXED_RATE = 0xf,
728 };
729 
730 #define MT7996_HDR_TRANS_MAX_SIZE	(sizeof(struct hdr_trans_en) +	 \
731 					 sizeof(struct hdr_trans_vlan) + \
732 					 sizeof(struct hdr_trans_blacklist))
733 
734 enum {
735 	UNI_HDR_TRANS_EN,
736 	UNI_HDR_TRANS_VLAN,
737 	UNI_HDR_TRANS_BLACKLIST,
738 };
739 
740 enum {
741 	RATE_PARAM_FIXED = 3,
742 	RATE_PARAM_MMPS_UPDATE = 5,
743 	RATE_PARAM_FIXED_HE_LTF = 7,
744 	RATE_PARAM_FIXED_MCS,
745 	RATE_PARAM_FIXED_GI = 11,
746 	RATE_PARAM_AUTO = 20,
747 };
748 
749 enum {
750 	BF_SOUNDING_ON = 1,
751 	BF_HW_EN_UPDATE = 17,
752 	BF_MOD_EN_CTRL = 20,
753 };
754 
755 enum {
756 	CMD_BAND_NONE,
757 	CMD_BAND_24G,
758 	CMD_BAND_5G,
759 	CMD_BAND_6G,
760 };
761 
762 struct bss_req_hdr {
763 	u8 bss_idx;
764 	u8 __rsv[3];
765 } __packed;
766 
767 enum {
768 	UNI_CHANNEL_SWITCH,
769 	UNI_CHANNEL_RX_PATH,
770 };
771 
772 #define MT7996_BSS_UPDATE_MAX_SIZE	(sizeof(struct bss_req_hdr) +		\
773 					 sizeof(struct mt76_connac_bss_basic_tlv) +	\
774 					 sizeof(struct bss_rlm_tlv) +		\
775 					 sizeof(struct bss_ra_tlv) +		\
776 					 sizeof(struct bss_info_uni_he) +	\
777 					 sizeof(struct bss_rate_tlv) +		\
778 					 sizeof(struct bss_txcmd_tlv) +		\
779 					 sizeof(struct bss_power_save) +	\
780 					 sizeof(struct bss_sec_tlv) +		\
781 					 sizeof(struct bss_ifs_time_tlv) +	\
782 					 sizeof(struct bss_mld_tlv))
783 
784 #define MT7996_STA_UPDATE_MAX_SIZE	(sizeof(struct sta_req_hdr) +		\
785 					 sizeof(struct sta_rec_basic) +		\
786 					 sizeof(struct sta_rec_bf) +		\
787 					 sizeof(struct sta_rec_ht_uni) +	\
788 					 sizeof(struct sta_rec_he_v2) +		\
789 					 sizeof(struct sta_rec_ba_uni) +	\
790 					 sizeof(struct sta_rec_vht) +		\
791 					 sizeof(struct sta_rec_uapsd) + 	\
792 					 sizeof(struct sta_rec_amsdu) +		\
793 					 sizeof(struct sta_rec_bfee) +		\
794 					 sizeof(struct sta_rec_ra_uni) +	\
795 					 sizeof(struct sta_rec_sec) +		\
796 					 sizeof(struct sta_rec_ra_fixed_uni) +	\
797 					 sizeof(struct sta_rec_he_6g_capa) +	\
798 					 sizeof(struct sta_rec_eht) +		\
799 					 sizeof(struct sta_rec_hdrt) +		\
800 					 sizeof(struct sta_rec_hdr_trans) +	\
801 					 sizeof(struct tlv))
802 
803 #define MT7996_MAX_BEACON_SIZE		1338
804 #define MT7996_BEACON_UPDATE_SIZE	(sizeof(struct bss_req_hdr) +		\
805 					 sizeof(struct bss_bcn_content_tlv) +	\
806 					 4 + MT_TXD_SIZE +			\
807 					 sizeof(struct bss_bcn_cntdwn_tlv) +	\
808 					 sizeof(struct bss_bcn_mbss_tlv))
809 #define MT7996_MAX_BSS_OFFLOAD_SIZE	(MT7996_MAX_BEACON_SIZE +		\
810 					 MT7996_BEACON_UPDATE_SIZE)
811 
812 static inline s8
mt7996_get_power_bound(struct mt7996_phy * phy,s8 txpower)813 mt7996_get_power_bound(struct mt7996_phy *phy, s8 txpower)
814 {
815 	struct mt76_phy *mphy = phy->mt76;
816 	int n_chains = hweight16(mphy->chainmask);
817 
818 	txpower = mt76_get_sar_power(mphy, mphy->chandef.chan, txpower * 2);
819 	txpower -= mt76_tx_power_nss_delta(n_chains);
820 
821 	return txpower;
822 }
823 
824 enum {
825 	UNI_BAND_CONFIG_RADIO_ENABLE,
826 	UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,
827 };
828 
829 enum {
830 	UNI_WSYS_CONFIG_FW_LOG_CTRL,
831 	UNI_WSYS_CONFIG_FW_DBG_CTRL,
832 };
833 
834 enum {
835 	UNI_RDD_CTRL_PARM,
836 	UNI_RDD_CTRL_SET_TH = 0x3,
837 };
838 
839 enum {
840 	UNI_EFUSE_ACCESS = 1,
841 	UNI_EFUSE_BUFFER_MODE,
842 	UNI_EFUSE_FREE_BLOCK,
843 	UNI_EFUSE_BUFFER_RD,
844 };
845 
846 enum {
847 	UNI_VOW_DRR_CTRL,
848 	UNI_VOW_RX_AT_AIRTIME_EN = 0x0b,
849 	UNI_VOW_RX_AT_AIRTIME_CLR_EN = 0x0e,
850 };
851 
852 enum {
853 	UNI_CMD_MIB_DATA,
854 };
855 
856 enum {
857 	UNI_POWER_OFF,
858 };
859 
860 enum {
861 	UNI_CMD_TWT_ARGT_UPDATE = 0x0,
862 	UNI_CMD_TWT_MGMT_OFFLOAD,
863 };
864 
865 enum {
866 	UNI_RRO_DEL_ENTRY = 0x1,
867 	UNI_RRO_SET_PLATFORM_TYPE,
868 	UNI_RRO_GET_BA_SESSION_TABLE,
869 	UNI_RRO_SET_BYPASS_MODE,
870 	UNI_RRO_SET_TXFREE_PATH,
871 	UNI_RRO_DEL_BA_SESSION,
872 	UNI_RRO_SET_FLUSH_TIMEOUT
873 };
874 
875 enum{
876 	UNI_CMD_SR_ENABLE = 0x1,
877 	UNI_CMD_SR_ENABLE_SD,
878 	UNI_CMD_SR_ENABLE_MODE,
879 	UNI_CMD_SR_ENABLE_DPD = 0x12,
880 	UNI_CMD_SR_ENABLE_TX,
881 	UNI_CMD_SR_SET_SRG_BITMAP = 0x80,
882 	UNI_CMD_SR_SET_PARAM = 0xc1,
883 	UNI_CMD_SR_SET_SIGA = 0xd0,
884 };
885 
886 enum {
887 	UNI_CMD_THERMAL_PROTECT_ENABLE = 0x6,
888 	UNI_CMD_THERMAL_PROTECT_DISABLE,
889 	UNI_CMD_THERMAL_PROTECT_DUTY_CONFIG,
890 };
891 
892 enum {
893 	UNI_TXPOWER_POWER_LIMIT_TABLE_CTRL = 4,
894 };
895 
896 enum {
897 	UNI_CMD_ACCESS_REG_BASIC = 0x0,
898 	UNI_CMD_ACCESS_RF_REG_BASIC,
899 };
900 
901 enum {
902 	UNI_CMD_SER_QUERY,
903 	/* recovery */
904 	UNI_CMD_SER_SET_RECOVER_L1,
905 	UNI_CMD_SER_SET_RECOVER_L2,
906 	UNI_CMD_SER_SET_RECOVER_L3_RX_ABORT,
907 	UNI_CMD_SER_SET_RECOVER_L3_TX_ABORT,
908 	UNI_CMD_SER_SET_RECOVER_L3_TX_DISABLE,
909 	UNI_CMD_SER_SET_RECOVER_L3_BF,
910 	UNI_CMD_SER_SET_RECOVER_L4_MDP,
911 	UNI_CMD_SER_SET_RECOVER_FULL,
912 	UNI_CMD_SER_SET_SYSTEM_ASSERT,
913 	/* action */
914 	UNI_CMD_SER_ENABLE = 1,
915 	UNI_CMD_SER_SET,
916 	UNI_CMD_SER_TRIGGER
917 };
918 
919 enum {
920 	MT7996_SEC_MODE_PLAIN,
921 	MT7996_SEC_MODE_AES,
922 	MT7996_SEC_MODE_SCRAMBLE,
923 	MT7996_SEC_MODE_MAX,
924 };
925 
926 #define MT7996_PATCH_SEC		GENMASK(31, 24)
927 #define MT7996_PATCH_SCRAMBLE_KEY	GENMASK(15, 8)
928 #define MT7996_PATCH_AES_KEY		GENMASK(7, 0)
929 
930 #define MT7996_SEC_ENCRYPT		BIT(0)
931 #define MT7996_SEC_KEY_IDX		GENMASK(2, 1)
932 #define MT7996_SEC_IV			BIT(3)
933 
934 struct fixed_rate_table_ctrl {
935 	u8 _rsv[4];
936 
937 	__le16 tag;
938 	__le16 len;
939 
940 	u8 table_idx;
941 	u8 antenna_idx;
942 	__le16 rate_idx;
943 	u8 spe_idx_sel;
944 	u8 spe_idx;
945 	u8 gi;
946 	u8 he_ltf;
947 	bool ldpc;
948 	bool txbf;
949 	bool dynamic_bw;
950 
951 	u8 _rsv2;
952 } __packed;
953 
954 #endif
955