1e3ec7017SPing-Ke Shih /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2e3ec7017SPing-Ke Shih /* Copyright(c) 2019-2020  Realtek Corporation
3e3ec7017SPing-Ke Shih  */
4e3ec7017SPing-Ke Shih 
5e3ec7017SPing-Ke Shih #ifndef __RTW89_CORE_H__
6e3ec7017SPing-Ke Shih #define __RTW89_CORE_H__
7e3ec7017SPing-Ke Shih 
8e3ec7017SPing-Ke Shih #include <linux/average.h>
9e3ec7017SPing-Ke Shih #include <linux/bitfield.h>
10e3ec7017SPing-Ke Shih #include <linux/firmware.h>
11e3ec7017SPing-Ke Shih #include <linux/iopoll.h>
12e3ec7017SPing-Ke Shih #include <linux/workqueue.h>
13e3ec7017SPing-Ke Shih #include <net/mac80211.h>
14e3ec7017SPing-Ke Shih 
15e3ec7017SPing-Ke Shih struct rtw89_dev;
164a9e48acSPing-Ke Shih struct rtw89_pci_info;
17e3ec7017SPing-Ke Shih 
18e3ec7017SPing-Ke Shih extern const struct ieee80211_ops rtw89_ops;
19e3ec7017SPing-Ke Shih 
20e3ec7017SPing-Ke Shih #define MASKBYTE0 0xff
21e3ec7017SPing-Ke Shih #define MASKBYTE1 0xff00
22e3ec7017SPing-Ke Shih #define MASKBYTE2 0xff0000
23e3ec7017SPing-Ke Shih #define MASKBYTE3 0xff000000
24e3ec7017SPing-Ke Shih #define MASKBYTE4 0xff00000000ULL
25e3ec7017SPing-Ke Shih #define MASKHWORD 0xffff0000
26e3ec7017SPing-Ke Shih #define MASKLWORD 0x0000ffff
27e3ec7017SPing-Ke Shih #define MASKDWORD 0xffffffff
28e3ec7017SPing-Ke Shih #define RFREG_MASK 0xfffff
29e3ec7017SPing-Ke Shih #define INV_RF_DATA 0xffffffff
30e3ec7017SPing-Ke Shih 
31e3ec7017SPing-Ke Shih #define RTW89_TRACK_WORK_PERIOD	round_jiffies_relative(HZ * 2)
32679955d5SKuan-Chung Chen #define RTW89_FORBID_BA_TIMER round_jiffies_relative(HZ * 4)
33e3ec7017SPing-Ke Shih #define CFO_TRACK_MAX_USER 64
34e3ec7017SPing-Ke Shih #define MAX_RSSI 110
35e3ec7017SPing-Ke Shih #define RSSI_FACTOR 1
36e3ec7017SPing-Ke Shih #define RTW89_RSSI_RAW_TO_DBM(rssi) ((s8)((rssi) >> RSSI_FACTOR) - MAX_RSSI)
37e3ec7017SPing-Ke Shih 
38e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_VARIANT GENMASK(1, 0)
39e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE 3
40e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_CTL_ID GENMASK(5, 2)
41e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE_CID_OM 1
42e3ec7017SPing-Ke Shih #define RTW89_HTC_VARIANT_HE_CID_CAS 6
43e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_CTL_INFO GENMASK(31, 6)
44e3ec7017SPing-Ke Shih 
45e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_RX_NSS GENMASK(8, 6)
46e3ec7017SPing-Ke Shih enum htc_om_channel_width {
47e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_20 = 0,
48e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_40 = 1,
49e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_80 = 2,
50e3ec7017SPing-Ke Shih 	HTC_OM_CHANNEL_WIDTH_160_OR_80_80 = 3,
51e3ec7017SPing-Ke Shih };
52e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_CH_WIDTH GENMASK(10, 9)
53e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_UL_MU_DIS BIT(11)
54e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_TX_NSTS GENMASK(14, 12)
55e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_ER_SU_DIS BIT(15)
56e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_DL_MU_MIMO_RR BIT(16)
57e3ec7017SPing-Ke Shih #define RTW89_HTC_MASK_HTC_OM_UL_MU_DATA_DIS BIT(17)
58e3ec7017SPing-Ke Shih 
595165f168SPo Hao Huang #define RTW89_TF_PAD GENMASK(11, 0)
605165f168SPo Hao Huang #define RTW89_TF_BASIC_USER_INFO_SZ 6
615165f168SPo Hao Huang 
625165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_AID12(data)	\
635165f168SPo Hao Huang 	le32_get_bits(*((const __le32 *)(data)), GENMASK(11, 0))
645165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_RUA(data)	\
655165f168SPo Hao Huang 	le32_get_bits(*((const __le32 *)(data)), GENMASK(19, 12))
665165f168SPo Hao Huang #define RTW89_GET_TF_USER_INFO_UL_MCS(data)	\
675165f168SPo Hao Huang 	le32_get_bits(*((const __le32 *)(data)), GENMASK(24, 21))
685165f168SPo Hao Huang 
69e3ec7017SPing-Ke Shih enum rtw89_subband {
70e3ec7017SPing-Ke Shih 	RTW89_CH_2G = 0,
71e3ec7017SPing-Ke Shih 	RTW89_CH_5G_BAND_1 = 1,
72e3ec7017SPing-Ke Shih 	/* RTW89_CH_5G_BAND_2 = 2, unused */
73e3ec7017SPing-Ke Shih 	RTW89_CH_5G_BAND_3 = 3,
74e3ec7017SPing-Ke Shih 	RTW89_CH_5G_BAND_4 = 4,
75e3ec7017SPing-Ke Shih 
768e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX0, /* Low */
778e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX1, /* Low */
788e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX2, /* Mid */
798e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX3, /* Mid */
808e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX4, /* High */
818e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX5, /* High */
828e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX6, /* Ultra-high */
838e438ad4SZong-Zhe Yang 	RTW89_CH_6G_BAND_IDX7, /* Ultra-high */
848e438ad4SZong-Zhe Yang 
85e3ec7017SPing-Ke Shih 	RTW89_SUBBAND_NR,
86e3ec7017SPing-Ke Shih };
87e3ec7017SPing-Ke Shih 
88e6b17cbdSPing-Ke Shih enum rtw89_gain_offset {
89e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_2G_CCK,
90e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_2G_OFDM,
91e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_5G_LOW,
92e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_5G_MID,
93e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_5G_HIGH,
94e6b17cbdSPing-Ke Shih 
95e6b17cbdSPing-Ke Shih 	RTW89_GAIN_OFFSET_NR,
96e6b17cbdSPing-Ke Shih };
97e6b17cbdSPing-Ke Shih 
98e3ec7017SPing-Ke Shih enum rtw89_hci_type {
99e3ec7017SPing-Ke Shih 	RTW89_HCI_TYPE_PCIE,
100e3ec7017SPing-Ke Shih 	RTW89_HCI_TYPE_USB,
101e3ec7017SPing-Ke Shih 	RTW89_HCI_TYPE_SDIO,
102e3ec7017SPing-Ke Shih };
103e3ec7017SPing-Ke Shih 
104e3ec7017SPing-Ke Shih enum rtw89_core_chip_id {
105e3ec7017SPing-Ke Shih 	RTL8852A,
106e3ec7017SPing-Ke Shih 	RTL8852B,
107e3ec7017SPing-Ke Shih 	RTL8852C,
108e3ec7017SPing-Ke Shih };
109e3ec7017SPing-Ke Shih 
110e3ec7017SPing-Ke Shih enum rtw89_cv {
111e3ec7017SPing-Ke Shih 	CHIP_CAV,
112e3ec7017SPing-Ke Shih 	CHIP_CBV,
113e3ec7017SPing-Ke Shih 	CHIP_CCV,
114e3ec7017SPing-Ke Shih 	CHIP_CDV,
115e3ec7017SPing-Ke Shih 	CHIP_CEV,
116e3ec7017SPing-Ke Shih 	CHIP_CFV,
117e3ec7017SPing-Ke Shih 	CHIP_CV_MAX,
118e3ec7017SPing-Ke Shih 	CHIP_CV_INVALID = CHIP_CV_MAX,
119e3ec7017SPing-Ke Shih };
120e3ec7017SPing-Ke Shih 
121e3ec7017SPing-Ke Shih enum rtw89_core_tx_type {
122e3ec7017SPing-Ke Shih 	RTW89_CORE_TX_TYPE_DATA,
123e3ec7017SPing-Ke Shih 	RTW89_CORE_TX_TYPE_MGMT,
124e3ec7017SPing-Ke Shih 	RTW89_CORE_TX_TYPE_FWCMD,
125e3ec7017SPing-Ke Shih };
126e3ec7017SPing-Ke Shih 
127e3ec7017SPing-Ke Shih enum rtw89_core_rx_type {
128e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_WIFI		= 0,
129e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_PPDU_STAT	= 1,
130e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_CHAN_INFO	= 2,
131e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_BB_SCOPE	= 3,
132e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_F2P_TXCMD	= 4,
133e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_SS2FW	= 5,
134e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_TX_REPORT	= 6,
135e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_TX_REL_HOST	= 7,
136e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_DFS_REPORT	= 8,
137e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_TX_REL_CPU	= 9,
138e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_C2H		= 10,
139e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_CSI		= 11,
140e3ec7017SPing-Ke Shih 	RTW89_CORE_RX_TYPE_CQI		= 12,
141a95bd62eSPing-Ke Shih 	RTW89_CORE_RX_TYPE_H2C		= 13,
142a95bd62eSPing-Ke Shih 	RTW89_CORE_RX_TYPE_FWDL		= 14,
143e3ec7017SPing-Ke Shih };
144e3ec7017SPing-Ke Shih 
145e3ec7017SPing-Ke Shih enum rtw89_txq_flags {
146e3ec7017SPing-Ke Shih 	RTW89_TXQ_F_AMPDU		= 0,
147e3ec7017SPing-Ke Shih 	RTW89_TXQ_F_BLOCK_BA		= 1,
148679955d5SKuan-Chung Chen 	RTW89_TXQ_F_FORBID_BA		= 2,
149e3ec7017SPing-Ke Shih };
150e3ec7017SPing-Ke Shih 
151e3ec7017SPing-Ke Shih enum rtw89_net_type {
152e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_NO_LINK		= 0,
153e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_AD_HOC		= 1,
154e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_INFRA		= 2,
155e3ec7017SPing-Ke Shih 	RTW89_NET_TYPE_AP_MODE		= 3,
156e3ec7017SPing-Ke Shih };
157e3ec7017SPing-Ke Shih 
158e3ec7017SPing-Ke Shih enum rtw89_wifi_role {
159e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_NONE,
160e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_STATION,
161e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_AP,
162e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_AP_VLAN,
163e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_ADHOC,
164e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_ADHOC_MASTER,
165e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_MESH_POINT,
166e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_MONITOR,
167e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_P2P_DEVICE,
168e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_P2P_CLIENT,
169e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_P2P_GO,
170e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_NAN,
171e3ec7017SPing-Ke Shih 	RTW89_WIFI_ROLE_MLME_MAX
172e3ec7017SPing-Ke Shih };
173e3ec7017SPing-Ke Shih 
174e3ec7017SPing-Ke Shih enum rtw89_upd_mode {
1758b252070SPing-Ke Shih 	RTW89_ROLE_CREATE,
1768b252070SPing-Ke Shih 	RTW89_ROLE_REMOVE,
1778b252070SPing-Ke Shih 	RTW89_ROLE_TYPE_CHANGE,
1788b252070SPing-Ke Shih 	RTW89_ROLE_INFO_CHANGE,
1798b252070SPing-Ke Shih 	RTW89_ROLE_CON_DISCONN
180e3ec7017SPing-Ke Shih };
181e3ec7017SPing-Ke Shih 
182e3ec7017SPing-Ke Shih enum rtw89_self_role {
183e3ec7017SPing-Ke Shih 	RTW89_SELF_ROLE_CLIENT,
184e3ec7017SPing-Ke Shih 	RTW89_SELF_ROLE_AP,
185e3ec7017SPing-Ke Shih 	RTW89_SELF_ROLE_AP_CLIENT
186e3ec7017SPing-Ke Shih };
187e3ec7017SPing-Ke Shih 
188e3ec7017SPing-Ke Shih enum rtw89_msk_sO_el {
189e3ec7017SPing-Ke Shih 	RTW89_NO_MSK,
190e3ec7017SPing-Ke Shih 	RTW89_SMA,
191e3ec7017SPing-Ke Shih 	RTW89_TMA,
192e3ec7017SPing-Ke Shih 	RTW89_BSSID
193e3ec7017SPing-Ke Shih };
194e3ec7017SPing-Ke Shih 
195e3ec7017SPing-Ke Shih enum rtw89_sch_tx_sel {
196e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_ALL,
197e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_HIQ,
198e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_MG0,
199e3ec7017SPing-Ke Shih 	RTW89_SCH_TX_SEL_MACID,
200e3ec7017SPing-Ke Shih };
201e3ec7017SPing-Ke Shih 
202e3ec7017SPing-Ke Shih /* RTW89_ADDR_CAM_SEC_NONE	: not enabled
203e3ec7017SPing-Ke Shih  * RTW89_ADDR_CAM_SEC_ALL_UNI	: 0 - 6 unicast
204e3ec7017SPing-Ke Shih  * RTW89_ADDR_CAM_SEC_NORMAL	: 0 - 1 unicast, 2 - 4 group, 5 - 6 BIP
205e3ec7017SPing-Ke Shih  * RTW89_ADDR_CAM_SEC_4GROUP	: 0 - 1 unicast, 2 - 5 group, 6 BIP
206e3ec7017SPing-Ke Shih  */
207e3ec7017SPing-Ke Shih enum rtw89_add_cam_sec_mode {
208e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_NONE		= 0,
209e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_ALL_UNI	= 1,
210e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_NORMAL	= 2,
211e3ec7017SPing-Ke Shih 	RTW89_ADDR_CAM_SEC_4GROUP	= 3,
212e3ec7017SPing-Ke Shih };
213e3ec7017SPing-Ke Shih 
214e3ec7017SPing-Ke Shih enum rtw89_sec_key_type {
215e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_NONE		= 0,
216e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_WEP40	= 1,
217e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_WEP104	= 2,
218e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_TKIP		= 3,
219e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_WAPI		= 4,
220e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_GCMSMS4	= 5,
221e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_CCMP128	= 6,
222e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_CCMP256	= 7,
223e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_GCMP128	= 8,
224e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_GCMP256	= 9,
225e3ec7017SPing-Ke Shih 	RTW89_SEC_KEY_TYPE_BIP_CCMP128	= 10,
226e3ec7017SPing-Ke Shih };
227e3ec7017SPing-Ke Shih 
228e3ec7017SPing-Ke Shih enum rtw89_port {
229e3ec7017SPing-Ke Shih 	RTW89_PORT_0 = 0,
230e3ec7017SPing-Ke Shih 	RTW89_PORT_1 = 1,
231e3ec7017SPing-Ke Shih 	RTW89_PORT_2 = 2,
232e3ec7017SPing-Ke Shih 	RTW89_PORT_3 = 3,
233e3ec7017SPing-Ke Shih 	RTW89_PORT_4 = 4,
234e3ec7017SPing-Ke Shih 	RTW89_PORT_NUM
235e3ec7017SPing-Ke Shih };
236e3ec7017SPing-Ke Shih 
237e3ec7017SPing-Ke Shih enum rtw89_band {
238e3ec7017SPing-Ke Shih 	RTW89_BAND_2G = 0,
239e3ec7017SPing-Ke Shih 	RTW89_BAND_5G = 1,
2400237f65aSZong-Zhe Yang 	RTW89_BAND_6G = 2,
241e3ec7017SPing-Ke Shih 	RTW89_BAND_MAX,
242e3ec7017SPing-Ke Shih };
243e3ec7017SPing-Ke Shih 
244e3ec7017SPing-Ke Shih enum rtw89_hw_rate {
245e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK1	= 0x0,
246e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK2	= 0x1,
247e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK5_5	= 0x2,
248e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_CCK11	= 0x3,
249e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM6	= 0x4,
250e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM9	= 0x5,
251e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM12	= 0x6,
252e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM18	= 0x7,
253e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM24	= 0x8,
254e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM36	= 0x9,
255e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM48	= 0xA,
256e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_OFDM54	= 0xB,
257e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS0	= 0x80,
258e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS1	= 0x81,
259e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS2	= 0x82,
260e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS3	= 0x83,
261e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS4	= 0x84,
262e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS5	= 0x85,
263e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS6	= 0x86,
264e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS7	= 0x87,
265e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS8	= 0x88,
266e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS9	= 0x89,
267e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS10	= 0x8A,
268e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS11	= 0x8B,
269e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS12	= 0x8C,
270e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS13	= 0x8D,
271e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS14	= 0x8E,
272e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS15	= 0x8F,
273e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS16	= 0x90,
274e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS17	= 0x91,
275e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS18	= 0x92,
276e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS19	= 0x93,
277e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS20	= 0x94,
278e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS21	= 0x95,
279e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS22	= 0x96,
280e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS23	= 0x97,
281e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS24	= 0x98,
282e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS25	= 0x99,
283e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS26	= 0x9A,
284e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS27	= 0x9B,
285e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS28	= 0x9C,
286e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS29	= 0x9D,
287e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS30	= 0x9E,
288e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MCS31	= 0x9F,
289e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS0	= 0x100,
290e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS1	= 0x101,
291e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS2	= 0x102,
292e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS3	= 0x103,
293e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS4	= 0x104,
294e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS5	= 0x105,
295e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS6	= 0x106,
296e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS7	= 0x107,
297e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS8	= 0x108,
298e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS1_MCS9	= 0x109,
299e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS0	= 0x110,
300e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS1	= 0x111,
301e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS2	= 0x112,
302e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS3	= 0x113,
303e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS4	= 0x114,
304e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS5	= 0x115,
305e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS6	= 0x116,
306e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS7	= 0x117,
307e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS8	= 0x118,
308e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS2_MCS9	= 0x119,
309e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS0	= 0x120,
310e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS1	= 0x121,
311e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS2	= 0x122,
312e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS3	= 0x123,
313e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS4	= 0x124,
314e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS5	= 0x125,
315e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS6	= 0x126,
316e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS7	= 0x127,
317e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS8	= 0x128,
318e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS3_MCS9	= 0x129,
319e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS0	= 0x130,
320e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS1	= 0x131,
321e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS2	= 0x132,
322e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS3	= 0x133,
323e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS4	= 0x134,
324e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS5	= 0x135,
325e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS6	= 0x136,
326e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS7	= 0x137,
327e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS8	= 0x138,
328e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_VHT_NSS4_MCS9	= 0x139,
329e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS0	= 0x180,
330e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS1	= 0x181,
331e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS2	= 0x182,
332e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS3	= 0x183,
333e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS4	= 0x184,
334e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS5	= 0x185,
335e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS6	= 0x186,
336e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS7	= 0x187,
337e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS8	= 0x188,
338e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS9	= 0x189,
339e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS10	= 0x18A,
340e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS1_MCS11	= 0x18B,
341e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS0	= 0x190,
342e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS1	= 0x191,
343e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS2	= 0x192,
344e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS3	= 0x193,
345e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS4	= 0x194,
346e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS5	= 0x195,
347e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS6	= 0x196,
348e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS7	= 0x197,
349e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS8	= 0x198,
350e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS9	= 0x199,
351e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS10	= 0x19A,
352e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS2_MCS11	= 0x19B,
353e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS0	= 0x1A0,
354e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS1	= 0x1A1,
355e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS2	= 0x1A2,
356e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS3	= 0x1A3,
357e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS4	= 0x1A4,
358e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS5	= 0x1A5,
359e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS6	= 0x1A6,
360e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS7	= 0x1A7,
361e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS8	= 0x1A8,
362e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS9	= 0x1A9,
363e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS10	= 0x1AA,
364e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS3_MCS11	= 0x1AB,
365e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS0	= 0x1B0,
366e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS1	= 0x1B1,
367e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS2	= 0x1B2,
368e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS3	= 0x1B3,
369e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS4	= 0x1B4,
370e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS5	= 0x1B5,
371e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS6	= 0x1B6,
372e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS7	= 0x1B7,
373e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS8	= 0x1B8,
374e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS9	= 0x1B9,
375e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS10	= 0x1BA,
376e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_HE_NSS4_MCS11	= 0x1BB,
377e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_NR,
378e3ec7017SPing-Ke Shih 
379e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MASK_MOD = GENMASK(8, 7),
380e3ec7017SPing-Ke Shih 	RTW89_HW_RATE_MASK_VAL = GENMASK(6, 0),
381e3ec7017SPing-Ke Shih };
382e3ec7017SPing-Ke Shih 
383e3ec7017SPing-Ke Shih /* 2G channels,
384e3ec7017SPing-Ke Shih  * 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
385e3ec7017SPing-Ke Shih  */
386e3ec7017SPing-Ke Shih #define RTW89_2G_CH_NUM 14
387e3ec7017SPing-Ke Shih 
388e3ec7017SPing-Ke Shih /* 5G channels,
389e3ec7017SPing-Ke Shih  * 36, 38, 40, 42, 44, 46, 48, 50,
390e3ec7017SPing-Ke Shih  * 52, 54, 56, 58, 60, 62, 64,
391e3ec7017SPing-Ke Shih  * 100, 102, 104, 106, 108, 110, 112, 114,
392e3ec7017SPing-Ke Shih  * 116, 118, 120, 122, 124, 126, 128, 130,
393e3ec7017SPing-Ke Shih  * 132, 134, 136, 138, 140, 142, 144,
394e3ec7017SPing-Ke Shih  * 149, 151, 153, 155, 157, 159, 161, 163,
395e3ec7017SPing-Ke Shih  * 165, 167, 169, 171, 173, 175, 177
396e3ec7017SPing-Ke Shih  */
397e3ec7017SPing-Ke Shih #define RTW89_5G_CH_NUM 53
398e3ec7017SPing-Ke Shih 
399ac74f016SZong-Zhe Yang /* 6G channels,
400ac74f016SZong-Zhe Yang  * 1, 3, 5, 7, 9, 11, 13, 15,
401ac74f016SZong-Zhe Yang  * 17, 19, 21, 23, 25, 27, 29, 33,
402ac74f016SZong-Zhe Yang  * 35, 37, 39, 41, 43, 45, 47, 49,
403ac74f016SZong-Zhe Yang  * 51, 53, 55, 57, 59, 61, 65, 67,
404ac74f016SZong-Zhe Yang  * 69, 71, 73, 75, 77, 79, 81, 83,
405ac74f016SZong-Zhe Yang  * 85, 87, 89, 91, 93, 97, 99, 101,
406ac74f016SZong-Zhe Yang  * 103, 105, 107, 109, 111, 113, 115, 117,
407ac74f016SZong-Zhe Yang  * 119, 121, 123, 125, 129, 131, 133, 135,
408ac74f016SZong-Zhe Yang  * 137, 139, 141, 143, 145, 147, 149, 151,
409ac74f016SZong-Zhe Yang  * 153, 155, 157, 161, 163, 165, 167, 169,
410ac74f016SZong-Zhe Yang  * 171, 173, 175, 177, 179, 181, 183, 185,
411ac74f016SZong-Zhe Yang  * 187, 189, 193, 195, 197, 199, 201, 203,
412ac74f016SZong-Zhe Yang  * 205, 207, 209, 211, 213, 215, 217, 219,
413ac74f016SZong-Zhe Yang  * 221, 225, 227, 229, 231, 233, 235, 237,
414ac74f016SZong-Zhe Yang  * 239, 241, 243, 245, 247, 249, 251, 253,
415ac74f016SZong-Zhe Yang  */
416ac74f016SZong-Zhe Yang #define RTW89_6G_CH_NUM 120
417ac74f016SZong-Zhe Yang 
418e3ec7017SPing-Ke Shih enum rtw89_rate_section {
419e3ec7017SPing-Ke Shih 	RTW89_RS_CCK,
420e3ec7017SPing-Ke Shih 	RTW89_RS_OFDM,
421e3ec7017SPing-Ke Shih 	RTW89_RS_MCS, /* for HT/VHT/HE */
422e3ec7017SPing-Ke Shih 	RTW89_RS_HEDCM,
423e3ec7017SPing-Ke Shih 	RTW89_RS_OFFSET,
424e3ec7017SPing-Ke Shih 	RTW89_RS_MAX,
425e3ec7017SPing-Ke Shih 	RTW89_RS_LMT_NUM = RTW89_RS_MCS + 1,
426342475acSPing-Ke Shih 	RTW89_RS_TX_SHAPE_NUM = RTW89_RS_OFDM + 1,
427e3ec7017SPing-Ke Shih };
428e3ec7017SPing-Ke Shih 
429e3ec7017SPing-Ke Shih enum rtw89_rate_max {
430e3ec7017SPing-Ke Shih 	RTW89_RATE_CCK_MAX	= 4,
431e3ec7017SPing-Ke Shih 	RTW89_RATE_OFDM_MAX	= 8,
432e3ec7017SPing-Ke Shih 	RTW89_RATE_MCS_MAX	= 12,
433e3ec7017SPing-Ke Shih 	RTW89_RATE_HEDCM_MAX	= 4, /* for HEDCM MCS0/1/3/4 */
434e3ec7017SPing-Ke Shih 	RTW89_RATE_OFFSET_MAX	= 5, /* for HE(HEDCM)/VHT/HT/OFDM/CCK offset */
435e3ec7017SPing-Ke Shih };
436e3ec7017SPing-Ke Shih 
437e3ec7017SPing-Ke Shih enum rtw89_nss {
438e3ec7017SPing-Ke Shih 	RTW89_NSS_1		= 0,
439e3ec7017SPing-Ke Shih 	RTW89_NSS_2		= 1,
440e3ec7017SPing-Ke Shih 	/* HE DCM only support 1ss and 2ss */
441e3ec7017SPing-Ke Shih 	RTW89_NSS_HEDCM_MAX	= RTW89_NSS_2 + 1,
442e3ec7017SPing-Ke Shih 	RTW89_NSS_3		= 2,
443e3ec7017SPing-Ke Shih 	RTW89_NSS_4		= 3,
444e3ec7017SPing-Ke Shih 	RTW89_NSS_MAX,
445e3ec7017SPing-Ke Shih };
446e3ec7017SPing-Ke Shih 
447e3ec7017SPing-Ke Shih enum rtw89_ntx {
448e3ec7017SPing-Ke Shih 	RTW89_1TX	= 0,
449e3ec7017SPing-Ke Shih 	RTW89_2TX	= 1,
450e3ec7017SPing-Ke Shih 	RTW89_NTX_NUM,
451e3ec7017SPing-Ke Shih };
452e3ec7017SPing-Ke Shih 
453e3ec7017SPing-Ke Shih enum rtw89_beamforming_type {
454e3ec7017SPing-Ke Shih 	RTW89_NONBF	= 0,
455e3ec7017SPing-Ke Shih 	RTW89_BF	= 1,
456e3ec7017SPing-Ke Shih 	RTW89_BF_NUM,
457e3ec7017SPing-Ke Shih };
458e3ec7017SPing-Ke Shih 
459e3ec7017SPing-Ke Shih enum rtw89_regulation_type {
460e3ec7017SPing-Ke Shih 	RTW89_WW	= 0,
461e3ec7017SPing-Ke Shih 	RTW89_ETSI	= 1,
462e3ec7017SPing-Ke Shih 	RTW89_FCC	= 2,
463e3ec7017SPing-Ke Shih 	RTW89_MKK	= 3,
464e3ec7017SPing-Ke Shih 	RTW89_NA	= 4,
465e3ec7017SPing-Ke Shih 	RTW89_IC	= 5,
466e3ec7017SPing-Ke Shih 	RTW89_KCC	= 6,
46754257714SZong-Zhe Yang 	RTW89_ACMA	= 7,
46854257714SZong-Zhe Yang 	RTW89_NCC	= 8,
46954257714SZong-Zhe Yang 	RTW89_MEXICO	= 9,
47054257714SZong-Zhe Yang 	RTW89_CHILE	= 10,
471e3ec7017SPing-Ke Shih 	RTW89_UKRAINE	= 11,
472e3ec7017SPing-Ke Shih 	RTW89_CN	= 12,
47354257714SZong-Zhe Yang 	RTW89_QATAR	= 13,
4745a0e776bSZong-Zhe Yang 	RTW89_UK	= 14,
475e3ec7017SPing-Ke Shih 	RTW89_REGD_NUM,
476e3ec7017SPing-Ke Shih };
477e3ec7017SPing-Ke Shih 
478e3ec7017SPing-Ke Shih struct rtw89_txpwr_byrate {
479e3ec7017SPing-Ke Shih 	s8 cck[RTW89_RATE_CCK_MAX];
480e3ec7017SPing-Ke Shih 	s8 ofdm[RTW89_RATE_OFDM_MAX];
481e3ec7017SPing-Ke Shih 	s8 mcs[RTW89_NSS_MAX][RTW89_RATE_MCS_MAX];
482e3ec7017SPing-Ke Shih 	s8 hedcm[RTW89_NSS_HEDCM_MAX][RTW89_RATE_HEDCM_MAX];
483e3ec7017SPing-Ke Shih 	s8 offset[RTW89_RATE_OFFSET_MAX];
484e3ec7017SPing-Ke Shih };
485e3ec7017SPing-Ke Shih 
486e3ec7017SPing-Ke Shih enum rtw89_bandwidth_section_num {
487e3ec7017SPing-Ke Shih 	RTW89_BW20_SEC_NUM = 8,
488e3ec7017SPing-Ke Shih 	RTW89_BW40_SEC_NUM = 4,
489e3ec7017SPing-Ke Shih 	RTW89_BW80_SEC_NUM = 2,
490e3ec7017SPing-Ke Shih };
491e3ec7017SPing-Ke Shih 
492e3ec7017SPing-Ke Shih struct rtw89_txpwr_limit {
493e3ec7017SPing-Ke Shih 	s8 cck_20m[RTW89_BF_NUM];
494e3ec7017SPing-Ke Shih 	s8 cck_40m[RTW89_BF_NUM];
495e3ec7017SPing-Ke Shih 	s8 ofdm[RTW89_BF_NUM];
496e3ec7017SPing-Ke Shih 	s8 mcs_20m[RTW89_BW20_SEC_NUM][RTW89_BF_NUM];
497e3ec7017SPing-Ke Shih 	s8 mcs_40m[RTW89_BW40_SEC_NUM][RTW89_BF_NUM];
498e3ec7017SPing-Ke Shih 	s8 mcs_80m[RTW89_BW80_SEC_NUM][RTW89_BF_NUM];
499e3ec7017SPing-Ke Shih 	s8 mcs_160m[RTW89_BF_NUM];
500e3ec7017SPing-Ke Shih 	s8 mcs_40m_0p5[RTW89_BF_NUM];
501e3ec7017SPing-Ke Shih 	s8 mcs_40m_2p5[RTW89_BF_NUM];
502e3ec7017SPing-Ke Shih };
503e3ec7017SPing-Ke Shih 
504e3ec7017SPing-Ke Shih #define RTW89_RU_SEC_NUM 8
505e3ec7017SPing-Ke Shih 
506e3ec7017SPing-Ke Shih struct rtw89_txpwr_limit_ru {
507e3ec7017SPing-Ke Shih 	s8 ru26[RTW89_RU_SEC_NUM];
508e3ec7017SPing-Ke Shih 	s8 ru52[RTW89_RU_SEC_NUM];
509e3ec7017SPing-Ke Shih 	s8 ru106[RTW89_RU_SEC_NUM];
510e3ec7017SPing-Ke Shih };
511e3ec7017SPing-Ke Shih 
512e3ec7017SPing-Ke Shih struct rtw89_rate_desc {
513e3ec7017SPing-Ke Shih 	enum rtw89_nss nss;
514e3ec7017SPing-Ke Shih 	enum rtw89_rate_section rs;
515e3ec7017SPing-Ke Shih 	u8 idx;
516e3ec7017SPing-Ke Shih };
517e3ec7017SPing-Ke Shih 
518e3ec7017SPing-Ke Shih #define PHY_STS_HDR_LEN 8
519e3ec7017SPing-Ke Shih #define RF_PATH_MAX 4
520e3ec7017SPing-Ke Shih #define RTW89_MAX_PPDU_CNT 8
521e3ec7017SPing-Ke Shih struct rtw89_rx_phy_ppdu {
522e3ec7017SPing-Ke Shih 	u8 *buf;
523e3ec7017SPing-Ke Shih 	u32 len;
524e3ec7017SPing-Ke Shih 	u8 rssi_avg;
525e3ec7017SPing-Ke Shih 	s8 rssi[RF_PATH_MAX];
526e3ec7017SPing-Ke Shih 	u8 mac_id;
527eb4e52b3SPo Hao Huang 	u8 chan_idx;
528eb4e52b3SPo Hao Huang 	u8 ie;
529eb4e52b3SPo Hao Huang 	u16 rate;
530e3ec7017SPing-Ke Shih 	bool to_self;
531e3ec7017SPing-Ke Shih 	bool valid;
532e3ec7017SPing-Ke Shih };
533e3ec7017SPing-Ke Shih 
534e3ec7017SPing-Ke Shih enum rtw89_mac_idx {
535e3ec7017SPing-Ke Shih 	RTW89_MAC_0 = 0,
536e3ec7017SPing-Ke Shih 	RTW89_MAC_1 = 1,
537e3ec7017SPing-Ke Shih };
538e3ec7017SPing-Ke Shih 
539e3ec7017SPing-Ke Shih enum rtw89_phy_idx {
540e3ec7017SPing-Ke Shih 	RTW89_PHY_0 = 0,
541e3ec7017SPing-Ke Shih 	RTW89_PHY_1 = 1,
542e3ec7017SPing-Ke Shih 	RTW89_PHY_MAX
543e3ec7017SPing-Ke Shih };
544e3ec7017SPing-Ke Shih 
545cbb145b9SZong-Zhe Yang enum rtw89_sub_entity_idx {
546cbb145b9SZong-Zhe Yang 	RTW89_SUB_ENTITY_0 = 0,
547cbb145b9SZong-Zhe Yang 
548cbb145b9SZong-Zhe Yang 	NUM_OF_RTW89_SUB_ENTITY,
549cbb145b9SZong-Zhe Yang };
550cbb145b9SZong-Zhe Yang 
551e3ec7017SPing-Ke Shih enum rtw89_rf_path {
552e3ec7017SPing-Ke Shih 	RF_PATH_A = 0,
553e3ec7017SPing-Ke Shih 	RF_PATH_B = 1,
554e3ec7017SPing-Ke Shih 	RF_PATH_C = 2,
555e3ec7017SPing-Ke Shih 	RF_PATH_D = 3,
556e3ec7017SPing-Ke Shih 	RF_PATH_AB,
557e3ec7017SPing-Ke Shih 	RF_PATH_AC,
558e3ec7017SPing-Ke Shih 	RF_PATH_AD,
559e3ec7017SPing-Ke Shih 	RF_PATH_BC,
560e3ec7017SPing-Ke Shih 	RF_PATH_BD,
561e3ec7017SPing-Ke Shih 	RF_PATH_CD,
562e3ec7017SPing-Ke Shih 	RF_PATH_ABC,
563e3ec7017SPing-Ke Shih 	RF_PATH_ABD,
564e3ec7017SPing-Ke Shih 	RF_PATH_ACD,
565e3ec7017SPing-Ke Shih 	RF_PATH_BCD,
566e3ec7017SPing-Ke Shih 	RF_PATH_ABCD,
567e3ec7017SPing-Ke Shih };
568e3ec7017SPing-Ke Shih 
569e3ec7017SPing-Ke Shih enum rtw89_rf_path_bit {
570e3ec7017SPing-Ke Shih 	RF_A	= BIT(0),
571e3ec7017SPing-Ke Shih 	RF_B	= BIT(1),
572e3ec7017SPing-Ke Shih 	RF_C	= BIT(2),
573e3ec7017SPing-Ke Shih 	RF_D	= BIT(3),
574e3ec7017SPing-Ke Shih 
575e3ec7017SPing-Ke Shih 	RF_AB	= (RF_A | RF_B),
576e3ec7017SPing-Ke Shih 	RF_AC	= (RF_A | RF_C),
577e3ec7017SPing-Ke Shih 	RF_AD	= (RF_A | RF_D),
578e3ec7017SPing-Ke Shih 	RF_BC	= (RF_B | RF_C),
579e3ec7017SPing-Ke Shih 	RF_BD	= (RF_B | RF_D),
580e3ec7017SPing-Ke Shih 	RF_CD	= (RF_C | RF_D),
581e3ec7017SPing-Ke Shih 
582e3ec7017SPing-Ke Shih 	RF_ABC	= (RF_A | RF_B | RF_C),
583e3ec7017SPing-Ke Shih 	RF_ABD	= (RF_A | RF_B | RF_D),
584e3ec7017SPing-Ke Shih 	RF_ACD	= (RF_A | RF_C | RF_D),
585e3ec7017SPing-Ke Shih 	RF_BCD	= (RF_B | RF_C | RF_D),
586e3ec7017SPing-Ke Shih 
587e3ec7017SPing-Ke Shih 	RF_ABCD	= (RF_A | RF_B | RF_C | RF_D),
588e3ec7017SPing-Ke Shih };
589e3ec7017SPing-Ke Shih 
590e3ec7017SPing-Ke Shih enum rtw89_bandwidth {
591e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_20	= 0,
592e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_40	= 1,
593e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_80	= 2,
594e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_160	= 3,
595e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_80_80	= 4,
596e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_5	= 5,
597e3ec7017SPing-Ke Shih 	RTW89_CHANNEL_WIDTH_10	= 6,
598e3ec7017SPing-Ke Shih };
599e3ec7017SPing-Ke Shih 
600e3ec7017SPing-Ke Shih enum rtw89_ps_mode {
601e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_NONE	= 0,
602e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_RFOFF	= 1,
603e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_CLK_GATED	= 2,
604e3ec7017SPing-Ke Shih 	RTW89_PS_MODE_PWR_GATED	= 3,
605e3ec7017SPing-Ke Shih };
606e3ec7017SPing-Ke Shih 
607e3ec7017SPing-Ke Shih #define RTW89_2G_BW_NUM (RTW89_CHANNEL_WIDTH_40 + 1)
60894b70cafSZong-Zhe Yang #define RTW89_5G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
609ac74f016SZong-Zhe Yang #define RTW89_6G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
610aa7f148bSPing-Ke Shih #define RTW89_PPE_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
611e3ec7017SPing-Ke Shih 
612e3ec7017SPing-Ke Shih enum rtw89_ru_bandwidth {
613e3ec7017SPing-Ke Shih 	RTW89_RU26 = 0,
614e3ec7017SPing-Ke Shih 	RTW89_RU52 = 1,
615e3ec7017SPing-Ke Shih 	RTW89_RU106 = 2,
616e3ec7017SPing-Ke Shih 	RTW89_RU_NUM,
617e3ec7017SPing-Ke Shih };
618e3ec7017SPing-Ke Shih 
619e3ec7017SPing-Ke Shih enum rtw89_sc_offset {
620e3ec7017SPing-Ke Shih 	RTW89_SC_DONT_CARE	= 0,
621e3ec7017SPing-Ke Shih 	RTW89_SC_20_UPPER	= 1,
622e3ec7017SPing-Ke Shih 	RTW89_SC_20_LOWER	= 2,
623e3ec7017SPing-Ke Shih 	RTW89_SC_20_UPMOST	= 3,
624e3ec7017SPing-Ke Shih 	RTW89_SC_20_LOWEST	= 4,
625e715f10fSPing-Ke Shih 	RTW89_SC_20_UP2X	= 5,
626e715f10fSPing-Ke Shih 	RTW89_SC_20_LOW2X	= 6,
627e715f10fSPing-Ke Shih 	RTW89_SC_20_UP3X	= 7,
628e715f10fSPing-Ke Shih 	RTW89_SC_20_LOW3X	= 8,
629e3ec7017SPing-Ke Shih 	RTW89_SC_40_UPPER	= 9,
630e3ec7017SPing-Ke Shih 	RTW89_SC_40_LOWER	= 10,
631e3ec7017SPing-Ke Shih };
632e3ec7017SPing-Ke Shih 
6333e5831caSZong-Zhe Yang struct rtw89_chan {
6343e5831caSZong-Zhe Yang 	u8 channel;
6353e5831caSZong-Zhe Yang 	u8 primary_channel;
6363e5831caSZong-Zhe Yang 	enum rtw89_band band_type;
6373e5831caSZong-Zhe Yang 	enum rtw89_bandwidth band_width;
638bb8152b3SZong-Zhe Yang 
639bb8152b3SZong-Zhe Yang 	/* The follow-up are derived from the above. We must ensure that it
640bb8152b3SZong-Zhe Yang 	 * is assigned correctly in rtw89_chan_create() if new one is added.
641bb8152b3SZong-Zhe Yang 	 */
642bb8152b3SZong-Zhe Yang 	u32 freq;
6433e5831caSZong-Zhe Yang 	enum rtw89_subband subband_type;
6443e5831caSZong-Zhe Yang 	enum rtw89_sc_offset pri_ch_idx;
645e3ec7017SPing-Ke Shih };
646e3ec7017SPing-Ke Shih 
647cbb145b9SZong-Zhe Yang struct rtw89_chan_rcd {
648cbb145b9SZong-Zhe Yang 	u8 prev_primary_channel;
649cbb145b9SZong-Zhe Yang 	enum rtw89_band prev_band_type;
650cbb145b9SZong-Zhe Yang };
651cbb145b9SZong-Zhe Yang 
652e3ec7017SPing-Ke Shih struct rtw89_channel_help_params {
653d780f926SPing-Ke Shih 	u32 tx_en;
654e3ec7017SPing-Ke Shih };
655e3ec7017SPing-Ke Shih 
656e3ec7017SPing-Ke Shih struct rtw89_port_reg {
657e3ec7017SPing-Ke Shih 	u32 port_cfg;
658e3ec7017SPing-Ke Shih 	u32 tbtt_prohib;
659e3ec7017SPing-Ke Shih 	u32 bcn_area;
660e3ec7017SPing-Ke Shih 	u32 bcn_early;
661e3ec7017SPing-Ke Shih 	u32 tbtt_early;
662e3ec7017SPing-Ke Shih 	u32 tbtt_agg;
663e3ec7017SPing-Ke Shih 	u32 bcn_space;
664e3ec7017SPing-Ke Shih 	u32 bcn_forcetx;
665e3ec7017SPing-Ke Shih 	u32 bcn_err_cnt;
666e3ec7017SPing-Ke Shih 	u32 bcn_err_flag;
667e3ec7017SPing-Ke Shih 	u32 dtim_ctrl;
668e3ec7017SPing-Ke Shih 	u32 tbtt_shift;
669e3ec7017SPing-Ke Shih 	u32 bcn_cnt_tmr;
670e3ec7017SPing-Ke Shih 	u32 tsftr_l;
671e3ec7017SPing-Ke Shih 	u32 tsftr_h;
672e3ec7017SPing-Ke Shih };
673e3ec7017SPing-Ke Shih 
674e3ec7017SPing-Ke Shih struct rtw89_txwd_body {
675e3ec7017SPing-Ke Shih 	__le32 dword0;
676e3ec7017SPing-Ke Shih 	__le32 dword1;
677e3ec7017SPing-Ke Shih 	__le32 dword2;
678e3ec7017SPing-Ke Shih 	__le32 dword3;
679e3ec7017SPing-Ke Shih 	__le32 dword4;
680e3ec7017SPing-Ke Shih 	__le32 dword5;
681e3ec7017SPing-Ke Shih } __packed;
682e3ec7017SPing-Ke Shih 
683f59acddeSPing-Ke Shih struct rtw89_txwd_body_v1 {
684f59acddeSPing-Ke Shih 	__le32 dword0;
685f59acddeSPing-Ke Shih 	__le32 dword1;
686f59acddeSPing-Ke Shih 	__le32 dword2;
687f59acddeSPing-Ke Shih 	__le32 dword3;
688f59acddeSPing-Ke Shih 	__le32 dword4;
689f59acddeSPing-Ke Shih 	__le32 dword5;
690f59acddeSPing-Ke Shih 	__le32 dword6;
691f59acddeSPing-Ke Shih 	__le32 dword7;
692f59acddeSPing-Ke Shih } __packed;
693f59acddeSPing-Ke Shih 
694e3ec7017SPing-Ke Shih struct rtw89_txwd_info {
695e3ec7017SPing-Ke Shih 	__le32 dword0;
696e3ec7017SPing-Ke Shih 	__le32 dword1;
697e3ec7017SPing-Ke Shih 	__le32 dword2;
698e3ec7017SPing-Ke Shih 	__le32 dword3;
699e3ec7017SPing-Ke Shih 	__le32 dword4;
700e3ec7017SPing-Ke Shih 	__le32 dword5;
701e3ec7017SPing-Ke Shih } __packed;
702e3ec7017SPing-Ke Shih 
703e3ec7017SPing-Ke Shih struct rtw89_rx_desc_info {
704e3ec7017SPing-Ke Shih 	u16 pkt_size;
705e3ec7017SPing-Ke Shih 	u8 pkt_type;
706e3ec7017SPing-Ke Shih 	u8 drv_info_size;
707e3ec7017SPing-Ke Shih 	u8 shift;
708e3ec7017SPing-Ke Shih 	u8 wl_hd_iv_len;
709e3ec7017SPing-Ke Shih 	bool long_rxdesc;
710e3ec7017SPing-Ke Shih 	bool bb_sel;
711e3ec7017SPing-Ke Shih 	bool mac_info_valid;
712e3ec7017SPing-Ke Shih 	u16 data_rate;
713e3ec7017SPing-Ke Shih 	u8 gi_ltf;
714e3ec7017SPing-Ke Shih 	u8 bw;
715e3ec7017SPing-Ke Shih 	u32 free_run_cnt;
716e3ec7017SPing-Ke Shih 	u8 user_id;
717e3ec7017SPing-Ke Shih 	bool sr_en;
718e3ec7017SPing-Ke Shih 	u8 ppdu_cnt;
719e3ec7017SPing-Ke Shih 	u8 ppdu_type;
720e3ec7017SPing-Ke Shih 	bool icv_err;
721e3ec7017SPing-Ke Shih 	bool crc32_err;
722e3ec7017SPing-Ke Shih 	bool hw_dec;
723e3ec7017SPing-Ke Shih 	bool sw_dec;
724e3ec7017SPing-Ke Shih 	bool addr1_match;
725e3ec7017SPing-Ke Shih 	u8 frag;
726e3ec7017SPing-Ke Shih 	u16 seq;
727e3ec7017SPing-Ke Shih 	u8 frame_type;
728e3ec7017SPing-Ke Shih 	u8 rx_pl_id;
729e3ec7017SPing-Ke Shih 	bool addr_cam_valid;
730e3ec7017SPing-Ke Shih 	u8 addr_cam_id;
731e3ec7017SPing-Ke Shih 	u8 sec_cam_id;
732e3ec7017SPing-Ke Shih 	u8 mac_id;
733e3ec7017SPing-Ke Shih 	u16 offset;
734e3ec7017SPing-Ke Shih 	bool ready;
735e3ec7017SPing-Ke Shih };
736e3ec7017SPing-Ke Shih 
737e3ec7017SPing-Ke Shih struct rtw89_rxdesc_short {
738e3ec7017SPing-Ke Shih 	__le32 dword0;
739e3ec7017SPing-Ke Shih 	__le32 dword1;
740e3ec7017SPing-Ke Shih 	__le32 dword2;
741e3ec7017SPing-Ke Shih 	__le32 dword3;
742e3ec7017SPing-Ke Shih } __packed;
743e3ec7017SPing-Ke Shih 
744e3ec7017SPing-Ke Shih struct rtw89_rxdesc_long {
745e3ec7017SPing-Ke Shih 	__le32 dword0;
746e3ec7017SPing-Ke Shih 	__le32 dword1;
747e3ec7017SPing-Ke Shih 	__le32 dword2;
748e3ec7017SPing-Ke Shih 	__le32 dword3;
749e3ec7017SPing-Ke Shih 	__le32 dword4;
750e3ec7017SPing-Ke Shih 	__le32 dword5;
751e3ec7017SPing-Ke Shih 	__le32 dword6;
752e3ec7017SPing-Ke Shih 	__le32 dword7;
753e3ec7017SPing-Ke Shih } __packed;
754e3ec7017SPing-Ke Shih 
755e3ec7017SPing-Ke Shih struct rtw89_tx_desc_info {
756e3ec7017SPing-Ke Shih 	u16 pkt_size;
757e3ec7017SPing-Ke Shih 	u8 wp_offset;
7589eecaec2SPing-Ke Shih 	u8 mac_id;
759e3ec7017SPing-Ke Shih 	u8 qsel;
760e3ec7017SPing-Ke Shih 	u8 ch_dma;
761e3ec7017SPing-Ke Shih 	u8 hdr_llc_len;
762e3ec7017SPing-Ke Shih 	bool is_bmc;
763e3ec7017SPing-Ke Shih 	bool en_wd_info;
764e3ec7017SPing-Ke Shih 	bool wd_page;
765e3ec7017SPing-Ke Shih 	bool use_rate;
766e3ec7017SPing-Ke Shih 	bool dis_data_fb;
767e3ec7017SPing-Ke Shih 	bool tid_indicate;
768e3ec7017SPing-Ke Shih 	bool agg_en;
769e3ec7017SPing-Ke Shih 	bool bk;
770e3ec7017SPing-Ke Shih 	u8 ampdu_density;
771e3ec7017SPing-Ke Shih 	u8 ampdu_num;
772e3ec7017SPing-Ke Shih 	bool sec_en;
7736d5b5d62SPing-Ke Shih 	u8 addr_info_nr;
77479a6c9a4SPing-Ke Shih 	u8 sec_keyid;
775e3ec7017SPing-Ke Shih 	u8 sec_type;
776e3ec7017SPing-Ke Shih 	u8 sec_cam_idx;
77779a6c9a4SPing-Ke Shih 	u8 sec_seq[6];
778e3ec7017SPing-Ke Shih 	u16 data_rate;
779e3ec7017SPing-Ke Shih 	u16 data_retry_lowest_rate;
780e3ec7017SPing-Ke Shih 	bool fw_dl;
781e3ec7017SPing-Ke Shih 	u16 seq;
782e3ec7017SPing-Ke Shih 	bool a_ctrl_bsr;
78391644020SPing-Ke Shih 	u8 hw_ssn_sel;
78491644020SPing-Ke Shih #define RTW89_MGMT_HW_SSN_SEL	1
78591644020SPing-Ke Shih 	u8 hw_seq_mode;
78691644020SPing-Ke Shih #define RTW89_MGMT_HW_SEQ_MODE	1
78711d261f2SPing-Ke Shih 	bool hiq;
7889eecaec2SPing-Ke Shih 	u8 port;
789e3ec7017SPing-Ke Shih };
790e3ec7017SPing-Ke Shih 
791e3ec7017SPing-Ke Shih struct rtw89_core_tx_request {
792e3ec7017SPing-Ke Shih 	enum rtw89_core_tx_type tx_type;
793e3ec7017SPing-Ke Shih 
794e3ec7017SPing-Ke Shih 	struct sk_buff *skb;
795e3ec7017SPing-Ke Shih 	struct ieee80211_vif *vif;
796e3ec7017SPing-Ke Shih 	struct ieee80211_sta *sta;
797e3ec7017SPing-Ke Shih 	struct rtw89_tx_desc_info desc_info;
798e3ec7017SPing-Ke Shih };
799e3ec7017SPing-Ke Shih 
800e3ec7017SPing-Ke Shih struct rtw89_txq {
801e3ec7017SPing-Ke Shih 	struct list_head list;
802e3ec7017SPing-Ke Shih 	unsigned long flags;
803e3ec7017SPing-Ke Shih 	int wait_cnt;
804e3ec7017SPing-Ke Shih };
805e3ec7017SPing-Ke Shih 
806e3ec7017SPing-Ke Shih struct rtw89_mac_ax_gnt {
807e3ec7017SPing-Ke Shih 	u8 gnt_bt_sw_en;
808e3ec7017SPing-Ke Shih 	u8 gnt_bt;
809e3ec7017SPing-Ke Shih 	u8 gnt_wl_sw_en;
810e3ec7017SPing-Ke Shih 	u8 gnt_wl;
811e3ec7017SPing-Ke Shih };
812e3ec7017SPing-Ke Shih 
813e3ec7017SPing-Ke Shih #define RTW89_MAC_AX_COEX_GNT_NR 2
814e3ec7017SPing-Ke Shih struct rtw89_mac_ax_coex_gnt {
815e3ec7017SPing-Ke Shih 	struct rtw89_mac_ax_gnt band[RTW89_MAC_AX_COEX_GNT_NR];
816e3ec7017SPing-Ke Shih };
817e3ec7017SPing-Ke Shih 
818e3ec7017SPing-Ke Shih enum rtw89_btc_ncnt {
819e3ec7017SPing-Ke Shih 	BTC_NCNT_POWER_ON = 0x0,
820e3ec7017SPing-Ke Shih 	BTC_NCNT_POWER_OFF,
821e3ec7017SPing-Ke Shih 	BTC_NCNT_INIT_COEX,
822e3ec7017SPing-Ke Shih 	BTC_NCNT_SCAN_START,
823e3ec7017SPing-Ke Shih 	BTC_NCNT_SCAN_FINISH,
824e3ec7017SPing-Ke Shih 	BTC_NCNT_SPECIAL_PACKET,
825e3ec7017SPing-Ke Shih 	BTC_NCNT_SWITCH_BAND,
826e3ec7017SPing-Ke Shih 	BTC_NCNT_RFK_TIMEOUT,
827e3ec7017SPing-Ke Shih 	BTC_NCNT_SHOW_COEX_INFO,
828e3ec7017SPing-Ke Shih 	BTC_NCNT_ROLE_INFO,
829e3ec7017SPing-Ke Shih 	BTC_NCNT_CONTROL,
830e3ec7017SPing-Ke Shih 	BTC_NCNT_RADIO_STATE,
831e3ec7017SPing-Ke Shih 	BTC_NCNT_CUSTOMERIZE,
832e3ec7017SPing-Ke Shih 	BTC_NCNT_WL_RFK,
833e3ec7017SPing-Ke Shih 	BTC_NCNT_WL_STA,
834e3ec7017SPing-Ke Shih 	BTC_NCNT_FWINFO,
835e3ec7017SPing-Ke Shih 	BTC_NCNT_TIMER,
836e3ec7017SPing-Ke Shih 	BTC_NCNT_NUM
837e3ec7017SPing-Ke Shih };
838e3ec7017SPing-Ke Shih 
839e3ec7017SPing-Ke Shih enum rtw89_btc_btinfo {
840e3ec7017SPing-Ke Shih 	BTC_BTINFO_L0 = 0,
841e3ec7017SPing-Ke Shih 	BTC_BTINFO_L1,
842e3ec7017SPing-Ke Shih 	BTC_BTINFO_L2,
843e3ec7017SPing-Ke Shih 	BTC_BTINFO_L3,
844e3ec7017SPing-Ke Shih 	BTC_BTINFO_H0,
845e3ec7017SPing-Ke Shih 	BTC_BTINFO_H1,
846e3ec7017SPing-Ke Shih 	BTC_BTINFO_H2,
847e3ec7017SPing-Ke Shih 	BTC_BTINFO_H3,
848e3ec7017SPing-Ke Shih 	BTC_BTINFO_MAX
849e3ec7017SPing-Ke Shih };
850e3ec7017SPing-Ke Shih 
851e3ec7017SPing-Ke Shih enum rtw89_btc_dcnt {
852e3ec7017SPing-Ke Shih 	BTC_DCNT_RUN = 0x0,
853e3ec7017SPing-Ke Shih 	BTC_DCNT_CX_RUNINFO,
854e3ec7017SPing-Ke Shih 	BTC_DCNT_RPT,
855e3ec7017SPing-Ke Shih 	BTC_DCNT_RPT_FREEZE,
856e3ec7017SPing-Ke Shih 	BTC_DCNT_CYCLE,
857e3ec7017SPing-Ke Shih 	BTC_DCNT_CYCLE_FREEZE,
858e3ec7017SPing-Ke Shih 	BTC_DCNT_W1,
859e3ec7017SPing-Ke Shih 	BTC_DCNT_W1_FREEZE,
860e3ec7017SPing-Ke Shih 	BTC_DCNT_B1,
861e3ec7017SPing-Ke Shih 	BTC_DCNT_B1_FREEZE,
862e3ec7017SPing-Ke Shih 	BTC_DCNT_TDMA_NONSYNC,
863e3ec7017SPing-Ke Shih 	BTC_DCNT_SLOT_NONSYNC,
864e3ec7017SPing-Ke Shih 	BTC_DCNT_BTCNT_FREEZE,
865e3ec7017SPing-Ke Shih 	BTC_DCNT_WL_SLOT_DRIFT,
866e3ec7017SPing-Ke Shih 	BTC_DCNT_WL_STA_LAST,
867e3ec7017SPing-Ke Shih 	BTC_DCNT_NUM,
868e3ec7017SPing-Ke Shih };
869e3ec7017SPing-Ke Shih 
870e3ec7017SPing-Ke Shih enum rtw89_btc_wl_state_cnt {
871e3ec7017SPing-Ke Shih 	BTC_WCNT_SCANAP = 0x0,
872e3ec7017SPing-Ke Shih 	BTC_WCNT_DHCP,
873e3ec7017SPing-Ke Shih 	BTC_WCNT_EAPOL,
874e3ec7017SPing-Ke Shih 	BTC_WCNT_ARP,
875e3ec7017SPing-Ke Shih 	BTC_WCNT_SCBDUPDATE,
876e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_REQ,
877e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_GO,
878e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_REJECT,
879e3ec7017SPing-Ke Shih 	BTC_WCNT_RFK_TIMEOUT,
880e3ec7017SPing-Ke Shih 	BTC_WCNT_CH_UPDATE,
881e3ec7017SPing-Ke Shih 	BTC_WCNT_NUM
882e3ec7017SPing-Ke Shih };
883e3ec7017SPing-Ke Shih 
884e3ec7017SPing-Ke Shih enum rtw89_btc_bt_state_cnt {
885e3ec7017SPing-Ke Shih 	BTC_BCNT_RETRY = 0x0,
886e3ec7017SPing-Ke Shih 	BTC_BCNT_REINIT,
887e3ec7017SPing-Ke Shih 	BTC_BCNT_REENABLE,
888e3ec7017SPing-Ke Shih 	BTC_BCNT_SCBDREAD,
889e3ec7017SPing-Ke Shih 	BTC_BCNT_RELINK,
890e3ec7017SPing-Ke Shih 	BTC_BCNT_IGNOWL,
891e3ec7017SPing-Ke Shih 	BTC_BCNT_INQPAG,
892e3ec7017SPing-Ke Shih 	BTC_BCNT_INQ,
893e3ec7017SPing-Ke Shih 	BTC_BCNT_PAGE,
894e3ec7017SPing-Ke Shih 	BTC_BCNT_ROLESW,
895e3ec7017SPing-Ke Shih 	BTC_BCNT_AFH,
896e3ec7017SPing-Ke Shih 	BTC_BCNT_INFOUPDATE,
897e3ec7017SPing-Ke Shih 	BTC_BCNT_INFOSAME,
898e3ec7017SPing-Ke Shih 	BTC_BCNT_SCBDUPDATE,
899e3ec7017SPing-Ke Shih 	BTC_BCNT_HIPRI_TX,
900e3ec7017SPing-Ke Shih 	BTC_BCNT_HIPRI_RX,
901e3ec7017SPing-Ke Shih 	BTC_BCNT_LOPRI_TX,
902e3ec7017SPing-Ke Shih 	BTC_BCNT_LOPRI_RX,
9038c7e9cebSChing-Te Ku 	BTC_BCNT_POLUT,
904e3ec7017SPing-Ke Shih 	BTC_BCNT_RATECHG,
905e3ec7017SPing-Ke Shih 	BTC_BCNT_NUM
906e3ec7017SPing-Ke Shih };
907e3ec7017SPing-Ke Shih 
908e3ec7017SPing-Ke Shih enum rtw89_btc_bt_profile {
909e3ec7017SPing-Ke Shih 	BTC_BT_NOPROFILE = 0,
910e3ec7017SPing-Ke Shih 	BTC_BT_HFP = BIT(0),
911e3ec7017SPing-Ke Shih 	BTC_BT_HID = BIT(1),
912e3ec7017SPing-Ke Shih 	BTC_BT_A2DP = BIT(2),
913e3ec7017SPing-Ke Shih 	BTC_BT_PAN = BIT(3),
914e3ec7017SPing-Ke Shih 	BTC_PROFILE_MAX = 4,
915e3ec7017SPing-Ke Shih };
916e3ec7017SPing-Ke Shih 
917e3ec7017SPing-Ke Shih struct rtw89_btc_ant_info {
918e3ec7017SPing-Ke Shih 	u8 type;  /* shared, dedicated */
919e3ec7017SPing-Ke Shih 	u8 num;
920e3ec7017SPing-Ke Shih 	u8 isolation;
921e3ec7017SPing-Ke Shih 
922e3ec7017SPing-Ke Shih 	u8 single_pos: 1;/* Single antenna at S0 or S1 */
923e3ec7017SPing-Ke Shih 	u8 diversity: 1;
924e3ec7017SPing-Ke Shih };
925e3ec7017SPing-Ke Shih 
926e3ec7017SPing-Ke Shih enum rtw89_tfc_dir {
927e3ec7017SPing-Ke Shih 	RTW89_TFC_UL,
928e3ec7017SPing-Ke Shih 	RTW89_TFC_DL,
929e3ec7017SPing-Ke Shih };
930e3ec7017SPing-Ke Shih 
931e3ec7017SPing-Ke Shih struct rtw89_btc_wl_smap {
932e3ec7017SPing-Ke Shih 	u32 busy: 1;
933e3ec7017SPing-Ke Shih 	u32 scan: 1;
934e3ec7017SPing-Ke Shih 	u32 connecting: 1;
935e3ec7017SPing-Ke Shih 	u32 roaming: 1;
936e3ec7017SPing-Ke Shih 	u32 _4way: 1;
937e3ec7017SPing-Ke Shih 	u32 rf_off: 1;
938e3ec7017SPing-Ke Shih 	u32 lps: 1;
939e3ec7017SPing-Ke Shih 	u32 ips: 1;
940e3ec7017SPing-Ke Shih 	u32 init_ok: 1;
941e3ec7017SPing-Ke Shih 	u32 traffic_dir : 2;
942e3ec7017SPing-Ke Shih 	u32 rf_off_pre: 1;
943e3ec7017SPing-Ke Shih 	u32 lps_pre: 1;
944e3ec7017SPing-Ke Shih };
945e3ec7017SPing-Ke Shih 
946e3ec7017SPing-Ke Shih enum rtw89_tfc_lv {
947e3ec7017SPing-Ke Shih 	RTW89_TFC_IDLE,
948e3ec7017SPing-Ke Shih 	RTW89_TFC_ULTRA_LOW,
949e3ec7017SPing-Ke Shih 	RTW89_TFC_LOW,
950e3ec7017SPing-Ke Shih 	RTW89_TFC_MID,
951e3ec7017SPing-Ke Shih 	RTW89_TFC_HIGH,
952e3ec7017SPing-Ke Shih };
953e3ec7017SPing-Ke Shih 
954e3ec7017SPing-Ke Shih #define RTW89_TP_SHIFT 18 /* bytes/2s --> Mbps */
955e3ec7017SPing-Ke Shih DECLARE_EWMA(tp, 10, 2);
956e3ec7017SPing-Ke Shih 
957e3ec7017SPing-Ke Shih struct rtw89_traffic_stats {
958e3ec7017SPing-Ke Shih 	/* units in bytes */
959e3ec7017SPing-Ke Shih 	u64 tx_unicast;
960e3ec7017SPing-Ke Shih 	u64 rx_unicast;
961e3ec7017SPing-Ke Shih 	u32 tx_avg_len;
962e3ec7017SPing-Ke Shih 	u32 rx_avg_len;
963e3ec7017SPing-Ke Shih 
964e3ec7017SPing-Ke Shih 	/* count for packets */
965e3ec7017SPing-Ke Shih 	u64 tx_cnt;
966e3ec7017SPing-Ke Shih 	u64 rx_cnt;
967e3ec7017SPing-Ke Shih 
968e3ec7017SPing-Ke Shih 	/* units in Mbps */
969e3ec7017SPing-Ke Shih 	u32 tx_throughput;
970e3ec7017SPing-Ke Shih 	u32 rx_throughput;
971e3ec7017SPing-Ke Shih 	u32 tx_throughput_raw;
972e3ec7017SPing-Ke Shih 	u32 rx_throughput_raw;
9735165f168SPo Hao Huang 
9745165f168SPo Hao Huang 	u32 rx_tf_acc;
9755165f168SPo Hao Huang 	u32 rx_tf_periodic;
9765165f168SPo Hao Huang 
977e3ec7017SPing-Ke Shih 	enum rtw89_tfc_lv tx_tfc_lv;
978e3ec7017SPing-Ke Shih 	enum rtw89_tfc_lv rx_tfc_lv;
979e3ec7017SPing-Ke Shih 	struct ewma_tp tx_ewma_tp;
980e3ec7017SPing-Ke Shih 	struct ewma_tp rx_ewma_tp;
981e3ec7017SPing-Ke Shih 
982e3ec7017SPing-Ke Shih 	u16 tx_rate;
983e3ec7017SPing-Ke Shih 	u16 rx_rate;
984e3ec7017SPing-Ke Shih };
985e3ec7017SPing-Ke Shih 
986e3ec7017SPing-Ke Shih struct rtw89_btc_statistic {
987e3ec7017SPing-Ke Shih 	u8 rssi; /* 0%~110% (dBm = rssi -110) */
988e3ec7017SPing-Ke Shih 	struct rtw89_traffic_stats traffic;
989e3ec7017SPing-Ke Shih };
990e3ec7017SPing-Ke Shih 
991e3ec7017SPing-Ke Shih #define BTC_WL_RSSI_THMAX 4
992e3ec7017SPing-Ke Shih 
993e3ec7017SPing-Ke Shih struct rtw89_btc_wl_link_info {
994e3ec7017SPing-Ke Shih 	struct rtw89_btc_statistic stat;
995e3ec7017SPing-Ke Shih 	enum rtw89_tfc_dir dir;
996e3ec7017SPing-Ke Shih 	u8 rssi_state[BTC_WL_RSSI_THMAX];
997e3ec7017SPing-Ke Shih 	u8 mac_addr[ETH_ALEN];
998e3ec7017SPing-Ke Shih 	u8 busy;
999e3ec7017SPing-Ke Shih 	u8 ch;
1000e3ec7017SPing-Ke Shih 	u8 bw;
1001e3ec7017SPing-Ke Shih 	u8 band;
1002e3ec7017SPing-Ke Shih 	u8 role;
1003e3ec7017SPing-Ke Shih 	u8 pid;
1004e3ec7017SPing-Ke Shih 	u8 phy;
1005e3ec7017SPing-Ke Shih 	u8 dtim_period;
1006e3ec7017SPing-Ke Shih 	u8 mode;
1007e3ec7017SPing-Ke Shih 
1008e3ec7017SPing-Ke Shih 	u8 mac_id;
1009e3ec7017SPing-Ke Shih 	u8 tx_retry;
1010e3ec7017SPing-Ke Shih 
1011e3ec7017SPing-Ke Shih 	u32 bcn_period;
1012e3ec7017SPing-Ke Shih 	u32 busy_t;
1013e3ec7017SPing-Ke Shih 	u32 tx_time;
1014e3ec7017SPing-Ke Shih 	u32 client_cnt;
1015e3ec7017SPing-Ke Shih 	u32 rx_rate_drop_cnt;
1016e3ec7017SPing-Ke Shih 
1017e3ec7017SPing-Ke Shih 	u32 active: 1;
1018e3ec7017SPing-Ke Shih 	u32 noa: 1;
1019e3ec7017SPing-Ke Shih 	u32 client_ps: 1;
1020e3ec7017SPing-Ke Shih 	u32 connected: 2;
1021e3ec7017SPing-Ke Shih };
1022e3ec7017SPing-Ke Shih 
1023e3ec7017SPing-Ke Shih union rtw89_btc_wl_state_map {
1024e3ec7017SPing-Ke Shih 	u32 val;
1025e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_smap map;
1026e3ec7017SPing-Ke Shih };
1027e3ec7017SPing-Ke Shih 
1028e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hfp_desc {
1029e3ec7017SPing-Ke Shih 	u32 exist: 1;
1030e3ec7017SPing-Ke Shih 	u32 type: 2;
1031e3ec7017SPing-Ke Shih 	u32 rsvd: 29;
1032e3ec7017SPing-Ke Shih };
1033e3ec7017SPing-Ke Shih 
1034e3ec7017SPing-Ke Shih struct rtw89_btc_bt_hid_desc {
1035e3ec7017SPing-Ke Shih 	u32 exist: 1;
1036e3ec7017SPing-Ke Shih 	u32 slot_info: 2;
1037e3ec7017SPing-Ke Shih 	u32 pair_cnt: 2;
1038e3ec7017SPing-Ke Shih 	u32 type: 8;
1039e3ec7017SPing-Ke Shih 	u32 rsvd: 19;
1040e3ec7017SPing-Ke Shih };
1041e3ec7017SPing-Ke Shih 
1042e3ec7017SPing-Ke Shih struct rtw89_btc_bt_a2dp_desc {
1043e3ec7017SPing-Ke Shih 	u8 exist: 1;
1044e3ec7017SPing-Ke Shih 	u8 exist_last: 1;
1045e3ec7017SPing-Ke Shih 	u8 play_latency: 1;
1046e3ec7017SPing-Ke Shih 	u8 type: 3;
1047e3ec7017SPing-Ke Shih 	u8 active: 1;
1048e3ec7017SPing-Ke Shih 	u8 sink: 1;
1049e3ec7017SPing-Ke Shih 
1050e3ec7017SPing-Ke Shih 	u8 bitpool;
1051e3ec7017SPing-Ke Shih 	u16 vendor_id;
1052e3ec7017SPing-Ke Shih 	u32 device_name;
1053e3ec7017SPing-Ke Shih 	u32 flush_time;
1054e3ec7017SPing-Ke Shih };
1055e3ec7017SPing-Ke Shih 
1056e3ec7017SPing-Ke Shih struct rtw89_btc_bt_pan_desc {
1057e3ec7017SPing-Ke Shih 	u32 exist: 1;
1058e3ec7017SPing-Ke Shih 	u32 type: 1;
1059e3ec7017SPing-Ke Shih 	u32 active: 1;
1060e3ec7017SPing-Ke Shih 	u32 rsvd: 29;
1061e3ec7017SPing-Ke Shih };
1062e3ec7017SPing-Ke Shih 
1063e3ec7017SPing-Ke Shih struct rtw89_btc_bt_rfk_info {
1064e3ec7017SPing-Ke Shih 	u32 run: 1;
1065e3ec7017SPing-Ke Shih 	u32 req: 1;
1066e3ec7017SPing-Ke Shih 	u32 timeout: 1;
1067e3ec7017SPing-Ke Shih 	u32 rsvd: 29;
1068e3ec7017SPing-Ke Shih };
1069e3ec7017SPing-Ke Shih 
1070e3ec7017SPing-Ke Shih union rtw89_btc_bt_rfk_info_map {
1071e3ec7017SPing-Ke Shih 	u32 val;
1072e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_rfk_info map;
1073e3ec7017SPing-Ke Shih };
1074e3ec7017SPing-Ke Shih 
1075e3ec7017SPing-Ke Shih struct rtw89_btc_bt_ver_info {
1076e3ec7017SPing-Ke Shih 	u32 fw_coex; /* match with which coex_ver */
1077e3ec7017SPing-Ke Shih 	u32 fw;
1078e3ec7017SPing-Ke Shih };
1079e3ec7017SPing-Ke Shih 
1080e3ec7017SPing-Ke Shih struct rtw89_btc_bool_sta_chg {
1081e3ec7017SPing-Ke Shih 	u32 now: 1;
1082e3ec7017SPing-Ke Shih 	u32 last: 1;
1083e3ec7017SPing-Ke Shih 	u32 remain: 1;
1084e3ec7017SPing-Ke Shih 	u32 srvd: 29;
1085e3ec7017SPing-Ke Shih };
1086e3ec7017SPing-Ke Shih 
1087e3ec7017SPing-Ke Shih struct rtw89_btc_u8_sta_chg {
1088e3ec7017SPing-Ke Shih 	u8 now;
1089e3ec7017SPing-Ke Shih 	u8 last;
1090e3ec7017SPing-Ke Shih 	u8 remain;
1091e3ec7017SPing-Ke Shih 	u8 rsvd;
1092e3ec7017SPing-Ke Shih };
1093e3ec7017SPing-Ke Shih 
1094e3ec7017SPing-Ke Shih struct rtw89_btc_wl_scan_info {
1095e3ec7017SPing-Ke Shih 	u8 band[RTW89_PHY_MAX];
1096e3ec7017SPing-Ke Shih 	u8 phy_map;
1097e3ec7017SPing-Ke Shih 	u8 rsvd;
1098e3ec7017SPing-Ke Shih };
1099e3ec7017SPing-Ke Shih 
1100e3ec7017SPing-Ke Shih struct rtw89_btc_wl_dbcc_info {
1101e3ec7017SPing-Ke Shih 	u8 op_band[RTW89_PHY_MAX]; /* op band in each phy */
1102e3ec7017SPing-Ke Shih 	u8 scan_band[RTW89_PHY_MAX]; /* scan band in  each phy */
1103e3ec7017SPing-Ke Shih 	u8 real_band[RTW89_PHY_MAX];
1104e3ec7017SPing-Ke Shih 	u8 role[RTW89_PHY_MAX]; /* role in each phy */
1105e3ec7017SPing-Ke Shih };
1106e3ec7017SPing-Ke Shih 
1107e3ec7017SPing-Ke Shih struct rtw89_btc_wl_active_role {
1108e3ec7017SPing-Ke Shih 	u8 connected: 1;
1109e3ec7017SPing-Ke Shih 	u8 pid: 3;
1110e3ec7017SPing-Ke Shih 	u8 phy: 1;
1111e3ec7017SPing-Ke Shih 	u8 noa: 1;
1112e3ec7017SPing-Ke Shih 	u8 band: 2;
1113e3ec7017SPing-Ke Shih 
1114e3ec7017SPing-Ke Shih 	u8 client_ps: 1;
1115e3ec7017SPing-Ke Shih 	u8 bw: 7;
1116e3ec7017SPing-Ke Shih 
1117e3ec7017SPing-Ke Shih 	u8 role;
1118e3ec7017SPing-Ke Shih 	u8 ch;
1119e3ec7017SPing-Ke Shih 
1120e3ec7017SPing-Ke Shih 	u16 tx_lvl;
1121e3ec7017SPing-Ke Shih 	u16 rx_lvl;
1122e3ec7017SPing-Ke Shih 	u16 tx_rate;
1123e3ec7017SPing-Ke Shih 	u16 rx_rate;
1124e3ec7017SPing-Ke Shih };
1125e3ec7017SPing-Ke Shih 
1126e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info_bpos {
1127e3ec7017SPing-Ke Shih 	u16 none: 1;
1128e3ec7017SPing-Ke Shih 	u16 station: 1;
1129e3ec7017SPing-Ke Shih 	u16 ap: 1;
1130e3ec7017SPing-Ke Shih 	u16 vap: 1;
1131e3ec7017SPing-Ke Shih 	u16 adhoc: 1;
1132e3ec7017SPing-Ke Shih 	u16 adhoc_master: 1;
1133e3ec7017SPing-Ke Shih 	u16 mesh: 1;
1134e3ec7017SPing-Ke Shih 	u16 moniter: 1;
1135e3ec7017SPing-Ke Shih 	u16 p2p_device: 1;
1136e3ec7017SPing-Ke Shih 	u16 p2p_gc: 1;
1137e3ec7017SPing-Ke Shih 	u16 p2p_go: 1;
1138e3ec7017SPing-Ke Shih 	u16 nan: 1;
1139e3ec7017SPing-Ke Shih };
1140e3ec7017SPing-Ke Shih 
1141e3ec7017SPing-Ke Shih union rtw89_btc_wl_role_info_map {
1142e3ec7017SPing-Ke Shih 	u16 val;
1143e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_role_info_bpos role;
1144e3ec7017SPing-Ke Shih };
1145e3ec7017SPing-Ke Shih 
1146e3ec7017SPing-Ke Shih struct rtw89_btc_wl_role_info { /* struct size must be n*4 bytes */
1147e3ec7017SPing-Ke Shih 	u8 connect_cnt;
1148e3ec7017SPing-Ke Shih 	u8 link_mode;
1149e3ec7017SPing-Ke Shih 	union rtw89_btc_wl_role_info_map role_map;
115020d9fc88SPing-Ke Shih 	struct rtw89_btc_wl_active_role active_role[RTW89_PORT_NUM];
1151e3ec7017SPing-Ke Shih };
1152e3ec7017SPing-Ke Shih 
1153e3ec7017SPing-Ke Shih struct rtw89_btc_wl_ver_info {
1154e3ec7017SPing-Ke Shih 	u32 fw_coex; /* match with which coex_ver */
1155e3ec7017SPing-Ke Shih 	u32 fw;
1156e3ec7017SPing-Ke Shih 	u32 mac;
1157e3ec7017SPing-Ke Shih 	u32 bb;
1158e3ec7017SPing-Ke Shih 	u32 rf;
1159e3ec7017SPing-Ke Shih };
1160e3ec7017SPing-Ke Shih 
1161e3ec7017SPing-Ke Shih struct rtw89_btc_wl_afh_info {
1162e3ec7017SPing-Ke Shih 	u8 en;
1163e3ec7017SPing-Ke Shih 	u8 ch;
1164e3ec7017SPing-Ke Shih 	u8 bw;
1165e3ec7017SPing-Ke Shih 	u8 rsvd;
1166e3ec7017SPing-Ke Shih } __packed;
1167e3ec7017SPing-Ke Shih 
1168e3ec7017SPing-Ke Shih struct rtw89_btc_wl_rfk_info {
1169e3ec7017SPing-Ke Shih 	u32 state: 2;
1170e3ec7017SPing-Ke Shih 	u32 path_map: 4;
1171e3ec7017SPing-Ke Shih 	u32 phy_map: 2;
1172e3ec7017SPing-Ke Shih 	u32 band: 2;
1173e3ec7017SPing-Ke Shih 	u32 type: 8;
1174e3ec7017SPing-Ke Shih 	u32 rsvd: 14;
1175e3ec7017SPing-Ke Shih };
1176e3ec7017SPing-Ke Shih 
1177e3ec7017SPing-Ke Shih struct rtw89_btc_bt_smap {
1178e3ec7017SPing-Ke Shih 	u32 connect: 1;
1179e3ec7017SPing-Ke Shih 	u32 ble_connect: 1;
1180e3ec7017SPing-Ke Shih 	u32 acl_busy: 1;
1181e3ec7017SPing-Ke Shih 	u32 sco_busy: 1;
1182e3ec7017SPing-Ke Shih 	u32 mesh_busy: 1;
1183e3ec7017SPing-Ke Shih 	u32 inq_pag: 1;
1184e3ec7017SPing-Ke Shih };
1185e3ec7017SPing-Ke Shih 
1186e3ec7017SPing-Ke Shih union rtw89_btc_bt_state_map {
1187e3ec7017SPing-Ke Shih 	u32 val;
1188e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_smap map;
1189e3ec7017SPing-Ke Shih };
1190e3ec7017SPing-Ke Shih 
1191e3ec7017SPing-Ke Shih #define BTC_BT_RSSI_THMAX 4
1192e3ec7017SPing-Ke Shih #define BTC_BT_AFH_GROUP 12
1193e3ec7017SPing-Ke Shih 
1194e3ec7017SPing-Ke Shih struct rtw89_btc_bt_link_info {
1195e3ec7017SPing-Ke Shih 	struct rtw89_btc_u8_sta_chg profile_cnt;
1196e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg multi_link;
1197e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg relink;
1198e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_hfp_desc hfp_desc;
1199e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_hid_desc hid_desc;
1200e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_a2dp_desc a2dp_desc;
1201e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_pan_desc pan_desc;
1202e3ec7017SPing-Ke Shih 	union rtw89_btc_bt_state_map status;
1203e3ec7017SPing-Ke Shih 
1204e3ec7017SPing-Ke Shih 	u8 sut_pwr_level[BTC_PROFILE_MAX];
1205e3ec7017SPing-Ke Shih 	u8 golden_rx_shift[BTC_PROFILE_MAX];
1206e3ec7017SPing-Ke Shih 	u8 rssi_state[BTC_BT_RSSI_THMAX];
1207e3ec7017SPing-Ke Shih 	u8 afh_map[BTC_BT_AFH_GROUP];
1208e3ec7017SPing-Ke Shih 
1209e3ec7017SPing-Ke Shih 	u32 role_sw: 1;
1210e3ec7017SPing-Ke Shih 	u32 slave_role: 1;
1211e3ec7017SPing-Ke Shih 	u32 afh_update: 1;
1212e3ec7017SPing-Ke Shih 	u32 cqddr: 1;
1213e3ec7017SPing-Ke Shih 	u32 rssi: 8;
1214e3ec7017SPing-Ke Shih 	u32 tx_3m: 1;
1215e3ec7017SPing-Ke Shih 	u32 rsvd: 19;
1216e3ec7017SPing-Ke Shih };
1217e3ec7017SPing-Ke Shih 
1218e3ec7017SPing-Ke Shih struct rtw89_btc_3rdcx_info {
1219e3ec7017SPing-Ke Shih 	u8 type;   /* 0: none, 1:zigbee, 2:LTE  */
1220e3ec7017SPing-Ke Shih 	u8 hw_coex;
1221e3ec7017SPing-Ke Shih 	u16 rsvd;
1222e3ec7017SPing-Ke Shih };
1223e3ec7017SPing-Ke Shih 
1224e3ec7017SPing-Ke Shih struct rtw89_btc_dm_emap {
1225e3ec7017SPing-Ke Shih 	u32 init: 1;
1226e3ec7017SPing-Ke Shih 	u32 pta_owner: 1;
1227e3ec7017SPing-Ke Shih 	u32 wl_rfk_timeout: 1;
1228e3ec7017SPing-Ke Shih 	u32 bt_rfk_timeout: 1;
1229e3ec7017SPing-Ke Shih 
1230e3ec7017SPing-Ke Shih 	u32 wl_fw_hang: 1;
1231e3ec7017SPing-Ke Shih 	u32 offload_mismatch: 1;
1232e3ec7017SPing-Ke Shih 	u32 cycle_hang: 1;
1233e3ec7017SPing-Ke Shih 	u32 w1_hang: 1;
1234e3ec7017SPing-Ke Shih 
1235e3ec7017SPing-Ke Shih 	u32 b1_hang: 1;
1236e3ec7017SPing-Ke Shih 	u32 tdma_no_sync: 1;
1237e3ec7017SPing-Ke Shih 	u32 wl_slot_drift: 1;
1238e3ec7017SPing-Ke Shih };
1239e3ec7017SPing-Ke Shih 
1240e3ec7017SPing-Ke Shih union rtw89_btc_dm_error_map {
1241e3ec7017SPing-Ke Shih 	u32 val;
1242e3ec7017SPing-Ke Shih 	struct rtw89_btc_dm_emap map;
1243e3ec7017SPing-Ke Shih };
1244e3ec7017SPing-Ke Shih 
1245e3ec7017SPing-Ke Shih struct rtw89_btc_rf_para {
1246e3ec7017SPing-Ke Shih 	u32 tx_pwr_freerun;
1247e3ec7017SPing-Ke Shih 	u32 rx_gain_freerun;
1248e3ec7017SPing-Ke Shih 	u32 tx_pwr_perpkt;
1249e3ec7017SPing-Ke Shih 	u32 rx_gain_perpkt;
1250e3ec7017SPing-Ke Shih };
1251e3ec7017SPing-Ke Shih 
1252e3ec7017SPing-Ke Shih struct rtw89_btc_wl_info {
125320d9fc88SPing-Ke Shih 	struct rtw89_btc_wl_link_info link_info[RTW89_PORT_NUM];
1254e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_rfk_info rfk_info;
1255e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_ver_info  ver_info;
1256e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_afh_info afh_info;
1257e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_role_info role_info;
1258e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_scan_info scan_info;
1259e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_dbcc_info dbcc_info;
1260e3ec7017SPing-Ke Shih 	struct rtw89_btc_rf_para rf_para;
1261e3ec7017SPing-Ke Shih 	union rtw89_btc_wl_state_map status;
1262e3ec7017SPing-Ke Shih 
1263e3ec7017SPing-Ke Shih 	u8 port_id[RTW89_WIFI_ROLE_MLME_MAX];
1264e3ec7017SPing-Ke Shih 	u8 rssi_level;
1265e3ec7017SPing-Ke Shih 
1266e3ec7017SPing-Ke Shih 	u32 scbd;
1267e3ec7017SPing-Ke Shih };
1268e3ec7017SPing-Ke Shih 
1269e3ec7017SPing-Ke Shih struct rtw89_btc_module {
1270e3ec7017SPing-Ke Shih 	struct rtw89_btc_ant_info ant;
1271e3ec7017SPing-Ke Shih 	u8 rfe_type;
1272e3ec7017SPing-Ke Shih 	u8 cv;
1273e3ec7017SPing-Ke Shih 
1274e3ec7017SPing-Ke Shih 	u8 bt_solo: 1;
1275e3ec7017SPing-Ke Shih 	u8 bt_pos: 1;
1276e3ec7017SPing-Ke Shih 	u8 switch_type: 1;
1277e3ec7017SPing-Ke Shih 
1278e3ec7017SPing-Ke Shih 	u8 rsvd;
1279e3ec7017SPing-Ke Shih };
1280e3ec7017SPing-Ke Shih 
1281e3ec7017SPing-Ke Shih #define RTW89_BTC_DM_MAXSTEP 30
1282e3ec7017SPing-Ke Shih #define RTW89_BTC_DM_CNT_MAX (RTW89_BTC_DM_MAXSTEP * 8)
1283e3ec7017SPing-Ke Shih 
1284e3ec7017SPing-Ke Shih struct rtw89_btc_dm_step {
1285e3ec7017SPing-Ke Shih 	u16 step[RTW89_BTC_DM_MAXSTEP];
1286e3ec7017SPing-Ke Shih 	u8 step_pos;
1287e3ec7017SPing-Ke Shih 	bool step_ov;
1288e3ec7017SPing-Ke Shih };
1289e3ec7017SPing-Ke Shih 
1290e3ec7017SPing-Ke Shih struct rtw89_btc_init_info {
1291e3ec7017SPing-Ke Shih 	struct rtw89_btc_module module;
1292e3ec7017SPing-Ke Shih 	u8 wl_guard_ch;
1293e3ec7017SPing-Ke Shih 
1294e3ec7017SPing-Ke Shih 	u8 wl_only: 1;
1295e3ec7017SPing-Ke Shih 	u8 wl_init_ok: 1;
1296e3ec7017SPing-Ke Shih 	u8 dbcc_en: 1;
1297e3ec7017SPing-Ke Shih 	u8 cx_other: 1;
1298e3ec7017SPing-Ke Shih 	u8 bt_only: 1;
1299e3ec7017SPing-Ke Shih 
1300e3ec7017SPing-Ke Shih 	u16 rsvd;
1301e3ec7017SPing-Ke Shih };
1302e3ec7017SPing-Ke Shih 
1303e3ec7017SPing-Ke Shih struct rtw89_btc_wl_tx_limit_para {
1304e3ec7017SPing-Ke Shih 	u16 enable;
1305e3ec7017SPing-Ke Shih 	u32 tx_time;	/* unit: us */
1306e3ec7017SPing-Ke Shih 	u16 tx_retry;
1307e3ec7017SPing-Ke Shih };
1308e3ec7017SPing-Ke Shih 
1309e3ec7017SPing-Ke Shih struct rtw89_btc_bt_scan_info {
1310e3ec7017SPing-Ke Shih 	u16 win;
1311e3ec7017SPing-Ke Shih 	u16 intvl;
1312e3ec7017SPing-Ke Shih 	u32 enable: 1;
1313e3ec7017SPing-Ke Shih 	u32 interlace: 1;
1314e3ec7017SPing-Ke Shih 	u32 rsvd: 30;
1315e3ec7017SPing-Ke Shih };
1316e3ec7017SPing-Ke Shih 
1317e3ec7017SPing-Ke Shih enum rtw89_btc_bt_scan_type {
1318e3ec7017SPing-Ke Shih 	BTC_SCAN_INQ	= 0,
1319e3ec7017SPing-Ke Shih 	BTC_SCAN_PAGE,
1320e3ec7017SPing-Ke Shih 	BTC_SCAN_BLE,
1321e3ec7017SPing-Ke Shih 	BTC_SCAN_INIT,
1322e3ec7017SPing-Ke Shih 	BTC_SCAN_TV,
1323e3ec7017SPing-Ke Shih 	BTC_SCAN_ADV,
1324e3ec7017SPing-Ke Shih 	BTC_SCAN_MAX1,
1325e3ec7017SPing-Ke Shih };
1326e3ec7017SPing-Ke Shih 
1327e3ec7017SPing-Ke Shih struct rtw89_btc_bt_info {
1328e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_link_info link_info;
1329e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_scan_info scan_info[BTC_SCAN_MAX1];
1330e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_ver_info ver_info;
1331e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg enable;
1332e3ec7017SPing-Ke Shih 	struct rtw89_btc_bool_sta_chg inq_pag;
1333e3ec7017SPing-Ke Shih 	struct rtw89_btc_rf_para rf_para;
1334e3ec7017SPing-Ke Shih 	union rtw89_btc_bt_rfk_info_map rfk_info;
1335e3ec7017SPing-Ke Shih 
1336e3ec7017SPing-Ke Shih 	u8 raw_info[BTC_BTINFO_MAX]; /* raw bt info from mailbox */
1337e3ec7017SPing-Ke Shih 
1338e3ec7017SPing-Ke Shih 	u32 scbd;
1339e3ec7017SPing-Ke Shih 	u32 feature;
1340e3ec7017SPing-Ke Shih 
1341e3ec7017SPing-Ke Shih 	u32 mbx_avl: 1;
1342e3ec7017SPing-Ke Shih 	u32 whql_test: 1;
1343e3ec7017SPing-Ke Shih 	u32 igno_wl: 1;
1344e3ec7017SPing-Ke Shih 	u32 reinit: 1;
1345e3ec7017SPing-Ke Shih 	u32 ble_scan_en: 1;
1346e3ec7017SPing-Ke Shih 	u32 btg_type: 1;
1347e3ec7017SPing-Ke Shih 	u32 inq: 1;
1348e3ec7017SPing-Ke Shih 	u32 pag: 1;
1349e3ec7017SPing-Ke Shih 	u32 run_patch_code: 1;
1350e3ec7017SPing-Ke Shih 	u32 hi_lna_rx: 1;
1351e3ec7017SPing-Ke Shih 	u32 rsvd: 22;
1352e3ec7017SPing-Ke Shih };
1353e3ec7017SPing-Ke Shih 
1354e3ec7017SPing-Ke Shih struct rtw89_btc_cx {
1355e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_info wl;
1356e3ec7017SPing-Ke Shih 	struct rtw89_btc_bt_info bt;
1357e3ec7017SPing-Ke Shih 	struct rtw89_btc_3rdcx_info other;
1358e3ec7017SPing-Ke Shih 	u32 state_map;
1359e3ec7017SPing-Ke Shih 	u32 cnt_bt[BTC_BCNT_NUM];
1360e3ec7017SPing-Ke Shih 	u32 cnt_wl[BTC_WCNT_NUM];
1361e3ec7017SPing-Ke Shih };
1362e3ec7017SPing-Ke Shih 
1363e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_tdma {
1364e3ec7017SPing-Ke Shih 	u8 type;
1365e3ec7017SPing-Ke Shih 	u8 rxflctrl;
1366e3ec7017SPing-Ke Shih 	u8 txpause;
1367e3ec7017SPing-Ke Shih 	u8 wtgle_n;
1368e3ec7017SPing-Ke Shih 	u8 leak_n;
1369e3ec7017SPing-Ke Shih 	u8 ext_ctrl;
1370e3ec7017SPing-Ke Shih 	u8 rsvd0;
1371e3ec7017SPing-Ke Shih 	u8 rsvd1;
1372e3ec7017SPing-Ke Shih } __packed;
1373e3ec7017SPing-Ke Shih 
1374e3ec7017SPing-Ke Shih #define CXMREG_MAX 30
1375e3ec7017SPing-Ke Shih #define FCXMAX_STEP 255 /*STEP trace record cnt, Max:65535, default:255*/
1376e3ec7017SPing-Ke Shih #define BTCRPT_VER 1
1377e3ec7017SPing-Ke Shih #define BTC_CYCLE_SLOT_MAX 48 /* must be even number, non-zero */
1378e3ec7017SPing-Ke Shih 
1379e3ec7017SPing-Ke Shih enum rtw89_btc_bt_rfk_counter {
1380e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_REQ = 0,
1381e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_GO = 1,
1382e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_REJECT = 2,
1383e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_FAIL = 3,
1384e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_TIMEOUT = 4,
1385e3ec7017SPing-Ke Shih 	BTC_BCNT_RFK_MAX
1386e3ec7017SPing-Ke Shih };
1387e3ec7017SPing-Ke Shih 
1388e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_rpt_ctrl {
1389e3ec7017SPing-Ke Shih 	u16 fver;
1390e3ec7017SPing-Ke Shih 	u16 rpt_cnt; /* tmr counters */
1391e3ec7017SPing-Ke Shih 	u32 wl_fw_coex_ver; /* match which driver's coex version */
1392e3ec7017SPing-Ke Shih 	u32 wl_fw_cx_offload;
1393e3ec7017SPing-Ke Shih 	u32 wl_fw_ver;
1394e3ec7017SPing-Ke Shih 	u32 rpt_enable;
1395e3ec7017SPing-Ke Shih 	u32 rpt_para; /* ms */
1396e3ec7017SPing-Ke Shih 	u32 mb_send_fail_cnt; /* fw send mailbox fail counter */
1397e3ec7017SPing-Ke Shih 	u32 mb_send_ok_cnt; /* fw send mailbox ok counter */
1398e3ec7017SPing-Ke Shih 	u32 mb_recv_cnt; /* fw recv mailbox counter */
1399e3ec7017SPing-Ke Shih 	u32 mb_a2dp_empty_cnt; /* a2dp empty count */
1400e3ec7017SPing-Ke Shih 	u32 mb_a2dp_flct_cnt; /* a2dp empty flow control counter */
1401e3ec7017SPing-Ke Shih 	u32 mb_a2dp_full_cnt; /* a2dp empty full counter */
1402e3ec7017SPing-Ke Shih 	u32 bt_rfk_cnt[BTC_BCNT_RFK_MAX];
1403e3ec7017SPing-Ke Shih 	u32 c2h_cnt; /* fw send c2h counter  */
1404e3ec7017SPing-Ke Shih 	u32 h2c_cnt; /* fw recv h2c counter */
1405e3ec7017SPing-Ke Shih } __packed;
1406e3ec7017SPing-Ke Shih 
1407e3ec7017SPing-Ke Shih enum rtw89_fbtc_ext_ctrl_type {
1408e3ec7017SPing-Ke Shih 	CXECTL_OFF = 0x0, /* tdma off */
1409e3ec7017SPing-Ke Shih 	CXECTL_B2 = 0x1, /* allow B2 (beacon-early) */
1410e3ec7017SPing-Ke Shih 	CXECTL_EXT = 0x2,
1411e3ec7017SPing-Ke Shih 	CXECTL_MAX
1412e3ec7017SPing-Ke Shih };
1413e3ec7017SPing-Ke Shih 
1414e3ec7017SPing-Ke Shih union rtw89_btc_fbtc_rxflct {
1415e3ec7017SPing-Ke Shih 	u8 val;
1416e3ec7017SPing-Ke Shih 	u8 type: 3;
1417e3ec7017SPing-Ke Shih 	u8 tgln_n: 5;
1418e3ec7017SPing-Ke Shih };
1419e3ec7017SPing-Ke Shih 
1420e3ec7017SPing-Ke Shih enum rtw89_btc_cxst_state {
1421e3ec7017SPing-Ke Shih 	CXST_OFF = 0x0,
1422e3ec7017SPing-Ke Shih 	CXST_B2W = 0x1,
1423e3ec7017SPing-Ke Shih 	CXST_W1 = 0x2,
1424e3ec7017SPing-Ke Shih 	CXST_W2 = 0x3,
1425e3ec7017SPing-Ke Shih 	CXST_W2B = 0x4,
1426e3ec7017SPing-Ke Shih 	CXST_B1 = 0x5,
1427e3ec7017SPing-Ke Shih 	CXST_B2 = 0x6,
1428e3ec7017SPing-Ke Shih 	CXST_B3 = 0x7,
1429e3ec7017SPing-Ke Shih 	CXST_B4 = 0x8,
1430e3ec7017SPing-Ke Shih 	CXST_LK = 0x9,
1431e3ec7017SPing-Ke Shih 	CXST_BLK = 0xa,
1432e3ec7017SPing-Ke Shih 	CXST_E2G = 0xb,
1433e3ec7017SPing-Ke Shih 	CXST_E5G = 0xc,
1434e3ec7017SPing-Ke Shih 	CXST_EBT = 0xd,
1435e3ec7017SPing-Ke Shih 	CXST_ENULL = 0xe,
1436e3ec7017SPing-Ke Shih 	CXST_WLK = 0xf,
1437e3ec7017SPing-Ke Shih 	CXST_W1FDD = 0x10,
1438e3ec7017SPing-Ke Shih 	CXST_B1FDD = 0x11,
1439e3ec7017SPing-Ke Shih 	CXST_MAX = 0x12,
1440e3ec7017SPing-Ke Shih };
1441e3ec7017SPing-Ke Shih 
1442e3ec7017SPing-Ke Shih enum {
1443e3ec7017SPing-Ke Shih 	CXBCN_ALL = 0x0,
1444e3ec7017SPing-Ke Shih 	CXBCN_ALL_OK,
1445e3ec7017SPing-Ke Shih 	CXBCN_BT_SLOT,
1446e3ec7017SPing-Ke Shih 	CXBCN_BT_OK,
1447e3ec7017SPing-Ke Shih 	CXBCN_MAX
1448e3ec7017SPing-Ke Shih };
1449e3ec7017SPing-Ke Shih 
1450e3ec7017SPing-Ke Shih enum btc_slot_type {
1451e3ec7017SPing-Ke Shih 	SLOT_MIX = 0x0, /* accept BT Lower-Pri Tx/Rx request 0x778 = 1 */
1452e3ec7017SPing-Ke Shih 	SLOT_ISO = 0x1, /* no accept BT Lower-Pri Tx/Rx request 0x778 = d*/
1453e3ec7017SPing-Ke Shih 	CXSTYPE_NUM,
1454e3ec7017SPing-Ke Shih };
1455e3ec7017SPing-Ke Shih 
1456e3ec7017SPing-Ke Shih enum { /* TIME */
1457e3ec7017SPing-Ke Shih 	CXT_BT = 0x0,
1458e3ec7017SPing-Ke Shih 	CXT_WL = 0x1,
1459e3ec7017SPing-Ke Shih 	CXT_MAX
1460e3ec7017SPing-Ke Shih };
1461e3ec7017SPing-Ke Shih 
1462e3ec7017SPing-Ke Shih enum { /* TIME-A2DP */
1463e3ec7017SPing-Ke Shih 	CXT_FLCTRL_OFF = 0x0,
1464e3ec7017SPing-Ke Shih 	CXT_FLCTRL_ON = 0x1,
1465e3ec7017SPing-Ke Shih 	CXT_FLCTRL_MAX
1466e3ec7017SPing-Ke Shih };
1467e3ec7017SPing-Ke Shih 
1468e3ec7017SPing-Ke Shih enum { /* STEP TYPE */
1469e3ec7017SPing-Ke Shih 	CXSTEP_NONE = 0x0,
1470e3ec7017SPing-Ke Shih 	CXSTEP_EVNT = 0x1,
1471e3ec7017SPing-Ke Shih 	CXSTEP_SLOT = 0x2,
1472e3ec7017SPing-Ke Shih 	CXSTEP_MAX,
1473e3ec7017SPing-Ke Shih };
1474e3ec7017SPing-Ke Shih 
1475e3ec7017SPing-Ke Shih #define FCXGPIODBG_VER 1
1476e3ec7017SPing-Ke Shih #define BTC_DBG_MAX1  32
1477e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_gpio_dbg {
1478e3ec7017SPing-Ke Shih 	u8 fver;
1479e3ec7017SPing-Ke Shih 	u8 rsvd;
1480e3ec7017SPing-Ke Shih 	u16 rsvd2;
1481e3ec7017SPing-Ke Shih 	u32 en_map; /* which debug signal (see btc_wl_gpio_debug) is enable */
1482e3ec7017SPing-Ke Shih 	u32 pre_state; /* the debug signal is 1 or 0  */
1483e3ec7017SPing-Ke Shih 	u8 gpio_map[BTC_DBG_MAX1]; /*the debug signals to GPIO-Position */
1484e3ec7017SPing-Ke Shih } __packed;
1485e3ec7017SPing-Ke Shih 
1486e3ec7017SPing-Ke Shih #define FCXMREG_VER 1
1487e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_mreg_val {
1488e3ec7017SPing-Ke Shih 	u8 fver;
1489e3ec7017SPing-Ke Shih 	u8 reg_num;
1490e3ec7017SPing-Ke Shih 	__le16 rsvd;
1491e3ec7017SPing-Ke Shih 	__le32 mreg_val[CXMREG_MAX];
1492e3ec7017SPing-Ke Shih } __packed;
1493e3ec7017SPing-Ke Shih 
1494e3ec7017SPing-Ke Shih #define RTW89_DEF_FBTC_MREG(__type, __bytes, __offset) \
1495e3ec7017SPing-Ke Shih 	{ .type = cpu_to_le16(__type), .bytes = cpu_to_le16(__bytes), \
1496e3ec7017SPing-Ke Shih 	  .offset = cpu_to_le32(__offset), }
1497e3ec7017SPing-Ke Shih 
1498e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_mreg {
1499e3ec7017SPing-Ke Shih 	__le16 type;
1500e3ec7017SPing-Ke Shih 	__le16 bytes;
1501e3ec7017SPing-Ke Shih 	__le32 offset;
1502e3ec7017SPing-Ke Shih } __packed;
1503e3ec7017SPing-Ke Shih 
1504e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slot {
1505e3ec7017SPing-Ke Shih 	__le16 dur;
1506e3ec7017SPing-Ke Shih 	__le32 cxtbl;
1507e3ec7017SPing-Ke Shih 	__le16 cxtype;
1508e3ec7017SPing-Ke Shih } __packed;
1509e3ec7017SPing-Ke Shih 
1510e3ec7017SPing-Ke Shih #define FCXSLOTS_VER 1
1511e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_slots {
1512e3ec7017SPing-Ke Shih 	u8 fver;
1513e3ec7017SPing-Ke Shih 	u8 tbl_num;
1514e3ec7017SPing-Ke Shih 	__le16 rsvd;
1515e3ec7017SPing-Ke Shih 	__le32 update_map;
1516e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slot slot[CXST_MAX];
1517e3ec7017SPing-Ke Shih } __packed;
1518e3ec7017SPing-Ke Shih 
1519e3ec7017SPing-Ke Shih #define FCXSTEP_VER 2
1520e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_step {
1521e3ec7017SPing-Ke Shih 	u8 type;
1522e3ec7017SPing-Ke Shih 	u8 val;
1523e3ec7017SPing-Ke Shih 	__le16 difft;
1524e3ec7017SPing-Ke Shih } __packed;
1525e3ec7017SPing-Ke Shih 
1526e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_steps {
1527e3ec7017SPing-Ke Shih 	u8 fver;
1528e3ec7017SPing-Ke Shih 	u8 rsvd;
1529e3ec7017SPing-Ke Shih 	__le16 cnt;
1530e3ec7017SPing-Ke Shih 	__le16 pos_old;
1531e3ec7017SPing-Ke Shih 	__le16 pos_new;
1532e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_step step[FCXMAX_STEP];
1533e3ec7017SPing-Ke Shih } __packed;
1534e3ec7017SPing-Ke Shih 
1535e3ec7017SPing-Ke Shih #define FCXCYSTA_VER 2
1536e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_cysta { /* statistics for cycles */
1537e3ec7017SPing-Ke Shih 	u8 fver;
1538e3ec7017SPing-Ke Shih 	u8 rsvd;
1539e3ec7017SPing-Ke Shih 	__le16 cycles; /* total cycle number */
1540e3ec7017SPing-Ke Shih 	__le16 cycles_a2dp[CXT_FLCTRL_MAX];
1541e3ec7017SPing-Ke Shih 	__le16 a2dpept; /* a2dp empty cnt */
1542e3ec7017SPing-Ke Shih 	__le16 a2dpeptto; /* a2dp empty timeout cnt*/
1543e3ec7017SPing-Ke Shih 	__le16 tavg_cycle[CXT_MAX]; /* avg wl/bt cycle time */
1544e3ec7017SPing-Ke Shih 	__le16 tmax_cycle[CXT_MAX]; /* max wl/bt cycle time */
1545e3ec7017SPing-Ke Shih 	__le16 tmaxdiff_cycle[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */
1546e3ec7017SPing-Ke Shih 	__le16 tavg_a2dp[CXT_FLCTRL_MAX]; /* avg a2dp PSTDMA/TDMA time */
1547e3ec7017SPing-Ke Shih 	__le16 tmax_a2dp[CXT_FLCTRL_MAX]; /* max a2dp PSTDMA/TDMA time */
1548e3ec7017SPing-Ke Shih 	__le16 tavg_a2dpept; /* avg a2dp empty time */
1549e3ec7017SPing-Ke Shih 	__le16 tmax_a2dpept; /* max a2dp empty time */
1550e3ec7017SPing-Ke Shih 	__le16 tavg_lk; /* avg leak-slot time */
1551e3ec7017SPing-Ke Shih 	__le16 tmax_lk; /* max leak-slot time */
1552e3ec7017SPing-Ke Shih 	__le32 slot_cnt[CXST_MAX]; /* slot count */
1553e3ec7017SPing-Ke Shih 	__le32 bcn_cnt[CXBCN_MAX];
1554e3ec7017SPing-Ke Shih 	__le32 leakrx_cnt; /* the rximr occur at leak slot  */
1555e3ec7017SPing-Ke Shih 	__le32 collision_cnt; /* counter for event/timer occur at same time */
1556e3ec7017SPing-Ke Shih 	__le32 skip_cnt;
1557e3ec7017SPing-Ke Shih 	__le32 exception;
1558e3ec7017SPing-Ke Shih 	__le32 except_cnt;
1559e3ec7017SPing-Ke Shih 	__le16 tslot_cycle[BTC_CYCLE_SLOT_MAX];
1560e3ec7017SPing-Ke Shih } __packed;
1561e3ec7017SPing-Ke Shih 
1562e3ec7017SPing-Ke Shih #define FCXNULLSTA_VER 1
1563e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_cynullsta { /* cycle null statistics */
1564e3ec7017SPing-Ke Shih 	u8 fver;
1565e3ec7017SPing-Ke Shih 	u8 rsvd;
1566e3ec7017SPing-Ke Shih 	__le16 rsvd2;
1567e3ec7017SPing-Ke Shih 	__le32 max_t[2]; /* max_t for 0:null0/1:null1 */
1568e3ec7017SPing-Ke Shih 	__le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */
1569e3ec7017SPing-Ke Shih 	__le32 result[2][4]; /* 0:fail, 1:ok, 2:on_time, 3:retry */
1570e3ec7017SPing-Ke Shih } __packed;
1571e3ec7017SPing-Ke Shih 
1572e3ec7017SPing-Ke Shih #define FCX_BTVER_VER 1
1573e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btver {
1574e3ec7017SPing-Ke Shih 	u8 fver;
1575e3ec7017SPing-Ke Shih 	u8 rsvd;
1576e3ec7017SPing-Ke Shih 	__le16 rsvd2;
1577e3ec7017SPing-Ke Shih 	__le32 coex_ver; /*bit[15:8]->shared, bit[7:0]->non-shared */
1578e3ec7017SPing-Ke Shih 	__le32 fw_ver;
1579e3ec7017SPing-Ke Shih 	__le32 feature;
1580e3ec7017SPing-Ke Shih } __packed;
1581e3ec7017SPing-Ke Shih 
1582e3ec7017SPing-Ke Shih #define FCX_BTSCAN_VER 1
1583e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btscan {
1584e3ec7017SPing-Ke Shih 	u8 fver;
1585e3ec7017SPing-Ke Shih 	u8 rsvd;
1586e3ec7017SPing-Ke Shih 	__le16 rsvd2;
1587e3ec7017SPing-Ke Shih 	u8 scan[6];
1588e3ec7017SPing-Ke Shih } __packed;
1589e3ec7017SPing-Ke Shih 
1590e3ec7017SPing-Ke Shih #define FCX_BTAFH_VER 1
1591e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btafh {
1592e3ec7017SPing-Ke Shih 	u8 fver;
1593e3ec7017SPing-Ke Shih 	u8 rsvd;
1594e3ec7017SPing-Ke Shih 	__le16 rsvd2;
1595e3ec7017SPing-Ke Shih 	u8 afh_l[4]; /*bit0:2402, bit1: 2403.... bit31:2433 */
1596e3ec7017SPing-Ke Shih 	u8 afh_m[4]; /*bit0:2434, bit1: 2435.... bit31:2465 */
1597e3ec7017SPing-Ke Shih 	u8 afh_h[4]; /*bit0:2466, bit1:2467......bit14:2480 */
1598e3ec7017SPing-Ke Shih } __packed;
1599e3ec7017SPing-Ke Shih 
1600e3ec7017SPing-Ke Shih #define FCX_BTDEVINFO_VER 1
1601e3ec7017SPing-Ke Shih struct rtw89_btc_fbtc_btdevinfo {
1602e3ec7017SPing-Ke Shih 	u8 fver;
1603e3ec7017SPing-Ke Shih 	u8 rsvd;
1604e3ec7017SPing-Ke Shih 	__le16 vendor_id;
1605e3ec7017SPing-Ke Shih 	__le32 dev_name; /* only 24 bits valid */
1606e3ec7017SPing-Ke Shih 	__le32 flush_time;
1607e3ec7017SPing-Ke Shih } __packed;
1608e3ec7017SPing-Ke Shih 
1609e3ec7017SPing-Ke Shih #define RTW89_BTC_WL_DEF_TX_PWR GENMASK(7, 0)
1610e3ec7017SPing-Ke Shih struct rtw89_btc_rf_trx_para {
1611e3ec7017SPing-Ke Shih 	u32 wl_tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
1612e3ec7017SPing-Ke Shih 	u32 wl_rx_gain;  /* rx gain table index (TBD.) */
1613e3ec7017SPing-Ke Shih 	u8 bt_tx_power; /* decrease Tx power (dB) */
1614e3ec7017SPing-Ke Shih 	u8 bt_rx_gain;  /* LNA constrain level */
1615e3ec7017SPing-Ke Shih };
1616e3ec7017SPing-Ke Shih 
1617e3ec7017SPing-Ke Shih struct rtw89_btc_dm {
1618e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slot slot[CXST_MAX];
1619e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slot slot_now[CXST_MAX];
1620e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_tdma tdma;
1621e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_tdma tdma_now;
1622e3ec7017SPing-Ke Shih 	struct rtw89_mac_ax_coex_gnt gnt;
1623e3ec7017SPing-Ke Shih 	struct rtw89_btc_init_info init_info; /* pass to wl_fw if offload */
1624e3ec7017SPing-Ke Shih 	struct rtw89_btc_rf_trx_para rf_trx_para;
1625e3ec7017SPing-Ke Shih 	struct rtw89_btc_wl_tx_limit_para wl_tx_limit;
1626e3ec7017SPing-Ke Shih 	struct rtw89_btc_dm_step dm_step;
1627e3ec7017SPing-Ke Shih 	union rtw89_btc_dm_error_map error;
1628e3ec7017SPing-Ke Shih 	u32 cnt_dm[BTC_DCNT_NUM];
1629e3ec7017SPing-Ke Shih 	u32 cnt_notify[BTC_NCNT_NUM];
1630e3ec7017SPing-Ke Shih 
1631e3ec7017SPing-Ke Shih 	u32 update_slot_map;
1632e3ec7017SPing-Ke Shih 	u32 set_ant_path;
1633e3ec7017SPing-Ke Shih 
1634e3ec7017SPing-Ke Shih 	u32 wl_only: 1;
1635e3ec7017SPing-Ke Shih 	u32 wl_fw_cx_offload: 1;
1636e3ec7017SPing-Ke Shih 	u32 freerun: 1;
1637e3ec7017SPing-Ke Shih 	u32 wl_ps_ctrl: 2;
1638e3ec7017SPing-Ke Shih 	u32 wl_mimo_ps: 1;
1639e3ec7017SPing-Ke Shih 	u32 leak_ap: 1;
1640e3ec7017SPing-Ke Shih 	u32 noisy_level: 3;
1641e3ec7017SPing-Ke Shih 	u32 coex_info_map: 8;
1642e3ec7017SPing-Ke Shih 	u32 bt_only: 1;
1643e3ec7017SPing-Ke Shih 	u32 wl_btg_rx: 1;
1644e3ec7017SPing-Ke Shih 	u32 trx_para_level: 8;
1645e3ec7017SPing-Ke Shih 	u32 wl_stb_chg: 1;
1646e3ec7017SPing-Ke Shih 	u32 rsvd: 3;
1647e3ec7017SPing-Ke Shih 
1648e3ec7017SPing-Ke Shih 	u16 slot_dur[CXST_MAX];
1649e3ec7017SPing-Ke Shih 
1650e3ec7017SPing-Ke Shih 	u8 run_reason;
1651e3ec7017SPing-Ke Shih 	u8 run_action;
1652e3ec7017SPing-Ke Shih };
1653e3ec7017SPing-Ke Shih 
1654e3ec7017SPing-Ke Shih struct rtw89_btc_ctrl {
1655e3ec7017SPing-Ke Shih 	u32 manual: 1;
1656e3ec7017SPing-Ke Shih 	u32 igno_bt: 1;
1657e3ec7017SPing-Ke Shih 	u32 always_freerun: 1;
1658e3ec7017SPing-Ke Shih 	u32 trace_step: 16;
1659e3ec7017SPing-Ke Shih 	u32 rsvd: 12;
1660e3ec7017SPing-Ke Shih };
1661e3ec7017SPing-Ke Shih 
1662e3ec7017SPing-Ke Shih struct rtw89_btc_dbg {
1663e3ec7017SPing-Ke Shih 	/* cmd "rb" */
1664e3ec7017SPing-Ke Shih 	bool rb_done;
1665e3ec7017SPing-Ke Shih 	u32 rb_val;
1666e3ec7017SPing-Ke Shih };
1667e3ec7017SPing-Ke Shih 
1668e3ec7017SPing-Ke Shih #define FCXTDMA_VER 1
1669e3ec7017SPing-Ke Shih 
1670e3ec7017SPing-Ke Shih enum rtw89_btc_btf_fw_event {
1671e3ec7017SPing-Ke Shih 	BTF_EVNT_RPT = 0,
1672e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_INFO = 1,
1673e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_SCBD = 2,
1674e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_REG = 3,
1675e3ec7017SPing-Ke Shih 	BTF_EVNT_CX_RUNINFO = 4,
1676e3ec7017SPing-Ke Shih 	BTF_EVNT_BT_PSD = 5,
1677e3ec7017SPing-Ke Shih 	BTF_EVNT_BUF_OVERFLOW,
1678e3ec7017SPing-Ke Shih 	BTF_EVNT_C2H_LOOPBACK,
1679e3ec7017SPing-Ke Shih 	BTF_EVNT_MAX,
1680e3ec7017SPing-Ke Shih };
1681e3ec7017SPing-Ke Shih 
1682e3ec7017SPing-Ke Shih enum btf_fw_event_report {
1683e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_CTRL = 0x0,
1684e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_TDMA,
1685e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_SLOT,
1686e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_CYSTA,
1687e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_STEP,
1688e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_NULLSTA,
1689e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_MREG,
1690e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_GPIO_DBG,
1691e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_VER,
1692e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_SCAN,
1693e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_AFH,
1694e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_BT_DEVICE,
1695e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_TEST,
1696e3ec7017SPing-Ke Shih 	BTC_RPT_TYPE_MAX = 31
1697e3ec7017SPing-Ke Shih };
1698e3ec7017SPing-Ke Shih 
1699e3ec7017SPing-Ke Shih enum rtw_btc_btf_reg_type {
1700e3ec7017SPing-Ke Shih 	REG_MAC = 0x0,
1701e3ec7017SPing-Ke Shih 	REG_BB = 0x1,
1702e3ec7017SPing-Ke Shih 	REG_RF = 0x2,
1703e3ec7017SPing-Ke Shih 	REG_BT_RF = 0x3,
1704e3ec7017SPing-Ke Shih 	REG_BT_MODEM = 0x4,
1705e3ec7017SPing-Ke Shih 	REG_BT_BLUEWIZE = 0x5,
1706e3ec7017SPing-Ke Shih 	REG_BT_VENDOR = 0x6,
1707e3ec7017SPing-Ke Shih 	REG_BT_LE = 0x7,
1708e3ec7017SPing-Ke Shih 	REG_MAX_TYPE,
1709e3ec7017SPing-Ke Shih };
1710e3ec7017SPing-Ke Shih 
1711e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_cmn_info {
1712e3ec7017SPing-Ke Shih 	u32 rx_cnt;
1713e3ec7017SPing-Ke Shih 	u32 rx_len;
1714e3ec7017SPing-Ke Shih 	u32 req_len; /* expected rsp len */
1715e3ec7017SPing-Ke Shih 	u8 req_fver; /* expected rsp fver */
1716e3ec7017SPing-Ke Shih 	u8 rsp_fver; /* fver from fw */
1717e3ec7017SPing-Ke Shih 	u8 valid;
1718e3ec7017SPing-Ke Shih } __packed;
1719e3ec7017SPing-Ke Shih 
1720e3ec7017SPing-Ke Shih struct rtw89_btc_report_ctrl_state {
1721e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1722e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_rpt_ctrl finfo; /* info from fw */
1723e3ec7017SPing-Ke Shih };
1724e3ec7017SPing-Ke Shih 
1725e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_tdma {
1726e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1727e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_tdma finfo; /* info from fw */
1728e3ec7017SPing-Ke Shih };
1729e3ec7017SPing-Ke Shih 
1730e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_slots {
1731e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1732e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_slots finfo; /* info from fw */
1733e3ec7017SPing-Ke Shih };
1734e3ec7017SPing-Ke Shih 
1735e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_cysta {
1736e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1737e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_cysta finfo; /* info from fw */
1738e3ec7017SPing-Ke Shih };
1739e3ec7017SPing-Ke Shih 
1740e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_step {
1741e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1742e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_steps finfo; /* info from fw */
1743e3ec7017SPing-Ke Shih };
1744e3ec7017SPing-Ke Shih 
1745e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_nullsta {
1746e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1747e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_cynullsta finfo; /* info from fw */
1748e3ec7017SPing-Ke Shih };
1749e3ec7017SPing-Ke Shih 
1750e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_mreg {
1751e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1752e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_mreg_val finfo; /* info from fw */
1753e3ec7017SPing-Ke Shih };
1754e3ec7017SPing-Ke Shih 
1755e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_gpio_dbg {
1756e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1757e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_gpio_dbg finfo; /* info from fw */
1758e3ec7017SPing-Ke Shih };
1759e3ec7017SPing-Ke Shih 
1760e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btver {
1761e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1762e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_btver finfo; /* info from fw */
1763e3ec7017SPing-Ke Shih };
1764e3ec7017SPing-Ke Shih 
1765e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btscan {
1766e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1767e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_btscan finfo; /* info from fw */
1768e3ec7017SPing-Ke Shih };
1769e3ec7017SPing-Ke Shih 
1770e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btafh {
1771e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1772e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_btafh finfo; /* info from fw */
1773e3ec7017SPing-Ke Shih };
1774e3ec7017SPing-Ke Shih 
1775e3ec7017SPing-Ke Shih struct rtw89_btc_rpt_fbtc_btdev {
1776e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
1777e3ec7017SPing-Ke Shih 	struct rtw89_btc_fbtc_btdevinfo finfo; /* info from fw */
1778e3ec7017SPing-Ke Shih };
1779e3ec7017SPing-Ke Shih 
1780e3ec7017SPing-Ke Shih enum rtw89_btc_btfre_type {
1781e3ec7017SPing-Ke Shih 	BTFRE_INVALID_INPUT = 0x0, /* invalid input parameters */
1782e3ec7017SPing-Ke Shih 	BTFRE_UNDEF_TYPE,
1783e3ec7017SPing-Ke Shih 	BTFRE_EXCEPTION,
1784e3ec7017SPing-Ke Shih 	BTFRE_MAX,
1785e3ec7017SPing-Ke Shih };
1786e3ec7017SPing-Ke Shih 
1787e3ec7017SPing-Ke Shih struct rtw89_btc_btf_fwinfo {
1788e3ec7017SPing-Ke Shih 	u32 cnt_c2h;
1789e3ec7017SPing-Ke Shih 	u32 cnt_h2c;
1790e3ec7017SPing-Ke Shih 	u32 cnt_h2c_fail;
1791e3ec7017SPing-Ke Shih 	u32 event[BTF_EVNT_MAX];
1792e3ec7017SPing-Ke Shih 
1793e3ec7017SPing-Ke Shih 	u32 err[BTFRE_MAX];
1794e3ec7017SPing-Ke Shih 	u32 len_mismch;
1795e3ec7017SPing-Ke Shih 	u32 fver_mismch;
1796e3ec7017SPing-Ke Shih 	u32 rpt_en_map;
1797e3ec7017SPing-Ke Shih 
1798e3ec7017SPing-Ke Shih 	struct rtw89_btc_report_ctrl_state rpt_ctrl;
1799e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_tdma rpt_fbtc_tdma;
1800e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_slots rpt_fbtc_slots;
1801e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_cysta rpt_fbtc_cysta;
1802e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_step rpt_fbtc_step;
1803e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_nullsta rpt_fbtc_nullsta;
1804e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_mreg rpt_fbtc_mregval;
1805e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_gpio_dbg rpt_fbtc_gpio_dbg;
1806e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btver rpt_fbtc_btver;
1807e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btscan rpt_fbtc_btscan;
1808e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btafh rpt_fbtc_btafh;
1809e3ec7017SPing-Ke Shih 	struct rtw89_btc_rpt_fbtc_btdev rpt_fbtc_btdev;
1810e3ec7017SPing-Ke Shih };
1811e3ec7017SPing-Ke Shih 
1812e3ec7017SPing-Ke Shih #define RTW89_BTC_POLICY_MAXLEN 512
1813e3ec7017SPing-Ke Shih 
1814e3ec7017SPing-Ke Shih struct rtw89_btc {
1815e3ec7017SPing-Ke Shih 	struct rtw89_btc_cx cx;
1816e3ec7017SPing-Ke Shih 	struct rtw89_btc_dm dm;
1817e3ec7017SPing-Ke Shih 	struct rtw89_btc_ctrl ctrl;
1818e3ec7017SPing-Ke Shih 	struct rtw89_btc_module mdinfo;
1819e3ec7017SPing-Ke Shih 	struct rtw89_btc_btf_fwinfo fwinfo;
1820e3ec7017SPing-Ke Shih 	struct rtw89_btc_dbg dbg;
1821e3ec7017SPing-Ke Shih 
1822e3ec7017SPing-Ke Shih 	struct work_struct eapol_notify_work;
1823e3ec7017SPing-Ke Shih 	struct work_struct arp_notify_work;
1824e3ec7017SPing-Ke Shih 	struct work_struct dhcp_notify_work;
1825e3ec7017SPing-Ke Shih 	struct work_struct icmp_notify_work;
1826e3ec7017SPing-Ke Shih 
1827e3ec7017SPing-Ke Shih 	u32 bt_req_len;
1828e3ec7017SPing-Ke Shih 
1829e3ec7017SPing-Ke Shih 	u8 policy[RTW89_BTC_POLICY_MAXLEN];
1830e3ec7017SPing-Ke Shih 	u16 policy_len;
1831e3ec7017SPing-Ke Shih 	u16 policy_type;
1832e3ec7017SPing-Ke Shih 	bool bt_req_en;
1833e3ec7017SPing-Ke Shih 	bool update_policy_force;
1834e3ec7017SPing-Ke Shih 	bool lps;
1835e3ec7017SPing-Ke Shih };
1836e3ec7017SPing-Ke Shih 
1837e3ec7017SPing-Ke Shih enum rtw89_ra_mode {
1838e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_CCK = BIT(0),
1839e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_OFDM = BIT(1),
1840e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_HT = BIT(2),
1841e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_VHT = BIT(3),
1842e3ec7017SPing-Ke Shih 	RTW89_RA_MODE_HE = BIT(4),
1843e3ec7017SPing-Ke Shih };
1844e3ec7017SPing-Ke Shih 
1845e3ec7017SPing-Ke Shih enum rtw89_ra_report_mode {
1846e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_LEGACY,
1847e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_HT,
1848e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_VHT,
1849e3ec7017SPing-Ke Shih 	RTW89_RA_RPT_MODE_HE,
1850e3ec7017SPing-Ke Shih };
1851e3ec7017SPing-Ke Shih 
1852e3ec7017SPing-Ke Shih enum rtw89_dig_noisy_level {
1853e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL0 = -1,
1854e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL1 = 0,
1855e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL2 = 1,
1856e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL3 = 2,
1857e3ec7017SPing-Ke Shih 	RTW89_DIG_NOISY_LEVEL_MAX = 3,
1858e3ec7017SPing-Ke Shih };
1859e3ec7017SPing-Ke Shih 
1860e3ec7017SPing-Ke Shih enum rtw89_gi_ltf {
1861e3ec7017SPing-Ke Shih 	RTW89_GILTF_LGI_4XHE32 = 0,
1862e3ec7017SPing-Ke Shih 	RTW89_GILTF_SGI_4XHE08 = 1,
1863e3ec7017SPing-Ke Shih 	RTW89_GILTF_2XHE16 = 2,
1864e3ec7017SPing-Ke Shih 	RTW89_GILTF_2XHE08 = 3,
1865e3ec7017SPing-Ke Shih 	RTW89_GILTF_1XHE16 = 4,
1866e3ec7017SPing-Ke Shih 	RTW89_GILTF_1XHE08 = 5,
1867e3ec7017SPing-Ke Shih 	RTW89_GILTF_MAX
1868e3ec7017SPing-Ke Shih };
1869e3ec7017SPing-Ke Shih 
1870e3ec7017SPing-Ke Shih enum rtw89_rx_frame_type {
1871e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_MGNT = 0,
1872e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_CTRL = 1,
1873e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_DATA = 2,
1874e3ec7017SPing-Ke Shih 	RTW89_RX_TYPE_RSVD = 3,
1875e3ec7017SPing-Ke Shih };
1876e3ec7017SPing-Ke Shih 
1877e3ec7017SPing-Ke Shih struct rtw89_ra_info {
1878e3ec7017SPing-Ke Shih 	u8 is_dis_ra:1;
1879e3ec7017SPing-Ke Shih 	/* Bit0 : CCK
1880e3ec7017SPing-Ke Shih 	 * Bit1 : OFDM
1881e3ec7017SPing-Ke Shih 	 * Bit2 : HT
1882e3ec7017SPing-Ke Shih 	 * Bit3 : VHT
1883e3ec7017SPing-Ke Shih 	 * Bit4 : HE
1884e3ec7017SPing-Ke Shih 	 */
1885e3ec7017SPing-Ke Shih 	u8 mode_ctrl:5;
1886e3ec7017SPing-Ke Shih 	u8 bw_cap:2;
1887e3ec7017SPing-Ke Shih 	u8 macid;
1888e3ec7017SPing-Ke Shih 	u8 dcm_cap:1;
1889e3ec7017SPing-Ke Shih 	u8 er_cap:1;
1890e3ec7017SPing-Ke Shih 	u8 init_rate_lv:2;
1891e3ec7017SPing-Ke Shih 	u8 upd_all:1;
1892e3ec7017SPing-Ke Shih 	u8 en_sgi:1;
1893e3ec7017SPing-Ke Shih 	u8 ldpc_cap:1;
1894e3ec7017SPing-Ke Shih 	u8 stbc_cap:1;
1895e3ec7017SPing-Ke Shih 	u8 ss_num:3;
1896e3ec7017SPing-Ke Shih 	u8 giltf:3;
1897e3ec7017SPing-Ke Shih 	u8 upd_bw_nss_mask:1;
1898e3ec7017SPing-Ke Shih 	u8 upd_mask:1;
1899e3ec7017SPing-Ke Shih 	u64 ra_mask; /* 63 bits ra_mask + 1 bit CSI ctrl */
1900e3ec7017SPing-Ke Shih 	/* BFee CSI */
1901e3ec7017SPing-Ke Shih 	u8 band_num;
1902e3ec7017SPing-Ke Shih 	u8 ra_csi_rate_en:1;
1903e3ec7017SPing-Ke Shih 	u8 fixed_csi_rate_en:1;
1904e3ec7017SPing-Ke Shih 	u8 cr_tbl_sel:1;
1905e3ec7017SPing-Ke Shih 	u8 rsvd2:5;
1906e3ec7017SPing-Ke Shih 	u8 csi_mcs_ss_idx;
1907e3ec7017SPing-Ke Shih 	u8 csi_mode:2;
1908e3ec7017SPing-Ke Shih 	u8 csi_gi_ltf:3;
1909e3ec7017SPing-Ke Shih 	u8 csi_bw:3;
1910e3ec7017SPing-Ke Shih };
1911e3ec7017SPing-Ke Shih 
1912e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAX_USR 4
1913e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_INFO_USR_SIZE 4
1914e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_INFO_SIZE 8
1915e3ec7017SPing-Ke Shih #define RTW89_PPDU_MAC_RX_CNT_SIZE 96
1916e3ec7017SPing-Ke Shih 
1917e3ec7017SPing-Ke Shih #define RTW89_MAX_RX_AGG_NUM 64
1918e3ec7017SPing-Ke Shih #define RTW89_MAX_TX_AGG_NUM 128
1919e3ec7017SPing-Ke Shih 
1920e3ec7017SPing-Ke Shih struct rtw89_ampdu_params {
1921e3ec7017SPing-Ke Shih 	u16 agg_num;
1922e3ec7017SPing-Ke Shih 	bool amsdu;
1923e3ec7017SPing-Ke Shih };
1924e3ec7017SPing-Ke Shih 
1925e3ec7017SPing-Ke Shih struct rtw89_ra_report {
1926e3ec7017SPing-Ke Shih 	struct rate_info txrate;
1927e3ec7017SPing-Ke Shih 	u32 bit_rate;
1928e3ec7017SPing-Ke Shih 	u16 hw_rate;
1929e3ec7017SPing-Ke Shih };
1930e3ec7017SPing-Ke Shih 
1931e3ec7017SPing-Ke Shih DECLARE_EWMA(rssi, 10, 16);
1932e3ec7017SPing-Ke Shih 
19333ffbb5a8SPing-Ke Shih #define RTW89_BA_CAM_NUM 2
19343ffbb5a8SPing-Ke Shih 
19353ffbb5a8SPing-Ke Shih struct rtw89_ba_cam_entry {
19363ffbb5a8SPing-Ke Shih 	u8 tid;
19373ffbb5a8SPing-Ke Shih };
19383ffbb5a8SPing-Ke Shih 
1939e3ec7017SPing-Ke Shih #define RTW89_MAX_ADDR_CAM_NUM		128
1940e3ec7017SPing-Ke Shih #define RTW89_MAX_BSSID_CAM_NUM		20
1941e3ec7017SPing-Ke Shih #define RTW89_MAX_SEC_CAM_NUM		128
1942e3ec7017SPing-Ke Shih #define RTW89_SEC_CAM_IN_ADDR_CAM	7
1943e3ec7017SPing-Ke Shih 
1944e3ec7017SPing-Ke Shih struct rtw89_addr_cam_entry {
1945e3ec7017SPing-Ke Shih 	u8 addr_cam_idx;
1946e3ec7017SPing-Ke Shih 	u8 offset;
1947e3ec7017SPing-Ke Shih 	u8 len;
1948e3ec7017SPing-Ke Shih 	u8 valid	: 1;
1949e3ec7017SPing-Ke Shih 	u8 addr_mask	: 6;
1950e3ec7017SPing-Ke Shih 	u8 wapi		: 1;
1951e3ec7017SPing-Ke Shih 	u8 mask_sel	: 2;
1952e3ec7017SPing-Ke Shih 	u8 bssid_cam_idx: 6;
1953e3ec7017SPing-Ke Shih 
1954e3ec7017SPing-Ke Shih 	u8 sec_ent_mode;
1955e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(sec_cam_map, RTW89_SEC_CAM_IN_ADDR_CAM);
1956e3ec7017SPing-Ke Shih 	u8 sec_ent_keyid[RTW89_SEC_CAM_IN_ADDR_CAM];
1957e3ec7017SPing-Ke Shih 	u8 sec_ent[RTW89_SEC_CAM_IN_ADDR_CAM];
1958e3ec7017SPing-Ke Shih 	struct rtw89_sec_cam_entry *sec_entries[RTW89_SEC_CAM_IN_ADDR_CAM];
1959e3ec7017SPing-Ke Shih };
1960e3ec7017SPing-Ke Shih 
1961e3ec7017SPing-Ke Shih struct rtw89_bssid_cam_entry {
1962e3ec7017SPing-Ke Shih 	u8 bssid[ETH_ALEN];
1963e3ec7017SPing-Ke Shih 	u8 phy_idx;
1964e3ec7017SPing-Ke Shih 	u8 bssid_cam_idx;
1965e3ec7017SPing-Ke Shih 	u8 offset;
1966e3ec7017SPing-Ke Shih 	u8 len;
1967e3ec7017SPing-Ke Shih 	u8 valid : 1;
1968e3ec7017SPing-Ke Shih 	u8 num;
1969e3ec7017SPing-Ke Shih };
1970e3ec7017SPing-Ke Shih 
1971e3ec7017SPing-Ke Shih struct rtw89_sec_cam_entry {
1972e3ec7017SPing-Ke Shih 	u8 sec_cam_idx;
1973e3ec7017SPing-Ke Shih 	u8 offset;
1974e3ec7017SPing-Ke Shih 	u8 len;
1975e3ec7017SPing-Ke Shih 	u8 type : 4;
1976e3ec7017SPing-Ke Shih 	u8 ext_key : 1;
1977e3ec7017SPing-Ke Shih 	u8 spp_mode : 1;
1978e3ec7017SPing-Ke Shih 	/* 256 bits */
1979e3ec7017SPing-Ke Shih 	u8 key[32];
1980e3ec7017SPing-Ke Shih };
1981e3ec7017SPing-Ke Shih 
19822ab856ccSPing-Ke Shih struct rtw89_sta {
19832ab856ccSPing-Ke Shih 	u8 mac_id;
19842ab856ccSPing-Ke Shih 	bool disassoc;
19852ab856ccSPing-Ke Shih 	struct rtw89_vif *rtwvif;
19862ab856ccSPing-Ke Shih 	struct rtw89_ra_info ra;
19872ab856ccSPing-Ke Shih 	struct rtw89_ra_report ra_report;
19882ab856ccSPing-Ke Shih 	int max_agg_wait;
19892ab856ccSPing-Ke Shih 	u8 prev_rssi;
19902ab856ccSPing-Ke Shih 	struct ewma_rssi avg_rssi;
19912ab856ccSPing-Ke Shih 	struct rtw89_ampdu_params ampdu_params[IEEE80211_NUM_TIDS];
19922ab856ccSPing-Ke Shih 	struct ieee80211_rx_status rx_status;
19932ab856ccSPing-Ke Shih 	u16 rx_hw_rate;
19942ab856ccSPing-Ke Shih 	__le32 htc_template;
19957312100dSPing-Ke Shih 	struct rtw89_addr_cam_entry addr_cam; /* AP mode or TDLS peer only */
199639913cc8SPing-Ke Shih 	struct rtw89_bssid_cam_entry bssid_cam; /* TDLS peer only */
19972ab856ccSPing-Ke Shih 
19982ab856ccSPing-Ke Shih 	bool use_cfg_mask;
19992ab856ccSPing-Ke Shih 	struct cfg80211_bitrate_mask mask;
20002ab856ccSPing-Ke Shih 
20012ab856ccSPing-Ke Shih 	bool cctl_tx_time;
20022ab856ccSPing-Ke Shih 	u32 ampdu_max_time:4;
20032ab856ccSPing-Ke Shih 	bool cctl_tx_retry_limit;
20042ab856ccSPing-Ke Shih 	u32 data_tx_cnt_lmt:6;
20052ab856ccSPing-Ke Shih 
20062ab856ccSPing-Ke Shih 	DECLARE_BITMAP(ba_cam_map, RTW89_BA_CAM_NUM);
20072ab856ccSPing-Ke Shih 	struct rtw89_ba_cam_entry ba_cam_entry[RTW89_BA_CAM_NUM];
20082ab856ccSPing-Ke Shih };
20092ab856ccSPing-Ke Shih 
2010e3ec7017SPing-Ke Shih struct rtw89_efuse {
2011e3ec7017SPing-Ke Shih 	bool valid;
2012e3ec7017SPing-Ke Shih 	u8 xtal_cap;
2013e3ec7017SPing-Ke Shih 	u8 addr[ETH_ALEN];
2014e3ec7017SPing-Ke Shih 	u8 rfe_type;
2015e3ec7017SPing-Ke Shih 	char country_code[2];
2016e3ec7017SPing-Ke Shih };
2017e3ec7017SPing-Ke Shih 
2018e3ec7017SPing-Ke Shih struct rtw89_phy_rate_pattern {
2019e3ec7017SPing-Ke Shih 	u64 ra_mask;
2020e3ec7017SPing-Ke Shih 	u16 rate;
2021e3ec7017SPing-Ke Shih 	u8 ra_mode;
2022e3ec7017SPing-Ke Shih 	bool enable;
2023e3ec7017SPing-Ke Shih };
2024e3ec7017SPing-Ke Shih 
2025e3ec7017SPing-Ke Shih struct rtw89_vif {
2026e3ec7017SPing-Ke Shih 	struct list_head list;
2027d62816b4SPing-Ke Shih 	struct rtw89_dev *rtwdev;
2028e3ec7017SPing-Ke Shih 	u8 mac_id;
2029e3ec7017SPing-Ke Shih 	u8 port;
2030e3ec7017SPing-Ke Shih 	u8 mac_addr[ETH_ALEN];
2031e3ec7017SPing-Ke Shih 	u8 bssid[ETH_ALEN];
2032e3ec7017SPing-Ke Shih 	u8 phy_idx;
2033e3ec7017SPing-Ke Shih 	u8 mac_idx;
2034e3ec7017SPing-Ke Shih 	u8 net_type;
2035e3ec7017SPing-Ke Shih 	u8 wifi_role;
2036e3ec7017SPing-Ke Shih 	u8 self_role;
2037e3ec7017SPing-Ke Shih 	u8 wmm;
2038e3ec7017SPing-Ke Shih 	u8 bcn_hit_cond;
2039e3ec7017SPing-Ke Shih 	u8 hit_rule;
2040e3ec7017SPing-Ke Shih 	bool trigger;
2041e3ec7017SPing-Ke Shih 	bool lsig_txop;
2042e3ec7017SPing-Ke Shih 	u8 tgt_ind;
2043e3ec7017SPing-Ke Shih 	u8 frm_tgt_ind;
2044e3ec7017SPing-Ke Shih 	bool wowlan_pattern;
2045e3ec7017SPing-Ke Shih 	bool wowlan_uc;
2046e3ec7017SPing-Ke Shih 	bool wowlan_magic;
2047e3ec7017SPing-Ke Shih 	bool is_hesta;
2048e3ec7017SPing-Ke Shih 	bool last_a_ctrl;
2049d62816b4SPing-Ke Shih 	struct work_struct update_beacon_work;
2050e3ec7017SPing-Ke Shih 	struct rtw89_addr_cam_entry addr_cam;
2051e3ec7017SPing-Ke Shih 	struct rtw89_bssid_cam_entry bssid_cam;
2052e3ec7017SPing-Ke Shih 	struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS];
2053e3ec7017SPing-Ke Shih 	struct rtw89_traffic_stats stats;
2054e3ec7017SPing-Ke Shih 	struct rtw89_phy_rate_pattern rate_pattern;
205589590777SPo Hao Huang 	struct cfg80211_scan_request *scan_req;
205689590777SPo Hao Huang 	struct ieee80211_scan_ies *scan_ies;
2057e3ec7017SPing-Ke Shih };
2058e3ec7017SPing-Ke Shih 
2059e3ec7017SPing-Ke Shih enum rtw89_lv1_rcvy_step {
2060e3ec7017SPing-Ke Shih 	RTW89_LV1_RCVY_STEP_1,
2061e3ec7017SPing-Ke Shih 	RTW89_LV1_RCVY_STEP_2,
2062e3ec7017SPing-Ke Shih };
2063e3ec7017SPing-Ke Shih 
2064e3ec7017SPing-Ke Shih struct rtw89_hci_ops {
2065e3ec7017SPing-Ke Shih 	int (*tx_write)(struct rtw89_dev *rtwdev, struct rtw89_core_tx_request *tx_req);
2066e3ec7017SPing-Ke Shih 	void (*tx_kick_off)(struct rtw89_dev *rtwdev, u8 txch);
2067e3ec7017SPing-Ke Shih 	void (*flush_queues)(struct rtw89_dev *rtwdev, u32 queues, bool drop);
2068e3ec7017SPing-Ke Shih 	void (*reset)(struct rtw89_dev *rtwdev);
2069e3ec7017SPing-Ke Shih 	int (*start)(struct rtw89_dev *rtwdev);
2070e3ec7017SPing-Ke Shih 	void (*stop)(struct rtw89_dev *rtwdev);
207152edbb9fSPing-Ke Shih 	void (*pause)(struct rtw89_dev *rtwdev, bool pause);
207252edbb9fSPing-Ke Shih 	void (*switch_mode)(struct rtw89_dev *rtwdev, bool low_power);
2073e3ec7017SPing-Ke Shih 	void (*recalc_int_mit)(struct rtw89_dev *rtwdev);
2074e3ec7017SPing-Ke Shih 
2075e3ec7017SPing-Ke Shih 	u8 (*read8)(struct rtw89_dev *rtwdev, u32 addr);
2076e3ec7017SPing-Ke Shih 	u16 (*read16)(struct rtw89_dev *rtwdev, u32 addr);
2077e3ec7017SPing-Ke Shih 	u32 (*read32)(struct rtw89_dev *rtwdev, u32 addr);
2078e3ec7017SPing-Ke Shih 	void (*write8)(struct rtw89_dev *rtwdev, u32 addr, u8 data);
2079e3ec7017SPing-Ke Shih 	void (*write16)(struct rtw89_dev *rtwdev, u32 addr, u16 data);
2080e3ec7017SPing-Ke Shih 	void (*write32)(struct rtw89_dev *rtwdev, u32 addr, u32 data);
2081e3ec7017SPing-Ke Shih 
2082e3ec7017SPing-Ke Shih 	int (*mac_pre_init)(struct rtw89_dev *rtwdev);
2083e3ec7017SPing-Ke Shih 	int (*mac_post_init)(struct rtw89_dev *rtwdev);
2084e3ec7017SPing-Ke Shih 	int (*deinit)(struct rtw89_dev *rtwdev);
2085e3ec7017SPing-Ke Shih 
2086e3ec7017SPing-Ke Shih 	u32 (*check_and_reclaim_tx_resource)(struct rtw89_dev *rtwdev, u8 txch);
2087e3ec7017SPing-Ke Shih 	int (*mac_lv1_rcvy)(struct rtw89_dev *rtwdev, enum rtw89_lv1_rcvy_step step);
2088e3ec7017SPing-Ke Shih 	void (*dump_err_status)(struct rtw89_dev *rtwdev);
2089e3ec7017SPing-Ke Shih 	int (*napi_poll)(struct napi_struct *napi, int budget);
209014f9f479SZong-Zhe Yang 
209114f9f479SZong-Zhe Yang 	/* Deal with locks inside recovery_start and recovery_complete callbacks
209214f9f479SZong-Zhe Yang 	 * by hci instance, and handle things which need to consider under SER.
209314f9f479SZong-Zhe Yang 	 * e.g. turn on/off interrupts except for the one for halt notification.
209414f9f479SZong-Zhe Yang 	 */
209514f9f479SZong-Zhe Yang 	void (*recovery_start)(struct rtw89_dev *rtwdev);
209614f9f479SZong-Zhe Yang 	void (*recovery_complete)(struct rtw89_dev *rtwdev);
2097e3ec7017SPing-Ke Shih };
2098e3ec7017SPing-Ke Shih 
2099e3ec7017SPing-Ke Shih struct rtw89_hci_info {
2100e3ec7017SPing-Ke Shih 	const struct rtw89_hci_ops *ops;
2101e3ec7017SPing-Ke Shih 	enum rtw89_hci_type type;
2102e3ec7017SPing-Ke Shih 	u32 rpwm_addr;
2103e3ec7017SPing-Ke Shih 	u32 cpwm_addr;
210452edbb9fSPing-Ke Shih 	bool paused;
2105e3ec7017SPing-Ke Shih };
2106e3ec7017SPing-Ke Shih 
2107e3ec7017SPing-Ke Shih struct rtw89_chip_ops {
210861ebeecbSPing-Ke Shih 	int (*enable_bb_rf)(struct rtw89_dev *rtwdev);
210961ebeecbSPing-Ke Shih 	void (*disable_bb_rf)(struct rtw89_dev *rtwdev);
2110e3ec7017SPing-Ke Shih 	void (*bb_reset)(struct rtw89_dev *rtwdev,
2111e3ec7017SPing-Ke Shih 			 enum rtw89_phy_idx phy_idx);
2112e3ec7017SPing-Ke Shih 	void (*bb_sethw)(struct rtw89_dev *rtwdev);
2113e3ec7017SPing-Ke Shih 	u32 (*read_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
2114e3ec7017SPing-Ke Shih 		       u32 addr, u32 mask);
2115e3ec7017SPing-Ke Shih 	bool (*write_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
2116e3ec7017SPing-Ke Shih 			 u32 addr, u32 mask, u32 data);
2117e3ec7017SPing-Ke Shih 	void (*set_channel)(struct rtw89_dev *rtwdev,
2118ce57e55cSZong-Zhe Yang 			    const struct rtw89_chan *chan,
2119ce57e55cSZong-Zhe Yang 			    enum rtw89_mac_idx mac_idx,
2120ce57e55cSZong-Zhe Yang 			    enum rtw89_phy_idx phy_idx);
2121e3ec7017SPing-Ke Shih 	void (*set_channel_help)(struct rtw89_dev *rtwdev, bool enter,
2122ce57e55cSZong-Zhe Yang 				 struct rtw89_channel_help_params *p,
2123ce57e55cSZong-Zhe Yang 				 const struct rtw89_chan *chan,
2124ce57e55cSZong-Zhe Yang 				 enum rtw89_mac_idx mac_idx,
2125ce57e55cSZong-Zhe Yang 				 enum rtw89_phy_idx phy_idx);
2126e3ec7017SPing-Ke Shih 	int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map);
2127e3ec7017SPing-Ke Shih 	int (*read_phycap)(struct rtw89_dev *rtwdev, u8 *phycap_map);
2128e3ec7017SPing-Ke Shih 	void (*fem_setup)(struct rtw89_dev *rtwdev);
2129e3ec7017SPing-Ke Shih 	void (*rfk_init)(struct rtw89_dev *rtwdev);
2130e3ec7017SPing-Ke Shih 	void (*rfk_channel)(struct rtw89_dev *rtwdev);
2131010d0051SZong-Zhe Yang 	void (*rfk_band_changed)(struct rtw89_dev *rtwdev,
2132010d0051SZong-Zhe Yang 				 enum rtw89_phy_idx phy_idx);
2133e3ec7017SPing-Ke Shih 	void (*rfk_scan)(struct rtw89_dev *rtwdev, bool start);
2134e3ec7017SPing-Ke Shih 	void (*rfk_track)(struct rtw89_dev *rtwdev);
2135e3ec7017SPing-Ke Shih 	void (*power_trim)(struct rtw89_dev *rtwdev);
213607ef5f2fSZong-Zhe Yang 	void (*set_txpwr)(struct rtw89_dev *rtwdev,
213707ef5f2fSZong-Zhe Yang 			  const struct rtw89_chan *chan,
213807ef5f2fSZong-Zhe Yang 			  enum rtw89_phy_idx phy_idx);
213907ef5f2fSZong-Zhe Yang 	void (*set_txpwr_ctrl)(struct rtw89_dev *rtwdev,
214007ef5f2fSZong-Zhe Yang 			       enum rtw89_phy_idx phy_idx);
2141e3ec7017SPing-Ke Shih 	int (*init_txpwr_unit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
2142e3ec7017SPing-Ke Shih 	u8 (*get_thermal)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path);
2143e3ec7017SPing-Ke Shih 	void (*ctrl_btg)(struct rtw89_dev *rtwdev, bool btg);
2144e3ec7017SPing-Ke Shih 	void (*query_ppdu)(struct rtw89_dev *rtwdev,
2145e3ec7017SPing-Ke Shih 			   struct rtw89_rx_phy_ppdu *phy_ppdu,
2146e3ec7017SPing-Ke Shih 			   struct ieee80211_rx_status *status);
2147e3ec7017SPing-Ke Shih 	void (*bb_ctrl_btc_preagc)(struct rtw89_dev *rtwdev, bool bt_en);
2148cd89a471SPing-Ke Shih 	void (*cfg_txrx_path)(struct rtw89_dev *rtwdev);
2149e3ec7017SPing-Ke Shih 	void (*set_txpwr_ul_tb_offset)(struct rtw89_dev *rtwdev,
2150a9ffae8dSYuan-Han Zhang 				       s8 pw_ofst, enum rtw89_mac_idx mac_idx);
21512a7e54dbSPing-Ke Shih 	int (*pwr_on_func)(struct rtw89_dev *rtwdev);
21522a7e54dbSPing-Ke Shih 	int (*pwr_off_func)(struct rtw89_dev *rtwdev);
2153f59acddeSPing-Ke Shih 	void (*fill_txdesc)(struct rtw89_dev *rtwdev,
2154f59acddeSPing-Ke Shih 			    struct rtw89_tx_desc_info *desc_info,
2155f59acddeSPing-Ke Shih 			    void *txdesc);
2156a95bd62eSPing-Ke Shih 	void (*fill_txdesc_fwcmd)(struct rtw89_dev *rtwdev,
2157a95bd62eSPing-Ke Shih 				  struct rtw89_tx_desc_info *desc_info,
2158a95bd62eSPing-Ke Shih 				  void *txdesc);
2159feed6541SChia-Yuan Li 	int (*cfg_ctrl_path)(struct rtw89_dev *rtwdev, bool wl);
2160feed6541SChia-Yuan Li 	int (*mac_cfg_gnt)(struct rtw89_dev *rtwdev,
2161feed6541SChia-Yuan Li 			   const struct rtw89_mac_ax_coex_gnt *gnt_cfg);
2162de7ba639SPing-Ke Shih 	int (*stop_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx,
2163de7ba639SPing-Ke Shih 			   u32 *tx_en, enum rtw89_sch_tx_sel sel);
2164de7ba639SPing-Ke Shih 	int (*resume_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en);
21650a6f299bSPing-Ke Shih 	int (*h2c_dctl_sec_cam)(struct rtw89_dev *rtwdev,
21660a6f299bSPing-Ke Shih 				struct rtw89_vif *rtwvif,
21670a6f299bSPing-Ke Shih 				struct rtw89_sta *rtwsta);
2168e3ec7017SPing-Ke Shih 
2169e3ec7017SPing-Ke Shih 	void (*btc_set_rfe)(struct rtw89_dev *rtwdev);
2170e3ec7017SPing-Ke Shih 	void (*btc_init_cfg)(struct rtw89_dev *rtwdev);
2171e3ec7017SPing-Ke Shih 	void (*btc_set_wl_pri)(struct rtw89_dev *rtwdev, u8 map, bool state);
2172e3ec7017SPing-Ke Shih 	void (*btc_set_wl_txpwr_ctrl)(struct rtw89_dev *rtwdev, u32 txpwr_val);
2173e3ec7017SPing-Ke Shih 	s8 (*btc_get_bt_rssi)(struct rtw89_dev *rtwdev, s8 val);
2174e3ec7017SPing-Ke Shih 	void (*btc_bt_aci_imp)(struct rtw89_dev *rtwdev);
2175e3ec7017SPing-Ke Shih 	void (*btc_update_bt_cnt)(struct rtw89_dev *rtwdev);
2176e3ec7017SPing-Ke Shih 	void (*btc_wl_s1_standby)(struct rtw89_dev *rtwdev, bool state);
2177e3ec7017SPing-Ke Shih };
2178e3ec7017SPing-Ke Shih 
2179e3ec7017SPing-Ke Shih enum rtw89_dma_ch {
2180e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH0 = 0,
2181e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH1 = 1,
2182e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH2 = 2,
2183e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH3 = 3,
2184e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH4 = 4,
2185e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH5 = 5,
2186e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH6 = 6,
2187e3ec7017SPing-Ke Shih 	RTW89_DMA_ACH7 = 7,
2188e3ec7017SPing-Ke Shih 	RTW89_DMA_B0MG = 8,
2189e3ec7017SPing-Ke Shih 	RTW89_DMA_B0HI = 9,
2190e3ec7017SPing-Ke Shih 	RTW89_DMA_B1MG = 10,
2191e3ec7017SPing-Ke Shih 	RTW89_DMA_B1HI = 11,
2192e3ec7017SPing-Ke Shih 	RTW89_DMA_H2C = 12,
2193e3ec7017SPing-Ke Shih 	RTW89_DMA_CH_NUM = 13
2194e3ec7017SPing-Ke Shih };
2195e3ec7017SPing-Ke Shih 
2196e3ec7017SPing-Ke Shih enum rtw89_qta_mode {
2197e3ec7017SPing-Ke Shih 	RTW89_QTA_SCC,
2198e3ec7017SPing-Ke Shih 	RTW89_QTA_DLFW,
2199e3ec7017SPing-Ke Shih 
2200e3ec7017SPing-Ke Shih 	/* keep last */
2201e3ec7017SPing-Ke Shih 	RTW89_QTA_INVALID,
2202e3ec7017SPing-Ke Shih };
2203e3ec7017SPing-Ke Shih 
2204e3ec7017SPing-Ke Shih struct rtw89_hfc_ch_cfg {
2205e3ec7017SPing-Ke Shih 	u16 min;
2206e3ec7017SPing-Ke Shih 	u16 max;
2207e3ec7017SPing-Ke Shih #define grp_0 0
2208e3ec7017SPing-Ke Shih #define grp_1 1
2209e3ec7017SPing-Ke Shih #define grp_num 2
2210e3ec7017SPing-Ke Shih 	u8 grp;
2211e3ec7017SPing-Ke Shih };
2212e3ec7017SPing-Ke Shih 
2213e3ec7017SPing-Ke Shih struct rtw89_hfc_ch_info {
2214e3ec7017SPing-Ke Shih 	u16 aval;
2215e3ec7017SPing-Ke Shih 	u16 used;
2216e3ec7017SPing-Ke Shih };
2217e3ec7017SPing-Ke Shih 
2218e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_cfg {
2219e3ec7017SPing-Ke Shih 	u16 grp0;
2220e3ec7017SPing-Ke Shih 	u16 grp1;
2221e3ec7017SPing-Ke Shih 	u16 pub_max;
2222e3ec7017SPing-Ke Shih 	u16 wp_thrd;
2223e3ec7017SPing-Ke Shih };
2224e3ec7017SPing-Ke Shih 
2225e3ec7017SPing-Ke Shih struct rtw89_hfc_pub_info {
2226e3ec7017SPing-Ke Shih 	u16 g0_used;
2227e3ec7017SPing-Ke Shih 	u16 g1_used;
2228e3ec7017SPing-Ke Shih 	u16 g0_aval;
2229e3ec7017SPing-Ke Shih 	u16 g1_aval;
2230e3ec7017SPing-Ke Shih 	u16 pub_aval;
2231e3ec7017SPing-Ke Shih 	u16 wp_aval;
2232e3ec7017SPing-Ke Shih };
2233e3ec7017SPing-Ke Shih 
2234e3ec7017SPing-Ke Shih struct rtw89_hfc_prec_cfg {
2235e3ec7017SPing-Ke Shih 	u16 ch011_prec;
2236e3ec7017SPing-Ke Shih 	u16 h2c_prec;
2237e3ec7017SPing-Ke Shih 	u16 wp_ch07_prec;
2238e3ec7017SPing-Ke Shih 	u16 wp_ch811_prec;
2239e3ec7017SPing-Ke Shih 	u8 ch011_full_cond;
2240e3ec7017SPing-Ke Shih 	u8 h2c_full_cond;
2241e3ec7017SPing-Ke Shih 	u8 wp_ch07_full_cond;
2242e3ec7017SPing-Ke Shih 	u8 wp_ch811_full_cond;
2243e3ec7017SPing-Ke Shih };
2244e3ec7017SPing-Ke Shih 
2245e3ec7017SPing-Ke Shih struct rtw89_hfc_param {
2246e3ec7017SPing-Ke Shih 	bool en;
2247e3ec7017SPing-Ke Shih 	bool h2c_en;
2248e3ec7017SPing-Ke Shih 	u8 mode;
2249e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_ch_cfg *ch_cfg;
2250e3ec7017SPing-Ke Shih 	struct rtw89_hfc_ch_info ch_info[RTW89_DMA_CH_NUM];
2251e3ec7017SPing-Ke Shih 	struct rtw89_hfc_pub_cfg pub_cfg;
2252e3ec7017SPing-Ke Shih 	struct rtw89_hfc_pub_info pub_info;
2253e3ec7017SPing-Ke Shih 	struct rtw89_hfc_prec_cfg prec_cfg;
2254e3ec7017SPing-Ke Shih };
2255e3ec7017SPing-Ke Shih 
2256e3ec7017SPing-Ke Shih struct rtw89_hfc_param_ini {
2257e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_ch_cfg *ch_cfg;
2258e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_pub_cfg *pub_cfg;
2259e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_prec_cfg *prec_cfg;
2260e3ec7017SPing-Ke Shih 	u8 mode;
2261e3ec7017SPing-Ke Shih };
2262e3ec7017SPing-Ke Shih 
2263e3ec7017SPing-Ke Shih struct rtw89_dle_size {
2264e3ec7017SPing-Ke Shih 	u16 pge_size;
2265e3ec7017SPing-Ke Shih 	u16 lnk_pge_num;
2266e3ec7017SPing-Ke Shih 	u16 unlnk_pge_num;
2267e3ec7017SPing-Ke Shih };
2268e3ec7017SPing-Ke Shih 
2269e3ec7017SPing-Ke Shih struct rtw89_wde_quota {
2270e3ec7017SPing-Ke Shih 	u16 hif;
2271e3ec7017SPing-Ke Shih 	u16 wcpu;
2272e3ec7017SPing-Ke Shih 	u16 pkt_in;
2273e3ec7017SPing-Ke Shih 	u16 cpu_io;
2274e3ec7017SPing-Ke Shih };
2275e3ec7017SPing-Ke Shih 
2276e3ec7017SPing-Ke Shih struct rtw89_ple_quota {
2277e3ec7017SPing-Ke Shih 	u16 cma0_tx;
2278e3ec7017SPing-Ke Shih 	u16 cma1_tx;
2279e3ec7017SPing-Ke Shih 	u16 c2h;
2280e3ec7017SPing-Ke Shih 	u16 h2c;
2281e3ec7017SPing-Ke Shih 	u16 wcpu;
2282e3ec7017SPing-Ke Shih 	u16 mpdu_proc;
2283e3ec7017SPing-Ke Shih 	u16 cma0_dma;
2284e3ec7017SPing-Ke Shih 	u16 cma1_dma;
2285e3ec7017SPing-Ke Shih 	u16 bb_rpt;
2286e3ec7017SPing-Ke Shih 	u16 wd_rel;
2287e3ec7017SPing-Ke Shih 	u16 cpu_io;
228879d099e0SPing-Ke Shih 	u16 tx_rpt;
2289e3ec7017SPing-Ke Shih };
2290e3ec7017SPing-Ke Shih 
2291e3ec7017SPing-Ke Shih struct rtw89_dle_mem {
2292e3ec7017SPing-Ke Shih 	enum rtw89_qta_mode mode;
2293e3ec7017SPing-Ke Shih 	const struct rtw89_dle_size *wde_size;
2294e3ec7017SPing-Ke Shih 	const struct rtw89_dle_size *ple_size;
2295e3ec7017SPing-Ke Shih 	const struct rtw89_wde_quota *wde_min_qt;
2296e3ec7017SPing-Ke Shih 	const struct rtw89_wde_quota *wde_max_qt;
2297e3ec7017SPing-Ke Shih 	const struct rtw89_ple_quota *ple_min_qt;
2298e3ec7017SPing-Ke Shih 	const struct rtw89_ple_quota *ple_max_qt;
2299e3ec7017SPing-Ke Shih };
2300e3ec7017SPing-Ke Shih 
2301e3ec7017SPing-Ke Shih struct rtw89_reg_def {
2302e3ec7017SPing-Ke Shih 	u32 addr;
2303e3ec7017SPing-Ke Shih 	u32 mask;
2304e3ec7017SPing-Ke Shih };
2305e3ec7017SPing-Ke Shih 
2306e3ec7017SPing-Ke Shih struct rtw89_reg2_def {
2307e3ec7017SPing-Ke Shih 	u32 addr;
2308e3ec7017SPing-Ke Shih 	u32 data;
2309e3ec7017SPing-Ke Shih };
2310e3ec7017SPing-Ke Shih 
2311e3ec7017SPing-Ke Shih struct rtw89_reg3_def {
2312e3ec7017SPing-Ke Shih 	u32 addr;
2313e3ec7017SPing-Ke Shih 	u32 mask;
2314e3ec7017SPing-Ke Shih 	u32 data;
2315e3ec7017SPing-Ke Shih };
2316e3ec7017SPing-Ke Shih 
2317e3ec7017SPing-Ke Shih struct rtw89_reg5_def {
2318e3ec7017SPing-Ke Shih 	u8 flag; /* recognized by parsers */
2319e3ec7017SPing-Ke Shih 	u8 path;
2320e3ec7017SPing-Ke Shih 	u32 addr;
2321e3ec7017SPing-Ke Shih 	u32 mask;
2322e3ec7017SPing-Ke Shih 	u32 data;
2323e3ec7017SPing-Ke Shih };
2324e3ec7017SPing-Ke Shih 
2325e3ec7017SPing-Ke Shih struct rtw89_phy_table {
2326e3ec7017SPing-Ke Shih 	const struct rtw89_reg2_def *regs;
2327e3ec7017SPing-Ke Shih 	u32 n_regs;
2328e3ec7017SPing-Ke Shih 	enum rtw89_rf_path rf_path;
23292a5f2b32SPing-Ke Shih 	void (*config)(struct rtw89_dev *rtwdev, const struct rtw89_reg2_def *reg,
23302a5f2b32SPing-Ke Shih 		       enum rtw89_rf_path rf_path, void *data);
2331e3ec7017SPing-Ke Shih };
2332e3ec7017SPing-Ke Shih 
2333e3ec7017SPing-Ke Shih struct rtw89_txpwr_table {
2334e3ec7017SPing-Ke Shih 	const void *data;
2335e3ec7017SPing-Ke Shih 	u32 size;
2336e3ec7017SPing-Ke Shih 	void (*load)(struct rtw89_dev *rtwdev,
2337e3ec7017SPing-Ke Shih 		     const struct rtw89_txpwr_table *tbl);
2338e3ec7017SPing-Ke Shih };
2339e3ec7017SPing-Ke Shih 
2340ab8a5671SPing-Ke Shih struct rtw89_page_regs {
2341ab8a5671SPing-Ke Shih 	u32 hci_fc_ctrl;
2342ab8a5671SPing-Ke Shih 	u32 ch_page_ctrl;
2343ab8a5671SPing-Ke Shih 	u32 ach_page_ctrl;
2344ab8a5671SPing-Ke Shih 	u32 ach_page_info;
2345ab8a5671SPing-Ke Shih 	u32 pub_page_info3;
2346ab8a5671SPing-Ke Shih 	u32 pub_page_ctrl1;
2347ab8a5671SPing-Ke Shih 	u32 pub_page_ctrl2;
2348ab8a5671SPing-Ke Shih 	u32 pub_page_info1;
2349ab8a5671SPing-Ke Shih 	u32 pub_page_info2;
2350ab8a5671SPing-Ke Shih 	u32 wp_page_ctrl1;
2351ab8a5671SPing-Ke Shih 	u32 wp_page_ctrl2;
2352ab8a5671SPing-Ke Shih 	u32 wp_page_info1;
2353ab8a5671SPing-Ke Shih };
2354ab8a5671SPing-Ke Shih 
2355eeadcd2aSChia-Yuan Li struct rtw89_imr_info {
2356eeadcd2aSChia-Yuan Li 	u32 wdrls_imr_set;
2357eeadcd2aSChia-Yuan Li 	u32 wsec_imr_reg;
2358eeadcd2aSChia-Yuan Li 	u32 wsec_imr_set;
2359eeadcd2aSChia-Yuan Li 	u32 mpdu_tx_imr_set;
2360eeadcd2aSChia-Yuan Li 	u32 mpdu_rx_imr_set;
2361eeadcd2aSChia-Yuan Li 	u32 sta_sch_imr_set;
2362eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b0_reg;
2363eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b0_clr;
2364eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b0_set;
2365eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b1_reg;
2366eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b1_clr;
2367eeadcd2aSChia-Yuan Li 	u32 txpktctl_imr_b1_set;
2368eeadcd2aSChia-Yuan Li 	u32 wde_imr_clr;
2369eeadcd2aSChia-Yuan Li 	u32 wde_imr_set;
2370eeadcd2aSChia-Yuan Li 	u32 ple_imr_clr;
2371eeadcd2aSChia-Yuan Li 	u32 ple_imr_set;
2372eeadcd2aSChia-Yuan Li 	u32 host_disp_imr_clr;
2373eeadcd2aSChia-Yuan Li 	u32 host_disp_imr_set;
2374eeadcd2aSChia-Yuan Li 	u32 cpu_disp_imr_clr;
2375eeadcd2aSChia-Yuan Li 	u32 cpu_disp_imr_set;
2376eeadcd2aSChia-Yuan Li 	u32 other_disp_imr_clr;
2377eeadcd2aSChia-Yuan Li 	u32 other_disp_imr_set;
2378eeadcd2aSChia-Yuan Li 	u32 bbrpt_chinfo_err_imr_reg;
2379eeadcd2aSChia-Yuan Li 	u32 bbrpt_err_imr_set;
2380eeadcd2aSChia-Yuan Li 	u32 bbrpt_dfs_err_imr_reg;
2381d86369e9SChia-Yuan Li 	u32 ptcl_imr_clr;
2382d86369e9SChia-Yuan Li 	u32 ptcl_imr_set;
2383d86369e9SChia-Yuan Li 	u32 cdma_imr_0_reg;
2384d86369e9SChia-Yuan Li 	u32 cdma_imr_0_clr;
2385d86369e9SChia-Yuan Li 	u32 cdma_imr_0_set;
2386d86369e9SChia-Yuan Li 	u32 cdma_imr_1_reg;
2387d86369e9SChia-Yuan Li 	u32 cdma_imr_1_clr;
2388d86369e9SChia-Yuan Li 	u32 cdma_imr_1_set;
2389d86369e9SChia-Yuan Li 	u32 phy_intf_imr_reg;
2390d86369e9SChia-Yuan Li 	u32 phy_intf_imr_clr;
2391d86369e9SChia-Yuan Li 	u32 phy_intf_imr_set;
2392d86369e9SChia-Yuan Li 	u32 rmac_imr_reg;
2393d86369e9SChia-Yuan Li 	u32 rmac_imr_clr;
2394d86369e9SChia-Yuan Li 	u32 rmac_imr_set;
2395d86369e9SChia-Yuan Li 	u32 tmac_imr_reg;
2396d86369e9SChia-Yuan Li 	u32 tmac_imr_clr;
2397d86369e9SChia-Yuan Li 	u32 tmac_imr_set;
2398eeadcd2aSChia-Yuan Li };
2399eeadcd2aSChia-Yuan Li 
2400e3ec7017SPing-Ke Shih struct rtw89_chip_info {
2401e3ec7017SPing-Ke Shih 	enum rtw89_core_chip_id chip_id;
2402e3ec7017SPing-Ke Shih 	const struct rtw89_chip_ops *ops;
2403e3ec7017SPing-Ke Shih 	const char *fw_name;
2404e3ec7017SPing-Ke Shih 	u32 fifo_size;
2405e3ec7017SPing-Ke Shih 	u16 max_amsdu_limit;
2406e3ec7017SPing-Ke Shih 	bool dis_2g_40m_ul_ofdma;
24079f8004bfSZong-Zhe Yang 	u32 rsvd_ple_ofst;
2408e3ec7017SPing-Ke Shih 	const struct rtw89_hfc_param_ini *hfc_param_ini;
2409e3ec7017SPing-Ke Shih 	const struct rtw89_dle_mem *dle_mem;
2410e3ec7017SPing-Ke Shih 	u32 rf_base_addr[2];
24117fc06a07SZong-Zhe Yang 	u8 support_chanctx_num;
24120237f65aSZong-Zhe Yang 	u8 support_bands;
2413d221270aSPing-Ke Shih 	bool support_bw160;
241479a6c9a4SPing-Ke Shih 	bool hw_sec_hdr;
2415e3ec7017SPing-Ke Shih 	u8 rf_path_num;
2416e3ec7017SPing-Ke Shih 	u8 tx_nss;
2417e3ec7017SPing-Ke Shih 	u8 rx_nss;
2418e3ec7017SPing-Ke Shih 	u8 acam_num;
2419e3ec7017SPing-Ke Shih 	u8 bcam_num;
2420e3ec7017SPing-Ke Shih 	u8 scam_num;
2421e3ec7017SPing-Ke Shih 
2422e3ec7017SPing-Ke Shih 	u8 sec_ctrl_efuse_size;
2423e3ec7017SPing-Ke Shih 	u32 physical_efuse_size;
2424e3ec7017SPing-Ke Shih 	u32 logical_efuse_size;
2425e3ec7017SPing-Ke Shih 	u32 limit_efuse_size;
2426bdfbf06cSPing-Ke Shih 	u32 dav_phy_efuse_size;
2427bdfbf06cSPing-Ke Shih 	u32 dav_log_efuse_size;
2428e3ec7017SPing-Ke Shih 	u32 phycap_addr;
2429e3ec7017SPing-Ke Shih 	u32 phycap_size;
2430e3ec7017SPing-Ke Shih 
2431e3ec7017SPing-Ke Shih 	const struct rtw89_pwr_cfg * const *pwr_on_seq;
2432e3ec7017SPing-Ke Shih 	const struct rtw89_pwr_cfg * const *pwr_off_seq;
2433e3ec7017SPing-Ke Shih 	const struct rtw89_phy_table *bb_table;
2434eefad995SPing-Ke Shih 	const struct rtw89_phy_table *bb_gain_table;
2435e3ec7017SPing-Ke Shih 	const struct rtw89_phy_table *rf_table[RF_PATH_MAX];
2436e3ec7017SPing-Ke Shih 	const struct rtw89_phy_table *nctl_table;
2437e3ec7017SPing-Ke Shih 	const struct rtw89_txpwr_table *byr_table;
2438e3ec7017SPing-Ke Shih 	const struct rtw89_phy_dig_gain_table *dig_table;
2439c7845551SPing-Ke Shih 	const struct rtw89_phy_tssi_dbw_table *tssi_dbw_table;
2440e3ec7017SPing-Ke Shih 	const s8 (*txpwr_lmt_2g)[RTW89_2G_BW_NUM][RTW89_NTX_NUM]
2441e3ec7017SPing-Ke Shih 				[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
2442e3ec7017SPing-Ke Shih 				[RTW89_REGD_NUM][RTW89_2G_CH_NUM];
2443e3ec7017SPing-Ke Shih 	const s8 (*txpwr_lmt_5g)[RTW89_5G_BW_NUM][RTW89_NTX_NUM]
2444e3ec7017SPing-Ke Shih 				[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
2445e3ec7017SPing-Ke Shih 				[RTW89_REGD_NUM][RTW89_5G_CH_NUM];
2446ac74f016SZong-Zhe Yang 	const s8 (*txpwr_lmt_6g)[RTW89_6G_BW_NUM][RTW89_NTX_NUM]
2447ac74f016SZong-Zhe Yang 				[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
2448ac74f016SZong-Zhe Yang 				[RTW89_REGD_NUM][RTW89_6G_CH_NUM];
2449e3ec7017SPing-Ke Shih 	const s8 (*txpwr_lmt_ru_2g)[RTW89_RU_NUM][RTW89_NTX_NUM]
2450e3ec7017SPing-Ke Shih 				   [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
2451e3ec7017SPing-Ke Shih 	const s8 (*txpwr_lmt_ru_5g)[RTW89_RU_NUM][RTW89_NTX_NUM]
2452e3ec7017SPing-Ke Shih 				   [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
2453ac74f016SZong-Zhe Yang 	const s8 (*txpwr_lmt_ru_6g)[RTW89_RU_NUM][RTW89_NTX_NUM]
2454ac74f016SZong-Zhe Yang 				   [RTW89_REGD_NUM][RTW89_6G_CH_NUM];
2455e3ec7017SPing-Ke Shih 
2456e3ec7017SPing-Ke Shih 	u8 txpwr_factor_rf;
2457e3ec7017SPing-Ke Shih 	u8 txpwr_factor_mac;
2458e3ec7017SPing-Ke Shih 
2459e3ec7017SPing-Ke Shih 	u32 para_ver;
2460e3ec7017SPing-Ke Shih 	u32 wlcx_desired;
2461e3ec7017SPing-Ke Shih 	u8 btcx_desired;
2462e3ec7017SPing-Ke Shih 	u8 scbd;
2463e3ec7017SPing-Ke Shih 	u8 mailbox;
2464e3ec7017SPing-Ke Shih 
2465e3ec7017SPing-Ke Shih 	u8 afh_guard_ch;
2466e3ec7017SPing-Ke Shih 	const u8 *wl_rssi_thres;
2467e3ec7017SPing-Ke Shih 	const u8 *bt_rssi_thres;
2468e3ec7017SPing-Ke Shih 	u8 rssi_tol;
2469e3ec7017SPing-Ke Shih 
2470e3ec7017SPing-Ke Shih 	u8 mon_reg_num;
2471e3ec7017SPing-Ke Shih 	const struct rtw89_btc_fbtc_mreg *mon_reg;
2472e3ec7017SPing-Ke Shih 	u8 rf_para_ulink_num;
2473e3ec7017SPing-Ke Shih 	const struct rtw89_btc_rf_trx_para *rf_para_ulink;
2474e3ec7017SPing-Ke Shih 	u8 rf_para_dlink_num;
2475e3ec7017SPing-Ke Shih 	const struct rtw89_btc_rf_trx_para *rf_para_dlink;
2476e3ec7017SPing-Ke Shih 	u8 ps_mode_supported;
247752edbb9fSPing-Ke Shih 	u8 low_power_hci_modes;
24782af64b4aSPing-Ke Shih 
2479aa7f148bSPing-Ke Shih 	u32 h2c_cctl_func_id;
24802af64b4aSPing-Ke Shih 	u32 hci_func_en_addr;
2481a95bd62eSPing-Ke Shih 	u32 h2c_desc_size;
2482f59acddeSPing-Ke Shih 	u32 txwd_body_size;
2483e8955811SPing-Ke Shih 	u32 h2c_ctrl_reg;
2484e8955811SPing-Ke Shih 	const u32 *h2c_regs;
2485e8955811SPing-Ke Shih 	u32 c2h_ctrl_reg;
2486e8955811SPing-Ke Shih 	const u32 *c2h_regs;
2487ab8a5671SPing-Ke Shih 	const struct rtw89_page_regs *page_regs;
2488b7379148SYuan-Han Zhang 	const struct rtw89_reg_def *dcfo_comp;
2489b7379148SYuan-Han Zhang 	u8 dcfo_comp_sft;
2490eeadcd2aSChia-Yuan Li 	const struct rtw89_imr_info *imr_info;
2491e3ec7017SPing-Ke Shih };
2492e3ec7017SPing-Ke Shih 
24934a9e48acSPing-Ke Shih union rtw89_bus_info {
24944a9e48acSPing-Ke Shih 	const struct rtw89_pci_info *pci;
24954a9e48acSPing-Ke Shih };
24964a9e48acSPing-Ke Shih 
2497861e58c8SZong-Zhe Yang struct rtw89_driver_info {
2498861e58c8SZong-Zhe Yang 	const struct rtw89_chip_info *chip;
24994a9e48acSPing-Ke Shih 	union rtw89_bus_info bus;
2500861e58c8SZong-Zhe Yang };
2501861e58c8SZong-Zhe Yang 
2502e3ec7017SPing-Ke Shih enum rtw89_hcifc_mode {
2503e3ec7017SPing-Ke Shih 	RTW89_HCIFC_POH = 0,
2504e3ec7017SPing-Ke Shih 	RTW89_HCIFC_STF = 1,
2505e3ec7017SPing-Ke Shih 	RTW89_HCIFC_SDIO = 2,
2506e3ec7017SPing-Ke Shih 
2507e3ec7017SPing-Ke Shih 	/* keep last */
2508e3ec7017SPing-Ke Shih 	RTW89_HCIFC_MODE_INVALID,
2509e3ec7017SPing-Ke Shih };
2510e3ec7017SPing-Ke Shih 
2511e3ec7017SPing-Ke Shih struct rtw89_dle_info {
2512e3ec7017SPing-Ke Shih 	enum rtw89_qta_mode qta_mode;
2513e3ec7017SPing-Ke Shih 	u16 wde_pg_size;
2514e3ec7017SPing-Ke Shih 	u16 ple_pg_size;
2515e3ec7017SPing-Ke Shih 	u16 c0_rx_qta;
2516e3ec7017SPing-Ke Shih 	u16 c1_rx_qta;
2517e3ec7017SPing-Ke Shih };
2518e3ec7017SPing-Ke Shih 
2519e3ec7017SPing-Ke Shih enum rtw89_host_rpr_mode {
2520e3ec7017SPing-Ke Shih 	RTW89_RPR_MODE_POH = 0,
2521e3ec7017SPing-Ke Shih 	RTW89_RPR_MODE_STF
2522e3ec7017SPing-Ke Shih };
2523e3ec7017SPing-Ke Shih 
2524e3ec7017SPing-Ke Shih struct rtw89_mac_info {
2525e3ec7017SPing-Ke Shih 	struct rtw89_dle_info dle_info;
2526e3ec7017SPing-Ke Shih 	struct rtw89_hfc_param hfc_param;
2527e3ec7017SPing-Ke Shih 	enum rtw89_qta_mode qta_mode;
2528e3ec7017SPing-Ke Shih 	u8 rpwm_seq_num;
2529e3ec7017SPing-Ke Shih 	u8 cpwm_seq_num;
2530e3ec7017SPing-Ke Shih };
2531e3ec7017SPing-Ke Shih 
2532e3ec7017SPing-Ke Shih enum rtw89_fw_type {
2533e3ec7017SPing-Ke Shih 	RTW89_FW_NORMAL = 1,
2534e3ec7017SPing-Ke Shih 	RTW89_FW_WOWLAN = 3,
2535e3ec7017SPing-Ke Shih };
2536e3ec7017SPing-Ke Shih 
253711fe4ccdSZong-Zhe Yang enum rtw89_fw_feature {
253811fe4ccdSZong-Zhe Yang 	RTW89_FW_FEATURE_OLD_HT_RA_FORMAT,
253911fe4ccdSZong-Zhe Yang 	RTW89_FW_FEATURE_SCAN_OFFLOAD,
254011fe4ccdSZong-Zhe Yang 	RTW89_FW_FEATURE_TX_WAKE,
2541edb89629SZong-Zhe Yang 	RTW89_FW_FEATURE_CRASH_TRIGGER,
254211fe4ccdSZong-Zhe Yang };
254311fe4ccdSZong-Zhe Yang 
2544e3ec7017SPing-Ke Shih struct rtw89_fw_suit {
2545e3ec7017SPing-Ke Shih 	const u8 *data;
2546e3ec7017SPing-Ke Shih 	u32 size;
2547e3ec7017SPing-Ke Shih 	u8 major_ver;
2548e3ec7017SPing-Ke Shih 	u8 minor_ver;
2549e3ec7017SPing-Ke Shih 	u8 sub_ver;
2550e3ec7017SPing-Ke Shih 	u8 sub_idex;
2551e3ec7017SPing-Ke Shih 	u16 build_year;
2552e3ec7017SPing-Ke Shih 	u16 build_mon;
2553e3ec7017SPing-Ke Shih 	u16 build_date;
2554e3ec7017SPing-Ke Shih 	u16 build_hour;
2555e3ec7017SPing-Ke Shih 	u16 build_min;
2556e3ec7017SPing-Ke Shih 	u8 cmd_ver;
2557e3ec7017SPing-Ke Shih };
2558e3ec7017SPing-Ke Shih 
2559e3ec7017SPing-Ke Shih #define RTW89_FW_VER_CODE(major, minor, sub, idx)	\
2560e3ec7017SPing-Ke Shih 	(((major) << 24) | ((minor) << 16) | ((sub) << 8) | (idx))
2561e3ec7017SPing-Ke Shih #define RTW89_FW_SUIT_VER_CODE(s)	\
2562e3ec7017SPing-Ke Shih 	RTW89_FW_VER_CODE((s)->major_ver, (s)->minor_ver, (s)->sub_ver, (s)->sub_idex)
2563e3ec7017SPing-Ke Shih 
2564*deebea35SZong-Zhe Yang #define RTW89_MFW_HDR_VER_CODE(mfw_hdr)		\
2565*deebea35SZong-Zhe Yang 	RTW89_FW_VER_CODE((mfw_hdr)->ver.major,	\
2566*deebea35SZong-Zhe Yang 			  (mfw_hdr)->ver.minor,	\
2567*deebea35SZong-Zhe Yang 			  (mfw_hdr)->ver.sub,	\
2568*deebea35SZong-Zhe Yang 			  (mfw_hdr)->ver.idx)
2569*deebea35SZong-Zhe Yang 
2570*deebea35SZong-Zhe Yang #define RTW89_FW_HDR_VER_CODE(fw_hdr)				\
2571*deebea35SZong-Zhe Yang 	RTW89_FW_VER_CODE(GET_FW_HDR_MAJOR_VERSION(fw_hdr),	\
2572*deebea35SZong-Zhe Yang 			  GET_FW_HDR_MINOR_VERSION(fw_hdr),	\
2573*deebea35SZong-Zhe Yang 			  GET_FW_HDR_SUBVERSION(fw_hdr),	\
2574*deebea35SZong-Zhe Yang 			  GET_FW_HDR_SUBINDEX(fw_hdr))
2575*deebea35SZong-Zhe Yang 
2576e3ec7017SPing-Ke Shih struct rtw89_fw_info {
2577e3ec7017SPing-Ke Shih 	const struct firmware *firmware;
2578e3ec7017SPing-Ke Shih 	struct rtw89_dev *rtwdev;
2579e3ec7017SPing-Ke Shih 	struct completion completion;
2580e3ec7017SPing-Ke Shih 	u8 h2c_seq;
2581e3ec7017SPing-Ke Shih 	u8 rec_seq;
2582e3ec7017SPing-Ke Shih 	struct rtw89_fw_suit normal;
2583e3ec7017SPing-Ke Shih 	struct rtw89_fw_suit wowlan;
2584e3ec7017SPing-Ke Shih 	bool fw_log_enable;
258511fe4ccdSZong-Zhe Yang 	u32 feature_map;
2586e3ec7017SPing-Ke Shih };
2587e3ec7017SPing-Ke Shih 
258811fe4ccdSZong-Zhe Yang #define RTW89_CHK_FW_FEATURE(_feat, _fw) \
258911fe4ccdSZong-Zhe Yang 	(!!((_fw)->feature_map & BIT(RTW89_FW_FEATURE_ ## _feat)))
259011fe4ccdSZong-Zhe Yang 
259111fe4ccdSZong-Zhe Yang #define RTW89_SET_FW_FEATURE(_fw_feature, _fw) \
259211fe4ccdSZong-Zhe Yang 	((_fw)->feature_map |= BIT(_fw_feature))
259311fe4ccdSZong-Zhe Yang 
2594e3ec7017SPing-Ke Shih struct rtw89_cam_info {
2595e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(addr_cam_map, RTW89_MAX_ADDR_CAM_NUM);
2596e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(bssid_cam_map, RTW89_MAX_BSSID_CAM_NUM);
2597e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(sec_cam_map, RTW89_MAX_SEC_CAM_NUM);
2598e3ec7017SPing-Ke Shih };
2599e3ec7017SPing-Ke Shih 
2600e3ec7017SPing-Ke Shih enum rtw89_sar_sources {
2601e3ec7017SPing-Ke Shih 	RTW89_SAR_SOURCE_NONE,
2602e3ec7017SPing-Ke Shih 	RTW89_SAR_SOURCE_COMMON,
2603e3ec7017SPing-Ke Shih 
2604e3ec7017SPing-Ke Shih 	RTW89_SAR_SOURCE_NR,
2605e3ec7017SPing-Ke Shih };
2606e3ec7017SPing-Ke Shih 
2607425671f0SZong-Zhe Yang enum rtw89_sar_subband {
2608425671f0SZong-Zhe Yang 	RTW89_SAR_2GHZ_SUBBAND,
2609425671f0SZong-Zhe Yang 	RTW89_SAR_5GHZ_SUBBAND_1_2, /* U-NII-1 and U-NII-2 */
2610425671f0SZong-Zhe Yang 	RTW89_SAR_5GHZ_SUBBAND_2_E, /* U-NII-2-Extended */
2611425671f0SZong-Zhe Yang 	RTW89_SAR_5GHZ_SUBBAND_3,   /* U-NII-3 */
2612425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */
2613425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */
2614425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_6,   /* U-NII-6 */
2615425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */
2616425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */
2617425671f0SZong-Zhe Yang 	RTW89_SAR_6GHZ_SUBBAND_8,   /* U-NII-8 */
2618425671f0SZong-Zhe Yang 
2619425671f0SZong-Zhe Yang 	RTW89_SAR_SUBBAND_NR,
2620425671f0SZong-Zhe Yang };
2621425671f0SZong-Zhe Yang 
2622e3ec7017SPing-Ke Shih struct rtw89_sar_cfg_common {
2623425671f0SZong-Zhe Yang 	bool set[RTW89_SAR_SUBBAND_NR];
2624425671f0SZong-Zhe Yang 	s32 cfg[RTW89_SAR_SUBBAND_NR];
2625e3ec7017SPing-Ke Shih };
2626e3ec7017SPing-Ke Shih 
2627e3ec7017SPing-Ke Shih struct rtw89_sar_info {
2628e3ec7017SPing-Ke Shih 	/* used to decide how to acces SAR cfg union */
2629e3ec7017SPing-Ke Shih 	enum rtw89_sar_sources src;
2630e3ec7017SPing-Ke Shih 
2631e3ec7017SPing-Ke Shih 	/* reserved for different knids of SAR cfg struct.
2632e3ec7017SPing-Ke Shih 	 * supposed that a single cfg struct cannot handle various SAR sources.
2633e3ec7017SPing-Ke Shih 	 */
2634e3ec7017SPing-Ke Shih 	union {
2635e3ec7017SPing-Ke Shih 		struct rtw89_sar_cfg_common cfg_common;
2636e3ec7017SPing-Ke Shih 	};
2637e3ec7017SPing-Ke Shih };
2638e3ec7017SPing-Ke Shih 
263984b50f41SZong-Zhe Yang struct rtw89_chanctx_cfg {
264084b50f41SZong-Zhe Yang 	enum rtw89_sub_entity_idx idx;
264184b50f41SZong-Zhe Yang };
264284b50f41SZong-Zhe Yang 
26437cf674ffSZong-Zhe Yang enum rtw89_entity_mode {
26447cf674ffSZong-Zhe Yang 	RTW89_ENTITY_MODE_SCC,
26457cf674ffSZong-Zhe Yang };
26467cf674ffSZong-Zhe Yang 
2647e3ec7017SPing-Ke Shih struct rtw89_hal {
2648e3ec7017SPing-Ke Shih 	u32 rx_fltr;
2649e3ec7017SPing-Ke Shih 	u8 cv;
2650e3ec7017SPing-Ke Shih 	u32 sw_amsdu_max_size;
2651e3ec7017SPing-Ke Shih 	u32 antenna_tx;
2652e3ec7017SPing-Ke Shih 	u32 antenna_rx;
2653e3ec7017SPing-Ke Shih 	u8 tx_nss;
2654e3ec7017SPing-Ke Shih 	u8 rx_nss;
26551c2423deSJohnson Lin 	bool support_cckpd;
26561e6f0d2aSJohnson Lin 	bool support_igi;
2657967439c7SZong-Zhe Yang 
2658494399b2SZong-Zhe Yang 	DECLARE_BITMAP(entity_map, NUM_OF_RTW89_SUB_ENTITY);
2659494399b2SZong-Zhe Yang 	struct cfg80211_chan_def chandef[NUM_OF_RTW89_SUB_ENTITY];
2660494399b2SZong-Zhe Yang 
2661967439c7SZong-Zhe Yang 	bool entity_active;
26627cf674ffSZong-Zhe Yang 	enum rtw89_entity_mode entity_mode;
2663cbb145b9SZong-Zhe Yang 
2664cbb145b9SZong-Zhe Yang 	struct rtw89_chan chan[NUM_OF_RTW89_SUB_ENTITY];
2665cbb145b9SZong-Zhe Yang 	struct rtw89_chan_rcd chan_rcd[NUM_OF_RTW89_SUB_ENTITY];
2666e3ec7017SPing-Ke Shih };
2667e3ec7017SPing-Ke Shih 
2668e3ec7017SPing-Ke Shih #define RTW89_MAX_MAC_ID_NUM 128
266989590777SPo Hao Huang #define RTW89_MAX_PKT_OFLD_NUM 255
2670e3ec7017SPing-Ke Shih 
2671e3ec7017SPing-Ke Shih enum rtw89_flags {
2672e3ec7017SPing-Ke Shih 	RTW89_FLAG_POWERON,
2673e3ec7017SPing-Ke Shih 	RTW89_FLAG_FW_RDY,
2674e3ec7017SPing-Ke Shih 	RTW89_FLAG_RUNNING,
2675e3ec7017SPing-Ke Shih 	RTW89_FLAG_BFEE_MON,
2676e3ec7017SPing-Ke Shih 	RTW89_FLAG_BFEE_EN,
2677e3ec7017SPing-Ke Shih 	RTW89_FLAG_NAPI_RUNNING,
2678e3ec7017SPing-Ke Shih 	RTW89_FLAG_LEISURE_PS,
2679e3ec7017SPing-Ke Shih 	RTW89_FLAG_LOW_POWER_MODE,
2680e3ec7017SPing-Ke Shih 	RTW89_FLAG_INACTIVE_PS,
2681edb89629SZong-Zhe Yang 	RTW89_FLAG_RESTART_TRIGGER,
2682e3ec7017SPing-Ke Shih 
2683e3ec7017SPing-Ke Shih 	NUM_OF_RTW89_FLAGS,
2684e3ec7017SPing-Ke Shih };
2685e3ec7017SPing-Ke Shih 
2686e3ec7017SPing-Ke Shih struct rtw89_pkt_stat {
2687e3ec7017SPing-Ke Shih 	u16 beacon_nr;
2688e3ec7017SPing-Ke Shih 	u32 rx_rate_cnt[RTW89_HW_RATE_NR];
2689e3ec7017SPing-Ke Shih };
2690e3ec7017SPing-Ke Shih 
2691e3ec7017SPing-Ke Shih DECLARE_EWMA(thermal, 4, 4);
2692e3ec7017SPing-Ke Shih 
2693e3ec7017SPing-Ke Shih struct rtw89_phy_stat {
2694e3ec7017SPing-Ke Shih 	struct ewma_thermal avg_thermal[RF_PATH_MAX];
2695e3ec7017SPing-Ke Shih 	struct rtw89_pkt_stat cur_pkt_stat;
2696e3ec7017SPing-Ke Shih 	struct rtw89_pkt_stat last_pkt_stat;
2697e3ec7017SPing-Ke Shih };
2698e3ec7017SPing-Ke Shih 
2699e3ec7017SPing-Ke Shih #define RTW89_DACK_PATH_NR 2
2700e3ec7017SPing-Ke Shih #define RTW89_DACK_IDX_NR 2
2701e3ec7017SPing-Ke Shih #define RTW89_DACK_MSBK_NR 16
2702e3ec7017SPing-Ke Shih struct rtw89_dack_info {
2703e3ec7017SPing-Ke Shih 	bool dack_done;
2704e3ec7017SPing-Ke Shih 	u8 msbk_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR][RTW89_DACK_MSBK_NR];
2705e3ec7017SPing-Ke Shih 	u8 dadck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
2706e3ec7017SPing-Ke Shih 	u16 addck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
2707e3ec7017SPing-Ke Shih 	u16 biask_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
2708e3ec7017SPing-Ke Shih 	u32 dack_cnt;
2709e3ec7017SPing-Ke Shih 	bool addck_timeout[RTW89_DACK_PATH_NR];
2710e3ec7017SPing-Ke Shih 	bool dadck_timeout[RTW89_DACK_PATH_NR];
2711e3ec7017SPing-Ke Shih 	bool msbk_timeout[RTW89_DACK_PATH_NR];
2712e3ec7017SPing-Ke Shih };
2713e3ec7017SPing-Ke Shih 
2714e3ec7017SPing-Ke Shih #define RTW89_IQK_CHS_NR 2
2715e3ec7017SPing-Ke Shih #define RTW89_IQK_PATH_NR 4
271616b44ed0SPing-Ke Shih 
271716b44ed0SPing-Ke Shih struct rtw89_mcc_info {
271816b44ed0SPing-Ke Shih 	u8 ch[RTW89_IQK_CHS_NR];
271916b44ed0SPing-Ke Shih 	u8 band[RTW89_IQK_CHS_NR];
272016b44ed0SPing-Ke Shih 	u8 table_idx;
272116b44ed0SPing-Ke Shih };
272216b44ed0SPing-Ke Shih 
2723fb8177d7SPing-Ke Shih struct rtw89_lck_info {
2724fb8177d7SPing-Ke Shih 	u8 thermal[RF_PATH_MAX];
2725fb8177d7SPing-Ke Shih };
2726fb8177d7SPing-Ke Shih 
2727e3d365ffSPing-Ke Shih struct rtw89_rx_dck_info {
2728e3d365ffSPing-Ke Shih 	u8 thermal[RF_PATH_MAX];
2729e3d365ffSPing-Ke Shih };
2730e3d365ffSPing-Ke Shih 
2731e3ec7017SPing-Ke Shih struct rtw89_iqk_info {
2732e3ec7017SPing-Ke Shih 	bool lok_cor_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
2733e3ec7017SPing-Ke Shih 	bool lok_fin_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
27342da8109dSPing-Ke Shih 	bool lok_fail[RTW89_IQK_PATH_NR];
2735e3ec7017SPing-Ke Shih 	bool iqk_tx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
2736e3ec7017SPing-Ke Shih 	bool iqk_rx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
2737e3ec7017SPing-Ke Shih 	u32 iqk_fail_cnt;
2738e3ec7017SPing-Ke Shih 	bool is_iqk_init;
2739e3ec7017SPing-Ke Shih 	u32 iqk_channel[RTW89_IQK_CHS_NR];
2740e3ec7017SPing-Ke Shih 	u8 iqk_band[RTW89_IQK_PATH_NR];
2741e3ec7017SPing-Ke Shih 	u8 iqk_ch[RTW89_IQK_PATH_NR];
2742e3ec7017SPing-Ke Shih 	u8 iqk_bw[RTW89_IQK_PATH_NR];
2743e3ec7017SPing-Ke Shih 	u8 kcount;
2744e3ec7017SPing-Ke Shih 	u8 iqk_times;
2745e3ec7017SPing-Ke Shih 	u8 version;
2746e3ec7017SPing-Ke Shih 	u32 nb_txcfir[RTW89_IQK_PATH_NR];
2747e3ec7017SPing-Ke Shih 	u32 nb_rxcfir[RTW89_IQK_PATH_NR];
2748e3ec7017SPing-Ke Shih 	u32 bp_txkresult[RTW89_IQK_PATH_NR];
2749e3ec7017SPing-Ke Shih 	u32 bp_rxkresult[RTW89_IQK_PATH_NR];
2750e3ec7017SPing-Ke Shih 	u32 bp_iqkenable[RTW89_IQK_PATH_NR];
2751e3ec7017SPing-Ke Shih 	bool is_wb_txiqk[RTW89_IQK_PATH_NR];
2752e3ec7017SPing-Ke Shih 	bool is_wb_rxiqk[RTW89_IQK_PATH_NR];
2753e3ec7017SPing-Ke Shih 	bool is_nbiqk;
2754e3ec7017SPing-Ke Shih 	bool iqk_fft_en;
2755e3ec7017SPing-Ke Shih 	bool iqk_xym_en;
2756e3ec7017SPing-Ke Shih 	bool iqk_sram_en;
2757e3ec7017SPing-Ke Shih 	bool iqk_cfir_en;
2758e3ec7017SPing-Ke Shih 	u8 thermal[RTW89_IQK_PATH_NR];
2759e3ec7017SPing-Ke Shih 	bool thermal_rek_en;
2760e3ec7017SPing-Ke Shih 	u32 syn1to2;
2761e3ec7017SPing-Ke Shih 	u8 iqk_mcc_ch[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
2762e3ec7017SPing-Ke Shih 	u8 iqk_table_idx[RTW89_IQK_PATH_NR];
27632da8109dSPing-Ke Shih 	u32 lok_idac[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
27642da8109dSPing-Ke Shih 	u32 lok_vbuf[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
2765e3ec7017SPing-Ke Shih };
2766e3ec7017SPing-Ke Shih 
2767e3ec7017SPing-Ke Shih #define RTW89_DPK_RF_PATH 2
2768e3ec7017SPing-Ke Shih #define RTW89_DPK_AVG_THERMAL_NUM 8
2769e3ec7017SPing-Ke Shih #define RTW89_DPK_BKUP_NUM 2
2770e3ec7017SPing-Ke Shih struct rtw89_dpk_bkup_para {
2771e3ec7017SPing-Ke Shih 	enum rtw89_band band;
2772e3ec7017SPing-Ke Shih 	enum rtw89_bandwidth bw;
2773e3ec7017SPing-Ke Shih 	u8 ch;
2774e3ec7017SPing-Ke Shih 	bool path_ok;
2775da4cea16SPing-Ke Shih 	u8 mdpd_en;
2776e3ec7017SPing-Ke Shih 	u8 txagc_dpk;
2777e3ec7017SPing-Ke Shih 	u8 ther_dpk;
2778e3ec7017SPing-Ke Shih 	u8 gs;
2779e3ec7017SPing-Ke Shih 	u16 pwsf;
2780e3ec7017SPing-Ke Shih };
2781e3ec7017SPing-Ke Shih 
2782e3ec7017SPing-Ke Shih struct rtw89_dpk_info {
2783e3ec7017SPing-Ke Shih 	bool is_dpk_enable;
2784e3ec7017SPing-Ke Shih 	bool is_dpk_reload_en;
2785da4cea16SPing-Ke Shih 	u16 dc_i[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
2786da4cea16SPing-Ke Shih 	u16 dc_q[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
2787da4cea16SPing-Ke Shih 	u8 corr_val[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
2788da4cea16SPing-Ke Shih 	u8 corr_idx[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
2789e3ec7017SPing-Ke Shih 	u8 cur_idx[RTW89_DPK_RF_PATH];
2790da4cea16SPing-Ke Shih 	u8 cur_k_set;
2791e3ec7017SPing-Ke Shih 	struct rtw89_dpk_bkup_para bp[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
2792e3ec7017SPing-Ke Shih };
2793e3ec7017SPing-Ke Shih 
2794e3ec7017SPing-Ke Shih struct rtw89_fem_info {
2795e3ec7017SPing-Ke Shih 	bool elna_2g;
2796e3ec7017SPing-Ke Shih 	bool elna_5g;
2797e3ec7017SPing-Ke Shih 	bool epa_2g;
2798e3ec7017SPing-Ke Shih 	bool epa_5g;
2799da4cea16SPing-Ke Shih 	bool epa_6g;
2800e3ec7017SPing-Ke Shih };
2801e3ec7017SPing-Ke Shih 
2802e3ec7017SPing-Ke Shih struct rtw89_phy_ch_info {
2803e3ec7017SPing-Ke Shih 	u8 rssi_min;
2804e3ec7017SPing-Ke Shih 	u16 rssi_min_macid;
2805e3ec7017SPing-Ke Shih 	u8 pre_rssi_min;
2806e3ec7017SPing-Ke Shih 	u8 rssi_max;
2807e3ec7017SPing-Ke Shih 	u16 rssi_max_macid;
2808e3ec7017SPing-Ke Shih 	u8 rxsc_160;
2809e3ec7017SPing-Ke Shih 	u8 rxsc_80;
2810e3ec7017SPing-Ke Shih 	u8 rxsc_40;
2811e3ec7017SPing-Ke Shih 	u8 rxsc_20;
2812e3ec7017SPing-Ke Shih 	u8 rxsc_l;
2813e3ec7017SPing-Ke Shih 	u8 is_noisy;
2814e3ec7017SPing-Ke Shih };
2815e3ec7017SPing-Ke Shih 
2816e3ec7017SPing-Ke Shih struct rtw89_agc_gaincode_set {
2817e3ec7017SPing-Ke Shih 	u8 lna_idx;
2818e3ec7017SPing-Ke Shih 	u8 tia_idx;
2819e3ec7017SPing-Ke Shih 	u8 rxb_idx;
2820e3ec7017SPing-Ke Shih };
2821e3ec7017SPing-Ke Shih 
2822e3ec7017SPing-Ke Shih #define IGI_RSSI_TH_NUM 5
2823e3ec7017SPing-Ke Shih #define FA_TH_NUM 4
2824e3ec7017SPing-Ke Shih #define LNA_GAIN_NUM 7
2825e3ec7017SPing-Ke Shih #define TIA_GAIN_NUM 2
2826e3ec7017SPing-Ke Shih struct rtw89_dig_info {
2827e3ec7017SPing-Ke Shih 	struct rtw89_agc_gaincode_set cur_gaincode;
2828e3ec7017SPing-Ke Shih 	bool force_gaincode_idx_en;
2829e3ec7017SPing-Ke Shih 	struct rtw89_agc_gaincode_set force_gaincode;
2830e3ec7017SPing-Ke Shih 	u8 igi_rssi_th[IGI_RSSI_TH_NUM];
2831e3ec7017SPing-Ke Shih 	u16 fa_th[FA_TH_NUM];
2832e3ec7017SPing-Ke Shih 	u8 igi_rssi;
2833e3ec7017SPing-Ke Shih 	u8 igi_fa_rssi;
2834e3ec7017SPing-Ke Shih 	u8 fa_rssi_ofst;
2835e3ec7017SPing-Ke Shih 	u8 dyn_igi_max;
2836e3ec7017SPing-Ke Shih 	u8 dyn_igi_min;
2837e3ec7017SPing-Ke Shih 	bool dyn_pd_th_en;
2838e3ec7017SPing-Ke Shih 	u8 dyn_pd_th_max;
2839e3ec7017SPing-Ke Shih 	u8 pd_low_th_ofst;
2840e3ec7017SPing-Ke Shih 	u8 ib_pbk;
2841e3ec7017SPing-Ke Shih 	s8 ib_pkpwr;
2842e3ec7017SPing-Ke Shih 	s8 lna_gain_a[LNA_GAIN_NUM];
2843e3ec7017SPing-Ke Shih 	s8 lna_gain_g[LNA_GAIN_NUM];
2844e3ec7017SPing-Ke Shih 	s8 *lna_gain;
2845e3ec7017SPing-Ke Shih 	s8 tia_gain_a[TIA_GAIN_NUM];
2846e3ec7017SPing-Ke Shih 	s8 tia_gain_g[TIA_GAIN_NUM];
2847e3ec7017SPing-Ke Shih 	s8 *tia_gain;
2848e3ec7017SPing-Ke Shih 	bool is_linked_pre;
2849e3ec7017SPing-Ke Shih 	bool bypass_dig;
2850e3ec7017SPing-Ke Shih };
2851e3ec7017SPing-Ke Shih 
2852e3ec7017SPing-Ke Shih enum rtw89_multi_cfo_mode {
2853e3ec7017SPing-Ke Shih 	RTW89_PKT_BASED_AVG_MODE = 0,
2854e3ec7017SPing-Ke Shih 	RTW89_ENTRY_BASED_AVG_MODE = 1,
2855e3ec7017SPing-Ke Shih 	RTW89_TP_BASED_AVG_MODE = 2,
2856e3ec7017SPing-Ke Shih };
2857e3ec7017SPing-Ke Shih 
2858e3ec7017SPing-Ke Shih enum rtw89_phy_cfo_status {
2859e3ec7017SPing-Ke Shih 	RTW89_PHY_DCFO_STATE_NORMAL = 0,
2860e3ec7017SPing-Ke Shih 	RTW89_PHY_DCFO_STATE_ENHANCE = 1,
2861bc013052SEric Huang 	RTW89_PHY_DCFO_STATE_HOLD = 2,
2862e3ec7017SPing-Ke Shih 	RTW89_PHY_DCFO_STATE_MAX
2863e3ec7017SPing-Ke Shih };
2864e3ec7017SPing-Ke Shih 
2865bc013052SEric Huang enum rtw89_phy_cfo_ul_ofdma_acc_mode {
2866bc013052SEric Huang 	RTW89_CFO_UL_OFDMA_ACC_DISABLE = 0,
2867bc013052SEric Huang 	RTW89_CFO_UL_OFDMA_ACC_ENABLE = 1
2868bc013052SEric Huang };
2869bc013052SEric Huang 
2870e3ec7017SPing-Ke Shih struct rtw89_cfo_tracking_info {
2871e3ec7017SPing-Ke Shih 	u16 cfo_timer_ms;
2872e3ec7017SPing-Ke Shih 	bool cfo_trig_by_timer_en;
2873e3ec7017SPing-Ke Shih 	enum rtw89_phy_cfo_status phy_cfo_status;
2874bc013052SEric Huang 	enum rtw89_phy_cfo_ul_ofdma_acc_mode cfo_ul_ofdma_acc_mode;
2875e3ec7017SPing-Ke Shih 	u8 phy_cfo_trk_cnt;
2876e3ec7017SPing-Ke Shih 	bool is_adjust;
2877e3ec7017SPing-Ke Shih 	enum rtw89_multi_cfo_mode rtw89_multi_cfo_mode;
2878e3ec7017SPing-Ke Shih 	bool apply_compensation;
2879e3ec7017SPing-Ke Shih 	u8 crystal_cap;
2880e3ec7017SPing-Ke Shih 	u8 crystal_cap_default;
2881e3ec7017SPing-Ke Shih 	u8 def_x_cap;
2882e3ec7017SPing-Ke Shih 	s8 x_cap_ofst;
2883e3ec7017SPing-Ke Shih 	u32 sta_cfo_tolerance;
2884e3ec7017SPing-Ke Shih 	s32 cfo_tail[CFO_TRACK_MAX_USER];
2885e3ec7017SPing-Ke Shih 	u16 cfo_cnt[CFO_TRACK_MAX_USER];
2886e3ec7017SPing-Ke Shih 	s32 cfo_avg_pre;
2887e3ec7017SPing-Ke Shih 	s32 cfo_avg[CFO_TRACK_MAX_USER];
2888e3ec7017SPing-Ke Shih 	s32 pre_cfo_avg[CFO_TRACK_MAX_USER];
2889e3ec7017SPing-Ke Shih 	u32 packet_count;
2890e3ec7017SPing-Ke Shih 	u32 packet_count_pre;
2891e3ec7017SPing-Ke Shih 	s32 residual_cfo_acc;
2892e3ec7017SPing-Ke Shih 	u8 phy_cfotrk_state;
2893e3ec7017SPing-Ke Shih 	u8 phy_cfotrk_cnt;
2894a9e06f2eSYi-Tang Chiu 	bool divergence_lock_en;
2895a9e06f2eSYi-Tang Chiu 	u8 x_cap_lb;
2896a9e06f2eSYi-Tang Chiu 	u8 x_cap_ub;
2897a9e06f2eSYi-Tang Chiu 	u8 lock_cnt;
2898e3ec7017SPing-Ke Shih };
2899e3ec7017SPing-Ke Shih 
2900e3ec7017SPing-Ke Shih /* 2GL, 2GH, 5GL1, 5GH1, 5GM1, 5GM2, 5GH1, 5GH2 */
2901e3ec7017SPing-Ke Shih #define TSSI_TRIM_CH_GROUP_NUM 8
2902a82174c6SPing-Ke Shih #define TSSI_TRIM_CH_GROUP_NUM_6G 16
2903e3ec7017SPing-Ke Shih 
2904e3ec7017SPing-Ke Shih #define TSSI_CCK_CH_GROUP_NUM 6
2905e3ec7017SPing-Ke Shih #define TSSI_MCS_2G_CH_GROUP_NUM 5
2906e3ec7017SPing-Ke Shih #define TSSI_MCS_5G_CH_GROUP_NUM 14
2907a82174c6SPing-Ke Shih #define TSSI_MCS_6G_CH_GROUP_NUM 32
2908e3ec7017SPing-Ke Shih #define TSSI_MCS_CH_GROUP_NUM \
2909e3ec7017SPing-Ke Shih 	(TSSI_MCS_2G_CH_GROUP_NUM + TSSI_MCS_5G_CH_GROUP_NUM)
2910e3ec7017SPing-Ke Shih 
2911e3ec7017SPing-Ke Shih struct rtw89_tssi_info {
2912e3ec7017SPing-Ke Shih 	u8 thermal[RF_PATH_MAX];
2913e3ec7017SPing-Ke Shih 	s8 tssi_trim[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM];
2914a82174c6SPing-Ke Shih 	s8 tssi_trim_6g[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM_6G];
2915e3ec7017SPing-Ke Shih 	s8 tssi_cck[RF_PATH_MAX][TSSI_CCK_CH_GROUP_NUM];
2916e3ec7017SPing-Ke Shih 	s8 tssi_mcs[RF_PATH_MAX][TSSI_MCS_CH_GROUP_NUM];
2917a82174c6SPing-Ke Shih 	s8 tssi_6g_mcs[RF_PATH_MAX][TSSI_MCS_6G_CH_GROUP_NUM];
2918e3ec7017SPing-Ke Shih 	s8 extra_ofst[RF_PATH_MAX];
2919e3ec7017SPing-Ke Shih 	bool tssi_tracking_check[RF_PATH_MAX];
2920e3ec7017SPing-Ke Shih 	u8 default_txagc_offset[RF_PATH_MAX];
2921e3ec7017SPing-Ke Shih 	u32 base_thermal[RF_PATH_MAX];
2922e3ec7017SPing-Ke Shih };
2923e3ec7017SPing-Ke Shih 
2924e3ec7017SPing-Ke Shih struct rtw89_power_trim_info {
2925e3ec7017SPing-Ke Shih 	bool pg_thermal_trim;
2926e3ec7017SPing-Ke Shih 	bool pg_pa_bias_trim;
2927e3ec7017SPing-Ke Shih 	u8 thermal_trim[RF_PATH_MAX];
2928e3ec7017SPing-Ke Shih 	u8 pa_bias_trim[RF_PATH_MAX];
2929e3ec7017SPing-Ke Shih };
2930e3ec7017SPing-Ke Shih 
2931e3ec7017SPing-Ke Shih struct rtw89_regulatory {
2932e3ec7017SPing-Ke Shih 	char alpha2[3];
2933e3ec7017SPing-Ke Shih 	u8 txpwr_regd[RTW89_BAND_MAX];
2934e3ec7017SPing-Ke Shih };
2935e3ec7017SPing-Ke Shih 
2936e3ec7017SPing-Ke Shih enum rtw89_ifs_clm_application {
2937e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_INIT = 0,
2938e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_BACKGROUND = 1,
2939e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_ACS = 2,
2940e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_DIG = 3,
2941e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_TDMA_DIG = 4,
2942e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_DBG = 5,
2943e3ec7017SPing-Ke Shih 	RTW89_IFS_CLM_DBG_MANUAL = 6
2944e3ec7017SPing-Ke Shih };
2945e3ec7017SPing-Ke Shih 
2946e3ec7017SPing-Ke Shih enum rtw89_env_racing_lv {
2947e3ec7017SPing-Ke Shih 	RTW89_RAC_RELEASE = 0,
2948e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_1 = 1,
2949e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_2 = 2,
2950e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_3 = 3,
2951e3ec7017SPing-Ke Shih 	RTW89_RAC_LV_4 = 4,
2952e3ec7017SPing-Ke Shih 	RTW89_RAC_MAX_NUM = 5
2953e3ec7017SPing-Ke Shih };
2954e3ec7017SPing-Ke Shih 
2955e3ec7017SPing-Ke Shih struct rtw89_ccx_para_info {
2956e3ec7017SPing-Ke Shih 	enum rtw89_env_racing_lv rac_lv;
2957e3ec7017SPing-Ke Shih 	u16 mntr_time;
2958e3ec7017SPing-Ke Shih 	u8 nhm_manual_th_ofst;
2959e3ec7017SPing-Ke Shih 	u8 nhm_manual_th0;
2960e3ec7017SPing-Ke Shih 	enum rtw89_ifs_clm_application ifs_clm_app;
2961e3ec7017SPing-Ke Shih 	u32 ifs_clm_manual_th_times;
2962e3ec7017SPing-Ke Shih 	u32 ifs_clm_manual_th0;
2963e3ec7017SPing-Ke Shih 	u8 fahm_manual_th_ofst;
2964e3ec7017SPing-Ke Shih 	u8 fahm_manual_th0;
2965e3ec7017SPing-Ke Shih 	u8 fahm_numer_opt;
2966e3ec7017SPing-Ke Shih 	u8 fahm_denom_opt;
2967e3ec7017SPing-Ke Shih };
2968e3ec7017SPing-Ke Shih 
2969e3ec7017SPing-Ke Shih enum rtw89_ccx_edcca_opt_sc_idx {
2970e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_P0 = 0,
2971e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_S1 = 1,
2972e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_S2 = 2,
2973e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG0_S3 = 3,
2974e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_P0 = 4,
2975e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_S1 = 5,
2976e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_S2 = 6,
2977e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_SEG1_S3 = 7
2978e3ec7017SPing-Ke Shih };
2979e3ec7017SPing-Ke Shih 
2980e3ec7017SPing-Ke Shih enum rtw89_ccx_edcca_opt_bw_idx {
2981e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_0 = 0,
2982e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_1 = 1,
2983e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_2 = 2,
2984e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_3 = 3,
2985e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_4 = 4,
2986e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_5 = 5,
2987e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_6 = 6,
2988e3ec7017SPing-Ke Shih 	RTW89_CCX_EDCCA_BW20_7 = 7
2989e3ec7017SPing-Ke Shih };
2990e3ec7017SPing-Ke Shih 
2991e3ec7017SPing-Ke Shih #define RTW89_NHM_TH_NUM 11
2992e3ec7017SPing-Ke Shih #define RTW89_FAHM_TH_NUM 11
2993e3ec7017SPing-Ke Shih #define RTW89_NHM_RPT_NUM 12
2994e3ec7017SPing-Ke Shih #define RTW89_FAHM_RPT_NUM 12
2995e3ec7017SPing-Ke Shih #define RTW89_IFS_CLM_NUM 4
2996e3ec7017SPing-Ke Shih struct rtw89_env_monitor_info {
2997e3ec7017SPing-Ke Shih 	u32 ccx_trigger_time;
2998e3ec7017SPing-Ke Shih 	u64 start_time;
2999e3ec7017SPing-Ke Shih 	u8 ccx_rpt_stamp;
3000e3ec7017SPing-Ke Shih 	u8 ccx_watchdog_result;
3001e3ec7017SPing-Ke Shih 	bool ccx_ongoing;
3002e3ec7017SPing-Ke Shih 	u8 ccx_rac_lv;
3003e3ec7017SPing-Ke Shih 	bool ccx_manual_ctrl;
3004e3ec7017SPing-Ke Shih 	u8 ccx_pre_rssi;
3005e3ec7017SPing-Ke Shih 	u16 clm_mntr_time;
3006e3ec7017SPing-Ke Shih 	u16 nhm_mntr_time;
3007e3ec7017SPing-Ke Shih 	u16 ifs_clm_mntr_time;
3008e3ec7017SPing-Ke Shih 	enum rtw89_ifs_clm_application ifs_clm_app;
3009e3ec7017SPing-Ke Shih 	u16 fahm_mntr_time;
3010e3ec7017SPing-Ke Shih 	u16 edcca_clm_mntr_time;
3011e3ec7017SPing-Ke Shih 	u16 ccx_period;
3012e3ec7017SPing-Ke Shih 	u8 ccx_unit_idx;
3013e3ec7017SPing-Ke Shih 	enum rtw89_ccx_edcca_opt_bw_idx ccx_edcca_opt_bw_idx;
3014e3ec7017SPing-Ke Shih 	u8 nhm_th[RTW89_NHM_TH_NUM];
3015e3ec7017SPing-Ke Shih 	u16 ifs_clm_th_l[RTW89_IFS_CLM_NUM];
3016e3ec7017SPing-Ke Shih 	u16 ifs_clm_th_h[RTW89_IFS_CLM_NUM];
3017e3ec7017SPing-Ke Shih 	u8 fahm_numer_opt;
3018e3ec7017SPing-Ke Shih 	u8 fahm_denom_opt;
3019e3ec7017SPing-Ke Shih 	u8 fahm_th[RTW89_FAHM_TH_NUM];
3020e3ec7017SPing-Ke Shih 	u16 clm_result;
3021e3ec7017SPing-Ke Shih 	u16 nhm_result[RTW89_NHM_RPT_NUM];
3022e3ec7017SPing-Ke Shih 	u8 nhm_wgt[RTW89_NHM_RPT_NUM];
3023e3ec7017SPing-Ke Shih 	u16 nhm_tx_cnt;
3024e3ec7017SPing-Ke Shih 	u16 nhm_cca_cnt;
3025e3ec7017SPing-Ke Shih 	u16 nhm_idle_cnt;
3026e3ec7017SPing-Ke Shih 	u16 ifs_clm_tx;
3027e3ec7017SPing-Ke Shih 	u16 ifs_clm_edcca_excl_cca;
3028e3ec7017SPing-Ke Shih 	u16 ifs_clm_ofdmfa;
3029e3ec7017SPing-Ke Shih 	u16 ifs_clm_ofdmcca_excl_fa;
3030e3ec7017SPing-Ke Shih 	u16 ifs_clm_cckfa;
3031e3ec7017SPing-Ke Shih 	u16 ifs_clm_cckcca_excl_fa;
3032e3ec7017SPing-Ke Shih 	u16 ifs_clm_total_ifs;
3033e3ec7017SPing-Ke Shih 	u8 ifs_clm_his[RTW89_IFS_CLM_NUM];
3034e3ec7017SPing-Ke Shih 	u16 ifs_clm_avg[RTW89_IFS_CLM_NUM];
3035e3ec7017SPing-Ke Shih 	u16 ifs_clm_cca[RTW89_IFS_CLM_NUM];
3036e3ec7017SPing-Ke Shih 	u16 fahm_result[RTW89_FAHM_RPT_NUM];
3037e3ec7017SPing-Ke Shih 	u16 fahm_denom_result;
3038e3ec7017SPing-Ke Shih 	u16 edcca_clm_result;
3039e3ec7017SPing-Ke Shih 	u8 clm_ratio;
3040e3ec7017SPing-Ke Shih 	u8 nhm_rpt[RTW89_NHM_RPT_NUM];
3041e3ec7017SPing-Ke Shih 	u8 nhm_tx_ratio;
3042e3ec7017SPing-Ke Shih 	u8 nhm_cca_ratio;
3043e3ec7017SPing-Ke Shih 	u8 nhm_idle_ratio;
3044e3ec7017SPing-Ke Shih 	u8 nhm_ratio;
3045e3ec7017SPing-Ke Shih 	u16 nhm_result_sum;
3046e3ec7017SPing-Ke Shih 	u8 nhm_pwr;
3047e3ec7017SPing-Ke Shih 	u8 ifs_clm_tx_ratio;
3048e3ec7017SPing-Ke Shih 	u8 ifs_clm_edcca_excl_cca_ratio;
3049e3ec7017SPing-Ke Shih 	u8 ifs_clm_cck_fa_ratio;
3050e3ec7017SPing-Ke Shih 	u8 ifs_clm_ofdm_fa_ratio;
3051e3ec7017SPing-Ke Shih 	u8 ifs_clm_cck_cca_excl_fa_ratio;
3052e3ec7017SPing-Ke Shih 	u8 ifs_clm_ofdm_cca_excl_fa_ratio;
3053e3ec7017SPing-Ke Shih 	u16 ifs_clm_cck_fa_permil;
3054e3ec7017SPing-Ke Shih 	u16 ifs_clm_ofdm_fa_permil;
3055e3ec7017SPing-Ke Shih 	u32 ifs_clm_ifs_avg[RTW89_IFS_CLM_NUM];
3056e3ec7017SPing-Ke Shih 	u32 ifs_clm_cca_avg[RTW89_IFS_CLM_NUM];
3057e3ec7017SPing-Ke Shih 	u8 fahm_rpt[RTW89_FAHM_RPT_NUM];
3058e3ec7017SPing-Ke Shih 	u16 fahm_result_sum;
3059e3ec7017SPing-Ke Shih 	u8 fahm_ratio;
3060e3ec7017SPing-Ke Shih 	u8 fahm_denom_ratio;
3061e3ec7017SPing-Ke Shih 	u8 fahm_pwr;
3062e3ec7017SPing-Ke Shih 	u8 edcca_clm_ratio;
3063e3ec7017SPing-Ke Shih };
3064e3ec7017SPing-Ke Shih 
3065e3ec7017SPing-Ke Shih enum rtw89_ser_rcvy_step {
3066e3ec7017SPing-Ke Shih 	RTW89_SER_DRV_STOP_TX,
3067e3ec7017SPing-Ke Shih 	RTW89_SER_DRV_STOP_RX,
3068e3ec7017SPing-Ke Shih 	RTW89_SER_DRV_STOP_RUN,
3069e3ec7017SPing-Ke Shih 	RTW89_SER_HAL_STOP_DMA,
3070e3ec7017SPing-Ke Shih 	RTW89_NUM_OF_SER_FLAGS
3071e3ec7017SPing-Ke Shih };
3072e3ec7017SPing-Ke Shih 
3073e3ec7017SPing-Ke Shih struct rtw89_ser {
3074e3ec7017SPing-Ke Shih 	u8 state;
3075e3ec7017SPing-Ke Shih 	u8 alarm_event;
3076e3ec7017SPing-Ke Shih 
3077e3ec7017SPing-Ke Shih 	struct work_struct ser_hdl_work;
3078e3ec7017SPing-Ke Shih 	struct delayed_work ser_alarm_work;
3079af5175acSJoe Perches 	const struct state_ent *st_tbl;
3080af5175acSJoe Perches 	const struct event_ent *ev_tbl;
3081e3ec7017SPing-Ke Shih 	struct list_head msg_q;
3082e3ec7017SPing-Ke Shih 	spinlock_t msg_q_lock; /* lock when read/write ser msg */
3083e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(flags, RTW89_NUM_OF_SER_FLAGS);
3084e3ec7017SPing-Ke Shih };
3085e3ec7017SPing-Ke Shih 
3086e3ec7017SPing-Ke Shih enum rtw89_mac_ax_ps_mode {
3087e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_ACTIVE = 0,
3088e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_LEGACY = 1,
3089e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_WMMPS  = 2,
3090e3ec7017SPing-Ke Shih 	RTW89_MAC_AX_PS_MODE_MAX    = 3,
3091e3ec7017SPing-Ke Shih };
3092e3ec7017SPing-Ke Shih 
3093e3ec7017SPing-Ke Shih enum rtw89_last_rpwm_mode {
3094e3ec7017SPing-Ke Shih 	RTW89_LAST_RPWM_PS        = 0x0,
3095e3ec7017SPing-Ke Shih 	RTW89_LAST_RPWM_ACTIVE    = 0x6,
3096e3ec7017SPing-Ke Shih };
3097e3ec7017SPing-Ke Shih 
3098e3ec7017SPing-Ke Shih struct rtw89_lps_parm {
3099e3ec7017SPing-Ke Shih 	u8 macid;
3100e3ec7017SPing-Ke Shih 	u8 psmode; /* enum rtw89_mac_ax_ps_mode */
3101e3ec7017SPing-Ke Shih 	u8 lastrpwm; /* enum rtw89_last_rpwm_mode */
3102e3ec7017SPing-Ke Shih };
3103e3ec7017SPing-Ke Shih 
3104e3ec7017SPing-Ke Shih struct rtw89_ppdu_sts_info {
3105e3ec7017SPing-Ke Shih 	struct sk_buff_head rx_queue[RTW89_PHY_MAX];
3106e3ec7017SPing-Ke Shih 	u8 curr_rx_ppdu_cnt[RTW89_PHY_MAX];
3107e3ec7017SPing-Ke Shih };
3108e3ec7017SPing-Ke Shih 
3109e3ec7017SPing-Ke Shih struct rtw89_early_h2c {
3110e3ec7017SPing-Ke Shih 	struct list_head list;
3111e3ec7017SPing-Ke Shih 	u8 *h2c;
3112e3ec7017SPing-Ke Shih 	u16 h2c_len;
3113e3ec7017SPing-Ke Shih };
3114e3ec7017SPing-Ke Shih 
311589590777SPo Hao Huang struct rtw89_hw_scan_info {
311689590777SPo Hao Huang 	struct ieee80211_vif *scanning_vif;
311789590777SPo Hao Huang 	struct list_head pkt_list[NUM_NL80211_BANDS];
311889590777SPo Hao Huang 	u8 op_pri_ch;
311989590777SPo Hao Huang 	u8 op_chan;
312089590777SPo Hao Huang 	u8 op_bw;
312189590777SPo Hao Huang 	u8 op_band;
312289590777SPo Hao Huang };
312389590777SPo Hao Huang 
3124e885871eSZong-Zhe Yang enum rtw89_phy_bb_gain_band {
3125e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_2G = 0,
3126e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_5G_L = 1,
3127e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_5G_M = 2,
3128e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_5G_H = 3,
3129e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_L = 4,
3130e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_M = 5,
3131e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_H = 6,
3132e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_6G_UH = 7,
3133e885871eSZong-Zhe Yang 
3134e885871eSZong-Zhe Yang 	RTW89_BB_GAIN_BAND_NR,
3135e885871eSZong-Zhe Yang };
3136e885871eSZong-Zhe Yang 
3137e885871eSZong-Zhe Yang enum rtw89_phy_bb_rxsc_num {
3138e885871eSZong-Zhe Yang 	RTW89_BB_RXSC_NUM_40 = 9, /* SC: 0, 1~8 */
3139e885871eSZong-Zhe Yang 	RTW89_BB_RXSC_NUM_80 = 13, /* SC: 0, 1~8, 9~12 */
3140e885871eSZong-Zhe Yang 	RTW89_BB_RXSC_NUM_160 = 15, /* SC: 0, 1~8, 9~12, 13~14 */
3141e885871eSZong-Zhe Yang };
3142e885871eSZong-Zhe Yang 
3143e885871eSZong-Zhe Yang struct rtw89_phy_bb_gain_info {
3144e885871eSZong-Zhe Yang 	s8 lna_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
3145e885871eSZong-Zhe Yang 	s8 tia_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][TIA_GAIN_NUM];
3146e885871eSZong-Zhe Yang 	s8 lna_gain_bypass[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
3147e885871eSZong-Zhe Yang 	s8 lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
3148e885871eSZong-Zhe Yang 	s8 tia_lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
3149e885871eSZong-Zhe Yang 			[LNA_GAIN_NUM + 1]; /* TIA0_LNA0~6 + TIA1_LNA6 */
3150e885871eSZong-Zhe Yang 	s8 rpl_ofst_20[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX];
3151e885871eSZong-Zhe Yang 	s8 rpl_ofst_40[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
3152e885871eSZong-Zhe Yang 		      [RTW89_BB_RXSC_NUM_40];
3153e885871eSZong-Zhe Yang 	s8 rpl_ofst_80[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
3154e885871eSZong-Zhe Yang 		      [RTW89_BB_RXSC_NUM_80];
3155e885871eSZong-Zhe Yang 	s8 rpl_ofst_160[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
3156e885871eSZong-Zhe Yang 		       [RTW89_BB_RXSC_NUM_160];
3157e885871eSZong-Zhe Yang };
3158e885871eSZong-Zhe Yang 
3159e6b17cbdSPing-Ke Shih struct rtw89_phy_efuse_gain {
3160e6b17cbdSPing-Ke Shih 	bool offset_valid;
3161e6b17cbdSPing-Ke Shih 	s8 offset[RF_PATH_MAX][RTW89_GAIN_OFFSET_NR]; /* S(8, 0) */
3162e6b17cbdSPing-Ke Shih 	s8 offset_base[RTW89_PHY_MAX]; /* S(8, 4) */
3163e6b17cbdSPing-Ke Shih };
3164e6b17cbdSPing-Ke Shih 
3165e3ec7017SPing-Ke Shih struct rtw89_dev {
3166e3ec7017SPing-Ke Shih 	struct ieee80211_hw *hw;
3167e3ec7017SPing-Ke Shih 	struct device *dev;
31687fc06a07SZong-Zhe Yang 	const struct ieee80211_ops *ops;
3169e3ec7017SPing-Ke Shih 
3170e3ec7017SPing-Ke Shih 	bool dbcc_en;
317189590777SPo Hao Huang 	struct rtw89_hw_scan_info scan_info;
3172e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip;
31734a9e48acSPing-Ke Shih 	const struct rtw89_pci_info *pci_info;
3174e3ec7017SPing-Ke Shih 	struct rtw89_hal hal;
3175e3ec7017SPing-Ke Shih 	struct rtw89_mac_info mac;
3176e3ec7017SPing-Ke Shih 	struct rtw89_fw_info fw;
3177e3ec7017SPing-Ke Shih 	struct rtw89_hci_info hci;
3178e3ec7017SPing-Ke Shih 	struct rtw89_efuse efuse;
3179e3ec7017SPing-Ke Shih 	struct rtw89_traffic_stats stats;
3180e3ec7017SPing-Ke Shih 
3181e3ec7017SPing-Ke Shih 	/* ensures exclusive access from mac80211 callbacks */
3182e3ec7017SPing-Ke Shih 	struct mutex mutex;
3183e3ec7017SPing-Ke Shih 	struct list_head rtwvifs_list;
3184e3ec7017SPing-Ke Shih 	/* used to protect rf read write */
3185e3ec7017SPing-Ke Shih 	struct mutex rf_mutex;
3186e3ec7017SPing-Ke Shih 	struct workqueue_struct *txq_wq;
3187e3ec7017SPing-Ke Shih 	struct work_struct txq_work;
3188e3ec7017SPing-Ke Shih 	struct delayed_work txq_reinvoke_work;
3189679955d5SKuan-Chung Chen 	/* used to protect ba_list and forbid_ba_list */
3190e3ec7017SPing-Ke Shih 	spinlock_t ba_lock;
3191e3ec7017SPing-Ke Shih 	/* txqs to setup ba session */
3192e3ec7017SPing-Ke Shih 	struct list_head ba_list;
3193679955d5SKuan-Chung Chen 	/* txqs to forbid ba session */
3194679955d5SKuan-Chung Chen 	struct list_head forbid_ba_list;
3195e3ec7017SPing-Ke Shih 	struct work_struct ba_work;
31967bfd05ffSChin-Yen Lee 	/* used to protect rpwm */
31977bfd05ffSChin-Yen Lee 	spinlock_t rpwm_lock;
3198e3ec7017SPing-Ke Shih 
3199e3ec7017SPing-Ke Shih 	struct rtw89_cam_info cam_info;
3200e3ec7017SPing-Ke Shih 
3201e3ec7017SPing-Ke Shih 	struct sk_buff_head c2h_queue;
3202e3ec7017SPing-Ke Shih 	struct work_struct c2h_work;
320389590777SPo Hao Huang 	struct work_struct ips_work;
3204e3ec7017SPing-Ke Shih 
3205e3ec7017SPing-Ke Shih 	struct list_head early_h2c_list;
3206e3ec7017SPing-Ke Shih 
3207e3ec7017SPing-Ke Shih 	struct rtw89_ser ser;
3208e3ec7017SPing-Ke Shih 
320920d9fc88SPing-Ke Shih 	DECLARE_BITMAP(hw_port, RTW89_PORT_NUM);
3210e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(mac_id_map, RTW89_MAX_MAC_ID_NUM);
3211e3ec7017SPing-Ke Shih 	DECLARE_BITMAP(flags, NUM_OF_RTW89_FLAGS);
321289590777SPo Hao Huang 	DECLARE_BITMAP(pkt_offload, RTW89_MAX_PKT_OFLD_NUM);
3213e3ec7017SPing-Ke Shih 
3214e3ec7017SPing-Ke Shih 	struct rtw89_phy_stat phystat;
3215e3ec7017SPing-Ke Shih 	struct rtw89_dack_info dack;
3216e3ec7017SPing-Ke Shih 	struct rtw89_iqk_info iqk;
3217e3ec7017SPing-Ke Shih 	struct rtw89_dpk_info dpk;
321816b44ed0SPing-Ke Shih 	struct rtw89_mcc_info mcc;
3219fb8177d7SPing-Ke Shih 	struct rtw89_lck_info lck;
3220e3d365ffSPing-Ke Shih 	struct rtw89_rx_dck_info rx_dck;
3221e3ec7017SPing-Ke Shih 	bool is_tssi_mode[RF_PATH_MAX];
3222e3ec7017SPing-Ke Shih 	bool is_bt_iqk_timeout;
3223e3ec7017SPing-Ke Shih 
3224e3ec7017SPing-Ke Shih 	struct rtw89_fem_info fem;
3225e3ec7017SPing-Ke Shih 	struct rtw89_txpwr_byrate byr[RTW89_BAND_MAX];
3226e3ec7017SPing-Ke Shih 	struct rtw89_tssi_info tssi;
3227e3ec7017SPing-Ke Shih 	struct rtw89_power_trim_info pwr_trim;
3228e3ec7017SPing-Ke Shih 
3229e3ec7017SPing-Ke Shih 	struct rtw89_cfo_tracking_info cfo_tracking;
3230e3ec7017SPing-Ke Shih 	struct rtw89_env_monitor_info env_monitor;
3231e3ec7017SPing-Ke Shih 	struct rtw89_dig_info dig;
3232e3ec7017SPing-Ke Shih 	struct rtw89_phy_ch_info ch_info;
3233e885871eSZong-Zhe Yang 	struct rtw89_phy_bb_gain_info bb_gain;
3234e6b17cbdSPing-Ke Shih 	struct rtw89_phy_efuse_gain efuse_gain;
3235e885871eSZong-Zhe Yang 
3236e3ec7017SPing-Ke Shih 	struct delayed_work track_work;
3237e3ec7017SPing-Ke Shih 	struct delayed_work coex_act1_work;
3238e3ec7017SPing-Ke Shih 	struct delayed_work coex_bt_devinfo_work;
3239e3ec7017SPing-Ke Shih 	struct delayed_work coex_rfk_chk_work;
3240e3ec7017SPing-Ke Shih 	struct delayed_work cfo_track_work;
3241679955d5SKuan-Chung Chen 	struct delayed_work forbid_ba_work;
3242e3ec7017SPing-Ke Shih 	struct rtw89_ppdu_sts_info ppdu_sts;
3243e3ec7017SPing-Ke Shih 	u8 total_sta_assoc;
3244e3ec7017SPing-Ke Shih 	bool scanning;
3245e3ec7017SPing-Ke Shih 
3246e3ec7017SPing-Ke Shih 	const struct rtw89_regulatory *regd;
3247e3ec7017SPing-Ke Shih 	struct rtw89_sar_info sar;
3248e3ec7017SPing-Ke Shih 
3249e3ec7017SPing-Ke Shih 	struct rtw89_btc btc;
3250e3ec7017SPing-Ke Shih 	enum rtw89_ps_mode ps_mode;
3251e3ec7017SPing-Ke Shih 	bool lps_enabled;
3252e3ec7017SPing-Ke Shih 
3253e3ec7017SPing-Ke Shih 	/* napi structure */
3254e3ec7017SPing-Ke Shih 	struct net_device netdev;
3255e3ec7017SPing-Ke Shih 	struct napi_struct napi;
3256e3ec7017SPing-Ke Shih 	int napi_budget_countdown;
3257e3ec7017SPing-Ke Shih 
3258e3ec7017SPing-Ke Shih 	/* HCI related data, keep last */
32592e2f63a1SGustavo A. R. Silva 	u8 priv[] __aligned(sizeof(void *));
3260e3ec7017SPing-Ke Shih };
3261e3ec7017SPing-Ke Shih 
3262e3ec7017SPing-Ke Shih static inline int rtw89_hci_tx_write(struct rtw89_dev *rtwdev,
3263e3ec7017SPing-Ke Shih 				     struct rtw89_core_tx_request *tx_req)
3264e3ec7017SPing-Ke Shih {
3265e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->tx_write(rtwdev, tx_req);
3266e3ec7017SPing-Ke Shih }
3267e3ec7017SPing-Ke Shih 
3268e3ec7017SPing-Ke Shih static inline void rtw89_hci_reset(struct rtw89_dev *rtwdev)
3269e3ec7017SPing-Ke Shih {
3270e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->reset(rtwdev);
3271e3ec7017SPing-Ke Shih }
3272e3ec7017SPing-Ke Shih 
3273e3ec7017SPing-Ke Shih static inline int rtw89_hci_start(struct rtw89_dev *rtwdev)
3274e3ec7017SPing-Ke Shih {
3275e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->start(rtwdev);
3276e3ec7017SPing-Ke Shih }
3277e3ec7017SPing-Ke Shih 
3278e3ec7017SPing-Ke Shih static inline void rtw89_hci_stop(struct rtw89_dev *rtwdev)
3279e3ec7017SPing-Ke Shih {
3280e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->stop(rtwdev);
3281e3ec7017SPing-Ke Shih }
3282e3ec7017SPing-Ke Shih 
3283e3ec7017SPing-Ke Shih static inline int rtw89_hci_deinit(struct rtw89_dev *rtwdev)
3284e3ec7017SPing-Ke Shih {
3285e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->deinit(rtwdev);
3286e3ec7017SPing-Ke Shih }
3287e3ec7017SPing-Ke Shih 
328852edbb9fSPing-Ke Shih static inline void rtw89_hci_pause(struct rtw89_dev *rtwdev, bool pause)
328952edbb9fSPing-Ke Shih {
329052edbb9fSPing-Ke Shih 	rtwdev->hci.ops->pause(rtwdev, pause);
329152edbb9fSPing-Ke Shih }
329252edbb9fSPing-Ke Shih 
329352edbb9fSPing-Ke Shih static inline void rtw89_hci_switch_mode(struct rtw89_dev *rtwdev, bool low_power)
329452edbb9fSPing-Ke Shih {
329552edbb9fSPing-Ke Shih 	rtwdev->hci.ops->switch_mode(rtwdev, low_power);
329652edbb9fSPing-Ke Shih }
329752edbb9fSPing-Ke Shih 
3298e3ec7017SPing-Ke Shih static inline void rtw89_hci_recalc_int_mit(struct rtw89_dev *rtwdev)
3299e3ec7017SPing-Ke Shih {
3300e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->recalc_int_mit(rtwdev);
3301e3ec7017SPing-Ke Shih }
3302e3ec7017SPing-Ke Shih 
3303e3ec7017SPing-Ke Shih static inline u32 rtw89_hci_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev, u8 txch)
3304e3ec7017SPing-Ke Shih {
3305e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->check_and_reclaim_tx_resource(rtwdev, txch);
3306e3ec7017SPing-Ke Shih }
3307e3ec7017SPing-Ke Shih 
3308e3ec7017SPing-Ke Shih static inline void rtw89_hci_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)
3309e3ec7017SPing-Ke Shih {
3310e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->tx_kick_off(rtwdev, txch);
3311e3ec7017SPing-Ke Shih }
3312e3ec7017SPing-Ke Shih 
3313e3ec7017SPing-Ke Shih static inline void rtw89_hci_flush_queues(struct rtw89_dev *rtwdev, u32 queues,
3314e3ec7017SPing-Ke Shih 					  bool drop)
3315e3ec7017SPing-Ke Shih {
3316fc5f311fSPing-Ke Shih 	if (!test_bit(RTW89_FLAG_POWERON, rtwdev->flags))
3317fc5f311fSPing-Ke Shih 		return;
3318fc5f311fSPing-Ke Shih 
3319e3ec7017SPing-Ke Shih 	if (rtwdev->hci.ops->flush_queues)
3320e3ec7017SPing-Ke Shih 		return rtwdev->hci.ops->flush_queues(rtwdev, queues, drop);
3321e3ec7017SPing-Ke Shih }
3322e3ec7017SPing-Ke Shih 
332314f9f479SZong-Zhe Yang static inline void rtw89_hci_recovery_start(struct rtw89_dev *rtwdev)
332414f9f479SZong-Zhe Yang {
332514f9f479SZong-Zhe Yang 	if (rtwdev->hci.ops->recovery_start)
332614f9f479SZong-Zhe Yang 		rtwdev->hci.ops->recovery_start(rtwdev);
332714f9f479SZong-Zhe Yang }
332814f9f479SZong-Zhe Yang 
332914f9f479SZong-Zhe Yang static inline void rtw89_hci_recovery_complete(struct rtw89_dev *rtwdev)
333014f9f479SZong-Zhe Yang {
333114f9f479SZong-Zhe Yang 	if (rtwdev->hci.ops->recovery_complete)
333214f9f479SZong-Zhe Yang 		rtwdev->hci.ops->recovery_complete(rtwdev);
333314f9f479SZong-Zhe Yang }
333414f9f479SZong-Zhe Yang 
3335e3ec7017SPing-Ke Shih static inline u8 rtw89_read8(struct rtw89_dev *rtwdev, u32 addr)
3336e3ec7017SPing-Ke Shih {
3337e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->read8(rtwdev, addr);
3338e3ec7017SPing-Ke Shih }
3339e3ec7017SPing-Ke Shih 
3340e3ec7017SPing-Ke Shih static inline u16 rtw89_read16(struct rtw89_dev *rtwdev, u32 addr)
3341e3ec7017SPing-Ke Shih {
3342e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->read16(rtwdev, addr);
3343e3ec7017SPing-Ke Shih }
3344e3ec7017SPing-Ke Shih 
3345e3ec7017SPing-Ke Shih static inline u32 rtw89_read32(struct rtw89_dev *rtwdev, u32 addr)
3346e3ec7017SPing-Ke Shih {
3347e3ec7017SPing-Ke Shih 	return rtwdev->hci.ops->read32(rtwdev, addr);
3348e3ec7017SPing-Ke Shih }
3349e3ec7017SPing-Ke Shih 
3350e3ec7017SPing-Ke Shih static inline void rtw89_write8(struct rtw89_dev *rtwdev, u32 addr, u8 data)
3351e3ec7017SPing-Ke Shih {
3352e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->write8(rtwdev, addr, data);
3353e3ec7017SPing-Ke Shih }
3354e3ec7017SPing-Ke Shih 
3355e3ec7017SPing-Ke Shih static inline void rtw89_write16(struct rtw89_dev *rtwdev, u32 addr, u16 data)
3356e3ec7017SPing-Ke Shih {
3357e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->write16(rtwdev, addr, data);
3358e3ec7017SPing-Ke Shih }
3359e3ec7017SPing-Ke Shih 
3360e3ec7017SPing-Ke Shih static inline void rtw89_write32(struct rtw89_dev *rtwdev, u32 addr, u32 data)
3361e3ec7017SPing-Ke Shih {
3362e3ec7017SPing-Ke Shih 	rtwdev->hci.ops->write32(rtwdev, addr, data);
3363e3ec7017SPing-Ke Shih }
3364e3ec7017SPing-Ke Shih 
3365e3ec7017SPing-Ke Shih static inline void
3366e3ec7017SPing-Ke Shih rtw89_write8_set(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
3367e3ec7017SPing-Ke Shih {
3368e3ec7017SPing-Ke Shih 	u8 val;
3369e3ec7017SPing-Ke Shih 
3370e3ec7017SPing-Ke Shih 	val = rtw89_read8(rtwdev, addr);
3371e3ec7017SPing-Ke Shih 	rtw89_write8(rtwdev, addr, val | bit);
3372e3ec7017SPing-Ke Shih }
3373e3ec7017SPing-Ke Shih 
3374e3ec7017SPing-Ke Shih static inline void
3375e3ec7017SPing-Ke Shih rtw89_write16_set(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
3376e3ec7017SPing-Ke Shih {
3377e3ec7017SPing-Ke Shih 	u16 val;
3378e3ec7017SPing-Ke Shih 
3379e3ec7017SPing-Ke Shih 	val = rtw89_read16(rtwdev, addr);
3380e3ec7017SPing-Ke Shih 	rtw89_write16(rtwdev, addr, val | bit);
3381e3ec7017SPing-Ke Shih }
3382e3ec7017SPing-Ke Shih 
3383e3ec7017SPing-Ke Shih static inline void
3384e3ec7017SPing-Ke Shih rtw89_write32_set(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
3385e3ec7017SPing-Ke Shih {
3386e3ec7017SPing-Ke Shih 	u32 val;
3387e3ec7017SPing-Ke Shih 
3388e3ec7017SPing-Ke Shih 	val = rtw89_read32(rtwdev, addr);
3389e3ec7017SPing-Ke Shih 	rtw89_write32(rtwdev, addr, val | bit);
3390e3ec7017SPing-Ke Shih }
3391e3ec7017SPing-Ke Shih 
3392e3ec7017SPing-Ke Shih static inline void
3393e3ec7017SPing-Ke Shih rtw89_write8_clr(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
3394e3ec7017SPing-Ke Shih {
3395e3ec7017SPing-Ke Shih 	u8 val;
3396e3ec7017SPing-Ke Shih 
3397e3ec7017SPing-Ke Shih 	val = rtw89_read8(rtwdev, addr);
3398e3ec7017SPing-Ke Shih 	rtw89_write8(rtwdev, addr, val & ~bit);
3399e3ec7017SPing-Ke Shih }
3400e3ec7017SPing-Ke Shih 
3401e3ec7017SPing-Ke Shih static inline void
3402e3ec7017SPing-Ke Shih rtw89_write16_clr(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
3403e3ec7017SPing-Ke Shih {
3404e3ec7017SPing-Ke Shih 	u16 val;
3405e3ec7017SPing-Ke Shih 
3406e3ec7017SPing-Ke Shih 	val = rtw89_read16(rtwdev, addr);
3407e3ec7017SPing-Ke Shih 	rtw89_write16(rtwdev, addr, val & ~bit);
3408e3ec7017SPing-Ke Shih }
3409e3ec7017SPing-Ke Shih 
3410e3ec7017SPing-Ke Shih static inline void
3411e3ec7017SPing-Ke Shih rtw89_write32_clr(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
3412e3ec7017SPing-Ke Shih {
3413e3ec7017SPing-Ke Shih 	u32 val;
3414e3ec7017SPing-Ke Shih 
3415e3ec7017SPing-Ke Shih 	val = rtw89_read32(rtwdev, addr);
3416e3ec7017SPing-Ke Shih 	rtw89_write32(rtwdev, addr, val & ~bit);
3417e3ec7017SPing-Ke Shih }
3418e3ec7017SPing-Ke Shih 
3419e3ec7017SPing-Ke Shih static inline u32
3420e3ec7017SPing-Ke Shih rtw89_read32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
3421e3ec7017SPing-Ke Shih {
3422e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
3423e3ec7017SPing-Ke Shih 	u32 orig;
3424e3ec7017SPing-Ke Shih 	u32 ret;
3425e3ec7017SPing-Ke Shih 
3426e3ec7017SPing-Ke Shih 	orig = rtw89_read32(rtwdev, addr);
3427e3ec7017SPing-Ke Shih 	ret = (orig & mask) >> shift;
3428e3ec7017SPing-Ke Shih 
3429e3ec7017SPing-Ke Shih 	return ret;
3430e3ec7017SPing-Ke Shih }
3431e3ec7017SPing-Ke Shih 
3432e3ec7017SPing-Ke Shih static inline u16
3433e3ec7017SPing-Ke Shih rtw89_read16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
3434e3ec7017SPing-Ke Shih {
3435e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
3436e3ec7017SPing-Ke Shih 	u32 orig;
3437e3ec7017SPing-Ke Shih 	u32 ret;
3438e3ec7017SPing-Ke Shih 
3439e3ec7017SPing-Ke Shih 	orig = rtw89_read16(rtwdev, addr);
3440e3ec7017SPing-Ke Shih 	ret = (orig & mask) >> shift;
3441e3ec7017SPing-Ke Shih 
3442e3ec7017SPing-Ke Shih 	return ret;
3443e3ec7017SPing-Ke Shih }
3444e3ec7017SPing-Ke Shih 
3445e3ec7017SPing-Ke Shih static inline u8
3446e3ec7017SPing-Ke Shih rtw89_read8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
3447e3ec7017SPing-Ke Shih {
3448e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
3449e3ec7017SPing-Ke Shih 	u32 orig;
3450e3ec7017SPing-Ke Shih 	u32 ret;
3451e3ec7017SPing-Ke Shih 
3452e3ec7017SPing-Ke Shih 	orig = rtw89_read8(rtwdev, addr);
3453e3ec7017SPing-Ke Shih 	ret = (orig & mask) >> shift;
3454e3ec7017SPing-Ke Shih 
3455e3ec7017SPing-Ke Shih 	return ret;
3456e3ec7017SPing-Ke Shih }
3457e3ec7017SPing-Ke Shih 
3458e3ec7017SPing-Ke Shih static inline void
3459e3ec7017SPing-Ke Shih rtw89_write32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u32 data)
3460e3ec7017SPing-Ke Shih {
3461e3ec7017SPing-Ke Shih 	u32 shift = __ffs(mask);
3462e3ec7017SPing-Ke Shih 	u32 orig;
3463e3ec7017SPing-Ke Shih 	u32 set;
3464e3ec7017SPing-Ke Shih 
3465e3ec7017SPing-Ke Shih 	WARN(addr & 0x3, "should be 4-byte aligned, addr = 0x%08x\n", addr);
3466e3ec7017SPing-Ke Shih 
3467e3ec7017SPing-Ke Shih 	orig = rtw89_read32(rtwdev, addr);
3468e3ec7017SPing-Ke Shih 	set = (orig & ~mask) | ((data << shift) & mask);
3469e3ec7017SPing-Ke Shih 	rtw89_write32(rtwdev, addr, set);
3470e3ec7017SPing-Ke Shih }
3471e3ec7017SPing-Ke Shih 
3472e3ec7017SPing-Ke Shih static inline void
3473e3ec7017SPing-Ke Shih rtw89_write16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u16 data)
3474e3ec7017SPing-Ke Shih {
3475e3ec7017SPing-Ke Shih 	u32 shift;
3476e3ec7017SPing-Ke Shih 	u16 orig, set;
3477e3ec7017SPing-Ke Shih 
3478e3ec7017SPing-Ke Shih 	mask &= 0xffff;
3479e3ec7017SPing-Ke Shih 	shift = __ffs(mask);
3480e3ec7017SPing-Ke Shih 
3481e3ec7017SPing-Ke Shih 	orig = rtw89_read16(rtwdev, addr);
3482e3ec7017SPing-Ke Shih 	set = (orig & ~mask) | ((data << shift) & mask);
3483e3ec7017SPing-Ke Shih 	rtw89_write16(rtwdev, addr, set);
3484e3ec7017SPing-Ke Shih }
3485e3ec7017SPing-Ke Shih 
3486e3ec7017SPing-Ke Shih static inline void
3487e3ec7017SPing-Ke Shih rtw89_write8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u8 data)
3488e3ec7017SPing-Ke Shih {
3489e3ec7017SPing-Ke Shih 	u32 shift;
3490e3ec7017SPing-Ke Shih 	u8 orig, set;
3491e3ec7017SPing-Ke Shih 
3492e3ec7017SPing-Ke Shih 	mask &= 0xff;
3493e3ec7017SPing-Ke Shih 	shift = __ffs(mask);
3494e3ec7017SPing-Ke Shih 
3495e3ec7017SPing-Ke Shih 	orig = rtw89_read8(rtwdev, addr);
3496e3ec7017SPing-Ke Shih 	set = (orig & ~mask) | ((data << shift) & mask);
3497e3ec7017SPing-Ke Shih 	rtw89_write8(rtwdev, addr, set);
3498e3ec7017SPing-Ke Shih }
3499e3ec7017SPing-Ke Shih 
3500e3ec7017SPing-Ke Shih static inline u32
3501e3ec7017SPing-Ke Shih rtw89_read_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
3502e3ec7017SPing-Ke Shih 	      u32 addr, u32 mask)
3503e3ec7017SPing-Ke Shih {
3504e3ec7017SPing-Ke Shih 	u32 val;
3505e3ec7017SPing-Ke Shih 
3506e3ec7017SPing-Ke Shih 	mutex_lock(&rtwdev->rf_mutex);
3507e3ec7017SPing-Ke Shih 	val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask);
3508e3ec7017SPing-Ke Shih 	mutex_unlock(&rtwdev->rf_mutex);
3509e3ec7017SPing-Ke Shih 
3510e3ec7017SPing-Ke Shih 	return val;
3511e3ec7017SPing-Ke Shih }
3512e3ec7017SPing-Ke Shih 
3513e3ec7017SPing-Ke Shih static inline void
3514e3ec7017SPing-Ke Shih rtw89_write_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
3515e3ec7017SPing-Ke Shih 	       u32 addr, u32 mask, u32 data)
3516e3ec7017SPing-Ke Shih {
3517e3ec7017SPing-Ke Shih 	mutex_lock(&rtwdev->rf_mutex);
3518e3ec7017SPing-Ke Shih 	rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data);
3519e3ec7017SPing-Ke Shih 	mutex_unlock(&rtwdev->rf_mutex);
3520e3ec7017SPing-Ke Shih }
3521e3ec7017SPing-Ke Shih 
3522e3ec7017SPing-Ke Shih static inline struct ieee80211_txq *rtw89_txq_to_txq(struct rtw89_txq *rtwtxq)
3523e3ec7017SPing-Ke Shih {
3524e3ec7017SPing-Ke Shih 	void *p = rtwtxq;
3525e3ec7017SPing-Ke Shih 
3526e3ec7017SPing-Ke Shih 	return container_of(p, struct ieee80211_txq, drv_priv);
3527e3ec7017SPing-Ke Shih }
3528e3ec7017SPing-Ke Shih 
3529e3ec7017SPing-Ke Shih static inline void rtw89_core_txq_init(struct rtw89_dev *rtwdev,
3530e3ec7017SPing-Ke Shih 				       struct ieee80211_txq *txq)
3531e3ec7017SPing-Ke Shih {
3532e3ec7017SPing-Ke Shih 	struct rtw89_txq *rtwtxq;
3533e3ec7017SPing-Ke Shih 
3534e3ec7017SPing-Ke Shih 	if (!txq)
3535e3ec7017SPing-Ke Shih 		return;
3536e3ec7017SPing-Ke Shih 
3537e3ec7017SPing-Ke Shih 	rtwtxq = (struct rtw89_txq *)txq->drv_priv;
3538e3ec7017SPing-Ke Shih 	INIT_LIST_HEAD(&rtwtxq->list);
3539e3ec7017SPing-Ke Shih }
3540e3ec7017SPing-Ke Shih 
3541e3ec7017SPing-Ke Shih static inline struct ieee80211_vif *rtwvif_to_vif(struct rtw89_vif *rtwvif)
3542e3ec7017SPing-Ke Shih {
3543e3ec7017SPing-Ke Shih 	void *p = rtwvif;
3544e3ec7017SPing-Ke Shih 
3545e3ec7017SPing-Ke Shih 	return container_of(p, struct ieee80211_vif, drv_priv);
3546e3ec7017SPing-Ke Shih }
3547e3ec7017SPing-Ke Shih 
3548e3ec7017SPing-Ke Shih static inline struct ieee80211_sta *rtwsta_to_sta(struct rtw89_sta *rtwsta)
3549e3ec7017SPing-Ke Shih {
3550e3ec7017SPing-Ke Shih 	void *p = rtwsta;
3551e3ec7017SPing-Ke Shih 
3552e3ec7017SPing-Ke Shih 	return container_of(p, struct ieee80211_sta, drv_priv);
3553e3ec7017SPing-Ke Shih }
3554e3ec7017SPing-Ke Shih 
355540822e07SPing-Ke Shih static inline struct ieee80211_sta *rtwsta_to_sta_safe(struct rtw89_sta *rtwsta)
355640822e07SPing-Ke Shih {
355740822e07SPing-Ke Shih 	return rtwsta ? rtwsta_to_sta(rtwsta) : NULL;
355840822e07SPing-Ke Shih }
355940822e07SPing-Ke Shih 
356040822e07SPing-Ke Shih static inline struct rtw89_sta *sta_to_rtwsta_safe(struct ieee80211_sta *sta)
356140822e07SPing-Ke Shih {
356240822e07SPing-Ke Shih 	return sta ? (struct rtw89_sta *)sta->drv_priv : NULL;
356340822e07SPing-Ke Shih }
356440822e07SPing-Ke Shih 
3565167044afSPing-Ke Shih static inline u8 rtw89_hw_to_rate_info_bw(enum rtw89_bandwidth hw_bw)
3566167044afSPing-Ke Shih {
3567167044afSPing-Ke Shih 	if (hw_bw == RTW89_CHANNEL_WIDTH_160)
3568167044afSPing-Ke Shih 		return RATE_INFO_BW_160;
3569167044afSPing-Ke Shih 	else if (hw_bw == RTW89_CHANNEL_WIDTH_80)
3570167044afSPing-Ke Shih 		return RATE_INFO_BW_80;
3571167044afSPing-Ke Shih 	else if (hw_bw == RTW89_CHANNEL_WIDTH_40)
3572167044afSPing-Ke Shih 		return RATE_INFO_BW_40;
3573167044afSPing-Ke Shih 	else
3574167044afSPing-Ke Shih 		return RATE_INFO_BW_20;
3575167044afSPing-Ke Shih }
3576167044afSPing-Ke Shih 
3577e3ec7017SPing-Ke Shih static inline
3578a06d2dd7SZong-Zhe Yang enum nl80211_band rtw89_hw_to_nl80211_band(enum rtw89_band hw_band)
3579a06d2dd7SZong-Zhe Yang {
3580a06d2dd7SZong-Zhe Yang 	switch (hw_band) {
3581a06d2dd7SZong-Zhe Yang 	default:
3582a06d2dd7SZong-Zhe Yang 	case RTW89_BAND_2G:
3583a06d2dd7SZong-Zhe Yang 		return NL80211_BAND_2GHZ;
3584a06d2dd7SZong-Zhe Yang 	case RTW89_BAND_5G:
3585a06d2dd7SZong-Zhe Yang 		return NL80211_BAND_5GHZ;
3586a06d2dd7SZong-Zhe Yang 	case RTW89_BAND_6G:
3587a06d2dd7SZong-Zhe Yang 		return NL80211_BAND_6GHZ;
3588a06d2dd7SZong-Zhe Yang 	}
3589a06d2dd7SZong-Zhe Yang }
3590a06d2dd7SZong-Zhe Yang 
3591a06d2dd7SZong-Zhe Yang static inline
3592e715f10fSPing-Ke Shih enum rtw89_bandwidth nl_to_rtw89_bandwidth(enum nl80211_chan_width width)
3593e715f10fSPing-Ke Shih {
3594e715f10fSPing-Ke Shih 	switch (width) {
3595e715f10fSPing-Ke Shih 	default:
3596e715f10fSPing-Ke Shih 		WARN(1, "Not support bandwidth %d\n", width);
3597e715f10fSPing-Ke Shih 		fallthrough;
3598e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_20_NOHT:
3599e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_20:
3600e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_20;
3601e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_40:
3602e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_40;
3603e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_80:
3604e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_80;
3605e715f10fSPing-Ke Shih 	case NL80211_CHAN_WIDTH_160:
3606e715f10fSPing-Ke Shih 		return RTW89_CHANNEL_WIDTH_160;
3607e715f10fSPing-Ke Shih 	}
3608e715f10fSPing-Ke Shih }
3609e715f10fSPing-Ke Shih 
3610e715f10fSPing-Ke Shih static inline
36112ab856ccSPing-Ke Shih struct rtw89_addr_cam_entry *rtw89_get_addr_cam_of(struct rtw89_vif *rtwvif,
36122ab856ccSPing-Ke Shih 						   struct rtw89_sta *rtwsta)
36132ab856ccSPing-Ke Shih {
36147312100dSPing-Ke Shih 	if (rtwsta) {
36157312100dSPing-Ke Shih 		struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta);
36167312100dSPing-Ke Shih 
36177312100dSPing-Ke Shih 		if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE || sta->tdls)
36182ab856ccSPing-Ke Shih 			return &rtwsta->addr_cam;
36197312100dSPing-Ke Shih 	}
36202ab856ccSPing-Ke Shih 	return &rtwvif->addr_cam;
36212ab856ccSPing-Ke Shih }
36222ab856ccSPing-Ke Shih 
36232ab856ccSPing-Ke Shih static inline
362439913cc8SPing-Ke Shih struct rtw89_bssid_cam_entry *rtw89_get_bssid_cam_of(struct rtw89_vif *rtwvif,
362539913cc8SPing-Ke Shih 						     struct rtw89_sta *rtwsta)
362639913cc8SPing-Ke Shih {
362739913cc8SPing-Ke Shih 	if (rtwsta) {
362839913cc8SPing-Ke Shih 		struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta);
362939913cc8SPing-Ke Shih 
363039913cc8SPing-Ke Shih 		if (sta->tdls)
363139913cc8SPing-Ke Shih 			return &rtwsta->bssid_cam;
363239913cc8SPing-Ke Shih 	}
363339913cc8SPing-Ke Shih 	return &rtwvif->bssid_cam;
363439913cc8SPing-Ke Shih }
363539913cc8SPing-Ke Shih 
363639913cc8SPing-Ke Shih static inline
3637e3ec7017SPing-Ke Shih void rtw89_chip_set_channel_prepare(struct rtw89_dev *rtwdev,
3638ce57e55cSZong-Zhe Yang 				    struct rtw89_channel_help_params *p,
3639ce57e55cSZong-Zhe Yang 				    const struct rtw89_chan *chan,
3640ce57e55cSZong-Zhe Yang 				    enum rtw89_mac_idx mac_idx,
3641ce57e55cSZong-Zhe Yang 				    enum rtw89_phy_idx phy_idx)
3642e3ec7017SPing-Ke Shih {
3643ce57e55cSZong-Zhe Yang 	rtwdev->chip->ops->set_channel_help(rtwdev, true, p, chan,
3644ce57e55cSZong-Zhe Yang 					    mac_idx, phy_idx);
3645e3ec7017SPing-Ke Shih }
3646e3ec7017SPing-Ke Shih 
3647e3ec7017SPing-Ke Shih static inline
3648e3ec7017SPing-Ke Shih void rtw89_chip_set_channel_done(struct rtw89_dev *rtwdev,
3649ce57e55cSZong-Zhe Yang 				 struct rtw89_channel_help_params *p,
3650ce57e55cSZong-Zhe Yang 				 const struct rtw89_chan *chan,
3651ce57e55cSZong-Zhe Yang 				 enum rtw89_mac_idx mac_idx,
3652ce57e55cSZong-Zhe Yang 				 enum rtw89_phy_idx phy_idx)
3653e3ec7017SPing-Ke Shih {
3654ce57e55cSZong-Zhe Yang 	rtwdev->chip->ops->set_channel_help(rtwdev, false, p, chan,
3655ce57e55cSZong-Zhe Yang 					    mac_idx, phy_idx);
3656e3ec7017SPing-Ke Shih }
3657e3ec7017SPing-Ke Shih 
3658cbb145b9SZong-Zhe Yang static inline
3659494399b2SZong-Zhe Yang const struct cfg80211_chan_def *rtw89_chandef_get(struct rtw89_dev *rtwdev,
3660494399b2SZong-Zhe Yang 						  enum rtw89_sub_entity_idx idx)
3661494399b2SZong-Zhe Yang {
3662494399b2SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
3663494399b2SZong-Zhe Yang 
3664494399b2SZong-Zhe Yang 	return &hal->chandef[idx];
3665494399b2SZong-Zhe Yang }
3666494399b2SZong-Zhe Yang 
3667494399b2SZong-Zhe Yang static inline
3668cbb145b9SZong-Zhe Yang const struct rtw89_chan *rtw89_chan_get(struct rtw89_dev *rtwdev,
3669cbb145b9SZong-Zhe Yang 					enum rtw89_sub_entity_idx idx)
3670cbb145b9SZong-Zhe Yang {
3671cbb145b9SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
3672cbb145b9SZong-Zhe Yang 
3673cbb145b9SZong-Zhe Yang 	return &hal->chan[idx];
3674cbb145b9SZong-Zhe Yang }
3675cbb145b9SZong-Zhe Yang 
3676cbb145b9SZong-Zhe Yang static inline
3677cbb145b9SZong-Zhe Yang const struct rtw89_chan_rcd *rtw89_chan_rcd_get(struct rtw89_dev *rtwdev,
3678cbb145b9SZong-Zhe Yang 						enum rtw89_sub_entity_idx idx)
3679cbb145b9SZong-Zhe Yang {
3680cbb145b9SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
3681cbb145b9SZong-Zhe Yang 
3682cbb145b9SZong-Zhe Yang 	return &hal->chan_rcd[idx];
3683cbb145b9SZong-Zhe Yang }
3684cbb145b9SZong-Zhe Yang 
3685e3ec7017SPing-Ke Shih static inline void rtw89_chip_fem_setup(struct rtw89_dev *rtwdev)
3686e3ec7017SPing-Ke Shih {
3687e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3688e3ec7017SPing-Ke Shih 
3689e3ec7017SPing-Ke Shih 	if (chip->ops->fem_setup)
3690e3ec7017SPing-Ke Shih 		chip->ops->fem_setup(rtwdev);
3691e3ec7017SPing-Ke Shih }
3692e3ec7017SPing-Ke Shih 
3693e3ec7017SPing-Ke Shih static inline void rtw89_chip_bb_sethw(struct rtw89_dev *rtwdev)
3694e3ec7017SPing-Ke Shih {
3695e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3696e3ec7017SPing-Ke Shih 
3697e3ec7017SPing-Ke Shih 	if (chip->ops->bb_sethw)
3698e3ec7017SPing-Ke Shih 		chip->ops->bb_sethw(rtwdev);
3699e3ec7017SPing-Ke Shih }
3700e3ec7017SPing-Ke Shih 
3701e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_init(struct rtw89_dev *rtwdev)
3702e3ec7017SPing-Ke Shih {
3703e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3704e3ec7017SPing-Ke Shih 
3705e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_init)
3706e3ec7017SPing-Ke Shih 		chip->ops->rfk_init(rtwdev);
3707e3ec7017SPing-Ke Shih }
3708e3ec7017SPing-Ke Shih 
3709e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_channel(struct rtw89_dev *rtwdev)
3710e3ec7017SPing-Ke Shih {
3711e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3712e3ec7017SPing-Ke Shih 
3713e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_channel)
3714e3ec7017SPing-Ke Shih 		chip->ops->rfk_channel(rtwdev);
3715e3ec7017SPing-Ke Shih }
3716e3ec7017SPing-Ke Shih 
3717010d0051SZong-Zhe Yang static inline void rtw89_chip_rfk_band_changed(struct rtw89_dev *rtwdev,
3718010d0051SZong-Zhe Yang 					       enum rtw89_phy_idx phy_idx)
3719e3ec7017SPing-Ke Shih {
3720e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3721e3ec7017SPing-Ke Shih 
3722e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_band_changed)
3723010d0051SZong-Zhe Yang 		chip->ops->rfk_band_changed(rtwdev, phy_idx);
3724e3ec7017SPing-Ke Shih }
3725e3ec7017SPing-Ke Shih 
3726e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_scan(struct rtw89_dev *rtwdev, bool start)
3727e3ec7017SPing-Ke Shih {
3728e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3729e3ec7017SPing-Ke Shih 
3730e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_scan)
3731e3ec7017SPing-Ke Shih 		chip->ops->rfk_scan(rtwdev, start);
3732e3ec7017SPing-Ke Shih }
3733e3ec7017SPing-Ke Shih 
3734e3ec7017SPing-Ke Shih static inline void rtw89_chip_rfk_track(struct rtw89_dev *rtwdev)
3735e3ec7017SPing-Ke Shih {
3736e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3737e3ec7017SPing-Ke Shih 
3738e3ec7017SPing-Ke Shih 	if (chip->ops->rfk_track)
3739e3ec7017SPing-Ke Shih 		chip->ops->rfk_track(rtwdev);
3740e3ec7017SPing-Ke Shih }
3741e3ec7017SPing-Ke Shih 
3742e3ec7017SPing-Ke Shih static inline void rtw89_chip_set_txpwr_ctrl(struct rtw89_dev *rtwdev)
3743e3ec7017SPing-Ke Shih {
3744e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3745e3ec7017SPing-Ke Shih 
3746e3ec7017SPing-Ke Shih 	if (chip->ops->set_txpwr_ctrl)
374707ef5f2fSZong-Zhe Yang 		chip->ops->set_txpwr_ctrl(rtwdev,  RTW89_PHY_0);
3748e3ec7017SPing-Ke Shih }
3749e3ec7017SPing-Ke Shih 
3750e3ec7017SPing-Ke Shih static inline void rtw89_chip_power_trim(struct rtw89_dev *rtwdev)
3751e3ec7017SPing-Ke Shih {
3752e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3753e3ec7017SPing-Ke Shih 
3754e3ec7017SPing-Ke Shih 	if (chip->ops->power_trim)
3755e3ec7017SPing-Ke Shih 		chip->ops->power_trim(rtwdev);
3756e3ec7017SPing-Ke Shih }
3757e3ec7017SPing-Ke Shih 
3758e3ec7017SPing-Ke Shih static inline void rtw89_chip_init_txpwr_unit(struct rtw89_dev *rtwdev,
3759e3ec7017SPing-Ke Shih 					      enum rtw89_phy_idx phy_idx)
3760e3ec7017SPing-Ke Shih {
3761e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3762e3ec7017SPing-Ke Shih 
3763e3ec7017SPing-Ke Shih 	if (chip->ops->init_txpwr_unit)
3764e3ec7017SPing-Ke Shih 		chip->ops->init_txpwr_unit(rtwdev, phy_idx);
3765e3ec7017SPing-Ke Shih }
3766e3ec7017SPing-Ke Shih 
3767e3ec7017SPing-Ke Shih static inline u8 rtw89_chip_get_thermal(struct rtw89_dev *rtwdev,
3768e3ec7017SPing-Ke Shih 					enum rtw89_rf_path rf_path)
3769e3ec7017SPing-Ke Shih {
3770e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3771e3ec7017SPing-Ke Shih 
3772e3ec7017SPing-Ke Shih 	if (!chip->ops->get_thermal)
3773e3ec7017SPing-Ke Shih 		return 0x10;
3774e3ec7017SPing-Ke Shih 
3775e3ec7017SPing-Ke Shih 	return chip->ops->get_thermal(rtwdev, rf_path);
3776e3ec7017SPing-Ke Shih }
3777e3ec7017SPing-Ke Shih 
3778e3ec7017SPing-Ke Shih static inline void rtw89_chip_query_ppdu(struct rtw89_dev *rtwdev,
3779e3ec7017SPing-Ke Shih 					 struct rtw89_rx_phy_ppdu *phy_ppdu,
3780e3ec7017SPing-Ke Shih 					 struct ieee80211_rx_status *status)
3781e3ec7017SPing-Ke Shih {
3782e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3783e3ec7017SPing-Ke Shih 
3784e3ec7017SPing-Ke Shih 	if (chip->ops->query_ppdu)
3785e3ec7017SPing-Ke Shih 		chip->ops->query_ppdu(rtwdev, phy_ppdu, status);
3786e3ec7017SPing-Ke Shih }
3787e3ec7017SPing-Ke Shih 
3788e3ec7017SPing-Ke Shih static inline void rtw89_chip_bb_ctrl_btc_preagc(struct rtw89_dev *rtwdev,
3789e3ec7017SPing-Ke Shih 						 bool bt_en)
3790e3ec7017SPing-Ke Shih {
3791e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3792e3ec7017SPing-Ke Shih 
3793e3ec7017SPing-Ke Shih 	if (chip->ops->bb_ctrl_btc_preagc)
3794e3ec7017SPing-Ke Shih 		chip->ops->bb_ctrl_btc_preagc(rtwdev, bt_en);
3795e3ec7017SPing-Ke Shih }
3796e3ec7017SPing-Ke Shih 
3797cd89a471SPing-Ke Shih static inline void rtw89_chip_cfg_txrx_path(struct rtw89_dev *rtwdev)
3798cd89a471SPing-Ke Shih {
3799cd89a471SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3800cd89a471SPing-Ke Shih 
3801cd89a471SPing-Ke Shih 	if (chip->ops->cfg_txrx_path)
3802cd89a471SPing-Ke Shih 		chip->ops->cfg_txrx_path(rtwdev);
3803cd89a471SPing-Ke Shih }
3804cd89a471SPing-Ke Shih 
3805e3ec7017SPing-Ke Shih static inline
3806e3ec7017SPing-Ke Shih void rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev,
3807e3ec7017SPing-Ke Shih 				       struct ieee80211_vif *vif)
3808e3ec7017SPing-Ke Shih {
3809e3ec7017SPing-Ke Shih 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
3810e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3811e3ec7017SPing-Ke Shih 
3812f276e20bSJohannes Berg 	if (!vif->bss_conf.he_support || !vif->cfg.assoc)
3813e3ec7017SPing-Ke Shih 		return;
3814e3ec7017SPing-Ke Shih 
3815e3ec7017SPing-Ke Shih 	if (chip->ops->set_txpwr_ul_tb_offset)
3816e3ec7017SPing-Ke Shih 		chip->ops->set_txpwr_ul_tb_offset(rtwdev, 0, rtwvif->mac_idx);
3817e3ec7017SPing-Ke Shih }
3818e3ec7017SPing-Ke Shih 
3819e3ec7017SPing-Ke Shih static inline void rtw89_load_txpwr_table(struct rtw89_dev *rtwdev,
3820e3ec7017SPing-Ke Shih 					  const struct rtw89_txpwr_table *tbl)
3821e3ec7017SPing-Ke Shih {
3822e3ec7017SPing-Ke Shih 	tbl->load(rtwdev, tbl);
3823e3ec7017SPing-Ke Shih }
3824e3ec7017SPing-Ke Shih 
3825e3ec7017SPing-Ke Shih static inline u8 rtw89_regd_get(struct rtw89_dev *rtwdev, u8 band)
3826e3ec7017SPing-Ke Shih {
3827e3ec7017SPing-Ke Shih 	return rtwdev->regd->txpwr_regd[band];
3828e3ec7017SPing-Ke Shih }
3829e3ec7017SPing-Ke Shih 
3830e3ec7017SPing-Ke Shih static inline void rtw89_ctrl_btg(struct rtw89_dev *rtwdev, bool btg)
3831e3ec7017SPing-Ke Shih {
3832e3ec7017SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3833e3ec7017SPing-Ke Shih 
3834e3ec7017SPing-Ke Shih 	if (chip->ops->ctrl_btg)
3835e3ec7017SPing-Ke Shih 		chip->ops->ctrl_btg(rtwdev, btg);
3836e3ec7017SPing-Ke Shih }
3837e3ec7017SPing-Ke Shih 
3838feed6541SChia-Yuan Li static inline
3839f59acddeSPing-Ke Shih void rtw89_chip_fill_txdesc(struct rtw89_dev *rtwdev,
3840f59acddeSPing-Ke Shih 			    struct rtw89_tx_desc_info *desc_info,
3841f59acddeSPing-Ke Shih 			    void *txdesc)
3842f59acddeSPing-Ke Shih {
3843f59acddeSPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3844f59acddeSPing-Ke Shih 
3845f59acddeSPing-Ke Shih 	chip->ops->fill_txdesc(rtwdev, desc_info, txdesc);
3846f59acddeSPing-Ke Shih }
3847f59acddeSPing-Ke Shih 
3848f59acddeSPing-Ke Shih static inline
3849a95bd62eSPing-Ke Shih void rtw89_chip_fill_txdesc_fwcmd(struct rtw89_dev *rtwdev,
3850a95bd62eSPing-Ke Shih 				  struct rtw89_tx_desc_info *desc_info,
3851a95bd62eSPing-Ke Shih 				  void *txdesc)
3852a95bd62eSPing-Ke Shih {
3853a95bd62eSPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3854a95bd62eSPing-Ke Shih 
3855a95bd62eSPing-Ke Shih 	chip->ops->fill_txdesc_fwcmd(rtwdev, desc_info, txdesc);
3856a95bd62eSPing-Ke Shih }
3857a95bd62eSPing-Ke Shih 
3858a95bd62eSPing-Ke Shih static inline
3859feed6541SChia-Yuan Li void rtw89_chip_mac_cfg_gnt(struct rtw89_dev *rtwdev,
3860feed6541SChia-Yuan Li 			    const struct rtw89_mac_ax_coex_gnt *gnt_cfg)
3861feed6541SChia-Yuan Li {
3862feed6541SChia-Yuan Li 	const struct rtw89_chip_info *chip = rtwdev->chip;
3863feed6541SChia-Yuan Li 
3864feed6541SChia-Yuan Li 	chip->ops->mac_cfg_gnt(rtwdev, gnt_cfg);
3865feed6541SChia-Yuan Li }
3866feed6541SChia-Yuan Li 
3867feed6541SChia-Yuan Li static inline void rtw89_chip_cfg_ctrl_path(struct rtw89_dev *rtwdev, bool wl)
3868feed6541SChia-Yuan Li {
3869feed6541SChia-Yuan Li 	const struct rtw89_chip_info *chip = rtwdev->chip;
3870feed6541SChia-Yuan Li 
3871feed6541SChia-Yuan Li 	chip->ops->cfg_ctrl_path(rtwdev, wl);
3872feed6541SChia-Yuan Li }
3873feed6541SChia-Yuan Li 
3874de7ba639SPing-Ke Shih static inline
3875de7ba639SPing-Ke Shih int rtw89_chip_stop_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx,
3876de7ba639SPing-Ke Shih 			   u32 *tx_en, enum rtw89_sch_tx_sel sel)
3877de7ba639SPing-Ke Shih {
3878de7ba639SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3879de7ba639SPing-Ke Shih 
3880de7ba639SPing-Ke Shih 	return chip->ops->stop_sch_tx(rtwdev, mac_idx, tx_en, sel);
3881de7ba639SPing-Ke Shih }
3882de7ba639SPing-Ke Shih 
3883de7ba639SPing-Ke Shih static inline
3884de7ba639SPing-Ke Shih int rtw89_chip_resume_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en)
3885de7ba639SPing-Ke Shih {
3886de7ba639SPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
3887de7ba639SPing-Ke Shih 
3888de7ba639SPing-Ke Shih 	return chip->ops->resume_sch_tx(rtwdev, mac_idx, tx_en);
3889de7ba639SPing-Ke Shih }
3890de7ba639SPing-Ke Shih 
38910a6f299bSPing-Ke Shih static inline
38920a6f299bSPing-Ke Shih int rtw89_chip_h2c_dctl_sec_cam(struct rtw89_dev *rtwdev,
38930a6f299bSPing-Ke Shih 				struct rtw89_vif *rtwvif,
38940a6f299bSPing-Ke Shih 				struct rtw89_sta *rtwsta)
38950a6f299bSPing-Ke Shih {
38960a6f299bSPing-Ke Shih 	const struct rtw89_chip_info *chip = rtwdev->chip;
38970a6f299bSPing-Ke Shih 
38980a6f299bSPing-Ke Shih 	if (!chip->ops->h2c_dctl_sec_cam)
38990a6f299bSPing-Ke Shih 		return 0;
39000a6f299bSPing-Ke Shih 	return chip->ops->h2c_dctl_sec_cam(rtwdev, rtwvif, rtwsta);
39010a6f299bSPing-Ke Shih }
39020a6f299bSPing-Ke Shih 
3903e3ec7017SPing-Ke Shih static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr)
3904e3ec7017SPing-Ke Shih {
3905e3ec7017SPing-Ke Shih 	__le16 fc = hdr->frame_control;
3906e3ec7017SPing-Ke Shih 
3907e3ec7017SPing-Ke Shih 	if (ieee80211_has_tods(fc))
3908e3ec7017SPing-Ke Shih 		return hdr->addr1;
3909e3ec7017SPing-Ke Shih 	else if (ieee80211_has_fromds(fc))
3910e3ec7017SPing-Ke Shih 		return hdr->addr2;
3911e3ec7017SPing-Ke Shih 	else
3912e3ec7017SPing-Ke Shih 		return hdr->addr3;
3913e3ec7017SPing-Ke Shih }
3914e3ec7017SPing-Ke Shih 
3915e3ec7017SPing-Ke Shih static inline bool rtw89_sta_has_beamformer_cap(struct ieee80211_sta *sta)
3916e3ec7017SPing-Ke Shih {
3917046d2e7cSSriram R 	if ((sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) ||
3918046d2e7cSSriram R 	    (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) ||
3919046d2e7cSSriram R 	    (sta->deflink.he_cap.he_cap_elem.phy_cap_info[3] &
3920046d2e7cSSriram R 			IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER) ||
3921046d2e7cSSriram R 	    (sta->deflink.he_cap.he_cap_elem.phy_cap_info[4] &
3922046d2e7cSSriram R 			IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER))
3923e3ec7017SPing-Ke Shih 		return true;
3924e3ec7017SPing-Ke Shih 	return false;
3925e3ec7017SPing-Ke Shih }
3926e3ec7017SPing-Ke Shih 
3927e3ec7017SPing-Ke Shih static inline struct rtw89_fw_suit *rtw89_fw_suit_get(struct rtw89_dev *rtwdev,
3928e3ec7017SPing-Ke Shih 						      enum rtw89_fw_type type)
3929e3ec7017SPing-Ke Shih {
3930e3ec7017SPing-Ke Shih 	struct rtw89_fw_info *fw_info = &rtwdev->fw;
3931e3ec7017SPing-Ke Shih 
3932e3ec7017SPing-Ke Shih 	if (type == RTW89_FW_WOWLAN)
3933e3ec7017SPing-Ke Shih 		return &fw_info->wowlan;
3934e3ec7017SPing-Ke Shih 	return &fw_info->normal;
3935e3ec7017SPing-Ke Shih }
3936e3ec7017SPing-Ke Shih 
3937e3ec7017SPing-Ke Shih int rtw89_core_tx_write(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif,
3938e3ec7017SPing-Ke Shih 			struct ieee80211_sta *sta, struct sk_buff *skb, int *qsel);
3939e3ec7017SPing-Ke Shih int rtw89_h2c_tx(struct rtw89_dev *rtwdev,
3940e3ec7017SPing-Ke Shih 		 struct sk_buff *skb, bool fwdl);
3941e3ec7017SPing-Ke Shih void rtw89_core_tx_kick_off(struct rtw89_dev *rtwdev, u8 qsel);
3942e3ec7017SPing-Ke Shih void rtw89_core_fill_txdesc(struct rtw89_dev *rtwdev,
3943e3ec7017SPing-Ke Shih 			    struct rtw89_tx_desc_info *desc_info,
3944e3ec7017SPing-Ke Shih 			    void *txdesc);
3945f59acddeSPing-Ke Shih void rtw89_core_fill_txdesc_v1(struct rtw89_dev *rtwdev,
3946f59acddeSPing-Ke Shih 			       struct rtw89_tx_desc_info *desc_info,
3947f59acddeSPing-Ke Shih 			       void *txdesc);
3948a95bd62eSPing-Ke Shih void rtw89_core_fill_txdesc_fwcmd_v1(struct rtw89_dev *rtwdev,
3949a95bd62eSPing-Ke Shih 				     struct rtw89_tx_desc_info *desc_info,
3950a95bd62eSPing-Ke Shih 				     void *txdesc);
3951e3ec7017SPing-Ke Shih void rtw89_core_rx(struct rtw89_dev *rtwdev,
3952e3ec7017SPing-Ke Shih 		   struct rtw89_rx_desc_info *desc_info,
3953e3ec7017SPing-Ke Shih 		   struct sk_buff *skb);
3954e3ec7017SPing-Ke Shih void rtw89_core_query_rxdesc(struct rtw89_dev *rtwdev,
3955e3ec7017SPing-Ke Shih 			     struct rtw89_rx_desc_info *desc_info,
3956e3ec7017SPing-Ke Shih 			     u8 *data, u32 data_offset);
3957e3ec7017SPing-Ke Shih void rtw89_core_napi_start(struct rtw89_dev *rtwdev);
3958e3ec7017SPing-Ke Shih void rtw89_core_napi_stop(struct rtw89_dev *rtwdev);
3959e3ec7017SPing-Ke Shih void rtw89_core_napi_init(struct rtw89_dev *rtwdev);
3960e3ec7017SPing-Ke Shih void rtw89_core_napi_deinit(struct rtw89_dev *rtwdev);
3961e3ec7017SPing-Ke Shih int rtw89_core_sta_add(struct rtw89_dev *rtwdev,
3962e3ec7017SPing-Ke Shih 		       struct ieee80211_vif *vif,
3963e3ec7017SPing-Ke Shih 		       struct ieee80211_sta *sta);
3964e3ec7017SPing-Ke Shih int rtw89_core_sta_assoc(struct rtw89_dev *rtwdev,
3965e3ec7017SPing-Ke Shih 			 struct ieee80211_vif *vif,
3966e3ec7017SPing-Ke Shih 			 struct ieee80211_sta *sta);
3967e3ec7017SPing-Ke Shih int rtw89_core_sta_disassoc(struct rtw89_dev *rtwdev,
3968e3ec7017SPing-Ke Shih 			    struct ieee80211_vif *vif,
3969e3ec7017SPing-Ke Shih 			    struct ieee80211_sta *sta);
3970e3ec7017SPing-Ke Shih int rtw89_core_sta_disconnect(struct rtw89_dev *rtwdev,
3971e3ec7017SPing-Ke Shih 			      struct ieee80211_vif *vif,
3972e3ec7017SPing-Ke Shih 			      struct ieee80211_sta *sta);
3973e3ec7017SPing-Ke Shih int rtw89_core_sta_remove(struct rtw89_dev *rtwdev,
3974e3ec7017SPing-Ke Shih 			  struct ieee80211_vif *vif,
3975e3ec7017SPing-Ke Shih 			  struct ieee80211_sta *sta);
3976e3ec7017SPing-Ke Shih int rtw89_core_init(struct rtw89_dev *rtwdev);
3977e3ec7017SPing-Ke Shih void rtw89_core_deinit(struct rtw89_dev *rtwdev);
3978e3ec7017SPing-Ke Shih int rtw89_core_register(struct rtw89_dev *rtwdev);
3979e3ec7017SPing-Ke Shih void rtw89_core_unregister(struct rtw89_dev *rtwdev);
39807fc06a07SZong-Zhe Yang struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device,
39817fc06a07SZong-Zhe Yang 					   u32 bus_data_size,
39827fc06a07SZong-Zhe Yang 					   const struct rtw89_chip_info *chip);
39837fc06a07SZong-Zhe Yang void rtw89_free_ieee80211_hw(struct rtw89_dev *rtwdev);
3984967439c7SZong-Zhe Yang void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev);
3985a88b6cc4SZong-Zhe Yang void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef);
3986e3ec7017SPing-Ke Shih void rtw89_set_channel(struct rtw89_dev *rtwdev);
3987e3ec7017SPing-Ke Shih u8 rtw89_core_acquire_bit_map(unsigned long *addr, unsigned long size);
3988e3ec7017SPing-Ke Shih void rtw89_core_release_bit_map(unsigned long *addr, u8 bit);
3989e3ec7017SPing-Ke Shih void rtw89_core_release_all_bits_map(unsigned long *addr, unsigned int nbits);
39903ffbb5a8SPing-Ke Shih int rtw89_core_acquire_sta_ba_entry(struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx);
39913ffbb5a8SPing-Ke Shih int rtw89_core_release_sta_ba_entry(struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx);
3992e3ec7017SPing-Ke Shih void rtw89_vif_type_mapping(struct ieee80211_vif *vif, bool assoc);
3993e3ec7017SPing-Ke Shih int rtw89_chip_info_setup(struct rtw89_dev *rtwdev);
39949a3a593cSPing-Ke Shih bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate);
3995e3ec7017SPing-Ke Shih int rtw89_regd_init(struct rtw89_dev *rtwdev,
3996e3ec7017SPing-Ke Shih 		    void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request));
3997e3ec7017SPing-Ke Shih void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
3998e3ec7017SPing-Ke Shih void rtw89_traffic_stats_init(struct rtw89_dev *rtwdev,
3999e3ec7017SPing-Ke Shih 			      struct rtw89_traffic_stats *stats);
4000e3ec7017SPing-Ke Shih int rtw89_core_start(struct rtw89_dev *rtwdev);
4001e3ec7017SPing-Ke Shih void rtw89_core_stop(struct rtw89_dev *rtwdev);
4002d62816b4SPing-Ke Shih void rtw89_core_update_beacon_work(struct work_struct *work);
400389590777SPo Hao Huang void rtw89_core_scan_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
400489590777SPo Hao Huang 			   const u8 *mac_addr, bool hw_scan);
400589590777SPo Hao Huang void rtw89_core_scan_complete(struct rtw89_dev *rtwdev,
400689590777SPo Hao Huang 			      struct ieee80211_vif *vif, bool hw_scan);
4007e3ec7017SPing-Ke Shih 
4008e3ec7017SPing-Ke Shih #endif
4009