xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/be/dp_be_tx.h (revision 7c7742990b15ded9d0e97405b5704faf7e14401a)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2022 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) & 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 /**
53  * dp_tx_hw_enqueue_be() - Enqueue to TCL HW for transmit for BE target
54  * @soc: DP Soc Handle
55  * @vdev: DP vdev handle
56  * @tx_desc: Tx Descriptor Handle
57  * @fw_metadata: Metadata to send to Target Firmware along with frame
58  * @tx_exc_metadata: Handle that holds exception path meta data
59  * @msdu_info: msdu_info containing information about TX buffer
60  *
61  *  Gets the next free TCL HW DMA descriptor and sets up required parameters
62  *  from software Tx descriptor
63  *
64  * Return: QDF_STATUS_SUCCESS: success
65  *         QDF_STATUS_E_RESOURCES: Error return
66  */
67 QDF_STATUS dp_tx_hw_enqueue_be(struct dp_soc *soc, struct dp_vdev *vdev,
68 			       struct dp_tx_desc_s *tx_desc,
69 				uint16_t fw_metadata,
70 				struct cdp_tx_exception_metadata *metadata,
71 				struct dp_tx_msdu_info_s *msdu_info);
72 
73 /**
74  * dp_tx_hw_enqueue_be() - This is a fast send API to directly enqueue to HW
75  * @soc: DP Soc Handle
76  * @vdev_id: DP vdev ID
77  * @nbuf: network buffer to be transmitted
78  *
79  *  Gets the next free TCL HW DMA descriptor and sets up required parameters
80  *  from software Tx descriptor
81  *
82  * Return: NULL for success
83  *         nbuf for failure
84  */
85 
86 qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc, uint8_t vdev_id,
87 			      qdf_nbuf_t nbuf);
88 
89 /**
90  * dp_tx_comp_get_params_from_hal_desc_be() - Get TX desc from HAL comp desc
91  * @soc: DP soc handle
92  * @tx_comp_hal_desc: HAL TX Comp Descriptor
93  * @r_tx_desc: SW Tx Descriptor retrieved from HAL desc.
94  *
95  * Return: None
96  */
97 void dp_tx_comp_get_params_from_hal_desc_be(struct dp_soc *soc,
98 					    void *tx_comp_hal_desc,
99 					    struct dp_tx_desc_s **r_tx_desc);
100 
101 /**
102  * dp_tx_process_htt_completion_be() - Tx HTT Completion Indication Handler
103  * @soc: Handle to DP soc structure
104  * @tx_desc: software descriptor head pointer
105  * @status : Tx completion status from HTT descriptor
106  * @ring_id: ring number
107  *
108  * This function will process HTT Tx indication messages from Target
109  *
110  * Return: none
111  */
112 void dp_tx_process_htt_completion_be(struct dp_soc *soc,
113 				     struct dp_tx_desc_s *tx_desc,
114 				     uint8_t *status,
115 				     uint8_t ring_id);
116 
117 /**
118  * dp_tx_init_bank_profiles() - Init TX bank profiles
119  * @soc: DP soc handle
120  *
121  * Return: QDF_STATUS_SUCCESS or QDF error code.
122  */
123 QDF_STATUS dp_tx_init_bank_profiles(struct dp_soc_be *soc);
124 
125 /**
126  * dp_tx_deinit_bank_profiles() - De-Init TX bank profiles
127  * @soc: DP soc handle
128  *
129  * Return: None
130  */
131 void dp_tx_deinit_bank_profiles(struct dp_soc_be *soc);
132 
133 /**
134  * dp_tx_get_bank_profile() - get TX bank profile for vdev
135  * @soc: DP soc handle
136  * @be_vdev: BE vdev pointer
137  *
138  * Return: bank profile allocated to vdev or DP_BE_INVALID_BANK_ID
139  */
140 int dp_tx_get_bank_profile(struct dp_soc_be *soc,
141 			   struct dp_vdev_be *be_vdev);
142 
143 /**
144  * dp_tx_put_bank_profile() - release TX bank profile for vdev
145  * @soc: DP soc handle
146  *
147  * Return: None
148  */
149 void dp_tx_put_bank_profile(struct dp_soc_be *soc, struct dp_vdev_be *be_vdev);
150 
151 /**
152  * dp_tx_update_bank_profile() - release existing and allocate new bank profile
153  * @soc: DP soc handle
154  * @be_vdev: pointer to be_vdev structure
155  *
156  * The function releases the existing bank profile allocated to the vdev and
157  * looks for a new bank profile based on updated dp_vdev TX params.
158  *
159  * Return: None
160  */
161 void dp_tx_update_bank_profile(struct dp_soc_be *be_soc,
162 			       struct dp_vdev_be *be_vdev);
163 
164 /**
165  * dp_tx_desc_pool_init_be() - Initialize Tx Descriptor pool(s)
166  * @soc: Handle to DP Soc structure
167  * @num_elem: number of descriptor in pool
168  * @pool_id: pool ID to allocate
169  *
170  * Return: QDF_STATUS_SUCCESS - success, others - failure
171  */
172 QDF_STATUS dp_tx_desc_pool_init_be(struct dp_soc *soc,
173 				   uint32_t num_elem,
174 				   uint8_t pool_id);
175 /**
176  * dp_tx_desc_pool_deinit_be() - De-initialize Tx Descriptor pool(s)
177  * @soc: Handle to DP Soc structure
178  * @tx_desc_pool: Tx descriptor pool handler
179  * @pool_id: pool ID to deinit
180  *
181  * Return: None
182  */
183 void dp_tx_desc_pool_deinit_be(struct dp_soc *soc,
184 			       struct dp_tx_desc_pool_s *tx_desc_pool,
185 			       uint8_t pool_id);
186 
187 #ifdef WLAN_FEATURE_11BE_MLO
188 /**
189  * dp_tx_mlo_mcast_handler_be() - Tx handler for Mcast packets
190  * @soc: Handle to DP Soc structure
191  * @vdev: DP vdev handle
192  * @nbuf: nbuf to be enqueued
193  *
194  * Return: None
195  */
196 void dp_tx_mlo_mcast_handler_be(struct dp_soc *soc,
197 				struct dp_vdev *vdev,
198 				qdf_nbuf_t nbuf);
199 #ifdef WLAN_MCAST_MLO
200 #ifdef WLAN_MLO_MULTI_CHIP
201 /**
202  * dp_tx_mlo_mcast_pkt_send() - handler to send MLO Mcast packets
203  * @be_vdev: Handle to DP be_vdev structure
204  * @ptnr_vdev: DP ptnr_vdev handle
205  * @nbuf: nbuf to be enqueued
206  *
207  * Return: None
208  */
209 void dp_tx_mlo_mcast_pkt_send(struct dp_vdev_be *be_vdev,
210 			      struct dp_vdev *ptnr_vdev,
211 			      void *arg);
212 
213 /**
214  * dp_tx_mcast_mlo_reinject_routing_set() - mlo mcast reinject routing handler
215  * @be_vdev: Handle to DP be_vdev structure
216  * @cmd: cmd to set TQM/FW based reinjection
217  *
218  * Return: None
219  */
220 void dp_tx_mcast_mlo_reinject_routing_set(struct dp_soc *soc, void *arg);
221 #endif
222 #endif
223 #endif
224 
225 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
226 /**
227  * dp_tx_comp_nf_handler() - Tx completion ring Near full scenario handler
228  * @int_ctx: Interrupt context
229  * @soc: Datapath SoC handle
230  * @hal_ring_hdl: TX completion ring handle
231  * @ring_id: TX completion ring number
232  * @quota: Quota of the work to be done
233  *
234  * Return: work done
235  */
236 uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
237 			       hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
238 			       uint32_t quota);
239 #else
240 static inline
241 uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
242 			       hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
243 			       uint32_t quota)
244 {
245 	return 0;
246 }
247 #endif /* WLAN_FEATURE_NEAR_FULL_IRQ */
248 
249 /**
250  * dp_tx_compute_tx_delay_be() - Compute HW Tx completion delay
251  * @soc: Handle to DP Soc structure
252  * @vdev: vdev
253  * @ts: Tx completion status
254  * @delay_us: Delay to be calculated in microseconds
255  *
256  * Return: QDF_STATUS
257  */
258 QDF_STATUS dp_tx_compute_tx_delay_be(struct dp_soc *soc,
259 				     struct dp_vdev *vdev,
260 				     struct hal_tx_completion_status *ts,
261 				     uint32_t *delay_us);
262 #endif
263