mt76: mt7915: add support for continuous tx in testmode
[linux-2.6-microblaze.git] / drivers / net / wireless / mediatek / mt76 / mt7915 / mcu.h
1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2020 MediaTek Inc. */
3
4 #ifndef __MT7915_MCU_H
5 #define __MT7915_MCU_H
6
7 struct mt7915_mcu_txd {
8         __le32 txd[8];
9
10         __le16 len;
11         __le16 pq_id;
12
13         u8 cid;
14         u8 pkt_type;
15         u8 set_query; /* FW don't care */
16         u8 seq;
17
18         u8 uc_d2b0_rev;
19         u8 ext_cid;
20         u8 s2d_index;
21         u8 ext_cid_ack;
22
23         u32 reserved[5];
24 } __packed __aligned(4);
25
26 /* event table */
27 enum {
28         MCU_EVENT_TARGET_ADDRESS_LEN = 0x01,
29         MCU_EVENT_FW_START = 0x01,
30         MCU_EVENT_GENERIC = 0x01,
31         MCU_EVENT_ACCESS_REG = 0x02,
32         MCU_EVENT_MT_PATCH_SEM = 0x04,
33         MCU_EVENT_CH_PRIVILEGE = 0x18,
34         MCU_EVENT_EXT = 0xed,
35         MCU_EVENT_RESTART_DL = 0xef,
36 };
37
38 /* ext event table */
39 enum {
40         MCU_EXT_EVENT_PS_SYNC = 0x5,
41         MCU_EXT_EVENT_FW_LOG_2_HOST = 0x13,
42         MCU_EXT_EVENT_THERMAL_PROTECT = 0x22,
43         MCU_EXT_EVENT_ASSERT_DUMP = 0x23,
44         MCU_EXT_EVENT_RDD_REPORT = 0x3a,
45         MCU_EXT_EVENT_CSA_NOTIFY = 0x4f,
46         MCU_EXT_EVENT_RATE_REPORT = 0x87,
47 };
48
49 enum {
50         MCU_ATE_SET_TRX = 0x1,
51         MCU_ATE_SET_FREQ_OFFSET = 0xa,
52         MCU_ATE_SET_SLOT_TIME = 0x13,
53         MCU_ATE_CLEAN_TXQUEUE = 0x1c,
54 };
55
56 struct mt7915_mcu_rxd {
57         __le32 rxd[6];
58
59         __le16 len;
60         __le16 pkt_type_id;
61
62         u8 eid;
63         u8 seq;
64         __le16 __rsv;
65
66         u8 ext_eid;
67         u8 __rsv1[2];
68         u8 s2d_index;
69 };
70
71 struct mt7915_mcu_rdd_report {
72         struct mt7915_mcu_rxd rxd;
73
74         u8 idx;
75         u8 long_detected;
76         u8 constant_prf_detected;
77         u8 staggered_prf_detected;
78         u8 radar_type_idx;
79         u8 periodic_pulse_num;
80         u8 long_pulse_num;
81         u8 hw_pulse_num;
82
83         u8 out_lpn;
84         u8 out_spn;
85         u8 out_crpn;
86         u8 out_crpw;
87         u8 out_crbn;
88         u8 out_stgpn;
89         u8 out_stgpw;
90
91         u8 rsv;
92
93         __le32 out_pri_const;
94         __le32 out_pri_stg[3];
95
96         struct {
97                 __le32 start;
98                 __le16 pulse_width;
99                 __le16 pulse_power;
100                 u8 mdrdy_flag;
101                 u8 rsv[3];
102         } long_pulse[32];
103
104         struct {
105                 __le32 start;
106                 __le16 pulse_width;
107                 __le16 pulse_power;
108                 u8 mdrdy_flag;
109                 u8 rsv[3];
110         } periodic_pulse[32];
111
112         struct {
113                 __le32 start;
114                 __le16 pulse_width;
115                 __le16 pulse_power;
116                 u8 sc_pass;
117                 u8 sw_reset;
118                 u8 mdrdy_flag;
119                 u8 tx_active;
120         } hw_pulse[32];
121 } __packed;
122
123 struct mt7915_mcu_eeprom {
124         u8 buffer_mode;
125         u8 format;
126         __le16 len;
127 } __packed;
128
129 struct mt7915_mcu_eeprom_info {
130         __le32 addr;
131         __le32 valid;
132         u8 data[16];
133 } __packed;
134
135 struct mt7915_mcu_ra_info {
136         struct mt7915_mcu_rxd rxd;
137
138         __le32 event_id;
139         __le16 wlan_idx;
140         __le16 ru_idx;
141         __le16 direction;
142         __le16 dump_group;
143
144         __le32 suggest_rate;
145         __le32 min_rate;        /* for dynamic sounding */
146         __le32 max_rate;        /* for dynamic sounding */
147         __le32 init_rate_down_rate;
148
149         __le16 curr_rate;
150         __le16 init_rate_down_total;
151         __le16 init_rate_down_succ;
152         __le16 success;
153         __le16 attempts;
154
155         __le16 prev_rate;
156         __le16 prob_up_rate;
157         u8 no_rate_up_cnt;
158         u8 ppdu_cnt;
159         u8 gi;
160
161         u8 try_up_fail;
162         u8 try_up_total;
163         u8 suggest_wf;
164         u8 try_up_check;
165         u8 prob_up_period;
166         u8 prob_down_pending;
167 } __packed;
168
169
170 struct mt7915_mcu_phy_rx_info {
171         u8 category;
172         u8 rate;
173         u8 mode;
174         u8 nsts;
175         u8 gi;
176         u8 coding;
177         u8 stbc;
178         u8 bw;
179 };
180
181 #define MT_RA_RATE_NSS                  GENMASK(8, 6)
182 #define MT_RA_RATE_MCS                  GENMASK(3, 0)
183 #define MT_RA_RATE_TX_MODE              GENMASK(12, 9)
184 #define MT_RA_RATE_DCM_EN               BIT(4)
185 #define MT_RA_RATE_BW                   GENMASK(14, 13)
186
187 struct edca {
188         u8 queue;
189         u8 set;
190         u8 aifs;
191         u8 cw_min;
192         __le16 cw_max;
193         __le16 txop;
194 };
195
196 struct mt7915_mcu_tx {
197         u8 total;
198         u8 action;
199         u8 valid;
200         u8 mode;
201
202         struct edca edca[IEEE80211_NUM_ACS];
203 } __packed;
204
205 #define WMM_AIFS_SET            BIT(0)
206 #define WMM_CW_MIN_SET          BIT(1)
207 #define WMM_CW_MAX_SET          BIT(2)
208 #define WMM_TXOP_SET            BIT(3)
209 #define WMM_PARAM_SET           GENMASK(3, 0)
210
211 #define MCU_PQ_ID(p, q)                 (((p) << 15) | ((q) << 10))
212 #define MCU_PKT_ID                      0xa0
213
214 enum {
215         MCU_Q_QUERY,
216         MCU_Q_SET,
217         MCU_Q_RESERVED,
218         MCU_Q_NA
219 };
220
221 enum {
222         MCU_S2D_H2N,
223         MCU_S2D_C2N,
224         MCU_S2D_H2C,
225         MCU_S2D_H2CN
226 };
227
228 enum {
229         MCU_CMD_TARGET_ADDRESS_LEN_REQ = 0x01,
230         MCU_CMD_FW_START_REQ = 0x02,
231         MCU_CMD_INIT_ACCESS_REG = 0x3,
232         MCU_CMD_NIC_POWER_CTRL = 0x4,
233         MCU_CMD_PATCH_START_REQ = 0x05,
234         MCU_CMD_PATCH_FINISH_REQ = 0x07,
235         MCU_CMD_PATCH_SEM_CONTROL = 0x10,
236         MCU_CMD_EXT_CID = 0xED,
237         MCU_CMD_FW_SCATTER = 0xEE,
238         MCU_CMD_RESTART_DL_REQ = 0xEF,
239 };
240
241 enum {
242         MCU_EXT_CMD_EFUSE_ACCESS = 0x01,
243         MCU_EXT_CMD_RF_TEST = 0x04,
244         MCU_EXT_CMD_PM_STATE_CTRL = 0x07,
245         MCU_EXT_CMD_CHANNEL_SWITCH = 0x08,
246         MCU_EXT_CMD_FW_LOG_2_HOST = 0x13,
247         MCU_EXT_CMD_TXBF_ACTION = 0x1e,
248         MCU_EXT_CMD_EFUSE_BUFFER_MODE = 0x21,
249         MCU_EXT_CMD_STA_REC_UPDATE = 0x25,
250         MCU_EXT_CMD_BSS_INFO_UPDATE = 0x26,
251         MCU_EXT_CMD_EDCA_UPDATE = 0x27,
252         MCU_EXT_CMD_DEV_INFO_UPDATE = 0x2A,
253         MCU_EXT_CMD_THERMAL_CTRL = 0x2c,
254         MCU_EXT_CMD_WTBL_UPDATE = 0x32,
255         MCU_EXT_CMD_SET_DRR_CTRL = 0x36,
256         MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
257         MCU_EXT_CMD_ATE_CTRL = 0x3d,
258         MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
259         MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,
260         MCU_EXT_CMD_RX_HDR_TRANS = 0x47,
261         MCU_EXT_CMD_MUAR_UPDATE = 0x48,
262         MCU_EXT_CMD_SET_RX_PATH = 0x4e,
263         MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58,
264         MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
265         MCU_EXT_CMD_SET_SER_TRIGGER = 0x81,
266         MCU_EXT_CMD_SCS_CTRL = 0x82,
267         MCU_EXT_CMD_RATE_CTRL = 0x87,
268         MCU_EXT_CMD_FW_DBG_CTRL = 0x95,
269         MCU_EXT_CMD_SET_RDD_TH = 0x9d,
270         MCU_EXT_CMD_SET_SPR = 0xa8,
271         MCU_EXT_CMD_PHY_STAT_INFO = 0xad,
272 };
273
274 enum {
275         PATCH_SEM_RELEASE,
276         PATCH_SEM_GET
277 };
278
279 enum {
280         PATCH_NOT_DL_SEM_FAIL,
281         PATCH_IS_DL,
282         PATCH_NOT_DL_SEM_SUCCESS,
283         PATCH_REL_SEM_SUCCESS
284 };
285
286 enum {
287         FW_STATE_INITIAL,
288         FW_STATE_FW_DOWNLOAD,
289         FW_STATE_NORMAL_OPERATION,
290         FW_STATE_NORMAL_TRX,
291         FW_STATE_WACPU_RDY        = 7
292 };
293
294 enum {
295         EE_MODE_EFUSE,
296         EE_MODE_BUFFER,
297 };
298
299 enum {
300         EE_FORMAT_BIN,
301         EE_FORMAT_WHOLE,
302         EE_FORMAT_MULTIPLE,
303 };
304
305 enum {
306         MCU_PHY_STATE_TX_RATE,
307         MCU_PHY_STATE_RX_RATE,
308         MCU_PHY_STATE_RSSI,
309         MCU_PHY_STATE_CONTENTION_RX_RATE,
310         MCU_PHY_STATE_OFDMLQ_CNINFO,
311 };
312
313 #define STA_TYPE_STA                    BIT(0)
314 #define STA_TYPE_AP                     BIT(1)
315 #define STA_TYPE_ADHOC                  BIT(2)
316 #define STA_TYPE_WDS                    BIT(4)
317 #define STA_TYPE_BC                     BIT(5)
318
319 #define NETWORK_INFRA                   BIT(16)
320 #define NETWORK_P2P                     BIT(17)
321 #define NETWORK_IBSS                    BIT(18)
322 #define NETWORK_WDS                     BIT(21)
323
324 #define CONNECTION_INFRA_STA            (STA_TYPE_STA | NETWORK_INFRA)
325 #define CONNECTION_INFRA_AP             (STA_TYPE_AP | NETWORK_INFRA)
326 #define CONNECTION_P2P_GC               (STA_TYPE_STA | NETWORK_P2P)
327 #define CONNECTION_P2P_GO               (STA_TYPE_AP | NETWORK_P2P)
328 #define CONNECTION_IBSS_ADHOC           (STA_TYPE_ADHOC | NETWORK_IBSS)
329 #define CONNECTION_WDS                  (STA_TYPE_WDS | NETWORK_WDS)
330 #define CONNECTION_INFRA_BC             (STA_TYPE_BC | NETWORK_INFRA)
331
332 #define CONN_STATE_DISCONNECT           0
333 #define CONN_STATE_CONNECT              1
334 #define CONN_STATE_PORT_SECURE          2
335
336 enum {
337         DEV_INFO_ACTIVE,
338         DEV_INFO_MAX_NUM
339 };
340
341 enum {
342         SCS_SEND_DATA,
343         SCS_SET_MANUAL_PD_TH,
344         SCS_CONFIG,
345         SCS_ENABLE,
346         SCS_SHOW_INFO,
347         SCS_GET_GLO_ADDR,
348         SCS_GET_GLO_ADDR_EVENT,
349 };
350
351 enum {
352         CMD_CBW_20MHZ = IEEE80211_STA_RX_BW_20,
353         CMD_CBW_40MHZ = IEEE80211_STA_RX_BW_40,
354         CMD_CBW_80MHZ = IEEE80211_STA_RX_BW_80,
355         CMD_CBW_160MHZ = IEEE80211_STA_RX_BW_160,
356         CMD_CBW_10MHZ,
357         CMD_CBW_5MHZ,
358         CMD_CBW_8080MHZ,
359
360         CMD_HE_MCS_BW80 = 0,
361         CMD_HE_MCS_BW160,
362         CMD_HE_MCS_BW8080,
363         CMD_HE_MCS_BW_NUM
364 };
365
366 struct tlv {
367         __le16 tag;
368         __le16 len;
369 } __packed;
370
371 struct bss_info_omac {
372         __le16 tag;
373         __le16 len;
374         u8 hw_bss_idx;
375         u8 omac_idx;
376         u8 band_idx;
377         u8 rsv0;
378         __le32 conn_type;
379         u32 rsv1;
380 } __packed;
381
382 struct bss_info_basic {
383         __le16 tag;
384         __le16 len;
385         __le32 network_type;
386         u8 active;
387         u8 rsv0;
388         __le16 bcn_interval;
389         u8 bssid[ETH_ALEN];
390         u8 wmm_idx;
391         u8 dtim_period;
392         u8 bmc_wcid_lo;
393         u8 cipher;
394         u8 phy_mode;
395         u8 max_bssid;   /* max BSSID. range: 1 ~ 8, 0: MBSSID disabled */
396         u8 non_tx_bssid;/* non-transmitted BSSID, 0: transmitted BSSID */
397         u8 bmc_wcid_hi; /* high Byte and version */
398         u8 rsv[2];
399 } __packed;
400
401 struct bss_info_rf_ch {
402         __le16 tag;
403         __le16 len;
404         u8 pri_ch;
405         u8 center_ch0;
406         u8 center_ch1;
407         u8 bw;
408         u8 he_ru26_block;       /* 1: don't send HETB in RU26, 0: allow */
409         u8 he_all_disable;      /* 1: disallow all HETB, 0: allow */
410         u8 rsv[2];
411 } __packed;
412
413 struct bss_info_ext_bss {
414         __le16 tag;
415         __le16 len;
416         __le32 mbss_tsf_offset; /* in unit of us */
417         u8 rsv[8];
418 } __packed;
419
420 struct bss_info_bmc_rate {
421         __le16 tag;
422         __le16 len;
423         __le16 bc_trans;
424         __le16 mc_trans;
425         u8 short_preamble;
426         u8 rsv[7];
427 } __packed;
428
429 struct bss_info_ra {
430         __le16 tag;
431         __le16 len;
432         u8 op_mode;
433         u8 adhoc_en;
434         u8 short_preamble;
435         u8 tx_streams;
436         u8 rx_streams;
437         u8 algo;
438         u8 force_sgi;
439         u8 force_gf;
440         u8 ht_mode;
441         u8 has_20_sta;          /* Check if any sta support GF. */
442         u8 bss_width_trigger_events;
443         u8 vht_nss_cap;
444         u8 vht_bw_signal;       /* not use */
445         u8 vht_force_sgi;       /* not use */
446         u8 se_off;
447         u8 antenna_idx;
448         u8 train_up_rule;
449         u8 rsv[3];
450         unsigned short train_up_high_thres;
451         short train_up_rule_rssi;
452         unsigned short low_traffic_thres;
453         __le16 max_phyrate;
454         __le32 phy_cap;
455         __le32 interval;
456         __le32 fast_interval;
457 } __packed;
458
459 struct bss_info_hw_amsdu {
460         __le16 tag;
461         __le16 len;
462         __le32 cmp_bitmap_0;
463         __le32 cmp_bitmap_1;
464         __le16 trig_thres;
465         u8 enable;
466         u8 rsv;
467 } __packed;
468
469 struct bss_info_he {
470         __le16 tag;
471         __le16 len;
472         u8 he_pe_duration;
473         u8 vht_op_info_present;
474         __le16 he_rts_thres;
475         __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM];
476         u8 rsv[6];
477 } __packed;
478
479 struct bss_info_bcn {
480         __le16 tag;
481         __le16 len;
482         u8 ver;
483         u8 enable;
484         __le16 sub_ntlv;
485 } __packed __aligned(4);
486
487 struct bss_info_bcn_csa {
488         __le16 tag;
489         __le16 len;
490         u8 cnt;
491         u8 rsv[3];
492 } __packed __aligned(4);
493
494 struct bss_info_bcn_bcc {
495         __le16 tag;
496         __le16 len;
497         u8 cnt;
498         u8 rsv[3];
499 } __packed __aligned(4);
500
501 struct bss_info_bcn_mbss {
502 #define MAX_BEACON_NUM  32
503         __le16 tag;
504         __le16 len;
505         __le32 bitmap;
506         __le16 offset[MAX_BEACON_NUM];
507         u8 rsv[8];
508 } __packed __aligned(4);
509
510 struct bss_info_bcn_cont {
511         __le16 tag;
512         __le16 len;
513         __le16 tim_ofs;
514         __le16 csa_ofs;
515         __le16 bcc_ofs;
516         __le16 pkt_len;
517 } __packed __aligned(4);
518
519 enum {
520         BSS_INFO_BCN_CSA,
521         BSS_INFO_BCN_BCC,
522         BSS_INFO_BCN_MBSSID,
523         BSS_INFO_BCN_CONTENT,
524         BSS_INFO_BCN_MAX
525 };
526
527 enum {
528         BSS_INFO_OMAC,
529         BSS_INFO_BASIC,
530         BSS_INFO_RF_CH,         /* optional, for BT/LTE coex */
531         BSS_INFO_PM,            /* sta only */
532         BSS_INFO_UAPSD,         /* sta only */
533         BSS_INFO_ROAM_DETECT,   /* obsoleted */
534         BSS_INFO_LQ_RM,         /* obsoleted */
535         BSS_INFO_EXT_BSS,
536         BSS_INFO_BMC_RATE,      /* for bmc rate control in CR4 */
537         BSS_INFO_SYNC_MODE,     /* obsoleted */
538         BSS_INFO_RA,
539         BSS_INFO_HW_AMSDU,
540         BSS_INFO_BSS_COLOR,
541         BSS_INFO_HE_BASIC,
542         BSS_INFO_PROTECT_INFO,
543         BSS_INFO_OFFLOAD,
544         BSS_INFO_11V_MBSSID,
545         BSS_INFO_MAX_NUM
546 };
547
548 enum {
549         WTBL_RESET_AND_SET = 1,
550         WTBL_SET,
551         WTBL_QUERY,
552         WTBL_RESET_ALL
553 };
554
555 struct wtbl_req_hdr {
556         u8 wlan_idx_lo;
557         u8 operation;
558         __le16 tlv_num;
559         u8 wlan_idx_hi;
560         u8 rsv[3];
561 } __packed;
562
563 struct wtbl_generic {
564         __le16 tag;
565         __le16 len;
566         u8 peer_addr[ETH_ALEN];
567         u8 muar_idx;
568         u8 skip_tx;
569         u8 cf_ack;
570         u8 qos;
571         u8 mesh;
572         u8 adm;
573         __le16 partial_aid;
574         u8 baf_en;
575         u8 aad_om;
576 } __packed;
577
578 struct wtbl_rx {
579         __le16 tag;
580         __le16 len;
581         u8 rcid;
582         u8 rca1;
583         u8 rca2;
584         u8 rv;
585         u8 rsv[4];
586 } __packed;
587
588 struct wtbl_ht {
589         __le16 tag;
590         __le16 len;
591         u8 ht;
592         u8 ldpc;
593         u8 af;
594         u8 mm;
595         u8 rsv[4];
596 } __packed;
597
598 struct wtbl_vht {
599         __le16 tag;
600         __le16 len;
601         u8 ldpc;
602         u8 dyn_bw;
603         u8 vht;
604         u8 txop_ps;
605         u8 rsv[4];
606 } __packed;
607
608 struct wtbl_hdr_trans {
609         __le16 tag;
610         __le16 len;
611         u8 to_ds;
612         u8 from_ds;
613         u8 no_rx_trans;
614         u8 _rsv;
615 };
616
617 enum {
618         MT_BA_TYPE_INVALID,
619         MT_BA_TYPE_ORIGINATOR,
620         MT_BA_TYPE_RECIPIENT
621 };
622
623 enum {
624         RST_BA_MAC_TID_MATCH,
625         RST_BA_MAC_MATCH,
626         RST_BA_NO_MATCH
627 };
628
629 struct wtbl_ba {
630         __le16 tag;
631         __le16 len;
632         /* common */
633         u8 tid;
634         u8 ba_type;
635         u8 rsv0[2];
636         /* originator only */
637         __le16 sn;
638         u8 ba_en;
639         u8 ba_winsize_idx;
640         __le16 ba_winsize;
641         /* recipient only */
642         u8 peer_addr[ETH_ALEN];
643         u8 rst_ba_tid;
644         u8 rst_ba_sel;
645         u8 rst_ba_sb;
646         u8 band_idx;
647         u8 rsv1[4];
648 } __packed;
649
650 struct wtbl_smps {
651         __le16 tag;
652         __le16 len;
653         u8 smps;
654         u8 rsv[3];
655 } __packed;
656
657 enum {
658         WTBL_GENERIC,
659         WTBL_RX,
660         WTBL_HT,
661         WTBL_VHT,
662         WTBL_PEER_PS,           /* not used */
663         WTBL_TX_PS,
664         WTBL_HDR_TRANS,
665         WTBL_SEC_KEY,
666         WTBL_BA,
667         WTBL_RDG,               /* obsoleted */
668         WTBL_PROTECT,           /* not used */
669         WTBL_CLEAR,             /* not used */
670         WTBL_BF,
671         WTBL_SMPS,
672         WTBL_RAW_DATA,          /* debug only */
673         WTBL_PN,
674         WTBL_SPE,
675         WTBL_MAX_NUM
676 };
677
678 struct sta_ntlv_hdr {
679         u8 rsv[2];
680         __le16 tlv_num;
681 } __packed;
682
683 struct sta_req_hdr {
684         u8 bss_idx;
685         u8 wlan_idx_lo;
686         __le16 tlv_num;
687         u8 is_tlv_append;
688         u8 muar_idx;
689         u8 wlan_idx_hi;
690         u8 rsv;
691 } __packed;
692
693 struct sta_rec_basic {
694         __le16 tag;
695         __le16 len;
696         __le32 conn_type;
697         u8 conn_state;
698         u8 qos;
699         __le16 aid;
700         u8 peer_addr[ETH_ALEN];
701         __le16 extra_info;
702 } __packed;
703
704 struct sta_rec_ht {
705         __le16 tag;
706         __le16 len;
707         __le16 ht_cap;
708         u16 rsv;
709 } __packed;
710
711 struct sta_rec_vht {
712         __le16 tag;
713         __le16 len;
714         __le32 vht_cap;
715         __le16 vht_rx_mcs_map;
716         __le16 vht_tx_mcs_map;
717         u8 rts_bw_sig;
718         u8 rsv[3];
719 } __packed;
720
721 struct sta_rec_uapsd {
722         __le16 tag;
723         __le16 len;
724         u8 dac_map;
725         u8 tac_map;
726         u8 max_sp;
727         u8 rsv0;
728         __le16 listen_interval;
729         u8 rsv1[2];
730 } __packed;
731
732 struct sta_rec_muru {
733         __le16 tag;
734         __le16 len;
735
736         struct {
737                 bool ofdma_dl_en;
738                 bool ofdma_ul_en;
739                 bool mimo_dl_en;
740                 bool mimo_ul_en;
741                 u8 rsv[4];
742         } cfg;
743
744         struct {
745                 u8 punc_pream_rx;
746                 bool he_20m_in_40m_2g;
747                 bool he_20m_in_160m;
748                 bool he_80m_in_160m;
749                 bool lt16_sigb;
750                 bool rx_su_comp_sigb;
751                 bool rx_su_non_comp_sigb;
752                 u8 rsv;
753         } ofdma_dl;
754
755         struct {
756                 u8 t_frame_dur;
757                 u8 mu_cascading;
758                 u8 uo_ra;
759                 u8 he_2x996_tone;
760                 u8 rx_t_frame_11ac;
761                 u8 rsv[3];
762         } ofdma_ul;
763
764         struct {
765                 bool vht_mu_bfee;
766                 bool partial_bw_dl_mimo;
767                 u8 rsv[2];
768         } mimo_dl;
769
770         struct {
771                 bool full_ul_mimo;
772                 bool partial_ul_mimo;
773                 u8 rsv[2];
774         } mimo_ul;
775 } __packed;
776
777 struct sta_rec_he {
778         __le16 tag;
779         __le16 len;
780
781         __le32 he_cap;
782
783         u8 t_frame_dur;
784         u8 max_ampdu_exp;
785         u8 bw_set;
786         u8 device_class;
787         u8 dcm_tx_mode;
788         u8 dcm_tx_max_nss;
789         u8 dcm_rx_mode;
790         u8 dcm_rx_max_nss;
791         u8 dcm_max_ru;
792         u8 punc_pream_rx;
793         u8 pkt_ext;
794         u8 rsv1;
795
796         __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM];
797
798         u8 rsv2[2];
799 } __packed;
800
801 struct sta_rec_ba {
802         __le16 tag;
803         __le16 len;
804         u8 tid;
805         u8 ba_type;
806         u8 amsdu;
807         u8 ba_en;
808         __le16 ssn;
809         __le16 winsize;
810 } __packed;
811
812 struct sta_rec_amsdu {
813         __le16 tag;
814         __le16 len;
815         u8 max_amsdu_num;
816         u8 max_mpdu_size;
817         u8 amsdu_en;
818         u8 rsv;
819 } __packed;
820
821 struct sec_key {
822         u8 cipher_id;
823         u8 cipher_len;
824         u8 key_id;
825         u8 key_len;
826         u8 key[32];
827 } __packed;
828
829 struct sta_rec_sec {
830         __le16 tag;
831         __le16 len;
832         u8 add;
833         u8 n_cipher;
834         u8 rsv[2];
835
836         struct sec_key key[2];
837 } __packed;
838
839 struct ra_phy {
840         u8 type;
841         u8 flag;
842         u8 stbc;
843         u8 sgi;
844         u8 bw;
845         u8 ldpc;
846         u8 mcs;
847         u8 nss;
848         u8 he_ltf;
849 };
850
851 struct sta_rec_ra {
852         __le16 tag;
853         __le16 len;
854
855         u8 valid;
856         u8 auto_rate;
857         u8 phy_mode;
858         u8 channel;
859         u8 bw;
860         u8 disable_cck;
861         u8 ht_mcs32;
862         u8 ht_gf;
863         u8 ht_mcs[4];
864         u8 mmps_mode;
865         u8 gband_256;
866         u8 af;
867         u8 auth_wapi_mode;
868         u8 rate_len;
869
870         u8 supp_mode;
871         u8 supp_cck_rate;
872         u8 supp_ofdm_rate;
873         __le32 supp_ht_mcs;
874         __le16 supp_vht_mcs[4];
875
876         u8 op_mode;
877         u8 op_vht_chan_width;
878         u8 op_vht_rx_nss;
879         u8 op_vht_rx_nss_type;
880
881         __le32 sta_status;
882
883         struct ra_phy phy;
884 } __packed;
885
886 struct sta_rec_ra_fixed {
887         __le16 tag;
888         __le16 len;
889
890         __le32 field;
891         u8 op_mode;
892         u8 op_vht_chan_width;
893         u8 op_vht_rx_nss;
894         u8 op_vht_rx_nss_type;
895
896         struct ra_phy phy;
897
898         u8 spe_en;
899         u8 short_preamble;
900         u8 is_5g;
901         u8 mmps_mode;
902 } __packed;
903
904 #define RATE_PARAM_FIXED                3
905 #define RATE_PARAM_AUTO                 20
906 #define RATE_CFG_MCS                    GENMASK(3, 0)
907 #define RATE_CFG_NSS                    GENMASK(7, 4)
908 #define RATE_CFG_GI                     GENMASK(11, 8)
909 #define RATE_CFG_BW                     GENMASK(15, 12)
910 #define RATE_CFG_STBC                   GENMASK(19, 16)
911 #define RATE_CFG_LDPC                   GENMASK(23, 20)
912 #define RATE_CFG_PHY_TYPE               GENMASK(27, 24)
913
914 struct sta_rec_bf {
915         __le16 tag;
916         __le16 len;
917
918         __le16 pfmu;            /* 0xffff: no access right for PFMU */
919         bool su_mu;             /* 0: SU, 1: MU */
920         u8 bf_cap;              /* 0: iBF, 1: eBF */
921         u8 sounding_phy;        /* 0: legacy, 1: OFDM, 2: HT, 4: VHT */
922         u8 ndpa_rate;
923         u8 ndp_rate;
924         u8 rept_poll_rate;
925         u8 tx_mode;             /* 0: legacy, 1: OFDM, 2: HT, 4: VHT ... */
926         u8 nc;
927         u8 nr;
928         u8 bw;                  /* 0: 20M, 1: 40M, 2: 80M, 3: 160M */
929
930         u8 mem_total;
931         u8 mem_20m;
932         struct {
933                 u8 row;
934                 u8 col: 6, row_msb: 2;
935         } mem[4];
936
937         __le16 smart_ant;
938         u8 se_idx;
939         u8 auto_sounding;       /* b7: low traffic indicator
940                                  * b6: Stop sounding for this entry
941                                  * b5 ~ b0: postpone sounding
942                                  */
943         u8 ibf_timeout;
944         u8 ibf_dbw;
945         u8 ibf_ncol;
946         u8 ibf_nrow;
947         u8 nr_bw160;
948         u8 nc_bw160;
949         u8 ru_start_idx;
950         u8 ru_end_idx;
951
952         bool trigger_su;
953         bool trigger_mu;
954         bool ng16_su;
955         bool ng16_mu;
956         bool codebook42_su;
957         bool codebook75_mu;
958
959         u8 he_ltf;
960         u8 rsv[2];
961 } __packed;
962
963 struct sta_rec_bfee {
964         __le16 tag;
965         __le16 len;
966         bool fb_identity_matrix;        /* 1: feedback identity matrix */
967         bool ignore_feedback;           /* 1: ignore */
968         u8 rsv[2];
969 } __packed;
970
971 enum {
972         STA_REC_BASIC,
973         STA_REC_RA,
974         STA_REC_RA_CMM_INFO,
975         STA_REC_RA_UPDATE,
976         STA_REC_BF,
977         STA_REC_AMSDU,
978         STA_REC_BA,
979         STA_REC_RED,            /* not used */
980         STA_REC_TX_PROC,        /* for hdr trans and CSO in CR4 */
981         STA_REC_HT,
982         STA_REC_VHT,
983         STA_REC_APPS,
984         STA_REC_KEY,
985         STA_REC_WTBL,
986         STA_REC_HE,
987         STA_REC_HW_AMSDU,
988         STA_REC_WTBL_AADOM,
989         STA_REC_KEY_V2,
990         STA_REC_MURU,
991         STA_REC_MUEDCA,
992         STA_REC_BFEE,
993         STA_REC_MAX_NUM
994 };
995
996 enum mt7915_cipher_type {
997         MT_CIPHER_NONE,
998         MT_CIPHER_WEP40,
999         MT_CIPHER_WEP104,
1000         MT_CIPHER_WEP128,
1001         MT_CIPHER_TKIP,
1002         MT_CIPHER_AES_CCMP,
1003         MT_CIPHER_CCMP_256,
1004         MT_CIPHER_GCMP,
1005         MT_CIPHER_GCMP_256,
1006         MT_CIPHER_WAPI,
1007         MT_CIPHER_BIP_CMAC_128,
1008 };
1009
1010 enum {
1011         CH_SWITCH_NORMAL = 0,
1012         CH_SWITCH_SCAN = 3,
1013         CH_SWITCH_MCC = 4,
1014         CH_SWITCH_DFS = 5,
1015         CH_SWITCH_BACKGROUND_SCAN_START = 6,
1016         CH_SWITCH_BACKGROUND_SCAN_RUNNING = 7,
1017         CH_SWITCH_BACKGROUND_SCAN_STOP = 8,
1018         CH_SWITCH_SCAN_BYPASS_DPD = 9
1019 };
1020
1021 enum {
1022         THERMAL_SENSOR_TEMP_QUERY,
1023         THERMAL_SENSOR_MANUAL_CTRL,
1024         THERMAL_SENSOR_INFO_QUERY,
1025         THERMAL_SENSOR_TASK_CTRL,
1026 };
1027
1028 enum {
1029         MT_EBF = BIT(0),        /* explicit beamforming */
1030         MT_IBF = BIT(1)         /* implicit beamforming */
1031 };
1032
1033 #define MT7915_WTBL_UPDATE_MAX_SIZE     (sizeof(struct wtbl_req_hdr) +  \
1034                                          sizeof(struct wtbl_generic) +  \
1035                                          sizeof(struct wtbl_rx) +       \
1036                                          sizeof(struct wtbl_ht) +       \
1037                                          sizeof(struct wtbl_vht) +      \
1038                                          sizeof(struct wtbl_hdr_trans) +\
1039                                          sizeof(struct wtbl_ba) +       \
1040                                          sizeof(struct wtbl_smps))
1041
1042 #define MT7915_STA_UPDATE_MAX_SIZE      (sizeof(struct sta_req_hdr) +   \
1043                                          sizeof(struct sta_rec_basic) + \
1044                                          sizeof(struct sta_rec_ht) +    \
1045                                          sizeof(struct sta_rec_he) +    \
1046                                          sizeof(struct sta_rec_ba) +    \
1047                                          sizeof(struct sta_rec_vht) +   \
1048                                          sizeof(struct sta_rec_uapsd) + \
1049                                          sizeof(struct sta_rec_amsdu) + \
1050                                          sizeof(struct tlv) +           \
1051                                          MT7915_WTBL_UPDATE_MAX_SIZE)
1052
1053 #define MT7915_WTBL_UPDATE_BA_SIZE      (sizeof(struct wtbl_req_hdr) +  \
1054                                          sizeof(struct wtbl_ba))
1055
1056 #define MT7915_BSS_UPDATE_MAX_SIZE      (sizeof(struct sta_req_hdr) +   \
1057                                          sizeof(struct bss_info_omac) + \
1058                                          sizeof(struct bss_info_basic) +\
1059                                          sizeof(struct bss_info_rf_ch) +\
1060                                          sizeof(struct bss_info_ra) +   \
1061                                          sizeof(struct bss_info_hw_amsdu) +\
1062                                          sizeof(struct bss_info_he) +   \
1063                                          sizeof(struct bss_info_bmc_rate) +\
1064                                          sizeof(struct bss_info_ext_bss))
1065
1066 #define MT7915_BEACON_UPDATE_SIZE       (sizeof(struct sta_req_hdr) +   \
1067                                          sizeof(struct bss_info_bcn_csa) + \
1068                                          sizeof(struct bss_info_bcn_bcc) + \
1069                                          sizeof(struct bss_info_bcn_mbss) + \
1070                                          sizeof(struct bss_info_bcn_cont))
1071
1072 #define PHY_MODE_A                      BIT(0)
1073 #define PHY_MODE_B                      BIT(1)
1074 #define PHY_MODE_G                      BIT(2)
1075 #define PHY_MODE_GN                     BIT(3)
1076 #define PHY_MODE_AN                     BIT(4)
1077 #define PHY_MODE_AC                     BIT(5)
1078 #define PHY_MODE_AX_24G                 BIT(6)
1079 #define PHY_MODE_AX_5G                  BIT(7)
1080 #define PHY_MODE_AX_6G                  BIT(8)
1081
1082 #define MODE_CCK                        BIT(0)
1083 #define MODE_OFDM                       BIT(1)
1084 #define MODE_HT                         BIT(2)
1085 #define MODE_VHT                        BIT(3)
1086 #define MODE_HE                         BIT(4)
1087
1088 #define STA_CAP_WMM                     BIT(0)
1089 #define STA_CAP_SGI_20                  BIT(4)
1090 #define STA_CAP_SGI_40                  BIT(5)
1091 #define STA_CAP_TX_STBC                 BIT(6)
1092 #define STA_CAP_RX_STBC                 BIT(7)
1093 #define STA_CAP_VHT_SGI_80              BIT(16)
1094 #define STA_CAP_VHT_SGI_160             BIT(17)
1095 #define STA_CAP_VHT_TX_STBC             BIT(18)
1096 #define STA_CAP_VHT_RX_STBC             BIT(19)
1097 #define STA_CAP_VHT_LDPC                BIT(23)
1098 #define STA_CAP_LDPC                    BIT(24)
1099 #define STA_CAP_HT                      BIT(26)
1100 #define STA_CAP_VHT                     BIT(27)
1101 #define STA_CAP_HE                      BIT(28)
1102
1103 /* HE MAC */
1104 #define STA_REC_HE_CAP_HTC                      BIT(0)
1105 #define STA_REC_HE_CAP_BQR                      BIT(1)
1106 #define STA_REC_HE_CAP_BSR                      BIT(2)
1107 #define STA_REC_HE_CAP_OM                       BIT(3)
1108 #define STA_REC_HE_CAP_AMSDU_IN_AMPDU           BIT(4)
1109 /* HE PHY */
1110 #define STA_REC_HE_CAP_DUAL_BAND                BIT(5)
1111 #define STA_REC_HE_CAP_LDPC                     BIT(6)
1112 #define STA_REC_HE_CAP_TRIG_CQI_FK              BIT(7)
1113 #define STA_REC_HE_CAP_PARTIAL_BW_EXT_RANGE     BIT(8)
1114 /* STBC */
1115 #define STA_REC_HE_CAP_LE_EQ_80M_TX_STBC        BIT(9)
1116 #define STA_REC_HE_CAP_LE_EQ_80M_RX_STBC        BIT(10)
1117 #define STA_REC_HE_CAP_GT_80M_TX_STBC           BIT(11)
1118 #define STA_REC_HE_CAP_GT_80M_RX_STBC           BIT(12)
1119 /* GI */
1120 #define STA_REC_HE_CAP_SU_PPDU_1LTF_8US_GI      BIT(13)
1121 #define STA_REC_HE_CAP_SU_MU_PPDU_4LTF_8US_GI   BIT(14)
1122 #define STA_REC_HE_CAP_ER_SU_PPDU_1LTF_8US_GI   BIT(15)
1123 #define STA_REC_HE_CAP_ER_SU_PPDU_4LTF_8US_GI   BIT(16)
1124 #define STA_REC_HE_CAP_NDP_4LTF_3DOT2MS_GI      BIT(17)
1125 /* 242 TONE */
1126 #define STA_REC_HE_CAP_BW20_RU242_SUPPORT       BIT(18)
1127 #define STA_REC_HE_CAP_TX_1024QAM_UNDER_RU242   BIT(19)
1128 #define STA_REC_HE_CAP_RX_1024QAM_UNDER_RU242   BIT(20)
1129
1130 #endif