1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2020 MediaTek Inc. */
7 struct mt7915_mcu_txd
{
15 u8 set_query
; /* FW don't care */
24 } __packed
__aligned(4);
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,
35 MCU_EVENT_RESTART_DL
= 0xef,
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,
50 MCU_ATE_SET_TRX
= 0x1,
51 MCU_ATE_SET_FREQ_OFFSET
= 0xa,
54 struct mt7915_mcu_rxd
{
69 struct mt7915_mcu_rdd_report
{
70 struct mt7915_mcu_rxd rxd
;
74 u8 constant_prf_detected
;
75 u8 staggered_prf_detected
;
77 u8 periodic_pulse_num
;
92 __le32 out_pri_stg
[3];
108 } periodic_pulse
[32];
121 struct mt7915_mcu_eeprom_info
{
127 struct mt7915_mcu_ra_info
{
128 struct mt7915_mcu_rxd rxd
;
137 __le32 min_rate
; /* for dynamic sounding */
138 __le32 max_rate
; /* for dynamic sounding */
139 __le32 init_rate_down_rate
;
142 __le16 init_rate_down_total
;
143 __le16 init_rate_down_succ
;
158 u8 prob_down_pending
;
162 struct mt7915_mcu_phy_rx_info
{
173 #define MT_RA_RATE_NSS GENMASK(8, 6)
174 #define MT_RA_RATE_MCS GENMASK(3, 0)
175 #define MT_RA_RATE_TX_MODE GENMASK(12, 9)
176 #define MT_RA_RATE_DCM_EN BIT(4)
177 #define MT_RA_RATE_BW GENMASK(14, 13)
179 #define MCU_PQ_ID(p, q) (((p) << 15) | ((q) << 10))
180 #define MCU_PKT_ID 0xa0
197 MCU_CMD_TARGET_ADDRESS_LEN_REQ
= 0x01,
198 MCU_CMD_FW_START_REQ
= 0x02,
199 MCU_CMD_INIT_ACCESS_REG
= 0x3,
200 MCU_CMD_NIC_POWER_CTRL
= 0x4,
201 MCU_CMD_PATCH_START_REQ
= 0x05,
202 MCU_CMD_PATCH_FINISH_REQ
= 0x07,
203 MCU_CMD_PATCH_SEM_CONTROL
= 0x10,
204 MCU_CMD_EXT_CID
= 0xED,
205 MCU_CMD_FW_SCATTER
= 0xEE,
206 MCU_CMD_RESTART_DL_REQ
= 0xEF,
210 MCU_EXT_CMD_EFUSE_ACCESS
= 0x01,
211 MCU_EXT_CMD_PM_STATE_CTRL
= 0x07,
212 MCU_EXT_CMD_CHANNEL_SWITCH
= 0x08,
213 MCU_EXT_CMD_FW_LOG_2_HOST
= 0x13,
214 MCU_EXT_CMD_TXBF_ACTION
= 0x1e,
215 MCU_EXT_CMD_EFUSE_BUFFER_MODE
= 0x21,
216 MCU_EXT_CMD_STA_REC_UPDATE
= 0x25,
217 MCU_EXT_CMD_BSS_INFO_UPDATE
= 0x26,
218 MCU_EXT_CMD_EDCA_UPDATE
= 0x27,
219 MCU_EXT_CMD_DEV_INFO_UPDATE
= 0x2A,
220 MCU_EXT_CMD_THERMAL_CTRL
= 0x2c,
221 MCU_EXT_CMD_WTBL_UPDATE
= 0x32,
222 MCU_EXT_CMD_SET_DRR_CTRL
= 0x36,
223 MCU_EXT_CMD_SET_RDD_CTRL
= 0x3a,
224 MCU_EXT_CMD_ATE_CTRL
= 0x3d,
225 MCU_EXT_CMD_PROTECT_CTRL
= 0x3e,
226 MCU_EXT_CMD_MAC_INIT_CTRL
= 0x46,
227 MCU_EXT_CMD_RX_HDR_TRANS
= 0x47,
228 MCU_EXT_CMD_MUAR_UPDATE
= 0x48,
229 MCU_EXT_CMD_SET_RX_PATH
= 0x4e,
230 MCU_EXT_CMD_TX_POWER_FEATURE_CTRL
= 0x58,
231 MCU_EXT_CMD_MWDS_SUPPORT
= 0x80,
232 MCU_EXT_CMD_SET_SER_TRIGGER
= 0x81,
233 MCU_EXT_CMD_SCS_CTRL
= 0x82,
234 MCU_EXT_CMD_RATE_CTRL
= 0x87,
235 MCU_EXT_CMD_FW_DBG_CTRL
= 0x95,
236 MCU_EXT_CMD_SET_RDD_TH
= 0x9d,
237 MCU_EXT_CMD_SET_SPR
= 0xa8,
238 MCU_EXT_CMD_PHY_STAT_INFO
= 0xad,
247 PATCH_NOT_DL_SEM_FAIL
,
249 PATCH_NOT_DL_SEM_SUCCESS
,
250 PATCH_REL_SEM_SUCCESS
255 FW_STATE_FW_DOWNLOAD
,
256 FW_STATE_NORMAL_OPERATION
,
258 FW_STATE_WACPU_RDY
= 7
273 MCU_PHY_STATE_TX_RATE
,
274 MCU_PHY_STATE_RX_RATE
,
276 MCU_PHY_STATE_CONTENTION_RX_RATE
,
277 MCU_PHY_STATE_OFDMLQ_CNINFO
,
280 #define STA_TYPE_STA BIT(0)
281 #define STA_TYPE_AP BIT(1)
282 #define STA_TYPE_ADHOC BIT(2)
283 #define STA_TYPE_WDS BIT(4)
284 #define STA_TYPE_BC BIT(5)
286 #define NETWORK_INFRA BIT(16)
287 #define NETWORK_P2P BIT(17)
288 #define NETWORK_IBSS BIT(18)
289 #define NETWORK_WDS BIT(21)
291 #define CONNECTION_INFRA_STA (STA_TYPE_STA | NETWORK_INFRA)
292 #define CONNECTION_INFRA_AP (STA_TYPE_AP | NETWORK_INFRA)
293 #define CONNECTION_P2P_GC (STA_TYPE_STA | NETWORK_P2P)
294 #define CONNECTION_P2P_GO (STA_TYPE_AP | NETWORK_P2P)
295 #define CONNECTION_IBSS_ADHOC (STA_TYPE_ADHOC | NETWORK_IBSS)
296 #define CONNECTION_WDS (STA_TYPE_WDS | NETWORK_WDS)
297 #define CONNECTION_INFRA_BC (STA_TYPE_BC | NETWORK_INFRA)
299 #define CONN_STATE_DISCONNECT 0
300 #define CONN_STATE_CONNECT 1
301 #define CONN_STATE_PORT_SECURE 2
310 SCS_SET_MANUAL_PD_TH
,
315 SCS_GET_GLO_ADDR_EVENT
,
319 CMD_CBW_20MHZ
= IEEE80211_STA_RX_BW_20
,
320 CMD_CBW_40MHZ
= IEEE80211_STA_RX_BW_40
,
321 CMD_CBW_80MHZ
= IEEE80211_STA_RX_BW_80
,
322 CMD_CBW_160MHZ
= IEEE80211_STA_RX_BW_160
,
338 struct bss_info_omac
{
349 struct bss_info_basic
{
362 u8 max_bssid
; /* max BSSID. range: 1 ~ 8, 0: MBSSID disabled */
363 u8 non_tx_bssid
;/* non-transmitted BSSID, 0: transmitted BSSID */
364 u8 bmc_wcid_hi
; /* high Byte and version */
368 struct bss_info_rf_ch
{
375 u8 he_ru26_block
; /* 1: don't send HETB in RU26, 0: allow */
376 u8 he_all_disable
; /* 1: disallow all HETB, 0: allow */
380 struct bss_info_ext_bss
{
383 __le32 mbss_tsf_offset
; /* in unit of us */
387 struct bss_info_bmc_rate
{
408 u8 has_20_sta
; /* Check if any sta support GF. */
409 u8 bss_width_trigger_events
;
411 u8 vht_bw_signal
; /* not use */
412 u8 vht_force_sgi
; /* not use */
417 unsigned short train_up_high_thres
;
418 short train_up_rule_rssi
;
419 unsigned short low_traffic_thres
;
423 __le32 fast_interval
;
426 struct bss_info_hw_amsdu
{
440 u8 vht_op_info_present
;
442 __le16 max_nss_mcs
[CMD_HE_MCS_BW_NUM
];
446 struct bss_info_bcn
{
452 } __packed
__aligned(4);
454 struct bss_info_bcn_csa
{
459 } __packed
__aligned(4);
461 struct bss_info_bcn_bcc
{
466 } __packed
__aligned(4);
468 struct bss_info_bcn_mbss
{
469 #define MAX_BEACON_NUM 32
473 __le16 offset
[MAX_BEACON_NUM
];
475 } __packed
__aligned(4);
477 struct bss_info_bcn_cont
{
484 } __packed
__aligned(4);
490 BSS_INFO_BCN_CONTENT
,
497 BSS_INFO_RF_CH
, /* optional, for BT/LTE coex */
498 BSS_INFO_PM
, /* sta only */
499 BSS_INFO_UAPSD
, /* sta only */
500 BSS_INFO_ROAM_DETECT
, /* obsoleted */
501 BSS_INFO_LQ_RM
, /* obsoleted */
503 BSS_INFO_BMC_RATE
, /* for bmc rate control in CR4 */
504 BSS_INFO_SYNC_MODE
, /* obsoleted */
509 BSS_INFO_PROTECT_INFO
,
516 WTBL_RESET_AND_SET
= 1,
522 struct wtbl_req_hdr
{
530 struct wtbl_generic
{
533 u8 peer_addr
[ETH_ALEN
];
575 struct wtbl_hdr_trans
{
586 MT_BA_TYPE_ORIGINATOR
,
591 RST_BA_MAC_TID_MATCH
,
603 /* originator only */
609 u8 peer_addr
[ETH_ALEN
];
629 WTBL_PEER_PS
, /* not used */
634 WTBL_RDG
, /* obsoleted */
635 WTBL_PROTECT
, /* not used */
636 WTBL_CLEAR
, /* not used */
639 WTBL_RAW_DATA
, /* debug only */
645 struct sta_ntlv_hdr
{
660 struct sta_rec_basic
{
667 u8 peer_addr
[ETH_ALEN
];
682 __le16 vht_rx_mcs_map
;
683 __le16 vht_tx_mcs_map
;
688 struct sta_rec_uapsd
{
695 __le16 listen_interval
;
699 struct sta_rec_muru
{
713 bool he_20m_in_40m_2g
;
717 bool rx_su_comp_sigb
;
718 bool rx_su_non_comp_sigb
;
733 bool partial_bw_dl_mimo
;
739 bool partial_ul_mimo
;
763 __le16 max_nss_mcs
[CMD_HE_MCS_BW_NUM
];
779 struct sta_rec_amsdu
{
803 struct sec_key key
[2];
841 __le16 supp_vht_mcs
[4];
844 u8 op_vht_chan_width
;
846 u8 op_vht_rx_nss_type
;
853 struct sta_rec_ra_fixed
{
859 u8 op_vht_chan_width
;
861 u8 op_vht_rx_nss_type
;
871 #define RATE_PARAM_FIXED 3
872 #define RATE_PARAM_AUTO 20
873 #define RATE_CFG_MCS GENMASK(3, 0)
874 #define RATE_CFG_NSS GENMASK(7, 4)
875 #define RATE_CFG_GI GENMASK(11, 8)
876 #define RATE_CFG_BW GENMASK(15, 12)
877 #define RATE_CFG_STBC GENMASK(19, 16)
878 #define RATE_CFG_LDPC GENMASK(23, 20)
879 #define RATE_CFG_PHY_TYPE GENMASK(27, 24)
885 __le16 pfmu
; /* 0xffff: no access right for PFMU */
886 bool su_mu
; /* 0: SU, 1: MU */
887 u8 bf_cap
; /* 0: iBF, 1: eBF */
888 u8 sounding_phy
; /* 0: legacy, 1: OFDM, 2: HT, 4: VHT */
892 u8 tx_mode
; /* 0: legacy, 1: OFDM, 2: HT, 4: VHT ... */
895 u8 bw
; /* 0: 20M, 1: 40M, 2: 80M, 3: 160M */
901 u8 col
: 6, row_msb
: 2;
906 u8 auto_sounding
; /* b7: low traffic indicator
907 * b6: Stop sounding for this entry
908 * b5 ~ b0: postpone sounding
930 struct sta_rec_bfee
{
933 bool fb_identity_matrix
; /* 1: feedback identity matrix */
934 bool ignore_feedback
; /* 1: ignore */
946 STA_REC_RED
, /* not used */
947 STA_REC_TX_PROC
, /* for hdr trans and CSO in CR4 */
963 enum mt7915_cipher_type
{
974 MT_CIPHER_BIP_CMAC_128
,
978 CH_SWITCH_NORMAL
= 0,
982 CH_SWITCH_BACKGROUND_SCAN_START
= 6,
983 CH_SWITCH_BACKGROUND_SCAN_RUNNING
= 7,
984 CH_SWITCH_BACKGROUND_SCAN_STOP
= 8,
985 CH_SWITCH_SCAN_BYPASS_DPD
= 9
989 THERMAL_SENSOR_TEMP_QUERY
,
990 THERMAL_SENSOR_MANUAL_CTRL
,
991 THERMAL_SENSOR_INFO_QUERY
,
992 THERMAL_SENSOR_TASK_CTRL
,
996 MT_EBF
= BIT(0), /* explicit beamforming */
997 MT_IBF
= BIT(1) /* implicit beamforming */
1000 #define MT7915_WTBL_UPDATE_MAX_SIZE (sizeof(struct wtbl_req_hdr) + \
1001 sizeof(struct wtbl_generic) + \
1002 sizeof(struct wtbl_rx) + \
1003 sizeof(struct wtbl_ht) + \
1004 sizeof(struct wtbl_vht) + \
1005 sizeof(struct wtbl_hdr_trans) +\
1006 sizeof(struct wtbl_ba) + \
1007 sizeof(struct wtbl_smps))
1009 #define MT7915_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
1010 sizeof(struct sta_rec_basic) + \
1011 sizeof(struct sta_rec_ht) + \
1012 sizeof(struct sta_rec_he) + \
1013 sizeof(struct sta_rec_ba) + \
1014 sizeof(struct sta_rec_vht) + \
1015 sizeof(struct sta_rec_uapsd) + \
1016 sizeof(struct sta_rec_amsdu) + \
1017 sizeof(struct tlv) + \
1018 MT7915_WTBL_UPDATE_MAX_SIZE)
1020 #define MT7915_WTBL_UPDATE_BA_SIZE (sizeof(struct wtbl_req_hdr) + \
1021 sizeof(struct wtbl_ba))
1023 #define MT7915_BSS_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
1024 sizeof(struct bss_info_omac) + \
1025 sizeof(struct bss_info_basic) +\
1026 sizeof(struct bss_info_rf_ch) +\
1027 sizeof(struct bss_info_ra) + \
1028 sizeof(struct bss_info_hw_amsdu) +\
1029 sizeof(struct bss_info_he) + \
1030 sizeof(struct bss_info_bmc_rate) +\
1031 sizeof(struct bss_info_ext_bss))
1033 #define MT7915_BEACON_UPDATE_SIZE (sizeof(struct sta_req_hdr) + \
1034 sizeof(struct bss_info_bcn_csa) + \
1035 sizeof(struct bss_info_bcn_bcc) + \
1036 sizeof(struct bss_info_bcn_mbss) + \
1037 sizeof(struct bss_info_bcn_cont))
1039 #define PHY_MODE_A BIT(0)
1040 #define PHY_MODE_B BIT(1)
1041 #define PHY_MODE_G BIT(2)
1042 #define PHY_MODE_GN BIT(3)
1043 #define PHY_MODE_AN BIT(4)
1044 #define PHY_MODE_AC BIT(5)
1045 #define PHY_MODE_AX_24G BIT(6)
1046 #define PHY_MODE_AX_5G BIT(7)
1047 #define PHY_MODE_AX_6G BIT(8)
1049 #define MODE_CCK BIT(0)
1050 #define MODE_OFDM BIT(1)
1051 #define MODE_HT BIT(2)
1052 #define MODE_VHT BIT(3)
1053 #define MODE_HE BIT(4)
1055 #define STA_CAP_WMM BIT(0)
1056 #define STA_CAP_SGI_20 BIT(4)
1057 #define STA_CAP_SGI_40 BIT(5)
1058 #define STA_CAP_TX_STBC BIT(6)
1059 #define STA_CAP_RX_STBC BIT(7)
1060 #define STA_CAP_VHT_SGI_80 BIT(16)
1061 #define STA_CAP_VHT_SGI_160 BIT(17)
1062 #define STA_CAP_VHT_TX_STBC BIT(18)
1063 #define STA_CAP_VHT_RX_STBC BIT(19)
1064 #define STA_CAP_VHT_LDPC BIT(23)
1065 #define STA_CAP_LDPC BIT(24)
1066 #define STA_CAP_HT BIT(26)
1067 #define STA_CAP_VHT BIT(27)
1068 #define STA_CAP_HE BIT(28)
1071 #define STA_REC_HE_CAP_HTC BIT(0)
1072 #define STA_REC_HE_CAP_BQR BIT(1)
1073 #define STA_REC_HE_CAP_BSR BIT(2)
1074 #define STA_REC_HE_CAP_OM BIT(3)
1075 #define STA_REC_HE_CAP_AMSDU_IN_AMPDU BIT(4)
1077 #define STA_REC_HE_CAP_DUAL_BAND BIT(5)
1078 #define STA_REC_HE_CAP_LDPC BIT(6)
1079 #define STA_REC_HE_CAP_TRIG_CQI_FK BIT(7)
1080 #define STA_REC_HE_CAP_PARTIAL_BW_EXT_RANGE BIT(8)
1082 #define STA_REC_HE_CAP_LE_EQ_80M_TX_STBC BIT(9)
1083 #define STA_REC_HE_CAP_LE_EQ_80M_RX_STBC BIT(10)
1084 #define STA_REC_HE_CAP_GT_80M_TX_STBC BIT(11)
1085 #define STA_REC_HE_CAP_GT_80M_RX_STBC BIT(12)
1087 #define STA_REC_HE_CAP_SU_PPDU_1LTF_8US_GI BIT(13)
1088 #define STA_REC_HE_CAP_SU_MU_PPDU_4LTF_8US_GI BIT(14)
1089 #define STA_REC_HE_CAP_ER_SU_PPDU_1LTF_8US_GI BIT(15)
1090 #define STA_REC_HE_CAP_ER_SU_PPDU_4LTF_8US_GI BIT(16)
1091 #define STA_REC_HE_CAP_NDP_4LTF_3DOT2MS_GI BIT(17)
1093 #define STA_REC_HE_CAP_BW20_RU242_SUPPORT BIT(18)
1094 #define STA_REC_HE_CAP_TX_1024QAM_UNDER_RU242 BIT(19)
1095 #define STA_REC_HE_CAP_RX_1024QAM_UNDER_RU242 BIT(20)