hal_internal.h 52 KB

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