hal_internal.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HAL_INTERNAL_H_
  19. #define _HAL_INTERNAL_H_
  20. #include "qdf_types.h"
  21. #include "qdf_atomic.h"
  22. #include "qdf_lock.h"
  23. #include "qdf_mem.h"
  24. #include "qdf_nbuf.h"
  25. #include "pld_common.h"
  26. #if defined(FEATURE_HAL_DELAYED_REG_WRITE) || \
  27. defined(FEATURE_HAL_DELAYED_REG_WRITE_V2)
  28. #include "qdf_defer.h"
  29. #include "qdf_timer.h"
  30. #endif
  31. #define hal_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_HAL, params)
  32. #define hal_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_HAL, params)
  33. #define hal_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_HAL, params)
  34. #define hal_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_HAL, params)
  35. #define hal_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params)
  36. #define hal_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_HAL, params)
  37. #define hal_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_HAL, params)
  38. #define hal_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_HAL, params)
  39. #define hal_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_HAL, params)
  40. #define hal_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_HAL, params)
  41. #ifdef ENABLE_VERBOSE_DEBUG
  42. extern bool is_hal_verbose_debug_enabled;
  43. #define hal_verbose_debug(params...) \
  44. if (unlikely(is_hal_verbose_debug_enabled)) \
  45. do {\
  46. QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params); \
  47. } while (0)
  48. #define hal_verbose_hex_dump(params...) \
  49. if (unlikely(is_hal_verbose_debug_enabled)) \
  50. do {\
  51. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HAL, \
  52. QDF_TRACE_LEVEL_DEBUG, \
  53. params); \
  54. } while (0)
  55. #else
  56. #define hal_verbose_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params)
  57. #define hal_verbose_hex_dump(params...) \
  58. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HAL, QDF_TRACE_LEVEL_DEBUG, \
  59. params)
  60. #endif
  61. /*
  62. * Given the offset of a field in bytes, returns uint8_t *
  63. */
  64. #define _OFFSET_TO_BYTE_PTR(_ptr, _off_in_bytes) \
  65. (((uint8_t *)(_ptr)) + (_off_in_bytes))
  66. /*
  67. * Given the offset of a field in bytes, returns uint32_t *
  68. */
  69. #define _OFFSET_TO_WORD_PTR(_ptr, _off_in_bytes) \
  70. (((uint32_t *)(_ptr)) + ((_off_in_bytes) >> 2))
  71. /*
  72. * Given the offset of a field in bytes, returns uint64_t *
  73. */
  74. #define _OFFSET_TO_QWORD_PTR(_ptr, _off_in_bytes) \
  75. (((uint64_t *)(_ptr)) + ((_off_in_bytes) >> 3))
  76. #define _HAL_MS(_word, _mask, _shift) \
  77. (((_word) & (_mask)) >> (_shift))
  78. /*
  79. * Get number of QWORDS possible for num.
  80. * Its the caller's duty to make sure num is a multiple of QWORD (8)
  81. */
  82. #define HAL_GET_NUM_QWORDS(num) ((num) >> 3)
  83. /*
  84. * Get number of DWORDS possible for num.
  85. * Its the caller's duty to make sure num is a multiple of DWORD (8)
  86. */
  87. #define HAL_GET_NUM_DWORDS(num) ((num) >> 2)
  88. /*
  89. * dp_hal_soc - opaque handle for DP HAL soc
  90. */
  91. struct hal_soc_handle;
  92. typedef struct hal_soc_handle *hal_soc_handle_t;
  93. /**
  94. * hal_ring_desc - opaque handle for DP ring descriptor
  95. */
  96. struct hal_ring_desc;
  97. typedef struct hal_ring_desc *hal_ring_desc_t;
  98. /**
  99. * hal_link_desc - opaque handle for DP link descriptor
  100. */
  101. struct hal_link_desc;
  102. typedef struct hal_link_desc *hal_link_desc_t;
  103. /**
  104. * hal_rxdma_desc - opaque handle for DP rxdma dst ring descriptor
  105. */
  106. struct hal_rxdma_desc;
  107. typedef struct hal_rxdma_desc *hal_rxdma_desc_t;
  108. /**
  109. * hal_buff_addrinfo - opaque handle for DP buffer address info
  110. */
  111. struct hal_buff_addrinfo;
  112. typedef struct hal_buff_addrinfo *hal_buff_addrinfo_t;
  113. /**
  114. * hal_rx_mon_desc_info - opaque handle for sw monitor ring desc info
  115. */
  116. struct hal_rx_mon_desc_info;
  117. typedef struct hal_rx_mon_desc_info *hal_rx_mon_desc_info_t;
  118. struct hal_buf_info;
  119. typedef struct hal_buf_info *hal_buf_info_t;
  120. struct rx_msdu_desc_info;
  121. typedef struct rx_msdu_desc_info *rx_msdu_desc_info_t;
  122. /* TBD: This should be movded to shared HW header file */
  123. enum hal_srng_ring_id {
  124. /* UMAC rings */
  125. HAL_SRNG_REO2SW0 = 0,
  126. HAL_SRNG_REO2SW1 = 1,
  127. HAL_SRNG_REO2SW2 = 2,
  128. HAL_SRNG_REO2SW3 = 3,
  129. HAL_SRNG_REO2SW4 = 4,
  130. HAL_SRNG_REO2SW5 = 5,
  131. HAL_SRNG_REO2SW6 = 6,
  132. HAL_SRNG_REO2SW7 = 7,
  133. HAL_SRNG_REO2SW8 = 8,
  134. HAL_SRNG_REO2TCL = 9,
  135. HAL_SRNG_SW2REO = 10,
  136. HAL_SRNG_SW2REO1 = 11,
  137. HAL_SRNG_REO_CMD = 12,
  138. HAL_SRNG_REO_STATUS = 13,
  139. /* 14-15 unused */
  140. HAL_SRNG_SW2TCL1 = 16,
  141. HAL_SRNG_SW2TCL2 = 17,
  142. HAL_SRNG_SW2TCL3 = 18,
  143. HAL_SRNG_SW2TCL4 = 19, /* FW2TCL ring */
  144. HAL_SRNG_SW2TCL5 = 20,
  145. /* 20-23 unused */
  146. HAL_SRNG_SW2TCL_CMD = 24,
  147. HAL_SRNG_TCL_STATUS = 25,
  148. /* 26-31 unused */
  149. HAL_SRNG_CE_0_SRC = 32,
  150. HAL_SRNG_CE_1_SRC = 33,
  151. HAL_SRNG_CE_2_SRC = 34,
  152. HAL_SRNG_CE_3_SRC = 35,
  153. HAL_SRNG_CE_4_SRC = 36,
  154. HAL_SRNG_CE_5_SRC = 37,
  155. HAL_SRNG_CE_6_SRC = 38,
  156. HAL_SRNG_CE_7_SRC = 39,
  157. HAL_SRNG_CE_8_SRC = 40,
  158. HAL_SRNG_CE_9_SRC = 41,
  159. HAL_SRNG_CE_10_SRC = 42,
  160. HAL_SRNG_CE_11_SRC = 43,
  161. /* 44-55 unused */
  162. HAL_SRNG_CE_0_DST = 56,
  163. HAL_SRNG_CE_1_DST = 57,
  164. HAL_SRNG_CE_2_DST = 58,
  165. HAL_SRNG_CE_3_DST = 59,
  166. HAL_SRNG_CE_4_DST = 60,
  167. HAL_SRNG_CE_5_DST = 61,
  168. HAL_SRNG_CE_6_DST = 62,
  169. HAL_SRNG_CE_7_DST = 63,
  170. HAL_SRNG_CE_8_DST = 64,
  171. HAL_SRNG_CE_9_DST = 65,
  172. HAL_SRNG_CE_10_DST = 66,
  173. HAL_SRNG_CE_11_DST = 67,
  174. /* 68-79 unused */
  175. HAL_SRNG_CE_0_DST_STATUS = 80,
  176. HAL_SRNG_CE_1_DST_STATUS = 81,
  177. HAL_SRNG_CE_2_DST_STATUS = 82,
  178. HAL_SRNG_CE_3_DST_STATUS = 83,
  179. HAL_SRNG_CE_4_DST_STATUS = 84,
  180. HAL_SRNG_CE_5_DST_STATUS = 85,
  181. HAL_SRNG_CE_6_DST_STATUS = 86,
  182. HAL_SRNG_CE_7_DST_STATUS = 87,
  183. HAL_SRNG_CE_8_DST_STATUS = 88,
  184. HAL_SRNG_CE_9_DST_STATUS = 89,
  185. HAL_SRNG_CE_10_DST_STATUS = 90,
  186. HAL_SRNG_CE_11_DST_STATUS = 91,
  187. /* 92-103 unused */
  188. HAL_SRNG_WBM_IDLE_LINK = 104,
  189. HAL_SRNG_WBM_SW_RELEASE = 105,
  190. HAL_SRNG_WBM2SW0_RELEASE = 106,
  191. HAL_SRNG_WBM2SW1_RELEASE = 107,
  192. HAL_SRNG_WBM2SW2_RELEASE = 108,
  193. HAL_SRNG_WBM2SW3_RELEASE = 109,
  194. HAL_SRNG_WBM2SW4_RELEASE = 110,
  195. HAL_SRNG_WBM2SW5_RELEASE = 111,
  196. HAL_SRNG_WBM2SW6_RELEASE = 112,
  197. /* 113-127 unused */
  198. HAL_SRNG_UMAC_ID_END = 127,
  199. /* LMAC rings - The following set will be replicated for each LMAC */
  200. HAL_SRNG_LMAC1_ID_START = 128,
  201. HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 = HAL_SRNG_LMAC1_ID_START,
  202. #ifdef IPA_OFFLOAD
  203. HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 = (HAL_SRNG_LMAC1_ID_START + 1),
  204. HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 = (HAL_SRNG_LMAC1_ID_START + 2),
  205. HAL_SRNG_WMAC1_SW2RXDMA1_BUF = (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 + 1),
  206. #else
  207. HAL_SRNG_WMAC1_SW2RXDMA1_BUF = (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 + 1),
  208. #endif
  209. HAL_SRNG_WMAC1_SW2RXDMA2_BUF = (HAL_SRNG_WMAC1_SW2RXDMA1_BUF + 1),
  210. HAL_SRNG_WMAC1_SW2RXDMA0_STATBUF = (HAL_SRNG_WMAC1_SW2RXDMA2_BUF + 1),
  211. HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF =
  212. (HAL_SRNG_WMAC1_SW2RXDMA0_STATBUF + 1),
  213. HAL_SRNG_WMAC1_RXDMA2SW0 = (HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF + 1),
  214. HAL_SRNG_WMAC1_RXDMA2SW1 = (HAL_SRNG_WMAC1_RXDMA2SW0 + 1),
  215. HAL_SRNG_WMAC1_SW2RXDMA1_DESC = (HAL_SRNG_WMAC1_RXDMA2SW1 + 1),
  216. #ifdef WLAN_FEATURE_CIF_CFR
  217. HAL_SRNG_WIFI_POS_SRC_DMA_RING = (HAL_SRNG_WMAC1_SW2RXDMA1_DESC + 1),
  218. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING = (HAL_SRNG_WIFI_POS_SRC_DMA_RING + 1),
  219. #else
  220. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING = (HAL_SRNG_WMAC1_SW2RXDMA1_DESC + 1),
  221. #endif
  222. /* -142 unused */
  223. HAL_SRNG_LMAC1_ID_END = 143
  224. };
  225. /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */
  226. enum hal_ring_type {
  227. REO_DST = 0,
  228. REO_EXCEPTION = 1,
  229. REO_REINJECT = 2,
  230. REO_CMD = 3,
  231. REO_STATUS = 4,
  232. TCL_DATA = 5,
  233. TCL_CMD_CREDIT = 6,
  234. TCL_STATUS = 7,
  235. CE_SRC = 8,
  236. CE_DST = 9,
  237. CE_DST_STATUS = 10,
  238. WBM_IDLE_LINK = 11,
  239. SW2WBM_RELEASE = 12,
  240. WBM2SW_RELEASE = 13,
  241. RXDMA_BUF = 14,
  242. RXDMA_DST = 15,
  243. RXDMA_MONITOR_BUF = 16,
  244. RXDMA_MONITOR_STATUS = 17,
  245. RXDMA_MONITOR_DST = 18,
  246. RXDMA_MONITOR_DESC = 19,
  247. DIR_BUF_RX_DMA_SRC = 20,
  248. #ifdef WLAN_FEATURE_CIF_CFR
  249. WIFI_POS_SRC,
  250. #endif
  251. MAX_RING_TYPES
  252. };
  253. #define HAL_RXDMA_MAX_RING_SIZE 0xFFFF
  254. #define HAL_MAX_LMACS 3
  255. #define HAL_MAX_RINGS_PER_LMAC (HAL_SRNG_LMAC1_ID_END - HAL_SRNG_LMAC1_ID_START)
  256. #define HAL_MAX_LMAC_RINGS (HAL_MAX_LMACS * HAL_MAX_RINGS_PER_LMAC)
  257. #define HAL_SRNG_ID_MAX (HAL_SRNG_UMAC_ID_END + HAL_MAX_LMAC_RINGS)
  258. enum hal_srng_dir {
  259. HAL_SRNG_SRC_RING,
  260. HAL_SRNG_DST_RING
  261. };
  262. /**
  263. * enum hal_reo_remap_reg - REO remap registers
  264. * @HAL_REO_REMAP_REG_IX0: reo remap reg IX0
  265. * @HAL_REO_REMAP_REG_IX1: reo remap reg IX1
  266. * @HAL_REO_REMAP_REG_IX2: reo remap reg IX2
  267. * @HAL_REO_REMAP_REG_IX3: reo remap reg IX3
  268. */
  269. enum hal_reo_remap_reg {
  270. HAL_REO_REMAP_REG_IX0,
  271. HAL_REO_REMAP_REG_IX1,
  272. HAL_REO_REMAP_REG_IX2,
  273. HAL_REO_REMAP_REG_IX3
  274. };
  275. /* Lock wrappers for SRNG */
  276. #define hal_srng_lock_t qdf_spinlock_t
  277. #define SRNG_LOCK_INIT(_lock) qdf_spinlock_create(_lock)
  278. #define SRNG_LOCK(_lock) qdf_spin_lock_bh(_lock)
  279. #define SRNG_TRY_LOCK(_lock) qdf_spin_trylock_bh(_lock)
  280. #define SRNG_UNLOCK(_lock) qdf_spin_unlock_bh(_lock)
  281. #define SRNG_LOCK_DESTROY(_lock) qdf_spinlock_destroy(_lock)
  282. struct hal_soc;
  283. /**
  284. * dp_hal_ring - opaque handle for DP HAL SRNG
  285. */
  286. struct hal_ring_handle;
  287. typedef struct hal_ring_handle *hal_ring_handle_t;
  288. #define MAX_SRNG_REG_GROUPS 2
  289. /* Hal Srng bit mask
  290. * HAL_SRNG_FLUSH_EVENT: SRNG HP TP flush in case of link down
  291. */
  292. #define HAL_SRNG_FLUSH_EVENT BIT(0)
  293. #if defined(FEATURE_HAL_DELAYED_REG_WRITE) || \
  294. defined(FEATURE_HAL_DELAYED_REG_WRITE_V2)
  295. /**
  296. * struct hal_reg_write_q_elem - delayed register write queue element
  297. * @srng: hal_srng queued for a delayed write
  298. * @addr: iomem address of the register
  299. * @enqueue_val: register value at the time of delayed write enqueue
  300. * @dequeue_val: register value at the time of delayed write dequeue
  301. * @valid: whether this entry is valid or not
  302. * @enqueue_time: enqueue time (qdf_log_timestamp)
  303. * @work_scheduled_time: work scheduled time (qdf_log_timestamp)
  304. * @dequeue_time: dequeue time (qdf_log_timestamp)
  305. */
  306. struct hal_reg_write_q_elem {
  307. struct hal_srng *srng;
  308. void __iomem *addr;
  309. uint32_t enqueue_val;
  310. uint32_t dequeue_val;
  311. uint8_t valid;
  312. qdf_time_t enqueue_time;
  313. qdf_time_t work_scheduled_time;
  314. qdf_time_t dequeue_time;
  315. };
  316. /**
  317. * struct hal_reg_write_srng_stats - srng stats to keep track of register writes
  318. * @enqueues: writes enqueued to delayed work
  319. * @dequeues: writes dequeued from delayed work (not written yet)
  320. * @coalesces: writes not enqueued since srng is already queued up
  321. * @direct: writes not enqueued and written to register directly
  322. */
  323. struct hal_reg_write_srng_stats {
  324. uint32_t enqueues;
  325. uint32_t dequeues;
  326. uint32_t coalesces;
  327. uint32_t direct;
  328. };
  329. /**
  330. * enum hal_reg_sched_delay - ENUM for write sched delay histogram
  331. * @REG_WRITE_SCHED_DELAY_SUB_100us: index for delay < 100us
  332. * @REG_WRITE_SCHED_DELAY_SUB_1000us: index for delay < 1000us
  333. * @REG_WRITE_SCHED_DELAY_SUB_5000us: index for delay < 5000us
  334. * @REG_WRITE_SCHED_DELAY_GT_5000us: index for delay >= 5000us
  335. * @REG_WRITE_SCHED_DELAY_HIST_MAX: Max value (nnsize of histogram array)
  336. */
  337. enum hal_reg_sched_delay {
  338. REG_WRITE_SCHED_DELAY_SUB_100us,
  339. REG_WRITE_SCHED_DELAY_SUB_1000us,
  340. REG_WRITE_SCHED_DELAY_SUB_5000us,
  341. REG_WRITE_SCHED_DELAY_GT_5000us,
  342. REG_WRITE_SCHED_DELAY_HIST_MAX,
  343. };
  344. /**
  345. * struct hal_reg_write_soc_stats - soc stats to keep track of register writes
  346. * @enqueues: writes enqueued to delayed work
  347. * @dequeues: writes dequeued from delayed work (not written yet)
  348. * @coalesces: writes not enqueued since srng is already queued up
  349. * @direct: writes not enqueud and writted to register directly
  350. * @prevent_l1_fails: prevent l1 API failed
  351. * @q_depth: current queue depth in delayed register write queue
  352. * @max_q_depth: maximum queue for delayed register write queue
  353. * @sched_delay: = kernel work sched delay + bus wakeup delay, histogram
  354. */
  355. struct hal_reg_write_soc_stats {
  356. qdf_atomic_t enqueues;
  357. uint32_t dequeues;
  358. qdf_atomic_t coalesces;
  359. qdf_atomic_t direct;
  360. uint32_t prevent_l1_fails;
  361. qdf_atomic_t q_depth;
  362. uint32_t max_q_depth;
  363. uint32_t sched_delay[REG_WRITE_SCHED_DELAY_HIST_MAX];
  364. };
  365. #ifdef FEATURE_HAL_DELAYED_REG_WRITE_V2
  366. struct hal_reg_write_tcl_stats {
  367. uint32_t wq_delayed;
  368. uint32_t wq_direct;
  369. uint32_t timer_enq;
  370. uint32_t timer_direct;
  371. uint32_t enq_timer_set;
  372. uint32_t direct_timer_set;
  373. uint32_t timer_reset;
  374. qdf_time_t enq_time;
  375. qdf_time_t deq_time;
  376. uint32_t sched_delay[REG_WRITE_SCHED_DELAY_HIST_MAX];
  377. };
  378. #endif
  379. #endif
  380. struct hal_offload_info {
  381. uint8_t lro_eligible;
  382. uint8_t tcp_proto;
  383. uint8_t tcp_pure_ack;
  384. uint8_t ipv6_proto;
  385. uint8_t tcp_offset;
  386. uint16_t tcp_csum;
  387. uint16_t tcp_win;
  388. uint32_t tcp_seq_num;
  389. uint32_t tcp_ack_num;
  390. uint32_t flow_id;
  391. };
  392. /* Common SRNG ring structure for source and destination rings */
  393. struct hal_srng {
  394. /* Unique SRNG ring ID */
  395. uint8_t ring_id;
  396. /* Ring initialization done */
  397. uint8_t initialized;
  398. /* Interrupt/MSI value assigned to this ring */
  399. int irq;
  400. /* Physical base address of the ring */
  401. qdf_dma_addr_t ring_base_paddr;
  402. /* Virtual base address of the ring */
  403. uint32_t *ring_base_vaddr;
  404. /* Number of entries in ring */
  405. uint32_t num_entries;
  406. /* Ring size */
  407. uint32_t ring_size;
  408. /* Ring size mask */
  409. uint32_t ring_size_mask;
  410. /* Size of ring entry */
  411. uint32_t entry_size;
  412. /* Interrupt timer threshold – in micro seconds */
  413. uint32_t intr_timer_thres_us;
  414. /* Interrupt batch counter threshold – in number of ring entries */
  415. uint32_t intr_batch_cntr_thres_entries;
  416. /* Applicable only for CE dest ring */
  417. uint32_t prefetch_timer;
  418. /* MSI Address */
  419. qdf_dma_addr_t msi_addr;
  420. /* MSI data */
  421. uint32_t msi_data;
  422. /* Misc flags */
  423. uint32_t flags;
  424. /* Lock for serializing ring index updates */
  425. hal_srng_lock_t lock;
  426. /* Start offset of SRNG register groups for this ring
  427. * TBD: See if this is required - register address can be derived
  428. * from ring ID
  429. */
  430. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  431. /* Ring type/name */
  432. enum hal_ring_type ring_type;
  433. /* Source or Destination ring */
  434. enum hal_srng_dir ring_dir;
  435. union {
  436. struct {
  437. /* SW tail pointer */
  438. uint32_t tp;
  439. /* Shadow head pointer location to be updated by HW */
  440. uint32_t *hp_addr;
  441. /* Cached head pointer */
  442. uint32_t cached_hp;
  443. /* Tail pointer location to be updated by SW – This
  444. * will be a register address and need not be
  445. * accessed through SW structure */
  446. uint32_t *tp_addr;
  447. /* Current SW loop cnt */
  448. uint32_t loop_cnt;
  449. /* max transfer size */
  450. uint16_t max_buffer_length;
  451. } dst_ring;
  452. struct {
  453. /* SW head pointer */
  454. uint32_t hp;
  455. /* SW reap head pointer */
  456. uint32_t reap_hp;
  457. /* Shadow tail pointer location to be updated by HW */
  458. uint32_t *tp_addr;
  459. /* Cached tail pointer */
  460. uint32_t cached_tp;
  461. /* Head pointer location to be updated by SW – This
  462. * will be a register address and need not be accessed
  463. * through SW structure */
  464. uint32_t *hp_addr;
  465. /* Low threshold – in number of ring entries */
  466. uint32_t low_threshold;
  467. } src_ring;
  468. } u;
  469. struct hal_soc *hal_soc;
  470. /* Number of times hp/tp updated in runtime resume */
  471. uint32_t flush_count;
  472. /* hal srng event flag*/
  473. unsigned long srng_event;
  474. /* last flushed time stamp */
  475. uint64_t last_flush_ts;
  476. #if defined(FEATURE_HAL_DELAYED_REG_WRITE) || \
  477. defined(FEATURE_HAL_DELAYED_REG_WRITE_V2)
  478. /* Previous hp/tp (based on ring dir) value written to the reg */
  479. uint32_t last_reg_wr_val;
  480. /* flag to indicate whether srng is already queued for delayed write */
  481. uint8_t reg_write_in_progress;
  482. /* srng specific delayed write stats */
  483. struct hal_reg_write_srng_stats wstats;
  484. #endif
  485. };
  486. /* HW SRNG configuration table */
  487. struct hal_hw_srng_config {
  488. int start_ring_id;
  489. uint16_t max_rings;
  490. uint16_t entry_size;
  491. uint32_t reg_start[MAX_SRNG_REG_GROUPS];
  492. uint16_t reg_size[MAX_SRNG_REG_GROUPS];
  493. uint8_t lmac_ring;
  494. enum hal_srng_dir ring_dir;
  495. uint32_t max_size;
  496. };
  497. #define MAX_SHADOW_REGISTERS 40
  498. #define MAX_GENERIC_SHADOW_REG 5
  499. /**
  500. * struct shadow_reg_config - Hal soc structure that contains
  501. * the list of generic shadow registers
  502. * @target_register: target reg offset
  503. * @shadow_config_index: shadow config index in shadow config
  504. * list sent to FW
  505. * @va: virtual addr of shadow reg
  506. *
  507. * This structure holds the generic registers that are mapped to
  508. * the shadow region and holds the mapping of the target
  509. * register offset to shadow config index provided to FW during
  510. * init
  511. */
  512. struct shadow_reg_config {
  513. uint32_t target_register;
  514. int shadow_config_index;
  515. uint64_t va;
  516. };
  517. /* REO parameters to be passed to hal_reo_setup */
  518. struct hal_reo_params {
  519. /** rx hash steering enabled or disabled */
  520. bool rx_hash_enabled;
  521. /** reo remap 1 register */
  522. uint32_t remap1;
  523. /** reo remap 2 register */
  524. uint32_t remap2;
  525. /** fragment destination ring */
  526. uint8_t frag_dst_ring;
  527. /* Destination for alternate */
  528. uint8_t alt_dst_ind_0;
  529. /** padding */
  530. uint8_t padding[2];
  531. };
  532. /**
  533. * enum hal_reo_cmd_type: Enum for REO command type
  534. * @CMD_GET_QUEUE_STATS: Get REO queue status/stats
  535. * @CMD_FLUSH_QUEUE: Flush all frames in REO queue
  536. * @CMD_FLUSH_CACHE: Flush descriptor entries in the cache
  537. * @CMD_UNBLOCK_CACHE: Unblock a descriptor’s address that was blocked
  538. * earlier with a ‘REO_FLUSH_CACHE’ command
  539. * @CMD_FLUSH_TIMEOUT_LIST: Flush buffers/descriptors from timeout list
  540. * @CMD_UPDATE_RX_REO_QUEUE: Update REO queue settings
  541. */
  542. enum hal_reo_cmd_type {
  543. CMD_GET_QUEUE_STATS = 0,
  544. CMD_FLUSH_QUEUE = 1,
  545. CMD_FLUSH_CACHE = 2,
  546. CMD_UNBLOCK_CACHE = 3,
  547. CMD_FLUSH_TIMEOUT_LIST = 4,
  548. CMD_UPDATE_RX_REO_QUEUE = 5
  549. };
  550. struct hal_rx_pkt_capture_flags {
  551. uint8_t encrypt_type;
  552. uint8_t fragment_flag;
  553. uint8_t fcs_err;
  554. uint32_t chan_freq;
  555. uint32_t rssi_comb;
  556. uint64_t tsft;
  557. };
  558. struct hal_hw_txrx_ops {
  559. /* init and setup */
  560. void (*hal_srng_dst_hw_init)(struct hal_soc *hal,
  561. struct hal_srng *srng);
  562. void (*hal_srng_src_hw_init)(struct hal_soc *hal,
  563. struct hal_srng *srng);
  564. void (*hal_get_hw_hptp)(struct hal_soc *hal,
  565. hal_ring_handle_t hal_ring_hdl,
  566. uint32_t *headp, uint32_t *tailp,
  567. uint8_t ring_type);
  568. void (*hal_reo_setup)(struct hal_soc *hal_soc, void *reoparams);
  569. void (*hal_setup_link_idle_list)(
  570. struct hal_soc *hal_soc,
  571. qdf_dma_addr_t scatter_bufs_base_paddr[],
  572. void *scatter_bufs_base_vaddr[],
  573. uint32_t num_scatter_bufs,
  574. uint32_t scatter_buf_size,
  575. uint32_t last_buf_end_offset,
  576. uint32_t num_entries);
  577. qdf_iomem_t (*hal_get_window_address)(struct hal_soc *hal_soc,
  578. qdf_iomem_t addr);
  579. void (*hal_reo_set_err_dst_remap)(void *hal_soc);
  580. void (*hal_reo_qdesc_setup)(hal_soc_handle_t hal_soc_hdl, int tid,
  581. uint32_t ba_window_size,
  582. uint32_t start_seq, void *hw_qdesc_vaddr,
  583. qdf_dma_addr_t hw_qdesc_paddr,
  584. int pn_type);
  585. uint32_t (*hal_gen_reo_remap_val)(enum hal_reo_remap_reg,
  586. uint8_t *ix0_map);
  587. /* tx */
  588. void (*hal_tx_desc_set_dscp_tid_table_id)(void *desc, uint8_t id);
  589. void (*hal_tx_set_dscp_tid_map)(struct hal_soc *hal_soc, uint8_t *map,
  590. uint8_t id);
  591. void (*hal_tx_update_dscp_tid)(struct hal_soc *hal_soc, uint8_t tid,
  592. uint8_t id,
  593. uint8_t dscp);
  594. void (*hal_tx_desc_set_lmac_id)(void *desc, uint8_t lmac_id);
  595. void (*hal_tx_desc_set_buf_addr)(void *desc, dma_addr_t paddr,
  596. uint8_t pool_id, uint32_t desc_id,
  597. uint8_t type);
  598. void (*hal_tx_desc_set_search_type)(void *desc, uint8_t search_type);
  599. void (*hal_tx_desc_set_search_index)(void *desc, uint32_t search_index);
  600. void (*hal_tx_desc_set_cache_set_num)(void *desc, uint8_t search_index);
  601. void (*hal_tx_comp_get_status)(void *desc, void *ts,
  602. struct hal_soc *hal);
  603. uint8_t (*hal_tx_comp_get_release_reason)(void *hal_desc);
  604. uint8_t (*hal_get_wbm_internal_error)(void *hal_desc);
  605. void (*hal_tx_desc_set_mesh_en)(void *desc, uint8_t en);
  606. void (*hal_tx_init_cmd_credit_ring)(hal_soc_handle_t hal_soc_hdl,
  607. hal_ring_handle_t hal_ring_hdl);
  608. uint32_t (*hal_tx_comp_get_buffer_source)(void *hal_desc);
  609. /* rx */
  610. uint32_t (*hal_rx_msdu_start_nss_get)(uint8_t *);
  611. void (*hal_rx_mon_hw_desc_get_mpdu_status)(void *hw_desc_addr,
  612. struct mon_rx_status *rs);
  613. uint8_t (*hal_rx_get_tlv)(void *rx_tlv);
  614. void (*hal_rx_proc_phyrx_other_receive_info_tlv)(void *rx_tlv_hdr,
  615. void *ppdu_info_handle);
  616. void (*hal_rx_dump_msdu_start_tlv)(void *msdu_start, uint8_t dbg_level);
  617. void (*hal_rx_dump_msdu_end_tlv)(void *msdu_end,
  618. uint8_t dbg_level);
  619. uint32_t (*hal_get_link_desc_size)(void);
  620. uint32_t (*hal_rx_mpdu_start_tid_get)(uint8_t *buf);
  621. uint32_t (*hal_rx_msdu_start_reception_type_get)(uint8_t *buf);
  622. uint16_t (*hal_rx_msdu_end_da_idx_get)(uint8_t *buf);
  623. void* (*hal_rx_msdu_desc_info_get_ptr)(void *msdu_details_ptr);
  624. void* (*hal_rx_link_desc_msdu0_ptr)(void *msdu_link_ptr);
  625. void (*hal_reo_status_get_header)(hal_ring_desc_t ring_desc, int b,
  626. void *h);
  627. uint32_t (*hal_rx_status_get_tlv_info)(void *rx_tlv_hdr,
  628. void *ppdu_info,
  629. hal_soc_handle_t hal_soc_hdl,
  630. qdf_nbuf_t nbuf);
  631. void (*hal_rx_wbm_err_info_get)(void *wbm_desc,
  632. void *wbm_er_info);
  633. void (*hal_rx_dump_mpdu_start_tlv)(void *mpdustart,
  634. uint8_t dbg_level);
  635. void (*hal_tx_set_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t *map);
  636. void (*hal_tx_update_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t pcp,
  637. uint8_t id);
  638. void (*hal_tx_set_tidmap_prty)(struct hal_soc *hal_soc, uint8_t prio);
  639. /* rx */
  640. uint8_t (*hal_rx_get_rx_fragment_number)(uint8_t *buf);
  641. uint8_t (*hal_rx_msdu_end_da_is_mcbc_get)(uint8_t *buf);
  642. uint8_t (*hal_rx_msdu_end_sa_is_valid_get)(uint8_t *buf);
  643. uint16_t (*hal_rx_msdu_end_sa_idx_get)(uint8_t *buf);
  644. uint32_t (*hal_rx_desc_is_first_msdu)(void *hw_desc_addr);
  645. uint32_t (*hal_rx_msdu_end_l3_hdr_padding_get)(uint8_t *buf);
  646. uint32_t (*hal_rx_encryption_info_valid)(uint8_t *buf);
  647. void (*hal_rx_print_pn)(uint8_t *buf);
  648. uint8_t (*hal_rx_msdu_end_first_msdu_get)(uint8_t *buf);
  649. uint8_t (*hal_rx_msdu_end_da_is_valid_get)(uint8_t *buf);
  650. uint8_t (*hal_rx_msdu_end_last_msdu_get)(uint8_t *buf);
  651. bool (*hal_rx_get_mpdu_mac_ad4_valid)(uint8_t *buf);
  652. uint32_t (*hal_rx_mpdu_start_sw_peer_id_get)(uint8_t *buf);
  653. uint32_t (*hal_rx_mpdu_get_to_ds)(uint8_t *buf);
  654. uint32_t (*hal_rx_mpdu_get_fr_ds)(uint8_t *buf);
  655. uint8_t (*hal_rx_get_mpdu_frame_control_valid)(uint8_t *buf);
  656. QDF_STATUS
  657. (*hal_rx_mpdu_get_addr1)(uint8_t *buf, uint8_t *mac_addr);
  658. QDF_STATUS
  659. (*hal_rx_mpdu_get_addr2)(uint8_t *buf, uint8_t *mac_addr);
  660. QDF_STATUS
  661. (*hal_rx_mpdu_get_addr3)(uint8_t *buf, uint8_t *mac_addr);
  662. QDF_STATUS
  663. (*hal_rx_mpdu_get_addr4)(uint8_t *buf, uint8_t *mac_addr);
  664. uint8_t (*hal_rx_get_mpdu_sequence_control_valid)(uint8_t *buf);
  665. bool (*hal_rx_is_unicast)(uint8_t *buf);
  666. uint32_t (*hal_rx_tid_get)(hal_soc_handle_t hal_soc_hdl, uint8_t *buf);
  667. uint32_t (*hal_rx_hw_desc_get_ppduid_get)(void *rx_tlv_hdr,
  668. void *rxdma_dst_ring_desc);
  669. uint32_t (*hal_rx_mpdu_start_mpdu_qos_control_valid_get)(uint8_t *buf);
  670. uint32_t (*hal_rx_msdu_end_sa_sw_peer_id_get)(uint8_t *buf);
  671. void * (*hal_rx_msdu0_buffer_addr_lsb)(void *link_desc_addr);
  672. void * (*hal_rx_msdu_desc_info_ptr_get)(void *msdu0);
  673. void * (*hal_ent_mpdu_desc_info)(void *hw_addr);
  674. void * (*hal_dst_mpdu_desc_info)(void *hw_addr);
  675. uint8_t (*hal_rx_get_fc_valid)(uint8_t *buf);
  676. uint8_t (*hal_rx_get_to_ds_flag)(uint8_t *buf);
  677. uint8_t (*hal_rx_get_mac_addr2_valid)(uint8_t *buf);
  678. uint8_t (*hal_rx_get_filter_category)(uint8_t *buf);
  679. uint32_t (*hal_rx_get_ppdu_id)(uint8_t *buf);
  680. void (*hal_reo_config)(struct hal_soc *soc,
  681. uint32_t reg_val,
  682. struct hal_reo_params *reo_params);
  683. uint32_t (*hal_rx_msdu_flow_idx_get)(uint8_t *buf);
  684. bool (*hal_rx_msdu_flow_idx_invalid)(uint8_t *buf);
  685. bool (*hal_rx_msdu_flow_idx_timeout)(uint8_t *buf);
  686. uint32_t (*hal_rx_msdu_fse_metadata_get)(uint8_t *buf);
  687. uint16_t (*hal_rx_msdu_cce_metadata_get)(uint8_t *buf);
  688. void
  689. (*hal_rx_msdu_get_flow_params)(
  690. uint8_t *buf,
  691. bool *flow_invalid,
  692. bool *flow_timeout,
  693. uint32_t *flow_index);
  694. uint16_t (*hal_rx_tlv_get_tcp_chksum)(uint8_t *buf);
  695. uint16_t (*hal_rx_get_rx_sequence)(uint8_t *buf);
  696. void (*hal_rx_get_bb_info)(void *rx_tlv, void *ppdu_info_handle);
  697. void (*hal_rx_get_rtt_info)(void *rx_tlv, void *ppdu_info_handle);
  698. void (*hal_rx_msdu_packet_metadata_get)(uint8_t *buf,
  699. void *msdu_pkt_metadata);
  700. uint16_t (*hal_rx_get_fisa_cumulative_l4_checksum)(uint8_t *buf);
  701. uint16_t (*hal_rx_get_fisa_cumulative_ip_length)(uint8_t *buf);
  702. bool (*hal_rx_get_udp_proto)(uint8_t *buf);
  703. bool (*hal_rx_get_fisa_flow_agg_continuation)(uint8_t *buf);
  704. uint8_t (*hal_rx_get_fisa_flow_agg_count)(uint8_t *buf);
  705. bool (*hal_rx_get_fisa_timeout)(uint8_t *buf);
  706. uint8_t (*hal_rx_mpdu_start_tlv_tag_valid)(void *rx_tlv_hdr);
  707. void (*hal_rx_sw_mon_desc_info_get)(hal_ring_desc_t rxdma_dst_ring_desc,
  708. hal_rx_mon_desc_info_t mon_desc_info);
  709. uint8_t (*hal_rx_wbm_err_msdu_continuation_get)(void *ring_desc);
  710. uint32_t (*hal_rx_msdu_end_offset_get)(void);
  711. uint32_t (*hal_rx_attn_offset_get)(void);
  712. uint32_t (*hal_rx_msdu_start_offset_get)(void);
  713. uint32_t (*hal_rx_mpdu_start_offset_get)(void);
  714. uint32_t (*hal_rx_mpdu_end_offset_get)(void);
  715. uint32_t (*hal_rx_pkt_tlv_offset_get)(void);
  716. void * (*hal_rx_flow_setup_fse)(uint8_t *rx_fst,
  717. uint32_t table_offset,
  718. uint8_t *rx_flow);
  719. void (*hal_compute_reo_remap_ix2_ix3)(uint32_t *ring,
  720. uint32_t num_rings,
  721. uint32_t *remap1,
  722. uint32_t *remap2);
  723. uint32_t (*hal_rx_flow_setup_cmem_fse)(
  724. struct hal_soc *soc, uint32_t cmem_ba,
  725. uint32_t table_offset, uint8_t *rx_flow);
  726. uint32_t (*hal_rx_flow_get_cmem_fse_ts)(struct hal_soc *soc,
  727. uint32_t fse_offset);
  728. void (*hal_rx_flow_get_cmem_fse)(struct hal_soc *soc,
  729. uint32_t fse_offset,
  730. uint32_t *fse, qdf_size_t len);
  731. void (*hal_rx_msdu_get_reo_destination_indication)(uint8_t *buf,
  732. uint32_t *reo_destination_indication);
  733. uint8_t (*hal_tx_get_num_tcl_banks)(void);
  734. uint32_t (*hal_get_reo_qdesc_size)(uint32_t ba_window_size, int tid);
  735. void (*hal_set_link_desc_addr)(void *desc, uint32_t cookie,
  736. qdf_dma_addr_t link_desc_paddr);
  737. void (*hal_tx_init_data_ring)(hal_soc_handle_t hal_soc_hdl,
  738. hal_ring_handle_t hal_ring_hdl);
  739. void* (*hal_rx_msdu_ext_desc_info_get_ptr)(void *msdu_details_ptr);
  740. void (*hal_get_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
  741. uint8_t ac, uint32_t *value);
  742. void (*hal_set_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
  743. uint8_t ac, uint32_t value);
  744. uint32_t (*hal_get_reo_reg_base_offset)(void);
  745. void (*hal_rx_get_tlv_size)(uint16_t *rx_pkt_tlv_size,
  746. uint16_t *rx_mon_pkt_tlv_size);
  747. uint32_t (*hal_rx_msdu_is_wlan_mcast)(qdf_nbuf_t nbuf);
  748. uint32_t (*hal_rx_tlv_decap_format_get)(void *hw_desc_addr);
  749. void (*hal_rx_dump_pkt_tlvs)(hal_soc_handle_t hal_soc_hdl,
  750. uint8_t *buf, uint8_t dbg_level);
  751. int (*hal_rx_tlv_get_offload_info)(uint8_t *rx_tlv,
  752. struct hal_offload_info *offload_info);
  753. uint16_t (*hal_rx_tlv_phy_ppdu_id_get)(uint8_t *buf);
  754. uint32_t (*hal_rx_tlv_msdu_done_get)(uint8_t *buf);
  755. uint32_t (*hal_rx_tlv_msdu_len_get)(uint8_t *buf);
  756. uint16_t (*hal_rx_get_frame_ctrl_field)(uint8_t *buf);
  757. int (*hal_rx_get_proto_params)(uint8_t *buf, void *fisa_params);
  758. int (*hal_rx_get_l3_l4_offsets)(uint8_t *buf, uint32_t *l3_hdr_offset,
  759. uint32_t *l4_hdr_offset);
  760. uint32_t (*hal_rx_tlv_mic_err_get)(uint8_t *buf);
  761. uint32_t (*hal_rx_tlv_get_pkt_type)(uint8_t *buf);
  762. void (*hal_rx_tlv_get_pn_num)(uint8_t *buf, uint64_t *pn_num);
  763. uint8_t * (*hal_rx_pkt_hdr_get)(uint8_t *buf);
  764. uint32_t (*hal_rx_msdu_reo_dst_ind_get)(hal_soc_handle_t hal_soc_hdl,
  765. void *msdu_link_desc);
  766. void (*hal_msdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
  767. void *msdu_desc_info, uint32_t dst_ind,
  768. uint32_t nbuf_len);
  769. void (*hal_mpdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
  770. void *mpdu_desc_info, uint32_t seq_no);
  771. uint32_t (*hal_rx_tlv_sgi_get)(uint8_t *buf);
  772. uint32_t (*hal_rx_tlv_get_freq)(uint8_t *buf);
  773. uint8_t (*hal_rx_msdu_get_keyid)(uint8_t *buf);
  774. uint32_t (*hal_rx_tlv_rate_mcs_get)(uint8_t *buf);
  775. uint32_t (*hal_rx_tlv_decrypt_err_get)(uint8_t *buf);
  776. uint32_t (*hal_rx_tlv_first_mpdu_get)(uint8_t *buf);
  777. uint32_t (*hal_rx_tlv_bw_get)(uint8_t *buf);
  778. uint32_t (*hal_rx_tlv_get_is_decrypted)(uint8_t *buf);
  779. uint32_t (*hal_rx_wbm_err_src_get)(hal_ring_desc_t ring_desc);
  780. uint8_t (*hal_rx_ret_buf_manager_get)(hal_ring_desc_t ring_desc);
  781. void (*hal_rx_msdu_link_desc_set)(hal_soc_handle_t hal_soc_hdl,
  782. void *src_srng_desc,
  783. hal_buff_addrinfo_t buf_addr_info,
  784. uint8_t bm_action);
  785. void (*hal_rx_buf_cookie_rbm_get)(uint32_t *buf_addr_info_hdl,
  786. hal_buf_info_t buf_info_hdl);
  787. void (*hal_rx_reo_buf_paddr_get)(hal_ring_desc_t rx_desc,
  788. struct hal_buf_info *buf_info);
  789. void (*hal_rxdma_buff_addr_info_set)(void *rxdma_entry,
  790. qdf_dma_addr_t paddr,
  791. uint32_t cookie, uint8_t manager);
  792. uint32_t (*hal_rx_msdu_flags_get)(rx_msdu_desc_info_t msdu_desc_info_hdl);
  793. uint32_t (*hal_rx_get_reo_error_code)(hal_ring_desc_t rx_desc);
  794. void (*hal_rx_tlv_csum_err_get)(uint8_t *rx_tlv_hdr,
  795. uint32_t *ip_csum_err,
  796. uint32_t *tcp_udp_csum_err);
  797. void (*hal_rx_mpdu_desc_info_get)(void *desc_addr,
  798. void *mpdu_desc_info_hdl);
  799. uint8_t (*hal_rx_err_status_get)(hal_ring_desc_t rx_desc);
  800. uint8_t (*hal_rx_reo_buf_type_get)(hal_ring_desc_t rx_desc);
  801. bool (*hal_rx_mpdu_info_ampdu_flag_get)(uint8_t *buf);
  802. uint32_t (*hal_rx_tlv_mpdu_len_err_get)(void *hw_desc_addr);
  803. uint32_t (*hal_rx_tlv_mpdu_fcs_err_get)(void *hw_desc_addr);
  804. void (*hal_rx_tlv_get_pkt_capture_flags)(uint8_t *rx_tlv_hdr,
  805. struct hal_rx_pkt_capture_flags *flags);
  806. uint8_t *(*hal_rx_desc_get_80211_hdr)(void *hw_desc_addr);
  807. uint32_t (*hal_rx_hw_desc_mpdu_user_id)(void *hw_desc_addr);
  808. void (*hal_rx_priv_info_set_in_tlv)(uint8_t *buf,
  809. uint8_t *priv_data,
  810. uint32_t len);
  811. void (*hal_rx_priv_info_get_from_tlv)(uint8_t *buf,
  812. uint8_t *priv_data,
  813. uint32_t len);
  814. void (*hal_rx_tlv_msdu_len_set)(uint8_t *buf, uint32_t len);
  815. /* REO CMD and STATUS */
  816. int (*hal_reo_send_cmd)(hal_soc_handle_t hal_soc_hdl,
  817. hal_ring_handle_t hal_ring_hdl,
  818. enum hal_reo_cmd_type cmd,
  819. void *params);
  820. QDF_STATUS (*hal_reo_status_update)(hal_soc_handle_t hal_soc_hdl,
  821. hal_ring_desc_t reo_desc,
  822. void *st_handle,
  823. uint32_t tlv, int *num_ref);
  824. uint8_t (*hal_get_tlv_hdr_size)(void);
  825. };
  826. /**
  827. * struct hal_soc_stats - Hal layer stats
  828. * @reg_write_fail: number of failed register writes
  829. * @wstats: delayed register write stats
  830. * @shadow_reg_write_fail: shadow reg write failure stats
  831. * @shadow_reg_write_succ: shadow reg write success stats
  832. *
  833. * This structure holds all the statistics at HAL layer.
  834. */
  835. struct hal_soc_stats {
  836. uint32_t reg_write_fail;
  837. #if defined(FEATURE_HAL_DELAYED_REG_WRITE) || \
  838. defined(FEATURE_HAL_DELAYED_REG_WRITE_V2)
  839. struct hal_reg_write_soc_stats wstats;
  840. #endif
  841. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  842. uint32_t shadow_reg_write_fail;
  843. uint32_t shadow_reg_write_succ;
  844. #endif
  845. };
  846. #ifdef ENABLE_HAL_REG_WR_HISTORY
  847. /* The history size should always be a power of 2 */
  848. #define HAL_REG_WRITE_HIST_SIZE 8
  849. /**
  850. * struct hal_reg_write_fail_entry - Record of
  851. * register write which failed.
  852. * @timestamp: timestamp of reg write failure
  853. * @reg_offset: offset of register where the write failed
  854. * @write_val: the value which was to be written
  855. * @read_val: the value read back from the register after write
  856. */
  857. struct hal_reg_write_fail_entry {
  858. uint64_t timestamp;
  859. uint32_t reg_offset;
  860. uint32_t write_val;
  861. uint32_t read_val;
  862. };
  863. /**
  864. * struct hal_reg_write_fail_history - Hal layer history
  865. * of all the register write failures.
  866. * @index: index to add the new record
  867. * @record: array of all the records in history
  868. *
  869. * This structure holds the history of register write
  870. * failures at HAL layer.
  871. */
  872. struct hal_reg_write_fail_history {
  873. qdf_atomic_t index;
  874. struct hal_reg_write_fail_entry record[HAL_REG_WRITE_HIST_SIZE];
  875. };
  876. #endif
  877. /**
  878. * struct hal_soc - HAL context to be used to access SRNG APIs
  879. * (currently used by data path and
  880. * transport (CE) modules)
  881. * @list_shadow_reg_config: array of generic regs mapped to
  882. * shadow regs
  883. * @num_generic_shadow_regs_configured: number of generic regs
  884. * mapped to shadow regs
  885. */
  886. struct hal_soc {
  887. /* HIF handle to access HW registers */
  888. struct hif_opaque_softc *hif_handle;
  889. /* QDF device handle */
  890. qdf_device_t qdf_dev;
  891. /* Device base address */
  892. void *dev_base_addr;
  893. /* Device base address for ce - qca5018 target */
  894. void *dev_base_addr_ce;
  895. /* HAL internal state for all SRNG rings.
  896. * TODO: See if this is required
  897. */
  898. struct hal_srng srng_list[HAL_SRNG_ID_MAX];
  899. /* Remote pointer memory for HW/FW updates */
  900. uint32_t *shadow_rdptr_mem_vaddr;
  901. qdf_dma_addr_t shadow_rdptr_mem_paddr;
  902. /* Shared memory for ring pointer updates from host to FW */
  903. uint32_t *shadow_wrptr_mem_vaddr;
  904. qdf_dma_addr_t shadow_wrptr_mem_paddr;
  905. /* REO blocking resource index */
  906. uint8_t reo_res_bitmap;
  907. uint8_t index;
  908. uint32_t target_type;
  909. /* shadow register configuration */
  910. struct pld_shadow_reg_v2_cfg shadow_config[MAX_SHADOW_REGISTERS];
  911. int num_shadow_registers_configured;
  912. bool use_register_windowing;
  913. uint32_t register_window;
  914. qdf_spinlock_t register_access_lock;
  915. /* Static window map configuration for multiple window write*/
  916. bool static_window_map;
  917. /* srng table */
  918. struct hal_hw_srng_config *hw_srng_table;
  919. int32_t *hal_hw_reg_offset;
  920. struct hal_hw_txrx_ops *ops;
  921. /* Indicate srngs initialization */
  922. bool init_phase;
  923. /* Hal level stats */
  924. struct hal_soc_stats stats;
  925. #ifdef ENABLE_HAL_REG_WR_HISTORY
  926. struct hal_reg_write_fail_history *reg_wr_fail_hist;
  927. #endif
  928. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  929. /* queue(array) to hold register writes */
  930. struct hal_reg_write_q_elem *reg_write_queue;
  931. /* delayed work to be queued into workqueue */
  932. qdf_work_t reg_write_work;
  933. /* workqueue for delayed register writes */
  934. qdf_workqueue_t *reg_write_wq;
  935. /* write index used by caller to enqueue delayed work */
  936. qdf_atomic_t write_idx;
  937. /* read index used by worker thread to dequeue/write registers */
  938. uint32_t read_idx;
  939. #endif /*FEATURE_HAL_DELAYED_REG_WRITE */
  940. #ifdef FEATURE_HAL_DELAYED_REG_WRITE_V2
  941. /* delayed work for TCL reg write to be queued into workqueue */
  942. qdf_work_t tcl_reg_write_work;
  943. /* workqueue for TCL delayed register writes */
  944. qdf_workqueue_t *tcl_reg_write_wq;
  945. /* flag denotes whether TCL delayed write work is active */
  946. qdf_atomic_t tcl_work_active;
  947. /* flag indiactes TCL write happening from direct context */
  948. bool tcl_direct;
  949. /* timer to handle the pending TCL reg writes */
  950. qdf_timer_t tcl_reg_write_timer;
  951. /* stats related to TCL reg write */
  952. struct hal_reg_write_tcl_stats tcl_stats;
  953. #endif /* FEATURE_HAL_DELAYED_REG_WRITE_V2 */
  954. qdf_atomic_t active_work_cnt;
  955. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  956. struct shadow_reg_config
  957. list_shadow_reg_config[MAX_GENERIC_SHADOW_REG];
  958. int num_generic_shadow_regs_configured;
  959. #endif
  960. };
  961. #if defined(FEATURE_HAL_DELAYED_REG_WRITE) || \
  962. defined(FEATURE_HAL_DELAYED_REG_WRITE_V2)
  963. /**
  964. * hal_delayed_reg_write() - delayed regiter write
  965. * @hal_soc: HAL soc handle
  966. * @srng: hal srng
  967. * @addr: iomem address
  968. * @value: value to be written
  969. *
  970. * Return: none
  971. */
  972. void hal_delayed_reg_write(struct hal_soc *hal_soc,
  973. struct hal_srng *srng,
  974. void __iomem *addr,
  975. uint32_t value);
  976. #endif
  977. void hal_qca6750_attach(struct hal_soc *hal_soc);
  978. void hal_qca6490_attach(struct hal_soc *hal_soc);
  979. void hal_qca6390_attach(struct hal_soc *hal_soc);
  980. void hal_qca6290_attach(struct hal_soc *hal_soc);
  981. void hal_qca8074_attach(struct hal_soc *hal_soc);
  982. void hal_wcn7850_attach(struct hal_soc *hal_soc);
  983. /*
  984. * hal_soc_to_dp_hal_roc - API to convert hal_soc to opaque
  985. * dp_hal_soc handle type
  986. * @hal_soc - hal_soc type
  987. *
  988. * Return: hal_soc_handle_t type
  989. */
  990. static inline
  991. hal_soc_handle_t hal_soc_to_hal_soc_handle(struct hal_soc *hal_soc)
  992. {
  993. return (hal_soc_handle_t)hal_soc;
  994. }
  995. /*
  996. * hal_srng_to_hal_ring_handle - API to convert hal_srng to opaque
  997. * dp_hal_ring handle type
  998. * @hal_srng - hal_srng type
  999. *
  1000. * Return: hal_ring_handle_t type
  1001. */
  1002. static inline
  1003. hal_ring_handle_t hal_srng_to_hal_ring_handle(struct hal_srng *hal_srng)
  1004. {
  1005. return (hal_ring_handle_t)hal_srng;
  1006. }
  1007. /*
  1008. * hal_ring_handle_to_hal_srng - API to convert dp_hal_ring to hal_srng handle
  1009. * @hal_ring - hal_ring_handle_t type
  1010. *
  1011. * Return: hal_srng pointer type
  1012. */
  1013. static inline
  1014. struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring)
  1015. {
  1016. return (struct hal_srng *)hal_ring;
  1017. }
  1018. #endif /* _HAL_INTERNAL_H_ */