hw.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. /* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2. /*
  3. * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021-2022, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef ATH11K_HW_H
  7. #define ATH11K_HW_H
  8. #include "hal.h"
  9. #include "wmi.h"
  10. /* Target configuration defines */
  11. /* Num VDEVS per radio */
  12. #define TARGET_NUM_VDEVS(ab) (ab->hw_params.num_vdevs)
  13. #define TARGET_NUM_PEERS_PDEV(ab) (ab->hw_params.num_peers + TARGET_NUM_VDEVS(ab))
  14. /* Num of peers for Single Radio mode */
  15. #define TARGET_NUM_PEERS_SINGLE(ab) (TARGET_NUM_PEERS_PDEV(ab))
  16. /* Num of peers for DBS */
  17. #define TARGET_NUM_PEERS_DBS(ab) (2 * TARGET_NUM_PEERS_PDEV(ab))
  18. /* Num of peers for DBS_SBS */
  19. #define TARGET_NUM_PEERS_DBS_SBS(ab) (3 * TARGET_NUM_PEERS_PDEV(ab))
  20. /* Max num of stations (per radio) */
  21. #define TARGET_NUM_STATIONS(ab) (ab->hw_params.num_peers)
  22. #define TARGET_NUM_PEERS(ab, x) TARGET_NUM_PEERS_##x(ab)
  23. #define TARGET_NUM_PEER_KEYS 2
  24. #define TARGET_NUM_TIDS(ab, x) (2 * TARGET_NUM_PEERS(ab, x) + \
  25. 4 * TARGET_NUM_VDEVS(ab) + 8)
  26. #define TARGET_AST_SKID_LIMIT 16
  27. #define TARGET_NUM_OFFLD_PEERS 4
  28. #define TARGET_NUM_OFFLD_REORDER_BUFFS 4
  29. #define TARGET_TX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(4))
  30. #define TARGET_RX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(4))
  31. #define TARGET_RX_TIMEOUT_LO_PRI 100
  32. #define TARGET_RX_TIMEOUT_HI_PRI 40
  33. #define TARGET_DECAP_MODE_RAW 0
  34. #define TARGET_DECAP_MODE_NATIVE_WIFI 1
  35. #define TARGET_DECAP_MODE_ETH 2
  36. #define TARGET_SCAN_MAX_PENDING_REQS 4
  37. #define TARGET_BMISS_OFFLOAD_MAX_VDEV 3
  38. #define TARGET_ROAM_OFFLOAD_MAX_VDEV 3
  39. #define TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES 8
  40. #define TARGET_GTK_OFFLOAD_MAX_VDEV 3
  41. #define TARGET_NUM_MCAST_GROUPS 12
  42. #define TARGET_NUM_MCAST_TABLE_ELEMS 64
  43. #define TARGET_MCAST2UCAST_MODE 2
  44. #define TARGET_TX_DBG_LOG_SIZE 1024
  45. #define TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
  46. #define TARGET_VOW_CONFIG 0
  47. #define TARGET_NUM_MSDU_DESC (2500)
  48. #define TARGET_MAX_FRAG_ENTRIES 6
  49. #define TARGET_MAX_BCN_OFFLD 16
  50. #define TARGET_NUM_WDS_ENTRIES 32
  51. #define TARGET_DMA_BURST_SIZE 1
  52. #define TARGET_RX_BATCHMODE 1
  53. #define ATH11K_HW_MAX_QUEUES 4
  54. #define ATH11K_QUEUE_LEN 4096
  55. #define ATH11k_HW_RATECODE_CCK_SHORT_PREAM_MASK 0x4
  56. #define ATH11K_FW_DIR "ath11k"
  57. #define ATH11K_BOARD_MAGIC "QCA-ATH11K-BOARD"
  58. #define ATH11K_BOARD_API2_FILE "board-2.bin"
  59. #define ATH11K_DEFAULT_BOARD_FILE "board.bin"
  60. #define ATH11K_DEFAULT_CAL_FILE "caldata.bin"
  61. #define ATH11K_AMSS_FILE "amss.bin"
  62. #define ATH11K_M3_FILE "m3.bin"
  63. #define ATH11K_REGDB_FILE_NAME "regdb.bin"
  64. enum ath11k_hw_rate_cck {
  65. ATH11K_HW_RATE_CCK_LP_11M = 0,
  66. ATH11K_HW_RATE_CCK_LP_5_5M,
  67. ATH11K_HW_RATE_CCK_LP_2M,
  68. ATH11K_HW_RATE_CCK_LP_1M,
  69. ATH11K_HW_RATE_CCK_SP_11M,
  70. ATH11K_HW_RATE_CCK_SP_5_5M,
  71. ATH11K_HW_RATE_CCK_SP_2M,
  72. };
  73. enum ath11k_hw_rate_ofdm {
  74. ATH11K_HW_RATE_OFDM_48M = 0,
  75. ATH11K_HW_RATE_OFDM_24M,
  76. ATH11K_HW_RATE_OFDM_12M,
  77. ATH11K_HW_RATE_OFDM_6M,
  78. ATH11K_HW_RATE_OFDM_54M,
  79. ATH11K_HW_RATE_OFDM_36M,
  80. ATH11K_HW_RATE_OFDM_18M,
  81. ATH11K_HW_RATE_OFDM_9M,
  82. };
  83. enum ath11k_bus {
  84. ATH11K_BUS_AHB,
  85. ATH11K_BUS_PCI,
  86. };
  87. #define ATH11K_EXT_IRQ_GRP_NUM_MAX 11
  88. struct hal_rx_desc;
  89. struct hal_tcl_data_cmd;
  90. struct ath11k_hw_ring_mask {
  91. u8 tx[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  92. u8 rx_mon_status[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  93. u8 rx[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  94. u8 rx_err[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  95. u8 rx_wbm_rel[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  96. u8 reo_status[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  97. u8 rxdma2host[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  98. u8 host2rxdma[ATH11K_EXT_IRQ_GRP_NUM_MAX];
  99. };
  100. struct ath11k_hw_tcl2wbm_rbm_map {
  101. u8 tcl_ring_num;
  102. u8 wbm_ring_num;
  103. u8 rbm_id;
  104. };
  105. struct ath11k_hw_hal_params {
  106. enum hal_rx_buf_return_buf_manager rx_buf_rbm;
  107. const struct ath11k_hw_tcl2wbm_rbm_map *tcl2wbm_rbm_map;
  108. };
  109. struct ath11k_hw_params {
  110. const char *name;
  111. u16 hw_rev;
  112. u8 max_radios;
  113. u32 bdf_addr;
  114. struct {
  115. const char *dir;
  116. size_t board_size;
  117. size_t cal_offset;
  118. } fw;
  119. const struct ath11k_hw_ops *hw_ops;
  120. const struct ath11k_hw_ring_mask *ring_mask;
  121. bool internal_sleep_clock;
  122. const struct ath11k_hw_regs *regs;
  123. u32 qmi_service_ins_id;
  124. const struct ce_attr *host_ce_config;
  125. u32 ce_count;
  126. const struct ce_pipe_config *target_ce_config;
  127. u32 target_ce_count;
  128. const struct service_to_pipe *svc_to_ce_map;
  129. u32 svc_to_ce_map_len;
  130. bool single_pdev_only;
  131. bool rxdma1_enable;
  132. int num_rxmda_per_pdev;
  133. bool rx_mac_buf_ring;
  134. bool vdev_start_delay;
  135. bool htt_peer_map_v2;
  136. struct {
  137. u8 fft_sz;
  138. u8 fft_pad_sz;
  139. u8 summary_pad_sz;
  140. u8 fft_hdr_len;
  141. u16 max_fft_bins;
  142. bool fragment_160mhz;
  143. } spectral;
  144. u16 interface_modes;
  145. bool supports_monitor;
  146. bool full_monitor_mode;
  147. bool supports_shadow_regs;
  148. bool idle_ps;
  149. bool supports_sta_ps;
  150. bool cold_boot_calib;
  151. bool cbcal_restart_fw;
  152. int fw_mem_mode;
  153. u32 num_vdevs;
  154. u32 num_peers;
  155. bool supports_suspend;
  156. u32 hal_desc_sz;
  157. bool supports_regdb;
  158. bool fix_l1ss;
  159. bool credit_flow;
  160. u8 max_tx_ring;
  161. const struct ath11k_hw_hal_params *hal_params;
  162. bool supports_dynamic_smps_6ghz;
  163. bool alloc_cacheable_memory;
  164. bool supports_rssi_stats;
  165. bool fw_wmi_diag_event;
  166. bool current_cc_support;
  167. bool dbr_debug_support;
  168. bool global_reset;
  169. const struct cfg80211_sar_capa *bios_sar_capa;
  170. bool m3_fw_support;
  171. bool fixed_bdf_addr;
  172. bool fixed_mem_region;
  173. bool static_window_map;
  174. bool hybrid_bus_type;
  175. bool fixed_fw_mem;
  176. bool support_off_channel_tx;
  177. bool supports_multi_bssid;
  178. struct {
  179. u32 start;
  180. u32 end;
  181. } sram_dump;
  182. bool tcl_ring_retry;
  183. u32 tx_ring_size;
  184. bool smp2p_wow_exit;
  185. };
  186. struct ath11k_hw_ops {
  187. u8 (*get_hw_mac_from_pdev_id)(int pdev_id);
  188. void (*wmi_init_config)(struct ath11k_base *ab,
  189. struct target_resource_config *config);
  190. int (*mac_id_to_pdev_id)(struct ath11k_hw_params *hw, int mac_id);
  191. int (*mac_id_to_srng_id)(struct ath11k_hw_params *hw, int mac_id);
  192. void (*tx_mesh_enable)(struct ath11k_base *ab,
  193. struct hal_tcl_data_cmd *tcl_cmd);
  194. bool (*rx_desc_get_first_msdu)(struct hal_rx_desc *desc);
  195. bool (*rx_desc_get_last_msdu)(struct hal_rx_desc *desc);
  196. u8 (*rx_desc_get_l3_pad_bytes)(struct hal_rx_desc *desc);
  197. u8 *(*rx_desc_get_hdr_status)(struct hal_rx_desc *desc);
  198. bool (*rx_desc_encrypt_valid)(struct hal_rx_desc *desc);
  199. u32 (*rx_desc_get_encrypt_type)(struct hal_rx_desc *desc);
  200. u8 (*rx_desc_get_decap_type)(struct hal_rx_desc *desc);
  201. u8 (*rx_desc_get_mesh_ctl)(struct hal_rx_desc *desc);
  202. bool (*rx_desc_get_ldpc_support)(struct hal_rx_desc *desc);
  203. bool (*rx_desc_get_mpdu_seq_ctl_vld)(struct hal_rx_desc *desc);
  204. bool (*rx_desc_get_mpdu_fc_valid)(struct hal_rx_desc *desc);
  205. u16 (*rx_desc_get_mpdu_start_seq_no)(struct hal_rx_desc *desc);
  206. u16 (*rx_desc_get_msdu_len)(struct hal_rx_desc *desc);
  207. u8 (*rx_desc_get_msdu_sgi)(struct hal_rx_desc *desc);
  208. u8 (*rx_desc_get_msdu_rate_mcs)(struct hal_rx_desc *desc);
  209. u8 (*rx_desc_get_msdu_rx_bw)(struct hal_rx_desc *desc);
  210. u32 (*rx_desc_get_msdu_freq)(struct hal_rx_desc *desc);
  211. u8 (*rx_desc_get_msdu_pkt_type)(struct hal_rx_desc *desc);
  212. u8 (*rx_desc_get_msdu_nss)(struct hal_rx_desc *desc);
  213. u8 (*rx_desc_get_mpdu_tid)(struct hal_rx_desc *desc);
  214. u16 (*rx_desc_get_mpdu_peer_id)(struct hal_rx_desc *desc);
  215. void (*rx_desc_copy_attn_end_tlv)(struct hal_rx_desc *fdesc,
  216. struct hal_rx_desc *ldesc);
  217. u32 (*rx_desc_get_mpdu_start_tag)(struct hal_rx_desc *desc);
  218. u32 (*rx_desc_get_mpdu_ppdu_id)(struct hal_rx_desc *desc);
  219. void (*rx_desc_set_msdu_len)(struct hal_rx_desc *desc, u16 len);
  220. struct rx_attention *(*rx_desc_get_attention)(struct hal_rx_desc *desc);
  221. u8 *(*rx_desc_get_msdu_payload)(struct hal_rx_desc *desc);
  222. void (*reo_setup)(struct ath11k_base *ab);
  223. u16 (*mpdu_info_get_peerid)(u8 *tlv_data);
  224. bool (*rx_desc_mac_addr2_valid)(struct hal_rx_desc *desc);
  225. u8* (*rx_desc_mpdu_start_addr2)(struct hal_rx_desc *desc);
  226. u32 (*get_ring_selector)(struct sk_buff *skb);
  227. };
  228. extern const struct ath11k_hw_ops ipq8074_ops;
  229. extern const struct ath11k_hw_ops ipq6018_ops;
  230. extern const struct ath11k_hw_ops qca6390_ops;
  231. extern const struct ath11k_hw_ops qcn9074_ops;
  232. extern const struct ath11k_hw_ops wcn6855_ops;
  233. extern const struct ath11k_hw_ops wcn6750_ops;
  234. extern const struct ath11k_hw_ring_mask ath11k_hw_ring_mask_ipq8074;
  235. extern const struct ath11k_hw_ring_mask ath11k_hw_ring_mask_qca6390;
  236. extern const struct ath11k_hw_ring_mask ath11k_hw_ring_mask_qcn9074;
  237. extern const struct ath11k_hw_ring_mask ath11k_hw_ring_mask_wcn6750;
  238. extern const struct ath11k_hw_hal_params ath11k_hw_hal_params_ipq8074;
  239. extern const struct ath11k_hw_hal_params ath11k_hw_hal_params_qca6390;
  240. extern const struct ath11k_hw_hal_params ath11k_hw_hal_params_wcn6750;
  241. static inline
  242. int ath11k_hw_get_mac_from_pdev_id(struct ath11k_hw_params *hw,
  243. int pdev_idx)
  244. {
  245. if (hw->hw_ops->get_hw_mac_from_pdev_id)
  246. return hw->hw_ops->get_hw_mac_from_pdev_id(pdev_idx);
  247. return 0;
  248. }
  249. static inline int ath11k_hw_mac_id_to_pdev_id(struct ath11k_hw_params *hw,
  250. int mac_id)
  251. {
  252. if (hw->hw_ops->mac_id_to_pdev_id)
  253. return hw->hw_ops->mac_id_to_pdev_id(hw, mac_id);
  254. return 0;
  255. }
  256. static inline int ath11k_hw_mac_id_to_srng_id(struct ath11k_hw_params *hw,
  257. int mac_id)
  258. {
  259. if (hw->hw_ops->mac_id_to_srng_id)
  260. return hw->hw_ops->mac_id_to_srng_id(hw, mac_id);
  261. return 0;
  262. }
  263. struct ath11k_fw_ie {
  264. __le32 id;
  265. __le32 len;
  266. u8 data[];
  267. };
  268. enum ath11k_bd_ie_board_type {
  269. ATH11K_BD_IE_BOARD_NAME = 0,
  270. ATH11K_BD_IE_BOARD_DATA = 1,
  271. };
  272. enum ath11k_bd_ie_regdb_type {
  273. ATH11K_BD_IE_REGDB_NAME = 0,
  274. ATH11K_BD_IE_REGDB_DATA = 1,
  275. };
  276. enum ath11k_bd_ie_type {
  277. /* contains sub IEs of enum ath11k_bd_ie_board_type */
  278. ATH11K_BD_IE_BOARD = 0,
  279. /* contains sub IEs of enum ath11k_bd_ie_regdb_type */
  280. ATH11K_BD_IE_REGDB = 1,
  281. };
  282. struct ath11k_hw_regs {
  283. u32 hal_tcl1_ring_base_lsb;
  284. u32 hal_tcl1_ring_base_msb;
  285. u32 hal_tcl1_ring_id;
  286. u32 hal_tcl1_ring_misc;
  287. u32 hal_tcl1_ring_tp_addr_lsb;
  288. u32 hal_tcl1_ring_tp_addr_msb;
  289. u32 hal_tcl1_ring_consumer_int_setup_ix0;
  290. u32 hal_tcl1_ring_consumer_int_setup_ix1;
  291. u32 hal_tcl1_ring_msi1_base_lsb;
  292. u32 hal_tcl1_ring_msi1_base_msb;
  293. u32 hal_tcl1_ring_msi1_data;
  294. u32 hal_tcl2_ring_base_lsb;
  295. u32 hal_tcl_ring_base_lsb;
  296. u32 hal_tcl_status_ring_base_lsb;
  297. u32 hal_reo1_ring_base_lsb;
  298. u32 hal_reo1_ring_base_msb;
  299. u32 hal_reo1_ring_id;
  300. u32 hal_reo1_ring_misc;
  301. u32 hal_reo1_ring_hp_addr_lsb;
  302. u32 hal_reo1_ring_hp_addr_msb;
  303. u32 hal_reo1_ring_producer_int_setup;
  304. u32 hal_reo1_ring_msi1_base_lsb;
  305. u32 hal_reo1_ring_msi1_base_msb;
  306. u32 hal_reo1_ring_msi1_data;
  307. u32 hal_reo2_ring_base_lsb;
  308. u32 hal_reo1_aging_thresh_ix_0;
  309. u32 hal_reo1_aging_thresh_ix_1;
  310. u32 hal_reo1_aging_thresh_ix_2;
  311. u32 hal_reo1_aging_thresh_ix_3;
  312. u32 hal_reo1_ring_hp;
  313. u32 hal_reo1_ring_tp;
  314. u32 hal_reo2_ring_hp;
  315. u32 hal_reo_tcl_ring_base_lsb;
  316. u32 hal_reo_tcl_ring_hp;
  317. u32 hal_reo_status_ring_base_lsb;
  318. u32 hal_reo_status_hp;
  319. u32 hal_reo_cmd_ring_base_lsb;
  320. u32 hal_reo_cmd_ring_hp;
  321. u32 hal_sw2reo_ring_base_lsb;
  322. u32 hal_sw2reo_ring_hp;
  323. u32 hal_seq_wcss_umac_ce0_src_reg;
  324. u32 hal_seq_wcss_umac_ce0_dst_reg;
  325. u32 hal_seq_wcss_umac_ce1_src_reg;
  326. u32 hal_seq_wcss_umac_ce1_dst_reg;
  327. u32 hal_wbm_idle_link_ring_base_lsb;
  328. u32 hal_wbm_idle_link_ring_misc;
  329. u32 hal_wbm_release_ring_base_lsb;
  330. u32 hal_wbm0_release_ring_base_lsb;
  331. u32 hal_wbm1_release_ring_base_lsb;
  332. u32 pcie_qserdes_sysclk_en_sel;
  333. u32 pcie_pcs_osc_dtct_config_base;
  334. u32 hal_shadow_base_addr;
  335. u32 hal_reo1_misc_ctl;
  336. };
  337. extern const struct ath11k_hw_regs ipq8074_regs;
  338. extern const struct ath11k_hw_regs qca6390_regs;
  339. extern const struct ath11k_hw_regs qcn9074_regs;
  340. extern const struct ath11k_hw_regs wcn6855_regs;
  341. extern const struct ath11k_hw_regs wcn6750_regs;
  342. static inline const char *ath11k_bd_ie_type_str(enum ath11k_bd_ie_type type)
  343. {
  344. switch (type) {
  345. case ATH11K_BD_IE_BOARD:
  346. return "board data";
  347. case ATH11K_BD_IE_REGDB:
  348. return "regdb data";
  349. }
  350. return "unknown";
  351. }
  352. extern const struct cfg80211_sar_capa ath11k_hw_sar_capa_wcn6855;
  353. #endif