blob: 6e00cf3aeffa5c18c90945454522ad6729d3dfcd [file] [log] [blame]
developer0f312e82022-11-01 12:31:52 +08001/* 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
11struct 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
27struct mt7996_mcu_uni_event {
28 u8 cid;
29 u8 __rsv[3];
30 __le32 status; /* 0: success, others: fail */
31} __packed;
32
33struct mt7996_mcu_csa_notify {
34 struct mt7996_mcu_rxd rxd;
35
36 u8 omac_idx;
37 u8 csa_count;
38 u8 band_idx;
39 u8 rsv;
40} __packed;
41
42struct mt7996_mcu_rdd_report {
43 struct mt7996_mcu_rxd rxd;
44
45 u8 __rsv1[4];
46
47 __le16 tag;
48 __le16 len;
49
50 u8 band_idx;
51 u8 long_detected;
52 u8 constant_prf_detected;
53 u8 staggered_prf_detected;
54 u8 radar_type_idx;
55 u8 periodic_pulse_num;
56 u8 long_pulse_num;
57 u8 hw_pulse_num;
58
59 u8 out_lpn;
60 u8 out_spn;
61 u8 out_crpn;
62 u8 out_crpw;
63 u8 out_crbn;
64 u8 out_stgpn;
65 u8 out_stgpw;
66
67 u8 __rsv2;
68
69 __le32 out_pri_const;
70 __le32 out_pri_stg[3];
71 __le32 out_pri_stg_dmin;
72
73 struct {
74 __le32 start;
75 __le16 pulse_width;
76 __le16 pulse_power;
77 u8 mdrdy_flag;
78 u8 rsv[3];
79 } long_pulse[32];
80
81 struct {
82 __le32 start;
83 __le16 pulse_width;
84 __le16 pulse_power;
85 u8 mdrdy_flag;
86 u8 rsv[3];
87 } periodic_pulse[32];
88
89 struct {
90 __le32 start;
91 __le16 pulse_width;
92 __le16 pulse_power;
93 u8 sc_pass;
94 u8 sw_reset;
95 u8 mdrdy_flag;
96 u8 tx_active;
97 } hw_pulse[32];
98} __packed;
99
100struct mt7996_mcu_background_chain_ctrl {
101 u8 chan; /* primary channel */
102 u8 central_chan; /* central channel */
103 u8 bw;
104 u8 tx_stream;
105 u8 rx_stream;
106
107 u8 monitor_chan; /* monitor channel */
108 u8 monitor_central_chan;/* monitor central channel */
109 u8 monitor_bw;
110 u8 monitor_tx_stream;
111 u8 monitor_rx_stream;
112
113 u8 scan_mode; /* 0: ScanStop
114 * 1: ScanStart
115 * 2: ScanRunning
116 */
117 u8 band_idx; /* DBDC */
118 u8 monitor_scan_type;
119 u8 band; /* 0: 2.4GHz, 1: 5GHz */
120 u8 rsv[2];
121} __packed;
122
123struct mt7996_mcu_eeprom {
124 u8 _rsv[4];
125
126 __le16 tag;
127 __le16 len;
128 u8 buffer_mode;
129 u8 format;
130 __le16 buf_len;
131} __packed;
132
133struct mt7996_mcu_phy_rx_info {
134 u8 category;
135 u8 rate;
136 u8 mode;
137 u8 nsts;
138 u8 gi;
139 u8 coding;
140 u8 stbc;
141 u8 bw;
142};
143
144struct mt7996_mcu_mib {
145 __le16 tag;
146 __le16 len;
147 __le32 offs;
148 __le64 data;
149} __packed;
150
151enum mt7996_chan_mib_offs {
152 UNI_MIB_OBSS_AIRTIME = 26,
153 UNI_MIB_NON_WIFI_TIME = 27,
154 UNI_MIB_TX_TIME = 28,
155 UNI_MIB_RX_TIME = 29
156};
157
158struct edca {
159 __le16 tag;
160 __le16 len;
161
162 u8 queue;
163 u8 set;
164 u8 cw_min;
165 u8 cw_max;
166 __le16 txop;
167 u8 aifs;
168 u8 __rsv;
169};
170
171#define MCU_PQ_ID(p, q) (((p) << 15) | ((q) << 10))
172#define MCU_PKT_ID 0xa0
173
174enum {
175 MCU_FW_LOG_WM,
176 MCU_FW_LOG_WA,
177 MCU_FW_LOG_TO_HOST,
178 MCU_FW_LOG_RELAY = 16
179};
180
181enum {
182 MCU_TWT_AGRT_ADD,
183 MCU_TWT_AGRT_MODIFY,
184 MCU_TWT_AGRT_DELETE,
185 MCU_TWT_AGRT_TEARDOWN,
186 MCU_TWT_AGRT_GET_TSF,
187};
188
189enum {
190 MCU_WA_PARAM_CMD_QUERY,
191 MCU_WA_PARAM_CMD_SET,
192 MCU_WA_PARAM_CMD_CAPABILITY,
193 MCU_WA_PARAM_CMD_DEBUG,
194};
195
196enum {
197 MCU_WA_PARAM_PDMA_RX = 0x04,
198 MCU_WA_PARAM_CPU_UTIL = 0x0b,
199 MCU_WA_PARAM_RED = 0x0e,
200 MCU_WA_PARAM_HW_PATH_HIF_VER = 0x2f,
201};
202
203enum mcu_mmps_mode {
204 MCU_MMPS_STATIC,
205 MCU_MMPS_DYNAMIC,
206 MCU_MMPS_RSV,
207 MCU_MMPS_DISABLE,
208};
209
210struct bss_rate_tlv {
211 __le16 tag;
212 __le16 len;
213 u8 __rsv1[4];
214 __le16 bc_trans;
215 __le16 mc_trans;
216 u8 short_preamble;
217 u8 bc_fixed_rate;
218 u8 mc_fixed_rate;
219 u8 __rsv2[1];
220} __packed;
221
222struct bss_ra_tlv {
223 __le16 tag;
224 __le16 len;
225 u8 short_preamble;
226 u8 force_sgi;
227 u8 force_gf;
228 u8 ht_mode;
229 u8 se_off;
230 u8 antenna_idx;
231 __le16 max_phyrate;
232 u8 force_tx_streams;
233 u8 __rsv[3];
234} __packed;
235
236struct bss_rlm_tlv {
237 __le16 tag;
238 __le16 len;
239 u8 control_channel;
240 u8 center_chan;
241 u8 center_chan2;
242 u8 bw;
243 u8 tx_streams;
244 u8 rx_streams;
245 u8 ht_op_info;
246 u8 sco;
247 u8 band;
248 u8 __rsv[3];
249} __packed;
250
251struct bss_color_tlv {
252 __le16 tag;
253 __le16 len;
254 u8 enable;
255 u8 color;
256 u8 rsv[2];
257} __packed;
258
259struct bss_inband_discovery_tlv {
260 __le16 tag;
261 __le16 len;
262 u8 tx_type;
263 u8 tx_mode;
264 u8 tx_interval;
265 u8 enable;
266 __le16 wcid;
267 __le16 prob_rsp_len;
268#define MAX_INBAND_FRAME_SIZE 512
269 u8 pkt[MAX_INBAND_FRAME_SIZE];
270} __packed;
271
272struct bss_bcn_content_tlv {
273 __le16 tag;
274 __le16 len;
275 __le16 tim_ie_pos;
276 __le16 csa_ie_pos;
277 __le16 bcc_ie_pos;
278 u8 enable;
279 u8 type;
280 __le16 pkt_len;
281#define MAX_BEACON_SIZE 512
282 u8 pkt[MAX_BEACON_SIZE];
283} __packed;
284
285struct bss_bcn_cntdwn_tlv {
286 __le16 tag;
287 __le16 len;
288 u8 cnt;
289 u8 rsv[3];
290} __packed;
291
292struct bss_bcn_mbss_tlv {
293 __le16 tag;
294 __le16 len;
295 __le32 bitmap;
296#define MAX_BEACON_NUM 32
297 __le16 offset[MAX_BEACON_NUM];
298} __packed __aligned(4);
299
300struct bss_txcmd_tlv {
301 __le16 tag;
302 __le16 len;
303 u8 txcmd_mode;
304 u8 __rsv[3];
305} __packed;
306
307struct bss_sec_tlv {
308 __le16 tag;
309 __le16 len;
310 u8 __rsv1[2];
311 u8 cipher;
312 u8 __rsv2[1];
313} __packed;
314
315struct bss_power_save {
316 __le16 tag;
317 __le16 len;
318 u8 profile;
319 u8 _rsv[3];
320} __packed;
321
322struct bss_mld_tlv {
323 __le16 tag;
324 __le16 len;
325 u8 group_mld_id;
326 u8 own_mld_id;
327 u8 mac_addr[ETH_ALEN];
328 u8 remap_idx;
329 u8 __rsv[3];
330} __packed;
331
332struct sta_rec_ba_uni {
333 __le16 tag;
334 __le16 len;
335 u8 tid;
336 u8 ba_type;
337 u8 amsdu;
338 u8 ba_en;
339 __le16 ssn;
340 __le16 winsize;
341 u8 ba_rdd_rro;
342 u8 __rsv[3];
343} __packed;
344
345struct sec_key_uni {
346 __le16 wlan_idx;
347 u8 mgmt_prot;
348 u8 cipher_id;
349 u8 cipher_len;
350 u8 key_id;
351 u8 key_len;
352 u8 need_resp;
353 u8 key[32];
354} __packed;
355
356struct sta_rec_sec_uni {
357 __le16 tag;
358 __le16 len;
359 u8 add;
360 u8 n_cipher;
361 u8 rsv[2];
362
363 struct sec_key_uni key[2];
364} __packed;
365
366struct sta_rec_hdrt {
367 __le16 tag;
368 __le16 len;
369 u8 hdrt_mode;
370 u8 rsv[3];
371} __packed;
372
373struct sta_rec_hdr_trans {
374 __le16 tag;
375 __le16 len;
376 u8 from_ds;
377 u8 to_ds;
378 u8 dis_rx_hdr_tran;
379 u8 rsv;
380} __packed;
381
382struct hdr_trans_en {
383 __le16 tag;
384 __le16 len;
385 u8 enable;
386 u8 check_bssid;
387 u8 mode;
388 u8 __rsv;
389} __packed;
390
391struct hdr_trans_vlan {
392 __le16 tag;
393 __le16 len;
394 u8 insert_vlan;
395 u8 remove_vlan;
396 u8 tid;
397 u8 __rsv;
398} __packed;
399
400struct hdr_trans_blacklist {
401 __le16 tag;
402 __le16 len;
403 u8 idx;
404 u8 enable;
405 __le16 type;
406} __packed;
407
408struct uni_header {
409 u8 __rsv[4];
410} __packed;
411
412struct vow_rx_airtime {
413 __le16 tag;
414 __le16 len;
415
416 u8 enable;
417 u8 band;
418 u8 __rsv[2];
419} __packed;
420
421struct bf_sounding_on {
422 __le16 tag;
423 __le16 len;
424
425 u8 snd_mode;
426 u8 sta_num;
427 u8 __rsv[2];
428 __le16 wlan_id[4];
429 __le32 snd_period;
430} __packed;
431
432struct bf_hw_en_status_update {
433 __le16 tag;
434 __le16 len;
435
436 bool ebf;
437 bool ibf;
438 u8 __rsv[2];
439} __packed;
440
441struct bf_mod_en_ctrl {
442 __le16 tag;
443 __le16 len;
444
445 u8 bf_num;
446 u8 bf_bitmap;
447 u8 bf_sel[8];
448 u8 __rsv[2];
449} __packed;
450
451union bf_tag_tlv{
452 struct bf_sounding_on bf_snd;
453 struct bf_hw_en_status_update bf_hw_en;
454 struct bf_mod_en_ctrl bf_mod_en;
455};
456
457struct ra_rate {
458 __le16 wlan_idx;
459 u8 mode;
460 u8 stbc;
461 __le16 gi;
462 u8 bw;
463 u8 ldpc;
464 u8 mcs;
465 u8 nss;
466 __le16 ltf;
467 u8 spe;
468 u8 preamble;
469 u8 __rsv[2];
470} __packed;
471
472struct ra_fixed_rate {
473 __le16 tag;
474 __le16 len;
475
476 __le16 version;
477 struct ra_rate rate;
478} __packed;
479
480enum {
481 UNI_RA_FIXED_RATE = 0xf,
482};
483
484#define MT7996_HDR_TRANS_MAX_SIZE (sizeof(struct hdr_trans_en) + \
485 sizeof(struct hdr_trans_vlan) + \
486 sizeof(struct hdr_trans_blacklist))
487
488enum {
489 UNI_HDR_TRANS_EN,
490 UNI_HDR_TRANS_VLAN,
491 UNI_HDR_TRANS_BLACKLIST,
492};
493
494enum {
495 RATE_PARAM_FIXED = 3,
496 RATE_PARAM_MMPS_UPDATE = 5,
497 RATE_PARAM_FIXED_HE_LTF = 7,
498 RATE_PARAM_FIXED_MCS,
499 RATE_PARAM_FIXED_GI = 11,
500 RATE_PARAM_AUTO = 20,
501};
502
503enum {
504 BF_SOUNDING_ON = 1,
505 BF_HW_EN_UPDATE = 17,
506 BF_MOD_EN_CTRL = 20,
507};
508
509enum {
510 CMD_BAND_NONE,
511 CMD_BAND_24G,
512 CMD_BAND_5G,
513 CMD_BAND_6G,
514};
515
516struct bss_req_hdr {
517 u8 bss_idx;
518 u8 __rsv[3];
519} __packed;
520
521enum {
522 UNI_CHANNEL_SWITCH,
523 UNI_CHANNEL_RX_PATH,
524};
525
526#define MT7996_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \
527 sizeof(struct mt76_connac_bss_basic_tlv) + \
528 sizeof(struct bss_rlm_tlv) + \
529 sizeof(struct bss_ra_tlv) + \
530 sizeof(struct bss_info_uni_he) + \
531 sizeof(struct bss_rate_tlv) + \
532 sizeof(struct bss_txcmd_tlv) + \
533 sizeof(struct bss_power_save) + \
534 sizeof(struct bss_sec_tlv) + \
535 sizeof(struct bss_mld_tlv))
536
537#define MT7996_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
538 sizeof(struct sta_rec_basic) + \
539 sizeof(struct sta_rec_bf) + \
540 sizeof(struct sta_rec_ht) + \
541 sizeof(struct sta_rec_he_v2) + \
542 sizeof(struct sta_rec_ba_uni) + \
543 sizeof(struct sta_rec_vht) + \
544 sizeof(struct sta_rec_uapsd) + \
545 sizeof(struct sta_rec_amsdu) + \
546 sizeof(struct sta_rec_bfee) + \
547 sizeof(struct sta_rec_phy) + \
548 sizeof(struct sta_rec_ra) + \
549 sizeof(struct sta_rec_sec) + \
550 sizeof(struct sta_rec_ra_fixed) + \
551 sizeof(struct sta_rec_he_6g_capa) + \
552 sizeof(struct sta_rec_hdrt) + \
553 sizeof(struct sta_rec_hdr_trans) + \
554 sizeof(struct tlv))
555
556#define MT7996_BEACON_UPDATE_SIZE (sizeof(struct bss_req_hdr) + \
557 sizeof(struct bss_bcn_content_tlv) + \
558 sizeof(struct bss_bcn_cntdwn_tlv) + \
559 sizeof(struct bss_bcn_mbss_tlv))
560
561#define MT7996_INBAND_FRAME_SIZE (sizeof(struct bss_req_hdr) + \
562 sizeof(struct bss_inband_discovery_tlv))
563
564enum {
565 UNI_BAND_CONFIG_RADIO_ENABLE,
566 UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,
567};
568
569enum {
570 UNI_WSYS_CONFIG_FW_LOG_CTRL,
571 UNI_WSYS_CONFIG_FW_DBG_CTRL,
572};
573
574enum {
575 UNI_RDD_CTRL_PARM,
576};
577
578enum {
579 UNI_EFUSE_ACCESS = 1,
580 UNI_EFUSE_BUFFER_MODE,
581 UNI_EFUSE_FREE_BLOCK,
582 UNI_EFUSE_BUFFER_RD,
583};
584
585enum {
586 UNI_VOW_DRR_CTRL,
587 UNI_VOW_RX_AT_AIRTIME_EN = 0x0b,
588 UNI_VOW_RX_AT_AIRTIME_CLR_EN = 0x0e,
589};
590
591enum {
592 UNI_CMD_MIB_DATA,
593};
594
595enum {
596 UNI_POWER_OFF,
597};
598
599enum {
600 UNI_CMD_TWT_ARGT_UPDATE = 0x0,
601 UNI_CMD_TWT_MGMT_OFFLOAD,
602};
603
604enum {
605 UNI_RRO_DEL_ENTRY = 0x1,
606 UNI_RRO_SET_PLATFORM_TYPE,
607 UNI_RRO_GET_BA_SESSION_TABLE,
608 UNI_RRO_SET_BYPASS_MODE,
609 UNI_RRO_SET_TXFREE_PATH,
610};
611
612enum{
613 UNI_CMD_SR_ENABLE = 0x1,
614};
615
616enum {
617 UNI_CMD_ACCESS_REG_BASIC = 0x0,
618 UNI_CMD_ACCESS_RF_REG_BASIC,
619};
620
621enum {
622 MT7996_SEC_MODE_PLAIN,
623 MT7996_SEC_MODE_AES,
624 MT7996_SEC_MODE_SCRAMBLE,
625 MT7996_SEC_MODE_MAX,
626};
627
628#define MT7996_PATCH_SEC GENMASK(31, 24)
629#define MT7996_PATCH_SCRAMBLE_KEY GENMASK(15, 8)
630#define MT7996_PATCH_AES_KEY GENMASK(7, 0)
631
632#define MT7996_SEC_ENCRYPT BIT(0)
633#define MT7996_SEC_KEY_IDX GENMASK(2, 1)
634#define MT7996_SEC_IV BIT(3)
635
636#endif