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 sec_key_uni { 351 __le16 wlan_idx; 352 u8 mgmt_prot; 353 u8 cipher_id; 354 u8 cipher_len; 355 u8 key_id; 356 u8 key_len; 357 u8 need_resp; 358 u8 key[32]; 359 } __packed; 360 361 struct sta_rec_sec_uni { 362 __le16 tag; 363 __le16 len; 364 u8 add; 365 u8 n_cipher; 366 u8 rsv[2]; 367 368 struct sec_key_uni key[2]; 369 } __packed; 370 371 struct sta_rec_hdrt { 372 __le16 tag; 373 __le16 len; 374 u8 hdrt_mode; 375 u8 rsv[3]; 376 } __packed; 377 378 struct sta_rec_hdr_trans { 379 __le16 tag; 380 __le16 len; 381 u8 from_ds; 382 u8 to_ds; 383 u8 dis_rx_hdr_tran; 384 u8 rsv; 385 } __packed; 386 387 struct hdr_trans_en { 388 __le16 tag; 389 __le16 len; 390 u8 enable; 391 u8 check_bssid; 392 u8 mode; 393 u8 __rsv; 394 } __packed; 395 396 struct hdr_trans_vlan { 397 __le16 tag; 398 __le16 len; 399 u8 insert_vlan; 400 u8 remove_vlan; 401 u8 tid; 402 u8 __rsv; 403 } __packed; 404 405 struct hdr_trans_blacklist { 406 __le16 tag; 407 __le16 len; 408 u8 idx; 409 u8 enable; 410 __le16 type; 411 } __packed; 412 413 struct uni_header { 414 u8 __rsv[4]; 415 } __packed; 416 417 struct vow_rx_airtime { 418 __le16 tag; 419 __le16 len; 420 421 u8 enable; 422 u8 band; 423 u8 __rsv[2]; 424 } __packed; 425 426 struct bf_sounding_on { 427 __le16 tag; 428 __le16 len; 429 430 u8 snd_mode; 431 u8 sta_num; 432 u8 __rsv[2]; 433 __le16 wlan_id[4]; 434 __le32 snd_period; 435 } __packed; 436 437 struct bf_hw_en_status_update { 438 __le16 tag; 439 __le16 len; 440 441 bool ebf; 442 bool ibf; 443 u8 __rsv[2]; 444 } __packed; 445 446 struct bf_mod_en_ctrl { 447 __le16 tag; 448 __le16 len; 449 450 u8 bf_num; 451 u8 bf_bitmap; 452 u8 bf_sel[8]; 453 u8 __rsv[2]; 454 } __packed; 455 456 union bf_tag_tlv { 457 struct bf_sounding_on bf_snd; 458 struct bf_hw_en_status_update bf_hw_en; 459 struct bf_mod_en_ctrl bf_mod_en; 460 }; 461 462 struct ra_rate { 463 __le16 wlan_idx; 464 u8 mode; 465 u8 stbc; 466 __le16 gi; 467 u8 bw; 468 u8 ldpc; 469 u8 mcs; 470 u8 nss; 471 __le16 ltf; 472 u8 spe; 473 u8 preamble; 474 u8 __rsv[2]; 475 } __packed; 476 477 struct ra_fixed_rate { 478 __le16 tag; 479 __le16 len; 480 481 __le16 version; 482 struct ra_rate rate; 483 } __packed; 484 485 enum { 486 UNI_RA_FIXED_RATE = 0xf, 487 }; 488 489 #define MT7996_HDR_TRANS_MAX_SIZE (sizeof(struct hdr_trans_en) + \ 490 sizeof(struct hdr_trans_vlan) + \ 491 sizeof(struct hdr_trans_blacklist)) 492 493 enum { 494 UNI_HDR_TRANS_EN, 495 UNI_HDR_TRANS_VLAN, 496 UNI_HDR_TRANS_BLACKLIST, 497 }; 498 499 enum { 500 RATE_PARAM_FIXED = 3, 501 RATE_PARAM_MMPS_UPDATE = 5, 502 RATE_PARAM_FIXED_HE_LTF = 7, 503 RATE_PARAM_FIXED_MCS, 504 RATE_PARAM_FIXED_GI = 11, 505 RATE_PARAM_AUTO = 20, 506 }; 507 508 enum { 509 BF_SOUNDING_ON = 1, 510 BF_HW_EN_UPDATE = 17, 511 BF_MOD_EN_CTRL = 20, 512 }; 513 514 enum { 515 CMD_BAND_NONE, 516 CMD_BAND_24G, 517 CMD_BAND_5G, 518 CMD_BAND_6G, 519 }; 520 521 struct bss_req_hdr { 522 u8 bss_idx; 523 u8 __rsv[3]; 524 } __packed; 525 526 enum { 527 UNI_CHANNEL_SWITCH, 528 UNI_CHANNEL_RX_PATH, 529 }; 530 531 #define MT7996_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \ 532 sizeof(struct mt76_connac_bss_basic_tlv) + \ 533 sizeof(struct bss_rlm_tlv) + \ 534 sizeof(struct bss_ra_tlv) + \ 535 sizeof(struct bss_info_uni_he) + \ 536 sizeof(struct bss_rate_tlv) + \ 537 sizeof(struct bss_txcmd_tlv) + \ 538 sizeof(struct bss_power_save) + \ 539 sizeof(struct bss_sec_tlv) + \ 540 sizeof(struct bss_mld_tlv)) 541 542 #define MT7996_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \ 543 sizeof(struct sta_rec_basic) + \ 544 sizeof(struct sta_rec_bf) + \ 545 sizeof(struct sta_rec_ht) + \ 546 sizeof(struct sta_rec_he_v2) + \ 547 sizeof(struct sta_rec_ba_uni) + \ 548 sizeof(struct sta_rec_vht) + \ 549 sizeof(struct sta_rec_uapsd) + \ 550 sizeof(struct sta_rec_amsdu) + \ 551 sizeof(struct sta_rec_bfee) + \ 552 sizeof(struct sta_rec_phy) + \ 553 sizeof(struct sta_rec_ra) + \ 554 sizeof(struct sta_rec_sec) + \ 555 sizeof(struct sta_rec_ra_fixed) + \ 556 sizeof(struct sta_rec_he_6g_capa) + \ 557 sizeof(struct sta_rec_hdrt) + \ 558 sizeof(struct sta_rec_hdr_trans) + \ 559 sizeof(struct tlv)) 560 561 #define MT7996_BEACON_UPDATE_SIZE (sizeof(struct bss_req_hdr) + \ 562 sizeof(struct bss_bcn_content_tlv) + \ 563 sizeof(struct bss_bcn_cntdwn_tlv) + \ 564 sizeof(struct bss_bcn_mbss_tlv)) 565 566 #define MT7996_INBAND_FRAME_SIZE (sizeof(struct bss_req_hdr) + \ 567 sizeof(struct bss_inband_discovery_tlv)) 568 569 enum { 570 UNI_BAND_CONFIG_RADIO_ENABLE, 571 UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08, 572 }; 573 574 enum { 575 UNI_WSYS_CONFIG_FW_LOG_CTRL, 576 UNI_WSYS_CONFIG_FW_DBG_CTRL, 577 }; 578 579 enum { 580 UNI_RDD_CTRL_PARM, 581 UNI_RDD_CTRL_SET_TH = 0x3, 582 }; 583 584 enum { 585 UNI_EFUSE_ACCESS = 1, 586 UNI_EFUSE_BUFFER_MODE, 587 UNI_EFUSE_FREE_BLOCK, 588 UNI_EFUSE_BUFFER_RD, 589 }; 590 591 enum { 592 UNI_VOW_DRR_CTRL, 593 UNI_VOW_RX_AT_AIRTIME_EN = 0x0b, 594 UNI_VOW_RX_AT_AIRTIME_CLR_EN = 0x0e, 595 }; 596 597 enum { 598 UNI_CMD_MIB_DATA, 599 }; 600 601 enum { 602 UNI_POWER_OFF, 603 }; 604 605 enum { 606 UNI_CMD_TWT_ARGT_UPDATE = 0x0, 607 UNI_CMD_TWT_MGMT_OFFLOAD, 608 }; 609 610 enum { 611 UNI_RRO_DEL_ENTRY = 0x1, 612 UNI_RRO_SET_PLATFORM_TYPE, 613 UNI_RRO_GET_BA_SESSION_TABLE, 614 UNI_RRO_SET_BYPASS_MODE, 615 UNI_RRO_SET_TXFREE_PATH, 616 }; 617 618 enum{ 619 UNI_CMD_SR_ENABLE = 0x1, 620 UNI_CMD_SR_ENABLE_SD, 621 UNI_CMD_SR_ENABLE_MODE, 622 UNI_CMD_SR_ENABLE_DPD = 0x12, 623 UNI_CMD_SR_ENABLE_TX, 624 UNI_CMD_SR_SET_SRG_BITMAP = 0x80, 625 UNI_CMD_SR_SET_PARAM = 0xc1, 626 UNI_CMD_SR_SET_SIGA = 0xd0, 627 }; 628 629 enum { 630 UNI_CMD_ACCESS_REG_BASIC = 0x0, 631 UNI_CMD_ACCESS_RF_REG_BASIC, 632 }; 633 634 enum { 635 UNI_CMD_SER_QUERY = 0x0, 636 UNI_CMD_SER_SET = 0x2, 637 UNI_CMD_SER_TRIGGER = 0x3, 638 }; 639 640 enum { 641 SER_QUERY, 642 /* recovery */ 643 SER_SET_RECOVER_L1, 644 SER_SET_RECOVER_L2, 645 SER_SET_RECOVER_L3_RX_ABORT, 646 SER_SET_RECOVER_L3_TX_ABORT, 647 SER_SET_RECOVER_L3_TX_DISABLE, 648 SER_SET_RECOVER_L3_BF, 649 /* action */ 650 SER_ENABLE = 2, 651 SER_RECOVER 652 }; 653 654 enum { 655 MT7996_SEC_MODE_PLAIN, 656 MT7996_SEC_MODE_AES, 657 MT7996_SEC_MODE_SCRAMBLE, 658 MT7996_SEC_MODE_MAX, 659 }; 660 661 #define MT7996_PATCH_SEC GENMASK(31, 24) 662 #define MT7996_PATCH_SCRAMBLE_KEY GENMASK(15, 8) 663 #define MT7996_PATCH_AES_KEY GENMASK(7, 0) 664 665 #define MT7996_SEC_ENCRYPT BIT(0) 666 #define MT7996_SEC_KEY_IDX GENMASK(2, 1) 667 #define MT7996_SEC_IV BIT(3) 668 669 #endif 670