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 28 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 * @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_fast_send_be() - Transmit a frame on a given VAP 103 * @soc_hdl: DP soc handle 104 * @vdev_id: id of DP vdev handle 105 * @nbuf: skb 106 * 107 * Entry point for Core Tx layer (DP_TX) invoked from 108 * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding 109 * cases 110 * 111 * Return: NULL on success, 112 * nbuf when it fails to send 113 */ 114 qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, 115 qdf_nbuf_t nbuf); 116 #else 117 static inline qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc, uint8_t vdev_id, 118 qdf_nbuf_t nbuf) 119 { 120 return NULL; 121 } 122 #endif 123 124 /** 125 * dp_tx_comp_get_params_from_hal_desc_be() - Get TX desc from HAL comp desc 126 * @soc: DP soc handle 127 * @tx_comp_hal_desc: HAL TX Comp Descriptor 128 * @r_tx_desc: SW Tx Descriptor retrieved from HAL desc. 129 * 130 * Return: None 131 */ 132 void dp_tx_comp_get_params_from_hal_desc_be(struct dp_soc *soc, 133 void *tx_comp_hal_desc, 134 struct dp_tx_desc_s **r_tx_desc); 135 136 /** 137 * dp_tx_process_htt_completion_be() - Tx HTT Completion Indication Handler 138 * @soc: Handle to DP soc structure 139 * @tx_desc: software descriptor head pointer 140 * @status: Tx completion status from HTT descriptor 141 * @ring_id: ring number 142 * 143 * This function will process HTT Tx indication messages from Target 144 * 145 * Return: none 146 */ 147 void dp_tx_process_htt_completion_be(struct dp_soc *soc, 148 struct dp_tx_desc_s *tx_desc, 149 uint8_t *status, 150 uint8_t ring_id); 151 152 /** 153 * dp_tx_init_bank_profiles() - Init TX bank profiles 154 * @soc: DP soc handle 155 * 156 * Return: QDF_STATUS_SUCCESS or QDF error code. 157 */ 158 QDF_STATUS dp_tx_init_bank_profiles(struct dp_soc_be *soc); 159 160 /** 161 * dp_tx_deinit_bank_profiles() - De-Init TX bank profiles 162 * @soc: DP soc handle 163 * 164 * Return: None 165 */ 166 void dp_tx_deinit_bank_profiles(struct dp_soc_be *soc); 167 168 /** 169 * dp_tx_get_bank_profile() - get TX bank profile for vdev 170 * @soc: DP soc handle 171 * @be_vdev: BE vdev pointer 172 * 173 * Return: bank profile allocated to vdev or DP_BE_INVALID_BANK_ID 174 */ 175 int dp_tx_get_bank_profile(struct dp_soc_be *soc, 176 struct dp_vdev_be *be_vdev); 177 178 /** 179 * dp_tx_put_bank_profile() - release TX bank profile for vdev 180 * @soc: DP soc handle 181 * @be_vdev: pointer to be_vdev structure 182 * 183 * Return: None 184 */ 185 void dp_tx_put_bank_profile(struct dp_soc_be *soc, struct dp_vdev_be *be_vdev); 186 187 /** 188 * dp_tx_update_bank_profile() - release existing and allocate new bank profile 189 * @be_soc: DP soc handle 190 * @be_vdev: pointer to be_vdev structure 191 * 192 * The function releases the existing bank profile allocated to the vdev and 193 * looks for a new bank profile based on updated dp_vdev TX params. 194 * 195 * Return: None 196 */ 197 void dp_tx_update_bank_profile(struct dp_soc_be *be_soc, 198 struct dp_vdev_be *be_vdev); 199 200 /** 201 * dp_tx_desc_pool_init_be() - Initialize Tx Descriptor pool(s) 202 * @soc: Handle to DP Soc structure 203 * @num_elem: number of descriptor in pool 204 * @pool_id: pool ID to allocate 205 * 206 * Return: QDF_STATUS_SUCCESS - success, others - failure 207 */ 208 QDF_STATUS dp_tx_desc_pool_init_be(struct dp_soc *soc, 209 uint32_t num_elem, 210 uint8_t pool_id); 211 /** 212 * dp_tx_desc_pool_deinit_be() - De-initialize Tx Descriptor pool(s) 213 * @soc: Handle to DP Soc structure 214 * @tx_desc_pool: Tx descriptor pool handler 215 * @pool_id: pool ID to deinit 216 * 217 * Return: None 218 */ 219 void dp_tx_desc_pool_deinit_be(struct dp_soc *soc, 220 struct dp_tx_desc_pool_s *tx_desc_pool, 221 uint8_t pool_id); 222 223 #ifdef WLAN_SUPPORT_PPEDS 224 /** 225 * dp_ppeds_tx_comp_handler()- Handle tx completions for ppe2tcl ring 226 * @be_soc: Handle to DP Soc structure 227 * @quota: Max number of tx completions to process 228 * 229 * Return: Number of tx completions processed 230 */ 231 int dp_ppeds_tx_comp_handler(struct dp_soc_be *be_soc, uint32_t quota); 232 233 /* 234 * dp_ppeds_stats() - Accounting fw2wbm_tx_drop drops in Tx path 235 * @soc: Handle to DP Soc structure 236 * @peer_id: Peer ID in the descriptor 237 * 238 * Return: NONE 239 */ 240 241 static inline 242 void dp_ppeds_stats(struct dp_soc *soc, uint16_t peer_id); 243 244 #endif 245 #ifdef WLAN_FEATURE_11BE_MLO 246 /** 247 * dp_tx_mlo_mcast_handler_be() - Tx handler for Mcast packets 248 * @soc: Handle to DP Soc structure 249 * @vdev: DP vdev handle 250 * @nbuf: nbuf to be enqueued 251 * 252 * Return: None 253 */ 254 void dp_tx_mlo_mcast_handler_be(struct dp_soc *soc, 255 struct dp_vdev *vdev, 256 qdf_nbuf_t nbuf); 257 258 /** 259 * dp_tx_mlo_is_mcast_primary_be() - Function to check for primary mcast vdev 260 * @soc: Handle to DP Soc structure 261 * @vdev: DP vdev handle 262 * 263 * Return: True if vdev is mcast primary 264 * False for all othercase 265 */ 266 bool dp_tx_mlo_is_mcast_primary_be(struct dp_soc *soc, 267 struct dp_vdev *vdev); 268 #ifdef WLAN_MCAST_MLO 269 #ifdef WLAN_MLO_MULTI_CHIP 270 #ifdef CONFIG_MLO_SINGLE_DEV 271 /** 272 * dp_tx_mlo_mcast_send_be() - Tx send handler for mlo mcast enhance 273 * @soc: DP soc handle 274 * @vdev: DP vdev handle 275 * @nbuf: skb 276 * @tx_exc_metadata: Handle that holds exception path meta data 277 * 278 * Return: NULL for success 279 * nbuf for failure 280 */ 281 282 qdf_nbuf_t dp_tx_mlo_mcast_send_be(struct dp_soc *soc, struct dp_vdev *vdev, 283 qdf_nbuf_t nbuf, 284 struct cdp_tx_exception_metadata 285 *tx_exc_metadata); 286 #endif 287 /** 288 * dp_tx_mlo_mcast_pkt_send() - handler to send MLO Mcast packets 289 * @be_vdev: Handle to DP be_vdev structure 290 * @ptnr_vdev: DP ptnr_vdev handle 291 * @arg: nbuf to be enqueued 292 * 293 * Return: None 294 */ 295 void dp_tx_mlo_mcast_pkt_send(struct dp_vdev_be *be_vdev, 296 struct dp_vdev *ptnr_vdev, 297 void *arg); 298 #endif 299 #endif 300 #endif 301 302 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ 303 /** 304 * dp_tx_comp_nf_handler() - Tx completion ring Near full scenario handler 305 * @int_ctx: Interrupt context 306 * @soc: Datapath SoC handle 307 * @hal_ring_hdl: TX completion ring handle 308 * @ring_id: TX completion ring number 309 * @quota: Quota of the work to be done 310 * 311 * Return: work done 312 */ 313 uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc, 314 hal_ring_handle_t hal_ring_hdl, uint8_t ring_id, 315 uint32_t quota); 316 #else 317 static inline 318 uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc, 319 hal_ring_handle_t hal_ring_hdl, uint8_t ring_id, 320 uint32_t quota) 321 { 322 return 0; 323 } 324 #endif /* WLAN_FEATURE_NEAR_FULL_IRQ */ 325 326 /** 327 * dp_tx_compute_tx_delay_be() - Compute HW Tx completion delay 328 * @soc: Handle to DP Soc structure 329 * @vdev: vdev 330 * @ts: Tx completion status 331 * @delay_us: Delay to be calculated in microseconds 332 * 333 * Return: QDF_STATUS 334 */ 335 QDF_STATUS dp_tx_compute_tx_delay_be(struct dp_soc *soc, 336 struct dp_vdev *vdev, 337 struct hal_tx_completion_status *ts, 338 uint32_t *delay_us); 339 340 /** 341 * dp_tx_desc_pool_alloc_be() - Allocate TX descriptor pool 342 * @soc: Handle to DP Soc structure 343 * @num_elem: Number of elements to allocate 344 * @pool_id: TCL descriptor pool ID 345 * 346 * Return: QDF_STATUS 347 */ 348 QDF_STATUS dp_tx_desc_pool_alloc_be(struct dp_soc *soc, uint32_t num_elem, 349 uint8_t pool_id); 350 351 /** 352 * dp_tx_desc_pool_free_be() - Free TX descriptor pool 353 * @soc: Handle to DP Soc structure 354 * @pool_id: TCL descriptor pool ID 355 * 356 * Return: none 357 */ 358 void dp_tx_desc_pool_free_be(struct dp_soc *soc, uint8_t pool_id); 359 #endif 360