Path: blob/main/sys/contrib/dev/mediatek/mt76/mt7925/mcu.h
48524 views
/* SPDX-License-Identifier: ISC */1/* Copyright (C) 2023 MediaTek Inc. */23#ifndef __MT7925_MCU_H4#define __MT7925_MCU_H56#include "../mt76_connac_mcu.h"78/* ext event table */9enum {10MCU_EXT_EVENT_RATE_REPORT = 0x87,11};1213struct mt7925_mcu_eeprom_info {14__le32 addr;15__le32 valid;16u8 data[MT7925_EEPROM_BLOCK_SIZE];17} __packed;1819#define MT_RA_RATE_NSS GENMASK(8, 6)20#define MT_RA_RATE_MCS GENMASK(3, 0)21#define MT_RA_RATE_TX_MODE GENMASK(12, 9)22#define MT_RA_RATE_DCM_EN BIT(4)23#define MT_RA_RATE_BW GENMASK(14, 13)2425struct mt7925_mcu_rxd {26__le32 rxd[8];2728__le16 len;29__le16 pkt_type_id;3031u8 eid;32u8 seq;33u8 option;34u8 __rsv;3536u8 ext_eid;37u8 __rsv1[2];38u8 s2d_index;3940u8 tlv[];41};4243struct mt7925_mcu_uni_event {44u8 cid;45u8 pad[3];46__le32 status; /* 0: success, others: fail */47} __packed;4849enum {50MT_EBF = BIT(0), /* explicit beamforming */51MT_IBF = BIT(1) /* implicit beamforming */52};5354struct mt7925_mcu_reg_event {55__le32 reg;56__le32 val;57} __packed;5859struct mt7925_mcu_ant_id_config {60u8 ant_id[4];61} __packed;6263struct mt7925_txpwr_req {64u8 _rsv[4];65__le16 tag;66__le16 len;6768u8 format_id;69u8 catg;70u8 band_idx;71u8 _rsv1;72} __packed;7374struct mt7925_txpwr_event {75u8 rsv[4];76__le16 tag;77__le16 len;7879u8 catg;80u8 band_idx;81u8 ch_band;82u8 format; /* 0:Legacy, 1:HE */8384/* Rate power info */85struct mt7925_txpwr txpwr;8687s8 pwr_max;88s8 pwr_min;89u8 rsv1;90} __packed;9192enum {93TM_SWITCH_MODE,94TM_SET_AT_CMD,95TM_QUERY_AT_CMD,96};9798enum {99MT7925_TM_NORMAL,100MT7925_TM_TESTMODE,101MT7925_TM_ICAP,102MT7925_TM_ICAP_OVERLAP,103MT7925_TM_WIFISPECTRUM,104};105106struct mt7925_rftest_evt {107__le32 param0;108__le32 param1;109} __packed;110111enum {112UNI_CHANNEL_SWITCH,113UNI_CHANNEL_RX_PATH,114};115116enum {117UNI_CHIP_CONFIG_CHIP_CFG = 0x2,118UNI_CHIP_CONFIG_NIC_CAPA = 0x3,119};120121enum {122UNI_BAND_CONFIG_RADIO_ENABLE,123UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,124UNI_BAND_CONFIG_SET_MAC80211_RX_FILTER = 0x0C,125};126127enum {128UNI_WSYS_CONFIG_FW_LOG_CTRL,129UNI_WSYS_CONFIG_FW_DBG_CTRL,130};131132enum {133UNI_EFUSE_ACCESS = 1,134UNI_EFUSE_BUFFER_MODE,135UNI_EFUSE_FREE_BLOCK,136UNI_EFUSE_BUFFER_RD,137};138139enum {140UNI_CMD_ACCESS_REG_BASIC = 0x0,141UNI_CMD_ACCESS_RF_REG_BASIC,142};143144enum {145UNI_MBMC_SETTING,146};147148enum {149UNI_EVENT_SCAN_DONE_BASIC = 0,150UNI_EVENT_SCAN_DONE_CHNLINFO = 2,151UNI_EVENT_SCAN_DONE_NLO = 3,152};153154enum connac3_mcu_cipher_type {155CONNAC3_CIPHER_NONE = 0,156CONNAC3_CIPHER_WEP40 = 1,157CONNAC3_CIPHER_TKIP = 2,158CONNAC3_CIPHER_AES_CCMP = 4,159CONNAC3_CIPHER_WEP104 = 5,160CONNAC3_CIPHER_BIP_CMAC_128 = 6,161CONNAC3_CIPHER_WEP128 = 7,162CONNAC3_CIPHER_WAPI = 8,163CONNAC3_CIPHER_CCMP_256 = 10,164CONNAC3_CIPHER_GCMP = 11,165CONNAC3_CIPHER_GCMP_256 = 12,166};167168struct mt7925_mcu_scan_chinfo_event {169u8 nr_chan;170u8 alpha2[3];171} __packed;172173enum {174UNI_SCAN_REQ = 1,175UNI_SCAN_CANCEL = 2,176UNI_SCAN_SCHED_REQ = 3,177UNI_SCAN_SCHED_ENABLE = 4,178UNI_SCAN_SSID = 10,179UNI_SCAN_BSSID,180UNI_SCAN_CHANNEL,181UNI_SCAN_IE,182UNI_SCAN_MISC,183UNI_SCAN_SSID_MATCH_SETS,184};185186enum {187UNI_SNIFFER_ENABLE,188UNI_SNIFFER_CONFIG,189};190191#define MT7925_RNR_SCAN_MAX_BSSIDS 10192struct scan_hdr_tlv {193/* fixed field */194u8 seq_num;195u8 bss_idx;196u8 pad[2];197/* tlv */198u8 data[];199} __packed;200201struct scan_req_tlv {202__le16 tag;203__le16 len;204205u8 scan_type; /* 0: PASSIVE SCAN206* 1: ACTIVE SCAN207*/208u8 probe_req_num; /* Number of probe request for each SSID */209u8 scan_func; /* BIT(0) Enable random MAC scan210* BIT(1) Disable DBDC scan type 1~3.211* BIT(2) Use DBDC scan type 3 (dedicated one RF to scan).212*/213u8 src_mask;214__le16 channel_min_dwell_time;215__le16 channel_dwell_time; /* channel Dwell interval */216__le16 timeout_value;217__le16 probe_delay_time;218__le32 func_mask_ext;219} __packed;220221struct scan_ssid_tlv {222__le16 tag;223__le16 len;224225u8 ssid_type; /* BIT(0) wildcard SSID226* BIT(1) P2P wildcard SSID227* BIT(2) specified SSID + wildcard SSID228* BIT(2) + ssid_type_ext BIT(0) specified SSID only229*/230u8 ssids_num;231u8 is_short_ssid;232u8 pad;233struct mt76_connac_mcu_scan_ssid ssids[MT7925_RNR_SCAN_MAX_BSSIDS];234} __packed;235236struct scan_bssid_tlv {237__le16 tag;238__le16 len;239240u8 bssid[ETH_ALEN];241u8 match_ch;242u8 match_ssid_ind;243u8 rcpi;244u8 match_short_ssid_ind;245u8 pad[2];246} __packed;247248struct scan_chan_info_tlv {249__le16 tag;250__le16 len;251252u8 channel_type; /* 0: Full channels253* 1: Only 2.4GHz channels254* 2: Only 5GHz channels255* 3: P2P social channel only (channel #1, #6 and #11)256* 4: Specified channels257* Others: Reserved258*/259u8 channels_num; /* valid when channel_type is 4 */260u8 pad[2];261struct mt76_connac_mcu_scan_channel channels[64];262} __packed;263264struct scan_ie_tlv {265__le16 tag;266__le16 len;267268__le16 ies_len;269u8 band;270u8 pad;271u8 ies[];272};273274struct scan_misc_tlv {275__le16 tag;276__le16 len;277278u8 random_mac[ETH_ALEN];279u8 rsv[2];280};281282struct scan_sched_req {283__le16 tag;284__le16 len;285286u8 version;287u8 stop_on_match;288u8 intervals_num;289u8 scan_func;290__le16 intervals[MT76_CONNAC_MAX_NUM_SCHED_SCAN_INTERVAL];291};292293struct scan_sched_ssid_match_sets {294__le16 tag;295__le16 len;296297u8 match_num;298u8 rsv[3];299300struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH];301};302303struct scan_sched_enable {304__le16 tag;305__le16 len;306307u8 active;308u8 rsv[3];309};310311struct mbmc_set_req {312u8 pad[4];313u8 data[];314} __packed;315316struct mbmc_conf_tlv {317__le16 tag;318__le16 len;319320u8 mbmc_en;321u8 band;322u8 pad[2];323} __packed;324325struct edca {326__le16 tag;327__le16 len;328329u8 queue;330u8 set;331u8 cw_min;332u8 cw_max;333__le16 txop;334u8 aifs;335u8 __rsv;336};337338struct bss_req_hdr {339u8 bss_idx;340u8 __rsv[3];341} __packed;342343struct bss_rate_tlv {344__le16 tag;345__le16 len;346u8 __rsv1[2];347__le16 basic_rate;348__le16 bc_trans;349__le16 mc_trans;350u8 short_preamble;351u8 bc_fixed_rate;352u8 mc_fixed_rate;353u8 __rsv2;354} __packed;355356struct bss_mld_tlv {357__le16 tag;358__le16 len;359u8 group_mld_id;360u8 own_mld_id;361u8 mac_addr[ETH_ALEN];362u8 remap_idx;363u8 link_id;364u8 eml_enable;365u8 max_link_num;366u8 hybrid_mode;367u8 __rsv[3];368} __packed;369370struct bss_eht_tlv {371__le16 tag;372__le16 len;373u8 is_eht_op_present;374u8 is_eth_dscb_present;375u8 eht_ctrl;376u8 eht_ccfs0;377u8 eht_ccfs1;378u8 pad1;379__le16 eht_dis_sub_chan_bitmap;380u8 pad2[4];381} __packed;382383struct sta_rec_ba_uni {384__le16 tag;385__le16 len;386u8 tid;387u8 ba_type;388u8 amsdu;389u8 ba_en;390__le16 ssn;391__le16 winsize;392u8 ba_rdd_rro;393u8 __rsv[3];394} __packed;395396struct sta_rec_eht {397__le16 tag;398__le16 len;399u8 tid_bitmap;400u8 _rsv;401__le16 mac_cap;402__le64 phy_cap;403__le64 phy_cap_ext;404u8 mcs_map_bw20[4];405u8 mcs_map_bw80[3];406u8 mcs_map_bw160[3];407u8 mcs_map_bw320[3];408u8 _rsv2[3];409} __packed;410411struct sta_rec_sec_uni {412__le16 tag;413__le16 len;414u8 add;415u8 tx_key;416u8 key_type;417u8 is_authenticator;418u8 peer_addr[6];419u8 bss_idx;420u8 cipher_id;421u8 key_id;422u8 key_len;423u8 wlan_idx;424u8 mgmt_prot;425u8 key[32];426u8 key_rsc[16];427} __packed;428429struct sta_rec_hdr_trans {430__le16 tag;431__le16 len;432u8 from_ds;433u8 to_ds;434u8 dis_rx_hdr_tran;435u8 rsv;436} __packed;437438struct sta_rec_mld {439__le16 tag;440__le16 len;441u8 mac_addr[ETH_ALEN];442__le16 primary_id;443__le16 secondary_id;444__le16 wlan_id;445u8 link_num;446u8 rsv[3];447struct {448__le16 wlan_id;449u8 bss_idx;450u8 rsv;451} __packed link[2];452} __packed;453454struct sta_rec_eht_mld {455__le16 tag;456__le16 len;457u8 nsep;458u8 mld_type;459u8 __rsv1[1];460u8 str_cap[3];461u8 eml_cap[3];462u8 __rsv2[3];463} __packed;464465struct bss_ifs_time_tlv {466__le16 tag;467__le16 len;468u8 slot_valid;469u8 sifs_valid;470u8 rifs_valid;471u8 eifs_valid;472__le16 slot_time;473__le16 sifs_time;474__le16 rifs_time;475__le16 eifs_time;476u8 eifs_cck_valid;477u8 rsv;478__le16 eifs_cck_time;479} __packed;480481struct bss_rlm_tlv {482__le16 tag;483__le16 len;484u8 control_channel;485u8 center_chan;486u8 center_chan2;487u8 bw;488u8 tx_streams;489u8 rx_streams;490u8 ht_op_info;491u8 sco;492u8 band;493u8 pad[3];494} __packed;495496#define MT7925_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \497sizeof(struct sta_rec_basic) + \498sizeof(struct sta_rec_bf) + \499sizeof(struct sta_rec_ht) + \500sizeof(struct sta_rec_he_v2) + \501sizeof(struct sta_rec_ba_uni) + \502sizeof(struct sta_rec_vht) + \503sizeof(struct sta_rec_uapsd) + \504sizeof(struct sta_rec_amsdu) + \505sizeof(struct sta_rec_bfee) + \506sizeof(struct sta_rec_phy) + \507sizeof(struct sta_rec_ra) + \508sizeof(struct sta_rec_sec_uni) + \509sizeof(struct sta_rec_ra_fixed) + \510sizeof(struct sta_rec_he_6g_capa) + \511sizeof(struct sta_rec_eht) + \512sizeof(struct sta_rec_hdr_trans) + \513sizeof(struct sta_rec_mld) + \514sizeof(struct tlv) * 2 + \515sizeof(struct sta_rec_remove))516517#define MT7925_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \518sizeof(struct mt76_connac_bss_basic_tlv) + \519sizeof(struct mt76_connac_bss_qos_tlv) + \520sizeof(struct bss_rate_tlv) + \521sizeof(struct bss_mld_tlv) + \522sizeof(struct bss_info_uni_he) + \523sizeof(struct bss_info_uni_bss_color) + \524sizeof(struct bss_ifs_time_tlv) + \525sizeof(struct bss_rlm_tlv) + \526sizeof(struct tlv))527528#define MT_CONNAC3_SKU_POWER_LIMIT 449529struct mt7925_sku_tlv {530u8 channel;531s8 pwr_limit[MT_CONNAC3_SKU_POWER_LIMIT];532} __packed;533534struct mt7925_tx_power_limit_tlv {535u8 rsv[4];536537__le16 tag;538__le16 len;539540/* DW0 - common info*/541u8 ver;542u8 pad0;543__le16 rsv1;544/* DW1 - cmd hint */545u8 n_chan; /* # channel */546u8 band; /* 2.4GHz - 5GHz - 6GHz */547u8 last_msg;548u8 limit_type;549/* DW3 */550u8 alpha2[4]; /* regulatory_request.alpha2 */551u8 pad2[32];552553u8 data[];554} __packed;555556struct mt7925_arpns_tlv {557__le16 tag;558__le16 len;559560u8 enable;561u8 ips_num;562u8 rsv[2];563} __packed;564565struct mt7925_wow_pattern_tlv {566__le16 tag;567__le16 len;568u8 bss_idx;569u8 index; /* pattern index */570u8 enable; /* 0: disable571* 1: enable572*/573u8 data_len; /* pattern length */574u8 offset;575u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN];576u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN];577u8 rsv[4];578};579580struct roc_acquire_tlv {581__le16 tag;582__le16 len;583u8 bss_idx;584u8 tokenid;585u8 control_channel;586u8 sco;587u8 band;588u8 bw;589u8 center_chan;590u8 center_chan2;591u8 bw_from_ap;592u8 center_chan_from_ap;593u8 center_chan2_from_ap;594u8 reqtype;595__le32 maxinterval;596u8 dbdcband;597u8 rsv[3];598} __packed;599600enum ENUM_CMD_TEST_CTRL_ACT {601CMD_TEST_CTRL_ACT_SWITCH_MODE = 0,602CMD_TEST_CTRL_ACT_SET_AT = 1,603CMD_TEST_CTRL_ACT_GET_AT = 2,604CMD_TEST_CTRL_ACT_SET_AT_ENG = 3,605CMD_TEST_CTRL_ACT_GET_AT_ENG = 4,606CMD_TEST_CTRL_ACT_NUM607};608609enum ENUM_CMD_TEST_CTRL_ACT_SWITCH_MODE_OP {610CMD_TEST_CTRL_ACT_SWITCH_MODE_NORMAL = 0,611CMD_TEST_CTRL_ACT_SWITCH_MODE_RF_TEST = 1,612CMD_TEST_CTRL_ACT_SWITCH_MODE_ICAP = 2,613CMD_TEST_CTRL_ACT_SWITCH_MODE_NUM614};615616union testmode_data {617__le32 op_mode;618__le32 channel_freq;619u8 rf_at_info[84];620};621622union testmode_evt {623__le32 op_mode;624__le32 channel_freq;625u8 rf_at_info[1024];626};627628struct uni_cmd_testmode_ctrl {629u16 tag;630u16 length;631u8 action;632u8 reserved[3];633union testmode_data data;634} __packed;635636struct mt7925_rftest_cmd {637u8 padding[4];638struct uni_cmd_testmode_ctrl ctrl;639} __packed;640641static inline enum connac3_mcu_cipher_type642mt7925_mcu_get_cipher(int cipher)643{644switch (cipher) {645case WLAN_CIPHER_SUITE_WEP40:646return CONNAC3_CIPHER_WEP40;647case WLAN_CIPHER_SUITE_WEP104:648return CONNAC3_CIPHER_WEP104;649case WLAN_CIPHER_SUITE_TKIP:650return CONNAC3_CIPHER_TKIP;651case WLAN_CIPHER_SUITE_AES_CMAC:652return CONNAC3_CIPHER_BIP_CMAC_128;653case WLAN_CIPHER_SUITE_CCMP:654return CONNAC3_CIPHER_AES_CCMP;655case WLAN_CIPHER_SUITE_CCMP_256:656return CONNAC3_CIPHER_CCMP_256;657case WLAN_CIPHER_SUITE_GCMP:658return CONNAC3_CIPHER_GCMP;659case WLAN_CIPHER_SUITE_GCMP_256:660return CONNAC3_CIPHER_GCMP_256;661case WLAN_CIPHER_SUITE_SMS4:662return CONNAC3_CIPHER_WAPI;663default:664return CONNAC3_CIPHER_NONE;665}666}667668int mt7925_mcu_set_dbdc(struct mt76_phy *phy, bool enable);669int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,670struct ieee80211_scan_request *scan_req);671int mt7925_mcu_cancel_hw_scan(struct mt76_phy *phy,672struct ieee80211_vif *vif);673int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,674struct ieee80211_vif *vif,675struct cfg80211_sched_scan_request *sreq,676struct ieee80211_scan_ies *ies);677int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,678struct ieee80211_vif *vif,679bool enable);680void mt7925_mcu_del_dev(struct mt76_dev *mdev,681struct ieee80211_vif *vif);682int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,683struct ieee80211_chanctx_conf *ctx,684struct ieee80211_bss_conf *link_conf,685struct ieee80211_link_sta *link_sta,686int enable);687int mt7925_mcu_set_timing(struct mt792x_phy *phy,688struct ieee80211_bss_conf *link_conf);689int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);690int mt7925_mcu_set_thermal_protect(struct mt792x_dev *dev);691int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);692int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);693int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif_link *mvif,694struct ieee80211_bss_conf *link_conf,695struct ieee80211_chanctx_conf *ctx);696int mt7925_mcu_set_eht_pp(struct mt76_phy *phy, struct mt76_vif_link *mvif,697struct ieee80211_bss_conf *link_conf,698struct ieee80211_chanctx_conf *ctx);699int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);700int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,701struct ieee80211_bss_conf *link_conf);702int703mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev,704struct ieee80211_bss_conf *link_conf, bool enable);705#endif706707708