hal_internal.h 55 KB

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