blob: c3bd8af556a36fd163a6c45b305437923609386d [file] [log] [blame]
developerb11a5392022-03-31 00:34:47 +08001/* SPDX-License-Identifier: ISC */
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#ifndef __BERSA_MCU_H
5#define __BERSA_MCU_H
6
7#include "../mt76_connac_mcu.h"
8
9struct bersa_mcu_txd {
10 __le32 txd[8];
11
12 __le16 len;
13 __le16 pq_id;
14
15 u8 cid;
16 u8 pkt_type;
17 u8 set_query; /* FW don't care */
18 u8 seq;
19
20 u8 uc_d2b0_rev;
21 u8 ext_cid;
22 u8 s2d_index;
23 u8 ext_cid_ack;
24
25 u32 reserved[5];
26} __packed __aligned(4);
27
28/**
29 * struct bersa_uni_txd - mcu command descriptor for firmware v3
30 * @txd: hardware descriptor
31 * @len: total length not including txd
32 * @cid: command identifier
33 * @pkt_type: must be 0xa0 (cmd packet by long format)
34 * @frag_n: fragment number
35 * @seq: sequence number
36 * @checksum: 0 mean there is no checksum
37 * @s2d_index: index for command source and destination
38 * Definition | value | note
39 * CMD_S2D_IDX_H2N | 0x00 | command from HOST to WM
40 * CMD_S2D_IDX_C2N | 0x01 | command from WA to WM
41 * CMD_S2D_IDX_H2C | 0x02 | command from HOST to WA
42 * CMD_S2D_IDX_H2N_AND_H2C | 0x03 | command from HOST to WA and WM
43 *
44 * @option: command option
45 * BIT[0]: UNI_CMD_OPT_BIT_ACK
46 * set to 1 to request a fw reply
47 * if UNI_CMD_OPT_BIT_0_ACK is set and UNI_CMD_OPT_BIT_2_SET_QUERY
48 * is set, mcu firmware will send response event EID = 0x01
49 * (UNI_EVENT_ID_CMD_RESULT) to the host.
50 * BIT[1]: UNI_CMD_OPT_BIT_UNI_CMD
51 * 0: original command
52 * 1: unified command
53 * BIT[2]: UNI_CMD_OPT_BIT_SET_QUERY
54 * 0: QUERY command
55 * 1: SET command
56 */
57struct bersa_uni_txd {
58 __le32 txd[8];
59
60 /* DW1 */
61 __le16 len;
62 __le16 cid;
63
64 /* DW2 */
65 u8 reserved;
66 u8 pkt_type;
67 u8 frag_n;
68 u8 seq;
69
70 /* DW3 */
71 __le16 checksum;
72 u8 s2d_index;
73 u8 option;
74
75 /* DW4 */
76 u8 reserved2[4];
77} __packed __aligned(4);
78
79enum {
80 MCU_ATE_SET_TRX = 0x1,
81 MCU_ATE_SET_FREQ_OFFSET = 0xa,
82 MCU_ATE_SET_SLOT_TIME = 0x13,
83 MCU_ATE_CLEAN_TXQUEUE = 0x1c,
84};
85
86struct bersa_mcu_rxd {
87 __le32 rxd[8];
88
89 __le16 len;
90 __le16 pkt_type_id;
91
92 u8 eid;
93 u8 seq;
94 u8 option;
95 u8 __rsv;
96
97 u8 ext_eid;
98 u8 __rsv1[2];
99 u8 s2d_index;
100};
101
102struct bersa_mcu_uni_event {
103 u8 cid;
104 u8 __rsv[3];
105 __le32 status; /* 0: success, others: fail */
106} __packed;
107
108struct bersa_mcu_thermal_ctrl {
109 u8 ctrl_id;
110 u8 band_idx;
111 union {
112 struct {
113 u8 protect_type; /* 1: duty admit, 2: radio off */
114 u8 trigger_type; /* 0: low, 1: high */
115 } __packed type;
116 struct {
117 u8 duty_level; /* level 0~3 */
118 u8 duty_cycle;
119 } __packed duty;
120 };
121} __packed;
122
123struct bersa_mcu_thermal_notify {
124 struct bersa_mcu_rxd rxd;
125
126 struct bersa_mcu_thermal_ctrl ctrl;
127 __le32 temperature;
128 u8 rsv[8];
129} __packed;
130
131struct bersa_mcu_csa_notify {
132 struct bersa_mcu_rxd rxd;
133
134 u8 omac_idx;
135 u8 csa_count;
136 u8 band_idx;
137 u8 rsv;
138} __packed;
139
140struct bersa_mcu_rdd_report {
141 struct bersa_mcu_rxd rxd;
142
143 u8 band_idx;
144 u8 long_detected;
145 u8 constant_prf_detected;
146 u8 staggered_prf_detected;
147 u8 radar_type_idx;
148 u8 periodic_pulse_num;
149 u8 long_pulse_num;
150 u8 hw_pulse_num;
151
152 u8 out_lpn;
153 u8 out_spn;
154 u8 out_crpn;
155 u8 out_crpw;
156 u8 out_crbn;
157 u8 out_stgpn;
158 u8 out_stgpw;
159
160 u8 rsv;
161
162 __le32 out_pri_const;
163 __le32 out_pri_stg[3];
164
165 struct {
166 __le32 start;
167 __le16 pulse_width;
168 __le16 pulse_power;
169 u8 mdrdy_flag;
170 u8 rsv[3];
171 } long_pulse[32];
172
173 struct {
174 __le32 start;
175 __le16 pulse_width;
176 __le16 pulse_power;
177 u8 mdrdy_flag;
178 u8 rsv[3];
179 } periodic_pulse[32];
180
181 struct {
182 __le32 start;
183 __le16 pulse_width;
184 __le16 pulse_power;
185 u8 sc_pass;
186 u8 sw_reset;
187 u8 mdrdy_flag;
188 u8 tx_active;
189 } hw_pulse[32];
190} __packed;
191
192struct bersa_mcu_background_chain_ctrl {
193 u8 chan; /* primary channel */
194 u8 central_chan; /* central channel */
195 u8 bw;
196 u8 tx_stream;
197 u8 rx_stream;
198
199 u8 monitor_chan; /* monitor channel */
200 u8 monitor_central_chan;/* monitor central channel */
201 u8 monitor_bw;
202 u8 monitor_tx_stream;
203 u8 monitor_rx_stream;
204
205 u8 scan_mode; /* 0: ScanStop
206 * 1: ScanStart
207 * 2: ScanRunning
208 */
209 u8 band_idx; /* DBDC */
210 u8 monitor_scan_type;
211 u8 band; /* 0: 2.4GHz, 1: 5GHz */
212 u8 rsv[2];
213} __packed;
214
215struct bersa_mcu_eeprom {
216 u8 _rsv[4];
217
218 __le16 tag;
219 __le16 len;
220 u8 buffer_mode;
221 u8 format;
222 __le16 buf_len;
223} __packed;
224
225struct bersa_mcu_eeprom_info {
226 __le32 addr;
227 __le32 valid;
228 u8 data[16];
229} __packed;
230
231struct bersa_mcu_phy_rx_info {
232 u8 category;
233 u8 rate;
234 u8 mode;
235 u8 nsts;
236 u8 gi;
237 u8 coding;
238 u8 stbc;
239 u8 bw;
240};
241
242struct bersa_mcu_mib {
243 __le16 tag;
244 __le16 len;
245 __le32 offs;
246 __le64 data;
247} __packed;
248
249enum bersa_chan_mib_offs {
250 /* bersa */
251 MIB_BUSY_TIME = 0,
252 MIB_TX_TIME = 6,
253 MIB_RX_TIME = 8,
254 MIB_OBSS_AIRTIME = 499,
255};
256
257struct edca {
258 __le16 tag;
259 __le16 len;
260
261 u8 queue;
262 u8 set;
263 u8 cw_min;
264 u8 cw_max;
265 __le16 txop;
266 u8 aifs;
267 u8 __rsv;
268};
269
270struct bersa_mcu_muru_stats {
271 __le32 event_id;
272 struct {
273 __le32 cck_cnt;
274 __le32 ofdm_cnt;
275 __le32 htmix_cnt;
276 __le32 htgf_cnt;
277 __le32 vht_su_cnt;
278 __le32 vht_2mu_cnt;
279 __le32 vht_3mu_cnt;
280 __le32 vht_4mu_cnt;
281 __le32 he_su_cnt;
282 __le32 he_ext_su_cnt;
283 __le32 he_2ru_cnt;
284 __le32 he_2mu_cnt;
285 __le32 he_3ru_cnt;
286 __le32 he_3mu_cnt;
287 __le32 he_4ru_cnt;
288 __le32 he_4mu_cnt;
289 __le32 he_5to8ru_cnt;
290 __le32 he_9to16ru_cnt;
291 __le32 he_gtr16ru_cnt;
292 } dl;
293
294 struct {
295 __le32 hetrig_su_cnt;
296 __le32 hetrig_2ru_cnt;
297 __le32 hetrig_3ru_cnt;
298 __le32 hetrig_4ru_cnt;
299 __le32 hetrig_5to8ru_cnt;
300 __le32 hetrig_9to16ru_cnt;
301 __le32 hetrig_gtr16ru_cnt;
302 __le32 hetrig_2mu_cnt;
303 __le32 hetrig_3mu_cnt;
304 __le32 hetrig_4mu_cnt;
305 } ul;
306};
307
308#define WMM_AIFS_SET BIT(0)
309#define WMM_CW_MIN_SET BIT(1)
310#define WMM_CW_MAX_SET BIT(2)
311#define WMM_TXOP_SET BIT(3)
312#define WMM_PARAM_SET GENMASK(3, 0)
313
314#define MCU_PQ_ID(p, q) (((p) << 15) | ((q) << 10))
315#define MCU_PKT_ID 0xa0
316
317enum {
318 MCU_FW_LOG_WM,
319 MCU_FW_LOG_WA,
320 MCU_FW_LOG_TO_HOST,
321 MCU_FW_LOG_RELAY = 16
322};
323
324enum {
325 MCU_TWT_AGRT_ADD,
326 MCU_TWT_AGRT_MODIFY,
327 MCU_TWT_AGRT_DELETE,
328 MCU_TWT_AGRT_TEARDOWN,
329 MCU_TWT_AGRT_GET_TSF,
330};
331
332enum {
333 MCU_WA_PARAM_CMD_QUERY,
334 MCU_WA_PARAM_CMD_SET,
335 MCU_WA_PARAM_CMD_CAPABILITY,
336 MCU_WA_PARAM_CMD_DEBUG,
337};
338
339enum {
340 MCU_WA_PARAM_PDMA_RX = 0x04,
341 MCU_WA_PARAM_CPU_UTIL = 0x0b,
342 MCU_WA_PARAM_RED = 0x0e,
343};
344
345enum mcu_mmps_mode {
346 MCU_MMPS_STATIC,
347 MCU_MMPS_DYNAMIC,
348 MCU_MMPS_RSV,
349 MCU_MMPS_DISABLE,
350};
351
developerb11a5392022-03-31 00:34:47 +0800352struct bss_rate_tlv {
353 __le16 tag;
354 __le16 len;
355 u8 __rsv1[4];
356 __le16 bc_trans;
357 __le16 mc_trans;
358 u8 short_preamble;
359 u8 bc_fixed_rate;
360 u8 mc_fixed_rate;
361 u8 __rsv2[1];
362} __packed;
363
364struct bss_ra_tlv {
365 __le16 tag;
366 __le16 len;
367 u8 short_preamble;
368 u8 force_sgi;
369 u8 force_gf;
370 u8 ht_mode;
371 u8 se_off;
372 u8 antenna_idx;
373 __le16 max_phyrate;
374 u8 force_tx_streams;
375 u8 __rsv[3];
376} __packed;
377
378struct bss_rlm_tlv {
379 __le16 tag;
380 __le16 len;
381 u8 control_channel;
382 u8 center_chan;
383 u8 center_chan2;
384 u8 bw;
385 u8 tx_streams;
386 u8 rx_streams;
387 u8 ht_op_info;
388 u8 sco;
389 u8 band;
390 u8 __rsv[3];
391} __packed;
392
393struct bss_color_tlv {
394 __le16 tag;
395 __le16 len;
396 u8 enable;
397 u8 color;
398 u8 rsv[2];
399} __packed;
400
401#define MAX_BEACON_SIZE 512
402struct bss_bcn_content_tlv {
403 __le16 tag;
404 __le16 len;
405 __le16 tim_ie_pos;
406 __le16 csa_ie_pos;
407 __le16 bcc_ie_pos;
408 u8 enable;
409 u8 type;
410 __le16 pkt_len;
411 u8 pkt[MAX_BEACON_SIZE];
412} __packed;
413
414struct bss_bcn_cntdwn_tlv {
415 __le16 tag;
416 __le16 len;
417 u8 cnt;
418 u8 rsv[3];
419} __packed;
420
421struct bss_bcn_mbss_tlv {
422#define MAX_BEACON_NUM 32
423 __le16 tag;
424 __le16 len;
425 __le32 bitmap;
426 __le16 offset[MAX_BEACON_NUM];
427} __packed __aligned(4);
428
429struct bss_txcmd_tlv {
430 __le16 tag;
431 __le16 len;
432 u8 txcmd_mode;
433 u8 __rsv[3];
434} __packed;
435
436struct bss_sec_tlv {
437 __le16 tag;
438 __le16 len;
439 u8 __rsv1[2];
440 u8 cipher;
441 u8 __rsv2[1];
442} __packed;
443
444struct bss_power_save {
445 __le16 tag;
446 __le16 len;
447 u8 profile;
448 u8 _rsv[3];
449} __packed;
450
451struct bss_mld_tlv {
452 __le16 tag;
453 __le16 len;
454 u8 group_mld_id;
455 u8 own_mld_id;
456 u8 mac_addr[ETH_ALEN];
457 u8 remap_idx;
458 u8 __rsv[3];
459} __packed;
460
461struct hdr_trans_en {
462 __le16 tag;
463 __le16 len;
464 u8 enable;
465 u8 check_bssid;
466 u8 mode;
467 u8 __rsv;
468} __packed;
469
470struct hdr_trans_vlan {
471 __le16 tag;
472 __le16 len;
473 u8 insert_vlan;
474 u8 remove_vlan;
475 u8 tid;
476 u8 __rsv;
477} __packed;
478
479struct hdr_trans_blacklist {
480 __le16 tag;
481 __le16 len;
482 u8 idx;
483 u8 enable;
484 __le16 type;
485} __packed;
486
487#define BERSA_HDR_TRANS_MAX_SIZE (sizeof(struct hdr_trans_en) + \
488 sizeof(struct hdr_trans_vlan) + \
489 sizeof(struct hdr_trans_blacklist))
490
491enum {
492 UNI_HDR_TRANS_EN,
493 UNI_HDR_TRANS_VLAN,
494 UNI_HDR_TRANS_BLACKLIST,
495};
496
497enum {
498 RATE_PARAM_FIXED = 3,
499 RATE_PARAM_MMPS_UPDATE = 5,
500 RATE_PARAM_FIXED_HE_LTF = 7,
501 RATE_PARAM_FIXED_MCS,
502 RATE_PARAM_FIXED_GI = 11,
503 RATE_PARAM_AUTO = 20,
504};
505
506#define RATE_CFG_MCS GENMASK(3, 0)
507#define RATE_CFG_NSS GENMASK(7, 4)
508#define RATE_CFG_GI GENMASK(11, 8)
509#define RATE_CFG_BW GENMASK(15, 12)
510#define RATE_CFG_STBC GENMASK(19, 16)
511#define RATE_CFG_LDPC GENMASK(23, 20)
512#define RATE_CFG_PHY_TYPE GENMASK(27, 24)
513#define RATE_CFG_HE_LTF GENMASK(31, 28)
514
515enum {
516 THERMAL_PROTECT_PARAMETER_CTRL,
517 THERMAL_PROTECT_BASIC_INFO,
518 THERMAL_PROTECT_ENABLE,
519 THERMAL_PROTECT_DISABLE,
520 THERMAL_PROTECT_DUTY_CONFIG,
521 THERMAL_PROTECT_MECH_INFO,
522 THERMAL_PROTECT_DUTY_INFO,
523 THERMAL_PROTECT_STATE_ACT,
524};
525
526enum {
527 MT_BF_SOUNDING_ON = 1,
528 MT_BF_TYPE_UPDATE = 20,
529 MT_BF_MODULE_UPDATE = 25
530};
531
532enum {
533 MURU_SET_ARB_OP_MODE = 14,
534 MURU_SET_PLATFORM_TYPE = 25,
535};
536
537enum {
538 MURU_PLATFORM_TYPE_PERF_LEVEL_1 = 1,
539 MURU_PLATFORM_TYPE_PERF_LEVEL_2,
540};
541
542/* tx cmd tx statistics */
543enum {
544 MURU_SET_TXC_TX_STATS_EN = 150,
545 MURU_GET_TXC_TX_STATS = 151,
546};
547
548enum {
549 CMD_BAND_NONE,
550 CMD_BAND_24G,
551 CMD_BAND_5G,
552 CMD_BAND_6G,
553};
554
555struct bss_req_hdr {
556 u8 bss_idx;
557 u8 __rsv[3];
558} __packed;
559
560enum {
561 UNI_CHANNEL_SWITCH,
562 UNI_CHANNEL_RX_PATH,
563};
564#define BERSA_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \
565 sizeof(struct mt76_connac_bss_basic_tlv) + \
566 sizeof(struct bss_rlm_tlv) +\
567 sizeof(struct bss_ra_tlv) + \
568 sizeof(struct bss_info_uni_he) + \
569 sizeof(struct bss_rate_tlv) +\
570 sizeof(struct bss_txcmd_tlv) +\
571 sizeof(struct bss_power_save) +\
572 sizeof(struct bss_sec_tlv) +\
573 sizeof(struct bss_mld_tlv))
574
575#define BERSA_BEACON_UPDATE_SIZE (sizeof(struct bss_req_hdr) + \
576 sizeof(struct bss_bcn_content_tlv) + \
577 sizeof(struct bss_bcn_cntdwn_tlv) + \
578 sizeof(struct bss_bcn_mbss_tlv))
579
580enum {
581 UNI_BAND_CONFIG_RADIO_ENABLE,
582 UNI_BAND_CONFIG_EDCCA_ENABLE = 0x5,
583 UNI_BAND_CONFIG_EDCCA_THRESHOLD = 0x6,
584 UNI_BAND_CONFIG_RTS_THRESHOLD = 0x8,
585};
586
587enum {
588 UNI_WSYS_CONFIG_FW_LOG_CTRL,
589 UNI_WSYS_CONFIG_FW_DBG_CTRL,
590};
591
592enum {
593 UNI_RDD_CTRL_PARM,
594};
595
596enum {
597 UNI_TXPOWER_SHOW_INFO = 0x7,
598};
599
600enum {
601 UNI_EFUSE_ACCESS = 1,
602 UNI_EFUSE_BUFFER_MODE,
603 UNI_EFUSE_FREE_BLOCK,
604 UNI_EFUSE_BUFFER_RD,
605};
606
607enum {
608 UNI_VOW_DRR_CTRL,
609 UNI_VOW_FEATURE_CTRL,
610 UNI_VOW_BSSGROUP_CTRL_1_GROUP,
611 UNI_VOW_BSSGROUP_TOKEN_CFG,
612 UNI_VOW_BSSGROUP_CTRL_ALL_GROUP,
613 UNI_VOW_BSSGROUP_BW_GROUP_QUANTUM,
614 UNI_VOW_BSSGROUP_BW_GROUP_QUANTUM_ALL,
615 UNI_VOW_AT_PROC_EST_FEATURE,
616 UNI_VOW_AT_PROC_EST_MONITOR_PERIOD,
617 UNI_VOW_AT_PROC_EST_GROUP_RATIO,
618 UNI_VOW_AT_PROC_EST_GROUP_TO_BAND_MAPPING,
619 UNI_VOW_RX_AT_AIRTIME_EN,
620 UNI_VOW_RX_AT_MIBTIME_EN,
621 UNI_VOW_RX_AT_EARLYEND_EN,
622 UNI_VOW_RX_AT_AIRTIME_CLR_EN,
623 UNI_VOW_RX_AT_STA_WMM_CTRL,
624 UNI_VOW_RX_AT_MBSS_WMM_CTRL,
625 UNI_VOW_RX_AT_ED_OFFSET,
626 UNI_VOW_RX_AT_SW_TIMER,
627 UNI_VOW_RX_AT_BACKOFF_TIMER,
628 UNI_VOW_RX_AT_REPORT_RX_NONWIFI_TIME,
629 UNI_VOW_RX_AT_REPORT_RX_OBSS_TIME,
630 UNI_VOW_RX_AT_REPORT_MIB_OBSS_TIME,
631 UNI_VOW_RX_AT_REPORT_PER_STA_RX_TIME,
632 UNI_VOW_RED_ENABLE,
633 UNI_VOW_RED_TX_RPT,
634};
635
636enum {
637 UNI_CMD_MIB_DATA,
638};
639
640#endif