1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */ 2 /* Copyright (C) 2020 MediaTek Inc. */ 3 4 #ifndef __MT76_CONNAC_MCU_H 5 #define __MT76_CONNAC_MCU_H 6 7 #include "mt76_connac.h" 8 9 #define FW_FEATURE_SET_ENCRYPT BIT(0) 10 #define FW_FEATURE_SET_KEY_IDX GENMASK(2, 1) 11 #define FW_FEATURE_ENCRY_MODE BIT(4) 12 #define FW_FEATURE_OVERRIDE_ADDR BIT(5) 13 #define FW_FEATURE_NON_DL BIT(6) 14 15 #define DL_MODE_ENCRYPT BIT(0) 16 #define DL_MODE_KEY_IDX GENMASK(2, 1) 17 #define DL_MODE_RESET_SEC_IV BIT(3) 18 #define DL_MODE_WORKING_PDA_CR4 BIT(4) 19 #define DL_MODE_VALID_RAM_ENTRY BIT(5) 20 #define DL_CONFIG_ENCRY_MODE_SEL BIT(6) 21 #define DL_MODE_NEED_RSP BIT(31) 22 23 #define FW_START_OVERRIDE BIT(0) 24 #define FW_START_WORKING_PDA_CR4 BIT(2) 25 #define FW_START_WORKING_PDA_DSP BIT(3) 26 27 #define PATCH_SEC_NOT_SUPPORT GENMASK(31, 0) 28 #define PATCH_SEC_TYPE_MASK GENMASK(15, 0) 29 #define PATCH_SEC_TYPE_INFO 0x2 30 31 #define PATCH_SEC_ENC_TYPE_MASK GENMASK(31, 24) 32 #define PATCH_SEC_ENC_TYPE_PLAIN 0x00 33 #define PATCH_SEC_ENC_TYPE_AES 0x01 34 #define PATCH_SEC_ENC_TYPE_SCRAMBLE 0x02 35 #define PATCH_SEC_ENC_SCRAMBLE_INFO_MASK GENMASK(15, 0) 36 #define PATCH_SEC_ENC_AES_KEY_MASK GENMASK(7, 0) 37 38 enum { 39 FW_TYPE_DEFAULT = 0, 40 FW_TYPE_CLC = 2, 41 FW_TYPE_MAX_NUM = 255 42 }; 43 44 #define MCU_PQ_ID(p, q) (((p) << 15) | ((q) << 10)) 45 #define MCU_PKT_ID 0xa0 46 47 struct mt76_connac2_mcu_txd { 48 __le32 txd[8]; 49 50 __le16 len; 51 __le16 pq_id; 52 53 u8 cid; 54 u8 pkt_type; 55 u8 set_query; /* FW don't care */ 56 u8 seq; 57 58 u8 uc_d2b0_rev; 59 u8 ext_cid; 60 u8 s2d_index; 61 u8 ext_cid_ack; 62 63 u32 rsv[5]; 64 } __packed __aligned(4); 65 66 /** 67 * struct mt76_connac2_mcu_uni_txd - mcu command descriptor for connac2 and connac3 68 * @txd: hardware descriptor 69 * @len: total length not including txd 70 * @cid: command identifier 71 * @pkt_type: must be 0xa0 (cmd packet by long format) 72 * @frag_n: fragment number 73 * @seq: sequence number 74 * @checksum: 0 mean there is no checksum 75 * @s2d_index: index for command source and destination 76 * Definition | value | note 77 * CMD_S2D_IDX_H2N | 0x00 | command from HOST to WM 78 * CMD_S2D_IDX_C2N | 0x01 | command from WA to WM 79 * CMD_S2D_IDX_H2C | 0x02 | command from HOST to WA 80 * CMD_S2D_IDX_H2N_AND_H2C | 0x03 | command from HOST to WA and WM 81 * 82 * @option: command option 83 * BIT[0]: UNI_CMD_OPT_BIT_ACK 84 * set to 1 to request a fw reply 85 * if UNI_CMD_OPT_BIT_0_ACK is set and UNI_CMD_OPT_BIT_2_SET_QUERY 86 * is set, mcu firmware will send response event EID = 0x01 87 * (UNI_EVENT_ID_CMD_RESULT) to the host. 88 * BIT[1]: UNI_CMD_OPT_BIT_UNI_CMD 89 * 0: original command 90 * 1: unified command 91 * BIT[2]: UNI_CMD_OPT_BIT_SET_QUERY 92 * 0: QUERY command 93 * 1: SET command 94 */ 95 struct mt76_connac2_mcu_uni_txd { 96 __le32 txd[8]; 97 98 /* DW1 */ 99 __le16 len; 100 __le16 cid; 101 102 /* DW2 */ 103 u8 rsv; 104 u8 pkt_type; 105 u8 frag_n; 106 u8 seq; 107 108 /* DW3 */ 109 __le16 checksum; 110 u8 s2d_index; 111 u8 option; 112 113 /* DW4 */ 114 u8 rsv1[4]; 115 } __packed __aligned(4); 116 117 struct mt76_connac2_mcu_rxd { 118 /* New members MUST be added within the struct_group() macro below. */ 119 struct_group_tagged(mt76_connac2_mcu_rxd_hdr, hdr, 120 __le32 rxd[6]; 121 122 __le16 len; 123 __le16 pkt_type_id; 124 125 u8 eid; 126 u8 seq; 127 u8 option; 128 u8 rsv; 129 u8 ext_eid; 130 u8 rsv1[2]; 131 u8 s2d_index; 132 ); 133 134 u8 tlv[]; 135 }; 136 static_assert(offsetof(struct mt76_connac2_mcu_rxd, tlv) == sizeof(struct mt76_connac2_mcu_rxd_hdr), 137 "struct member likely outside of struct_group_tagged()"); 138 139 struct mt76_connac2_patch_hdr { 140 char build_date[16]; 141 char platform[4]; 142 __be32 hw_sw_ver; 143 __be32 patch_ver; 144 __be16 checksum; 145 u16 rsv; 146 struct { 147 __be32 patch_ver; 148 __be32 subsys; 149 __be32 feature; 150 __be32 n_region; 151 __be32 crc; 152 u32 rsv[11]; 153 } desc; 154 } __packed; 155 156 struct mt76_connac2_patch_sec { 157 __be32 type; 158 __be32 offs; 159 __be32 size; 160 union { 161 __be32 spec[13]; 162 struct { 163 __be32 addr; 164 __be32 len; 165 __be32 sec_key_idx; 166 __be32 align_len; 167 u32 rsv[9]; 168 } info; 169 }; 170 } __packed; 171 172 struct mt76_connac2_fw_trailer { 173 u8 chip_id; 174 u8 eco_code; 175 u8 n_region; 176 u8 format_ver; 177 u8 format_flag; 178 u8 rsv[2]; 179 char fw_ver[10]; 180 char build_date[15]; 181 __le32 crc; 182 } __packed; 183 184 struct mt76_connac2_fw_region { 185 __le32 decomp_crc; 186 __le32 decomp_len; 187 __le32 decomp_blk_sz; 188 u8 rsv[4]; 189 __le32 addr; 190 __le32 len; 191 u8 feature_set; 192 u8 type; 193 u8 rsv1[14]; 194 } __packed; 195 196 struct tlv { 197 __le16 tag; 198 __le16 len; 199 u8 data[]; 200 } __packed; 201 202 struct bss_info_omac { 203 __le16 tag; 204 __le16 len; 205 u8 hw_bss_idx; 206 u8 omac_idx; 207 u8 band_idx; 208 u8 rsv0; 209 __le32 conn_type; 210 u32 rsv1; 211 } __packed; 212 213 struct bss_info_basic { 214 __le16 tag; 215 __le16 len; 216 __le32 network_type; 217 u8 active; 218 u8 rsv0; 219 __le16 bcn_interval; 220 u8 bssid[ETH_ALEN]; 221 u8 wmm_idx; 222 u8 dtim_period; 223 u8 bmc_wcid_lo; 224 u8 cipher; 225 u8 phy_mode; 226 u8 max_bssid; /* max BSSID. range: 1 ~ 8, 0: MBSSID disabled */ 227 u8 non_tx_bssid;/* non-transmitted BSSID, 0: transmitted BSSID */ 228 u8 bmc_wcid_hi; /* high Byte and version */ 229 u8 rsv[2]; 230 } __packed; 231 232 struct bss_info_rf_ch { 233 __le16 tag; 234 __le16 len; 235 u8 pri_ch; 236 u8 center_ch0; 237 u8 center_ch1; 238 u8 bw; 239 u8 he_ru26_block; /* 1: don't send HETB in RU26, 0: allow */ 240 u8 he_all_disable; /* 1: disallow all HETB, 0: allow */ 241 u8 rsv[2]; 242 } __packed; 243 244 struct bss_info_ext_bss { 245 __le16 tag; 246 __le16 len; 247 __le32 mbss_tsf_offset; /* in unit of us */ 248 u8 rsv[8]; 249 } __packed; 250 251 enum { 252 BSS_INFO_OMAC, 253 BSS_INFO_BASIC, 254 BSS_INFO_RF_CH, /* optional, for BT/LTE coex */ 255 BSS_INFO_PM, /* sta only */ 256 BSS_INFO_UAPSD, /* sta only */ 257 BSS_INFO_ROAM_DETECT, /* obsoleted */ 258 BSS_INFO_LQ_RM, /* obsoleted */ 259 BSS_INFO_EXT_BSS, 260 BSS_INFO_BMC_RATE, /* for bmc rate control in CR4 */ 261 BSS_INFO_SYNC_MODE, /* obsoleted */ 262 BSS_INFO_RA, 263 BSS_INFO_HW_AMSDU, 264 BSS_INFO_BSS_COLOR, 265 BSS_INFO_HE_BASIC, 266 BSS_INFO_PROTECT_INFO, 267 BSS_INFO_OFFLOAD, 268 BSS_INFO_11V_MBSSID, 269 BSS_INFO_MAX_NUM 270 }; 271 272 /* sta_rec */ 273 274 struct sta_ntlv_hdr { 275 u8 rsv[2]; 276 __le16 tlv_num; 277 } __packed; 278 279 struct sta_req_hdr { 280 u8 bss_idx; 281 u8 wlan_idx_lo; 282 __le16 tlv_num; 283 u8 is_tlv_append; 284 u8 muar_idx; 285 u8 wlan_idx_hi; 286 u8 rsv; 287 } __packed; 288 289 struct sta_rec_basic { 290 __le16 tag; 291 __le16 len; 292 __le32 conn_type; 293 u8 conn_state; 294 u8 qos; 295 __le16 aid; 296 u8 peer_addr[ETH_ALEN]; 297 #define EXTRA_INFO_VER BIT(0) 298 #define EXTRA_INFO_NEW BIT(1) 299 __le16 extra_info; 300 } __packed; 301 302 struct sta_rec_ht { 303 __le16 tag; 304 __le16 len; 305 __le16 ht_cap; 306 u16 rsv; 307 } __packed; 308 309 struct sta_rec_vht { 310 __le16 tag; 311 __le16 len; 312 __le32 vht_cap; 313 __le16 vht_rx_mcs_map; 314 __le16 vht_tx_mcs_map; 315 /* mt7915 - mt7921 */ 316 u8 rts_bw_sig; 317 u8 rsv[3]; 318 } __packed; 319 320 struct sta_rec_uapsd { 321 __le16 tag; 322 __le16 len; 323 u8 dac_map; 324 u8 tac_map; 325 u8 max_sp; 326 u8 rsv0; 327 __le16 listen_interval; 328 u8 rsv1[2]; 329 } __packed; 330 331 struct sta_rec_ba { 332 __le16 tag; 333 __le16 len; 334 u8 tid; 335 u8 ba_type; 336 u8 amsdu; 337 u8 ba_en; 338 __le16 ssn; 339 __le16 winsize; 340 } __packed; 341 342 struct sta_rec_he { 343 __le16 tag; 344 __le16 len; 345 346 __le32 he_cap; 347 348 u8 t_frame_dur; 349 u8 max_ampdu_exp; 350 u8 bw_set; 351 u8 device_class; 352 u8 dcm_tx_mode; 353 u8 dcm_tx_max_nss; 354 u8 dcm_rx_mode; 355 u8 dcm_rx_max_nss; 356 u8 dcm_max_ru; 357 u8 punc_pream_rx; 358 u8 pkt_ext; 359 u8 rsv1; 360 361 __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM]; 362 363 u8 rsv2[2]; 364 } __packed; 365 366 struct sta_rec_he_v2 { 367 __le16 tag; 368 __le16 len; 369 u8 he_mac_cap[6]; 370 u8 he_phy_cap[11]; 371 u8 pkt_ext; 372 /* 0: BW80, 1: BW160, 2: BW8080 */ 373 __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM]; 374 } __packed; 375 376 struct sta_rec_amsdu { 377 __le16 tag; 378 __le16 len; 379 u8 max_amsdu_num; 380 u8 max_mpdu_size; 381 u8 amsdu_en; 382 u8 rsv; 383 } __packed; 384 385 struct sta_rec_state { 386 __le16 tag; 387 __le16 len; 388 __le32 flags; 389 u8 state; 390 u8 vht_opmode; 391 u8 action; 392 u8 rsv[1]; 393 } __packed; 394 395 #define RA_LEGACY_OFDM GENMASK(13, 6) 396 #define RA_LEGACY_CCK GENMASK(3, 0) 397 #define HT_MCS_MASK_NUM 10 398 struct sta_rec_ra_info { 399 __le16 tag; 400 __le16 len; 401 __le16 legacy; 402 u8 rx_mcs_bitmask[HT_MCS_MASK_NUM]; 403 } __packed; 404 405 struct sta_rec_phy { 406 __le16 tag; 407 __le16 len; 408 __le16 basic_rate; 409 u8 phy_type; 410 u8 ampdu; 411 u8 rts_policy; 412 u8 rcpi; 413 u8 max_ampdu_len; /* connac3 */ 414 u8 rsv[1]; 415 } __packed; 416 417 struct sta_rec_he_6g_capa { 418 __le16 tag; 419 __le16 len; 420 __le16 capa; 421 u8 rsv[2]; 422 } __packed; 423 424 struct sta_rec_pn_info { 425 __le16 tag; 426 __le16 len; 427 u8 pn[6]; 428 u8 tsc_type; 429 u8 rsv; 430 } __packed; 431 432 struct sec_key { 433 u8 cipher_id; 434 u8 cipher_len; 435 u8 key_id; 436 u8 key_len; 437 u8 key[32]; 438 } __packed; 439 440 struct sta_rec_sec { 441 __le16 tag; 442 __le16 len; 443 u8 add; 444 u8 n_cipher; 445 u8 rsv[2]; 446 447 struct sec_key key[2]; 448 } __packed; 449 450 struct sta_rec_bf { 451 __le16 tag; 452 __le16 len; 453 454 __le16 pfmu; /* 0xffff: no access right for PFMU */ 455 bool su_mu; /* 0: SU, 1: MU */ 456 u8 bf_cap; /* 0: iBF, 1: eBF */ 457 u8 sounding_phy; /* 0: legacy, 1: OFDM, 2: HT, 4: VHT */ 458 u8 ndpa_rate; 459 u8 ndp_rate; 460 u8 rept_poll_rate; 461 u8 tx_mode; /* 0: legacy, 1: OFDM, 2: HT, 4: VHT ... */ 462 u8 ncol; 463 u8 nrow; 464 u8 bw; /* 0: 20M, 1: 40M, 2: 80M, 3: 160M */ 465 466 u8 mem_total; 467 u8 mem_20m; 468 struct { 469 u8 row; 470 u8 col: 6, row_msb: 2; 471 } mem[4]; 472 473 __le16 smart_ant; 474 u8 se_idx; 475 u8 auto_sounding; /* b7: low traffic indicator 476 * b6: Stop sounding for this entry 477 * b5 ~ b0: postpone sounding 478 */ 479 u8 ibf_timeout; 480 u8 ibf_dbw; 481 u8 ibf_ncol; 482 u8 ibf_nrow; 483 u8 nrow_gt_bw80; 484 u8 ncol_gt_bw80; 485 u8 ru_start_idx; 486 u8 ru_end_idx; 487 488 bool trigger_su; 489 bool trigger_mu; 490 bool ng16_su; 491 bool ng16_mu; 492 bool codebook42_su; 493 bool codebook75_mu; 494 495 u8 he_ltf; 496 u8 rsv[3]; 497 } __packed; 498 499 struct sta_rec_bfee { 500 __le16 tag; 501 __le16 len; 502 bool fb_identity_matrix; /* 1: feedback identity matrix */ 503 bool ignore_feedback; /* 1: ignore */ 504 u8 rsv[2]; 505 } __packed; 506 507 struct sta_rec_muru { 508 __le16 tag; 509 __le16 len; 510 511 struct { 512 bool ofdma_dl_en; 513 bool ofdma_ul_en; 514 bool mimo_dl_en; 515 bool mimo_ul_en; 516 u8 rsv[4]; 517 } cfg; 518 519 struct { 520 u8 punc_pream_rx; 521 bool he_20m_in_40m_2g; 522 bool he_20m_in_160m; 523 bool he_80m_in_160m; 524 bool lt16_sigb; 525 bool rx_su_comp_sigb; 526 bool rx_su_non_comp_sigb; 527 u8 rsv; 528 } ofdma_dl; 529 530 struct { 531 u8 t_frame_dur; 532 u8 mu_cascading; 533 u8 uo_ra; 534 u8 he_2x996_tone; 535 u8 rx_t_frame_11ac; 536 u8 rx_ctrl_frame_to_mbss; 537 u8 rsv[2]; 538 } ofdma_ul; 539 540 struct { 541 bool vht_mu_bfee; 542 bool partial_bw_dl_mimo; 543 u8 rsv[2]; 544 } mimo_dl; 545 546 struct { 547 bool full_ul_mimo; 548 bool partial_ul_mimo; 549 u8 rsv[2]; 550 } mimo_ul; 551 } __packed; 552 553 struct sta_rec_remove { 554 __le16 tag; 555 __le16 len; 556 u8 action; 557 u8 pad[3]; 558 } __packed; 559 560 struct sta_phy { 561 u8 type; 562 u8 flag; 563 u8 stbc; 564 u8 sgi; 565 u8 bw; 566 u8 ldpc; 567 u8 mcs; 568 u8 nss; 569 u8 he_ltf; 570 }; 571 572 struct sta_rec_ra { 573 __le16 tag; 574 __le16 len; 575 576 u8 valid; 577 u8 auto_rate; 578 u8 phy_mode; 579 u8 channel; 580 u8 bw; 581 u8 disable_cck; 582 u8 ht_mcs32; 583 u8 ht_gf; 584 u8 ht_mcs[4]; 585 u8 mmps_mode; 586 u8 gband_256; 587 u8 af; 588 u8 auth_wapi_mode; 589 u8 rate_len; 590 591 u8 supp_mode; 592 u8 supp_cck_rate; 593 u8 supp_ofdm_rate; 594 __le32 supp_ht_mcs; 595 __le16 supp_vht_mcs[4]; 596 597 u8 op_mode; 598 u8 op_vht_chan_width; 599 u8 op_vht_rx_nss; 600 u8 op_vht_rx_nss_type; 601 602 __le32 sta_cap; 603 604 struct sta_phy phy; 605 } __packed; 606 607 struct sta_rec_ra_fixed { 608 __le16 tag; 609 __le16 len; 610 611 __le32 field; 612 u8 op_mode; 613 u8 op_vht_chan_width; 614 u8 op_vht_rx_nss; 615 u8 op_vht_rx_nss_type; 616 617 struct sta_phy phy; 618 619 u8 spe_idx; 620 u8 short_preamble; 621 u8 is_5g; 622 u8 mmps_mode; 623 } __packed; 624 625 struct sta_rec_tx_proc { 626 __le16 tag; 627 __le16 len; 628 __le32 flag; 629 } __packed; 630 631 struct sta_rec_eml_op { 632 __le16 tag; 633 __le16 len; 634 u8 link_bitmap; 635 u8 link_ant_num[3]; 636 } __packed; 637 638 /* wtbl_rec */ 639 640 struct wtbl_req_hdr { 641 u8 wlan_idx_lo; 642 u8 operation; 643 __le16 tlv_num; 644 u8 wlan_idx_hi; 645 u8 rsv[3]; 646 } __packed; 647 648 struct wtbl_generic { 649 __le16 tag; 650 __le16 len; 651 u8 peer_addr[ETH_ALEN]; 652 u8 muar_idx; 653 u8 skip_tx; 654 u8 cf_ack; 655 u8 qos; 656 u8 mesh; 657 u8 adm; 658 __le16 partial_aid; 659 u8 baf_en; 660 u8 aad_om; 661 } __packed; 662 663 struct wtbl_rx { 664 __le16 tag; 665 __le16 len; 666 u8 rcid; 667 u8 rca1; 668 u8 rca2; 669 u8 rv; 670 u8 rsv[4]; 671 } __packed; 672 673 struct wtbl_ht { 674 __le16 tag; 675 __le16 len; 676 u8 ht; 677 u8 ldpc; 678 u8 af; 679 u8 mm; 680 u8 rsv[4]; 681 } __packed; 682 683 struct wtbl_vht { 684 __le16 tag; 685 __le16 len; 686 u8 ldpc; 687 u8 dyn_bw; 688 u8 vht; 689 u8 txop_ps; 690 u8 rsv[4]; 691 } __packed; 692 693 struct wtbl_tx_ps { 694 __le16 tag; 695 __le16 len; 696 u8 txps; 697 u8 rsv[3]; 698 } __packed; 699 700 struct wtbl_hdr_trans { 701 __le16 tag; 702 __le16 len; 703 u8 to_ds; 704 u8 from_ds; 705 u8 no_rx_trans; 706 u8 rsv; 707 } __packed; 708 709 struct wtbl_ba { 710 __le16 tag; 711 __le16 len; 712 /* common */ 713 u8 tid; 714 u8 ba_type; 715 u8 rsv0[2]; 716 /* originator only */ 717 __le16 sn; 718 u8 ba_en; 719 u8 ba_winsize_idx; 720 /* originator & recipient */ 721 __le16 ba_winsize; 722 /* recipient only */ 723 u8 peer_addr[ETH_ALEN]; 724 u8 rst_ba_tid; 725 u8 rst_ba_sel; 726 u8 rst_ba_sb; 727 u8 band_idx; 728 u8 rsv1[4]; 729 } __packed; 730 731 struct wtbl_smps { 732 __le16 tag; 733 __le16 len; 734 u8 smps; 735 u8 rsv[3]; 736 } __packed; 737 738 /* mt7615 only */ 739 740 struct wtbl_bf { 741 __le16 tag; 742 __le16 len; 743 u8 ibf; 744 u8 ebf; 745 u8 ibf_vht; 746 u8 ebf_vht; 747 u8 gid; 748 u8 pfmu_idx; 749 u8 rsv[2]; 750 } __packed; 751 752 struct wtbl_pn { 753 __le16 tag; 754 __le16 len; 755 u8 pn[6]; 756 u8 rsv[2]; 757 } __packed; 758 759 struct wtbl_spe { 760 __le16 tag; 761 __le16 len; 762 u8 spe_idx; 763 u8 rsv[3]; 764 } __packed; 765 766 struct wtbl_raw { 767 __le16 tag; 768 __le16 len; 769 u8 wtbl_idx; 770 u8 dw; 771 u8 rsv[2]; 772 __le32 msk; 773 __le32 val; 774 } __packed; 775 776 #define MT76_CONNAC_WTBL_UPDATE_MAX_SIZE (sizeof(struct wtbl_req_hdr) + \ 777 sizeof(struct wtbl_generic) + \ 778 sizeof(struct wtbl_rx) + \ 779 sizeof(struct wtbl_ht) + \ 780 sizeof(struct wtbl_vht) + \ 781 sizeof(struct wtbl_tx_ps) + \ 782 sizeof(struct wtbl_hdr_trans) +\ 783 sizeof(struct wtbl_ba) + \ 784 sizeof(struct wtbl_bf) + \ 785 sizeof(struct wtbl_smps) + \ 786 sizeof(struct wtbl_pn) + \ 787 sizeof(struct wtbl_spe)) 788 789 #define MT76_CONNAC_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \ 790 sizeof(struct sta_rec_basic) + \ 791 sizeof(struct sta_rec_bf) + \ 792 sizeof(struct sta_rec_ht) + \ 793 sizeof(struct sta_rec_he) + \ 794 sizeof(struct sta_rec_ba) + \ 795 sizeof(struct sta_rec_vht) + \ 796 sizeof(struct sta_rec_uapsd) + \ 797 sizeof(struct sta_rec_amsdu) + \ 798 sizeof(struct sta_rec_muru) + \ 799 sizeof(struct sta_rec_bfee) + \ 800 sizeof(struct sta_rec_ra) + \ 801 sizeof(struct sta_rec_sec) + \ 802 sizeof(struct sta_rec_ra_fixed) + \ 803 sizeof(struct sta_rec_he_6g_capa) + \ 804 sizeof(struct sta_rec_pn_info) + \ 805 sizeof(struct sta_rec_tx_proc) + \ 806 sizeof(struct sta_rec_eml_op) + \ 807 sizeof(struct tlv) + \ 808 MT76_CONNAC_WTBL_UPDATE_MAX_SIZE) 809 810 enum { 811 STA_REC_BASIC, 812 STA_REC_RA, 813 STA_REC_RA_CMM_INFO, 814 STA_REC_RA_UPDATE, 815 STA_REC_BF, 816 STA_REC_AMSDU, 817 STA_REC_BA, 818 STA_REC_STATE, 819 STA_REC_TX_PROC, /* for hdr trans and CSO in CR4 */ 820 STA_REC_HT, 821 STA_REC_VHT, 822 STA_REC_APPS, 823 STA_REC_KEY, 824 STA_REC_WTBL, 825 STA_REC_HE, 826 STA_REC_HW_AMSDU, 827 STA_REC_WTBL_AADOM, 828 STA_REC_KEY_V2, 829 STA_REC_MURU, 830 STA_REC_MUEDCA, 831 STA_REC_BFEE, 832 STA_REC_PHY = 0x15, 833 STA_REC_HE_6G = 0x17, 834 STA_REC_HE_V2 = 0x19, 835 STA_REC_MLD = 0x20, 836 STA_REC_EHT_MLD = 0x21, 837 STA_REC_EHT = 0x22, 838 STA_REC_MLD_OFF = 0x23, 839 STA_REC_REMOVE = 0x25, 840 STA_REC_PN_INFO = 0x26, 841 STA_REC_KEY_V3 = 0x27, 842 STA_REC_HDRT = 0x28, 843 STA_REC_EML_OP = 0x29, 844 STA_REC_HDR_TRANS = 0x2B, 845 STA_REC_MAX_NUM 846 }; 847 848 enum { 849 WTBL_GENERIC, 850 WTBL_RX, 851 WTBL_HT, 852 WTBL_VHT, 853 WTBL_PEER_PS, /* not used */ 854 WTBL_TX_PS, 855 WTBL_HDR_TRANS, 856 WTBL_SEC_KEY, 857 WTBL_BA, 858 WTBL_RDG, /* obsoleted */ 859 WTBL_PROTECT, /* not used */ 860 WTBL_CLEAR, /* not used */ 861 WTBL_BF, 862 WTBL_SMPS, 863 WTBL_RAW_DATA, /* debug only */ 864 WTBL_PN, 865 WTBL_SPE, 866 WTBL_MAX_NUM 867 }; 868 869 #define STA_TYPE_STA BIT(0) 870 #define STA_TYPE_AP BIT(1) 871 #define STA_TYPE_ADHOC BIT(2) 872 #define STA_TYPE_WDS BIT(4) 873 #define STA_TYPE_BC BIT(5) 874 875 #define NETWORK_INFRA BIT(16) 876 #define NETWORK_P2P BIT(17) 877 #define NETWORK_IBSS BIT(18) 878 #define NETWORK_WDS BIT(21) 879 880 #define SCAN_FUNC_RANDOM_MAC BIT(0) 881 #define SCAN_FUNC_RNR_SCAN BIT(3) 882 #define SCAN_FUNC_SPLIT_SCAN BIT(5) 883 884 #define CONNECTION_INFRA_STA (STA_TYPE_STA | NETWORK_INFRA) 885 #define CONNECTION_INFRA_AP (STA_TYPE_AP | NETWORK_INFRA) 886 #define CONNECTION_P2P_GC (STA_TYPE_STA | NETWORK_P2P) 887 #define CONNECTION_P2P_GO (STA_TYPE_AP | NETWORK_P2P) 888 #define CONNECTION_IBSS_ADHOC (STA_TYPE_ADHOC | NETWORK_IBSS) 889 #define CONNECTION_WDS (STA_TYPE_WDS | NETWORK_WDS) 890 #define CONNECTION_INFRA_BC (STA_TYPE_BC | NETWORK_INFRA) 891 892 #define CONN_STATE_DISCONNECT 0 893 #define CONN_STATE_CONNECT 1 894 #define CONN_STATE_PORT_SECURE 2 895 896 /* HE MAC */ 897 #define STA_REC_HE_CAP_HTC BIT(0) 898 #define STA_REC_HE_CAP_BQR BIT(1) 899 #define STA_REC_HE_CAP_BSR BIT(2) 900 #define STA_REC_HE_CAP_OM BIT(3) 901 #define STA_REC_HE_CAP_AMSDU_IN_AMPDU BIT(4) 902 /* HE PHY */ 903 #define STA_REC_HE_CAP_DUAL_BAND BIT(5) 904 #define STA_REC_HE_CAP_LDPC BIT(6) 905 #define STA_REC_HE_CAP_TRIG_CQI_FK BIT(7) 906 #define STA_REC_HE_CAP_PARTIAL_BW_EXT_RANGE BIT(8) 907 /* STBC */ 908 #define STA_REC_HE_CAP_LE_EQ_80M_TX_STBC BIT(9) 909 #define STA_REC_HE_CAP_LE_EQ_80M_RX_STBC BIT(10) 910 #define STA_REC_HE_CAP_GT_80M_TX_STBC BIT(11) 911 #define STA_REC_HE_CAP_GT_80M_RX_STBC BIT(12) 912 /* GI */ 913 #define STA_REC_HE_CAP_SU_PPDU_1LTF_8US_GI BIT(13) 914 #define STA_REC_HE_CAP_SU_MU_PPDU_4LTF_8US_GI BIT(14) 915 #define STA_REC_HE_CAP_ER_SU_PPDU_1LTF_8US_GI BIT(15) 916 #define STA_REC_HE_CAP_ER_SU_PPDU_4LTF_8US_GI BIT(16) 917 #define STA_REC_HE_CAP_NDP_4LTF_3DOT2MS_GI BIT(17) 918 /* 242 TONE */ 919 #define STA_REC_HE_CAP_BW20_RU242_SUPPORT BIT(18) 920 #define STA_REC_HE_CAP_TX_1024QAM_UNDER_RU242 BIT(19) 921 #define STA_REC_HE_CAP_RX_1024QAM_UNDER_RU242 BIT(20) 922 923 #define PHY_MODE_A BIT(0) 924 #define PHY_MODE_B BIT(1) 925 #define PHY_MODE_G BIT(2) 926 #define PHY_MODE_GN BIT(3) 927 #define PHY_MODE_AN BIT(4) 928 #define PHY_MODE_AC BIT(5) 929 #define PHY_MODE_AX_24G BIT(6) 930 #define PHY_MODE_AX_5G BIT(7) 931 932 #define PHY_MODE_AX_6G BIT(0) /* phymode_ext */ 933 #define PHY_MODE_BE_24G BIT(1) 934 #define PHY_MODE_BE_5G BIT(2) 935 #define PHY_MODE_BE_6G BIT(3) 936 937 #define MODE_CCK BIT(0) 938 #define MODE_OFDM BIT(1) 939 #define MODE_HT BIT(2) 940 #define MODE_VHT BIT(3) 941 #define MODE_HE BIT(4) 942 #define MODE_EHT BIT(5) 943 944 #define STA_CAP_WMM BIT(0) 945 #define STA_CAP_SGI_20 BIT(4) 946 #define STA_CAP_SGI_40 BIT(5) 947 #define STA_CAP_TX_STBC BIT(6) 948 #define STA_CAP_RX_STBC BIT(7) 949 #define STA_CAP_VHT_SGI_80 BIT(16) 950 #define STA_CAP_VHT_SGI_160 BIT(17) 951 #define STA_CAP_VHT_TX_STBC BIT(18) 952 #define STA_CAP_VHT_RX_STBC BIT(19) 953 #define STA_CAP_VHT_LDPC BIT(23) 954 #define STA_CAP_LDPC BIT(24) 955 #define STA_CAP_HT BIT(26) 956 #define STA_CAP_VHT BIT(27) 957 #define STA_CAP_HE BIT(28) 958 959 enum { 960 PHY_TYPE_HR_DSSS_INDEX = 0, 961 PHY_TYPE_ERP_INDEX, 962 PHY_TYPE_ERP_P2P_INDEX, 963 PHY_TYPE_OFDM_INDEX, 964 PHY_TYPE_HT_INDEX, 965 PHY_TYPE_VHT_INDEX, 966 PHY_TYPE_HE_INDEX, 967 PHY_TYPE_BE_INDEX, 968 PHY_TYPE_INDEX_NUM 969 }; 970 971 #define HR_DSSS_ERP_BASIC_RATE GENMASK(3, 0) 972 #define OFDM_BASIC_RATE (BIT(6) | BIT(8) | BIT(10)) 973 974 #define PHY_TYPE_BIT_HR_DSSS BIT(PHY_TYPE_HR_DSSS_INDEX) 975 #define PHY_TYPE_BIT_ERP BIT(PHY_TYPE_ERP_INDEX) 976 #define PHY_TYPE_BIT_OFDM BIT(PHY_TYPE_OFDM_INDEX) 977 #define PHY_TYPE_BIT_HT BIT(PHY_TYPE_HT_INDEX) 978 #define PHY_TYPE_BIT_VHT BIT(PHY_TYPE_VHT_INDEX) 979 #define PHY_TYPE_BIT_HE BIT(PHY_TYPE_HE_INDEX) 980 #define PHY_TYPE_BIT_BE BIT(PHY_TYPE_BE_INDEX) 981 982 #define MT_WTBL_RATE_TX_MODE GENMASK(9, 6) 983 #define MT_WTBL_RATE_MCS GENMASK(5, 0) 984 #define MT_WTBL_RATE_NSS GENMASK(12, 10) 985 #define MT_WTBL_RATE_HE_GI GENMASK(7, 4) 986 #define MT_WTBL_RATE_GI GENMASK(3, 0) 987 988 #define MT_WTBL_W5_CHANGE_BW_RATE GENMASK(7, 5) 989 #define MT_WTBL_W5_SHORT_GI_20 BIT(8) 990 #define MT_WTBL_W5_SHORT_GI_40 BIT(9) 991 #define MT_WTBL_W5_SHORT_GI_80 BIT(10) 992 #define MT_WTBL_W5_SHORT_GI_160 BIT(11) 993 #define MT_WTBL_W5_BW_CAP GENMASK(13, 12) 994 #define MT_WTBL_W5_MPDU_FAIL_COUNT GENMASK(25, 23) 995 #define MT_WTBL_W5_MPDU_OK_COUNT GENMASK(28, 26) 996 #define MT_WTBL_W5_RATE_IDX GENMASK(31, 29) 997 998 enum { 999 WTBL_RESET_AND_SET = 1, 1000 WTBL_SET, 1001 WTBL_QUERY, 1002 WTBL_RESET_ALL 1003 }; 1004 1005 enum { 1006 MT_BA_TYPE_INVALID, 1007 MT_BA_TYPE_ORIGINATOR, 1008 MT_BA_TYPE_RECIPIENT 1009 }; 1010 1011 enum { 1012 RST_BA_MAC_TID_MATCH, 1013 RST_BA_MAC_MATCH, 1014 RST_BA_NO_MATCH 1015 }; 1016 1017 enum { 1018 DEV_INFO_ACTIVE, 1019 DEV_INFO_MAX_NUM 1020 }; 1021 1022 /* event table */ 1023 enum { 1024 MCU_EVENT_TARGET_ADDRESS_LEN = 0x01, 1025 MCU_EVENT_FW_START = 0x01, 1026 MCU_EVENT_GENERIC = 0x01, 1027 MCU_EVENT_ACCESS_REG = 0x02, 1028 MCU_EVENT_MT_PATCH_SEM = 0x04, 1029 MCU_EVENT_REG_ACCESS = 0x05, 1030 MCU_EVENT_LP_INFO = 0x07, 1031 MCU_EVENT_SCAN_DONE = 0x0d, 1032 MCU_EVENT_TX_DONE = 0x0f, 1033 MCU_EVENT_ROC = 0x10, 1034 MCU_EVENT_BSS_ABSENCE = 0x11, 1035 MCU_EVENT_BSS_BEACON_LOSS = 0x13, 1036 MCU_EVENT_CH_PRIVILEGE = 0x18, 1037 MCU_EVENT_SCHED_SCAN_DONE = 0x23, 1038 MCU_EVENT_DBG_MSG = 0x27, 1039 MCU_EVENT_RSSI_NOTIFY = 0x96, 1040 MCU_EVENT_TXPWR = 0xd0, 1041 MCU_EVENT_EXT = 0xed, 1042 MCU_EVENT_RESTART_DL = 0xef, 1043 MCU_EVENT_COREDUMP = 0xf0, 1044 }; 1045 1046 /* ext event table */ 1047 enum { 1048 MCU_EXT_EVENT_PS_SYNC = 0x5, 1049 MCU_EXT_EVENT_FW_LOG_2_HOST = 0x13, 1050 MCU_EXT_EVENT_THERMAL_PROTECT = 0x22, 1051 MCU_EXT_EVENT_ASSERT_DUMP = 0x23, 1052 MCU_EXT_EVENT_RDD_REPORT = 0x3a, 1053 MCU_EXT_EVENT_CSA_NOTIFY = 0x4f, 1054 MCU_EXT_EVENT_WA_TX_STAT = 0x74, 1055 MCU_EXT_EVENT_BCC_NOTIFY = 0x75, 1056 MCU_EXT_EVENT_WF_RF_PIN_CTRL = 0x9a, 1057 MCU_EXT_EVENT_MURU_CTRL = 0x9f, 1058 }; 1059 1060 /* unified event table */ 1061 enum { 1062 MCU_UNI_EVENT_RESULT = 0x01, 1063 MCU_UNI_EVENT_HIF_CTRL = 0x03, 1064 MCU_UNI_EVENT_FW_LOG_2_HOST = 0x04, 1065 MCU_UNI_EVENT_ACCESS_REG = 0x6, 1066 MCU_UNI_EVENT_IE_COUNTDOWN = 0x09, 1067 MCU_UNI_EVENT_COREDUMP = 0x0a, 1068 MCU_UNI_EVENT_BSS_BEACON_LOSS = 0x0c, 1069 MCU_UNI_EVENT_SCAN_DONE = 0x0e, 1070 MCU_UNI_EVENT_RDD_REPORT = 0x11, 1071 MCU_UNI_EVENT_ROC = 0x27, 1072 MCU_UNI_EVENT_TX_DONE = 0x2d, 1073 MCU_UNI_EVENT_THERMAL = 0x35, 1074 MCU_UNI_EVENT_RSSI_MONITOR = 0x41, 1075 MCU_UNI_EVENT_NIC_CAPAB = 0x43, 1076 MCU_UNI_EVENT_WED_RRO = 0x57, 1077 MCU_UNI_EVENT_PER_STA_INFO = 0x6d, 1078 MCU_UNI_EVENT_ALL_STA_INFO = 0x6e, 1079 MCU_UNI_EVENT_SDO = 0x83, 1080 }; 1081 1082 #define MCU_UNI_CMD_EVENT BIT(1) 1083 #define MCU_UNI_CMD_UNSOLICITED_EVENT BIT(2) 1084 1085 enum { 1086 MCU_Q_QUERY, 1087 MCU_Q_SET, 1088 MCU_Q_RESERVED, 1089 MCU_Q_NA 1090 }; 1091 1092 enum { 1093 MCU_S2D_H2N, 1094 MCU_S2D_C2N, 1095 MCU_S2D_H2C, 1096 MCU_S2D_H2CN 1097 }; 1098 1099 enum { 1100 PATCH_NOT_DL_SEM_FAIL, 1101 PATCH_IS_DL, 1102 PATCH_NOT_DL_SEM_SUCCESS, 1103 PATCH_REL_SEM_SUCCESS 1104 }; 1105 1106 enum { 1107 FW_STATE_INITIAL, 1108 FW_STATE_FW_DOWNLOAD, 1109 FW_STATE_NORMAL_OPERATION, 1110 FW_STATE_NORMAL_TRX, 1111 FW_STATE_RDY = 7 1112 }; 1113 1114 enum { 1115 CH_SWITCH_NORMAL = 0, 1116 CH_SWITCH_SCAN = 3, 1117 CH_SWITCH_MCC = 4, 1118 CH_SWITCH_DFS = 5, 1119 CH_SWITCH_BACKGROUND_SCAN_START = 6, 1120 CH_SWITCH_BACKGROUND_SCAN_RUNNING = 7, 1121 CH_SWITCH_BACKGROUND_SCAN_STOP = 8, 1122 CH_SWITCH_SCAN_BYPASS_DPD = 9 1123 }; 1124 1125 enum { 1126 THERMAL_SENSOR_TEMP_QUERY, 1127 THERMAL_SENSOR_MANUAL_CTRL, 1128 THERMAL_SENSOR_INFO_QUERY, 1129 THERMAL_SENSOR_TASK_CTRL, 1130 }; 1131 1132 enum mcu_cipher_type { 1133 MCU_CIPHER_NONE = 0, 1134 MCU_CIPHER_WEP40, 1135 MCU_CIPHER_WEP104, 1136 MCU_CIPHER_WEP128, 1137 MCU_CIPHER_TKIP, 1138 MCU_CIPHER_AES_CCMP, 1139 MCU_CIPHER_CCMP_256, 1140 MCU_CIPHER_GCMP, 1141 MCU_CIPHER_GCMP_256, 1142 MCU_CIPHER_WAPI, 1143 MCU_CIPHER_BIP_CMAC_128, 1144 MCU_CIPHER_BIP_CMAC_256, 1145 MCU_CIPHER_BCN_PROT_CMAC_128, 1146 MCU_CIPHER_BCN_PROT_CMAC_256, 1147 MCU_CIPHER_BCN_PROT_GMAC_128, 1148 MCU_CIPHER_BCN_PROT_GMAC_256, 1149 MCU_CIPHER_BIP_GMAC_128, 1150 MCU_CIPHER_BIP_GMAC_256, 1151 }; 1152 1153 enum { 1154 EE_MODE_EFUSE, 1155 EE_MODE_BUFFER, 1156 }; 1157 1158 enum { 1159 EE_FORMAT_BIN, 1160 EE_FORMAT_WHOLE, 1161 EE_FORMAT_MULTIPLE, 1162 }; 1163 1164 enum { 1165 MCU_PHY_STATE_TX_RATE, 1166 MCU_PHY_STATE_RX_RATE, 1167 MCU_PHY_STATE_RSSI, 1168 MCU_PHY_STATE_CONTENTION_RX_RATE, 1169 MCU_PHY_STATE_OFDMLQ_CNINFO, 1170 }; 1171 1172 #define MCU_CMD_ACK BIT(0) 1173 #define MCU_CMD_UNI BIT(1) 1174 #define MCU_CMD_SET BIT(2) 1175 1176 #define MCU_CMD_UNI_EXT_ACK (MCU_CMD_ACK | MCU_CMD_UNI | \ 1177 MCU_CMD_SET) 1178 #define MCU_CMD_UNI_QUERY_ACK (MCU_CMD_ACK | MCU_CMD_UNI) 1179 1180 #define __MCU_CMD_FIELD_ID GENMASK(7, 0) 1181 #define __MCU_CMD_FIELD_EXT_ID GENMASK(15, 8) 1182 #define __MCU_CMD_FIELD_QUERY BIT(16) 1183 #define __MCU_CMD_FIELD_UNI BIT(17) 1184 #define __MCU_CMD_FIELD_CE BIT(18) 1185 #define __MCU_CMD_FIELD_WA BIT(19) 1186 #define __MCU_CMD_FIELD_WM BIT(20) 1187 1188 #define MCU_CMD(_t) FIELD_PREP(__MCU_CMD_FIELD_ID, \ 1189 MCU_CMD_##_t) 1190 #define MCU_EXT_CMD(_t) (MCU_CMD(EXT_CID) | \ 1191 FIELD_PREP(__MCU_CMD_FIELD_EXT_ID, \ 1192 MCU_EXT_CMD_##_t)) 1193 #define MCU_EXT_QUERY(_t) (MCU_EXT_CMD(_t) | __MCU_CMD_FIELD_QUERY) 1194 #define MCU_UNI_CMD(_t) (__MCU_CMD_FIELD_UNI | \ 1195 FIELD_PREP(__MCU_CMD_FIELD_ID, \ 1196 MCU_UNI_CMD_##_t)) 1197 1198 #define MCU_UNI_QUERY(_t) (__MCU_CMD_FIELD_UNI | __MCU_CMD_FIELD_QUERY | \ 1199 FIELD_PREP(__MCU_CMD_FIELD_ID, \ 1200 MCU_UNI_CMD_##_t)) 1201 1202 #define MCU_CE_CMD(_t) (__MCU_CMD_FIELD_CE | \ 1203 FIELD_PREP(__MCU_CMD_FIELD_ID, \ 1204 MCU_CE_CMD_##_t)) 1205 #define MCU_CE_QUERY(_t) (MCU_CE_CMD(_t) | __MCU_CMD_FIELD_QUERY) 1206 1207 #define MCU_WA_CMD(_t) (MCU_CMD(_t) | __MCU_CMD_FIELD_WA) 1208 #define MCU_WA_EXT_CMD(_t) (MCU_EXT_CMD(_t) | __MCU_CMD_FIELD_WA) 1209 #define MCU_WA_PARAM_CMD(_t) (MCU_WA_CMD(WA_PARAM) | \ 1210 FIELD_PREP(__MCU_CMD_FIELD_EXT_ID, \ 1211 MCU_WA_PARAM_CMD_##_t)) 1212 1213 #define MCU_WM_UNI_CMD(_t) (MCU_UNI_CMD(_t) | \ 1214 __MCU_CMD_FIELD_WM) 1215 #define MCU_WM_UNI_CMD_QUERY(_t) (MCU_UNI_CMD(_t) | \ 1216 __MCU_CMD_FIELD_QUERY | \ 1217 __MCU_CMD_FIELD_WM) 1218 #define MCU_WA_UNI_CMD(_t) (MCU_UNI_CMD(_t) | \ 1219 __MCU_CMD_FIELD_WA) 1220 #define MCU_WMWA_UNI_CMD(_t) (MCU_WM_UNI_CMD(_t) | \ 1221 __MCU_CMD_FIELD_WA) 1222 1223 enum { 1224 MCU_EXT_CMD_EFUSE_ACCESS = 0x01, 1225 MCU_EXT_CMD_RF_REG_ACCESS = 0x02, 1226 MCU_EXT_CMD_RF_TEST = 0x04, 1227 MCU_EXT_CMD_ID_RADIO_ON_OFF_CTRL = 0x05, 1228 MCU_EXT_CMD_PM_STATE_CTRL = 0x07, 1229 MCU_EXT_CMD_CHANNEL_SWITCH = 0x08, 1230 MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11, 1231 MCU_EXT_CMD_FW_LOG_2_HOST = 0x13, 1232 MCU_EXT_CMD_TXBF_ACTION = 0x1e, 1233 MCU_EXT_CMD_EFUSE_BUFFER_MODE = 0x21, 1234 MCU_EXT_CMD_THERMAL_PROT = 0x23, 1235 MCU_EXT_CMD_STA_REC_UPDATE = 0x25, 1236 MCU_EXT_CMD_BSS_INFO_UPDATE = 0x26, 1237 MCU_EXT_CMD_EDCA_UPDATE = 0x27, 1238 MCU_EXT_CMD_DEV_INFO_UPDATE = 0x2A, 1239 MCU_EXT_CMD_THERMAL_CTRL = 0x2c, 1240 MCU_EXT_CMD_WTBL_UPDATE = 0x32, 1241 MCU_EXT_CMD_SET_DRR_CTRL = 0x36, 1242 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a, 1243 MCU_EXT_CMD_ATE_CTRL = 0x3d, 1244 MCU_EXT_CMD_PROTECT_CTRL = 0x3e, 1245 MCU_EXT_CMD_DBDC_CTRL = 0x45, 1246 MCU_EXT_CMD_MAC_INIT_CTRL = 0x46, 1247 MCU_EXT_CMD_RX_HDR_TRANS = 0x47, 1248 MCU_EXT_CMD_MUAR_UPDATE = 0x48, 1249 MCU_EXT_CMD_BCN_OFFLOAD = 0x49, 1250 MCU_EXT_CMD_RX_AIRTIME_CTRL = 0x4a, 1251 MCU_EXT_CMD_SET_RX_PATH = 0x4e, 1252 MCU_EXT_CMD_EFUSE_FREE_BLOCK = 0x4f, 1253 MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58, 1254 MCU_EXT_CMD_RXDCOC_CAL = 0x59, 1255 MCU_EXT_CMD_GET_MIB_INFO = 0x5a, 1256 MCU_EXT_CMD_TXDPD_CAL = 0x60, 1257 MCU_EXT_CMD_CAL_CACHE = 0x67, 1258 MCU_EXT_CMD_RED_ENABLE = 0x68, 1259 MCU_EXT_CMD_CP_SUPPORT = 0x75, 1260 MCU_EXT_CMD_SET_RADAR_TH = 0x7c, 1261 MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d, 1262 MCU_EXT_CMD_MWDS_SUPPORT = 0x80, 1263 MCU_EXT_CMD_SET_SER_TRIGGER = 0x81, 1264 MCU_EXT_CMD_TWT_AGRT_UPDATE = 0x94, 1265 MCU_EXT_CMD_FW_DBG_CTRL = 0x95, 1266 MCU_EXT_CMD_OFFCH_SCAN_CTRL = 0x9a, 1267 MCU_EXT_CMD_SET_RDD_TH = 0x9d, 1268 MCU_EXT_CMD_MURU_CTRL = 0x9f, 1269 MCU_EXT_CMD_SET_SPR = 0xa8, 1270 MCU_EXT_CMD_GROUP_PRE_CAL_INFO = 0xab, 1271 MCU_EXT_CMD_DPD_PRE_CAL_INFO = 0xac, 1272 MCU_EXT_CMD_PHY_STAT_INFO = 0xad, 1273 MCU_EXT_CMD_WF_RF_PIN_CTRL = 0xbd, 1274 }; 1275 1276 enum { 1277 MCU_UNI_CMD_DEV_INFO_UPDATE = 0x01, 1278 MCU_UNI_CMD_BSS_INFO_UPDATE = 0x02, 1279 MCU_UNI_CMD_STA_REC_UPDATE = 0x03, 1280 MCU_UNI_CMD_EDCA_UPDATE = 0x04, 1281 MCU_UNI_CMD_SUSPEND = 0x05, 1282 MCU_UNI_CMD_OFFLOAD = 0x06, 1283 MCU_UNI_CMD_HIF_CTRL = 0x07, 1284 MCU_UNI_CMD_BAND_CONFIG = 0x08, 1285 MCU_UNI_CMD_REPT_MUAR = 0x09, 1286 MCU_UNI_CMD_WSYS_CONFIG = 0x0b, 1287 MCU_UNI_CMD_REG_ACCESS = 0x0d, 1288 MCU_UNI_CMD_CHIP_CONFIG = 0x0e, 1289 MCU_UNI_CMD_POWER_CTRL = 0x0f, 1290 MCU_UNI_CMD_RX_HDR_TRANS = 0x12, 1291 MCU_UNI_CMD_SER = 0x13, 1292 MCU_UNI_CMD_TWT = 0x14, 1293 MCU_UNI_CMD_SET_DOMAIN_INFO = 0x15, 1294 MCU_UNI_CMD_SCAN_REQ = 0x16, 1295 MCU_UNI_CMD_RDD_CTRL = 0x19, 1296 MCU_UNI_CMD_GET_MIB_INFO = 0x22, 1297 MCU_UNI_CMD_GET_STAT_INFO = 0x23, 1298 MCU_UNI_CMD_SNIFFER = 0x24, 1299 MCU_UNI_CMD_SR = 0x25, 1300 MCU_UNI_CMD_ROC = 0x27, 1301 MCU_UNI_CMD_SET_DBDC_PARMS = 0x28, 1302 MCU_UNI_CMD_TXPOWER = 0x2b, 1303 MCU_UNI_CMD_SET_POWER_LIMIT = 0x2c, 1304 MCU_UNI_CMD_EFUSE_CTRL = 0x2d, 1305 MCU_UNI_CMD_RA = 0x2f, 1306 MCU_UNI_CMD_MURU = 0x31, 1307 MCU_UNI_CMD_TESTMODE_RX_STAT = 0x32, 1308 MCU_UNI_CMD_BF = 0x33, 1309 MCU_UNI_CMD_CHANNEL_SWITCH = 0x34, 1310 MCU_UNI_CMD_THERMAL = 0x35, 1311 MCU_UNI_CMD_VOW = 0x37, 1312 MCU_UNI_CMD_FIXED_RATE_TABLE = 0x40, 1313 MCU_UNI_CMD_RSSI_MONITOR = 0x41, 1314 MCU_UNI_CMD_TESTMODE_CTRL = 0x46, 1315 MCU_UNI_CMD_RRO = 0x57, 1316 MCU_UNI_CMD_OFFCH_SCAN_CTRL = 0x58, 1317 MCU_UNI_CMD_PER_STA_INFO = 0x6d, 1318 MCU_UNI_CMD_ALL_STA_INFO = 0x6e, 1319 MCU_UNI_CMD_ASSERT_DUMP = 0x6f, 1320 MCU_UNI_CMD_EXT_EEPROM_CTRL = 0x74, 1321 MCU_UNI_CMD_RADIO_STATUS = 0x80, 1322 MCU_UNI_CMD_MLD = 0x82, 1323 MCU_UNI_CMD_SDO = 0x88, 1324 }; 1325 1326 enum { 1327 MCU_CMD_TARGET_ADDRESS_LEN_REQ = 0x01, 1328 MCU_CMD_FW_START_REQ = 0x02, 1329 MCU_CMD_INIT_ACCESS_REG = 0x3, 1330 MCU_CMD_NIC_POWER_CTRL = 0x4, 1331 MCU_CMD_PATCH_START_REQ = 0x05, 1332 MCU_CMD_PATCH_FINISH_REQ = 0x07, 1333 MCU_CMD_PATCH_SEM_CONTROL = 0x10, 1334 MCU_CMD_WA_PARAM = 0xc4, 1335 MCU_CMD_EXT_CID = 0xed, 1336 MCU_CMD_FW_SCATTER = 0xee, 1337 MCU_CMD_RESTART_DL_REQ = 0xef, 1338 }; 1339 1340 /* offload mcu commands */ 1341 enum { 1342 MCU_CE_CMD_TEST_CTRL = 0x01, 1343 MCU_CE_CMD_START_HW_SCAN = 0x03, 1344 MCU_CE_CMD_SET_PS_PROFILE = 0x05, 1345 MCU_CE_CMD_SET_RX_FILTER = 0x0a, 1346 MCU_CE_CMD_SET_CHAN_DOMAIN = 0x0f, 1347 MCU_CE_CMD_SET_BSS_CONNECTED = 0x16, 1348 MCU_CE_CMD_SET_BSS_ABORT = 0x17, 1349 MCU_CE_CMD_CANCEL_HW_SCAN = 0x1b, 1350 MCU_CE_CMD_SET_ROC = 0x1c, 1351 MCU_CE_CMD_SET_EDCA_PARMS = 0x1d, 1352 MCU_CE_CMD_SET_P2P_OPPPS = 0x33, 1353 MCU_CE_CMD_SET_CLC = 0x5c, 1354 MCU_CE_CMD_SET_RATE_TX_POWER = 0x5d, 1355 MCU_CE_CMD_SCHED_SCAN_ENABLE = 0x61, 1356 MCU_CE_CMD_SCHED_SCAN_REQ = 0x62, 1357 MCU_CE_CMD_GET_NIC_CAPAB = 0x8a, 1358 MCU_CE_CMD_RSSI_MONITOR = 0xa1, 1359 MCU_CE_CMD_SET_MU_EDCA_PARMS = 0xb0, 1360 MCU_CE_CMD_REG_WRITE = 0xc0, 1361 MCU_CE_CMD_REG_READ = 0xc0, 1362 MCU_CE_CMD_CHIP_CONFIG = 0xca, 1363 MCU_CE_CMD_FWLOG_2_HOST = 0xc5, 1364 MCU_CE_CMD_GET_WTBL = 0xcd, 1365 MCU_CE_CMD_GET_TXPWR = 0xd0, 1366 }; 1367 1368 enum { 1369 PATCH_SEM_RELEASE, 1370 PATCH_SEM_GET 1371 }; 1372 1373 enum { 1374 UNI_BSS_INFO_BASIC = 0, 1375 UNI_BSS_INFO_RA = 1, 1376 UNI_BSS_INFO_RLM = 2, 1377 UNI_BSS_INFO_PROTECT_INFO = 3, 1378 UNI_BSS_INFO_BSS_COLOR = 4, 1379 UNI_BSS_INFO_HE_BASIC = 5, 1380 UNI_BSS_INFO_11V_MBSSID = 6, 1381 UNI_BSS_INFO_BCN_CONTENT = 7, 1382 UNI_BSS_INFO_BCN_CSA = 8, 1383 UNI_BSS_INFO_BCN_BCC = 9, 1384 UNI_BSS_INFO_BCN_MBSSID = 10, 1385 UNI_BSS_INFO_RATE = 11, 1386 UNI_BSS_INFO_QBSS = 15, 1387 UNI_BSS_INFO_SEC = 16, 1388 UNI_BSS_INFO_BCN_PROT = 17, 1389 UNI_BSS_INFO_TXCMD = 18, 1390 UNI_BSS_INFO_UAPSD = 19, 1391 UNI_BSS_INFO_PS = 21, 1392 UNI_BSS_INFO_BCNFT = 22, 1393 UNI_BSS_INFO_IFS_TIME = 23, 1394 UNI_BSS_INFO_OFFLOAD = 25, 1395 UNI_BSS_INFO_MLD = 26, 1396 UNI_BSS_INFO_PM_DISABLE = 27, 1397 UNI_BSS_INFO_EHT = 30, 1398 UNI_BSS_INFO_MLD_LINK_OP = 36, 1399 }; 1400 1401 enum { 1402 UNI_OFFLOAD_OFFLOAD_ARP, 1403 UNI_OFFLOAD_OFFLOAD_ND, 1404 UNI_OFFLOAD_OFFLOAD_GTK_REKEY, 1405 UNI_OFFLOAD_OFFLOAD_BMC_RPY_DETECT, 1406 }; 1407 1408 enum UNI_ALL_STA_INFO_TAG { 1409 UNI_ALL_STA_TXRX_RATE, 1410 UNI_ALL_STA_TX_STAT, 1411 UNI_ALL_STA_TXRX_ADM_STAT, 1412 UNI_ALL_STA_TXRX_AIR_TIME, 1413 UNI_ALL_STA_DATA_TX_RETRY_COUNT, 1414 UNI_ALL_STA_GI_MODE, 1415 UNI_ALL_STA_TXRX_MSDU_COUNT, 1416 UNI_ALL_STA_MAX_NUM 1417 }; 1418 1419 enum { 1420 MT_NIC_CAP_TX_RESOURCE, 1421 MT_NIC_CAP_TX_EFUSE_ADDR, 1422 MT_NIC_CAP_COEX, 1423 MT_NIC_CAP_SINGLE_SKU, 1424 MT_NIC_CAP_CSUM_OFFLOAD, 1425 MT_NIC_CAP_HW_VER, 1426 MT_NIC_CAP_SW_VER, 1427 MT_NIC_CAP_MAC_ADDR, 1428 MT_NIC_CAP_PHY, 1429 MT_NIC_CAP_MAC, 1430 MT_NIC_CAP_FRAME_BUF, 1431 MT_NIC_CAP_BEAM_FORM, 1432 MT_NIC_CAP_LOCATION, 1433 MT_NIC_CAP_MUMIMO, 1434 MT_NIC_CAP_BUFFER_MODE_INFO, 1435 MT_NIC_CAP_HW_ADIE_VERSION = 0x14, 1436 MT_NIC_CAP_ANTSWP = 0x16, 1437 MT_NIC_CAP_WFDMA_REALLOC, 1438 MT_NIC_CAP_6G, 1439 MT_NIC_CAP_CHIP_CAP = 0x20, 1440 MT_NIC_CAP_EML_CAP = 0x22, 1441 }; 1442 1443 #define UNI_WOW_DETECT_TYPE_MAGIC BIT(0) 1444 #define UNI_WOW_DETECT_TYPE_ANY BIT(1) 1445 #define UNI_WOW_DETECT_TYPE_DISCONNECT BIT(2) 1446 #define UNI_WOW_DETECT_TYPE_GTK_REKEY_FAIL BIT(3) 1447 #define UNI_WOW_DETECT_TYPE_BCN_LOST BIT(4) 1448 #define UNI_WOW_DETECT_TYPE_SCH_SCAN_HIT BIT(5) 1449 #define UNI_WOW_DETECT_TYPE_BITMAP BIT(6) 1450 1451 enum { 1452 UNI_SUSPEND_MODE_SETTING, 1453 UNI_SUSPEND_WOW_CTRL, 1454 UNI_SUSPEND_WOW_GPIO_PARAM, 1455 UNI_SUSPEND_WOW_WAKEUP_PORT, 1456 UNI_SUSPEND_WOW_PATTERN, 1457 }; 1458 1459 enum { 1460 WOW_USB = 1, 1461 WOW_PCIE = 2, 1462 WOW_GPIO = 3, 1463 }; 1464 1465 struct mt76_connac_bss_basic_tlv { 1466 __le16 tag; 1467 __le16 len; 1468 u8 active; 1469 u8 omac_idx; 1470 u8 hw_bss_idx; 1471 u8 band_idx; 1472 __le32 conn_type; 1473 u8 conn_state; 1474 u8 wmm_idx; 1475 u8 bssid[ETH_ALEN]; 1476 __le16 bmc_tx_wlan_idx; 1477 __le16 bcn_interval; 1478 u8 dtim_period; 1479 u8 phymode; /* bit(0): A 1480 * bit(1): B 1481 * bit(2): G 1482 * bit(3): GN 1483 * bit(4): AN 1484 * bit(5): AC 1485 * bit(6): AX2 1486 * bit(7): AX5 1487 * bit(8): AX6 1488 */ 1489 __le16 sta_idx; 1490 __le16 nonht_basic_phy; 1491 u8 phymode_ext; /* bit(0) AX_6G */ 1492 u8 link_idx; 1493 } __packed; 1494 1495 struct mt76_connac_bss_qos_tlv { 1496 __le16 tag; 1497 __le16 len; 1498 u8 qos; 1499 u8 pad[3]; 1500 } __packed; 1501 1502 struct mt76_connac_beacon_loss_event { 1503 u8 bss_idx; 1504 u8 reason; 1505 u8 pad[2]; 1506 } __packed; 1507 1508 struct mt76_connac_rssi_notify_event { 1509 __le32 rssi[4]; 1510 } __packed; 1511 1512 struct mt76_connac_mcu_bss_event { 1513 u8 bss_idx; 1514 u8 is_absent; 1515 u8 free_quota; 1516 u8 pad; 1517 } __packed; 1518 1519 struct mt76_connac_mcu_scan_ssid { 1520 __le32 ssid_len; 1521 u8 ssid[IEEE80211_MAX_SSID_LEN]; 1522 } __packed; 1523 1524 struct mt76_connac_mcu_scan_channel { 1525 u8 band; /* 1: 2.4GHz 1526 * 2: 5.0GHz 1527 * Others: Reserved 1528 */ 1529 u8 channel_num; 1530 } __packed; 1531 1532 struct mt76_connac_mcu_scan_match { 1533 __le32 rssi_th; 1534 u8 ssid[IEEE80211_MAX_SSID_LEN]; 1535 u8 ssid_len; 1536 u8 rsv[3]; 1537 } __packed; 1538 1539 struct mt76_connac_hw_scan_req { 1540 u8 seq_num; 1541 u8 bss_idx; 1542 u8 scan_type; /* 0: PASSIVE SCAN 1543 * 1: ACTIVE SCAN 1544 */ 1545 u8 ssid_type; /* BIT(0) wildcard SSID 1546 * BIT(1) P2P wildcard SSID 1547 * BIT(2) specified SSID + wildcard SSID 1548 * BIT(2) + ssid_type_ext BIT(0) specified SSID only 1549 */ 1550 u8 ssids_num; 1551 u8 probe_req_num; /* Number of probe request for each SSID */ 1552 u8 scan_func; /* BIT(0) Enable random MAC scan 1553 * BIT(1) Disable DBDC scan type 1~3. 1554 * BIT(2) Use DBDC scan type 3 (dedicated one RF to scan). 1555 */ 1556 u8 version; /* 0: Not support fields after ies. 1557 * 1: Support fields after ies. 1558 */ 1559 struct mt76_connac_mcu_scan_ssid ssids[4]; 1560 __le16 probe_delay_time; 1561 __le16 channel_dwell_time; /* channel Dwell interval */ 1562 __le16 timeout_value; 1563 u8 channel_type; /* 0: Full channels 1564 * 1: Only 2.4GHz channels 1565 * 2: Only 5GHz channels 1566 * 3: P2P social channel only (channel #1, #6 and #11) 1567 * 4: Specified channels 1568 * Others: Reserved 1569 */ 1570 u8 channels_num; /* valid when channel_type is 4 */ 1571 /* valid when channels_num is set */ 1572 struct mt76_connac_mcu_scan_channel channels[32]; 1573 __le16 ies_len; 1574 u8 ies[MT76_CONNAC_SCAN_IE_LEN]; 1575 /* following fields are valid if version > 0 */ 1576 u8 ext_channels_num; 1577 u8 ext_ssids_num; 1578 __le16 channel_min_dwell_time; 1579 struct mt76_connac_mcu_scan_channel ext_channels[32]; 1580 struct mt76_connac_mcu_scan_ssid ext_ssids[6]; 1581 u8 bssid[ETH_ALEN]; 1582 u8 random_mac[ETH_ALEN]; /* valid when BIT(1) in scan_func is set. */ 1583 u8 pad[63]; 1584 u8 ssid_type_ext; 1585 } __packed; 1586 1587 #define MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM 64 1588 1589 struct mt76_connac_hw_scan_done { 1590 u8 seq_num; 1591 u8 sparse_channel_num; 1592 struct mt76_connac_mcu_scan_channel sparse_channel; 1593 u8 complete_channel_num; 1594 u8 current_state; 1595 u8 version; 1596 u8 pad; 1597 __le32 beacon_scan_num; 1598 u8 pno_enabled; 1599 u8 pad2[3]; 1600 u8 sparse_channel_valid_num; 1601 u8 pad3[3]; 1602 u8 channel_num[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM]; 1603 /* idle format for channel_idle_time 1604 * 0: first bytes: idle time(ms) 2nd byte: dwell time(ms) 1605 * 1: first bytes: idle time(8ms) 2nd byte: dwell time(8ms) 1606 * 2: dwell time (16us) 1607 */ 1608 __le16 channel_idle_time[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM]; 1609 /* beacon and probe response count */ 1610 u8 beacon_probe_num[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM]; 1611 u8 mdrdy_count[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM]; 1612 __le32 beacon_2g_num; 1613 __le32 beacon_5g_num; 1614 } __packed; 1615 1616 struct mt76_connac_sched_scan_req { 1617 u8 version; 1618 u8 seq_num; 1619 u8 stop_on_match; 1620 u8 ssids_num; 1621 u8 match_num; 1622 u8 pad; 1623 __le16 ie_len; 1624 struct mt76_connac_mcu_scan_ssid ssids[MT76_CONNAC_MAX_SCHED_SCAN_SSID]; 1625 struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH]; 1626 u8 channel_type; 1627 u8 channels_num; 1628 u8 intervals_num; 1629 u8 scan_func; /* MT7663: BIT(0) eable random mac address */ 1630 struct mt76_connac_mcu_scan_channel channels[64]; 1631 __le16 intervals[MT76_CONNAC_MAX_NUM_SCHED_SCAN_INTERVAL]; 1632 union { 1633 struct { 1634 u8 random_mac[ETH_ALEN]; 1635 u8 pad2[58]; 1636 } mt7663; 1637 struct { 1638 u8 bss_idx; 1639 u8 pad1[3]; 1640 __le32 delay; 1641 u8 pad2[12]; 1642 u8 random_mac[ETH_ALEN]; 1643 u8 pad3[38]; 1644 } mt7921; 1645 }; 1646 } __packed; 1647 1648 struct mt76_connac_sched_scan_done { 1649 u8 seq_num; 1650 u8 status; /* 0: ssid found */ 1651 __le16 pad; 1652 } __packed; 1653 1654 struct bss_info_uni_bss_color { 1655 __le16 tag; 1656 __le16 len; 1657 u8 enable; 1658 u8 bss_color; 1659 u8 rsv[2]; 1660 } __packed; 1661 1662 struct bss_info_uni_he { 1663 __le16 tag; 1664 __le16 len; 1665 __le16 he_rts_thres; 1666 u8 he_pe_duration; 1667 u8 su_disable; 1668 __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM]; 1669 u8 rsv[2]; 1670 } __packed; 1671 1672 struct bss_info_uni_mbssid { 1673 __le16 tag; 1674 __le16 len; 1675 u8 max_indicator; 1676 u8 mbss_idx; 1677 u8 tx_bss_omac_idx; 1678 u8 rsv; 1679 } __packed; 1680 1681 struct mt76_connac_gtk_rekey_tlv { 1682 __le16 tag; 1683 __le16 len; 1684 u8 kek[NL80211_KEK_LEN]; 1685 u8 kck[NL80211_KCK_LEN]; 1686 u8 replay_ctr[NL80211_REPLAY_CTR_LEN]; 1687 u8 rekey_mode; /* 0: rekey offload enable 1688 * 1: rekey offload disable 1689 * 2: rekey update 1690 */ 1691 u8 keyid; 1692 u8 option; /* 1: rekey data update without enabling offload */ 1693 u8 pad[1]; 1694 __le32 proto; /* WPA-RSN-WAPI-OPSN */ 1695 __le32 pairwise_cipher; 1696 __le32 group_cipher; 1697 __le32 key_mgmt; /* NONE-PSK-IEEE802.1X */ 1698 __le32 mgmt_group_cipher; 1699 u8 reserverd[4]; 1700 } __packed; 1701 1702 #define MT76_CONNAC_WOW_MASK_MAX_LEN 16 1703 #define MT76_CONNAC_WOW_PATTEN_MAX_LEN 128 1704 1705 struct mt76_connac_wow_pattern_tlv { 1706 __le16 tag; 1707 __le16 len; 1708 u8 index; /* pattern index */ 1709 u8 enable; /* 0: disable 1710 * 1: enable 1711 */ 1712 u8 data_len; /* pattern length */ 1713 u8 pad; 1714 u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN]; 1715 u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN]; 1716 u8 rsv[4]; 1717 } __packed; 1718 1719 struct mt76_connac_wow_ctrl_tlv { 1720 __le16 tag; 1721 __le16 len; 1722 u8 cmd; /* 0x1: PM_WOWLAN_REQ_START 1723 * 0x2: PM_WOWLAN_REQ_STOP 1724 * 0x3: PM_WOWLAN_PARAM_CLEAR 1725 */ 1726 u8 trigger; /* 0: NONE 1727 * BIT(0): NL80211_WOWLAN_TRIG_MAGIC_PKT 1728 * BIT(1): NL80211_WOWLAN_TRIG_ANY 1729 * BIT(2): NL80211_WOWLAN_TRIG_DISCONNECT 1730 * BIT(3): NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE 1731 * BIT(4): BEACON_LOST 1732 * BIT(5): NL80211_WOWLAN_TRIG_NET_DETECT 1733 */ 1734 u8 wakeup_hif; /* 0x0: HIF_SDIO 1735 * 0x1: HIF_USB 1736 * 0x2: HIF_PCIE 1737 * 0x3: HIF_GPIO 1738 */ 1739 u8 pad; 1740 u8 rsv[4]; 1741 } __packed; 1742 1743 struct mt76_connac_wow_gpio_param_tlv { 1744 __le16 tag; 1745 __le16 len; 1746 u8 gpio_pin; 1747 u8 trigger_lvl; 1748 u8 pad[2]; 1749 __le32 gpio_interval; 1750 u8 rsv[4]; 1751 } __packed; 1752 1753 struct mt76_connac_arpns_tlv { 1754 __le16 tag; 1755 __le16 len; 1756 u8 mode; 1757 u8 ips_num; 1758 u8 option; 1759 u8 pad[1]; 1760 } __packed; 1761 1762 struct mt76_connac_suspend_tlv { 1763 __le16 tag; 1764 __le16 len; 1765 u8 enable; /* 0: suspend mode disabled 1766 * 1: suspend mode enabled 1767 */ 1768 u8 mdtim; /* LP parameter */ 1769 u8 wow_suspend; /* 0: update by origin policy 1770 * 1: update by wow dtim 1771 */ 1772 u8 pad[5]; 1773 } __packed; 1774 1775 enum mt76_sta_info_state { 1776 MT76_STA_INFO_STATE_NONE, 1777 MT76_STA_INFO_STATE_AUTH, 1778 MT76_STA_INFO_STATE_ASSOC 1779 }; 1780 1781 struct mt76_sta_cmd_info { 1782 union { 1783 struct ieee80211_sta *sta; 1784 struct ieee80211_link_sta *link_sta; 1785 }; 1786 struct mt76_wcid *wcid; 1787 1788 struct ieee80211_vif *vif; 1789 struct ieee80211_bss_conf *link_conf; 1790 1791 bool offload_fw; 1792 bool enable; 1793 bool newly; 1794 int cmd; 1795 u8 rcpi; 1796 u8 state; 1797 }; 1798 1799 #define MT_SKU_POWER_LIMIT 161 1800 1801 struct mt76_connac_sku_tlv { 1802 u8 channel; 1803 s8 pwr_limit[MT_SKU_POWER_LIMIT]; 1804 } __packed; 1805 1806 struct mt76_connac_tx_power_limit_tlv { 1807 /* DW0 - common info*/ 1808 u8 ver; 1809 u8 pad0; 1810 __le16 len; 1811 /* DW1 - cmd hint */ 1812 u8 n_chan; /* # channel */ 1813 u8 band; /* 2.4GHz - 5GHz - 6GHz */ 1814 u8 last_msg; 1815 u8 pad1; 1816 /* DW3 */ 1817 u8 alpha2[4]; /* regulatory_request.alpha2 */ 1818 u8 pad2[32]; 1819 } __packed; 1820 1821 struct mt76_connac_config { 1822 __le16 id; 1823 u8 type; 1824 u8 resp_type; 1825 __le16 data_size; 1826 __le16 resv; 1827 u8 data[320]; 1828 } __packed; 1829 1830 struct mt76_connac_mcu_uni_event { 1831 u8 cid; 1832 u8 pad[3]; 1833 __le32 status; /* 0: success, others: fail */ 1834 } __packed; 1835 1836 struct mt76_connac_mcu_reg_event { 1837 __le32 reg; 1838 __le32 val; 1839 } __packed; 1840 1841 static inline enum mcu_cipher_type 1842 mt76_connac_mcu_get_cipher(int cipher) 1843 { 1844 switch (cipher) { 1845 case WLAN_CIPHER_SUITE_WEP40: 1846 return MCU_CIPHER_WEP40; 1847 case WLAN_CIPHER_SUITE_WEP104: 1848 return MCU_CIPHER_WEP104; 1849 case WLAN_CIPHER_SUITE_TKIP: 1850 return MCU_CIPHER_TKIP; 1851 case WLAN_CIPHER_SUITE_AES_CMAC: 1852 return MCU_CIPHER_BIP_CMAC_128; 1853 case WLAN_CIPHER_SUITE_CCMP: 1854 return MCU_CIPHER_AES_CCMP; 1855 case WLAN_CIPHER_SUITE_CCMP_256: 1856 return MCU_CIPHER_CCMP_256; 1857 case WLAN_CIPHER_SUITE_GCMP: 1858 return MCU_CIPHER_GCMP; 1859 case WLAN_CIPHER_SUITE_GCMP_256: 1860 return MCU_CIPHER_GCMP_256; 1861 case WLAN_CIPHER_SUITE_BIP_GMAC_128: 1862 return MCU_CIPHER_BIP_GMAC_128; 1863 case WLAN_CIPHER_SUITE_BIP_GMAC_256: 1864 return MCU_CIPHER_BIP_GMAC_256; 1865 case WLAN_CIPHER_SUITE_BIP_CMAC_256: 1866 return MCU_CIPHER_BIP_CMAC_256; 1867 case WLAN_CIPHER_SUITE_SMS4: 1868 return MCU_CIPHER_WAPI; 1869 default: 1870 return MCU_CIPHER_NONE; 1871 } 1872 } 1873 1874 static inline u32 1875 mt76_connac_mcu_gen_dl_mode(struct mt76_dev *dev, u8 feature_set, bool is_wa) 1876 { 1877 u32 ret = 0; 1878 1879 ret |= feature_set & FW_FEATURE_SET_ENCRYPT ? 1880 DL_MODE_ENCRYPT | DL_MODE_RESET_SEC_IV : 0; 1881 if (is_connac2(dev) || is_mt7925(dev)) 1882 ret |= feature_set & FW_FEATURE_ENCRY_MODE ? 1883 DL_CONFIG_ENCRY_MODE_SEL : 0; 1884 ret |= FIELD_PREP(DL_MODE_KEY_IDX, 1885 FIELD_GET(FW_FEATURE_SET_KEY_IDX, feature_set)); 1886 ret |= DL_MODE_NEED_RSP; 1887 ret |= is_wa ? DL_MODE_WORKING_PDA_CR4 : 0; 1888 1889 return ret; 1890 } 1891 1892 #define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id) 1893 #define to_wcid_hi(id) FIELD_GET(GENMASK(10, 8), (u16)id) 1894 1895 static inline void 1896 mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid, 1897 u8 *wlan_idx_lo, u8 *wlan_idx_hi) 1898 { 1899 *wlan_idx_hi = 0; 1900 1901 if (!is_connac_v1(dev)) { 1902 *wlan_idx_lo = wcid ? to_wcid_lo(wcid->idx) : 0; 1903 *wlan_idx_hi = wcid ? to_wcid_hi(wcid->idx) : 0; 1904 } else { 1905 *wlan_idx_lo = wcid ? wcid->idx : 0; 1906 } 1907 } 1908 1909 struct sk_buff * 1910 __mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif_link *mvif, 1911 struct mt76_wcid *wcid, int len); 1912 static inline struct sk_buff * 1913 mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif_link *mvif, 1914 struct mt76_wcid *wcid) 1915 { 1916 return __mt76_connac_mcu_alloc_sta_req(dev, mvif, wcid, 1917 MT76_CONNAC_STA_UPDATE_MAX_SIZE); 1918 } 1919 1920 struct wtbl_req_hdr * 1921 mt76_connac_mcu_alloc_wtbl_req(struct mt76_dev *dev, struct mt76_wcid *wcid, 1922 int cmd, void *sta_wtbl, struct sk_buff **skb); 1923 struct tlv *mt76_connac_mcu_add_nested_tlv(struct sk_buff *skb, int tag, 1924 int len, void *sta_ntlv, 1925 void *sta_wtbl); 1926 static inline struct tlv * 1927 mt76_connac_mcu_add_tlv(struct sk_buff *skb, int tag, int len) 1928 { 1929 return mt76_connac_mcu_add_nested_tlv(skb, tag, len, skb->data, NULL); 1930 } 1931 1932 int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy); 1933 int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif); 1934 void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb, 1935 struct ieee80211_bss_conf *link_conf, 1936 struct ieee80211_link_sta *link_sta, 1937 int state, bool newly); 1938 void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb, 1939 struct ieee80211_vif *vif, 1940 struct ieee80211_sta *sta, void *sta_wtbl, 1941 void *wtbl_tlv); 1942 void mt76_connac_mcu_wtbl_hdr_trans_tlv(struct sk_buff *skb, 1943 struct ieee80211_vif *vif, 1944 struct mt76_wcid *wcid, 1945 void *sta_wtbl, void *wtbl_tlv); 1946 int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev, 1947 struct ieee80211_vif *vif, 1948 struct mt76_wcid *wcid, int cmd); 1949 void mt76_connac_mcu_sta_he_tlv_v2(struct sk_buff *skb, struct ieee80211_sta *sta); 1950 u8 mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif, 1951 enum nl80211_band band, 1952 struct ieee80211_link_sta *link_sta); 1953 int mt76_connac_mcu_wtbl_update_hdr_trans(struct mt76_dev *dev, 1954 struct ieee80211_vif *vif, 1955 struct ieee80211_sta *sta); 1956 void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, 1957 struct ieee80211_sta *sta, 1958 struct ieee80211_vif *vif, 1959 u8 rcpi, u8 state); 1960 void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb, 1961 struct ieee80211_sta *sta, void *sta_wtbl, 1962 void *wtbl_tlv, bool ht_ldpc, bool vht_ldpc); 1963 void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb, 1964 struct ieee80211_ampdu_params *params, 1965 bool enable, bool tx, void *sta_wtbl, 1966 void *wtbl_tlv); 1967 void mt76_connac_mcu_sta_ba_tlv(struct sk_buff *skb, 1968 struct ieee80211_ampdu_params *params, 1969 bool enable, bool tx); 1970 int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy, 1971 struct ieee80211_bss_conf *bss_conf, 1972 struct mt76_vif_link *mvif, 1973 struct mt76_wcid *wcid, 1974 bool enable); 1975 int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif_link *mvif, 1976 struct ieee80211_ampdu_params *params, 1977 int cmd, bool enable, bool tx); 1978 int mt76_connac_mcu_uni_set_chctx(struct mt76_phy *phy, 1979 struct mt76_vif_link *vif, 1980 struct ieee80211_chanctx_conf *ctx); 1981 int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy, 1982 struct ieee80211_vif *vif, 1983 struct mt76_wcid *wcid, 1984 bool enable, 1985 struct ieee80211_chanctx_conf *ctx); 1986 int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy, 1987 struct mt76_sta_cmd_info *info); 1988 void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac, 1989 struct ieee80211_vif *vif); 1990 int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band); 1991 int mt76_connac_mcu_set_mac_enable(struct mt76_dev *dev, int band, bool enable, 1992 bool hdr_trans); 1993 int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len, 1994 u32 mode); 1995 int mt76_connac_mcu_start_patch(struct mt76_dev *dev); 1996 int mt76_connac_mcu_patch_sem_ctrl(struct mt76_dev *dev, bool get); 1997 int mt76_connac_mcu_start_firmware(struct mt76_dev *dev, u32 addr, u32 option); 1998 1999 void mt76_connac_mcu_build_rnr_scan_param(struct mt76_dev *mdev, 2000 struct cfg80211_scan_request *sreq); 2001 int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, 2002 struct ieee80211_scan_request *scan_req); 2003 int mt76_connac_mcu_cancel_hw_scan(struct mt76_phy *phy, 2004 struct ieee80211_vif *vif); 2005 int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy, 2006 struct ieee80211_vif *vif, 2007 struct cfg80211_sched_scan_request *sreq); 2008 int mt76_connac_mcu_sched_scan_enable(struct mt76_phy *phy, 2009 struct ieee80211_vif *vif, 2010 bool enable); 2011 int mt76_connac_mcu_update_arp_filter(struct mt76_dev *dev, 2012 struct mt76_vif_link *vif, 2013 struct ieee80211_bss_conf *info); 2014 int mt76_connac_mcu_set_gtk_rekey(struct mt76_dev *dev, struct ieee80211_vif *vif, 2015 bool suspend); 2016 int mt76_connac_mcu_set_wow_ctrl(struct mt76_phy *phy, struct ieee80211_vif *vif, 2017 bool suspend, struct cfg80211_wowlan *wowlan); 2018 int mt76_connac_mcu_update_gtk_rekey(struct ieee80211_hw *hw, 2019 struct ieee80211_vif *vif, 2020 struct cfg80211_gtk_rekey_data *key); 2021 int mt76_connac_mcu_set_suspend_mode(struct mt76_dev *dev, 2022 struct ieee80211_vif *vif, 2023 bool enable, u8 mdtim, 2024 bool wow_suspend); 2025 int mt76_connac_mcu_set_hif_suspend(struct mt76_dev *dev, bool suspend, bool wait_resp); 2026 void mt76_connac_mcu_set_suspend_iter(void *priv, u8 *mac, 2027 struct ieee80211_vif *vif); 2028 int mt76_connac_sta_state_dp(struct mt76_dev *dev, 2029 enum ieee80211_sta_state old_state, 2030 enum ieee80211_sta_state new_state); 2031 int mt76_connac_mcu_chip_config(struct mt76_dev *dev); 2032 int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable); 2033 void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb, 2034 struct mt76_connac_coredump *coredump); 2035 s8 mt76_connac_get_ch_power(struct mt76_phy *phy, 2036 struct ieee80211_channel *chan, 2037 s8 target_power); 2038 int mt76_connac_mcu_set_rate_txpower(struct mt76_phy *phy); 2039 int mt76_connac_mcu_set_p2p_oppps(struct ieee80211_hw *hw, 2040 struct ieee80211_vif *vif); 2041 u32 mt76_connac_mcu_reg_rr(struct mt76_dev *dev, u32 offset); 2042 void mt76_connac_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val); 2043 2044 const struct ieee80211_sta_he_cap * 2045 mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif); 2046 const struct ieee80211_sta_eht_cap * 2047 mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif); 2048 u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, 2049 enum nl80211_band band, 2050 struct ieee80211_link_sta *sta); 2051 u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_bss_conf *conf, 2052 enum nl80211_band band); 2053 2054 int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, 2055 struct mt76_connac_sta_key_conf *sta_key_conf, 2056 struct ieee80211_key_conf *key, int mcu_cmd, 2057 struct mt76_wcid *wcid, enum set_key_cmd cmd); 2058 2059 void mt76_connac_mcu_bss_ext_tlv(struct sk_buff *skb, struct mt76_vif_link *mvif); 2060 void mt76_connac_mcu_bss_omac_tlv(struct sk_buff *skb, 2061 struct ieee80211_vif *vif); 2062 int mt76_connac_mcu_bss_basic_tlv(struct sk_buff *skb, 2063 struct ieee80211_vif *vif, 2064 struct ieee80211_sta *sta, 2065 struct mt76_phy *phy, u16 wlan_idx, 2066 bool enable); 2067 void mt76_connac_mcu_sta_uapsd(struct sk_buff *skb, struct ieee80211_vif *vif, 2068 struct ieee80211_sta *sta); 2069 void mt76_connac_mcu_wtbl_smps_tlv(struct sk_buff *skb, 2070 struct ieee80211_sta *sta, 2071 void *sta_wtbl, void *wtbl_tlv); 2072 int mt76_connac_mcu_set_pm(struct mt76_dev *dev, int band, int enter); 2073 int mt76_connac_mcu_restart(struct mt76_dev *dev); 2074 int mt76_connac_mcu_del_wtbl_all(struct mt76_dev *dev); 2075 int mt76_connac_mcu_rdd_cmd(struct mt76_dev *dev, int cmd, u8 index, 2076 u8 rx_sel, u8 val); 2077 int mt76_connac_mcu_sta_wed_update(struct mt76_dev *dev, struct sk_buff *skb); 2078 int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm, 2079 const char *fw_wa); 2080 int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name); 2081 int mt76_connac2_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb, 2082 int cmd, int *wait_seq); 2083 #endif /* __MT76_CONNAC_MCU_H */ 2084