hal_internal.h 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761
  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. #ifdef IPA_OFFLOAD
  268. HAL_SRNG_WMAC1_SW2RXDMA0_BUF1,
  269. HAL_SRNG_WMAC1_SW2RXDMA0_BUF2,
  270. #ifdef IPA_WDI3_VLAN_SUPPORT
  271. HAL_SRNG_WMAC1_SW2RXDMA0_BUF3,
  272. #endif
  273. #endif
  274. HAL_SRNG_WMAC1_SW2RXDMA1_BUF,
  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. #ifdef IPA_OFFLOAD
  305. HAL_SRNG_WMAC1_SW2RXDMA0_BUF1,
  306. HAL_SRNG_WMAC1_SW2RXDMA0_BUF2,
  307. #ifdef IPA_WDI3_VLAN_SUPPORT
  308. HAL_SRNG_WMAC1_SW2RXDMA0_BUF3,
  309. #endif
  310. #endif
  311. HAL_SRNG_WMAC1_SW2RXDMA1_BUF,
  312. #ifdef FEATURE_DIRECT_LINK
  313. HAL_SRNG_WMAC1_RX_DIRECT_LINK_SW_REFILL_RING,
  314. #endif
  315. HAL_SRNG_WMAC1_SW2RXDMA2_BUF,
  316. HAL_SRNG_WMAC1_SW2RXDMA0_STATBUF,
  317. HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF,
  318. HAL_SRNG_WMAC1_RXDMA2SW0,
  319. HAL_SRNG_WMAC1_RXDMA2SW1,
  320. HAL_SRNG_WMAC1_RXMON2SW0 = HAL_SRNG_WMAC1_RXDMA2SW1,
  321. HAL_SRNG_WMAC1_SW2RXDMA1_DESC,
  322. #ifdef WLAN_FEATURE_CIF_CFR
  323. HAL_SRNG_WIFI_POS_SRC_DMA_RING,
  324. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING,
  325. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING1,
  326. #else
  327. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING,
  328. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING1,
  329. #endif
  330. HAL_SRNG_WMAC1_TXMON2SW0,
  331. HAL_SRNG_SW2TXMON_BUF0,
  332. HAL_SRNG_LMAC1_ID_END = (HAL_SRNG_SW2TXMON_BUF0 + 2),
  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. 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. void (*hal_set_reo_ent_desc_reo_dest_ind)(uint8_t *desc,
  1261. uint32_t dst_ind);
  1262. QDF_STATUS
  1263. (*hal_rx_reo_ent_get_src_link_id)(hal_rxdma_desc_t rx_desc,
  1264. uint8_t *src_link_id);
  1265. /* REO CMD and STATUS */
  1266. int (*hal_reo_send_cmd)(hal_soc_handle_t hal_soc_hdl,
  1267. hal_ring_handle_t hal_ring_hdl,
  1268. enum hal_reo_cmd_type cmd,
  1269. void *params);
  1270. QDF_STATUS (*hal_reo_status_update)(hal_soc_handle_t hal_soc_hdl,
  1271. hal_ring_desc_t reo_desc,
  1272. void *st_handle,
  1273. uint32_t tlv, int *num_ref);
  1274. uint8_t (*hal_get_tlv_hdr_size)(void);
  1275. uint8_t (*hal_get_idle_link_bm_id)(uint8_t chip_id);
  1276. bool (*hal_txmon_is_mon_buf_addr_tlv)(void *tx_tlv_hdr);
  1277. void (*hal_txmon_populate_packet_info)(void *tx_tlv_hdr,
  1278. void *pkt_info);
  1279. /* TX MONITOR */
  1280. #ifdef QCA_MONITOR_2_0_SUPPORT
  1281. uint32_t (*hal_txmon_status_parse_tlv)(void *data_ppdu_info,
  1282. void *prot_ppdu_info,
  1283. void *data_status_info,
  1284. void *prot_status_info,
  1285. void *tx_tlv_hdr,
  1286. qdf_frag_t status_frag);
  1287. uint32_t (*hal_txmon_status_get_num_users)(void *tx_tlv_hdr,
  1288. uint8_t *num_users);
  1289. void (*hal_txmon_get_word_mask)(void *wmask);
  1290. #endif /* QCA_MONITOR_2_0_SUPPORT */
  1291. QDF_STATUS (*hal_reo_shared_qaddr_setup)(hal_soc_handle_t hal_soc_hdl,
  1292. struct reo_queue_ref_table
  1293. *reo_qref);
  1294. void (*hal_reo_shared_qaddr_init)(hal_soc_handle_t hal_soc_hdl,
  1295. int qref_reset);
  1296. void (*hal_reo_shared_qaddr_detach)(hal_soc_handle_t hal_soc_hdl);
  1297. void (*hal_reo_shared_qaddr_write)(hal_soc_handle_t hal_soc_hdl,
  1298. uint16_t peer_id,
  1299. int tid,
  1300. qdf_dma_addr_t hw_qdesc_paddr);
  1301. #ifdef WLAN_FEATURE_MARK_FIRST_WAKEUP_PACKET
  1302. uint8_t (*hal_get_first_wow_wakeup_packet)(uint8_t *buf);
  1303. #endif
  1304. void (*hal_reo_shared_qaddr_cache_clear)(hal_soc_handle_t hal_soc_hdl);
  1305. uint32_t (*hal_rx_tlv_l3_type_get)(uint8_t *buf);
  1306. void (*hal_tx_vdev_mismatch_routing_set)(hal_soc_handle_t hal_soc_hdl,
  1307. enum hal_tx_vdev_mismatch_notify config);
  1308. void (*hal_tx_mcast_mlo_reinject_routing_set)(
  1309. hal_soc_handle_t hal_soc_hdl,
  1310. enum hal_tx_mcast_mlo_reinject_notify config);
  1311. void (*hal_cookie_conversion_reg_cfg_be)(hal_soc_handle_t hal_soc_hdl,
  1312. struct hal_hw_cc_config
  1313. *cc_cfg);
  1314. void (*hal_tx_populate_bank_register)(hal_soc_handle_t hal_soc_hdl,
  1315. union hal_tx_bank_config *config,
  1316. uint8_t bank_id);
  1317. void (*hal_tx_vdev_mcast_ctrl_set)(hal_soc_handle_t hal_soc_hdl,
  1318. uint8_t vdev_id,
  1319. uint8_t mcast_ctrl_val);
  1320. void (*hal_get_tsf_time)(hal_soc_handle_t hal_soc_hdl, uint32_t tsf_id,
  1321. uint32_t mac_id, uint64_t *tsf,
  1322. uint64_t *tsf_sync_soc_time);
  1323. void (*hal_get_tsf2_scratch_reg)(hal_soc_handle_t hal_soc_hdl,
  1324. uint8_t mac_id, uint64_t *value);
  1325. void (*hal_get_tqm_scratch_reg)(hal_soc_handle_t hal_soc_hdl,
  1326. uint64_t *value);
  1327. #ifdef FEATURE_DIRECT_LINK
  1328. QDF_STATUS (*hal_srng_set_msi_config)(hal_ring_handle_t ring_hdl,
  1329. void *ring_params);
  1330. #endif
  1331. void (*hal_tx_ring_halt_set)(hal_soc_handle_t hal_soc_hdl);
  1332. void (*hal_tx_ring_halt_reset)(hal_soc_handle_t hal_soc_hdl);
  1333. bool (*hal_tx_ring_halt_poll)(hal_soc_handle_t hal_soc_hdl);
  1334. uint32_t (*hal_tx_get_num_ppe_vp_search_idx_tbl_entries)(
  1335. hal_soc_handle_t hal_soc_hdl);
  1336. uint32_t (*hal_tx_ring_halt_get)(hal_soc_handle_t hal_soc_hdl);
  1337. };
  1338. /**
  1339. * struct hal_soc_stats - Hal layer stats
  1340. * @reg_write_fail: number of failed register writes
  1341. * @wstats: delayed register write stats
  1342. * @shadow_reg_write_fail: shadow reg write failure stats
  1343. * @shadow_reg_write_succ: shadow reg write success stats
  1344. *
  1345. * This structure holds all the statistics at HAL layer.
  1346. */
  1347. struct hal_soc_stats {
  1348. uint32_t reg_write_fail;
  1349. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1350. struct hal_reg_write_soc_stats wstats;
  1351. #endif
  1352. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  1353. uint32_t shadow_reg_write_fail;
  1354. uint32_t shadow_reg_write_succ;
  1355. #endif
  1356. };
  1357. #ifdef ENABLE_HAL_REG_WR_HISTORY
  1358. /* The history size should always be a power of 2 */
  1359. #define HAL_REG_WRITE_HIST_SIZE 8
  1360. /**
  1361. * struct hal_reg_write_fail_entry - Record of
  1362. * register write which failed.
  1363. * @timestamp: timestamp of reg write failure
  1364. * @reg_offset: offset of register where the write failed
  1365. * @write_val: the value which was to be written
  1366. * @read_val: the value read back from the register after write
  1367. */
  1368. struct hal_reg_write_fail_entry {
  1369. uint64_t timestamp;
  1370. uint32_t reg_offset;
  1371. uint32_t write_val;
  1372. uint32_t read_val;
  1373. };
  1374. /**
  1375. * struct hal_reg_write_fail_history - Hal layer history
  1376. * of all the register write failures.
  1377. * @index: index to add the new record
  1378. * @record: array of all the records in history
  1379. *
  1380. * This structure holds the history of register write
  1381. * failures at HAL layer.
  1382. */
  1383. struct hal_reg_write_fail_history {
  1384. qdf_atomic_t index;
  1385. struct hal_reg_write_fail_entry record[HAL_REG_WRITE_HIST_SIZE];
  1386. };
  1387. #endif
  1388. /**
  1389. * union hal_shadow_reg_cfg - Shadow register config
  1390. * @addr: Place holder where shadow address is saved
  1391. * @v2: shadow config v2 format
  1392. * @v3: shadow config v3 format
  1393. */
  1394. union hal_shadow_reg_cfg {
  1395. uint32_t addr;
  1396. struct pld_shadow_reg_v2_cfg v2;
  1397. #ifdef CONFIG_SHADOW_V3
  1398. struct pld_shadow_reg_v3_cfg v3;
  1399. #endif
  1400. };
  1401. #ifdef HAL_RECORD_SUSPEND_WRITE
  1402. #define HAL_SUSPEND_WRITE_HISTORY_MAX 256
  1403. struct hal_suspend_write_record {
  1404. uint64_t ts;
  1405. uint8_t ring_id;
  1406. uit32_t value;
  1407. uint32_t direct_wcount;
  1408. };
  1409. struct hal_suspend_write_history {
  1410. qdf_atomic_t index;
  1411. struct hal_suspend_write_record record[HAL_SUSPEND_WRITE_HISTORY_MAX];
  1412. };
  1413. #endif
  1414. /**
  1415. * struct hal_soc - HAL context to be used to access SRNG APIs
  1416. * (currently used by data path and
  1417. * transport (CE) modules)
  1418. * @hif_handle: HIF handle to access HW registers
  1419. * @qdf_dev: QDF device handle
  1420. * @dev_base_addr: Device base address
  1421. * @dev_base_addr_ce: Device base address for ce - qca5018 target
  1422. * @dev_base_addr_cmem: Device base address for CMEM
  1423. * @dev_base_addr_pmm: Device base address for PMM
  1424. * @srng_list: HAL internal state for all SRNG rings
  1425. * @shadow_rdptr_mem_vaddr: Remote pointer memory for HW/FW updates (virtual)
  1426. * @shadow_rdptr_mem_paddr: Remote pointer memory for HW/FW updates (physical)
  1427. * @shadow_wrptr_mem_vaddr: Shared memory for ring pointer updates from host
  1428. * to FW (virtual)
  1429. * @shadow_wrptr_mem_paddr: Shared memory for ring pointer updates from host
  1430. * to FW (physical)
  1431. * @reo_res_bitmap: REO blocking resource index
  1432. * @index:
  1433. * @target_type:
  1434. * @version:
  1435. * @shadow_config: shadow register configuration
  1436. * @num_shadow_registers_configured:
  1437. * @use_register_windowing:
  1438. * @register_window:
  1439. * @register_access_lock:
  1440. * @static_window_map: Static window map configuration for multiple window write
  1441. * @hw_srng_table: srng table
  1442. * @hal_hw_reg_offset:
  1443. * @ops: TXRX operations
  1444. * @init_phase: Indicate srngs initialization
  1445. * @stats: Hal level stats
  1446. * @reg_wr_fail_hist: write failure history
  1447. * @reg_write_queue: queue(array) to hold register writes
  1448. * @reg_write_work: delayed work to be queued into workqueue
  1449. * @reg_write_wq: workqueue for delayed register writes
  1450. * @write_idx: write index used by caller to enqueue delayed work
  1451. * @read_idx: read index used by worker thread to dequeue/write registers
  1452. * @active_work_cnt:
  1453. * @list_shadow_reg_config: array of generic regs mapped to
  1454. * shadow regs
  1455. * @num_generic_shadow_regs_configured: number of generic regs
  1456. * mapped to shadow regs
  1457. * @dmac_cmn_src_rxbuf_ring: flag to indicate cmn dmac rings in beryllium
  1458. * @reo_qref: Reo queue ref table items
  1459. */
  1460. struct hal_soc {
  1461. struct hif_opaque_softc *hif_handle;
  1462. qdf_device_t qdf_dev;
  1463. void *dev_base_addr;
  1464. void *dev_base_addr_ce;
  1465. void *dev_base_addr_cmem;
  1466. void *dev_base_addr_pmm;
  1467. struct hal_srng srng_list[HAL_SRNG_ID_MAX];
  1468. uint32_t *shadow_rdptr_mem_vaddr;
  1469. qdf_dma_addr_t shadow_rdptr_mem_paddr;
  1470. uint32_t *shadow_wrptr_mem_vaddr;
  1471. qdf_dma_addr_t shadow_wrptr_mem_paddr;
  1472. uint8_t reo_res_bitmap;
  1473. uint8_t index;
  1474. uint32_t target_type;
  1475. uint32_t version;
  1476. union hal_shadow_reg_cfg shadow_config[MAX_SHADOW_REGISTERS];
  1477. int num_shadow_registers_configured;
  1478. bool use_register_windowing;
  1479. uint32_t register_window;
  1480. qdf_spinlock_t register_access_lock;
  1481. bool static_window_map;
  1482. struct hal_hw_srng_config *hw_srng_table;
  1483. int32_t hal_hw_reg_offset[SRNG_REGISTER_MAX];
  1484. struct hal_hw_txrx_ops *ops;
  1485. bool init_phase;
  1486. struct hal_soc_stats stats;
  1487. #ifdef ENABLE_HAL_REG_WR_HISTORY
  1488. struct hal_reg_write_fail_history *reg_wr_fail_hist;
  1489. #endif
  1490. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  1491. struct hal_reg_write_q_elem *reg_write_queue;
  1492. qdf_work_t reg_write_work;
  1493. qdf_workqueue_t *reg_write_wq;
  1494. qdf_atomic_t write_idx;
  1495. uint32_t read_idx;
  1496. #endif /*FEATURE_HAL_DELAYED_REG_WRITE */
  1497. qdf_atomic_t active_work_cnt;
  1498. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  1499. struct shadow_reg_config
  1500. list_shadow_reg_config[MAX_GENERIC_SHADOW_REG];
  1501. int num_generic_shadow_regs_configured;
  1502. #endif
  1503. bool dmac_cmn_src_rxbuf_ring;
  1504. struct reo_queue_ref_table reo_qref;
  1505. };
  1506. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1507. /**
  1508. * hal_delayed_reg_write() - delayed register write
  1509. * @hal_soc: HAL soc handle
  1510. * @srng: hal srng
  1511. * @addr: iomem address
  1512. * @value: value to be written
  1513. *
  1514. * Return: none
  1515. */
  1516. void hal_delayed_reg_write(struct hal_soc *hal_soc,
  1517. struct hal_srng *srng,
  1518. void __iomem *addr,
  1519. uint32_t value);
  1520. #endif
  1521. void hal_qca6750_attach(struct hal_soc *hal_soc);
  1522. void hal_qca6490_attach(struct hal_soc *hal_soc);
  1523. void hal_qca6390_attach(struct hal_soc *hal_soc);
  1524. void hal_qca6290_attach(struct hal_soc *hal_soc);
  1525. void hal_qca8074_attach(struct hal_soc *hal_soc);
  1526. /**
  1527. * hal_kiwi_attach() - Attach kiwi target specific hal_soc ops,
  1528. * offset and srng table
  1529. * @hal_soc: HAL soc
  1530. */
  1531. void hal_kiwi_attach(struct hal_soc *hal_soc);
  1532. void hal_qcn9224v2_attach(struct hal_soc *hal_soc);
  1533. void hal_wcn6450_attach(struct hal_soc *hal_soc);
  1534. /**
  1535. * hal_soc_to_hal_soc_handle() - API to convert hal_soc to opaque
  1536. * hal_soc_handle_t type
  1537. * @hal_soc: hal_soc type
  1538. *
  1539. * Return: hal_soc_handle_t type
  1540. */
  1541. static inline
  1542. hal_soc_handle_t hal_soc_to_hal_soc_handle(struct hal_soc *hal_soc)
  1543. {
  1544. return (hal_soc_handle_t)hal_soc;
  1545. }
  1546. /**
  1547. * hal_srng_to_hal_ring_handle() - API to convert hal_srng to opaque
  1548. * hal_ring handle_t type
  1549. * @hal_srng: hal_srng type
  1550. *
  1551. * Return: hal_ring_handle_t type
  1552. */
  1553. static inline
  1554. hal_ring_handle_t hal_srng_to_hal_ring_handle(struct hal_srng *hal_srng)
  1555. {
  1556. return (hal_ring_handle_t)hal_srng;
  1557. }
  1558. /**
  1559. * hal_ring_handle_to_hal_srng() - API to convert hal_ring_handle_t to hal_srng
  1560. * @hal_ring: hal_ring_handle_t type
  1561. *
  1562. * Return: hal_srng pointer type
  1563. */
  1564. static inline
  1565. struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring)
  1566. {
  1567. return (struct hal_srng *)hal_ring;
  1568. }
  1569. /* Size of REO queue reference table in Host
  1570. * 2k peers * 17 tids * 8bytes(rx_reo_queue_reference)
  1571. * = 278528 bytes
  1572. */
  1573. #define REO_QUEUE_REF_NON_ML_TABLE_SIZE 278528
  1574. /* Calculated based on 512 MLO peers */
  1575. #define REO_QUEUE_REF_ML_TABLE_SIZE 69632
  1576. #define HAL_ML_PEER_ID_START 0x2000
  1577. #define HAL_PEER_ID_IS_MLO(peer_id) ((peer_id) & HAL_ML_PEER_ID_START)
  1578. /*
  1579. * REO2PPE destination indication
  1580. */
  1581. #define REO2PPE_DST_IND 6
  1582. #define REO2PPE_DST_RING 11
  1583. #define REO2PPE_RULE_FAIL_FB 0x2000
  1584. /**
  1585. * enum hal_pkt_type - Type of packet type reported by HW
  1586. * @HAL_DOT11A: 802.11a PPDU type
  1587. * @HAL_DOT11B: 802.11b PPDU type
  1588. * @HAL_DOT11N_MM: 802.11n Mixed Mode PPDU type
  1589. * @HAL_DOT11AC: 802.11ac PPDU type
  1590. * @HAL_DOT11AX: 802.11ax PPDU type
  1591. * @HAL_DOT11BA: 802.11ba (WUR) PPDU type
  1592. * @HAL_DOT11BE: 802.11be PPDU type
  1593. * @HAL_DOT11AZ: 802.11az (ranging) PPDU type
  1594. * @HAL_DOT11N_GF: 802.11n Green Field PPDU type
  1595. * @HAL_DOT11_MAX: Maximum enumeration
  1596. *
  1597. * Enum indicating the packet type reported by HW in rx_pkt_tlvs (RX data)
  1598. * or WBM2SW ring entry's descriptor (TX data completion)
  1599. */
  1600. enum hal_pkt_type {
  1601. HAL_DOT11A = 0,
  1602. HAL_DOT11B = 1,
  1603. HAL_DOT11N_MM = 2,
  1604. HAL_DOT11AC = 3,
  1605. HAL_DOT11AX = 4,
  1606. HAL_DOT11BA = 5,
  1607. HAL_DOT11BE = 6,
  1608. HAL_DOT11AZ = 7,
  1609. HAL_DOT11N_GF = 8,
  1610. HAL_DOT11_MAX,
  1611. };
  1612. #endif /* _HAL_INTERNAL_H_ */