hal_internal.h 41 KB

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