647 lines · c
1/* SPDX-License-Identifier: ISC */2/* Copyright (C) 2023 MediaTek Inc. */3 4#ifndef __MT7925_MCU_H5#define __MT7925_MCU_H6 7#include "../mt76_connac_mcu.h"8 9/* ext event table */10enum {11 MCU_EXT_EVENT_RATE_REPORT = 0x87,12};13 14struct mt7925_mcu_eeprom_info {15 __le32 addr;16 __le32 valid;17 u8 data[MT7925_EEPROM_BLOCK_SIZE];18} __packed;19 20#define MT_RA_RATE_NSS GENMASK(8, 6)21#define MT_RA_RATE_MCS GENMASK(3, 0)22#define MT_RA_RATE_TX_MODE GENMASK(12, 9)23#define MT_RA_RATE_DCM_EN BIT(4)24#define MT_RA_RATE_BW GENMASK(14, 13)25 26struct mt7925_mcu_rxd {27 __le32 rxd[8];28 29 __le16 len;30 __le16 pkt_type_id;31 32 u8 eid;33 u8 seq;34 u8 option;35 u8 __rsv;36 37 u8 ext_eid;38 u8 __rsv1[2];39 u8 s2d_index;40 41 u8 tlv[];42};43 44struct mt7925_mcu_uni_event {45 u8 cid;46 u8 pad[3];47 __le32 status; /* 0: success, others: fail */48} __packed;49 50enum {51 MT_EBF = BIT(0), /* explicit beamforming */52 MT_IBF = BIT(1) /* implicit beamforming */53};54 55struct mt7925_mcu_reg_event {56 __le32 reg;57 __le32 val;58} __packed;59 60struct mt7925_mcu_ant_id_config {61 u8 ant_id[4];62} __packed;63 64struct mt7925_txpwr_req {65 u8 _rsv[4];66 __le16 tag;67 __le16 len;68 69 u8 format_id;70 u8 catg;71 u8 band_idx;72 u8 _rsv1;73} __packed;74 75struct mt7925_txpwr_event {76 u8 rsv[4];77 __le16 tag;78 __le16 len;79 80 u8 catg;81 u8 band_idx;82 u8 ch_band;83 u8 format; /* 0:Legacy, 1:HE */84 85 /* Rate power info */86 struct mt7925_txpwr txpwr;87 88 s8 pwr_max;89 s8 pwr_min;90 u8 rsv1;91} __packed;92 93enum {94 TM_SWITCH_MODE,95 TM_SET_AT_CMD,96 TM_QUERY_AT_CMD,97};98 99enum {100 MT7925_TM_NORMAL,101 MT7925_TM_TESTMODE,102 MT7925_TM_ICAP,103 MT7925_TM_ICAP_OVERLAP,104 MT7925_TM_WIFISPECTRUM,105};106 107struct mt7925_rftest_cmd {108 u8 action;109 u8 rsv[3];110 __le32 param0;111 __le32 param1;112} __packed;113 114struct mt7925_rftest_evt {115 __le32 param0;116 __le32 param1;117} __packed;118 119enum {120 UNI_CHANNEL_SWITCH,121 UNI_CHANNEL_RX_PATH,122};123 124enum {125 UNI_CHIP_CONFIG_CHIP_CFG = 0x2,126 UNI_CHIP_CONFIG_NIC_CAPA = 0x3,127};128 129enum {130 UNI_BAND_CONFIG_RADIO_ENABLE,131 UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,132 UNI_BAND_CONFIG_SET_MAC80211_RX_FILTER = 0x0C,133};134 135enum {136 UNI_WSYS_CONFIG_FW_LOG_CTRL,137 UNI_WSYS_CONFIG_FW_DBG_CTRL,138};139 140enum {141 UNI_EFUSE_ACCESS = 1,142 UNI_EFUSE_BUFFER_MODE,143 UNI_EFUSE_FREE_BLOCK,144 UNI_EFUSE_BUFFER_RD,145};146 147enum {148 UNI_CMD_ACCESS_REG_BASIC = 0x0,149 UNI_CMD_ACCESS_RF_REG_BASIC,150};151 152enum {153 UNI_MBMC_SETTING,154};155 156enum {157 UNI_EVENT_SCAN_DONE_BASIC = 0,158 UNI_EVENT_SCAN_DONE_CHNLINFO = 2,159 UNI_EVENT_SCAN_DONE_NLO = 3,160};161 162enum connac3_mcu_cipher_type {163 CONNAC3_CIPHER_NONE = 0,164 CONNAC3_CIPHER_WEP40 = 1,165 CONNAC3_CIPHER_TKIP = 2,166 CONNAC3_CIPHER_AES_CCMP = 4,167 CONNAC3_CIPHER_WEP104 = 5,168 CONNAC3_CIPHER_BIP_CMAC_128 = 6,169 CONNAC3_CIPHER_WEP128 = 7,170 CONNAC3_CIPHER_WAPI = 8,171 CONNAC3_CIPHER_CCMP_256 = 10,172 CONNAC3_CIPHER_GCMP = 11,173 CONNAC3_CIPHER_GCMP_256 = 12,174};175 176struct mt7925_mcu_scan_chinfo_event {177 u8 nr_chan;178 u8 alpha2[3];179} __packed;180 181enum {182 UNI_SCAN_REQ = 1,183 UNI_SCAN_CANCEL = 2,184 UNI_SCAN_SCHED_REQ = 3,185 UNI_SCAN_SCHED_ENABLE = 4,186 UNI_SCAN_SSID = 10,187 UNI_SCAN_BSSID,188 UNI_SCAN_CHANNEL,189 UNI_SCAN_IE,190 UNI_SCAN_MISC,191 UNI_SCAN_SSID_MATCH_SETS,192};193 194enum {195 UNI_SNIFFER_ENABLE,196 UNI_SNIFFER_CONFIG,197};198 199struct scan_hdr_tlv {200 /* fixed field */201 u8 seq_num;202 u8 bss_idx;203 u8 pad[2];204 /* tlv */205 u8 data[];206} __packed;207 208struct scan_req_tlv {209 __le16 tag;210 __le16 len;211 212 u8 scan_type; /* 0: PASSIVE SCAN213 * 1: ACTIVE SCAN214 */215 u8 probe_req_num; /* Number of probe request for each SSID */216 u8 scan_func; /* BIT(0) Enable random MAC scan217 * BIT(1) Disable DBDC scan type 1~3.218 * BIT(2) Use DBDC scan type 3 (dedicated one RF to scan).219 */220 u8 src_mask;221 __le16 channel_min_dwell_time;222 __le16 channel_dwell_time; /* channel Dwell interval */223 __le16 timeout_value;224 __le16 probe_delay_time;225 __le32 func_mask_ext;226};227 228struct scan_ssid_tlv {229 __le16 tag;230 __le16 len;231 232 u8 ssid_type; /* BIT(0) wildcard SSID233 * BIT(1) P2P wildcard SSID234 * BIT(2) specified SSID + wildcard SSID235 * BIT(2) + ssid_type_ext BIT(0) specified SSID only236 */237 u8 ssids_num;238 u8 pad[2];239 struct mt76_connac_mcu_scan_ssid ssids[4];240};241 242struct scan_bssid_tlv {243 __le16 tag;244 __le16 len;245 246 u8 bssid[ETH_ALEN];247 u8 match_ch;248 u8 match_ssid_ind;249 u8 rcpi;250 u8 pad[3];251};252 253struct scan_chan_info_tlv {254 __le16 tag;255 __le16 len;256 257 u8 channel_type; /* 0: Full channels258 * 1: Only 2.4GHz channels259 * 2: Only 5GHz channels260 * 3: P2P social channel only (channel #1, #6 and #11)261 * 4: Specified channels262 * Others: Reserved263 */264 u8 channels_num; /* valid when channel_type is 4 */265 u8 pad[2];266 struct mt76_connac_mcu_scan_channel channels[64];267};268 269struct scan_ie_tlv {270 __le16 tag;271 __le16 len;272 273 __le16 ies_len;274 u8 band;275 u8 pad;276 u8 ies[MT76_CONNAC_SCAN_IE_LEN];277};278 279struct scan_misc_tlv {280 __le16 tag;281 __le16 len;282 283 u8 random_mac[ETH_ALEN];284 u8 rsv[2];285};286 287struct scan_sched_req {288 __le16 tag;289 __le16 len;290 291 u8 version;292 u8 stop_on_match;293 u8 intervals_num;294 u8 scan_func;295 __le16 intervals[MT76_CONNAC_MAX_NUM_SCHED_SCAN_INTERVAL];296};297 298struct scan_sched_ssid_match_sets {299 __le16 tag;300 __le16 len;301 302 u8 match_num;303 u8 rsv[3];304 305 struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH];306};307 308struct scan_sched_enable {309 __le16 tag;310 __le16 len;311 312 u8 active;313 u8 rsv[3];314};315 316struct mbmc_set_req {317 u8 pad[4];318 u8 data[];319} __packed;320 321struct mbmc_conf_tlv {322 __le16 tag;323 __le16 len;324 325 u8 mbmc_en;326 u8 band;327 u8 pad[2];328} __packed;329 330struct edca {331 __le16 tag;332 __le16 len;333 334 u8 queue;335 u8 set;336 u8 cw_min;337 u8 cw_max;338 __le16 txop;339 u8 aifs;340 u8 __rsv;341};342 343struct bss_req_hdr {344 u8 bss_idx;345 u8 __rsv[3];346} __packed;347 348struct bss_rate_tlv {349 __le16 tag;350 __le16 len;351 u8 __rsv1[2];352 __le16 basic_rate;353 __le16 bc_trans;354 __le16 mc_trans;355 u8 short_preamble;356 u8 bc_fixed_rate;357 u8 mc_fixed_rate;358 u8 __rsv2;359} __packed;360 361struct bss_mld_tlv {362 __le16 tag;363 __le16 len;364 u8 group_mld_id;365 u8 own_mld_id;366 u8 mac_addr[ETH_ALEN];367 u8 remap_idx;368 u8 link_id;369 u8 eml_enable;370 u8 max_link_num;371 u8 hybrid_mode;372 u8 __rsv[3];373} __packed;374 375struct sta_rec_ba_uni {376 __le16 tag;377 __le16 len;378 u8 tid;379 u8 ba_type;380 u8 amsdu;381 u8 ba_en;382 __le16 ssn;383 __le16 winsize;384 u8 ba_rdd_rro;385 u8 __rsv[3];386} __packed;387 388struct sta_rec_eht {389 __le16 tag;390 __le16 len;391 u8 tid_bitmap;392 u8 _rsv;393 __le16 mac_cap;394 __le64 phy_cap;395 __le64 phy_cap_ext;396 u8 mcs_map_bw20[4];397 u8 mcs_map_bw80[3];398 u8 mcs_map_bw160[3];399 u8 mcs_map_bw320[3];400 u8 _rsv2[3];401} __packed;402 403struct sta_rec_sec_uni {404 __le16 tag;405 __le16 len;406 u8 add;407 u8 tx_key;408 u8 key_type;409 u8 is_authenticator;410 u8 peer_addr[6];411 u8 bss_idx;412 u8 cipher_id;413 u8 key_id;414 u8 key_len;415 u8 wlan_idx;416 u8 mgmt_prot;417 u8 key[32];418 u8 key_rsc[16];419} __packed;420 421struct sta_rec_hdr_trans {422 __le16 tag;423 __le16 len;424 u8 from_ds;425 u8 to_ds;426 u8 dis_rx_hdr_tran;427 u8 rsv;428} __packed;429 430struct sta_rec_mld {431 __le16 tag;432 __le16 len;433 u8 mac_addr[ETH_ALEN];434 __le16 primary_id;435 __le16 secondary_id;436 __le16 wlan_id;437 u8 link_num;438 u8 rsv[3];439 struct {440 __le16 wlan_id;441 u8 bss_idx;442 u8 rsv;443 } __packed link[2];444} __packed;445 446struct sta_rec_eht_mld {447 __le16 tag;448 __le16 len;449 u8 nsep;450 u8 mld_type;451 u8 __rsv1[1];452 u8 str_cap[3];453 u8 eml_cap[3];454 u8 __rsv2[3];455} __packed;456 457struct bss_ifs_time_tlv {458 __le16 tag;459 __le16 len;460 u8 slot_valid;461 u8 sifs_valid;462 u8 rifs_valid;463 u8 eifs_valid;464 __le16 slot_time;465 __le16 sifs_time;466 __le16 rifs_time;467 __le16 eifs_time;468 u8 eifs_cck_valid;469 u8 rsv;470 __le16 eifs_cck_time;471} __packed;472 473struct bss_rlm_tlv {474 __le16 tag;475 __le16 len;476 u8 control_channel;477 u8 center_chan;478 u8 center_chan2;479 u8 bw;480 u8 tx_streams;481 u8 rx_streams;482 u8 ht_op_info;483 u8 sco;484 u8 band;485 u8 pad[3];486} __packed;487 488#define MT7925_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \489 sizeof(struct sta_rec_basic) + \490 sizeof(struct sta_rec_bf) + \491 sizeof(struct sta_rec_ht) + \492 sizeof(struct sta_rec_he_v2) + \493 sizeof(struct sta_rec_ba_uni) + \494 sizeof(struct sta_rec_vht) + \495 sizeof(struct sta_rec_uapsd) + \496 sizeof(struct sta_rec_amsdu) + \497 sizeof(struct sta_rec_bfee) + \498 sizeof(struct sta_rec_phy) + \499 sizeof(struct sta_rec_ra) + \500 sizeof(struct sta_rec_sec_uni) + \501 sizeof(struct sta_rec_ra_fixed) + \502 sizeof(struct sta_rec_he_6g_capa) + \503 sizeof(struct sta_rec_eht) + \504 sizeof(struct sta_rec_hdr_trans) + \505 sizeof(struct sta_rec_mld) + \506 sizeof(struct tlv) * 2 + \507 sizeof(struct sta_rec_remove))508 509#define MT7925_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \510 sizeof(struct mt76_connac_bss_basic_tlv) + \511 sizeof(struct mt76_connac_bss_qos_tlv) + \512 sizeof(struct bss_rate_tlv) + \513 sizeof(struct bss_mld_tlv) + \514 sizeof(struct bss_info_uni_he) + \515 sizeof(struct bss_info_uni_bss_color) + \516 sizeof(struct bss_ifs_time_tlv) + \517 sizeof(struct bss_rlm_tlv) + \518 sizeof(struct tlv))519 520#define MT_CONNAC3_SKU_POWER_LIMIT 449521struct mt7925_sku_tlv {522 u8 channel;523 s8 pwr_limit[MT_CONNAC3_SKU_POWER_LIMIT];524} __packed;525 526struct mt7925_tx_power_limit_tlv {527 u8 rsv[4];528 529 __le16 tag;530 __le16 len;531 532 /* DW0 - common info*/533 u8 ver;534 u8 pad0;535 __le16 rsv1;536 /* DW1 - cmd hint */537 u8 n_chan; /* # channel */538 u8 band; /* 2.4GHz - 5GHz - 6GHz */539 u8 last_msg;540 u8 limit_type;541 /* DW3 */542 u8 alpha2[4]; /* regulatory_request.alpha2 */543 u8 pad2[32];544 545 u8 data[];546} __packed;547 548struct mt7925_arpns_tlv {549 __le16 tag;550 __le16 len;551 552 u8 enable;553 u8 ips_num;554 u8 rsv[2];555} __packed;556 557struct mt7925_wow_pattern_tlv {558 __le16 tag;559 __le16 len;560 u8 bss_idx;561 u8 index; /* pattern index */562 u8 enable; /* 0: disable563 * 1: enable564 */565 u8 data_len; /* pattern length */566 u8 offset;567 u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN];568 u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN];569 u8 rsv[7];570} __packed;571 572struct roc_acquire_tlv {573 __le16 tag;574 __le16 len;575 u8 bss_idx;576 u8 tokenid;577 u8 control_channel;578 u8 sco;579 u8 band;580 u8 bw;581 u8 center_chan;582 u8 center_chan2;583 u8 bw_from_ap;584 u8 center_chan_from_ap;585 u8 center_chan2_from_ap;586 u8 reqtype;587 __le32 maxinterval;588 u8 dbdcband;589 u8 rsv[3];590} __packed;591 592static inline enum connac3_mcu_cipher_type593mt7925_mcu_get_cipher(int cipher)594{595 switch (cipher) {596 case WLAN_CIPHER_SUITE_WEP40:597 return CONNAC3_CIPHER_WEP40;598 case WLAN_CIPHER_SUITE_WEP104:599 return CONNAC3_CIPHER_WEP104;600 case WLAN_CIPHER_SUITE_TKIP:601 return CONNAC3_CIPHER_TKIP;602 case WLAN_CIPHER_SUITE_AES_CMAC:603 return CONNAC3_CIPHER_BIP_CMAC_128;604 case WLAN_CIPHER_SUITE_CCMP:605 return CONNAC3_CIPHER_AES_CCMP;606 case WLAN_CIPHER_SUITE_CCMP_256:607 return CONNAC3_CIPHER_CCMP_256;608 case WLAN_CIPHER_SUITE_GCMP:609 return CONNAC3_CIPHER_GCMP;610 case WLAN_CIPHER_SUITE_GCMP_256:611 return CONNAC3_CIPHER_GCMP_256;612 case WLAN_CIPHER_SUITE_SMS4:613 return CONNAC3_CIPHER_WAPI;614 default:615 return CONNAC3_CIPHER_NONE;616 }617}618 619int mt7925_mcu_set_dbdc(struct mt76_phy *phy);620int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,621 struct ieee80211_scan_request *scan_req);622int mt7925_mcu_cancel_hw_scan(struct mt76_phy *phy,623 struct ieee80211_vif *vif);624int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,625 struct ieee80211_vif *vif,626 struct cfg80211_sched_scan_request *sreq);627int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,628 struct ieee80211_vif *vif,629 bool enable);630int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,631 struct ieee80211_chanctx_conf *ctx,632 struct ieee80211_bss_conf *link_conf,633 struct ieee80211_link_sta *link_sta,634 int enable);635int mt7925_mcu_set_timing(struct mt792x_phy *phy,636 struct ieee80211_bss_conf *link_conf);637int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);638int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);639int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);640int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,641 struct ieee80211_bss_conf *link_conf,642 struct ieee80211_chanctx_conf *ctx);643int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);644int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,645 struct ieee80211_bss_conf *link_conf);646#endif647