18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ISC */ 28c2ecf20Sopenharmony_ci/* Copyright (C) 2019 MediaTek Inc. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef __MT7615_MAC_H 58c2ecf20Sopenharmony_ci#define __MT7615_MAC_H 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#define MT_CT_PARSE_LEN 72 88c2ecf20Sopenharmony_ci#define MT_CT_DMA_BUF_NUM 2 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define MT_RXD0_LENGTH GENMASK(15, 0) 118c2ecf20Sopenharmony_ci#define MT_RXD0_PKT_FLAG GENMASK(19, 16) 128c2ecf20Sopenharmony_ci#define MT_RXD0_PKT_TYPE GENMASK(31, 29) 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define MT_RXD0_NORMAL_ETH_TYPE_OFS GENMASK(22, 16) 158c2ecf20Sopenharmony_ci#define MT_RXD0_NORMAL_IP_SUM BIT(23) 168c2ecf20Sopenharmony_ci#define MT_RXD0_NORMAL_UDP_TCP_SUM BIT(24) 178c2ecf20Sopenharmony_ci#define MT_RXD0_NORMAL_GROUP_1 BIT(25) 188c2ecf20Sopenharmony_ci#define MT_RXD0_NORMAL_GROUP_2 BIT(26) 198c2ecf20Sopenharmony_ci#define MT_RXD0_NORMAL_GROUP_3 BIT(27) 208c2ecf20Sopenharmony_ci#define MT_RXD0_NORMAL_GROUP_4 BIT(28) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cienum rx_pkt_type { 238c2ecf20Sopenharmony_ci PKT_TYPE_TXS, 248c2ecf20Sopenharmony_ci PKT_TYPE_TXRXV, 258c2ecf20Sopenharmony_ci PKT_TYPE_NORMAL, 268c2ecf20Sopenharmony_ci PKT_TYPE_RX_DUP_RFB, 278c2ecf20Sopenharmony_ci PKT_TYPE_RX_TMR, 288c2ecf20Sopenharmony_ci PKT_TYPE_RETRIEVE, 298c2ecf20Sopenharmony_ci PKT_TYPE_TXRX_NOTIFY, 308c2ecf20Sopenharmony_ci PKT_TYPE_RX_EVENT, 318c2ecf20Sopenharmony_ci PKT_TYPE_NORMAL_MCU, 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_BSSID GENMASK(31, 26) 358c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_PAYLOAD_FORMAT GENMASK(25, 24) 368c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_HDR_TRANS BIT(23) 378c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_HDR_OFFSET BIT(22) 388c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_MAC_HDR_LEN GENMASK(21, 16) 398c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_CH_FREQ GENMASK(15, 8) 408c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_KEY_ID GENMASK(7, 6) 418c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_BEACON_UC BIT(5) 428c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_BEACON_MC BIT(4) 438c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_BF_REPORT BIT(3) 448c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_ADDR_TYPE GENMASK(2, 1) 458c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_BCAST GENMASK(2, 1) 468c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_MCAST BIT(2) 478c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_U2M BIT(1) 488c2ecf20Sopenharmony_ci#define MT_RXD1_NORMAL_HTC_VLD BIT(0) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_NON_AMPDU BIT(31) 518c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_NON_AMPDU_SUB BIT(30) 528c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_NDATA BIT(29) 538c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_NULL_FRAME BIT(28) 548c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_FRAG BIT(27) 558c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_INT_FRAME BIT(26) 568c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_HDR_TRANS_ERROR BIT(25) 578c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_MAX_LEN_ERROR BIT(24) 588c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_AMSDU_ERR BIT(23) 598c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_LEN_MISMATCH BIT(22) 608c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_TKIP_MIC_ERR BIT(21) 618c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_ICV_ERR BIT(20) 628c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_CLM BIT(19) 638c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_CM BIT(18) 648c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_FCS_ERR BIT(17) 658c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_SW_BIT BIT(16) 668c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_SEC_MODE GENMASK(15, 12) 678c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_TID GENMASK(11, 8) 688c2ecf20Sopenharmony_ci#define MT_RXD2_NORMAL_WLAN_IDX GENMASK(7, 0) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_PF_STS GENMASK(31, 30) 718c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_PF_MODE BIT(29) 728c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_CLS_BITMAP GENMASK(28, 19) 738c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_WOL GENMASK(18, 14) 748c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_MAGIC_PKT BIT(13) 758c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_OFLD GENMASK(12, 11) 768c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_CLS BIT(10) 778c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_PATTERN_DROP BIT(9) 788c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_TSF_COMPARE_LOSS BIT(8) 798c2ecf20Sopenharmony_ci#define MT_RXD3_NORMAL_RXV_SEQ GENMASK(7, 0) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define MT_RXV1_ACID_DET_H BIT(31) 828c2ecf20Sopenharmony_ci#define MT_RXV1_ACID_DET_L BIT(30) 838c2ecf20Sopenharmony_ci#define MT_RXV1_VHTA2_B8_B3 GENMASK(29, 24) 848c2ecf20Sopenharmony_ci#define MT_RXV1_NUM_RX GENMASK(23, 22) 858c2ecf20Sopenharmony_ci#define MT_RXV1_HT_NO_SOUND BIT(21) 868c2ecf20Sopenharmony_ci#define MT_RXV1_HT_SMOOTH BIT(20) 878c2ecf20Sopenharmony_ci#define MT_RXV1_HT_SHORT_GI BIT(19) 888c2ecf20Sopenharmony_ci#define MT_RXV1_HT_AGGR BIT(18) 898c2ecf20Sopenharmony_ci#define MT_RXV1_VHTA1_B22 BIT(17) 908c2ecf20Sopenharmony_ci#define MT_RXV1_FRAME_MODE GENMASK(16, 15) 918c2ecf20Sopenharmony_ci#define MT_RXV1_TX_MODE GENMASK(14, 12) 928c2ecf20Sopenharmony_ci#define MT_RXV1_HT_EXT_LTF GENMASK(11, 10) 938c2ecf20Sopenharmony_ci#define MT_RXV1_HT_AD_CODE BIT(9) 948c2ecf20Sopenharmony_ci#define MT_RXV1_HT_STBC GENMASK(8, 7) 958c2ecf20Sopenharmony_ci#define MT_RXV1_TX_RATE GENMASK(6, 0) 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define MT_RXV2_SEL_ANT BIT(31) 988c2ecf20Sopenharmony_ci#define MT_RXV2_VALID_BIT BIT(30) 998c2ecf20Sopenharmony_ci#define MT_RXV2_NSTS GENMASK(29, 27) 1008c2ecf20Sopenharmony_ci#define MT_RXV2_GROUP_ID GENMASK(26, 21) 1018c2ecf20Sopenharmony_ci#define MT_RXV2_LENGTH GENMASK(20, 0) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define MT_RXV3_WB_RSSI GENMASK(31, 24) 1048c2ecf20Sopenharmony_ci#define MT_RXV3_IB_RSSI GENMASK(23, 16) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define MT_RXV4_RCPI3 GENMASK(31, 24) 1078c2ecf20Sopenharmony_ci#define MT_RXV4_RCPI2 GENMASK(23, 16) 1088c2ecf20Sopenharmony_ci#define MT_RXV4_RCPI1 GENMASK(15, 8) 1098c2ecf20Sopenharmony_ci#define MT_RXV4_RCPI0 GENMASK(7, 0) 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define MT_RXV5_FOE GENMASK(11, 0) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define MT_RXV6_NF3 GENMASK(31, 24) 1148c2ecf20Sopenharmony_ci#define MT_RXV6_NF2 GENMASK(23, 16) 1158c2ecf20Sopenharmony_ci#define MT_RXV6_NF1 GENMASK(15, 8) 1168c2ecf20Sopenharmony_ci#define MT_RXV6_NF0 GENMASK(7, 0) 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cienum tx_header_format { 1198c2ecf20Sopenharmony_ci MT_HDR_FORMAT_802_3, 1208c2ecf20Sopenharmony_ci MT_HDR_FORMAT_CMD, 1218c2ecf20Sopenharmony_ci MT_HDR_FORMAT_802_11, 1228c2ecf20Sopenharmony_ci MT_HDR_FORMAT_802_11_EXT, 1238c2ecf20Sopenharmony_ci}; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cienum tx_pkt_type { 1268c2ecf20Sopenharmony_ci MT_TX_TYPE_CT, 1278c2ecf20Sopenharmony_ci MT_TX_TYPE_SF, 1288c2ecf20Sopenharmony_ci MT_TX_TYPE_CMD, 1298c2ecf20Sopenharmony_ci MT_TX_TYPE_FW, 1308c2ecf20Sopenharmony_ci}; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cienum tx_port_idx { 1338c2ecf20Sopenharmony_ci MT_TX_PORT_IDX_LMAC, 1348c2ecf20Sopenharmony_ci MT_TX_PORT_IDX_MCU 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cienum tx_mcu_port_q_idx { 1388c2ecf20Sopenharmony_ci MT_TX_MCU_PORT_RX_Q0 = 0, 1398c2ecf20Sopenharmony_ci MT_TX_MCU_PORT_RX_Q1, 1408c2ecf20Sopenharmony_ci MT_TX_MCU_PORT_RX_Q2, 1418c2ecf20Sopenharmony_ci MT_TX_MCU_PORT_RX_Q3, 1428c2ecf20Sopenharmony_ci MT_TX_MCU_PORT_RX_FWDL = 0x1e 1438c2ecf20Sopenharmony_ci}; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cienum tx_phy_bandwidth { 1468c2ecf20Sopenharmony_ci MT_PHY_BW_20, 1478c2ecf20Sopenharmony_ci MT_PHY_BW_40, 1488c2ecf20Sopenharmony_ci MT_PHY_BW_80, 1498c2ecf20Sopenharmony_ci MT_PHY_BW_160, 1508c2ecf20Sopenharmony_ci}; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci#define MT_CT_INFO_APPLY_TXD BIT(0) 1538c2ecf20Sopenharmony_ci#define MT_CT_INFO_COPY_HOST_TXD_ALL BIT(1) 1548c2ecf20Sopenharmony_ci#define MT_CT_INFO_MGMT_FRAME BIT(2) 1558c2ecf20Sopenharmony_ci#define MT_CT_INFO_NONE_CIPHER_FRAME BIT(3) 1568c2ecf20Sopenharmony_ci#define MT_CT_INFO_HSR2_TX BIT(4) 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci#define MT_TXD_SIZE (8 * 4) 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci#define MT_USB_TXD_SIZE (MT_TXD_SIZE + 8 * 4) 1618c2ecf20Sopenharmony_ci#define MT_USB_HDR_SIZE 4 1628c2ecf20Sopenharmony_ci#define MT_USB_TAIL_SIZE 4 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define MT_TXD0_P_IDX BIT(31) 1658c2ecf20Sopenharmony_ci#define MT_TXD0_Q_IDX GENMASK(30, 26) 1668c2ecf20Sopenharmony_ci#define MT_TXD0_UDP_TCP_SUM BIT(24) 1678c2ecf20Sopenharmony_ci#define MT_TXD0_IP_SUM BIT(23) 1688c2ecf20Sopenharmony_ci#define MT_TXD0_ETH_TYPE_OFFSET GENMASK(22, 16) 1698c2ecf20Sopenharmony_ci#define MT_TXD0_TX_BYTES GENMASK(15, 0) 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci#define MT_TXD1_OWN_MAC GENMASK(31, 26) 1728c2ecf20Sopenharmony_ci#define MT_TXD1_PKT_FMT GENMASK(25, 24) 1738c2ecf20Sopenharmony_ci#define MT_TXD1_TID GENMASK(23, 21) 1748c2ecf20Sopenharmony_ci#define MT_TXD1_AMSDU BIT(20) 1758c2ecf20Sopenharmony_ci#define MT_TXD1_UNXV BIT(19) 1768c2ecf20Sopenharmony_ci#define MT_TXD1_HDR_PAD GENMASK(18, 17) 1778c2ecf20Sopenharmony_ci#define MT_TXD1_TXD_LEN BIT(16) 1788c2ecf20Sopenharmony_ci#define MT_TXD1_LONG_FORMAT BIT(15) 1798c2ecf20Sopenharmony_ci#define MT_TXD1_HDR_FORMAT GENMASK(14, 13) 1808c2ecf20Sopenharmony_ci#define MT_TXD1_HDR_INFO GENMASK(12, 8) 1818c2ecf20Sopenharmony_ci#define MT_TXD1_WLAN_IDX GENMASK(7, 0) 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci#define MT_TXD2_FIX_RATE BIT(31) 1848c2ecf20Sopenharmony_ci#define MT_TXD2_TIMING_MEASURE BIT(30) 1858c2ecf20Sopenharmony_ci#define MT_TXD2_BA_DISABLE BIT(29) 1868c2ecf20Sopenharmony_ci#define MT_TXD2_POWER_OFFSET GENMASK(28, 24) 1878c2ecf20Sopenharmony_ci#define MT_TXD2_MAX_TX_TIME GENMASK(23, 16) 1888c2ecf20Sopenharmony_ci#define MT_TXD2_FRAG GENMASK(15, 14) 1898c2ecf20Sopenharmony_ci#define MT_TXD2_HTC_VLD BIT(13) 1908c2ecf20Sopenharmony_ci#define MT_TXD2_DURATION BIT(12) 1918c2ecf20Sopenharmony_ci#define MT_TXD2_BIP BIT(11) 1928c2ecf20Sopenharmony_ci#define MT_TXD2_MULTICAST BIT(10) 1938c2ecf20Sopenharmony_ci#define MT_TXD2_RTS BIT(9) 1948c2ecf20Sopenharmony_ci#define MT_TXD2_SOUNDING BIT(8) 1958c2ecf20Sopenharmony_ci#define MT_TXD2_NDPA BIT(7) 1968c2ecf20Sopenharmony_ci#define MT_TXD2_NDP BIT(6) 1978c2ecf20Sopenharmony_ci#define MT_TXD2_FRAME_TYPE GENMASK(5, 4) 1988c2ecf20Sopenharmony_ci#define MT_TXD2_SUB_TYPE GENMASK(3, 0) 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#define MT_TXD3_SN_VALID BIT(31) 2018c2ecf20Sopenharmony_ci#define MT_TXD3_PN_VALID BIT(30) 2028c2ecf20Sopenharmony_ci#define MT_TXD3_SEQ GENMASK(27, 16) 2038c2ecf20Sopenharmony_ci#define MT_TXD3_REM_TX_COUNT GENMASK(15, 11) 2048c2ecf20Sopenharmony_ci#define MT_TXD3_TX_COUNT GENMASK(10, 6) 2058c2ecf20Sopenharmony_ci#define MT_TXD3_PROTECT_FRAME BIT(1) 2068c2ecf20Sopenharmony_ci#define MT_TXD3_NO_ACK BIT(0) 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci#define MT_TXD4_PN_LOW GENMASK(31, 0) 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci#define MT_TXD5_PN_HIGH GENMASK(31, 16) 2118c2ecf20Sopenharmony_ci#define MT_TXD5_SW_POWER_MGMT BIT(13) 2128c2ecf20Sopenharmony_ci#define MT_TXD5_DA_SELECT BIT(11) 2138c2ecf20Sopenharmony_ci#define MT_TXD5_TX_STATUS_HOST BIT(10) 2148c2ecf20Sopenharmony_ci#define MT_TXD5_TX_STATUS_MCU BIT(9) 2158c2ecf20Sopenharmony_ci#define MT_TXD5_TX_STATUS_FMT BIT(8) 2168c2ecf20Sopenharmony_ci#define MT_TXD5_PID GENMASK(7, 0) 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci#define MT_TXD6_FIXED_RATE BIT(31) 2198c2ecf20Sopenharmony_ci#define MT_TXD6_SGI BIT(30) 2208c2ecf20Sopenharmony_ci#define MT_TXD6_LDPC BIT(29) 2218c2ecf20Sopenharmony_ci#define MT_TXD6_TX_BF BIT(28) 2228c2ecf20Sopenharmony_ci#define MT_TXD6_TX_RATE GENMASK(27, 16) 2238c2ecf20Sopenharmony_ci#define MT_TXD6_ANT_ID GENMASK(15, 4) 2248c2ecf20Sopenharmony_ci#define MT_TXD6_DYN_BW BIT(3) 2258c2ecf20Sopenharmony_ci#define MT_TXD6_FIXED_BW BIT(2) 2268c2ecf20Sopenharmony_ci#define MT_TXD6_BW GENMASK(1, 0) 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/* MT7663 DW7 HW-AMSDU */ 2298c2ecf20Sopenharmony_ci#define MT_TXD7_HW_AMSDU_CAP BIT(30) 2308c2ecf20Sopenharmony_ci#define MT_TXD7_TYPE GENMASK(21, 20) 2318c2ecf20Sopenharmony_ci#define MT_TXD7_SUB_TYPE GENMASK(19, 16) 2328c2ecf20Sopenharmony_ci#define MT_TXD7_SPE_IDX GENMASK(15, 11) 2338c2ecf20Sopenharmony_ci#define MT_TXD7_SPE_IDX_SLE BIT(10) 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci#define MT_TXD8_L_TYPE GENMASK(5, 4) 2368c2ecf20Sopenharmony_ci#define MT_TXD8_L_SUB_TYPE GENMASK(3, 0) 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci#define MT_TX_RATE_STBC BIT(11) 2398c2ecf20Sopenharmony_ci#define MT_TX_RATE_NSS GENMASK(10, 9) 2408c2ecf20Sopenharmony_ci#define MT_TX_RATE_MODE GENMASK(8, 6) 2418c2ecf20Sopenharmony_ci#define MT_TX_RATE_IDX GENMASK(5, 0) 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci#define MT_TXP_MAX_BUF_NUM 6 2448c2ecf20Sopenharmony_ci#define MT_HW_TXP_MAX_MSDU_NUM 4 2458c2ecf20Sopenharmony_ci#define MT_HW_TXP_MAX_BUF_NUM 4 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci#define MT_MSDU_ID_VALID BIT(15) 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci#define MT_TXD_LEN_MASK GENMASK(11, 0) 2508c2ecf20Sopenharmony_ci#define MT_TXD_LEN_MSDU_LAST BIT(14) 2518c2ecf20Sopenharmony_ci#define MT_TXD_LEN_AMSDU_LAST BIT(15) 2528c2ecf20Sopenharmony_ci/* mt7663 */ 2538c2ecf20Sopenharmony_ci#define MT_TXD_LEN_LAST BIT(15) 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_cistruct mt7615_txp_ptr { 2568c2ecf20Sopenharmony_ci __le32 buf0; 2578c2ecf20Sopenharmony_ci __le16 len0; 2588c2ecf20Sopenharmony_ci __le16 len1; 2598c2ecf20Sopenharmony_ci __le32 buf1; 2608c2ecf20Sopenharmony_ci} __packed __aligned(4); 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_cistruct mt7615_hw_txp { 2638c2ecf20Sopenharmony_ci __le16 msdu_id[MT_HW_TXP_MAX_MSDU_NUM]; 2648c2ecf20Sopenharmony_ci struct mt7615_txp_ptr ptr[MT_HW_TXP_MAX_BUF_NUM / 2]; 2658c2ecf20Sopenharmony_ci} __packed __aligned(4); 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_cistruct mt7615_fw_txp { 2688c2ecf20Sopenharmony_ci __le16 flags; 2698c2ecf20Sopenharmony_ci __le16 token; 2708c2ecf20Sopenharmony_ci u8 bss_idx; 2718c2ecf20Sopenharmony_ci u8 rept_wds_wcid; 2728c2ecf20Sopenharmony_ci u8 rsv; 2738c2ecf20Sopenharmony_ci u8 nbuf; 2748c2ecf20Sopenharmony_ci __le32 buf[MT_TXP_MAX_BUF_NUM]; 2758c2ecf20Sopenharmony_ci __le16 len[MT_TXP_MAX_BUF_NUM]; 2768c2ecf20Sopenharmony_ci} __packed __aligned(4); 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_cistruct mt7615_txp_common { 2798c2ecf20Sopenharmony_ci union { 2808c2ecf20Sopenharmony_ci struct mt7615_fw_txp fw; 2818c2ecf20Sopenharmony_ci struct mt7615_hw_txp hw; 2828c2ecf20Sopenharmony_ci }; 2838c2ecf20Sopenharmony_ci}; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_cistruct mt7615_tx_free { 2868c2ecf20Sopenharmony_ci __le16 rx_byte_cnt; 2878c2ecf20Sopenharmony_ci __le16 ctrl; 2888c2ecf20Sopenharmony_ci u8 txd_cnt; 2898c2ecf20Sopenharmony_ci u8 rsv[3]; 2908c2ecf20Sopenharmony_ci __le16 token[]; 2918c2ecf20Sopenharmony_ci} __packed __aligned(4); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci#define MT_TX_FREE_MSDU_ID_CNT GENMASK(6, 0) 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci#define MT_TXS0_PID GENMASK(31, 24) 2968c2ecf20Sopenharmony_ci#define MT_TXS0_BA_ERROR BIT(22) 2978c2ecf20Sopenharmony_ci#define MT_TXS0_PS_FLAG BIT(21) 2988c2ecf20Sopenharmony_ci#define MT_TXS0_TXOP_TIMEOUT BIT(20) 2998c2ecf20Sopenharmony_ci#define MT_TXS0_BIP_ERROR BIT(19) 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci#define MT_TXS0_QUEUE_TIMEOUT BIT(18) 3028c2ecf20Sopenharmony_ci#define MT_TXS0_RTS_TIMEOUT BIT(17) 3038c2ecf20Sopenharmony_ci#define MT_TXS0_ACK_TIMEOUT BIT(16) 3048c2ecf20Sopenharmony_ci#define MT_TXS0_ACK_ERROR_MASK GENMASK(18, 16) 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci#define MT_TXS0_TX_STATUS_HOST BIT(15) 3078c2ecf20Sopenharmony_ci#define MT_TXS0_TX_STATUS_MCU BIT(14) 3088c2ecf20Sopenharmony_ci#define MT_TXS0_TXS_FORMAT BIT(13) 3098c2ecf20Sopenharmony_ci#define MT_TXS0_FIXED_RATE BIT(12) 3108c2ecf20Sopenharmony_ci#define MT_TXS0_TX_RATE GENMASK(11, 0) 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci#define MT_TXS1_ANT_ID GENMASK(31, 20) 3138c2ecf20Sopenharmony_ci#define MT_TXS1_RESP_RATE GENMASK(19, 16) 3148c2ecf20Sopenharmony_ci#define MT_TXS1_BW GENMASK(15, 14) 3158c2ecf20Sopenharmony_ci#define MT_TXS1_I_TXBF BIT(13) 3168c2ecf20Sopenharmony_ci#define MT_TXS1_E_TXBF BIT(12) 3178c2ecf20Sopenharmony_ci#define MT_TXS1_TID GENMASK(11, 9) 3188c2ecf20Sopenharmony_ci#define MT_TXS1_AMPDU BIT(8) 3198c2ecf20Sopenharmony_ci#define MT_TXS1_ACKED_MPDU BIT(7) 3208c2ecf20Sopenharmony_ci#define MT_TXS1_TX_POWER_DBM GENMASK(6, 0) 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci#define MT_TXS2_WCID GENMASK(31, 24) 3238c2ecf20Sopenharmony_ci#define MT_TXS2_RXV_SEQNO GENMASK(23, 16) 3248c2ecf20Sopenharmony_ci#define MT_TXS2_TX_DELAY GENMASK(15, 0) 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci#define MT_TXS3_LAST_TX_RATE GENMASK(31, 29) 3278c2ecf20Sopenharmony_ci#define MT_TXS3_TX_COUNT GENMASK(28, 24) 3288c2ecf20Sopenharmony_ci#define MT_TXS3_F1_TSSI1 GENMASK(23, 12) 3298c2ecf20Sopenharmony_ci#define MT_TXS3_F1_TSSI0 GENMASK(11, 0) 3308c2ecf20Sopenharmony_ci#define MT_TXS3_F0_SEQNO GENMASK(11, 0) 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci#define MT_TXS4_F0_TIMESTAMP GENMASK(31, 0) 3338c2ecf20Sopenharmony_ci#define MT_TXS4_F1_TSSI3 GENMASK(23, 12) 3348c2ecf20Sopenharmony_ci#define MT_TXS4_F1_TSSI2 GENMASK(11, 0) 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci#define MT_TXS5_F0_FRONT_TIME GENMASK(24, 0) 3378c2ecf20Sopenharmony_ci#define MT_TXS5_F1_NOISE_2 GENMASK(23, 16) 3388c2ecf20Sopenharmony_ci#define MT_TXS5_F1_NOISE_1 GENMASK(15, 8) 3398c2ecf20Sopenharmony_ci#define MT_TXS5_F1_NOISE_0 GENMASK(7, 0) 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci#define MT_TXS6_F1_RCPI_3 GENMASK(31, 24) 3428c2ecf20Sopenharmony_ci#define MT_TXS6_F1_RCPI_2 GENMASK(23, 16) 3438c2ecf20Sopenharmony_ci#define MT_TXS6_F1_RCPI_1 GENMASK(15, 8) 3448c2ecf20Sopenharmony_ci#define MT_TXS6_F1_RCPI_0 GENMASK(7, 0) 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_cistruct mt7615_dfs_pulse { 3478c2ecf20Sopenharmony_ci u32 max_width; /* us */ 3488c2ecf20Sopenharmony_ci int max_pwr; /* dbm */ 3498c2ecf20Sopenharmony_ci int min_pwr; /* dbm */ 3508c2ecf20Sopenharmony_ci u32 min_stgr_pri; /* us */ 3518c2ecf20Sopenharmony_ci u32 max_stgr_pri; /* us */ 3528c2ecf20Sopenharmony_ci u32 min_cr_pri; /* us */ 3538c2ecf20Sopenharmony_ci u32 max_cr_pri; /* us */ 3548c2ecf20Sopenharmony_ci}; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_cistruct mt7615_dfs_pattern { 3578c2ecf20Sopenharmony_ci u8 enb; 3588c2ecf20Sopenharmony_ci u8 stgr; 3598c2ecf20Sopenharmony_ci u8 min_crpn; 3608c2ecf20Sopenharmony_ci u8 max_crpn; 3618c2ecf20Sopenharmony_ci u8 min_crpr; 3628c2ecf20Sopenharmony_ci u8 min_pw; 3638c2ecf20Sopenharmony_ci u8 max_pw; 3648c2ecf20Sopenharmony_ci u32 min_pri; 3658c2ecf20Sopenharmony_ci u32 max_pri; 3668c2ecf20Sopenharmony_ci u8 min_crbn; 3678c2ecf20Sopenharmony_ci u8 max_crbn; 3688c2ecf20Sopenharmony_ci u8 min_stgpn; 3698c2ecf20Sopenharmony_ci u8 max_stgpn; 3708c2ecf20Sopenharmony_ci u8 min_stgpr; 3718c2ecf20Sopenharmony_ci}; 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_cistruct mt7615_dfs_radar_spec { 3748c2ecf20Sopenharmony_ci struct mt7615_dfs_pulse pulse_th; 3758c2ecf20Sopenharmony_ci struct mt7615_dfs_pattern radar_pattern[16]; 3768c2ecf20Sopenharmony_ci}; 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_cienum mt7615_cipher_type { 3798c2ecf20Sopenharmony_ci MT_CIPHER_NONE, 3808c2ecf20Sopenharmony_ci MT_CIPHER_WEP40, 3818c2ecf20Sopenharmony_ci MT_CIPHER_TKIP, 3828c2ecf20Sopenharmony_ci MT_CIPHER_TKIP_NO_MIC, 3838c2ecf20Sopenharmony_ci MT_CIPHER_AES_CCMP, 3848c2ecf20Sopenharmony_ci MT_CIPHER_WEP104, 3858c2ecf20Sopenharmony_ci MT_CIPHER_BIP_CMAC_128, 3868c2ecf20Sopenharmony_ci MT_CIPHER_WEP128, 3878c2ecf20Sopenharmony_ci MT_CIPHER_WAPI, 3888c2ecf20Sopenharmony_ci MT_CIPHER_CCMP_256 = 10, 3898c2ecf20Sopenharmony_ci MT_CIPHER_GCMP, 3908c2ecf20Sopenharmony_ci MT_CIPHER_GCMP_256, 3918c2ecf20Sopenharmony_ci}; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistatic inline enum mt7615_cipher_type 3948c2ecf20Sopenharmony_cimt7615_mac_get_cipher(int cipher) 3958c2ecf20Sopenharmony_ci{ 3968c2ecf20Sopenharmony_ci switch (cipher) { 3978c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_WEP40: 3988c2ecf20Sopenharmony_ci return MT_CIPHER_WEP40; 3998c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_WEP104: 4008c2ecf20Sopenharmony_ci return MT_CIPHER_WEP104; 4018c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_TKIP: 4028c2ecf20Sopenharmony_ci return MT_CIPHER_TKIP; 4038c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_AES_CMAC: 4048c2ecf20Sopenharmony_ci return MT_CIPHER_BIP_CMAC_128; 4058c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_CCMP: 4068c2ecf20Sopenharmony_ci return MT_CIPHER_AES_CCMP; 4078c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_CCMP_256: 4088c2ecf20Sopenharmony_ci return MT_CIPHER_CCMP_256; 4098c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_GCMP: 4108c2ecf20Sopenharmony_ci return MT_CIPHER_GCMP; 4118c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_GCMP_256: 4128c2ecf20Sopenharmony_ci return MT_CIPHER_GCMP_256; 4138c2ecf20Sopenharmony_ci case WLAN_CIPHER_SUITE_SMS4: 4148c2ecf20Sopenharmony_ci return MT_CIPHER_WAPI; 4158c2ecf20Sopenharmony_ci default: 4168c2ecf20Sopenharmony_ci return MT_CIPHER_NONE; 4178c2ecf20Sopenharmony_ci } 4188c2ecf20Sopenharmony_ci} 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_cistatic inline struct mt7615_txp_common * 4218c2ecf20Sopenharmony_cimt7615_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t) 4228c2ecf20Sopenharmony_ci{ 4238c2ecf20Sopenharmony_ci u8 *txwi; 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci if (!t) 4268c2ecf20Sopenharmony_ci return NULL; 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci txwi = mt76_get_txwi_ptr(dev, t); 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci return (struct mt7615_txp_common *)(txwi + MT_TXD_SIZE); 4318c2ecf20Sopenharmony_ci} 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_cistatic inline u32 mt7615_mac_wtbl_addr(struct mt7615_dev *dev, int wcid) 4348c2ecf20Sopenharmony_ci{ 4358c2ecf20Sopenharmony_ci return MT_WTBL_BASE(dev) + wcid * MT_WTBL_ENTRY_SIZE; 4368c2ecf20Sopenharmony_ci} 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci#endif 439