xref: /wlan-dirver/qca-wifi-host-cmn/hal/wifi3.0/hal_internal.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _HAL_INTERNAL_H_
21 #define _HAL_INTERNAL_H_
22 
23 #include "qdf_types.h"
24 #include "qdf_atomic.h"
25 #include "qdf_lock.h"
26 #include "qdf_mem.h"
27 #include "qdf_nbuf.h"
28 #include "pld_common.h"
29 #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
30 #include "qdf_defer.h"
31 #include "qdf_timer.h"
32 #endif
33 
34 #define hal_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_HAL, params)
35 #define hal_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_HAL, params)
36 #define hal_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_HAL, params)
37 #define hal_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_HAL, params)
38 #define hal_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params)
39 
40 #define hal_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_HAL, params)
41 #define hal_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_HAL, params)
42 #define hal_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_HAL, params)
43 #define hal_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_HAL, params)
44 #define hal_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_HAL, params)
45 
46 #ifdef ENABLE_VERBOSE_DEBUG
47 extern bool is_hal_verbose_debug_enabled;
48 #define hal_verbose_debug(params...) \
49 	if (unlikely(is_hal_verbose_debug_enabled)) \
50 		do {\
51 			QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params); \
52 		} while (0)
53 #define hal_verbose_hex_dump(params...) \
54 	if (unlikely(is_hal_verbose_debug_enabled)) \
55 		do {\
56 			QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HAL, \
57 					   QDF_TRACE_LEVEL_DEBUG, \
58 					   params); \
59 		} while (0)
60 #else
61 #define hal_verbose_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params)
62 #define hal_verbose_hex_dump(params...) \
63 		QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HAL, QDF_TRACE_LEVEL_DEBUG, \
64 				   params)
65 #endif
66 
67 /*
68  * Given the offset of a field in bytes, returns uint8_t *
69  */
70 #define _OFFSET_TO_BYTE_PTR(_ptr, _off_in_bytes)	\
71 	(((uint8_t *)(_ptr)) + (_off_in_bytes))
72 
73 /*
74  * Given the offset of a field in bytes, returns uint32_t *
75  */
76 #define _OFFSET_TO_WORD_PTR(_ptr, _off_in_bytes)	\
77 	(((uint32_t *)(_ptr)) + ((_off_in_bytes) >> 2))
78 
79 /*
80  * Given the offset of a field in bytes, returns uint64_t *
81  */
82 #define _OFFSET_TO_QWORD_PTR(_ptr, _off_in_bytes)	\
83 	(((uint64_t *)(_ptr)) + ((_off_in_bytes) >> 3))
84 
85 #define _HAL_MS(_word, _mask, _shift)		\
86 	(((_word) & (_mask)) >> (_shift))
87 
88 /*
89  * Get number of QWORDS possible for num.
90  * Its the caller's duty to make sure num is a multiple of QWORD (8)
91  */
92 #define HAL_GET_NUM_QWORDS(num)	((num) >> 3)
93 
94 /*
95  * Get number of DWORDS possible for num.
96  * Its the caller's duty to make sure num is a multiple of DWORD (8)
97  */
98 #define HAL_GET_NUM_DWORDS(num)	((num) >> 2)
99 
100 struct hal_hw_cc_config {
101 	uint32_t lut_base_addr_31_0;
102 	uint32_t cc_global_en:1,
103 		 page_4k_align:1,
104 		 cookie_offset_msb:5,
105 		 cookie_page_msb:5,
106 		 lut_base_addr_39_32:8,
107 		 wbm2sw6_cc_en:1,
108 		 wbm2sw5_cc_en:1,
109 		 wbm2sw4_cc_en:1,
110 		 wbm2sw3_cc_en:1,
111 		 wbm2sw2_cc_en:1,
112 		 wbm2sw1_cc_en:1,
113 		 wbm2sw0_cc_en:1,
114 		 wbm2fw_cc_en:1,
115 		 error_path_cookie_conv_en:1,
116 		 release_path_cookie_conv_en:1,
117 		 reserved:2;
118 };
119 
120 /*
121  * dp_hal_soc - opaque handle for DP HAL soc
122  */
123 struct hal_soc_handle;
124 typedef struct hal_soc_handle *hal_soc_handle_t;
125 
126 /**
127  * hal_ring_desc - opaque handle for DP ring descriptor
128  */
129 struct hal_ring_desc;
130 typedef struct hal_ring_desc *hal_ring_desc_t;
131 
132 /**
133  * hal_link_desc - opaque handle for DP link descriptor
134  */
135 struct hal_link_desc;
136 typedef struct hal_link_desc *hal_link_desc_t;
137 
138 /**
139  * hal_rxdma_desc - opaque handle for DP rxdma dst ring descriptor
140  */
141 struct hal_rxdma_desc;
142 typedef struct hal_rxdma_desc *hal_rxdma_desc_t;
143 
144 /**
145  * hal_buff_addrinfo - opaque handle for DP buffer address info
146  */
147 struct hal_buff_addrinfo;
148 typedef struct hal_buff_addrinfo *hal_buff_addrinfo_t;
149 
150 /**
151  * hal_rx_mon_desc_info - opaque handle for sw monitor ring desc info
152  */
153 struct hal_rx_mon_desc_info;
154 typedef struct hal_rx_mon_desc_info *hal_rx_mon_desc_info_t;
155 
156 struct hal_buf_info;
157 typedef struct hal_buf_info *hal_buf_info_t;
158 
159 struct rx_msdu_desc_info;
160 typedef struct rx_msdu_desc_info *rx_msdu_desc_info_t;
161 
162 /**
163  * Opaque hanlder for PPE VP config.
164  */
165 union hal_tx_ppe_vp_config;
166 union hal_tx_cmn_config_ppe;
167 union hal_tx_bank_config;
168 
169 /* TBD: This should be movded to shared HW header file */
170 enum hal_srng_ring_id {
171 	/* UMAC rings */
172 	HAL_SRNG_REO2SW0 = 0,
173 	HAL_SRNG_REO2SW1 = 1,
174 	HAL_SRNG_REO2SW2 = 2,
175 	HAL_SRNG_REO2SW3 = 3,
176 	HAL_SRNG_REO2SW4 = 4,
177 	HAL_SRNG_REO2SW5 = 5,
178 	HAL_SRNG_REO2SW6 = 6,
179 	HAL_SRNG_REO2SW7 = 7,
180 	HAL_SRNG_REO2SW8 = 8,
181 	HAL_SRNG_REO2TCL = 9,
182 	HAL_SRNG_REO2PPE = 10,
183 	/* 11-15 unused */
184 	HAL_SRNG_SW2REO = 16,
185 	HAL_SRNG_SW2REO1 = 17,
186 	HAL_SRNG_SW2REO2 = 18,
187 	HAL_SRNG_SW2REO3 = 19,
188 	HAL_SRNG_REO_CMD = 20,
189 	HAL_SRNG_REO_STATUS = 21,
190 	/* 22-23 unused */
191 	HAL_SRNG_SW2TCL1 = 24,
192 	HAL_SRNG_SW2TCL2 = 25,
193 	HAL_SRNG_SW2TCL3 = 26,
194 	HAL_SRNG_SW2TCL4 = 27,
195 	HAL_SRNG_SW2TCL5 = 28,
196 	HAL_SRNG_SW2TCL6 = 29,
197 	HAL_SRNG_PPE2TCL1 = 30,
198 	/* 31-39 unused */
199 	HAL_SRNG_SW2TCL_CMD = 40,
200 	HAL_SRNG_TCL_STATUS = 41,
201 	HAL_SRNG_SW2TCL_CREDIT = 42,
202 	/* 43-63 unused */
203 	HAL_SRNG_CE_0_SRC = 64,
204 	HAL_SRNG_CE_1_SRC = 65,
205 	HAL_SRNG_CE_2_SRC = 66,
206 	HAL_SRNG_CE_3_SRC = 67,
207 	HAL_SRNG_CE_4_SRC = 68,
208 	HAL_SRNG_CE_5_SRC = 69,
209 	HAL_SRNG_CE_6_SRC = 70,
210 	HAL_SRNG_CE_7_SRC = 71,
211 	HAL_SRNG_CE_8_SRC = 72,
212 	HAL_SRNG_CE_9_SRC = 73,
213 	HAL_SRNG_CE_10_SRC = 74,
214 	HAL_SRNG_CE_11_SRC = 75,
215 	HAL_SRNG_CE_12_SRC = 76,
216 	HAL_SRNG_CE_13_SRC = 77,
217 	HAL_SRNG_CE_14_SRC = 78,
218 	HAL_SRNG_CE_15_SRC = 79,
219 	/* 80 */
220 	HAL_SRNG_CE_0_DST = 81,
221 	HAL_SRNG_CE_1_DST = 82,
222 	HAL_SRNG_CE_2_DST = 83,
223 	HAL_SRNG_CE_3_DST = 84,
224 	HAL_SRNG_CE_4_DST = 85,
225 	HAL_SRNG_CE_5_DST = 86,
226 	HAL_SRNG_CE_6_DST = 87,
227 	HAL_SRNG_CE_7_DST = 89,
228 	HAL_SRNG_CE_8_DST = 90,
229 	HAL_SRNG_CE_9_DST = 91,
230 	HAL_SRNG_CE_10_DST = 92,
231 	HAL_SRNG_CE_11_DST = 93,
232 	HAL_SRNG_CE_12_DST = 94,
233 	HAL_SRNG_CE_13_DST = 95,
234 	HAL_SRNG_CE_14_DST = 96,
235 	HAL_SRNG_CE_15_DST = 97,
236 	/* 98-99 unused */
237 	HAL_SRNG_CE_0_DST_STATUS = 100,
238 	HAL_SRNG_CE_1_DST_STATUS = 101,
239 	HAL_SRNG_CE_2_DST_STATUS = 102,
240 	HAL_SRNG_CE_3_DST_STATUS = 103,
241 	HAL_SRNG_CE_4_DST_STATUS = 104,
242 	HAL_SRNG_CE_5_DST_STATUS = 105,
243 	HAL_SRNG_CE_6_DST_STATUS = 106,
244 	HAL_SRNG_CE_7_DST_STATUS = 107,
245 	HAL_SRNG_CE_8_DST_STATUS = 108,
246 	HAL_SRNG_CE_9_DST_STATUS = 109,
247 	HAL_SRNG_CE_10_DST_STATUS = 110,
248 	HAL_SRNG_CE_11_DST_STATUS = 111,
249 	HAL_SRNG_CE_12_DST_STATUS = 112,
250 	HAL_SRNG_CE_13_DST_STATUS = 113,
251 	HAL_SRNG_CE_14_DST_STATUS = 114,
252 	HAL_SRNG_CE_15_DST_STATUS = 115,
253 	/* 116-119 unused */
254 	HAL_SRNG_WBM_IDLE_LINK = 120,
255 	HAL_SRNG_WBM_SW_RELEASE = 121,
256 	HAL_SRNG_WBM_SW1_RELEASE = 122,
257 	HAL_SRNG_WBM_PPE_RELEASE = 123,
258 	/* 124-127 unused */
259 	HAL_SRNG_WBM2SW0_RELEASE = 128,
260 	HAL_SRNG_WBM2SW1_RELEASE = 129,
261 	HAL_SRNG_WBM2SW2_RELEASE = 130,
262 	HAL_SRNG_WBM2SW3_RELEASE = 131,
263 	HAL_SRNG_WBM2SW4_RELEASE = 132,
264 	HAL_SRNG_WBM2SW5_RELEASE = 133,
265 	HAL_SRNG_WBM2SW6_RELEASE = 134,
266 	HAL_SRNG_WBM_ERROR_RELEASE = 135,
267 	/* 136-158 unused */
268 	HAL_SRNG_UMAC_ID_END = 159,
269 	/* Common DMAC rings shared by all LMACs */
270 	HAL_SRNG_SW2RXDMA_BUF0 = 160,
271 	HAL_SRNG_SW2RXDMA_BUF1 = 161,
272 	HAL_SRNG_SW2RXDMA_BUF2 = 162,
273 	/* 163-167 unused */
274 	HAL_SRNG_SW2RXMON_BUF0 = 168,
275 	/* 169-175 unused */
276 	/* 177-183 unused */
277 	HAL_SRNG_DMAC_CMN_ID_END = 183,
278 	/* LMAC rings - The following set will be replicated for each LMAC */
279 	HAL_SRNG_LMAC1_ID_START = 184,
280 	HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 = HAL_SRNG_LMAC1_ID_START,
281 #ifdef IPA_OFFLOAD
282 	HAL_SRNG_WMAC1_SW2RXDMA0_BUF1,
283 	HAL_SRNG_WMAC1_SW2RXDMA0_BUF2,
284 #ifdef IPA_WDI3_VLAN_SUPPORT
285 	HAL_SRNG_WMAC1_SW2RXDMA0_BUF3,
286 #endif
287 	HAL_SRNG_WMAC1_SW2RXDMA1_BUF,
288 #else
289 	HAL_SRNG_WMAC1_SW2RXDMA1_BUF,
290 #endif
291 	HAL_SRNG_WMAC1_SW2RXDMA2_BUF,
292 	HAL_SRNG_WMAC1_SW2RXDMA0_STATBUF,
293 	HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF,
294 	HAL_SRNG_WMAC1_RXDMA2SW0,
295 	HAL_SRNG_WMAC1_RXDMA2SW1,
296 	HAL_SRNG_WMAC1_RXMON2SW0 = HAL_SRNG_WMAC1_RXDMA2SW1,
297 	HAL_SRNG_WMAC1_SW2RXDMA1_DESC,
298 #ifdef WLAN_FEATURE_CIF_CFR
299 	HAL_SRNG_WIFI_POS_SRC_DMA_RING,
300 	HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING,
301 	HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING1,
302 #else
303 	HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING,
304 	HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING1,
305 #endif
306 	HAL_SRNG_WMAC1_TXMON2SW0,
307 	HAL_SRNG_SW2TXMON_BUF0,
308 	HAL_SRNG_LMAC1_ID_END = (HAL_SRNG_SW2TXMON_BUF0 + 2),
309 };
310 
311 #define HAL_RXDMA_MAX_RING_SIZE 0xFFFF
312 #define HAL_MAX_LMACS 3
313 #define HAL_MAX_RINGS_PER_LMAC (HAL_SRNG_LMAC1_ID_END - HAL_SRNG_LMAC1_ID_START)
314 #define HAL_MAX_LMAC_RINGS (HAL_MAX_LMACS * HAL_MAX_RINGS_PER_LMAC)
315 
316 #define HAL_SRNG_ID_MAX (HAL_SRNG_DMAC_CMN_ID_END + HAL_MAX_LMAC_RINGS)
317 
318 /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */
319 enum hal_ring_type {
320 	REO_DST = 0,
321 	REO_EXCEPTION = 1,
322 	REO_REINJECT = 2,
323 	REO_CMD = 3,
324 	REO_STATUS = 4,
325 	TCL_DATA = 5,
326 	TCL_CMD_CREDIT = 6,
327 	TCL_STATUS = 7,
328 	CE_SRC = 8,
329 	CE_DST = 9,
330 	CE_DST_STATUS = 10,
331 	WBM_IDLE_LINK = 11,
332 	SW2WBM_RELEASE = 12,
333 	WBM2SW_RELEASE = 13,
334 	RXDMA_BUF = 14,
335 	RXDMA_DST = 15,
336 	RXDMA_MONITOR_BUF = 16,
337 	RXDMA_MONITOR_STATUS = 17,
338 	RXDMA_MONITOR_DST = 18,
339 	RXDMA_MONITOR_DESC = 19,
340 	DIR_BUF_RX_DMA_SRC = 20,
341 #ifdef WLAN_FEATURE_CIF_CFR
342 	WIFI_POS_SRC,
343 #endif
344 	REO2PPE,
345 	PPE2TCL,
346 	PPE_RELEASE,
347 	TX_MONITOR_BUF,
348 	TX_MONITOR_DST,
349 	SW2RXDMA_NEW,
350 	MAX_RING_TYPES
351 };
352 
353 enum SRNG_REGISTERS {
354 	DST_HP = 0,
355 	DST_TP,
356 	DST_ID,
357 	DST_MISC,
358 	DST_HP_ADDR_LSB,
359 	DST_HP_ADDR_MSB,
360 	DST_MSI1_BASE_LSB,
361 	DST_MSI1_BASE_MSB,
362 	DST_MSI1_DATA,
363 #ifdef CONFIG_BERYLLIUM
364 	DST_MSI2_BASE_LSB,
365 	DST_MSI2_BASE_MSB,
366 	DST_MSI2_DATA,
367 #endif
368 	DST_BASE_LSB,
369 	DST_BASE_MSB,
370 	DST_PRODUCER_INT_SETUP,
371 #ifdef CONFIG_BERYLLIUM
372 	DST_PRODUCER_INT2_SETUP,
373 #endif
374 
375 	SRC_HP,
376 	SRC_TP,
377 	SRC_ID,
378 	SRC_MISC,
379 	SRC_TP_ADDR_LSB,
380 	SRC_TP_ADDR_MSB,
381 	SRC_MSI1_BASE_LSB,
382 	SRC_MSI1_BASE_MSB,
383 	SRC_MSI1_DATA,
384 	SRC_BASE_LSB,
385 	SRC_BASE_MSB,
386 	SRC_CONSUMER_INT_SETUP_IX0,
387 	SRC_CONSUMER_INT_SETUP_IX1,
388 	SRNG_REGISTER_MAX,
389 };
390 
391 enum hal_srng_dir {
392 	HAL_SRNG_SRC_RING,
393 	HAL_SRNG_DST_RING
394 };
395 
396 /**
397  * enum hal_reo_remap_reg - REO remap registers
398  * @HAL_REO_REMAP_REG_IX0: reo remap reg IX0
399  * @HAL_REO_REMAP_REG_IX1: reo remap reg IX1
400  * @HAL_REO_REMAP_REG_IX2: reo remap reg IX2
401  * @HAL_REO_REMAP_REG_IX3: reo remap reg IX3
402  */
403 enum hal_reo_remap_reg {
404 	HAL_REO_REMAP_REG_IX0,
405 	HAL_REO_REMAP_REG_IX1,
406 	HAL_REO_REMAP_REG_IX2,
407 	HAL_REO_REMAP_REG_IX3
408 };
409 
410 /* Lock wrappers for SRNG */
411 #define hal_srng_lock_t qdf_spinlock_t
412 #define SRNG_LOCK_INIT(_lock) qdf_spinlock_create(_lock)
413 #define SRNG_LOCK(_lock) qdf_spin_lock_bh(_lock)
414 #define SRNG_TRY_LOCK(_lock) qdf_spin_trylock_bh(_lock)
415 #define SRNG_UNLOCK(_lock) qdf_spin_unlock_bh(_lock)
416 #define SRNG_LOCK_DESTROY(_lock) qdf_spinlock_destroy(_lock)
417 
418 struct hal_soc;
419 
420 /**
421  * dp_hal_ring - opaque handle for DP HAL SRNG
422  */
423 struct hal_ring_handle;
424 typedef struct hal_ring_handle *hal_ring_handle_t;
425 
426 #define MAX_SRNG_REG_GROUPS 2
427 
428 /* Hal Srng bit mask
429  * HAL_SRNG_FLUSH_EVENT: SRNG HP TP flush in case of link down
430  */
431 #define HAL_SRNG_FLUSH_EVENT BIT(0)
432 
433 #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
434 
435 /**
436  * struct hal_reg_write_q_elem - delayed register write queue element
437  * @srng: hal_srng queued for a delayed write
438  * @addr: iomem address of the register
439  * @enqueue_val: register value at the time of delayed write enqueue
440  * @dequeue_val: register value at the time of delayed write dequeue
441  * @valid: whether this entry is valid or not
442  * @enqueue_time: enqueue time (qdf_log_timestamp)
443  * @work_scheduled_time: work scheduled time (qdf_log_timestamp)
444  * @dequeue_time: dequeue time (qdf_log_timestamp)
445  * @cpu_id: record cpuid when schedule work
446  */
447 struct hal_reg_write_q_elem {
448 	struct hal_srng *srng;
449 	void __iomem *addr;
450 	uint32_t enqueue_val;
451 	uint32_t dequeue_val;
452 	uint8_t valid;
453 	qdf_time_t enqueue_time;
454 	qdf_time_t work_scheduled_time;
455 	qdf_time_t dequeue_time;
456 	int cpu_id;
457 };
458 
459 /**
460  * struct hal_reg_write_srng_stats - srng stats to keep track of register writes
461  * @enqueues: writes enqueued to delayed work
462  * @dequeues: writes dequeued from delayed work (not written yet)
463  * @coalesces: writes not enqueued since srng is already queued up
464  * @direct: writes not enqueued and written to register directly
465  * @dequeue_delay: dequeue operation be delayed
466  */
467 struct hal_reg_write_srng_stats {
468 	uint32_t enqueues;
469 	uint32_t dequeues;
470 	uint32_t coalesces;
471 	uint32_t direct;
472 	uint32_t dequeue_delay;
473 };
474 
475 /**
476  * enum hal_reg_sched_delay - ENUM for write sched delay histogram
477  * @REG_WRITE_SCHED_DELAY_SUB_100us: index for delay < 100us
478  * @REG_WRITE_SCHED_DELAY_SUB_1000us: index for delay < 1000us
479  * @REG_WRITE_SCHED_DELAY_SUB_5000us: index for delay < 5000us
480  * @REG_WRITE_SCHED_DELAY_GT_5000us: index for delay >= 5000us
481  * @REG_WRITE_SCHED_DELAY_HIST_MAX: Max value (nnsize of histogram array)
482  */
483 enum hal_reg_sched_delay {
484 	REG_WRITE_SCHED_DELAY_SUB_100us,
485 	REG_WRITE_SCHED_DELAY_SUB_1000us,
486 	REG_WRITE_SCHED_DELAY_SUB_5000us,
487 	REG_WRITE_SCHED_DELAY_GT_5000us,
488 	REG_WRITE_SCHED_DELAY_HIST_MAX,
489 };
490 
491 /**
492  * struct hal_reg_write_soc_stats - soc stats to keep track of register writes
493  * @enqueues: writes enqueued to delayed work
494  * @dequeues: writes dequeued from delayed work (not written yet)
495  * @coalesces: writes not enqueued since srng is already queued up
496  * @direct: writes not enqueud and writted to register directly
497  * @prevent_l1_fails: prevent l1 API failed
498  * @q_depth: current queue depth in delayed register write queue
499  * @max_q_depth: maximum queue for delayed register write queue
500  * @sched_delay: = kernel work sched delay + bus wakeup delay, histogram
501  * @dequeue_delay: dequeue operation be delayed
502  */
503 struct hal_reg_write_soc_stats {
504 	qdf_atomic_t enqueues;
505 	uint32_t dequeues;
506 	qdf_atomic_t coalesces;
507 	qdf_atomic_t direct;
508 	uint32_t prevent_l1_fails;
509 	qdf_atomic_t q_depth;
510 	uint32_t max_q_depth;
511 	uint32_t sched_delay[REG_WRITE_SCHED_DELAY_HIST_MAX];
512 	uint32_t dequeue_delay;
513 };
514 #endif
515 
516 struct hal_offload_info {
517 	uint8_t lro_eligible;
518 	uint8_t tcp_proto;
519 	uint8_t tcp_pure_ack;
520 	uint8_t ipv6_proto;
521 	uint8_t tcp_offset;
522 	uint16_t tcp_csum;
523 	uint16_t tcp_win;
524 	uint32_t tcp_seq_num;
525 	uint32_t tcp_ack_num;
526 	uint32_t flow_id;
527 };
528 
529 #ifdef WLAN_DP_SRNG_USAGE_WM_TRACKING
530 /**
531  * enum hal_srng_high_wm_bin - BIN for SRNG high watermark
532  * @HAL_SRNG_HIGH_WM_BIN_BELOW_50_PERCENT: <50% SRNG entries used
533  * @HAL_SRNG_HIGH_WM_BIN_50_to_60: 50-60% SRNG entries used
534  * @HAL_SRNG_HIGH_WM_BIN_60_to_70: 60-70% SRNG entries used
535  * @HAL_SRNG_HIGH_WM_BIN_70_to_80: 70-80% SRNG entries used
536  * @HAL_SRNG_HIGH_WM_BIN_80_to_90: 80-90% SRNG entries used
537  * @HAL_SRNG_HIGH_WM_BIN_90_to_100: 90-100% SRNG entries used
538  */
539 enum hal_srng_high_wm_bin {
540 	HAL_SRNG_HIGH_WM_BIN_BELOW_50_PERCENT,
541 	HAL_SRNG_HIGH_WM_BIN_50_to_60,
542 	HAL_SRNG_HIGH_WM_BIN_60_to_70,
543 	HAL_SRNG_HIGH_WM_BIN_70_to_80,
544 	HAL_SRNG_HIGH_WM_BIN_80_to_90,
545 	HAL_SRNG_HIGH_WM_BIN_90_to_100,
546 	HAL_SRNG_HIGH_WM_BIN_MAX,
547 };
548 
549 /**
550  * struct hal_srng_high_wm_info - SRNG usage high watermark info
551  * @val: highest number of entries used in SRNG
552  * @timestamp: Timestamp when the max num entries were in used for a SRNG
553  * @bin_thresh: threshold for each bins
554  * @bins: Bins for srng usage
555  */
556 struct hal_srng_high_wm_info {
557 	uint32_t val;
558 	uint64_t timestamp;
559 	uint32_t bin_thresh[HAL_SRNG_HIGH_WM_BIN_MAX];
560 	uint32_t bins[HAL_SRNG_HIGH_WM_BIN_MAX];
561 };
562 #endif
563 
564 /* Common SRNG ring structure for source and destination rings */
565 struct hal_srng {
566 	/* Unique SRNG ring ID */
567 	uint8_t ring_id;
568 
569 	/* Ring initialization done */
570 	uint8_t initialized;
571 
572 	/* Interrupt/MSI value assigned to this ring */
573 	int irq;
574 
575 	/* Physical base address of the ring */
576 	qdf_dma_addr_t ring_base_paddr;
577 
578 	/* Virtual base address of the ring */
579 	uint32_t *ring_base_vaddr;
580 
581 	/* virtual address end */
582 	uint32_t *ring_vaddr_end;
583 
584 	/* Number of entries in ring */
585 	uint32_t num_entries;
586 
587 	/* Ring size */
588 	uint32_t ring_size;
589 
590 	/* Ring size mask */
591 	uint32_t ring_size_mask;
592 
593 	/* Size of ring entry */
594 	uint32_t entry_size;
595 
596 	/* Interrupt timer threshold – in micro seconds */
597 	uint32_t intr_timer_thres_us;
598 
599 	/* Interrupt batch counter threshold – in number of ring entries */
600 	uint32_t intr_batch_cntr_thres_entries;
601 
602 	/* Applicable only for CE dest ring */
603 	uint32_t prefetch_timer;
604 
605 	/* MSI Address */
606 	qdf_dma_addr_t msi_addr;
607 
608 	/* MSI data */
609 	uint32_t msi_data;
610 
611 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
612 	/* MSI2 Address */
613 	qdf_dma_addr_t msi2_addr;
614 
615 	/* MSI2 data */
616 	uint32_t msi2_data;
617 #endif
618 
619 	/* Misc flags */
620 	uint32_t flags;
621 
622 	/* Lock for serializing ring index updates */
623 	hal_srng_lock_t lock;
624 
625 	/* Start offset of SRNG register groups for this ring
626 	 * TBD: See if this is required - register address can be derived
627 	 * from ring ID
628 	 */
629 	void *hwreg_base[MAX_SRNG_REG_GROUPS];
630 
631 	/* Ring type/name */
632 	enum hal_ring_type ring_type;
633 
634 	/* Source or Destination ring */
635 	enum hal_srng_dir ring_dir;
636 
637 	union {
638 		struct {
639 			/* SW tail pointer */
640 			uint32_t tp;
641 
642 			/* Shadow head pointer location to be updated by HW */
643 			uint32_t *hp_addr;
644 
645 			/* Cached head pointer */
646 			uint32_t cached_hp;
647 
648 			/* Tail pointer location to be updated by SW – This
649 			 * will be a register address and need not be
650 			 * accessed through SW structure */
651 			uint32_t *tp_addr;
652 
653 			/* Current SW loop cnt */
654 			uint32_t loop_cnt;
655 
656 			/* max transfer size */
657 			uint16_t max_buffer_length;
658 
659 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
660 			/* near full IRQ supported */
661 			uint16_t nf_irq_support;
662 
663 			/* High threshold for Near full IRQ */
664 			uint16_t high_thresh;
665 #endif
666 		} dst_ring;
667 
668 		struct {
669 			/* SW head pointer */
670 			uint32_t hp;
671 
672 			/* SW reap head pointer */
673 			uint32_t reap_hp;
674 
675 			/* Shadow tail pointer location to be updated by HW */
676 			uint32_t *tp_addr;
677 
678 			/* Cached tail pointer */
679 			uint32_t cached_tp;
680 
681 			/* Head pointer location to be updated by SW – This
682 			 * will be a register address and need not be accessed
683 			 * through SW structure */
684 			uint32_t *hp_addr;
685 
686 			/* Low threshold – in number of ring entries */
687 			uint32_t low_threshold;
688 		} src_ring;
689 	} u;
690 
691 	struct hal_soc *hal_soc;
692 
693 	/* Number of times hp/tp updated in runtime resume */
694 	uint32_t flush_count;
695 	/* hal srng event flag*/
696 	unsigned long srng_event;
697 	/* last flushed time stamp */
698 	uint64_t last_flush_ts;
699 #if defined(CLEAR_SW2TCL_CONSUMED_DESC)
700 	/* last ring desc entry cleared */
701 	uint32_t last_desc_cleared;
702 #endif
703 #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
704 	/* flag to indicate whether srng is already queued for delayed write */
705 	uint8_t reg_write_in_progress;
706 	/* last dequeue elem time stamp */
707 	qdf_time_t last_dequeue_time;
708 
709 	/* srng specific delayed write stats */
710 	struct hal_reg_write_srng_stats wstats;
711 #endif
712 #ifdef WLAN_DP_SRNG_USAGE_WM_TRACKING
713 	struct hal_srng_high_wm_info high_wm;
714 #endif
715 };
716 
717 /* HW SRNG configuration table */
718 struct hal_hw_srng_config {
719 	int start_ring_id;
720 	uint16_t max_rings;
721 	uint16_t entry_size;
722 	uint32_t reg_start[MAX_SRNG_REG_GROUPS];
723 	uint16_t reg_size[MAX_SRNG_REG_GROUPS];
724 	uint8_t lmac_ring;
725 	enum hal_srng_dir ring_dir;
726 	uint32_t max_size;
727 	bool nf_irq_support;
728 };
729 
730 #define MAX_SHADOW_REGISTERS 40
731 #define MAX_GENERIC_SHADOW_REG 5
732 
733 /**
734  * struct shadow_reg_config - Hal soc structure that contains
735  * the list of generic shadow registers
736  * @target_register: target reg offset
737  * @shadow_config_index: shadow config index in shadow config
738  *				list sent to FW
739  * @va: virtual addr of shadow reg
740  *
741  * This structure holds the generic registers that are mapped to
742  * the shadow region and holds the mapping of the target
743  * register offset to shadow config index provided to FW during
744  * init
745  */
746 struct shadow_reg_config {
747 	uint32_t target_register;
748 	int shadow_config_index;
749 	uint64_t va;
750 };
751 
752 /* REO parameters to be passed to hal_reo_setup */
753 struct hal_reo_params {
754 	/** rx hash steering enabled or disabled */
755 	bool rx_hash_enabled;
756 	/** reo remap 0 register */
757 	uint32_t remap0;
758 	/** reo remap 1 register */
759 	uint32_t remap1;
760 	/** reo remap 2 register */
761 	uint32_t remap2;
762 	/** fragment destination ring */
763 	uint8_t frag_dst_ring;
764 	/* Destination for alternate */
765 	uint8_t alt_dst_ind_0;
766 	/** padding */
767 	uint8_t padding[2];
768 };
769 
770 /**
771  * enum hal_reo_cmd_type: Enum for REO command type
772  * @CMD_GET_QUEUE_STATS: Get REO queue status/stats
773  * @CMD_FLUSH_QUEUE: Flush all frames in REO queue
774  * @CMD_FLUSH_CACHE: Flush descriptor entries in the cache
775  * @CMD_UNBLOCK_CACHE: Unblock a descriptor’s address that was blocked
776  *	earlier with a ‘REO_FLUSH_CACHE’ command
777  * @CMD_FLUSH_TIMEOUT_LIST: Flush buffers/descriptors from timeout list
778  * @CMD_UPDATE_RX_REO_QUEUE: Update REO queue settings
779  */
780 enum hal_reo_cmd_type {
781 	CMD_GET_QUEUE_STATS	= 0,
782 	CMD_FLUSH_QUEUE		= 1,
783 	CMD_FLUSH_CACHE		= 2,
784 	CMD_UNBLOCK_CACHE	= 3,
785 	CMD_FLUSH_TIMEOUT_LIST	= 4,
786 	CMD_UPDATE_RX_REO_QUEUE = 5
787 };
788 
789 /**
790  * enum hal_tx_mcast_mlo_reinject_notify
791  * @HAL_TX_MCAST_MLO_REINJECT_FW_NOTIFY: MLO Mcast reinject routed to FW
792  * @HAL_TX_MCAST_MLO_REINJECT_TQM_NOTIFY: MLO Mcast reinject routed to TQM
793  */
794 enum hal_tx_mcast_mlo_reinject_notify {
795 	HAL_TX_MCAST_MLO_REINJECT_FW_NOTIFY = 0,
796 	HAL_TX_MCAST_MLO_REINJECT_TQM_NOTIFY,
797 };
798 
799 /**
800  * enum hal_tx_vdev_mismatch_notify
801  * @HAL_TX_VDEV_MISMATCH_TQM_NOTIFY: vdev mismatch exception routed to TQM
802  * @HAL_TX_VDEV_MISMATCH_FW_NOTIFY: vdev mismatch exception routed to FW
803  */
804 enum hal_tx_vdev_mismatch_notify {
805 	HAL_TX_VDEV_MISMATCH_TQM_NOTIFY = 0,
806 	HAL_TX_VDEV_MISMATCH_FW_NOTIFY,
807 };
808 
809 struct hal_rx_pkt_capture_flags {
810 	uint8_t encrypt_type;
811 	uint8_t fragment_flag;
812 	uint8_t fcs_err;
813 	uint32_t chan_freq;
814 	uint32_t rssi_comb;
815 	uint64_t tsft;
816 };
817 
818 struct hal_hw_txrx_ops {
819 	/* init and setup */
820 	void (*hal_srng_dst_hw_init)(struct hal_soc *hal,
821 				     struct hal_srng *srng);
822 	void (*hal_srng_src_hw_init)(struct hal_soc *hal,
823 				     struct hal_srng *srng);
824 	void (*hal_get_hw_hptp)(struct hal_soc *hal,
825 				hal_ring_handle_t hal_ring_hdl,
826 				uint32_t *headp, uint32_t *tailp,
827 				uint8_t ring_type);
828 	void (*hal_reo_setup)(struct hal_soc *hal_soc, void *reoparams);
829 	void (*hal_setup_link_idle_list)(
830 				struct hal_soc *hal_soc,
831 				qdf_dma_addr_t scatter_bufs_base_paddr[],
832 				void *scatter_bufs_base_vaddr[],
833 				uint32_t num_scatter_bufs,
834 				uint32_t scatter_buf_size,
835 				uint32_t last_buf_end_offset,
836 				uint32_t num_entries);
837 	qdf_iomem_t (*hal_get_window_address)(struct hal_soc *hal_soc,
838 					      qdf_iomem_t addr);
839 	void (*hal_reo_set_err_dst_remap)(void *hal_soc);
840 	uint8_t (*hal_reo_enable_pn_in_dest)(void *hal_soc);
841 	void (*hal_reo_qdesc_setup)(hal_soc_handle_t hal_soc_hdl, int tid,
842 				    uint32_t ba_window_size,
843 				    uint32_t start_seq, void *hw_qdesc_vaddr,
844 				    qdf_dma_addr_t hw_qdesc_paddr,
845 				    int pn_type, uint8_t vdev_stats_id);
846 	uint32_t (*hal_gen_reo_remap_val)(enum hal_reo_remap_reg,
847 					  uint8_t *ix0_map);
848 
849 	/* tx */
850 	void (*hal_tx_desc_set_dscp_tid_table_id)(void *desc, uint8_t id);
851 	void (*hal_tx_set_dscp_tid_map)(struct hal_soc *hal_soc, uint8_t *map,
852 					uint8_t id);
853 	void (*hal_tx_update_dscp_tid)(struct hal_soc *hal_soc, uint8_t tid,
854 				       uint8_t id,
855 				       uint8_t dscp);
856 	void (*hal_tx_desc_set_lmac_id)(void *desc, uint8_t lmac_id);
857 	void (*hal_tx_desc_set_buf_addr)(void *desc, dma_addr_t paddr,
858 					 uint8_t pool_id, uint32_t desc_id,
859 					 uint8_t type);
860 	void (*hal_tx_desc_set_search_type)(void *desc, uint8_t search_type);
861 	void (*hal_tx_desc_set_search_index)(void *desc, uint32_t search_index);
862 	void (*hal_tx_desc_set_cache_set_num)(void *desc, uint8_t search_index);
863 	void (*hal_tx_comp_get_status)(void *desc, void *ts,
864 				       struct hal_soc *hal);
865 	uint8_t (*hal_tx_comp_get_release_reason)(void *hal_desc);
866 	uint8_t (*hal_get_wbm_internal_error)(void *hal_desc);
867 	void (*hal_tx_desc_set_mesh_en)(void *desc, uint8_t en);
868 	void (*hal_tx_init_cmd_credit_ring)(hal_soc_handle_t hal_soc_hdl,
869 					    hal_ring_handle_t hal_ring_hdl);
870 	uint32_t (*hal_tx_comp_get_buffer_source)(void *hal_desc);
871 	uint32_t (*hal_tx_get_num_ppe_vp_tbl_entries)(
872 					hal_soc_handle_t hal_soc_hdl);
873 	void (*hal_tx_set_ppe_cmn_cfg)(hal_soc_handle_t hal_soc_hdl,
874 				       union hal_tx_cmn_config_ppe *cmn_cfg);
875 	void (*hal_tx_set_ppe_vp_entry)(hal_soc_handle_t hal_soc_hdl,
876 					union hal_tx_ppe_vp_config *vp_cfg,
877 					int ppe_vp_idx);
878 	void (*hal_tx_set_ppe_pri2tid)(hal_soc_handle_t hal_soc_hdl,
879 				       uint32_t val,
880 				       uint8_t map_no);
881 	void (*hal_tx_update_ppe_pri2tid)(hal_soc_handle_t hal_soc_hdl,
882 					  uint8_t pri,
883 					  uint8_t tid);
884 	void (*hal_tx_dump_ppe_vp_entry)(hal_soc_handle_t hal_soc_hdl);
885 	void (*hal_tx_enable_pri2tid_map)(hal_soc_handle_t hal_soc_hdl,
886 					  bool value, uint8_t ppe_vp_idx);
887 	void (*hal_tx_config_rbm_mapping_be)(hal_soc_handle_t hal_soc_hdl,
888 					     hal_ring_handle_t hal_ring_hdl,
889 					     uint8_t rbm_id);
890 
891 	/* rx */
892 	uint32_t (*hal_rx_msdu_start_nss_get)(uint8_t *);
893 	void (*hal_rx_mon_hw_desc_get_mpdu_status)(void *hw_desc_addr,
894 						   struct mon_rx_status *rs);
895 	uint8_t (*hal_rx_get_tlv)(void *rx_tlv);
896 	void (*hal_rx_proc_phyrx_other_receive_info_tlv)(void *rx_tlv_hdr,
897 							void *ppdu_info_handle);
898 	void (*hal_rx_dump_msdu_start_tlv)(void *msdu_start, uint8_t dbg_level);
899 	void (*hal_rx_dump_msdu_end_tlv)(void *msdu_end,
900 					 uint8_t dbg_level);
901 	uint32_t (*hal_get_link_desc_size)(void);
902 	uint32_t (*hal_rx_mpdu_start_tid_get)(uint8_t *buf);
903 	uint32_t (*hal_rx_msdu_start_reception_type_get)(uint8_t *buf);
904 	uint16_t (*hal_rx_msdu_end_da_idx_get)(uint8_t *buf);
905 	void* (*hal_rx_msdu_desc_info_get_ptr)(void *msdu_details_ptr);
906 	void* (*hal_rx_link_desc_msdu0_ptr)(void *msdu_link_ptr);
907 	void (*hal_reo_status_get_header)(hal_ring_desc_t ring_desc, int b,
908 					  void *h);
909 	uint32_t (*hal_rx_status_get_tlv_info)(void *rx_tlv_hdr,
910 					       void *ppdu_info,
911 					       hal_soc_handle_t hal_soc_hdl,
912 					       qdf_nbuf_t nbuf);
913 
914 	void (*hal_rx_wbm_rel_buf_paddr_get)(hal_ring_desc_t rx_desc,
915 					     struct hal_buf_info *buf_info);
916 
917 	void (*hal_rx_wbm_err_info_get)(void *wbm_desc,
918 				void *wbm_er_info);
919 	void (*hal_rx_dump_mpdu_start_tlv)(void *mpdustart,
920 						uint8_t dbg_level);
921 
922 	void (*hal_tx_set_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t *map);
923 	void (*hal_tx_update_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t pcp,
924 					  uint8_t id);
925 	void (*hal_tx_set_tidmap_prty)(struct hal_soc *hal_soc, uint8_t prio);
926 
927 	/* rx */
928 	uint8_t (*hal_rx_get_rx_fragment_number)(uint8_t *buf);
929 	uint8_t (*hal_rx_msdu_end_da_is_mcbc_get)(uint8_t *buf);
930 	uint8_t (*hal_rx_msdu_end_is_tkip_mic_err)(uint8_t *buf);
931 	uint8_t (*hal_rx_msdu_end_sa_is_valid_get)(uint8_t *buf);
932 	uint16_t (*hal_rx_msdu_end_sa_idx_get)(uint8_t *buf);
933 	uint32_t (*hal_rx_desc_is_first_msdu)(void *hw_desc_addr);
934 	uint32_t (*hal_rx_msdu_end_l3_hdr_padding_get)(uint8_t *buf);
935 	uint32_t (*hal_rx_encryption_info_valid)(uint8_t *buf);
936 	void (*hal_rx_print_pn)(uint8_t *buf);
937 	uint8_t (*hal_rx_msdu_end_first_msdu_get)(uint8_t *buf);
938 	uint8_t (*hal_rx_msdu_end_da_is_valid_get)(uint8_t *buf);
939 	uint8_t (*hal_rx_msdu_end_last_msdu_get)(uint8_t *buf);
940 	bool (*hal_rx_get_mpdu_mac_ad4_valid)(uint8_t *buf);
941 	uint32_t (*hal_rx_mpdu_start_sw_peer_id_get)(uint8_t *buf);
942 	uint32_t (*hal_rx_mpdu_peer_meta_data_get)(uint8_t *buf);
943 	uint32_t (*hal_rx_mpdu_get_to_ds)(uint8_t *buf);
944 	uint32_t (*hal_rx_mpdu_get_fr_ds)(uint8_t *buf);
945 	uint8_t (*hal_rx_get_mpdu_frame_control_valid)(uint8_t *buf);
946 	QDF_STATUS
947 		(*hal_rx_mpdu_get_addr1)(uint8_t *buf, uint8_t *mac_addr);
948 	QDF_STATUS
949 		(*hal_rx_mpdu_get_addr2)(uint8_t *buf, uint8_t *mac_addr);
950 	QDF_STATUS
951 		(*hal_rx_mpdu_get_addr3)(uint8_t *buf, uint8_t *mac_addr);
952 	QDF_STATUS
953 		(*hal_rx_mpdu_get_addr4)(uint8_t *buf, uint8_t *mac_addr);
954 	uint8_t (*hal_rx_get_mpdu_sequence_control_valid)(uint8_t *buf);
955 	bool (*hal_rx_is_unicast)(uint8_t *buf);
956 	uint32_t (*hal_rx_tid_get)(hal_soc_handle_t hal_soc_hdl, uint8_t *buf);
957 	uint32_t (*hal_rx_hw_desc_get_ppduid_get)(void *rx_tlv_hdr,
958 						  void *rxdma_dst_ring_desc);
959 	uint32_t (*hal_rx_mpdu_start_mpdu_qos_control_valid_get)(uint8_t *buf);
960 	uint32_t (*hal_rx_msdu_end_sa_sw_peer_id_get)(uint8_t *buf);
961 	void * (*hal_rx_msdu0_buffer_addr_lsb)(void *link_desc_addr);
962 	void * (*hal_rx_msdu_desc_info_ptr_get)(void *msdu0);
963 	void * (*hal_ent_mpdu_desc_info)(void *hw_addr);
964 	void * (*hal_dst_mpdu_desc_info)(void *hw_addr);
965 	uint8_t (*hal_rx_get_fc_valid)(uint8_t *buf);
966 	uint8_t (*hal_rx_get_to_ds_flag)(uint8_t *buf);
967 	uint8_t (*hal_rx_get_mac_addr2_valid)(uint8_t *buf);
968 	uint8_t (*hal_rx_get_filter_category)(uint8_t *buf);
969 	uint32_t (*hal_rx_get_ppdu_id)(uint8_t *buf);
970 	void (*hal_reo_config)(struct hal_soc *soc,
971 			       uint32_t reg_val,
972 			       struct hal_reo_params *reo_params);
973 	uint32_t (*hal_rx_msdu_flow_idx_get)(uint8_t *buf);
974 	bool (*hal_rx_msdu_flow_idx_invalid)(uint8_t *buf);
975 	bool (*hal_rx_msdu_flow_idx_timeout)(uint8_t *buf);
976 	uint32_t (*hal_rx_msdu_fse_metadata_get)(uint8_t *buf);
977 	bool (*hal_rx_msdu_cce_match_get)(uint8_t *buf);
978 	uint16_t (*hal_rx_msdu_cce_metadata_get)(uint8_t *buf);
979 	void
980 	    (*hal_rx_msdu_get_flow_params)(
981 					  uint8_t *buf,
982 					  bool *flow_invalid,
983 					  bool *flow_timeout,
984 					  uint32_t *flow_index);
985 	uint16_t (*hal_rx_tlv_get_tcp_chksum)(uint8_t *buf);
986 	uint16_t (*hal_rx_get_rx_sequence)(uint8_t *buf);
987 	void (*hal_rx_get_bb_info)(void *rx_tlv, void *ppdu_info_handle);
988 	void (*hal_rx_get_rtt_info)(void *rx_tlv, void *ppdu_info_handle);
989 	void (*hal_rx_msdu_packet_metadata_get)(uint8_t *buf,
990 						void *msdu_pkt_metadata);
991 	uint16_t (*hal_rx_get_fisa_cumulative_l4_checksum)(uint8_t *buf);
992 	uint16_t (*hal_rx_get_fisa_cumulative_ip_length)(uint8_t *buf);
993 	bool (*hal_rx_get_udp_proto)(uint8_t *buf);
994 	bool (*hal_rx_get_fisa_flow_agg_continuation)(uint8_t *buf);
995 	uint8_t (*hal_rx_get_fisa_flow_agg_count)(uint8_t *buf);
996 	bool (*hal_rx_get_fisa_timeout)(uint8_t *buf);
997 	uint8_t (*hal_rx_mpdu_start_tlv_tag_valid)(void *rx_tlv_hdr);
998 	void (*hal_rx_sw_mon_desc_info_get)(hal_ring_desc_t rxdma_dst_ring_desc,
999 					    hal_rx_mon_desc_info_t mon_desc_info);
1000 	uint8_t (*hal_rx_wbm_err_msdu_continuation_get)(void *ring_desc);
1001 	uint32_t (*hal_rx_msdu_end_offset_get)(void);
1002 	uint32_t (*hal_rx_attn_offset_get)(void);
1003 	uint32_t (*hal_rx_msdu_start_offset_get)(void);
1004 	uint32_t (*hal_rx_mpdu_start_offset_get)(void);
1005 	uint32_t (*hal_rx_mpdu_end_offset_get)(void);
1006 	uint32_t (*hal_rx_pkt_tlv_offset_get)(void);
1007 	void * (*hal_rx_flow_setup_fse)(uint8_t *rx_fst,
1008 					uint32_t table_offset,
1009 					uint8_t *rx_flow);
1010 	void * (*hal_rx_flow_get_tuple_info)(uint8_t *rx_fst,
1011 					     uint32_t hal_hash,
1012 					     uint8_t *tuple_info);
1013 	QDF_STATUS (*hal_rx_flow_delete_entry)(uint8_t *fst,
1014 					       void *fse);
1015 	uint32_t (*hal_rx_fst_get_fse_size)(void);
1016 	void (*hal_compute_reo_remap_ix2_ix3)(uint32_t *ring,
1017 					      uint32_t num_rings,
1018 					      uint32_t *remap1,
1019 					      uint32_t *remap2);
1020 	void (*hal_compute_reo_remap_ix0)(uint32_t *remap0);
1021 	uint32_t (*hal_rx_flow_setup_cmem_fse)(
1022 				struct hal_soc *soc, uint32_t cmem_ba,
1023 				uint32_t table_offset, uint8_t *rx_flow);
1024 	uint32_t (*hal_rx_flow_get_cmem_fse_ts)(struct hal_soc *soc,
1025 						uint32_t fse_offset);
1026 	void (*hal_rx_flow_get_cmem_fse)(struct hal_soc *soc,
1027 					 uint32_t fse_offset,
1028 					 uint32_t *fse, qdf_size_t len);
1029 
1030 	void (*hal_cmem_write)(hal_soc_handle_t hal_soc_hdl, uint32_t offset,
1031 			       uint32_t value);
1032 
1033 	void (*hal_rx_msdu_get_reo_destination_indication)(uint8_t *buf,
1034 							   uint32_t *reo_destination_indication);
1035 	uint8_t (*hal_tx_get_num_tcl_banks)(void);
1036 	uint32_t (*hal_get_reo_qdesc_size)(uint32_t ba_window_size, int tid);
1037 	uint16_t (*hal_get_rx_max_ba_window)(int tid);
1038 
1039 	void (*hal_set_link_desc_addr)(void *desc, uint32_t cookie,
1040 				       qdf_dma_addr_t link_desc_paddr,
1041 				       uint8_t bm_id);
1042 	void (*hal_tx_init_data_ring)(hal_soc_handle_t hal_soc_hdl,
1043 				      hal_ring_handle_t hal_ring_hdl);
1044 	void* (*hal_rx_msdu_ext_desc_info_get_ptr)(void *msdu_details_ptr);
1045 	void (*hal_get_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
1046 					 uint8_t ac, uint32_t *value);
1047 	void (*hal_set_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
1048 					 uint8_t ac, uint32_t value);
1049 	uint32_t (*hal_get_reo_reg_base_offset)(void);
1050 	void (*hal_rx_get_tlv_size)(uint16_t *rx_pkt_tlv_size,
1051 				    uint16_t *rx_mon_pkt_tlv_size);
1052 	uint32_t (*hal_rx_msdu_is_wlan_mcast)(qdf_nbuf_t nbuf);
1053 	uint32_t (*hal_rx_tlv_decap_format_get)(void *hw_desc_addr);
1054 	void (*hal_rx_dump_pkt_tlvs)(hal_soc_handle_t hal_soc_hdl,
1055 				     uint8_t *buf, uint8_t dbg_level);
1056 	int (*hal_rx_tlv_get_offload_info)(uint8_t *rx_tlv,
1057 					   struct hal_offload_info *offload_info);
1058 	uint16_t (*hal_rx_tlv_phy_ppdu_id_get)(uint8_t *buf);
1059 	uint32_t (*hal_rx_tlv_msdu_done_get)(uint8_t *buf);
1060 	uint32_t (*hal_rx_tlv_msdu_len_get)(uint8_t *buf);
1061 	uint16_t (*hal_rx_get_frame_ctrl_field)(uint8_t *buf);
1062 	int (*hal_rx_get_proto_params)(uint8_t *buf, void *fisa_params);
1063 	int (*hal_rx_get_l3_l4_offsets)(uint8_t *buf, uint32_t *l3_hdr_offset,
1064 					uint32_t *l4_hdr_offset);
1065 	uint32_t (*hal_rx_tlv_mic_err_get)(uint8_t *buf);
1066 	uint32_t (*hal_rx_tlv_get_pkt_type)(uint8_t *buf);
1067 	void (*hal_rx_tlv_get_pn_num)(uint8_t *buf, uint64_t *pn_num);
1068 	void (*hal_rx_reo_prev_pn_get)(void *ring_desc, uint64_t *prev_pn);
1069 	uint8_t * (*hal_rx_pkt_hdr_get)(uint8_t *buf);
1070 	uint32_t (*hal_rx_msdu_reo_dst_ind_get)(hal_soc_handle_t hal_soc_hdl,
1071 						void *msdu_link_desc);
1072 	void (*hal_msdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
1073 				       void *msdu_desc_info, uint32_t dst_ind,
1074 				       uint32_t nbuf_len);
1075 	void (*hal_mpdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
1076 				       void *mpdu_desc_info, uint32_t seq_no);
1077 	uint32_t (*hal_rx_tlv_sgi_get)(uint8_t *buf);
1078 	uint32_t (*hal_rx_tlv_get_freq)(uint8_t *buf);
1079 	uint8_t (*hal_rx_msdu_get_keyid)(uint8_t *buf);
1080 	uint32_t (*hal_rx_tlv_rate_mcs_get)(uint8_t *buf);
1081 	uint32_t (*hal_rx_tlv_decrypt_err_get)(uint8_t *buf);
1082 	uint32_t (*hal_rx_tlv_first_mpdu_get)(uint8_t *buf);
1083 	uint32_t (*hal_rx_tlv_bw_get)(uint8_t *buf);
1084 	uint32_t (*hal_rx_tlv_get_is_decrypted)(uint8_t *buf);
1085 
1086 	uint32_t (*hal_rx_wbm_err_src_get)(hal_ring_desc_t ring_desc);
1087 	uint8_t (*hal_rx_ret_buf_manager_get)(hal_ring_desc_t ring_desc);
1088 	void (*hal_rx_msdu_link_desc_set)(hal_soc_handle_t hal_soc_hdl,
1089 					  void *src_srng_desc,
1090 					  hal_buff_addrinfo_t buf_addr_info,
1091 					  uint8_t bm_action);
1092 
1093 	void (*hal_rx_buf_cookie_rbm_get)(uint32_t *buf_addr_info_hdl,
1094 					  hal_buf_info_t buf_info_hdl);
1095 	void (*hal_rx_reo_buf_paddr_get)(hal_ring_desc_t rx_desc,
1096 					 struct hal_buf_info *buf_info);
1097 	void (*hal_rxdma_buff_addr_info_set)(void *rxdma_entry,
1098 					     qdf_dma_addr_t paddr,
1099 					     uint32_t cookie, uint8_t manager);
1100 	uint32_t (*hal_rx_msdu_flags_get)(rx_msdu_desc_info_t msdu_desc_info_hdl);
1101 	uint32_t (*hal_rx_get_reo_error_code)(hal_ring_desc_t rx_desc);
1102 	void (*hal_rx_tlv_csum_err_get)(uint8_t *rx_tlv_hdr,
1103 					uint32_t *ip_csum_err,
1104 					uint32_t *tcp_udp_csum_err);
1105 	void (*hal_rx_mpdu_desc_info_get)(void *desc_addr,
1106 					  void *mpdu_desc_info_hdl);
1107 	uint8_t (*hal_rx_err_status_get)(hal_ring_desc_t rx_desc);
1108 	uint8_t (*hal_rx_reo_buf_type_get)(hal_ring_desc_t rx_desc);
1109 	bool (*hal_rx_mpdu_info_ampdu_flag_get)(uint8_t *buf);
1110 	uint32_t (*hal_rx_tlv_mpdu_len_err_get)(void *hw_desc_addr);
1111 	uint32_t (*hal_rx_tlv_mpdu_fcs_err_get)(void *hw_desc_addr);
1112 	void (*hal_rx_tlv_get_pkt_capture_flags)(uint8_t *rx_tlv_hdr,
1113 						 struct hal_rx_pkt_capture_flags *flags);
1114 	uint8_t *(*hal_rx_desc_get_80211_hdr)(void *hw_desc_addr);
1115 	uint32_t (*hal_rx_hw_desc_mpdu_user_id)(void *hw_desc_addr);
1116 	void (*hal_rx_priv_info_set_in_tlv)(uint8_t *buf,
1117 					    uint8_t *priv_data,
1118 					    uint32_t len);
1119 	void (*hal_rx_priv_info_get_from_tlv)(uint8_t *buf,
1120 					      uint8_t *priv_data,
1121 					      uint32_t len);
1122 	void (*hal_rx_tlv_msdu_len_set)(uint8_t *buf, uint32_t len);
1123 	void (*hal_rx_tlv_populate_mpdu_desc_info)(uint8_t *buf,
1124 						   void *mpdu_desc_info_hdl);
1125 	uint8_t *(*hal_get_reo_ent_desc_qdesc_addr)(uint8_t *desc);
1126 	uint64_t (*hal_rx_get_qdesc_addr)(uint8_t *dst_ring_desc,
1127 					  uint8_t *buf);
1128 	void (*hal_set_reo_ent_desc_reo_dest_ind)(uint8_t *desc,
1129 						  uint32_t dst_ind);
1130 
1131 	/* REO CMD and STATUS */
1132 	int (*hal_reo_send_cmd)(hal_soc_handle_t hal_soc_hdl,
1133 				hal_ring_handle_t  hal_ring_hdl,
1134 				enum hal_reo_cmd_type cmd,
1135 				void *params);
1136 	QDF_STATUS (*hal_reo_status_update)(hal_soc_handle_t hal_soc_hdl,
1137 					    hal_ring_desc_t reo_desc,
1138 					    void *st_handle,
1139 					    uint32_t tlv, int *num_ref);
1140 	uint8_t (*hal_get_tlv_hdr_size)(void);
1141 	uint8_t (*hal_get_idle_link_bm_id)(uint8_t chip_id);
1142 
1143 	bool (*hal_txmon_is_mon_buf_addr_tlv)(void *tx_tlv_hdr);
1144 	void (*hal_txmon_populate_packet_info)(void *tx_tlv_hdr,
1145 					       void *pkt_info);
1146 	/* TX MONITOR */
1147 #ifdef QCA_MONITOR_2_0_SUPPORT
1148 	uint32_t (*hal_txmon_status_parse_tlv)(void *data_ppdu_info,
1149 					       void *prot_ppdu_info,
1150 					       void *data_status_info,
1151 					       void *prot_status_info,
1152 					       void *tx_tlv_hdr,
1153 					       qdf_frag_t status_frag);
1154 	uint32_t (*hal_txmon_status_get_num_users)(void *tx_tlv_hdr,
1155 						   uint8_t *num_users);
1156 #endif /* QCA_MONITOR_2_0_SUPPORT */
1157 	void (*hal_reo_shared_qaddr_setup)(hal_soc_handle_t hal_soc_hdl);
1158 	void (*hal_reo_shared_qaddr_init)(hal_soc_handle_t hal_soc_hdl);
1159 	void (*hal_reo_shared_qaddr_detach)(hal_soc_handle_t hal_soc_hdl);
1160 	void (*hal_reo_shared_qaddr_write)(hal_soc_handle_t hal_soc_hdl,
1161 					   uint16_t peer_id,
1162 					   int tid,
1163 					   qdf_dma_addr_t hw_qdesc_paddr);
1164 #ifdef WLAN_FEATURE_MARK_FIRST_WAKEUP_PACKET
1165 	uint8_t (*hal_get_first_wow_wakeup_packet)(uint8_t *buf);
1166 #endif
1167 	void (*hal_reo_shared_qaddr_cache_clear)(hal_soc_handle_t hal_soc_hdl);
1168 	uint32_t (*hal_rx_tlv_l3_type_get)(uint8_t *buf);
1169 	void (*hal_tx_vdev_mismatch_routing_set)(hal_soc_handle_t hal_soc_hdl,
1170 			enum hal_tx_vdev_mismatch_notify config);
1171 	void (*hal_tx_mcast_mlo_reinject_routing_set)(
1172 			hal_soc_handle_t hal_soc_hdl,
1173 			enum hal_tx_mcast_mlo_reinject_notify config);
1174 	void (*hal_cookie_conversion_reg_cfg_be)(hal_soc_handle_t hal_soc_hdl,
1175 						 struct hal_hw_cc_config
1176 						 *cc_cfg);
1177 	void (*hal_tx_populate_bank_register)(hal_soc_handle_t hal_soc_hdl,
1178 					      union hal_tx_bank_config *config,
1179 					      uint8_t bank_id);
1180 	void (*hal_tx_vdev_mcast_ctrl_set)(hal_soc_handle_t hal_soc_hdl,
1181 					   uint8_t vdev_id,
1182 					   uint8_t mcast_ctrl_val);
1183 };
1184 
1185 /**
1186  * struct hal_soc_stats - Hal layer stats
1187  * @reg_write_fail: number of failed register writes
1188  * @wstats: delayed register write stats
1189  * @shadow_reg_write_fail: shadow reg write failure stats
1190  * @shadow_reg_write_succ: shadow reg write success stats
1191  *
1192  * This structure holds all the statistics at HAL layer.
1193  */
1194 struct hal_soc_stats {
1195 	uint32_t reg_write_fail;
1196 #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
1197 	struct hal_reg_write_soc_stats wstats;
1198 #endif
1199 #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
1200 	uint32_t shadow_reg_write_fail;
1201 	uint32_t shadow_reg_write_succ;
1202 #endif
1203 };
1204 
1205 #ifdef ENABLE_HAL_REG_WR_HISTORY
1206 /* The history size should always be a power of 2 */
1207 #define HAL_REG_WRITE_HIST_SIZE 8
1208 
1209 /**
1210  * struct hal_reg_write_fail_entry - Record of
1211  *		register write which failed.
1212  * @timestamp: timestamp of reg write failure
1213  * @reg_offset: offset of register where the write failed
1214  * @write_val: the value which was to be written
1215  * @read_val: the value read back from the register after write
1216  */
1217 struct hal_reg_write_fail_entry {
1218 	uint64_t timestamp;
1219 	uint32_t reg_offset;
1220 	uint32_t write_val;
1221 	uint32_t read_val;
1222 };
1223 
1224 /**
1225  * struct hal_reg_write_fail_history - Hal layer history
1226  *		of all the register write failures.
1227  * @index: index to add the new record
1228  * @record: array of all the records in history
1229  *
1230  * This structure holds the history of register write
1231  * failures at HAL layer.
1232  */
1233 struct hal_reg_write_fail_history {
1234 	qdf_atomic_t index;
1235 	struct hal_reg_write_fail_entry record[HAL_REG_WRITE_HIST_SIZE];
1236 };
1237 #endif
1238 
1239 /**
1240  * struct reo_queue_ref_table - Reo qref LUT addr
1241  * @mlo_reo_qref_table_vaddr: MLO table vaddr
1242  * @non_mlo_reo_qref_table_vaddr: Non MLO table vaddr
1243  * @mlo_reo_qref_table_paddr: MLO table paddr
1244  * @non_mlo_reo_qref_table_paddr: Non MLO table paddr
1245  * @reo_qref_table_en: Enable flag
1246  */
1247 struct reo_queue_ref_table {
1248 	uint64_t *mlo_reo_qref_table_vaddr;
1249 	uint64_t *non_mlo_reo_qref_table_vaddr;
1250 	qdf_dma_addr_t mlo_reo_qref_table_paddr;
1251 	qdf_dma_addr_t non_mlo_reo_qref_table_paddr;
1252 	uint8_t reo_qref_table_en;
1253 };
1254 
1255 /**
1256  * union hal_shadow_reg_cfg - Shadow register config
1257  * @addr: Place holder where shadow address is saved
1258  * @v2: shadow config v2 format
1259  * @v3: shadow config v3 format
1260  */
1261 union hal_shadow_reg_cfg {
1262 	uint32_t addr;
1263 	struct pld_shadow_reg_v2_cfg v2;
1264 #ifdef CONFIG_SHADOW_V3
1265 	struct pld_shadow_reg_v3_cfg v3;
1266 #endif
1267 };
1268 
1269 /**
1270  * struct hal_soc - HAL context to be used to access SRNG APIs
1271  *		    (currently used by data path and
1272  *		    transport (CE) modules)
1273  * @list_shadow_reg_config: array of generic regs mapped to
1274  *			    shadow regs
1275  * @num_generic_shadow_regs_configured: number of generic regs
1276  *					mapped to shadow regs
1277  */
1278 struct hal_soc {
1279 	/* HIF handle to access HW registers */
1280 	struct hif_opaque_softc *hif_handle;
1281 
1282 	/* QDF device handle */
1283 	qdf_device_t qdf_dev;
1284 
1285 	/* Device base address */
1286 	void *dev_base_addr;
1287 	/* Device base address for ce - qca5018 target */
1288 	void *dev_base_addr_ce;
1289 
1290 	/* HAL internal state for all SRNG rings.
1291 	 * TODO: See if this is required
1292 	 */
1293 	struct hal_srng srng_list[HAL_SRNG_ID_MAX];
1294 
1295 	/* Remote pointer memory for HW/FW updates */
1296 	uint32_t *shadow_rdptr_mem_vaddr;
1297 	qdf_dma_addr_t shadow_rdptr_mem_paddr;
1298 
1299 	/* Shared memory for ring pointer updates from host to FW */
1300 	uint32_t *shadow_wrptr_mem_vaddr;
1301 	qdf_dma_addr_t shadow_wrptr_mem_paddr;
1302 
1303 	/* REO blocking resource index */
1304 	uint8_t reo_res_bitmap;
1305 	uint8_t index;
1306 	uint32_t target_type;
1307 	uint32_t version;
1308 
1309 	/* shadow register configuration */
1310 	union hal_shadow_reg_cfg shadow_config[MAX_SHADOW_REGISTERS];
1311 	int num_shadow_registers_configured;
1312 	bool use_register_windowing;
1313 	uint32_t register_window;
1314 	qdf_spinlock_t register_access_lock;
1315 
1316 	/* Static window map configuration for multiple window write*/
1317 	bool static_window_map;
1318 
1319 	/* srng table */
1320 	struct hal_hw_srng_config *hw_srng_table;
1321 	int32_t hal_hw_reg_offset[SRNG_REGISTER_MAX];
1322 	struct hal_hw_txrx_ops *ops;
1323 
1324 	/* Indicate srngs initialization */
1325 	bool init_phase;
1326 	/* Hal level stats */
1327 	struct hal_soc_stats stats;
1328 #ifdef ENABLE_HAL_REG_WR_HISTORY
1329 	struct hal_reg_write_fail_history *reg_wr_fail_hist;
1330 #endif
1331 #ifdef FEATURE_HAL_DELAYED_REG_WRITE
1332 	/* queue(array) to hold register writes */
1333 	struct hal_reg_write_q_elem *reg_write_queue;
1334 	/* delayed work to be queued into workqueue */
1335 	qdf_work_t reg_write_work;
1336 	/* workqueue for delayed register writes */
1337 	qdf_workqueue_t *reg_write_wq;
1338 	/* write index used by caller to enqueue delayed work */
1339 	qdf_atomic_t write_idx;
1340 	/* read index used by worker thread to dequeue/write registers */
1341 	uint32_t read_idx;
1342 #endif /*FEATURE_HAL_DELAYED_REG_WRITE */
1343 	qdf_atomic_t active_work_cnt;
1344 #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
1345 	struct shadow_reg_config
1346 		list_shadow_reg_config[MAX_GENERIC_SHADOW_REG];
1347 	int num_generic_shadow_regs_configured;
1348 #endif
1349 	/* flag to indicate cmn dmac rings in berryllium */
1350 	bool dmac_cmn_src_rxbuf_ring;
1351 	/* Reo queue ref table items */
1352 	struct reo_queue_ref_table reo_qref;
1353 };
1354 
1355 #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
1356 /**
1357  *  hal_delayed_reg_write() - delayed regiter write
1358  * @hal_soc: HAL soc handle
1359  * @srng: hal srng
1360  * @addr: iomem address
1361  * @value: value to be written
1362  *
1363  * Return: none
1364  */
1365 void hal_delayed_reg_write(struct hal_soc *hal_soc,
1366 			   struct hal_srng *srng,
1367 			   void __iomem *addr,
1368 			   uint32_t value);
1369 #endif
1370 
1371 void hal_qca6750_attach(struct hal_soc *hal_soc);
1372 void hal_qca6490_attach(struct hal_soc *hal_soc);
1373 void hal_qca6390_attach(struct hal_soc *hal_soc);
1374 void hal_qca6290_attach(struct hal_soc *hal_soc);
1375 void hal_qca8074_attach(struct hal_soc *hal_soc);
1376 void hal_kiwi_attach(struct hal_soc *hal_soc);
1377 void hal_qcn9224v1_attach(struct hal_soc *hal_soc);
1378 void hal_qcn9224v2_attach(struct hal_soc *hal_soc);
1379 /*
1380  * hal_soc_to_dp_hal_roc - API to convert hal_soc to opaque
1381  * dp_hal_soc handle type
1382  * @hal_soc - hal_soc type
1383  *
1384  * Return: hal_soc_handle_t type
1385  */
1386 static inline
1387 hal_soc_handle_t hal_soc_to_hal_soc_handle(struct hal_soc *hal_soc)
1388 {
1389 	return (hal_soc_handle_t)hal_soc;
1390 }
1391 
1392 /*
1393  * hal_srng_to_hal_ring_handle - API to convert hal_srng to opaque
1394  * dp_hal_ring handle type
1395  * @hal_srng - hal_srng type
1396  *
1397  * Return: hal_ring_handle_t type
1398  */
1399 static inline
1400 hal_ring_handle_t hal_srng_to_hal_ring_handle(struct hal_srng *hal_srng)
1401 {
1402 	return (hal_ring_handle_t)hal_srng;
1403 }
1404 
1405 /*
1406  * hal_ring_handle_to_hal_srng - API to convert dp_hal_ring to hal_srng handle
1407  * @hal_ring - hal_ring_handle_t type
1408  *
1409  * Return: hal_srng pointer type
1410  */
1411 static inline
1412 struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring)
1413 {
1414 	return (struct hal_srng *)hal_ring;
1415 }
1416 
1417 /* Size of REO queue reference table in Host
1418  * 2k peers * 17 tids * 8bytes(rx_reo_queue_reference)
1419  * = 278528 bytes
1420  */
1421 #define REO_QUEUE_REF_NON_ML_TABLE_SIZE 278528
1422 /* Calculated based on 512 MLO peers */
1423 #define REO_QUEUE_REF_ML_TABLE_SIZE 69632
1424 #define HAL_ML_PEER_ID_START 0x2000
1425 #define HAL_PEER_ID_IS_MLO(peer_id) ((peer_id) & HAL_ML_PEER_ID_START)
1426 
1427 /*
1428  * REO2PPE destination indication
1429  */
1430 #define REO2PPE_DST_IND 11
1431 
1432 /**
1433  * enum hal_pkt_type - Type of packet type reported by HW
1434  * @HAL_DOT11A: 802.11a PPDU type
1435  * @HAL_DOT11B: 802.11b PPDU type
1436  * @HAL_DOT11N_MM: 802.11n Mixed Mode PPDU type
1437  * @HAL_DOT11AC: 802.11ac PPDU type
1438  * @HAL_DOT11AX: 802.11ax PPDU type
1439  * @HAL_DOT11BA: 802.11ba (WUR) PPDU type
1440  * @HAL_DOT11BE: 802.11be PPDU type
1441  * @HAL_DOT11AZ: 802.11az (ranging) PPDU type
1442  * @HAL_DOT11N_GF: 802.11n Green Field PPDU type
1443  *
1444  * Enum indicating the packet type reported by HW in rx_pkt_tlvs (RX data)
1445  * or WBM2SW ring entry's descriptor (TX data completion)
1446  */
1447 enum hal_pkt_type {
1448 	HAL_DOT11A = 0,
1449 	HAL_DOT11B = 1,
1450 	HAL_DOT11N_MM = 2,
1451 	HAL_DOT11AC = 3,
1452 	HAL_DOT11AX = 4,
1453 	HAL_DOT11BA = 5,
1454 	HAL_DOT11BE = 6,
1455 	HAL_DOT11AZ = 7,
1456 	HAL_DOT11N_GF = 8,
1457 	HAL_DOT11_MAX,
1458 };
1459 
1460 #endif /* _HAL_INTERNAL_H_ */
1461