hal_internal.h 47 KB

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