hal_internal.h 47 KB

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