1 /* SPDX-License-Identifier: ISC */ 2 /* 3 * Copyright (C) 2022 MediaTek Inc. 4 */ 5 6 #ifndef __MT7996_MCU_H 7 #define __MT7996_MCU_H 8 9 #include "../mt76_connac_mcu.h" 10 11 struct mt7996_mcu_rxd { 12 __le32 rxd[8]; 13 14 __le16 len; 15 __le16 pkt_type_id; 16 17 u8 eid; 18 u8 seq; 19 u8 option; 20 u8 __rsv; 21 22 u8 ext_eid; 23 u8 __rsv1[2]; 24 u8 s2d_index; 25 }; 26 27 struct mt7996_mcu_uni_event { 28 u8 cid; 29 u8 __rsv[3]; 30 __le32 status; /* 0: success, others: fail */ 31 } __packed; 32 33 struct mt7996_mcu_csa_notify { 34 struct mt7996_mcu_rxd rxd; 35 36 u8 omac_idx; 37 u8 csa_count; 38 u8 band_idx; 39 u8 rsv; 40 } __packed; 41 42 struct mt7996_mcu_rdd_report { 43 struct mt7996_mcu_rxd rxd; 44 45 u8 __rsv1[4]; 46 47 __le16 tag; 48 __le16 len; 49 50 u8 band_idx; 51 u8 long_detected; 52 u8 constant_prf_detected; 53 u8 staggered_prf_detected; 54 u8 radar_type_idx; 55 u8 periodic_pulse_num; 56 u8 long_pulse_num; 57 u8 hw_pulse_num; 58 59 u8 out_lpn; 60 u8 out_spn; 61 u8 out_crpn; 62 u8 out_crpw; 63 u8 out_crbn; 64 u8 out_stgpn; 65 u8 out_stgpw; 66 67 u8 __rsv2; 68 69 __le32 out_pri_const; 70 __le32 out_pri_stg[3]; 71 __le32 out_pri_stg_dmin; 72 73 struct { 74 __le32 start; 75 __le16 pulse_width; 76 __le16 pulse_power; 77 u8 mdrdy_flag; 78 u8 rsv[3]; 79 } long_pulse[32]; 80 81 struct { 82 __le32 start; 83 __le16 pulse_width; 84 __le16 pulse_power; 85 u8 mdrdy_flag; 86 u8 rsv[3]; 87 } periodic_pulse[32]; 88 89 struct { 90 __le32 start; 91 __le16 pulse_width; 92 __le16 pulse_power; 93 u8 sc_pass; 94 u8 sw_reset; 95 u8 mdrdy_flag; 96 u8 tx_active; 97 } hw_pulse[32]; 98 } __packed; 99 100 struct mt7996_mcu_background_chain_ctrl { 101 u8 _rsv[4]; 102 103 __le16 tag; 104 __le16 len; 105 106 u8 chan; /* primary channel */ 107 u8 central_chan; /* central channel */ 108 u8 bw; 109 u8 tx_stream; 110 u8 rx_stream; 111 112 u8 monitor_chan; /* monitor channel */ 113 u8 monitor_central_chan;/* monitor central channel */ 114 u8 monitor_bw; 115 u8 monitor_tx_stream; 116 u8 monitor_rx_stream; 117 118 u8 scan_mode; /* 0: ScanStop 119 * 1: ScanStart 120 * 2: ScanRunning 121 */ 122 u8 band_idx; /* DBDC */ 123 u8 monitor_scan_type; 124 u8 band; /* 0: 2.4GHz, 1: 5GHz */ 125 u8 rsv[2]; 126 } __packed; 127 128 struct mt7996_mcu_eeprom { 129 u8 _rsv[4]; 130 131 __le16 tag; 132 __le16 len; 133 u8 buffer_mode; 134 u8 format; 135 __le16 buf_len; 136 } __packed; 137 138 struct mt7996_mcu_phy_rx_info { 139 u8 category; 140 u8 rate; 141 u8 mode; 142 u8 nsts; 143 u8 gi; 144 u8 coding; 145 u8 stbc; 146 u8 bw; 147 }; 148 149 struct mt7996_mcu_mib { 150 __le16 tag; 151 __le16 len; 152 __le32 offs; 153 __le64 data; 154 } __packed; 155 156 enum mt7996_chan_mib_offs { 157 UNI_MIB_OBSS_AIRTIME = 26, 158 UNI_MIB_NON_WIFI_TIME = 27, 159 UNI_MIB_TX_TIME = 28, 160 UNI_MIB_RX_TIME = 29 161 }; 162 163 struct edca { 164 __le16 tag; 165 __le16 len; 166 167 u8 queue; 168 u8 set; 169 u8 cw_min; 170 u8 cw_max; 171 __le16 txop; 172 u8 aifs; 173 u8 __rsv; 174 }; 175 176 #define MCU_PQ_ID(p, q) (((p) << 15) | ((q) << 10)) 177 #define MCU_PKT_ID 0xa0 178 179 enum { 180 MCU_FW_LOG_WM, 181 MCU_FW_LOG_WA, 182 MCU_FW_LOG_TO_HOST, 183 MCU_FW_LOG_RELAY = 16 184 }; 185 186 enum { 187 MCU_TWT_AGRT_ADD, 188 MCU_TWT_AGRT_MODIFY, 189 MCU_TWT_AGRT_DELETE, 190 MCU_TWT_AGRT_TEARDOWN, 191 MCU_TWT_AGRT_GET_TSF, 192 }; 193 194 enum { 195 MCU_WA_PARAM_CMD_QUERY, 196 MCU_WA_PARAM_CMD_SET, 197 MCU_WA_PARAM_CMD_CAPABILITY, 198 MCU_WA_PARAM_CMD_DEBUG, 199 }; 200 201 enum { 202 MCU_WA_PARAM_PDMA_RX = 0x04, 203 MCU_WA_PARAM_CPU_UTIL = 0x0b, 204 MCU_WA_PARAM_RED = 0x0e, 205 MCU_WA_PARAM_HW_PATH_HIF_VER = 0x2f, 206 }; 207 208 enum mcu_mmps_mode { 209 MCU_MMPS_STATIC, 210 MCU_MMPS_DYNAMIC, 211 MCU_MMPS_RSV, 212 MCU_MMPS_DISABLE, 213 }; 214 215 struct bss_rate_tlv { 216 __le16 tag; 217 __le16 len; 218 u8 __rsv1[4]; 219 __le16 bc_trans; 220 __le16 mc_trans; 221 u8 short_preamble; 222 u8 bc_fixed_rate; 223 u8 mc_fixed_rate; 224 u8 __rsv2[1]; 225 } __packed; 226 227 struct bss_ra_tlv { 228 __le16 tag; 229 __le16 len; 230 u8 short_preamble; 231 u8 force_sgi; 232 u8 force_gf; 233 u8 ht_mode; 234 u8 se_off; 235 u8 antenna_idx; 236 __le16 max_phyrate; 237 u8 force_tx_streams; 238 u8 __rsv[3]; 239 } __packed; 240 241 struct bss_rlm_tlv { 242 __le16 tag; 243 __le16 len; 244 u8 control_channel; 245 u8 center_chan; 246 u8 center_chan2; 247 u8 bw; 248 u8 tx_streams; 249 u8 rx_streams; 250 u8 ht_op_info; 251 u8 sco; 252 u8 band; 253 u8 __rsv[3]; 254 } __packed; 255 256 struct bss_color_tlv { 257 __le16 tag; 258 __le16 len; 259 u8 enable; 260 u8 color; 261 u8 rsv[2]; 262 } __packed; 263 264 struct bss_inband_discovery_tlv { 265 __le16 tag; 266 __le16 len; 267 u8 tx_type; 268 u8 tx_mode; 269 u8 tx_interval; 270 u8 enable; 271 __le16 wcid; 272 __le16 prob_rsp_len; 273 #define MAX_INBAND_FRAME_SIZE 512 274 u8 pkt[MAX_INBAND_FRAME_SIZE]; 275 } __packed; 276 277 struct bss_bcn_content_tlv { 278 __le16 tag; 279 __le16 len; 280 __le16 tim_ie_pos; 281 __le16 csa_ie_pos; 282 __le16 bcc_ie_pos; 283 u8 enable; 284 u8 type; 285 __le16 pkt_len; 286 #define MAX_BEACON_SIZE 512 287 u8 pkt[MAX_BEACON_SIZE]; 288 } __packed; 289 290 struct bss_bcn_cntdwn_tlv { 291 __le16 tag; 292 __le16 len; 293 u8 cnt; 294 u8 rsv[3]; 295 } __packed; 296 297 struct bss_bcn_mbss_tlv { 298 __le16 tag; 299 __le16 len; 300 __le32 bitmap; 301 #define MAX_BEACON_NUM 32 302 __le16 offset[MAX_BEACON_NUM]; 303 } __packed __aligned(4); 304 305 struct bss_txcmd_tlv { 306 __le16 tag; 307 __le16 len; 308 u8 txcmd_mode; 309 u8 __rsv[3]; 310 } __packed; 311 312 struct bss_sec_tlv { 313 __le16 tag; 314 __le16 len; 315 u8 __rsv1[2]; 316 u8 cipher; 317 u8 __rsv2[1]; 318 } __packed; 319 320 struct bss_power_save { 321 __le16 tag; 322 __le16 len; 323 u8 profile; 324 u8 _rsv[3]; 325 } __packed; 326 327 struct bss_mld_tlv { 328 __le16 tag; 329 __le16 len; 330 u8 group_mld_id; 331 u8 own_mld_id; 332 u8 mac_addr[ETH_ALEN]; 333 u8 remap_idx; 334 u8 __rsv[3]; 335 } __packed; 336 337 struct sta_rec_ba_uni { 338 __le16 tag; 339 __le16 len; 340 u8 tid; 341 u8 ba_type; 342 u8 amsdu; 343 u8 ba_en; 344 __le16 ssn; 345 __le16 winsize; 346 u8 ba_rdd_rro; 347 u8 __rsv[3]; 348 } __packed; 349 350 struct sta_rec_eht { 351 __le16 tag; 352 __le16 len; 353 u8 tid_bitmap; 354 u8 _rsv; 355 __le16 mac_cap; 356 __le64 phy_cap; 357 __le64 phy_cap_ext; 358 u8 mcs_map_bw20[4]; 359 u8 mcs_map_bw80[3]; 360 u8 mcs_map_bw160[3]; 361 u8 mcs_map_bw320[3]; 362 u8 _rsv2[3]; 363 } __packed; 364 365 struct sec_key_uni { 366 __le16 wlan_idx; 367 u8 mgmt_prot; 368 u8 cipher_id; 369 u8 cipher_len; 370 u8 key_id; 371 u8 key_len; 372 u8 need_resp; 373 u8 key[32]; 374 } __packed; 375 376 struct sta_rec_sec_uni { 377 __le16 tag; 378 __le16 len; 379 u8 add; 380 u8 n_cipher; 381 u8 rsv[2]; 382 383 struct sec_key_uni key[2]; 384 } __packed; 385 386 struct sta_rec_hdrt { 387 __le16 tag; 388 __le16 len; 389 u8 hdrt_mode; 390 u8 rsv[3]; 391 } __packed; 392 393 struct sta_rec_hdr_trans { 394 __le16 tag; 395 __le16 len; 396 u8 from_ds; 397 u8 to_ds; 398 u8 dis_rx_hdr_tran; 399 u8 mesh; 400 } __packed; 401 402 struct hdr_trans_en { 403 __le16 tag; 404 __le16 len; 405 u8 enable; 406 u8 check_bssid; 407 u8 mode; 408 u8 __rsv; 409 } __packed; 410 411 struct hdr_trans_vlan { 412 __le16 tag; 413 __le16 len; 414 u8 insert_vlan; 415 u8 remove_vlan; 416 u8 tid; 417 u8 __rsv; 418 } __packed; 419 420 struct hdr_trans_blacklist { 421 __le16 tag; 422 __le16 len; 423 u8 idx; 424 u8 enable; 425 __le16 type; 426 } __packed; 427 428 struct uni_header { 429 u8 __rsv[4]; 430 } __packed; 431 432 struct vow_rx_airtime { 433 __le16 tag; 434 __le16 len; 435 436 u8 enable; 437 u8 band; 438 u8 __rsv[2]; 439 } __packed; 440 441 struct bf_sounding_on { 442 __le16 tag; 443 __le16 len; 444 445 u8 snd_mode; 446 u8 sta_num; 447 u8 __rsv[2]; 448 __le16 wlan_id[4]; 449 __le32 snd_period; 450 } __packed; 451 452 struct bf_hw_en_status_update { 453 __le16 tag; 454 __le16 len; 455 456 bool ebf; 457 bool ibf; 458 u8 __rsv[2]; 459 } __packed; 460 461 struct bf_mod_en_ctrl { 462 __le16 tag; 463 __le16 len; 464 465 u8 bf_num; 466 u8 bf_bitmap; 467 u8 bf_sel[8]; 468 u8 __rsv[2]; 469 } __packed; 470 471 union bf_tag_tlv { 472 struct bf_sounding_on bf_snd; 473 struct bf_hw_en_status_update bf_hw_en; 474 struct bf_mod_en_ctrl bf_mod_en; 475 }; 476 477 struct ra_rate { 478 __le16 wlan_idx; 479 u8 mode; 480 u8 stbc; 481 __le16 gi; 482 u8 bw; 483 u8 ldpc; 484 u8 mcs; 485 u8 nss; 486 __le16 ltf; 487 u8 spe; 488 u8 preamble; 489 u8 __rsv[2]; 490 } __packed; 491 492 struct ra_fixed_rate { 493 __le16 tag; 494 __le16 len; 495 496 __le16 version; 497 struct ra_rate rate; 498 } __packed; 499 500 enum { 501 UNI_RA_FIXED_RATE = 0xf, 502 }; 503 504 #define MT7996_HDR_TRANS_MAX_SIZE (sizeof(struct hdr_trans_en) + \ 505 sizeof(struct hdr_trans_vlan) + \ 506 sizeof(struct hdr_trans_blacklist)) 507 508 enum { 509 UNI_HDR_TRANS_EN, 510 UNI_HDR_TRANS_VLAN, 511 UNI_HDR_TRANS_BLACKLIST, 512 }; 513 514 enum { 515 RATE_PARAM_FIXED = 3, 516 RATE_PARAM_MMPS_UPDATE = 5, 517 RATE_PARAM_FIXED_HE_LTF = 7, 518 RATE_PARAM_FIXED_MCS, 519 RATE_PARAM_FIXED_GI = 11, 520 RATE_PARAM_AUTO = 20, 521 }; 522 523 enum { 524 BF_SOUNDING_ON = 1, 525 BF_HW_EN_UPDATE = 17, 526 BF_MOD_EN_CTRL = 20, 527 }; 528 529 enum { 530 CMD_BAND_NONE, 531 CMD_BAND_24G, 532 CMD_BAND_5G, 533 CMD_BAND_6G, 534 }; 535 536 struct bss_req_hdr { 537 u8 bss_idx; 538 u8 __rsv[3]; 539 } __packed; 540 541 enum { 542 UNI_CHANNEL_SWITCH, 543 UNI_CHANNEL_RX_PATH, 544 }; 545 546 #define MT7996_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \ 547 sizeof(struct mt76_connac_bss_basic_tlv) + \ 548 sizeof(struct bss_rlm_tlv) + \ 549 sizeof(struct bss_ra_tlv) + \ 550 sizeof(struct bss_info_uni_he) + \ 551 sizeof(struct bss_rate_tlv) + \ 552 sizeof(struct bss_txcmd_tlv) + \ 553 sizeof(struct bss_power_save) + \ 554 sizeof(struct bss_sec_tlv) + \ 555 sizeof(struct bss_mld_tlv)) 556 557 #define MT7996_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \ 558 sizeof(struct sta_rec_basic) + \ 559 sizeof(struct sta_rec_bf) + \ 560 sizeof(struct sta_rec_ht) + \ 561 sizeof(struct sta_rec_he_v2) + \ 562 sizeof(struct sta_rec_ba_uni) + \ 563 sizeof(struct sta_rec_vht) + \ 564 sizeof(struct sta_rec_uapsd) + \ 565 sizeof(struct sta_rec_amsdu) + \ 566 sizeof(struct sta_rec_bfee) + \ 567 sizeof(struct sta_rec_phy) + \ 568 sizeof(struct sta_rec_ra) + \ 569 sizeof(struct sta_rec_sec) + \ 570 sizeof(struct sta_rec_ra_fixed) + \ 571 sizeof(struct sta_rec_he_6g_capa) + \ 572 sizeof(struct sta_rec_eht) + \ 573 sizeof(struct sta_rec_hdrt) + \ 574 sizeof(struct sta_rec_hdr_trans) + \ 575 sizeof(struct tlv)) 576 577 #define MT7996_BEACON_UPDATE_SIZE (sizeof(struct bss_req_hdr) + \ 578 sizeof(struct bss_bcn_content_tlv) + \ 579 sizeof(struct bss_bcn_cntdwn_tlv) + \ 580 sizeof(struct bss_bcn_mbss_tlv)) 581 582 #define MT7996_INBAND_FRAME_SIZE (sizeof(struct bss_req_hdr) + \ 583 sizeof(struct bss_inband_discovery_tlv)) 584 585 enum { 586 UNI_BAND_CONFIG_RADIO_ENABLE, 587 UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08, 588 }; 589 590 enum { 591 UNI_WSYS_CONFIG_FW_LOG_CTRL, 592 UNI_WSYS_CONFIG_FW_DBG_CTRL, 593 }; 594 595 enum { 596 UNI_RDD_CTRL_PARM, 597 UNI_RDD_CTRL_SET_TH = 0x3, 598 }; 599 600 enum { 601 UNI_EFUSE_ACCESS = 1, 602 UNI_EFUSE_BUFFER_MODE, 603 UNI_EFUSE_FREE_BLOCK, 604 UNI_EFUSE_BUFFER_RD, 605 }; 606 607 enum { 608 UNI_VOW_DRR_CTRL, 609 UNI_VOW_RX_AT_AIRTIME_EN = 0x0b, 610 UNI_VOW_RX_AT_AIRTIME_CLR_EN = 0x0e, 611 }; 612 613 enum { 614 UNI_CMD_MIB_DATA, 615 }; 616 617 enum { 618 UNI_POWER_OFF, 619 }; 620 621 enum { 622 UNI_CMD_TWT_ARGT_UPDATE = 0x0, 623 UNI_CMD_TWT_MGMT_OFFLOAD, 624 }; 625 626 enum { 627 UNI_RRO_DEL_ENTRY = 0x1, 628 UNI_RRO_SET_PLATFORM_TYPE, 629 UNI_RRO_GET_BA_SESSION_TABLE, 630 UNI_RRO_SET_BYPASS_MODE, 631 UNI_RRO_SET_TXFREE_PATH, 632 }; 633 634 enum{ 635 UNI_CMD_SR_ENABLE = 0x1, 636 UNI_CMD_SR_ENABLE_SD, 637 UNI_CMD_SR_ENABLE_MODE, 638 UNI_CMD_SR_ENABLE_DPD = 0x12, 639 UNI_CMD_SR_ENABLE_TX, 640 UNI_CMD_SR_SET_SRG_BITMAP = 0x80, 641 UNI_CMD_SR_SET_PARAM = 0xc1, 642 UNI_CMD_SR_SET_SIGA = 0xd0, 643 }; 644 645 enum { 646 UNI_CMD_ACCESS_REG_BASIC = 0x0, 647 UNI_CMD_ACCESS_RF_REG_BASIC, 648 }; 649 650 enum { 651 UNI_CMD_SER_QUERY, 652 /* recovery */ 653 UNI_CMD_SER_SET_RECOVER_L1, 654 UNI_CMD_SER_SET_RECOVER_L2, 655 UNI_CMD_SER_SET_RECOVER_L3_RX_ABORT, 656 UNI_CMD_SER_SET_RECOVER_L3_TX_ABORT, 657 UNI_CMD_SER_SET_RECOVER_L3_TX_DISABLE, 658 UNI_CMD_SER_SET_RECOVER_L3_BF, 659 UNI_CMD_SER_SET_RECOVER_L4_MDP, 660 UNI_CMD_SER_SET_RECOVER_FULL, 661 UNI_CMD_SER_SET_SYSTEM_ASSERT, 662 /* action */ 663 UNI_CMD_SER_ENABLE = 1, 664 UNI_CMD_SER_SET, 665 UNI_CMD_SER_TRIGGER 666 }; 667 668 enum { 669 MT7996_SEC_MODE_PLAIN, 670 MT7996_SEC_MODE_AES, 671 MT7996_SEC_MODE_SCRAMBLE, 672 MT7996_SEC_MODE_MAX, 673 }; 674 675 #define MT7996_PATCH_SEC GENMASK(31, 24) 676 #define MT7996_PATCH_SCRAMBLE_KEY GENMASK(15, 8) 677 #define MT7996_PATCH_AES_KEY GENMASK(7, 0) 678 679 #define MT7996_SEC_ENCRYPT BIT(0) 680 #define MT7996_SEC_KEY_IDX GENMASK(2, 1) 681 #define MT7996_SEC_IV BIT(3) 682 683 #endif 684