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