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