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