1 /* 2 * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 #ifndef __DP_BE_TX_H 20 #define __DP_BE_TX_H 21 /** 22 * DOC: dp_be_tx.h 23 * 24 * BE specific TX Datapath header file. Need not be exposed to common DP code. 25 * 26 */ 27 28 #include <dp_types.h> 29 #include "dp_be.h" 30 31 struct __attribute__((__packed__)) dp_tx_comp_peer_id { 32 uint16_t peer_id:13, 33 ml_peer_valid:1, 34 reserved:2; 35 }; 36 37 /* Invalid TX Bank ID value */ 38 #define DP_BE_INVALID_BANK_ID -1 39 40 /* Extraction of msdu queue information from per packet sawf metadata */ 41 #define DP_TX_HLOS_TID_GET(_var) \ 42 (((_var) & 0x0e) >> 1) 43 #define DP_TX_FLOW_OVERRIDE_GET(_var) \ 44 ((_var >> 3) & 0x1) 45 #define DP_TX_WHO_CLFY_INF_SEL_GET(_var) \ 46 (((_var) & 0x30) >> 4) 47 #define DP_TX_FLOW_OVERRIDE_ENABLE 0x1 48 49 #define DP_TX_FAST_DESC_SIZE 24 50 #define DP_TX_L3_L4_CSUM_ENABLE 0x1f 51 52 #ifdef DP_USE_REDUCED_PEER_ID_FIELD_WIDTH 53 /** 54 * dp_tx_comp_get_peer_id_be() - Get peer ID from TX Comp Desc 55 * @soc: Handle to DP Soc structure 56 * @tx_comp_hal_desc: TX comp ring descriptor 57 * 58 * Return: Peer ID 59 */ 60 static inline uint16_t dp_tx_comp_get_peer_id_be(struct dp_soc *soc, 61 void *tx_comp_hal_desc) 62 { 63 uint16_t peer_id = hal_tx_comp_get_peer_id(tx_comp_hal_desc); 64 struct dp_tx_comp_peer_id *tx_peer_id = 65 (struct dp_tx_comp_peer_id *)&peer_id; 66 67 return (tx_peer_id->peer_id | 68 (tx_peer_id->ml_peer_valid << soc->peer_id_shift)); 69 } 70 #else 71 static inline uint16_t dp_tx_comp_get_peer_id_be(struct dp_soc *soc, 72 void *tx_comp_hal_desc) 73 { 74 return hal_tx_comp_get_peer_id(tx_comp_hal_desc); 75 76 } 77 #endif 78 79 /** 80 * dp_tx_hw_enqueue_be() - Enqueue to TCL HW for transmit for BE target 81 * @soc: DP Soc Handle 82 * @vdev: DP vdev handle 83 * @tx_desc: Tx Descriptor Handle 84 * @fw_metadata: Metadata to send to Target Firmware along with frame 85 * @tx_exc_metadata: Handle that holds exception path meta data 86 * @msdu_info: msdu_info containing information about TX buffer 87 * 88 * Gets the next free TCL HW DMA descriptor and sets up required parameters 89 * from software Tx descriptor 90 * 91 * Return: QDF_STATUS_SUCCESS: success 92 * QDF_STATUS_E_RESOURCES: Error return 93 */ 94 QDF_STATUS dp_tx_hw_enqueue_be(struct dp_soc *soc, struct dp_vdev *vdev, 95 struct dp_tx_desc_s *tx_desc, 96 uint16_t fw_metadata, 97 struct cdp_tx_exception_metadata *metadata, 98 struct dp_tx_msdu_info_s *msdu_info); 99 100 #ifdef QCA_DP_TX_NBUF_LIST_FREE 101 /** 102 * dp_tx_hw_enqueue_be() - This is a fast send API to directly enqueue to HW 103 * @soc: DP Soc Handle 104 * @vdev_id: DP vdev ID 105 * @nbuf: network buffer to be transmitted 106 * 107 * Gets the next free TCL HW DMA descriptor and sets up required parameters 108 * from software Tx descriptor 109 * 110 * Return: NULL for success 111 * nbuf for failure 112 */ 113 qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc, uint8_t vdev_id, 114 qdf_nbuf_t nbuf); 115 #else 116 static inline qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc, uint8_t vdev_id, 117 qdf_nbuf_t nbuf) 118 { 119 return NULL; 120 } 121 #endif 122 123 /** 124 * dp_tx_comp_get_params_from_hal_desc_be() - Get TX desc from HAL comp desc 125 * @soc: DP soc handle 126 * @tx_comp_hal_desc: HAL TX Comp Descriptor 127 * @r_tx_desc: SW Tx Descriptor retrieved from HAL desc. 128 * 129 * Return: None 130 */ 131 void dp_tx_comp_get_params_from_hal_desc_be(struct dp_soc *soc, 132 void *tx_comp_hal_desc, 133 struct dp_tx_desc_s **r_tx_desc); 134 135 /** 136 * dp_tx_process_htt_completion_be() - Tx HTT Completion Indication Handler 137 * @soc: Handle to DP soc structure 138 * @tx_desc: software descriptor head pointer 139 * @status : Tx completion status from HTT descriptor 140 * @ring_id: ring number 141 * 142 * This function will process HTT Tx indication messages from Target 143 * 144 * Return: none 145 */ 146 void dp_tx_process_htt_completion_be(struct dp_soc *soc, 147 struct dp_tx_desc_s *tx_desc, 148 uint8_t *status, 149 uint8_t ring_id); 150 151 /** 152 * dp_tx_init_bank_profiles() - Init TX bank profiles 153 * @soc: DP soc handle 154 * 155 * Return: QDF_STATUS_SUCCESS or QDF error code. 156 */ 157 QDF_STATUS dp_tx_init_bank_profiles(struct dp_soc_be *soc); 158 159 /** 160 * dp_tx_deinit_bank_profiles() - De-Init TX bank profiles 161 * @soc: DP soc handle 162 * 163 * Return: None 164 */ 165 void dp_tx_deinit_bank_profiles(struct dp_soc_be *soc); 166 167 /** 168 * dp_tx_get_bank_profile() - get TX bank profile for vdev 169 * @soc: DP soc handle 170 * @be_vdev: BE vdev pointer 171 * 172 * Return: bank profile allocated to vdev or DP_BE_INVALID_BANK_ID 173 */ 174 int dp_tx_get_bank_profile(struct dp_soc_be *soc, 175 struct dp_vdev_be *be_vdev); 176 177 /** 178 * dp_tx_put_bank_profile() - release TX bank profile for vdev 179 * @soc: DP soc handle 180 * 181 * Return: None 182 */ 183 void dp_tx_put_bank_profile(struct dp_soc_be *soc, struct dp_vdev_be *be_vdev); 184 185 /** 186 * dp_tx_update_bank_profile() - release existing and allocate new bank profile 187 * @soc: DP soc handle 188 * @be_vdev: pointer to be_vdev structure 189 * 190 * The function releases the existing bank profile allocated to the vdev and 191 * looks for a new bank profile based on updated dp_vdev TX params. 192 * 193 * Return: None 194 */ 195 void dp_tx_update_bank_profile(struct dp_soc_be *be_soc, 196 struct dp_vdev_be *be_vdev); 197 198 /** 199 * dp_tx_desc_pool_init_be() - Initialize Tx Descriptor pool(s) 200 * @soc: Handle to DP Soc structure 201 * @num_elem: number of descriptor in pool 202 * @pool_id: pool ID to allocate 203 * 204 * Return: QDF_STATUS_SUCCESS - success, others - failure 205 */ 206 QDF_STATUS dp_tx_desc_pool_init_be(struct dp_soc *soc, 207 uint32_t num_elem, 208 uint8_t pool_id); 209 /** 210 * dp_tx_desc_pool_deinit_be() - De-initialize Tx Descriptor pool(s) 211 * @soc: Handle to DP Soc structure 212 * @tx_desc_pool: Tx descriptor pool handler 213 * @pool_id: pool ID to deinit 214 * 215 * Return: None 216 */ 217 void dp_tx_desc_pool_deinit_be(struct dp_soc *soc, 218 struct dp_tx_desc_pool_s *tx_desc_pool, 219 uint8_t pool_id); 220 221 #ifdef WLAN_SUPPORT_PPEDS 222 /** 223 * dp_ppeds_tx_comp_handler()- Handle tx completions for ppe2tcl ring 224 * @soc: Handle to DP Soc structure 225 * @quota: Max number of tx completions to process 226 * 227 * Return: Number of tx completions processed 228 */ 229 int dp_ppeds_tx_comp_handler(struct dp_soc_be *be_soc, uint32_t quota); 230 231 /* 232 * dp_ppeds_stats() - Accounting fw2wbm_tx_drop drops in Tx path 233 * @soc: Handle to DP Soc structure 234 * @peer_id: Peer ID in the descriptor 235 * 236 * Return: NONE 237 */ 238 239 static inline 240 void dp_ppeds_stats(struct dp_soc *soc, uint16_t peer_id); 241 242 #endif 243 #ifdef WLAN_FEATURE_11BE_MLO 244 /** 245 * dp_tx_mlo_mcast_handler_be() - Tx handler for Mcast packets 246 * @soc: Handle to DP Soc structure 247 * @vdev: DP vdev handle 248 * @nbuf: nbuf to be enqueued 249 * 250 * Return: None 251 */ 252 void dp_tx_mlo_mcast_handler_be(struct dp_soc *soc, 253 struct dp_vdev *vdev, 254 qdf_nbuf_t nbuf); 255 256 /** 257 * dp_tx_mlo_is_mcast_primary_be() - Function to check for primary mcast vdev 258 * @soc: Handle to DP Soc structure 259 * @vdev: DP vdev handle 260 * 261 * Return: True if vdev is mcast primary 262 * False for all othercase 263 */ 264 bool dp_tx_mlo_is_mcast_primary_be(struct dp_soc *soc, 265 struct dp_vdev *vdev); 266 #ifdef WLAN_MCAST_MLO 267 #ifdef WLAN_MLO_MULTI_CHIP 268 #ifdef CONFIG_MLO_SINGLE_DEV 269 /** 270 * dp_tx_mlo_mcast_send_be() - Tx send handler for mlo mcast enhance 271 * @soc: DP soc handle 272 * @vdev_id: id of DP vdev handle 273 * @nbuf: skb 274 * @tx_exc_metadata: Handle that holds exception path meta data 275 * @pkt_drop_st: if packet drop will set for 1 276 * 277 * Return: NULL for success 278 * nbuf for failure 279 */ 280 281 qdf_nbuf_t dp_tx_mlo_mcast_send_be(struct dp_soc *soc, struct dp_vdev *vdev, 282 qdf_nbuf_t nbuf, 283 struct cdp_tx_exception_metadata 284 *tx_exc_metadata); 285 #endif 286 /** 287 * dp_tx_mlo_mcast_pkt_send() - handler to send MLO Mcast packets 288 * @be_vdev: Handle to DP be_vdev structure 289 * @ptnr_vdev: DP ptnr_vdev handle 290 * @nbuf: nbuf to be enqueued 291 * 292 * Return: None 293 */ 294 void dp_tx_mlo_mcast_pkt_send(struct dp_vdev_be *be_vdev, 295 struct dp_vdev *ptnr_vdev, 296 void *arg); 297 #endif 298 #endif 299 #endif 300 301 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ 302 /** 303 * dp_tx_comp_nf_handler() - Tx completion ring Near full scenario handler 304 * @int_ctx: Interrupt context 305 * @soc: Datapath SoC handle 306 * @hal_ring_hdl: TX completion ring handle 307 * @ring_id: TX completion ring number 308 * @quota: Quota of the work to be done 309 * 310 * Return: work done 311 */ 312 uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc, 313 hal_ring_handle_t hal_ring_hdl, uint8_t ring_id, 314 uint32_t quota); 315 #else 316 static inline 317 uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc, 318 hal_ring_handle_t hal_ring_hdl, uint8_t ring_id, 319 uint32_t quota) 320 { 321 return 0; 322 } 323 #endif /* WLAN_FEATURE_NEAR_FULL_IRQ */ 324 325 /** 326 * dp_tx_compute_tx_delay_be() - Compute HW Tx completion delay 327 * @soc: Handle to DP Soc structure 328 * @vdev: vdev 329 * @ts: Tx completion status 330 * @delay_us: Delay to be calculated in microseconds 331 * 332 * Return: QDF_STATUS 333 */ 334 QDF_STATUS dp_tx_compute_tx_delay_be(struct dp_soc *soc, 335 struct dp_vdev *vdev, 336 struct hal_tx_completion_status *ts, 337 uint32_t *delay_us); 338 #endif 339