hal_internal.h 37 KB

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