hal_hw_headers.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. /*
  2. * Copyright (c) 2016-2020 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_HW_INTERNAL_H_
  19. #define _HAL_HW_INTERNAL_H_
  20. #include "qdf_types.h"
  21. #include "qdf_lock.h"
  22. #include "qdf_mem.h"
  23. #include "rx_msdu_link.h"
  24. #include "rx_reo_queue.h"
  25. #include "rx_reo_queue_ext.h"
  26. #include "wcss_seq_hwiobase.h"
  27. #include "tlv_hdr.h"
  28. #include "tlv_tag_def.h"
  29. #include "reo_destination_ring.h"
  30. #include "reo_reg_seq_hwioreg.h"
  31. #include "reo_entrance_ring.h"
  32. #include "reo_get_queue_stats.h"
  33. #include "reo_get_queue_stats_status.h"
  34. #include "tcl_data_cmd.h"
  35. #include "tcl_gse_cmd.h"
  36. #include "tcl_status_ring.h"
  37. #include "mac_tcl_reg_seq_hwioreg.h"
  38. #include "ce_src_desc.h"
  39. #include "ce_stat_desc.h"
  40. #ifdef QCA_WIFI_QCA6490
  41. #include "wfss_ce_channel_dst_reg_seq_hwioreg.h"
  42. #else
  43. #include "wfss_ce_reg_seq_hwioreg.h"
  44. #endif /* QCA_WIFI_QCA6490 */
  45. #include "wbm_link_descriptor_ring.h"
  46. #include "wbm_reg_seq_hwioreg.h"
  47. #include "wbm_buffer_ring.h"
  48. #include "wbm_release_ring.h"
  49. #include "rx_msdu_desc_info.h"
  50. #include "rx_mpdu_start.h"
  51. #include "rx_mpdu_end.h"
  52. #include "rx_msdu_start.h"
  53. #include "rx_msdu_end.h"
  54. #include "rx_attention.h"
  55. #include "rx_ppdu_start.h"
  56. #include "rx_ppdu_start_user_info.h"
  57. #include "rx_ppdu_end_user_stats.h"
  58. #include "rx_ppdu_end_user_stats_ext.h"
  59. #include "rx_mpdu_desc_info.h"
  60. #include "rxpcu_ppdu_end_info.h"
  61. #include "phyrx_he_sig_a_su.h"
  62. #include "phyrx_he_sig_a_mu_dl.h"
  63. #if defined(QCA_WIFI_QCA6290_11AX_MU_UL) && defined(QCA_WIFI_QCA6290_11AX)
  64. #include "phyrx_he_sig_a_mu_ul.h"
  65. #endif
  66. #include "phyrx_he_sig_b1_mu.h"
  67. #include "phyrx_he_sig_b2_mu.h"
  68. #include "phyrx_he_sig_b2_ofdma.h"
  69. #include "phyrx_l_sig_a.h"
  70. #include "phyrx_l_sig_b.h"
  71. #include "phyrx_vht_sig_a.h"
  72. #include "phyrx_ht_sig.h"
  73. #include "tx_msdu_extension.h"
  74. #include "receive_rssi_info.h"
  75. #include "phyrx_pkt_end.h"
  76. #include "phyrx_rssi_legacy.h"
  77. #include "wcss_version.h"
  78. #include "rx_msdu_link.h"
  79. #include "hal_internal.h"
  80. #define HAL_SRNG_REO_EXCEPTION HAL_SRNG_REO2SW1
  81. #define HAL_SRNG_REO_ALTERNATE_SELECT 0x7
  82. #define HAL_NON_QOS_TID 16
  83. /* TODO: Check if the following can be provided directly by HW headers */
  84. #define SRNG_LOOP_CNT_MASK REO_DESTINATION_RING_15_LOOPING_COUNT_MASK
  85. #define SRNG_LOOP_CNT_LSB REO_DESTINATION_RING_15_LOOPING_COUNT_LSB
  86. /* HAL Macro to get the buffer info size */
  87. #define HAL_RX_BUFFINFO_NUM_DWORDS NUM_OF_DWORDS_BUFFER_ADDR_INFO
  88. #define HAL_DEFAULT_BE_BK_VI_REO_TIMEOUT_MS 100 /* milliseconds */
  89. #define HAL_DEFAULT_VO_REO_TIMEOUT_MS 40 /* milliseconds */
  90. #define HAL_DESC_SET_FIELD(_desc, _word, _fld, _value) do { \
  91. ((uint32_t *)(_desc))[(_word ## _ ## _fld ## _OFFSET) >> 2] &= \
  92. ~(_word ## _ ## _fld ## _MASK); \
  93. ((uint32_t *)(_desc))[(_word ## _ ## _fld ## _OFFSET) >> 2] |= \
  94. ((_value) << _word ## _ ## _fld ## _LSB); \
  95. } while (0)
  96. #define HAL_SM(_reg, _fld, _val) \
  97. (((_val) << (_reg ## _ ## _fld ## _SHFT)) & \
  98. (_reg ## _ ## _fld ## _BMSK))
  99. #define HAL_MS(_reg, _fld, _val) \
  100. (((_val) & (_reg ## _ ## _fld ## _BMSK)) >> \
  101. (_reg ## _ ## _fld ## _SHFT))
  102. #define HAL_REG_WRITE(_soc, _reg, _value) \
  103. hal_write32_mb(_soc, (_reg), (_value))
  104. /* Check register writing result */
  105. #define HAL_REG_WRITE_CONFIRM(_soc, _reg, _value) \
  106. hal_write32_mb_confirm(_soc, (_reg), (_value))
  107. #define HAL_REG_READ(_soc, _offset) \
  108. hal_read32_mb(_soc, (_offset))
  109. #define WBM_IDLE_DESC_LIST 1
  110. /**
  111. * Common SRNG register access macros:
  112. * The SRNG registers are distributed across various UMAC and LMAC HW blocks,
  113. * but the register group and format is exactly same for all rings, with some
  114. * difference between producer rings (these are 'producer rings' with respect
  115. * to HW and referred as 'destination rings' in SW) and consumer rings (these
  116. * are 'consumer rings' with respect to HW and
  117. * referred as 'source rings' in SW).
  118. * The following macros provide uniform access to all SRNG rings.
  119. */
  120. /* SRNG registers are split among two groups R0 and R2 and following
  121. * definitions identify the group to which each register belongs to
  122. */
  123. #define R0_INDEX 0
  124. #define R2_INDEX 1
  125. #define HWREG_INDEX(_reg_group) _reg_group ## _ ## INDEX
  126. /* Registers in R0 group */
  127. #define BASE_LSB_GROUP R0
  128. #define BASE_MSB_GROUP R0
  129. #define ID_GROUP R0
  130. #define STATUS_GROUP R0
  131. #define MISC_GROUP R0
  132. #define HP_ADDR_LSB_GROUP R0
  133. #define HP_ADDR_MSB_GROUP R0
  134. #define PRODUCER_INT_SETUP_GROUP R0
  135. #define PRODUCER_INT_STATUS_GROUP R0
  136. #define PRODUCER_FULL_COUNTER_GROUP R0
  137. #define MSI1_BASE_LSB_GROUP R0
  138. #define MSI1_BASE_MSB_GROUP R0
  139. #define MSI1_DATA_GROUP R0
  140. #define HP_TP_SW_OFFSET_GROUP R0
  141. #define TP_ADDR_LSB_GROUP R0
  142. #define TP_ADDR_MSB_GROUP R0
  143. #define CONSUMER_INT_SETUP_IX0_GROUP R0
  144. #define CONSUMER_INT_SETUP_IX1_GROUP R0
  145. #define CONSUMER_INT_STATUS_GROUP R0
  146. #define CONSUMER_EMPTY_COUNTER_GROUP R0
  147. #define CONSUMER_PREFETCH_TIMER_GROUP R0
  148. #define CONSUMER_PREFETCH_STATUS_GROUP R0
  149. /* Registers in R2 group */
  150. #define HP_GROUP R2
  151. #define TP_GROUP R2
  152. /**
  153. * Register definitions for all SRNG based rings are same, except few
  154. * differences between source (HW consumer) and destination (HW producer)
  155. * registers. Following macros definitions provide generic access to all
  156. * SRNG based rings.
  157. * For source rings, we will use the register/field definitions of SW2TCL1
  158. * ring defined in the HW header file mac_tcl_reg_seq_hwioreg.h. To setup
  159. * individual fields, SRNG_SM macros should be used with fields specified
  160. * using SRNG_SRC_FLD(<register>, <field>), Register writes should be done
  161. * using SRNG_SRC_REG_WRITE(<hal_srng>, <register>, <value>).
  162. * Similarly for destination rings we will use definitions of REO2SW1 ring
  163. * defined in the register reo_destination_ring.h. To setup individual
  164. * fields SRNG_SM macros should be used with fields specified using
  165. * SRNG_DST_FLD(<register>, <field>). Register writes should be done using
  166. * SRNG_DST_REG_WRITE(<hal_srng>, <register>, <value>).
  167. */
  168. #define SRNG_DST_REG_OFFSET(_reg, _reg_group) \
  169. HWIO_REO_ ## _reg_group ## _REO2SW1_RING_ ## _reg##_ADDR(0)
  170. #define SRNG_SRC_REG_OFFSET(_reg, _reg_group) \
  171. HWIO_TCL_ ## _reg_group ## _SW2TCL1_RING_ ## _reg ## _ADDR(0)
  172. #define _SRNG_DST_FLD(_reg_group, _reg_fld) \
  173. HWIO_REO_ ## _reg_group ## _REO2SW1_RING_ ## _reg_fld
  174. #define _SRNG_SRC_FLD(_reg_group, _reg_fld) \
  175. HWIO_TCL_ ## _reg_group ## _SW2TCL1_RING_ ## _reg_fld
  176. #define _SRNG_FLD(_reg_group, _reg_fld, _dir) \
  177. _SRNG_ ## _dir ## _FLD(_reg_group, _reg_fld)
  178. #define SRNG_DST_FLD(_reg, _f) _SRNG_FLD(_reg ## _GROUP, _reg ## _ ## _f, DST)
  179. #define SRNG_SRC_FLD(_reg, _f) _SRNG_FLD(_reg ## _GROUP, _reg ## _ ## _f, SRC)
  180. #define SRNG_SRC_R0_START_OFFSET SRNG_SRC_REG_OFFSET(BASE_LSB, R0)
  181. #define SRNG_DST_R0_START_OFFSET SRNG_DST_REG_OFFSET(BASE_LSB, R0)
  182. #define SRNG_SRC_R2_START_OFFSET SRNG_SRC_REG_OFFSET(HP, R2)
  183. #define SRNG_DST_R2_START_OFFSET SRNG_DST_REG_OFFSET(HP, R2)
  184. #define SRNG_SRC_START_OFFSET(_reg_group) \
  185. SRNG_SRC_ ## _reg_group ## _START_OFFSET
  186. #define SRNG_DST_START_OFFSET(_reg_group) \
  187. SRNG_DST_ ## _reg_group ## _START_OFFSET
  188. #define SRNG_REG_ADDR(_srng, _reg, _reg_group, _dir) \
  189. ((_srng)->hwreg_base[HWREG_INDEX(_reg_group)] + \
  190. ((_srng)->hal_soc->hal_hw_reg_offset[_dir ## _ ##_reg]))
  191. #define CALCULATE_REG_OFFSET(_dir, _reg, _reg_group) \
  192. (SRNG_ ## _dir ## _REG_OFFSET(_reg, _reg_group) - \
  193. SRNG_ ## _dir ## _START_OFFSET(_reg_group))
  194. #define REG_OFFSET(_dir, _reg) \
  195. CALCULATE_REG_OFFSET(_dir, _reg, _reg ## _GROUP)
  196. #define SRNG_DST_ADDR(_srng, _reg) \
  197. SRNG_REG_ADDR(_srng, _reg, _reg ## _GROUP, DST)
  198. #define SRNG_SRC_ADDR(_srng, _reg) \
  199. SRNG_REG_ADDR(_srng, _reg, _reg ## _GROUP, SRC)
  200. #ifdef FEATURE_HAL_DELAYED_WRITE
  201. #define SRNG_REG_WRITE(_srng, _reg, _value, _dir) \
  202. hal_delayed_reg_write(_srng->hal_soc, _srng,\
  203. SRNG_ ## _dir ## _ADDR(_srng, _reg), (_value))
  204. #else
  205. #define SRNG_REG_WRITE(_srng, _reg, _value, _dir) \
  206. hal_write_address_32_mb(_srng->hal_soc,\
  207. SRNG_ ## _dir ## _ADDR(_srng, _reg), (_value))
  208. #endif
  209. #define SRNG_REG_READ(_srng, _reg, _dir) \
  210. hal_read_address_32_mb(_srng->hal_soc, \
  211. SRNG_ ## _dir ## _ADDR(_srng, _reg))
  212. #define SRNG_SRC_REG_WRITE(_srng, _reg, _value) \
  213. SRNG_REG_WRITE(_srng, _reg, _value, SRC)
  214. #define SRNG_DST_REG_WRITE(_srng, _reg, _value) \
  215. SRNG_REG_WRITE(_srng, _reg, _value, DST)
  216. #define SRNG_SRC_REG_READ(_srng, _reg) \
  217. SRNG_REG_READ(_srng, _reg, SRC)
  218. #define SRNG_DST_REG_READ(_srng, _reg) \
  219. SRNG_REG_READ(_srng, _reg, DST)
  220. #define _SRNG_FM(_reg_fld) _reg_fld ## _BMSK
  221. #define _SRNG_FS(_reg_fld) _reg_fld ## _SHFT
  222. #define SRNG_SM(_reg_fld, _val) \
  223. (((_val) << _SRNG_FS(_reg_fld)) & _SRNG_FM(_reg_fld))
  224. #define SRNG_MS(_reg_fld, _val) \
  225. (((_val) & _SRNG_FM(_reg_fld)) >> _SRNG_FS(_reg_fld))
  226. #define SRNG_MAX_SIZE_DWORDS \
  227. (SRNG_MS(SRNG_SRC_FLD(BASE_MSB, RING_SIZE), 0xffffffff))
  228. /**
  229. * HW ring configuration table to identify hardware ring attributes like
  230. * register addresses, number of rings, ring entry size etc., for each type
  231. * of SRNG ring.
  232. *
  233. * Currently there is just one HW ring table, but there could be multiple
  234. * configurations in future based on HW variants from the same wifi3.0 family
  235. * and hence need to be attached with hal_soc based on HW type
  236. */
  237. #define HAL_SRNG_CONFIG(_hal_soc, _ring_type) \
  238. (&_hal_soc->hw_srng_table[_ring_type])
  239. enum SRNG_REGISTERS {
  240. DST_HP = 0,
  241. DST_TP,
  242. DST_ID,
  243. DST_MISC,
  244. DST_HP_ADDR_LSB,
  245. DST_HP_ADDR_MSB,
  246. DST_MSI1_BASE_LSB,
  247. DST_MSI1_BASE_MSB,
  248. DST_MSI1_DATA,
  249. DST_BASE_LSB,
  250. DST_BASE_MSB,
  251. DST_PRODUCER_INT_SETUP,
  252. SRC_HP,
  253. SRC_TP,
  254. SRC_ID,
  255. SRC_MISC,
  256. SRC_TP_ADDR_LSB,
  257. SRC_TP_ADDR_MSB,
  258. SRC_MSI1_BASE_LSB,
  259. SRC_MSI1_BASE_MSB,
  260. SRC_MSI1_DATA,
  261. SRC_BASE_LSB,
  262. SRC_BASE_MSB,
  263. SRC_CONSUMER_INT_SETUP_IX0,
  264. SRC_CONSUMER_INT_SETUP_IX1,
  265. };
  266. /**
  267. * hal_set_link_desc_addr - Setup link descriptor in a buffer_addr_info
  268. * HW structure
  269. *
  270. * @desc: Descriptor entry (from WBM_IDLE_LINK ring)
  271. * @cookie: SW cookie for the buffer/descriptor
  272. * @link_desc_paddr: Physical address of link descriptor entry
  273. *
  274. */
  275. static inline void hal_set_link_desc_addr(void *desc, uint32_t cookie,
  276. qdf_dma_addr_t link_desc_paddr)
  277. {
  278. uint32_t *buf_addr = (uint32_t *)desc;
  279. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_0, BUFFER_ADDR_31_0,
  280. link_desc_paddr & 0xffffffff);
  281. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_1, BUFFER_ADDR_39_32,
  282. (uint64_t)link_desc_paddr >> 32);
  283. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_1, RETURN_BUFFER_MANAGER,
  284. WBM_IDLE_DESC_LIST);
  285. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_1, SW_BUFFER_COOKIE,
  286. cookie);
  287. }
  288. /**
  289. * hal_get_reo_qdesc_size - Get size of reo queue descriptor
  290. *
  291. * @hal_soc: Opaque HAL SOC handle
  292. * @ba_window_size: BlockAck window size
  293. * @tid: TID number
  294. *
  295. */
  296. static inline
  297. uint32_t hal_get_reo_qdesc_size(hal_soc_handle_t hal_soc_hdl,
  298. uint32_t ba_window_size, int tid)
  299. {
  300. /* Return descriptor size corresponding to window size of 2 since
  301. * we set ba_window_size to 2 while setting up REO descriptors as
  302. * a WAR to get 2k jump exception aggregates are received without
  303. * a BA session.
  304. */
  305. if (ba_window_size <= 1) {
  306. if (tid != HAL_NON_QOS_TID)
  307. return sizeof(struct rx_reo_queue) +
  308. sizeof(struct rx_reo_queue_ext);
  309. else
  310. return sizeof(struct rx_reo_queue);
  311. }
  312. if (ba_window_size <= 105)
  313. return sizeof(struct rx_reo_queue) +
  314. sizeof(struct rx_reo_queue_ext);
  315. if (ba_window_size <= 210)
  316. return sizeof(struct rx_reo_queue) +
  317. (2 * sizeof(struct rx_reo_queue_ext));
  318. return sizeof(struct rx_reo_queue) +
  319. (3 * sizeof(struct rx_reo_queue_ext));
  320. }
  321. #endif /* _HAL_HW_INTERNAL_H_ */