hal_internal.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464
  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. SRNG_REGISTER_MAX,
  362. };
  363. enum hal_srng_dir {
  364. HAL_SRNG_SRC_RING,
  365. HAL_SRNG_DST_RING
  366. };
  367. /**
  368. * enum hal_reo_remap_reg - REO remap registers
  369. * @HAL_REO_REMAP_REG_IX0: reo remap reg IX0
  370. * @HAL_REO_REMAP_REG_IX1: reo remap reg IX1
  371. * @HAL_REO_REMAP_REG_IX2: reo remap reg IX2
  372. * @HAL_REO_REMAP_REG_IX3: reo remap reg IX3
  373. */
  374. enum hal_reo_remap_reg {
  375. HAL_REO_REMAP_REG_IX0,
  376. HAL_REO_REMAP_REG_IX1,
  377. HAL_REO_REMAP_REG_IX2,
  378. HAL_REO_REMAP_REG_IX3
  379. };
  380. /* Lock wrappers for SRNG */
  381. #define hal_srng_lock_t qdf_spinlock_t
  382. #define SRNG_LOCK_INIT(_lock) qdf_spinlock_create(_lock)
  383. #define SRNG_LOCK(_lock) qdf_spin_lock_bh(_lock)
  384. #define SRNG_TRY_LOCK(_lock) qdf_spin_trylock_bh(_lock)
  385. #define SRNG_UNLOCK(_lock) qdf_spin_unlock_bh(_lock)
  386. #define SRNG_LOCK_DESTROY(_lock) qdf_spinlock_destroy(_lock)
  387. struct hal_soc;
  388. /**
  389. * dp_hal_ring - opaque handle for DP HAL SRNG
  390. */
  391. struct hal_ring_handle;
  392. typedef struct hal_ring_handle *hal_ring_handle_t;
  393. #define MAX_SRNG_REG_GROUPS 2
  394. /* Hal Srng bit mask
  395. * HAL_SRNG_FLUSH_EVENT: SRNG HP TP flush in case of link down
  396. */
  397. #define HAL_SRNG_FLUSH_EVENT BIT(0)
  398. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  399. /**
  400. * struct hal_reg_write_q_elem - delayed register write queue element
  401. * @srng: hal_srng queued for a delayed write
  402. * @addr: iomem address of the register
  403. * @enqueue_val: register value at the time of delayed write enqueue
  404. * @dequeue_val: register value at the time of delayed write dequeue
  405. * @valid: whether this entry is valid or not
  406. * @enqueue_time: enqueue time (qdf_log_timestamp)
  407. * @work_scheduled_time: work scheduled time (qdf_log_timestamp)
  408. * @dequeue_time: dequeue time (qdf_log_timestamp)
  409. * @cpu_id: record cpuid when schedule work
  410. */
  411. struct hal_reg_write_q_elem {
  412. struct hal_srng *srng;
  413. void __iomem *addr;
  414. uint32_t enqueue_val;
  415. uint32_t dequeue_val;
  416. uint8_t valid;
  417. qdf_time_t enqueue_time;
  418. qdf_time_t work_scheduled_time;
  419. qdf_time_t dequeue_time;
  420. int cpu_id;
  421. };
  422. /**
  423. * struct hal_reg_write_srng_stats - srng stats to keep track of register writes
  424. * @enqueues: writes enqueued to delayed work
  425. * @dequeues: writes dequeued from delayed work (not written yet)
  426. * @coalesces: writes not enqueued since srng is already queued up
  427. * @direct: writes not enqueued and written to register directly
  428. * @dequeue_delay: dequeue operation be delayed
  429. */
  430. struct hal_reg_write_srng_stats {
  431. uint32_t enqueues;
  432. uint32_t dequeues;
  433. uint32_t coalesces;
  434. uint32_t direct;
  435. uint32_t dequeue_delay;
  436. };
  437. /**
  438. * enum hal_reg_sched_delay - ENUM for write sched delay histogram
  439. * @REG_WRITE_SCHED_DELAY_SUB_100us: index for delay < 100us
  440. * @REG_WRITE_SCHED_DELAY_SUB_1000us: index for delay < 1000us
  441. * @REG_WRITE_SCHED_DELAY_SUB_5000us: index for delay < 5000us
  442. * @REG_WRITE_SCHED_DELAY_GT_5000us: index for delay >= 5000us
  443. * @REG_WRITE_SCHED_DELAY_HIST_MAX: Max value (nnsize of histogram array)
  444. */
  445. enum hal_reg_sched_delay {
  446. REG_WRITE_SCHED_DELAY_SUB_100us,
  447. REG_WRITE_SCHED_DELAY_SUB_1000us,
  448. REG_WRITE_SCHED_DELAY_SUB_5000us,
  449. REG_WRITE_SCHED_DELAY_GT_5000us,
  450. REG_WRITE_SCHED_DELAY_HIST_MAX,
  451. };
  452. /**
  453. * struct hal_reg_write_soc_stats - soc stats to keep track of register writes
  454. * @enqueues: writes enqueued to delayed work
  455. * @dequeues: writes dequeued from delayed work (not written yet)
  456. * @coalesces: writes not enqueued since srng is already queued up
  457. * @direct: writes not enqueud and writted to register directly
  458. * @prevent_l1_fails: prevent l1 API failed
  459. * @q_depth: current queue depth in delayed register write queue
  460. * @max_q_depth: maximum queue for delayed register write queue
  461. * @sched_delay: = kernel work sched delay + bus wakeup delay, histogram
  462. * @dequeue_delay: dequeue operation be delayed
  463. */
  464. struct hal_reg_write_soc_stats {
  465. qdf_atomic_t enqueues;
  466. uint32_t dequeues;
  467. qdf_atomic_t coalesces;
  468. qdf_atomic_t direct;
  469. uint32_t prevent_l1_fails;
  470. qdf_atomic_t q_depth;
  471. uint32_t max_q_depth;
  472. uint32_t sched_delay[REG_WRITE_SCHED_DELAY_HIST_MAX];
  473. uint32_t dequeue_delay;
  474. };
  475. #endif
  476. struct hal_offload_info {
  477. uint8_t lro_eligible;
  478. uint8_t tcp_proto;
  479. uint8_t tcp_pure_ack;
  480. uint8_t ipv6_proto;
  481. uint8_t tcp_offset;
  482. uint16_t tcp_csum;
  483. uint16_t tcp_win;
  484. uint32_t tcp_seq_num;
  485. uint32_t tcp_ack_num;
  486. uint32_t flow_id;
  487. };
  488. #ifdef WLAN_DP_SRNG_USAGE_WM_TRACKING
  489. /**
  490. * enum hal_srng_high_wm_bin - BIN for SRNG high watermark
  491. * @HAL_SRNG_HIGH_WM_BIN_BELOW_50_PERCENT: <50% SRNG entries used
  492. * @HAL_SRNG_HIGH_WM_BIN_50_to_60: 50-60% SRNG entries used
  493. * @HAL_SRNG_HIGH_WM_BIN_60_to_70: 60-70% SRNG entries used
  494. * @HAL_SRNG_HIGH_WM_BIN_70_to_80: 70-80% SRNG entries used
  495. * @HAL_SRNG_HIGH_WM_BIN_80_to_90: 80-90% SRNG entries used
  496. * @HAL_SRNG_HIGH_WM_BIN_90_to_100: 90-100% SRNG entries used
  497. */
  498. enum hal_srng_high_wm_bin {
  499. HAL_SRNG_HIGH_WM_BIN_BELOW_50_PERCENT,
  500. HAL_SRNG_HIGH_WM_BIN_50_to_60,
  501. HAL_SRNG_HIGH_WM_BIN_60_to_70,
  502. HAL_SRNG_HIGH_WM_BIN_70_to_80,
  503. HAL_SRNG_HIGH_WM_BIN_80_to_90,
  504. HAL_SRNG_HIGH_WM_BIN_90_to_100,
  505. HAL_SRNG_HIGH_WM_BIN_MAX,
  506. };
  507. /**
  508. * struct hal_srng_high_wm_info - SRNG usage high watermark info
  509. * @val: highest number of entries used in SRNG
  510. * @timestamp: Timestamp when the max num entries were in used for a SRNG
  511. * @bin_thresh: threshold for each bins
  512. * @bins: Bins for srng usage
  513. */
  514. struct hal_srng_high_wm_info {
  515. uint32_t val;
  516. uint64_t timestamp;
  517. uint32_t bin_thresh[HAL_SRNG_HIGH_WM_BIN_MAX];
  518. uint32_t bins[HAL_SRNG_HIGH_WM_BIN_MAX];
  519. };
  520. #endif
  521. /* Common SRNG ring structure for source and destination rings */
  522. struct hal_srng {
  523. /* Unique SRNG ring ID */
  524. uint8_t ring_id;
  525. /* Ring initialization done */
  526. uint8_t initialized;
  527. /* Interrupt/MSI value assigned to this ring */
  528. int irq;
  529. /* Physical base address of the ring */
  530. qdf_dma_addr_t ring_base_paddr;
  531. /* Virtual base address of the ring */
  532. uint32_t *ring_base_vaddr;
  533. /* virtual address end */
  534. uint32_t *ring_vaddr_end;
  535. /* Number of entries in ring */
  536. uint32_t num_entries;
  537. /* Ring size */
  538. uint32_t ring_size;
  539. /* Ring size mask */
  540. uint32_t ring_size_mask;
  541. /* Size of ring entry */
  542. uint32_t entry_size;
  543. /* Interrupt timer threshold – in micro seconds */
  544. uint32_t intr_timer_thres_us;
  545. /* Interrupt batch counter threshold – in number of ring entries */
  546. uint32_t intr_batch_cntr_thres_entries;
  547. /* Applicable only for CE dest ring */
  548. uint32_t prefetch_timer;
  549. /* MSI Address */
  550. qdf_dma_addr_t msi_addr;
  551. /* MSI data */
  552. uint32_t msi_data;
  553. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  554. /* MSI2 Address */
  555. qdf_dma_addr_t msi2_addr;
  556. /* MSI2 data */
  557. uint32_t msi2_data;
  558. #endif
  559. /* Misc flags */
  560. uint32_t flags;
  561. /* Lock for serializing ring index updates */
  562. hal_srng_lock_t lock;
  563. /* Start offset of SRNG register groups for this ring
  564. * TBD: See if this is required - register address can be derived
  565. * from ring ID
  566. */
  567. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  568. /* Ring type/name */
  569. enum hal_ring_type ring_type;
  570. /* Source or Destination ring */
  571. enum hal_srng_dir ring_dir;
  572. union {
  573. struct {
  574. /* SW tail pointer */
  575. uint32_t tp;
  576. /* Shadow head pointer location to be updated by HW */
  577. uint32_t *hp_addr;
  578. /* Cached head pointer */
  579. uint32_t cached_hp;
  580. /* Tail pointer location to be updated by SW – This
  581. * will be a register address and need not be
  582. * accessed through SW structure */
  583. uint32_t *tp_addr;
  584. /* Current SW loop cnt */
  585. uint32_t loop_cnt;
  586. /* max transfer size */
  587. uint16_t max_buffer_length;
  588. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  589. /* near full IRQ supported */
  590. uint16_t nf_irq_support;
  591. /* High threshold for Near full IRQ */
  592. uint16_t high_thresh;
  593. #endif
  594. } dst_ring;
  595. struct {
  596. /* SW head pointer */
  597. uint32_t hp;
  598. /* SW reap head pointer */
  599. uint32_t reap_hp;
  600. /* Shadow tail pointer location to be updated by HW */
  601. uint32_t *tp_addr;
  602. /* Cached tail pointer */
  603. uint32_t cached_tp;
  604. /* Head pointer location to be updated by SW – This
  605. * will be a register address and need not be accessed
  606. * through SW structure */
  607. uint32_t *hp_addr;
  608. /* Low threshold – in number of ring entries */
  609. uint32_t low_threshold;
  610. } src_ring;
  611. } u;
  612. struct hal_soc *hal_soc;
  613. /* Number of times hp/tp updated in runtime resume */
  614. uint32_t flush_count;
  615. /* hal srng event flag*/
  616. unsigned long srng_event;
  617. /* last flushed time stamp */
  618. uint64_t last_flush_ts;
  619. #if defined(CLEAR_SW2TCL_CONSUMED_DESC)
  620. /* last ring desc entry cleared */
  621. uint32_t last_desc_cleared;
  622. #endif
  623. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  624. /* flag to indicate whether srng is already queued for delayed write */
  625. uint8_t reg_write_in_progress;
  626. /* last dequeue elem time stamp */
  627. qdf_time_t last_dequeue_time;
  628. /* srng specific delayed write stats */
  629. struct hal_reg_write_srng_stats wstats;
  630. #endif
  631. #ifdef WLAN_DP_SRNG_USAGE_WM_TRACKING
  632. struct hal_srng_high_wm_info high_wm;
  633. #endif
  634. };
  635. /* HW SRNG configuration table */
  636. struct hal_hw_srng_config {
  637. int start_ring_id;
  638. uint16_t max_rings;
  639. uint16_t entry_size;
  640. uint32_t reg_start[MAX_SRNG_REG_GROUPS];
  641. uint16_t reg_size[MAX_SRNG_REG_GROUPS];
  642. uint8_t lmac_ring;
  643. enum hal_srng_dir ring_dir;
  644. uint32_t max_size;
  645. bool nf_irq_support;
  646. };
  647. #define MAX_SHADOW_REGISTERS 40
  648. #define MAX_GENERIC_SHADOW_REG 5
  649. /**
  650. * struct shadow_reg_config - Hal soc structure that contains
  651. * the list of generic shadow registers
  652. * @target_register: target reg offset
  653. * @shadow_config_index: shadow config index in shadow config
  654. * list sent to FW
  655. * @va: virtual addr of shadow reg
  656. *
  657. * This structure holds the generic registers that are mapped to
  658. * the shadow region and holds the mapping of the target
  659. * register offset to shadow config index provided to FW during
  660. * init
  661. */
  662. struct shadow_reg_config {
  663. uint32_t target_register;
  664. int shadow_config_index;
  665. uint64_t va;
  666. };
  667. /* REO parameters to be passed to hal_reo_setup */
  668. struct hal_reo_params {
  669. /** rx hash steering enabled or disabled */
  670. bool rx_hash_enabled;
  671. /** reo remap 0 register */
  672. uint32_t remap0;
  673. /** reo remap 1 register */
  674. uint32_t remap1;
  675. /** reo remap 2 register */
  676. uint32_t remap2;
  677. /** fragment destination ring */
  678. uint8_t frag_dst_ring;
  679. /* Destination for alternate */
  680. uint8_t alt_dst_ind_0;
  681. /** padding */
  682. uint8_t padding[2];
  683. };
  684. /**
  685. * enum hal_reo_cmd_type: Enum for REO command type
  686. * @CMD_GET_QUEUE_STATS: Get REO queue status/stats
  687. * @CMD_FLUSH_QUEUE: Flush all frames in REO queue
  688. * @CMD_FLUSH_CACHE: Flush descriptor entries in the cache
  689. * @CMD_UNBLOCK_CACHE: Unblock a descriptor’s address that was blocked
  690. * earlier with a ‘REO_FLUSH_CACHE’ command
  691. * @CMD_FLUSH_TIMEOUT_LIST: Flush buffers/descriptors from timeout list
  692. * @CMD_UPDATE_RX_REO_QUEUE: Update REO queue settings
  693. */
  694. enum hal_reo_cmd_type {
  695. CMD_GET_QUEUE_STATS = 0,
  696. CMD_FLUSH_QUEUE = 1,
  697. CMD_FLUSH_CACHE = 2,
  698. CMD_UNBLOCK_CACHE = 3,
  699. CMD_FLUSH_TIMEOUT_LIST = 4,
  700. CMD_UPDATE_RX_REO_QUEUE = 5
  701. };
  702. /**
  703. * enum hal_tx_mcast_mlo_reinject_notify
  704. * @HAL_TX_MCAST_MLO_REINJECT_FW_NOTIFY: MLO Mcast reinject routed to FW
  705. * @HAL_TX_MCAST_MLO_REINJECT_TQM_NOTIFY: MLO Mcast reinject routed to TQM
  706. */
  707. enum hal_tx_mcast_mlo_reinject_notify {
  708. HAL_TX_MCAST_MLO_REINJECT_FW_NOTIFY = 0,
  709. HAL_TX_MCAST_MLO_REINJECT_TQM_NOTIFY,
  710. };
  711. /**
  712. * enum hal_tx_vdev_mismatch_notify
  713. * @HAL_TX_VDEV_MISMATCH_TQM_NOTIFY: vdev mismatch exception routed to TQM
  714. * @HAL_TX_VDEV_MISMATCH_FW_NOTIFY: vdev mismatch exception routed to FW
  715. */
  716. enum hal_tx_vdev_mismatch_notify {
  717. HAL_TX_VDEV_MISMATCH_TQM_NOTIFY = 0,
  718. HAL_TX_VDEV_MISMATCH_FW_NOTIFY,
  719. };
  720. struct hal_rx_pkt_capture_flags {
  721. uint8_t encrypt_type;
  722. uint8_t fragment_flag;
  723. uint8_t fcs_err;
  724. uint32_t chan_freq;
  725. uint32_t rssi_comb;
  726. uint64_t tsft;
  727. };
  728. struct hal_hw_txrx_ops {
  729. /* init and setup */
  730. void (*hal_srng_dst_hw_init)(struct hal_soc *hal,
  731. struct hal_srng *srng);
  732. void (*hal_srng_src_hw_init)(struct hal_soc *hal,
  733. struct hal_srng *srng);
  734. void (*hal_get_hw_hptp)(struct hal_soc *hal,
  735. hal_ring_handle_t hal_ring_hdl,
  736. uint32_t *headp, uint32_t *tailp,
  737. uint8_t ring_type);
  738. void (*hal_reo_setup)(struct hal_soc *hal_soc, void *reoparams);
  739. void (*hal_setup_link_idle_list)(
  740. struct hal_soc *hal_soc,
  741. qdf_dma_addr_t scatter_bufs_base_paddr[],
  742. void *scatter_bufs_base_vaddr[],
  743. uint32_t num_scatter_bufs,
  744. uint32_t scatter_buf_size,
  745. uint32_t last_buf_end_offset,
  746. uint32_t num_entries);
  747. qdf_iomem_t (*hal_get_window_address)(struct hal_soc *hal_soc,
  748. qdf_iomem_t addr);
  749. void (*hal_reo_set_err_dst_remap)(void *hal_soc);
  750. uint8_t (*hal_reo_enable_pn_in_dest)(void *hal_soc);
  751. void (*hal_reo_qdesc_setup)(hal_soc_handle_t hal_soc_hdl, int tid,
  752. uint32_t ba_window_size,
  753. uint32_t start_seq, void *hw_qdesc_vaddr,
  754. qdf_dma_addr_t hw_qdesc_paddr,
  755. int pn_type, uint8_t vdev_stats_id);
  756. uint32_t (*hal_gen_reo_remap_val)(enum hal_reo_remap_reg,
  757. uint8_t *ix0_map);
  758. /* tx */
  759. void (*hal_tx_desc_set_dscp_tid_table_id)(void *desc, uint8_t id);
  760. void (*hal_tx_set_dscp_tid_map)(struct hal_soc *hal_soc, uint8_t *map,
  761. uint8_t id);
  762. void (*hal_tx_update_dscp_tid)(struct hal_soc *hal_soc, uint8_t tid,
  763. uint8_t id,
  764. uint8_t dscp);
  765. void (*hal_tx_desc_set_lmac_id)(void *desc, uint8_t lmac_id);
  766. void (*hal_tx_desc_set_buf_addr)(void *desc, dma_addr_t paddr,
  767. uint8_t pool_id, uint32_t desc_id,
  768. uint8_t type);
  769. void (*hal_tx_desc_set_search_type)(void *desc, uint8_t search_type);
  770. void (*hal_tx_desc_set_search_index)(void *desc, uint32_t search_index);
  771. void (*hal_tx_desc_set_cache_set_num)(void *desc, uint8_t search_index);
  772. void (*hal_tx_comp_get_status)(void *desc, void *ts,
  773. struct hal_soc *hal);
  774. uint8_t (*hal_tx_comp_get_release_reason)(void *hal_desc);
  775. uint8_t (*hal_get_wbm_internal_error)(void *hal_desc);
  776. void (*hal_tx_desc_set_mesh_en)(void *desc, uint8_t en);
  777. void (*hal_tx_init_cmd_credit_ring)(hal_soc_handle_t hal_soc_hdl,
  778. hal_ring_handle_t hal_ring_hdl);
  779. uint32_t (*hal_tx_comp_get_buffer_source)(void *hal_desc);
  780. uint32_t (*hal_tx_get_num_ppe_vp_tbl_entries)(
  781. hal_soc_handle_t hal_soc_hdl);
  782. void (*hal_tx_set_ppe_cmn_cfg)(hal_soc_handle_t hal_soc_hdl,
  783. union hal_tx_cmn_config_ppe *cmn_cfg);
  784. void (*hal_tx_set_ppe_vp_entry)(hal_soc_handle_t hal_soc_hdl,
  785. union hal_tx_ppe_vp_config *vp_cfg,
  786. int ppe_vp_idx);
  787. void (*hal_tx_set_ppe_pri2tid)(hal_soc_handle_t hal_soc_hdl,
  788. uint32_t val,
  789. uint8_t map_no);
  790. void (*hal_tx_update_ppe_pri2tid)(hal_soc_handle_t hal_soc_hdl,
  791. uint8_t pri,
  792. uint8_t tid);
  793. void (*hal_tx_dump_ppe_vp_entry)(hal_soc_handle_t hal_soc_hdl);
  794. void (*hal_tx_enable_pri2tid_map)(hal_soc_handle_t hal_soc_hdl,
  795. bool value, uint8_t ppe_vp_idx);
  796. void (*hal_tx_config_rbm_mapping_be)(hal_soc_handle_t hal_soc_hdl,
  797. hal_ring_handle_t hal_ring_hdl,
  798. uint8_t rbm_id);
  799. /* rx */
  800. uint32_t (*hal_rx_msdu_start_nss_get)(uint8_t *);
  801. void (*hal_rx_mon_hw_desc_get_mpdu_status)(void *hw_desc_addr,
  802. struct mon_rx_status *rs);
  803. uint8_t (*hal_rx_get_tlv)(void *rx_tlv);
  804. void (*hal_rx_proc_phyrx_other_receive_info_tlv)(void *rx_tlv_hdr,
  805. void *ppdu_info_handle);
  806. void (*hal_rx_dump_msdu_start_tlv)(void *msdu_start, uint8_t dbg_level);
  807. void (*hal_rx_dump_msdu_end_tlv)(void *msdu_end,
  808. uint8_t dbg_level);
  809. uint32_t (*hal_get_link_desc_size)(void);
  810. uint32_t (*hal_rx_mpdu_start_tid_get)(uint8_t *buf);
  811. uint32_t (*hal_rx_msdu_start_reception_type_get)(uint8_t *buf);
  812. uint16_t (*hal_rx_msdu_end_da_idx_get)(uint8_t *buf);
  813. void* (*hal_rx_msdu_desc_info_get_ptr)(void *msdu_details_ptr);
  814. void* (*hal_rx_link_desc_msdu0_ptr)(void *msdu_link_ptr);
  815. void (*hal_reo_status_get_header)(hal_ring_desc_t ring_desc, int b,
  816. void *h);
  817. uint32_t (*hal_rx_status_get_tlv_info)(void *rx_tlv_hdr,
  818. void *ppdu_info,
  819. hal_soc_handle_t hal_soc_hdl,
  820. qdf_nbuf_t nbuf);
  821. void (*hal_rx_wbm_rel_buf_paddr_get)(hal_ring_desc_t rx_desc,
  822. struct hal_buf_info *buf_info);
  823. void (*hal_rx_wbm_err_info_get)(void *wbm_desc,
  824. void *wbm_er_info);
  825. void (*hal_rx_dump_mpdu_start_tlv)(void *mpdustart,
  826. uint8_t dbg_level);
  827. void (*hal_tx_set_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t *map);
  828. void (*hal_tx_update_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t pcp,
  829. uint8_t id);
  830. void (*hal_tx_set_tidmap_prty)(struct hal_soc *hal_soc, uint8_t prio);
  831. /* rx */
  832. uint8_t (*hal_rx_get_rx_fragment_number)(uint8_t *buf);
  833. uint8_t (*hal_rx_msdu_end_da_is_mcbc_get)(uint8_t *buf);
  834. uint8_t (*hal_rx_msdu_end_is_tkip_mic_err)(uint8_t *buf);
  835. uint8_t (*hal_rx_msdu_end_sa_is_valid_get)(uint8_t *buf);
  836. uint16_t (*hal_rx_msdu_end_sa_idx_get)(uint8_t *buf);
  837. uint32_t (*hal_rx_desc_is_first_msdu)(void *hw_desc_addr);
  838. uint32_t (*hal_rx_msdu_end_l3_hdr_padding_get)(uint8_t *buf);
  839. uint32_t (*hal_rx_encryption_info_valid)(uint8_t *buf);
  840. void (*hal_rx_print_pn)(uint8_t *buf);
  841. uint8_t (*hal_rx_msdu_end_first_msdu_get)(uint8_t *buf);
  842. uint8_t (*hal_rx_msdu_end_da_is_valid_get)(uint8_t *buf);
  843. uint8_t (*hal_rx_msdu_end_last_msdu_get)(uint8_t *buf);
  844. bool (*hal_rx_get_mpdu_mac_ad4_valid)(uint8_t *buf);
  845. uint32_t (*hal_rx_mpdu_start_sw_peer_id_get)(uint8_t *buf);
  846. uint32_t (*hal_rx_tlv_peer_meta_data_get)(uint8_t *buf);
  847. uint32_t (*hal_rx_mpdu_get_to_ds)(uint8_t *buf);
  848. uint32_t (*hal_rx_mpdu_get_fr_ds)(uint8_t *buf);
  849. uint8_t (*hal_rx_get_mpdu_frame_control_valid)(uint8_t *buf);
  850. QDF_STATUS
  851. (*hal_rx_mpdu_get_addr1)(uint8_t *buf, uint8_t *mac_addr);
  852. QDF_STATUS
  853. (*hal_rx_mpdu_get_addr2)(uint8_t *buf, uint8_t *mac_addr);
  854. QDF_STATUS
  855. (*hal_rx_mpdu_get_addr3)(uint8_t *buf, uint8_t *mac_addr);
  856. QDF_STATUS
  857. (*hal_rx_mpdu_get_addr4)(uint8_t *buf, uint8_t *mac_addr);
  858. uint8_t (*hal_rx_get_mpdu_sequence_control_valid)(uint8_t *buf);
  859. bool (*hal_rx_is_unicast)(uint8_t *buf);
  860. uint32_t (*hal_rx_tid_get)(hal_soc_handle_t hal_soc_hdl, uint8_t *buf);
  861. uint32_t (*hal_rx_hw_desc_get_ppduid_get)(void *rx_tlv_hdr,
  862. void *rxdma_dst_ring_desc);
  863. uint32_t (*hal_rx_mpdu_start_mpdu_qos_control_valid_get)(uint8_t *buf);
  864. uint32_t (*hal_rx_msdu_end_sa_sw_peer_id_get)(uint8_t *buf);
  865. void * (*hal_rx_msdu0_buffer_addr_lsb)(void *link_desc_addr);
  866. void * (*hal_rx_msdu_desc_info_ptr_get)(void *msdu0);
  867. void * (*hal_ent_mpdu_desc_info)(void *hw_addr);
  868. void * (*hal_dst_mpdu_desc_info)(void *hw_addr);
  869. uint8_t (*hal_rx_get_fc_valid)(uint8_t *buf);
  870. uint8_t (*hal_rx_get_to_ds_flag)(uint8_t *buf);
  871. uint8_t (*hal_rx_get_mac_addr2_valid)(uint8_t *buf);
  872. uint8_t (*hal_rx_get_filter_category)(uint8_t *buf);
  873. uint32_t (*hal_rx_get_ppdu_id)(uint8_t *buf);
  874. void (*hal_reo_config)(struct hal_soc *soc,
  875. uint32_t reg_val,
  876. struct hal_reo_params *reo_params);
  877. uint32_t (*hal_rx_msdu_flow_idx_get)(uint8_t *buf);
  878. bool (*hal_rx_msdu_flow_idx_invalid)(uint8_t *buf);
  879. bool (*hal_rx_msdu_flow_idx_timeout)(uint8_t *buf);
  880. uint32_t (*hal_rx_msdu_fse_metadata_get)(uint8_t *buf);
  881. bool (*hal_rx_msdu_cce_match_get)(uint8_t *buf);
  882. uint16_t (*hal_rx_msdu_cce_metadata_get)(uint8_t *buf);
  883. void
  884. (*hal_rx_msdu_get_flow_params)(
  885. uint8_t *buf,
  886. bool *flow_invalid,
  887. bool *flow_timeout,
  888. uint32_t *flow_index);
  889. uint16_t (*hal_rx_tlv_get_tcp_chksum)(uint8_t *buf);
  890. uint16_t (*hal_rx_get_rx_sequence)(uint8_t *buf);
  891. void (*hal_rx_get_bb_info)(void *rx_tlv, void *ppdu_info_handle);
  892. void (*hal_rx_get_rtt_info)(void *rx_tlv, void *ppdu_info_handle);
  893. void (*hal_rx_msdu_packet_metadata_get)(uint8_t *buf,
  894. void *msdu_pkt_metadata);
  895. uint16_t (*hal_rx_get_fisa_cumulative_l4_checksum)(uint8_t *buf);
  896. uint16_t (*hal_rx_get_fisa_cumulative_ip_length)(uint8_t *buf);
  897. bool (*hal_rx_get_udp_proto)(uint8_t *buf);
  898. bool (*hal_rx_get_fisa_flow_agg_continuation)(uint8_t *buf);
  899. uint8_t (*hal_rx_get_fisa_flow_agg_count)(uint8_t *buf);
  900. bool (*hal_rx_get_fisa_timeout)(uint8_t *buf);
  901. uint8_t (*hal_rx_mpdu_start_tlv_tag_valid)(void *rx_tlv_hdr);
  902. void (*hal_rx_sw_mon_desc_info_get)(hal_ring_desc_t rxdma_dst_ring_desc,
  903. hal_rx_mon_desc_info_t mon_desc_info);
  904. uint8_t (*hal_rx_wbm_err_msdu_continuation_get)(void *ring_desc);
  905. uint32_t (*hal_rx_msdu_end_offset_get)(void);
  906. uint32_t (*hal_rx_attn_offset_get)(void);
  907. uint32_t (*hal_rx_msdu_start_offset_get)(void);
  908. uint32_t (*hal_rx_mpdu_start_offset_get)(void);
  909. uint32_t (*hal_rx_mpdu_end_offset_get)(void);
  910. uint32_t (*hal_rx_pkt_tlv_offset_get)(void);
  911. void * (*hal_rx_flow_setup_fse)(uint8_t *rx_fst,
  912. uint32_t table_offset,
  913. uint8_t *rx_flow);
  914. void * (*hal_rx_flow_get_tuple_info)(uint8_t *rx_fst,
  915. uint32_t hal_hash,
  916. uint8_t *tuple_info);
  917. QDF_STATUS (*hal_rx_flow_delete_entry)(uint8_t *fst,
  918. void *fse);
  919. uint32_t (*hal_rx_fst_get_fse_size)(void);
  920. void (*hal_compute_reo_remap_ix2_ix3)(uint32_t *ring,
  921. uint32_t num_rings,
  922. uint32_t *remap1,
  923. uint32_t *remap2);
  924. void (*hal_compute_reo_remap_ix0)(uint32_t *remap0);
  925. uint32_t (*hal_rx_flow_setup_cmem_fse)(
  926. struct hal_soc *soc, uint32_t cmem_ba,
  927. uint32_t table_offset, uint8_t *rx_flow);
  928. uint32_t (*hal_rx_flow_get_cmem_fse_ts)(struct hal_soc *soc,
  929. uint32_t fse_offset);
  930. void (*hal_rx_flow_get_cmem_fse)(struct hal_soc *soc,
  931. uint32_t fse_offset,
  932. uint32_t *fse, qdf_size_t len);
  933. void (*hal_cmem_write)(hal_soc_handle_t hal_soc_hdl, uint32_t offset,
  934. uint32_t value);
  935. void (*hal_rx_msdu_get_reo_destination_indication)(uint8_t *buf,
  936. uint32_t *reo_destination_indication);
  937. uint8_t (*hal_tx_get_num_tcl_banks)(void);
  938. uint32_t (*hal_get_reo_qdesc_size)(uint32_t ba_window_size, int tid);
  939. uint16_t (*hal_get_rx_max_ba_window)(int tid);
  940. void (*hal_set_link_desc_addr)(void *desc, uint32_t cookie,
  941. qdf_dma_addr_t link_desc_paddr,
  942. uint8_t bm_id);
  943. void (*hal_tx_init_data_ring)(hal_soc_handle_t hal_soc_hdl,
  944. hal_ring_handle_t hal_ring_hdl);
  945. void* (*hal_rx_msdu_ext_desc_info_get_ptr)(void *msdu_details_ptr);
  946. void (*hal_get_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
  947. uint8_t ac, uint32_t *value);
  948. void (*hal_set_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
  949. uint8_t ac, uint32_t value);
  950. uint32_t (*hal_get_reo_reg_base_offset)(void);
  951. void (*hal_rx_get_tlv_size)(uint16_t *rx_pkt_tlv_size,
  952. uint16_t *rx_mon_pkt_tlv_size);
  953. uint32_t (*hal_rx_msdu_is_wlan_mcast)(qdf_nbuf_t nbuf);
  954. uint32_t (*hal_rx_tlv_decap_format_get)(void *hw_desc_addr);
  955. void (*hal_rx_dump_pkt_tlvs)(hal_soc_handle_t hal_soc_hdl,
  956. uint8_t *buf, uint8_t dbg_level);
  957. int (*hal_rx_tlv_get_offload_info)(uint8_t *rx_tlv,
  958. struct hal_offload_info *offload_info);
  959. uint16_t (*hal_rx_tlv_phy_ppdu_id_get)(uint8_t *buf);
  960. uint32_t (*hal_rx_tlv_msdu_done_get)(uint8_t *buf);
  961. uint32_t (*hal_rx_tlv_msdu_len_get)(uint8_t *buf);
  962. uint16_t (*hal_rx_get_frame_ctrl_field)(uint8_t *buf);
  963. int (*hal_rx_get_proto_params)(uint8_t *buf, void *fisa_params);
  964. int (*hal_rx_get_l3_l4_offsets)(uint8_t *buf, uint32_t *l3_hdr_offset,
  965. uint32_t *l4_hdr_offset);
  966. uint32_t (*hal_rx_tlv_mic_err_get)(uint8_t *buf);
  967. uint32_t (*hal_rx_tlv_get_pkt_type)(uint8_t *buf);
  968. void (*hal_rx_tlv_get_pn_num)(uint8_t *buf, uint64_t *pn_num);
  969. void (*hal_rx_reo_prev_pn_get)(void *ring_desc, uint64_t *prev_pn);
  970. uint8_t * (*hal_rx_pkt_hdr_get)(uint8_t *buf);
  971. uint32_t (*hal_rx_msdu_reo_dst_ind_get)(hal_soc_handle_t hal_soc_hdl,
  972. void *msdu_link_desc);
  973. void (*hal_msdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
  974. void *msdu_desc_info, uint32_t dst_ind,
  975. uint32_t nbuf_len);
  976. void (*hal_mpdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
  977. void *mpdu_desc_info, uint32_t seq_no);
  978. #ifdef DP_UMAC_HW_RESET_SUPPORT
  979. void (*hal_unregister_reo_send_cmd)(struct hal_soc *hal_soc);
  980. void (*hal_register_reo_send_cmd)(struct hal_soc *hal_soc);
  981. #endif
  982. uint32_t (*hal_rx_tlv_sgi_get)(uint8_t *buf);
  983. uint32_t (*hal_rx_tlv_get_freq)(uint8_t *buf);
  984. uint8_t (*hal_rx_msdu_get_keyid)(uint8_t *buf);
  985. uint32_t (*hal_rx_tlv_rate_mcs_get)(uint8_t *buf);
  986. uint32_t (*hal_rx_tlv_decrypt_err_get)(uint8_t *buf);
  987. uint32_t (*hal_rx_tlv_first_mpdu_get)(uint8_t *buf);
  988. uint32_t (*hal_rx_tlv_bw_get)(uint8_t *buf);
  989. uint32_t (*hal_rx_tlv_get_is_decrypted)(uint8_t *buf);
  990. uint32_t (*hal_rx_wbm_err_src_get)(hal_ring_desc_t ring_desc);
  991. uint8_t (*hal_rx_ret_buf_manager_get)(hal_ring_desc_t ring_desc);
  992. void (*hal_rx_msdu_link_desc_set)(hal_soc_handle_t hal_soc_hdl,
  993. void *src_srng_desc,
  994. hal_buff_addrinfo_t buf_addr_info,
  995. uint8_t bm_action);
  996. void (*hal_rx_buf_cookie_rbm_get)(uint32_t *buf_addr_info_hdl,
  997. hal_buf_info_t buf_info_hdl);
  998. void (*hal_rx_reo_buf_paddr_get)(hal_ring_desc_t rx_desc,
  999. struct hal_buf_info *buf_info);
  1000. void (*hal_rxdma_buff_addr_info_set)(void *rxdma_entry,
  1001. qdf_dma_addr_t paddr,
  1002. uint32_t cookie, uint8_t manager);
  1003. uint32_t (*hal_rx_msdu_flags_get)(rx_msdu_desc_info_t msdu_desc_info_hdl);
  1004. uint32_t (*hal_rx_get_reo_error_code)(hal_ring_desc_t rx_desc);
  1005. void (*hal_rx_tlv_csum_err_get)(uint8_t *rx_tlv_hdr,
  1006. uint32_t *ip_csum_err,
  1007. uint32_t *tcp_udp_csum_err);
  1008. void (*hal_rx_mpdu_desc_info_get)(void *desc_addr,
  1009. void *mpdu_desc_info_hdl);
  1010. uint8_t (*hal_rx_err_status_get)(hal_ring_desc_t rx_desc);
  1011. uint8_t (*hal_rx_reo_buf_type_get)(hal_ring_desc_t rx_desc);
  1012. bool (*hal_rx_mpdu_info_ampdu_flag_get)(uint8_t *buf);
  1013. uint32_t (*hal_rx_tlv_mpdu_len_err_get)(void *hw_desc_addr);
  1014. uint32_t (*hal_rx_tlv_mpdu_fcs_err_get)(void *hw_desc_addr);
  1015. void (*hal_rx_tlv_get_pkt_capture_flags)(uint8_t *rx_tlv_hdr,
  1016. struct hal_rx_pkt_capture_flags *flags);
  1017. uint8_t *(*hal_rx_desc_get_80211_hdr)(void *hw_desc_addr);
  1018. uint32_t (*hal_rx_hw_desc_mpdu_user_id)(void *hw_desc_addr);
  1019. void (*hal_rx_priv_info_set_in_tlv)(uint8_t *buf,
  1020. uint8_t *priv_data,
  1021. uint32_t len);
  1022. void (*hal_rx_priv_info_get_from_tlv)(uint8_t *buf,
  1023. uint8_t *priv_data,
  1024. uint32_t len);
  1025. void (*hal_rx_tlv_msdu_len_set)(uint8_t *buf, uint32_t len);
  1026. void (*hal_rx_tlv_populate_mpdu_desc_info)(uint8_t *buf,
  1027. void *mpdu_desc_info_hdl);
  1028. uint8_t *(*hal_get_reo_ent_desc_qdesc_addr)(uint8_t *desc);
  1029. uint64_t (*hal_rx_get_qdesc_addr)(uint8_t *dst_ring_desc,
  1030. uint8_t *buf);
  1031. void (*hal_set_reo_ent_desc_reo_dest_ind)(uint8_t *desc,
  1032. uint32_t dst_ind);
  1033. /* REO CMD and STATUS */
  1034. int (*hal_reo_send_cmd)(hal_soc_handle_t hal_soc_hdl,
  1035. hal_ring_handle_t hal_ring_hdl,
  1036. enum hal_reo_cmd_type cmd,
  1037. void *params);
  1038. QDF_STATUS (*hal_reo_status_update)(hal_soc_handle_t hal_soc_hdl,
  1039. hal_ring_desc_t reo_desc,
  1040. void *st_handle,
  1041. uint32_t tlv, int *num_ref);
  1042. uint8_t (*hal_get_tlv_hdr_size)(void);
  1043. uint8_t (*hal_get_idle_link_bm_id)(uint8_t chip_id);
  1044. bool (*hal_txmon_is_mon_buf_addr_tlv)(void *tx_tlv_hdr);
  1045. void (*hal_txmon_populate_packet_info)(void *tx_tlv_hdr,
  1046. void *pkt_info);
  1047. /* TX MONITOR */
  1048. #ifdef QCA_MONITOR_2_0_SUPPORT
  1049. uint32_t (*hal_txmon_status_parse_tlv)(void *data_ppdu_info,
  1050. void *prot_ppdu_info,
  1051. void *data_status_info,
  1052. void *prot_status_info,
  1053. void *tx_tlv_hdr,
  1054. qdf_frag_t status_frag);
  1055. uint32_t (*hal_txmon_status_get_num_users)(void *tx_tlv_hdr,
  1056. uint8_t *num_users);
  1057. #endif /* QCA_MONITOR_2_0_SUPPORT */
  1058. void (*hal_reo_shared_qaddr_setup)(hal_soc_handle_t hal_soc_hdl);
  1059. void (*hal_reo_shared_qaddr_init)(hal_soc_handle_t hal_soc_hdl);
  1060. void (*hal_reo_shared_qaddr_detach)(hal_soc_handle_t hal_soc_hdl);
  1061. void (*hal_reo_shared_qaddr_write)(hal_soc_handle_t hal_soc_hdl,
  1062. uint16_t peer_id,
  1063. int tid,
  1064. qdf_dma_addr_t hw_qdesc_paddr);
  1065. #ifdef WLAN_FEATURE_MARK_FIRST_WAKEUP_PACKET
  1066. uint8_t (*hal_get_first_wow_wakeup_packet)(uint8_t *buf);
  1067. #endif
  1068. void (*hal_reo_shared_qaddr_cache_clear)(hal_soc_handle_t hal_soc_hdl);
  1069. uint32_t (*hal_rx_tlv_l3_type_get)(uint8_t *buf);
  1070. void (*hal_tx_vdev_mismatch_routing_set)(hal_soc_handle_t hal_soc_hdl,
  1071. enum hal_tx_vdev_mismatch_notify config);
  1072. void (*hal_tx_mcast_mlo_reinject_routing_set)(
  1073. hal_soc_handle_t hal_soc_hdl,
  1074. enum hal_tx_mcast_mlo_reinject_notify config);
  1075. void (*hal_cookie_conversion_reg_cfg_be)(hal_soc_handle_t hal_soc_hdl,
  1076. struct hal_hw_cc_config
  1077. *cc_cfg);
  1078. void (*hal_tx_populate_bank_register)(hal_soc_handle_t hal_soc_hdl,
  1079. union hal_tx_bank_config *config,
  1080. uint8_t bank_id);
  1081. void (*hal_tx_vdev_mcast_ctrl_set)(hal_soc_handle_t hal_soc_hdl,
  1082. uint8_t vdev_id,
  1083. uint8_t mcast_ctrl_val);
  1084. };
  1085. /**
  1086. * struct hal_soc_stats - Hal layer stats
  1087. * @reg_write_fail: number of failed register writes
  1088. * @wstats: delayed register write stats
  1089. * @shadow_reg_write_fail: shadow reg write failure stats
  1090. * @shadow_reg_write_succ: shadow reg write success stats
  1091. *
  1092. * This structure holds all the statistics at HAL layer.
  1093. */
  1094. struct hal_soc_stats {
  1095. uint32_t reg_write_fail;
  1096. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1097. struct hal_reg_write_soc_stats wstats;
  1098. #endif
  1099. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  1100. uint32_t shadow_reg_write_fail;
  1101. uint32_t shadow_reg_write_succ;
  1102. #endif
  1103. };
  1104. #ifdef ENABLE_HAL_REG_WR_HISTORY
  1105. /* The history size should always be a power of 2 */
  1106. #define HAL_REG_WRITE_HIST_SIZE 8
  1107. /**
  1108. * struct hal_reg_write_fail_entry - Record of
  1109. * register write which failed.
  1110. * @timestamp: timestamp of reg write failure
  1111. * @reg_offset: offset of register where the write failed
  1112. * @write_val: the value which was to be written
  1113. * @read_val: the value read back from the register after write
  1114. */
  1115. struct hal_reg_write_fail_entry {
  1116. uint64_t timestamp;
  1117. uint32_t reg_offset;
  1118. uint32_t write_val;
  1119. uint32_t read_val;
  1120. };
  1121. /**
  1122. * struct hal_reg_write_fail_history - Hal layer history
  1123. * of all the register write failures.
  1124. * @index: index to add the new record
  1125. * @record: array of all the records in history
  1126. *
  1127. * This structure holds the history of register write
  1128. * failures at HAL layer.
  1129. */
  1130. struct hal_reg_write_fail_history {
  1131. qdf_atomic_t index;
  1132. struct hal_reg_write_fail_entry record[HAL_REG_WRITE_HIST_SIZE];
  1133. };
  1134. #endif
  1135. /**
  1136. * struct reo_queue_ref_table - Reo qref LUT addr
  1137. * @mlo_reo_qref_table_vaddr: MLO table vaddr
  1138. * @non_mlo_reo_qref_table_vaddr: Non MLO table vaddr
  1139. * @mlo_reo_qref_table_paddr: MLO table paddr
  1140. * @non_mlo_reo_qref_table_paddr: Non MLO table paddr
  1141. * @reo_qref_table_en: Enable flag
  1142. */
  1143. struct reo_queue_ref_table {
  1144. uint64_t *mlo_reo_qref_table_vaddr;
  1145. uint64_t *non_mlo_reo_qref_table_vaddr;
  1146. qdf_dma_addr_t mlo_reo_qref_table_paddr;
  1147. qdf_dma_addr_t non_mlo_reo_qref_table_paddr;
  1148. uint8_t reo_qref_table_en;
  1149. };
  1150. /**
  1151. * union hal_shadow_reg_cfg - Shadow register config
  1152. * @addr: Place holder where shadow address is saved
  1153. * @v2: shadow config v2 format
  1154. * @v3: shadow config v3 format
  1155. */
  1156. union hal_shadow_reg_cfg {
  1157. uint32_t addr;
  1158. struct pld_shadow_reg_v2_cfg v2;
  1159. #ifdef CONFIG_SHADOW_V3
  1160. struct pld_shadow_reg_v3_cfg v3;
  1161. #endif
  1162. };
  1163. /**
  1164. * struct hal_soc - HAL context to be used to access SRNG APIs
  1165. * (currently used by data path and
  1166. * transport (CE) modules)
  1167. * @list_shadow_reg_config: array of generic regs mapped to
  1168. * shadow regs
  1169. * @num_generic_shadow_regs_configured: number of generic regs
  1170. * mapped to shadow regs
  1171. */
  1172. struct hal_soc {
  1173. /* HIF handle to access HW registers */
  1174. struct hif_opaque_softc *hif_handle;
  1175. /* QDF device handle */
  1176. qdf_device_t qdf_dev;
  1177. /* Device base address */
  1178. void *dev_base_addr;
  1179. /* Device base address for ce - qca5018 target */
  1180. void *dev_base_addr_ce;
  1181. /* HAL internal state for all SRNG rings.
  1182. * TODO: See if this is required
  1183. */
  1184. struct hal_srng srng_list[HAL_SRNG_ID_MAX];
  1185. /* Remote pointer memory for HW/FW updates */
  1186. uint32_t *shadow_rdptr_mem_vaddr;
  1187. qdf_dma_addr_t shadow_rdptr_mem_paddr;
  1188. /* Shared memory for ring pointer updates from host to FW */
  1189. uint32_t *shadow_wrptr_mem_vaddr;
  1190. qdf_dma_addr_t shadow_wrptr_mem_paddr;
  1191. /* REO blocking resource index */
  1192. uint8_t reo_res_bitmap;
  1193. uint8_t index;
  1194. uint32_t target_type;
  1195. uint32_t version;
  1196. /* shadow register configuration */
  1197. union hal_shadow_reg_cfg shadow_config[MAX_SHADOW_REGISTERS];
  1198. int num_shadow_registers_configured;
  1199. bool use_register_windowing;
  1200. uint32_t register_window;
  1201. qdf_spinlock_t register_access_lock;
  1202. /* Static window map configuration for multiple window write*/
  1203. bool static_window_map;
  1204. /* srng table */
  1205. struct hal_hw_srng_config *hw_srng_table;
  1206. int32_t hal_hw_reg_offset[SRNG_REGISTER_MAX];
  1207. struct hal_hw_txrx_ops *ops;
  1208. /* Indicate srngs initialization */
  1209. bool init_phase;
  1210. /* Hal level stats */
  1211. struct hal_soc_stats stats;
  1212. #ifdef ENABLE_HAL_REG_WR_HISTORY
  1213. struct hal_reg_write_fail_history *reg_wr_fail_hist;
  1214. #endif
  1215. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  1216. /* queue(array) to hold register writes */
  1217. struct hal_reg_write_q_elem *reg_write_queue;
  1218. /* delayed work to be queued into workqueue */
  1219. qdf_work_t reg_write_work;
  1220. /* workqueue for delayed register writes */
  1221. qdf_workqueue_t *reg_write_wq;
  1222. /* write index used by caller to enqueue delayed work */
  1223. qdf_atomic_t write_idx;
  1224. /* read index used by worker thread to dequeue/write registers */
  1225. uint32_t read_idx;
  1226. #endif /*FEATURE_HAL_DELAYED_REG_WRITE */
  1227. qdf_atomic_t active_work_cnt;
  1228. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  1229. struct shadow_reg_config
  1230. list_shadow_reg_config[MAX_GENERIC_SHADOW_REG];
  1231. int num_generic_shadow_regs_configured;
  1232. #endif
  1233. /* flag to indicate cmn dmac rings in berryllium */
  1234. bool dmac_cmn_src_rxbuf_ring;
  1235. /* Reo queue ref table items */
  1236. struct reo_queue_ref_table reo_qref;
  1237. };
  1238. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1239. /**
  1240. * hal_delayed_reg_write() - delayed regiter write
  1241. * @hal_soc: HAL soc handle
  1242. * @srng: hal srng
  1243. * @addr: iomem address
  1244. * @value: value to be written
  1245. *
  1246. * Return: none
  1247. */
  1248. void hal_delayed_reg_write(struct hal_soc *hal_soc,
  1249. struct hal_srng *srng,
  1250. void __iomem *addr,
  1251. uint32_t value);
  1252. #endif
  1253. void hal_qca6750_attach(struct hal_soc *hal_soc);
  1254. void hal_qca6490_attach(struct hal_soc *hal_soc);
  1255. void hal_qca6390_attach(struct hal_soc *hal_soc);
  1256. void hal_qca6290_attach(struct hal_soc *hal_soc);
  1257. void hal_qca8074_attach(struct hal_soc *hal_soc);
  1258. void hal_kiwi_attach(struct hal_soc *hal_soc);
  1259. void hal_qcn9224v1_attach(struct hal_soc *hal_soc);
  1260. void hal_qcn9224v2_attach(struct hal_soc *hal_soc);
  1261. /*
  1262. * hal_soc_to_dp_hal_roc - API to convert hal_soc to opaque
  1263. * dp_hal_soc handle type
  1264. * @hal_soc - hal_soc type
  1265. *
  1266. * Return: hal_soc_handle_t type
  1267. */
  1268. static inline
  1269. hal_soc_handle_t hal_soc_to_hal_soc_handle(struct hal_soc *hal_soc)
  1270. {
  1271. return (hal_soc_handle_t)hal_soc;
  1272. }
  1273. /*
  1274. * hal_srng_to_hal_ring_handle - API to convert hal_srng to opaque
  1275. * dp_hal_ring handle type
  1276. * @hal_srng - hal_srng type
  1277. *
  1278. * Return: hal_ring_handle_t type
  1279. */
  1280. static inline
  1281. hal_ring_handle_t hal_srng_to_hal_ring_handle(struct hal_srng *hal_srng)
  1282. {
  1283. return (hal_ring_handle_t)hal_srng;
  1284. }
  1285. /*
  1286. * hal_ring_handle_to_hal_srng - API to convert dp_hal_ring to hal_srng handle
  1287. * @hal_ring - hal_ring_handle_t type
  1288. *
  1289. * Return: hal_srng pointer type
  1290. */
  1291. static inline
  1292. struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring)
  1293. {
  1294. return (struct hal_srng *)hal_ring;
  1295. }
  1296. /* Size of REO queue reference table in Host
  1297. * 2k peers * 17 tids * 8bytes(rx_reo_queue_reference)
  1298. * = 278528 bytes
  1299. */
  1300. #define REO_QUEUE_REF_NON_ML_TABLE_SIZE 278528
  1301. /* Calculated based on 512 MLO peers */
  1302. #define REO_QUEUE_REF_ML_TABLE_SIZE 69632
  1303. #define HAL_ML_PEER_ID_START 0x2000
  1304. #define HAL_PEER_ID_IS_MLO(peer_id) ((peer_id) & HAL_ML_PEER_ID_START)
  1305. /*
  1306. * REO2PPE destination indication
  1307. */
  1308. #define REO2PPE_DST_IND 11
  1309. /**
  1310. * enum hal_pkt_type - Type of packet type reported by HW
  1311. * @HAL_DOT11A: 802.11a PPDU type
  1312. * @HAL_DOT11B: 802.11b PPDU type
  1313. * @HAL_DOT11N_MM: 802.11n Mixed Mode PPDU type
  1314. * @HAL_DOT11AC: 802.11ac PPDU type
  1315. * @HAL_DOT11AX: 802.11ax PPDU type
  1316. * @HAL_DOT11BA: 802.11ba (WUR) PPDU type
  1317. * @HAL_DOT11BE: 802.11be PPDU type
  1318. * @HAL_DOT11AZ: 802.11az (ranging) PPDU type
  1319. * @HAL_DOT11N_GF: 802.11n Green Field PPDU type
  1320. *
  1321. * Enum indicating the packet type reported by HW in rx_pkt_tlvs (RX data)
  1322. * or WBM2SW ring entry's descriptor (TX data completion)
  1323. */
  1324. enum hal_pkt_type {
  1325. HAL_DOT11A = 0,
  1326. HAL_DOT11B = 1,
  1327. HAL_DOT11N_MM = 2,
  1328. HAL_DOT11AC = 3,
  1329. HAL_DOT11AX = 4,
  1330. HAL_DOT11BA = 5,
  1331. HAL_DOT11BE = 6,
  1332. HAL_DOT11AZ = 7,
  1333. HAL_DOT11N_GF = 8,
  1334. HAL_DOT11_MAX,
  1335. };
  1336. #endif /* _HAL_INTERNAL_H_ */