1e3ec7017SPing-Ke Shih /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2e3ec7017SPing-Ke Shih /* Copyright(c) 2019-2020 Realtek Corporation 3e3ec7017SPing-Ke Shih */ 4e3ec7017SPing-Ke Shih 5e3ec7017SPing-Ke Shih #ifndef __RTW89_CORE_H__ 6e3ec7017SPing-Ke Shih #define __RTW89_CORE_H__ 7e3ec7017SPing-Ke Shih 8e3ec7017SPing-Ke Shih #include <linux/average.h> 9e3ec7017SPing-Ke Shih #include <linux/bitfield.h> 10e3ec7017SPing-Ke Shih #include <linux/firmware.h> 11e3ec7017SPing-Ke Shih #include <linux/iopoll.h> 12e3ec7017SPing-Ke Shih #include <linux/workqueue.h> 13e3ec7017SPing-Ke Shih #include <net/mac80211.h> 14e3ec7017SPing-Ke Shih 15e3ec7017SPing-Ke Shih struct rtw89_dev; 164a9e48acSPing-Ke Shih struct rtw89_pci_info; 17e3ec7017SPing-Ke Shih 18e3ec7017SPing-Ke Shih extern const struct ieee80211_ops rtw89_ops; 19e3ec7017SPing-Ke Shih 20e3ec7017SPing-Ke Shih #define MASKBYTE0 0xff 21e3ec7017SPing-Ke Shih #define MASKBYTE1 0xff00 22e3ec7017SPing-Ke Shih #define MASKBYTE2 0xff0000 23e3ec7017SPing-Ke Shih #define MASKBYTE3 0xff000000 24e3ec7017SPing-Ke Shih #define MASKBYTE4 0xff00000000ULL 25e3ec7017SPing-Ke Shih #define MASKHWORD 0xffff0000 26e3ec7017SPing-Ke Shih #define MASKLWORD 0x0000ffff 27e3ec7017SPing-Ke Shih #define MASKDWORD 0xffffffff 28e3ec7017SPing-Ke Shih #define RFREG_MASK 0xfffff 29e3ec7017SPing-Ke Shih #define INV_RF_DATA 0xffffffff 30e3ec7017SPing-Ke Shih 31e3ec7017SPing-Ke Shih #define RTW89_TRACK_WORK_PERIOD round_jiffies_relative(HZ * 2) 32679955d5SKuan-Chung Chen #define RTW89_FORBID_BA_TIMER round_jiffies_relative(HZ * 4) 33e3ec7017SPing-Ke Shih #define CFO_TRACK_MAX_USER 64 34e3ec7017SPing-Ke Shih #define MAX_RSSI 110 35e3ec7017SPing-Ke Shih #define RSSI_FACTOR 1 36e3ec7017SPing-Ke Shih #define RTW89_RSSI_RAW_TO_DBM(rssi) ((s8)((rssi) >> RSSI_FACTOR) - MAX_RSSI) 377dbdf655SPing-Ke Shih #define RTW89_TX_DIV_RSSI_RAW_TH (2 << RSSI_FACTOR) 38e3ec7017SPing-Ke Shih 39e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_VARIANT GENMASK(1, 0) 40e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE 3 41e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_CTL_ID GENMASK(5, 2) 42e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE_CID_OM 1 43e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE_CID_CAS 6 44e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_CTL_INFO GENMASK(31, 6) 45e3ec7017SPing-Ke Shih 46e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_RX_NSS GENMASK(8, 6) 47e3ec7017SPing-Ke Shih enum htc_om_channel_width { 48e3ec7017SPing-Ke Shih HTC_OM_CHANNEL_WIDTH_20 = 0, 49e3ec7017SPing-Ke Shih HTC_OM_CHANNEL_WIDTH_40 = 1, 50e3ec7017SPing-Ke Shih HTC_OM_CHANNEL_WIDTH_80 = 2, 51e3ec7017SPing-Ke Shih HTC_OM_CHANNEL_WIDTH_160_OR_80_80 = 3, 52e3ec7017SPing-Ke Shih }; 53e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_CH_WIDTH GENMASK(10, 9) 54e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_UL_MU_DIS BIT(11) 55e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_TX_NSTS GENMASK(14, 12) 56e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_ER_SU_DIS BIT(15) 57e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_DL_MU_MIMO_RR BIT(16) 58e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_UL_MU_DATA_DIS BIT(17) 59e3ec7017SPing-Ke Shih 605165f168SPo Hao Huang #define RTW89_TF_PAD GENMASK(11, 0) 615165f168SPo Hao Huang #define RTW89_TF_BASIC_USER_INFO_SZ 6 625165f168SPo Hao Huang 635165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_AID12(data) \ 645165f168SPo Hao Huang le32_get_bits(*((const __le32 *)(data)), GENMASK(11, 0)) 655165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_RUA(data) \ 665165f168SPo Hao Huang le32_get_bits(*((const __le32 *)(data)), GENMASK(19, 12)) 675165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_UL_MCS(data) \ 685165f168SPo Hao Huang le32_get_bits(*((const __le32 *)(data)), GENMASK(24, 21)) 695165f168SPo Hao Huang 70e3ec7017SPing-Ke Shih enum rtw89_subband { 71e3ec7017SPing-Ke Shih RTW89_CH_2G = 0, 72e3ec7017SPing-Ke Shih RTW89_CH_5G_BAND_1 = 1, 73e3ec7017SPing-Ke Shih /* RTW89_CH_5G_BAND_2 = 2, unused */ 74e3ec7017SPing-Ke Shih RTW89_CH_5G_BAND_3 = 3, 75e3ec7017SPing-Ke Shih RTW89_CH_5G_BAND_4 = 4, 76e3ec7017SPing-Ke Shih 778e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX0, /* Low */ 788e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX1, /* Low */ 798e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX2, /* Mid */ 808e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX3, /* Mid */ 818e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX4, /* High */ 828e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX5, /* High */ 838e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX6, /* Ultra-high */ 848e438ad4SZong-Zhe Yang RTW89_CH_6G_BAND_IDX7, /* Ultra-high */ 858e438ad4SZong-Zhe Yang 86e3ec7017SPing-Ke Shih RTW89_SUBBAND_NR, 87e3ec7017SPing-Ke Shih }; 88e3ec7017SPing-Ke Shih 89e6b17cbdSPing-Ke Shih enum rtw89_gain_offset { 90e6b17cbdSPing-Ke Shih RTW89_GAIN_OFFSET_2G_CCK, 91e6b17cbdSPing-Ke Shih RTW89_GAIN_OFFSET_2G_OFDM, 92e6b17cbdSPing-Ke Shih RTW89_GAIN_OFFSET_5G_LOW, 93e6b17cbdSPing-Ke Shih RTW89_GAIN_OFFSET_5G_MID, 94e6b17cbdSPing-Ke Shih RTW89_GAIN_OFFSET_5G_HIGH, 95e6b17cbdSPing-Ke Shih 96e6b17cbdSPing-Ke Shih RTW89_GAIN_OFFSET_NR, 97e6b17cbdSPing-Ke Shih }; 98e6b17cbdSPing-Ke Shih 99e3ec7017SPing-Ke Shih enum rtw89_hci_type { 100e3ec7017SPing-Ke Shih RTW89_HCI_TYPE_PCIE, 101e3ec7017SPing-Ke Shih RTW89_HCI_TYPE_USB, 102e3ec7017SPing-Ke Shih RTW89_HCI_TYPE_SDIO, 103e3ec7017SPing-Ke Shih }; 104e3ec7017SPing-Ke Shih 105e3ec7017SPing-Ke Shih enum rtw89_core_chip_id { 106e3ec7017SPing-Ke Shih RTL8852A, 107e3ec7017SPing-Ke Shih RTL8852B, 108e3ec7017SPing-Ke Shih RTL8852C, 109e3ec7017SPing-Ke Shih }; 110e3ec7017SPing-Ke Shih 111e3ec7017SPing-Ke Shih enum rtw89_cv { 112e3ec7017SPing-Ke Shih CHIP_CAV, 113e3ec7017SPing-Ke Shih CHIP_CBV, 114e3ec7017SPing-Ke Shih CHIP_CCV, 115e3ec7017SPing-Ke Shih CHIP_CDV, 116e3ec7017SPing-Ke Shih CHIP_CEV, 117e3ec7017SPing-Ke Shih CHIP_CFV, 118e3ec7017SPing-Ke Shih CHIP_CV_MAX, 119e3ec7017SPing-Ke Shih CHIP_CV_INVALID = CHIP_CV_MAX, 120e3ec7017SPing-Ke Shih }; 121e3ec7017SPing-Ke Shih 122e3ec7017SPing-Ke Shih enum rtw89_core_tx_type { 123e3ec7017SPing-Ke Shih RTW89_CORE_TX_TYPE_DATA, 124e3ec7017SPing-Ke Shih RTW89_CORE_TX_TYPE_MGMT, 125e3ec7017SPing-Ke Shih RTW89_CORE_TX_TYPE_FWCMD, 126e3ec7017SPing-Ke Shih }; 127e3ec7017SPing-Ke Shih 128e3ec7017SPing-Ke Shih enum rtw89_core_rx_type { 129e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_WIFI = 0, 130e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_PPDU_STAT = 1, 131e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_CHAN_INFO = 2, 132e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_BB_SCOPE = 3, 133e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_F2P_TXCMD = 4, 134e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_SS2FW = 5, 135e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_TX_REPORT = 6, 136e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_TX_REL_HOST = 7, 137e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_DFS_REPORT = 8, 138e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_TX_REL_CPU = 9, 139e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_C2H = 10, 140e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_CSI = 11, 141e3ec7017SPing-Ke Shih RTW89_CORE_RX_TYPE_CQI = 12, 142a95bd62eSPing-Ke Shih RTW89_CORE_RX_TYPE_H2C = 13, 143a95bd62eSPing-Ke Shih RTW89_CORE_RX_TYPE_FWDL = 14, 144e3ec7017SPing-Ke Shih }; 145e3ec7017SPing-Ke Shih 146e3ec7017SPing-Ke Shih enum rtw89_txq_flags { 147e3ec7017SPing-Ke Shih RTW89_TXQ_F_AMPDU = 0, 148e3ec7017SPing-Ke Shih RTW89_TXQ_F_BLOCK_BA = 1, 149679955d5SKuan-Chung Chen RTW89_TXQ_F_FORBID_BA = 2, 150e3ec7017SPing-Ke Shih }; 151e3ec7017SPing-Ke Shih 152e3ec7017SPing-Ke Shih enum rtw89_net_type { 153e3ec7017SPing-Ke Shih RTW89_NET_TYPE_NO_LINK = 0, 154e3ec7017SPing-Ke Shih RTW89_NET_TYPE_AD_HOC = 1, 155e3ec7017SPing-Ke Shih RTW89_NET_TYPE_INFRA = 2, 156e3ec7017SPing-Ke Shih RTW89_NET_TYPE_AP_MODE = 3, 157e3ec7017SPing-Ke Shih }; 158e3ec7017SPing-Ke Shih 159e3ec7017SPing-Ke Shih enum rtw89_wifi_role { 160e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_NONE, 161e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_STATION, 162e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_AP, 163e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_AP_VLAN, 164e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_ADHOC, 165e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_ADHOC_MASTER, 166e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_MESH_POINT, 167e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_MONITOR, 168e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_P2P_DEVICE, 169e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_P2P_CLIENT, 170e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_P2P_GO, 171e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_NAN, 172e3ec7017SPing-Ke Shih RTW89_WIFI_ROLE_MLME_MAX 173e3ec7017SPing-Ke Shih }; 174e3ec7017SPing-Ke Shih 175e3ec7017SPing-Ke Shih enum rtw89_upd_mode { 1768b252070SPing-Ke Shih RTW89_ROLE_CREATE, 1778b252070SPing-Ke Shih RTW89_ROLE_REMOVE, 1788b252070SPing-Ke Shih RTW89_ROLE_TYPE_CHANGE, 1798b252070SPing-Ke Shih RTW89_ROLE_INFO_CHANGE, 1808b252070SPing-Ke Shih RTW89_ROLE_CON_DISCONN 181e3ec7017SPing-Ke Shih }; 182e3ec7017SPing-Ke Shih 183e3ec7017SPing-Ke Shih enum rtw89_self_role { 184e3ec7017SPing-Ke Shih RTW89_SELF_ROLE_CLIENT, 185e3ec7017SPing-Ke Shih RTW89_SELF_ROLE_AP, 186e3ec7017SPing-Ke Shih RTW89_SELF_ROLE_AP_CLIENT 187e3ec7017SPing-Ke Shih }; 188e3ec7017SPing-Ke Shih 189e3ec7017SPing-Ke Shih enum rtw89_msk_sO_el { 190e3ec7017SPing-Ke Shih RTW89_NO_MSK, 191e3ec7017SPing-Ke Shih RTW89_SMA, 192e3ec7017SPing-Ke Shih RTW89_TMA, 193e3ec7017SPing-Ke Shih RTW89_BSSID 194e3ec7017SPing-Ke Shih }; 195e3ec7017SPing-Ke Shih 196e3ec7017SPing-Ke Shih enum rtw89_sch_tx_sel { 197e3ec7017SPing-Ke Shih RTW89_SCH_TX_SEL_ALL, 198e3ec7017SPing-Ke Shih RTW89_SCH_TX_SEL_HIQ, 199e3ec7017SPing-Ke Shih RTW89_SCH_TX_SEL_MG0, 200e3ec7017SPing-Ke Shih RTW89_SCH_TX_SEL_MACID, 201e3ec7017SPing-Ke Shih }; 202e3ec7017SPing-Ke Shih 203e3ec7017SPing-Ke Shih /* RTW89_ADDR_CAM_SEC_NONE : not enabled 204e3ec7017SPing-Ke Shih * RTW89_ADDR_CAM_SEC_ALL_UNI : 0 - 6 unicast 205e3ec7017SPing-Ke Shih * RTW89_ADDR_CAM_SEC_NORMAL : 0 - 1 unicast, 2 - 4 group, 5 - 6 BIP 206e3ec7017SPing-Ke Shih * RTW89_ADDR_CAM_SEC_4GROUP : 0 - 1 unicast, 2 - 5 group, 6 BIP 207e3ec7017SPing-Ke Shih */ 208e3ec7017SPing-Ke Shih enum rtw89_add_cam_sec_mode { 209e3ec7017SPing-Ke Shih RTW89_ADDR_CAM_SEC_NONE = 0, 210e3ec7017SPing-Ke Shih RTW89_ADDR_CAM_SEC_ALL_UNI = 1, 211e3ec7017SPing-Ke Shih RTW89_ADDR_CAM_SEC_NORMAL = 2, 212e3ec7017SPing-Ke Shih RTW89_ADDR_CAM_SEC_4GROUP = 3, 213e3ec7017SPing-Ke Shih }; 214e3ec7017SPing-Ke Shih 215e3ec7017SPing-Ke Shih enum rtw89_sec_key_type { 216e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_NONE = 0, 217e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_WEP40 = 1, 218e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_WEP104 = 2, 219e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_TKIP = 3, 220e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_WAPI = 4, 221e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_GCMSMS4 = 5, 222e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_CCMP128 = 6, 223e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_CCMP256 = 7, 224e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_GCMP128 = 8, 225e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_GCMP256 = 9, 226e3ec7017SPing-Ke Shih RTW89_SEC_KEY_TYPE_BIP_CCMP128 = 10, 227e3ec7017SPing-Ke Shih }; 228e3ec7017SPing-Ke Shih 229e3ec7017SPing-Ke Shih enum rtw89_port { 230e3ec7017SPing-Ke Shih RTW89_PORT_0 = 0, 231e3ec7017SPing-Ke Shih RTW89_PORT_1 = 1, 232e3ec7017SPing-Ke Shih RTW89_PORT_2 = 2, 233e3ec7017SPing-Ke Shih RTW89_PORT_3 = 3, 234e3ec7017SPing-Ke Shih RTW89_PORT_4 = 4, 235e3ec7017SPing-Ke Shih RTW89_PORT_NUM 236e3ec7017SPing-Ke Shih }; 237e3ec7017SPing-Ke Shih 238e3ec7017SPing-Ke Shih enum rtw89_band { 239e3ec7017SPing-Ke Shih RTW89_BAND_2G = 0, 240e3ec7017SPing-Ke Shih RTW89_BAND_5G = 1, 2410237f65aSZong-Zhe Yang RTW89_BAND_6G = 2, 242e3ec7017SPing-Ke Shih RTW89_BAND_MAX, 243e3ec7017SPing-Ke Shih }; 244e3ec7017SPing-Ke Shih 245e3ec7017SPing-Ke Shih enum rtw89_hw_rate { 246e3ec7017SPing-Ke Shih RTW89_HW_RATE_CCK1 = 0x0, 247e3ec7017SPing-Ke Shih RTW89_HW_RATE_CCK2 = 0x1, 248e3ec7017SPing-Ke Shih RTW89_HW_RATE_CCK5_5 = 0x2, 249e3ec7017SPing-Ke Shih RTW89_HW_RATE_CCK11 = 0x3, 250e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM6 = 0x4, 251e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM9 = 0x5, 252e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM12 = 0x6, 253e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM18 = 0x7, 254e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM24 = 0x8, 255e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM36 = 0x9, 256e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM48 = 0xA, 257e3ec7017SPing-Ke Shih RTW89_HW_RATE_OFDM54 = 0xB, 258e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS0 = 0x80, 259e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS1 = 0x81, 260e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS2 = 0x82, 261e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS3 = 0x83, 262e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS4 = 0x84, 263e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS5 = 0x85, 264e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS6 = 0x86, 265e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS7 = 0x87, 266e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS8 = 0x88, 267e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS9 = 0x89, 268e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS10 = 0x8A, 269e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS11 = 0x8B, 270e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS12 = 0x8C, 271e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS13 = 0x8D, 272e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS14 = 0x8E, 273e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS15 = 0x8F, 274e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS16 = 0x90, 275e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS17 = 0x91, 276e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS18 = 0x92, 277e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS19 = 0x93, 278e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS20 = 0x94, 279e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS21 = 0x95, 280e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS22 = 0x96, 281e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS23 = 0x97, 282e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS24 = 0x98, 283e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS25 = 0x99, 284e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS26 = 0x9A, 285e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS27 = 0x9B, 286e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS28 = 0x9C, 287e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS29 = 0x9D, 288e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS30 = 0x9E, 289e3ec7017SPing-Ke Shih RTW89_HW_RATE_MCS31 = 0x9F, 290e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS0 = 0x100, 291e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS1 = 0x101, 292e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS2 = 0x102, 293e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS3 = 0x103, 294e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS4 = 0x104, 295e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS5 = 0x105, 296e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS6 = 0x106, 297e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS7 = 0x107, 298e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS8 = 0x108, 299e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS1_MCS9 = 0x109, 300e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS0 = 0x110, 301e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS1 = 0x111, 302e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS2 = 0x112, 303e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS3 = 0x113, 304e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS4 = 0x114, 305e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS5 = 0x115, 306e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS6 = 0x116, 307e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS7 = 0x117, 308e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS8 = 0x118, 309e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS2_MCS9 = 0x119, 310e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS0 = 0x120, 311e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS1 = 0x121, 312e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS2 = 0x122, 313e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS3 = 0x123, 314e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS4 = 0x124, 315e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS5 = 0x125, 316e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS6 = 0x126, 317e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS7 = 0x127, 318e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS8 = 0x128, 319e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS3_MCS9 = 0x129, 320e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS0 = 0x130, 321e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS1 = 0x131, 322e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS2 = 0x132, 323e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS3 = 0x133, 324e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS4 = 0x134, 325e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS5 = 0x135, 326e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS6 = 0x136, 327e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS7 = 0x137, 328e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS8 = 0x138, 329e3ec7017SPing-Ke Shih RTW89_HW_RATE_VHT_NSS4_MCS9 = 0x139, 330e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS0 = 0x180, 331e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS1 = 0x181, 332e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS2 = 0x182, 333e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS3 = 0x183, 334e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS4 = 0x184, 335e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS5 = 0x185, 336e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS6 = 0x186, 337e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS7 = 0x187, 338e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS8 = 0x188, 339e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS9 = 0x189, 340e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS10 = 0x18A, 341e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS1_MCS11 = 0x18B, 342e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS0 = 0x190, 343e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS1 = 0x191, 344e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS2 = 0x192, 345e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS3 = 0x193, 346e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS4 = 0x194, 347e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS5 = 0x195, 348e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS6 = 0x196, 349e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS7 = 0x197, 350e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS8 = 0x198, 351e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS9 = 0x199, 352e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS10 = 0x19A, 353e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS2_MCS11 = 0x19B, 354e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS0 = 0x1A0, 355e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS1 = 0x1A1, 356e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS2 = 0x1A2, 357e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS3 = 0x1A3, 358e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS4 = 0x1A4, 359e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS5 = 0x1A5, 360e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS6 = 0x1A6, 361e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS7 = 0x1A7, 362e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS8 = 0x1A8, 363e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS9 = 0x1A9, 364e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS10 = 0x1AA, 365e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS3_MCS11 = 0x1AB, 366e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS0 = 0x1B0, 367e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS1 = 0x1B1, 368e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS2 = 0x1B2, 369e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS3 = 0x1B3, 370e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS4 = 0x1B4, 371e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS5 = 0x1B5, 372e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS6 = 0x1B6, 373e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS7 = 0x1B7, 374e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS8 = 0x1B8, 375e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS9 = 0x1B9, 376e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS10 = 0x1BA, 377e3ec7017SPing-Ke Shih RTW89_HW_RATE_HE_NSS4_MCS11 = 0x1BB, 378e3ec7017SPing-Ke Shih RTW89_HW_RATE_NR, 379e3ec7017SPing-Ke Shih 380e3ec7017SPing-Ke Shih RTW89_HW_RATE_MASK_MOD = GENMASK(8, 7), 381e3ec7017SPing-Ke Shih RTW89_HW_RATE_MASK_VAL = GENMASK(6, 0), 382e3ec7017SPing-Ke Shih }; 383e3ec7017SPing-Ke Shih 384e3ec7017SPing-Ke Shih /* 2G channels, 385e3ec7017SPing-Ke Shih * 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 386e3ec7017SPing-Ke Shih */ 387e3ec7017SPing-Ke Shih #define RTW89_2G_CH_NUM 14 388e3ec7017SPing-Ke Shih 389e3ec7017SPing-Ke Shih /* 5G channels, 390e3ec7017SPing-Ke Shih * 36, 38, 40, 42, 44, 46, 48, 50, 391e3ec7017SPing-Ke Shih * 52, 54, 56, 58, 60, 62, 64, 392e3ec7017SPing-Ke Shih * 100, 102, 104, 106, 108, 110, 112, 114, 393e3ec7017SPing-Ke Shih * 116, 118, 120, 122, 124, 126, 128, 130, 394e3ec7017SPing-Ke Shih * 132, 134, 136, 138, 140, 142, 144, 395e3ec7017SPing-Ke Shih * 149, 151, 153, 155, 157, 159, 161, 163, 396e3ec7017SPing-Ke Shih * 165, 167, 169, 171, 173, 175, 177 397e3ec7017SPing-Ke Shih */ 398e3ec7017SPing-Ke Shih #define RTW89_5G_CH_NUM 53 399e3ec7017SPing-Ke Shih 400ac74f016SZong-Zhe Yang /* 6G channels, 401ac74f016SZong-Zhe Yang * 1, 3, 5, 7, 9, 11, 13, 15, 402ac74f016SZong-Zhe Yang * 17, 19, 21, 23, 25, 27, 29, 33, 403ac74f016SZong-Zhe Yang * 35, 37, 39, 41, 43, 45, 47, 49, 404ac74f016SZong-Zhe Yang * 51, 53, 55, 57, 59, 61, 65, 67, 405ac74f016SZong-Zhe Yang * 69, 71, 73, 75, 77, 79, 81, 83, 406ac74f016SZong-Zhe Yang * 85, 87, 89, 91, 93, 97, 99, 101, 407ac74f016SZong-Zhe Yang * 103, 105, 107, 109, 111, 113, 115, 117, 408ac74f016SZong-Zhe Yang * 119, 121, 123, 125, 129, 131, 133, 135, 409ac74f016SZong-Zhe Yang * 137, 139, 141, 143, 145, 147, 149, 151, 410ac74f016SZong-Zhe Yang * 153, 155, 157, 161, 163, 165, 167, 169, 411ac74f016SZong-Zhe Yang * 171, 173, 175, 177, 179, 181, 183, 185, 412ac74f016SZong-Zhe Yang * 187, 189, 193, 195, 197, 199, 201, 203, 413ac74f016SZong-Zhe Yang * 205, 207, 209, 211, 213, 215, 217, 219, 414ac74f016SZong-Zhe Yang * 221, 225, 227, 229, 231, 233, 235, 237, 415ac74f016SZong-Zhe Yang * 239, 241, 243, 245, 247, 249, 251, 253, 416ac74f016SZong-Zhe Yang */ 417ac74f016SZong-Zhe Yang #define RTW89_6G_CH_NUM 120 418ac74f016SZong-Zhe Yang 419e3ec7017SPing-Ke Shih enum rtw89_rate_section { 420e3ec7017SPing-Ke Shih RTW89_RS_CCK, 421e3ec7017SPing-Ke Shih RTW89_RS_OFDM, 422e3ec7017SPing-Ke Shih RTW89_RS_MCS, /* for HT/VHT/HE */ 423e3ec7017SPing-Ke Shih RTW89_RS_HEDCM, 424e3ec7017SPing-Ke Shih RTW89_RS_OFFSET, 425e3ec7017SPing-Ke Shih RTW89_RS_MAX, 426e3ec7017SPing-Ke Shih RTW89_RS_LMT_NUM = RTW89_RS_MCS + 1, 427342475acSPing-Ke Shih RTW89_RS_TX_SHAPE_NUM = RTW89_RS_OFDM + 1, 428e3ec7017SPing-Ke Shih }; 429e3ec7017SPing-Ke Shih 430e3ec7017SPing-Ke Shih enum rtw89_rate_max { 431e3ec7017SPing-Ke Shih RTW89_RATE_CCK_MAX = 4, 432e3ec7017SPing-Ke Shih RTW89_RATE_OFDM_MAX = 8, 433e3ec7017SPing-Ke Shih RTW89_RATE_MCS_MAX = 12, 434e3ec7017SPing-Ke Shih RTW89_RATE_HEDCM_MAX = 4, /* for HEDCM MCS0/1/3/4 */ 435e3ec7017SPing-Ke Shih RTW89_RATE_OFFSET_MAX = 5, /* for HE(HEDCM)/VHT/HT/OFDM/CCK offset */ 436e3ec7017SPing-Ke Shih }; 437e3ec7017SPing-Ke Shih 438e3ec7017SPing-Ke Shih enum rtw89_nss { 439e3ec7017SPing-Ke Shih RTW89_NSS_1 = 0, 440e3ec7017SPing-Ke Shih RTW89_NSS_2 = 1, 441e3ec7017SPing-Ke Shih /* HE DCM only support 1ss and 2ss */ 442e3ec7017SPing-Ke Shih RTW89_NSS_HEDCM_MAX = RTW89_NSS_2 + 1, 443e3ec7017SPing-Ke Shih RTW89_NSS_3 = 2, 444e3ec7017SPing-Ke Shih RTW89_NSS_4 = 3, 445e3ec7017SPing-Ke Shih RTW89_NSS_MAX, 446e3ec7017SPing-Ke Shih }; 447e3ec7017SPing-Ke Shih 448e3ec7017SPing-Ke Shih enum rtw89_ntx { 449e3ec7017SPing-Ke Shih RTW89_1TX = 0, 450e3ec7017SPing-Ke Shih RTW89_2TX = 1, 451e3ec7017SPing-Ke Shih RTW89_NTX_NUM, 452e3ec7017SPing-Ke Shih }; 453e3ec7017SPing-Ke Shih 454e3ec7017SPing-Ke Shih enum rtw89_beamforming_type { 455e3ec7017SPing-Ke Shih RTW89_NONBF = 0, 456e3ec7017SPing-Ke Shih RTW89_BF = 1, 457e3ec7017SPing-Ke Shih RTW89_BF_NUM, 458e3ec7017SPing-Ke Shih }; 459e3ec7017SPing-Ke Shih 460e3ec7017SPing-Ke Shih enum rtw89_regulation_type { 461e3ec7017SPing-Ke Shih RTW89_WW = 0, 462e3ec7017SPing-Ke Shih RTW89_ETSI = 1, 463e3ec7017SPing-Ke Shih RTW89_FCC = 2, 464e3ec7017SPing-Ke Shih RTW89_MKK = 3, 465e3ec7017SPing-Ke Shih RTW89_NA = 4, 466e3ec7017SPing-Ke Shih RTW89_IC = 5, 467e3ec7017SPing-Ke Shih RTW89_KCC = 6, 46854257714SZong-Zhe Yang RTW89_ACMA = 7, 46954257714SZong-Zhe Yang RTW89_NCC = 8, 47054257714SZong-Zhe Yang RTW89_MEXICO = 9, 47154257714SZong-Zhe Yang RTW89_CHILE = 10, 472e3ec7017SPing-Ke Shih RTW89_UKRAINE = 11, 473e3ec7017SPing-Ke Shih RTW89_CN = 12, 47454257714SZong-Zhe Yang RTW89_QATAR = 13, 4755a0e776bSZong-Zhe Yang RTW89_UK = 14, 476e3ec7017SPing-Ke Shih RTW89_REGD_NUM, 477e3ec7017SPing-Ke Shih }; 478e3ec7017SPing-Ke Shih 479e3ec7017SPing-Ke Shih struct rtw89_txpwr_byrate { 480e3ec7017SPing-Ke Shih s8 cck[RTW89_RATE_CCK_MAX]; 481e3ec7017SPing-Ke Shih s8 ofdm[RTW89_RATE_OFDM_MAX]; 482e3ec7017SPing-Ke Shih s8 mcs[RTW89_NSS_MAX][RTW89_RATE_MCS_MAX]; 483e3ec7017SPing-Ke Shih s8 hedcm[RTW89_NSS_HEDCM_MAX][RTW89_RATE_HEDCM_MAX]; 484e3ec7017SPing-Ke Shih s8 offset[RTW89_RATE_OFFSET_MAX]; 485e3ec7017SPing-Ke Shih }; 486e3ec7017SPing-Ke Shih 487e3ec7017SPing-Ke Shih enum rtw89_bandwidth_section_num { 488e3ec7017SPing-Ke Shih RTW89_BW20_SEC_NUM = 8, 489e3ec7017SPing-Ke Shih RTW89_BW40_SEC_NUM = 4, 490e3ec7017SPing-Ke Shih RTW89_BW80_SEC_NUM = 2, 491e3ec7017SPing-Ke Shih }; 492e3ec7017SPing-Ke Shih 493e3ec7017SPing-Ke Shih struct rtw89_txpwr_limit { 494e3ec7017SPing-Ke Shih s8 cck_20m[RTW89_BF_NUM]; 495e3ec7017SPing-Ke Shih s8 cck_40m[RTW89_BF_NUM]; 496e3ec7017SPing-Ke Shih s8 ofdm[RTW89_BF_NUM]; 497e3ec7017SPing-Ke Shih s8 mcs_20m[RTW89_BW20_SEC_NUM][RTW89_BF_NUM]; 498e3ec7017SPing-Ke Shih s8 mcs_40m[RTW89_BW40_SEC_NUM][RTW89_BF_NUM]; 499e3ec7017SPing-Ke Shih s8 mcs_80m[RTW89_BW80_SEC_NUM][RTW89_BF_NUM]; 500e3ec7017SPing-Ke Shih s8 mcs_160m[RTW89_BF_NUM]; 501e3ec7017SPing-Ke Shih s8 mcs_40m_0p5[RTW89_BF_NUM]; 502e3ec7017SPing-Ke Shih s8 mcs_40m_2p5[RTW89_BF_NUM]; 503e3ec7017SPing-Ke Shih }; 504e3ec7017SPing-Ke Shih 505e3ec7017SPing-Ke Shih #define RTW89_RU_SEC_NUM 8 506e3ec7017SPing-Ke Shih 507e3ec7017SPing-Ke Shih struct rtw89_txpwr_limit_ru { 508e3ec7017SPing-Ke Shih s8 ru26[RTW89_RU_SEC_NUM]; 509e3ec7017SPing-Ke Shih s8 ru52[RTW89_RU_SEC_NUM]; 510e3ec7017SPing-Ke Shih s8 ru106[RTW89_RU_SEC_NUM]; 511e3ec7017SPing-Ke Shih }; 512e3ec7017SPing-Ke Shih 513e3ec7017SPing-Ke Shih struct rtw89_rate_desc { 514e3ec7017SPing-Ke Shih enum rtw89_nss nss; 515e3ec7017SPing-Ke Shih enum rtw89_rate_section rs; 516e3ec7017SPing-Ke Shih u8 idx; 517e3ec7017SPing-Ke Shih }; 518e3ec7017SPing-Ke Shih 519e3ec7017SPing-Ke Shih #define PHY_STS_HDR_LEN 8 520e3ec7017SPing-Ke Shih #define RF_PATH_MAX 4 521e3ec7017SPing-Ke Shih #define RTW89_MAX_PPDU_CNT 8 522e3ec7017SPing-Ke Shih struct rtw89_rx_phy_ppdu { 523e3ec7017SPing-Ke Shih u8 *buf; 524e3ec7017SPing-Ke Shih u32 len; 525e3ec7017SPing-Ke Shih u8 rssi_avg; 5266ce472d6SPing-Ke Shih u8 rssi[RF_PATH_MAX]; 527e3ec7017SPing-Ke Shih u8 mac_id; 528eb4e52b3SPo Hao Huang u8 chan_idx; 529eb4e52b3SPo Hao Huang u8 ie; 530eb4e52b3SPo Hao Huang u16 rate; 531e3ec7017SPing-Ke Shih bool to_self; 532e3ec7017SPing-Ke Shih bool valid; 533e3ec7017SPing-Ke Shih }; 534e3ec7017SPing-Ke Shih 535e3ec7017SPing-Ke Shih enum rtw89_mac_idx { 536e3ec7017SPing-Ke Shih RTW89_MAC_0 = 0, 537e3ec7017SPing-Ke Shih RTW89_MAC_1 = 1, 538e3ec7017SPing-Ke Shih }; 539e3ec7017SPing-Ke Shih 540e3ec7017SPing-Ke Shih enum rtw89_phy_idx { 541e3ec7017SPing-Ke Shih RTW89_PHY_0 = 0, 542e3ec7017SPing-Ke Shih RTW89_PHY_1 = 1, 543e3ec7017SPing-Ke Shih RTW89_PHY_MAX 544e3ec7017SPing-Ke Shih }; 545e3ec7017SPing-Ke Shih 546cbb145b9SZong-Zhe Yang enum rtw89_sub_entity_idx { 547cbb145b9SZong-Zhe Yang RTW89_SUB_ENTITY_0 = 0, 548cbb145b9SZong-Zhe Yang 549cbb145b9SZong-Zhe Yang NUM_OF_RTW89_SUB_ENTITY, 550cbb145b9SZong-Zhe Yang }; 551cbb145b9SZong-Zhe Yang 552e3ec7017SPing-Ke Shih enum rtw89_rf_path { 553e3ec7017SPing-Ke Shih RF_PATH_A = 0, 554e3ec7017SPing-Ke Shih RF_PATH_B = 1, 555e3ec7017SPing-Ke Shih RF_PATH_C = 2, 556e3ec7017SPing-Ke Shih RF_PATH_D = 3, 557e3ec7017SPing-Ke Shih RF_PATH_AB, 558e3ec7017SPing-Ke Shih RF_PATH_AC, 559e3ec7017SPing-Ke Shih RF_PATH_AD, 560e3ec7017SPing-Ke Shih RF_PATH_BC, 561e3ec7017SPing-Ke Shih RF_PATH_BD, 562e3ec7017SPing-Ke Shih RF_PATH_CD, 563e3ec7017SPing-Ke Shih RF_PATH_ABC, 564e3ec7017SPing-Ke Shih RF_PATH_ABD, 565e3ec7017SPing-Ke Shih RF_PATH_ACD, 566e3ec7017SPing-Ke Shih RF_PATH_BCD, 567e3ec7017SPing-Ke Shih RF_PATH_ABCD, 568e3ec7017SPing-Ke Shih }; 569e3ec7017SPing-Ke Shih 570e3ec7017SPing-Ke Shih enum rtw89_rf_path_bit { 571e3ec7017SPing-Ke Shih RF_A = BIT(0), 572e3ec7017SPing-Ke Shih RF_B = BIT(1), 573e3ec7017SPing-Ke Shih RF_C = BIT(2), 574e3ec7017SPing-Ke Shih RF_D = BIT(3), 575e3ec7017SPing-Ke Shih 576e3ec7017SPing-Ke Shih RF_AB = (RF_A | RF_B), 577e3ec7017SPing-Ke Shih RF_AC = (RF_A | RF_C), 578e3ec7017SPing-Ke Shih RF_AD = (RF_A | RF_D), 579e3ec7017SPing-Ke Shih RF_BC = (RF_B | RF_C), 580e3ec7017SPing-Ke Shih RF_BD = (RF_B | RF_D), 581e3ec7017SPing-Ke Shih RF_CD = (RF_C | RF_D), 582e3ec7017SPing-Ke Shih 583e3ec7017SPing-Ke Shih RF_ABC = (RF_A | RF_B | RF_C), 584e3ec7017SPing-Ke Shih RF_ABD = (RF_A | RF_B | RF_D), 585e3ec7017SPing-Ke Shih RF_ACD = (RF_A | RF_C | RF_D), 586e3ec7017SPing-Ke Shih RF_BCD = (RF_B | RF_C | RF_D), 587e3ec7017SPing-Ke Shih 588e3ec7017SPing-Ke Shih RF_ABCD = (RF_A | RF_B | RF_C | RF_D), 589e3ec7017SPing-Ke Shih }; 590e3ec7017SPing-Ke Shih 591e3ec7017SPing-Ke Shih enum rtw89_bandwidth { 592e3ec7017SPing-Ke Shih RTW89_CHANNEL_WIDTH_20 = 0, 593e3ec7017SPing-Ke Shih RTW89_CHANNEL_WIDTH_40 = 1, 594e3ec7017SPing-Ke Shih RTW89_CHANNEL_WIDTH_80 = 2, 595e3ec7017SPing-Ke Shih RTW89_CHANNEL_WIDTH_160 = 3, 596e3ec7017SPing-Ke Shih RTW89_CHANNEL_WIDTH_80_80 = 4, 597e3ec7017SPing-Ke Shih RTW89_CHANNEL_WIDTH_5 = 5, 598e3ec7017SPing-Ke Shih RTW89_CHANNEL_WIDTH_10 = 6, 599e3ec7017SPing-Ke Shih }; 600e3ec7017SPing-Ke Shih 601e3ec7017SPing-Ke Shih enum rtw89_ps_mode { 602e3ec7017SPing-Ke Shih RTW89_PS_MODE_NONE = 0, 603e3ec7017SPing-Ke Shih RTW89_PS_MODE_RFOFF = 1, 604e3ec7017SPing-Ke Shih RTW89_PS_MODE_CLK_GATED = 2, 605e3ec7017SPing-Ke Shih RTW89_PS_MODE_PWR_GATED = 3, 606e3ec7017SPing-Ke Shih }; 607e3ec7017SPing-Ke Shih 608e3ec7017SPing-Ke Shih #define RTW89_2G_BW_NUM (RTW89_CHANNEL_WIDTH_40 + 1) 60994b70cafSZong-Zhe Yang #define RTW89_5G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1) 610ac74f016SZong-Zhe Yang #define RTW89_6G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1) 611aa7f148bSPing-Ke Shih #define RTW89_PPE_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1) 612e3ec7017SPing-Ke Shih 613e3ec7017SPing-Ke Shih enum rtw89_ru_bandwidth { 614e3ec7017SPing-Ke Shih RTW89_RU26 = 0, 615e3ec7017SPing-Ke Shih RTW89_RU52 = 1, 616e3ec7017SPing-Ke Shih RTW89_RU106 = 2, 617e3ec7017SPing-Ke Shih RTW89_RU_NUM, 618e3ec7017SPing-Ke Shih }; 619e3ec7017SPing-Ke Shih 620e3ec7017SPing-Ke Shih enum rtw89_sc_offset { 621e3ec7017SPing-Ke Shih RTW89_SC_DONT_CARE = 0, 622e3ec7017SPing-Ke Shih RTW89_SC_20_UPPER = 1, 623e3ec7017SPing-Ke Shih RTW89_SC_20_LOWER = 2, 624e3ec7017SPing-Ke Shih RTW89_SC_20_UPMOST = 3, 625e3ec7017SPing-Ke Shih RTW89_SC_20_LOWEST = 4, 626e715f10fSPing-Ke Shih RTW89_SC_20_UP2X = 5, 627e715f10fSPing-Ke Shih RTW89_SC_20_LOW2X = 6, 628e715f10fSPing-Ke Shih RTW89_SC_20_UP3X = 7, 629e715f10fSPing-Ke Shih RTW89_SC_20_LOW3X = 8, 630e3ec7017SPing-Ke Shih RTW89_SC_40_UPPER = 9, 631e3ec7017SPing-Ke Shih RTW89_SC_40_LOWER = 10, 632e3ec7017SPing-Ke Shih }; 633e3ec7017SPing-Ke Shih 6343e5831caSZong-Zhe Yang struct rtw89_chan { 6353e5831caSZong-Zhe Yang u8 channel; 6363e5831caSZong-Zhe Yang u8 primary_channel; 6373e5831caSZong-Zhe Yang enum rtw89_band band_type; 6383e5831caSZong-Zhe Yang enum rtw89_bandwidth band_width; 639bb8152b3SZong-Zhe Yang 640bb8152b3SZong-Zhe Yang /* The follow-up are derived from the above. We must ensure that it 641bb8152b3SZong-Zhe Yang * is assigned correctly in rtw89_chan_create() if new one is added. 642bb8152b3SZong-Zhe Yang */ 643bb8152b3SZong-Zhe Yang u32 freq; 6443e5831caSZong-Zhe Yang enum rtw89_subband subband_type; 6453e5831caSZong-Zhe Yang enum rtw89_sc_offset pri_ch_idx; 646e3ec7017SPing-Ke Shih }; 647e3ec7017SPing-Ke Shih 648cbb145b9SZong-Zhe Yang struct rtw89_chan_rcd { 649cbb145b9SZong-Zhe Yang u8 prev_primary_channel; 650cbb145b9SZong-Zhe Yang enum rtw89_band prev_band_type; 651cbb145b9SZong-Zhe Yang }; 652cbb145b9SZong-Zhe Yang 653e3ec7017SPing-Ke Shih struct rtw89_channel_help_params { 654d780f926SPing-Ke Shih u32 tx_en; 655e3ec7017SPing-Ke Shih }; 656e3ec7017SPing-Ke Shih 657e3ec7017SPing-Ke Shih struct rtw89_port_reg { 658e3ec7017SPing-Ke Shih u32 port_cfg; 659e3ec7017SPing-Ke Shih u32 tbtt_prohib; 660e3ec7017SPing-Ke Shih u32 bcn_area; 661e3ec7017SPing-Ke Shih u32 bcn_early; 662e3ec7017SPing-Ke Shih u32 tbtt_early; 663e3ec7017SPing-Ke Shih u32 tbtt_agg; 664e3ec7017SPing-Ke Shih u32 bcn_space; 665e3ec7017SPing-Ke Shih u32 bcn_forcetx; 666e3ec7017SPing-Ke Shih u32 bcn_err_cnt; 667e3ec7017SPing-Ke Shih u32 bcn_err_flag; 668e3ec7017SPing-Ke Shih u32 dtim_ctrl; 669e3ec7017SPing-Ke Shih u32 tbtt_shift; 670e3ec7017SPing-Ke Shih u32 bcn_cnt_tmr; 671e3ec7017SPing-Ke Shih u32 tsftr_l; 672e3ec7017SPing-Ke Shih u32 tsftr_h; 673e3ec7017SPing-Ke Shih }; 674e3ec7017SPing-Ke Shih 675e3ec7017SPing-Ke Shih struct rtw89_txwd_body { 676e3ec7017SPing-Ke Shih __le32 dword0; 677e3ec7017SPing-Ke Shih __le32 dword1; 678e3ec7017SPing-Ke Shih __le32 dword2; 679e3ec7017SPing-Ke Shih __le32 dword3; 680e3ec7017SPing-Ke Shih __le32 dword4; 681e3ec7017SPing-Ke Shih __le32 dword5; 682e3ec7017SPing-Ke Shih } __packed; 683e3ec7017SPing-Ke Shih 684f59acddeSPing-Ke Shih struct rtw89_txwd_body_v1 { 685f59acddeSPing-Ke Shih __le32 dword0; 686f59acddeSPing-Ke Shih __le32 dword1; 687f59acddeSPing-Ke Shih __le32 dword2; 688f59acddeSPing-Ke Shih __le32 dword3; 689f59acddeSPing-Ke Shih __le32 dword4; 690f59acddeSPing-Ke Shih __le32 dword5; 691f59acddeSPing-Ke Shih __le32 dword6; 692f59acddeSPing-Ke Shih __le32 dword7; 693f59acddeSPing-Ke Shih } __packed; 694f59acddeSPing-Ke Shih 695e3ec7017SPing-Ke Shih struct rtw89_txwd_info { 696e3ec7017SPing-Ke Shih __le32 dword0; 697e3ec7017SPing-Ke Shih __le32 dword1; 698e3ec7017SPing-Ke Shih __le32 dword2; 699e3ec7017SPing-Ke Shih __le32 dword3; 700e3ec7017SPing-Ke Shih __le32 dword4; 701e3ec7017SPing-Ke Shih __le32 dword5; 702e3ec7017SPing-Ke Shih } __packed; 703e3ec7017SPing-Ke Shih 704e3ec7017SPing-Ke Shih struct rtw89_rx_desc_info { 705e3ec7017SPing-Ke Shih u16 pkt_size; 706e3ec7017SPing-Ke Shih u8 pkt_type; 707e3ec7017SPing-Ke Shih u8 drv_info_size; 708e3ec7017SPing-Ke Shih u8 shift; 709e3ec7017SPing-Ke Shih u8 wl_hd_iv_len; 710e3ec7017SPing-Ke Shih bool long_rxdesc; 711e3ec7017SPing-Ke Shih bool bb_sel; 712e3ec7017SPing-Ke Shih bool mac_info_valid; 713e3ec7017SPing-Ke Shih u16 data_rate; 714e3ec7017SPing-Ke Shih u8 gi_ltf; 715e3ec7017SPing-Ke Shih u8 bw; 716e3ec7017SPing-Ke Shih u32 free_run_cnt; 717e3ec7017SPing-Ke Shih u8 user_id; 718e3ec7017SPing-Ke Shih bool sr_en; 719e3ec7017SPing-Ke Shih u8 ppdu_cnt; 720e3ec7017SPing-Ke Shih u8 ppdu_type; 721e3ec7017SPing-Ke Shih bool icv_err; 722e3ec7017SPing-Ke Shih bool crc32_err; 723e3ec7017SPing-Ke Shih bool hw_dec; 724e3ec7017SPing-Ke Shih bool sw_dec; 725e3ec7017SPing-Ke Shih bool addr1_match; 726e3ec7017SPing-Ke Shih u8 frag; 727e3ec7017SPing-Ke Shih u16 seq; 728e3ec7017SPing-Ke Shih u8 frame_type; 729e3ec7017SPing-Ke Shih u8 rx_pl_id; 730e3ec7017SPing-Ke Shih bool addr_cam_valid; 731e3ec7017SPing-Ke Shih u8 addr_cam_id; 732e3ec7017SPing-Ke Shih u8 sec_cam_id; 733e3ec7017SPing-Ke Shih u8 mac_id; 734e3ec7017SPing-Ke Shih u16 offset; 735e3ec7017SPing-Ke Shih bool ready; 736e3ec7017SPing-Ke Shih }; 737e3ec7017SPing-Ke Shih 738e3ec7017SPing-Ke Shih struct rtw89_rxdesc_short { 739e3ec7017SPing-Ke Shih __le32 dword0; 740e3ec7017SPing-Ke Shih __le32 dword1; 741e3ec7017SPing-Ke Shih __le32 dword2; 742e3ec7017SPing-Ke Shih __le32 dword3; 743e3ec7017SPing-Ke Shih } __packed; 744e3ec7017SPing-Ke Shih 745e3ec7017SPing-Ke Shih struct rtw89_rxdesc_long { 746e3ec7017SPing-Ke Shih __le32 dword0; 747e3ec7017SPing-Ke Shih __le32 dword1; 748e3ec7017SPing-Ke Shih __le32 dword2; 749e3ec7017SPing-Ke Shih __le32 dword3; 750e3ec7017SPing-Ke Shih __le32 dword4; 751e3ec7017SPing-Ke Shih __le32 dword5; 752e3ec7017SPing-Ke Shih __le32 dword6; 753e3ec7017SPing-Ke Shih __le32 dword7; 754e3ec7017SPing-Ke Shih } __packed; 755e3ec7017SPing-Ke Shih 756e3ec7017SPing-Ke Shih struct rtw89_tx_desc_info { 757e3ec7017SPing-Ke Shih u16 pkt_size; 758e3ec7017SPing-Ke Shih u8 wp_offset; 7599eecaec2SPing-Ke Shih u8 mac_id; 760e3ec7017SPing-Ke Shih u8 qsel; 761e3ec7017SPing-Ke Shih u8 ch_dma; 762e3ec7017SPing-Ke Shih u8 hdr_llc_len; 763e3ec7017SPing-Ke Shih bool is_bmc; 764e3ec7017SPing-Ke Shih bool en_wd_info; 765e3ec7017SPing-Ke Shih bool wd_page; 766e3ec7017SPing-Ke Shih bool use_rate; 767e3ec7017SPing-Ke Shih bool dis_data_fb; 768e3ec7017SPing-Ke Shih bool tid_indicate; 769e3ec7017SPing-Ke Shih bool agg_en; 770e3ec7017SPing-Ke Shih bool bk; 771e3ec7017SPing-Ke Shih u8 ampdu_density; 772e3ec7017SPing-Ke Shih u8 ampdu_num; 773e3ec7017SPing-Ke Shih bool sec_en; 7746d5b5d62SPing-Ke Shih u8 addr_info_nr; 77579a6c9a4SPing-Ke Shih u8 sec_keyid; 776e3ec7017SPing-Ke Shih u8 sec_type; 777e3ec7017SPing-Ke Shih u8 sec_cam_idx; 77879a6c9a4SPing-Ke Shih u8 sec_seq[6]; 779e3ec7017SPing-Ke Shih u16 data_rate; 780e3ec7017SPing-Ke Shih u16 data_retry_lowest_rate; 781e3ec7017SPing-Ke Shih bool fw_dl; 782e3ec7017SPing-Ke Shih u16 seq; 783e3ec7017SPing-Ke Shih bool a_ctrl_bsr; 78491644020SPing-Ke Shih u8 hw_ssn_sel; 78591644020SPing-Ke Shih #define RTW89_MGMT_HW_SSN_SEL 1 78691644020SPing-Ke Shih u8 hw_seq_mode; 78791644020SPing-Ke Shih #define RTW89_MGMT_HW_SEQ_MODE 1 78811d261f2SPing-Ke Shih bool hiq; 7899eecaec2SPing-Ke Shih u8 port; 790e3ec7017SPing-Ke Shih }; 791e3ec7017SPing-Ke Shih 792e3ec7017SPing-Ke Shih struct rtw89_core_tx_request { 793e3ec7017SPing-Ke Shih enum rtw89_core_tx_type tx_type; 794e3ec7017SPing-Ke Shih 795e3ec7017SPing-Ke Shih struct sk_buff *skb; 796e3ec7017SPing-Ke Shih struct ieee80211_vif *vif; 797e3ec7017SPing-Ke Shih struct ieee80211_sta *sta; 798e3ec7017SPing-Ke Shih struct rtw89_tx_desc_info desc_info; 799e3ec7017SPing-Ke Shih }; 800e3ec7017SPing-Ke Shih 801e3ec7017SPing-Ke Shih struct rtw89_txq { 802e3ec7017SPing-Ke Shih struct list_head list; 803e3ec7017SPing-Ke Shih unsigned long flags; 804e3ec7017SPing-Ke Shih int wait_cnt; 805e3ec7017SPing-Ke Shih }; 806e3ec7017SPing-Ke Shih 807e3ec7017SPing-Ke Shih struct rtw89_mac_ax_gnt { 808e3ec7017SPing-Ke Shih u8 gnt_bt_sw_en; 809e3ec7017SPing-Ke Shih u8 gnt_bt; 810e3ec7017SPing-Ke Shih u8 gnt_wl_sw_en; 811e3ec7017SPing-Ke Shih u8 gnt_wl; 8121162584cSChing-Te Ku } __packed; 813e3ec7017SPing-Ke Shih 814e3ec7017SPing-Ke Shih #define RTW89_MAC_AX_COEX_GNT_NR 2 815e3ec7017SPing-Ke Shih struct rtw89_mac_ax_coex_gnt { 816e3ec7017SPing-Ke Shih struct rtw89_mac_ax_gnt band[RTW89_MAC_AX_COEX_GNT_NR]; 817e3ec7017SPing-Ke Shih }; 818e3ec7017SPing-Ke Shih 819e3ec7017SPing-Ke Shih enum rtw89_btc_ncnt { 820e3ec7017SPing-Ke Shih BTC_NCNT_POWER_ON = 0x0, 821e3ec7017SPing-Ke Shih BTC_NCNT_POWER_OFF, 822e3ec7017SPing-Ke Shih BTC_NCNT_INIT_COEX, 823e3ec7017SPing-Ke Shih BTC_NCNT_SCAN_START, 824e3ec7017SPing-Ke Shih BTC_NCNT_SCAN_FINISH, 825e3ec7017SPing-Ke Shih BTC_NCNT_SPECIAL_PACKET, 826e3ec7017SPing-Ke Shih BTC_NCNT_SWITCH_BAND, 827e3ec7017SPing-Ke Shih BTC_NCNT_RFK_TIMEOUT, 828e3ec7017SPing-Ke Shih BTC_NCNT_SHOW_COEX_INFO, 829e3ec7017SPing-Ke Shih BTC_NCNT_ROLE_INFO, 830e3ec7017SPing-Ke Shih BTC_NCNT_CONTROL, 831e3ec7017SPing-Ke Shih BTC_NCNT_RADIO_STATE, 832e3ec7017SPing-Ke Shih BTC_NCNT_CUSTOMERIZE, 833e3ec7017SPing-Ke Shih BTC_NCNT_WL_RFK, 834e3ec7017SPing-Ke Shih BTC_NCNT_WL_STA, 835e3ec7017SPing-Ke Shih BTC_NCNT_FWINFO, 836e3ec7017SPing-Ke Shih BTC_NCNT_TIMER, 837e3ec7017SPing-Ke Shih BTC_NCNT_NUM 838e3ec7017SPing-Ke Shih }; 839e3ec7017SPing-Ke Shih 840e3ec7017SPing-Ke Shih enum rtw89_btc_btinfo { 841e3ec7017SPing-Ke Shih BTC_BTINFO_L0 = 0, 842e3ec7017SPing-Ke Shih BTC_BTINFO_L1, 843e3ec7017SPing-Ke Shih BTC_BTINFO_L2, 844e3ec7017SPing-Ke Shih BTC_BTINFO_L3, 845e3ec7017SPing-Ke Shih BTC_BTINFO_H0, 846e3ec7017SPing-Ke Shih BTC_BTINFO_H1, 847e3ec7017SPing-Ke Shih BTC_BTINFO_H2, 848e3ec7017SPing-Ke Shih BTC_BTINFO_H3, 849e3ec7017SPing-Ke Shih BTC_BTINFO_MAX 850e3ec7017SPing-Ke Shih }; 851e3ec7017SPing-Ke Shih 852e3ec7017SPing-Ke Shih enum rtw89_btc_dcnt { 853e3ec7017SPing-Ke Shih BTC_DCNT_RUN = 0x0, 854e3ec7017SPing-Ke Shih BTC_DCNT_CX_RUNINFO, 855e3ec7017SPing-Ke Shih BTC_DCNT_RPT, 856e3ec7017SPing-Ke Shih BTC_DCNT_RPT_FREEZE, 857e3ec7017SPing-Ke Shih BTC_DCNT_CYCLE, 858e3ec7017SPing-Ke Shih BTC_DCNT_CYCLE_FREEZE, 859e3ec7017SPing-Ke Shih BTC_DCNT_W1, 860e3ec7017SPing-Ke Shih BTC_DCNT_W1_FREEZE, 861e3ec7017SPing-Ke Shih BTC_DCNT_B1, 862e3ec7017SPing-Ke Shih BTC_DCNT_B1_FREEZE, 863e3ec7017SPing-Ke Shih BTC_DCNT_TDMA_NONSYNC, 864e3ec7017SPing-Ke Shih BTC_DCNT_SLOT_NONSYNC, 865e3ec7017SPing-Ke Shih BTC_DCNT_BTCNT_FREEZE, 866e3ec7017SPing-Ke Shih BTC_DCNT_WL_SLOT_DRIFT, 8673832a542SChing-Te Ku BTC_DCNT_BT_SLOT_DRIFT, 868e3ec7017SPing-Ke Shih BTC_DCNT_WL_STA_LAST, 869e3ec7017SPing-Ke Shih BTC_DCNT_NUM, 870e3ec7017SPing-Ke Shih }; 871e3ec7017SPing-Ke Shih 872e3ec7017SPing-Ke Shih enum rtw89_btc_wl_state_cnt { 873e3ec7017SPing-Ke Shih BTC_WCNT_SCANAP = 0x0, 874e3ec7017SPing-Ke Shih BTC_WCNT_DHCP, 875e3ec7017SPing-Ke Shih BTC_WCNT_EAPOL, 876e3ec7017SPing-Ke Shih BTC_WCNT_ARP, 877e3ec7017SPing-Ke Shih BTC_WCNT_SCBDUPDATE, 878e3ec7017SPing-Ke Shih BTC_WCNT_RFK_REQ, 879e3ec7017SPing-Ke Shih BTC_WCNT_RFK_GO, 880e3ec7017SPing-Ke Shih BTC_WCNT_RFK_REJECT, 881e3ec7017SPing-Ke Shih BTC_WCNT_RFK_TIMEOUT, 882e3ec7017SPing-Ke Shih BTC_WCNT_CH_UPDATE, 883e3ec7017SPing-Ke Shih BTC_WCNT_NUM 884e3ec7017SPing-Ke Shih }; 885e3ec7017SPing-Ke Shih 886e3ec7017SPing-Ke Shih enum rtw89_btc_bt_state_cnt { 887e3ec7017SPing-Ke Shih BTC_BCNT_RETRY = 0x0, 888e3ec7017SPing-Ke Shih BTC_BCNT_REINIT, 889e3ec7017SPing-Ke Shih BTC_BCNT_REENABLE, 890e3ec7017SPing-Ke Shih BTC_BCNT_SCBDREAD, 891e3ec7017SPing-Ke Shih BTC_BCNT_RELINK, 892e3ec7017SPing-Ke Shih BTC_BCNT_IGNOWL, 893e3ec7017SPing-Ke Shih BTC_BCNT_INQPAG, 894e3ec7017SPing-Ke Shih BTC_BCNT_INQ, 895e3ec7017SPing-Ke Shih BTC_BCNT_PAGE, 896e3ec7017SPing-Ke Shih BTC_BCNT_ROLESW, 897e3ec7017SPing-Ke Shih BTC_BCNT_AFH, 898e3ec7017SPing-Ke Shih BTC_BCNT_INFOUPDATE, 899e3ec7017SPing-Ke Shih BTC_BCNT_INFOSAME, 900e3ec7017SPing-Ke Shih BTC_BCNT_SCBDUPDATE, 901e3ec7017SPing-Ke Shih BTC_BCNT_HIPRI_TX, 902e3ec7017SPing-Ke Shih BTC_BCNT_HIPRI_RX, 903e3ec7017SPing-Ke Shih BTC_BCNT_LOPRI_TX, 904e3ec7017SPing-Ke Shih BTC_BCNT_LOPRI_RX, 9058c7e9cebSChing-Te Ku BTC_BCNT_POLUT, 906e3ec7017SPing-Ke Shih BTC_BCNT_RATECHG, 907e3ec7017SPing-Ke Shih BTC_BCNT_NUM 908e3ec7017SPing-Ke Shih }; 909e3ec7017SPing-Ke Shih 910e3ec7017SPing-Ke Shih enum rtw89_btc_bt_profile { 911e3ec7017SPing-Ke Shih BTC_BT_NOPROFILE = 0, 912e3ec7017SPing-Ke Shih BTC_BT_HFP = BIT(0), 913e3ec7017SPing-Ke Shih BTC_BT_HID = BIT(1), 914e3ec7017SPing-Ke Shih BTC_BT_A2DP = BIT(2), 915e3ec7017SPing-Ke Shih BTC_BT_PAN = BIT(3), 916e3ec7017SPing-Ke Shih BTC_PROFILE_MAX = 4, 917e3ec7017SPing-Ke Shih }; 918e3ec7017SPing-Ke Shih 919e3ec7017SPing-Ke Shih struct rtw89_btc_ant_info { 920e3ec7017SPing-Ke Shih u8 type; /* shared, dedicated */ 921e3ec7017SPing-Ke Shih u8 num; 922e3ec7017SPing-Ke Shih u8 isolation; 923e3ec7017SPing-Ke Shih 924e3ec7017SPing-Ke Shih u8 single_pos: 1;/* Single antenna at S0 or S1 */ 925e3ec7017SPing-Ke Shih u8 diversity: 1; 926e3ec7017SPing-Ke Shih }; 927e3ec7017SPing-Ke Shih 928e3ec7017SPing-Ke Shih enum rtw89_tfc_dir { 929e3ec7017SPing-Ke Shih RTW89_TFC_UL, 930e3ec7017SPing-Ke Shih RTW89_TFC_DL, 931e3ec7017SPing-Ke Shih }; 932e3ec7017SPing-Ke Shih 933e3ec7017SPing-Ke Shih struct rtw89_btc_wl_smap { 934e3ec7017SPing-Ke Shih u32 busy: 1; 935e3ec7017SPing-Ke Shih u32 scan: 1; 936e3ec7017SPing-Ke Shih u32 connecting: 1; 937e3ec7017SPing-Ke Shih u32 roaming: 1; 938e3ec7017SPing-Ke Shih u32 _4way: 1; 939e3ec7017SPing-Ke Shih u32 rf_off: 1; 94038ede035SChing-Te Ku u32 lps: 2; 941e3ec7017SPing-Ke Shih u32 ips: 1; 942e3ec7017SPing-Ke Shih u32 init_ok: 1; 943e3ec7017SPing-Ke Shih u32 traffic_dir : 2; 944e3ec7017SPing-Ke Shih u32 rf_off_pre: 1; 94538ede035SChing-Te Ku u32 lps_pre: 2; 946e3ec7017SPing-Ke Shih }; 947e3ec7017SPing-Ke Shih 948e3ec7017SPing-Ke Shih enum rtw89_tfc_lv { 949e3ec7017SPing-Ke Shih RTW89_TFC_IDLE, 950e3ec7017SPing-Ke Shih RTW89_TFC_ULTRA_LOW, 951e3ec7017SPing-Ke Shih RTW89_TFC_LOW, 952e3ec7017SPing-Ke Shih RTW89_TFC_MID, 953e3ec7017SPing-Ke Shih RTW89_TFC_HIGH, 954e3ec7017SPing-Ke Shih }; 955e3ec7017SPing-Ke Shih 956e3ec7017SPing-Ke Shih #define RTW89_TP_SHIFT 18 /* bytes/2s --> Mbps */ 957e3ec7017SPing-Ke Shih DECLARE_EWMA(tp, 10, 2); 958e3ec7017SPing-Ke Shih 959e3ec7017SPing-Ke Shih struct rtw89_traffic_stats { 960e3ec7017SPing-Ke Shih /* units in bytes */ 961e3ec7017SPing-Ke Shih u64 tx_unicast; 962e3ec7017SPing-Ke Shih u64 rx_unicast; 963e3ec7017SPing-Ke Shih u32 tx_avg_len; 964e3ec7017SPing-Ke Shih u32 rx_avg_len; 965e3ec7017SPing-Ke Shih 966e3ec7017SPing-Ke Shih /* count for packets */ 967e3ec7017SPing-Ke Shih u64 tx_cnt; 968e3ec7017SPing-Ke Shih u64 rx_cnt; 969e3ec7017SPing-Ke Shih 970e3ec7017SPing-Ke Shih /* units in Mbps */ 971e3ec7017SPing-Ke Shih u32 tx_throughput; 972e3ec7017SPing-Ke Shih u32 rx_throughput; 973e3ec7017SPing-Ke Shih u32 tx_throughput_raw; 974e3ec7017SPing-Ke Shih u32 rx_throughput_raw; 9755165f168SPo Hao Huang 9765165f168SPo Hao Huang u32 rx_tf_acc; 9775165f168SPo Hao Huang u32 rx_tf_periodic; 9785165f168SPo Hao Huang 979e3ec7017SPing-Ke Shih enum rtw89_tfc_lv tx_tfc_lv; 980e3ec7017SPing-Ke Shih enum rtw89_tfc_lv rx_tfc_lv; 981e3ec7017SPing-Ke Shih struct ewma_tp tx_ewma_tp; 982e3ec7017SPing-Ke Shih struct ewma_tp rx_ewma_tp; 983e3ec7017SPing-Ke Shih 984e3ec7017SPing-Ke Shih u16 tx_rate; 985e3ec7017SPing-Ke Shih u16 rx_rate; 986e3ec7017SPing-Ke Shih }; 987e3ec7017SPing-Ke Shih 988e3ec7017SPing-Ke Shih struct rtw89_btc_statistic { 989e3ec7017SPing-Ke Shih u8 rssi; /* 0%~110% (dBm = rssi -110) */ 990e3ec7017SPing-Ke Shih struct rtw89_traffic_stats traffic; 991e3ec7017SPing-Ke Shih }; 992e3ec7017SPing-Ke Shih 993e3ec7017SPing-Ke Shih #define BTC_WL_RSSI_THMAX 4 994e3ec7017SPing-Ke Shih 995e3ec7017SPing-Ke Shih struct rtw89_btc_wl_link_info { 996e3ec7017SPing-Ke Shih struct rtw89_btc_statistic stat; 997e3ec7017SPing-Ke Shih enum rtw89_tfc_dir dir; 998e3ec7017SPing-Ke Shih u8 rssi_state[BTC_WL_RSSI_THMAX]; 999e3ec7017SPing-Ke Shih u8 mac_addr[ETH_ALEN]; 1000e3ec7017SPing-Ke Shih u8 busy; 1001e3ec7017SPing-Ke Shih u8 ch; 1002e3ec7017SPing-Ke Shih u8 bw; 1003e3ec7017SPing-Ke Shih u8 band; 1004e3ec7017SPing-Ke Shih u8 role; 1005e3ec7017SPing-Ke Shih u8 pid; 1006e3ec7017SPing-Ke Shih u8 phy; 1007e3ec7017SPing-Ke Shih u8 dtim_period; 1008e3ec7017SPing-Ke Shih u8 mode; 1009e3ec7017SPing-Ke Shih 1010e3ec7017SPing-Ke Shih u8 mac_id; 1011e3ec7017SPing-Ke Shih u8 tx_retry; 1012e3ec7017SPing-Ke Shih 1013e3ec7017SPing-Ke Shih u32 bcn_period; 1014e3ec7017SPing-Ke Shih u32 busy_t; 1015e3ec7017SPing-Ke Shih u32 tx_time; 1016e3ec7017SPing-Ke Shih u32 client_cnt; 1017e3ec7017SPing-Ke Shih u32 rx_rate_drop_cnt; 1018e3ec7017SPing-Ke Shih 1019e3ec7017SPing-Ke Shih u32 active: 1; 1020e3ec7017SPing-Ke Shih u32 noa: 1; 1021e3ec7017SPing-Ke Shih u32 client_ps: 1; 1022e3ec7017SPing-Ke Shih u32 connected: 2; 1023e3ec7017SPing-Ke Shih }; 1024e3ec7017SPing-Ke Shih 1025e3ec7017SPing-Ke Shih union rtw89_btc_wl_state_map { 1026e3ec7017SPing-Ke Shih u32 val; 1027e3ec7017SPing-Ke Shih struct rtw89_btc_wl_smap map; 1028e3ec7017SPing-Ke Shih }; 1029e3ec7017SPing-Ke Shih 1030e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hfp_desc { 1031e3ec7017SPing-Ke Shih u32 exist: 1; 1032e3ec7017SPing-Ke Shih u32 type: 2; 1033e3ec7017SPing-Ke Shih u32 rsvd: 29; 1034e3ec7017SPing-Ke Shih }; 1035e3ec7017SPing-Ke Shih 1036e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hid_desc { 1037e3ec7017SPing-Ke Shih u32 exist: 1; 1038e3ec7017SPing-Ke Shih u32 slot_info: 2; 1039e3ec7017SPing-Ke Shih u32 pair_cnt: 2; 1040e3ec7017SPing-Ke Shih u32 type: 8; 1041e3ec7017SPing-Ke Shih u32 rsvd: 19; 1042e3ec7017SPing-Ke Shih }; 1043e3ec7017SPing-Ke Shih 1044e3ec7017SPing-Ke Shih struct rtw89_btc_bt_a2dp_desc { 1045e3ec7017SPing-Ke Shih u8 exist: 1; 1046e3ec7017SPing-Ke Shih u8 exist_last: 1; 1047e3ec7017SPing-Ke Shih u8 play_latency: 1; 1048e3ec7017SPing-Ke Shih u8 type: 3; 1049e3ec7017SPing-Ke Shih u8 active: 1; 1050e3ec7017SPing-Ke Shih u8 sink: 1; 1051e3ec7017SPing-Ke Shih 1052e3ec7017SPing-Ke Shih u8 bitpool; 1053e3ec7017SPing-Ke Shih u16 vendor_id; 1054e3ec7017SPing-Ke Shih u32 device_name; 1055e3ec7017SPing-Ke Shih u32 flush_time; 1056e3ec7017SPing-Ke Shih }; 1057e3ec7017SPing-Ke Shih 1058e3ec7017SPing-Ke Shih struct rtw89_btc_bt_pan_desc { 1059e3ec7017SPing-Ke Shih u32 exist: 1; 1060e3ec7017SPing-Ke Shih u32 type: 1; 1061e3ec7017SPing-Ke Shih u32 active: 1; 1062e3ec7017SPing-Ke Shih u32 rsvd: 29; 1063e3ec7017SPing-Ke Shih }; 1064e3ec7017SPing-Ke Shih 1065e3ec7017SPing-Ke Shih struct rtw89_btc_bt_rfk_info { 1066e3ec7017SPing-Ke Shih u32 run: 1; 1067e3ec7017SPing-Ke Shih u32 req: 1; 1068e3ec7017SPing-Ke Shih u32 timeout: 1; 1069e3ec7017SPing-Ke Shih u32 rsvd: 29; 1070e3ec7017SPing-Ke Shih }; 1071e3ec7017SPing-Ke Shih 1072e3ec7017SPing-Ke Shih union rtw89_btc_bt_rfk_info_map { 1073e3ec7017SPing-Ke Shih u32 val; 1074e3ec7017SPing-Ke Shih struct rtw89_btc_bt_rfk_info map; 1075e3ec7017SPing-Ke Shih }; 1076e3ec7017SPing-Ke Shih 1077e3ec7017SPing-Ke Shih struct rtw89_btc_bt_ver_info { 1078e3ec7017SPing-Ke Shih u32 fw_coex; /* match with which coex_ver */ 1079e3ec7017SPing-Ke Shih u32 fw; 1080e3ec7017SPing-Ke Shih }; 1081e3ec7017SPing-Ke Shih 1082e3ec7017SPing-Ke Shih struct rtw89_btc_bool_sta_chg { 1083e3ec7017SPing-Ke Shih u32 now: 1; 1084e3ec7017SPing-Ke Shih u32 last: 1; 1085e3ec7017SPing-Ke Shih u32 remain: 1; 1086e3ec7017SPing-Ke Shih u32 srvd: 29; 1087e3ec7017SPing-Ke Shih }; 1088e3ec7017SPing-Ke Shih 1089e3ec7017SPing-Ke Shih struct rtw89_btc_u8_sta_chg { 1090e3ec7017SPing-Ke Shih u8 now; 1091e3ec7017SPing-Ke Shih u8 last; 1092e3ec7017SPing-Ke Shih u8 remain; 1093e3ec7017SPing-Ke Shih u8 rsvd; 1094e3ec7017SPing-Ke Shih }; 1095e3ec7017SPing-Ke Shih 1096e3ec7017SPing-Ke Shih struct rtw89_btc_wl_scan_info { 1097e3ec7017SPing-Ke Shih u8 band[RTW89_PHY_MAX]; 1098e3ec7017SPing-Ke Shih u8 phy_map; 1099e3ec7017SPing-Ke Shih u8 rsvd; 1100e3ec7017SPing-Ke Shih }; 1101e3ec7017SPing-Ke Shih 1102e3ec7017SPing-Ke Shih struct rtw89_btc_wl_dbcc_info { 1103e3ec7017SPing-Ke Shih u8 op_band[RTW89_PHY_MAX]; /* op band in each phy */ 1104e3ec7017SPing-Ke Shih u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */ 1105e3ec7017SPing-Ke Shih u8 real_band[RTW89_PHY_MAX]; 1106e3ec7017SPing-Ke Shih u8 role[RTW89_PHY_MAX]; /* role in each phy */ 1107e3ec7017SPing-Ke Shih }; 1108e3ec7017SPing-Ke Shih 1109e3ec7017SPing-Ke Shih struct rtw89_btc_wl_active_role { 1110e3ec7017SPing-Ke Shih u8 connected: 1; 1111e3ec7017SPing-Ke Shih u8 pid: 3; 1112e3ec7017SPing-Ke Shih u8 phy: 1; 1113e3ec7017SPing-Ke Shih u8 noa: 1; 1114e3ec7017SPing-Ke Shih u8 band: 2; 1115e3ec7017SPing-Ke Shih 1116e3ec7017SPing-Ke Shih u8 client_ps: 1; 1117e3ec7017SPing-Ke Shih u8 bw: 7; 1118e3ec7017SPing-Ke Shih 1119e3ec7017SPing-Ke Shih u8 role; 1120e3ec7017SPing-Ke Shih u8 ch; 1121e3ec7017SPing-Ke Shih 1122e3ec7017SPing-Ke Shih u16 tx_lvl; 1123e3ec7017SPing-Ke Shih u16 rx_lvl; 1124e3ec7017SPing-Ke Shih u16 tx_rate; 1125e3ec7017SPing-Ke Shih u16 rx_rate; 1126e3ec7017SPing-Ke Shih }; 1127e3ec7017SPing-Ke Shih 1128e390cf2eSChing-Te Ku struct rtw89_btc_wl_active_role_v1 { 1129e390cf2eSChing-Te Ku u8 connected: 1; 1130e390cf2eSChing-Te Ku u8 pid: 3; 1131e390cf2eSChing-Te Ku u8 phy: 1; 1132e390cf2eSChing-Te Ku u8 noa: 1; 1133e390cf2eSChing-Te Ku u8 band: 2; 1134e390cf2eSChing-Te Ku 1135e390cf2eSChing-Te Ku u8 client_ps: 1; 1136e390cf2eSChing-Te Ku u8 bw: 7; 1137e390cf2eSChing-Te Ku 1138e390cf2eSChing-Te Ku u8 role; 1139e390cf2eSChing-Te Ku u8 ch; 1140e390cf2eSChing-Te Ku 1141e390cf2eSChing-Te Ku u16 tx_lvl; 1142e390cf2eSChing-Te Ku u16 rx_lvl; 1143e390cf2eSChing-Te Ku u16 tx_rate; 1144e390cf2eSChing-Te Ku u16 rx_rate; 1145e390cf2eSChing-Te Ku 1146e390cf2eSChing-Te Ku u32 noa_duration; /* ms */ 1147e390cf2eSChing-Te Ku }; 1148e390cf2eSChing-Te Ku 1149e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info_bpos { 1150e3ec7017SPing-Ke Shih u16 none: 1; 1151e3ec7017SPing-Ke Shih u16 station: 1; 1152e3ec7017SPing-Ke Shih u16 ap: 1; 1153e3ec7017SPing-Ke Shih u16 vap: 1; 1154e3ec7017SPing-Ke Shih u16 adhoc: 1; 1155e3ec7017SPing-Ke Shih u16 adhoc_master: 1; 1156e3ec7017SPing-Ke Shih u16 mesh: 1; 1157e3ec7017SPing-Ke Shih u16 moniter: 1; 1158e3ec7017SPing-Ke Shih u16 p2p_device: 1; 1159e3ec7017SPing-Ke Shih u16 p2p_gc: 1; 1160e3ec7017SPing-Ke Shih u16 p2p_go: 1; 1161e3ec7017SPing-Ke Shih u16 nan: 1; 1162e3ec7017SPing-Ke Shih }; 1163e3ec7017SPing-Ke Shih 1164747dc30eSChing-Te Ku struct rtw89_btc_wl_scc_ctrl { 1165747dc30eSChing-Te Ku u8 null_role1; 1166747dc30eSChing-Te Ku u8 null_role2; 1167747dc30eSChing-Te Ku u8 ebt_null; /* if tx null at EBT slot */ 1168747dc30eSChing-Te Ku }; 1169747dc30eSChing-Te Ku 1170e3ec7017SPing-Ke Shih union rtw89_btc_wl_role_info_map { 1171e3ec7017SPing-Ke Shih u16 val; 1172e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info_bpos role; 1173e3ec7017SPing-Ke Shih }; 1174e3ec7017SPing-Ke Shih 1175e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info { /* struct size must be n*4 bytes */ 1176e3ec7017SPing-Ke Shih u8 connect_cnt; 1177e3ec7017SPing-Ke Shih u8 link_mode; 1178e3ec7017SPing-Ke Shih union rtw89_btc_wl_role_info_map role_map; 117920d9fc88SPing-Ke Shih struct rtw89_btc_wl_active_role active_role[RTW89_PORT_NUM]; 1180e3ec7017SPing-Ke Shih }; 1181e3ec7017SPing-Ke Shih 1182e390cf2eSChing-Te Ku struct rtw89_btc_wl_role_info_v1 { /* struct size must be n*4 bytes */ 1183e390cf2eSChing-Te Ku u8 connect_cnt; 1184e390cf2eSChing-Te Ku u8 link_mode; 1185e390cf2eSChing-Te Ku union rtw89_btc_wl_role_info_map role_map; 1186e390cf2eSChing-Te Ku struct rtw89_btc_wl_active_role_v1 active_role_v1[RTW89_PORT_NUM]; 1187e390cf2eSChing-Te Ku u32 mrole_type; /* btc_wl_mrole_type */ 1188e390cf2eSChing-Te Ku u32 mrole_noa_duration; /* ms */ 1189e390cf2eSChing-Te Ku 1190e390cf2eSChing-Te Ku u32 dbcc_en: 1; 1191e390cf2eSChing-Te Ku u32 dbcc_chg: 1; 1192e390cf2eSChing-Te Ku u32 dbcc_2g_phy: 2; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */ 1193e390cf2eSChing-Te Ku u32 link_mode_chg: 1; 1194e390cf2eSChing-Te Ku u32 rsvd: 27; 1195e390cf2eSChing-Te Ku }; 1196e390cf2eSChing-Te Ku 1197e3ec7017SPing-Ke Shih struct rtw89_btc_wl_ver_info { 1198e3ec7017SPing-Ke Shih u32 fw_coex; /* match with which coex_ver */ 1199e3ec7017SPing-Ke Shih u32 fw; 1200e3ec7017SPing-Ke Shih u32 mac; 1201e3ec7017SPing-Ke Shih u32 bb; 1202e3ec7017SPing-Ke Shih u32 rf; 1203e3ec7017SPing-Ke Shih }; 1204e3ec7017SPing-Ke Shih 1205e3ec7017SPing-Ke Shih struct rtw89_btc_wl_afh_info { 1206e3ec7017SPing-Ke Shih u8 en; 1207e3ec7017SPing-Ke Shih u8 ch; 1208e3ec7017SPing-Ke Shih u8 bw; 1209e3ec7017SPing-Ke Shih u8 rsvd; 1210e3ec7017SPing-Ke Shih } __packed; 1211e3ec7017SPing-Ke Shih 1212e3ec7017SPing-Ke Shih struct rtw89_btc_wl_rfk_info { 1213e3ec7017SPing-Ke Shih u32 state: 2; 1214e3ec7017SPing-Ke Shih u32 path_map: 4; 1215e3ec7017SPing-Ke Shih u32 phy_map: 2; 1216e3ec7017SPing-Ke Shih u32 band: 2; 1217e3ec7017SPing-Ke Shih u32 type: 8; 1218e3ec7017SPing-Ke Shih u32 rsvd: 14; 1219e3ec7017SPing-Ke Shih }; 1220e3ec7017SPing-Ke Shih 1221e3ec7017SPing-Ke Shih struct rtw89_btc_bt_smap { 1222e3ec7017SPing-Ke Shih u32 connect: 1; 1223e3ec7017SPing-Ke Shih u32 ble_connect: 1; 1224e3ec7017SPing-Ke Shih u32 acl_busy: 1; 1225e3ec7017SPing-Ke Shih u32 sco_busy: 1; 1226e3ec7017SPing-Ke Shih u32 mesh_busy: 1; 1227e3ec7017SPing-Ke Shih u32 inq_pag: 1; 1228e3ec7017SPing-Ke Shih }; 1229e3ec7017SPing-Ke Shih 1230e3ec7017SPing-Ke Shih union rtw89_btc_bt_state_map { 1231e3ec7017SPing-Ke Shih u32 val; 1232e3ec7017SPing-Ke Shih struct rtw89_btc_bt_smap map; 1233e3ec7017SPing-Ke Shih }; 1234e3ec7017SPing-Ke Shih 1235e3ec7017SPing-Ke Shih #define BTC_BT_RSSI_THMAX 4 1236e3ec7017SPing-Ke Shih #define BTC_BT_AFH_GROUP 12 1237e3ec7017SPing-Ke Shih 1238e3ec7017SPing-Ke Shih struct rtw89_btc_bt_link_info { 1239e3ec7017SPing-Ke Shih struct rtw89_btc_u8_sta_chg profile_cnt; 1240e3ec7017SPing-Ke Shih struct rtw89_btc_bool_sta_chg multi_link; 1241e3ec7017SPing-Ke Shih struct rtw89_btc_bool_sta_chg relink; 1242e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hfp_desc hfp_desc; 1243e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hid_desc hid_desc; 1244e3ec7017SPing-Ke Shih struct rtw89_btc_bt_a2dp_desc a2dp_desc; 1245e3ec7017SPing-Ke Shih struct rtw89_btc_bt_pan_desc pan_desc; 1246e3ec7017SPing-Ke Shih union rtw89_btc_bt_state_map status; 1247e3ec7017SPing-Ke Shih 1248e3ec7017SPing-Ke Shih u8 sut_pwr_level[BTC_PROFILE_MAX]; 1249e3ec7017SPing-Ke Shih u8 golden_rx_shift[BTC_PROFILE_MAX]; 1250e3ec7017SPing-Ke Shih u8 rssi_state[BTC_BT_RSSI_THMAX]; 1251e3ec7017SPing-Ke Shih u8 afh_map[BTC_BT_AFH_GROUP]; 1252e3ec7017SPing-Ke Shih 1253e3ec7017SPing-Ke Shih u32 role_sw: 1; 1254e3ec7017SPing-Ke Shih u32 slave_role: 1; 1255e3ec7017SPing-Ke Shih u32 afh_update: 1; 1256e3ec7017SPing-Ke Shih u32 cqddr: 1; 1257e3ec7017SPing-Ke Shih u32 rssi: 8; 1258e3ec7017SPing-Ke Shih u32 tx_3m: 1; 1259e3ec7017SPing-Ke Shih u32 rsvd: 19; 1260e3ec7017SPing-Ke Shih }; 1261e3ec7017SPing-Ke Shih 1262e3ec7017SPing-Ke Shih struct rtw89_btc_3rdcx_info { 1263e3ec7017SPing-Ke Shih u8 type; /* 0: none, 1:zigbee, 2:LTE */ 1264e3ec7017SPing-Ke Shih u8 hw_coex; 1265e3ec7017SPing-Ke Shih u16 rsvd; 1266e3ec7017SPing-Ke Shih }; 1267e3ec7017SPing-Ke Shih 1268e3ec7017SPing-Ke Shih struct rtw89_btc_dm_emap { 1269e3ec7017SPing-Ke Shih u32 init: 1; 1270e3ec7017SPing-Ke Shih u32 pta_owner: 1; 1271e3ec7017SPing-Ke Shih u32 wl_rfk_timeout: 1; 1272e3ec7017SPing-Ke Shih u32 bt_rfk_timeout: 1; 1273e3ec7017SPing-Ke Shih 1274e3ec7017SPing-Ke Shih u32 wl_fw_hang: 1; 1275e3ec7017SPing-Ke Shih u32 offload_mismatch: 1; 1276e3ec7017SPing-Ke Shih u32 cycle_hang: 1; 1277e3ec7017SPing-Ke Shih u32 w1_hang: 1; 1278e3ec7017SPing-Ke Shih 1279e3ec7017SPing-Ke Shih u32 b1_hang: 1; 1280e3ec7017SPing-Ke Shih u32 tdma_no_sync: 1; 1281e3ec7017SPing-Ke Shih u32 wl_slot_drift: 1; 1282e3ec7017SPing-Ke Shih }; 1283e3ec7017SPing-Ke Shih 1284e3ec7017SPing-Ke Shih union rtw89_btc_dm_error_map { 1285e3ec7017SPing-Ke Shih u32 val; 1286e3ec7017SPing-Ke Shih struct rtw89_btc_dm_emap map; 1287e3ec7017SPing-Ke Shih }; 1288e3ec7017SPing-Ke Shih 1289e3ec7017SPing-Ke Shih struct rtw89_btc_rf_para { 1290e3ec7017SPing-Ke Shih u32 tx_pwr_freerun; 1291e3ec7017SPing-Ke Shih u32 rx_gain_freerun; 1292e3ec7017SPing-Ke Shih u32 tx_pwr_perpkt; 1293e3ec7017SPing-Ke Shih u32 rx_gain_perpkt; 1294e3ec7017SPing-Ke Shih }; 1295e3ec7017SPing-Ke Shih 1296e3ec7017SPing-Ke Shih struct rtw89_btc_wl_info { 129720d9fc88SPing-Ke Shih struct rtw89_btc_wl_link_info link_info[RTW89_PORT_NUM]; 1298e3ec7017SPing-Ke Shih struct rtw89_btc_wl_rfk_info rfk_info; 1299e3ec7017SPing-Ke Shih struct rtw89_btc_wl_ver_info ver_info; 1300e3ec7017SPing-Ke Shih struct rtw89_btc_wl_afh_info afh_info; 1301e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info role_info; 1302e390cf2eSChing-Te Ku struct rtw89_btc_wl_role_info_v1 role_info_v1; 1303e3ec7017SPing-Ke Shih struct rtw89_btc_wl_scan_info scan_info; 1304e3ec7017SPing-Ke Shih struct rtw89_btc_wl_dbcc_info dbcc_info; 1305e3ec7017SPing-Ke Shih struct rtw89_btc_rf_para rf_para; 1306e3ec7017SPing-Ke Shih union rtw89_btc_wl_state_map status; 1307e3ec7017SPing-Ke Shih 1308e3ec7017SPing-Ke Shih u8 port_id[RTW89_WIFI_ROLE_MLME_MAX]; 1309e3ec7017SPing-Ke Shih u8 rssi_level; 1310e3ec7017SPing-Ke Shih 1311e3ec7017SPing-Ke Shih u32 scbd; 1312e3ec7017SPing-Ke Shih }; 1313e3ec7017SPing-Ke Shih 1314e3ec7017SPing-Ke Shih struct rtw89_btc_module { 1315e3ec7017SPing-Ke Shih struct rtw89_btc_ant_info ant; 1316e3ec7017SPing-Ke Shih u8 rfe_type; 1317e3ec7017SPing-Ke Shih u8 cv; 1318e3ec7017SPing-Ke Shih 1319e3ec7017SPing-Ke Shih u8 bt_solo: 1; 1320e3ec7017SPing-Ke Shih u8 bt_pos: 1; 1321e3ec7017SPing-Ke Shih u8 switch_type: 1; 1322e3ec7017SPing-Ke Shih 1323e3ec7017SPing-Ke Shih u8 rsvd; 1324e3ec7017SPing-Ke Shih }; 1325e3ec7017SPing-Ke Shih 1326e3ec7017SPing-Ke Shih #define RTW89_BTC_DM_MAXSTEP 30 1327e3ec7017SPing-Ke Shih #define RTW89_BTC_DM_CNT_MAX (RTW89_BTC_DM_MAXSTEP * 8) 1328e3ec7017SPing-Ke Shih 1329e3ec7017SPing-Ke Shih struct rtw89_btc_dm_step { 1330e3ec7017SPing-Ke Shih u16 step[RTW89_BTC_DM_MAXSTEP]; 1331e3ec7017SPing-Ke Shih u8 step_pos; 1332e3ec7017SPing-Ke Shih bool step_ov; 1333e3ec7017SPing-Ke Shih }; 1334e3ec7017SPing-Ke Shih 1335e3ec7017SPing-Ke Shih struct rtw89_btc_init_info { 1336e3ec7017SPing-Ke Shih struct rtw89_btc_module module; 1337e3ec7017SPing-Ke Shih u8 wl_guard_ch; 1338e3ec7017SPing-Ke Shih 1339e3ec7017SPing-Ke Shih u8 wl_only: 1; 1340e3ec7017SPing-Ke Shih u8 wl_init_ok: 1; 1341e3ec7017SPing-Ke Shih u8 dbcc_en: 1; 1342e3ec7017SPing-Ke Shih u8 cx_other: 1; 1343e3ec7017SPing-Ke Shih u8 bt_only: 1; 1344e3ec7017SPing-Ke Shih 1345e3ec7017SPing-Ke Shih u16 rsvd; 1346e3ec7017SPing-Ke Shih }; 1347e3ec7017SPing-Ke Shih 1348e3ec7017SPing-Ke Shih struct rtw89_btc_wl_tx_limit_para { 1349e3ec7017SPing-Ke Shih u16 enable; 1350e3ec7017SPing-Ke Shih u32 tx_time; /* unit: us */ 1351e3ec7017SPing-Ke Shih u16 tx_retry; 1352e3ec7017SPing-Ke Shih }; 1353e3ec7017SPing-Ke Shih 1354e3ec7017SPing-Ke Shih struct rtw89_btc_bt_scan_info { 1355e3ec7017SPing-Ke Shih u16 win; 1356e3ec7017SPing-Ke Shih u16 intvl; 1357e3ec7017SPing-Ke Shih u32 enable: 1; 1358e3ec7017SPing-Ke Shih u32 interlace: 1; 1359e3ec7017SPing-Ke Shih u32 rsvd: 30; 1360e3ec7017SPing-Ke Shih }; 1361e3ec7017SPing-Ke Shih 1362e3ec7017SPing-Ke Shih enum rtw89_btc_bt_scan_type { 1363e3ec7017SPing-Ke Shih BTC_SCAN_INQ = 0, 1364e3ec7017SPing-Ke Shih BTC_SCAN_PAGE, 1365e3ec7017SPing-Ke Shih BTC_SCAN_BLE, 1366e3ec7017SPing-Ke Shih BTC_SCAN_INIT, 1367e3ec7017SPing-Ke Shih BTC_SCAN_TV, 1368e3ec7017SPing-Ke Shih BTC_SCAN_ADV, 1369e3ec7017SPing-Ke Shih BTC_SCAN_MAX1, 1370e3ec7017SPing-Ke Shih }; 1371e3ec7017SPing-Ke Shih 1372e3ec7017SPing-Ke Shih struct rtw89_btc_bt_info { 1373e3ec7017SPing-Ke Shih struct rtw89_btc_bt_link_info link_info; 1374e3ec7017SPing-Ke Shih struct rtw89_btc_bt_scan_info scan_info[BTC_SCAN_MAX1]; 1375e3ec7017SPing-Ke Shih struct rtw89_btc_bt_ver_info ver_info; 1376e3ec7017SPing-Ke Shih struct rtw89_btc_bool_sta_chg enable; 1377e3ec7017SPing-Ke Shih struct rtw89_btc_bool_sta_chg inq_pag; 1378e3ec7017SPing-Ke Shih struct rtw89_btc_rf_para rf_para; 1379e3ec7017SPing-Ke Shih union rtw89_btc_bt_rfk_info_map rfk_info; 1380e3ec7017SPing-Ke Shih 1381e3ec7017SPing-Ke Shih u8 raw_info[BTC_BTINFO_MAX]; /* raw bt info from mailbox */ 1382e3ec7017SPing-Ke Shih 1383e3ec7017SPing-Ke Shih u32 scbd; 1384e3ec7017SPing-Ke Shih u32 feature; 1385e3ec7017SPing-Ke Shih 1386e3ec7017SPing-Ke Shih u32 mbx_avl: 1; 1387e3ec7017SPing-Ke Shih u32 whql_test: 1; 1388e3ec7017SPing-Ke Shih u32 igno_wl: 1; 1389e3ec7017SPing-Ke Shih u32 reinit: 1; 1390e3ec7017SPing-Ke Shih u32 ble_scan_en: 1; 1391e3ec7017SPing-Ke Shih u32 btg_type: 1; 1392e3ec7017SPing-Ke Shih u32 inq: 1; 1393e3ec7017SPing-Ke Shih u32 pag: 1; 1394e3ec7017SPing-Ke Shih u32 run_patch_code: 1; 1395e3ec7017SPing-Ke Shih u32 hi_lna_rx: 1; 1396e3ec7017SPing-Ke Shih u32 rsvd: 22; 1397e3ec7017SPing-Ke Shih }; 1398e3ec7017SPing-Ke Shih 1399e3ec7017SPing-Ke Shih struct rtw89_btc_cx { 1400e3ec7017SPing-Ke Shih struct rtw89_btc_wl_info wl; 1401e3ec7017SPing-Ke Shih struct rtw89_btc_bt_info bt; 1402e3ec7017SPing-Ke Shih struct rtw89_btc_3rdcx_info other; 1403e3ec7017SPing-Ke Shih u32 state_map; 1404e3ec7017SPing-Ke Shih u32 cnt_bt[BTC_BCNT_NUM]; 1405e3ec7017SPing-Ke Shih u32 cnt_wl[BTC_WCNT_NUM]; 1406e3ec7017SPing-Ke Shih }; 1407e3ec7017SPing-Ke Shih 1408e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_tdma { 1409ba787c07SChing-Te Ku u8 type; /* chip_info::fcxtdma_ver */ 1410e3ec7017SPing-Ke Shih u8 rxflctrl; 1411e3ec7017SPing-Ke Shih u8 txpause; 1412e3ec7017SPing-Ke Shih u8 wtgle_n; 1413e3ec7017SPing-Ke Shih u8 leak_n; 1414e3ec7017SPing-Ke Shih u8 ext_ctrl; 1415ce986f3dSChing-Te Ku u8 rxflctrl_role; 1416ce986f3dSChing-Te Ku u8 option_ctrl; 1417ce986f3dSChing-Te Ku } __packed; 1418ce986f3dSChing-Te Ku 1419ce986f3dSChing-Te Ku struct rtw89_btc_fbtc_tdma_v1 { 1420ce986f3dSChing-Te Ku u8 fver; /* chip_info::fcxtdma_ver */ 1421ce986f3dSChing-Te Ku u8 rsvd; 1422ce986f3dSChing-Te Ku __le16 rsvd1; 1423ce986f3dSChing-Te Ku struct rtw89_btc_fbtc_tdma tdma; 1424e3ec7017SPing-Ke Shih } __packed; 1425e3ec7017SPing-Ke Shih 1426e3ec7017SPing-Ke Shih #define CXMREG_MAX 30 1427e3ec7017SPing-Ke Shih #define FCXMAX_STEP 255 /*STEP trace record cnt, Max:65535, default:255*/ 1428e3ec7017SPing-Ke Shih #define BTC_CYCLE_SLOT_MAX 48 /* must be even number, non-zero */ 1429e3ec7017SPing-Ke Shih 14301162584cSChing-Te Ku enum rtw89_btc_bt_sta_counter { 1431e3ec7017SPing-Ke Shih BTC_BCNT_RFK_REQ = 0, 1432e3ec7017SPing-Ke Shih BTC_BCNT_RFK_GO = 1, 1433e3ec7017SPing-Ke Shih BTC_BCNT_RFK_REJECT = 2, 1434e3ec7017SPing-Ke Shih BTC_BCNT_RFK_FAIL = 3, 1435e3ec7017SPing-Ke Shih BTC_BCNT_RFK_TIMEOUT = 4, 14361162584cSChing-Te Ku BTC_BCNT_HI_TX = 5, 14371162584cSChing-Te Ku BTC_BCNT_HI_RX = 6, 14381162584cSChing-Te Ku BTC_BCNT_LO_TX = 7, 14391162584cSChing-Te Ku BTC_BCNT_LO_RX = 8, 14401162584cSChing-Te Ku BTC_BCNT_POLLUTED = 9, 14411162584cSChing-Te Ku BTC_BCNT_STA_MAX 1442e3ec7017SPing-Ke Shih }; 1443e3ec7017SPing-Ke Shih 1444e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_rpt_ctrl { 1445ba787c07SChing-Te Ku u16 fver; /* chip_info::fcxbtcrpt_ver */ 1446e3ec7017SPing-Ke Shih u16 rpt_cnt; /* tmr counters */ 1447e3ec7017SPing-Ke Shih u32 wl_fw_coex_ver; /* match which driver's coex version */ 1448e3ec7017SPing-Ke Shih u32 wl_fw_cx_offload; 1449e3ec7017SPing-Ke Shih u32 wl_fw_ver; 1450e3ec7017SPing-Ke Shih u32 rpt_enable; 1451e3ec7017SPing-Ke Shih u32 rpt_para; /* ms */ 1452e3ec7017SPing-Ke Shih u32 mb_send_fail_cnt; /* fw send mailbox fail counter */ 1453e3ec7017SPing-Ke Shih u32 mb_send_ok_cnt; /* fw send mailbox ok counter */ 1454e3ec7017SPing-Ke Shih u32 mb_recv_cnt; /* fw recv mailbox counter */ 1455e3ec7017SPing-Ke Shih u32 mb_a2dp_empty_cnt; /* a2dp empty count */ 1456e3ec7017SPing-Ke Shih u32 mb_a2dp_flct_cnt; /* a2dp empty flow control counter */ 1457e3ec7017SPing-Ke Shih u32 mb_a2dp_full_cnt; /* a2dp empty full counter */ 14581162584cSChing-Te Ku u32 bt_rfk_cnt[BTC_BCNT_HI_TX]; 1459e3ec7017SPing-Ke Shih u32 c2h_cnt; /* fw send c2h counter */ 1460e3ec7017SPing-Ke Shih u32 h2c_cnt; /* fw recv h2c counter */ 1461e3ec7017SPing-Ke Shih } __packed; 1462e3ec7017SPing-Ke Shih 14631162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_info { 14641162584cSChing-Te Ku __le32 cnt; /* fw report counter */ 14651162584cSChing-Te Ku __le32 en; /* report map */ 14661162584cSChing-Te Ku __le32 para; /* not used */ 14671162584cSChing-Te Ku 14681162584cSChing-Te Ku __le32 cnt_c2h; /* fw send c2h counter */ 14691162584cSChing-Te Ku __le32 cnt_h2c; /* fw recv h2c counter */ 14701162584cSChing-Te Ku __le32 len_c2h; /* The total length of the last C2H */ 14711162584cSChing-Te Ku 14721162584cSChing-Te Ku __le32 cnt_aoac_rf_on; /* rf-on counter for aoac switch notify */ 14731162584cSChing-Te Ku __le32 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */ 14741162584cSChing-Te Ku } __packed; 14751162584cSChing-Te Ku 14761162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info { 14771162584cSChing-Te Ku __le32 cx_ver; /* match which driver's coex version */ 14781162584cSChing-Te Ku __le32 cx_offload; 14791162584cSChing-Te Ku __le32 fw_ver; 14801162584cSChing-Te Ku } __packed; 14811162584cSChing-Te Ku 14821162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty { 14831162584cSChing-Te Ku __le32 cnt_empty; /* a2dp empty count */ 14841162584cSChing-Te Ku __le32 cnt_flowctrl; /* a2dp empty flow control counter */ 14851162584cSChing-Te Ku __le32 cnt_tx; 14861162584cSChing-Te Ku __le32 cnt_ack; 14871162584cSChing-Te Ku __le32 cnt_nack; 14881162584cSChing-Te Ku } __packed; 14891162584cSChing-Te Ku 14901162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox { 14911162584cSChing-Te Ku __le32 cnt_send_ok; /* fw send mailbox ok counter */ 14921162584cSChing-Te Ku __le32 cnt_send_fail; /* fw send mailbox fail counter */ 14931162584cSChing-Te Ku __le32 cnt_recv; /* fw recv mailbox counter */ 14941162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty a2dp; 14951162584cSChing-Te Ku } __packed; 14961162584cSChing-Te Ku 14971162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_v1 { 14981162584cSChing-Te Ku u8 fver; 14991162584cSChing-Te Ku u8 rsvd; 15001162584cSChing-Te Ku __le16 rsvd1; 15011162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_info rpt_info; 15021162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info wl_fw_info; 15031162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info; 15041162584cSChing-Te Ku __le32 bt_cnt[BTC_BCNT_STA_MAX]; 15051162584cSChing-Te Ku struct rtw89_mac_ax_gnt gnt_val[RTW89_PHY_MAX]; 15061162584cSChing-Te Ku } __packed; 15071162584cSChing-Te Ku 1508e3ec7017SPing-Ke Shih enum rtw89_fbtc_ext_ctrl_type { 1509e3ec7017SPing-Ke Shih CXECTL_OFF = 0x0, /* tdma off */ 1510e3ec7017SPing-Ke Shih CXECTL_B2 = 0x1, /* allow B2 (beacon-early) */ 1511e3ec7017SPing-Ke Shih CXECTL_EXT = 0x2, 1512e3ec7017SPing-Ke Shih CXECTL_MAX 1513e3ec7017SPing-Ke Shih }; 1514e3ec7017SPing-Ke Shih 1515e3ec7017SPing-Ke Shih union rtw89_btc_fbtc_rxflct { 1516e3ec7017SPing-Ke Shih u8 val; 1517e3ec7017SPing-Ke Shih u8 type: 3; 1518e3ec7017SPing-Ke Shih u8 tgln_n: 5; 1519e3ec7017SPing-Ke Shih }; 1520e3ec7017SPing-Ke Shih 1521e3ec7017SPing-Ke Shih enum rtw89_btc_cxst_state { 1522e3ec7017SPing-Ke Shih CXST_OFF = 0x0, 1523e3ec7017SPing-Ke Shih CXST_B2W = 0x1, 1524e3ec7017SPing-Ke Shih CXST_W1 = 0x2, 1525e3ec7017SPing-Ke Shih CXST_W2 = 0x3, 1526e3ec7017SPing-Ke Shih CXST_W2B = 0x4, 1527e3ec7017SPing-Ke Shih CXST_B1 = 0x5, 1528e3ec7017SPing-Ke Shih CXST_B2 = 0x6, 1529e3ec7017SPing-Ke Shih CXST_B3 = 0x7, 1530e3ec7017SPing-Ke Shih CXST_B4 = 0x8, 1531e3ec7017SPing-Ke Shih CXST_LK = 0x9, 1532e3ec7017SPing-Ke Shih CXST_BLK = 0xa, 1533e3ec7017SPing-Ke Shih CXST_E2G = 0xb, 1534e3ec7017SPing-Ke Shih CXST_E5G = 0xc, 1535e3ec7017SPing-Ke Shih CXST_EBT = 0xd, 1536e3ec7017SPing-Ke Shih CXST_ENULL = 0xe, 1537e3ec7017SPing-Ke Shih CXST_WLK = 0xf, 1538e3ec7017SPing-Ke Shih CXST_W1FDD = 0x10, 1539e3ec7017SPing-Ke Shih CXST_B1FDD = 0x11, 1540e3ec7017SPing-Ke Shih CXST_MAX = 0x12, 1541e3ec7017SPing-Ke Shih }; 1542e3ec7017SPing-Ke Shih 1543e3ec7017SPing-Ke Shih enum { 1544e3ec7017SPing-Ke Shih CXBCN_ALL = 0x0, 1545e3ec7017SPing-Ke Shih CXBCN_ALL_OK, 1546e3ec7017SPing-Ke Shih CXBCN_BT_SLOT, 1547e3ec7017SPing-Ke Shih CXBCN_BT_OK, 1548e3ec7017SPing-Ke Shih CXBCN_MAX 1549e3ec7017SPing-Ke Shih }; 1550e3ec7017SPing-Ke Shih 1551e3ec7017SPing-Ke Shih enum btc_slot_type { 1552e3ec7017SPing-Ke Shih SLOT_MIX = 0x0, /* accept BT Lower-Pri Tx/Rx request 0x778 = 1 */ 1553e3ec7017SPing-Ke Shih SLOT_ISO = 0x1, /* no accept BT Lower-Pri Tx/Rx request 0x778 = d*/ 1554e3ec7017SPing-Ke Shih CXSTYPE_NUM, 1555e3ec7017SPing-Ke Shih }; 1556e3ec7017SPing-Ke Shih 1557e3ec7017SPing-Ke Shih enum { /* TIME */ 1558e3ec7017SPing-Ke Shih CXT_BT = 0x0, 1559e3ec7017SPing-Ke Shih CXT_WL = 0x1, 1560e3ec7017SPing-Ke Shih CXT_MAX 1561e3ec7017SPing-Ke Shih }; 1562e3ec7017SPing-Ke Shih 1563e3ec7017SPing-Ke Shih enum { /* TIME-A2DP */ 1564e3ec7017SPing-Ke Shih CXT_FLCTRL_OFF = 0x0, 1565e3ec7017SPing-Ke Shih CXT_FLCTRL_ON = 0x1, 1566e3ec7017SPing-Ke Shih CXT_FLCTRL_MAX 1567e3ec7017SPing-Ke Shih }; 1568e3ec7017SPing-Ke Shih 1569e3ec7017SPing-Ke Shih enum { /* STEP TYPE */ 1570e3ec7017SPing-Ke Shih CXSTEP_NONE = 0x0, 1571e3ec7017SPing-Ke Shih CXSTEP_EVNT = 0x1, 1572e3ec7017SPing-Ke Shih CXSTEP_SLOT = 0x2, 1573e3ec7017SPing-Ke Shih CXSTEP_MAX, 1574e3ec7017SPing-Ke Shih }; 1575e3ec7017SPing-Ke Shih 1576e3ec7017SPing-Ke Shih #define BTC_DBG_MAX1 32 1577e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_gpio_dbg { 1578ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxgpiodbg_ver */ 1579e3ec7017SPing-Ke Shih u8 rsvd; 1580e3ec7017SPing-Ke Shih u16 rsvd2; 1581e3ec7017SPing-Ke Shih u32 en_map; /* which debug signal (see btc_wl_gpio_debug) is enable */ 1582e3ec7017SPing-Ke Shih u32 pre_state; /* the debug signal is 1 or 0 */ 1583e3ec7017SPing-Ke Shih u8 gpio_map[BTC_DBG_MAX1]; /*the debug signals to GPIO-Position */ 1584e3ec7017SPing-Ke Shih } __packed; 1585e3ec7017SPing-Ke Shih 1586e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_mreg_val { 1587ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxmreg_ver */ 1588e3ec7017SPing-Ke Shih u8 reg_num; 1589e3ec7017SPing-Ke Shih __le16 rsvd; 1590e3ec7017SPing-Ke Shih __le32 mreg_val[CXMREG_MAX]; 1591e3ec7017SPing-Ke Shih } __packed; 1592e3ec7017SPing-Ke Shih 1593e3ec7017SPing-Ke Shih #define RTW89_DEF_FBTC_MREG(__type, __bytes, __offset) \ 1594e3ec7017SPing-Ke Shih { .type = cpu_to_le16(__type), .bytes = cpu_to_le16(__bytes), \ 1595e3ec7017SPing-Ke Shih .offset = cpu_to_le32(__offset), } 1596e3ec7017SPing-Ke Shih 1597e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_mreg { 1598e3ec7017SPing-Ke Shih __le16 type; 1599e3ec7017SPing-Ke Shih __le16 bytes; 1600e3ec7017SPing-Ke Shih __le32 offset; 1601e3ec7017SPing-Ke Shih } __packed; 1602e3ec7017SPing-Ke Shih 1603e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slot { 1604e3ec7017SPing-Ke Shih __le16 dur; 1605e3ec7017SPing-Ke Shih __le32 cxtbl; 1606e3ec7017SPing-Ke Shih __le16 cxtype; 1607e3ec7017SPing-Ke Shih } __packed; 1608e3ec7017SPing-Ke Shih 1609e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slots { 1610ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxslots_ver */ 1611e3ec7017SPing-Ke Shih u8 tbl_num; 1612e3ec7017SPing-Ke Shih __le16 rsvd; 1613e3ec7017SPing-Ke Shih __le32 update_map; 1614e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slot slot[CXST_MAX]; 1615e3ec7017SPing-Ke Shih } __packed; 1616e3ec7017SPing-Ke Shih 1617e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_step { 1618e3ec7017SPing-Ke Shih u8 type; 1619e3ec7017SPing-Ke Shih u8 val; 1620e3ec7017SPing-Ke Shih __le16 difft; 1621e3ec7017SPing-Ke Shih } __packed; 1622e3ec7017SPing-Ke Shih 1623e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_steps { 1624ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxstep_ver */ 1625e3ec7017SPing-Ke Shih u8 rsvd; 1626e3ec7017SPing-Ke Shih __le16 cnt; 1627e3ec7017SPing-Ke Shih __le16 pos_old; 1628e3ec7017SPing-Ke Shih __le16 pos_new; 1629e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_step step[FCXMAX_STEP]; 1630e3ec7017SPing-Ke Shih } __packed; 1631e3ec7017SPing-Ke Shih 1632e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_cysta { /* statistics for cycles */ 1633ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxcysta_ver */ 1634e3ec7017SPing-Ke Shih u8 rsvd; 1635e3ec7017SPing-Ke Shih __le16 cycles; /* total cycle number */ 1636e3ec7017SPing-Ke Shih __le16 cycles_a2dp[CXT_FLCTRL_MAX]; 1637e3ec7017SPing-Ke Shih __le16 a2dpept; /* a2dp empty cnt */ 1638e3ec7017SPing-Ke Shih __le16 a2dpeptto; /* a2dp empty timeout cnt*/ 1639e3ec7017SPing-Ke Shih __le16 tavg_cycle[CXT_MAX]; /* avg wl/bt cycle time */ 1640e3ec7017SPing-Ke Shih __le16 tmax_cycle[CXT_MAX]; /* max wl/bt cycle time */ 1641e3ec7017SPing-Ke Shih __le16 tmaxdiff_cycle[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */ 1642e3ec7017SPing-Ke Shih __le16 tavg_a2dp[CXT_FLCTRL_MAX]; /* avg a2dp PSTDMA/TDMA time */ 1643e3ec7017SPing-Ke Shih __le16 tmax_a2dp[CXT_FLCTRL_MAX]; /* max a2dp PSTDMA/TDMA time */ 1644e3ec7017SPing-Ke Shih __le16 tavg_a2dpept; /* avg a2dp empty time */ 1645e3ec7017SPing-Ke Shih __le16 tmax_a2dpept; /* max a2dp empty time */ 1646e3ec7017SPing-Ke Shih __le16 tavg_lk; /* avg leak-slot time */ 1647e3ec7017SPing-Ke Shih __le16 tmax_lk; /* max leak-slot time */ 1648e3ec7017SPing-Ke Shih __le32 slot_cnt[CXST_MAX]; /* slot count */ 1649e3ec7017SPing-Ke Shih __le32 bcn_cnt[CXBCN_MAX]; 1650e3ec7017SPing-Ke Shih __le32 leakrx_cnt; /* the rximr occur at leak slot */ 1651e3ec7017SPing-Ke Shih __le32 collision_cnt; /* counter for event/timer occur at same time */ 1652e3ec7017SPing-Ke Shih __le32 skip_cnt; 1653e3ec7017SPing-Ke Shih __le32 exception; 1654e3ec7017SPing-Ke Shih __le32 except_cnt; 1655e3ec7017SPing-Ke Shih __le16 tslot_cycle[BTC_CYCLE_SLOT_MAX]; 1656e3ec7017SPing-Ke Shih } __packed; 1657e3ec7017SPing-Ke Shih 16583832a542SChing-Te Ku struct rtw89_btc_fbtc_fdd_try_info { 16593832a542SChing-Te Ku __le16 cycles[CXT_FLCTRL_MAX]; 16603832a542SChing-Te Ku __le16 tavg[CXT_FLCTRL_MAX]; /* avg try BT-Slot-TDD/BT-slot-FDD time */ 16613832a542SChing-Te Ku __le16 tmax[CXT_FLCTRL_MAX]; /* max try BT-Slot-TDD/BT-slot-FDD time */ 16623832a542SChing-Te Ku } __packed; 16633832a542SChing-Te Ku 16643832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_time_info { 16653832a542SChing-Te Ku __le16 tavg[CXT_MAX]; /* avg wl/bt cycle time */ 16663832a542SChing-Te Ku __le16 tmax[CXT_MAX]; /* max wl/bt cycle time */ 16673832a542SChing-Te Ku __le16 tmaxdiff[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */ 16683832a542SChing-Te Ku } __packed; 16693832a542SChing-Te Ku 16703832a542SChing-Te Ku struct rtw89_btc_fbtc_a2dp_trx_stat { 16713832a542SChing-Te Ku u8 empty_cnt; 16723832a542SChing-Te Ku u8 retry_cnt; 16733832a542SChing-Te Ku u8 tx_rate; 16743832a542SChing-Te Ku u8 tx_cnt; 16753832a542SChing-Te Ku u8 ack_cnt; 16763832a542SChing-Te Ku u8 nack_cnt; 16773832a542SChing-Te Ku u8 rsvd1; 16783832a542SChing-Te Ku u8 rsvd2; 16793832a542SChing-Te Ku } __packed; 16803832a542SChing-Te Ku 16813832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_a2dp_empty_info { 16823832a542SChing-Te Ku __le16 cnt; /* a2dp empty cnt */ 16833832a542SChing-Te Ku __le16 cnt_timeout; /* a2dp empty timeout cnt*/ 16843832a542SChing-Te Ku __le16 tavg; /* avg a2dp empty time */ 16853832a542SChing-Te Ku __le16 tmax; /* max a2dp empty time */ 16863832a542SChing-Te Ku } __packed; 16873832a542SChing-Te Ku 16883832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_leak_info { 16893832a542SChing-Te Ku __le32 cnt_rximr; /* the rximr occur at leak slot */ 16903832a542SChing-Te Ku __le16 tavg; /* avg leak-slot time */ 16913832a542SChing-Te Ku __le16 tmax; /* max leak-slot time */ 16923832a542SChing-Te Ku } __packed; 16933832a542SChing-Te Ku 16943832a542SChing-Te Ku struct rtw89_btc_fbtc_cysta_v1 { /* statistics for cycles */ 16953832a542SChing-Te Ku u8 fver; 16963832a542SChing-Te Ku u8 rsvd; 16973832a542SChing-Te Ku __le16 cycles; /* total cycle number */ 16983832a542SChing-Te Ku __le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; 16993832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_time_info cycle_time; 17003832a542SChing-Te Ku struct rtw89_btc_fbtc_fdd_try_info fdd_try; 17013832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept; 17023832a542SChing-Te Ku struct rtw89_btc_fbtc_a2dp_trx_stat a2dp_trx[BTC_CYCLE_SLOT_MAX]; 17033832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_leak_info leak_slot; 17043832a542SChing-Te Ku __le32 slot_cnt[CXST_MAX]; /* slot count */ 17053832a542SChing-Te Ku __le32 bcn_cnt[CXBCN_MAX]; 17063832a542SChing-Te Ku __le32 collision_cnt; /* counter for event/timer occur at the same time */ 17073832a542SChing-Te Ku __le32 skip_cnt; 17083832a542SChing-Te Ku __le32 except_cnt; 17093832a542SChing-Te Ku __le32 except_map; 17103832a542SChing-Te Ku } __packed; 17113832a542SChing-Te Ku 1712e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_cynullsta { /* cycle null statistics */ 1713ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxnullsta_ver */ 1714e3ec7017SPing-Ke Shih u8 rsvd; 1715e3ec7017SPing-Ke Shih __le16 rsvd2; 1716e3ec7017SPing-Ke Shih __le32 max_t[2]; /* max_t for 0:null0/1:null1 */ 1717e3ec7017SPing-Ke Shih __le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */ 1718e3ec7017SPing-Ke Shih __le32 result[2][4]; /* 0:fail, 1:ok, 2:on_time, 3:retry */ 1719e3ec7017SPing-Ke Shih } __packed; 1720e3ec7017SPing-Ke Shih 17211bb2d4f1SChing-Te Ku struct rtw89_btc_fbtc_cynullsta_v1 { /* cycle null statistics */ 17221bb2d4f1SChing-Te Ku u8 fver; /* chip_info::fcxnullsta_ver */ 17231bb2d4f1SChing-Te Ku u8 rsvd; 17241bb2d4f1SChing-Te Ku __le16 rsvd2; 17251bb2d4f1SChing-Te Ku __le32 max_t[2]; /* max_t for 0:null0/1:null1 */ 17261bb2d4f1SChing-Te Ku __le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */ 17271bb2d4f1SChing-Te Ku __le32 result[2][5]; /* 0:fail, 1:ok, 2:on_time, 3:retry, 4:tx */ 17281bb2d4f1SChing-Te Ku } __packed; 17291bb2d4f1SChing-Te Ku 1730e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btver { 1731ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxbtver_ver */ 1732e3ec7017SPing-Ke Shih u8 rsvd; 1733e3ec7017SPing-Ke Shih __le16 rsvd2; 1734e3ec7017SPing-Ke Shih __le32 coex_ver; /*bit[15:8]->shared, bit[7:0]->non-shared */ 1735e3ec7017SPing-Ke Shih __le32 fw_ver; 1736e3ec7017SPing-Ke Shih __le32 feature; 1737e3ec7017SPing-Ke Shih } __packed; 1738e3ec7017SPing-Ke Shih 1739e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btscan { 1740ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxbtscan_ver */ 1741e3ec7017SPing-Ke Shih u8 rsvd; 1742e3ec7017SPing-Ke Shih __le16 rsvd2; 1743e3ec7017SPing-Ke Shih u8 scan[6]; 1744e3ec7017SPing-Ke Shih } __packed; 1745e3ec7017SPing-Ke Shih 1746e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btafh { 1747ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxbtafh_ver */ 1748e3ec7017SPing-Ke Shih u8 rsvd; 1749e3ec7017SPing-Ke Shih __le16 rsvd2; 1750e3ec7017SPing-Ke Shih u8 afh_l[4]; /*bit0:2402, bit1: 2403.... bit31:2433 */ 1751e3ec7017SPing-Ke Shih u8 afh_m[4]; /*bit0:2434, bit1: 2435.... bit31:2465 */ 1752e3ec7017SPing-Ke Shih u8 afh_h[4]; /*bit0:2466, bit1:2467......bit14:2480 */ 1753e3ec7017SPing-Ke Shih } __packed; 1754e3ec7017SPing-Ke Shih 1755e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btdevinfo { 1756ba787c07SChing-Te Ku u8 fver; /* chip_info::fcxbtdevinfo_ver */ 1757e3ec7017SPing-Ke Shih u8 rsvd; 1758e3ec7017SPing-Ke Shih __le16 vendor_id; 1759e3ec7017SPing-Ke Shih __le32 dev_name; /* only 24 bits valid */ 1760e3ec7017SPing-Ke Shih __le32 flush_time; 1761e3ec7017SPing-Ke Shih } __packed; 1762e3ec7017SPing-Ke Shih 1763e3ec7017SPing-Ke Shih #define RTW89_BTC_WL_DEF_TX_PWR GENMASK(7, 0) 1764e3ec7017SPing-Ke Shih struct rtw89_btc_rf_trx_para { 1765e3ec7017SPing-Ke Shih u32 wl_tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */ 1766e3ec7017SPing-Ke Shih u32 wl_rx_gain; /* rx gain table index (TBD.) */ 1767e3ec7017SPing-Ke Shih u8 bt_tx_power; /* decrease Tx power (dB) */ 1768e3ec7017SPing-Ke Shih u8 bt_rx_gain; /* LNA constrain level */ 1769e3ec7017SPing-Ke Shih }; 1770e3ec7017SPing-Ke Shih 1771e3ec7017SPing-Ke Shih struct rtw89_btc_dm { 1772e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slot slot[CXST_MAX]; 1773e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slot slot_now[CXST_MAX]; 1774e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_tdma tdma; 1775e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_tdma tdma_now; 1776e3ec7017SPing-Ke Shih struct rtw89_mac_ax_coex_gnt gnt; 1777e3ec7017SPing-Ke Shih struct rtw89_btc_init_info init_info; /* pass to wl_fw if offload */ 1778e3ec7017SPing-Ke Shih struct rtw89_btc_rf_trx_para rf_trx_para; 1779e3ec7017SPing-Ke Shih struct rtw89_btc_wl_tx_limit_para wl_tx_limit; 1780e3ec7017SPing-Ke Shih struct rtw89_btc_dm_step dm_step; 1781747dc30eSChing-Te Ku struct rtw89_btc_wl_scc_ctrl wl_scc; 1782e3ec7017SPing-Ke Shih union rtw89_btc_dm_error_map error; 1783e3ec7017SPing-Ke Shih u32 cnt_dm[BTC_DCNT_NUM]; 1784e3ec7017SPing-Ke Shih u32 cnt_notify[BTC_NCNT_NUM]; 1785e3ec7017SPing-Ke Shih 1786e3ec7017SPing-Ke Shih u32 update_slot_map; 1787e3ec7017SPing-Ke Shih u32 set_ant_path; 1788e3ec7017SPing-Ke Shih 1789e3ec7017SPing-Ke Shih u32 wl_only: 1; 1790e3ec7017SPing-Ke Shih u32 wl_fw_cx_offload: 1; 1791e3ec7017SPing-Ke Shih u32 freerun: 1; 1792e3ec7017SPing-Ke Shih u32 wl_ps_ctrl: 2; 1793e3ec7017SPing-Ke Shih u32 wl_mimo_ps: 1; 1794e3ec7017SPing-Ke Shih u32 leak_ap: 1; 1795e3ec7017SPing-Ke Shih u32 noisy_level: 3; 1796e3ec7017SPing-Ke Shih u32 coex_info_map: 8; 1797e3ec7017SPing-Ke Shih u32 bt_only: 1; 1798e3ec7017SPing-Ke Shih u32 wl_btg_rx: 1; 1799e3ec7017SPing-Ke Shih u32 trx_para_level: 8; 1800e3ec7017SPing-Ke Shih u32 wl_stb_chg: 1; 1801ce986f3dSChing-Te Ku u32 tdma_instant_excute: 1; 1802ce986f3dSChing-Te Ku u32 rsvd: 2; 1803e3ec7017SPing-Ke Shih 1804e3ec7017SPing-Ke Shih u16 slot_dur[CXST_MAX]; 1805e3ec7017SPing-Ke Shih 1806e3ec7017SPing-Ke Shih u8 run_reason; 1807e3ec7017SPing-Ke Shih u8 run_action; 1808e3ec7017SPing-Ke Shih }; 1809e3ec7017SPing-Ke Shih 1810e3ec7017SPing-Ke Shih struct rtw89_btc_ctrl { 1811e3ec7017SPing-Ke Shih u32 manual: 1; 1812e3ec7017SPing-Ke Shih u32 igno_bt: 1; 1813e3ec7017SPing-Ke Shih u32 always_freerun: 1; 1814e3ec7017SPing-Ke Shih u32 trace_step: 16; 1815e3ec7017SPing-Ke Shih u32 rsvd: 12; 1816e3ec7017SPing-Ke Shih }; 1817e3ec7017SPing-Ke Shih 1818e3ec7017SPing-Ke Shih struct rtw89_btc_dbg { 1819e3ec7017SPing-Ke Shih /* cmd "rb" */ 1820e3ec7017SPing-Ke Shih bool rb_done; 1821e3ec7017SPing-Ke Shih u32 rb_val; 1822e3ec7017SPing-Ke Shih }; 1823e3ec7017SPing-Ke Shih 1824e3ec7017SPing-Ke Shih enum rtw89_btc_btf_fw_event { 1825e3ec7017SPing-Ke Shih BTF_EVNT_RPT = 0, 1826e3ec7017SPing-Ke Shih BTF_EVNT_BT_INFO = 1, 1827e3ec7017SPing-Ke Shih BTF_EVNT_BT_SCBD = 2, 1828e3ec7017SPing-Ke Shih BTF_EVNT_BT_REG = 3, 1829e3ec7017SPing-Ke Shih BTF_EVNT_CX_RUNINFO = 4, 1830e3ec7017SPing-Ke Shih BTF_EVNT_BT_PSD = 5, 1831e3ec7017SPing-Ke Shih BTF_EVNT_BUF_OVERFLOW, 1832e3ec7017SPing-Ke Shih BTF_EVNT_C2H_LOOPBACK, 1833e3ec7017SPing-Ke Shih BTF_EVNT_MAX, 1834e3ec7017SPing-Ke Shih }; 1835e3ec7017SPing-Ke Shih 1836e3ec7017SPing-Ke Shih enum btf_fw_event_report { 1837e3ec7017SPing-Ke Shih BTC_RPT_TYPE_CTRL = 0x0, 1838e3ec7017SPing-Ke Shih BTC_RPT_TYPE_TDMA, 1839e3ec7017SPing-Ke Shih BTC_RPT_TYPE_SLOT, 1840e3ec7017SPing-Ke Shih BTC_RPT_TYPE_CYSTA, 1841e3ec7017SPing-Ke Shih BTC_RPT_TYPE_STEP, 1842e3ec7017SPing-Ke Shih BTC_RPT_TYPE_NULLSTA, 1843e3ec7017SPing-Ke Shih BTC_RPT_TYPE_MREG, 1844e3ec7017SPing-Ke Shih BTC_RPT_TYPE_GPIO_DBG, 1845e3ec7017SPing-Ke Shih BTC_RPT_TYPE_BT_VER, 1846e3ec7017SPing-Ke Shih BTC_RPT_TYPE_BT_SCAN, 1847e3ec7017SPing-Ke Shih BTC_RPT_TYPE_BT_AFH, 1848e3ec7017SPing-Ke Shih BTC_RPT_TYPE_BT_DEVICE, 1849e3ec7017SPing-Ke Shih BTC_RPT_TYPE_TEST, 1850e3ec7017SPing-Ke Shih BTC_RPT_TYPE_MAX = 31 1851e3ec7017SPing-Ke Shih }; 1852e3ec7017SPing-Ke Shih 1853e3ec7017SPing-Ke Shih enum rtw_btc_btf_reg_type { 1854e3ec7017SPing-Ke Shih REG_MAC = 0x0, 1855e3ec7017SPing-Ke Shih REG_BB = 0x1, 1856e3ec7017SPing-Ke Shih REG_RF = 0x2, 1857e3ec7017SPing-Ke Shih REG_BT_RF = 0x3, 1858e3ec7017SPing-Ke Shih REG_BT_MODEM = 0x4, 1859e3ec7017SPing-Ke Shih REG_BT_BLUEWIZE = 0x5, 1860e3ec7017SPing-Ke Shih REG_BT_VENDOR = 0x6, 1861e3ec7017SPing-Ke Shih REG_BT_LE = 0x7, 1862e3ec7017SPing-Ke Shih REG_MAX_TYPE, 1863e3ec7017SPing-Ke Shih }; 1864e3ec7017SPing-Ke Shih 1865e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info { 1866e3ec7017SPing-Ke Shih u32 rx_cnt; 1867e3ec7017SPing-Ke Shih u32 rx_len; 1868e3ec7017SPing-Ke Shih u32 req_len; /* expected rsp len */ 1869e3ec7017SPing-Ke Shih u8 req_fver; /* expected rsp fver */ 1870e3ec7017SPing-Ke Shih u8 rsp_fver; /* fver from fw */ 1871e3ec7017SPing-Ke Shih u8 valid; 1872e3ec7017SPing-Ke Shih } __packed; 1873e3ec7017SPing-Ke Shih 1874e3ec7017SPing-Ke Shih struct rtw89_btc_report_ctrl_state { 1875e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 18761162584cSChing-Te Ku union { 18771162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl finfo; /* info from fw for 52A*/ 18781162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_v1 finfo_v1; /* info from fw for 52C*/ 18791162584cSChing-Te Ku }; 1880e3ec7017SPing-Ke Shih }; 1881e3ec7017SPing-Ke Shih 1882e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_tdma { 1883e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1884ce986f3dSChing-Te Ku union { 1885e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_tdma finfo; /* info from fw */ 1886ce986f3dSChing-Te Ku struct rtw89_btc_fbtc_tdma_v1 finfo_v1; /* info from fw for 52C*/ 1887ce986f3dSChing-Te Ku }; 1888e3ec7017SPing-Ke Shih }; 1889e3ec7017SPing-Ke Shih 1890e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_slots { 1891e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1892e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slots finfo; /* info from fw */ 1893e3ec7017SPing-Ke Shih }; 1894e3ec7017SPing-Ke Shih 1895e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_cysta { 1896e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 18973832a542SChing-Te Ku union { 18983832a542SChing-Te Ku struct rtw89_btc_fbtc_cysta finfo; /* info from fw for 52A*/ 18993832a542SChing-Te Ku struct rtw89_btc_fbtc_cysta_v1 finfo_v1; /* info from fw for 52C*/ 19003832a542SChing-Te Ku }; 1901e3ec7017SPing-Ke Shih }; 1902e3ec7017SPing-Ke Shih 1903e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_step { 1904e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1905e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_steps finfo; /* info from fw */ 1906e3ec7017SPing-Ke Shih }; 1907e3ec7017SPing-Ke Shih 1908e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_nullsta { 1909e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 19101bb2d4f1SChing-Te Ku union { 1911e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_cynullsta finfo; /* info from fw */ 19121bb2d4f1SChing-Te Ku struct rtw89_btc_fbtc_cynullsta_v1 finfo_v1; /* info from fw */ 19131bb2d4f1SChing-Te Ku }; 1914e3ec7017SPing-Ke Shih }; 1915e3ec7017SPing-Ke Shih 1916e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_mreg { 1917e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1918e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_mreg_val finfo; /* info from fw */ 1919e3ec7017SPing-Ke Shih }; 1920e3ec7017SPing-Ke Shih 1921e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_gpio_dbg { 1922e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1923e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_gpio_dbg finfo; /* info from fw */ 1924e3ec7017SPing-Ke Shih }; 1925e3ec7017SPing-Ke Shih 1926e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btver { 1927e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1928e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btver finfo; /* info from fw */ 1929e3ec7017SPing-Ke Shih }; 1930e3ec7017SPing-Ke Shih 1931e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btscan { 1932e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1933e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btscan finfo; /* info from fw */ 1934e3ec7017SPing-Ke Shih }; 1935e3ec7017SPing-Ke Shih 1936e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btafh { 1937e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1938e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btafh finfo; /* info from fw */ 1939e3ec7017SPing-Ke Shih }; 1940e3ec7017SPing-Ke Shih 1941e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btdev { 1942e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */ 1943e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btdevinfo finfo; /* info from fw */ 1944e3ec7017SPing-Ke Shih }; 1945e3ec7017SPing-Ke Shih 1946e3ec7017SPing-Ke Shih enum rtw89_btc_btfre_type { 1947e3ec7017SPing-Ke Shih BTFRE_INVALID_INPUT = 0x0, /* invalid input parameters */ 1948e3ec7017SPing-Ke Shih BTFRE_UNDEF_TYPE, 1949e3ec7017SPing-Ke Shih BTFRE_EXCEPTION, 1950e3ec7017SPing-Ke Shih BTFRE_MAX, 1951e3ec7017SPing-Ke Shih }; 1952e3ec7017SPing-Ke Shih 1953e3ec7017SPing-Ke Shih struct rtw89_btc_btf_fwinfo { 1954e3ec7017SPing-Ke Shih u32 cnt_c2h; 1955e3ec7017SPing-Ke Shih u32 cnt_h2c; 1956e3ec7017SPing-Ke Shih u32 cnt_h2c_fail; 1957e3ec7017SPing-Ke Shih u32 event[BTF_EVNT_MAX]; 1958e3ec7017SPing-Ke Shih 1959e3ec7017SPing-Ke Shih u32 err[BTFRE_MAX]; 1960e3ec7017SPing-Ke Shih u32 len_mismch; 1961e3ec7017SPing-Ke Shih u32 fver_mismch; 1962e3ec7017SPing-Ke Shih u32 rpt_en_map; 1963e3ec7017SPing-Ke Shih 1964e3ec7017SPing-Ke Shih struct rtw89_btc_report_ctrl_state rpt_ctrl; 1965e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_tdma rpt_fbtc_tdma; 1966e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_slots rpt_fbtc_slots; 1967e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_cysta rpt_fbtc_cysta; 1968e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_step rpt_fbtc_step; 1969e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_nullsta rpt_fbtc_nullsta; 1970e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_mreg rpt_fbtc_mregval; 1971e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_gpio_dbg rpt_fbtc_gpio_dbg; 1972e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btver rpt_fbtc_btver; 1973e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btscan rpt_fbtc_btscan; 1974e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btafh rpt_fbtc_btafh; 1975e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btdev rpt_fbtc_btdev; 1976e3ec7017SPing-Ke Shih }; 1977e3ec7017SPing-Ke Shih 1978e3ec7017SPing-Ke Shih #define RTW89_BTC_POLICY_MAXLEN 512 1979e3ec7017SPing-Ke Shih 1980e3ec7017SPing-Ke Shih struct rtw89_btc { 1981e3ec7017SPing-Ke Shih struct rtw89_btc_cx cx; 1982e3ec7017SPing-Ke Shih struct rtw89_btc_dm dm; 1983e3ec7017SPing-Ke Shih struct rtw89_btc_ctrl ctrl; 1984e3ec7017SPing-Ke Shih struct rtw89_btc_module mdinfo; 1985e3ec7017SPing-Ke Shih struct rtw89_btc_btf_fwinfo fwinfo; 1986e3ec7017SPing-Ke Shih struct rtw89_btc_dbg dbg; 1987e3ec7017SPing-Ke Shih 1988e3ec7017SPing-Ke Shih struct work_struct eapol_notify_work; 1989e3ec7017SPing-Ke Shih struct work_struct arp_notify_work; 1990e3ec7017SPing-Ke Shih struct work_struct dhcp_notify_work; 1991e3ec7017SPing-Ke Shih struct work_struct icmp_notify_work; 1992e3ec7017SPing-Ke Shih 1993e3ec7017SPing-Ke Shih u32 bt_req_len; 1994e3ec7017SPing-Ke Shih 1995e3ec7017SPing-Ke Shih u8 policy[RTW89_BTC_POLICY_MAXLEN]; 1996e3ec7017SPing-Ke Shih u16 policy_len; 1997e3ec7017SPing-Ke Shih u16 policy_type; 1998e3ec7017SPing-Ke Shih bool bt_req_en; 1999e3ec7017SPing-Ke Shih bool update_policy_force; 2000e3ec7017SPing-Ke Shih bool lps; 2001e3ec7017SPing-Ke Shih }; 2002e3ec7017SPing-Ke Shih 2003e3ec7017SPing-Ke Shih enum rtw89_ra_mode { 2004e3ec7017SPing-Ke Shih RTW89_RA_MODE_CCK = BIT(0), 2005e3ec7017SPing-Ke Shih RTW89_RA_MODE_OFDM = BIT(1), 2006e3ec7017SPing-Ke Shih RTW89_RA_MODE_HT = BIT(2), 2007e3ec7017SPing-Ke Shih RTW89_RA_MODE_VHT = BIT(3), 2008e3ec7017SPing-Ke Shih RTW89_RA_MODE_HE = BIT(4), 2009e3ec7017SPing-Ke Shih }; 2010e3ec7017SPing-Ke Shih 2011e3ec7017SPing-Ke Shih enum rtw89_ra_report_mode { 2012e3ec7017SPing-Ke Shih RTW89_RA_RPT_MODE_LEGACY, 2013e3ec7017SPing-Ke Shih RTW89_RA_RPT_MODE_HT, 2014e3ec7017SPing-Ke Shih RTW89_RA_RPT_MODE_VHT, 2015e3ec7017SPing-Ke Shih RTW89_RA_RPT_MODE_HE, 2016e3ec7017SPing-Ke Shih }; 2017e3ec7017SPing-Ke Shih 2018e3ec7017SPing-Ke Shih enum rtw89_dig_noisy_level { 2019e3ec7017SPing-Ke Shih RTW89_DIG_NOISY_LEVEL0 = -1, 2020e3ec7017SPing-Ke Shih RTW89_DIG_NOISY_LEVEL1 = 0, 2021e3ec7017SPing-Ke Shih RTW89_DIG_NOISY_LEVEL2 = 1, 2022e3ec7017SPing-Ke Shih RTW89_DIG_NOISY_LEVEL3 = 2, 2023e3ec7017SPing-Ke Shih RTW89_DIG_NOISY_LEVEL_MAX = 3, 2024e3ec7017SPing-Ke Shih }; 2025e3ec7017SPing-Ke Shih 2026e3ec7017SPing-Ke Shih enum rtw89_gi_ltf { 2027e3ec7017SPing-Ke Shih RTW89_GILTF_LGI_4XHE32 = 0, 2028e3ec7017SPing-Ke Shih RTW89_GILTF_SGI_4XHE08 = 1, 2029e3ec7017SPing-Ke Shih RTW89_GILTF_2XHE16 = 2, 2030e3ec7017SPing-Ke Shih RTW89_GILTF_2XHE08 = 3, 2031e3ec7017SPing-Ke Shih RTW89_GILTF_1XHE16 = 4, 2032e3ec7017SPing-Ke Shih RTW89_GILTF_1XHE08 = 5, 2033e3ec7017SPing-Ke Shih RTW89_GILTF_MAX 2034e3ec7017SPing-Ke Shih }; 2035e3ec7017SPing-Ke Shih 2036e3ec7017SPing-Ke Shih enum rtw89_rx_frame_type { 2037e3ec7017SPing-Ke Shih RTW89_RX_TYPE_MGNT = 0, 2038e3ec7017SPing-Ke Shih RTW89_RX_TYPE_CTRL = 1, 2039e3ec7017SPing-Ke Shih RTW89_RX_TYPE_DATA = 2, 2040e3ec7017SPing-Ke Shih RTW89_RX_TYPE_RSVD = 3, 2041e3ec7017SPing-Ke Shih }; 2042e3ec7017SPing-Ke Shih 2043e3ec7017SPing-Ke Shih struct rtw89_ra_info { 2044e3ec7017SPing-Ke Shih u8 is_dis_ra:1; 2045e3ec7017SPing-Ke Shih /* Bit0 : CCK 2046e3ec7017SPing-Ke Shih * Bit1 : OFDM 2047e3ec7017SPing-Ke Shih * Bit2 : HT 2048e3ec7017SPing-Ke Shih * Bit3 : VHT 2049e3ec7017SPing-Ke Shih * Bit4 : HE 2050e3ec7017SPing-Ke Shih */ 2051e3ec7017SPing-Ke Shih u8 mode_ctrl:5; 2052e3ec7017SPing-Ke Shih u8 bw_cap:2; 2053e3ec7017SPing-Ke Shih u8 macid; 2054e3ec7017SPing-Ke Shih u8 dcm_cap:1; 2055e3ec7017SPing-Ke Shih u8 er_cap:1; 2056e3ec7017SPing-Ke Shih u8 init_rate_lv:2; 2057e3ec7017SPing-Ke Shih u8 upd_all:1; 2058e3ec7017SPing-Ke Shih u8 en_sgi:1; 2059e3ec7017SPing-Ke Shih u8 ldpc_cap:1; 2060e3ec7017SPing-Ke Shih u8 stbc_cap:1; 2061e3ec7017SPing-Ke Shih u8 ss_num:3; 2062e3ec7017SPing-Ke Shih u8 giltf:3; 2063e3ec7017SPing-Ke Shih u8 upd_bw_nss_mask:1; 2064e3ec7017SPing-Ke Shih u8 upd_mask:1; 2065e3ec7017SPing-Ke Shih u64 ra_mask; /* 63 bits ra_mask + 1 bit CSI ctrl */ 2066e3ec7017SPing-Ke Shih /* BFee CSI */ 2067e3ec7017SPing-Ke Shih u8 band_num; 2068e3ec7017SPing-Ke Shih u8 ra_csi_rate_en:1; 2069e3ec7017SPing-Ke Shih u8 fixed_csi_rate_en:1; 2070e3ec7017SPing-Ke Shih u8 cr_tbl_sel:1; 2071e3ec7017SPing-Ke Shih u8 rsvd2:5; 2072e3ec7017SPing-Ke Shih u8 csi_mcs_ss_idx; 2073e3ec7017SPing-Ke Shih u8 csi_mode:2; 2074e3ec7017SPing-Ke Shih u8 csi_gi_ltf:3; 2075e3ec7017SPing-Ke Shih u8 csi_bw:3; 2076e3ec7017SPing-Ke Shih }; 2077e3ec7017SPing-Ke Shih 2078e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAX_USR 4 2079e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_INFO_USR_SIZE 4 2080e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_INFO_SIZE 8 2081e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_RX_CNT_SIZE 96 2082e3ec7017SPing-Ke Shih 2083e3ec7017SPing-Ke Shih #define RTW89_MAX_RX_AGG_NUM 64 2084e3ec7017SPing-Ke Shih #define RTW89_MAX_TX_AGG_NUM 128 2085e3ec7017SPing-Ke Shih 2086e3ec7017SPing-Ke Shih struct rtw89_ampdu_params { 2087e3ec7017SPing-Ke Shih u16 agg_num; 2088e3ec7017SPing-Ke Shih bool amsdu; 2089e3ec7017SPing-Ke Shih }; 2090e3ec7017SPing-Ke Shih 2091e3ec7017SPing-Ke Shih struct rtw89_ra_report { 2092e3ec7017SPing-Ke Shih struct rate_info txrate; 2093e3ec7017SPing-Ke Shih u32 bit_rate; 2094e3ec7017SPing-Ke Shih u16 hw_rate; 20950d466f05SPing-Ke Shih bool might_fallback_legacy; 2096e3ec7017SPing-Ke Shih }; 2097e3ec7017SPing-Ke Shih 2098e3ec7017SPing-Ke Shih DECLARE_EWMA(rssi, 10, 16); 2099e3ec7017SPing-Ke Shih 21003ffbb5a8SPing-Ke Shih struct rtw89_ba_cam_entry { 210108aa8077SPing-Ke Shih struct list_head list; 21023ffbb5a8SPing-Ke Shih u8 tid; 21033ffbb5a8SPing-Ke Shih }; 21043ffbb5a8SPing-Ke Shih 2105e3ec7017SPing-Ke Shih #define RTW89_MAX_ADDR_CAM_NUM 128 2106e3ec7017SPing-Ke Shih #define RTW89_MAX_BSSID_CAM_NUM 20 2107e3ec7017SPing-Ke Shih #define RTW89_MAX_SEC_CAM_NUM 128 21082def7356SPing-Ke Shih #define RTW89_MAX_BA_CAM_NUM 8 2109e3ec7017SPing-Ke Shih #define RTW89_SEC_CAM_IN_ADDR_CAM 7 2110e3ec7017SPing-Ke Shih 2111e3ec7017SPing-Ke Shih struct rtw89_addr_cam_entry { 2112e3ec7017SPing-Ke Shih u8 addr_cam_idx; 2113e3ec7017SPing-Ke Shih u8 offset; 2114e3ec7017SPing-Ke Shih u8 len; 2115e3ec7017SPing-Ke Shih u8 valid : 1; 2116e3ec7017SPing-Ke Shih u8 addr_mask : 6; 2117e3ec7017SPing-Ke Shih u8 wapi : 1; 2118e3ec7017SPing-Ke Shih u8 mask_sel : 2; 2119e3ec7017SPing-Ke Shih u8 bssid_cam_idx: 6; 2120e3ec7017SPing-Ke Shih 2121e3ec7017SPing-Ke Shih u8 sec_ent_mode; 2122e3ec7017SPing-Ke Shih DECLARE_BITMAP(sec_cam_map, RTW89_SEC_CAM_IN_ADDR_CAM); 2123e3ec7017SPing-Ke Shih u8 sec_ent_keyid[RTW89_SEC_CAM_IN_ADDR_CAM]; 2124e3ec7017SPing-Ke Shih u8 sec_ent[RTW89_SEC_CAM_IN_ADDR_CAM]; 2125e3ec7017SPing-Ke Shih struct rtw89_sec_cam_entry *sec_entries[RTW89_SEC_CAM_IN_ADDR_CAM]; 2126e3ec7017SPing-Ke Shih }; 2127e3ec7017SPing-Ke Shih 2128e3ec7017SPing-Ke Shih struct rtw89_bssid_cam_entry { 2129e3ec7017SPing-Ke Shih u8 bssid[ETH_ALEN]; 2130e3ec7017SPing-Ke Shih u8 phy_idx; 2131e3ec7017SPing-Ke Shih u8 bssid_cam_idx; 2132e3ec7017SPing-Ke Shih u8 offset; 2133e3ec7017SPing-Ke Shih u8 len; 2134e3ec7017SPing-Ke Shih u8 valid : 1; 2135e3ec7017SPing-Ke Shih u8 num; 2136e3ec7017SPing-Ke Shih }; 2137e3ec7017SPing-Ke Shih 2138e3ec7017SPing-Ke Shih struct rtw89_sec_cam_entry { 2139e3ec7017SPing-Ke Shih u8 sec_cam_idx; 2140e3ec7017SPing-Ke Shih u8 offset; 2141e3ec7017SPing-Ke Shih u8 len; 2142e3ec7017SPing-Ke Shih u8 type : 4; 2143e3ec7017SPing-Ke Shih u8 ext_key : 1; 2144e3ec7017SPing-Ke Shih u8 spp_mode : 1; 2145e3ec7017SPing-Ke Shih /* 256 bits */ 2146e3ec7017SPing-Ke Shih u8 key[32]; 2147e3ec7017SPing-Ke Shih }; 2148e3ec7017SPing-Ke Shih 21492ab856ccSPing-Ke Shih struct rtw89_sta { 21502ab856ccSPing-Ke Shih u8 mac_id; 21512ab856ccSPing-Ke Shih bool disassoc; 21526ce472d6SPing-Ke Shih struct rtw89_dev *rtwdev; 21532ab856ccSPing-Ke Shih struct rtw89_vif *rtwvif; 21542ab856ccSPing-Ke Shih struct rtw89_ra_info ra; 21552ab856ccSPing-Ke Shih struct rtw89_ra_report ra_report; 21562ab856ccSPing-Ke Shih int max_agg_wait; 21572ab856ccSPing-Ke Shih u8 prev_rssi; 21582ab856ccSPing-Ke Shih struct ewma_rssi avg_rssi; 21596ce472d6SPing-Ke Shih struct ewma_rssi rssi[RF_PATH_MAX]; 21602ab856ccSPing-Ke Shih struct rtw89_ampdu_params ampdu_params[IEEE80211_NUM_TIDS]; 21612ab856ccSPing-Ke Shih struct ieee80211_rx_status rx_status; 21622ab856ccSPing-Ke Shih u16 rx_hw_rate; 21632ab856ccSPing-Ke Shih __le32 htc_template; 21647312100dSPing-Ke Shih struct rtw89_addr_cam_entry addr_cam; /* AP mode or TDLS peer only */ 216539913cc8SPing-Ke Shih struct rtw89_bssid_cam_entry bssid_cam; /* TDLS peer only */ 216608aa8077SPing-Ke Shih struct list_head ba_cam_list; 21672ab856ccSPing-Ke Shih 21682ab856ccSPing-Ke Shih bool use_cfg_mask; 21692ab856ccSPing-Ke Shih struct cfg80211_bitrate_mask mask; 21702ab856ccSPing-Ke Shih 21712ab856ccSPing-Ke Shih bool cctl_tx_time; 21722ab856ccSPing-Ke Shih u32 ampdu_max_time:4; 21732ab856ccSPing-Ke Shih bool cctl_tx_retry_limit; 21742ab856ccSPing-Ke Shih u32 data_tx_cnt_lmt:6; 21752ab856ccSPing-Ke Shih }; 21762ab856ccSPing-Ke Shih 2177e3ec7017SPing-Ke Shih struct rtw89_efuse { 2178e3ec7017SPing-Ke Shih bool valid; 2179e3ec7017SPing-Ke Shih u8 xtal_cap; 2180e3ec7017SPing-Ke Shih u8 addr[ETH_ALEN]; 2181e3ec7017SPing-Ke Shih u8 rfe_type; 2182e3ec7017SPing-Ke Shih char country_code[2]; 2183e3ec7017SPing-Ke Shih }; 2184e3ec7017SPing-Ke Shih 2185e3ec7017SPing-Ke Shih struct rtw89_phy_rate_pattern { 2186e3ec7017SPing-Ke Shih u64 ra_mask; 2187e3ec7017SPing-Ke Shih u16 rate; 2188e3ec7017SPing-Ke Shih u8 ra_mode; 2189e3ec7017SPing-Ke Shih bool enable; 2190e3ec7017SPing-Ke Shih }; 2191e3ec7017SPing-Ke Shih 2192e3ec7017SPing-Ke Shih struct rtw89_vif { 2193e3ec7017SPing-Ke Shih struct list_head list; 2194d62816b4SPing-Ke Shih struct rtw89_dev *rtwdev; 2195e3ec7017SPing-Ke Shih u8 mac_id; 2196e3ec7017SPing-Ke Shih u8 port; 2197e3ec7017SPing-Ke Shih u8 mac_addr[ETH_ALEN]; 2198e3ec7017SPing-Ke Shih u8 bssid[ETH_ALEN]; 2199e3ec7017SPing-Ke Shih u8 phy_idx; 2200e3ec7017SPing-Ke Shih u8 mac_idx; 2201e3ec7017SPing-Ke Shih u8 net_type; 2202e3ec7017SPing-Ke Shih u8 wifi_role; 2203e3ec7017SPing-Ke Shih u8 self_role; 2204e3ec7017SPing-Ke Shih u8 wmm; 2205e3ec7017SPing-Ke Shih u8 bcn_hit_cond; 2206e3ec7017SPing-Ke Shih u8 hit_rule; 2207e3ec7017SPing-Ke Shih bool trigger; 2208e3ec7017SPing-Ke Shih bool lsig_txop; 2209e3ec7017SPing-Ke Shih u8 tgt_ind; 2210e3ec7017SPing-Ke Shih u8 frm_tgt_ind; 2211e3ec7017SPing-Ke Shih bool wowlan_pattern; 2212e3ec7017SPing-Ke Shih bool wowlan_uc; 2213e3ec7017SPing-Ke Shih bool wowlan_magic; 2214e3ec7017SPing-Ke Shih bool is_hesta; 2215e3ec7017SPing-Ke Shih bool last_a_ctrl; 2216d62816b4SPing-Ke Shih struct work_struct update_beacon_work; 2217e3ec7017SPing-Ke Shih struct rtw89_addr_cam_entry addr_cam; 2218e3ec7017SPing-Ke Shih struct rtw89_bssid_cam_entry bssid_cam; 2219e3ec7017SPing-Ke Shih struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS]; 2220e3ec7017SPing-Ke Shih struct rtw89_traffic_stats stats; 2221e3ec7017SPing-Ke Shih struct rtw89_phy_rate_pattern rate_pattern; 222289590777SPo Hao Huang struct cfg80211_scan_request *scan_req; 222389590777SPo Hao Huang struct ieee80211_scan_ies *scan_ies; 2224e3ec7017SPing-Ke Shih }; 2225e3ec7017SPing-Ke Shih 2226e3ec7017SPing-Ke Shih enum rtw89_lv1_rcvy_step { 2227e3ec7017SPing-Ke Shih RTW89_LV1_RCVY_STEP_1, 2228e3ec7017SPing-Ke Shih RTW89_LV1_RCVY_STEP_2, 2229e3ec7017SPing-Ke Shih }; 2230e3ec7017SPing-Ke Shih 2231e3ec7017SPing-Ke Shih struct rtw89_hci_ops { 2232e3ec7017SPing-Ke Shih int (*tx_write)(struct rtw89_dev *rtwdev, struct rtw89_core_tx_request *tx_req); 2233e3ec7017SPing-Ke Shih void (*tx_kick_off)(struct rtw89_dev *rtwdev, u8 txch); 2234e3ec7017SPing-Ke Shih void (*flush_queues)(struct rtw89_dev *rtwdev, u32 queues, bool drop); 2235e3ec7017SPing-Ke Shih void (*reset)(struct rtw89_dev *rtwdev); 2236e3ec7017SPing-Ke Shih int (*start)(struct rtw89_dev *rtwdev); 2237e3ec7017SPing-Ke Shih void (*stop)(struct rtw89_dev *rtwdev); 223852edbb9fSPing-Ke Shih void (*pause)(struct rtw89_dev *rtwdev, bool pause); 223952edbb9fSPing-Ke Shih void (*switch_mode)(struct rtw89_dev *rtwdev, bool low_power); 2240e3ec7017SPing-Ke Shih void (*recalc_int_mit)(struct rtw89_dev *rtwdev); 2241e3ec7017SPing-Ke Shih 2242e3ec7017SPing-Ke Shih u8 (*read8)(struct rtw89_dev *rtwdev, u32 addr); 2243e3ec7017SPing-Ke Shih u16 (*read16)(struct rtw89_dev *rtwdev, u32 addr); 2244e3ec7017SPing-Ke Shih u32 (*read32)(struct rtw89_dev *rtwdev, u32 addr); 2245e3ec7017SPing-Ke Shih void (*write8)(struct rtw89_dev *rtwdev, u32 addr, u8 data); 2246e3ec7017SPing-Ke Shih void (*write16)(struct rtw89_dev *rtwdev, u32 addr, u16 data); 2247e3ec7017SPing-Ke Shih void (*write32)(struct rtw89_dev *rtwdev, u32 addr, u32 data); 2248e3ec7017SPing-Ke Shih 2249e3ec7017SPing-Ke Shih int (*mac_pre_init)(struct rtw89_dev *rtwdev); 2250e3ec7017SPing-Ke Shih int (*mac_post_init)(struct rtw89_dev *rtwdev); 2251e3ec7017SPing-Ke Shih int (*deinit)(struct rtw89_dev *rtwdev); 2252e3ec7017SPing-Ke Shih 2253e3ec7017SPing-Ke Shih u32 (*check_and_reclaim_tx_resource)(struct rtw89_dev *rtwdev, u8 txch); 2254e3ec7017SPing-Ke Shih int (*mac_lv1_rcvy)(struct rtw89_dev *rtwdev, enum rtw89_lv1_rcvy_step step); 2255e3ec7017SPing-Ke Shih void (*dump_err_status)(struct rtw89_dev *rtwdev); 2256e3ec7017SPing-Ke Shih int (*napi_poll)(struct napi_struct *napi, int budget); 225714f9f479SZong-Zhe Yang 225814f9f479SZong-Zhe Yang /* Deal with locks inside recovery_start and recovery_complete callbacks 225914f9f479SZong-Zhe Yang * by hci instance, and handle things which need to consider under SER. 226014f9f479SZong-Zhe Yang * e.g. turn on/off interrupts except for the one for halt notification. 226114f9f479SZong-Zhe Yang */ 226214f9f479SZong-Zhe Yang void (*recovery_start)(struct rtw89_dev *rtwdev); 226314f9f479SZong-Zhe Yang void (*recovery_complete)(struct rtw89_dev *rtwdev); 2264e3ec7017SPing-Ke Shih }; 2265e3ec7017SPing-Ke Shih 2266e3ec7017SPing-Ke Shih struct rtw89_hci_info { 2267e3ec7017SPing-Ke Shih const struct rtw89_hci_ops *ops; 2268e3ec7017SPing-Ke Shih enum rtw89_hci_type type; 2269e3ec7017SPing-Ke Shih u32 rpwm_addr; 2270e3ec7017SPing-Ke Shih u32 cpwm_addr; 227152edbb9fSPing-Ke Shih bool paused; 2272e3ec7017SPing-Ke Shih }; 2273e3ec7017SPing-Ke Shih 2274e3ec7017SPing-Ke Shih struct rtw89_chip_ops { 227561ebeecbSPing-Ke Shih int (*enable_bb_rf)(struct rtw89_dev *rtwdev); 227661ebeecbSPing-Ke Shih void (*disable_bb_rf)(struct rtw89_dev *rtwdev); 2277e3ec7017SPing-Ke Shih void (*bb_reset)(struct rtw89_dev *rtwdev, 2278e3ec7017SPing-Ke Shih enum rtw89_phy_idx phy_idx); 2279e3ec7017SPing-Ke Shih void (*bb_sethw)(struct rtw89_dev *rtwdev); 2280e3ec7017SPing-Ke Shih u32 (*read_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path, 2281e3ec7017SPing-Ke Shih u32 addr, u32 mask); 2282e3ec7017SPing-Ke Shih bool (*write_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path, 2283e3ec7017SPing-Ke Shih u32 addr, u32 mask, u32 data); 2284e3ec7017SPing-Ke Shih void (*set_channel)(struct rtw89_dev *rtwdev, 2285ce57e55cSZong-Zhe Yang const struct rtw89_chan *chan, 2286ce57e55cSZong-Zhe Yang enum rtw89_mac_idx mac_idx, 2287ce57e55cSZong-Zhe Yang enum rtw89_phy_idx phy_idx); 2288e3ec7017SPing-Ke Shih void (*set_channel_help)(struct rtw89_dev *rtwdev, bool enter, 2289ce57e55cSZong-Zhe Yang struct rtw89_channel_help_params *p, 2290ce57e55cSZong-Zhe Yang const struct rtw89_chan *chan, 2291ce57e55cSZong-Zhe Yang enum rtw89_mac_idx mac_idx, 2292ce57e55cSZong-Zhe Yang enum rtw89_phy_idx phy_idx); 2293e3ec7017SPing-Ke Shih int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map); 2294e3ec7017SPing-Ke Shih int (*read_phycap)(struct rtw89_dev *rtwdev, u8 *phycap_map); 2295e3ec7017SPing-Ke Shih void (*fem_setup)(struct rtw89_dev *rtwdev); 2296e3ec7017SPing-Ke Shih void (*rfk_init)(struct rtw89_dev *rtwdev); 2297e3ec7017SPing-Ke Shih void (*rfk_channel)(struct rtw89_dev *rtwdev); 2298010d0051SZong-Zhe Yang void (*rfk_band_changed)(struct rtw89_dev *rtwdev, 2299010d0051SZong-Zhe Yang enum rtw89_phy_idx phy_idx); 2300e3ec7017SPing-Ke Shih void (*rfk_scan)(struct rtw89_dev *rtwdev, bool start); 2301e3ec7017SPing-Ke Shih void (*rfk_track)(struct rtw89_dev *rtwdev); 2302e3ec7017SPing-Ke Shih void (*power_trim)(struct rtw89_dev *rtwdev); 230307ef5f2fSZong-Zhe Yang void (*set_txpwr)(struct rtw89_dev *rtwdev, 230407ef5f2fSZong-Zhe Yang const struct rtw89_chan *chan, 230507ef5f2fSZong-Zhe Yang enum rtw89_phy_idx phy_idx); 230607ef5f2fSZong-Zhe Yang void (*set_txpwr_ctrl)(struct rtw89_dev *rtwdev, 230707ef5f2fSZong-Zhe Yang enum rtw89_phy_idx phy_idx); 2308e3ec7017SPing-Ke Shih int (*init_txpwr_unit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx); 2309e3ec7017SPing-Ke Shih u8 (*get_thermal)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path); 2310e3ec7017SPing-Ke Shih void (*ctrl_btg)(struct rtw89_dev *rtwdev, bool btg); 2311e3ec7017SPing-Ke Shih void (*query_ppdu)(struct rtw89_dev *rtwdev, 2312e3ec7017SPing-Ke Shih struct rtw89_rx_phy_ppdu *phy_ppdu, 2313e3ec7017SPing-Ke Shih struct ieee80211_rx_status *status); 2314e3ec7017SPing-Ke Shih void (*bb_ctrl_btc_preagc)(struct rtw89_dev *rtwdev, bool bt_en); 2315cd89a471SPing-Ke Shih void (*cfg_txrx_path)(struct rtw89_dev *rtwdev); 2316e3ec7017SPing-Ke Shih void (*set_txpwr_ul_tb_offset)(struct rtw89_dev *rtwdev, 2317a9ffae8dSYuan-Han Zhang s8 pw_ofst, enum rtw89_mac_idx mac_idx); 23182a7e54dbSPing-Ke Shih int (*pwr_on_func)(struct rtw89_dev *rtwdev); 23192a7e54dbSPing-Ke Shih int (*pwr_off_func)(struct rtw89_dev *rtwdev); 2320f59acddeSPing-Ke Shih void (*fill_txdesc)(struct rtw89_dev *rtwdev, 2321f59acddeSPing-Ke Shih struct rtw89_tx_desc_info *desc_info, 2322f59acddeSPing-Ke Shih void *txdesc); 2323a95bd62eSPing-Ke Shih void (*fill_txdesc_fwcmd)(struct rtw89_dev *rtwdev, 2324a95bd62eSPing-Ke Shih struct rtw89_tx_desc_info *desc_info, 2325a95bd62eSPing-Ke Shih void *txdesc); 2326feed6541SChia-Yuan Li int (*cfg_ctrl_path)(struct rtw89_dev *rtwdev, bool wl); 2327feed6541SChia-Yuan Li int (*mac_cfg_gnt)(struct rtw89_dev *rtwdev, 2328feed6541SChia-Yuan Li const struct rtw89_mac_ax_coex_gnt *gnt_cfg); 2329de7ba639SPing-Ke Shih int (*stop_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx, 2330de7ba639SPing-Ke Shih u32 *tx_en, enum rtw89_sch_tx_sel sel); 2331de7ba639SPing-Ke Shih int (*resume_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en); 23320a6f299bSPing-Ke Shih int (*h2c_dctl_sec_cam)(struct rtw89_dev *rtwdev, 23330a6f299bSPing-Ke Shih struct rtw89_vif *rtwvif, 23340a6f299bSPing-Ke Shih struct rtw89_sta *rtwsta); 2335e3ec7017SPing-Ke Shih 2336e3ec7017SPing-Ke Shih void (*btc_set_rfe)(struct rtw89_dev *rtwdev); 2337e3ec7017SPing-Ke Shih void (*btc_init_cfg)(struct rtw89_dev *rtwdev); 2338e3ec7017SPing-Ke Shih void (*btc_set_wl_pri)(struct rtw89_dev *rtwdev, u8 map, bool state); 2339e3ec7017SPing-Ke Shih void (*btc_set_wl_txpwr_ctrl)(struct rtw89_dev *rtwdev, u32 txpwr_val); 2340e3ec7017SPing-Ke Shih s8 (*btc_get_bt_rssi)(struct rtw89_dev *rtwdev, s8 val); 2341e3ec7017SPing-Ke Shih void (*btc_bt_aci_imp)(struct rtw89_dev *rtwdev); 2342e3ec7017SPing-Ke Shih void (*btc_update_bt_cnt)(struct rtw89_dev *rtwdev); 2343e3ec7017SPing-Ke Shih void (*btc_wl_s1_standby)(struct rtw89_dev *rtwdev, bool state); 2344a8a0b1f7SChing-Te Ku void (*btc_set_policy)(struct rtw89_dev *rtwdev, u16 policy_type); 2345e3ec7017SPing-Ke Shih }; 2346e3ec7017SPing-Ke Shih 2347e3ec7017SPing-Ke Shih enum rtw89_dma_ch { 2348e3ec7017SPing-Ke Shih RTW89_DMA_ACH0 = 0, 2349e3ec7017SPing-Ke Shih RTW89_DMA_ACH1 = 1, 2350e3ec7017SPing-Ke Shih RTW89_DMA_ACH2 = 2, 2351e3ec7017SPing-Ke Shih RTW89_DMA_ACH3 = 3, 2352e3ec7017SPing-Ke Shih RTW89_DMA_ACH4 = 4, 2353e3ec7017SPing-Ke Shih RTW89_DMA_ACH5 = 5, 2354e3ec7017SPing-Ke Shih RTW89_DMA_ACH6 = 6, 2355e3ec7017SPing-Ke Shih RTW89_DMA_ACH7 = 7, 2356e3ec7017SPing-Ke Shih RTW89_DMA_B0MG = 8, 2357e3ec7017SPing-Ke Shih RTW89_DMA_B0HI = 9, 2358e3ec7017SPing-Ke Shih RTW89_DMA_B1MG = 10, 2359e3ec7017SPing-Ke Shih RTW89_DMA_B1HI = 11, 2360e3ec7017SPing-Ke Shih RTW89_DMA_H2C = 12, 2361e3ec7017SPing-Ke Shih RTW89_DMA_CH_NUM = 13 2362e3ec7017SPing-Ke Shih }; 2363e3ec7017SPing-Ke Shih 2364e3ec7017SPing-Ke Shih enum rtw89_qta_mode { 2365e3ec7017SPing-Ke Shih RTW89_QTA_SCC, 2366e3ec7017SPing-Ke Shih RTW89_QTA_DLFW, 2367e3ec7017SPing-Ke Shih 2368e3ec7017SPing-Ke Shih /* keep last */ 2369e3ec7017SPing-Ke Shih RTW89_QTA_INVALID, 2370e3ec7017SPing-Ke Shih }; 2371e3ec7017SPing-Ke Shih 2372e3ec7017SPing-Ke Shih struct rtw89_hfc_ch_cfg { 2373e3ec7017SPing-Ke Shih u16 min; 2374e3ec7017SPing-Ke Shih u16 max; 2375e3ec7017SPing-Ke Shih #define grp_0 0 2376e3ec7017SPing-Ke Shih #define grp_1 1 2377e3ec7017SPing-Ke Shih #define grp_num 2 2378e3ec7017SPing-Ke Shih u8 grp; 2379e3ec7017SPing-Ke Shih }; 2380e3ec7017SPing-Ke Shih 2381e3ec7017SPing-Ke Shih struct rtw89_hfc_ch_info { 2382e3ec7017SPing-Ke Shih u16 aval; 2383e3ec7017SPing-Ke Shih u16 used; 2384e3ec7017SPing-Ke Shih }; 2385e3ec7017SPing-Ke Shih 2386e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_cfg { 2387e3ec7017SPing-Ke Shih u16 grp0; 2388e3ec7017SPing-Ke Shih u16 grp1; 2389e3ec7017SPing-Ke Shih u16 pub_max; 2390e3ec7017SPing-Ke Shih u16 wp_thrd; 2391e3ec7017SPing-Ke Shih }; 2392e3ec7017SPing-Ke Shih 2393e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_info { 2394e3ec7017SPing-Ke Shih u16 g0_used; 2395e3ec7017SPing-Ke Shih u16 g1_used; 2396e3ec7017SPing-Ke Shih u16 g0_aval; 2397e3ec7017SPing-Ke Shih u16 g1_aval; 2398e3ec7017SPing-Ke Shih u16 pub_aval; 2399e3ec7017SPing-Ke Shih u16 wp_aval; 2400e3ec7017SPing-Ke Shih }; 2401e3ec7017SPing-Ke Shih 2402e3ec7017SPing-Ke Shih struct rtw89_hfc_prec_cfg { 2403e3ec7017SPing-Ke Shih u16 ch011_prec; 2404e3ec7017SPing-Ke Shih u16 h2c_prec; 2405e3ec7017SPing-Ke Shih u16 wp_ch07_prec; 2406e3ec7017SPing-Ke Shih u16 wp_ch811_prec; 2407e3ec7017SPing-Ke Shih u8 ch011_full_cond; 2408e3ec7017SPing-Ke Shih u8 h2c_full_cond; 2409e3ec7017SPing-Ke Shih u8 wp_ch07_full_cond; 2410e3ec7017SPing-Ke Shih u8 wp_ch811_full_cond; 2411e3ec7017SPing-Ke Shih }; 2412e3ec7017SPing-Ke Shih 2413e3ec7017SPing-Ke Shih struct rtw89_hfc_param { 2414e3ec7017SPing-Ke Shih bool en; 2415e3ec7017SPing-Ke Shih bool h2c_en; 2416e3ec7017SPing-Ke Shih u8 mode; 2417e3ec7017SPing-Ke Shih const struct rtw89_hfc_ch_cfg *ch_cfg; 2418e3ec7017SPing-Ke Shih struct rtw89_hfc_ch_info ch_info[RTW89_DMA_CH_NUM]; 2419e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_cfg pub_cfg; 2420e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_info pub_info; 2421e3ec7017SPing-Ke Shih struct rtw89_hfc_prec_cfg prec_cfg; 2422e3ec7017SPing-Ke Shih }; 2423e3ec7017SPing-Ke Shih 2424e3ec7017SPing-Ke Shih struct rtw89_hfc_param_ini { 2425e3ec7017SPing-Ke Shih const struct rtw89_hfc_ch_cfg *ch_cfg; 2426e3ec7017SPing-Ke Shih const struct rtw89_hfc_pub_cfg *pub_cfg; 2427e3ec7017SPing-Ke Shih const struct rtw89_hfc_prec_cfg *prec_cfg; 2428e3ec7017SPing-Ke Shih u8 mode; 2429e3ec7017SPing-Ke Shih }; 2430e3ec7017SPing-Ke Shih 2431e3ec7017SPing-Ke Shih struct rtw89_dle_size { 2432e3ec7017SPing-Ke Shih u16 pge_size; 2433e3ec7017SPing-Ke Shih u16 lnk_pge_num; 2434e3ec7017SPing-Ke Shih u16 unlnk_pge_num; 2435e3ec7017SPing-Ke Shih }; 2436e3ec7017SPing-Ke Shih 2437e3ec7017SPing-Ke Shih struct rtw89_wde_quota { 2438e3ec7017SPing-Ke Shih u16 hif; 2439e3ec7017SPing-Ke Shih u16 wcpu; 2440e3ec7017SPing-Ke Shih u16 pkt_in; 2441e3ec7017SPing-Ke Shih u16 cpu_io; 2442e3ec7017SPing-Ke Shih }; 2443e3ec7017SPing-Ke Shih 2444e3ec7017SPing-Ke Shih struct rtw89_ple_quota { 2445e3ec7017SPing-Ke Shih u16 cma0_tx; 2446e3ec7017SPing-Ke Shih u16 cma1_tx; 2447e3ec7017SPing-Ke Shih u16 c2h; 2448e3ec7017SPing-Ke Shih u16 h2c; 2449e3ec7017SPing-Ke Shih u16 wcpu; 2450e3ec7017SPing-Ke Shih u16 mpdu_proc; 2451e3ec7017SPing-Ke Shih u16 cma0_dma; 2452e3ec7017SPing-Ke Shih u16 cma1_dma; 2453e3ec7017SPing-Ke Shih u16 bb_rpt; 2454e3ec7017SPing-Ke Shih u16 wd_rel; 2455e3ec7017SPing-Ke Shih u16 cpu_io; 245679d099e0SPing-Ke Shih u16 tx_rpt; 2457e3ec7017SPing-Ke Shih }; 2458e3ec7017SPing-Ke Shih 2459e3ec7017SPing-Ke Shih struct rtw89_dle_mem { 2460e3ec7017SPing-Ke Shih enum rtw89_qta_mode mode; 2461e3ec7017SPing-Ke Shih const struct rtw89_dle_size *wde_size; 2462e3ec7017SPing-Ke Shih const struct rtw89_dle_size *ple_size; 2463e3ec7017SPing-Ke Shih const struct rtw89_wde_quota *wde_min_qt; 2464e3ec7017SPing-Ke Shih const struct rtw89_wde_quota *wde_max_qt; 2465e3ec7017SPing-Ke Shih const struct rtw89_ple_quota *ple_min_qt; 2466e3ec7017SPing-Ke Shih const struct rtw89_ple_quota *ple_max_qt; 2467e3ec7017SPing-Ke Shih }; 2468e3ec7017SPing-Ke Shih 2469e3ec7017SPing-Ke Shih struct rtw89_reg_def { 2470e3ec7017SPing-Ke Shih u32 addr; 2471e3ec7017SPing-Ke Shih u32 mask; 2472e3ec7017SPing-Ke Shih }; 2473e3ec7017SPing-Ke Shih 2474e3ec7017SPing-Ke Shih struct rtw89_reg2_def { 2475e3ec7017SPing-Ke Shih u32 addr; 2476e3ec7017SPing-Ke Shih u32 data; 2477e3ec7017SPing-Ke Shih }; 2478e3ec7017SPing-Ke Shih 2479e3ec7017SPing-Ke Shih struct rtw89_reg3_def { 2480e3ec7017SPing-Ke Shih u32 addr; 2481e3ec7017SPing-Ke Shih u32 mask; 2482e3ec7017SPing-Ke Shih u32 data; 2483e3ec7017SPing-Ke Shih }; 2484e3ec7017SPing-Ke Shih 2485e3ec7017SPing-Ke Shih struct rtw89_reg5_def { 2486e3ec7017SPing-Ke Shih u8 flag; /* recognized by parsers */ 2487e3ec7017SPing-Ke Shih u8 path; 2488e3ec7017SPing-Ke Shih u32 addr; 2489e3ec7017SPing-Ke Shih u32 mask; 2490e3ec7017SPing-Ke Shih u32 data; 2491e3ec7017SPing-Ke Shih }; 2492e3ec7017SPing-Ke Shih 2493e3ec7017SPing-Ke Shih struct rtw89_phy_table { 2494e3ec7017SPing-Ke Shih const struct rtw89_reg2_def *regs; 2495e3ec7017SPing-Ke Shih u32 n_regs; 2496e3ec7017SPing-Ke Shih enum rtw89_rf_path rf_path; 24972a5f2b32SPing-Ke Shih void (*config)(struct rtw89_dev *rtwdev, const struct rtw89_reg2_def *reg, 24982a5f2b32SPing-Ke Shih enum rtw89_rf_path rf_path, void *data); 2499e3ec7017SPing-Ke Shih }; 2500e3ec7017SPing-Ke Shih 2501e3ec7017SPing-Ke Shih struct rtw89_txpwr_table { 2502e3ec7017SPing-Ke Shih const void *data; 2503e3ec7017SPing-Ke Shih u32 size; 2504e3ec7017SPing-Ke Shih void (*load)(struct rtw89_dev *rtwdev, 2505e3ec7017SPing-Ke Shih const struct rtw89_txpwr_table *tbl); 2506e3ec7017SPing-Ke Shih }; 2507e3ec7017SPing-Ke Shih 2508ab8a5671SPing-Ke Shih struct rtw89_page_regs { 2509ab8a5671SPing-Ke Shih u32 hci_fc_ctrl; 2510ab8a5671SPing-Ke Shih u32 ch_page_ctrl; 2511ab8a5671SPing-Ke Shih u32 ach_page_ctrl; 2512ab8a5671SPing-Ke Shih u32 ach_page_info; 2513ab8a5671SPing-Ke Shih u32 pub_page_info3; 2514ab8a5671SPing-Ke Shih u32 pub_page_ctrl1; 2515ab8a5671SPing-Ke Shih u32 pub_page_ctrl2; 2516ab8a5671SPing-Ke Shih u32 pub_page_info1; 2517ab8a5671SPing-Ke Shih u32 pub_page_info2; 2518ab8a5671SPing-Ke Shih u32 wp_page_ctrl1; 2519ab8a5671SPing-Ke Shih u32 wp_page_ctrl2; 2520ab8a5671SPing-Ke Shih u32 wp_page_info1; 2521ab8a5671SPing-Ke Shih }; 2522ab8a5671SPing-Ke Shih 2523eeadcd2aSChia-Yuan Li struct rtw89_imr_info { 2524eeadcd2aSChia-Yuan Li u32 wdrls_imr_set; 2525eeadcd2aSChia-Yuan Li u32 wsec_imr_reg; 2526eeadcd2aSChia-Yuan Li u32 wsec_imr_set; 2527eeadcd2aSChia-Yuan Li u32 mpdu_tx_imr_set; 2528eeadcd2aSChia-Yuan Li u32 mpdu_rx_imr_set; 2529eeadcd2aSChia-Yuan Li u32 sta_sch_imr_set; 2530eeadcd2aSChia-Yuan Li u32 txpktctl_imr_b0_reg; 2531eeadcd2aSChia-Yuan Li u32 txpktctl_imr_b0_clr; 2532eeadcd2aSChia-Yuan Li u32 txpktctl_imr_b0_set; 2533eeadcd2aSChia-Yuan Li u32 txpktctl_imr_b1_reg; 2534eeadcd2aSChia-Yuan Li u32 txpktctl_imr_b1_clr; 2535eeadcd2aSChia-Yuan Li u32 txpktctl_imr_b1_set; 2536eeadcd2aSChia-Yuan Li u32 wde_imr_clr; 2537eeadcd2aSChia-Yuan Li u32 wde_imr_set; 2538eeadcd2aSChia-Yuan Li u32 ple_imr_clr; 2539eeadcd2aSChia-Yuan Li u32 ple_imr_set; 2540eeadcd2aSChia-Yuan Li u32 host_disp_imr_clr; 2541eeadcd2aSChia-Yuan Li u32 host_disp_imr_set; 2542eeadcd2aSChia-Yuan Li u32 cpu_disp_imr_clr; 2543eeadcd2aSChia-Yuan Li u32 cpu_disp_imr_set; 2544eeadcd2aSChia-Yuan Li u32 other_disp_imr_clr; 2545eeadcd2aSChia-Yuan Li u32 other_disp_imr_set; 2546eeadcd2aSChia-Yuan Li u32 bbrpt_chinfo_err_imr_reg; 2547eeadcd2aSChia-Yuan Li u32 bbrpt_err_imr_set; 2548eeadcd2aSChia-Yuan Li u32 bbrpt_dfs_err_imr_reg; 2549d86369e9SChia-Yuan Li u32 ptcl_imr_clr; 2550d86369e9SChia-Yuan Li u32 ptcl_imr_set; 2551d86369e9SChia-Yuan Li u32 cdma_imr_0_reg; 2552d86369e9SChia-Yuan Li u32 cdma_imr_0_clr; 2553d86369e9SChia-Yuan Li u32 cdma_imr_0_set; 2554d86369e9SChia-Yuan Li u32 cdma_imr_1_reg; 2555d86369e9SChia-Yuan Li u32 cdma_imr_1_clr; 2556d86369e9SChia-Yuan Li u32 cdma_imr_1_set; 2557d86369e9SChia-Yuan Li u32 phy_intf_imr_reg; 2558d86369e9SChia-Yuan Li u32 phy_intf_imr_clr; 2559d86369e9SChia-Yuan Li u32 phy_intf_imr_set; 2560d86369e9SChia-Yuan Li u32 rmac_imr_reg; 2561d86369e9SChia-Yuan Li u32 rmac_imr_clr; 2562d86369e9SChia-Yuan Li u32 rmac_imr_set; 2563d86369e9SChia-Yuan Li u32 tmac_imr_reg; 2564d86369e9SChia-Yuan Li u32 tmac_imr_clr; 2565d86369e9SChia-Yuan Li u32 tmac_imr_set; 2566eeadcd2aSChia-Yuan Li }; 2567eeadcd2aSChia-Yuan Li 25689ef9edb9SChia-Yuan Li struct rtw89_rrsr_cfgs { 25699ef9edb9SChia-Yuan Li struct rtw89_reg3_def ref_rate; 25709ef9edb9SChia-Yuan Li struct rtw89_reg3_def rsc; 25719ef9edb9SChia-Yuan Li }; 25729ef9edb9SChia-Yuan Li 257387deaad9SEric Huang struct rtw89_dig_regs { 257487deaad9SEric Huang u32 seg0_pd_reg; 257587deaad9SEric Huang u32 pd_lower_bound_mask; 257687deaad9SEric Huang u32 pd_spatial_reuse_en; 257787deaad9SEric Huang struct rtw89_reg_def p0_lna_init; 257887deaad9SEric Huang struct rtw89_reg_def p1_lna_init; 257987deaad9SEric Huang struct rtw89_reg_def p0_tia_init; 258087deaad9SEric Huang struct rtw89_reg_def p1_tia_init; 258187deaad9SEric Huang struct rtw89_reg_def p0_rxb_init; 258287deaad9SEric Huang struct rtw89_reg_def p1_rxb_init; 258387deaad9SEric Huang struct rtw89_reg_def p0_p20_pagcugc_en; 258487deaad9SEric Huang struct rtw89_reg_def p0_s20_pagcugc_en; 258587deaad9SEric Huang struct rtw89_reg_def p1_p20_pagcugc_en; 258687deaad9SEric Huang struct rtw89_reg_def p1_s20_pagcugc_en; 258787deaad9SEric Huang }; 258887deaad9SEric Huang 2589e3ec7017SPing-Ke Shih struct rtw89_chip_info { 2590e3ec7017SPing-Ke Shih enum rtw89_core_chip_id chip_id; 2591e3ec7017SPing-Ke Shih const struct rtw89_chip_ops *ops; 2592e3ec7017SPing-Ke Shih const char *fw_name; 2593e3ec7017SPing-Ke Shih u32 fifo_size; 2594e3ec7017SPing-Ke Shih u16 max_amsdu_limit; 2595e3ec7017SPing-Ke Shih bool dis_2g_40m_ul_ofdma; 25969f8004bfSZong-Zhe Yang u32 rsvd_ple_ofst; 2597e3ec7017SPing-Ke Shih const struct rtw89_hfc_param_ini *hfc_param_ini; 2598e3ec7017SPing-Ke Shih const struct rtw89_dle_mem *dle_mem; 2599e3ec7017SPing-Ke Shih u32 rf_base_addr[2]; 26007fc06a07SZong-Zhe Yang u8 support_chanctx_num; 26010237f65aSZong-Zhe Yang u8 support_bands; 2602d221270aSPing-Ke Shih bool support_bw160; 260379a6c9a4SPing-Ke Shih bool hw_sec_hdr; 2604e3ec7017SPing-Ke Shih u8 rf_path_num; 2605e3ec7017SPing-Ke Shih u8 tx_nss; 2606e3ec7017SPing-Ke Shih u8 rx_nss; 2607e3ec7017SPing-Ke Shih u8 acam_num; 2608e3ec7017SPing-Ke Shih u8 bcam_num; 2609e3ec7017SPing-Ke Shih u8 scam_num; 26102def7356SPing-Ke Shih u8 bacam_num; 26118b1b4730SPing-Ke Shih u8 bacam_dynamic_num; 26128b1b4730SPing-Ke Shih bool bacam_v1; 2613e3ec7017SPing-Ke Shih 2614e3ec7017SPing-Ke Shih u8 sec_ctrl_efuse_size; 2615e3ec7017SPing-Ke Shih u32 physical_efuse_size; 2616e3ec7017SPing-Ke Shih u32 logical_efuse_size; 2617e3ec7017SPing-Ke Shih u32 limit_efuse_size; 2618bdfbf06cSPing-Ke Shih u32 dav_phy_efuse_size; 2619bdfbf06cSPing-Ke Shih u32 dav_log_efuse_size; 2620e3ec7017SPing-Ke Shih u32 phycap_addr; 2621e3ec7017SPing-Ke Shih u32 phycap_size; 2622e3ec7017SPing-Ke Shih 2623e3ec7017SPing-Ke Shih const struct rtw89_pwr_cfg * const *pwr_on_seq; 2624e3ec7017SPing-Ke Shih const struct rtw89_pwr_cfg * const *pwr_off_seq; 2625e3ec7017SPing-Ke Shih const struct rtw89_phy_table *bb_table; 2626eefad995SPing-Ke Shih const struct rtw89_phy_table *bb_gain_table; 2627e3ec7017SPing-Ke Shih const struct rtw89_phy_table *rf_table[RF_PATH_MAX]; 2628e3ec7017SPing-Ke Shih const struct rtw89_phy_table *nctl_table; 2629e3ec7017SPing-Ke Shih const struct rtw89_txpwr_table *byr_table; 2630e3ec7017SPing-Ke Shih const struct rtw89_phy_dig_gain_table *dig_table; 263187deaad9SEric Huang const struct rtw89_dig_regs *dig_regs; 2632c7845551SPing-Ke Shih const struct rtw89_phy_tssi_dbw_table *tssi_dbw_table; 2633e3ec7017SPing-Ke Shih const s8 (*txpwr_lmt_2g)[RTW89_2G_BW_NUM][RTW89_NTX_NUM] 2634e3ec7017SPing-Ke Shih [RTW89_RS_LMT_NUM][RTW89_BF_NUM] 2635e3ec7017SPing-Ke Shih [RTW89_REGD_NUM][RTW89_2G_CH_NUM]; 2636e3ec7017SPing-Ke Shih const s8 (*txpwr_lmt_5g)[RTW89_5G_BW_NUM][RTW89_NTX_NUM] 2637e3ec7017SPing-Ke Shih [RTW89_RS_LMT_NUM][RTW89_BF_NUM] 2638e3ec7017SPing-Ke Shih [RTW89_REGD_NUM][RTW89_5G_CH_NUM]; 2639ac74f016SZong-Zhe Yang const s8 (*txpwr_lmt_6g)[RTW89_6G_BW_NUM][RTW89_NTX_NUM] 2640ac74f016SZong-Zhe Yang [RTW89_RS_LMT_NUM][RTW89_BF_NUM] 2641ac74f016SZong-Zhe Yang [RTW89_REGD_NUM][RTW89_6G_CH_NUM]; 2642e3ec7017SPing-Ke Shih const s8 (*txpwr_lmt_ru_2g)[RTW89_RU_NUM][RTW89_NTX_NUM] 2643e3ec7017SPing-Ke Shih [RTW89_REGD_NUM][RTW89_2G_CH_NUM]; 2644e3ec7017SPing-Ke Shih const s8 (*txpwr_lmt_ru_5g)[RTW89_RU_NUM][RTW89_NTX_NUM] 2645e3ec7017SPing-Ke Shih [RTW89_REGD_NUM][RTW89_5G_CH_NUM]; 2646ac74f016SZong-Zhe Yang const s8 (*txpwr_lmt_ru_6g)[RTW89_RU_NUM][RTW89_NTX_NUM] 2647ac74f016SZong-Zhe Yang [RTW89_REGD_NUM][RTW89_6G_CH_NUM]; 2648e3ec7017SPing-Ke Shih 2649e3ec7017SPing-Ke Shih u8 txpwr_factor_rf; 2650e3ec7017SPing-Ke Shih u8 txpwr_factor_mac; 2651e3ec7017SPing-Ke Shih 2652e3ec7017SPing-Ke Shih u32 para_ver; 2653e3ec7017SPing-Ke Shih u32 wlcx_desired; 2654e3ec7017SPing-Ke Shih u8 btcx_desired; 2655e3ec7017SPing-Ke Shih u8 scbd; 2656e3ec7017SPing-Ke Shih u8 mailbox; 2657*8468446aSChing-Te Ku u16 btc_fwinfo_buf; 2658e3ec7017SPing-Ke Shih 2659ba787c07SChing-Te Ku u8 fcxbtcrpt_ver; 2660ba787c07SChing-Te Ku u8 fcxtdma_ver; 2661ba787c07SChing-Te Ku u8 fcxslots_ver; 2662ba787c07SChing-Te Ku u8 fcxcysta_ver; 2663ba787c07SChing-Te Ku u8 fcxstep_ver; 2664ba787c07SChing-Te Ku u8 fcxnullsta_ver; 2665ba787c07SChing-Te Ku u8 fcxmreg_ver; 2666ba787c07SChing-Te Ku u8 fcxgpiodbg_ver; 2667ba787c07SChing-Te Ku u8 fcxbtver_ver; 2668ba787c07SChing-Te Ku u8 fcxbtscan_ver; 2669ba787c07SChing-Te Ku u8 fcxbtafh_ver; 2670ba787c07SChing-Te Ku u8 fcxbtdevinfo_ver; 2671ba787c07SChing-Te Ku 2672e3ec7017SPing-Ke Shih u8 afh_guard_ch; 2673e3ec7017SPing-Ke Shih const u8 *wl_rssi_thres; 2674e3ec7017SPing-Ke Shih const u8 *bt_rssi_thres; 2675e3ec7017SPing-Ke Shih u8 rssi_tol; 2676e3ec7017SPing-Ke Shih 2677e3ec7017SPing-Ke Shih u8 mon_reg_num; 2678e3ec7017SPing-Ke Shih const struct rtw89_btc_fbtc_mreg *mon_reg; 2679e3ec7017SPing-Ke Shih u8 rf_para_ulink_num; 2680e3ec7017SPing-Ke Shih const struct rtw89_btc_rf_trx_para *rf_para_ulink; 2681e3ec7017SPing-Ke Shih u8 rf_para_dlink_num; 2682e3ec7017SPing-Ke Shih const struct rtw89_btc_rf_trx_para *rf_para_dlink; 2683e3ec7017SPing-Ke Shih u8 ps_mode_supported; 268452edbb9fSPing-Ke Shih u8 low_power_hci_modes; 26852af64b4aSPing-Ke Shih 2686aa7f148bSPing-Ke Shih u32 h2c_cctl_func_id; 26872af64b4aSPing-Ke Shih u32 hci_func_en_addr; 2688a95bd62eSPing-Ke Shih u32 h2c_desc_size; 2689f59acddeSPing-Ke Shih u32 txwd_body_size; 2690e8955811SPing-Ke Shih u32 h2c_ctrl_reg; 2691e8955811SPing-Ke Shih const u32 *h2c_regs; 2692e8955811SPing-Ke Shih u32 c2h_ctrl_reg; 2693e8955811SPing-Ke Shih const u32 *c2h_regs; 2694ab8a5671SPing-Ke Shih const struct rtw89_page_regs *page_regs; 2695b7379148SYuan-Han Zhang const struct rtw89_reg_def *dcfo_comp; 2696b7379148SYuan-Han Zhang u8 dcfo_comp_sft; 2697eeadcd2aSChia-Yuan Li const struct rtw89_imr_info *imr_info; 26989ef9edb9SChia-Yuan Li const struct rtw89_rrsr_cfgs *rrsr_cfgs; 2699e3ec7017SPing-Ke Shih }; 2700e3ec7017SPing-Ke Shih 27014a9e48acSPing-Ke Shih union rtw89_bus_info { 27024a9e48acSPing-Ke Shih const struct rtw89_pci_info *pci; 27034a9e48acSPing-Ke Shih }; 27044a9e48acSPing-Ke Shih 2705861e58c8SZong-Zhe Yang struct rtw89_driver_info { 2706861e58c8SZong-Zhe Yang const struct rtw89_chip_info *chip; 27074a9e48acSPing-Ke Shih union rtw89_bus_info bus; 2708861e58c8SZong-Zhe Yang }; 2709861e58c8SZong-Zhe Yang 2710e3ec7017SPing-Ke Shih enum rtw89_hcifc_mode { 2711e3ec7017SPing-Ke Shih RTW89_HCIFC_POH = 0, 2712e3ec7017SPing-Ke Shih RTW89_HCIFC_STF = 1, 2713e3ec7017SPing-Ke Shih RTW89_HCIFC_SDIO = 2, 2714e3ec7017SPing-Ke Shih 2715e3ec7017SPing-Ke Shih /* keep last */ 2716e3ec7017SPing-Ke Shih RTW89_HCIFC_MODE_INVALID, 2717e3ec7017SPing-Ke Shih }; 2718e3ec7017SPing-Ke Shih 2719e3ec7017SPing-Ke Shih struct rtw89_dle_info { 2720e3ec7017SPing-Ke Shih enum rtw89_qta_mode qta_mode; 2721e3ec7017SPing-Ke Shih u16 wde_pg_size; 2722e3ec7017SPing-Ke Shih u16 ple_pg_size; 2723e3ec7017SPing-Ke Shih u16 c0_rx_qta; 2724e3ec7017SPing-Ke Shih u16 c1_rx_qta; 2725e3ec7017SPing-Ke Shih }; 2726e3ec7017SPing-Ke Shih 2727e3ec7017SPing-Ke Shih enum rtw89_host_rpr_mode { 2728e3ec7017SPing-Ke Shih RTW89_RPR_MODE_POH = 0, 2729e3ec7017SPing-Ke Shih RTW89_RPR_MODE_STF 2730e3ec7017SPing-Ke Shih }; 2731e3ec7017SPing-Ke Shih 2732e3ec7017SPing-Ke Shih struct rtw89_mac_info { 2733e3ec7017SPing-Ke Shih struct rtw89_dle_info dle_info; 2734e3ec7017SPing-Ke Shih struct rtw89_hfc_param hfc_param; 2735e3ec7017SPing-Ke Shih enum rtw89_qta_mode qta_mode; 2736e3ec7017SPing-Ke Shih u8 rpwm_seq_num; 2737e3ec7017SPing-Ke Shih u8 cpwm_seq_num; 2738e3ec7017SPing-Ke Shih }; 2739e3ec7017SPing-Ke Shih 2740e3ec7017SPing-Ke Shih enum rtw89_fw_type { 2741e3ec7017SPing-Ke Shih RTW89_FW_NORMAL = 1, 2742e3ec7017SPing-Ke Shih RTW89_FW_WOWLAN = 3, 2743e3ec7017SPing-Ke Shih }; 2744e3ec7017SPing-Ke Shih 274511fe4ccdSZong-Zhe Yang enum rtw89_fw_feature { 274611fe4ccdSZong-Zhe Yang RTW89_FW_FEATURE_OLD_HT_RA_FORMAT, 274711fe4ccdSZong-Zhe Yang RTW89_FW_FEATURE_SCAN_OFFLOAD, 274811fe4ccdSZong-Zhe Yang RTW89_FW_FEATURE_TX_WAKE, 2749edb89629SZong-Zhe Yang RTW89_FW_FEATURE_CRASH_TRIGGER, 2750183c8effSChin-Yen Lee RTW89_FW_FEATURE_NO_DEEP_PS, 275111fe4ccdSZong-Zhe Yang }; 275211fe4ccdSZong-Zhe Yang 2753e3ec7017SPing-Ke Shih struct rtw89_fw_suit { 2754e3ec7017SPing-Ke Shih const u8 *data; 2755e3ec7017SPing-Ke Shih u32 size; 2756e3ec7017SPing-Ke Shih u8 major_ver; 2757e3ec7017SPing-Ke Shih u8 minor_ver; 2758e3ec7017SPing-Ke Shih u8 sub_ver; 2759e3ec7017SPing-Ke Shih u8 sub_idex; 2760e3ec7017SPing-Ke Shih u16 build_year; 2761e3ec7017SPing-Ke Shih u16 build_mon; 2762e3ec7017SPing-Ke Shih u16 build_date; 2763e3ec7017SPing-Ke Shih u16 build_hour; 2764e3ec7017SPing-Ke Shih u16 build_min; 2765e3ec7017SPing-Ke Shih u8 cmd_ver; 2766e3ec7017SPing-Ke Shih }; 2767e3ec7017SPing-Ke Shih 2768e3ec7017SPing-Ke Shih #define RTW89_FW_VER_CODE(major, minor, sub, idx) \ 2769e3ec7017SPing-Ke Shih (((major) << 24) | ((minor) << 16) | ((sub) << 8) | (idx)) 2770e3ec7017SPing-Ke Shih #define RTW89_FW_SUIT_VER_CODE(s) \ 2771e3ec7017SPing-Ke Shih RTW89_FW_VER_CODE((s)->major_ver, (s)->minor_ver, (s)->sub_ver, (s)->sub_idex) 2772e3ec7017SPing-Ke Shih 2773deebea35SZong-Zhe Yang #define RTW89_MFW_HDR_VER_CODE(mfw_hdr) \ 2774deebea35SZong-Zhe Yang RTW89_FW_VER_CODE((mfw_hdr)->ver.major, \ 2775deebea35SZong-Zhe Yang (mfw_hdr)->ver.minor, \ 2776deebea35SZong-Zhe Yang (mfw_hdr)->ver.sub, \ 2777deebea35SZong-Zhe Yang (mfw_hdr)->ver.idx) 2778deebea35SZong-Zhe Yang 2779deebea35SZong-Zhe Yang #define RTW89_FW_HDR_VER_CODE(fw_hdr) \ 2780deebea35SZong-Zhe Yang RTW89_FW_VER_CODE(GET_FW_HDR_MAJOR_VERSION(fw_hdr), \ 2781deebea35SZong-Zhe Yang GET_FW_HDR_MINOR_VERSION(fw_hdr), \ 2782deebea35SZong-Zhe Yang GET_FW_HDR_SUBVERSION(fw_hdr), \ 2783deebea35SZong-Zhe Yang GET_FW_HDR_SUBINDEX(fw_hdr)) 2784deebea35SZong-Zhe Yang 2785e3ec7017SPing-Ke Shih struct rtw89_fw_info { 2786e3ec7017SPing-Ke Shih const struct firmware *firmware; 2787e3ec7017SPing-Ke Shih struct rtw89_dev *rtwdev; 2788e3ec7017SPing-Ke Shih struct completion completion; 2789e3ec7017SPing-Ke Shih u8 h2c_seq; 2790e3ec7017SPing-Ke Shih u8 rec_seq; 2791e3ec7017SPing-Ke Shih struct rtw89_fw_suit normal; 2792e3ec7017SPing-Ke Shih struct rtw89_fw_suit wowlan; 2793e3ec7017SPing-Ke Shih bool fw_log_enable; 279411fe4ccdSZong-Zhe Yang u32 feature_map; 2795e3ec7017SPing-Ke Shih }; 2796e3ec7017SPing-Ke Shih 279711fe4ccdSZong-Zhe Yang #define RTW89_CHK_FW_FEATURE(_feat, _fw) \ 279811fe4ccdSZong-Zhe Yang (!!((_fw)->feature_map & BIT(RTW89_FW_FEATURE_ ## _feat))) 279911fe4ccdSZong-Zhe Yang 280011fe4ccdSZong-Zhe Yang #define RTW89_SET_FW_FEATURE(_fw_feature, _fw) \ 280111fe4ccdSZong-Zhe Yang ((_fw)->feature_map |= BIT(_fw_feature)) 280211fe4ccdSZong-Zhe Yang 2803e3ec7017SPing-Ke Shih struct rtw89_cam_info { 2804e3ec7017SPing-Ke Shih DECLARE_BITMAP(addr_cam_map, RTW89_MAX_ADDR_CAM_NUM); 2805e3ec7017SPing-Ke Shih DECLARE_BITMAP(bssid_cam_map, RTW89_MAX_BSSID_CAM_NUM); 2806e3ec7017SPing-Ke Shih DECLARE_BITMAP(sec_cam_map, RTW89_MAX_SEC_CAM_NUM); 280708aa8077SPing-Ke Shih DECLARE_BITMAP(ba_cam_map, RTW89_MAX_BA_CAM_NUM); 280808aa8077SPing-Ke Shih struct rtw89_ba_cam_entry ba_cam_entry[RTW89_MAX_BA_CAM_NUM]; 2809e3ec7017SPing-Ke Shih }; 2810e3ec7017SPing-Ke Shih 2811e3ec7017SPing-Ke Shih enum rtw89_sar_sources { 2812e3ec7017SPing-Ke Shih RTW89_SAR_SOURCE_NONE, 2813e3ec7017SPing-Ke Shih RTW89_SAR_SOURCE_COMMON, 2814e3ec7017SPing-Ke Shih 2815e3ec7017SPing-Ke Shih RTW89_SAR_SOURCE_NR, 2816e3ec7017SPing-Ke Shih }; 2817e3ec7017SPing-Ke Shih 2818425671f0SZong-Zhe Yang enum rtw89_sar_subband { 2819425671f0SZong-Zhe Yang RTW89_SAR_2GHZ_SUBBAND, 2820425671f0SZong-Zhe Yang RTW89_SAR_5GHZ_SUBBAND_1_2, /* U-NII-1 and U-NII-2 */ 2821425671f0SZong-Zhe Yang RTW89_SAR_5GHZ_SUBBAND_2_E, /* U-NII-2-Extended */ 2822425671f0SZong-Zhe Yang RTW89_SAR_5GHZ_SUBBAND_3, /* U-NII-3 */ 2823425671f0SZong-Zhe Yang RTW89_SAR_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */ 2824425671f0SZong-Zhe Yang RTW89_SAR_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */ 2825425671f0SZong-Zhe Yang RTW89_SAR_6GHZ_SUBBAND_6, /* U-NII-6 */ 2826425671f0SZong-Zhe Yang RTW89_SAR_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */ 2827425671f0SZong-Zhe Yang RTW89_SAR_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */ 2828425671f0SZong-Zhe Yang RTW89_SAR_6GHZ_SUBBAND_8, /* U-NII-8 */ 2829425671f0SZong-Zhe Yang 2830425671f0SZong-Zhe Yang RTW89_SAR_SUBBAND_NR, 2831425671f0SZong-Zhe Yang }; 2832425671f0SZong-Zhe Yang 2833e3ec7017SPing-Ke Shih struct rtw89_sar_cfg_common { 2834425671f0SZong-Zhe Yang bool set[RTW89_SAR_SUBBAND_NR]; 2835425671f0SZong-Zhe Yang s32 cfg[RTW89_SAR_SUBBAND_NR]; 2836e3ec7017SPing-Ke Shih }; 2837e3ec7017SPing-Ke Shih 2838e3ec7017SPing-Ke Shih struct rtw89_sar_info { 2839e3ec7017SPing-Ke Shih /* used to decide how to acces SAR cfg union */ 2840e3ec7017SPing-Ke Shih enum rtw89_sar_sources src; 2841e3ec7017SPing-Ke Shih 2842e3ec7017SPing-Ke Shih /* reserved for different knids of SAR cfg struct. 2843e3ec7017SPing-Ke Shih * supposed that a single cfg struct cannot handle various SAR sources. 2844e3ec7017SPing-Ke Shih */ 2845e3ec7017SPing-Ke Shih union { 2846e3ec7017SPing-Ke Shih struct rtw89_sar_cfg_common cfg_common; 2847e3ec7017SPing-Ke Shih }; 2848e3ec7017SPing-Ke Shih }; 2849e3ec7017SPing-Ke Shih 285084b50f41SZong-Zhe Yang struct rtw89_chanctx_cfg { 285184b50f41SZong-Zhe Yang enum rtw89_sub_entity_idx idx; 285284b50f41SZong-Zhe Yang }; 285384b50f41SZong-Zhe Yang 28547cf674ffSZong-Zhe Yang enum rtw89_entity_mode { 28557cf674ffSZong-Zhe Yang RTW89_ENTITY_MODE_SCC, 28567cf674ffSZong-Zhe Yang }; 28577cf674ffSZong-Zhe Yang 2858e3ec7017SPing-Ke Shih struct rtw89_hal { 2859e3ec7017SPing-Ke Shih u32 rx_fltr; 2860e3ec7017SPing-Ke Shih u8 cv; 2861e3ec7017SPing-Ke Shih u32 sw_amsdu_max_size; 2862e3ec7017SPing-Ke Shih u32 antenna_tx; 2863e3ec7017SPing-Ke Shih u32 antenna_rx; 2864e3ec7017SPing-Ke Shih u8 tx_nss; 2865e3ec7017SPing-Ke Shih u8 rx_nss; 2866dc229d94SPing-Ke Shih bool tx_path_diversity; 28671c2423deSJohnson Lin bool support_cckpd; 28681e6f0d2aSJohnson Lin bool support_igi; 2869967439c7SZong-Zhe Yang 2870494399b2SZong-Zhe Yang DECLARE_BITMAP(entity_map, NUM_OF_RTW89_SUB_ENTITY); 2871494399b2SZong-Zhe Yang struct cfg80211_chan_def chandef[NUM_OF_RTW89_SUB_ENTITY]; 2872494399b2SZong-Zhe Yang 2873967439c7SZong-Zhe Yang bool entity_active; 28747cf674ffSZong-Zhe Yang enum rtw89_entity_mode entity_mode; 2875cbb145b9SZong-Zhe Yang 2876cbb145b9SZong-Zhe Yang struct rtw89_chan chan[NUM_OF_RTW89_SUB_ENTITY]; 2877cbb145b9SZong-Zhe Yang struct rtw89_chan_rcd chan_rcd[NUM_OF_RTW89_SUB_ENTITY]; 2878e3ec7017SPing-Ke Shih }; 2879e3ec7017SPing-Ke Shih 2880e3ec7017SPing-Ke Shih #define RTW89_MAX_MAC_ID_NUM 128 288189590777SPo Hao Huang #define RTW89_MAX_PKT_OFLD_NUM 255 2882e3ec7017SPing-Ke Shih 2883e3ec7017SPing-Ke Shih enum rtw89_flags { 2884e3ec7017SPing-Ke Shih RTW89_FLAG_POWERON, 2885e3ec7017SPing-Ke Shih RTW89_FLAG_FW_RDY, 2886e3ec7017SPing-Ke Shih RTW89_FLAG_RUNNING, 2887e3ec7017SPing-Ke Shih RTW89_FLAG_BFEE_MON, 2888e3ec7017SPing-Ke Shih RTW89_FLAG_BFEE_EN, 2889e3ec7017SPing-Ke Shih RTW89_FLAG_NAPI_RUNNING, 2890e3ec7017SPing-Ke Shih RTW89_FLAG_LEISURE_PS, 2891e3ec7017SPing-Ke Shih RTW89_FLAG_LOW_POWER_MODE, 2892e3ec7017SPing-Ke Shih RTW89_FLAG_INACTIVE_PS, 2893edb89629SZong-Zhe Yang RTW89_FLAG_RESTART_TRIGGER, 2894e3ec7017SPing-Ke Shih 2895e3ec7017SPing-Ke Shih NUM_OF_RTW89_FLAGS, 2896e3ec7017SPing-Ke Shih }; 2897e3ec7017SPing-Ke Shih 2898e3ec7017SPing-Ke Shih struct rtw89_pkt_stat { 2899e3ec7017SPing-Ke Shih u16 beacon_nr; 2900e3ec7017SPing-Ke Shih u32 rx_rate_cnt[RTW89_HW_RATE_NR]; 2901e3ec7017SPing-Ke Shih }; 2902e3ec7017SPing-Ke Shih 2903e3ec7017SPing-Ke Shih DECLARE_EWMA(thermal, 4, 4); 2904e3ec7017SPing-Ke Shih 2905e3ec7017SPing-Ke Shih struct rtw89_phy_stat { 2906e3ec7017SPing-Ke Shih struct ewma_thermal avg_thermal[RF_PATH_MAX]; 2907e3ec7017SPing-Ke Shih struct rtw89_pkt_stat cur_pkt_stat; 2908e3ec7017SPing-Ke Shih struct rtw89_pkt_stat last_pkt_stat; 2909e3ec7017SPing-Ke Shih }; 2910e3ec7017SPing-Ke Shih 2911e3ec7017SPing-Ke Shih #define RTW89_DACK_PATH_NR 2 2912e3ec7017SPing-Ke Shih #define RTW89_DACK_IDX_NR 2 2913e3ec7017SPing-Ke Shih #define RTW89_DACK_MSBK_NR 16 2914e3ec7017SPing-Ke Shih struct rtw89_dack_info { 2915e3ec7017SPing-Ke Shih bool dack_done; 2916e3ec7017SPing-Ke Shih u8 msbk_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR][RTW89_DACK_MSBK_NR]; 2917e3ec7017SPing-Ke Shih u8 dadck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR]; 2918e3ec7017SPing-Ke Shih u16 addck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR]; 2919e3ec7017SPing-Ke Shih u16 biask_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR]; 2920e3ec7017SPing-Ke Shih u32 dack_cnt; 2921e3ec7017SPing-Ke Shih bool addck_timeout[RTW89_DACK_PATH_NR]; 2922e3ec7017SPing-Ke Shih bool dadck_timeout[RTW89_DACK_PATH_NR]; 2923e3ec7017SPing-Ke Shih bool msbk_timeout[RTW89_DACK_PATH_NR]; 2924e3ec7017SPing-Ke Shih }; 2925e3ec7017SPing-Ke Shih 2926e3ec7017SPing-Ke Shih #define RTW89_IQK_CHS_NR 2 2927e3ec7017SPing-Ke Shih #define RTW89_IQK_PATH_NR 4 292816b44ed0SPing-Ke Shih 292916b44ed0SPing-Ke Shih struct rtw89_mcc_info { 293016b44ed0SPing-Ke Shih u8 ch[RTW89_IQK_CHS_NR]; 293116b44ed0SPing-Ke Shih u8 band[RTW89_IQK_CHS_NR]; 293216b44ed0SPing-Ke Shih u8 table_idx; 293316b44ed0SPing-Ke Shih }; 293416b44ed0SPing-Ke Shih 2935fb8177d7SPing-Ke Shih struct rtw89_lck_info { 2936fb8177d7SPing-Ke Shih u8 thermal[RF_PATH_MAX]; 2937fb8177d7SPing-Ke Shih }; 2938fb8177d7SPing-Ke Shih 2939e3d365ffSPing-Ke Shih struct rtw89_rx_dck_info { 2940e3d365ffSPing-Ke Shih u8 thermal[RF_PATH_MAX]; 2941e3d365ffSPing-Ke Shih }; 2942e3d365ffSPing-Ke Shih 2943e3ec7017SPing-Ke Shih struct rtw89_iqk_info { 2944e3ec7017SPing-Ke Shih bool lok_cor_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR]; 2945e3ec7017SPing-Ke Shih bool lok_fin_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR]; 29462da8109dSPing-Ke Shih bool lok_fail[RTW89_IQK_PATH_NR]; 2947e3ec7017SPing-Ke Shih bool iqk_tx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR]; 2948e3ec7017SPing-Ke Shih bool iqk_rx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR]; 2949e3ec7017SPing-Ke Shih u32 iqk_fail_cnt; 2950e3ec7017SPing-Ke Shih bool is_iqk_init; 2951e3ec7017SPing-Ke Shih u32 iqk_channel[RTW89_IQK_CHS_NR]; 2952e3ec7017SPing-Ke Shih u8 iqk_band[RTW89_IQK_PATH_NR]; 2953e3ec7017SPing-Ke Shih u8 iqk_ch[RTW89_IQK_PATH_NR]; 2954e3ec7017SPing-Ke Shih u8 iqk_bw[RTW89_IQK_PATH_NR]; 2955e3ec7017SPing-Ke Shih u8 kcount; 2956e3ec7017SPing-Ke Shih u8 iqk_times; 2957e3ec7017SPing-Ke Shih u8 version; 2958e3ec7017SPing-Ke Shih u32 nb_txcfir[RTW89_IQK_PATH_NR]; 2959e3ec7017SPing-Ke Shih u32 nb_rxcfir[RTW89_IQK_PATH_NR]; 2960e3ec7017SPing-Ke Shih u32 bp_txkresult[RTW89_IQK_PATH_NR]; 2961e3ec7017SPing-Ke Shih u32 bp_rxkresult[RTW89_IQK_PATH_NR]; 2962e3ec7017SPing-Ke Shih u32 bp_iqkenable[RTW89_IQK_PATH_NR]; 2963e3ec7017SPing-Ke Shih bool is_wb_txiqk[RTW89_IQK_PATH_NR]; 2964e3ec7017SPing-Ke Shih bool is_wb_rxiqk[RTW89_IQK_PATH_NR]; 2965e3ec7017SPing-Ke Shih bool is_nbiqk; 2966e3ec7017SPing-Ke Shih bool iqk_fft_en; 2967e3ec7017SPing-Ke Shih bool iqk_xym_en; 2968e3ec7017SPing-Ke Shih bool iqk_sram_en; 2969e3ec7017SPing-Ke Shih bool iqk_cfir_en; 2970e3ec7017SPing-Ke Shih u8 thermal[RTW89_IQK_PATH_NR]; 2971e3ec7017SPing-Ke Shih bool thermal_rek_en; 2972e3ec7017SPing-Ke Shih u32 syn1to2; 2973e3ec7017SPing-Ke Shih u8 iqk_mcc_ch[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR]; 2974e3ec7017SPing-Ke Shih u8 iqk_table_idx[RTW89_IQK_PATH_NR]; 29752da8109dSPing-Ke Shih u32 lok_idac[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR]; 29762da8109dSPing-Ke Shih u32 lok_vbuf[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR]; 2977e3ec7017SPing-Ke Shih }; 2978e3ec7017SPing-Ke Shih 2979e3ec7017SPing-Ke Shih #define RTW89_DPK_RF_PATH 2 2980e3ec7017SPing-Ke Shih #define RTW89_DPK_AVG_THERMAL_NUM 8 2981e3ec7017SPing-Ke Shih #define RTW89_DPK_BKUP_NUM 2 2982e3ec7017SPing-Ke Shih struct rtw89_dpk_bkup_para { 2983e3ec7017SPing-Ke Shih enum rtw89_band band; 2984e3ec7017SPing-Ke Shih enum rtw89_bandwidth bw; 2985e3ec7017SPing-Ke Shih u8 ch; 2986e3ec7017SPing-Ke Shih bool path_ok; 2987da4cea16SPing-Ke Shih u8 mdpd_en; 2988e3ec7017SPing-Ke Shih u8 txagc_dpk; 2989e3ec7017SPing-Ke Shih u8 ther_dpk; 2990e3ec7017SPing-Ke Shih u8 gs; 2991e3ec7017SPing-Ke Shih u16 pwsf; 2992e3ec7017SPing-Ke Shih }; 2993e3ec7017SPing-Ke Shih 2994e3ec7017SPing-Ke Shih struct rtw89_dpk_info { 2995e3ec7017SPing-Ke Shih bool is_dpk_enable; 2996e3ec7017SPing-Ke Shih bool is_dpk_reload_en; 2997da4cea16SPing-Ke Shih u16 dc_i[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM]; 2998da4cea16SPing-Ke Shih u16 dc_q[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM]; 2999da4cea16SPing-Ke Shih u8 corr_val[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM]; 3000da4cea16SPing-Ke Shih u8 corr_idx[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM]; 3001e3ec7017SPing-Ke Shih u8 cur_idx[RTW89_DPK_RF_PATH]; 3002da4cea16SPing-Ke Shih u8 cur_k_set; 3003e3ec7017SPing-Ke Shih struct rtw89_dpk_bkup_para bp[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM]; 3004e3ec7017SPing-Ke Shih }; 3005e3ec7017SPing-Ke Shih 3006e3ec7017SPing-Ke Shih struct rtw89_fem_info { 3007e3ec7017SPing-Ke Shih bool elna_2g; 3008e3ec7017SPing-Ke Shih bool elna_5g; 3009e3ec7017SPing-Ke Shih bool epa_2g; 3010e3ec7017SPing-Ke Shih bool epa_5g; 3011da4cea16SPing-Ke Shih bool epa_6g; 3012e3ec7017SPing-Ke Shih }; 3013e3ec7017SPing-Ke Shih 3014e3ec7017SPing-Ke Shih struct rtw89_phy_ch_info { 3015e3ec7017SPing-Ke Shih u8 rssi_min; 3016e3ec7017SPing-Ke Shih u16 rssi_min_macid; 3017e3ec7017SPing-Ke Shih u8 pre_rssi_min; 3018e3ec7017SPing-Ke Shih u8 rssi_max; 3019e3ec7017SPing-Ke Shih u16 rssi_max_macid; 3020e3ec7017SPing-Ke Shih u8 rxsc_160; 3021e3ec7017SPing-Ke Shih u8 rxsc_80; 3022e3ec7017SPing-Ke Shih u8 rxsc_40; 3023e3ec7017SPing-Ke Shih u8 rxsc_20; 3024e3ec7017SPing-Ke Shih u8 rxsc_l; 3025e3ec7017SPing-Ke Shih u8 is_noisy; 3026e3ec7017SPing-Ke Shih }; 3027e3ec7017SPing-Ke Shih 3028e3ec7017SPing-Ke Shih struct rtw89_agc_gaincode_set { 3029e3ec7017SPing-Ke Shih u8 lna_idx; 3030e3ec7017SPing-Ke Shih u8 tia_idx; 3031e3ec7017SPing-Ke Shih u8 rxb_idx; 3032e3ec7017SPing-Ke Shih }; 3033e3ec7017SPing-Ke Shih 3034e3ec7017SPing-Ke Shih #define IGI_RSSI_TH_NUM 5 3035e3ec7017SPing-Ke Shih #define FA_TH_NUM 4 3036e3ec7017SPing-Ke Shih #define LNA_GAIN_NUM 7 3037e3ec7017SPing-Ke Shih #define TIA_GAIN_NUM 2 3038e3ec7017SPing-Ke Shih struct rtw89_dig_info { 3039e3ec7017SPing-Ke Shih struct rtw89_agc_gaincode_set cur_gaincode; 3040e3ec7017SPing-Ke Shih bool force_gaincode_idx_en; 3041e3ec7017SPing-Ke Shih struct rtw89_agc_gaincode_set force_gaincode; 3042e3ec7017SPing-Ke Shih u8 igi_rssi_th[IGI_RSSI_TH_NUM]; 3043e3ec7017SPing-Ke Shih u16 fa_th[FA_TH_NUM]; 3044e3ec7017SPing-Ke Shih u8 igi_rssi; 3045e3ec7017SPing-Ke Shih u8 igi_fa_rssi; 3046e3ec7017SPing-Ke Shih u8 fa_rssi_ofst; 3047e3ec7017SPing-Ke Shih u8 dyn_igi_max; 3048e3ec7017SPing-Ke Shih u8 dyn_igi_min; 3049e3ec7017SPing-Ke Shih bool dyn_pd_th_en; 3050e3ec7017SPing-Ke Shih u8 dyn_pd_th_max; 3051e3ec7017SPing-Ke Shih u8 pd_low_th_ofst; 3052e3ec7017SPing-Ke Shih u8 ib_pbk; 3053e3ec7017SPing-Ke Shih s8 ib_pkpwr; 3054e3ec7017SPing-Ke Shih s8 lna_gain_a[LNA_GAIN_NUM]; 3055e3ec7017SPing-Ke Shih s8 lna_gain_g[LNA_GAIN_NUM]; 3056e3ec7017SPing-Ke Shih s8 *lna_gain; 3057e3ec7017SPing-Ke Shih s8 tia_gain_a[TIA_GAIN_NUM]; 3058e3ec7017SPing-Ke Shih s8 tia_gain_g[TIA_GAIN_NUM]; 3059e3ec7017SPing-Ke Shih s8 *tia_gain; 3060e3ec7017SPing-Ke Shih bool is_linked_pre; 3061e3ec7017SPing-Ke Shih bool bypass_dig; 3062e3ec7017SPing-Ke Shih }; 3063e3ec7017SPing-Ke Shih 3064e3ec7017SPing-Ke Shih enum rtw89_multi_cfo_mode { 3065e3ec7017SPing-Ke Shih RTW89_PKT_BASED_AVG_MODE = 0, 3066e3ec7017SPing-Ke Shih RTW89_ENTRY_BASED_AVG_MODE = 1, 3067e3ec7017SPing-Ke Shih RTW89_TP_BASED_AVG_MODE = 2, 3068e3ec7017SPing-Ke Shih }; 3069e3ec7017SPing-Ke Shih 3070e3ec7017SPing-Ke Shih enum rtw89_phy_cfo_status { 3071e3ec7017SPing-Ke Shih RTW89_PHY_DCFO_STATE_NORMAL = 0, 3072e3ec7017SPing-Ke Shih RTW89_PHY_DCFO_STATE_ENHANCE = 1, 3073bc013052SEric Huang RTW89_PHY_DCFO_STATE_HOLD = 2, 3074e3ec7017SPing-Ke Shih RTW89_PHY_DCFO_STATE_MAX 3075e3ec7017SPing-Ke Shih }; 3076e3ec7017SPing-Ke Shih 3077bc013052SEric Huang enum rtw89_phy_cfo_ul_ofdma_acc_mode { 3078bc013052SEric Huang RTW89_CFO_UL_OFDMA_ACC_DISABLE = 0, 3079bc013052SEric Huang RTW89_CFO_UL_OFDMA_ACC_ENABLE = 1 3080bc013052SEric Huang }; 3081bc013052SEric Huang 3082e3ec7017SPing-Ke Shih struct rtw89_cfo_tracking_info { 3083e3ec7017SPing-Ke Shih u16 cfo_timer_ms; 3084e3ec7017SPing-Ke Shih bool cfo_trig_by_timer_en; 3085e3ec7017SPing-Ke Shih enum rtw89_phy_cfo_status phy_cfo_status; 3086bc013052SEric Huang enum rtw89_phy_cfo_ul_ofdma_acc_mode cfo_ul_ofdma_acc_mode; 3087e3ec7017SPing-Ke Shih u8 phy_cfo_trk_cnt; 3088e3ec7017SPing-Ke Shih bool is_adjust; 3089e3ec7017SPing-Ke Shih enum rtw89_multi_cfo_mode rtw89_multi_cfo_mode; 3090e3ec7017SPing-Ke Shih bool apply_compensation; 3091e3ec7017SPing-Ke Shih u8 crystal_cap; 3092e3ec7017SPing-Ke Shih u8 crystal_cap_default; 3093e3ec7017SPing-Ke Shih u8 def_x_cap; 3094e3ec7017SPing-Ke Shih s8 x_cap_ofst; 3095e3ec7017SPing-Ke Shih u32 sta_cfo_tolerance; 3096e3ec7017SPing-Ke Shih s32 cfo_tail[CFO_TRACK_MAX_USER]; 3097e3ec7017SPing-Ke Shih u16 cfo_cnt[CFO_TRACK_MAX_USER]; 3098e3ec7017SPing-Ke Shih s32 cfo_avg_pre; 3099e3ec7017SPing-Ke Shih s32 cfo_avg[CFO_TRACK_MAX_USER]; 3100e3ec7017SPing-Ke Shih s32 pre_cfo_avg[CFO_TRACK_MAX_USER]; 3101e3ec7017SPing-Ke Shih u32 packet_count; 3102e3ec7017SPing-Ke Shih u32 packet_count_pre; 3103e3ec7017SPing-Ke Shih s32 residual_cfo_acc; 3104e3ec7017SPing-Ke Shih u8 phy_cfotrk_state; 3105e3ec7017SPing-Ke Shih u8 phy_cfotrk_cnt; 3106a9e06f2eSYi-Tang Chiu bool divergence_lock_en; 3107a9e06f2eSYi-Tang Chiu u8 x_cap_lb; 3108a9e06f2eSYi-Tang Chiu u8 x_cap_ub; 3109a9e06f2eSYi-Tang Chiu u8 lock_cnt; 3110e3ec7017SPing-Ke Shih }; 3111e3ec7017SPing-Ke Shih 3112e3ec7017SPing-Ke Shih /* 2GL, 2GH, 5GL1, 5GH1, 5GM1, 5GM2, 5GH1, 5GH2 */ 3113e3ec7017SPing-Ke Shih #define TSSI_TRIM_CH_GROUP_NUM 8 3114a82174c6SPing-Ke Shih #define TSSI_TRIM_CH_GROUP_NUM_6G 16 3115e3ec7017SPing-Ke Shih 3116e3ec7017SPing-Ke Shih #define TSSI_CCK_CH_GROUP_NUM 6 3117e3ec7017SPing-Ke Shih #define TSSI_MCS_2G_CH_GROUP_NUM 5 3118e3ec7017SPing-Ke Shih #define TSSI_MCS_5G_CH_GROUP_NUM 14 3119a82174c6SPing-Ke Shih #define TSSI_MCS_6G_CH_GROUP_NUM 32 3120e3ec7017SPing-Ke Shih #define TSSI_MCS_CH_GROUP_NUM \ 3121e3ec7017SPing-Ke Shih (TSSI_MCS_2G_CH_GROUP_NUM + TSSI_MCS_5G_CH_GROUP_NUM) 3122e3ec7017SPing-Ke Shih 3123e3ec7017SPing-Ke Shih struct rtw89_tssi_info { 3124e3ec7017SPing-Ke Shih u8 thermal[RF_PATH_MAX]; 3125e3ec7017SPing-Ke Shih s8 tssi_trim[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM]; 3126a82174c6SPing-Ke Shih s8 tssi_trim_6g[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM_6G]; 3127e3ec7017SPing-Ke Shih s8 tssi_cck[RF_PATH_MAX][TSSI_CCK_CH_GROUP_NUM]; 3128e3ec7017SPing-Ke Shih s8 tssi_mcs[RF_PATH_MAX][TSSI_MCS_CH_GROUP_NUM]; 3129a82174c6SPing-Ke Shih s8 tssi_6g_mcs[RF_PATH_MAX][TSSI_MCS_6G_CH_GROUP_NUM]; 3130e3ec7017SPing-Ke Shih s8 extra_ofst[RF_PATH_MAX]; 3131e3ec7017SPing-Ke Shih bool tssi_tracking_check[RF_PATH_MAX]; 3132e3ec7017SPing-Ke Shih u8 default_txagc_offset[RF_PATH_MAX]; 3133e3ec7017SPing-Ke Shih u32 base_thermal[RF_PATH_MAX]; 3134e3ec7017SPing-Ke Shih }; 3135e3ec7017SPing-Ke Shih 3136e3ec7017SPing-Ke Shih struct rtw89_power_trim_info { 3137e3ec7017SPing-Ke Shih bool pg_thermal_trim; 3138e3ec7017SPing-Ke Shih bool pg_pa_bias_trim; 3139e3ec7017SPing-Ke Shih u8 thermal_trim[RF_PATH_MAX]; 3140e3ec7017SPing-Ke Shih u8 pa_bias_trim[RF_PATH_MAX]; 3141e3ec7017SPing-Ke Shih }; 3142e3ec7017SPing-Ke Shih 3143e3ec7017SPing-Ke Shih struct rtw89_regulatory { 3144e3ec7017SPing-Ke Shih char alpha2[3]; 3145e3ec7017SPing-Ke Shih u8 txpwr_regd[RTW89_BAND_MAX]; 3146e3ec7017SPing-Ke Shih }; 3147e3ec7017SPing-Ke Shih 3148e3ec7017SPing-Ke Shih enum rtw89_ifs_clm_application { 3149e3ec7017SPing-Ke Shih RTW89_IFS_CLM_INIT = 0, 3150e3ec7017SPing-Ke Shih RTW89_IFS_CLM_BACKGROUND = 1, 3151e3ec7017SPing-Ke Shih RTW89_IFS_CLM_ACS = 2, 3152e3ec7017SPing-Ke Shih RTW89_IFS_CLM_DIG = 3, 3153e3ec7017SPing-Ke Shih RTW89_IFS_CLM_TDMA_DIG = 4, 3154e3ec7017SPing-Ke Shih RTW89_IFS_CLM_DBG = 5, 3155e3ec7017SPing-Ke Shih RTW89_IFS_CLM_DBG_MANUAL = 6 3156e3ec7017SPing-Ke Shih }; 3157e3ec7017SPing-Ke Shih 3158e3ec7017SPing-Ke Shih enum rtw89_env_racing_lv { 3159e3ec7017SPing-Ke Shih RTW89_RAC_RELEASE = 0, 3160e3ec7017SPing-Ke Shih RTW89_RAC_LV_1 = 1, 3161e3ec7017SPing-Ke Shih RTW89_RAC_LV_2 = 2, 3162e3ec7017SPing-Ke Shih RTW89_RAC_LV_3 = 3, 3163e3ec7017SPing-Ke Shih RTW89_RAC_LV_4 = 4, 3164e3ec7017SPing-Ke Shih RTW89_RAC_MAX_NUM = 5 3165e3ec7017SPing-Ke Shih }; 3166e3ec7017SPing-Ke Shih 3167e3ec7017SPing-Ke Shih struct rtw89_ccx_para_info { 3168e3ec7017SPing-Ke Shih enum rtw89_env_racing_lv rac_lv; 3169e3ec7017SPing-Ke Shih u16 mntr_time; 3170e3ec7017SPing-Ke Shih u8 nhm_manual_th_ofst; 3171e3ec7017SPing-Ke Shih u8 nhm_manual_th0; 3172e3ec7017SPing-Ke Shih enum rtw89_ifs_clm_application ifs_clm_app; 3173e3ec7017SPing-Ke Shih u32 ifs_clm_manual_th_times; 3174e3ec7017SPing-Ke Shih u32 ifs_clm_manual_th0; 3175e3ec7017SPing-Ke Shih u8 fahm_manual_th_ofst; 3176e3ec7017SPing-Ke Shih u8 fahm_manual_th0; 3177e3ec7017SPing-Ke Shih u8 fahm_numer_opt; 3178e3ec7017SPing-Ke Shih u8 fahm_denom_opt; 3179e3ec7017SPing-Ke Shih }; 3180e3ec7017SPing-Ke Shih 3181e3ec7017SPing-Ke Shih enum rtw89_ccx_edcca_opt_sc_idx { 3182e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG0_P0 = 0, 3183e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG0_S1 = 1, 3184e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG0_S2 = 2, 3185e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG0_S3 = 3, 3186e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG1_P0 = 4, 3187e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG1_S1 = 5, 3188e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG1_S2 = 6, 3189e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_SEG1_S3 = 7 3190e3ec7017SPing-Ke Shih }; 3191e3ec7017SPing-Ke Shih 3192e3ec7017SPing-Ke Shih enum rtw89_ccx_edcca_opt_bw_idx { 3193e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_0 = 0, 3194e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_1 = 1, 3195e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_2 = 2, 3196e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_3 = 3, 3197e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_4 = 4, 3198e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_5 = 5, 3199e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_6 = 6, 3200e3ec7017SPing-Ke Shih RTW89_CCX_EDCCA_BW20_7 = 7 3201e3ec7017SPing-Ke Shih }; 3202e3ec7017SPing-Ke Shih 3203e3ec7017SPing-Ke Shih #define RTW89_NHM_TH_NUM 11 3204e3ec7017SPing-Ke Shih #define RTW89_FAHM_TH_NUM 11 3205e3ec7017SPing-Ke Shih #define RTW89_NHM_RPT_NUM 12 3206e3ec7017SPing-Ke Shih #define RTW89_FAHM_RPT_NUM 12 3207e3ec7017SPing-Ke Shih #define RTW89_IFS_CLM_NUM 4 3208e3ec7017SPing-Ke Shih struct rtw89_env_monitor_info { 3209e3ec7017SPing-Ke Shih u32 ccx_trigger_time; 3210e3ec7017SPing-Ke Shih u64 start_time; 3211e3ec7017SPing-Ke Shih u8 ccx_rpt_stamp; 3212e3ec7017SPing-Ke Shih u8 ccx_watchdog_result; 3213e3ec7017SPing-Ke Shih bool ccx_ongoing; 3214e3ec7017SPing-Ke Shih u8 ccx_rac_lv; 3215e3ec7017SPing-Ke Shih bool ccx_manual_ctrl; 3216e3ec7017SPing-Ke Shih u8 ccx_pre_rssi; 3217e3ec7017SPing-Ke Shih u16 clm_mntr_time; 3218e3ec7017SPing-Ke Shih u16 nhm_mntr_time; 3219e3ec7017SPing-Ke Shih u16 ifs_clm_mntr_time; 3220e3ec7017SPing-Ke Shih enum rtw89_ifs_clm_application ifs_clm_app; 3221e3ec7017SPing-Ke Shih u16 fahm_mntr_time; 3222e3ec7017SPing-Ke Shih u16 edcca_clm_mntr_time; 3223e3ec7017SPing-Ke Shih u16 ccx_period; 3224e3ec7017SPing-Ke Shih u8 ccx_unit_idx; 3225e3ec7017SPing-Ke Shih enum rtw89_ccx_edcca_opt_bw_idx ccx_edcca_opt_bw_idx; 3226e3ec7017SPing-Ke Shih u8 nhm_th[RTW89_NHM_TH_NUM]; 3227e3ec7017SPing-Ke Shih u16 ifs_clm_th_l[RTW89_IFS_CLM_NUM]; 3228e3ec7017SPing-Ke Shih u16 ifs_clm_th_h[RTW89_IFS_CLM_NUM]; 3229e3ec7017SPing-Ke Shih u8 fahm_numer_opt; 3230e3ec7017SPing-Ke Shih u8 fahm_denom_opt; 3231e3ec7017SPing-Ke Shih u8 fahm_th[RTW89_FAHM_TH_NUM]; 3232e3ec7017SPing-Ke Shih u16 clm_result; 3233e3ec7017SPing-Ke Shih u16 nhm_result[RTW89_NHM_RPT_NUM]; 3234e3ec7017SPing-Ke Shih u8 nhm_wgt[RTW89_NHM_RPT_NUM]; 3235e3ec7017SPing-Ke Shih u16 nhm_tx_cnt; 3236e3ec7017SPing-Ke Shih u16 nhm_cca_cnt; 3237e3ec7017SPing-Ke Shih u16 nhm_idle_cnt; 3238e3ec7017SPing-Ke Shih u16 ifs_clm_tx; 3239e3ec7017SPing-Ke Shih u16 ifs_clm_edcca_excl_cca; 3240e3ec7017SPing-Ke Shih u16 ifs_clm_ofdmfa; 3241e3ec7017SPing-Ke Shih u16 ifs_clm_ofdmcca_excl_fa; 3242e3ec7017SPing-Ke Shih u16 ifs_clm_cckfa; 3243e3ec7017SPing-Ke Shih u16 ifs_clm_cckcca_excl_fa; 3244e3ec7017SPing-Ke Shih u16 ifs_clm_total_ifs; 3245e3ec7017SPing-Ke Shih u8 ifs_clm_his[RTW89_IFS_CLM_NUM]; 3246e3ec7017SPing-Ke Shih u16 ifs_clm_avg[RTW89_IFS_CLM_NUM]; 3247e3ec7017SPing-Ke Shih u16 ifs_clm_cca[RTW89_IFS_CLM_NUM]; 3248e3ec7017SPing-Ke Shih u16 fahm_result[RTW89_FAHM_RPT_NUM]; 3249e3ec7017SPing-Ke Shih u16 fahm_denom_result; 3250e3ec7017SPing-Ke Shih u16 edcca_clm_result; 3251e3ec7017SPing-Ke Shih u8 clm_ratio; 3252e3ec7017SPing-Ke Shih u8 nhm_rpt[RTW89_NHM_RPT_NUM]; 3253e3ec7017SPing-Ke Shih u8 nhm_tx_ratio; 3254e3ec7017SPing-Ke Shih u8 nhm_cca_ratio; 3255e3ec7017SPing-Ke Shih u8 nhm_idle_ratio; 3256e3ec7017SPing-Ke Shih u8 nhm_ratio; 3257e3ec7017SPing-Ke Shih u16 nhm_result_sum; 3258e3ec7017SPing-Ke Shih u8 nhm_pwr; 3259e3ec7017SPing-Ke Shih u8 ifs_clm_tx_ratio; 3260e3ec7017SPing-Ke Shih u8 ifs_clm_edcca_excl_cca_ratio; 3261e3ec7017SPing-Ke Shih u8 ifs_clm_cck_fa_ratio; 3262e3ec7017SPing-Ke Shih u8 ifs_clm_ofdm_fa_ratio; 3263e3ec7017SPing-Ke Shih u8 ifs_clm_cck_cca_excl_fa_ratio; 3264e3ec7017SPing-Ke Shih u8 ifs_clm_ofdm_cca_excl_fa_ratio; 3265e3ec7017SPing-Ke Shih u16 ifs_clm_cck_fa_permil; 3266e3ec7017SPing-Ke Shih u16 ifs_clm_ofdm_fa_permil; 3267e3ec7017SPing-Ke Shih u32 ifs_clm_ifs_avg[RTW89_IFS_CLM_NUM]; 3268e3ec7017SPing-Ke Shih u32 ifs_clm_cca_avg[RTW89_IFS_CLM_NUM]; 3269e3ec7017SPing-Ke Shih u8 fahm_rpt[RTW89_FAHM_RPT_NUM]; 3270e3ec7017SPing-Ke Shih u16 fahm_result_sum; 3271e3ec7017SPing-Ke Shih u8 fahm_ratio; 3272e3ec7017SPing-Ke Shih u8 fahm_denom_ratio; 3273e3ec7017SPing-Ke Shih u8 fahm_pwr; 3274e3ec7017SPing-Ke Shih u8 edcca_clm_ratio; 3275e3ec7017SPing-Ke Shih }; 3276e3ec7017SPing-Ke Shih 3277e3ec7017SPing-Ke Shih enum rtw89_ser_rcvy_step { 3278e3ec7017SPing-Ke Shih RTW89_SER_DRV_STOP_TX, 3279e3ec7017SPing-Ke Shih RTW89_SER_DRV_STOP_RX, 3280e3ec7017SPing-Ke Shih RTW89_SER_DRV_STOP_RUN, 3281e3ec7017SPing-Ke Shih RTW89_SER_HAL_STOP_DMA, 3282e3ec7017SPing-Ke Shih RTW89_NUM_OF_SER_FLAGS 3283e3ec7017SPing-Ke Shih }; 3284e3ec7017SPing-Ke Shih 3285e3ec7017SPing-Ke Shih struct rtw89_ser { 3286e3ec7017SPing-Ke Shih u8 state; 3287e3ec7017SPing-Ke Shih u8 alarm_event; 3288e3ec7017SPing-Ke Shih 3289e3ec7017SPing-Ke Shih struct work_struct ser_hdl_work; 3290e3ec7017SPing-Ke Shih struct delayed_work ser_alarm_work; 3291af5175acSJoe Perches const struct state_ent *st_tbl; 3292af5175acSJoe Perches const struct event_ent *ev_tbl; 3293e3ec7017SPing-Ke Shih struct list_head msg_q; 3294e3ec7017SPing-Ke Shih spinlock_t msg_q_lock; /* lock when read/write ser msg */ 3295e3ec7017SPing-Ke Shih DECLARE_BITMAP(flags, RTW89_NUM_OF_SER_FLAGS); 3296e3ec7017SPing-Ke Shih }; 3297e3ec7017SPing-Ke Shih 3298e3ec7017SPing-Ke Shih enum rtw89_mac_ax_ps_mode { 3299e3ec7017SPing-Ke Shih RTW89_MAC_AX_PS_MODE_ACTIVE = 0, 3300e3ec7017SPing-Ke Shih RTW89_MAC_AX_PS_MODE_LEGACY = 1, 3301e3ec7017SPing-Ke Shih RTW89_MAC_AX_PS_MODE_WMMPS = 2, 3302e3ec7017SPing-Ke Shih RTW89_MAC_AX_PS_MODE_MAX = 3, 3303e3ec7017SPing-Ke Shih }; 3304e3ec7017SPing-Ke Shih 3305e3ec7017SPing-Ke Shih enum rtw89_last_rpwm_mode { 3306e3ec7017SPing-Ke Shih RTW89_LAST_RPWM_PS = 0x0, 3307e3ec7017SPing-Ke Shih RTW89_LAST_RPWM_ACTIVE = 0x6, 3308e3ec7017SPing-Ke Shih }; 3309e3ec7017SPing-Ke Shih 3310e3ec7017SPing-Ke Shih struct rtw89_lps_parm { 3311e3ec7017SPing-Ke Shih u8 macid; 3312e3ec7017SPing-Ke Shih u8 psmode; /* enum rtw89_mac_ax_ps_mode */ 3313e3ec7017SPing-Ke Shih u8 lastrpwm; /* enum rtw89_last_rpwm_mode */ 3314e3ec7017SPing-Ke Shih }; 3315e3ec7017SPing-Ke Shih 3316e3ec7017SPing-Ke Shih struct rtw89_ppdu_sts_info { 3317e3ec7017SPing-Ke Shih struct sk_buff_head rx_queue[RTW89_PHY_MAX]; 3318e3ec7017SPing-Ke Shih u8 curr_rx_ppdu_cnt[RTW89_PHY_MAX]; 3319e3ec7017SPing-Ke Shih }; 3320e3ec7017SPing-Ke Shih 3321e3ec7017SPing-Ke Shih struct rtw89_early_h2c { 3322e3ec7017SPing-Ke Shih struct list_head list; 3323e3ec7017SPing-Ke Shih u8 *h2c; 3324e3ec7017SPing-Ke Shih u16 h2c_len; 3325e3ec7017SPing-Ke Shih }; 3326e3ec7017SPing-Ke Shih 332789590777SPo Hao Huang struct rtw89_hw_scan_info { 332889590777SPo Hao Huang struct ieee80211_vif *scanning_vif; 332989590777SPo Hao Huang struct list_head pkt_list[NUM_NL80211_BANDS]; 333089590777SPo Hao Huang u8 op_pri_ch; 333189590777SPo Hao Huang u8 op_chan; 333289590777SPo Hao Huang u8 op_bw; 333389590777SPo Hao Huang u8 op_band; 3334bd1056d4SPo-Hao Huang u32 last_chan_idx; 333589590777SPo Hao Huang }; 333689590777SPo Hao Huang 3337e885871eSZong-Zhe Yang enum rtw89_phy_bb_gain_band { 3338e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_2G = 0, 3339e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_5G_L = 1, 3340e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_5G_M = 2, 3341e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_5G_H = 3, 3342e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_6G_L = 4, 3343e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_6G_M = 5, 3344e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_6G_H = 6, 3345e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_6G_UH = 7, 3346e885871eSZong-Zhe Yang 3347e885871eSZong-Zhe Yang RTW89_BB_GAIN_BAND_NR, 3348e885871eSZong-Zhe Yang }; 3349e885871eSZong-Zhe Yang 3350e885871eSZong-Zhe Yang enum rtw89_phy_bb_rxsc_num { 3351e885871eSZong-Zhe Yang RTW89_BB_RXSC_NUM_40 = 9, /* SC: 0, 1~8 */ 3352e885871eSZong-Zhe Yang RTW89_BB_RXSC_NUM_80 = 13, /* SC: 0, 1~8, 9~12 */ 3353e885871eSZong-Zhe Yang RTW89_BB_RXSC_NUM_160 = 15, /* SC: 0, 1~8, 9~12, 13~14 */ 3354e885871eSZong-Zhe Yang }; 3355e885871eSZong-Zhe Yang 3356e885871eSZong-Zhe Yang struct rtw89_phy_bb_gain_info { 3357e885871eSZong-Zhe Yang s8 lna_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM]; 3358e885871eSZong-Zhe Yang s8 tia_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][TIA_GAIN_NUM]; 3359e885871eSZong-Zhe Yang s8 lna_gain_bypass[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM]; 3360e885871eSZong-Zhe Yang s8 lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM]; 3361e885871eSZong-Zhe Yang s8 tia_lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX] 3362e885871eSZong-Zhe Yang [LNA_GAIN_NUM + 1]; /* TIA0_LNA0~6 + TIA1_LNA6 */ 3363e885871eSZong-Zhe Yang s8 rpl_ofst_20[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]; 3364e885871eSZong-Zhe Yang s8 rpl_ofst_40[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX] 3365e885871eSZong-Zhe Yang [RTW89_BB_RXSC_NUM_40]; 3366e885871eSZong-Zhe Yang s8 rpl_ofst_80[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX] 3367e885871eSZong-Zhe Yang [RTW89_BB_RXSC_NUM_80]; 3368e885871eSZong-Zhe Yang s8 rpl_ofst_160[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX] 3369e885871eSZong-Zhe Yang [RTW89_BB_RXSC_NUM_160]; 3370e885871eSZong-Zhe Yang }; 3371e885871eSZong-Zhe Yang 3372e6b17cbdSPing-Ke Shih struct rtw89_phy_efuse_gain { 3373e6b17cbdSPing-Ke Shih bool offset_valid; 3374e6b17cbdSPing-Ke Shih s8 offset[RF_PATH_MAX][RTW89_GAIN_OFFSET_NR]; /* S(8, 0) */ 3375e6b17cbdSPing-Ke Shih s8 offset_base[RTW89_PHY_MAX]; /* S(8, 4) */ 3376e6b17cbdSPing-Ke Shih }; 3377e6b17cbdSPing-Ke Shih 3378e3ec7017SPing-Ke Shih struct rtw89_dev { 3379e3ec7017SPing-Ke Shih struct ieee80211_hw *hw; 3380e3ec7017SPing-Ke Shih struct device *dev; 33817fc06a07SZong-Zhe Yang const struct ieee80211_ops *ops; 3382e3ec7017SPing-Ke Shih 3383e3ec7017SPing-Ke Shih bool dbcc_en; 338489590777SPo Hao Huang struct rtw89_hw_scan_info scan_info; 3385e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip; 33864a9e48acSPing-Ke Shih const struct rtw89_pci_info *pci_info; 3387e3ec7017SPing-Ke Shih struct rtw89_hal hal; 3388e3ec7017SPing-Ke Shih struct rtw89_mac_info mac; 3389e3ec7017SPing-Ke Shih struct rtw89_fw_info fw; 3390e3ec7017SPing-Ke Shih struct rtw89_hci_info hci; 3391e3ec7017SPing-Ke Shih struct rtw89_efuse efuse; 3392e3ec7017SPing-Ke Shih struct rtw89_traffic_stats stats; 3393e3ec7017SPing-Ke Shih 3394e3ec7017SPing-Ke Shih /* ensures exclusive access from mac80211 callbacks */ 3395e3ec7017SPing-Ke Shih struct mutex mutex; 3396e3ec7017SPing-Ke Shih struct list_head rtwvifs_list; 3397e3ec7017SPing-Ke Shih /* used to protect rf read write */ 3398e3ec7017SPing-Ke Shih struct mutex rf_mutex; 3399e3ec7017SPing-Ke Shih struct workqueue_struct *txq_wq; 3400e3ec7017SPing-Ke Shih struct work_struct txq_work; 3401e3ec7017SPing-Ke Shih struct delayed_work txq_reinvoke_work; 3402679955d5SKuan-Chung Chen /* used to protect ba_list and forbid_ba_list */ 3403e3ec7017SPing-Ke Shih spinlock_t ba_lock; 3404e3ec7017SPing-Ke Shih /* txqs to setup ba session */ 3405e3ec7017SPing-Ke Shih struct list_head ba_list; 3406679955d5SKuan-Chung Chen /* txqs to forbid ba session */ 3407679955d5SKuan-Chung Chen struct list_head forbid_ba_list; 3408e3ec7017SPing-Ke Shih struct work_struct ba_work; 34097bfd05ffSChin-Yen Lee /* used to protect rpwm */ 34107bfd05ffSChin-Yen Lee spinlock_t rpwm_lock; 3411e3ec7017SPing-Ke Shih 3412e3ec7017SPing-Ke Shih struct rtw89_cam_info cam_info; 3413e3ec7017SPing-Ke Shih 3414e3ec7017SPing-Ke Shih struct sk_buff_head c2h_queue; 3415e3ec7017SPing-Ke Shih struct work_struct c2h_work; 341689590777SPo Hao Huang struct work_struct ips_work; 3417e3ec7017SPing-Ke Shih 3418e3ec7017SPing-Ke Shih struct list_head early_h2c_list; 3419e3ec7017SPing-Ke Shih 3420e3ec7017SPing-Ke Shih struct rtw89_ser ser; 3421e3ec7017SPing-Ke Shih 342220d9fc88SPing-Ke Shih DECLARE_BITMAP(hw_port, RTW89_PORT_NUM); 3423e3ec7017SPing-Ke Shih DECLARE_BITMAP(mac_id_map, RTW89_MAX_MAC_ID_NUM); 3424e3ec7017SPing-Ke Shih DECLARE_BITMAP(flags, NUM_OF_RTW89_FLAGS); 342589590777SPo Hao Huang DECLARE_BITMAP(pkt_offload, RTW89_MAX_PKT_OFLD_NUM); 3426e3ec7017SPing-Ke Shih 3427e3ec7017SPing-Ke Shih struct rtw89_phy_stat phystat; 3428e3ec7017SPing-Ke Shih struct rtw89_dack_info dack; 3429e3ec7017SPing-Ke Shih struct rtw89_iqk_info iqk; 3430e3ec7017SPing-Ke Shih struct rtw89_dpk_info dpk; 343116b44ed0SPing-Ke Shih struct rtw89_mcc_info mcc; 3432fb8177d7SPing-Ke Shih struct rtw89_lck_info lck; 3433e3d365ffSPing-Ke Shih struct rtw89_rx_dck_info rx_dck; 3434e3ec7017SPing-Ke Shih bool is_tssi_mode[RF_PATH_MAX]; 3435e3ec7017SPing-Ke Shih bool is_bt_iqk_timeout; 3436e3ec7017SPing-Ke Shih 3437e3ec7017SPing-Ke Shih struct rtw89_fem_info fem; 3438e3ec7017SPing-Ke Shih struct rtw89_txpwr_byrate byr[RTW89_BAND_MAX]; 3439e3ec7017SPing-Ke Shih struct rtw89_tssi_info tssi; 3440e3ec7017SPing-Ke Shih struct rtw89_power_trim_info pwr_trim; 3441e3ec7017SPing-Ke Shih 3442e3ec7017SPing-Ke Shih struct rtw89_cfo_tracking_info cfo_tracking; 3443e3ec7017SPing-Ke Shih struct rtw89_env_monitor_info env_monitor; 3444e3ec7017SPing-Ke Shih struct rtw89_dig_info dig; 3445e3ec7017SPing-Ke Shih struct rtw89_phy_ch_info ch_info; 3446e885871eSZong-Zhe Yang struct rtw89_phy_bb_gain_info bb_gain; 3447e6b17cbdSPing-Ke Shih struct rtw89_phy_efuse_gain efuse_gain; 3448e885871eSZong-Zhe Yang 3449e3ec7017SPing-Ke Shih struct delayed_work track_work; 3450e3ec7017SPing-Ke Shih struct delayed_work coex_act1_work; 3451e3ec7017SPing-Ke Shih struct delayed_work coex_bt_devinfo_work; 3452e3ec7017SPing-Ke Shih struct delayed_work coex_rfk_chk_work; 3453e3ec7017SPing-Ke Shih struct delayed_work cfo_track_work; 3454679955d5SKuan-Chung Chen struct delayed_work forbid_ba_work; 3455e3ec7017SPing-Ke Shih struct rtw89_ppdu_sts_info ppdu_sts; 3456e3ec7017SPing-Ke Shih u8 total_sta_assoc; 3457e3ec7017SPing-Ke Shih bool scanning; 3458e3ec7017SPing-Ke Shih 3459e3ec7017SPing-Ke Shih const struct rtw89_regulatory *regd; 3460e3ec7017SPing-Ke Shih struct rtw89_sar_info sar; 3461e3ec7017SPing-Ke Shih 3462e3ec7017SPing-Ke Shih struct rtw89_btc btc; 3463e3ec7017SPing-Ke Shih enum rtw89_ps_mode ps_mode; 3464e3ec7017SPing-Ke Shih bool lps_enabled; 3465e3ec7017SPing-Ke Shih 3466e3ec7017SPing-Ke Shih /* napi structure */ 3467e3ec7017SPing-Ke Shih struct net_device netdev; 3468e3ec7017SPing-Ke Shih struct napi_struct napi; 3469e3ec7017SPing-Ke Shih int napi_budget_countdown; 3470e3ec7017SPing-Ke Shih 3471e3ec7017SPing-Ke Shih /* HCI related data, keep last */ 34722e2f63a1SGustavo A. R. Silva u8 priv[] __aligned(sizeof(void *)); 3473e3ec7017SPing-Ke Shih }; 3474e3ec7017SPing-Ke Shih 3475e3ec7017SPing-Ke Shih static inline int rtw89_hci_tx_write(struct rtw89_dev *rtwdev, 3476e3ec7017SPing-Ke Shih struct rtw89_core_tx_request *tx_req) 3477e3ec7017SPing-Ke Shih { 3478e3ec7017SPing-Ke Shih return rtwdev->hci.ops->tx_write(rtwdev, tx_req); 3479e3ec7017SPing-Ke Shih } 3480e3ec7017SPing-Ke Shih 3481e3ec7017SPing-Ke Shih static inline void rtw89_hci_reset(struct rtw89_dev *rtwdev) 3482e3ec7017SPing-Ke Shih { 3483e3ec7017SPing-Ke Shih rtwdev->hci.ops->reset(rtwdev); 3484e3ec7017SPing-Ke Shih } 3485e3ec7017SPing-Ke Shih 3486e3ec7017SPing-Ke Shih static inline int rtw89_hci_start(struct rtw89_dev *rtwdev) 3487e3ec7017SPing-Ke Shih { 3488e3ec7017SPing-Ke Shih return rtwdev->hci.ops->start(rtwdev); 3489e3ec7017SPing-Ke Shih } 3490e3ec7017SPing-Ke Shih 3491e3ec7017SPing-Ke Shih static inline void rtw89_hci_stop(struct rtw89_dev *rtwdev) 3492e3ec7017SPing-Ke Shih { 3493e3ec7017SPing-Ke Shih rtwdev->hci.ops->stop(rtwdev); 3494e3ec7017SPing-Ke Shih } 3495e3ec7017SPing-Ke Shih 3496e3ec7017SPing-Ke Shih static inline int rtw89_hci_deinit(struct rtw89_dev *rtwdev) 3497e3ec7017SPing-Ke Shih { 3498e3ec7017SPing-Ke Shih return rtwdev->hci.ops->deinit(rtwdev); 3499e3ec7017SPing-Ke Shih } 3500e3ec7017SPing-Ke Shih 350152edbb9fSPing-Ke Shih static inline void rtw89_hci_pause(struct rtw89_dev *rtwdev, bool pause) 350252edbb9fSPing-Ke Shih { 350352edbb9fSPing-Ke Shih rtwdev->hci.ops->pause(rtwdev, pause); 350452edbb9fSPing-Ke Shih } 350552edbb9fSPing-Ke Shih 350652edbb9fSPing-Ke Shih static inline void rtw89_hci_switch_mode(struct rtw89_dev *rtwdev, bool low_power) 350752edbb9fSPing-Ke Shih { 350852edbb9fSPing-Ke Shih rtwdev->hci.ops->switch_mode(rtwdev, low_power); 350952edbb9fSPing-Ke Shih } 351052edbb9fSPing-Ke Shih 3511e3ec7017SPing-Ke Shih static inline void rtw89_hci_recalc_int_mit(struct rtw89_dev *rtwdev) 3512e3ec7017SPing-Ke Shih { 3513e3ec7017SPing-Ke Shih rtwdev->hci.ops->recalc_int_mit(rtwdev); 3514e3ec7017SPing-Ke Shih } 3515e3ec7017SPing-Ke Shih 3516e3ec7017SPing-Ke Shih static inline u32 rtw89_hci_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev, u8 txch) 3517e3ec7017SPing-Ke Shih { 3518e3ec7017SPing-Ke Shih return rtwdev->hci.ops->check_and_reclaim_tx_resource(rtwdev, txch); 3519e3ec7017SPing-Ke Shih } 3520e3ec7017SPing-Ke Shih 3521e3ec7017SPing-Ke Shih static inline void rtw89_hci_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch) 3522e3ec7017SPing-Ke Shih { 3523e3ec7017SPing-Ke Shih return rtwdev->hci.ops->tx_kick_off(rtwdev, txch); 3524e3ec7017SPing-Ke Shih } 3525e3ec7017SPing-Ke Shih 3526e3ec7017SPing-Ke Shih static inline void rtw89_hci_flush_queues(struct rtw89_dev *rtwdev, u32 queues, 3527e3ec7017SPing-Ke Shih bool drop) 3528e3ec7017SPing-Ke Shih { 3529fc5f311fSPing-Ke Shih if (!test_bit(RTW89_FLAG_POWERON, rtwdev->flags)) 3530fc5f311fSPing-Ke Shih return; 3531fc5f311fSPing-Ke Shih 3532e3ec7017SPing-Ke Shih if (rtwdev->hci.ops->flush_queues) 3533e3ec7017SPing-Ke Shih return rtwdev->hci.ops->flush_queues(rtwdev, queues, drop); 3534e3ec7017SPing-Ke Shih } 3535e3ec7017SPing-Ke Shih 353614f9f479SZong-Zhe Yang static inline void rtw89_hci_recovery_start(struct rtw89_dev *rtwdev) 353714f9f479SZong-Zhe Yang { 353814f9f479SZong-Zhe Yang if (rtwdev->hci.ops->recovery_start) 353914f9f479SZong-Zhe Yang rtwdev->hci.ops->recovery_start(rtwdev); 354014f9f479SZong-Zhe Yang } 354114f9f479SZong-Zhe Yang 354214f9f479SZong-Zhe Yang static inline void rtw89_hci_recovery_complete(struct rtw89_dev *rtwdev) 354314f9f479SZong-Zhe Yang { 354414f9f479SZong-Zhe Yang if (rtwdev->hci.ops->recovery_complete) 354514f9f479SZong-Zhe Yang rtwdev->hci.ops->recovery_complete(rtwdev); 354614f9f479SZong-Zhe Yang } 354714f9f479SZong-Zhe Yang 3548e3ec7017SPing-Ke Shih static inline u8 rtw89_read8(struct rtw89_dev *rtwdev, u32 addr) 3549e3ec7017SPing-Ke Shih { 3550e3ec7017SPing-Ke Shih return rtwdev->hci.ops->read8(rtwdev, addr); 3551e3ec7017SPing-Ke Shih } 3552e3ec7017SPing-Ke Shih 3553e3ec7017SPing-Ke Shih static inline u16 rtw89_read16(struct rtw89_dev *rtwdev, u32 addr) 3554e3ec7017SPing-Ke Shih { 3555e3ec7017SPing-Ke Shih return rtwdev->hci.ops->read16(rtwdev, addr); 3556e3ec7017SPing-Ke Shih } 3557e3ec7017SPing-Ke Shih 3558e3ec7017SPing-Ke Shih static inline u32 rtw89_read32(struct rtw89_dev *rtwdev, u32 addr) 3559e3ec7017SPing-Ke Shih { 3560e3ec7017SPing-Ke Shih return rtwdev->hci.ops->read32(rtwdev, addr); 3561e3ec7017SPing-Ke Shih } 3562e3ec7017SPing-Ke Shih 3563e3ec7017SPing-Ke Shih static inline void rtw89_write8(struct rtw89_dev *rtwdev, u32 addr, u8 data) 3564e3ec7017SPing-Ke Shih { 3565e3ec7017SPing-Ke Shih rtwdev->hci.ops->write8(rtwdev, addr, data); 3566e3ec7017SPing-Ke Shih } 3567e3ec7017SPing-Ke Shih 3568e3ec7017SPing-Ke Shih static inline void rtw89_write16(struct rtw89_dev *rtwdev, u32 addr, u16 data) 3569e3ec7017SPing-Ke Shih { 3570e3ec7017SPing-Ke Shih rtwdev->hci.ops->write16(rtwdev, addr, data); 3571e3ec7017SPing-Ke Shih } 3572e3ec7017SPing-Ke Shih 3573e3ec7017SPing-Ke Shih static inline void rtw89_write32(struct rtw89_dev *rtwdev, u32 addr, u32 data) 3574e3ec7017SPing-Ke Shih { 3575e3ec7017SPing-Ke Shih rtwdev->hci.ops->write32(rtwdev, addr, data); 3576e3ec7017SPing-Ke Shih } 3577e3ec7017SPing-Ke Shih 3578e3ec7017SPing-Ke Shih static inline void 3579e3ec7017SPing-Ke Shih rtw89_write8_set(struct rtw89_dev *rtwdev, u32 addr, u8 bit) 3580e3ec7017SPing-Ke Shih { 3581e3ec7017SPing-Ke Shih u8 val; 3582e3ec7017SPing-Ke Shih 3583e3ec7017SPing-Ke Shih val = rtw89_read8(rtwdev, addr); 3584e3ec7017SPing-Ke Shih rtw89_write8(rtwdev, addr, val | bit); 3585e3ec7017SPing-Ke Shih } 3586e3ec7017SPing-Ke Shih 3587e3ec7017SPing-Ke Shih static inline void 3588e3ec7017SPing-Ke Shih rtw89_write16_set(struct rtw89_dev *rtwdev, u32 addr, u16 bit) 3589e3ec7017SPing-Ke Shih { 3590e3ec7017SPing-Ke Shih u16 val; 3591e3ec7017SPing-Ke Shih 3592e3ec7017SPing-Ke Shih val = rtw89_read16(rtwdev, addr); 3593e3ec7017SPing-Ke Shih rtw89_write16(rtwdev, addr, val | bit); 3594e3ec7017SPing-Ke Shih } 3595e3ec7017SPing-Ke Shih 3596e3ec7017SPing-Ke Shih static inline void 3597e3ec7017SPing-Ke Shih rtw89_write32_set(struct rtw89_dev *rtwdev, u32 addr, u32 bit) 3598e3ec7017SPing-Ke Shih { 3599e3ec7017SPing-Ke Shih u32 val; 3600e3ec7017SPing-Ke Shih 3601e3ec7017SPing-Ke Shih val = rtw89_read32(rtwdev, addr); 3602e3ec7017SPing-Ke Shih rtw89_write32(rtwdev, addr, val | bit); 3603e3ec7017SPing-Ke Shih } 3604e3ec7017SPing-Ke Shih 3605e3ec7017SPing-Ke Shih static inline void 3606e3ec7017SPing-Ke Shih rtw89_write8_clr(struct rtw89_dev *rtwdev, u32 addr, u8 bit) 3607e3ec7017SPing-Ke Shih { 3608e3ec7017SPing-Ke Shih u8 val; 3609e3ec7017SPing-Ke Shih 3610e3ec7017SPing-Ke Shih val = rtw89_read8(rtwdev, addr); 3611e3ec7017SPing-Ke Shih rtw89_write8(rtwdev, addr, val & ~bit); 3612e3ec7017SPing-Ke Shih } 3613e3ec7017SPing-Ke Shih 3614e3ec7017SPing-Ke Shih static inline void 3615e3ec7017SPing-Ke Shih rtw89_write16_clr(struct rtw89_dev *rtwdev, u32 addr, u16 bit) 3616e3ec7017SPing-Ke Shih { 3617e3ec7017SPing-Ke Shih u16 val; 3618e3ec7017SPing-Ke Shih 3619e3ec7017SPing-Ke Shih val = rtw89_read16(rtwdev, addr); 3620e3ec7017SPing-Ke Shih rtw89_write16(rtwdev, addr, val & ~bit); 3621e3ec7017SPing-Ke Shih } 3622e3ec7017SPing-Ke Shih 3623e3ec7017SPing-Ke Shih static inline void 3624e3ec7017SPing-Ke Shih rtw89_write32_clr(struct rtw89_dev *rtwdev, u32 addr, u32 bit) 3625e3ec7017SPing-Ke Shih { 3626e3ec7017SPing-Ke Shih u32 val; 3627e3ec7017SPing-Ke Shih 3628e3ec7017SPing-Ke Shih val = rtw89_read32(rtwdev, addr); 3629e3ec7017SPing-Ke Shih rtw89_write32(rtwdev, addr, val & ~bit); 3630e3ec7017SPing-Ke Shih } 3631e3ec7017SPing-Ke Shih 3632e3ec7017SPing-Ke Shih static inline u32 3633e3ec7017SPing-Ke Shih rtw89_read32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask) 3634e3ec7017SPing-Ke Shih { 3635e3ec7017SPing-Ke Shih u32 shift = __ffs(mask); 3636e3ec7017SPing-Ke Shih u32 orig; 3637e3ec7017SPing-Ke Shih u32 ret; 3638e3ec7017SPing-Ke Shih 3639e3ec7017SPing-Ke Shih orig = rtw89_read32(rtwdev, addr); 3640e3ec7017SPing-Ke Shih ret = (orig & mask) >> shift; 3641e3ec7017SPing-Ke Shih 3642e3ec7017SPing-Ke Shih return ret; 3643e3ec7017SPing-Ke Shih } 3644e3ec7017SPing-Ke Shih 3645e3ec7017SPing-Ke Shih static inline u16 3646e3ec7017SPing-Ke Shih rtw89_read16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask) 3647e3ec7017SPing-Ke Shih { 3648e3ec7017SPing-Ke Shih u32 shift = __ffs(mask); 3649e3ec7017SPing-Ke Shih u32 orig; 3650e3ec7017SPing-Ke Shih u32 ret; 3651e3ec7017SPing-Ke Shih 3652e3ec7017SPing-Ke Shih orig = rtw89_read16(rtwdev, addr); 3653e3ec7017SPing-Ke Shih ret = (orig & mask) >> shift; 3654e3ec7017SPing-Ke Shih 3655e3ec7017SPing-Ke Shih return ret; 3656e3ec7017SPing-Ke Shih } 3657e3ec7017SPing-Ke Shih 3658e3ec7017SPing-Ke Shih static inline u8 3659e3ec7017SPing-Ke Shih rtw89_read8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask) 3660e3ec7017SPing-Ke Shih { 3661e3ec7017SPing-Ke Shih u32 shift = __ffs(mask); 3662e3ec7017SPing-Ke Shih u32 orig; 3663e3ec7017SPing-Ke Shih u32 ret; 3664e3ec7017SPing-Ke Shih 3665e3ec7017SPing-Ke Shih orig = rtw89_read8(rtwdev, addr); 3666e3ec7017SPing-Ke Shih ret = (orig & mask) >> shift; 3667e3ec7017SPing-Ke Shih 3668e3ec7017SPing-Ke Shih return ret; 3669e3ec7017SPing-Ke Shih } 3670e3ec7017SPing-Ke Shih 3671e3ec7017SPing-Ke Shih static inline void 3672e3ec7017SPing-Ke Shih rtw89_write32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u32 data) 3673e3ec7017SPing-Ke Shih { 3674e3ec7017SPing-Ke Shih u32 shift = __ffs(mask); 3675e3ec7017SPing-Ke Shih u32 orig; 3676e3ec7017SPing-Ke Shih u32 set; 3677e3ec7017SPing-Ke Shih 3678e3ec7017SPing-Ke Shih WARN(addr & 0x3, "should be 4-byte aligned, addr = 0x%08x\n", addr); 3679e3ec7017SPing-Ke Shih 3680e3ec7017SPing-Ke Shih orig = rtw89_read32(rtwdev, addr); 3681e3ec7017SPing-Ke Shih set = (orig & ~mask) | ((data << shift) & mask); 3682e3ec7017SPing-Ke Shih rtw89_write32(rtwdev, addr, set); 3683e3ec7017SPing-Ke Shih } 3684e3ec7017SPing-Ke Shih 3685e3ec7017SPing-Ke Shih static inline void 3686e3ec7017SPing-Ke Shih rtw89_write16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u16 data) 3687e3ec7017SPing-Ke Shih { 3688e3ec7017SPing-Ke Shih u32 shift; 3689e3ec7017SPing-Ke Shih u16 orig, set; 3690e3ec7017SPing-Ke Shih 3691e3ec7017SPing-Ke Shih mask &= 0xffff; 3692e3ec7017SPing-Ke Shih shift = __ffs(mask); 3693e3ec7017SPing-Ke Shih 3694e3ec7017SPing-Ke Shih orig = rtw89_read16(rtwdev, addr); 3695e3ec7017SPing-Ke Shih set = (orig & ~mask) | ((data << shift) & mask); 3696e3ec7017SPing-Ke Shih rtw89_write16(rtwdev, addr, set); 3697e3ec7017SPing-Ke Shih } 3698e3ec7017SPing-Ke Shih 3699e3ec7017SPing-Ke Shih static inline void 3700e3ec7017SPing-Ke Shih rtw89_write8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u8 data) 3701e3ec7017SPing-Ke Shih { 3702e3ec7017SPing-Ke Shih u32 shift; 3703e3ec7017SPing-Ke Shih u8 orig, set; 3704e3ec7017SPing-Ke Shih 3705e3ec7017SPing-Ke Shih mask &= 0xff; 3706e3ec7017SPing-Ke Shih shift = __ffs(mask); 3707e3ec7017SPing-Ke Shih 3708e3ec7017SPing-Ke Shih orig = rtw89_read8(rtwdev, addr); 3709e3ec7017SPing-Ke Shih set = (orig & ~mask) | ((data << shift) & mask); 3710e3ec7017SPing-Ke Shih rtw89_write8(rtwdev, addr, set); 3711e3ec7017SPing-Ke Shih } 3712e3ec7017SPing-Ke Shih 3713e3ec7017SPing-Ke Shih static inline u32 3714e3ec7017SPing-Ke Shih rtw89_read_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path, 3715e3ec7017SPing-Ke Shih u32 addr, u32 mask) 3716e3ec7017SPing-Ke Shih { 3717e3ec7017SPing-Ke Shih u32 val; 3718e3ec7017SPing-Ke Shih 3719e3ec7017SPing-Ke Shih mutex_lock(&rtwdev->rf_mutex); 3720e3ec7017SPing-Ke Shih val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask); 3721e3ec7017SPing-Ke Shih mutex_unlock(&rtwdev->rf_mutex); 3722e3ec7017SPing-Ke Shih 3723e3ec7017SPing-Ke Shih return val; 3724e3ec7017SPing-Ke Shih } 3725e3ec7017SPing-Ke Shih 3726e3ec7017SPing-Ke Shih static inline void 3727e3ec7017SPing-Ke Shih rtw89_write_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path, 3728e3ec7017SPing-Ke Shih u32 addr, u32 mask, u32 data) 3729e3ec7017SPing-Ke Shih { 3730e3ec7017SPing-Ke Shih mutex_lock(&rtwdev->rf_mutex); 3731e3ec7017SPing-Ke Shih rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data); 3732e3ec7017SPing-Ke Shih mutex_unlock(&rtwdev->rf_mutex); 3733e3ec7017SPing-Ke Shih } 3734e3ec7017SPing-Ke Shih 3735e3ec7017SPing-Ke Shih static inline struct ieee80211_txq *rtw89_txq_to_txq(struct rtw89_txq *rtwtxq) 3736e3ec7017SPing-Ke Shih { 3737e3ec7017SPing-Ke Shih void *p = rtwtxq; 3738e3ec7017SPing-Ke Shih 3739e3ec7017SPing-Ke Shih return container_of(p, struct ieee80211_txq, drv_priv); 3740e3ec7017SPing-Ke Shih } 3741e3ec7017SPing-Ke Shih 3742e3ec7017SPing-Ke Shih static inline void rtw89_core_txq_init(struct rtw89_dev *rtwdev, 3743e3ec7017SPing-Ke Shih struct ieee80211_txq *txq) 3744e3ec7017SPing-Ke Shih { 3745e3ec7017SPing-Ke Shih struct rtw89_txq *rtwtxq; 3746e3ec7017SPing-Ke Shih 3747e3ec7017SPing-Ke Shih if (!txq) 3748e3ec7017SPing-Ke Shih return; 3749e3ec7017SPing-Ke Shih 3750e3ec7017SPing-Ke Shih rtwtxq = (struct rtw89_txq *)txq->drv_priv; 3751e3ec7017SPing-Ke Shih INIT_LIST_HEAD(&rtwtxq->list); 3752e3ec7017SPing-Ke Shih } 3753e3ec7017SPing-Ke Shih 3754e3ec7017SPing-Ke Shih static inline struct ieee80211_vif *rtwvif_to_vif(struct rtw89_vif *rtwvif) 3755e3ec7017SPing-Ke Shih { 3756e3ec7017SPing-Ke Shih void *p = rtwvif; 3757e3ec7017SPing-Ke Shih 3758e3ec7017SPing-Ke Shih return container_of(p, struct ieee80211_vif, drv_priv); 3759e3ec7017SPing-Ke Shih } 3760e3ec7017SPing-Ke Shih 3761bd1056d4SPo-Hao Huang static inline struct ieee80211_vif *rtwvif_to_vif_safe(struct rtw89_vif *rtwvif) 3762bd1056d4SPo-Hao Huang { 3763bd1056d4SPo-Hao Huang return rtwvif ? rtwvif_to_vif(rtwvif) : NULL; 3764bd1056d4SPo-Hao Huang } 3765bd1056d4SPo-Hao Huang 3766bd1056d4SPo-Hao Huang static inline struct rtw89_vif *vif_to_rtwvif_safe(struct ieee80211_vif *vif) 3767bd1056d4SPo-Hao Huang { 3768bd1056d4SPo-Hao Huang return vif ? (struct rtw89_vif *)vif->drv_priv : NULL; 3769bd1056d4SPo-Hao Huang } 3770bd1056d4SPo-Hao Huang 3771e3ec7017SPing-Ke Shih static inline struct ieee80211_sta *rtwsta_to_sta(struct rtw89_sta *rtwsta) 3772e3ec7017SPing-Ke Shih { 3773e3ec7017SPing-Ke Shih void *p = rtwsta; 3774e3ec7017SPing-Ke Shih 3775e3ec7017SPing-Ke Shih return container_of(p, struct ieee80211_sta, drv_priv); 3776e3ec7017SPing-Ke Shih } 3777e3ec7017SPing-Ke Shih 377840822e07SPing-Ke Shih static inline struct ieee80211_sta *rtwsta_to_sta_safe(struct rtw89_sta *rtwsta) 377940822e07SPing-Ke Shih { 378040822e07SPing-Ke Shih return rtwsta ? rtwsta_to_sta(rtwsta) : NULL; 378140822e07SPing-Ke Shih } 378240822e07SPing-Ke Shih 378340822e07SPing-Ke Shih static inline struct rtw89_sta *sta_to_rtwsta_safe(struct ieee80211_sta *sta) 378440822e07SPing-Ke Shih { 378540822e07SPing-Ke Shih return sta ? (struct rtw89_sta *)sta->drv_priv : NULL; 378640822e07SPing-Ke Shih } 378740822e07SPing-Ke Shih 3788167044afSPing-Ke Shih static inline u8 rtw89_hw_to_rate_info_bw(enum rtw89_bandwidth hw_bw) 3789167044afSPing-Ke Shih { 3790167044afSPing-Ke Shih if (hw_bw == RTW89_CHANNEL_WIDTH_160) 3791167044afSPing-Ke Shih return RATE_INFO_BW_160; 3792167044afSPing-Ke Shih else if (hw_bw == RTW89_CHANNEL_WIDTH_80) 3793167044afSPing-Ke Shih return RATE_INFO_BW_80; 3794167044afSPing-Ke Shih else if (hw_bw == RTW89_CHANNEL_WIDTH_40) 3795167044afSPing-Ke Shih return RATE_INFO_BW_40; 3796167044afSPing-Ke Shih else 3797167044afSPing-Ke Shih return RATE_INFO_BW_20; 3798167044afSPing-Ke Shih } 3799167044afSPing-Ke Shih 3800e3ec7017SPing-Ke Shih static inline 3801a06d2dd7SZong-Zhe Yang enum nl80211_band rtw89_hw_to_nl80211_band(enum rtw89_band hw_band) 3802a06d2dd7SZong-Zhe Yang { 3803a06d2dd7SZong-Zhe Yang switch (hw_band) { 3804a06d2dd7SZong-Zhe Yang default: 3805a06d2dd7SZong-Zhe Yang case RTW89_BAND_2G: 3806a06d2dd7SZong-Zhe Yang return NL80211_BAND_2GHZ; 3807a06d2dd7SZong-Zhe Yang case RTW89_BAND_5G: 3808a06d2dd7SZong-Zhe Yang return NL80211_BAND_5GHZ; 3809a06d2dd7SZong-Zhe Yang case RTW89_BAND_6G: 3810a06d2dd7SZong-Zhe Yang return NL80211_BAND_6GHZ; 3811a06d2dd7SZong-Zhe Yang } 3812a06d2dd7SZong-Zhe Yang } 3813a06d2dd7SZong-Zhe Yang 3814a06d2dd7SZong-Zhe Yang static inline 38153a1e7cb1SPo-Hao Huang enum rtw89_band rtw89_nl80211_to_hw_band(enum nl80211_band nl_band) 38163a1e7cb1SPo-Hao Huang { 38173a1e7cb1SPo-Hao Huang switch (nl_band) { 38183a1e7cb1SPo-Hao Huang default: 38193a1e7cb1SPo-Hao Huang case NL80211_BAND_2GHZ: 38203a1e7cb1SPo-Hao Huang return RTW89_BAND_2G; 38213a1e7cb1SPo-Hao Huang case NL80211_BAND_5GHZ: 38223a1e7cb1SPo-Hao Huang return RTW89_BAND_5G; 38233a1e7cb1SPo-Hao Huang case NL80211_BAND_6GHZ: 38243a1e7cb1SPo-Hao Huang return RTW89_BAND_6G; 38253a1e7cb1SPo-Hao Huang } 38263a1e7cb1SPo-Hao Huang } 38273a1e7cb1SPo-Hao Huang 38283a1e7cb1SPo-Hao Huang static inline 3829e715f10fSPing-Ke Shih enum rtw89_bandwidth nl_to_rtw89_bandwidth(enum nl80211_chan_width width) 3830e715f10fSPing-Ke Shih { 3831e715f10fSPing-Ke Shih switch (width) { 3832e715f10fSPing-Ke Shih default: 3833e715f10fSPing-Ke Shih WARN(1, "Not support bandwidth %d\n", width); 3834e715f10fSPing-Ke Shih fallthrough; 3835e715f10fSPing-Ke Shih case NL80211_CHAN_WIDTH_20_NOHT: 3836e715f10fSPing-Ke Shih case NL80211_CHAN_WIDTH_20: 3837e715f10fSPing-Ke Shih return RTW89_CHANNEL_WIDTH_20; 3838e715f10fSPing-Ke Shih case NL80211_CHAN_WIDTH_40: 3839e715f10fSPing-Ke Shih return RTW89_CHANNEL_WIDTH_40; 3840e715f10fSPing-Ke Shih case NL80211_CHAN_WIDTH_80: 3841e715f10fSPing-Ke Shih return RTW89_CHANNEL_WIDTH_80; 3842e715f10fSPing-Ke Shih case NL80211_CHAN_WIDTH_160: 3843e715f10fSPing-Ke Shih return RTW89_CHANNEL_WIDTH_160; 3844e715f10fSPing-Ke Shih } 3845e715f10fSPing-Ke Shih } 3846e715f10fSPing-Ke Shih 3847e715f10fSPing-Ke Shih static inline 38482ab856ccSPing-Ke Shih struct rtw89_addr_cam_entry *rtw89_get_addr_cam_of(struct rtw89_vif *rtwvif, 38492ab856ccSPing-Ke Shih struct rtw89_sta *rtwsta) 38502ab856ccSPing-Ke Shih { 38517312100dSPing-Ke Shih if (rtwsta) { 38527312100dSPing-Ke Shih struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta); 38537312100dSPing-Ke Shih 38547312100dSPing-Ke Shih if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE || sta->tdls) 38552ab856ccSPing-Ke Shih return &rtwsta->addr_cam; 38567312100dSPing-Ke Shih } 38572ab856ccSPing-Ke Shih return &rtwvif->addr_cam; 38582ab856ccSPing-Ke Shih } 38592ab856ccSPing-Ke Shih 38602ab856ccSPing-Ke Shih static inline 386139913cc8SPing-Ke Shih struct rtw89_bssid_cam_entry *rtw89_get_bssid_cam_of(struct rtw89_vif *rtwvif, 386239913cc8SPing-Ke Shih struct rtw89_sta *rtwsta) 386339913cc8SPing-Ke Shih { 386439913cc8SPing-Ke Shih if (rtwsta) { 386539913cc8SPing-Ke Shih struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta); 386639913cc8SPing-Ke Shih 386739913cc8SPing-Ke Shih if (sta->tdls) 386839913cc8SPing-Ke Shih return &rtwsta->bssid_cam; 386939913cc8SPing-Ke Shih } 387039913cc8SPing-Ke Shih return &rtwvif->bssid_cam; 387139913cc8SPing-Ke Shih } 387239913cc8SPing-Ke Shih 387339913cc8SPing-Ke Shih static inline 3874e3ec7017SPing-Ke Shih void rtw89_chip_set_channel_prepare(struct rtw89_dev *rtwdev, 3875ce57e55cSZong-Zhe Yang struct rtw89_channel_help_params *p, 3876ce57e55cSZong-Zhe Yang const struct rtw89_chan *chan, 3877ce57e55cSZong-Zhe Yang enum rtw89_mac_idx mac_idx, 3878ce57e55cSZong-Zhe Yang enum rtw89_phy_idx phy_idx) 3879e3ec7017SPing-Ke Shih { 3880ce57e55cSZong-Zhe Yang rtwdev->chip->ops->set_channel_help(rtwdev, true, p, chan, 3881ce57e55cSZong-Zhe Yang mac_idx, phy_idx); 3882e3ec7017SPing-Ke Shih } 3883e3ec7017SPing-Ke Shih 3884e3ec7017SPing-Ke Shih static inline 3885e3ec7017SPing-Ke Shih void rtw89_chip_set_channel_done(struct rtw89_dev *rtwdev, 3886ce57e55cSZong-Zhe Yang struct rtw89_channel_help_params *p, 3887ce57e55cSZong-Zhe Yang const struct rtw89_chan *chan, 3888ce57e55cSZong-Zhe Yang enum rtw89_mac_idx mac_idx, 3889ce57e55cSZong-Zhe Yang enum rtw89_phy_idx phy_idx) 3890e3ec7017SPing-Ke Shih { 3891ce57e55cSZong-Zhe Yang rtwdev->chip->ops->set_channel_help(rtwdev, false, p, chan, 3892ce57e55cSZong-Zhe Yang mac_idx, phy_idx); 3893e3ec7017SPing-Ke Shih } 3894e3ec7017SPing-Ke Shih 3895cbb145b9SZong-Zhe Yang static inline 3896494399b2SZong-Zhe Yang const struct cfg80211_chan_def *rtw89_chandef_get(struct rtw89_dev *rtwdev, 3897494399b2SZong-Zhe Yang enum rtw89_sub_entity_idx idx) 3898494399b2SZong-Zhe Yang { 3899494399b2SZong-Zhe Yang struct rtw89_hal *hal = &rtwdev->hal; 3900494399b2SZong-Zhe Yang 3901494399b2SZong-Zhe Yang return &hal->chandef[idx]; 3902494399b2SZong-Zhe Yang } 3903494399b2SZong-Zhe Yang 3904494399b2SZong-Zhe Yang static inline 3905cbb145b9SZong-Zhe Yang const struct rtw89_chan *rtw89_chan_get(struct rtw89_dev *rtwdev, 3906cbb145b9SZong-Zhe Yang enum rtw89_sub_entity_idx idx) 3907cbb145b9SZong-Zhe Yang { 3908cbb145b9SZong-Zhe Yang struct rtw89_hal *hal = &rtwdev->hal; 3909cbb145b9SZong-Zhe Yang 3910cbb145b9SZong-Zhe Yang return &hal->chan[idx]; 3911cbb145b9SZong-Zhe Yang } 3912cbb145b9SZong-Zhe Yang 3913cbb145b9SZong-Zhe Yang static inline 3914cbb145b9SZong-Zhe Yang const struct rtw89_chan_rcd *rtw89_chan_rcd_get(struct rtw89_dev *rtwdev, 3915cbb145b9SZong-Zhe Yang enum rtw89_sub_entity_idx idx) 3916cbb145b9SZong-Zhe Yang { 3917cbb145b9SZong-Zhe Yang struct rtw89_hal *hal = &rtwdev->hal; 3918cbb145b9SZong-Zhe Yang 3919cbb145b9SZong-Zhe Yang return &hal->chan_rcd[idx]; 3920cbb145b9SZong-Zhe Yang } 3921cbb145b9SZong-Zhe Yang 3922e3ec7017SPing-Ke Shih static inline void rtw89_chip_fem_setup(struct rtw89_dev *rtwdev) 3923e3ec7017SPing-Ke Shih { 3924e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3925e3ec7017SPing-Ke Shih 3926e3ec7017SPing-Ke Shih if (chip->ops->fem_setup) 3927e3ec7017SPing-Ke Shih chip->ops->fem_setup(rtwdev); 3928e3ec7017SPing-Ke Shih } 3929e3ec7017SPing-Ke Shih 3930e3ec7017SPing-Ke Shih static inline void rtw89_chip_bb_sethw(struct rtw89_dev *rtwdev) 3931e3ec7017SPing-Ke Shih { 3932e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3933e3ec7017SPing-Ke Shih 3934e3ec7017SPing-Ke Shih if (chip->ops->bb_sethw) 3935e3ec7017SPing-Ke Shih chip->ops->bb_sethw(rtwdev); 3936e3ec7017SPing-Ke Shih } 3937e3ec7017SPing-Ke Shih 3938e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_init(struct rtw89_dev *rtwdev) 3939e3ec7017SPing-Ke Shih { 3940e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3941e3ec7017SPing-Ke Shih 3942e3ec7017SPing-Ke Shih if (chip->ops->rfk_init) 3943e3ec7017SPing-Ke Shih chip->ops->rfk_init(rtwdev); 3944e3ec7017SPing-Ke Shih } 3945e3ec7017SPing-Ke Shih 3946e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_channel(struct rtw89_dev *rtwdev) 3947e3ec7017SPing-Ke Shih { 3948e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3949e3ec7017SPing-Ke Shih 3950e3ec7017SPing-Ke Shih if (chip->ops->rfk_channel) 3951e3ec7017SPing-Ke Shih chip->ops->rfk_channel(rtwdev); 3952e3ec7017SPing-Ke Shih } 3953e3ec7017SPing-Ke Shih 3954010d0051SZong-Zhe Yang static inline void rtw89_chip_rfk_band_changed(struct rtw89_dev *rtwdev, 3955010d0051SZong-Zhe Yang enum rtw89_phy_idx phy_idx) 3956e3ec7017SPing-Ke Shih { 3957e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3958e3ec7017SPing-Ke Shih 3959e3ec7017SPing-Ke Shih if (chip->ops->rfk_band_changed) 3960010d0051SZong-Zhe Yang chip->ops->rfk_band_changed(rtwdev, phy_idx); 3961e3ec7017SPing-Ke Shih } 3962e3ec7017SPing-Ke Shih 3963e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_scan(struct rtw89_dev *rtwdev, bool start) 3964e3ec7017SPing-Ke Shih { 3965e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3966e3ec7017SPing-Ke Shih 3967e3ec7017SPing-Ke Shih if (chip->ops->rfk_scan) 3968e3ec7017SPing-Ke Shih chip->ops->rfk_scan(rtwdev, start); 3969e3ec7017SPing-Ke Shih } 3970e3ec7017SPing-Ke Shih 3971e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_track(struct rtw89_dev *rtwdev) 3972e3ec7017SPing-Ke Shih { 3973e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3974e3ec7017SPing-Ke Shih 3975e3ec7017SPing-Ke Shih if (chip->ops->rfk_track) 3976e3ec7017SPing-Ke Shih chip->ops->rfk_track(rtwdev); 3977e3ec7017SPing-Ke Shih } 3978e3ec7017SPing-Ke Shih 3979e3ec7017SPing-Ke Shih static inline void rtw89_chip_set_txpwr_ctrl(struct rtw89_dev *rtwdev) 3980e3ec7017SPing-Ke Shih { 3981e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3982e3ec7017SPing-Ke Shih 3983e3ec7017SPing-Ke Shih if (chip->ops->set_txpwr_ctrl) 398407ef5f2fSZong-Zhe Yang chip->ops->set_txpwr_ctrl(rtwdev, RTW89_PHY_0); 3985e3ec7017SPing-Ke Shih } 3986e3ec7017SPing-Ke Shih 3987e3ec7017SPing-Ke Shih static inline void rtw89_chip_power_trim(struct rtw89_dev *rtwdev) 3988e3ec7017SPing-Ke Shih { 3989e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3990e3ec7017SPing-Ke Shih 3991e3ec7017SPing-Ke Shih if (chip->ops->power_trim) 3992e3ec7017SPing-Ke Shih chip->ops->power_trim(rtwdev); 3993e3ec7017SPing-Ke Shih } 3994e3ec7017SPing-Ke Shih 3995e3ec7017SPing-Ke Shih static inline void rtw89_chip_init_txpwr_unit(struct rtw89_dev *rtwdev, 3996e3ec7017SPing-Ke Shih enum rtw89_phy_idx phy_idx) 3997e3ec7017SPing-Ke Shih { 3998e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 3999e3ec7017SPing-Ke Shih 4000e3ec7017SPing-Ke Shih if (chip->ops->init_txpwr_unit) 4001e3ec7017SPing-Ke Shih chip->ops->init_txpwr_unit(rtwdev, phy_idx); 4002e3ec7017SPing-Ke Shih } 4003e3ec7017SPing-Ke Shih 4004e3ec7017SPing-Ke Shih static inline u8 rtw89_chip_get_thermal(struct rtw89_dev *rtwdev, 4005e3ec7017SPing-Ke Shih enum rtw89_rf_path rf_path) 4006e3ec7017SPing-Ke Shih { 4007e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4008e3ec7017SPing-Ke Shih 4009e3ec7017SPing-Ke Shih if (!chip->ops->get_thermal) 4010e3ec7017SPing-Ke Shih return 0x10; 4011e3ec7017SPing-Ke Shih 4012e3ec7017SPing-Ke Shih return chip->ops->get_thermal(rtwdev, rf_path); 4013e3ec7017SPing-Ke Shih } 4014e3ec7017SPing-Ke Shih 4015e3ec7017SPing-Ke Shih static inline void rtw89_chip_query_ppdu(struct rtw89_dev *rtwdev, 4016e3ec7017SPing-Ke Shih struct rtw89_rx_phy_ppdu *phy_ppdu, 4017e3ec7017SPing-Ke Shih struct ieee80211_rx_status *status) 4018e3ec7017SPing-Ke Shih { 4019e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4020e3ec7017SPing-Ke Shih 4021e3ec7017SPing-Ke Shih if (chip->ops->query_ppdu) 4022e3ec7017SPing-Ke Shih chip->ops->query_ppdu(rtwdev, phy_ppdu, status); 4023e3ec7017SPing-Ke Shih } 4024e3ec7017SPing-Ke Shih 4025e3ec7017SPing-Ke Shih static inline void rtw89_chip_bb_ctrl_btc_preagc(struct rtw89_dev *rtwdev, 4026e3ec7017SPing-Ke Shih bool bt_en) 4027e3ec7017SPing-Ke Shih { 4028e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4029e3ec7017SPing-Ke Shih 4030e3ec7017SPing-Ke Shih if (chip->ops->bb_ctrl_btc_preagc) 4031e3ec7017SPing-Ke Shih chip->ops->bb_ctrl_btc_preagc(rtwdev, bt_en); 4032e3ec7017SPing-Ke Shih } 4033e3ec7017SPing-Ke Shih 4034cd89a471SPing-Ke Shih static inline void rtw89_chip_cfg_txrx_path(struct rtw89_dev *rtwdev) 4035cd89a471SPing-Ke Shih { 4036cd89a471SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4037cd89a471SPing-Ke Shih 4038cd89a471SPing-Ke Shih if (chip->ops->cfg_txrx_path) 4039cd89a471SPing-Ke Shih chip->ops->cfg_txrx_path(rtwdev); 4040cd89a471SPing-Ke Shih } 4041cd89a471SPing-Ke Shih 4042e3ec7017SPing-Ke Shih static inline 4043e3ec7017SPing-Ke Shih void rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev, 4044e3ec7017SPing-Ke Shih struct ieee80211_vif *vif) 4045e3ec7017SPing-Ke Shih { 4046e3ec7017SPing-Ke Shih struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; 4047e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4048e3ec7017SPing-Ke Shih 4049f276e20bSJohannes Berg if (!vif->bss_conf.he_support || !vif->cfg.assoc) 4050e3ec7017SPing-Ke Shih return; 4051e3ec7017SPing-Ke Shih 4052e3ec7017SPing-Ke Shih if (chip->ops->set_txpwr_ul_tb_offset) 4053e3ec7017SPing-Ke Shih chip->ops->set_txpwr_ul_tb_offset(rtwdev, 0, rtwvif->mac_idx); 4054e3ec7017SPing-Ke Shih } 4055e3ec7017SPing-Ke Shih 4056e3ec7017SPing-Ke Shih static inline void rtw89_load_txpwr_table(struct rtw89_dev *rtwdev, 4057e3ec7017SPing-Ke Shih const struct rtw89_txpwr_table *tbl) 4058e3ec7017SPing-Ke Shih { 4059e3ec7017SPing-Ke Shih tbl->load(rtwdev, tbl); 4060e3ec7017SPing-Ke Shih } 4061e3ec7017SPing-Ke Shih 4062e3ec7017SPing-Ke Shih static inline u8 rtw89_regd_get(struct rtw89_dev *rtwdev, u8 band) 4063e3ec7017SPing-Ke Shih { 4064e3ec7017SPing-Ke Shih return rtwdev->regd->txpwr_regd[band]; 4065e3ec7017SPing-Ke Shih } 4066e3ec7017SPing-Ke Shih 4067e3ec7017SPing-Ke Shih static inline void rtw89_ctrl_btg(struct rtw89_dev *rtwdev, bool btg) 4068e3ec7017SPing-Ke Shih { 4069e3ec7017SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4070e3ec7017SPing-Ke Shih 4071e3ec7017SPing-Ke Shih if (chip->ops->ctrl_btg) 4072e3ec7017SPing-Ke Shih chip->ops->ctrl_btg(rtwdev, btg); 4073e3ec7017SPing-Ke Shih } 4074e3ec7017SPing-Ke Shih 4075feed6541SChia-Yuan Li static inline 4076f59acddeSPing-Ke Shih void rtw89_chip_fill_txdesc(struct rtw89_dev *rtwdev, 4077f59acddeSPing-Ke Shih struct rtw89_tx_desc_info *desc_info, 4078f59acddeSPing-Ke Shih void *txdesc) 4079f59acddeSPing-Ke Shih { 4080f59acddeSPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4081f59acddeSPing-Ke Shih 4082f59acddeSPing-Ke Shih chip->ops->fill_txdesc(rtwdev, desc_info, txdesc); 4083f59acddeSPing-Ke Shih } 4084f59acddeSPing-Ke Shih 4085f59acddeSPing-Ke Shih static inline 4086a95bd62eSPing-Ke Shih void rtw89_chip_fill_txdesc_fwcmd(struct rtw89_dev *rtwdev, 4087a95bd62eSPing-Ke Shih struct rtw89_tx_desc_info *desc_info, 4088a95bd62eSPing-Ke Shih void *txdesc) 4089a95bd62eSPing-Ke Shih { 4090a95bd62eSPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4091a95bd62eSPing-Ke Shih 4092a95bd62eSPing-Ke Shih chip->ops->fill_txdesc_fwcmd(rtwdev, desc_info, txdesc); 4093a95bd62eSPing-Ke Shih } 4094a95bd62eSPing-Ke Shih 4095a95bd62eSPing-Ke Shih static inline 4096feed6541SChia-Yuan Li void rtw89_chip_mac_cfg_gnt(struct rtw89_dev *rtwdev, 4097feed6541SChia-Yuan Li const struct rtw89_mac_ax_coex_gnt *gnt_cfg) 4098feed6541SChia-Yuan Li { 4099feed6541SChia-Yuan Li const struct rtw89_chip_info *chip = rtwdev->chip; 4100feed6541SChia-Yuan Li 4101feed6541SChia-Yuan Li chip->ops->mac_cfg_gnt(rtwdev, gnt_cfg); 4102feed6541SChia-Yuan Li } 4103feed6541SChia-Yuan Li 4104feed6541SChia-Yuan Li static inline void rtw89_chip_cfg_ctrl_path(struct rtw89_dev *rtwdev, bool wl) 4105feed6541SChia-Yuan Li { 4106feed6541SChia-Yuan Li const struct rtw89_chip_info *chip = rtwdev->chip; 4107feed6541SChia-Yuan Li 4108feed6541SChia-Yuan Li chip->ops->cfg_ctrl_path(rtwdev, wl); 4109feed6541SChia-Yuan Li } 4110feed6541SChia-Yuan Li 4111de7ba639SPing-Ke Shih static inline 4112de7ba639SPing-Ke Shih int rtw89_chip_stop_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, 4113de7ba639SPing-Ke Shih u32 *tx_en, enum rtw89_sch_tx_sel sel) 4114de7ba639SPing-Ke Shih { 4115de7ba639SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4116de7ba639SPing-Ke Shih 4117de7ba639SPing-Ke Shih return chip->ops->stop_sch_tx(rtwdev, mac_idx, tx_en, sel); 4118de7ba639SPing-Ke Shih } 4119de7ba639SPing-Ke Shih 4120de7ba639SPing-Ke Shih static inline 4121de7ba639SPing-Ke Shih int rtw89_chip_resume_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en) 4122de7ba639SPing-Ke Shih { 4123de7ba639SPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 4124de7ba639SPing-Ke Shih 4125de7ba639SPing-Ke Shih return chip->ops->resume_sch_tx(rtwdev, mac_idx, tx_en); 4126de7ba639SPing-Ke Shih } 4127de7ba639SPing-Ke Shih 41280a6f299bSPing-Ke Shih static inline 41290a6f299bSPing-Ke Shih int rtw89_chip_h2c_dctl_sec_cam(struct rtw89_dev *rtwdev, 41300a6f299bSPing-Ke Shih struct rtw89_vif *rtwvif, 41310a6f299bSPing-Ke Shih struct rtw89_sta *rtwsta) 41320a6f299bSPing-Ke Shih { 41330a6f299bSPing-Ke Shih const struct rtw89_chip_info *chip = rtwdev->chip; 41340a6f299bSPing-Ke Shih 41350a6f299bSPing-Ke Shih if (!chip->ops->h2c_dctl_sec_cam) 41360a6f299bSPing-Ke Shih return 0; 41370a6f299bSPing-Ke Shih return chip->ops->h2c_dctl_sec_cam(rtwdev, rtwvif, rtwsta); 41380a6f299bSPing-Ke Shih } 41390a6f299bSPing-Ke Shih 4140e3ec7017SPing-Ke Shih static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr) 4141e3ec7017SPing-Ke Shih { 4142e3ec7017SPing-Ke Shih __le16 fc = hdr->frame_control; 4143e3ec7017SPing-Ke Shih 4144e3ec7017SPing-Ke Shih if (ieee80211_has_tods(fc)) 4145e3ec7017SPing-Ke Shih return hdr->addr1; 4146e3ec7017SPing-Ke Shih else if (ieee80211_has_fromds(fc)) 4147e3ec7017SPing-Ke Shih return hdr->addr2; 4148e3ec7017SPing-Ke Shih else 4149e3ec7017SPing-Ke Shih return hdr->addr3; 4150e3ec7017SPing-Ke Shih } 4151e3ec7017SPing-Ke Shih 4152e3ec7017SPing-Ke Shih static inline bool rtw89_sta_has_beamformer_cap(struct ieee80211_sta *sta) 4153e3ec7017SPing-Ke Shih { 4154046d2e7cSSriram R if ((sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) || 4155046d2e7cSSriram R (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) || 4156046d2e7cSSriram R (sta->deflink.he_cap.he_cap_elem.phy_cap_info[3] & 4157046d2e7cSSriram R IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER) || 4158046d2e7cSSriram R (sta->deflink.he_cap.he_cap_elem.phy_cap_info[4] & 4159046d2e7cSSriram R IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER)) 4160e3ec7017SPing-Ke Shih return true; 4161e3ec7017SPing-Ke Shih return false; 4162e3ec7017SPing-Ke Shih } 4163e3ec7017SPing-Ke Shih 4164e3ec7017SPing-Ke Shih static inline struct rtw89_fw_suit *rtw89_fw_suit_get(struct rtw89_dev *rtwdev, 4165e3ec7017SPing-Ke Shih enum rtw89_fw_type type) 4166e3ec7017SPing-Ke Shih { 4167e3ec7017SPing-Ke Shih struct rtw89_fw_info *fw_info = &rtwdev->fw; 4168e3ec7017SPing-Ke Shih 4169e3ec7017SPing-Ke Shih if (type == RTW89_FW_WOWLAN) 4170e3ec7017SPing-Ke Shih return &fw_info->wowlan; 4171e3ec7017SPing-Ke Shih return &fw_info->normal; 4172e3ec7017SPing-Ke Shih } 4173e3ec7017SPing-Ke Shih 4174e3ec7017SPing-Ke Shih int rtw89_core_tx_write(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, 4175e3ec7017SPing-Ke Shih struct ieee80211_sta *sta, struct sk_buff *skb, int *qsel); 4176e3ec7017SPing-Ke Shih int rtw89_h2c_tx(struct rtw89_dev *rtwdev, 4177e3ec7017SPing-Ke Shih struct sk_buff *skb, bool fwdl); 4178e3ec7017SPing-Ke Shih void rtw89_core_tx_kick_off(struct rtw89_dev *rtwdev, u8 qsel); 4179e3ec7017SPing-Ke Shih void rtw89_core_fill_txdesc(struct rtw89_dev *rtwdev, 4180e3ec7017SPing-Ke Shih struct rtw89_tx_desc_info *desc_info, 4181e3ec7017SPing-Ke Shih void *txdesc); 4182f59acddeSPing-Ke Shih void rtw89_core_fill_txdesc_v1(struct rtw89_dev *rtwdev, 4183f59acddeSPing-Ke Shih struct rtw89_tx_desc_info *desc_info, 4184f59acddeSPing-Ke Shih void *txdesc); 4185a95bd62eSPing-Ke Shih void rtw89_core_fill_txdesc_fwcmd_v1(struct rtw89_dev *rtwdev, 4186a95bd62eSPing-Ke Shih struct rtw89_tx_desc_info *desc_info, 4187a95bd62eSPing-Ke Shih void *txdesc); 4188e3ec7017SPing-Ke Shih void rtw89_core_rx(struct rtw89_dev *rtwdev, 4189e3ec7017SPing-Ke Shih struct rtw89_rx_desc_info *desc_info, 4190e3ec7017SPing-Ke Shih struct sk_buff *skb); 4191e3ec7017SPing-Ke Shih void rtw89_core_query_rxdesc(struct rtw89_dev *rtwdev, 4192e3ec7017SPing-Ke Shih struct rtw89_rx_desc_info *desc_info, 4193e3ec7017SPing-Ke Shih u8 *data, u32 data_offset); 4194e3ec7017SPing-Ke Shih void rtw89_core_napi_start(struct rtw89_dev *rtwdev); 4195e3ec7017SPing-Ke Shih void rtw89_core_napi_stop(struct rtw89_dev *rtwdev); 4196e3ec7017SPing-Ke Shih void rtw89_core_napi_init(struct rtw89_dev *rtwdev); 4197e3ec7017SPing-Ke Shih void rtw89_core_napi_deinit(struct rtw89_dev *rtwdev); 4198e3ec7017SPing-Ke Shih int rtw89_core_sta_add(struct rtw89_dev *rtwdev, 4199e3ec7017SPing-Ke Shih struct ieee80211_vif *vif, 4200e3ec7017SPing-Ke Shih struct ieee80211_sta *sta); 4201e3ec7017SPing-Ke Shih int rtw89_core_sta_assoc(struct rtw89_dev *rtwdev, 4202e3ec7017SPing-Ke Shih struct ieee80211_vif *vif, 4203e3ec7017SPing-Ke Shih struct ieee80211_sta *sta); 4204e3ec7017SPing-Ke Shih int rtw89_core_sta_disassoc(struct rtw89_dev *rtwdev, 4205e3ec7017SPing-Ke Shih struct ieee80211_vif *vif, 4206e3ec7017SPing-Ke Shih struct ieee80211_sta *sta); 4207e3ec7017SPing-Ke Shih int rtw89_core_sta_disconnect(struct rtw89_dev *rtwdev, 4208e3ec7017SPing-Ke Shih struct ieee80211_vif *vif, 4209e3ec7017SPing-Ke Shih struct ieee80211_sta *sta); 4210e3ec7017SPing-Ke Shih int rtw89_core_sta_remove(struct rtw89_dev *rtwdev, 4211e3ec7017SPing-Ke Shih struct ieee80211_vif *vif, 4212e3ec7017SPing-Ke Shih struct ieee80211_sta *sta); 4213e3ec7017SPing-Ke Shih int rtw89_core_init(struct rtw89_dev *rtwdev); 4214e3ec7017SPing-Ke Shih void rtw89_core_deinit(struct rtw89_dev *rtwdev); 4215e3ec7017SPing-Ke Shih int rtw89_core_register(struct rtw89_dev *rtwdev); 4216e3ec7017SPing-Ke Shih void rtw89_core_unregister(struct rtw89_dev *rtwdev); 42177fc06a07SZong-Zhe Yang struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device, 42187fc06a07SZong-Zhe Yang u32 bus_data_size, 42197fc06a07SZong-Zhe Yang const struct rtw89_chip_info *chip); 42207fc06a07SZong-Zhe Yang void rtw89_free_ieee80211_hw(struct rtw89_dev *rtwdev); 4221967439c7SZong-Zhe Yang void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev); 4222a88b6cc4SZong-Zhe Yang void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef); 4223e3ec7017SPing-Ke Shih void rtw89_set_channel(struct rtw89_dev *rtwdev); 4224e3ec7017SPing-Ke Shih u8 rtw89_core_acquire_bit_map(unsigned long *addr, unsigned long size); 4225e3ec7017SPing-Ke Shih void rtw89_core_release_bit_map(unsigned long *addr, u8 bit); 4226e3ec7017SPing-Ke Shih void rtw89_core_release_all_bits_map(unsigned long *addr, unsigned int nbits); 42272def7356SPing-Ke Shih int rtw89_core_acquire_sta_ba_entry(struct rtw89_dev *rtwdev, 42282def7356SPing-Ke Shih struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx); 42292def7356SPing-Ke Shih int rtw89_core_release_sta_ba_entry(struct rtw89_dev *rtwdev, 42302def7356SPing-Ke Shih struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx); 4231e3ec7017SPing-Ke Shih void rtw89_vif_type_mapping(struct ieee80211_vif *vif, bool assoc); 4232e3ec7017SPing-Ke Shih int rtw89_chip_info_setup(struct rtw89_dev *rtwdev); 42339a3a593cSPing-Ke Shih bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate); 4234e3ec7017SPing-Ke Shih int rtw89_regd_init(struct rtw89_dev *rtwdev, 4235e3ec7017SPing-Ke Shih void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request)); 4236e3ec7017SPing-Ke Shih void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request); 4237e3ec7017SPing-Ke Shih void rtw89_traffic_stats_init(struct rtw89_dev *rtwdev, 4238e3ec7017SPing-Ke Shih struct rtw89_traffic_stats *stats); 4239e3ec7017SPing-Ke Shih int rtw89_core_start(struct rtw89_dev *rtwdev); 4240e3ec7017SPing-Ke Shih void rtw89_core_stop(struct rtw89_dev *rtwdev); 4241d62816b4SPing-Ke Shih void rtw89_core_update_beacon_work(struct work_struct *work); 424289590777SPo Hao Huang void rtw89_core_scan_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 424389590777SPo Hao Huang const u8 *mac_addr, bool hw_scan); 424489590777SPo Hao Huang void rtw89_core_scan_complete(struct rtw89_dev *rtwdev, 424589590777SPo Hao Huang struct ieee80211_vif *vif, bool hw_scan); 4246e3ec7017SPing-Ke Shih 4247e3ec7017SPing-Ke Shih #endif 4248