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