1d8899132SKalle Valo /* SPDX-License-Identifier: BSD-3-Clause-Clear */ 2d8899132SKalle Valo /* 3d8899132SKalle Valo * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved. 4*ed61863dSLingbo Kong * Copyright (c) 2021-2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved. 5d8899132SKalle Valo */ 6d8899132SKalle Valo 7d8899132SKalle Valo #ifndef ATH12K_HAL_TX_H 8d8899132SKalle Valo #define ATH12K_HAL_TX_H 9d8899132SKalle Valo 10d8899132SKalle Valo #include "hal_desc.h" 11d8899132SKalle Valo #include "core.h" 12d8899132SKalle Valo 13d8899132SKalle Valo #define HAL_TX_ADDRX_EN 1 14d8899132SKalle Valo #define HAL_TX_ADDRY_EN 2 15d8899132SKalle Valo 16d8899132SKalle Valo #define HAL_TX_ADDR_SEARCH_DEFAULT 0 17d8899132SKalle Valo #define HAL_TX_ADDR_SEARCH_INDEX 1 18d8899132SKalle Valo 19d8899132SKalle Valo /* TODO: check all these data can be managed with struct ath12k_tx_desc_info for perf */ 20d8899132SKalle Valo struct hal_tx_info { 21d8899132SKalle Valo u16 meta_data_flags; /* %HAL_TCL_DATA_CMD_INFO0_META_ */ 22d8899132SKalle Valo u8 ring_id; 23d8899132SKalle Valo u8 rbm_id; 24d8899132SKalle Valo u32 desc_id; 25d8899132SKalle Valo enum hal_tcl_desc_type type; 26d8899132SKalle Valo enum hal_tcl_encap_type encap_type; 27d8899132SKalle Valo dma_addr_t paddr; 28d8899132SKalle Valo u32 data_len; 29d8899132SKalle Valo u32 pkt_offset; 30d8899132SKalle Valo enum hal_encrypt_type encrypt_type; 31d8899132SKalle Valo u32 flags0; /* %HAL_TCL_DATA_CMD_INFO1_ */ 32d8899132SKalle Valo u32 flags1; /* %HAL_TCL_DATA_CMD_INFO2_ */ 33d8899132SKalle Valo u16 addr_search_flags; /* %HAL_TCL_DATA_CMD_INFO0_ADDR(X/Y)_ */ 34d8899132SKalle Valo u16 bss_ast_hash; 35d8899132SKalle Valo u16 bss_ast_idx; 36d8899132SKalle Valo u8 tid; 37d8899132SKalle Valo u8 search_type; /* %HAL_TX_ADDR_SEARCH_ */ 38d8899132SKalle Valo u8 lmac_id; 39d8899132SKalle Valo u8 vdev_id; 40d8899132SKalle Valo u8 dscp_tid_tbl_idx; 41d8899132SKalle Valo bool enable_mesh; 42d8899132SKalle Valo int bank_id; 43d8899132SKalle Valo }; 44d8899132SKalle Valo 45d8899132SKalle Valo /* TODO: Check if the actual desc macros can be used instead */ 46d8899132SKalle Valo #define HAL_TX_STATUS_FLAGS_FIRST_MSDU BIT(0) 47d8899132SKalle Valo #define HAL_TX_STATUS_FLAGS_LAST_MSDU BIT(1) 48d8899132SKalle Valo #define HAL_TX_STATUS_FLAGS_MSDU_IN_AMSDU BIT(2) 49d8899132SKalle Valo #define HAL_TX_STATUS_FLAGS_RATE_STATS_VALID BIT(3) 50d8899132SKalle Valo #define HAL_TX_STATUS_FLAGS_RATE_LDPC BIT(4) 51d8899132SKalle Valo #define HAL_TX_STATUS_FLAGS_RATE_STBC BIT(5) 52d8899132SKalle Valo #define HAL_TX_STATUS_FLAGS_OFDMA BIT(6) 53d8899132SKalle Valo 54d8899132SKalle Valo #define HAL_TX_STATUS_DESC_LEN sizeof(struct hal_wbm_release_ring) 55d8899132SKalle Valo 56d8899132SKalle Valo /* Tx status parsed from srng desc */ 57d8899132SKalle Valo struct hal_tx_status { 58d8899132SKalle Valo enum hal_wbm_rel_src_module buf_rel_source; 59d8899132SKalle Valo enum hal_wbm_tqm_rel_reason status; 60*ed61863dSLingbo Kong s8 ack_rssi; 61d8899132SKalle Valo u32 flags; /* %HAL_TX_STATUS_FLAGS_ */ 62d8899132SKalle Valo u32 ppdu_id; 63d8899132SKalle Valo u8 try_cnt; 64d8899132SKalle Valo u8 tid; 65d8899132SKalle Valo u16 peer_id; 66d8899132SKalle Valo u32 rate_stats; 67d8899132SKalle Valo }; 68d8899132SKalle Valo 69d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO0_BF_TYPE GENMASK(17, 16) 70d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO0_PREAMBLE_11B BIT(20) 71d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO0_PKT_TYPE GENMASK(24, 21) 72d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO0_BANDWIDTH GENMASK(30, 28) 73d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO1_MCS GENMASK(3, 0) 74d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO1_STBC BIT(6) 75d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO2_NSS GENMASK(23, 21) 76d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO3_AP_PKT_BW GENMASK(6, 4) 77d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO3_LTF_SIZE GENMASK(20, 19) 78d8899132SKalle Valo #define HAL_TX_PHY_DESC_INFO3_ACTIVE_CHANNEL GENMASK(17, 15) 79d8899132SKalle Valo 80d8899132SKalle Valo struct hal_tx_phy_desc { 81d8899132SKalle Valo __le32 info0; 82d8899132SKalle Valo __le32 info1; 83d8899132SKalle Valo __le32 info2; 84d8899132SKalle Valo __le32 info3; 85d8899132SKalle Valo } __packed; 86d8899132SKalle Valo 87d8899132SKalle Valo #define HAL_TX_FES_STAT_PROT_INFO0_STRT_FRM_TS_15_0 GENMASK(15, 0) 88d8899132SKalle Valo #define HAL_TX_FES_STAT_PROT_INFO0_STRT_FRM_TS_31_16 GENMASK(31, 16) 89d8899132SKalle Valo #define HAL_TX_FES_STAT_PROT_INFO1_END_FRM_TS_15_0 GENMASK(15, 0) 90d8899132SKalle Valo #define HAL_TX_FES_STAT_PROT_INFO1_END_FRM_TS_31_16 GENMASK(31, 16) 91d8899132SKalle Valo 92d8899132SKalle Valo struct hal_tx_fes_status_prot { 93d8899132SKalle Valo __le64 reserved; 94d8899132SKalle Valo __le32 info0; 95d8899132SKalle Valo __le32 info1; 96d8899132SKalle Valo __le32 reserved1[11]; 97d8899132SKalle Valo } __packed; 98d8899132SKalle Valo 99d8899132SKalle Valo #define HAL_TX_FES_STAT_USR_PPDU_INFO0_DURATION GENMASK(15, 0) 100d8899132SKalle Valo 101d8899132SKalle Valo struct hal_tx_fes_status_user_ppdu { 102d8899132SKalle Valo __le64 reserved; 103d8899132SKalle Valo __le32 info0; 104d8899132SKalle Valo __le32 reserved1[3]; 105d8899132SKalle Valo } __packed; 106d8899132SKalle Valo 107d8899132SKalle Valo #define HAL_TX_FES_STAT_STRT_INFO0_PROT_TS_LOWER_32 GENMASK(31, 0) 108d8899132SKalle Valo #define HAL_TX_FES_STAT_STRT_INFO1_PROT_TS_UPPER_32 GENMASK(31, 0) 109d8899132SKalle Valo 110d8899132SKalle Valo struct hal_tx_fes_status_start_prot { 111d8899132SKalle Valo __le32 info0; 112d8899132SKalle Valo __le32 info1; 113d8899132SKalle Valo __le64 reserved; 114d8899132SKalle Valo } __packed; 115d8899132SKalle Valo 116d8899132SKalle Valo #define HAL_TX_FES_STATUS_START_INFO0_MEDIUM_PROT_TYPE GENMASK(29, 27) 117d8899132SKalle Valo 118d8899132SKalle Valo struct hal_tx_fes_status_start { 119d8899132SKalle Valo __le32 reserved; 120d8899132SKalle Valo __le32 info0; 121d8899132SKalle Valo __le64 reserved1; 122d8899132SKalle Valo } __packed; 123d8899132SKalle Valo 124d8899132SKalle Valo #define HAL_TX_Q_EXT_INFO0_FRAME_CTRL GENMASK(15, 0) 125d8899132SKalle Valo #define HAL_TX_Q_EXT_INFO0_QOS_CTRL GENMASK(31, 16) 126d8899132SKalle Valo #define HAL_TX_Q_EXT_INFO1_AMPDU_FLAG BIT(0) 127d8899132SKalle Valo 128d8899132SKalle Valo struct hal_tx_queue_exten { 129d8899132SKalle Valo __le32 info0; 130d8899132SKalle Valo __le32 info1; 131d8899132SKalle Valo } __packed; 132d8899132SKalle Valo 133d8899132SKalle Valo #define HAL_TX_FES_SETUP_INFO0_NUM_OF_USERS GENMASK(28, 23) 134d8899132SKalle Valo 135d8899132SKalle Valo struct hal_tx_fes_setup { 136d8899132SKalle Valo __le32 schedule_id; 137d8899132SKalle Valo __le32 info0; 138d8899132SKalle Valo __le64 reserved; 139d8899132SKalle Valo } __packed; 140d8899132SKalle Valo 141d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO0_MEDIUM_PROT_TYPE GENMASK(2, 0) 142d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO1_PROT_FRAME_ADDR1_31_0 GENMASK(31, 0) 143d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO2_PROT_FRAME_ADDR1_47_32 GENMASK(15, 0) 144d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO2_PROT_FRAME_ADDR2_15_0 GENMASK(31, 16) 145d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO3_PROT_FRAME_ADDR2_47_16 GENMASK(31, 0) 146d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO4_PROT_FRAME_ADDR3_31_0 GENMASK(31, 0) 147d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO5_PROT_FRAME_ADDR3_47_32 GENMASK(15, 0) 148d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO5_PROT_FRAME_ADDR4_15_0 GENMASK(31, 16) 149d8899132SKalle Valo #define HAL_TX_PPDU_SETUP_INFO6_PROT_FRAME_ADDR4_47_16 GENMASK(31, 0) 150d8899132SKalle Valo 151d8899132SKalle Valo struct hal_tx_pcu_ppdu_setup_init { 152d8899132SKalle Valo __le32 info0; 153d8899132SKalle Valo __le32 info1; 154d8899132SKalle Valo __le32 info2; 155d8899132SKalle Valo __le32 info3; 156d8899132SKalle Valo __le32 reserved; 157d8899132SKalle Valo __le32 info4; 158d8899132SKalle Valo __le32 info5; 159d8899132SKalle Valo __le32 info6; 160d8899132SKalle Valo } __packed; 161d8899132SKalle Valo 162d8899132SKalle Valo #define HAL_TX_FES_STATUS_END_INFO0_START_TIMESTAMP_15_0 GENMASK(15, 0) 163d8899132SKalle Valo #define HAL_TX_FES_STATUS_END_INFO0_START_TIMESTAMP_31_16 GENMASK(31, 16) 164d8899132SKalle Valo 165d8899132SKalle Valo struct hal_tx_fes_status_end { 166d8899132SKalle Valo __le32 reserved[2]; 167d8899132SKalle Valo __le32 info0; 168d8899132SKalle Valo __le32 reserved1[19]; 169d8899132SKalle Valo } __packed; 170d8899132SKalle Valo 171d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_EPD BIT(0) 172d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_ENCAP_TYPE GENMASK(2, 1) 173d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_ENCRYPT_TYPE GENMASK(6, 3) 174d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_SRC_BUFFER_SWAP BIT(7) 175d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_LINK_META_SWAP BIT(8) 176d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_INDEX_LOOKUP_EN BIT(9) 177d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_ADDRX_EN BIT(10) 178d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_ADDRY_EN BIT(11) 179d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_MESH_EN GENMASK(13, 12) 180d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_VDEV_ID_CHECK_EN BIT(14) 181d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_PMAC_ID GENMASK(16, 15) 182d8899132SKalle Valo /* STA mode will have MCAST_PKT_CTRL instead of DSCP_TID_MAP bitfield */ 183d8899132SKalle Valo #define HAL_TX_BANK_CONFIG_DSCP_TIP_MAP_ID GENMASK(22, 17) 184d8899132SKalle Valo 185d8899132SKalle Valo void ath12k_hal_tx_cmd_desc_setup(struct ath12k_base *ab, 186d8899132SKalle Valo struct hal_tcl_data_cmd *tcl_cmd, 187d8899132SKalle Valo struct hal_tx_info *ti); 188d8899132SKalle Valo void ath12k_hal_tx_set_dscp_tid_map(struct ath12k_base *ab, int id); 189d8899132SKalle Valo int ath12k_hal_reo_cmd_send(struct ath12k_base *ab, struct hal_srng *srng, 190d8899132SKalle Valo enum hal_reo_cmd_type type, 191d8899132SKalle Valo struct ath12k_hal_reo_cmd *cmd); 192d8899132SKalle Valo void ath12k_hal_tx_configure_bank_register(struct ath12k_base *ab, u32 bank_config, 193d8899132SKalle Valo u8 bank_id); 194d8899132SKalle Valo #endif 195