xref: /openbmc/linux/drivers/net/wireless/ath/ath11k/hal.h (revision c4a11bf4)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef ATH11K_HAL_H
7 #define ATH11K_HAL_H
8 
9 #include "hal_desc.h"
10 #include "rx_desc.h"
11 
12 struct ath11k_base;
13 
14 #define HAL_LINK_DESC_SIZE			(32 << 2)
15 #define HAL_LINK_DESC_ALIGN			128
16 #define HAL_NUM_MPDUS_PER_LINK_DESC		6
17 #define HAL_NUM_TX_MSDUS_PER_LINK_DESC		7
18 #define HAL_NUM_RX_MSDUS_PER_LINK_DESC		6
19 #define HAL_NUM_MPDU_LINKS_PER_QUEUE_DESC	12
20 #define HAL_MAX_AVAIL_BLK_RES			3
21 
22 #define HAL_RING_BASE_ALIGN	8
23 
24 #define HAL_WBM_IDLE_SCATTER_BUF_SIZE_MAX	32704
25 /* TODO: Check with hw team on the supported scatter buf size */
26 #define HAL_WBM_IDLE_SCATTER_NEXT_PTR_SIZE	8
27 #define HAL_WBM_IDLE_SCATTER_BUF_SIZE (HAL_WBM_IDLE_SCATTER_BUF_SIZE_MAX - \
28 				       HAL_WBM_IDLE_SCATTER_NEXT_PTR_SIZE)
29 
30 #define HAL_DSCP_TID_MAP_TBL_NUM_ENTRIES_MAX	48
31 #define HAL_DSCP_TID_TBL_SIZE			24
32 
33 /* calculate the register address from bar0 of shadow register x */
34 #define HAL_SHADOW_BASE_ADDR			0x000008fc
35 #define HAL_SHADOW_NUM_REGS			36
36 #define HAL_HP_OFFSET_IN_REG_START		1
37 #define HAL_OFFSET_FROM_HP_TO_TP		4
38 
39 #define HAL_SHADOW_REG(x) (HAL_SHADOW_BASE_ADDR + (4 * (x)))
40 
41 /* WCSS Relative address */
42 #define HAL_SEQ_WCSS_UMAC_OFFSET		0x00a00000
43 #define HAL_SEQ_WCSS_UMAC_REO_REG		0x00a38000
44 #define HAL_SEQ_WCSS_UMAC_TCL_REG		0x00a44000
45 #define HAL_SEQ_WCSS_UMAC_CE0_SRC_REG(x) \
46 		(ab->hw_params.regs->hal_seq_wcss_umac_ce0_src_reg)
47 #define HAL_SEQ_WCSS_UMAC_CE0_DST_REG(x) \
48 		(ab->hw_params.regs->hal_seq_wcss_umac_ce0_dst_reg)
49 #define HAL_SEQ_WCSS_UMAC_CE1_SRC_REG(x) \
50 		(ab->hw_params.regs->hal_seq_wcss_umac_ce1_src_reg)
51 #define HAL_SEQ_WCSS_UMAC_CE1_DST_REG(x) \
52 		(ab->hw_params.regs->hal_seq_wcss_umac_ce1_dst_reg)
53 #define HAL_SEQ_WCSS_UMAC_WBM_REG		0x00a34000
54 
55 #define HAL_CE_WFSS_CE_REG_BASE			0x01b80000
56 #define HAL_WLAON_REG_BASE			0x01f80000
57 
58 /* SW2TCL(x) R0 ring configuration address */
59 #define HAL_TCL1_RING_CMN_CTRL_REG		0x00000014
60 #define HAL_TCL1_RING_DSCP_TID_MAP		0x0000002c
61 #define HAL_TCL1_RING_BASE_LSB(ab)		ab->hw_params.regs->hal_tcl1_ring_base_lsb
62 #define HAL_TCL1_RING_BASE_MSB(ab)		ab->hw_params.regs->hal_tcl1_ring_base_msb
63 #define HAL_TCL1_RING_ID(ab)			ab->hw_params.regs->hal_tcl1_ring_id
64 #define HAL_TCL1_RING_MISC(ab)			ab->hw_params.regs->hal_tcl1_ring_misc
65 #define HAL_TCL1_RING_TP_ADDR_LSB(ab) \
66 	ab->hw_params.regs->hal_tcl1_ring_tp_addr_lsb
67 #define HAL_TCL1_RING_TP_ADDR_MSB(ab) \
68 	ab->hw_params.regs->hal_tcl1_ring_tp_addr_msb
69 #define HAL_TCL1_RING_CONSUMER_INT_SETUP_IX0(ab) \
70 	ab->hw_params.regs->hal_tcl1_ring_consumer_int_setup_ix0
71 #define HAL_TCL1_RING_CONSUMER_INT_SETUP_IX1(ab) \
72 	ab->hw_params.regs->hal_tcl1_ring_consumer_int_setup_ix1
73 #define HAL_TCL1_RING_MSI1_BASE_LSB(ab) \
74 	ab->hw_params.regs->hal_tcl1_ring_msi1_base_lsb
75 #define HAL_TCL1_RING_MSI1_BASE_MSB(ab) \
76 	ab->hw_params.regs->hal_tcl1_ring_msi1_base_msb
77 #define HAL_TCL1_RING_MSI1_DATA(ab) \
78 	ab->hw_params.regs->hal_tcl1_ring_msi1_data
79 #define HAL_TCL2_RING_BASE_LSB(ab)		ab->hw_params.regs->hal_tcl2_ring_base_lsb
80 #define HAL_TCL_RING_BASE_LSB(ab)		ab->hw_params.regs->hal_tcl_ring_base_lsb
81 
82 #define HAL_TCL1_RING_MSI1_BASE_LSB_OFFSET(ab)				\
83 	(HAL_TCL1_RING_MSI1_BASE_LSB(ab) - HAL_TCL1_RING_BASE_LSB(ab))
84 #define HAL_TCL1_RING_MSI1_BASE_MSB_OFFSET(ab)				\
85 	(HAL_TCL1_RING_MSI1_BASE_MSB(ab) - HAL_TCL1_RING_BASE_LSB(ab))
86 #define HAL_TCL1_RING_MSI1_DATA_OFFSET(ab)				\
87 	(HAL_TCL1_RING_MSI1_DATA(ab) - HAL_TCL1_RING_BASE_LSB(ab))
88 #define HAL_TCL1_RING_BASE_MSB_OFFSET(ab)				\
89 	(HAL_TCL1_RING_BASE_MSB(ab) - HAL_TCL1_RING_BASE_LSB(ab))
90 #define HAL_TCL1_RING_ID_OFFSET(ab)				\
91 	(HAL_TCL1_RING_ID(ab) - HAL_TCL1_RING_BASE_LSB(ab))
92 #define HAL_TCL1_RING_CONSR_INT_SETUP_IX0_OFFSET(ab)			\
93 	(HAL_TCL1_RING_CONSUMER_INT_SETUP_IX0(ab) - HAL_TCL1_RING_BASE_LSB(ab))
94 #define HAL_TCL1_RING_CONSR_INT_SETUP_IX1_OFFSET(ab) \
95 		(HAL_TCL1_RING_CONSUMER_INT_SETUP_IX1(ab) - HAL_TCL1_RING_BASE_LSB(ab))
96 #define HAL_TCL1_RING_TP_ADDR_LSB_OFFSET(ab) \
97 		(HAL_TCL1_RING_TP_ADDR_LSB(ab) - HAL_TCL1_RING_BASE_LSB(ab))
98 #define HAL_TCL1_RING_TP_ADDR_MSB_OFFSET(ab) \
99 		(HAL_TCL1_RING_TP_ADDR_MSB(ab) - HAL_TCL1_RING_BASE_LSB(ab))
100 #define HAL_TCL1_RING_MISC_OFFSET(ab) \
101 		(HAL_TCL1_RING_MISC(ab) - HAL_TCL1_RING_BASE_LSB(ab))
102 
103 /* SW2TCL(x) R2 ring pointers (head/tail) address */
104 #define HAL_TCL1_RING_HP			0x00002000
105 #define HAL_TCL1_RING_TP			0x00002004
106 #define HAL_TCL2_RING_HP			0x00002008
107 #define HAL_TCL_RING_HP				0x00002018
108 
109 #define HAL_TCL1_RING_TP_OFFSET \
110 		(HAL_TCL1_RING_TP - HAL_TCL1_RING_HP)
111 
112 /* TCL STATUS ring address */
113 #define HAL_TCL_STATUS_RING_BASE_LSB(ab) \
114 	ab->hw_params.regs->hal_tcl_status_ring_base_lsb
115 #define HAL_TCL_STATUS_RING_HP			0x00002030
116 
117 /* REO2SW(x) R0 ring configuration address */
118 #define HAL_REO1_GEN_ENABLE			0x00000000
119 #define HAL_REO1_DEST_RING_CTRL_IX_0		0x00000004
120 #define HAL_REO1_DEST_RING_CTRL_IX_1		0x00000008
121 #define HAL_REO1_DEST_RING_CTRL_IX_2		0x0000000c
122 #define HAL_REO1_DEST_RING_CTRL_IX_3		0x00000010
123 #define HAL_REO1_MISC_CTL			0x00000630
124 #define HAL_REO1_RING_BASE_LSB(ab)		ab->hw_params.regs->hal_reo1_ring_base_lsb
125 #define HAL_REO1_RING_BASE_MSB(ab)		ab->hw_params.regs->hal_reo1_ring_base_msb
126 #define HAL_REO1_RING_ID(ab)			ab->hw_params.regs->hal_reo1_ring_id
127 #define HAL_REO1_RING_MISC(ab)			ab->hw_params.regs->hal_reo1_ring_misc
128 #define HAL_REO1_RING_HP_ADDR_LSB(ab) \
129 	ab->hw_params.regs->hal_reo1_ring_hp_addr_lsb
130 #define HAL_REO1_RING_HP_ADDR_MSB(ab) \
131 	ab->hw_params.regs->hal_reo1_ring_hp_addr_msb
132 #define HAL_REO1_RING_PRODUCER_INT_SETUP(ab) \
133 	ab->hw_params.regs->hal_reo1_ring_producer_int_setup
134 #define HAL_REO1_RING_MSI1_BASE_LSB(ab) \
135 	ab->hw_params.regs->hal_reo1_ring_msi1_base_lsb
136 #define HAL_REO1_RING_MSI1_BASE_MSB(ab) \
137 	ab->hw_params.regs->hal_reo1_ring_msi1_base_msb
138 #define HAL_REO1_RING_MSI1_DATA(ab) \
139 	ab->hw_params.regs->hal_reo1_ring_msi1_data
140 #define HAL_REO2_RING_BASE_LSB(ab)		ab->hw_params.regs->hal_reo2_ring_base_lsb
141 #define HAL_REO1_AGING_THRESH_IX_0(ab) \
142 	ab->hw_params.regs->hal_reo1_aging_thresh_ix_0
143 #define HAL_REO1_AGING_THRESH_IX_1(ab) \
144 	ab->hw_params.regs->hal_reo1_aging_thresh_ix_1
145 #define HAL_REO1_AGING_THRESH_IX_2(ab) \
146 	ab->hw_params.regs->hal_reo1_aging_thresh_ix_2
147 #define HAL_REO1_AGING_THRESH_IX_3(ab) \
148 	ab->hw_params.regs->hal_reo1_aging_thresh_ix_3
149 
150 #define HAL_REO1_RING_MSI1_BASE_LSB_OFFSET(ab) \
151 		(HAL_REO1_RING_MSI1_BASE_LSB(ab) - HAL_REO1_RING_BASE_LSB(ab))
152 #define HAL_REO1_RING_MSI1_BASE_MSB_OFFSET(ab) \
153 		(HAL_REO1_RING_MSI1_BASE_MSB(ab) - HAL_REO1_RING_BASE_LSB(ab))
154 #define HAL_REO1_RING_MSI1_DATA_OFFSET(ab) \
155 		(HAL_REO1_RING_MSI1_DATA(ab) - HAL_REO1_RING_BASE_LSB(ab))
156 #define HAL_REO1_RING_BASE_MSB_OFFSET(ab) \
157 		(HAL_REO1_RING_BASE_MSB(ab) - HAL_REO1_RING_BASE_LSB(ab))
158 #define HAL_REO1_RING_ID_OFFSET(ab) (HAL_REO1_RING_ID(ab) - HAL_REO1_RING_BASE_LSB(ab))
159 #define HAL_REO1_RING_PRODUCER_INT_SETUP_OFFSET(ab) \
160 		(HAL_REO1_RING_PRODUCER_INT_SETUP(ab) - HAL_REO1_RING_BASE_LSB(ab))
161 #define HAL_REO1_RING_HP_ADDR_LSB_OFFSET(ab) \
162 		(HAL_REO1_RING_HP_ADDR_LSB(ab) - HAL_REO1_RING_BASE_LSB(ab))
163 #define HAL_REO1_RING_HP_ADDR_MSB_OFFSET(ab) \
164 		(HAL_REO1_RING_HP_ADDR_MSB(ab) - HAL_REO1_RING_BASE_LSB(ab))
165 #define HAL_REO1_RING_MISC_OFFSET(ab) \
166 	(HAL_REO1_RING_MISC(ab) - HAL_REO1_RING_BASE_LSB(ab))
167 
168 /* REO2SW(x) R2 ring pointers (head/tail) address */
169 #define HAL_REO1_RING_HP(ab)			ab->hw_params.regs->hal_reo1_ring_hp
170 #define HAL_REO1_RING_TP(ab)			ab->hw_params.regs->hal_reo1_ring_tp
171 #define HAL_REO2_RING_HP(ab)			ab->hw_params.regs->hal_reo2_ring_hp
172 
173 #define HAL_REO1_RING_TP_OFFSET(ab)	(HAL_REO1_RING_TP(ab) - HAL_REO1_RING_HP(ab))
174 
175 /* REO2TCL R0 ring configuration address */
176 #define HAL_REO_TCL_RING_BASE_LSB(ab) \
177 	ab->hw_params.regs->hal_reo_tcl_ring_base_lsb
178 
179 /* REO2TCL R2 ring pointer (head/tail) address */
180 #define HAL_REO_TCL_RING_HP(ab)			ab->hw_params.regs->hal_reo_tcl_ring_hp
181 
182 /* REO CMD R0 address */
183 #define HAL_REO_CMD_RING_BASE_LSB		0x00000194
184 
185 /* REO CMD R2 address */
186 #define HAL_REO_CMD_HP				0x00003020
187 
188 /* SW2REO R0 address */
189 #define HAL_SW2REO_RING_BASE_LSB		0x000001ec
190 
191 /* SW2REO R2 address */
192 #define HAL_SW2REO_RING_HP			0x00003028
193 
194 /* CE ring R0 address */
195 #define HAL_CE_DST_RING_BASE_LSB		0x00000000
196 #define HAL_CE_DST_STATUS_RING_BASE_LSB		0x00000058
197 #define HAL_CE_DST_RING_CTRL			0x000000b0
198 
199 /* CE ring R2 address */
200 #define HAL_CE_DST_RING_HP			0x00000400
201 #define HAL_CE_DST_STATUS_RING_HP		0x00000408
202 
203 /* REO status address */
204 #define HAL_REO_STATUS_RING_BASE_LSB(ab) \
205 	ab->hw_params.regs->hal_reo_status_ring_base_lsb
206 #define HAL_REO_STATUS_HP(ab)			ab->hw_params.regs->hal_reo_status_hp
207 
208 /* WBM Idle R0 address */
209 #define HAL_WBM_IDLE_LINK_RING_BASE_LSB(x) \
210 		(ab->hw_params.regs->hal_wbm_idle_link_ring_base_lsb)
211 #define HAL_WBM_IDLE_LINK_RING_MISC_ADDR(x) \
212 		(ab->hw_params.regs->hal_wbm_idle_link_ring_misc)
213 #define HAL_WBM_R0_IDLE_LIST_CONTROL_ADDR	0x00000048
214 #define HAL_WBM_R0_IDLE_LIST_SIZE_ADDR		0x0000004c
215 #define HAL_WBM_SCATTERED_RING_BASE_LSB		0x00000058
216 #define HAL_WBM_SCATTERED_RING_BASE_MSB		0x0000005c
217 #define HAL_WBM_SCATTERED_DESC_PTR_HEAD_INFO_IX0 0x00000068
218 #define HAL_WBM_SCATTERED_DESC_PTR_HEAD_INFO_IX1 0x0000006c
219 #define HAL_WBM_SCATTERED_DESC_PTR_TAIL_INFO_IX0 0x00000078
220 #define HAL_WBM_SCATTERED_DESC_PTR_TAIL_INFO_IX1 0x0000007c
221 #define HAL_WBM_SCATTERED_DESC_PTR_HP_ADDR	 0x00000084
222 
223 /* WBM Idle R2 address */
224 #define HAL_WBM_IDLE_LINK_RING_HP		0x000030b0
225 
226 /* SW2WBM R0 release address */
227 #define HAL_WBM_RELEASE_RING_BASE_LSB(x) \
228 		(ab->hw_params.regs->hal_wbm_release_ring_base_lsb)
229 
230 /* SW2WBM R2 release address */
231 #define HAL_WBM_RELEASE_RING_HP			0x00003018
232 
233 /* WBM2SW R0 release address */
234 #define HAL_WBM0_RELEASE_RING_BASE_LSB(x) \
235 		(ab->hw_params.regs->hal_wbm0_release_ring_base_lsb)
236 #define HAL_WBM1_RELEASE_RING_BASE_LSB(x) \
237 		(ab->hw_params.regs->hal_wbm1_release_ring_base_lsb)
238 
239 /* WBM2SW R2 release address */
240 #define HAL_WBM0_RELEASE_RING_HP		0x000030c0
241 #define HAL_WBM1_RELEASE_RING_HP		0x000030c8
242 
243 /* TCL ring feild mask and offset */
244 #define HAL_TCL1_RING_BASE_MSB_RING_SIZE		GENMASK(27, 8)
245 #define HAL_TCL1_RING_BASE_MSB_RING_BASE_ADDR_MSB	GENMASK(7, 0)
246 #define HAL_TCL1_RING_ID_ENTRY_SIZE			GENMASK(7, 0)
247 #define HAL_TCL1_RING_MISC_MSI_LOOPCNT_DISABLE		BIT(1)
248 #define HAL_TCL1_RING_MISC_MSI_SWAP			BIT(3)
249 #define HAL_TCL1_RING_MISC_HOST_FW_SWAP			BIT(4)
250 #define HAL_TCL1_RING_MISC_DATA_TLV_SWAP		BIT(5)
251 #define HAL_TCL1_RING_MISC_SRNG_ENABLE			BIT(6)
252 #define HAL_TCL1_RING_CONSR_INT_SETUP_IX0_INTR_TMR_THOLD   GENMASK(31, 16)
253 #define HAL_TCL1_RING_CONSR_INT_SETUP_IX0_BATCH_COUNTER_THOLD GENMASK(14, 0)
254 #define HAL_TCL1_RING_CONSR_INT_SETUP_IX1_LOW_THOLD	GENMASK(15, 0)
255 #define HAL_TCL1_RING_MSI1_BASE_MSB_MSI1_ENABLE		BIT(8)
256 #define HAL_TCL1_RING_MSI1_BASE_MSB_ADDR		GENMASK(7, 0)
257 #define HAL_TCL1_RING_CMN_CTRL_DSCP_TID_MAP_PROG_EN	BIT(17)
258 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP		GENMASK(31, 0)
259 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP0		GENMASK(2, 0)
260 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP1		GENMASK(5, 3)
261 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP2		GENMASK(8, 6)
262 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP3		GENMASK(11, 9)
263 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP4		GENMASK(14, 12)
264 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP5		GENMASK(17, 15)
265 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP6		GENMASK(20, 18)
266 #define HAL_TCL1_RING_FIELD_DSCP_TID_MAP7		GENMASK(23, 21)
267 
268 /* REO ring feild mask and offset */
269 #define HAL_REO1_RING_BASE_MSB_RING_SIZE		GENMASK(27, 8)
270 #define HAL_REO1_RING_BASE_MSB_RING_BASE_ADDR_MSB	GENMASK(7, 0)
271 #define HAL_REO1_RING_ID_RING_ID			GENMASK(15, 8)
272 #define HAL_REO1_RING_ID_ENTRY_SIZE			GENMASK(7, 0)
273 #define HAL_REO1_RING_MISC_MSI_SWAP			BIT(3)
274 #define HAL_REO1_RING_MISC_HOST_FW_SWAP			BIT(4)
275 #define HAL_REO1_RING_MISC_DATA_TLV_SWAP		BIT(5)
276 #define HAL_REO1_RING_MISC_SRNG_ENABLE			BIT(6)
277 #define HAL_REO1_RING_PRDR_INT_SETUP_INTR_TMR_THOLD	GENMASK(31, 16)
278 #define HAL_REO1_RING_PRDR_INT_SETUP_BATCH_COUNTER_THOLD GENMASK(14, 0)
279 #define HAL_REO1_RING_MSI1_BASE_MSB_MSI1_ENABLE		BIT(8)
280 #define HAL_REO1_RING_MSI1_BASE_MSB_ADDR		GENMASK(7, 0)
281 #define HAL_REO1_GEN_ENABLE_FRAG_DST_RING		GENMASK(25, 23)
282 #define HAL_REO1_GEN_ENABLE_AGING_LIST_ENABLE		BIT(2)
283 #define HAL_REO1_GEN_ENABLE_AGING_FLUSH_ENABLE		BIT(3)
284 #define HAL_REO1_MISC_CTL_FRAGMENT_DST_RING		GENMASK(20, 17)
285 
286 /* CE ring bit field mask and shift */
287 #define HAL_CE_DST_R0_DEST_CTRL_MAX_LEN			GENMASK(15, 0)
288 
289 #define HAL_ADDR_LSB_REG_MASK				0xffffffff
290 
291 #define HAL_ADDR_MSB_REG_SHIFT				32
292 
293 /* WBM ring bit field mask and shift */
294 #define HAL_WBM_LINK_DESC_IDLE_LIST_MODE		BIT(1)
295 #define HAL_WBM_SCATTER_BUFFER_SIZE			GENMASK(10, 2)
296 #define HAL_WBM_SCATTER_RING_SIZE_OF_IDLE_LINK_DESC_LIST GENMASK(31, 16)
297 #define HAL_WBM_SCATTERED_DESC_MSB_BASE_ADDR_39_32	GENMASK(7, 0)
298 #define HAL_WBM_SCATTERED_DESC_MSB_BASE_ADDR_MATCH_TAG	GENMASK(31, 8)
299 
300 #define HAL_WBM_SCATTERED_DESC_HEAD_P_OFFSET_IX1	GENMASK(20, 8)
301 #define HAL_WBM_SCATTERED_DESC_TAIL_P_OFFSET_IX1	GENMASK(20, 8)
302 
303 #define BASE_ADDR_MATCH_TAG_VAL 0x5
304 
305 #define HAL_REO_REO2SW1_RING_BASE_MSB_RING_SIZE		0x000fffff
306 #define HAL_REO_REO2TCL_RING_BASE_MSB_RING_SIZE		0x000fffff
307 #define HAL_REO_SW2REO_RING_BASE_MSB_RING_SIZE		0x0000ffff
308 #define HAL_REO_CMD_RING_BASE_MSB_RING_SIZE		0x0000ffff
309 #define HAL_REO_STATUS_RING_BASE_MSB_RING_SIZE		0x0000ffff
310 #define HAL_SW2TCL1_RING_BASE_MSB_RING_SIZE		0x000fffff
311 #define HAL_SW2TCL1_CMD_RING_BASE_MSB_RING_SIZE		0x000fffff
312 #define HAL_TCL_STATUS_RING_BASE_MSB_RING_SIZE		0x0000ffff
313 #define HAL_CE_SRC_RING_BASE_MSB_RING_SIZE		0x0000ffff
314 #define HAL_CE_DST_RING_BASE_MSB_RING_SIZE		0x0000ffff
315 #define HAL_CE_DST_STATUS_RING_BASE_MSB_RING_SIZE	0x0000ffff
316 #define HAL_WBM_IDLE_LINK_RING_BASE_MSB_RING_SIZE	0x0000ffff
317 #define HAL_SW2WBM_RELEASE_RING_BASE_MSB_RING_SIZE	0x0000ffff
318 #define HAL_WBM2SW_RELEASE_RING_BASE_MSB_RING_SIZE	0x000fffff
319 #define HAL_RXDMA_RING_MAX_SIZE				0x0000ffff
320 
321 /* Add any other errors here and return them in
322  * ath11k_hal_rx_desc_get_err().
323  */
324 
325 enum hal_srng_ring_id {
326 	HAL_SRNG_RING_ID_REO2SW1 = 0,
327 	HAL_SRNG_RING_ID_REO2SW2,
328 	HAL_SRNG_RING_ID_REO2SW3,
329 	HAL_SRNG_RING_ID_REO2SW4,
330 	HAL_SRNG_RING_ID_REO2TCL,
331 	HAL_SRNG_RING_ID_SW2REO,
332 
333 	HAL_SRNG_RING_ID_REO_CMD = 8,
334 	HAL_SRNG_RING_ID_REO_STATUS,
335 
336 	HAL_SRNG_RING_ID_SW2TCL1 = 16,
337 	HAL_SRNG_RING_ID_SW2TCL2,
338 	HAL_SRNG_RING_ID_SW2TCL3,
339 	HAL_SRNG_RING_ID_SW2TCL4,
340 
341 	HAL_SRNG_RING_ID_SW2TCL_CMD = 24,
342 	HAL_SRNG_RING_ID_TCL_STATUS,
343 
344 	HAL_SRNG_RING_ID_CE0_SRC = 32,
345 	HAL_SRNG_RING_ID_CE1_SRC,
346 	HAL_SRNG_RING_ID_CE2_SRC,
347 	HAL_SRNG_RING_ID_CE3_SRC,
348 	HAL_SRNG_RING_ID_CE4_SRC,
349 	HAL_SRNG_RING_ID_CE5_SRC,
350 	HAL_SRNG_RING_ID_CE6_SRC,
351 	HAL_SRNG_RING_ID_CE7_SRC,
352 	HAL_SRNG_RING_ID_CE8_SRC,
353 	HAL_SRNG_RING_ID_CE9_SRC,
354 	HAL_SRNG_RING_ID_CE10_SRC,
355 	HAL_SRNG_RING_ID_CE11_SRC,
356 
357 	HAL_SRNG_RING_ID_CE0_DST = 56,
358 	HAL_SRNG_RING_ID_CE1_DST,
359 	HAL_SRNG_RING_ID_CE2_DST,
360 	HAL_SRNG_RING_ID_CE3_DST,
361 	HAL_SRNG_RING_ID_CE4_DST,
362 	HAL_SRNG_RING_ID_CE5_DST,
363 	HAL_SRNG_RING_ID_CE6_DST,
364 	HAL_SRNG_RING_ID_CE7_DST,
365 	HAL_SRNG_RING_ID_CE8_DST,
366 	HAL_SRNG_RING_ID_CE9_DST,
367 	HAL_SRNG_RING_ID_CE10_DST,
368 	HAL_SRNG_RING_ID_CE11_DST,
369 
370 	HAL_SRNG_RING_ID_CE0_DST_STATUS = 80,
371 	HAL_SRNG_RING_ID_CE1_DST_STATUS,
372 	HAL_SRNG_RING_ID_CE2_DST_STATUS,
373 	HAL_SRNG_RING_ID_CE3_DST_STATUS,
374 	HAL_SRNG_RING_ID_CE4_DST_STATUS,
375 	HAL_SRNG_RING_ID_CE5_DST_STATUS,
376 	HAL_SRNG_RING_ID_CE6_DST_STATUS,
377 	HAL_SRNG_RING_ID_CE7_DST_STATUS,
378 	HAL_SRNG_RING_ID_CE8_DST_STATUS,
379 	HAL_SRNG_RING_ID_CE9_DST_STATUS,
380 	HAL_SRNG_RING_ID_CE10_DST_STATUS,
381 	HAL_SRNG_RING_ID_CE11_DST_STATUS,
382 
383 	HAL_SRNG_RING_ID_WBM_IDLE_LINK = 104,
384 	HAL_SRNG_RING_ID_WBM_SW_RELEASE,
385 	HAL_SRNG_RING_ID_WBM2SW0_RELEASE,
386 	HAL_SRNG_RING_ID_WBM2SW1_RELEASE,
387 	HAL_SRNG_RING_ID_WBM2SW2_RELEASE,
388 	HAL_SRNG_RING_ID_WBM2SW3_RELEASE,
389 
390 	HAL_SRNG_RING_ID_UMAC_ID_END = 127,
391 	HAL_SRNG_RING_ID_LMAC1_ID_START,
392 
393 	HAL_SRNG_RING_ID_WMAC1_SW2RXDMA0_BUF = HAL_SRNG_RING_ID_LMAC1_ID_START,
394 	HAL_SRNG_RING_ID_WMAC1_SW2RXDMA1_BUF,
395 	HAL_SRNG_RING_ID_WMAC1_SW2RXDMA2_BUF,
396 	HAL_SRNG_RING_ID_WMAC1_SW2RXDMA0_STATBUF,
397 	HAL_SRNG_RING_ID_WMAC1_SW2RXDMA1_STATBUF,
398 	HAL_SRNG_RING_ID_WMAC1_RXDMA2SW0,
399 	HAL_SRNG_RING_ID_WMAC1_RXDMA2SW1,
400 	HAL_SRNG_RING_ID_WMAC1_SW2RXDMA1_DESC,
401 	HAL_SRNG_RING_ID_RXDMA_DIR_BUF,
402 
403 	HAL_SRNG_RING_ID_LMAC1_ID_END = 143
404 };
405 
406 /* SRNG registers are split into two groups R0 and R2 */
407 #define HAL_SRNG_REG_GRP_R0	0
408 #define HAL_SRNG_REG_GRP_R2	1
409 #define HAL_SRNG_NUM_REG_GRP    2
410 
411 #define HAL_SRNG_NUM_LMACS      3
412 #define HAL_SRNG_REO_EXCEPTION  HAL_SRNG_RING_ID_REO2SW1
413 #define HAL_SRNG_RINGS_PER_LMAC (HAL_SRNG_RING_ID_LMAC1_ID_END - \
414 				 HAL_SRNG_RING_ID_LMAC1_ID_START)
415 #define HAL_SRNG_NUM_LMAC_RINGS (HAL_SRNG_NUM_LMACS * HAL_SRNG_RINGS_PER_LMAC)
416 #define HAL_SRNG_RING_ID_MAX    (HAL_SRNG_RING_ID_UMAC_ID_END + \
417 				 HAL_SRNG_NUM_LMAC_RINGS)
418 
419 enum hal_ring_type {
420 	HAL_REO_DST,
421 	HAL_REO_EXCEPTION,
422 	HAL_REO_REINJECT,
423 	HAL_REO_CMD,
424 	HAL_REO_STATUS,
425 	HAL_TCL_DATA,
426 	HAL_TCL_CMD,
427 	HAL_TCL_STATUS,
428 	HAL_CE_SRC,
429 	HAL_CE_DST,
430 	HAL_CE_DST_STATUS,
431 	HAL_WBM_IDLE_LINK,
432 	HAL_SW2WBM_RELEASE,
433 	HAL_WBM2SW_RELEASE,
434 	HAL_RXDMA_BUF,
435 	HAL_RXDMA_DST,
436 	HAL_RXDMA_MONITOR_BUF,
437 	HAL_RXDMA_MONITOR_STATUS,
438 	HAL_RXDMA_MONITOR_DST,
439 	HAL_RXDMA_MONITOR_DESC,
440 	HAL_RXDMA_DIR_BUF,
441 	HAL_MAX_RING_TYPES,
442 };
443 
444 #define HAL_RX_MAX_BA_WINDOW	256
445 
446 #define HAL_DEFAULT_REO_TIMEOUT_USEC		(40 * 1000)
447 
448 /**
449  * enum hal_reo_cmd_type: Enum for REO command type
450  * @CMD_GET_QUEUE_STATS: Get REO queue status/stats
451  * @CMD_FLUSH_QUEUE: Flush all frames in REO queue
452  * @CMD_FLUSH_CACHE: Flush descriptor entries in the cache
453  * @CMD_UNBLOCK_CACHE: Unblock a descriptor's address that was blocked
454  *      earlier with a 'REO_FLUSH_CACHE' command
455  * @CMD_FLUSH_TIMEOUT_LIST: Flush buffers/descriptors from timeout list
456  * @CMD_UPDATE_RX_REO_QUEUE: Update REO queue settings
457  */
458 enum hal_reo_cmd_type {
459 	HAL_REO_CMD_GET_QUEUE_STATS     = 0,
460 	HAL_REO_CMD_FLUSH_QUEUE         = 1,
461 	HAL_REO_CMD_FLUSH_CACHE         = 2,
462 	HAL_REO_CMD_UNBLOCK_CACHE       = 3,
463 	HAL_REO_CMD_FLUSH_TIMEOUT_LIST  = 4,
464 	HAL_REO_CMD_UPDATE_RX_QUEUE     = 5,
465 };
466 
467 /**
468  * enum hal_reo_cmd_status: Enum for execution status of REO command
469  * @HAL_REO_CMD_SUCCESS: Command has successfully executed
470  * @HAL_REO_CMD_BLOCKED: Command could not be executed as the queue
471  *			 or cache was blocked
472  * @HAL_REO_CMD_FAILED: Command execution failed, could be due to
473  *			invalid queue desc
474  * @HAL_REO_CMD_RESOURCE_BLOCKED:
475  * @HAL_REO_CMD_DRAIN:
476  */
477 enum hal_reo_cmd_status {
478 	HAL_REO_CMD_SUCCESS		= 0,
479 	HAL_REO_CMD_BLOCKED		= 1,
480 	HAL_REO_CMD_FAILED		= 2,
481 	HAL_REO_CMD_RESOURCE_BLOCKED	= 3,
482 	HAL_REO_CMD_DRAIN		= 0xff,
483 };
484 
485 struct hal_wbm_idle_scatter_list {
486 	dma_addr_t paddr;
487 	struct hal_wbm_link_desc *vaddr;
488 };
489 
490 struct hal_srng_params {
491 	dma_addr_t ring_base_paddr;
492 	u32 *ring_base_vaddr;
493 	int num_entries;
494 	u32 intr_batch_cntr_thres_entries;
495 	u32 intr_timer_thres_us;
496 	u32 flags;
497 	u32 max_buffer_len;
498 	u32 low_threshold;
499 	dma_addr_t msi_addr;
500 	u32 msi_data;
501 
502 	/* Add more params as needed */
503 };
504 
505 enum hal_srng_dir {
506 	HAL_SRNG_DIR_SRC,
507 	HAL_SRNG_DIR_DST
508 };
509 
510 /* srng flags */
511 #define HAL_SRNG_FLAGS_MSI_SWAP			0x00000008
512 #define HAL_SRNG_FLAGS_RING_PTR_SWAP		0x00000010
513 #define HAL_SRNG_FLAGS_DATA_TLV_SWAP		0x00000020
514 #define HAL_SRNG_FLAGS_LOW_THRESH_INTR_EN	0x00010000
515 #define HAL_SRNG_FLAGS_MSI_INTR			0x00020000
516 #define HAL_SRNG_FLAGS_LMAC_RING		0x80000000
517 
518 #define HAL_SRNG_TLV_HDR_TAG		GENMASK(9, 1)
519 #define HAL_SRNG_TLV_HDR_LEN		GENMASK(25, 10)
520 
521 /* Common SRNG ring structure for source and destination rings */
522 struct hal_srng {
523 	/* Unique SRNG ring ID */
524 	u8 ring_id;
525 
526 	/* Ring initialization done */
527 	u8 initialized;
528 
529 	/* Interrupt/MSI value assigned to this ring */
530 	int irq;
531 
532 	/* Physical base address of the ring */
533 	dma_addr_t ring_base_paddr;
534 
535 	/* Virtual base address of the ring */
536 	u32 *ring_base_vaddr;
537 
538 	/* Number of entries in ring */
539 	u32 num_entries;
540 
541 	/* Ring size */
542 	u32 ring_size;
543 
544 	/* Ring size mask */
545 	u32 ring_size_mask;
546 
547 	/* Size of ring entry */
548 	u32 entry_size;
549 
550 	/* Interrupt timer threshold - in micro seconds */
551 	u32 intr_timer_thres_us;
552 
553 	/* Interrupt batch counter threshold - in number of ring entries */
554 	u32 intr_batch_cntr_thres_entries;
555 
556 	/* MSI Address */
557 	dma_addr_t msi_addr;
558 
559 	/* MSI data */
560 	u32 msi_data;
561 
562 	/* Misc flags */
563 	u32 flags;
564 
565 	/* Lock for serializing ring index updates */
566 	spinlock_t lock;
567 
568 	/* Start offset of SRNG register groups for this ring
569 	 * TBD: See if this is required - register address can be derived
570 	 * from ring ID
571 	 */
572 	u32 hwreg_base[HAL_SRNG_NUM_REG_GRP];
573 
574 	u64 timestamp;
575 
576 	/* Source or Destination ring */
577 	enum hal_srng_dir ring_dir;
578 
579 	union {
580 		struct {
581 			/* SW tail pointer */
582 			u32 tp;
583 
584 			/* Shadow head pointer location to be updated by HW */
585 			volatile u32 *hp_addr;
586 
587 			/* Cached head pointer */
588 			u32 cached_hp;
589 
590 			/* Tail pointer location to be updated by SW - This
591 			 * will be a register address and need not be
592 			 * accessed through SW structure
593 			 */
594 			u32 *tp_addr;
595 
596 			/* Current SW loop cnt */
597 			u32 loop_cnt;
598 
599 			/* max transfer size */
600 			u16 max_buffer_length;
601 
602 			/* head pointer at access end */
603 			u32 last_hp;
604 		} dst_ring;
605 
606 		struct {
607 			/* SW head pointer */
608 			u32 hp;
609 
610 			/* SW reap head pointer */
611 			u32 reap_hp;
612 
613 			/* Shadow tail pointer location to be updated by HW */
614 			u32 *tp_addr;
615 
616 			/* Cached tail pointer */
617 			u32 cached_tp;
618 
619 			/* Head pointer location to be updated by SW - This
620 			 * will be a register address and need not be accessed
621 			 * through SW structure
622 			 */
623 			u32 *hp_addr;
624 
625 			/* Low threshold - in number of ring entries */
626 			u32 low_threshold;
627 
628 			/* tail pointer at access end */
629 			u32 last_tp;
630 		} src_ring;
631 	} u;
632 };
633 
634 /* Interrupt mitigation - Batch threshold in terms of numer of frames */
635 #define HAL_SRNG_INT_BATCH_THRESHOLD_TX 256
636 #define HAL_SRNG_INT_BATCH_THRESHOLD_RX 128
637 #define HAL_SRNG_INT_BATCH_THRESHOLD_OTHER 1
638 
639 /* Interrupt mitigation - timer threshold in us */
640 #define HAL_SRNG_INT_TIMER_THRESHOLD_TX 1000
641 #define HAL_SRNG_INT_TIMER_THRESHOLD_RX 500
642 #define HAL_SRNG_INT_TIMER_THRESHOLD_OTHER 256
643 
644 /* HW SRNG configuration table */
645 struct hal_srng_config {
646 	int start_ring_id;
647 	u16 max_rings;
648 	u16 entry_size;
649 	u32 reg_start[HAL_SRNG_NUM_REG_GRP];
650 	u16 reg_size[HAL_SRNG_NUM_REG_GRP];
651 	u8 lmac_ring;
652 	enum hal_srng_dir ring_dir;
653 	u32 max_size;
654 };
655 
656 /**
657  * enum hal_rx_buf_return_buf_manager
658  *
659  * @HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST: Buffer returned to WBM idle buffer list
660  * @HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST: Descriptor returned to WBM idle
661  *	descriptor list.
662  * @HAL_RX_BUF_RBM_FW_BM: Buffer returned to FW
663  * @HAL_RX_BUF_RBM_SW0_BM: For Tx completion -- returned to host
664  * @HAL_RX_BUF_RBM_SW1_BM: For Tx completion -- returned to host
665  * @HAL_RX_BUF_RBM_SW2_BM: For Tx completion -- returned to host
666  * @HAL_RX_BUF_RBM_SW3_BM: For Rx release -- returned to host
667  */
668 
669 enum hal_rx_buf_return_buf_manager {
670 	HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST,
671 	HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST,
672 	HAL_RX_BUF_RBM_FW_BM,
673 	HAL_RX_BUF_RBM_SW0_BM,
674 	HAL_RX_BUF_RBM_SW1_BM,
675 	HAL_RX_BUF_RBM_SW2_BM,
676 	HAL_RX_BUF_RBM_SW3_BM,
677 };
678 
679 #define HAL_SRNG_DESC_LOOP_CNT		0xf0000000
680 
681 #define HAL_REO_CMD_FLG_NEED_STATUS		BIT(0)
682 #define HAL_REO_CMD_FLG_STATS_CLEAR		BIT(1)
683 #define HAL_REO_CMD_FLG_FLUSH_BLOCK_LATER	BIT(2)
684 #define HAL_REO_CMD_FLG_FLUSH_RELEASE_BLOCKING	BIT(3)
685 #define HAL_REO_CMD_FLG_FLUSH_NO_INVAL		BIT(4)
686 #define HAL_REO_CMD_FLG_FLUSH_FWD_ALL_MPDUS	BIT(5)
687 #define HAL_REO_CMD_FLG_FLUSH_ALL		BIT(6)
688 #define HAL_REO_CMD_FLG_UNBLK_RESOURCE		BIT(7)
689 #define HAL_REO_CMD_FLG_UNBLK_CACHE		BIT(8)
690 
691 /* Should be matching with HAL_REO_UPD_RX_QUEUE_INFO0_UPD_* feilds */
692 #define HAL_REO_CMD_UPD0_RX_QUEUE_NUM		BIT(8)
693 #define HAL_REO_CMD_UPD0_VLD			BIT(9)
694 #define HAL_REO_CMD_UPD0_ALDC			BIT(10)
695 #define HAL_REO_CMD_UPD0_DIS_DUP_DETECTION	BIT(11)
696 #define HAL_REO_CMD_UPD0_SOFT_REORDER_EN	BIT(12)
697 #define HAL_REO_CMD_UPD0_AC			BIT(13)
698 #define HAL_REO_CMD_UPD0_BAR			BIT(14)
699 #define HAL_REO_CMD_UPD0_RETRY			BIT(15)
700 #define HAL_REO_CMD_UPD0_CHECK_2K_MODE		BIT(16)
701 #define HAL_REO_CMD_UPD0_OOR_MODE		BIT(17)
702 #define HAL_REO_CMD_UPD0_BA_WINDOW_SIZE		BIT(18)
703 #define HAL_REO_CMD_UPD0_PN_CHECK		BIT(19)
704 #define HAL_REO_CMD_UPD0_EVEN_PN		BIT(20)
705 #define HAL_REO_CMD_UPD0_UNEVEN_PN		BIT(21)
706 #define HAL_REO_CMD_UPD0_PN_HANDLE_ENABLE	BIT(22)
707 #define HAL_REO_CMD_UPD0_PN_SIZE		BIT(23)
708 #define HAL_REO_CMD_UPD0_IGNORE_AMPDU_FLG	BIT(24)
709 #define HAL_REO_CMD_UPD0_SVLD			BIT(25)
710 #define HAL_REO_CMD_UPD0_SSN			BIT(26)
711 #define HAL_REO_CMD_UPD0_SEQ_2K_ERR		BIT(27)
712 #define HAL_REO_CMD_UPD0_PN_ERR			BIT(28)
713 #define HAL_REO_CMD_UPD0_PN_VALID		BIT(29)
714 #define HAL_REO_CMD_UPD0_PN			BIT(30)
715 
716 /* Should be matching with HAL_REO_UPD_RX_QUEUE_INFO1_* feilds */
717 #define HAL_REO_CMD_UPD1_VLD			BIT(16)
718 #define HAL_REO_CMD_UPD1_ALDC			GENMASK(18, 17)
719 #define HAL_REO_CMD_UPD1_DIS_DUP_DETECTION	BIT(19)
720 #define HAL_REO_CMD_UPD1_SOFT_REORDER_EN	BIT(20)
721 #define HAL_REO_CMD_UPD1_AC			GENMASK(22, 21)
722 #define HAL_REO_CMD_UPD1_BAR			BIT(23)
723 #define HAL_REO_CMD_UPD1_RETRY			BIT(24)
724 #define HAL_REO_CMD_UPD1_CHECK_2K_MODE		BIT(25)
725 #define HAL_REO_CMD_UPD1_OOR_MODE		BIT(26)
726 #define HAL_REO_CMD_UPD1_PN_CHECK		BIT(27)
727 #define HAL_REO_CMD_UPD1_EVEN_PN		BIT(28)
728 #define HAL_REO_CMD_UPD1_UNEVEN_PN		BIT(29)
729 #define HAL_REO_CMD_UPD1_PN_HANDLE_ENABLE	BIT(30)
730 #define HAL_REO_CMD_UPD1_IGNORE_AMPDU_FLG	BIT(31)
731 
732 /* Should be matching with HAL_REO_UPD_RX_QUEUE_INFO2_* feilds */
733 #define HAL_REO_CMD_UPD2_SVLD			BIT(10)
734 #define HAL_REO_CMD_UPD2_SSN			GENMASK(22, 11)
735 #define HAL_REO_CMD_UPD2_SEQ_2K_ERR		BIT(23)
736 #define HAL_REO_CMD_UPD2_PN_ERR			BIT(24)
737 
738 #define HAL_REO_DEST_RING_CTRL_HASH_RING_MAP	GENMASK(31, 8)
739 
740 struct ath11k_hal_reo_cmd {
741 	u32 addr_lo;
742 	u32 flag;
743 	u32 upd0;
744 	u32 upd1;
745 	u32 upd2;
746 	u32 pn[4];
747 	u16 rx_queue_num;
748 	u16 min_rel;
749 	u16 min_fwd;
750 	u8 addr_hi;
751 	u8 ac_list;
752 	u8 blocking_idx;
753 	u16 ba_window_size;
754 	u8 pn_size;
755 };
756 
757 enum hal_pn_type {
758 	HAL_PN_TYPE_NONE,
759 	HAL_PN_TYPE_WPA,
760 	HAL_PN_TYPE_WAPI_EVEN,
761 	HAL_PN_TYPE_WAPI_UNEVEN,
762 };
763 
764 enum hal_ce_desc {
765 	HAL_CE_DESC_SRC,
766 	HAL_CE_DESC_DST,
767 	HAL_CE_DESC_DST_STATUS,
768 };
769 
770 #define HAL_HASH_ROUTING_RING_TCL 0
771 #define HAL_HASH_ROUTING_RING_SW1 1
772 #define HAL_HASH_ROUTING_RING_SW2 2
773 #define HAL_HASH_ROUTING_RING_SW3 3
774 #define HAL_HASH_ROUTING_RING_SW4 4
775 #define HAL_HASH_ROUTING_RING_REL 5
776 #define HAL_HASH_ROUTING_RING_FW  6
777 
778 struct hal_reo_status_header {
779 	u16 cmd_num;
780 	enum hal_reo_cmd_status cmd_status;
781 	u16 cmd_exe_time;
782 	u32 timestamp;
783 };
784 
785 struct hal_reo_status_queue_stats {
786 	u16 ssn;
787 	u16 curr_idx;
788 	u32 pn[4];
789 	u32 last_rx_queue_ts;
790 	u32 last_rx_dequeue_ts;
791 	u32 rx_bitmap[8]; /* Bitmap from 0-255 */
792 	u32 curr_mpdu_cnt;
793 	u32 curr_msdu_cnt;
794 	u16 fwd_due_to_bar_cnt;
795 	u16 dup_cnt;
796 	u32 frames_in_order_cnt;
797 	u32 num_mpdu_processed_cnt;
798 	u32 num_msdu_processed_cnt;
799 	u32 total_num_processed_byte_cnt;
800 	u32 late_rx_mpdu_cnt;
801 	u32 reorder_hole_cnt;
802 	u8 timeout_cnt;
803 	u8 bar_rx_cnt;
804 	u8 num_window_2k_jump_cnt;
805 };
806 
807 struct hal_reo_status_flush_queue {
808 	bool err_detected;
809 };
810 
811 enum hal_reo_status_flush_cache_err_code {
812 	HAL_REO_STATUS_FLUSH_CACHE_ERR_CODE_SUCCESS,
813 	HAL_REO_STATUS_FLUSH_CACHE_ERR_CODE_IN_USE,
814 	HAL_REO_STATUS_FLUSH_CACHE_ERR_CODE_NOT_FOUND,
815 };
816 
817 struct hal_reo_status_flush_cache {
818 	bool err_detected;
819 	enum hal_reo_status_flush_cache_err_code err_code;
820 	bool cache_controller_flush_status_hit;
821 	u8 cache_controller_flush_status_desc_type;
822 	u8 cache_controller_flush_status_client_id;
823 	u8 cache_controller_flush_status_err;
824 	u8 cache_controller_flush_status_cnt;
825 };
826 
827 enum hal_reo_status_unblock_cache_type {
828 	HAL_REO_STATUS_UNBLOCK_BLOCKING_RESOURCE,
829 	HAL_REO_STATUS_UNBLOCK_ENTIRE_CACHE_USAGE,
830 };
831 
832 struct hal_reo_status_unblock_cache {
833 	bool err_detected;
834 	enum hal_reo_status_unblock_cache_type unblock_type;
835 };
836 
837 struct hal_reo_status_flush_timeout_list {
838 	bool err_detected;
839 	bool list_empty;
840 	u16 release_desc_cnt;
841 	u16 fwd_buf_cnt;
842 };
843 
844 enum hal_reo_threshold_idx {
845 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER0,
846 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER1,
847 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER2,
848 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER_SUM,
849 };
850 
851 struct hal_reo_status_desc_thresh_reached {
852 	enum hal_reo_threshold_idx threshold_idx;
853 	u32 link_desc_counter0;
854 	u32 link_desc_counter1;
855 	u32 link_desc_counter2;
856 	u32 link_desc_counter_sum;
857 };
858 
859 struct hal_reo_status {
860 	struct hal_reo_status_header uniform_hdr;
861 	u8 loop_cnt;
862 	union {
863 		struct hal_reo_status_queue_stats queue_stats;
864 		struct hal_reo_status_flush_queue flush_queue;
865 		struct hal_reo_status_flush_cache flush_cache;
866 		struct hal_reo_status_unblock_cache unblock_cache;
867 		struct hal_reo_status_flush_timeout_list timeout_list;
868 		struct hal_reo_status_desc_thresh_reached desc_thresh_reached;
869 	} u;
870 };
871 
872 /**
873  * HAL context to be used to access SRNG APIs (currently used by data path
874  * and transport (CE) modules)
875  */
876 struct ath11k_hal {
877 	/* HAL internal state for all SRNG rings.
878 	 */
879 	struct hal_srng srng_list[HAL_SRNG_RING_ID_MAX];
880 
881 	/* SRNG configuration table */
882 	struct hal_srng_config *srng_config;
883 
884 	/* Remote pointer memory for HW/FW updates */
885 	struct {
886 		u32 *vaddr;
887 		dma_addr_t paddr;
888 	} rdp;
889 
890 	/* Shared memory for ring pointer updates from host to FW */
891 	struct {
892 		u32 *vaddr;
893 		dma_addr_t paddr;
894 	} wrp;
895 
896 	/* Available REO blocking resources bitmap */
897 	u8 avail_blk_resource;
898 
899 	u8 current_blk_index;
900 
901 	/* shadow register configuration */
902 	u32 shadow_reg_addr[HAL_SHADOW_NUM_REGS];
903 	int num_shadow_reg_configured;
904 };
905 
906 u32 ath11k_hal_reo_qdesc_size(u32 ba_window_size, u8 tid);
907 void ath11k_hal_reo_qdesc_setup(void *vaddr, int tid, u32 ba_window_size,
908 				u32 start_seq, enum hal_pn_type type);
909 void ath11k_hal_reo_init_cmd_ring(struct ath11k_base *ab,
910 				  struct hal_srng *srng);
911 void ath11k_hal_setup_link_idle_list(struct ath11k_base *ab,
912 				     struct hal_wbm_idle_scatter_list *sbuf,
913 				     u32 nsbufs, u32 tot_link_desc,
914 				     u32 end_offset);
915 
916 dma_addr_t ath11k_hal_srng_get_tp_addr(struct ath11k_base *ab,
917 				       struct hal_srng *srng);
918 dma_addr_t ath11k_hal_srng_get_hp_addr(struct ath11k_base *ab,
919 				       struct hal_srng *srng);
920 void ath11k_hal_set_link_desc_addr(struct hal_wbm_link_desc *desc, u32 cookie,
921 				   dma_addr_t paddr);
922 u32 ath11k_hal_ce_get_desc_size(enum hal_ce_desc type);
923 void ath11k_hal_ce_src_set_desc(void *buf, dma_addr_t paddr, u32 len, u32 id,
924 				u8 byte_swap_data);
925 void ath11k_hal_ce_dst_set_desc(void *buf, dma_addr_t paddr);
926 u32 ath11k_hal_ce_dst_status_get_length(void *buf);
927 int ath11k_hal_srng_get_entrysize(struct ath11k_base *ab, u32 ring_type);
928 int ath11k_hal_srng_get_max_entries(struct ath11k_base *ab, u32 ring_type);
929 void ath11k_hal_srng_get_params(struct ath11k_base *ab, struct hal_srng *srng,
930 				struct hal_srng_params *params);
931 u32 *ath11k_hal_srng_dst_get_next_entry(struct ath11k_base *ab,
932 					struct hal_srng *srng);
933 u32 *ath11k_hal_srng_dst_peek(struct ath11k_base *ab, struct hal_srng *srng);
934 int ath11k_hal_srng_dst_num_free(struct ath11k_base *ab, struct hal_srng *srng,
935 				 bool sync_hw_ptr);
936 u32 *ath11k_hal_srng_src_peek(struct ath11k_base *ab, struct hal_srng *srng);
937 u32 *ath11k_hal_srng_src_get_next_reaped(struct ath11k_base *ab,
938 					 struct hal_srng *srng);
939 u32 *ath11k_hal_srng_src_reap_next(struct ath11k_base *ab,
940 				   struct hal_srng *srng);
941 u32 *ath11k_hal_srng_src_get_next_entry(struct ath11k_base *ab,
942 					struct hal_srng *srng);
943 int ath11k_hal_srng_src_num_free(struct ath11k_base *ab, struct hal_srng *srng,
944 				 bool sync_hw_ptr);
945 void ath11k_hal_srng_access_begin(struct ath11k_base *ab,
946 				  struct hal_srng *srng);
947 void ath11k_hal_srng_access_end(struct ath11k_base *ab, struct hal_srng *srng);
948 int ath11k_hal_srng_setup(struct ath11k_base *ab, enum hal_ring_type type,
949 			  int ring_num, int mac_id,
950 			  struct hal_srng_params *params);
951 int ath11k_hal_srng_init(struct ath11k_base *ath11k);
952 void ath11k_hal_srng_deinit(struct ath11k_base *ath11k);
953 void ath11k_hal_dump_srng_stats(struct ath11k_base *ab);
954 void ath11k_hal_srng_get_shadow_config(struct ath11k_base *ab,
955 				       u32 **cfg, u32 *len);
956 int ath11k_hal_srng_update_shadow_config(struct ath11k_base *ab,
957 					 enum hal_ring_type ring_type,
958 					int ring_num);
959 void ath11k_hal_srng_shadow_config(struct ath11k_base *ab);
960 void ath11k_hal_srng_shadow_update_hp_tp(struct ath11k_base *ab,
961 					 struct hal_srng *srng);
962 #endif
963