hal_internal.h 52 KB

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