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