162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause-Clear */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
462306a36Sopenharmony_ci * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef ATH12K_HAL_TX_H
862306a36Sopenharmony_ci#define ATH12K_HAL_TX_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include "hal_desc.h"
1162306a36Sopenharmony_ci#include "core.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define HAL_TX_ADDRX_EN			1
1462306a36Sopenharmony_ci#define HAL_TX_ADDRY_EN			2
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define HAL_TX_ADDR_SEARCH_DEFAULT	0
1762306a36Sopenharmony_ci#define HAL_TX_ADDR_SEARCH_INDEX	1
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/* TODO: check all these data can be managed with struct ath12k_tx_desc_info for perf */
2062306a36Sopenharmony_cistruct hal_tx_info {
2162306a36Sopenharmony_ci	u16 meta_data_flags; /* %HAL_TCL_DATA_CMD_INFO0_META_ */
2262306a36Sopenharmony_ci	u8 ring_id;
2362306a36Sopenharmony_ci	u8 rbm_id;
2462306a36Sopenharmony_ci	u32 desc_id;
2562306a36Sopenharmony_ci	enum hal_tcl_desc_type type;
2662306a36Sopenharmony_ci	enum hal_tcl_encap_type encap_type;
2762306a36Sopenharmony_ci	dma_addr_t paddr;
2862306a36Sopenharmony_ci	u32 data_len;
2962306a36Sopenharmony_ci	u32 pkt_offset;
3062306a36Sopenharmony_ci	enum hal_encrypt_type encrypt_type;
3162306a36Sopenharmony_ci	u32 flags0; /* %HAL_TCL_DATA_CMD_INFO1_ */
3262306a36Sopenharmony_ci	u32 flags1; /* %HAL_TCL_DATA_CMD_INFO2_ */
3362306a36Sopenharmony_ci	u16 addr_search_flags; /* %HAL_TCL_DATA_CMD_INFO0_ADDR(X/Y)_ */
3462306a36Sopenharmony_ci	u16 bss_ast_hash;
3562306a36Sopenharmony_ci	u16 bss_ast_idx;
3662306a36Sopenharmony_ci	u8 tid;
3762306a36Sopenharmony_ci	u8 search_type; /* %HAL_TX_ADDR_SEARCH_ */
3862306a36Sopenharmony_ci	u8 lmac_id;
3962306a36Sopenharmony_ci	u8 vdev_id;
4062306a36Sopenharmony_ci	u8 dscp_tid_tbl_idx;
4162306a36Sopenharmony_ci	bool enable_mesh;
4262306a36Sopenharmony_ci	int bank_id;
4362306a36Sopenharmony_ci};
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/* TODO: Check if the actual desc macros can be used instead */
4662306a36Sopenharmony_ci#define HAL_TX_STATUS_FLAGS_FIRST_MSDU		BIT(0)
4762306a36Sopenharmony_ci#define HAL_TX_STATUS_FLAGS_LAST_MSDU		BIT(1)
4862306a36Sopenharmony_ci#define HAL_TX_STATUS_FLAGS_MSDU_IN_AMSDU	BIT(2)
4962306a36Sopenharmony_ci#define HAL_TX_STATUS_FLAGS_RATE_STATS_VALID	BIT(3)
5062306a36Sopenharmony_ci#define HAL_TX_STATUS_FLAGS_RATE_LDPC		BIT(4)
5162306a36Sopenharmony_ci#define HAL_TX_STATUS_FLAGS_RATE_STBC		BIT(5)
5262306a36Sopenharmony_ci#define HAL_TX_STATUS_FLAGS_OFDMA		BIT(6)
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define HAL_TX_STATUS_DESC_LEN		sizeof(struct hal_wbm_release_ring)
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* Tx status parsed from srng desc */
5762306a36Sopenharmony_cistruct hal_tx_status {
5862306a36Sopenharmony_ci	enum hal_wbm_rel_src_module buf_rel_source;
5962306a36Sopenharmony_ci	enum hal_wbm_tqm_rel_reason status;
6062306a36Sopenharmony_ci	u8 ack_rssi;
6162306a36Sopenharmony_ci	u32 flags; /* %HAL_TX_STATUS_FLAGS_ */
6262306a36Sopenharmony_ci	u32 ppdu_id;
6362306a36Sopenharmony_ci	u8 try_cnt;
6462306a36Sopenharmony_ci	u8 tid;
6562306a36Sopenharmony_ci	u16 peer_id;
6662306a36Sopenharmony_ci	u32 rate_stats;
6762306a36Sopenharmony_ci};
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO0_BF_TYPE		GENMASK(17, 16)
7062306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO0_PREAMBLE_11B	BIT(20)
7162306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO0_PKT_TYPE		GENMASK(24, 21)
7262306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO0_BANDWIDTH		GENMASK(30, 28)
7362306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO1_MCS		GENMASK(3, 0)
7462306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO1_STBC		BIT(6)
7562306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO2_NSS		GENMASK(23, 21)
7662306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO3_AP_PKT_BW		GENMASK(6, 4)
7762306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO3_LTF_SIZE		GENMASK(20, 19)
7862306a36Sopenharmony_ci#define HAL_TX_PHY_DESC_INFO3_ACTIVE_CHANNEL	GENMASK(17, 15)
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_cistruct hal_tx_phy_desc {
8162306a36Sopenharmony_ci	__le32 info0;
8262306a36Sopenharmony_ci	__le32 info1;
8362306a36Sopenharmony_ci	__le32 info2;
8462306a36Sopenharmony_ci	__le32 info3;
8562306a36Sopenharmony_ci} __packed;
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define HAL_TX_FES_STAT_PROT_INFO0_STRT_FRM_TS_15_0	GENMASK(15, 0)
8862306a36Sopenharmony_ci#define HAL_TX_FES_STAT_PROT_INFO0_STRT_FRM_TS_31_16	GENMASK(31, 16)
8962306a36Sopenharmony_ci#define HAL_TX_FES_STAT_PROT_INFO1_END_FRM_TS_15_0	GENMASK(15, 0)
9062306a36Sopenharmony_ci#define HAL_TX_FES_STAT_PROT_INFO1_END_FRM_TS_31_16	GENMASK(31, 16)
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_cistruct hal_tx_fes_status_prot {
9362306a36Sopenharmony_ci	__le64 reserved;
9462306a36Sopenharmony_ci	__le32 info0;
9562306a36Sopenharmony_ci	__le32 info1;
9662306a36Sopenharmony_ci	__le32 reserved1[11];
9762306a36Sopenharmony_ci} __packed;
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define HAL_TX_FES_STAT_USR_PPDU_INFO0_DURATION		GENMASK(15, 0)
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistruct hal_tx_fes_status_user_ppdu {
10262306a36Sopenharmony_ci	__le64 reserved;
10362306a36Sopenharmony_ci	__le32 info0;
10462306a36Sopenharmony_ci	__le32 reserved1[3];
10562306a36Sopenharmony_ci} __packed;
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci#define HAL_TX_FES_STAT_STRT_INFO0_PROT_TS_LOWER_32	GENMASK(31, 0)
10862306a36Sopenharmony_ci#define HAL_TX_FES_STAT_STRT_INFO1_PROT_TS_UPPER_32	GENMASK(31, 0)
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_cistruct hal_tx_fes_status_start_prot {
11162306a36Sopenharmony_ci	__le32 info0;
11262306a36Sopenharmony_ci	__le32 info1;
11362306a36Sopenharmony_ci	__le64 reserved;
11462306a36Sopenharmony_ci} __packed;
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define HAL_TX_FES_STATUS_START_INFO0_MEDIUM_PROT_TYPE	GENMASK(29, 27)
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_cistruct hal_tx_fes_status_start {
11962306a36Sopenharmony_ci	__le32 reserved;
12062306a36Sopenharmony_ci	__le32 info0;
12162306a36Sopenharmony_ci	__le64 reserved1;
12262306a36Sopenharmony_ci} __packed;
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#define HAL_TX_Q_EXT_INFO0_FRAME_CTRL		GENMASK(15, 0)
12562306a36Sopenharmony_ci#define HAL_TX_Q_EXT_INFO0_QOS_CTRL		GENMASK(31, 16)
12662306a36Sopenharmony_ci#define HAL_TX_Q_EXT_INFO1_AMPDU_FLAG		BIT(0)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_cistruct hal_tx_queue_exten {
12962306a36Sopenharmony_ci	__le32 info0;
13062306a36Sopenharmony_ci	__le32 info1;
13162306a36Sopenharmony_ci} __packed;
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci#define HAL_TX_FES_SETUP_INFO0_NUM_OF_USERS	GENMASK(28, 23)
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_cistruct hal_tx_fes_setup {
13662306a36Sopenharmony_ci	__le32 schedule_id;
13762306a36Sopenharmony_ci	__le32 info0;
13862306a36Sopenharmony_ci	__le64 reserved;
13962306a36Sopenharmony_ci} __packed;
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO0_MEDIUM_PROT_TYPE	GENMASK(2, 0)
14262306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO1_PROT_FRAME_ADDR1_31_0	GENMASK(31, 0)
14362306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO2_PROT_FRAME_ADDR1_47_32	GENMASK(15, 0)
14462306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO2_PROT_FRAME_ADDR2_15_0	GENMASK(31, 16)
14562306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO3_PROT_FRAME_ADDR2_47_16	GENMASK(31, 0)
14662306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO4_PROT_FRAME_ADDR3_31_0	GENMASK(31, 0)
14762306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO5_PROT_FRAME_ADDR3_47_32	GENMASK(15, 0)
14862306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO5_PROT_FRAME_ADDR4_15_0	GENMASK(31, 16)
14962306a36Sopenharmony_ci#define HAL_TX_PPDU_SETUP_INFO6_PROT_FRAME_ADDR4_47_16	GENMASK(31, 0)
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_cistruct hal_tx_pcu_ppdu_setup_init {
15262306a36Sopenharmony_ci	__le32 info0;
15362306a36Sopenharmony_ci	__le32 info1;
15462306a36Sopenharmony_ci	__le32 info2;
15562306a36Sopenharmony_ci	__le32 info3;
15662306a36Sopenharmony_ci	__le32 reserved;
15762306a36Sopenharmony_ci	__le32 info4;
15862306a36Sopenharmony_ci	__le32 info5;
15962306a36Sopenharmony_ci	__le32 info6;
16062306a36Sopenharmony_ci} __packed;
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci#define HAL_TX_FES_STATUS_END_INFO0_START_TIMESTAMP_15_0	GENMASK(15, 0)
16362306a36Sopenharmony_ci#define HAL_TX_FES_STATUS_END_INFO0_START_TIMESTAMP_31_16	GENMASK(31, 16)
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_cistruct hal_tx_fes_status_end {
16662306a36Sopenharmony_ci	__le32 reserved[2];
16762306a36Sopenharmony_ci	__le32 info0;
16862306a36Sopenharmony_ci	__le32 reserved1[19];
16962306a36Sopenharmony_ci} __packed;
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_EPD			BIT(0)
17262306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_ENCAP_TYPE		GENMASK(2, 1)
17362306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_ENCRYPT_TYPE		GENMASK(6, 3)
17462306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_SRC_BUFFER_SWAP	BIT(7)
17562306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_LINK_META_SWAP	BIT(8)
17662306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_INDEX_LOOKUP_EN	BIT(9)
17762306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_ADDRX_EN		BIT(10)
17862306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_ADDRY_EN		BIT(11)
17962306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_MESH_EN		GENMASK(13, 12)
18062306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_VDEV_ID_CHECK_EN	BIT(14)
18162306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_PMAC_ID		GENMASK(16, 15)
18262306a36Sopenharmony_ci/* STA mode will have MCAST_PKT_CTRL instead of DSCP_TID_MAP bitfield */
18362306a36Sopenharmony_ci#define HAL_TX_BANK_CONFIG_DSCP_TIP_MAP_ID	GENMASK(22, 17)
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_civoid ath12k_hal_tx_cmd_desc_setup(struct ath12k_base *ab,
18662306a36Sopenharmony_ci				  struct hal_tcl_data_cmd *tcl_cmd,
18762306a36Sopenharmony_ci				  struct hal_tx_info *ti);
18862306a36Sopenharmony_civoid ath12k_hal_tx_set_dscp_tid_map(struct ath12k_base *ab, int id);
18962306a36Sopenharmony_ciint ath12k_hal_reo_cmd_send(struct ath12k_base *ab, struct hal_srng *srng,
19062306a36Sopenharmony_ci			    enum hal_reo_cmd_type type,
19162306a36Sopenharmony_ci			    struct ath12k_hal_reo_cmd *cmd);
19262306a36Sopenharmony_civoid ath12k_hal_tx_configure_bank_register(struct ath12k_base *ab, u32 bank_config,
19362306a36Sopenharmony_ci					   u8 bank_id);
19462306a36Sopenharmony_ci#endif
195