hal_internal.h 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474
  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. };
  650. #define MAX_SHADOW_REGISTERS 40
  651. #define MAX_GENERIC_SHADOW_REG 5
  652. /**
  653. * struct shadow_reg_config - Hal soc structure that contains
  654. * the list of generic shadow registers
  655. * @target_register: target reg offset
  656. * @shadow_config_index: shadow config index in shadow config
  657. * list sent to FW
  658. * @va: virtual addr of shadow reg
  659. *
  660. * This structure holds the generic registers that are mapped to
  661. * the shadow region and holds the mapping of the target
  662. * register offset to shadow config index provided to FW during
  663. * init
  664. */
  665. struct shadow_reg_config {
  666. uint32_t target_register;
  667. int shadow_config_index;
  668. uint64_t va;
  669. };
  670. /* REO parameters to be passed to hal_reo_setup */
  671. struct hal_reo_params {
  672. /** rx hash steering enabled or disabled */
  673. bool rx_hash_enabled;
  674. /** reo remap 0 register */
  675. uint32_t remap0;
  676. /** reo remap 1 register */
  677. uint32_t remap1;
  678. /** reo remap 2 register */
  679. uint32_t remap2;
  680. /** fragment destination ring */
  681. uint8_t frag_dst_ring;
  682. /* Destination for alternate */
  683. uint8_t alt_dst_ind_0;
  684. /** padding */
  685. uint8_t padding[2];
  686. };
  687. /**
  688. * enum hal_reo_cmd_type: Enum for REO command type
  689. * @CMD_GET_QUEUE_STATS: Get REO queue status/stats
  690. * @CMD_FLUSH_QUEUE: Flush all frames in REO queue
  691. * @CMD_FLUSH_CACHE: Flush descriptor entries in the cache
  692. * @CMD_UNBLOCK_CACHE: Unblock a descriptor’s address that was blocked
  693. * earlier with a ‘REO_FLUSH_CACHE’ command
  694. * @CMD_FLUSH_TIMEOUT_LIST: Flush buffers/descriptors from timeout list
  695. * @CMD_UPDATE_RX_REO_QUEUE: Update REO queue settings
  696. */
  697. enum hal_reo_cmd_type {
  698. CMD_GET_QUEUE_STATS = 0,
  699. CMD_FLUSH_QUEUE = 1,
  700. CMD_FLUSH_CACHE = 2,
  701. CMD_UNBLOCK_CACHE = 3,
  702. CMD_FLUSH_TIMEOUT_LIST = 4,
  703. CMD_UPDATE_RX_REO_QUEUE = 5
  704. };
  705. /**
  706. * enum hal_tx_mcast_mlo_reinject_notify
  707. * @HAL_TX_MCAST_MLO_REINJECT_FW_NOTIFY: MLO Mcast reinject routed to FW
  708. * @HAL_TX_MCAST_MLO_REINJECT_TQM_NOTIFY: MLO Mcast reinject routed to TQM
  709. */
  710. enum hal_tx_mcast_mlo_reinject_notify {
  711. HAL_TX_MCAST_MLO_REINJECT_FW_NOTIFY = 0,
  712. HAL_TX_MCAST_MLO_REINJECT_TQM_NOTIFY,
  713. };
  714. /**
  715. * enum hal_tx_vdev_mismatch_notify
  716. * @HAL_TX_VDEV_MISMATCH_TQM_NOTIFY: vdev mismatch exception routed to TQM
  717. * @HAL_TX_VDEV_MISMATCH_FW_NOTIFY: vdev mismatch exception routed to FW
  718. */
  719. enum hal_tx_vdev_mismatch_notify {
  720. HAL_TX_VDEV_MISMATCH_TQM_NOTIFY = 0,
  721. HAL_TX_VDEV_MISMATCH_FW_NOTIFY,
  722. };
  723. struct hal_rx_pkt_capture_flags {
  724. uint8_t encrypt_type;
  725. uint8_t fragment_flag;
  726. uint8_t fcs_err;
  727. uint32_t chan_freq;
  728. uint32_t rssi_comb;
  729. uint64_t tsft;
  730. };
  731. struct hal_hw_txrx_ops {
  732. /* init and setup */
  733. void (*hal_srng_dst_hw_init)(struct hal_soc *hal,
  734. struct hal_srng *srng, bool idle_check);
  735. void (*hal_srng_src_hw_init)(struct hal_soc *hal,
  736. struct hal_srng *srng, bool idle_check);
  737. void (*hal_srng_hw_disable)(struct hal_soc *hal,
  738. struct hal_srng *srng);
  739. void (*hal_get_hw_hptp)(struct hal_soc *hal,
  740. hal_ring_handle_t hal_ring_hdl,
  741. uint32_t *headp, uint32_t *tailp,
  742. uint8_t ring_type);
  743. void (*hal_reo_setup)(struct hal_soc *hal_soc, void *reoparams,
  744. int qref_reset);
  745. void (*hal_setup_link_idle_list)(
  746. struct hal_soc *hal_soc,
  747. qdf_dma_addr_t scatter_bufs_base_paddr[],
  748. void *scatter_bufs_base_vaddr[],
  749. uint32_t num_scatter_bufs,
  750. uint32_t scatter_buf_size,
  751. uint32_t last_buf_end_offset,
  752. uint32_t num_entries);
  753. qdf_iomem_t (*hal_get_window_address)(struct hal_soc *hal_soc,
  754. qdf_iomem_t addr);
  755. void (*hal_reo_set_err_dst_remap)(void *hal_soc);
  756. uint8_t (*hal_reo_enable_pn_in_dest)(void *hal_soc);
  757. void (*hal_reo_qdesc_setup)(hal_soc_handle_t hal_soc_hdl, int tid,
  758. uint32_t ba_window_size,
  759. uint32_t start_seq, void *hw_qdesc_vaddr,
  760. qdf_dma_addr_t hw_qdesc_paddr,
  761. int pn_type, uint8_t vdev_stats_id);
  762. uint32_t (*hal_gen_reo_remap_val)(enum hal_reo_remap_reg,
  763. uint8_t *ix0_map);
  764. /* tx */
  765. void (*hal_tx_desc_set_dscp_tid_table_id)(void *desc, uint8_t id);
  766. void (*hal_tx_set_dscp_tid_map)(struct hal_soc *hal_soc, uint8_t *map,
  767. uint8_t id);
  768. void (*hal_tx_update_dscp_tid)(struct hal_soc *hal_soc, uint8_t tid,
  769. uint8_t id,
  770. uint8_t dscp);
  771. void (*hal_tx_desc_set_lmac_id)(void *desc, uint8_t lmac_id);
  772. void (*hal_tx_desc_set_buf_addr)(void *desc, dma_addr_t paddr,
  773. uint8_t pool_id, uint32_t desc_id,
  774. uint8_t type);
  775. void (*hal_tx_desc_set_search_type)(void *desc, uint8_t search_type);
  776. void (*hal_tx_desc_set_search_index)(void *desc, uint32_t search_index);
  777. void (*hal_tx_desc_set_cache_set_num)(void *desc, uint8_t search_index);
  778. void (*hal_tx_comp_get_status)(void *desc, void *ts,
  779. struct hal_soc *hal);
  780. uint8_t (*hal_tx_comp_get_release_reason)(void *hal_desc);
  781. uint8_t (*hal_get_wbm_internal_error)(void *hal_desc);
  782. void (*hal_tx_desc_set_mesh_en)(void *desc, uint8_t en);
  783. void (*hal_tx_init_cmd_credit_ring)(hal_soc_handle_t hal_soc_hdl,
  784. hal_ring_handle_t hal_ring_hdl);
  785. uint32_t (*hal_tx_comp_get_buffer_source)(void *hal_desc);
  786. uint32_t (*hal_tx_get_num_ppe_vp_tbl_entries)(
  787. hal_soc_handle_t hal_soc_hdl);
  788. void (*hal_tx_set_ppe_cmn_cfg)(hal_soc_handle_t hal_soc_hdl,
  789. union hal_tx_cmn_config_ppe *cmn_cfg);
  790. void (*hal_tx_set_ppe_vp_entry)(hal_soc_handle_t hal_soc_hdl,
  791. union hal_tx_ppe_vp_config *vp_cfg,
  792. int ppe_vp_idx);
  793. void (*hal_tx_set_ppe_pri2tid)(hal_soc_handle_t hal_soc_hdl,
  794. uint32_t val,
  795. uint8_t map_no);
  796. void (*hal_tx_update_ppe_pri2tid)(hal_soc_handle_t hal_soc_hdl,
  797. uint8_t pri,
  798. uint8_t tid);
  799. void (*hal_tx_dump_ppe_vp_entry)(hal_soc_handle_t hal_soc_hdl);
  800. void (*hal_tx_enable_pri2tid_map)(hal_soc_handle_t hal_soc_hdl,
  801. bool value, uint8_t ppe_vp_idx);
  802. void (*hal_tx_config_rbm_mapping_be)(hal_soc_handle_t hal_soc_hdl,
  803. hal_ring_handle_t hal_ring_hdl,
  804. uint8_t rbm_id);
  805. /* rx */
  806. uint32_t (*hal_rx_msdu_start_nss_get)(uint8_t *);
  807. void (*hal_rx_mon_hw_desc_get_mpdu_status)(void *hw_desc_addr,
  808. struct mon_rx_status *rs);
  809. uint8_t (*hal_rx_get_tlv)(void *rx_tlv);
  810. void (*hal_rx_proc_phyrx_other_receive_info_tlv)(void *rx_tlv_hdr,
  811. void *ppdu_info_handle);
  812. void (*hal_rx_dump_msdu_start_tlv)(void *msdu_start, uint8_t dbg_level);
  813. void (*hal_rx_dump_msdu_end_tlv)(void *msdu_end,
  814. uint8_t dbg_level);
  815. uint32_t (*hal_get_link_desc_size)(void);
  816. uint32_t (*hal_rx_mpdu_start_tid_get)(uint8_t *buf);
  817. uint32_t (*hal_rx_msdu_start_reception_type_get)(uint8_t *buf);
  818. uint16_t (*hal_rx_msdu_end_da_idx_get)(uint8_t *buf);
  819. void* (*hal_rx_msdu_desc_info_get_ptr)(void *msdu_details_ptr);
  820. void* (*hal_rx_link_desc_msdu0_ptr)(void *msdu_link_ptr);
  821. void (*hal_reo_status_get_header)(hal_ring_desc_t ring_desc, int b,
  822. void *h);
  823. uint32_t (*hal_rx_status_get_tlv_info)(void *rx_tlv_hdr,
  824. void *ppdu_info,
  825. hal_soc_handle_t hal_soc_hdl,
  826. qdf_nbuf_t nbuf);
  827. void (*hal_rx_wbm_rel_buf_paddr_get)(hal_ring_desc_t rx_desc,
  828. struct hal_buf_info *buf_info);
  829. void (*hal_rx_wbm_err_info_get)(void *wbm_desc,
  830. void *wbm_er_info);
  831. void (*hal_rx_dump_mpdu_start_tlv)(void *mpdustart,
  832. uint8_t dbg_level);
  833. void (*hal_tx_set_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t *map);
  834. void (*hal_tx_update_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t pcp,
  835. uint8_t id);
  836. void (*hal_tx_set_tidmap_prty)(struct hal_soc *hal_soc, uint8_t prio);
  837. /* rx */
  838. uint8_t (*hal_rx_get_rx_fragment_number)(uint8_t *buf);
  839. uint8_t (*hal_rx_msdu_end_da_is_mcbc_get)(uint8_t *buf);
  840. uint8_t (*hal_rx_msdu_end_is_tkip_mic_err)(uint8_t *buf);
  841. uint8_t (*hal_rx_msdu_end_sa_is_valid_get)(uint8_t *buf);
  842. uint16_t (*hal_rx_msdu_end_sa_idx_get)(uint8_t *buf);
  843. uint32_t (*hal_rx_desc_is_first_msdu)(void *hw_desc_addr);
  844. uint32_t (*hal_rx_msdu_end_l3_hdr_padding_get)(uint8_t *buf);
  845. uint32_t (*hal_rx_encryption_info_valid)(uint8_t *buf);
  846. void (*hal_rx_print_pn)(uint8_t *buf);
  847. uint8_t (*hal_rx_msdu_end_first_msdu_get)(uint8_t *buf);
  848. uint8_t (*hal_rx_msdu_end_da_is_valid_get)(uint8_t *buf);
  849. uint8_t (*hal_rx_msdu_end_last_msdu_get)(uint8_t *buf);
  850. bool (*hal_rx_get_mpdu_mac_ad4_valid)(uint8_t *buf);
  851. uint32_t (*hal_rx_mpdu_start_sw_peer_id_get)(uint8_t *buf);
  852. uint32_t (*hal_rx_tlv_peer_meta_data_get)(uint8_t *buf);
  853. uint32_t (*hal_rx_mpdu_get_to_ds)(uint8_t *buf);
  854. uint32_t (*hal_rx_mpdu_get_fr_ds)(uint8_t *buf);
  855. uint8_t (*hal_rx_get_mpdu_frame_control_valid)(uint8_t *buf);
  856. QDF_STATUS
  857. (*hal_rx_mpdu_get_addr1)(uint8_t *buf, uint8_t *mac_addr);
  858. QDF_STATUS
  859. (*hal_rx_mpdu_get_addr2)(uint8_t *buf, uint8_t *mac_addr);
  860. QDF_STATUS
  861. (*hal_rx_mpdu_get_addr3)(uint8_t *buf, uint8_t *mac_addr);
  862. QDF_STATUS
  863. (*hal_rx_mpdu_get_addr4)(uint8_t *buf, uint8_t *mac_addr);
  864. uint8_t (*hal_rx_get_mpdu_sequence_control_valid)(uint8_t *buf);
  865. bool (*hal_rx_is_unicast)(uint8_t *buf);
  866. uint32_t (*hal_rx_tid_get)(hal_soc_handle_t hal_soc_hdl, uint8_t *buf);
  867. uint32_t (*hal_rx_hw_desc_get_ppduid_get)(void *rx_tlv_hdr,
  868. void *rxdma_dst_ring_desc);
  869. uint32_t (*hal_rx_mpdu_start_mpdu_qos_control_valid_get)(uint8_t *buf);
  870. uint32_t (*hal_rx_msdu_end_sa_sw_peer_id_get)(uint8_t *buf);
  871. void * (*hal_rx_msdu0_buffer_addr_lsb)(void *link_desc_addr);
  872. void * (*hal_rx_msdu_desc_info_ptr_get)(void *msdu0);
  873. void * (*hal_ent_mpdu_desc_info)(void *hw_addr);
  874. void * (*hal_dst_mpdu_desc_info)(void *hw_addr);
  875. uint8_t (*hal_rx_get_fc_valid)(uint8_t *buf);
  876. uint8_t (*hal_rx_get_to_ds_flag)(uint8_t *buf);
  877. uint8_t (*hal_rx_get_mac_addr2_valid)(uint8_t *buf);
  878. uint8_t (*hal_rx_get_filter_category)(uint8_t *buf);
  879. uint32_t (*hal_rx_get_ppdu_id)(uint8_t *buf);
  880. void (*hal_reo_config)(struct hal_soc *soc,
  881. uint32_t reg_val,
  882. struct hal_reo_params *reo_params);
  883. uint32_t (*hal_rx_msdu_flow_idx_get)(uint8_t *buf);
  884. bool (*hal_rx_msdu_flow_idx_invalid)(uint8_t *buf);
  885. bool (*hal_rx_msdu_flow_idx_timeout)(uint8_t *buf);
  886. uint32_t (*hal_rx_msdu_fse_metadata_get)(uint8_t *buf);
  887. bool (*hal_rx_msdu_cce_match_get)(uint8_t *buf);
  888. uint16_t (*hal_rx_msdu_cce_metadata_get)(uint8_t *buf);
  889. void
  890. (*hal_rx_msdu_get_flow_params)(
  891. uint8_t *buf,
  892. bool *flow_invalid,
  893. bool *flow_timeout,
  894. uint32_t *flow_index);
  895. uint16_t (*hal_rx_tlv_get_tcp_chksum)(uint8_t *buf);
  896. uint16_t (*hal_rx_get_rx_sequence)(uint8_t *buf);
  897. void (*hal_rx_get_bb_info)(void *rx_tlv, void *ppdu_info_handle);
  898. void (*hal_rx_get_rtt_info)(void *rx_tlv, void *ppdu_info_handle);
  899. void (*hal_rx_msdu_packet_metadata_get)(uint8_t *buf,
  900. void *msdu_pkt_metadata);
  901. uint16_t (*hal_rx_get_fisa_cumulative_l4_checksum)(uint8_t *buf);
  902. uint16_t (*hal_rx_get_fisa_cumulative_ip_length)(uint8_t *buf);
  903. bool (*hal_rx_get_udp_proto)(uint8_t *buf);
  904. bool (*hal_rx_get_fisa_flow_agg_continuation)(uint8_t *buf);
  905. uint8_t (*hal_rx_get_fisa_flow_agg_count)(uint8_t *buf);
  906. bool (*hal_rx_get_fisa_timeout)(uint8_t *buf);
  907. uint8_t (*hal_rx_mpdu_start_tlv_tag_valid)(void *rx_tlv_hdr);
  908. void (*hal_rx_sw_mon_desc_info_get)(hal_ring_desc_t rxdma_dst_ring_desc,
  909. hal_rx_mon_desc_info_t mon_desc_info);
  910. uint8_t (*hal_rx_wbm_err_msdu_continuation_get)(void *ring_desc);
  911. uint32_t (*hal_rx_msdu_end_offset_get)(void);
  912. uint32_t (*hal_rx_attn_offset_get)(void);
  913. uint32_t (*hal_rx_msdu_start_offset_get)(void);
  914. uint32_t (*hal_rx_mpdu_start_offset_get)(void);
  915. uint32_t (*hal_rx_mpdu_end_offset_get)(void);
  916. uint32_t (*hal_rx_pkt_tlv_offset_get)(void);
  917. void * (*hal_rx_flow_setup_fse)(uint8_t *rx_fst,
  918. uint32_t table_offset,
  919. uint8_t *rx_flow);
  920. void * (*hal_rx_flow_get_tuple_info)(uint8_t *rx_fst,
  921. uint32_t hal_hash,
  922. uint8_t *tuple_info);
  923. QDF_STATUS (*hal_rx_flow_delete_entry)(uint8_t *fst,
  924. void *fse);
  925. uint32_t (*hal_rx_fst_get_fse_size)(void);
  926. void (*hal_compute_reo_remap_ix2_ix3)(uint32_t *ring,
  927. uint32_t num_rings,
  928. uint32_t *remap1,
  929. uint32_t *remap2);
  930. void (*hal_compute_reo_remap_ix0)(uint32_t *remap0);
  931. uint32_t (*hal_rx_flow_setup_cmem_fse)(
  932. struct hal_soc *soc, uint32_t cmem_ba,
  933. uint32_t table_offset, uint8_t *rx_flow);
  934. uint32_t (*hal_rx_flow_get_cmem_fse_ts)(struct hal_soc *soc,
  935. uint32_t fse_offset);
  936. void (*hal_rx_flow_get_cmem_fse)(struct hal_soc *soc,
  937. uint32_t fse_offset,
  938. uint32_t *fse, qdf_size_t len);
  939. void (*hal_cmem_write)(hal_soc_handle_t hal_soc_hdl, uint32_t offset,
  940. uint32_t value);
  941. void (*hal_rx_msdu_get_reo_destination_indication)(uint8_t *buf,
  942. uint32_t *reo_destination_indication);
  943. uint8_t (*hal_tx_get_num_tcl_banks)(void);
  944. uint32_t (*hal_get_reo_qdesc_size)(uint32_t ba_window_size, int tid);
  945. uint16_t (*hal_get_rx_max_ba_window)(int tid);
  946. void (*hal_set_link_desc_addr)(void *desc, uint32_t cookie,
  947. qdf_dma_addr_t link_desc_paddr,
  948. uint8_t bm_id);
  949. void (*hal_tx_init_data_ring)(hal_soc_handle_t hal_soc_hdl,
  950. hal_ring_handle_t hal_ring_hdl);
  951. void* (*hal_rx_msdu_ext_desc_info_get_ptr)(void *msdu_details_ptr);
  952. void (*hal_get_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
  953. uint8_t ac, uint32_t *value);
  954. void (*hal_set_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl,
  955. uint8_t ac, uint32_t value);
  956. uint32_t (*hal_get_reo_reg_base_offset)(void);
  957. void (*hal_rx_get_tlv_size)(uint16_t *rx_pkt_tlv_size,
  958. uint16_t *rx_mon_pkt_tlv_size);
  959. uint32_t (*hal_rx_msdu_is_wlan_mcast)(qdf_nbuf_t nbuf);
  960. uint32_t (*hal_rx_tlv_decap_format_get)(void *hw_desc_addr);
  961. void (*hal_rx_dump_pkt_tlvs)(hal_soc_handle_t hal_soc_hdl,
  962. uint8_t *buf, uint8_t dbg_level);
  963. int (*hal_rx_tlv_get_offload_info)(uint8_t *rx_tlv,
  964. struct hal_offload_info *offload_info);
  965. uint16_t (*hal_rx_tlv_phy_ppdu_id_get)(uint8_t *buf);
  966. uint32_t (*hal_rx_tlv_msdu_done_get)(uint8_t *buf);
  967. uint32_t (*hal_rx_tlv_msdu_len_get)(uint8_t *buf);
  968. uint16_t (*hal_rx_get_frame_ctrl_field)(uint8_t *buf);
  969. int (*hal_rx_get_proto_params)(uint8_t *buf, void *fisa_params);
  970. int (*hal_rx_get_l3_l4_offsets)(uint8_t *buf, uint32_t *l3_hdr_offset,
  971. uint32_t *l4_hdr_offset);
  972. uint32_t (*hal_rx_tlv_mic_err_get)(uint8_t *buf);
  973. uint32_t (*hal_rx_tlv_get_pkt_type)(uint8_t *buf);
  974. void (*hal_rx_tlv_get_pn_num)(uint8_t *buf, uint64_t *pn_num);
  975. void (*hal_rx_reo_prev_pn_get)(void *ring_desc, uint64_t *prev_pn);
  976. uint8_t * (*hal_rx_pkt_hdr_get)(uint8_t *buf);
  977. uint32_t (*hal_rx_msdu_reo_dst_ind_get)(hal_soc_handle_t hal_soc_hdl,
  978. void *msdu_link_desc);
  979. void (*hal_msdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
  980. void *msdu_desc_info, uint32_t dst_ind,
  981. uint32_t nbuf_len);
  982. void (*hal_mpdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl,
  983. void *mpdu_desc_info, uint32_t seq_no);
  984. #ifdef DP_UMAC_HW_RESET_SUPPORT
  985. void (*hal_unregister_reo_send_cmd)(struct hal_soc *hal_soc);
  986. void (*hal_register_reo_send_cmd)(struct hal_soc *hal_soc);
  987. void (*hal_reset_rx_reo_tid_q)(struct hal_soc *hal_soc,
  988. void *hw_qdesc_vaddr, uint32_t size);
  989. #endif
  990. uint32_t (*hal_rx_tlv_sgi_get)(uint8_t *buf);
  991. uint32_t (*hal_rx_tlv_get_freq)(uint8_t *buf);
  992. uint8_t (*hal_rx_msdu_get_keyid)(uint8_t *buf);
  993. uint32_t (*hal_rx_tlv_rate_mcs_get)(uint8_t *buf);
  994. uint32_t (*hal_rx_tlv_decrypt_err_get)(uint8_t *buf);
  995. uint32_t (*hal_rx_tlv_first_mpdu_get)(uint8_t *buf);
  996. uint32_t (*hal_rx_tlv_bw_get)(uint8_t *buf);
  997. uint32_t (*hal_rx_tlv_get_is_decrypted)(uint8_t *buf);
  998. uint32_t (*hal_rx_wbm_err_src_get)(hal_ring_desc_t ring_desc);
  999. uint8_t (*hal_rx_ret_buf_manager_get)(hal_ring_desc_t ring_desc);
  1000. void (*hal_rx_msdu_link_desc_set)(hal_soc_handle_t hal_soc_hdl,
  1001. void *src_srng_desc,
  1002. hal_buff_addrinfo_t buf_addr_info,
  1003. uint8_t bm_action);
  1004. void (*hal_rx_buf_cookie_rbm_get)(uint32_t *buf_addr_info_hdl,
  1005. hal_buf_info_t buf_info_hdl);
  1006. void (*hal_rx_reo_buf_paddr_get)(hal_ring_desc_t rx_desc,
  1007. struct hal_buf_info *buf_info);
  1008. void (*hal_rxdma_buff_addr_info_set)(void *rxdma_entry,
  1009. qdf_dma_addr_t paddr,
  1010. uint32_t cookie, uint8_t manager);
  1011. uint32_t (*hal_rx_msdu_flags_get)(rx_msdu_desc_info_t msdu_desc_info_hdl);
  1012. uint32_t (*hal_rx_get_reo_error_code)(hal_ring_desc_t rx_desc);
  1013. void (*hal_rx_tlv_csum_err_get)(uint8_t *rx_tlv_hdr,
  1014. uint32_t *ip_csum_err,
  1015. uint32_t *tcp_udp_csum_err);
  1016. void (*hal_rx_mpdu_desc_info_get)(void *desc_addr,
  1017. void *mpdu_desc_info_hdl);
  1018. uint8_t (*hal_rx_err_status_get)(hal_ring_desc_t rx_desc);
  1019. uint8_t (*hal_rx_reo_buf_type_get)(hal_ring_desc_t rx_desc);
  1020. bool (*hal_rx_mpdu_info_ampdu_flag_get)(uint8_t *buf);
  1021. uint32_t (*hal_rx_tlv_mpdu_len_err_get)(void *hw_desc_addr);
  1022. uint32_t (*hal_rx_tlv_mpdu_fcs_err_get)(void *hw_desc_addr);
  1023. void (*hal_rx_tlv_get_pkt_capture_flags)(uint8_t *rx_tlv_hdr,
  1024. struct hal_rx_pkt_capture_flags *flags);
  1025. uint8_t *(*hal_rx_desc_get_80211_hdr)(void *hw_desc_addr);
  1026. uint32_t (*hal_rx_hw_desc_mpdu_user_id)(void *hw_desc_addr);
  1027. void (*hal_rx_priv_info_set_in_tlv)(uint8_t *buf,
  1028. uint8_t *priv_data,
  1029. uint32_t len);
  1030. void (*hal_rx_priv_info_get_from_tlv)(uint8_t *buf,
  1031. uint8_t *priv_data,
  1032. uint32_t len);
  1033. void (*hal_rx_tlv_msdu_len_set)(uint8_t *buf, uint32_t len);
  1034. void (*hal_rx_tlv_populate_mpdu_desc_info)(uint8_t *buf,
  1035. void *mpdu_desc_info_hdl);
  1036. uint8_t *(*hal_get_reo_ent_desc_qdesc_addr)(uint8_t *desc);
  1037. uint64_t (*hal_rx_get_qdesc_addr)(uint8_t *dst_ring_desc,
  1038. uint8_t *buf);
  1039. void (*hal_set_reo_ent_desc_reo_dest_ind)(uint8_t *desc,
  1040. uint32_t dst_ind);
  1041. /* REO CMD and STATUS */
  1042. int (*hal_reo_send_cmd)(hal_soc_handle_t hal_soc_hdl,
  1043. hal_ring_handle_t hal_ring_hdl,
  1044. enum hal_reo_cmd_type cmd,
  1045. void *params);
  1046. QDF_STATUS (*hal_reo_status_update)(hal_soc_handle_t hal_soc_hdl,
  1047. hal_ring_desc_t reo_desc,
  1048. void *st_handle,
  1049. uint32_t tlv, int *num_ref);
  1050. uint8_t (*hal_get_tlv_hdr_size)(void);
  1051. uint8_t (*hal_get_idle_link_bm_id)(uint8_t chip_id);
  1052. bool (*hal_txmon_is_mon_buf_addr_tlv)(void *tx_tlv_hdr);
  1053. void (*hal_txmon_populate_packet_info)(void *tx_tlv_hdr,
  1054. void *pkt_info);
  1055. /* TX MONITOR */
  1056. #ifdef QCA_MONITOR_2_0_SUPPORT
  1057. uint32_t (*hal_txmon_status_parse_tlv)(void *data_ppdu_info,
  1058. void *prot_ppdu_info,
  1059. void *data_status_info,
  1060. void *prot_status_info,
  1061. void *tx_tlv_hdr,
  1062. qdf_frag_t status_frag);
  1063. uint32_t (*hal_txmon_status_get_num_users)(void *tx_tlv_hdr,
  1064. uint8_t *num_users);
  1065. #endif /* QCA_MONITOR_2_0_SUPPORT */
  1066. void (*hal_reo_shared_qaddr_setup)(hal_soc_handle_t hal_soc_hdl);
  1067. void (*hal_reo_shared_qaddr_init)(hal_soc_handle_t hal_soc_hdl,
  1068. int qref_reset);
  1069. void (*hal_reo_shared_qaddr_detach)(hal_soc_handle_t hal_soc_hdl);
  1070. void (*hal_reo_shared_qaddr_write)(hal_soc_handle_t hal_soc_hdl,
  1071. uint16_t peer_id,
  1072. int tid,
  1073. qdf_dma_addr_t hw_qdesc_paddr);
  1074. #ifdef WLAN_FEATURE_MARK_FIRST_WAKEUP_PACKET
  1075. uint8_t (*hal_get_first_wow_wakeup_packet)(uint8_t *buf);
  1076. #endif
  1077. void (*hal_reo_shared_qaddr_cache_clear)(hal_soc_handle_t hal_soc_hdl);
  1078. uint32_t (*hal_rx_tlv_l3_type_get)(uint8_t *buf);
  1079. void (*hal_tx_vdev_mismatch_routing_set)(hal_soc_handle_t hal_soc_hdl,
  1080. enum hal_tx_vdev_mismatch_notify config);
  1081. void (*hal_tx_mcast_mlo_reinject_routing_set)(
  1082. hal_soc_handle_t hal_soc_hdl,
  1083. enum hal_tx_mcast_mlo_reinject_notify config);
  1084. void (*hal_cookie_conversion_reg_cfg_be)(hal_soc_handle_t hal_soc_hdl,
  1085. struct hal_hw_cc_config
  1086. *cc_cfg);
  1087. void (*hal_tx_populate_bank_register)(hal_soc_handle_t hal_soc_hdl,
  1088. union hal_tx_bank_config *config,
  1089. uint8_t bank_id);
  1090. void (*hal_tx_vdev_mcast_ctrl_set)(hal_soc_handle_t hal_soc_hdl,
  1091. uint8_t vdev_id,
  1092. uint8_t mcast_ctrl_val);
  1093. };
  1094. /**
  1095. * struct hal_soc_stats - Hal layer stats
  1096. * @reg_write_fail: number of failed register writes
  1097. * @wstats: delayed register write stats
  1098. * @shadow_reg_write_fail: shadow reg write failure stats
  1099. * @shadow_reg_write_succ: shadow reg write success stats
  1100. *
  1101. * This structure holds all the statistics at HAL layer.
  1102. */
  1103. struct hal_soc_stats {
  1104. uint32_t reg_write_fail;
  1105. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1106. struct hal_reg_write_soc_stats wstats;
  1107. #endif
  1108. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  1109. uint32_t shadow_reg_write_fail;
  1110. uint32_t shadow_reg_write_succ;
  1111. #endif
  1112. };
  1113. #ifdef ENABLE_HAL_REG_WR_HISTORY
  1114. /* The history size should always be a power of 2 */
  1115. #define HAL_REG_WRITE_HIST_SIZE 8
  1116. /**
  1117. * struct hal_reg_write_fail_entry - Record of
  1118. * register write which failed.
  1119. * @timestamp: timestamp of reg write failure
  1120. * @reg_offset: offset of register where the write failed
  1121. * @write_val: the value which was to be written
  1122. * @read_val: the value read back from the register after write
  1123. */
  1124. struct hal_reg_write_fail_entry {
  1125. uint64_t timestamp;
  1126. uint32_t reg_offset;
  1127. uint32_t write_val;
  1128. uint32_t read_val;
  1129. };
  1130. /**
  1131. * struct hal_reg_write_fail_history - Hal layer history
  1132. * of all the register write failures.
  1133. * @index: index to add the new record
  1134. * @record: array of all the records in history
  1135. *
  1136. * This structure holds the history of register write
  1137. * failures at HAL layer.
  1138. */
  1139. struct hal_reg_write_fail_history {
  1140. qdf_atomic_t index;
  1141. struct hal_reg_write_fail_entry record[HAL_REG_WRITE_HIST_SIZE];
  1142. };
  1143. #endif
  1144. /**
  1145. * struct reo_queue_ref_table - Reo qref LUT addr
  1146. * @mlo_reo_qref_table_vaddr: MLO table vaddr
  1147. * @non_mlo_reo_qref_table_vaddr: Non MLO table vaddr
  1148. * @mlo_reo_qref_table_paddr: MLO table paddr
  1149. * @non_mlo_reo_qref_table_paddr: Non MLO table paddr
  1150. * @reo_qref_table_en: Enable flag
  1151. */
  1152. struct reo_queue_ref_table {
  1153. uint64_t *mlo_reo_qref_table_vaddr;
  1154. uint64_t *non_mlo_reo_qref_table_vaddr;
  1155. qdf_dma_addr_t mlo_reo_qref_table_paddr;
  1156. qdf_dma_addr_t non_mlo_reo_qref_table_paddr;
  1157. uint8_t reo_qref_table_en;
  1158. };
  1159. /**
  1160. * union hal_shadow_reg_cfg - Shadow register config
  1161. * @addr: Place holder where shadow address is saved
  1162. * @v2: shadow config v2 format
  1163. * @v3: shadow config v3 format
  1164. */
  1165. union hal_shadow_reg_cfg {
  1166. uint32_t addr;
  1167. struct pld_shadow_reg_v2_cfg v2;
  1168. #ifdef CONFIG_SHADOW_V3
  1169. struct pld_shadow_reg_v3_cfg v3;
  1170. #endif
  1171. };
  1172. /**
  1173. * struct hal_soc - HAL context to be used to access SRNG APIs
  1174. * (currently used by data path and
  1175. * transport (CE) modules)
  1176. * @list_shadow_reg_config: array of generic regs mapped to
  1177. * shadow regs
  1178. * @num_generic_shadow_regs_configured: number of generic regs
  1179. * mapped to shadow regs
  1180. */
  1181. struct hal_soc {
  1182. /* HIF handle to access HW registers */
  1183. struct hif_opaque_softc *hif_handle;
  1184. /* QDF device handle */
  1185. qdf_device_t qdf_dev;
  1186. /* Device base address */
  1187. void *dev_base_addr;
  1188. /* Device base address for ce - qca5018 target */
  1189. void *dev_base_addr_ce;
  1190. /* HAL internal state for all SRNG rings.
  1191. * TODO: See if this is required
  1192. */
  1193. struct hal_srng srng_list[HAL_SRNG_ID_MAX];
  1194. /* Remote pointer memory for HW/FW updates */
  1195. uint32_t *shadow_rdptr_mem_vaddr;
  1196. qdf_dma_addr_t shadow_rdptr_mem_paddr;
  1197. /* Shared memory for ring pointer updates from host to FW */
  1198. uint32_t *shadow_wrptr_mem_vaddr;
  1199. qdf_dma_addr_t shadow_wrptr_mem_paddr;
  1200. /* REO blocking resource index */
  1201. uint8_t reo_res_bitmap;
  1202. uint8_t index;
  1203. uint32_t target_type;
  1204. uint32_t version;
  1205. /* shadow register configuration */
  1206. union hal_shadow_reg_cfg shadow_config[MAX_SHADOW_REGISTERS];
  1207. int num_shadow_registers_configured;
  1208. bool use_register_windowing;
  1209. uint32_t register_window;
  1210. qdf_spinlock_t register_access_lock;
  1211. /* Static window map configuration for multiple window write*/
  1212. bool static_window_map;
  1213. /* srng table */
  1214. struct hal_hw_srng_config *hw_srng_table;
  1215. int32_t hal_hw_reg_offset[SRNG_REGISTER_MAX];
  1216. struct hal_hw_txrx_ops *ops;
  1217. /* Indicate srngs initialization */
  1218. bool init_phase;
  1219. /* Hal level stats */
  1220. struct hal_soc_stats stats;
  1221. #ifdef ENABLE_HAL_REG_WR_HISTORY
  1222. struct hal_reg_write_fail_history *reg_wr_fail_hist;
  1223. #endif
  1224. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  1225. /* queue(array) to hold register writes */
  1226. struct hal_reg_write_q_elem *reg_write_queue;
  1227. /* delayed work to be queued into workqueue */
  1228. qdf_work_t reg_write_work;
  1229. /* workqueue for delayed register writes */
  1230. qdf_workqueue_t *reg_write_wq;
  1231. /* write index used by caller to enqueue delayed work */
  1232. qdf_atomic_t write_idx;
  1233. /* read index used by worker thread to dequeue/write registers */
  1234. uint32_t read_idx;
  1235. #endif /*FEATURE_HAL_DELAYED_REG_WRITE */
  1236. qdf_atomic_t active_work_cnt;
  1237. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  1238. struct shadow_reg_config
  1239. list_shadow_reg_config[MAX_GENERIC_SHADOW_REG];
  1240. int num_generic_shadow_regs_configured;
  1241. #endif
  1242. /* flag to indicate cmn dmac rings in berryllium */
  1243. bool dmac_cmn_src_rxbuf_ring;
  1244. /* Reo queue ref table items */
  1245. struct reo_queue_ref_table reo_qref;
  1246. };
  1247. #if defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1248. /**
  1249. * hal_delayed_reg_write() - delayed regiter write
  1250. * @hal_soc: HAL soc handle
  1251. * @srng: hal srng
  1252. * @addr: iomem address
  1253. * @value: value to be written
  1254. *
  1255. * Return: none
  1256. */
  1257. void hal_delayed_reg_write(struct hal_soc *hal_soc,
  1258. struct hal_srng *srng,
  1259. void __iomem *addr,
  1260. uint32_t value);
  1261. #endif
  1262. void hal_qca6750_attach(struct hal_soc *hal_soc);
  1263. void hal_qca6490_attach(struct hal_soc *hal_soc);
  1264. void hal_qca6390_attach(struct hal_soc *hal_soc);
  1265. void hal_qca6290_attach(struct hal_soc *hal_soc);
  1266. void hal_qca8074_attach(struct hal_soc *hal_soc);
  1267. void hal_kiwi_attach(struct hal_soc *hal_soc);
  1268. void hal_qcn9224v1_attach(struct hal_soc *hal_soc);
  1269. void hal_qcn9224v2_attach(struct hal_soc *hal_soc);
  1270. /*
  1271. * hal_soc_to_dp_hal_roc - API to convert hal_soc to opaque
  1272. * dp_hal_soc handle type
  1273. * @hal_soc - hal_soc type
  1274. *
  1275. * Return: hal_soc_handle_t type
  1276. */
  1277. static inline
  1278. hal_soc_handle_t hal_soc_to_hal_soc_handle(struct hal_soc *hal_soc)
  1279. {
  1280. return (hal_soc_handle_t)hal_soc;
  1281. }
  1282. /*
  1283. * hal_srng_to_hal_ring_handle - API to convert hal_srng to opaque
  1284. * dp_hal_ring handle type
  1285. * @hal_srng - hal_srng type
  1286. *
  1287. * Return: hal_ring_handle_t type
  1288. */
  1289. static inline
  1290. hal_ring_handle_t hal_srng_to_hal_ring_handle(struct hal_srng *hal_srng)
  1291. {
  1292. return (hal_ring_handle_t)hal_srng;
  1293. }
  1294. /*
  1295. * hal_ring_handle_to_hal_srng - API to convert dp_hal_ring to hal_srng handle
  1296. * @hal_ring - hal_ring_handle_t type
  1297. *
  1298. * Return: hal_srng pointer type
  1299. */
  1300. static inline
  1301. struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring)
  1302. {
  1303. return (struct hal_srng *)hal_ring;
  1304. }
  1305. /* Size of REO queue reference table in Host
  1306. * 2k peers * 17 tids * 8bytes(rx_reo_queue_reference)
  1307. * = 278528 bytes
  1308. */
  1309. #define REO_QUEUE_REF_NON_ML_TABLE_SIZE 278528
  1310. /* Calculated based on 512 MLO peers */
  1311. #define REO_QUEUE_REF_ML_TABLE_SIZE 69632
  1312. #define HAL_ML_PEER_ID_START 0x2000
  1313. #define HAL_PEER_ID_IS_MLO(peer_id) ((peer_id) & HAL_ML_PEER_ID_START)
  1314. /*
  1315. * REO2PPE destination indication
  1316. */
  1317. #define REO2PPE_DST_IND 11
  1318. /**
  1319. * enum hal_pkt_type - Type of packet type reported by HW
  1320. * @HAL_DOT11A: 802.11a PPDU type
  1321. * @HAL_DOT11B: 802.11b PPDU type
  1322. * @HAL_DOT11N_MM: 802.11n Mixed Mode PPDU type
  1323. * @HAL_DOT11AC: 802.11ac PPDU type
  1324. * @HAL_DOT11AX: 802.11ax PPDU type
  1325. * @HAL_DOT11BA: 802.11ba (WUR) PPDU type
  1326. * @HAL_DOT11BE: 802.11be PPDU type
  1327. * @HAL_DOT11AZ: 802.11az (ranging) PPDU type
  1328. * @HAL_DOT11N_GF: 802.11n Green Field PPDU type
  1329. *
  1330. * Enum indicating the packet type reported by HW in rx_pkt_tlvs (RX data)
  1331. * or WBM2SW ring entry's descriptor (TX data completion)
  1332. */
  1333. enum hal_pkt_type {
  1334. HAL_DOT11A = 0,
  1335. HAL_DOT11B = 1,
  1336. HAL_DOT11N_MM = 2,
  1337. HAL_DOT11AC = 3,
  1338. HAL_DOT11AX = 4,
  1339. HAL_DOT11BA = 5,
  1340. HAL_DOT11BE = 6,
  1341. HAL_DOT11AZ = 7,
  1342. HAL_DOT11N_GF = 8,
  1343. HAL_DOT11_MAX,
  1344. };
  1345. #endif /* _HAL_INTERNAL_H_ */