hal_internal.h 50 KB

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