1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef ATH11K_HAL_TX_H
7 #define ATH11K_HAL_TX_H
8 
9 #include "hal_desc.h"
10 
11 #define HAL_TX_ADDRX_EN			1
12 #define HAL_TX_ADDRY_EN			2
13 
14 #define HAL_TX_ADDR_SEARCH_DEFAULT	0
15 #define HAL_TX_ADDR_SEARCH_INDEX	1
16 
17 struct hal_tx_info {
18 	u16 meta_data_flags; /* %HAL_TCL_DATA_CMD_INFO0_META_ */
19 	u8 ring_id;
20 	u32 desc_id;
21 	enum hal_tcl_desc_type type;
22 	enum hal_tcl_encap_type encap_type;
23 	dma_addr_t paddr;
24 	u32 data_len;
25 	u32 pkt_offset;
26 	enum hal_encrypt_type encrypt_type;
27 	u32 flags0; /* %HAL_TCL_DATA_CMD_INFO1_ */
28 	u32 flags1; /* %HAL_TCL_DATA_CMD_INFO2_ */
29 	u16 addr_search_flags; /* %HAL_TCL_DATA_CMD_INFO0_ADDR(X/Y)_ */
30 	u16 bss_ast_hash;
31 	u8 tid;
32 	u8 search_type; /* %HAL_TX_ADDR_SEARCH_ */
33 	u8 lmac_id;
34 	u8 dscp_tid_tbl_idx;
35 };
36 
37 /* TODO: Check if the actual desc macros can be used instead */
38 #define HAL_TX_STATUS_FLAGS_FIRST_MSDU		BIT(0)
39 #define HAL_TX_STATUS_FLAGS_LAST_MSDU		BIT(1)
40 #define HAL_TX_STATUS_FLAGS_MSDU_IN_AMSDU	BIT(2)
41 #define HAL_TX_STATUS_FLAGS_RATE_STATS_VALID	BIT(3)
42 #define HAL_TX_STATUS_FLAGS_RATE_LDPC		BIT(4)
43 #define HAL_TX_STATUS_FLAGS_RATE_STBC		BIT(5)
44 #define HAL_TX_STATUS_FLAGS_OFDMA		BIT(6)
45 
46 #define HAL_TX_STATUS_DESC_LEN		sizeof(struct hal_wbm_release_ring)
47 
48 /* Tx status parsed from srng desc */
49 struct hal_tx_status {
50 	enum hal_wbm_rel_src_module buf_rel_source;
51 	u32 desc_id;
52 	enum hal_wbm_tqm_rel_reason status;
53 	u8 ack_rssi;
54 	enum hal_tx_rate_stats_bw bw;
55 	enum hal_tx_rate_stats_pkt_type pkt_type;
56 	enum hal_tx_rate_stats_sgi sgi;
57 	u8 mcs;
58 	u16 num_tones_in_ru;
59 	u32 flags; /* %HAL_TX_STATUS_FLAGS_ */
60 	u32 tsf;
61 	u32 ppdu_id;
62 	u8 try_cnt;
63 	u8 tid;
64 	u16 peer_id;
65 };
66 
67 void ath11k_hal_tx_cmd_desc_setup(struct ath11k_base *ab, void *cmd,
68 				  struct hal_tx_info *ti);
69 void ath11k_hal_tx_desc_sync(void *tx_desc_cached, void *hw_desc);
70 void ath11k_hal_tx_status_parse(struct ath11k_base *ab,
71 				struct hal_wbm_release_ring *desc,
72 				struct hal_tx_status *ts);
73 void ath11k_hal_tx_status_desc_sync(void *hw_desc, void *local_desc);
74 void ath11k_hal_tx_set_dscp_tid_map(struct ath11k_base *ab, int id);
75 int ath11k_hal_reo_cmd_send(struct ath11k_base *ab, struct hal_srng *srng,
76 			    enum hal_reo_cmd_type type,
77 			    struct ath11k_hal_reo_cmd *cmd);
78 void ath11k_hal_tx_init_data_ring(struct ath11k_base *ab,
79 				  struct hal_srng *srng);
80 #endif
81