xref: /openbsd-src/sys/dev/ic/qwzvar.h (revision 32e6bca906ecb0ab11bf4d807853c616386772f6)
1*32e6bca9Spatrick /*	$OpenBSD: qwzvar.h,v 1.11 2024/12/22 23:30:27 patrick Exp $	*/
24bba8532Spatrick 
34bba8532Spatrick /*
44bba8532Spatrick  * Copyright (c) 2018-2019 The Linux Foundation.
54bba8532Spatrick  * All rights reserved.
64bba8532Spatrick  *
74bba8532Spatrick  * Redistribution and use in source and binary forms, with or without
84bba8532Spatrick  * modification, are permitted (subject to the limitations in the disclaimer
94bba8532Spatrick  * below) provided that the following conditions are met:
104bba8532Spatrick  *
114bba8532Spatrick  *  * Redistributions of source code must retain the above copyright notice,
124bba8532Spatrick  *    this list of conditions and the following disclaimer.
134bba8532Spatrick  *
144bba8532Spatrick  *  * Redistributions in binary form must reproduce the above copyright
154bba8532Spatrick  *    notice, this list of conditions and the following disclaimer in the
164bba8532Spatrick  *    documentation and/or other materials provided with the distribution.
174bba8532Spatrick  *
184bba8532Spatrick  *  * Neither the name of [Owner Organization] nor the names of its
194bba8532Spatrick  *    contributors may be used to endorse or promote products derived from
204bba8532Spatrick  *    this software without specific prior written permission.
214bba8532Spatrick  *
224bba8532Spatrick  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
234bba8532Spatrick  * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
244bba8532Spatrick  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
254bba8532Spatrick  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
264bba8532Spatrick  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
274bba8532Spatrick  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
284bba8532Spatrick  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
294bba8532Spatrick  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
304bba8532Spatrick  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
314bba8532Spatrick  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
324bba8532Spatrick  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
334bba8532Spatrick  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
344bba8532Spatrick  */
354bba8532Spatrick 
364bba8532Spatrick #ifdef QWZ_DEBUG
374bba8532Spatrick #define DPRINTF(x...)		do { if (qwz_debug) printf(x); } while(0)
384bba8532Spatrick #define DNPRINTF(n,x...)	do { if (qwz_debug & n) printf(x); } while(0)
394bba8532Spatrick #define	QWZ_D_MISC		0x00000001
404bba8532Spatrick #define	QWZ_D_MHI		0x00000002
414bba8532Spatrick #define	QWZ_D_QMI		0x00000004
424bba8532Spatrick #define	QWZ_D_WMI		0x00000008
434bba8532Spatrick #define	QWZ_D_HTC		0x00000010
444bba8532Spatrick #define	QWZ_D_HTT		0x00000020
454bba8532Spatrick #define	QWZ_D_MAC		0x00000040
464bba8532Spatrick #define	QWZ_D_MGMT		0x00000080
474bba8532Spatrick #define	QWZ_D_CE		0x00000100
484bba8532Spatrick extern uint32_t	qwz_debug;
494bba8532Spatrick #else
504bba8532Spatrick #define DPRINTF(x...)
514bba8532Spatrick #define DNPRINTF(n,x...)
524bba8532Spatrick #endif
534bba8532Spatrick 
544bba8532Spatrick struct qwz_softc;
554bba8532Spatrick 
564bba8532Spatrick #define ATH12K_EXT_IRQ_GRP_NUM_MAX 11
574bba8532Spatrick 
584bba8532Spatrick struct ath12k_hw_ring_mask {
594bba8532Spatrick 	uint8_t tx[ATH12K_EXT_IRQ_GRP_NUM_MAX];
60c12edff5Spatrick 	uint8_t rx_mon_dest[ATH12K_EXT_IRQ_GRP_NUM_MAX];
614bba8532Spatrick 	uint8_t rx[ATH12K_EXT_IRQ_GRP_NUM_MAX];
624bba8532Spatrick 	uint8_t rx_err[ATH12K_EXT_IRQ_GRP_NUM_MAX];
634bba8532Spatrick 	uint8_t rx_wbm_rel[ATH12K_EXT_IRQ_GRP_NUM_MAX];
644bba8532Spatrick 	uint8_t reo_status[ATH12K_EXT_IRQ_GRP_NUM_MAX];
654bba8532Spatrick 	uint8_t host2rxdma[ATH12K_EXT_IRQ_GRP_NUM_MAX];
6627c3d914Spatrick 	uint8_t tx_mon_dest[ATH12K_EXT_IRQ_GRP_NUM_MAX];
674bba8532Spatrick };
684bba8532Spatrick 
694bba8532Spatrick #define ATH12K_FW_DIR			"qwz"
704bba8532Spatrick 
714bba8532Spatrick #define ATH12K_BOARD_MAGIC		"QCA-ATH12K-BOARD"
724bba8532Spatrick #define ATH12K_BOARD_API2_FILE		"board-2"
734bba8532Spatrick #define ATH12K_DEFAULT_BOARD_FILE	"board"
744bba8532Spatrick #define ATH12K_DEFAULT_CAL_FILE		"caldata"
754bba8532Spatrick #define ATH12K_AMSS_FILE		"amss"
764bba8532Spatrick #define ATH12K_M3_FILE			"m3"
774bba8532Spatrick 
784bba8532Spatrick #define QWZ_FW_BUILD_ID_MASK "QC_IMAGE_VERSION_STRING="
794bba8532Spatrick 
801b22ca7fSpatrick struct ath12k_hal_tcl_to_wbm_rbm_map {
814bba8532Spatrick 	uint8_t wbm_ring_num;
824bba8532Spatrick 	uint8_t rbm_id;
834bba8532Spatrick };
844bba8532Spatrick 
854bba8532Spatrick /**
864bba8532Spatrick  * enum hal_rx_buf_return_buf_manager
874bba8532Spatrick  *
884bba8532Spatrick  * @HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST: Buffer returned to WBM idle buffer list
8927c3d914Spatrick  * @HAL_RX_BUF_RBM_WBM_CHIP0_IDLE_DESC_LIST: Descriptor returned to WBM idle
9027c3d914Spatrick  * 	descriptor list, where the chip 0 WBM is chosen in case of a
9127c3d914Spatrick  *  	multi-chip config
924bba8532Spatrick  * @HAL_RX_BUF_RBM_FW_BM: Buffer returned to FW
934bba8532Spatrick  * @HAL_RX_BUF_RBM_SW0_BM: For Tx completion -- returned to host
944bba8532Spatrick  * @HAL_RX_BUF_RBM_SW1_BM: For Tx completion -- returned to host
954bba8532Spatrick  * @HAL_RX_BUF_RBM_SW2_BM: For Tx completion -- returned to host
964bba8532Spatrick  * @HAL_RX_BUF_RBM_SW3_BM: For Rx release -- returned to host
9727c3d914Spatrick  * @HAL_RX_BUF_RBM_SW4_BM: For Tx completion -- returned to host
9827c3d914Spatrick  * @HAL_RX_BUF_RBM_SW5_BM: For ring 5 -- returned to host
9927c3d914Spatrick  * @HAL_RX_BUF_RBM_SW6_BM: For ring 6 -- returned to host
1004bba8532Spatrick  */
1014bba8532Spatrick 
1024bba8532Spatrick enum hal_rx_buf_return_buf_manager {
1034bba8532Spatrick 	HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST,
10409a673e5Spatrick 	HAL_RX_BUF_RBM_WBM_DEV0_IDLE_DESC_LIST,
10509a673e5Spatrick 	HAL_RX_BUF_RBM_WBM_DEV1_IDLE_DESC_LIST,
10609a673e5Spatrick 	HAL_RX_BUF_RBM_WBM_DEV2_IDLE_DESC_LIST,
1074bba8532Spatrick 	HAL_RX_BUF_RBM_FW_BM,
1084bba8532Spatrick 	HAL_RX_BUF_RBM_SW0_BM,
1094bba8532Spatrick 	HAL_RX_BUF_RBM_SW1_BM,
1104bba8532Spatrick 	HAL_RX_BUF_RBM_SW2_BM,
1114bba8532Spatrick 	HAL_RX_BUF_RBM_SW3_BM,
1124bba8532Spatrick 	HAL_RX_BUF_RBM_SW4_BM,
11327c3d914Spatrick 	HAL_RX_BUF_RBM_SW5_BM,
11427c3d914Spatrick 	HAL_RX_BUF_RBM_SW6_BM,
1154bba8532Spatrick };
1164bba8532Spatrick 
1174bba8532Spatrick struct ath12k_hw_hal_params {
1184bba8532Spatrick 	enum hal_rx_buf_return_buf_manager rx_buf_rbm;
1194bba8532Spatrick 	const struct ath12k_hw_tcl2wbm_rbm_map *tcl2wbm_rbm_map;
12027c3d914Spatrick 	uint32_t wbm2sw_cc_enable;
1214bba8532Spatrick };
1224bba8532Spatrick 
1234bba8532Spatrick struct hal_tx_info {
1244bba8532Spatrick 	uint16_t meta_data_flags; /* %HAL_TCL_DATA_CMD_INFO0_META_ */
1254bba8532Spatrick 	uint8_t ring_id;
1264bba8532Spatrick 	uint32_t desc_id;
1274bba8532Spatrick 	enum hal_tcl_desc_type type;
1284bba8532Spatrick 	enum hal_tcl_encap_type encap_type;
1294bba8532Spatrick 	uint64_t paddr;
1304bba8532Spatrick 	uint32_t data_len;
1314bba8532Spatrick 	uint32_t pkt_offset;
1324bba8532Spatrick 	enum hal_encrypt_type encrypt_type;
1334bba8532Spatrick 	uint32_t flags0; /* %HAL_TCL_DATA_CMD_INFO1_ */
1344bba8532Spatrick 	uint32_t flags1; /* %HAL_TCL_DATA_CMD_INFO2_ */
1354bba8532Spatrick 	uint16_t addr_search_flags; /* %HAL_TCL_DATA_CMD_INFO0_ADDR(X/Y)_ */
1364bba8532Spatrick 	uint16_t bss_ast_hash;
1374bba8532Spatrick 	uint16_t bss_ast_idx;
1384bba8532Spatrick 	uint8_t tid;
1394bba8532Spatrick 	uint8_t search_type; /* %HAL_TX_ADDR_SEARCH_ */
1404bba8532Spatrick 	uint8_t lmac_id;
1414bba8532Spatrick 	uint8_t dscp_tid_tbl_idx;
1424bba8532Spatrick 	bool enable_mesh;
1434bba8532Spatrick 	uint8_t rbm_id;
1444bba8532Spatrick };
1454bba8532Spatrick 
1464bba8532Spatrick /* TODO: Check if the actual desc macros can be used instead */
1474bba8532Spatrick #define HAL_TX_STATUS_FLAGS_FIRST_MSDU		BIT(0)
1484bba8532Spatrick #define HAL_TX_STATUS_FLAGS_LAST_MSDU		BIT(1)
1494bba8532Spatrick #define HAL_TX_STATUS_FLAGS_MSDU_IN_AMSDU	BIT(2)
1504bba8532Spatrick #define HAL_TX_STATUS_FLAGS_RATE_STATS_VALID	BIT(3)
1514bba8532Spatrick #define HAL_TX_STATUS_FLAGS_RATE_LDPC		BIT(4)
1524bba8532Spatrick #define HAL_TX_STATUS_FLAGS_RATE_STBC		BIT(5)
1534bba8532Spatrick #define HAL_TX_STATUS_FLAGS_OFDMA		BIT(6)
1544bba8532Spatrick 
1554bba8532Spatrick #define HAL_TX_STATUS_DESC_LEN		sizeof(struct hal_wbm_release_ring)
1564bba8532Spatrick 
1574bba8532Spatrick /* Tx status parsed from srng desc */
1584bba8532Spatrick struct hal_tx_status {
1594bba8532Spatrick 	enum hal_wbm_rel_src_module buf_rel_source;
1604bba8532Spatrick 	enum hal_wbm_tqm_rel_reason status;
1614bba8532Spatrick 	uint8_t ack_rssi;
1624bba8532Spatrick 	uint32_t flags; /* %HAL_TX_STATUS_FLAGS_ */
1634bba8532Spatrick 	uint32_t ppdu_id;
1644bba8532Spatrick 	uint8_t try_cnt;
1654bba8532Spatrick 	uint8_t tid;
1664bba8532Spatrick 	uint16_t peer_id;
1674bba8532Spatrick 	uint32_t rate_stats;
1684bba8532Spatrick };
1694bba8532Spatrick 
1701b22ca7fSpatrick struct hal_ops {
1711b22ca7fSpatrick 	int (*create_srng_config)(struct qwz_softc *);
172eb49c7f0Spatrick 	uint16_t (*rxdma_ring_wmask_rx_mpdu_start)(void);
173eb49c7f0Spatrick 	uint32_t (*rxdma_ring_wmask_rx_msdu_end)(void);
174eb49c7f0Spatrick 	const struct hal_rx_ops *(*get_hal_rx_compact_ops)(void);
1751b22ca7fSpatrick 	const struct ath12k_hal_tcl_to_wbm_rbm_map *tcl_to_wbm_rbm_map;
1761b22ca7fSpatrick };
1771b22ca7fSpatrick 
1784bba8532Spatrick struct ath12k_hw_params {
1794bba8532Spatrick 	const char *name;
1804bba8532Spatrick 	uint16_t hw_rev;
1814bba8532Spatrick 	uint8_t max_radios;
1824bba8532Spatrick 	uint32_t bdf_addr;
1834bba8532Spatrick 
1844bba8532Spatrick 	struct {
1854bba8532Spatrick 		const char *dir;
1864bba8532Spatrick 		size_t board_size;
1874bba8532Spatrick 		size_t cal_offset;
1884bba8532Spatrick 	} fw;
1894bba8532Spatrick 
1904bba8532Spatrick 	const struct ath12k_hw_ops *hw_ops;
1914bba8532Spatrick 	const struct ath12k_hw_ring_mask *ring_mask;
1924bba8532Spatrick 
1934bba8532Spatrick 	bool internal_sleep_clock;
1944bba8532Spatrick 
1954bba8532Spatrick 	const struct ath12k_hw_regs *regs;
1964bba8532Spatrick 	uint32_t qmi_service_ins_id;
1974bba8532Spatrick 	const struct ce_attr *host_ce_config;
1984bba8532Spatrick 	uint32_t ce_count;
1994bba8532Spatrick 	const struct ce_pipe_config *target_ce_config;
2004bba8532Spatrick 	uint32_t target_ce_count;
2014bba8532Spatrick 	const struct service_to_pipe *svc_to_ce_map;
2024bba8532Spatrick 	uint32_t svc_to_ce_map_len;
2034bba8532Spatrick 
2044bba8532Spatrick 	bool single_pdev_only;
2054bba8532Spatrick 
2064bba8532Spatrick 	bool rxdma1_enable;
2074bba8532Spatrick 	int num_rxmda_per_pdev;
20827c3d914Spatrick 	int num_rxdma_dst_ring;
2094bba8532Spatrick 	bool rx_mac_buf_ring;
2104bba8532Spatrick 	bool vdev_start_delay;
2114bba8532Spatrick 	bool htt_peer_map_v2;
2124bba8532Spatrick #if notyet
2134bba8532Spatrick 	struct {
2144bba8532Spatrick 		uint8_t fft_sz;
2154bba8532Spatrick 		uint8_t fft_pad_sz;
2164bba8532Spatrick 		uint8_t summary_pad_sz;
2174bba8532Spatrick 		uint8_t fft_hdr_len;
2184bba8532Spatrick 		uint16_t max_fft_bins;
2194bba8532Spatrick 		bool fragment_160mhz;
2204bba8532Spatrick 	} spectral;
2214bba8532Spatrick 
2224bba8532Spatrick 	uint16_t interface_modes;
2234bba8532Spatrick 	bool supports_monitor;
2244bba8532Spatrick 	bool full_monitor_mode;
2254bba8532Spatrick #endif
226eb49c7f0Spatrick 	bool reoq_lut_support;
2274bba8532Spatrick 	bool supports_shadow_regs;
2284bba8532Spatrick 	bool idle_ps;
2294bba8532Spatrick 	bool supports_sta_ps;
2304bba8532Spatrick 	bool supports_suspend;
2314bba8532Spatrick 	uint32_t hal_desc_sz;
2324bba8532Spatrick 	bool fix_l1ss;
233eb49c7f0Spatrick 	uint32_t num_tcl_banks;
234eb49c7f0Spatrick 	uint32_t max_tx_ring;
2354bba8532Spatrick 	const struct ath12k_hw_hal_params *hal_params;
236eb49c7f0Spatrick 	void (*wmi_init)(struct qwz_softc *sc,
237eb49c7f0Spatrick 	    struct wmi_resource_config_arg *config);
2381b22ca7fSpatrick 	const struct hal_ops *hal_ops;
23927c3d914Spatrick 	uint64_t qmi_cnss_feature_bitmap;
2404bba8532Spatrick #if notyet
2414bba8532Spatrick 	bool supports_dynamic_smps_6ghz;
2424bba8532Spatrick 	bool alloc_cacheable_memory;
2434bba8532Spatrick 	bool supports_rssi_stats;
2444bba8532Spatrick #endif
2454bba8532Spatrick 	bool current_cc_support;
2464bba8532Spatrick 	bool dbr_debug_support;
2474bba8532Spatrick #ifdef notyet
2484bba8532Spatrick 	const struct cfg80211_sar_capa *bios_sar_capa;
2494bba8532Spatrick 	bool support_off_channel_tx;
2504bba8532Spatrick 	bool supports_multi_bssid;
2514bba8532Spatrick 
2524bba8532Spatrick 	struct {
2534bba8532Spatrick 		uint32_t start;
2544bba8532Spatrick 		uint32_t end;
2554bba8532Spatrick 	} sram_dump;
2564bba8532Spatrick 
2574bba8532Spatrick 	bool tcl_ring_retry;
2584bba8532Spatrick #endif
2594bba8532Spatrick 	uint32_t tx_ring_size;
2604bba8532Spatrick 	bool smp2p_wow_exit;
2614bba8532Spatrick };
2624bba8532Spatrick 
2634bba8532Spatrick struct ath12k_hw_ops {
2644bba8532Spatrick 	uint8_t (*get_hw_mac_from_pdev_id)(int pdev_id);
2654bba8532Spatrick 	int (*mac_id_to_pdev_id)(struct ath12k_hw_params *hw, int mac_id);
2664bba8532Spatrick 	int (*mac_id_to_srng_id)(struct ath12k_hw_params *hw, int mac_id);
267eb49c7f0Spatrick 	bool (*dp_srng_is_tx_comp_ring)(int ring_num);
268eb49c7f0Spatrick };
269eb49c7f0Spatrick 
270eb49c7f0Spatrick struct hal_rx_ops {
2714bba8532Spatrick 	int (*rx_desc_get_first_msdu)(struct hal_rx_desc *desc);
2724bba8532Spatrick #if notyet
2734bba8532Spatrick 	bool (*rx_desc_get_last_msdu)(struct hal_rx_desc *desc);
2744bba8532Spatrick #endif
2754bba8532Spatrick 	uint8_t (*rx_desc_get_l3_pad_bytes)(struct hal_rx_desc *desc);
2764bba8532Spatrick 	uint8_t *(*rx_desc_get_hdr_status)(struct hal_rx_desc *desc);
2774bba8532Spatrick 	int (*rx_desc_encrypt_valid)(struct hal_rx_desc *desc);
2784bba8532Spatrick 	uint32_t (*rx_desc_get_encrypt_type)(struct hal_rx_desc *desc);
2794bba8532Spatrick 	uint8_t (*rx_desc_get_decap_type)(struct hal_rx_desc *desc);
2804bba8532Spatrick #ifdef notyet
2814bba8532Spatrick 	uint8_t (*rx_desc_get_mesh_ctl)(struct hal_rx_desc *desc);
2824bba8532Spatrick 	bool (*rx_desc_get_mpdu_seq_ctl_vld)(struct hal_rx_desc *desc);
2834bba8532Spatrick 	bool (*rx_desc_get_mpdu_fc_valid)(struct hal_rx_desc *desc);
2844bba8532Spatrick 	uint16_t (*rx_desc_get_mpdu_start_seq_no)(struct hal_rx_desc *desc);
2854bba8532Spatrick #endif
2864bba8532Spatrick 	uint16_t (*rx_desc_get_msdu_len)(struct hal_rx_desc *desc);
2874bba8532Spatrick #ifdef notyet
2884bba8532Spatrick 	uint8_t (*rx_desc_get_msdu_sgi)(struct hal_rx_desc *desc);
2894bba8532Spatrick 	uint8_t (*rx_desc_get_msdu_rate_mcs)(struct hal_rx_desc *desc);
2904bba8532Spatrick 	uint8_t (*rx_desc_get_msdu_rx_bw)(struct hal_rx_desc *desc);
2914bba8532Spatrick #endif
2924bba8532Spatrick 	uint32_t (*rx_desc_get_msdu_freq)(struct hal_rx_desc *desc);
2934bba8532Spatrick 	uint8_t (*rx_desc_get_msdu_pkt_type)(struct hal_rx_desc *desc);
2944bba8532Spatrick 	uint8_t (*rx_desc_get_msdu_nss)(struct hal_rx_desc *desc);
2954bba8532Spatrick 	uint8_t (*rx_desc_get_mpdu_tid)(struct hal_rx_desc *desc);
2964bba8532Spatrick 	uint16_t (*rx_desc_get_mpdu_peer_id)(struct hal_rx_desc *desc);
2976040dc01Spatrick 	void (*rx_desc_copy_end_tlv)(struct hal_rx_desc *fdesc,
2984bba8532Spatrick 				     struct hal_rx_desc *ldesc);
2994bba8532Spatrick 	uint32_t (*rx_desc_get_mpdu_start_tag)(struct hal_rx_desc *desc);
3004bba8532Spatrick 	uint32_t (*rx_desc_get_mpdu_ppdu_id)(struct hal_rx_desc *desc);
3014bba8532Spatrick 	void (*rx_desc_set_msdu_len)(struct hal_rx_desc *desc, uint16_t len);
3024bba8532Spatrick #ifdef notyet
3034bba8532Spatrick 	uint8_t *(*rx_desc_get_msdu_payload)(struct hal_rx_desc *desc);
3046040dc01Spatrick 	uint32_t (*rx_desc_get_mpdu_start_offset)(void);
3056040dc01Spatrick 	uint32_t (*rx_desc_get_msdu_end_offset)(void);
3064bba8532Spatrick 	bool (*rx_desc_mac_addr2_valid)(struct hal_rx_desc *desc);
3074bba8532Spatrick 	uint8_t* (*rx_desc_mpdu_start_addr2)(struct hal_rx_desc *desc);
3084bba8532Spatrick #endif
3096040dc01Spatrick 	int (*rx_desc_is_da_mcbc)(struct hal_rx_desc *desc);
3106040dc01Spatrick #ifdef notyet
3116040dc01Spatrick 	void (*rx_desc_get_dot11_hdr)(struct hal_rx_desc *desc,
3126040dc01Spatrick 				      struct ieee80211_hdr *hdr);
3136040dc01Spatrick 	uint16_t (*rx_desc_get_mpdu_frame_ctl)(struct hal_rx_desc *desc);
3146040dc01Spatrick 	void (*rx_desc_get_crypto_header)(struct hal_rx_desc *desc,
3156040dc01Spatrick 					  uint8_t *crypto_hdr,
3166040dc01Spatrick 					  enum hal_encrypt_type enctype);
3176040dc01Spatrick #endif
3186040dc01Spatrick 	bool (*dp_rx_h_msdu_done)(struct hal_rx_desc *desc);
3196040dc01Spatrick #ifdef notyet
3206040dc01Spatrick 	bool (*dp_rx_h_l4_cksum_fail)(struct hal_rx_desc *desc);
3216040dc01Spatrick 	bool (*dp_rx_h_ip_cksum_fail)(struct hal_rx_desc *desc);
3226040dc01Spatrick #endif
3236040dc01Spatrick 	int (*dp_rx_h_is_decrypted)(struct hal_rx_desc *desc);
3246040dc01Spatrick 	uint32_t (*dp_rx_h_mpdu_err)(struct hal_rx_desc *desc);
325eb49c7f0Spatrick 	uint32_t (*rx_desc_get_desc_size)(void);
3266040dc01Spatrick #ifdef notyet
3276040dc01Spatrick 	uint8_t (*rx_desc_get_msdu_src_link_id)(struct hal_rx_desc *desc);
3286040dc01Spatrick #endif
3294bba8532Spatrick };
3304bba8532Spatrick 
331eb49c7f0Spatrick extern const struct hal_rx_ops hal_rx_wcn7850_ops;
332eb49c7f0Spatrick 
33327c3d914Spatrick extern const struct ath12k_hw_ring_mask ath12k_hw_ring_mask_wcn7850;
3344bba8532Spatrick 
3354bba8532Spatrick struct ath12k_hw_regs {
3364bba8532Spatrick 	uint32_t hal_tcl1_ring_id;
3374bba8532Spatrick 	uint32_t hal_tcl1_ring_misc;
3384bba8532Spatrick 	uint32_t hal_tcl1_ring_tp_addr_lsb;
3394bba8532Spatrick 	uint32_t hal_tcl1_ring_tp_addr_msb;
3404bba8532Spatrick 	uint32_t hal_tcl1_ring_consumer_int_setup_ix0;
3414bba8532Spatrick 	uint32_t hal_tcl1_ring_consumer_int_setup_ix1;
3424bba8532Spatrick 	uint32_t hal_tcl1_ring_msi1_base_lsb;
3434bba8532Spatrick 	uint32_t hal_tcl1_ring_msi1_base_msb;
3444bba8532Spatrick 	uint32_t hal_tcl1_ring_msi1_data;
3454bba8532Spatrick 	uint32_t hal_tcl_ring_base_lsb;
3464bba8532Spatrick 
3474bba8532Spatrick 	uint32_t hal_tcl_status_ring_base_lsb;
3484bba8532Spatrick 
349b8a42cceSpatrick 	uint32_t hal_wbm_idle_ring_base_lsb;
350b8a42cceSpatrick 	uint32_t hal_wbm_idle_ring_misc_addr;
35127c3d914Spatrick 	uint32_t hal_wbm_r0_idle_list_cntl_addr;
35227c3d914Spatrick 	uint32_t hal_wbm_r0_idle_list_size_addr;
35327c3d914Spatrick 	uint32_t hal_wbm_scattered_ring_base_lsb;
35427c3d914Spatrick 	uint32_t hal_wbm_scattered_ring_base_msb;
35527c3d914Spatrick 	uint32_t hal_wbm_scattered_desc_head_info_ix0;
35627c3d914Spatrick 	uint32_t hal_wbm_scattered_desc_head_info_ix1;
35727c3d914Spatrick 	uint32_t hal_wbm_scattered_desc_tail_info_ix0;
35827c3d914Spatrick 	uint32_t hal_wbm_scattered_desc_tail_info_ix1;
35927c3d914Spatrick 	uint32_t hal_wbm_scattered_desc_ptr_hp_addr;
3604bba8532Spatrick 
361b8a42cceSpatrick 	uint32_t hal_wbm_sw_release_ring_base_lsb;
36227c3d914Spatrick 	uint32_t hal_wbm_sw1_release_ring_base_lsb;
3634bba8532Spatrick 	uint32_t hal_wbm0_release_ring_base_lsb;
3644bba8532Spatrick 	uint32_t hal_wbm1_release_ring_base_lsb;
3654bba8532Spatrick 
3664bba8532Spatrick 	uint32_t pcie_qserdes_sysclk_en_sel;
3674bba8532Spatrick 	uint32_t pcie_pcs_osc_dtct_config_base;
3684bba8532Spatrick 
36927c3d914Spatrick 	uint32_t hal_ppe_rel_ring_base;
37027c3d914Spatrick 
371b8a42cceSpatrick 	uint32_t hal_reo2_ring_base;
372b8a42cceSpatrick 	uint32_t hal_reo1_misc_ctrl_addr;
37327c3d914Spatrick 	uint32_t hal_reo1_sw_cookie_cfg0;
37427c3d914Spatrick 	uint32_t hal_reo1_sw_cookie_cfg1;
37527c3d914Spatrick 	uint32_t hal_reo1_qdesc_lut_base0;
37627c3d914Spatrick 	uint32_t hal_reo1_qdesc_lut_base1;
377b8a42cceSpatrick 	uint32_t hal_reo1_ring_base_lsb;
378b8a42cceSpatrick 	uint32_t hal_reo1_ring_base_msb;
379b8a42cceSpatrick 	uint32_t hal_reo1_ring_id;
380b8a42cceSpatrick 	uint32_t hal_reo1_ring_misc;
381b8a42cceSpatrick 	uint32_t hal_reo1_ring_hp_addr_lsb;
382b8a42cceSpatrick 	uint32_t hal_reo1_ring_hp_addr_msb;
383b8a42cceSpatrick 	uint32_t hal_reo1_ring_producer_int_setup;
384b8a42cceSpatrick 	uint32_t hal_reo1_ring_msi1_base_lsb;
385b8a42cceSpatrick 	uint32_t hal_reo1_ring_msi1_base_msb;
386b8a42cceSpatrick 	uint32_t hal_reo1_ring_msi1_data;
38727c3d914Spatrick 	uint32_t hal_reo1_aging_thres_ix0;
38827c3d914Spatrick 	uint32_t hal_reo1_aging_thres_ix1;
38927c3d914Spatrick 	uint32_t hal_reo1_aging_thres_ix2;
39027c3d914Spatrick 	uint32_t hal_reo1_aging_thres_ix3;
39127c3d914Spatrick 
39227c3d914Spatrick 	uint32_t hal_reo2_sw0_ring_base;
393b8a42cceSpatrick 
394b8a42cceSpatrick 	uint32_t hal_sw2reo_ring_base;
39527c3d914Spatrick 	uint32_t hal_sw2reo1_ring_base;
396b8a42cceSpatrick 
397b8a42cceSpatrick 	uint32_t hal_reo_cmd_ring_base;
398b8a42cceSpatrick 
399b8a42cceSpatrick 	uint32_t hal_reo_status_ring_base;
4004bba8532Spatrick };
4014bba8532Spatrick 
40227c3d914Spatrick extern const struct ath12k_hw_regs wcn7850_regs;
4034bba8532Spatrick 
4044bba8532Spatrick enum ath12k_dev_flags {
4054bba8532Spatrick 	ATH12K_CAC_RUNNING,
4064bba8532Spatrick 	ATH12K_FLAG_CORE_REGISTERED,
4074bba8532Spatrick 	ATH12K_FLAG_CRASH_FLUSH,
4084bba8532Spatrick 	ATH12K_FLAG_RAW_MODE,
4094bba8532Spatrick 	ATH12K_FLAG_HW_CRYPTO_DISABLED,
4104bba8532Spatrick 	ATH12K_FLAG_BTCOEX,
4114bba8532Spatrick 	ATH12K_FLAG_RECOVERY,
4124bba8532Spatrick 	ATH12K_FLAG_UNREGISTERING,
4134bba8532Spatrick 	ATH12K_FLAG_REGISTERED,
4144bba8532Spatrick 	ATH12K_FLAG_QMI_FAIL,
4154bba8532Spatrick 	ATH12K_FLAG_HTC_SUSPEND_COMPLETE,
4164bba8532Spatrick 	ATH12K_FLAG_CE_IRQ_ENABLED,
4174bba8532Spatrick 	ATH12K_FLAG_EXT_IRQ_ENABLED,
4184bba8532Spatrick 	ATH12K_FLAG_FIXED_MEM_RGN,
4194bba8532Spatrick 	ATH12K_FLAG_DEVICE_INIT_DONE,
4204bba8532Spatrick 	ATH12K_FLAG_MULTI_MSI_VECTORS,
4214bba8532Spatrick };
4224bba8532Spatrick 
4234bba8532Spatrick enum ath12k_scan_state {
4244bba8532Spatrick 	ATH12K_SCAN_IDLE,
4254bba8532Spatrick 	ATH12K_SCAN_STARTING,
4264bba8532Spatrick 	ATH12K_SCAN_RUNNING,
4274bba8532Spatrick 	ATH12K_SCAN_ABORTING,
4284bba8532Spatrick };
4294bba8532Spatrick 
4304bba8532Spatrick enum ath12k_11d_state {
4314bba8532Spatrick 	ATH12K_11D_IDLE,
4324bba8532Spatrick 	ATH12K_11D_PREPARING,
4334bba8532Spatrick 	ATH12K_11D_RUNNING,
4344bba8532Spatrick };
4354bba8532Spatrick 
4364bba8532Spatrick /* enum ath12k_spectral_mode:
4374bba8532Spatrick  *
4384bba8532Spatrick  * @SPECTRAL_DISABLED: spectral mode is disabled
4394bba8532Spatrick  * @SPECTRAL_BACKGROUND: hardware sends samples when it is not busy with
4404bba8532Spatrick  *	something else.
4414bba8532Spatrick  * @SPECTRAL_MANUAL: spectral scan is enabled, triggering for samples
4424bba8532Spatrick  *	is performed manually.
4434bba8532Spatrick  */
4444bba8532Spatrick enum ath12k_spectral_mode {
4454bba8532Spatrick 	ATH12K_SPECTRAL_DISABLED = 0,
4464bba8532Spatrick 	ATH12K_SPECTRAL_BACKGROUND,
4474bba8532Spatrick 	ATH12K_SPECTRAL_MANUAL,
4484bba8532Spatrick };
4494bba8532Spatrick 
4504bba8532Spatrick #define QWZ_SCAN_11D_INTERVAL		600000
4514bba8532Spatrick #define QWZ_11D_INVALID_VDEV_ID		0xFFFF
4524bba8532Spatrick 
4534bba8532Spatrick struct qwz_ops {
4544bba8532Spatrick 	uint32_t	(*read32)(struct qwz_softc *, uint32_t);
4554bba8532Spatrick 	void		(*write32)(struct qwz_softc *, uint32_t, uint32_t);
4564bba8532Spatrick 	int		(*start)(struct qwz_softc *);
4574bba8532Spatrick 	void		(*stop)(struct qwz_softc *);
4584bba8532Spatrick 	int		(*power_up)(struct qwz_softc *);
4594bba8532Spatrick 	void		(*power_down)(struct qwz_softc *);
4604bba8532Spatrick 	int		(*submit_xfer)(struct qwz_softc *, struct mbuf *);
4614bba8532Spatrick 	void		(*irq_enable)(struct qwz_softc *sc);
4624bba8532Spatrick 	void		(*irq_disable)(struct qwz_softc *sc);
4634bba8532Spatrick 	int		(*map_service_to_pipe)(struct qwz_softc *, uint16_t,
4644bba8532Spatrick 			    uint8_t *, uint8_t *);
4654bba8532Spatrick 	int		(*get_user_msi_vector)(struct qwz_softc *, char *,
4664bba8532Spatrick 			    int *, uint32_t *, uint32_t *);
4674bba8532Spatrick };
4684bba8532Spatrick 
4694bba8532Spatrick struct qwz_dmamem {
4704bba8532Spatrick 	bus_dmamap_t		map;
4714bba8532Spatrick 	bus_dma_segment_t	seg;
4724bba8532Spatrick 	size_t			size;
4734bba8532Spatrick 	caddr_t			kva;
4744bba8532Spatrick };
4754bba8532Spatrick 
4764bba8532Spatrick struct qwz_dmamem *qwz_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t);
4774bba8532Spatrick void qwz_dmamem_free(bus_dma_tag_t, struct qwz_dmamem *);
4784bba8532Spatrick 
4794bba8532Spatrick #define QWZ_DMA_MAP(_adm)	((_adm)->map)
4804bba8532Spatrick #define QWZ_DMA_LEN(_adm)	((_adm)->size)
4814bba8532Spatrick #define QWZ_DMA_DVA(_adm)	((_adm)->map->dm_segs[0].ds_addr)
4824bba8532Spatrick #define QWZ_DMA_KVA(_adm)	((void *)(_adm)->kva)
4834bba8532Spatrick 
4844bba8532Spatrick struct hal_srng_params {
4854bba8532Spatrick 	bus_addr_t ring_base_paddr;
4864bba8532Spatrick 	uint32_t *ring_base_vaddr;
4874bba8532Spatrick 	int num_entries;
4884bba8532Spatrick 	uint32_t intr_batch_cntr_thres_entries;
4894bba8532Spatrick 	uint32_t intr_timer_thres_us;
4904bba8532Spatrick 	uint32_t flags;
4914bba8532Spatrick 	uint32_t max_buffer_len;
4924bba8532Spatrick 	uint32_t low_threshold;
4934bba8532Spatrick 	uint64_t msi_addr;
4944bba8532Spatrick 	uint32_t msi_data;
4954bba8532Spatrick 
4964bba8532Spatrick 	/* Add more params as needed */
4974bba8532Spatrick };
4984bba8532Spatrick 
4994bba8532Spatrick enum hal_srng_dir {
5004bba8532Spatrick 	HAL_SRNG_DIR_SRC,
5014bba8532Spatrick 	HAL_SRNG_DIR_DST
5024bba8532Spatrick };
5034bba8532Spatrick 
5044bba8532Spatrick /* srng flags */
5054bba8532Spatrick #define HAL_SRNG_FLAGS_MSI_SWAP			0x00000008
5064bba8532Spatrick #define HAL_SRNG_FLAGS_RING_PTR_SWAP		0x00000010
5074bba8532Spatrick #define HAL_SRNG_FLAGS_DATA_TLV_SWAP		0x00000020
5084bba8532Spatrick #define HAL_SRNG_FLAGS_LOW_THRESH_INTR_EN	0x00010000
5094bba8532Spatrick #define HAL_SRNG_FLAGS_MSI_INTR			0x00020000
51009a673e5Spatrick #define HAL_SRNG_FLAGS_HIGH_THRESH_INTR_EN	0x00080000
5114bba8532Spatrick #define HAL_SRNG_FLAGS_LMAC_RING		0x80000000
5124bba8532Spatrick 
5134bba8532Spatrick #define HAL_SRNG_TLV_HDR_TAG		GENMASK(9, 1)
5144bba8532Spatrick #define HAL_SRNG_TLV_HDR_LEN		GENMASK(25, 10)
5154bba8532Spatrick 
5164bba8532Spatrick /* Common SRNG ring structure for source and destination rings */
5174bba8532Spatrick struct hal_srng {
5184bba8532Spatrick 	/* Unique SRNG ring ID */
5194bba8532Spatrick 	uint8_t ring_id;
5204bba8532Spatrick 
5214bba8532Spatrick 	/* Ring initialization done */
5224bba8532Spatrick 	uint8_t initialized;
5234bba8532Spatrick 
5244bba8532Spatrick 	/* Interrupt/MSI value assigned to this ring */
5254bba8532Spatrick 	int irq;
5264bba8532Spatrick 
5274bba8532Spatrick 	/* Physical base address of the ring */
5284bba8532Spatrick 	bus_addr_t ring_base_paddr;
5294bba8532Spatrick 
5304bba8532Spatrick 	/* Virtual base address of the ring */
5314bba8532Spatrick 	uint32_t *ring_base_vaddr;
5324bba8532Spatrick 
5334bba8532Spatrick 	/* Number of entries in ring */
5344bba8532Spatrick 	uint32_t num_entries;
5354bba8532Spatrick 
5364bba8532Spatrick 	/* Ring size */
5374bba8532Spatrick 	uint32_t ring_size;
5384bba8532Spatrick 
5394bba8532Spatrick 	/* Ring size mask */
5404bba8532Spatrick 	uint32_t ring_size_mask;
5414bba8532Spatrick 
5424bba8532Spatrick 	/* Size of ring entry */
5434bba8532Spatrick 	uint32_t entry_size;
5444bba8532Spatrick 
5454bba8532Spatrick 	/* Interrupt timer threshold - in micro seconds */
5464bba8532Spatrick 	uint32_t intr_timer_thres_us;
5474bba8532Spatrick 
5484bba8532Spatrick 	/* Interrupt batch counter threshold - in number of ring entries */
5494bba8532Spatrick 	uint32_t intr_batch_cntr_thres_entries;
5504bba8532Spatrick 
5514bba8532Spatrick 	/* MSI Address */
5524bba8532Spatrick 	bus_addr_t msi_addr;
5534bba8532Spatrick 
5544bba8532Spatrick 	/* MSI data */
5554bba8532Spatrick 	uint32_t msi_data;
5564bba8532Spatrick 
5574bba8532Spatrick 	/* Misc flags */
5584bba8532Spatrick 	uint32_t flags;
5594bba8532Spatrick #ifdef notyet
5604bba8532Spatrick 	/* Lock for serializing ring index updates */
5614bba8532Spatrick 	spinlock_t lock;
5624bba8532Spatrick #endif
5634bba8532Spatrick 	/* Start offset of SRNG register groups for this ring
5644bba8532Spatrick 	 * TBD: See if this is required - register address can be derived
5654bba8532Spatrick 	 * from ring ID
5664bba8532Spatrick 	 */
5674bba8532Spatrick 	uint32_t hwreg_base[HAL_SRNG_NUM_REG_GRP];
5684bba8532Spatrick 
5694bba8532Spatrick 	uint64_t timestamp;
5704bba8532Spatrick 
5714bba8532Spatrick 	/* Source or Destination ring */
5724bba8532Spatrick 	enum hal_srng_dir ring_dir;
5734bba8532Spatrick 
5744bba8532Spatrick 	union {
5754bba8532Spatrick 		struct {
5764bba8532Spatrick 			/* SW tail pointer */
5774bba8532Spatrick 			uint32_t tp;
5784bba8532Spatrick 
5794bba8532Spatrick 			/* Shadow head pointer location to be updated by HW */
5804bba8532Spatrick 			volatile uint32_t *hp_addr;
5814bba8532Spatrick 
5824bba8532Spatrick 			/* Cached head pointer */
5834bba8532Spatrick 			uint32_t cached_hp;
5844bba8532Spatrick 
5854bba8532Spatrick 			/* Tail pointer location to be updated by SW - This
5864bba8532Spatrick 			 * will be a register address and need not be
5874bba8532Spatrick 			 * accessed through SW structure
5884bba8532Spatrick 			 */
5894bba8532Spatrick 			uint32_t *tp_addr;
5904bba8532Spatrick 
5914bba8532Spatrick 			/* Current SW loop cnt */
5924bba8532Spatrick 			uint32_t loop_cnt;
5934bba8532Spatrick 
5944bba8532Spatrick 			/* max transfer size */
5954bba8532Spatrick 			uint16_t max_buffer_length;
5964bba8532Spatrick 
5974bba8532Spatrick 			/* head pointer at access end */
5984bba8532Spatrick 			uint32_t last_hp;
5994bba8532Spatrick 		} dst_ring;
6004bba8532Spatrick 
6014bba8532Spatrick 		struct {
6024bba8532Spatrick 			/* SW head pointer */
6034bba8532Spatrick 			uint32_t hp;
6044bba8532Spatrick 
6054bba8532Spatrick 			/* SW reap head pointer */
6064bba8532Spatrick 			uint32_t reap_hp;
6074bba8532Spatrick 
6084bba8532Spatrick 			/* Shadow tail pointer location to be updated by HW */
6094bba8532Spatrick 			uint32_t *tp_addr;
6104bba8532Spatrick 
6114bba8532Spatrick 			/* Cached tail pointer */
6124bba8532Spatrick 			uint32_t cached_tp;
6134bba8532Spatrick 
6144bba8532Spatrick 			/* Head pointer location to be updated by SW - This
6154bba8532Spatrick 			 * will be a register address and need not be accessed
6164bba8532Spatrick 			 * through SW structure
6174bba8532Spatrick 			 */
6184bba8532Spatrick 			uint32_t *hp_addr;
6194bba8532Spatrick 
6204bba8532Spatrick 			/* Low threshold - in number of ring entries */
6214bba8532Spatrick 			uint32_t low_threshold;
6224bba8532Spatrick 
6234bba8532Spatrick 			/* tail pointer at access end */
6244bba8532Spatrick 			uint32_t last_tp;
6254bba8532Spatrick 		} src_ring;
6264bba8532Spatrick 	} u;
6274bba8532Spatrick };
6284bba8532Spatrick 
6294bba8532Spatrick enum hal_ring_type {
6304bba8532Spatrick 	HAL_REO_DST,
6314bba8532Spatrick 	HAL_REO_EXCEPTION,
6324bba8532Spatrick 	HAL_REO_REINJECT,
6334bba8532Spatrick 	HAL_REO_CMD,
6344bba8532Spatrick 	HAL_REO_STATUS,
6354bba8532Spatrick 	HAL_TCL_DATA,
6364bba8532Spatrick 	HAL_TCL_CMD,
6374bba8532Spatrick 	HAL_TCL_STATUS,
6384bba8532Spatrick 	HAL_CE_SRC,
6394bba8532Spatrick 	HAL_CE_DST,
6404bba8532Spatrick 	HAL_CE_DST_STATUS,
6414bba8532Spatrick 	HAL_WBM_IDLE_LINK,
6424bba8532Spatrick 	HAL_SW2WBM_RELEASE,
6434bba8532Spatrick 	HAL_WBM2SW_RELEASE,
6444bba8532Spatrick 	HAL_RXDMA_BUF,
6454bba8532Spatrick 	HAL_RXDMA_DST,
6464bba8532Spatrick 	HAL_RXDMA_MONITOR_BUF,
6474bba8532Spatrick 	HAL_RXDMA_MONITOR_STATUS,
6484bba8532Spatrick 	HAL_RXDMA_MONITOR_DST,
6494bba8532Spatrick 	HAL_RXDMA_MONITOR_DESC,
6504bba8532Spatrick 	HAL_RXDMA_DIR_BUF,
65127c3d914Spatrick 	HAL_PPE2TCL,
65227c3d914Spatrick 	HAL_PPE_RELEASE,
65327c3d914Spatrick 	HAL_TX_MONITOR_BUF,
65427c3d914Spatrick 	HAL_TX_MONITOR_DST,
6554bba8532Spatrick 	HAL_MAX_RING_TYPES,
6564bba8532Spatrick };
6574bba8532Spatrick 
65827c3d914Spatrick enum hal_srng_mac_type {
65927c3d914Spatrick 	ATH12K_HAL_SRNG_UMAC,
66027c3d914Spatrick 	ATH12K_HAL_SRNG_DMAC,
66127c3d914Spatrick 	ATH12K_HAL_SRNG_PMAC
66227c3d914Spatrick };
66327c3d914Spatrick 
6644bba8532Spatrick /* HW SRNG configuration table */
6654bba8532Spatrick struct hal_srng_config {
6664bba8532Spatrick 	int start_ring_id;
6674bba8532Spatrick 	uint16_t max_rings;
6684bba8532Spatrick 	uint16_t entry_size;
6694bba8532Spatrick 	uint32_t reg_start[HAL_SRNG_NUM_REG_GRP];
6704bba8532Spatrick 	uint16_t reg_size[HAL_SRNG_NUM_REG_GRP];
67127c3d914Spatrick 	enum hal_srng_mac_type mac_type;
6724bba8532Spatrick 	enum hal_srng_dir ring_dir;
6734bba8532Spatrick 	uint32_t max_size;
6744bba8532Spatrick };
6754bba8532Spatrick 
6764bba8532Spatrick #define QWZ_NUM_SRNG_CFG	21
6774bba8532Spatrick 
6784bba8532Spatrick struct hal_reo_status_header {
6794bba8532Spatrick 	uint16_t cmd_num;
6804bba8532Spatrick 	enum hal_reo_cmd_status cmd_status;
6814bba8532Spatrick 	uint16_t cmd_exe_time;
6824bba8532Spatrick 	uint32_t timestamp;
6834bba8532Spatrick };
6844bba8532Spatrick 
6854bba8532Spatrick struct hal_reo_status_queue_stats {
6864bba8532Spatrick 	uint16_t ssn;
6874bba8532Spatrick 	uint16_t curr_idx;
6884bba8532Spatrick 	uint32_t pn[4];
6894bba8532Spatrick 	uint32_t last_rx_queue_ts;
6904bba8532Spatrick 	uint32_t last_rx_dequeue_ts;
6914bba8532Spatrick 	uint32_t rx_bitmap[8]; /* Bitmap from 0-255 */
6924bba8532Spatrick 	uint32_t curr_mpdu_cnt;
6934bba8532Spatrick 	uint32_t curr_msdu_cnt;
6944bba8532Spatrick 	uint16_t fwd_due_to_bar_cnt;
6954bba8532Spatrick 	uint16_t dup_cnt;
6964bba8532Spatrick 	uint32_t frames_in_order_cnt;
6974bba8532Spatrick 	uint32_t num_mpdu_processed_cnt;
6984bba8532Spatrick 	uint32_t num_msdu_processed_cnt;
6994bba8532Spatrick 	uint32_t total_num_processed_byte_cnt;
7004bba8532Spatrick 	uint32_t late_rx_mpdu_cnt;
7014bba8532Spatrick 	uint32_t reorder_hole_cnt;
7024bba8532Spatrick 	uint8_t timeout_cnt;
7034bba8532Spatrick 	uint8_t bar_rx_cnt;
7044bba8532Spatrick 	uint8_t num_window_2k_jump_cnt;
7054bba8532Spatrick };
7064bba8532Spatrick 
7074bba8532Spatrick struct hal_reo_status_flush_queue {
7084bba8532Spatrick 	bool err_detected;
7094bba8532Spatrick };
7104bba8532Spatrick 
7114bba8532Spatrick enum hal_reo_status_flush_cache_err_code {
7124bba8532Spatrick 	HAL_REO_STATUS_FLUSH_CACHE_ERR_CODE_SUCCESS,
7134bba8532Spatrick 	HAL_REO_STATUS_FLUSH_CACHE_ERR_CODE_IN_USE,
7144bba8532Spatrick 	HAL_REO_STATUS_FLUSH_CACHE_ERR_CODE_NOT_FOUND,
7154bba8532Spatrick };
7164bba8532Spatrick 
7174bba8532Spatrick struct hal_reo_status_flush_cache {
7184bba8532Spatrick 	bool err_detected;
7194bba8532Spatrick 	enum hal_reo_status_flush_cache_err_code err_code;
7204bba8532Spatrick 	bool cache_controller_flush_status_hit;
7214bba8532Spatrick 	uint8_t cache_controller_flush_status_desc_type;
7224bba8532Spatrick 	uint8_t cache_controller_flush_status_client_id;
7234bba8532Spatrick 	uint8_t cache_controller_flush_status_err;
7244bba8532Spatrick 	uint8_t cache_controller_flush_status_cnt;
7254bba8532Spatrick };
7264bba8532Spatrick 
7274bba8532Spatrick enum hal_reo_status_unblock_cache_type {
7284bba8532Spatrick 	HAL_REO_STATUS_UNBLOCK_BLOCKING_RESOURCE,
7294bba8532Spatrick 	HAL_REO_STATUS_UNBLOCK_ENTIRE_CACHE_USAGE,
7304bba8532Spatrick };
7314bba8532Spatrick 
7324bba8532Spatrick struct hal_reo_status_unblock_cache {
7334bba8532Spatrick 	bool err_detected;
7344bba8532Spatrick 	enum hal_reo_status_unblock_cache_type unblock_type;
7354bba8532Spatrick };
7364bba8532Spatrick 
7374bba8532Spatrick struct hal_reo_status_flush_timeout_list {
7384bba8532Spatrick 	bool err_detected;
7394bba8532Spatrick 	bool list_empty;
7404bba8532Spatrick 	uint16_t release_desc_cnt;
7414bba8532Spatrick 	uint16_t fwd_buf_cnt;
7424bba8532Spatrick };
7434bba8532Spatrick 
7444bba8532Spatrick enum hal_reo_threshold_idx {
7454bba8532Spatrick 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER0,
7464bba8532Spatrick 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER1,
7474bba8532Spatrick 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER2,
7484bba8532Spatrick 	HAL_REO_THRESHOLD_IDX_DESC_COUNTER_SUM,
7494bba8532Spatrick };
7504bba8532Spatrick 
7514bba8532Spatrick struct hal_reo_status_desc_thresh_reached {
7524bba8532Spatrick 	enum hal_reo_threshold_idx threshold_idx;
7534bba8532Spatrick 	uint32_t link_desc_counter0;
7544bba8532Spatrick 	uint32_t link_desc_counter1;
7554bba8532Spatrick 	uint32_t link_desc_counter2;
7564bba8532Spatrick 	uint32_t link_desc_counter_sum;
7574bba8532Spatrick };
7584bba8532Spatrick 
7594bba8532Spatrick struct hal_reo_status {
7604bba8532Spatrick 	struct hal_reo_status_header uniform_hdr;
7614bba8532Spatrick 	uint8_t loop_cnt;
7624bba8532Spatrick 	union {
7634bba8532Spatrick 		struct hal_reo_status_queue_stats queue_stats;
7644bba8532Spatrick 		struct hal_reo_status_flush_queue flush_queue;
7654bba8532Spatrick 		struct hal_reo_status_flush_cache flush_cache;
7664bba8532Spatrick 		struct hal_reo_status_unblock_cache unblock_cache;
7674bba8532Spatrick 		struct hal_reo_status_flush_timeout_list timeout_list;
7684bba8532Spatrick 		struct hal_reo_status_desc_thresh_reached desc_thresh_reached;
7694bba8532Spatrick 	} u;
7704bba8532Spatrick };
7714bba8532Spatrick 
7724bba8532Spatrick /* HAL context to be used to access SRNG APIs (currently used by data path
7734bba8532Spatrick  * and transport (CE) modules)
7744bba8532Spatrick  */
7754bba8532Spatrick struct ath12k_hal {
7764bba8532Spatrick 	/* HAL internal state for all SRNG rings.
7774bba8532Spatrick 	 */
7784bba8532Spatrick 	struct hal_srng srng_list[HAL_SRNG_RING_ID_MAX];
7794bba8532Spatrick 
7804bba8532Spatrick 	/* SRNG configuration table */
78127c3d914Spatrick 	struct hal_srng_config *srng_config;
7824bba8532Spatrick 
7834bba8532Spatrick 	/* Remote pointer memory for HW/FW updates */
7844bba8532Spatrick 	struct qwz_dmamem *rdpmem;
7854bba8532Spatrick 	struct {
7864bba8532Spatrick 		uint32_t *vaddr;
7874bba8532Spatrick 		bus_addr_t paddr;
7884bba8532Spatrick 	} rdp;
7894bba8532Spatrick 
7904bba8532Spatrick 	/* Shared memory for ring pointer updates from host to FW */
7914bba8532Spatrick 	struct qwz_dmamem *wrpmem;
7924bba8532Spatrick 	struct {
7934bba8532Spatrick 		uint32_t *vaddr;
7944bba8532Spatrick 		bus_addr_t paddr;
7954bba8532Spatrick 	} wrp;
7964bba8532Spatrick 
7974bba8532Spatrick 	/* Available REO blocking resources bitmap */
7984bba8532Spatrick 	uint8_t avail_blk_resource;
7994bba8532Spatrick 
8004bba8532Spatrick 	uint8_t current_blk_index;
8014bba8532Spatrick 
8024bba8532Spatrick 	/* shadow register configuration */
8034bba8532Spatrick 	uint32_t shadow_reg_addr[HAL_SHADOW_NUM_REGS];
8044bba8532Spatrick 	int num_shadow_reg_configured;
8054bba8532Spatrick #ifdef notyet
8064bba8532Spatrick 	struct lock_class_key srng_key[HAL_SRNG_RING_ID_MAX];
8074bba8532Spatrick #endif
808eb49c7f0Spatrick 
809eb49c7f0Spatrick 	uint32_t hal_desc_sz;
8104bba8532Spatrick };
8114bba8532Spatrick 
8124bba8532Spatrick enum hal_pn_type {
8134bba8532Spatrick 	HAL_PN_TYPE_NONE,
8144bba8532Spatrick 	HAL_PN_TYPE_WPA,
8154bba8532Spatrick 	HAL_PN_TYPE_WAPI_EVEN,
8164bba8532Spatrick 	HAL_PN_TYPE_WAPI_UNEVEN,
8174bba8532Spatrick };
8184bba8532Spatrick 
8194bba8532Spatrick enum hal_ce_desc {
8204bba8532Spatrick 	HAL_CE_DESC_SRC,
8214bba8532Spatrick 	HAL_CE_DESC_DST,
8224bba8532Spatrick 	HAL_CE_DESC_DST_STATUS,
8234bba8532Spatrick };
8244bba8532Spatrick 
8254bba8532Spatrick struct ce_ie_addr {
8264bba8532Spatrick 	uint32_t ie1_reg_addr;
8274bba8532Spatrick 	uint32_t ie2_reg_addr;
8284bba8532Spatrick 	uint32_t ie3_reg_addr;
8294bba8532Spatrick };
8304bba8532Spatrick 
8314bba8532Spatrick struct ce_remap {
8324bba8532Spatrick 	uint32_t base;
8334bba8532Spatrick 	uint32_t size;
8344bba8532Spatrick };
8354bba8532Spatrick 
8364bba8532Spatrick struct ce_attr {
8374bba8532Spatrick 	/* CE_ATTR_* values */
8384bba8532Spatrick 	unsigned int flags;
8394bba8532Spatrick 
8404bba8532Spatrick 	/* #entries in source ring - Must be a power of 2 */
8414bba8532Spatrick 	unsigned int src_nentries;
8424bba8532Spatrick 
8434bba8532Spatrick 	/*
8444bba8532Spatrick 	 * Max source send size for this CE.
8454bba8532Spatrick 	 * This is also the minimum size of a destination buffer.
8464bba8532Spatrick 	 */
8474bba8532Spatrick 	unsigned int src_sz_max;
8484bba8532Spatrick 
8494bba8532Spatrick 	/* #entries in destination ring - Must be a power of 2 */
8504bba8532Spatrick 	unsigned int dest_nentries;
8514bba8532Spatrick 
8524bba8532Spatrick 	void (*recv_cb)(struct qwz_softc *, struct mbuf *);
8534bba8532Spatrick };
8544bba8532Spatrick 
8554bba8532Spatrick #define CE_DESC_RING_ALIGN 8
8564bba8532Spatrick 
8574bba8532Spatrick struct qwz_rx_msdu {
8584bba8532Spatrick 	TAILQ_ENTRY(qwz_rx_msdu) entry;
8594bba8532Spatrick 	struct mbuf *m;
8604bba8532Spatrick 	struct ieee80211_rxinfo rxi;
8614bba8532Spatrick 	int is_first_msdu;
8624bba8532Spatrick 	int is_last_msdu;
8634bba8532Spatrick 	int is_continuation;
8644bba8532Spatrick 	int is_mcbc;
8654bba8532Spatrick 	int is_eapol;
8664bba8532Spatrick 	struct hal_rx_desc *rx_desc;
8674bba8532Spatrick 	uint8_t err_rel_src;
8684bba8532Spatrick 	uint8_t err_code;
8694bba8532Spatrick 	uint8_t mac_id;
8704bba8532Spatrick 	uint8_t unmapped;
8714bba8532Spatrick 	uint8_t is_frag;
8724bba8532Spatrick 	uint8_t tid;
8734bba8532Spatrick 	uint16_t peer_id;
8744bba8532Spatrick 	uint16_t seq_no;
8754bba8532Spatrick };
8764bba8532Spatrick 
8774bba8532Spatrick TAILQ_HEAD(qwz_rx_msdu_list, qwz_rx_msdu);
8784bba8532Spatrick 
8794bba8532Spatrick struct qwz_rx_data {
8804bba8532Spatrick 	struct mbuf	*m;
8814bba8532Spatrick 	bus_dmamap_t	map;
8824bba8532Spatrick 	struct qwz_rx_msdu rx_msdu;
8834bba8532Spatrick };
8844bba8532Spatrick 
8854bba8532Spatrick struct qwz_tx_data {
8864bba8532Spatrick 	struct ieee80211_node *ni;
8874bba8532Spatrick 	struct mbuf	*m;
8884bba8532Spatrick 	bus_dmamap_t	map;
8894bba8532Spatrick 	uint8_t eid;
8904bba8532Spatrick 	uint8_t flags;
8914bba8532Spatrick 	uint32_t cipher;
8924bba8532Spatrick };
8934bba8532Spatrick 
8944bba8532Spatrick struct qwz_ce_ring {
8954bba8532Spatrick 	/* Number of entries in this ring; must be power of 2 */
8964bba8532Spatrick 	unsigned int nentries;
8974bba8532Spatrick 	unsigned int nentries_mask;
8984bba8532Spatrick 
8994bba8532Spatrick 	/* For dest ring, this is the next index to be processed
9004bba8532Spatrick 	 * by software after it was/is received into.
9014bba8532Spatrick 	 *
9024bba8532Spatrick 	 * For src ring, this is the last descriptor that was sent
9034bba8532Spatrick 	 * and completion processed by software.
9044bba8532Spatrick 	 *
9054bba8532Spatrick 	 * Regardless of src or dest ring, this is an invariant
9064bba8532Spatrick 	 * (modulo ring size):
9074bba8532Spatrick 	 *     write index >= read index >= sw_index
9084bba8532Spatrick 	 */
9094bba8532Spatrick 	unsigned int sw_index;
9104bba8532Spatrick 	/* cached copy */
9114bba8532Spatrick 	unsigned int write_index;
9124bba8532Spatrick 
9134bba8532Spatrick 	/* Start of DMA-coherent area reserved for descriptors */
9144bba8532Spatrick 	/* Host address space */
9154bba8532Spatrick 	caddr_t base_addr;
9164bba8532Spatrick 
9174bba8532Spatrick 	/* DMA map for Tx/Rx descriptors. */
9184bba8532Spatrick 	bus_dmamap_t		dmap;
9194bba8532Spatrick 	bus_dma_segment_t	dsegs;
9204bba8532Spatrick 	int			nsegs;
9214bba8532Spatrick 	size_t			desc_sz;
9224bba8532Spatrick 
9234bba8532Spatrick 	/* HAL ring id */
9244bba8532Spatrick 	uint32_t hal_ring_id;
9254bba8532Spatrick 
9264bba8532Spatrick 	/*
9274bba8532Spatrick 	 * Per-transfer data.
9284bba8532Spatrick 	 * Size and type of this data depends on how the ring is used.
9294bba8532Spatrick 	 *
9304bba8532Spatrick 	 * For transfers using DMA, the context contains pointers to
9314bba8532Spatrick 	 * struct qwz_rx_data if this ring is a dest ring, or struct
9324bba8532Spatrick 	 * qwz_tx_data if this ring is a src ring. DMA maps are allocated
9334bba8532Spatrick 	 * when the device is started via sc->ops.start, and will be used
9344bba8532Spatrick 	 * to load mbufs for DMA transfers.
9354bba8532Spatrick 	 * In this case, the pointers MUST NOT be cleared until the device
9364bba8532Spatrick 	 * is stopped. Otherwise we'd lose track of our DMA mappings!
9374bba8532Spatrick 	 * The Linux ath12k driver works differently because it can store
9384bba8532Spatrick 	 * DMA mapping information in a Linux socket buffer structure, which
9394bba8532Spatrick 	 * is not possible with mbufs.
9404bba8532Spatrick 	 *
9414bba8532Spatrick 	 * Keep last.
9424bba8532Spatrick 	 */
9434bba8532Spatrick 	void *per_transfer_context[0];
9444bba8532Spatrick };
9454bba8532Spatrick 
9464bba8532Spatrick void qwz_htc_tx_completion_handler(struct qwz_softc *, struct mbuf *);
9474bba8532Spatrick void qwz_htc_rx_completion_handler(struct qwz_softc *, struct mbuf *);
9484bba8532Spatrick void qwz_dp_htt_htc_t2h_msg_handler(struct qwz_softc *, struct mbuf *);
9494bba8532Spatrick 
9504bba8532Spatrick struct qwz_dp;
9514bba8532Spatrick 
9524bba8532Spatrick struct qwz_dp_htt_wbm_tx_status {
9534bba8532Spatrick 	uint32_t msdu_id;
9544bba8532Spatrick 	int acked;
9554bba8532Spatrick 	int ack_rssi;
9564bba8532Spatrick 	uint16_t peer_id;
9574bba8532Spatrick };
9584bba8532Spatrick 
9594bba8532Spatrick #define DP_NUM_CLIENTS_MAX 64
9604bba8532Spatrick #define DP_AVG_TIDS_PER_CLIENT 2
9614bba8532Spatrick #define DP_NUM_TIDS_MAX (DP_NUM_CLIENTS_MAX * DP_AVG_TIDS_PER_CLIENT)
9624bba8532Spatrick #define DP_AVG_MSDUS_PER_FLOW 128
9634bba8532Spatrick #define DP_AVG_FLOWS_PER_TID 2
9644bba8532Spatrick #define DP_AVG_MPDUS_PER_TID_MAX 128
9654bba8532Spatrick #define DP_AVG_MSDUS_PER_MPDU 4
9664bba8532Spatrick 
9674bba8532Spatrick #define DP_RX_HASH_ENABLE	1 /* Enable hash based Rx steering */
9684bba8532Spatrick 
9694bba8532Spatrick #define DP_BA_WIN_SZ_MAX	256
9704bba8532Spatrick 
971eb49c7f0Spatrick #define DP_TCL_NUM_RING_MAX	4
9724bba8532Spatrick 
9734bba8532Spatrick #define DP_IDLE_SCATTER_BUFS_MAX 16
9744bba8532Spatrick 
9754bba8532Spatrick #define DP_WBM_RELEASE_RING_SIZE	64
9764bba8532Spatrick #define DP_TCL_DATA_RING_SIZE		512
9774bba8532Spatrick #define DP_TCL_DATA_RING_SIZE_WCN6750	2048
9784bba8532Spatrick #define DP_TX_COMP_RING_SIZE		32768
9794bba8532Spatrick #define DP_TX_IDR_SIZE			DP_TX_COMP_RING_SIZE
9804bba8532Spatrick #define DP_TCL_CMD_RING_SIZE		32
9814bba8532Spatrick #define DP_TCL_STATUS_RING_SIZE		32
9824bba8532Spatrick #define DP_REO_DST_RING_MAX		4
9834bba8532Spatrick #define DP_REO_DST_RING_SIZE		2048
9844bba8532Spatrick #define DP_REO_REINJECT_RING_SIZE	32
9854bba8532Spatrick #define DP_RX_RELEASE_RING_SIZE		1024
9864bba8532Spatrick #define DP_REO_EXCEPTION_RING_SIZE	128
9874bba8532Spatrick #define DP_REO_CMD_RING_SIZE		256
9884bba8532Spatrick #define DP_REO_STATUS_RING_SIZE		2048
9894bba8532Spatrick #define DP_RXDMA_BUF_RING_SIZE		4096
9904bba8532Spatrick #define DP_RXDMA_REFILL_RING_SIZE	2048
9914bba8532Spatrick #define DP_RXDMA_ERR_DST_RING_SIZE	1024
9924bba8532Spatrick #define DP_RXDMA_MON_STATUS_RING_SIZE	1024
9934bba8532Spatrick #define DP_RXDMA_MONITOR_BUF_RING_SIZE	4096
9944bba8532Spatrick #define DP_RXDMA_MONITOR_DST_RING_SIZE	2048
9954bba8532Spatrick #define DP_RXDMA_MONITOR_DESC_RING_SIZE	4096
99627c3d914Spatrick #define DP_TX_MONITOR_BUF_RING_SIZE	4096
99727c3d914Spatrick #define DP_TX_MONITOR_DEST_RING_SIZE	2048
99827c3d914Spatrick 
99927c3d914Spatrick #define DP_TX_MONITOR_BUF_SIZE		2048
100027c3d914Spatrick #define DP_TX_MONITOR_BUF_SIZE_MIN	48
100127c3d914Spatrick #define DP_TX_MONITOR_BUF_SIZE_MAX	8192
10024bba8532Spatrick 
10034bba8532Spatrick #define DP_RX_RELEASE_RING_NUM	3
10044bba8532Spatrick 
10054bba8532Spatrick #define DP_RX_BUFFER_SIZE	2048
10064bba8532Spatrick #define	DP_RX_BUFFER_SIZE_LITE  1024
10074bba8532Spatrick #define DP_RX_BUFFER_ALIGN_SIZE	128
10084bba8532Spatrick 
10094bba8532Spatrick #define DP_RXDMA_BUF_COOKIE_BUF_ID	GENMASK(17, 0)
10104bba8532Spatrick #define DP_RXDMA_BUF_COOKIE_PDEV_ID	GENMASK(20, 18)
10114bba8532Spatrick 
10124bba8532Spatrick #define DP_HW2SW_MACID(mac_id) ((mac_id) ? ((mac_id) - 1) : 0)
10134bba8532Spatrick #define DP_SW2HW_MACID(mac_id) ((mac_id) + 1)
10144bba8532Spatrick 
10154bba8532Spatrick #define DP_TX_DESC_ID_MAC_ID  GENMASK(1, 0)
10164bba8532Spatrick #define DP_TX_DESC_ID_MSDU_ID GENMASK(18, 2)
10174bba8532Spatrick #define DP_TX_DESC_ID_POOL_ID GENMASK(20, 19)
10184bba8532Spatrick 
101927c3d914Spatrick #define ATH12K_NUM_POOL_TX_DESC	32768
102027c3d914Spatrick 
102127c3d914Spatrick /* TODO: revisit this count during testing */
102227c3d914Spatrick #define ATH12K_RX_DESC_COUNT	(12288)
102327c3d914Spatrick 
102427c3d914Spatrick #define ATH12K_PAGE_SIZE	PAGE_SIZE
102527c3d914Spatrick 
102627c3d914Spatrick /* Total 1024 entries in PPT, i.e 4K/4 considering 4K aligned
102727c3d914Spatrick  * SPT pages which makes lower 12bits 0
102827c3d914Spatrick  */
102927c3d914Spatrick #define ATH12K_MAX_PPT_ENTRIES	1024
103027c3d914Spatrick 
103127c3d914Spatrick /* Total 512 entries in a SPT, i.e 4K Page/8 */
103227c3d914Spatrick #define ATH12K_MAX_SPT_ENTRIES	512
103327c3d914Spatrick 
103427c3d914Spatrick #define ATH12K_NUM_RX_SPT_PAGES	((ATH12K_RX_DESC_COUNT) / ATH12K_MAX_SPT_ENTRIES)
103527c3d914Spatrick 
103627c3d914Spatrick #define ATH12K_TX_SPT_PAGES_PER_POOL (ATH12K_NUM_POOL_TX_DESC / \
103727c3d914Spatrick 					  ATH12K_MAX_SPT_ENTRIES)
103827c3d914Spatrick #define ATH12K_NUM_TX_SPT_PAGES	(ATH12K_TX_SPT_PAGES_PER_POOL * ATH12K_HW_MAX_QUEUES)
103927c3d914Spatrick #define ATH12K_NUM_SPT_PAGES	(ATH12K_NUM_RX_SPT_PAGES + ATH12K_NUM_TX_SPT_PAGES)
104027c3d914Spatrick 
104127c3d914Spatrick #define ATH12K_TX_SPT_PAGE_OFFSET 0
104227c3d914Spatrick #define ATH12K_RX_SPT_PAGE_OFFSET ATH12K_NUM_TX_SPT_PAGES
104327c3d914Spatrick 
104427c3d914Spatrick /* The SPT pages are divided for RX and TX, first block for RX
104527c3d914Spatrick  * and remaining for TX
104627c3d914Spatrick  */
104727c3d914Spatrick #define ATH12K_NUM_TX_SPT_PAGE_START ATH12K_NUM_RX_SPT_PAGES
104827c3d914Spatrick 
104927c3d914Spatrick #define ATH12K_DP_RX_DESC_MAGIC	0xBABABABA
105027c3d914Spatrick 
105127c3d914Spatrick /* 4K aligned address have last 12 bits set to 0, this check is done
105227c3d914Spatrick  * so that two spt pages address can be stored per 8bytes
105327c3d914Spatrick  * of CMEM (PPT)
105427c3d914Spatrick  */
105527c3d914Spatrick #define ATH12K_SPT_4K_ALIGN_CHECK 0xFFF
105627c3d914Spatrick #define ATH12K_SPT_4K_ALIGN_OFFSET 12
105727c3d914Spatrick #define ATH12K_PPT_ADDR_OFFSET(ppt_index) (4 * (ppt_index))
105827c3d914Spatrick 
105927c3d914Spatrick /* To indicate HW of CMEM address, b0-31 are cmem base received via QMI */
106027c3d914Spatrick #define ATH12K_CMEM_ADDR_MSB 0x10
106127c3d914Spatrick 
106227c3d914Spatrick /* Of 20 bits cookie, b0-b8 is to indicate SPT offset and b9-19 for PPT */
106327c3d914Spatrick #define ATH12K_CC_SPT_MSB 8
106427c3d914Spatrick #define ATH12K_CC_PPT_MSB 19
106527c3d914Spatrick #define ATH12K_CC_PPT_SHIFT 9
106627c3d914Spatrick #define ATH12K_DP_CC_COOKIE_SPT	GENMASK(8, 0)
106727c3d914Spatrick #define ATH12K_DP_CC_COOKIE_PPT	GENMASK(19, 9)
106827c3d914Spatrick 
106927c3d914Spatrick #define DP_REO_QREF_NUM		GENMASK(31, 16)
107027c3d914Spatrick #define DP_MAX_PEER_ID		2047
107127c3d914Spatrick 
107227c3d914Spatrick /* Total size of the LUT is based on 2K peers, each having reference
107327c3d914Spatrick  * for 17tids, note each entry is of type ath12k_reo_queue_ref
107427c3d914Spatrick  * hence total size is 2048 * 17 * 8 = 278528
107527c3d914Spatrick  */
107627c3d914Spatrick #define DP_REOQ_LUT_SIZE	278528
107727c3d914Spatrick 
107827c3d914Spatrick /* Invalid TX Bank ID value */
107927c3d914Spatrick #define DP_INVALID_BANK_ID -1
108027c3d914Spatrick 
108127c3d914Spatrick struct ath12k_dp_tx_bank_profile {
108227c3d914Spatrick 	uint8_t is_configured;
108327c3d914Spatrick 	uint32_t num_users;
108427c3d914Spatrick 	uint32_t bank_config;
108527c3d914Spatrick };
108627c3d914Spatrick 
10874bba8532Spatrick struct qwz_hp_update_timer {
10884bba8532Spatrick 	struct timeout timer;
10894bba8532Spatrick 	int started;
10904bba8532Spatrick 	int init;
10914bba8532Spatrick 	uint32_t tx_num;
10924bba8532Spatrick 	uint32_t timer_tx_num;
10934bba8532Spatrick 	uint32_t ring_id;
10944bba8532Spatrick 	uint32_t interval;
10954bba8532Spatrick 	struct qwz_softc *sc;
10964bba8532Spatrick };
10974bba8532Spatrick 
109827c3d914Spatrick struct ath12k_rx_desc_info {
109927c3d914Spatrick 	TAILQ_ENTRY(ath12k_rx_desc_info) entry;
1100eb49c7f0Spatrick 	struct mbuf	*m;
1101eb49c7f0Spatrick 	bus_dmamap_t	map;
110227c3d914Spatrick 	uint32_t cookie;
110327c3d914Spatrick 	uint32_t magic;
110427c3d914Spatrick 	uint8_t in_use		: 1,
110527c3d914Spatrick 	        reserved	: 7;
110627c3d914Spatrick };
110727c3d914Spatrick 
110827c3d914Spatrick struct ath12k_tx_desc_info {
110927c3d914Spatrick 	TAILQ_ENTRY(ath12k_tx_desc_info) entry;
11109c0f05d8Spatrick 	struct mbuf	*m;
11119c0f05d8Spatrick 	bus_dmamap_t	map;
111227c3d914Spatrick 	uint32_t desc_id; /* Cookie */
111327c3d914Spatrick 	uint8_t mac_id;
111427c3d914Spatrick 	uint8_t pool_id;
111527c3d914Spatrick };
111627c3d914Spatrick 
111727c3d914Spatrick struct ath12k_spt_info {
111827c3d914Spatrick 	struct qwz_dmamem *mem;
111927c3d914Spatrick 	struct ath12k_rx_desc_info *rxbaddr[ATH12K_NUM_RX_SPT_PAGES];
112027c3d914Spatrick 	struct ath12k_tx_desc_info *txbaddr[ATH12K_NUM_TX_SPT_PAGES];
112127c3d914Spatrick };
112227c3d914Spatrick 
11234bba8532Spatrick struct dp_rx_tid {
11244bba8532Spatrick 	uint8_t tid;
11254bba8532Spatrick 	struct qwz_dmamem *mem;
11264bba8532Spatrick 	uint32_t *vaddr;
11274bba8532Spatrick 	uint64_t paddr;
11284bba8532Spatrick 	uint32_t size;
11294bba8532Spatrick 	uint32_t ba_win_sz;
11304bba8532Spatrick 	int active;
11314bba8532Spatrick 
11324bba8532Spatrick 	/* Info related to rx fragments */
11334bba8532Spatrick 	uint32_t cur_sn;
11344bba8532Spatrick 	uint16_t last_frag_no;
11354bba8532Spatrick 	uint16_t rx_frag_bitmap;
11364bba8532Spatrick #if 0
11374bba8532Spatrick 	struct sk_buff_head rx_frags;
11384bba8532Spatrick 	struct hal_reo_dest_ring *dst_ring_desc;
11394bba8532Spatrick 
11404bba8532Spatrick 	/* Timer info related to fragments */
11414bba8532Spatrick 	struct timer_list frag_timer;
11424bba8532Spatrick 	struct ath12k_base *ab;
11434bba8532Spatrick #endif
11444bba8532Spatrick };
11454bba8532Spatrick 
11464bba8532Spatrick #define DP_REO_DESC_FREE_THRESHOLD  64
11474bba8532Spatrick #define DP_REO_DESC_FREE_TIMEOUT_MS 1000
11484bba8532Spatrick #define DP_MON_PURGE_TIMEOUT_MS     100
11494bba8532Spatrick #define DP_MON_SERVICE_BUDGET       128
11504bba8532Spatrick 
11514bba8532Spatrick struct dp_reo_cache_flush_elem {
11524bba8532Spatrick 	TAILQ_ENTRY(dp_reo_cache_flush_elem) entry;
11534bba8532Spatrick 	struct dp_rx_tid data;
11544bba8532Spatrick 	uint64_t ts;
11554bba8532Spatrick };
11564bba8532Spatrick 
11574bba8532Spatrick TAILQ_HEAD(dp_reo_cmd_cache_flush_head, dp_reo_cache_flush_elem);
11584bba8532Spatrick 
11594bba8532Spatrick struct dp_reo_cmd {
11604bba8532Spatrick 	TAILQ_ENTRY(dp_reo_cmd) entry;
11614bba8532Spatrick 	struct dp_rx_tid data;
11624bba8532Spatrick 	int cmd_num;
11634bba8532Spatrick 	void (*handler)(struct qwz_dp *, void *,
11644bba8532Spatrick 	    enum hal_reo_cmd_status status);
11654bba8532Spatrick };
11664bba8532Spatrick 
11674bba8532Spatrick TAILQ_HEAD(dp_reo_cmd_head, dp_reo_cmd);
11684bba8532Spatrick 
11694bba8532Spatrick struct dp_srng {
11704bba8532Spatrick 	struct qwz_dmamem *mem;
11714bba8532Spatrick 	uint32_t *vaddr;
11724bba8532Spatrick 	bus_addr_t paddr;
11734bba8532Spatrick 	int size;
11744bba8532Spatrick 	uint32_t ring_id;
11754bba8532Spatrick };
11764bba8532Spatrick 
11774bba8532Spatrick struct dp_tx_ring {
11784bba8532Spatrick 	uint8_t tcl_data_ring_id;
11794bba8532Spatrick 	struct dp_srng tcl_data_ring;
11804bba8532Spatrick 	struct dp_srng tcl_comp_ring;
11814bba8532Spatrick 	int cur;
11824bba8532Spatrick 	int queued;
11834bba8532Spatrick 	struct qwz_tx_data *data;
11844bba8532Spatrick 	struct hal_wbm_release_ring *tx_status;
11854bba8532Spatrick 	int tx_status_head;
11864bba8532Spatrick 	int tx_status_tail;
11874bba8532Spatrick };
11884bba8532Spatrick 
11894bba8532Spatrick 
11904bba8532Spatrick struct dp_link_desc_bank {
11914bba8532Spatrick 	struct qwz_dmamem *mem;
11924bba8532Spatrick 	caddr_t *vaddr;
11934bba8532Spatrick 	bus_addr_t paddr;
11944bba8532Spatrick 	uint32_t size;
11954bba8532Spatrick };
11964bba8532Spatrick 
11974bba8532Spatrick /* Size to enforce scatter idle list mode */
11984bba8532Spatrick #define DP_LINK_DESC_ALLOC_SIZE_THRESH 0x200000
11994bba8532Spatrick #define DP_LINK_DESC_BANKS_MAX 8
12004bba8532Spatrick 
120127c3d914Spatrick #define DP_LINK_DESC_START	0x4000
120227c3d914Spatrick #define DP_LINK_DESC_SHIFT	3
120327c3d914Spatrick 
120427c3d914Spatrick #define DP_LINK_DESC_COOKIE_SET(id, page) \
120527c3d914Spatrick 	((((id) + DP_LINK_DESC_START) << DP_LINK_DESC_SHIFT) | (page))
120627c3d914Spatrick 
120727c3d914Spatrick #define DP_LINK_DESC_BANK_MASK	GENMASK(2, 0)
120827c3d914Spatrick 
12094bba8532Spatrick struct hal_wbm_idle_scatter_list {
12104bba8532Spatrick 	struct qwz_dmamem *mem;
12114bba8532Spatrick 	bus_addr_t paddr;
12124bba8532Spatrick 	struct hal_wbm_link_desc *vaddr;
12134bba8532Spatrick };
12144bba8532Spatrick 
1215eb49c7f0Spatrick struct dp_rxdma_mon_ring {
1216eb49c7f0Spatrick 	struct dp_srng refill_buf_ring;
1217eb49c7f0Spatrick #if 0
1218eb49c7f0Spatrick 	struct idr bufs_idr;
1219eb49c7f0Spatrick 	/* Protects bufs_idr */
1220eb49c7f0Spatrick 	spinlock_t idr_lock;
1221eb49c7f0Spatrick #else
1222eb49c7f0Spatrick 	struct qwz_rx_data *rx_data;
1223eb49c7f0Spatrick #endif
1224eb49c7f0Spatrick 	int bufs_max;
1225eb49c7f0Spatrick 	uint8_t freemap[howmany(DP_RXDMA_BUF_RING_SIZE, 8)];
1226eb49c7f0Spatrick };
1227eb49c7f0Spatrick 
1228eb49c7f0Spatrick struct dp_rxdma_ring {
1229eb49c7f0Spatrick 	struct dp_srng refill_buf_ring;
1230eb49c7f0Spatrick 	struct qwz_rx_data *rx_data;
1231eb49c7f0Spatrick 	int bufs_max;
1232eb49c7f0Spatrick };
1233eb49c7f0Spatrick 
1234eb49c7f0Spatrick #define MAX_RXDMA_PER_PDEV     2
1235eb49c7f0Spatrick 
12364bba8532Spatrick struct qwz_dp {
12374bba8532Spatrick 	struct qwz_softc *sc;
1238eb49c7f0Spatrick 	uint8_t num_bank_profiles;
1239eb49c7f0Spatrick 	struct ath12k_dp_tx_bank_profile *bank_profiles;
12404bba8532Spatrick 	enum ath12k_htc_ep_id eid;
12414bba8532Spatrick 	int htt_tgt_version_received;
12424bba8532Spatrick 	uint8_t htt_tgt_ver_major;
12434bba8532Spatrick 	uint8_t htt_tgt_ver_minor;
12444bba8532Spatrick 	struct dp_link_desc_bank link_desc_banks[DP_LINK_DESC_BANKS_MAX];
12454bba8532Spatrick 	struct dp_srng wbm_idle_ring;
12464bba8532Spatrick 	struct dp_srng wbm_desc_rel_ring;
12474bba8532Spatrick 	struct dp_srng reo_reinject_ring;
12484bba8532Spatrick 	struct dp_srng rx_rel_ring;
12494bba8532Spatrick 	struct dp_srng reo_except_ring;
12504bba8532Spatrick 	struct dp_srng reo_cmd_ring;
12514bba8532Spatrick 	struct dp_srng reo_status_ring;
1252eb49c7f0Spatrick 	enum peer_metadata_version peer_metadata_ver;
12534bba8532Spatrick 	struct dp_srng reo_dst_ring[DP_REO_DST_RING_MAX];
12544bba8532Spatrick 	struct dp_tx_ring tx_ring[DP_TCL_NUM_RING_MAX];
12554bba8532Spatrick 	struct hal_wbm_idle_scatter_list scatter_list[DP_IDLE_SCATTER_BUFS_MAX];
12564bba8532Spatrick 	struct dp_reo_cmd_head reo_cmd_list;
12574bba8532Spatrick 	struct dp_reo_cmd_cache_flush_head reo_cmd_cache_flush_list;
12584bba8532Spatrick #if 0
12594bba8532Spatrick 	struct list_head dp_full_mon_mpdu_list;
12604bba8532Spatrick #endif
12614bba8532Spatrick 	uint32_t reo_cmd_cache_flush_count;
1262eb49c7f0Spatrick 	enum hal_rx_buf_return_buf_manager idle_link_rbm;
12634bba8532Spatrick #if 0
12644bba8532Spatrick 	/**
12654bba8532Spatrick 	 * protects access to below fields,
12664bba8532Spatrick 	 * - reo_cmd_list
12674bba8532Spatrick 	 * - reo_cmd_cache_flush_list
12684bba8532Spatrick 	 * - reo_cmd_cache_flush_count
12694bba8532Spatrick 	 */
12704bba8532Spatrick 	spinlock_t reo_cmd_lock;
12714bba8532Spatrick #endif
12724bba8532Spatrick 	struct qwz_hp_update_timer reo_cmd_timer;
12734bba8532Spatrick 	struct qwz_hp_update_timer tx_ring_timer[DP_TCL_NUM_RING_MAX];
127427c3d914Spatrick 	struct ath12k_spt_info *spt_info;
127527c3d914Spatrick 	uint32_t num_spt_pages;
127627c3d914Spatrick 	TAILQ_HEAD(,ath12k_rx_desc_info) rx_desc_free_list;
127727c3d914Spatrick #ifdef notyet
127827c3d914Spatrick 	/* protects the free desc list */
127927c3d914Spatrick 	spinlock_t rx_desc_lock;
128027c3d914Spatrick #endif
128127c3d914Spatrick 	TAILQ_HEAD(,ath12k_tx_desc_info) tx_desc_free_list[ATH12K_HW_MAX_QUEUES];
128227c3d914Spatrick 	TAILQ_HEAD(,ath12k_tx_desc_info) tx_desc_used_list[ATH12K_HW_MAX_QUEUES];
128327c3d914Spatrick #ifdef notyet
128427c3d914Spatrick 	/* protects the free and used desc lists */
128527c3d914Spatrick 	spinlock_t tx_desc_lock[ATH12K_HW_MAX_QUEUES];
128627c3d914Spatrick #endif
1287eb49c7f0Spatrick 	struct dp_rxdma_ring rx_refill_buf_ring;
1288eb49c7f0Spatrick 	struct dp_srng rx_mac_buf_ring[MAX_RXDMA_PER_PDEV];
1289eb49c7f0Spatrick 	struct dp_srng rxdma_err_dst_ring[MAX_RXDMA_PER_PDEV];
1290eb49c7f0Spatrick 	struct dp_rxdma_mon_ring rxdma_mon_buf_ring;
12914bba8532Spatrick };
12924bba8532Spatrick 
12934bba8532Spatrick #define ATH12K_SHADOW_DP_TIMER_INTERVAL 20
12944bba8532Spatrick #define ATH12K_SHADOW_CTRL_TIMER_INTERVAL 10
12954bba8532Spatrick 
12964bba8532Spatrick struct qwz_ce_pipe {
12974bba8532Spatrick 	struct qwz_softc *sc;
12984bba8532Spatrick 	uint16_t pipe_num;
12994bba8532Spatrick 	unsigned int attr_flags;
13004bba8532Spatrick 	unsigned int buf_sz;
13014bba8532Spatrick 	unsigned int rx_buf_needed;
13024bba8532Spatrick 
130327c3d914Spatrick 	int (*send_cb)(struct qwz_ce_pipe *pipe);
13044bba8532Spatrick 	void (*recv_cb)(struct qwz_softc *, struct mbuf *);
13054bba8532Spatrick 
13064bba8532Spatrick #ifdef notyet
13074bba8532Spatrick 	struct tasklet_struct intr_tq;
13084bba8532Spatrick #endif
13094bba8532Spatrick 	struct qwz_ce_ring *src_ring;
13104bba8532Spatrick 	struct qwz_ce_ring *dest_ring;
13114bba8532Spatrick 	struct qwz_ce_ring *status_ring;
13124bba8532Spatrick 	uint64_t timestamp;
13134bba8532Spatrick };
13144bba8532Spatrick 
13154bba8532Spatrick struct qwz_ce {
13164bba8532Spatrick 	struct qwz_ce_pipe ce_pipe[CE_COUNT_MAX];
13174bba8532Spatrick #ifdef notyet
13184bba8532Spatrick 	/* Protects rings of all ce pipes */
13194bba8532Spatrick 	spinlock_t ce_lock;
13204bba8532Spatrick #endif
13214bba8532Spatrick };
13224bba8532Spatrick 
13234bba8532Spatrick 
13244bba8532Spatrick /* XXX This may be non-zero on AHB but is always zero on PCI. */
13254bba8532Spatrick #define ATH12K_CE_OFFSET(sc)	(0)
13264bba8532Spatrick 
13274bba8532Spatrick struct qwz_qmi_ce_cfg {
13284bba8532Spatrick 	const uint8_t *shadow_reg;
13294bba8532Spatrick 	int shadow_reg_len;
133027c3d914Spatrick 	uint32_t *shadow_reg_v3;
133127c3d914Spatrick 	uint32_t shadow_reg_v3_len;
13324bba8532Spatrick };
13334bba8532Spatrick 
13344bba8532Spatrick struct qwz_qmi_target_info {
13354bba8532Spatrick 	uint32_t chip_id;
13364bba8532Spatrick 	uint32_t chip_family;
13374bba8532Spatrick 	uint32_t board_id;
13384bba8532Spatrick 	uint32_t soc_id;
13394bba8532Spatrick 	uint32_t fw_version;
13404bba8532Spatrick 	uint32_t eeprom_caldata;
13414bba8532Spatrick 	char fw_build_timestamp[ATH12K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1];
13424bba8532Spatrick 	char fw_build_id[ATH12K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1];
13434bba8532Spatrick 	char bdf_ext[ATH12K_QMI_BDF_EXT_STR_LENGTH];
13444bba8532Spatrick };
13454bba8532Spatrick 
134627c3d914Spatrick struct qwz_qmi_dev_mem_info {
134727c3d914Spatrick 	uint64_t start;
134827c3d914Spatrick 	uint64_t size;
134927c3d914Spatrick };
135027c3d914Spatrick 
13514bba8532Spatrick enum ath12k_bdf_search {
13524bba8532Spatrick 	ATH12K_BDF_SEARCH_DEFAULT,
13534bba8532Spatrick 	ATH12K_BDF_SEARCH_BUS_AND_BOARD,
13544bba8532Spatrick };
13554bba8532Spatrick 
13564bba8532Spatrick struct qwz_device_id {
13574bba8532Spatrick 	enum ath12k_bdf_search bdf_search;
13584bba8532Spatrick 	uint32_t vendor;
13594bba8532Spatrick 	uint32_t device;
13604bba8532Spatrick 	uint32_t subsystem_vendor;
13614bba8532Spatrick 	uint32_t subsystem_device;
13624bba8532Spatrick };
13634bba8532Spatrick 
13644bba8532Spatrick struct qwz_wmi_base;
13654bba8532Spatrick 
13664bba8532Spatrick struct qwz_pdev_wmi {
13674bba8532Spatrick 	struct qwz_wmi_base *wmi;
13684bba8532Spatrick 	enum ath12k_htc_ep_id eid;
13694bba8532Spatrick 	const struct wmi_peer_flags_map *peer_flags;
13704bba8532Spatrick 	uint32_t rx_decap_mode;
13714bba8532Spatrick };
13724bba8532Spatrick 
13734bba8532Spatrick #define QWZ_MAX_RADIOS 3
13744bba8532Spatrick 
13754bba8532Spatrick struct qwz_wmi_base {
13764bba8532Spatrick 	struct qwz_softc *sc;
13774bba8532Spatrick 	struct qwz_pdev_wmi wmi[QWZ_MAX_RADIOS];
13784bba8532Spatrick 	enum ath12k_htc_ep_id wmi_endpoint_id[QWZ_MAX_RADIOS];
13794bba8532Spatrick 	uint32_t max_msg_len[QWZ_MAX_RADIOS];
13804bba8532Spatrick 	int service_ready;
13814bba8532Spatrick 	int unified_ready;
13824bba8532Spatrick 	uint8_t svc_map[howmany(WMI_MAX_EXT2_SERVICE, 8)];
13834bba8532Spatrick 	int tx_credits;
13844bba8532Spatrick 	const struct wmi_peer_flags_map *peer_flags;
13854bba8532Spatrick 	uint32_t num_mem_chunks;
13864bba8532Spatrick 	uint32_t rx_decap_mode;
13874bba8532Spatrick 	struct wmi_host_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
13884bba8532Spatrick 	enum wmi_host_hw_mode_config_type preferred_hw_mode;
13894bba8532Spatrick 	struct target_resource_config  wlan_resource_config;
13904bba8532Spatrick 	struct ath12k_targ_cap *targ_cap;
13914bba8532Spatrick };
13924bba8532Spatrick 
13934bba8532Spatrick struct wmi_tlv_policy {
13944bba8532Spatrick 	size_t min_len;
13954bba8532Spatrick };
13964bba8532Spatrick 
13974bba8532Spatrick struct wmi_tlv_svc_ready_parse {
13984bba8532Spatrick 	int wmi_svc_bitmap_done;
13994bba8532Spatrick };
14004bba8532Spatrick 
14014bba8532Spatrick struct wmi_tlv_dma_ring_caps_parse {
14024bba8532Spatrick 	struct wmi_dma_ring_capabilities *dma_ring_caps;
14034bba8532Spatrick 	uint32_t n_dma_ring_caps;
14044bba8532Spatrick };
14054bba8532Spatrick 
14064bba8532Spatrick struct wmi_tlv_svc_rdy_ext_parse {
14074bba8532Spatrick 	struct ath12k_service_ext_param param;
14084bba8532Spatrick 	struct wmi_soc_mac_phy_hw_mode_caps *hw_caps;
14094bba8532Spatrick 	struct wmi_hw_mode_capabilities *hw_mode_caps;
14104bba8532Spatrick 	uint32_t n_hw_mode_caps;
14114bba8532Spatrick 	uint32_t tot_phy_id;
14124bba8532Spatrick 	struct wmi_hw_mode_capabilities pref_hw_mode_caps;
14134bba8532Spatrick 	struct wmi_mac_phy_capabilities *mac_phy_caps;
14144bba8532Spatrick 	size_t mac_phy_caps_size;
14154bba8532Spatrick 	uint32_t n_mac_phy_caps;
14164bba8532Spatrick 	struct wmi_soc_hal_reg_capabilities *soc_hal_reg_caps;
14174bba8532Spatrick 	struct wmi_hal_reg_capabilities_ext *ext_hal_reg_caps;
14184bba8532Spatrick 	uint32_t n_ext_hal_reg_caps;
14194bba8532Spatrick 	struct wmi_tlv_dma_ring_caps_parse dma_caps_parse;
14204bba8532Spatrick 	int hw_mode_done;
14214bba8532Spatrick 	int mac_phy_done;
14224bba8532Spatrick 	int ext_hal_reg_done;
14234bba8532Spatrick 	int mac_phy_chainmask_combo_done;
14244bba8532Spatrick 	int mac_phy_chainmask_cap_done;
14254bba8532Spatrick 	int oem_dma_ring_cap_done;
14264bba8532Spatrick 	int dma_ring_cap_done;
14274bba8532Spatrick };
14284bba8532Spatrick 
14294bba8532Spatrick struct wmi_tlv_svc_rdy_ext2_parse {
14304bba8532Spatrick 	struct wmi_tlv_dma_ring_caps_parse dma_caps_parse;
14314bba8532Spatrick 	bool dma_ring_cap_done;
14324bba8532Spatrick };
14334bba8532Spatrick 
14344bba8532Spatrick struct wmi_tlv_rdy_parse {
14354bba8532Spatrick 	uint32_t num_extra_mac_addr;
14364bba8532Spatrick };
14374bba8532Spatrick 
14384bba8532Spatrick struct wmi_tlv_dma_buf_release_parse {
14394bba8532Spatrick 	struct ath12k_wmi_dma_buf_release_fixed_param fixed;
14404bba8532Spatrick 	struct wmi_dma_buf_release_entry *buf_entry;
14414bba8532Spatrick 	struct wmi_dma_buf_release_meta_data *meta_data;
14424bba8532Spatrick 	uint32_t num_buf_entry;
14434bba8532Spatrick 	uint32_t num_meta;
14444bba8532Spatrick 	bool buf_entry_done;
14454bba8532Spatrick 	bool meta_data_done;
14464bba8532Spatrick };
14474bba8532Spatrick 
14484bba8532Spatrick struct wmi_tlv_fw_stats_parse {
14494bba8532Spatrick 	const struct wmi_stats_event *ev;
14504bba8532Spatrick 	const struct wmi_per_chain_rssi_stats *rssi;
14514bba8532Spatrick 	struct ath12k_fw_stats *stats;
14524bba8532Spatrick 	int rssi_num;
14534bba8532Spatrick 	bool chain_rssi_done;
14544bba8532Spatrick };
14554bba8532Spatrick 
14564bba8532Spatrick struct wmi_tlv_mgmt_rx_parse {
14574bba8532Spatrick 	const struct wmi_mgmt_rx_hdr *fixed;
14584bba8532Spatrick 	const uint8_t *frame_buf;
14594bba8532Spatrick 	bool frame_buf_done;
14604bba8532Spatrick };
14614bba8532Spatrick 
14624bba8532Spatrick struct qwz_htc;
14634bba8532Spatrick 
14644bba8532Spatrick struct qwz_htc_ep_ops {
14654bba8532Spatrick 	void (*ep_tx_complete)(struct qwz_softc *, struct mbuf *);
14664bba8532Spatrick 	void (*ep_rx_complete)(struct qwz_softc *, struct mbuf *);
14674bba8532Spatrick 	void (*ep_tx_credits)(struct qwz_softc *);
14684bba8532Spatrick };
14694bba8532Spatrick 
14704bba8532Spatrick /* service connection information */
14714bba8532Spatrick struct qwz_htc_svc_conn_req {
14724bba8532Spatrick 	uint16_t service_id;
14734bba8532Spatrick 	struct qwz_htc_ep_ops ep_ops;
14744bba8532Spatrick 	int max_send_queue_depth;
14754bba8532Spatrick };
14764bba8532Spatrick 
14774bba8532Spatrick /* service connection response information */
14784bba8532Spatrick struct qwz_htc_svc_conn_resp {
14794bba8532Spatrick 	uint8_t buffer_len;
14804bba8532Spatrick 	uint8_t actual_len;
14814bba8532Spatrick 	enum ath12k_htc_ep_id eid;
14824bba8532Spatrick 	unsigned int max_msg_len;
14834bba8532Spatrick 	uint8_t connect_resp_code;
14844bba8532Spatrick };
14854bba8532Spatrick 
14864bba8532Spatrick #define ATH12K_NUM_CONTROL_TX_BUFFERS 2
14874bba8532Spatrick #define ATH12K_HTC_MAX_LEN 4096
14884bba8532Spatrick #define ATH12K_HTC_MAX_CTRL_MSG_LEN 256
14894bba8532Spatrick #define ATH12K_HTC_WAIT_TIMEOUT_HZ (1 * HZ)
14904bba8532Spatrick #define ATH12K_HTC_CONTROL_BUFFER_SIZE (ATH12K_HTC_MAX_CTRL_MSG_LEN + \
14914bba8532Spatrick 					sizeof(struct ath12k_htc_hdr))
14924bba8532Spatrick #define ATH12K_HTC_CONN_SVC_TIMEOUT_HZ (1 * HZ)
14934bba8532Spatrick #define ATH12K_HTC_MAX_SERVICE_ALLOC_ENTRIES 8
14944bba8532Spatrick 
14954bba8532Spatrick struct qwz_htc_ep {
14964bba8532Spatrick 	struct qwz_htc *htc;
14974bba8532Spatrick 	enum ath12k_htc_ep_id eid;
14984bba8532Spatrick 	enum ath12k_htc_svc_id service_id;
14994bba8532Spatrick 	struct qwz_htc_ep_ops ep_ops;
15004bba8532Spatrick 
15014bba8532Spatrick 	int max_tx_queue_depth;
15024bba8532Spatrick 	int max_ep_message_len;
15034bba8532Spatrick 	uint8_t ul_pipe_id;
15044bba8532Spatrick 	uint8_t dl_pipe_id;
15054bba8532Spatrick 
15064bba8532Spatrick 	uint8_t seq_no; /* for debugging */
15074bba8532Spatrick 	int tx_credits;
15084bba8532Spatrick 	bool tx_credit_flow_enabled;
15094bba8532Spatrick };
15104bba8532Spatrick 
15114bba8532Spatrick struct qwz_htc_svc_tx_credits {
15124bba8532Spatrick 	uint16_t service_id;
15134bba8532Spatrick 	uint8_t  credit_allocation;
15144bba8532Spatrick };
15154bba8532Spatrick 
15164bba8532Spatrick struct qwz_htc {
15174bba8532Spatrick 	struct qwz_softc *sc;
15184bba8532Spatrick 	struct qwz_htc_ep endpoint[ATH12K_HTC_EP_COUNT];
15194bba8532Spatrick #ifdef notyet
15204bba8532Spatrick 	/* protects endpoints */
15214bba8532Spatrick 	spinlock_t tx_lock;
15224bba8532Spatrick #endif
15234bba8532Spatrick 	uint8_t control_resp_buffer[ATH12K_HTC_MAX_CTRL_MSG_LEN];
15244bba8532Spatrick 	int control_resp_len;
15254bba8532Spatrick 
15264bba8532Spatrick 	int ctl_resp;
15274bba8532Spatrick 
15284bba8532Spatrick 	int total_transmit_credits;
15294bba8532Spatrick 	struct qwz_htc_svc_tx_credits
15304bba8532Spatrick 		service_alloc_table[ATH12K_HTC_MAX_SERVICE_ALLOC_ENTRIES];
15314bba8532Spatrick 	int target_credit_size;
15324bba8532Spatrick 	uint8_t wmi_ep_count;
15334bba8532Spatrick };
15344bba8532Spatrick 
15354bba8532Spatrick struct qwz_msi_user {
15364bba8532Spatrick 	char *name;
15374bba8532Spatrick 	int num_vectors;
15384bba8532Spatrick 	uint32_t base_vector;
15394bba8532Spatrick };
15404bba8532Spatrick 
15414bba8532Spatrick struct qwz_msi_config {
15424bba8532Spatrick 	int total_vectors;
15434bba8532Spatrick 	int total_users;
15444bba8532Spatrick 	struct qwz_msi_user *users;
15454bba8532Spatrick 	uint16_t hw_rev;
15464bba8532Spatrick };
15474bba8532Spatrick 
15484bba8532Spatrick struct ath12k_band_cap {
15494bba8532Spatrick 	uint32_t phy_id;
15504bba8532Spatrick 	uint32_t max_bw_supported;
15514bba8532Spatrick 	uint32_t ht_cap_info;
15524bba8532Spatrick 	uint32_t he_cap_info[2];
15534bba8532Spatrick 	uint32_t he_mcs;
15544bba8532Spatrick 	uint32_t he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE];
15554bba8532Spatrick 	struct ath12k_ppe_threshold he_ppet;
15564bba8532Spatrick 	uint16_t he_6ghz_capa;
15574bba8532Spatrick };
15584bba8532Spatrick 
15594bba8532Spatrick struct ath12k_pdev_cap {
15604bba8532Spatrick 	uint32_t supported_bands;
15614bba8532Spatrick 	uint32_t ampdu_density;
15624bba8532Spatrick 	uint32_t vht_cap;
15634bba8532Spatrick 	uint32_t vht_mcs;
15644bba8532Spatrick 	uint32_t he_mcs;
15654bba8532Spatrick 	uint32_t tx_chain_mask;
15664bba8532Spatrick 	uint32_t rx_chain_mask;
15674bba8532Spatrick 	uint32_t tx_chain_mask_shift;
15684bba8532Spatrick 	uint32_t rx_chain_mask_shift;
15694bba8532Spatrick 	struct ath12k_band_cap band[WMI_NUM_SUPPORTED_BAND_MAX];
15704bba8532Spatrick 	int nss_ratio_enabled;
15714bba8532Spatrick 	uint8_t nss_ratio_info;
15724bba8532Spatrick };
15734bba8532Spatrick 
15744bba8532Spatrick struct qwz_pdev {
15754bba8532Spatrick 	struct qwz_softc *sc;
15764bba8532Spatrick 	uint32_t pdev_id;
15774bba8532Spatrick 	struct ath12k_pdev_cap cap;
15784bba8532Spatrick 	uint8_t mac_addr[IEEE80211_ADDR_LEN];
15794bba8532Spatrick };
15804bba8532Spatrick 
15814bba8532Spatrick struct qwz_dbring_cap {
15824bba8532Spatrick 	uint32_t pdev_id;
15834bba8532Spatrick 	enum wmi_direct_buffer_module id;
15844bba8532Spatrick 	uint32_t min_elem;
15854bba8532Spatrick 	uint32_t min_buf_sz;
15864bba8532Spatrick 	uint32_t min_buf_align;
15874bba8532Spatrick };
15884bba8532Spatrick 
15894bba8532Spatrick enum hal_rx_mon_status {
15904bba8532Spatrick 	HAL_RX_MON_STATUS_PPDU_NOT_DONE,
15914bba8532Spatrick 	HAL_RX_MON_STATUS_PPDU_DONE,
15924bba8532Spatrick 	HAL_RX_MON_STATUS_BUF_DONE,
15934bba8532Spatrick };
15944bba8532Spatrick 
15954bba8532Spatrick struct hal_rx_user_status {
15964bba8532Spatrick 	uint32_t mcs:4,
15974bba8532Spatrick 	nss:3,
15984bba8532Spatrick 	ofdma_info_valid:1,
15994bba8532Spatrick 	dl_ofdma_ru_start_index:7,
16004bba8532Spatrick 	dl_ofdma_ru_width:7,
16014bba8532Spatrick 	dl_ofdma_ru_size:8;
16024bba8532Spatrick 	uint32_t ul_ofdma_user_v0_word0;
16034bba8532Spatrick 	uint32_t ul_ofdma_user_v0_word1;
16044bba8532Spatrick 	uint32_t ast_index;
16054bba8532Spatrick 	uint32_t tid;
16064bba8532Spatrick 	uint16_t tcp_msdu_count;
16074bba8532Spatrick 	uint16_t udp_msdu_count;
16084bba8532Spatrick 	uint16_t other_msdu_count;
16094bba8532Spatrick 	uint16_t frame_control;
16104bba8532Spatrick 	uint8_t frame_control_info_valid;
16114bba8532Spatrick 	uint8_t data_sequence_control_info_valid;
16124bba8532Spatrick 	uint16_t first_data_seq_ctrl;
16134bba8532Spatrick 	uint32_t preamble_type;
16144bba8532Spatrick 	uint16_t ht_flags;
16154bba8532Spatrick 	uint16_t vht_flags;
16164bba8532Spatrick 	uint16_t he_flags;
16174bba8532Spatrick 	uint8_t rs_flags;
16184bba8532Spatrick 	uint32_t mpdu_cnt_fcs_ok;
16194bba8532Spatrick 	uint32_t mpdu_cnt_fcs_err;
16204bba8532Spatrick 	uint32_t mpdu_fcs_ok_bitmap[8];
16214bba8532Spatrick 	uint32_t mpdu_ok_byte_count;
16224bba8532Spatrick 	uint32_t mpdu_err_byte_count;
16234bba8532Spatrick };
16244bba8532Spatrick 
16254bba8532Spatrick struct hal_rx_wbm_rel_info {
16264bba8532Spatrick 	uint32_t cookie;
16274bba8532Spatrick 	enum hal_wbm_rel_src_module err_rel_src;
16284bba8532Spatrick 	enum hal_reo_dest_ring_push_reason push_reason;
16294bba8532Spatrick 	uint32_t err_code;
16304bba8532Spatrick 	int first_msdu;
16314bba8532Spatrick 	int last_msdu;
16324bba8532Spatrick };
16334bba8532Spatrick 
16344bba8532Spatrick #define HAL_INVALID_PEERID 0xffff
16354bba8532Spatrick #define VHT_SIG_SU_NSS_MASK 0x7
16364bba8532Spatrick 
16374bba8532Spatrick #define HAL_RX_MAX_MCS 12
16384bba8532Spatrick #define HAL_RX_MAX_NSS 8
16394bba8532Spatrick 
16404bba8532Spatrick #define HAL_TLV_STATUS_PPDU_NOT_DONE    HAL_RX_MON_STATUS_PPDU_NOT_DONE
16414bba8532Spatrick #define HAL_TLV_STATUS_PPDU_DONE        HAL_RX_MON_STATUS_PPDU_DONE
16424bba8532Spatrick #define HAL_TLV_STATUS_BUF_DONE         HAL_RX_MON_STATUS_BUF_DONE
16434bba8532Spatrick 
16444bba8532Spatrick struct hal_rx_mon_ppdu_info {
16454bba8532Spatrick 	uint32_t ppdu_id;
16464bba8532Spatrick 	uint32_t ppdu_ts;
16474bba8532Spatrick 	uint32_t num_mpdu_fcs_ok;
16484bba8532Spatrick 	uint32_t num_mpdu_fcs_err;
16494bba8532Spatrick 	uint32_t preamble_type;
16504bba8532Spatrick 	uint16_t chan_num;
16514bba8532Spatrick 	uint16_t tcp_msdu_count;
16524bba8532Spatrick 	uint16_t tcp_ack_msdu_count;
16534bba8532Spatrick 	uint16_t udp_msdu_count;
16544bba8532Spatrick 	uint16_t other_msdu_count;
16554bba8532Spatrick 	uint16_t peer_id;
16564bba8532Spatrick 	uint8_t rate;
16574bba8532Spatrick 	uint8_t mcs;
16584bba8532Spatrick 	uint8_t nss;
16594bba8532Spatrick 	uint8_t bw;
16604bba8532Spatrick 	uint8_t vht_flag_values1;
16614bba8532Spatrick 	uint8_t vht_flag_values2;
16624bba8532Spatrick 	uint8_t vht_flag_values3[4];
16634bba8532Spatrick 	uint8_t vht_flag_values4;
16644bba8532Spatrick 	uint8_t vht_flag_values5;
16654bba8532Spatrick 	uint16_t vht_flag_values6;
16664bba8532Spatrick 	uint8_t is_stbc;
16674bba8532Spatrick 	uint8_t gi;
16684bba8532Spatrick 	uint8_t ldpc;
16694bba8532Spatrick 	uint8_t beamformed;
16704bba8532Spatrick 	uint8_t rssi_comb;
16714bba8532Spatrick 	uint8_t rssi_chain_pri20[HAL_RX_MAX_NSS];
16724bba8532Spatrick 	uint8_t tid;
16734bba8532Spatrick 	uint16_t ht_flags;
16744bba8532Spatrick 	uint16_t vht_flags;
16754bba8532Spatrick 	uint16_t he_flags;
16764bba8532Spatrick 	uint16_t he_mu_flags;
16774bba8532Spatrick 	uint8_t dcm;
16784bba8532Spatrick 	uint8_t ru_alloc;
16794bba8532Spatrick 	uint8_t reception_type;
16804bba8532Spatrick 	uint64_t tsft;
16814bba8532Spatrick 	uint64_t rx_duration;
16824bba8532Spatrick 	uint16_t frame_control;
16834bba8532Spatrick 	uint32_t ast_index;
16844bba8532Spatrick 	uint8_t rs_fcs_err;
16854bba8532Spatrick 	uint8_t rs_flags;
16864bba8532Spatrick 	uint8_t cck_flag;
16874bba8532Spatrick 	uint8_t ofdm_flag;
16884bba8532Spatrick 	uint8_t ulofdma_flag;
16894bba8532Spatrick 	uint8_t frame_control_info_valid;
16904bba8532Spatrick 	uint16_t he_per_user_1;
16914bba8532Spatrick 	uint16_t he_per_user_2;
16924bba8532Spatrick 	uint8_t he_per_user_position;
16934bba8532Spatrick 	uint8_t he_per_user_known;
16944bba8532Spatrick 	uint16_t he_flags1;
16954bba8532Spatrick 	uint16_t he_flags2;
16964bba8532Spatrick 	uint8_t he_RU[4];
16974bba8532Spatrick 	uint16_t he_data1;
16984bba8532Spatrick 	uint16_t he_data2;
16994bba8532Spatrick 	uint16_t he_data3;
17004bba8532Spatrick 	uint16_t he_data4;
17014bba8532Spatrick 	uint16_t he_data5;
17024bba8532Spatrick 	uint16_t he_data6;
17034bba8532Spatrick 	uint32_t ppdu_len;
17044bba8532Spatrick 	uint32_t prev_ppdu_id;
17054bba8532Spatrick 	uint32_t device_id;
17064bba8532Spatrick 	uint16_t first_data_seq_ctrl;
17074bba8532Spatrick 	uint8_t monitor_direct_used;
17084bba8532Spatrick 	uint8_t data_sequence_control_info_valid;
17094bba8532Spatrick 	uint8_t ltf_size;
17104bba8532Spatrick 	uint8_t rxpcu_filter_pass;
17114bba8532Spatrick 	char rssi_chain[8][8];
17124bba8532Spatrick 	struct hal_rx_user_status userstats;
17134bba8532Spatrick };
17144bba8532Spatrick 
17154bba8532Spatrick enum dp_mon_status_buf_state {
17164bba8532Spatrick 	/* PPDU id matches in dst ring and status ring */
17174bba8532Spatrick 	DP_MON_STATUS_MATCH,
17184bba8532Spatrick 	/* status ring dma is not done */
17194bba8532Spatrick 	DP_MON_STATUS_NO_DMA,
17204bba8532Spatrick 	/* status ring is lagging, reap status ring */
17214bba8532Spatrick 	DP_MON_STATUS_LAG,
17224bba8532Spatrick 	/* status ring is leading, reap dst ring and drop */
17234bba8532Spatrick 	DP_MON_STATUS_LEAD,
17244bba8532Spatrick 	/* replinish monitor status ring */
17254bba8532Spatrick 	DP_MON_STATUS_REPLINISH,
17264bba8532Spatrick };
17274bba8532Spatrick 
17284bba8532Spatrick struct qwz_pdev_mon_stats {
17294bba8532Spatrick 	uint32_t status_ppdu_state;
17304bba8532Spatrick 	uint32_t status_ppdu_start;
17314bba8532Spatrick 	uint32_t status_ppdu_end;
17324bba8532Spatrick 	uint32_t status_ppdu_compl;
17334bba8532Spatrick 	uint32_t status_ppdu_start_mis;
17344bba8532Spatrick 	uint32_t status_ppdu_end_mis;
17354bba8532Spatrick 	uint32_t status_ppdu_done;
17364bba8532Spatrick 	uint32_t dest_ppdu_done;
17374bba8532Spatrick 	uint32_t dest_mpdu_done;
17384bba8532Spatrick 	uint32_t dest_mpdu_drop;
17394bba8532Spatrick 	uint32_t dup_mon_linkdesc_cnt;
17404bba8532Spatrick 	uint32_t dup_mon_buf_cnt;
17414bba8532Spatrick 	uint32_t dest_mon_stuck;
17424bba8532Spatrick 	uint32_t dest_mon_not_reaped;
17434bba8532Spatrick };
17444bba8532Spatrick 
17454bba8532Spatrick struct qwz_mon_data {
17464bba8532Spatrick 	struct dp_link_desc_bank link_desc_banks[DP_LINK_DESC_BANKS_MAX];
17474bba8532Spatrick 	struct hal_rx_mon_ppdu_info mon_ppdu_info;
17484bba8532Spatrick 
17494bba8532Spatrick 	uint32_t mon_ppdu_status;
17504bba8532Spatrick 	uint32_t mon_last_buf_cookie;
17514bba8532Spatrick 	uint64_t mon_last_linkdesc_paddr;
17524bba8532Spatrick 	uint16_t chan_noise_floor;
17534bba8532Spatrick 	bool hold_mon_dst_ring;
17544bba8532Spatrick 	enum dp_mon_status_buf_state buf_state;
17554bba8532Spatrick 	bus_addr_t mon_status_paddr;
17564bba8532Spatrick 	struct dp_full_mon_mpdu *mon_mpdu;
17574bba8532Spatrick #ifdef notyet
17584bba8532Spatrick 	struct hal_sw_mon_ring_entries sw_mon_entries;
17594bba8532Spatrick #endif
17604bba8532Spatrick 	struct qwz_pdev_mon_stats rx_mon_stats;
17614bba8532Spatrick #ifdef notyet
17624bba8532Spatrick 	/* lock for monitor data */
17634bba8532Spatrick 	spinlock_t mon_lock;
17644bba8532Spatrick 	struct sk_buff_head rx_status_q;
17654bba8532Spatrick #endif
17664bba8532Spatrick };
17674bba8532Spatrick 
17684bba8532Spatrick 
17694bba8532Spatrick struct qwz_pdev_dp {
17704bba8532Spatrick 	uint32_t mac_id;
17714bba8532Spatrick #if 0
17724bba8532Spatrick 	atomic_t num_tx_pending;
17734bba8532Spatrick 	wait_queue_head_t tx_empty_waitq;
17744bba8532Spatrick #endif
177527c3d914Spatrick 	struct dp_srng rxdma_mon_dst_ring[MAX_RXDMA_PER_PDEV];
177627c3d914Spatrick 	struct dp_srng tx_mon_dst_ring[MAX_RXDMA_PER_PDEV];
17774bba8532Spatrick #if 0
17784bba8532Spatrick 	struct ieee80211_rx_status rx_status;
17794bba8532Spatrick #endif
17804bba8532Spatrick 	struct qwz_mon_data mon_data;
17814bba8532Spatrick };
17824bba8532Spatrick 
17834bba8532Spatrick struct qwz_txmgmt_queue {
17844bba8532Spatrick 	struct qwz_tx_data data[8];
17854bba8532Spatrick 	int cur;
17864bba8532Spatrick 	int queued;
17874bba8532Spatrick };
17884bba8532Spatrick 
17894bba8532Spatrick struct qwz_vif {
17904bba8532Spatrick 	uint32_t vdev_id;
17914bba8532Spatrick 	enum wmi_vdev_type vdev_type;
17924bba8532Spatrick 	enum wmi_vdev_subtype vdev_subtype;
17934bba8532Spatrick 	uint32_t beacon_interval;
17944bba8532Spatrick 	uint32_t dtim_period;
17954bba8532Spatrick 	uint16_t ast_hash;
17964bba8532Spatrick 	uint16_t ast_idx;
17974bba8532Spatrick 	uint16_t tcl_metadata;
17984bba8532Spatrick 	uint8_t hal_addr_search_flags;
17994bba8532Spatrick 	uint8_t search_type;
18004bba8532Spatrick 
18014bba8532Spatrick 	struct qwz_softc *sc;
18024bba8532Spatrick 
18034bba8532Spatrick 	uint16_t tx_seq_no;
18044bba8532Spatrick 	struct wmi_wmm_params_all_arg wmm_params;
18054bba8532Spatrick 	TAILQ_ENTRY(qwz_vif) entry;
18064bba8532Spatrick 	union {
18074bba8532Spatrick 		struct {
18084bba8532Spatrick 			uint32_t uapsd;
18094bba8532Spatrick 		} sta;
18104bba8532Spatrick 		struct {
18114bba8532Spatrick 			/* 127 stations; wmi limit */
18124bba8532Spatrick 			uint8_t tim_bitmap[16];
18134bba8532Spatrick 			uint8_t tim_len;
18144bba8532Spatrick 			uint32_t ssid_len;
18154bba8532Spatrick 			uint8_t ssid[IEEE80211_NWID_LEN];
18164bba8532Spatrick 			bool hidden_ssid;
18174bba8532Spatrick 			/* P2P_IE with NoA attribute for P2P_GO case */
18184bba8532Spatrick 			uint32_t noa_len;
18194bba8532Spatrick 			uint8_t *noa_data;
18204bba8532Spatrick 		} ap;
18214bba8532Spatrick 	} u;
18224bba8532Spatrick 
18234bba8532Spatrick 	bool is_started;
18244bba8532Spatrick 	bool is_up;
18254bba8532Spatrick 	bool ftm_responder;
18264bba8532Spatrick 	bool spectral_enabled;
18274bba8532Spatrick 	bool ps;
18284bba8532Spatrick 	uint32_t aid;
18294bba8532Spatrick 	uint8_t bssid[IEEE80211_ADDR_LEN];
18304bba8532Spatrick #if 0
18314bba8532Spatrick 	struct cfg80211_bitrate_mask bitrate_mask;
18324bba8532Spatrick 	struct delayed_work connection_loss_work;
18334bba8532Spatrick #endif
18344bba8532Spatrick 	int num_legacy_stations;
18354bba8532Spatrick 	int rtscts_prot_mode;
18364bba8532Spatrick 	int txpower;
18374bba8532Spatrick 	bool rsnie_present;
18384bba8532Spatrick 	bool wpaie_present;
18394bba8532Spatrick 	bool bcca_zero_sent;
18404bba8532Spatrick 	bool do_not_send_tmpl;
18414bba8532Spatrick 	struct ieee80211_channel *chan;
18424bba8532Spatrick #if 0
18434bba8532Spatrick 	struct ath12k_arp_ns_offload arp_ns_offload;
18444bba8532Spatrick 	struct ath12k_rekey_data rekey_data;
18454bba8532Spatrick #endif
18464bba8532Spatrick #ifdef CONFIG_ATH12K_DEBUGFS
18474bba8532Spatrick 	struct dentry *debugfs_twt;
18484bba8532Spatrick #endif /* CONFIG_ATH12K_DEBUGFS */
18494bba8532Spatrick 
18504bba8532Spatrick 	struct qwz_txmgmt_queue txmgmt;
18514bba8532Spatrick };
18524bba8532Spatrick 
18534bba8532Spatrick TAILQ_HEAD(qwz_vif_list, qwz_vif);
18544bba8532Spatrick 
18554bba8532Spatrick struct qwz_survey_info {
18564bba8532Spatrick 	int8_t noise;
18574bba8532Spatrick 	uint64_t time;
18584bba8532Spatrick 	uint64_t time_busy;
18594bba8532Spatrick };
18604bba8532Spatrick 
18614bba8532Spatrick #define ATH12K_IRQ_NUM_MAX 52
18624bba8532Spatrick #define ATH12K_EXT_IRQ_NUM_MAX	16
18634bba8532Spatrick 
18644bba8532Spatrick struct qwz_ext_irq_grp {
18654bba8532Spatrick 	struct qwz_softc *sc;
18664bba8532Spatrick 	uint32_t irqs[ATH12K_EXT_IRQ_NUM_MAX];
18674bba8532Spatrick 	uint32_t num_irq;
18684bba8532Spatrick 	uint32_t grp_id;
18694bba8532Spatrick 	uint64_t timestamp;
18704bba8532Spatrick #if 0
18714bba8532Spatrick 	bool napi_enabled;
18724bba8532Spatrick 	struct napi_struct napi;
18734bba8532Spatrick 	struct net_device napi_ndev;
18744bba8532Spatrick #endif
18754bba8532Spatrick };
18764bba8532Spatrick 
18774bba8532Spatrick struct qwz_rx_radiotap_header {
18784bba8532Spatrick 	struct ieee80211_radiotap_header wr_ihdr;
18794bba8532Spatrick } __packed;
18804bba8532Spatrick 
18814bba8532Spatrick #define IWX_RX_RADIOTAP_PRESENT	0 /* TODO add more information */
18824bba8532Spatrick 
18834bba8532Spatrick struct qwz_tx_radiotap_header {
18844bba8532Spatrick 	struct ieee80211_radiotap_header wt_ihdr;
18854bba8532Spatrick } __packed;
18864bba8532Spatrick 
18874bba8532Spatrick #define IWX_TX_RADIOTAP_PRESENT	0 /* TODO add more information */
18884bba8532Spatrick 
18894bba8532Spatrick struct qwz_setkey_task_arg {
18904bba8532Spatrick 	struct ieee80211_node *ni;
18914bba8532Spatrick 	struct ieee80211_key *k;
18924bba8532Spatrick 	int cmd;
18934bba8532Spatrick #define QWZ_ADD_KEY	1
18944bba8532Spatrick #define QWZ_DEL_KEY	2
18954bba8532Spatrick };
18964bba8532Spatrick 
18974bba8532Spatrick struct qwz_softc {
18984bba8532Spatrick 	struct device			sc_dev;
18994bba8532Spatrick 	struct ieee80211com		sc_ic;
19004bba8532Spatrick 	uint32_t			sc_flags;
19014bba8532Spatrick 	int				sc_node;
19024bba8532Spatrick 
19034bba8532Spatrick 	int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int);
19044bba8532Spatrick 
19054bba8532Spatrick 	struct rwlock ioctl_rwl;
19064bba8532Spatrick 
19074bba8532Spatrick 	struct task		init_task; /* NB: not reference-counted */
19084bba8532Spatrick 	struct refcnt		task_refs;
19094bba8532Spatrick 	struct taskq		*sc_nswq;
19104bba8532Spatrick 	struct task		newstate_task;
19114bba8532Spatrick 	enum ieee80211_state	ns_nstate;
19124bba8532Spatrick 	int			ns_arg;
19134bba8532Spatrick 
19144bba8532Spatrick 	/* Task for setting encryption keys and its arguments. */
19154bba8532Spatrick 	struct task		setkey_task;
19164bba8532Spatrick 	/*
19174bba8532Spatrick 	 * At present we need to process at most two keys at once:
19184bba8532Spatrick 	 * Our pairwise key and a group key.
19194bba8532Spatrick 	 * When hostap mode is implemented this array needs to grow or
19204bba8532Spatrick 	 * it might become a bottleneck for associations that occur at
19214bba8532Spatrick 	 * roughly the same time.
19224bba8532Spatrick 	 */
19234bba8532Spatrick 	struct qwz_setkey_task_arg setkey_arg[2];
19244bba8532Spatrick 	int setkey_cur;
19254bba8532Spatrick 	int setkey_tail;
19264bba8532Spatrick 	int setkey_nkeys;
19274bba8532Spatrick 
19284bba8532Spatrick 	int install_key_done;
19294bba8532Spatrick 	int install_key_status;
19304bba8532Spatrick 
19314bba8532Spatrick 	enum ath12k_11d_state	state_11d;
19324bba8532Spatrick 	int			completed_11d_scan;
19334bba8532Spatrick 	uint32_t		vdev_id_11d_scan;
19344bba8532Spatrick 	struct {
19354bba8532Spatrick 		int started;
19364bba8532Spatrick 		int completed;
19374bba8532Spatrick 		int on_channel;
19384bba8532Spatrick 		struct timeout timeout;
19394bba8532Spatrick 		enum ath12k_scan_state state;
19404bba8532Spatrick 		int vdev_id;
19414bba8532Spatrick 		int is_roc;
19424bba8532Spatrick 		int roc_freq;
19434bba8532Spatrick 		int roc_notify;
19444bba8532Spatrick 	} scan;
19454bba8532Spatrick 	u_int			scan_channel;
19464bba8532Spatrick 	struct qwz_survey_info	survey[IEEE80211_CHAN_MAX];
19474bba8532Spatrick 
19484bba8532Spatrick 	int			attached;
19494bba8532Spatrick 	struct {
19504bba8532Spatrick 		u_char *data;
19514bba8532Spatrick 		size_t size;
1952aff7e5a9Spatrick 	} fw_img[3];
19534bba8532Spatrick #define QWZ_FW_AMSS	0
19544bba8532Spatrick #define QWZ_FW_BOARD	1
19554bba8532Spatrick #define QWZ_FW_M3	2
19564bba8532Spatrick 
19574bba8532Spatrick 	int			sc_tx_timer;
19584bba8532Spatrick 	uint32_t		qfullmsk;
19594bba8532Spatrick #define	QWZ_MGMT_QUEUE_ID	31
19604bba8532Spatrick 
19614bba8532Spatrick 	bus_addr_t			mem;
19624bba8532Spatrick 	struct ath12k_hw_params		hw_params;
19634bba8532Spatrick 	struct ath12k_hal		hal;
19644bba8532Spatrick 	struct qwz_ce			ce;
19654bba8532Spatrick 	struct qwz_dp			dp;
19664bba8532Spatrick 	struct qwz_pdev_dp		pdev_dp;
19674bba8532Spatrick 	struct qwz_wmi_base		wmi;
19684bba8532Spatrick 	struct qwz_htc			htc;
1969eb49c7f0Spatrick 	const struct hal_rx_ops		*hal_rx_ops;
1970eb49c7f0Spatrick 	uint32_t			wmi_conf_rx_decap_mode;
19714bba8532Spatrick 
19724bba8532Spatrick 	enum ath12k_firmware_mode	fw_mode;
19734bba8532Spatrick 	enum ath12k_crypt_mode		crypto_mode;
19744bba8532Spatrick 	enum ath12k_hw_txrx_mode	frame_mode;
19754bba8532Spatrick 
19764bba8532Spatrick 	struct qwz_ext_irq_grp		ext_irq_grp[ATH12K_EXT_IRQ_GRP_NUM_MAX];
19774bba8532Spatrick 
19784bba8532Spatrick 	uint16_t			qmi_txn_id;
19794bba8532Spatrick 	int				qmi_cal_done;
19804bba8532Spatrick 	struct qwz_qmi_ce_cfg		qmi_ce_cfg;
19814bba8532Spatrick 	struct qwz_qmi_target_info	qmi_target;
198227c3d914Spatrick 	struct qwz_qmi_dev_mem_info	qmi_dev_mem[ATH12K_QMI_WLFW_MAX_DEV_MEM_NUM_V01];
19834bba8532Spatrick 	struct ath12k_targ_cap		target_caps;
19844bba8532Spatrick 	int				num_radios;
1985eb49c7f0Spatrick 	uint8_t				device_id;
19864bba8532Spatrick 	uint32_t			cc_freq_hz;
19874bba8532Spatrick 	uint32_t			cfg_tx_chainmask;
19884bba8532Spatrick 	uint32_t			cfg_rx_chainmask;
19894bba8532Spatrick 	int				num_tx_chains;
19904bba8532Spatrick 	int				num_rx_chains;
19914bba8532Spatrick 	int				num_created_vdevs;
19924bba8532Spatrick 	int				num_started_vdevs;
19934bba8532Spatrick 	uint32_t			allocated_vdev_map;
19944bba8532Spatrick 	uint32_t			free_vdev_map;
19954bba8532Spatrick 	int				num_peers;
19964bba8532Spatrick 	int				peer_mapped;
19974bba8532Spatrick 	int				peer_delete_done;
19984bba8532Spatrick 	int				vdev_setup_done;
19994bba8532Spatrick 	int				peer_assoc_done;
20004bba8532Spatrick 
20014bba8532Spatrick 	struct qwz_dbring_cap	*db_caps;
20024bba8532Spatrick 	uint32_t		 num_db_cap;
20034bba8532Spatrick 
20044bba8532Spatrick 	uint8_t		mac_addr[IEEE80211_ADDR_LEN];
20054bba8532Spatrick 	int		wmi_ready;
20064bba8532Spatrick 	uint32_t	wlan_init_status;
20074bba8532Spatrick 
20084bba8532Spatrick 	uint32_t pktlog_defs_checksum;
20094bba8532Spatrick 
20104bba8532Spatrick 	struct qwz_vif_list vif_list;
20114bba8532Spatrick 	struct qwz_pdev pdevs[MAX_RADIOS];
20124bba8532Spatrick 	struct {
20134bba8532Spatrick 		enum WMI_HOST_WLAN_BAND supported_bands;
20144bba8532Spatrick 		uint32_t pdev_id;
20154bba8532Spatrick 	} target_pdev_ids[MAX_RADIOS];
20164bba8532Spatrick 	uint8_t target_pdev_count;
20174bba8532Spatrick 	uint32_t pdevs_active;
20184bba8532Spatrick 	int pdevs_macaddr_valid;
20194bba8532Spatrick 	struct ath12k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS];
20204bba8532Spatrick 
20214bba8532Spatrick 	struct {
20224bba8532Spatrick 		uint32_t service;
20234bba8532Spatrick 		uint32_t instance;
20244bba8532Spatrick 		uint32_t node;
20254bba8532Spatrick 		uint32_t port;
20264bba8532Spatrick 	} qrtr_server;
20274bba8532Spatrick 
20284bba8532Spatrick 	struct qmi_response_type_v01	qmi_resp;
20294bba8532Spatrick 
20304bba8532Spatrick 	struct qwz_dmamem		*fwmem;
20314bba8532Spatrick 	int				 expect_fwmem_req;
20324bba8532Spatrick 	int				 fwmem_ready;
2033aff7e5a9Spatrick 	int				 fw_ready;
20344bba8532Spatrick 
20354bba8532Spatrick 	int				 ctl_resp;
20364bba8532Spatrick 
20374bba8532Spatrick 	struct qwz_dmamem		*m3_mem;
20384bba8532Spatrick 
20394bba8532Spatrick 	struct timeout			 mon_reap_timer;
20404bba8532Spatrick #define ATH12K_MON_TIMER_INTERVAL	10
20414bba8532Spatrick 
20424bba8532Spatrick 	/* Provided by attachment driver: */
20434bba8532Spatrick 	struct qwz_ops			ops;
20444bba8532Spatrick 	bus_dma_tag_t			sc_dmat;
20454bba8532Spatrick 	enum ath12k_hw_rev		sc_hw_rev;
204627c3d914Spatrick 	int				static_window_map;
20474bba8532Spatrick 	struct qwz_device_id		id;
20484bba8532Spatrick 	char				sc_bus_str[4]; /* "pci" or "ahb" */
20494bba8532Spatrick 	int				num_msivec;
20504bba8532Spatrick 	uint32_t			msi_addr_lo;
20514bba8532Spatrick 	uint32_t			msi_addr_hi;
20524bba8532Spatrick 	uint32_t			msi_data_start;
20534bba8532Spatrick 	const struct qwz_msi_config	*msi_cfg;
20544bba8532Spatrick 	uint32_t			msi_ce_irqmask;
20554bba8532Spatrick 
20564bba8532Spatrick 	struct qmi_wlanfw_request_mem_ind_msg_v01 *sc_req_mem_ind;
20574bba8532Spatrick 
20584bba8532Spatrick 	caddr_t			sc_drvbpf;
20594bba8532Spatrick 
20604bba8532Spatrick 	union {
20614bba8532Spatrick 		struct qwz_rx_radiotap_header th;
20624bba8532Spatrick 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
20634bba8532Spatrick 	} sc_rxtapu;
20644bba8532Spatrick #define sc_rxtap	sc_rxtapu.th
20654bba8532Spatrick 	int			sc_rxtap_len;
20664bba8532Spatrick 
20674bba8532Spatrick 	union {
20684bba8532Spatrick 		struct qwz_tx_radiotap_header th;
20694bba8532Spatrick 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
20704bba8532Spatrick 	} sc_txtapu;
20714bba8532Spatrick #define sc_txtap	sc_txtapu.th
20724bba8532Spatrick 	int			sc_txtap_len;
20734bba8532Spatrick };
20744bba8532Spatrick 
20754bba8532Spatrick int	qwz_ce_intr(void *);
20764bba8532Spatrick int	qwz_ext_intr(void *);
20774bba8532Spatrick int	qwz_dp_service_srng(struct qwz_softc *, int);
20784bba8532Spatrick 
20794bba8532Spatrick int	qwz_init_hw_params(struct qwz_softc *);
20804bba8532Spatrick int	qwz_attach(struct qwz_softc *);
20814bba8532Spatrick void	qwz_detach(struct qwz_softc *);
20824bba8532Spatrick int	qwz_activate(struct device *, int);
20834bba8532Spatrick 
20844bba8532Spatrick void	qwz_core_deinit(struct qwz_softc *);
20854bba8532Spatrick void	qwz_ce_cleanup_pipes(struct qwz_softc *);
20864bba8532Spatrick 
20874bba8532Spatrick int	qwz_ioctl(struct ifnet *, u_long, caddr_t);
20884bba8532Spatrick void	qwz_start(struct ifnet *);
20894bba8532Spatrick void	qwz_watchdog(struct ifnet *);
20904bba8532Spatrick int	qwz_media_change(struct ifnet *);
20914bba8532Spatrick void	qwz_init_task(void *);
20924bba8532Spatrick int	qwz_newstate(struct ieee80211com *, enum ieee80211_state, int);
20934bba8532Spatrick void	qwz_newstate_task(void *);
20944bba8532Spatrick 
20954bba8532Spatrick struct ath12k_peer {
20964bba8532Spatrick #if 0
20974bba8532Spatrick 	struct list_head list;
20984bba8532Spatrick 	struct ieee80211_sta *sta;
20994bba8532Spatrick #endif
21004bba8532Spatrick 	int vdev_id;
21014bba8532Spatrick #if 0
21024bba8532Spatrick 	u8 addr[ETH_ALEN];
21034bba8532Spatrick #endif
21044bba8532Spatrick 	int peer_id;
21054bba8532Spatrick 	uint16_t ast_hash;
21064bba8532Spatrick 	uint8_t pdev_id;
21074bba8532Spatrick 	uint16_t hw_peer_id;
21084bba8532Spatrick #if 0
21094bba8532Spatrick 	/* protected by ab->data_lock */
21104bba8532Spatrick 	struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
21114bba8532Spatrick #endif
21124bba8532Spatrick 	struct dp_rx_tid rx_tid[IEEE80211_NUM_TID + 1];
21134bba8532Spatrick #if 0
21144bba8532Spatrick 	/* peer id based rhashtable list pointer */
21154bba8532Spatrick 	struct rhash_head rhash_id;
21164bba8532Spatrick 	/* peer addr based rhashtable list pointer */
21174bba8532Spatrick 	struct rhash_head rhash_addr;
21184bba8532Spatrick 
21194bba8532Spatrick 	/* Info used in MMIC verification of
21204bba8532Spatrick 	 * RX fragments
21214bba8532Spatrick 	 */
21224bba8532Spatrick 	struct crypto_shash *tfm_mmic;
21234bba8532Spatrick 	u8 mcast_keyidx;
21244bba8532Spatrick 	u8 ucast_keyidx;
21254bba8532Spatrick 	u16 sec_type;
21264bba8532Spatrick 	u16 sec_type_grp;
21274bba8532Spatrick 	bool is_authorized;
21284bba8532Spatrick 	bool dp_setup_done;
21294bba8532Spatrick #endif
21304bba8532Spatrick };
21314bba8532Spatrick 
21324bba8532Spatrick struct qwz_node {
21334bba8532Spatrick 	struct ieee80211_node ni;
21344bba8532Spatrick 	struct ath12k_peer peer;
21354bba8532Spatrick 	unsigned int flags;
21364bba8532Spatrick #define QWZ_NODE_FLAG_HAVE_PAIRWISE_KEY	0x01
21374bba8532Spatrick #define QWZ_NODE_FLAG_HAVE_GROUP_KEY	0x02
21384bba8532Spatrick };
21394bba8532Spatrick 
21404bba8532Spatrick struct ieee80211_node *qwz_node_alloc(struct ieee80211com *);
21414bba8532Spatrick int	qwz_set_key(struct ieee80211com *, struct ieee80211_node *,
21424bba8532Spatrick     struct ieee80211_key *);
21434bba8532Spatrick void	qwz_delete_key(struct ieee80211com *, struct ieee80211_node *,
21444bba8532Spatrick     struct ieee80211_key *);
21454bba8532Spatrick 
21464bba8532Spatrick void	qwz_qrtr_recv_msg(struct qwz_softc *, struct mbuf *);
21474bba8532Spatrick 
21484bba8532Spatrick int	qwz_hal_srng_init(struct qwz_softc *);
21494bba8532Spatrick 
21504bba8532Spatrick int	qwz_ce_alloc_pipes(struct qwz_softc *);
21514bba8532Spatrick void	qwz_ce_free_pipes(struct qwz_softc *);
21524bba8532Spatrick void	qwz_ce_rx_post_buf(struct qwz_softc *);
21534bba8532Spatrick void	qwz_ce_get_shadow_config(struct qwz_softc *, uint32_t **, uint32_t *);
21544bba8532Spatrick 
21554bba8532Spatrick static inline unsigned int
21564bba8532Spatrick qwz_roundup_pow_of_two(unsigned int i)
21574bba8532Spatrick {
21584bba8532Spatrick 	return (powerof2(i) ? i : (1 << (fls(i) - 1)));
21594bba8532Spatrick }
21604bba8532Spatrick 
21614bba8532Spatrick static inline unsigned int
21624bba8532Spatrick qwz_ce_get_attr_flags(struct qwz_softc *sc, int ce_id)
21634bba8532Spatrick {
21644bba8532Spatrick 	KASSERT(ce_id < sc->hw_params.ce_count);
21654bba8532Spatrick 	return sc->hw_params.host_ce_config[ce_id].flags;
21664bba8532Spatrick }
21674bba8532Spatrick 
21684bba8532Spatrick static inline enum ieee80211_edca_ac qwz_tid_to_ac(uint32_t tid)
21694bba8532Spatrick {
21704bba8532Spatrick 	return (((tid == 0) || (tid == 3)) ? EDCA_AC_BE :
21714bba8532Spatrick 		((tid == 1) || (tid == 2)) ? EDCA_AC_BK :
21724bba8532Spatrick 		((tid == 4) || (tid == 5)) ? EDCA_AC_VI :
21734bba8532Spatrick 		EDCA_AC_VO);
21744bba8532Spatrick }
2175