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