162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 262306a36Sopenharmony_ci/* Copyright(c) 2020 Realtek Corporation 362306a36Sopenharmony_ci */ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#ifndef __RTW89_TXRX_H__ 662306a36Sopenharmony_ci#define __RTW89_TXRX_H__ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include "debug.h" 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#define DATA_RATE_MODE_CTRL_MASK GENMASK(8, 7) 1162306a36Sopenharmony_ci#define DATA_RATE_MODE_CTRL_MASK_V1 GENMASK(10, 8) 1262306a36Sopenharmony_ci#define DATA_RATE_NOT_HT_IDX_MASK GENMASK(3, 0) 1362306a36Sopenharmony_ci#define DATA_RATE_MODE_NON_HT 0x0 1462306a36Sopenharmony_ci#define DATA_RATE_HT_IDX_MASK GENMASK(4, 0) 1562306a36Sopenharmony_ci#define DATA_RATE_HT_IDX_MASK_V1 GENMASK(4, 0) 1662306a36Sopenharmony_ci#define DATA_RATE_MODE_HT 0x1 1762306a36Sopenharmony_ci#define DATA_RATE_VHT_HE_NSS_MASK GENMASK(6, 4) 1862306a36Sopenharmony_ci#define DATA_RATE_VHT_HE_IDX_MASK GENMASK(3, 0) 1962306a36Sopenharmony_ci#define DATA_RATE_NSS_MASK_V1 GENMASK(7, 5) 2062306a36Sopenharmony_ci#define DATA_RATE_MCS_MASK_V1 GENMASK(4, 0) 2162306a36Sopenharmony_ci#define DATA_RATE_MODE_VHT 0x2 2262306a36Sopenharmony_ci#define DATA_RATE_MODE_HE 0x3 2362306a36Sopenharmony_ci#define DATA_RATE_MODE_EHT 0x4 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistatic inline u8 rtw89_get_data_rate_mode(struct rtw89_dev *rtwdev, u16 hw_rate) 2662306a36Sopenharmony_ci{ 2762306a36Sopenharmony_ci if (rtwdev->chip->chip_gen == RTW89_CHIP_BE) 2862306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_MODE_CTRL_MASK_V1); 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_MODE_CTRL_MASK); 3162306a36Sopenharmony_ci} 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_cistatic inline u8 rtw89_get_data_not_ht_idx(struct rtw89_dev *rtwdev, u16 hw_rate) 3462306a36Sopenharmony_ci{ 3562306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_NOT_HT_IDX_MASK); 3662306a36Sopenharmony_ci} 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_cistatic inline u8 rtw89_get_data_ht_mcs(struct rtw89_dev *rtwdev, u16 hw_rate) 3962306a36Sopenharmony_ci{ 4062306a36Sopenharmony_ci if (rtwdev->chip->chip_gen == RTW89_CHIP_BE) 4162306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_HT_IDX_MASK_V1); 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_HT_IDX_MASK); 4462306a36Sopenharmony_ci} 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_cistatic inline u8 rtw89_get_data_mcs(struct rtw89_dev *rtwdev, u16 hw_rate) 4762306a36Sopenharmony_ci{ 4862306a36Sopenharmony_ci if (rtwdev->chip->chip_gen == RTW89_CHIP_BE) 4962306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_MCS_MASK_V1); 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_VHT_HE_IDX_MASK); 5262306a36Sopenharmony_ci} 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistatic inline u8 rtw89_get_data_nss(struct rtw89_dev *rtwdev, u16 hw_rate) 5562306a36Sopenharmony_ci{ 5662306a36Sopenharmony_ci if (rtwdev->chip->chip_gen == RTW89_CHIP_BE) 5762306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_NSS_MASK_V1); 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci return u16_get_bits(hw_rate, DATA_RATE_VHT_HE_NSS_MASK); 6062306a36Sopenharmony_ci} 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* TX WD BODY DWORD 0 */ 6362306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_WP_OFFSET GENMASK(31, 24) 6462306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_WP_OFFSET_V1 GENMASK(28, 24) 6562306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_MORE_DATA BIT(23) 6662306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_WD_INFO_EN BIT(22) 6762306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_FW_DL BIT(20) 6862306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_CHANNEL_DMA GENMASK(19, 16) 6962306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_HDR_LLC_LEN GENMASK(15, 11) 7062306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_WD_PAGE BIT(7) 7162306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_HW_AMSDU BIT(5) 7262306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_HW_SSN_SEL GENMASK(3, 2) 7362306a36Sopenharmony_ci#define RTW89_TXWD_BODY0_HW_SSN_MODE GENMASK(1, 0) 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* TX WD BODY DWORD 1 */ 7662306a36Sopenharmony_ci#define RTW89_TXWD_BODY1_ADDR_INFO_NUM GENMASK(31, 26) 7762306a36Sopenharmony_ci#define RTW89_TXWD_BODY1_PAYLOAD_ID GENMASK(31, 16) 7862306a36Sopenharmony_ci#define RTW89_TXWD_BODY1_SEC_KEYID GENMASK(5, 4) 7962306a36Sopenharmony_ci#define RTW89_TXWD_BODY1_SEC_TYPE GENMASK(3, 0) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* TX WD BODY DWORD 2 */ 8262306a36Sopenharmony_ci#define RTW89_TXWD_BODY2_MACID GENMASK(30, 24) 8362306a36Sopenharmony_ci#define RTW89_TXWD_BODY2_TID_INDICATE BIT(23) 8462306a36Sopenharmony_ci#define RTW89_TXWD_BODY2_QSEL GENMASK(22, 17) 8562306a36Sopenharmony_ci#define RTW89_TXWD_BODY2_TXPKT_SIZE GENMASK(13, 0) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/* TX WD BODY DWORD 3 */ 8862306a36Sopenharmony_ci#define RTW89_TXWD_BODY3_BK BIT(13) 8962306a36Sopenharmony_ci#define RTW89_TXWD_BODY3_AGG_EN BIT(12) 9062306a36Sopenharmony_ci#define RTW89_TXWD_BODY3_SW_SEQ GENMASK(11, 0) 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci/* TX WD BODY DWORD 4 */ 9362306a36Sopenharmony_ci#define RTW89_TXWD_BODY4_SEC_IV_L1 GENMASK(31, 24) 9462306a36Sopenharmony_ci#define RTW89_TXWD_BODY4_SEC_IV_L0 GENMASK(23, 16) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci/* TX WD BODY DWORD 5 */ 9762306a36Sopenharmony_ci#define RTW89_TXWD_BODY5_SEC_IV_H5 GENMASK(31, 24) 9862306a36Sopenharmony_ci#define RTW89_TXWD_BODY5_SEC_IV_H4 GENMASK(23, 16) 9962306a36Sopenharmony_ci#define RTW89_TXWD_BODY5_SEC_IV_H3 GENMASK(15, 8) 10062306a36Sopenharmony_ci#define RTW89_TXWD_BODY5_SEC_IV_H2 GENMASK(7, 0) 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci/* TX WD BODY DWORD 6 (V1) */ 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* TX WD BODY DWORD 7 (V1) */ 10562306a36Sopenharmony_ci#define RTW89_TXWD_BODY7_USE_RATE_V1 BIT(31) 10662306a36Sopenharmony_ci#define RTW89_TXWD_BODY7_DATA_BW GENMASK(29, 28) 10762306a36Sopenharmony_ci#define RTW89_TXWD_BODY7_GI_LTF GENMASK(27, 25) 10862306a36Sopenharmony_ci#define RTW89_TXWD_BODY7_DATA_RATE GENMASK(24, 16) 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* TX WD INFO DWORD 0 */ 11162306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_USE_RATE BIT(30) 11262306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_DATA_BW GENMASK(29, 28) 11362306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_GI_LTF GENMASK(27, 25) 11462306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_DATA_RATE GENMASK(24, 16) 11562306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_DATA_ER BIT(15) 11662306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_DISDATAFB BIT(10) 11762306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_DATA_BW_ER BIT(8) 11862306a36Sopenharmony_ci#define RTW89_TXWD_INFO0_MULTIPORT_ID GENMASK(6, 4) 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci/* TX WD INFO DWORD 1 */ 12162306a36Sopenharmony_ci#define RTW89_TXWD_INFO1_DATA_RTY_LOWEST_RATE GENMASK(24, 16) 12262306a36Sopenharmony_ci#define RTW89_TXWD_INFO1_A_CTRL_BSR BIT(14) 12362306a36Sopenharmony_ci#define RTW89_TXWD_INFO1_MAX_AGGNUM GENMASK(7, 0) 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* TX WD INFO DWORD 2 */ 12662306a36Sopenharmony_ci#define RTW89_TXWD_INFO2_AMPDU_DENSITY GENMASK(20, 18) 12762306a36Sopenharmony_ci#define RTW89_TXWD_INFO2_SEC_TYPE GENMASK(12, 9) 12862306a36Sopenharmony_ci#define RTW89_TXWD_INFO2_SEC_HW_ENC BIT(8) 12962306a36Sopenharmony_ci#define RTW89_TXWD_INFO2_FORCE_KEY_EN BIT(8) 13062306a36Sopenharmony_ci#define RTW89_TXWD_INFO2_SEC_CAM_IDX GENMASK(7, 0) 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/* TX WD INFO DWORD 3 */ 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci/* TX WD INFO DWORD 4 */ 13562306a36Sopenharmony_ci#define RTW89_TXWD_INFO4_RTS_EN BIT(27) 13662306a36Sopenharmony_ci#define RTW89_TXWD_INFO4_HW_RTS_EN BIT(31) 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* TX WD INFO DWORD 5 */ 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci/* RX WD dword0 */ 14162306a36Sopenharmony_ci#define AX_RXD_RPKT_LEN_MASK GENMASK(13, 0) 14262306a36Sopenharmony_ci#define AX_RXD_SHIFT_MASK GENMASK(15, 14) 14362306a36Sopenharmony_ci#define AX_RXD_WL_HD_IV_LEN_MASK GENMASK(21, 16) 14462306a36Sopenharmony_ci#define AX_RXD_BB_SEL BIT(22) 14562306a36Sopenharmony_ci#define AX_RXD_MAC_INFO_VLD BIT(23) 14662306a36Sopenharmony_ci#define AX_RXD_RPKT_TYPE_MASK GENMASK(27, 24) 14762306a36Sopenharmony_ci#define AX_RXD_DRV_INFO_SIZE_MASK GENMASK(30, 28) 14862306a36Sopenharmony_ci#define AX_RXD_LONG_RXD BIT(31) 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci/* RX WD dword1 */ 15162306a36Sopenharmony_ci#define AX_RXD_PPDU_TYPE_MASK GENMASK(3, 0) 15262306a36Sopenharmony_ci#define AX_RXD_PPDU_CNT_MASK GENMASK(6, 4) 15362306a36Sopenharmony_ci#define AX_RXD_SR_EN BIT(7) 15462306a36Sopenharmony_ci#define AX_RXD_USER_ID_MASK GENMASK(15, 8) 15562306a36Sopenharmony_ci#define AX_RXD_USER_ID_v1_MASK GENMASK(13, 8) 15662306a36Sopenharmony_ci#define AX_RXD_RX_DATARATE_MASK GENMASK(24, 16) 15762306a36Sopenharmony_ci#define AX_RXD_RX_GI_LTF_MASK GENMASK(27, 25) 15862306a36Sopenharmony_ci#define AX_RXD_NON_SRG_PPDU BIT(28) 15962306a36Sopenharmony_ci#define AX_RXD_INTER_PPDU BIT(29) 16062306a36Sopenharmony_ci#define AX_RXD_NON_SRG_PPDU_v1 BIT(14) 16162306a36Sopenharmony_ci#define AX_RXD_INTER_PPDU_v1 BIT(15) 16262306a36Sopenharmony_ci#define AX_RXD_BW_MASK GENMASK(31, 30) 16362306a36Sopenharmony_ci#define AX_RXD_BW_v1_MASK GENMASK(31, 29) 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci/* RX WD dword2 */ 16662306a36Sopenharmony_ci#define AX_RXD_FREERUN_CNT_MASK GENMASK(31, 0) 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci/* RX WD dword3 */ 16962306a36Sopenharmony_ci#define AX_RXD_A1_MATCH BIT(0) 17062306a36Sopenharmony_ci#define AX_RXD_SW_DEC BIT(1) 17162306a36Sopenharmony_ci#define AX_RXD_HW_DEC BIT(2) 17262306a36Sopenharmony_ci#define AX_RXD_AMPDU BIT(3) 17362306a36Sopenharmony_ci#define AX_RXD_AMPDU_END_PKT BIT(4) 17462306a36Sopenharmony_ci#define AX_RXD_AMSDU BIT(5) 17562306a36Sopenharmony_ci#define AX_RXD_AMSDU_CUT BIT(6) 17662306a36Sopenharmony_ci#define AX_RXD_LAST_MSDU BIT(7) 17762306a36Sopenharmony_ci#define AX_RXD_BYPASS BIT(8) 17862306a36Sopenharmony_ci#define AX_RXD_CRC32_ERR BIT(9) 17962306a36Sopenharmony_ci#define AX_RXD_ICV_ERR BIT(10) 18062306a36Sopenharmony_ci#define AX_RXD_MAGIC_WAKE BIT(11) 18162306a36Sopenharmony_ci#define AX_RXD_UNICAST_WAKE BIT(12) 18262306a36Sopenharmony_ci#define AX_RXD_PATTERN_WAKE BIT(13) 18362306a36Sopenharmony_ci#define AX_RXD_GET_CH_INFO_MASK GENMASK(15, 14) 18462306a36Sopenharmony_ci#define AX_RXD_PATTERN_IDX_MASK GENMASK(20, 16) 18562306a36Sopenharmony_ci#define AX_RXD_TARGET_IDC_MASK GENMASK(23, 21) 18662306a36Sopenharmony_ci#define AX_RXD_CHKSUM_OFFLOAD_EN BIT(24) 18762306a36Sopenharmony_ci#define AX_RXD_WITH_LLC BIT(25) 18862306a36Sopenharmony_ci#define AX_RXD_RX_STATISTICS BIT(26) 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci/* RX WD dword4 */ 19162306a36Sopenharmony_ci#define AX_RXD_TYPE_MASK GENMASK(1, 0) 19262306a36Sopenharmony_ci#define AX_RXD_MC BIT(2) 19362306a36Sopenharmony_ci#define AX_RXD_BC BIT(3) 19462306a36Sopenharmony_ci#define AX_RXD_MD BIT(4) 19562306a36Sopenharmony_ci#define AX_RXD_MF BIT(5) 19662306a36Sopenharmony_ci#define AX_RXD_PWR BIT(6) 19762306a36Sopenharmony_ci#define AX_RXD_QOS BIT(7) 19862306a36Sopenharmony_ci#define AX_RXD_TID_MASK GENMASK(11, 8) 19962306a36Sopenharmony_ci#define AX_RXD_EOSP BIT(12) 20062306a36Sopenharmony_ci#define AX_RXD_HTC BIT(13) 20162306a36Sopenharmony_ci#define AX_RXD_QNULL BIT(14) 20262306a36Sopenharmony_ci#define AX_RXD_SEQ_MASK GENMASK(27, 16) 20362306a36Sopenharmony_ci#define AX_RXD_FRAG_MASK GENMASK(31, 28) 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci/* RX WD dword5 */ 20662306a36Sopenharmony_ci#define AX_RXD_SEC_CAM_IDX_MASK GENMASK(7, 0) 20762306a36Sopenharmony_ci#define AX_RXD_ADDR_CAM_MASK GENMASK(15, 8) 20862306a36Sopenharmony_ci#define AX_RXD_MAC_ID_MASK GENMASK(23, 16) 20962306a36Sopenharmony_ci#define AX_RXD_RX_PL_ID_MASK GENMASK(27, 24) 21062306a36Sopenharmony_ci#define AX_RXD_ADDR_CAM_VLD BIT(28) 21162306a36Sopenharmony_ci#define AX_RXD_ADDR_FWD_EN BIT(29) 21262306a36Sopenharmony_ci#define AX_RXD_RX_PL_MATCH BIT(30) 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci/* RX WD dword6 */ 21562306a36Sopenharmony_ci#define AX_RXD_MAC_ADDR_MASK GENMASK(31, 0) 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci/* RX WD dword7 */ 21862306a36Sopenharmony_ci#define AX_RXD_MAC_ADDR_H_MASK GENMASK(15, 0) 21962306a36Sopenharmony_ci#define AX_RXD_SMART_ANT BIT(16) 22062306a36Sopenharmony_ci#define AX_RXD_SEC_TYPE_MASK GENMASK(20, 17) 22162306a36Sopenharmony_ci#define AX_RXD_HDR_CNV BIT(21) 22262306a36Sopenharmony_ci#define AX_RXD_HDR_OFFSET_MASK GENMASK(26, 22) 22362306a36Sopenharmony_ci#define AX_RXD_BIP_KEYID BIT(27) 22462306a36Sopenharmony_ci#define AX_RXD_BIP_ENC BIT(28) 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_cistruct rtw89_rxinfo_user { 22762306a36Sopenharmony_ci __le32 w0; 22862306a36Sopenharmony_ci}; 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci#define RTW89_RXINFO_USER_MAC_ID_VALID BIT(0) 23162306a36Sopenharmony_ci#define RTW89_RXINFO_USER_DATA BIT(1) 23262306a36Sopenharmony_ci#define RTW89_RXINFO_USER_CTRL BIT(2) 23362306a36Sopenharmony_ci#define RTW89_RXINFO_USER_MGMT BIT(3) 23462306a36Sopenharmony_ci#define RTW89_RXINFO_USER_BCM BIT(4) 23562306a36Sopenharmony_ci#define RTW89_RXINFO_USER_MACID GENMASK(15, 8) 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_cistruct rtw89_rxinfo { 23862306a36Sopenharmony_ci __le32 w0; 23962306a36Sopenharmony_ci __le32 w1; 24062306a36Sopenharmony_ci struct rtw89_rxinfo_user user[]; 24162306a36Sopenharmony_ci} __packed; 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci#define RTW89_RXINFO_W0_USR_NUM GENMASK(3, 0) 24462306a36Sopenharmony_ci#define RTW89_RXINFO_W0_FW_DEFINE GENMASK(15, 8) 24562306a36Sopenharmony_ci#define RTW89_RXINFO_W0_LSIG_LEN GENMASK(27, 16) 24662306a36Sopenharmony_ci#define RTW89_RXINFO_W0_IS_TO_SELF BIT(28) 24762306a36Sopenharmony_ci#define RTW89_RXINFO_W0_RX_CNT_VLD BIT(29) 24862306a36Sopenharmony_ci#define RTW89_RXINFO_W0_LONG_RXD GENMASK(31, 30) 24962306a36Sopenharmony_ci#define RTW89_RXINFO_W1_SERVICE GENMASK(15, 0) 25062306a36Sopenharmony_ci#define RTW89_RXINFO_W1_PLCP_LEN GENMASK(23, 16) 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_cistruct rtw89_phy_sts_hdr { 25362306a36Sopenharmony_ci __le32 w0; 25462306a36Sopenharmony_ci __le32 w1; 25562306a36Sopenharmony_ci} __packed; 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci#define RTW89_PHY_STS_HDR_W0_IE_MAP GENMASK(4, 0) 25862306a36Sopenharmony_ci#define RTW89_PHY_STS_HDR_W0_LEN GENMASK(15, 8) 25962306a36Sopenharmony_ci#define RTW89_PHY_STS_HDR_W0_RSSI_AVG GENMASK(31, 24) 26062306a36Sopenharmony_ci#define RTW89_PHY_STS_HDR_W1_RSSI_A GENMASK(7, 0) 26162306a36Sopenharmony_ci#define RTW89_PHY_STS_HDR_W1_RSSI_B GENMASK(15, 8) 26262306a36Sopenharmony_ci#define RTW89_PHY_STS_HDR_W1_RSSI_C GENMASK(23, 16) 26362306a36Sopenharmony_ci#define RTW89_PHY_STS_HDR_W1_RSSI_D GENMASK(31, 24) 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_cistruct rtw89_phy_sts_iehdr { 26662306a36Sopenharmony_ci __le32 w0; 26762306a36Sopenharmony_ci}; 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci#define RTW89_PHY_STS_IEHDR_TYPE GENMASK(4, 0) 27062306a36Sopenharmony_ci#define RTW89_PHY_STS_IEHDR_LEN GENMASK(11, 5) 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_cistruct rtw89_phy_sts_ie0 { 27362306a36Sopenharmony_ci __le32 w0; 27462306a36Sopenharmony_ci __le32 w1; 27562306a36Sopenharmony_ci __le32 w2; 27662306a36Sopenharmony_ci} __packed; 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_ci#define RTW89_PHY_STS_IE01_W0_CH_IDX GENMASK(23, 16) 27962306a36Sopenharmony_ci#define RTW89_PHY_STS_IE01_W1_FD_CFO GENMASK(19, 8) 28062306a36Sopenharmony_ci#define RTW89_PHY_STS_IE01_W1_PREMB_CFO GENMASK(31, 20) 28162306a36Sopenharmony_ci#define RTW89_PHY_STS_IE01_W2_AVG_SNR GENMASK(5, 0) 28262306a36Sopenharmony_ci#define RTW89_PHY_STS_IE01_W2_EVM_MAX GENMASK(15, 8) 28362306a36Sopenharmony_ci#define RTW89_PHY_STS_IE01_W2_EVM_MIN GENMASK(23, 16) 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_cienum rtw89_tx_channel { 28662306a36Sopenharmony_ci RTW89_TXCH_ACH0 = 0, 28762306a36Sopenharmony_ci RTW89_TXCH_ACH1 = 1, 28862306a36Sopenharmony_ci RTW89_TXCH_ACH2 = 2, 28962306a36Sopenharmony_ci RTW89_TXCH_ACH3 = 3, 29062306a36Sopenharmony_ci RTW89_TXCH_ACH4 = 4, 29162306a36Sopenharmony_ci RTW89_TXCH_ACH5 = 5, 29262306a36Sopenharmony_ci RTW89_TXCH_ACH6 = 6, 29362306a36Sopenharmony_ci RTW89_TXCH_ACH7 = 7, 29462306a36Sopenharmony_ci RTW89_TXCH_CH8 = 8, /* MGMT Band 0 */ 29562306a36Sopenharmony_ci RTW89_TXCH_CH9 = 9, /* HI Band 0 */ 29662306a36Sopenharmony_ci RTW89_TXCH_CH10 = 10, /* MGMT Band 1 */ 29762306a36Sopenharmony_ci RTW89_TXCH_CH11 = 11, /* HI Band 1 */ 29862306a36Sopenharmony_ci RTW89_TXCH_CH12 = 12, /* FW CMD */ 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci /* keep last */ 30162306a36Sopenharmony_ci RTW89_TXCH_NUM, 30262306a36Sopenharmony_ci RTW89_TXCH_MAX = RTW89_TXCH_NUM - 1 30362306a36Sopenharmony_ci}; 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_cienum rtw89_rx_channel { 30662306a36Sopenharmony_ci RTW89_RXCH_RXQ = 0, 30762306a36Sopenharmony_ci RTW89_RXCH_RPQ = 1, 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci /* keep last */ 31062306a36Sopenharmony_ci RTW89_RXCH_NUM, 31162306a36Sopenharmony_ci RTW89_RXCH_MAX = RTW89_RXCH_NUM - 1 31262306a36Sopenharmony_ci}; 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_cienum rtw89_tx_qsel { 31562306a36Sopenharmony_ci RTW89_TX_QSEL_BE_0 = 0x00, 31662306a36Sopenharmony_ci RTW89_TX_QSEL_BK_0 = 0x01, 31762306a36Sopenharmony_ci RTW89_TX_QSEL_VI_0 = 0x02, 31862306a36Sopenharmony_ci RTW89_TX_QSEL_VO_0 = 0x03, 31962306a36Sopenharmony_ci RTW89_TX_QSEL_BE_1 = 0x04, 32062306a36Sopenharmony_ci RTW89_TX_QSEL_BK_1 = 0x05, 32162306a36Sopenharmony_ci RTW89_TX_QSEL_VI_1 = 0x06, 32262306a36Sopenharmony_ci RTW89_TX_QSEL_VO_1 = 0x07, 32362306a36Sopenharmony_ci RTW89_TX_QSEL_BE_2 = 0x08, 32462306a36Sopenharmony_ci RTW89_TX_QSEL_BK_2 = 0x09, 32562306a36Sopenharmony_ci RTW89_TX_QSEL_VI_2 = 0x0a, 32662306a36Sopenharmony_ci RTW89_TX_QSEL_VO_2 = 0x0b, 32762306a36Sopenharmony_ci RTW89_TX_QSEL_BE_3 = 0x0c, 32862306a36Sopenharmony_ci RTW89_TX_QSEL_BK_3 = 0x0d, 32962306a36Sopenharmony_ci RTW89_TX_QSEL_VI_3 = 0x0e, 33062306a36Sopenharmony_ci RTW89_TX_QSEL_VO_3 = 0x0f, 33162306a36Sopenharmony_ci RTW89_TX_QSEL_B0_BCN = 0x10, 33262306a36Sopenharmony_ci RTW89_TX_QSEL_B0_HI = 0x11, 33362306a36Sopenharmony_ci RTW89_TX_QSEL_B0_MGMT = 0x12, 33462306a36Sopenharmony_ci RTW89_TX_QSEL_B0_NOPS = 0x13, 33562306a36Sopenharmony_ci RTW89_TX_QSEL_B0_MGMT_FAST = 0x14, 33662306a36Sopenharmony_ci /* reserved */ 33762306a36Sopenharmony_ci /* reserved */ 33862306a36Sopenharmony_ci /* reserved */ 33962306a36Sopenharmony_ci RTW89_TX_QSEL_B1_BCN = 0x18, 34062306a36Sopenharmony_ci RTW89_TX_QSEL_B1_HI = 0x19, 34162306a36Sopenharmony_ci RTW89_TX_QSEL_B1_MGMT = 0x1a, 34262306a36Sopenharmony_ci RTW89_TX_QSEL_B1_NOPS = 0x1b, 34362306a36Sopenharmony_ci RTW89_TX_QSEL_B1_MGMT_FAST = 0x1c, 34462306a36Sopenharmony_ci /* reserved */ 34562306a36Sopenharmony_ci /* reserved */ 34662306a36Sopenharmony_ci /* reserved */ 34762306a36Sopenharmony_ci}; 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_cistatic inline u8 rtw89_core_get_qsel(struct rtw89_dev *rtwdev, u8 tid) 35062306a36Sopenharmony_ci{ 35162306a36Sopenharmony_ci switch (tid) { 35262306a36Sopenharmony_ci default: 35362306a36Sopenharmony_ci rtw89_warn(rtwdev, "Should use tag 1d: %d\n", tid); 35462306a36Sopenharmony_ci fallthrough; 35562306a36Sopenharmony_ci case 0: 35662306a36Sopenharmony_ci case 3: 35762306a36Sopenharmony_ci return RTW89_TX_QSEL_BE_0; 35862306a36Sopenharmony_ci case 1: 35962306a36Sopenharmony_ci case 2: 36062306a36Sopenharmony_ci return RTW89_TX_QSEL_BK_0; 36162306a36Sopenharmony_ci case 4: 36262306a36Sopenharmony_ci case 5: 36362306a36Sopenharmony_ci return RTW89_TX_QSEL_VI_0; 36462306a36Sopenharmony_ci case 6: 36562306a36Sopenharmony_ci case 7: 36662306a36Sopenharmony_ci return RTW89_TX_QSEL_VO_0; 36762306a36Sopenharmony_ci } 36862306a36Sopenharmony_ci} 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_cistatic inline u8 rtw89_core_get_ch_dma(struct rtw89_dev *rtwdev, u8 qsel) 37162306a36Sopenharmony_ci{ 37262306a36Sopenharmony_ci switch (qsel) { 37362306a36Sopenharmony_ci default: 37462306a36Sopenharmony_ci rtw89_warn(rtwdev, "Cannot map qsel to dma: %d\n", qsel); 37562306a36Sopenharmony_ci fallthrough; 37662306a36Sopenharmony_ci case RTW89_TX_QSEL_BE_0: 37762306a36Sopenharmony_ci return RTW89_TXCH_ACH0; 37862306a36Sopenharmony_ci case RTW89_TX_QSEL_BK_0: 37962306a36Sopenharmony_ci return RTW89_TXCH_ACH1; 38062306a36Sopenharmony_ci case RTW89_TX_QSEL_VI_0: 38162306a36Sopenharmony_ci return RTW89_TXCH_ACH2; 38262306a36Sopenharmony_ci case RTW89_TX_QSEL_VO_0: 38362306a36Sopenharmony_ci return RTW89_TXCH_ACH3; 38462306a36Sopenharmony_ci case RTW89_TX_QSEL_B0_MGMT: 38562306a36Sopenharmony_ci return RTW89_TXCH_CH8; 38662306a36Sopenharmony_ci case RTW89_TX_QSEL_B0_HI: 38762306a36Sopenharmony_ci return RTW89_TXCH_CH9; 38862306a36Sopenharmony_ci case RTW89_TX_QSEL_B1_MGMT: 38962306a36Sopenharmony_ci return RTW89_TXCH_CH10; 39062306a36Sopenharmony_ci case RTW89_TX_QSEL_B1_HI: 39162306a36Sopenharmony_ci return RTW89_TXCH_CH11; 39262306a36Sopenharmony_ci } 39362306a36Sopenharmony_ci} 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_cistatic inline u8 rtw89_core_get_tid_indicate(struct rtw89_dev *rtwdev, u8 tid) 39662306a36Sopenharmony_ci{ 39762306a36Sopenharmony_ci switch (tid) { 39862306a36Sopenharmony_ci case 3: 39962306a36Sopenharmony_ci case 2: 40062306a36Sopenharmony_ci case 5: 40162306a36Sopenharmony_ci case 7: 40262306a36Sopenharmony_ci return 1; 40362306a36Sopenharmony_ci default: 40462306a36Sopenharmony_ci rtw89_warn(rtwdev, "Should use tag 1d: %d\n", tid); 40562306a36Sopenharmony_ci fallthrough; 40662306a36Sopenharmony_ci case 0: 40762306a36Sopenharmony_ci case 1: 40862306a36Sopenharmony_ci case 4: 40962306a36Sopenharmony_ci case 6: 41062306a36Sopenharmony_ci return 0; 41162306a36Sopenharmony_ci } 41262306a36Sopenharmony_ci} 41362306a36Sopenharmony_ci 41462306a36Sopenharmony_ci#endif 415