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;
17c220d08eSPing-Ke Shih struct rtw89_mac_gen_def;
181165f571SPing-Ke Shih struct rtw89_phy_gen_def;
19e3ec7017SPing-Ke Shih 
20e3ec7017SPing-Ke Shih extern const struct ieee80211_ops rtw89_ops;
21e3ec7017SPing-Ke Shih 
22e3ec7017SPing-Ke Shih #define MASKBYTE0 0xff
23e3ec7017SPing-Ke Shih #define MASKBYTE1 0xff00
24e3ec7017SPing-Ke Shih #define MASKBYTE2 0xff0000
25e3ec7017SPing-Ke Shih #define MASKBYTE3 0xff000000
26e3ec7017SPing-Ke Shih #define MASKBYTE4 0xff00000000ULL
27e3ec7017SPing-Ke Shih #define MASKHWORD 0xffff0000
28e3ec7017SPing-Ke Shih #define MASKLWORD 0x0000ffff
29e3ec7017SPing-Ke Shih #define MASKDWORD 0xffffffff
30e3ec7017SPing-Ke Shih #define RFREG_MASK 0xfffff
31e3ec7017SPing-Ke Shih #define INV_RF_DATA 0xffffffff
32e3ec7017SPing-Ke Shih 
33e3ec7017SPing-Ke Shih #define RTW89_TRACK_WORK_PERIOD	round_jiffies_relative(HZ * 2)
34679955d5SKuan-Chung Chen #define RTW89_FORBID_BA_TIMER round_jiffies_relative(HZ * 4)
35e3ec7017SPing-Ke Shih #define CFO_TRACK_MAX_USER 64
36e3ec7017SPing-Ke Shih #define MAX_RSSI 110
37e3ec7017SPing-Ke Shih #define RSSI_FACTOR 1
38e3ec7017SPing-Ke Shih #define RTW89_RSSI_RAW_TO_DBM(rssi) ((s8)((rssi) >> RSSI_FACTOR) - MAX_RSSI)
397dbdf655SPing-Ke Shih #define RTW89_TX_DIV_RSSI_RAW_TH (2 << RSSI_FACTOR)
4051e8ed4eSPing-Ke Shih #define RTW89_RADIOTAP_ROOM ALIGN(sizeof(struct ieee80211_radiotap_he), 64)
41e3ec7017SPing-Ke Shih 
42e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_VARIANT GENMASK(1, 0)
43e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE 3
44e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_CTL_ID GENMASK(5, 2)
45e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE_CID_OM 1
46e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE_CID_CAS 6
47e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_CTL_INFO GENMASK(31, 6)
48e3ec7017SPing-Ke Shih 
49e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_RX_NSS GENMASK(8, 6)
50e3ec7017SPing-Ke Shih enum htc_om_channel_width {
51e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_20 = 0,
52e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_40 = 1,
53e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_80 = 2,
54e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_160_OR_80_80 = 3,
55e3ec7017SPing-Ke Shih };
56e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_CH_WIDTH GENMASK(10, 9)
57e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_UL_MU_DIS BIT(11)
58e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_TX_NSTS GENMASK(14, 12)
59e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_ER_SU_DIS BIT(15)
60e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_DL_MU_MIMO_RR BIT(16)
61e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_UL_MU_DATA_DIS BIT(17)
62e3ec7017SPing-Ke Shih 
635165f168SPo Hao Huang #define RTW89_TF_PAD GENMASK(11, 0)
645165f168SPo Hao Huang #define RTW89_TF_BASIC_USER_INFO_SZ 6
655165f168SPo Hao Huang 
665165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_AID12(data)	\
675165f168SPo Hao Huang 	le32_get_bits(*((const __le32 *)(data)), GENMASK(11, 0))
685165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_RUA(data)	\
695165f168SPo Hao Huang 	le32_get_bits(*((const __le32 *)(data)), GENMASK(19, 12))
705165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_UL_MCS(data)	\
715165f168SPo Hao Huang 	le32_get_bits(*((const __le32 *)(data)), GENMASK(24, 21))
725165f168SPo Hao Huang 
73e3ec7017SPing-Ke Shih enum rtw89_subband {
74e3ec7017SPing-Ke Shih 	RTW89_CH_2G = 0,
75e3ec7017SPing-Ke Shih 	RTW89_CH_5G_BAND_1 = 1,
76e3ec7017SPing-Ke Shih 	/* RTW89_CH_5G_BAND_2 = 2, unused */
77e3ec7017SPing-Ke Shih 	RTW89_CH_5G_BAND_3 = 3,
78e3ec7017SPing-Ke Shih 	RTW89_CH_5G_BAND_4 = 4,
79e3ec7017SPing-Ke Shih 
808e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX0, /* Low */
818e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX1, /* Low */
828e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX2, /* Mid */
838e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX3, /* Mid */
848e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX4, /* High */
858e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX5, /* High */
868e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX6, /* Ultra-high */
878e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX7, /* Ultra-high */
888e438ad4SZong-Zhe Yang 
89e3ec7017SPing-Ke Shih 	RTW89_SUBBAND_NR,
90134cf7c0SPing-Ke Shih 	RTW89_SUBBAND_2GHZ_5GHZ_NR = RTW89_CH_5G_BAND_4 + 1,
91e3ec7017SPing-Ke Shih };
92e3ec7017SPing-Ke Shih 
93e6b17cbdSPing-Ke Shih enum rtw89_gain_offset {
94e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_2G_CCK,
95e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_2G_OFDM,
96e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_5G_LOW,
97e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_5G_MID,
98e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_5G_HIGH,
99e6b17cbdSPing-Ke Shih 
100e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_NR,
101e6b17cbdSPing-Ke Shih };
102e6b17cbdSPing-Ke Shih 
103e3ec7017SPing-Ke Shih enum rtw89_hci_type {
104e3ec7017SPing-Ke Shih 	RTW89_HCI_TYPE_PCIE,
105e3ec7017SPing-Ke Shih 	RTW89_HCI_TYPE_USB,
106e3ec7017SPing-Ke Shih 	RTW89_HCI_TYPE_SDIO,
107e3ec7017SPing-Ke Shih };
108e3ec7017SPing-Ke Shih 
109e3ec7017SPing-Ke Shih enum rtw89_core_chip_id {
110e3ec7017SPing-Ke Shih 	RTL8852A,
111e3ec7017SPing-Ke Shih 	RTL8852B,
112e3ec7017SPing-Ke Shih 	RTL8852C,
113a6fb2bb8SPing-Ke Shih 	RTL8851B,
114f698afa7SPing-Ke Shih 	RTL8922A,
115f698afa7SPing-Ke Shih };
116f698afa7SPing-Ke Shih 
117f698afa7SPing-Ke Shih enum rtw89_chip_gen {
118f698afa7SPing-Ke Shih 	RTW89_CHIP_AX,
119f698afa7SPing-Ke Shih 	RTW89_CHIP_BE,
120f698afa7SPing-Ke Shih 
121f698afa7SPing-Ke Shih 	RTW89_CHIP_GEN_NUM,
122e3ec7017SPing-Ke Shih };
123e3ec7017SPing-Ke Shih 
124e3ec7017SPing-Ke Shih enum rtw89_cv {
125e3ec7017SPing-Ke Shih 	CHIP_CAV,
126e3ec7017SPing-Ke Shih 	CHIP_CBV,
127e3ec7017SPing-Ke Shih 	CHIP_CCV,
128e3ec7017SPing-Ke Shih 	CHIP_CDV,
129e3ec7017SPing-Ke Shih 	CHIP_CEV,
130e3ec7017SPing-Ke Shih 	CHIP_CFV,
131e3ec7017SPing-Ke Shih 	CHIP_CV_MAX,
132e3ec7017SPing-Ke Shih 	CHIP_CV_INVALID = CHIP_CV_MAX,
133e3ec7017SPing-Ke Shih };
134e3ec7017SPing-Ke Shih 
135b6335d91SPing-Ke Shih enum rtw89_bacam_ver {
136b6335d91SPing-Ke Shih 	RTW89_BACAM_V0,
137b6335d91SPing-Ke Shih 	RTW89_BACAM_V1,
138b6335d91SPing-Ke Shih 
139b6335d91SPing-Ke Shih 	RTW89_BACAM_V0_EXT = 99,
140b6335d91SPing-Ke Shih };
141b6335d91SPing-Ke Shih 
142e3ec7017SPing-Ke Shih enum rtw89_core_tx_type {
143e3ec7017SPing-Ke Shih 	RTW89_CORE_TX_TYPE_DATA,
144e3ec7017SPing-Ke Shih 	RTW89_CORE_TX_TYPE_MGMT,
145e3ec7017SPing-Ke Shih 	RTW89_CORE_TX_TYPE_FWCMD,
146e3ec7017SPing-Ke Shih };
147e3ec7017SPing-Ke Shih 
148e3ec7017SPing-Ke Shih enum rtw89_core_rx_type {
149e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_WIFI		= 0,
150e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_PPDU_STAT	= 1,
151e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_CHAN_INFO	= 2,
152e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_BB_SCOPE	= 3,
153e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_F2P_TXCMD	= 4,
154e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_SS2FW	= 5,
155e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_TX_REPORT	= 6,
156e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_TX_REL_HOST	= 7,
157e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_DFS_REPORT	= 8,
158e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_TX_REL_CPU	= 9,
159e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_C2H		= 10,
160e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_CSI		= 11,
161e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_CQI		= 12,
162a95bd62eSPing-Ke Shih 	RTW89_CORE_RX_TYPE_H2C		= 13,
163a95bd62eSPing-Ke Shih 	RTW89_CORE_RX_TYPE_FWDL		= 14,
164e3ec7017SPing-Ke Shih };
165e3ec7017SPing-Ke Shih 
166e3ec7017SPing-Ke Shih enum rtw89_txq_flags {
167e3ec7017SPing-Ke Shih 	RTW89_TXQ_F_AMPDU		= 0,
168e3ec7017SPing-Ke Shih 	RTW89_TXQ_F_BLOCK_BA		= 1,
169679955d5SKuan-Chung Chen 	RTW89_TXQ_F_FORBID_BA		= 2,
170e3ec7017SPing-Ke Shih };
171e3ec7017SPing-Ke Shih 
172e3ec7017SPing-Ke Shih enum rtw89_net_type {
173e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_NO_LINK		= 0,
174e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_AD_HOC		= 1,
175e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_INFRA		= 2,
176e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_AP_MODE		= 3,
177e3ec7017SPing-Ke Shih };
178e3ec7017SPing-Ke Shih 
179e3ec7017SPing-Ke Shih enum rtw89_wifi_role {
180e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_NONE,
181e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_STATION,
182e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_AP,
183e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_AP_VLAN,
184e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_ADHOC,
185e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_ADHOC_MASTER,
186e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_MESH_POINT,
187e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_MONITOR,
188e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_P2P_DEVICE,
189e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_P2P_CLIENT,
190e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_P2P_GO,
191e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_NAN,
192e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_MLME_MAX
193e3ec7017SPing-Ke Shih };
194e3ec7017SPing-Ke Shih 
195e3ec7017SPing-Ke Shih enum rtw89_upd_mode {
1968b252070SPing-Ke Shih 	RTW89_ROLE_CREATE,
1978b252070SPing-Ke Shih 	RTW89_ROLE_REMOVE,
1988b252070SPing-Ke Shih 	RTW89_ROLE_TYPE_CHANGE,
1998b252070SPing-Ke Shih 	RTW89_ROLE_INFO_CHANGE,
20019e28c7fSChin-Yen Lee 	RTW89_ROLE_CON_DISCONN,
20119e28c7fSChin-Yen Lee 	RTW89_ROLE_BAND_SW,
20219e28c7fSChin-Yen Lee 	RTW89_ROLE_FW_RESTORE,
203e3ec7017SPing-Ke Shih };
204e3ec7017SPing-Ke Shih 
205e3ec7017SPing-Ke Shih enum rtw89_self_role {
206e3ec7017SPing-Ke Shih 	RTW89_SELF_ROLE_CLIENT,
207e3ec7017SPing-Ke Shih 	RTW89_SELF_ROLE_AP,
208e3ec7017SPing-Ke Shih 	RTW89_SELF_ROLE_AP_CLIENT
209e3ec7017SPing-Ke Shih };
210e3ec7017SPing-Ke Shih 
211e3ec7017SPing-Ke Shih enum rtw89_msk_sO_el {
212e3ec7017SPing-Ke Shih 	RTW89_NO_MSK,
213e3ec7017SPing-Ke Shih 	RTW89_SMA,
214e3ec7017SPing-Ke Shih 	RTW89_TMA,
215e3ec7017SPing-Ke Shih 	RTW89_BSSID
216e3ec7017SPing-Ke Shih };
217e3ec7017SPing-Ke Shih 
218e3ec7017SPing-Ke Shih enum rtw89_sch_tx_sel {
219e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_ALL,
220e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_HIQ,
221e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_MG0,
222e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_MACID,
223e3ec7017SPing-Ke Shih };
224e3ec7017SPing-Ke Shih 
225e3ec7017SPing-Ke Shih /* RTW89_ADDR_CAM_SEC_NONE	: not enabled
226e3ec7017SPing-Ke Shih  * RTW89_ADDR_CAM_SEC_ALL_UNI	: 0 - 6 unicast
227e3ec7017SPing-Ke Shih  * RTW89_ADDR_CAM_SEC_NORMAL	: 0 - 1 unicast, 2 - 4 group, 5 - 6 BIP
228e3ec7017SPing-Ke Shih  * RTW89_ADDR_CAM_SEC_4GROUP	: 0 - 1 unicast, 2 - 5 group, 6 BIP
229e3ec7017SPing-Ke Shih  */
230e3ec7017SPing-Ke Shih enum rtw89_add_cam_sec_mode {
231e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_NONE		= 0,
232e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_ALL_UNI	= 1,
233e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_NORMAL	= 2,
234e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_4GROUP	= 3,
235e3ec7017SPing-Ke Shih };
236e3ec7017SPing-Ke Shih 
237e3ec7017SPing-Ke Shih enum rtw89_sec_key_type {
238e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_NONE		= 0,
239e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_WEP40	= 1,
240e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_WEP104	= 2,
241e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_TKIP		= 3,
242e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_WAPI		= 4,
243e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_GCMSMS4	= 5,
244e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_CCMP128	= 6,
245e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_CCMP256	= 7,
246e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_GCMP128	= 8,
247e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_GCMP256	= 9,
248e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_BIP_CCMP128	= 10,
249e3ec7017SPing-Ke Shih };
250e3ec7017SPing-Ke Shih 
251e3ec7017SPing-Ke Shih enum rtw89_port {
252e3ec7017SPing-Ke Shih 	RTW89_PORT_0 = 0,
253e3ec7017SPing-Ke Shih 	RTW89_PORT_1 = 1,
254e3ec7017SPing-Ke Shih 	RTW89_PORT_2 = 2,
255e3ec7017SPing-Ke Shih 	RTW89_PORT_3 = 3,
256e3ec7017SPing-Ke Shih 	RTW89_PORT_4 = 4,
257e3ec7017SPing-Ke Shih 	RTW89_PORT_NUM
258e3ec7017SPing-Ke Shih };
259e3ec7017SPing-Ke Shih 
260e3ec7017SPing-Ke Shih enum rtw89_band {
261e3ec7017SPing-Ke Shih 	RTW89_BAND_2G = 0,
262e3ec7017SPing-Ke Shih 	RTW89_BAND_5G = 1,
2630237f65aSZong-Zhe Yang 	RTW89_BAND_6G = 2,
264b4a283fbSZong-Zhe Yang 	RTW89_BAND_NUM,
265e3ec7017SPing-Ke Shih };
266e3ec7017SPing-Ke Shih 
267e3ec7017SPing-Ke Shih enum rtw89_hw_rate {
268e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK1	= 0x0,
269e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK2	= 0x1,
270e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK5_5	= 0x2,
271e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK11	= 0x3,
272e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM6	= 0x4,
273e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM9	= 0x5,
274e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM12	= 0x6,
275e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM18	= 0x7,
276e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM24	= 0x8,
277e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM36	= 0x9,
278e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM48	= 0xA,
279e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM54	= 0xB,
280e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS0	= 0x80,
281e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS1	= 0x81,
282e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS2	= 0x82,
283e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS3	= 0x83,
284e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS4	= 0x84,
285e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS5	= 0x85,
286e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS6	= 0x86,
287e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS7	= 0x87,
288e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS8	= 0x88,
289e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS9	= 0x89,
290e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS10	= 0x8A,
291e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS11	= 0x8B,
292e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS12	= 0x8C,
293e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS13	= 0x8D,
294e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS14	= 0x8E,
295e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS15	= 0x8F,
296e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS16	= 0x90,
297e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS17	= 0x91,
298e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS18	= 0x92,
299e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS19	= 0x93,
300e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS20	= 0x94,
301e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS21	= 0x95,
302e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS22	= 0x96,
303e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS23	= 0x97,
304e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS24	= 0x98,
305e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS25	= 0x99,
306e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS26	= 0x9A,
307e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS27	= 0x9B,
308e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS28	= 0x9C,
309e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS29	= 0x9D,
310e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS30	= 0x9E,
311e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS31	= 0x9F,
312e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS0	= 0x100,
313e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS1	= 0x101,
314e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS2	= 0x102,
315e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS3	= 0x103,
316e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS4	= 0x104,
317e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS5	= 0x105,
318e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS6	= 0x106,
319e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS7	= 0x107,
320e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS8	= 0x108,
321e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS9	= 0x109,
322e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS0	= 0x110,
323e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS1	= 0x111,
324e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS2	= 0x112,
325e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS3	= 0x113,
326e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS4	= 0x114,
327e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS5	= 0x115,
328e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS6	= 0x116,
329e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS7	= 0x117,
330e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS8	= 0x118,
331e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS9	= 0x119,
332e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS0	= 0x120,
333e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS1	= 0x121,
334e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS2	= 0x122,
335e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS3	= 0x123,
336e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS4	= 0x124,
337e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS5	= 0x125,
338e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS6	= 0x126,
339e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS7	= 0x127,
340e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS8	= 0x128,
341e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS9	= 0x129,
342e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS0	= 0x130,
343e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS1	= 0x131,
344e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS2	= 0x132,
345e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS3	= 0x133,
346e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS4	= 0x134,
347e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS5	= 0x135,
348e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS6	= 0x136,
349e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS7	= 0x137,
350e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS8	= 0x138,
351e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS9	= 0x139,
352e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS0	= 0x180,
353e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS1	= 0x181,
354e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS2	= 0x182,
355e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS3	= 0x183,
356e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS4	= 0x184,
357e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS5	= 0x185,
358e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS6	= 0x186,
359e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS7	= 0x187,
360e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS8	= 0x188,
361e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS9	= 0x189,
362e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS10	= 0x18A,
363e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS11	= 0x18B,
364e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS0	= 0x190,
365e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS1	= 0x191,
366e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS2	= 0x192,
367e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS3	= 0x193,
368e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS4	= 0x194,
369e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS5	= 0x195,
370e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS6	= 0x196,
371e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS7	= 0x197,
372e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS8	= 0x198,
373e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS9	= 0x199,
374e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS10	= 0x19A,
375e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS11	= 0x19B,
376e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS0	= 0x1A0,
377e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS1	= 0x1A1,
378e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS2	= 0x1A2,
379e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS3	= 0x1A3,
380e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS4	= 0x1A4,
381e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS5	= 0x1A5,
382e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS6	= 0x1A6,
383e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS7	= 0x1A7,
384e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS8	= 0x1A8,
385e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS9	= 0x1A9,
386e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS10	= 0x1AA,
387e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS11	= 0x1AB,
388e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS0	= 0x1B0,
389e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS1	= 0x1B1,
390e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS2	= 0x1B2,
391e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS3	= 0x1B3,
392e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS4	= 0x1B4,
393e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS5	= 0x1B5,
394e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS6	= 0x1B6,
395e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS7	= 0x1B7,
396e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS8	= 0x1B8,
397e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS9	= 0x1B9,
398e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS10	= 0x1BA,
399e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS11	= 0x1BB,
4009e5c6c0dSPing-Ke Shih 
4019e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS0		= 0x100,
4029e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS1		= 0x101,
4039e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS2		= 0x102,
4049e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS3		= 0x103,
4059e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS4		= 0x104,
4069e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS5		= 0x105,
4079e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS6		= 0x106,
4089e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS7		= 0x107,
4099e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS8		= 0x108,
4109e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS9		= 0x109,
4119e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS10		= 0x10A,
4129e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS11		= 0x10B,
4139e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS12		= 0x10C,
4149e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS13		= 0x10D,
4159e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS14		= 0x10E,
4169e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS15		= 0x10F,
4179e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS16		= 0x110,
4189e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS17		= 0x111,
4199e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS18		= 0x112,
4209e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS19		= 0x113,
4219e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS20		= 0x114,
4229e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS21		= 0x115,
4239e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS22		= 0x116,
4249e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS23		= 0x117,
4259e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS24		= 0x118,
4269e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS25		= 0x119,
4279e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS26		= 0x11A,
4289e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS27		= 0x11B,
4299e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS28		= 0x11C,
4309e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS29		= 0x11D,
4319e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS30		= 0x11E,
4329e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_MCS31		= 0x11F,
4339e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS0	= 0x200,
4349e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS1	= 0x201,
4359e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS2	= 0x202,
4369e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS3	= 0x203,
4379e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS4	= 0x204,
4389e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS5	= 0x205,
4399e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS6	= 0x206,
4409e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS7	= 0x207,
4419e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS8	= 0x208,
4429e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS9	= 0x209,
4439e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS10	= 0x20A,
4449e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS1_MCS11	= 0x20B,
4459e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS0	= 0x220,
4469e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS1	= 0x221,
4479e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS2	= 0x222,
4489e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS3	= 0x223,
4499e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS4	= 0x224,
4509e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS5	= 0x225,
4519e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS6	= 0x226,
4529e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS7	= 0x227,
4539e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS8	= 0x228,
4549e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS9	= 0x229,
4559e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS10	= 0x22A,
4569e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS2_MCS11	= 0x22B,
4579e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS0	= 0x240,
4589e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS1	= 0x241,
4599e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS2	= 0x242,
4609e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS3	= 0x243,
4619e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS4	= 0x244,
4629e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS5	= 0x245,
4639e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS6	= 0x246,
4649e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS7	= 0x247,
4659e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS8	= 0x248,
4669e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS9	= 0x249,
4679e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS10	= 0x24A,
4689e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS3_MCS11	= 0x24B,
4699e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS0	= 0x260,
4709e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS1	= 0x261,
4719e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS2	= 0x262,
4729e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS3	= 0x263,
4739e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS4	= 0x264,
4749e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS5	= 0x265,
4759e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS6	= 0x266,
4769e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS7	= 0x267,
4779e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS8	= 0x268,
4789e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS9	= 0x269,
4799e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS10	= 0x26A,
4809e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_VHT_NSS4_MCS11	= 0x26B,
4819e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS0	= 0x300,
4829e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS1	= 0x301,
4839e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS2	= 0x302,
4849e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS3	= 0x303,
4859e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS4	= 0x304,
4869e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS5	= 0x305,
4879e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS6	= 0x306,
4889e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS7	= 0x307,
4899e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS8	= 0x308,
4909e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS9	= 0x309,
4919e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS10	= 0x30A,
4929e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS1_MCS11	= 0x30B,
4939e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS0	= 0x320,
4949e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS1	= 0x321,
4959e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS2	= 0x322,
4969e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS3	= 0x323,
4979e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS4	= 0x324,
4989e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS5	= 0x325,
4999e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS6	= 0x326,
5009e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS7	= 0x327,
5019e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS8	= 0x328,
5029e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS9	= 0x329,
5039e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS10	= 0x32A,
5049e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS2_MCS11	= 0x32B,
5059e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS0	= 0x340,
5069e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS1	= 0x341,
5079e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS2	= 0x342,
5089e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS3	= 0x343,
5099e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS4	= 0x344,
5109e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS5	= 0x345,
5119e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS6	= 0x346,
5129e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS7	= 0x347,
5139e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS8	= 0x348,
5149e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS9	= 0x349,
5159e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS10	= 0x34A,
5169e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS3_MCS11	= 0x34B,
5179e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS0	= 0x360,
5189e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS1	= 0x361,
5199e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS2	= 0x362,
5209e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS3	= 0x363,
5219e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS4	= 0x364,
5229e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS5	= 0x365,
5239e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS6	= 0x366,
5249e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS7	= 0x367,
5259e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS8	= 0x368,
5269e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS9	= 0x369,
5279e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS10	= 0x36A,
5289e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_HE_NSS4_MCS11	= 0x36B,
5299e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS0	= 0x400,
5309e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS1	= 0x401,
5319e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS2	= 0x402,
5329e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS3	= 0x403,
5339e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS4	= 0x404,
5349e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS5	= 0x405,
5359e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS6	= 0x406,
5369e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS7	= 0x407,
5379e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS8	= 0x408,
5389e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS9	= 0x409,
5399e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS10	= 0x40A,
5409e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS11	= 0x40B,
5419e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS12	= 0x40C,
5429e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS13	= 0x40D,
5439e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS14	= 0x40E,
5449e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS1_MCS15	= 0x40F,
5459e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS0	= 0x420,
5469e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS1	= 0x421,
5479e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS2	= 0x422,
5489e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS3	= 0x423,
5499e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS4	= 0x424,
5509e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS5	= 0x425,
5519e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS6	= 0x426,
5529e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS7	= 0x427,
5539e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS8	= 0x428,
5549e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS9	= 0x429,
5559e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS10	= 0x42A,
5569e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS11	= 0x42B,
5579e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS12	= 0x42C,
5589e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS2_MCS13	= 0x42D,
5599e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS0	= 0x440,
5609e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS1	= 0x441,
5619e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS2	= 0x442,
5629e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS3	= 0x443,
5639e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS4	= 0x444,
5649e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS5	= 0x445,
5659e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS6	= 0x446,
5669e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS7	= 0x447,
5679e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS8	= 0x448,
5689e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS9	= 0x449,
5699e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS10	= 0x44A,
5709e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS11	= 0x44B,
5719e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS12	= 0x44C,
5729e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS3_MCS13	= 0x44D,
5739e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS0	= 0x460,
5749e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS1	= 0x461,
5759e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS2	= 0x462,
5769e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS3	= 0x463,
5779e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS4	= 0x464,
5789e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS5	= 0x465,
5799e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS6	= 0x466,
5809e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS7	= 0x467,
5819e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS8	= 0x468,
5829e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS9	= 0x469,
5839e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS10	= 0x46A,
5849e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS11	= 0x46B,
5859e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS12	= 0x46C,
5869e5c6c0dSPing-Ke Shih 	RTW89_HW_RATE_V1_EHT_NSS4_MCS13	= 0x46D,
5879e5c6c0dSPing-Ke Shih 
588e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_NR,
589ae775faaSPing-Ke Shih 	RTW89_HW_RATE_INVAL,
590e3ec7017SPing-Ke Shih 
591e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MASK_MOD = GENMASK(8, 7),
592e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MASK_VAL = GENMASK(6, 0),
5935c152231SPing-Ke Shih 	RTW89_HW_RATE_V1_MASK_MOD = GENMASK(10, 8),
5945c152231SPing-Ke Shih 	RTW89_HW_RATE_V1_MASK_VAL = GENMASK(7, 0),
595e3ec7017SPing-Ke Shih };
596e3ec7017SPing-Ke Shih 
597e3ec7017SPing-Ke Shih /* 2G channels,
598e3ec7017SPing-Ke Shih  * 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
599e3ec7017SPing-Ke Shih  */
600e3ec7017SPing-Ke Shih #define RTW89_2G_CH_NUM 14
601e3ec7017SPing-Ke Shih 
602e3ec7017SPing-Ke Shih /* 5G channels,
603e3ec7017SPing-Ke Shih  * 36, 38, 40, 42, 44, 46, 48, 50,
604e3ec7017SPing-Ke Shih  * 52, 54, 56, 58, 60, 62, 64,
605e3ec7017SPing-Ke Shih  * 100, 102, 104, 106, 108, 110, 112, 114,
606e3ec7017SPing-Ke Shih  * 116, 118, 120, 122, 124, 126, 128, 130,
607e3ec7017SPing-Ke Shih  * 132, 134, 136, 138, 140, 142, 144,
608e3ec7017SPing-Ke Shih  * 149, 151, 153, 155, 157, 159, 161, 163,
609e3ec7017SPing-Ke Shih  * 165, 167, 169, 171, 173, 175, 177
610e3ec7017SPing-Ke Shih  */
611e3ec7017SPing-Ke Shih #define RTW89_5G_CH_NUM 53
612e3ec7017SPing-Ke Shih 
613ac74f016SZong-Zhe Yang /* 6G channels,
614ac74f016SZong-Zhe Yang  * 1, 3, 5, 7, 9, 11, 13, 15,
615ac74f016SZong-Zhe Yang  * 17, 19, 21, 23, 25, 27, 29, 33,
616ac74f016SZong-Zhe Yang  * 35, 37, 39, 41, 43, 45, 47, 49,
617ac74f016SZong-Zhe Yang  * 51, 53, 55, 57, 59, 61, 65, 67,
618ac74f016SZong-Zhe Yang  * 69, 71, 73, 75, 77, 79, 81, 83,
619ac74f016SZong-Zhe Yang  * 85, 87, 89, 91, 93, 97, 99, 101,
620ac74f016SZong-Zhe Yang  * 103, 105, 107, 109, 111, 113, 115, 117,
621ac74f016SZong-Zhe Yang  * 119, 121, 123, 125, 129, 131, 133, 135,
622ac74f016SZong-Zhe Yang  * 137, 139, 141, 143, 145, 147, 149, 151,
623ac74f016SZong-Zhe Yang  * 153, 155, 157, 161, 163, 165, 167, 169,
624ac74f016SZong-Zhe Yang  * 171, 173, 175, 177, 179, 181, 183, 185,
625ac74f016SZong-Zhe Yang  * 187, 189, 193, 195, 197, 199, 201, 203,
626ac74f016SZong-Zhe Yang  * 205, 207, 209, 211, 213, 215, 217, 219,
627ac74f016SZong-Zhe Yang  * 221, 225, 227, 229, 231, 233, 235, 237,
628ac74f016SZong-Zhe Yang  * 239, 241, 243, 245, 247, 249, 251, 253,
629ac74f016SZong-Zhe Yang  */
630ac74f016SZong-Zhe Yang #define RTW89_6G_CH_NUM 120
631ac74f016SZong-Zhe Yang 
632e3ec7017SPing-Ke Shih enum rtw89_rate_section {
633e3ec7017SPing-Ke Shih 	RTW89_RS_CCK,
634e3ec7017SPing-Ke Shih 	RTW89_RS_OFDM,
635e3ec7017SPing-Ke Shih 	RTW89_RS_MCS, /* for HT/VHT/HE */
636e3ec7017SPing-Ke Shih 	RTW89_RS_HEDCM,
637e3ec7017SPing-Ke Shih 	RTW89_RS_OFFSET,
638b4a283fbSZong-Zhe Yang 	RTW89_RS_NUM,
639e3ec7017SPing-Ke Shih 	RTW89_RS_LMT_NUM = RTW89_RS_MCS + 1,
640342475acSPing-Ke Shih 	RTW89_RS_TX_SHAPE_NUM = RTW89_RS_OFDM + 1,
641e3ec7017SPing-Ke Shih };
642e3ec7017SPing-Ke Shih 
643b4a283fbSZong-Zhe Yang enum rtw89_rate_num {
644b4a283fbSZong-Zhe Yang 	RTW89_RATE_CCK_NUM	= 4,
645b4a283fbSZong-Zhe Yang 	RTW89_RATE_OFDM_NUM	= 8,
646b4a283fbSZong-Zhe Yang 	RTW89_RATE_MCS_NUM	= 12,
647b4a283fbSZong-Zhe Yang 	RTW89_RATE_HEDCM_NUM	= 4, /* for HEDCM MCS0/1/3/4 */
648b4a283fbSZong-Zhe Yang 	RTW89_RATE_OFFSET_NUM	= 5, /* for HE(HEDCM)/VHT/HT/OFDM/CCK offset */
649e3ec7017SPing-Ke Shih };
650e3ec7017SPing-Ke Shih 
651e3ec7017SPing-Ke Shih enum rtw89_nss {
652e3ec7017SPing-Ke Shih 	RTW89_NSS_1		= 0,
653e3ec7017SPing-Ke Shih 	RTW89_NSS_2		= 1,
654e3ec7017SPing-Ke Shih 	/* HE DCM only support 1ss and 2ss */
655b4a283fbSZong-Zhe Yang 	RTW89_NSS_HEDCM_NUM	= RTW89_NSS_2 + 1,
656e3ec7017SPing-Ke Shih 	RTW89_NSS_3		= 2,
657e3ec7017SPing-Ke Shih 	RTW89_NSS_4		= 3,
658b4a283fbSZong-Zhe Yang 	RTW89_NSS_NUM,
659e3ec7017SPing-Ke Shih };
660e3ec7017SPing-Ke Shih 
661e3ec7017SPing-Ke Shih enum rtw89_ntx {
662e3ec7017SPing-Ke Shih 	RTW89_1TX	= 0,
663e3ec7017SPing-Ke Shih 	RTW89_2TX	= 1,
664e3ec7017SPing-Ke Shih 	RTW89_NTX_NUM,
665e3ec7017SPing-Ke Shih };
666e3ec7017SPing-Ke Shih 
667e3ec7017SPing-Ke Shih enum rtw89_beamforming_type {
668e3ec7017SPing-Ke Shih 	RTW89_NONBF	= 0,
669e3ec7017SPing-Ke Shih 	RTW89_BF	= 1,
670e3ec7017SPing-Ke Shih 	RTW89_BF_NUM,
671e3ec7017SPing-Ke Shih };
672e3ec7017SPing-Ke Shih 
673e3ec7017SPing-Ke Shih enum rtw89_regulation_type {
674e3ec7017SPing-Ke Shih 	RTW89_WW	= 0,
675e3ec7017SPing-Ke Shih 	RTW89_ETSI	= 1,
676e3ec7017SPing-Ke Shih 	RTW89_FCC	= 2,
677e3ec7017SPing-Ke Shih 	RTW89_MKK	= 3,
678e3ec7017SPing-Ke Shih 	RTW89_NA	= 4,
679e3ec7017SPing-Ke Shih 	RTW89_IC	= 5,
680e3ec7017SPing-Ke Shih 	RTW89_KCC	= 6,
68154257714SZong-Zhe Yang 	RTW89_ACMA	= 7,
68254257714SZong-Zhe Yang 	RTW89_NCC	= 8,
68354257714SZong-Zhe Yang 	RTW89_MEXICO	= 9,
68454257714SZong-Zhe Yang 	RTW89_CHILE	= 10,
685e3ec7017SPing-Ke Shih 	RTW89_UKRAINE	= 11,
686e3ec7017SPing-Ke Shih 	RTW89_CN	= 12,
68754257714SZong-Zhe Yang 	RTW89_QATAR	= 13,
6885a0e776bSZong-Zhe Yang 	RTW89_UK	= 14,
689e3ec7017SPing-Ke Shih 	RTW89_REGD_NUM,
690e3ec7017SPing-Ke Shih };
691e3ec7017SPing-Ke Shih 
692f6baa1d3SZong-Zhe Yang enum rtw89_reg_6ghz_power {
693f6baa1d3SZong-Zhe Yang 	RTW89_REG_6GHZ_POWER_VLP = 0,
694f6baa1d3SZong-Zhe Yang 	RTW89_REG_6GHZ_POWER_LPI = 1,
695f6baa1d3SZong-Zhe Yang 	RTW89_REG_6GHZ_POWER_STD = 2,
696f6baa1d3SZong-Zhe Yang 
697f6baa1d3SZong-Zhe Yang 	NUM_OF_RTW89_REG_6GHZ_POWER,
698f6baa1d3SZong-Zhe Yang 	RTW89_REG_6GHZ_POWER_DFLT = RTW89_REG_6GHZ_POWER_VLP,
699f6baa1d3SZong-Zhe Yang };
700f6baa1d3SZong-Zhe Yang 
701ee88d748SChin-Yen Lee enum rtw89_fw_pkt_ofld_type {
702ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_PROBE_RSP = 0,
703ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_PS_POLL = 1,
704ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_NULL_DATA = 2,
705ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_QOS_NULL = 3,
706ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_CTS2SELF = 4,
707ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_ARP_RSP = 5,
708ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_NDP = 6,
709ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_EAPOL_KEY = 7,
710ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_SA_QUERY = 8,
711ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_PROBE_REQ = 12,
712ee88d748SChin-Yen Lee 	RTW89_PKT_OFLD_TYPE_NUM,
713ee88d748SChin-Yen Lee };
714ee88d748SChin-Yen Lee 
715e3ec7017SPing-Ke Shih struct rtw89_txpwr_byrate {
716b4a283fbSZong-Zhe Yang 	s8 cck[RTW89_RATE_CCK_NUM];
717b4a283fbSZong-Zhe Yang 	s8 ofdm[RTW89_RATE_OFDM_NUM];
718b4a283fbSZong-Zhe Yang 	s8 mcs[RTW89_NSS_NUM][RTW89_RATE_MCS_NUM];
719b4a283fbSZong-Zhe Yang 	s8 hedcm[RTW89_NSS_HEDCM_NUM][RTW89_RATE_HEDCM_NUM];
720b4a283fbSZong-Zhe Yang 	s8 offset[RTW89_RATE_OFFSET_NUM];
721e3ec7017SPing-Ke Shih };
722e3ec7017SPing-Ke Shih 
723e3ec7017SPing-Ke Shih enum rtw89_bandwidth_section_num {
724e3ec7017SPing-Ke Shih 	RTW89_BW20_SEC_NUM = 8,
725e3ec7017SPing-Ke Shih 	RTW89_BW40_SEC_NUM = 4,
726e3ec7017SPing-Ke Shih 	RTW89_BW80_SEC_NUM = 2,
727e3ec7017SPing-Ke Shih };
728e3ec7017SPing-Ke Shih 
7299b43bd1aSZong-Zhe Yang #define RTW89_TXPWR_LMT_PAGE_SIZE 40
7309b43bd1aSZong-Zhe Yang 
731e3ec7017SPing-Ke Shih struct rtw89_txpwr_limit {
732e3ec7017SPing-Ke Shih 	s8 cck_20m[RTW89_BF_NUM];
733e3ec7017SPing-Ke Shih 	s8 cck_40m[RTW89_BF_NUM];
734e3ec7017SPing-Ke Shih 	s8 ofdm[RTW89_BF_NUM];
735e3ec7017SPing-Ke Shih 	s8 mcs_20m[RTW89_BW20_SEC_NUM][RTW89_BF_NUM];
736e3ec7017SPing-Ke Shih 	s8 mcs_40m[RTW89_BW40_SEC_NUM][RTW89_BF_NUM];
737e3ec7017SPing-Ke Shih 	s8 mcs_80m[RTW89_BW80_SEC_NUM][RTW89_BF_NUM];
738e3ec7017SPing-Ke Shih 	s8 mcs_160m[RTW89_BF_NUM];
739e3ec7017SPing-Ke Shih 	s8 mcs_40m_0p5[RTW89_BF_NUM];
740e3ec7017SPing-Ke Shih 	s8 mcs_40m_2p5[RTW89_BF_NUM];
741e3ec7017SPing-Ke Shih };
742e3ec7017SPing-Ke Shih 
743e3ec7017SPing-Ke Shih #define RTW89_RU_SEC_NUM 8
744e3ec7017SPing-Ke Shih 
7459b43bd1aSZong-Zhe Yang #define RTW89_TXPWR_LMT_RU_PAGE_SIZE 24
7469b43bd1aSZong-Zhe Yang 
747e3ec7017SPing-Ke Shih struct rtw89_txpwr_limit_ru {
748e3ec7017SPing-Ke Shih 	s8 ru26[RTW89_RU_SEC_NUM];
749e3ec7017SPing-Ke Shih 	s8 ru52[RTW89_RU_SEC_NUM];
750e3ec7017SPing-Ke Shih 	s8 ru106[RTW89_RU_SEC_NUM];
751e3ec7017SPing-Ke Shih };
752e3ec7017SPing-Ke Shih 
753e3ec7017SPing-Ke Shih struct rtw89_rate_desc {
754e3ec7017SPing-Ke Shih 	enum rtw89_nss nss;
755e3ec7017SPing-Ke Shih 	enum rtw89_rate_section rs;
756e3ec7017SPing-Ke Shih 	u8 idx;
757e3ec7017SPing-Ke Shih };
758e3ec7017SPing-Ke Shih 
759e3ec7017SPing-Ke Shih #define PHY_STS_HDR_LEN 8
760e3ec7017SPing-Ke Shih #define RF_PATH_MAX 4
761e3ec7017SPing-Ke Shih #define RTW89_MAX_PPDU_CNT 8
762e3ec7017SPing-Ke Shih struct rtw89_rx_phy_ppdu {
763332debb8SPing-Ke Shih 	void *buf;
764e3ec7017SPing-Ke Shih 	u32 len;
765e3ec7017SPing-Ke Shih 	u8 rssi_avg;
7666ce472d6SPing-Ke Shih 	u8 rssi[RF_PATH_MAX];
767e3ec7017SPing-Ke Shih 	u8 mac_id;
768eb4e52b3SPo Hao Huang 	u8 chan_idx;
769eb4e52b3SPo Hao Huang 	u8 ie;
770eb4e52b3SPo Hao Huang 	u16 rate;
7714bb223a1SPing-Ke Shih 	struct {
7724bb223a1SPing-Ke Shih 		bool has;
7734bb223a1SPing-Ke Shih 		u8 avg_snr;
7744bb223a1SPing-Ke Shih 		u8 evm_max;
7754bb223a1SPing-Ke Shih 		u8 evm_min;
7764bb223a1SPing-Ke Shih 	} ofdm;
777e3ec7017SPing-Ke Shih 	bool to_self;
778e3ec7017SPing-Ke Shih 	bool valid;
779e3ec7017SPing-Ke Shih };
780e3ec7017SPing-Ke Shih 
781e3ec7017SPing-Ke Shih enum rtw89_mac_idx {
782e3ec7017SPing-Ke Shih 	RTW89_MAC_0 = 0,
783e3ec7017SPing-Ke Shih 	RTW89_MAC_1 = 1,
784e3ec7017SPing-Ke Shih };
785e3ec7017SPing-Ke Shih 
786e3ec7017SPing-Ke Shih enum rtw89_phy_idx {
787e3ec7017SPing-Ke Shih 	RTW89_PHY_0 = 0,
788e3ec7017SPing-Ke Shih 	RTW89_PHY_1 = 1,
789e3ec7017SPing-Ke Shih 	RTW89_PHY_MAX
790e3ec7017SPing-Ke Shih };
791e3ec7017SPing-Ke Shih 
792cbb145b9SZong-Zhe Yang enum rtw89_sub_entity_idx {
793cbb145b9SZong-Zhe Yang 	RTW89_SUB_ENTITY_0 = 0,
7944843aa37SZong-Zhe Yang 	RTW89_SUB_ENTITY_1 = 1,
795cbb145b9SZong-Zhe Yang 
796cbb145b9SZong-Zhe Yang 	NUM_OF_RTW89_SUB_ENTITY,
797a0e97ae3SPo-Hao Huang 	RTW89_SUB_ENTITY_IDLE = NUM_OF_RTW89_SUB_ENTITY,
798cbb145b9SZong-Zhe Yang };
799cbb145b9SZong-Zhe Yang 
800e3ec7017SPing-Ke Shih enum rtw89_rf_path {
801e3ec7017SPing-Ke Shih 	RF_PATH_A = 0,
802e3ec7017SPing-Ke Shih 	RF_PATH_B = 1,
803e3ec7017SPing-Ke Shih 	RF_PATH_C = 2,
804e3ec7017SPing-Ke Shih 	RF_PATH_D = 3,
805e3ec7017SPing-Ke Shih 	RF_PATH_AB,
806e3ec7017SPing-Ke Shih 	RF_PATH_AC,
807e3ec7017SPing-Ke Shih 	RF_PATH_AD,
808e3ec7017SPing-Ke Shih 	RF_PATH_BC,
809e3ec7017SPing-Ke Shih 	RF_PATH_BD,
810e3ec7017SPing-Ke Shih 	RF_PATH_CD,
811e3ec7017SPing-Ke Shih 	RF_PATH_ABC,
812e3ec7017SPing-Ke Shih 	RF_PATH_ABD,
813e3ec7017SPing-Ke Shih 	RF_PATH_ACD,
814e3ec7017SPing-Ke Shih 	RF_PATH_BCD,
815e3ec7017SPing-Ke Shih 	RF_PATH_ABCD,
816e3ec7017SPing-Ke Shih };
817e3ec7017SPing-Ke Shih 
818e3ec7017SPing-Ke Shih enum rtw89_rf_path_bit {
819e3ec7017SPing-Ke Shih 	RF_A	= BIT(0),
820e3ec7017SPing-Ke Shih 	RF_B	= BIT(1),
821e3ec7017SPing-Ke Shih 	RF_C	= BIT(2),
822e3ec7017SPing-Ke Shih 	RF_D	= BIT(3),
823e3ec7017SPing-Ke Shih 
824e3ec7017SPing-Ke Shih 	RF_AB	= (RF_A | RF_B),
825e3ec7017SPing-Ke Shih 	RF_AC	= (RF_A | RF_C),
826e3ec7017SPing-Ke Shih 	RF_AD	= (RF_A | RF_D),
827e3ec7017SPing-Ke Shih 	RF_BC	= (RF_B | RF_C),
828e3ec7017SPing-Ke Shih 	RF_BD	= (RF_B | RF_D),
829e3ec7017SPing-Ke Shih 	RF_CD	= (RF_C | RF_D),
830e3ec7017SPing-Ke Shih 
831e3ec7017SPing-Ke Shih 	RF_ABC	= (RF_A | RF_B | RF_C),
832e3ec7017SPing-Ke Shih 	RF_ABD	= (RF_A | RF_B | RF_D),
833e3ec7017SPing-Ke Shih 	RF_ACD	= (RF_A | RF_C | RF_D),
834e3ec7017SPing-Ke Shih 	RF_BCD	= (RF_B | RF_C | RF_D),
835e3ec7017SPing-Ke Shih 
836e3ec7017SPing-Ke Shih 	RF_ABCD	= (RF_A | RF_B | RF_C | RF_D),
837e3ec7017SPing-Ke Shih };
838e3ec7017SPing-Ke Shih 
839e3ec7017SPing-Ke Shih enum rtw89_bandwidth {
840e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_20	= 0,
841e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_40	= 1,
842e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_80	= 2,
843e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_160	= 3,
844e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_80_80	= 4,
845e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_5	= 5,
846e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_10	= 6,
847e3ec7017SPing-Ke Shih };
848e3ec7017SPing-Ke Shih 
849e3ec7017SPing-Ke Shih enum rtw89_ps_mode {
850e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_NONE	= 0,
851e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_RFOFF	= 1,
852e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_CLK_GATED	= 2,
853e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_PWR_GATED	= 3,
854e3ec7017SPing-Ke Shih };
855e3ec7017SPing-Ke Shih 
856e3ec7017SPing-Ke Shih #define RTW89_2G_BW_NUM (RTW89_CHANNEL_WIDTH_40 + 1)
85794b70cafSZong-Zhe Yang #define RTW89_5G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
858ac74f016SZong-Zhe Yang #define RTW89_6G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
859aa7f148bSPing-Ke Shih #define RTW89_PPE_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
860e3ec7017SPing-Ke Shih 
861e3ec7017SPing-Ke Shih enum rtw89_ru_bandwidth {
862e3ec7017SPing-Ke Shih 	RTW89_RU26 = 0,
863e3ec7017SPing-Ke Shih 	RTW89_RU52 = 1,
864e3ec7017SPing-Ke Shih 	RTW89_RU106 = 2,
865e3ec7017SPing-Ke Shih 	RTW89_RU_NUM,
866e3ec7017SPing-Ke Shih };
867e3ec7017SPing-Ke Shih 
868e3ec7017SPing-Ke Shih enum rtw89_sc_offset {
869e3ec7017SPing-Ke Shih 	RTW89_SC_DONT_CARE	= 0,
870e3ec7017SPing-Ke Shih 	RTW89_SC_20_UPPER	= 1,
871e3ec7017SPing-Ke Shih 	RTW89_SC_20_LOWER	= 2,
872e3ec7017SPing-Ke Shih 	RTW89_SC_20_UPMOST	= 3,
873e3ec7017SPing-Ke Shih 	RTW89_SC_20_LOWEST	= 4,
874e715f10fSPing-Ke Shih 	RTW89_SC_20_UP2X	= 5,
875e715f10fSPing-Ke Shih 	RTW89_SC_20_LOW2X	= 6,
876e715f10fSPing-Ke Shih 	RTW89_SC_20_UP3X	= 7,
877e715f10fSPing-Ke Shih 	RTW89_SC_20_LOW3X	= 8,
878e3ec7017SPing-Ke Shih 	RTW89_SC_40_UPPER	= 9,
879e3ec7017SPing-Ke Shih 	RTW89_SC_40_LOWER	= 10,
880e3ec7017SPing-Ke Shih };
881e3ec7017SPing-Ke Shih 
882ee88d748SChin-Yen Lee enum rtw89_wow_flags {
883ee88d748SChin-Yen Lee 	RTW89_WOW_FLAG_EN_MAGIC_PKT,
884ee88d748SChin-Yen Lee 	RTW89_WOW_FLAG_EN_REKEY_PKT,
885ee88d748SChin-Yen Lee 	RTW89_WOW_FLAG_EN_DISCONNECT,
886ee88d748SChin-Yen Lee 	RTW89_WOW_FLAG_NUM,
887ee88d748SChin-Yen Lee };
888ee88d748SChin-Yen Lee 
8893e5831caSZong-Zhe Yang struct rtw89_chan {
8903e5831caSZong-Zhe Yang 	u8 channel;
8913e5831caSZong-Zhe Yang 	u8 primary_channel;
8923e5831caSZong-Zhe Yang 	enum rtw89_band band_type;
8933e5831caSZong-Zhe Yang 	enum rtw89_bandwidth band_width;
894bb8152b3SZong-Zhe Yang 
895bb8152b3SZong-Zhe Yang 	/* The follow-up are derived from the above. We must ensure that it
896bb8152b3SZong-Zhe Yang 	 * is assigned correctly in rtw89_chan_create() if new one is added.
897bb8152b3SZong-Zhe Yang 	 */
898bb8152b3SZong-Zhe Yang 	u32 freq;
8993e5831caSZong-Zhe Yang 	enum rtw89_subband subband_type;
9003e5831caSZong-Zhe Yang 	enum rtw89_sc_offset pri_ch_idx;
901e3ec7017SPing-Ke Shih };
902e3ec7017SPing-Ke Shih 
903cbb145b9SZong-Zhe Yang struct rtw89_chan_rcd {
904cbb145b9SZong-Zhe Yang 	u8 prev_primary_channel;
905cbb145b9SZong-Zhe Yang 	enum rtw89_band prev_band_type;
9064843aa37SZong-Zhe Yang 	bool band_changed;
907cbb145b9SZong-Zhe Yang };
908cbb145b9SZong-Zhe Yang 
909e3ec7017SPing-Ke Shih struct rtw89_channel_help_params {
910d780f926SPing-Ke Shih 	u32 tx_en;
911e3ec7017SPing-Ke Shih };
912e3ec7017SPing-Ke Shih 
913e3ec7017SPing-Ke Shih struct rtw89_port_reg {
914e3ec7017SPing-Ke Shih 	u32 port_cfg;
915e3ec7017SPing-Ke Shih 	u32 tbtt_prohib;
916e3ec7017SPing-Ke Shih 	u32 bcn_area;
917e3ec7017SPing-Ke Shih 	u32 bcn_early;
918e3ec7017SPing-Ke Shih 	u32 tbtt_early;
919e3ec7017SPing-Ke Shih 	u32 tbtt_agg;
920e3ec7017SPing-Ke Shih 	u32 bcn_space;
921e3ec7017SPing-Ke Shih 	u32 bcn_forcetx;
922e3ec7017SPing-Ke Shih 	u32 bcn_err_cnt;
923e3ec7017SPing-Ke Shih 	u32 bcn_err_flag;
924e3ec7017SPing-Ke Shih 	u32 dtim_ctrl;
925e3ec7017SPing-Ke Shih 	u32 tbtt_shift;
926e3ec7017SPing-Ke Shih 	u32 bcn_cnt_tmr;
927e3ec7017SPing-Ke Shih 	u32 tsftr_l;
928e3ec7017SPing-Ke Shih 	u32 tsftr_h;
929e3ec7017SPing-Ke Shih };
930e3ec7017SPing-Ke Shih 
931e3ec7017SPing-Ke Shih struct rtw89_txwd_body {
932e3ec7017SPing-Ke Shih 	__le32 dword0;
933e3ec7017SPing-Ke Shih 	__le32 dword1;
934e3ec7017SPing-Ke Shih 	__le32 dword2;
935e3ec7017SPing-Ke Shih 	__le32 dword3;
936e3ec7017SPing-Ke Shih 	__le32 dword4;
937e3ec7017SPing-Ke Shih 	__le32 dword5;
938e3ec7017SPing-Ke Shih } __packed;
939e3ec7017SPing-Ke Shih 
940f59acddeSPing-Ke Shih struct rtw89_txwd_body_v1 {
941f59acddeSPing-Ke Shih 	__le32 dword0;
942f59acddeSPing-Ke Shih 	__le32 dword1;
943f59acddeSPing-Ke Shih 	__le32 dword2;
944f59acddeSPing-Ke Shih 	__le32 dword3;
945f59acddeSPing-Ke Shih 	__le32 dword4;
946f59acddeSPing-Ke Shih 	__le32 dword5;
947f59acddeSPing-Ke Shih 	__le32 dword6;
948f59acddeSPing-Ke Shih 	__le32 dword7;
949f59acddeSPing-Ke Shih } __packed;
950f59acddeSPing-Ke Shih 
951e3ec7017SPing-Ke Shih struct rtw89_txwd_info {
952e3ec7017SPing-Ke Shih 	__le32 dword0;
953e3ec7017SPing-Ke Shih 	__le32 dword1;
954e3ec7017SPing-Ke Shih 	__le32 dword2;
955e3ec7017SPing-Ke Shih 	__le32 dword3;
956e3ec7017SPing-Ke Shih 	__le32 dword4;
957e3ec7017SPing-Ke Shih 	__le32 dword5;
958e3ec7017SPing-Ke Shih } __packed;
959e3ec7017SPing-Ke Shih 
960e3ec7017SPing-Ke Shih struct rtw89_rx_desc_info {
961e3ec7017SPing-Ke Shih 	u16 pkt_size;
962e3ec7017SPing-Ke Shih 	u8 pkt_type;
963e3ec7017SPing-Ke Shih 	u8 drv_info_size;
964e3ec7017SPing-Ke Shih 	u8 shift;
965e3ec7017SPing-Ke Shih 	u8 wl_hd_iv_len;
966e3ec7017SPing-Ke Shih 	bool long_rxdesc;
967e3ec7017SPing-Ke Shih 	bool bb_sel;
968e3ec7017SPing-Ke Shih 	bool mac_info_valid;
969e3ec7017SPing-Ke Shih 	u16 data_rate;
970e3ec7017SPing-Ke Shih 	u8 gi_ltf;
971e3ec7017SPing-Ke Shih 	u8 bw;
972e3ec7017SPing-Ke Shih 	u32 free_run_cnt;
973e3ec7017SPing-Ke Shih 	u8 user_id;
974e3ec7017SPing-Ke Shih 	bool sr_en;
975e3ec7017SPing-Ke Shih 	u8 ppdu_cnt;
976e3ec7017SPing-Ke Shih 	u8 ppdu_type;
977e3ec7017SPing-Ke Shih 	bool icv_err;
978e3ec7017SPing-Ke Shih 	bool crc32_err;
979e3ec7017SPing-Ke Shih 	bool hw_dec;
980e3ec7017SPing-Ke Shih 	bool sw_dec;
981e3ec7017SPing-Ke Shih 	bool addr1_match;
982e3ec7017SPing-Ke Shih 	u8 frag;
983e3ec7017SPing-Ke Shih 	u16 seq;
984e3ec7017SPing-Ke Shih 	u8 frame_type;
985e3ec7017SPing-Ke Shih 	u8 rx_pl_id;
986e3ec7017SPing-Ke Shih 	bool addr_cam_valid;
987e3ec7017SPing-Ke Shih 	u8 addr_cam_id;
988e3ec7017SPing-Ke Shih 	u8 sec_cam_id;
989e3ec7017SPing-Ke Shih 	u8 mac_id;
990e3ec7017SPing-Ke Shih 	u16 offset;
991de9f9338SPing-Ke Shih 	u16 rxd_len;
992e3ec7017SPing-Ke Shih 	bool ready;
993e3ec7017SPing-Ke Shih };
994e3ec7017SPing-Ke Shih 
995e3ec7017SPing-Ke Shih struct rtw89_rxdesc_short {
996e3ec7017SPing-Ke Shih 	__le32 dword0;
997e3ec7017SPing-Ke Shih 	__le32 dword1;
998e3ec7017SPing-Ke Shih 	__le32 dword2;
999e3ec7017SPing-Ke Shih 	__le32 dword3;
1000e3ec7017SPing-Ke Shih } __packed;
1001e3ec7017SPing-Ke Shih 
1002e3ec7017SPing-Ke Shih struct rtw89_rxdesc_long {
1003e3ec7017SPing-Ke Shih 	__le32 dword0;
1004e3ec7017SPing-Ke Shih 	__le32 dword1;
1005e3ec7017SPing-Ke Shih 	__le32 dword2;
1006e3ec7017SPing-Ke Shih 	__le32 dword3;
1007e3ec7017SPing-Ke Shih 	__le32 dword4;
1008e3ec7017SPing-Ke Shih 	__le32 dword5;
1009e3ec7017SPing-Ke Shih 	__le32 dword6;
1010e3ec7017SPing-Ke Shih 	__le32 dword7;
1011e3ec7017SPing-Ke Shih } __packed;
1012e3ec7017SPing-Ke Shih 
1013e3ec7017SPing-Ke Shih struct rtw89_tx_desc_info {
1014e3ec7017SPing-Ke Shih 	u16 pkt_size;
1015e3ec7017SPing-Ke Shih 	u8 wp_offset;
10169eecaec2SPing-Ke Shih 	u8 mac_id;
1017e3ec7017SPing-Ke Shih 	u8 qsel;
1018e3ec7017SPing-Ke Shih 	u8 ch_dma;
1019e3ec7017SPing-Ke Shih 	u8 hdr_llc_len;
1020e3ec7017SPing-Ke Shih 	bool is_bmc;
1021e3ec7017SPing-Ke Shih 	bool en_wd_info;
1022e3ec7017SPing-Ke Shih 	bool wd_page;
1023e3ec7017SPing-Ke Shih 	bool use_rate;
1024e3ec7017SPing-Ke Shih 	bool dis_data_fb;
1025e3ec7017SPing-Ke Shih 	bool tid_indicate;
1026e3ec7017SPing-Ke Shih 	bool agg_en;
1027e3ec7017SPing-Ke Shih 	bool bk;
1028e3ec7017SPing-Ke Shih 	u8 ampdu_density;
1029e3ec7017SPing-Ke Shih 	u8 ampdu_num;
1030e3ec7017SPing-Ke Shih 	bool sec_en;
10316d5b5d62SPing-Ke Shih 	u8 addr_info_nr;
103279a6c9a4SPing-Ke Shih 	u8 sec_keyid;
1033e3ec7017SPing-Ke Shih 	u8 sec_type;
1034e3ec7017SPing-Ke Shih 	u8 sec_cam_idx;
103579a6c9a4SPing-Ke Shih 	u8 sec_seq[6];
1036e3ec7017SPing-Ke Shih 	u16 data_rate;
1037e3ec7017SPing-Ke Shih 	u16 data_retry_lowest_rate;
1038e3ec7017SPing-Ke Shih 	bool fw_dl;
1039e3ec7017SPing-Ke Shih 	u16 seq;
1040e3ec7017SPing-Ke Shih 	bool a_ctrl_bsr;
104191644020SPing-Ke Shih 	u8 hw_ssn_sel;
104291644020SPing-Ke Shih #define RTW89_MGMT_HW_SSN_SEL	1
104391644020SPing-Ke Shih 	u8 hw_seq_mode;
104491644020SPing-Ke Shih #define RTW89_MGMT_HW_SEQ_MODE	1
104511d261f2SPing-Ke Shih 	bool hiq;
10469eecaec2SPing-Ke Shih 	u8 port;
104725ed1a17SPing-Ke Shih 	bool er_cap;
1048e3ec7017SPing-Ke Shih };
1049e3ec7017SPing-Ke Shih 
1050e3ec7017SPing-Ke Shih struct rtw89_core_tx_request {
1051e3ec7017SPing-Ke Shih 	enum rtw89_core_tx_type tx_type;
1052e3ec7017SPing-Ke Shih 
1053e3ec7017SPing-Ke Shih 	struct sk_buff *skb;
1054e3ec7017SPing-Ke Shih 	struct ieee80211_vif *vif;
1055e3ec7017SPing-Ke Shih 	struct ieee80211_sta *sta;
1056e3ec7017SPing-Ke Shih 	struct rtw89_tx_desc_info desc_info;
1057e3ec7017SPing-Ke Shih };
1058e3ec7017SPing-Ke Shih 
1059e3ec7017SPing-Ke Shih struct rtw89_txq {
1060e3ec7017SPing-Ke Shih 	struct list_head list;
1061e3ec7017SPing-Ke Shih 	unsigned long flags;
1062e3ec7017SPing-Ke Shih 	int wait_cnt;
1063e3ec7017SPing-Ke Shih };
1064e3ec7017SPing-Ke Shih 
1065e3ec7017SPing-Ke Shih struct rtw89_mac_ax_gnt {
1066e3ec7017SPing-Ke Shih 	u8 gnt_bt_sw_en;
1067e3ec7017SPing-Ke Shih 	u8 gnt_bt;
1068e3ec7017SPing-Ke Shih 	u8 gnt_wl_sw_en;
1069e3ec7017SPing-Ke Shih 	u8 gnt_wl;
10701162584cSChing-Te Ku } __packed;
1071e3ec7017SPing-Ke Shih 
1072e3ec7017SPing-Ke Shih #define RTW89_MAC_AX_COEX_GNT_NR 2
1073e3ec7017SPing-Ke Shih struct rtw89_mac_ax_coex_gnt {
1074e3ec7017SPing-Ke Shih 	struct rtw89_mac_ax_gnt band[RTW89_MAC_AX_COEX_GNT_NR];
1075e3ec7017SPing-Ke Shih };
1076e3ec7017SPing-Ke Shih 
1077e3ec7017SPing-Ke Shih enum rtw89_btc_ncnt {
1078e3ec7017SPing-Ke Shih 	BTC_NCNT_POWER_ON = 0x0,
1079e3ec7017SPing-Ke Shih 	BTC_NCNT_POWER_OFF,
1080e3ec7017SPing-Ke Shih 	BTC_NCNT_INIT_COEX,
1081e3ec7017SPing-Ke Shih 	BTC_NCNT_SCAN_START,
1082e3ec7017SPing-Ke Shih 	BTC_NCNT_SCAN_FINISH,
1083e3ec7017SPing-Ke Shih 	BTC_NCNT_SPECIAL_PACKET,
1084e3ec7017SPing-Ke Shih 	BTC_NCNT_SWITCH_BAND,
1085e3ec7017SPing-Ke Shih 	BTC_NCNT_RFK_TIMEOUT,
1086e3ec7017SPing-Ke Shih 	BTC_NCNT_SHOW_COEX_INFO,
1087e3ec7017SPing-Ke Shih 	BTC_NCNT_ROLE_INFO,
1088e3ec7017SPing-Ke Shih 	BTC_NCNT_CONTROL,
1089e3ec7017SPing-Ke Shih 	BTC_NCNT_RADIO_STATE,
1090e3ec7017SPing-Ke Shih 	BTC_NCNT_CUSTOMERIZE,
1091e3ec7017SPing-Ke Shih 	BTC_NCNT_WL_RFK,
1092e3ec7017SPing-Ke Shih 	BTC_NCNT_WL_STA,
1093e3ec7017SPing-Ke Shih 	BTC_NCNT_FWINFO,
1094e3ec7017SPing-Ke Shih 	BTC_NCNT_TIMER,
1095e3ec7017SPing-Ke Shih 	BTC_NCNT_NUM
1096e3ec7017SPing-Ke Shih };
1097e3ec7017SPing-Ke Shih 
1098e3ec7017SPing-Ke Shih enum rtw89_btc_btinfo {
1099e3ec7017SPing-Ke Shih 	BTC_BTINFO_L0 = 0,
1100e3ec7017SPing-Ke Shih 	BTC_BTINFO_L1,
1101e3ec7017SPing-Ke Shih 	BTC_BTINFO_L2,
1102e3ec7017SPing-Ke Shih 	BTC_BTINFO_L3,
1103e3ec7017SPing-Ke Shih 	BTC_BTINFO_H0,
1104e3ec7017SPing-Ke Shih 	BTC_BTINFO_H1,
1105e3ec7017SPing-Ke Shih 	BTC_BTINFO_H2,
1106e3ec7017SPing-Ke Shih 	BTC_BTINFO_H3,
1107e3ec7017SPing-Ke Shih 	BTC_BTINFO_MAX
1108e3ec7017SPing-Ke Shih };
1109e3ec7017SPing-Ke Shih 
1110e3ec7017SPing-Ke Shih enum rtw89_btc_dcnt {
1111e3ec7017SPing-Ke Shih 	BTC_DCNT_RUN = 0x0,
1112e3ec7017SPing-Ke Shih 	BTC_DCNT_CX_RUNINFO,
1113e3ec7017SPing-Ke Shih 	BTC_DCNT_RPT,
1114e49bdd85SChing-Te Ku 	BTC_DCNT_RPT_HANG,
1115e3ec7017SPing-Ke Shih 	BTC_DCNT_CYCLE,
1116e49bdd85SChing-Te Ku 	BTC_DCNT_CYCLE_HANG,
1117e3ec7017SPing-Ke Shih 	BTC_DCNT_W1,
1118e49bdd85SChing-Te Ku 	BTC_DCNT_W1_HANG,
1119e3ec7017SPing-Ke Shih 	BTC_DCNT_B1,
1120e49bdd85SChing-Te Ku 	BTC_DCNT_B1_HANG,
1121e3ec7017SPing-Ke Shih 	BTC_DCNT_TDMA_NONSYNC,
1122e3ec7017SPing-Ke Shih 	BTC_DCNT_SLOT_NONSYNC,
1123e49bdd85SChing-Te Ku 	BTC_DCNT_BTCNT_HANG,
1124e3ec7017SPing-Ke Shih 	BTC_DCNT_WL_SLOT_DRIFT,
1125e3ec7017SPing-Ke Shih 	BTC_DCNT_WL_STA_LAST,
1126e49bdd85SChing-Te Ku 	BTC_DCNT_BT_SLOT_DRIFT,
1127e49bdd85SChing-Te Ku 	BTC_DCNT_BT_SLOT_FLOOD,
1128e49bdd85SChing-Te Ku 	BTC_DCNT_FDDT_TRIG,
1129e49bdd85SChing-Te Ku 	BTC_DCNT_E2G,
1130e49bdd85SChing-Te Ku 	BTC_DCNT_E2G_HANG,
1131e49bdd85SChing-Te Ku 	BTC_DCNT_NUM
1132e3ec7017SPing-Ke Shih };
1133e3ec7017SPing-Ke Shih 
1134e3ec7017SPing-Ke Shih enum rtw89_btc_wl_state_cnt {
1135e3ec7017SPing-Ke Shih 	BTC_WCNT_SCANAP = 0x0,
1136e3ec7017SPing-Ke Shih 	BTC_WCNT_DHCP,
1137e3ec7017SPing-Ke Shih 	BTC_WCNT_EAPOL,
1138e3ec7017SPing-Ke Shih 	BTC_WCNT_ARP,
1139e3ec7017SPing-Ke Shih 	BTC_WCNT_SCBDUPDATE,
1140e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_REQ,
1141e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_GO,
1142e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_REJECT,
1143e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_TIMEOUT,
1144e3ec7017SPing-Ke Shih 	BTC_WCNT_CH_UPDATE,
1145e3ec7017SPing-Ke Shih 	BTC_WCNT_NUM
1146e3ec7017SPing-Ke Shih };
1147e3ec7017SPing-Ke Shih 
1148e3ec7017SPing-Ke Shih enum rtw89_btc_bt_state_cnt {
1149e3ec7017SPing-Ke Shih 	BTC_BCNT_RETRY = 0x0,
1150e3ec7017SPing-Ke Shih 	BTC_BCNT_REINIT,
1151e3ec7017SPing-Ke Shih 	BTC_BCNT_REENABLE,
1152e3ec7017SPing-Ke Shih 	BTC_BCNT_SCBDREAD,
1153e3ec7017SPing-Ke Shih 	BTC_BCNT_RELINK,
1154e3ec7017SPing-Ke Shih 	BTC_BCNT_IGNOWL,
1155e3ec7017SPing-Ke Shih 	BTC_BCNT_INQPAG,
1156e3ec7017SPing-Ke Shih 	BTC_BCNT_INQ,
1157e3ec7017SPing-Ke Shih 	BTC_BCNT_PAGE,
1158e3ec7017SPing-Ke Shih 	BTC_BCNT_ROLESW,
1159e3ec7017SPing-Ke Shih 	BTC_BCNT_AFH,
1160e3ec7017SPing-Ke Shih 	BTC_BCNT_INFOUPDATE,
1161e3ec7017SPing-Ke Shih 	BTC_BCNT_INFOSAME,
1162e3ec7017SPing-Ke Shih 	BTC_BCNT_SCBDUPDATE,
1163e3ec7017SPing-Ke Shih 	BTC_BCNT_HIPRI_TX,
1164e3ec7017SPing-Ke Shih 	BTC_BCNT_HIPRI_RX,
1165e3ec7017SPing-Ke Shih 	BTC_BCNT_LOPRI_TX,
1166e3ec7017SPing-Ke Shih 	BTC_BCNT_LOPRI_RX,
11678c7e9cebSChing-Te Ku 	BTC_BCNT_POLUT,
1168e3ec7017SPing-Ke Shih 	BTC_BCNT_RATECHG,
1169e3ec7017SPing-Ke Shih 	BTC_BCNT_NUM
1170e3ec7017SPing-Ke Shih };
1171e3ec7017SPing-Ke Shih 
1172e3ec7017SPing-Ke Shih enum rtw89_btc_bt_profile {
1173e3ec7017SPing-Ke Shih 	BTC_BT_NOPROFILE = 0,
1174e3ec7017SPing-Ke Shih 	BTC_BT_HFP = BIT(0),
1175e3ec7017SPing-Ke Shih 	BTC_BT_HID = BIT(1),
1176e3ec7017SPing-Ke Shih 	BTC_BT_A2DP = BIT(2),
1177e3ec7017SPing-Ke Shih 	BTC_BT_PAN = BIT(3),
1178e3ec7017SPing-Ke Shih 	BTC_PROFILE_MAX = 4,
1179e3ec7017SPing-Ke Shih };
1180e3ec7017SPing-Ke Shih 
1181e3ec7017SPing-Ke Shih struct rtw89_btc_ant_info {
1182e3ec7017SPing-Ke Shih 	u8 type;  /* shared, dedicated */
1183e3ec7017SPing-Ke Shih 	u8 num;
1184e3ec7017SPing-Ke Shih 	u8 isolation;
1185e3ec7017SPing-Ke Shih 
1186e3ec7017SPing-Ke Shih 	u8 single_pos: 1;/* Single antenna at S0 or S1 */
1187e3ec7017SPing-Ke Shih 	u8 diversity: 1;
1188c0fea064SPing-Ke Shih 	u8 btg_pos: 2;
1189c0fea064SPing-Ke Shih 	u8 stream_cnt: 4;
1190e3ec7017SPing-Ke Shih };
1191e3ec7017SPing-Ke Shih 
1192e3ec7017SPing-Ke Shih enum rtw89_tfc_dir {
1193e3ec7017SPing-Ke Shih 	RTW89_TFC_UL,
1194e3ec7017SPing-Ke Shih 	RTW89_TFC_DL,
1195e3ec7017SPing-Ke Shih };
1196e3ec7017SPing-Ke Shih 
1197e3ec7017SPing-Ke Shih struct rtw89_btc_wl_smap {
1198e3ec7017SPing-Ke Shih 	u32 busy: 1;
1199e3ec7017SPing-Ke Shih 	u32 scan: 1;
1200e3ec7017SPing-Ke Shih 	u32 connecting: 1;
1201e3ec7017SPing-Ke Shih 	u32 roaming: 1;
1202e3ec7017SPing-Ke Shih 	u32 _4way: 1;
1203e3ec7017SPing-Ke Shih 	u32 rf_off: 1;
120438ede035SChing-Te Ku 	u32 lps: 2;
1205e3ec7017SPing-Ke Shih 	u32 ips: 1;
1206e3ec7017SPing-Ke Shih 	u32 init_ok: 1;
1207e3ec7017SPing-Ke Shih 	u32 traffic_dir : 2;
1208e3ec7017SPing-Ke Shih 	u32 rf_off_pre: 1;
120938ede035SChing-Te Ku 	u32 lps_pre: 2;
1210e3ec7017SPing-Ke Shih };
1211e3ec7017SPing-Ke Shih 
1212e3ec7017SPing-Ke Shih enum rtw89_tfc_lv {
1213e3ec7017SPing-Ke Shih 	RTW89_TFC_IDLE,
1214e3ec7017SPing-Ke Shih 	RTW89_TFC_ULTRA_LOW,
1215e3ec7017SPing-Ke Shih 	RTW89_TFC_LOW,
1216e3ec7017SPing-Ke Shih 	RTW89_TFC_MID,
1217e3ec7017SPing-Ke Shih 	RTW89_TFC_HIGH,
1218e3ec7017SPing-Ke Shih };
1219e3ec7017SPing-Ke Shih 
1220e3ec7017SPing-Ke Shih #define RTW89_TP_SHIFT 18 /* bytes/2s --> Mbps */
1221e3ec7017SPing-Ke Shih DECLARE_EWMA(tp, 10, 2);
1222e3ec7017SPing-Ke Shih 
1223e3ec7017SPing-Ke Shih struct rtw89_traffic_stats {
1224e3ec7017SPing-Ke Shih 	/* units in bytes */
1225e3ec7017SPing-Ke Shih 	u64 tx_unicast;
1226e3ec7017SPing-Ke Shih 	u64 rx_unicast;
1227e3ec7017SPing-Ke Shih 	u32 tx_avg_len;
1228e3ec7017SPing-Ke Shih 	u32 rx_avg_len;
1229e3ec7017SPing-Ke Shih 
1230e3ec7017SPing-Ke Shih 	/* count for packets */
1231e3ec7017SPing-Ke Shih 	u64 tx_cnt;
1232e3ec7017SPing-Ke Shih 	u64 rx_cnt;
1233e3ec7017SPing-Ke Shih 
1234e3ec7017SPing-Ke Shih 	/* units in Mbps */
1235e3ec7017SPing-Ke Shih 	u32 tx_throughput;
1236e3ec7017SPing-Ke Shih 	u32 rx_throughput;
1237e3ec7017SPing-Ke Shih 	u32 tx_throughput_raw;
1238e3ec7017SPing-Ke Shih 	u32 rx_throughput_raw;
12395165f168SPo Hao Huang 
12405165f168SPo Hao Huang 	u32 rx_tf_acc;
12415165f168SPo Hao Huang 	u32 rx_tf_periodic;
12425165f168SPo Hao Huang 
1243e3ec7017SPing-Ke Shih 	enum rtw89_tfc_lv tx_tfc_lv;
1244e3ec7017SPing-Ke Shih 	enum rtw89_tfc_lv rx_tfc_lv;
1245e3ec7017SPing-Ke Shih 	struct ewma_tp tx_ewma_tp;
1246e3ec7017SPing-Ke Shih 	struct ewma_tp rx_ewma_tp;
1247e3ec7017SPing-Ke Shih 
1248e3ec7017SPing-Ke Shih 	u16 tx_rate;
1249e3ec7017SPing-Ke Shih 	u16 rx_rate;
1250e3ec7017SPing-Ke Shih };
1251e3ec7017SPing-Ke Shih 
1252e3ec7017SPing-Ke Shih struct rtw89_btc_statistic {
1253e3ec7017SPing-Ke Shih 	u8 rssi; /* 0%~110% (dBm = rssi -110) */
1254e3ec7017SPing-Ke Shih 	struct rtw89_traffic_stats traffic;
1255e3ec7017SPing-Ke Shih };
1256e3ec7017SPing-Ke Shih 
1257e3ec7017SPing-Ke Shih #define BTC_WL_RSSI_THMAX 4
1258e3ec7017SPing-Ke Shih 
1259e3ec7017SPing-Ke Shih struct rtw89_btc_wl_link_info {
1260e3ec7017SPing-Ke Shih 	struct rtw89_btc_statistic stat;
1261e3ec7017SPing-Ke Shih 	enum rtw89_tfc_dir dir;
1262e3ec7017SPing-Ke Shih 	u8 rssi_state[BTC_WL_RSSI_THMAX];
1263e3ec7017SPing-Ke Shih 	u8 mac_addr[ETH_ALEN];
1264e3ec7017SPing-Ke Shih 	u8 busy;
1265e3ec7017SPing-Ke Shih 	u8 ch;
1266e3ec7017SPing-Ke Shih 	u8 bw;
1267e3ec7017SPing-Ke Shih 	u8 band;
1268e3ec7017SPing-Ke Shih 	u8 role;
1269e3ec7017SPing-Ke Shih 	u8 pid;
1270e3ec7017SPing-Ke Shih 	u8 phy;
1271e3ec7017SPing-Ke Shih 	u8 dtim_period;
1272e3ec7017SPing-Ke Shih 	u8 mode;
1273e3ec7017SPing-Ke Shih 
1274e3ec7017SPing-Ke Shih 	u8 mac_id;
1275e3ec7017SPing-Ke Shih 	u8 tx_retry;
1276e3ec7017SPing-Ke Shih 
1277e3ec7017SPing-Ke Shih 	u32 bcn_period;
1278e3ec7017SPing-Ke Shih 	u32 busy_t;
1279e3ec7017SPing-Ke Shih 	u32 tx_time;
1280e3ec7017SPing-Ke Shih 	u32 client_cnt;
1281e3ec7017SPing-Ke Shih 	u32 rx_rate_drop_cnt;
1282e3ec7017SPing-Ke Shih 
1283e3ec7017SPing-Ke Shih 	u32 active: 1;
1284e3ec7017SPing-Ke Shih 	u32 noa: 1;
1285e3ec7017SPing-Ke Shih 	u32 client_ps: 1;
1286e3ec7017SPing-Ke Shih 	u32 connected: 2;
1287e3ec7017SPing-Ke Shih };
1288e3ec7017SPing-Ke Shih 
1289e3ec7017SPing-Ke Shih union rtw89_btc_wl_state_map {
1290e3ec7017SPing-Ke Shih 	u32 val;
1291e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_smap map;
1292e3ec7017SPing-Ke Shih };
1293e3ec7017SPing-Ke Shih 
1294e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hfp_desc {
1295e3ec7017SPing-Ke Shih 	u32 exist: 1;
1296e3ec7017SPing-Ke Shih 	u32 type: 2;
1297e3ec7017SPing-Ke Shih 	u32 rsvd: 29;
1298e3ec7017SPing-Ke Shih };
1299e3ec7017SPing-Ke Shih 
1300e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hid_desc {
1301e3ec7017SPing-Ke Shih 	u32 exist: 1;
1302e3ec7017SPing-Ke Shih 	u32 slot_info: 2;
1303e3ec7017SPing-Ke Shih 	u32 pair_cnt: 2;
1304e3ec7017SPing-Ke Shih 	u32 type: 8;
1305e3ec7017SPing-Ke Shih 	u32 rsvd: 19;
1306e3ec7017SPing-Ke Shih };
1307e3ec7017SPing-Ke Shih 
1308e3ec7017SPing-Ke Shih struct rtw89_btc_bt_a2dp_desc {
1309e3ec7017SPing-Ke Shih 	u8 exist: 1;
1310e3ec7017SPing-Ke Shih 	u8 exist_last: 1;
1311e3ec7017SPing-Ke Shih 	u8 play_latency: 1;
1312e3ec7017SPing-Ke Shih 	u8 type: 3;
1313e3ec7017SPing-Ke Shih 	u8 active: 1;
1314e3ec7017SPing-Ke Shih 	u8 sink: 1;
1315e3ec7017SPing-Ke Shih 
1316e3ec7017SPing-Ke Shih 	u8 bitpool;
1317e3ec7017SPing-Ke Shih 	u16 vendor_id;
1318e3ec7017SPing-Ke Shih 	u32 device_name;
1319e3ec7017SPing-Ke Shih 	u32 flush_time;
1320e3ec7017SPing-Ke Shih };
1321e3ec7017SPing-Ke Shih 
1322e3ec7017SPing-Ke Shih struct rtw89_btc_bt_pan_desc {
1323e3ec7017SPing-Ke Shih 	u32 exist: 1;
1324e3ec7017SPing-Ke Shih 	u32 type: 1;
1325e3ec7017SPing-Ke Shih 	u32 active: 1;
1326e3ec7017SPing-Ke Shih 	u32 rsvd: 29;
1327e3ec7017SPing-Ke Shih };
1328e3ec7017SPing-Ke Shih 
1329e3ec7017SPing-Ke Shih struct rtw89_btc_bt_rfk_info {
1330e3ec7017SPing-Ke Shih 	u32 run: 1;
1331e3ec7017SPing-Ke Shih 	u32 req: 1;
1332e3ec7017SPing-Ke Shih 	u32 timeout: 1;
1333e3ec7017SPing-Ke Shih 	u32 rsvd: 29;
1334e3ec7017SPing-Ke Shih };
1335e3ec7017SPing-Ke Shih 
1336e3ec7017SPing-Ke Shih union rtw89_btc_bt_rfk_info_map {
1337e3ec7017SPing-Ke Shih 	u32 val;
1338e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_rfk_info map;
1339e3ec7017SPing-Ke Shih };
1340e3ec7017SPing-Ke Shih 
1341e3ec7017SPing-Ke Shih struct rtw89_btc_bt_ver_info {
1342e3ec7017SPing-Ke Shih 	u32 fw_coex; /* match with which coex_ver */
1343e3ec7017SPing-Ke Shih 	u32 fw;
1344e3ec7017SPing-Ke Shih };
1345e3ec7017SPing-Ke Shih 
1346e3ec7017SPing-Ke Shih struct rtw89_btc_bool_sta_chg {
1347e3ec7017SPing-Ke Shih 	u32 now: 1;
1348e3ec7017SPing-Ke Shih 	u32 last: 1;
1349e3ec7017SPing-Ke Shih 	u32 remain: 1;
1350e3ec7017SPing-Ke Shih 	u32 srvd: 29;
1351e3ec7017SPing-Ke Shih };
1352e3ec7017SPing-Ke Shih 
1353e3ec7017SPing-Ke Shih struct rtw89_btc_u8_sta_chg {
1354e3ec7017SPing-Ke Shih 	u8 now;
1355e3ec7017SPing-Ke Shih 	u8 last;
1356e3ec7017SPing-Ke Shih 	u8 remain;
1357e3ec7017SPing-Ke Shih 	u8 rsvd;
1358e3ec7017SPing-Ke Shih };
1359e3ec7017SPing-Ke Shih 
1360e3ec7017SPing-Ke Shih struct rtw89_btc_wl_scan_info {
1361e3ec7017SPing-Ke Shih 	u8 band[RTW89_PHY_MAX];
1362e3ec7017SPing-Ke Shih 	u8 phy_map;
1363e3ec7017SPing-Ke Shih 	u8 rsvd;
1364e3ec7017SPing-Ke Shih };
1365e3ec7017SPing-Ke Shih 
1366e3ec7017SPing-Ke Shih struct rtw89_btc_wl_dbcc_info {
1367e3ec7017SPing-Ke Shih 	u8 op_band[RTW89_PHY_MAX]; /* op band in each phy */
1368e3ec7017SPing-Ke Shih 	u8 scan_band[RTW89_PHY_MAX]; /* scan band in  each phy */
1369e3ec7017SPing-Ke Shih 	u8 real_band[RTW89_PHY_MAX];
1370e3ec7017SPing-Ke Shih 	u8 role[RTW89_PHY_MAX]; /* role in each phy */
1371e3ec7017SPing-Ke Shih };
1372e3ec7017SPing-Ke Shih 
1373e3ec7017SPing-Ke Shih struct rtw89_btc_wl_active_role {
1374e3ec7017SPing-Ke Shih 	u8 connected: 1;
1375e3ec7017SPing-Ke Shih 	u8 pid: 3;
1376e3ec7017SPing-Ke Shih 	u8 phy: 1;
1377e3ec7017SPing-Ke Shih 	u8 noa: 1;
1378e3ec7017SPing-Ke Shih 	u8 band: 2;
1379e3ec7017SPing-Ke Shih 
1380e3ec7017SPing-Ke Shih 	u8 client_ps: 1;
1381e3ec7017SPing-Ke Shih 	u8 bw: 7;
1382e3ec7017SPing-Ke Shih 
1383e3ec7017SPing-Ke Shih 	u8 role;
1384e3ec7017SPing-Ke Shih 	u8 ch;
1385e3ec7017SPing-Ke Shih 
1386e3ec7017SPing-Ke Shih 	u16 tx_lvl;
1387e3ec7017SPing-Ke Shih 	u16 rx_lvl;
1388e3ec7017SPing-Ke Shih 	u16 tx_rate;
1389e3ec7017SPing-Ke Shih 	u16 rx_rate;
1390e3ec7017SPing-Ke Shih };
1391e3ec7017SPing-Ke Shih 
1392e390cf2eSChing-Te Ku struct rtw89_btc_wl_active_role_v1 {
1393e390cf2eSChing-Te Ku 	u8 connected: 1;
1394e390cf2eSChing-Te Ku 	u8 pid: 3;
1395e390cf2eSChing-Te Ku 	u8 phy: 1;
1396e390cf2eSChing-Te Ku 	u8 noa: 1;
1397e390cf2eSChing-Te Ku 	u8 band: 2;
1398e390cf2eSChing-Te Ku 
1399e390cf2eSChing-Te Ku 	u8 client_ps: 1;
1400e390cf2eSChing-Te Ku 	u8 bw: 7;
1401e390cf2eSChing-Te Ku 
1402e390cf2eSChing-Te Ku 	u8 role;
1403e390cf2eSChing-Te Ku 	u8 ch;
1404e390cf2eSChing-Te Ku 
1405e390cf2eSChing-Te Ku 	u16 tx_lvl;
1406e390cf2eSChing-Te Ku 	u16 rx_lvl;
1407e390cf2eSChing-Te Ku 	u16 tx_rate;
1408e390cf2eSChing-Te Ku 	u16 rx_rate;
1409e390cf2eSChing-Te Ku 
1410e390cf2eSChing-Te Ku 	u32 noa_duration; /* ms */
1411e390cf2eSChing-Te Ku };
1412e390cf2eSChing-Te Ku 
14135049964cSChing-Te Ku struct rtw89_btc_wl_active_role_v2 {
14145049964cSChing-Te Ku 	u8 connected: 1;
14155049964cSChing-Te Ku 	u8 pid: 3;
14165049964cSChing-Te Ku 	u8 phy: 1;
14175049964cSChing-Te Ku 	u8 noa: 1;
14185049964cSChing-Te Ku 	u8 band: 2;
14195049964cSChing-Te Ku 
14205049964cSChing-Te Ku 	u8 client_ps: 1;
14215049964cSChing-Te Ku 	u8 bw: 7;
14225049964cSChing-Te Ku 
14235049964cSChing-Te Ku 	u8 role;
14245049964cSChing-Te Ku 	u8 ch;
14255049964cSChing-Te Ku 
14265049964cSChing-Te Ku 	u32 noa_duration; /* ms */
14275049964cSChing-Te Ku };
14285049964cSChing-Te Ku 
1429e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info_bpos {
1430e3ec7017SPing-Ke Shih 	u16 none: 1;
1431e3ec7017SPing-Ke Shih 	u16 station: 1;
1432e3ec7017SPing-Ke Shih 	u16 ap: 1;
1433e3ec7017SPing-Ke Shih 	u16 vap: 1;
1434e3ec7017SPing-Ke Shih 	u16 adhoc: 1;
1435e3ec7017SPing-Ke Shih 	u16 adhoc_master: 1;
1436e3ec7017SPing-Ke Shih 	u16 mesh: 1;
1437e3ec7017SPing-Ke Shih 	u16 moniter: 1;
1438e3ec7017SPing-Ke Shih 	u16 p2p_device: 1;
1439e3ec7017SPing-Ke Shih 	u16 p2p_gc: 1;
1440e3ec7017SPing-Ke Shih 	u16 p2p_go: 1;
1441e3ec7017SPing-Ke Shih 	u16 nan: 1;
1442e3ec7017SPing-Ke Shih };
1443e3ec7017SPing-Ke Shih 
1444747dc30eSChing-Te Ku struct rtw89_btc_wl_scc_ctrl {
1445747dc30eSChing-Te Ku 	u8 null_role1;
1446747dc30eSChing-Te Ku 	u8 null_role2;
1447747dc30eSChing-Te Ku 	u8 ebt_null; /* if tx null at EBT slot */
1448747dc30eSChing-Te Ku };
1449747dc30eSChing-Te Ku 
1450e3ec7017SPing-Ke Shih union rtw89_btc_wl_role_info_map {
1451e3ec7017SPing-Ke Shih 	u16 val;
1452e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_role_info_bpos role;
1453e3ec7017SPing-Ke Shih };
1454e3ec7017SPing-Ke Shih 
1455e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info { /* struct size must be n*4 bytes */
1456e3ec7017SPing-Ke Shih 	u8 connect_cnt;
1457e3ec7017SPing-Ke Shih 	u8 link_mode;
1458e3ec7017SPing-Ke Shih 	union rtw89_btc_wl_role_info_map role_map;
145920d9fc88SPing-Ke Shih 	struct rtw89_btc_wl_active_role active_role[RTW89_PORT_NUM];
1460e3ec7017SPing-Ke Shih };
1461e3ec7017SPing-Ke Shih 
1462e390cf2eSChing-Te Ku struct rtw89_btc_wl_role_info_v1 { /* struct size must be n*4 bytes */
1463e390cf2eSChing-Te Ku 	u8 connect_cnt;
1464e390cf2eSChing-Te Ku 	u8 link_mode;
1465e390cf2eSChing-Te Ku 	union rtw89_btc_wl_role_info_map role_map;
1466e390cf2eSChing-Te Ku 	struct rtw89_btc_wl_active_role_v1 active_role_v1[RTW89_PORT_NUM];
1467e390cf2eSChing-Te Ku 	u32 mrole_type; /* btc_wl_mrole_type */
1468e390cf2eSChing-Te Ku 	u32 mrole_noa_duration; /* ms */
1469e390cf2eSChing-Te Ku 
1470e390cf2eSChing-Te Ku 	u32 dbcc_en: 1;
1471e390cf2eSChing-Te Ku 	u32 dbcc_chg: 1;
1472e390cf2eSChing-Te Ku 	u32 dbcc_2g_phy: 2; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
1473e390cf2eSChing-Te Ku 	u32 link_mode_chg: 1;
1474e390cf2eSChing-Te Ku 	u32 rsvd: 27;
1475e390cf2eSChing-Te Ku };
1476e390cf2eSChing-Te Ku 
14775049964cSChing-Te Ku struct rtw89_btc_wl_role_info_v2 { /* struct size must be n*4 bytes */
14785049964cSChing-Te Ku 	u8 connect_cnt;
14795049964cSChing-Te Ku 	u8 link_mode;
14805049964cSChing-Te Ku 	union rtw89_btc_wl_role_info_map role_map;
14815049964cSChing-Te Ku 	struct rtw89_btc_wl_active_role_v2 active_role_v2[RTW89_PORT_NUM];
14825049964cSChing-Te Ku 	u32 mrole_type; /* btc_wl_mrole_type */
14835049964cSChing-Te Ku 	u32 mrole_noa_duration; /* ms */
14845049964cSChing-Te Ku 
14855049964cSChing-Te Ku 	u32 dbcc_en: 1;
14865049964cSChing-Te Ku 	u32 dbcc_chg: 1;
14875049964cSChing-Te Ku 	u32 dbcc_2g_phy: 2; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
14885049964cSChing-Te Ku 	u32 link_mode_chg: 1;
14895049964cSChing-Te Ku 	u32 rsvd: 27;
14905049964cSChing-Te Ku };
14915049964cSChing-Te Ku 
1492e3ec7017SPing-Ke Shih struct rtw89_btc_wl_ver_info {
1493e3ec7017SPing-Ke Shih 	u32 fw_coex; /* match with which coex_ver */
1494e3ec7017SPing-Ke Shih 	u32 fw;
1495e3ec7017SPing-Ke Shih 	u32 mac;
1496e3ec7017SPing-Ke Shih 	u32 bb;
1497e3ec7017SPing-Ke Shih 	u32 rf;
1498e3ec7017SPing-Ke Shih };
1499e3ec7017SPing-Ke Shih 
1500e3ec7017SPing-Ke Shih struct rtw89_btc_wl_afh_info {
1501e3ec7017SPing-Ke Shih 	u8 en;
1502e3ec7017SPing-Ke Shih 	u8 ch;
1503e3ec7017SPing-Ke Shih 	u8 bw;
1504e3ec7017SPing-Ke Shih 	u8 rsvd;
1505e3ec7017SPing-Ke Shih } __packed;
1506e3ec7017SPing-Ke Shih 
1507e3ec7017SPing-Ke Shih struct rtw89_btc_wl_rfk_info {
1508e3ec7017SPing-Ke Shih 	u32 state: 2;
1509e3ec7017SPing-Ke Shih 	u32 path_map: 4;
1510e3ec7017SPing-Ke Shih 	u32 phy_map: 2;
1511e3ec7017SPing-Ke Shih 	u32 band: 2;
1512e3ec7017SPing-Ke Shih 	u32 type: 8;
1513e3ec7017SPing-Ke Shih 	u32 rsvd: 14;
1514e3ec7017SPing-Ke Shih };
1515e3ec7017SPing-Ke Shih 
1516e3ec7017SPing-Ke Shih struct rtw89_btc_bt_smap {
1517e3ec7017SPing-Ke Shih 	u32 connect: 1;
1518e3ec7017SPing-Ke Shih 	u32 ble_connect: 1;
1519e3ec7017SPing-Ke Shih 	u32 acl_busy: 1;
1520e3ec7017SPing-Ke Shih 	u32 sco_busy: 1;
1521e3ec7017SPing-Ke Shih 	u32 mesh_busy: 1;
1522e3ec7017SPing-Ke Shih 	u32 inq_pag: 1;
1523e3ec7017SPing-Ke Shih };
1524e3ec7017SPing-Ke Shih 
1525e3ec7017SPing-Ke Shih union rtw89_btc_bt_state_map {
1526e3ec7017SPing-Ke Shih 	u32 val;
1527e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_smap map;
1528e3ec7017SPing-Ke Shih };
1529e3ec7017SPing-Ke Shih 
1530e3ec7017SPing-Ke Shih #define BTC_BT_RSSI_THMAX 4
1531e3ec7017SPing-Ke Shih #define BTC_BT_AFH_GROUP 12
15320cdfcfceSChing-Te Ku #define BTC_BT_AFH_LE_GROUP 5
1533e3ec7017SPing-Ke Shih 
1534e3ec7017SPing-Ke Shih struct rtw89_btc_bt_link_info {
1535e3ec7017SPing-Ke Shih 	struct rtw89_btc_u8_sta_chg profile_cnt;
1536e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg multi_link;
1537e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg relink;
1538e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_hfp_desc hfp_desc;
1539e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_hid_desc hid_desc;
1540e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_a2dp_desc a2dp_desc;
1541e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_pan_desc pan_desc;
1542e3ec7017SPing-Ke Shih 	union rtw89_btc_bt_state_map status;
1543e3ec7017SPing-Ke Shih 
1544e3ec7017SPing-Ke Shih 	u8 sut_pwr_level[BTC_PROFILE_MAX];
1545e3ec7017SPing-Ke Shih 	u8 golden_rx_shift[BTC_PROFILE_MAX];
1546e3ec7017SPing-Ke Shih 	u8 rssi_state[BTC_BT_RSSI_THMAX];
1547e3ec7017SPing-Ke Shih 	u8 afh_map[BTC_BT_AFH_GROUP];
15480cdfcfceSChing-Te Ku 	u8 afh_map_le[BTC_BT_AFH_LE_GROUP];
1549e3ec7017SPing-Ke Shih 
1550e3ec7017SPing-Ke Shih 	u32 role_sw: 1;
1551e3ec7017SPing-Ke Shih 	u32 slave_role: 1;
1552e3ec7017SPing-Ke Shih 	u32 afh_update: 1;
1553e3ec7017SPing-Ke Shih 	u32 cqddr: 1;
1554e3ec7017SPing-Ke Shih 	u32 rssi: 8;
1555e3ec7017SPing-Ke Shih 	u32 tx_3m: 1;
1556e3ec7017SPing-Ke Shih 	u32 rsvd: 19;
1557e3ec7017SPing-Ke Shih };
1558e3ec7017SPing-Ke Shih 
1559e3ec7017SPing-Ke Shih struct rtw89_btc_3rdcx_info {
1560e3ec7017SPing-Ke Shih 	u8 type;   /* 0: none, 1:zigbee, 2:LTE  */
1561e3ec7017SPing-Ke Shih 	u8 hw_coex;
1562e3ec7017SPing-Ke Shih 	u16 rsvd;
1563e3ec7017SPing-Ke Shih };
1564e3ec7017SPing-Ke Shih 
1565e3ec7017SPing-Ke Shih struct rtw89_btc_dm_emap {
1566e3ec7017SPing-Ke Shih 	u32 init: 1;
1567e3ec7017SPing-Ke Shih 	u32 pta_owner: 1;
1568e3ec7017SPing-Ke Shih 	u32 wl_rfk_timeout: 1;
1569e3ec7017SPing-Ke Shih 	u32 bt_rfk_timeout: 1;
1570e3ec7017SPing-Ke Shih 	u32 wl_fw_hang: 1;
1571e3ec7017SPing-Ke Shih 	u32 cycle_hang: 1;
1572e3ec7017SPing-Ke Shih 	u32 w1_hang: 1;
1573e3ec7017SPing-Ke Shih 	u32 b1_hang: 1;
1574e3ec7017SPing-Ke Shih 	u32 tdma_no_sync: 1;
1575e49bdd85SChing-Te Ku 	u32 slot_no_sync: 1;
1576e3ec7017SPing-Ke Shih 	u32 wl_slot_drift: 1;
1577e49bdd85SChing-Te Ku 	u32 bt_slot_drift: 1;
1578e49bdd85SChing-Te Ku 	u32 role_num_mismatch: 1;
1579e49bdd85SChing-Te Ku 	u32 null1_tx_late: 1;
1580e49bdd85SChing-Te Ku 	u32 bt_afh_conflict: 1;
1581e49bdd85SChing-Te Ku 	u32 bt_leafh_conflict: 1;
1582e49bdd85SChing-Te Ku 	u32 bt_slot_flood: 1;
1583e49bdd85SChing-Te Ku 	u32 wl_e2g_hang: 1;
1584e49bdd85SChing-Te Ku 	u32 wl_ver_mismatch: 1;
1585e49bdd85SChing-Te Ku 	u32 bt_ver_mismatch: 1;
1586e3ec7017SPing-Ke Shih };
1587e3ec7017SPing-Ke Shih 
1588e3ec7017SPing-Ke Shih union rtw89_btc_dm_error_map {
1589e3ec7017SPing-Ke Shih 	u32 val;
1590e3ec7017SPing-Ke Shih 	struct rtw89_btc_dm_emap map;
1591e3ec7017SPing-Ke Shih };
1592e3ec7017SPing-Ke Shih 
1593e3ec7017SPing-Ke Shih struct rtw89_btc_rf_para {
1594e3ec7017SPing-Ke Shih 	u32 tx_pwr_freerun;
1595e3ec7017SPing-Ke Shih 	u32 rx_gain_freerun;
1596e3ec7017SPing-Ke Shih 	u32 tx_pwr_perpkt;
1597e3ec7017SPing-Ke Shih 	u32 rx_gain_perpkt;
1598e3ec7017SPing-Ke Shih };
1599e3ec7017SPing-Ke Shih 
1600a2c0ce5dSChing-Te Ku struct rtw89_btc_wl_nhm {
1601a2c0ce5dSChing-Te Ku 	u8 instant_wl_nhm_dbm;
1602a2c0ce5dSChing-Te Ku 	u8 instant_wl_nhm_per_mhz;
1603a2c0ce5dSChing-Te Ku 	u16 valid_record_times;
1604a2c0ce5dSChing-Te Ku 	s8 record_pwr[16];
1605a2c0ce5dSChing-Te Ku 	u8 record_ratio[16];
1606a2c0ce5dSChing-Te Ku 	s8 pwr; /* dbm_per_MHz  */
1607a2c0ce5dSChing-Te Ku 	u8 ratio;
1608a2c0ce5dSChing-Te Ku 	u8 current_status;
1609a2c0ce5dSChing-Te Ku 	u8 refresh;
1610a2c0ce5dSChing-Te Ku 	bool start_flag;
1611a2c0ce5dSChing-Te Ku 	s8 pwr_max;
1612a2c0ce5dSChing-Te Ku 	s8 pwr_min;
1613a2c0ce5dSChing-Te Ku };
1614a2c0ce5dSChing-Te Ku 
1615e3ec7017SPing-Ke Shih struct rtw89_btc_wl_info {
161620d9fc88SPing-Ke Shih 	struct rtw89_btc_wl_link_info link_info[RTW89_PORT_NUM];
1617e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_rfk_info rfk_info;
1618e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_ver_info  ver_info;
1619e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_afh_info afh_info;
1620e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_role_info role_info;
1621e390cf2eSChing-Te Ku 	struct rtw89_btc_wl_role_info_v1 role_info_v1;
16225049964cSChing-Te Ku 	struct rtw89_btc_wl_role_info_v2 role_info_v2;
1623e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_scan_info scan_info;
1624e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_dbcc_info dbcc_info;
1625e3ec7017SPing-Ke Shih 	struct rtw89_btc_rf_para rf_para;
1626a2c0ce5dSChing-Te Ku 	struct rtw89_btc_wl_nhm nhm;
1627e3ec7017SPing-Ke Shih 	union rtw89_btc_wl_state_map status;
1628e3ec7017SPing-Ke Shih 
1629e3ec7017SPing-Ke Shih 	u8 port_id[RTW89_WIFI_ROLE_MLME_MAX];
1630e3ec7017SPing-Ke Shih 	u8 rssi_level;
1631a2c0ce5dSChing-Te Ku 	u8 cn_report;
1632e3ec7017SPing-Ke Shih 
1633ba297a25SChing-Te Ku 	bool scbd_change;
1634e3ec7017SPing-Ke Shih 	u32 scbd;
1635e3ec7017SPing-Ke Shih };
1636e3ec7017SPing-Ke Shih 
1637e3ec7017SPing-Ke Shih struct rtw89_btc_module {
1638e3ec7017SPing-Ke Shih 	struct rtw89_btc_ant_info ant;
1639e3ec7017SPing-Ke Shih 	u8 rfe_type;
1640e3ec7017SPing-Ke Shih 	u8 cv;
1641e3ec7017SPing-Ke Shih 
1642e3ec7017SPing-Ke Shih 	u8 bt_solo: 1;
1643e3ec7017SPing-Ke Shih 	u8 bt_pos: 1;
1644e3ec7017SPing-Ke Shih 	u8 switch_type: 1;
1645c0fea064SPing-Ke Shih 	u8 wa_type: 3;
1646e3ec7017SPing-Ke Shih 
1647c0fea064SPing-Ke Shih 	u8 kt_ver_adie;
1648e3ec7017SPing-Ke Shih };
1649e3ec7017SPing-Ke Shih 
1650e3ec7017SPing-Ke Shih #define RTW89_BTC_DM_MAXSTEP 30
1651e3ec7017SPing-Ke Shih #define RTW89_BTC_DM_CNT_MAX (RTW89_BTC_DM_MAXSTEP * 8)
1652e3ec7017SPing-Ke Shih 
1653e3ec7017SPing-Ke Shih struct rtw89_btc_dm_step {
1654e3ec7017SPing-Ke Shih 	u16 step[RTW89_BTC_DM_MAXSTEP];
1655e3ec7017SPing-Ke Shih 	u8 step_pos;
1656e3ec7017SPing-Ke Shih 	bool step_ov;
1657e3ec7017SPing-Ke Shih };
1658e3ec7017SPing-Ke Shih 
1659e3ec7017SPing-Ke Shih struct rtw89_btc_init_info {
1660e3ec7017SPing-Ke Shih 	struct rtw89_btc_module module;
1661e3ec7017SPing-Ke Shih 	u8 wl_guard_ch;
1662e3ec7017SPing-Ke Shih 
1663e3ec7017SPing-Ke Shih 	u8 wl_only: 1;
1664e3ec7017SPing-Ke Shih 	u8 wl_init_ok: 1;
1665e3ec7017SPing-Ke Shih 	u8 dbcc_en: 1;
1666e3ec7017SPing-Ke Shih 	u8 cx_other: 1;
1667e3ec7017SPing-Ke Shih 	u8 bt_only: 1;
1668e3ec7017SPing-Ke Shih 
1669e3ec7017SPing-Ke Shih 	u16 rsvd;
1670e3ec7017SPing-Ke Shih };
1671e3ec7017SPing-Ke Shih 
1672e3ec7017SPing-Ke Shih struct rtw89_btc_wl_tx_limit_para {
1673e3ec7017SPing-Ke Shih 	u16 enable;
1674e3ec7017SPing-Ke Shih 	u32 tx_time;	/* unit: us */
1675e3ec7017SPing-Ke Shih 	u16 tx_retry;
1676e3ec7017SPing-Ke Shih };
1677e3ec7017SPing-Ke Shih 
1678e3ec7017SPing-Ke Shih enum rtw89_btc_bt_scan_type {
1679e3ec7017SPing-Ke Shih 	BTC_SCAN_INQ	= 0,
1680e3ec7017SPing-Ke Shih 	BTC_SCAN_PAGE,
1681e3ec7017SPing-Ke Shih 	BTC_SCAN_BLE,
1682e3ec7017SPing-Ke Shih 	BTC_SCAN_INIT,
1683e3ec7017SPing-Ke Shih 	BTC_SCAN_TV,
1684e3ec7017SPing-Ke Shih 	BTC_SCAN_ADV,
1685e3ec7017SPing-Ke Shih 	BTC_SCAN_MAX1,
1686e3ec7017SPing-Ke Shih };
1687e3ec7017SPing-Ke Shih 
1688262cc19eSChing-Te Ku enum rtw89_btc_ble_scan_type {
1689262cc19eSChing-Te Ku 	CXSCAN_BG = 0,
1690262cc19eSChing-Te Ku 	CXSCAN_INIT,
1691262cc19eSChing-Te Ku 	CXSCAN_LE,
1692262cc19eSChing-Te Ku 	CXSCAN_MAX
1693262cc19eSChing-Te Ku };
1694262cc19eSChing-Te Ku 
1695262cc19eSChing-Te Ku #define RTW89_BTC_BTC_SCAN_V1_FLAG_ENABLE BIT(0)
1696262cc19eSChing-Te Ku #define RTW89_BTC_BTC_SCAN_V1_FLAG_INTERLACE BIT(1)
1697262cc19eSChing-Te Ku 
1698262cc19eSChing-Te Ku struct rtw89_btc_bt_scan_info_v1 {
1699262cc19eSChing-Te Ku 	__le16 win;
1700262cc19eSChing-Te Ku 	__le16 intvl;
1701262cc19eSChing-Te Ku 	__le32 flags;
1702262cc19eSChing-Te Ku } __packed;
1703262cc19eSChing-Te Ku 
1704262cc19eSChing-Te Ku struct rtw89_btc_bt_scan_info_v2 {
1705262cc19eSChing-Te Ku 	__le16 win;
1706262cc19eSChing-Te Ku 	__le16 intvl;
1707262cc19eSChing-Te Ku } __packed;
1708262cc19eSChing-Te Ku 
1709262cc19eSChing-Te Ku struct rtw89_btc_fbtc_btscan_v1 {
1710262cc19eSChing-Te Ku 	u8 fver; /* btc_ver::fcxbtscan */
1711262cc19eSChing-Te Ku 	u8 rsvd;
1712262cc19eSChing-Te Ku 	__le16 rsvd2;
1713262cc19eSChing-Te Ku 	struct rtw89_btc_bt_scan_info_v1 scan[BTC_SCAN_MAX1];
1714262cc19eSChing-Te Ku } __packed;
1715262cc19eSChing-Te Ku 
1716262cc19eSChing-Te Ku struct rtw89_btc_fbtc_btscan_v2 {
1717262cc19eSChing-Te Ku 	u8 fver; /* btc_ver::fcxbtscan */
1718262cc19eSChing-Te Ku 	u8 type;
1719262cc19eSChing-Te Ku 	__le16 rsvd2;
1720262cc19eSChing-Te Ku 	struct rtw89_btc_bt_scan_info_v2 para[CXSCAN_MAX];
1721262cc19eSChing-Te Ku } __packed;
1722262cc19eSChing-Te Ku 
1723262cc19eSChing-Te Ku union rtw89_btc_fbtc_btscan {
1724262cc19eSChing-Te Ku 	struct rtw89_btc_fbtc_btscan_v1 v1;
1725262cc19eSChing-Te Ku 	struct rtw89_btc_fbtc_btscan_v2 v2;
1726262cc19eSChing-Te Ku };
1727262cc19eSChing-Te Ku 
1728e3ec7017SPing-Ke Shih struct rtw89_btc_bt_info {
1729e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_link_info link_info;
1730262cc19eSChing-Te Ku 	struct rtw89_btc_bt_scan_info_v1 scan_info_v1[BTC_SCAN_MAX1];
1731262cc19eSChing-Te Ku 	struct rtw89_btc_bt_scan_info_v2 scan_info_v2[CXSCAN_MAX];
1732e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_ver_info ver_info;
1733e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg enable;
1734e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg inq_pag;
1735e3ec7017SPing-Ke Shih 	struct rtw89_btc_rf_para rf_para;
1736e3ec7017SPing-Ke Shih 	union rtw89_btc_bt_rfk_info_map rfk_info;
1737e3ec7017SPing-Ke Shih 
1738e3ec7017SPing-Ke Shih 	u8 raw_info[BTC_BTINFO_MAX]; /* raw bt info from mailbox */
1739e3ec7017SPing-Ke Shih 
1740e3ec7017SPing-Ke Shih 	u32 scbd;
1741e3ec7017SPing-Ke Shih 	u32 feature;
1742e3ec7017SPing-Ke Shih 
1743e3ec7017SPing-Ke Shih 	u32 mbx_avl: 1;
1744e3ec7017SPing-Ke Shih 	u32 whql_test: 1;
1745e3ec7017SPing-Ke Shih 	u32 igno_wl: 1;
1746e3ec7017SPing-Ke Shih 	u32 reinit: 1;
1747e3ec7017SPing-Ke Shih 	u32 ble_scan_en: 1;
1748e3ec7017SPing-Ke Shih 	u32 btg_type: 1;
1749e3ec7017SPing-Ke Shih 	u32 inq: 1;
1750e3ec7017SPing-Ke Shih 	u32 pag: 1;
1751e3ec7017SPing-Ke Shih 	u32 run_patch_code: 1;
1752e3ec7017SPing-Ke Shih 	u32 hi_lna_rx: 1;
17534d5468c6SChing-Te Ku 	u32 scan_rx_low_pri: 1;
1754262cc19eSChing-Te Ku 	u32 scan_info_update: 1;
1755262cc19eSChing-Te Ku 	u32 rsvd: 20;
1756e3ec7017SPing-Ke Shih };
1757e3ec7017SPing-Ke Shih 
1758e3ec7017SPing-Ke Shih struct rtw89_btc_cx {
1759e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_info wl;
1760e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_info bt;
1761e3ec7017SPing-Ke Shih 	struct rtw89_btc_3rdcx_info other;
1762e3ec7017SPing-Ke Shih 	u32 state_map;
1763e3ec7017SPing-Ke Shih 	u32 cnt_bt[BTC_BCNT_NUM];
1764e3ec7017SPing-Ke Shih 	u32 cnt_wl[BTC_WCNT_NUM];
1765e3ec7017SPing-Ke Shih };
1766e3ec7017SPing-Ke Shih 
1767e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_tdma {
17681fc4a874SPing-Ke Shih 	u8 type; /* btc_ver::fcxtdma */
1769e3ec7017SPing-Ke Shih 	u8 rxflctrl;
1770e3ec7017SPing-Ke Shih 	u8 txpause;
1771e3ec7017SPing-Ke Shih 	u8 wtgle_n;
1772e3ec7017SPing-Ke Shih 	u8 leak_n;
1773e3ec7017SPing-Ke Shih 	u8 ext_ctrl;
1774ce986f3dSChing-Te Ku 	u8 rxflctrl_role;
1775ce986f3dSChing-Te Ku 	u8 option_ctrl;
1776ce986f3dSChing-Te Ku } __packed;
1777ce986f3dSChing-Te Ku 
1778e0097ac5SChing-Te Ku struct rtw89_btc_fbtc_tdma_v3 {
17791fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxtdma */
1780ce986f3dSChing-Te Ku 	u8 rsvd;
1781ce986f3dSChing-Te Ku 	__le16 rsvd1;
1782ce986f3dSChing-Te Ku 	struct rtw89_btc_fbtc_tdma tdma;
1783e3ec7017SPing-Ke Shih } __packed;
1784e3ec7017SPing-Ke Shih 
1785e0097ac5SChing-Te Ku union rtw89_btc_fbtc_tdma_le32 {
1786e0097ac5SChing-Te Ku 	struct rtw89_btc_fbtc_tdma v1;
1787e0097ac5SChing-Te Ku 	struct rtw89_btc_fbtc_tdma_v3 v3;
1788e0097ac5SChing-Te Ku };
1789e0097ac5SChing-Te Ku 
1790e3ec7017SPing-Ke Shih #define CXMREG_MAX 30
1791e5e52febSChing-Te Ku #define CXMREG_MAX_V2 20
1792e3ec7017SPing-Ke Shih #define FCXMAX_STEP 255 /*STEP trace record cnt, Max:65535, default:255*/
1793e3ec7017SPing-Ke Shih #define BTC_CYCLE_SLOT_MAX 48 /* must be even number, non-zero */
1794e3ec7017SPing-Ke Shih 
17951162584cSChing-Te Ku enum rtw89_btc_bt_sta_counter {
1796e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_REQ = 0,
1797e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_GO = 1,
1798e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_REJECT = 2,
1799e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_FAIL = 3,
1800e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_TIMEOUT = 4,
18011162584cSChing-Te Ku 	BTC_BCNT_HI_TX = 5,
18021162584cSChing-Te Ku 	BTC_BCNT_HI_RX = 6,
18031162584cSChing-Te Ku 	BTC_BCNT_LO_TX = 7,
18041162584cSChing-Te Ku 	BTC_BCNT_LO_RX = 8,
18051162584cSChing-Te Ku 	BTC_BCNT_POLLUTED = 9,
18061162584cSChing-Te Ku 	BTC_BCNT_STA_MAX
1807e3ec7017SPing-Ke Shih };
1808e3ec7017SPing-Ke Shih 
1809d7904ca8SChing-Te Ku enum rtw89_btc_bt_sta_counter_v105 {
1810d7904ca8SChing-Te Ku 	BTC_BCNT_RFK_REQ_V105 = 0,
1811d7904ca8SChing-Te Ku 	BTC_BCNT_HI_TX_V105 = 1,
1812d7904ca8SChing-Te Ku 	BTC_BCNT_HI_RX_V105 = 2,
1813d7904ca8SChing-Te Ku 	BTC_BCNT_LO_TX_V105 = 3,
1814d7904ca8SChing-Te Ku 	BTC_BCNT_LO_RX_V105 = 4,
1815d7904ca8SChing-Te Ku 	BTC_BCNT_POLLUTED_V105 = 5,
1816d7904ca8SChing-Te Ku 	BTC_BCNT_STA_MAX_V105
1817d7904ca8SChing-Te Ku };
1818d7904ca8SChing-Te Ku 
1819b02e3f5cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_v1 {
18201fc4a874SPing-Ke Shih 	u16 fver; /* btc_ver::fcxbtcrpt */
1821e3ec7017SPing-Ke Shih 	u16 rpt_cnt; /* tmr counters */
1822e3ec7017SPing-Ke Shih 	u32 wl_fw_coex_ver; /* match which driver's coex version */
1823e3ec7017SPing-Ke Shih 	u32 wl_fw_cx_offload;
1824e3ec7017SPing-Ke Shih 	u32 wl_fw_ver;
1825e3ec7017SPing-Ke Shih 	u32 rpt_enable;
1826e3ec7017SPing-Ke Shih 	u32 rpt_para; /* ms */
1827e3ec7017SPing-Ke Shih 	u32 mb_send_fail_cnt; /* fw send mailbox fail counter */
1828e3ec7017SPing-Ke Shih 	u32 mb_send_ok_cnt; /* fw send mailbox ok counter */
1829e3ec7017SPing-Ke Shih 	u32 mb_recv_cnt; /* fw recv mailbox counter */
1830e3ec7017SPing-Ke Shih 	u32 mb_a2dp_empty_cnt; /* a2dp empty count */
1831e3ec7017SPing-Ke Shih 	u32 mb_a2dp_flct_cnt; /* a2dp empty flow control counter */
1832e3ec7017SPing-Ke Shih 	u32 mb_a2dp_full_cnt; /* a2dp empty full counter */
18331162584cSChing-Te Ku 	u32 bt_rfk_cnt[BTC_BCNT_HI_TX];
1834e3ec7017SPing-Ke Shih 	u32 c2h_cnt; /* fw send c2h counter  */
1835e3ec7017SPing-Ke Shih 	u32 h2c_cnt; /* fw recv h2c counter */
1836e3ec7017SPing-Ke Shih } __packed;
1837e3ec7017SPing-Ke Shih 
18381162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_info {
18391162584cSChing-Te Ku 	__le32 cnt; /* fw report counter */
18401162584cSChing-Te Ku 	__le32 en; /* report map */
18411162584cSChing-Te Ku 	__le32 para; /* not used */
18421162584cSChing-Te Ku 
18431162584cSChing-Te Ku 	__le32 cnt_c2h; /* fw send c2h counter  */
18441162584cSChing-Te Ku 	__le32 cnt_h2c; /* fw recv h2c counter */
18451162584cSChing-Te Ku 	__le32 len_c2h; /* The total length of the last C2H  */
18461162584cSChing-Te Ku 
18471162584cSChing-Te Ku 	__le32 cnt_aoac_rf_on;  /* rf-on counter for aoac switch notify */
18481162584cSChing-Te Ku 	__le32 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */
18491162584cSChing-Te Ku } __packed;
18501162584cSChing-Te Ku 
18510c06fd47SChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_info_v5 {
18520c06fd47SChing-Te Ku 	__le32 cx_ver; /* match which driver's coex version */
18530c06fd47SChing-Te Ku 	__le32 fw_ver;
18540c06fd47SChing-Te Ku 	__le32 en; /* report map */
18550c06fd47SChing-Te Ku 
18560c06fd47SChing-Te Ku 	__le16 cnt; /* fw report counter */
18570c06fd47SChing-Te Ku 	__le16 cnt_c2h; /* fw send c2h counter  */
18580c06fd47SChing-Te Ku 	__le16 cnt_h2c; /* fw recv h2c counter */
18590c06fd47SChing-Te Ku 	__le16 len_c2h; /* The total length of the last C2H  */
18600c06fd47SChing-Te Ku 
18610c06fd47SChing-Te Ku 	__le16 cnt_aoac_rf_on;  /* rf-on counter for aoac switch notify */
18620c06fd47SChing-Te Ku 	__le16 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */
18630c06fd47SChing-Te Ku } __packed;
18640c06fd47SChing-Te Ku 
18651162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info {
18661162584cSChing-Te Ku 	__le32 cx_ver; /* match which driver's coex version */
18671162584cSChing-Te Ku 	__le32 cx_offload;
18681162584cSChing-Te Ku 	__le32 fw_ver;
18691162584cSChing-Te Ku } __packed;
18701162584cSChing-Te Ku 
18711162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty {
18721162584cSChing-Te Ku 	__le32 cnt_empty; /* a2dp empty count */
18731162584cSChing-Te Ku 	__le32 cnt_flowctrl; /* a2dp empty flow control counter */
18741162584cSChing-Te Ku 	__le32 cnt_tx;
18751162584cSChing-Te Ku 	__le32 cnt_ack;
18761162584cSChing-Te Ku 	__le32 cnt_nack;
18771162584cSChing-Te Ku } __packed;
18781162584cSChing-Te Ku 
18791162584cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox {
18801162584cSChing-Te Ku 	__le32 cnt_send_ok; /* fw send mailbox ok counter */
18811162584cSChing-Te Ku 	__le32 cnt_send_fail; /* fw send mailbox fail counter */
18821162584cSChing-Te Ku 	__le32 cnt_recv; /* fw recv mailbox counter */
18831162584cSChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty a2dp;
18841162584cSChing-Te Ku } __packed;
18851162584cSChing-Te Ku 
1886b02e3f5cSChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_v4 {
18871162584cSChing-Te Ku 	u8 fver;
18881162584cSChing-Te Ku 	u8 rsvd;
18891162584cSChing-Te Ku 	__le16 rsvd1;
18901162584cSChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_info rpt_info;
18911162584cSChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info wl_fw_info;
18921162584cSChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
18931162584cSChing-Te Ku 	__le32 bt_cnt[BTC_BCNT_STA_MAX];
18941162584cSChing-Te Ku 	struct rtw89_mac_ax_gnt gnt_val[RTW89_PHY_MAX];
18951162584cSChing-Te Ku } __packed;
18961162584cSChing-Te Ku 
18970c06fd47SChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_v5 {
18980c06fd47SChing-Te Ku 	u8 fver;
18990c06fd47SChing-Te Ku 	u8 rsvd;
19000c06fd47SChing-Te Ku 	__le16 rsvd1;
19010c06fd47SChing-Te Ku 
19020c06fd47SChing-Te Ku 	u8 gnt_val[RTW89_PHY_MAX][4];
19030c06fd47SChing-Te Ku 	__le16 bt_cnt[BTC_BCNT_STA_MAX];
19040c06fd47SChing-Te Ku 
19050c06fd47SChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_info_v5 rpt_info;
19060c06fd47SChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
19070c06fd47SChing-Te Ku } __packed;
19080c06fd47SChing-Te Ku 
1909d7904ca8SChing-Te Ku struct rtw89_btc_fbtc_rpt_ctrl_v105 {
1910d7904ca8SChing-Te Ku 	u8 fver;
1911d7904ca8SChing-Te Ku 	u8 rsvd;
1912d7904ca8SChing-Te Ku 	__le16 rsvd1;
1913d7904ca8SChing-Te Ku 
1914d7904ca8SChing-Te Ku 	u8 gnt_val[RTW89_PHY_MAX][4];
1915d7904ca8SChing-Te Ku 	__le16 bt_cnt[BTC_BCNT_STA_MAX_V105];
1916d7904ca8SChing-Te Ku 
1917d7904ca8SChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_info_v5 rpt_info;
1918d7904ca8SChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
1919d7904ca8SChing-Te Ku } __packed;
1920d7904ca8SChing-Te Ku 
1921b02e3f5cSChing-Te Ku union rtw89_btc_fbtc_rpt_ctrl_ver_info {
1922b02e3f5cSChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_v1 v1;
1923b02e3f5cSChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_v4 v4;
19240c06fd47SChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_v5 v5;
1925d7904ca8SChing-Te Ku 	struct rtw89_btc_fbtc_rpt_ctrl_v105 v105;
1926b02e3f5cSChing-Te Ku };
1927b02e3f5cSChing-Te Ku 
1928e3ec7017SPing-Ke Shih enum rtw89_fbtc_ext_ctrl_type {
1929e3ec7017SPing-Ke Shih 	CXECTL_OFF = 0x0, /* tdma off */
1930e3ec7017SPing-Ke Shih 	CXECTL_B2 = 0x1, /* allow B2 (beacon-early) */
1931e3ec7017SPing-Ke Shih 	CXECTL_EXT = 0x2,
1932e3ec7017SPing-Ke Shih 	CXECTL_MAX
1933e3ec7017SPing-Ke Shih };
1934e3ec7017SPing-Ke Shih 
1935e3ec7017SPing-Ke Shih union rtw89_btc_fbtc_rxflct {
1936e3ec7017SPing-Ke Shih 	u8 val;
1937e3ec7017SPing-Ke Shih 	u8 type: 3;
1938e3ec7017SPing-Ke Shih 	u8 tgln_n: 5;
1939e3ec7017SPing-Ke Shih };
1940e3ec7017SPing-Ke Shih 
1941e3ec7017SPing-Ke Shih enum rtw89_btc_cxst_state {
1942e3ec7017SPing-Ke Shih 	CXST_OFF = 0x0,
1943e3ec7017SPing-Ke Shih 	CXST_B2W = 0x1,
1944e3ec7017SPing-Ke Shih 	CXST_W1 = 0x2,
1945e3ec7017SPing-Ke Shih 	CXST_W2 = 0x3,
1946e3ec7017SPing-Ke Shih 	CXST_W2B = 0x4,
1947e3ec7017SPing-Ke Shih 	CXST_B1 = 0x5,
1948e3ec7017SPing-Ke Shih 	CXST_B2 = 0x6,
1949e3ec7017SPing-Ke Shih 	CXST_B3 = 0x7,
1950e3ec7017SPing-Ke Shih 	CXST_B4 = 0x8,
1951e3ec7017SPing-Ke Shih 	CXST_LK = 0x9,
1952e3ec7017SPing-Ke Shih 	CXST_BLK = 0xa,
1953e3ec7017SPing-Ke Shih 	CXST_E2G = 0xb,
1954e3ec7017SPing-Ke Shih 	CXST_E5G = 0xc,
1955e3ec7017SPing-Ke Shih 	CXST_EBT = 0xd,
1956e3ec7017SPing-Ke Shih 	CXST_ENULL = 0xe,
1957e3ec7017SPing-Ke Shih 	CXST_WLK = 0xf,
1958e3ec7017SPing-Ke Shih 	CXST_W1FDD = 0x10,
1959e3ec7017SPing-Ke Shih 	CXST_B1FDD = 0x11,
1960e3ec7017SPing-Ke Shih 	CXST_MAX = 0x12,
1961e3ec7017SPing-Ke Shih };
1962e3ec7017SPing-Ke Shih 
19632626ccefSChing-Te Ku enum rtw89_btc_cxevnt {
19642626ccefSChing-Te Ku 	CXEVNT_TDMA_ENTRY = 0x0,
19652626ccefSChing-Te Ku 	CXEVNT_WL_TMR,
19662626ccefSChing-Te Ku 	CXEVNT_B1_TMR,
19672626ccefSChing-Te Ku 	CXEVNT_B2_TMR,
19682626ccefSChing-Te Ku 	CXEVNT_B3_TMR,
19692626ccefSChing-Te Ku 	CXEVNT_B4_TMR,
19702626ccefSChing-Te Ku 	CXEVNT_W2B_TMR,
19712626ccefSChing-Te Ku 	CXEVNT_B2W_TMR,
19722626ccefSChing-Te Ku 	CXEVNT_BCN_EARLY,
19732626ccefSChing-Te Ku 	CXEVNT_A2DP_EMPTY,
19742626ccefSChing-Te Ku 	CXEVNT_LK_END,
19752626ccefSChing-Te Ku 	CXEVNT_RX_ISR,
19762626ccefSChing-Te Ku 	CXEVNT_RX_FC0,
19772626ccefSChing-Te Ku 	CXEVNT_RX_FC1,
19782626ccefSChing-Te Ku 	CXEVNT_BT_RELINK,
19792626ccefSChing-Te Ku 	CXEVNT_BT_RETRY,
19802626ccefSChing-Te Ku 	CXEVNT_E2G,
19812626ccefSChing-Te Ku 	CXEVNT_E5G,
19822626ccefSChing-Te Ku 	CXEVNT_EBT,
19832626ccefSChing-Te Ku 	CXEVNT_ENULL,
19842626ccefSChing-Te Ku 	CXEVNT_DRV_WLK,
19852626ccefSChing-Te Ku 	CXEVNT_BCN_OK,
19862626ccefSChing-Te Ku 	CXEVNT_BT_CHANGE,
19872626ccefSChing-Te Ku 	CXEVNT_EBT_EXTEND,
19882626ccefSChing-Te Ku 	CXEVNT_E2G_NULL1,
19892626ccefSChing-Te Ku 	CXEVNT_B1FDD_TMR,
19902626ccefSChing-Te Ku 	CXEVNT_MAX
19912626ccefSChing-Te Ku };
19922626ccefSChing-Te Ku 
1993e3ec7017SPing-Ke Shih enum {
1994e3ec7017SPing-Ke Shih 	CXBCN_ALL = 0x0,
1995e3ec7017SPing-Ke Shih 	CXBCN_ALL_OK,
1996e3ec7017SPing-Ke Shih 	CXBCN_BT_SLOT,
1997e3ec7017SPing-Ke Shih 	CXBCN_BT_OK,
1998e3ec7017SPing-Ke Shih 	CXBCN_MAX
1999e3ec7017SPing-Ke Shih };
2000e3ec7017SPing-Ke Shih 
2001e3ec7017SPing-Ke Shih enum btc_slot_type {
2002e3ec7017SPing-Ke Shih 	SLOT_MIX = 0x0, /* accept BT Lower-Pri Tx/Rx request 0x778 = 1 */
2003e3ec7017SPing-Ke Shih 	SLOT_ISO = 0x1, /* no accept BT Lower-Pri Tx/Rx request 0x778 = d*/
2004e3ec7017SPing-Ke Shih 	CXSTYPE_NUM,
2005e3ec7017SPing-Ke Shih };
2006e3ec7017SPing-Ke Shih 
2007e3ec7017SPing-Ke Shih enum { /* TIME */
2008e3ec7017SPing-Ke Shih 	CXT_BT = 0x0,
2009e3ec7017SPing-Ke Shih 	CXT_WL = 0x1,
2010e3ec7017SPing-Ke Shih 	CXT_MAX
2011e3ec7017SPing-Ke Shih };
2012e3ec7017SPing-Ke Shih 
2013e3ec7017SPing-Ke Shih enum { /* TIME-A2DP */
2014e3ec7017SPing-Ke Shih 	CXT_FLCTRL_OFF = 0x0,
2015e3ec7017SPing-Ke Shih 	CXT_FLCTRL_ON = 0x1,
2016e3ec7017SPing-Ke Shih 	CXT_FLCTRL_MAX
2017e3ec7017SPing-Ke Shih };
2018e3ec7017SPing-Ke Shih 
2019e3ec7017SPing-Ke Shih enum { /* STEP TYPE */
2020e3ec7017SPing-Ke Shih 	CXSTEP_NONE = 0x0,
2021e3ec7017SPing-Ke Shih 	CXSTEP_EVNT = 0x1,
2022e3ec7017SPing-Ke Shih 	CXSTEP_SLOT = 0x2,
2023e3ec7017SPing-Ke Shih 	CXSTEP_MAX,
2024e3ec7017SPing-Ke Shih };
2025e3ec7017SPing-Ke Shih 
20260cdfcfceSChing-Te Ku enum rtw89_btc_afh_map_type { /*AFH MAP TYPE */
20270cdfcfceSChing-Te Ku 	RPT_BT_AFH_SEQ_LEGACY = 0x10,
20280cdfcfceSChing-Te Ku 	RPT_BT_AFH_SEQ_LE = 0x20
20290cdfcfceSChing-Te Ku };
20300cdfcfceSChing-Te Ku 
2031e3ec7017SPing-Ke Shih #define BTC_DBG_MAX1  32
2032e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_gpio_dbg {
20331fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxgpiodbg */
2034e3ec7017SPing-Ke Shih 	u8 rsvd;
2035e3ec7017SPing-Ke Shih 	u16 rsvd2;
2036e3ec7017SPing-Ke Shih 	u32 en_map; /* which debug signal (see btc_wl_gpio_debug) is enable */
2037e3ec7017SPing-Ke Shih 	u32 pre_state; /* the debug signal is 1 or 0  */
2038e3ec7017SPing-Ke Shih 	u8 gpio_map[BTC_DBG_MAX1]; /*the debug signals to GPIO-Position */
2039e3ec7017SPing-Ke Shih } __packed;
2040e3ec7017SPing-Ke Shih 
2041e5e52febSChing-Te Ku struct rtw89_btc_fbtc_mreg_val_v1 {
20421fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxmreg */
2043e3ec7017SPing-Ke Shih 	u8 reg_num;
2044e3ec7017SPing-Ke Shih 	__le16 rsvd;
2045e3ec7017SPing-Ke Shih 	__le32 mreg_val[CXMREG_MAX];
2046e3ec7017SPing-Ke Shih } __packed;
2047e3ec7017SPing-Ke Shih 
2048e5e52febSChing-Te Ku struct rtw89_btc_fbtc_mreg_val_v2 {
2049e5e52febSChing-Te Ku 	u8 fver; /* btc_ver::fcxmreg */
2050e5e52febSChing-Te Ku 	u8 reg_num;
2051e5e52febSChing-Te Ku 	__le16 rsvd;
2052e5e52febSChing-Te Ku 	__le32 mreg_val[CXMREG_MAX_V2];
2053e5e52febSChing-Te Ku } __packed;
2054e5e52febSChing-Te Ku 
2055e5e52febSChing-Te Ku union rtw89_btc_fbtc_mreg_val {
2056e5e52febSChing-Te Ku 	struct rtw89_btc_fbtc_mreg_val_v1 v1;
2057e5e52febSChing-Te Ku 	struct rtw89_btc_fbtc_mreg_val_v2 v2;
2058e5e52febSChing-Te Ku };
2059e5e52febSChing-Te Ku 
2060e3ec7017SPing-Ke Shih #define RTW89_DEF_FBTC_MREG(__type, __bytes, __offset) \
2061e3ec7017SPing-Ke Shih 	{ .type = cpu_to_le16(__type), .bytes = cpu_to_le16(__bytes), \
2062e3ec7017SPing-Ke Shih 	  .offset = cpu_to_le32(__offset), }
2063e3ec7017SPing-Ke Shih 
2064e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_mreg {
2065e3ec7017SPing-Ke Shih 	__le16 type;
2066e3ec7017SPing-Ke Shih 	__le16 bytes;
2067e3ec7017SPing-Ke Shih 	__le32 offset;
2068e3ec7017SPing-Ke Shih } __packed;
2069e3ec7017SPing-Ke Shih 
2070e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slot {
2071e3ec7017SPing-Ke Shih 	__le16 dur;
2072e3ec7017SPing-Ke Shih 	__le32 cxtbl;
2073e3ec7017SPing-Ke Shih 	__le16 cxtype;
2074e3ec7017SPing-Ke Shih } __packed;
2075e3ec7017SPing-Ke Shih 
2076e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slots {
20771fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxslots */
2078e3ec7017SPing-Ke Shih 	u8 tbl_num;
2079e3ec7017SPing-Ke Shih 	__le16 rsvd;
2080e3ec7017SPing-Ke Shih 	__le32 update_map;
2081e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slot slot[CXST_MAX];
2082e3ec7017SPing-Ke Shih } __packed;
2083e3ec7017SPing-Ke Shih 
2084e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_step {
2085e3ec7017SPing-Ke Shih 	u8 type;
2086e3ec7017SPing-Ke Shih 	u8 val;
2087e3ec7017SPing-Ke Shih 	__le16 difft;
2088e3ec7017SPing-Ke Shih } __packed;
2089e3ec7017SPing-Ke Shih 
20902626ccefSChing-Te Ku struct rtw89_btc_fbtc_steps_v2 {
20911fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxstep */
2092e3ec7017SPing-Ke Shih 	u8 rsvd;
2093e3ec7017SPing-Ke Shih 	__le16 cnt;
2094e3ec7017SPing-Ke Shih 	__le16 pos_old;
2095e3ec7017SPing-Ke Shih 	__le16 pos_new;
2096e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_step step[FCXMAX_STEP];
2097e3ec7017SPing-Ke Shih } __packed;
2098e3ec7017SPing-Ke Shih 
20992626ccefSChing-Te Ku struct rtw89_btc_fbtc_steps_v3 {
2100b696d422SChing-Te Ku 	u8 fver;
2101b696d422SChing-Te Ku 	u8 en;
2102b696d422SChing-Te Ku 	__le16 rsvd;
2103b696d422SChing-Te Ku 	__le32 cnt;
2104b696d422SChing-Te Ku 	struct rtw89_btc_fbtc_step step[FCXMAX_STEP];
2105b696d422SChing-Te Ku } __packed;
2106b696d422SChing-Te Ku 
21072626ccefSChing-Te Ku union rtw89_btc_fbtc_steps_info {
21082626ccefSChing-Te Ku 	struct rtw89_btc_fbtc_steps_v2 v2;
21092626ccefSChing-Te Ku 	struct rtw89_btc_fbtc_steps_v3 v3;
21102626ccefSChing-Te Ku };
21112626ccefSChing-Te Ku 
2112fab895b3SChing-Te Ku struct rtw89_btc_fbtc_cysta_v2 { /* statistics for cycles */
21131fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxcysta */
2114e3ec7017SPing-Ke Shih 	u8 rsvd;
2115e3ec7017SPing-Ke Shih 	__le16 cycles; /* total cycle number */
2116e3ec7017SPing-Ke Shih 	__le16 cycles_a2dp[CXT_FLCTRL_MAX];
2117e3ec7017SPing-Ke Shih 	__le16 a2dpept; /* a2dp empty cnt */
2118e3ec7017SPing-Ke Shih 	__le16 a2dpeptto; /* a2dp empty timeout cnt*/
2119e3ec7017SPing-Ke Shih 	__le16 tavg_cycle[CXT_MAX]; /* avg wl/bt cycle time */
2120e3ec7017SPing-Ke Shih 	__le16 tmax_cycle[CXT_MAX]; /* max wl/bt cycle time */
2121e3ec7017SPing-Ke Shih 	__le16 tmaxdiff_cycle[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */
2122e3ec7017SPing-Ke Shih 	__le16 tavg_a2dp[CXT_FLCTRL_MAX]; /* avg a2dp PSTDMA/TDMA time */
2123e3ec7017SPing-Ke Shih 	__le16 tmax_a2dp[CXT_FLCTRL_MAX]; /* max a2dp PSTDMA/TDMA time */
2124e3ec7017SPing-Ke Shih 	__le16 tavg_a2dpept; /* avg a2dp empty time */
2125e3ec7017SPing-Ke Shih 	__le16 tmax_a2dpept; /* max a2dp empty time */
2126e3ec7017SPing-Ke Shih 	__le16 tavg_lk; /* avg leak-slot time */
2127e3ec7017SPing-Ke Shih 	__le16 tmax_lk; /* max leak-slot time */
2128e3ec7017SPing-Ke Shih 	__le32 slot_cnt[CXST_MAX]; /* slot count */
2129e3ec7017SPing-Ke Shih 	__le32 bcn_cnt[CXBCN_MAX];
2130e3ec7017SPing-Ke Shih 	__le32 leakrx_cnt; /* the rximr occur at leak slot  */
2131e3ec7017SPing-Ke Shih 	__le32 collision_cnt; /* counter for event/timer occur at same time */
2132e3ec7017SPing-Ke Shih 	__le32 skip_cnt;
2133e3ec7017SPing-Ke Shih 	__le32 exception;
2134e3ec7017SPing-Ke Shih 	__le32 except_cnt;
2135e3ec7017SPing-Ke Shih 	__le16 tslot_cycle[BTC_CYCLE_SLOT_MAX];
2136e3ec7017SPing-Ke Shih } __packed;
2137e3ec7017SPing-Ke Shih 
21383832a542SChing-Te Ku struct rtw89_btc_fbtc_fdd_try_info {
21393832a542SChing-Te Ku 	__le16 cycles[CXT_FLCTRL_MAX];
21403832a542SChing-Te Ku 	__le16 tavg[CXT_FLCTRL_MAX]; /* avg try BT-Slot-TDD/BT-slot-FDD time */
21413832a542SChing-Te Ku 	__le16 tmax[CXT_FLCTRL_MAX]; /* max try BT-Slot-TDD/BT-slot-FDD time */
21423832a542SChing-Te Ku } __packed;
21433832a542SChing-Te Ku 
21443832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_time_info {
21453832a542SChing-Te Ku 	__le16 tavg[CXT_MAX]; /* avg wl/bt cycle time */
21463832a542SChing-Te Ku 	__le16 tmax[CXT_MAX]; /* max wl/bt cycle time */
21473832a542SChing-Te Ku 	__le16 tmaxdiff[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */
21483832a542SChing-Te Ku } __packed;
21493832a542SChing-Te Ku 
21503ab7f9b9SChing-Te Ku struct rtw89_btc_fbtc_cycle_time_info_v5 {
21513ab7f9b9SChing-Te Ku 	__le16 tavg[CXT_MAX]; /* avg wl/bt cycle time */
21523ab7f9b9SChing-Te Ku 	__le16 tmax[CXT_MAX]; /* max wl/bt cycle time */
21533ab7f9b9SChing-Te Ku } __packed;
21543ab7f9b9SChing-Te Ku 
21553832a542SChing-Te Ku struct rtw89_btc_fbtc_a2dp_trx_stat {
21563832a542SChing-Te Ku 	u8 empty_cnt;
21573832a542SChing-Te Ku 	u8 retry_cnt;
21583832a542SChing-Te Ku 	u8 tx_rate;
21593832a542SChing-Te Ku 	u8 tx_cnt;
21603832a542SChing-Te Ku 	u8 ack_cnt;
21613832a542SChing-Te Ku 	u8 nack_cnt;
21623832a542SChing-Te Ku 	u8 rsvd1;
21633832a542SChing-Te Ku 	u8 rsvd2;
21643832a542SChing-Te Ku } __packed;
21653832a542SChing-Te Ku 
2166202c3b5cSChing-Te Ku struct rtw89_btc_fbtc_a2dp_trx_stat_v4 {
2167202c3b5cSChing-Te Ku 	u8 empty_cnt;
2168202c3b5cSChing-Te Ku 	u8 retry_cnt;
2169202c3b5cSChing-Te Ku 	u8 tx_rate;
2170202c3b5cSChing-Te Ku 	u8 tx_cnt;
2171202c3b5cSChing-Te Ku 	u8 ack_cnt;
2172202c3b5cSChing-Te Ku 	u8 nack_cnt;
2173202c3b5cSChing-Te Ku 	u8 no_empty_cnt;
2174202c3b5cSChing-Te Ku 	u8 rsvd;
2175202c3b5cSChing-Te Ku } __packed;
2176202c3b5cSChing-Te Ku 
21773832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_a2dp_empty_info {
21783832a542SChing-Te Ku 	__le16 cnt; /* a2dp empty cnt */
21793832a542SChing-Te Ku 	__le16 cnt_timeout; /* a2dp empty timeout cnt*/
21803832a542SChing-Te Ku 	__le16 tavg; /* avg a2dp empty time */
21813832a542SChing-Te Ku 	__le16 tmax; /* max a2dp empty time */
21823832a542SChing-Te Ku } __packed;
21833832a542SChing-Te Ku 
21843832a542SChing-Te Ku struct rtw89_btc_fbtc_cycle_leak_info {
21853832a542SChing-Te Ku 	__le32 cnt_rximr; /* the rximr occur at leak slot  */
21863832a542SChing-Te Ku 	__le16 tavg; /* avg leak-slot time */
21873832a542SChing-Te Ku 	__le16 tmax; /* max leak-slot time */
21883832a542SChing-Te Ku } __packed;
21893832a542SChing-Te Ku 
2190202c3b5cSChing-Te Ku #define RTW89_BTC_FDDT_PHASE_CYCLE GENMASK(9, 0)
2191202c3b5cSChing-Te Ku #define RTW89_BTC_FDDT_TRAIN_STEP GENMASK(15, 10)
2192202c3b5cSChing-Te Ku 
2193202c3b5cSChing-Te Ku struct rtw89_btc_fbtc_cycle_fddt_info {
2194202c3b5cSChing-Te Ku 	__le16 train_cycle;
2195202c3b5cSChing-Te Ku 	__le16 tp;
2196202c3b5cSChing-Te Ku 
2197202c3b5cSChing-Te Ku 	s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
2198202c3b5cSChing-Te Ku 	s8 bt_tx_power; /* decrease Tx power (dB) */
2199202c3b5cSChing-Te Ku 	s8 bt_rx_gain;  /* LNA constrain level */
2200202c3b5cSChing-Te Ku 	u8 no_empty_cnt;
2201202c3b5cSChing-Te Ku 
2202202c3b5cSChing-Te Ku 	u8 rssi; /* [7:4] -> bt_rssi_level, [3:0]-> wl_rssi_level */
2203202c3b5cSChing-Te Ku 	u8 cn; /* condition_num */
2204202c3b5cSChing-Te Ku 	u8 train_status; /* [7:4]-> train-state, [3:0]-> train-phase */
2205202c3b5cSChing-Te Ku 	u8 train_result; /* refer to enum btc_fddt_check_map */
2206202c3b5cSChing-Te Ku } __packed;
2207202c3b5cSChing-Te Ku 
2208202c3b5cSChing-Te Ku #define RTW89_BTC_FDDT_CELL_TRAIN_STATE GENMASK(3, 0)
2209202c3b5cSChing-Te Ku #define RTW89_BTC_FDDT_CELL_TRAIN_PHASE GENMASK(7, 4)
2210202c3b5cSChing-Te Ku 
22113ab7f9b9SChing-Te Ku struct rtw89_btc_fbtc_cycle_fddt_info_v5 {
22123ab7f9b9SChing-Te Ku 	__le16 train_cycle;
22133ab7f9b9SChing-Te Ku 	__le16 tp;
22143ab7f9b9SChing-Te Ku 
22153ab7f9b9SChing-Te Ku 	s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
22163ab7f9b9SChing-Te Ku 	s8 bt_tx_power; /* decrease Tx power (dB) */
22173ab7f9b9SChing-Te Ku 	s8 bt_rx_gain;  /* LNA constrain level */
22183ab7f9b9SChing-Te Ku 	u8 no_empty_cnt;
22193ab7f9b9SChing-Te Ku 
22203ab7f9b9SChing-Te Ku 	u8 rssi; /* [7:4] -> bt_rssi_level, [3:0]-> wl_rssi_level */
22213ab7f9b9SChing-Te Ku 	u8 cn; /* condition_num */
22223ab7f9b9SChing-Te Ku 	u8 train_status; /* [7:4]-> train-state, [3:0]-> train-phase */
22233ab7f9b9SChing-Te Ku 	u8 train_result; /* refer to enum btc_fddt_check_map */
22243ab7f9b9SChing-Te Ku } __packed;
22253ab7f9b9SChing-Te Ku 
2226202c3b5cSChing-Te Ku struct rtw89_btc_fbtc_fddt_cell_status {
2227202c3b5cSChing-Te Ku 	s8 wl_tx_pwr;
2228202c3b5cSChing-Te Ku 	s8 bt_tx_pwr;
2229202c3b5cSChing-Te Ku 	s8 bt_rx_gain;
2230202c3b5cSChing-Te Ku 	u8 state_phase; /* [0:3] train state, [4:7] train phase */
2231202c3b5cSChing-Te Ku } __packed;
2232202c3b5cSChing-Te Ku 
2233fab895b3SChing-Te Ku struct rtw89_btc_fbtc_cysta_v3 { /* statistics for cycles */
22343832a542SChing-Te Ku 	u8 fver;
22353832a542SChing-Te Ku 	u8 rsvd;
22363832a542SChing-Te Ku 	__le16 cycles; /* total cycle number */
22373832a542SChing-Te Ku 	__le16 slot_step_time[BTC_CYCLE_SLOT_MAX];
22383832a542SChing-Te Ku 	struct rtw89_btc_fbtc_cycle_time_info cycle_time;
22393832a542SChing-Te Ku 	struct rtw89_btc_fbtc_fdd_try_info fdd_try;
22403832a542SChing-Te Ku 	struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
22413832a542SChing-Te Ku 	struct rtw89_btc_fbtc_a2dp_trx_stat a2dp_trx[BTC_CYCLE_SLOT_MAX];
22423832a542SChing-Te Ku 	struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
22433832a542SChing-Te Ku 	__le32 slot_cnt[CXST_MAX]; /* slot count */
22443832a542SChing-Te Ku 	__le32 bcn_cnt[CXBCN_MAX];
22453832a542SChing-Te Ku 	__le32 collision_cnt; /* counter for event/timer occur at the same time */
22463832a542SChing-Te Ku 	__le32 skip_cnt;
22473832a542SChing-Te Ku 	__le32 except_cnt;
22483832a542SChing-Te Ku 	__le32 except_map;
22493832a542SChing-Te Ku } __packed;
22503832a542SChing-Te Ku 
2251202c3b5cSChing-Te Ku #define FDD_TRAIN_WL_DIRECTION 2
2252202c3b5cSChing-Te Ku #define FDD_TRAIN_WL_RSSI_LEVEL 5
2253202c3b5cSChing-Te Ku #define FDD_TRAIN_BT_RSSI_LEVEL 5
2254202c3b5cSChing-Te Ku 
2255202c3b5cSChing-Te Ku struct rtw89_btc_fbtc_cysta_v4 { /* statistics for cycles */
2256202c3b5cSChing-Te Ku 	u8 fver;
2257202c3b5cSChing-Te Ku 	u8 rsvd;
2258202c3b5cSChing-Te Ku 	u8 collision_cnt; /* counter for event/timer occur at the same time */
2259202c3b5cSChing-Te Ku 	u8 except_cnt;
2260202c3b5cSChing-Te Ku 
2261202c3b5cSChing-Te Ku 	__le16 skip_cnt;
2262202c3b5cSChing-Te Ku 	__le16 cycles; /* total cycle number */
2263202c3b5cSChing-Te Ku 
2264202c3b5cSChing-Te Ku 	__le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; /* record the wl/bt slot time */
2265202c3b5cSChing-Te Ku 	__le16 slot_cnt[CXST_MAX]; /* slot count */
2266202c3b5cSChing-Te Ku 	__le16 bcn_cnt[CXBCN_MAX];
2267202c3b5cSChing-Te Ku 	struct rtw89_btc_fbtc_cycle_time_info cycle_time;
2268202c3b5cSChing-Te Ku 	struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
2269202c3b5cSChing-Te Ku 	struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
2270202c3b5cSChing-Te Ku 	struct rtw89_btc_fbtc_a2dp_trx_stat_v4 a2dp_trx[BTC_CYCLE_SLOT_MAX];
2271202c3b5cSChing-Te Ku 	struct rtw89_btc_fbtc_cycle_fddt_info fddt_trx[BTC_CYCLE_SLOT_MAX];
2272202c3b5cSChing-Te Ku 	struct rtw89_btc_fbtc_fddt_cell_status fddt_cells[FDD_TRAIN_WL_DIRECTION]
2273202c3b5cSChing-Te Ku 							 [FDD_TRAIN_WL_RSSI_LEVEL]
2274202c3b5cSChing-Te Ku 							 [FDD_TRAIN_BT_RSSI_LEVEL];
2275202c3b5cSChing-Te Ku 	__le32 except_map;
2276202c3b5cSChing-Te Ku } __packed;
2277202c3b5cSChing-Te Ku 
22783ab7f9b9SChing-Te Ku struct rtw89_btc_fbtc_cysta_v5 { /* statistics for cycles */
22793ab7f9b9SChing-Te Ku 	u8 fver;
22803ab7f9b9SChing-Te Ku 	u8 rsvd;
22813ab7f9b9SChing-Te Ku 	u8 collision_cnt; /* counter for event/timer occur at the same time */
22823ab7f9b9SChing-Te Ku 	u8 except_cnt;
22833ab7f9b9SChing-Te Ku 	u8 wl_rx_err_ratio[BTC_CYCLE_SLOT_MAX];
22843ab7f9b9SChing-Te Ku 
22853ab7f9b9SChing-Te Ku 	__le16 skip_cnt;
22863ab7f9b9SChing-Te Ku 	__le16 cycles; /* total cycle number */
22873ab7f9b9SChing-Te Ku 
22883ab7f9b9SChing-Te Ku 	__le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; /* record the wl/bt slot time */
22893ab7f9b9SChing-Te Ku 	__le16 slot_cnt[CXST_MAX]; /* slot count */
22903ab7f9b9SChing-Te Ku 	__le16 bcn_cnt[CXBCN_MAX];
22913ab7f9b9SChing-Te Ku 	struct rtw89_btc_fbtc_cycle_time_info_v5 cycle_time;
22923ab7f9b9SChing-Te Ku 	struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
22933ab7f9b9SChing-Te Ku 	struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
22943ab7f9b9SChing-Te Ku 	struct rtw89_btc_fbtc_a2dp_trx_stat_v4 a2dp_trx[BTC_CYCLE_SLOT_MAX];
22953ab7f9b9SChing-Te Ku 	struct rtw89_btc_fbtc_cycle_fddt_info_v5 fddt_trx[BTC_CYCLE_SLOT_MAX];
2296*84ff6a96SChing-Te Ku 	struct rtw89_btc_fbtc_fddt_cell_status fddt_cells[FDD_TRAIN_WL_DIRECTION]
22973ab7f9b9SChing-Te Ku 							 [FDD_TRAIN_WL_RSSI_LEVEL]
22983ab7f9b9SChing-Te Ku 							 [FDD_TRAIN_BT_RSSI_LEVEL];
22993ab7f9b9SChing-Te Ku 	__le32 except_map;
23003ab7f9b9SChing-Te Ku } __packed;
23013ab7f9b9SChing-Te Ku 
2302fab895b3SChing-Te Ku union rtw89_btc_fbtc_cysta_info {
2303fab895b3SChing-Te Ku 	struct rtw89_btc_fbtc_cysta_v2 v2;
2304fab895b3SChing-Te Ku 	struct rtw89_btc_fbtc_cysta_v3 v3;
2305202c3b5cSChing-Te Ku 	struct rtw89_btc_fbtc_cysta_v4 v4;
23063ab7f9b9SChing-Te Ku 	struct rtw89_btc_fbtc_cysta_v5 v5;
2307fab895b3SChing-Te Ku };
2308fab895b3SChing-Te Ku 
23093d929f07SChing-Te Ku struct rtw89_btc_fbtc_cynullsta_v1 { /* cycle null statistics */
23101fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxnullsta */
2311e3ec7017SPing-Ke Shih 	u8 rsvd;
2312e3ec7017SPing-Ke Shih 	__le16 rsvd2;
2313e3ec7017SPing-Ke Shih 	__le32 max_t[2]; /* max_t for 0:null0/1:null1 */
2314e3ec7017SPing-Ke Shih 	__le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */
2315e3ec7017SPing-Ke Shih 	__le32 result[2][4]; /* 0:fail, 1:ok, 2:on_time, 3:retry */
2316e3ec7017SPing-Ke Shih } __packed;
2317e3ec7017SPing-Ke Shih 
23183d929f07SChing-Te Ku struct rtw89_btc_fbtc_cynullsta_v2 { /* cycle null statistics */
23191fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxnullsta */
23201bb2d4f1SChing-Te Ku 	u8 rsvd;
23211bb2d4f1SChing-Te Ku 	__le16 rsvd2;
23221bb2d4f1SChing-Te Ku 	__le32 max_t[2]; /* max_t for 0:null0/1:null1 */
23231bb2d4f1SChing-Te Ku 	__le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */
23241bb2d4f1SChing-Te Ku 	__le32 result[2][5]; /* 0:fail, 1:ok, 2:on_time, 3:retry, 4:tx */
23251bb2d4f1SChing-Te Ku } __packed;
23261bb2d4f1SChing-Te Ku 
23273d929f07SChing-Te Ku union rtw89_btc_fbtc_cynullsta_info {
23283d929f07SChing-Te Ku 	struct rtw89_btc_fbtc_cynullsta_v1 v1; /* info from fw */
23293d929f07SChing-Te Ku 	struct rtw89_btc_fbtc_cynullsta_v2 v2;
23303d929f07SChing-Te Ku };
23313d929f07SChing-Te Ku 
2332e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btver {
23331fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxbtver */
2334e3ec7017SPing-Ke Shih 	u8 rsvd;
2335e3ec7017SPing-Ke Shih 	__le16 rsvd2;
2336e3ec7017SPing-Ke Shih 	__le32 coex_ver; /*bit[15:8]->shared, bit[7:0]->non-shared */
2337e3ec7017SPing-Ke Shih 	__le32 fw_ver;
2338e3ec7017SPing-Ke Shih 	__le32 feature;
2339e3ec7017SPing-Ke Shih } __packed;
2340e3ec7017SPing-Ke Shih 
2341e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btafh {
23421fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxbtafh */
2343e3ec7017SPing-Ke Shih 	u8 rsvd;
2344e3ec7017SPing-Ke Shih 	__le16 rsvd2;
2345e3ec7017SPing-Ke Shih 	u8 afh_l[4]; /*bit0:2402, bit1: 2403.... bit31:2433 */
2346e3ec7017SPing-Ke Shih 	u8 afh_m[4]; /*bit0:2434, bit1: 2435.... bit31:2465 */
2347e3ec7017SPing-Ke Shih 	u8 afh_h[4]; /*bit0:2466, bit1:2467......bit14:2480 */
2348e3ec7017SPing-Ke Shih } __packed;
2349e3ec7017SPing-Ke Shih 
23500cdfcfceSChing-Te Ku struct rtw89_btc_fbtc_btafh_v2 {
23510cdfcfceSChing-Te Ku 	u8 fver; /* btc_ver::fcxbtafh */
23520cdfcfceSChing-Te Ku 	u8 rsvd;
23530cdfcfceSChing-Te Ku 	u8 rsvd2;
23540cdfcfceSChing-Te Ku 	u8 map_type;
23550cdfcfceSChing-Te Ku 	u8 afh_l[4];
23560cdfcfceSChing-Te Ku 	u8 afh_m[4];
23570cdfcfceSChing-Te Ku 	u8 afh_h[4];
23580cdfcfceSChing-Te Ku 	u8 afh_le_a[4];
23590cdfcfceSChing-Te Ku 	u8 afh_le_b[4];
23600cdfcfceSChing-Te Ku } __packed;
23610cdfcfceSChing-Te Ku 
2362e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btdevinfo {
23631fc4a874SPing-Ke Shih 	u8 fver; /* btc_ver::fcxbtdevinfo */
2364e3ec7017SPing-Ke Shih 	u8 rsvd;
2365e3ec7017SPing-Ke Shih 	__le16 vendor_id;
2366e3ec7017SPing-Ke Shih 	__le32 dev_name; /* only 24 bits valid */
2367e3ec7017SPing-Ke Shih 	__le32 flush_time;
2368e3ec7017SPing-Ke Shih } __packed;
2369e3ec7017SPing-Ke Shih 
2370e3ec7017SPing-Ke Shih #define RTW89_BTC_WL_DEF_TX_PWR GENMASK(7, 0)
2371e3ec7017SPing-Ke Shih struct rtw89_btc_rf_trx_para {
2372e3ec7017SPing-Ke Shih 	u32 wl_tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
2373e3ec7017SPing-Ke Shih 	u32 wl_rx_gain;  /* rx gain table index (TBD.) */
2374e3ec7017SPing-Ke Shih 	u8 bt_tx_power; /* decrease Tx power (dB) */
2375e3ec7017SPing-Ke Shih 	u8 bt_rx_gain;  /* LNA constrain level */
2376e3ec7017SPing-Ke Shih };
2377e3ec7017SPing-Ke Shih 
2378a2c0ce5dSChing-Te Ku struct rtw89_btc_trx_info {
2379a2c0ce5dSChing-Te Ku 	u8 tx_lvl;
2380a2c0ce5dSChing-Te Ku 	u8 rx_lvl;
2381a2c0ce5dSChing-Te Ku 	u8 wl_rssi;
2382a2c0ce5dSChing-Te Ku 	u8 bt_rssi;
2383a2c0ce5dSChing-Te Ku 
2384a2c0ce5dSChing-Te Ku 	s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
2385a2c0ce5dSChing-Te Ku 	s8 rx_gain;  /* rx gain table index (TBD.) */
2386a2c0ce5dSChing-Te Ku 	s8 bt_tx_power; /* decrease Tx power (dB) */
2387a2c0ce5dSChing-Te Ku 	s8 bt_rx_gain;  /* LNA constrain level */
2388a2c0ce5dSChing-Te Ku 
2389a2c0ce5dSChing-Te Ku 	u8 cn; /* condition_num */
2390a2c0ce5dSChing-Te Ku 	s8 nhm;
2391a2c0ce5dSChing-Te Ku 	u8 bt_profile;
2392a2c0ce5dSChing-Te Ku 	u8 rsvd2;
2393a2c0ce5dSChing-Te Ku 
2394a2c0ce5dSChing-Te Ku 	u16 tx_rate;
2395a2c0ce5dSChing-Te Ku 	u16 rx_rate;
2396a2c0ce5dSChing-Te Ku 
2397a2c0ce5dSChing-Te Ku 	u32 tx_tp;
2398a2c0ce5dSChing-Te Ku 	u32 rx_tp;
2399a2c0ce5dSChing-Te Ku 	u32 rx_err_ratio;
2400a2c0ce5dSChing-Te Ku };
2401a2c0ce5dSChing-Te Ku 
2402e3ec7017SPing-Ke Shih struct rtw89_btc_dm {
2403e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slot slot[CXST_MAX];
2404e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slot slot_now[CXST_MAX];
2405e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_tdma tdma;
2406e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_tdma tdma_now;
2407e3ec7017SPing-Ke Shih 	struct rtw89_mac_ax_coex_gnt gnt;
2408e3ec7017SPing-Ke Shih 	struct rtw89_btc_init_info init_info; /* pass to wl_fw if offload */
2409e3ec7017SPing-Ke Shih 	struct rtw89_btc_rf_trx_para rf_trx_para;
2410e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_tx_limit_para wl_tx_limit;
2411e3ec7017SPing-Ke Shih 	struct rtw89_btc_dm_step dm_step;
2412747dc30eSChing-Te Ku 	struct rtw89_btc_wl_scc_ctrl wl_scc;
2413a2c0ce5dSChing-Te Ku 	struct rtw89_btc_trx_info trx_info;
2414e3ec7017SPing-Ke Shih 	union rtw89_btc_dm_error_map error;
2415e3ec7017SPing-Ke Shih 	u32 cnt_dm[BTC_DCNT_NUM];
2416e3ec7017SPing-Ke Shih 	u32 cnt_notify[BTC_NCNT_NUM];
2417e3ec7017SPing-Ke Shih 
2418e3ec7017SPing-Ke Shih 	u32 update_slot_map;
2419e3ec7017SPing-Ke Shih 	u32 set_ant_path;
2420e3ec7017SPing-Ke Shih 
2421e3ec7017SPing-Ke Shih 	u32 wl_only: 1;
2422e3ec7017SPing-Ke Shih 	u32 wl_fw_cx_offload: 1;
2423e3ec7017SPing-Ke Shih 	u32 freerun: 1;
24243ab7f9b9SChing-Te Ku 	u32 fddt_train: 1;
2425e3ec7017SPing-Ke Shih 	u32 wl_ps_ctrl: 2;
2426e3ec7017SPing-Ke Shih 	u32 wl_mimo_ps: 1;
2427e3ec7017SPing-Ke Shih 	u32 leak_ap: 1;
2428e3ec7017SPing-Ke Shih 	u32 noisy_level: 3;
2429e3ec7017SPing-Ke Shih 	u32 coex_info_map: 8;
2430e3ec7017SPing-Ke Shih 	u32 bt_only: 1;
2431e3ec7017SPing-Ke Shih 	u32 wl_btg_rx: 1;
2432e3ec7017SPing-Ke Shih 	u32 trx_para_level: 8;
2433e3ec7017SPing-Ke Shih 	u32 wl_stb_chg: 1;
2434435f87d0SChing-Te Ku 	u32 pta_owner: 1;
2435ce986f3dSChing-Te Ku 	u32 tdma_instant_excute: 1;
2436e3ec7017SPing-Ke Shih 
2437e3ec7017SPing-Ke Shih 	u16 slot_dur[CXST_MAX];
2438e3ec7017SPing-Ke Shih 
2439e3ec7017SPing-Ke Shih 	u8 run_reason;
2440e3ec7017SPing-Ke Shih 	u8 run_action;
244120595db3SChing-Te Ku 
244220595db3SChing-Te Ku 	u8 wl_lna2: 1;
2443e3ec7017SPing-Ke Shih };
2444e3ec7017SPing-Ke Shih 
2445e3ec7017SPing-Ke Shih struct rtw89_btc_ctrl {
2446e3ec7017SPing-Ke Shih 	u32 manual: 1;
2447e3ec7017SPing-Ke Shih 	u32 igno_bt: 1;
2448e3ec7017SPing-Ke Shih 	u32 always_freerun: 1;
2449e3ec7017SPing-Ke Shih 	u32 trace_step: 16;
2450e3ec7017SPing-Ke Shih 	u32 rsvd: 12;
2451e3ec7017SPing-Ke Shih };
2452e3ec7017SPing-Ke Shih 
2453e3ec7017SPing-Ke Shih struct rtw89_btc_dbg {
2454e3ec7017SPing-Ke Shih 	/* cmd "rb" */
2455e3ec7017SPing-Ke Shih 	bool rb_done;
2456e3ec7017SPing-Ke Shih 	u32 rb_val;
2457e3ec7017SPing-Ke Shih };
2458e3ec7017SPing-Ke Shih 
2459e3ec7017SPing-Ke Shih enum rtw89_btc_btf_fw_event {
2460e3ec7017SPing-Ke Shih 	BTF_EVNT_RPT = 0,
2461e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_INFO = 1,
2462e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_SCBD = 2,
2463e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_REG = 3,
2464e3ec7017SPing-Ke Shih 	BTF_EVNT_CX_RUNINFO = 4,
2465e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_PSD = 5,
2466e3ec7017SPing-Ke Shih 	BTF_EVNT_BUF_OVERFLOW,
2467e3ec7017SPing-Ke Shih 	BTF_EVNT_C2H_LOOPBACK,
2468e3ec7017SPing-Ke Shih 	BTF_EVNT_MAX,
2469e3ec7017SPing-Ke Shih };
2470e3ec7017SPing-Ke Shih 
2471e3ec7017SPing-Ke Shih enum btf_fw_event_report {
2472e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_CTRL = 0x0,
2473e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_TDMA,
2474e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_SLOT,
2475e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_CYSTA,
2476e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_STEP,
2477e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_NULLSTA,
2478e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_MREG,
2479e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_GPIO_DBG,
2480e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_VER,
2481e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_SCAN,
2482e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_AFH,
2483e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_DEVICE,
2484e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_TEST,
2485e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_MAX = 31
2486e3ec7017SPing-Ke Shih };
2487e3ec7017SPing-Ke Shih 
2488e3ec7017SPing-Ke Shih enum rtw_btc_btf_reg_type {
2489e3ec7017SPing-Ke Shih 	REG_MAC = 0x0,
2490e3ec7017SPing-Ke Shih 	REG_BB = 0x1,
2491e3ec7017SPing-Ke Shih 	REG_RF = 0x2,
2492e3ec7017SPing-Ke Shih 	REG_BT_RF = 0x3,
2493e3ec7017SPing-Ke Shih 	REG_BT_MODEM = 0x4,
2494e3ec7017SPing-Ke Shih 	REG_BT_BLUEWIZE = 0x5,
2495e3ec7017SPing-Ke Shih 	REG_BT_VENDOR = 0x6,
2496e3ec7017SPing-Ke Shih 	REG_BT_LE = 0x7,
2497e3ec7017SPing-Ke Shih 	REG_MAX_TYPE,
2498e3ec7017SPing-Ke Shih };
2499e3ec7017SPing-Ke Shih 
2500e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info {
2501e3ec7017SPing-Ke Shih 	u32 rx_cnt;
2502e3ec7017SPing-Ke Shih 	u32 rx_len;
2503e3ec7017SPing-Ke Shih 	u32 req_len; /* expected rsp len */
2504e3ec7017SPing-Ke Shih 	u8 req_fver; /* expected rsp fver */
2505e3ec7017SPing-Ke Shih 	u8 rsp_fver; /* fver from fw */
2506e3ec7017SPing-Ke Shih 	u8 valid;
2507e3ec7017SPing-Ke Shih } __packed;
2508e3ec7017SPing-Ke Shih 
25090cdfcfceSChing-Te Ku union rtw89_btc_fbtc_btafh_info {
25100cdfcfceSChing-Te Ku 	struct rtw89_btc_fbtc_btafh v1;
25110cdfcfceSChing-Te Ku 	struct rtw89_btc_fbtc_btafh_v2 v2;
25120cdfcfceSChing-Te Ku };
25130cdfcfceSChing-Te Ku 
2514e3ec7017SPing-Ke Shih struct rtw89_btc_report_ctrl_state {
2515e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2516b02e3f5cSChing-Te Ku 	union rtw89_btc_fbtc_rpt_ctrl_ver_info finfo;
2517e3ec7017SPing-Ke Shih };
2518e3ec7017SPing-Ke Shih 
2519e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_tdma {
2520e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2521e0097ac5SChing-Te Ku 	union rtw89_btc_fbtc_tdma_le32 finfo;
2522e3ec7017SPing-Ke Shih };
2523e3ec7017SPing-Ke Shih 
2524e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_slots {
2525e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2526e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slots finfo; /* info from fw */
2527e3ec7017SPing-Ke Shih };
2528e3ec7017SPing-Ke Shih 
2529e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_cysta {
2530e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2531fab895b3SChing-Te Ku 	union rtw89_btc_fbtc_cysta_info finfo;
2532e3ec7017SPing-Ke Shih };
2533e3ec7017SPing-Ke Shih 
2534e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_step {
2535e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
25362626ccefSChing-Te Ku 	union rtw89_btc_fbtc_steps_info finfo; /* info from fw */
2537e3ec7017SPing-Ke Shih };
2538e3ec7017SPing-Ke Shih 
2539e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_nullsta {
2540e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
25413d929f07SChing-Te Ku 	union rtw89_btc_fbtc_cynullsta_info finfo;
2542e3ec7017SPing-Ke Shih };
2543e3ec7017SPing-Ke Shih 
2544e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_mreg {
2545e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2546e5e52febSChing-Te Ku 	union rtw89_btc_fbtc_mreg_val finfo; /* info from fw */
2547e3ec7017SPing-Ke Shih };
2548e3ec7017SPing-Ke Shih 
2549e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_gpio_dbg {
2550e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2551e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_gpio_dbg finfo; /* info from fw */
2552e3ec7017SPing-Ke Shih };
2553e3ec7017SPing-Ke Shih 
2554e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btver {
2555e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2556e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_btver finfo; /* info from fw */
2557e3ec7017SPing-Ke Shih };
2558e3ec7017SPing-Ke Shih 
2559e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btscan {
2560e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2561262cc19eSChing-Te Ku 	union rtw89_btc_fbtc_btscan finfo; /* info from fw */
2562e3ec7017SPing-Ke Shih };
2563e3ec7017SPing-Ke Shih 
2564e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btafh {
2565e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
25660cdfcfceSChing-Te Ku 	union rtw89_btc_fbtc_btafh_info finfo;
2567e3ec7017SPing-Ke Shih };
2568e3ec7017SPing-Ke Shih 
2569e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btdev {
2570e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
2571e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_btdevinfo finfo; /* info from fw */
2572e3ec7017SPing-Ke Shih };
2573e3ec7017SPing-Ke Shih 
2574e3ec7017SPing-Ke Shih enum rtw89_btc_btfre_type {
2575e3ec7017SPing-Ke Shih 	BTFRE_INVALID_INPUT = 0x0, /* invalid input parameters */
2576e3ec7017SPing-Ke Shih 	BTFRE_UNDEF_TYPE,
2577e3ec7017SPing-Ke Shih 	BTFRE_EXCEPTION,
2578e3ec7017SPing-Ke Shih 	BTFRE_MAX,
2579e3ec7017SPing-Ke Shih };
2580e3ec7017SPing-Ke Shih 
2581e3ec7017SPing-Ke Shih struct rtw89_btc_btf_fwinfo {
2582e3ec7017SPing-Ke Shih 	u32 cnt_c2h;
2583e3ec7017SPing-Ke Shih 	u32 cnt_h2c;
2584e3ec7017SPing-Ke Shih 	u32 cnt_h2c_fail;
2585e3ec7017SPing-Ke Shih 	u32 event[BTF_EVNT_MAX];
2586e3ec7017SPing-Ke Shih 
2587e3ec7017SPing-Ke Shih 	u32 err[BTFRE_MAX];
2588e3ec7017SPing-Ke Shih 	u32 len_mismch;
2589e3ec7017SPing-Ke Shih 	u32 fver_mismch;
2590e3ec7017SPing-Ke Shih 	u32 rpt_en_map;
2591e3ec7017SPing-Ke Shih 
2592e3ec7017SPing-Ke Shih 	struct rtw89_btc_report_ctrl_state rpt_ctrl;
2593e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_tdma rpt_fbtc_tdma;
2594e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_slots rpt_fbtc_slots;
2595e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_cysta rpt_fbtc_cysta;
2596e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_step rpt_fbtc_step;
2597e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_nullsta rpt_fbtc_nullsta;
2598e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_mreg rpt_fbtc_mregval;
2599e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_gpio_dbg rpt_fbtc_gpio_dbg;
2600e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btver rpt_fbtc_btver;
2601e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btscan rpt_fbtc_btscan;
2602e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btafh rpt_fbtc_btafh;
2603e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btdev rpt_fbtc_btdev;
2604e3ec7017SPing-Ke Shih };
2605e3ec7017SPing-Ke Shih 
26066140635aSPing-Ke Shih struct rtw89_btc_ver {
26076140635aSPing-Ke Shih 	enum rtw89_core_chip_id chip_id;
26086140635aSPing-Ke Shih 	u32 fw_ver_code;
26096140635aSPing-Ke Shih 
26106140635aSPing-Ke Shih 	u8 fcxbtcrpt;
26116140635aSPing-Ke Shih 	u8 fcxtdma;
26126140635aSPing-Ke Shih 	u8 fcxslots;
26136140635aSPing-Ke Shih 	u8 fcxcysta;
26146140635aSPing-Ke Shih 	u8 fcxstep;
26156140635aSPing-Ke Shih 	u8 fcxnullsta;
26166140635aSPing-Ke Shih 	u8 fcxmreg;
26176140635aSPing-Ke Shih 	u8 fcxgpiodbg;
26186140635aSPing-Ke Shih 	u8 fcxbtver;
26196140635aSPing-Ke Shih 	u8 fcxbtscan;
26206140635aSPing-Ke Shih 	u8 fcxbtafh;
26216140635aSPing-Ke Shih 	u8 fcxbtdevinfo;
26226140635aSPing-Ke Shih 	u8 fwlrole;
26236140635aSPing-Ke Shih 	u8 frptmap;
26246140635aSPing-Ke Shih 	u8 fcxctrl;
26256140635aSPing-Ke Shih 
26266140635aSPing-Ke Shih 	u16 info_buf;
26276140635aSPing-Ke Shih 	u8 max_role_num;
26286140635aSPing-Ke Shih };
26296140635aSPing-Ke Shih 
2630e3ec7017SPing-Ke Shih #define RTW89_BTC_POLICY_MAXLEN 512
2631e3ec7017SPing-Ke Shih 
2632e3ec7017SPing-Ke Shih struct rtw89_btc {
26336140635aSPing-Ke Shih 	const struct rtw89_btc_ver *ver;
26346140635aSPing-Ke Shih 
2635e3ec7017SPing-Ke Shih 	struct rtw89_btc_cx cx;
2636e3ec7017SPing-Ke Shih 	struct rtw89_btc_dm dm;
2637e3ec7017SPing-Ke Shih 	struct rtw89_btc_ctrl ctrl;
2638e3ec7017SPing-Ke Shih 	struct rtw89_btc_module mdinfo;
2639e3ec7017SPing-Ke Shih 	struct rtw89_btc_btf_fwinfo fwinfo;
2640e3ec7017SPing-Ke Shih 	struct rtw89_btc_dbg dbg;
2641e3ec7017SPing-Ke Shih 
2642e3ec7017SPing-Ke Shih 	struct work_struct eapol_notify_work;
2643e3ec7017SPing-Ke Shih 	struct work_struct arp_notify_work;
2644e3ec7017SPing-Ke Shih 	struct work_struct dhcp_notify_work;
2645e3ec7017SPing-Ke Shih 	struct work_struct icmp_notify_work;
2646e3ec7017SPing-Ke Shih 
2647e3ec7017SPing-Ke Shih 	u32 bt_req_len;
2648e3ec7017SPing-Ke Shih 
2649e3ec7017SPing-Ke Shih 	u8 policy[RTW89_BTC_POLICY_MAXLEN];
2650e3ec7017SPing-Ke Shih 	u16 policy_len;
2651e3ec7017SPing-Ke Shih 	u16 policy_type;
2652e3ec7017SPing-Ke Shih 	bool bt_req_en;
2653e3ec7017SPing-Ke Shih 	bool update_policy_force;
2654e3ec7017SPing-Ke Shih 	bool lps;
2655e3ec7017SPing-Ke Shih };
2656e3ec7017SPing-Ke Shih 
265764a24cb6SZong-Zhe Yang enum rtw89_btc_hmsg {
265864a24cb6SZong-Zhe Yang 	RTW89_BTC_HMSG_TMR_EN = 0x0,
265964a24cb6SZong-Zhe Yang 	RTW89_BTC_HMSG_BT_REG_READBACK = 0x1,
266064a24cb6SZong-Zhe Yang 	RTW89_BTC_HMSG_SET_BT_REQ_SLOT = 0x2,
266164a24cb6SZong-Zhe Yang 	RTW89_BTC_HMSG_FW_EV = 0x3,
266264a24cb6SZong-Zhe Yang 	RTW89_BTC_HMSG_BT_LINK_CHG = 0x4,
266364a24cb6SZong-Zhe Yang 	RTW89_BTC_HMSG_SET_BT_REQ_STBC = 0x5,
266464a24cb6SZong-Zhe Yang 
266564a24cb6SZong-Zhe Yang 	NUM_OF_RTW89_BTC_HMSG,
266664a24cb6SZong-Zhe Yang };
266764a24cb6SZong-Zhe Yang 
2668e3ec7017SPing-Ke Shih enum rtw89_ra_mode {
2669e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_CCK = BIT(0),
2670e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_OFDM = BIT(1),
2671e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_HT = BIT(2),
2672e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_VHT = BIT(3),
2673e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_HE = BIT(4),
2674e3ec7017SPing-Ke Shih };
2675e3ec7017SPing-Ke Shih 
2676e3ec7017SPing-Ke Shih enum rtw89_ra_report_mode {
2677e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_LEGACY,
2678e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_HT,
2679e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_VHT,
2680e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_HE,
2681e3ec7017SPing-Ke Shih };
2682e3ec7017SPing-Ke Shih 
2683e3ec7017SPing-Ke Shih enum rtw89_dig_noisy_level {
2684e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL0 = -1,
2685e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL1 = 0,
2686e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL2 = 1,
2687e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL3 = 2,
2688e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL_MAX = 3,
2689e3ec7017SPing-Ke Shih };
2690e3ec7017SPing-Ke Shih 
2691e3ec7017SPing-Ke Shih enum rtw89_gi_ltf {
2692e3ec7017SPing-Ke Shih 	RTW89_GILTF_LGI_4XHE32 = 0,
2693e3ec7017SPing-Ke Shih 	RTW89_GILTF_SGI_4XHE08 = 1,
2694e3ec7017SPing-Ke Shih 	RTW89_GILTF_2XHE16 = 2,
2695e3ec7017SPing-Ke Shih 	RTW89_GILTF_2XHE08 = 3,
2696e3ec7017SPing-Ke Shih 	RTW89_GILTF_1XHE16 = 4,
2697e3ec7017SPing-Ke Shih 	RTW89_GILTF_1XHE08 = 5,
2698e3ec7017SPing-Ke Shih 	RTW89_GILTF_MAX
2699e3ec7017SPing-Ke Shih };
2700e3ec7017SPing-Ke Shih 
2701e3ec7017SPing-Ke Shih enum rtw89_rx_frame_type {
2702e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_MGNT = 0,
2703e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_CTRL = 1,
2704e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_DATA = 2,
2705e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_RSVD = 3,
2706e3ec7017SPing-Ke Shih };
2707e3ec7017SPing-Ke Shih 
2708e3ec7017SPing-Ke Shih struct rtw89_ra_info {
2709e3ec7017SPing-Ke Shih 	u8 is_dis_ra:1;
2710e3ec7017SPing-Ke Shih 	/* Bit0 : CCK
2711e3ec7017SPing-Ke Shih 	 * Bit1 : OFDM
2712e3ec7017SPing-Ke Shih 	 * Bit2 : HT
2713e3ec7017SPing-Ke Shih 	 * Bit3 : VHT
2714e3ec7017SPing-Ke Shih 	 * Bit4 : HE
2715c97683ffSPing-Ke Shih 	 * Bit5 : EHT
2716e3ec7017SPing-Ke Shih 	 */
2717c97683ffSPing-Ke Shih 	u8 mode_ctrl:6;
2718c97683ffSPing-Ke Shih 	u8 bw_cap:3; /* enum rtw89_bandwidth */
2719e3ec7017SPing-Ke Shih 	u8 macid;
2720e3ec7017SPing-Ke Shih 	u8 dcm_cap:1;
2721e3ec7017SPing-Ke Shih 	u8 er_cap:1;
2722e3ec7017SPing-Ke Shih 	u8 init_rate_lv:2;
2723e3ec7017SPing-Ke Shih 	u8 upd_all:1;
2724e3ec7017SPing-Ke Shih 	u8 en_sgi:1;
2725e3ec7017SPing-Ke Shih 	u8 ldpc_cap:1;
2726e3ec7017SPing-Ke Shih 	u8 stbc_cap:1;
2727e3ec7017SPing-Ke Shih 	u8 ss_num:3;
2728e3ec7017SPing-Ke Shih 	u8 giltf:3;
2729e3ec7017SPing-Ke Shih 	u8 upd_bw_nss_mask:1;
2730e3ec7017SPing-Ke Shih 	u8 upd_mask:1;
2731e3ec7017SPing-Ke Shih 	u64 ra_mask; /* 63 bits ra_mask + 1 bit CSI ctrl */
2732e3ec7017SPing-Ke Shih 	/* BFee CSI */
2733e3ec7017SPing-Ke Shih 	u8 band_num;
2734e3ec7017SPing-Ke Shih 	u8 ra_csi_rate_en:1;
2735e3ec7017SPing-Ke Shih 	u8 fixed_csi_rate_en:1;
2736e3ec7017SPing-Ke Shih 	u8 cr_tbl_sel:1;
27370891b366SKuan-Chung Chen 	u8 fix_giltf_en:1;
27380891b366SKuan-Chung Chen 	u8 fix_giltf:3;
27390891b366SKuan-Chung Chen 	u8 rsvd2:1;
2740e3ec7017SPing-Ke Shih 	u8 csi_mcs_ss_idx;
2741e3ec7017SPing-Ke Shih 	u8 csi_mode:2;
2742e3ec7017SPing-Ke Shih 	u8 csi_gi_ltf:3;
2743e3ec7017SPing-Ke Shih 	u8 csi_bw:3;
2744e3ec7017SPing-Ke Shih };
2745e3ec7017SPing-Ke Shih 
2746e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAX_USR 4
2747e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_INFO_USR_SIZE 4
2748e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_INFO_SIZE 8
2749e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_RX_CNT_SIZE 96
2750e3ec7017SPing-Ke Shih 
2751e3ec7017SPing-Ke Shih #define RTW89_MAX_RX_AGG_NUM 64
2752e3ec7017SPing-Ke Shih #define RTW89_MAX_TX_AGG_NUM 128
2753e3ec7017SPing-Ke Shih 
2754e3ec7017SPing-Ke Shih struct rtw89_ampdu_params {
2755e3ec7017SPing-Ke Shih 	u16 agg_num;
2756e3ec7017SPing-Ke Shih 	bool amsdu;
2757e3ec7017SPing-Ke Shih };
2758e3ec7017SPing-Ke Shih 
2759e3ec7017SPing-Ke Shih struct rtw89_ra_report {
2760e3ec7017SPing-Ke Shih 	struct rate_info txrate;
2761e3ec7017SPing-Ke Shih 	u32 bit_rate;
2762e3ec7017SPing-Ke Shih 	u16 hw_rate;
27630d466f05SPing-Ke Shih 	bool might_fallback_legacy;
2764e3ec7017SPing-Ke Shih };
2765e3ec7017SPing-Ke Shih 
2766e3ec7017SPing-Ke Shih DECLARE_EWMA(rssi, 10, 16);
27674bb223a1SPing-Ke Shih DECLARE_EWMA(evm, 10, 16);
27684bb223a1SPing-Ke Shih DECLARE_EWMA(snr, 10, 16);
2769e3ec7017SPing-Ke Shih 
27703ffbb5a8SPing-Ke Shih struct rtw89_ba_cam_entry {
277108aa8077SPing-Ke Shih 	struct list_head list;
27723ffbb5a8SPing-Ke Shih 	u8 tid;
27733ffbb5a8SPing-Ke Shih };
27743ffbb5a8SPing-Ke Shih 
2775e3ec7017SPing-Ke Shih #define RTW89_MAX_ADDR_CAM_NUM		128
2776e3ec7017SPing-Ke Shih #define RTW89_MAX_BSSID_CAM_NUM		20
2777e3ec7017SPing-Ke Shih #define RTW89_MAX_SEC_CAM_NUM		128
27782def7356SPing-Ke Shih #define RTW89_MAX_BA_CAM_NUM		8
2779e3ec7017SPing-Ke Shih #define RTW89_SEC_CAM_IN_ADDR_CAM	7
2780e3ec7017SPing-Ke Shih 
2781e3ec7017SPing-Ke Shih struct rtw89_addr_cam_entry {
2782e3ec7017SPing-Ke Shih 	u8 addr_cam_idx;
2783e3ec7017SPing-Ke Shih 	u8 offset;
2784e3ec7017SPing-Ke Shih 	u8 len;
2785e3ec7017SPing-Ke Shih 	u8 valid	: 1;
2786e3ec7017SPing-Ke Shih 	u8 addr_mask	: 6;
2787e3ec7017SPing-Ke Shih 	u8 wapi		: 1;
2788e3ec7017SPing-Ke Shih 	u8 mask_sel	: 2;
2789e3ec7017SPing-Ke Shih 	u8 bssid_cam_idx: 6;
2790e3ec7017SPing-Ke Shih 
2791e3ec7017SPing-Ke Shih 	u8 sec_ent_mode;
2792e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(sec_cam_map, RTW89_SEC_CAM_IN_ADDR_CAM);
2793e3ec7017SPing-Ke Shih 	u8 sec_ent_keyid[RTW89_SEC_CAM_IN_ADDR_CAM];
2794e3ec7017SPing-Ke Shih 	u8 sec_ent[RTW89_SEC_CAM_IN_ADDR_CAM];
2795e3ec7017SPing-Ke Shih 	struct rtw89_sec_cam_entry *sec_entries[RTW89_SEC_CAM_IN_ADDR_CAM];
2796e3ec7017SPing-Ke Shih };
2797e3ec7017SPing-Ke Shih 
2798e3ec7017SPing-Ke Shih struct rtw89_bssid_cam_entry {
2799e3ec7017SPing-Ke Shih 	u8 bssid[ETH_ALEN];
2800e3ec7017SPing-Ke Shih 	u8 phy_idx;
2801e3ec7017SPing-Ke Shih 	u8 bssid_cam_idx;
2802e3ec7017SPing-Ke Shih 	u8 offset;
2803e3ec7017SPing-Ke Shih 	u8 len;
2804e3ec7017SPing-Ke Shih 	u8 valid : 1;
2805e3ec7017SPing-Ke Shih 	u8 num;
2806e3ec7017SPing-Ke Shih };
2807e3ec7017SPing-Ke Shih 
2808e3ec7017SPing-Ke Shih struct rtw89_sec_cam_entry {
2809e3ec7017SPing-Ke Shih 	u8 sec_cam_idx;
2810e3ec7017SPing-Ke Shih 	u8 offset;
2811e3ec7017SPing-Ke Shih 	u8 len;
2812e3ec7017SPing-Ke Shih 	u8 type : 4;
2813e3ec7017SPing-Ke Shih 	u8 ext_key : 1;
2814e3ec7017SPing-Ke Shih 	u8 spp_mode : 1;
2815e3ec7017SPing-Ke Shih 	/* 256 bits */
2816e3ec7017SPing-Ke Shih 	u8 key[32];
2817e3ec7017SPing-Ke Shih };
2818e3ec7017SPing-Ke Shih 
28192ab856ccSPing-Ke Shih struct rtw89_sta {
28202ab856ccSPing-Ke Shih 	u8 mac_id;
28212ab856ccSPing-Ke Shih 	bool disassoc;
282225ed1a17SPing-Ke Shih 	bool er_cap;
28236ce472d6SPing-Ke Shih 	struct rtw89_dev *rtwdev;
28242ab856ccSPing-Ke Shih 	struct rtw89_vif *rtwvif;
28252ab856ccSPing-Ke Shih 	struct rtw89_ra_info ra;
28262ab856ccSPing-Ke Shih 	struct rtw89_ra_report ra_report;
28272ab856ccSPing-Ke Shih 	int max_agg_wait;
28282ab856ccSPing-Ke Shih 	u8 prev_rssi;
28292ab856ccSPing-Ke Shih 	struct ewma_rssi avg_rssi;
28306ce472d6SPing-Ke Shih 	struct ewma_rssi rssi[RF_PATH_MAX];
28314bb223a1SPing-Ke Shih 	struct ewma_snr avg_snr;
28324bb223a1SPing-Ke Shih 	struct ewma_evm evm_min[RF_PATH_MAX];
28334bb223a1SPing-Ke Shih 	struct ewma_evm evm_max[RF_PATH_MAX];
28342ab856ccSPing-Ke Shih 	struct rtw89_ampdu_params ampdu_params[IEEE80211_NUM_TIDS];
28352ab856ccSPing-Ke Shih 	struct ieee80211_rx_status rx_status;
28362ab856ccSPing-Ke Shih 	u16 rx_hw_rate;
28372ab856ccSPing-Ke Shih 	__le32 htc_template;
28387312100dSPing-Ke Shih 	struct rtw89_addr_cam_entry addr_cam; /* AP mode or TDLS peer only */
283939913cc8SPing-Ke Shih 	struct rtw89_bssid_cam_entry bssid_cam; /* TDLS peer only */
284008aa8077SPing-Ke Shih 	struct list_head ba_cam_list;
2841a0e97ae3SPo-Hao Huang 	struct sk_buff_head roc_queue;
28422ab856ccSPing-Ke Shih 
28432ab856ccSPing-Ke Shih 	bool use_cfg_mask;
28442ab856ccSPing-Ke Shih 	struct cfg80211_bitrate_mask mask;
28452ab856ccSPing-Ke Shih 
28462ab856ccSPing-Ke Shih 	bool cctl_tx_time;
28472ab856ccSPing-Ke Shih 	u32 ampdu_max_time:4;
28482ab856ccSPing-Ke Shih 	bool cctl_tx_retry_limit;
28492ab856ccSPing-Ke Shih 	u32 data_tx_cnt_lmt:6;
28502ab856ccSPing-Ke Shih };
28512ab856ccSPing-Ke Shih 
2852e3ec7017SPing-Ke Shih struct rtw89_efuse {
2853e3ec7017SPing-Ke Shih 	bool valid;
2854134cf7c0SPing-Ke Shih 	bool power_k_valid;
2855e3ec7017SPing-Ke Shih 	u8 xtal_cap;
2856e3ec7017SPing-Ke Shih 	u8 addr[ETH_ALEN];
2857e3ec7017SPing-Ke Shih 	u8 rfe_type;
2858e3ec7017SPing-Ke Shih 	char country_code[2];
2859e3ec7017SPing-Ke Shih };
2860e3ec7017SPing-Ke Shih 
2861e3ec7017SPing-Ke Shih struct rtw89_phy_rate_pattern {
2862e3ec7017SPing-Ke Shih 	u64 ra_mask;
2863e3ec7017SPing-Ke Shih 	u16 rate;
2864e3ec7017SPing-Ke Shih 	u8 ra_mode;
2865e3ec7017SPing-Ke Shih 	bool enable;
2866e3ec7017SPing-Ke Shih };
2867e3ec7017SPing-Ke Shih 
28681ae5ca61SPo-Hao Huang struct rtw89_tx_wait_info {
28691ae5ca61SPo-Hao Huang 	struct rcu_head rcu_head;
28701ae5ca61SPo-Hao Huang 	struct completion completion;
28711ae5ca61SPo-Hao Huang 	bool tx_done;
28721ae5ca61SPo-Hao Huang };
28731ae5ca61SPo-Hao Huang 
28741ae5ca61SPo-Hao Huang struct rtw89_tx_skb_data {
28751ae5ca61SPo-Hao Huang 	struct rtw89_tx_wait_info __rcu *wait;
28761ae5ca61SPo-Hao Huang 	u8 hci_priv[];
28771ae5ca61SPo-Hao Huang };
28781ae5ca61SPo-Hao Huang 
2879a0e97ae3SPo-Hao Huang #define RTW89_ROC_IDLE_TIMEOUT 500
2880a0e97ae3SPo-Hao Huang #define RTW89_ROC_TX_TIMEOUT 30
2881a0e97ae3SPo-Hao Huang enum rtw89_roc_state {
2882a0e97ae3SPo-Hao Huang 	RTW89_ROC_IDLE,
2883a0e97ae3SPo-Hao Huang 	RTW89_ROC_NORMAL,
2884a0e97ae3SPo-Hao Huang 	RTW89_ROC_MGMT,
2885a0e97ae3SPo-Hao Huang };
2886a0e97ae3SPo-Hao Huang 
2887a0e97ae3SPo-Hao Huang struct rtw89_roc {
2888a0e97ae3SPo-Hao Huang 	struct ieee80211_channel chan;
2889a0e97ae3SPo-Hao Huang 	struct delayed_work roc_work;
2890a0e97ae3SPo-Hao Huang 	enum ieee80211_roc_type type;
2891a0e97ae3SPo-Hao Huang 	enum rtw89_roc_state state;
2892a0e97ae3SPo-Hao Huang 	int duration;
2893a0e97ae3SPo-Hao Huang };
2894a0e97ae3SPo-Hao Huang 
2895f4a43c3bSDian-Syuan Yang #define RTW89_P2P_MAX_NOA_NUM 2
2896f4a43c3bSDian-Syuan Yang 
289751383fd7SZong-Zhe Yang struct rtw89_p2p_ie_head {
289851383fd7SZong-Zhe Yang 	u8 eid;
289951383fd7SZong-Zhe Yang 	u8 ie_len;
290051383fd7SZong-Zhe Yang 	u8 oui[3];
290151383fd7SZong-Zhe Yang 	u8 oui_type;
290251383fd7SZong-Zhe Yang } __packed;
290351383fd7SZong-Zhe Yang 
290451383fd7SZong-Zhe Yang struct rtw89_noa_attr_head {
290551383fd7SZong-Zhe Yang 	u8 attr_type;
290651383fd7SZong-Zhe Yang 	__le16 attr_len;
290751383fd7SZong-Zhe Yang 	u8 index;
290851383fd7SZong-Zhe Yang 	u8 oppps_ctwindow;
290951383fd7SZong-Zhe Yang } __packed;
291051383fd7SZong-Zhe Yang 
291151383fd7SZong-Zhe Yang struct rtw89_p2p_noa_ie {
291251383fd7SZong-Zhe Yang 	struct rtw89_p2p_ie_head p2p_head;
291351383fd7SZong-Zhe Yang 	struct rtw89_noa_attr_head noa_head;
291451383fd7SZong-Zhe Yang 	struct ieee80211_p2p_noa_desc noa_desc[RTW89_P2P_MAX_NOA_NUM];
291551383fd7SZong-Zhe Yang } __packed;
291651383fd7SZong-Zhe Yang 
291751383fd7SZong-Zhe Yang struct rtw89_p2p_noa_setter {
291851383fd7SZong-Zhe Yang 	struct rtw89_p2p_noa_ie ie;
291951383fd7SZong-Zhe Yang 	u8 noa_count;
292051383fd7SZong-Zhe Yang 	u8 noa_index;
292151383fd7SZong-Zhe Yang };
292251383fd7SZong-Zhe Yang 
2923e3ec7017SPing-Ke Shih struct rtw89_vif {
2924e3ec7017SPing-Ke Shih 	struct list_head list;
2925d62816b4SPing-Ke Shih 	struct rtw89_dev *rtwdev;
2926a0e97ae3SPo-Hao Huang 	struct rtw89_roc roc;
292775ee07b0SZong-Zhe Yang 	enum rtw89_sub_entity_idx sub_entity_idx;
2928f6baa1d3SZong-Zhe Yang 	enum rtw89_reg_6ghz_power reg_6ghz_power;
292975ee07b0SZong-Zhe Yang 
2930e3ec7017SPing-Ke Shih 	u8 mac_id;
2931e3ec7017SPing-Ke Shih 	u8 port;
2932e3ec7017SPing-Ke Shih 	u8 mac_addr[ETH_ALEN];
2933e3ec7017SPing-Ke Shih 	u8 bssid[ETH_ALEN];
2934e3ec7017SPing-Ke Shih 	u8 phy_idx;
2935e3ec7017SPing-Ke Shih 	u8 mac_idx;
2936e3ec7017SPing-Ke Shih 	u8 net_type;
2937e3ec7017SPing-Ke Shih 	u8 wifi_role;
2938e3ec7017SPing-Ke Shih 	u8 self_role;
2939e3ec7017SPing-Ke Shih 	u8 wmm;
2940e3ec7017SPing-Ke Shih 	u8 bcn_hit_cond;
2941e3ec7017SPing-Ke Shih 	u8 hit_rule;
2942f4a43c3bSDian-Syuan Yang 	u8 last_noa_nr;
2943a0e97ae3SPo-Hao Huang 	bool offchan;
2944e3ec7017SPing-Ke Shih 	bool trigger;
2945e3ec7017SPing-Ke Shih 	bool lsig_txop;
2946e3ec7017SPing-Ke Shih 	u8 tgt_ind;
2947e3ec7017SPing-Ke Shih 	u8 frm_tgt_ind;
2948e3ec7017SPing-Ke Shih 	bool wowlan_pattern;
2949e3ec7017SPing-Ke Shih 	bool wowlan_uc;
2950e3ec7017SPing-Ke Shih 	bool wowlan_magic;
2951e3ec7017SPing-Ke Shih 	bool is_hesta;
2952e3ec7017SPing-Ke Shih 	bool last_a_ctrl;
295329136c95SEric Huang 	bool dyn_tb_bedge_en;
295429136c95SEric Huang 	u8 def_tri_idx;
2955d881d0a1SKuan-Chung Chen 	u32 tdls_peer;
2956d62816b4SPing-Ke Shih 	struct work_struct update_beacon_work;
2957e3ec7017SPing-Ke Shih 	struct rtw89_addr_cam_entry addr_cam;
2958e3ec7017SPing-Ke Shih 	struct rtw89_bssid_cam_entry bssid_cam;
2959e3ec7017SPing-Ke Shih 	struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS];
2960e3ec7017SPing-Ke Shih 	struct rtw89_traffic_stats stats;
2961e3ec7017SPing-Ke Shih 	struct rtw89_phy_rate_pattern rate_pattern;
296289590777SPo Hao Huang 	struct cfg80211_scan_request *scan_req;
296389590777SPo Hao Huang 	struct ieee80211_scan_ies *scan_ies;
29645c12bb66SChin-Yen Lee 	struct list_head general_pkt_list;
296551383fd7SZong-Zhe Yang 	struct rtw89_p2p_noa_setter p2p_noa;
2966e3ec7017SPing-Ke Shih };
2967e3ec7017SPing-Ke Shih 
2968e3ec7017SPing-Ke Shih enum rtw89_lv1_rcvy_step {
2969e3ec7017SPing-Ke Shih 	RTW89_LV1_RCVY_STEP_1,
2970e3ec7017SPing-Ke Shih 	RTW89_LV1_RCVY_STEP_2,
2971e3ec7017SPing-Ke Shih };
2972e3ec7017SPing-Ke Shih 
2973e3ec7017SPing-Ke Shih struct rtw89_hci_ops {
2974e3ec7017SPing-Ke Shih 	int (*tx_write)(struct rtw89_dev *rtwdev, struct rtw89_core_tx_request *tx_req);
2975e3ec7017SPing-Ke Shih 	void (*tx_kick_off)(struct rtw89_dev *rtwdev, u8 txch);
2976e3ec7017SPing-Ke Shih 	void (*flush_queues)(struct rtw89_dev *rtwdev, u32 queues, bool drop);
2977e3ec7017SPing-Ke Shih 	void (*reset)(struct rtw89_dev *rtwdev);
2978e3ec7017SPing-Ke Shih 	int (*start)(struct rtw89_dev *rtwdev);
2979e3ec7017SPing-Ke Shih 	void (*stop)(struct rtw89_dev *rtwdev);
298052edbb9fSPing-Ke Shih 	void (*pause)(struct rtw89_dev *rtwdev, bool pause);
298152edbb9fSPing-Ke Shih 	void (*switch_mode)(struct rtw89_dev *rtwdev, bool low_power);
2982e3ec7017SPing-Ke Shih 	void (*recalc_int_mit)(struct rtw89_dev *rtwdev);
2983e3ec7017SPing-Ke Shih 
2984e3ec7017SPing-Ke Shih 	u8 (*read8)(struct rtw89_dev *rtwdev, u32 addr);
2985e3ec7017SPing-Ke Shih 	u16 (*read16)(struct rtw89_dev *rtwdev, u32 addr);
2986e3ec7017SPing-Ke Shih 	u32 (*read32)(struct rtw89_dev *rtwdev, u32 addr);
2987e3ec7017SPing-Ke Shih 	void (*write8)(struct rtw89_dev *rtwdev, u32 addr, u8 data);
2988e3ec7017SPing-Ke Shih 	void (*write16)(struct rtw89_dev *rtwdev, u32 addr, u16 data);
2989e3ec7017SPing-Ke Shih 	void (*write32)(struct rtw89_dev *rtwdev, u32 addr, u32 data);
2990e3ec7017SPing-Ke Shih 
2991e3ec7017SPing-Ke Shih 	int (*mac_pre_init)(struct rtw89_dev *rtwdev);
2992e3ec7017SPing-Ke Shih 	int (*mac_post_init)(struct rtw89_dev *rtwdev);
2993e3ec7017SPing-Ke Shih 	int (*deinit)(struct rtw89_dev *rtwdev);
2994e3ec7017SPing-Ke Shih 
2995e3ec7017SPing-Ke Shih 	u32 (*check_and_reclaim_tx_resource)(struct rtw89_dev *rtwdev, u8 txch);
2996e3ec7017SPing-Ke Shih 	int (*mac_lv1_rcvy)(struct rtw89_dev *rtwdev, enum rtw89_lv1_rcvy_step step);
2997e3ec7017SPing-Ke Shih 	void (*dump_err_status)(struct rtw89_dev *rtwdev);
2998e3ec7017SPing-Ke Shih 	int (*napi_poll)(struct napi_struct *napi, int budget);
299914f9f479SZong-Zhe Yang 
300014f9f479SZong-Zhe Yang 	/* Deal with locks inside recovery_start and recovery_complete callbacks
300114f9f479SZong-Zhe Yang 	 * by hci instance, and handle things which need to consider under SER.
300214f9f479SZong-Zhe Yang 	 * e.g. turn on/off interrupts except for the one for halt notification.
300314f9f479SZong-Zhe Yang 	 */
300414f9f479SZong-Zhe Yang 	void (*recovery_start)(struct rtw89_dev *rtwdev);
300514f9f479SZong-Zhe Yang 	void (*recovery_complete)(struct rtw89_dev *rtwdev);
300619e28c7fSChin-Yen Lee 
300719e28c7fSChin-Yen Lee 	void (*ctrl_txdma_ch)(struct rtw89_dev *rtwdev, bool enable);
300819e28c7fSChin-Yen Lee 	void (*ctrl_txdma_fw_ch)(struct rtw89_dev *rtwdev, bool enable);
300919e28c7fSChin-Yen Lee 	void (*ctrl_trxhci)(struct rtw89_dev *rtwdev, bool enable);
301019e28c7fSChin-Yen Lee 	int (*poll_txdma_ch)(struct rtw89_dev *rtwdev);
301119e28c7fSChin-Yen Lee 	void (*clr_idx_all)(struct rtw89_dev *rtwdev);
301219e28c7fSChin-Yen Lee 	void (*clear)(struct rtw89_dev *rtwdev, struct pci_dev *pdev);
301319e28c7fSChin-Yen Lee 	void (*disable_intr)(struct rtw89_dev *rtwdev);
301419e28c7fSChin-Yen Lee 	void (*enable_intr)(struct rtw89_dev *rtwdev);
301519e28c7fSChin-Yen Lee 	int (*rst_bdram)(struct rtw89_dev *rtwdev);
3016e3ec7017SPing-Ke Shih };
3017e3ec7017SPing-Ke Shih 
3018e3ec7017SPing-Ke Shih struct rtw89_hci_info {
3019e3ec7017SPing-Ke Shih 	const struct rtw89_hci_ops *ops;
3020e3ec7017SPing-Ke Shih 	enum rtw89_hci_type type;
3021e3ec7017SPing-Ke Shih 	u32 rpwm_addr;
3022e3ec7017SPing-Ke Shih 	u32 cpwm_addr;
302352edbb9fSPing-Ke Shih 	bool paused;
3024e3ec7017SPing-Ke Shih };
3025e3ec7017SPing-Ke Shih 
3026e3ec7017SPing-Ke Shih struct rtw89_chip_ops {
302761ebeecbSPing-Ke Shih 	int (*enable_bb_rf)(struct rtw89_dev *rtwdev);
302814b6e9f4SPing-Ke Shih 	int (*disable_bb_rf)(struct rtw89_dev *rtwdev);
3029e3ec7017SPing-Ke Shih 	void (*bb_reset)(struct rtw89_dev *rtwdev,
3030e3ec7017SPing-Ke Shih 			 enum rtw89_phy_idx phy_idx);
3031e3ec7017SPing-Ke Shih 	void (*bb_sethw)(struct rtw89_dev *rtwdev);
3032e3ec7017SPing-Ke Shih 	u32 (*read_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
3033e3ec7017SPing-Ke Shih 		       u32 addr, u32 mask);
3034e3ec7017SPing-Ke Shih 	bool (*write_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
3035e3ec7017SPing-Ke Shih 			 u32 addr, u32 mask, u32 data);
3036e3ec7017SPing-Ke Shih 	void (*set_channel)(struct rtw89_dev *rtwdev,
3037ce57e55cSZong-Zhe Yang 			    const struct rtw89_chan *chan,
3038ce57e55cSZong-Zhe Yang 			    enum rtw89_mac_idx mac_idx,
3039ce57e55cSZong-Zhe Yang 			    enum rtw89_phy_idx phy_idx);
3040e3ec7017SPing-Ke Shih 	void (*set_channel_help)(struct rtw89_dev *rtwdev, bool enter,
3041ce57e55cSZong-Zhe Yang 				 struct rtw89_channel_help_params *p,
3042ce57e55cSZong-Zhe Yang 				 const struct rtw89_chan *chan,
3043ce57e55cSZong-Zhe Yang 				 enum rtw89_mac_idx mac_idx,
3044ce57e55cSZong-Zhe Yang 				 enum rtw89_phy_idx phy_idx);
3045e3ec7017SPing-Ke Shih 	int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map);
3046e3ec7017SPing-Ke Shih 	int (*read_phycap)(struct rtw89_dev *rtwdev, u8 *phycap_map);
3047e3ec7017SPing-Ke Shih 	void (*fem_setup)(struct rtw89_dev *rtwdev);
3048f03bd042SPing-Ke Shih 	void (*rfe_gpio)(struct rtw89_dev *rtwdev);
3049e3ec7017SPing-Ke Shih 	void (*rfk_init)(struct rtw89_dev *rtwdev);
3050e3ec7017SPing-Ke Shih 	void (*rfk_channel)(struct rtw89_dev *rtwdev);
3051010d0051SZong-Zhe Yang 	void (*rfk_band_changed)(struct rtw89_dev *rtwdev,
3052010d0051SZong-Zhe Yang 				 enum rtw89_phy_idx phy_idx);
3053e3ec7017SPing-Ke Shih 	void (*rfk_scan)(struct rtw89_dev *rtwdev, bool start);
3054e3ec7017SPing-Ke Shih 	void (*rfk_track)(struct rtw89_dev *rtwdev);
3055e3ec7017SPing-Ke Shih 	void (*power_trim)(struct rtw89_dev *rtwdev);
305607ef5f2fSZong-Zhe Yang 	void (*set_txpwr)(struct rtw89_dev *rtwdev,
305707ef5f2fSZong-Zhe Yang 			  const struct rtw89_chan *chan,
305807ef5f2fSZong-Zhe Yang 			  enum rtw89_phy_idx phy_idx);
305907ef5f2fSZong-Zhe Yang 	void (*set_txpwr_ctrl)(struct rtw89_dev *rtwdev,
306007ef5f2fSZong-Zhe Yang 			       enum rtw89_phy_idx phy_idx);
3061e3ec7017SPing-Ke Shih 	int (*init_txpwr_unit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
3062e3ec7017SPing-Ke Shih 	u8 (*get_thermal)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path);
3063e3ec7017SPing-Ke Shih 	void (*ctrl_btg)(struct rtw89_dev *rtwdev, bool btg);
3064e3ec7017SPing-Ke Shih 	void (*query_ppdu)(struct rtw89_dev *rtwdev,
3065e3ec7017SPing-Ke Shih 			   struct rtw89_rx_phy_ppdu *phy_ppdu,
3066e3ec7017SPing-Ke Shih 			   struct ieee80211_rx_status *status);
3067e3ec7017SPing-Ke Shih 	void (*bb_ctrl_btc_preagc)(struct rtw89_dev *rtwdev, bool bt_en);
3068cd89a471SPing-Ke Shih 	void (*cfg_txrx_path)(struct rtw89_dev *rtwdev);
3069e3ec7017SPing-Ke Shih 	void (*set_txpwr_ul_tb_offset)(struct rtw89_dev *rtwdev,
3070a9ffae8dSYuan-Han Zhang 				       s8 pw_ofst, enum rtw89_mac_idx mac_idx);
30712a7e54dbSPing-Ke Shih 	int (*pwr_on_func)(struct rtw89_dev *rtwdev);
30722a7e54dbSPing-Ke Shih 	int (*pwr_off_func)(struct rtw89_dev *rtwdev);
3073de9f9338SPing-Ke Shih 	void (*query_rxdesc)(struct rtw89_dev *rtwdev,
3074de9f9338SPing-Ke Shih 			     struct rtw89_rx_desc_info *desc_info,
3075de9f9338SPing-Ke Shih 			     u8 *data, u32 data_offset);
3076f59acddeSPing-Ke Shih 	void (*fill_txdesc)(struct rtw89_dev *rtwdev,
3077f59acddeSPing-Ke Shih 			    struct rtw89_tx_desc_info *desc_info,
3078f59acddeSPing-Ke Shih 			    void *txdesc);
3079a95bd62eSPing-Ke Shih 	void (*fill_txdesc_fwcmd)(struct rtw89_dev *rtwdev,
3080a95bd62eSPing-Ke Shih 				  struct rtw89_tx_desc_info *desc_info,
3081a95bd62eSPing-Ke Shih 				  void *txdesc);
3082feed6541SChia-Yuan Li 	int (*cfg_ctrl_path)(struct rtw89_dev *rtwdev, bool wl);
3083feed6541SChia-Yuan Li 	int (*mac_cfg_gnt)(struct rtw89_dev *rtwdev,
3084feed6541SChia-Yuan Li 			   const struct rtw89_mac_ax_coex_gnt *gnt_cfg);
3085de7ba639SPing-Ke Shih 	int (*stop_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx,
3086de7ba639SPing-Ke Shih 			   u32 *tx_en, enum rtw89_sch_tx_sel sel);
3087de7ba639SPing-Ke Shih 	int (*resume_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en);
30880a6f299bSPing-Ke Shih 	int (*h2c_dctl_sec_cam)(struct rtw89_dev *rtwdev,
30890a6f299bSPing-Ke Shih 				struct rtw89_vif *rtwvif,
30900a6f299bSPing-Ke Shih 				struct rtw89_sta *rtwsta);
3091e3ec7017SPing-Ke Shih 
3092e3ec7017SPing-Ke Shih 	void (*btc_set_rfe)(struct rtw89_dev *rtwdev);
3093e3ec7017SPing-Ke Shih 	void (*btc_init_cfg)(struct rtw89_dev *rtwdev);
3094e3ec7017SPing-Ke Shih 	void (*btc_set_wl_pri)(struct rtw89_dev *rtwdev, u8 map, bool state);
3095e3ec7017SPing-Ke Shih 	void (*btc_set_wl_txpwr_ctrl)(struct rtw89_dev *rtwdev, u32 txpwr_val);
3096e3ec7017SPing-Ke Shih 	s8 (*btc_get_bt_rssi)(struct rtw89_dev *rtwdev, s8 val);
3097e3ec7017SPing-Ke Shih 	void (*btc_update_bt_cnt)(struct rtw89_dev *rtwdev);
3098e3ec7017SPing-Ke Shih 	void (*btc_wl_s1_standby)(struct rtw89_dev *rtwdev, bool state);
3099a8a0b1f7SChing-Te Ku 	void (*btc_set_policy)(struct rtw89_dev *rtwdev, u16 policy_type);
3100f2fe93b3SChing-Te Ku 	void (*btc_set_wl_rx_gain)(struct rtw89_dev *rtwdev, u32 level);
3101e3ec7017SPing-Ke Shih };
3102e3ec7017SPing-Ke Shih 
3103e3ec7017SPing-Ke Shih enum rtw89_dma_ch {
3104e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH0 = 0,
3105e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH1 = 1,
3106e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH2 = 2,
3107e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH3 = 3,
3108e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH4 = 4,
3109e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH5 = 5,
3110e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH6 = 6,
3111e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH7 = 7,
3112e3ec7017SPing-Ke Shih 	RTW89_DMA_B0MG = 8,
3113e3ec7017SPing-Ke Shih 	RTW89_DMA_B0HI = 9,
3114e3ec7017SPing-Ke Shih 	RTW89_DMA_B1MG = 10,
3115e3ec7017SPing-Ke Shih 	RTW89_DMA_B1HI = 11,
3116e3ec7017SPing-Ke Shih 	RTW89_DMA_H2C = 12,
3117e3ec7017SPing-Ke Shih 	RTW89_DMA_CH_NUM = 13
3118e3ec7017SPing-Ke Shih };
3119e3ec7017SPing-Ke Shih 
3120e3ec7017SPing-Ke Shih enum rtw89_qta_mode {
3121e3ec7017SPing-Ke Shih 	RTW89_QTA_SCC,
3122e3ec7017SPing-Ke Shih 	RTW89_QTA_DLFW,
31237a68ec3dSChih-Kang Chang 	RTW89_QTA_WOW,
3124e3ec7017SPing-Ke Shih 
3125e3ec7017SPing-Ke Shih 	/* keep last */
3126e3ec7017SPing-Ke Shih 	RTW89_QTA_INVALID,
3127e3ec7017SPing-Ke Shih };
3128e3ec7017SPing-Ke Shih 
3129e3ec7017SPing-Ke Shih struct rtw89_hfc_ch_cfg {
3130e3ec7017SPing-Ke Shih 	u16 min;
3131e3ec7017SPing-Ke Shih 	u16 max;
3132e3ec7017SPing-Ke Shih #define grp_0 0
3133e3ec7017SPing-Ke Shih #define grp_1 1
3134e3ec7017SPing-Ke Shih #define grp_num 2
3135e3ec7017SPing-Ke Shih 	u8 grp;
3136e3ec7017SPing-Ke Shih };
3137e3ec7017SPing-Ke Shih 
3138e3ec7017SPing-Ke Shih struct rtw89_hfc_ch_info {
3139e3ec7017SPing-Ke Shih 	u16 aval;
3140e3ec7017SPing-Ke Shih 	u16 used;
3141e3ec7017SPing-Ke Shih };
3142e3ec7017SPing-Ke Shih 
3143e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_cfg {
3144e3ec7017SPing-Ke Shih 	u16 grp0;
3145e3ec7017SPing-Ke Shih 	u16 grp1;
3146e3ec7017SPing-Ke Shih 	u16 pub_max;
3147e3ec7017SPing-Ke Shih 	u16 wp_thrd;
3148e3ec7017SPing-Ke Shih };
3149e3ec7017SPing-Ke Shih 
3150e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_info {
3151e3ec7017SPing-Ke Shih 	u16 g0_used;
3152e3ec7017SPing-Ke Shih 	u16 g1_used;
3153e3ec7017SPing-Ke Shih 	u16 g0_aval;
3154e3ec7017SPing-Ke Shih 	u16 g1_aval;
3155e3ec7017SPing-Ke Shih 	u16 pub_aval;
3156e3ec7017SPing-Ke Shih 	u16 wp_aval;
3157e3ec7017SPing-Ke Shih };
3158e3ec7017SPing-Ke Shih 
3159e3ec7017SPing-Ke Shih struct rtw89_hfc_prec_cfg {
3160e3ec7017SPing-Ke Shih 	u16 ch011_prec;
3161e3ec7017SPing-Ke Shih 	u16 h2c_prec;
3162e3ec7017SPing-Ke Shih 	u16 wp_ch07_prec;
3163e3ec7017SPing-Ke Shih 	u16 wp_ch811_prec;
3164e3ec7017SPing-Ke Shih 	u8 ch011_full_cond;
3165e3ec7017SPing-Ke Shih 	u8 h2c_full_cond;
3166e3ec7017SPing-Ke Shih 	u8 wp_ch07_full_cond;
3167e3ec7017SPing-Ke Shih 	u8 wp_ch811_full_cond;
3168e3ec7017SPing-Ke Shih };
3169e3ec7017SPing-Ke Shih 
3170e3ec7017SPing-Ke Shih struct rtw89_hfc_param {
3171e3ec7017SPing-Ke Shih 	bool en;
3172e3ec7017SPing-Ke Shih 	bool h2c_en;
3173e3ec7017SPing-Ke Shih 	u8 mode;
3174e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_ch_cfg *ch_cfg;
3175e3ec7017SPing-Ke Shih 	struct rtw89_hfc_ch_info ch_info[RTW89_DMA_CH_NUM];
3176e3ec7017SPing-Ke Shih 	struct rtw89_hfc_pub_cfg pub_cfg;
3177e3ec7017SPing-Ke Shih 	struct rtw89_hfc_pub_info pub_info;
3178e3ec7017SPing-Ke Shih 	struct rtw89_hfc_prec_cfg prec_cfg;
3179e3ec7017SPing-Ke Shih };
3180e3ec7017SPing-Ke Shih 
3181e3ec7017SPing-Ke Shih struct rtw89_hfc_param_ini {
3182e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_ch_cfg *ch_cfg;
3183e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_pub_cfg *pub_cfg;
3184e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_prec_cfg *prec_cfg;
3185e3ec7017SPing-Ke Shih 	u8 mode;
3186e3ec7017SPing-Ke Shih };
3187e3ec7017SPing-Ke Shih 
3188e3ec7017SPing-Ke Shih struct rtw89_dle_size {
3189e3ec7017SPing-Ke Shih 	u16 pge_size;
3190e3ec7017SPing-Ke Shih 	u16 lnk_pge_num;
3191e3ec7017SPing-Ke Shih 	u16 unlnk_pge_num;
3192e3ec7017SPing-Ke Shih };
3193e3ec7017SPing-Ke Shih 
3194e3ec7017SPing-Ke Shih struct rtw89_wde_quota {
3195e3ec7017SPing-Ke Shih 	u16 hif;
3196e3ec7017SPing-Ke Shih 	u16 wcpu;
3197e3ec7017SPing-Ke Shih 	u16 pkt_in;
3198e3ec7017SPing-Ke Shih 	u16 cpu_io;
3199e3ec7017SPing-Ke Shih };
3200e3ec7017SPing-Ke Shih 
3201e3ec7017SPing-Ke Shih struct rtw89_ple_quota {
3202e3ec7017SPing-Ke Shih 	u16 cma0_tx;
3203e3ec7017SPing-Ke Shih 	u16 cma1_tx;
3204e3ec7017SPing-Ke Shih 	u16 c2h;
3205e3ec7017SPing-Ke Shih 	u16 h2c;
3206e3ec7017SPing-Ke Shih 	u16 wcpu;
3207e3ec7017SPing-Ke Shih 	u16 mpdu_proc;
3208e3ec7017SPing-Ke Shih 	u16 cma0_dma;
3209e3ec7017SPing-Ke Shih 	u16 cma1_dma;
3210e3ec7017SPing-Ke Shih 	u16 bb_rpt;
3211e3ec7017SPing-Ke Shih 	u16 wd_rel;
3212e3ec7017SPing-Ke Shih 	u16 cpu_io;
321379d099e0SPing-Ke Shih 	u16 tx_rpt;
3214e3ec7017SPing-Ke Shih };
3215e3ec7017SPing-Ke Shih 
3216e3ec7017SPing-Ke Shih struct rtw89_dle_mem {
3217e3ec7017SPing-Ke Shih 	enum rtw89_qta_mode mode;
3218e3ec7017SPing-Ke Shih 	const struct rtw89_dle_size *wde_size;
3219e3ec7017SPing-Ke Shih 	const struct rtw89_dle_size *ple_size;
3220e3ec7017SPing-Ke Shih 	const struct rtw89_wde_quota *wde_min_qt;
3221e3ec7017SPing-Ke Shih 	const struct rtw89_wde_quota *wde_max_qt;
3222e3ec7017SPing-Ke Shih 	const struct rtw89_ple_quota *ple_min_qt;
3223e3ec7017SPing-Ke Shih 	const struct rtw89_ple_quota *ple_max_qt;
3224e3ec7017SPing-Ke Shih };
3225e3ec7017SPing-Ke Shih 
3226e3ec7017SPing-Ke Shih struct rtw89_reg_def {
3227e3ec7017SPing-Ke Shih 	u32 addr;
3228e3ec7017SPing-Ke Shih 	u32 mask;
3229e3ec7017SPing-Ke Shih };
3230e3ec7017SPing-Ke Shih 
3231e3ec7017SPing-Ke Shih struct rtw89_reg2_def {
3232e3ec7017SPing-Ke Shih 	u32 addr;
3233e3ec7017SPing-Ke Shih 	u32 data;
3234e3ec7017SPing-Ke Shih };
3235e3ec7017SPing-Ke Shih 
3236e3ec7017SPing-Ke Shih struct rtw89_reg3_def {
3237e3ec7017SPing-Ke Shih 	u32 addr;
3238e3ec7017SPing-Ke Shih 	u32 mask;
3239e3ec7017SPing-Ke Shih 	u32 data;
3240e3ec7017SPing-Ke Shih };
3241e3ec7017SPing-Ke Shih 
3242e3ec7017SPing-Ke Shih struct rtw89_reg5_def {
3243e3ec7017SPing-Ke Shih 	u8 flag; /* recognized by parsers */
3244e3ec7017SPing-Ke Shih 	u8 path;
3245e3ec7017SPing-Ke Shih 	u32 addr;
3246e3ec7017SPing-Ke Shih 	u32 mask;
3247e3ec7017SPing-Ke Shih 	u32 data;
3248e3ec7017SPing-Ke Shih };
3249e3ec7017SPing-Ke Shih 
3250e3ec7017SPing-Ke Shih struct rtw89_phy_table {
3251e3ec7017SPing-Ke Shih 	const struct rtw89_reg2_def *regs;
3252e3ec7017SPing-Ke Shih 	u32 n_regs;
3253e3ec7017SPing-Ke Shih 	enum rtw89_rf_path rf_path;
32542a5f2b32SPing-Ke Shih 	void (*config)(struct rtw89_dev *rtwdev, const struct rtw89_reg2_def *reg,
32552a5f2b32SPing-Ke Shih 		       enum rtw89_rf_path rf_path, void *data);
3256e3ec7017SPing-Ke Shih };
3257e3ec7017SPing-Ke Shih 
3258e3ec7017SPing-Ke Shih struct rtw89_txpwr_table {
3259e3ec7017SPing-Ke Shih 	const void *data;
3260e3ec7017SPing-Ke Shih 	u32 size;
3261e3ec7017SPing-Ke Shih 	void (*load)(struct rtw89_dev *rtwdev,
3262e3ec7017SPing-Ke Shih 		     const struct rtw89_txpwr_table *tbl);
3263e3ec7017SPing-Ke Shih };
3264e3ec7017SPing-Ke Shih 
32655395482aSZong-Zhe Yang struct rtw89_txpwr_rule_2ghz {
32665395482aSZong-Zhe Yang 	const s8 (*lmt)[RTW89_2G_BW_NUM][RTW89_NTX_NUM]
32675395482aSZong-Zhe Yang 		       [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
32685395482aSZong-Zhe Yang 		       [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
32695395482aSZong-Zhe Yang 	const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
32705395482aSZong-Zhe Yang 			  [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
32715395482aSZong-Zhe Yang };
32725395482aSZong-Zhe Yang 
32735395482aSZong-Zhe Yang struct rtw89_txpwr_rule_5ghz {
32745395482aSZong-Zhe Yang 	const s8 (*lmt)[RTW89_5G_BW_NUM][RTW89_NTX_NUM]
32755395482aSZong-Zhe Yang 		       [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
32765395482aSZong-Zhe Yang 		       [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
32775395482aSZong-Zhe Yang 	const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
32785395482aSZong-Zhe Yang 			  [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
32795395482aSZong-Zhe Yang };
32805395482aSZong-Zhe Yang 
32815395482aSZong-Zhe Yang struct rtw89_txpwr_rule_6ghz {
32825395482aSZong-Zhe Yang 	const s8 (*lmt)[RTW89_6G_BW_NUM][RTW89_NTX_NUM]
32835395482aSZong-Zhe Yang 		       [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
32842a8ec45fSZong-Zhe Yang 		       [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
32852a8ec45fSZong-Zhe Yang 		       [RTW89_6G_CH_NUM];
32865395482aSZong-Zhe Yang 	const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
3287dad142c3SZong-Zhe Yang 			  [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
3288dad142c3SZong-Zhe Yang 			  [RTW89_6G_CH_NUM];
32895395482aSZong-Zhe Yang };
32905395482aSZong-Zhe Yang 
32915395482aSZong-Zhe Yang struct rtw89_rfe_parms {
32925395482aSZong-Zhe Yang 	struct rtw89_txpwr_rule_2ghz rule_2ghz;
32935395482aSZong-Zhe Yang 	struct rtw89_txpwr_rule_5ghz rule_5ghz;
32945395482aSZong-Zhe Yang 	struct rtw89_txpwr_rule_6ghz rule_6ghz;
32955395482aSZong-Zhe Yang };
32965395482aSZong-Zhe Yang 
32975395482aSZong-Zhe Yang struct rtw89_rfe_parms_conf {
32985395482aSZong-Zhe Yang 	const struct rtw89_rfe_parms *rfe_parms;
32995395482aSZong-Zhe Yang 	u8 rfe_type;
33005395482aSZong-Zhe Yang };
33015395482aSZong-Zhe Yang 
3302ab8a5671SPing-Ke Shih struct rtw89_page_regs {
3303ab8a5671SPing-Ke Shih 	u32 hci_fc_ctrl;
3304ab8a5671SPing-Ke Shih 	u32 ch_page_ctrl;
3305ab8a5671SPing-Ke Shih 	u32 ach_page_ctrl;
3306ab8a5671SPing-Ke Shih 	u32 ach_page_info;
3307ab8a5671SPing-Ke Shih 	u32 pub_page_info3;
3308ab8a5671SPing-Ke Shih 	u32 pub_page_ctrl1;
3309ab8a5671SPing-Ke Shih 	u32 pub_page_ctrl2;
3310ab8a5671SPing-Ke Shih 	u32 pub_page_info1;
3311ab8a5671SPing-Ke Shih 	u32 pub_page_info2;
3312ab8a5671SPing-Ke Shih 	u32 wp_page_ctrl1;
3313ab8a5671SPing-Ke Shih 	u32 wp_page_ctrl2;
3314ab8a5671SPing-Ke Shih 	u32 wp_page_info1;
3315ab8a5671SPing-Ke Shih };
3316ab8a5671SPing-Ke Shih 
3317eeadcd2aSChia-Yuan Li struct rtw89_imr_info {
3318eeadcd2aSChia-Yuan Li 	u32 wdrls_imr_set;
3319eeadcd2aSChia-Yuan Li 	u32 wsec_imr_reg;
3320eeadcd2aSChia-Yuan Li 	u32 wsec_imr_set;
3321eeadcd2aSChia-Yuan Li 	u32 mpdu_tx_imr_set;
3322eeadcd2aSChia-Yuan Li 	u32 mpdu_rx_imr_set;
3323eeadcd2aSChia-Yuan Li 	u32 sta_sch_imr_set;
3324eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b0_reg;
3325eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b0_clr;
3326eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b0_set;
3327eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b1_reg;
3328eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b1_clr;
3329eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b1_set;
3330eeadcd2aSChia-Yuan Li 	u32 wde_imr_clr;
3331eeadcd2aSChia-Yuan Li 	u32 wde_imr_set;
3332eeadcd2aSChia-Yuan Li 	u32 ple_imr_clr;
3333eeadcd2aSChia-Yuan Li 	u32 ple_imr_set;
3334eeadcd2aSChia-Yuan Li 	u32 host_disp_imr_clr;
3335eeadcd2aSChia-Yuan Li 	u32 host_disp_imr_set;
3336eeadcd2aSChia-Yuan Li 	u32 cpu_disp_imr_clr;
3337eeadcd2aSChia-Yuan Li 	u32 cpu_disp_imr_set;
3338eeadcd2aSChia-Yuan Li 	u32 other_disp_imr_clr;
3339eeadcd2aSChia-Yuan Li 	u32 other_disp_imr_set;
334075f1ed29SPing-Ke Shih 	u32 bbrpt_com_err_imr_reg;
3341eeadcd2aSChia-Yuan Li 	u32 bbrpt_chinfo_err_imr_reg;
3342eeadcd2aSChia-Yuan Li 	u32 bbrpt_err_imr_set;
3343eeadcd2aSChia-Yuan Li 	u32 bbrpt_dfs_err_imr_reg;
3344d86369e9SChia-Yuan Li 	u32 ptcl_imr_clr;
3345d86369e9SChia-Yuan Li 	u32 ptcl_imr_set;
3346d86369e9SChia-Yuan Li 	u32 cdma_imr_0_reg;
3347d86369e9SChia-Yuan Li 	u32 cdma_imr_0_clr;
3348d86369e9SChia-Yuan Li 	u32 cdma_imr_0_set;
3349d86369e9SChia-Yuan Li 	u32 cdma_imr_1_reg;
3350d86369e9SChia-Yuan Li 	u32 cdma_imr_1_clr;
3351d86369e9SChia-Yuan Li 	u32 cdma_imr_1_set;
3352d86369e9SChia-Yuan Li 	u32 phy_intf_imr_reg;
3353d86369e9SChia-Yuan Li 	u32 phy_intf_imr_clr;
3354d86369e9SChia-Yuan Li 	u32 phy_intf_imr_set;
3355d86369e9SChia-Yuan Li 	u32 rmac_imr_reg;
3356d86369e9SChia-Yuan Li 	u32 rmac_imr_clr;
3357d86369e9SChia-Yuan Li 	u32 rmac_imr_set;
3358d86369e9SChia-Yuan Li 	u32 tmac_imr_reg;
3359d86369e9SChia-Yuan Li 	u32 tmac_imr_clr;
3360d86369e9SChia-Yuan Li 	u32 tmac_imr_set;
3361eeadcd2aSChia-Yuan Li };
3362eeadcd2aSChia-Yuan Li 
33630789881aSChia-Yuan Li struct rtw89_xtal_info {
33640789881aSChia-Yuan Li 	u32 xcap_reg;
33650789881aSChia-Yuan Li 	u32 sc_xo_mask;
33660789881aSChia-Yuan Li 	u32 sc_xi_mask;
33670789881aSChia-Yuan Li };
33680789881aSChia-Yuan Li 
33699ef9edb9SChia-Yuan Li struct rtw89_rrsr_cfgs {
33709ef9edb9SChia-Yuan Li 	struct rtw89_reg3_def ref_rate;
33719ef9edb9SChia-Yuan Li 	struct rtw89_reg3_def rsc;
33729ef9edb9SChia-Yuan Li };
33739ef9edb9SChia-Yuan Li 
337487deaad9SEric Huang struct rtw89_dig_regs {
337587deaad9SEric Huang 	u32 seg0_pd_reg;
337687deaad9SEric Huang 	u32 pd_lower_bound_mask;
337787deaad9SEric Huang 	u32 pd_spatial_reuse_en;
3378058b2074SCheng-Chieh Hsieh 	u32 bmode_pd_reg;
3379058b2074SCheng-Chieh Hsieh 	u32 bmode_cca_rssi_limit_en;
3380058b2074SCheng-Chieh Hsieh 	u32 bmode_pd_lower_bound_reg;
3381058b2074SCheng-Chieh Hsieh 	u32 bmode_rssi_nocca_low_th_mask;
338287deaad9SEric Huang 	struct rtw89_reg_def p0_lna_init;
338387deaad9SEric Huang 	struct rtw89_reg_def p1_lna_init;
338487deaad9SEric Huang 	struct rtw89_reg_def p0_tia_init;
338587deaad9SEric Huang 	struct rtw89_reg_def p1_tia_init;
338687deaad9SEric Huang 	struct rtw89_reg_def p0_rxb_init;
338787deaad9SEric Huang 	struct rtw89_reg_def p1_rxb_init;
338887deaad9SEric Huang 	struct rtw89_reg_def p0_p20_pagcugc_en;
338987deaad9SEric Huang 	struct rtw89_reg_def p0_s20_pagcugc_en;
339087deaad9SEric Huang 	struct rtw89_reg_def p1_p20_pagcugc_en;
339187deaad9SEric Huang 	struct rtw89_reg_def p1_s20_pagcugc_en;
339287deaad9SEric Huang };
339387deaad9SEric Huang 
339429136c95SEric Huang struct rtw89_phy_ul_tb_info {
339529136c95SEric Huang 	bool dyn_tb_tri_en;
339629136c95SEric Huang 	u8 def_if_bandedge;
339729136c95SEric Huang };
339829136c95SEric Huang 
3399e3715859SEric Huang struct rtw89_antdiv_stats {
3400e3715859SEric Huang 	struct ewma_rssi cck_rssi_avg;
3401e3715859SEric Huang 	struct ewma_rssi ofdm_rssi_avg;
3402e3715859SEric Huang 	struct ewma_rssi non_legacy_rssi_avg;
3403e3715859SEric Huang 	u16 pkt_cnt_cck;
3404e3715859SEric Huang 	u16 pkt_cnt_ofdm;
3405e3715859SEric Huang 	u16 pkt_cnt_non_legacy;
34065feecb40SEric Huang 	u32 evm;
3407e3715859SEric Huang };
3408e3715859SEric Huang 
3409e3715859SEric Huang struct rtw89_antdiv_info {
3410e3715859SEric Huang 	struct rtw89_antdiv_stats target_stats;
3411e3715859SEric Huang 	struct rtw89_antdiv_stats main_stats;
3412e3715859SEric Huang 	struct rtw89_antdiv_stats aux_stats;
3413e3715859SEric Huang 	u8 training_count;
3414e3715859SEric Huang 	u8 rssi_pre;
3415e3715859SEric Huang 	bool get_stats;
3416e3715859SEric Huang };
3417e3715859SEric Huang 
34184843aa37SZong-Zhe Yang enum rtw89_chanctx_state {
34194843aa37SZong-Zhe Yang 	RTW89_CHANCTX_STATE_MCC_START,
34204843aa37SZong-Zhe Yang 	RTW89_CHANCTX_STATE_MCC_STOP,
34214843aa37SZong-Zhe Yang };
34224843aa37SZong-Zhe Yang 
34234843aa37SZong-Zhe Yang enum rtw89_chanctx_callbacks {
34244843aa37SZong-Zhe Yang 	RTW89_CHANCTX_CALLBACK_PLACEHOLDER,
34254843aa37SZong-Zhe Yang 
34264843aa37SZong-Zhe Yang 	NUM_OF_RTW89_CHANCTX_CALLBACKS,
34274843aa37SZong-Zhe Yang };
34284843aa37SZong-Zhe Yang 
34294843aa37SZong-Zhe Yang struct rtw89_chanctx_listener {
34304843aa37SZong-Zhe Yang 	void (*callbacks[NUM_OF_RTW89_CHANCTX_CALLBACKS])
34314843aa37SZong-Zhe Yang 		(struct rtw89_dev *rtwdev, enum rtw89_chanctx_state state);
34324843aa37SZong-Zhe Yang };
34334843aa37SZong-Zhe Yang 
3434e3ec7017SPing-Ke Shih struct rtw89_chip_info {
3435e3ec7017SPing-Ke Shih 	enum rtw89_core_chip_id chip_id;
3436f698afa7SPing-Ke Shih 	enum rtw89_chip_gen chip_gen;
3437e3ec7017SPing-Ke Shih 	const struct rtw89_chip_ops *ops;
3438c220d08eSPing-Ke Shih 	const struct rtw89_mac_gen_def *mac_def;
34391165f571SPing-Ke Shih 	const struct rtw89_phy_gen_def *phy_def;
3440ffde7f34SPing-Ke Shih 	const char *fw_basename;
3441ffde7f34SPing-Ke Shih 	u8 fw_format_max;
34427410bd72SPing-Ke Shih 	bool try_ce_fw;
3443dd59c6a3SPing-Ke Shih 	u32 needed_fw_elms;
3444e3ec7017SPing-Ke Shih 	u32 fifo_size;
3445ce816ab5SPing-Ke Shih 	bool small_fifo_size;
34465f8c35b9SPing-Ke Shih 	u32 dle_scc_rsvd_size;
3447e3ec7017SPing-Ke Shih 	u16 max_amsdu_limit;
3448e3ec7017SPing-Ke Shih 	bool dis_2g_40m_ul_ofdma;
34499f8004bfSZong-Zhe Yang 	u32 rsvd_ple_ofst;
3450e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_param_ini *hfc_param_ini;
3451e3ec7017SPing-Ke Shih 	const struct rtw89_dle_mem *dle_mem;
345241d56769SChih-Kang Chang 	u8 wde_qempty_acq_num;
345341d56769SChih-Kang Chang 	u8 wde_qempty_mgq_sel;
3454e3ec7017SPing-Ke Shih 	u32 rf_base_addr[2];
34557fc06a07SZong-Zhe Yang 	u8 support_chanctx_num;
34560237f65aSZong-Zhe Yang 	u8 support_bands;
3457d221270aSPing-Ke Shih 	bool support_bw160;
3458a002f981SZong-Zhe Yang 	bool support_unii4;
345929136c95SEric Huang 	bool support_ul_tb_ctrl;
346079a6c9a4SPing-Ke Shih 	bool hw_sec_hdr;
3461e3ec7017SPing-Ke Shih 	u8 rf_path_num;
3462e3ec7017SPing-Ke Shih 	u8 tx_nss;
3463e3ec7017SPing-Ke Shih 	u8 rx_nss;
3464e3ec7017SPing-Ke Shih 	u8 acam_num;
3465e3ec7017SPing-Ke Shih 	u8 bcam_num;
3466e3ec7017SPing-Ke Shih 	u8 scam_num;
34672def7356SPing-Ke Shih 	u8 bacam_num;
34688b1b4730SPing-Ke Shih 	u8 bacam_dynamic_num;
3469b6335d91SPing-Ke Shih 	enum rtw89_bacam_ver bacam_ver;
3470e3ec7017SPing-Ke Shih 
3471e3ec7017SPing-Ke Shih 	u8 sec_ctrl_efuse_size;
3472e3ec7017SPing-Ke Shih 	u32 physical_efuse_size;
3473e3ec7017SPing-Ke Shih 	u32 logical_efuse_size;
3474e3ec7017SPing-Ke Shih 	u32 limit_efuse_size;
3475bdfbf06cSPing-Ke Shih 	u32 dav_phy_efuse_size;
3476bdfbf06cSPing-Ke Shih 	u32 dav_log_efuse_size;
3477e3ec7017SPing-Ke Shih 	u32 phycap_addr;
3478e3ec7017SPing-Ke Shih 	u32 phycap_size;
3479e3ec7017SPing-Ke Shih 
3480e3ec7017SPing-Ke Shih 	const struct rtw89_pwr_cfg * const *pwr_on_seq;
3481e3ec7017SPing-Ke Shih 	const struct rtw89_pwr_cfg * const *pwr_off_seq;
3482e3ec7017SPing-Ke Shih 	const struct rtw89_phy_table *bb_table;
3483eefad995SPing-Ke Shih 	const struct rtw89_phy_table *bb_gain_table;
3484e3ec7017SPing-Ke Shih 	const struct rtw89_phy_table *rf_table[RF_PATH_MAX];
3485e3ec7017SPing-Ke Shih 	const struct rtw89_phy_table *nctl_table;
3486a24be8bbSPing-Ke Shih 	const struct rtw89_rfk_tbl *nctl_post_table;
3487e3ec7017SPing-Ke Shih 	const struct rtw89_txpwr_table *byr_table;
3488e3ec7017SPing-Ke Shih 	const struct rtw89_phy_dig_gain_table *dig_table;
348987deaad9SEric Huang 	const struct rtw89_dig_regs *dig_regs;
3490c7845551SPing-Ke Shih 	const struct rtw89_phy_tssi_dbw_table *tssi_dbw_table;
34915395482aSZong-Zhe Yang 
34925395482aSZong-Zhe Yang 	/* NULL if no rfe-specific, or a null-terminated array by rfe_parms */
34935395482aSZong-Zhe Yang 	const struct rtw89_rfe_parms_conf *rfe_parms_conf;
34945395482aSZong-Zhe Yang 	const struct rtw89_rfe_parms *dflt_parms;
34954843aa37SZong-Zhe Yang 	const struct rtw89_chanctx_listener *chanctx_listener;
3496e3ec7017SPing-Ke Shih 
3497e3ec7017SPing-Ke Shih 	u8 txpwr_factor_rf;
3498e3ec7017SPing-Ke Shih 	u8 txpwr_factor_mac;
3499e3ec7017SPing-Ke Shih 
3500e3ec7017SPing-Ke Shih 	u32 para_ver;
3501e3ec7017SPing-Ke Shih 	u32 wlcx_desired;
3502e3ec7017SPing-Ke Shih 	u8 btcx_desired;
3503e3ec7017SPing-Ke Shih 	u8 scbd;
3504e3ec7017SPing-Ke Shih 	u8 mailbox;
3505ba787c07SChing-Te Ku 
3506e3ec7017SPing-Ke Shih 	u8 afh_guard_ch;
3507e3ec7017SPing-Ke Shih 	const u8 *wl_rssi_thres;
3508e3ec7017SPing-Ke Shih 	const u8 *bt_rssi_thres;
3509e3ec7017SPing-Ke Shih 	u8 rssi_tol;
3510e3ec7017SPing-Ke Shih 
3511e3ec7017SPing-Ke Shih 	u8 mon_reg_num;
3512e3ec7017SPing-Ke Shih 	const struct rtw89_btc_fbtc_mreg *mon_reg;
3513e3ec7017SPing-Ke Shih 	u8 rf_para_ulink_num;
3514e3ec7017SPing-Ke Shih 	const struct rtw89_btc_rf_trx_para *rf_para_ulink;
3515e3ec7017SPing-Ke Shih 	u8 rf_para_dlink_num;
3516e3ec7017SPing-Ke Shih 	const struct rtw89_btc_rf_trx_para *rf_para_dlink;
3517e3ec7017SPing-Ke Shih 	u8 ps_mode_supported;
351852edbb9fSPing-Ke Shih 	u8 low_power_hci_modes;
35192af64b4aSPing-Ke Shih 
3520aa7f148bSPing-Ke Shih 	u32 h2c_cctl_func_id;
35212af64b4aSPing-Ke Shih 	u32 hci_func_en_addr;
3522a95bd62eSPing-Ke Shih 	u32 h2c_desc_size;
3523f59acddeSPing-Ke Shih 	u32 txwd_body_size;
3524e8955811SPing-Ke Shih 	u32 h2c_ctrl_reg;
3525e8955811SPing-Ke Shih 	const u32 *h2c_regs;
3526e749ef96SPing-Ke Shih 	struct rtw89_reg_def h2c_counter_reg;
3527e8955811SPing-Ke Shih 	u32 c2h_ctrl_reg;
3528e8955811SPing-Ke Shih 	const u32 *c2h_regs;
3529e749ef96SPing-Ke Shih 	struct rtw89_reg_def c2h_counter_reg;
3530ab8a5671SPing-Ke Shih 	const struct rtw89_page_regs *page_regs;
353110cd4092SEric Huang 	bool cfo_src_fd;
35329f9882dbSEric Huang 	bool cfo_hw_comp;
3533b7379148SYuan-Han Zhang 	const struct rtw89_reg_def *dcfo_comp;
3534b7379148SYuan-Han Zhang 	u8 dcfo_comp_sft;
3535eeadcd2aSChia-Yuan Li 	const struct rtw89_imr_info *imr_info;
35369ef9edb9SChia-Yuan Li 	const struct rtw89_rrsr_cfgs *rrsr_cfgs;
3537a48f4fd0SEric Huang 	u32 bss_clr_map_reg;
3538a1b7163aSPing-Ke Shih 	u32 dma_ch_mask;
3539280c4447SChih-Kang Chang 	u32 edcca_lvl_reg;
354019e28c7fSChin-Yen Lee 	const struct wiphy_wowlan_support *wowlan_stub;
35410789881aSChia-Yuan Li 	const struct rtw89_xtal_info *xtal_info;
3542e3ec7017SPing-Ke Shih };
3543e3ec7017SPing-Ke Shih 
35444a9e48acSPing-Ke Shih union rtw89_bus_info {
35454a9e48acSPing-Ke Shih 	const struct rtw89_pci_info *pci;
35464a9e48acSPing-Ke Shih };
35474a9e48acSPing-Ke Shih 
3548861e58c8SZong-Zhe Yang struct rtw89_driver_info {
3549861e58c8SZong-Zhe Yang 	const struct rtw89_chip_info *chip;
35504a9e48acSPing-Ke Shih 	union rtw89_bus_info bus;
3551861e58c8SZong-Zhe Yang };
3552861e58c8SZong-Zhe Yang 
3553e3ec7017SPing-Ke Shih enum rtw89_hcifc_mode {
3554e3ec7017SPing-Ke Shih 	RTW89_HCIFC_POH = 0,
3555e3ec7017SPing-Ke Shih 	RTW89_HCIFC_STF = 1,
3556e3ec7017SPing-Ke Shih 	RTW89_HCIFC_SDIO = 2,
3557e3ec7017SPing-Ke Shih 
3558e3ec7017SPing-Ke Shih 	/* keep last */
3559e3ec7017SPing-Ke Shih 	RTW89_HCIFC_MODE_INVALID,
3560e3ec7017SPing-Ke Shih };
3561e3ec7017SPing-Ke Shih 
3562e3ec7017SPing-Ke Shih struct rtw89_dle_info {
3563e3ec7017SPing-Ke Shih 	enum rtw89_qta_mode qta_mode;
3564e3ec7017SPing-Ke Shih 	u16 ple_pg_size;
3565e3ec7017SPing-Ke Shih 	u16 c0_rx_qta;
3566e3ec7017SPing-Ke Shih 	u16 c1_rx_qta;
3567e3ec7017SPing-Ke Shih };
3568e3ec7017SPing-Ke Shih 
3569e3ec7017SPing-Ke Shih enum rtw89_host_rpr_mode {
3570e3ec7017SPing-Ke Shih 	RTW89_RPR_MODE_POH = 0,
3571e3ec7017SPing-Ke Shih 	RTW89_RPR_MODE_STF
3572e3ec7017SPing-Ke Shih };
3573e3ec7017SPing-Ke Shih 
357422b10cdbSZong-Zhe Yang #define RTW89_COMPLETION_BUF_SIZE 24
357522b10cdbSZong-Zhe Yang #define RTW89_WAIT_COND_IDLE UINT_MAX
357622b10cdbSZong-Zhe Yang 
357722b10cdbSZong-Zhe Yang struct rtw89_completion_data {
357822b10cdbSZong-Zhe Yang 	bool err;
357922b10cdbSZong-Zhe Yang 	u8 buf[RTW89_COMPLETION_BUF_SIZE];
358022b10cdbSZong-Zhe Yang };
358122b10cdbSZong-Zhe Yang 
358222b10cdbSZong-Zhe Yang struct rtw89_wait_info {
358322b10cdbSZong-Zhe Yang 	atomic_t cond;
358422b10cdbSZong-Zhe Yang 	struct completion completion;
358522b10cdbSZong-Zhe Yang 	struct rtw89_completion_data data;
358622b10cdbSZong-Zhe Yang };
358722b10cdbSZong-Zhe Yang 
358822b10cdbSZong-Zhe Yang #define RTW89_WAIT_FOR_COND_TIMEOUT msecs_to_jiffies(100)
358922b10cdbSZong-Zhe Yang 
rtw89_init_wait(struct rtw89_wait_info * wait)359022b10cdbSZong-Zhe Yang static inline void rtw89_init_wait(struct rtw89_wait_info *wait)
359122b10cdbSZong-Zhe Yang {
359222b10cdbSZong-Zhe Yang 	init_completion(&wait->completion);
359322b10cdbSZong-Zhe Yang 	atomic_set(&wait->cond, RTW89_WAIT_COND_IDLE);
359422b10cdbSZong-Zhe Yang }
359522b10cdbSZong-Zhe Yang 
35968febd68bSZong-Zhe Yang struct rtw89_mac_info {
35978febd68bSZong-Zhe Yang 	struct rtw89_dle_info dle_info;
35988febd68bSZong-Zhe Yang 	struct rtw89_hfc_param hfc_param;
35998febd68bSZong-Zhe Yang 	enum rtw89_qta_mode qta_mode;
36008febd68bSZong-Zhe Yang 	u8 rpwm_seq_num;
36018febd68bSZong-Zhe Yang 	u8 cpwm_seq_num;
36028febd68bSZong-Zhe Yang 
36038febd68bSZong-Zhe Yang 	/* see RTW89_FW_OFLD_WAIT_COND series for wait condition */
36048febd68bSZong-Zhe Yang 	struct rtw89_wait_info fw_ofld_wait;
36058febd68bSZong-Zhe Yang };
36068febd68bSZong-Zhe Yang 
3607e3ec7017SPing-Ke Shih enum rtw89_fw_type {
3608e3ec7017SPing-Ke Shih 	RTW89_FW_NORMAL = 1,
3609e3ec7017SPing-Ke Shih 	RTW89_FW_WOWLAN = 3,
36107410bd72SPing-Ke Shih 	RTW89_FW_NORMAL_CE = 5,
36117d112665SPing-Ke Shih 	RTW89_FW_BBMCU0 = 64,
36127d112665SPing-Ke Shih 	RTW89_FW_BBMCU1 = 65,
361305208419SChin-Yen Lee 	RTW89_FW_LOGFMT = 255,
3614e3ec7017SPing-Ke Shih };
3615e3ec7017SPing-Ke Shih 
361611fe4ccdSZong-Zhe Yang enum rtw89_fw_feature {
361711fe4ccdSZong-Zhe Yang 	RTW89_FW_FEATURE_OLD_HT_RA_FORMAT,
361811fe4ccdSZong-Zhe Yang 	RTW89_FW_FEATURE_SCAN_OFFLOAD,
361911fe4ccdSZong-Zhe Yang 	RTW89_FW_FEATURE_TX_WAKE,
3620edb89629SZong-Zhe Yang 	RTW89_FW_FEATURE_CRASH_TRIGGER,
36210d1f7ff1SZong-Zhe Yang 	RTW89_FW_FEATURE_NO_PACKET_DROP,
3622183c8effSChin-Yen Lee 	RTW89_FW_FEATURE_NO_DEEP_PS,
3623e5624482SPing-Ke Shih 	RTW89_FW_FEATURE_NO_LPS_PG,
3624d2b6da24SPo-Hao Huang 	RTW89_FW_FEATURE_BEACON_FILTER,
362511fe4ccdSZong-Zhe Yang };
362611fe4ccdSZong-Zhe Yang 
3627e3ec7017SPing-Ke Shih struct rtw89_fw_suit {
36281b073b35SPing-Ke Shih 	enum rtw89_fw_type type;
3629e3ec7017SPing-Ke Shih 	const u8 *data;
3630e3ec7017SPing-Ke Shih 	u32 size;
3631e3ec7017SPing-Ke Shih 	u8 major_ver;
3632e3ec7017SPing-Ke Shih 	u8 minor_ver;
3633e3ec7017SPing-Ke Shih 	u8 sub_ver;
3634e3ec7017SPing-Ke Shih 	u8 sub_idex;
3635e3ec7017SPing-Ke Shih 	u16 build_year;
3636e3ec7017SPing-Ke Shih 	u16 build_mon;
3637e3ec7017SPing-Ke Shih 	u16 build_date;
3638e3ec7017SPing-Ke Shih 	u16 build_hour;
3639e3ec7017SPing-Ke Shih 	u16 build_min;
3640e3ec7017SPing-Ke Shih 	u8 cmd_ver;
36411b073b35SPing-Ke Shih 	u8 hdr_ver;
36421b073b35SPing-Ke Shih 	u32 commitid;
3643e3ec7017SPing-Ke Shih };
3644e3ec7017SPing-Ke Shih 
3645e3ec7017SPing-Ke Shih #define RTW89_FW_VER_CODE(major, minor, sub, idx)	\
3646e3ec7017SPing-Ke Shih 	(((major) << 24) | ((minor) << 16) | ((sub) << 8) | (idx))
3647e3ec7017SPing-Ke Shih #define RTW89_FW_SUIT_VER_CODE(s)	\
3648e3ec7017SPing-Ke Shih 	RTW89_FW_VER_CODE((s)->major_ver, (s)->minor_ver, (s)->sub_ver, (s)->sub_idex)
3649e3ec7017SPing-Ke Shih 
3650deebea35SZong-Zhe Yang #define RTW89_MFW_HDR_VER_CODE(mfw_hdr)		\
3651deebea35SZong-Zhe Yang 	RTW89_FW_VER_CODE((mfw_hdr)->ver.major,	\
3652deebea35SZong-Zhe Yang 			  (mfw_hdr)->ver.minor,	\
3653deebea35SZong-Zhe Yang 			  (mfw_hdr)->ver.sub,	\
3654deebea35SZong-Zhe Yang 			  (mfw_hdr)->ver.idx)
3655deebea35SZong-Zhe Yang 
3656deebea35SZong-Zhe Yang #define RTW89_FW_HDR_VER_CODE(fw_hdr)				\
3657f072eb39SPing-Ke Shih 	RTW89_FW_VER_CODE(le32_get_bits((fw_hdr)->w1, FW_HDR_W1_MAJOR_VERSION),	\
3658f072eb39SPing-Ke Shih 			  le32_get_bits((fw_hdr)->w1, FW_HDR_W1_MINOR_VERSION),	\
3659f072eb39SPing-Ke Shih 			  le32_get_bits((fw_hdr)->w1, FW_HDR_W1_SUBVERSION),	\
3660f072eb39SPing-Ke Shih 			  le32_get_bits((fw_hdr)->w1, FW_HDR_W1_SUBINDEX))
3661deebea35SZong-Zhe Yang 
3662b80ad23aSPing-Ke Shih struct rtw89_fw_req_info {
3663e3ec7017SPing-Ke Shih 	const struct firmware *firmware;
3664e3ec7017SPing-Ke Shih 	struct completion completion;
3665b80ad23aSPing-Ke Shih };
3666b80ad23aSPing-Ke Shih 
3667cad2bd8aSChin-Yen Lee struct rtw89_fw_log {
3668cad2bd8aSChin-Yen Lee 	struct rtw89_fw_suit suit;
3669cad2bd8aSChin-Yen Lee 	bool enable;
3670cad2bd8aSChin-Yen Lee 	u32 last_fmt_id;
3671cad2bd8aSChin-Yen Lee 	u32 fmt_count;
3672cad2bd8aSChin-Yen Lee 	const __le32 *fmt_ids;
3673cad2bd8aSChin-Yen Lee 	const char *(*fmts)[];
3674cad2bd8aSChin-Yen Lee };
3675cad2bd8aSChin-Yen Lee 
367689474720SPing-Ke Shih struct rtw89_fw_elm_info {
367789474720SPing-Ke Shih 	struct rtw89_phy_table *bb_tbl;
367889474720SPing-Ke Shih 	struct rtw89_phy_table *bb_gain;
367989474720SPing-Ke Shih 	struct rtw89_phy_table *rf_radio[RF_PATH_MAX];
368089474720SPing-Ke Shih 	struct rtw89_phy_table *rf_nctl;
368189474720SPing-Ke Shih };
368289474720SPing-Ke Shih 
3683b80ad23aSPing-Ke Shih struct rtw89_fw_info {
3684b80ad23aSPing-Ke Shih 	struct rtw89_fw_req_info req;
3685ffde7f34SPing-Ke Shih 	int fw_format;
3686e3ec7017SPing-Ke Shih 	u8 h2c_seq;
3687e3ec7017SPing-Ke Shih 	u8 rec_seq;
3688e749ef96SPing-Ke Shih 	u8 h2c_counter;
3689e749ef96SPing-Ke Shih 	u8 c2h_counter;
3690e3ec7017SPing-Ke Shih 	struct rtw89_fw_suit normal;
3691e3ec7017SPing-Ke Shih 	struct rtw89_fw_suit wowlan;
36927d112665SPing-Ke Shih 	struct rtw89_fw_suit bbmcu0;
36937d112665SPing-Ke Shih 	struct rtw89_fw_suit bbmcu1;
3694cad2bd8aSChin-Yen Lee 	struct rtw89_fw_log log;
369511fe4ccdSZong-Zhe Yang 	u32 feature_map;
369689474720SPing-Ke Shih 	struct rtw89_fw_elm_info elm_info;
3697e3ec7017SPing-Ke Shih };
3698e3ec7017SPing-Ke Shih 
369911fe4ccdSZong-Zhe Yang #define RTW89_CHK_FW_FEATURE(_feat, _fw) \
370011fe4ccdSZong-Zhe Yang 	(!!((_fw)->feature_map & BIT(RTW89_FW_FEATURE_ ## _feat)))
370111fe4ccdSZong-Zhe Yang 
370211fe4ccdSZong-Zhe Yang #define RTW89_SET_FW_FEATURE(_fw_feature, _fw) \
370311fe4ccdSZong-Zhe Yang 	((_fw)->feature_map |= BIT(_fw_feature))
370411fe4ccdSZong-Zhe Yang 
3705e3ec7017SPing-Ke Shih struct rtw89_cam_info {
3706e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(addr_cam_map, RTW89_MAX_ADDR_CAM_NUM);
3707e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(bssid_cam_map, RTW89_MAX_BSSID_CAM_NUM);
3708e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(sec_cam_map, RTW89_MAX_SEC_CAM_NUM);
370908aa8077SPing-Ke Shih 	DECLARE_BITMAP(ba_cam_map, RTW89_MAX_BA_CAM_NUM);
371008aa8077SPing-Ke Shih 	struct rtw89_ba_cam_entry ba_cam_entry[RTW89_MAX_BA_CAM_NUM];
3711e3ec7017SPing-Ke Shih };
3712e3ec7017SPing-Ke Shih 
3713e3ec7017SPing-Ke Shih enum rtw89_sar_sources {
3714e3ec7017SPing-Ke Shih 	RTW89_SAR_SOURCE_NONE,
3715e3ec7017SPing-Ke Shih 	RTW89_SAR_SOURCE_COMMON,
3716e3ec7017SPing-Ke Shih 
3717e3ec7017SPing-Ke Shih 	RTW89_SAR_SOURCE_NR,
3718e3ec7017SPing-Ke Shih };
3719e3ec7017SPing-Ke Shih 
3720425671f0SZong-Zhe Yang enum rtw89_sar_subband {
3721425671f0SZong-Zhe Yang 	RTW89_SAR_2GHZ_SUBBAND,
3722425671f0SZong-Zhe Yang 	RTW89_SAR_5GHZ_SUBBAND_1_2, /* U-NII-1 and U-NII-2 */
3723425671f0SZong-Zhe Yang 	RTW89_SAR_5GHZ_SUBBAND_2_E, /* U-NII-2-Extended */
3724425671f0SZong-Zhe Yang 	RTW89_SAR_5GHZ_SUBBAND_3,   /* U-NII-3 */
3725425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */
3726425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */
3727425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_6,   /* U-NII-6 */
3728425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */
3729425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */
3730425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_8,   /* U-NII-8 */
3731425671f0SZong-Zhe Yang 
3732425671f0SZong-Zhe Yang 	RTW89_SAR_SUBBAND_NR,
3733425671f0SZong-Zhe Yang };
3734425671f0SZong-Zhe Yang 
3735e3ec7017SPing-Ke Shih struct rtw89_sar_cfg_common {
3736425671f0SZong-Zhe Yang 	bool set[RTW89_SAR_SUBBAND_NR];
3737425671f0SZong-Zhe Yang 	s32 cfg[RTW89_SAR_SUBBAND_NR];
3738e3ec7017SPing-Ke Shih };
3739e3ec7017SPing-Ke Shih 
3740e3ec7017SPing-Ke Shih struct rtw89_sar_info {
3741e3ec7017SPing-Ke Shih 	/* used to decide how to acces SAR cfg union */
3742e3ec7017SPing-Ke Shih 	enum rtw89_sar_sources src;
3743e3ec7017SPing-Ke Shih 
3744e3ec7017SPing-Ke Shih 	/* reserved for different knids of SAR cfg struct.
3745e3ec7017SPing-Ke Shih 	 * supposed that a single cfg struct cannot handle various SAR sources.
3746e3ec7017SPing-Ke Shih 	 */
3747e3ec7017SPing-Ke Shih 	union {
3748e3ec7017SPing-Ke Shih 		struct rtw89_sar_cfg_common cfg_common;
3749e3ec7017SPing-Ke Shih 	};
3750e3ec7017SPing-Ke Shih };
3751e3ec7017SPing-Ke Shih 
3752eb2624f5SKuan-Chung Chen enum rtw89_tas_state {
3753eb2624f5SKuan-Chung Chen 	RTW89_TAS_STATE_DPR_OFF,
3754eb2624f5SKuan-Chung Chen 	RTW89_TAS_STATE_DPR_ON,
3755eb2624f5SKuan-Chung Chen 	RTW89_TAS_STATE_DPR_FORBID,
3756eb2624f5SKuan-Chung Chen };
3757eb2624f5SKuan-Chung Chen 
3758eb2624f5SKuan-Chung Chen #define RTW89_TAS_MAX_WINDOW 50
3759eb2624f5SKuan-Chung Chen struct rtw89_tas_info {
3760eb2624f5SKuan-Chung Chen 	s16 txpwr_history[RTW89_TAS_MAX_WINDOW];
3761eb2624f5SKuan-Chung Chen 	s32 total_txpwr;
3762eb2624f5SKuan-Chung Chen 	u8 cur_idx;
3763eb2624f5SKuan-Chung Chen 	s8 dpr_gap;
3764eb2624f5SKuan-Chung Chen 	s8 delta;
3765eb2624f5SKuan-Chung Chen 	enum rtw89_tas_state state;
3766eb2624f5SKuan-Chung Chen 	bool enable;
3767eb2624f5SKuan-Chung Chen };
3768eb2624f5SKuan-Chung Chen 
376984b50f41SZong-Zhe Yang struct rtw89_chanctx_cfg {
377084b50f41SZong-Zhe Yang 	enum rtw89_sub_entity_idx idx;
377184b50f41SZong-Zhe Yang };
377284b50f41SZong-Zhe Yang 
37737cf674ffSZong-Zhe Yang enum rtw89_entity_mode {
37747cf674ffSZong-Zhe Yang 	RTW89_ENTITY_MODE_SCC,
37754843aa37SZong-Zhe Yang 	RTW89_ENTITY_MODE_MCC_PREPARE,
37764843aa37SZong-Zhe Yang 	RTW89_ENTITY_MODE_MCC,
37774843aa37SZong-Zhe Yang 
37784843aa37SZong-Zhe Yang 	NUM_OF_RTW89_ENTITY_MODE,
37794843aa37SZong-Zhe Yang 	RTW89_ENTITY_MODE_INVALID = NUM_OF_RTW89_ENTITY_MODE,
37807cf674ffSZong-Zhe Yang };
37817cf674ffSZong-Zhe Yang 
378275ee07b0SZong-Zhe Yang struct rtw89_sub_entity {
378375ee07b0SZong-Zhe Yang 	struct cfg80211_chan_def chandef;
378475ee07b0SZong-Zhe Yang 	struct rtw89_chan chan;
378575ee07b0SZong-Zhe Yang 	struct rtw89_chan_rcd rcd;
378675ee07b0SZong-Zhe Yang 	struct rtw89_chanctx_cfg *cfg;
378775ee07b0SZong-Zhe Yang };
378875ee07b0SZong-Zhe Yang 
3789e3ec7017SPing-Ke Shih struct rtw89_hal {
3790e3ec7017SPing-Ke Shih 	u32 rx_fltr;
3791e3ec7017SPing-Ke Shih 	u8 cv;
3792a6fb2bb8SPing-Ke Shih 	u8 acv;
3793e3ec7017SPing-Ke Shih 	u32 antenna_tx;
3794e3ec7017SPing-Ke Shih 	u32 antenna_rx;
3795e3ec7017SPing-Ke Shih 	u8 tx_nss;
3796e3ec7017SPing-Ke Shih 	u8 rx_nss;
3797dc229d94SPing-Ke Shih 	bool tx_path_diversity;
3798f48453e0SPing-Ke Shih 	bool ant_diversity;
3799f48453e0SPing-Ke Shih 	bool ant_diversity_fixed;
38001c2423deSJohnson Lin 	bool support_cckpd;
38011e6f0d2aSJohnson Lin 	bool support_igi;
3802a0e97ae3SPo-Hao Huang 	atomic_t roc_entity_idx;
3803967439c7SZong-Zhe Yang 
3804494399b2SZong-Zhe Yang 	DECLARE_BITMAP(entity_map, NUM_OF_RTW89_SUB_ENTITY);
380575ee07b0SZong-Zhe Yang 	struct rtw89_sub_entity sub[NUM_OF_RTW89_SUB_ENTITY];
3806a0e97ae3SPo-Hao Huang 	struct cfg80211_chan_def roc_chandef;
3807494399b2SZong-Zhe Yang 
3808967439c7SZong-Zhe Yang 	bool entity_active;
38097cf674ffSZong-Zhe Yang 	enum rtw89_entity_mode entity_mode;
3810280c4447SChih-Kang Chang 
3811280c4447SChih-Kang Chang 	u32 edcca_bak;
3812e3ec7017SPing-Ke Shih };
3813e3ec7017SPing-Ke Shih 
3814e3ec7017SPing-Ke Shih #define RTW89_MAX_MAC_ID_NUM 128
381589590777SPo Hao Huang #define RTW89_MAX_PKT_OFLD_NUM 255
3816e3ec7017SPing-Ke Shih 
3817e3ec7017SPing-Ke Shih enum rtw89_flags {
3818e3ec7017SPing-Ke Shih 	RTW89_FLAG_POWERON,
3819e3ec7017SPing-Ke Shih 	RTW89_FLAG_FW_RDY,
3820e3ec7017SPing-Ke Shih 	RTW89_FLAG_RUNNING,
3821e3ec7017SPing-Ke Shih 	RTW89_FLAG_BFEE_MON,
3822e3ec7017SPing-Ke Shih 	RTW89_FLAG_BFEE_EN,
38238a66293eSPing-Ke Shih 	RTW89_FLAG_BFEE_TIMER_KEEP,
3824e3ec7017SPing-Ke Shih 	RTW89_FLAG_NAPI_RUNNING,
3825e3ec7017SPing-Ke Shih 	RTW89_FLAG_LEISURE_PS,
3826e3ec7017SPing-Ke Shih 	RTW89_FLAG_LOW_POWER_MODE,
3827e3ec7017SPing-Ke Shih 	RTW89_FLAG_INACTIVE_PS,
38288a1f6c88SZong-Zhe Yang 	RTW89_FLAG_CRASH_SIMULATING,
3829b79a84fbSZong-Zhe Yang 	RTW89_FLAG_SER_HANDLING,
383019e28c7fSChin-Yen Lee 	RTW89_FLAG_WOWLAN,
383119e28c7fSChin-Yen Lee 	RTW89_FLAG_FORBIDDEN_TRACK_WROK,
3832ac3a9f18SPing-Ke Shih 	RTW89_FLAG_CHANGING_INTERFACE,
3833e3ec7017SPing-Ke Shih 
3834e3ec7017SPing-Ke Shih 	NUM_OF_RTW89_FLAGS,
3835e3ec7017SPing-Ke Shih };
3836e3ec7017SPing-Ke Shih 
38379a785583SZong-Zhe Yang enum rtw89_pkt_drop_sel {
38389a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_MACID_BE_ONCE,
38399a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_MACID_BK_ONCE,
38409a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_MACID_VI_ONCE,
38419a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_MACID_VO_ONCE,
38429a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_MACID_ALL,
38439a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_MG0_ONCE,
38449a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_HIQ_ONCE,
38459a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_HIQ_PORT,
38469a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_HIQ_MBSSID,
38479a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_BAND,
38489a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_BAND_ONCE,
38499a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_REL_MACID,
38509a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_REL_HIQ_PORT,
38519a785583SZong-Zhe Yang 	RTW89_PKT_DROP_SEL_REL_HIQ_MBSSID,
38529a785583SZong-Zhe Yang };
38539a785583SZong-Zhe Yang 
38549a785583SZong-Zhe Yang struct rtw89_pkt_drop_params {
38559a785583SZong-Zhe Yang 	enum rtw89_pkt_drop_sel sel;
38569a785583SZong-Zhe Yang 	enum rtw89_mac_idx mac_band;
38579a785583SZong-Zhe Yang 	u8 macid;
38589a785583SZong-Zhe Yang 	u8 port;
38599a785583SZong-Zhe Yang 	u8 mbssid;
38609a785583SZong-Zhe Yang 	bool tf_trs;
386141d56769SChih-Kang Chang 	u32 macid_band_sel[4];
38629a785583SZong-Zhe Yang };
38639a785583SZong-Zhe Yang 
3864e3ec7017SPing-Ke Shih struct rtw89_pkt_stat {
3865e3ec7017SPing-Ke Shih 	u16 beacon_nr;
3866e3ec7017SPing-Ke Shih 	u32 rx_rate_cnt[RTW89_HW_RATE_NR];
3867e3ec7017SPing-Ke Shih };
3868e3ec7017SPing-Ke Shih 
3869e3ec7017SPing-Ke Shih DECLARE_EWMA(thermal, 4, 4);
3870e3ec7017SPing-Ke Shih 
3871e3ec7017SPing-Ke Shih struct rtw89_phy_stat {
3872e3ec7017SPing-Ke Shih 	struct ewma_thermal avg_thermal[RF_PATH_MAX];
3873e3ec7017SPing-Ke Shih 	struct rtw89_pkt_stat cur_pkt_stat;
3874e3ec7017SPing-Ke Shih 	struct rtw89_pkt_stat last_pkt_stat;
3875e3ec7017SPing-Ke Shih };
3876e3ec7017SPing-Ke Shih 
3877e3ec7017SPing-Ke Shih #define RTW89_DACK_PATH_NR 2
3878e3ec7017SPing-Ke Shih #define RTW89_DACK_IDX_NR 2
3879e3ec7017SPing-Ke Shih #define RTW89_DACK_MSBK_NR 16
3880e3ec7017SPing-Ke Shih struct rtw89_dack_info {
3881e3ec7017SPing-Ke Shih 	bool dack_done;
3882e3ec7017SPing-Ke Shih 	u8 msbk_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR][RTW89_DACK_MSBK_NR];
3883e3ec7017SPing-Ke Shih 	u8 dadck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
3884e3ec7017SPing-Ke Shih 	u16 addck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
3885e3ec7017SPing-Ke Shih 	u16 biask_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
3886e3ec7017SPing-Ke Shih 	u32 dack_cnt;
3887e3ec7017SPing-Ke Shih 	bool addck_timeout[RTW89_DACK_PATH_NR];
3888e3ec7017SPing-Ke Shih 	bool dadck_timeout[RTW89_DACK_PATH_NR];
3889e3ec7017SPing-Ke Shih 	bool msbk_timeout[RTW89_DACK_PATH_NR];
3890e3ec7017SPing-Ke Shih };
3891e3ec7017SPing-Ke Shih 
3892e3ec7017SPing-Ke Shih #define RTW89_IQK_CHS_NR 2
3893e3ec7017SPing-Ke Shih #define RTW89_IQK_PATH_NR 4
389416b44ed0SPing-Ke Shih 
389538f25decSZong-Zhe Yang struct rtw89_rfk_mcc_info {
389616b44ed0SPing-Ke Shih 	u8 ch[RTW89_IQK_CHS_NR];
389716b44ed0SPing-Ke Shih 	u8 band[RTW89_IQK_CHS_NR];
389816b44ed0SPing-Ke Shih 	u8 table_idx;
389916b44ed0SPing-Ke Shih };
390016b44ed0SPing-Ke Shih 
3901fb8177d7SPing-Ke Shih struct rtw89_lck_info {
3902fb8177d7SPing-Ke Shih 	u8 thermal[RF_PATH_MAX];
3903fb8177d7SPing-Ke Shih };
3904fb8177d7SPing-Ke Shih 
3905e3d365ffSPing-Ke Shih struct rtw89_rx_dck_info {
3906e3d365ffSPing-Ke Shih 	u8 thermal[RF_PATH_MAX];
3907e3d365ffSPing-Ke Shih };
3908e3d365ffSPing-Ke Shih 
3909e3ec7017SPing-Ke Shih struct rtw89_iqk_info {
3910e3ec7017SPing-Ke Shih 	bool lok_cor_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
3911e3ec7017SPing-Ke Shih 	bool lok_fin_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
39122da8109dSPing-Ke Shih 	bool lok_fail[RTW89_IQK_PATH_NR];
3913e3ec7017SPing-Ke Shih 	bool iqk_tx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
3914e3ec7017SPing-Ke Shih 	bool iqk_rx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
3915e3ec7017SPing-Ke Shih 	u32 iqk_fail_cnt;
3916e3ec7017SPing-Ke Shih 	bool is_iqk_init;
3917e3ec7017SPing-Ke Shih 	u32 iqk_channel[RTW89_IQK_CHS_NR];
3918e3ec7017SPing-Ke Shih 	u8 iqk_band[RTW89_IQK_PATH_NR];
3919e3ec7017SPing-Ke Shih 	u8 iqk_ch[RTW89_IQK_PATH_NR];
3920e3ec7017SPing-Ke Shih 	u8 iqk_bw[RTW89_IQK_PATH_NR];
3921e3ec7017SPing-Ke Shih 	u8 iqk_times;
3922e3ec7017SPing-Ke Shih 	u8 version;
3923e3ec7017SPing-Ke Shih 	u32 nb_txcfir[RTW89_IQK_PATH_NR];
3924e3ec7017SPing-Ke Shih 	u32 nb_rxcfir[RTW89_IQK_PATH_NR];
3925e3ec7017SPing-Ke Shih 	u32 bp_txkresult[RTW89_IQK_PATH_NR];
3926e3ec7017SPing-Ke Shih 	u32 bp_rxkresult[RTW89_IQK_PATH_NR];
3927e3ec7017SPing-Ke Shih 	u32 bp_iqkenable[RTW89_IQK_PATH_NR];
3928e3ec7017SPing-Ke Shih 	bool is_wb_txiqk[RTW89_IQK_PATH_NR];
3929e3ec7017SPing-Ke Shih 	bool is_wb_rxiqk[RTW89_IQK_PATH_NR];
3930e3ec7017SPing-Ke Shih 	bool is_nbiqk;
3931e3ec7017SPing-Ke Shih 	bool iqk_fft_en;
3932e3ec7017SPing-Ke Shih 	bool iqk_xym_en;
3933e3ec7017SPing-Ke Shih 	bool iqk_sram_en;
3934e3ec7017SPing-Ke Shih 	bool iqk_cfir_en;
3935e3ec7017SPing-Ke Shih 	u32 syn1to2;
3936e3ec7017SPing-Ke Shih 	u8 iqk_mcc_ch[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
3937e3ec7017SPing-Ke Shih 	u8 iqk_table_idx[RTW89_IQK_PATH_NR];
39382da8109dSPing-Ke Shih 	u32 lok_idac[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
39392da8109dSPing-Ke Shih 	u32 lok_vbuf[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
3940e3ec7017SPing-Ke Shih };
3941e3ec7017SPing-Ke Shih 
3942e3ec7017SPing-Ke Shih #define RTW89_DPK_RF_PATH 2
3943e3ec7017SPing-Ke Shih #define RTW89_DPK_AVG_THERMAL_NUM 8
3944e3ec7017SPing-Ke Shih #define RTW89_DPK_BKUP_NUM 2
3945e3ec7017SPing-Ke Shih struct rtw89_dpk_bkup_para {
3946e3ec7017SPing-Ke Shih 	enum rtw89_band band;
3947e3ec7017SPing-Ke Shih 	enum rtw89_bandwidth bw;
3948e3ec7017SPing-Ke Shih 	u8 ch;
3949e3ec7017SPing-Ke Shih 	bool path_ok;
3950da4cea16SPing-Ke Shih 	u8 mdpd_en;
3951e3ec7017SPing-Ke Shih 	u8 txagc_dpk;
3952e3ec7017SPing-Ke Shih 	u8 ther_dpk;
3953e3ec7017SPing-Ke Shih 	u8 gs;
3954e3ec7017SPing-Ke Shih 	u16 pwsf;
3955e3ec7017SPing-Ke Shih };
3956e3ec7017SPing-Ke Shih 
3957e3ec7017SPing-Ke Shih struct rtw89_dpk_info {
3958e3ec7017SPing-Ke Shih 	bool is_dpk_enable;
3959e3ec7017SPing-Ke Shih 	bool is_dpk_reload_en;
39605b8471acSPing-Ke Shih 	u8 dpk_gs[RTW89_PHY_MAX];
3961da4cea16SPing-Ke Shih 	u16 dc_i[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
3962da4cea16SPing-Ke Shih 	u16 dc_q[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
3963da4cea16SPing-Ke Shih 	u8 corr_val[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
3964da4cea16SPing-Ke Shih 	u8 corr_idx[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
3965e3ec7017SPing-Ke Shih 	u8 cur_idx[RTW89_DPK_RF_PATH];
3966da4cea16SPing-Ke Shih 	u8 cur_k_set;
3967e3ec7017SPing-Ke Shih 	struct rtw89_dpk_bkup_para bp[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
3968e3ec7017SPing-Ke Shih };
3969e3ec7017SPing-Ke Shih 
3970e3ec7017SPing-Ke Shih struct rtw89_fem_info {
3971e3ec7017SPing-Ke Shih 	bool elna_2g;
3972e3ec7017SPing-Ke Shih 	bool elna_5g;
3973e3ec7017SPing-Ke Shih 	bool epa_2g;
3974e3ec7017SPing-Ke Shih 	bool epa_5g;
3975da4cea16SPing-Ke Shih 	bool epa_6g;
3976e3ec7017SPing-Ke Shih };
3977e3ec7017SPing-Ke Shih 
3978e3ec7017SPing-Ke Shih struct rtw89_phy_ch_info {
3979e3ec7017SPing-Ke Shih 	u8 rssi_min;
3980e3ec7017SPing-Ke Shih 	u16 rssi_min_macid;
3981e3ec7017SPing-Ke Shih 	u8 pre_rssi_min;
3982e3ec7017SPing-Ke Shih 	u8 rssi_max;
3983e3ec7017SPing-Ke Shih 	u16 rssi_max_macid;
3984e3ec7017SPing-Ke Shih 	u8 rxsc_160;
3985e3ec7017SPing-Ke Shih 	u8 rxsc_80;
3986e3ec7017SPing-Ke Shih 	u8 rxsc_40;
3987e3ec7017SPing-Ke Shih 	u8 rxsc_20;
3988e3ec7017SPing-Ke Shih 	u8 rxsc_l;
3989e3ec7017SPing-Ke Shih 	u8 is_noisy;
3990e3ec7017SPing-Ke Shih };
3991e3ec7017SPing-Ke Shih 
3992e3ec7017SPing-Ke Shih struct rtw89_agc_gaincode_set {
3993e3ec7017SPing-Ke Shih 	u8 lna_idx;
3994e3ec7017SPing-Ke Shih 	u8 tia_idx;
3995e3ec7017SPing-Ke Shih 	u8 rxb_idx;
3996e3ec7017SPing-Ke Shih };
3997e3ec7017SPing-Ke Shih 
3998e3ec7017SPing-Ke Shih #define IGI_RSSI_TH_NUM 5
3999e3ec7017SPing-Ke Shih #define FA_TH_NUM 4
4000e3ec7017SPing-Ke Shih #define LNA_GAIN_NUM 7
4001e3ec7017SPing-Ke Shih #define TIA_GAIN_NUM 2
4002e3ec7017SPing-Ke Shih struct rtw89_dig_info {
4003e3ec7017SPing-Ke Shih 	struct rtw89_agc_gaincode_set cur_gaincode;
4004e3ec7017SPing-Ke Shih 	bool force_gaincode_idx_en;
4005e3ec7017SPing-Ke Shih 	struct rtw89_agc_gaincode_set force_gaincode;
4006e3ec7017SPing-Ke Shih 	u8 igi_rssi_th[IGI_RSSI_TH_NUM];
4007e3ec7017SPing-Ke Shih 	u16 fa_th[FA_TH_NUM];
4008e3ec7017SPing-Ke Shih 	u8 igi_rssi;
4009e3ec7017SPing-Ke Shih 	u8 igi_fa_rssi;
4010e3ec7017SPing-Ke Shih 	u8 fa_rssi_ofst;
4011e3ec7017SPing-Ke Shih 	u8 dyn_igi_max;
4012e3ec7017SPing-Ke Shih 	u8 dyn_igi_min;
4013e3ec7017SPing-Ke Shih 	bool dyn_pd_th_en;
4014e3ec7017SPing-Ke Shih 	u8 dyn_pd_th_max;
4015e3ec7017SPing-Ke Shih 	u8 pd_low_th_ofst;
4016e3ec7017SPing-Ke Shih 	u8 ib_pbk;
4017e3ec7017SPing-Ke Shih 	s8 ib_pkpwr;
4018e3ec7017SPing-Ke Shih 	s8 lna_gain_a[LNA_GAIN_NUM];
4019e3ec7017SPing-Ke Shih 	s8 lna_gain_g[LNA_GAIN_NUM];
4020e3ec7017SPing-Ke Shih 	s8 *lna_gain;
4021e3ec7017SPing-Ke Shih 	s8 tia_gain_a[TIA_GAIN_NUM];
4022e3ec7017SPing-Ke Shih 	s8 tia_gain_g[TIA_GAIN_NUM];
4023e3ec7017SPing-Ke Shih 	s8 *tia_gain;
4024e3ec7017SPing-Ke Shih 	bool is_linked_pre;
4025e3ec7017SPing-Ke Shih 	bool bypass_dig;
4026e3ec7017SPing-Ke Shih };
4027e3ec7017SPing-Ke Shih 
4028e3ec7017SPing-Ke Shih enum rtw89_multi_cfo_mode {
4029e3ec7017SPing-Ke Shih 	RTW89_PKT_BASED_AVG_MODE = 0,
4030e3ec7017SPing-Ke Shih 	RTW89_ENTRY_BASED_AVG_MODE = 1,
4031e3ec7017SPing-Ke Shih 	RTW89_TP_BASED_AVG_MODE = 2,
4032e3ec7017SPing-Ke Shih };
4033e3ec7017SPing-Ke Shih 
4034e3ec7017SPing-Ke Shih enum rtw89_phy_cfo_status {
4035e3ec7017SPing-Ke Shih 	RTW89_PHY_DCFO_STATE_NORMAL = 0,
4036e3ec7017SPing-Ke Shih 	RTW89_PHY_DCFO_STATE_ENHANCE = 1,
4037bc013052SEric Huang 	RTW89_PHY_DCFO_STATE_HOLD = 2,
4038e3ec7017SPing-Ke Shih 	RTW89_PHY_DCFO_STATE_MAX
4039e3ec7017SPing-Ke Shih };
4040e3ec7017SPing-Ke Shih 
4041bc013052SEric Huang enum rtw89_phy_cfo_ul_ofdma_acc_mode {
4042bc013052SEric Huang 	RTW89_CFO_UL_OFDMA_ACC_DISABLE = 0,
4043bc013052SEric Huang 	RTW89_CFO_UL_OFDMA_ACC_ENABLE = 1
4044bc013052SEric Huang };
4045bc013052SEric Huang 
4046e3ec7017SPing-Ke Shih struct rtw89_cfo_tracking_info {
4047e3ec7017SPing-Ke Shih 	u16 cfo_timer_ms;
4048e3ec7017SPing-Ke Shih 	bool cfo_trig_by_timer_en;
4049e3ec7017SPing-Ke Shih 	enum rtw89_phy_cfo_status phy_cfo_status;
4050bc013052SEric Huang 	enum rtw89_phy_cfo_ul_ofdma_acc_mode cfo_ul_ofdma_acc_mode;
4051e3ec7017SPing-Ke Shih 	u8 phy_cfo_trk_cnt;
4052e3ec7017SPing-Ke Shih 	bool is_adjust;
4053e3ec7017SPing-Ke Shih 	enum rtw89_multi_cfo_mode rtw89_multi_cfo_mode;
4054e3ec7017SPing-Ke Shih 	bool apply_compensation;
4055e3ec7017SPing-Ke Shih 	u8 crystal_cap;
4056e3ec7017SPing-Ke Shih 	u8 crystal_cap_default;
4057e3ec7017SPing-Ke Shih 	u8 def_x_cap;
4058e3ec7017SPing-Ke Shih 	s8 x_cap_ofst;
4059e3ec7017SPing-Ke Shih 	u32 sta_cfo_tolerance;
4060e3ec7017SPing-Ke Shih 	s32 cfo_tail[CFO_TRACK_MAX_USER];
4061e3ec7017SPing-Ke Shih 	u16 cfo_cnt[CFO_TRACK_MAX_USER];
4062e3ec7017SPing-Ke Shih 	s32 cfo_avg_pre;
4063e3ec7017SPing-Ke Shih 	s32 cfo_avg[CFO_TRACK_MAX_USER];
4064e3ec7017SPing-Ke Shih 	s32 pre_cfo_avg[CFO_TRACK_MAX_USER];
40659f9882dbSEric Huang 	s32 dcfo_avg;
40669f9882dbSEric Huang 	s32 dcfo_avg_pre;
4067e3ec7017SPing-Ke Shih 	u32 packet_count;
4068e3ec7017SPing-Ke Shih 	u32 packet_count_pre;
4069e3ec7017SPing-Ke Shih 	s32 residual_cfo_acc;
4070e3ec7017SPing-Ke Shih 	u8 phy_cfotrk_state;
4071e3ec7017SPing-Ke Shih 	u8 phy_cfotrk_cnt;
4072a9e06f2eSYi-Tang Chiu 	bool divergence_lock_en;
4073a9e06f2eSYi-Tang Chiu 	u8 x_cap_lb;
4074a9e06f2eSYi-Tang Chiu 	u8 x_cap_ub;
4075a9e06f2eSYi-Tang Chiu 	u8 lock_cnt;
4076e3ec7017SPing-Ke Shih };
4077e3ec7017SPing-Ke Shih 
40787f18a70dSPing-Ke Shih enum rtw89_tssi_alimk_band {
40797f18a70dSPing-Ke Shih 	TSSI_ALIMK_2G = 0,
40807f18a70dSPing-Ke Shih 	TSSI_ALIMK_5GL,
40817f18a70dSPing-Ke Shih 	TSSI_ALIMK_5GM,
40827f18a70dSPing-Ke Shih 	TSSI_ALIMK_5GH,
40837f18a70dSPing-Ke Shih 	TSSI_ALIMK_MAX
40847f18a70dSPing-Ke Shih };
40857f18a70dSPing-Ke Shih 
4086e3ec7017SPing-Ke Shih /* 2GL, 2GH, 5GL1, 5GH1, 5GM1, 5GM2, 5GH1, 5GH2 */
4087e3ec7017SPing-Ke Shih #define TSSI_TRIM_CH_GROUP_NUM 8
4088a82174c6SPing-Ke Shih #define TSSI_TRIM_CH_GROUP_NUM_6G 16
4089e3ec7017SPing-Ke Shih 
4090e3ec7017SPing-Ke Shih #define TSSI_CCK_CH_GROUP_NUM 6
4091e3ec7017SPing-Ke Shih #define TSSI_MCS_2G_CH_GROUP_NUM 5
4092e3ec7017SPing-Ke Shih #define TSSI_MCS_5G_CH_GROUP_NUM 14
4093a82174c6SPing-Ke Shih #define TSSI_MCS_6G_CH_GROUP_NUM 32
4094e3ec7017SPing-Ke Shih #define TSSI_MCS_CH_GROUP_NUM \
4095e3ec7017SPing-Ke Shih 	(TSSI_MCS_2G_CH_GROUP_NUM + TSSI_MCS_5G_CH_GROUP_NUM)
40967f18a70dSPing-Ke Shih #define TSSI_MAX_CH_NUM 67
40977f18a70dSPing-Ke Shih #define TSSI_ALIMK_VALUE_NUM 8
4098e3ec7017SPing-Ke Shih 
4099e3ec7017SPing-Ke Shih struct rtw89_tssi_info {
4100e3ec7017SPing-Ke Shih 	u8 thermal[RF_PATH_MAX];
4101e3ec7017SPing-Ke Shih 	s8 tssi_trim[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM];
4102a82174c6SPing-Ke Shih 	s8 tssi_trim_6g[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM_6G];
4103e3ec7017SPing-Ke Shih 	s8 tssi_cck[RF_PATH_MAX][TSSI_CCK_CH_GROUP_NUM];
4104e3ec7017SPing-Ke Shih 	s8 tssi_mcs[RF_PATH_MAX][TSSI_MCS_CH_GROUP_NUM];
4105a82174c6SPing-Ke Shih 	s8 tssi_6g_mcs[RF_PATH_MAX][TSSI_MCS_6G_CH_GROUP_NUM];
4106e3ec7017SPing-Ke Shih 	s8 extra_ofst[RF_PATH_MAX];
4107e3ec7017SPing-Ke Shih 	bool tssi_tracking_check[RF_PATH_MAX];
4108e3ec7017SPing-Ke Shih 	u8 default_txagc_offset[RF_PATH_MAX];
4109e3ec7017SPing-Ke Shih 	u32 base_thermal[RF_PATH_MAX];
41107f18a70dSPing-Ke Shih 	bool check_backup_aligmk[RF_PATH_MAX][TSSI_MAX_CH_NUM];
41117f18a70dSPing-Ke Shih 	u32 alignment_backup_by_ch[RF_PATH_MAX][TSSI_MAX_CH_NUM][TSSI_ALIMK_VALUE_NUM];
41127f18a70dSPing-Ke Shih 	u32 alignment_value[RF_PATH_MAX][TSSI_ALIMK_MAX][TSSI_ALIMK_VALUE_NUM];
41137f18a70dSPing-Ke Shih 	bool alignment_done[RF_PATH_MAX][TSSI_ALIMK_MAX];
41147f18a70dSPing-Ke Shih 	u32 tssi_alimk_time;
4115e3ec7017SPing-Ke Shih };
4116e3ec7017SPing-Ke Shih 
4117e3ec7017SPing-Ke Shih struct rtw89_power_trim_info {
4118e3ec7017SPing-Ke Shih 	bool pg_thermal_trim;
4119e3ec7017SPing-Ke Shih 	bool pg_pa_bias_trim;
4120e3ec7017SPing-Ke Shih 	u8 thermal_trim[RF_PATH_MAX];
4121e3ec7017SPing-Ke Shih 	u8 pa_bias_trim[RF_PATH_MAX];
4122e3ec7017SPing-Ke Shih };
4123e3ec7017SPing-Ke Shih 
4124f6baa1d3SZong-Zhe Yang struct rtw89_regd {
4125e3ec7017SPing-Ke Shih 	char alpha2[3];
4126b4a283fbSZong-Zhe Yang 	u8 txpwr_regd[RTW89_BAND_NUM];
4127e3ec7017SPing-Ke Shih };
4128e3ec7017SPing-Ke Shih 
4129f6baa1d3SZong-Zhe Yang struct rtw89_regulatory_info {
4130f6baa1d3SZong-Zhe Yang 	const struct rtw89_regd *regd;
4131f6baa1d3SZong-Zhe Yang 	enum rtw89_reg_6ghz_power reg_6ghz_power;
4132f6baa1d3SZong-Zhe Yang };
4133f6baa1d3SZong-Zhe Yang 
4134e3ec7017SPing-Ke Shih enum rtw89_ifs_clm_application {
4135e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_INIT = 0,
4136e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_BACKGROUND = 1,
4137e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_ACS = 2,
4138e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_DIG = 3,
4139e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_TDMA_DIG = 4,
4140e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_DBG = 5,
4141e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_DBG_MANUAL = 6
4142e3ec7017SPing-Ke Shih };
4143e3ec7017SPing-Ke Shih 
4144e3ec7017SPing-Ke Shih enum rtw89_env_racing_lv {
4145e3ec7017SPing-Ke Shih 	RTW89_RAC_RELEASE = 0,
4146e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_1 = 1,
4147e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_2 = 2,
4148e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_3 = 3,
4149e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_4 = 4,
4150e3ec7017SPing-Ke Shih 	RTW89_RAC_MAX_NUM = 5
4151e3ec7017SPing-Ke Shih };
4152e3ec7017SPing-Ke Shih 
4153e3ec7017SPing-Ke Shih struct rtw89_ccx_para_info {
4154e3ec7017SPing-Ke Shih 	enum rtw89_env_racing_lv rac_lv;
4155e3ec7017SPing-Ke Shih 	u16 mntr_time;
4156e3ec7017SPing-Ke Shih 	u8 nhm_manual_th_ofst;
4157e3ec7017SPing-Ke Shih 	u8 nhm_manual_th0;
4158e3ec7017SPing-Ke Shih 	enum rtw89_ifs_clm_application ifs_clm_app;
4159e3ec7017SPing-Ke Shih 	u32 ifs_clm_manual_th_times;
4160e3ec7017SPing-Ke Shih 	u32 ifs_clm_manual_th0;
4161e3ec7017SPing-Ke Shih 	u8 fahm_manual_th_ofst;
4162e3ec7017SPing-Ke Shih 	u8 fahm_manual_th0;
4163e3ec7017SPing-Ke Shih 	u8 fahm_numer_opt;
4164e3ec7017SPing-Ke Shih 	u8 fahm_denom_opt;
4165e3ec7017SPing-Ke Shih };
4166e3ec7017SPing-Ke Shih 
4167e3ec7017SPing-Ke Shih enum rtw89_ccx_edcca_opt_sc_idx {
4168e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_P0 = 0,
4169e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_S1 = 1,
4170e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_S2 = 2,
4171e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_S3 = 3,
4172e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_P0 = 4,
4173e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_S1 = 5,
4174e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_S2 = 6,
4175e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_S3 = 7
4176e3ec7017SPing-Ke Shih };
4177e3ec7017SPing-Ke Shih 
4178e3ec7017SPing-Ke Shih enum rtw89_ccx_edcca_opt_bw_idx {
4179e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_0 = 0,
4180e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_1 = 1,
4181e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_2 = 2,
4182e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_3 = 3,
4183e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_4 = 4,
4184e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_5 = 5,
4185e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_6 = 6,
4186e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_7 = 7
4187e3ec7017SPing-Ke Shih };
4188e3ec7017SPing-Ke Shih 
4189e3ec7017SPing-Ke Shih #define RTW89_NHM_TH_NUM 11
4190e3ec7017SPing-Ke Shih #define RTW89_FAHM_TH_NUM 11
4191e3ec7017SPing-Ke Shih #define RTW89_NHM_RPT_NUM 12
4192e3ec7017SPing-Ke Shih #define RTW89_FAHM_RPT_NUM 12
4193e3ec7017SPing-Ke Shih #define RTW89_IFS_CLM_NUM 4
4194e3ec7017SPing-Ke Shih struct rtw89_env_monitor_info {
4195e3ec7017SPing-Ke Shih 	u8 ccx_watchdog_result;
4196e3ec7017SPing-Ke Shih 	bool ccx_ongoing;
4197e3ec7017SPing-Ke Shih 	u8 ccx_rac_lv;
4198e3ec7017SPing-Ke Shih 	bool ccx_manual_ctrl;
4199e3ec7017SPing-Ke Shih 	u16 ifs_clm_mntr_time;
4200e3ec7017SPing-Ke Shih 	enum rtw89_ifs_clm_application ifs_clm_app;
4201e3ec7017SPing-Ke Shih 	u16 ccx_period;
4202e3ec7017SPing-Ke Shih 	u8 ccx_unit_idx;
4203e3ec7017SPing-Ke Shih 	u16 ifs_clm_th_l[RTW89_IFS_CLM_NUM];
4204e3ec7017SPing-Ke Shih 	u16 ifs_clm_th_h[RTW89_IFS_CLM_NUM];
4205e3ec7017SPing-Ke Shih 	u16 ifs_clm_tx;
4206e3ec7017SPing-Ke Shih 	u16 ifs_clm_edcca_excl_cca;
4207e3ec7017SPing-Ke Shih 	u16 ifs_clm_ofdmfa;
4208e3ec7017SPing-Ke Shih 	u16 ifs_clm_ofdmcca_excl_fa;
4209e3ec7017SPing-Ke Shih 	u16 ifs_clm_cckfa;
4210e3ec7017SPing-Ke Shih 	u16 ifs_clm_cckcca_excl_fa;
4211e3ec7017SPing-Ke Shih 	u16 ifs_clm_total_ifs;
4212e3ec7017SPing-Ke Shih 	u8 ifs_clm_his[RTW89_IFS_CLM_NUM];
4213e3ec7017SPing-Ke Shih 	u16 ifs_clm_avg[RTW89_IFS_CLM_NUM];
4214e3ec7017SPing-Ke Shih 	u16 ifs_clm_cca[RTW89_IFS_CLM_NUM];
4215e3ec7017SPing-Ke Shih 	u8 ifs_clm_tx_ratio;
4216e3ec7017SPing-Ke Shih 	u8 ifs_clm_edcca_excl_cca_ratio;
4217e3ec7017SPing-Ke Shih 	u8 ifs_clm_cck_fa_ratio;
4218e3ec7017SPing-Ke Shih 	u8 ifs_clm_ofdm_fa_ratio;
4219e3ec7017SPing-Ke Shih 	u8 ifs_clm_cck_cca_excl_fa_ratio;
4220e3ec7017SPing-Ke Shih 	u8 ifs_clm_ofdm_cca_excl_fa_ratio;
4221e3ec7017SPing-Ke Shih 	u16 ifs_clm_cck_fa_permil;
4222e3ec7017SPing-Ke Shih 	u16 ifs_clm_ofdm_fa_permil;
4223e3ec7017SPing-Ke Shih 	u32 ifs_clm_ifs_avg[RTW89_IFS_CLM_NUM];
4224e3ec7017SPing-Ke Shih 	u32 ifs_clm_cca_avg[RTW89_IFS_CLM_NUM];
4225e3ec7017SPing-Ke Shih };
4226e3ec7017SPing-Ke Shih 
4227e3ec7017SPing-Ke Shih enum rtw89_ser_rcvy_step {
4228e3ec7017SPing-Ke Shih 	RTW89_SER_DRV_STOP_TX,
4229e3ec7017SPing-Ke Shih 	RTW89_SER_DRV_STOP_RX,
4230e3ec7017SPing-Ke Shih 	RTW89_SER_DRV_STOP_RUN,
4231e3ec7017SPing-Ke Shih 	RTW89_SER_HAL_STOP_DMA,
42328130e94eSChin-Yen Lee 	RTW89_SER_SUPPRESS_LOG,
4233e3ec7017SPing-Ke Shih 	RTW89_NUM_OF_SER_FLAGS
4234e3ec7017SPing-Ke Shih };
4235e3ec7017SPing-Ke Shih 
4236e3ec7017SPing-Ke Shih struct rtw89_ser {
4237e3ec7017SPing-Ke Shih 	u8 state;
4238e3ec7017SPing-Ke Shih 	u8 alarm_event;
423956617fd0SZong-Zhe Yang 	bool prehandle_l1;
4240e3ec7017SPing-Ke Shih 
4241e3ec7017SPing-Ke Shih 	struct work_struct ser_hdl_work;
4242e3ec7017SPing-Ke Shih 	struct delayed_work ser_alarm_work;
4243af5175acSJoe Perches 	const struct state_ent *st_tbl;
4244af5175acSJoe Perches 	const struct event_ent *ev_tbl;
4245e3ec7017SPing-Ke Shih 	struct list_head msg_q;
4246e3ec7017SPing-Ke Shih 	spinlock_t msg_q_lock; /* lock when read/write ser msg */
4247e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(flags, RTW89_NUM_OF_SER_FLAGS);
4248e3ec7017SPing-Ke Shih };
4249e3ec7017SPing-Ke Shih 
4250e3ec7017SPing-Ke Shih enum rtw89_mac_ax_ps_mode {
4251e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_ACTIVE = 0,
4252e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_LEGACY = 1,
4253e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_WMMPS  = 2,
4254e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_MAX    = 3,
4255e3ec7017SPing-Ke Shih };
4256e3ec7017SPing-Ke Shih 
4257e3ec7017SPing-Ke Shih enum rtw89_last_rpwm_mode {
4258e3ec7017SPing-Ke Shih 	RTW89_LAST_RPWM_PS        = 0x0,
4259e3ec7017SPing-Ke Shih 	RTW89_LAST_RPWM_ACTIVE    = 0x6,
4260e3ec7017SPing-Ke Shih };
4261e3ec7017SPing-Ke Shih 
4262e3ec7017SPing-Ke Shih struct rtw89_lps_parm {
4263e3ec7017SPing-Ke Shih 	u8 macid;
4264e3ec7017SPing-Ke Shih 	u8 psmode; /* enum rtw89_mac_ax_ps_mode */
4265e3ec7017SPing-Ke Shih 	u8 lastrpwm; /* enum rtw89_last_rpwm_mode */
4266e3ec7017SPing-Ke Shih };
4267e3ec7017SPing-Ke Shih 
4268e3ec7017SPing-Ke Shih struct rtw89_ppdu_sts_info {
4269e3ec7017SPing-Ke Shih 	struct sk_buff_head rx_queue[RTW89_PHY_MAX];
4270e3ec7017SPing-Ke Shih 	u8 curr_rx_ppdu_cnt[RTW89_PHY_MAX];
4271e3ec7017SPing-Ke Shih };
4272e3ec7017SPing-Ke Shih 
4273e3ec7017SPing-Ke Shih struct rtw89_early_h2c {
4274e3ec7017SPing-Ke Shih 	struct list_head list;
4275e3ec7017SPing-Ke Shih 	u8 *h2c;
4276e3ec7017SPing-Ke Shih 	u16 h2c_len;
4277e3ec7017SPing-Ke Shih };
4278e3ec7017SPing-Ke Shih 
427989590777SPo Hao Huang struct rtw89_hw_scan_info {
428089590777SPo Hao Huang 	struct ieee80211_vif *scanning_vif;
428189590777SPo Hao Huang 	struct list_head pkt_list[NUM_NL80211_BANDS];
4282e7399db2SPo-Hao Huang 	struct rtw89_chan op_chan;
4283bd1056d4SPo-Hao Huang 	u32 last_chan_idx;
428489590777SPo Hao Huang };
428589590777SPo Hao Huang 
4286e885871eSZong-Zhe Yang enum rtw89_phy_bb_gain_band {
4287e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_2G = 0,
4288e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_5G_L = 1,
4289e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_5G_M = 2,
4290e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_5G_H = 3,
4291e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_L = 4,
4292e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_M = 5,
4293e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_H = 6,
4294e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_UH = 7,
4295e885871eSZong-Zhe Yang 
4296e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_NR,
4297e885871eSZong-Zhe Yang };
4298e885871eSZong-Zhe Yang 
4299e885871eSZong-Zhe Yang enum rtw89_phy_bb_rxsc_num {
4300e885871eSZong-Zhe Yang 	RTW89_BB_RXSC_NUM_40 = 9, /* SC: 0, 1~8 */
4301e885871eSZong-Zhe Yang 	RTW89_BB_RXSC_NUM_80 = 13, /* SC: 0, 1~8, 9~12 */
4302e885871eSZong-Zhe Yang 	RTW89_BB_RXSC_NUM_160 = 15, /* SC: 0, 1~8, 9~12, 13~14 */
4303e885871eSZong-Zhe Yang };
4304e885871eSZong-Zhe Yang 
4305e885871eSZong-Zhe Yang struct rtw89_phy_bb_gain_info {
4306e885871eSZong-Zhe Yang 	s8 lna_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
4307e885871eSZong-Zhe Yang 	s8 tia_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][TIA_GAIN_NUM];
4308e885871eSZong-Zhe Yang 	s8 lna_gain_bypass[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
4309e885871eSZong-Zhe Yang 	s8 lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
4310e885871eSZong-Zhe Yang 	s8 tia_lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
4311e885871eSZong-Zhe Yang 			[LNA_GAIN_NUM + 1]; /* TIA0_LNA0~6 + TIA1_LNA6 */
4312e885871eSZong-Zhe Yang 	s8 rpl_ofst_20[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX];
4313e885871eSZong-Zhe Yang 	s8 rpl_ofst_40[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
4314e885871eSZong-Zhe Yang 		      [RTW89_BB_RXSC_NUM_40];
4315e885871eSZong-Zhe Yang 	s8 rpl_ofst_80[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
4316e885871eSZong-Zhe Yang 		      [RTW89_BB_RXSC_NUM_80];
4317e885871eSZong-Zhe Yang 	s8 rpl_ofst_160[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
4318e885871eSZong-Zhe Yang 		       [RTW89_BB_RXSC_NUM_160];
4319e885871eSZong-Zhe Yang };
4320e885871eSZong-Zhe Yang 
4321e6b17cbdSPing-Ke Shih struct rtw89_phy_efuse_gain {
4322e6b17cbdSPing-Ke Shih 	bool offset_valid;
4323134cf7c0SPing-Ke Shih 	bool comp_valid;
4324e6b17cbdSPing-Ke Shih 	s8 offset[RF_PATH_MAX][RTW89_GAIN_OFFSET_NR]; /* S(8, 0) */
4325e6b17cbdSPing-Ke Shih 	s8 offset_base[RTW89_PHY_MAX]; /* S(8, 4) */
43266b069898SPing-Ke Shih 	s8 rssi_base[RTW89_PHY_MAX]; /* S(8, 4) */
4327134cf7c0SPing-Ke Shih 	s8 comp[RF_PATH_MAX][RTW89_SUBBAND_NR]; /* S(8, 0) */
4328e6b17cbdSPing-Ke Shih };
4329e6b17cbdSPing-Ke Shih 
4330d2b68e95SChin-Yen Lee #define RTW89_MAX_PATTERN_NUM             18
4331d2b68e95SChin-Yen Lee #define RTW89_MAX_PATTERN_MASK_SIZE       4
4332d2b68e95SChin-Yen Lee #define RTW89_MAX_PATTERN_SIZE            128
4333d2b68e95SChin-Yen Lee 
4334d2b68e95SChin-Yen Lee struct rtw89_wow_cam_info {
4335d2b68e95SChin-Yen Lee 	bool r_w;
4336d2b68e95SChin-Yen Lee 	u8 idx;
4337d2b68e95SChin-Yen Lee 	u32 mask[RTW89_MAX_PATTERN_MASK_SIZE];
4338d2b68e95SChin-Yen Lee 	u16 crc;
4339d2b68e95SChin-Yen Lee 	bool negative_pattern_match;
4340d2b68e95SChin-Yen Lee 	bool skip_mac_hdr;
4341d2b68e95SChin-Yen Lee 	bool uc;
4342d2b68e95SChin-Yen Lee 	bool mc;
4343d2b68e95SChin-Yen Lee 	bool bc;
4344d2b68e95SChin-Yen Lee 	bool valid;
4345d2b68e95SChin-Yen Lee };
4346d2b68e95SChin-Yen Lee 
4347ee88d748SChin-Yen Lee struct rtw89_wow_param {
4348ee88d748SChin-Yen Lee 	struct ieee80211_vif *wow_vif;
4349ee88d748SChin-Yen Lee 	DECLARE_BITMAP(flags, RTW89_WOW_FLAG_NUM);
4350d2b68e95SChin-Yen Lee 	struct rtw89_wow_cam_info patterns[RTW89_MAX_PATTERN_NUM];
4351ee88d748SChin-Yen Lee 	u8 pattern_cnt;
4352ee88d748SChin-Yen Lee };
4353ee88d748SChin-Yen Lee 
4354ef9dff4cSZong-Zhe Yang struct rtw89_mcc_info {
4355ef9dff4cSZong-Zhe Yang 	struct rtw89_wait_info wait;
4356ef9dff4cSZong-Zhe Yang };
4357ef9dff4cSZong-Zhe Yang 
4358e3ec7017SPing-Ke Shih struct rtw89_dev {
4359e3ec7017SPing-Ke Shih 	struct ieee80211_hw *hw;
4360e3ec7017SPing-Ke Shih 	struct device *dev;
43617fc06a07SZong-Zhe Yang 	const struct ieee80211_ops *ops;
4362e3ec7017SPing-Ke Shih 
4363e3ec7017SPing-Ke Shih 	bool dbcc_en;
436489590777SPo Hao Huang 	struct rtw89_hw_scan_info scan_info;
4365e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip;
43664a9e48acSPing-Ke Shih 	const struct rtw89_pci_info *pci_info;
43675395482aSZong-Zhe Yang 	const struct rtw89_rfe_parms *rfe_parms;
4368e3ec7017SPing-Ke Shih 	struct rtw89_hal hal;
4369ef9dff4cSZong-Zhe Yang 	struct rtw89_mcc_info mcc;
4370e3ec7017SPing-Ke Shih 	struct rtw89_mac_info mac;
4371e3ec7017SPing-Ke Shih 	struct rtw89_fw_info fw;
4372e3ec7017SPing-Ke Shih 	struct rtw89_hci_info hci;
4373e3ec7017SPing-Ke Shih 	struct rtw89_efuse efuse;
4374e3ec7017SPing-Ke Shih 	struct rtw89_traffic_stats stats;
4375e3ec7017SPing-Ke Shih 
4376e3ec7017SPing-Ke Shih 	/* ensures exclusive access from mac80211 callbacks */
4377e3ec7017SPing-Ke Shih 	struct mutex mutex;
4378e3ec7017SPing-Ke Shih 	struct list_head rtwvifs_list;
4379e3ec7017SPing-Ke Shih 	/* used to protect rf read write */
4380e3ec7017SPing-Ke Shih 	struct mutex rf_mutex;
4381e3ec7017SPing-Ke Shih 	struct workqueue_struct *txq_wq;
4382e3ec7017SPing-Ke Shih 	struct work_struct txq_work;
4383e3ec7017SPing-Ke Shih 	struct delayed_work txq_reinvoke_work;
4384679955d5SKuan-Chung Chen 	/* used to protect ba_list and forbid_ba_list */
4385e3ec7017SPing-Ke Shih 	spinlock_t ba_lock;
4386e3ec7017SPing-Ke Shih 	/* txqs to setup ba session */
4387e3ec7017SPing-Ke Shih 	struct list_head ba_list;
4388679955d5SKuan-Chung Chen 	/* txqs to forbid ba session */
4389679955d5SKuan-Chung Chen 	struct list_head forbid_ba_list;
4390e3ec7017SPing-Ke Shih 	struct work_struct ba_work;
43917bfd05ffSChin-Yen Lee 	/* used to protect rpwm */
43927bfd05ffSChin-Yen Lee 	spinlock_t rpwm_lock;
4393e3ec7017SPing-Ke Shih 
4394e3ec7017SPing-Ke Shih 	struct rtw89_cam_info cam_info;
4395e3ec7017SPing-Ke Shih 
4396e3ec7017SPing-Ke Shih 	struct sk_buff_head c2h_queue;
4397e3ec7017SPing-Ke Shih 	struct work_struct c2h_work;
439889590777SPo Hao Huang 	struct work_struct ips_work;
4399b80ad23aSPing-Ke Shih 	struct work_struct load_firmware_work;
44003ea1cd8dSZong-Zhe Yang 	struct work_struct cancel_6ghz_probe_work;
4401e3ec7017SPing-Ke Shih 
4402e3ec7017SPing-Ke Shih 	struct list_head early_h2c_list;
4403e3ec7017SPing-Ke Shih 
4404e3ec7017SPing-Ke Shih 	struct rtw89_ser ser;
4405e3ec7017SPing-Ke Shih 
440620d9fc88SPing-Ke Shih 	DECLARE_BITMAP(hw_port, RTW89_PORT_NUM);
4407e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(mac_id_map, RTW89_MAX_MAC_ID_NUM);
4408e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(flags, NUM_OF_RTW89_FLAGS);
440989590777SPo Hao Huang 	DECLARE_BITMAP(pkt_offload, RTW89_MAX_PKT_OFLD_NUM);
4410e3ec7017SPing-Ke Shih 
4411e3ec7017SPing-Ke Shih 	struct rtw89_phy_stat phystat;
4412e3ec7017SPing-Ke Shih 	struct rtw89_dack_info dack;
4413e3ec7017SPing-Ke Shih 	struct rtw89_iqk_info iqk;
4414e3ec7017SPing-Ke Shih 	struct rtw89_dpk_info dpk;
441538f25decSZong-Zhe Yang 	struct rtw89_rfk_mcc_info rfk_mcc;
4416fb8177d7SPing-Ke Shih 	struct rtw89_lck_info lck;
4417e3d365ffSPing-Ke Shih 	struct rtw89_rx_dck_info rx_dck;
4418e3ec7017SPing-Ke Shih 	bool is_tssi_mode[RF_PATH_MAX];
4419e3ec7017SPing-Ke Shih 	bool is_bt_iqk_timeout;
4420e3ec7017SPing-Ke Shih 
4421e3ec7017SPing-Ke Shih 	struct rtw89_fem_info fem;
4422b4a283fbSZong-Zhe Yang 	struct rtw89_txpwr_byrate byr[RTW89_BAND_NUM];
4423e3ec7017SPing-Ke Shih 	struct rtw89_tssi_info tssi;
4424e3ec7017SPing-Ke Shih 	struct rtw89_power_trim_info pwr_trim;
4425e3ec7017SPing-Ke Shih 
4426e3ec7017SPing-Ke Shih 	struct rtw89_cfo_tracking_info cfo_tracking;
4427e3ec7017SPing-Ke Shih 	struct rtw89_env_monitor_info env_monitor;
4428e3ec7017SPing-Ke Shih 	struct rtw89_dig_info dig;
4429e3ec7017SPing-Ke Shih 	struct rtw89_phy_ch_info ch_info;
4430e885871eSZong-Zhe Yang 	struct rtw89_phy_bb_gain_info bb_gain;
4431e6b17cbdSPing-Ke Shih 	struct rtw89_phy_efuse_gain efuse_gain;
443229136c95SEric Huang 	struct rtw89_phy_ul_tb_info ul_tb_info;
4433e3715859SEric Huang 	struct rtw89_antdiv_info antdiv;
4434e885871eSZong-Zhe Yang 
4435e3ec7017SPing-Ke Shih 	struct delayed_work track_work;
44364843aa37SZong-Zhe Yang 	struct delayed_work chanctx_work;
4437e3ec7017SPing-Ke Shih 	struct delayed_work coex_act1_work;
4438e3ec7017SPing-Ke Shih 	struct delayed_work coex_bt_devinfo_work;
4439e3ec7017SPing-Ke Shih 	struct delayed_work coex_rfk_chk_work;
4440e3ec7017SPing-Ke Shih 	struct delayed_work cfo_track_work;
4441679955d5SKuan-Chung Chen 	struct delayed_work forbid_ba_work;
4442a0e97ae3SPo-Hao Huang 	struct delayed_work roc_work;
4443e3715859SEric Huang 	struct delayed_work antdiv_work;
4444e3ec7017SPing-Ke Shih 	struct rtw89_ppdu_sts_info ppdu_sts;
4445e3ec7017SPing-Ke Shih 	u8 total_sta_assoc;
4446e3ec7017SPing-Ke Shih 	bool scanning;
4447e3ec7017SPing-Ke Shih 
4448f6baa1d3SZong-Zhe Yang 	struct rtw89_regulatory_info regulatory;
4449e3ec7017SPing-Ke Shih 	struct rtw89_sar_info sar;
4450eb2624f5SKuan-Chung Chen 	struct rtw89_tas_info tas;
4451e3ec7017SPing-Ke Shih 
4452e3ec7017SPing-Ke Shih 	struct rtw89_btc btc;
4453e3ec7017SPing-Ke Shih 	enum rtw89_ps_mode ps_mode;
4454e3ec7017SPing-Ke Shih 	bool lps_enabled;
4455e3ec7017SPing-Ke Shih 
4456ee88d748SChin-Yen Lee 	struct rtw89_wow_param wow;
4457ee88d748SChin-Yen Lee 
4458e3ec7017SPing-Ke Shih 	/* napi structure */
4459e3ec7017SPing-Ke Shih 	struct net_device netdev;
4460e3ec7017SPing-Ke Shih 	struct napi_struct napi;
4461e3ec7017SPing-Ke Shih 	int napi_budget_countdown;
4462e3ec7017SPing-Ke Shih 
4463e3ec7017SPing-Ke Shih 	/* HCI related data, keep last */
44642e2f63a1SGustavo A. R. Silva 	u8 priv[] __aligned(sizeof(void *));
4465e3ec7017SPing-Ke Shih };
4466e3ec7017SPing-Ke Shih 
rtw89_hci_tx_write(struct rtw89_dev * rtwdev,struct rtw89_core_tx_request * tx_req)4467e3ec7017SPing-Ke Shih static inline int rtw89_hci_tx_write(struct rtw89_dev *rtwdev,
4468e3ec7017SPing-Ke Shih 				     struct rtw89_core_tx_request *tx_req)
4469e3ec7017SPing-Ke Shih {
4470e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->tx_write(rtwdev, tx_req);
4471e3ec7017SPing-Ke Shih }
4472e3ec7017SPing-Ke Shih 
rtw89_hci_reset(struct rtw89_dev * rtwdev)4473e3ec7017SPing-Ke Shih static inline void rtw89_hci_reset(struct rtw89_dev *rtwdev)
4474e3ec7017SPing-Ke Shih {
4475e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->reset(rtwdev);
4476e3ec7017SPing-Ke Shih }
4477e3ec7017SPing-Ke Shih 
rtw89_hci_start(struct rtw89_dev * rtwdev)4478e3ec7017SPing-Ke Shih static inline int rtw89_hci_start(struct rtw89_dev *rtwdev)
4479e3ec7017SPing-Ke Shih {
4480e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->start(rtwdev);
4481e3ec7017SPing-Ke Shih }
4482e3ec7017SPing-Ke Shih 
rtw89_hci_stop(struct rtw89_dev * rtwdev)4483e3ec7017SPing-Ke Shih static inline void rtw89_hci_stop(struct rtw89_dev *rtwdev)
4484e3ec7017SPing-Ke Shih {
4485e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->stop(rtwdev);
4486e3ec7017SPing-Ke Shih }
4487e3ec7017SPing-Ke Shih 
rtw89_hci_deinit(struct rtw89_dev * rtwdev)4488e3ec7017SPing-Ke Shih static inline int rtw89_hci_deinit(struct rtw89_dev *rtwdev)
4489e3ec7017SPing-Ke Shih {
4490e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->deinit(rtwdev);
4491e3ec7017SPing-Ke Shih }
4492e3ec7017SPing-Ke Shih 
rtw89_hci_pause(struct rtw89_dev * rtwdev,bool pause)449352edbb9fSPing-Ke Shih static inline void rtw89_hci_pause(struct rtw89_dev *rtwdev, bool pause)
449452edbb9fSPing-Ke Shih {
449552edbb9fSPing-Ke Shih 	rtwdev->hci.ops->pause(rtwdev, pause);
449652edbb9fSPing-Ke Shih }
449752edbb9fSPing-Ke Shih 
rtw89_hci_switch_mode(struct rtw89_dev * rtwdev,bool low_power)449852edbb9fSPing-Ke Shih static inline void rtw89_hci_switch_mode(struct rtw89_dev *rtwdev, bool low_power)
449952edbb9fSPing-Ke Shih {
450052edbb9fSPing-Ke Shih 	rtwdev->hci.ops->switch_mode(rtwdev, low_power);
450152edbb9fSPing-Ke Shih }
450252edbb9fSPing-Ke Shih 
rtw89_hci_recalc_int_mit(struct rtw89_dev * rtwdev)4503e3ec7017SPing-Ke Shih static inline void rtw89_hci_recalc_int_mit(struct rtw89_dev *rtwdev)
4504e3ec7017SPing-Ke Shih {
4505e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->recalc_int_mit(rtwdev);
4506e3ec7017SPing-Ke Shih }
4507e3ec7017SPing-Ke Shih 
rtw89_hci_check_and_reclaim_tx_resource(struct rtw89_dev * rtwdev,u8 txch)4508e3ec7017SPing-Ke Shih static inline u32 rtw89_hci_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev, u8 txch)
4509e3ec7017SPing-Ke Shih {
4510e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->check_and_reclaim_tx_resource(rtwdev, txch);
4511e3ec7017SPing-Ke Shih }
4512e3ec7017SPing-Ke Shih 
rtw89_hci_tx_kick_off(struct rtw89_dev * rtwdev,u8 txch)4513e3ec7017SPing-Ke Shih static inline void rtw89_hci_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)
4514e3ec7017SPing-Ke Shih {
4515e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->tx_kick_off(rtwdev, txch);
4516e3ec7017SPing-Ke Shih }
4517e3ec7017SPing-Ke Shih 
rtw89_hci_flush_queues(struct rtw89_dev * rtwdev,u32 queues,bool drop)4518e3ec7017SPing-Ke Shih static inline void rtw89_hci_flush_queues(struct rtw89_dev *rtwdev, u32 queues,
4519e3ec7017SPing-Ke Shih 					  bool drop)
4520e3ec7017SPing-Ke Shih {
4521fc5f311fSPing-Ke Shih 	if (!test_bit(RTW89_FLAG_POWERON, rtwdev->flags))
4522fc5f311fSPing-Ke Shih 		return;
4523fc5f311fSPing-Ke Shih 
4524e3ec7017SPing-Ke Shih 	if (rtwdev->hci.ops->flush_queues)
4525e3ec7017SPing-Ke Shih 		return rtwdev->hci.ops->flush_queues(rtwdev, queues, drop);
4526e3ec7017SPing-Ke Shih }
4527e3ec7017SPing-Ke Shih 
rtw89_hci_recovery_start(struct rtw89_dev * rtwdev)452814f9f479SZong-Zhe Yang static inline void rtw89_hci_recovery_start(struct rtw89_dev *rtwdev)
452914f9f479SZong-Zhe Yang {
453014f9f479SZong-Zhe Yang 	if (rtwdev->hci.ops->recovery_start)
453114f9f479SZong-Zhe Yang 		rtwdev->hci.ops->recovery_start(rtwdev);
453214f9f479SZong-Zhe Yang }
453314f9f479SZong-Zhe Yang 
rtw89_hci_recovery_complete(struct rtw89_dev * rtwdev)453414f9f479SZong-Zhe Yang static inline void rtw89_hci_recovery_complete(struct rtw89_dev *rtwdev)
453514f9f479SZong-Zhe Yang {
453614f9f479SZong-Zhe Yang 	if (rtwdev->hci.ops->recovery_complete)
453714f9f479SZong-Zhe Yang 		rtwdev->hci.ops->recovery_complete(rtwdev);
453814f9f479SZong-Zhe Yang }
453914f9f479SZong-Zhe Yang 
rtw89_hci_enable_intr(struct rtw89_dev * rtwdev)454019e28c7fSChin-Yen Lee static inline void rtw89_hci_enable_intr(struct rtw89_dev *rtwdev)
454119e28c7fSChin-Yen Lee {
454219e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->enable_intr)
454319e28c7fSChin-Yen Lee 		rtwdev->hci.ops->enable_intr(rtwdev);
454419e28c7fSChin-Yen Lee }
454519e28c7fSChin-Yen Lee 
rtw89_hci_disable_intr(struct rtw89_dev * rtwdev)454619e28c7fSChin-Yen Lee static inline void rtw89_hci_disable_intr(struct rtw89_dev *rtwdev)
454719e28c7fSChin-Yen Lee {
454819e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->disable_intr)
454919e28c7fSChin-Yen Lee 		rtwdev->hci.ops->disable_intr(rtwdev);
455019e28c7fSChin-Yen Lee }
455119e28c7fSChin-Yen Lee 
rtw89_hci_ctrl_txdma_ch(struct rtw89_dev * rtwdev,bool enable)455219e28c7fSChin-Yen Lee static inline void rtw89_hci_ctrl_txdma_ch(struct rtw89_dev *rtwdev, bool enable)
455319e28c7fSChin-Yen Lee {
455419e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->ctrl_txdma_ch)
455519e28c7fSChin-Yen Lee 		rtwdev->hci.ops->ctrl_txdma_ch(rtwdev, enable);
455619e28c7fSChin-Yen Lee }
455719e28c7fSChin-Yen Lee 
rtw89_hci_ctrl_txdma_fw_ch(struct rtw89_dev * rtwdev,bool enable)455819e28c7fSChin-Yen Lee static inline void rtw89_hci_ctrl_txdma_fw_ch(struct rtw89_dev *rtwdev, bool enable)
455919e28c7fSChin-Yen Lee {
456019e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->ctrl_txdma_fw_ch)
456119e28c7fSChin-Yen Lee 		rtwdev->hci.ops->ctrl_txdma_fw_ch(rtwdev, enable);
456219e28c7fSChin-Yen Lee }
456319e28c7fSChin-Yen Lee 
rtw89_hci_ctrl_trxhci(struct rtw89_dev * rtwdev,bool enable)456419e28c7fSChin-Yen Lee static inline void rtw89_hci_ctrl_trxhci(struct rtw89_dev *rtwdev, bool enable)
456519e28c7fSChin-Yen Lee {
456619e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->ctrl_trxhci)
456719e28c7fSChin-Yen Lee 		rtwdev->hci.ops->ctrl_trxhci(rtwdev, enable);
456819e28c7fSChin-Yen Lee }
456919e28c7fSChin-Yen Lee 
rtw89_hci_poll_txdma_ch(struct rtw89_dev * rtwdev)457019e28c7fSChin-Yen Lee static inline int rtw89_hci_poll_txdma_ch(struct rtw89_dev *rtwdev)
457119e28c7fSChin-Yen Lee {
457219e28c7fSChin-Yen Lee 	int ret = 0;
457319e28c7fSChin-Yen Lee 
457419e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->poll_txdma_ch)
457519e28c7fSChin-Yen Lee 		ret = rtwdev->hci.ops->poll_txdma_ch(rtwdev);
457619e28c7fSChin-Yen Lee 	return ret;
457719e28c7fSChin-Yen Lee }
457819e28c7fSChin-Yen Lee 
rtw89_hci_clr_idx_all(struct rtw89_dev * rtwdev)457919e28c7fSChin-Yen Lee static inline void rtw89_hci_clr_idx_all(struct rtw89_dev *rtwdev)
458019e28c7fSChin-Yen Lee {
458119e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->clr_idx_all)
458219e28c7fSChin-Yen Lee 		rtwdev->hci.ops->clr_idx_all(rtwdev);
458319e28c7fSChin-Yen Lee }
458419e28c7fSChin-Yen Lee 
rtw89_hci_rst_bdram(struct rtw89_dev * rtwdev)458519e28c7fSChin-Yen Lee static inline int rtw89_hci_rst_bdram(struct rtw89_dev *rtwdev)
458619e28c7fSChin-Yen Lee {
458719e28c7fSChin-Yen Lee 	int ret = 0;
458819e28c7fSChin-Yen Lee 
458919e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->rst_bdram)
459019e28c7fSChin-Yen Lee 		ret = rtwdev->hci.ops->rst_bdram(rtwdev);
459119e28c7fSChin-Yen Lee 	return ret;
459219e28c7fSChin-Yen Lee }
459319e28c7fSChin-Yen Lee 
rtw89_hci_clear(struct rtw89_dev * rtwdev,struct pci_dev * pdev)459419e28c7fSChin-Yen Lee static inline void rtw89_hci_clear(struct rtw89_dev *rtwdev, struct pci_dev *pdev)
459519e28c7fSChin-Yen Lee {
459619e28c7fSChin-Yen Lee 	if (rtwdev->hci.ops->clear)
459719e28c7fSChin-Yen Lee 		rtwdev->hci.ops->clear(rtwdev, pdev);
459819e28c7fSChin-Yen Lee }
459919e28c7fSChin-Yen Lee 
46001ae5ca61SPo-Hao Huang static inline
RTW89_TX_SKB_CB(struct sk_buff * skb)46011ae5ca61SPo-Hao Huang struct rtw89_tx_skb_data *RTW89_TX_SKB_CB(struct sk_buff *skb)
46021ae5ca61SPo-Hao Huang {
46031ae5ca61SPo-Hao Huang 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
46041ae5ca61SPo-Hao Huang 
46051ae5ca61SPo-Hao Huang 	return (struct rtw89_tx_skb_data *)info->status.status_driver_data;
46061ae5ca61SPo-Hao Huang }
46071ae5ca61SPo-Hao Huang 
rtw89_read8(struct rtw89_dev * rtwdev,u32 addr)4608e3ec7017SPing-Ke Shih static inline u8 rtw89_read8(struct rtw89_dev *rtwdev, u32 addr)
4609e3ec7017SPing-Ke Shih {
4610e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->read8(rtwdev, addr);
4611e3ec7017SPing-Ke Shih }
4612e3ec7017SPing-Ke Shih 
rtw89_read16(struct rtw89_dev * rtwdev,u32 addr)4613e3ec7017SPing-Ke Shih static inline u16 rtw89_read16(struct rtw89_dev *rtwdev, u32 addr)
4614e3ec7017SPing-Ke Shih {
4615e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->read16(rtwdev, addr);
4616e3ec7017SPing-Ke Shih }
4617e3ec7017SPing-Ke Shih 
rtw89_read32(struct rtw89_dev * rtwdev,u32 addr)4618e3ec7017SPing-Ke Shih static inline u32 rtw89_read32(struct rtw89_dev *rtwdev, u32 addr)
4619e3ec7017SPing-Ke Shih {
4620e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->read32(rtwdev, addr);
4621e3ec7017SPing-Ke Shih }
4622e3ec7017SPing-Ke Shih 
rtw89_write8(struct rtw89_dev * rtwdev,u32 addr,u8 data)4623e3ec7017SPing-Ke Shih static inline void rtw89_write8(struct rtw89_dev *rtwdev, u32 addr, u8 data)
4624e3ec7017SPing-Ke Shih {
4625e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->write8(rtwdev, addr, data);
4626e3ec7017SPing-Ke Shih }
4627e3ec7017SPing-Ke Shih 
rtw89_write16(struct rtw89_dev * rtwdev,u32 addr,u16 data)4628e3ec7017SPing-Ke Shih static inline void rtw89_write16(struct rtw89_dev *rtwdev, u32 addr, u16 data)
4629e3ec7017SPing-Ke Shih {
4630e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->write16(rtwdev, addr, data);
4631e3ec7017SPing-Ke Shih }
4632e3ec7017SPing-Ke Shih 
rtw89_write32(struct rtw89_dev * rtwdev,u32 addr,u32 data)4633e3ec7017SPing-Ke Shih static inline void rtw89_write32(struct rtw89_dev *rtwdev, u32 addr, u32 data)
4634e3ec7017SPing-Ke Shih {
4635e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->write32(rtwdev, addr, data);
4636e3ec7017SPing-Ke Shih }
4637e3ec7017SPing-Ke Shih 
4638e3ec7017SPing-Ke Shih static inline void
rtw89_write8_set(struct rtw89_dev * rtwdev,u32 addr,u8 bit)4639e3ec7017SPing-Ke Shih rtw89_write8_set(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
4640e3ec7017SPing-Ke Shih {
4641e3ec7017SPing-Ke Shih 	u8 val;
4642e3ec7017SPing-Ke Shih 
4643e3ec7017SPing-Ke Shih 	val = rtw89_read8(rtwdev, addr);
4644e3ec7017SPing-Ke Shih 	rtw89_write8(rtwdev, addr, val | bit);
4645e3ec7017SPing-Ke Shih }
4646e3ec7017SPing-Ke Shih 
4647e3ec7017SPing-Ke Shih static inline void
rtw89_write16_set(struct rtw89_dev * rtwdev,u32 addr,u16 bit)4648e3ec7017SPing-Ke Shih rtw89_write16_set(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
4649e3ec7017SPing-Ke Shih {
4650e3ec7017SPing-Ke Shih 	u16 val;
4651e3ec7017SPing-Ke Shih 
4652e3ec7017SPing-Ke Shih 	val = rtw89_read16(rtwdev, addr);
4653e3ec7017SPing-Ke Shih 	rtw89_write16(rtwdev, addr, val | bit);
4654e3ec7017SPing-Ke Shih }
4655e3ec7017SPing-Ke Shih 
4656e3ec7017SPing-Ke Shih static inline void
rtw89_write32_set(struct rtw89_dev * rtwdev,u32 addr,u32 bit)4657e3ec7017SPing-Ke Shih rtw89_write32_set(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
4658e3ec7017SPing-Ke Shih {
4659e3ec7017SPing-Ke Shih 	u32 val;
4660e3ec7017SPing-Ke Shih 
4661e3ec7017SPing-Ke Shih 	val = rtw89_read32(rtwdev, addr);
4662e3ec7017SPing-Ke Shih 	rtw89_write32(rtwdev, addr, val | bit);
4663e3ec7017SPing-Ke Shih }
4664e3ec7017SPing-Ke Shih 
4665e3ec7017SPing-Ke Shih static inline void
rtw89_write8_clr(struct rtw89_dev * rtwdev,u32 addr,u8 bit)4666e3ec7017SPing-Ke Shih rtw89_write8_clr(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
4667e3ec7017SPing-Ke Shih {
4668e3ec7017SPing-Ke Shih 	u8 val;
4669e3ec7017SPing-Ke Shih 
4670e3ec7017SPing-Ke Shih 	val = rtw89_read8(rtwdev, addr);
4671e3ec7017SPing-Ke Shih 	rtw89_write8(rtwdev, addr, val & ~bit);
4672e3ec7017SPing-Ke Shih }
4673e3ec7017SPing-Ke Shih 
4674e3ec7017SPing-Ke Shih static inline void
rtw89_write16_clr(struct rtw89_dev * rtwdev,u32 addr,u16 bit)4675e3ec7017SPing-Ke Shih rtw89_write16_clr(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
4676e3ec7017SPing-Ke Shih {
4677e3ec7017SPing-Ke Shih 	u16 val;
4678e3ec7017SPing-Ke Shih 
4679e3ec7017SPing-Ke Shih 	val = rtw89_read16(rtwdev, addr);
4680e3ec7017SPing-Ke Shih 	rtw89_write16(rtwdev, addr, val & ~bit);
4681e3ec7017SPing-Ke Shih }
4682e3ec7017SPing-Ke Shih 
4683e3ec7017SPing-Ke Shih static inline void
rtw89_write32_clr(struct rtw89_dev * rtwdev,u32 addr,u32 bit)4684e3ec7017SPing-Ke Shih rtw89_write32_clr(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
4685e3ec7017SPing-Ke Shih {
4686e3ec7017SPing-Ke Shih 	u32 val;
4687e3ec7017SPing-Ke Shih 
4688e3ec7017SPing-Ke Shih 	val = rtw89_read32(rtwdev, addr);
4689e3ec7017SPing-Ke Shih 	rtw89_write32(rtwdev, addr, val & ~bit);
4690e3ec7017SPing-Ke Shih }
4691e3ec7017SPing-Ke Shih 
4692e3ec7017SPing-Ke Shih static inline u32
rtw89_read32_mask(struct rtw89_dev * rtwdev,u32 addr,u32 mask)4693e3ec7017SPing-Ke Shih rtw89_read32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
4694e3ec7017SPing-Ke Shih {
4695e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
4696e3ec7017SPing-Ke Shih 	u32 orig;
4697e3ec7017SPing-Ke Shih 	u32 ret;
4698e3ec7017SPing-Ke Shih 
4699e3ec7017SPing-Ke Shih 	orig = rtw89_read32(rtwdev, addr);
4700e3ec7017SPing-Ke Shih 	ret = (orig & mask) >> shift;
4701e3ec7017SPing-Ke Shih 
4702e3ec7017SPing-Ke Shih 	return ret;
4703e3ec7017SPing-Ke Shih }
4704e3ec7017SPing-Ke Shih 
4705e3ec7017SPing-Ke Shih static inline u16
rtw89_read16_mask(struct rtw89_dev * rtwdev,u32 addr,u32 mask)4706e3ec7017SPing-Ke Shih rtw89_read16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
4707e3ec7017SPing-Ke Shih {
4708e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
4709e3ec7017SPing-Ke Shih 	u32 orig;
4710e3ec7017SPing-Ke Shih 	u32 ret;
4711e3ec7017SPing-Ke Shih 
4712e3ec7017SPing-Ke Shih 	orig = rtw89_read16(rtwdev, addr);
4713e3ec7017SPing-Ke Shih 	ret = (orig & mask) >> shift;
4714e3ec7017SPing-Ke Shih 
4715e3ec7017SPing-Ke Shih 	return ret;
4716e3ec7017SPing-Ke Shih }
4717e3ec7017SPing-Ke Shih 
4718e3ec7017SPing-Ke Shih static inline u8
rtw89_read8_mask(struct rtw89_dev * rtwdev,u32 addr,u32 mask)4719e3ec7017SPing-Ke Shih rtw89_read8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
4720e3ec7017SPing-Ke Shih {
4721e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
4722e3ec7017SPing-Ke Shih 	u32 orig;
4723e3ec7017SPing-Ke Shih 	u32 ret;
4724e3ec7017SPing-Ke Shih 
4725e3ec7017SPing-Ke Shih 	orig = rtw89_read8(rtwdev, addr);
4726e3ec7017SPing-Ke Shih 	ret = (orig & mask) >> shift;
4727e3ec7017SPing-Ke Shih 
4728e3ec7017SPing-Ke Shih 	return ret;
4729e3ec7017SPing-Ke Shih }
4730e3ec7017SPing-Ke Shih 
4731e3ec7017SPing-Ke Shih static inline void
rtw89_write32_mask(struct rtw89_dev * rtwdev,u32 addr,u32 mask,u32 data)4732e3ec7017SPing-Ke Shih rtw89_write32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u32 data)
4733e3ec7017SPing-Ke Shih {
4734e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
4735e3ec7017SPing-Ke Shih 	u32 orig;
4736e3ec7017SPing-Ke Shih 	u32 set;
4737e3ec7017SPing-Ke Shih 
4738e3ec7017SPing-Ke Shih 	WARN(addr & 0x3, "should be 4-byte aligned, addr = 0x%08x\n", addr);
4739e3ec7017SPing-Ke Shih 
4740e3ec7017SPing-Ke Shih 	orig = rtw89_read32(rtwdev, addr);
4741e3ec7017SPing-Ke Shih 	set = (orig & ~mask) | ((data << shift) & mask);
4742e3ec7017SPing-Ke Shih 	rtw89_write32(rtwdev, addr, set);
4743e3ec7017SPing-Ke Shih }
4744e3ec7017SPing-Ke Shih 
4745e3ec7017SPing-Ke Shih static inline void
rtw89_write16_mask(struct rtw89_dev * rtwdev,u32 addr,u32 mask,u16 data)4746e3ec7017SPing-Ke Shih rtw89_write16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u16 data)
4747e3ec7017SPing-Ke Shih {
4748e3ec7017SPing-Ke Shih 	u32 shift;
4749e3ec7017SPing-Ke Shih 	u16 orig, set;
4750e3ec7017SPing-Ke Shih 
4751e3ec7017SPing-Ke Shih 	mask &= 0xffff;
4752e3ec7017SPing-Ke Shih 	shift = __ffs(mask);
4753e3ec7017SPing-Ke Shih 
4754e3ec7017SPing-Ke Shih 	orig = rtw89_read16(rtwdev, addr);
4755e3ec7017SPing-Ke Shih 	set = (orig & ~mask) | ((data << shift) & mask);
4756e3ec7017SPing-Ke Shih 	rtw89_write16(rtwdev, addr, set);
4757e3ec7017SPing-Ke Shih }
4758e3ec7017SPing-Ke Shih 
4759e3ec7017SPing-Ke Shih static inline void
rtw89_write8_mask(struct rtw89_dev * rtwdev,u32 addr,u32 mask,u8 data)4760e3ec7017SPing-Ke Shih rtw89_write8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u8 data)
4761e3ec7017SPing-Ke Shih {
4762e3ec7017SPing-Ke Shih 	u32 shift;
4763e3ec7017SPing-Ke Shih 	u8 orig, set;
4764e3ec7017SPing-Ke Shih 
4765e3ec7017SPing-Ke Shih 	mask &= 0xff;
4766e3ec7017SPing-Ke Shih 	shift = __ffs(mask);
4767e3ec7017SPing-Ke Shih 
4768e3ec7017SPing-Ke Shih 	orig = rtw89_read8(rtwdev, addr);
4769e3ec7017SPing-Ke Shih 	set = (orig & ~mask) | ((data << shift) & mask);
4770e3ec7017SPing-Ke Shih 	rtw89_write8(rtwdev, addr, set);
4771e3ec7017SPing-Ke Shih }
4772e3ec7017SPing-Ke Shih 
4773e3ec7017SPing-Ke Shih static inline u32
rtw89_read_rf(struct rtw89_dev * rtwdev,enum rtw89_rf_path rf_path,u32 addr,u32 mask)4774e3ec7017SPing-Ke Shih rtw89_read_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
4775e3ec7017SPing-Ke Shih 	      u32 addr, u32 mask)
4776e3ec7017SPing-Ke Shih {
4777e3ec7017SPing-Ke Shih 	u32 val;
4778e3ec7017SPing-Ke Shih 
4779e3ec7017SPing-Ke Shih 	mutex_lock(&rtwdev->rf_mutex);
4780e3ec7017SPing-Ke Shih 	val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask);
4781e3ec7017SPing-Ke Shih 	mutex_unlock(&rtwdev->rf_mutex);
4782e3ec7017SPing-Ke Shih 
4783e3ec7017SPing-Ke Shih 	return val;
4784e3ec7017SPing-Ke Shih }
4785e3ec7017SPing-Ke Shih 
4786e3ec7017SPing-Ke Shih static inline void
rtw89_write_rf(struct rtw89_dev * rtwdev,enum rtw89_rf_path rf_path,u32 addr,u32 mask,u32 data)4787e3ec7017SPing-Ke Shih rtw89_write_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
4788e3ec7017SPing-Ke Shih 	       u32 addr, u32 mask, u32 data)
4789e3ec7017SPing-Ke Shih {
4790e3ec7017SPing-Ke Shih 	mutex_lock(&rtwdev->rf_mutex);
4791e3ec7017SPing-Ke Shih 	rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data);
4792e3ec7017SPing-Ke Shih 	mutex_unlock(&rtwdev->rf_mutex);
4793e3ec7017SPing-Ke Shih }
4794e3ec7017SPing-Ke Shih 
rtw89_txq_to_txq(struct rtw89_txq * rtwtxq)4795e3ec7017SPing-Ke Shih static inline struct ieee80211_txq *rtw89_txq_to_txq(struct rtw89_txq *rtwtxq)
4796e3ec7017SPing-Ke Shih {
4797e3ec7017SPing-Ke Shih 	void *p = rtwtxq;
4798e3ec7017SPing-Ke Shih 
4799e3ec7017SPing-Ke Shih 	return container_of(p, struct ieee80211_txq, drv_priv);
4800e3ec7017SPing-Ke Shih }
4801e3ec7017SPing-Ke Shih 
rtw89_core_txq_init(struct rtw89_dev * rtwdev,struct ieee80211_txq * txq)4802e3ec7017SPing-Ke Shih static inline void rtw89_core_txq_init(struct rtw89_dev *rtwdev,
4803e3ec7017SPing-Ke Shih 				       struct ieee80211_txq *txq)
4804e3ec7017SPing-Ke Shih {
4805e3ec7017SPing-Ke Shih 	struct rtw89_txq *rtwtxq;
4806e3ec7017SPing-Ke Shih 
4807e3ec7017SPing-Ke Shih 	if (!txq)
4808e3ec7017SPing-Ke Shih 		return;
4809e3ec7017SPing-Ke Shih 
4810e3ec7017SPing-Ke Shih 	rtwtxq = (struct rtw89_txq *)txq->drv_priv;
4811e3ec7017SPing-Ke Shih 	INIT_LIST_HEAD(&rtwtxq->list);
4812e3ec7017SPing-Ke Shih }
4813e3ec7017SPing-Ke Shih 
rtwvif_to_vif(struct rtw89_vif * rtwvif)4814e3ec7017SPing-Ke Shih static inline struct ieee80211_vif *rtwvif_to_vif(struct rtw89_vif *rtwvif)
4815e3ec7017SPing-Ke Shih {
4816e3ec7017SPing-Ke Shih 	void *p = rtwvif;
4817e3ec7017SPing-Ke Shih 
4818e3ec7017SPing-Ke Shih 	return container_of(p, struct ieee80211_vif, drv_priv);
4819e3ec7017SPing-Ke Shih }
4820e3ec7017SPing-Ke Shih 
rtwvif_to_vif_safe(struct rtw89_vif * rtwvif)4821bd1056d4SPo-Hao Huang static inline struct ieee80211_vif *rtwvif_to_vif_safe(struct rtw89_vif *rtwvif)
4822bd1056d4SPo-Hao Huang {
4823bd1056d4SPo-Hao Huang 	return rtwvif ? rtwvif_to_vif(rtwvif) : NULL;
4824bd1056d4SPo-Hao Huang }
4825bd1056d4SPo-Hao Huang 
vif_to_rtwvif_safe(struct ieee80211_vif * vif)4826bd1056d4SPo-Hao Huang static inline struct rtw89_vif *vif_to_rtwvif_safe(struct ieee80211_vif *vif)
4827bd1056d4SPo-Hao Huang {
4828bd1056d4SPo-Hao Huang 	return vif ? (struct rtw89_vif *)vif->drv_priv : NULL;
4829bd1056d4SPo-Hao Huang }
4830bd1056d4SPo-Hao Huang 
rtwsta_to_sta(struct rtw89_sta * rtwsta)4831e3ec7017SPing-Ke Shih static inline struct ieee80211_sta *rtwsta_to_sta(struct rtw89_sta *rtwsta)
4832e3ec7017SPing-Ke Shih {
4833e3ec7017SPing-Ke Shih 	void *p = rtwsta;
4834e3ec7017SPing-Ke Shih 
4835e3ec7017SPing-Ke Shih 	return container_of(p, struct ieee80211_sta, drv_priv);
4836e3ec7017SPing-Ke Shih }
4837e3ec7017SPing-Ke Shih 
rtwsta_to_sta_safe(struct rtw89_sta * rtwsta)483840822e07SPing-Ke Shih static inline struct ieee80211_sta *rtwsta_to_sta_safe(struct rtw89_sta *rtwsta)
483940822e07SPing-Ke Shih {
484040822e07SPing-Ke Shih 	return rtwsta ? rtwsta_to_sta(rtwsta) : NULL;
484140822e07SPing-Ke Shih }
484240822e07SPing-Ke Shih 
sta_to_rtwsta_safe(struct ieee80211_sta * sta)484340822e07SPing-Ke Shih static inline struct rtw89_sta *sta_to_rtwsta_safe(struct ieee80211_sta *sta)
484440822e07SPing-Ke Shih {
484540822e07SPing-Ke Shih 	return sta ? (struct rtw89_sta *)sta->drv_priv : NULL;
484640822e07SPing-Ke Shih }
484740822e07SPing-Ke Shih 
rtw89_hw_to_rate_info_bw(enum rtw89_bandwidth hw_bw)4848167044afSPing-Ke Shih static inline u8 rtw89_hw_to_rate_info_bw(enum rtw89_bandwidth hw_bw)
4849167044afSPing-Ke Shih {
4850167044afSPing-Ke Shih 	if (hw_bw == RTW89_CHANNEL_WIDTH_160)
4851167044afSPing-Ke Shih 		return RATE_INFO_BW_160;
4852167044afSPing-Ke Shih 	else if (hw_bw == RTW89_CHANNEL_WIDTH_80)
4853167044afSPing-Ke Shih 		return RATE_INFO_BW_80;
4854167044afSPing-Ke Shih 	else if (hw_bw == RTW89_CHANNEL_WIDTH_40)
4855167044afSPing-Ke Shih 		return RATE_INFO_BW_40;
4856167044afSPing-Ke Shih 	else
4857167044afSPing-Ke Shih 		return RATE_INFO_BW_20;
4858167044afSPing-Ke Shih }
4859167044afSPing-Ke Shih 
4860e3ec7017SPing-Ke Shih static inline
rtw89_hw_to_nl80211_band(enum rtw89_band hw_band)4861a06d2dd7SZong-Zhe Yang enum nl80211_band rtw89_hw_to_nl80211_band(enum rtw89_band hw_band)
4862a06d2dd7SZong-Zhe Yang {
4863a06d2dd7SZong-Zhe Yang 	switch (hw_band) {
4864a06d2dd7SZong-Zhe Yang 	default:
4865a06d2dd7SZong-Zhe Yang 	case RTW89_BAND_2G:
4866a06d2dd7SZong-Zhe Yang 		return NL80211_BAND_2GHZ;
4867a06d2dd7SZong-Zhe Yang 	case RTW89_BAND_5G:
4868a06d2dd7SZong-Zhe Yang 		return NL80211_BAND_5GHZ;
4869a06d2dd7SZong-Zhe Yang 	case RTW89_BAND_6G:
4870a06d2dd7SZong-Zhe Yang 		return NL80211_BAND_6GHZ;
4871a06d2dd7SZong-Zhe Yang 	}
4872a06d2dd7SZong-Zhe Yang }
4873a06d2dd7SZong-Zhe Yang 
4874a06d2dd7SZong-Zhe Yang static inline
rtw89_nl80211_to_hw_band(enum nl80211_band nl_band)48753a1e7cb1SPo-Hao Huang enum rtw89_band rtw89_nl80211_to_hw_band(enum nl80211_band nl_band)
48763a1e7cb1SPo-Hao Huang {
48773a1e7cb1SPo-Hao Huang 	switch (nl_band) {
48783a1e7cb1SPo-Hao Huang 	default:
48793a1e7cb1SPo-Hao Huang 	case NL80211_BAND_2GHZ:
48803a1e7cb1SPo-Hao Huang 		return RTW89_BAND_2G;
48813a1e7cb1SPo-Hao Huang 	case NL80211_BAND_5GHZ:
48823a1e7cb1SPo-Hao Huang 		return RTW89_BAND_5G;
48833a1e7cb1SPo-Hao Huang 	case NL80211_BAND_6GHZ:
48843a1e7cb1SPo-Hao Huang 		return RTW89_BAND_6G;
48853a1e7cb1SPo-Hao Huang 	}
48863a1e7cb1SPo-Hao Huang }
48873a1e7cb1SPo-Hao Huang 
48883a1e7cb1SPo-Hao Huang static inline
nl_to_rtw89_bandwidth(enum nl80211_chan_width width)4889e715f10fSPing-Ke Shih enum rtw89_bandwidth nl_to_rtw89_bandwidth(enum nl80211_chan_width width)
4890e715f10fSPing-Ke Shih {
4891e715f10fSPing-Ke Shih 	switch (width) {
4892e715f10fSPing-Ke Shih 	default:
4893e715f10fSPing-Ke Shih 		WARN(1, "Not support bandwidth %d\n", width);
4894e715f10fSPing-Ke Shih 		fallthrough;
4895e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_20_NOHT:
4896e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_20:
4897e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_20;
4898e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_40:
4899e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_40;
4900e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_80:
4901e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_80;
4902e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_160:
4903e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_160;
4904e715f10fSPing-Ke Shih 	}
4905e715f10fSPing-Ke Shih }
4906e715f10fSPing-Ke Shih 
4907e715f10fSPing-Ke Shih static inline
rtw89_get_addr_cam_of(struct rtw89_vif * rtwvif,struct rtw89_sta * rtwsta)49082ab856ccSPing-Ke Shih struct rtw89_addr_cam_entry *rtw89_get_addr_cam_of(struct rtw89_vif *rtwvif,
49092ab856ccSPing-Ke Shih 						   struct rtw89_sta *rtwsta)
49102ab856ccSPing-Ke Shih {
49117312100dSPing-Ke Shih 	if (rtwsta) {
49127312100dSPing-Ke Shih 		struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta);
49137312100dSPing-Ke Shih 
49147312100dSPing-Ke Shih 		if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE || sta->tdls)
49152ab856ccSPing-Ke Shih 			return &rtwsta->addr_cam;
49167312100dSPing-Ke Shih 	}
49172ab856ccSPing-Ke Shih 	return &rtwvif->addr_cam;
49182ab856ccSPing-Ke Shih }
49192ab856ccSPing-Ke Shih 
49202ab856ccSPing-Ke Shih static inline
rtw89_get_bssid_cam_of(struct rtw89_vif * rtwvif,struct rtw89_sta * rtwsta)492139913cc8SPing-Ke Shih struct rtw89_bssid_cam_entry *rtw89_get_bssid_cam_of(struct rtw89_vif *rtwvif,
492239913cc8SPing-Ke Shih 						     struct rtw89_sta *rtwsta)
492339913cc8SPing-Ke Shih {
492439913cc8SPing-Ke Shih 	if (rtwsta) {
492539913cc8SPing-Ke Shih 		struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta);
492639913cc8SPing-Ke Shih 
492739913cc8SPing-Ke Shih 		if (sta->tdls)
492839913cc8SPing-Ke Shih 			return &rtwsta->bssid_cam;
492939913cc8SPing-Ke Shih 	}
493039913cc8SPing-Ke Shih 	return &rtwvif->bssid_cam;
493139913cc8SPing-Ke Shih }
493239913cc8SPing-Ke Shih 
493339913cc8SPing-Ke Shih static inline
rtw89_chip_set_channel_prepare(struct rtw89_dev * rtwdev,struct rtw89_channel_help_params * p,const struct rtw89_chan * chan,enum rtw89_mac_idx mac_idx,enum rtw89_phy_idx phy_idx)4934e3ec7017SPing-Ke Shih void rtw89_chip_set_channel_prepare(struct rtw89_dev *rtwdev,
4935ce57e55cSZong-Zhe Yang 				    struct rtw89_channel_help_params *p,
4936ce57e55cSZong-Zhe Yang 				    const struct rtw89_chan *chan,
4937ce57e55cSZong-Zhe Yang 				    enum rtw89_mac_idx mac_idx,
4938ce57e55cSZong-Zhe Yang 				    enum rtw89_phy_idx phy_idx)
4939e3ec7017SPing-Ke Shih {
4940ce57e55cSZong-Zhe Yang 	rtwdev->chip->ops->set_channel_help(rtwdev, true, p, chan,
4941ce57e55cSZong-Zhe Yang 					    mac_idx, phy_idx);
4942e3ec7017SPing-Ke Shih }
4943e3ec7017SPing-Ke Shih 
4944e3ec7017SPing-Ke Shih static inline
rtw89_chip_set_channel_done(struct rtw89_dev * rtwdev,struct rtw89_channel_help_params * p,const struct rtw89_chan * chan,enum rtw89_mac_idx mac_idx,enum rtw89_phy_idx phy_idx)4945e3ec7017SPing-Ke Shih void rtw89_chip_set_channel_done(struct rtw89_dev *rtwdev,
4946ce57e55cSZong-Zhe Yang 				 struct rtw89_channel_help_params *p,
4947ce57e55cSZong-Zhe Yang 				 const struct rtw89_chan *chan,
4948ce57e55cSZong-Zhe Yang 				 enum rtw89_mac_idx mac_idx,
4949ce57e55cSZong-Zhe Yang 				 enum rtw89_phy_idx phy_idx)
4950e3ec7017SPing-Ke Shih {
4951ce57e55cSZong-Zhe Yang 	rtwdev->chip->ops->set_channel_help(rtwdev, false, p, chan,
4952ce57e55cSZong-Zhe Yang 					    mac_idx, phy_idx);
4953e3ec7017SPing-Ke Shih }
4954e3ec7017SPing-Ke Shih 
4955cbb145b9SZong-Zhe Yang static inline
rtw89_chandef_get(struct rtw89_dev * rtwdev,enum rtw89_sub_entity_idx idx)4956494399b2SZong-Zhe Yang const struct cfg80211_chan_def *rtw89_chandef_get(struct rtw89_dev *rtwdev,
4957494399b2SZong-Zhe Yang 						  enum rtw89_sub_entity_idx idx)
4958494399b2SZong-Zhe Yang {
4959494399b2SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
4960a0e97ae3SPo-Hao Huang 	enum rtw89_sub_entity_idx roc_idx = atomic_read(&hal->roc_entity_idx);
4961a0e97ae3SPo-Hao Huang 
4962a0e97ae3SPo-Hao Huang 	if (roc_idx == idx)
4963a0e97ae3SPo-Hao Huang 		return &hal->roc_chandef;
4964494399b2SZong-Zhe Yang 
496575ee07b0SZong-Zhe Yang 	return &hal->sub[idx].chandef;
4966494399b2SZong-Zhe Yang }
4967494399b2SZong-Zhe Yang 
4968494399b2SZong-Zhe Yang static inline
rtw89_chan_get(struct rtw89_dev * rtwdev,enum rtw89_sub_entity_idx idx)4969cbb145b9SZong-Zhe Yang const struct rtw89_chan *rtw89_chan_get(struct rtw89_dev *rtwdev,
4970cbb145b9SZong-Zhe Yang 					enum rtw89_sub_entity_idx idx)
4971cbb145b9SZong-Zhe Yang {
4972cbb145b9SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
4973cbb145b9SZong-Zhe Yang 
497475ee07b0SZong-Zhe Yang 	return &hal->sub[idx].chan;
4975cbb145b9SZong-Zhe Yang }
4976cbb145b9SZong-Zhe Yang 
4977cbb145b9SZong-Zhe Yang static inline
rtw89_chan_rcd_get(struct rtw89_dev * rtwdev,enum rtw89_sub_entity_idx idx)4978cbb145b9SZong-Zhe Yang const struct rtw89_chan_rcd *rtw89_chan_rcd_get(struct rtw89_dev *rtwdev,
4979cbb145b9SZong-Zhe Yang 						enum rtw89_sub_entity_idx idx)
4980cbb145b9SZong-Zhe Yang {
4981cbb145b9SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
4982cbb145b9SZong-Zhe Yang 
498375ee07b0SZong-Zhe Yang 	return &hal->sub[idx].rcd;
4984cbb145b9SZong-Zhe Yang }
4985cbb145b9SZong-Zhe Yang 
4986ad3dc722SZong-Zhe Yang static inline
rtw89_scan_chan_get(struct rtw89_dev * rtwdev)4987ad3dc722SZong-Zhe Yang const struct rtw89_chan *rtw89_scan_chan_get(struct rtw89_dev *rtwdev)
4988ad3dc722SZong-Zhe Yang {
4989ad3dc722SZong-Zhe Yang 	struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif;
4990ad3dc722SZong-Zhe Yang 	struct rtw89_vif *rtwvif = vif_to_rtwvif_safe(vif);
4991ad3dc722SZong-Zhe Yang 
4992ad3dc722SZong-Zhe Yang 	if (rtwvif)
4993ad3dc722SZong-Zhe Yang 		return rtw89_chan_get(rtwdev, rtwvif->sub_entity_idx);
4994ad3dc722SZong-Zhe Yang 	else
4995ad3dc722SZong-Zhe Yang 		return rtw89_chan_get(rtwdev, RTW89_SUB_ENTITY_0);
4996ad3dc722SZong-Zhe Yang }
4997ad3dc722SZong-Zhe Yang 
rtw89_chip_fem_setup(struct rtw89_dev * rtwdev)4998e3ec7017SPing-Ke Shih static inline void rtw89_chip_fem_setup(struct rtw89_dev *rtwdev)
4999e3ec7017SPing-Ke Shih {
5000e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5001e3ec7017SPing-Ke Shih 
5002e3ec7017SPing-Ke Shih 	if (chip->ops->fem_setup)
5003e3ec7017SPing-Ke Shih 		chip->ops->fem_setup(rtwdev);
5004e3ec7017SPing-Ke Shih }
5005e3ec7017SPing-Ke Shih 
rtw89_chip_rfe_gpio(struct rtw89_dev * rtwdev)5006f03bd042SPing-Ke Shih static inline void rtw89_chip_rfe_gpio(struct rtw89_dev *rtwdev)
5007f03bd042SPing-Ke Shih {
5008f03bd042SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5009f03bd042SPing-Ke Shih 
5010f03bd042SPing-Ke Shih 	if (chip->ops->rfe_gpio)
5011f03bd042SPing-Ke Shih 		chip->ops->rfe_gpio(rtwdev);
5012f03bd042SPing-Ke Shih }
5013f03bd042SPing-Ke Shih 
rtw89_chip_bb_sethw(struct rtw89_dev * rtwdev)5014e3ec7017SPing-Ke Shih static inline void rtw89_chip_bb_sethw(struct rtw89_dev *rtwdev)
5015e3ec7017SPing-Ke Shih {
5016e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5017e3ec7017SPing-Ke Shih 
5018e3ec7017SPing-Ke Shih 	if (chip->ops->bb_sethw)
5019e3ec7017SPing-Ke Shih 		chip->ops->bb_sethw(rtwdev);
5020e3ec7017SPing-Ke Shih }
5021e3ec7017SPing-Ke Shih 
rtw89_chip_rfk_init(struct rtw89_dev * rtwdev)5022e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_init(struct rtw89_dev *rtwdev)
5023e3ec7017SPing-Ke Shih {
5024e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5025e3ec7017SPing-Ke Shih 
5026e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_init)
5027e3ec7017SPing-Ke Shih 		chip->ops->rfk_init(rtwdev);
5028e3ec7017SPing-Ke Shih }
5029e3ec7017SPing-Ke Shih 
rtw89_chip_rfk_channel(struct rtw89_dev * rtwdev)5030e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_channel(struct rtw89_dev *rtwdev)
5031e3ec7017SPing-Ke Shih {
5032e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5033e3ec7017SPing-Ke Shih 
5034e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_channel)
5035e3ec7017SPing-Ke Shih 		chip->ops->rfk_channel(rtwdev);
5036e3ec7017SPing-Ke Shih }
5037e3ec7017SPing-Ke Shih 
rtw89_chip_rfk_band_changed(struct rtw89_dev * rtwdev,enum rtw89_phy_idx phy_idx)5038010d0051SZong-Zhe Yang static inline void rtw89_chip_rfk_band_changed(struct rtw89_dev *rtwdev,
5039010d0051SZong-Zhe Yang 					       enum rtw89_phy_idx phy_idx)
5040e3ec7017SPing-Ke Shih {
5041e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5042e3ec7017SPing-Ke Shih 
5043e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_band_changed)
5044010d0051SZong-Zhe Yang 		chip->ops->rfk_band_changed(rtwdev, phy_idx);
5045e3ec7017SPing-Ke Shih }
5046e3ec7017SPing-Ke Shih 
rtw89_chip_rfk_scan(struct rtw89_dev * rtwdev,bool start)5047e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_scan(struct rtw89_dev *rtwdev, bool start)
5048e3ec7017SPing-Ke Shih {
5049e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5050e3ec7017SPing-Ke Shih 
5051e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_scan)
5052e3ec7017SPing-Ke Shih 		chip->ops->rfk_scan(rtwdev, start);
5053e3ec7017SPing-Ke Shih }
5054e3ec7017SPing-Ke Shih 
rtw89_chip_rfk_track(struct rtw89_dev * rtwdev)5055e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_track(struct rtw89_dev *rtwdev)
5056e3ec7017SPing-Ke Shih {
5057e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5058e3ec7017SPing-Ke Shih 
5059e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_track)
5060e3ec7017SPing-Ke Shih 		chip->ops->rfk_track(rtwdev);
5061e3ec7017SPing-Ke Shih }
5062e3ec7017SPing-Ke Shih 
rtw89_chip_set_txpwr_ctrl(struct rtw89_dev * rtwdev)5063e3ec7017SPing-Ke Shih static inline void rtw89_chip_set_txpwr_ctrl(struct rtw89_dev *rtwdev)
5064e3ec7017SPing-Ke Shih {
5065e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5066e3ec7017SPing-Ke Shih 
5067e3ec7017SPing-Ke Shih 	if (chip->ops->set_txpwr_ctrl)
506807ef5f2fSZong-Zhe Yang 		chip->ops->set_txpwr_ctrl(rtwdev,  RTW89_PHY_0);
5069e3ec7017SPing-Ke Shih }
5070e3ec7017SPing-Ke Shih 
rtw89_chip_power_trim(struct rtw89_dev * rtwdev)5071e3ec7017SPing-Ke Shih static inline void rtw89_chip_power_trim(struct rtw89_dev *rtwdev)
5072e3ec7017SPing-Ke Shih {
5073e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5074e3ec7017SPing-Ke Shih 
5075e3ec7017SPing-Ke Shih 	if (chip->ops->power_trim)
5076e3ec7017SPing-Ke Shih 		chip->ops->power_trim(rtwdev);
5077e3ec7017SPing-Ke Shih }
5078e3ec7017SPing-Ke Shih 
rtw89_chip_init_txpwr_unit(struct rtw89_dev * rtwdev,enum rtw89_phy_idx phy_idx)5079e3ec7017SPing-Ke Shih static inline void rtw89_chip_init_txpwr_unit(struct rtw89_dev *rtwdev,
5080e3ec7017SPing-Ke Shih 					      enum rtw89_phy_idx phy_idx)
5081e3ec7017SPing-Ke Shih {
5082e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5083e3ec7017SPing-Ke Shih 
5084e3ec7017SPing-Ke Shih 	if (chip->ops->init_txpwr_unit)
5085e3ec7017SPing-Ke Shih 		chip->ops->init_txpwr_unit(rtwdev, phy_idx);
5086e3ec7017SPing-Ke Shih }
5087e3ec7017SPing-Ke Shih 
rtw89_chip_get_thermal(struct rtw89_dev * rtwdev,enum rtw89_rf_path rf_path)5088e3ec7017SPing-Ke Shih static inline u8 rtw89_chip_get_thermal(struct rtw89_dev *rtwdev,
5089e3ec7017SPing-Ke Shih 					enum rtw89_rf_path rf_path)
5090e3ec7017SPing-Ke Shih {
5091e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5092e3ec7017SPing-Ke Shih 
5093e3ec7017SPing-Ke Shih 	if (!chip->ops->get_thermal)
5094e3ec7017SPing-Ke Shih 		return 0x10;
5095e3ec7017SPing-Ke Shih 
5096e3ec7017SPing-Ke Shih 	return chip->ops->get_thermal(rtwdev, rf_path);
5097e3ec7017SPing-Ke Shih }
5098e3ec7017SPing-Ke Shih 
rtw89_chip_query_ppdu(struct rtw89_dev * rtwdev,struct rtw89_rx_phy_ppdu * phy_ppdu,struct ieee80211_rx_status * status)5099e3ec7017SPing-Ke Shih static inline void rtw89_chip_query_ppdu(struct rtw89_dev *rtwdev,
5100e3ec7017SPing-Ke Shih 					 struct rtw89_rx_phy_ppdu *phy_ppdu,
5101e3ec7017SPing-Ke Shih 					 struct ieee80211_rx_status *status)
5102e3ec7017SPing-Ke Shih {
5103e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5104e3ec7017SPing-Ke Shih 
5105e3ec7017SPing-Ke Shih 	if (chip->ops->query_ppdu)
5106e3ec7017SPing-Ke Shih 		chip->ops->query_ppdu(rtwdev, phy_ppdu, status);
5107e3ec7017SPing-Ke Shih }
5108e3ec7017SPing-Ke Shih 
rtw89_chip_bb_ctrl_btc_preagc(struct rtw89_dev * rtwdev,bool bt_en)5109e3ec7017SPing-Ke Shih static inline void rtw89_chip_bb_ctrl_btc_preagc(struct rtw89_dev *rtwdev,
5110e3ec7017SPing-Ke Shih 						 bool bt_en)
5111e3ec7017SPing-Ke Shih {
5112e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5113e3ec7017SPing-Ke Shih 
5114e3ec7017SPing-Ke Shih 	if (chip->ops->bb_ctrl_btc_preagc)
5115e3ec7017SPing-Ke Shih 		chip->ops->bb_ctrl_btc_preagc(rtwdev, bt_en);
5116e3ec7017SPing-Ke Shih }
5117e3ec7017SPing-Ke Shih 
rtw89_chip_cfg_txrx_path(struct rtw89_dev * rtwdev)5118cd89a471SPing-Ke Shih static inline void rtw89_chip_cfg_txrx_path(struct rtw89_dev *rtwdev)
5119cd89a471SPing-Ke Shih {
5120cd89a471SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5121cd89a471SPing-Ke Shih 
5122cd89a471SPing-Ke Shih 	if (chip->ops->cfg_txrx_path)
5123cd89a471SPing-Ke Shih 		chip->ops->cfg_txrx_path(rtwdev);
5124cd89a471SPing-Ke Shih }
5125cd89a471SPing-Ke Shih 
5126e3ec7017SPing-Ke Shih static inline
rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev * rtwdev,struct ieee80211_vif * vif)5127e3ec7017SPing-Ke Shih void rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev,
5128e3ec7017SPing-Ke Shih 				       struct ieee80211_vif *vif)
5129e3ec7017SPing-Ke Shih {
5130e3ec7017SPing-Ke Shih 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
5131e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5132e3ec7017SPing-Ke Shih 
5133f276e20bSJohannes Berg 	if (!vif->bss_conf.he_support || !vif->cfg.assoc)
5134e3ec7017SPing-Ke Shih 		return;
5135e3ec7017SPing-Ke Shih 
5136e3ec7017SPing-Ke Shih 	if (chip->ops->set_txpwr_ul_tb_offset)
5137e3ec7017SPing-Ke Shih 		chip->ops->set_txpwr_ul_tb_offset(rtwdev, 0, rtwvif->mac_idx);
5138e3ec7017SPing-Ke Shih }
5139e3ec7017SPing-Ke Shih 
rtw89_load_txpwr_table(struct rtw89_dev * rtwdev,const struct rtw89_txpwr_table * tbl)5140e3ec7017SPing-Ke Shih static inline void rtw89_load_txpwr_table(struct rtw89_dev *rtwdev,
5141e3ec7017SPing-Ke Shih 					  const struct rtw89_txpwr_table *tbl)
5142e3ec7017SPing-Ke Shih {
5143e3ec7017SPing-Ke Shih 	tbl->load(rtwdev, tbl);
5144e3ec7017SPing-Ke Shih }
5145e3ec7017SPing-Ke Shih 
rtw89_regd_get(struct rtw89_dev * rtwdev,u8 band)5146e3ec7017SPing-Ke Shih static inline u8 rtw89_regd_get(struct rtw89_dev *rtwdev, u8 band)
5147e3ec7017SPing-Ke Shih {
5148f6baa1d3SZong-Zhe Yang 	const struct rtw89_regd *regd = rtwdev->regulatory.regd;
5149f6baa1d3SZong-Zhe Yang 
5150f6baa1d3SZong-Zhe Yang 	return regd->txpwr_regd[band];
5151e3ec7017SPing-Ke Shih }
5152e3ec7017SPing-Ke Shih 
rtw89_ctrl_btg(struct rtw89_dev * rtwdev,bool btg)5153e3ec7017SPing-Ke Shih static inline void rtw89_ctrl_btg(struct rtw89_dev *rtwdev, bool btg)
5154e3ec7017SPing-Ke Shih {
5155e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5156e3ec7017SPing-Ke Shih 
5157e3ec7017SPing-Ke Shih 	if (chip->ops->ctrl_btg)
5158e3ec7017SPing-Ke Shih 		chip->ops->ctrl_btg(rtwdev, btg);
5159e3ec7017SPing-Ke Shih }
5160e3ec7017SPing-Ke Shih 
5161feed6541SChia-Yuan Li static inline
rtw89_chip_query_rxdesc(struct rtw89_dev * rtwdev,struct rtw89_rx_desc_info * desc_info,u8 * data,u32 data_offset)5162de9f9338SPing-Ke Shih void rtw89_chip_query_rxdesc(struct rtw89_dev *rtwdev,
5163de9f9338SPing-Ke Shih 			     struct rtw89_rx_desc_info *desc_info,
5164de9f9338SPing-Ke Shih 			     u8 *data, u32 data_offset)
5165de9f9338SPing-Ke Shih {
5166de9f9338SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5167de9f9338SPing-Ke Shih 
5168de9f9338SPing-Ke Shih 	chip->ops->query_rxdesc(rtwdev, desc_info, data, data_offset);
5169de9f9338SPing-Ke Shih }
5170de9f9338SPing-Ke Shih 
5171de9f9338SPing-Ke Shih static inline
rtw89_chip_fill_txdesc(struct rtw89_dev * rtwdev,struct rtw89_tx_desc_info * desc_info,void * txdesc)5172f59acddeSPing-Ke Shih void rtw89_chip_fill_txdesc(struct rtw89_dev *rtwdev,
5173f59acddeSPing-Ke Shih 			    struct rtw89_tx_desc_info *desc_info,
5174f59acddeSPing-Ke Shih 			    void *txdesc)
5175f59acddeSPing-Ke Shih {
5176f59acddeSPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5177f59acddeSPing-Ke Shih 
5178f59acddeSPing-Ke Shih 	chip->ops->fill_txdesc(rtwdev, desc_info, txdesc);
5179f59acddeSPing-Ke Shih }
5180f59acddeSPing-Ke Shih 
5181f59acddeSPing-Ke Shih static inline
rtw89_chip_fill_txdesc_fwcmd(struct rtw89_dev * rtwdev,struct rtw89_tx_desc_info * desc_info,void * txdesc)5182a95bd62eSPing-Ke Shih void rtw89_chip_fill_txdesc_fwcmd(struct rtw89_dev *rtwdev,
5183a95bd62eSPing-Ke Shih 				  struct rtw89_tx_desc_info *desc_info,
5184a95bd62eSPing-Ke Shih 				  void *txdesc)
5185a95bd62eSPing-Ke Shih {
5186a95bd62eSPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5187a95bd62eSPing-Ke Shih 
5188a95bd62eSPing-Ke Shih 	chip->ops->fill_txdesc_fwcmd(rtwdev, desc_info, txdesc);
5189a95bd62eSPing-Ke Shih }
5190a95bd62eSPing-Ke Shih 
5191a95bd62eSPing-Ke Shih static inline
rtw89_chip_mac_cfg_gnt(struct rtw89_dev * rtwdev,const struct rtw89_mac_ax_coex_gnt * gnt_cfg)5192feed6541SChia-Yuan Li void rtw89_chip_mac_cfg_gnt(struct rtw89_dev *rtwdev,
5193feed6541SChia-Yuan Li 			    const struct rtw89_mac_ax_coex_gnt *gnt_cfg)
5194feed6541SChia-Yuan Li {
5195feed6541SChia-Yuan Li 	const struct rtw89_chip_info *chip = rtwdev->chip;
5196feed6541SChia-Yuan Li 
5197feed6541SChia-Yuan Li 	chip->ops->mac_cfg_gnt(rtwdev, gnt_cfg);
5198feed6541SChia-Yuan Li }
5199feed6541SChia-Yuan Li 
rtw89_chip_cfg_ctrl_path(struct rtw89_dev * rtwdev,bool wl)5200feed6541SChia-Yuan Li static inline void rtw89_chip_cfg_ctrl_path(struct rtw89_dev *rtwdev, bool wl)
5201feed6541SChia-Yuan Li {
5202feed6541SChia-Yuan Li 	const struct rtw89_chip_info *chip = rtwdev->chip;
5203feed6541SChia-Yuan Li 
5204feed6541SChia-Yuan Li 	chip->ops->cfg_ctrl_path(rtwdev, wl);
5205feed6541SChia-Yuan Li }
5206feed6541SChia-Yuan Li 
5207de7ba639SPing-Ke Shih static inline
rtw89_chip_stop_sch_tx(struct rtw89_dev * rtwdev,u8 mac_idx,u32 * tx_en,enum rtw89_sch_tx_sel sel)5208de7ba639SPing-Ke Shih int rtw89_chip_stop_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx,
5209de7ba639SPing-Ke Shih 			   u32 *tx_en, enum rtw89_sch_tx_sel sel)
5210de7ba639SPing-Ke Shih {
5211de7ba639SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5212de7ba639SPing-Ke Shih 
5213de7ba639SPing-Ke Shih 	return chip->ops->stop_sch_tx(rtwdev, mac_idx, tx_en, sel);
5214de7ba639SPing-Ke Shih }
5215de7ba639SPing-Ke Shih 
5216de7ba639SPing-Ke Shih static inline
rtw89_chip_resume_sch_tx(struct rtw89_dev * rtwdev,u8 mac_idx,u32 tx_en)5217de7ba639SPing-Ke Shih int rtw89_chip_resume_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en)
5218de7ba639SPing-Ke Shih {
5219de7ba639SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
5220de7ba639SPing-Ke Shih 
5221de7ba639SPing-Ke Shih 	return chip->ops->resume_sch_tx(rtwdev, mac_idx, tx_en);
5222de7ba639SPing-Ke Shih }
5223de7ba639SPing-Ke Shih 
52240a6f299bSPing-Ke Shih static inline
rtw89_chip_h2c_dctl_sec_cam(struct rtw89_dev * rtwdev,struct rtw89_vif * rtwvif,struct rtw89_sta * rtwsta)52250a6f299bSPing-Ke Shih int rtw89_chip_h2c_dctl_sec_cam(struct rtw89_dev *rtwdev,
52260a6f299bSPing-Ke Shih 				struct rtw89_vif *rtwvif,
52270a6f299bSPing-Ke Shih 				struct rtw89_sta *rtwsta)
52280a6f299bSPing-Ke Shih {
52290a6f299bSPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
52300a6f299bSPing-Ke Shih 
52310a6f299bSPing-Ke Shih 	if (!chip->ops->h2c_dctl_sec_cam)
52320a6f299bSPing-Ke Shih 		return 0;
52330a6f299bSPing-Ke Shih 	return chip->ops->h2c_dctl_sec_cam(rtwdev, rtwvif, rtwsta);
52340a6f299bSPing-Ke Shih }
52350a6f299bSPing-Ke Shih 
get_hdr_bssid(struct ieee80211_hdr * hdr)5236e3ec7017SPing-Ke Shih static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr)
5237e3ec7017SPing-Ke Shih {
5238e3ec7017SPing-Ke Shih 	__le16 fc = hdr->frame_control;
5239e3ec7017SPing-Ke Shih 
5240e3ec7017SPing-Ke Shih 	if (ieee80211_has_tods(fc))
5241e3ec7017SPing-Ke Shih 		return hdr->addr1;
5242e3ec7017SPing-Ke Shih 	else if (ieee80211_has_fromds(fc))
5243e3ec7017SPing-Ke Shih 		return hdr->addr2;
5244e3ec7017SPing-Ke Shih 	else
5245e3ec7017SPing-Ke Shih 		return hdr->addr3;
5246e3ec7017SPing-Ke Shih }
5247e3ec7017SPing-Ke Shih 
rtw89_sta_has_beamformer_cap(struct ieee80211_sta * sta)5248e3ec7017SPing-Ke Shih static inline bool rtw89_sta_has_beamformer_cap(struct ieee80211_sta *sta)
5249e3ec7017SPing-Ke Shih {
5250046d2e7cSSriram R 	if ((sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) ||
5251046d2e7cSSriram R 	    (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) ||
5252046d2e7cSSriram R 	    (sta->deflink.he_cap.he_cap_elem.phy_cap_info[3] &
5253046d2e7cSSriram R 			IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER) ||
5254046d2e7cSSriram R 	    (sta->deflink.he_cap.he_cap_elem.phy_cap_info[4] &
5255046d2e7cSSriram R 			IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER))
5256e3ec7017SPing-Ke Shih 		return true;
5257e3ec7017SPing-Ke Shih 	return false;
5258e3ec7017SPing-Ke Shih }
5259e3ec7017SPing-Ke Shih 
rtw89_fw_suit_get(struct rtw89_dev * rtwdev,enum rtw89_fw_type type)5260e3ec7017SPing-Ke Shih static inline struct rtw89_fw_suit *rtw89_fw_suit_get(struct rtw89_dev *rtwdev,
5261e3ec7017SPing-Ke Shih 						      enum rtw89_fw_type type)
5262e3ec7017SPing-Ke Shih {
5263e3ec7017SPing-Ke Shih 	struct rtw89_fw_info *fw_info = &rtwdev->fw;
5264e3ec7017SPing-Ke Shih 
52657d112665SPing-Ke Shih 	switch (type) {
52667d112665SPing-Ke Shih 	case RTW89_FW_WOWLAN:
5267e3ec7017SPing-Ke Shih 		return &fw_info->wowlan;
52687d112665SPing-Ke Shih 	case RTW89_FW_LOGFMT:
5269cad2bd8aSChin-Yen Lee 		return &fw_info->log.suit;
52707d112665SPing-Ke Shih 	case RTW89_FW_BBMCU0:
52717d112665SPing-Ke Shih 		return &fw_info->bbmcu0;
52727d112665SPing-Ke Shih 	case RTW89_FW_BBMCU1:
52737d112665SPing-Ke Shih 		return &fw_info->bbmcu1;
52747d112665SPing-Ke Shih 	default:
52757d112665SPing-Ke Shih 		break;
52767d112665SPing-Ke Shih 	}
52777d112665SPing-Ke Shih 
5278e3ec7017SPing-Ke Shih 	return &fw_info->normal;
5279e3ec7017SPing-Ke Shih }
5280e3ec7017SPing-Ke Shih 
rtw89_alloc_skb_for_rx(struct rtw89_dev * rtwdev,unsigned int length)528151e8ed4eSPing-Ke Shih static inline struct sk_buff *rtw89_alloc_skb_for_rx(struct rtw89_dev *rtwdev,
528251e8ed4eSPing-Ke Shih 						     unsigned int length)
528351e8ed4eSPing-Ke Shih {
528451e8ed4eSPing-Ke Shih 	struct sk_buff *skb;
528551e8ed4eSPing-Ke Shih 
528651e8ed4eSPing-Ke Shih 	if (rtwdev->hw->conf.flags & IEEE80211_CONF_MONITOR) {
528751e8ed4eSPing-Ke Shih 		skb = dev_alloc_skb(length + RTW89_RADIOTAP_ROOM);
528851e8ed4eSPing-Ke Shih 		if (!skb)
528951e8ed4eSPing-Ke Shih 			return NULL;
529051e8ed4eSPing-Ke Shih 
529151e8ed4eSPing-Ke Shih 		skb_reserve(skb, RTW89_RADIOTAP_ROOM);
529251e8ed4eSPing-Ke Shih 		return skb;
529351e8ed4eSPing-Ke Shih 	}
529451e8ed4eSPing-Ke Shih 
529551e8ed4eSPing-Ke Shih 	return dev_alloc_skb(length);
529651e8ed4eSPing-Ke Shih }
529751e8ed4eSPing-Ke Shih 
rtw89_core_tx_wait_complete(struct rtw89_dev * rtwdev,struct rtw89_tx_skb_data * skb_data,bool tx_done)52981ae5ca61SPo-Hao Huang static inline void rtw89_core_tx_wait_complete(struct rtw89_dev *rtwdev,
52991ae5ca61SPo-Hao Huang 					       struct rtw89_tx_skb_data *skb_data,
53001ae5ca61SPo-Hao Huang 					       bool tx_done)
53011ae5ca61SPo-Hao Huang {
53021ae5ca61SPo-Hao Huang 	struct rtw89_tx_wait_info *wait;
53031ae5ca61SPo-Hao Huang 
53041ae5ca61SPo-Hao Huang 	rcu_read_lock();
53051ae5ca61SPo-Hao Huang 
53061ae5ca61SPo-Hao Huang 	wait = rcu_dereference(skb_data->wait);
53071ae5ca61SPo-Hao Huang 	if (!wait)
53081ae5ca61SPo-Hao Huang 		goto out;
53091ae5ca61SPo-Hao Huang 
53101ae5ca61SPo-Hao Huang 	wait->tx_done = tx_done;
53111ae5ca61SPo-Hao Huang 	complete(&wait->completion);
53121ae5ca61SPo-Hao Huang 
53131ae5ca61SPo-Hao Huang out:
53141ae5ca61SPo-Hao Huang 	rcu_read_unlock();
53151ae5ca61SPo-Hao Huang }
53161ae5ca61SPo-Hao Huang 
5317e3ec7017SPing-Ke Shih int rtw89_core_tx_write(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif,
5318e3ec7017SPing-Ke Shih 			struct ieee80211_sta *sta, struct sk_buff *skb, int *qsel);
5319e3ec7017SPing-Ke Shih int rtw89_h2c_tx(struct rtw89_dev *rtwdev,
5320e3ec7017SPing-Ke Shih 		 struct sk_buff *skb, bool fwdl);
5321e3ec7017SPing-Ke Shih void rtw89_core_tx_kick_off(struct rtw89_dev *rtwdev, u8 qsel);
53221ae5ca61SPo-Hao Huang int rtw89_core_tx_kick_off_and_wait(struct rtw89_dev *rtwdev, struct sk_buff *skb,
53231ae5ca61SPo-Hao Huang 				    int qsel, unsigned int timeout);
5324e3ec7017SPing-Ke Shih void rtw89_core_fill_txdesc(struct rtw89_dev *rtwdev,
5325e3ec7017SPing-Ke Shih 			    struct rtw89_tx_desc_info *desc_info,
5326e3ec7017SPing-Ke Shih 			    void *txdesc);
5327f59acddeSPing-Ke Shih void rtw89_core_fill_txdesc_v1(struct rtw89_dev *rtwdev,
5328f59acddeSPing-Ke Shih 			       struct rtw89_tx_desc_info *desc_info,
5329f59acddeSPing-Ke Shih 			       void *txdesc);
5330a95bd62eSPing-Ke Shih void rtw89_core_fill_txdesc_fwcmd_v1(struct rtw89_dev *rtwdev,
5331a95bd62eSPing-Ke Shih 				     struct rtw89_tx_desc_info *desc_info,
5332a95bd62eSPing-Ke Shih 				     void *txdesc);
5333e3ec7017SPing-Ke Shih void rtw89_core_rx(struct rtw89_dev *rtwdev,
5334e3ec7017SPing-Ke Shih 		   struct rtw89_rx_desc_info *desc_info,
5335e3ec7017SPing-Ke Shih 		   struct sk_buff *skb);
5336e3ec7017SPing-Ke Shih void rtw89_core_query_rxdesc(struct rtw89_dev *rtwdev,
5337e3ec7017SPing-Ke Shih 			     struct rtw89_rx_desc_info *desc_info,
5338e3ec7017SPing-Ke Shih 			     u8 *data, u32 data_offset);
5339e3ec7017SPing-Ke Shih void rtw89_core_napi_start(struct rtw89_dev *rtwdev);
5340e3ec7017SPing-Ke Shih void rtw89_core_napi_stop(struct rtw89_dev *rtwdev);
5341e3ec7017SPing-Ke Shih void rtw89_core_napi_init(struct rtw89_dev *rtwdev);
5342e3ec7017SPing-Ke Shih void rtw89_core_napi_deinit(struct rtw89_dev *rtwdev);
5343e3ec7017SPing-Ke Shih int rtw89_core_sta_add(struct rtw89_dev *rtwdev,
5344e3ec7017SPing-Ke Shih 		       struct ieee80211_vif *vif,
5345e3ec7017SPing-Ke Shih 		       struct ieee80211_sta *sta);
5346e3ec7017SPing-Ke Shih int rtw89_core_sta_assoc(struct rtw89_dev *rtwdev,
5347e3ec7017SPing-Ke Shih 			 struct ieee80211_vif *vif,
5348e3ec7017SPing-Ke Shih 			 struct ieee80211_sta *sta);
5349e3ec7017SPing-Ke Shih int rtw89_core_sta_disassoc(struct rtw89_dev *rtwdev,
5350e3ec7017SPing-Ke Shih 			    struct ieee80211_vif *vif,
5351e3ec7017SPing-Ke Shih 			    struct ieee80211_sta *sta);
5352e3ec7017SPing-Ke Shih int rtw89_core_sta_disconnect(struct rtw89_dev *rtwdev,
5353e3ec7017SPing-Ke Shih 			      struct ieee80211_vif *vif,
5354e3ec7017SPing-Ke Shih 			      struct ieee80211_sta *sta);
5355e3ec7017SPing-Ke Shih int rtw89_core_sta_remove(struct rtw89_dev *rtwdev,
5356e3ec7017SPing-Ke Shih 			  struct ieee80211_vif *vif,
5357e3ec7017SPing-Ke Shih 			  struct ieee80211_sta *sta);
53583004a0a4SKuan-Chung Chen void rtw89_core_set_tid_config(struct rtw89_dev *rtwdev,
53593004a0a4SKuan-Chung Chen 			       struct ieee80211_sta *sta,
53603004a0a4SKuan-Chung Chen 			       struct cfg80211_tid_config *tid_config);
5361e3ec7017SPing-Ke Shih int rtw89_core_init(struct rtw89_dev *rtwdev);
5362e3ec7017SPing-Ke Shih void rtw89_core_deinit(struct rtw89_dev *rtwdev);
5363e3ec7017SPing-Ke Shih int rtw89_core_register(struct rtw89_dev *rtwdev);
5364e3ec7017SPing-Ke Shih void rtw89_core_unregister(struct rtw89_dev *rtwdev);
53657fc06a07SZong-Zhe Yang struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device,
53667fc06a07SZong-Zhe Yang 					   u32 bus_data_size,
53677fc06a07SZong-Zhe Yang 					   const struct rtw89_chip_info *chip);
53687fc06a07SZong-Zhe Yang void rtw89_free_ieee80211_hw(struct rtw89_dev *rtwdev);
5369967439c7SZong-Zhe Yang void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev);
5370a88b6cc4SZong-Zhe Yang void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef);
53714843aa37SZong-Zhe Yang void rtw89_get_channel_params(const struct cfg80211_chan_def *chandef,
53724843aa37SZong-Zhe Yang 			      struct rtw89_chan *chan);
5373e3ec7017SPing-Ke Shih void rtw89_set_channel(struct rtw89_dev *rtwdev);
5374e7399db2SPo-Hao Huang void rtw89_get_channel(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
5375e7399db2SPo-Hao Huang 		       struct rtw89_chan *chan);
5376e3ec7017SPing-Ke Shih u8 rtw89_core_acquire_bit_map(unsigned long *addr, unsigned long size);
5377e3ec7017SPing-Ke Shih void rtw89_core_release_bit_map(unsigned long *addr, u8 bit);
5378e3ec7017SPing-Ke Shih void rtw89_core_release_all_bits_map(unsigned long *addr, unsigned int nbits);
53792def7356SPing-Ke Shih int rtw89_core_acquire_sta_ba_entry(struct rtw89_dev *rtwdev,
53802def7356SPing-Ke Shih 				    struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx);
53812def7356SPing-Ke Shih int rtw89_core_release_sta_ba_entry(struct rtw89_dev *rtwdev,
53822def7356SPing-Ke Shih 				    struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx);
5383e3ec7017SPing-Ke Shih void rtw89_vif_type_mapping(struct ieee80211_vif *vif, bool assoc);
5384e3ec7017SPing-Ke Shih int rtw89_chip_info_setup(struct rtw89_dev *rtwdev);
53859a3a593cSPing-Ke Shih bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate);
5386a002f981SZong-Zhe Yang int rtw89_regd_setup(struct rtw89_dev *rtwdev);
5387e3ec7017SPing-Ke Shih int rtw89_regd_init(struct rtw89_dev *rtwdev,
5388e3ec7017SPing-Ke Shih 		    void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request));
5389e3ec7017SPing-Ke Shih void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
5390e3ec7017SPing-Ke Shih void rtw89_traffic_stats_init(struct rtw89_dev *rtwdev,
5391e3ec7017SPing-Ke Shih 			      struct rtw89_traffic_stats *stats);
539222b10cdbSZong-Zhe Yang int rtw89_wait_for_cond(struct rtw89_wait_info *wait, unsigned int cond);
539322b10cdbSZong-Zhe Yang void rtw89_complete_cond(struct rtw89_wait_info *wait, unsigned int cond,
539422b10cdbSZong-Zhe Yang 			 const struct rtw89_completion_data *data);
5395e3ec7017SPing-Ke Shih int rtw89_core_start(struct rtw89_dev *rtwdev);
5396e3ec7017SPing-Ke Shih void rtw89_core_stop(struct rtw89_dev *rtwdev);
5397d62816b4SPing-Ke Shih void rtw89_core_update_beacon_work(struct work_struct *work);
5398a0e97ae3SPo-Hao Huang void rtw89_roc_work(struct work_struct *work);
5399a0e97ae3SPo-Hao Huang void rtw89_roc_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif);
5400a0e97ae3SPo-Hao Huang void rtw89_roc_end(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif);
540189590777SPo Hao Huang void rtw89_core_scan_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
540289590777SPo Hao Huang 			   const u8 *mac_addr, bool hw_scan);
540389590777SPo Hao Huang void rtw89_core_scan_complete(struct rtw89_dev *rtwdev,
540489590777SPo Hao Huang 			      struct ieee80211_vif *vif, bool hw_scan);
5405f6baa1d3SZong-Zhe Yang void rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev,
5406f6baa1d3SZong-Zhe Yang 				 struct rtw89_vif *rtwvif, bool active);
540764a24cb6SZong-Zhe Yang void rtw89_core_ntfy_btc_event(struct rtw89_dev *rtwdev, enum rtw89_btc_hmsg event);
5408e3ec7017SPing-Ke Shih 
5409e3ec7017SPing-Ke Shih #endif
5410