hal_internal.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. * Copyright (c) 2016-2019 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_lock.h"
  22. #include "qdf_mem.h"
  23. #include "qdf_nbuf.h"
  24. #include "pld_common.h"
  25. #define hal_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_TXRX, params)
  26. #define hal_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_TXRX, params)
  27. #define hal_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_TXRX, params)
  28. #define hal_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_TXRX, params)
  29. #define hal_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_TXRX, params)
  30. #define hal_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_HAL, params)
  31. #define hal_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_HAL, params)
  32. #define hal_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_HAL, params)
  33. #define hal_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_HAL, params)
  34. #define hal_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_HAL, params)
  35. #ifdef ENABLE_VERBOSE_DEBUG
  36. extern bool is_hal_verbose_debug_enabled;
  37. #define hal_verbose_debug(params...) \
  38. if (unlikely(is_hal_verbose_debug_enabled)) \
  39. do {\
  40. QDF_TRACE_DEBUG(QDF_MODULE_ID_TXRX, params); \
  41. } while (0)
  42. #define hal_verbose_hex_dump(params...) \
  43. if (unlikely(is_hal_verbose_debug_enabled)) \
  44. do {\
  45. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_TXRX, \
  46. QDF_TRACE_LEVEL_DEBUG, \
  47. params); \
  48. } while (0)
  49. #else
  50. #define hal_verbose_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_TXRX, params)
  51. #define hal_verbose_hex_dump(params...) \
  52. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG, \
  53. params)
  54. #endif
  55. /*
  56. * dp_hal_soc - opaque handle for DP HAL soc
  57. */
  58. struct hal_soc_handle;
  59. typedef struct hal_soc_handle *hal_soc_handle_t;
  60. /* TBD: This should be movded to shared HW header file */
  61. enum hal_srng_ring_id {
  62. /* UMAC rings */
  63. HAL_SRNG_REO2SW1 = 0,
  64. HAL_SRNG_REO2SW2 = 1,
  65. HAL_SRNG_REO2SW3 = 2,
  66. HAL_SRNG_REO2SW4 = 3,
  67. HAL_SRNG_REO2TCL = 4,
  68. HAL_SRNG_SW2REO = 5,
  69. /* 6-7 unused */
  70. HAL_SRNG_REO_CMD = 8,
  71. HAL_SRNG_REO_STATUS = 9,
  72. /* 10-15 unused */
  73. HAL_SRNG_SW2TCL1 = 16,
  74. HAL_SRNG_SW2TCL2 = 17,
  75. HAL_SRNG_SW2TCL3 = 18,
  76. HAL_SRNG_SW2TCL4 = 19, /* FW2TCL ring */
  77. /* 20-23 unused */
  78. HAL_SRNG_SW2TCL_CMD = 24,
  79. HAL_SRNG_TCL_STATUS = 25,
  80. /* 26-31 unused */
  81. HAL_SRNG_CE_0_SRC = 32,
  82. HAL_SRNG_CE_1_SRC = 33,
  83. HAL_SRNG_CE_2_SRC = 34,
  84. HAL_SRNG_CE_3_SRC = 35,
  85. HAL_SRNG_CE_4_SRC = 36,
  86. HAL_SRNG_CE_5_SRC = 37,
  87. HAL_SRNG_CE_6_SRC = 38,
  88. HAL_SRNG_CE_7_SRC = 39,
  89. HAL_SRNG_CE_8_SRC = 40,
  90. HAL_SRNG_CE_9_SRC = 41,
  91. HAL_SRNG_CE_10_SRC = 42,
  92. HAL_SRNG_CE_11_SRC = 43,
  93. /* 44-55 unused */
  94. HAL_SRNG_CE_0_DST = 56,
  95. HAL_SRNG_CE_1_DST = 57,
  96. HAL_SRNG_CE_2_DST = 58,
  97. HAL_SRNG_CE_3_DST = 59,
  98. HAL_SRNG_CE_4_DST = 60,
  99. HAL_SRNG_CE_5_DST = 61,
  100. HAL_SRNG_CE_6_DST = 62,
  101. HAL_SRNG_CE_7_DST = 63,
  102. HAL_SRNG_CE_8_DST = 64,
  103. HAL_SRNG_CE_9_DST = 65,
  104. HAL_SRNG_CE_10_DST = 66,
  105. HAL_SRNG_CE_11_DST = 67,
  106. /* 68-79 unused */
  107. HAL_SRNG_CE_0_DST_STATUS = 80,
  108. HAL_SRNG_CE_1_DST_STATUS = 81,
  109. HAL_SRNG_CE_2_DST_STATUS = 82,
  110. HAL_SRNG_CE_3_DST_STATUS = 83,
  111. HAL_SRNG_CE_4_DST_STATUS = 84,
  112. HAL_SRNG_CE_5_DST_STATUS = 85,
  113. HAL_SRNG_CE_6_DST_STATUS = 86,
  114. HAL_SRNG_CE_7_DST_STATUS = 87,
  115. HAL_SRNG_CE_8_DST_STATUS = 88,
  116. HAL_SRNG_CE_9_DST_STATUS = 89,
  117. HAL_SRNG_CE_10_DST_STATUS = 90,
  118. HAL_SRNG_CE_11_DST_STATUS = 91,
  119. /* 92-103 unused */
  120. HAL_SRNG_WBM_IDLE_LINK = 104,
  121. HAL_SRNG_WBM_SW_RELEASE = 105,
  122. HAL_SRNG_WBM2SW0_RELEASE = 106,
  123. HAL_SRNG_WBM2SW1_RELEASE = 107,
  124. HAL_SRNG_WBM2SW2_RELEASE = 108,
  125. HAL_SRNG_WBM2SW3_RELEASE = 109,
  126. /* 110-127 unused */
  127. HAL_SRNG_UMAC_ID_END = 127,
  128. /* LMAC rings - The following set will be replicated for each LMAC */
  129. HAL_SRNG_LMAC1_ID_START = 128,
  130. HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 = HAL_SRNG_LMAC1_ID_START,
  131. #ifdef IPA_OFFLOAD
  132. HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 = (HAL_SRNG_LMAC1_ID_START + 1),
  133. HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 = (HAL_SRNG_LMAC1_ID_START + 2),
  134. HAL_SRNG_WMAC1_SW2RXDMA1_BUF = (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 + 1),
  135. #else
  136. HAL_SRNG_WMAC1_SW2RXDMA1_BUF = (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 + 1),
  137. #endif
  138. HAL_SRNG_WMAC1_SW2RXDMA2_BUF = (HAL_SRNG_WMAC1_SW2RXDMA1_BUF + 1),
  139. HAL_SRNG_WMAC1_SW2RXDMA0_STATBUF = (HAL_SRNG_WMAC1_SW2RXDMA2_BUF + 1),
  140. HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF =
  141. (HAL_SRNG_WMAC1_SW2RXDMA0_STATBUF + 1),
  142. HAL_SRNG_WMAC1_RXDMA2SW0 = (HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF + 1),
  143. HAL_SRNG_WMAC1_RXDMA2SW1 = (HAL_SRNG_WMAC1_RXDMA2SW0 + 1),
  144. HAL_SRNG_WMAC1_SW2RXDMA1_DESC = (HAL_SRNG_WMAC1_RXDMA2SW1 + 1),
  145. #ifdef WLAN_FEATURE_CIF_CFR
  146. HAL_SRNG_WIFI_POS_SRC_DMA_RING = (HAL_SRNG_WMAC1_SW2RXDMA1_DESC + 1),
  147. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING = (HAL_SRNG_WIFI_POS_SRC_DMA_RING + 1),
  148. #else
  149. HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING = (HAL_SRNG_WMAC1_SW2RXDMA1_DESC + 1),
  150. #endif
  151. /* -142 unused */
  152. HAL_SRNG_LMAC1_ID_END = 143
  153. };
  154. #define HAL_RXDMA_MAX_RING_SIZE 0xFFFF
  155. #define HAL_MAX_LMACS 3
  156. #define HAL_MAX_RINGS_PER_LMAC (HAL_SRNG_LMAC1_ID_END - HAL_SRNG_LMAC1_ID_START)
  157. #define HAL_MAX_LMAC_RINGS (HAL_MAX_LMACS * HAL_MAX_RINGS_PER_LMAC)
  158. #define HAL_SRNG_ID_MAX (HAL_SRNG_UMAC_ID_END + HAL_MAX_LMAC_RINGS)
  159. enum hal_srng_dir {
  160. HAL_SRNG_SRC_RING,
  161. HAL_SRNG_DST_RING
  162. };
  163. /* Lock wrappers for SRNG */
  164. #define hal_srng_lock_t qdf_spinlock_t
  165. #define SRNG_LOCK_INIT(_lock) qdf_spinlock_create(_lock)
  166. #define SRNG_LOCK(_lock) qdf_spin_lock_bh(_lock)
  167. #define SRNG_UNLOCK(_lock) qdf_spin_unlock_bh(_lock)
  168. #define SRNG_LOCK_DESTROY(_lock) qdf_spinlock_destroy(_lock)
  169. struct hal_soc;
  170. /**
  171. * dp_hal_ring - opaque handle for DP HAL SRNG
  172. */
  173. struct hal_ring_handle;
  174. typedef struct hal_ring_handle *hal_ring_handle_t;
  175. #define MAX_SRNG_REG_GROUPS 2
  176. /* Hal Srng bit mask
  177. * HAL_SRNG_FLUSH_EVENT: SRNG HP TP flush in case of link down
  178. */
  179. #define HAL_SRNG_FLUSH_EVENT BIT(0)
  180. /* Common SRNG ring structure for source and destination rings */
  181. struct hal_srng {
  182. /* Unique SRNG ring ID */
  183. uint8_t ring_id;
  184. /* Ring initialization done */
  185. uint8_t initialized;
  186. /* Interrupt/MSI value assigned to this ring */
  187. int irq;
  188. /* Physical base address of the ring */
  189. qdf_dma_addr_t ring_base_paddr;
  190. /* Virtual base address of the ring */
  191. uint32_t *ring_base_vaddr;
  192. /* Number of entries in ring */
  193. uint32_t num_entries;
  194. /* Ring size */
  195. uint32_t ring_size;
  196. /* Ring size mask */
  197. uint32_t ring_size_mask;
  198. /* Size of ring entry */
  199. uint32_t entry_size;
  200. /* Interrupt timer threshold – in micro seconds */
  201. uint32_t intr_timer_thres_us;
  202. /* Interrupt batch counter threshold – in number of ring entries */
  203. uint32_t intr_batch_cntr_thres_entries;
  204. /* MSI Address */
  205. qdf_dma_addr_t msi_addr;
  206. /* MSI data */
  207. uint32_t msi_data;
  208. /* Misc flags */
  209. uint32_t flags;
  210. /* Lock for serializing ring index updates */
  211. hal_srng_lock_t lock;
  212. /* Start offset of SRNG register groups for this ring
  213. * TBD: See if this is required - register address can be derived
  214. * from ring ID
  215. */
  216. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  217. /* Source or Destination ring */
  218. enum hal_srng_dir ring_dir;
  219. union {
  220. struct {
  221. /* SW tail pointer */
  222. uint32_t tp;
  223. /* Shadow head pointer location to be updated by HW */
  224. uint32_t *hp_addr;
  225. /* Cached head pointer */
  226. uint32_t cached_hp;
  227. /* Tail pointer location to be updated by SW – This
  228. * will be a register address and need not be
  229. * accessed through SW structure */
  230. uint32_t *tp_addr;
  231. /* Current SW loop cnt */
  232. uint32_t loop_cnt;
  233. /* max transfer size */
  234. uint16_t max_buffer_length;
  235. } dst_ring;
  236. struct {
  237. /* SW head pointer */
  238. uint32_t hp;
  239. /* SW reap head pointer */
  240. uint32_t reap_hp;
  241. /* Shadow tail pointer location to be updated by HW */
  242. uint32_t *tp_addr;
  243. /* Cached tail pointer */
  244. uint32_t cached_tp;
  245. /* Head pointer location to be updated by SW – This
  246. * will be a register address and need not be accessed
  247. * through SW structure */
  248. uint32_t *hp_addr;
  249. /* Low threshold – in number of ring entries */
  250. uint32_t low_threshold;
  251. } src_ring;
  252. } u;
  253. struct hal_soc *hal_soc;
  254. /* Number of times hp/tp updated in runtime resume */
  255. uint32_t flush_count;
  256. /* hal srng event flag*/
  257. unsigned long srng_event;
  258. /* last flushed time stamp */
  259. uint64_t last_flush_ts;
  260. };
  261. /* HW SRNG configuration table */
  262. struct hal_hw_srng_config {
  263. int start_ring_id;
  264. uint16_t max_rings;
  265. uint16_t entry_size;
  266. uint32_t reg_start[MAX_SRNG_REG_GROUPS];
  267. uint16_t reg_size[MAX_SRNG_REG_GROUPS];
  268. uint8_t lmac_ring;
  269. enum hal_srng_dir ring_dir;
  270. uint32_t max_size;
  271. };
  272. #define MAX_SHADOW_REGISTERS 36
  273. /* REO parameters to be passed to hal_reo_setup */
  274. struct hal_reo_params {
  275. /** rx hash steering enabled or disabled */
  276. bool rx_hash_enabled;
  277. /** reo remap 1 register */
  278. uint32_t remap1;
  279. /** reo remap 2 register */
  280. uint32_t remap2;
  281. /** fragment destination ring */
  282. uint8_t frag_dst_ring;
  283. /** padding */
  284. uint8_t padding[3];
  285. };
  286. struct hal_hw_txrx_ops {
  287. /* init and setup */
  288. void (*hal_srng_dst_hw_init)(struct hal_soc *hal,
  289. struct hal_srng *srng);
  290. void (*hal_srng_src_hw_init)(struct hal_soc *hal,
  291. struct hal_srng *srng);
  292. void (*hal_get_hw_hptp)(struct hal_soc *hal,
  293. hal_ring_handle_t hal_ring_hdl,
  294. uint32_t *headp, uint32_t *tailp,
  295. uint8_t ring_type);
  296. void (*hal_reo_setup)(struct hal_soc *hal_soc, void *reoparams);
  297. void (*hal_setup_link_idle_list)(
  298. struct hal_soc *hal_soc,
  299. qdf_dma_addr_t scatter_bufs_base_paddr[],
  300. void *scatter_bufs_base_vaddr[],
  301. uint32_t num_scatter_bufs,
  302. uint32_t scatter_buf_size,
  303. uint32_t last_buf_end_offset,
  304. uint32_t num_entries);
  305. /* tx */
  306. void (*hal_tx_desc_set_dscp_tid_table_id)(void *desc, uint8_t id);
  307. void (*hal_tx_set_dscp_tid_map)(struct hal_soc *hal_soc, uint8_t *map,
  308. uint8_t id);
  309. void (*hal_tx_update_dscp_tid)(struct hal_soc *hal_soc, uint8_t tid,
  310. uint8_t id,
  311. uint8_t dscp);
  312. void (*hal_tx_desc_set_lmac_id)(void *desc, uint8_t lmac_id);
  313. void (*hal_tx_desc_set_buf_addr)(void *desc, dma_addr_t paddr,
  314. uint8_t pool_id, uint32_t desc_id, uint8_t type);
  315. void (*hal_tx_desc_set_search_type)(void *desc, uint8_t search_type);
  316. void (*hal_tx_desc_set_search_index)(void *desc, uint32_t search_index);
  317. void (*hal_tx_desc_set_cache_set_num)(void *desc, uint8_t search_index);
  318. void (*hal_tx_comp_get_status)(void *desc, void *ts,
  319. struct hal_soc *hal);
  320. uint8_t (*hal_tx_comp_get_release_reason)(void *hal_desc);
  321. void (*hal_tx_desc_set_mesh_en)(void *desc, uint8_t en);
  322. /* rx */
  323. uint32_t (*hal_rx_msdu_start_nss_get)(uint8_t *);
  324. void (*hal_rx_mon_hw_desc_get_mpdu_status)(void *hw_desc_addr,
  325. struct mon_rx_status *rs);
  326. uint8_t (*hal_rx_get_tlv)(void *rx_tlv);
  327. void (*hal_rx_proc_phyrx_other_receive_info_tlv)(void *rx_tlv_hdr,
  328. void *ppdu_info_handle);
  329. void (*hal_rx_dump_msdu_start_tlv)(void *msdu_start, uint8_t dbg_level);
  330. void (*hal_rx_dump_msdu_end_tlv)(void *msdu_end,
  331. uint8_t dbg_level);
  332. uint32_t (*hal_get_link_desc_size)(void);
  333. uint32_t (*hal_rx_mpdu_start_tid_get)(uint8_t *buf);
  334. uint32_t (*hal_rx_msdu_start_reception_type_get)(uint8_t *buf);
  335. uint16_t (*hal_rx_msdu_end_da_idx_get)(uint8_t *buf);
  336. void* (*hal_rx_msdu_desc_info_get_ptr)(void *msdu_details_ptr);
  337. void* (*hal_rx_link_desc_msdu0_ptr)(void *msdu_link_ptr);
  338. void (*hal_reo_status_get_header)(uint32_t *d, int b, void *h);
  339. uint32_t (*hal_rx_status_get_tlv_info)(void *rx_tlv_hdr,
  340. void *ppdu_info,
  341. hal_soc_handle_t hal_soc_hdl,
  342. qdf_nbuf_t nbuf);
  343. void (*hal_rx_wbm_err_info_get)(void *wbm_desc,
  344. void *wbm_er_info);
  345. void (*hal_rx_dump_mpdu_start_tlv)(void *mpdustart,
  346. uint8_t dbg_level);
  347. void (*hal_tx_set_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t *map);
  348. void (*hal_tx_update_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t pcp,
  349. uint8_t id);
  350. void (*hal_tx_set_tidmap_prty)(struct hal_soc *hal_soc, uint8_t prio);
  351. uint8_t (*hal_rx_get_rx_fragment_number)(uint8_t *buf);
  352. uint8_t (*hal_rx_msdu_end_da_is_mcbc_get)(uint8_t *buf);
  353. uint8_t (*hal_rx_msdu_end_sa_is_valid_get)(uint8_t *buf);
  354. uint16_t (*hal_rx_msdu_end_sa_idx_get)(uint8_t *buf);
  355. uint32_t (*hal_rx_desc_is_first_msdu)(void *hw_desc_addr);
  356. uint32_t (*hal_rx_msdu_end_l3_hdr_padding_get)(uint8_t *buf);
  357. uint32_t (*hal_rx_encryption_info_valid)(uint8_t *buf);
  358. void (*hal_rx_print_pn)(uint8_t *buf);
  359. uint8_t (*hal_rx_msdu_end_first_msdu_get)(uint8_t *buf);
  360. uint8_t (*hal_rx_msdu_end_da_is_valid_get)(uint8_t *buf);
  361. uint8_t (*hal_rx_msdu_end_last_msdu_get)(uint8_t *buf);
  362. bool (*hal_rx_get_mpdu_mac_ad4_valid)(uint8_t *buf);
  363. uint32_t (*hal_rx_mpdu_start_sw_peer_id_get)(uint8_t *buf);
  364. uint32_t (*hal_rx_mpdu_get_to_ds)(uint8_t *buf);
  365. uint32_t (*hal_rx_mpdu_get_fr_ds)(uint8_t *buf);
  366. uint8_t (*hal_rx_get_mpdu_frame_control_valid)(uint8_t *buf);
  367. QDF_STATUS
  368. (*hal_rx_mpdu_get_addr1)(uint8_t *buf, uint8_t *mac_addr);
  369. QDF_STATUS
  370. (*hal_rx_mpdu_get_addr2)(uint8_t *buf, uint8_t *mac_addr);
  371. QDF_STATUS
  372. (*hal_rx_mpdu_get_addr3)(uint8_t *buf, uint8_t *mac_addr);
  373. QDF_STATUS
  374. (*hal_rx_mpdu_get_addr4)(uint8_t *buf, uint8_t *mac_addr);
  375. uint8_t (*hal_rx_get_mpdu_sequence_control_valid)(uint8_t *buf);
  376. bool (*hal_rx_is_unicast)(uint8_t *buf);
  377. uint32_t (*hal_rx_tid_get)(hal_soc_handle_t hal_soc_hdl, uint8_t *buf);
  378. uint32_t (*hal_rx_hw_desc_get_ppduid_get)(void *hw_desc_addr);
  379. uint32_t (*hal_rx_mpdu_start_mpdu_qos_control_valid_get)(uint8_t *buf);
  380. uint32_t (*hal_rx_msdu_end_sa_sw_peer_id_get)(uint8_t *buf);
  381. void * (*hal_rx_msdu0_buffer_addr_lsb)(void *link_desc_addr);
  382. void * (*hal_rx_msdu_desc_info_ptr_get)(void *msdu0);
  383. void * (*hal_ent_mpdu_desc_info)(void *hw_addr);
  384. void * (*hal_dst_mpdu_desc_info)(void *hw_addr);
  385. uint8_t (*hal_rx_get_fc_valid)(uint8_t *buf);
  386. uint8_t (*hal_rx_get_to_ds_flag)(uint8_t *buf);
  387. uint8_t (*hal_rx_get_mac_addr2_valid)(uint8_t *buf);
  388. uint8_t (*hal_rx_get_filter_category)(uint8_t *buf);
  389. uint32_t (*hal_rx_get_ppdu_id)(uint8_t *buf);
  390. void (*hal_reo_config)(struct hal_soc *soc,
  391. uint32_t reg_val,
  392. struct hal_reo_params *reo_params);
  393. uint32_t (*hal_rx_msdu_flow_idx_get)(uint8_t *buf);
  394. bool (*hal_rx_msdu_flow_idx_invalid)(uint8_t *buf);
  395. bool (*hal_rx_msdu_flow_idx_timeout)(uint8_t *buf);
  396. uint32_t (*hal_rx_msdu_fse_metadata_get)(uint8_t *buf);
  397. uint16_t (*hal_rx_msdu_cce_metadata_get)(uint8_t *buf);
  398. void
  399. (*hal_rx_msdu_get_flow_params)(
  400. uint8_t *buf,
  401. bool *flow_invalid,
  402. bool *flow_timeout,
  403. uint32_t *flow_index);
  404. uint16_t (*hal_rx_tlv_get_tcp_chksum)(uint8_t *buf);
  405. uint16_t (*hal_rx_get_rx_sequence)(uint8_t *buf);
  406. };
  407. /**
  408. * HAL context to be used to access SRNG APIs (currently used by data path
  409. * and transport (CE) modules)
  410. */
  411. struct hal_soc {
  412. /* HIF handle to access HW registers */
  413. struct hif_opaque_softc *hif_handle;
  414. /* QDF device handle */
  415. qdf_device_t qdf_dev;
  416. /* Device base address */
  417. void *dev_base_addr;
  418. /* HAL internal state for all SRNG rings.
  419. * TODO: See if this is required
  420. */
  421. struct hal_srng srng_list[HAL_SRNG_ID_MAX];
  422. /* Remote pointer memory for HW/FW updates */
  423. uint32_t *shadow_rdptr_mem_vaddr;
  424. qdf_dma_addr_t shadow_rdptr_mem_paddr;
  425. /* Shared memory for ring pointer updates from host to FW */
  426. uint32_t *shadow_wrptr_mem_vaddr;
  427. qdf_dma_addr_t shadow_wrptr_mem_paddr;
  428. /* REO blocking resource index */
  429. uint8_t reo_res_bitmap;
  430. uint8_t index;
  431. uint32_t target_type;
  432. /* shadow register configuration */
  433. struct pld_shadow_reg_v2_cfg shadow_config[MAX_SHADOW_REGISTERS];
  434. int num_shadow_registers_configured;
  435. bool use_register_windowing;
  436. uint32_t register_window;
  437. qdf_spinlock_t register_access_lock;
  438. /* srng table */
  439. struct hal_hw_srng_config *hw_srng_table;
  440. int32_t *hal_hw_reg_offset;
  441. struct hal_hw_txrx_ops *ops;
  442. /* Indicate srngs initialization */
  443. bool init_phase;
  444. };
  445. void hal_qca6490_attach(struct hal_soc *hal_soc);
  446. void hal_qca6390_attach(struct hal_soc *hal_soc);
  447. void hal_qca6290_attach(struct hal_soc *hal_soc);
  448. void hal_qca8074_attach(struct hal_soc *hal_soc);
  449. /*
  450. * hal_soc_to_dp_hal_roc - API to convert hal_soc to opaque
  451. * dp_hal_soc handle type
  452. * @hal_soc - hal_soc type
  453. *
  454. * Return: hal_soc_handle_t type
  455. */
  456. static inline
  457. hal_soc_handle_t hal_soc_to_hal_soc_handle(struct hal_soc *hal_soc)
  458. {
  459. return (hal_soc_handle_t)hal_soc;
  460. }
  461. /*
  462. * hal_srng_to_hal_ring_handle - API to convert hal_srng to opaque
  463. * dp_hal_ring handle type
  464. * @hal_srng - hal_srng type
  465. *
  466. * Return: hal_ring_handle_t type
  467. */
  468. static inline
  469. hal_ring_handle_t hal_srng_to_hal_ring_handle(struct hal_srng *hal_srng)
  470. {
  471. return (hal_ring_handle_t)hal_srng;
  472. }
  473. /*
  474. * hal_ring_handle_to_hal_srng - API to convert dp_hal_ring to hal_srng handle
  475. * @hal_ring - hal_ring_handle_t type
  476. *
  477. * Return: hal_srng pointer type
  478. */
  479. static inline
  480. struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring)
  481. {
  482. return (struct hal_srng *)hal_ring;
  483. }
  484. #endif /* _HAL_INTERNAL_H_ */