hal_internal.h 55 KB

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