xref: /linux/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h (revision 91ec2035134982b98fab0609a9fd8480e8217dc1)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /* Copyright (C) 2023 MediaTek Inc. */
3 
4 #ifndef __MT7925_MCU_H
5 #define __MT7925_MCU_H
6 
7 #include "../mt76_connac_mcu.h"
8 
9 /* ext event table */
10 enum {
11 	MCU_EXT_EVENT_RATE_REPORT = 0x87,
12 };
13 
14 struct mt7925_mcu_eeprom_info {
15 	__le32 addr;
16 	__le32 valid;
17 	u8 data[MT7925_EEPROM_BLOCK_SIZE];
18 } __packed;
19 
20 #define MT_RA_RATE_NSS			GENMASK(8, 6)
21 #define MT_RA_RATE_MCS			GENMASK(3, 0)
22 #define MT_RA_RATE_TX_MODE		GENMASK(12, 9)
23 #define MT_RA_RATE_DCM_EN		BIT(4)
24 #define MT_RA_RATE_BW			GENMASK(14, 13)
25 
26 struct mt7925_mcu_rxd {
27 	__le32 rxd[8];
28 
29 	__le16 len;
30 	__le16 pkt_type_id;
31 
32 	u8 eid;
33 	u8 seq;
34 	u8 option;
35 	u8 __rsv;
36 
37 	u8 ext_eid;
38 	u8 __rsv1[2];
39 	u8 s2d_index;
40 
41 	u8 tlv[];
42 };
43 
44 struct mt7925_mcu_uni_event {
45 	u8 cid;
46 	u8 pad[3];
47 	__le32 status; /* 0: success, others: fail */
48 } __packed;
49 
50 enum {
51 	MT_EBF = BIT(0),	/* explicit beamforming */
52 	MT_IBF = BIT(1)		/* implicit beamforming */
53 };
54 
55 struct mt7925_mcu_reg_event {
56 	__le32 reg;
57 	__le32 val;
58 } __packed;
59 
60 struct mt7925_mcu_ant_id_config {
61 	u8 ant_id[4];
62 } __packed;
63 
64 struct mt7925_txpwr_req {
65 	u8 _rsv[4];
66 	__le16 tag;
67 	__le16 len;
68 
69 	u8 format_id;
70 	u8 catg;
71 	u8 band_idx;
72 	u8 _rsv1;
73 } __packed;
74 
75 struct mt7925_txpwr_event {
76 	u8 rsv[4];
77 	__le16 tag;
78 	__le16 len;
79 
80 	u8 catg;
81 	u8 band_idx;
82 	u8 ch_band;
83 	u8 format; /* 0:Legacy, 1:HE */
84 
85 	/* Rate power info */
86 	struct mt7925_txpwr txpwr;
87 
88 	s8 pwr_max;
89 	s8 pwr_min;
90 	u8 rsv1;
91 } __packed;
92 
93 enum {
94 	TM_SWITCH_MODE,
95 	TM_SET_AT_CMD,
96 	TM_QUERY_AT_CMD,
97 };
98 
99 enum {
100 	MT7925_TM_NORMAL,
101 	MT7925_TM_TESTMODE,
102 	MT7925_TM_ICAP,
103 	MT7925_TM_ICAP_OVERLAP,
104 	MT7925_TM_WIFISPECTRUM,
105 };
106 
107 struct mt7925_rftest_evt {
108 	__le32 param0;
109 	__le32 param1;
110 } __packed;
111 
112 enum {
113 	UNI_CHANNEL_SWITCH,
114 	UNI_CHANNEL_RX_PATH,
115 };
116 
117 enum {
118 	UNI_CHIP_CONFIG_CHIP_CFG = 0x2,
119 	UNI_CHIP_CONFIG_NIC_CAPA = 0x3,
120 };
121 
122 enum {
123 	UNI_BAND_CONFIG_RADIO_ENABLE,
124 	UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,
125 	UNI_BAND_CONFIG_SET_MAC80211_RX_FILTER = 0x0C,
126 };
127 
128 enum {
129 	UNI_WSYS_CONFIG_FW_LOG_CTRL,
130 	UNI_WSYS_CONFIG_FW_DBG_CTRL,
131 };
132 
133 enum {
134 	UNI_EFUSE_ACCESS = 1,
135 	UNI_EFUSE_BUFFER_MODE,
136 	UNI_EFUSE_FREE_BLOCK,
137 	UNI_EFUSE_BUFFER_RD,
138 };
139 
140 enum {
141 	UNI_CMD_ACCESS_REG_BASIC = 0x0,
142 	UNI_CMD_ACCESS_RF_REG_BASIC,
143 };
144 
145 enum {
146 	UNI_MBMC_SETTING = 0,
147 	UNI_MBMC_NO_RESP_SETTING = 1,
148 };
149 
150 enum {
151 	UNI_EVENT_SCAN_DONE_BASIC = 0,
152 	UNI_EVENT_SCAN_DONE_CHNLINFO = 2,
153 	UNI_EVENT_SCAN_DONE_NLO = 3,
154 };
155 
156 enum {
157 	UNI_CMD_RSSI_MONITOR_SET = 0,
158 };
159 
160 enum {
161 	UNI_EVENT_RSSI_MONITOR_INFO = 0,
162 };
163 
164 enum connac3_mcu_cipher_type {
165 	CONNAC3_CIPHER_NONE = 0,
166 	CONNAC3_CIPHER_WEP40 = 1,
167 	CONNAC3_CIPHER_TKIP = 2,
168 	CONNAC3_CIPHER_AES_CCMP = 4,
169 	CONNAC3_CIPHER_WEP104 = 5,
170 	CONNAC3_CIPHER_BIP_CMAC_128 = 6,
171 	CONNAC3_CIPHER_WEP128 = 7,
172 	CONNAC3_CIPHER_WAPI = 8,
173 	CONNAC3_CIPHER_CCMP_256 = 10,
174 	CONNAC3_CIPHER_GCMP = 11,
175 	CONNAC3_CIPHER_GCMP_256 = 12,
176 };
177 
178 enum DMASHDL_GROUP_IDX {
179 	DMASHDL_GROUP_0 = 0,
180 	DMASHDL_GROUP_1,
181 	DMASHDL_GROUP_2,
182 	DMASHDL_GROUP_3,
183 	DMASHDL_GROUP_4,
184 	DMASHDL_GROUP_5,
185 	DMASHDL_GROUP_6,
186 	DMASHDL_GROUP_7,
187 	DMASHDL_GROUP_8,
188 	DMASHDL_GROUP_9,
189 	DMASHDL_GROUP_10,
190 	DMASHDL_GROUP_11,
191 	DMASHDL_GROUP_12,
192 	DMASHDL_GROUP_13,
193 	DMASHDL_GROUP_14,
194 	DMASHDL_GROUP_15,
195 	DMASHDL_GROUP_NUM,
196 	DMASHDL_LITE_GROUP_NUM = 64
197 };
198 
199 struct mt7925_mcu_scan_chinfo_event {
200 	u8 nr_chan;
201 	u8 alpha2[3];
202 } __packed;
203 
204 enum {
205 	UNI_SCAN_REQ = 1,
206 	UNI_SCAN_CANCEL = 2,
207 	UNI_SCAN_SCHED_REQ = 3,
208 	UNI_SCAN_SCHED_ENABLE = 4,
209 	UNI_SCAN_SSID = 10,
210 	UNI_SCAN_BSSID,
211 	UNI_SCAN_CHANNEL,
212 	UNI_SCAN_IE,
213 	UNI_SCAN_MISC,
214 	UNI_SCAN_SSID_MATCH_SETS,
215 };
216 
217 enum {
218 	UNI_SNIFFER_ENABLE,
219 	UNI_SNIFFER_CONFIG,
220 };
221 
222 #define MT7925_RNR_SCAN_MAX_BSSIDS	10
223 struct scan_hdr_tlv {
224 	/* fixed field */
225 	u8 seq_num;
226 	u8 bss_idx;
227 	u8 pad[2];
228 	/* tlv */
229 	u8 data[];
230 } __packed;
231 
232 struct scan_req_tlv {
233 	__le16 tag;
234 	__le16 len;
235 
236 	u8 scan_type; /* 0: PASSIVE SCAN
237 		       * 1: ACTIVE SCAN
238 		       */
239 	u8 probe_req_num; /* Number of probe request for each SSID */
240 	u8 scan_func; /* BIT(0) Enable random MAC scan
241 		       * BIT(1) Disable DBDC scan type 1~3.
242 		       * BIT(2) Use DBDC scan type 3 (dedicated one RF to scan).
243 		       */
244 	u8 src_mask;
245 	__le16 channel_min_dwell_time;
246 	__le16 channel_dwell_time; /* channel Dwell interval */
247 	__le16 timeout_value;
248 	__le16 probe_delay_time;
249 	__le32 func_mask_ext;
250 } __packed;
251 
252 struct scan_ssid_tlv {
253 	__le16 tag;
254 	__le16 len;
255 
256 	u8 ssid_type; /* BIT(0) wildcard SSID
257 		       * BIT(1) P2P wildcard SSID
258 		       * BIT(2) specified SSID + wildcard SSID
259 		       * BIT(2) + ssid_type_ext BIT(0) specified SSID only
260 		       */
261 	u8 ssids_num;
262 	u8 is_short_ssid;
263 	u8 pad;
264 	struct mt76_connac_mcu_scan_ssid ssids[MT7925_RNR_SCAN_MAX_BSSIDS];
265 } __packed;
266 
267 struct scan_bssid_tlv {
268 	__le16 tag;
269 	__le16 len;
270 
271 	u8 bssid[ETH_ALEN];
272 	u8 match_ch;
273 	u8 match_ssid_ind;
274 	u8 rcpi;
275 	u8 match_short_ssid_ind;
276 	u8 pad[2];
277 } __packed;
278 
279 struct scan_chan_info_tlv {
280 	__le16 tag;
281 	__le16 len;
282 
283 	u8 channel_type; /* 0: Full channels
284 			  * 1: Only 2.4GHz channels
285 			  * 2: Only 5GHz channels
286 			  * 3: P2P social channel only (channel #1, #6 and #11)
287 			  * 4: Specified channels
288 			  * Others: Reserved
289 			  */
290 	u8 channels_num; /* valid when channel_type is 4 */
291 	u8 pad[2];
292 	struct mt76_connac_mcu_scan_channel channels[64];
293 } __packed;
294 
295 struct scan_ie_tlv {
296 	__le16 tag;
297 	__le16 len;
298 
299 	__le16 ies_len;
300 	u8 band;
301 	u8 pad;
302 	u8 ies[];
303 };
304 
305 struct scan_misc_tlv {
306 	__le16 tag;
307 	__le16 len;
308 
309 	u8 random_mac[ETH_ALEN];
310 	u8 rsv[2];
311 };
312 
313 struct scan_sched_req {
314 	__le16 tag;
315 	__le16 len;
316 
317 	u8 version;
318 	u8 stop_on_match;
319 	u8 intervals_num;
320 	u8 scan_func;
321 	__le16 intervals[MT76_CONNAC_MAX_NUM_SCHED_SCAN_INTERVAL];
322 };
323 
324 struct scan_sched_ssid_match_sets {
325 	__le16 tag;
326 	__le16 len;
327 
328 	u8 match_num;
329 	u8 rsv[3];
330 
331 	struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH];
332 };
333 
334 struct scan_sched_enable {
335 	__le16 tag;
336 	__le16 len;
337 
338 	u8 active;
339 	u8 rsv[3];
340 };
341 
342 struct mbmc_set_req {
343 	u8 pad[4];
344 	u8 data[];
345 } __packed;
346 
347 struct mbmc_conf_tlv {
348 	__le16 tag;
349 	__le16 len;
350 
351 	u8 mbmc_en;
352 	u8 band;
353 	u8 pad[2];
354 } __packed;
355 
356 struct edca {
357 	__le16 tag;
358 	__le16 len;
359 
360 	u8 queue;
361 	u8 set;
362 	u8 cw_min;
363 	u8 cw_max;
364 	__le16 txop;
365 	u8 aifs;
366 	u8 __rsv;
367 };
368 
369 struct bss_req_hdr {
370 	u8 bss_idx;
371 	u8 __rsv[3];
372 } __packed;
373 
374 struct bss_rate_tlv {
375 	__le16 tag;
376 	__le16 len;
377 	u8 __rsv1[2];
378 	__le16 basic_rate;
379 	__le16 bc_trans;
380 	__le16 mc_trans;
381 	u8 short_preamble;
382 	u8 bc_fixed_rate;
383 	u8 mc_fixed_rate;
384 	u8 __rsv2;
385 } __packed;
386 
387 struct bss_mld_tlv {
388 	__le16 tag;
389 	__le16 len;
390 	u8 group_mld_id;
391 	u8 own_mld_id;
392 	u8 mac_addr[ETH_ALEN];
393 	u8 remap_idx;
394 	u8 link_id;
395 	u8 eml_enable;
396 	u8 max_link_num;
397 	u8 hybrid_mode;
398 	u8 __rsv[3];
399 } __packed;
400 
401 struct bss_eht_tlv {
402 	__le16 tag;
403 	__le16 len;
404 	u8  is_eht_op_present;
405 	u8  is_eth_dscb_present;
406 	u8  eht_ctrl;
407 	u8  eht_ccfs0;
408 	u8  eht_ccfs1;
409 	u8  pad1;
410 	__le16 eht_dis_sub_chan_bitmap;
411 	u8  pad2[4];
412 } __packed;
413 
414 struct sta_rec_ba_uni {
415 	__le16 tag;
416 	__le16 len;
417 	u8 tid;
418 	u8 ba_type;
419 	u8 amsdu;
420 	u8 ba_en;
421 	__le16 ssn;
422 	__le16 winsize;
423 	u8 ba_rdd_rro;
424 	u8 __rsv[3];
425 } __packed;
426 
427 struct sta_rec_eht {
428 	__le16 tag;
429 	__le16 len;
430 	u8 tid_bitmap;
431 	u8 _rsv;
432 	__le16 mac_cap;
433 	__le64 phy_cap;
434 	__le64 phy_cap_ext;
435 	u8 mcs_map_bw20[4];
436 	u8 mcs_map_bw80[3];
437 	u8 mcs_map_bw160[3];
438 	u8 mcs_map_bw320[3];
439 	u8 _rsv2[3];
440 } __packed;
441 
442 struct sta_rec_sec_uni {
443 	__le16 tag;
444 	__le16 len;
445 	u8 add;
446 	u8 tx_key;
447 	u8 key_type;
448 	u8 is_authenticator;
449 	u8 peer_addr[6];
450 	u8 bss_idx;
451 	u8 cipher_id;
452 	u8 key_id;
453 	u8 key_len;
454 	u8 wlan_idx;
455 	u8 mgmt_prot;
456 	u8 key[32];
457 	u8 key_rsc[16];
458 } __packed;
459 
460 struct sta_rec_hdr_trans {
461 	__le16 tag;
462 	__le16 len;
463 	u8 from_ds;
464 	u8 to_ds;
465 	u8 dis_rx_hdr_tran;
466 	u8 rsv;
467 } __packed;
468 
469 struct sta_rec_mld {
470 	__le16 tag;
471 	__le16 len;
472 	u8 mac_addr[ETH_ALEN];
473 	__le16 primary_id;
474 	__le16 secondary_id;
475 	__le16 wlan_id;
476 	u8 link_num;
477 	u8 rsv[3];
478 	struct {
479 		__le16 wlan_id;
480 		u8 bss_idx;
481 		u8 rsv;
482 	} __packed link[2];
483 } __packed;
484 
485 struct sta_rec_eht_mld {
486 	__le16 tag;
487 	__le16 len;
488 	u8 nsep;
489 	u8 mld_type;
490 	u8 __rsv1[1];
491 	u8 str_cap[3];
492 	u8 eml_cap[3];
493 	u8 __rsv2[3];
494 } __packed;
495 
496 struct bss_ifs_time_tlv {
497 	__le16 tag;
498 	__le16 len;
499 	u8 slot_valid;
500 	u8 sifs_valid;
501 	u8 rifs_valid;
502 	u8 eifs_valid;
503 	__le16 slot_time;
504 	__le16 sifs_time;
505 	__le16 rifs_time;
506 	__le16 eifs_time;
507 	u8 eifs_cck_valid;
508 	u8 rsv;
509 	__le16 eifs_cck_time;
510 } __packed;
511 
512 struct bss_rlm_tlv {
513 	__le16 tag;
514 	__le16 len;
515 	u8 control_channel;
516 	u8 center_chan;
517 	u8 center_chan2;
518 	u8 bw;
519 	u8 tx_streams;
520 	u8 rx_streams;
521 	u8 ht_op_info;
522 	u8 sco;
523 	u8 band;
524 	u8 pad[3];
525 } __packed;
526 
527 #define MT7925_STA_UPDATE_MAX_SIZE	(sizeof(struct sta_req_hdr) +		\
528 					 sizeof(struct sta_rec_basic) +		\
529 					 sizeof(struct sta_rec_bf) +		\
530 					 sizeof(struct sta_rec_ht) +		\
531 					 sizeof(struct sta_rec_he_v2) +		\
532 					 sizeof(struct sta_rec_ba_uni) +	\
533 					 sizeof(struct sta_rec_vht) +		\
534 					 sizeof(struct sta_rec_uapsd) +		\
535 					 sizeof(struct sta_rec_amsdu) +		\
536 					 sizeof(struct sta_rec_bfee) +		\
537 					 sizeof(struct sta_rec_phy) +		\
538 					 sizeof(struct sta_rec_ra) +		\
539 					 sizeof(struct sta_rec_sec_uni) +   \
540 					 sizeof(struct sta_rec_ra_fixed) +	\
541 					 sizeof(struct sta_rec_he_6g_capa) +	\
542 					 sizeof(struct sta_rec_eht) +		\
543 					 sizeof(struct sta_rec_hdr_trans) +	\
544 					 sizeof(struct sta_rec_mld) +		\
545 					 sizeof(struct tlv) * 2 +		\
546 					 sizeof(struct sta_rec_remove))
547 
548 #define MT7925_BSS_UPDATE_MAX_SIZE	(sizeof(struct bss_req_hdr) +		\
549 					 sizeof(struct mt76_connac_bss_basic_tlv) +	\
550 					 sizeof(struct mt76_connac_bss_qos_tlv) +	\
551 					 sizeof(struct bss_rate_tlv) +			\
552 					 sizeof(struct bss_mld_tlv) +			\
553 					 sizeof(struct bss_info_uni_he) +		\
554 					 sizeof(struct bss_info_uni_bss_color) +	\
555 					 sizeof(struct bss_ifs_time_tlv) +		\
556 					 sizeof(struct bss_rlm_tlv) +		\
557 					 sizeof(struct tlv))
558 
559 #define MT_CONNAC3_SKU_POWER_LIMIT      449
560 struct mt7925_sku_tlv {
561 	u8 channel;
562 	s8 pwr_limit[MT_CONNAC3_SKU_POWER_LIMIT];
563 } __packed;
564 
565 struct mt7925_tx_power_limit_tlv {
566 	u8 rsv[4];
567 
568 	__le16 tag;
569 	__le16 len;
570 
571 	/* DW0 - common info*/
572 	u8 ver;
573 	u8 pad0;
574 	__le16 rsv1;
575 	/* DW1 - cmd hint */
576 	u8 n_chan; /* # channel */
577 	u8 band; /* 2.4GHz - 5GHz - 6GHz */
578 	u8 last_msg;
579 	u8 limit_type;
580 	/* DW3 */
581 	u8 alpha2[4]; /* regulatory_request.alpha2 */
582 	u8 pad2[32];
583 
584 	u8 data[];
585 } __packed;
586 
587 struct mt7925_arpns_tlv {
588 	__le16 tag;
589 	__le16 len;
590 
591 	u8 enable;
592 	u8 ips_num;
593 	u8 rsv[2];
594 } __packed;
595 
596 struct mt7925_wow_pattern_tlv {
597 	__le16 tag;
598 	__le16 len;
599 	u8 bss_idx;
600 	u8 index; /* pattern index */
601 	u8 enable; /* 0: disable
602 		    * 1: enable
603 		    */
604 	u8 data_len; /* pattern length */
605 	u8 offset;
606 	u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN];
607 	u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN];
608 	u8 rsv[4];
609 };
610 
611 #define MT7925_WOW_PATTERN_TLV_V2_SIZE	\
612 	(offsetof(struct mt7925_wow_pattern_tlv, rsv) + 3)
613 
614 struct roc_acquire_tlv {
615 	__le16 tag;
616 	__le16 len;
617 	u8 bss_idx;
618 	u8 tokenid;
619 	u8 control_channel;
620 	u8 sco;
621 	u8 band;
622 	u8 bw;
623 	u8 center_chan;
624 	u8 center_chan2;
625 	u8 bw_from_ap;
626 	u8 center_chan_from_ap;
627 	u8 center_chan2_from_ap;
628 	u8 reqtype;
629 	__le32 maxinterval;
630 	u8 dbdcband;
631 	u8 rsv[3];
632 } __packed;
633 
634 enum ENUM_CMD_TEST_CTRL_ACT {
635 	CMD_TEST_CTRL_ACT_SWITCH_MODE = 0,
636 	CMD_TEST_CTRL_ACT_SET_AT = 1,
637 	CMD_TEST_CTRL_ACT_GET_AT = 2,
638 	CMD_TEST_CTRL_ACT_SET_AT_ENG = 3,
639 	CMD_TEST_CTRL_ACT_GET_AT_ENG = 4,
640 	CMD_TEST_CTRL_ACT_NUM
641 };
642 
643 enum ENUM_CMD_TEST_CTRL_ACT_SWITCH_MODE_OP {
644 	CMD_TEST_CTRL_ACT_SWITCH_MODE_NORMAL = 0,
645 	CMD_TEST_CTRL_ACT_SWITCH_MODE_RF_TEST = 1,
646 	CMD_TEST_CTRL_ACT_SWITCH_MODE_ICAP = 2,
647 	CMD_TEST_CTRL_ACT_SWITCH_MODE_NUM
648 };
649 
650 union testmode_data {
651 	__le32 op_mode;
652 	__le32 channel_freq;
653 	u8 rf_at_info[84];
654 };
655 
656 union testmode_evt {
657 	__le32 op_mode;
658 	__le32 channel_freq;
659 	u8 rf_at_info[1024];
660 };
661 
662 struct uni_cmd_testmode_ctrl {
663 	u16 tag;
664 	u16 length;
665 	u8 action;
666 	u8 reserved[3];
667 	union testmode_data data;
668 } __packed;
669 
670 struct mt7925_rftest_cmd {
671 	u8 padding[4];
672 	struct uni_cmd_testmode_ctrl ctrl;
673 } __packed;
674 
675 static inline enum connac3_mcu_cipher_type
mt7925_mcu_get_cipher(int cipher)676 mt7925_mcu_get_cipher(int cipher)
677 {
678 	switch (cipher) {
679 	case WLAN_CIPHER_SUITE_WEP40:
680 		return CONNAC3_CIPHER_WEP40;
681 	case WLAN_CIPHER_SUITE_WEP104:
682 		return CONNAC3_CIPHER_WEP104;
683 	case WLAN_CIPHER_SUITE_TKIP:
684 		return CONNAC3_CIPHER_TKIP;
685 	case WLAN_CIPHER_SUITE_AES_CMAC:
686 		return CONNAC3_CIPHER_BIP_CMAC_128;
687 	case WLAN_CIPHER_SUITE_CCMP:
688 		return CONNAC3_CIPHER_AES_CCMP;
689 	case WLAN_CIPHER_SUITE_CCMP_256:
690 		return CONNAC3_CIPHER_CCMP_256;
691 	case WLAN_CIPHER_SUITE_GCMP:
692 		return CONNAC3_CIPHER_GCMP;
693 	case WLAN_CIPHER_SUITE_GCMP_256:
694 		return CONNAC3_CIPHER_GCMP_256;
695 	case WLAN_CIPHER_SUITE_SMS4:
696 		return CONNAC3_CIPHER_WAPI;
697 	default:
698 		return CONNAC3_CIPHER_NONE;
699 	}
700 }
701 
702 static inline bool
mt7925_mcu_tlv_valid(struct tlv * tlv,u32 rem)703 mt7925_mcu_tlv_valid(struct tlv *tlv, u32 rem)
704 {
705 	u16 len;
706 
707 	if (rem < sizeof(*tlv))
708 		return false;
709 
710 	len = le16_to_cpu(tlv->len);
711 
712 	/* a length below the header size would not advance the cursor */
713 	return len >= sizeof(*tlv) && len <= rem;
714 }
715 
716 #define mt7925_for_each_tlv(tlv, rem)					\
717 	for (; mt7925_mcu_tlv_valid(tlv, rem);				\
718 	     (rem) -= le16_to_cpu((tlv)->len),				\
719 	     (tlv) = (struct tlv *)((u8 *)(tlv) + le16_to_cpu((tlv)->len)))
720 
721 int mt7925_mcu_set_dbdc(struct mt76_phy *phy, bool enable);
722 int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
723 		       struct ieee80211_scan_request *scan_req);
724 int mt7925_mcu_cancel_hw_scan(struct mt76_phy *phy,
725 			      struct ieee80211_vif *vif);
726 int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
727 			      struct ieee80211_vif *vif,
728 			      struct cfg80211_sched_scan_request *sreq,
729 			      struct ieee80211_scan_ies *ies);
730 int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
731 				 struct ieee80211_vif *vif,
732 				 bool enable);
733 void mt7925_mcu_del_dev(struct mt76_dev *mdev,
734 			struct ieee80211_vif *vif);
735 int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
736 			    struct ieee80211_chanctx_conf *ctx,
737 			    struct ieee80211_bss_conf *link_conf,
738 			    struct ieee80211_link_sta *link_sta,
739 			    int enable);
740 int mt7925_mcu_add_bss_info_sta(struct mt792x_phy *phy,
741 				struct ieee80211_chanctx_conf *ctx,
742 				struct ieee80211_bss_conf *link_conf,
743 				struct ieee80211_link_sta *link_sta,
744 				u16 bmc_tx_wlan_idx,
745 				u16 sta_wlan_idx,
746 				int enable);
747 int mt7925_mcu_set_timing(struct mt792x_phy *phy,
748 			  struct ieee80211_bss_conf *link_conf);
749 int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);
750 int mt7925_mcu_set_thermal_protect(struct mt792x_dev *dev);
751 int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);
752 int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);
753 int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif_link *mvif,
754 			 struct ieee80211_bss_conf *link_conf,
755 			 struct ieee80211_chanctx_conf *ctx);
756 int mt7925_mcu_set_eht_pp(struct mt76_phy *phy, struct mt76_vif_link *mvif,
757 			  struct ieee80211_bss_conf *link_conf,
758 			  struct ieee80211_chanctx_conf *ctx);
759 int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);
760 int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,
761 				 struct ieee80211_bss_conf *link_conf);
762 int
763 mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev,
764 			 struct ieee80211_bss_conf *link_conf, bool enable);
765 #endif
766